use of android.hardware.face.FaceManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class FaceSetupSliceTest method getSlice_faceNotEnrolled_shouldReturnSlice.
@Test
public void getSlice_faceNotEnrolled_shouldReturnSlice() {
final FaceManager faceManager = mock(FaceManager.class);
when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_FACE)).thenReturn(true);
when(faceManager.hasEnrolledTemplates(UserHandle.myUserId())).thenReturn(false);
when(mContext.getSystemService(Context.FACE_SERVICE)).thenReturn(faceManager);
final FaceSetupSlice setupSlice = new FaceSetupSlice(mContext);
assertThat(setupSlice.getSlice()).isNotNull();
}
use of android.hardware.face.FaceManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class FaceSetupSliceTest method getSlice_faceEnrolled_musteEnroll_shouldReturnSlice.
@Test
public void getSlice_faceEnrolled_musteEnroll_shouldReturnSlice() {
final FaceManager faceManager = mock(FaceManager.class);
when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_FACE)).thenReturn(true);
when(faceManager.hasEnrolledTemplates(UserHandle.myUserId())).thenReturn(true);
when(mContext.getSystemService(Context.FACE_SERVICE)).thenReturn(faceManager);
Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.FACE_UNLOCK_RE_ENROLL, 3);
final FaceSetupSlice setupSlice = new FaceSetupSlice(mContext);
assertThat(setupSlice.getSlice()).isNotNull();
}
use of android.hardware.face.FaceManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class FaceSetupSliceTest method getSlice_faceEnrolled_noReEnroll_shouldReturnNull.
@Test
public void getSlice_faceEnrolled_noReEnroll_shouldReturnNull() {
final FaceManager faceManager = mock(FaceManager.class);
when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_FACE)).thenReturn(true);
when(faceManager.hasEnrolledTemplates(UserHandle.myUserId())).thenReturn(true);
when(mContext.getSystemService(Context.FACE_SERVICE)).thenReturn(faceManager);
Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.FACE_UNLOCK_RE_ENROLL, 0);
final FaceSetupSlice setupSlice = new FaceSetupSlice(mContext);
assertThat(setupSlice.getSlice()).isNull();
}
use of android.hardware.face.FaceManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class TopLevelSecurityEntryPreferenceController method getSummary.
@Override
public CharSequence getSummary() {
final FingerprintManager fpm = Utils.getFingerprintManagerOrNull(mContext);
final FaceManager faceManager = Utils.getFaceManagerOrNull(mContext);
if (faceManager != null && faceManager.isHardwareDetected()) {
return mContext.getText(R.string.security_dashboard_summary_face);
} else if (fpm != null && fpm.isHardwareDetected()) {
return mContext.getText(R.string.security_dashboard_summary);
} else {
return mContext.getText(R.string.security_dashboard_summary_no_fingerprint);
}
}
use of android.hardware.face.FaceManager in project android_packages_apps_Settings by omnirom.
the class MultiBiometricEnrollHelper method launchFaceEnroll.
private void launchFaceEnroll() {
final FaceManager faceManager = mActivity.getSystemService(FaceManager.class);
faceManager.generateChallenge(mUserId, (sensorId, userId, challenge) -> {
final byte[] hardwareAuthToken = BiometricUtils.requestGatekeeperHat(mActivity, mGkPwHandle, mUserId, challenge);
final Intent faceIntent = BiometricUtils.getFaceIntroIntent(mActivity, mActivity.getIntent());
faceIntent.putExtra(BiometricEnrollBase.EXTRA_KEY_SENSOR_ID, sensorId);
faceIntent.putExtra(BiometricEnrollBase.EXTRA_KEY_CHALLENGE, challenge);
if (mRequestEnrollFingerprint) {
// Give FaceEnroll a pendingIntent pointing to fingerprint enrollment, so that it
// can be started when user skips or finishes face enrollment. FLAG_UPDATE_CURRENT
// ensures it is launched with the most recent values.
final Intent fpIntent = BiometricUtils.getFingerprintIntroIntent(mActivity, mActivity.getIntent());
fpIntent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_GK_PW_HANDLE, mGkPwHandle);
final PendingIntent fpAfterFaceIntent = PendingIntent.getActivity(mActivity, 0, /* requestCode */
fpIntent, PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT);
faceIntent.putExtra(EXTRA_ENROLL_AFTER_FACE, fpAfterFaceIntent);
}
BiometricUtils.launchEnrollForResult(mActivity, faceIntent, REQUEST_FACE_ENROLL, hardwareAuthToken, mGkPwHandle, mUserId);
});
}
Aggregations