summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Kevin Chyn <kchyn@google.com> 2019-04-20 02:26:16 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2019-04-20 02:26:16 +0000
commit5e052537b74d2e399bbe23e0289f0d5f8d3f2fcc (patch)
tree9e5cc1f7ddf05d52f89ead36a3a9810c5b068a0c
parentdd0b1d9bd88fde74ab000fac033fecc84a9d58a9 (diff)
parent1e50792d72208e823fe1cfdb39e0a25965029228 (diff)
Merge "Check PackageManager for feature before getting system service" into qt-dev
-rw-r--r--keystore/java/android/security/keystore/KeymasterUtils.java17
1 files changed, 13 insertions, 4 deletions
diff --git a/keystore/java/android/security/keystore/KeymasterUtils.java b/keystore/java/android/security/keystore/KeymasterUtils.java
index 52896b59ddaf..79e48cdfdd8e 100644
--- a/keystore/java/android/security/keystore/KeymasterUtils.java
+++ b/keystore/java/android/security/keystore/KeymasterUtils.java
@@ -16,6 +16,7 @@
package android.security.keystore;
+import android.content.pm.PackageManager;
import android.hardware.face.FaceManager;
import android.hardware.fingerprint.FingerprintManager;
import android.security.GateKeeper;
@@ -122,12 +123,20 @@ public abstract class KeymasterUtils {
}
if (spec.getUserAuthenticationValidityDurationSeconds() == -1) {
+ PackageManager pm = KeyStore.getApplicationContext().getPackageManager();
// Every use of this key needs to be authorized by the user. This currently means
// fingerprint or face auth.
- FingerprintManager fingerprintManager =
- KeyStore.getApplicationContext().getSystemService(FingerprintManager.class);
- FaceManager faceManager =
- KeyStore.getApplicationContext().getSystemService(FaceManager.class);
+ FingerprintManager fingerprintManager = null;
+ FaceManager faceManager = null;
+
+ if (pm.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)) {
+ fingerprintManager = KeyStore.getApplicationContext()
+ .getSystemService(FingerprintManager.class);
+ }
+ if (pm.hasSystemFeature(PackageManager.FEATURE_FACE)) {
+ faceManager = KeyStore.getApplicationContext().getSystemService(FaceManager.class);
+ }
+
// TODO: Restore USE_FINGERPRINT permission check in
// FingerprintManager.getAuthenticatorId once the ID is no longer needed here.
final long fingerprintOnlySid =