Search in sources :

Example 11 with FingerprintManager

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

Example 12 with FingerprintManager

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);
    }
}
Also used : Preference(android.preference.Preference) CheckBox(com.amaze.filemanager.ui.views.preference.CheckBox) FingerprintManager(android.hardware.fingerprint.FingerprintManager) KeyguardManager(android.app.KeyguardManager)

Example 13 with FingerprintManager

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

Example 14 with FingerprintManager

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

Example 15 with FingerprintManager

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

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