You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Changed|Fixed(JobSchedulerAPI): Fix ResultReturner.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 format
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)
```
```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#773
0 commit comments