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

Commit 4578854a authored by Curtis Belmonte's avatar Curtis Belmonte
Browse files

Use separate enroll timeout for fingerprint and face

Currently, we use the same timeout for enrolling any biometric,
including fingerprint and face. This commit requires each type of
biometric to specify its own enrollment timeout and specifically changes
the timeout for face from 60 to 75 seconds.

Test: Multi-angle face enrollment w/ 1-24 buckets captured == 75 seconds
Test: Single-capture face enrollment == 75 seconds
Test: Fingerprint enrollment == 60 seconds

Bug: 137688980
Change-Id: I2735ed4647956c8a4cba573215b551a5c0be6955
parent d60190de
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -282,10 +282,10 @@ public abstract class BiometricServiceBase extends SystemService
        public EnrollClientImpl(Context context, DaemonWrapper daemon, long halDeviceId,
                IBinder token, ServiceListener listener, int userId, int groupId,
                byte[] cryptoToken, boolean restricted, String owner,
                final int[] disabledFeatures) {
                final int[] disabledFeatures, int timeoutSec) {
            super(context, getConstants(), daemon, halDeviceId, token, listener,
                    userId, groupId, cryptoToken, restricted, owner, getBiometricUtils(),
                    disabledFeatures);
                    disabledFeatures, timeoutSec);
        }

        @Override
+5 −5
Original line number Diff line number Diff line
@@ -31,11 +31,11 @@ import java.util.Arrays;
 * A class to keep track of the enrollment state for a given client.
 */
public abstract class EnrollClient extends ClientMonitor {
    private static final long MS_PER_SEC = 1000;
    private static final int ENROLLMENT_TIMEOUT_MS = 60 * 1000; // 1 minute
    private final byte[] mCryptoToken;
    private final BiometricUtils mBiometricUtils;
    private final int[] mDisabledFeatures;
    private final int mTimeoutSec;

    private long mEnrollmentStartTimeMs;

    public abstract boolean shouldVibrate();
@@ -44,12 +44,13 @@ public abstract class EnrollClient extends ClientMonitor {
            BiometricServiceBase.DaemonWrapper daemon, long halDeviceId, IBinder token,
            BiometricServiceBase.ServiceListener listener, int userId, int groupId,
            byte[] cryptoToken, boolean restricted, String owner, BiometricUtils utils,
            final int[] disabledFeatures) {
            final int[] disabledFeatures, int timeoutSec) {
        super(context, constants, daemon, halDeviceId, token, listener, userId, groupId, restricted,
                owner, 0 /* cookie */);
        mBiometricUtils = utils;
        mCryptoToken = Arrays.copyOf(cryptoToken, cryptoToken.length);
        mDisabledFeatures = Arrays.copyOf(disabledFeatures, disabledFeatures.length);
        mTimeoutSec = timeoutSec;
    }

    @Override
@@ -94,14 +95,13 @@ public abstract class EnrollClient extends ClientMonitor {
    @Override
    public int start() {
        mEnrollmentStartTimeMs = System.currentTimeMillis();
        final int timeout = (int) (ENROLLMENT_TIMEOUT_MS / MS_PER_SEC);
        try {
            final ArrayList<Integer> disabledFeatures = new ArrayList<>();
            for (int i = 0; i < mDisabledFeatures.length; i++) {
                disabledFeatures.add(mDisabledFeatures[i]);
            }

            final int result = getDaemonWrapper().enroll(mCryptoToken, getGroupId(), timeout,
            final int result = getDaemonWrapper().enroll(mCryptoToken, getGroupId(), mTimeoutSec,
                    disabledFeatures);
            if (result != 0) {
                Slog.w(getLogTag(), "startEnroll failed, result=" + result);
+3 −1
Original line number Diff line number Diff line
@@ -329,6 +329,7 @@ public class FaceService extends BiometricServiceBase {
     * Receives the incoming binder calls from FaceManager.
     */
    private final class FaceServiceWrapper extends IFaceService.Stub {
        private static final int ENROLL_TIMEOUT_SEC = 75;

        /**
         * The following methods contain common code which is shared in biometrics/common.
@@ -368,7 +369,8 @@ public class FaceService extends BiometricServiceBase {
            final boolean restricted = isRestricted();
            final EnrollClientImpl client = new EnrollClientImpl(getContext(), mDaemonWrapper,
                    mHalDeviceId, token, new ServiceListenerImpl(receiver), mCurrentUserId,
                    0 /* groupId */, cryptoToken, restricted, opPackageName, disabledFeatures) {
                    0 /* groupId */, cryptoToken, restricted, opPackageName, disabledFeatures,
                    ENROLL_TIMEOUT_SEC) {

                @Override
                public int[] getAcquireIgnorelist() {
+3 −1
Original line number Diff line number Diff line
@@ -176,6 +176,7 @@ public class FingerprintService extends BiometricServiceBase {
     * Receives the incoming binder calls from FingerprintManager.
     */
    private final class FingerprintServiceWrapper extends IFingerprintService.Stub {
        private static final int ENROLL_TIMEOUT_SEC = 60;

        /**
         * The following methods contain common code which is shared in biometrics/common.
@@ -203,7 +204,8 @@ public class FingerprintService extends BiometricServiceBase {
            final int groupId = userId; // default group for fingerprint enrollment
            final EnrollClientImpl client = new EnrollClientImpl(getContext(), mDaemonWrapper,
                    mHalDeviceId, token, new ServiceListenerImpl(receiver), mCurrentUserId, groupId,
                    cryptoToken, restricted, opPackageName, new int[0] /* disabledFeatures */) {
                    cryptoToken, restricted, opPackageName, new int[0] /* disabledFeatures */,
                    ENROLL_TIMEOUT_SEC) {
                @Override
                public boolean shouldVibrate() {
                    return true;