From 416ec500ea24ecd95a293002191d923b864377d8 Mon Sep 17 00:00:00 2001 From: Alex Stetson Date: Fri, 22 Jul 2022 11:59:55 -0700 Subject: [PATCH] Check for null before using user switcher view On certain platforms, this view may not be relevant or set when switch is called via an alternative method (such as a guest exit notification). Therefore, if the null state is not accounted for, sysui will crash. Bug: 239738046 Test: manual Change-Id: Ief87945e3811b74c6a44c29ae029343663f085bb --- .../statusbar/policy/UserSwitcherController.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java index 40281a194b126..ed8db268eddb9 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java @@ -167,6 +167,7 @@ public class UserSwitcherController implements Dumpable { private final AtomicBoolean mGuestIsResetting; private final AtomicBoolean mGuestCreationScheduled; private FalsingManager mFalsingManager; + @Nullable private View mView; private String mCreateSupervisedUserPackage; private GlobalSettings mGlobalSettings; @@ -572,9 +573,11 @@ public class UserSwitcherController implements Dumpable { protected void switchToUserId(int id) { try { - mInteractionJankMonitor.begin(InteractionJankMonitor.Configuration.Builder - .withView(InteractionJankMonitor.CUJ_USER_SWITCH, mView) - .setTimeout(MULTI_USER_JOURNEY_TIMEOUT)); + if (mView != null) { + mInteractionJankMonitor.begin(InteractionJankMonitor.Configuration.Builder + .withView(InteractionJankMonitor.CUJ_USER_SWITCH, mView) + .setTimeout(MULTI_USER_JOURNEY_TIMEOUT)); + } mLatencyTracker.onActionStart(LatencyTracker.ACTION_USER_SWITCH); pauseRefreshUsers(); mActivityManager.switchUser(id);