From b72b72ac13a5ac3f2d4ea8184eb0b2f2460c34ca Mon Sep 17 00:00:00 2001 From: Ats Jenk Date: Fri, 19 Aug 2022 12:38:26 -0700 Subject: [PATCH] Fix bug with clearing bubble to expand When BubbleController receives multiple status bar state updates, it can clear the bubble to be expanded information. This can happen when user receives a bubble notification on lockscreen and taps on it. In this case we set the bubble to be expanded field on the controller as the device is locked and we can't expand the bubble yet. Phone unlock flow triggers multiple statusbar updates to the BubbleController which can clear the bubble to be expanded field. Make sure field is only cleared when bubble actually is going to be expanded. Bug: 240226362 Test: atest BubblesTest Test: have bubbles stacked, pattern lock screen, lock device and receive an incoming notification to one of the bubbles, click on the notification to unlock device. Observe bubbles is expanded after unlocking device. Change-Id: I61f1d6a1fb673a89fa9b7a1d6b6253874d0c5778 --- .../wm/shell/bubbles/BubbleController.java | 1 - .../android/systemui/wmshell/BubblesTest.java | 27 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) 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 de26b54971caa..6c76e3f0dd0e3 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 @@ -538,7 +538,6 @@ public class BubbleController implements ConfigurationChangeListener { if (mNotifEntryToExpandOnShadeUnlock != null) { expandStackAndSelectBubble(mNotifEntryToExpandOnShadeUnlock); - mNotifEntryToExpandOnShadeUnlock = null; } updateStack(); 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 18acf3f6ce531..d0c87e8b8b27c 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java @@ -1370,6 +1370,33 @@ public class BubblesTest extends SysuiTestCase { assertThat(stackView.getVisibility()).isEqualTo(View.VISIBLE); } + /** + * Test to verify behavior for following situation: + * + * Test that duplicate status bar state updates to false do not clear the + * pending bubble to be + * expanded. + */ + @Test + public void testOnStatusBarStateChanged_statusBarChangeDoesNotClearExpandingBubble() { + mBubbleController.updateBubble(mBubbleEntry); + mBubbleController.onStatusBarStateChanged(false); + // Set the bubble to expand once status bar state changes + mBubbleController.expandStackAndSelectBubble(mBubbleEntry); + // Check that stack is currently collapsed + assertStackCollapsed(); + // Post status bar state change update with the same value + mBubbleController.onStatusBarStateChanged(false); + // Stack should remain collapsedb + assertStackCollapsed(); + // Post status bar state change which should trigger bubble to expand + mBubbleController.onStatusBarStateChanged(true); + assertStackExpanded(); + } + @Test public void testSetShouldAutoExpand_notifiesFlagChanged() { mBubbleController.updateBubble(mBubbleEntry);