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

Commit 668090c0 authored by Beverly Tai's avatar Beverly Tai Committed by Android (Google) Code Review
Browse files

Merge "Update FP sensor location before showing dwellAnim" into tm-qpr-dev

parents d5d35fb2 7d7d6403
Loading
Loading
Loading
Loading
+5 −14
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@ import android.content.Context
import android.graphics.Point
import android.hardware.biometrics.BiometricFingerprintConstants
import android.hardware.biometrics.BiometricSourceType
import android.util.Log
import androidx.annotation.VisibleForTesting
import com.android.keyguard.KeyguardUpdateMonitor
import com.android.keyguard.KeyguardUpdateMonitorCallback
@@ -95,7 +94,6 @@ class AuthRippleController @Inject constructor(
    public override fun onViewAttached() {
        authController.addCallback(authControllerCallback)
        updateRippleColor()
        updateSensorLocation()
        updateUdfpsDependentParams()
        udfpsController?.addCallback(udfpsControllerCallback)
        configurationController.addCallback(configurationChangedListener)
@@ -237,8 +235,12 @@ class AuthRippleController @Inject constructor(
    }

    private fun showDwellRipple() {
        updateSensorLocation()
        fingerprintSensorLocation?.let {
            mView.setFingerprintSensorLocation(it, udfpsRadius)
            mView.startDwellRipple(statusBarStateController.isDozing)
        }
    }

    private val keyguardUpdateMonitorCallback =
        object : KeyguardUpdateMonitorCallback() {
@@ -291,13 +293,6 @@ class AuthRippleController @Inject constructor(
    private val udfpsControllerCallback =
        object : UdfpsController.Callback {
            override fun onFingerDown() {
                if (fingerprintSensorLocation == null) {
                    Log.e("AuthRipple", "fingerprintSensorLocation=null onFingerDown. " +
                            "Skip showing dwell ripple")
                    return
                }

                mView.setFingerprintSensorLocation(fingerprintSensorLocation!!, udfpsRadius)
                showDwellRipple()
            }

@@ -310,12 +305,10 @@ class AuthRippleController @Inject constructor(
        object : AuthController.Callback {
            override fun onAllAuthenticatorsRegistered() {
                updateUdfpsDependentParams()
                updateSensorLocation()
            }

            override fun onUdfpsLocationChanged() {
                updateUdfpsDependentParams()
                updateSensorLocation()
            }
        }

@@ -345,13 +338,11 @@ class AuthRippleController @Inject constructor(
                                "\n\tudfpsRadius=$udfpsRadius")
                    }
                    "fingerprint" -> {
                        updateSensorLocation()
                        pw.println("fingerprint ripple sensorLocation=$fingerprintSensorLocation")
                        showUnlockRipple(BiometricSourceType.FINGERPRINT)
                    }
                    "face" -> {
                        // note: only shows when about to proceed to the home screen
                        updateSensorLocation()
                        pw.println("face ripple sensorLocation=$faceSensorLocation")
                        showUnlockRipple(BiometricSourceType.FACE)
                    }
+24 −2
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.systemui.biometrics

import android.graphics.Point
import android.hardware.biometrics.BiometricSourceType
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal
import android.testing.AndroidTestingRunner
import android.testing.TestableLooper.RunWithLooper
import androidx.test.filters.SmallTest
@@ -76,6 +77,7 @@ class AuthRippleControllerTest : SysuiTestCase() {
    @Mock private lateinit var udfpsController: UdfpsController
    @Mock private lateinit var statusBarStateController: StatusBarStateController
    @Mock private lateinit var lightRevealScrim: LightRevealScrim
    @Mock private lateinit var fpSensorProp: FingerprintSensorPropertiesInternal

    @Before
    fun setUp() {
@@ -86,6 +88,7 @@ class AuthRippleControllerTest : SysuiTestCase() {
                .startMocking()

        `when`(RotationUtils.getRotation(context)).thenReturn(RotationUtils.ROTATION_NONE)
        `when`(authController.udfpsProps).thenReturn(listOf(fpSensorProp))
        `when`(udfpsControllerProvider.get()).thenReturn(udfpsController)

        controller = AuthRippleController(
@@ -132,7 +135,7 @@ class AuthRippleControllerTest : SysuiTestCase() {
            false /* isStrongBiometric */)

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

@@ -155,7 +158,7 @@ class AuthRippleControllerTest : SysuiTestCase() {
                false /* isStrongBiometric */)

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

@@ -342,4 +345,23 @@ class AuthRippleControllerTest : SysuiTestCase() {
        captor.value.onUiModeChanged()
        verify(rippleView).setLockScreenColor(ArgumentMatchers.anyInt())
    }

    @Test
    fun testUdfps_onFingerDown_showDwellRipple() {
        // GIVEN view is already attached
        controller.onViewAttached()
        val captor = ArgumentCaptor.forClass(UdfpsController.Callback::class.java)
        verify(udfpsController).addCallback(captor.capture())

        // GIVEN fp is updated to Point(5, 5)
        val fpsLocation = Point(5, 5)
        `when`(authController.fingerprintSensorLocation).thenReturn(fpsLocation)

        // WHEN finger is down
        captor.value.onFingerDown()

        // THEN update sensor location and show ripple
        verify(rippleView).setFingerprintSensorLocation(fpsLocation, 0f)
        verify(rippleView).startDwellRipple(false)
    }
}