Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 20d5e754 authored by Sherry Zhou's avatar Sherry Zhou
Browse files

Reland fixing clock staying in AOD state in LS when transitioning from bouncer and camera

Flag: ACONFIG com.android.systemui.migrate_clocks_to_blueprint STAGING
Bug: 330187403
Test: manual, atest ClockEventControllerTest

Change-Id: I93dd5ab34ff3f596388770c287794628c49ad598
parent db03730b
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -430,6 +430,7 @@ constructor(
                    if (MigrateClocksToBlueprint.isEnabled) {
                        listenForDozeAmountTransition(this)
                        listenForAnyStateToAodTransition(this)
                        listenForAnyStateToLockscreenTransition(this)
                    } else {
                        listenForDozeAmount(this)
                    }
@@ -561,6 +562,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 {
+42 −0
Original line number Diff line number Diff line
@@ -360,6 +360,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) {
@@ -381,6 +402,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) {