前言
这一部分简单讲讲底层的实现。
Face HIDL
为了实现 Face HIDL,必须在供应商 (vendor) 指定的库 (library) 里实现 IBiometricsFace.hal
的所有方法。接下来我们就来看看 hardware/interfaces/biometrics/face/1.0/
目录下的源代码。
IBiometricsFace.hal
hardware/interfaces/biometrics/face/1.0/IBiometricsFace.hal
package android.hardware.biometrics.face@1.0;
import IBiometricsFaceClientCallback;
/**
* 用于人脸认证的 HAL 接口
*/
interface IBiometricsFace {
/**
* 设置当前的客户端回调
*/
@callflow(next={"setActiveUser"})
@entry
setCallback(IBiometricsFaceClientCallback clientCallback)
generates (OptionalUint64 result);
/**
* 设置所有随后的 HAL 操作作用于上面的活跃用户
*/
@callflow(next={"authenticate", "generateChallenge", "enumerate", "remove"})
setActiveUser(int32_t userId, string storePath) generates (Status status);
/**
* 生成随机数,用于 token 校验
*/
@callflow(next={"enroll", "revokeChallenge", "setFeature"})
generateChallenge(uint32_t challengeTimeoutSec)
generates (OptionalUint64 result);
/**
* 录入一张用户的人脸
*/
@callflow(next={"cancel", "enroll", "revokeChallenge", "remove"})
enroll(vec<uint8_t> hat, uint32_t timeoutSec, vec<Feature> disabledFeatures)
generates (Status status);
/**
* 撤销随机数
*/
@callflow(next={"authenticate", "setActiveUser", "enumerate", "remove"})
revokeChallenge() generates (Status status);
setFeature(Feature feature, bool enabled, vec<uint8_t> hat, uint32_t faceId)
generates(Status status);
getFeature(Feature feature, uint32_t faceId) generates (OptionalBool result);
/**
* 返回和当前人脸集关联的标识符 (ID),