Loading packages/SystemUI/src/com/android/keyguard/ClockEventController.kt +12 −0 Original line number Diff line number Diff line Loading @@ -432,6 +432,7 @@ constructor( if (MigrateClocksToBlueprint.isEnabled) { listenForDozeAmountTransition(this) listenForAnyStateToAodTransition(this) listenForAnyStateToLockscreenTransition(this) } else { listenForDozeAmount(this) } Loading Loading @@ -565,6 +566,17 @@ constructor( } } @VisibleForTesting internal fun listenForAnyStateToLockscreenTransition(scope: CoroutineScope): Job { return scope.launch("$TAG#listenForAnyStateToLockscreenTransition") { 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("$TAG#listenForDozing") { Loading packages/SystemUI/tests/src/com/android/keyguard/ClockEventControllerTest.kt +42 −0 Original line number Diff line number Diff line Loading @@ -361,6 +361,27 @@ class ClockEventControllerTest : SysuiTestCase() { job.cancel() } @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) { Loading @@ -382,6 +403,27 @@ class ClockEventControllerTest : SysuiTestCase() { 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() } @Test fun unregisterListeners_validate() = runBlocking(IMMEDIATE) { Loading Loading
packages/SystemUI/src/com/android/keyguard/ClockEventController.kt +12 −0 Original line number Diff line number Diff line Loading @@ -432,6 +432,7 @@ constructor( if (MigrateClocksToBlueprint.isEnabled) { listenForDozeAmountTransition(this) listenForAnyStateToAodTransition(this) listenForAnyStateToLockscreenTransition(this) } else { listenForDozeAmount(this) } Loading Loading @@ -565,6 +566,17 @@ constructor( } } @VisibleForTesting internal fun listenForAnyStateToLockscreenTransition(scope: CoroutineScope): Job { return scope.launch("$TAG#listenForAnyStateToLockscreenTransition") { 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("$TAG#listenForDozing") { Loading
packages/SystemUI/tests/src/com/android/keyguard/ClockEventControllerTest.kt +42 −0 Original line number Diff line number Diff line Loading @@ -361,6 +361,27 @@ class ClockEventControllerTest : SysuiTestCase() { job.cancel() } @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) { Loading @@ -382,6 +403,27 @@ class ClockEventControllerTest : SysuiTestCase() { 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() } @Test fun unregisterListeners_validate() = runBlocking(IMMEDIATE) { Loading