From e0507bbbf95ae6d958c900f32122baf078d47d71 Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Wed, 12 Aug 2015 20:30:34 -0700 Subject: [PATCH] Reset fingerprint lockout timer when strong auth is used. Fixes bug 22565462 Change-Id: I4842877839845e7fe103396d8ca8104928568c04 --- .../fingerprint/FingerprintManager.java | 20 +++++++++++++++++++ .../fingerprint/IFingerprintService.aidl | 3 +++ core/res/AndroidManifest.xml | 4 ++++ .../keyguard/KeyguardUpdateMonitor.java | 4 ++++ packages/SystemUI/AndroidManifest.xml | 1 + .../fingerprint/FingerprintService.java | 10 ++++++++++ 6 files changed, 42 insertions(+) diff --git a/core/java/android/hardware/fingerprint/FingerprintManager.java b/core/java/android/hardware/fingerprint/FingerprintManager.java index ee37047044256..061fad96ed252 100644 --- a/core/java/android/hardware/fingerprint/FingerprintManager.java +++ b/core/java/android/hardware/fingerprint/FingerprintManager.java @@ -668,6 +668,25 @@ public class FingerprintManager { return 0; } + /** + * Reset the lockout timer when asked to do so by keyguard. + * + * @param token an opaque token returned by password confirmation. + * + * @hide + */ + public void resetTimeout(byte[] token) { + if (mService != null) { + try { + mService.resetTimeout(token); + } catch (RemoteException e) { + Log.v(TAG, "Remote exception in getAuthenticatorId(): ", e); + } + } else { + Log.w(TAG, "getAuthenticatorId(): Service not connected!"); + } + } + private class MyHandler extends Handler { private MyHandler(Context context) { super(context.getMainLooper()); @@ -677,6 +696,7 @@ public class FingerprintManager { super(looper); } + @Override public void handleMessage(android.os.Message msg) { switch(msg.what) { case MSG_ENROLL_RESULT: diff --git a/core/java/android/hardware/fingerprint/IFingerprintService.aidl b/core/java/android/hardware/fingerprint/IFingerprintService.aidl index 5e233b87343eb..33563549b2ba7 100644 --- a/core/java/android/hardware/fingerprint/IFingerprintService.aidl +++ b/core/java/android/hardware/fingerprint/IFingerprintService.aidl @@ -68,4 +68,7 @@ interface IFingerprintService { // Gets the authenticator ID for fingerprint long getAuthenticatorId(String opPackageName); + + // Reset the timeout when user authenticates with strong auth (e.g. PIN, pattern or password) + void resetTimeout(in byte [] cryptoToken); } diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index 629d14b341c30..58f2d476ec6ba 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -2465,6 +2465,10 @@ + + + + diff --git a/services/core/java/com/android/server/fingerprint/FingerprintService.java b/services/core/java/com/android/server/fingerprint/FingerprintService.java index 17607ff1ce8c8..befa3116bc8c9 100644 --- a/services/core/java/com/android/server/fingerprint/FingerprintService.java +++ b/services/core/java/com/android/server/fingerprint/FingerprintService.java @@ -54,6 +54,7 @@ import android.hardware.fingerprint.IFingerprintServiceReceiver; import android.view.Display; import static android.Manifest.permission.MANAGE_FINGERPRINT; +import static android.Manifest.permission.RESET_FINGERPRINT_LOCKOUT; import static android.Manifest.permission.USE_FINGERPRINT; import java.io.File; @@ -255,6 +256,9 @@ public class FingerprintService extends SystemService implements IBinder.DeathRe Slog.v(TAG, "Reset fingerprint lockout"); } mFailedAttempts = 0; + // If we're asked to reset failed attempts externally (i.e. from Keyguard), the runnable + // may still be in the queue; remove it. + mHandler.removeCallbacks(mLockoutReset); } private boolean handleFailedAttempt(ClientMonitor clientMonitor) { @@ -878,6 +882,12 @@ public class FingerprintService extends SystemService implements IBinder.DeathRe Binder.restoreCallingIdentity(ident); } } + @Override // Binder call + public void resetTimeout(byte [] token) { + checkPermission(RESET_FINGERPRINT_LOCKOUT); + // TODO: confirm security token when we move timeout management into the HAL layer. + mLockoutReset.run(); + } } private void dumpInternal(PrintWriter pw) {