指纹模块流程分析(二)之Fingerprint framework初始化流程

二、Fingerprint framework初始化流程

在系统开机的时候,会启动各种Service,包括FingerprintService。从下图的开机log(sys_log.boot)中可以看出:

05-29 10:37:57.870869  1127  1127 I SystemServiceManager: Starting com.android.server.dreams.DreamManagerService

05-29 10:37:57.874643  1127  1127 I SystemServer: StartAssetAtlasService

05-29 10:37:57.883240  1127  1127 I SystemServiceManager: Starting com.android.server.print.PrintManagerService

05-29 10:37:57.910104  1127  1127 I SystemServiceManager: Starting com.android.server.restrictions.RestrictionsManagerService

05-29 10:37:57.913926  1127  1127 I SystemServiceManager: Starting com.android.server.media.MediaSessionService

05-29 10:37:57.926584  1127  1127 I SystemServer: StartMediaRouterService

05-29 10:37:57.939619  1127  1127 I SystemServiceManager: Starting com.android.server.trust.TrustManagerService

05-29 10:37:57.952689  1127  1127 I SystemServiceManager: Starting com.android.server.fingerprint.FingerprintService

05-29 10:37:58.866228  1127  1127 V FingerprintService: Fingerprint HAL id: 488345235968

05-29 10:37:58.867305  1127  1127 I SystemServer: StartBackgroundDexOptService

 

FingerprintService的启动在SystemServer.Java的startOtherService方法中

/**

* Starts a miscellaneous grab bag of stuff that has yet to be refactored

* and organized.

*/

private void startOtherServices() {

   final Context context = mSystemContext;

   VibratorService vibrator = null;

   IMountService mountService = null;

   .......

   //启动FingerprintService

   if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)) {

       mSystemServiceManager.startService(FingerprintService.class);

   }

        ......

这里启动的时候,会将FingerprintService添加到ServiceManager中去,如下图:

指纹模块流程分析(二)之Fingerprint framework初始化流程_第1张图片

 

将FingerprintService添加到ServiceManager中后,在SystemServiceRegistry.java中静态代码块中注册服务的时候,可以从ServiceManager中获取FingerprintService的Binder对象,从而可以构造出FingerprintManager对象,这样app端就可以通过Context来获取FingerprintManager对象。另外FingerprintService的onStart()方法中还会调用getFingerprintDaemon()来完成以下步骤:

//①获取fingerprintd

//②向fingerprintd注册回调函数mDaemonCallback

//③调用获取fingerprintd的openhal函数

public IFingerprintDaemon getFingerprintDaemon() {

             //①获取fingerprintd

            mDaemon = IFingerprintDaemon.Stub.asInterface(ServiceManager.getService(

            FINGERPRINTD));

            mDaemon.asBinder().linkToDeath(this, 0);

            //②fingerprintd注册回调函数mDaemonCallback

            mDaemon.init(mDaemonCallback);

            //③调用获取fingerprintdopenhal函数

            mHalDeviceId = mDaemon.openHal();

            ......

    }

app端通过Context获取FingerprintManager,通过调用FingerprintManager的接口来实现相应的功能,FingerprintManager转调FingerprintService中方法,FingerprintService负责管理整个注册,识别、删除指纹、检查权限等流程的逻辑,FingerprintService调用fingerprintd的接口,通过fingerprintd和FingerprintHal层进行通信。

你可能感兴趣的:(指纹,AOSP)