FingerprintService启动-Android13

FingerprintService启动-Android13

  • 1、指纹服务启动
    • 1.1 rc启动Binder对接指纹厂商TA库
    • 1.2 FingerprintService启动
      • 1.2.1 SystemServer启动FingerprintService
      • 1.2.2 注册Binder服务fingerprint
  • 2、获取底层信息
    • 2.1 AIDL 对接TA中获取
    • 2.2 指纹类型判断

android13-release


1、指纹服务启动

1.1 rc启动Binder对接指纹厂商TA库

android虚拟设备 这里android.hardware.biometrics.fingerprint@2.1-service.rc,实际现在Android 13上使用 AIDL 调用指纹厂商TA so库
(HIDL转换AIDL了解一下:AOSP > 文档 > 核心主题 > HIDL;对于fwk层实质是一样的,之前只是区分hwBinder域,这里注册的Binder服务android.hardware.biometrics.fingerprint@2.1::IBiometricsFingerprint/default

12-24 09:54:06.228     0     0 I init    : Parsing file /vendor/etc/init/android.hardware.biometrics.fingerprint@2.1-service.rc...
12-24 09:54:16.601   511   511 D android.hardware.biometrics.fingerprint@2.1-service: Opening fingerprint hal library...
12-24 09:54:16.616   511   511 D FingerprintHal: ----------------> fingerprint_open ----------------->
12-24 09:54:16.616   511   511 D FingerprintHal: ----------------> set_notify_callback ----------------->
12-24 09:54:16.616   511   511 D FingerprintHal: fingerprint callback notification set
12-24 09:54:16.620   511   526 D FingerprintHal: ----------------> listenerFunction ----------------->
12-24 09:54:16.646   511   511 I HidlServiceManagement: Registered android.hardware.biometrics.fingerprint@2.1::IBiometricsFingerprint/default
12-24 09:54:16.646   511   511 I HidlServiceManagement: Removing namespace from process name android.hardware.biometrics.fingerprint@2.1-service to fingerprint@2.1-service.

在这里插入图片描述

1.2 FingerprintService启动

1.2.1 SystemServer启动FingerprintService

12-24 09:54:36.628   606   606 D SystemServerTiming: StartFingerprintSensor
12-24 09:54:36.628   606   606 I SystemServiceManager: Starting com.android.server.biometrics.sensors.fingerprint.FingerprintService
12-24 09:54:36.629   606   606 V SystemServerTiming: StartFingerprintSensor took to complete: 1ms

frameworks/base/services/java/com/android/server/SystemServer.java

if (hasFeatureFingerprint) {t.traceBegin("StartFingerprintSensor");final FingerprintService fingerprintService =mSystemServiceManager.startService(FingerprintService.class);t.traceEnd();
}// Start this service after all biometric sensor services are started.
t.traceBegin("StartBiometricService");
mSystemServiceManager.startService(BiometricService.class);
t.traceEnd();t.traceBegin("StartAuthService");
mSystemServiceManager.startService(AuthService.class);
t.traceEnd();

1.2.2 注册Binder服务fingerprint

接收来自FingerprintManager的调用

frameworks/base/services/core/java/com/android/server/biometrics/sensors/fingerprint/FingerprintService.java

    public FingerprintService(Context context) {super(context);mServiceWrapper = new FingerprintServiceWrapper();mAppOps = context.getSystemService(AppOpsManager.class);mGestureAvailabilityDispatcher = new GestureAvailabilityDispatcher();mLockoutResetDispatcher = new LockoutResetDispatcher(context);mLockPatternUtils = new LockPatternUtils(context);mServiceProviders = new ArrayList<>();mBiometricStateCallback = new BiometricStateCallback();mAuthenticatorsRegisteredCallbacks = new RemoteCallbackList<>();mSensorProps = new ArrayList<>();mHandler = new Handler(Looper.getMainLooper());}@Overridepublic void onStart() {publishBinderService(Context.FINGERPRINT_SERVICE, mServiceWrapper);}

2、获取底层信息

实际获取在AuthService服务调用fingerprintService.registerAuthenticators(hidlFingerprintSensors);

frameworks/base/services/core/java/com/android/server/biometrics/AuthService.java

    /*** Registration of all HIDL and AIDL biometric HALs starts here.* The flow looks like this:* AuthService* └── .onStart()*     └── .registerAuthenticators(...)*         ├── FaceService.registerAuthenticators(...)*         │   └── for (p : serviceProviders)*         │       └── for (s : p.sensors)*         │           └── BiometricService.registerAuthenticator(s)*         │*         ├── FingerprintService.registerAuthenticators(...)*         │   └── for (p : serviceProviders)*         │       └── for (s : p.sensors)*         │           └── BiometricService.registerAuthenticator(s)*         │*         └── IrisService.registerAuthenticators(...)*             └── for (p : serviceProviders)*                 └── for (s : p.sensors)*                     └── BiometricService.registerAuthenticator(s)*/@Overridepublic void onStart() {mBiometricService = mInjector.getBiometricService();final SensorConfig[] hidlConfigs;if (!mInjector.isHidlDisabled(getContext())) {final int firstApiLevel = SystemProperties.getInt(SYSPROP_FIRST_API_LEVEL, 0);final int apiLevel = SystemProperties.getInt(SYSPROP_API_LEVEL, firstApiLevel);String[] configStrings = mInjector.getConfiguration(getContext());if (configStrings.length == 0 && apiLevel == Build.VERSION_CODES.R) {// For backwards compatibility with R where biometrics could work without being// configured in config_biometric_sensors. In the absence of a vendor provided// configuration, we assume the weakest biometric strength (i.e. convenience).Slog.w(TAG, "Found R vendor partition without config_biometric_sensors");configStrings = generateRSdkCompatibleConfiguration();}hidlConfigs = new SensorConfig[configStrings.length];for (int i = 0; i < configStrings.length; ++i) {hidlConfigs[i] = new SensorConfig(configStrings[i]);}} else {hidlConfigs = null;}// Registers HIDL and AIDL authenticators, but only HIDL configs need to be provided.registerAuthenticators(hidlConfigs);mInjector.publishBinderService(this, mImpl);}

下面日志是之前的HAIL:

12-24 09:54:36.650   606   606 D AuthService: Registering HIDL ID: 0 Modality: 2 Strength: 15
12-24 09:55:05.131   606  1740 D Fingerprint21: Daemon was null, reconnecting, current operation: null
12-24 09:55:05.186   606  1740 D Fingerprint21: Fingerprint HAL ready, HAL ID: 132452338342080
12-24 11:05:23.563   606   606 D Fingerprint21: handleError, client: FingerprintEnrollClient, error: 5, vendorCode: 0

2.1 AIDL 对接TA中获取

addAidlProviders() 获取TA信息,fp.getSensorProps()现在指纹类型显示位置从HAL中获取,转化成FingerprintSensorPropertiesInternal
在这里插入图片描述

private void addAidlProviders() {final String[] instances = ServiceManager.getDeclaredInstances(IFingerprint.DESCRIPTOR);if (instances == null || instances.length == 0) {return;}for (String instance : instances) {final String fqName = IFingerprint.DESCRIPTOR + "/" + instance;final IFingerprint fp = IFingerprint.Stub.asInterface(Binder.allowBlocking(ServiceManager.waitForDeclaredService(fqName)));if (fp == null) {Slog.e(TAG, "Unable to get declared service: " + fqName);continue;}try {final SensorProps[] props = fp.getSensorProps();final FingerprintProvider provider =new FingerprintProvider(getContext(), mBiometricStateCallback, props,instance, mLockoutResetDispatcher,mGestureAvailabilityDispatcher,BiometricContext.getInstance(getContext()));mServiceProviders.add(provider);} catch (RemoteException e) {Slog.e(TAG, "Remote exception in getSensorProps: " + fqName);}}
}@Override // Binder call
public void registerAuthenticators(@NonNull List<FingerprintSensorPropertiesInternal> hidlSensors) {Utils.checkPermission(getContext(), USE_BIOMETRIC_INTERNAL);// Some HAL might not be started before the system service and will cause the code below// to wait, and some of the operations below might take a significant amount of time to// complete (calls to the HALs). To avoid blocking the rest of system server we put// this on a background thread.final ServiceThread thread = new ServiceThread(TAG, Process.THREAD_PRIORITY_BACKGROUND,true /* allowIo */);thread.start();final Handler handler = new Handler(thread.getLooper());handler.post(() -> {addHidlProviders(hidlSensors);addAidlProviders();final IBiometricService biometricService = IBiometricService.Stub.asInterface(ServiceManager.getService(Context.BIOMETRIC_SERVICE));// Register each sensor individually with BiometricServicefor (ServiceProvider provider : mServiceProviders) {final List<FingerprintSensorPropertiesInternal> props =provider.getSensorProperties();for (FingerprintSensorPropertiesInternal prop : props) {final int sensorId = prop.sensorId;final @BiometricManager.Authenticators.Types int strength =Utils.propertyStrengthToAuthenticatorStrength(prop.sensorStrength);final FingerprintAuthenticator authenticator = new FingerprintAuthenticator(mServiceWrapper, sensorId);try {biometricService.registerAuthenticator(sensorId, TYPE_FINGERPRINT,strength, authenticator);} catch (RemoteException e) {Slog.e(TAG, "Remote exception when registering sensorId: " + sensorId);}}}synchronized (mLock) {for (ServiceProvider provider : mServiceProviders) {mSensorProps.addAll(provider.getSensorProperties());}}broadcastCurrentEnrollmentState(null); // broadcasts to all listenersbroadcastAllAuthenticatorsRegistered();});
}

2.2 指纹类型判断

  1. 指纹类型:屏下指纹(TYPE_UDFPS_OPTICAL、TYPE_UDFPS_ULTRASONIC)、侧边指纹(TYPE_POWER_BUTTON
  2. 屏下指纹和侧边指纹判断:isAnyUdfpsTypeisAnySidefpsType
  3. 日志查看:FingerprintProvider.*Added: ID
    frameworks/base/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/FingerprintProvider.java
    在这里插入图片描述
  • 类型对照

frameworks/base/core/java/android/hardware/fingerprint/FingerprintSensorProperties.java

    /*** @hide*/public static final int TYPE_UNKNOWN = 0;/*** @hide*/public static final int TYPE_REAR = 1;/*** @hide*/public static final int TYPE_UDFPS_ULTRASONIC = 2;/*** @hide*/public static final int TYPE_UDFPS_OPTICAL = 3;/*** @hide*/public static final int TYPE_POWER_BUTTON = 4;/*** @hide*/public static final int TYPE_HOME_BUTTON = 5;/*** @hide*/@IntDef({TYPE_UNKNOWN,TYPE_REAR,TYPE_UDFPS_ULTRASONIC,TYPE_UDFPS_OPTICAL,TYPE_POWER_BUTTON,TYPE_HOME_BUTTON})@Retention(RetentionPolicy.SOURCE)public @interface SensorType {}
  • 屏下指纹和侧边指纹判断

hardware/interfaces/biometrics/fingerprint/aidl/android/hardware/biometrics/fingerprint/FingerprintSensorType.aidl

package android.hardware.biometrics.fingerprint;@VintfStability
@Backing(type="byte")
enum FingerprintSensorType {UNKNOWN,REAR,UNDER_DISPLAY_ULTRASONIC,UNDER_DISPLAY_OPTICAL,POWER_BUTTON,HOME_BUTTON
}
    public boolean isAnyUdfpsType() {switch (sensorType) {case TYPE_UDFPS_OPTICAL:case TYPE_UDFPS_ULTRASONIC:return true;default:return false;}}/*** Returns if sensor type is side-FPS* @return true if sensor is side-fps, false otherwise*/public boolean isAnySidefpsType() {switch (sensorType) {case TYPE_POWER_BUTTON:return true;default:return false;}}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/313024.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

SpringBoot2.7.12整合Knife4j

SpringBoot2.7.12整合Knife4j 是什么 Knife4j是一个集Swagger2 和 OpenAPI3为一体的增强解决方案 添加依赖 <!--引入Knife4j的官方start包,该指南选择Spring Boot版本<3.0,开发者需要注意--> <dependency><groupId>com.github.xiaoymin</groupId>&l…

Intellij建议用String替换StringBuilder

文章目录 前言String 和 StringBuilder 性能对比String 和 StringBuilder 使用的字节码对比总结 本文收发地址 https://blog.csdn.net/CSqingchen/article/details/135324313 最新更新地址 https://gitee.com/chenjim/chenjimblog 前言 最近编码时看到 Intellij 建议使用 Stri…

[附代码]稳态视觉诱发电位SSVEP之预训练模型提高性能

SSVEP 之深度学习 深度学习已经被广泛运用在脑电信号分析来提高脑机接口的性能,这是一个end-to-end的方法,简单来说,只要搭建好深度学习网络,做好特征工程,然后分类即可,对于一个刚刚接触脑机接口领域深度学习的学习者来说,可以先忽略中间的数学相关的东西,先建一个网…

Linux常用命令大全总结及讲解(超详细版)

前言&#xff1a; Linux 是一个基于Linux 内核的开源类Unix 操作系统&#xff0c;Linus Torvalds于 1991 年 9 月 17 日首次发布的操作系统内核。Linux 通常打包为Linux 发行版。 Linux 最初是为基于Intel x86架构的个人计算机开发的&#xff0c;但此后被移植到的平台比任何其…

【大数据面试知识点】分区器Partitioner:HashPartitioner、RangePartitioner

Spark HashParitioner的弊端是什么&#xff1f; HashPartitioner分区的原理很简单&#xff0c;对于给定的key&#xff0c;计算其hashCode&#xff0c;并除于分区的个数取余&#xff0c;如果余数小于0&#xff0c;则用余数分区的个数&#xff0c;最后返回的值就是这个key所属的…

【NLP论文】02 TF-IDF 关键词权值计算

之前写了一篇关于关键词词库构建的文章&#xff0c;没想到反响还不错&#xff0c;最近有空把接下来的两篇补完&#xff0c;也继续使用物流关键词词库举例&#xff0c;本篇文章承接关键词词库构建并以其为基础&#xff0c;将计算各关键词的 TF-IDF 权值&#xff0c;TF-IDF 权值主…

D45D46|动态规划之子序列问题

300.最长递增子序列&#xff1a; 初始思路&#xff1a; 动态规划五部曲&#xff1a; 1&#xff09;dp数组的定义&#xff0c;dp[i]表述数组第i个元素大于前面几个值&#xff1b; 2&#xff09;dp数组的迭代&#xff0c;min nums[x]表示递增数组中的最后一个值&#xff0c;如…

【python_数据分组】

对excel按照标签进行分组&#xff0c;例如按照“开票主体和对方公司”进行分组&#xff0c;并获取对应的明细。 表格如下&#xff1a; def main(excel_data):result {}for d in excel_data:if str(d[0])str(d[1]) in result:result[str(d[0])str(d[1])].append([d[0],d[1],…

table表格中使用el-popover 无效问题解决

实例只针对单个的按钮管用在表格里每一列都有el-popover相当于是v-for遍历了 所以我们在触发按钮的时候并不是单个的触发某一个 主要执行 代码 <el-popover placement"left" :ref"popover-${scope.$index}"> 动态绑定了ref 关闭弹窗 执行deltask…

留言板(Mybatis连接数据库版)

目录 1.添加Mybatis和SQL的依赖 2.建立数据库和需要的表 3.对应表中的字段&#xff0c;补充Java对象 4.对代码进行逻辑分层 5.后端逻辑代码 之前的项目实例【基于Spring MVC的前后端交互案例及应用分层的实现】https://blog.csdn.net/weixin_67793092/article/details/134…

在FC中手工创建虚拟机模板

1、Linux去除个性化信息 &#xff08;1&#xff09;编辑网卡配置文件&#xff0c;只保留以下内容&#xff08;以RHEL 7为例&#xff09; &#xff08;2&#xff09;清除主机密钥信息&#xff08;开机会自动生成&#xff09; &#xff08;3&#xff09;清除Machine ID&#xff…

【HarmonyOS开发】探究Hap与App包的结构与区别

1、Hap与App包的区别 OpenHarmony 可以进行两种形式&#xff08;Hap和App&#xff09;的打包&#xff0c;HAP是用于本地调试的&#xff0c;APP包是用于上架发布的。 根据不同的设备类型&#xff0c;一个APP包可以包含多个HAP包。 下面从两个角度进行分析 1.1 编译构建角度 编…