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
This commit is contained in:
Alex Stetson
2022-07-22 11:59:55 -07:00
parent 8d5e38f727
commit 416ec500ea

View File

@@ -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);