diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java index 2b8c1eb455684..9c3bc288a58f4 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java @@ -1061,6 +1061,9 @@ public class BubbleController implements ConfigurationChangeListener { && mBubbleData.hasOverflowBubbleWithKey(notif.getKey())) { // Update the bubble but don't promote it out of overflow Bubble b = mBubbleData.getOverflowBubbleWithKey(notif.getKey()); + if (notif.isBubble()) { + notif.setFlagBubble(false); + } b.setEntry(notif); } else if (mBubbleData.isSuppressedWithLocusId(notif.getLocusId())) { // Update the bubble but don't promote it out of overflow @@ -1176,7 +1179,7 @@ public class BubbleController implements ConfigurationChangeListener { // notification, so that the bubble will be re-created if shouldBubbleUp returns // true. mBubbleData.dismissBubbleWithKey(key, DISMISS_NO_BUBBLE_UP); - } else if (entry != null && mTmpRanking.isBubble() && !isActive) { + } else if (entry != null && mTmpRanking.isBubble() && !isActiveOrInOverflow) { entry.setFlagBubble(true); onEntryUpdated(entry, shouldBubbleUp, /* fromSystem= */ true); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java b/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java index 25f83fcd4bcca..ff95969f1e53d 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java @@ -1433,6 +1433,35 @@ public class BubblesTest extends SysuiTestCase { assertThat(mBubbleData.hasBubbleInStackWithKey(mBubbleEntry.getKey())).isFalse(); } + /** + * Verifies that if a bubble is in the overflow and a non-interruptive notification update + * comes in for it with FLAG_BUBBLE that the flag is removed. + */ + @Test + public void testNonInterruptiveUpdate_doesntOverrideOverflowFlagBubble() { + mEntryListener.onEntryAdded(mRow); + mEntryListener.onEntryUpdated(mRow, /* fromSystem= */ true); + assertBubbleNotificationNotSuppressedFromShade(mBubbleEntry); + + // Dismiss the bubble so it's in the overflow + mBubbleController.removeBubble( + mRow.getKey(), Bubbles.DISMISS_USER_GESTURE); + assertThat(mBubbleData.hasOverflowBubbleWithKey(mRow.getKey())).isTrue(); + // Once it's in the overflow it's not actively a bubble (doesn't have FLAG_BUBBLE) + Bubble b = mBubbleData.getOverflowBubbleWithKey(mBubbleEntry.getKey()); + assertThat(b.isBubble()).isFalse(); + + // Send a non-notifying update that has FLAG_BUBBLE + mRow.getSbn().getNotification().flags = FLAG_BUBBLE; + assertThat(mRow.getSbn().getNotification().isBubbleNotification()).isTrue(); + mBubbleController.updateBubble(mBubbleEntry, + /* suppressFlyout= */ false, /* showInShade= */ true); + + // Verify that it still doesn't have FLAG_BUBBLE because it's in the overflow. + b = mBubbleData.getOverflowBubbleWithKey(mBubbleEntry.getKey()); + assertThat(b.isBubble()).isFalse(); + } + @Test public void testNonSystemUpdatesIgnored() { mEntryListener.onEntryAdded(mRow);