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

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

Merge "Add reason for showing the bouncer" into main

parents cee81a9d 3d19e43b
Loading
Loading
Loading
Loading
+8 −7
Original line number Diff line number Diff line
@@ -77,6 +77,7 @@ class PrimaryBouncerInteractorTest : SysuiTestCase() {
    private lateinit var resources: TestableResources
    private lateinit var trustRepository: FakeTrustRepository
    private lateinit var testScope: TestScope
    private val TEST_REASON = "reason"

    @Before
    fun setUp() {
@@ -118,7 +119,7 @@ class PrimaryBouncerInteractorTest : SysuiTestCase() {
            mainHandler.setMode(FakeHandler.Mode.QUEUEING)

            // WHEN bouncer show is requested
            underTest.show(true)
            underTest.show(true, TEST_REASON)

            // WHEN all queued messages are dispatched
            mainHandler.dispatchQueuedMessages()
@@ -134,7 +135,7 @@ class PrimaryBouncerInteractorTest : SysuiTestCase() {

    @Test
    fun testShow_isScrimmed() {
        underTest.show(true)
        underTest.show(true, TEST_REASON)
        verify(repository).setKeyguardAuthenticatedBiometrics(null)
        verify(repository).setPrimaryStartingToHide(false)
        verify(repository).setPrimaryScrimmed(true)
@@ -162,7 +163,7 @@ class PrimaryBouncerInteractorTest : SysuiTestCase() {
    @Test
    fun testShowReturnsFalseWhenDelegateIsNotSet() {
        whenever(bouncerView.delegate).thenReturn(null)
        assertThat(underTest.show(true)).isEqualTo(false)
        assertThat(underTest.show(true, TEST_REASON)).isEqualTo(false)
    }

    @Test
@@ -171,7 +172,7 @@ class PrimaryBouncerInteractorTest : SysuiTestCase() {
        whenever(keyguardSecurityModel.getSecurityMode(anyInt()))
            .thenReturn(KeyguardSecurityModel.SecurityMode.SimPuk)

        underTest.show(true)
        underTest.show(true, TEST_REASON)
        verify(repository).setPrimaryShow(false)
        verify(repository).setPrimaryShow(true)
    }
@@ -352,7 +353,7 @@ class PrimaryBouncerInteractorTest : SysuiTestCase() {
        whenever(faceAuthInteractor.canFaceAuthRun()).thenReturn(true)

        // WHEN bouncer show is requested
        underTest.show(true)
        underTest.show(true, TEST_REASON)

        // THEN primary show & primary showing soon aren't updated immediately
        verify(repository, never()).setPrimaryShow(true)
@@ -375,7 +376,7 @@ class PrimaryBouncerInteractorTest : SysuiTestCase() {
        whenever(faceAuthInteractor.canFaceAuthRun()).thenReturn(false)

        // WHEN bouncer show is requested
        underTest.show(true)
        underTest.show(true, TEST_REASON)

        // THEN primary show & primary showing soon are updated immediately
        verify(repository).setPrimaryShow(true)
@@ -394,7 +395,7 @@ class PrimaryBouncerInteractorTest : SysuiTestCase() {
            runCurrent()

            // WHEN bouncer show is requested
            underTest.show(true)
            underTest.show(true, TEST_REASON)

            // THEN primary show & primary showing soon were scheduled to update
            verify(repository, never()).setPrimaryShow(true)
+20 −4
Original line number Diff line number Diff line
@@ -267,12 +267,20 @@ class KeyguardKeyEventInteractorTest : SysuiTestCase() {
        // action down: does NOT collapse the shade
        val actionDownMenuKeyEvent = KeyEvent(KeyEvent.ACTION_DOWN, keycode)
        assertThat(underTest.dispatchKeyEvent(actionDownMenuKeyEvent)).isFalse()
        verify(statusBarKeyguardViewManager, never()).showPrimaryBouncer(any())
        verify(statusBarKeyguardViewManager, never())
            .showPrimaryBouncer(
                any(),
                eq("KeyguardKeyEventInteractor#collapseShadeLockedOrShowPrimaryBouncer"),
            )

        // action up: collapses the shade
        val actionUpMenuKeyEvent = KeyEvent(KeyEvent.ACTION_UP, keycode)
        assertThat(underTest.dispatchKeyEvent(actionUpMenuKeyEvent)).isTrue()
        verify(statusBarKeyguardViewManager).showPrimaryBouncer(eq(true))
        verify(statusBarKeyguardViewManager)
            .showPrimaryBouncer(
                eq(true),
                eq("KeyguardKeyEventInteractor#collapseShadeLockedOrShowPrimaryBouncer"),
            )
    }

    private fun verifyActionsDoNothing(keycode: Int) {
@@ -280,12 +288,20 @@ class KeyguardKeyEventInteractorTest : SysuiTestCase() {
        val actionDownMenuKeyEvent = KeyEvent(KeyEvent.ACTION_DOWN, keycode)
        assertThat(underTest.dispatchKeyEvent(actionDownMenuKeyEvent)).isFalse()
        verify(shadeController, never()).animateCollapseShadeForced()
        verify(statusBarKeyguardViewManager, never()).showPrimaryBouncer(any())
        verify(statusBarKeyguardViewManager, never())
            .showPrimaryBouncer(
                any(),
                eq("KeyguardKeyEventInteractor#collapseShadeLockedOrShowPrimaryBouncer"),
            )

        // action up: doesNothing
        val actionUpMenuKeyEvent = KeyEvent(KeyEvent.ACTION_UP, keycode)
        assertThat(underTest.dispatchKeyEvent(actionUpMenuKeyEvent)).isFalse()
        verify(shadeController, never()).animateCollapseShadeForced()
        verify(statusBarKeyguardViewManager, never()).showPrimaryBouncer(any())
        verify(statusBarKeyguardViewManager, never())
            .showPrimaryBouncer(
                any(),
                eq("KeyguardKeyEventInteractor#collapseShadeLockedOrShowPrimaryBouncer"),
            )
    }
}
+7 −5
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import com.android.systemui.plugins.ActivityStarter
import com.android.systemui.statusbar.phone.statusBarKeyguardViewManager
import com.android.systemui.testKosmos
import com.android.systemui.util.mockito.any
import com.android.systemui.util.mockito.eq
import com.google.common.collect.Range
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.test.runTest
@@ -56,7 +57,8 @@ class AlternateBouncerViewModelTest : SysuiTestCase() {
    fun onTapped() =
        testScope.runTest {
            underTest.onTapped()
            verify(statusBarKeyguardViewManager).showPrimaryBouncer(any())
            verify(statusBarKeyguardViewManager)
                .showPrimaryBouncer(any(), eq("AlternateBouncerViewModel#onTapped"))
        }

    @Test
@@ -154,7 +156,7 @@ class AlternateBouncerViewModelTest : SysuiTestCase() {

    private fun stepToAlternateBouncer(
        value: Float,
        state: TransitionState = TransitionState.RUNNING
        state: TransitionState = TransitionState.RUNNING,
    ): TransitionStep {
        return step(
            from = KeyguardState.LOCKSCREEN,
@@ -166,7 +168,7 @@ class AlternateBouncerViewModelTest : SysuiTestCase() {

    private fun stepFromAlternateBouncer(
        value: Float,
        state: TransitionState = TransitionState.RUNNING
        state: TransitionState = TransitionState.RUNNING,
    ): TransitionStep {
        return step(
            from = KeyguardState.ALTERNATE_BOUNCER,
@@ -180,14 +182,14 @@ class AlternateBouncerViewModelTest : SysuiTestCase() {
        from: KeyguardState,
        to: KeyguardState,
        value: Float,
        transitionState: TransitionState
        transitionState: TransitionState,
    ): TransitionStep {
        return TransitionStep(
            from = from,
            to = to,
            value = value,
            transitionState = transitionState,
            ownerName = "AlternateBouncerViewModelTest"
            ownerName = "AlternateBouncerViewModelTest",
        )
    }
}
+24 −12
Original line number Diff line number Diff line
@@ -186,7 +186,8 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase {
                .thenReturn(false);
        mBiometricUnlockController.onBiometricAuthenticated(UserHandle.USER_CURRENT,
                BiometricSourceType.FINGERPRINT, true /* isStrongBiometric */);
        verify(mStatusBarKeyguardViewManager).showPrimaryBouncer(anyBoolean());
        verify(mStatusBarKeyguardViewManager).showPrimaryBouncer(anyBoolean(),
                eq("BiometricUnlockController#MODE_SHOW_BOUNCER"));
        verify(mStatusBarKeyguardViewManager, never()).notifyKeyguardAuthenticated(anyBoolean());
        assertThat(mBiometricUnlockController.getMode())
                .isEqualTo(BiometricUnlockController.MODE_SHOW_BOUNCER);
@@ -198,7 +199,8 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase {
                .thenReturn(false);
        mBiometricUnlockController.onBiometricAuthenticated(UserHandle.USER_CURRENT,
                BiometricSourceType.FINGERPRINT, false /* isStrongBiometric */);
        verify(mStatusBarKeyguardViewManager).showPrimaryBouncer(anyBoolean());
        verify(mStatusBarKeyguardViewManager).showPrimaryBouncer(anyBoolean(),
                eq("BiometricUnlockController#MODE_SHOW_BOUNCER"));
        assertThat(mBiometricUnlockController.getMode())
                .isEqualTo(BiometricUnlockController.MODE_SHOW_BOUNCER);
        assertThat(mBiometricUnlockController.getBiometricType())
@@ -248,7 +250,8 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase {
        mBiometricUnlockController.onBiometricAuthenticated(UserHandle.USER_CURRENT,
                BiometricSourceType.FINGERPRINT, true /* isStrongBiometric */);

        verify(mStatusBarKeyguardViewManager, never()).showPrimaryBouncer(anyBoolean());
        verify(mStatusBarKeyguardViewManager, never()).showPrimaryBouncer(anyBoolean(),
                eq("BiometricUnlockController#MODE_SHOW_BOUNCER"));
        verify(mStatusBarKeyguardViewManager).notifyKeyguardAuthenticated(eq(false));
        assertThat(mBiometricUnlockController.getMode())
                .isEqualTo(BiometricUnlockController.MODE_UNLOCK_COLLAPSING);
@@ -327,7 +330,8 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase {
        mBiometricUnlockController.onBiometricAuthenticated(UserHandle.USER_CURRENT,
                BiometricSourceType.FACE, true /* isStrongBiometric */);

        verify(mStatusBarKeyguardViewManager).showPrimaryBouncer(anyBoolean());
        verify(mStatusBarKeyguardViewManager).showPrimaryBouncer(anyBoolean(),
                eq("BiometricUnlockController#MODE_SHOW_BOUNCER"));
        assertThat(mBiometricUnlockController.getMode())
                .isEqualTo(BiometricUnlockController.MODE_SHOW_BOUNCER);
    }
@@ -359,7 +363,8 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase {
        mBiometricUnlockController.onBiometricAuthenticated(UserHandle.USER_CURRENT,
                BiometricSourceType.FACE, true /* isStrongBiometric */);

        verify(mStatusBarKeyguardViewManager, never()).showPrimaryBouncer(anyBoolean());
        verify(mStatusBarKeyguardViewManager, never()).showPrimaryBouncer(anyBoolean(),
                eq("BiometricUnlockController#MODE_SHOW_BOUNCER"));
        assertThat(mBiometricUnlockController.getMode())
                .isEqualTo(BiometricUnlockController.MODE_NONE);
    }
@@ -438,17 +443,20 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase {

        // WHEN udfps fails once - then don't show the bouncer yet
        mBiometricUnlockController.onBiometricAuthFailed(BiometricSourceType.FINGERPRINT);
        verify(mStatusBarKeyguardViewManager, never()).showPrimaryBouncer(anyBoolean());
        verify(mStatusBarKeyguardViewManager, never()).showPrimaryBouncer(anyBoolean(),
                eq("BiometricUnlockController#MODE_SHOW_BOUNCER"));

        // WHEN udfps fails the second time - then don't show the bouncer yet
        mBiometricUnlockController.onBiometricAuthFailed(BiometricSourceType.FINGERPRINT);
        verify(mStatusBarKeyguardViewManager, never()).showPrimaryBouncer(anyBoolean());
        verify(mStatusBarKeyguardViewManager, never()).showPrimaryBouncer(anyBoolean(),
                eq("BiometricUnlockController#MODE_SHOW_BOUNCER"));

        // WHEN udpfs fails the third time
        mBiometricUnlockController.onBiometricAuthFailed(BiometricSourceType.FINGERPRINT);

        // THEN show the bouncer
        verify(mStatusBarKeyguardViewManager).showPrimaryBouncer(true);
        verify(mStatusBarKeyguardViewManager).showPrimaryBouncer(true,
                "BiometricUnlockController#MODE_SHOW_BOUNCER");
    }

    @Test
@@ -460,14 +468,16 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase {
        mBiometricUnlockController.onBiometricAuthFailed(BiometricSourceType.FINGERPRINT);
        mBiometricUnlockController.onBiometricAuthFailed(BiometricSourceType.FINGERPRINT);
        mBiometricUnlockController.onBiometricAuthFailed(BiometricSourceType.FINGERPRINT);
        verify(mStatusBarKeyguardViewManager, never()).showPrimaryBouncer(anyBoolean());
        verify(mStatusBarKeyguardViewManager, never()).showPrimaryBouncer(anyBoolean(),
                eq("BiometricUnlockController#MODE_SHOW_BOUNCER"));

        // WHEN lockout is received
        mBiometricUnlockController.onBiometricError(FingerprintManager.FINGERPRINT_ERROR_LOCKOUT,
                "Lockout", BiometricSourceType.FINGERPRINT);

        // THEN show bouncer
        verify(mStatusBarKeyguardViewManager).showPrimaryBouncer(true);
        verify(mStatusBarKeyguardViewManager).showPrimaryBouncer(true,
                "BiometricUnlockController#MODE_SHOW_BOUNCER");
    }

    @Test
@@ -544,7 +554,8 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase {
                BiometricSourceType.FINGERPRINT, true /* isStrongBiometric */);

        // THEN shows primary bouncer
        verify(mStatusBarKeyguardViewManager).showPrimaryBouncer(anyBoolean());
        verify(mStatusBarKeyguardViewManager).showPrimaryBouncer(anyBoolean(),
                eq("BiometricUnlockController#MODE_SHOW_BOUNCER"));
    }

    @Test
@@ -554,7 +565,8 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase {
                BiometricSourceType.FACE, false /* isStrongBiometric */);

        // THEN shows primary bouncer
        verify(mStatusBarKeyguardViewManager).showPrimaryBouncer(anyBoolean());
        verify(mStatusBarKeyguardViewManager).showPrimaryBouncer(anyBoolean(),
                eq("BiometricUnlockController#MODE_SHOW_BOUNCER"));
    }

    private void givenFingerprintModeUnlockCollapsing() {
+2 −1
Original line number Diff line number Diff line
@@ -124,7 +124,8 @@ public class StatusBarRemoteInputCallbackTest extends SysuiTestCase {
        mRemoteInputCallback.onLockedRemoteInput(
                mock(ExpandableNotificationRow.class), mock(View.class));

        verify(mStatusBarKeyguardViewManager).showBouncer(true);
        verify(mStatusBarKeyguardViewManager).showBouncer(true,
                "StatusBarRemoteInputCallback#onLockedRemoteInput");
    }
    @Test
    @DisableFlags(ExpandHeadsUpOnInlineReply.FLAG_NAME)
Loading