Android11.0源码关于指纹&人脸的录入及解锁源码分析
1. 指纹录入
指纹录入文件路径:
frameworks/base/core/java/android/hardware/fingerprint/FingerprintManager.java
packages/apps/Settings/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollSidecar.java
指纹录入回调:
private FingerprintManager.EnrollmentCallback mEnrollmentCallback
= new FingerprintManager.EnrollmentCallback() {
@Override
public void onEnrollmentProgress(int remaining) {
FingerprintEnrollSidecar.super.onEnrollmentProgress(remaining);
}
@Override
public void onEnrollmentHelp(int helpMsgId, CharSequence helpString) {
FingerprintEnrollSidecar.super.onEnrollmentHelp(helpMsgId, helpString);
}
@Override
public void onEnrollmentError(int errMsgId, CharSequence errString) {
FingerprintEnrollSidecar.super.onEnrollmentError(errMsgId, errString);
}
};
**
2. 人脸录入
** 人脸录入文件路径:
frameworks/base/core/java/android/hardware/face/FaceManager.java
packages/apps/Settings/src/com/android/settings/biometrics/face/FaceEnrollSidecar.java
人脸录入回调:
private FaceManager.EnrollmentCallback mEnrollmentCallback
= new FaceManager.EnrollmentCallback() {
@Override
public void onEnrollmentProgress(int remaining) {
FaceEnrollSidecar.super.onEnrollmentProgress(remaining);
}
@Override
public void onEnrollmentHelp(int helpMsgId, CharSequence helpString) {
FaceEnrollSidecar.super.onEnrollmentHelp(helpMsgId, helpString);
}
@Override
public void onEnrollmentError(int errMsgId, CharSequence errString) {
FaceEnrollSidecar.super.onEnrollmentError(errMsgId, errString);
}
};
3. 指纹解锁
指纹解锁注入回调文件路径:
frameworks/base/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
private FingerprintManager.AuthenticationCallback mFingerprintAuthenticationCallback
= new AuthenticationCallback() {
@Override
public void onAuthenticationFailed() {
handleFingerprintAuthFailed();
}
@Override
public void onAuthenticationSucceeded(AuthenticationResult result) {
Trace.beginSection("KeyguardUpdateMonitor#onAuthenticationSucceeded");
handleFingerprintAuthenticated(result.getUserId(), result.isStrongBiometric());
Trace.endSection();
}
@Override
public void onAuthenticationHelp(int helpMsgId, CharSequence helpString) {
handleFingerprintHelp(helpMsgId, helpString.toString());
}
@Override
public void onAuthenticationError(int errMsgId, CharSequence errString) {
handleFingerprintError(errMsgId, errString.toString());
}
@Override
public void onAuthenticationAcquired(int acquireInfo) {
handleFingerprintAcquired(acquireInfo);
}
};
4. 人脸解锁 人脸解锁注入回调文件路经:
frameworks/base/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
FaceManager.AuthenticationCallback mFaceAuthenticationCallback
= new FaceManager.AuthenticationCallback() {
@Override
public void onAuthenticationFailed() {
handleFaceAuthFailed();
}
@Override
public void onAuthenticationSucceeded(FaceManager.AuthenticationResult result) {
Trace.beginSection("KeyguardUpdateMonitor#onAuthenticationSucceeded");
handleFaceAuthenticated(result.getUserId(), result.isStrongBiometric());
Trace.endSection();
}
@Override
public void onAuthenticationHelp(int helpMsgId, CharSequence helpString) {
handleFaceHelp(helpMsgId, helpString.toString());
}
@Override
public void onAuthenticationError(int errMsgId, CharSequence errString) {
if (errMsgId > 1000) {
}
handleFaceError(errMsgId, errString.toString());
}
@Override
public void onAuthenticationAcquired(int acquireInfo) {
handleFaceAcquired(acquireInfo);
}
};
5.指纹管理 文件路径:
frameworks/base/core/java/android/hardware/fingerprint/FingerprintManager.java
910 private void sendAcquiredResult(long deviceId, int acquireInfo, int vendorCode) {
911 if (mAuthenticationCallback != null) {
912 mAuthenticationCallback.onAuthenticationAcquired(acquireInfo);
913 }
914 final String msg = getAcquiredString(mContext, acquireInfo, vendorCode);
915 if (msg == null) {
916 return;
917 }
918
919 final int clientInfo = acquireInfo == FINGERPRINT_ACQUIRED_VENDOR
920 ? (vendorCode + FINGERPRINT_ACQUIRED_VENDOR_BASE) : acquireInfo;
921 if (mEnrollmentCallback != null) {
922 mEnrollmentCallback.onEnrollmentHelp(clientInfo, msg);
923 } else if (mAuthenticationCallback != null) {
924 if (acquireInfo != BiometricFingerprintConstants.FINGERPRINT_ACQUIRED_START) {
925 mAuthenticationCallback.onAuthenticationHelp(clientInfo, msg);
926 }
927 }
928 }
930 private void sendErrorResult(long deviceId, int errMsgId, int vendorCode) {
931
932 final int clientErrMsgId = errMsgId == FINGERPRINT_ERROR_VENDOR
933 ? (vendorCode + FINGERPRINT_ERROR_VENDOR_BASE) : errMsgId;
934 if (mEnrollmentCallback != null) {
935 mEnrollmentCallback.onEnrollmentError(clientErrMsgId,
936 getErrorString(mContext, errMsgId, vendorCode));
937 } else if (mAuthenticationCallback != null) {
938 mAuthenticationCallback.onAuthenticationError(clientErrMsgId,
939 getErrorString(mContext, errMsgId, vendorCode));
940 } else if (mRemovalCallback != null) {
941 mRemovalCallback.onRemovalError(mRemovalFingerprint, clientErrMsgId,
942 getErrorString(mContext, errMsgId, vendorCode));
943 } else if (mEnumerateCallback != null) {
944 mEnumerateCallback.onEnumerateError(clientErrMsgId,
945 getErrorString(mContext, errMsgId, vendorCode));
946 }
947 }
6.人脸管理 文件路径:
frameworks/base/core/java/android/hardware/face/FaceManager.java
1077 private void sendAcquiredResult(long deviceId, int acquireInfo, int vendorCode) {
1078 if (mAuthenticationCallback != null) {
1079 mAuthenticationCallback.onAuthenticationAcquired(acquireInfo);
1080 }
1081 final String msg = getAcquiredString(mContext, acquireInfo, vendorCode);
1082 final int clientInfo = acquireInfo == FACE_ACQUIRED_VENDOR
1083 ? (vendorCode + FACE_ACQUIRED_VENDOR_BASE) : acquireInfo;
1084 if (mEnrollmentCallback != null) {
1085 mEnrollmentCallback.onEnrollmentHelp(clientInfo, msg);
1086 } else if (mAuthenticationCallback != null && msg != null) {
1087 mAuthenticationCallback.onAuthenticationHelp(clientInfo, msg);
1088 }
1089 }
1041 private void sendErrorResult(long deviceId, int errMsgId, int vendorCode) {
1042
1043 final int clientErrMsgId = errMsgId == FACE_ERROR_VENDOR
1044 ? (vendorCode + FACE_ERROR_VENDOR_BASE) : errMsgId;
1045 if (mEnrollmentCallback != null) {
1046 mEnrollmentCallback.onEnrollmentError(clientErrMsgId,
1047 getErrorString(mContext, errMsgId, vendorCode));
1048 } else if (mAuthenticationCallback != null) {
1049 mAuthenticationCallback.onAuthenticationError(clientErrMsgId,
1050 getErrorString(mContext, errMsgId, vendorCode));
1051 } else if (mRemovalCallback != null) {
1052 mRemovalCallback.onRemovalError(mRemovalFace, clientErrMsgId,
1053 getErrorString(mContext, errMsgId, vendorCode));
1054 }
1055 }
|