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

Commit 978fb5c4 authored by Matt Pietal's avatar Matt Pietal Committed by Android (Google) Code Review
Browse files

Merge "Don't allow transition to PRIMARY_BOUNCER if wake and unlock" into main

parents 4fefcc1a e78acf3b
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -39,6 +39,8 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.Flags
import com.android.systemui.SysuiTestCase
import com.android.systemui.bouncer.data.repository.FakeKeyguardBouncerRepository
import com.android.systemui.bouncer.data.repository.fakeKeyguardBouncerRepository
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.keyguard.data.repository.FakeKeyguardTransitionRepository
import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository
@@ -85,11 +87,13 @@ class FromAodTransitionInteractorTest : SysuiTestCase() {

    private lateinit var powerInteractor: PowerInteractor
    private lateinit var transitionRepository: FakeKeyguardTransitionRepository
    private lateinit var bouncerRepository: FakeKeyguardBouncerRepository

    @Before
    fun setup() {
        powerInteractor = kosmos.powerInteractor
        transitionRepository = kosmos.fakeKeyguardTransitionRepositorySpy
        bouncerRepository = kosmos.fakeKeyguardBouncerRepository
        underTest = kosmos.fromAodTransitionInteractor

        underTest.start()
@@ -303,6 +307,29 @@ class FromAodTransitionInteractorTest : SysuiTestCase() {
                .startedTransition(from = KeyguardState.AOD, to = KeyguardState.GONE)
        }

    @Test
    fun testWakeAndUnlock_transitionsToGone_evenIfBouncerShows() =
        testScope.runTest {
            kosmos.fakeKeyguardRepository.setBiometricUnlockState(
                BiometricUnlockMode.WAKE_AND_UNLOCK
            )
            runCurrent()
            bouncerRepository.setPrimaryShow(true)
            runCurrent()
            powerInteractor.setAwakeForTest()
            runCurrent()

            // Waking up from wake and unlock should not start any transitions, we'll wait for the
            // dismiss call.
            assertThat(transitionRepository).noTransitionsStarted()

            underTest.dismissAod()
            advanceTimeBy(100) // account for debouncing

            assertThat(transitionRepository)
                .startedTransition(from = KeyguardState.AOD, to = KeyguardState.GONE)
        }

    @Test
    fun testTransitionToOccluded_onWake() =
        testScope.runTest {
+4 −1
Original line number Diff line number Diff line
@@ -193,7 +193,10 @@ constructor(
        if (SceneContainerFlag.isEnabled) return
        scope.launch("$TAG#listenForAodToPrimaryBouncer") {
            keyguardInteractor.primaryBouncerShowing
                .filterRelevantKeyguardStateAnd { primaryBouncerShowing -> primaryBouncerShowing }
                .filterRelevantKeyguardStateAnd { primaryBouncerShowing ->
                    !isWakeAndUnlock(keyguardInteractor.biometricUnlockState.value.mode) &&
                        primaryBouncerShowing
                }
                .collect { startTransitionTo(KeyguardState.PRIMARY_BOUNCER) }
        }
    }