Merge "Use biometricUnlockController state change to show the unlock ripple." into tm-qpr-dev
This commit is contained in:
@@ -41,8 +41,8 @@ import com.android.systemui.statusbar.NotificationShadeWindowController
|
|||||||
import com.android.systemui.statusbar.commandline.Command
|
import com.android.systemui.statusbar.commandline.Command
|
||||||
import com.android.systemui.statusbar.commandline.CommandRegistry
|
import com.android.systemui.statusbar.commandline.CommandRegistry
|
||||||
import com.android.systemui.statusbar.phone.BiometricUnlockController
|
import com.android.systemui.statusbar.phone.BiometricUnlockController
|
||||||
|
import com.android.systemui.statusbar.phone.BiometricUnlockController.MODE_DISMISS_BOUNCER
|
||||||
import com.android.systemui.statusbar.phone.CentralSurfaces
|
import com.android.systemui.statusbar.phone.CentralSurfaces
|
||||||
import com.android.systemui.statusbar.phone.KeyguardBypassController
|
|
||||||
import com.android.systemui.statusbar.phone.dagger.CentralSurfacesComponent.CentralSurfacesScope
|
import com.android.systemui.statusbar.phone.dagger.CentralSurfacesComponent.CentralSurfacesScope
|
||||||
import com.android.systemui.statusbar.policy.ConfigurationController
|
import com.android.systemui.statusbar.policy.ConfigurationController
|
||||||
import com.android.systemui.statusbar.policy.KeyguardStateController
|
import com.android.systemui.statusbar.policy.KeyguardStateController
|
||||||
@@ -60,7 +60,9 @@ import javax.inject.Provider
|
|||||||
* The ripple uses the accent color of the current theme.
|
* The ripple uses the accent color of the current theme.
|
||||||
*/
|
*/
|
||||||
@CentralSurfacesScope
|
@CentralSurfacesScope
|
||||||
class AuthRippleController @Inject constructor(
|
class AuthRippleController
|
||||||
|
@Inject
|
||||||
|
constructor(
|
||||||
private val centralSurfaces: CentralSurfaces,
|
private val centralSurfaces: CentralSurfaces,
|
||||||
private val sysuiContext: Context,
|
private val sysuiContext: Context,
|
||||||
private val authController: AuthController,
|
private val authController: AuthController,
|
||||||
@@ -70,18 +72,18 @@ class AuthRippleController @Inject constructor(
|
|||||||
private val wakefulnessLifecycle: WakefulnessLifecycle,
|
private val wakefulnessLifecycle: WakefulnessLifecycle,
|
||||||
private val commandRegistry: CommandRegistry,
|
private val commandRegistry: CommandRegistry,
|
||||||
private val notificationShadeWindowController: NotificationShadeWindowController,
|
private val notificationShadeWindowController: NotificationShadeWindowController,
|
||||||
private val bypassController: KeyguardBypassController,
|
|
||||||
private val biometricUnlockController: BiometricUnlockController,
|
private val biometricUnlockController: BiometricUnlockController,
|
||||||
private val udfpsControllerProvider: Provider<UdfpsController>,
|
private val udfpsControllerProvider: Provider<UdfpsController>,
|
||||||
private val statusBarStateController: StatusBarStateController,
|
private val statusBarStateController: StatusBarStateController,
|
||||||
private val featureFlags: FeatureFlags,
|
private val featureFlags: FeatureFlags,
|
||||||
private val logger: KeyguardLogger,
|
private val logger: KeyguardLogger,
|
||||||
rippleView: AuthRippleView?
|
rippleView: AuthRippleView?
|
||||||
) : ViewController<AuthRippleView>(rippleView), KeyguardStateController.Callback,
|
) :
|
||||||
|
ViewController<AuthRippleView>(rippleView),
|
||||||
|
KeyguardStateController.Callback,
|
||||||
WakefulnessLifecycle.Observer {
|
WakefulnessLifecycle.Observer {
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting internal var startLightRevealScrimOnKeyguardFadingAway = false
|
||||||
internal var startLightRevealScrimOnKeyguardFadingAway = false
|
|
||||||
var lightRevealScrimAnimator: ValueAnimator? = null
|
var lightRevealScrimAnimator: ValueAnimator? = null
|
||||||
var fingerprintSensorLocation: Point? = null
|
var fingerprintSensorLocation: Point? = null
|
||||||
private var faceSensorLocation: Point? = null
|
private var faceSensorLocation: Point? = null
|
||||||
@@ -90,6 +92,16 @@ class AuthRippleController @Inject constructor(
|
|||||||
private var udfpsController: UdfpsController? = null
|
private var udfpsController: UdfpsController? = null
|
||||||
private var udfpsRadius: Float = -1f
|
private var udfpsRadius: Float = -1f
|
||||||
|
|
||||||
|
private val biometricModeListener = object : BiometricUnlockController.BiometricModeListener {
|
||||||
|
override fun onModeChanged(mode: Int) {
|
||||||
|
// isBiometricUnlock does not cover the scenario when biometrics unlocks
|
||||||
|
// the device while the bouncer is showing.
|
||||||
|
if (biometricUnlockController.isBiometricUnlock || mode == MODE_DISMISS_BOUNCER) {
|
||||||
|
showUnlockRipple(biometricUnlockController.biometricType)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onInit() {
|
override fun onInit() {
|
||||||
mView.setAlphaInDuration(sysuiContext.resources.getInteger(
|
mView.setAlphaInDuration(sysuiContext.resources.getInteger(
|
||||||
R.integer.auth_ripple_alpha_in_duration).toLong())
|
R.integer.auth_ripple_alpha_in_duration).toLong())
|
||||||
@@ -106,6 +118,7 @@ class AuthRippleController @Inject constructor(
|
|||||||
keyguardStateController.addCallback(this)
|
keyguardStateController.addCallback(this)
|
||||||
wakefulnessLifecycle.addObserver(this)
|
wakefulnessLifecycle.addObserver(this)
|
||||||
commandRegistry.registerCommand("auth-ripple") { AuthRippleCommand() }
|
commandRegistry.registerCommand("auth-ripple") { AuthRippleCommand() }
|
||||||
|
biometricUnlockController.addBiometricModeListener(biometricModeListener)
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
@@ -117,6 +130,7 @@ class AuthRippleController @Inject constructor(
|
|||||||
keyguardStateController.removeCallback(this)
|
keyguardStateController.removeCallback(this)
|
||||||
wakefulnessLifecycle.removeObserver(this)
|
wakefulnessLifecycle.removeObserver(this)
|
||||||
commandRegistry.unregisterCommand("auth-ripple")
|
commandRegistry.unregisterCommand("auth-ripple")
|
||||||
|
biometricUnlockController.removeBiometricModeListener(biometricModeListener)
|
||||||
|
|
||||||
notificationShadeWindowController.setForcePluginOpen(false, this)
|
notificationShadeWindowController.setForcePluginOpen(false, this)
|
||||||
}
|
}
|
||||||
@@ -147,9 +161,6 @@ class AuthRippleController @Inject constructor(
|
|||||||
showUnlockedRipple()
|
showUnlockedRipple()
|
||||||
}
|
}
|
||||||
} else if (biometricSourceType == BiometricSourceType.FACE) {
|
} else if (biometricSourceType == BiometricSourceType.FACE) {
|
||||||
if (!bypassController.canBypass() && !authController.isUdfpsFingerDown) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
faceSensorLocation?.let {
|
faceSensorLocation?.let {
|
||||||
mView.setSensorLocation(it)
|
mView.setSensorLocation(it)
|
||||||
circleReveal = CircleReveal(
|
circleReveal = CircleReveal(
|
||||||
@@ -271,7 +282,6 @@ class AuthRippleController @Inject constructor(
|
|||||||
if (biometricSourceType == BiometricSourceType.FINGERPRINT) {
|
if (biometricSourceType == BiometricSourceType.FINGERPRINT) {
|
||||||
mView.fadeDwellRipple()
|
mView.fadeDwellRipple()
|
||||||
}
|
}
|
||||||
showUnlockRipple(biometricSourceType)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBiometricAuthFailed(biometricSourceType: BiometricSourceType) {
|
override fun onBiometricAuthFailed(biometricSourceType: BiometricSourceType) {
|
||||||
|
|||||||
@@ -17,14 +17,14 @@
|
|||||||
package com.android.systemui.biometrics
|
package com.android.systemui.biometrics
|
||||||
|
|
||||||
import android.graphics.Point
|
import android.graphics.Point
|
||||||
import android.hardware.biometrics.BiometricSourceType
|
import android.hardware.biometrics.BiometricSourceType.FACE
|
||||||
|
import android.hardware.biometrics.BiometricSourceType.FINGERPRINT
|
||||||
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal
|
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
|
||||||
import com.android.dx.mockito.inline.extended.ExtendedMockito.mockitoSession
|
import com.android.dx.mockito.inline.extended.ExtendedMockito.mockitoSession
|
||||||
import com.android.keyguard.KeyguardUpdateMonitor
|
import com.android.keyguard.KeyguardUpdateMonitor
|
||||||
import com.android.keyguard.KeyguardUpdateMonitorCallback
|
|
||||||
import com.android.keyguard.logging.KeyguardLogger
|
import com.android.keyguard.logging.KeyguardLogger
|
||||||
import com.android.systemui.SysuiTestCase
|
import com.android.systemui.SysuiTestCase
|
||||||
import com.android.systemui.dump.logcatLogBuffer
|
import com.android.systemui.dump.logcatLogBuffer
|
||||||
@@ -36,11 +36,11 @@ import com.android.systemui.statusbar.NotificationShadeWindowController
|
|||||||
import com.android.systemui.statusbar.commandline.CommandRegistry
|
import com.android.systemui.statusbar.commandline.CommandRegistry
|
||||||
import com.android.systemui.statusbar.phone.BiometricUnlockController
|
import com.android.systemui.statusbar.phone.BiometricUnlockController
|
||||||
import com.android.systemui.statusbar.phone.CentralSurfaces
|
import com.android.systemui.statusbar.phone.CentralSurfaces
|
||||||
import com.android.systemui.statusbar.phone.KeyguardBypassController
|
|
||||||
import com.android.systemui.statusbar.policy.ConfigurationController
|
import com.android.systemui.statusbar.policy.ConfigurationController
|
||||||
import com.android.systemui.statusbar.policy.KeyguardStateController
|
import com.android.systemui.statusbar.policy.KeyguardStateController
|
||||||
import com.android.systemui.util.leak.RotationUtils
|
import com.android.systemui.util.leak.RotationUtils
|
||||||
import com.android.systemui.util.mockito.any
|
import com.android.systemui.util.mockito.any
|
||||||
|
import javax.inject.Provider
|
||||||
import org.junit.After
|
import org.junit.After
|
||||||
import org.junit.Assert.assertFalse
|
import org.junit.Assert.assertFalse
|
||||||
import org.junit.Assert.assertTrue
|
import org.junit.Assert.assertTrue
|
||||||
@@ -50,15 +50,15 @@ import org.junit.runner.RunWith
|
|||||||
import org.mockito.ArgumentCaptor
|
import org.mockito.ArgumentCaptor
|
||||||
import org.mockito.ArgumentMatchers
|
import org.mockito.ArgumentMatchers
|
||||||
import org.mockito.ArgumentMatchers.eq
|
import org.mockito.ArgumentMatchers.eq
|
||||||
|
import org.mockito.Captor
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
import org.mockito.Mockito.`when`
|
|
||||||
import org.mockito.Mockito.never
|
import org.mockito.Mockito.never
|
||||||
import org.mockito.Mockito.reset
|
import org.mockito.Mockito.reset
|
||||||
import org.mockito.Mockito.verify
|
import org.mockito.Mockito.verify
|
||||||
|
import org.mockito.Mockito.`when`
|
||||||
import org.mockito.MockitoAnnotations
|
import org.mockito.MockitoAnnotations
|
||||||
import org.mockito.MockitoSession
|
import org.mockito.MockitoSession
|
||||||
import org.mockito.quality.Strictness
|
import org.mockito.quality.Strictness
|
||||||
import javax.inject.Provider
|
|
||||||
|
|
||||||
@SmallTest
|
@SmallTest
|
||||||
@RunWith(AndroidTestingRunner::class)
|
@RunWith(AndroidTestingRunner::class)
|
||||||
@@ -75,7 +75,6 @@ class AuthRippleControllerTest : SysuiTestCase() {
|
|||||||
@Mock private lateinit var keyguardStateController: KeyguardStateController
|
@Mock private lateinit var keyguardStateController: KeyguardStateController
|
||||||
@Mock private lateinit var wakefulnessLifecycle: WakefulnessLifecycle
|
@Mock private lateinit var wakefulnessLifecycle: WakefulnessLifecycle
|
||||||
@Mock private lateinit var notificationShadeWindowController: NotificationShadeWindowController
|
@Mock private lateinit var notificationShadeWindowController: NotificationShadeWindowController
|
||||||
@Mock private lateinit var bypassController: KeyguardBypassController
|
|
||||||
@Mock private lateinit var biometricUnlockController: BiometricUnlockController
|
@Mock private lateinit var biometricUnlockController: BiometricUnlockController
|
||||||
@Mock private lateinit var udfpsControllerProvider: Provider<UdfpsController>
|
@Mock private lateinit var udfpsControllerProvider: Provider<UdfpsController>
|
||||||
@Mock private lateinit var udfpsController: UdfpsController
|
@Mock private lateinit var udfpsController: UdfpsController
|
||||||
@@ -84,10 +83,15 @@ class AuthRippleControllerTest : SysuiTestCase() {
|
|||||||
@Mock private lateinit var lightRevealScrim: LightRevealScrim
|
@Mock private lateinit var lightRevealScrim: LightRevealScrim
|
||||||
@Mock private lateinit var fpSensorProp: FingerprintSensorPropertiesInternal
|
@Mock private lateinit var fpSensorProp: FingerprintSensorPropertiesInternal
|
||||||
|
|
||||||
|
@Captor
|
||||||
|
private lateinit var biometricModeListener:
|
||||||
|
ArgumentCaptor<BiometricUnlockController.BiometricModeListener>
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setUp() {
|
fun setUp() {
|
||||||
MockitoAnnotations.initMocks(this)
|
MockitoAnnotations.initMocks(this)
|
||||||
staticMockSession = mockitoSession()
|
staticMockSession =
|
||||||
|
mockitoSession()
|
||||||
.mockStatic(RotationUtils::class.java)
|
.mockStatic(RotationUtils::class.java)
|
||||||
.strictness(Strictness.LENIENT)
|
.strictness(Strictness.LENIENT)
|
||||||
.startMocking()
|
.startMocking()
|
||||||
@@ -96,7 +100,8 @@ class AuthRippleControllerTest : SysuiTestCase() {
|
|||||||
`when`(authController.udfpsProps).thenReturn(listOf(fpSensorProp))
|
`when`(authController.udfpsProps).thenReturn(listOf(fpSensorProp))
|
||||||
`when`(udfpsControllerProvider.get()).thenReturn(udfpsController)
|
`when`(udfpsControllerProvider.get()).thenReturn(udfpsController)
|
||||||
|
|
||||||
controller = AuthRippleController(
|
controller =
|
||||||
|
AuthRippleController(
|
||||||
mCentralSurfaces,
|
mCentralSurfaces,
|
||||||
context,
|
context,
|
||||||
authController,
|
authController,
|
||||||
@@ -106,7 +111,6 @@ class AuthRippleControllerTest : SysuiTestCase() {
|
|||||||
wakefulnessLifecycle,
|
wakefulnessLifecycle,
|
||||||
commandRegistry,
|
commandRegistry,
|
||||||
notificationShadeWindowController,
|
notificationShadeWindowController,
|
||||||
bypassController,
|
|
||||||
biometricUnlockController,
|
biometricUnlockController,
|
||||||
udfpsControllerProvider,
|
udfpsControllerProvider,
|
||||||
statusBarStateController,
|
statusBarStateController,
|
||||||
@@ -130,16 +134,14 @@ class AuthRippleControllerTest : SysuiTestCase() {
|
|||||||
`when`(authController.fingerprintSensorLocation).thenReturn(fpsLocation)
|
`when`(authController.fingerprintSensorLocation).thenReturn(fpsLocation)
|
||||||
controller.onViewAttached()
|
controller.onViewAttached()
|
||||||
`when`(keyguardStateController.isShowing).thenReturn(true)
|
`when`(keyguardStateController.isShowing).thenReturn(true)
|
||||||
`when`(keyguardUpdateMonitor.isUnlockingWithBiometricAllowed(
|
`when`(keyguardUpdateMonitor.isUnlockingWithBiometricAllowed(eq(FINGERPRINT)))
|
||||||
eq(BiometricSourceType.FINGERPRINT))).thenReturn(true)
|
.thenReturn(true)
|
||||||
|
`when`(biometricUnlockController.isBiometricUnlock).thenReturn(true)
|
||||||
|
`when`(biometricUnlockController.biometricType).thenReturn(FINGERPRINT)
|
||||||
|
|
||||||
// WHEN fingerprint authenticated
|
// WHEN unlocked with fingerprint
|
||||||
val captor = ArgumentCaptor.forClass(KeyguardUpdateMonitorCallback::class.java)
|
verify(biometricUnlockController).addBiometricModeListener(biometricModeListener.capture())
|
||||||
verify(keyguardUpdateMonitor).registerCallback(captor.capture())
|
biometricModeListener.value.onModeChanged(/* mode= */ 0)
|
||||||
captor.value.onBiometricAuthenticated(
|
|
||||||
0 /* userId */,
|
|
||||||
BiometricSourceType.FINGERPRINT /* type */,
|
|
||||||
false /* isStrongBiometric */)
|
|
||||||
|
|
||||||
// THEN update sensor location and show ripple
|
// THEN update sensor location and show ripple
|
||||||
verify(rippleView).setFingerprintSensorLocation(fpsLocation, 0f)
|
verify(rippleView).setFingerprintSensorLocation(fpsLocation, 0f)
|
||||||
@@ -152,17 +154,15 @@ class AuthRippleControllerTest : SysuiTestCase() {
|
|||||||
val fpsLocation = Point(5, 5)
|
val fpsLocation = Point(5, 5)
|
||||||
`when`(authController.udfpsLocation).thenReturn(fpsLocation)
|
`when`(authController.udfpsLocation).thenReturn(fpsLocation)
|
||||||
controller.onViewAttached()
|
controller.onViewAttached()
|
||||||
`when`(keyguardUpdateMonitor.isUnlockingWithBiometricAllowed(
|
`when`(keyguardUpdateMonitor.isUnlockingWithBiometricAllowed(eq(FINGERPRINT)))
|
||||||
eq(BiometricSourceType.FINGERPRINT))).thenReturn(true)
|
.thenReturn(true)
|
||||||
|
`when`(biometricUnlockController.isBiometricUnlock).thenReturn(true)
|
||||||
|
`when`(biometricUnlockController.biometricType).thenReturn(FINGERPRINT)
|
||||||
|
|
||||||
// WHEN keyguard is NOT showing & fingerprint authenticated
|
// WHEN keyguard is NOT showing & fingerprint authenticated
|
||||||
`when`(keyguardStateController.isShowing).thenReturn(false)
|
`when`(keyguardStateController.isShowing).thenReturn(false)
|
||||||
val captor = ArgumentCaptor.forClass(KeyguardUpdateMonitorCallback::class.java)
|
verify(biometricUnlockController).addBiometricModeListener(biometricModeListener.capture())
|
||||||
verify(keyguardUpdateMonitor).registerCallback(captor.capture())
|
biometricModeListener.value.onModeChanged(/* mode= */ 0)
|
||||||
captor.value.onBiometricAuthenticated(
|
|
||||||
0 /* userId */,
|
|
||||||
BiometricSourceType.FINGERPRINT /* type */,
|
|
||||||
false /* isStrongBiometric */)
|
|
||||||
|
|
||||||
// THEN no ripple
|
// THEN no ripple
|
||||||
verify(rippleView, never()).startUnlockedRipple(any())
|
verify(rippleView, never()).startUnlockedRipple(any())
|
||||||
@@ -175,61 +175,14 @@ class AuthRippleControllerTest : SysuiTestCase() {
|
|||||||
`when`(authController.udfpsLocation).thenReturn(fpsLocation)
|
`when`(authController.udfpsLocation).thenReturn(fpsLocation)
|
||||||
controller.onViewAttached()
|
controller.onViewAttached()
|
||||||
`when`(keyguardStateController.isShowing).thenReturn(true)
|
`when`(keyguardStateController.isShowing).thenReturn(true)
|
||||||
|
`when`(biometricUnlockController.isBiometricUnlock).thenReturn(true)
|
||||||
|
`when`(biometricUnlockController.biometricType).thenReturn(FINGERPRINT)
|
||||||
|
|
||||||
// WHEN unlocking with fingerprint is NOT allowed & fingerprint authenticated
|
// WHEN unlocking with fingerprint is NOT allowed & fingerprint authenticated
|
||||||
`when`(keyguardUpdateMonitor.isUnlockingWithBiometricAllowed(
|
`when`(keyguardUpdateMonitor.isUnlockingWithBiometricAllowed(eq(FINGERPRINT)))
|
||||||
eq(BiometricSourceType.FINGERPRINT))).thenReturn(false)
|
.thenReturn(false)
|
||||||
val captor = ArgumentCaptor.forClass(KeyguardUpdateMonitorCallback::class.java)
|
verify(biometricUnlockController).addBiometricModeListener(biometricModeListener.capture())
|
||||||
verify(keyguardUpdateMonitor).registerCallback(captor.capture())
|
biometricModeListener.value.onModeChanged(/* mode= */ 0)
|
||||||
captor.value.onBiometricAuthenticated(
|
|
||||||
0 /* userId */,
|
|
||||||
BiometricSourceType.FINGERPRINT /* type */,
|
|
||||||
false /* isStrongBiometric */)
|
|
||||||
|
|
||||||
// THEN no ripple
|
|
||||||
verify(rippleView, never()).startUnlockedRipple(any())
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun testFaceTriggerBypassEnabled_Ripple() {
|
|
||||||
// GIVEN face auth sensor exists, keyguard is showing & unlocking with face is allowed
|
|
||||||
val faceLocation = Point(5, 5)
|
|
||||||
`when`(authController.faceSensorLocation).thenReturn(faceLocation)
|
|
||||||
controller.onViewAttached()
|
|
||||||
|
|
||||||
`when`(keyguardStateController.isShowing).thenReturn(true)
|
|
||||||
`when`(keyguardUpdateMonitor.isUnlockingWithBiometricAllowed(
|
|
||||||
BiometricSourceType.FACE)).thenReturn(true)
|
|
||||||
|
|
||||||
// WHEN bypass is enabled & face authenticated
|
|
||||||
`when`(bypassController.canBypass()).thenReturn(true)
|
|
||||||
val captor = ArgumentCaptor.forClass(KeyguardUpdateMonitorCallback::class.java)
|
|
||||||
verify(keyguardUpdateMonitor).registerCallback(captor.capture())
|
|
||||||
captor.value.onBiometricAuthenticated(
|
|
||||||
0 /* userId */,
|
|
||||||
BiometricSourceType.FACE /* type */,
|
|
||||||
false /* isStrongBiometric */)
|
|
||||||
|
|
||||||
// THEN show ripple
|
|
||||||
verify(rippleView).setSensorLocation(faceLocation)
|
|
||||||
verify(rippleView).startUnlockedRipple(any())
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun testFaceTriggerNonBypass_NoRipple() {
|
|
||||||
// GIVEN face auth sensor exists
|
|
||||||
val faceLocation = Point(5, 5)
|
|
||||||
`when`(authController.faceSensorLocation).thenReturn(faceLocation)
|
|
||||||
controller.onViewAttached()
|
|
||||||
|
|
||||||
// WHEN bypass isn't enabled & face authenticated
|
|
||||||
`when`(bypassController.canBypass()).thenReturn(false)
|
|
||||||
val captor = ArgumentCaptor.forClass(KeyguardUpdateMonitorCallback::class.java)
|
|
||||||
verify(keyguardUpdateMonitor).registerCallback(captor.capture())
|
|
||||||
captor.value.onBiometricAuthenticated(
|
|
||||||
0 /* userId */,
|
|
||||||
BiometricSourceType.FACE /* type */,
|
|
||||||
false /* isStrongBiometric */)
|
|
||||||
|
|
||||||
// THEN no ripple
|
// THEN no ripple
|
||||||
verify(rippleView, never()).startUnlockedRipple(any())
|
verify(rippleView, never()).startUnlockedRipple(any())
|
||||||
@@ -239,14 +192,12 @@ class AuthRippleControllerTest : SysuiTestCase() {
|
|||||||
fun testNullFaceSensorLocationDoesNothing() {
|
fun testNullFaceSensorLocationDoesNothing() {
|
||||||
`when`(authController.faceSensorLocation).thenReturn(null)
|
`when`(authController.faceSensorLocation).thenReturn(null)
|
||||||
controller.onViewAttached()
|
controller.onViewAttached()
|
||||||
|
`when`(biometricUnlockController.biometricType).thenReturn(FACE)
|
||||||
|
`when`(biometricUnlockController.isBiometricUnlock).thenReturn(true)
|
||||||
|
|
||||||
val captor = ArgumentCaptor.forClass(KeyguardUpdateMonitorCallback::class.java)
|
verify(biometricUnlockController).addBiometricModeListener(biometricModeListener.capture())
|
||||||
verify(keyguardUpdateMonitor).registerCallback(captor.capture())
|
biometricModeListener.value.onModeChanged(/* mode= */ 0)
|
||||||
|
|
||||||
captor.value.onBiometricAuthenticated(
|
|
||||||
0 /* userId */,
|
|
||||||
BiometricSourceType.FACE /* type */,
|
|
||||||
false /* isStrongBiometric */)
|
|
||||||
verify(rippleView, never()).startUnlockedRipple(any())
|
verify(rippleView, never()).startUnlockedRipple(any())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,25 +205,21 @@ class AuthRippleControllerTest : SysuiTestCase() {
|
|||||||
fun testNullFingerprintSensorLocationDoesNothing() {
|
fun testNullFingerprintSensorLocationDoesNothing() {
|
||||||
`when`(authController.fingerprintSensorLocation).thenReturn(null)
|
`when`(authController.fingerprintSensorLocation).thenReturn(null)
|
||||||
controller.onViewAttached()
|
controller.onViewAttached()
|
||||||
|
`when`(biometricUnlockController.biometricType).thenReturn(FINGERPRINT)
|
||||||
|
`when`(biometricUnlockController.isBiometricUnlock).thenReturn(true)
|
||||||
|
|
||||||
val captor = ArgumentCaptor.forClass(KeyguardUpdateMonitorCallback::class.java)
|
verify(biometricUnlockController).addBiometricModeListener(biometricModeListener.capture())
|
||||||
verify(keyguardUpdateMonitor).registerCallback(captor.capture())
|
biometricModeListener.value.onModeChanged(/* mode= */ 0)
|
||||||
|
|
||||||
captor.value.onBiometricAuthenticated(
|
|
||||||
0 /* userId */,
|
|
||||||
BiometricSourceType.FINGERPRINT /* type */,
|
|
||||||
false /* isStrongBiometric */)
|
|
||||||
verify(rippleView, never()).startUnlockedRipple(any())
|
verify(rippleView, never()).startUnlockedRipple(any())
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun registersAndDeregisters() {
|
fun registersAndDeregisters() {
|
||||||
controller.onViewAttached()
|
controller.onViewAttached()
|
||||||
val captor = ArgumentCaptor
|
val captor = ArgumentCaptor.forClass(KeyguardStateController.Callback::class.java)
|
||||||
.forClass(KeyguardStateController.Callback::class.java)
|
|
||||||
verify(keyguardStateController).addCallback(captor.capture())
|
verify(keyguardStateController).addCallback(captor.capture())
|
||||||
val captor2 = ArgumentCaptor
|
val captor2 = ArgumentCaptor.forClass(WakefulnessLifecycle.Observer::class.java)
|
||||||
.forClass(WakefulnessLifecycle.Observer::class.java)
|
|
||||||
verify(wakefulnessLifecycle).addObserver(captor2.capture())
|
verify(wakefulnessLifecycle).addObserver(captor2.capture())
|
||||||
controller.onViewDetached()
|
controller.onViewDetached()
|
||||||
verify(keyguardStateController).removeCallback(any())
|
verify(keyguardStateController).removeCallback(any())
|
||||||
@@ -286,17 +233,20 @@ class AuthRippleControllerTest : SysuiTestCase() {
|
|||||||
`when`(authController.fingerprintSensorLocation).thenReturn(fpsLocation)
|
`when`(authController.fingerprintSensorLocation).thenReturn(fpsLocation)
|
||||||
controller.onViewAttached()
|
controller.onViewAttached()
|
||||||
`when`(keyguardStateController.isShowing).thenReturn(true)
|
`when`(keyguardStateController.isShowing).thenReturn(true)
|
||||||
`when`(keyguardUpdateMonitor.isUnlockingWithBiometricAllowed(
|
`when`(keyguardUpdateMonitor.isUnlockingWithBiometricAllowed(FINGERPRINT)).thenReturn(true)
|
||||||
BiometricSourceType.FINGERPRINT)).thenReturn(true)
|
|
||||||
`when`(biometricUnlockController.isWakeAndUnlock).thenReturn(true)
|
`when`(biometricUnlockController.isWakeAndUnlock).thenReturn(true)
|
||||||
|
|
||||||
controller.showUnlockRipple(BiometricSourceType.FINGERPRINT)
|
controller.showUnlockRipple(FINGERPRINT)
|
||||||
assertTrue("reveal didn't start on keyguardFadingAway",
|
assertTrue(
|
||||||
controller.startLightRevealScrimOnKeyguardFadingAway)
|
"reveal didn't start on keyguardFadingAway",
|
||||||
|
controller.startLightRevealScrimOnKeyguardFadingAway
|
||||||
|
)
|
||||||
`when`(keyguardStateController.isKeyguardFadingAway).thenReturn(true)
|
`when`(keyguardStateController.isKeyguardFadingAway).thenReturn(true)
|
||||||
controller.onKeyguardFadingAwayChanged()
|
controller.onKeyguardFadingAwayChanged()
|
||||||
assertFalse("reveal triggers multiple times",
|
assertFalse(
|
||||||
controller.startLightRevealScrimOnKeyguardFadingAway)
|
"reveal triggers multiple times",
|
||||||
|
controller.startLightRevealScrimOnKeyguardFadingAway
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -308,23 +258,26 @@ class AuthRippleControllerTest : SysuiTestCase() {
|
|||||||
`when`(keyguardStateController.isShowing).thenReturn(true)
|
`when`(keyguardStateController.isShowing).thenReturn(true)
|
||||||
`when`(biometricUnlockController.isWakeAndUnlock).thenReturn(true)
|
`when`(biometricUnlockController.isWakeAndUnlock).thenReturn(true)
|
||||||
`when`(authController.isUdfpsFingerDown).thenReturn(true)
|
`when`(authController.isUdfpsFingerDown).thenReturn(true)
|
||||||
`when`(keyguardUpdateMonitor.isUnlockingWithBiometricAllowed(
|
`when`(keyguardUpdateMonitor.isUnlockingWithBiometricAllowed(eq(FACE))).thenReturn(true)
|
||||||
eq(BiometricSourceType.FACE))).thenReturn(true)
|
|
||||||
|
|
||||||
controller.showUnlockRipple(BiometricSourceType.FACE)
|
controller.showUnlockRipple(FACE)
|
||||||
assertTrue("reveal didn't start on keyguardFadingAway",
|
assertTrue(
|
||||||
controller.startLightRevealScrimOnKeyguardFadingAway)
|
"reveal didn't start on keyguardFadingAway",
|
||||||
|
controller.startLightRevealScrimOnKeyguardFadingAway
|
||||||
|
)
|
||||||
`when`(keyguardStateController.isKeyguardFadingAway).thenReturn(true)
|
`when`(keyguardStateController.isKeyguardFadingAway).thenReturn(true)
|
||||||
controller.onKeyguardFadingAwayChanged()
|
controller.onKeyguardFadingAwayChanged()
|
||||||
assertFalse("reveal triggers multiple times",
|
assertFalse(
|
||||||
controller.startLightRevealScrimOnKeyguardFadingAway)
|
"reveal triggers multiple times",
|
||||||
|
controller.startLightRevealScrimOnKeyguardFadingAway
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testUpdateRippleColor() {
|
fun testUpdateRippleColor() {
|
||||||
controller.onViewAttached()
|
controller.onViewAttached()
|
||||||
val captor = ArgumentCaptor
|
val captor =
|
||||||
.forClass(ConfigurationController.ConfigurationListener::class.java)
|
ArgumentCaptor.forClass(ConfigurationController.ConfigurationListener::class.java)
|
||||||
verify(configurationController).addCallback(captor.capture())
|
verify(configurationController).addCallback(captor.capture())
|
||||||
|
|
||||||
reset(rippleView)
|
reset(rippleView)
|
||||||
|
|||||||
Reference in New Issue
Block a user