From dee0b87f73abb633f3ffc80109c5ca2b7610eb66 Mon Sep 17 00:00:00 2001 From: Beverly Date: Fri, 31 Mar 2023 19:05:02 +0000 Subject: [PATCH] Preemptively hide UDPFS icon on biometric authenticated To avoid overlap with the unlock icon after face auth is successful on AOD. We intentionally check for isBiometricAuthenticated instead of isUnlocked because checking keyguardStateController#isUnlocked would cause a delay in showing UDFPS on the transition from HOME => AOD, (since the isUnlocked state doesn't immediately get updated) which would be unintended. Test: atest UdfpsKeyguardViewControllerTest Fixes: 233833672 Change-Id: Icfaee57ca8889321b765192199bc86c52b1d0f47 --- .../biometrics/UdfpsKeyguardViewController.kt | 12 ++++++++++++ .../UdfpsKeyguardViewControllerTest.java | 17 +++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsKeyguardViewController.kt b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsKeyguardViewController.kt index 063b41e8db0f9..5101ad4c94bcf 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsKeyguardViewController.kt +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsKeyguardViewController.kt @@ -167,6 +167,9 @@ constructor( private val keyguardStateControllerCallback: KeyguardStateController.Callback = object : KeyguardStateController.Callback { + override fun onUnlockedChanged() { + updatePauseAuth() + } override fun onLaunchTransitionFadingAwayChanged() { launchTransitionFadingAway = keyguardStateController.isLaunchTransitionFadingAway updatePauseAuth() @@ -403,6 +406,15 @@ constructor( if (isBouncerExpansionGreaterThan(.5f)) { return true } + if ( + keyguardUpdateMonitor.getUserUnlockedWithBiometric( + KeyguardUpdateMonitor.getCurrentUser() + ) + ) { + // If the device was unlocked by a biometric, immediately hide the UDFPS icon to avoid + // overlap with the LockIconView. Shortly afterwards, UDFPS will stop running. + return true + } return view.unpausedAlpha < 255 * .1 } diff --git a/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsKeyguardViewControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsKeyguardViewControllerTest.java index f437a8f009f81..6d9acb92a5f4f 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsKeyguardViewControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsKeyguardViewControllerTest.java @@ -19,6 +19,7 @@ package com.android.systemui.biometrics; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.Mockito.atLeast; import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.never; @@ -156,6 +157,22 @@ public class UdfpsKeyguardViewControllerTest extends UdfpsKeyguardViewController assertFalse(mController.shouldPauseAuth()); } + @Test + public void onBiometricAuthenticated_pauseAuth() { + // GIVEN view is attached and we're on the keyguard (see testShouldNotPauseAuthOnKeyguard) + mController.onViewAttached(); + captureStatusBarStateListeners(); + sendStatusBarStateChanged(StatusBarState.KEYGUARD); + + // WHEN biometric is authenticated + captureKeyguardStateControllerCallback(); + when(mKeyguardUpdateMonitor.getUserUnlockedWithBiometric(anyInt())).thenReturn(true); + mKeyguardStateControllerCallback.onUnlockedChanged(); + + // THEN pause auth + assertTrue(mController.shouldPauseAuth()); + } + @Test public void testShouldPauseAuthIsLaunchTransitionFadingAway() { // GIVEN view is attached and we're on the keyguard (see testShouldNotPauseAuthOnKeyguard)