Move saving face data to fwk
diff --git a/app/src/main/java/com/libremobileos/faceunlock/ScanActivity.java b/app/src/main/java/com/libremobileos/faceunlock/ScanActivity.java
index 6d23635..08661dd 100644
--- a/app/src/main/java/com/libremobileos/faceunlock/ScanActivity.java
+++ b/app/src/main/java/com/libremobileos/faceunlock/ScanActivity.java
@@ -46,8 +46,6 @@
import java.util.List;
import android.hardware.face.FaceManager;
-import android.hardware.biometrics.face.V1_0.FaceError;
-
public class ScanActivity extends CameraActivity {
// AI-based detector
@@ -214,39 +212,27 @@
if (faces.size() == 10) {
String encodedFaces = FaceDataEncoder.encode(faces.stream().map(FaceScanner.Face::getExtra).toArray(float[][]::new));
if (mToken != null) {
- String storeDir = this.getFilesDir().getPath();
try {
- storeDir = faceUnlockManager.getStorePath();
+ faceUnlockManager.finishEnroll(encodedFaces, mToken);
+ final Intent intent = new Intent();
+ ComponentName componentName = ComponentName.unflattenFromString("com.android.settings/com.android.settings.biometrics.face.FaceEnrollFinish");
+ intent.setComponent(componentName);
+ intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT
+ | Intent.FLAG_ACTIVITY_CLEAR_TOP
+ | Intent.FLAG_ACTIVITY_SINGLE_TOP);
+ intent.putExtra(EXTRA_KEY_CHALLENGE_TOKEN, mToken);
+ intent.putExtra(EXTRA_KEY_SENSOR_ID, mSensorId);
+ intent.putExtra(EXTRA_KEY_CHALLENGE, mChallenge);
+ intent.putExtra(EXTRA_FROM_SETTINGS_SUMMARY, mFromSettingsSummary);
+ if (mUserId != 0) {
+ intent.putExtra(EXTRA_USER_ID, mUserId);
+ }
+ startActivity(intent);
+
+ finish();
} catch (RemoteException e) {
e.printStackTrace();
}
- RemoteFaceServiceClient.connect(storeDir, faced -> {
- try {
- if (!faced.enroll(encodedFaces, mToken)) {
- faceUnlockManager.error(FaceError.UNABLE_TO_PROCESS);
- } else {
- faceUnlockManager.enrollResult(0);
- }
- final Intent intent = new Intent();
- ComponentName componentName = ComponentName.unflattenFromString("com.android.settings/com.android.settings.biometrics.face.FaceEnrollFinish");
- intent.setComponent(componentName);
- intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT
- | Intent.FLAG_ACTIVITY_CLEAR_TOP
- | Intent.FLAG_ACTIVITY_SINGLE_TOP);
- intent.putExtra(EXTRA_KEY_CHALLENGE_TOKEN, mToken);
- intent.putExtra(EXTRA_KEY_SENSOR_ID, mSensorId);
- intent.putExtra(EXTRA_KEY_CHALLENGE, mChallenge);
- intent.putExtra(EXTRA_FROM_SETTINGS_SUMMARY, mFromSettingsSummary);
- if (mUserId != 0) {
- intent.putExtra(EXTRA_USER_ID, mUserId);
- }
- startActivity(intent);
-
- finish();
- } catch (RemoteException e) {
- e.printStackTrace();
- }
- });
}
} else {
if (mToken != null) {
diff --git a/app/system_libs/LMOFaceClient.jar b/app/system_libs/LMOFaceClient.jar
index 14c04f0..700314b 100644
--- a/app/system_libs/LMOFaceClient.jar
+++ b/app/system_libs/LMOFaceClient.jar
Binary files differ
diff --git a/framework/client/com/libremobileos/faceunlock/client/FaceUnlockManager.java b/framework/client/com/libremobileos/faceunlock/client/FaceUnlockManager.java
index 5230467..dc95a74 100644
--- a/framework/client/com/libremobileos/faceunlock/client/FaceUnlockManager.java
+++ b/framework/client/com/libremobileos/faceunlock/client/FaceUnlockManager.java
@@ -64,13 +64,13 @@
}
/**
- * Get face data dir storage path
+ * Save Enrolled face and HAT
*/
- public String getStorePath() {
+ public void finishEnroll(String encodedFaces, byte[] token) {
try {
- return mFaceUnlockManager.getStorePath();
+ mFaceUnlockManager.finishEnroll(encodedFaces, token);
} catch (RemoteException e) {
- throw new RuntimeException("Failed when getStorePath(): " + e);
+ throw new RuntimeException("Failed when finishEnroll(): " + e);
}
}
-}
\ No newline at end of file
+}
diff --git a/framework/client/com/libremobileos/faceunlock/client/IFaceUnlockManager.aidl b/framework/client/com/libremobileos/faceunlock/client/IFaceUnlockManager.aidl
index 51d3a74..39909b1 100644
--- a/framework/client/com/libremobileos/faceunlock/client/IFaceUnlockManager.aidl
+++ b/framework/client/com/libremobileos/faceunlock/client/IFaceUnlockManager.aidl
@@ -19,5 +19,5 @@
interface IFaceUnlockManager {
void enrollResult(int remaining);
void error(int error);
- String getStorePath();
-}
\ No newline at end of file
+ void finishEnroll(String encodedFaces, in byte[] token);
+}
diff --git a/framework/server/com/libremobileos/faceunlock/server/FaceUnlockServer.java b/framework/server/com/libremobileos/faceunlock/server/FaceUnlockServer.java
index 590c6dd..8c96a0f 100644
--- a/framework/server/com/libremobileos/faceunlock/server/FaceUnlockServer.java
+++ b/framework/server/com/libremobileos/faceunlock/server/FaceUnlockServer.java
@@ -23,6 +23,7 @@
import android.graphics.Bitmap;
import android.graphics.Matrix;
import android.hardware.biometrics.face.V1_0.FaceAcquiredInfo;
+import android.hardware.biometrics.face.V1_0.FaceError;
import android.hardware.biometrics.face.V1_0.Feature;
import android.hardware.biometrics.face.V1_0.Status;
import android.os.Handler;
@@ -390,12 +391,22 @@
}
@Override
- public String getStorePath() {
- return mStorePath;
+ public void finishEnroll(String encodedFaces, byte[] token) {
+ RemoteFaceServiceClient.connect(mStorePath, faced -> {
+ try {
+ if (!faced.enroll(encodedFaces, token)) {
+ mCallback.onError(kDeviceId, mUserId, FaceError.UNABLE_TO_PROCESS, 0);
+ } else {
+ mCallback.onEnrollResult(kDeviceId, kFaceId, mUserId, 0);
+ }
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ });
}
};
public static interface BinderPublishCallback {
public void publishBinderService(String name, IBinder binder);
}
-}
\ No newline at end of file
+}