POST
Fingerprint implementation in android 8.0 and later
Since Android 8.0, Android has fully introduced the HIDL layer into the framework. The purpose is to separate vendor partition from system partition so that Android is capable to upgrade the framework through OTA without recompiling HAL. Correspondingly, the framework of fingerprint has also been reconstructed. This page will give an introduction about the difference in the fingerprint framework between android 7.0 (and early version) and android 8.0 (and later version).
After the study of the previous three articles,
Android Fingerprint Framework (1)
Android Fingerprint Framework (2)
Android Fingerprint Framework (3)
we have discussed the fingerprint framework on android 7.0 in previous blogs, here give a summary for anyone who has not read these articles yet.
fingerprint framework in Android 7.0
This diagram is the fingerprint framework on the android platform, which I have presented in another article and copied here.
From the top layer, the fingerprint application will start the workflow and this is the fingerprint management entry defined by the Android system layer. In the framework internal, some tasks will be done to handle the request from the application.
-
init.rc
starts up theFingerprintd
process during the system boot-up.Fingerpringd
then registerIFingerprintDaemon
remote service toServiceManager
. -
System Server will start fingerprint system service
FingerprintService
.
SystemServer.java
FingerprintService
calls the interface ofFingerprintd
to communicate with Fingerprint HAL layer.
FingerprintService.java
Fingerprintd
callsFingerprintDaemonProxy
function to open HAL.
FingerprintDaemonProxy.cpp
- The HAL code is at below android path normally.
I drew a flow chart to help understand the whole flow more clearly.
The related source code and android path can be found in the below table. Android 7.0 (NOUGAT)
File | Android Path |
---|---|
init.rc | root/system/core/rootdir/init.rc |
fingerprintd.cpp | root/system/core/fingerprintd/fingerprintd.cpp |
FingerprintDaemonProxy.h | root/system/core/fingerprintd/ |
fingerprintdaemonproxy.cpp | root/system/core/fingerprintd/fingerprintdaemonproxy.cpp |
SystemServer.java | root/frameworks/base/services/java/com/android/server/SystemServer.java |
FingerprintService.java | root/frameworks/base/services/core/ java/com/android/server/fingerprint/FingerprintService.java |
hardware.h | root/hardware/libhardware/include/hardware/hardware.h |
hardware.c | root/hardware/libhardware/hardware.c |
fingerprint framework in Android 8.0
Above is the fingerprint framework of Android 7.0, however in Android 8.0 and later versions, Android has updated the framework and introduced a set of languages called HIDL to define the interface between framework and HAL.
Let’s see the difference.
Android 8.0 adds a sub-directory /interface
in the /hardware
directory, which includes all HIDL files for the hardware module.
Android 8.0 removed Fingerprintd
, instead, FingerprintService
accesses HAL by calling HIDL.
We can find the change in getFingerprintDaemon()
method.
In Android 7.0
FingerprintService.java
While in Android 8.0, mDaemon is achieved from the service of IBiometricsFingerprint
.
FingerprintService.java
IBiometricsFingerprint
is a new fingerprint HIDL interface that was introduced on Android 8.0.
IBiometricsFingerprint.hal
use HIDL language format defined a series of standard fingerprint operation interfaces.
And biometricsfingerprint.cpp class realized the IBiometricsFingerprint
interface.
We may notice that the IBiometricsFingerprint
returns a service for caller, actually there is a file in the HIDL sub-directory:
android.hardware.biometrics.fingerprint@2.1-service.rc, which will start fps_hal service.
fingerprint@2.1-service.rc
The files of the fingerprint HIDL related.
If we look at the Service.cpp, we will find the service actually will create a BiometricsFingerprint
instance and register as service.
In the constructor of BiometricsFingerprint
class, it calls openHal()
to open HAL module.
BiometricsFingerprint.cpp
Let’s check the openHal()
function.
BiometricsFingerprint.cpp
Have you found that the function realization is similar to the FingerprintDaemonProxy::openHal()
? The native method is called and the HAL module is opened here. After access to the HAL, others are all same under the HAL layer.
So far, we can change the fingerprint framework of Android 8.0 as below.
Compare this flowchart carefully with the last flowchart above, we can find the difference.
The related source code and android path can be found in the below table
File | Android Path |
---|---|
fingerprint@2.1-service | root/hardware/interfaces/biometrics/fingerprint/2.1/default |
service.cpp | root/hardware/interfaces/biometrics/fingerprint/2.1/default |
BiometricsFingerprint.h | root/hardware/interfaces/biometrics/fingerprint/2.1/default |
BiometricsFingerprint.cpp | root/hardware/interfaces/biometrics/fingerprint/2.1/default |
IBiometricsFingerprint.hal | root/hardware/interfaces/biometrics/fingerprint/2.1 |
IBiometricsFingerprintClientCallback.hal | root/hardware/interfaces/biometrics/fingerprint/2.1 |
Now, I think the main difference of the fingerprint framework on Android 8.0 has been introduced and if you have further questions, you can ask in the comment box, I will reply to you as soon as I can.