From 5afa7487dfe14e2272a7cf0f201c4f326dfe435f Mon Sep 17 00:00:00 2001 From: Joshua Mccloskey Date: Thu, 15 Jul 2021 11:43:26 -0700 Subject: [PATCH] Fixed double face auth on swipe Previously, if a face was rejected, and PIN/Pattern/Pass was presented, and the user swiped on to unlock simultaneously, 2x face authentications would be observed. Test: Verified 10/10 times that device no longer performs 2x face authentications in the scenario described above. Fixes: 188598635 Change-Id: I24f964981484cfa19f7e1709f95da485204ff7a9 --- .../keyguard/KeyguardFaceListenModel.kt | 3 ++- .../keyguard/KeyguardUpdateMonitor.java | 20 ++++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardFaceListenModel.kt b/packages/SystemUI/src/com/android/keyguard/KeyguardFaceListenModel.kt index ff20805c5ea4f..0785cc3c04d2c 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardFaceListenModel.kt +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardFaceListenModel.kt @@ -23,5 +23,6 @@ data class KeyguardFaceListenModel( val isLockIconPressed: Boolean, val isScanningAllowedByStrongAuth: Boolean, val isPrimaryUser: Boolean, - val isSecureCameraLaunched: Boolean + val isSecureCameraLaunched: Boolean, + val isFaceAuthenticated: Boolean ) diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java index bd000b2effa3b..907e86658b48b 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java @@ -1058,9 +1058,18 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab || isSimPinSecure()); } + private boolean getIsFaceAuthenticated() { + boolean faceAuthenticated = false; + BiometricAuthenticated bioFaceAuthenticated = mUserFaceAuthenticated.get(getCurrentUser()); + if (bioFaceAuthenticated != null) { + faceAuthenticated = bioFaceAuthenticated.mAuthenticated; + } + return faceAuthenticated; + } + private void requireStrongAuthIfAllLockedOut() { final boolean faceLock = - mFaceLockedOutPermanent || !shouldListenForFace(); + (mFaceLockedOutPermanent || !shouldListenForFace()) && !getIsFaceAuthenticated(); final boolean fpLock = mFingerprintLockedOutPermanent || !shouldListenForFingerprint(isUdfpsEnrolled()); @@ -2236,6 +2245,9 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab strongAuthAllowsScanning = false; } + // If the face has recently been authenticated do not attempt to authenticate again. + boolean faceAuthenticated = getIsFaceAuthenticated(); + // Only listen if this KeyguardUpdateMonitor belongs to the primary user. There is an // instance of KeyguardUpdateMonitor for each user but KeyguardUpdateMonitor is user-aware. final boolean shouldListen = @@ -2244,7 +2256,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab && !mSwitchingUser && !isFaceDisabled(user) && becauseCannotSkipBouncer && !mKeyguardGoingAway && mBiometricEnabledForUser.get(user) && !mLockIconPressed && strongAuthAllowsScanning && mIsPrimaryUser - && (!mSecureCameraLaunched || mOccludingAppRequestingFace); + && (!mSecureCameraLaunched || mOccludingAppRequestingFace) + && !faceAuthenticated; // Aggregate relevant fields for debug logging. if (DEBUG_FACE || DEBUG_SPEW) { @@ -2265,7 +2278,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab mLockIconPressed, strongAuthAllowsScanning, mIsPrimaryUser, - mSecureCameraLaunched); + mSecureCameraLaunched, + faceAuthenticated); maybeLogFaceListenerModelData(model); }