package gunav2.keymon.com.mx;


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

public class appupdater extends android.app.Service{
	public static class appupdater_BR extends android.content.BroadcastReceiver {

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

	}
    static appupdater mostCurrent;
	public static BA processBA;
    private ServiceHelper _service;
    public static Class<?> getObject() {
		return appupdater.class;
	}
	@Override
	public void onCreate() {
        super.onCreate();
        mostCurrent = this;
        if (processBA == null) {
		    processBA = new anywheresoftware.b4a.ShellBA(this, null, null, "gunav2.keymon.com.mx", "gunav2.keymon.com.mx.appupdater");
            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.appupdater", processBA, _service, anywheresoftware.b4a.keywords.Common.Density);
		}
        if (!false && ServiceHelper.StarterHelper.startFromServiceCreate(processBA, false) == false) {
				
		}
		else {
            processBA.setActivityPaused(false);
            BA.LogInfo("*** Service (appupdater) 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 (appupdater) 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 (appupdater) 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 (appupdater) Destroy (ignored)**");
        }
        else {
            BA.LogInfo("** Service (appupdater) 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 static class _mnewversion{
public boolean IsInitialized;
public boolean update;
public boolean nonewAPP;
public boolean notifyUser;
public String version;
public String newMsg;
public String okMsg;
public String appLink;
public void Initialize() {
IsInitialized = true;
update = false;
nonewAPP = false;
notifyUser = false;
version = "";
newMsg = "";
okMsg = "";
appLink = "";
}
@Override
		public String toString() {
			return BA.TypeToString(this, false);
		}}
public anywheresoftware.b4a.keywords.Common __c = null;
public static String _lnk = "";
public static anywheresoftware.b4a.objects.NotificationWrapper _nnewapp = null;
public static int _nnewappnid = 0;
public static anywheresoftware.b4j.object.JavaObject _nativeme = null;
public static anywheresoftware.b4a.objects.NotificationWrapper _n2 = null;
public static int _n2id = 0;
public static String _sharedfolder = "";
public static boolean _usefileprovider = false;
public static anywheresoftware.b4a.objects.RuntimePermissions _rp = null;
public static gunav2.keymon.com.mx.appupdater._mnewversion _newapp = null;
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.tracker _tracker = null;
public gunav2.keymon.com.mx.firebasemessaging _firebasemessaging = null;
public gunav2.keymon.com.mx.mapa_rutas _mapa_rutas = 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 anywheresoftware.b4a.objects.NotificationWrapper  _createnotification(String _title,String _content,String _icon,Object _targetactivity,boolean _sound,boolean _vibrate) throws Exception{
RDebugUtils.currentModule="appupdater";
if (Debug.shouldDelegate(processBA, "createnotification", false))
	 {return ((anywheresoftware.b4a.objects.NotificationWrapper) Debug.delegate(processBA, "createnotification", new Object[] {_title,_content,_icon,_targetactivity,_sound,_vibrate}));}
RDebugUtils.currentLine=70320128;
 //BA.debugLineNum = 70320128;BA.debugLine="Private Sub CreateNotification(Title As String, Co";
RDebugUtils.currentLine=70320129;
 //BA.debugLineNum = 70320129;BA.debugLine="n2.Initialize";
_n2.Initialize();
RDebugUtils.currentLine=70320130;
 //BA.debugLineNum = 70320130;BA.debugLine="n2.Light = False";
_n2.setLight(anywheresoftware.b4a.keywords.Common.False);
RDebugUtils.currentLine=70320131;
 //BA.debugLineNum = 70320131;BA.debugLine="n2.Vibrate = Vibrate";
_n2.setVibrate(_vibrate);
RDebugUtils.currentLine=70320132;
 //BA.debugLineNum = 70320132;BA.debugLine="n2.Sound = Sound";
_n2.setSound(_sound);
RDebugUtils.currentLine=70320133;
 //BA.debugLineNum = 70320133;BA.debugLine="n2.OnGoingEvent = True";
_n2.setOnGoingEvent(anywheresoftware.b4a.keywords.Common.True);
RDebugUtils.currentLine=70320134;
 //BA.debugLineNum = 70320134;BA.debugLine="n2.Icon = Icon";
_n2.setIcon(_icon);
RDebugUtils.currentLine=70320135;
 //BA.debugLineNum = 70320135;BA.debugLine="n2.SetInfo(Title, Content, TargetActivity)";
_n2.SetInfoNew(processBA,BA.ObjectToCharSequence(_title),BA.ObjectToCharSequence(_content),_targetactivity);
RDebugUtils.currentLine=70320136;
 //BA.debugLineNum = 70320136;BA.debugLine="n2.Notify(nNewAppnID)";
_n2.Notify(_nnewappnid);
RDebugUtils.currentLine=70320137;
 //BA.debugLineNum = 70320137;BA.debugLine="End Sub";
return null;
}
public static anywheresoftware.b4a.objects.NotificationWrapper  _createnotification2(String _title,String _content,String _icon,Object _targetactivity,boolean _sound,boolean _vibrate,anywheresoftware.b4a.objects.NotificationWrapper _pn,int _pnid) throws Exception{
RDebugUtils.currentModule="appupdater";
if (Debug.shouldDelegate(processBA, "createnotification2", false))
	 {return ((anywheresoftware.b4a.objects.NotificationWrapper) Debug.delegate(processBA, "createnotification2", new Object[] {_title,_content,_icon,_targetactivity,_sound,_vibrate,_pn,_pnid}));}
RDebugUtils.currentLine=70254592;
 //BA.debugLineNum = 70254592;BA.debugLine="Private Sub CreateNotification2(Title As String, C";
RDebugUtils.currentLine=70254595;
 //BA.debugLineNum = 70254595;BA.debugLine="pN.Initialize2(pN.IMPORTANCE_HIGH)";
_pn.Initialize2(_pn.IMPORTANCE_HIGH);
RDebugUtils.currentLine=70254598;
 //BA.debugLineNum = 70254598;BA.debugLine="pN.Vibrate = Vibrate";
_pn.setVibrate(_vibrate);
RDebugUtils.currentLine=70254599;
 //BA.debugLineNum = 70254599;BA.debugLine="pN.Sound = Sound";
_pn.setSound(_sound);
RDebugUtils.currentLine=70254601;
 //BA.debugLineNum = 70254601;BA.debugLine="pN.Icon = Icon";
_pn.setIcon(_icon);
RDebugUtils.currentLine=70254602;
 //BA.debugLineNum = 70254602;BA.debugLine="pN.AutoCancel = True";
_pn.setAutoCancel(anywheresoftware.b4a.keywords.Common.True);
RDebugUtils.currentLine=70254603;
 //BA.debugLineNum = 70254603;BA.debugLine="pN.SetInfo(Title, Content, TargetActivity)";
_pn.SetInfoNew(processBA,BA.ObjectToCharSequence(_title),BA.ObjectToCharSequence(_content),_targetactivity);
RDebugUtils.currentLine=70254604;
 //BA.debugLineNum = 70254604;BA.debugLine="pN.Notify(pNID)";
_pn.Notify(_pnid);
RDebugUtils.currentLine=70254605;
 //BA.debugLineNum = 70254605;BA.debugLine="Return pN";
if (true) return _pn;
RDebugUtils.currentLine=70254606;
 //BA.debugLineNum = 70254606;BA.debugLine="End Sub";
return null;
}
public static gunav2.keymon.com.mx.httpjob  _download(Object _callback,String _link) throws Exception{
RDebugUtils.currentModule="appupdater";
if (Debug.shouldDelegate(processBA, "download", false))
	 {return ((gunav2.keymon.com.mx.httpjob) Debug.delegate(processBA, "download", new Object[] {_callback,_link}));}
gunav2.keymon.com.mx.httpjob _j = null;
RDebugUtils.currentLine=70189056;
 //BA.debugLineNum = 70189056;BA.debugLine="Sub Download (Callback As Object, link As String)";
RDebugUtils.currentLine=70189057;
 //BA.debugLineNum = 70189057;BA.debugLine="Dim j As HttpJob";
_j = new gunav2.keymon.com.mx.httpjob();
RDebugUtils.currentLine=70189058;
 //BA.debugLineNum = 70189058;BA.debugLine="j.Initialize(\"\", Callback)";
_j._initialize /*String*/ (null,processBA,"",_callback);
RDebugUtils.currentLine=70189059;
 //BA.debugLineNum = 70189059;BA.debugLine="j.Download(link)";
_j._download /*String*/ (null,_link);
RDebugUtils.currentLine=70189060;
 //BA.debugLineNum = 70189060;BA.debugLine="Return j";
if (true) return _j;
RDebugUtils.currentLine=70189061;
 //BA.debugLineNum = 70189061;BA.debugLine="End Sub";
return null;
}
public static String  _download_destroy() throws Exception{
RDebugUtils.currentModule="appupdater";
if (Debug.shouldDelegate(processBA, "download_destroy", false))
	 {return ((String) Debug.delegate(processBA, "download_destroy", null));}
RDebugUtils.currentLine=70123520;
 //BA.debugLineNum = 70123520;BA.debugLine="Sub download_Destroy";
RDebugUtils.currentLine=70123521;
 //BA.debugLineNum = 70123521;BA.debugLine="n2.Cancel(n2ID)";
_n2.Cancel(_n2id);
RDebugUtils.currentLine=70123522;
 //BA.debugLineNum = 70123522;BA.debugLine="Service.StopForeground(n2ID)";
mostCurrent._service.StopForeground(_n2id);
RDebugUtils.currentLine=70123523;
 //BA.debugLineNum = 70123523;BA.debugLine="End Sub";
return "";
}
public static void  _download_newapk() throws Exception{
RDebugUtils.currentModule="appupdater";
if (Debug.shouldDelegate(processBA, "download_newapk", false))
	 {Debug.delegate(processBA, "download_newapk", null); return;}
ResumableSub_download_newApk rsub = new ResumableSub_download_newApk(null);
rsub.resume(processBA, null);
}
public static class ResumableSub_download_newApk extends BA.ResumableSub {
public ResumableSub_download_newApk(gunav2.keymon.com.mx.appupdater parent) {
this.parent = parent;
}
gunav2.keymon.com.mx.appupdater parent;
gunav2.keymon.com.mx.httpjob _job_newapp = null;
boolean _downladsuccess = false;
anywheresoftware.b4a.objects.streams.File.OutputStreamWrapper _outnewapk = null;
anywheresoftware.b4a.objects.IntentWrapper _in = null;

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

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

case 0:
//C
this.state = 1;
RDebugUtils.currentLine=70057987;
 //BA.debugLineNum = 70057987;BA.debugLine="Log(\"Descargando actualización\")";
anywheresoftware.b4a.keywords.Common.LogImpl("070057987","Descargando actualización",0);
RDebugUtils.currentLine=70057989;
 //BA.debugLineNum = 70057989;BA.debugLine="Starter.muestraProgreso = 1";
parent.mostCurrent._starter._muestraprogreso /*String*/  = BA.NumberToString(1);
RDebugUtils.currentLine=70057990;
 //BA.debugLineNum = 70057990;BA.debugLine="B4XPages.MainPage.muestraProgreso(\"Descargando nu";
parent.mostCurrent._b4xpages._mainpage /*gunav2.keymon.com.mx.b4xmainpage*/ (processBA)._muestraprogreso /*String*/ (null,"Descargando nueva versión, un momento por favor.");
RDebugUtils.currentLine=70057991;
 //BA.debugLineNum = 70057991;BA.debugLine="Dim job_newAPP As HttpJob";
_job_newapp = new gunav2.keymon.com.mx.httpjob();
RDebugUtils.currentLine=70057992;
 //BA.debugLineNum = 70057992;BA.debugLine="If job_newAPP.IsInitialized Then job_newAPP.Relea";
if (true) break;

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

case 3:
//C
this.state = 6;
_job_newapp._release /*String*/ (null);
if (true) break;

case 6:
//C
this.state = 7;
;
RDebugUtils.currentLine=70057993;
 //BA.debugLineNum = 70057993;BA.debugLine="Log(\">>>>  LOGIN LINK2: \" & Starter.nuevoLink)";
anywheresoftware.b4a.keywords.Common.LogImpl("070057993",">>>>  LOGIN LINK2: "+parent.mostCurrent._starter._nuevolink /*String*/ ,0);
RDebugUtils.currentLine=70057994;
 //BA.debugLineNum = 70057994;BA.debugLine="If Starter.nuevoLink <> \"\" Then newApp.appLink =";
if (true) break;

case 7:
//if
this.state = 12;
if ((parent.mostCurrent._starter._nuevolink /*String*/ ).equals("") == false) { 
this.state = 9;
;}if (true) break;

case 9:
//C
this.state = 12;
parent._newapp.appLink /*String*/  = parent.mostCurrent._starter._nuevolink /*String*/ ;
if (true) break;

case 12:
//C
this.state = 13;
;
RDebugUtils.currentLine=70057995;
 //BA.debugLineNum = 70057995;BA.debugLine="job_newAPP.Initialize(\"job_newAPP\",Me)";
_job_newapp._initialize /*String*/ (null,processBA,"job_newAPP",appupdater.getObject());
RDebugUtils.currentLine=70057996;
 //BA.debugLineNum = 70057996;BA.debugLine="Log(newApp.appLink & \"?dummy=\" & DateTime.Now)";
anywheresoftware.b4a.keywords.Common.LogImpl("070057996",parent._newapp.appLink /*String*/ +"?dummy="+BA.NumberToString(anywheresoftware.b4a.keywords.Common.DateTime.getNow()),0);
RDebugUtils.currentLine=70057997;
 //BA.debugLineNum = 70057997;BA.debugLine="job_newAPP.Download(newApp.appLink & \"?dummy=\" &";
_job_newapp._download /*String*/ (null,parent._newapp.appLink /*String*/ +"?dummy="+BA.NumberToString(anywheresoftware.b4a.keywords.Common.DateTime.getNow()));
RDebugUtils.currentLine=70057998;
 //BA.debugLineNum = 70057998;BA.debugLine="Log(\"Vamos a descargar: \" & newApp.appLink & \"?du";
anywheresoftware.b4a.keywords.Common.LogImpl("070057998","Vamos a descargar: "+parent._newapp.appLink /*String*/ +"?dummy="+BA.NumberToString(anywheresoftware.b4a.keywords.Common.DateTime.getNow()),0);
RDebugUtils.currentLine=70057999;
 //BA.debugLineNum = 70057999;BA.debugLine="Wait for (job_newAPP) JobDone (job_newAPP As Http";
anywheresoftware.b4a.keywords.Common.WaitFor("jobdone", processBA, new anywheresoftware.b4a.shell.DebugResumableSub.DelegatableResumableSub(this, "appupdater", "download_newapk"), (Object)(_job_newapp));
this.state = 27;
return;
case 27:
//C
this.state = 13;
_job_newapp = (gunav2.keymon.com.mx.httpjob) result[0];
;
RDebugUtils.currentLine=70058000;
 //BA.debugLineNum = 70058000;BA.debugLine="Private downladSuccess As Boolean = False";
_downladsuccess = anywheresoftware.b4a.keywords.Common.False;
RDebugUtils.currentLine=70058001;
 //BA.debugLineNum = 70058001;BA.debugLine="If job_newAPP.Success = True Then";
if (true) break;

case 13:
//if
this.state = 20;
if (_job_newapp._success /*boolean*/ ==anywheresoftware.b4a.keywords.Common.True) { 
this.state = 15;
}if (true) break;

case 15:
//C
this.state = 16;
RDebugUtils.currentLine=70058003;
 //BA.debugLineNum = 70058003;BA.debugLine="downladSuccess = True";
_downladsuccess = anywheresoftware.b4a.keywords.Common.True;
RDebugUtils.currentLine=70058004;
 //BA.debugLineNum = 70058004;BA.debugLine="If File.Exists(SharedFolder,\"newapp.apk\") Then";
if (true) break;

case 16:
//if
this.state = 19;
if (anywheresoftware.b4a.keywords.Common.File.Exists(parent._sharedfolder,"newapp.apk")) { 
this.state = 18;
}if (true) break;

case 18:
//C
this.state = 19;
RDebugUtils.currentLine=70058006;
 //BA.debugLineNum = 70058006;BA.debugLine="File.Delete(SharedFolder,\"newapp.apk\")";
anywheresoftware.b4a.keywords.Common.File.Delete(parent._sharedfolder,"newapp.apk");
 if (true) break;

case 19:
//C
this.state = 20;
;
RDebugUtils.currentLine=70058009;
 //BA.debugLineNum = 70058009;BA.debugLine="Dim outNewAPK As OutputStream = File.OpenOutput(";
_outnewapk = new anywheresoftware.b4a.objects.streams.File.OutputStreamWrapper();
_outnewapk = anywheresoftware.b4a.keywords.Common.File.OpenOutput(parent._sharedfolder,"newapp.apk",anywheresoftware.b4a.keywords.Common.False);
RDebugUtils.currentLine=70058010;
 //BA.debugLineNum = 70058010;BA.debugLine="File.Copy2(job_newAPP.GetInputStream, outNewAPK)";
anywheresoftware.b4a.keywords.Common.File.Copy2((java.io.InputStream)(_job_newapp._getinputstream /*anywheresoftware.b4a.objects.streams.File.InputStreamWrapper*/ (null).getObject()),(java.io.OutputStream)(_outnewapk.getObject()));
RDebugUtils.currentLine=70058011;
 //BA.debugLineNum = 70058011;BA.debugLine="outNewAPK.Close";
_outnewapk.Close();
RDebugUtils.currentLine=70058012;
 //BA.debugLineNum = 70058012;BA.debugLine="Log(\"APK dir: \"&SharedFolder)";
anywheresoftware.b4a.keywords.Common.LogImpl("070058012","APK dir: "+parent._sharedfolder,0);
 if (true) break;

case 20:
//C
this.state = 21;
;
RDebugUtils.currentLine=70058014;
 //BA.debugLineNum = 70058014;BA.debugLine="job_newAPP.Release";
_job_newapp._release /*String*/ (null);
RDebugUtils.currentLine=70058015;
 //BA.debugLineNum = 70058015;BA.debugLine="n2.Cancel(nNewAppnID)";
parent._n2.Cancel(parent._nnewappnid);
RDebugUtils.currentLine=70058016;
 //BA.debugLineNum = 70058016;BA.debugLine="B4XPages.MainPage.ocultaProgreso";
parent.mostCurrent._b4xpages._mainpage /*gunav2.keymon.com.mx.b4xmainpage*/ (processBA)._ocultaprogreso /*String*/ (null);
RDebugUtils.currentLine=70058017;
 //BA.debugLineNum = 70058017;BA.debugLine="If downladSuccess Then";
if (true) break;

case 21:
//if
this.state = 26;
if (_downladsuccess) { 
this.state = 23;
}else {
this.state = 25;
}if (true) break;

case 23:
//C
this.state = 26;
RDebugUtils.currentLine=70058019;
 //BA.debugLineNum = 70058019;BA.debugLine="Dim in As Intent";
_in = new anywheresoftware.b4a.objects.IntentWrapper();
RDebugUtils.currentLine=70058020;
 //BA.debugLineNum = 70058020;BA.debugLine="in.Initialize(in.ACTION_VIEW,\"\" )";
_in.Initialize(_in.ACTION_VIEW,"");
RDebugUtils.currentLine=70058021;
 //BA.debugLineNum = 70058021;BA.debugLine="SetFileUriAsIntentData(in, \"newapp.apk\")";
_setfileuriasintentdata(_in,"newapp.apk");
RDebugUtils.currentLine=70058023;
 //BA.debugLineNum = 70058023;BA.debugLine="in.SetType(\"application/vnd.android.package-arch";
_in.SetType("application/vnd.android.package-archive");
RDebugUtils.currentLine=70058024;
 //BA.debugLineNum = 70058024;BA.debugLine="StartActivity(in)";
anywheresoftware.b4a.keywords.Common.StartActivity(processBA,(Object)(_in.getObject()));
 if (true) break;

case 25:
//C
this.state = 26;
RDebugUtils.currentLine=70058026;
 //BA.debugLineNum = 70058026;BA.debugLine="B4XPages.MainPage.principal.l_forzarActualizacio";
parent.mostCurrent._b4xpages._mainpage /*gunav2.keymon.com.mx.b4xmainpage*/ (processBA)._principal /*gunav2.keymon.com.mx.c_principal*/ ._l_forzaractualizacion /*anywheresoftware.b4a.objects.LabelWrapper*/ .setTextColor(anywheresoftware.b4a.keywords.Common.Colors.Red);
RDebugUtils.currentLine=70058027;
 //BA.debugLineNum = 70058027;BA.debugLine="B4XPages.MainPage.principal.l_forzarActualizacio";
parent.mostCurrent._b4xpages._mainpage /*gunav2.keymon.com.mx.b4xmainpage*/ (processBA)._principal /*gunav2.keymon.com.mx.c_principal*/ ._l_forzaractualizacion /*anywheresoftware.b4a.objects.LabelWrapper*/ .setText(BA.ObjectToCharSequence("Hubo un error en la descarga, por favor revise que tenga conexion a internet e intente de nuevo."));
RDebugUtils.currentLine=70058028;
 //BA.debugLineNum = 70058028;BA.debugLine="Log(\"ERROR EN CONEXION\")";
anywheresoftware.b4a.keywords.Common.LogImpl("070058028","ERROR EN CONEXION",0);
RDebugUtils.currentLine=70058029;
 //BA.debugLineNum = 70058029;BA.debugLine="Sleep(5000)";
anywheresoftware.b4a.keywords.Common.Sleep(processBA,new anywheresoftware.b4a.shell.DebugResumableSub.DelegatableResumableSub(this, "appupdater", "download_newapk"),(int) (5000));
this.state = 28;
return;
case 28:
//C
this.state = 26;
;
RDebugUtils.currentLine=70058030;
 //BA.debugLineNum = 70058030;BA.debugLine="ExitApplication";
anywheresoftware.b4a.keywords.Common.ExitApplication();
 if (true) break;

case 26:
//C
this.state = -1;
;
RDebugUtils.currentLine=70058032;
 //BA.debugLineNum = 70058032;BA.debugLine="Starter.muestraProgreso = 0";
parent.mostCurrent._starter._muestraprogreso /*String*/  = BA.NumberToString(0);
RDebugUtils.currentLine=70058033;
 //BA.debugLineNum = 70058033;BA.debugLine="B4XPages.MainPage.principal.p_transparenteActuali";
parent.mostCurrent._b4xpages._mainpage /*gunav2.keymon.com.mx.b4xmainpage*/ (processBA)._principal /*gunav2.keymon.com.mx.c_principal*/ ._p_transparenteactualizacion /*anywheresoftware.b4a.objects.PanelWrapper*/ .setVisible(anywheresoftware.b4a.keywords.Common.False);
RDebugUtils.currentLine=70058035;
 //BA.debugLineNum = 70058035;BA.debugLine="StopService(Me)";
anywheresoftware.b4a.keywords.Common.StopService(processBA,appupdater.getObject());
RDebugUtils.currentLine=70058037;
 //BA.debugLineNum = 70058037;BA.debugLine="End Sub";
if (true) break;

            }
        }
    }
}
public static String  _setfileuriasintentdata(anywheresoftware.b4a.objects.IntentWrapper _intent,String _filename) throws Exception{
RDebugUtils.currentModule="appupdater";
if (Debug.shouldDelegate(processBA, "setfileuriasintentdata", false))
	 {return ((String) Debug.delegate(processBA, "setfileuriasintentdata", new Object[] {_intent,_filename}));}
anywheresoftware.b4j.object.JavaObject _jo = null;
RDebugUtils.currentLine=70582272;
 //BA.debugLineNum = 70582272;BA.debugLine="Sub SetFileUriAsIntentData (Intent As Intent, File";
RDebugUtils.currentLine=70582273;
 //BA.debugLineNum = 70582273;BA.debugLine="Dim jo As JavaObject = Intent";
_jo = new anywheresoftware.b4j.object.JavaObject();
_jo = (anywheresoftware.b4j.object.JavaObject) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4j.object.JavaObject(), (java.lang.Object)(_intent.getObject()));
RDebugUtils.currentLine=70582274;
 //BA.debugLineNum = 70582274;BA.debugLine="jo.RunMethod(\"setData\", Array(GetFileUri(FileName";
_jo.RunMethod("setData",new Object[]{_getfileuri(_filename)});
RDebugUtils.currentLine=70582275;
 //BA.debugLineNum = 70582275;BA.debugLine="Intent.Flags = Bit.Or(Intent.Flags, 1) 'FLAG_GRAN";
_intent.setFlags(anywheresoftware.b4a.keywords.Common.Bit.Or(_intent.getFlags(),(int) (1)));
RDebugUtils.currentLine=70582276;
 //BA.debugLineNum = 70582276;BA.debugLine="End Sub";
return "";
}
public static String  _download_start(anywheresoftware.b4a.objects.IntentWrapper _startingintent) throws Exception{
RDebugUtils.currentModule="appupdater";
if (Debug.shouldDelegate(processBA, "download_start", false))
	 {return ((String) Debug.delegate(processBA, "download_start", new Object[] {_startingintent}));}
RDebugUtils.currentLine=69992448;
 //BA.debugLineNum = 69992448;BA.debugLine="Sub download_Start (StartingIntent As Intent)";
RDebugUtils.currentLine=69992449;
 //BA.debugLineNum = 69992449;BA.debugLine="download_newApk";
_download_newapk();
RDebugUtils.currentLine=69992450;
 //BA.debugLineNum = 69992450;BA.debugLine="End Sub";
return "";
}
public static String  _fileprovider_init() throws Exception{
RDebugUtils.currentModule="appupdater";
if (Debug.shouldDelegate(processBA, "fileprovider_init", false))
	 {return ((String) Debug.delegate(processBA, "fileprovider_init", null));}
anywheresoftware.b4a.phone.Phone _p = null;
RDebugUtils.currentLine=70451200;
 //BA.debugLineNum = 70451200;BA.debugLine="Sub fileProvider_init";
RDebugUtils.currentLine=70451201;
 //BA.debugLineNum = 70451201;BA.debugLine="Dim p As Phone";
_p = new anywheresoftware.b4a.phone.Phone();
RDebugUtils.currentLine=70451202;
 //BA.debugLineNum = 70451202;BA.debugLine="If p.SdkVersion >= 24 Or File.ExternalWritable =";
if (_p.getSdkVersion()>=24 || anywheresoftware.b4a.keywords.Common.File.getExternalWritable()==anywheresoftware.b4a.keywords.Common.False) { 
RDebugUtils.currentLine=70451203;
 //BA.debugLineNum = 70451203;BA.debugLine="UseFileProvider = True";
_usefileprovider = anywheresoftware.b4a.keywords.Common.True;
RDebugUtils.currentLine=70451204;
 //BA.debugLineNum = 70451204;BA.debugLine="SharedFolder = File.Combine(File.DirInternal, \"s";
_sharedfolder = anywheresoftware.b4a.keywords.Common.File.Combine(anywheresoftware.b4a.keywords.Common.File.getDirInternal(),"shared");
RDebugUtils.currentLine=70451205;
 //BA.debugLineNum = 70451205;BA.debugLine="If Not(File.IsDirectory(File.DirInternal,\"shared";
if (anywheresoftware.b4a.keywords.Common.Not(anywheresoftware.b4a.keywords.Common.File.IsDirectory(anywheresoftware.b4a.keywords.Common.File.getDirInternal(),"shared"))) { 
RDebugUtils.currentLine=70451206;
 //BA.debugLineNum = 70451206;BA.debugLine="File.MakeDir(\"\", SharedFolder)";
anywheresoftware.b4a.keywords.Common.File.MakeDir("",_sharedfolder);
 };
 }else {
RDebugUtils.currentLine=70451209;
 //BA.debugLineNum = 70451209;BA.debugLine="UseFileProvider = False";
_usefileprovider = anywheresoftware.b4a.keywords.Common.False;
RDebugUtils.currentLine=70451210;
 //BA.debugLineNum = 70451210;BA.debugLine="SharedFolder = rp.GetSafeDirDefaultExternal(\"sha";
_sharedfolder = _rp.GetSafeDirDefaultExternal("shared");
 };
RDebugUtils.currentLine=70451212;
 //BA.debugLineNum = 70451212;BA.debugLine="Log($\"Using FileProvider? ${UseFileProvider}\"$)";
anywheresoftware.b4a.keywords.Common.LogImpl("070451212",("Using FileProvider? "+anywheresoftware.b4a.keywords.Common.SmartStringFormatter("",(Object)(_usefileprovider))+""),0);
RDebugUtils.currentLine=70451213;
 //BA.debugLineNum = 70451213;BA.debugLine="End Sub";
return "";
}
public static Object  _getfileuri(String _filename) throws Exception{
RDebugUtils.currentModule="appupdater";
if (Debug.shouldDelegate(processBA, "getfileuri", false))
	 {return ((Object) Debug.delegate(processBA, "getfileuri", new Object[] {_filename}));}
anywheresoftware.b4j.object.JavaObject _uri = null;
anywheresoftware.b4j.object.JavaObject _f = null;
anywheresoftware.b4j.object.JavaObject _fp = null;
anywheresoftware.b4j.object.JavaObject _context = null;
RDebugUtils.currentLine=70516736;
 //BA.debugLineNum = 70516736;BA.debugLine="Sub GetFileUri (FileName As String) As Object";
RDebugUtils.currentLine=70516737;
 //BA.debugLineNum = 70516737;BA.debugLine="Try";
try {RDebugUtils.currentLine=70516738;
 //BA.debugLineNum = 70516738;BA.debugLine="If Not(UseFileProvider) Then";
if (anywheresoftware.b4a.keywords.Common.Not(_usefileprovider)) { 
RDebugUtils.currentLine=70516739;
 //BA.debugLineNum = 70516739;BA.debugLine="Dim uri As JavaObject";
_uri = new anywheresoftware.b4j.object.JavaObject();
RDebugUtils.currentLine=70516740;
 //BA.debugLineNum = 70516740;BA.debugLine="Return uri.InitializeStatic(\"android.net.Uri\").";
if (true) return _uri.InitializeStatic("android.net.Uri").RunMethod("parse",new Object[]{(Object)("file://"+anywheresoftware.b4a.keywords.Common.File.Combine(_sharedfolder,_filename))});
 };
RDebugUtils.currentLine=70516742;
 //BA.debugLineNum = 70516742;BA.debugLine="Dim f As JavaObject";
_f = new anywheresoftware.b4j.object.JavaObject();
RDebugUtils.currentLine=70516743;
 //BA.debugLineNum = 70516743;BA.debugLine="f.InitializeNewInstance(\"java.io.File\", Array(Sh";
_f.InitializeNewInstance("java.io.File",new Object[]{(Object)(_sharedfolder),(Object)(_filename)});
RDebugUtils.currentLine=70516744;
 //BA.debugLineNum = 70516744;BA.debugLine="Dim fp As JavaObject";
_fp = new anywheresoftware.b4j.object.JavaObject();
RDebugUtils.currentLine=70516745;
 //BA.debugLineNum = 70516745;BA.debugLine="Dim context As JavaObject";
_context = new anywheresoftware.b4j.object.JavaObject();
RDebugUtils.currentLine=70516746;
 //BA.debugLineNum = 70516746;BA.debugLine="context.InitializeContext";
_context.InitializeContext(processBA);
RDebugUtils.currentLine=70516747;
 //BA.debugLineNum = 70516747;BA.debugLine="fp.InitializeStatic(\"android.support.v4.content.";
_fp.InitializeStatic("androidx.core.content.FileProvider");
RDebugUtils.currentLine=70516748;
 //BA.debugLineNum = 70516748;BA.debugLine="Return fp.RunMethod(\"getUriForFile\", Array(conte";
if (true) return _fp.RunMethod("getUriForFile",new Object[]{(Object)(_context.getObject()),(Object)(anywheresoftware.b4a.keywords.Common.Application.getPackageName()+".provider"),(Object)(_f.getObject())});
 } 
       catch (Exception e14) {
			processBA.setLastException(e14);RDebugUtils.currentLine=70516750;
 //BA.debugLineNum = 70516750;BA.debugLine="Log(\"FileProvider::GetFileUri - error - \" & Last";
anywheresoftware.b4a.keywords.Common.LogImpl("070516750","FileProvider::GetFileUri - error - "+anywheresoftware.b4a.keywords.Common.LastException(processBA).getMessage(),0);
RDebugUtils.currentLine=70516751;
 //BA.debugLineNum = 70516751;BA.debugLine="Return \"\"";
if (true) return (Object)("");
 };
RDebugUtils.currentLine=70516753;
 //BA.debugLineNum = 70516753;BA.debugLine="End Sub";
return null;
}
public static String  _service_create() throws Exception{
RDebugUtils.currentModule="appupdater";
if (Debug.shouldDelegate(processBA, "service_create", false))
	 {return ((String) Debug.delegate(processBA, "service_create", null));}
RDebugUtils.currentLine=69861376;
 //BA.debugLineNum = 69861376;BA.debugLine="Sub Service_Create";
RDebugUtils.currentLine=69861377;
 //BA.debugLineNum = 69861377;BA.debugLine="Log(\"appUpdater(), Service_Create\")";
anywheresoftware.b4a.keywords.Common.LogImpl("069861377","appUpdater(), Service_Create",0);
RDebugUtils.currentLine=69861378;
 //BA.debugLineNum = 69861378;BA.debugLine="newApp.Initialize";
_newapp.Initialize();
RDebugUtils.currentLine=69861379;
 //BA.debugLineNum = 69861379;BA.debugLine="Service.AutomaticForegroundMode = Service.AUTOMAT";
mostCurrent._service.AutomaticForegroundMode = mostCurrent._service.AUTOMATIC_FOREGROUND_NEVER;
RDebugUtils.currentLine=69861380;
 //BA.debugLineNum = 69861380;BA.debugLine="n2.Initialize";
_n2.Initialize();
RDebugUtils.currentLine=69861381;
 //BA.debugLineNum = 69861381;BA.debugLine="nativeMe.InitializeContext";
_nativeme.InitializeContext(processBA);
RDebugUtils.currentLine=69861382;
 //BA.debugLineNum = 69861382;BA.debugLine="End Sub";
return "";
}
public static String  _service_destroy() throws Exception{
RDebugUtils.currentModule="appupdater";
if (Debug.shouldDelegate(processBA, "service_destroy", false))
	 {return ((String) Debug.delegate(processBA, "service_destroy", null));}
RDebugUtils.currentLine=70385664;
 //BA.debugLineNum = 70385664;BA.debugLine="Sub Service_Destroy";
RDebugUtils.currentLine=70385665;
 //BA.debugLineNum = 70385665;BA.debugLine="Log(\"appUpdater(), Service_Destroy\")";
anywheresoftware.b4a.keywords.Common.LogImpl("070385665","appUpdater(), Service_Destroy",0);
RDebugUtils.currentLine=70385666;
 //BA.debugLineNum = 70385666;BA.debugLine="End Sub";
return "";
}
public static void  _service_start(anywheresoftware.b4a.objects.IntentWrapper _startingintent) throws Exception{
RDebugUtils.currentModule="appupdater";
if (Debug.shouldDelegate(processBA, "service_start", false))
	 {Debug.delegate(processBA, "service_start", new Object[] {_startingintent}); return;}
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.appupdater parent,anywheresoftware.b4a.objects.IntentWrapper _startingintent) {
this.parent = parent;
this._startingintent = _startingintent;
}
gunav2.keymon.com.mx.appupdater parent;
anywheresoftware.b4a.objects.IntentWrapper _startingintent;
gunav2.keymon.com.mx.httpjob _j = null;
String[] _app = null;

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

    while (true) {
try {

        switch (state) {
            case -1:
return;

case 0:
//C
this.state = 1;
RDebugUtils.currentLine=69926913;
 //BA.debugLineNum = 69926913;BA.debugLine="Log(\"appUpdater(), Service_Start\")";
anywheresoftware.b4a.keywords.Common.LogImpl("069926913","appUpdater(), Service_Start",0);
RDebugUtils.currentLine=69926915;
 //BA.debugLineNum = 69926915;BA.debugLine="B4XPages.MainPage.muestraProgreso(\"Buscando actua";
parent.mostCurrent._b4xpages._mainpage /*gunav2.keymon.com.mx.b4xmainpage*/ (processBA)._muestraprogreso /*String*/ (null,"Buscando actualizaciones, un momento por favor.");
RDebugUtils.currentLine=69926916;
 //BA.debugLineNum = 69926916;BA.debugLine="Log(\"Buscando actualización\")";
anywheresoftware.b4a.keywords.Common.LogImpl("069926916","Buscando actualización",0);
RDebugUtils.currentLine=69926917;
 //BA.debugLineNum = 69926917;BA.debugLine="fileProvider_init";
_fileprovider_init();
RDebugUtils.currentLine=69926918;
 //BA.debugLineNum = 69926918;BA.debugLine="Wait For (Download(Me, lnk)) JobDone (j As HttpJo";
anywheresoftware.b4a.keywords.Common.WaitFor("jobdone", processBA, new anywheresoftware.b4a.shell.DebugResumableSub.DelegatableResumableSub(this, "appupdater", "service_start"), (Object)(_download(appupdater.getObject(),parent._lnk)));
this.state = 20;
return;
case 20:
//C
this.state = 1;
_j = (gunav2.keymon.com.mx.httpjob) result[0];
;
RDebugUtils.currentLine=69926919;
 //BA.debugLineNum = 69926919;BA.debugLine="If j.Success Then";
if (true) break;

case 1:
//if
this.state = 19;
if (_j._success /*boolean*/ ) { 
this.state = 3;
}else {
this.state = 18;
}if (true) break;

case 3:
//C
this.state = 4;
RDebugUtils.currentLine=69926920;
 //BA.debugLineNum = 69926920;BA.debugLine="Try";
if (true) break;

case 4:
//try
this.state = 16;
this.catchState = 15;
this.state = 6;
if (true) break;

case 6:
//C
this.state = 7;
this.catchState = 15;
RDebugUtils.currentLine=69926921;
 //BA.debugLineNum = 69926921;BA.debugLine="Dim app() As String = Regex.Split(Chr(9),j.GetS";
_app = anywheresoftware.b4a.keywords.Common.Regex.Split(BA.ObjectToString(anywheresoftware.b4a.keywords.Common.Chr((int) (9))),_j._getstring /*String*/ (null));
RDebugUtils.currentLine=69926923;
 //BA.debugLineNum = 69926923;BA.debugLine="newApp.appLink = app(3)	'Liga a nueva app";
parent._newapp.appLink /*String*/  = _app[(int) (3)];
RDebugUtils.currentLine=69926924;
 //BA.debugLineNum = 69926924;BA.debugLine="newApp.newMsg = app(1)	'Texto de que hay actual";
parent._newapp.newMsg /*String*/  = _app[(int) (1)];
RDebugUtils.currentLine=69926925;
 //BA.debugLineNum = 69926925;BA.debugLine="newApp.okMsg = app(2)	'Texto de app al corrient";
parent._newapp.okMsg /*String*/  = _app[(int) (2)];
RDebugUtils.currentLine=69926926;
 //BA.debugLineNum = 69926926;BA.debugLine="newApp.version = app(0)	'Version actual";
parent._newapp.version /*String*/  = _app[(int) (0)];
RDebugUtils.currentLine=69926928;
 //BA.debugLineNum = 69926928;BA.debugLine="Log($\"Application.VersionName=${Application.Ver";
anywheresoftware.b4a.keywords.Common.LogImpl("069926928",("Application.VersionName="+anywheresoftware.b4a.keywords.Common.SmartStringFormatter("",(Object)(anywheresoftware.b4a.keywords.Common.Application.getVersionName()))+", newApp="+anywheresoftware.b4a.keywords.Common.SmartStringFormatter("",(Object)(parent._newapp))+""),0);
RDebugUtils.currentLine=69926931;
 //BA.debugLineNum = 69926931;BA.debugLine="If newApp.version = Application.VersionName  Th";
if (true) break;

case 7:
//if
this.state = 10;
if ((parent._newapp.version /*String*/ ).equals(anywheresoftware.b4a.keywords.Common.Application.getVersionName())) { 
this.state = 9;
}if (true) break;

case 9:
//C
this.state = 10;
RDebugUtils.currentLine=69926932;
 //BA.debugLineNum = 69926932;BA.debugLine="newApp.update = False";
parent._newapp.update /*boolean*/  = anywheresoftware.b4a.keywords.Common.False;
RDebugUtils.currentLine=69926933;
 //BA.debugLineNum = 69926933;BA.debugLine="Log(\"No new app\")";
anywheresoftware.b4a.keywords.Common.LogImpl("069926933","No new app",0);
RDebugUtils.currentLine=69926934;
 //BA.debugLineNum = 69926934;BA.debugLine="B4XPages.ShowPage(\"updateAvailable\")";
parent.mostCurrent._b4xpages._showpage /*String*/ (processBA,"updateAvailable");
 if (true) break;
;
RDebugUtils.currentLine=69926938;
 //BA.debugLineNum = 69926938;BA.debugLine="If newApp.version <> Application.VersionName  T";

case 10:
//if
this.state = 13;
if ((parent._newapp.version /*String*/ ).equals(anywheresoftware.b4a.keywords.Common.Application.getVersionName()) == false) { 
this.state = 12;
}if (true) break;

case 12:
//C
this.state = 13;
RDebugUtils.currentLine=69926939;
 //BA.debugLineNum = 69926939;BA.debugLine="newApp.update = True";
parent._newapp.update /*boolean*/  = anywheresoftware.b4a.keywords.Common.True;
RDebugUtils.currentLine=69926940;
 //BA.debugLineNum = 69926940;BA.debugLine="Log(\"New app true\")";
anywheresoftware.b4a.keywords.Common.LogImpl("069926940","New app true",0);
RDebugUtils.currentLine=69926941;
 //BA.debugLineNum = 69926941;BA.debugLine="B4XPages.ShowPage(\"updateAvailable\")";
parent.mostCurrent._b4xpages._showpage /*String*/ (processBA,"updateAvailable");
 if (true) break;

case 13:
//C
this.state = 16;
;
 if (true) break;

case 15:
//C
this.state = 16;
this.catchState = 0;
RDebugUtils.currentLine=69926946;
 //BA.debugLineNum = 69926946;BA.debugLine="Log(\"appUpdater(), Job Failed, error  \" & LastE";
anywheresoftware.b4a.keywords.Common.LogImpl("069926946","appUpdater(), Job Failed, error  "+anywheresoftware.b4a.keywords.Common.LastException(processBA).getMessage(),0);
 if (true) break;
if (true) break;

case 16:
//C
this.state = 19;
this.catchState = 0;
;
 if (true) break;

case 18:
//C
this.state = 19;
RDebugUtils.currentLine=69926949;
 //BA.debugLineNum = 69926949;BA.debugLine="Log(\"appUpdater(), Job Failed \" & lnk)";
anywheresoftware.b4a.keywords.Common.LogImpl("069926949","appUpdater(), Job Failed "+parent._lnk,0);
 if (true) break;

case 19:
//C
this.state = -1;
;
RDebugUtils.currentLine=69926951;
 //BA.debugLineNum = 69926951;BA.debugLine="j.Release";
_j._release /*String*/ (null);
RDebugUtils.currentLine=69926952;
 //BA.debugLineNum = 69926952;BA.debugLine="StopService(Me)";
anywheresoftware.b4a.keywords.Common.StopService(processBA,appupdater.getObject());
RDebugUtils.currentLine=69926953;
 //BA.debugLineNum = 69926953;BA.debugLine="End Sub";
if (true) break;
}} 
       catch (Exception e0) {
			
if (catchState == 0)
    throw e0;
else {
    state = catchState;
processBA.setLastException(e0);}
            }
        }
    }
}
}