Merge "Revert "Stop running face detection on bouncer if both face and fp are enrolled."" into tm-qpr-dev

This commit is contained in:
Chandru S
2022-09-26 17:05:27 +00:00
committed by Android (Google) Code Review
4 changed files with 15 additions and 104 deletions

View File

@@ -57,11 +57,10 @@ data class KeyguardFaceListenModel(
val faceLockedOut: Boolean, val faceLockedOut: Boolean,
val fpLockedOut: Boolean, val fpLockedOut: Boolean,
val goingToSleep: Boolean, val goingToSleep: Boolean,
val keyguardAwakeExcludingBouncerShowing: Boolean, val keyguardAwake: Boolean,
val keyguardGoingAway: Boolean, val keyguardGoingAway: Boolean,
val listeningForFaceAssistant: Boolean, val listeningForFaceAssistant: Boolean,
val occludingAppRequestingFaceAuth: Boolean, val occludingAppRequestingFaceAuth: Boolean,
val onlyFaceEnrolled: Boolean,
val primaryUser: Boolean, val primaryUser: Boolean,
val scanningAllowedByStrongAuth: Boolean, val scanningAllowedByStrongAuth: Boolean,
val secureCameraLaunched: Boolean, val secureCameraLaunched: Boolean,

View File

@@ -2593,11 +2593,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
} }
final boolean statusBarShadeLocked = mStatusBarState == StatusBarState.SHADE_LOCKED; final boolean statusBarShadeLocked = mStatusBarState == StatusBarState.SHADE_LOCKED;
// mKeyguardIsVisible is true even when the bouncer is shown, we don't want to run face auth final boolean awakeKeyguard = mKeyguardIsVisible && mDeviceInteractive && !mGoingToSleep
// on bouncer if both fp and fingerprint are enrolled. && !statusBarShadeLocked;
final boolean awakeKeyguardExcludingBouncerShowing = mKeyguardIsVisible
&& mDeviceInteractive && !mGoingToSleep
&& !statusBarShadeLocked && !mBouncerFullyShown;
final int user = getCurrentUser(); final int user = getCurrentUser();
final int strongAuth = mStrongAuthTracker.getStrongAuthForUser(user); final int strongAuth = mStrongAuthTracker.getStrongAuthForUser(user);
final boolean isLockDown = final boolean isLockDown =
@@ -2637,16 +2634,15 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
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 onlyFaceEnrolled = isOnlyFaceEnrolled();
final boolean fpOrFaceIsLockedOut = isFaceLockedOut() || fpLockedout; final boolean fpOrFaceIsLockedOut = isFaceLockedOut() || fpLockedout;
// 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.
final boolean shouldListen = final boolean shouldListen =
((mBouncerFullyShown && !mGoingToSleep && onlyFaceEnrolled) (mBouncerFullyShown && !mGoingToSleep
|| mAuthInterruptActive || mAuthInterruptActive
|| mOccludingAppRequestingFace || mOccludingAppRequestingFace
|| awakeKeyguardExcludingBouncerShowing || awakeKeyguard
|| shouldListenForFaceAssistant || shouldListenForFaceAssistant
|| mAuthController.isUdfpsFingerDown() || mAuthController.isUdfpsFingerDown()
|| mUdfpsBouncerShowing) || mUdfpsBouncerShowing)
@@ -2672,11 +2668,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
isFaceLockedOut(), isFaceLockedOut(),
fpLockedout, fpLockedout,
mGoingToSleep, mGoingToSleep,
awakeKeyguardExcludingBouncerShowing, awakeKeyguard,
mKeyguardGoingAway, mKeyguardGoingAway,
shouldListenForFaceAssistant, shouldListenForFaceAssistant,
mOccludingAppRequestingFace, mOccludingAppRequestingFace,
onlyFaceEnrolled,
mIsPrimaryUser, mIsPrimaryUser,
strongAuthAllowsScanning, strongAuthAllowsScanning,
mSecureCameraLaunched, mSecureCameraLaunched,
@@ -2686,11 +2681,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
return shouldListen; return shouldListen;
} }
private boolean isOnlyFaceEnrolled() {
return isFaceEnrolled()
&& !getCachedIsUnlockWithFingerprintPossible(sCurrentUser);
}
private void maybeLogListenerModelData(KeyguardListenModel model) { private void maybeLogListenerModelData(KeyguardListenModel model) {
mLogger.logKeyguardListenerModel(model); mLogger.logKeyguardListenerModel(model);

View File

@@ -86,13 +86,12 @@ private fun faceModel(user: Int) = KeyguardFaceListenModel(
becauseCannotSkipBouncer = false, becauseCannotSkipBouncer = false,
biometricSettingEnabledForUser = false, biometricSettingEnabledForUser = false,
bouncerFullyShown = false, bouncerFullyShown = false,
onlyFaceEnrolled = false,
faceAuthenticated = false, faceAuthenticated = false,
faceDisabled = false, faceDisabled = false,
faceLockedOut = false, faceLockedOut = false,
fpLockedOut = false, fpLockedOut = false,
goingToSleep = false, goingToSleep = false,
keyguardAwakeExcludingBouncerShowing = false, keyguardAwake = false,
keyguardGoingAway = false, keyguardGoingAway = false,
listeningForFaceAssistant = false, listeningForFaceAssistant = false,
occludingAppRequestingFaceAuth = false, occludingAppRequestingFaceAuth = false,

View File

@@ -212,8 +212,6 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
mBiometricEnabledCallbackArgCaptor; mBiometricEnabledCallbackArgCaptor;
@Captor @Captor
private ArgumentCaptor<FaceManager.AuthenticationCallback> mAuthenticationCallbackCaptor; private ArgumentCaptor<FaceManager.AuthenticationCallback> mAuthenticationCallbackCaptor;
@Captor
private ArgumentCaptor<CancellationSignal> mCancellationSignalCaptor;
// Direct executor // Direct executor
private final Executor mBackgroundExecutor = Runnable::run; private final Executor mBackgroundExecutor = Runnable::run;
@@ -596,13 +594,11 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
@Test @Test
public void testTriesToAuthenticate_whenBouncer() { public void testTriesToAuthenticate_whenBouncer() {
fingerprintIsNotEnrolled();
faceAuthEnabled();
setKeyguardBouncerVisibility(true); setKeyguardBouncerVisibility(true);
verify(mFaceManager).authenticate(any(), any(), any(), any(), anyInt(), anyBoolean()); verify(mFaceManager).authenticate(any(), any(), any(), any(), anyInt(), anyBoolean());
verify(mFaceManager, atLeastOnce()).isHardwareDetected(); verify(mFaceManager).isHardwareDetected();
verify(mFaceManager, atLeastOnce()).hasEnrolledTemplates(anyInt()); verify(mFaceManager).hasEnrolledTemplates(anyInt());
} }
@Test @Test
@@ -1237,9 +1233,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
public void testShouldListenForFace_whenFaceIsAlreadyAuthenticated_returnsFalse() public void testShouldListenForFace_whenFaceIsAlreadyAuthenticated_returnsFalse()
throws RemoteException { throws RemoteException {
// Face auth should run when the following is true. // Face auth should run when the following is true.
faceAuthEnabled();
bouncerFullyVisibleAndNotGoingToSleep(); bouncerFullyVisibleAndNotGoingToSleep();
fingerprintIsNotEnrolled();
keyguardNotGoingAway(); keyguardNotGoingAway();
currentUserIsPrimary(); currentUserIsPrimary();
strongAuthNotRequired(); strongAuthNotRequired();
@@ -1266,7 +1260,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
mKeyguardUpdateMonitor = mKeyguardUpdateMonitor =
new TestableKeyguardUpdateMonitor(mSpiedContext); new TestableKeyguardUpdateMonitor(mSpiedContext);
// Preconditions for face auth to run // Face auth should run when the following is true.
keyguardNotGoingAway(); keyguardNotGoingAway();
bouncerFullyVisibleAndNotGoingToSleep(); bouncerFullyVisibleAndNotGoingToSleep();
strongAuthNotRequired(); strongAuthNotRequired();
@@ -1283,7 +1277,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
@Test @Test
public void testShouldListenForFace_whenStrongAuthDoesNotAllowScanning_returnsFalse() public void testShouldListenForFace_whenStrongAuthDoesNotAllowScanning_returnsFalse()
throws RemoteException { throws RemoteException {
// Preconditions for face auth to run // Face auth should run when the following is true.
keyguardNotGoingAway(); keyguardNotGoingAway();
bouncerFullyVisibleAndNotGoingToSleep(); bouncerFullyVisibleAndNotGoingToSleep();
currentUserIsPrimary(); currentUserIsPrimary();
@@ -1304,11 +1298,8 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
@Test @Test
public void testShouldListenForFace_whenBiometricsDisabledForUser_returnsFalse() public void testShouldListenForFace_whenBiometricsDisabledForUser_returnsFalse()
throws RemoteException { throws RemoteException {
// Preconditions for face auth to run
faceAuthEnabled();
keyguardNotGoingAway(); keyguardNotGoingAway();
bouncerFullyVisibleAndNotGoingToSleep(); bouncerFullyVisibleAndNotGoingToSleep();
fingerprintIsNotEnrolled();
currentUserIsPrimary(); currentUserIsPrimary();
currentUserDoesNotHaveTrust(); currentUserDoesNotHaveTrust();
biometricsNotDisabledThroughDevicePolicyManager(); biometricsNotDisabledThroughDevicePolicyManager();
@@ -1328,11 +1319,9 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
@Test @Test
public void testShouldListenForFace_whenUserCurrentlySwitching_returnsFalse() public void testShouldListenForFace_whenUserCurrentlySwitching_returnsFalse()
throws RemoteException { throws RemoteException {
// Preconditions for face auth to run // Face auth should run when the following is true.
faceAuthEnabled();
keyguardNotGoingAway(); keyguardNotGoingAway();
bouncerFullyVisibleAndNotGoingToSleep(); bouncerFullyVisibleAndNotGoingToSleep();
fingerprintIsNotEnrolled();
currentUserIsPrimary(); currentUserIsPrimary();
currentUserDoesNotHaveTrust(); currentUserDoesNotHaveTrust();
biometricsNotDisabledThroughDevicePolicyManager(); biometricsNotDisabledThroughDevicePolicyManager();
@@ -1351,11 +1340,8 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
@Test @Test
public void testShouldListenForFace_whenSecureCameraLaunched_returnsFalse() public void testShouldListenForFace_whenSecureCameraLaunched_returnsFalse()
throws RemoteException { throws RemoteException {
// Preconditions for face auth to run
faceAuthEnabled();
keyguardNotGoingAway(); keyguardNotGoingAway();
bouncerFullyVisibleAndNotGoingToSleep(); bouncerFullyVisibleAndNotGoingToSleep();
fingerprintIsNotEnrolled();
currentUserIsPrimary(); currentUserIsPrimary();
currentUserDoesNotHaveTrust(); currentUserDoesNotHaveTrust();
biometricsNotDisabledThroughDevicePolicyManager(); biometricsNotDisabledThroughDevicePolicyManager();
@@ -1374,7 +1360,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
@Test @Test
public void testShouldListenForFace_whenOccludingAppRequestsFaceAuth_returnsTrue() public void testShouldListenForFace_whenOccludingAppRequestsFaceAuth_returnsTrue()
throws RemoteException { throws RemoteException {
// Preconditions for face auth to run // Face auth should run when the following is true.
keyguardNotGoingAway(); keyguardNotGoingAway();
bouncerFullyVisibleAndNotGoingToSleep(); bouncerFullyVisibleAndNotGoingToSleep();
currentUserIsPrimary(); currentUserIsPrimary();
@@ -1397,8 +1383,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
@Test @Test
public void testShouldListenForFace_whenBouncerShowingAndDeviceIsAwake_returnsTrue() public void testShouldListenForFace_whenBouncerShowingAndDeviceIsAwake_returnsTrue()
throws RemoteException { throws RemoteException {
// Preconditions for face auth to run // Face auth should run when the following is true.
faceAuthEnabled();
keyguardNotGoingAway(); keyguardNotGoingAway();
currentUserIsPrimary(); currentUserIsPrimary();
currentUserDoesNotHaveTrust(); currentUserDoesNotHaveTrust();
@@ -1410,7 +1395,6 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
assertThat(mKeyguardUpdateMonitor.shouldListenForFace()).isFalse(); assertThat(mKeyguardUpdateMonitor.shouldListenForFace()).isFalse();
bouncerFullyVisibleAndNotGoingToSleep(); bouncerFullyVisibleAndNotGoingToSleep();
fingerprintIsNotEnrolled();
mTestableLooper.processAllMessages(); mTestableLooper.processAllMessages();
assertThat(mKeyguardUpdateMonitor.shouldListenForFace()).isTrue(); assertThat(mKeyguardUpdateMonitor.shouldListenForFace()).isTrue();
@@ -1419,7 +1403,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
@Test @Test
public void testShouldListenForFace_whenAuthInterruptIsActive_returnsTrue() public void testShouldListenForFace_whenAuthInterruptIsActive_returnsTrue()
throws RemoteException { throws RemoteException {
// Preconditions for face auth to run // Face auth should run when the following is true.
keyguardNotGoingAway(); keyguardNotGoingAway();
currentUserIsPrimary(); currentUserIsPrimary();
currentUserDoesNotHaveTrust(); currentUserDoesNotHaveTrust();
@@ -1445,7 +1429,6 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
biometricsNotDisabledThroughDevicePolicyManager(); biometricsNotDisabledThroughDevicePolicyManager();
biometricsEnabledForCurrentUser(); biometricsEnabledForCurrentUser();
userNotCurrentlySwitching(); userNotCurrentlySwitching();
bouncerFullyVisible();
statusBarShadeIsLocked(); statusBarShadeIsLocked();
mTestableLooper.processAllMessages(); mTestableLooper.processAllMessages();
@@ -1459,9 +1442,6 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
keyguardIsVisible(); keyguardIsVisible();
assertThat(mKeyguardUpdateMonitor.shouldListenForFace()).isFalse(); assertThat(mKeyguardUpdateMonitor.shouldListenForFace()).isFalse();
statusBarShadeIsNotLocked(); statusBarShadeIsNotLocked();
assertThat(mKeyguardUpdateMonitor.shouldListenForFace()).isFalse();
bouncerNotFullyVisible();
assertThat(mKeyguardUpdateMonitor.shouldListenForFace()).isTrue(); assertThat(mKeyguardUpdateMonitor.shouldListenForFace()).isTrue();
} }
@@ -1522,44 +1502,6 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
assertThat(mKeyguardUpdateMonitor.shouldListenForFace()).isFalse(); assertThat(mKeyguardUpdateMonitor.shouldListenForFace()).isFalse();
} }
@Test
public void testBouncerVisibility_whenBothFingerprintAndFaceIsEnrolled_stopsFaceAuth()
throws RemoteException {
// Both fingerprint and face are enrolled by default
// Preconditions for face auth to run
keyguardNotGoingAway();
currentUserIsPrimary();
currentUserDoesNotHaveTrust();
biometricsNotDisabledThroughDevicePolicyManager();
biometricsEnabledForCurrentUser();
userNotCurrentlySwitching();
deviceNotGoingToSleep();
deviceIsInteractive();
statusBarShadeIsNotLocked();
keyguardIsVisible();
mTestableLooper.processAllMessages();
clearInvocations(mUiEventLogger);
assertThat(mKeyguardUpdateMonitor.shouldListenForFace()).isTrue();
mKeyguardUpdateMonitor.requestFaceAuth(true,
FaceAuthApiRequestReason.UDFPS_POINTER_DOWN);
verify(mFaceManager).authenticate(any(),
mCancellationSignalCaptor.capture(),
mAuthenticationCallbackCaptor.capture(),
any(),
anyInt(),
anyBoolean());
CancellationSignal cancelSignal = mCancellationSignalCaptor.getValue();
bouncerFullyVisible();
mTestableLooper.processAllMessages();
assertThat(cancelSignal.isCanceled()).isTrue();
}
@Test @Test
public void testFingerprintCanAuth_whenCancellationNotReceivedAndAuthFailed() { public void testFingerprintCanAuth_whenCancellationNotReceivedAndAuthFailed() {
mKeyguardUpdateMonitor.dispatchStartedWakingUp(); mKeyguardUpdateMonitor.dispatchStartedWakingUp();
@@ -1623,21 +1565,6 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
.onAuthenticationError(FaceManager.FACE_ERROR_LOCKOUT_PERMANENT, ""); .onAuthenticationError(FaceManager.FACE_ERROR_LOCKOUT_PERMANENT, "");
} }
private void faceAuthEnabled() {
// this ensures KeyguardUpdateMonitor updates the cached mIsFaceEnrolled flag using the
// face manager mock wire-up in setup()
mKeyguardUpdateMonitor.isFaceAuthEnabledForUser(mCurrentUserId);
}
private void fingerprintIsNotEnrolled() {
when(mFingerprintManager.hasEnrolledTemplates(mCurrentUserId)).thenReturn(false);
// This updates the cached fingerprint state.
// There is no straightforward API to update the fingerprint state.
// It currently works updates after enrollment changes because something else invokes
// startListeningForFingerprint(), which internally calls this method.
mKeyguardUpdateMonitor.isUnlockWithFingerprintPossible(mCurrentUserId);
}
private void statusBarShadeIsNotLocked() { private void statusBarShadeIsNotLocked() {
mStatusBarStateListener.onStateChanged(StatusBarState.KEYGUARD); mStatusBarStateListener.onStateChanged(StatusBarState.KEYGUARD);
} }
@@ -1744,10 +1671,6 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
mKeyguardUpdateMonitor.dispatchStartedWakingUp(); mKeyguardUpdateMonitor.dispatchStartedWakingUp();
} }
private void bouncerNotFullyVisible() {
setKeyguardBouncerVisibility(false);
}
private void bouncerFullyVisible() { private void bouncerFullyVisible() {
setKeyguardBouncerVisibility(true); setKeyguardBouncerVisibility(true);
} }