From 6a27f50138f6ab5a7f3141617e60e37bbb660be4 Mon Sep 17 00:00:00 2001 From: Fabian Kozynski Date: Tue, 30 Jul 2019 14:36:52 -0400 Subject: [PATCH] Mitigate IPC calls from MultiUserSwitcher Reduce the calls to UserManager#hasUserRestriction when checking if the switcher should be shown by reordering the conditions. In most cases, the switcher is disabled (from settings) and it will short circuit. TODO: actually remove the call from main thread Test: manual, when device does not have multiple users, there are no calls to UserManager Bug: 138640355 Bug: 138661450 Change-Id: I35905d4d8a7194866f55009b86dff0a2a4214e1a --- .../android/systemui/statusbar/phone/MultiUserSwitch.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/MultiUserSwitch.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/MultiUserSwitch.java index c0a1b123fe775..1d4d0bd17f01e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/MultiUserSwitch.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/MultiUserSwitch.java @@ -103,10 +103,11 @@ public class MultiUserSwitch extends FrameLayout implements View.OnClickListener final boolean userSwitcherEnabled = Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.USER_SWITCHER_ENABLED, 0) != 0; - if (!UserManager.supportsMultipleUsers() - || mUserManager.hasUserRestriction(UserManager.DISALLOW_USER_SWITCH) + // TODO(b/138661450) Move IPC calls to background + if (!userSwitcherEnabled + || !UserManager.supportsMultipleUsers() || UserManager.isDeviceInDemoMode(mContext) - || !userSwitcherEnabled) { + || mUserManager.hasUserRestriction(UserManager.DISALLOW_USER_SWITCH)) { return false; }