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

This commit is contained in:
Beverly Tai
2022-09-20 12:34:29 +00:00
committed by Android (Google) Code Review
2 changed files with 29 additions and 16 deletions

View File

@@ -23,7 +23,6 @@ import android.content.Context
import android.graphics.Point import android.graphics.Point
import android.hardware.biometrics.BiometricFingerprintConstants import android.hardware.biometrics.BiometricFingerprintConstants
import android.hardware.biometrics.BiometricSourceType import android.hardware.biometrics.BiometricSourceType
import android.util.Log
import androidx.annotation.VisibleForTesting import androidx.annotation.VisibleForTesting
import com.android.keyguard.KeyguardUpdateMonitor import com.android.keyguard.KeyguardUpdateMonitor
import com.android.keyguard.KeyguardUpdateMonitorCallback import com.android.keyguard.KeyguardUpdateMonitorCallback
@@ -95,7 +94,6 @@ class AuthRippleController @Inject constructor(
public override fun onViewAttached() { public override fun onViewAttached() {
authController.addCallback(authControllerCallback) authController.addCallback(authControllerCallback)
updateRippleColor() updateRippleColor()
updateSensorLocation()
updateUdfpsDependentParams() updateUdfpsDependentParams()
udfpsController?.addCallback(udfpsControllerCallback) udfpsController?.addCallback(udfpsControllerCallback)
configurationController.addCallback(configurationChangedListener) configurationController.addCallback(configurationChangedListener)
@@ -237,7 +235,11 @@ class AuthRippleController @Inject constructor(
} }
private fun showDwellRipple() { private fun showDwellRipple() {
mView.startDwellRipple(statusBarStateController.isDozing) updateSensorLocation()
fingerprintSensorLocation?.let {
mView.setFingerprintSensorLocation(it, udfpsRadius)
mView.startDwellRipple(statusBarStateController.isDozing)
}
} }
private val keyguardUpdateMonitorCallback = private val keyguardUpdateMonitorCallback =
@@ -291,13 +293,6 @@ class AuthRippleController @Inject constructor(
private val udfpsControllerCallback = private val udfpsControllerCallback =
object : UdfpsController.Callback { object : UdfpsController.Callback {
override fun onFingerDown() { override fun onFingerDown() {
if (fingerprintSensorLocation == null) {
Log.e("AuthRipple", "fingerprintSensorLocation=null onFingerDown. " +
"Skip showing dwell ripple")
return
}
mView.setFingerprintSensorLocation(fingerprintSensorLocation!!, udfpsRadius)
showDwellRipple() showDwellRipple()
} }
@@ -310,12 +305,10 @@ class AuthRippleController @Inject constructor(
object : AuthController.Callback { object : AuthController.Callback {
override fun onAllAuthenticatorsRegistered() { override fun onAllAuthenticatorsRegistered() {
updateUdfpsDependentParams() updateUdfpsDependentParams()
updateSensorLocation()
} }
override fun onUdfpsLocationChanged() { override fun onUdfpsLocationChanged() {
updateUdfpsDependentParams() updateUdfpsDependentParams()
updateSensorLocation()
} }
} }
@@ -345,13 +338,11 @@ class AuthRippleController @Inject constructor(
"\n\tudfpsRadius=$udfpsRadius") "\n\tudfpsRadius=$udfpsRadius")
} }
"fingerprint" -> { "fingerprint" -> {
updateSensorLocation()
pw.println("fingerprint ripple sensorLocation=$fingerprintSensorLocation") pw.println("fingerprint ripple sensorLocation=$fingerprintSensorLocation")
showUnlockRipple(BiometricSourceType.FINGERPRINT) showUnlockRipple(BiometricSourceType.FINGERPRINT)
} }
"face" -> { "face" -> {
// note: only shows when about to proceed to the home screen // note: only shows when about to proceed to the home screen
updateSensorLocation()
pw.println("face ripple sensorLocation=$faceSensorLocation") pw.println("face ripple sensorLocation=$faceSensorLocation")
showUnlockRipple(BiometricSourceType.FACE) showUnlockRipple(BiometricSourceType.FACE)
} }

View File

@@ -18,6 +18,7 @@ package com.android.systemui.biometrics
import android.graphics.Point import android.graphics.Point
import android.hardware.biometrics.BiometricSourceType import android.hardware.biometrics.BiometricSourceType
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal
import android.testing.AndroidTestingRunner import android.testing.AndroidTestingRunner
import android.testing.TestableLooper.RunWithLooper import android.testing.TestableLooper.RunWithLooper
import androidx.test.filters.SmallTest import androidx.test.filters.SmallTest
@@ -76,6 +77,7 @@ class AuthRippleControllerTest : SysuiTestCase() {
@Mock private lateinit var udfpsController: UdfpsController @Mock private lateinit var udfpsController: UdfpsController
@Mock private lateinit var statusBarStateController: StatusBarStateController @Mock private lateinit var statusBarStateController: StatusBarStateController
@Mock private lateinit var lightRevealScrim: LightRevealScrim @Mock private lateinit var lightRevealScrim: LightRevealScrim
@Mock private lateinit var fpSensorProp: FingerprintSensorPropertiesInternal
@Before @Before
fun setUp() { fun setUp() {
@@ -86,6 +88,7 @@ class AuthRippleControllerTest : SysuiTestCase() {
.startMocking() .startMocking()
`when`(RotationUtils.getRotation(context)).thenReturn(RotationUtils.ROTATION_NONE) `when`(RotationUtils.getRotation(context)).thenReturn(RotationUtils.ROTATION_NONE)
`when`(authController.udfpsProps).thenReturn(listOf(fpSensorProp))
`when`(udfpsControllerProvider.get()).thenReturn(udfpsController) `when`(udfpsControllerProvider.get()).thenReturn(udfpsController)
controller = AuthRippleController( controller = AuthRippleController(
@@ -132,7 +135,7 @@ class AuthRippleControllerTest : SysuiTestCase() {
false /* isStrongBiometric */) false /* isStrongBiometric */)
// THEN update sensor location and show ripple // THEN update sensor location and show ripple
verify(rippleView).setFingerprintSensorLocation(fpsLocation, -1f) verify(rippleView).setFingerprintSensorLocation(fpsLocation, 0f)
verify(rippleView).startUnlockedRipple(any()) verify(rippleView).startUnlockedRipple(any())
} }
@@ -155,7 +158,7 @@ class AuthRippleControllerTest : SysuiTestCase() {
false /* isStrongBiometric */) false /* isStrongBiometric */)
// THEN update sensor location and show ripple // THEN update sensor location and show ripple
verify(rippleView).setFingerprintSensorLocation(fpsLocation, -1f) verify(rippleView).setFingerprintSensorLocation(fpsLocation, 0f)
verify(rippleView).startUnlockedRipple(any()) verify(rippleView).startUnlockedRipple(any())
} }
@@ -342,4 +345,23 @@ class AuthRippleControllerTest : SysuiTestCase() {
captor.value.onUiModeChanged() captor.value.onUiModeChanged()
verify(rippleView).setLockScreenColor(ArgumentMatchers.anyInt()) 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)
}
} }