Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit af677ddd authored by Udam Saini's avatar Udam Saini Committed by Android (Google) Code Review
Browse files

Merge "Improves flow for fingerprint"

parents 7a89f68f bf1483c3
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -1020,6 +1020,15 @@
    <!-- Summary specifying that this is the current screen lock setting [CHAR LIMIT=45] -->
    <string name="current_screen_lock">Current screen lock</string>
    <!-- Title for preference that guides the user through creating a backup unlock pattern for fingerprint [CHAR LIMIT=45]-->
    <string name="fingerprint_unlock_set_unlock_pattern">Fingerprint + Pattern</string>
    <!-- Title for preference that guides the user through creating a backup unlock PIN for fingerprint [CHAR LIMIT=45]-->
    <string name="fingerprint_unlock_set_unlock_pin">Fingerprint + PIN</string>
    <!-- Title for preference that guides the user through creating a backup unlock password for fingerprint [CHAR LIMIT=45]-->
    <string name="fingerprint_unlock_set_unlock_password">Fingerprint + Password</string>
    <!-- Summary for preference that has been disabled by because of the DevicePolicyAdmin, or because device encryption is enabled, or because there are credentials in the credential storage [CHAR LIMIT=50] -->
    <string name="unlock_set_unlock_disabled_summary">Disabled by administrator, encryption policy, or credential storage</string>
+14 −0
Original line number Diff line number Diff line
@@ -300,6 +300,7 @@ public class ChooseLockGeneric extends SettingsActivity {
                }
                addPreferencesFromResource(R.xml.security_settings_picker);
                disableUnusablePreferences(quality, hideDisabledPrefs);
                updatePreferenceText();
                updateCurrentPreference();
                updatePreferenceSummaryIfNeeded();
            } else {
@@ -307,6 +308,19 @@ public class ChooseLockGeneric extends SettingsActivity {
            }
        }

        private void updatePreferenceText() {
            if (mForFingerprint) {
                Preference pattern = findPreference(KEY_UNLOCK_SET_PATTERN);
                pattern.setTitle(R.string.fingerprint_unlock_set_unlock_pattern);

                Preference pin = findPreference(KEY_UNLOCK_SET_PIN);
                pin.setTitle(R.string.fingerprint_unlock_set_unlock_pin);

                Preference password = findPreference(KEY_UNLOCK_SET_PASSWORD);
                password.setTitle(R.string.fingerprint_unlock_set_unlock_password);
            }
        }

        private void updateCurrentPreference() {
            String currentKey = getKeyForCurrent();
            Preference preference = findPreference(currentKey);
+44 −8
Original line number Diff line number Diff line
@@ -18,11 +18,13 @@ package com.android.settings.fingerprint;

import android.app.admin.DevicePolicyManager;
import android.content.Intent;
import android.hardware.fingerprint.FingerprintManager;
import android.os.Bundle;
import android.os.UserHandle;
import android.view.View;

import com.android.internal.logging.MetricsLogger;
import com.android.settings.ChooseLockGeneric;
import com.android.settings.ChooseLockSettingsHelper;
import com.android.settings.HelpUtils;
import com.android.settings.R;
@@ -32,6 +34,9 @@ import com.android.settings.R;
 */
public class FingerprintEnrollIntroduction extends FingerprintEnrollBase {

    private static final int CHOOSE_LOCK_GENERIC_REQUEST = 1;
    private static final int FINGERPRINT_FIND_SENSOR_REQUEST = 2;

    private boolean mHasPassword;

    @Override
@@ -41,6 +46,12 @@ public class FingerprintEnrollIntroduction extends FingerprintEnrollBase {
        setHeaderText(R.string.security_settings_fingerprint_enroll_introduction_title);
        findViewById(R.id.cancel_button).setOnClickListener(this);
        findViewById(R.id.learn_more_button).setOnClickListener(this);
        final int passwordQuality = new ChooseLockSettingsHelper(this).utils()
                .getActivePasswordQuality(UserHandle.myUserId());
        updatePasswordQuality();
    }

    private void updatePasswordQuality() {
        final int passwordQuality = new ChooseLockSettingsHelper(this).utils()
                .getActivePasswordQuality(UserHandle.myUserId());
        mHasPassword = passwordQuality != DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED;
@@ -48,19 +59,37 @@ public class FingerprintEnrollIntroduction extends FingerprintEnrollBase {

    @Override
    protected void onNextButtonClick() {
        Intent intent;
        if (!mHasPassword) {
            // No fingerprints registered, launch into enrollment wizard.
            intent = getOnboardIntent();
            launchChooseLock();
        } else {
            // Lock thingy is already set up, launch directly into find sensor step from wizard.
            intent = getFindSensorIntent();
            launchFindSensor(null);
        }
        startActivityForResult(intent, 0);
    }

    protected Intent getOnboardIntent() {
        return new Intent(this, FingerprintEnrollOnboard.class);
    private void launchChooseLock() {
        Intent intent = getChooseLockIntent();
        long challenge = getSystemService(FingerprintManager.class).preEnroll();
        intent.putExtra(ChooseLockGeneric.ChooseLockGenericFragment.MINIMUM_QUALITY_KEY,
                DevicePolicyManager.PASSWORD_QUALITY_SOMETHING);
        intent.putExtra(ChooseLockGeneric.ChooseLockGenericFragment.HIDE_DISABLED_PREFS, true);
        intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, true);
        intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, challenge);
        intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_FOR_FINGERPRINT, true);
        startActivityForResult(intent, CHOOSE_LOCK_GENERIC_REQUEST);
    }

    private void launchFindSensor(byte[] token) {
        Intent intent = getFindSensorIntent();
        if (token != null) {
            intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, token);
        }
        startActivityForResult(intent, FINGERPRINT_FIND_SENSOR_REQUEST);
    }

    protected Intent getChooseLockIntent() {
        return new Intent(this, ChooseLockGeneric.class);
    }

    protected Intent getFindSensorIntent() {
@@ -70,8 +99,15 @@ public class FingerprintEnrollIntroduction extends FingerprintEnrollBase {
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (resultCode == RESULT_FINISHED) {
            if (requestCode == FINGERPRINT_FIND_SENSOR_REQUEST) {
                setResult(RESULT_OK);
                finish();
            } else if (requestCode == CHOOSE_LOCK_GENERIC_REQUEST) {
                updatePasswordQuality();
                byte[] token = data.getByteArrayExtra(
                        ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN);
                launchFindSensor(token);
            }
        } else {
            super.onActivityResult(requestCode, resultCode, data);
        }
+3 −2
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.widget.Button;

import com.android.internal.logging.MetricsLogger;
import com.android.settings.R;
import com.android.settings.SetupChooseLockGeneric;
import com.android.settings.SetupWizardUtils;
import com.android.setupwizardlib.view.NavigationBar;

@@ -30,8 +31,8 @@ public class SetupFingerprintEnrollIntroduction extends FingerprintEnrollIntrodu
        implements NavigationBar.NavigationBarListener {

    @Override
    protected Intent getOnboardIntent() {
        final Intent intent = new Intent(this, SetupFingerprintEnrollOnboard.class);
    protected Intent getChooseLockIntent() {
        Intent intent = new Intent(this, SetupChooseLockGeneric.class);
        SetupWizardUtils.copySetupExtras(getIntent(), intent);
        return intent;
    }