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

Commit 6db0f195 authored by Brad Hinegardner's avatar Brad Hinegardner Committed by Android (Google) Code Review
Browse files

Merge "Revert "Hide keyguard immediately on DOZING->GONE"" into main

parents e9a3872a 3b7d9600
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -53,7 +53,7 @@ class DozingToGoneTransitionViewModelTest : SysuiTestCase() {
    @Test
    fun lockscreenAlpha() =
        testScope.runTest {
            val viewState = ViewStateAccessor()
            val viewState = ViewStateAccessor(alpha = { 0.6f })
            val alpha by collectValues(underTest.lockscreenAlpha(viewState))

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

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

    @Test
+4 −31
Original line number Diff line number Diff line
@@ -29,7 +29,6 @@ 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
@@ -66,7 +65,6 @@ constructor(

    override fun start() {
        listenForDozingToAny()
        listenForDozingToGoneViaBiometrics()
        listenForWakeFromDozing()
        listenForTransitionToCamera(scope, keyguardInteractor)
    }
@@ -79,35 +77,6 @@ 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
@@ -118,6 +87,7 @@ constructor(
                .debounce(50L)
                .filterRelevantKeyguardStateAnd { isAwake -> isAwake }
                .sample(
                    keyguardInteractor.biometricUnlockState,
                    keyguardInteractor.isKeyguardOccluded,
                    communalInteractor.isIdleOnCommunal,
                    canTransitionToGoneOnWake,
@@ -126,6 +96,7 @@ constructor(
                .collect {
                    (
                        _,
                        biometricUnlockState,
                        occluded,
                        isIdleOnCommunal,
                        canTransitionToGoneOnWake,
@@ -133,6 +104,8 @@ constructor(
                    startTransitionTo(
                        if (!deviceEntryRepository.isLockscreenEnabled()) {
                            KeyguardState.GONE
                        } else if (isWakeAndUnlock(biometricUnlockState.mode)) {
                            KeyguardState.GONE
                        } else if (canTransitionToGoneOnWake) {
                            KeyguardState.GONE
                        } else if (primaryBouncerShowing) {
+5 −2
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

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
@@ -49,10 +50,12 @@ constructor(
            )

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

+2 −2
Original line number Diff line number Diff line
@@ -570,13 +570,13 @@ class KeyguardTransitionScenariosTest(flags: FlagsParameterization?) : SysuiTest
            // WHEN biometrics succeeds with wake and unlock mode
            powerInteractor.setAwakeForTest()
            keyguardRepository.setBiometricUnlockState(BiometricUnlockMode.WAKE_AND_UNLOCK)
            runCurrent()
            advanceTimeBy(60L)

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