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

Commit 759538ca authored by Sherry Zhou's avatar Sherry Zhou Committed by Android (Google) Code Review
Browse files

Merge "Fix clocks showing colored style for pulsing notifications" into main

parents e08677a6 98efd836
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) {