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

Commit 099b44a9 authored by Kevin Chyn's avatar Kevin Chyn
Browse files

29/n: Fix EnrollClient onClientFinished

EnrollClient was not updated to use the FinishCallback properly.
This CL fixes that.

Bug: 157790417

Test: Enroll on fingerprint/face device. Notice authenticatorId is
      updated.
Change-Id: Iba47ac2803c1281e4424316900b1c47c8c91bc54
parent dc5a7985
Loading
Loading
Loading
Loading
+6 −9
Original line number Diff line number Diff line
@@ -105,6 +105,11 @@ public abstract class BiometricServiceBase<T> extends SystemService
    protected final ClientMonitor.FinishCallback mClientFinishCallback =
            (clientMonitor, success) -> {
        removeClient(clientMonitor);
        // When enrollment finishes, update this group's authenticator id, as the HAL has
        // already generated a new authenticator id when the new biometric is enrolled.
        if (clientMonitor instanceof EnrollClient) {
            updateActiveGroup(clientMonitor.getTargetUserId());
        }
    };

    private IBiometricService mBiometricService;
@@ -373,15 +378,7 @@ public abstract class BiometricServiceBase<T> extends SystemService
        }

        final EnrollClient enrollClient = (EnrollClient) client;

        if (enrollClient.onEnrollResult(identifier, remaining)) {
            removeClient(enrollClient);
            // When enrollment finishes, update this group's authenticator id, as the HAL has
            // already generated a new authenticator id when the new biometric is enrolled.
            if (identifier instanceof Fingerprint) {
                updateActiveGroup(((Fingerprint)identifier).getGroupId());
            }
        }
        enrollClient.onEnrollResult(identifier, remaining);
    }

    protected void handleError(int error, int vendorCode) {
+11 −20
Original line number Diff line number Diff line
@@ -55,36 +55,27 @@ public abstract class EnrollClient<T> extends AcquisitionClient<T> {
        mShouldVibrate = shouldVibrate;
    }

    public boolean onEnrollResult(BiometricAuthenticator.Identifier identifier,
            int remaining) {
        if (remaining == 0) {
            mBiometricUtils.addBiometricForUser(getContext(), getTargetUserId(), identifier);
            logOnEnrolled(getTargetUserId(),
                    System.currentTimeMillis() - mEnrollmentStartTimeMs,
                    true /* enrollSuccessful */);
        }
        notifyUserActivity();
        return sendEnrollResult(identifier, remaining);
    }

    /*
     * @return true if we're done.
     */
    private boolean sendEnrollResult(BiometricAuthenticator.Identifier identifier, int remaining) {
    public void onEnrollResult(BiometricAuthenticator.Identifier identifier, int remaining) {
        if (mShouldVibrate) {
            vibrateSuccess();
        }

        try {
        final ClientMonitorCallbackConverter listener = getListener();
        try {
            if (listener != null) {
                listener.onEnrollResult(identifier, remaining);
            }
            return remaining == 0;
        } catch (RemoteException e) {
            Slog.w(TAG, "Failed to notify EnrollResult:", e);
            return true;
            Slog.e(TAG, "Remote exception", e);
        }

        if (remaining == 0) {
            mBiometricUtils.addBiometricForUser(getContext(), getTargetUserId(), identifier);
            logOnEnrolled(getTargetUserId(), System.currentTimeMillis() - mEnrollmentStartTimeMs,
                    true /* enrollSuccessful */);
            mFinishCallback.onClientFinished(this, true /* success */);
        }
        notifyUserActivity();
    }

    @Override