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

Commit e717267a authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix race on setCanceledAfterLifetimeExtension" into main

parents 78d71ada 83461490
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -12018,6 +12018,10 @@ public class NotificationManagerService extends SystemService {
        if (record != null && (record.getSbn().getNotification().flags
                & FLAG_LIFETIME_EXTENDED_BY_DIRECT_REPLY) > 0
                && !record.isCanceledAfterLifetimeExtension()) {
            // Mark that the notification is being updated due to cancelation, so it won't
            // be updated again if the app cancels multiple times.
            record.setCanceledAfterLifetimeExtension(true);
            boolean isAppForeground = pkg != null && packageImportance == IMPORTANCE_FOREGROUND;
            // Save the original Record's post silently value, so we can restore it after we send
@@ -12033,9 +12037,6 @@ public class NotificationManagerService extends SystemService {
            PostNotificationTracker tracker = mPostNotificationTrackerFactory.newTracker(null);
            tracker.addCleanupRunnable(() -> {
                synchronized (mNotificationLock) {
                    // Mark that the notification has been updated due to cancelation, so it won't
                    // be updated again if the app cancels multiple times.
                    record.setCanceledAfterLifetimeExtension(true);
                    // Set the post silently status to the record's previous value.
                    record.setPostSilently(savedPostSilentlyState);
                    // Remove FLAG_ONLY_ALERT_ONCE if the notification did not previously have it.
+0 −1
Original line number Diff line number Diff line
@@ -3206,7 +3206,6 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
        // Send two cancelations.
        mBinderService.cancelNotificationWithTag(mPkg, mPkg, sbn.getTag(), sbn.getId(),
                sbn.getUserId());
        waitForIdle();
        mBinderService.cancelNotificationWithTag(mPkg, mPkg, sbn.getTag(), sbn.getId(),
                sbn.getUserId());
        waitForIdle();