Search in sources :

Example 81 with FingerprintManager

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

the class FingerprintEnrollFindSensor method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final FingerprintManager fingerprintManager = getSystemService(FingerprintManager.class);
    final List<FingerprintSensorPropertiesInternal> props = fingerprintManager.getSensorPropertiesInternal();
    mCanAssumeUdfps = props != null && props.size() == 1 && props.get(0).isAnyUdfpsType();
    setContentView(getContentView());
    mFooterBarMixin = getLayout().getMixin(FooterBarMixin.class);
    mFooterBarMixin.setSecondaryButton(new FooterButton.Builder(this).setText(R.string.security_settings_fingerprint_enroll_enrolling_skip).setListener(this::onSkipButtonClick).setButtonType(FooterButton.ButtonType.SKIP).setTheme(R.style.SudGlifButton_Secondary).build());
    if (mCanAssumeUdfps) {
        setHeaderText(R.string.security_settings_udfps_enroll_find_sensor_title);
        setDescriptionText(R.string.security_settings_udfps_enroll_find_sensor_message);
        mFooterBarMixin.setPrimaryButton(new FooterButton.Builder(this).setText(R.string.security_settings_udfps_enroll_find_sensor_start_button).setListener(this::onStartButtonClick).setButtonType(FooterButton.ButtonType.NEXT).setTheme(R.style.SudGlifButton_Primary).build());
    } else {
        setHeaderText(R.string.security_settings_fingerprint_enroll_find_sensor_title);
        setDescriptionText(R.string.security_settings_fingerprint_enroll_find_sensor_message);
    }
    // adb shell am start -a android.app.action.SET_NEW_PASSWORD
    if (mToken == null && BiometricUtils.containsGatekeeperPasswordHandle(getIntent())) {
        final FingerprintManager fpm = getSystemService(FingerprintManager.class);
        fpm.generateChallenge(mUserId, (sensorId, userId, challenge) -> {
            mChallenge = challenge;
            mSensorId = sensorId;
            mToken = BiometricUtils.requestGatekeeperHat(this, getIntent(), mUserId, challenge);
            // Put this into the intent. This is really just to work around the fact that the
            // enrollment sidecar gets the HAT from the activity's intent, rather than having
            // it passed in.
            getIntent().putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken);
            startLookingForFingerprint();
        });
    } else if (mToken != null) {
        // HAT passed in from somewhere else, such as FingerprintEnrollIntroduction
        startLookingForFingerprint();
    } else {
        // There's something wrong with the enrollment flow, this should never happen.
        throw new IllegalStateException("HAT and GkPwHandle both missing...");
    }
    mAnimation = null;
    if (!mCanAssumeUdfps) {
        View animationView = findViewById(R.id.fingerprint_sensor_location_animation);
        if (animationView instanceof FingerprintFindSensorAnimation) {
            mAnimation = (FingerprintFindSensorAnimation) animationView;
        }
    }
}
Also used : FingerprintSensorPropertiesInternal(android.hardware.fingerprint.FingerprintSensorPropertiesInternal) FingerprintManager(android.hardware.fingerprint.FingerprintManager) FooterBarMixin(com.google.android.setupcompat.template.FooterBarMixin) View(android.view.View)

Example 82 with FingerprintManager

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

the class FingerprintEnrollFinish method updateFingerprintSuggestionEnableState.

private void updateFingerprintSuggestionEnableState() {
    final FingerprintManager fpm = Utils.getFingerprintManagerOrNull(this);
    if (fpm != null) {
        int enrolled = fpm.getEnrolledFingerprints(mUserId).size();
        // Only show "Add another fingerprint" if the user already enrolled one.
        // "Add fingerprint" will be shown in the main flow if the user hasn't enrolled any
        // fingerprints. If the user already added more than one fingerprint, they already know
        // to add multiple fingerprints so we don't show the suggestion.
        int flag = (enrolled == 1) ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
        ComponentName componentName = new ComponentName(getApplicationContext(), FINGERPRINT_SUGGESTION_ACTIVITY);
        getPackageManager().setComponentEnabledSetting(componentName, flag, PackageManager.DONT_KILL_APP);
        Log.d(TAG, FINGERPRINT_SUGGESTION_ACTIVITY + " enabled state = " + (enrolled == 1));
    }
}
Also used : FingerprintManager(android.hardware.fingerprint.FingerprintManager) ComponentName(android.content.ComponentName)

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