From b5286610b5184552d56d5bef0f81fe85e702817d Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Tue, 6 Aug 2019 00:32:49 +0200 Subject: [PATCH] Create new job id for each file executed See https://github.com/termux/termux-boot/pull/11 --- app/src/main/java/com/termux/boot/BootJobService.java | 2 +- app/src/main/java/com/termux/boot/BootReceiver.java | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/termux/boot/BootJobService.java b/app/src/main/java/com/termux/boot/BootJobService.java index 4ddbcd4..55474d2 100644 --- a/app/src/main/java/com/termux/boot/BootJobService.java +++ b/app/src/main/java/com/termux/boot/BootJobService.java @@ -13,7 +13,7 @@ public class BootJobService extends JobService { public static final String SCRIPT_FILE_PATH = "com.termux.boot.script_path"; - private static final String TAG = "termux:boot JobService"; + private static final String TAG = "termux"; // Constants from TermuxService. private static final String TERMUX_SERVICE = "com.termux.app.TermuxService"; diff --git a/app/src/main/java/com/termux/boot/BootReceiver.java b/app/src/main/java/com/termux/boot/BootReceiver.java index 9f7a265..89ee518 100644 --- a/app/src/main/java/com/termux/boot/BootReceiver.java +++ b/app/src/main/java/com/termux/boot/BootReceiver.java @@ -15,6 +15,9 @@ public class BootReceiver extends BroadcastReceiver { + public static final int TERMUX_BOOT_JOB_ID_BASE = 1000; + static int jobId = TERMUX_BOOT_JOB_ID_BASE; + @Override public void onReceive(Context context, Intent intent) { if (!Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) return; @@ -40,7 +43,7 @@ public void onReceive(Context context, Intent intent) { extras.putString(BootJobService.SCRIPT_FILE_PATH, file.getAbsolutePath()); ComponentName serviceComponent = new ComponentName(context, BootJobService.class); - JobInfo job = new JobInfo.Builder(0, serviceComponent) + JobInfo job = new JobInfo.Builder(jobId++, serviceComponent) .setExtras(extras) .setOverrideDeadline(3 * 1000) .build();