From 4c8e0bd83bc052c5b5a9fe0b30fae8a88c4749ae Mon Sep 17 00:00:00 2001 From: Andrew Gunnerson Date: Thu, 20 Jul 2023 15:18:46 -0400 Subject: [PATCH] NotificationActionService: PendingIntent needs to be unique across app restarts Otherwise, an Intent from a previous PendingIntent with the same notification ID might be used, causing the wrong file to be deleted. Signed-off-by: Andrew Gunnerson --- .../main/java/com/chiller3/bcr/NotificationActionService.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/chiller3/bcr/NotificationActionService.kt b/app/src/main/java/com/chiller3/bcr/NotificationActionService.kt index 3a2530731..aa818c1a8 100644 --- a/app/src/main/java/com/chiller3/bcr/NotificationActionService.kt +++ b/app/src/main/java/com/chiller3/bcr/NotificationActionService.kt @@ -27,7 +27,8 @@ class NotificationActionService : Service() { ) = Intent(context, NotificationActionService::class.java).apply { action = ACTION_DELETE_URI // Unused, but guarantees filterEquals() uniqueness for use with PendingIntents - data = Uri.fromParts("notification", notificationId.toString(), null) + val uniqueSsp = files.asSequence().map { it.uri.toString() }.joinToString("\u0000") + data = Uri.fromParts("unused", uniqueSsp, null) putExtra(EXTRA_FILES, ArrayList(files)) putExtra(EXTRA_NOTIFICATION_ID, notificationId) } @@ -76,6 +77,7 @@ class NotificationActionService : Service() { } handler.post { + Log.i(TAG, "Cancelling notification $notificationId") notificationManager.cancel(notificationId) stopSelf(startId) }