use of android.hardware.fingerprint.FingerprintManager in project android_packages_apps_Settings by SudaMod.
the class FingerprintEnrollIntroduction method onResume.
@Override
protected void onResume() {
super.onResume();
final FingerprintManager fingerprintManager = Utils.getFingerprintManagerOrNull(this);
int errorMsg = 0;
if (fingerprintManager != null) {
final int max = getResources().getInteger(com.android.internal.R.integer.config_fingerprintMaxTemplatesPerUser);
final int numEnrolledFingerprints = fingerprintManager.getEnrolledFingerprints(mUserId).size();
if (numEnrolledFingerprints >= max) {
errorMsg = R.string.fingerprint_intro_error_max;
}
} else {
errorMsg = R.string.fingerprint_intro_error_unknown;
}
if (errorMsg == 0) {
mErrorText.setText(null);
getNextButton().setVisibility(View.VISIBLE);
} else {
mErrorText.setText(errorMsg);
getNextButton().setVisibility(View.GONE);
}
}
use of android.hardware.fingerprint.FingerprintManager in project android_packages_apps_Settings by SudaMod.
the class SuggestionsChecks method isSuggestionComplete.
public boolean isSuggestionComplete(Tile suggestion) {
ComponentName component = suggestion.intent.getComponent();
String className = component.getClassName();
if (className.equals(WallpaperSuggestionActivity.class.getName())) {
return hasWallpaperSet();
} else if (className.equals(WifiCallingSuggestionActivity.class.getName())) {
return isWifiCallingUnavailableOrEnabled();
} else if (className.equals(FingerprintSuggestionActivity.class.getName())) {
return !Utils.hasFingerprintHardware(mContext) || !isFingerprintEnabled() || isNotSingleFingerprintEnrolled();
} else if (className.equals(ScreenLockSuggestionActivity.class.getName())) {
return isDeviceSecured();
} else if (className.equals(FingerprintEnrollSuggestionActivity.class.getName())) {
final FingerprintManager manager = Utils.getFingerprintManagerOrNull(mContext);
if (manager == null || !isFingerprintEnabled() || !Utils.hasFingerprintHardware(mContext)) {
return true;
}
return manager.hasEnrolledFingerprints();
}
final SuggestionFeatureProvider provider = FeatureFactory.getFactory(mContext).getSuggestionFeatureProvider(mContext);
return provider.isSuggestionCompleted(mContext, component);
}
use of android.hardware.fingerprint.FingerprintManager in project android_packages_apps_Settings by SudaMod.
the class SecuritySettingsTest method testSummaryProvider_noFpHardware_shouldSetSummaryWithNoFingerprint.
@Test
public void testSummaryProvider_noFpHardware_shouldSetSummaryWithNoFingerprint() {
final FingerprintManager fpm = mock(FingerprintManager.class);
when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)).thenReturn(true);
// Cast to Object to workaround a robolectric casting bug
when((Object) mContext.getSystemService(FingerprintManager.class)).thenReturn(fpm);
when(fpm.isHardwareDetected()).thenReturn(false);
mSummaryProvider.setListening(true);
verify(mContext).getString(R.string.security_dashboard_summary_no_fingerprint);
}
use of android.hardware.fingerprint.FingerprintManager in project android_packages_apps_Settings by SudaMod.
the class FingerprintSettings method getFingerprintPreferenceForUser.
public static Preference getFingerprintPreferenceForUser(Context context, final int userId) {
final FingerprintManager fpm = Utils.getFingerprintManagerOrNull(context);
if (fpm == null || !fpm.isHardwareDetected()) {
Log.v(TAG, "No fingerprint hardware detected!!");
return null;
}
Preference fingerprintPreference = new Preference(context);
fingerprintPreference.setKey(KEY_FINGERPRINT_SETTINGS);
fingerprintPreference.setTitle(R.string.security_settings_fingerprint_preference_title);
final List<Fingerprint> items = fpm.getEnrolledFingerprints(userId);
final int fingerprintCount = items != null ? items.size() : 0;
final String clazz;
if (fingerprintCount > 0) {
fingerprintPreference.setSummary(context.getResources().getQuantityString(R.plurals.security_settings_fingerprint_preference_summary, fingerprintCount, fingerprintCount));
clazz = FingerprintSettings.class.getName();
} else {
fingerprintPreference.setSummary(R.string.security_settings_fingerprint_preference_summary_none);
clazz = FingerprintEnrollIntroduction.class.getName();
}
fingerprintPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
final Context context = preference.getContext();
final UserManager userManager = UserManager.get(context);
if (Utils.startQuietModeDialogIfNecessary(context, userManager, userId)) {
return false;
}
Intent intent = new Intent();
intent.setClassName("com.android.settings", clazz);
intent.putExtra(Intent.EXTRA_USER_ID, userId);
context.startActivity(intent);
return true;
}
});
return fingerprintPreference;
}
use of android.hardware.fingerprint.FingerprintManager in project android_packages_apps_Settings by SudaMod.
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 IFingerprintManager fingerprintManagerWrapper = fingerprintManager == null ? null : new FingerprintManagerWrapper(fingerprintManager);
return new SetNewPasswordController(userId, context.getPackageManager(), fingerprintManagerWrapper, (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE), ui);
}
Aggregations