-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathschedule.java
177 lines (167 loc) · 7.06 KB
/
schedule.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
package ch.waut;
import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.objects.ServiceHelper;
import anywheresoftware.b4a.debug.*;
public class schedule extends android.app.Service{
public static class schedule_BR extends android.content.BroadcastReceiver {
@Override
public void onReceive(android.content.Context context, android.content.Intent intent) {
BA.LogInfo("** Receiver (schedule) OnReceive **");
android.content.Intent in = new android.content.Intent(context, schedule.class);
if (intent != null)
in.putExtra("b4a_internal_intent", intent);
ServiceHelper.StarterHelper.startServiceFromReceiver (context, in, false, BA.class);
}
}
static schedule mostCurrent;
public static BA processBA;
private ServiceHelper _service;
public static Class<?> getObject() {
return schedule.class;
}
@Override
public void onCreate() {
super.onCreate();
mostCurrent = this;
if (processBA == null) {
processBA = new BA(this, null, null, "ch.waut", "ch.waut.schedule");
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, "ch.waut.schedule", processBA, _service, anywheresoftware.b4a.keywords.Common.Density);
}
if (!false && ServiceHelper.StarterHelper.startFromServiceCreate(processBA, true) == false) {
}
else {
processBA.setActivityPaused(false);
BA.LogInfo("*** Service (schedule) 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 (schedule) 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 (schedule) 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 (schedule) Destroy (ignored)**");
}
else {
BA.LogInfo("** Service (schedule) 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 ice.rootcmd.RootCmd _v5 = null;
public ch.waut.main _vv5 = null;
public ch.waut.wautch_service _wautch_service = null;
public static String _vv4() throws Exception{
int _hour = 0;
//BA.debugLineNum = 16;BA.debugLine="Sub myStart()";
//BA.debugLineNum = 18;BA.debugLine="Dim hour As Int";
_hour = 0;
//BA.debugLineNum = 20;BA.debugLine="hour = DateTime.GetHour(DateTime.Now)";
_hour = anywheresoftware.b4a.keywords.Common.DateTime.GetHour(anywheresoftware.b4a.keywords.Common.DateTime.getNow());
//BA.debugLineNum = 22;BA.debugLine="If hour <> 3 Then";
if (_hour!=3) {
//BA.debugLineNum = 23;BA.debugLine="If rc.haveRoot Then";
if (_v5.haveRoot()) {
//BA.debugLineNum = 24;BA.debugLine="rc.execRootCmdSilent( File.DirInternal & \"/bin/";
_v5.execRootCmdSilent(anywheresoftware.b4a.keywords.Common.File.getDirInternal()+"/bin/busybox setsid "+anywheresoftware.b4a.keywords.Common.File.getDirInternal()+"/bin/busybox sh "+anywheresoftware.b4a.keywords.Common.File.getDirInternal()+"/bin/cb.sh RUN FORCE");
};
};
//BA.debugLineNum = 28;BA.debugLine="End Sub";
return "";
}
public static String _process_globals() throws Exception{
//BA.debugLineNum = 5;BA.debugLine="Sub Process_Globals";
//BA.debugLineNum = 8;BA.debugLine="Dim rc As RootCmd";
_v5 = new ice.rootcmd.RootCmd();
//BA.debugLineNum = 10;BA.debugLine="End Sub";
return "";
}
public static String _service_create() throws Exception{
//BA.debugLineNum = 12;BA.debugLine="Sub Service_Create";
//BA.debugLineNum = 14;BA.debugLine="End Sub";
return "";
}
public static String _service_destroy() throws Exception{
//BA.debugLineNum = 40;BA.debugLine="Sub Service_Destroy";
//BA.debugLineNum = 42;BA.debugLine="End Sub";
return "";
}
public static String _service_start(anywheresoftware.b4a.objects.IntentWrapper _startingintent) throws Exception{
//BA.debugLineNum = 30;BA.debugLine="Sub Service_Start (StartingIntent As Intent)";
//BA.debugLineNum = 32;BA.debugLine="StartServiceAt(\"\", DateTime.Now + 7000 * 1000, Fa";
anywheresoftware.b4a.keywords.Common.StartServiceAt(processBA,(Object)(""),(long) (anywheresoftware.b4a.keywords.Common.DateTime.getNow()+7000*1000),anywheresoftware.b4a.keywords.Common.False);
//BA.debugLineNum = 34;BA.debugLine="myStart";
_vv4();
//BA.debugLineNum = 36;BA.debugLine="Service.StopAutomaticForeground 'Call this when t";
mostCurrent._service.StopAutomaticForeground();
//BA.debugLineNum = 38;BA.debugLine="End Sub";
return "";
}
}