-
Notifications
You must be signed in to change notification settings - Fork 2
/
wautch_service.bas
145 lines (100 loc) · 5.46 KB
/
wautch_service.bas
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
B4A=true
Group=Default Group
ModulesStructureVersion=1
Type=Service
Version=7.3
@EndOfDesignText@
#Region Service Attributes
#StartAtBoot: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim rc As RootCmd
Dim fs As MLfiles
' Dim ph As Phone
' Dim PE As PhoneEvents
' Dim BatteryLevel As Int
' Dim BatteryCharging As Boolean
End Sub
'Sub PE_BatteryChanged(Level As Int, Scale As Int, Plugged As Boolean, Intent As Intent)
' BatteryLevel = Level
' BatteryCharging = Plugged
' 'Log("Level: " & Level & "%, Scale: " & Scale & ", Plugged: " & Plugged)
'End Sub
Sub Service_Create
StartService(Schedule)
End Sub
Sub myStart()
File.MakeDir(File.DirInternal, "bin")
File.Copy(File.DirAssets,"busybox",File.DirInternal,"/bin/busybox")
File.Copy(File.DirAssets,"cb_runhaveged",File.DirInternal,"/bin/cb_runhaveged")
File.Copy(File.DirAssets,"haveged",File.DirInternal,"/bin/haveged")
File.Copy(File.DirAssets,"sqlite3",File.DirInternal,"/bin/sqlite3")
File.Copy(File.DirAssets,"cb.sh",File.DirInternal,"/bin/cb.sh")
File.Copy(File.DirAssets,"cb_init.sh",File.DirInternal,"/bin/cb_init.sh")
File.Copy(File.DirAssets,"cb_io.sh",File.DirInternal,"/bin/cb_io.sh")
File.Copy(File.DirAssets,"cb_networking.sh",File.DirInternal,"/bin/cb_networking.sh")
File.Copy(File.DirAssets,"cb_weekly.sh",File.DirInternal,"/bin/cb_weekly.sh")
rc.haveRoot
fs.GetRoot
fs.chmod(File.DirInternal & "/bin/busybox",755)
' File.Copy(File.DirAssets,"busybox",File.DirInternal,"/busybox")
' fs.chmod(File.DirInternal & "/busybox",755)
' ToastMessageShow("run (fs)...",True)
' ph.Shell("toolbox", Array As String("chmod", "-R", "755", File.DirInternal & "/bin"),Null,Null)
' ph.Shell("toolbox", Array As String("chmod", "755", File.DirInternal & "/bin/busybox"),Null,Null)
' ph.Shell("chmod", Array As String(" -R ", " 755 ", File.DirInternal & "/bin"),Null,Null)
' ph.Shell("chmod", Array As String(" 755 ", File.DirInternal & "/bin/busybox"),Null,Null)
fs.chmod(File.DirInternal & "/bin/cb_runhaveged",755)
fs.chmod(File.DirInternal & "/bin/haveged",755)
fs.chmod(File.DirInternal & "/bin/sqlite3",755)
fs.chmod(File.DirInternal & "/bin/cb.sh",755)
fs.chmod(File.DirInternal & "/bin/cb_init.sh",755)
fs.chmod(File.DirInternal & "/bin/cb_io.sh",755)
fs.chmod(File.DirInternal & "/bin/cb_networking.sh",755)
fs.chmod(File.DirInternal & "/bin/cb_weekly.sh",755)
If rc.haveRoot Then
' ToastMessageShow("run (rc)...",True)
rc.execRootCmdSilent(File.DirInternal & "/bin/busybox chmod -R 755 " & File.DirInternal & "/bin")
rc.execRootCmdSilent(File.DirInternal & "/bin/busybox chmod 755 " & File.DirInternal & "/bin/busybox")
rc.execRootCmdSilent( File.DirInternal & "/bin/busybox chmod 755 " & File.DirInternal & "/bin/cb_runhaveged" )
rc.execRootCmdSilent( File.DirInternal & "/bin/busybox chmod 755 " & File.DirInternal & "/bin/haveged" )
rc.execRootCmdSilent( File.DirInternal & "/bin/busybox chmod 755 " & File.DirInternal & "/bin/sqlite3" )
rc.execRootCmdSilent( File.DirInternal & "/bin/busybox chmod 755 " & File.DirInternal & "/bin/cb.sh" )
rc.execRootCmdSilent( File.DirInternal & "/bin/busybox chmod 755 " & File.DirInternal & "/bin/cb_init.sh" )
rc.execRootCmdSilent( File.DirInternal & "/bin/busybox chmod 755 " & File.DirInternal & "/bin/cb_io.sh" )
rc.execRootCmdSilent( File.DirInternal & "/bin/busybox chmod 755 " & File.DirInternal & "/bin/cb_networking.sh" )
rc.execRootCmdSilent( File.DirInternal & "/bin/busybox chmod 755 " & File.DirInternal & "/bin/cb_weekly.sh" )
rc.execRootCmdSilent( "/system/bin/toolbox chmod -R 755 " & File.DirInternal & "/bin" )
rc.execRootCmdSilent( "/system/bin/toolbox chmod 755 " & File.DirInternal & "/bin/busybox" )
rc.execRootCmdSilent( "/system/bin/toybox chmod -R 755 " & File.DirInternal & "/bin" )
rc.execRootCmdSilent( "/system/bin/toybox chmod 755 " & File.DirInternal & "/bin/busybox" )
rc.execRootCmdSilent( "/system/bin/chmod -R 755 " & File.DirInternal & "/bin" )
rc.execRootCmdSilent( "/system/bin/chmod 755 " & File.DirInternal & "/bin/busybox" )
' rc.execRootCmdSilent( "/system/bin/chmod 755 " & File.DirInternal & "/busybox" )
' rc.execRootCmdSilent("su - shell -c su -c toybox chmod 755 " & File.DirInternal & "/busybox")
' rc.execRootCmdSilent("su - shell -c su -c toolbox chmod 755 " & File.DirInternal & "/busybox")
' rc.execRootCmdSilent("su - shell -c su -c chmod 755 " & File.DirInternal & "/busybox")
End If
Dim hour As Int
hour = DateTime.GetHour(DateTime.Now)
If hour = 3 Then
If rc.haveRoot Then
' ToastMessageShow("run...",True)
' rc.execRootCmdSilent( File.DirInternal & "/bin/busybox setsid " & File.DirInternal & "/bin/busybox sh " & File.DirInternal & "/bin/cb.sh RUN FORCE" )
rc.execRootCmdSilent( File.DirInternal & "/bin/busybox setsid " & File.DirInternal & "/bin/busybox sh " & File.DirInternal & "/bin/cb_weekly.sh RUN FORCE" )
End If
End If
End Sub
Sub Service_Start (StartingIntent As Intent)
Dim hour As Int
Dim timeofday As Long
hour = DateTime.GetHour(DateTime.Now)
timeofday = DateTime.Now + ( ( 27 - hour ) * 3600000 )
StartServiceAt("", timeofday , True)
myStart
Service.StopAutomaticForeground 'Call this when the background task completes (if there is one)
End Sub
Sub Service_Destroy
End Sub