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

Commit 98efd836 authored by Sherry Zhou's avatar Sherry Zhou
Browse files

Fix clocks showing colored style for pulsing notifications

Bug: 338600948
Test: atest ClockEventControllerTest. Manually test by turning off AOD, adding a 5s delayed notification in go/notify-apk and turning off the screen by pressing
power button; Observe the screen wakes up after 5s and color is shown in
AOD style.
Flag: ACONFIG com.android.systemui.migrate_clocks_to_blueprint STAGING

Change-Id: I068a0be3b77ce02b2f4fcea8c23a7bc358fd8ed9
parent 8cea9345
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -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
@@ -432,6 +433,7 @@ constructor(
                        listenForDozeAmountTransition(this)
                        listenForAnyStateToAodTransition(this)
                        listenForAnyStateToLockscreenTransition(this)
                        listenForAnyStateToDozingTransition(this)
                    } else {
                        listenForDozeAmount(this)
                    }
@@ -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 {
+22 −1
Original line number Diff line number Diff line
@@ -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))
@@ -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) {