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

Commit b373fd8f authored by Mady Mellor's avatar Mady Mellor Committed by Xin Li
Browse files

DO NOT MERGE Fix issue with bubble stack & bubble data expanded bit being out of sync

If onBackPressed was used while the stack was expanded, it was calling
setExpanded on BubbleStackView (BSV) and NOT BubbleData. This results in
BSV and BubbleData being out of sync which can lead to incorrect behavior.
(e.g. using individual bubble dismiss method instead of the stack dismiss
method).

Test: atest BubblesTest NewNotifPipelineTest
Fixes: 217361258
(cherry picked from commit 8f368c53)
(cherry picked from commit 6843c124)
Merged-In: I748fdd49626acaa0e986a9d8038039cada6faa60
Change-Id: I748fdd49626acaa0e986a9d8038039cada6faa60
parent 15bcf9d7
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -1724,6 +1724,7 @@ public class BubbleStackView extends FrameLayout

    /**
     * Changes the expanded state of the stack.
     * Don't call this directly, call mBubbleData#setExpanded.
     *
     * @param shouldExpand whether the bubble stack should appear expanded
     */
@@ -1770,7 +1771,7 @@ public class BubbleStackView extends FrameLayout
            } else if (mManageEduView != null && mManageEduView.getVisibility() == VISIBLE) {
                mManageEduView.hide();
            } else {
                setExpanded(false);
                mBubbleData.setExpanded(false);
            }
        }
    }
+16 −0
Original line number Diff line number Diff line
@@ -1275,6 +1275,22 @@ public class BubblesTest extends SysuiTestCase {
        assertSysuiStates(false /* stackExpanded */, false /* mangeMenuExpanded */);
    }

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

        // Expand the stack
        mBubbleData.setExpanded(true);
        assertStackExpanded();

        // Hit back
        BubbleStackView stackView = mBubbleController.getStackView();
        stackView.onBackPressed();

        // Make sure we're collapsed
        assertStackCollapsed();
    }

    /** Creates a bubble using the userId and package. */
    private Bubble createBubble(int userId, String pkg) {
        final UserHandle userHandle = new UserHandle(userId);
+16 −0
Original line number Diff line number Diff line
@@ -1091,6 +1091,22 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
        assertSysuiStates(false /* stackExpanded */, false /* mangeMenuExpanded */);
    }

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

        // Expand the stack
        mBubbleData.setExpanded(true);
        assertStackExpanded();

        // Hit back
        BubbleStackView stackView = mBubbleController.getStackView();
        stackView.onBackPressed();

        // Make sure we're collapsed
        assertStackCollapsed();
    }

    /**
     * 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