Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c60c7a1a authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Cancel NotificationTimeout alarms when canceling notification" am: 9e7ac57a

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1695745

Change-Id: I51cc9a62275b8a4f28365b619e74cd96cc7b58f6
parents 91a9308a 9e7ac57a
Loading
Loading
Loading
Loading
+16 −1
Original line number Original line Diff line number Diff line
@@ -6850,7 +6850,7 @@ public class NotificationManagerService extends SystemService {
                                    .appendPath(record.getKey()).build())
                                    .appendPath(record.getKey()).build())
                            .addFlags(Intent.FLAG_RECEIVER_FOREGROUND)
                            .addFlags(Intent.FLAG_RECEIVER_FOREGROUND)
                            .putExtra(EXTRA_KEY, record.getKey()),
                            .putExtra(EXTRA_KEY, record.getKey()),
                    PendingIntent.FLAG_UPDATE_CURRENT);
                    PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
            mAlarmManager.setExactAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP,
            mAlarmManager.setExactAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP,
                    mSystemClock.elapsedRealtime() + record.getNotification().getTimeoutAfter(),
                    mSystemClock.elapsedRealtime() + record.getNotification().getTimeoutAfter(),
                    pi);
                    pi);
@@ -7713,6 +7713,21 @@ public class NotificationManagerService extends SystemService {
            int rank, int count, boolean wasPosted, String listenerName) {
            int rank, int count, boolean wasPosted, String listenerName) {
        final String canceledKey = r.getKey();
        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.
        // Record caller.
        recordCallerLocked(r);
        recordCallerLocked(r);