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

Commit 978a3ec1 authored by Xiaowen Lei's avatar Xiaowen Lei Committed by Android (Google) Code Review
Browse files

Merge "Update AuthRippleController to also show ripple when dreaming." into tm-dev

parents e29c639e d704d149
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -116,7 +116,7 @@ class AuthRippleController @Inject constructor(
    }
    }


    fun showRipple(biometricSourceType: BiometricSourceType?) {
    fun showRipple(biometricSourceType: BiometricSourceType?) {
        if (!keyguardUpdateMonitor.isKeyguardVisible ||
        if (!(keyguardUpdateMonitor.isKeyguardVisible || keyguardUpdateMonitor.isDreaming) ||
            keyguardUpdateMonitor.userNeedsStrongAuth()) {
            keyguardUpdateMonitor.userNeedsStrongAuth()) {
            return
            return
        }
        }
+27 −2
Original line number Original line Diff line number Diff line
@@ -114,12 +114,13 @@ class AuthRippleControllerTest : SysuiTestCase() {
    }
    }


    @Test
    @Test
    fun testFingerprintTrigger_Ripple() {
    fun testFingerprintTrigger_KeyguardVisible_Ripple() {
        // GIVEN fp exists, keyguard is visible, user doesn't need strong auth
        // GIVEN fp exists, keyguard is visible, user doesn't need strong auth
        val fpsLocation = PointF(5f, 5f)
        val fpsLocation = PointF(5f, 5f)
        `when`(authController.fingerprintSensorLocation).thenReturn(fpsLocation)
        `when`(authController.fingerprintSensorLocation).thenReturn(fpsLocation)
        controller.onViewAttached()
        controller.onViewAttached()
        `when`(keyguardUpdateMonitor.isKeyguardVisible).thenReturn(true)
        `when`(keyguardUpdateMonitor.isKeyguardVisible).thenReturn(true)
        `when`(keyguardUpdateMonitor.isDreaming).thenReturn(false)
        `when`(keyguardUpdateMonitor.userNeedsStrongAuth()).thenReturn(false)
        `when`(keyguardUpdateMonitor.userNeedsStrongAuth()).thenReturn(false)


        // WHEN fingerprint authenticated
        // WHEN fingerprint authenticated
@@ -136,7 +137,30 @@ class AuthRippleControllerTest : SysuiTestCase() {
    }
    }


    @Test
    @Test
    fun testFingerprintTrigger_KeyguardNotVisible_NoRipple() {
    fun testFingerprintTrigger_Dreaming_Ripple() {
        // GIVEN fp exists, keyguard is visible, user doesn't need strong auth
        val fpsLocation = PointF(5f, 5f)
        `when`(authController.fingerprintSensorLocation).thenReturn(fpsLocation)
        controller.onViewAttached()
        `when`(keyguardUpdateMonitor.isKeyguardVisible).thenReturn(false)
        `when`(keyguardUpdateMonitor.isDreaming).thenReturn(true)
        `when`(keyguardUpdateMonitor.userNeedsStrongAuth()).thenReturn(false)

        // WHEN fingerprint authenticated
        val captor = ArgumentCaptor.forClass(KeyguardUpdateMonitorCallback::class.java)
        verify(keyguardUpdateMonitor).registerCallback(captor.capture())
        captor.value.onBiometricAuthenticated(
                0 /* userId */,
                BiometricSourceType.FINGERPRINT /* type */,
                false /* isStrongBiometric */)

        // THEN update sensor location and show ripple
        verify(rippleView).setFingerprintSensorLocation(fpsLocation, -1f)
        verify(rippleView).startUnlockedRipple(any())
    }

    @Test
    fun testFingerprintTrigger_KeyguardNotVisible_NotDreaming_NoRipple() {
        // GIVEN fp exists & user doesn't need strong auth
        // GIVEN fp exists & user doesn't need strong auth
        val fpsLocation = PointF(5f, 5f)
        val fpsLocation = PointF(5f, 5f)
        `when`(authController.udfpsSensorLocation).thenReturn(fpsLocation)
        `when`(authController.udfpsSensorLocation).thenReturn(fpsLocation)
@@ -145,6 +169,7 @@ class AuthRippleControllerTest : SysuiTestCase() {


        // WHEN keyguard is NOT visible & fingerprint authenticated
        // WHEN keyguard is NOT visible & fingerprint authenticated
        `when`(keyguardUpdateMonitor.isKeyguardVisible).thenReturn(false)
        `when`(keyguardUpdateMonitor.isKeyguardVisible).thenReturn(false)
        `when`(keyguardUpdateMonitor.isDreaming).thenReturn(false)
        val captor = ArgumentCaptor.forClass(KeyguardUpdateMonitorCallback::class.java)
        val captor = ArgumentCaptor.forClass(KeyguardUpdateMonitorCallback::class.java)
        verify(keyguardUpdateMonitor).registerCallback(captor.capture())
        verify(keyguardUpdateMonitor).registerCallback(captor.capture())
        captor.value.onBiometricAuthenticated(
        captor.value.onBiometricAuthenticated(