Search in sources :

Example 1 with FaceManager

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();
}
Also used : FaceManager(android.hardware.face.FaceManager) Test(org.junit.Test)

Example 2 with FaceManager

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();
}
Also used : FaceManager(android.hardware.face.FaceManager) Test(org.junit.Test)

Example 3 with FaceManager

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();
}
Also used : FaceManager(android.hardware.face.FaceManager) Test(org.junit.Test)

Example 4 with FaceManager

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);
    }
}
Also used : FingerprintManager(android.hardware.fingerprint.FingerprintManager) FaceManager(android.hardware.face.FaceManager)

Example 5 with FaceManager

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);
    });
}
Also used : Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent) FaceManager(android.hardware.face.FaceManager)

Aggregations

FaceManager (android.hardware.face.FaceManager)15 Test (org.junit.Test)8 FingerprintManager (android.hardware.fingerprint.FingerprintManager)4 Intent (android.content.Intent)2 LockPatternUtils (com.android.internal.widget.LockPatternUtils)2 PendingIntent (android.app.PendingIntent)1 Context (android.content.Context)1 PackageManager (android.content.pm.PackageManager)1 BiometricManager (android.hardware.biometrics.BiometricManager)1 BiometricError (android.hardware.biometrics.BiometricManager.BiometricError)1 FaceSensorPropertiesInternal (android.hardware.face.FaceSensorPropertiesInternal)1 FingerprintSensorPropertiesInternal (android.hardware.fingerprint.FingerprintSensorPropertiesInternal)1 UserManager (android.os.UserManager)1 Preference (androidx.preference.Preference)1 SliceMetadata (androidx.slice.SliceMetadata)1 AbstractPreferenceController (com.android.settingslib.core.AbstractPreferenceController)1