Loading packages/SystemUI/multivalentTests/src/com/android/systemui/communal/CommunalSceneStartableTest.kt +3 −0 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ import com.android.systemui.flags.andSceneContainer import com.android.systemui.flags.fakeFeatureFlagsClassic import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor import com.android.systemui.keyguard.domain.interactor.keyguardInteractor import com.android.systemui.keyguard.domain.interactor.keyguardTransitionInteractor import com.android.systemui.keyguard.shared.model.KeyguardState Loading Loading @@ -494,6 +495,7 @@ class CommunalSceneStartableTest(flags: FlagsParameterization) : SysuiTestCase() // Start dreaming. updateDreaming(true) advanceTimeBy(KeyguardInteractor.IS_ABLE_TO_DREAM_DELAY_MS) // Hub times out immediately. assertThat(scene).isEqualTo(CommunalScenes.Blank) Loading Loading @@ -650,6 +652,7 @@ class CommunalSceneStartableTest(flags: FlagsParameterization) : SysuiTestCase() // Start dreaming. updateDreaming(true) advanceTimeBy(KeyguardInteractor.IS_ABLE_TO_DREAM_DELAY_MS) // Hub times out immediately. assertThat(scene).isEqualTo(Scenes.Dream) Loading packages/SystemUI/multivalentTests/src/com/android/systemui/scene/domain/startable/SceneContainerStartableTest.kt +32 −6 Original line number Diff line number Diff line Loading @@ -74,6 +74,7 @@ import com.android.systemui.keyguard.data.repository.fakeTrustRepository import com.android.systemui.keyguard.data.repository.keyguardRepository import com.android.systemui.keyguard.data.repository.keyguardTransitionRepository import com.android.systemui.keyguard.dismissCallbackRegistry import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor import com.android.systemui.keyguard.domain.interactor.dozeInteractor import com.android.systemui.keyguard.domain.interactor.keyguardEnabledInteractor import com.android.systemui.keyguard.domain.interactor.keyguardInteractor Loading Loading @@ -1270,8 +1271,11 @@ class SceneContainerStartableTest : SysuiTestCase() { authenticationMethod = AuthenticationMethodModel.None, isLockscreenEnabled = false, ) assertThat(currentSceneKey).isEqualTo(Scenes.Lockscreen) powerInteractor.setAsleepForTest() underTest.start() runCurrent() assertThat(currentSceneKey).isEqualTo(Scenes.Lockscreen) powerInteractor.setAwakeForTest() runCurrent() Loading Loading @@ -2139,6 +2143,7 @@ class SceneContainerStartableTest : SysuiTestCase() { val currentScene by collectLastValue(sceneInteractor.currentScene) val transitionStateFlow = prepareState() underTest.start() runCurrent() emulateSceneTransition(transitionStateFlow, toScene = Scenes.Bouncer) assertThat(currentScene).isNotEqualTo(Scenes.Lockscreen) Loading @@ -2153,6 +2158,7 @@ class SceneContainerStartableTest : SysuiTestCase() { val currentScene by collectLastValue(sceneInteractor.currentScene) val transitionStateFlow = prepareState() underTest.start() runCurrent() emulateSceneTransition(transitionStateFlow, toScene = Scenes.Bouncer) assertThat(currentScene).isEqualTo(Scenes.Bouncer) Loading Loading @@ -2269,6 +2275,7 @@ class SceneContainerStartableTest : SysuiTestCase() { assertThat(currentScene).isEqualTo(Scenes.Gone) assertThat(kosmos.deviceEntryInteractor.isDeviceEntered.value).isTrue() underTest.start() runCurrent() sceneInteractor.changeScene(Scenes.Shade, "") assertThat(currentScene).isEqualTo(Scenes.Shade) assertThat(kosmos.deviceEntryInteractor.isDeviceEntered.value).isTrue() Loading Loading @@ -2350,6 +2357,7 @@ class SceneContainerStartableTest : SysuiTestCase() { val currentScene by collectLastValue(sceneInteractor.currentScene) prepareState() underTest.start() runCurrent() // run all pending dismiss succeeded/cancelled calls from setup: kosmos.fakeExecutor.runAllReady() Loading Loading @@ -2461,13 +2469,18 @@ class SceneContainerStartableTest : SysuiTestCase() { @Test fun switchFromDreamToLockscreen_whenLockedAndDreamStopped() = testScope.runTest { keyguardInteractor.setDreaming(true) val currentScene by collectLastValue(sceneInteractor.currentScene) prepareState(initialSceneKey = Scenes.Dream) assertThat(currentScene).isEqualTo(Scenes.Dream) underTest.start() advanceTimeBy(KeyguardInteractor.IS_ABLE_TO_DREAM_DELAY_MS) runCurrent() keyguardInteractor.setDreaming(true) advanceTimeBy(KeyguardInteractor.IS_ABLE_TO_DREAM_DELAY_MS) runCurrent() assertThat(currentScene).isEqualTo(Scenes.Dream) keyguardInteractor.setDreaming(false) advanceTimeBy(KeyguardInteractor.IS_ABLE_TO_DREAM_DELAY_MS) runCurrent() assertThat(currentScene).isEqualTo(Scenes.Lockscreen) } Loading @@ -2475,13 +2488,18 @@ class SceneContainerStartableTest : SysuiTestCase() { @Test fun switchFromDreamToGone_whenUnlockedAndDreamStopped() = testScope.runTest { keyguardInteractor.setDreaming(true) val currentScene by collectLastValue(sceneInteractor.currentScene) prepareState(initialSceneKey = Scenes.Dream, isDeviceUnlocked = true) assertThat(currentScene).isEqualTo(Scenes.Dream) underTest.start() advanceTimeBy(KeyguardInteractor.IS_ABLE_TO_DREAM_DELAY_MS) runCurrent() keyguardInteractor.setDreaming(true) advanceTimeBy(KeyguardInteractor.IS_ABLE_TO_DREAM_DELAY_MS) runCurrent() assertThat(currentScene).isEqualTo(Scenes.Dream) keyguardInteractor.setDreaming(false) advanceTimeBy(KeyguardInteractor.IS_ABLE_TO_DREAM_DELAY_MS) runCurrent() assertThat(currentScene).isEqualTo(Scenes.Gone) } Loading Loading @@ -2684,6 +2702,7 @@ class SceneContainerStartableTest : SysuiTestCase() { underTest.start() val currentScene by collectLastValue(sceneInteractor.currentScene) val currentOverlays by collectLastValue(sceneInteractor.currentOverlays) runCurrent() sceneInteractor.changeScene(Scenes.Shade, "reason") sceneInteractor.showOverlay(Overlays.NotificationsShade, "reason") assertThat(currentScene).isEqualTo(Scenes.Shade) Loading Loading @@ -2835,8 +2854,15 @@ class SceneContainerStartableTest : SysuiTestCase() { ) sceneInteractor.setTransitionState(transitionStateFlow) initialSceneKey?.let { if (isDeviceUnlocked && initialSceneKey != Scenes.Gone) { // Pass through the Gone scene to populate device entry state properly. transitionStateFlow.value = ObservableTransitionState.Idle(Scenes.Gone) sceneInteractor.changeScene(Scenes.Gone, "prepareState, passing through Gone scene") runCurrent() } transitionStateFlow.value = ObservableTransitionState.Idle(it) sceneInteractor.changeScene(it, "reason") sceneInteractor.changeScene(it, "prepareState, initialSceneKey isn't null") } if (startsAwake) { powerInteractor.setAwakeForTest() Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/domain/interactor/KeyguardBypassInteractorTest.kt +7 −6 Original line number Diff line number Diff line Loading @@ -127,12 +127,6 @@ class KeyguardBypassInteractorTest : SysuiTestCase() { kosmos.configureKeyguardBypass(isBypassAvailable = skipIsBypassAvailableCheck) underTest = kosmos.keyguardBypassInteractor // bouncerShowing false, !onLockscreenScene false // !onLockscreenScene false setScene( bouncerShowing = !skipBouncerShowingCheck, onLockscreenScene = skipOnLockscreenSceneCheck, ) // alternateBouncerShowing false setAlternateBouncerShowing(!skipAlternateBouncerShowingCheck) // launchingAffordance false Loading @@ -141,6 +135,13 @@ class KeyguardBypassInteractorTest : SysuiTestCase() { setPulseExpanding(!skipPulseExpandingCheck) // qsExpanding false setQsExpanded(!skipQsExpandedCheck) // bouncerShowing false, !onLockscreenScene false // !onLockscreenScene false setScene( bouncerShowing = !skipBouncerShowingCheck, onLockscreenScene = skipOnLockscreenSceneCheck, ) } private fun setAlternateBouncerShowing(alternateBouncerVisible: Boolean) { Loading packages/SystemUI/src/com/android/systemui/communal/CommunalSceneStartable.kt +6 −1 Original line number Diff line number Diff line Loading @@ -183,7 +183,12 @@ constructor( this@CommunalSceneStartable.isDreaming = isDreaming if (scene.isCommunal() && isDreaming && timeoutJob == null) { // If dreaming starts after timeout has expired, ex. if dream restarts under // the hub, just close the hub immediately. // the hub, wait for IS_ABLE_TO_DREAM_DELAY_MS and then close the hub. The // delay is necessary so the KeyguardInteractor.isAbleToDream flow passes // through that same amount of delay and publishes a new value which is then // picked up by the HomeSceneFamilyResolver such that the next call to // SceneInteractor.changeScene(Home) will resolve "Home" to "Dream". delay(KeyguardInteractor.IS_ABLE_TO_DREAM_DELAY_MS) communalSceneInteractor.changeScene( CommunalScenes.Blank, "dream started after timeout", Loading packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt +11 −2 Original line number Diff line number Diff line Loading @@ -200,7 +200,10 @@ constructor( * Dozing and dreaming have overlapping events. If the doze state remains in FINISH, it means * that doze mode is not running and DREAMING is ok to commence. * * Allow a brief moment to prevent rapidly oscillating between true/false signals. * Allow a brief moment to prevent rapidly oscillating between true/false signals. The amount of * time is [IS_ABLE_TO_DREAM_DELAY_MS] - consumers should consider waiting for that long before * examining the value of this flow, to let other consumers have enough time to also see that * same new value. */ val isAbleToDream: Flow<Boolean> = dozeTransitionModel Loading @@ -212,7 +215,7 @@ constructor( // do not immediately process any dreaming information when exiting AOD. It // should actually be quite strange to leave AOD and then go straight to // DREAMING so this should be fine. delay(500L) delay(IS_ABLE_TO_DREAM_DELAY_MS) isDreaming .sample(powerInteractor.isAwake) { isDreaming, isAwake -> isDreaming && isAwake Loading Loading @@ -550,5 +553,11 @@ constructor( companion object { private const val TAG = "KeyguardInteractor" /** * Amount of time that [KeyguardInteractor.isAbleToDream] is delayed; consumers of that flow * should consider waiting this amount of time before check the value of this flow, to let * other consumers have enough time to see the new value. */ const val IS_ABLE_TO_DREAM_DELAY_MS = 500L } } Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/communal/CommunalSceneStartableTest.kt +3 −0 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ import com.android.systemui.flags.andSceneContainer import com.android.systemui.flags.fakeFeatureFlagsClassic import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor import com.android.systemui.keyguard.domain.interactor.keyguardInteractor import com.android.systemui.keyguard.domain.interactor.keyguardTransitionInteractor import com.android.systemui.keyguard.shared.model.KeyguardState Loading Loading @@ -494,6 +495,7 @@ class CommunalSceneStartableTest(flags: FlagsParameterization) : SysuiTestCase() // Start dreaming. updateDreaming(true) advanceTimeBy(KeyguardInteractor.IS_ABLE_TO_DREAM_DELAY_MS) // Hub times out immediately. assertThat(scene).isEqualTo(CommunalScenes.Blank) Loading Loading @@ -650,6 +652,7 @@ class CommunalSceneStartableTest(flags: FlagsParameterization) : SysuiTestCase() // Start dreaming. updateDreaming(true) advanceTimeBy(KeyguardInteractor.IS_ABLE_TO_DREAM_DELAY_MS) // Hub times out immediately. assertThat(scene).isEqualTo(Scenes.Dream) Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/scene/domain/startable/SceneContainerStartableTest.kt +32 −6 Original line number Diff line number Diff line Loading @@ -74,6 +74,7 @@ import com.android.systemui.keyguard.data.repository.fakeTrustRepository import com.android.systemui.keyguard.data.repository.keyguardRepository import com.android.systemui.keyguard.data.repository.keyguardTransitionRepository import com.android.systemui.keyguard.dismissCallbackRegistry import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor import com.android.systemui.keyguard.domain.interactor.dozeInteractor import com.android.systemui.keyguard.domain.interactor.keyguardEnabledInteractor import com.android.systemui.keyguard.domain.interactor.keyguardInteractor Loading Loading @@ -1270,8 +1271,11 @@ class SceneContainerStartableTest : SysuiTestCase() { authenticationMethod = AuthenticationMethodModel.None, isLockscreenEnabled = false, ) assertThat(currentSceneKey).isEqualTo(Scenes.Lockscreen) powerInteractor.setAsleepForTest() underTest.start() runCurrent() assertThat(currentSceneKey).isEqualTo(Scenes.Lockscreen) powerInteractor.setAwakeForTest() runCurrent() Loading Loading @@ -2139,6 +2143,7 @@ class SceneContainerStartableTest : SysuiTestCase() { val currentScene by collectLastValue(sceneInteractor.currentScene) val transitionStateFlow = prepareState() underTest.start() runCurrent() emulateSceneTransition(transitionStateFlow, toScene = Scenes.Bouncer) assertThat(currentScene).isNotEqualTo(Scenes.Lockscreen) Loading @@ -2153,6 +2158,7 @@ class SceneContainerStartableTest : SysuiTestCase() { val currentScene by collectLastValue(sceneInteractor.currentScene) val transitionStateFlow = prepareState() underTest.start() runCurrent() emulateSceneTransition(transitionStateFlow, toScene = Scenes.Bouncer) assertThat(currentScene).isEqualTo(Scenes.Bouncer) Loading Loading @@ -2269,6 +2275,7 @@ class SceneContainerStartableTest : SysuiTestCase() { assertThat(currentScene).isEqualTo(Scenes.Gone) assertThat(kosmos.deviceEntryInteractor.isDeviceEntered.value).isTrue() underTest.start() runCurrent() sceneInteractor.changeScene(Scenes.Shade, "") assertThat(currentScene).isEqualTo(Scenes.Shade) assertThat(kosmos.deviceEntryInteractor.isDeviceEntered.value).isTrue() Loading Loading @@ -2350,6 +2357,7 @@ class SceneContainerStartableTest : SysuiTestCase() { val currentScene by collectLastValue(sceneInteractor.currentScene) prepareState() underTest.start() runCurrent() // run all pending dismiss succeeded/cancelled calls from setup: kosmos.fakeExecutor.runAllReady() Loading Loading @@ -2461,13 +2469,18 @@ class SceneContainerStartableTest : SysuiTestCase() { @Test fun switchFromDreamToLockscreen_whenLockedAndDreamStopped() = testScope.runTest { keyguardInteractor.setDreaming(true) val currentScene by collectLastValue(sceneInteractor.currentScene) prepareState(initialSceneKey = Scenes.Dream) assertThat(currentScene).isEqualTo(Scenes.Dream) underTest.start() advanceTimeBy(KeyguardInteractor.IS_ABLE_TO_DREAM_DELAY_MS) runCurrent() keyguardInteractor.setDreaming(true) advanceTimeBy(KeyguardInteractor.IS_ABLE_TO_DREAM_DELAY_MS) runCurrent() assertThat(currentScene).isEqualTo(Scenes.Dream) keyguardInteractor.setDreaming(false) advanceTimeBy(KeyguardInteractor.IS_ABLE_TO_DREAM_DELAY_MS) runCurrent() assertThat(currentScene).isEqualTo(Scenes.Lockscreen) } Loading @@ -2475,13 +2488,18 @@ class SceneContainerStartableTest : SysuiTestCase() { @Test fun switchFromDreamToGone_whenUnlockedAndDreamStopped() = testScope.runTest { keyguardInteractor.setDreaming(true) val currentScene by collectLastValue(sceneInteractor.currentScene) prepareState(initialSceneKey = Scenes.Dream, isDeviceUnlocked = true) assertThat(currentScene).isEqualTo(Scenes.Dream) underTest.start() advanceTimeBy(KeyguardInteractor.IS_ABLE_TO_DREAM_DELAY_MS) runCurrent() keyguardInteractor.setDreaming(true) advanceTimeBy(KeyguardInteractor.IS_ABLE_TO_DREAM_DELAY_MS) runCurrent() assertThat(currentScene).isEqualTo(Scenes.Dream) keyguardInteractor.setDreaming(false) advanceTimeBy(KeyguardInteractor.IS_ABLE_TO_DREAM_DELAY_MS) runCurrent() assertThat(currentScene).isEqualTo(Scenes.Gone) } Loading Loading @@ -2684,6 +2702,7 @@ class SceneContainerStartableTest : SysuiTestCase() { underTest.start() val currentScene by collectLastValue(sceneInteractor.currentScene) val currentOverlays by collectLastValue(sceneInteractor.currentOverlays) runCurrent() sceneInteractor.changeScene(Scenes.Shade, "reason") sceneInteractor.showOverlay(Overlays.NotificationsShade, "reason") assertThat(currentScene).isEqualTo(Scenes.Shade) Loading Loading @@ -2835,8 +2854,15 @@ class SceneContainerStartableTest : SysuiTestCase() { ) sceneInteractor.setTransitionState(transitionStateFlow) initialSceneKey?.let { if (isDeviceUnlocked && initialSceneKey != Scenes.Gone) { // Pass through the Gone scene to populate device entry state properly. transitionStateFlow.value = ObservableTransitionState.Idle(Scenes.Gone) sceneInteractor.changeScene(Scenes.Gone, "prepareState, passing through Gone scene") runCurrent() } transitionStateFlow.value = ObservableTransitionState.Idle(it) sceneInteractor.changeScene(it, "reason") sceneInteractor.changeScene(it, "prepareState, initialSceneKey isn't null") } if (startsAwake) { powerInteractor.setAwakeForTest() Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/domain/interactor/KeyguardBypassInteractorTest.kt +7 −6 Original line number Diff line number Diff line Loading @@ -127,12 +127,6 @@ class KeyguardBypassInteractorTest : SysuiTestCase() { kosmos.configureKeyguardBypass(isBypassAvailable = skipIsBypassAvailableCheck) underTest = kosmos.keyguardBypassInteractor // bouncerShowing false, !onLockscreenScene false // !onLockscreenScene false setScene( bouncerShowing = !skipBouncerShowingCheck, onLockscreenScene = skipOnLockscreenSceneCheck, ) // alternateBouncerShowing false setAlternateBouncerShowing(!skipAlternateBouncerShowingCheck) // launchingAffordance false Loading @@ -141,6 +135,13 @@ class KeyguardBypassInteractorTest : SysuiTestCase() { setPulseExpanding(!skipPulseExpandingCheck) // qsExpanding false setQsExpanded(!skipQsExpandedCheck) // bouncerShowing false, !onLockscreenScene false // !onLockscreenScene false setScene( bouncerShowing = !skipBouncerShowingCheck, onLockscreenScene = skipOnLockscreenSceneCheck, ) } private fun setAlternateBouncerShowing(alternateBouncerVisible: Boolean) { Loading
packages/SystemUI/src/com/android/systemui/communal/CommunalSceneStartable.kt +6 −1 Original line number Diff line number Diff line Loading @@ -183,7 +183,12 @@ constructor( this@CommunalSceneStartable.isDreaming = isDreaming if (scene.isCommunal() && isDreaming && timeoutJob == null) { // If dreaming starts after timeout has expired, ex. if dream restarts under // the hub, just close the hub immediately. // the hub, wait for IS_ABLE_TO_DREAM_DELAY_MS and then close the hub. The // delay is necessary so the KeyguardInteractor.isAbleToDream flow passes // through that same amount of delay and publishes a new value which is then // picked up by the HomeSceneFamilyResolver such that the next call to // SceneInteractor.changeScene(Home) will resolve "Home" to "Dream". delay(KeyguardInteractor.IS_ABLE_TO_DREAM_DELAY_MS) communalSceneInteractor.changeScene( CommunalScenes.Blank, "dream started after timeout", Loading
packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt +11 −2 Original line number Diff line number Diff line Loading @@ -200,7 +200,10 @@ constructor( * Dozing and dreaming have overlapping events. If the doze state remains in FINISH, it means * that doze mode is not running and DREAMING is ok to commence. * * Allow a brief moment to prevent rapidly oscillating between true/false signals. * Allow a brief moment to prevent rapidly oscillating between true/false signals. The amount of * time is [IS_ABLE_TO_DREAM_DELAY_MS] - consumers should consider waiting for that long before * examining the value of this flow, to let other consumers have enough time to also see that * same new value. */ val isAbleToDream: Flow<Boolean> = dozeTransitionModel Loading @@ -212,7 +215,7 @@ constructor( // do not immediately process any dreaming information when exiting AOD. It // should actually be quite strange to leave AOD and then go straight to // DREAMING so this should be fine. delay(500L) delay(IS_ABLE_TO_DREAM_DELAY_MS) isDreaming .sample(powerInteractor.isAwake) { isDreaming, isAwake -> isDreaming && isAwake Loading Loading @@ -550,5 +553,11 @@ constructor( companion object { private const val TAG = "KeyguardInteractor" /** * Amount of time that [KeyguardInteractor.isAbleToDream] is delayed; consumers of that flow * should consider waiting this amount of time before check the value of this flow, to let * other consumers have enough time to see the new value. */ const val IS_ABLE_TO_DREAM_DELAY_MS = 500L } }