Loading packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/WindowManagerLockscreenVisibilityInteractorTest.kt +35 −0 Original line number Diff line number Diff line Loading @@ -1045,6 +1045,41 @@ class WindowManagerLockscreenVisibilityInteractorTest : SysuiTestCase() { assertThat(usingKeyguardGoingAwayAnimation).isFalse() } @Test fun aodVisibility_visibleFullyInAod_falseOtherwise() = testScope.runTest { val aodVisibility by collectValues(underTest.value.aodVisibility) transitionRepository.sendTransitionStepsThroughRunning( from = KeyguardState.LOCKSCREEN, to = KeyguardState.AOD, testScope, throughValue = 0.5f, ) assertEquals(listOf(false), aodVisibility) transitionRepository.sendTransitionStep( TransitionStep( transitionState = TransitionState.FINISHED, from = KeyguardState.LOCKSCREEN, to = KeyguardState.AOD, ) ) runCurrent() assertEquals(listOf(false, true), aodVisibility) transitionRepository.sendTransitionStepsThroughRunning( from = KeyguardState.AOD, to = KeyguardState.GONE, testScope, ) runCurrent() assertEquals(listOf(false, true, false), aodVisibility) } companion object { private val progress = MutableStateFlow(0f) Loading packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/WindowManagerLockscreenVisibilityInteractor.kt +3 −12 Original line number Diff line number Diff line Loading @@ -24,7 +24,6 @@ import com.android.systemui.Flags.transitionRaceCondition import com.android.systemui.dagger.SysUISingleton import com.android.systemui.deviceentry.domain.interactor.DeviceEntryInteractor import com.android.systemui.keyguard.data.repository.KeyguardTransitionRepository import com.android.systemui.keyguard.shared.model.BiometricUnlockMode import com.android.systemui.keyguard.shared.model.Edge import com.android.systemui.keyguard.shared.model.KeyguardState import com.android.systemui.keyguard.shared.model.KeyguardState.Companion.deviceIsAsleepInState Loading Loading @@ -331,17 +330,9 @@ constructor( * clock/smartspace/notif icons are visible. */ val aodVisibility: Flow<Boolean> = combine( keyguardInteractor.isDozing, keyguardInteractor.isAodAvailable, keyguardInteractor.biometricUnlockState, ) { isDozing, isAodAvailable, biometricUnlockState -> // AOD is visible if we're dozing, unless we are wake and unlocking (where we go // directly from AOD to unlocked while dozing). isDozing && isAodAvailable && !BiometricUnlockMode.isWakeAndUnlock(biometricUnlockState.mode) } transitionInteractor .transitionValue(KeyguardState.AOD) .map { it == 1f } .distinctUntilChanged() companion object { Loading packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardTransitionRepository.kt +27 −6 Original line number Diff line number Diff line Loading @@ -124,8 +124,8 @@ class FakeKeyguardTransitionRepository( /** * Sends TransitionSteps between [from] and [to], calling [runCurrent] after each step. * * By default, sends steps through FINISHED (STARTED, RUNNING, FINISHED) but can be halted part * way using [throughTransitionState]. * By default, sends steps through FINISHED (STARTED, RUNNING @0.5f, RUNNING @1f, FINISHED) but * can be halted part way using [throughTransitionState]. */ suspend fun sendTransitionSteps( from: KeyguardState, Loading @@ -136,6 +136,25 @@ class FakeKeyguardTransitionRepository( sendTransitionSteps(from, to, testScope.testScheduler, throughTransitionState) } /** * Sends a STARTED step between [from] and [to], followed by two RUNNING steps at value * [throughValue] / 2 and [throughValue], calling [runCurrent] after each step. */ suspend fun sendTransitionStepsThroughRunning( from: KeyguardState, to: KeyguardState, testScope: TestScope, throughValue: Float = 1f, ) { sendTransitionSteps( from, to, testScope.testScheduler, TransitionState.RUNNING, throughValue, ) } /** * Sends the provided [step] and makes sure that all previous [TransitionState]'s are sent when * [fillInSteps] is true. e.g. when a step FINISHED is provided, a step with STARTED and RUNNING Loading Loading @@ -178,14 +197,15 @@ class FakeKeyguardTransitionRepository( /** * Sends TransitionSteps between [from] and [to], calling [runCurrent] after each step. * * By default, sends steps through FINISHED (STARTED, RUNNING, FINISHED) but can be halted part * way using [throughTransitionState]. * By default, sends steps through FINISHED (STARTED, RUNNING @0.5f, RUNNING @1f, FINISHED) but * can be halted part way using [throughTransitionState]. */ suspend fun sendTransitionSteps( from: KeyguardState, to: KeyguardState, testScheduler: TestCoroutineScheduler, throughTransitionState: TransitionState = TransitionState.FINISHED, throughTransitionValue: Float = 1f, ) { val lastStep = _transitions.replayCache.lastOrNull() if (lastStep != null && lastStep.transitionState != TransitionState.FINISHED) { Loading Loading @@ -216,13 +236,14 @@ class FakeKeyguardTransitionRepository( throughTransitionState == TransitionState.RUNNING || throughTransitionState == TransitionState.FINISHED ) { // Send two steps to better simulate RUNNING transitions. sendTransitionStep( step = TransitionStep( transitionState = TransitionState.RUNNING, from = from, to = to, value = 0.5f, value = throughTransitionValue / 2f, ) ) testScheduler.runCurrent() Loading @@ -233,7 +254,7 @@ class FakeKeyguardTransitionRepository( transitionState = TransitionState.RUNNING, from = from, to = to, value = 1f, value = throughTransitionValue, ) ) testScheduler.runCurrent() Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/WindowManagerLockscreenVisibilityInteractorTest.kt +35 −0 Original line number Diff line number Diff line Loading @@ -1045,6 +1045,41 @@ class WindowManagerLockscreenVisibilityInteractorTest : SysuiTestCase() { assertThat(usingKeyguardGoingAwayAnimation).isFalse() } @Test fun aodVisibility_visibleFullyInAod_falseOtherwise() = testScope.runTest { val aodVisibility by collectValues(underTest.value.aodVisibility) transitionRepository.sendTransitionStepsThroughRunning( from = KeyguardState.LOCKSCREEN, to = KeyguardState.AOD, testScope, throughValue = 0.5f, ) assertEquals(listOf(false), aodVisibility) transitionRepository.sendTransitionStep( TransitionStep( transitionState = TransitionState.FINISHED, from = KeyguardState.LOCKSCREEN, to = KeyguardState.AOD, ) ) runCurrent() assertEquals(listOf(false, true), aodVisibility) transitionRepository.sendTransitionStepsThroughRunning( from = KeyguardState.AOD, to = KeyguardState.GONE, testScope, ) runCurrent() assertEquals(listOf(false, true, false), aodVisibility) } companion object { private val progress = MutableStateFlow(0f) Loading
packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/WindowManagerLockscreenVisibilityInteractor.kt +3 −12 Original line number Diff line number Diff line Loading @@ -24,7 +24,6 @@ import com.android.systemui.Flags.transitionRaceCondition import com.android.systemui.dagger.SysUISingleton import com.android.systemui.deviceentry.domain.interactor.DeviceEntryInteractor import com.android.systemui.keyguard.data.repository.KeyguardTransitionRepository import com.android.systemui.keyguard.shared.model.BiometricUnlockMode import com.android.systemui.keyguard.shared.model.Edge import com.android.systemui.keyguard.shared.model.KeyguardState import com.android.systemui.keyguard.shared.model.KeyguardState.Companion.deviceIsAsleepInState Loading Loading @@ -331,17 +330,9 @@ constructor( * clock/smartspace/notif icons are visible. */ val aodVisibility: Flow<Boolean> = combine( keyguardInteractor.isDozing, keyguardInteractor.isAodAvailable, keyguardInteractor.biometricUnlockState, ) { isDozing, isAodAvailable, biometricUnlockState -> // AOD is visible if we're dozing, unless we are wake and unlocking (where we go // directly from AOD to unlocked while dozing). isDozing && isAodAvailable && !BiometricUnlockMode.isWakeAndUnlock(biometricUnlockState.mode) } transitionInteractor .transitionValue(KeyguardState.AOD) .map { it == 1f } .distinctUntilChanged() companion object { Loading
packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardTransitionRepository.kt +27 −6 Original line number Diff line number Diff line Loading @@ -124,8 +124,8 @@ class FakeKeyguardTransitionRepository( /** * Sends TransitionSteps between [from] and [to], calling [runCurrent] after each step. * * By default, sends steps through FINISHED (STARTED, RUNNING, FINISHED) but can be halted part * way using [throughTransitionState]. * By default, sends steps through FINISHED (STARTED, RUNNING @0.5f, RUNNING @1f, FINISHED) but * can be halted part way using [throughTransitionState]. */ suspend fun sendTransitionSteps( from: KeyguardState, Loading @@ -136,6 +136,25 @@ class FakeKeyguardTransitionRepository( sendTransitionSteps(from, to, testScope.testScheduler, throughTransitionState) } /** * Sends a STARTED step between [from] and [to], followed by two RUNNING steps at value * [throughValue] / 2 and [throughValue], calling [runCurrent] after each step. */ suspend fun sendTransitionStepsThroughRunning( from: KeyguardState, to: KeyguardState, testScope: TestScope, throughValue: Float = 1f, ) { sendTransitionSteps( from, to, testScope.testScheduler, TransitionState.RUNNING, throughValue, ) } /** * Sends the provided [step] and makes sure that all previous [TransitionState]'s are sent when * [fillInSteps] is true. e.g. when a step FINISHED is provided, a step with STARTED and RUNNING Loading Loading @@ -178,14 +197,15 @@ class FakeKeyguardTransitionRepository( /** * Sends TransitionSteps between [from] and [to], calling [runCurrent] after each step. * * By default, sends steps through FINISHED (STARTED, RUNNING, FINISHED) but can be halted part * way using [throughTransitionState]. * By default, sends steps through FINISHED (STARTED, RUNNING @0.5f, RUNNING @1f, FINISHED) but * can be halted part way using [throughTransitionState]. */ suspend fun sendTransitionSteps( from: KeyguardState, to: KeyguardState, testScheduler: TestCoroutineScheduler, throughTransitionState: TransitionState = TransitionState.FINISHED, throughTransitionValue: Float = 1f, ) { val lastStep = _transitions.replayCache.lastOrNull() if (lastStep != null && lastStep.transitionState != TransitionState.FINISHED) { Loading Loading @@ -216,13 +236,14 @@ class FakeKeyguardTransitionRepository( throughTransitionState == TransitionState.RUNNING || throughTransitionState == TransitionState.FINISHED ) { // Send two steps to better simulate RUNNING transitions. sendTransitionStep( step = TransitionStep( transitionState = TransitionState.RUNNING, from = from, to = to, value = 0.5f, value = throughTransitionValue / 2f, ) ) testScheduler.runCurrent() Loading @@ -233,7 +254,7 @@ class FakeKeyguardTransitionRepository( transitionState = TransitionState.RUNNING, from = from, to = to, value = 1f, value = throughTransitionValue, ) ) testScheduler.runCurrent() Loading