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

Commit 5f2d6d50 authored by Beverly's avatar Beverly Committed by Beverly Tai
Browse files

Attempt to show altBouncer before showing primary bouncer

This is in preparation for an implementation of
ActivityStarterInteralImpl#dismissKeyguardThenExecute
calling attemptDeviceEntry() which can show the alternateBouncer,
show the primaryBouncer, or immediately dismiss the device
depending on the state of the device.

Flag: ACONFIG com.android.systemui.scene_container DEVELOPMENT
Test: atest DeviceEntryInteractorTest
Bug: 308819693
Change-Id: I63f7982b552da7543b28772ebf21c9f5159f8cd1
parent 3f721e8e
Loading
Loading
Loading
Loading
+60 −0
Original line number Diff line number Diff line
@@ -25,6 +25,9 @@ import com.android.systemui.authentication.data.repository.FakeAuthenticationRep
import com.android.systemui.authentication.data.repository.fakeAuthenticationRepository
import com.android.systemui.authentication.domain.interactor.authenticationInteractor
import com.android.systemui.authentication.shared.model.AuthenticationMethodModel
import com.android.systemui.biometrics.data.repository.fakeFingerprintPropertyRepository
import com.android.systemui.bouncer.data.repository.keyguardBouncerRepository
import com.android.systemui.bouncer.domain.interactor.alternateBouncerInteractor
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.coroutines.collectValues
import com.android.systemui.deviceentry.data.repository.fakeDeviceEntryRepository
@@ -40,11 +43,16 @@ import com.android.systemui.deviceentry.shared.model.DeviceEntryRestrictionReaso
import com.android.systemui.deviceentry.shared.model.DeviceEntryRestrictionReason.UserLockdown
import com.android.systemui.flags.EnableSceneContainer
import com.android.systemui.flags.fakeSystemPropertiesHelper
import com.android.systemui.keyguard.data.repository.biometricSettingsRepository
import com.android.systemui.keyguard.data.repository.deviceEntryFingerprintAuthRepository
import com.android.systemui.keyguard.data.repository.fakeBiometricSettingsRepository
import com.android.systemui.keyguard.data.repository.fakeDeviceEntryFaceAuthRepository
import com.android.systemui.keyguard.data.repository.fakeDeviceEntryFingerprintAuthRepository
import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository
import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository
import com.android.systemui.keyguard.data.repository.fakeTrustRepository
import com.android.systemui.keyguard.shared.model.AuthenticationFlags
import com.android.systemui.keyguard.shared.model.KeyguardState
import com.android.systemui.keyguard.shared.model.SuccessFingerprintAuthenticationStatus
import com.android.systemui.kosmos.testScope
import com.android.systemui.scene.domain.interactor.sceneInteractor
@@ -370,6 +378,42 @@ class DeviceEntryInteractorTest : SysuiTestCase() {
            assertThat(currentScene).isEqualTo(Scenes.Gone)
        }

    @Test
    fun showOrUnlockDevice_noAlternateBouncer_switchesToBouncerScene() =
        testScope.runTest {
            val currentScene by collectLastValue(sceneInteractor.currentScene)
            switchToScene(Scenes.Lockscreen)
            assertThat(currentScene).isEqualTo(Scenes.Lockscreen)

            kosmos.fakeFingerprintPropertyRepository.supportsRearFps() // altBouncer unsupported
            kosmos.fakeAuthenticationRepository.setAuthenticationMethod(
                AuthenticationMethodModel.Pin
            )
            runCurrent()

            underTest.attemptDeviceEntry()

            assertThat(currentScene).isEqualTo(Scenes.Bouncer)
        }

    @Test
    fun showOrUnlockDevice_showsAlternateBouncer_staysOnLockscreenScene() =
        testScope.runTest {
            val currentScene by collectLastValue(sceneInteractor.currentScene)
            switchToScene(Scenes.Lockscreen)
            assertThat(currentScene).isEqualTo(Scenes.Lockscreen)

            kosmos.fakeAuthenticationRepository.setAuthenticationMethod(
                AuthenticationMethodModel.Pin
            )
            givenCanShowAlternateBouncer()
            runCurrent()

            underTest.attemptDeviceEntry()

            assertThat(currentScene).isEqualTo(Scenes.Lockscreen)
        }

    @Test
    fun isBypassEnabled_disabledInRepository_false() =
        testScope.runTest {
@@ -593,4 +637,20 @@ class DeviceEntryInteractorTest : SysuiTestCase() {
    private fun switchToScene(sceneKey: SceneKey) {
        sceneInteractor.changeScene(sceneKey, "reason")
    }

    private suspend fun givenCanShowAlternateBouncer() {
        val canShowAlternateBouncer by
            testScope.collectLastValue(kosmos.alternateBouncerInteractor.canShowAlternateBouncer)
        kosmos.fakeFingerprintPropertyRepository.supportsUdfps()
        kosmos.fakeKeyguardTransitionRepository.sendTransitionSteps(
            from = KeyguardState.GONE,
            to = KeyguardState.LOCKSCREEN,
            testScheduler = testScope.testScheduler,
        )
        kosmos.deviceEntryFingerprintAuthRepository.setLockedOut(false)
        kosmos.biometricSettingsRepository.setIsFingerprintAuthCurrentlyAllowed(true)
        kosmos.fakeKeyguardRepository.setKeyguardDismissible(false)
        kosmos.keyguardBouncerRepository.setPrimaryShow(false)
        assertThat(canShowAlternateBouncer).isTrue()
    }
}
+10 −4
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.systemui.deviceentry.domain.interactor
import androidx.annotation.VisibleForTesting
import com.android.systemui.authentication.domain.interactor.AuthenticationInteractor
import com.android.systemui.authentication.shared.model.AuthenticationMethodModel
import com.android.systemui.bouncer.domain.interactor.AlternateBouncerInteractor
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.deviceentry.data.repository.DeviceEntryRepository
@@ -63,6 +64,7 @@ constructor(
    private val trustInteractor: TrustInteractor,
    private val deviceUnlockedInteractor: DeviceUnlockedInteractor,
    private val systemPropertiesHelper: SystemPropertiesHelper,
    private val alternateBouncerInteractor: AlternateBouncerInteractor,
) {
    /**
     * Whether the device is unlocked.
@@ -211,10 +213,14 @@ constructor(
        //       4. Transition to bouncer scene
        applicationScope.launch {
            if (isAuthenticationRequired()) {
                if (alternateBouncerInteractor.canShowAlternateBouncer.value) {
                    alternateBouncerInteractor.forceShow()
                } else {
                    sceneInteractor.changeScene(
                        toScene = Scenes.Bouncer,
                        loggingReason = "request to unlock device while authentication required",
                    )
                }
            } else {
                sceneInteractor.changeScene(
                    toScene = Scenes.Gone,
+2 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.deviceentry.domain.interactor

import com.android.systemui.authentication.domain.interactor.authenticationInteractor
import com.android.systemui.bouncer.domain.interactor.alternateBouncerInteractor
import com.android.systemui.deviceentry.data.repository.deviceEntryRepository
import com.android.systemui.flags.fakeSystemPropertiesHelper
import com.android.systemui.keyguard.domain.interactor.trustInteractor
@@ -39,5 +40,6 @@ val Kosmos.deviceEntryInteractor by
            trustInteractor = trustInteractor,
            deviceUnlockedInteractor = deviceUnlockedInteractor,
            systemPropertiesHelper = fakeSystemPropertiesHelper,
            alternateBouncerInteractor = alternateBouncerInteractor,
        )
    }