Search in sources :

Example 11 with FaceManager

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

the class FaceSetupSliceTest method getSlice_faceEnrolled_shouldReEnroll_shouldReturnSlice.

@Test
public void getSlice_faceEnrolled_shouldReEnroll_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, 1);
    final FaceSetupSlice setupSlice = new FaceSetupSlice(mContext);
    assertThat(setupSlice.getSlice()).isNotNull();
}
Also used : FaceManager(android.hardware.face.FaceManager) Test(org.junit.Test)

Example 12 with FaceManager

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

the class FaceSettings method isFaceHardwareDetected.

/**
 * @param context
 * @return true if the Face hardware is detected.
 */
public static boolean isFaceHardwareDetected(Context context) {
    FaceManager manager = Utils.getFaceManagerOrNull(context);
    boolean isHardwareDetected = false;
    if (manager == null) {
        Log.d(TAG, "FaceManager is null");
    } else {
        isHardwareDetected = manager.isHardwareDetected();
        Log.d(TAG, "FaceManager is not null. Hardware detected: " + isHardwareDetected);
    }
    return manager != null && isHardwareDetected;
}
Also used : FaceManager(android.hardware.face.FaceManager)

Example 13 with FaceManager

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

the class FaceSettings method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final Context context = getPrefContext();
    if (!isFaceHardwareDetected(context)) {
        Log.w(TAG, "no faceManager, finish this");
        finish();
        return;
    }
    mUserManager = context.getSystemService(UserManager.class);
    mFaceManager = context.getSystemService(FaceManager.class);
    mToken = getIntent().getByteArrayExtra(KEY_TOKEN);
    mSensorId = getIntent().getIntExtra(BiometricEnrollBase.EXTRA_KEY_SENSOR_ID, -1);
    mChallenge = getIntent().getLongExtra(BiometricEnrollBase.EXTRA_KEY_CHALLENGE, 0L);
    mUserId = getActivity().getIntent().getIntExtra(Intent.EXTRA_USER_ID, UserHandle.myUserId());
    mFaceFeatureProvider = FeatureFactory.getFactory(getContext()).getFaceFeatureProvider();
    if (mUserManager.getUserInfo(mUserId).isManagedProfile()) {
        getActivity().setTitle(getActivity().getResources().getString(R.string.security_settings_face_profile_preference_title));
    }
    mLockscreenController = Utils.isMultipleBiometricsSupported(context) ? use(BiometricLockscreenBypassPreferenceController.class) : use(FaceSettingsLockscreenBypassPreferenceController.class);
    mLockscreenController.setUserId(mUserId);
    Preference keyguardPref = findPreference(FaceSettingsKeyguardPreferenceController.KEY);
    Preference appPref = findPreference(FaceSettingsAppPreferenceController.KEY);
    Preference attentionPref = findPreference(FaceSettingsAttentionPreferenceController.KEY);
    Preference confirmPref = findPreference(FaceSettingsConfirmPreferenceController.KEY);
    Preference bypassPref = findPreference(mLockscreenController.getPreferenceKey());
    mTogglePreferences = new ArrayList<>(Arrays.asList(keyguardPref, appPref, attentionPref, confirmPref, bypassPref));
    mRemoveButton = findPreference(FaceSettingsRemoveButtonPreferenceController.KEY);
    mEnrollButton = findPreference(FaceSettingsEnrollButtonPreferenceController.KEY);
    // There is no better way to do this :/
    for (AbstractPreferenceController controller : mControllers) {
        if (controller instanceof FaceSettingsPreferenceController) {
            ((FaceSettingsPreferenceController) controller).setUserId(mUserId);
        } else if (controller instanceof FaceSettingsEnrollButtonPreferenceController) {
            ((FaceSettingsEnrollButtonPreferenceController) controller).setUserId(mUserId);
        }
    }
    mRemoveController.setUserId(mUserId);
    // Don't show keyguard controller for work profile settings.
    if (mUserManager.isManagedProfile(mUserId)) {
        removePreference(FaceSettingsKeyguardPreferenceController.KEY);
        removePreference(mLockscreenController.getPreferenceKey());
    }
    if (savedInstanceState != null) {
        mToken = savedInstanceState.getByteArray(KEY_TOKEN);
    }
}
Also used : Context(android.content.Context) AbstractPreferenceController(com.android.settingslib.core.AbstractPreferenceController) Preference(androidx.preference.Preference) UserManager(android.os.UserManager) FaceManager(android.hardware.face.FaceManager)

Example 14 with FaceManager

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

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);
    final SliceMetadata metadata = SliceMetadata.from(mContext, setupSlice.getSlice());
    assertThat(metadata.isErrorSlice()).isTrue();
}
Also used : SliceMetadata(androidx.slice.SliceMetadata) FaceManager(android.hardware.face.FaceManager) Test(org.junit.Test)

Example 15 with FaceManager

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

the class FaceSetupSliceTest method getSlice_faceEnrolled_shouldReEnroll_shouldReturnSlice.

@Test
public void getSlice_faceEnrolled_shouldReEnroll_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, 1);
    final FaceSetupSlice setupSlice = new FaceSetupSlice(mContext);
    assertThat(setupSlice.getSlice()).isNotNull();
}
Also used : FaceManager(android.hardware.face.FaceManager) Test(org.junit.Test)

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