summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Kevin Chyn <kchyn@google.com> 2018-11-09 04:42:35 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2018-11-09 04:42:35 +0000
commita85b4a2d29c6770de65529ecf95cb6ca90fa7a0b (patch)
tree7e1893c7b6b10be6ea834c01434097c5c05e1f39
parentc578d38eb752c9ab3edaada6c4bd53900425f184 (diff)
parente739daf2e844dafa34110dce13008499d3e10aeb (diff)
Merge "Return correct error when HW there is no biometric hardware"
-rw-r--r--core/java/android/app/SystemServiceRegistry.java16
-rw-r--r--core/java/android/hardware/biometrics/BiometricManager.java24
-rw-r--r--services/java/com/android/server/SystemServer.java2
3 files changed, 34 insertions, 8 deletions
diff --git a/core/java/android/app/SystemServiceRegistry.java b/core/java/android/app/SystemServiceRegistry.java
index e95f9abed908..713f752fc45b 100644
--- a/core/java/android/app/SystemServiceRegistry.java
+++ b/core/java/android/app/SystemServiceRegistry.java
@@ -857,11 +857,17 @@ final class SystemServiceRegistry {
@Override
public BiometricManager createService(ContextImpl ctx)
throws ServiceNotFoundException {
- final IBinder binder =
- ServiceManager.getServiceOrThrow(Context.BIOMETRIC_SERVICE);
- final IBiometricService service =
- IBiometricService.Stub.asInterface(binder);
- return new BiometricManager(ctx.getOuterContext(), service);
+ if (BiometricManager.hasBiometrics(ctx)) {
+ final IBinder binder =
+ ServiceManager.getServiceOrThrow(Context.BIOMETRIC_SERVICE);
+ final IBiometricService service =
+ IBiometricService.Stub.asInterface(binder);
+ return new BiometricManager(ctx.getOuterContext(), service);
+ } else {
+ // Allow access to the manager when service is null. This saves memory
+ // on devices without biometric hardware.
+ return new BiometricManager(ctx.getOuterContext(), null);
+ }
}
});
diff --git a/core/java/android/hardware/biometrics/BiometricManager.java b/core/java/android/hardware/biometrics/BiometricManager.java
index fe006045bf0f..ff58c7525a3a 100644
--- a/core/java/android/hardware/biometrics/BiometricManager.java
+++ b/core/java/android/hardware/biometrics/BiometricManager.java
@@ -22,6 +22,7 @@ import static android.Manifest.permission.USE_BIOMETRIC_INTERNAL;
import android.annotation.IntDef;
import android.annotation.RequiresPermission;
import android.content.Context;
+import android.content.pm.PackageManager;
import android.os.RemoteException;
import android.util.Slog;
@@ -64,6 +65,19 @@ public class BiometricManager {
private final Context mContext;
private final IBiometricService mService;
+ private final boolean mHasHardware;
+
+ /**
+ * @param context
+ * @return
+ * @hide
+ */
+ public static boolean hasBiometrics(Context context) {
+ final PackageManager pm = context.getPackageManager();
+ return pm.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)
+ || pm.hasSystemFeature(PackageManager.FEATURE_IRIS)
+ || pm.hasSystemFeature(PackageManager.FEATURE_FACE);
+ }
/**
* @hide
@@ -73,6 +87,8 @@ public class BiometricManager {
public BiometricManager(Context context, IBiometricService service) {
mContext = context;
mService = service;
+
+ mHasHardware = hasBiometrics(context);
}
/**
@@ -93,8 +109,12 @@ public class BiometricManager {
throw e.rethrowFromSystemServer();
}
} else {
- Slog.w(TAG, "hasEnrolledBiometrics(): Service not connected");
- return BIOMETRIC_ERROR_UNAVAILABLE;
+ if (!mHasHardware) {
+ return BIOMETRIC_ERROR_NO_HARDWARE;
+ } else {
+ Slog.w(TAG, "hasEnrolledBiometrics(): Service not connected");
+ return BIOMETRIC_ERROR_UNAVAILABLE;
+ }
}
}
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index e364e9a1d876..933eac682b54 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -1627,7 +1627,7 @@ public final class SystemServer {
if (hasFeatureFace || hasFeatureIris || hasFeatureFingerprint) {
// Start this service after all biometric services.
- traceBeginAndSlog("StartBiometricPromptService");
+ traceBeginAndSlog("StartBiometricService");
mSystemServiceManager.startService(BiometricService.class);
traceEnd();
}