Merge "Do not run face detection for bypass when the user is authenticated by FP" into tm-qpr-dev am: 6e16fac514

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20493546

Change-Id: Ib3a81e55c8ad6b8cd34e67c75ce5b9ec6e027500
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Chandru S
2022-11-17 10:38:03 +00:00
committed by Automerger Merge Worker
4 changed files with 53 additions and 17 deletions

View File

@@ -50,10 +50,9 @@ data class KeyguardFaceListenModel(
override val listening: Boolean, override val listening: Boolean,
// keep sorted // keep sorted
val authInterruptActive: Boolean, val authInterruptActive: Boolean,
val becauseCannotSkipBouncer: Boolean,
val biometricSettingEnabledForUser: Boolean, val biometricSettingEnabledForUser: Boolean,
val bouncerFullyShown: Boolean, val bouncerFullyShown: Boolean,
val faceAuthenticated: Boolean, val faceAndFpNotAuthenticated: Boolean,
val faceDisabled: Boolean, val faceDisabled: Boolean,
val faceLockedOut: Boolean, val faceLockedOut: Boolean,
val fpLockedOut: Boolean, val fpLockedOut: Boolean,
@@ -67,7 +66,9 @@ data class KeyguardFaceListenModel(
val secureCameraLaunched: Boolean, val secureCameraLaunched: Boolean,
val switchingUser: Boolean, val switchingUser: Boolean,
val udfpsBouncerShowing: Boolean, val udfpsBouncerShowing: Boolean,
) : KeyguardListenModel() val udfpsFingerDown: Boolean,
val userNotTrustedOrDetectionIsNeeded: Boolean,
) : KeyguardListenModel()
/** /**
* Verbose debug information associated with [KeyguardUpdateMonitor.shouldTriggerActiveUnlock]. * Verbose debug information associated with [KeyguardUpdateMonitor.shouldTriggerActiveUnlock].
*/ */

View File

@@ -810,9 +810,9 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
} }
// Don't send cancel if authentication succeeds // Don't send cancel if authentication succeeds
mFingerprintCancelSignal = null; mFingerprintCancelSignal = null;
mLogger.logFingerprintSuccess(userId, isStrongBiometric);
updateBiometricListeningState(BIOMETRIC_ACTION_UPDATE, updateBiometricListeningState(BIOMETRIC_ACTION_UPDATE,
FACE_AUTH_UPDATED_FP_AUTHENTICATED); FACE_AUTH_UPDATED_FP_AUTHENTICATED);
mLogger.logFingerprintSuccess(userId, isStrongBiometric);
for (int i = 0; i < mCallbacks.size(); i++) { for (int i = 0; i < mCallbacks.size(); i++) {
KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get(); KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
if (cb != null) { if (cb != null) {
@@ -2726,9 +2726,9 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
final boolean canBypass = mKeyguardBypassController != null final boolean canBypass = mKeyguardBypassController != null
&& mKeyguardBypassController.canBypass(); && mKeyguardBypassController.canBypass();
// There's no reason to ask the HAL for authentication when the user can dismiss the // There's no reason to ask the HAL for authentication when the user can dismiss the
// bouncer, unless we're bypassing and need to auto-dismiss the lock screen even when // bouncer because the user is trusted, unless we're bypassing and need to auto-dismiss
// TrustAgents or biometrics are keeping the device unlocked. // the lock screen even when TrustAgents are keeping the device unlocked.
final boolean becauseCannotSkipBouncer = !getUserCanSkipBouncer(user) || canBypass; final boolean userNotTrustedOrDetectionIsNeeded = !getUserHasTrust(user) || canBypass;
// Scan even when encrypted or timeout to show a preemptive bouncer when bypassing. // Scan even when encrypted or timeout to show a preemptive bouncer when bypassing.
// Lock-down mode shouldn't scan, since it is more explicit. // Lock-down mode shouldn't scan, since it is more explicit.
@@ -2745,11 +2745,12 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
strongAuthAllowsScanning = false; strongAuthAllowsScanning = false;
} }
// If the face has recently been authenticated do not attempt to authenticate again. // If the face or fp has recently been authenticated do not attempt to authenticate again.
final boolean faceAuthenticated = getIsFaceAuthenticated(); final boolean faceAndFpNotAuthenticated = !getUserUnlockedWithBiometric(user);
final boolean faceDisabledForUser = isFaceDisabled(user); final boolean faceDisabledForUser = isFaceDisabled(user);
final boolean biometricEnabledForUser = mBiometricEnabledForUser.get(user); final boolean biometricEnabledForUser = mBiometricEnabledForUser.get(user);
final boolean shouldListenForFaceAssistant = shouldListenForFaceAssistant(); final boolean shouldListenForFaceAssistant = shouldListenForFaceAssistant();
final boolean isUdfpsFingerDown = mAuthController.isUdfpsFingerDown();
// Only listen if this KeyguardUpdateMonitor belongs to the primary user. There is an // Only listen if this KeyguardUpdateMonitor belongs to the primary user. There is an
// instance of KeyguardUpdateMonitor for each user but KeyguardUpdateMonitor is user-aware. // instance of KeyguardUpdateMonitor for each user but KeyguardUpdateMonitor is user-aware.
@@ -2759,13 +2760,13 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|| mOccludingAppRequestingFace || mOccludingAppRequestingFace
|| awakeKeyguard || awakeKeyguard
|| shouldListenForFaceAssistant || shouldListenForFaceAssistant
|| mAuthController.isUdfpsFingerDown() || isUdfpsFingerDown
|| mUdfpsBouncerShowing) || mUdfpsBouncerShowing)
&& !mSwitchingUser && !faceDisabledForUser && becauseCannotSkipBouncer && !mSwitchingUser && !faceDisabledForUser && userNotTrustedOrDetectionIsNeeded
&& !mKeyguardGoingAway && biometricEnabledForUser && !mKeyguardGoingAway && biometricEnabledForUser
&& strongAuthAllowsScanning && mIsPrimaryUser && strongAuthAllowsScanning && mIsPrimaryUser
&& (!mSecureCameraLaunched || mOccludingAppRequestingFace) && (!mSecureCameraLaunched || mOccludingAppRequestingFace)
&& !faceAuthenticated && faceAndFpNotAuthenticated
&& !mGoingToSleep && !mGoingToSleep
// We only care about fp locked out state and not face because we still trigger // We only care about fp locked out state and not face because we still trigger
// face auth even when face is locked out to show the user a message that face // face auth even when face is locked out to show the user a message that face
@@ -2779,10 +2780,9 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
user, user,
shouldListen, shouldListen,
mAuthInterruptActive, mAuthInterruptActive,
becauseCannotSkipBouncer,
biometricEnabledForUser, biometricEnabledForUser,
mPrimaryBouncerFullyShown, mPrimaryBouncerFullyShown,
faceAuthenticated, faceAndFpNotAuthenticated,
faceDisabledForUser, faceDisabledForUser,
isFaceLockedOut(), isFaceLockedOut(),
fpLockedOut, fpLockedOut,
@@ -2795,7 +2795,9 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
strongAuthAllowsScanning, strongAuthAllowsScanning,
mSecureCameraLaunched, mSecureCameraLaunched,
mSwitchingUser, mSwitchingUser,
mUdfpsBouncerShowing)); mUdfpsBouncerShowing,
isUdfpsFingerDown,
userNotTrustedOrDetectionIsNeeded));
return shouldListen; return shouldListen;
} }

View File

@@ -84,10 +84,9 @@ private fun faceModel(user: Int) = KeyguardFaceListenModel(
userId = user, userId = user,
listening = false, listening = false,
authInterruptActive = false, authInterruptActive = false,
becauseCannotSkipBouncer = false,
biometricSettingEnabledForUser = false, biometricSettingEnabledForUser = false,
bouncerFullyShown = false, bouncerFullyShown = false,
faceAuthenticated = false, faceAndFpNotAuthenticated = false,
faceDisabled = false, faceDisabled = false,
faceLockedOut = false, faceLockedOut = false,
fpLockedOut = false, fpLockedOut = false,
@@ -101,4 +100,6 @@ private fun faceModel(user: Int) = KeyguardFaceListenModel(
secureCameraLaunched = false, secureCameraLaunched = false,
switchingUser = false, switchingUser = false,
udfpsBouncerShowing = false, udfpsBouncerShowing = false,
udfpsFingerDown = false,
userNotTrustedOrDetectionIsNeeded = false
) )

View File

@@ -1381,6 +1381,29 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
assertThat(mKeyguardUpdateMonitor.shouldListenForFace()).isFalse(); assertThat(mKeyguardUpdateMonitor.shouldListenForFace()).isFalse();
} }
@Test
public void testShouldListenForFace_whenFpIsAlreadyAuthenticated_returnsFalse()
throws RemoteException {
// Face auth should run when the following is true.
bouncerFullyVisibleAndNotGoingToSleep();
keyguardNotGoingAway();
currentUserIsPrimary();
strongAuthNotRequired();
biometricsEnabledForCurrentUser();
currentUserDoesNotHaveTrust();
biometricsNotDisabledThroughDevicePolicyManager();
userNotCurrentlySwitching();
mTestableLooper.processAllMessages();
assertThat(mKeyguardUpdateMonitor.shouldListenForFace()).isTrue();
successfulFingerprintAuth();
mTestableLooper.processAllMessages();
assertThat(mKeyguardUpdateMonitor.shouldListenForFace()).isFalse();
}
@Test @Test
public void testShouldListenForFace_whenUserIsNotPrimary_returnsFalse() throws RemoteException { public void testShouldListenForFace_whenUserIsNotPrimary_returnsFalse() throws RemoteException {
cleanupKeyguardUpdateMonitor(); cleanupKeyguardUpdateMonitor();
@@ -1935,6 +1958,15 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
.onAuthenticationAcquired(FINGERPRINT_ACQUIRED_START); .onAuthenticationAcquired(FINGERPRINT_ACQUIRED_START);
} }
private void successfulFingerprintAuth() {
mKeyguardUpdateMonitor.mFingerprintAuthenticationCallback
.onAuthenticationSucceeded(
new FingerprintManager.AuthenticationResult(null,
null,
mCurrentUserId,
true));
}
private void triggerSuccessfulFaceAuth() { private void triggerSuccessfulFaceAuth() {
mKeyguardUpdateMonitor.requestFaceAuth(FaceAuthApiRequestReason.UDFPS_POINTER_DOWN); mKeyguardUpdateMonitor.requestFaceAuth(FaceAuthApiRequestReason.UDFPS_POINTER_DOWN);
verify(mFaceManager).authenticate(any(), verify(mFaceManager).authenticate(any(),