diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardListenModel.kt b/packages/SystemUI/src/com/android/keyguard/KeyguardListenModel.kt index 65412066651ed..5953611b454a3 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardListenModel.kt +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardListenModel.kt @@ -54,6 +54,7 @@ data class KeyguardFaceListenModel( val bouncerFullyShown: Boolean, val faceAuthenticated: Boolean, val faceDisabled: Boolean, + val goingToSleep: Boolean, val keyguardAwake: Boolean, val keyguardGoingAway: Boolean, val listeningForFaceAssistant: Boolean, diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java index dd2664dacf499..1383635a46d14 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java @@ -628,7 +628,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab */ public void setKeyguardGoingAway(boolean goingAway) { mKeyguardGoingAway = goingAway; - updateBiometricListeningState(BIOMETRIC_ACTION_UPDATE); + // This is set specifically to stop face authentication from running. + updateBiometricListeningState(BIOMETRIC_ACTION_STOP); } /** @@ -1746,7 +1747,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab cb.onFinishedGoingToSleep(arg1); } } - updateBiometricListeningState(BIOMETRIC_ACTION_UPDATE); + // This is set specifically to stop face authentication from running. + updateBiometricListeningState(BIOMETRIC_ACTION_STOP); } private void handleScreenTurnedOff() { @@ -1764,7 +1766,12 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab cb.onDreamingStateChanged(mIsDreaming); } } - updateBiometricListeningState(BIOMETRIC_ACTION_UPDATE); + if (mIsDreaming) { + updateFingerprintListeningState(BIOMETRIC_ACTION_UPDATE); + updateFaceListeningState(BIOMETRIC_ACTION_STOP); + } else { + updateBiometricListeningState(BIOMETRIC_ACTION_UPDATE); + } } private void handleUserInfoChanged(int userId) { @@ -2477,9 +2484,11 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab boolean strongAuthAllowsScanning = (!isEncryptedOrTimedOut || canBypass && !mBouncerFullyShown); - // If the device supports face detection (without authentication), allow it to happen - // if the device is in lockdown mode. Otherwise, prevent scanning. + // If the device supports face detection (without authentication) and bypass is enabled, + // allow face scanning to happen if the device is in lockdown mode. + // Otherwise, prevent scanning. final boolean supportsDetectOnly = !mFaceSensorProperties.isEmpty() + && canBypass && mFaceSensorProperties.get(0).supportsFaceDetection; if (isLockDown && !supportsDetectOnly) { strongAuthAllowsScanning = false; @@ -2494,8 +2503,11 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab // 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 = - (mBouncerFullyShown || mAuthInterruptActive || mOccludingAppRequestingFace - || awakeKeyguard || shouldListenForFaceAssistant + (mBouncerFullyShown && !mGoingToSleep + || mAuthInterruptActive + || mOccludingAppRequestingFace + || awakeKeyguard + || shouldListenForFaceAssistant || mAuthController.isUdfpsFingerDown()) && !mSwitchingUser && !faceDisabledForUser && becauseCannotSkipBouncer && !mKeyguardGoingAway && biometricEnabledForUser && !mLockIconPressed @@ -2517,6 +2529,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab mBouncerFullyShown, faceAuthenticated, faceDisabledForUser, + mGoingToSleep, awakeKeyguard, mKeyguardGoingAway, shouldListenForFaceAssistant, diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardListenQueueTest.kt b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardListenQueueTest.kt index 4cca38a6e5a8a..cc606de1b0b9f 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardListenQueueTest.kt +++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardListenQueueTest.kt @@ -88,6 +88,7 @@ private fun faceModel(user: Int) = KeyguardFaceListenModel( bouncerFullyShown = false, faceAuthenticated = false, faceDisabled = false, + goingToSleep = false, keyguardAwake = false, keyguardGoingAway = false, listeningForFaceAssistant = false,