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

Commit e4d18345 authored by Mady Mellor's avatar Mady Mellor
Browse files

Tell NoMan to update the auto-expand flag

Bug: 226316876
Test: atest BubblesTest NewNotifPipelineBubblesTest
Change-Id: Iad01b8f35d3481ab0bf080e6319ea9452e9f628d
parent 40422db4
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -771,12 +771,17 @@ public class Bubble implements BubbleViewProvider {
        return isEnabled(Notification.BubbleMetadata.FLAG_AUTO_EXPAND_BUBBLE);
    }

    void setShouldAutoExpand(boolean shouldAutoExpand) {
    @VisibleForTesting
    public void setShouldAutoExpand(boolean shouldAutoExpand) {
        boolean prevAutoExpand = shouldAutoExpand();
        if (shouldAutoExpand) {
            enable(Notification.BubbleMetadata.FLAG_AUTO_EXPAND_BUBBLE);
        } else {
            disable(Notification.BubbleMetadata.FLAG_AUTO_EXPAND_BUBBLE);
        }
        if (prevAutoExpand != shouldAutoExpand && mBubbleMetadataFlagListener != null) {
            mBubbleMetadataFlagListener.onBubbleMetadataFlagChanged(this);
        }
    }

    public void setIsBubble(final boolean isBubble) {
+19 −0
Original line number Diff line number Diff line
@@ -1447,6 +1447,25 @@ public class BubblesTest extends SysuiTestCase {
        assertThat(stackView.getVisibility()).isEqualTo(View.VISIBLE);
    }

    @Test
    public void testSetShouldAutoExpand_notifiesFlagChanged() {
        mEntryListener.onPendingEntryAdded(mRow);

        assertTrue(mBubbleController.hasBubbles());
        Bubble b = mBubbleData.getBubbleInStackWithKey(mBubbleEntry.getKey());
        assertThat(b.shouldAutoExpand()).isFalse();

        // Set it to the same thing
        b.setShouldAutoExpand(false);

        // Verify it doesn't notify
        verify(mBubbleController, never()).onBubbleMetadataFlagChanged(any());

        // Set it to something different
        b.setShouldAutoExpand(true);
        verify(mBubbleController).onBubbleMetadataFlagChanged(b);
    }

    /** Creates a bubble using the userId and package. */
    private Bubble createBubble(int userId, String pkg) {
        final UserHandle userHandle = new UserHandle(userId);
+19 −0
Original line number Diff line number Diff line
@@ -1267,6 +1267,25 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
        assertThat(stackView.getVisibility()).isEqualTo(View.VISIBLE);
    }

    @Test
    public void testSetShouldAutoExpand_notifiesFlagChanged() {
        mBubbleController.updateBubble(mBubbleEntry);

        assertTrue(mBubbleController.hasBubbles());
        Bubble b = mBubbleData.getBubbleInStackWithKey(mBubbleEntry.getKey());
        assertThat(b.shouldAutoExpand()).isFalse();

        // Set it to the same thing
        b.setShouldAutoExpand(false);

        // Verify it doesn't notify
        verify(mBubbleController, never()).onBubbleMetadataFlagChanged(any());

        // Set it to something different
        b.setShouldAutoExpand(true);
        verify(mBubbleController).onBubbleMetadataFlagChanged(b);
    }

    /**
     * Sets the bubble metadata flags for this entry. These flags are normally set by
     * NotificationManagerService when the notification is sent, however, these tests do not