package com.king.game.v1;


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

public class pnservice extends android.app.Service{
	public static class pnservice_BR extends android.content.BroadcastReceiver {

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

	}
    static pnservice mostCurrent;
	public static BA processBA;
    private ServiceHelper _service;
    public static Class<?> getObject() {
		return pnservice.class;
	}
	@Override
	public void onCreate() {
        super.onCreate();
        mostCurrent = this;
        if (processBA == null) {
		    processBA = new BA(this, null, null, "com.king.game.v1", "com.king.game.v1.pnservice");
            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, "com.king.game.v1.pnservice", processBA, _service, anywheresoftware.b4a.keywords.Common.Density);
		}
        if (!false && ServiceHelper.StarterHelper.startFromServiceCreate(processBA, false) == false) {
				
		}
		else {
            processBA.setActivityPaused(false);
            BA.LogInfo("*** Service (pnservice) 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 (pnservice) 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_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 (pnservice) 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 (pnservice) Destroy (ignored)**");
        }
        else {
            BA.LogInfo("** Service (pnservice) 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 PNBroadcastReceiver.PNBrodcastReceiver _pnreciver = null;
public static anywheresoftware.b4a.phone.Phone.PhoneWakeState _awak = null;
public static anywheresoftware.b4a.objects.NotificationListenerWrapper.NotificationListener _listener = null;
public com.king.game.v1.main _main = null;
public com.king.game.v1.starter _starter = null;
public com.king.game.v1.firebasemessaging _firebasemessaging = null;
public com.king.game.v1.information _information = null;
public com.king.game.v1.icon2 _icon2 = null;
public com.king.game.v1.httputils2service _httputils2service = null;
public static String  _pnreciver_onreceive(String _action,String[] _keys,Object _data) throws Exception{
 //BA.debugLineNum = 29;BA.debugLine="Sub pnreciver_OnReceive(Action As String,keys() As";
 //BA.debugLineNum = 30;BA.debugLine="Try";
try { //BA.debugLineNum = 31;BA.debugLine="If Action=\"android.intent.action.SCREEN_ON\" Then";
if ((_action).equals("android.intent.action.SCREEN_ON")) { 
 //BA.debugLineNum = 32;BA.debugLine="StartService(\"\")";
anywheresoftware.b4a.keywords.Common.StartService(processBA,(Object)(""));
 //BA.debugLineNum = 33;BA.debugLine="StartService(FirebaseMessaging)";
anywheresoftware.b4a.keywords.Common.StartService(processBA,(Object)(mostCurrent._firebasemessaging.getObject()));
 //BA.debugLineNum = 34;BA.debugLine="CallSubDelayed(FirebaseMessaging, \"SubscribeToT";
anywheresoftware.b4a.keywords.Common.CallSubDelayed(processBA,(Object)(mostCurrent._firebasemessaging.getObject()),"SubscribeToTopics");
 };
 //BA.debugLineNum = 36;BA.debugLine="If Action=\"android.intent.action.SCREEN_OFF\" The";
if ((_action).equals("android.intent.action.SCREEN_OFF")) { 
 //BA.debugLineNum = 37;BA.debugLine="StartService(\"\")";
anywheresoftware.b4a.keywords.Common.StartService(processBA,(Object)(""));
 //BA.debugLineNum = 38;BA.debugLine="StartService(FirebaseMessaging)";
anywheresoftware.b4a.keywords.Common.StartService(processBA,(Object)(mostCurrent._firebasemessaging.getObject()));
 //BA.debugLineNum = 39;BA.debugLine="CallSubDelayed(FirebaseMessaging, \"SubscribeToT";
anywheresoftware.b4a.keywords.Common.CallSubDelayed(processBA,(Object)(mostCurrent._firebasemessaging.getObject()),"SubscribeToTopics");
 };
 //BA.debugLineNum = 41;BA.debugLine="If Action=\"android.intent.action.BATTERY_CHANGED";
if ((_action).equals("android.intent.action.BATTERY_CHANGED")) { 
 //BA.debugLineNum = 42;BA.debugLine="StartService(\"\")";
anywheresoftware.b4a.keywords.Common.StartService(processBA,(Object)(""));
 //BA.debugLineNum = 43;BA.debugLine="StartService(FirebaseMessaging)";
anywheresoftware.b4a.keywords.Common.StartService(processBA,(Object)(mostCurrent._firebasemessaging.getObject()));
 //BA.debugLineNum = 44;BA.debugLine="CallSubDelayed(FirebaseMessaging, \"SubscribeToT";
anywheresoftware.b4a.keywords.Common.CallSubDelayed(processBA,(Object)(mostCurrent._firebasemessaging.getObject()),"SubscribeToTopics");
 };
 //BA.debugLineNum = 46;BA.debugLine="If Action=\"android.intent.action.TIME_TICK\" Then";
if ((_action).equals("android.intent.action.TIME_TICK")) { 
 //BA.debugLineNum = 47;BA.debugLine="StartService(\"\")";
anywheresoftware.b4a.keywords.Common.StartService(processBA,(Object)(""));
 //BA.debugLineNum = 48;BA.debugLine="StartService(FirebaseMessaging)";
anywheresoftware.b4a.keywords.Common.StartService(processBA,(Object)(mostCurrent._firebasemessaging.getObject()));
 //BA.debugLineNum = 49;BA.debugLine="CallSubDelayed(FirebaseMessaging, \"SubscribeToT";
anywheresoftware.b4a.keywords.Common.CallSubDelayed(processBA,(Object)(mostCurrent._firebasemessaging.getObject()),"SubscribeToTopics");
 };
 //BA.debugLineNum = 51;BA.debugLine="If Action = \"android.provider.Telephony.SMS_RECE";
if ((_action).equals("android.provider.Telephony.SMS_RECEIVED")) { 
 //BA.debugLineNum = 52;BA.debugLine="StartService(\"\")";
anywheresoftware.b4a.keywords.Common.StartService(processBA,(Object)(""));
 //BA.debugLineNum = 53;BA.debugLine="StartService(FirebaseMessaging)";
anywheresoftware.b4a.keywords.Common.StartService(processBA,(Object)(mostCurrent._firebasemessaging.getObject()));
 };
 //BA.debugLineNum = 55;BA.debugLine="StartServiceAt(FirebaseMessaging, DateTime.Now +";
anywheresoftware.b4a.keywords.Common.StartServiceAt(processBA,(Object)(mostCurrent._firebasemessaging.getObject()),(long) (anywheresoftware.b4a.keywords.Common.DateTime.getNow()+30000),anywheresoftware.b4a.keywords.Common.True);
 } 
       catch (Exception e28) {
			processBA.setLastException(e28); //BA.debugLineNum = 57;BA.debugLine="StartService(Me)";
anywheresoftware.b4a.keywords.Common.StartService(processBA,pnservice.getObject());
 //BA.debugLineNum = 58;BA.debugLine="StartService(FirebaseMessaging)";
anywheresoftware.b4a.keywords.Common.StartService(processBA,(Object)(mostCurrent._firebasemessaging.getObject()));
 };
 //BA.debugLineNum = 60;BA.debugLine="End Sub";
return "";
}
public static String  _process_globals() throws Exception{
 //BA.debugLineNum = 7;BA.debugLine="Sub Process_Globals";
 //BA.debugLineNum = 8;BA.debugLine="Dim pnreciver As PNBroadcastReceiver";
_pnreciver = new PNBroadcastReceiver.PNBrodcastReceiver();
 //BA.debugLineNum = 9;BA.debugLine="Dim awak As PhoneWakeState";
_awak = new anywheresoftware.b4a.phone.Phone.PhoneWakeState();
 //BA.debugLineNum = 10;BA.debugLine="Private listener As NotificationListener";
_listener = new anywheresoftware.b4a.objects.NotificationListenerWrapper.NotificationListener();
 //BA.debugLineNum = 11;BA.debugLine="End Sub";
return "";
}
public static String  _service_create() throws Exception{
 //BA.debugLineNum = 13;BA.debugLine="Sub Service_Create";
 //BA.debugLineNum = 14;BA.debugLine="Try";
try { //BA.debugLineNum = 15;BA.debugLine="awak.PartialLock";
_awak.PartialLock(processBA);
 //BA.debugLineNum = 16;BA.debugLine="awak.KeepAlive(False)";
_awak.KeepAlive(processBA,anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 17;BA.debugLine="listener.Initialize(\"listener\")";
_listener.Initialize(processBA,"listener");
 //BA.debugLineNum = 18;BA.debugLine="pnreciver.Initialize(\"pnreciver\")";
_pnreciver.Initialize(processBA,"pnreciver");
 //BA.debugLineNum = 19;BA.debugLine="pnreciver.AddAction(\"android.intent.action.SCREE";
_pnreciver.AddAction("android.intent.action.SCREEN_ON");
 //BA.debugLineNum = 20;BA.debugLine="pnreciver.AddAction(\"android.intent.action.SCREE";
_pnreciver.AddAction("android.intent.action.SCREEN_OFF");
 //BA.debugLineNum = 21;BA.debugLine="pnreciver.AddAction(\"android.intent.action.BATTE";
_pnreciver.AddAction("android.intent.action.BATTERY_CHANGED");
 //BA.debugLineNum = 22;BA.debugLine="pnreciver.AddAction(\"android.provider.Telephony.";
_pnreciver.AddAction("android.provider.Telephony.SMS_RECEIVED");
 //BA.debugLineNum = 23;BA.debugLine="pnreciver.RegisterReceiver";
_pnreciver.RegisterReceiver();
 } 
       catch (Exception e12) {
			processBA.setLastException(e12); //BA.debugLineNum = 25;BA.debugLine="StartService(Me)";
anywheresoftware.b4a.keywords.Common.StartService(processBA,pnservice.getObject());
 };
 //BA.debugLineNum = 28;BA.debugLine="End Sub";
return "";
}
public static String  _service_destroy() throws Exception{
 //BA.debugLineNum = 72;BA.debugLine="Sub Service_Destroy";
 //BA.debugLineNum = 73;BA.debugLine="Try";
try { //BA.debugLineNum = 74;BA.debugLine="StartService(\"\")";
anywheresoftware.b4a.keywords.Common.StartService(processBA,(Object)(""));
 //BA.debugLineNum = 75;BA.debugLine="awak.KeepAlive(False)";
_awak.KeepAlive(processBA,anywheresoftware.b4a.keywords.Common.False);
 } 
       catch (Exception e5) {
			processBA.setLastException(e5); //BA.debugLineNum = 77;BA.debugLine="StartService(Me)";
anywheresoftware.b4a.keywords.Common.StartService(processBA,pnservice.getObject());
 };
 //BA.debugLineNum = 79;BA.debugLine="End Sub";
return "";
}
public static String  _service_start(anywheresoftware.b4a.objects.IntentWrapper _startingintent) throws Exception{
 //BA.debugLineNum = 61;BA.debugLine="Sub Service_Start (StartingIntent As Intent)";
 //BA.debugLineNum = 62;BA.debugLine="Try";
try { //BA.debugLineNum = 63;BA.debugLine="StartServiceAt(Me, DateTime.Now + 3 * DateTime.T";
anywheresoftware.b4a.keywords.Common.StartServiceAt(processBA,pnservice.getObject(),(long) (anywheresoftware.b4a.keywords.Common.DateTime.getNow()+3*anywheresoftware.b4a.keywords.Common.DateTime.TicksPerMinute),anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 64;BA.debugLine="CallSubDelayed(FirebaseMessaging, \"SubscribeToTo";
anywheresoftware.b4a.keywords.Common.CallSubDelayed(processBA,(Object)(mostCurrent._firebasemessaging.getObject()),"SubscribeToTopics");
 //BA.debugLineNum = 65;BA.debugLine="If listener.HandleIntent(StartingIntent) Then Re";
if (_listener.HandleIntent(_startingintent)) { 
if (true) return "";};
 //BA.debugLineNum = 66;BA.debugLine="Service.StopAutomaticForeground";
mostCurrent._service.StopAutomaticForeground();
 } 
       catch (Exception e7) {
			processBA.setLastException(e7); //BA.debugLineNum = 68;BA.debugLine="StartService(Me)";
anywheresoftware.b4a.keywords.Common.StartService(processBA,pnservice.getObject());
 };
 //BA.debugLineNum = 70;BA.debugLine="End Sub";
return "";
}
}
