Search in sources :

Example 51 with FingerprintManager

use of android.hardware.fingerprint.FingerprintManager in project TinyKeePass by sorz.

the class FingerprintUiHelper method start.

public void start(int cipherMode) throws KeyException {
    Cipher cipher;
    try {
        SecureStringStorage storage = new SecureStringStorage(context);
        switch(cipherMode) {
            case Cipher.ENCRYPT_MODE:
                cipher = storage.getEncryptCipher();
                break;
            case Cipher.DECRYPT_MODE:
                cipher = storage.getDecryptCipher();
                break;
            default:
                throw new UnsupportedOperationException("not support such cipher mode");
        }
    } catch (SecureStringStorage.SystemException e) {
        throw new RuntimeException("cannot get cipher", e);
    }
    FingerprintManager.CryptoObject cryptoObject = new FingerprintManager.CryptoObject(cipher);
    FingerprintManager fingerprintManager = (FingerprintManager) context.getSystemService(FINGERPRINT_SERVICE);
    cancellationSignal = new CancellationSignal();
    fingerprintManager.authenticate(cryptoObject, cancellationSignal, 0, this, null);
}
Also used : FingerprintManager(android.hardware.fingerprint.FingerprintManager) Cipher(javax.crypto.Cipher) CancellationSignal(android.os.CancellationSignal)

Example 52 with FingerprintManager

use of android.hardware.fingerprint.FingerprintManager in project AmazeFileManager by TeamAmaze.

the class GeneralDialogCreation method showDecryptFingerprintDialog.

@RequiresApi(api = M)
public static void showDecryptFingerprintDialog(final Context c, MainActivity main, final Intent intent, AppTheme appTheme, final EncryptDecryptUtils.DecryptButtonCallbackInterface decryptButtonCallbackInterface) throws GeneralSecurityException, IOException {
    int accentColor = main.getColorPreference().getColor(ColorUsage.ACCENT);
    MaterialDialog.Builder builder = new MaterialDialog.Builder(c);
    builder.title(c.getString(R.string.crypt_decrypt));
    View rootView = View.inflate(c, R.layout.dialog_decrypt_fingerprint_authentication, null);
    Button cancelButton = (Button) rootView.findViewById(R.id.button_decrypt_fingerprint_cancel);
    cancelButton.setTextColor(accentColor);
    builder.customView(rootView, true);
    builder.canceledOnTouchOutside(false);
    builder.theme(appTheme.getMaterialDialogTheme());
    final MaterialDialog dialog = builder.show();
    cancelButton.setOnClickListener(v -> dialog.cancel());
    FingerprintManager manager = (FingerprintManager) c.getSystemService(Context.FINGERPRINT_SERVICE);
    FingerprintManager.CryptoObject object = new FingerprintManager.CryptoObject(CryptUtil.initCipher(c));
    FingerprintHandler handler = new FingerprintHandler(c, intent, dialog, decryptButtonCallbackInterface);
    handler.authenticate(manager, object);
}
Also used : MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) Button(android.widget.Button) AppCompatButton(android.support.v7.widget.AppCompatButton) FingerprintManager(android.hardware.fingerprint.FingerprintManager) FingerprintHandler(com.amaze.filemanager.utils.FingerprintHandler) View(android.view.View) TextView(android.widget.TextView) RequiresApi(android.support.annotation.RequiresApi)

Example 53 with FingerprintManager

use of android.hardware.fingerprint.FingerprintManager in project android_packages_apps_Settings by omnirom.

the class FingerprintSettings method getFingerprintPreferenceForUser.

public static Preference getFingerprintPreferenceForUser(Context context, final int userId) {
    final FingerprintManager fpm = Utils.getFingerprintManagerOrNull(context);
    if (fpm == null || !fpm.isHardwareDetected()) {
        Log.v(TAG, "No fingerprint hardware detected!!");
        return null;
    }
    Preference fingerprintPreference = new Preference(context);
    fingerprintPreference.setKey(KEY_FINGERPRINT_SETTINGS);
    fingerprintPreference.setTitle(R.string.security_settings_fingerprint_preference_title);
    final List<Fingerprint> items = fpm.getEnrolledFingerprints(userId);
    final int fingerprintCount = items != null ? items.size() : 0;
    final String clazz;
    if (fingerprintCount > 0) {
        fingerprintPreference.setSummary(context.getResources().getQuantityString(R.plurals.security_settings_fingerprint_preference_summary, fingerprintCount, fingerprintCount));
        clazz = FingerprintSettings.class.getName();
    } else {
        fingerprintPreference.setSummary(R.string.security_settings_fingerprint_preference_summary_none);
        clazz = FingerprintEnrollIntroduction.class.getName();
    }
    fingerprintPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            final Context context = preference.getContext();
            final UserManager userManager = UserManager.get(context);
            if (Utils.startQuietModeDialogIfNecessary(context, userManager, userId)) {
                return false;
            }
            Intent intent = new Intent();
            intent.setClassName("com.android.settings", clazz);
            intent.putExtra(Intent.EXTRA_USER_ID, userId);
            context.startActivity(intent);
            return true;
        }
    });
    return fingerprintPreference;
}
Also used : Context(android.content.Context) Fingerprint(android.hardware.fingerprint.Fingerprint) Intent(android.content.Intent) SpannableString(android.text.SpannableString) TextPaint(android.text.TextPaint) Fingerprint(android.hardware.fingerprint.Fingerprint) OnPreferenceClickListener(android.support.v7.preference.Preference.OnPreferenceClickListener) FooterPreference(com.android.settingslib.widget.FooterPreference) TwoTargetPreference(com.android.settingslib.TwoTargetPreference) Preference(android.support.v7.preference.Preference) FingerprintManager(android.hardware.fingerprint.FingerprintManager) UserManager(android.os.UserManager)

Example 54 with FingerprintManager

use of android.hardware.fingerprint.FingerprintManager in project android_packages_apps_Settings by omnirom.

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 55 with FingerprintManager

use of android.hardware.fingerprint.FingerprintManager in project android_packages_apps_Settings by omnirom.

the class SuggestionsChecks method isSuggestionComplete.

public boolean isSuggestionComplete(Tile suggestion) {
    ComponentName component = suggestion.intent.getComponent();
    String className = component.getClassName();
    if (className.equals(WallpaperSuggestionActivity.class.getName())) {
        return hasWallpaperSet();
    } else if (className.equals(WifiCallingSuggestionActivity.class.getName())) {
        return isWifiCallingUnavailableOrEnabled();
    } else if (className.equals(FingerprintSuggestionActivity.class.getName())) {
        return !Utils.hasFingerprintHardware(mContext) || !isFingerprintEnabled() || isNotSingleFingerprintEnrolled();
    } else if (className.equals(ScreenLockSuggestionActivity.class.getName())) {
        return isDeviceSecured();
    } else if (className.equals(FingerprintEnrollSuggestionActivity.class.getName())) {
        final FingerprintManager manager = Utils.getFingerprintManagerOrNull(mContext);
        if (manager == null || !isFingerprintEnabled() || !Utils.hasFingerprintHardware(mContext)) {
            return true;
        }
        return manager.hasEnrolledFingerprints();
    }
    final SuggestionFeatureProvider provider = FeatureFactory.getFactory(mContext).getSuggestionFeatureProvider(mContext);
    return provider.isSuggestionCompleted(mContext, component);
}
Also used : WallpaperSuggestionActivity(com.android.settings.wallpaper.WallpaperSuggestionActivity) FingerprintEnrollSuggestionActivity(com.android.settings.Settings.FingerprintEnrollSuggestionActivity) FingerprintManager(android.hardware.fingerprint.FingerprintManager) ComponentName(android.content.ComponentName) FingerprintSuggestionActivity(com.android.settings.fingerprint.FingerprintSuggestionActivity)

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