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

This commit is contained in:
TreeHugger Robot
2020-08-13 21:50:06 +00:00
committed by Android (Google) Code Review

View File

@@ -134,7 +134,8 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
@IntDef({DISMISS_USER_GESTURE, DISMISS_AGED, DISMISS_TASK_FINISHED, DISMISS_BLOCKED, @IntDef({DISMISS_USER_GESTURE, DISMISS_AGED, DISMISS_TASK_FINISHED, DISMISS_BLOCKED,
DISMISS_NOTIF_CANCEL, DISMISS_ACCESSIBILITY_ACTION, DISMISS_NO_LONGER_BUBBLE, DISMISS_NOTIF_CANCEL, DISMISS_ACCESSIBILITY_ACTION, DISMISS_NO_LONGER_BUBBLE,
DISMISS_USER_CHANGED, DISMISS_GROUP_CANCELLED, DISMISS_INVALID_INTENT, 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}) @Target({FIELD, LOCAL_VARIABLE, PARAMETER})
@interface DismissReason {} @interface DismissReason {}
@@ -151,6 +152,7 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
static final int DISMISS_OVERFLOW_MAX_REACHED = 11; static final int DISMISS_OVERFLOW_MAX_REACHED = 11;
static final int DISMISS_SHORTCUT_REMOVED = 12; static final int DISMISS_SHORTCUT_REMOVED = 12;
static final int DISMISS_PACKAGE_REMOVED = 13; static final int DISMISS_PACKAGE_REMOVED = 13;
static final int DISMISS_NO_BUBBLE_UP = 14;
private final Context mContext; private final Context mContext;
private final NotificationEntryManager mNotificationEntryManager; private final NotificationEntryManager mNotificationEntryManager;
@@ -1243,8 +1245,18 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
rankingMap.getRanking(key, mTmpRanking); rankingMap.getRanking(key, mTmpRanking);
boolean isActiveBubble = mBubbleData.hasAnyBubbleWithKey(key); boolean isActiveBubble = mBubbleData.hasAnyBubbleWithKey(key);
if (isActiveBubble && !mTmpRanking.canBubble()) { if (isActiveBubble && !mTmpRanking.canBubble()) {
mBubbleData.dismissBubbleWithKey(entry.getKey(), // If this entry is no longer allowed to bubble, dismiss with the BLOCKED reason.
BubbleController.DISMISS_BLOCKED); // 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) { } else if (entry != null && mTmpRanking.isBubble() && !isActiveBubble) {
entry.setFlagBubble(true); entry.setFlagBubble(true);
onEntryUpdated(entry); onEntryUpdated(entry);
@@ -1321,8 +1333,10 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
mStackView.removeBubble(bubble); mStackView.removeBubble(bubble);
} }
// If the bubble is removed for user switching, leave the notification in place. // Leave the notification in place if we're dismissing due to user switching, or
if (reason == DISMISS_USER_CHANGED) { // 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; continue;
} }
if (reason == DISMISS_NOTIF_CANCEL) { if (reason == DISMISS_NOTIF_CANCEL) {