merge with develop

This commit is contained in:
2022-03-16 16:49:04 +02:00
9 changed files with 991 additions and 1237 deletions

View File

@ -1,9 +1,8 @@
package com.safemobile.activities;
import java.util.ArrayList;
import java.util.Hashtable;
import android.app.TabActivity;
import android.content.BroadcastReceiver;
import com.safemobile.bluetooth.BluetoothTether;
import com.safemobile.lib.AppParams;
import com.safemobile.lib.SM;
import com.safemobile.lib.SuperVehicle;
@ -11,43 +10,21 @@ import com.safemobile.lib.Vehicle;
import com.safemobile.services.TCPhandler;
import com.safemobile.services.TCPmsgParser;
import android.app.Activity;
import android.app.NotificationManager;
import android.app.TabActivity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.os.Handler;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import java.util.ArrayList;
import java.util.Hashtable;
@SuppressWarnings("deprecation")
public abstract class AbstractSDParentActivity extends TabActivity {
/** UI Elements */
public RelativeLayout layoutLoading;
public ImageView imageViewLoading;
/** Misc */
public Activity activity;
public Context context;
public NotificationManager mNotificationManager;
public boolean displayLogCat = true; // show logCat messages when TCP send was successful
public String imei, mess;
private static final boolean SHOULD_DISPLAY_LOGCAT = true; // show logCat messages when TCP send was successful
private String imei;
private String mess;
public int demoPosition = 0;
/** Lists */
public ArrayList<Vehicle> allVehicle = new ArrayList<Vehicle>();
public Hashtable<Long, SuperVehicle> SuperVehHash = new Hashtable<Long, SuperVehicle>();
public Hashtable<Long, Vehicle> VehHashbySc_id = new Hashtable<Long, Vehicle>();
/** Handler */
public Handler myHandler = new Handler();
/** BlueTooth Tether */
public BluetoothTether bluetoothTether = null;
/** Broadcast Receiver */
public BroadcastReceiver mReceiver = null;
private ArrayList<Vehicle> allVehicle = new ArrayList<>();
private Hashtable<Long, SuperVehicle> superVehHash = new Hashtable<>();
private Hashtable<Long, Vehicle> vehHashByScId = new Hashtable<>();
/** TCP */
protected TCPhandler tcp = null;
@ -66,9 +43,9 @@ public abstract class AbstractSDParentActivity extends TabActivity {
public Object getTCPState() {
// return true if tcp connection is on, false if not connected and null
if(tcp!=null && tcp.isConnectionUP)
if (tcp != null && tcp.isConnectionUP)
return "true";
else if(tcp!=null && !tcp.isConnectionUP)
else if (tcp != null)
return "false";
return null;
}
@ -84,83 +61,78 @@ public abstract class AbstractSDParentActivity extends TabActivity {
public abstract void updateDemoPosition();
public abstract void updateResultsPollInUi(String type);
public abstract double best_zoom(double LATMAX,double LATmin,double LNGMAX,double LNGmin);
public abstract double best_zoom(double latMax,double latMin,double lngMax,double lngMin);
/* SafeDispatch Mobile functions */
/** get Vehicles for an user id */
public boolean getVehicles(int userID)
{
if(tcp == null)
public boolean getVehicles(int userID) {
if (tcp == null)
return false;
boolean res = tcp.Write("0.0", "#21#" + AppParams.USERID + "#");
if(res && displayLogCat)
boolean res = tcp.Write("0.0", "#21#" + userID + "#");
if (res && SHOULD_DISPLAY_LOGCAT)
SM.Debug("Message (getVehs) sent to app server");
else
SM.Debug("Could not send message(getVehs)!!");
return res;
}
/** get vehicles Last Positions for an user id */
public boolean getLastPositions(int userID)
{
if(tcp == null)
public boolean getLastPositions(int userID) {
if (tcp == null)
return false;
boolean res = tcp.Write("0.0", "#25#" + userID + "#");
if(res && displayLogCat)
if (res && SHOULD_DISPLAY_LOGCAT)
SM.Debug("Message (getLastPOS) sent to app server");
else
SM.Debug("Could not send message(getLastSMS)!!");
return res;
}
/** set Enable/Disable a vehicle */
public boolean setVehicleStatus(int radioCode, int opCode, int sc_id, int enable)
{
if(tcp == null)
public boolean setVehicleStatus(int radioCode, int opCode, int sc_id, int enable) {
if (tcp == null)
return false;
boolean res = tcp.Write("0.0", "#"+radioCode+"#"+opCode+"#" + sc_id+"#" + enable + "#");
if(res && displayLogCat)
SM.Debug("Message (Option4Unit) sent to app server radioCode:"+radioCode+ " opCode:"+opCode+ " sc_id:"+sc_id+ " value:" + enable);
boolean res = tcp.Write("0.0", "#" + radioCode + "#" + opCode + "#" + sc_id + "#" + enable + "#");
if (res && SHOULD_DISPLAY_LOGCAT)
SM.Debug("Message (Option4Unit) sent to app server radioCode:" + radioCode + " opCode:" + opCode + " sc_id:" + sc_id + " value:" + enable);
else
SM.Debug("Could not send message(Option4Unit)!!");
return res;
}
/** get Last SMSs for an user */
public boolean getLastSMSs(int userID)
{
if(tcp == null)
public boolean getLastSMSs(int userID) {
if (tcp == null)
return false;
boolean res = tcp.Write("0.0", "#23#" + userID + "#");
if(res && displayLogCat)
if (res && SHOULD_DISPLAY_LOGCAT)
SM.Debug("#Send Request#", "Message [getLastSMSs] sent to app server");
else
SM.Debug("#Send Request#", "Could not send message [getLastSMSs]!!");
return res;
}
/** get SMSs for an user that are recent than timeGMT
* @param sc_id the vehicle imei for which we want the SMSs
* @param timeGMT the unix time for the last message in the grid or messages that are newer than this time */
public boolean getRecentSMSs(int sc_id, long timeGMT)
{
if(tcp == null)
public boolean getRecentSMSs(int sc_id, long timeGMT) {
if (tcp == null)
return false;
boolean res = tcp.Write("0.0", "#22#"+sc_id+"#" +timeGMT+"#");
if(res && displayLogCat)
boolean res = tcp.Write("0.0", "#22#" + sc_id + "#" + timeGMT + "#");
if (res && SHOULD_DISPLAY_LOGCAT)
SM.Debug("#Send Request#", "Message [getRecentSMSs] sent to app server");
else
SM.Debug("#Send Request#", "Could not send message [getRecentSMSs]!!");
return res;
}
@ -174,7 +146,7 @@ public abstract class AbstractSDParentActivity extends TabActivity {
return false;
boolean res = tcp.Write(seqID, "#24#" + AppParams.USERID + "#" + sc_id + "#" + txt + "#");
if(res && displayLogCat)
if(res && SHOULD_DISPLAY_LOGCAT)
SM.Debug("Message [sendSMS] sent to app server sc_id:"+sc_id+ " txt:"+txt);
else
SM.Debug("Could not send message [sendSMS]!!");
@ -183,16 +155,16 @@ public abstract class AbstractSDParentActivity extends TabActivity {
}
public boolean sendAlarmAcknoledge(int alarm_id, int type)
public boolean sendAlarmAcknowledge(int alarm_id, int type)
{
if(tcp == null)
return false;
boolean res = tcp.Write("0.0", "#28#" + alarm_id + "#" + type + "#");
if(res)
SM.Debug("Message [sendAlarmAcknoledge] sent to app server alarm_id:" + alarm_id + " type:" + type);
SM.Debug("Message [sendAlarmAcknowledge] sent to app server alarm_id:" + alarm_id + " type:" + type);
else
SM.Debug("Could not send message [sendAlarmAcknoledge]!!");
SM.Debug("Could not send message [sendAlarmAcknowledge]!!");
return res;
}
@ -290,7 +262,7 @@ public abstract class AbstractSDParentActivity extends TabActivity {
if(tcp == null)
return false;
boolean res = tcp.Write("0.0", "#27#" + userID + "#"); // = tcp.Write("0.0", "#30#99#" + gwID + "#" + rgwID + "#");
boolean res = tcp.Write("0.0", "#27#" + userID + "#");
if(res)
SM.Debug("Message [GetAlarms] sent to app server");
else
@ -313,11 +285,45 @@ public abstract class AbstractSDParentActivity extends TabActivity {
return res;
}
//public abstract void getVehiclePosition(long imei);
/*
public abstract void onResume();
public abstract void onStart();
public abstract void onPause();
*/
public String getImei() {
return imei;
}
public void setImei(String imei) {
this.imei = imei;
}
public String getMess() {
return mess;
}
public void setMess(String mess) {
this.mess = mess;
}
/** Lists */
public ArrayList<Vehicle> getAllVehicle() {
return allVehicle;
}
public void setAllVehicle(ArrayList<Vehicle> allVehicle) {
this.allVehicle = allVehicle;
}
public Hashtable<Long, SuperVehicle> getSuperVehHash() {
return superVehHash;
}
public void setSuperVehHash(Hashtable<Long, SuperVehicle> superVehHash) {
this.superVehHash = superVehHash;
}
public Hashtable<Long, Vehicle> getVehHashByScId() {
return vehHashByScId;
}
public void setVehHashByScId(Hashtable<Long, Vehicle> vehHashByScId) {
this.vehHashByScId = vehHashByScId;
}
}