summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Treehugger Robot <treehugger-gerrit@google.com> 2021-05-06 15:07:46 +0000
committer Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2021-05-06 15:07:46 +0000
commitf82ddac1f5dc720fb5a2f30b50a816611aa0747a (patch)
treede8a38f2143ab1fcaf7c94d609fdfa55c2b022a7
parentf4b981eb46b82b5d976799f68e9c3a10de54c8ed (diff)
parentc60c7a1a4a381d6f6d257516c063b985766398c4 (diff)
Merge "Cancel NotificationTimeout alarms when canceling notification" am: 9e7ac57a6c am: c60c7a1a4a
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1695745 Change-Id: I4cff81ddbbfb6d5b250ed210399ef72619daf8e1
-rwxr-xr-xservices/core/java/com/android/server/notification/NotificationManagerService.java15
1 files changed, 15 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index c01ee5e2b50a..5babfeb08f76 100755
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -7745,6 +7745,21 @@ public class NotificationManagerService extends SystemService {
int rank, int count, boolean wasPosted, String listenerName) {
final String canceledKey = r.getKey();
+ // Get pending intent used to create alarm, use FLAG_NO_CREATE if PendingIntent
+ // does not already exist, then null will be returned.
+ final PendingIntent pi = PendingIntent.getBroadcast(getContext(),
+ REQUEST_CODE_TIMEOUT,
+ new Intent(ACTION_NOTIFICATION_TIMEOUT)
+ .setData(new Uri.Builder().scheme(SCHEME_TIMEOUT)
+ .appendPath(r.getKey()).build())
+ .addFlags(Intent.FLAG_RECEIVER_FOREGROUND),
+ PendingIntent.FLAG_NO_CREATE | PendingIntent.FLAG_IMMUTABLE);
+
+ // Cancel alarm corresponding to pi.
+ if (pi != null) {
+ mAlarmManager.cancel(pi);
+ }
+
// Record caller.
recordCallerLocked(r);