Introduction to fingerprint service instance of Android 7.0 fingerprint service

Fingerprint service is a relatively simple service in Android system (compared with AMS, WMS, etc.), which is also relatively independent, including several functions

Like other system services, applications communicate with the fingerprint service through the fingerprint manager. In addition to the above functions, the fingerprint manager provides some other interfaces. Important interfaces require system level permissions, and are not public APIs (fingerprint entry, deletion, renaming, reset error count, etc.)

Startup process of fingerprint service

Fingerprint service is created and initialized in the system server. When it is detected that the phone supports fingerprint function, it will start this service

After initialization, the fingerprintservice will establish communication with the Hal layer, that is, connect to fingerprintd and get the ifingerprintdaemon object (binder) for communication

In essence, in addition to the security related strategies, the function of fingerprint depends on hardware implementation, and fingerprint service only acts as the message transmitter of framework Java layer and native layer. Therefore, fingerprint identification, input and monitoring are to send death orders to fingerprintd and obtain corresponding results

Fingerprint monitoring authentication process

Taking fingerprint authentication as an example, this process is introduced. The process of entry and deletion is similar to authentication, and the description is not repeated

FingerprintManager

It can be seen that the message is still sent to the fingerprint service, but the function to enable fingerprint authentication passes in two important parameters: the cancellationsignal object, which is used to cancel fingerprint authentication, and the authenticationcallback object, which is the callback object of fingerprint authentication

You can also know the function by looking at the function name. They represent the callback results (success, failure, fingerprint detected, authentication exception, etc.) during fingerprint authentication. The parameters contain specific information. These information have corresponding constant definitions in fingerprint manager. If you are interested, you can view the code

FingerprintService

There will be a check on the package name, userid and whether the application process is in the foreground. Continue to see

Authenticationclient inherits from clientmonitor and is used to handle functional transactions related to fingerprint authentication. The same is true for other subclasses of clientmonitor, such as removalmonitor and enrollmonitor. Clientmonitor will directly communicate with fingerprintd. Its core is to call its start() or stop() method. For authenticationclient

After sending the authentication command to the bottom layer, you only need to wait for the authentication result. Earlier, we said that the communication with fingerprint D will be established during initialization. The core is the following line of code

Mdaemoncallback is a binder object that accepts the results from the bottom layer, and then sends the results to the application layer by layer through fingerprintservice and fingermanager.

Some changes in 8.0

Fingerprintd on 8.0 has changed a lot, and it is not even called fingerprintd. Of course, this is something in the native layer, which is not discussed here. For fingerprintservice, a significant change is the adjustment of security policy

summary

The above is an example of Android 7.0 fingerprint service fingerprintservice introduced by Xiaobian. I hope it will help you. If you have any questions, please leave me a message and Xiaobian will reply to you in time. Thank you very much for your support for the programming tips website!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>