Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerTest.java +73 −2 Original line number Diff line number Diff line Loading @@ -71,7 +71,11 @@ import androidx.test.filters.SmallTest; import com.android.internal.widget.LockPatternUtils; import com.android.systemui.SysuiTestCase; import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.deviceentry.domain.interactor.DeviceUnlockedInteractor; import com.android.systemui.deviceentry.shared.model.DeviceUnlockStatus; import com.android.systemui.dump.DumpManager; import com.android.systemui.flags.DisableSceneContainer; import com.android.systemui.flags.EnableSceneContainer; import com.android.systemui.flags.FakeFeatureFlagsClassic; import com.android.systemui.log.LogWtfHandlerRule; import com.android.systemui.plugins.statusbar.StatusBarStateController; Loading @@ -90,6 +94,10 @@ import com.android.systemui.util.time.FakeSystemClock; import com.google.android.collect.Lists; import dagger.Lazy; import kotlinx.coroutines.flow.StateFlow; import org.junit.After; import org.junit.Before; import org.junit.Rule; Loading Loading @@ -152,6 +160,12 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase { private BroadcastDispatcher mBroadcastDispatcher; @Mock private KeyguardStateController mKeyguardStateController; @Mock private Lazy<DeviceUnlockedInteractor> mDeviceUnlockedInteractorLazy; @Mock private DeviceUnlockedInteractor mDeviceUnlockedInteractor; @Mock private StateFlow<DeviceUnlockStatus> mDeviceUnlockStatusStateFlow; private UserInfo mCurrentUser; private UserInfo mSecondaryUser; Loading Loading @@ -238,6 +252,9 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase { mLockscreenUserManager = new TestNotificationLockscreenUserManager(mContext); mLockscreenUserManager.setUpWithPresenter(mPresenter); when(mDeviceUnlockedInteractor.getDeviceUnlockStatus()) .thenReturn(mDeviceUnlockStatusStateFlow); mBackgroundExecutor.runAllReady(); } Loading Loading @@ -493,7 +510,8 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase { } @Test public void testUpdateIsPublicMode() { @DisableSceneContainer public void testUpdateIsPublicMode_sceneContainerDisabled() { when(mKeyguardStateController.isMethodSecure()).thenReturn(true); when(mKeyguardStateController.isShowing()).thenReturn(false); Loading Loading @@ -527,6 +545,57 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase { mBackgroundExecutor.runAllReady(); assertTrue(mLockscreenUserManager.isLockscreenPublicMode(0)); verify(listener, never()).onNotificationStateChanged(); verify(mDeviceUnlockedInteractorLazy, never()).get(); } @Test @EnableSceneContainer public void testUpdateIsPublicMode_sceneContainerEnabled() { when(mDeviceUnlockedInteractorLazy.get()).thenReturn(mDeviceUnlockedInteractor); // device is unlocked when(mDeviceUnlockStatusStateFlow.getValue()).thenReturn(new DeviceUnlockStatus( /* isUnlocked = */ true, /* deviceUnlockSource = */ null )); NotificationStateChangedListener listener = mock(NotificationStateChangedListener.class); mLockscreenUserManager.addNotificationStateChangedListener(listener); mLockscreenUserManager.mCurrentProfiles.append(0, mock(UserInfo.class)); // first call explicitly sets user 0 to not public; notifies mLockscreenUserManager.updatePublicMode(); mBackgroundExecutor.runAllReady(); assertFalse(mLockscreenUserManager.isLockscreenPublicMode(0)); verify(listener).onNotificationStateChanged(); clearInvocations(listener); // calling again has no changes; does not notify mLockscreenUserManager.updatePublicMode(); mBackgroundExecutor.runAllReady(); assertFalse(mLockscreenUserManager.isLockscreenPublicMode(0)); verify(listener, never()).onNotificationStateChanged(); // device is not unlocked when(mDeviceUnlockStatusStateFlow.getValue()).thenReturn(new DeviceUnlockStatus( /* isUnlocked = */ false, /* deviceUnlockSource = */ null )); // Calling again with device now not unlocked makes user 0 public; notifies when(mKeyguardStateController.isShowing()).thenReturn(true); mLockscreenUserManager.updatePublicMode(); mBackgroundExecutor.runAllReady(); assertTrue(mLockscreenUserManager.isLockscreenPublicMode(0)); verify(listener).onNotificationStateChanged(); clearInvocations(listener); // calling again has no changes; does not notify mLockscreenUserManager.updatePublicMode(); mBackgroundExecutor.runAllReady(); assertTrue(mLockscreenUserManager.isLockscreenPublicMode(0)); verify(listener, never()).onNotificationStateChanged(); } @Test Loading Loading @@ -972,7 +1041,9 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase { mSettings, mock(DumpManager.class), mock(LockPatternUtils.class), mFakeFeatureFlags); mFakeFeatureFlags, mDeviceUnlockedInteractorLazy ); } public BroadcastReceiver getBaseBroadcastReceiverForTest() { Loading packages/SystemUI/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerImpl.java +14 −3 Original line number Diff line number Diff line Loading @@ -62,11 +62,13 @@ import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.dagger.qualifiers.Background; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.deviceentry.domain.interactor.DeviceUnlockedInteractor; import com.android.systemui.dump.DumpManager; import com.android.systemui.flags.FeatureFlagsClassic; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.plugins.statusbar.StatusBarStateController.StateListener; import com.android.systemui.recents.OverviewProxyService; import com.android.systemui.scene.shared.flag.SceneContainerFlag; import com.android.systemui.settings.UserTracker; import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.systemui.statusbar.notification.collection.notifcollection.CommonNotifCollection; Loading Loading @@ -286,6 +288,8 @@ public class NotificationLockscreenUserManagerImpl implements protected ContentObserver mLockscreenSettingsObserver; protected ContentObserver mSettingsObserver; private final Lazy<DeviceUnlockedInteractor> mDeviceUnlockedInteractorLazy; @Inject public NotificationLockscreenUserManagerImpl(Context context, BroadcastDispatcher broadcastDispatcher, Loading @@ -305,7 +309,8 @@ public class NotificationLockscreenUserManagerImpl implements SecureSettings secureSettings, DumpManager dumpManager, LockPatternUtils lockPatternUtils, FeatureFlagsClassic featureFlags) { FeatureFlagsClassic featureFlags, Lazy<DeviceUnlockedInteractor> deviceUnlockedInteractorLazy) { mContext = context; mMainExecutor = mainExecutor; mBackgroundExecutor = backgroundExecutor; Loading @@ -325,6 +330,7 @@ public class NotificationLockscreenUserManagerImpl implements mSecureSettings = secureSettings; mKeyguardStateController = keyguardStateController; mFeatureFlags = featureFlags; mDeviceUnlockedInteractorLazy = deviceUnlockedInteractorLazy; mLockScreenUris.add(SHOW_LOCKSCREEN); mLockScreenUris.add(SHOW_PRIVATE_LOCKSCREEN); Loading Loading @@ -748,8 +754,13 @@ public class NotificationLockscreenUserManagerImpl implements // camera on the keyguard has a state of SHADE but the keyguard is still showing. final boolean showingKeyguard = mState != StatusBarState.SHADE || mKeyguardStateController.isShowing(); final boolean devicePublic = showingKeyguard && mKeyguardStateController.isMethodSecure(); final boolean devicePublic; if (SceneContainerFlag.isEnabled()) { devicePublic = !mDeviceUnlockedInteractorLazy.get() .getDeviceUnlockStatus().getValue().isUnlocked(); } else { devicePublic = showingKeyguard && mKeyguardStateController.isMethodSecure(); } // Look for public mode users. Users are considered public in either case of: // - device keyguard is shown in secure mode; Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerTest.java +73 −2 Original line number Diff line number Diff line Loading @@ -71,7 +71,11 @@ import androidx.test.filters.SmallTest; import com.android.internal.widget.LockPatternUtils; import com.android.systemui.SysuiTestCase; import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.deviceentry.domain.interactor.DeviceUnlockedInteractor; import com.android.systemui.deviceentry.shared.model.DeviceUnlockStatus; import com.android.systemui.dump.DumpManager; import com.android.systemui.flags.DisableSceneContainer; import com.android.systemui.flags.EnableSceneContainer; import com.android.systemui.flags.FakeFeatureFlagsClassic; import com.android.systemui.log.LogWtfHandlerRule; import com.android.systemui.plugins.statusbar.StatusBarStateController; Loading @@ -90,6 +94,10 @@ import com.android.systemui.util.time.FakeSystemClock; import com.google.android.collect.Lists; import dagger.Lazy; import kotlinx.coroutines.flow.StateFlow; import org.junit.After; import org.junit.Before; import org.junit.Rule; Loading Loading @@ -152,6 +160,12 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase { private BroadcastDispatcher mBroadcastDispatcher; @Mock private KeyguardStateController mKeyguardStateController; @Mock private Lazy<DeviceUnlockedInteractor> mDeviceUnlockedInteractorLazy; @Mock private DeviceUnlockedInteractor mDeviceUnlockedInteractor; @Mock private StateFlow<DeviceUnlockStatus> mDeviceUnlockStatusStateFlow; private UserInfo mCurrentUser; private UserInfo mSecondaryUser; Loading Loading @@ -238,6 +252,9 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase { mLockscreenUserManager = new TestNotificationLockscreenUserManager(mContext); mLockscreenUserManager.setUpWithPresenter(mPresenter); when(mDeviceUnlockedInteractor.getDeviceUnlockStatus()) .thenReturn(mDeviceUnlockStatusStateFlow); mBackgroundExecutor.runAllReady(); } Loading Loading @@ -493,7 +510,8 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase { } @Test public void testUpdateIsPublicMode() { @DisableSceneContainer public void testUpdateIsPublicMode_sceneContainerDisabled() { when(mKeyguardStateController.isMethodSecure()).thenReturn(true); when(mKeyguardStateController.isShowing()).thenReturn(false); Loading Loading @@ -527,6 +545,57 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase { mBackgroundExecutor.runAllReady(); assertTrue(mLockscreenUserManager.isLockscreenPublicMode(0)); verify(listener, never()).onNotificationStateChanged(); verify(mDeviceUnlockedInteractorLazy, never()).get(); } @Test @EnableSceneContainer public void testUpdateIsPublicMode_sceneContainerEnabled() { when(mDeviceUnlockedInteractorLazy.get()).thenReturn(mDeviceUnlockedInteractor); // device is unlocked when(mDeviceUnlockStatusStateFlow.getValue()).thenReturn(new DeviceUnlockStatus( /* isUnlocked = */ true, /* deviceUnlockSource = */ null )); NotificationStateChangedListener listener = mock(NotificationStateChangedListener.class); mLockscreenUserManager.addNotificationStateChangedListener(listener); mLockscreenUserManager.mCurrentProfiles.append(0, mock(UserInfo.class)); // first call explicitly sets user 0 to not public; notifies mLockscreenUserManager.updatePublicMode(); mBackgroundExecutor.runAllReady(); assertFalse(mLockscreenUserManager.isLockscreenPublicMode(0)); verify(listener).onNotificationStateChanged(); clearInvocations(listener); // calling again has no changes; does not notify mLockscreenUserManager.updatePublicMode(); mBackgroundExecutor.runAllReady(); assertFalse(mLockscreenUserManager.isLockscreenPublicMode(0)); verify(listener, never()).onNotificationStateChanged(); // device is not unlocked when(mDeviceUnlockStatusStateFlow.getValue()).thenReturn(new DeviceUnlockStatus( /* isUnlocked = */ false, /* deviceUnlockSource = */ null )); // Calling again with device now not unlocked makes user 0 public; notifies when(mKeyguardStateController.isShowing()).thenReturn(true); mLockscreenUserManager.updatePublicMode(); mBackgroundExecutor.runAllReady(); assertTrue(mLockscreenUserManager.isLockscreenPublicMode(0)); verify(listener).onNotificationStateChanged(); clearInvocations(listener); // calling again has no changes; does not notify mLockscreenUserManager.updatePublicMode(); mBackgroundExecutor.runAllReady(); assertTrue(mLockscreenUserManager.isLockscreenPublicMode(0)); verify(listener, never()).onNotificationStateChanged(); } @Test Loading Loading @@ -972,7 +1041,9 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase { mSettings, mock(DumpManager.class), mock(LockPatternUtils.class), mFakeFeatureFlags); mFakeFeatureFlags, mDeviceUnlockedInteractorLazy ); } public BroadcastReceiver getBaseBroadcastReceiverForTest() { Loading
packages/SystemUI/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerImpl.java +14 −3 Original line number Diff line number Diff line Loading @@ -62,11 +62,13 @@ import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.dagger.qualifiers.Background; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.deviceentry.domain.interactor.DeviceUnlockedInteractor; import com.android.systemui.dump.DumpManager; import com.android.systemui.flags.FeatureFlagsClassic; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.plugins.statusbar.StatusBarStateController.StateListener; import com.android.systemui.recents.OverviewProxyService; import com.android.systemui.scene.shared.flag.SceneContainerFlag; import com.android.systemui.settings.UserTracker; import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.systemui.statusbar.notification.collection.notifcollection.CommonNotifCollection; Loading Loading @@ -286,6 +288,8 @@ public class NotificationLockscreenUserManagerImpl implements protected ContentObserver mLockscreenSettingsObserver; protected ContentObserver mSettingsObserver; private final Lazy<DeviceUnlockedInteractor> mDeviceUnlockedInteractorLazy; @Inject public NotificationLockscreenUserManagerImpl(Context context, BroadcastDispatcher broadcastDispatcher, Loading @@ -305,7 +309,8 @@ public class NotificationLockscreenUserManagerImpl implements SecureSettings secureSettings, DumpManager dumpManager, LockPatternUtils lockPatternUtils, FeatureFlagsClassic featureFlags) { FeatureFlagsClassic featureFlags, Lazy<DeviceUnlockedInteractor> deviceUnlockedInteractorLazy) { mContext = context; mMainExecutor = mainExecutor; mBackgroundExecutor = backgroundExecutor; Loading @@ -325,6 +330,7 @@ public class NotificationLockscreenUserManagerImpl implements mSecureSettings = secureSettings; mKeyguardStateController = keyguardStateController; mFeatureFlags = featureFlags; mDeviceUnlockedInteractorLazy = deviceUnlockedInteractorLazy; mLockScreenUris.add(SHOW_LOCKSCREEN); mLockScreenUris.add(SHOW_PRIVATE_LOCKSCREEN); Loading Loading @@ -748,8 +754,13 @@ public class NotificationLockscreenUserManagerImpl implements // camera on the keyguard has a state of SHADE but the keyguard is still showing. final boolean showingKeyguard = mState != StatusBarState.SHADE || mKeyguardStateController.isShowing(); final boolean devicePublic = showingKeyguard && mKeyguardStateController.isMethodSecure(); final boolean devicePublic; if (SceneContainerFlag.isEnabled()) { devicePublic = !mDeviceUnlockedInteractorLazy.get() .getDeviceUnlockStatus().getValue().isUnlocked(); } else { devicePublic = showingKeyguard && mKeyguardStateController.isMethodSecure(); } // Look for public mode users. Users are considered public in either case of: // - device keyguard is shown in secure mode; Loading