diff options
author | Alex Klyubin <klyubin@google.com> | 2015-04-30 11:43:53 -0700 |
---|---|---|
committer | Alex Klyubin <klyubin@google.com> | 2015-04-30 12:43:05 -0700 |
commit | 2d7a85cd2b2ab4dbbe09354c6ae1668bff51a514 (patch) | |
tree | beedd6c7ebf8236c659f065462897448c4aca955 /keystore/java/android/security/KeyStore.java | |
parent | 24ea865f0fd3b1ceafb3786bbed20ea345bc5cc0 (diff) | |
download | frameworks_base-2d7a85cd2b2ab4dbbe09354c6ae1668bff51a514.zip frameworks_base-2d7a85cd2b2ab4dbbe09354c6ae1668bff51a514.tar.gz frameworks_base-2d7a85cd2b2ab4dbbe09354c6ae1668bff51a514.tar.bz2 |
Switch from FingerprintService to FingerprintManager.
FingerprintService is a lower layer of abstraction which should
ideally be accessed only via FingerprintManager from
AndroidKeyStore.
The main issue with the switch is that it requires a reference to a
Context. This is now obtained using ActivityThread's hidden API.
Change-Id: If921e169838ee2cc5c7690b8c8d8ea95c33248aa
Diffstat (limited to 'keystore/java/android/security/KeyStore.java')
-rw-r--r-- | keystore/java/android/security/KeyStore.java | 50 |
1 files changed, 24 insertions, 26 deletions
diff --git a/keystore/java/android/security/KeyStore.java b/keystore/java/android/security/KeyStore.java index 5b0e74a..82d328b 100644 --- a/keystore/java/android/security/KeyStore.java +++ b/keystore/java/android/security/KeyStore.java @@ -21,7 +21,7 @@ import android.app.Application; import com.android.org.conscrypt.NativeConstants; import android.content.Context; -import android.hardware.fingerprint.IFingerprintService; +import android.hardware.fingerprint.FingerprintManager; import android.os.Binder; import android.os.IBinder; import android.os.RemoteException; @@ -79,11 +79,27 @@ public class KeyStore { private int mError = NO_ERROR; private final IKeystoreService mBinder; + private final Context mContext; private IBinder mToken; private KeyStore(IKeystoreService binder) { mBinder = binder; + mContext = getContext(); + } + + private static Context getContext() { + ActivityThread activityThread = ActivityThread.currentActivityThread(); + if (activityThread == null) { + throw new IllegalStateException( + "Failed to obtain application Context: no ActivityThread"); + } + Application application = activityThread.getApplication(); + if (application == null) { + throw new IllegalStateException( + "Failed to obtain application Context: no Application"); + } + return application; } public static KeyStore getInstance() { @@ -620,36 +636,18 @@ public class KeyStore { } } - private static long getFingerprintOnlySid() { - IFingerprintService service = IFingerprintService.Stub.asInterface( - ServiceManager.getService(Context.FINGERPRINT_SERVICE)); - if (service == null) { + private long getFingerprintOnlySid() { + FingerprintManager fingerprintManager = + mContext.getSystemService(FingerprintManager.class); + if (fingerprintManager == null) { return 0; } - String opPackageName = getMyOpPackageName(); - - try { - long deviceId = 0; // TODO: plumb hardware id to FPMS - if (!service.isHardwareDetected(deviceId, opPackageName)) { - return 0; - } - - return service.getAuthenticatorId(opPackageName); - } catch (RemoteException e) { - throw new IllegalStateException("Failed to communicate with fingerprint service", e); + if (!fingerprintManager.isHardwareDetected()) { + return 0; } - } - private static String getMyOpPackageName() { - ActivityThread activityThread = ActivityThread.currentActivityThread(); - if (activityThread != null) { - Application application = activityThread.getApplication(); - if (application != null) { - return application.getOpPackageName(); - } - } - throw new IllegalStateException("Cannot create AudioRecord outside of an app"); + return fingerprintManager.getAuthenticatorId(); } /** |