Fixed optional overflow crash by verifying the presence of bubbles.

The scenario where "A bubble was added from the overflow (and now it's
empty/not showing)" lacked a check to verify if bubbles are currently
present. Its absence caused calls to removeOverflowAndAddBubble()  of
BubbleBarViewController for any first bubble matching the previously
closed last bubble, not just those added from the overflow.
This CL addresses the issue by adding the missing check.

Test: Manual. Set enable_optional_bubble_overflow flag to true. Create
one bubble, dismiss it, create the same bubble again. Create another
bubble, dismiss it, open overflow and click on dismissed bubble. Observe
the overflow icon disappears.
Video: http://recall/-/gx8ASgewUeUS3QYohfrd1J/eYeyo6cNeUBw4mU6rrkXtN
Flag: com.android.wm.shell.enable_bubble_bar
Fixes: 373940143

Change-Id: I4085ce4e922e2b5d65466a00649dda086c14185f
This commit is contained in:
mpodolian
2024-12-19 13:37:08 -08:00
parent 5f5b1a3f56
commit 4bc4e45714
2 changed files with 4 additions and 2 deletions
@@ -324,7 +324,8 @@ public class BubbleBarController extends IBubblesListener.Stub {
if (Flags.enableOptionalBubbleOverflow()
&& update.showOverflowChanged && !update.showOverflow && update.addedBubble != null
&& update.removedBubbles.isEmpty()) {
&& update.removedBubbles.isEmpty()
&& !mBubbles.isEmpty()) {
// A bubble was added from the overflow (& now it's empty / not showing)
mBubbles.put(update.addedBubble.getKey(), update.addedBubble);
mBubbleBarViewController.removeOverflowAndAddBubble(update.addedBubble);
@@ -729,7 +729,8 @@ public class BubbleBarView extends FrameLayout {
Runnable onEndRunnable) {
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams((int) mIconSize, (int) mIconSize,
Gravity.LEFT);
boolean isOverflowSelected = mSelectedBubbleView.isOverflow();
boolean isOverflowSelected =
mSelectedBubbleView != null && mSelectedBubbleView.isOverflow();
boolean removingOverflow = removedBubble.isOverflow();
boolean addingOverflow = addedBubble.isOverflow();