From 576811e3b58edb3794f16b99cc7b2331451f935e Mon Sep 17 00:00:00 2001 From: Kevin Chyn Date: Wed, 12 Jun 2019 14:50:35 -0700 Subject: [PATCH] Decrease amount of getAuthenticatorId invocations to the HAL The HIDL contract is to update the authenticatorID when a new template is enrolled. Thus, only update the authenticatorId cache when 1) the user is actually switching, which is infrequent 2) a user has enrolled a new biometric Fixes: 133578311 Test: Authenticator ID is updated when new enrollment occurs Change-Id: If79cb43ac1f42676995c955203653cb5fae0f10f --- .../server/biometrics/BiometricServiceBase.java | 2 -- .../server/biometrics/face/FaceService.java | 16 ++++++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/services/core/java/com/android/server/biometrics/BiometricServiceBase.java b/services/core/java/com/android/server/biometrics/BiometricServiceBase.java index ed64cc7c1da69..0c4f0bd0edc6d 100644 --- a/services/core/java/com/android/server/biometrics/BiometricServiceBase.java +++ b/services/core/java/com/android/server/biometrics/BiometricServiceBase.java @@ -713,8 +713,6 @@ public abstract class BiometricServiceBase extends SystemService // already generated a new authenticator id when the new biometric is enrolled. if (identifier instanceof Fingerprint) { updateActiveGroup(((Fingerprint)identifier).getGroupId(), null); - } else { - updateActiveGroup(mCurrentUserId, null); } } } diff --git a/services/core/java/com/android/server/biometrics/face/FaceService.java b/services/core/java/com/android/server/biometrics/face/FaceService.java index 0f2b16a3e6ee5..d172fbc4c00d5 100644 --- a/services/core/java/com/android/server/biometrics/face/FaceService.java +++ b/services/core/java/com/android/server/biometrics/face/FaceService.java @@ -707,6 +707,18 @@ public class FaceService extends BiometricServiceBase { final Face face = new Face(getBiometricUtils() .getUniqueName(getContext(), userId), faceId, deviceId); FaceService.super.handleEnrollResult(face, remaining); + + // Enrollment changes the authenticatorId, so update it here. + IBiometricsFace daemon = getFaceDaemon(); + if (remaining == 0 && daemon != null) { + try { + mAuthenticatorIds.put(userId, + hasEnrolledBiometrics(userId) ? daemon.getAuthenticatorId().value + : 0L); + } catch (RemoteException e) { + Slog.e(TAG, "Unable to get authenticatorId", e); + } + } }); } @@ -968,9 +980,9 @@ public class FaceService extends BiometricServiceBase { daemon.setActiveUser(userId, faceDir.getAbsolutePath()); mCurrentUserId = userId; + mAuthenticatorIds.put(userId, + hasEnrolledBiometrics(userId) ? daemon.getAuthenticatorId().value : 0L); } - mAuthenticatorIds.put(userId, - hasEnrolledBiometrics(userId) ? daemon.getAuthenticatorId().value : 0L); } catch (RemoteException e) { Slog.e(TAG, "Failed to setActiveUser():", e); }