Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 576811e3 authored by Kevin Chyn's avatar Kevin Chyn
Browse files

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
parent 01462c0b
Loading
Loading
Loading
Loading
+0 −2
Original line number Original line Diff line number Diff line
@@ -713,8 +713,6 @@ public abstract class BiometricServiceBase extends SystemService
            // already generated a new authenticator id when the new biometric is enrolled.
            // already generated a new authenticator id when the new biometric is enrolled.
            if (identifier instanceof Fingerprint) {
            if (identifier instanceof Fingerprint) {
                updateActiveGroup(((Fingerprint)identifier).getGroupId(), null);
                updateActiveGroup(((Fingerprint)identifier).getGroupId(), null);
            } else {
                updateActiveGroup(mCurrentUserId, null);
            }
            }
        }
        }
    }
    }
+14 −2
Original line number Original line Diff line number Diff line
@@ -707,6 +707,18 @@ public class FaceService extends BiometricServiceBase {
                final Face face = new Face(getBiometricUtils()
                final Face face = new Face(getBiometricUtils()
                        .getUniqueName(getContext(), userId), faceId, deviceId);
                        .getUniqueName(getContext(), userId), faceId, deviceId);
                FaceService.super.handleEnrollResult(face, remaining);
                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());
                    daemon.setActiveUser(userId, faceDir.getAbsolutePath());
                    mCurrentUserId = userId;
                    mCurrentUserId = userId;
                }
                    mAuthenticatorIds.put(userId,
                    mAuthenticatorIds.put(userId,
                            hasEnrolledBiometrics(userId) ? daemon.getAuthenticatorId().value : 0L);
                            hasEnrolledBiometrics(userId) ? daemon.getAuthenticatorId().value : 0L);
                }
            } catch (RemoteException e) {
            } catch (RemoteException e) {
                Slog.e(TAG, "Failed to setActiveUser():", e);
                Slog.e(TAG, "Failed to setActiveUser():", e);
            }
            }