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

Commit 1a399cda authored by Mady Mellor's avatar Mady Mellor
Browse files

Fix bubble notifications not being removed when permission revoked

When the notification permission is revoked, we don't get a ranking
update, instead the notifications get canceled with reason package
banned. The notification permission was introduced post-bubbles so
this is something that got missed I think, usually removals come
via the ranking updates (e.g. notif channel is stopped or bubble
option on that channel is removed would cause a ranking update).

Fix for this is to allow onEntryRemovals for package banned to remove
a bubble.

Flag: EXEMPT bug fix
Test: manual - add some bubbles, revoke the notification permission,
               observe that the bubbles are removed
Test: atest BubblesTest
Bug: 363118567
Change-Id: I51b3bb72429bfd6e04854c83c9f1c7d58d144bce
parent 1ce71c6e
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import static android.provider.Settings.Secure.NOTIFICATION_BUBBLES;
import static android.service.notification.NotificationListenerService.REASON_APP_CANCEL;
import static android.service.notification.NotificationListenerService.REASON_APP_CANCEL_ALL;
import static android.service.notification.NotificationListenerService.REASON_GROUP_SUMMARY_CANCELED;
import static android.service.notification.NotificationListenerService.REASON_PACKAGE_BANNED;
import static android.service.notification.NotificationStats.DISMISSAL_BUBBLE;
import static android.service.notification.NotificationStats.DISMISS_SENTIMENT_NEUTRAL;

@@ -449,7 +450,8 @@ public class BubblesManager {
            @Override
            public void onEntryRemoved(NotificationEntry entry,
                    @NotifCollection.CancellationReason int reason) {
                if (reason == REASON_APP_CANCEL || reason == REASON_APP_CANCEL_ALL) {
                if (reason == REASON_APP_CANCEL || reason == REASON_APP_CANCEL_ALL
                        || reason == REASON_PACKAGE_BANNED) {
                    BubblesManager.this.onEntryRemoved(entry);
                }
            }
+13 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import static android.service.notification.NotificationListenerService.NOTIFICAT
import static android.service.notification.NotificationListenerService.NOTIFICATION_CHANNEL_OR_GROUP_UPDATED;
import static android.service.notification.NotificationListenerService.REASON_APP_CANCEL;
import static android.service.notification.NotificationListenerService.REASON_GROUP_SUMMARY_CANCELED;
import static android.service.notification.NotificationListenerService.REASON_PACKAGE_BANNED;

import static androidx.test.ext.truth.content.IntentSubject.assertThat;

@@ -1099,6 +1100,18 @@ public class BubblesTest extends SysuiTestCase {
        assertFalse(mBubbleController.hasBubbles());
    }

    @Test
    public void testNotifsBanned_entryListenerRemove() {
        mEntryListener.onEntryAdded(mRow);
        mBubbleController.updateBubble(mBubbleEntry);

        assertTrue(mBubbleController.hasBubbles());

        // Removes the notification
        mEntryListener.onEntryRemoved(mRow, REASON_PACKAGE_BANNED);
        assertFalse(mBubbleController.hasBubbles());
    }

    @Test
    public void removeBubble_intercepted() {
        mEntryListener.onEntryAdded(mRow);