Add AIDL constants to framework constants

Fixes: 188912467
Test: Modify HAL to send above constants. No longer see
      "Unknown enrollment acquired message" in logcat

Change-Id: I286465dae550fa123fef785879084e86081f2b43
This commit is contained in:
Kevin Chyn
2021-05-25 15:34:31 -07:00
parent a5e777f954
commit 9e1ae2cec0
4 changed files with 38 additions and 23 deletions

View File

@@ -53,9 +53,6 @@ public interface BiometricFaceConstants {
// authentication or removal. Must agree with the list in HAL h file
//
/**
* @hide
*/
@IntDef({FACE_ERROR_HW_UNAVAILABLE,
FACE_ERROR_UNABLE_TO_PROCESS,
FACE_ERROR_TIMEOUT,
@@ -110,8 +107,6 @@ public interface BiometricFaceConstants {
/**
* The {@link FaceManager#remove} call failed. Typically this will happen when the
* provided face id was incorrect.
*
* @hide
*/
int FACE_ERROR_UNABLE_TO_REMOVE = 6;
@@ -160,8 +155,6 @@ public interface BiometricFaceConstants {
/**
* The user pressed the negative button. This is a placeholder that is currently only used
* by the support library.
*
* @hide
*/
int FACE_ERROR_NEGATIVE_BUTTON = 13;
@@ -177,24 +170,23 @@ public interface BiometricFaceConstants {
* security update has addressed this issue. This error can be received if for example,
* authentication was requested with {@link Authenticators#BIOMETRIC_STRONG}, but the
* sensor's strength can currently only meet {@link Authenticators#BIOMETRIC_WEAK}.
* @hide
*/
int BIOMETRIC_ERROR_SECURITY_UPDATE_REQUIRED = 15;
/**
* Authentication cannot proceed because re-enrollment is required.
* @hide
*/
int BIOMETRIC_ERROR_RE_ENROLL = 16;
/**
* Unknown error received from the HAL.
* @hide
*/
int FACE_ERROR_UNKNOWN = 17;
/**
* @hide
* Vendor codes received from the HAL start at 0. Codes that the framework exposes to keyguard
* append this value for some reason. We should probably remove this and just send the actual
* vendor code.
*/
int FACE_ERROR_VENDOR_BASE = 1000;
@@ -203,9 +195,6 @@ public interface BiometricFaceConstants {
// existing constants. These must agree with face@1.0/types.hal.
//
/**
* @hide
*/
@IntDef({FACE_ACQUIRED_GOOD,
FACE_ACQUIRED_INSUFFICIENT,
FACE_ACQUIRED_TOO_BRIGHT,
@@ -229,7 +218,10 @@ public interface BiometricFaceConstants {
FACE_ACQUIRED_START,
FACE_ACQUIRED_SENSOR_DIRTY,
FACE_ACQUIRED_VENDOR,
FACE_ACQUIRED_UNKNOWN})
FACE_ACQUIRED_UNKNOWN,
FACE_ACQUIRED_FIRST_FRAME_RECEIVED,
FACE_ACQUIRED_DARK_GLASSES_DETECTED,
FACE_ACQUIRED_MOUTH_COVERING_DETECTED})
@Retention(RetentionPolicy.SOURCE)
@interface FaceAcquired {}
@@ -402,19 +394,35 @@ public interface BiometricFaceConstants {
/**
* 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
*/
int FACE_ACQUIRED_VENDOR = 22;
/**
* Unknown acquired code received from the HAL.
* @hide
*/
int FACE_ACQUIRED_UNKNOWN = 23;
/**
* @hide
* The first frame from the camera has been received.
*/
int FACE_ACQUIRED_FIRST_FRAME_RECEIVED = 24;
/**
* Dark glasses detected. This can be useful for providing relevant feedback to the user and
* enabling an alternative authentication logic if the implementation supports it.
*/
int FACE_ACQUIRED_DARK_GLASSES_DETECTED = 25;
/**
* A face mask or face covering detected. This can be useful for providing relevant feedback to
* the user and enabling an alternative authentication logic if the implementation supports it.
*/
int FACE_ACQUIRED_MOUTH_COVERING_DETECTED = 26;
/**
* Vendor codes received from the HAL start at 0. Codes that the framework exposes to keyguard
* append this value for some reason. We should probably remove this and just send the actual
* vendor code.
*/
int FACE_ACQUIRED_VENDOR_BASE = 1000;
}

View File

@@ -17,6 +17,7 @@
package android.hardware.face;
import android.annotation.NonNull;
import android.hardware.biometrics.BiometricFaceConstants;
import android.os.Parcel;
import android.os.Parcelable;
@@ -26,7 +27,7 @@ import android.os.Parcelable;
* @hide
*/
public final class FaceDataFrame implements Parcelable {
private final int mAcquiredInfo;
@BiometricFaceConstants.FaceAcquired private final int mAcquiredInfo;
private final int mVendorCode;
private final float mPan;
private final float mTilt;
@@ -48,7 +49,7 @@ public final class FaceDataFrame implements Parcelable {
* @param isCancellable Whether the ongoing face operation should be canceled.
*/
public FaceDataFrame(
int acquiredInfo,
@BiometricFaceConstants.FaceAcquired int acquiredInfo,
int vendorCode,
float pan,
float tilt,
@@ -69,7 +70,7 @@ public final class FaceDataFrame implements Parcelable {
* @param vendorCode An integer representing a custom vendor-specific message. Ignored unless
* {@code acquiredInfo} is {@code FACE_ACQUIRED_VENDOR}.
*/
public FaceDataFrame(int acquiredInfo, int vendorCode) {
public FaceDataFrame(@BiometricFaceConstants.FaceAcquired int acquiredInfo, int vendorCode) {
mAcquiredInfo = acquiredInfo;
mVendorCode = vendorCode;
mPan = 0f;
@@ -83,6 +84,7 @@ public final class FaceDataFrame implements Parcelable {
*
* @see android.hardware.biometrics.BiometricFaceConstants
*/
@BiometricFaceConstants.FaceAcquired
public int getAcquiredInfo() {
return mAcquiredInfo;
}

View File

@@ -1449,6 +1449,8 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan
case FACE_ACQUIRED_ROLL_TOO_EXTREME:
return context.getString(R.string.face_acquired_roll_too_extreme);
case FACE_ACQUIRED_FACE_OBSCURED:
case FACE_ACQUIRED_DARK_GLASSES_DETECTED:
case FACE_ACQUIRED_MOUTH_COVERING_DETECTED:
return context.getString(R.string.face_acquired_obscured);
case FACE_ACQUIRED_SENSOR_DIRTY:
return context.getString(R.string.face_acquired_sensor_dirty);

View File

@@ -120,10 +120,13 @@ final class AidlConversionUtils {
return BiometricFaceConstants.FACE_ACQUIRED_SENSOR_DIRTY;
case AcquiredInfo.VENDOR:
return BiometricFaceConstants.FACE_ACQUIRED_VENDOR;
case AcquiredInfo.UNKNOWN:
case AcquiredInfo.FIRST_FRAME_RECEIVED:
return BiometricFaceConstants.FACE_ACQUIRED_FIRST_FRAME_RECEIVED;
case AcquiredInfo.DARK_GLASSES_DETECTED:
return BiometricFaceConstants.FACE_ACQUIRED_DARK_GLASSES_DETECTED;
case AcquiredInfo.MOUTH_COVERING_DETECTED:
return BiometricFaceConstants.FACE_ACQUIRED_MOUTH_COVERING_DETECTED;
case AcquiredInfo.UNKNOWN:
default:
return BiometricFaceConstants.FACE_ACQUIRED_UNKNOWN;
}