use of android.hardware.fingerprint.FingerprintManager in project android_packages_apps_Settings by SudaMod.
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 android_packages_apps_Settings by SudaMod.
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 android_packages_apps_Settings by SudaMod.
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 QR-Code-Based-Attendance-System by ishan0445.
the class FingerprintActivity method onCreate.
@RequiresApi(api = Build.VERSION_CODES.M)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fingerprint);
// Initializing both Android Keyguard Manager and Fingerprint Manager
KeyguardManager keyguardManager = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);
FingerprintManager fingerprintManager = (FingerprintManager) getSystemService(FINGERPRINT_SERVICE);
textView = (TextView) findViewById(R.id.errorText);
// Check whether the device has a Fingerprint sensor.
if (!fingerprintManager.isHardwareDetected()) {
/**
* An error message will be displayed if the device does not contain the fingerprint hardware.
* However if you plan to implement a default authentication method,
* you can redirect the user to a default authentication activity from here.
* Example:
* Intent intent = new Intent(this, DefaultAuthenticationActivity.class);
* startActivity(intent);
*/
textView.setText("Your Device does not have a Fingerprint Sensor");
} else {
// Checks whether fingerprint permission is set on manifest
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) {
textView.setText("Fingerprint authentication permission not enabled");
} else {
// Check whether at least one fingerprint is registered
if (!fingerprintManager.hasEnrolledFingerprints()) {
textView.setText("Register at least one fingerprint in Settings");
} else {
// Checks whether lock screen security is enabled or not
if (!keyguardManager.isKeyguardSecure()) {
textView.setText("Lock screen security not enabled in Settings");
} else {
generateKey();
if (cipherInit()) {
FingerprintManager.CryptoObject cryptoObject = new FingerprintManager.CryptoObject(cipher);
FingerprintHandler helper = new FingerprintHandler(this);
helper.startAuth(fingerprintManager, cryptoObject);
}
}
}
}
}
}
use of android.hardware.fingerprint.FingerprintManager in project afwall by ukanth.
the class SecPreferenceFragment method canUserFingerPrint.
@TargetApi(Build.VERSION_CODES.M)
private boolean canUserFingerPrint() {
KeyguardManager keyguardManager = (KeyguardManager) globalContext.getSystemService(KEYGUARD_SERVICE);
FingerprintManager fingerprintManager = (FingerprintManager) globalContext.getSystemService(FINGERPRINT_SERVICE);
return fingerprintManager.isHardwareDetected() && ActivityCompat.checkSelfPermission(globalContext, Manifest.permission.USE_FINGERPRINT) == PackageManager.PERMISSION_GRANTED && fingerprintManager.hasEnrolledFingerprints() && keyguardManager.isKeyguardSecure();
}
Aggregations