package keymon.lat.medicomed; import anywheresoftware.b4a.BA; import anywheresoftware.b4a.objects.ServiceHelper; import anywheresoftware.b4a.debug.*; public class tracker extends android.app.Service{ public static class tracker_BR extends android.content.BroadcastReceiver { @Override public void onReceive(android.content.Context context, android.content.Intent intent) { BA.LogInfo("** Receiver (tracker) OnReceive **"); android.content.Intent in = new android.content.Intent(context, tracker.class); if (intent != null) in.putExtra("b4a_internal_intent", intent); ServiceHelper.StarterHelper.startServiceFromReceiver (context, in, false, BA.class); } } static tracker mostCurrent; public static BA processBA; private ServiceHelper _service; public static Class getObject() { return tracker.class; } @Override public void onCreate() { super.onCreate(); mostCurrent = this; if (processBA == null) { processBA = new BA(this, null, null, "keymon.lat.medicomed", "keymon.lat.medicomed.tracker"); if (BA.isShellModeRuntimeCheck(processBA)) { processBA.raiseEvent2(null, true, "SHELL", false); } try { Class.forName(BA.applicationContext.getPackageName() + ".main").getMethod("initializeProcessGlobals").invoke(null, null); } catch (Exception e) { throw new RuntimeException(e); } processBA.loadHtSubs(this.getClass()); ServiceHelper.init(); } _service = new ServiceHelper(this); processBA.service = this; if (BA.isShellModeRuntimeCheck(processBA)) { processBA.raiseEvent2(null, true, "CREATE", true, "keymon.lat.medicomed.tracker", processBA, _service, anywheresoftware.b4a.keywords.Common.Density); } if (!false && ServiceHelper.StarterHelper.startFromServiceCreate(processBA, false) == false) { } else { processBA.setActivityPaused(false); BA.LogInfo("*** Service (tracker) Create ***"); processBA.raiseEvent(null, "service_create"); } processBA.runHook("oncreate", this, null); if (false) { if (ServiceHelper.StarterHelper.runWaitForLayouts() == false) { BA.LogInfo("stopping spontaneous created service"); stopSelf(); } } } @Override public void onStart(android.content.Intent intent, int startId) { onStartCommand(intent, 0, 0); } @Override public int onStartCommand(final android.content.Intent intent, int flags, int startId) { if (ServiceHelper.StarterHelper.onStartCommand(processBA, new Runnable() { public void run() { handleStart(intent); }})) ; else { ServiceHelper.StarterHelper.addWaitForLayout (new Runnable() { public void run() { processBA.setActivityPaused(false); BA.LogInfo("** Service (tracker) Create **"); processBA.raiseEvent(null, "service_create"); handleStart(intent); ServiceHelper.StarterHelper.removeWaitForLayout(); } }); } processBA.runHook("onstartcommand", this, new Object[] {intent, flags, startId}); return android.app.Service.START_NOT_STICKY; } public void onTaskRemoved(android.content.Intent rootIntent) { super.onTaskRemoved(rootIntent); if (false) processBA.raiseEvent(null, "service_taskremoved"); } private void handleStart(android.content.Intent intent) { BA.LogInfo("** Service (tracker) Start **"); java.lang.reflect.Method startEvent = processBA.htSubs.get("service_start"); if (startEvent != null) { if (startEvent.getParameterTypes().length > 0) { anywheresoftware.b4a.objects.IntentWrapper iw = ServiceHelper.StarterHelper.handleStartIntent(intent, _service, processBA); processBA.raiseEvent(null, "service_start", iw); } else { processBA.raiseEvent(null, "service_start"); } } } @Override public void onDestroy() { super.onDestroy(); if (false) { BA.LogInfo("** Service (tracker) Destroy (ignored)**"); } else { BA.LogInfo("** Service (tracker) Destroy **"); processBA.raiseEvent(null, "service_destroy"); processBA.service = null; mostCurrent = null; processBA.setActivityPaused(true); processBA.runHook("ondestroy", this, null); } } @Override public android.os.IBinder onBind(android.content.Intent intent) { return null; }public anywheresoftware.b4a.keywords.Common __c = null; public static int _nid = 0; public static boolean _tracking = false; public static anywheresoftware.b4a.phone.Phone.PhoneWakeState _lock = null; public static uk.co.martinpearman.b4a.fusedlocationprovider.FusedLocationProviderWrapper _flp = null; public static uk.co.martinpearman.b4a.fusedlocationprovider.LocationRequest _actuallr = null; public static boolean _flpstarted = false; public static anywheresoftware.b4a.gps.LocationWrapper _uugcoords = null; public b4a.example.dateutils _dateutils = null; public keymon.lat.medicomed.main _main = null; public keymon.lat.medicomed.starter _starter = null; public keymon.lat.medicomed.subs _subs = null; public keymon.lat.medicomed.appupdater _appupdater = null; public keymon.lat.medicomed.mapa_rutas _mapa_rutas = null; public keymon.lat.medicomed.newinst2 _newinst2 = null; public keymon.lat.medicomed.b4xpages _b4xpages = null; public keymon.lat.medicomed.b4xcollections _b4xcollections = null; public keymon.lat.medicomed.httputils2service _httputils2service = null; public keymon.lat.medicomed.xuiviewsutils _xuiviewsutils = null; public static uk.co.martinpearman.b4a.fusedlocationprovider.LocationRequest _createlocationrequest() throws Exception{ uk.co.martinpearman.b4a.fusedlocationprovider.LocationRequest _lr = null; //BA.debugLineNum = 111;BA.debugLine="Private Sub CreateLocationRequest As LocationReque"; //BA.debugLineNum = 113;BA.debugLine="Dim lr As LocationRequest"; _lr = new uk.co.martinpearman.b4a.fusedlocationprovider.LocationRequest(); //BA.debugLineNum = 114;BA.debugLine="lr.Initialize"; _lr.Initialize(); //BA.debugLineNum = 115;BA.debugLine="lr.SetInterval(10000) 'Intervalo deseado para act"; _lr.SetInterval((long) (10000)); //BA.debugLineNum = 116;BA.debugLine="lr.SetFastestInterval(lr.GetInterval / 2) 'Interv"; _lr.SetFastestInterval((long) (_lr.GetInterval()/(double)2)); //BA.debugLineNum = 117;BA.debugLine="lr.SetSmallestDisplacement(50) 'Solo registra cam"; _lr.SetSmallestDisplacement((float) (50)); //BA.debugLineNum = 118;BA.debugLine="lr.SetPriority(lr.Priority.PRIORITY_HIGH_ACCURACY"; _lr.SetPriority(_lr.Priority.PRIORITY_HIGH_ACCURACY); //BA.debugLineNum = 119;BA.debugLine="actualLR=lr"; _actuallr = _lr; //BA.debugLineNum = 120;BA.debugLine="Return lr"; if (true) return _lr; //BA.debugLineNum = 121;BA.debugLine="End Sub"; return null; } public static uk.co.martinpearman.b4a.fusedlocationprovider.LocationRequest _createlocationrequestsmalld() throws Exception{ uk.co.martinpearman.b4a.fusedlocationprovider.LocationRequest _lr = null; //BA.debugLineNum = 123;BA.debugLine="Private Sub CreateLocationRequestSmallD As Locatio"; //BA.debugLineNum = 125;BA.debugLine="Dim lr As LocationRequest"; _lr = new uk.co.martinpearman.b4a.fusedlocationprovider.LocationRequest(); //BA.debugLineNum = 126;BA.debugLine="lr.Initialize"; _lr.Initialize(); //BA.debugLineNum = 127;BA.debugLine="lr.SetInterval(2000) 'Intervalo deseado para actu"; _lr.SetInterval((long) (2000)); //BA.debugLineNum = 128;BA.debugLine="lr.SetFastestInterval(lr.GetInterval / 2) 'Interv"; _lr.SetFastestInterval((long) (_lr.GetInterval()/(double)2)); //BA.debugLineNum = 129;BA.debugLine="lr.setNumUpdates(2) 'Solicitamos solo 2 actualiza"; _lr.SetNumUpdates((int) (2)); //BA.debugLineNum = 130;BA.debugLine="lr.SetSmallestDisplacement(0) 'Solo registra camb"; _lr.SetSmallestDisplacement((float) (0)); //BA.debugLineNum = 131;BA.debugLine="lr.SetPriority(lr.Priority.PRIORITY_HIGH_ACCURACY"; _lr.SetPriority(_lr.Priority.PRIORITY_HIGH_ACCURACY); //BA.debugLineNum = 132;BA.debugLine="actualLR=lr"; _actuallr = _lr; //BA.debugLineNum = 133;BA.debugLine="Return lr"; if (true) return _lr; //BA.debugLineNum = 134;BA.debugLine="End Sub"; return null; } public static anywheresoftware.b4a.objects.NotificationWrapper _createnotification(String _body) throws Exception{ anywheresoftware.b4a.objects.NotificationWrapper _notification = null; //BA.debugLineNum = 194;BA.debugLine="Sub CreateNotification (Body As String) As Notific"; //BA.debugLineNum = 195;BA.debugLine="Dim notification As Notification"; _notification = new anywheresoftware.b4a.objects.NotificationWrapper(); //BA.debugLineNum = 196;BA.debugLine="notification.Initialize2(notification.IMPORTANCE_"; _notification.Initialize2(_notification.IMPORTANCE_LOW); //BA.debugLineNum = 197;BA.debugLine="notification.Icon = \"icon\""; _notification.setIcon("icon"); //BA.debugLineNum = 198;BA.debugLine="notification.SetInfo(\"Medicomed\", Body, Main)"; _notification.SetInfoNew(processBA,BA.ObjectToCharSequence("Medicomed"),BA.ObjectToCharSequence(_body),(Object)(mostCurrent._main.getObject())); //BA.debugLineNum = 199;BA.debugLine="Return notification"; if (true) return _notification; //BA.debugLineNum = 200;BA.debugLine="End Sub"; return null; } public static String _dameultimaubicacionconocida() throws Exception{ String _coords = ""; //BA.debugLineNum = 136;BA.debugLine="Sub dameUltimaUbicacionConocida"; //BA.debugLineNum = 137;BA.debugLine="If FLP.GetLastKnownLocation.IsInitialized Then 'M"; if (_flp.GetLastKnownLocation().IsInitialized()) { //BA.debugLineNum = 139;BA.debugLine="If Starter.Logger Then LogColor($\"Mandamos UUC \""; if (mostCurrent._starter._logger /*boolean*/ ) { anywheresoftware.b4a.keywords.Common.LogImpl("365994755",("Mandamos UUC \""+anywheresoftware.b4a.keywords.Common.SmartStringFormatter("",(Object)(mostCurrent._subs._fechakmt /*String*/ (processBA,BA.NumberToString(_flp.GetLastKnownLocation().getTime()))))+"|Acc:"+anywheresoftware.b4a.keywords.Common.SmartStringFormatter("0.2",(Object)(_flp.GetLastKnownLocation().getAccuracy()))+"|"+anywheresoftware.b4a.keywords.Common.SmartStringFormatter("0.8",(Object)(_flp.GetLastKnownLocation().getLatitude()))+"|"+anywheresoftware.b4a.keywords.Common.SmartStringFormatter("0.8",(Object)(_flp.GetLastKnownLocation().getLongitude()))+"|Spd:"+anywheresoftware.b4a.keywords.Common.SmartStringFormatter("0.2",(Object)(_flp.GetLastKnownLocation().getSpeed()))+"|"),anywheresoftware.b4a.keywords.Common.Colors.RGB((int) (255),(int) (112),(int) (35)));}; //BA.debugLineNum = 140;BA.debugLine="Dim coords As String = FLP.GetLastKnownLocation."; _coords = BA.NumberToString(_flp.GetLastKnownLocation().getLatitude())+","+BA.NumberToString(_flp.GetLastKnownLocation().getLongitude())+","+_formatofecha(BA.NumberToString(_flp.GetLastKnownLocation().getTime())); }; //BA.debugLineNum = 144;BA.debugLine="End Sub"; return ""; } public static String _flp_connectionfailed(int _connectionresult1) throws Exception{ //BA.debugLineNum = 55;BA.debugLine="Sub flp_ConnectionFailed(ConnectionResult1 As Int)"; //BA.debugLineNum = 56;BA.debugLine="Log(\"Failed to connect to location provider\")"; anywheresoftware.b4a.keywords.Common.LogImpl("365536001","Failed to connect to location provider",0); //BA.debugLineNum = 57;BA.debugLine="End Sub"; return ""; } public static String _flp_connectionsuccess() throws Exception{ //BA.debugLineNum = 50;BA.debugLine="Sub flp_ConnectionSuccess"; //BA.debugLineNum = 53;BA.debugLine="End Sub"; return ""; } public static String _flp_locationchanged(anywheresoftware.b4a.gps.LocationWrapper _location1) throws Exception{ String _sdate = ""; String _stime = ""; String _coords = ""; //BA.debugLineNum = 154;BA.debugLine="Sub flp_LocationChanged (Location1 As Location)"; //BA.debugLineNum = 157;BA.debugLine="B4XPages.MainPage.lat_gps = Location1.Latitude"; mostCurrent._b4xpages._mainpage /*keymon.lat.medicomed.b4xmainpage*/ (processBA)._lat_gps /*String*/ = BA.NumberToString(_location1.getLatitude()); //BA.debugLineNum = 158;BA.debugLine="B4XPages.MainPage.lon_gps = Location1.Longitude"; mostCurrent._b4xpages._mainpage /*keymon.lat.medicomed.b4xmainpage*/ (processBA)._lon_gps /*String*/ = BA.NumberToString(_location1.getLongitude()); //BA.debugLineNum = 159;BA.debugLine="UUGCoords = Location1"; _uugcoords = _location1; //BA.debugLineNum = 167;BA.debugLine="Dim sDate,sTime As String"; _sdate = ""; _stime = ""; //BA.debugLineNum = 168;BA.debugLine="DateTime.DateFormat = \"MM/dd/yyyy\""; anywheresoftware.b4a.keywords.Common.DateTime.setDateFormat("MM/dd/yyyy"); //BA.debugLineNum = 169;BA.debugLine="sDate=DateTime.Date(DateTime.Now)"; _sdate = anywheresoftware.b4a.keywords.Common.DateTime.Date(anywheresoftware.b4a.keywords.Common.DateTime.getNow()); //BA.debugLineNum = 170;BA.debugLine="sTime=DateTime.Time(DateTime.Now)"; _stime = anywheresoftware.b4a.keywords.Common.DateTime.Time(anywheresoftware.b4a.keywords.Common.DateTime.getNow()); //BA.debugLineNum = 171;BA.debugLine="If Not(B4XPages.MainPage.skmt.IsInitialized) Then"; if (anywheresoftware.b4a.keywords.Common.Not(mostCurrent._b4xpages._mainpage /*keymon.lat.medicomed.b4xmainpage*/ (processBA)._skmt /*anywheresoftware.b4a.sql.SQL*/ .IsInitialized())) { mostCurrent._b4xpages._mainpage /*keymon.lat.medicomed.b4xmainpage*/ (processBA)._skmt /*anywheresoftware.b4a.sql.SQL*/ .Initialize(mostCurrent._starter._ruta /*String*/ ,"kmt.db",anywheresoftware.b4a.keywords.Common.True);}; //BA.debugLineNum = 172;BA.debugLine="Try"; try { //BA.debugLineNum = 173;BA.debugLine="B4XPages.MainPage.skmt.ExecNonQuery2(\"INSERT INT"; mostCurrent._b4xpages._mainpage /*keymon.lat.medicomed.b4xmainpage*/ (processBA)._skmt /*anywheresoftware.b4a.sql.SQL*/ .ExecNonQuery2("INSERT INTO HIST_GPS (HGDATE, HGLAT, HGLON) VALUES(?,?,?) ",anywheresoftware.b4a.keywords.Common.ArrayToList(new Object[]{(Object)(_sdate+_stime),(Object)(mostCurrent._b4xpages._mainpage /*keymon.lat.medicomed.b4xmainpage*/ (processBA)._lat_gps /*String*/ ),(Object)(mostCurrent._b4xpages._mainpage /*keymon.lat.medicomed.b4xmainpage*/ (processBA)._lon_gps /*String*/ )})); //BA.debugLineNum = 174;BA.debugLine="B4XPages.MainPage.skmt.ExecNonQuery(\"DELETE FROM"; mostCurrent._b4xpages._mainpage /*keymon.lat.medicomed.b4xmainpage*/ (processBA)._skmt /*anywheresoftware.b4a.sql.SQL*/ .ExecNonQuery("DELETE FROM HIST_GPS"); } catch (Exception e13) { processBA.setLastException(e13); //BA.debugLineNum = 176;BA.debugLine="LogColor(LastException, Colors.Red)"; anywheresoftware.b4a.keywords.Common.LogImpl("366125846",BA.ObjectToString(anywheresoftware.b4a.keywords.Common.LastException(processBA)),anywheresoftware.b4a.keywords.Common.Colors.Red); }; //BA.debugLineNum = 179;BA.debugLine="Dim coords As String = Location1.Latitude&\",\"&Loc"; _coords = BA.NumberToString(_location1.getLatitude())+","+BA.NumberToString(_location1.getLongitude())+","+_formatofecha(BA.NumberToString(_location1.getTime())); //BA.debugLineNum = 184;BA.debugLine="If Location1.Accuracy < 100 Then"; if (_location1.getAccuracy()<100) { }; //BA.debugLineNum = 188;BA.debugLine="CallSub2(Starter, \"GPS_LocationChanged\", Location"; anywheresoftware.b4a.keywords.Common.CallSubNew2(processBA,(Object)(mostCurrent._starter.getObject()),"GPS_LocationChanged",(Object)(_location1)); //BA.debugLineNum = 192;BA.debugLine="End Sub"; return ""; } public static String _formatofecha(String _fecha) throws Exception{ String _origformat = ""; String _lastupdate = ""; //BA.debugLineNum = 210;BA.debugLine="Sub formatoFecha(fecha As String) As String 'Convi"; //BA.debugLineNum = 212;BA.debugLine="Dim OrigFormat As String = DateTime.DateFormat '"; _origformat = anywheresoftware.b4a.keywords.Common.DateTime.getDateFormat(); //BA.debugLineNum = 213;BA.debugLine="DateTime.DateFormat=\"yyMMddHHmmss\""; anywheresoftware.b4a.keywords.Common.DateTime.setDateFormat("yyMMddHHmmss"); //BA.debugLineNum = 214;BA.debugLine="Dim lastUpdate As String=DateTime.Date(fecha)"; _lastupdate = anywheresoftware.b4a.keywords.Common.DateTime.Date((long)(Double.parseDouble(_fecha))); //BA.debugLineNum = 215;BA.debugLine="DateTime.DateFormat=OrigFormat 'return to orig d"; anywheresoftware.b4a.keywords.Common.DateTime.setDateFormat(_origformat); //BA.debugLineNum = 217;BA.debugLine="Return lastUpdate"; if (true) return _lastupdate; //BA.debugLineNum = 218;BA.debugLine="End Sub"; return ""; } public static String _process_globals() throws Exception{ //BA.debugLineNum = 29;BA.debugLine="Sub Process_Globals"; //BA.debugLineNum = 30;BA.debugLine="Private nid As Int = 51042"; _nid = (int) (51042); //BA.debugLineNum = 31;BA.debugLine="Private Tracking As Boolean"; _tracking = false; //BA.debugLineNum = 32;BA.debugLine="Private lock As PhoneWakeState"; _lock = new anywheresoftware.b4a.phone.Phone.PhoneWakeState(); //BA.debugLineNum = 34;BA.debugLine="Public FLP As FusedLocationProvider"; _flp = new uk.co.martinpearman.b4a.fusedlocationprovider.FusedLocationProviderWrapper(); //BA.debugLineNum = 35;BA.debugLine="Dim actualLR As LocationRequest"; _actuallr = new uk.co.martinpearman.b4a.fusedlocationprovider.LocationRequest(); //BA.debugLineNum = 36;BA.debugLine="Private flpStarted As Boolean"; _flpstarted = false; //BA.debugLineNum = 38;BA.debugLine="Dim UUGCoords As Location 'Ultima Ubicacion Guard"; _uugcoords = new anywheresoftware.b4a.gps.LocationWrapper(); //BA.debugLineNum = 39;BA.debugLine="End Sub"; return ""; } public static String _revisaflp() throws Exception{ boolean _todobienflp = false; //BA.debugLineNum = 221;BA.debugLine="Sub revisaFLP 'ignore"; //BA.debugLineNum = 222;BA.debugLine="LogColor(\"**** **** Revisamos FLP **** ****\", Col"; anywheresoftware.b4a.keywords.Common.LogImpl("366387969","**** **** Revisamos FLP **** ****",anywheresoftware.b4a.keywords.Common.Colors.RGB((int) (78),(int) (0),(int) (227))); //BA.debugLineNum = 223;BA.debugLine="Private todoBienFLP As Boolean = True"; _todobienflp = anywheresoftware.b4a.keywords.Common.True; //BA.debugLineNum = 224;BA.debugLine="Try"; try { //BA.debugLineNum = 225;BA.debugLine="If Not(FLP.IsInitialized) Then"; if (anywheresoftware.b4a.keywords.Common.Not(_flp.IsInitialized())) { //BA.debugLineNum = 226;BA.debugLine="Subs.log2DB(\"revisaFLP: No esta inicializado .."; mostCurrent._subs._log2db /*String*/ (processBA,"revisaFLP: No esta inicializado ... 'Reinicializando FLP'"); //BA.debugLineNum = 227;BA.debugLine="FLP.Initialize(\"flp\")"; _flp.Initialize(processBA,"flp"); //BA.debugLineNum = 228;BA.debugLine="todoBienFLP = False"; _todobienflp = anywheresoftware.b4a.keywords.Common.False; }; } catch (Exception e10) { processBA.setLastException(e10); //BA.debugLineNum = 231;BA.debugLine="LogColor(\"If Not(Tracker.FLP.IsInitialized) -->"; anywheresoftware.b4a.keywords.Common.LogImpl("366387978","If Not(Tracker.FLP.IsInitialized) --> "+BA.ObjectToString(anywheresoftware.b4a.keywords.Common.LastException(processBA)),anywheresoftware.b4a.keywords.Common.Colors.Red); }; //BA.debugLineNum = 233;BA.debugLine="Try"; try { //BA.debugLineNum = 234;BA.debugLine="If FLP.IsInitialized Then"; if (_flp.IsInitialized()) { //BA.debugLineNum = 235;BA.debugLine="Try"; try { //BA.debugLineNum = 236;BA.debugLine="If Not(FLP.IsConnected) Then"; if (anywheresoftware.b4a.keywords.Common.Not(_flp.IsConnected())) { //BA.debugLineNum = 237;BA.debugLine="Subs.log2DB(\"revisaFLP: No esta conectado ..."; mostCurrent._subs._log2db /*String*/ (processBA,"revisaFLP: No esta conectado ... 'Reconectando FLP'"); //BA.debugLineNum = 239;BA.debugLine="StartFLP"; _startflp(); //BA.debugLineNum = 240;BA.debugLine="todoBienFLP = False"; _todobienflp = anywheresoftware.b4a.keywords.Common.False; }; } catch (Exception e21) { processBA.setLastException(e21); //BA.debugLineNum = 243;BA.debugLine="LogColor(\"If Not(Tracker.FLP.IsConnected) -->"; anywheresoftware.b4a.keywords.Common.LogImpl("366387990","If Not(Tracker.FLP.IsConnected) --> "+BA.ObjectToString(anywheresoftware.b4a.keywords.Common.LastException(processBA)),anywheresoftware.b4a.keywords.Common.Colors.Red); }; //BA.debugLineNum = 245;BA.debugLine="Try"; try { //BA.debugLineNum = 246;BA.debugLine="If FLP.IsConnected And _ FLP.GetLastKnown"; if (_flp.IsConnected() && _flp.GetLastKnownLocation().IsInitialized() && _flp.GetLastKnownLocation().DistanceTo((android.location.Location)(_uugcoords.getObject()))>500) { //BA.debugLineNum = 249;BA.debugLine="Subs.log2DB(\"revisaFLP: 'No se esta actualiza"; mostCurrent._subs._log2db /*String*/ (processBA,"revisaFLP: 'No se esta actualizando, lo reiniciamos ...'"); //BA.debugLineNum = 250;BA.debugLine="StartService(Me)"; anywheresoftware.b4a.keywords.Common.StartService(processBA,tracker.getObject()); //BA.debugLineNum = 251;BA.debugLine="todoBienFLP = False"; _todobienflp = anywheresoftware.b4a.keywords.Common.False; }; } catch (Exception e30) { processBA.setLastException(e30); //BA.debugLineNum = 254;BA.debugLine="LogColor(\"If FLP.IsConnectctd and FLP.getLKL.I"; anywheresoftware.b4a.keywords.Common.LogImpl("366388001","If FLP.IsConnectctd and FLP.getLKL.IsInitialized --> "+BA.ObjectToString(anywheresoftware.b4a.keywords.Common.LastException(processBA)),anywheresoftware.b4a.keywords.Common.Colors.Red); }; }; //BA.debugLineNum = 257;BA.debugLine="If todoBienFLP Then LogColor(\" +++ +++ Sin error"; if (_todobienflp) { anywheresoftware.b4a.keywords.Common.LogImpl("366388004"," +++ +++ Sin errores en FLP",anywheresoftware.b4a.keywords.Common.Colors.Green);}; } catch (Exception e35) { processBA.setLastException(e35); //BA.debugLineNum = 259;BA.debugLine="LogColor(\"If Tracker.FLP.IsInitialized --> \"&Las"; anywheresoftware.b4a.keywords.Common.LogImpl("366388006","If Tracker.FLP.IsInitialized --> "+BA.ObjectToString(anywheresoftware.b4a.keywords.Common.LastException(processBA)),anywheresoftware.b4a.keywords.Common.Colors.Red); }; //BA.debugLineNum = 262;BA.debugLine="End Sub"; return ""; } public static String _revisauug() throws Exception{ int _daa = 0; //BA.debugLineNum = 266;BA.debugLine="Sub revisaUUG 'ignore"; //BA.debugLineNum = 267;BA.debugLine="Try"; try { //BA.debugLineNum = 269;BA.debugLine="If FLP.IsInitialized And FLP.IsConnected Then"; if (_flp.IsInitialized() && _flp.IsConnected()) { //BA.debugLineNum = 270;BA.debugLine="Try"; try { //BA.debugLineNum = 271;BA.debugLine="If FLP.GetLastKnownLocation.IsInitialized Then"; if (_flp.GetLastKnownLocation().IsInitialized()) { //BA.debugLineNum = 273;BA.debugLine="Dim daa As Int = UUGCoords.DistanceTo(FLP.Get"; _daa = (int) (_uugcoords.DistanceTo((android.location.Location)(_flp.GetLastKnownLocation().getObject()))); //BA.debugLineNum = 274;BA.debugLine="If Starter.Logger Then LogColor($\"**** UUC \"$"; if (mostCurrent._starter._logger /*boolean*/ ) { anywheresoftware.b4a.keywords.Common.LogImpl("366453512",("**** UUC \""+anywheresoftware.b4a.keywords.Common.SmartStringFormatter("",(Object)(mostCurrent._subs._fechakmt /*String*/ (processBA,BA.NumberToString(_flp.GetLastKnownLocation().getTime()))))+"|"+anywheresoftware.b4a.keywords.Common.SmartStringFormatter("0.2",(Object)(_flp.GetLastKnownLocation().getAccuracy()))+"|"+anywheresoftware.b4a.keywords.Common.SmartStringFormatter("0.8",(Object)(_flp.GetLastKnownLocation().getLatitude()))+"|"+anywheresoftware.b4a.keywords.Common.SmartStringFormatter("0.8",(Object)(_flp.GetLastKnownLocation().getLongitude()))+"|"+anywheresoftware.b4a.keywords.Common.SmartStringFormatter("0.2",(Object)(_flp.GetLastKnownLocation().getSpeed()))+"|"),anywheresoftware.b4a.keywords.Common.Colors.RGB((int) (255),(int) (112),(int) (35)));}; //BA.debugLineNum = 275;BA.debugLine="If daa > 40 And FLP.GetLastKnownLocation.Accu"; if (_daa>40 && _flp.GetLastKnownLocation().getAccuracy()<35) { //BA.debugLineNum = 276;BA.debugLine="B4XPages.MainPage.skmt.ExecNonQuery2(\"INSERT"; mostCurrent._b4xpages._mainpage /*keymon.lat.medicomed.b4xmainpage*/ (processBA)._skmt /*anywheresoftware.b4a.sql.SQL*/ .ExecNonQuery2("INSERT INTO RUTA_GPS(fecha, lat, lon) VALUES (?,?,?)",anywheresoftware.b4a.keywords.Common.ArrayToList(new Object[]{(Object)(mostCurrent._subs._fechakmt /*String*/ (processBA,BA.NumberToString(_flp.GetLastKnownLocation().getTime()))),(Object)(_flp.GetLastKnownLocation().getLatitude()),(Object)(_flp.GetLastKnownLocation().getLongitude())})); //BA.debugLineNum = 277;BA.debugLine="If Starter.Logger Then Log(\"++++ Distancia a"; if (mostCurrent._starter._logger /*boolean*/ ) { anywheresoftware.b4a.keywords.Common.LogImpl("366453515","++++ Distancia a anterior="+BA.NumberToString(_daa)+"|"+"Precision="+BA.NumberToString(_flp.GetLastKnownLocation().getAccuracy()),0);}; }; //BA.debugLineNum = 279;BA.debugLine="UUGCoords = FLP.GetLastKnownLocation"; _uugcoords = _flp.GetLastKnownLocation(); }; } catch (Exception e14) { processBA.setLastException(e14); //BA.debugLineNum = 282;BA.debugLine="LogColor(\"FLP.GetLastKnownLocation.IsInitializ"; anywheresoftware.b4a.keywords.Common.LogImpl("366453520","FLP.GetLastKnownLocation.IsInitialized --> "+BA.ObjectToString(anywheresoftware.b4a.keywords.Common.LastException(processBA)),anywheresoftware.b4a.keywords.Common.Colors.Red); }; }else { //BA.debugLineNum = 285;BA.debugLine="Log(\"StartFLP\")"; anywheresoftware.b4a.keywords.Common.LogImpl("366453523","StartFLP",0); //BA.debugLineNum = 286;BA.debugLine="StartFLP"; _startflp(); }; } catch (Exception e21) { processBA.setLastException(e21); //BA.debugLineNum = 289;BA.debugLine="LogColor(\"If FLP.IsInitialized --> \"&LastExcepti"; anywheresoftware.b4a.keywords.Common.LogImpl("366453527","If FLP.IsInitialized --> "+BA.ObjectToString(anywheresoftware.b4a.keywords.Common.LastException(processBA)),anywheresoftware.b4a.keywords.Common.Colors.Red); }; //BA.debugLineNum = 291;BA.debugLine="End Sub"; return ""; } public static String _service_create() throws Exception{ //BA.debugLineNum = 41;BA.debugLine="Sub Service_Create"; //BA.debugLineNum = 42;BA.debugLine="Service.AutomaticForegroundMode = Service.AUTOMAT"; mostCurrent._service.AutomaticForegroundMode = mostCurrent._service.AUTOMATIC_FOREGROUND_NEVER; //BA.debugLineNum = 44;BA.debugLine="FLP.Initialize(\"flp\")"; _flp.Initialize(processBA,"flp"); //BA.debugLineNum = 45;BA.debugLine="FLP.Connect"; _flp.Connect(); //BA.debugLineNum = 46;BA.debugLine="lock.PartialLock"; _lock.PartialLock(processBA); //BA.debugLineNum = 47;BA.debugLine="StartFLP"; _startflp(); //BA.debugLineNum = 48;BA.debugLine="End Sub"; return ""; } public static String _service_destroy() throws Exception{ //BA.debugLineNum = 202;BA.debugLine="Sub Service_Destroy"; //BA.debugLineNum = 203;BA.debugLine="If Tracking Then"; if (_tracking) { //BA.debugLineNum = 204;BA.debugLine="StopFLP"; _stopflp(); }; //BA.debugLineNum = 206;BA.debugLine="Tracking = False"; _tracking = anywheresoftware.b4a.keywords.Common.False; //BA.debugLineNum = 207;BA.debugLine="lock.ReleasePartialLock"; _lock.ReleasePartialLock(); //BA.debugLineNum = 208;BA.debugLine="End Sub"; return ""; } public static String _service_start(anywheresoftware.b4a.objects.IntentWrapper _startingintent) throws Exception{ //BA.debugLineNum = 59;BA.debugLine="Sub Service_Start (StartingIntent As Intent)"; //BA.debugLineNum = 61;BA.debugLine="Service.StopAutomaticForeground"; mostCurrent._service.StopAutomaticForeground(); //BA.debugLineNum = 62;BA.debugLine="Service.StartForeground(nid, CreateNotification(\""; mostCurrent._service.StartForeground(_nid,(android.app.Notification)(_createnotification("...").getObject())); //BA.debugLineNum = 63;BA.debugLine="Track"; _track(); //BA.debugLineNum = 64;BA.debugLine="StartServiceAt(Me, DateTime.Now + 5 * DateTime.Ti"; anywheresoftware.b4a.keywords.Common.StartServiceAt(processBA,tracker.getObject(),(long) (anywheresoftware.b4a.keywords.Common.DateTime.getNow()+5*anywheresoftware.b4a.keywords.Common.DateTime.TicksPerMinute),anywheresoftware.b4a.keywords.Common.True); //BA.debugLineNum = 65;BA.debugLine="FLP.GetLastKnownLocation.Initialize"; _flp.GetLastKnownLocation().Initialize(); //BA.debugLineNum = 66;BA.debugLine="End Sub"; return ""; } public static void _startflp() throws Exception{ ResumableSub_StartFLP rsub = new ResumableSub_StartFLP(null); rsub.resume(processBA, null); } public static class ResumableSub_StartFLP extends BA.ResumableSub { public ResumableSub_StartFLP(keymon.lat.medicomed.tracker parent) { this.parent = parent; } keymon.lat.medicomed.tracker parent; @Override public void resume(BA ba, Object[] result) throws Exception{ while (true) { switch (state) { case -1: return; case 0: //C this.state = 1; //BA.debugLineNum = 86;BA.debugLine="Do While FLP.IsConnected = False"; if (true) break; case 1: //do while this.state = 4; while (parent._flp.IsConnected()==anywheresoftware.b4a.keywords.Common.False) { this.state = 3; if (true) break; } if (true) break; case 3: //C this.state = 1; //BA.debugLineNum = 87;BA.debugLine="Sleep(500)"; anywheresoftware.b4a.keywords.Common.Sleep(processBA,this,(int) (500)); this.state = 5; return; case 5: //C this.state = 1; ; if (true) break; case 4: //C this.state = -1; ; //BA.debugLineNum = 92;BA.debugLine="FLP.RequestLocationUpdates(CreateLocationRequest)"; parent._flp.RequestLocationUpdates((com.google.android.gms.location.LocationRequest)(_createlocationrequest().getObject())); //BA.debugLineNum = 95;BA.debugLine="flpStarted = True"; parent._flpstarted = anywheresoftware.b4a.keywords.Common.True; //BA.debugLineNum = 97;BA.debugLine="End Sub"; if (true) break; } } } } public static void _startflpsmall() throws Exception{ ResumableSub_StartFLPSmall rsub = new ResumableSub_StartFLPSmall(null); rsub.resume(processBA, null); } public static class ResumableSub_StartFLPSmall extends BA.ResumableSub { public ResumableSub_StartFLPSmall(keymon.lat.medicomed.tracker parent) { this.parent = parent; } keymon.lat.medicomed.tracker parent; @Override public void resume(BA ba, Object[] result) throws Exception{ while (true) { switch (state) { case -1: return; case 0: //C this.state = 1; //BA.debugLineNum = 101;BA.debugLine="Do While FLP.IsConnected = False"; if (true) break; case 1: //do while this.state = 4; while (parent._flp.IsConnected()==anywheresoftware.b4a.keywords.Common.False) { this.state = 3; if (true) break; } if (true) break; case 3: //C this.state = 1; //BA.debugLineNum = 102;BA.debugLine="Sleep(500)"; anywheresoftware.b4a.keywords.Common.Sleep(processBA,this,(int) (500)); this.state = 5; return; case 5: //C this.state = 1; ; //BA.debugLineNum = 103;BA.debugLine="Log(\"sleeping\")"; anywheresoftware.b4a.keywords.Common.LogImpl("365798148","sleeping",0); if (true) break; case 4: //C this.state = -1; ; //BA.debugLineNum = 105;BA.debugLine="dameUltimaUbicacionConocida 'Regresamos ultima ub"; _dameultimaubicacionconocida(); //BA.debugLineNum = 106;BA.debugLine="FLP.RequestLocationUpdates(CreateLocationRequestS"; parent._flp.RequestLocationUpdates((com.google.android.gms.location.LocationRequest)(_createlocationrequestsmalld().getObject())); //BA.debugLineNum = 109;BA.debugLine="End Sub"; if (true) break; } } } } public static String _stopflp() throws Exception{ //BA.debugLineNum = 146;BA.debugLine="Public Sub StopFLP"; //BA.debugLineNum = 148;BA.debugLine="If flpStarted Then"; if (_flpstarted) { //BA.debugLineNum = 149;BA.debugLine="FLP.RemoveLocationUpdates 'Eliminamos todas las"; _flp.RemoveLocationUpdates(); //BA.debugLineNum = 150;BA.debugLine="flpStarted = False"; _flpstarted = anywheresoftware.b4a.keywords.Common.False; }; //BA.debugLineNum = 152;BA.debugLine="End Sub"; return ""; } public static String _track() throws Exception{ //BA.debugLineNum = 68;BA.debugLine="Public Sub Track"; //BA.debugLineNum = 70;BA.debugLine="If Not(FLP.IsInitialized) Then FLP.Initialize(\"fl"; if (anywheresoftware.b4a.keywords.Common.Not(_flp.IsInitialized())) { _flp.Initialize(processBA,"flp");}; //BA.debugLineNum = 71;BA.debugLine="If Not(FLP.IsConnected) Then FLP.Connect"; if (anywheresoftware.b4a.keywords.Common.Not(_flp.IsConnected())) { _flp.Connect();}; //BA.debugLineNum = 72;BA.debugLine="If Tracking And actualLR.IsInitialized Then"; if (_tracking && _actuallr.IsInitialized()) { //BA.debugLineNum = 74;BA.debugLine="Return 'Si ya estamos \"rastreando\" no hacemos na"; if (true) return ""; }; //BA.debugLineNum = 76;BA.debugLine="If Starter.rp.Check(Starter.rp.PERMISSION_ACCESS_"; if (mostCurrent._starter._rp /*anywheresoftware.b4a.objects.RuntimePermissions*/ .Check(mostCurrent._starter._rp /*anywheresoftware.b4a.objects.RuntimePermissions*/ .PERMISSION_ACCESS_FINE_LOCATION)==anywheresoftware.b4a.keywords.Common.False) { //BA.debugLineNum = 77;BA.debugLine="Log(\"No permission\")"; anywheresoftware.b4a.keywords.Common.LogImpl("365667081","No permission",0); //BA.debugLineNum = 78;BA.debugLine="Return"; if (true) return ""; }; //BA.debugLineNum = 80;BA.debugLine="StartFLP 'Iniciamos FusedLocationProvider"; _startflp(); //BA.debugLineNum = 81;BA.debugLine="Tracking = True"; _tracking = anywheresoftware.b4a.keywords.Common.True; //BA.debugLineNum = 82;BA.debugLine="End Sub"; return ""; } }