FingerprintService启动-Android13

news2025/1/21 21:54:15

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());
    }

    @Override
    public 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)
     */
    @Override
    public 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 BiometricService
        for (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 listeners
        broadcastAllAuthenticatorsRegistered();
    });
}

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.coloradmin.cn/o/1347666.html

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

相关文章

有限差分场的数值计算:代数、求导、积分

文章目录 前言一、代数运算1.手动计算流程2.ubermag库函数验证 二、求导运算1.手动计算流程2.ubermag库函数验证3.标量场的梯度&#xff0c;矢量场的散度和旋度 三、积分运算1.手动计算流程2.ubermag库函数验证 总结 靡不有初&#xff0c;鲜克有终。——《诗经大雅荡》 前言 …

fastApi 项目部署

方式一&#xff0c;Uvicorn部署 Run a Server Manually - Uvicorn - FastAPI 1&#xff0c;linux服务器安装 python>3.8 2&#xff0c;安装 uvicorn : pip install "uvicorn[standard]" 3&#xff0c;上传项目到服务器 main.py from typing imp…

机场信息集成系统系列介绍(6):机场协同决策支持系统ACDM*续集

目录 1、A-CDM实施效果评估背景 2、评估核心指标项 &#xff08;1&#xff09;机位效率 &#xff08;2&#xff09;登机效率 &#xff08;3&#xff09;推出效率 &#xff08;4&#xff09;滑行效率 &#xff08;5&#xff09;协同效率 3、其他指标项 &#xff08;1&a…

使用 Hyper-V 创建虚拟机

使用 Hyper-V 创建虚拟机 官网教程修改存储目录Hyper-V管理器创建虚拟机启动虚拟机Win10安装教程Press any key to boot from CD or DVD...... 如何使用Windows自带的虚拟机工具来创建虚拟机&#xff0c; 快速创建虚拟机进行学习探讨&#xff0c;如果有环境问题可以立即创建一个…

Vue-Setup

一、setup概述 小小提示&#xff1a;vue3中可以写多个根标签。 Person.vue中内容 <template><div class"person"><h2>姓名&#xff1a;{{name}}</h2><h2>年龄&#xff1a;{{age}}</h2><!--定义了一个事件&#xff0c;点击这…

【Image】超硬核数学推导——WGAN的先“破”后“立”

GAN的实现 上一篇文章中我们说到了GAN的数学解释 min ⁡ G max ⁡ D V ( D , G ) E x ∼ p data ( x ) [ log ⁡ D ( x ) ] E z ∼ p z ( z ) [ log ⁡ ( 1 − D ( G ( z ) ) ) ] − log ⁡ 4 2 J S D ( p data ∥ p g ) ≥ − log ⁡ 4 , where [ p d a t a p g ] \mi…

node相关的args属性与<param>子标签的区别

launch文件内&#xff1a;node标签内的<param>标签示例&#xff1a; 可以看到launch文件内的<param>标签在命令行内会转化为--ros-args -p 这样格式的命令&#xff0c;说明<param>标签指定的是ros2内的参数。不能用于传递非ros2的传入参数 如果要传入非ros2…

【测试基础】构造测试数据之 MySQL 篇

构造测试数据之 MySQL 篇 作为一名测试工程师&#xff0c;我们经常会构造测试数据进行一些功能验证。为了暴露更多的问题&#xff0c;在测试数据的构造上&#xff0c;我们应该尽可能的构造不同类型字段的数据&#xff0c;且一张表的字段最好不低于 10 10 10 个。 对于 MySQL …

在高并发场景下,缓存“雪崩”了怎么办

1. 缓存雪崩的常见原因 缓存“雪崩”是指&#xff0c;因为部分缓存节点不可用&#xff0c;而导致整个缓存系统&#xff08;甚至是整个服务系统&#xff09;不可用。缓存“雪崩”主要分为以下两种情况&#xff1a; 因缓存不支持 rehash 而导致的缓存“雪崩”缓存支持 rehash 时…

基于Vite创建简单Vue3工程

首先安装node.js环境&#xff0c;没有node.js环境&#xff0c;便没有npm命令。 1、Vue3创建执行命令 D:\TABLE\test>npm create vuelatestVue.js - The Progressive JavaScript Framework√ 请输入项目名称&#xff1a; ... vue_test √ 是否使用 TypeScript 语法&#xff…

很想写一个框架,比如,spring

很想写一个框架&#xff0c;比如&#xff0c;spring。 原理很清楚&#xff0c;源码也很熟悉。 可惜力不从心&#xff0c;是不是可以找几个小弟一起做。

Stata18软件安装包下载及安装教程

Stata 18下载链接&#xff1a;https://docs.qq.com/doc/DUm5pRlFJaWV5aWtY 1.选中下载好的安装包&#xff0c;右键选择解压到“Stata18”文件夹 2.选中“SetupStata18.exe”&#xff0c;右键以管理员身份运行 3.点击“Next” 4.选择“I accept.....”,选择“Next” 5.点击“Nex…

分布式系统架构设计之分布式数据存储的扩展方式、主从复制以及分布式一致性

三、水平扩展和垂直扩展 在分布式系统中&#xff0c;数据存储的扩展是为了适应业务的增长和提高系统的性能。分为水平扩展和垂直扩展两种方式&#xff0c;这两种方式在架构设计和应用场景上有着不同的优势和局限性。 水平扩展 水平扩展是通过增加节点或服务器的数量来扩大整…

【Vulnhub 靶场】【Looz: 1】【简单】【20210802】

1、环境介绍 靶场介绍&#xff1a;https://www.vulnhub.com/entry/looz-1,732/ 靶场下载&#xff1a;https://download.vulnhub.com/looz/Looz.zip 靶场难度&#xff1a;简单 发布日期&#xff1a;2021年08月02日 文件大小&#xff1a;2.1 GB 靶场作者&#xff1a;mhz_cyber &…

开发Python网络爬虫应用,爬取链家新房楼盘信息保存到mongodb中,并分析相关数据

这里写自定义目录标题 爬取代码分析数据问题 爬取代码 import requests import time from lxml import html from pymongo import MongoClient import randomBASEURL https://cq.fang.lianjia.com/loupan/# 获取某市区域的所有链接 def get_areas(url):print(获取区县列表)# …

QT上位机开发(抽奖软件)

【 声明&#xff1a;版权所有&#xff0c;欢迎转载&#xff0c;请勿用于商业用途。 联系信箱&#xff1a;feixiaoxing 163.com】 用抽奖软件抽奖&#xff0c;是一种很常见的抽奖方式。特别是写这篇文章的时候&#xff0c;正好处于2023年12月31日&#xff0c;也是一年中最后一天…

蓝牙物联网智能门控系统设计方案

随着电子信息技术的飞速发展&#xff0c;物联网技术提升到国家战略高度&#xff0c;研发和应用进程加速并不断取得实质性进展。物联网核心技术包括传感测试技术、网络通信技术、云计算等&#xff0c;具有广域覆盖、大容量、超低功耗和低成本等特点&#xff0c;目前在远程监控、…

win11 电脑睡眠功能失效了如何修复 win11 禁止鼠标唤醒

1、win11睡眠不管用怎么办&#xff0c;win11电脑睡眠功能失效了如何修复 在win11系统中拥有许多令人激动的新功能和改进&#xff0c;有些用户在使用win11电脑时可能会遇到一个问题&#xff1a;睡眠模式不起作用。当他们尝试将计算机置于睡眠状态时&#xff0c;却发现系统无法进…

学习SpringCloud微服务

SpringCloud 微服务单体框架微服务框架SpringCloud微服务拆分微服务差分原则拆分商品服务拆分购物车服务拆分用户服务拆分交易服务拆分支付服务服务调用RestTemplate远程调用 微服务拆分总结 服务治理注册中心Nacos注册中心服务注册服务发现 OpenFeign实现远程调用快速入门引入…

Plantuml之JSON数据语法介绍(二十五)

简介&#xff1a; CSDN博客专家&#xff0c;专注Android/Linux系统&#xff0c;分享多mic语音方案、音视频、编解码等技术&#xff0c;与大家一起成长&#xff01; 优质专栏&#xff1a;Audio工程师进阶系列【原创干货持续更新中……】&#x1f680; 优质专栏&#xff1a;多媒…