Loading core/java/android/hardware/face/FaceAuthenticationFrame.aidl 0 → 100644 +21 −0 Original line number Diff line number Diff line /* * Copyright (C) 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.hardware.face; /** * @hide */ parcelable FaceAuthenticationFrame; core/java/android/hardware/face/FaceDataFrame.java +16 −0 Original line number Diff line number Diff line Loading @@ -62,6 +62,22 @@ public final class FaceDataFrame implements Parcelable { mIsCancellable = isCancellable; } /** * A container for data common to {@link FaceAuthenticationFrame} and {@link FaceEnrollFrame}. * * @param acquiredInfo An integer corresponding to a known acquired message. * @param vendorCode An integer representing a custom vendor-specific message. Ignored unless * {@code acquiredInfo} is {@code FACE_ACQUIRED_VENDOR}. */ public FaceDataFrame(int acquiredInfo, int vendorCode) { mAcquiredInfo = acquiredInfo; mVendorCode = vendorCode; mPan = 0f; mTilt = 0f; mDistance = 0f; mIsCancellable = false; } /** * @return An integer corresponding to a known acquired message. * Loading core/java/android/hardware/face/FaceEnrollFrame.aidl 0 → 100644 +21 −0 Original line number Diff line number Diff line /* * Copyright (C) 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.hardware.face; /** * @hide */ parcelable FaceEnrollFrame; core/java/android/hardware/face/FaceEnrollStage.java +6 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import java.lang.annotation.RetentionPolicy; */ @Retention(RetentionPolicy.SOURCE) @IntDef({ FaceEnrollStage.UNKNOWN, FaceEnrollStage.FIRST_FRAME_RECEIVED, FaceEnrollStage.WAITING_FOR_CENTERING, FaceEnrollStage.HOLD_STILL_IN_CENTER, Loading @@ -36,6 +37,11 @@ import java.lang.annotation.RetentionPolicy; FaceEnrollStage.ENROLLMENT_FINISHED }) public @interface FaceEnrollStage { /** * The current enrollment stage is not known. */ int UNKNOWN = -1; /** * Enrollment has just begun. No action is needed from the user yet. */ Loading core/java/android/hardware/face/FaceManager.java +69 −14 Original line number Diff line number Diff line Loading @@ -71,17 +71,19 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan private static final int MSG_FACE_DETECTED = 109; private static final int MSG_CHALLENGE_INTERRUPTED = 110; private static final int MSG_CHALLENGE_INTERRUPT_FINISHED = 111; private static final int MSG_AUTHENTICATION_FRAME = 112; private static final int MSG_ENROLLMENT_FRAME = 113; private final IFaceService mService; private final Context mContext; private IBinder mToken = new Binder(); private AuthenticationCallback mAuthenticationCallback; private FaceDetectionCallback mFaceDetectionCallback; private EnrollmentCallback mEnrollmentCallback; private RemovalCallback mRemovalCallback; private SetFeatureCallback mSetFeatureCallback; private GetFeatureCallback mGetFeatureCallback; private GenerateChallengeCallback mGenerateChallengeCallback; @Nullable private AuthenticationCallback mAuthenticationCallback; @Nullable private FaceDetectionCallback mFaceDetectionCallback; @Nullable private EnrollmentCallback mEnrollmentCallback; @Nullable private RemovalCallback mRemovalCallback; @Nullable private SetFeatureCallback mSetFeatureCallback; @Nullable private GetFeatureCallback mGetFeatureCallback; @Nullable private GenerateChallengeCallback mGenerateChallengeCallback; private CryptoObject mCryptoObject; private Face mRemovalFace; private Handler mHandler; Loading Loading @@ -154,6 +156,16 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan public void onChallengeInterruptFinished(int sensorId) { mHandler.obtainMessage(MSG_CHALLENGE_INTERRUPT_FINISHED, sensorId).sendToTarget(); } @Override public void onAuthenticationFrame(FaceAuthenticationFrame frame) { mHandler.obtainMessage(MSG_AUTHENTICATION_FRAME, frame).sendToTarget(); } @Override public void onEnrollmentFrame(FaceEnrollFrame frame) { mHandler.obtainMessage(MSG_ENROLLMENT_FRAME, frame).sendToTarget(); } }; /** Loading Loading @@ -1248,6 +1260,12 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan case MSG_CHALLENGE_INTERRUPT_FINISHED: sendChallengeInterruptFinished((int) msg.obj /* sensorId */); break; case MSG_AUTHENTICATION_FRAME: sendAuthenticationFrame((FaceAuthenticationFrame) msg.obj /* frame */); break; case MSG_ENROLLMENT_FRAME: sendEnrollmentFrame((FaceEnrollFrame) msg.obj /* frame */); break; default: Slog.w(TAG, "Unknown message: " + msg.what); } Loading Loading @@ -1349,15 +1367,52 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan private void sendAcquiredResult(int acquireInfo, int vendorCode) { if (mAuthenticationCallback != null) { final FaceAuthenticationFrame frame = new FaceAuthenticationFrame( new FaceDataFrame(acquireInfo, vendorCode)); sendAuthenticationFrame(frame); } else if (mEnrollmentCallback != null) { final FaceEnrollFrame frame = new FaceEnrollFrame( null /* cell */, FaceEnrollStage.UNKNOWN, new FaceDataFrame(acquireInfo, vendorCode)); sendEnrollmentFrame(frame); } } private void sendAuthenticationFrame(@Nullable FaceAuthenticationFrame frame) { if (frame == null) { Slog.w(TAG, "Received null authentication frame"); } else if (mAuthenticationCallback != null) { // TODO(b/178414967): Send additional frame data to callback final int acquireInfo = frame.getData().getAcquiredInfo(); final int vendorCode = frame.getData().getVendorCode(); final int helpCode = getHelpCode(acquireInfo, vendorCode); final String helpMessage = getAcquiredString(mContext, acquireInfo, vendorCode); mAuthenticationCallback.onAuthenticationAcquired(acquireInfo); // Ensure that only non-null help messages are sent. if (helpMessage != null) { mAuthenticationCallback.onAuthenticationHelp(helpCode, helpMessage); } } final String msg = getAcquiredString(mContext, acquireInfo, vendorCode); final int clientInfo = acquireInfo == FACE_ACQUIRED_VENDOR ? (vendorCode + FACE_ACQUIRED_VENDOR_BASE) : acquireInfo; if (mEnrollmentCallback != null) { mEnrollmentCallback.onEnrollmentHelp(clientInfo, msg); } else if (mAuthenticationCallback != null && msg != null) { mAuthenticationCallback.onAuthenticationHelp(clientInfo, msg); } private void sendEnrollmentFrame(@Nullable FaceEnrollFrame frame) { if (frame == null) { Slog.w(TAG, "Received null enrollment frame"); } else if (mEnrollmentCallback != null) { // TODO(b/178414967): Send additional frame data to callback final int acquireInfo = frame.getData().getAcquiredInfo(); final int vendorCode = frame.getData().getVendorCode(); final int helpCode = getHelpCode(acquireInfo, vendorCode); final String helpMessage = getAcquiredString(mContext, acquireInfo, vendorCode); mEnrollmentCallback.onEnrollmentHelp(helpCode, helpMessage); } } private static int getHelpCode(int acquireInfo, int vendorCode) { return acquireInfo == FACE_ACQUIRED_VENDOR ? vendorCode + FACE_ACQUIRED_VENDOR_BASE : acquireInfo; } } Loading
core/java/android/hardware/face/FaceAuthenticationFrame.aidl 0 → 100644 +21 −0 Original line number Diff line number Diff line /* * Copyright (C) 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.hardware.face; /** * @hide */ parcelable FaceAuthenticationFrame;
core/java/android/hardware/face/FaceDataFrame.java +16 −0 Original line number Diff line number Diff line Loading @@ -62,6 +62,22 @@ public final class FaceDataFrame implements Parcelable { mIsCancellable = isCancellable; } /** * A container for data common to {@link FaceAuthenticationFrame} and {@link FaceEnrollFrame}. * * @param acquiredInfo An integer corresponding to a known acquired message. * @param vendorCode An integer representing a custom vendor-specific message. Ignored unless * {@code acquiredInfo} is {@code FACE_ACQUIRED_VENDOR}. */ public FaceDataFrame(int acquiredInfo, int vendorCode) { mAcquiredInfo = acquiredInfo; mVendorCode = vendorCode; mPan = 0f; mTilt = 0f; mDistance = 0f; mIsCancellable = false; } /** * @return An integer corresponding to a known acquired message. * Loading
core/java/android/hardware/face/FaceEnrollFrame.aidl 0 → 100644 +21 −0 Original line number Diff line number Diff line /* * Copyright (C) 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.hardware.face; /** * @hide */ parcelable FaceEnrollFrame;
core/java/android/hardware/face/FaceEnrollStage.java +6 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import java.lang.annotation.RetentionPolicy; */ @Retention(RetentionPolicy.SOURCE) @IntDef({ FaceEnrollStage.UNKNOWN, FaceEnrollStage.FIRST_FRAME_RECEIVED, FaceEnrollStage.WAITING_FOR_CENTERING, FaceEnrollStage.HOLD_STILL_IN_CENTER, Loading @@ -36,6 +37,11 @@ import java.lang.annotation.RetentionPolicy; FaceEnrollStage.ENROLLMENT_FINISHED }) public @interface FaceEnrollStage { /** * The current enrollment stage is not known. */ int UNKNOWN = -1; /** * Enrollment has just begun. No action is needed from the user yet. */ Loading
core/java/android/hardware/face/FaceManager.java +69 −14 Original line number Diff line number Diff line Loading @@ -71,17 +71,19 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan private static final int MSG_FACE_DETECTED = 109; private static final int MSG_CHALLENGE_INTERRUPTED = 110; private static final int MSG_CHALLENGE_INTERRUPT_FINISHED = 111; private static final int MSG_AUTHENTICATION_FRAME = 112; private static final int MSG_ENROLLMENT_FRAME = 113; private final IFaceService mService; private final Context mContext; private IBinder mToken = new Binder(); private AuthenticationCallback mAuthenticationCallback; private FaceDetectionCallback mFaceDetectionCallback; private EnrollmentCallback mEnrollmentCallback; private RemovalCallback mRemovalCallback; private SetFeatureCallback mSetFeatureCallback; private GetFeatureCallback mGetFeatureCallback; private GenerateChallengeCallback mGenerateChallengeCallback; @Nullable private AuthenticationCallback mAuthenticationCallback; @Nullable private FaceDetectionCallback mFaceDetectionCallback; @Nullable private EnrollmentCallback mEnrollmentCallback; @Nullable private RemovalCallback mRemovalCallback; @Nullable private SetFeatureCallback mSetFeatureCallback; @Nullable private GetFeatureCallback mGetFeatureCallback; @Nullable private GenerateChallengeCallback mGenerateChallengeCallback; private CryptoObject mCryptoObject; private Face mRemovalFace; private Handler mHandler; Loading Loading @@ -154,6 +156,16 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan public void onChallengeInterruptFinished(int sensorId) { mHandler.obtainMessage(MSG_CHALLENGE_INTERRUPT_FINISHED, sensorId).sendToTarget(); } @Override public void onAuthenticationFrame(FaceAuthenticationFrame frame) { mHandler.obtainMessage(MSG_AUTHENTICATION_FRAME, frame).sendToTarget(); } @Override public void onEnrollmentFrame(FaceEnrollFrame frame) { mHandler.obtainMessage(MSG_ENROLLMENT_FRAME, frame).sendToTarget(); } }; /** Loading Loading @@ -1248,6 +1260,12 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan case MSG_CHALLENGE_INTERRUPT_FINISHED: sendChallengeInterruptFinished((int) msg.obj /* sensorId */); break; case MSG_AUTHENTICATION_FRAME: sendAuthenticationFrame((FaceAuthenticationFrame) msg.obj /* frame */); break; case MSG_ENROLLMENT_FRAME: sendEnrollmentFrame((FaceEnrollFrame) msg.obj /* frame */); break; default: Slog.w(TAG, "Unknown message: " + msg.what); } Loading Loading @@ -1349,15 +1367,52 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan private void sendAcquiredResult(int acquireInfo, int vendorCode) { if (mAuthenticationCallback != null) { final FaceAuthenticationFrame frame = new FaceAuthenticationFrame( new FaceDataFrame(acquireInfo, vendorCode)); sendAuthenticationFrame(frame); } else if (mEnrollmentCallback != null) { final FaceEnrollFrame frame = new FaceEnrollFrame( null /* cell */, FaceEnrollStage.UNKNOWN, new FaceDataFrame(acquireInfo, vendorCode)); sendEnrollmentFrame(frame); } } private void sendAuthenticationFrame(@Nullable FaceAuthenticationFrame frame) { if (frame == null) { Slog.w(TAG, "Received null authentication frame"); } else if (mAuthenticationCallback != null) { // TODO(b/178414967): Send additional frame data to callback final int acquireInfo = frame.getData().getAcquiredInfo(); final int vendorCode = frame.getData().getVendorCode(); final int helpCode = getHelpCode(acquireInfo, vendorCode); final String helpMessage = getAcquiredString(mContext, acquireInfo, vendorCode); mAuthenticationCallback.onAuthenticationAcquired(acquireInfo); // Ensure that only non-null help messages are sent. if (helpMessage != null) { mAuthenticationCallback.onAuthenticationHelp(helpCode, helpMessage); } } final String msg = getAcquiredString(mContext, acquireInfo, vendorCode); final int clientInfo = acquireInfo == FACE_ACQUIRED_VENDOR ? (vendorCode + FACE_ACQUIRED_VENDOR_BASE) : acquireInfo; if (mEnrollmentCallback != null) { mEnrollmentCallback.onEnrollmentHelp(clientInfo, msg); } else if (mAuthenticationCallback != null && msg != null) { mAuthenticationCallback.onAuthenticationHelp(clientInfo, msg); } private void sendEnrollmentFrame(@Nullable FaceEnrollFrame frame) { if (frame == null) { Slog.w(TAG, "Received null enrollment frame"); } else if (mEnrollmentCallback != null) { // TODO(b/178414967): Send additional frame data to callback final int acquireInfo = frame.getData().getAcquiredInfo(); final int vendorCode = frame.getData().getVendorCode(); final int helpCode = getHelpCode(acquireInfo, vendorCode); final String helpMessage = getAcquiredString(mContext, acquireInfo, vendorCode); mEnrollmentCallback.onEnrollmentHelp(helpCode, helpMessage); } } private static int getHelpCode(int acquireInfo, int vendorCode) { return acquireInfo == FACE_ACQUIRED_VENDOR ? vendorCode + FACE_ACQUIRED_VENDOR_BASE : acquireInfo; } }