diff options
| -rw-r--r-- | packages/SystemUI/src/com/android/keyguard/ClockEventController.kt | 12 | ||||
| -rw-r--r-- | packages/SystemUI/tests/src/com/android/keyguard/ClockEventControllerTest.kt | 42 |
2 files changed, 54 insertions, 0 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/ClockEventController.kt b/packages/SystemUI/src/com/android/keyguard/ClockEventController.kt index 7c454078ad0e..460779c73cda 100644 --- a/packages/SystemUI/src/com/android/keyguard/ClockEventController.kt +++ b/packages/SystemUI/src/com/android/keyguard/ClockEventController.kt @@ -431,6 +431,7 @@ constructor( if (MigrateClocksToBlueprint.isEnabled) { listenForDozeAmountTransition(this) listenForAnyStateToAodTransition(this) + listenForAnyStateToLockscreenTransition(this) } else { listenForDozeAmount(this) } @@ -567,6 +568,17 @@ constructor( } @VisibleForTesting + internal fun listenForAnyStateToLockscreenTransition(scope: CoroutineScope): Job { + return scope.launch { + keyguardTransitionInteractor + .transitionStepsToState(LOCKSCREEN) + .filter { it.transitionState == TransitionState.STARTED } + .filter { it.from != AOD } + .collect { handleDoze(0f) } + } + } + + @VisibleForTesting internal fun listenForDozing(scope: CoroutineScope): Job { return scope.launch { combine( diff --git a/packages/SystemUI/tests/src/com/android/keyguard/ClockEventControllerTest.kt b/packages/SystemUI/tests/src/com/android/keyguard/ClockEventControllerTest.kt index 46684dcac315..e72027a921b7 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/ClockEventControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/keyguard/ClockEventControllerTest.kt @@ -371,6 +371,27 @@ class ClockEventControllerTest : SysuiTestCase() { } @Test + fun listenForTransitionToLSFromOccluded_updatesClockDozeAmountToOne() = + runBlocking(IMMEDIATE) { + val transitionStep = MutableStateFlow(TransitionStep()) + whenever(keyguardTransitionInteractor.transitionStepsToState(KeyguardState.LOCKSCREEN)) + .thenReturn(transitionStep) + + val job = underTest.listenForAnyStateToLockscreenTransition(this) + transitionStep.value = + TransitionStep( + from = KeyguardState.OCCLUDED, + to = KeyguardState.LOCKSCREEN, + transitionState = TransitionState.STARTED, + ) + yield() + + verify(animations, times(2)).doze(0f) + + job.cancel() + } + + @Test fun listenForTransitionToAodFromLockscreen_neverUpdatesClockDozeAmount() = runBlocking(IMMEDIATE) { val transitionStep = MutableStateFlow(TransitionStep()) @@ -388,6 +409,27 @@ class ClockEventControllerTest : SysuiTestCase() { verify(animations, never()).doze(1f) + job.cancel() + } + + @Test + fun listenForAnyStateToLockscreenTransition_neverUpdatesClockDozeAmount() = + runBlocking(IMMEDIATE) { + val transitionStep = MutableStateFlow(TransitionStep()) + whenever(keyguardTransitionInteractor.transitionStepsToState(KeyguardState.LOCKSCREEN)) + .thenReturn(transitionStep) + + val job = underTest.listenForAnyStateToLockscreenTransition(this) + transitionStep.value = + TransitionStep( + from = KeyguardState.AOD, + to = KeyguardState.LOCKSCREEN, + transitionState = TransitionState.STARTED, + ) + yield() + + verify(animations, never()).doze(0f) + job.cancel() } |