From 89c94f0abb406841471c36cbbc51fa8622e212b6 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Wed, 14 Dec 2022 00:03:04 +0000 Subject: [PATCH] Force update the disable flags following status bar registration - CentralSurfacesImpl currently takes a long time to initialize, so in between registration and updating CommandQueue with the registered bar's disabled flags, the service may already have updated its disabled state. This state would have already come into CommandQueue but would be clobbered by CSI in the post-init task. Since there are some legacy constraints in ordering of the initialization, we'll unblock the tests by forcing a disable flag update following the update to CommandQueue with the previous disabled flags. We can later investigate applying the returned flags earlier in the cycle, or add a mechanism to skip apply the registered disable flags if they were updated mid-init. Bug: 260615374 Test: atest WMShellFlickerTests:com.android.wm.shell.flicker.splitscreen.CopyContentInSplit Change-Id: I98943292ecab5cdc693149f417e5c4e8af137d1d --- .../statusbar/phone/CentralSurfacesImpl.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java index 31cdb0549d45c..005cd1bff90c3 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java @@ -16,6 +16,7 @@ package com.android.systemui.statusbar.phone; +import static android.app.StatusBarManager.DISABLE_HOME; import static android.app.StatusBarManager.WINDOW_STATE_HIDDEN; import static android.app.StatusBarManager.WINDOW_STATE_SHOWING; import static android.app.StatusBarManager.WindowVisibleState; @@ -70,6 +71,7 @@ import android.graphics.Point; import android.hardware.devicestate.DeviceStateManager; import android.metrics.LogMaker; import android.net.Uri; +import android.os.Binder; import android.os.Bundle; import android.os.Handler; import android.os.Looper; @@ -1047,8 +1049,21 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { // set the initial view visibility int disabledFlags1 = result.mDisabledFlags1; int disabledFlags2 = result.mDisabledFlags2; - mInitController.addPostInitTask( - () -> setUpDisableFlags(disabledFlags1, disabledFlags2)); + mInitController.addPostInitTask(() -> { + setUpDisableFlags(disabledFlags1, disabledFlags2); + try { + // NOTE(b/262059863): Force-update the disable flags after applying the flags + // returned from registerStatusBar(). The result's disabled flags may be stale + // if StatusBarManager's disabled flags are updated between registering the bar and + // this handling this post-init task. We force an update in this case, and use a new + // token to not conflict with any other disabled flags already requested by SysUI + Binder token = new Binder(); + mBarService.disable(DISABLE_HOME, token, mContext.getPackageName()); + mBarService.disable(0, token, mContext.getPackageName()); + } catch (RemoteException ex) { + ex.rethrowFromSystemServer(); + } + }); mFalsingManager.addFalsingBeliefListener(mFalsingBeliefListener);