use of android.hardware.fingerprint.FingerprintManager in project android_packages_apps_Settings by LineageOS.
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 AmazeFileManager by TeamAmaze.
the class PrefFrag method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
utilsProvider = ((BasicActivity) getActivity()).getUtilsProvider();
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.preferences);
sharedPref = PreferenceManager.getDefaultSharedPreferences(getActivity());
for (String PREFERENCE_KEY : PREFERENCE_KEYS) {
findPreference(PREFERENCE_KEY).setOnPreferenceClickListener(this);
}
// crypt master password
final Preference masterPasswordPreference = findPreference(PreferencesConstants.PREFERENCE_CRYPT_MASTER_PASSWORD);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2 || sharedPref.getBoolean(PreferencesConstants.PREFERENCE_CRYPT_FINGERPRINT, false)) {
// encryption feature not available
masterPasswordPreference.setEnabled(false);
}
masterPasswordPreference.setOnPreferenceClickListener(this);
CheckBox checkBoxFingerprint = (CheckBox) findPreference(PreferencesConstants.PREFERENCE_CRYPT_FINGERPRINT);
try {
// finger print sensor
final FingerprintManager fingerprintManager = (FingerprintManager) getActivity().getSystemService(Context.FINGERPRINT_SERVICE);
final KeyguardManager keyguardManager = (KeyguardManager) getActivity().getSystemService(Context.KEYGUARD_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && fingerprintManager.isHardwareDetected()) {
checkBoxFingerprint.setEnabled(true);
}
checkBoxFingerprint.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) {
Toast.makeText(getActivity(), getResources().getString(R.string.crypt_fingerprint_no_permission), Toast.LENGTH_LONG).show();
return false;
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !fingerprintManager.hasEnrolledFingerprints()) {
Toast.makeText(getActivity(), getResources().getString(R.string.crypt_fingerprint_not_enrolled), Toast.LENGTH_LONG).show();
return false;
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !keyguardManager.isKeyguardSecure()) {
Toast.makeText(getActivity(), getResources().getString(R.string.crypt_fingerprint_no_security), Toast.LENGTH_LONG).show();
return false;
}
masterPasswordPreference.setEnabled(false);
return true;
}
});
} catch (NoClassDefFoundError error) {
error.printStackTrace();
// fingerprint manager class not defined in the framework
checkBoxFingerprint.setEnabled(false);
}
}
use of android.hardware.fingerprint.FingerprintManager in project android_packages_apps_Settings by omnirom.
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 omnirom.
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 omnirom.
the class SecuritySettingsTest method testSummaryProvider_hasFingerPrint_hasStaticSummary.
@Test
public void testSummaryProvider_hasFingerPrint_hasStaticSummary() {
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(true);
mSummaryProvider.setListening(true);
verify(mContext).getString(R.string.security_dashboard_summary);
}
Aggregations