From 3041e526de57e76f2861b04e3b62a10b1408d851 Mon Sep 17 00:00:00 2001 From: Joe Bolinger Date: Fri, 15 Apr 2022 17:50:08 -0700 Subject: [PATCH] Declare example HAL as virtual instance. Bug: 228638448 Test: manual (see README.md) Change-Id: I4c00b9e394eb7863416b61662528869f7e70c09d --- .../fingerprint/aidl/default/Android.bp | 4 +- biometrics/fingerprint/aidl/default/README.md | 56 ++++++++++++------- ...rint-default.rc => fingerprint-example.rc} | 3 +- ...nt-default.xml => fingerprint-example.xml} | 2 +- biometrics/fingerprint/aidl/default/main.cpp | 2 +- .../compatibility_matrix.current.xml | 1 + 6 files changed, 41 insertions(+), 27 deletions(-) rename biometrics/fingerprint/aidl/default/{fingerprint-default.rc => fingerprint-example.rc} (57%) rename biometrics/fingerprint/aidl/default/{fingerprint-default.xml => fingerprint-example.xml} (79%) diff --git a/biometrics/fingerprint/aidl/default/Android.bp b/biometrics/fingerprint/aidl/default/Android.bp index e6628f29fc..70fadfecc6 100644 --- a/biometrics/fingerprint/aidl/default/Android.bp +++ b/biometrics/fingerprint/aidl/default/Android.bp @@ -11,8 +11,8 @@ cc_binary { name: "android.hardware.biometrics.fingerprint-service.example", vendor: true, relative_install_path: "hw", - init_rc: ["fingerprint-default.rc"], - vintf_fragments: ["fingerprint-default.xml"], + init_rc: ["fingerprint-example.rc"], + vintf_fragments: ["fingerprint-example.xml"], local_include_dirs: ["include"], srcs: [ "CancellationSignal.cpp", diff --git a/biometrics/fingerprint/aidl/default/README.md b/biometrics/fingerprint/aidl/default/README.md index 046602f00f..a6e6b81926 100644 --- a/biometrics/fingerprint/aidl/default/README.md +++ b/biometrics/fingerprint/aidl/default/README.md @@ -1,17 +1,30 @@ # Virtual Fingerprint HAL -This is a virtual HAL implementation that is backed by system properties -instead of actual hardware. It's intended for testing and UI development -on debuggable builds to allow devices to masquerade as alternative device -types and for emulators. +This is a virtual HAL implementation that is backed by system properties instead +of actual hardware. It's intended for testing and UI development on debuggable +builds to allow devices to masquerade as alternative device types and for +emulators. + +## Supported Devices + +This HAL can be used on emulators, like cuttlefish, or on real devices. Add the +following to your device's `.mk` file to include it: + +``` +PRODUCT_PACKAGES_DEBUG += android.hardware.biometrics.fingerprint-service.example +``` + +The virtual HAL will be ignored if a real HAL is also installed on the target +device. Set the `biometric_virtual_enabled` settings and reboot the device to +switch to the virtual HAL. Unset it and reboot again to switch back. ## Getting Started First, set the type of sensor the device should use, enable the virtual extensions in the framework, and reboot. -This doesn't work with HIDL and you typically need to have a PIN or password -set for things to work correctly, so this is a good time to set those too. +This doesn't work with HIDL and you typically need to have a PIN or password set +for things to work correctly, so this is a good time to set those too. ```shell $ adb root @@ -24,22 +37,23 @@ $ adb reboot ### Enrollments -Next, setup enrollments on the device. This can either be done through -the UI, or via adb. +Next, setup enrollments on the device. This can either be done through the UI, +or via adb. #### UI Enrollment - 1. Tee up the results of the enrollment before starting the process: +1. Tee up the results of the enrollment before starting the process: - ```shell - $ adb shell setprop vendor.fingerprint.virtual.next_enrollment 1:100,100,100:true - ``` - 2. Navigate to `Settings -> Security -> Fingerprint Unlock` and follow the prompts. - 3. Verify the enrollments in the UI: + ```shell + $ adb shell setprop vendor.fingerprint.virtual.next_enrollment 1:100,100,100:true + ``` +2. Navigate to `Settings -> Security -> Fingerprint Unlock` and follow the + prompts. +3. Verify the enrollments in the UI: - ```shell - $ adb shell getprop persist.vendor.fingerprint.virtual.enrollments - ``` + ```shell + $ adb shell getprop persist.vendor.fingerprint.virtual.enrollments + ``` #### Direct Enrollment @@ -51,10 +65,10 @@ $ adb shell setprop persist.vendor.fingerprint.virtual.enrollments 1 $ adb shell cmd fingerprint sync ``` -Note: You may need to do this twice. The templates are checked -as part of some lazy operations, like user switching and startup, which can -cause the framework to delete the enrollments before the sync operation runs. -Until this is fixed, just run the commands twice as a workaround. +**Note: You may need to do this twice.** The templates are checked as part of +some lazy operations, like user switching and startup, which can cause the +framework to delete the enrollments before the sync operation runs. Until this +is fixed, just run the commands twice as a workaround. ### Authenticate diff --git a/biometrics/fingerprint/aidl/default/fingerprint-default.rc b/biometrics/fingerprint/aidl/default/fingerprint-example.rc similarity index 57% rename from biometrics/fingerprint/aidl/default/fingerprint-default.rc rename to biometrics/fingerprint/aidl/default/fingerprint-example.rc index eb62c567fd..574438edbb 100644 --- a/biometrics/fingerprint/aidl/default/fingerprint-default.rc +++ b/biometrics/fingerprint/aidl/default/fingerprint-example.rc @@ -1,5 +1,4 @@ -service vendor.fingerprint-default /vendor/bin/hw/android.hardware.biometrics.fingerprint-service.example +service vendor.fingerprint-example /vendor/bin/hw/android.hardware.biometrics.fingerprint-service.example class hal user nobody group nobody - diff --git a/biometrics/fingerprint/aidl/default/fingerprint-default.xml b/biometrics/fingerprint/aidl/default/fingerprint-example.xml similarity index 79% rename from biometrics/fingerprint/aidl/default/fingerprint-default.xml rename to biometrics/fingerprint/aidl/default/fingerprint-example.xml index d322eb65b3..05d1279e58 100644 --- a/biometrics/fingerprint/aidl/default/fingerprint-default.xml +++ b/biometrics/fingerprint/aidl/default/fingerprint-example.xml @@ -2,6 +2,6 @@ android.hardware.biometrics.fingerprint 2 - IFingerprint/default + IFingerprint/virtual diff --git a/biometrics/fingerprint/aidl/default/main.cpp b/biometrics/fingerprint/aidl/default/main.cpp index c985201d63..0e672b10ab 100644 --- a/biometrics/fingerprint/aidl/default/main.cpp +++ b/biometrics/fingerprint/aidl/default/main.cpp @@ -27,7 +27,7 @@ int main() { ABinderProcess_setThreadPoolMaxThreadCount(0); std::shared_ptr hal = ndk::SharedRefBase::make(); - const std::string instance = std::string(Fingerprint::descriptor) + "/default"; + const std::string instance = std::string(Fingerprint::descriptor) + "/virtual"; binder_status_t status = AServiceManager_addService(hal->asBinder().get(), instance.c_str()); CHECK_EQ(status, STATUS_OK); diff --git a/compatibility_matrices/compatibility_matrix.current.xml b/compatibility_matrices/compatibility_matrix.current.xml index e3b17f508f..c49aaab600 100644 --- a/compatibility_matrices/compatibility_matrix.current.xml +++ b/compatibility_matrices/compatibility_matrix.current.xml @@ -142,6 +142,7 @@ IFingerprint default + virtual