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.mzph.cn/news/599394.shtml

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

相关文章

PyTorch基础操作

一、Tensor 在 PyTorch 中&#xff0c;张量&#xff08;Tensor&#xff09;是一个核心概念&#xff0c;它是一个用于存储和操作数据的多维数组&#xff0c;类似于 NumPy 的 ndarray&#xff0c;但与此同时&#xff0c;它也支持 GPU 加速&#xff0c;这使得在大规模数据上进行科…

CSS 放大翻转动画

<template><div class="container" @mouseenter="startAnimation" @mouseleave="stopAnimation"><!-- 旋方块 --><div class="box" :class="{ rotate-scale-up-hor: isAnimating }"><!-- 元素内…

使用爬虫爬取热门电影

文章目录 网站存储视频的原理M3U8文件解读网站分析代码实现 网站存储视频的原理 首先我们来了解一下网站存储视频的原理。 一般情况下&#xff0c;一个网页里想要显示出一个视频资源&#xff0c;必须有一个<video>标签&#xff0c; <video src"xxx.mp4"&…

Note: A Journey Across Canada

A Journey Across Canada 一场横穿加拿大的旅行 across journey After a quiz last autumn, Kuang crossed the continent eastward to Toronto to visit his schoolmate, the distance measuring approximately 5000 kilometers. 去年秋天一次考试后&#xff0c;Kuang向东穿…

数字人克隆系统开发公司?

广州硅基技术开发限公司是一家位于中国广东省广州市的科技公司。该公司专注于人工智能&#xff08;AI&#xff09;领域的研发和创新。广州硅基以技术创新和解决方案为核心&#xff0c;致力于为客户提供高质量的人工智能产品和服务。 广州硅基技术的主要业务包括但不限于&#…

stm32学习笔记:TIIM-输入捕获

输入捕获理论 4个输入捕获和输出比较通道&#xff0c;共用4个CCR寄存器 另外它们的CH1到CH4&#xff0c;4个通道的引脚&#xff0c;也是共用的。 所以对于同一个定时器&#xff0c;输入捕获和输出比较只能使用其中一个&#xff0c;不能同时使用。 电平跳变&#xff1a;上升沿…

《动手学深度学习》学习笔记 第5章 深度学习计算

本系列为《动手学深度学习》学习笔记 书籍链接&#xff1a;动手学深度学习 笔记是从第四章开始&#xff0c;前面三章为基础知道&#xff0c;有需要的可以自己去看看 关于本系列笔记&#xff1a; 书里为了让读者更好的理解&#xff0c;有大篇幅的描述性的文字&#xff0c;内容很…

Spring学习 Spring概述

1.1.Spring介绍 ​ Spring是轻量级Java EE应用开源框架&#xff08;官网&#xff1a; http://spring.io/ &#xff09;&#xff0c;它由Rod Johnson创为了解决企业级编程开发的复杂性而创建 1.2.简化应用开发体现在哪些方面&#xff1f; IOC 解决传统Web开发中硬编码所造成的…

python中collections.abc.Mapping 和collections.Mapping的区别

文章目录 在 Python 中&#xff0c;collections.abc.Mapping 和 collections.Mapping 都是用于表示映射类型&#xff08;即键值对的集合&#xff0c;例如字典&#xff09;的抽象基类。它们的区别在于它们的来源和使用方式。 collections.abc.Mapping 是 collections.abc 模块中…

1月5日代码随想录完全二叉树的节点个数

222.完全二叉树的节点个数 给你一棵 完全二叉树 的根节点 root &#xff0c;求出该树的节点个数。 完全二叉树 的定义如下&#xff1a;在完全二叉树中&#xff0c;除了最底层节点可能没填满外&#xff0c;其余每层节点数都达到最大值&#xff0c;并且最下面一层的节点都集中在…

即时设计:轻松实现设计稿动画,打造独具魅力的GIF作品

制作动画 随着动画设计越来越受欢迎&#xff0c;设计师们需要一款强大的工具&#xff0c;以便轻松控制设计稿元素的属性&#xff0c;实现动画效果。今天&#xff0c;我们向您推荐一款具备帧动画功能的设计工具&#xff0c;它可以让您轻松调整元素的宽高、相对位置等属性&#x…

Spring AI 指南

近年来&#xff0c;人工智能技术的迅猛发展改变了我们对科技的看法&#xff0c;并在各个领域引发了巨大的变革。每个人都希望在自己的项目上能够使用人工智能。Spring 框架提供了一个名为 “Spring AI” 的项目&#xff0c;Spring AI 项目旨在简化包含人工智能功能的应用程序的…

Matlab绘制动态心形线

1. 代码 for alpha0:0.1:30 x-1.8:0.001:1.8; y(x.^2).^(1/3)0.9*(3.3-x.^2).^(1/2).*sin(alpha*pi*x); plot(x,y,r-,LineWidth,1.2); set(gca,YGrid,on); axis([-3,3,-2,4]); text(-2,3.35,$f(x)x^{\frac{2}{3}}0.9(3.3-x^2)^{\frac{1}{2}}sin(\alpha\pi x)$,Interpreter,lat…

Geotrust DV通配符证书保护域名数量

Geotrust是一家知名的SSL证书提供商&#xff0c;旗下有多种类型的SSL数字证书&#xff0c;保护网站数据在传输过程中的安全性和完整性&#xff0c;帮助用户确认其网站的安全。通配符SSL证书是Geotrust颁发的一种可以同时保护多个域名站点的SSL证书。今天就随SSL盾小编了解Geotr…

Toshiba 数字隔离器助力工业应用实现稳定的高速隔离数据传输

隔离器件是将输入信号进行转换并输出&#xff0c;以实现输入、输出两端电气隔离的一种安规器件。电气隔离能够保证强电电路和弱电电路之间信号传输的安全性&#xff0c;如果没有进行电气隔离&#xff0c;一旦发生故障&#xff0c;强电电路的电流将直接流到弱电电路&#xff0c;…

啊哈c语言——逻辑挑战8:验证哥德巴赫猜想

上面这封书信是普鲁士数学家哥德巴赫在1742年6月7日写给瑞士数学家欧拉的&#xff0c;哥德巴赫在书信中提出了“任一大于2的整数都可以写成3个质数之和”的猜想。当时&#xff0c;哥德巴赫遵照的是“1也是素数”的约定。现今&#xff0c;数学界已经不使用这个约定了。哥德巴赫原…

Spring Boot 整合 Knife4j(快速上手)

关于 Knife4j 官方文档&#xff1a;https://doc.xiaominfo.com/ Knife4j是一个基于Swagger的API文档生成工具&#xff0c;它提供了一种方便的方式来为Spring Boot项目生成在线API文档。Knife4j的特点包括&#xff1a; 自动化生成&#xff1a;通过Swagger注解&#xff0c;Kn…

凸优化 3:最优化方法

凸优化 3&#xff1a;最优化方法 最优化方法适用场景对比费马引理一阶优化算法梯度下降最速下降 二阶优化算法牛顿法Hessian矩阵Hessian矩阵的逆Hessian矩阵和梯度的区别牛顿法和梯度下降法的区别 拟牛顿法DFP、BFGS/L-BFGS 数值优化算法坐标下降法SMO算法 基于导数的函数优化解…

FCN学习-----第一课

语义分割中的全卷积网络 CVPR IEEE国际计算机视觉与模式识别会议 PAMI IEEE模式分析与机器智能汇刊 需要会的知识点&#xff1a; 神经网络&#xff1a;前向传播和反向传播 卷积神经网络&#xff1a;CNN&#xff0c;卷积&#xff0c;池化&#xff0c;上采样 分类网络&#xff1a…

杨中科 ASP.NETCore Rest

什么是Rest RPC 1、Web API两种风格: 面向过程(RPC) 、面向REST (REST) 2、RPC:“控制器/操作方法“的形式把服务器端的代码当成方法去调用。把HTTP当成传输数据的通道&#xff0c;不关心HTTP谓词。通过QueryString请求报文体给服务器传递数据。状态码。比如/Persons/GetAll…