diff options
author | Haining Chen <hainingc@google.com> | 2023-02-03 15:19:44 -0800 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-02-11 16:13:49 +0000 |
commit | e99efc074e3092efceee3523a9a34a2f1b574793 (patch) | |
tree | fb2f26c31e790704f0e519620844fc39dbb1c782 | |
parent | e74f0df1481ec152b90045f34ad33691f53a91e6 (diff) | |
download | base-e99efc074e3092efceee3523a9a34a2f1b574793.tar.gz |
Schedule idle timeout when Keyguard state is reset and only if possible
The 4-hour idle timeout is scheduled when the device is locked (by
manually pressing the power button or after the screen timeout). This
usually happends when Keyguard decides to show up.
In the face non-bypass case, Keyguard is already shown and its state
will be reset after locking device. The idle timeout should also be
scheduled in this case.
Additionally, check if any non-strong biometrics are enrolled and
enabled. If not, do not schedule the idle timeout when the device is
locked.
Bug: 244743493, 261813434
Test: On a device with UDFPS, manually
(1) set up face auth, (2) unlock with face auth and stay on
Keyguard, (3) lock device, and verify that the alarm for idle
timeout is scheduled properly by "adb shell dumpsys alarm"
Test: On a device with side FPS, manually
(1) set up fingerprint (no face auth), (2) lock device, and verify
that no alarm is schedule for idle timeout, (3) swipe up to show
bouncer, and verify that the string on bouncer properly shows
"Enter your PIN" while side FPS can also be used for auth.
Repeat steps 2-3 after enabling face auth and then deleting it.
Change-Id: I8404927e8155f40496ac1740e4a6b7b38458f1f5
(cherry picked from commit f766281fafc48ce68dcd657c98cb39e33ef425c4)
Merged-In: I8404927e8155f40496ac1740e4a6b7b38458f1f5
-rw-r--r-- | packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java | 18 | ||||
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java | 25 |
2 files changed, 38 insertions, 5 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java index 93027c1914ee..7ae61cd8e2ab 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java @@ -94,6 +94,7 @@ import android.hardware.biometrics.BiometricFingerprintConstants; import android.hardware.biometrics.BiometricManager; import android.hardware.biometrics.BiometricSourceType; import android.hardware.biometrics.IBiometricEnabledOnKeyguardCallback; +import android.hardware.biometrics.SensorProperties; import android.hardware.face.FaceManager; import android.hardware.face.FaceSensorPropertiesInternal; import android.hardware.fingerprint.FingerprintManager; @@ -2963,6 +2964,23 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab return isUnlockWithFacePossible(userId) || isUnlockWithFingerprintPossible(userId); } + /** + * If non-strong (i.e. weak or convenience) biometrics hardware is available, not disabled, and + * user has enrolled templates. This does NOT check if the device is encrypted or in lockdown. + * + * @param userId User that's trying to unlock. + * @return {@code true} if possible. + */ + public boolean isUnlockingWithNonStrongBiometricsPossible(int userId) { + // This assumes that there is at most one face and at most one fingerprint sensor + return (mFaceManager != null && !mFaceSensorProperties.isEmpty() + && (mFaceSensorProperties.get(0).sensorStrength != SensorProperties.STRENGTH_STRONG) + && isUnlockWithFacePossible(userId)) + || (mFpm != null && !mFingerprintSensorProperties.isEmpty() + && (mFingerprintSensorProperties.get(0).sensorStrength + != SensorProperties.STRENGTH_STRONG) && isUnlockWithFingerprintPossible(userId)); + } + @SuppressLint("MissingPermission") @VisibleForTesting boolean isUnlockWithFingerprintPossible(int userId) { diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java index e0def25fd8d3..1b0356141432 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java @@ -2418,15 +2418,28 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, } mKeyguardDisplayManager.show(); - // schedule 4hr idle timeout after which non-strong biometrics (i.e. weak or convenience - // biometric) can't be used to unlock device until unlocking with strong biometric or - // primary auth (i.e. PIN/pattern/password) - mLockPatternUtils.scheduleNonStrongBiometricIdleTimeout( - KeyguardUpdateMonitor.getCurrentUser()); + scheduleNonStrongBiometricIdleTimeout(); Trace.endSection(); } + /** + * Schedule 4-hour idle timeout for non-strong biometrics when the device is locked + */ + private void scheduleNonStrongBiometricIdleTimeout() { + final int currentUser = KeyguardUpdateMonitor.getCurrentUser(); + // If unlocking with non-strong (i.e. weak or convenience) biometrics is possible, schedule + // 4hr idle timeout after which non-strong biometrics can't be used to unlock device until + // unlocking with strong biometric or primary auth (i.e. PIN/pattern/password) + if (mUpdateMonitor.isUnlockingWithNonStrongBiometricsPossible(currentUser)) { + if (DEBUG) { + Log.d(TAG, "scheduleNonStrongBiometricIdleTimeout: schedule an alarm for " + + "currentUser=" + currentUser); + } + mLockPatternUtils.scheduleNonStrongBiometricIdleTimeout(currentUser); + } + } + private final Runnable mKeyguardGoingAwayRunnable = new Runnable() { @Override public void run() { @@ -2920,6 +2933,8 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, if (DEBUG) Log.d(TAG, "handleReset"); mKeyguardViewControllerLazy.get().reset(true /* hideBouncerWhenShowing */); } + + scheduleNonStrongBiometricIdleTimeout(); } /** |