Add setting to customize fingerprint unlock behavior
This contains a squashed fixup commit:
指纹识别间隔时间延长至1s
Change-Id: I4a82d685edec3b156b97f097741971ca94595d74
(cherry picked from commit 1b9845f33c1004e1df0099795368096e14a44561)
Issue: FP4-2666
Issue: FP4-INT#13
Change-Id: Id5406c18ffe4f27e010a021d23b4d2f60efbc210
(cherry picked from commit c9ff0c836f6faad3c777fdc6f5569597a9d8b784)
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
index 0c087c2..1304c96 100755
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
@@ -64,6 +64,7 @@
import android.os.IRemoteCallback;
import android.os.Looper;
import android.os.Message;
+import android.os.PowerManager;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.Trace;
@@ -146,6 +147,8 @@
private static final String ACTION_FACE_UNLOCK_STOPPED
= "com.android.facelock.FACE_UNLOCK_STOPPED";
+ public static final String KEY_FINGERPRINT_UNLOCK_NEEDS_POWER_PRESS = "fingerprint_settings";
+
// Callback messages
private static final int MSG_TIME_UPDATE = 301;
private static final int MSG_BATTERY_UPDATE = 302;
@@ -291,12 +294,12 @@
* be slightly longer than the time between onFingerprintAuthenticated and
* setKeyguardGoingAway(true).
*/
- private static final int FINGERPRINT_CONTINUE_DELAY_MS = 500;
+ private static final int FINGERPRINT_CONTINUE_DELAY_MS = 1000;
// If the HAL dies or is unable to authenticate, keyguard should retry after a short delay
private int mHardwareFingerprintUnavailableRetryCount = 0;
private int mHardwareFaceUnavailableRetryCount = 0;
- private static final int HAL_ERROR_RETRY_TIMEOUT = 500; // ms
+ private static final int HAL_ERROR_RETRY_TIMEOUT = 1000; // ms
private static final int HAL_ERROR_RETRY_MAX = 10;
private final Runnable mCancelNotReceived = new Runnable() {
@@ -1846,9 +1849,18 @@
updateFaceListeningState();
}
+ private boolean getFingerprintUnlockNeedsPowerPress() {
+ return Settings.Global.getInt(
+ mContext.getContentResolver(),
+ KEY_FINGERPRINT_UNLOCK_NEEDS_POWER_PRESS,
+ false ? 1 : 0)
+ == 1;
+ }
+
private void updateFingerprintListeningState() {
// If this message exists, we should not authenticate again until this message is
// consumed by the handler
+ PowerManager mPm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
if (mHandler.hasMessages(MSG_BIOMETRIC_AUTHENTICATION_CONTINUE)) {
return;
}
@@ -1856,10 +1868,20 @@
boolean shouldListenForFingerprint = shouldListenForFingerprint();
boolean runningOrRestarting = mFingerprintRunningState == BIOMETRIC_STATE_RUNNING
|| mFingerprintRunningState == BIOMETRIC_STATE_CANCELLING_RESTARTING;
- if (runningOrRestarting && !shouldListenForFingerprint) {
- stopListeningForFingerprint();
- } else if (!runningOrRestarting && shouldListenForFingerprint) {
- startListeningForFingerprint();
+
+ boolean unlock_needs_power_press = getFingerprintUnlockNeedsPowerPress();
+ if (!unlock_needs_power_press) {
+ if (runningOrRestarting && !shouldListenForFingerprint) {
+ stopListeningForFingerprint();
+ } else if (!runningOrRestarting && shouldListenForFingerprint) {
+ startListeningForFingerprint();
+ }
+ } else {
+ if (!mPm.isScreenOn() || (runningOrRestarting && !shouldListenForFingerprint)) {
+ stopListeningForFingerprint();
+ } else if (!runningOrRestarting && shouldListenForFingerprint) {
+ startListeningForFingerprint();
+ }
}
}