From 7bd42e1b14baccde7eb584541181eaec0612a64a Mon Sep 17 00:00:00 2001 From: Joe Bolinger Date: Wed, 12 Jan 2022 16:27:03 -0800 Subject: [PATCH] Update common and face AIDL for session logging. Bug: 204585936 Bug: 204584403 Test: atest VtsHalBiometricsFaceTargetTest Change-Id: Icba064c5c48f808327323ab64b7b63f68737a2f8 --- biometrics/face/aidl/Android.bp | 2 +- .../hardware/biometrics/face/ISession.aidl | 3 +++ .../hardware/biometrics/face/ISession.aidl | 20 ++++++++++++++++++ biometrics/face/aidl/default/Android.bp | 4 ++-- biometrics/face/aidl/default/Session.cpp | 21 +++++++++++++++++++ biometrics/face/aidl/default/Session.h | 14 +++++++++++++ biometrics/face/aidl/default/face-default.xml | 1 + biometrics/face/aidl/vts/Android.bp | 4 ++-- .../compatibility_matrix.current.xml | 1 + 9 files changed, 65 insertions(+), 5 deletions(-) diff --git a/biometrics/face/aidl/Android.bp b/biometrics/face/aidl/Android.bp index 3f53fc8cdf..fff2c1d3d4 100644 --- a/biometrics/face/aidl/Android.bp +++ b/biometrics/face/aidl/Android.bp @@ -16,7 +16,7 @@ aidl_interface { imports: [ "android.hardware.biometrics.common", "android.hardware.common-V2", - "android.hardware.keymaster", + "android.hardware.keymaster-V3", ], stability: "vintf", backend: { diff --git a/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/ISession.aidl b/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/ISession.aidl index 78178642cd..4b51bb17cc 100644 --- a/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/ISession.aidl +++ b/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/ISession.aidl @@ -48,4 +48,7 @@ interface ISession { void invalidateAuthenticatorId(); 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); + 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); } diff --git a/biometrics/face/aidl/android/hardware/biometrics/face/ISession.aidl b/biometrics/face/aidl/android/hardware/biometrics/face/ISession.aidl index 5f06b408e8..bbe3632b6b 100644 --- a/biometrics/face/aidl/android/hardware/biometrics/face/ISession.aidl +++ b/biometrics/face/aidl/android/hardware/biometrics/face/ISession.aidl @@ -17,6 +17,7 @@ package android.hardware.biometrics.face; 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.Feature; @@ -441,4 +442,23 @@ interface ISession { * - ISessionCallback#onSessionClosed */ void close(); + + /** + * These are alternative methods for some operations to allow the HAL to make optional + * optimizations during execution. + * + * HALs may ignore the additional context and treat all *WithContext methods the same as + * the original methods. + */ + + /* See ISession#authenticateWithContext(long) */ + ICancellationSignal authenticateWithContext(in long operationId, in OperationContext context); + + /* See ISession#enroll(HardwareAuthToken, EnrollmentType, Feature[], NativeHandle) */ + ICancellationSignal enrollWithContext(in HardwareAuthToken hat, in EnrollmentType type, + in Feature[] features, in @nullable NativeHandle previewSurface, + in OperationContext context); + + /* See ISession#detectInteraction() */ + ICancellationSignal detectInteractionWithContext(in OperationContext context); } diff --git a/biometrics/face/aidl/default/Android.bp b/biometrics/face/aidl/default/Android.bp index 509231859d..7f66ecaf83 100644 --- a/biometrics/face/aidl/default/Android.bp +++ b/biometrics/face/aidl/default/Android.bp @@ -16,8 +16,8 @@ cc_binary { shared_libs: [ "libbase", "libbinder_ndk", - "android.hardware.biometrics.face-V1-ndk", - "android.hardware.biometrics.common-V1-ndk", + "android.hardware.biometrics.face-V2-ndk", + "android.hardware.biometrics.common-V2-ndk", ], srcs: [ "main.cpp", diff --git a/biometrics/face/aidl/default/Session.cpp b/biometrics/face/aidl/default/Session.cpp index 01cb620b35..9e753e5c33 100644 --- a/biometrics/face/aidl/default/Session.cpp +++ b/biometrics/face/aidl/default/Session.cpp @@ -151,4 +151,25 @@ ndk::ScopedAStatus Session::close() { return ndk::ScopedAStatus::ok(); } +ndk::ScopedAStatus Session::authenticateWithContext( + int64_t operationId, const common::OperationContext& /*context*/, + std::shared_ptr* out) { + return authenticate(operationId, out); +} + +ndk::ScopedAStatus Session::enrollWithContext(const keymaster::HardwareAuthToken& hat, + EnrollmentType enrollmentType, + const std::vector& features, + const std::optional& previewSurface, + const common::OperationContext& /*context*/, + std::shared_ptr* out) { + return enroll(hat, enrollmentType, features, previewSurface, out); +} + +ndk::ScopedAStatus Session::detectInteractionWithContext( + const common::OperationContext& /*context*/, + std::shared_ptr* out) { + return detectInteraction(out); +} + } // namespace aidl::android::hardware::biometrics::face diff --git a/biometrics/face/aidl/default/Session.h b/biometrics/face/aidl/default/Session.h index 4152909a49..0ce9e2060e 100644 --- a/biometrics/face/aidl/default/Session.h +++ b/biometrics/face/aidl/default/Session.h @@ -68,6 +68,20 @@ class Session : public BnSession { ndk::ScopedAStatus close() override; + ndk::ScopedAStatus authenticateWithContext( + int64_t operationId, const common::OperationContext& context, + std::shared_ptr* out) override; + + ndk::ScopedAStatus enrollWithContext( + const keymaster::HardwareAuthToken& hat, EnrollmentType enrollmentType, + const std::vector& features, const std::optional& previewSurface, + const common::OperationContext& context, + std::shared_ptr* out) override; + + ndk::ScopedAStatus detectInteractionWithContext( + const common::OperationContext& context, + std::shared_ptr* out) override; + private: std::shared_ptr cb_; std::mt19937 mRandom; diff --git a/biometrics/face/aidl/default/face-default.xml b/biometrics/face/aidl/default/face-default.xml index 6915ad0a4d..e6ef842734 100644 --- a/biometrics/face/aidl/default/face-default.xml +++ b/biometrics/face/aidl/default/face-default.xml @@ -1,6 +1,7 @@ android.hardware.biometrics.face + 2 IFace/default diff --git a/biometrics/face/aidl/vts/Android.bp b/biometrics/face/aidl/vts/Android.bp index 09ec4d06e3..4171ac3364 100644 --- a/biometrics/face/aidl/vts/Android.bp +++ b/biometrics/face/aidl/vts/Android.bp @@ -15,8 +15,8 @@ cc_test { ], srcs: ["VtsHalBiometricsFaceTargetTest.cpp"], static_libs: [ - "android.hardware.biometrics.common-V1-ndk", - "android.hardware.biometrics.face-V1-ndk", + "android.hardware.biometrics.common-V2-ndk", + "android.hardware.biometrics.face-V2-ndk", "android.hardware.common-V2-ndk", "android.hardware.keymaster-V3-ndk", ], diff --git a/compatibility_matrices/compatibility_matrix.current.xml b/compatibility_matrices/compatibility_matrix.current.xml index cf856889df..2762bf1de5 100644 --- a/compatibility_matrices/compatibility_matrix.current.xml +++ b/compatibility_matrices/compatibility_matrix.current.xml @@ -110,6 +110,7 @@ android.hardware.biometrics.face + 2 IFace default