Merge "Updated face session to use SurfaceView" into main

This commit is contained in:
Joshua Mccloskey 2023-11-10 19:37:44 +00:00 committed by Android (Google) Code Review
commit ad69b8158b
17 changed files with 248 additions and 96 deletions

View file

@ -18,6 +18,9 @@ aidl_interface {
"android.hardware.common-V2",
"android.hardware.keymaster-V4",
],
include_dirs: [
"frameworks/native/aidl/gui",
],
stability: "vintf",
backend: {
java: {
@ -26,6 +29,11 @@ aidl_interface {
cpp: {
enabled: false,
},
ndk: {
additional_shared_libraries: [
"libnativewindow",
],
},
},
versions_with_info: [
{
@ -54,6 +62,6 @@ aidl_interface {
},
],
frozen: true,
frozen: false,
}

View file

@ -34,31 +34,31 @@
package android.hardware.biometrics.face;
@Backing(type="byte") @VintfStability
enum AcquiredInfo {
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,
UNKNOWN,
GOOD,
INSUFFICIENT,
TOO_BRIGHT,
TOO_DARK,
TOO_CLOSE,
TOO_FAR,
FACE_TOO_HIGH,
FACE_TOO_LOW,
FACE_TOO_RIGHT,
FACE_TOO_LEFT,
POOR_GAZE,
NOT_DETECTED,
TOO_MUCH_MOTION,
RECALIBRATE,
TOO_DIFFERENT,
TOO_SIMILAR,
PAN_TOO_EXTREME,
TILT_TOO_EXTREME,
ROLL_TOO_EXTREME,
FACE_OBSCURED,
START,
SENSOR_DIRTY,
VENDOR,
FIRST_FRAME_RECEIVED,
DARK_GLASSES_DETECTED,
MOUTH_COVERING_DETECTED,
}

View file

@ -34,11 +34,11 @@
package android.hardware.biometrics.face;
@Backing(type="byte") @VintfStability
enum EnrollmentStage {
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,
UNKNOWN,
FIRST_FRAME_RECEIVED,
WAITING_FOR_CENTERING,
HOLD_STILL_IN_CENTER,
ENROLLING_MOVEMENT_1,
ENROLLING_MOVEMENT_2,
ENROLLMENT_FINISHED,
}

View file

@ -34,6 +34,6 @@
package android.hardware.biometrics.face;
@Backing(type="byte") @VintfStability
enum EnrollmentType {
DEFAULT = 0,
ACCESSIBILITY = 1,
DEFAULT,
ACCESSIBILITY,
}

View file

@ -34,13 +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 = 7,
REENROLL_REQUIRED = 8,
UNKNOWN,
HW_UNAVAILABLE,
UNABLE_TO_PROCESS,
TIMEOUT,
NO_SPACE,
CANCELED,
UNABLE_TO_REMOVE,
VENDOR,
REENROLL_REQUIRED,
}

View file

@ -0,0 +1,46 @@
/*
* Copyright (C) 2023 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.
*/
///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
// This file is a snapshot of an AIDL file. Do not edit it manually. There are
// two cases:
// 1). this is a frozen version file - do not edit this in any case.
// 2). this is a 'current' file. If you make a backwards compatible change to
// the interface (from the latest frozen version), the build system will
// prompt you to update this file with `m <name>-update-api`.
//
// You must not make a backward incompatible change to any AIDL file built
// with the aidl_interface module type with versions property set. The module
// type is used to build AIDL files in a way that they can be used across
// independently updatable components of the system. If a device is shipped
// with such a backward incompatible change, it has a high risk of breaking
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.biometrics.face;
@VintfStability
parcelable FaceEnrollOptions {
android.hardware.keymaster.HardwareAuthToken hardwareAuthToken;
android.hardware.biometrics.face.EnrollmentType enrollmentType;
android.hardware.biometrics.face.Feature[] features;
/**
* @deprecated use {@link surfacePreview} instead {@link NativeHandle} a handle used to render content from the face HAL. Note that only one of [{@link surfacePreview}, {@link nativeHandlePreview}] should be set at one time.
*/
@nullable android.hardware.common.NativeHandle nativeHandlePreview;
@nullable android.view.Surface surfacePreview;
@nullable android.hardware.biometrics.common.OperationContext context;
}

View file

@ -34,7 +34,7 @@
package android.hardware.biometrics.face;
@Backing(type="byte") @VintfStability
enum FaceSensorType {
UNKNOWN = 0,
RGB = 1,
IR = 2,
UNKNOWN,
RGB,
IR,
}

View file

@ -34,7 +34,7 @@
package android.hardware.biometrics.face;
@Backing(type="byte") @VintfStability
enum Feature {
REQUIRE_ATTENTION = 0,
REQUIRE_DIVERSE_POSES = 1,
DEBUG = 2,
REQUIRE_ATTENTION,
REQUIRE_DIVERSE_POSES,
DEBUG,
}

View file

@ -37,6 +37,9 @@ interface ISession {
void generateChallenge();
void revokeChallenge(in long challenge);
android.hardware.biometrics.face.EnrollmentStageConfig[] getEnrollmentConfig(in android.hardware.biometrics.face.EnrollmentType enrollmentType);
/**
* @deprecated use {@link enrollWithOptions} instead.
*/
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 @nullable android.hardware.common.NativeHandle previewSurface);
android.hardware.biometrics.common.ICancellationSignal authenticate(in long operationId);
android.hardware.biometrics.common.ICancellationSignal detectInteraction();
@ -49,7 +52,11 @@ interface ISession {
void resetLockout(in android.hardware.keymaster.HardwareAuthToken hat);
void close();
android.hardware.biometrics.common.ICancellationSignal authenticateWithContext(in long operationId, in android.hardware.biometrics.common.OperationContext context);
/**
* @deprecated use {@link enrollWithOptions} instead.
*/
android.hardware.biometrics.common.ICancellationSignal enrollWithContext(in android.hardware.keymaster.HardwareAuthToken hat, in android.hardware.biometrics.face.EnrollmentType type, in android.hardware.biometrics.face.Feature[] features, in @nullable android.hardware.common.NativeHandle previewSurface, in android.hardware.biometrics.common.OperationContext context);
android.hardware.biometrics.common.ICancellationSignal detectInteractionWithContext(in android.hardware.biometrics.common.OperationContext context);
void onContextChanged(in android.hardware.biometrics.common.OperationContext context);
android.hardware.biometrics.common.ICancellationSignal enrollWithOptions(in android.hardware.biometrics.face.FaceEnrollOptions options);
}

View file

@ -0,0 +1,69 @@
/*
* Copyright (C) 2023 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.face;
import android.hardware.biometrics.common.OperationContext;
import android.hardware.biometrics.face.EnrollmentStageConfig;
import android.hardware.biometrics.face.EnrollmentType;
import android.hardware.biometrics.face.Feature;
import android.hardware.common.NativeHandle;
import android.hardware.keymaster.HardwareAuthToken;
import android.view.Surface;
/**
* Enroll options used to pass information to the HAL when requesting an enroll operation.
*/
@VintfStability
parcelable FaceEnrollOptions {
/**
* See {@link HardwareAuthToken}.
*/
HardwareAuthToken hardwareAuthToken;
/**
* See {@link EnrollmentType}
*/
EnrollmentType enrollmentType;
/**
* See {@link Feature}
*/
Feature[] features;
/**
* @deprecated use {@link surfacePreview} instead
*
* {@link NativeHandle} a handle used to render content from the face HAL.
*
* Note that only one of [{@link surfacePreview}, {@link nativeHandlePreview}]
* should be set at one time.
*/
@nullable NativeHandle nativeHandlePreview;
/**
* {@link Surface} a surface used to render content from the face HAL.
*
* Note that only one of [{@link surfacePreview}, {@link nativeHandlePreview}]
* should be set at one time.
*/
@nullable Surface surfacePreview;
/**
* See {@link OperationContext}
*/
@nullable OperationContext context;
}

View file

@ -20,6 +20,7 @@ import android.hardware.biometrics.common.ICancellationSignal;
import android.hardware.biometrics.common.OperationContext;
import android.hardware.biometrics.face.EnrollmentStageConfig;
import android.hardware.biometrics.face.EnrollmentType;
import android.hardware.biometrics.face.FaceEnrollOptions;
import android.hardware.biometrics.face.Feature;
import android.hardware.common.NativeHandle;
import android.hardware.keymaster.HardwareAuthToken;
@ -115,44 +116,7 @@ interface ISession {
EnrollmentStageConfig[] getEnrollmentConfig(in EnrollmentType enrollmentType);
/**
* enroll:
*
* A request to add a face enrollment.
*
* At any point during enrollment, if a non-recoverable error occurs, the HAL must notify the
* framework via ISessionCallback#onError with the applicable enrollment-specific error.
*
* Before capturing face data, the HAL must first verify the authenticity and integrity of the
* provided HardwareAuthToken. In addition, it must check that the challenge within the provided
* HardwareAuthToken is valid. See ISession#generateChallenge. If any of the above checks fail,
* the framework must be notified using ISessionCallback#onError with Error::UNABLE_TO_PROCESS.
*
* During enrollment, the HAL may notify the framework via ISessionCallback#onAcquired with
* messages that may be used to guide the user. This callback can be invoked multiple times if
* necessary. Similarly, the framework may be notified of enrollment progress changes via
* ISessionCallback#onEnrollmentProgress. Once the framework is notified that there are 0
* "remaining" steps, the framework may cache the "enrollmentId". See
* ISessionCallback#onEnrollmentProgress for more info.
*
* When a face is successfully added and before the framework is notified of remaining=0, the
* HAL must update and associate this (sensorId, userId) pair with a new entropy-encoded random
* identifier. See ISession#getAuthenticatorId for more information.
*
* Callbacks that signify the end of this operation's lifecycle:
* - ISessionCallback#onError
* - ISessionCallback#onEnrollmentProgress(enrollmentId, remaining=0)
*
* Other applicable callbacks:
* - ISessionCallback#onAcquired
*
* @param hat See above documentation.
* @param enrollmentType See the EnrollmentType enum.
* @param features See the Feature enum.
* @param previewSurface A surface provided by the framework if SensorProps#halControlsPreview
* is set to true. The HAL must send the preview frames to previewSurface
* if it's not null.
* @return ICancellationSignal An object that can be used by the framework to cancel this
* operation.
* @deprecated use {@link enrollWithOptions} instead.
*/
ICancellationSignal enroll(in HardwareAuthToken hat, in EnrollmentType type,
in Feature[] features, in @nullable NativeHandle previewSurface);
@ -456,7 +420,9 @@ interface ISession {
/* See ISession#authenticateWithContext(long) */
ICancellationSignal authenticateWithContext(in long operationId, in OperationContext context);
/* See ISession#enroll(HardwareAuthToken, EnrollmentType, Feature[], NativeHandle) */
/*
* @deprecated use {@link enrollWithOptions} instead.
*/
ICancellationSignal enrollWithContext(in HardwareAuthToken hat, in EnrollmentType type,
in Feature[] features, in @nullable NativeHandle previewSurface,
in OperationContext context);
@ -469,4 +435,41 @@ interface ISession {
* running when the context changes.
*/
void onContextChanged(in OperationContext context);
/**
* enrollWithOptions:
*
* A request to add a face enrollment.
*
* At any point during enrollment, if a non-recoverable error occurs, the HAL must notify the
* framework via ISessionCallback#onError with the applicable enrollment-specific error.
*
* Before capturing face data, the HAL must first verify the authenticity and integrity of the
* provided HardwareAuthToken. In addition, it must check that the challenge within the provided
* HardwareAuthToken is valid. See ISession#generateChallenge. If any of the above checks fail,
* the framework must be notified using ISessionCallback#onError with Error::UNABLE_TO_PROCESS.
*
* During enrollment, the HAL may notify the framework via ISessionCallback#onAcquired with
* messages that may be used to guide the user. This callback can be invoked multiple times if
* necessary. Similarly, the framework may be notified of enrollment progress changes via
* ISessionCallback#onEnrollmentProgress. Once the framework is notified that there are 0
* "remaining" steps, the framework may cache the "enrollmentId". See
* ISessionCallback#onEnrollmentProgress for more info.
*
* When a face is successfully added and before the framework is notified of remaining=0, the
* HAL must update and associate this (sensorId, userId) pair with a new entropy-encoded random
* identifier. See ISession#getAuthenticatorId for more information.
*
* Callbacks that signify the end of this operation's lifecycle:
* - ISessionCallback#onError
* - ISessionCallback#onEnrollmentProgress(enrollmentId, remaining=0)
*
* Other applicable callbacks:
* - ISessionCallback#onAcquired
*
* @param FaceEnrollOptions See {@link FaceEnrollOptions} for more detail.
* @return ICancellationSignal An object that can be used by the framework to cancel this
* operation.
*/
ICancellationSignal enrollWithOptions(in FaceEnrollOptions options);
}

View file

@ -27,6 +27,7 @@ cc_binary {
shared_libs: [
"libbinder_ndk",
"liblog",
"libnativewindow",
],
srcs: [
"main.cpp",
@ -34,12 +35,15 @@ cc_binary {
"FakeFaceEngine.cpp",
"Session.cpp",
],
include_dirs: [
"frameworks/native/aidl/gui",
],
stl: "c++_static",
static_libs: [
"android.hardware.biometrics.common-V3-ndk",
"android.hardware.biometrics.common.thread",
"android.hardware.biometrics.common.util",
"android.hardware.biometrics.face-V3-ndk",
"android.hardware.biometrics.face-V4-ndk",
"android.hardware.common-V2-ndk",
"android.hardware.keymaster-V4-ndk",
"libandroid.hardware.biometrics.face.VirtualProps",
@ -63,10 +67,14 @@ cc_test {
shared_libs: [
"libbase",
"libbinder_ndk",
"libnativewindow",
],
include_dirs: [
"frameworks/native/aidl/gui",
],
static_libs: [
"libandroid.hardware.biometrics.face.VirtualProps",
"android.hardware.biometrics.face-V3-ndk",
"android.hardware.biometrics.face-V4-ndk",
"android.hardware.biometrics.common-V3-ndk",
"android.hardware.keymaster-V4-ndk",
"android.hardware.biometrics.common.util",

View file

@ -175,4 +175,10 @@ ndk::ScopedAStatus Session::onContextChanged(const common::OperationContext& /*c
return ndk::ScopedAStatus::ok();
}
ndk::ScopedAStatus Session::enrollWithOptions(const FaceEnrollOptions& options,
std::shared_ptr<common::ICancellationSignal>* out) {
return enroll(options.hardwareAuthToken, options.enrollmentType, options.features,
options.nativeHandlePreview, out);
}
} // namespace aidl::android::hardware::biometrics::face

View file

@ -19,6 +19,7 @@
#include <random>
#include <aidl/android/hardware/biometrics/face/BnSession.h>
#include <aidl/android/hardware/biometrics/face/FaceEnrollOptions.h>
#include <aidl/android/hardware/biometrics/face/ISessionCallback.h>
#include "FakeFaceEngine.h"
@ -88,6 +89,10 @@ class Session : public BnSession {
ndk::ScopedAStatus onContextChanged(const common::OperationContext& context) override;
ndk::ScopedAStatus enrollWithOptions(
const FaceEnrollOptions& options,
std::shared_ptr<common::ICancellationSignal>* out) override;
private:
std::unique_ptr<FakeFaceEngine> mEngine;
std::shared_ptr<ISessionCallback> mCb;

View file

@ -1,4 +1,4 @@
{
"name": "com.android.hardware.biometrics.face.virtual",
"version": 1
"version": 2
}

View file

@ -1,7 +1,7 @@
<manifest version="1.0" type="device">
<hal format="aidl">
<name>android.hardware.biometrics.face</name>
<version>3</version>
<version>4</version>
<fqname>IFace/virtual</fqname>
</hal>
</manifest>

View file

@ -117,7 +117,7 @@
</hal>
<hal format="aidl" optional="true" updatable-via-apex="true">
<name>android.hardware.biometrics.face</name>
<version>3</version>
<version>3-4</version>
<interface>
<name>IFace</name>
<instance>default</instance>