Search in sources :

Example 6 with FaceManager

use of android.hardware.face.FaceManager in project android_packages_apps_Settings by omnirom.

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 7 with FaceManager

use of android.hardware.face.FaceManager in project android_packages_apps_Settings by omnirom.

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 8 with FaceManager

use of android.hardware.face.FaceManager in project android_packages_apps_Settings by omnirom.

the class BiometricEnrollActivity method onCreate.

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final Intent intent = getIntent();
    if (this instanceof InternalActivity) {
        mUserId = intent.getIntExtra(Intent.EXTRA_USER_ID, UserHandle.myUserId());
        if (BiometricUtils.containsGatekeeperPasswordHandle(getIntent())) {
            mGkPwHandle = BiometricUtils.getGatekeeperPasswordHandle(getIntent());
        }
    }
    if (savedInstanceState != null) {
        mConfirmingCredentials = savedInstanceState.getBoolean(SAVED_STATE_CONFIRMING_CREDENTIALS, false);
        mIsEnrollActionLogged = savedInstanceState.getBoolean(SAVED_STATE_ENROLL_ACTION_LOGGED, false);
        mParentalOptions = savedInstanceState.getBundle(SAVED_STATE_PARENTAL_OPTIONS);
        if (savedInstanceState.containsKey(SAVED_STATE_GK_PW_HANDLE)) {
            mGkPwHandle = savedInstanceState.getLong(SAVED_STATE_GK_PW_HANDLE);
        }
    }
    // Log a framework stats event if this activity was launched via intent action.
    if (!mIsEnrollActionLogged && ACTION_BIOMETRIC_ENROLL.equals(intent.getAction())) {
        mIsEnrollActionLogged = true;
        // Get the current status for each authenticator type.
        @BiometricError final int strongBiometricStatus;
        @BiometricError final int weakBiometricStatus;
        @BiometricError final int deviceCredentialStatus;
        final BiometricManager bm = getSystemService(BiometricManager.class);
        if (bm != null) {
            strongBiometricStatus = bm.canAuthenticate(Authenticators.BIOMETRIC_STRONG);
            weakBiometricStatus = bm.canAuthenticate(Authenticators.BIOMETRIC_WEAK);
            deviceCredentialStatus = bm.canAuthenticate(Authenticators.DEVICE_CREDENTIAL);
        } else {
            strongBiometricStatus = BiometricManager.BIOMETRIC_ERROR_NO_HARDWARE;
            weakBiometricStatus = BiometricManager.BIOMETRIC_ERROR_NO_HARDWARE;
            deviceCredentialStatus = BiometricManager.BIOMETRIC_ERROR_NO_HARDWARE;
        }
        FrameworkStatsLog.write(FrameworkStatsLog.AUTH_ENROLL_ACTION_INVOKED, strongBiometricStatus == BiometricManager.BIOMETRIC_SUCCESS, weakBiometricStatus == BiometricManager.BIOMETRIC_SUCCESS, deviceCredentialStatus == BiometricManager.BIOMETRIC_SUCCESS, intent.hasExtra(EXTRA_BIOMETRIC_AUTHENTICATORS_ALLOWED), intent.getIntExtra(EXTRA_BIOMETRIC_AUTHENTICATORS_ALLOWED, 0));
    }
    // Put the theme in the intent so it gets propagated to other activities in the flow
    if (intent.getStringExtra(WizardManagerHelper.EXTRA_THEME) == null) {
        intent.putExtra(WizardManagerHelper.EXTRA_THEME, SetupWizardUtils.getThemeString(intent));
    }
    final PackageManager pm = getApplicationContext().getPackageManager();
    mHasFeatureFingerprint = pm.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT);
    mHasFeatureFace = pm.hasSystemFeature(PackageManager.FEATURE_FACE);
    // determine what can be enrolled
    final boolean isSetupWizard = WizardManagerHelper.isAnySetupWizard(getIntent());
    if (mHasFeatureFace) {
        final FaceManager faceManager = getSystemService(FaceManager.class);
        final List<FaceSensorPropertiesInternal> faceProperties = faceManager.getSensorPropertiesInternal();
        if (!faceProperties.isEmpty()) {
            final int maxEnrolls = isSetupWizard ? 1 : faceProperties.get(0).maxEnrollmentsPerUser;
            mIsFaceEnrollable = faceManager.getEnrolledFaces(mUserId).size() < maxEnrolls;
        }
    }
    if (mHasFeatureFingerprint) {
        final FingerprintManager fpManager = getSystemService(FingerprintManager.class);
        final List<FingerprintSensorPropertiesInternal> fpProperties = fpManager.getSensorPropertiesInternal();
        if (!fpProperties.isEmpty()) {
            final int maxEnrolls = isSetupWizard ? 1 : fpProperties.get(0).maxEnrollmentsPerUser;
            mIsFingerprintEnrollable = fpManager.getEnrolledFingerprints(mUserId).size() < maxEnrolls;
        }
    }
    mParentalOptionsRequired = intent.getBooleanExtra(EXTRA_REQUIRE_PARENTAL_CONSENT, false);
    mSkipReturnToParent = intent.getBooleanExtra(EXTRA_SKIP_RETURN_TO_PARENT, false);
    Log.d(TAG, "parentalOptionsRequired: " + mParentalOptionsRequired + ", skipReturnToParent: " + mSkipReturnToParent + ", isSetupWizard: " + isSetupWizard);
    // module. This can be removed when there is a way to notify consent status out of band.
    if (isSetupWizard && mParentalOptionsRequired) {
        Log.w(TAG, "Enrollment with parental consent is not supported when launched " + " directly from SuW - skipping enrollment");
        setResult(RESULT_SKIP);
        finish();
        return;
    }
    // restarting the process once it has been fully completed at least one time.
    if (isSetupWizard && mParentalOptionsRequired) {
        final boolean consentAlreadyManaged = ParentalControlsUtils.parentConsentRequired(this, BiometricAuthenticator.TYPE_FACE | BiometricAuthenticator.TYPE_FINGERPRINT) != null;
        if (consentAlreadyManaged) {
            Log.w(TAG, "Consent was already setup - skipping enrollment");
            setResult(RESULT_SKIP);
            finish();
            return;
        }
    }
    // start enrollment process if we haven't bailed out yet
    if (mParentalOptionsRequired && mParentalOptions == null) {
        mParentalConsentHelper = new ParentalConsentHelper(mIsFaceEnrollable, mIsFingerprintEnrollable, mGkPwHandle);
        setOrConfirmCredentialsNow();
    } else {
        startEnroll();
    }
}
Also used : FingerprintSensorPropertiesInternal(android.hardware.fingerprint.FingerprintSensorPropertiesInternal) BiometricError(android.hardware.biometrics.BiometricManager.BiometricError) Intent(android.content.Intent) FaceSensorPropertiesInternal(android.hardware.face.FaceSensorPropertiesInternal) BiometricManager(android.hardware.biometrics.BiometricManager) PackageManager(android.content.pm.PackageManager) FingerprintManager(android.hardware.fingerprint.FingerprintManager) FaceManager(android.hardware.face.FaceManager)

Example 9 with FaceManager

use of android.hardware.face.FaceManager in project android_packages_apps_Settings by omnirom.

the class SetNewPasswordController method create.

public static SetNewPasswordController create(Context context, Ui ui, Intent intent, IBinder activityToken) {
    // Trying to figure out which user is setting new password. If it is
    // ACTION_SET_NEW_PARENT_PROFILE_PASSWORD or the calling user is not allowed to set
    // separate profile challenge, it is the current user to set new password. Otherwise,
    // it is the user who starts this activity setting new password.
    int userId = ActivityManager.getCurrentUser();
    if (ACTION_SET_NEW_PASSWORD.equals(intent.getAction())) {
        final int callingUserId = Utils.getSecureTargetUser(activityToken, UserManager.get(context), null, intent.getExtras()).getIdentifier();
        final LockPatternUtils lockPatternUtils = new LockPatternUtils(context);
        if (lockPatternUtils.isSeparateProfileChallengeAllowed(callingUserId)) {
            userId = callingUserId;
        }
    }
    // Create a wrapper of FingerprintManager for testing, see IFingerPrintManager for details.
    final FingerprintManager fingerprintManager = Utils.getFingerprintManagerOrNull(context);
    final FaceManager faceManager = Utils.getFaceManagerOrNull(context);
    return new SetNewPasswordController(userId, context.getPackageManager(), fingerprintManager, faceManager, (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE), ui);
}
Also used : FingerprintManager(android.hardware.fingerprint.FingerprintManager) LockPatternUtils(com.android.internal.widget.LockPatternUtils) FaceManager(android.hardware.face.FaceManager)

Example 10 with FaceManager

use of android.hardware.face.FaceManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SetNewPasswordController method create.

public static SetNewPasswordController create(Context context, Ui ui, Intent intent, IBinder activityToken) {
    // Trying to figure out which user is setting new password. If it is
    // ACTION_SET_NEW_PARENT_PROFILE_PASSWORD or the calling user is not allowed to set
    // separate profile challenge, it is the current user to set new password. Otherwise,
    // it is the user who starts this activity setting new password.
    int userId = ActivityManager.getCurrentUser();
    if (ACTION_SET_NEW_PASSWORD.equals(intent.getAction())) {
        final int callingUserId = Utils.getSecureTargetUser(activityToken, UserManager.get(context), null, intent.getExtras()).getIdentifier();
        final LockPatternUtils lockPatternUtils = new LockPatternUtils(context);
        if (lockPatternUtils.isSeparateProfileChallengeAllowed(callingUserId)) {
            userId = callingUserId;
        }
    }
    // Create a wrapper of FingerprintManager for testing, see IFingerPrintManager for details.
    final FingerprintManager fingerprintManager = Utils.getFingerprintManagerOrNull(context);
    final FaceManager faceManager = Utils.getFaceManagerOrNull(context);
    return new SetNewPasswordController(userId, context.getPackageManager(), fingerprintManager, faceManager, (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE), ui);
}
Also used : FingerprintManager(android.hardware.fingerprint.FingerprintManager) LockPatternUtils(com.android.internal.widget.LockPatternUtils) 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