Loading packages/SystemUI/src/com/android/keyguard/ClockEventController.kt +17 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ import com.android.systemui.keyguard.MigrateClocksToBlueprint import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor import com.android.systemui.keyguard.shared.model.KeyguardState.AOD import com.android.systemui.keyguard.shared.model.KeyguardState.DOZING import com.android.systemui.keyguard.shared.model.KeyguardState.LOCKSCREEN import com.android.systemui.keyguard.shared.model.TransitionState import com.android.systemui.lifecycle.repeatWhenAttached Loading Loading @@ -432,6 +433,7 @@ constructor( listenForDozeAmountTransition(this) listenForAnyStateToAodTransition(this) listenForAnyStateToLockscreenTransition(this) listenForAnyStateToDozingTransition(this) } else { listenForDozeAmount(this) } Loading Loading @@ -578,6 +580,21 @@ constructor( } } /** * When keyguard is displayed due to pulsing notifications when AOD is off, * we should make sure clock is in dozing state instead of LS state */ @VisibleForTesting internal fun listenForAnyStateToDozingTransition(scope: CoroutineScope): Job { return scope.launch { keyguardTransitionInteractor .transitionStepsToState(DOZING) .filter { it.transitionState == TransitionState.FINISHED } .collect { handleDoze(1f) } } } @VisibleForTesting internal fun listenForDozing(scope: CoroutineScope): Job { return scope.launch { Loading packages/SystemUI/tests/src/com/android/keyguard/ClockEventControllerTest.kt +22 −1 Original line number Diff line number Diff line Loading @@ -371,7 +371,7 @@ class ClockEventControllerTest : SysuiTestCase() { } @Test fun listenForTransitionToLSFromOccluded_updatesClockDozeAmountToOne() = fun listenForTransitionToLSFromOccluded_updatesClockDozeAmountToZero() = runBlocking(IMMEDIATE) { val transitionStep = MutableStateFlow(TransitionStep()) whenever(keyguardTransitionInteractor.transitionStepsToState(KeyguardState.LOCKSCREEN)) Loading Loading @@ -433,6 +433,27 @@ class ClockEventControllerTest : SysuiTestCase() { job.cancel() } @Test fun listenForAnyStateToDozingTransition_UpdatesClockDozeAmountToOne() = runBlocking(IMMEDIATE) { val transitionStep = MutableStateFlow(TransitionStep()) whenever(keyguardTransitionInteractor.transitionStepsToState(KeyguardState.DOZING)) .thenReturn(transitionStep) val job = underTest.listenForAnyStateToDozingTransition(this) transitionStep.value = TransitionStep( from = KeyguardState.LOCKSCREEN, to = KeyguardState.DOZING, transitionState = TransitionState.STARTED, ) yield() verify(animations, times(2)).doze(1f) job.cancel() } @Test fun unregisterListeners_validate() = runBlocking(IMMEDIATE) { Loading Loading
packages/SystemUI/src/com/android/keyguard/ClockEventController.kt +17 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ import com.android.systemui.keyguard.MigrateClocksToBlueprint import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor import com.android.systemui.keyguard.shared.model.KeyguardState.AOD import com.android.systemui.keyguard.shared.model.KeyguardState.DOZING import com.android.systemui.keyguard.shared.model.KeyguardState.LOCKSCREEN import com.android.systemui.keyguard.shared.model.TransitionState import com.android.systemui.lifecycle.repeatWhenAttached Loading Loading @@ -432,6 +433,7 @@ constructor( listenForDozeAmountTransition(this) listenForAnyStateToAodTransition(this) listenForAnyStateToLockscreenTransition(this) listenForAnyStateToDozingTransition(this) } else { listenForDozeAmount(this) } Loading Loading @@ -578,6 +580,21 @@ constructor( } } /** * When keyguard is displayed due to pulsing notifications when AOD is off, * we should make sure clock is in dozing state instead of LS state */ @VisibleForTesting internal fun listenForAnyStateToDozingTransition(scope: CoroutineScope): Job { return scope.launch { keyguardTransitionInteractor .transitionStepsToState(DOZING) .filter { it.transitionState == TransitionState.FINISHED } .collect { handleDoze(1f) } } } @VisibleForTesting internal fun listenForDozing(scope: CoroutineScope): Job { return scope.launch { Loading
packages/SystemUI/tests/src/com/android/keyguard/ClockEventControllerTest.kt +22 −1 Original line number Diff line number Diff line Loading @@ -371,7 +371,7 @@ class ClockEventControllerTest : SysuiTestCase() { } @Test fun listenForTransitionToLSFromOccluded_updatesClockDozeAmountToOne() = fun listenForTransitionToLSFromOccluded_updatesClockDozeAmountToZero() = runBlocking(IMMEDIATE) { val transitionStep = MutableStateFlow(TransitionStep()) whenever(keyguardTransitionInteractor.transitionStepsToState(KeyguardState.LOCKSCREEN)) Loading Loading @@ -433,6 +433,27 @@ class ClockEventControllerTest : SysuiTestCase() { job.cancel() } @Test fun listenForAnyStateToDozingTransition_UpdatesClockDozeAmountToOne() = runBlocking(IMMEDIATE) { val transitionStep = MutableStateFlow(TransitionStep()) whenever(keyguardTransitionInteractor.transitionStepsToState(KeyguardState.DOZING)) .thenReturn(transitionStep) val job = underTest.listenForAnyStateToDozingTransition(this) transitionStep.value = TransitionStep( from = KeyguardState.LOCKSCREEN, to = KeyguardState.DOZING, transitionState = TransitionState.STARTED, ) yield() verify(animations, times(2)).doze(1f) job.cancel() } @Test fun unregisterListeners_validate() = runBlocking(IMMEDIATE) { Loading