Android P 指纹 Framework

从Android的官方API可以查到,向上层提供接口的是FingerprintManager,它的代码在路径frameworks/base/core/java/android/hardware/fingerprint下。

/**
 * A class that coordinates access to the fingerprint hardware.
 * @deprecated See {@link BiometricPrompt} which shows a system-provided dialog upon starting
 * authentication. In a world where devices may have different types of biometric authentication,
 * it's much more realistic to have a system-provided authentication dialog since the method may
 * vary by vendor/device.
 */
@Deprecated
@SystemService(Context.FINGERPRINT_SERVICE)
@RequiresFeature(PackageManager.FEATURE_FINGERPRINT)
public class FingerprintManager implements BiometricFingerprintConstants

frameworks/base/core/java/android/hardware/fingerprint目录下内容其实很少,一共只有几个文件。

这里除了FingerprintManager之外,就只有Fingerprint一个类了,其他都是aidl文件。

粗略的看了下Fingerprint类,它里面的内容超级少,主要是包含了几个成员变量,用来记录指纹的信息。

/**
 * Container for fingerprint metadata.
 * @hide
 */
public final class Fingerprint extends BiometricAuthenticator.BiometricIdentifier {
    private CharSequence mName;
    private int mGroupId;
    private int mFingerId;
    private long mDeviceId; // physical device this is associated with

    public Fingerprint(CharSequence name, int groupId, int fingerId, long deviceId) {
        mName = name;
        mGroupId = groupId;
        mFingerId = fingerId;
        mDeviceId = deviceId;
    }
    //...
}

如果仔细看代码的话,可以发现一个很神奇的东西,那个就Fingerprint类的所有成员都是private的,并且没有提供任何public的set方法!

这个就厉害了,因为有做过指纹部分的朋友一定记得指纹提供一个rename的接口。没有public的set方法,那它又是怎么实现rename接口的呢?

带着问题看源码!

rename方法在Manager中的实现如下:

/**
 * Renames the given fingerprint template
 * @param fpId the fingerprint id
 * @param userId the user who this fingerprint belongs to
 * @param newName the new name
 *
 * @hide
 */
@RequiresPermission(MANAGE_FINGERPRINT)
public void rename(int fpId, int userId, String newName) {
        // Renames the given fpId
        if (mService != null) {
            try {
                mService.rename(fpId, userId, newName);
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
        } else {
    
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值