Search in sources :

Example 66 with FingerprintManager

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);
    }
}
Also used : Button(android.widget.Button) FingerprintManager(android.hardware.fingerprint.FingerprintManager)

Example 67 with FingerprintManager

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);
}
Also used : FingerprintManager(android.hardware.fingerprint.FingerprintManager) Test(org.junit.Test)

Example 68 with FingerprintManager

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);
}
Also used : FingerprintManager(android.hardware.fingerprint.FingerprintManager) Test(org.junit.Test)

Example 69 with FingerprintManager

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);
                    }
                }
            }
        }
    }
}
Also used : FingerprintManager(android.hardware.fingerprint.FingerprintManager) KeyguardManager(android.app.KeyguardManager) RequiresApi(android.support.annotation.RequiresApi)

Example 70 with FingerprintManager

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();
}
Also used : FingerprintManager(android.hardware.fingerprint.FingerprintManager) KeyguardManager(android.app.KeyguardManager) TargetApi(android.annotation.TargetApi)

Aggregations

FingerprintManager (android.hardware.fingerprint.FingerprintManager)82 Test (org.junit.Test)18 Intent (android.content.Intent)11 ComponentName (android.content.ComponentName)8 Button (android.widget.Button)8 KeyguardManager (android.app.KeyguardManager)7 Context (android.content.Context)7 Fingerprint (android.hardware.fingerprint.Fingerprint)7 UserManager (android.os.UserManager)7 Preference (android.support.v7.preference.Preference)7 OnPreferenceClickListener (android.support.v7.preference.Preference.OnPreferenceClickListener)7 SpannableString (android.text.SpannableString)7 TextPaint (android.text.TextPaint)7 LockPatternUtils (com.android.internal.widget.LockPatternUtils)7 FingerprintEnrollSuggestionActivity (com.android.settings.Settings.FingerprintEnrollSuggestionActivity)6 FingerprintSuggestionActivity (com.android.settings.fingerprint.FingerprintSuggestionActivity)6 WallpaperSuggestionActivity (com.android.settings.wallpaper.WallpaperSuggestionActivity)6 TwoTargetPreference (com.android.settingslib.TwoTargetPreference)6 FooterPreference (com.android.settingslib.widget.FooterPreference)6 FaceManager (android.hardware.face.FaceManager)5