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

Commit dc48d448 authored by Ilya Matyukhin's avatar Ilya Matyukhin Committed by Android (Google) Code Review
Browse files

Merge changes If2a41e5e,If987a317,I86d3d50f

* changes:
  Remove redundant modifiers from the constants
  Add support for 2.2::FingerprintAcquiredInfo::START
  Use @2.2 callback with @2.2 HAL
parents c014bfd8 144bea08
Loading
Loading
Loading
Loading
+42 −41
Original line number Diff line number Diff line
@@ -37,12 +37,12 @@ public interface BiometricFaceConstants {
     * authentication. Note this is to accommodate people who have limited
     * vision.
     */
    public static final int FEATURE_REQUIRE_ATTENTION = 1;
    int FEATURE_REQUIRE_ATTENTION = 1;
    /**
     * Require a diverse set of poses during enrollment. Note this is to
     * accommodate people with limited mobility.
     */
    public static final int FEATURE_REQUIRE_REQUIRE_DIVERSITY = 2;
    int FEATURE_REQUIRE_REQUIRE_DIVERSITY = 2;

    //
    // Error messages from face authentication hardware during initialization, enrollment,
@@ -51,32 +51,32 @@ public interface BiometricFaceConstants {
    /**
     * The hardware is unavailable. Try again later.
     */
    public static final int FACE_ERROR_HW_UNAVAILABLE = 1;
    int FACE_ERROR_HW_UNAVAILABLE = 1;

    /**
     * Error state returned when the sensor was unable to process the current image.
     */
    public static final int FACE_ERROR_UNABLE_TO_PROCESS = 2;
    int FACE_ERROR_UNABLE_TO_PROCESS = 2;

    /**
     * Error state returned when the current request has been running too long. This is intended to
     * prevent programs from waiting for the face authentication sensor indefinitely. The timeout is
     * platform and sensor-specific, but is generally on the order of 30 seconds.
     */
    public static final int FACE_ERROR_TIMEOUT = 3;
    int FACE_ERROR_TIMEOUT = 3;

    /**
     * Error state returned for operations like enrollment; the operation cannot be completed
     * because there's not enough storage remaining to complete the operation.
     */
    public static final int FACE_ERROR_NO_SPACE = 4;
    int FACE_ERROR_NO_SPACE = 4;

    /**
     * The operation was canceled because the face authentication sensor is unavailable. For
     * example, this may happen when the user is switched, the device is locked or another pending
     * operation prevents or disables it.
     */
    public static final int FACE_ERROR_CANCELED = 5;
    int FACE_ERROR_CANCELED = 5;

    /**
     * The {@link FaceManager#remove} call failed. Typically this will happen when the
@@ -84,13 +84,13 @@ public interface BiometricFaceConstants {
     *
     * @hide
     */
    public static final int FACE_ERROR_UNABLE_TO_REMOVE = 6;
    int FACE_ERROR_UNABLE_TO_REMOVE = 6;

    /**
     * The operation was canceled because the API is locked out due to too many attempts.
     * This occurs after 5 failed attempts, and lasts for 30 seconds.
     */
    public static final int FACE_ERROR_LOCKOUT = 7;
    int FACE_ERROR_LOCKOUT = 7;

    /**
     * Hardware vendors may extend this list if there are conditions that do not fall under one of
@@ -100,47 +100,48 @@ public interface BiometricFaceConstants {
     * expected to show the error message string if they happen, but are advised not to rely on the
     * message id since they will be device and vendor-specific
     */
    public static final int FACE_ERROR_VENDOR = 8;
    int FACE_ERROR_VENDOR = 8;

    /**
     * The operation was canceled because FACE_ERROR_LOCKOUT occurred too many times.
     * Face authentication is disabled until the user unlocks with strong authentication
     * (PIN/Pattern/Password)
     */
    public static final int FACE_ERROR_LOCKOUT_PERMANENT = 9;
    int FACE_ERROR_LOCKOUT_PERMANENT = 9;

    /**
     * The user canceled the operation. Upon receiving this, applications should use alternate
     * authentication (e.g. a password). The application should also provide the means to return
     * to face authentication, such as a "use face authentication" button.
     */
    public static final int FACE_ERROR_USER_CANCELED = 10;
    int FACE_ERROR_USER_CANCELED = 10;

    /**
     * The user does not have a face enrolled.
     */
    public static final int FACE_ERROR_NOT_ENROLLED = 11;
    int FACE_ERROR_NOT_ENROLLED = 11;

    /**
     * The device does not have a face sensor. This message will propagate if the calling app
     * ignores the result from PackageManager.hasFeature(FEATURE_FACE) and calls
     * this API anyway. Apps should always check for the feature before calling this API.
     */
    public static final int FACE_ERROR_HW_NOT_PRESENT = 12;
    int FACE_ERROR_HW_NOT_PRESENT = 12;

    /**
     * The user pressed the negative button. This is a placeholder that is currently only used
     * by the support library.
     *
     * @hide
     */
    public static final int FACE_ERROR_NEGATIVE_BUTTON = 13;
    int FACE_ERROR_NEGATIVE_BUTTON = 13;

    /**
     * The device does not have pin, pattern, or password set up. See
     * {@link BiometricPrompt.Builder#setDeviceCredentialAllowed(boolean)} and
     * {@link KeyguardManager#isDeviceSecure()}
     */
    public static final int BIOMETRIC_ERROR_NO_DEVICE_CREDENTIAL = 14;
    int BIOMETRIC_ERROR_NO_DEVICE_CREDENTIAL = 14;

    /**
     * A security vulnerability has been discovered and the sensor is unavailable until a
@@ -154,7 +155,7 @@ public interface BiometricFaceConstants {
    /**
     * @hide
     */
    public static final int FACE_ERROR_VENDOR_BASE = 1000;
    int FACE_ERROR_VENDOR_BASE = 1000;

    //
    // Image acquisition messages. These will not be sent to the user, since they conflict with
@@ -164,13 +165,13 @@ public interface BiometricFaceConstants {
    /**
     * The image acquired was good.
     */
    public static final int FACE_ACQUIRED_GOOD = 0;
    int FACE_ACQUIRED_GOOD = 0;

    /**
     * The face image was not good enough to process due to a detected condition.
     * (See {@link #FACE_ACQUIRED_TOO_BRIGHT or @link #FACE_ACQUIRED_TOO_DARK}).
     */
    public static final int FACE_ACQUIRED_INSUFFICIENT = 1;
    int FACE_ACQUIRED_INSUFFICIENT = 1;

    /**
     * The face image was too bright due to too much ambient light.
@@ -179,7 +180,7 @@ public interface BiometricFaceConstants {
     * The user is expected to take action to retry in better lighting conditions
     * when this is returned.
     */
    public static final int FACE_ACQUIRED_TOO_BRIGHT = 2;
    int FACE_ACQUIRED_TOO_BRIGHT = 2;

    /**
     * The face image was too dark due to illumination light obscured.
@@ -188,65 +189,65 @@ public interface BiometricFaceConstants {
     * The user is expected to take action to retry in better lighting conditions
     * when this is returned.
     */
    public static final int FACE_ACQUIRED_TOO_DARK = 3;
    int FACE_ACQUIRED_TOO_DARK = 3;

    /**
     * The detected face is too close to the sensor, and the image can't be processed.
     * The user should be informed to move farther from the sensor when this is returned.
     */
    public static final int FACE_ACQUIRED_TOO_CLOSE = 4;
    int FACE_ACQUIRED_TOO_CLOSE = 4;

    /**
     * The detected face is too small, as the user might be too far from the sensor.
     * The user should be informed to move closer to the sensor when this is returned.
     */
    public static final int FACE_ACQUIRED_TOO_FAR = 5;
    int FACE_ACQUIRED_TOO_FAR = 5;

    /**
     * Only the upper part of the face was detected. The sensor field of view is too high.
     * The user should be informed to move up with respect to the sensor when this is returned.
     */
    public static final int FACE_ACQUIRED_TOO_HIGH = 6;
    int FACE_ACQUIRED_TOO_HIGH = 6;

    /**
     * Only the lower part of the face was detected. The sensor field of view is too low.
     * The user should be informed to move down with respect to the sensor when this is returned.
     */
    public static final int FACE_ACQUIRED_TOO_LOW = 7;
    int FACE_ACQUIRED_TOO_LOW = 7;

    /**
     * Only the right part of the face was detected. The sensor field of view is too far right.
     * The user should be informed to move to the right with respect to the sensor
     * when this is returned.
     */
    public static final int FACE_ACQUIRED_TOO_RIGHT = 8;
    int FACE_ACQUIRED_TOO_RIGHT = 8;

    /**
     * Only the left part of the face was detected. The sensor field of view is too far left.
     * The user should be informed to move to the left with respect to the sensor
     * when this is returned.
     */
    public static final int FACE_ACQUIRED_TOO_LEFT = 9;
    int FACE_ACQUIRED_TOO_LEFT = 9;

    /**
     * The user's eyes have strayed away from the sensor. If this message is sent, the user should
     * be informed to look at the device. If the user can't be found in the frame, one of the other
     * acquisition messages should be sent, e.g. FACE_ACQUIRED_NOT_DETECTED.
     */
    public static final int FACE_ACQUIRED_POOR_GAZE = 10;
    int FACE_ACQUIRED_POOR_GAZE = 10;

    /**
     * No face was detected in front of the sensor.
     * The user should be informed to point the sensor to a face when this is returned.
     */
    public static final int FACE_ACQUIRED_NOT_DETECTED = 11;
    int FACE_ACQUIRED_NOT_DETECTED = 11;

    /**
     * Too much motion was detected.
     * The user should be informed to keep their face steady relative to the
     * sensor.
     */
    public static final int FACE_ACQUIRED_TOO_MUCH_MOTION = 12;
    int FACE_ACQUIRED_TOO_MUCH_MOTION = 12;

    /**
     * The sensor needs to be re-calibrated. This is an unexpected condition, and should only be
@@ -254,20 +255,20 @@ public interface BiometricFaceConstants {
     * requires user intervention, e.g. re-enrolling. The expected response to this message is to
     * direct the user to re-enroll.
     */
    public static final int FACE_ACQUIRED_RECALIBRATE = 13;
    int FACE_ACQUIRED_RECALIBRATE = 13;

    /**
     * The face is too different from a previous acquisition. This condition
     * only applies to enrollment. This can happen if the user passes the
     * device to someone else in the middle of enrollment.
     */
    public static final int FACE_ACQUIRED_TOO_DIFFERENT = 14;
    int FACE_ACQUIRED_TOO_DIFFERENT = 14;

    /**
     * The face is too similar to a previous acquisition. This condition only
     * applies to enrollment. The user should change their pose.
     */
    public static final int FACE_ACQUIRED_TOO_SIMILAR = 15;
    int FACE_ACQUIRED_TOO_SIMILAR = 15;

    /**
     * The magnitude of the pan angle of the user’s face with respect to the sensor’s
@@ -279,7 +280,7 @@ public interface BiometricFaceConstants {
     *
     * The user should be informed to look more directly at the camera.
     */
    public static final int FACE_ACQUIRED_PAN_TOO_EXTREME = 16;
    int FACE_ACQUIRED_PAN_TOO_EXTREME = 16;

    /**
     * The magnitude of the tilt angle of the user’s face with respect to the sensor’s
@@ -290,7 +291,7 @@ public interface BiometricFaceConstants {
     *
     * The user should be informed to look more directly at the camera.
     */
    public static final int FACE_ACQUIRED_TILT_TOO_EXTREME = 17;
    int FACE_ACQUIRED_TILT_TOO_EXTREME = 17;

    /**
     * The magnitude of the roll angle of the user’s face with respect to the sensor’s
@@ -302,7 +303,7 @@ public interface BiometricFaceConstants {
     *
     * The user should be informed to look more directly at the camera.
     */
    public static final int FACE_ACQUIRED_ROLL_TOO_EXTREME = 18;
    int FACE_ACQUIRED_ROLL_TOO_EXTREME = 18;

    /**
     * The user’s face has been obscured by some object.
@@ -310,7 +311,7 @@ public interface BiometricFaceConstants {
     * The user should be informed to remove any objects from the line of sight from
     * the sensor to the user’s face.
     */
    public static final int FACE_ACQUIRED_FACE_OBSCURED = 19;
    int FACE_ACQUIRED_FACE_OBSCURED = 19;

    /**
     * This message represents the earliest message sent at the beginning of the authentication
@@ -320,12 +321,12 @@ public interface BiometricFaceConstants {
     * The framework will measure latency based on the time between the last START message and the
     * onAuthenticated callback.
     */
    public static final int FACE_ACQUIRED_START = 20;
    int FACE_ACQUIRED_START = 20;

    /**
     * The sensor is dirty. The user should be informed to clean the sensor.
     */
    public static final int FACE_ACQUIRED_SENSOR_DIRTY = 21;
    int FACE_ACQUIRED_SENSOR_DIRTY = 21;

    /**
     * Hardware vendors may extend this list if there are conditions that do not fall under one of
@@ -333,10 +334,10 @@ public interface BiometricFaceConstants {
     *
     * @hide
     */
    public static final int FACE_ACQUIRED_VENDOR = 22;
    int FACE_ACQUIRED_VENDOR = 22;

    /**
     * @hide
     */
    public static final int FACE_ACQUIRED_VENDOR_BASE = 1000;
    int FACE_ACQUIRED_VENDOR_BASE = 1000;
}
+38 −23
Original line number Diff line number Diff line
@@ -38,32 +38,32 @@ public interface BiometricFingerprintConstants {
    /**
     * The hardware is unavailable. Try again later.
     */
    public static final int FINGERPRINT_ERROR_HW_UNAVAILABLE = 1;
    int FINGERPRINT_ERROR_HW_UNAVAILABLE = 1;

    /**
     * Error state returned when the sensor was unable to process the current image.
     */
    public static final int FINGERPRINT_ERROR_UNABLE_TO_PROCESS = 2;
    int FINGERPRINT_ERROR_UNABLE_TO_PROCESS = 2;

    /**
     * Error state returned when the current request has been running too long. This is intended to
     * prevent programs from waiting for the fingerprint sensor indefinitely. The timeout is
     * platform and sensor-specific, but is generally on the order of 30 seconds.
     */
    public static final int FINGERPRINT_ERROR_TIMEOUT = 3;
    int FINGERPRINT_ERROR_TIMEOUT = 3;

    /**
     * Error state returned for operations like enrollment; the operation cannot be completed
     * because there's not enough storage remaining to complete the operation.
     */
    public static final int FINGERPRINT_ERROR_NO_SPACE = 4;
    int FINGERPRINT_ERROR_NO_SPACE = 4;

    /**
     * The operation was canceled because the fingerprint sensor is unavailable. For example,
     * this may happen when the user is switched, the device is locked or another pending operation
     * prevents or disables it.
     */
    public static final int FINGERPRINT_ERROR_CANCELED = 5;
    int FINGERPRINT_ERROR_CANCELED = 5;

    /**
     * The {@link FingerprintManager#remove} call failed. Typically this will happen when the
@@ -71,13 +71,13 @@ public interface BiometricFingerprintConstants {
     *
     * @hide
     */
    public static final int FINGERPRINT_ERROR_UNABLE_TO_REMOVE = 6;
    int FINGERPRINT_ERROR_UNABLE_TO_REMOVE = 6;

    /**
     * The operation was canceled because the API is locked out due to too many attempts.
     * This occurs after 5 failed attempts, and lasts for 30 seconds.
     */
    public static final int FINGERPRINT_ERROR_LOCKOUT = 7;
    int FINGERPRINT_ERROR_LOCKOUT = 7;

    /**
     * Hardware vendors may extend this list if there are conditions that do not fall under one of
@@ -87,46 +87,48 @@ public interface BiometricFingerprintConstants {
     * expected to show the error message string if they happen, but are advised not to rely on the
     * message id since they will be device and vendor-specific
     */
    public static final int FINGERPRINT_ERROR_VENDOR = 8;
    int FINGERPRINT_ERROR_VENDOR = 8;

    /**
     * The operation was canceled because FINGERPRINT_ERROR_LOCKOUT occurred too many times.
     * Fingerprint authentication is disabled until the user unlocks with strong authentication
     * (PIN/Pattern/Password)
     */
    public static final int FINGERPRINT_ERROR_LOCKOUT_PERMANENT = 9;
    int FINGERPRINT_ERROR_LOCKOUT_PERMANENT = 9;

    /**
     * The user canceled the operation. Upon receiving this, applications should use alternate
     * authentication (e.g. a password). The application should also provide the means to return
     * to fingerprint authentication, such as a "use fingerprint" button.
     */
    public static final int FINGERPRINT_ERROR_USER_CANCELED = 10;
    int FINGERPRINT_ERROR_USER_CANCELED = 10;

    /**
     * The user does not have any fingerprints enrolled.
     */
    public static final int FINGERPRINT_ERROR_NO_FINGERPRINTS = 11;
    int FINGERPRINT_ERROR_NO_FINGERPRINTS = 11;

    /**
     * The device does not have a fingerprint sensor.
     */
    public static final int FINGERPRINT_ERROR_HW_NOT_PRESENT = 12;
    int FINGERPRINT_ERROR_HW_NOT_PRESENT = 12;

    /**
     * The user pressed the negative button. This is a placeholder that is currently only used
     * by the support library.
     *
     * @hide
     */
    public static final int FINGERPRINT_ERROR_NEGATIVE_BUTTON = 13;
    int FINGERPRINT_ERROR_NEGATIVE_BUTTON = 13;

    /**
     * The device does not have pin, pattern, or password set up. See
     * {@link BiometricPrompt.Builder#setDeviceCredentialAllowed(boolean)} and
     * {@link KeyguardManager#isDeviceSecure()}
     *
     * @hide
     */
    public static final int BIOMETRIC_ERROR_NO_DEVICE_CREDENTIAL = 14;
    int BIOMETRIC_ERROR_NO_DEVICE_CREDENTIAL = 14;

    /**
     * A security vulnerability has been discovered and the sensor is unavailable until a
@@ -141,7 +143,7 @@ public interface BiometricFingerprintConstants {
     * @hide
     */
    @UnsupportedAppUsage
    public static final int FINGERPRINT_ERROR_VENDOR_BASE = 1000;
    int FINGERPRINT_ERROR_VENDOR_BASE = 1000;

    //
    // Image acquisition messages. Must agree with those in fingerprint.h
@@ -150,19 +152,19 @@ public interface BiometricFingerprintConstants {
    /**
     * The image acquired was good.
     */
    public static final int FINGERPRINT_ACQUIRED_GOOD = 0;
    int FINGERPRINT_ACQUIRED_GOOD = 0;

    /**
     * Only a partial fingerprint image was detected. During enrollment, the user should be
     * informed on what needs to happen to resolve this problem, e.g. "press firmly on sensor."
     */
    public static final int FINGERPRINT_ACQUIRED_PARTIAL = 1;
    int FINGERPRINT_ACQUIRED_PARTIAL = 1;

    /**
     * The fingerprint image was too noisy to process due to a detected condition (i.e. dry skin) or
     * a possibly dirty sensor (See {@link #FINGERPRINT_ACQUIRED_IMAGER_DIRTY}).
     */
    public static final int FINGERPRINT_ACQUIRED_INSUFFICIENT = 2;
    int FINGERPRINT_ACQUIRED_INSUFFICIENT = 2;

    /**
     * The fingerprint image was too noisy due to suspected or detected dirt on the sensor.
@@ -171,13 +173,13 @@ public interface BiometricFingerprintConstants {
     * (stuck pixels, swaths, etc.). The user is expected to take action to clean the sensor
     * when this is returned.
     */
    public static final int FINGERPRINT_ACQUIRED_IMAGER_DIRTY = 3;
    int FINGERPRINT_ACQUIRED_IMAGER_DIRTY = 3;

    /**
     * The fingerprint image was unreadable due to lack of motion. This is most appropriate for
     * linear array sensors that require a swipe motion.
     */
    public static final int FINGERPRINT_ACQUIRED_TOO_SLOW = 4;
    int FINGERPRINT_ACQUIRED_TOO_SLOW = 4;

    /**
     * The fingerprint image was incomplete due to quick motion. While mostly appropriate for
@@ -185,16 +187,29 @@ public interface BiometricFingerprintConstants {
     * The user should be asked to move the finger slower (linear) or leave the finger on the sensor
     * longer.
     */
    public static final int FINGERPRINT_ACQUIRED_TOO_FAST = 5;
    int FINGERPRINT_ACQUIRED_TOO_FAST = 5;

    /**
     * Hardware vendors may extend this list if there are conditions that do not fall under one of
     * the above categories. Vendors are responsible for providing error strings for these errors.
     *
     * @hide
     */
    public static final int FINGERPRINT_ACQUIRED_VENDOR = 6;
    int FINGERPRINT_ACQUIRED_VENDOR = 6;

    /**
     * This message represents the earliest message sent at the beginning of the authentication
     * pipeline. It is expected to be used to measure latency. Note this should be sent whenever
     * authentication is restarted.
     * The framework will measure latency based on the time between the last START message and the
     * onAuthenticated callback.
     *
     * @hide
     */
    int FINGERPRINT_ACQUIRED_START = 7;

    /**
     * @hide
     */
    public static final int FINGERPRINT_ACQUIRED_VENDOR_BASE = 1000;
    int FINGERPRINT_ACQUIRED_VENDOR_BASE = 1000;
}
+6 −1
Original line number Diff line number Diff line
@@ -918,9 +918,11 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
        if (mEnrollmentCallback != null) {
            mEnrollmentCallback.onEnrollmentHelp(clientInfo, msg);
        } else if (mAuthenticationCallback != null) {
            if (acquireInfo != BiometricFingerprintConstants.FINGERPRINT_ACQUIRED_START) {
                mAuthenticationCallback.onAuthenticationHelp(clientInfo, msg);
            }
        }
    }

    private void sendErrorResult(long deviceId, int errMsgId, int vendorCode) {
        // emulate HAL 2.1 behavior and send real errMsgId
@@ -1050,6 +1052,9 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
                        return msgArray[vendorCode];
                    }
                }
                break;
            case FINGERPRINT_ACQUIRED_START:
                return null;
        }
        Slog.w(TAG, "Invalid acquired message: " + acquireInfo + ", " + vendorCode);
        return null;
+8 −10
Original line number Diff line number Diff line
@@ -1459,7 +1459,6 @@ public class BiometricService extends SystemService {
            return;
        }

        if (acquiredInfo != BiometricConstants.BIOMETRIC_ACQUIRED_GOOD) {
        if (message == null) {
            Slog.w(TAG, "Ignoring null message: " + acquiredInfo);
            return;
@@ -1470,7 +1469,6 @@ public class BiometricService extends SystemService {
            Slog.e(TAG, "Remote exception", e);
        }
    }
    }

    private void handleOnDismissed(int reason) {
        if (mCurrentAuthSession == null) {
+7 −2
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.content.Context;
import android.hardware.biometrics.BiometricConstants;
import android.hardware.biometrics.BiometricsProtoEnums;
import android.hardware.face.FaceManager;
import android.hardware.fingerprint.FingerprintManager;
import android.util.Slog;

import com.android.internal.util.FrameworkStatsLog;
@@ -69,8 +70,12 @@ public abstract class LoggableMonitor {

    protected final void logOnAcquired(Context context, int acquiredInfo, int vendorCode,
            int targetUserId) {
        if (statsModality() == BiometricsProtoEnums.MODALITY_FACE) {
            if (acquiredInfo == FaceManager.FACE_ACQUIRED_START) {

        final boolean isFace = statsModality() == BiometricsProtoEnums.MODALITY_FACE;
        final boolean isFingerprint = statsModality() == BiometricsProtoEnums.MODALITY_FINGERPRINT;
        if (isFace || isFingerprint) {
            if ((isFingerprint && acquiredInfo == FingerprintManager.FINGERPRINT_ACQUIRED_START)
                    || (isFace && acquiredInfo == FaceManager.FACE_ACQUIRED_START)) {
                mFirstAcquireTimeMs = System.currentTimeMillis();
            }
        } else if (acquiredInfo == BiometricConstants.BIOMETRIC_ACQUIRED_GOOD) {
Loading