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

Commit 411b301d authored by Matt Pietal's avatar Matt Pietal
Browse files

Hide keyguard immediately on DOZING->GONE

Don't delay, or the clock will flash.

Test: atest DozingToGoneTransitionViewModelTest
Fixes: 338412830
Flag: EXEMPT addresses flickering for all devices
Change-Id: I26392ef148086b122873d72011565da0696a22ce
parent b01d46eb
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -53,7 +53,7 @@ class DozingToGoneTransitionViewModelTest : SysuiTestCase() {
    @Test
    fun lockscreenAlpha() =
        testScope.runTest {
            val viewState = ViewStateAccessor(alpha = { 0.6f })
            val viewState = ViewStateAccessor()
            val alpha by collectValues(underTest.lockscreenAlpha(viewState))

            keyguardTransitionRepository.sendTransitionSteps(
@@ -62,11 +62,9 @@ class DozingToGoneTransitionViewModelTest : SysuiTestCase() {
                testScope
            )

            assertThat(alpha[0]).isEqualTo(0.6f)
            // Fades out just prior to halfway
            // Remain at zero throughout
            assertThat(alpha[0]).isEqualTo(0f)
            assertThat(alpha[1]).isEqualTo(0f)
            // Must finish at 0
            assertThat(alpha[2]).isEqualTo(0f)
        }

    @Test
+31 −4
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import com.android.systemui.keyguard.shared.model.BiometricUnlockMode.Companion.
import com.android.systemui.keyguard.shared.model.KeyguardState
import com.android.systemui.power.domain.interactor.PowerInteractor
import com.android.systemui.util.kotlin.Utils.Companion.sample
import com.android.systemui.util.kotlin.sample
import javax.inject.Inject
import kotlin.time.Duration.Companion.milliseconds
import kotlinx.coroutines.CoroutineDispatcher
@@ -65,6 +66,7 @@ constructor(

    override fun start() {
        listenForDozingToAny()
        listenForDozingToGoneViaBiometrics()
        listenForWakeFromDozing()
        listenForTransitionToCamera(scope, keyguardInteractor)
    }
@@ -77,6 +79,35 @@ constructor(
            isKeyguardDismissible && !isKeyguardShowing
        }

    private fun listenForDozingToGoneViaBiometrics() {
        if (KeyguardWmStateRefactor.isEnabled) {
            return
        }

        // This is separate from `listenForDozingToAny` because any delay on wake and unlock will
        // cause a noticeable issue with animations
        scope.launch {
            powerInteractor.isAwake
                .filterRelevantKeyguardStateAnd { isAwake -> isAwake }
                .sample(
                    keyguardInteractor.biometricUnlockState,
                    ::Pair,
                )
                .collect {
                    (
                        _,
                        biometricUnlockState,
                    ) ->
                    if (isWakeAndUnlock(biometricUnlockState.mode)) {
                        startTransitionTo(
                            KeyguardState.GONE,
                            ownerReason = "biometric wake and unlock",
                        )
                    }
                }
        }
    }

    private fun listenForDozingToAny() {
        if (KeyguardWmStateRefactor.isEnabled) {
            return
@@ -87,7 +118,6 @@ constructor(
                .debounce(50L)
                .filterRelevantKeyguardStateAnd { isAwake -> isAwake }
                .sample(
                    keyguardInteractor.biometricUnlockState,
                    keyguardInteractor.isKeyguardOccluded,
                    communalInteractor.isIdleOnCommunal,
                    canTransitionToGoneOnWake,
@@ -96,7 +126,6 @@ constructor(
                .collect {
                    (
                        _,
                        biometricUnlockState,
                        occluded,
                        isIdleOnCommunal,
                        canTransitionToGoneOnWake,
@@ -104,8 +133,6 @@ constructor(
                    startTransitionTo(
                        if (!deviceEntryRepository.isLockscreenEnabled()) {
                            KeyguardState.GONE
                        } else if (isWakeAndUnlock(biometricUnlockState.mode)) {
                            KeyguardState.GONE
                        } else if (canTransitionToGoneOnWake) {
                            KeyguardState.GONE
                        } else if (primaryBouncerShowing) {
+2 −5
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package com.android.systemui.keyguard.ui.viewmodel

import android.util.MathUtils
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.keyguard.domain.interactor.FromDozingTransitionInteractor.Companion.TO_GONE_DURATION
import com.android.systemui.keyguard.shared.model.Edge
@@ -50,12 +49,10 @@ constructor(
            )

    fun lockscreenAlpha(viewState: ViewStateAccessor): Flow<Float> {
        var startAlpha = 1f
        return transitionAnimation.sharedFlow(
            duration = 200.milliseconds,
            onStart = { startAlpha = viewState.alpha() },
            onStep = { MathUtils.lerp(startAlpha, 0f, it) },
            onFinish = { 0f },
            onStart = { 0f },
            onStep = { 0f },
        )
    }

+3 −0
Original line number Diff line number Diff line
@@ -538,6 +538,9 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp
                    // later to awaken.
                }
                mNotificationShadeWindowController.setNotificationShadeFocusable(false);
                // Notify the interactor first, to prevent race conditions with the screen waking up
                // that would show a flicker of the lockscreen on DOZING->GONE
                mBiometricUnlockInteractor.setBiometricUnlockState(mode, biometricUnlockSource);
                mKeyguardViewMediator.onWakeAndUnlocking(wakeInKeyguard);
                Trace.endSection();
                break;
+2 −2
Original line number Diff line number Diff line
@@ -569,13 +569,13 @@ class KeyguardTransitionScenariosTest(flags: FlagsParameterization?) : SysuiTest
            // WHEN biometrics succeeds with wake and unlock mode
            powerInteractor.setAwakeForTest()
            keyguardRepository.setBiometricUnlockState(BiometricUnlockMode.WAKE_AND_UNLOCK)
            advanceTimeBy(60L)
            runCurrent()

            assertThat(transitionRepository)
                .startedTransition(
                    to = KeyguardState.GONE,
                    from = KeyguardState.DOZING,
                    ownerName = "FromDozingTransitionInteractor",
                    ownerName = "FromDozingTransitionInteractor(biometric wake and unlock)",
                    animatorAssertion = { it.isNotNull() }
                )