1st version that works
This commit is contained in:
47
libSafeMobile/src/main/java/com/safemobile/lib/Alarm.java
Normal file
47
libSafeMobile/src/main/java/com/safemobile/lib/Alarm.java
Normal file
@ -0,0 +1,47 @@
|
||||
package com.safemobile.lib;
|
||||
|
||||
public class Alarm {
|
||||
public int idx;
|
||||
public String unitName;
|
||||
public int type;
|
||||
public String typestr;
|
||||
public String description;
|
||||
public long timeGMT;
|
||||
public int ack;
|
||||
public long sc_id;
|
||||
|
||||
public Alarm()
|
||||
{
|
||||
}
|
||||
|
||||
public Alarm(int idx, int type, String description, int timeGMT, int ack, int sc_id)
|
||||
{
|
||||
this.idx = idx;
|
||||
this.sc_id = sc_id;
|
||||
this.type = type;
|
||||
this.description = description;
|
||||
this.timeGMT = timeGMT;
|
||||
this.ack = ack;
|
||||
switch (this.type)
|
||||
{
|
||||
case 0: typestr = "emergency";
|
||||
break;
|
||||
case 1: typestr = "landmark";
|
||||
break;
|
||||
case 2: typestr = "zone";
|
||||
break;
|
||||
case 3: typestr = "speed";
|
||||
break;
|
||||
case 4: typestr = "telemetry";
|
||||
break;
|
||||
default:
|
||||
typestr = "emergency";
|
||||
}
|
||||
this.unitName = "Empty";
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "idx: " + idx + " | sc_id: " + sc_id + " | type: " + type + " | description: " + description + " | timeGMT: " + timeGMT + " | ack:" + ack + " | typestr:" + typestr+" | unitName:" + unitName;
|
||||
}
|
||||
}
|
34
libSafeMobile/src/main/java/com/safemobile/lib/AlarmMSG.java
Normal file
34
libSafeMobile/src/main/java/com/safemobile/lib/AlarmMSG.java
Normal file
@ -0,0 +1,34 @@
|
||||
package com.safemobile.lib;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class AlarmMSG extends TCPmsg {
|
||||
|
||||
public ArrayList<Alarm> alarmList;
|
||||
public static int count=0;
|
||||
public AlarmMSG(TCPmsg tcp) {
|
||||
super(tcp);
|
||||
alarmList = new ArrayList<Alarm>();
|
||||
String date4parsing = super.data;
|
||||
//SM.Debug("SMS date4parsing:"+date4parsing);
|
||||
String[] tempArr = date4parsing.split(";");
|
||||
|
||||
//SM.Debug("SMS tempArr.length:" +tempArr.length);
|
||||
for(int i =0; i<tempArr.length;i++)
|
||||
{
|
||||
String[] tempVeh = tempArr[i].split("&");
|
||||
if(tempVeh.length<6)
|
||||
continue;
|
||||
//int idx, int type, String description, int timeGMT, int ack, int sc_id
|
||||
Alarm alarm = new Alarm(Integer.parseInt(tempVeh[1]),Integer.parseInt(tempVeh[5]),tempVeh[3],Integer.parseInt(tempVeh[4]),
|
||||
Integer.parseInt(tempVeh[0]),Integer.parseInt(tempVeh[2]));
|
||||
|
||||
alarmList.add(alarm);
|
||||
//SM.Debug(alarm.toString());
|
||||
}
|
||||
|
||||
count +=this.alarmList.size();
|
||||
SM.Debug("alarmList size:" +this.alarmList.size() + " total:" +count);
|
||||
}
|
||||
|
||||
}
|
194
libSafeMobile/src/main/java/com/safemobile/lib/AppParams.java
Normal file
194
libSafeMobile/src/main/java/com/safemobile/lib/AppParams.java
Normal file
@ -0,0 +1,194 @@
|
||||
package com.safemobile.lib;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Hashtable;
|
||||
|
||||
import com.safemobile.lib.radio.Channel;
|
||||
import com.safemobile.lib.radio.Emerg;
|
||||
import com.safemobile.lib.radio.IncCall;
|
||||
import com.safemobile.lib.radio.RadioGW;
|
||||
import com.safemobile.lib.radio.RadioStatus;
|
||||
import com.safemobile.lib.radio.Zone;
|
||||
import com.safemobile.lib.radio.Zone_and_channel;
|
||||
import com.safemobile.libpad.PadRecording;
|
||||
import com.safemobile.libpad.PadTextMessage;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
|
||||
public class AppParams {
|
||||
|
||||
public enum EnumCallState {hangTime, callEnd, online, offline, callReceived, callMade };
|
||||
public enum Dialogs {motionless, mandown, firmware, password};
|
||||
public enum Tabs {live, history, radio, message, alarms, recordings, setup};
|
||||
public enum Theme {SAFENET, SAFEDISPATCH, HYTERA, VISION}
|
||||
public enum ActivityResult { logout, restart, exit, tcpDown};
|
||||
|
||||
/* SafeMobile Dispatch */
|
||||
public static ArrayList<User> allUsers = new ArrayList<User>();
|
||||
public static Theme theme = Theme.SAFENET; // the Theme type
|
||||
|
||||
|
||||
/* ***************************************** */
|
||||
/* ********** Radio Status Params ********** */
|
||||
/* ***************************************** */
|
||||
public static RadioStatus crtRadioStatus = new RadioStatus();
|
||||
public static Zone_and_channel crtZoneAndChannel = new Zone_and_channel();
|
||||
public static Emerg crtEmergencyState = new Emerg();
|
||||
public static IncCall crtIncCall = new IncCall();
|
||||
public static PadRecording crtPlayingRecording = new PadRecording();
|
||||
public static ByteBuffer recordingBuffer = null;
|
||||
//public static ArrayList<PadTextMessage> listTextMessages = new ArrayList<PadTextMessage>();
|
||||
public static Hashtable<String, PadTextMessage> hashNotAckMsg = new Hashtable<String, PadTextMessage>();
|
||||
|
||||
// the text message hash table will have the first key the radioID, and the second key the textMessage DB ID
|
||||
public static Hashtable<Long, Hashtable<Long, PadTextMessage>> hashTextMessagesByRadioID = new Hashtable<Long, Hashtable<Long, PadTextMessage>>();
|
||||
|
||||
//public static ArrayList<PadRecording> listRecordings = new ArrayList<PadRecording>();
|
||||
public static Hashtable<Integer, PadRecording> listRecordings = new Hashtable<Integer, PadRecording>();
|
||||
public static ArrayList<Recording> recordings = new ArrayList<Recording>();
|
||||
public static ArrayList<Contact> listContacts = new ArrayList<Contact>();
|
||||
public static ArrayList<Zone> listZones = new ArrayList<Zone>();
|
||||
public static ArrayList<RadioGW> listRadios = new ArrayList<RadioGW>();
|
||||
public static Radio crtRadio = new Radio();
|
||||
public static Zone crtZone = new Zone();
|
||||
public static Channel crtChannel;
|
||||
|
||||
public static PadTextMessage crtSentTextMessage = new PadTextMessage();
|
||||
public static PadTextMessage crtAckedTextMessage = new PadTextMessage();
|
||||
public static PadTextMessage crtReceivedTextMessage = new PadTextMessage();
|
||||
|
||||
public static Contact crtContact = new Contact();
|
||||
public static Contact crtTetraContact = new Contact();
|
||||
public static Contact crtTetraGroup = new Contact();
|
||||
public static PadRecording crtRecording = new PadRecording();
|
||||
|
||||
|
||||
public static final int TRBOO = 1, TETRA = 2, SEPURAA = 3;
|
||||
public static final int NOT_ACK = 1;
|
||||
public static final int ACK = 2;
|
||||
public static int APPLICATION_TYPE = TRBOO; // WILL BE MODIFIED AT CONNECTION
|
||||
public static final String FIRMWARE_VERSION = "2.3.1";
|
||||
|
||||
public static boolean DEMO = false; // DEMO is set by package name (contains OR !contains "demo")
|
||||
|
||||
/** Safenet Login */
|
||||
public static long USERID = -1;
|
||||
public static String USERNAME = "";
|
||||
public static String PASSWORD = "";
|
||||
public static boolean REMEMBER = false;
|
||||
public static String DEFAULT = "";
|
||||
|
||||
//private String[] Types = {"AIR", "RADIOPAD", "MOTOPAD-TRBO", "MOTOPAD-TETRA"};
|
||||
public static String TYPE = "RADIOPAD"; // blue or red version (SafeMobile or AIR version)
|
||||
//public static boolean AIR = false; // blue or red version (SafeMobile or AIR version)
|
||||
public static boolean TABLET = false; // flag if device is a TABLET or PHONE (inconsistent - 06.Nov.2012)
|
||||
public static boolean PAUSED = false; // application status: PAUSED or RUNNING
|
||||
|
||||
public static boolean SEPURA = false;
|
||||
public static boolean PRINTER = false;
|
||||
|
||||
public static int UPDATE_SIZE = 20;
|
||||
|
||||
public static String Database = ""; //"de"; // database language
|
||||
public static boolean online = false;
|
||||
|
||||
/** Tabs */
|
||||
public static Tabs crtTab = Tabs.radio;
|
||||
|
||||
public static int CallState = 3; // tablet state: 7 - Hangtime, 3 - Ended, Other - inCall
|
||||
public static long CallSourId = -1;
|
||||
public static long CallDestId = -1;
|
||||
public static int CallType = 101;
|
||||
public static long selCallId = -1;
|
||||
public static int selCallType = 101;
|
||||
public static long CallStartTime = -1;
|
||||
public static int prevCallState = 4;
|
||||
public static boolean inCall = false;
|
||||
public static boolean externalSource = false;
|
||||
|
||||
/** Configuration File */
|
||||
//public static ConfigFile configFile = null; // config file
|
||||
|
||||
/** Database */
|
||||
//public static DatabaseCommunication databaseCommunication = null;
|
||||
|
||||
/** SharedPreferences */
|
||||
public static SharedPreferences prefs; // project preferences
|
||||
public static String LANGUAGE; // displaying language
|
||||
public static String LANGUAGETMP = "en"; // temporary displayed language
|
||||
public static String STREAM = "MUSIC"; // AudioHandler's AudioTrack default stream
|
||||
public static String SOURCE = "TCP"; // AudioHandler's AudioTrack default source
|
||||
public static boolean EXTERNALMIC = false; // external mic used with what-a-pair systems
|
||||
public static boolean TETHERSOUND = false; // allow BlueTooth tethering
|
||||
public static boolean TRBO = true;
|
||||
public static boolean NOTIFICATIONS = true;
|
||||
public static boolean RECORDINGS = true;
|
||||
public static String RECORDINGS_LOCATION = "Internal Storage";
|
||||
public static boolean MANDOWN = false;
|
||||
public static int MANDOWNTHRESHOLD = 25;
|
||||
public static boolean MOTIONLESS = false;
|
||||
public static int MOTIONLESSTIME = 300;
|
||||
public static int RADIOID = 100;
|
||||
public static String RADIOIP = "192.168.10.40";
|
||||
public static String IP="n/a"; // SafeBridge's IP
|
||||
public static String PORT="13570"; // SafeBridge's PORT
|
||||
public static String PATH = "n/a"; // ConfigFile PATH
|
||||
|
||||
/** BluComm
|
||||
* states : 0 - disconnected; 1 - connected but not pressed; 2 - pressed; */
|
||||
public static int BluCommState = 0; // remembers BluComm Microphone state
|
||||
public static final int PTTON = 1;
|
||||
public static final int PTTOFF = 0;
|
||||
|
||||
/** Call Types */
|
||||
public static final int AllCall = 101;
|
||||
public static final int PrivateCall = 102;
|
||||
public static final int GroupCall = 103;
|
||||
public static final int EndAllCall = AllCall+10;
|
||||
public static final int EndPrivateCall = PrivateCall+10;
|
||||
public static final int EndGroupCall = GroupCall+10;
|
||||
public static final int PTTBUTTON = 999;
|
||||
public static final int VOXON = 555;
|
||||
public static final int VOXOFF = 000;
|
||||
|
||||
/* Old Values
|
||||
public static final int Decoded = 1;
|
||||
public static final int InProgress = 2;
|
||||
public static final int Initiated = 4;
|
||||
public static final int Hangtime = 7;
|
||||
public static final int Ended = 3;
|
||||
public static final int InitButton = 5;
|
||||
public static final int MotoPrivate = 4;
|
||||
public static final int MotoGroup = 6;
|
||||
public static final int MotoAllCall = 16777215;
|
||||
//*/
|
||||
|
||||
//* New Values
|
||||
public static final int Initiated = 0;
|
||||
public static final int Decoded = 1;
|
||||
public static final int InProgress = 2;
|
||||
public static final int Hangtime = 3;
|
||||
public static final int Ended = 4;
|
||||
public static final int InitEnded = 5;
|
||||
public static final int InitHangtime = 6;
|
||||
public static final int MotoPrivate = 1;
|
||||
public static final int MotoGroup = 2;
|
||||
public static final int MotoAllCall = 3;
|
||||
public static final int MotoManualDial = 4;
|
||||
//*/
|
||||
|
||||
|
||||
/** BlueTooth Headset MAC */
|
||||
public static String BluCom = "00:15:45:";
|
||||
/*
|
||||
public static String MotorolaH730 = "00:24:1C:";
|
||||
public static String SamsungWep460 = "18:46:17:";
|
||||
*/
|
||||
|
||||
/** Notification values */
|
||||
public static final int messageNotif = 1;
|
||||
public static final int alertNotif = 2;
|
||||
public static final int pollNotif = 3;
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package com.safemobile.lib;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.safemobile.lib.radio.Zone;
|
||||
|
||||
public class ConfigFile {
|
||||
public ArrayList<Contact> contacts;
|
||||
public Radio radio;
|
||||
public ArrayList<Zone> zones;
|
||||
|
||||
public ConfigFile()
|
||||
{
|
||||
contacts = new ArrayList<Contact>();
|
||||
zones = new ArrayList<Zone>();
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "Contacts: " + contacts.size() + " | Radio: " + radio.toString() + " | Zones: " + zones.size();
|
||||
}
|
||||
|
||||
public String toLongString()
|
||||
{
|
||||
String cont = "", zone="";
|
||||
for(Contact contact: contacts)
|
||||
cont += "Name: " + contact.name + " | Id: " + contact.id + "\n";
|
||||
|
||||
for(Zone zonee: zones)
|
||||
zone += "Name: " + zonee.ZoneName + " | Id: " + zonee.id + "\n";
|
||||
|
||||
return "# Contacts #\n" + cont + "# Radio #\n" + radio.toString() + "\n# Zones #\n" + zone;
|
||||
}
|
||||
}
|
94
libSafeMobile/src/main/java/com/safemobile/lib/Contact.java
Normal file
94
libSafeMobile/src/main/java/com/safemobile/lib/Contact.java
Normal file
@ -0,0 +1,94 @@
|
||||
package com.safemobile.lib;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Contact {
|
||||
public int dbID = 0;
|
||||
public long id = 0;
|
||||
public String name = "";
|
||||
public int contactType = 0;
|
||||
public int parentDB_ID = 0;
|
||||
|
||||
public static final int PRIVATE = 1;
|
||||
public static final int GROUP = 2;
|
||||
public static final int ALL = 3;
|
||||
public static final int ZONE = 4;
|
||||
public static final int CHANNEL = 5;
|
||||
|
||||
|
||||
|
||||
public Contact()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Contact(long _id, String _name, int _contactType, int dbID, int parentDB_id)
|
||||
{
|
||||
id = _id;
|
||||
name = _name;
|
||||
contactType = _contactType;
|
||||
this.dbID = dbID;
|
||||
this.parentDB_ID = parentDB_id;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return id + ". " + name + " [" + getContactType(contactType) + "]";
|
||||
}
|
||||
|
||||
|
||||
private String getContactType(int contactType) {
|
||||
switch(contactType) {
|
||||
case PRIVATE: return "PRIVATE";
|
||||
case GROUP: return "GROUP";
|
||||
case ALL: return "ALL CALL";
|
||||
case ZONE: return "ZONE";
|
||||
case CHANNEL: return "CHANNEL";
|
||||
default: return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
public static ArrayList<Contact> parseTCPMsg(String msg) {
|
||||
|
||||
ArrayList<Contact> contacts = new ArrayList<Contact>();
|
||||
try
|
||||
{
|
||||
msg = msg.replace("#", "");
|
||||
// split payload to get contacts
|
||||
|
||||
// split contact by /
|
||||
String[] contArr = msg.split("/");
|
||||
Contact ct = new Contact();
|
||||
ct.dbID = Integer.parseInt(contArr[0]);
|
||||
ct.id = Long.parseLong(contArr[1]);
|
||||
ct.name = contArr[2];
|
||||
ct.contactType = Integer.parseInt(contArr[4]);
|
||||
ct.parentDB_ID = Integer.parseInt(contArr[3]);
|
||||
|
||||
contacts.add(ct);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
SM.Exception("Exception parse Contacts", ex.toString());
|
||||
}
|
||||
|
||||
return contacts;
|
||||
/*
|
||||
int id = 1;
|
||||
|
||||
// this will select the type
|
||||
switch(AppParams.APPLICATION_TYPE * 10 + id) {
|
||||
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public static String getNameForRadioID(ArrayList<Contact> listUnits, long radioID) {
|
||||
for(Contact ctc: listUnits)
|
||||
if(ctc.id == radioID && (ctc.contactType == Contact.PRIVATE))
|
||||
return ctc.name;
|
||||
|
||||
// if contact wasn't found I should return it's radioID
|
||||
return radioID+"";
|
||||
}
|
||||
}
|
19
libSafeMobile/src/main/java/com/safemobile/lib/GPS.java
Normal file
19
libSafeMobile/src/main/java/com/safemobile/lib/GPS.java
Normal file
@ -0,0 +1,19 @@
|
||||
package com.safemobile.lib;
|
||||
|
||||
public class GPS {
|
||||
|
||||
public long imei=0;
|
||||
public double lat=0;
|
||||
public double lng=0;
|
||||
public int speed=0;
|
||||
public long timeGMT=0;
|
||||
|
||||
public GPS(){
|
||||
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "imei: " + imei + " | LAT: " + lat + " | LNG: " + lng + " | speed: " + speed + " | timeGMT: " + timeGMT;
|
||||
}
|
||||
}
|
24
libSafeMobile/src/main/java/com/safemobile/lib/GPSmsg.java
Normal file
24
libSafeMobile/src/main/java/com/safemobile/lib/GPSmsg.java
Normal file
@ -0,0 +1,24 @@
|
||||
package com.safemobile.lib;
|
||||
|
||||
public class GPSmsg extends TCPmsg {
|
||||
|
||||
public GPS gpsValue;
|
||||
public static int count=0;
|
||||
public GPSmsg(TCPmsg tcp)
|
||||
{
|
||||
super(tcp);
|
||||
String date4parsing = super.data;
|
||||
//SM.Debug("SMS date4parsing:"+date4parsing);
|
||||
String[] tempVeh = date4parsing.split("#");
|
||||
gpsValue = new GPS();
|
||||
gpsValue.imei = Long.parseLong(tempVeh[0]);
|
||||
gpsValue.lat = Double.parseDouble(tempVeh[3]);
|
||||
gpsValue.lng = Double.parseDouble(tempVeh[4]);
|
||||
gpsValue.speed = Integer.parseInt(tempVeh[2]);
|
||||
gpsValue.timeGMT = Long.parseLong(tempVeh[1]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,22 @@
|
||||
package com.safemobile.lib;
|
||||
|
||||
public class HistCount {
|
||||
public String seq_id;
|
||||
public long count;
|
||||
|
||||
public HistCount()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public HistCount(String _seq_id, long _count)
|
||||
{
|
||||
seq_id = _seq_id;
|
||||
count = _count;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "seq_id: " + seq_id + " | count: " + count;
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.safemobile.lib;
|
||||
|
||||
public class HistCountmsg extends TCPmsg {
|
||||
|
||||
public HistCount histcountValue;
|
||||
public long count=0;
|
||||
public HistCountmsg(TCPmsg tcp)
|
||||
{
|
||||
super(tcp);
|
||||
String date4parsing = super.data;
|
||||
//SM.Debug("SMS date4parsing:"+date4parsing);
|
||||
//String[] tempVeh = date4parsing.split("#");
|
||||
date4parsing = date4parsing.replace("#", "");
|
||||
histcountValue = new HistCount();
|
||||
histcountValue.count = Long.parseLong(date4parsing);
|
||||
histcountValue.seq_id = super.seqID;
|
||||
}
|
||||
}
|
75
libSafeMobile/src/main/java/com/safemobile/lib/HistPos.java
Normal file
75
libSafeMobile/src/main/java/com/safemobile/lib/HistPos.java
Normal file
@ -0,0 +1,75 @@
|
||||
package com.safemobile.lib;
|
||||
|
||||
|
||||
public class HistPos {
|
||||
|
||||
public double lat=0;
|
||||
public double lng=0;
|
||||
public int speed=0;
|
||||
public long timeGMT=0;
|
||||
public String Address="";
|
||||
public int heading=0;
|
||||
|
||||
public HistPos(){
|
||||
|
||||
}
|
||||
|
||||
public HistPos(double _lat, double _lng, int _speed, long _timeGMT){
|
||||
lat = _lat;
|
||||
lng = _lng;
|
||||
speed = _speed;
|
||||
timeGMT = _timeGMT;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return " LAT: " + lat + " | LNG: " + lng + " | speed: " + speed + " | timeGMT: " + timeGMT + " | Address: " + Address;
|
||||
}
|
||||
|
||||
|
||||
public int GetIconHead()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (((heading >= 0) && (heading < 11.25)) || ((heading > 348.75) && (heading <= 360)))
|
||||
return R.drawable.arrow_e;
|
||||
else if ((heading >= 11.25) && (heading < 33.75))
|
||||
return R.drawable.arrow_ene;
|
||||
else if ((heading >= 33.75) && (heading < 56.25))
|
||||
return R.drawable.arrow_ne;
|
||||
else if ((heading >= 56.25) && (heading < 78.75))
|
||||
return R.drawable.arrow_nne;
|
||||
else if ((heading >= 78.75) && (heading < 101.25))
|
||||
return R.drawable.arrow_n;
|
||||
else if ((heading >= 101.25) && (heading < 123.75))
|
||||
return R.drawable.arrow_nnv;
|
||||
else if ((heading >= 123.75) && (heading < 146.25))
|
||||
return R.drawable.arrow_nv;
|
||||
else if ((heading >= 146.25) && (heading < 168.75))
|
||||
return R.drawable.arrow_vnv;
|
||||
else if ((heading >= 168.75) && (heading < 191.25))
|
||||
return R.drawable.arrow_v;
|
||||
else if ((heading >= 191.25) && (heading < 213.75))
|
||||
return R.drawable.arrow_vsv;
|
||||
else if ((heading >= 213.75) && (heading < 236.25))
|
||||
return R.drawable.arrow_sv;
|
||||
else if ((heading >= 236.25) && (heading < 258.75))
|
||||
return R.drawable.arrow_ssv;
|
||||
else if ((heading >= 258.75) && (heading < 281.25))
|
||||
return R.drawable.arrow_s;
|
||||
else if ((heading >= 281.25) && (heading < 303.75))
|
||||
return R.drawable.arrow_sse;
|
||||
else if ((heading >= 303.75) && (heading < 326.25))
|
||||
return R.drawable.arrow_se;
|
||||
else if ((heading >= 326.25) && (heading < 348.75))
|
||||
return R.drawable.arrow_ese;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
catch (Exception e) {
|
||||
SM.Debug("Erorr on select Arrows");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
126
libSafeMobile/src/main/java/com/safemobile/lib/HistPosmsg.java
Normal file
126
libSafeMobile/src/main/java/com/safemobile/lib/HistPosmsg.java
Normal file
@ -0,0 +1,126 @@
|
||||
package com.safemobile.lib;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
//Date data = Calendar.getInstance().getTime();
|
||||
//data.getTime();
|
||||
|
||||
public class HistPosmsg extends TCPmsg {
|
||||
|
||||
public ArrayList<HistPos> PosList;
|
||||
public int count=0;
|
||||
public HistPosmsg(TCPmsg tcp) {
|
||||
super(tcp);
|
||||
PosList = new ArrayList<HistPos>();
|
||||
try{
|
||||
String date4parsing = super.data;
|
||||
//SM.Debug("SMS date4parsing:"+date4parsing);
|
||||
String[] tempArr = date4parsing.split(";");
|
||||
//SM.Debug("SMS tempArr.length:" +tempArr.length);
|
||||
for(int i =0; i<tempArr.length;i++)
|
||||
{
|
||||
String[] tempVeh = tempArr[i].split("&");
|
||||
|
||||
if(tempVeh.length<6)
|
||||
continue;
|
||||
HistPos tmpLast = new HistPos();
|
||||
tmpLast.lat = Double.parseDouble(tempVeh[1]);
|
||||
tmpLast.lng = Double.parseDouble(tempVeh[2]);
|
||||
tmpLast.speed = Integer.parseInt(tempVeh[3]);
|
||||
tmpLast.timeGMT = Long.parseLong(tempVeh[5]);
|
||||
tmpLast.Address = tempVeh[6];
|
||||
//tmpLast.Address = "";
|
||||
|
||||
PosList.add(tmpLast);
|
||||
//SM.Debug("duda",tmpLast.toString());
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
SM.Debug("Error on parse hisotry:"+e.toString());
|
||||
}
|
||||
CalcHeadingForArray(PosList);
|
||||
count +=this.PosList.size();
|
||||
SM.Debug("duda","HistList size:" +this.PosList.size() + " total:" +count);
|
||||
}
|
||||
|
||||
public ArrayList<HistPos> CalcHeadingForArray(ArrayList<HistPos> list)
|
||||
{
|
||||
this.PosList = list;
|
||||
if (PosList.size()>1)
|
||||
{
|
||||
HistPos oldPos = PosList.get(0);
|
||||
HistPos tmpPos = null;
|
||||
int Headingtmp =0;
|
||||
for (int i=1;i<PosList.size();i++)
|
||||
{
|
||||
tmpPos = PosList.get(i);
|
||||
Headingtmp = CalcHead(tmpPos.lng, tmpPos.lat, oldPos.lng, oldPos.lat, Headingtmp);
|
||||
tmpPos.heading = Headingtmp;
|
||||
oldPos = tmpPos;
|
||||
}
|
||||
}
|
||||
|
||||
return this.PosList;
|
||||
}
|
||||
|
||||
private int CalcHead(double lastLocX, double lastLocY, double prevLocX, double prevLocY, int heading)
|
||||
{
|
||||
double dlng = lastLocX - prevLocX;
|
||||
double dlat = lastLocY - prevLocY;
|
||||
double mdelta_min = -0.00001;
|
||||
double delta_min = 0.00001;
|
||||
int headcalc = 0;
|
||||
double blat = 0;
|
||||
double blng = 0;
|
||||
if ((dlat > mdelta_min) && (dlat < delta_min) && ((mdelta_min < dlng) && dlng < (delta_min))) headcalc = heading;
|
||||
else
|
||||
{
|
||||
if ((mdelta_min < dlat) && (dlat < delta_min))
|
||||
{
|
||||
blng = 1;
|
||||
if (dlng < 0) headcalc = 180;
|
||||
else headcalc = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
blat = 1;
|
||||
if (dlat > 0) headcalc = 90;
|
||||
else headcalc = 270;
|
||||
}
|
||||
}
|
||||
if ((mdelta_min < dlng) && (dlng < delta_min))
|
||||
{
|
||||
if (blat == 0)
|
||||
{
|
||||
if (dlat > 0)
|
||||
{
|
||||
if (headcalc == 180) headcalc = 135;
|
||||
if (headcalc == 0) headcalc = 45;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (headcalc == 180) headcalc = 225;
|
||||
if (headcalc == 0) headcalc = 315;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (blng == 0)
|
||||
{
|
||||
if (dlng < 0)
|
||||
{
|
||||
if (headcalc == 90) headcalc = 135;
|
||||
if (headcalc == 270) headcalc = 225;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (headcalc == 90) headcalc = 45;
|
||||
if (headcalc == 270) headcalc = 315;
|
||||
}
|
||||
}
|
||||
}
|
||||
return headcalc;
|
||||
}
|
||||
|
||||
}
|
22
libSafeMobile/src/main/java/com/safemobile/lib/LastPos.java
Normal file
22
libSafeMobile/src/main/java/com/safemobile/lib/LastPos.java
Normal file
@ -0,0 +1,22 @@
|
||||
package com.safemobile.lib;
|
||||
|
||||
public class LastPos {
|
||||
|
||||
public long imei=0;
|
||||
public double lat=0;
|
||||
public double lng=0;
|
||||
public int speed=0;
|
||||
public long timeGMT=0;
|
||||
public String Address="";
|
||||
public boolean isON=false;
|
||||
|
||||
public LastPos(){
|
||||
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "imei: " + imei + " | LAT: " + lat + " | LNG: " + lng + " | speed: " + speed + " | timeGMT: " + timeGMT + " | Address: " + Address + " | isON: " + isON;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,42 @@
|
||||
package com.safemobile.lib;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class LastPosmsg extends TCPmsg {
|
||||
|
||||
public ArrayList<LastPos> PosList;
|
||||
public static int count=0;
|
||||
public LastPosmsg(TCPmsg tcp) {
|
||||
super(tcp);
|
||||
PosList = new ArrayList<LastPos>();
|
||||
String date4parsing = super.data;
|
||||
//SM.Debug("SMS date4parsing:"+date4parsing);
|
||||
String[] tempArr = date4parsing.split(";");
|
||||
//SM.Debug("SMS tempArr.length:" +tempArr.length);
|
||||
for(int i =0; i<tempArr.length;i++)
|
||||
{
|
||||
String[] tempVeh = tempArr[i].split("&");
|
||||
|
||||
if(tempVeh.length<6)
|
||||
continue;
|
||||
LastPos tmpLast = new LastPos();
|
||||
tmpLast.imei = Long.parseLong(tempVeh[0]);
|
||||
tmpLast.lat = Double.parseDouble(tempVeh[1]);
|
||||
tmpLast.lng = Double.parseDouble(tempVeh[2]);
|
||||
tmpLast.speed = Integer.parseInt(tempVeh[3]);
|
||||
if (Integer.parseInt(tempVeh[4])==0) tmpLast.isON =true;
|
||||
else tmpLast.isON = false;
|
||||
tmpLast.timeGMT = Long.parseLong(tempVeh[5]);
|
||||
|
||||
//tmpLast.Address = tempVeh[6];
|
||||
tmpLast.Address = "";
|
||||
PosList.add(tmpLast);
|
||||
//SM.Debug("duda",tmpLast.toString());
|
||||
|
||||
}
|
||||
count +=this.PosList.size();
|
||||
SM.Debug("duda","LastList size:" +this.PosList.size() + " total:" +count);
|
||||
}
|
||||
|
||||
}
|
||||
|
42
libSafeMobile/src/main/java/com/safemobile/lib/LoginMSG.java
Normal file
42
libSafeMobile/src/main/java/com/safemobile/lib/LoginMSG.java
Normal file
@ -0,0 +1,42 @@
|
||||
package com.safemobile.lib;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.safemobile.lib.User;
|
||||
|
||||
public class LoginMSG extends TCPmsg{
|
||||
|
||||
public ArrayList<User> userList;
|
||||
|
||||
public LoginMSG(TCPmsg m) {
|
||||
super(m);
|
||||
|
||||
userList = new ArrayList<User>();
|
||||
String date4parsing = super.data;
|
||||
//SM.Debug("date4parsing:"+date4parsing);
|
||||
String[] tempArr = date4parsing.split(";");
|
||||
|
||||
for(int i =0; i<tempArr.length;i++)
|
||||
{
|
||||
//SM.Debug("i:" + i+"Data :"+tempArr[i]);
|
||||
String[] tempUser = tempArr[i].split("&");
|
||||
//SM.Debug("split len:"+tempUser.length);
|
||||
|
||||
if(tempUser.length<3)
|
||||
continue;
|
||||
int ID = Integer.parseInt(tempUser[1]);
|
||||
String logName = tempUser[0];
|
||||
String pass = tempUser[2];
|
||||
User usr= new User(ID, "", "", logName, pass, 0, 0);
|
||||
|
||||
userList.add(usr);
|
||||
//SM.Debug("added user to list:" +logName);
|
||||
//SM.Debug("LoginMSG new size:" +this.userList.size());
|
||||
}
|
||||
|
||||
//SM.Debug("LoginMSG userList:" +this.userList.size());
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
8
libSafeMobile/src/main/java/com/safemobile/lib/Mic.java
Normal file
8
libSafeMobile/src/main/java/com/safemobile/lib/Mic.java
Normal file
@ -0,0 +1,8 @@
|
||||
package com.safemobile.lib;
|
||||
|
||||
public class Mic {
|
||||
public int mic_type;
|
||||
public int mic_state;
|
||||
public int mic_gain;
|
||||
public int signal_type;
|
||||
}
|
29
libSafeMobile/src/main/java/com/safemobile/lib/Msg.java
Normal file
29
libSafeMobile/src/main/java/com/safemobile/lib/Msg.java
Normal file
@ -0,0 +1,29 @@
|
||||
package com.safemobile.lib;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class Msg {
|
||||
public Vehicle from;
|
||||
public Date received;
|
||||
public String seqID;
|
||||
|
||||
/** Safenet */
|
||||
public long id;
|
||||
public String message;
|
||||
public boolean read;
|
||||
public boolean sent;
|
||||
|
||||
public String subscriber; //will be imei or gw_id+radio_id
|
||||
public Date time, timeSent;
|
||||
public int type;
|
||||
|
||||
public Msg() { }
|
||||
|
||||
public Msg(Vehicle From, String Message, Date Received, String seqID)
|
||||
{
|
||||
this.message = Message;
|
||||
from = From;
|
||||
received = Received;
|
||||
this.seqID = seqID;
|
||||
}
|
||||
}
|
@ -0,0 +1,157 @@
|
||||
package com.safemobile.lib;
|
||||
|
||||
public class OperationCodes {
|
||||
|
||||
/* TCP MSG EVENTS CODES */
|
||||
|
||||
/** Login Request
|
||||
* @param username
|
||||
* @param password values must be MD5 */
|
||||
public static final int CONNECTION_REQ = 19;
|
||||
public static final int CONNECTION_REP = 219;
|
||||
|
||||
|
||||
/** Get contacts from radio */
|
||||
public static final int CONTACTS_REQ = 26;
|
||||
public static final int CONTACTS_REP = 226;
|
||||
|
||||
|
||||
public static final int UNIT_STATUS_UPDATE = 250;
|
||||
|
||||
|
||||
|
||||
|
||||
/** Send a new sms to a unit
|
||||
* @param seqID a unique identifier for the message
|
||||
* @param sc_id units imei to which you send the sms
|
||||
* @param txt the text message that you want to send*/
|
||||
public static final int SEND_TM = 24;
|
||||
public static final int TM_ACK = 224;
|
||||
public static final int TM_ACK_SD = 242;
|
||||
|
||||
|
||||
/** Get radio status that tells if it's online or offline
|
||||
* @param gwID gateway id
|
||||
* @param rgwID radio gateway id */
|
||||
public static final int RADIO_STATUS_REQ = 99;
|
||||
public static final int RADIO_STATUS_REP = 199;
|
||||
public static final int RADIO_STATUS_BRDCST = 200;
|
||||
|
||||
|
||||
/** change zone and channels
|
||||
* @param gwID gateway id
|
||||
* @param rgwID radio gateway id
|
||||
* @param zoneNR desired zone number
|
||||
* @param channelNR desired channel number */
|
||||
public static final int CHANNEL_QUERY_REQ = 104;
|
||||
public static final int CHANNEL_BRDCST = 204;
|
||||
|
||||
|
||||
/** Reset the Bridge */
|
||||
public static final int BRIDGE_RESET = 98;
|
||||
|
||||
|
||||
/** PING-PONG */
|
||||
public static final int PING = 91;
|
||||
public static final int PONG = 92;
|
||||
|
||||
/** Emergency request
|
||||
* @param value this will select to activate or deactivate alarm (TRUE = activate) */
|
||||
public static final int EMERGENCY_REQ = 130;
|
||||
public static final int EMERGENCY_REP = 230;
|
||||
|
||||
/** Initiated a call
|
||||
* @param callType this will select the type of the call (All, Private or Group Call)
|
||||
* @param radioID the contact to which the call is made */
|
||||
public static final int SEND_PTT = 1313;
|
||||
public static final int CALL_STATUS_BRDCST = 126;
|
||||
|
||||
/** Change the call type for external mic initiated calls
|
||||
* @param callType this will select the type of the call (All, Private or Group Call)
|
||||
* @param radioID the contact to which the call is made */
|
||||
public static final int CALL_TYPE_REQ = 161;
|
||||
public static final int CALL_TYPE_REP = 171;
|
||||
|
||||
/** Terminate a call */
|
||||
public static final int DEKEY_REQ = 160;
|
||||
|
||||
|
||||
/** Request the list of all messages
|
||||
* @param timeGMTStart first message time (all messages will be newer than this time) */
|
||||
public static final int TM_LIST_REQ = 25;
|
||||
public static final int TM_LIST_REP = 225;
|
||||
|
||||
|
||||
/** Request the list of all recordings
|
||||
* @param timeGMTStart first message time (all messages will be newer than this time) */
|
||||
public static final int RECORDINGS_LIST_REQ = 27;
|
||||
public static final int RECORDINGS_LIST_REP = 227;
|
||||
|
||||
|
||||
/** Request a recording to be played */
|
||||
public static final int RECORDING_REQ = 28;
|
||||
public static final int RECORDING_REP = 228;
|
||||
|
||||
/** A SMS is received */
|
||||
public static final int RECEIVED_TM = 132;
|
||||
|
||||
|
||||
/** Notification was clicked to display the received TM */
|
||||
public static final int MESSAGE_NOTIFICATION_CLICKED = 690;
|
||||
|
||||
|
||||
/** get tcp connection from service */
|
||||
public static final int TCP_CONNECTION_REQ = 678;
|
||||
public static final int TCP_CONNECTION_UP = 679;
|
||||
public static final int TCP_CONNECTION_DOWN = 677;
|
||||
|
||||
/** operation code needed to change the Radio ID in radioTAB */
|
||||
public static final int RADIOID_CHANGED = 888;
|
||||
|
||||
|
||||
/** operation code needed when a bluetooth is tethered or not */
|
||||
public static final int BLUETOOTH_TETHER = 901;
|
||||
|
||||
/** get vehicles for an user id
|
||||
* @param USERID Logged in user id */
|
||||
public static final int GetVehicles = 2;
|
||||
|
||||
/** get radios list from App Server */
|
||||
public static final int GetRadiosList = 3;
|
||||
|
||||
/** get vehicles last positions
|
||||
* @param USERID Logged in user id */
|
||||
public static final int GetLastPositions = 4;
|
||||
|
||||
/** get the last sms for all the vehicles */
|
||||
public static final int GetLastSMS = 5;
|
||||
|
||||
/** get sms for a specific vehicle newer than a date
|
||||
* @param sc_id vehicle imei for which we wish the list of sms
|
||||
* @param timeGMT the unix time from the last sms in the grid */
|
||||
public static final int GetRecentSMSs = 6;
|
||||
|
||||
/** enable/ disable vehicle status or poll it
|
||||
* @param radioCode
|
||||
* @param opCode
|
||||
* @param sc_id vehicle imei
|
||||
* @param enable */
|
||||
public static final int Option4Unit = 8;
|
||||
|
||||
|
||||
/** get alarms for an user id
|
||||
* @param USERID Logged in user id */
|
||||
public static final int GetAlarms = 9;
|
||||
|
||||
/** acknoledge an alarm based on it's index and type
|
||||
* @param idx alarm's index in the DB
|
||||
* @param type alarm's type as shown in the grid*/
|
||||
public static final int SendAlarmAcknoledge = 10;
|
||||
|
||||
/** get history position for a specific vehicle
|
||||
* @param sc_id vehicle's imei
|
||||
* @param timeGMTStart history start date in unixtime
|
||||
* @param timeGMTStop history end date in unixtime*/
|
||||
public static final int GetHistoryPositions = 11;
|
||||
|
||||
}
|
203
libSafeMobile/src/main/java/com/safemobile/lib/Position.java
Normal file
203
libSafeMobile/src/main/java/com/safemobile/lib/Position.java
Normal file
@ -0,0 +1,203 @@
|
||||
package com.safemobile.lib;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Created by Adi on 8/11/2017.
|
||||
*/
|
||||
|
||||
public class Position implements Parcelable, Comparable<Position>{
|
||||
// region private fields
|
||||
public double latitude;
|
||||
public double longitude;
|
||||
public Date positionTime;
|
||||
public double speed;
|
||||
public String address;
|
||||
public float accuracy;
|
||||
//endregion
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
public Position()
|
||||
{
|
||||
latitude = 0;
|
||||
longitude = 0;
|
||||
positionTime = new Date(0);
|
||||
speed = 0;
|
||||
address = "";
|
||||
accuracy = 0;
|
||||
}
|
||||
|
||||
public Position(String json)
|
||||
{
|
||||
try {
|
||||
JSONObject posObj = new JSONObject(json);
|
||||
speed = posObj.isNull("speed")
|
||||
? 0 : posObj.getDouble("speed");
|
||||
latitude = posObj.isNull("latitude")
|
||||
? 0 : posObj.getDouble("latitude");
|
||||
longitude = posObj.isNull("longitude")
|
||||
? 0 : posObj.getDouble("longitude");
|
||||
address = posObj.isNull("address")
|
||||
? "" : posObj.getString("address");
|
||||
|
||||
accuracy = posObj.isNull("accuracy")
|
||||
? 0 : (float) posObj.getDouble("accuracy");
|
||||
|
||||
String posTime = posObj.isNull("positionTime")
|
||||
? "" : posObj.getString("positionTime");
|
||||
if(posTime.length() > 0)
|
||||
{
|
||||
//May 16, 2018 12:01:47
|
||||
try
|
||||
{
|
||||
String timeFormat = "MMMMM d, yyyy HH:mm:ss";
|
||||
DateFormat format = new SimpleDateFormat(timeFormat, Locale.ENGLISH);
|
||||
positionTime = format.parse(posTime);
|
||||
}
|
||||
catch (ParseException e)
|
||||
{
|
||||
String timeFormat = "MMM d, yyyy HH:mm:ss";
|
||||
DateFormat format = new SimpleDateFormat(timeFormat, Locale.ENGLISH);
|
||||
positionTime = format.parse(posTime);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
positionTime = new Date(0);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
positionTime = new Date(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public Position(double latitude, double longitude)
|
||||
{
|
||||
this.latitude = latitude;
|
||||
this.longitude = longitude;
|
||||
positionTime = new Date(0);
|
||||
speed = 0;
|
||||
address = "";
|
||||
accuracy = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor from Parcel, reads back fields IN THE ORDER they were
|
||||
* written
|
||||
*/
|
||||
public Position(Parcel parcel){
|
||||
latitude = parcel.readDouble();
|
||||
longitude = parcel.readDouble();
|
||||
positionTime = new Date(parcel.readLong());
|
||||
speed = parcel.readDouble();
|
||||
address = parcel.readString();
|
||||
accuracy = parcel.readFloat();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Method from Parcelable class, left as auto-generated
|
||||
* @return A default value
|
||||
*/
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Method to create the Parcel object from the main class that
|
||||
* will be passed when a Parcelable object is used
|
||||
* @param dest Parcel object in which all the object values will
|
||||
* be added
|
||||
* @param flags Additional flags about how the object should be
|
||||
* written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE.
|
||||
*/
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeDouble(latitude);
|
||||
dest.writeDouble(longitude);
|
||||
dest.writeLong(positionTime.getTime());
|
||||
dest.writeDouble(speed);
|
||||
dest.writeString(address);
|
||||
dest.writeFloat(accuracy);
|
||||
}
|
||||
|
||||
/**
|
||||
* Static field used to regenerate object, individually or as arrays
|
||||
*/
|
||||
public static final Parcelable.Creator<Position> CREATOR = new Parcelable.Creator<Position>() {
|
||||
public Position createFromParcel(Parcel in) {
|
||||
return new Position(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Position[] newArray(int size) {
|
||||
return new Position[size];
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Override of the method that returns a string representation of the object which
|
||||
* contains all the useful information about the object
|
||||
* @return String representation of the object
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "Latitude: " + latitude + " | "
|
||||
+ "Longitude: " + longitude + " | "
|
||||
+ "Speed: " + speed + " | "
|
||||
+ "PositionTime: " + (positionTime!= null ? positionTime.toString() : "null" ) + " | "
|
||||
+ "Address " + (address!= null ? address.toString() : "null" )
|
||||
+ "Accuracy " + accuracy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(@NonNull Position o) {
|
||||
return (latitude == o.latitude
|
||||
&& longitude == o.longitude
|
||||
) ? 0 : 1;
|
||||
}
|
||||
|
||||
// Overriding equals() to compare two Complex objects
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
Position pos = (Position) o;
|
||||
|
||||
return compareTo(pos) == 0;
|
||||
}
|
||||
|
||||
|
||||
// just omitted null checks
|
||||
@Override
|
||||
public int hashCode() {
|
||||
double res = latitude * longitude * 100000;
|
||||
int hash = (int)(latitude );
|
||||
hash = (int)(longitude) * hash;
|
||||
return (int)res;
|
||||
}
|
||||
|
||||
|
||||
public String toJson()
|
||||
{
|
||||
return new Gson().toJson(this);
|
||||
}
|
||||
}
|
22
libSafeMobile/src/main/java/com/safemobile/lib/Radio.java
Normal file
22
libSafeMobile/src/main/java/com/safemobile/lib/Radio.java
Normal file
@ -0,0 +1,22 @@
|
||||
package com.safemobile.lib;
|
||||
|
||||
public class Radio {
|
||||
public int id = 100;
|
||||
public String ip = "192.168.10.40";
|
||||
|
||||
public Radio()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Radio(int _id, String _ip)
|
||||
{
|
||||
id = _id;
|
||||
ip = _ip;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "id: " + id + " | ip: " + ip;
|
||||
}
|
||||
}
|
344
libSafeMobile/src/main/java/com/safemobile/lib/RadioMSG.java
Normal file
344
libSafeMobile/src/main/java/com/safemobile/lib/RadioMSG.java
Normal file
@ -0,0 +1,344 @@
|
||||
package com.safemobile.lib;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.safemobile.lib.radio.Channel;
|
||||
import com.safemobile.lib.radio.Emerg;
|
||||
import com.safemobile.lib.radio.IncCall;
|
||||
import com.safemobile.lib.radio.RadioGW;
|
||||
import com.safemobile.lib.radio.RadioStatus;
|
||||
import com.safemobile.lib.radio.SUstatus;
|
||||
import com.safemobile.lib.radio.Zone;
|
||||
import com.safemobile.lib.radio.Zone_and_channel;
|
||||
|
||||
public class RadioMSG extends TCPmsg {
|
||||
|
||||
public int rOpcode;
|
||||
public String payload="";
|
||||
public ArrayList<RadioGW> RadioGWList=null;
|
||||
|
||||
//zone and channel;
|
||||
public Zone_and_channel zac= null;
|
||||
|
||||
//radio status
|
||||
public RadioStatus rStatus = null;
|
||||
|
||||
//SU stauts
|
||||
public SUstatus suStatus = null;
|
||||
|
||||
//Incomming call
|
||||
public IncCall incCall = null;
|
||||
|
||||
//Emerg
|
||||
public Emerg emerg = null;
|
||||
|
||||
// Contacts list
|
||||
public ArrayList<Contact> contacts;
|
||||
|
||||
|
||||
public RadioMSG(TCPmsg tcp) {
|
||||
super(tcp);
|
||||
String date4parsing = super.data;
|
||||
|
||||
String[] arr = date4parsing.split("#");
|
||||
|
||||
rOpcode = Integer.parseInt(arr[0]);
|
||||
payload = arr[1];
|
||||
|
||||
switch(rOpcode)
|
||||
{
|
||||
case 200:
|
||||
{
|
||||
RadioGWList = new ArrayList<RadioGW>();
|
||||
String[] tempArr = payload.split(";");
|
||||
|
||||
int count = 0;
|
||||
for(int i =0; i<tempArr.length;i++)
|
||||
{
|
||||
String[] oneRadio = tempArr[i].split("&");
|
||||
|
||||
if(oneRadio.length<5)
|
||||
continue;
|
||||
RadioGW rgw = new RadioGW();
|
||||
|
||||
rgw.ID = Integer.parseInt(oneRadio[0]);
|
||||
rgw.GW_ID = Integer.parseInt(oneRadio[1]);
|
||||
rgw.IMEI = oneRadio[2];
|
||||
rgw.IP = oneRadio[3];
|
||||
|
||||
String zonelistStr =oneRadio[4];
|
||||
String[] zoneArr = zonelistStr.split("@");
|
||||
for(int j =0; j<zoneArr.length;j++)
|
||||
{
|
||||
Zone zon = new Zone();
|
||||
String[] oneZoneArr = zoneArr[j].split(":");
|
||||
|
||||
//TODO check what this values are from SD
|
||||
zon.dbID = Integer.parseInt(oneZoneArr[0]);
|
||||
zon.id = Integer.parseInt(oneZoneArr[1]);
|
||||
zon.ZoneName = oneZoneArr[2];
|
||||
String channelListStr = oneZoneArr[3];
|
||||
|
||||
String[] channelArr = channelListStr.split(",");
|
||||
for(int k =0; k < channelArr.length; k++)
|
||||
{
|
||||
Channel chn = new Channel();
|
||||
String[] oneChnArr = channelArr[k].split("/");
|
||||
chn.dbID = Integer.parseInt(oneChnArr[0]);
|
||||
chn.id = Integer.parseInt(oneChnArr[1]);
|
||||
chn.chName = oneChnArr[2];
|
||||
|
||||
//add channel to zone
|
||||
zon.channelList.add(chn);
|
||||
}
|
||||
|
||||
//add zone to radio GW
|
||||
rgw.zoneList.add(zon);
|
||||
}
|
||||
|
||||
RadioGWList.add(rgw);
|
||||
count++;
|
||||
}
|
||||
count +=this.RadioGWList.size();
|
||||
SM.Debug("radio","RadioGWList size:" +this.RadioGWList.size() + " total:" +count);
|
||||
break;
|
||||
}
|
||||
case OperationCodes.CHANNEL_BRDCST:
|
||||
{
|
||||
try {
|
||||
zac = new Zone_and_channel();
|
||||
String[] tempArr = payload.split("&");
|
||||
|
||||
String[] gwID_and_rgwID = tempArr[0].split("/");
|
||||
zac.gwID = Integer.parseInt(gwID_and_rgwID[0]);
|
||||
zac.rgwID = Integer.parseInt(gwID_and_rgwID[1]);
|
||||
|
||||
String[] zoneNr_and_channelNr = tempArr[1].split("/");
|
||||
zac.zoneNr = Integer.parseInt(zoneNr_and_channelNr[0]);
|
||||
zac.channelNr = Integer.parseInt(zoneNr_and_channelNr[1]);
|
||||
} catch (Exception e) {
|
||||
SM.Debug("Cmd 204 error:"+e.toString());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case OperationCodes.RADIO_STATUS_REP:
|
||||
{
|
||||
try {
|
||||
rStatus = new RadioStatus();
|
||||
String[] tempArr = payload.split("&");
|
||||
|
||||
if(tempArr.length == 4 || tempArr.length == 5) {
|
||||
rStatus.status = 1;
|
||||
rStatus.incCall.callStatus = Integer.parseInt(tempArr[0]);
|
||||
rStatus.incCall.callType = Integer.parseInt(tempArr[1]);
|
||||
rStatus.incCall.Imei = Integer.parseInt(tempArr[2]);
|
||||
rStatus.incCall.callerID = Integer.parseInt(tempArr[2]);
|
||||
rStatus.incCall.groupId = Integer.parseInt(tempArr[3]);
|
||||
rStatus.incCall.callDestID = Integer.parseInt(tempArr[3]);
|
||||
|
||||
if(tempArr.length == 5)
|
||||
rStatus.incCall.userID = Integer.parseInt(tempArr[4]);
|
||||
}
|
||||
else {
|
||||
String[] gwID_and_rgwID = tempArr[0].split("/");
|
||||
rStatus.gwID = Integer.parseInt(gwID_and_rgwID[0]);
|
||||
rStatus.rgwID = Integer.parseInt(gwID_and_rgwID[1]);
|
||||
rStatus.status = Integer.parseInt(tempArr[1]);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
SM.Debug("Cmd 199 error:"+e.toString());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 250:
|
||||
{
|
||||
try {
|
||||
suStatus = new SUstatus();
|
||||
String[] tempArr = payload.split("&");
|
||||
|
||||
suStatus.imei = Integer.parseInt(tempArr[0]);
|
||||
|
||||
suStatus.status = Integer.parseInt(tempArr[1]);
|
||||
} catch (Exception e) {
|
||||
SM.Debug("Cmd 250 error:"+e.toString());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 125:
|
||||
case OperationCodes.CALL_STATUS_BRDCST:
|
||||
{
|
||||
try {
|
||||
incCall = new IncCall();
|
||||
incCall.opCode = rOpcode;
|
||||
String[] tempArr = payload.split("&");
|
||||
|
||||
String[] gwID_and_rgwID_imei = tempArr[0].split("/");
|
||||
incCall.gwID = Integer.parseInt(gwID_and_rgwID_imei[0]);
|
||||
incCall.rgwID = Integer.parseInt(gwID_and_rgwID_imei[1]);
|
||||
incCall.Imei = Long.parseLong(gwID_and_rgwID_imei[2]);
|
||||
|
||||
incCall.callStatus = Integer.parseInt(tempArr[1]);
|
||||
incCall.callType = Integer.parseInt(tempArr[2]);
|
||||
incCall.groupId = Integer.parseInt(tempArr[3]);
|
||||
incCall.userID = Integer.parseInt(tempArr[4]);
|
||||
} catch (Exception e) {
|
||||
SM.Debug("Cmd 125, 126 error:"+e.toString());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 121:
|
||||
case 122:
|
||||
case 123:
|
||||
{
|
||||
try {
|
||||
incCall = new IncCall();
|
||||
incCall.opCode = rOpcode;
|
||||
|
||||
incCall.callStatus = Integer.parseInt(payload.substring(payload.length()-1, payload.length()));
|
||||
|
||||
} catch (Exception e) {
|
||||
SM.Debug("Cmd 121, 122, 123 error:"+e.toString());
|
||||
}
|
||||
/*
|
||||
try {
|
||||
System.out.println("############ tmpARR: " + payload );
|
||||
incCall = new IncCall();
|
||||
incCall.opCode = rOpcode;
|
||||
String[] tempArr = payload.split("&");
|
||||
|
||||
String[] gwID_and_rgwID_imei = tempArr[0].split("/");
|
||||
incCall.gwID = Integer.parseInt(gwID_and_rgwID_imei[0]);
|
||||
incCall.rgwID = Integer.parseInt(gwID_and_rgwID_imei[1]);
|
||||
|
||||
incCall.callStatus = Integer.parseInt(tempArr[1]);
|
||||
|
||||
incCall.callType = Integer.parseInt(tempArr[2]);
|
||||
|
||||
incCall.groupId = Integer.parseInt(tempArr[3]);
|
||||
} catch (Exception e) {
|
||||
SM.Debug("Cmd 121, 122, 123 error:"+e.toString());
|
||||
}
|
||||
*/
|
||||
break;
|
||||
}
|
||||
|
||||
case 115:
|
||||
case 116:
|
||||
case 117:
|
||||
{
|
||||
|
||||
try {
|
||||
incCall = new IncCall();
|
||||
incCall.opCode = rOpcode;
|
||||
|
||||
incCall.callStatus = Integer.parseInt(payload.substring(payload.length()-1, payload.length()));
|
||||
|
||||
} catch (Exception e) {
|
||||
SM.Debug("Cmd 115,116,117 error:"+e.toString());
|
||||
}
|
||||
break;
|
||||
|
||||
/*
|
||||
try {
|
||||
incCall = new IncCall();
|
||||
String[] tempArr = payload.split("&");
|
||||
incCall.opCode = rOpcode;
|
||||
String[] gwID_and_rgwID_imei = tempArr[0].split("/");
|
||||
incCall.gwID = Integer.parseInt(gwID_and_rgwID_imei[0]);
|
||||
incCall.rgwID = Integer.parseInt(gwID_and_rgwID_imei[1]);
|
||||
|
||||
incCall.callStatus = 3;
|
||||
|
||||
incCall.callType = Integer.parseInt(tempArr[2]);
|
||||
|
||||
incCall.groupId = Integer.parseInt(tempArr[3]);
|
||||
} catch (Exception e) {
|
||||
SM.Debug("Cmd 115, 116, 117 error:"+e.toString());
|
||||
}
|
||||
|
||||
break;
|
||||
*/
|
||||
}
|
||||
|
||||
case OperationCodes.CALL_TYPE_REP:
|
||||
{
|
||||
|
||||
try {
|
||||
incCall = new IncCall();
|
||||
incCall.opCode = rOpcode;
|
||||
String[] tempArr = payload.split("/");
|
||||
incCall.callType = Integer.parseInt(tempArr[0]);
|
||||
incCall.callStatus = Integer.parseInt(tempArr[1]);
|
||||
|
||||
SM.Debug("GOT CHANGE CALL TYPE MSG", incCall.opCode + " # " + incCall.callType + " # " + incCall.callStatus);
|
||||
} catch (Exception e) {
|
||||
SM.Debug("Cmd 115,116,117 error:"+e.toString());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 172:
|
||||
{
|
||||
|
||||
try {
|
||||
incCall = new IncCall();
|
||||
incCall.opCode = rOpcode;
|
||||
String[] tempArr = payload.split("/");
|
||||
incCall.mic = new Mic();
|
||||
incCall.mic.mic_type = Integer.parseInt(tempArr[0]);
|
||||
incCall.mic.signal_type = Integer.parseInt(tempArr[1]);
|
||||
incCall.mic.mic_state = Integer.parseInt(tempArr[2]);
|
||||
incCall.mic.mic_gain = Integer.parseInt(tempArr[3]);
|
||||
|
||||
SM.Debug("GOT Mic state changed", incCall.opCode + " # " + incCall.mic.mic_state);
|
||||
} catch (Exception e) {
|
||||
SM.Debug("Cmd 172 error:"+e.toString());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case OperationCodes.EMERGENCY_REP:
|
||||
{
|
||||
try {
|
||||
emerg = new Emerg();
|
||||
String[] tempArr = payload.split("/");
|
||||
|
||||
emerg.function = Integer.parseInt(tempArr[0]);
|
||||
emerg.status = Integer.parseInt(tempArr[1]);
|
||||
|
||||
// emerg.userID = Integer.parseInt(tempArr[2]);
|
||||
} catch (Exception e) {
|
||||
SM.Debug("Cmd 230 error:"+e.toString());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
case OperationCodes.CONTACTS_REP:
|
||||
{
|
||||
try
|
||||
{
|
||||
SM.Debug("Parsing Contacts");
|
||||
contacts = Contact.parseTCPMsg(payload);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
SM.Exception("Exception parse Contacts", ex.toString());
|
||||
}
|
||||
break;
|
||||
}
|
||||
*/
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
//SM.Debug("RadioMSG", "Done parsing");
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package com.safemobile.lib;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class RecordMSG extends TCPmsg {
|
||||
|
||||
public ArrayList<Recording> recordList;
|
||||
public static int count=0;
|
||||
public RecordMSG(TCPmsg tcp)
|
||||
{
|
||||
super(tcp);
|
||||
recordList = new ArrayList<Recording>();
|
||||
String date4parsing = super.data;
|
||||
//SM.Debug("SMS date4parsing:"+date4parsing);
|
||||
String[] tempArr = date4parsing.split(";");
|
||||
|
||||
//SM.Debug("SMS tempArr.length:" +tempArr.length);
|
||||
for(int i =0; i<tempArr.length;i++)
|
||||
{
|
||||
String[] tempRec = tempArr[i].split("&");
|
||||
if(tempRec.length<7)
|
||||
continue;
|
||||
|
||||
Recording RecValue = new Recording();
|
||||
RecValue.ID = Long.parseLong(tempRec[0]);
|
||||
RecValue.startGMT = Integer.parseInt(tempRec[1]);
|
||||
RecValue.endGMT = Integer.parseInt(tempRec[2]);
|
||||
RecValue.gwID = Integer.parseInt(tempRec[3]);
|
||||
RecValue.radioGWID = Integer.parseInt(tempRec[4]);
|
||||
RecValue.subID = Integer.parseInt(tempRec[5]);
|
||||
RecValue.typeID = Integer.parseInt(tempRec[6]);
|
||||
|
||||
recordList.add(RecValue);
|
||||
}
|
||||
|
||||
count +=this.recordList.size();
|
||||
SM.Debug("alarmList size:" +this.recordList.size() + " total:" +count);
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package com.safemobile.lib;
|
||||
|
||||
public class Recording {
|
||||
public long ID;
|
||||
public int startGMT;
|
||||
public int endGMT;
|
||||
public int gwID;
|
||||
public int radioGWID;
|
||||
public int subID;
|
||||
public int typeID;
|
||||
public String NameForDisplay="";
|
||||
|
||||
/** RadioPad */
|
||||
public long date;
|
||||
public int duration;
|
||||
public String filename;
|
||||
public long destinationRadioID;
|
||||
public long sourceRadioID;
|
||||
public int type;
|
||||
|
||||
public Recording()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "ID: " + ID + " | start: " + startGMT + " | end: " + endGMT + " | gwID: " + gwID + " | radioGWID: " + radioGWID + " | subID: " + subID + " | typeID: " + typeID;
|
||||
}
|
||||
}
|
36
libSafeMobile/src/main/java/com/safemobile/lib/SM.java
Normal file
36
libSafeMobile/src/main/java/com/safemobile/lib/SM.java
Normal file
@ -0,0 +1,36 @@
|
||||
package com.safemobile.lib;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
public class SM
|
||||
{
|
||||
public static void Debug(String tag, String msg)
|
||||
{
|
||||
Log.d(tag,msg);
|
||||
/*
|
||||
try
|
||||
{
|
||||
if (!tag.toUpperCase().contains("DEFAULT"))
|
||||
Log.d("Default",msg);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.d("Default","Error parse tag:"+ex.toString());
|
||||
}
|
||||
//*/
|
||||
}
|
||||
public static void Debug(String msg)
|
||||
{
|
||||
Log.d("Default",msg);
|
||||
}
|
||||
|
||||
public static void Exception(String msg)
|
||||
{
|
||||
Log.e("Exception",msg);
|
||||
}
|
||||
|
||||
public static void Exception(String tag, String msg)
|
||||
{
|
||||
Log.e(tag,msg);
|
||||
}
|
||||
}
|
34
libSafeMobile/src/main/java/com/safemobile/lib/SMS.java
Normal file
34
libSafeMobile/src/main/java/com/safemobile/lib/SMS.java
Normal file
@ -0,0 +1,34 @@
|
||||
package com.safemobile.lib;
|
||||
|
||||
public class SMS {
|
||||
public int idx = 0;
|
||||
public int status = 0;
|
||||
public int timeGMT = 0;
|
||||
public String mess = "";
|
||||
public long sc_id_dest = 0;
|
||||
public long sc_id_sour = 0;
|
||||
public String seq_idx = "";
|
||||
|
||||
public SMS(){
|
||||
|
||||
}
|
||||
|
||||
public SMS(int _idx, int _status, int _timeGMT, String _mess, long _sc_id_dest, long _sc_id_sour)
|
||||
{
|
||||
idx = _idx;
|
||||
status = _status;
|
||||
timeGMT = _timeGMT;
|
||||
mess = _mess;
|
||||
sc_id_dest = _sc_id_dest;
|
||||
sc_id_sour = _sc_id_sour;
|
||||
seq_idx = "";
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "idx: " + idx + " | status: " + status + " | timeGMT: " + timeGMT
|
||||
+ " | mess: " + mess + " | sc_id_dest: " + sc_id_dest + " | sc_id_sour: " + sc_id_sour
|
||||
+ " | seq_idx: " + seq_idx;
|
||||
}
|
||||
|
||||
}
|
53
libSafeMobile/src/main/java/com/safemobile/lib/SMSmsg.java
Normal file
53
libSafeMobile/src/main/java/com/safemobile/lib/SMSmsg.java
Normal file
@ -0,0 +1,53 @@
|
||||
package com.safemobile.lib;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.safemobile.lib.SMS;
|
||||
|
||||
public class SMSmsg extends TCPmsg {
|
||||
|
||||
public ArrayList<SMS> smsList;
|
||||
public static int count=0;
|
||||
public SMSmsg(TCPmsg tcp) {
|
||||
super(tcp);
|
||||
smsList = new ArrayList<SMS>();
|
||||
String date4parsing = super.data;
|
||||
//SM.Debug("SMS date4parsing:"+date4parsing);
|
||||
String[] tempArr = date4parsing.split(";");
|
||||
|
||||
//SM.Debug("SMS tempArr.length:" +tempArr.length);
|
||||
for(int i =0; i<tempArr.length;i++)
|
||||
{
|
||||
//SM.Debug("i:" + i+"Data :"+tempArr[i]);
|
||||
String[] tempVeh = tempArr[i].split("&");
|
||||
|
||||
if(tempVeh.length<7)
|
||||
continue;
|
||||
SMS sms = new SMS();
|
||||
String sm = "";
|
||||
try {
|
||||
sms.idx = Integer.parseInt(tempVeh[0]);
|
||||
sm = sms.idx + "";
|
||||
sms.status = Integer.parseInt(tempVeh[1]);
|
||||
sm = sms.status + "";
|
||||
sms.timeGMT = Integer.parseInt(tempVeh[2]);
|
||||
sm = sms.timeGMT + "";
|
||||
sms.mess = tempVeh[3];
|
||||
sms.sc_id_sour = Integer.parseInt(tempVeh[4]);
|
||||
sm = sms.sc_id_sour + "";
|
||||
sms.sc_id_dest = Integer.parseInt(tempVeh[5]);
|
||||
sm = sms.sc_id_dest + "";
|
||||
sms.seq_idx = tempVeh[6];
|
||||
}
|
||||
catch(Exception ex) {
|
||||
SM.Exception("Exception in SMSmsg: " + ex.toString() + " | " + sm);
|
||||
}
|
||||
smsList.add(sms);
|
||||
//SM.Debug(sms.toString());
|
||||
}
|
||||
|
||||
count +=this.smsList.size();
|
||||
//SM.Debug("smsList size:" +this.smsList.size() + " total:" +count);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package com.safemobile.lib;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class SerializedObject implements Serializable{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Object object;
|
||||
private String type;
|
||||
|
||||
public SerializedObject (Object object, String type){
|
||||
this.setObject(object);
|
||||
this.setType(type);
|
||||
}
|
||||
|
||||
public Object getObject() {
|
||||
return object;
|
||||
}
|
||||
public void setObject(Object object) {
|
||||
this.object = object;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
package com.safemobile.lib;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
public class SuperVehicle extends Vehicle{
|
||||
|
||||
public double lat=0;
|
||||
public double lng=0;
|
||||
public boolean needUpdate=false;
|
||||
public int speed=0;
|
||||
public long timeGMT=0;
|
||||
public String Address="";
|
||||
public boolean isON=false;
|
||||
|
||||
public SuperVehicle(long sc_id, String imei, long lp, String name, long driver_id, int time_route, int GPS_reporting_interval, int is_stolen)
|
||||
{
|
||||
super(sc_id, imei, lp, name, driver_id, time_route, GPS_reporting_interval,
|
||||
is_stolen);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public void SetDataFromLastPos(Double _lat,Double _lng,long _time,int _speed,String _Address,Boolean _isON)
|
||||
{
|
||||
try
|
||||
{
|
||||
lat = _lat;
|
||||
lng = _lng;
|
||||
timeGMT = _time;
|
||||
speed = _speed;
|
||||
Address = _Address;
|
||||
isON = _isON;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.d("Erorr", "Contert Error:"+ex.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public void SetNewPosition(Double _lat,Double _lng,long _time,int _speed)
|
||||
{
|
||||
try
|
||||
{
|
||||
lat = _lat;
|
||||
lng = _lng;
|
||||
timeGMT = _time;
|
||||
speed = _speed;
|
||||
isON = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.d("Erorr", "Contert Error:"+ex.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public String GetUnixTimeDisplay()
|
||||
{
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss dd-MMM");
|
||||
|
||||
return sdf.format(timeGMT*1000);
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "name: " + name + "imei: " + imei + " | LAT: " + lat + " | LNG: " + lng + " | speed: " + speed + " | timeGMT: " + timeGMT + " | Address: " + Address + " | isON: " + isON;
|
||||
}
|
||||
}
|
87
libSafeMobile/src/main/java/com/safemobile/lib/TCPmsg.java
Normal file
87
libSafeMobile/src/main/java/com/safemobile/lib/TCPmsg.java
Normal file
@ -0,0 +1,87 @@
|
||||
package com.safemobile.lib;
|
||||
|
||||
import com.safemobile.lib.SM;
|
||||
|
||||
public class TCPmsg
|
||||
{
|
||||
public boolean OK;
|
||||
public int msgLen;
|
||||
public String seqID;
|
||||
public int opCode;
|
||||
public String data;
|
||||
public String error;
|
||||
public String allData;
|
||||
|
||||
public String leftOver="";
|
||||
|
||||
private char[] _rawdata;
|
||||
private int _len;
|
||||
public TCPmsg(char[] rawdata, int len)
|
||||
{
|
||||
_rawdata = rawdata;
|
||||
_len = len;
|
||||
OK = Parse();
|
||||
}
|
||||
|
||||
public TCPmsg(TCPmsg tcp)
|
||||
{
|
||||
_rawdata =tcp._rawdata;
|
||||
_len = tcp._len;
|
||||
OK = Parse();
|
||||
}
|
||||
|
||||
public TCPmsg(char[] msg)
|
||||
{
|
||||
_rawdata = msg;
|
||||
_len = msg.length;
|
||||
OK = Parse();
|
||||
}
|
||||
|
||||
private boolean Parse()
|
||||
{
|
||||
char[] temp = new char[_len];
|
||||
for(int i=0;i<_len;i++) temp[i] = _rawdata[i];
|
||||
data =new String(temp);
|
||||
//SM.Debug("multi RX: " + data);
|
||||
this.allData = data;
|
||||
|
||||
String[] tempArr = data.split("#");
|
||||
if ((tempArr.length == 0) || (tempArr.length == 1))
|
||||
{
|
||||
SM.Debug("incorect messagebuss message=" + data);
|
||||
return false;
|
||||
}
|
||||
//get msg len
|
||||
int messLen = -1;
|
||||
try
|
||||
{
|
||||
messLen = Integer.parseInt(tempArr[1]);
|
||||
} catch (Exception e) {
|
||||
SM.Debug("incorect msg len =" + tempArr[1]);
|
||||
return false;
|
||||
}
|
||||
//messLen not int
|
||||
if(messLen ==-1) return false;
|
||||
|
||||
if (_len != messLen)
|
||||
{
|
||||
SM.Debug("message length("+messLen+") != actual length("+_len+")");
|
||||
return false;
|
||||
}
|
||||
|
||||
seqID = tempArr[2];
|
||||
opCode = Integer.parseInt(tempArr[3]);
|
||||
data = "";
|
||||
for (int i = 4; i < tempArr.length; i++)
|
||||
{
|
||||
if(tempArr[i] !="")
|
||||
data += tempArr[i]+"#";
|
||||
}
|
||||
|
||||
// add sequence ID to data when ack message
|
||||
if(opCode == OperationCodes.TM_ACK || opCode == OperationCodes.TM_ACK_SD)
|
||||
data+= seqID + "#";
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
47
libSafeMobile/src/main/java/com/safemobile/lib/User.java
Normal file
47
libSafeMobile/src/main/java/com/safemobile/lib/User.java
Normal file
@ -0,0 +1,47 @@
|
||||
package com.safemobile.lib;
|
||||
|
||||
public class User {
|
||||
public int id;
|
||||
public String firstname;
|
||||
public String lastname;
|
||||
public String login;
|
||||
public String password;
|
||||
public int user_type;
|
||||
public int ison = 0;
|
||||
public Vehicle vehValue;
|
||||
|
||||
public User()
|
||||
{
|
||||
this.id = -1;
|
||||
this.user_type = 1;
|
||||
}
|
||||
|
||||
public User(int id, String firstname, String lastname, String login, String password, int user_type, int ison)
|
||||
{
|
||||
this.id = id;
|
||||
this.firstname = firstname;
|
||||
this.lastname = lastname;
|
||||
this.login = login;
|
||||
this.password = password;
|
||||
this.user_type = user_type;
|
||||
this.ison = ison;
|
||||
this.vehValue =null;
|
||||
}
|
||||
|
||||
public User(int id, String firstname, String lastname, String login, String password, int user_type, int ison,Vehicle _vehValue)
|
||||
{
|
||||
this.id = id;
|
||||
this.firstname = firstname;
|
||||
this.lastname = lastname;
|
||||
this.login = login;
|
||||
this.password = password;
|
||||
this.user_type = user_type;
|
||||
this.ison = ison;
|
||||
vehValue =_vehValue;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "id: " + id + " | login: " + login + " | password: " + password + " | user_type: " + user_type;
|
||||
}
|
||||
}
|
46
libSafeMobile/src/main/java/com/safemobile/lib/VehMSG.java
Normal file
46
libSafeMobile/src/main/java/com/safemobile/lib/VehMSG.java
Normal file
@ -0,0 +1,46 @@
|
||||
package com.safemobile.lib;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.safemobile.lib.Vehicle;
|
||||
|
||||
public class VehMSG extends TCPmsg{
|
||||
|
||||
public ArrayList<Vehicle> vehList;
|
||||
|
||||
public VehMSG(TCPmsg m) {
|
||||
super(m);
|
||||
|
||||
vehList = new ArrayList<Vehicle>();
|
||||
String date4parsing = super.data;
|
||||
SM.Debug("date4parsing:"+date4parsing);
|
||||
String[] tempArr = date4parsing.split(";");
|
||||
|
||||
SM.Debug("tempArr.length:" +tempArr.length);
|
||||
for(int i =0; i<tempArr.length;i++)
|
||||
{
|
||||
//SM.Debug("i:" + i+"Data :"+tempArr[i]);
|
||||
String[] tempVeh = tempArr[i].split("&");
|
||||
//SM.Debug("split len:"+tempVeh.length);
|
||||
|
||||
if(tempVeh.length<7)
|
||||
continue;
|
||||
int sc_id = Integer.parseInt(tempVeh[0]);
|
||||
String imei = tempVeh[1];
|
||||
//String serialNumber = tempVeh[2];
|
||||
String name = tempVeh[3];
|
||||
//String groupName = tempVeh[4];
|
||||
int lp = Integer.parseInt(tempVeh[5]);
|
||||
//String userName = tempVeh[6];
|
||||
boolean status = (Integer.parseInt(tempVeh[7])==1);
|
||||
|
||||
Vehicle veh = new Vehicle(sc_id, imei, lp, name, lp, 0, 0, 0);
|
||||
veh.status = status;
|
||||
vehList.add(veh);
|
||||
//SM.Debug("added veh to list:" +name);
|
||||
//SM.Debug("vehList new size:" +this.vehList.size());
|
||||
}
|
||||
|
||||
SM.Debug("vehList vehList:" +this.vehList.size());
|
||||
}
|
||||
}
|
162
libSafeMobile/src/main/java/com/safemobile/lib/Vehicle.java
Normal file
162
libSafeMobile/src/main/java/com/safemobile/lib/Vehicle.java
Normal file
@ -0,0 +1,162 @@
|
||||
package com.safemobile.lib;
|
||||
|
||||
public class Vehicle {
|
||||
public long id;
|
||||
public long sc_id;
|
||||
public long lp;
|
||||
public String name;
|
||||
public long driver_id;
|
||||
public int time_route = 0;
|
||||
public int GPS_reporting_interval = 50;
|
||||
public int is_stolen = 0;
|
||||
|
||||
public String imei;
|
||||
|
||||
public boolean checked = false, status = true;
|
||||
|
||||
public Vehicle()
|
||||
{
|
||||
this.sc_id = -1;
|
||||
this.lp = -1;
|
||||
}
|
||||
|
||||
public Vehicle(long sc_id, String imei, long lp, String name, long driver_id, int time_route, int GPS_reporting_interval, int is_stolen)
|
||||
{
|
||||
this.sc_id = sc_id;
|
||||
this.imei = imei;
|
||||
this.lp = lp;
|
||||
this.name = name;
|
||||
this.driver_id = driver_id;
|
||||
this.time_route = time_route;
|
||||
this.GPS_reporting_interval = GPS_reporting_interval;
|
||||
this.is_stolen = is_stolen;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "sc_id: " + sc_id + "imei: " + imei + "name: " + name + " | driver_id: " + driver_id + " | GPS: " + GPS_reporting_interval + " | checked: " + checked + " | status: " + (status ? "ON" : "OFF");
|
||||
}
|
||||
|
||||
public int getSmallIcon()
|
||||
{
|
||||
return getSmallIconPRV(driver_id);
|
||||
}
|
||||
|
||||
private int getSmallIconPRV(long driver_id)
|
||||
{
|
||||
switch ((int)driver_id)
|
||||
{
|
||||
case 1: return R.drawable.peopleblue;
|
||||
case 2: return R.drawable.peoplegreen;
|
||||
case 3: return R.drawable.peoplegrey;
|
||||
case 4: return R.drawable.peoplepink;
|
||||
case 5: return R.drawable.peoplepurple;
|
||||
case 78: return R.drawable.ambulance;
|
||||
case 79: return R.drawable.army;
|
||||
case 80: return R.drawable.bigcar0;
|
||||
case 81: return R.drawable.bigcar1;
|
||||
case 82: return R.drawable.bigcar2;
|
||||
case 83: return R.drawable.bus;
|
||||
case 84: return R.drawable.bus0;
|
||||
case 85: return R.drawable.bus2;
|
||||
case 86: return R.drawable.cabrioletred;
|
||||
case 87: return R.drawable.car0;
|
||||
case 88: return R.drawable.car1;
|
||||
case 89: return R.drawable.car2;
|
||||
case 90: return R.drawable.car3;
|
||||
case 91: return R.drawable.cargrey;
|
||||
case 92: return R.drawable.classiccar;
|
||||
case 93: return R.drawable.classycar;
|
||||
case 94: return R.drawable.dodge;
|
||||
case 95: return R.drawable.fireescape;
|
||||
case 96: return R.drawable.firefighters2;
|
||||
case 97: return R.drawable.firetruck1;
|
||||
case 98: return R.drawable.firetruck2;
|
||||
case 99: return R.drawable.jeep;
|
||||
case 100: return R.drawable.longhaul;
|
||||
case 101: return R.drawable.lorrygreen;
|
||||
case 102: return R.drawable.minibus;
|
||||
case 103: return R.drawable.minicar;
|
||||
case 104: return R.drawable.minicar2;
|
||||
case 105: return R.drawable.police;
|
||||
case 106: return R.drawable.police1;
|
||||
case 107: return R.drawable.schoolbus;
|
||||
case 108: return R.drawable.schoolbus2;
|
||||
case 109: return R.drawable.taxi;
|
||||
case 110: return R.drawable.towtruckyellow;
|
||||
case 111: return R.drawable.tractorunitblack;
|
||||
case 112: return R.drawable.truck0;
|
||||
case 113: return R.drawable.truck1;
|
||||
case 114: return R.drawable.truck2;
|
||||
case 115: return R.drawable.truck3;
|
||||
case 116: return R.drawable.truck4;
|
||||
case 117: return R.drawable.truck5;
|
||||
case 118: return R.drawable.truck6;
|
||||
case 119: return R.drawable.truckyellow;
|
||||
case 120: return R.drawable.wagon;
|
||||
default: return R.drawable.peopleblue;
|
||||
}
|
||||
}
|
||||
|
||||
public int getLargeIcon()
|
||||
{
|
||||
return getLargeIconPRV(driver_id);
|
||||
}
|
||||
|
||||
private int getLargeIconPRV(long driver_id)
|
||||
{
|
||||
switch((int)driver_id)
|
||||
{
|
||||
case 1: return R.drawable.peopleblue_large;
|
||||
case 2: return R.drawable.peoplegreen_large;
|
||||
case 3: return R.drawable.peoplegrey_large;
|
||||
case 4: return R.drawable.peoplepink_large;
|
||||
case 5: return R.drawable.peoplepurple_large;
|
||||
case 78: return R.drawable.ambulance_large;
|
||||
case 79: return R.drawable.army_large;
|
||||
case 80: return R.drawable.bigcar0_large;
|
||||
case 81: return R.drawable.bigcar1_large;
|
||||
case 82: return R.drawable.bigcar2_large;
|
||||
case 83: return R.drawable.bus_large;
|
||||
case 84: return R.drawable.bus0_large;
|
||||
case 85: return R.drawable.bus2_large;
|
||||
case 86: return R.drawable.cabrioletred_large;
|
||||
case 87: return R.drawable.car0_large;
|
||||
case 88: return R.drawable.car1_large;
|
||||
case 89: return R.drawable.car2_large;
|
||||
case 90: return R.drawable.car3_large;
|
||||
case 91: return R.drawable.cargrey_large;
|
||||
case 92: return R.drawable.classiccar_large;
|
||||
case 93: return R.drawable.classycar_large;
|
||||
case 94: return R.drawable.dodge_large;
|
||||
case 95: return R.drawable.fireescape_large;
|
||||
case 96: return R.drawable.firefighters2_large;
|
||||
case 97: return R.drawable.firetruck1_large;
|
||||
case 98: return R.drawable.firetruck2_large;
|
||||
case 99: return R.drawable.jeep_large;
|
||||
case 100: return R.drawable.longhaul_large;
|
||||
case 101: return R.drawable.lorrygreen_large;
|
||||
case 102: return R.drawable.minibus_large;
|
||||
case 103: return R.drawable.minicar_large;
|
||||
case 104: return R.drawable.minicar2_large;
|
||||
case 105: return R.drawable.police_large;
|
||||
case 106: return R.drawable.police1_large;
|
||||
case 107: return R.drawable.schoolbus_large;
|
||||
case 108: return R.drawable.schoolbus2_large;
|
||||
case 109: return R.drawable.taxi_large;
|
||||
case 110: return R.drawable.towtruckyellow_large;
|
||||
case 111: return R.drawable.tractorunitblack_large;
|
||||
case 112: return R.drawable.truck0_large;
|
||||
case 113: return R.drawable.truck1_large;
|
||||
case 114: return R.drawable.truck2_large;
|
||||
case 115: return R.drawable.truck3_large;
|
||||
case 116: return R.drawable.truck4_large;
|
||||
case 117: return R.drawable.truck5_large;
|
||||
case 118: return R.drawable.truck6_large;
|
||||
case 119: return R.drawable.truckyellow;
|
||||
case 120: return R.drawable.wagon;
|
||||
default: return R.drawable.peopleblue;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
333
libSafeMobile/src/main/java/com/safemobile/lib/XMLParser.java
Normal file
333
libSafeMobile/src/main/java/com/safemobile/lib/XMLParser.java
Normal file
@ -0,0 +1,333 @@
|
||||
package com.safemobile.lib;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import android.os.Environment;
|
||||
import android.util.Xml;
|
||||
|
||||
import com.safemobile.lib.radio.Channel;
|
||||
import com.safemobile.lib.radio.Zone;
|
||||
|
||||
public class XMLParser {
|
||||
private ConfigFile config;
|
||||
private ArrayList<String> xmlPath;
|
||||
|
||||
public XMLParser()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ArrayList<String> getXMLPath()
|
||||
{
|
||||
// reset xmlPath
|
||||
xmlPath = new ArrayList<String>();
|
||||
File file[] = Environment.getExternalStorageDirectory().listFiles();
|
||||
recursiveFileFind(file);
|
||||
|
||||
return xmlPath;
|
||||
}
|
||||
|
||||
public ConfigFile parseXML(InputStream input)
|
||||
{
|
||||
XmlPullParser parser = Xml.newPullParser();
|
||||
ArrayList<Contact> contacts = new ArrayList<Contact>();
|
||||
ArrayList<Zone> zones = new ArrayList<Zone>();
|
||||
Radio radio = new Radio();
|
||||
try
|
||||
{
|
||||
parser.setInput(input, null);
|
||||
Contact contact = null;
|
||||
Zone zone = null;
|
||||
Channel channel = null;
|
||||
int eventType = parser.getEventType();
|
||||
boolean done = false;
|
||||
while (eventType != XmlPullParser.END_DOCUMENT && !done){
|
||||
String name = null;
|
||||
switch (eventType){
|
||||
// build config object on xml start
|
||||
case XmlPullParser.START_DOCUMENT:
|
||||
config = new ConfigFile();
|
||||
break;
|
||||
// if start tag (ex. <configuration>, <contact>, <channel>)
|
||||
case XmlPullParser.START_TAG:
|
||||
name = parser.getName();
|
||||
if (name.equalsIgnoreCase("contact"))
|
||||
{
|
||||
|
||||
try {
|
||||
String section = parser.getAttributeValue(3);
|
||||
if(section.equalsIgnoreCase("Digital"))
|
||||
{
|
||||
/* <contact name='Call1' call-type='Group Call' call-id='1' section='Digital' /> */
|
||||
contact = new Contact(0,"", 0,1,1);
|
||||
// get id and name for Contact
|
||||
contact.name = parser.getAttributeValue(0);
|
||||
String type = parser.getAttributeValue(1);
|
||||
|
||||
if(type.equals("Private Call"))
|
||||
contact.contactType = Contact.PRIVATE;
|
||||
else if (type.equals("Group Call"))
|
||||
contact.contactType = Contact.GROUP;
|
||||
contact.id = Integer.parseInt(parser.getAttributeValue(2));
|
||||
}
|
||||
else
|
||||
contact = null;
|
||||
}
|
||||
catch (Exception e) {
|
||||
SM.Exception(e.toString());
|
||||
contact.id = 0;
|
||||
}
|
||||
}
|
||||
else if (name.equalsIgnoreCase("radio-id"))
|
||||
{
|
||||
/* <radio-id>101</radio-id> */
|
||||
try {
|
||||
// get radio id
|
||||
radio.id = Integer.parseInt(parser.nextText());
|
||||
}
|
||||
catch(Exception ex) {
|
||||
SM.Debug(ex.toString());
|
||||
}
|
||||
}
|
||||
else if (name.equalsIgnoreCase("radio-ip"))
|
||||
{
|
||||
/* <radio-ip>192.168.10.1</radio-ip> */
|
||||
// get radio ip
|
||||
radio.ip = parser.nextText();
|
||||
}
|
||||
else if (name.equalsIgnoreCase("zone"))
|
||||
{
|
||||
/* <zone position='1' name='zone1'> */
|
||||
zone = new Zone();
|
||||
try {
|
||||
// set zone Id, Number and Name
|
||||
zone.dbID = Integer.valueOf(parser.getAttributeValue(0));
|
||||
zone.id = Integer.valueOf(parser.getAttributeValue(0));
|
||||
zone.ZoneName = parser.getAttributeValue(1);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
SM.Debug(ex.toString());
|
||||
}
|
||||
}
|
||||
else if(name.equalsIgnoreCase("channel"))
|
||||
{
|
||||
/* <channel position='1' name='Channel1' /> */
|
||||
channel = new Channel();
|
||||
try {
|
||||
// set channel Id, Number and Name
|
||||
channel.chName = parser.getAttributeValue(1);
|
||||
channel.dbID = Integer.valueOf(parser.getAttributeValue(0));
|
||||
channel.id = Integer.valueOf(parser.getAttributeValue(0));
|
||||
}
|
||||
catch(Exception ex) {
|
||||
SM.Debug(ex.toString());
|
||||
}
|
||||
}
|
||||
break;
|
||||
// if end tag (ex. </contacts>, </contact>, </channel>)
|
||||
case XmlPullParser.END_TAG:
|
||||
name = parser.getName();
|
||||
if (name.equalsIgnoreCase("contact") && contact != null)
|
||||
{
|
||||
if(contact.contactType == Contact.PRIVATE || contact.contactType == Contact.GROUP)
|
||||
contacts.add(contact); // add contact to Contacts list
|
||||
}
|
||||
else if (name.equalsIgnoreCase("channel"))
|
||||
zone.channelList.add(channel); // add channel to Channels List
|
||||
else if (name.equalsIgnoreCase("zone"))
|
||||
zones.add(zone); // add zone to Zones List
|
||||
else if (name.equalsIgnoreCase("configuration"))
|
||||
done = true; // flag finish parsing
|
||||
break;
|
||||
}
|
||||
eventType = parser.next();
|
||||
}
|
||||
|
||||
// add Lists to config
|
||||
config.contacts = contacts;
|
||||
config.radio = radio;
|
||||
|
||||
// check if every zone has at least a channel and if not, create one
|
||||
for(Zone zn :zones)
|
||||
{
|
||||
if(zn.channelList==null || (zn.channelList!=null && zn.channelList.size()== 0))
|
||||
{
|
||||
zn.channelList = new ArrayList<Channel>();
|
||||
Channel ch = new Channel();
|
||||
ch.dbID = 0;
|
||||
ch.chName = "N/A";
|
||||
ch.id = 0;
|
||||
zn.channelList.add(ch);
|
||||
}
|
||||
}
|
||||
|
||||
config.zones = zones;
|
||||
|
||||
//SM.Debug("CONFIG", config.toLongString());
|
||||
}
|
||||
catch (XmlPullParserException e) {
|
||||
//e.printStackTrace();
|
||||
SM.Exception(e.toString());
|
||||
|
||||
config = null;
|
||||
}
|
||||
catch (IOException e) {
|
||||
//e.printStackTrace();
|
||||
SM.Exception(e.toString());
|
||||
|
||||
config = null;
|
||||
}
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
// get files and directory for crt Directory (file1)
|
||||
private void recursiveFileFind(File[] crtFile){
|
||||
int i = 0;
|
||||
String filePath="";
|
||||
if(crtFile!=null)
|
||||
{
|
||||
while(i != crtFile.length)
|
||||
{
|
||||
// get absolute path for crtFile
|
||||
filePath = crtFile[i].getPath();
|
||||
if(crtFile[i].isDirectory()){
|
||||
// if crt file is a Directory get files for new file
|
||||
File file[] = crtFile[i].listFiles();
|
||||
recursiveFileFind(file);
|
||||
}
|
||||
i++;
|
||||
// if crtFile path extension is xml, add to ArrayList
|
||||
if(filePath.substring(filePath.length()-4, filePath.length()).equalsIgnoreCase(".xml"))
|
||||
{
|
||||
xmlPath.add(filePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean downloadXMLFile(String Path)
|
||||
{
|
||||
try {
|
||||
//set the download URL, a url that points to a file on the internet
|
||||
//this is the file to be downloaded
|
||||
//Path = "http://www.safemobile.com/upload/codeplugs/037TMA2140.xml";
|
||||
URL url = new URL(Path);
|
||||
//create the new connection
|
||||
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
|
||||
|
||||
//set up some things on the connection
|
||||
urlConnection.setRequestMethod("GET");
|
||||
urlConnection.setDoOutput(true);
|
||||
|
||||
//and connect!
|
||||
urlConnection.connect();
|
||||
|
||||
//set the path where we want to save the file
|
||||
//in this case, going to save it on the root directory of the
|
||||
//sd card.
|
||||
File SDCardRoot = Environment.getExternalStorageDirectory();
|
||||
//create a new file, specifying the path, and the filename
|
||||
//which we want to save the file as.
|
||||
File file = new File(SDCardRoot,"radioConfigFile.xml");
|
||||
|
||||
//this will be used to write the downloaded data into the file we created
|
||||
FileOutputStream fileOutput = new FileOutputStream(file);
|
||||
|
||||
//this will be used in reading the data from the internet
|
||||
InputStream inputStream = urlConnection.getInputStream();
|
||||
|
||||
//this is the total size of the file
|
||||
//int totalSize = urlConnection.getContentLength();
|
||||
//variable to store total downloaded bytes
|
||||
int downloadedSize = 0;
|
||||
|
||||
//create a buffer...
|
||||
byte[] buffer = new byte[1024];
|
||||
int bufferLength = 0; //used to store a temporary size of the buffer
|
||||
|
||||
//now, read through the input buffer and write the contents to the file
|
||||
while ( (bufferLength = inputStream.read(buffer)) > 0 ) {
|
||||
//add the data in the buffer to the file in the file output stream (the file on the sd card
|
||||
fileOutput.write(buffer, 0, bufferLength);
|
||||
//add up the size so we know how much is downloaded
|
||||
downloadedSize += bufferLength;
|
||||
}
|
||||
//close the output stream when done
|
||||
fileOutput.close();
|
||||
SM.Debug(" ############## FINISH " + downloadedSize);
|
||||
return true;
|
||||
|
||||
//catch some possible errors...
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
SM.Exception(e.toString());
|
||||
|
||||
File SDCardRoot = Environment.getExternalStorageDirectory();
|
||||
//delete file is failed to download
|
||||
File file = new File(SDCardRoot,"radioConfigFile.xml");
|
||||
Boolean result = file.delete();
|
||||
SM.Debug("DELETE FILE: " + result);
|
||||
return false;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
SM.Exception(e.toString());
|
||||
|
||||
File SDCardRoot = Environment.getExternalStorageDirectory();
|
||||
//delete file is failed to download
|
||||
File file = new File(SDCardRoot,"radioConfigFile.xml");
|
||||
Boolean result = file.delete();
|
||||
SM.Debug("DELETE FILE: " + result);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
private InputStream getTextFile(FileInputStream inputStream)
|
||||
{
|
||||
InputStream input = inputStream;
|
||||
|
||||
int read;
|
||||
FileOutputStream fos = new FileOutputStream(new File(path + ".tmp"));
|
||||
|
||||
//DataOutputStream os = new DataOutputStream(new FileOutputStream("\\data\\data\\com.safemobile.radiopadd\\files\\"));
|
||||
try {
|
||||
input = new DataInputStream(new FileInputStream("c:\\binary.smc"));
|
||||
while (true) { // exception deals catches EOF
|
||||
read = input.r
|
||||
fos.write(read);
|
||||
//os.writeInt(is.readByte());
|
||||
}
|
||||
} catch (EOFException eof) {
|
||||
System.out.println("Normal program termination.");
|
||||
} catch (FileNotFoundException noFile) {
|
||||
System.err.println("File not found! " + noFile);
|
||||
} catch (IOException io) {
|
||||
System.err.println("I/O error occurred: " + io);
|
||||
} catch (Throwable anything) {
|
||||
System.err.println("Abnormal exception caught !: " + anything);
|
||||
} finally {
|
||||
if (is != null) {
|
||||
try {
|
||||
is.close();
|
||||
os.close();
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package com.safemobile.lib.radio;
|
||||
|
||||
public class Channel {
|
||||
|
||||
public int dbID;
|
||||
public int id;
|
||||
public String chName;
|
||||
|
||||
public Channel()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Channel(int dbId, int id, String chName) {
|
||||
this.dbID = dbId;
|
||||
this.id = id;
|
||||
this.chName = chName;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "dbID: " + dbID + " | id: " + id + " | chName: " + chName ;
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.safemobile.lib.radio;
|
||||
|
||||
public class Emerg {
|
||||
public int function = 0;
|
||||
public int status = 0;
|
||||
|
||||
public Emerg(){
|
||||
|
||||
}
|
||||
public String toString()
|
||||
{
|
||||
return "function: " + function + " | status: " + status ;
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
package com.safemobile.lib.radio;
|
||||
|
||||
import com.safemobile.lib.AppParams;
|
||||
import com.safemobile.lib.Mic;
|
||||
|
||||
public class IncCall {
|
||||
public int gwID;
|
||||
public int rgwID;
|
||||
public long Imei;
|
||||
public int callStatus;
|
||||
public int callType;
|
||||
public int groupId;
|
||||
public int userID;
|
||||
public int opCode;
|
||||
public Mic mic = null;
|
||||
|
||||
public long callerID = 0;
|
||||
public long callDestID = 0;
|
||||
|
||||
public IncCall(){
|
||||
|
||||
}
|
||||
public String toString()
|
||||
{
|
||||
return " Imei: " + Imei + " | opCode: " + opCode
|
||||
+ " | callStatus: " + callStatus+ " | callType: " + callType
|
||||
+ " | groupId: " + groupId + " | userID: " + userID;
|
||||
}
|
||||
|
||||
public static String getCallTypeAsString(int type) {
|
||||
switch (type) {
|
||||
case AppParams.MotoAllCall: return "All Call";
|
||||
case AppParams.MotoGroup: return "Group Call";
|
||||
case AppParams.MotoPrivate: return "Private Call";
|
||||
default: return "";
|
||||
}
|
||||
}
|
||||
|
||||
public static String getCallStatusAsString(int status) {
|
||||
switch (status) {
|
||||
case AppParams.InProgress: return "In Progress";
|
||||
case AppParams.Initiated: return "Initiated";
|
||||
case AppParams.Decoded: return "Decoded";
|
||||
case AppParams.Hangtime: return "Hangtime";
|
||||
case AppParams.Ended: return "Ended";
|
||||
default: return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
public static String getCallInitiatorAsString(final long myID, int userID) {
|
||||
if(userID == myID)
|
||||
return "my Android";
|
||||
else if (userID == 0)
|
||||
return "Portable";
|
||||
else
|
||||
return "other Android";
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package com.safemobile.lib.radio;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class RadioGW {
|
||||
public int ID;
|
||||
public int GW_ID;
|
||||
public String IP;
|
||||
public String IMEI;
|
||||
public ArrayList<Zone> zoneList;
|
||||
public int lastZoneNr = 0;
|
||||
public int lastChannelNr = 0;
|
||||
public boolean isOnline = false;
|
||||
|
||||
public RadioGW(){zoneList = new ArrayList<Zone>();}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "ID: " + ID + " | GW_ID: " + GW_ID + " | IP: " + IP
|
||||
+ " | IMEI: " + IMEI ;
|
||||
}
|
||||
|
||||
public String getChannelName() {
|
||||
for(Zone zone: zoneList) {
|
||||
if(zone.id == lastZoneNr) {
|
||||
for(Channel ch: zone.channelList) {
|
||||
if(ch.id == lastChannelNr)
|
||||
return ch.chName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
public String getZoneName() {
|
||||
for(Zone zone: zoneList) {
|
||||
if(zone.id == lastZoneNr)
|
||||
return zone.ZoneName;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.safemobile.lib.radio;
|
||||
|
||||
public class RadioStatus {
|
||||
public int gwID = 0;
|
||||
public int rgwID = 0;
|
||||
public int status = 0;
|
||||
|
||||
public IncCall incCall = new IncCall();
|
||||
|
||||
public RadioStatus(){
|
||||
|
||||
}
|
||||
public String toString()
|
||||
{
|
||||
return "gwID: " + gwID + " | rgwID: " + rgwID + " | status: " + status;
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.safemobile.lib.radio;
|
||||
|
||||
public class SUstatus {
|
||||
public int imei;
|
||||
public int status;
|
||||
|
||||
public SUstatus(){
|
||||
|
||||
}
|
||||
public String toString()
|
||||
{
|
||||
return "imei: " + imei + " | status: " + status ;
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package com.safemobile.lib.radio;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
|
||||
public class Zone {
|
||||
public int dbID;
|
||||
public int id;
|
||||
public String ZoneName="";
|
||||
|
||||
public ArrayList<Channel> channelList = new ArrayList<Channel>();
|
||||
public Zone()
|
||||
{
|
||||
channelList = new ArrayList<Channel>();
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "zoneDbID: " + id +" |zoneID: " + dbID + " | ZoneName: " + ZoneName ;
|
||||
}
|
||||
|
||||
/**
|
||||
* sort the list of channels based on their names
|
||||
*/
|
||||
public void sortChannelListByName() {
|
||||
//Sorting
|
||||
Collections.sort(channelList, new Comparator<Channel>() {
|
||||
@Override
|
||||
public int compare(Channel channel1, Channel channel2)
|
||||
{
|
||||
return channel1.chName.compareTo(channel2.chName);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* sort the list of channels based on their ids
|
||||
*/
|
||||
public void sortChannelListByChannelID() {
|
||||
//Sorting
|
||||
Collections.sort(channelList, new Comparator<Channel>() {
|
||||
@Override
|
||||
public int compare(Channel channel1, Channel channel2)
|
||||
{
|
||||
return (channel1.id < channel2.id ? 1 : 0);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package com.safemobile.lib.radio;
|
||||
|
||||
public class ZoneChannel {
|
||||
|
||||
private Zone zone;
|
||||
private Channel channel;
|
||||
private boolean isSection = false;
|
||||
|
||||
public ZoneChannel(Zone zone) {
|
||||
setZone(zone);
|
||||
setSection(true);
|
||||
}
|
||||
|
||||
public ZoneChannel(Zone zone, Channel channel) {
|
||||
setZone(zone);
|
||||
setChannel(channel);
|
||||
if(channel != null)
|
||||
setSection(false);
|
||||
else
|
||||
setSection(true);
|
||||
}
|
||||
|
||||
public Zone getZone() {
|
||||
return zone;
|
||||
}
|
||||
|
||||
public void setZone(Zone zone) {
|
||||
this.zone = zone;
|
||||
}
|
||||
|
||||
public Channel getChannel() {
|
||||
return channel;
|
||||
}
|
||||
|
||||
public void setChannel(Channel channel) {
|
||||
this.channel = channel;
|
||||
}
|
||||
|
||||
public boolean isSection() {
|
||||
return isSection;
|
||||
}
|
||||
|
||||
public void setSection(boolean isSection) {
|
||||
this.isSection = isSection;
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.safemobile.lib.radio;
|
||||
|
||||
public class Zone_and_channel {
|
||||
public int gwID = 0;
|
||||
public int rgwID = 0;
|
||||
public int zoneNr = 0;
|
||||
public int channelNr = 0;
|
||||
|
||||
public Zone_and_channel(){
|
||||
|
||||
}
|
||||
public String toString()
|
||||
{
|
||||
return "gwID: " + gwID + " | rgwID: " + rgwID + " | zoneNr: " + zoneNr
|
||||
+ " | mechannelNrss: " + channelNr ;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user