xref: /aosp_15_r20/hardware/interfaces/biometrics/fingerprint/aidl/default/README.md (revision 4d7e907c777eeecc4c5bd7cf640a754fac206ff7)
1*4d7e907cSAndroid Build Coastguard Worker# Virtual Fingerprint HAL
2*4d7e907cSAndroid Build Coastguard Worker
3*4d7e907cSAndroid Build Coastguard WorkerThis is a virtual HAL implementation that is backed by system properties instead
4*4d7e907cSAndroid Build Coastguard Workerof actual hardware. It's intended for testing and UI development on debuggable
5*4d7e907cSAndroid Build Coastguard Workerbuilds to allow devices to masquerade as alternative device types and for
6*4d7e907cSAndroid Build Coastguard Workeremulators.
7*4d7e907cSAndroid Build Coastguard Worker
8*4d7e907cSAndroid Build Coastguard Worker## Supported Devices
9*4d7e907cSAndroid Build Coastguard Worker
10*4d7e907cSAndroid Build Coastguard WorkerThis HAL can be used on emulators, like cuttlefish, or on real devices. Add the
11*4d7e907cSAndroid Build Coastguard Workerfollowing to your device's `.mk` file to include it:
12*4d7e907cSAndroid Build Coastguard Worker
13*4d7e907cSAndroid Build Coastguard Worker```
14*4d7e907cSAndroid Build Coastguard WorkerPRODUCT_PACKAGES_DEBUG += com.android.hardware.biometrics.fingerprint.virtual
15*4d7e907cSAndroid Build Coastguard Worker```
16*4d7e907cSAndroid Build Coastguard Worker
17*4d7e907cSAndroid Build Coastguard WorkerThe virtual HAL will be ignored if a real HAL is also installed on the target
18*4d7e907cSAndroid Build Coastguard Workerdevice. Set the `biometric_virtual_enabled` settings and reboot the device to
19*4d7e907cSAndroid Build Coastguard Workerswitch to the virtual HAL. Unset it and reboot again to switch back.
20*4d7e907cSAndroid Build Coastguard Worker
21*4d7e907cSAndroid Build Coastguard Worker## Getting Started
22*4d7e907cSAndroid Build Coastguard Worker
23*4d7e907cSAndroid Build Coastguard WorkerFirst, set the type of sensor the device should use, enable the virtual
24*4d7e907cSAndroid Build Coastguard Workerextensions in the framework, and reboot.
25*4d7e907cSAndroid Build Coastguard Worker
26*4d7e907cSAndroid Build Coastguard Worker```shell
27*4d7e907cSAndroid Build Coastguard Worker$ adb root
28*4d7e907cSAndroid Build Coastguard Worker$ adb shell settings put secure biometric_virtual_enabled 1
29*4d7e907cSAndroid Build Coastguard Worker$ adb shell setprop persist.vendor.fingerprint.virtual.type rear
30*4d7e907cSAndroid Build Coastguard Worker$ adb reboot
31*4d7e907cSAndroid Build Coastguard Worker```
32*4d7e907cSAndroid Build Coastguard Worker
33*4d7e907cSAndroid Build Coastguard Worker### Enrollments
34*4d7e907cSAndroid Build Coastguard Worker
35*4d7e907cSAndroid Build Coastguard WorkerNext, setup enrollments on the device. This can either be done through the UI,
36*4d7e907cSAndroid Build Coastguard Workeror via adb directly.
37*4d7e907cSAndroid Build Coastguard Worker
38*4d7e907cSAndroid Build Coastguard Worker#### Direct Enrollment
39*4d7e907cSAndroid Build Coastguard Worker
40*4d7e907cSAndroid Build Coastguard WorkerTo set enrollment directly without the UI:
41*4d7e907cSAndroid Build Coastguard Worker
42*4d7e907cSAndroid Build Coastguard Worker```shell
43*4d7e907cSAndroid Build Coastguard Worker$ adb root
44*4d7e907cSAndroid Build Coastguard Worker$ adb shell locksettings set-pin 0000
45*4d7e907cSAndroid Build Coastguard Worker$ adb shell setprop persist.vendor.fingerprint.virtual.enrollments 1
46*4d7e907cSAndroid Build Coastguard Worker$ adb shell cmd fingerprint sync
47*4d7e907cSAndroid Build Coastguard Worker```
48*4d7e907cSAndroid Build Coastguard Worker
49*4d7e907cSAndroid Build Coastguard Worker#### UI Enrollment
50*4d7e907cSAndroid Build Coastguard Worker
51*4d7e907cSAndroid Build Coastguard Worker1. Set pin
52*4d7e907cSAndroid Build Coastguard Worker      ```shell
53*4d7e907cSAndroid Build Coastguard Worker      $ adb shell locksettings set-pin 0000
54*4d7e907cSAndroid Build Coastguard Worker      ```
55*4d7e907cSAndroid Build Coastguard Worker2. Tee up the results of the enrollment before starting the process:
56*4d7e907cSAndroid Build Coastguard Worker
57*4d7e907cSAndroid Build Coastguard Worker      ```shell
58*4d7e907cSAndroid Build Coastguard Worker      $ adb shell setprop vendor.fingerprint.virtual.next_enrollment 1:100,100,100:true
59*4d7e907cSAndroid Build Coastguard Worker      ```
60*4d7e907cSAndroid Build Coastguard Worker
61*4d7e907cSAndroid Build Coastguard Worker3. Navigate to `Settings -> Security -> Fingerprint Unlock` and follow the
62*4d7e907cSAndroid Build Coastguard Worker   prompts.
63*4d7e907cSAndroid Build Coastguard Worker4. Verify the enrollments in the UI:
64*4d7e907cSAndroid Build Coastguard Worker
65*4d7e907cSAndroid Build Coastguard Worker      ```shell
66*4d7e907cSAndroid Build Coastguard Worker      $ adb shell getprop persist.vendor.fingerprint.virtual.enrollments
67*4d7e907cSAndroid Build Coastguard Worker      ```
68*4d7e907cSAndroid Build Coastguard Worker
69*4d7e907cSAndroid Build Coastguard Worker## Authenticate
70*4d7e907cSAndroid Build Coastguard Worker
71*4d7e907cSAndroid Build Coastguard WorkerTo authenticate successfully set the enrolled id that should succeed. Unset it
72*4d7e907cSAndroid Build Coastguard Workeror change the value to make authenticate operations fail:
73*4d7e907cSAndroid Build Coastguard Worker
74*4d7e907cSAndroid Build Coastguard Worker````shell
75*4d7e907cSAndroid Build Coastguard Worker$ adb shell setprop vendor.fingerprint.virtual.enrollment_hit 1
76*4d7e907cSAndroid Build Coastguard Worker````
77*4d7e907cSAndroid Build Coastguard Worker
78*4d7e907cSAndroid Build Coastguard Worker## Acquired Info Insertion
79*4d7e907cSAndroid Build Coastguard Worker
80*4d7e907cSAndroid Build Coastguard WorkerFingerprint image acquisition states at HAL are reported to framework via onAcquired() callback. The valid acquired state info for AIDL HAL include
81*4d7e907cSAndroid Build Coastguard Worker
82*4d7e907cSAndroid Build Coastguard Worker{UNKNOWN(0), GOOD(1), PARTIAL(2), INSUFFICIENT(3), SENSOR_DIRTY(4), TOO_SLOW(5), TOO_FAST(6), VENDOR(7), START(8), TOO_DARK(9), TOO_BRIGHT(10), IMMOBILE(11), RETRYING_CAPTURE(12)}
83*4d7e907cSAndroid Build Coastguard Worker
84*4d7e907cSAndroid Build Coastguard WorkerRefer to [AcquiredInfo.aidl](../android/hardware/biometrics/fingerprint/AcquiredInfo.aidl) for details
85*4d7e907cSAndroid Build Coastguard Worker
86*4d7e907cSAndroid Build Coastguard Worker
87*4d7e907cSAndroid Build Coastguard WorkerThe states can be specified in sequence for the HAL operations involving fingerprint image captures, namely authenticate, enrollment and detectInteraction
88*4d7e907cSAndroid Build Coastguard Worker
89*4d7e907cSAndroid Build Coastguard Worker```shell
90*4d7e907cSAndroid Build Coastguard Worker$ adb shell setprop vendor.fingerprint.virtual.operation_authenticate_acquired 6,9,1
91*4d7e907cSAndroid Build Coastguard Worker$ adb shell setprop vendor.fingerprint.virtual.operation_detect_interaction_acquired 6,1
92*4d7e907cSAndroid Build Coastguard Worker$ adb shell setprop vendor.fingerprint.virtual.next_enrollment 2:1000-[5,1],500:true
93*4d7e907cSAndroid Build Coastguard Worker
94*4d7e907cSAndroid Build Coastguard Worker#next_enrollment format example:
95*4d7e907cSAndroid Build Coastguard Worker.---------------------- enrollment id (2)
96*4d7e907cSAndroid Build Coastguard Worker|   .------------------ the image capture 1 duration (1000ms)
97*4d7e907cSAndroid Build Coastguard Worker|   |   .--------------   acquired info first (TOO_SLOW)
98*4d7e907cSAndroid Build Coastguard Worker|   |   | .------------   acquired info second (GOOD)
99*4d7e907cSAndroid Build Coastguard Worker|   |   | |   .-------- the image capture 2 duration (500ms)
100*4d7e907cSAndroid Build Coastguard Worker|   |   | |   |   .---- enrollment end status (success)
101*4d7e907cSAndroid Build Coastguard Worker|   |   | |   |   |
102*4d7e907cSAndroid Build Coastguard Worker|   |   | |   |   |
103*4d7e907cSAndroid Build Coastguard Worker|   |   | |   |   |
104*4d7e907cSAndroid Build Coastguard Worker2:1000-[5,1],500:true
105*4d7e907cSAndroid Build Coastguard Worker```
106*4d7e907cSAndroid Build Coastguard WorkerFor vendor specific acquired info, acquiredInfo = 1000 + vendorAcquiredInfo
107*4d7e907cSAndroid Build Coastguard Worker
108*4d7e907cSAndroid Build Coastguard Worker## Error Insertion
109*4d7e907cSAndroid Build Coastguard WorkerThe valid error codes for AIDL HAL include
110*4d7e907cSAndroid Build Coastguard Worker
111*4d7e907cSAndroid Build Coastguard Worker{UNKNOWN(0), HW_UNAVAILABLE(1), UNABLE_TO_PROCESS(2), TIMEOUT(3), NO_SPACE(4), CANCELED(5), UNABLE_TO_REMOVE(6), VENDOR(7), BAD_CALIBRATION(8)}
112*4d7e907cSAndroid Build Coastguard Worker
113*4d7e907cSAndroid Build Coastguard WorkerRefer to [Error.aidl](../android/hardware/biometrics/fingerprint/Error.aidl) for details
114*4d7e907cSAndroid Build Coastguard Worker
115*4d7e907cSAndroid Build Coastguard Worker
116*4d7e907cSAndroid Build Coastguard WorkerThere are many HAL operations which can result in errors, refer to [here](fingerprint.sysprop) file for details.
117*4d7e907cSAndroid Build Coastguard Worker
118*4d7e907cSAndroid Build Coastguard Worker```shell
119*4d7e907cSAndroid Build Coastguard Worker$ adb shell setprop vendor.fingerprint.virtual.operation_authenticate_error 8
120*4d7e907cSAndroid Build Coastguard Worker```
121*4d7e907cSAndroid Build Coastguard WorkerFor vendor specific error, errorCode = 1000 + vendorErrorCode
122*4d7e907cSAndroid Build Coastguard Worker
123*4d7e907cSAndroid Build Coastguard Worker## Latency Insertion
124*4d7e907cSAndroid Build Coastguard WorkerThree HAL operations (authenticate, enrollment and detect interaction) latency can be optionally specified in multiple ways
125*4d7e907cSAndroid Build Coastguard Worker1. default latency is fixed at 400 ms if not specified via sysprop
126*4d7e907cSAndroid Build Coastguard Worker2. specify authenticate operation latency to 900 ms
127*4d7e907cSAndroid Build Coastguard Worker      ```shell adb shell setprop vendor.fingerprint.virtual.operation_authenticate_latency 900```
128*4d7e907cSAndroid Build Coastguard Worker3. specify authenticate operation latency between 600 to 1200 ms in unifrom distribution
129*4d7e907cSAndroid Build Coastguard Worker      ```shelladb shell setprop vendor.fingerprint.virtual.operation_authenticate_latency 600,1200```
130*4d7e907cSAndroid Build Coastguard Worker
131*4d7e907cSAndroid Build Coastguard Worker## Lockout
132*4d7e907cSAndroid Build Coastguard WorkerTo force the device into lockout state
133*4d7e907cSAndroid Build Coastguard Worker```shell
134*4d7e907cSAndroid Build Coastguard Worker$ adb shell setprop persist.vendor.fingerprint.virtual.lockout true
135*4d7e907cSAndroid Build Coastguard Worker```
136*4d7e907cSAndroid Build Coastguard WorkerTo test permanent lockout based on the failed authentication attempts (e.g. 7)
137*4d7e907cSAndroid Build Coastguard Worker```shell
138*4d7e907cSAndroid Build Coastguard Worker$ adb shell setprop persist.vendor.fingerprint.virtual.lockout_permanent_threshold 7
139*4d7e907cSAndroid Build Coastguard Worker$ adb shell setprop persist.vendor.fingerprint.virtual.lockout_enable true
140*4d7e907cSAndroid Build Coastguard Worker```
141*4d7e907cSAndroid Build Coastguard WorkerTo test timed lockout based on the failed authentication attempts (e.g. 8 seconds on 5 attempts)
142*4d7e907cSAndroid Build Coastguard Worker```shell
143*4d7e907cSAndroid Build Coastguard Worker$ adb shell setprop persist.vendor.fingerprint.virtual.lockout_timed_duration 8000
144*4d7e907cSAndroid Build Coastguard Worker$ adb shell setprop persist.vendor.fingerprint.virtual.lockout_timed_threshold 5
145*4d7e907cSAndroid Build Coastguard Worker$ adb shell setprop persist.vendor.fingerprint.virtual.lockout_enable true
146*4d7e907cSAndroid Build Coastguard Worker```
147*4d7e907cSAndroid Build Coastguard Worker
148*4d7e907cSAndroid Build Coastguard Worker## Reset all configurations to default
149*4d7e907cSAndroid Build Coastguard WorkerThe following command will reset virtual configurations (related system properties) to default value.
150*4d7e907cSAndroid Build Coastguard Worker```shell
151*4d7e907cSAndroid Build Coastguard Worker$ adb shell cmd android.hardware.biometrics.fingerprint.IFingerprint/virtual resetconfig
152*4d7e907cSAndroid Build Coastguard Worker$ adb reboot
153*4d7e907cSAndroid Build Coastguard Worker```
154*4d7e907cSAndroid Build Coastguard Worker
155*4d7e907cSAndroid Build Coastguard Worker## View HAL State
156*4d7e907cSAndroid Build Coastguard Worker
157*4d7e907cSAndroid Build Coastguard WorkerTo view all the properties of the HAL (see `fingerprint.sysprop` file for the API):
158*4d7e907cSAndroid Build Coastguard Worker
159*4d7e907cSAndroid Build Coastguard Worker```shell
160*4d7e907cSAndroid Build Coastguard Worker$ adb shell getprop | grep vendor.fingerprint.virtual
161*4d7e907cSAndroid Build Coastguard Worker```
162*4d7e907cSAndroid Build Coastguard WorkerTo dump virtual HAL internal data
163*4d7e907cSAndroid Build Coastguard Worker```shell
164*4d7e907cSAndroid Build Coastguard Workeradb shell dumpsys android.hardware.biometrics.fingerprint.IFingerprint/virtual
165*4d7e907cSAndroid Build Coastguard Worker```
166