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

Commit 847aad3e authored by Josh Tsuji's avatar Josh Tsuji Committed by Android (Google) Code Review
Browse files

Merge "Allow face auth while asleep; fix KeyguardTransitionRepository test issues." into main

parents ed8cda6a be83bf7f
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -383,7 +383,12 @@ constructor(
                "isFaceAuthEnrolledAndEnabled"
            ),
            Pair(keyguardRepository.isKeyguardGoingAway.isFalse(), "keyguardNotGoingAway"),
            Pair(powerInteractor.isAsleep.isFalse(), "deviceNotAsleep"),
            Pair(
                keyguardTransitionInteractor
                    .isInTransitionToStateWhere(KeyguardState::deviceIsAsleepInState)
                    .isFalse(),
                "deviceNotTransitioningToAsleepState"
            ),
            Pair(
                keyguardInteractor.isSecureCameraActive
                    .isFalse()
+2 −1
Original line number Diff line number Diff line
@@ -115,7 +115,8 @@ class KeyguardTransitionRepositoryImpl @Inject constructor() : KeyguardTransitio
    private var updateTransitionId: UUID? = null

    init {
        // Seed with transitions signaling a boot into lockscreen state
        // Seed with transitions signaling a boot into lockscreen state. If updating this, please
        // also update FakeKeyguardTransitionRepository.
        emitTransition(
            TransitionStep(
                KeyguardState.OFF,
+8 −6
Original line number Diff line number Diff line
@@ -12,7 +12,6 @@ import com.android.systemui.keyguard.data.repository.FakeKeyguardTransitionRepos
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractorFactory
import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractorFactory
import com.android.systemui.keyguard.shared.model.KeyguardState
import com.android.systemui.keyguard.shared.model.TransitionStep
import com.android.systemui.power.domain.interactor.PowerInteractor
import com.android.systemui.power.domain.interactor.PowerInteractor.Companion.setAsleepForTest
import com.android.systemui.power.domain.interactor.PowerInteractorFactory
@@ -45,7 +44,6 @@ class ResourceTrimmerTest : SysuiTestCase() {
    private val keyguardTransitionRepository = FakeKeyguardTransitionRepository()
    private lateinit var powerInteractor: PowerInteractor


    @Mock private lateinit var globalWindowManager: GlobalWindowManager
    private lateinit var resourceTrimmer: ResourceTrimmer

@@ -181,8 +179,10 @@ class ResourceTrimmerTest : SysuiTestCase() {
    @Test
    fun keyguardTransitionsToGone_trimsFontCache() =
        testScope.runTest {
            keyguardTransitionRepository.sendTransitionStep(
                TransitionStep(KeyguardState.LOCKSCREEN, KeyguardState.GONE)
            keyguardTransitionRepository.sendTransitionSteps(
                from = KeyguardState.LOCKSCREEN,
                to = KeyguardState.GONE,
                testScope
            )
            verify(globalWindowManager, times(1))
                .trimMemory(ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN)
@@ -194,8 +194,10 @@ class ResourceTrimmerTest : SysuiTestCase() {
    fun keyguardTransitionsToGone_flagDisabled_doesNotTrimFontCache() =
        testScope.runTest {
            featureFlags.set(Flags.TRIM_FONT_CACHES_AT_UNLOCK, false)
            keyguardTransitionRepository.sendTransitionStep(
                TransitionStep(KeyguardState.LOCKSCREEN, KeyguardState.GONE)
            keyguardTransitionRepository.sendTransitionSteps(
                from = KeyguardState.LOCKSCREEN,
                to = KeyguardState.GONE,
                testScope
            )
            // Memory hidden should still be called.
            verify(globalWindowManager, times(1))
+55 −48
Original line number Diff line number Diff line
@@ -32,7 +32,6 @@ import android.hardware.face.FaceManager
import android.hardware.face.FaceSensorProperties
import android.hardware.face.FaceSensorPropertiesInternal
import android.os.CancellationSignal
import android.util.Log
import android.view.Display
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
@@ -637,7 +636,19 @@ class DeviceEntryFaceAuthRepositoryTest : SysuiTestCase() {

    @Test
    fun authenticateDoesNotRunWhenDeviceIsGoingToSleep() =
        testScope.runTest { testGatingCheckForFaceAuth { powerInteractor.setAsleepForTest() } }
        testScope.runTest {
            testGatingCheckForFaceAuth {
                powerInteractor.setAsleepForTest()
                keyguardTransitionRepository.sendTransitionStep(
                    TransitionStep(
                        transitionState = TransitionState.STARTED,
                        from = KeyguardState.LOCKSCREEN,
                        to = KeyguardState.AOD,
                    )
                )
                runCurrent()
            }
        }

    @Test
    fun authenticateDoesNotRunWhenSecureCameraIsActive() =
@@ -733,13 +744,10 @@ class DeviceEntryFaceAuthRepositoryTest : SysuiTestCase() {

            allPreconditionsToRunFaceAuthAreTrue()

            Log.i("TEST", "started waking")
            keyguardTransitionRepository.sendTransitionStep(
                TransitionStep(
            keyguardTransitionRepository.sendTransitionSteps(
                from = KeyguardState.LOCKSCREEN,
                to = KeyguardState.OFF,
                    transitionState = TransitionState.FINISHED,
                )
                testScope
            )
            runCurrent()
            keyguardTransitionRepository.sendTransitionStep(
@@ -751,15 +759,11 @@ class DeviceEntryFaceAuthRepositoryTest : SysuiTestCase() {
            )
            runCurrent()

            Log.i("TEST", "sending display off")
            displayRepository.emit(setOf(display(0, 0, Display.DEFAULT_DISPLAY, Display.STATE_OFF)))
            displayRepository.emitDisplayChangeEvent(Display.DEFAULT_DISPLAY)

            Log.i("TEST", "sending step")

            runCurrent()

            Log.i("TEST", "About to assert if face auth can run.")
            assertThat(canFaceAuthRun()).isTrue()
        }

@@ -768,12 +772,10 @@ class DeviceEntryFaceAuthRepositoryTest : SysuiTestCase() {
        testScope.runTest {
            testGatingCheckForFaceAuth {
                powerInteractor.onFinishedWakingUp()
                keyguardTransitionRepository.sendTransitionStep(
                    TransitionStep(
                keyguardTransitionRepository.sendTransitionSteps(
                    from = KeyguardState.OFF,
                    to = KeyguardState.LOCKSCREEN,
                        transitionState = TransitionState.FINISHED,
                    )
                    testScope
                )
                runCurrent()

@@ -923,7 +925,19 @@ class DeviceEntryFaceAuthRepositoryTest : SysuiTestCase() {

    @Test
    fun detectDoesNotRunWhenDeviceSleepingStartingToSleep() =
        testScope.runTest { testGatingCheckForDetect { powerInteractor.setAsleepForTest() } }
        testScope.runTest {
            testGatingCheckForDetect {
                powerInteractor.setAsleepForTest()
                keyguardTransitionRepository.sendTransitionStep(
                    TransitionStep(
                        transitionState = TransitionState.STARTED,
                        from = KeyguardState.LOCKSCREEN,
                        to = KeyguardState.AOD,
                    )
                )
                runCurrent()
            }
        }

    @Test
    fun detectDoesNotRunWhenSecureCameraIsActive() =
@@ -1016,14 +1030,11 @@ class DeviceEntryFaceAuthRepositoryTest : SysuiTestCase() {
    @Test
    fun schedulesFaceManagerWatchdogWhenKeyguardIsGoneFromDozing() =
        testScope.runTest {
            keyguardTransitionRepository.sendTransitionStep(
                TransitionStep(
            keyguardTransitionRepository.sendTransitionSteps(
                from = KeyguardState.DOZING,
                to = KeyguardState.GONE,
                    transitionState = TransitionState.FINISHED
                )
                testScope
            )

            runCurrent()
            verify(faceManager).scheduleWatchdog()
        }
@@ -1031,14 +1042,11 @@ class DeviceEntryFaceAuthRepositoryTest : SysuiTestCase() {
    @Test
    fun schedulesFaceManagerWatchdogWhenKeyguardIsGoneFromAod() =
        testScope.runTest {
            keyguardTransitionRepository.sendTransitionStep(
                TransitionStep(
            keyguardTransitionRepository.sendTransitionSteps(
                from = KeyguardState.AOD,
                to = KeyguardState.GONE,
                    transitionState = TransitionState.FINISHED
                )
                testScope
            )

            runCurrent()
            verify(faceManager).scheduleWatchdog()
        }
@@ -1046,14 +1054,11 @@ class DeviceEntryFaceAuthRepositoryTest : SysuiTestCase() {
    @Test
    fun schedulesFaceManagerWatchdogWhenKeyguardIsGoneFromLockscreen() =
        testScope.runTest {
            keyguardTransitionRepository.sendTransitionStep(
                TransitionStep(
            keyguardTransitionRepository.sendTransitionSteps(
                from = KeyguardState.LOCKSCREEN,
                to = KeyguardState.GONE,
                    transitionState = TransitionState.FINISHED
                testScope
            )
            )

            runCurrent()
            verify(faceManager).scheduleWatchdog()
        }
@@ -1061,14 +1066,11 @@ class DeviceEntryFaceAuthRepositoryTest : SysuiTestCase() {
    @Test
    fun schedulesFaceManagerWatchdogWhenKeyguardIsGoneFromBouncer() =
        testScope.runTest {
            keyguardTransitionRepository.sendTransitionStep(
                TransitionStep(
            keyguardTransitionRepository.sendTransitionSteps(
                from = KeyguardState.PRIMARY_BOUNCER,
                to = KeyguardState.GONE,
                    transitionState = TransitionState.FINISHED
                )
                testScope
            )

            runCurrent()
            verify(faceManager).scheduleWatchdog()
        }
@@ -1251,6 +1253,11 @@ class DeviceEntryFaceAuthRepositoryTest : SysuiTestCase() {
        keyguardRepository.setKeyguardShowing(true)
        displayRepository.emit(setOf(display(0, 0, Display.DEFAULT_DISPLAY, Display.STATE_ON)))
        displayRepository.emitDisplayChangeEvent(Display.DEFAULT_DISPLAY)
        keyguardTransitionRepository.sendTransitionSteps(
            from = KeyguardState.AOD,
            to = KeyguardState.LOCKSCREEN,
            testScope
        )
        runCurrent()
    }

+8 −9
Original line number Diff line number Diff line
@@ -26,8 +26,6 @@ import com.android.systemui.keyguard.data.repository.FakeKeyguardTransitionRepos
import com.android.systemui.keyguard.shared.model.DismissAction
import com.android.systemui.keyguard.shared.model.KeyguardDone
import com.android.systemui.keyguard.shared.model.KeyguardState
import com.android.systemui.keyguard.shared.model.TransitionState
import com.android.systemui.keyguard.shared.model.TransitionStep
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.StandardTestDispatcher
@@ -179,8 +177,10 @@ class KeyguardDismissActionInteractorTest : SysuiTestCase() {
            assertThat(executeDismissAction).isNull()

            // WHEN the keyguard is GONE
            transitionRepository.sendTransitionStep(
                TransitionStep(to = KeyguardState.GONE, transitionState = TransitionState.FINISHED)
            transitionRepository.sendTransitionSteps(
                from = KeyguardState.LOCKSCREEN,
                to = KeyguardState.GONE,
                testScope
            )
            assertThat(executeDismissAction).isNotNull()
        }
@@ -198,11 +198,10 @@ class KeyguardDismissActionInteractorTest : SysuiTestCase() {
                    willAnimateOnLockscreen = true,
                )
            )
            transitionRepository.sendTransitionStep(
                TransitionStep(
            transitionRepository.sendTransitionSteps(
                from = KeyguardState.LOCKSCREEN,
                to = KeyguardState.AOD,
                    transitionState = TransitionState.FINISHED,
                )
                testScope
            )
            assertThat(resetDismissAction).isEqualTo(Unit)
        }
Loading