use of android.hardware.fingerprint.FingerprintManager in project android-fingerprint-authentication by multidots.
the class FingerPrintAuthHelper method startAuth.
/**
* Start the finger print authentication by enabling the finger print sensor.
* Note: Use this function in the onResume() of the activity/fragment. Never forget to call {@link #stopAuth()}
* in onPause() of the activity/fragment.
*/
@TargetApi(Build.VERSION_CODES.M)
public void startAuth() {
if (isScanning)
stopAuth();
// check if the device supports the finger print hardware?
if (!checkFingerPrintAvailability(mContext))
return;
FingerprintManager fingerprintManager = (FingerprintManager) mContext.getSystemService(Context.FINGERPRINT_SERVICE);
FingerprintManager.CryptoObject cryptoObject = getCryptoObject();
if (cryptoObject == null) {
mCallback.onAuthFailed(AuthErrorCodes.NON_RECOVERABLE_ERROR, ERROR_FAILED_TO_INIT_CHIPPER);
} else {
mCancellationSignal = new CancellationSignal();
// noinspection MissingPermission
fingerprintManager.authenticate(cryptoObject, mCancellationSignal, 0, new FingerprintManager.AuthenticationCallback() {
@Override
public void onAuthenticationError(int errMsgId, CharSequence errString) {
mCallback.onAuthFailed(AuthErrorCodes.NON_RECOVERABLE_ERROR, errString.toString());
}
@Override
public void onAuthenticationHelp(int helpMsgId, CharSequence helpString) {
mCallback.onAuthFailed(AuthErrorCodes.RECOVERABLE_ERROR, helpString.toString());
}
@Override
public void onAuthenticationFailed() {
mCallback.onAuthFailed(AuthErrorCodes.CANNOT_RECOGNIZE_ERROR, null);
}
@Override
public void onAuthenticationSucceeded(FingerprintManager.AuthenticationResult result) {
mCallback.onAuthSuccess(result.getCryptoObject());
}
}, null);
}
}
use of android.hardware.fingerprint.FingerprintManager in project platform_packages_apps_Settings by BlissRoms.
the class FingerprintEnrollFinish method onResume.
@Override
protected void onResume() {
super.onResume();
Button addButton = (Button) findViewById(R.id.add_another_button);
final FingerprintManager fpm = Utils.getFingerprintManagerOrNull(this);
boolean hideAddAnother = false;
if (fpm != null) {
int enrolled = fpm.getEnrolledFingerprints(mUserId).size();
int max = getResources().getInteger(com.android.internal.R.integer.config_fingerprintMaxTemplatesPerUser);
hideAddAnother = enrolled >= max;
}
if (hideAddAnother) {
// Don't show "Add" button if too many fingerprints already added
addButton.setVisibility(View.INVISIBLE);
} else {
addButton.setOnClickListener(this);
}
}
use of android.hardware.fingerprint.FingerprintManager in project platform_packages_apps_Settings by BlissRoms.
the class SecuritySettingsTest method testSummaryProvider_noFpFeature_shouldSetSummaryWithNoFingerprint.
@Test
public void testSummaryProvider_noFpFeature_shouldSetSummaryWithNoFingerprint() {
final FingerprintManager fpm = mock(FingerprintManager.class);
when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)).thenReturn(false);
mSummaryProvider.setListening(true);
verify(mContext).getString(R.string.security_dashboard_summary_no_fingerprint);
}
use of android.hardware.fingerprint.FingerprintManager in project platform_packages_apps_Settings by BlissRoms.
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);
}
use of android.hardware.fingerprint.FingerprintManager in project afwall by ukanth.
the class SecPreferenceFragment method checkFingerprintDeviceSupport.
@TargetApi(Build.VERSION_CODES.M)
private void checkFingerprintDeviceSupport() {
// Initializing both Android Keyguard Manager and Fingerprint Manager
KeyguardManager keyguardManager = (KeyguardManager) globalContext.getSystemService(KEYGUARD_SERVICE);
FingerprintManager fingerprintManager = (FingerprintManager) globalContext.getSystemService(FINGERPRINT_SERVICE);
ListPreference itemList = (ListPreference) findPreference("passSetting");
// Check whether the device has a Fingerprint sensor.
if (!fingerprintManager.isHardwareDetected()) {
Api.toast(globalContext, getString(R.string.device_with_no_fingerprint_sensor));
itemList.setValueIndex(0);
} else {
// Checks whether fingerprint permission is set on manifest
if (ActivityCompat.checkSelfPermission(globalContext, Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) {
Api.toast(globalContext, getString(R.string.fingerprint_permission_manifest_missing));
itemList.setValueIndex(0);
} else {
// Check whether at least one fingerprint is registered
if (!fingerprintManager.hasEnrolledFingerprints()) {
Api.toast(globalContext, getString(R.string.register_at_least_one_fingerprint));
itemList.setValueIndex(0);
} else {
// Checks whether lock screen security is enabled or not
if (!keyguardManager.isKeyguardSecure()) {
Api.toast(globalContext, getString(R.string.lock_screen_not_enabled));
itemList.setValueIndex(0);
} else {
// Anything is ok
if (!G.isFingerprintEnabled()) {
G.isFingerprintEnabled(true);
// make sure we set the index
itemList.setValueIndex(3);
Api.toast(globalContext, getString(R.string.fingerprint_enabled_successfully));
}
return;
}
}
}
}
}
Aggregations