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();
}
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;
}
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);
}
}
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();
}
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();
}
Aggregations