From a33e075a6b086fec02593a7bce9359e3c06a46c5 Mon Sep 17 00:00:00 2001 From: Matt Pietal Date: Tue, 2 Jun 2020 16:27:38 -0400 Subject: [PATCH] Controls UI - Wait for callback to potentially show controls A race condition exists when global actions is shown. The controls listing callback may not yet have been reached when the dialog is shown. If this happens, add controls into the space. Fixes: 156624057 Test: restart and immediately invoke power menu Change-Id: Ic3d70a7a4e65d9d01004ccb36133e992aadc73c7 --- .../systemui/globalactions/GlobalActionsDialog.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java index 1b13d4a49fecc..eeb35d4015c9f 100644 --- a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java +++ b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java @@ -391,7 +391,15 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, if (controlsComponent.getControlsListingController().isPresent()) { controlsComponent.getControlsListingController().get() - .addCallback(list -> mControlsServiceInfos = list); + .addCallback(list -> { + mControlsServiceInfos = list; + // This callback may occur after the dialog has been shown. + // If so, add controls into the already visible space + if (mDialog != null && !mDialog.isShowingControls() + && shouldShowControls()) { + mDialog.showControls(mControlsUiControllerOptional.get()); + } + }); } // Need to be user-specific with the context to make sure we read the correct prefs