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

Commit 55524d2a authored by Mady Mellor's avatar Mady Mellor
Browse files

Don't bubble things when we shouldn't

I haven't been able to repro these issues outside of tests on
cuttlefish, but I think logically these fixes make sense & seem to
resolve the test issue.

- Ensure non-notifying updates to bubbles in the overflow don't
  clobber the FLAG_BUBBLE state
- onRankingUpdate should only bubble stuff up if it's not active and
  not in the overflow (previously just not active)

Bug: 238896626
Test: atest BubblesTest#testNonInterruptiveUpdate_doesntOverrideOverflowFlagBubble
Test: atest --no-bazel-mode --iterations 20 PlatformScenarioTests:android.platform.test.scenario.sysui.bubble.ExpandAndDragToDismissTest
      (with vadim's changes & another CL)
Change-Id: Id588c1130e62533a23dc931dfb4fe3c92125a905
parent 6a2fc4a9
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -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);
            }
+29 −0
Original line number Diff line number Diff line
@@ -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);