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

Commit d704d149 authored by Xiaowen Lei's avatar Xiaowen Lei
Browse files

Update AuthRippleController to also show ripple when dreaming.

Bug: 220328680
Test: manually on device
Test: atest AuthRippleControllerTest
Change-Id: I6a9b4792cc08e0f7ddc98b0d5c1e63d3ea3d05e9
parent c29db93f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -116,7 +116,7 @@ class AuthRippleController @Inject constructor(
    }

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

    @Test
    fun testFingerprintTrigger_Ripple() {
    fun testFingerprintTrigger_KeyguardVisible_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(true)
        `when`(keyguardUpdateMonitor.isDreaming).thenReturn(false)
        `when`(keyguardUpdateMonitor.userNeedsStrongAuth()).thenReturn(false)

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

    @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
        val fpsLocation = PointF(5f, 5f)
        `when`(authController.udfpsSensorLocation).thenReturn(fpsLocation)
@@ -145,6 +169,7 @@ class AuthRippleControllerTest : SysuiTestCase() {

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