diff options
2 files changed, 17 insertions, 1 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerImpl.java index c9df317508f9..9b8dd0b75a24 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerImpl.java @@ -275,7 +275,12 @@ public class NotificationLockscreenUserManagerImpl implements updateLockscreenNotificationSetting(); updatePublicMode(); - mPresenter.onUserSwitched(mCurrentUserId); + if (mPresenter != null) { + mPresenter.onUserSwitched(mCurrentUserId); + } else { + Log.w(TAG, "user switch before setup with presenter", + new Exception()); + } for (UserChangedListener listener : mListeners) { listener.onUserChanged(mCurrentUserId); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerTest.java index 0c6f456b1e80..757f16cac227 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerTest.java @@ -598,6 +598,17 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase { @Test @EnableFlags(FLAG_KEYGUARD_PRIVATE_NOTIFICATIONS) + public void testEarlyUserSwitch() { + mLockscreenUserManager = + new TestNotificationLockscreenUserManager(mContext); + mBackgroundExecutor.runAllReady(); + mLockscreenUserManager.mUserChangedCallback.onUserChanging( + mCurrentUser.id, mContext); + // no crash! + } + + @Test + @EnableFlags(FLAG_KEYGUARD_PRIVATE_NOTIFICATIONS) public void testKeyguardManager_noPrivateNotifications() { Mockito.clearInvocations(mDevicePolicyManager); // User allows notifications |