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

Commit d34ba0bb authored by Curtis Belmonte's avatar Curtis Belmonte Committed by android-build-merger
Browse files

Merge "Use separate enroll timeout for fingerprint and face" into qt-r1-dev

am: c2f168ec

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


        @Override
        @Override
+5 −5
Original line number Original line 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.
 * A class to keep track of the enrollment state for a given client.
 */
 */
public abstract class EnrollClient extends ClientMonitor {
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 byte[] mCryptoToken;
    private final BiometricUtils mBiometricUtils;
    private final BiometricUtils mBiometricUtils;
    private final int[] mDisabledFeatures;
    private final int[] mDisabledFeatures;
    private final int mTimeoutSec;

    private long mEnrollmentStartTimeMs;
    private long mEnrollmentStartTimeMs;


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


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


            final int result = getDaemonWrapper().enroll(mCryptoToken, getGroupId(), timeout,
            final int result = getDaemonWrapper().enroll(mCryptoToken, getGroupId(), mTimeoutSec,
                    disabledFeatures);
                    disabledFeatures);
            if (result != 0) {
            if (result != 0) {
                Slog.w(getLogTag(), "startEnroll failed, result=" + result);
                Slog.w(getLogTag(), "startEnroll failed, result=" + result);
+3 −1
Original line number Original line Diff line number Diff line
@@ -329,6 +329,7 @@ public class FaceService extends BiometricServiceBase {
     * Receives the incoming binder calls from FaceManager.
     * Receives the incoming binder calls from FaceManager.
     */
     */
    private final class FaceServiceWrapper extends IFaceService.Stub {
    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.
         * 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 boolean restricted = isRestricted();
            final EnrollClientImpl client = new EnrollClientImpl(getContext(), mDaemonWrapper,
            final EnrollClientImpl client = new EnrollClientImpl(getContext(), mDaemonWrapper,
                    mHalDeviceId, token, new ServiceListenerImpl(receiver), mCurrentUserId,
                    mHalDeviceId, token, new ServiceListenerImpl(receiver), mCurrentUserId,
                    0 /* groupId */, cryptoToken, restricted, opPackageName, disabledFeatures) {
                    0 /* groupId */, cryptoToken, restricted, opPackageName, disabledFeatures,
                    ENROLL_TIMEOUT_SEC) {


                @Override
                @Override
                public int[] getAcquireIgnorelist() {
                public int[] getAcquireIgnorelist() {
+3 −1
Original line number Original line Diff line number Diff line
@@ -176,6 +176,7 @@ public class FingerprintService extends BiometricServiceBase {
     * Receives the incoming binder calls from FingerprintManager.
     * Receives the incoming binder calls from FingerprintManager.
     */
     */
    private final class FingerprintServiceWrapper extends IFingerprintService.Stub {
    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.
         * 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 int groupId = userId; // default group for fingerprint enrollment
            final EnrollClientImpl client = new EnrollClientImpl(getContext(), mDaemonWrapper,
            final EnrollClientImpl client = new EnrollClientImpl(getContext(), mDaemonWrapper,
                    mHalDeviceId, token, new ServiceListenerImpl(receiver), mCurrentUserId, groupId,
                    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
                @Override
                public boolean shouldVibrate() {
                public boolean shouldVibrate() {
                    return true;
                    return true;