Declare example HAL as virtual instance.
Bug: 228638448
Test: manual (see README.md)
Change-Id: I4c00b9e394eb7863416b61662528869f7e70c09d
diff --git a/biometrics/fingerprint/aidl/default/Android.bp b/biometrics/fingerprint/aidl/default/Android.bp
index e6628f2..70fadfe 100644
--- a/biometrics/fingerprint/aidl/default/Android.bp
+++ b/biometrics/fingerprint/aidl/default/Android.bp
@@ -11,8 +11,8 @@
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 046602f..a6e6b81 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 @@
### 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 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-default.rc
deleted file mode 100644
index eb62c56..0000000
--- a/biometrics/fingerprint/aidl/default/fingerprint-default.rc
+++ /dev/null
@@ -1,5 +0,0 @@
-service vendor.fingerprint-default /vendor/bin/hw/android.hardware.biometrics.fingerprint-service.example
- class hal
- user nobody
- group nobody
-
diff --git a/biometrics/fingerprint/aidl/default/fingerprint-example.rc b/biometrics/fingerprint/aidl/default/fingerprint-example.rc
new file mode 100644
index 0000000..574438e
--- /dev/null
+++ b/biometrics/fingerprint/aidl/default/fingerprint-example.rc
@@ -0,0 +1,4 @@
+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 d322eb6..05d1279 100644
--- a/biometrics/fingerprint/aidl/default/fingerprint-default.xml
+++ b/biometrics/fingerprint/aidl/default/fingerprint-example.xml
@@ -2,6 +2,6 @@
<hal format="aidl">
<name>android.hardware.biometrics.fingerprint</name>
<version>2</version>
- <fqname>IFingerprint/default</fqname>
+ <fqname>IFingerprint/virtual</fqname>
</hal>
</manifest>
diff --git a/biometrics/fingerprint/aidl/default/main.cpp b/biometrics/fingerprint/aidl/default/main.cpp
index c985201..0e672b1 100644
--- a/biometrics/fingerprint/aidl/default/main.cpp
+++ b/biometrics/fingerprint/aidl/default/main.cpp
@@ -27,7 +27,7 @@
ABinderProcess_setThreadPoolMaxThreadCount(0);
std::shared_ptr<Fingerprint> hal = ndk::SharedRefBase::make<Fingerprint>();
- 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 e3b17f5..c49aaab 100644
--- a/compatibility_matrices/compatibility_matrix.current.xml
+++ b/compatibility_matrices/compatibility_matrix.current.xml
@@ -142,6 +142,7 @@
<interface>
<name>IFingerprint</name>
<instance>default</instance>
+ <instance>virtual</instance>
</interface>
</hal>
<hal format="hidl" optional="true">