文件路径:
/packages/apps/Settings/src/com/android/settings/fingerprint/FingerprintEnrollEnrolling.java
protected void onStart() {
super.onStart();
mSidecar = (FingerprintEnrollSidecar) getFragmentManager().findFragmentByTag(TAG_SIDECAR);
if (mSidecar == null) {
mSidecar = new FingerprintEnrollSidecar();
getFragmentManager().beginTransaction().add(mSidecar, TAG_SIDECAR).commit();
}
mSidecar.setListener(this);//设置监听
updateProgress(false /* animate */);
updateDescription();
if (mRestoring) {
startIconAnimation();
}
}
此处会创建FingerprintEnrollSidecar类。
public void onStart() {
super.onStart();
if (!mEnrolling) {
startEnrollment();//启动录入
}
}
private void startEnrollment() {
mHandler.removeCallbacks(mTimeoutRunnable);
mEnrollmentSteps = -1;
mEnrollmentCancel = new CancellationSignal();
getActivity().getSystemService(FingerprintManager.class).enroll(mToken, mEnrollmentCancel,0 /* flags */, mEnrollmentCallback);//调用FingerprintManager类中方法enroll
mEnrolling = true;
}
public void enroll(byte [] token, CancellationSignal cancel, int flags,
EnrollmentCallback callback) {
if (mService != null) try {
mEnrollmentCallback = callback;
mService.enroll(mToken, token, getCurrentUserId(), mServiceReceiver, flags);//通过aidl远程调用服务
} catch (RemoteException e) {
Log.w(TAG, "Remote exception in enroll: ", e);
}
}
文件路径:
/frameworks/base/services/core/java/com/android/server/fingerprint/FingerprintService.java
private final class FingerprintServiceWrapper extends IFingerprintService.Stub {
// Binder call
public void enroll(final IBinder token, final byte[] cryptoToken, final int groupId, final IFingerprintServiceReceiver receiver, final int flags) {
......
mHandler.post(new Runnable() {
@Override
public void run() {
startEnrollment(token, cryptoClone, effectiveGroupId, receiver, flags, restricted);//启动注册
}
});
}
}
private void startEnrollment(IBinder token, byte [] cryptoToken, int userId,IFingerprintServiceReceiver receiver, int flags, boolean restricted,
String opPackageName) {
updateActiveGroup(userId, opPackageName);
final int groupId = userId; // default group for fingerprint enrollment
//新建注册客户端类
EnrollClient client = new EnrollClient(getContext(), mHalDeviceId, token, receiver, userId, groupId, cryptoToken, restricted, opPackageName) {
@Override
public IFingerprintDaemon getFingerprintDaemon() {
return FingerprintService.this.getFingerprintDaemon();
}
@Override
public void notifyUserActivity() {
FingerprintService.this.userActivity();
}
};
startClient(client, true /* initiatedByClient */);//启动客户端
}
private void startClient(ClientMonitor newClient, boolean initiatedByClient) {
。。。。。。
newClient.start();//启动客户端
}
public int start() {
IFingerprintDaemon daemon = getFingerprintDaemon();//获取fingerprintd服务
final int result = daemon.enroll(mCryptoToken, getGroupId(), timeout);//通过binder调用fingerprintd
}
status_t BnFingerprintDaemon::onTransact(uint32_t code, const Parcel& data, Parcel* reply,uint32_t flags) {
。。。。。。
case ENROLL: {
CHECK_INTERFACE(IFingerprintDaemon, data, reply);
if (!checkPermission(HAL_FINGERPRINT_PERMISSION)) {
return PERMISSION_DENIED;
}
const ssize_t tokenSize = data.readInt32();
const uint8_t* token = static_cast(data.readInplace(tokenSize));
const int32_t groupId = data.readInt32();
const int32_t timeout = data.readInt32();
const int32_t ret = enroll(token, tokenSize, groupId, timeout);
reply->writeNoException();
reply->writeInt32(ret);
return NO_ERROR;
}
int32_t FingerprintDaemonProxy::enroll(const uint8_t* token, ssize_t tokenSize, int32_t groupId,
int32_t timeout) {
ALOG(LOG_VERBOSE, LOG_TAG, "enroll(gid=%d, timeout=%d)\n", groupId, timeout);
if (tokenSize != sizeof(hw_auth_token_t) ) {
ALOG(LOG_VERBOSE, LOG_TAG, "enroll() : invalid token size %zu\n", tokenSize);
return -1;
}
const hw_auth_token_t* authToken = reinterpret_cast<const hw_auth_token_t*>(token);
return mDevice->enroll(mDevice, authToken, groupId, timeout);//HAL层由指纹厂家实现
}
到此Android指纹框架之enroll流程分析完了,不足之处,欢迎交流;接下来将分析指纹之比对流程,未完待续。。。。。。