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

Commit 7545d237 authored by Kevin Chyn's avatar Kevin Chyn Committed by Android (Google) Code Review
Browse files

Merge "Match Framework and AIDL SensorProps"

parents 0e2927e7 c1ef4186
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -103,6 +103,7 @@ public class BiometricManager {
        @IntDef(flag = true, value = {
                BIOMETRIC_STRONG,
                BIOMETRIC_WEAK,
                BIOMETRIC_CONVENIENCE,
                DEVICE_CREDENTIAL,
        })
        @interface Types {}
+82 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.hardware.biometrics;

import android.annotation.IntDef;
import android.os.Parcel;
import android.os.Parcelable;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

/**
 * The base class containing all sensor-agnostic information. This is a superset of the
 * {@link android.hardware.biometrics.common.CommonProps}, and provides backwards-compatible
 * behavior with the older generation of HIDL (non-AIDL) interfaces.
 * @hide
 */
public class SensorProperties implements Parcelable {

    public static final int STRENGTH_CONVENIENCE = 0;
    public static final int STRENGTH_WEAK = 1;
    public static final int STRENGTH_STRONG = 2;

    @IntDef({STRENGTH_CONVENIENCE, STRENGTH_WEAK, STRENGTH_STRONG})
    @Retention(RetentionPolicy.SOURCE)
    public @interface Strength {}

    public final int sensorId;
    @Strength public final int sensorStrength;
    public final int maxEnrollmentsPerUser;

    protected SensorProperties(int sensorId, @Strength int sensorStrength,
            int maxEnrollmentsPerUser) {
        this.sensorId = sensorId;
        this.sensorStrength = sensorStrength;
        this.maxEnrollmentsPerUser = maxEnrollmentsPerUser;
    }

    protected SensorProperties(Parcel in) {
        sensorId = in.readInt();
        sensorStrength = in.readInt();
        maxEnrollmentsPerUser = in.readInt();
    }

    public static final Creator<SensorProperties> CREATOR = new Creator<SensorProperties>() {
        @Override
        public SensorProperties createFromParcel(Parcel in) {
            return new SensorProperties(in);
        }

        @Override
        public SensorProperties[] newArray(int size) {
            return new SensorProperties[size];
        }
    };

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(sensorId);
        dest.writeInt(sensorStrength);
        dest.writeInt(maxEnrollmentsPerUser);
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -110,5 +110,5 @@ interface IFaceService {
            String opPackageName);

    // Give FaceService its ID. See AuthService.java
    void initializeConfiguration(int sensorId);
    void initializeConfiguration(int sensorId, int strength);
}
+27 −18
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.hardware.fingerprint;

import android.annotation.IntDef;
import android.hardware.biometrics.SensorProperties;
import android.hardware.face.FaceSensorProperties;
import android.os.Parcel;
import android.os.Parcelable;
@@ -28,45 +29,44 @@ import java.lang.annotation.RetentionPolicy;
 * Container for fingerprint sensor properties.
 * @hide
 */
public class FingerprintSensorProperties implements Parcelable {
public class FingerprintSensorProperties extends SensorProperties {

    public static final int TYPE_UNKNOWN = 0;
    public static final int TYPE_REAR = 1;
    public static final int TYPE_UDFPS = 2;
    public static final int TYPE_POWER_BUTTON = 3;
    public static final int TYPE_UDFPS_ULTRASONIC = 2;
    public static final int TYPE_UDFPS_OPTICAL = 3;
    public static final int TYPE_POWER_BUTTON = 4;
    public static final int TYPE_HOME_BUTTON = 5;

    @IntDef({
            TYPE_UNKNOWN,
    @IntDef({TYPE_UNKNOWN,
            TYPE_REAR,
            TYPE_UDFPS,
            TYPE_POWER_BUTTON})
            TYPE_UDFPS_ULTRASONIC,
            TYPE_UDFPS_OPTICAL,
            TYPE_POWER_BUTTON,
            TYPE_HOME_BUTTON})
    @Retention(RetentionPolicy.SOURCE)
    public @interface SensorType {}

    public final int sensorId;
    public final @SensorType int sensorType;
    // 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, int maxTemplatesAllowed) {
        this.sensorId = sensorId;
    public FingerprintSensorProperties(int sensorId, @Strength int strength,
            int maxEnrollmentsPerUser, @SensorType int sensorType,
            boolean resetLockoutRequiresHardwareAuthToken) {
        super(sensorId, strength, maxEnrollmentsPerUser);
        this.sensorType = sensorType;
        this.resetLockoutRequiresHardwareAuthToken = resetLockoutRequiresHardwareAuthToken;
        this.maxTemplatesAllowed = maxTemplatesAllowed;
    }

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

    public static final Creator<FingerprintSensorProperties> CREATOR =
@@ -89,9 +89,18 @@ public class FingerprintSensorProperties implements Parcelable {

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(sensorId);
        super.writeToParcel(dest, flags);
        dest.writeInt(sensorType);
        dest.writeBoolean(resetLockoutRequiresHardwareAuthToken);
        dest.writeInt(maxTemplatesAllowed);
    }

    public boolean isAnyUdfpsType() {
        switch (sensorType) {
            case TYPE_UDFPS_OPTICAL:
            case TYPE_UDFPS_ULTRASONIC:
                return true;
            default:
                return false;
        }
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -118,7 +118,7 @@ interface IFingerprintService {
    void removeClientActiveCallback(IFingerprintClientActiveCallback callback);

    // Give FingerprintService its ID. See AuthService.java
    void initializeConfiguration(int sensorId);
    void initializeConfiguration(int sensorId, int strength);

    // Notifies about a finger touching the sensor area.
    void onFingerDown(int x, int y, float minor, float major);
Loading