Commit 6fbf61a
committed
Changed|Fixed(JobSchedulerAPI): Fix
The `ResultReturner.returnData()` will be called once for each action.
The schedule job action will not print all pending jobs at end and only the pending job that was scheduled if successful. Users should use `termux-job-scheduler -p` to get all pending jobs.
The `termux-job-scheduler --p` action will print `No jobs found` instead of `No pending jobs` if no pending job exists.
The `termux-job-scheduler --cancel-all` action will now print all jobs to be cancelled, or `No jobs found` found.
The job description will use `4` spaces instead of a tab after the path.
```
Error in ResultReturner:
java.io.IOException: Connection refused
at android.net.LocalSocketImpl.connectLocal(Native Method)
at android.net.LocalSocketImpl.connect(LocalSocketImpl.java:259)
at android.net.LocalSocket.connect(LocalSocket.java:162)
at com.termux.api.util.ResultReturner.lambda$returnData$0(ResultReturner.java:250)
at com.termux.api.util.ResultReturner$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)
at java.lang.Thread.run(Thread.java:1119)
Suppressed: java.lang.Exception: Called by:
at com.termux.api.util.ResultReturner.returnData(ResultReturner.java:239)
at com.termux.api.apis.JobSchedulerAPI.displayPendingJobs(JobSchedulerAPI.java:197)
at com.termux.api.apis.JobSchedulerAPI.onReceive(JobSchedulerAPI.java:181)
at com.termux.api.TermuxApiReceiver.doWork(TermuxApiReceiver.java:146)
at com.termux.api.TermuxApiReceiver.onReceive(TermuxApiReceiver.java:65)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:5029)
at android.app.ActivityThread.-$$Nest$mhandleReceiver(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2577)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loopOnce(Looper.java:248)
at android.os.Looper.loop(Looper.java:338)
at android.app.ActivityThread.main(ActivityThread.java:9067)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:593)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:932)
`
8000
``
```shell
~ $ termux-job-scheduler -s ~/test1.sh --period-ms 900000 --job-id 1
Scheduling Job 1: /data/data/com.termux/files/home/test1.sh (periodic: 900000ms) (battery not low) (network: NetworkRequest [ NONE id=0, [ Capabilities: INTERNET&TRUSTED&VALIDATED&NOT_VCN_MANAGED&NOT_BANDWIDTH_CONSTRAINED Uid: 10215 UnderlyingNetworks: Null] ]) - response 1
Pending Job 1: /data/data/com.termux/files/home/test1.sh (periodic: 900000ms) (battery not low) (network: NetworkRequest [ NONE id=0, [ Capabilities: INTERNET&TRUSTED&VALIDATED&NOT_VCN_MANAGED&NOT_BANDWIDTH_CONSTRAINED Uid: 10215 UnderlyingNetworks: Null] ])
~ $ termux-job-scheduler -s ~/test2.sh --period-ms 900000 --job-id 2
Scheduling Job 2: /data/data/com.termux/files/home/test2.sh (periodic: 900000ms) (battery not low) (network: NetworkRequest [ NONE id=0, [ Capabilities: INTERNET&TRUSTED&VALIDATED&NOT_VCN_MANAGED&NOT_BANDWIDTH_CONSTRAINED Uid: 10215 UnderlyingNetworks: Null] ]) - response 1
Pending Job 2: /data/data/com.termux/files/home/test2.sh (periodic: 900000ms) (battery not low) (network: NetworkRequest [ NONE id=0, [ Capabilities: INTERNET&TRUSTED&VALIDATED&NOT_VCN_MANAGED&NOT_BANDWIDTH_CONSTRAINED Uid: 10215 UnderlyingNetworks: Null] ])
~ $ termux-job-scheduler -s ~/test3.sh --period-ms 900000 --job-id 3
Scheduling Job 3: /data/data/com.termux/files/home/test3.sh (periodic: 900000ms) (battery not low) (network: NetworkRequest [ NONE id=0, [ Capabilities: INTERNET&TRUSTED&VALIDATED&NOT_VCN_MANAGED&NOT_BANDWIDTH_CONSTRAINED Uid: 10215 UnderlyingNetworks: Null] ]) - response 1
Pending Job 3: /data/data/com.termux/files/home/test3.sh (periodic: 900000ms) (battery not low) (network: NetworkRequest [ NONE id=0, [ Capabilities: INTERNET&TRUSTED&VALIDATED&NOT_VCN_MANAGED&NOT_BANDWIDTH_CONSTRAINED Uid: 10215 UnderlyingNetworks: Null] ])
~ $ termux-job-scheduler -p
Pending Job 3: /data/data/com.termux/files/home/test3.sh (periodic: 900000ms) (battery not low) (network: NetworkRequest [ NONE id=0, [ Capabilities: INTERNET&TRUSTED&VALIDATED&NOT_VCN_MANAGED&NOT_BANDWIDTH_CONSTRAINED Uid: 10215 UnderlyingNetworks: Null] ])
Pending Job 2: /data/data/com.termux/files/home/test2.sh (periodic: 900000ms) (battery not low) (network: NetworkRequest [ NONE id=0, [ Capabilities: INTERNET&TRUSTED&VALIDATED&NOT_VCN_MANAGED&NOT_BANDWIDTH_CONSTRAINED Uid: 10215 UnderlyingNetworks: Null] ])
Pending Job 1: /data/data/com.termux/files/home/test1.sh (periodic: 900000ms) (battery not low) (network: NetworkRequest [ NONE id=0, [ Capabilities: INTERNET&TRUSTED&VALIDATED&NOT_VCN_MANAGED&NOT_BANDWIDTH_CONSTRAINED Uid: 10215 UnderlyingNetworks: Null] ])
~ $ termux-job-scheduler --cancel --job-id 2
Cancelling Job 2: /data/data/com.termux/files/home/test2.sh (periodic: 900000ms) (battery not low) (network: NetworkRequest [ NONE id=0, [ Capabilities: INTERNET&TRUSTED&VALIDATED&NOT_VCN_MANAGED&NOT_BANDWIDTH_CONSTRAINED Uid: 10215 UnderlyingNetworks: Null] ])
~ $ termux-job-scheduler --cancel-all
Cancelling Job 3: /data/data/com.termux/files/home/test3.sh (periodic: 900000ms) (battery not low) (network: NetworkRequest [ NONE id=0, [ Capabilities: INTERNET&TRUSTED&VALIDATED&NOT_VCN_MANAGED&NOT_BANDWIDTH_CONSTRAINED Uid: 10215 UnderlyingNetworks: Null] ])
Cancelling Job 1: /data/data/com.termux/files/home/test1.sh (periodic: 900000ms) (battery not low) (network: NetworkRequest [ NONE id=0, [ Capabilities: INTERNET&TRUSTED&VALIDATED&NOT_VCN_MANAGED&NOT_BANDWIDTH_CONSTRAINED Uid: 10215 UnderlyingNetworks: Null] ])
~ $ termux-job-scheduler --cancel-all
No jobs found
~ $ termux-job-scheduler -p
No jobs found
~ $ termux-job-scheduler --cancel --job-id 2
No job 2 found
```
Closes #762, Closes #773ResultReturner.returnData() being called multiple times for different printing since 51a02f4 and 61262f7 throwing Connection refused exceptions for calls after the first one instead of printing, and also refactor actions out to functions and change action output format1 parent 9be2a6d commit 6fbf61a
File tree
1 file changed
+111
-55
lines changed- app/src/main/java/com/termux/api/apis
1 file changed
+111
-55
lines changedLines changed: 111 additions & 55 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
56 | 57 | | |
57 | 58 | | |
58 | 59 | | |
59 | | - | |
| 60 | + | |
60 | 61 | | |
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
65 | 66 | | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | 67 | | |
71 | | - | |
72 | 68 | | |
73 | 69 | | |
74 | 70 | | |
75 | | - | |
| 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 | + | |
76 | 98 | | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
82 | 106 | | |
83 | 107 | | |
84 | 108 | | |
| |||
108 | 132 | | |
109 | 133 | | |
110 | 134 | | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | 135 | | |
129 | | - | |
| 136 | + | |
| 137 | + | |
130 | 138 | | |
131 | 139 | | |
132 | | - | |
133 | | - | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
134 | 143 | | |
135 | 144 | | |
136 | 145 | | |
| |||
142 | 151 | | |
143 | 152 | | |
144 | 153 | | |
145 | | - | |
| 154 | + | |
| 155 | + | |
146 | 156 | | |
147 | 157 | | |
148 | 158 | | |
| 159 | + | |
149 | 160 | | |
150 | 161 | | |
151 | 162 | | |
| |||
169 | 180 | | |
170 | 181 | | |
171 | 182 | | |
172 | | - | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
173 | 211 | | |
174 | | - | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
175 | 217 | | |
176 | | - | |
177 | | - | |
178 | | - | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
179 | 226 | | |
180 | 227 | | |
181 | | - | |
182 | 228 | | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
183 | 239 | | |
184 | 240 | | |
185 | | - | |
186 | | - | |
187 | | - | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
188 | 244 | | |
189 | | - | |
190 | | - | |
| 245 | + | |
| 246 | + | |
191 | 247 | | |
192 | 248 | | |
193 | 249 | | |
| 250 | + | |
194 | 251 | | |
195 | | - | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
196 | 255 | | |
197 | | - | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
198 | 259 | | |
199 | 260 | | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | 261 | | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
210 | 266 | | |
211 | 267 | | |
212 | 268 | | |
| |||
0 commit comments