Add Session#getEnrollmentConfig and better enum defaults

Bug: 183738533
Bug: 181358178
Test: atest VtsHalBiometricsFaceTargetTest
Change-Id: I45a60d58b0d32b7449bb7a2b04cc469b79454bcb
This commit is contained in:
Ilya Matyukhin
2021-04-22 00:29:01 -07:00
parent 2906d566ec
commit 929146ecff
19 changed files with 133 additions and 122 deletions

View File

@@ -34,30 +34,31 @@
package android.hardware.biometrics.face;
@Backing(type="byte") @VintfStability
enum AcquiredInfo {
GOOD = 0,
INSUFFICIENT = 1,
TOO_BRIGHT = 2,
TOO_DARK = 3,
TOO_CLOSE = 4,
TOO_FAR = 5,
FACE_TOO_HIGH = 6,
FACE_TOO_LOW = 7,
FACE_TOO_RIGHT = 8,
FACE_TOO_LEFT = 9,
POOR_GAZE = 10,
NOT_DETECTED = 11,
TOO_MUCH_MOTION = 12,
RECALIBRATE = 13,
TOO_DIFFERENT = 14,
TOO_SIMILAR = 15,
PAN_TOO_EXTREME = 16,
TILT_TOO_EXTREME = 17,
ROLL_TOO_EXTREME = 18,
FACE_OBSCURED = 19,
START = 20,
SENSOR_DIRTY = 21,
VENDOR = 22,
FIRST_FRAME_RECEIVED = 23,
DARK_GLASSES_DETECTED = 24,
MOUTH_COVERING_DETECTED = 25,
UNKNOWN = 0,
GOOD = 1,
INSUFFICIENT = 2,
TOO_BRIGHT = 3,
TOO_DARK = 4,
TOO_CLOSE = 5,
TOO_FAR = 6,
FACE_TOO_HIGH = 7,
FACE_TOO_LOW = 8,
FACE_TOO_RIGHT = 9,
FACE_TOO_LEFT = 10,
POOR_GAZE = 11,
NOT_DETECTED = 12,
TOO_MUCH_MOTION = 13,
RECALIBRATE = 14,
TOO_DIFFERENT = 15,
TOO_SIMILAR = 16,
PAN_TOO_EXTREME = 17,
TILT_TOO_EXTREME = 18,
ROLL_TOO_EXTREME = 19,
FACE_OBSCURED = 20,
START = 21,
SENSOR_DIRTY = 22,
VENDOR = 23,
FIRST_FRAME_RECEIVED = 24,
DARK_GLASSES_DETECTED = 25,
MOUTH_COVERING_DETECTED = 26,
}

View File

@@ -34,7 +34,7 @@
package android.hardware.biometrics.face;
@VintfStability
parcelable BaseFrame {
android.hardware.biometrics.face.AcquiredInfo acquiredInfo = android.hardware.biometrics.face.AcquiredInfo.INSUFFICIENT;
android.hardware.biometrics.face.AcquiredInfo acquiredInfo = android.hardware.biometrics.face.AcquiredInfo.UNKNOWN;
int vendorCode;
float pan;
float tilt;

View File

@@ -35,6 +35,6 @@ package android.hardware.biometrics.face;
@VintfStability
parcelable EnrollmentFrame {
@nullable android.hardware.biometrics.face.Cell cell;
android.hardware.biometrics.face.EnrollmentStage stage = android.hardware.biometrics.face.EnrollmentStage.FIRST_FRAME_RECEIVED;
android.hardware.biometrics.face.EnrollmentStage stage = android.hardware.biometrics.face.EnrollmentStage.UNKNOWN;
android.hardware.biometrics.face.BaseFrame data;
}

View File

@@ -34,10 +34,11 @@
package android.hardware.biometrics.face;
@Backing(type="byte") @VintfStability
enum EnrollmentStage {
FIRST_FRAME_RECEIVED = 0,
WAITING_FOR_CENTERING = 1,
HOLD_STILL_IN_CENTER = 2,
ENROLLING_MOVEMENT_1 = 3,
ENROLLING_MOVEMENT_2 = 4,
ENROLLMENT_FINISHED = 5,
UNKNOWN = 0,
FIRST_FRAME_RECEIVED = 1,
WAITING_FOR_CENTERING = 2,
HOLD_STILL_IN_CENTER = 3,
ENROLLING_MOVEMENT_1 = 4,
ENROLLING_MOVEMENT_2 = 5,
ENROLLMENT_FINISHED = 6,
}

View File

@@ -34,6 +34,6 @@
package android.hardware.biometrics.face;
@VintfStability
parcelable EnrollmentStageConfig {
android.hardware.biometrics.face.EnrollmentStage stage = android.hardware.biometrics.face.EnrollmentStage.FIRST_FRAME_RECEIVED;
android.hardware.biometrics.face.EnrollmentStage stage = android.hardware.biometrics.face.EnrollmentStage.UNKNOWN;
List<android.hardware.biometrics.face.Cell> cells;
}

View File

@@ -34,12 +34,13 @@
package android.hardware.biometrics.face;
@Backing(type="byte") @VintfStability
enum Error {
UNKNOWN = 0,
HW_UNAVAILABLE = 1,
UNABLE_TO_PROCESS = 2,
TIMEOUT = 3,
NO_SPACE = 4,
CANCELED = 5,
UNABLE_TO_REMOVE = 6,
VENDOR = 8,
REENROLL_REQUIRED = 16,
VENDOR = 7,
REENROLL_REQUIRED = 8,
}

View File

@@ -36,6 +36,7 @@ package android.hardware.biometrics.face;
interface ISession {
void generateChallenge();
void revokeChallenge(in long challenge);
android.hardware.biometrics.face.EnrollmentStageConfig[] getEnrollmentConfig(in android.hardware.biometrics.face.EnrollmentType enrollmentType);
android.hardware.biometrics.common.ICancellationSignal enroll(in android.hardware.keymaster.HardwareAuthToken hat, in android.hardware.biometrics.face.EnrollmentType type, in android.hardware.biometrics.face.Feature[] features, in android.hardware.common.NativeHandle previewSurface);
android.hardware.biometrics.common.ICancellationSignal authenticate(in long operationId);
android.hardware.biometrics.common.ICancellationSignal detectInteraction();

View File

@@ -35,7 +35,7 @@ package android.hardware.biometrics.face;
@VintfStability
parcelable SensorProps {
android.hardware.biometrics.common.CommonProps commonProps;
android.hardware.biometrics.face.FaceSensorType sensorType = android.hardware.biometrics.face.FaceSensorType.RGB;
android.hardware.biometrics.face.FaceSensorType sensorType = android.hardware.biometrics.face.FaceSensorType.UNKNOWN;
boolean halControlsPreview;
int enrollPreviewWidth;
int enrollPreviewHeight;

View File

@@ -19,18 +19,24 @@ package android.hardware.biometrics.face;
@VintfStability
@Backing(type="byte")
enum AcquiredInfo {
/**
* Placeholder value used for default initialization of AcquiredInfo. This
* value means AcquiredInfo wasn't explicitly initialized and must be
* discarded by the recipient.
*/
UNKNOWN,
/**
* The acquired face data was good, no further user interaction is necessary.
*/
GOOD = 0,
GOOD,
/**
* The acquired face data was too noisy or did not have sufficient detail.
* This is a catch-all for all acquisition errors not captured by the other
* constants.
*/
INSUFFICIENT = 1,
INSUFFICIENT,
/**
* Because there was too much ambient light, the captured face data was too
@@ -40,7 +46,7 @@ enum AcquiredInfo {
* The user is expected to take action to retry the operation in better
* lighting conditions when this is returned.
*/
TOO_BRIGHT = 2,
TOO_BRIGHT,
/**
* Because there was not enough illumination, the captured face data was too
@@ -50,7 +56,7 @@ enum AcquiredInfo {
* The user is expected to take action to retry the operation in better
* lighting conditions when this is returned.
*/
TOO_DARK = 3,
TOO_DARK,
/**
* The detected face is too close to the sensor, and the image cannot be
@@ -59,7 +65,7 @@ enum AcquiredInfo {
* The user is expected to be informed to move further from the sensor when
* this is returned.
*/
TOO_CLOSE = 4,
TOO_CLOSE,
/**
* The detected face is too small, as the user might be too far away from
@@ -68,7 +74,7 @@ enum AcquiredInfo {
* The user is expected to be informed to move closer to the sensor when
* this is returned.
*/
TOO_FAR = 5,
TOO_FAR,
/**
* Only the upper part of the face was detected. The sensor's field of view
@@ -77,7 +83,7 @@ enum AcquiredInfo {
* The user should be informed to move up with respect to the sensor when
* this is returned.
*/
FACE_TOO_HIGH = 6,
FACE_TOO_HIGH,
/**
* Only the lower part of the face was detected. The sensor's field of view
@@ -86,7 +92,7 @@ enum AcquiredInfo {
* The user should be informed to move down with respect to the sensor when
* this is returned.
*/
FACE_TOO_LOW = 7,
FACE_TOO_LOW,
/**
* Only the right part of the face was detected. The sensor's field of view
@@ -95,7 +101,7 @@ enum AcquiredInfo {
* The user should be informed to move to the right with respect to the
* sensor when this is returned.
*/
FACE_TOO_RIGHT = 8,
FACE_TOO_RIGHT,
/**
* Only the left part of the face was detected. The sensor's field of view
@@ -104,7 +110,7 @@ enum AcquiredInfo {
* The user should be informed to move to the left with respect to the
* sensor when this is returned.
*/
FACE_TOO_LEFT = 9,
FACE_TOO_LEFT,
/**
* The user's eyes have strayed away from the sensor. If this message is
@@ -112,7 +118,7 @@ enum AcquiredInfo {
* can't be found in the frame, one of the other acquisition messages
* must be sent, e.g. NOT_DETECTED.
*/
POOR_GAZE = 10,
POOR_GAZE,
/**
* No face was detected within the sensor's field of view.
@@ -120,7 +126,7 @@ enum AcquiredInfo {
* The user should be informed to point the sensor to a face when this is
* returned.
*/
NOT_DETECTED = 11,
NOT_DETECTED,
/**
* Too much motion was detected.
@@ -128,7 +134,7 @@ enum AcquiredInfo {
* The user should be informed to keep their face steady relative to the
* sensor.
*/
TOO_MUCH_MOTION = 12,
TOO_MUCH_MOTION,
/**
* The sensor needs to be re-calibrated. This is an unexpected condition,
@@ -137,20 +143,20 @@ enum AcquiredInfo {
* re-enrolling. The expected response to this message is to direct the
* user to re-enroll.
*/
RECALIBRATE = 13,
RECALIBRATE,
/**
* 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.
*/
TOO_DIFFERENT = 14,
TOO_DIFFERENT,
/**
* The face is too similar to a previous acquisition. This condition only
* applies to enrollment. The user should change their pose.
*/
TOO_SIMILAR = 15,
TOO_SIMILAR,
/**
* The magnitude of the pan angle of the users face with respect to the sensors
@@ -162,7 +168,7 @@ enum AcquiredInfo {
*
* The user should be informed to look more directly at the camera.
*/
PAN_TOO_EXTREME = 16,
PAN_TOO_EXTREME,
/**
* The magnitude of the tilt angle of the users face with respect to the sensors
@@ -173,7 +179,7 @@ enum AcquiredInfo {
*
* The user should be informed to look more directly at the camera.
*/
TILT_TOO_EXTREME = 17,
TILT_TOO_EXTREME,
/**
* The magnitude of the roll angle of the users face with respect to the sensors
@@ -185,7 +191,7 @@ enum AcquiredInfo {
*
* The user should be informed to look more directly at the camera.
*/
ROLL_TOO_EXTREME = 18,
ROLL_TOO_EXTREME,
/**
* The users face has been obscured by some object.
@@ -193,7 +199,7 @@ enum AcquiredInfo {
* The user should be informed to remove any objects from the line of sight from
* the sensor to the users face.
*/
FACE_OBSCURED = 19,
FACE_OBSCURED,
/**
* This message represents the earliest message sent at the beginning of the authentication
@@ -202,33 +208,33 @@ enum AcquiredInfo {
* will measure latency based on the time between the last START message and the onAuthenticated
* callback.
*/
START = 20,
START,
/**
* The sensor is dirty. The user should be informed to clean the sensor.
*/
SENSOR_DIRTY = 21,
SENSOR_DIRTY,
/**
* Vendor-specific acquisition message. See ISessionCallback#onAcquired vendorCode
* documentation.
*/
VENDOR = 22,
VENDOR,
/**
* The first frame from the camera has been received.
*/
FIRST_FRAME_RECEIVED = 23,
FIRST_FRAME_RECEIVED,
/**
* 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.
*/
DARK_GLASSES_DETECTED = 24,
DARK_GLASSES_DETECTED,
/**
* 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.
*/
MOUTH_COVERING_DETECTED = 25,
MOUTH_COVERING_DETECTED,
}

View File

@@ -23,7 +23,6 @@ import android.hardware.biometrics.face.BaseFrame;
*/
@VintfStability
parcelable AuthenticationFrame {
/**
* The frame metadata. Can be used by the framework to provide user feedback.
*/

View File

@@ -29,7 +29,7 @@ parcelable BaseFrame {
* Information about the frame that can be used by the framework to provide feedback to the
* user, for example ask the user to move their face in a certain way.
*/
AcquiredInfo acquiredInfo = AcquiredInfo.INSUFFICIENT;
AcquiredInfo acquiredInfo = AcquiredInfo.UNKNOWN;
/**
* If acquiredInfo is set to AcquiredInfo::VENDOR. This is the index into the configuration

View File

@@ -33,7 +33,7 @@ parcelable EnrollmentFrame {
/**
* The enrollment stage for which this frame was captured.
*/
EnrollmentStage stage = EnrollmentStage.FIRST_FRAME_RECEIVED;
EnrollmentStage stage = EnrollmentStage.UNKNOWN;
/**
* The frame metadata. Can be used by the framework to provide user feedback.

View File

@@ -22,34 +22,40 @@ package android.hardware.biometrics.face;
@VintfStability
@Backing(type="byte")
enum EnrollmentStage {
/**
* Placeholder value used for default initialization of EnrollmentStage. This
* value means EnrollmentStage wasn't explicitly initialized and must be
* discarded by the recipient.
*/
UNKNOWN,
/**
* HAL has obtained the first camera frame.
*/
FIRST_FRAME_RECEIVED,
/**
* HAL has obtained the first camera frame.
*/
FIRST_FRAME_RECEIVED,
/**
* HAL is waiting for the user's face to be centered.
*/
WAITING_FOR_CENTERING,
/**
* HAL is waiting for the user's face to be centered.
*/
WAITING_FOR_CENTERING,
/**
* HAL is expecting the user's face to stay centered.
*/
HOLD_STILL_IN_CENTER,
/**
* HAL is expecting the user's face to stay centered.
*/
HOLD_STILL_IN_CENTER,
/**
* Vendor defined movement 1.
*/
ENROLLING_MOVEMENT_1,
/**
* Vendor defined movement 1.
*/
ENROLLING_MOVEMENT_1,
/**
* Vendor defined movement 2.
*/
ENROLLING_MOVEMENT_2,
/**
* Vendor defined movement 2.
*/
ENROLLING_MOVEMENT_2,
/**
* HAL has finished the enrollment.
*/
ENROLLMENT_FINISHED,
/**
* HAL has finished the enrollment.
*/
ENROLLMENT_FINISHED,
}

View File

@@ -24,7 +24,7 @@ parcelable EnrollmentStageConfig {
/**
* The stage that's being configured.
*/
EnrollmentStage stage = EnrollmentStage.FIRST_FRAME_RECEIVED;
EnrollmentStage stage = EnrollmentStage.UNKNOWN;
/**
* Optional list of cells that must be completed to finish this stage.

View File

@@ -20,22 +20,22 @@ package android.hardware.biometrics.face;
@Backing(type="byte")
enum Error {
/**
* Reserved for testing and to keep subsequent numbering consistent with
* older interfaces.
*
* NO_ERROR = 0,
* Placeholder value used for default initialization of Error. This value
* means Error wasn't explicitly initialized and must be discarded by the
* recipient.
*/
UNKNOWN,
/**
* A hardware error has occurred that cannot be resolved. Try again later.
*/
HW_UNAVAILABLE = 1,
HW_UNAVAILABLE,
/**
* The current operation could not be completed, e.g. the sensor was unable
* to process the current image or the HAT was invalid.
*/
UNABLE_TO_PROCESS = 2,
UNABLE_TO_PROCESS,
/**
* The current operation took too long to complete. This is intended to
@@ -48,48 +48,34 @@ enum Error {
* indicate that the implementation is no longer looking and the framework
* should restart the operation on the next user interaction.
*/
TIMEOUT = 3,
TIMEOUT,
/**
* The current operation could not be completed because there is not enough
* storage space remaining to do so.
*/
NO_SPACE = 4,
NO_SPACE,
/**
* The current operation has been cancelled. This may happen if a new
* request (authenticate, remove, enumerate, enroll) is initiated while
* an on-going operation is in progress, or if cancel() was called.
*/
CANCELED = 5,
CANCELED,
/**
* The current remove operation could not be completed; the face template
* provided could not be removed.
*/
UNABLE_TO_REMOVE = 6,
/**
* Reserved to maintain backwards compatibility. See
* ISessionCallback#onLockoutTimed instead.
*
* LOCKOUT = 7,
*/
UNABLE_TO_REMOVE,
/**
* Used to enable a vendor-specific error message.
*/
VENDOR = 8,
/**
* Reserved to maintain backwards compatibility. See
* ISessionCallback#onLockoutPermanent instead.
*
* LOCKOUT_PERMANENT = 9
*/
VENDOR,
/**
* Authentication cannot be performed because re-enrollment is required.
*/
REENROLL_REQUIRED = 16,
REENROLL_REQUIRED,
}

View File

@@ -17,6 +17,7 @@
package android.hardware.biometrics.face;
import android.hardware.biometrics.common.ICancellationSignal;
import android.hardware.biometrics.face.EnrollmentStageConfig;
import android.hardware.biometrics.face.EnrollmentType;
import android.hardware.biometrics.face.Feature;
import android.hardware.common.NativeHandle;
@@ -104,9 +105,9 @@ interface ISession {
* each of the stages.
*
* @param enrollmentType See the EnrollmentType enum.
* @return A list of EnrollmentStageConfig that describes each enrollment stage.
*
List<EnrollmentStageConfig> getEnrollmentConfig(in EnrollmentType enrollmentType);
* @return An EnrollmentStageConfig array that describes each enrollment stage.
*/
EnrollmentStageConfig[] getEnrollmentConfig(in EnrollmentType enrollmentType);
/**
* enroll:

View File

@@ -29,7 +29,7 @@ parcelable SensorProps {
/**
* A statically configured sensor type representing this face sensor.
*/
FaceSensorType sensorType = FaceSensorType.RGB;
FaceSensorType sensorType = FaceSensorType.UNKNOWN;
/**
* Whether or not the HAL is responsible for showing the face enrollment preview to the user.

View File

@@ -52,6 +52,12 @@ ndk::ScopedAStatus Session::revokeChallenge(int64_t challenge) {
return ndk::ScopedAStatus::ok();
}
ndk::ScopedAStatus Session::getEnrollmentConfig(EnrollmentType /*enrollmentType*/,
std::vector<EnrollmentStageConfig>* return_val) {
*return_val = {};
return ndk::ScopedAStatus::ok();
}
ndk::ScopedAStatus Session::enroll(
const keymaster::HardwareAuthToken& /*hat*/, EnrollmentType /*enrollmentType*/,
const std::vector<Feature>& /*features*/, const NativeHandle& /*previewSurface*/,

View File

@@ -34,6 +34,9 @@ class Session : public BnSession {
ndk::ScopedAStatus revokeChallenge(int64_t challenge) override;
ndk::ScopedAStatus getEnrollmentConfig(EnrollmentType enrollmentType,
std::vector<EnrollmentStageConfig>* return_val) override;
ndk::ScopedAStatus enroll(const keymaster::HardwareAuthToken& hat,
EnrollmentType enrollmentType, const std::vector<Feature>& features,
const NativeHandle& previewSurface,