package gunav2.keymon.com.mx;


import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.objects.ServiceHelper;
import anywheresoftware.b4a.debug.*;

public class firebasemessaging extends android.app.Service{
	public static class firebasemessaging_BR extends android.content.BroadcastReceiver {

		@Override
		public void onReceive(android.content.Context context, android.content.Intent intent) {
            BA.LogInfo("** Receiver (firebasemessaging) OnReceive **");
			android.content.Intent in = new android.content.Intent(context, firebasemessaging.class);
			if (intent != null)
				in.putExtra("b4a_internal_intent", intent);
            ServiceHelper.StarterHelper.startServiceFromReceiver (context, in, false, BA.class);
		}

	}
    static firebasemessaging mostCurrent;
	public static BA processBA;
    private ServiceHelper _service;
    public static Class<?> getObject() {
		return firebasemessaging.class;
	}
	@Override
	public void onCreate() {
        super.onCreate();
        mostCurrent = this;
        if (processBA == null) {
		    processBA = new BA(this, null, null, "gunav2.keymon.com.mx", "gunav2.keymon.com.mx.firebasemessaging");
            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, "gunav2.keymon.com.mx.firebasemessaging", processBA, _service, anywheresoftware.b4a.keywords.Common.Density);
		}
        if (!false && ServiceHelper.StarterHelper.startFromServiceCreate(processBA, false) == false) {
				
		}
		else {
            processBA.setActivityPaused(false);
            BA.LogInfo("*** Service (firebasemessaging) 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 (firebasemessaging) 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 (firebasemessaging) 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 (firebasemessaging) Destroy (ignored)**");
        }
        else {
            BA.LogInfo("** Service (firebasemessaging) 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 anywheresoftware.b4a.objects.FirebaseNotificationsService.FirebaseMessageWrapper _fm = null;
public static String _api_key = "";
public static String _locrequest = "";
public static anywheresoftware.b4a.phone.PhoneEvents _pe = null;
public static anywheresoftware.b4a.sql.SQL.CursorWrapper _c = null;
public static de.donmanfred.GZipStringswrapper _gzip = null;
public static String _sprvsr = "";
public static String _subscrito = "";
public static String _au = "";
public b4a.example.dateutils _dateutils = null;
public gunav2.keymon.com.mx.main _main = null;
public gunav2.keymon.com.mx.starter _starter = null;
public gunav2.keymon.com.mx.subs _subs = null;
public gunav2.keymon.com.mx.mapa_rutas _mapa_rutas = null;
public gunav2.keymon.com.mx.appupdater _appupdater = null;
public gunav2.keymon.com.mx.tracker _tracker = null;
public gunav2.keymon.com.mx.newinst2 _newinst2 = null;
public gunav2.keymon.com.mx.b4xpages _b4xpages = null;
public gunav2.keymon.com.mx.b4xcollections _b4xcollections = null;
public gunav2.keymon.com.mx.httputils2service _httputils2service = null;
public gunav2.keymon.com.mx.xuiviewsutils _xuiviewsutils = null;
public static String  _borragpshist() throws Exception{
 //BA.debugLineNum = 218;BA.debugLine="Sub borraGPSHist";
 //BA.debugLineNum = 219;BA.debugLine="c = B4XPages.MainPage.skmt.ExecQuery(\"delete FROM";
_c = (anywheresoftware.b4a.sql.SQL.CursorWrapper) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4a.sql.SQL.CursorWrapper(), (android.database.Cursor)(mostCurrent._b4xpages._mainpage /*gunav2.keymon.com.mx.b4xmainpage*/ (processBA)._skmt /*anywheresoftware.b4a.sql.SQL*/ .ExecQuery("delete FROM RUTA_GPS")));
 //BA.debugLineNum = 220;BA.debugLine="End Sub";
return "";
}
public static String  _borramosarchivogps() throws Exception{
anywheresoftware.b4a.objects.streams.File.OutputStreamWrapper _out = null;
String _s = "";
byte[] _t = null;
 //BA.debugLineNum = 167;BA.debugLine="Sub borramosArchivoGPS";
 //BA.debugLineNum = 168;BA.debugLine="Dim out As OutputStream = File.OpenOutput(File.Di";
_out = new anywheresoftware.b4a.objects.streams.File.OutputStreamWrapper();
_out = anywheresoftware.b4a.keywords.Common.File.OpenOutput(anywheresoftware.b4a.keywords.Common.File.getDirRootExternal(),"gps.txt",anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 169;BA.debugLine="Dim s As String = \"\"";
_s = "";
 //BA.debugLineNum = 170;BA.debugLine="Dim t() As Byte = s.GetBytes(\"UTF-8\")";
_t = _s.getBytes("UTF-8");
 //BA.debugLineNum = 171;BA.debugLine="out.WriteBytes(t, 0, t.Length)";
_out.WriteBytes(_t,(int) (0),_t.length);
 //BA.debugLineNum = 172;BA.debugLine="out.Close";
_out.Close();
 //BA.debugLineNum = 173;BA.debugLine="End Sub";
return "";
}
public static String  _compress(String _str) throws Exception{
anywheresoftware.b4a.objects.StringUtils _su = null;
byte[] _compressed = null;
String _base64 = "";
 //BA.debugLineNum = 179;BA.debugLine="Sub compress(str As String) As String";
 //BA.debugLineNum = 181;BA.debugLine="Private su As StringUtils";
_su = new anywheresoftware.b4a.objects.StringUtils();
 //BA.debugLineNum = 182;BA.debugLine="Dim compressed() As Byte = GZip.compress(str)";
_compressed = _gzip.compress(_str);
 //BA.debugLineNum = 183;BA.debugLine="Log($\"CompressedBytesLength: ${compressed.Length}";
anywheresoftware.b4a.keywords.Common.LogImpl("456950788",("CompressedBytesLength: "+anywheresoftware.b4a.keywords.Common.SmartStringFormatter("",(Object)(_compressed.length))+""),0);
 //BA.debugLineNum = 184;BA.debugLine="Dim base64 As String = su.EncodeBase64(compressed";
_base64 = _su.EncodeBase64(_compressed);
 //BA.debugLineNum = 185;BA.debugLine="Log($\"CompressedBytes converted to base64 Length:";
anywheresoftware.b4a.keywords.Common.LogImpl("456950790",("CompressedBytes converted to base64 Length: "+anywheresoftware.b4a.keywords.Common.SmartStringFormatter("",(Object)(_base64.length()))+""),0);
 //BA.debugLineNum = 186;BA.debugLine="Log($\"CompressedBytes converted to base64: ${base";
anywheresoftware.b4a.keywords.Common.LogImpl("456950791",("CompressedBytes converted to base64: "+anywheresoftware.b4a.keywords.Common.SmartStringFormatter("",(Object)(_base64))+""),0);
 //BA.debugLineNum = 187;BA.debugLine="Return base64";
if (true) return _base64;
 //BA.debugLineNum = 188;BA.debugLine="End Sub";
return "";
}
public static String  _dameruta() throws Exception{
String _ruta2 = "";
int _i = 0;
 //BA.debugLineNum = 202;BA.debugLine="Sub dameRuta As String";
 //BA.debugLineNum = 203;BA.debugLine="Log(\"dameRuta\")";
anywheresoftware.b4a.keywords.Common.LogImpl("457081857","dameRuta",0);
 //BA.debugLineNum = 204;BA.debugLine="Dim c As Cursor";
_c = new anywheresoftware.b4a.sql.SQL.CursorWrapper();
 //BA.debugLineNum = 205;BA.debugLine="c = B4XPages.MainPage.skmt.ExecQuery(\"select LAT,";
_c = (anywheresoftware.b4a.sql.SQL.CursorWrapper) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4a.sql.SQL.CursorWrapper(), (android.database.Cursor)(mostCurrent._b4xpages._mainpage /*gunav2.keymon.com.mx.b4xmainpage*/ (processBA)._skmt /*anywheresoftware.b4a.sql.SQL*/ .ExecQuery("select LAT, LON from RUTA_GPS order by FECHA desc limit 390")));
 //BA.debugLineNum = 206;BA.debugLine="c.Position = 0";
_c.setPosition((int) (0));
 //BA.debugLineNum = 207;BA.debugLine="Dim ruta2 As String = \"\"";
_ruta2 = "";
 //BA.debugLineNum = 208;BA.debugLine="If c.RowCount>0 Then";
if (_c.getRowCount()>0) { 
 //BA.debugLineNum = 209;BA.debugLine="For i=0 To c.RowCount -1";
{
final int step7 = 1;
final int limit7 = (int) (_c.getRowCount()-1);
_i = (int) (0) ;
for (;_i <= limit7 ;_i = _i + step7 ) {
 //BA.debugLineNum = 210;BA.debugLine="c.Position=i";
_c.setPosition(_i);
 //BA.debugLineNum = 211;BA.debugLine="ruta2=ruta2&CRLF&c.GetString(\"LAT\")&\",\"&c.GetSt";
_ruta2 = _ruta2+anywheresoftware.b4a.keywords.Common.CRLF+_c.GetString("LAT")+","+_c.GetString("LON");
 }
};
 };
 //BA.debugLineNum = 214;BA.debugLine="c.Close";
_c.Close();
 //BA.debugLineNum = 215;BA.debugLine="Return compress(ruta2)";
if (true) return _compress(_ruta2);
 //BA.debugLineNum = 216;BA.debugLine="End Sub";
return "";
}
public static String  _decompress(String _base64) throws Exception{
anywheresoftware.b4a.objects.StringUtils _su = null;
byte[] _decompressedbytes = null;
anywheresoftware.b4a.agraham.byteconverter.ByteConverter _bc = null;
String _uncompressed = "";
 //BA.debugLineNum = 190;BA.debugLine="Sub decompress(base64 As String) As String 'ignore";
 //BA.debugLineNum = 192;BA.debugLine="Private su As StringUtils";
_su = new anywheresoftware.b4a.objects.StringUtils();
 //BA.debugLineNum = 193;BA.debugLine="Dim decompressedbytes() As Byte = su.DecodeBase64";
_decompressedbytes = _su.DecodeBase64(_base64);
 //BA.debugLineNum = 194;BA.debugLine="Log($\"decompressedbytesLength: ${decompressedbyte";
anywheresoftware.b4a.keywords.Common.LogImpl("457016324",("decompressedbytesLength: "+anywheresoftware.b4a.keywords.Common.SmartStringFormatter("",(Object)(_decompressedbytes.length))+""),0);
 //BA.debugLineNum = 195;BA.debugLine="Dim bc As ByteConverter";
_bc = new anywheresoftware.b4a.agraham.byteconverter.ByteConverter();
 //BA.debugLineNum = 196;BA.debugLine="Dim uncompressed As String = bc.StringFromBytes(d";
_uncompressed = _bc.StringFromBytes(_decompressedbytes,"UTF8");
 //BA.debugLineNum = 197;BA.debugLine="Log($\"uncompressedLength: ${uncompressed.Length}\"";
anywheresoftware.b4a.keywords.Common.LogImpl("457016327",("uncompressedLength: "+anywheresoftware.b4a.keywords.Common.SmartStringFormatter("",(Object)(_uncompressed.length()))+""),0);
 //BA.debugLineNum = 198;BA.debugLine="Log($\"Decompressed String = ${uncompressed}\"$)";
anywheresoftware.b4a.keywords.Common.LogImpl("457016328",("Decompressed String = "+anywheresoftware.b4a.keywords.Common.SmartStringFormatter("",(Object)(_uncompressed))+""),0);
 //BA.debugLineNum = 199;BA.debugLine="Return uncompressed";
if (true) return _uncompressed;
 //BA.debugLineNum = 200;BA.debugLine="End Sub";
return "";
}
public static String  _fm_messagearrived(anywheresoftware.b4a.objects.FirebaseNotificationsService.RemoteMessageWrapper _message) throws Exception{
anywheresoftware.b4a.objects.collections.List _tipos = null;
anywheresoftware.b4a.objects.collections.Map _params = null;
String _rutagpscmp = "";
 //BA.debugLineNum = 72;BA.debugLine="Sub fm_MessageArrived (Message As RemoteMessage)";
 //BA.debugLineNum = 73;BA.debugLine="Log(\"Message arrived\")";
anywheresoftware.b4a.keywords.Common.LogImpl("456492033","Message arrived",0);
 //BA.debugLineNum = 74;BA.debugLine="Log($\"Message data: ${Message.GetData}\"$)";
anywheresoftware.b4a.keywords.Common.LogImpl("456492034",("Message data: "+anywheresoftware.b4a.keywords.Common.SmartStringFormatter("",(Object)(_message.GetData().getObject()))+""),0);
 //BA.debugLineNum = 76;BA.debugLine="If Message.GetData.ContainsKey(\"t\") Then";
if (_message.GetData().ContainsKey((Object)("t"))) { 
 //BA.debugLineNum = 77;BA.debugLine="Dim tipos As List = Regex.Split(\",\",Message.GetD";
_tipos = new anywheresoftware.b4a.objects.collections.List();
_tipos = anywheresoftware.b4a.keywords.Common.ArrayToList(anywheresoftware.b4a.keywords.Common.Regex.Split(",",BA.ObjectToString(_message.GetData().Get((Object)("t")))));
 //BA.debugLineNum = 78;BA.debugLine="If tipos.IndexOf(\"pu\") <> -1 Or tipos.IndexOf(\"a";
if (_tipos.IndexOf((Object)("pu"))!=-1 || _tipos.IndexOf((Object)("au"))!=-1) { 
 //BA.debugLineNum = 79;BA.debugLine="Log(\"Es una peticion de ubicacion\")";
anywheresoftware.b4a.keywords.Common.LogImpl("456492039","Es una peticion de ubicacion",0);
 //BA.debugLineNum = 80;BA.debugLine="locRequest=\"Activa\"";
_locrequest = "Activa";
 //BA.debugLineNum = 81;BA.debugLine="Log(\"Llamamos StartFLPSmall\")";
anywheresoftware.b4a.keywords.Common.LogImpl("456492041","Llamamos StartFLPSmall",0);
 //BA.debugLineNum = 82;BA.debugLine="CallSubDelayed(Tracker, \"StartFLPSmall\")";
anywheresoftware.b4a.keywords.Common.CallSubDelayed(processBA,(Object)(mostCurrent._tracker.getObject()),"StartFLPSmall");
 //BA.debugLineNum = 83;BA.debugLine="CallSubDelayed(Tracker, \"StartFLP\")";
anywheresoftware.b4a.keywords.Common.CallSubDelayed(processBA,(Object)(mostCurrent._tracker.getObject()),"StartFLP");
 };
 //BA.debugLineNum = 85;BA.debugLine="If tipos.IndexOf(\"au\") <> -1 Then 'Si es una act";
if (_tipos.IndexOf((Object)("au"))!=-1) { 
 //BA.debugLineNum = 86;BA.debugLine="au = 1";
_au = BA.NumberToString(1);
 };
 //BA.debugLineNum = 88;BA.debugLine="If tipos.IndexOf(\"ping\") <> -1 Then 'Si es un pi";
if (_tipos.IndexOf((Object)("ping"))!=-1) { 
 //BA.debugLineNum = 89;BA.debugLine="Log(\"Es un ping\")";
anywheresoftware.b4a.keywords.Common.LogImpl("456492049","Es un ping",0);
 //BA.debugLineNum = 90;BA.debugLine="Log(\"Mandamos pong\")";
anywheresoftware.b4a.keywords.Common.LogImpl("456492050","Mandamos pong",0);
 //BA.debugLineNum = 91;BA.debugLine="Dim params As Map = CreateMap(\"topic\":Sprvsr,\"t";
_params = new anywheresoftware.b4a.objects.collections.Map();
_params = anywheresoftware.b4a.keywords.Common.createMap(new Object[] {(Object)("topic"),(Object)(_sprvsr),(Object)("title"),(Object)("pong"),(Object)("body"),(Object)(mostCurrent._b4xpages._mainpage /*gunav2.keymon.com.mx.b4xmainpage*/ (processBA)._usuario /*String*/ +" - Recibi mensaje "+BA.ObjectToString(_message.GetData().Get((Object)("title")))),(Object)("t"),(Object)("pong")});
 //BA.debugLineNum = 92;BA.debugLine="SendMessage(params)";
_sendmessage(_params);
 };
 //BA.debugLineNum = 94;BA.debugLine="If tipos.IndexOf(\"bgps\") <> -1 Then 'Si es una i";
if (_tipos.IndexOf((Object)("bgps"))!=-1) { 
 //BA.debugLineNum = 95;BA.debugLine="Log(\"Es una instruccion de borrar archivo gps\")";
anywheresoftware.b4a.keywords.Common.LogImpl("456492055","Es una instruccion de borrar archivo gps",0);
 //BA.debugLineNum = 96;BA.debugLine="Log(\"Borramos archivo gps\")";
anywheresoftware.b4a.keywords.Common.LogImpl("456492056","Borramos archivo gps",0);
 //BA.debugLineNum = 97;BA.debugLine="borramosArchivoGPS";
_borramosarchivogps();
 };
 //BA.debugLineNum = 99;BA.debugLine="If tipos.IndexOf(\"dr\") <> -1 Then 'Si es una pet";
if (_tipos.IndexOf((Object)("dr"))!=-1) { 
 //BA.debugLineNum = 100;BA.debugLine="Log(\"Es una peticion de Ruta GPS\")";
anywheresoftware.b4a.keywords.Common.LogImpl("456492060","Es una peticion de Ruta GPS",0);
 //BA.debugLineNum = 101;BA.debugLine="Dim rutaGpsCmp As String = dameRuta";
_rutagpscmp = _dameruta();
 //BA.debugLineNum = 102;BA.debugLine="Dim params As Map = CreateMap(\"topic\":Sprvsr,\"t";
_params = new anywheresoftware.b4a.objects.collections.Map();
_params = anywheresoftware.b4a.keywords.Common.createMap(new Object[] {(Object)("topic"),(Object)(_sprvsr),(Object)("title"),(Object)("ruta"),(Object)("body"),(Object)(mostCurrent._b4xpages._mainpage /*gunav2.keymon.com.mx.b4xmainpage*/ (processBA)._usuario /*String*/ +" - Recibi mensaje "+BA.ObjectToString(_message.GetData().Get((Object)("title")))),(Object)("t"),(Object)("ruta"),(Object)("r"),(Object)(_rutagpscmp)});
 //BA.debugLineNum = 103;BA.debugLine="SendMessage(params)";
_sendmessage(_params);
 };
 //BA.debugLineNum = 105;BA.debugLine="If tipos.IndexOf(\"bgps2\") <> -1 Then 'Si es una";
if (_tipos.IndexOf((Object)("bgps2"))!=-1) { 
 //BA.debugLineNum = 106;BA.debugLine="Log(\"Es una instruccion de borrar BD gps\")";
anywheresoftware.b4a.keywords.Common.LogImpl("456492066","Es una instruccion de borrar BD gps",0);
 //BA.debugLineNum = 107;BA.debugLine="Log(\"Borramos BD gps\")";
anywheresoftware.b4a.keywords.Common.LogImpl("456492067","Borramos BD gps",0);
 //BA.debugLineNum = 108;BA.debugLine="borraGPSHist";
_borragpshist();
 };
 //BA.debugLineNum = 110;BA.debugLine="If tipos.IndexOf(\"pu\") = -1 And tipos.IndexOf(\"a";
if (_tipos.IndexOf((Object)("pu"))==-1 && _tipos.IndexOf((Object)("au"))==-1 && _tipos.IndexOf((Object)("ping"))==-1 && _tipos.IndexOf((Object)("dr"))==-1) { 
 //BA.debugLineNum = 111;BA.debugLine="Log(\"No es ping ni solicitud de ubicacion o rut";
anywheresoftware.b4a.keywords.Common.LogImpl("456492071","No es ping ni solicitud de ubicacion o ruta, entonces no hacemos nada",0);
 };
 };
 //BA.debugLineNum = 119;BA.debugLine="End Sub";
return "";
}
public static String  _guardainfoenarchivo(String _coords) throws Exception{
String[] _latlon = null;
 //BA.debugLineNum = 161;BA.debugLine="Sub guardaInfoEnArchivo(coords As String) 'ignore";
 //BA.debugLineNum = 162;BA.debugLine="Log(\"Guardamos ubicacion en BD\")";
anywheresoftware.b4a.keywords.Common.LogImpl("456754177","Guardamos ubicacion en BD",0);
 //BA.debugLineNum = 163;BA.debugLine="Dim latlon() As String = Regex.Split(\",\", coords)";
_latlon = anywheresoftware.b4a.keywords.Common.Regex.Split(",",_coords);
 //BA.debugLineNum = 164;BA.debugLine="B4XPages.MainPage.skmt.ExecNonQuery2(\"INSERT INTO";
mostCurrent._b4xpages._mainpage /*gunav2.keymon.com.mx.b4xmainpage*/ (processBA)._skmt /*anywheresoftware.b4a.sql.SQL*/ .ExecNonQuery2("INSERT INTO RUTA_GPS(FECHA, LAT, LON) VALUES (?,?,?)",anywheresoftware.b4a.keywords.Common.ArrayToList(new Object[]{(Object)(_latlon[(int) (2)]),(Object)(_latlon[(int) (0)]),(Object)(_latlon[(int) (1)])}));
 //BA.debugLineNum = 165;BA.debugLine="End Sub";
return "";
}
public static String  _mandamosloc(String _coords) throws Exception{
anywheresoftware.b4a.objects.collections.Map _params = null;
 //BA.debugLineNum = 150;BA.debugLine="Sub mandamosLoc(coords As String)";
 //BA.debugLineNum = 153;BA.debugLine="If locRequest=\"Activa\" Then 'Si hay solicitud de";
if ((_locrequest).equals("Activa")) { 
 //BA.debugLineNum = 154;BA.debugLine="Dim params As Map = CreateMap(\"topic\":Sprvsr,\"ti";
_params = new anywheresoftware.b4a.objects.collections.Map();
_params = anywheresoftware.b4a.keywords.Common.createMap(new Object[] {(Object)("topic"),(Object)(_sprvsr),(Object)("title"),(Object)("ubicacionRecibida"),(Object)("body"),(Object)(_coords),(Object)("t"),(Object)("u")});
 //BA.debugLineNum = 155;BA.debugLine="SendMessage(params)";
_sendmessage(_params);
 //BA.debugLineNum = 156;BA.debugLine="locRequest=\"Enviada\"";
_locrequest = "Enviada";
 //BA.debugLineNum = 157;BA.debugLine="CallSubDelayed(Tracker,\"CreateLocationRequest\")";
anywheresoftware.b4a.keywords.Common.CallSubDelayed(processBA,(Object)(mostCurrent._tracker.getObject()),"CreateLocationRequest");
 };
 //BA.debugLineNum = 159;BA.debugLine="End Sub";
return "";
}
public static String  _pe_batterychanged(int _level,int _scale,boolean _plugged,anywheresoftware.b4a.objects.IntentWrapper _intent) throws Exception{
 //BA.debugLineNum = 175;BA.debugLine="Sub pe_BatteryChanged (Level As Int, Scale As Int,";
 //BA.debugLineNum = 176;BA.debugLine="B4XPages.MainPage.batt=Level";
mostCurrent._b4xpages._mainpage /*gunav2.keymon.com.mx.b4xmainpage*/ (processBA)._batt /*int*/  = _level;
 //BA.debugLineNum = 177;BA.debugLine="End Sub";
return "";
}
public static String  _process_globals() throws Exception{
 //BA.debugLineNum = 32;BA.debugLine="Sub Process_Globals";
 //BA.debugLineNum = 33;BA.debugLine="Private fm As FirebaseMessaging";
_fm = new anywheresoftware.b4a.objects.FirebaseNotificationsService.FirebaseMessageWrapper();
 //BA.debugLineNum = 34;BA.debugLine="Private const API_KEY As String = \"AAAAv1qt3Lk:AP";
_api_key = "AAAAv1qt3Lk:APA91bECIR-pHn6ul53eYyoVlpPuOo85RO-0zcAgEXwE7vqw8DFSbBtCaCINiqWQAkBBZXxHtQMdpU6B-jHIqgFKVL196UgwHv0Gw6_IgmipfV_NiItjzlH9d2QNpGLp9y_JUKVjUEhP";
 //BA.debugLineNum = 35;BA.debugLine="Dim locRequest As String";
_locrequest = "";
 //BA.debugLineNum = 37;BA.debugLine="Dim pe As PhoneEvents";
_pe = new anywheresoftware.b4a.phone.PhoneEvents();
 //BA.debugLineNum = 38;BA.debugLine="Dim c As Cursor";
_c = new anywheresoftware.b4a.sql.SQL.CursorWrapper();
 //BA.debugLineNum = 39;BA.debugLine="Public GZip As GZipStrings";
_gzip = new de.donmanfred.GZipStringswrapper();
 //BA.debugLineNum = 40;BA.debugLine="Dim Sprvsr As String = \"Sprv-Cedex\" ' El topico a";
_sprvsr = "Sprv-Cedex";
 //BA.debugLineNum = 41;BA.debugLine="Dim Subscrito As String";
_subscrito = "";
 //BA.debugLineNum = 42;BA.debugLine="Dim au As String 'ignore";
_au = "";
 //BA.debugLineNum = 43;BA.debugLine="End Sub";
return "";
}
public static String  _sendmessage(anywheresoftware.b4a.objects.collections.Map _params) throws Exception{
String _topic = "";
String _title = "";
String _body = "";
String _tipo = "";
String _rutagpscmp = "";
gunav2.keymon.com.mx.httpjob _job = null;
anywheresoftware.b4a.objects.collections.Map _m = null;
anywheresoftware.b4a.objects.collections.Map _data = null;
anywheresoftware.b4a.objects.collections.JSONParser.JSONGenerator _jg = null;
 //BA.debugLineNum = 125;BA.debugLine="Sub SendMessage(params As Map)";
 //BA.debugLineNum = 126;BA.debugLine="Dim topic As String= params.Get(\"topic\")";
_topic = BA.ObjectToString(_params.Get((Object)("topic")));
 //BA.debugLineNum = 127;BA.debugLine="Dim title As String= params.Get(\"title\")";
_title = BA.ObjectToString(_params.Get((Object)("title")));
 //BA.debugLineNum = 128;BA.debugLine="Dim body As String= params.Get(\"body\")";
_body = BA.ObjectToString(_params.Get((Object)("body")));
 //BA.debugLineNum = 129;BA.debugLine="Dim tipo As String= params.Get(\"t\")";
_tipo = BA.ObjectToString(_params.Get((Object)("t")));
 //BA.debugLineNum = 130;BA.debugLine="If params.ContainsKey(\"r\") Then";
if (_params.ContainsKey((Object)("r"))) { 
 //BA.debugLineNum = 131;BA.debugLine="Log(\"Con ruta\")";
anywheresoftware.b4a.keywords.Common.LogImpl("456623110","Con ruta",0);
 //BA.debugLineNum = 132;BA.debugLine="Dim rutaGpsCmp As String= params.Get(\"r\")";
_rutagpscmp = BA.ObjectToString(_params.Get((Object)("r")));
 }else {
 //BA.debugLineNum = 134;BA.debugLine="Log(\"Sin ruta\")";
anywheresoftware.b4a.keywords.Common.LogImpl("456623113","Sin ruta",0);
 //BA.debugLineNum = 135;BA.debugLine="Dim rutaGpsCmp As String = \"\"";
_rutagpscmp = "";
 };
 //BA.debugLineNum = 137;BA.debugLine="Dim Job As HttpJob";
_job = new gunav2.keymon.com.mx.httpjob();
 //BA.debugLineNum = 138;BA.debugLine="Job.Initialize(\"fcm\", Me)";
_job._initialize /*String*/ (processBA,"fcm",firebasemessaging.getObject());
 //BA.debugLineNum = 139;BA.debugLine="Dim m As Map = CreateMap(\"to\": $\"/topics/${topic}";
_m = new anywheresoftware.b4a.objects.collections.Map();
_m = anywheresoftware.b4a.keywords.Common.createMap(new Object[] {(Object)("to"),(Object)(("/topics/"+anywheresoftware.b4a.keywords.Common.SmartStringFormatter("",(Object)(_topic))+""))});
 //BA.debugLineNum = 140;BA.debugLine="Dim data As Map = CreateMap(\"title\":title, \"body\"";
_data = new anywheresoftware.b4a.objects.collections.Map();
_data = anywheresoftware.b4a.keywords.Common.createMap(new Object[] {(Object)("title"),(Object)(_title),(Object)("body"),(Object)(_body),(Object)("d"),(Object)(mostCurrent._b4xpages._mainpage /*gunav2.keymon.com.mx.b4xmainpage*/ (processBA)._usuario /*String*/ ),(Object)("t"),(Object)(_tipo),(Object)("b"),(Object)(mostCurrent._b4xpages._mainpage /*gunav2.keymon.com.mx.b4xmainpage*/ (processBA)._batt /*int*/ ),(Object)("mt"),(Object)(anywheresoftware.b4a.keywords.Common.NumberFormat2((double)(Double.parseDouble(mostCurrent._b4xpages._mainpage /*gunav2.keymon.com.mx.b4xmainpage*/ (processBA)._montoactual /*String*/ )),(int) (0),(int) (2),(int) (2),anywheresoftware.b4a.keywords.Common.False)),(Object)("r"),(Object)(_rutagpscmp),(Object)("v"),(Object)(mostCurrent._b4xpages._mainpage /*gunav2.keymon.com.mx.b4xmainpage*/ (processBA)._v /*String*/ )});
 //BA.debugLineNum = 141;BA.debugLine="m.Put(\"data\", data)";
_m.Put((Object)("data"),(Object)(_data.getObject()));
 //BA.debugLineNum = 142;BA.debugLine="Dim jg As JSONGenerator";
_jg = new anywheresoftware.b4a.objects.collections.JSONParser.JSONGenerator();
 //BA.debugLineNum = 143;BA.debugLine="jg.Initialize(m)";
_jg.Initialize(_m);
 //BA.debugLineNum = 144;BA.debugLine="Job.PostString(\"https://fcm.googleapis.com/fcm/se";
_job._poststring /*String*/ ("https://fcm.googleapis.com/fcm/send",_jg.ToString());
 //BA.debugLineNum = 145;BA.debugLine="Job.GetRequest.SetContentType(\"application/json;c";
_job._getrequest /*anywheresoftware.b4h.okhttp.OkHttpClientWrapper.OkHttpRequest*/ ().SetContentType("application/json;charset=UTF-8");
 //BA.debugLineNum = 146;BA.debugLine="Job.GetRequest.SetHeader(\"Authorization\", \"key=\"";
_job._getrequest /*anywheresoftware.b4h.okhttp.OkHttpClientWrapper.OkHttpRequest*/ ().SetHeader("Authorization","key="+_api_key);
 //BA.debugLineNum = 147;BA.debugLine="Log(m) 'ignore";
anywheresoftware.b4a.keywords.Common.LogImpl("456623126",BA.ObjectToString(_m),0);
 //BA.debugLineNum = 148;BA.debugLine="End Sub";
return "";
}
public static String  _service_create() throws Exception{
 //BA.debugLineNum = 45;BA.debugLine="Sub Service_Create";
 //BA.debugLineNum = 46;BA.debugLine="fm.Initialize(\"fm\") 'Inicializamos FirebaseMessag";
_fm.Initialize(processBA,"fm");
 //BA.debugLineNum = 47;BA.debugLine="pe.Initialize(\"pe\") 'Para obtener la bateria";
_pe.Initialize(processBA,"pe");
 //BA.debugLineNum = 48;BA.debugLine="End Sub";
return "";
}
public static String  _service_destroy() throws Exception{
 //BA.debugLineNum = 121;BA.debugLine="Sub Service_Destroy";
 //BA.debugLineNum = 123;BA.debugLine="End Sub";
return "";
}
public static void  _service_start(anywheresoftware.b4a.objects.IntentWrapper _startingintent) throws Exception{
ResumableSub_Service_Start rsub = new ResumableSub_Service_Start(null,_startingintent);
rsub.resume(processBA, null);
}
public static class ResumableSub_Service_Start extends BA.ResumableSub {
public ResumableSub_Service_Start(gunav2.keymon.com.mx.firebasemessaging parent,anywheresoftware.b4a.objects.IntentWrapper _startingintent) {
this.parent = parent;
this._startingintent = _startingintent;
}
gunav2.keymon.com.mx.firebasemessaging parent;
anywheresoftware.b4a.objects.IntentWrapper _startingintent;

@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 = 66;BA.debugLine="If StartingIntent.IsInitialized Then fm.HandleInt";
if (true) break;

case 1:
//if
this.state = 6;
if (_startingintent.IsInitialized()) { 
this.state = 3;
;}if (true) break;

case 3:
//C
this.state = 6;
parent._fm.HandleIntent((android.content.Intent)(_startingintent.getObject()));
if (true) break;

case 6:
//C
this.state = -1;
;
 //BA.debugLineNum = 67;BA.debugLine="Sleep(0)";
anywheresoftware.b4a.keywords.Common.Sleep(processBA,this,(int) (0));
this.state = 7;
return;
case 7:
//C
this.state = -1;
;
 //BA.debugLineNum = 68;BA.debugLine="Service.StopAutomaticForeground 'remove if not us";
parent.mostCurrent._service.StopAutomaticForeground();
 //BA.debugLineNum = 69;BA.debugLine="StartServiceAt(Me, DateTime.Now + 15 * DateTime.T";
anywheresoftware.b4a.keywords.Common.StartServiceAt(processBA,firebasemessaging.getObject(),(long) (anywheresoftware.b4a.keywords.Common.DateTime.getNow()+15*anywheresoftware.b4a.keywords.Common.DateTime.TicksPerMinute),anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 70;BA.debugLine="End Sub";
if (true) break;

            }
        }
    }
}
public static String  _subscribetotopics() throws Exception{
 //BA.debugLineNum = 50;BA.debugLine="Public Sub SubscribeToTopics";
 //BA.debugLineNum = 52;BA.debugLine="fm.SubscribeToTopic(\"Trckr\") 'Tracker Global";
_fm.SubscribeToTopic("Trckr");
 //BA.debugLineNum = 54;BA.debugLine="fm.SubscribeToTopic(\"Trckr-Cedex\") 'Topico de Gun";
_fm.SubscribeToTopic("Trckr-Cedex");
 //BA.debugLineNum = 55;BA.debugLine="If \"Cdx_\"&B4XPages.MainPage.usuario <> Subscrito";
if (("Cdx_"+mostCurrent._b4xpages._mainpage /*gunav2.keymon.com.mx.b4xmainpage*/ (processBA)._usuario /*String*/ ).equals(_subscrito) == false) { 
 //BA.debugLineNum = 56;BA.debugLine="fm.SubscribeToTopic(\"Cdx_\"&B4XPages.MainPage.usu";
_fm.SubscribeToTopic("Cdx_"+mostCurrent._b4xpages._mainpage /*gunav2.keymon.com.mx.b4xmainpage*/ (processBA)._usuario /*String*/ );
 //BA.debugLineNum = 57;BA.debugLine="fm.UnsubscribeFromTopic(Subscrito) 'Unsubscribe";
_fm.UnsubscribeFromTopic(_subscrito);
 };
 //BA.debugLineNum = 60;BA.debugLine="Subscrito = \"Cdx_\"&B4XPages.MainPage.usuario";
_subscrito = "Cdx_"+mostCurrent._b4xpages._mainpage /*gunav2.keymon.com.mx.b4xmainpage*/ (processBA)._usuario /*String*/ ;
 //BA.debugLineNum = 63;BA.debugLine="End Sub";
return "";
}
}
