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

Commit a7808c36 authored by Kevin Chyn's avatar Kevin Chyn
Browse files

Add maxTemplatesAllowed to Fingerprint/Face SensorProperties

Bug: 152242790
Bug: 162341940

Test: On fingerprint/face devices, enroll max number, notice
      enrollment shows the "max enrolled" string and prevents the
      user from enrolling additional templates.
Change-Id: I50c3b5810b0868d2ba9f1e923318585302b5776d
parent 9ed149dd
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -40,21 +40,27 @@ public class FaceSensorProperties implements Parcelable {
     * from above the HAL.
     */
    public final boolean supportsSelfIllumination;
    /**
     * Maximum number of enrollments a user/profile can have.
     */
    public final int maxTemplatesAllowed;

    /**
     * Initializes SensorProperties with specified values
     */
    public FaceSensorProperties(int sensorId, boolean supportsFaceDetection,
            boolean supportsSelfIllumination) {
            boolean supportsSelfIllumination, int maxTemplatesAllowed) {
        this.sensorId = sensorId;
        this.supportsFaceDetection = supportsFaceDetection;
        this.supportsSelfIllumination = supportsSelfIllumination;
        this.maxTemplatesAllowed = maxTemplatesAllowed;
    }

    protected FaceSensorProperties(Parcel in) {
        sensorId = in.readInt();
        supportsFaceDetection = in.readBoolean();
        supportsSelfIllumination = in.readBoolean();
        maxTemplatesAllowed = in.readInt();
    }

    public static final Creator<FaceSensorProperties> CREATOR =
@@ -80,5 +86,6 @@ public class FaceSensorProperties implements Parcelable {
        dest.writeInt(sensorId);
        dest.writeBoolean(supportsFaceDetection);
        dest.writeBoolean(supportsSelfIllumination);
        dest.writeInt(maxTemplatesAllowed);
    }
}
+6 −1
Original line number Diff line number Diff line
@@ -48,21 +48,25 @@ public class FingerprintSensorProperties implements Parcelable {
    // IBiometricsFingerprint@2.1 does not manage timeout below the HAL, so the Gatekeeper HAT
    // cannot be checked
    public final boolean resetLockoutRequiresHardwareAuthToken;
    // Maximum number of enrollments a user/profile can have.
    public final int maxTemplatesAllowed;

    /**
     * Initializes SensorProperties with specified values
     */
    public FingerprintSensorProperties(int sensorId, @SensorType int sensorType,
            boolean resetLockoutRequiresHardwareAuthToken) {
            boolean resetLockoutRequiresHardwareAuthToken, int maxTemplatesAllowed) {
        this.sensorId = sensorId;
        this.sensorType = sensorType;
        this.resetLockoutRequiresHardwareAuthToken = resetLockoutRequiresHardwareAuthToken;
        this.maxTemplatesAllowed = maxTemplatesAllowed;
    }

    protected FingerprintSensorProperties(Parcel in) {
        sensorId = in.readInt();
        sensorType = in.readInt();
        resetLockoutRequiresHardwareAuthToken = in.readBoolean();
        maxTemplatesAllowed = in.readInt();
    }

    public static final Creator<FingerprintSensorProperties> CREATOR =
@@ -88,5 +92,6 @@ public class FingerprintSensorProperties implements Parcelable {
        dest.writeInt(sensorId);
        dest.writeInt(sensorType);
        dest.writeBoolean(resetLockoutRequiresHardwareAuthToken);
        dest.writeInt(maxTemplatesAllowed);
    }
}
+2 −1
Original line number Diff line number Diff line
@@ -182,7 +182,8 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
        // IBiometricsFace@1.0 does not support detection, only authentication.
        when(mFaceSensorProperties.isEmpty()).thenReturn(false);
        when(mFaceSensorProperties.get(anyInt())).thenReturn(new FaceSensorProperties(0 /* id */,
                false /* supportsFaceDetection */, true /* supportsSelfIllumination */));
                false /* supportsFaceDetection */, true /* supportsSelfIllumination */,
                1 /* maxTemplatesAllowed */));

        when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
        when(mFingerprintManager.hasEnrolledTemplates(anyInt())).thenReturn(true);
+3 −1
Original line number Diff line number Diff line
@@ -277,8 +277,10 @@ class Face10 implements IHwBinder.DeathRecipient {
            @NonNull LockoutResetDispatcher lockoutResetDispatcher) {
        final boolean supportsSelfIllumination = context.getResources()
                .getBoolean(R.bool.config_faceAuthSupportsSelfIllumination);
        final int maxTemplatesAllowed = context.getResources()
                .getInteger(R.integer.config_faceMaxTemplatesPerUser);
        mFaceSensorProperties = new FaceSensorProperties(sensorId, false /* supportsFaceDetect */,
                supportsSelfIllumination);
                supportsSelfIllumination, maxTemplatesAllowed);
        mContext = context;
        mSensorId = sensorId;
        mScheduler = new BiometricScheduler(TAG, null /* gestureAvailabilityTracker */);
+4 −1
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ import android.util.Slog;
import android.util.proto.ProtoOutputStream;
import android.view.Surface;

import com.android.internal.R;
import com.android.internal.util.FrameworkStatsLog;
import com.android.server.biometrics.Utils;
import com.android.server.biometrics.fingerprint.FingerprintServiceDumpProto;
@@ -338,8 +339,10 @@ class Fingerprint21 implements IHwBinder.DeathRecipient {
                        : FingerprintSensorProperties.TYPE_REAR;
        // resetLockout is controlled by the framework, so hardwareAuthToken is not required
        final boolean resetLockoutRequiresHardwareAuthToken = false;
        final int maxTemplatesAllowed = mContext.getResources()
                .getInteger(R.integer.config_fingerprintMaxTemplatesPerUser);
        mSensorProperties = new FingerprintSensorProperties(sensorId, sensorType,
                resetLockoutRequiresHardwareAuthToken);
                resetLockoutRequiresHardwareAuthToken, maxTemplatesAllowed);
    }

    static Fingerprint21 newInstance(@NonNull Context context, int sensorId,
Loading