From 3b85a3f0ecc94577703a1542678bb4b27946b581 Mon Sep 17 00:00:00 2001 From: Aleksandras Kostarevas Date: Wed, 17 Jan 2024 15:55:30 +0200 Subject: [PATCH] Specify FLAG_IMMUTABLE for pending intent --- .../org/futo/inputmethod/dictionarypack/DictionaryService.java | 2 +- java/src/org/futo/inputmethod/latin/xlm/TrainingWorker.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/java/src/org/futo/inputmethod/dictionarypack/DictionaryService.java b/java/src/org/futo/inputmethod/dictionarypack/DictionaryService.java index 9274b17ea..c3d92b8b3 100644 --- a/java/src/org/futo/inputmethod/dictionarypack/DictionaryService.java +++ b/java/src/org/futo/inputmethod/dictionarypack/DictionaryService.java @@ -230,7 +230,7 @@ public final class DictionaryService extends Service { final long alarmTime = now + new Random().nextInt(MAX_ALARM_DELAY_MILLIS); final Intent updateIntent = new Intent(DictionaryPackConstants.UPDATE_NOW_INTENT_ACTION); final PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, - updateIntent, PendingIntent.FLAG_CANCEL_CURRENT); + updateIntent, PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE); // We set the alarm in the type that doesn't forcefully wake the device // from sleep, but fires the next time the device actually wakes for any diff --git a/java/src/org/futo/inputmethod/latin/xlm/TrainingWorker.kt b/java/src/org/futo/inputmethod/latin/xlm/TrainingWorker.kt index abbfd8b10..8a8160fd5 100644 --- a/java/src/org/futo/inputmethod/latin/xlm/TrainingWorker.kt +++ b/java/src/org/futo/inputmethod/latin/xlm/TrainingWorker.kt @@ -187,7 +187,7 @@ class TrainingWorker(context: Context, parameters: WorkerParameters) : Coroutine val cancel = "Halt" // This PendingIntent can be used to cancel the worker val intent = WorkManager.getInstance(applicationContext) - .createCancelPendingIntent(getId()) + .createCancelPendingIntent(id) // Create a Notification channel if necessary if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {