From 67df94588db8bd27bdcea94747ed6949c7586fbf Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Tue, 20 Oct 2020 09:18:35 -0700 Subject: [PATCH] Disable initializing wm component for non-primary sysui process Bug: 171278064 Test: Create another user and switch to/from the new user Change-Id: If399fb6a8d36617abc4e900902dd5dd5269ddb8c --- .../src/com/android/systemui/SystemUIFactory.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java b/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java index 4814501c840d4..bdd0b55b27ea3 100644 --- a/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java +++ b/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java @@ -85,10 +85,12 @@ public class SystemUIFactory { @VisibleForTesting public void init(Context context, boolean fromTest) throws ExecutionException, InterruptedException { + final boolean initializeComponents = !fromTest + && android.os.Process.myUserHandle().isSystem(); mRootComponent = buildGlobalRootComponent(context); // Stand up WMComponent mWMComponent = mRootComponent.getWMComponentBuilder().build(); - if (!fromTest) { + if (initializeComponents) { // Only initialize when not starting from tests since this currently initializes some // components that shouldn't be run in the test environment mWMComponent.init(); @@ -96,7 +98,7 @@ public class SystemUIFactory { // And finally, retrieve whatever SysUI needs from WMShell and build SysUI. SysUIComponent.Builder builder = mRootComponent.getSysUIComponent(); - if (!fromTest) { + if (initializeComponents) { // Only initialize when not starting from tests since this currently initializes some // components that shouldn't be run in the test environment builder = builder.setPip(mWMComponent.getPip()) @@ -111,7 +113,7 @@ public class SystemUIFactory { .setInputConsumerController(mWMComponent.getInputConsumerController()) .setShellTaskOrganizer(mWMComponent.getShellTaskOrganizer()) .build(); - if (!fromTest) { + if (initializeComponents) { mSysUIComponent.init(); }