From 26daeace301392aba9e332bf87c7f0494b88875d Mon Sep 17 00:00:00 2001 From: Liran Binyamin Date: Thu, 22 Jun 2023 11:18:38 -0400 Subject: [PATCH] Ensure the overflow is added first to the bubble bar Previously there was a race between initializing the bubble bar which creates the overflow and sending an initial bubble state update event from WMShell. If the event is processed first then bubbles are added before the overflow. This change ensures that the overflow is created if needed when the initial event is sent from WMShell. Fixes: 288414998 Test: - manual - Enable 3 button navigation - Create some bubbles - Switch to gesture navigation - Overflow should be added first (below other bubbles) Change-Id: Ie001c76a3f587d95021f4b7202492b3071706fd0 --- .../taskbar/bubbles/BubbleBarController.java | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java index 2bd6fcbcd2..6b5c962df1 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java @@ -185,16 +185,26 @@ public class BubbleBarController extends IBubblesListener.Stub { mBubbleBarViewController.setHiddenForBubbles(!BUBBLE_BAR_ENABLED); mBubbleStashedHandleViewController.setHiddenForBubbles(!BUBBLE_BAR_ENABLED); }); + } - BUBBLE_STATE_EXECUTOR.execute(() -> { - if (mOverflowBubble == null) { - BubbleBarOverflow overflow = createOverflow(mContext); - mMainExecutor.execute(() -> { + /** + * Creates and adds the overflow bubble to the bubble bar if it hasn't been created yet. + * + *

This should be called on the {@link #BUBBLE_STATE_EXECUTOR} executor to avoid inflating + * the overflow multiple times. + */ + private void createAndAddOverflowIfNeeded() { + if (mOverflowBubble == null) { + BubbleBarOverflow overflow = createOverflow(mContext); + mMainExecutor.execute(() -> { + // we're on the main executor now, so check that the overflow hasn't been created + // again to avoid races. + if (mOverflowBubble == null) { mBubbleBarViewController.addBubble(overflow); mOverflowBubble = overflow; - }); - } - }); + } + }); + } } /** @@ -226,6 +236,7 @@ public class BubbleBarController extends IBubblesListener.Stub { || !update.currentBubbleList.isEmpty()) { // We have bubbles to load BUBBLE_STATE_EXECUTOR.execute(() -> { + createAndAddOverflowIfNeeded(); if (update.addedBubble != null) { viewUpdate.addedBubble = populateBubble(update.addedBubble, mContext, mBarView); }