package reparto_intmex.keymon.lat;


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, anywheresoftware.b4a.ShellBA.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 anywheresoftware.b4a.ShellBA(this, null, null, "reparto_intmex.keymon.lat", "reparto_intmex.keymon.lat.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, "reparto_intmex.keymon.lat.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 String _locrequest = "";
public static anywheresoftware.b4a.gps.LocationWrapper _uugcoords = null;
public static String _trackeractividad = "";
public static String _pushserviceactividad = "";
public b4a.example.dateutils _dateutils = null;
public reparto_intmex.keymon.lat.main _main = null;
public reparto_intmex.keymon.lat.appupdater _appupdater = null;
public reparto_intmex.keymon.lat.foto _foto = null;
public reparto_intmex.keymon.lat.mapa_cliente _mapa_cliente = null;
public reparto_intmex.keymon.lat.mapa_rutas _mapa_rutas = null;
public reparto_intmex.keymon.lat.starter _starter = null;
public reparto_intmex.keymon.lat.subs _subs = null;
public reparto_intmex.keymon.lat.newinst2 _newinst2 = null;
public reparto_intmex.keymon.lat.b4xpages _b4xpages = null;
public reparto_intmex.keymon.lat.b4xcollections _b4xcollections = null;
public reparto_intmex.keymon.lat.httputils2service _httputils2service = null;
public reparto_intmex.keymon.lat.xuiviewsutils _xuiviewsutils = null;
public static uk.co.martinpearman.b4a.fusedlocationprovider.LocationRequest  _createlocationrequest() throws Exception{
RDebugUtils.currentModule="tracker";
if (Debug.shouldDelegate(processBA, "createlocationrequest", false))
	 {return ((uk.co.martinpearman.b4a.fusedlocationprovider.LocationRequest) Debug.delegate(processBA, "createlocationrequest", null));}
uk.co.martinpearman.b4a.fusedlocationprovider.LocationRequest _lr = null;
RDebugUtils.currentLine=71958528;
 //BA.debugLineNum = 71958528;BA.debugLine="Private Sub CreateLocationRequest As LocationReque";
RDebugUtils.currentLine=71958529;
 //BA.debugLineNum = 71958529;BA.debugLine="If B4XPages.MainPage.logger Then Log(\"CreateLocat";
if (mostCurrent._b4xpages._mainpage /*reparto_intmex.keymon.lat.b4xmainpage*/ (processBA)._logger /*boolean*/ ) { 
anywheresoftware.b4a.keywords.Common.LogImpl("271958529","CreateLocationRequest",0);};
RDebugUtils.currentLine=71958530;
 //BA.debugLineNum = 71958530;BA.debugLine="Dim lr As LocationRequest";
_lr = new uk.co.martinpearman.b4a.fusedlocationprovider.LocationRequest();
RDebugUtils.currentLine=71958531;
 //BA.debugLineNum = 71958531;BA.debugLine="lr.Initialize";
_lr.Initialize();
RDebugUtils.currentLine=71958532;
 //BA.debugLineNum = 71958532;BA.debugLine="lr.SetInterval(10000) 'Intervalo deseado para act";
_lr.SetInterval((long) (10000));
RDebugUtils.currentLine=71958533;
 //BA.debugLineNum = 71958533;BA.debugLine="lr.SetFastestInterval(lr.GetInterval / 2) 'Interv";
_lr.SetFastestInterval((long) (_lr.GetInterval()/(double)2));
RDebugUtils.currentLine=71958534;
 //BA.debugLineNum = 71958534;BA.debugLine="lr.SetSmallestDisplacement(75) 'Solo registra cam";
_lr.SetSmallestDisplacement((float) (75));
RDebugUtils.currentLine=71958535;
 //BA.debugLineNum = 71958535;BA.debugLine="lr.SetPriority(lr.Priority.PRIORITY_HIGH_ACCURACY";
_lr.SetPriority(_lr.Priority.PRIORITY_HIGH_ACCURACY);
RDebugUtils.currentLine=71958536;
 //BA.debugLineNum = 71958536;BA.debugLine="actualLR=lr";
_actuallr = _lr;
RDebugUtils.currentLine=71958537;
 //BA.debugLineNum = 71958537;BA.debugLine="Return lr";
if (true) return _lr;
RDebugUtils.currentLine=71958538;
 //BA.debugLineNum = 71958538;BA.debugLine="End Sub";
return null;
}
public static uk.co.martinpearman.b4a.fusedlocationprovider.LocationRequest  _createlocationrequest2times() throws Exception{
RDebugUtils.currentModule="tracker";
if (Debug.shouldDelegate(processBA, "createlocationrequest2times", false))
	 {return ((uk.co.martinpearman.b4a.fusedlocationprovider.LocationRequest) Debug.delegate(processBA, "createlocationrequest2times", null));}
uk.co.martinpearman.b4a.fusedlocationprovider.LocationRequest _lr = null;
RDebugUtils.currentLine=72024064;
 //BA.debugLineNum = 72024064;BA.debugLine="Private Sub CreateLocationRequest2times As Locatio";
RDebugUtils.currentLine=72024065;
 //BA.debugLineNum = 72024065;BA.debugLine="If B4XPages.MainPage.logger Then Log(\"Iniciamos C";
if (mostCurrent._b4xpages._mainpage /*reparto_intmex.keymon.lat.b4xmainpage*/ (processBA)._logger /*boolean*/ ) { 
anywheresoftware.b4a.keywords.Common.LogImpl("272024065","Iniciamos CreateLocationRequest2times",0);};
RDebugUtils.currentLine=72024066;
 //BA.debugLineNum = 72024066;BA.debugLine="Dim lr As LocationRequest";
_lr = new uk.co.martinpearman.b4a.fusedlocationprovider.LocationRequest();
RDebugUtils.currentLine=72024067;
 //BA.debugLineNum = 72024067;BA.debugLine="lr.Initialize";
_lr.Initialize();
RDebugUtils.currentLine=72024068;
 //BA.debugLineNum = 72024068;BA.debugLine="lr.SetInterval(2000) 'Intervalo deseado para actu";
_lr.SetInterval((long) (2000));
RDebugUtils.currentLine=72024069;
 //BA.debugLineNum = 72024069;BA.debugLine="lr.SetFastestInterval(lr.GetInterval / 2) 'Interv";
_lr.SetFastestInterval((long) (_lr.GetInterval()/(double)2));
RDebugUtils.currentLine=72024070;
 //BA.debugLineNum = 72024070;BA.debugLine="lr.setNumUpdates(2) 'Solicitamos solo 2 actualiza";
_lr.SetNumUpdates((int) (2));
RDebugUtils.currentLine=72024071;
 //BA.debugLineNum = 72024071;BA.debugLine="lr.SetSmallestDisplacement(10) 'Solo registra cam";
_lr.SetSmallestDisplacement((float) (10));
RDebugUtils.currentLine=72024072;
 //BA.debugLineNum = 72024072;BA.debugLine="lr.SetPriority(lr.Priority.PRIORITY_HIGH_ACCURACY";
_lr.SetPriority(_lr.Priority.PRIORITY_HIGH_ACCURACY);
RDebugUtils.currentLine=72024073;
 //BA.debugLineNum = 72024073;BA.debugLine="actualLR=lr";
_actuallr = _lr;
RDebugUtils.currentLine=72024074;
 //BA.debugLineNum = 72024074;BA.debugLine="Return lr";
if (true) return _lr;
RDebugUtils.currentLine=72024075;
 //BA.debugLineNum = 72024075;BA.debugLine="End Sub";
return null;
}
public static anywheresoftware.b4a.objects.NotificationWrapper  _createnotification(String _body) throws Exception{
RDebugUtils.currentModule="tracker";
if (Debug.shouldDelegate(processBA, "createnotification", false))
	 {return ((anywheresoftware.b4a.objects.NotificationWrapper) Debug.delegate(processBA, "createnotification", new Object[] {_body}));}
anywheresoftware.b4a.objects.NotificationWrapper _notification = null;
RDebugUtils.currentLine=72286208;
 //BA.debugLineNum = 72286208;BA.debugLine="Sub CreateNotification (Body As String) As Notific";
RDebugUtils.currentLine=72286209;
 //BA.debugLineNum = 72286209;BA.debugLine="Dim notification As Notification";
_notification = new anywheresoftware.b4a.objects.NotificationWrapper();
RDebugUtils.currentLine=72286210;
 //BA.debugLineNum = 72286210;BA.debugLine="notification.Initialize2(notification.IMPORTANCE_";
_notification.Initialize2(_notification.IMPORTANCE_LOW);
RDebugUtils.currentLine=72286211;
 //BA.debugLineNum = 72286211;BA.debugLine="notification.Icon = \"icon\"";
_notification.setIcon("icon");
RDebugUtils.currentLine=72286212;
 //BA.debugLineNum = 72286212;BA.debugLine="notification.SetInfo(\"INTMEX REPARTO\", Body, Main";
_notification.SetInfoNew(processBA,BA.ObjectToCharSequence("INTMEX REPARTO"),BA.ObjectToCharSequence(_body),(Object)(mostCurrent._main.getObject()));
RDebugUtils.currentLine=72286213;
 //BA.debugLineNum = 72286213;BA.debugLine="Return notification";
if (true) return _notification;
RDebugUtils.currentLine=72286214;
 //BA.debugLineNum = 72286214;BA.debugLine="End Sub";
return null;
}
public static String  _dameultimaubicacionconocida() throws Exception{
RDebugUtils.currentModule="tracker";
if (Debug.shouldDelegate(processBA, "dameultimaubicacionconocida", false))
	 {return ((String) Debug.delegate(processBA, "dameultimaubicacionconocida", null));}
String _coords = "";
RDebugUtils.currentLine=72089600;
 //BA.debugLineNum = 72089600;BA.debugLine="Sub dameUltimaUbicacionConocida";
RDebugUtils.currentLine=72089601;
 //BA.debugLineNum = 72089601;BA.debugLine="If FLP.GetLastKnownLocation.IsInitialized Then 'M";
if (_flp.GetLastKnownLocation().IsInitialized()) { 
RDebugUtils.currentLine=72089603;
 //BA.debugLineNum = 72089603;BA.debugLine="If B4XPages.MainPage.Logger Then LogColor($\"Mand";
if (mostCurrent._b4xpages._mainpage /*reparto_intmex.keymon.lat.b4xmainpage*/ (processBA)._logger /*boolean*/ ) { 
anywheresoftware.b4a.keywords.Common.LogImpl("272089603",("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)));};
RDebugUtils.currentLine=72089604;
 //BA.debugLineNum = 72089604;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()));
RDebugUtils.currentLine=72089606;
 //BA.debugLineNum = 72089606;BA.debugLine="Subs.mandamosLoc(coords)";
mostCurrent._subs._mandamosloc /*String*/ (processBA,_coords);
 };
RDebugUtils.currentLine=72089608;
 //BA.debugLineNum = 72089608;BA.debugLine="End Sub";
return "";
}
public static String  _formatofecha(String _fecha) throws Exception{
RDebugUtils.currentModule="tracker";
if (Debug.shouldDelegate(processBA, "formatofecha", false))
	 {return ((String) Debug.delegate(processBA, "formatofecha", new Object[] {_fecha}));}
String _origformat = "";
String _lastupdate = "";
RDebugUtils.currentLine=72417280;
 //BA.debugLineNum = 72417280;BA.debugLine="Sub formatoFecha(fecha As String) As String 'Convi";
RDebugUtils.currentLine=72417282;
 //BA.debugLineNum = 72417282;BA.debugLine="Dim OrigFormat As String = DateTime.DateFormat  '";
_origformat = anywheresoftware.b4a.keywords.Common.DateTime.getDateFormat();
RDebugUtils.currentLine=72417283;
 //BA.debugLineNum = 72417283;BA.debugLine="DateTime.DateFormat=\"yyMMddHHmmss\"";
anywheresoftware.b4a.keywords.Common.DateTime.setDateFormat("yyMMddHHmmss");
RDebugUtils.currentLine=72417284;
 //BA.debugLineNum = 72417284;BA.debugLine="Dim lastUpdate As String=DateTime.Date(fecha)";
_lastupdate = anywheresoftware.b4a.keywords.Common.DateTime.Date((long)(Double.parseDouble(_fecha)));
RDebugUtils.currentLine=72417285;
 //BA.debugLineNum = 72417285;BA.debugLine="DateTime.DateFormat=OrigFormat  'return to orig d";
anywheresoftware.b4a.keywords.Common.DateTime.setDateFormat(_origformat);
RDebugUtils.currentLine=72417287;
 //BA.debugLineNum = 72417287;BA.debugLine="Return lastUpdate";
if (true) return _lastupdate;
RDebugUtils.currentLine=72417288;
 //BA.debugLineNum = 72417288;BA.debugLine="End Sub";
return "";
}
public static String  _flp_connectionfailed(int _connectionresult1) throws Exception{
RDebugUtils.currentModule="tracker";
if (Debug.shouldDelegate(processBA, "flp_connectionfailed", false))
	 {return ((String) Debug.delegate(processBA, "flp_connectionfailed", new Object[] {_connectionresult1}));}
RDebugUtils.currentLine=71565312;
 //BA.debugLineNum = 71565312;BA.debugLine="Sub flp_ConnectionFailed(ConnectionResult1 As Int)";
RDebugUtils.currentLine=71565313;
 //BA.debugLineNum = 71565313;BA.debugLine="If B4XPages.MainPage.logger Then Log(\"Failed to c";
if (mostCurrent._b4xpages._mainpage /*reparto_intmex.keymon.lat.b4xmainpage*/ (processBA)._logger /*boolean*/ ) { 
anywheresoftware.b4a.keywords.Common.LogImpl("271565313","Failed to connect to location provider",0);};
RDebugUtils.currentLine=71565314;
 //BA.debugLineNum = 71565314;BA.debugLine="End Sub";
return "";
}
public static String  _flp_connectionsuccess() throws Exception{
RDebugUtils.currentModule="tracker";
if (Debug.shouldDelegate(processBA, "flp_connectionsuccess", false))
	 {return ((String) Debug.delegate(processBA, "flp_connectionsuccess", null));}
RDebugUtils.currentLine=71499776;
 //BA.debugLineNum = 71499776;BA.debugLine="Sub flp_ConnectionSuccess";
RDebugUtils.currentLine=71499779;
 //BA.debugLineNum = 71499779;BA.debugLine="End Sub";
return "";
}
public static String  _flp_connectionsuspended(int _connectionresult1) throws Exception{
RDebugUtils.currentModule="tracker";
if (Debug.shouldDelegate(processBA, "flp_connectionsuspended", false))
	 {return ((String) Debug.delegate(processBA, "flp_connectionsuspended", new Object[] {_connectionresult1}));}
RDebugUtils.currentLine=71630848;
 //BA.debugLineNum = 71630848;BA.debugLine="Sub flp_ConnectionSuspended(ConnectionResult1 As I";
RDebugUtils.currentLine=71630849;
 //BA.debugLineNum = 71630849;BA.debugLine="If B4XPages.MainPage.logger Then Log(\"FLP conecti";
if (mostCurrent._b4xpages._mainpage /*reparto_intmex.keymon.lat.b4xmainpage*/ (processBA)._logger /*boolean*/ ) { 
anywheresoftware.b4a.keywords.Common.LogImpl("271630849","FLP conection suspended",0);};
RDebugUtils.currentLine=71630850;
 //BA.debugLineNum = 71630850;BA.debugLine="StartFLP";
_startflp();
RDebugUtils.currentLine=71630851;
 //BA.debugLineNum = 71630851;BA.debugLine="End Sub";
return "";
}
public static void  _startflp() throws Exception{
RDebugUtils.currentModule="tracker";
if (Debug.shouldDelegate(processBA, "startflp", false))
	 {Debug.delegate(processBA, "startflp", null); return;}
ResumableSub_StartFLP rsub = new ResumableSub_StartFLP(null);
rsub.resume(processBA, null);
}
public static class ResumableSub_StartFLP extends BA.ResumableSub {
public ResumableSub_StartFLP(reparto_intmex.keymon.lat.tracker parent) {
this.parent = parent;
}
reparto_intmex.keymon.lat.tracker parent;

@Override
public void resume(BA ba, Object[] result) throws Exception{
RDebugUtils.currentModule="tracker";

    while (true) {
        switch (state) {
            case -1:
return;

case 0:
//C
this.state = 1;
RDebugUtils.currentLine=71827458;
 //BA.debugLineNum = 71827458;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;
RDebugUtils.currentLine=71827459;
 //BA.debugLineNum = 71827459;BA.debugLine="Sleep(500)";
anywheresoftware.b4a.keywords.Common.Sleep(processBA,new anywheresoftware.b4a.shell.DebugResumableSub.DelegatableResumableSub(this, "tracker", "startflp"),(int) (500));
this.state = 5;
return;
case 5:
//C
this.state = 1;
;
 if (true) break;

case 4:
//C
this.state = -1;
;
RDebugUtils.currentLine=71827464;
 //BA.debugLineNum = 71827464;BA.debugLine="FLP.RequestLocationUpdates(CreateLocationRequest";
parent._flp.RequestLocationUpdates((com.google.android.gms.location.LocationRequest)(_createlocationrequest().getObject()));
RDebugUtils.currentLine=71827467;
 //BA.debugLineNum = 71827467;BA.debugLine="flpStarted = True";
parent._flpstarted = anywheresoftware.b4a.keywords.Common.True;
RDebugUtils.currentLine=71827469;
 //BA.debugLineNum = 71827469;BA.debugLine="End Sub";
if (true) break;

            }
        }
    }
}
public static String  _flp_locationchanged(anywheresoftware.b4a.gps.LocationWrapper _location1) throws Exception{
RDebugUtils.currentModule="tracker";
if (Debug.shouldDelegate(processBA, "flp_locationchanged", false))
	 {return ((String) Debug.delegate(processBA, "flp_locationchanged", new Object[] {_location1}));}
String _sdate = "";
String _stime = "";
String _coords = "";
String _origformat = "";
int _minsdif = 0;
RDebugUtils.currentLine=72220672;
 //BA.debugLineNum = 72220672;BA.debugLine="Sub flp_LocationChanged (Location1 As Location)";
RDebugUtils.currentLine=72220673;
 //BA.debugLineNum = 72220673;BA.debugLine="Starter.trackerActividad = Subs.fechaKMT(DateTime";
mostCurrent._starter._trackeractividad /*String*/  = mostCurrent._subs._fechakmt /*String*/ (processBA,BA.NumberToString(anywheresoftware.b4a.keywords.Common.DateTime.getNow()));
RDebugUtils.currentLine=72220674;
 //BA.debugLineNum = 72220674;BA.debugLine="UUGCoords = Location1";
_uugcoords = _location1;
RDebugUtils.currentLine=72220676;
 //BA.debugLineNum = 72220676;BA.debugLine="CallSub2(Starter, \"GPS_LocationChanged\", Location";
anywheresoftware.b4a.keywords.Common.CallSubDebug2(processBA,(Object)(mostCurrent._starter.getObject()),"GPS_LocationChanged",(Object)(_location1));
RDebugUtils.currentLine=72220679;
 //BA.debugLineNum = 72220679;BA.debugLine="B4XPages.MainPage.lat_gps = Location1.Latitude";
mostCurrent._b4xpages._mainpage /*reparto_intmex.keymon.lat.b4xmainpage*/ (processBA)._lat_gps /*String*/  = BA.NumberToString(_location1.getLatitude());
RDebugUtils.currentLine=72220680;
 //BA.debugLineNum = 72220680;BA.debugLine="B4XPages.MainPage.lon_gps = Location1.Longitude";
mostCurrent._b4xpages._mainpage /*reparto_intmex.keymon.lat.b4xmainpage*/ (processBA)._lon_gps /*String*/  = BA.NumberToString(_location1.getLongitude());
RDebugUtils.currentLine=72220682;
 //BA.debugLineNum = 72220682;BA.debugLine="Dim sDate,sTime As String";
_sdate = "";
_stime = "";
RDebugUtils.currentLine=72220683;
 //BA.debugLineNum = 72220683;BA.debugLine="DateTime.DateFormat = \"MM/dd/yyyy\"";
anywheresoftware.b4a.keywords.Common.DateTime.setDateFormat("MM/dd/yyyy");
RDebugUtils.currentLine=72220684;
 //BA.debugLineNum = 72220684;BA.debugLine="sDate=DateTime.Date(DateTime.Now)";
_sdate = anywheresoftware.b4a.keywords.Common.DateTime.Date(anywheresoftware.b4a.keywords.Common.DateTime.getNow());
RDebugUtils.currentLine=72220685;
 //BA.debugLineNum = 72220685;BA.debugLine="sTime=DateTime.Time(DateTime.Now)";
_stime = anywheresoftware.b4a.keywords.Common.DateTime.Time(anywheresoftware.b4a.keywords.Common.DateTime.getNow());
RDebugUtils.currentLine=72220686;
 //BA.debugLineNum = 72220686;BA.debugLine="Try";
try {RDebugUtils.currentLine=72220687;
 //BA.debugLineNum = 72220687;BA.debugLine="Starter.skmt.ExecNonQuery(\"DELETE FROM HIST_GPS\"";
mostCurrent._starter._skmt /*anywheresoftware.b4a.sql.SQL*/ .ExecNonQuery("DELETE FROM HIST_GPS");
RDebugUtils.currentLine=72220688;
 //BA.debugLineNum = 72220688;BA.debugLine="Starter.skmt.ExecNonQuery2(\"INSERT INTO HIST_GPS";
mostCurrent._starter._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 /*reparto_intmex.keymon.lat.b4xmainpage*/ (processBA)._lat_gps /*String*/ ),(Object)(mostCurrent._b4xpages._mainpage /*reparto_intmex.keymon.lat.b4xmainpage*/ (processBA)._lon_gps /*String*/ )}));
 } 
       catch (Exception e14) {
			processBA.setLastException(e14);RDebugUtils.currentLine=72220690;
 //BA.debugLineNum = 72220690;BA.debugLine="If B4XPages.MainPage.logger Then Log(\"Error al b";
if (mostCurrent._b4xpages._mainpage /*reparto_intmex.keymon.lat.b4xmainpage*/ (processBA)._logger /*boolean*/ ) { 
anywheresoftware.b4a.keywords.Common.LogImpl("272220690","Error al borrar o insertar nuevas coordendas en HIST_GPS",0);};
 };
RDebugUtils.currentLine=72220693;
 //BA.debugLineNum = 72220693;BA.debugLine="Dim coords As String = Location1.Latitude&\",\"&Loc";
_coords = BA.NumberToString(_location1.getLatitude())+","+BA.NumberToString(_location1.getLongitude())+","+_formatofecha(BA.NumberToString(_location1.getTime()));
RDebugUtils.currentLine=72220694;
 //BA.debugLineNum = 72220694;BA.debugLine="Log(\"Loc changed : \"&Location1.Latitude&\",\"&Locat";
anywheresoftware.b4a.keywords.Common.LogImpl("272220694","Loc changed : "+BA.NumberToString(_location1.getLatitude())+","+BA.NumberToString(_location1.getLongitude()),0);
RDebugUtils.currentLine=72220695;
 //BA.debugLineNum = 72220695;BA.debugLine="If B4XPages.MainPage.logger Then Log(\"Mandamos Ub";
if (mostCurrent._b4xpages._mainpage /*reparto_intmex.keymon.lat.b4xmainpage*/ (processBA)._logger /*boolean*/ ) { 
anywheresoftware.b4a.keywords.Common.LogImpl("272220695","Mandamos Ubicacion",0);};
RDebugUtils.currentLine=72220696;
 //BA.debugLineNum = 72220696;BA.debugLine="If B4XPages.MainPage.logger Then Log(locRequest)";
if (mostCurrent._b4xpages._mainpage /*reparto_intmex.keymon.lat.b4xmainpage*/ (processBA)._logger /*boolean*/ ) { 
anywheresoftware.b4a.keywords.Common.LogImpl("272220696",_locrequest,0);};
RDebugUtils.currentLine=72220698;
 //BA.debugLineNum = 72220698;BA.debugLine="If Location1.Accuracy < 100 Then";
if (_location1.getAccuracy()<100) { 
RDebugUtils.currentLine=72220699;
 //BA.debugLineNum = 72220699;BA.debugLine="Subs.guardaInfoEnBD(coords)'Escribimos coordenad";
mostCurrent._subs._guardainfoenbd /*String*/ (processBA,_coords);
RDebugUtils.currentLine=72220701;
 //BA.debugLineNum = 72220701;BA.debugLine="Subs.mandamosLoc(coords)";
mostCurrent._subs._mandamosloc /*String*/ (processBA,_coords);
 };
RDebugUtils.currentLine=72220703;
 //BA.debugLineNum = 72220703;BA.debugLine="Dim origFormat As String = DateTime.TimeFormat 'G";
_origformat = anywheresoftware.b4a.keywords.Common.DateTime.getTimeFormat();
RDebugUtils.currentLine=72220704;
 //BA.debugLineNum = 72220704;BA.debugLine="DateTime.TimeFormat = \"HHmmss\" ' Modificamos form";
anywheresoftware.b4a.keywords.Common.DateTime.setTimeFormat("HHmmss");
RDebugUtils.currentLine=72220705;
 //BA.debugLineNum = 72220705;BA.debugLine="Dim minsDif As Int = DateTime.Time(DateTime.Now)";
_minsdif = (int) ((double)(Double.parseDouble(anywheresoftware.b4a.keywords.Common.DateTime.Time(anywheresoftware.b4a.keywords.Common.DateTime.getNow())))-(double)(Double.parseDouble(mostCurrent._b4xpages._mainpage /*reparto_intmex.keymon.lat.b4xmainpage*/ (processBA)._ultimaactualizaciongps /*String*/ )));
RDebugUtils.currentLine=72220707;
 //BA.debugLineNum = 72220707;BA.debugLine="If Location1.Accuracy < 100 And minsDif > 240 The";
if (_location1.getAccuracy()<100 && _minsdif>240) { 
RDebugUtils.currentLine=72220708;
 //BA.debugLineNum = 72220708;BA.debugLine="If B4XPages.MainPage.logger Then Log(\"actualizam";
if (mostCurrent._b4xpages._mainpage /*reparto_intmex.keymon.lat.b4xmainpage*/ (processBA)._logger /*boolean*/ ) { 
anywheresoftware.b4a.keywords.Common.LogImpl("272220708","actualizamos Ubicacion Web",0);};
RDebugUtils.currentLine=72220709;
 //BA.debugLineNum = 72220709;BA.debugLine="CallSubDelayed(Starter, \"ENVIA_ULTIMA_GPS\")";
anywheresoftware.b4a.keywords.Common.CallSubDelayed(processBA,(Object)(mostCurrent._starter.getObject()),"ENVIA_ULTIMA_GPS");
 };
RDebugUtils.currentLine=72220711;
 //BA.debugLineNum = 72220711;BA.debugLine="DateTime.TimeFormat = origFormat 'Regresamos form";
anywheresoftware.b4a.keywords.Common.DateTime.setTimeFormat(_origformat);
RDebugUtils.currentLine=72220713;
 //BA.debugLineNum = 72220713;BA.debugLine="Subs.monitor";
mostCurrent._subs._monitor /*String*/ (processBA);
RDebugUtils.currentLine=72220714;
 //BA.debugLineNum = 72220714;BA.debugLine="End Sub";
return "";
}
public static String  _service_create() throws Exception{
RDebugUtils.currentModule="tracker";
if (Debug.shouldDelegate(processBA, "service_create", false))
	 {return ((String) Debug.delegate(processBA, "service_create", null));}
RDebugUtils.currentLine=71434240;
 //BA.debugLineNum = 71434240;BA.debugLine="Sub Service_Create";
RDebugUtils.currentLine=71434241;
 //BA.debugLineNum = 71434241;BA.debugLine="Service.AutomaticForegroundMode = Service.AUTOMAT";
mostCurrent._service.AutomaticForegroundMode = mostCurrent._service.AUTOMATIC_FOREGROUND_NEVER;
RDebugUtils.currentLine=71434242;
 //BA.debugLineNum = 71434242;BA.debugLine="UUGCoords.Initialize";
_uugcoords.Initialize();
RDebugUtils.currentLine=71434243;
 //BA.debugLineNum = 71434243;BA.debugLine="UUGCoords.Latitude = 0";
_uugcoords.setLatitude(0);
RDebugUtils.currentLine=71434244;
 //BA.debugLineNum = 71434244;BA.debugLine="UUGCoords.Longitude = 0";
_uugcoords.setLongitude(0);
RDebugUtils.currentLine=71434246;
 //BA.debugLineNum = 71434246;BA.debugLine="FLP.Initialize(\"flp\")";
_flp.Initialize(processBA,"flp");
RDebugUtils.currentLine=71434247;
 //BA.debugLineNum = 71434247;BA.debugLine="FLP.Connect";
_flp.Connect();
RDebugUtils.currentLine=71434248;
 //BA.debugLineNum = 71434248;BA.debugLine="lock.PartialLock";
_lock.PartialLock(processBA);
RDebugUtils.currentLine=71434249;
 //BA.debugLineNum = 71434249;BA.debugLine="StartFLP";
_startflp();
RDebugUtils.currentLine=71434250;
 //BA.debugLineNum = 71434250;BA.debugLine="End Sub";
return "";
}
public static String  _service_destroy() throws Exception{
RDebugUtils.currentModule="tracker";
if (Debug.shouldDelegate(processBA, "service_destroy", false))
	 {return ((String) Debug.delegate(processBA, "service_destroy", null));}
RDebugUtils.currentLine=72351744;
 //BA.debugLineNum = 72351744;BA.debugLine="Sub Service_Destroy";
RDebugUtils.currentLine=72351745;
 //BA.debugLineNum = 72351745;BA.debugLine="If Tracking Then";
if (_tracking) { 
RDebugUtils.currentLine=72351746;
 //BA.debugLineNum = 72351746;BA.debugLine="StopFLP";
_stopflp();
 };
RDebugUtils.currentLine=72351748;
 //BA.debugLineNum = 72351748;BA.debugLine="Tracking = False";
_tracking = anywheresoftware.b4a.keywords.Common.False;
RDebugUtils.currentLine=72351749;
 //BA.debugLineNum = 72351749;BA.debugLine="lock.ReleasePartialLock";
_lock.ReleasePartialLock();
RDebugUtils.currentLine=72351750;
 //BA.debugLineNum = 72351750;BA.debugLine="End Sub";
return "";
}
public static String  _stopflp() throws Exception{
RDebugUtils.currentModule="tracker";
if (Debug.shouldDelegate(processBA, "stopflp", false))
	 {return ((String) Debug.delegate(processBA, "stopflp", null));}
RDebugUtils.currentLine=72155136;
 //BA.debugLineNum = 72155136;BA.debugLine="Public Sub StopFLP";
RDebugUtils.currentLine=72155138;
 //BA.debugLineNum = 72155138;BA.debugLine="If flpStarted Then";
if (_flpstarted) { 
RDebugUtils.currentLine=72155139;
 //BA.debugLineNum = 72155139;BA.debugLine="FLP.RemoveLocationUpdates  'Eliminamos todas las";
_flp.RemoveLocationUpdates();
RDebugUtils.currentLine=72155140;
 //BA.debugLineNum = 72155140;BA.debugLine="flpStarted = False";
_flpstarted = anywheresoftware.b4a.keywords.Common.False;
 };
RDebugUtils.currentLine=72155142;
 //BA.debugLineNum = 72155142;BA.debugLine="End Sub";
return "";
}
public static String  _service_start(anywheresoftware.b4a.objects.IntentWrapper _startingintent) throws Exception{
RDebugUtils.currentModule="tracker";
if (Debug.shouldDelegate(processBA, "service_start", false))
	 {return ((String) Debug.delegate(processBA, "service_start", new Object[] {_startingintent}));}
RDebugUtils.currentLine=71696384;
 //BA.debugLineNum = 71696384;BA.debugLine="Sub Service_Start (StartingIntent As Intent)";
RDebugUtils.currentLine=71696385;
 //BA.debugLineNum = 71696385;BA.debugLine="LogColor(\"Iniciando Tracker ...\", Colors.Green)";
anywheresoftware.b4a.keywords.Common.LogImpl("271696385","Iniciando Tracker ...",anywheresoftware.b4a.keywords.Common.Colors.Green);
RDebugUtils.currentLine=71696386;
 //BA.debugLineNum = 71696386;BA.debugLine="Service.StopAutomaticForeground";
mostCurrent._service.StopAutomaticForeground();
RDebugUtils.currentLine=71696388;
 //BA.debugLineNum = 71696388;BA.debugLine="StartServiceAt(Me, DateTime.Now + 10 * DateTime.T";
anywheresoftware.b4a.keywords.Common.StartServiceAt(processBA,tracker.getObject(),(long) (anywheresoftware.b4a.keywords.Common.DateTime.getNow()+10*anywheresoftware.b4a.keywords.Common.DateTime.TicksPerMinute),anywheresoftware.b4a.keywords.Common.True);
RDebugUtils.currentLine=71696389;
 //BA.debugLineNum = 71696389;BA.debugLine="Track";
_track();
RDebugUtils.currentLine=71696390;
 //BA.debugLineNum = 71696390;BA.debugLine="Starter.trackerActividad = Subs.fechaKMT(DateTime";
mostCurrent._starter._trackeractividad /*String*/  = mostCurrent._subs._fechakmt /*String*/ (processBA,BA.NumberToString(anywheresoftware.b4a.keywords.Common.DateTime.getNow()));
RDebugUtils.currentLine=71696392;
 //BA.debugLineNum = 71696392;BA.debugLine="End Sub";
return "";
}
public static String  _track() throws Exception{
RDebugUtils.currentModule="tracker";
if (Debug.shouldDelegate(processBA, "track", false))
	 {return ((String) Debug.delegate(processBA, "track", null));}
RDebugUtils.currentLine=71761920;
 //BA.debugLineNum = 71761920;BA.debugLine="Public Sub Track";
RDebugUtils.currentLine=71761921;
 //BA.debugLineNum = 71761921;BA.debugLine="If B4XPages.MainPage.logger Then Log(\"Inicia Trac";
if (mostCurrent._b4xpages._mainpage /*reparto_intmex.keymon.lat.b4xmainpage*/ (processBA)._logger /*boolean*/ ) { 
anywheresoftware.b4a.keywords.Common.LogImpl("271761921","Inicia Track - Tracking : "+BA.ObjectToString(_tracking),0);};
RDebugUtils.currentLine=71761922;
 //BA.debugLineNum = 71761922;BA.debugLine="If Tracking Then";
if (_tracking) { 
RDebugUtils.currentLine=71761924;
 //BA.debugLineNum = 71761924;BA.debugLine="Return 'Si ya estamos \"rastreando\" no hacemos na";
if (true) return "";
 };
RDebugUtils.currentLine=71761926;
 //BA.debugLineNum = 71761926;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) { 
RDebugUtils.currentLine=71761927;
 //BA.debugLineNum = 71761927;BA.debugLine="If B4XPages.MainPage.logger Then Log(\"No permiss";
if (mostCurrent._b4xpages._mainpage /*reparto_intmex.keymon.lat.b4xmainpage*/ (processBA)._logger /*boolean*/ ) { 
anywheresoftware.b4a.keywords.Common.LogImpl("271761927","No permission",0);};
RDebugUtils.currentLine=71761928;
 //BA.debugLineNum = 71761928;BA.debugLine="Return";
if (true) return "";
 };
RDebugUtils.currentLine=71761930;
 //BA.debugLineNum = 71761930;BA.debugLine="StartFLP 'Iniciamos FusedLocationProvider";
_startflp();
RDebugUtils.currentLine=71761931;
 //BA.debugLineNum = 71761931;BA.debugLine="Tracking = True";
_tracking = anywheresoftware.b4a.keywords.Common.True;
RDebugUtils.currentLine=71761932;
 //BA.debugLineNum = 71761932;BA.debugLine="End Sub";
return "";
}
public static void  _startflp2reqs() throws Exception{
RDebugUtils.currentModule="tracker";
if (Debug.shouldDelegate(processBA, "startflp2reqs", false))
	 {Debug.delegate(processBA, "startflp2reqs", null); return;}
ResumableSub_StartFLP2Reqs rsub = new ResumableSub_StartFLP2Reqs(null);
rsub.resume(processBA, null);
}
public static class ResumableSub_StartFLP2Reqs extends BA.ResumableSub {
public ResumableSub_StartFLP2Reqs(reparto_intmex.keymon.lat.tracker parent) {
this.parent = parent;
}
reparto_intmex.keymon.lat.tracker parent;

@Override
public void resume(BA ba, Object[] result) throws Exception{
RDebugUtils.currentModule="tracker";

    while (true) {
        switch (state) {
            case -1:
return;

case 0:
//C
this.state = 1;
RDebugUtils.currentLine=71892993;
 //BA.debugLineNum = 71892993;BA.debugLine="If B4XPages.MainPage.logger Then Log(\"StartFLP -";
if (true) break;

case 1:
//if
this.state = 6;
if (parent.mostCurrent._b4xpages._mainpage /*reparto_intmex.keymon.lat.b4xmainpage*/ (processBA)._logger /*boolean*/ ) { 
this.state = 3;
;}if (true) break;

case 3:
//C
this.state = 6;
anywheresoftware.b4a.keywords.Common.LogImpl("271892993","StartFLP - flpStarted="+BA.ObjectToString(parent._flpstarted),0);
if (true) break;

case 6:
//C
this.state = 7;
;
RDebugUtils.currentLine=71892994;
 //BA.debugLineNum = 71892994;BA.debugLine="Do While FLP.IsConnected = False";
if (true) break;

case 7:
//do while
this.state = 16;
while (parent._flp.IsConnected()==anywheresoftware.b4a.keywords.Common.False) {
this.state = 9;
if (true) break;
}
if (true) break;

case 9:
//C
this.state = 10;
RDebugUtils.currentLine=71892995;
 //BA.debugLineNum = 71892995;BA.debugLine="Sleep(500)";
anywheresoftware.b4a.keywords.Common.Sleep(processBA,new anywheresoftware.b4a.shell.DebugResumableSub.DelegatableResumableSub(this, "tracker", "startflp2reqs"),(int) (500));
this.state = 29;
return;
case 29:
//C
this.state = 10;
;
RDebugUtils.currentLine=71892996;
 //BA.debugLineNum = 71892996;BA.debugLine="If B4XPages.MainPage.logger Then Log(\"sleeping G";
if (true) break;

case 10:
//if
this.state = 15;
if (parent.mostCurrent._b4xpages._mainpage /*reparto_intmex.keymon.lat.b4xmainpage*/ (processBA)._logger /*boolean*/ ) { 
this.state = 12;
;}if (true) break;

case 12:
//C
this.state = 15;
anywheresoftware.b4a.keywords.Common.LogImpl("271892996","sleeping GR",0);
if (true) break;

case 15:
//C
this.state = 7;
;
 if (true) break;

case 16:
//C
this.state = 17;
;
RDebugUtils.currentLine=71892998;
 //BA.debugLineNum = 71892998;BA.debugLine="dameUltimaUbicacionConocida 'Regresamos ultima ub";
_dameultimaubicacionconocida();
RDebugUtils.currentLine=71892999;
 //BA.debugLineNum = 71892999;BA.debugLine="FLP.RequestLocationUpdates(CreateLocationRequest2";
parent._flp.RequestLocationUpdates((com.google.android.gms.location.LocationRequest)(_createlocationrequest2times().getObject()));
RDebugUtils.currentLine=71893000;
 //BA.debugLineNum = 71893000;BA.debugLine="If B4XPages.MainPage.logger Then Log(\"Buscamos ub";
if (true) break;

case 17:
//if
this.state = 22;
if (parent.mostCurrent._b4xpages._mainpage /*reparto_intmex.keymon.lat.b4xmainpage*/ (processBA)._logger /*boolean*/ ) { 
this.state = 19;
;}if (true) break;

case 19:
//C
this.state = 22;
anywheresoftware.b4a.keywords.Common.LogImpl("271893000","Buscamos ubicacion 2 peticiones",0);
if (true) break;

case 22:
//C
this.state = 23;
;
RDebugUtils.currentLine=71893001;
 //BA.debugLineNum = 71893001;BA.debugLine="If B4XPages.MainPage.logger Then Log(actualLR.Get";
if (true) break;

case 23:
//if
this.state = 28;
if (parent.mostCurrent._b4xpages._mainpage /*reparto_intmex.keymon.lat.b4xmainpage*/ (processBA)._logger /*boolean*/ ) { 
this.state = 25;
;}if (true) break;

case 25:
//C
this.state = 28;
anywheresoftware.b4a.keywords.Common.LogImpl("271893001",BA.NumberToString(parent._actuallr.GetSmallestDisplacement()),0);
if (true) break;

case 28:
//C
this.state = -1;
;
RDebugUtils.currentLine=71893002;
 //BA.debugLineNum = 71893002;BA.debugLine="End Sub";
if (true) break;

            }
        }
    }
}
}