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

Commit 052f3861 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Dismiss bubbles if shouldBubbleUp returns false (e.g. DND is enabled...

Merge "Dismiss bubbles if shouldBubbleUp returns false (e.g. DND is enabled and configured to hide that bubble)." into rvc-qpr-dev am: 19443611

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

Change-Id: Ie0bdec628a191735d992bce3a6948cb4cb9cef7f
parents b018ff78 19443611
Loading
Loading
Loading
Loading
+19 −5
Original line number Diff line number Diff line
@@ -134,7 +134,8 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
    @IntDef({DISMISS_USER_GESTURE, DISMISS_AGED, DISMISS_TASK_FINISHED, DISMISS_BLOCKED,
            DISMISS_NOTIF_CANCEL, DISMISS_ACCESSIBILITY_ACTION, DISMISS_NO_LONGER_BUBBLE,
            DISMISS_USER_CHANGED, DISMISS_GROUP_CANCELLED, DISMISS_INVALID_INTENT,
            DISMISS_OVERFLOW_MAX_REACHED, DISMISS_SHORTCUT_REMOVED, DISMISS_PACKAGE_REMOVED})
            DISMISS_OVERFLOW_MAX_REACHED, DISMISS_SHORTCUT_REMOVED, DISMISS_PACKAGE_REMOVED,
            DISMISS_NO_BUBBLE_UP})
    @Target({FIELD, LOCAL_VARIABLE, PARAMETER})
    @interface DismissReason {}

@@ -151,6 +152,7 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
    static final int DISMISS_OVERFLOW_MAX_REACHED = 11;
    static final int DISMISS_SHORTCUT_REMOVED = 12;
    static final int DISMISS_PACKAGE_REMOVED = 13;
    static final int DISMISS_NO_BUBBLE_UP = 14;

    private final Context mContext;
    private final NotificationEntryManager mNotificationEntryManager;
@@ -1243,8 +1245,18 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
            rankingMap.getRanking(key, mTmpRanking);
            boolean isActiveBubble = mBubbleData.hasAnyBubbleWithKey(key);
            if (isActiveBubble && !mTmpRanking.canBubble()) {
                mBubbleData.dismissBubbleWithKey(entry.getKey(),
                        BubbleController.DISMISS_BLOCKED);
                // If this entry is no longer allowed to bubble, dismiss with the BLOCKED reason.
                // This means that the app or channel's ability to bubble has been revoked.
                mBubbleData.dismissBubbleWithKey(
                        key, BubbleController.DISMISS_BLOCKED);
            } else if (isActiveBubble
                    && !mNotificationInterruptStateProvider.shouldBubbleUp(entry)) {
                // If this entry is allowed to bubble, but cannot currently bubble up, dismiss it.
                // This happens when DND is enabled and configured to hide bubbles. Dismissing with
                // the reason DISMISS_NO_BUBBLE_UP will retain the underlying notification, so that
                // the bubble will be re-created if shouldBubbleUp returns true.
                mBubbleData.dismissBubbleWithKey(
                        key, BubbleController.DISMISS_NO_BUBBLE_UP);
            } else if (entry != null && mTmpRanking.isBubble() && !isActiveBubble) {
                entry.setFlagBubble(true);
                onEntryUpdated(entry);
@@ -1321,8 +1333,10 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
                    mStackView.removeBubble(bubble);
                }

                // If the bubble is removed for user switching, leave the notification in place.
                if (reason == DISMISS_USER_CHANGED) {
                // Leave the notification in place if we're dismissing due to user switching, or
                // because DND is suppressing the bubble. In both of those cases, we need to be able
                // to restore the bubble from the notification later.
                if (reason == DISMISS_USER_CHANGED || reason == DISMISS_NO_BUBBLE_UP) {
                    continue;
                }
                if (reason == DISMISS_NOTIF_CANCEL) {