package Box.Control;


import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.objects.ServiceHelper;
import anywheresoftware.b4a.debug.*;

public class s1 extends  android.app.Service{
	public static class s1_BR extends android.content.BroadcastReceiver {

		@Override
		public void onReceive(android.content.Context context, android.content.Intent intent) {
            BA.LogInfo("** Receiver (s1) OnReceive **");
			android.content.Intent in = new android.content.Intent(context, s1.class);
			if (intent != null)
				in.putExtra("b4a_internal_intent", intent);
            ServiceHelper.StarterHelper.startServiceFromReceiver (context, in, false, BA.class);
		}

	}
    static s1 mostCurrent;
	public static BA processBA;
    private ServiceHelper _service;
    public static Class<?> getObject() {
		return s1.class;
	}
	@Override
	public void onCreate() {
        super.onCreate();
        mostCurrent = this;
        if (processBA == null) {
		    processBA = new BA(this, null, null, "Box.Control", "Box.Control.s1");
            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, "Box.Control.s1", processBA, _service, anywheresoftware.b4a.keywords.Common.Density);
		}
        if (!false && ServiceHelper.StarterHelper.startFromServiceCreate(processBA, false) == false) {
				
		}
		else {
            processBA.setActivityPaused(false);
            BA.LogInfo("*** Service (s1) Create ***");
            processBA.raiseEvent(null, "service_create");
        }
        processBA.runHook("oncreate", this, null);
        if (false) {
			ServiceHelper.StarterHelper.runWaitForLayouts();
		}
    }
		@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 (s1) 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 (s1) 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 (s1) Destroy (ignored)**");
        }
        else {
            BA.LogInfo("** Service (s1) 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 _counter = 0;
public static anywheresoftware.b4a.phone.Phone.PhoneSms _send_sms = null;
public static anywheresoftware.b4a.agraham.byteconverter.ByteConverter _str = null;
public static String _access = "";
public static String _file_name = "";
public static anywheresoftware.b4a.objects.collections.List _read_data = null;
public static anywheresoftware.b4a.objects.collections.JSONParser.JSONGenerator _jg = null;
public static anywheresoftware.b4a.objects.collections.JSONParser _json = null;
public static anywheresoftware.b4a.objects.collections.Map _generaladmin = null;
public static anywheresoftware.b4a.objects.collections.Map _generaladmin_data = null;
public static anywheresoftware.b4a.objects.collections.Map _hostservice_data = null;
public static anywheresoftware.b4a.objects.collections.Map _androidadmin_data = null;
public static anywheresoftware.b4a.phone.PhoneEvents _hg = null;
public static String _phone1 = "";
public static String _active_phone1 = "";
public static String _phone2 = "";
public static String _active_phone2 = "";
public static String _activephone1 = "";
public static String _activephone2 = "";
public static String _admin_code = "";
public static String _admin_message1 = "";
public static String _admin_message2 = "";
public static String _localisation = "";
public static String _welcome_message1 = "";
public static String _welcome_message2 = "";
public static String _welcome_message3 = "";
public static long _start_date = 0L;
public static long _stop_date = 0L;
public static long _start_time = 0L;
public static long _stop_time = 0L;
public static String _first_name = "";
public static String _last_name = "";
public static String _email = "";
public static String _phone = "";
public static String _city = "";
public static String _door_code = "";
public static String _battery_level = "";
public static boolean _wifi_enable = false;
public static boolean _ble_enable = false;
public static String _rentalid = "";
public Box.Control.main _main = null;
public Box.Control.starter _starter = null;
public Box.Control.agent _agent = null;
public Box.Control.param _param = null;
public static class _message{
public boolean IsInitialized;
public String Address;
public String Body;
public void Initialize() {
IsInitialized = true;
Address = "";
Body = "";
}
@Override
		public String toString() {
			return BA.TypeToString(this, false);
		}}
public static void  _command(int _nbre_pulse) throws Exception{
ResumableSub_Command rsub = new ResumableSub_Command(null,_nbre_pulse);
rsub.resume(processBA, null);
}
public static class ResumableSub_Command extends BA.ResumableSub {
public ResumableSub_Command(Box.Control.s1 parent,int _nbre_pulse) {
this.parent = parent;
this._nbre_pulse = _nbre_pulse;
}
Box.Control.s1 parent;
int _nbre_pulse;

@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 = 100;BA.debugLine="Do While Counter < Nbre_Pulse";
if (true) break;

case 1:
//do while
this.state = 4;
while (parent._counter<_nbre_pulse) {
this.state = 3;
if (true) break;
}
if (true) break;

case 3:
//C
this.state = 1;
 //BA.debugLineNum = 101;BA.debugLine="CallSub3(Starter, \"Beep\", 1000, 1000)";
anywheresoftware.b4a.keywords.Common.CallSubNew3(processBA,(Object)(parent.mostCurrent._starter.getObject()),"Beep",(Object)(1000),(Object)(1000));
 //BA.debugLineNum = 102;BA.debugLine="Sleep(3000) 'Délai entre chaque pulse";
anywheresoftware.b4a.keywords.Common.Sleep(processBA,this,(int) (3000));
this.state = 5;
return;
case 5:
//C
this.state = 1;
;
 //BA.debugLineNum = 103;BA.debugLine="Counter= Counter+1";
parent._counter = (int) (parent._counter+1);
 if (true) break;

case 4:
//C
this.state = -1;
;
 //BA.debugLineNum = 106;BA.debugLine="End Sub";
if (true) break;

            }
        }
    }
}
public static String  _create_host_jsonfile() throws Exception{
anywheresoftware.b4a.objects.collections.Map _map1 = null;
anywheresoftware.b4a.objects.collections.Map _m = null;
anywheresoftware.b4a.objects.collections.Map _ident_loc = null;
 //BA.debugLineNum = 182;BA.debugLine="Sub create_Host_JsonFile";
 //BA.debugLineNum = 185;BA.debugLine="Dim Map1 As Map";
_map1 = new anywheresoftware.b4a.objects.collections.Map();
 //BA.debugLineNum = 187;BA.debugLine="Dim m As Map";
_m = new anywheresoftware.b4a.objects.collections.Map();
 //BA.debugLineNum = 188;BA.debugLine="Dim Ident_Loc As Map";
_ident_loc = new anywheresoftware.b4a.objects.collections.Map();
 //BA.debugLineNum = 190;BA.debugLine="m.Initialize";
_m.Initialize();
 //BA.debugLineNum = 191;BA.debugLine="m.Put(\"StartDate\", Start_Date)";
_m.Put((Object)("StartDate"),(Object)(_start_date));
 //BA.debugLineNum = 192;BA.debugLine="m.Put(\"StopDate\", Stop_Date)";
_m.Put((Object)("StopDate"),(Object)(_stop_date));
 //BA.debugLineNum = 193;BA.debugLine="m.Put(\"StartTime\", Start_Time)";
_m.Put((Object)("StartTime"),(Object)(_start_time));
 //BA.debugLineNum = 194;BA.debugLine="m.Put(\"stopTime\", Stop_Time)";
_m.Put((Object)("stopTime"),(Object)(_stop_time));
 //BA.debugLineNum = 196;BA.debugLine="RentalId=Rnd(100000,999999)";
_rentalid = BA.NumberToString(anywheresoftware.b4a.keywords.Common.Rnd((int) (100000),(int) (999999)));
 //BA.debugLineNum = 198;BA.debugLine="Do While File.Exists(File.DirDefaultExternal,Rent";
while (anywheresoftware.b4a.keywords.Common.File.Exists(anywheresoftware.b4a.keywords.Common.File.getDirDefaultExternal(),_rentalid+".json")==anywheresoftware.b4a.keywords.Common.True) {
 //BA.debugLineNum = 199;BA.debugLine="RentalId=Rnd(100000,999999)";
_rentalid = BA.NumberToString(anywheresoftware.b4a.keywords.Common.Rnd((int) (100000),(int) (999999)));
 }
;
 //BA.debugLineNum = 202;BA.debugLine="Ident_Loc.Initialize";
_ident_loc.Initialize();
 //BA.debugLineNum = 203;BA.debugLine="Ident_Loc.Put(\"FirstName\",First_Name)";
_ident_loc.Put((Object)("FirstName"),(Object)(_first_name));
 //BA.debugLineNum = 204;BA.debugLine="Ident_Loc.Put(\"LastName\",Last_Name)";
_ident_loc.Put((Object)("LastName"),(Object)(_last_name));
 //BA.debugLineNum = 205;BA.debugLine="Ident_Loc.Put(\"Email\",Email)";
_ident_loc.Put((Object)("Email"),(Object)(_email));
 //BA.debugLineNum = 206;BA.debugLine="Ident_Loc.Put(\"Phone\",Phone)";
_ident_loc.Put((Object)("Phone"),(Object)(_phone));
 //BA.debugLineNum = 207;BA.debugLine="Ident_Loc.Put(\"City\",City)";
_ident_loc.Put((Object)("City"),(Object)(_city));
 //BA.debugLineNum = 208;BA.debugLine="Ident_Loc.Put(\"DoorCode\",Door_Code)";
_ident_loc.Put((Object)("DoorCode"),(Object)(_door_code));
 //BA.debugLineNum = 209;BA.debugLine="Ident_Loc.Put(\"Reserved\",m)";
_ident_loc.Put((Object)("Reserved"),(Object)(_m.getObject()));
 //BA.debugLineNum = 213;BA.debugLine="jg.Initialize(CreateMap( RentalId :Ident_Loc))";
_jg.Initialize(anywheresoftware.b4a.keywords.Common.createMap(new Object[] {(Object)(_rentalid),(Object)(_ident_loc.getObject())}));
 //BA.debugLineNum = 215;BA.debugLine="Log(jg.ToPrettyString(4))";
anywheresoftware.b4a.keywords.Common.LogImpl("11900577",_jg.ToPrettyString((int) (4)),0);
 //BA.debugLineNum = 217;BA.debugLine="File.WriteString(File.DirDefaultExternal,RentalId";
anywheresoftware.b4a.keywords.Common.File.WriteString(anywheresoftware.b4a.keywords.Common.File.getDirDefaultExternal(),_rentalid+".json",_jg.ToPrettyString((int) (4)));
 //BA.debugLineNum = 218;BA.debugLine="JSON.Initialize(File.ReadString(File.DirDefaultEx";
_json.Initialize(anywheresoftware.b4a.keywords.Common.File.ReadString(anywheresoftware.b4a.keywords.Common.File.getDirDefaultExternal(),_rentalid+".json"));
 //BA.debugLineNum = 219;BA.debugLine="Map1.Initialize";
_map1.Initialize();
 //BA.debugLineNum = 220;BA.debugLine="Map1 = JSON.NextObject";
_map1 = _json.NextObject();
 //BA.debugLineNum = 222;BA.debugLine="End Sub";
return "";
}
public static String  _hg_batterychanged(int _level,int _scale,boolean _plugged,anywheresoftware.b4a.objects.IntentWrapper _intent) throws Exception{
 //BA.debugLineNum = 402;BA.debugLine="Sub hg_BatteryChanged (Level As Int, Scale As Int,";
 //BA.debugLineNum = 403;BA.debugLine="Battery_Level=Level";
_battery_level = BA.NumberToString(_level);
 //BA.debugLineNum = 404;BA.debugLine="End Sub";
return "";
}
public static String  _json_setup(boolean _mode) throws Exception{
 //BA.debugLineNum = 109;BA.debugLine="Sub Json_setup(Mode As Boolean) 'False/True = Read";
 //BA.debugLineNum = 127;BA.debugLine="If Mode=False Then";
if (_mode==anywheresoftware.b4a.keywords.Common.False) { 
 //BA.debugLineNum = 128;BA.debugLine="JSON.Initialize(File.ReadString(File.DirDefaultE";
_json.Initialize(anywheresoftware.b4a.keywords.Common.File.ReadString(anywheresoftware.b4a.keywords.Common.File.getDirDefaultExternal(),"Setup.json"));
 //BA.debugLineNum = 130;BA.debugLine="GeneralAdmin = JSON.NextObject";
_generaladmin = _json.NextObject();
 //BA.debugLineNum = 132;BA.debugLine="GeneralAdmin_Data=GeneralAdmin.Get(\"GeneralAdmin";
_generaladmin_data = (anywheresoftware.b4a.objects.collections.Map) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4a.objects.collections.Map(), (anywheresoftware.b4a.objects.collections.Map.MyMap)(_generaladmin.Get((Object)("GeneralAdmin"))));
 //BA.debugLineNum = 133;BA.debugLine="HostService_Data=GeneralAdmin.Get(\"HostService\")";
_hostservice_data = (anywheresoftware.b4a.objects.collections.Map) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4a.objects.collections.Map(), (anywheresoftware.b4a.objects.collections.Map.MyMap)(_generaladmin.Get((Object)("HostService"))));
 //BA.debugLineNum = 134;BA.debugLine="AndroidAdmin_Data=GeneralAdmin.Get(\"AndroidAdmin";
_androidadmin_data = (anywheresoftware.b4a.objects.collections.Map) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4a.objects.collections.Map(), (anywheresoftware.b4a.objects.collections.Map.MyMap)(_generaladmin.Get((Object)("AndroidAdmin"))));
 //BA.debugLineNum = 136;BA.debugLine="Phone1=GeneralAdmin_Data.Get(\"Phone1\")";
_phone1 = BA.ObjectToString(_generaladmin_data.Get((Object)("Phone1")));
 //BA.debugLineNum = 137;BA.debugLine="Phone2=GeneralAdmin_Data.Get(\"Phone2\")";
_phone2 = BA.ObjectToString(_generaladmin_data.Get((Object)("Phone2")));
 //BA.debugLineNum = 138;BA.debugLine="Admin_Code=GeneralAdmin_Data.Get(\"Admin_Code\")";
_admin_code = BA.ObjectToString(_generaladmin_data.Get((Object)("Admin_Code")));
 //BA.debugLineNum = 139;BA.debugLine="Admin_Message1=GeneralAdmin_Data.Get(\"Admin_Mess";
_admin_message1 = BA.ObjectToString(_generaladmin_data.Get((Object)("Admin_Message1")));
 //BA.debugLineNum = 140;BA.debugLine="Admin_Message2=GeneralAdmin_Data.Get(\"Admin_Mess";
_admin_message2 = BA.ObjectToString(_generaladmin_data.Get((Object)("Admin_Message2")));
 //BA.debugLineNum = 141;BA.debugLine="Localisation=GeneralAdmin_Data.Get(\"Localisation";
_localisation = BA.ObjectToString(_generaladmin_data.Get((Object)("Localisation")));
 //BA.debugLineNum = 142;BA.debugLine="Welcome_Message1=HostService_Data.Get(\"Welcome_M";
_welcome_message1 = BA.ObjectToString(_hostservice_data.Get((Object)("Welcome_Message1")));
 //BA.debugLineNum = 143;BA.debugLine="Welcome_Message2=HostService_Data.Get(\"Welcome_M";
_welcome_message2 = BA.ObjectToString(_hostservice_data.Get((Object)("Welcome_Message2")));
 //BA.debugLineNum = 144;BA.debugLine="Welcome_Message3=HostService_Data.Get(\"Welcome_M";
_welcome_message3 = BA.ObjectToString(_hostservice_data.Get((Object)("Welcome_Message3")));
 //BA.debugLineNum = 145;BA.debugLine="ActivePhone1=GeneralAdmin_Data.Get(\"ActivePhone1";
_activephone1 = BA.ObjectToString(_generaladmin_data.Get((Object)("ActivePhone1")));
 //BA.debugLineNum = 146;BA.debugLine="ActivePhone2=GeneralAdmin_Data.Get(\"ActivePhone2";
_activephone2 = BA.ObjectToString(_generaladmin_data.Get((Object)("ActivePhone2")));
 //BA.debugLineNum = 147;BA.debugLine="Wifi_Enable=AndroidAdmin_Data.Get(\"Wifi\")";
_wifi_enable = BA.ObjectToBoolean(_androidadmin_data.Get((Object)("Wifi")));
 //BA.debugLineNum = 148;BA.debugLine="BLE_Enable=AndroidAdmin_Data.Get(\"BLE\")";
_ble_enable = BA.ObjectToBoolean(_androidadmin_data.Get((Object)("BLE")));
 //BA.debugLineNum = 149;BA.debugLine="Battery_Level=AndroidAdmin_Data.Get(\"BatteryLeve";
_battery_level = BA.ObjectToString(_androidadmin_data.Get((Object)("BatteryLevel")));
 }else if(_mode==anywheresoftware.b4a.keywords.Common.True) { 
 //BA.debugLineNum = 152;BA.debugLine="jg.Initialize(GeneralAdmin)";
_jg.Initialize(_generaladmin);
 //BA.debugLineNum = 153;BA.debugLine="File.WriteString(File.DirDefaultExternal,\"Setup.";
anywheresoftware.b4a.keywords.Common.File.WriteString(anywheresoftware.b4a.keywords.Common.File.getDirDefaultExternal(),"Setup.json",_jg.ToPrettyString((int) (4)));
 };
 //BA.debugLineNum = 158;BA.debugLine="End Sub";
return "";
}
public static Box.Control.s1._message[]  _parsesmsintent(anywheresoftware.b4a.objects.IntentWrapper _in) throws Exception{
Box.Control.s1._message[] _messages = null;
Object[] _pdus = null;
anywheresoftware.b4a.agraham.reflection.Reflection _r = null;
int _i = 0;
 //BA.debugLineNum = 161;BA.debugLine="Sub ParseSmsIntent (in As Intent) As Message()";
 //BA.debugLineNum = 164;BA.debugLine="Dim messages() As Message";
_messages = new Box.Control.s1._message[(int) (0)];
{
int d0 = _messages.length;
for (int i0 = 0;i0 < d0;i0++) {
_messages[i0] = new Box.Control.s1._message();
}
}
;
 //BA.debugLineNum = 165;BA.debugLine="If in.HasExtra(\"pdus\") = False Then Return messag";
if (_in.HasExtra("pdus")==anywheresoftware.b4a.keywords.Common.False) { 
if (true) return _messages;};
 //BA.debugLineNum = 166;BA.debugLine="Dim pdus() As Object";
_pdus = new Object[(int) (0)];
{
int d0 = _pdus.length;
for (int i0 = 0;i0 < d0;i0++) {
_pdus[i0] = new Object();
}
}
;
 //BA.debugLineNum = 167;BA.debugLine="Dim r As Reflector";
_r = new anywheresoftware.b4a.agraham.reflection.Reflection();
 //BA.debugLineNum = 168;BA.debugLine="pdus = in.GetExtra(\"pdus\")";
_pdus = (Object[])(_in.GetExtra("pdus"));
 //BA.debugLineNum = 169;BA.debugLine="If pdus.Length > 0 Then";
if (_pdus.length>0) { 
 //BA.debugLineNum = 170;BA.debugLine="Dim messages(pdus.Length) As Message";
_messages = new Box.Control.s1._message[_pdus.length];
{
int d0 = _messages.length;
for (int i0 = 0;i0 < d0;i0++) {
_messages[i0] = new Box.Control.s1._message();
}
}
;
 //BA.debugLineNum = 171;BA.debugLine="For i = 0 To pdus.Length - 1";
{
final int step8 = 1;
final int limit8 = (int) (_pdus.length-1);
_i = (int) (0) ;
for (;_i <= limit8 ;_i = _i + step8 ) {
 //BA.debugLineNum = 172;BA.debugLine="r.Target = r.RunStaticMethod(\"android.telephony";
_r.Target = _r.RunStaticMethod("android.telephony.SmsMessage","createFromPdu",new Object[]{_pdus[_i]},new String[]{"[B"});
 //BA.debugLineNum = 174;BA.debugLine="messages(i).Body = r.RunMethod(\"getMessageBody\"";
_messages[_i].Body /*String*/  = BA.ObjectToString(_r.RunMethod("getMessageBody"));
 //BA.debugLineNum = 175;BA.debugLine="messages(i).Address = r.RunMethod(\"getOriginati";
_messages[_i].Address /*String*/  = BA.ObjectToString(_r.RunMethod("getOriginatingAddress"));
 }
};
 };
 //BA.debugLineNum = 178;BA.debugLine="Return messages";
if (true) return _messages;
 //BA.debugLineNum = 179;BA.debugLine="End Sub";
return null;
}
public static String  _process_globals() throws Exception{
 //BA.debugLineNum = 6;BA.debugLine="Sub Process_Globals";
 //BA.debugLineNum = 8;BA.debugLine="Type Message (Address As String, Body As String)";
;
 //BA.debugLineNum = 9;BA.debugLine="Private Counter As Int = 0";
_counter = (int) (0);
 //BA.debugLineNum = 10;BA.debugLine="Dim Send_Sms As PhoneSms";
_send_sms = new anywheresoftware.b4a.phone.Phone.PhoneSms();
 //BA.debugLineNum = 11;BA.debugLine="Dim str As ByteConverter";
_str = new anywheresoftware.b4a.agraham.byteconverter.ByteConverter();
 //BA.debugLineNum = 12;BA.debugLine="Dim Access As String = \"0000\"";
_access = "0000";
 //BA.debugLineNum = 13;BA.debugLine="Dim file_name As String=\"Setup.json\"";
_file_name = "Setup.json";
 //BA.debugLineNum = 14;BA.debugLine="Dim Read_data As List";
_read_data = new anywheresoftware.b4a.objects.collections.List();
 //BA.debugLineNum = 15;BA.debugLine="Dim jg As JSONGenerator";
_jg = new anywheresoftware.b4a.objects.collections.JSONParser.JSONGenerator();
 //BA.debugLineNum = 16;BA.debugLine="Dim JSON As JSONParser";
_json = new anywheresoftware.b4a.objects.collections.JSONParser();
 //BA.debugLineNum = 17;BA.debugLine="Dim GeneralAdmin As Map";
_generaladmin = new anywheresoftware.b4a.objects.collections.Map();
 //BA.debugLineNum = 18;BA.debugLine="Dim GeneralAdmin_Data As Map";
_generaladmin_data = new anywheresoftware.b4a.objects.collections.Map();
 //BA.debugLineNum = 19;BA.debugLine="Dim HostService_Data As Map";
_hostservice_data = new anywheresoftware.b4a.objects.collections.Map();
 //BA.debugLineNum = 20;BA.debugLine="Dim AndroidAdmin_Data As Map";
_androidadmin_data = new anywheresoftware.b4a.objects.collections.Map();
 //BA.debugLineNum = 21;BA.debugLine="Dim hg As PhoneEvents";
_hg = new anywheresoftware.b4a.phone.PhoneEvents();
 //BA.debugLineNum = 22;BA.debugLine="Dim Phone1,Active_Phone1,Phone2,Active_Phone2,Act";
_phone1 = "";
_active_phone1 = "";
_phone2 = "";
_active_phone2 = "";
_activephone1 = "";
_activephone2 = "";
_admin_code = "";
_admin_message1 = "";
_admin_message2 = "";
_localisation = "";
_welcome_message1 = "";
_welcome_message2 = "";
_welcome_message3 = "";
 //BA.debugLineNum = 23;BA.debugLine="Dim Start_Date, Stop_Date, Start_Time, Stop_Time";
_start_date = 0L;
_stop_date = 0L;
_start_time = 0L;
_stop_time = 0L;
 //BA.debugLineNum = 24;BA.debugLine="Dim First_Name, Last_Name, Email, Phone, City, Do";
_first_name = "";
_last_name = "";
_email = "";
_phone = "";
_city = "";
_door_code = "";
_battery_level = "";
 //BA.debugLineNum = 25;BA.debugLine="Dim Wifi_Enable, BLE_Enable As Boolean";
_wifi_enable = false;
_ble_enable = false;
 //BA.debugLineNum = 27;BA.debugLine="Dim RentalId As String";
_rentalid = "";
 //BA.debugLineNum = 28;BA.debugLine="End Sub";
return "";
}
public static String  _send_succesful_command(String _number,String _message) throws Exception{
 //BA.debugLineNum = 406;BA.debugLine="Sub Send_Succesful_Command(Number As String,messag";
 //BA.debugLineNum = 408;BA.debugLine="Send_Sms.Send(Number,message)";
_send_sms.Send(_number,_message);
 //BA.debugLineNum = 409;BA.debugLine="End Sub";
return "";
}
public static String  _service_command(String _order) throws Exception{
String _data = "";
String _header = "";
boolean _data_valid = false;
boolean _success = false;
String[] _ident_header = null;
String _datas_header = "";
String[] _data_header = null;
int _nbre_header = 0;
String _header_item = "";
String[] _d_password = null;
String[] _d_phone1 = null;
String[] _d_activephone1 = null;
String[] _d_phone2 = null;
String[] _d_activephone2 = null;
String[] _d_admin_message1 = null;
String[] _d_admin_message2 = null;
String[] _d_localisation = null;
String[] _d_welcome_message1 = null;
String[] _d_welcome_message2 = null;
String[] _d_welcome_message3 = null;
String[] _d_wifi_enable = null;
String[] _d_ble_enable = null;
 //BA.debugLineNum = 227;BA.debugLine="Sub Service_Command(Order As String)";
 //BA.debugLineNum = 229;BA.debugLine="Dim Data As String=\"\"";
_data = "";
 //BA.debugLineNum = 230;BA.debugLine="Dim Header As String=\"\"";
_header = "";
 //BA.debugLineNum = 231;BA.debugLine="Dim Data_valid As Boolean=False";
_data_valid = anywheresoftware.b4a.keywords.Common.False;
 //BA.debugLineNum = 232;BA.debugLine="Dim success As Boolean=False";
_success = anywheresoftware.b4a.keywords.Common.False;
 //BA.debugLineNum = 234;BA.debugLine="Try";
try { //BA.debugLineNum = 235;BA.debugLine="If Order.SubString2(0,2)=\"#C\" And Order.SubStrin";
if ((_order.substring((int) (0),(int) (2))).equals("#C") && (_order.substring((int) (_order.length()-1))).equals("%")) { 
 //BA.debugLineNum = 238;BA.debugLine="Dim Ident_Header() As String=Regex.Split(\"#\",Or";
_ident_header = anywheresoftware.b4a.keywords.Common.Regex.Split("#",_order);
 //BA.debugLineNum = 239;BA.debugLine="Dim Datas_Header As String=Order.SubString(5)";
_datas_header = _order.substring((int) (5));
 //BA.debugLineNum = 240;BA.debugLine="Dim Data_Header() As String=Regex.Split(\"#\",Dat";
_data_header = anywheresoftware.b4a.keywords.Common.Regex.Split("#",_datas_header);
 //BA.debugLineNum = 241;BA.debugLine="Dim Nbre_Header As Int=Ident_Header(1).SubStrin";
_nbre_header = (int)(Double.parseDouble(_ident_header[(int) (1)].substring((int) (1))));
 //BA.debugLineNum = 243;BA.debugLine="If Nbre_Header<>Data_Header.Length Then";
if (_nbre_header!=_data_header.length) { 
 //BA.debugLineNum = 245;BA.debugLine="Send_Succesful_Command(Phone1,\"Command Fail\")";
_send_succesful_command(_phone1,"Command Fail");
 }else {
 //BA.debugLineNum = 249;BA.debugLine="For Each Header_Item As String In Data_Header";
{
final String[] group14 = _data_header;
final int groupLen14 = group14.length
;int index14 = 0;
;
for (; index14 < groupLen14;index14++){
_header_item = group14[index14];
 //BA.debugLineNum = 256;BA.debugLine="If Header_Item.SubString2(5,6)=\"%\"  And  Orde";
if ((_header_item.substring((int) (5),(int) (6))).equals("%") && (_order.substring((int) (_order.length()-1))).equals("%")) { 
 //BA.debugLineNum = 257;BA.debugLine="Header = Header_Item.SubString2(0,5)";
_header = _header_item.substring((int) (0),(int) (5));
 //BA.debugLineNum = 258;BA.debugLine="Data = Header_Item.SubString2(6,Header_Item.";
_data = _header_item.substring((int) (6),(int) (_header_item.length()-1));
 //BA.debugLineNum = 259;BA.debugLine="Data_valid=True";
_data_valid = anywheresoftware.b4a.keywords.Common.True;
 };
 //BA.debugLineNum = 263;BA.debugLine="If Data_valid=True Then";
if (_data_valid==anywheresoftware.b4a.keywords.Common.True) { 
 //BA.debugLineNum = 265;BA.debugLine="If Header.SubString2(0,2)=\"Or\" Then 'Admin C";
if ((_header.substring((int) (0),(int) (2))).equals("Or")) { 
 //BA.debugLineNum = 267;BA.debugLine="Select Case Header";
switch (BA.switchObjectToInt(_header,"Or001","Or002","Or003","Or004","Or005","Or006","Or007","Or008","Or009","Or010","Or011","Or012","Or013","Or014","Or015")) {
case 0: {
 //BA.debugLineNum = 272;BA.debugLine="Dim D_password() As String= Regex.Split(\"";
_d_password = anywheresoftware.b4a.keywords.Common.Regex.Split("%",_data);
 //BA.debugLineNum = 273;BA.debugLine="If D_password(0)=Admin_Code Then";
if ((_d_password[(int) (0)]).equals(_admin_code)) { 
 //BA.debugLineNum = 274;BA.debugLine="Admin_Code = D_password(1)";
_admin_code = _d_password[(int) (1)];
 //BA.debugLineNum = 275;BA.debugLine="success=True";
_success = anywheresoftware.b4a.keywords.Common.True;
 //BA.debugLineNum = 276;BA.debugLine="Send_Succesful_Command(Phone1,\"Successfu";
_send_succesful_command(_phone1,"Successful New Code ");
 };
 break; }
case 1: {
 //BA.debugLineNum = 280;BA.debugLine="Dim D_Phone1() As String= Regex.Split(\"%\"";
_d_phone1 = anywheresoftware.b4a.keywords.Common.Regex.Split("%",_data);
 //BA.debugLineNum = 281;BA.debugLine="Phone1=D_Phone1(0)";
_phone1 = _d_phone1[(int) (0)];
 break; }
case 2: {
 //BA.debugLineNum = 284;BA.debugLine="Dim D_ActivePhone1() As String= Regex.Spl";
_d_activephone1 = anywheresoftware.b4a.keywords.Common.Regex.Split("%",_data);
 //BA.debugLineNum = 285;BA.debugLine="Active_Phone1=D_ActivePhone1(0)";
_active_phone1 = _d_activephone1[(int) (0)];
 break; }
case 3: {
 //BA.debugLineNum = 288;BA.debugLine="Dim D_Phone2() As String= Regex.Split(\"%\"";
_d_phone2 = anywheresoftware.b4a.keywords.Common.Regex.Split("%",_data);
 //BA.debugLineNum = 289;BA.debugLine="Phone2=D_Phone2(0)";
_phone2 = _d_phone2[(int) (0)];
 break; }
case 4: {
 //BA.debugLineNum = 292;BA.debugLine="Dim D_ActivePhone2() As String= Regex.Spl";
_d_activephone2 = anywheresoftware.b4a.keywords.Common.Regex.Split("%",_data);
 //BA.debugLineNum = 293;BA.debugLine="Active_Phone2=D_ActivePhone2(0)";
_active_phone2 = _d_activephone2[(int) (0)];
 break; }
case 5: {
 //BA.debugLineNum = 296;BA.debugLine="Dim D_Admin_Message1() As String= Regex.S";
_d_admin_message1 = anywheresoftware.b4a.keywords.Common.Regex.Split("%",_data);
 //BA.debugLineNum = 297;BA.debugLine="Admin_Message1=D_Admin_Message1(0)";
_admin_message1 = _d_admin_message1[(int) (0)];
 break; }
case 6: {
 //BA.debugLineNum = 300;BA.debugLine="Dim D_Admin_Message2() As String= Regex.S";
_d_admin_message2 = anywheresoftware.b4a.keywords.Common.Regex.Split("%",_data);
 //BA.debugLineNum = 301;BA.debugLine="Admin_Message2=D_Admin_Message2(0)";
_admin_message2 = _d_admin_message2[(int) (0)];
 break; }
case 7: {
 //BA.debugLineNum = 303;BA.debugLine="Dim D_Localisation() As String= Regex.Spl";
_d_localisation = anywheresoftware.b4a.keywords.Common.Regex.Split("%",_data);
 //BA.debugLineNum = 304;BA.debugLine="Localisation=D_Localisation(0)";
_localisation = _d_localisation[(int) (0)];
 break; }
case 8: {
 //BA.debugLineNum = 307;BA.debugLine="Dim D_Welcome_Message1() As String= Regex";
_d_welcome_message1 = anywheresoftware.b4a.keywords.Common.Regex.Split("%",_data);
 //BA.debugLineNum = 308;BA.debugLine="Welcome_Message1=D_Welcome_Message1(0)";
_welcome_message1 = _d_welcome_message1[(int) (0)];
 break; }
case 9: {
 //BA.debugLineNum = 311;BA.debugLine="Dim D_Welcome_Message2() As String= Regex";
_d_welcome_message2 = anywheresoftware.b4a.keywords.Common.Regex.Split("%",_data);
 //BA.debugLineNum = 312;BA.debugLine="Welcome_Message2=D_Welcome_Message2(0)";
_welcome_message2 = _d_welcome_message2[(int) (0)];
 break; }
case 10: {
 //BA.debugLineNum = 315;BA.debugLine="Dim D_Welcome_Message3() As String= Regex";
_d_welcome_message3 = anywheresoftware.b4a.keywords.Common.Regex.Split("%",_data);
 //BA.debugLineNum = 316;BA.debugLine="Welcome_Message3=D_Welcome_Message3(0)";
_welcome_message3 = _d_welcome_message3[(int) (0)];
 break; }
case 11: {
 //BA.debugLineNum = 319;BA.debugLine="Dim D_Wifi_Enable() As String= Regex.Spli";
_d_wifi_enable = anywheresoftware.b4a.keywords.Common.Regex.Split("%",_data);
 //BA.debugLineNum = 320;BA.debugLine="Wifi_Enable=D_Wifi_Enable(0)";
_wifi_enable = BA.ObjectToBoolean(_d_wifi_enable[(int) (0)]);
 break; }
case 12: {
 //BA.debugLineNum = 323;BA.debugLine="Dim D_BLE_Enable() As String= Regex.Split";
_d_ble_enable = anywheresoftware.b4a.keywords.Common.Regex.Split("%",_data);
 //BA.debugLineNum = 324;BA.debugLine="BLE_Enable=D_BLE_Enable(0)";
_ble_enable = BA.ObjectToBoolean(_d_ble_enable[(int) (0)]);
 break; }
case 13: {
 //BA.debugLineNum = 328;BA.debugLine="Send_Succesful_Command(Phone1,\"Battery Le";
_send_succesful_command(_phone1,"Battery Level: "+_battery_level+"%");
 break; }
case 14: {
 break; }
}
;
 }else if((_header.substring((int) (0),(int) (3))).equals("#Hb")) { 
 //BA.debugLineNum = 335;BA.debugLine="Select Case Header";
switch (BA.switchObjectToInt(_header,"Hb001","Hb002","Hb003","Hb004","Hb005","Hb006","Hb007","Hb008","Hb009","Hb010","Hb011","Hb012")) {
case 0: {
 break; }
case 1: {
 break; }
case 2: {
 break; }
case 3: {
 break; }
case 4: {
 break; }
case 5: {
 break; }
case 6: {
 break; }
case 7: {
 break; }
case 8: {
 break; }
case 9: {
 break; }
case 10: {
 break; }
case 11: {
 break; }
}
;
 };
 };
 }
};
 //BA.debugLineNum = 369;BA.debugLine="If Data_valid=True Then";
if (_data_valid==anywheresoftware.b4a.keywords.Common.True) { 
 //BA.debugLineNum = 370;BA.debugLine="Send_Succesful_Command(Phone1,Nbre_Header & \"";
_send_succesful_command(_phone1,BA.NumberToString(_nbre_header)+" Successful Commands");
 };
 };
 };
 } 
       catch (Exception e94) {
			processBA.setLastException(e94); //BA.debugLineNum = 377;BA.debugLine="Log(LastException)";
anywheresoftware.b4a.keywords.Common.LogImpl("12031766",BA.ObjectToString(anywheresoftware.b4a.keywords.Common.LastException(processBA)),0);
 };
 //BA.debugLineNum = 400;BA.debugLine="End Sub";
return "";
}
public static String  _service_create() throws Exception{
 //BA.debugLineNum = 30;BA.debugLine="Sub Service_Create";
 //BA.debugLineNum = 33;BA.debugLine="Read_data.Initialize";
_read_data.Initialize();
 //BA.debugLineNum = 34;BA.debugLine="GeneralAdmin.Initialize";
_generaladmin.Initialize();
 //BA.debugLineNum = 35;BA.debugLine="GeneralAdmin_Data.Initialize";
_generaladmin_data.Initialize();
 //BA.debugLineNum = 36;BA.debugLine="HostService_Data.Initialize";
_hostservice_data.Initialize();
 //BA.debugLineNum = 37;BA.debugLine="AndroidAdmin_Data.Initialize";
_androidadmin_data.Initialize();
 //BA.debugLineNum = 38;BA.debugLine="Json_setup(False) 'Chargement du Setup";
_json_setup(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 41;BA.debugLine="hg.Initialize(\"hg\")";
_hg.Initialize(processBA,"hg");
 //BA.debugLineNum = 42;BA.debugLine="End Sub";
return "";
}
public static String  _service_destroy() throws Exception{
 //BA.debugLineNum = 411;BA.debugLine="Sub Service_Destroy";
 //BA.debugLineNum = 413;BA.debugLine="End Sub";
return "";
}
public static String  _service_start(anywheresoftware.b4a.objects.IntentWrapper _startingintent) throws Exception{
Box.Control.s1._message[] _messages = null;
int _i = 0;
String _number = "";
String _mess = "";
 //BA.debugLineNum = 44;BA.debugLine="Sub Service_Start(startingIntent As Intent)";
 //BA.debugLineNum = 50;BA.debugLine="If startingIntent.Action = \"android.provider.Tele";
if ((_startingintent.getAction()).equals("android.provider.Telephony.SMS_RECEIVED")) { 
 //BA.debugLineNum = 51;BA.debugLine="Dim messages() As Message";
_messages = new Box.Control.s1._message[(int) (0)];
{
int d0 = _messages.length;
for (int i0 = 0;i0 < d0;i0++) {
_messages[i0] = new Box.Control.s1._message();
}
}
;
 //BA.debugLineNum = 52;BA.debugLine="messages = ParseSmsIntent(startingIntent)";
_messages = _parsesmsintent(_startingintent);
 //BA.debugLineNum = 54;BA.debugLine="For i = 0 To messages.Length - 1";
{
final int step4 = 1;
final int limit4 = (int) (_messages.length /*int*/ -1);
_i = (int) (0) ;
for (;_i <= limit4 ;_i = _i + step4 ) {
 //BA.debugLineNum = 58;BA.debugLine="Dim Number As String = messages(i).Address' Ful";
_number = _messages[_i].Address /*String*/ ;
 //BA.debugLineNum = 59;BA.debugLine="Dim mess As String = messages(i).Body 'FullMess";
_mess = _messages[_i].Body /*String*/ ;
 //BA.debugLineNum = 67;BA.debugLine="Service_Command(mess)";
_service_command(_mess);
 //BA.debugLineNum = 89;BA.debugLine="Log(messages(i))";
anywheresoftware.b4a.keywords.Common.LogImpl("11638445",BA.ObjectToString(_messages[_i]),0);
 }
};
 };
 //BA.debugLineNum = 93;BA.debugLine="Service.StopAutomaticForeground";
mostCurrent._service.StopAutomaticForeground();
 //BA.debugLineNum = 94;BA.debugLine="End Sub";
return "";
}
}
