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

Commit 996d0dfa authored by Ricky Wai's avatar Ricky Wai
Browse files

Fingerprint should confirm device lock when unified

When unified and adding a fingerprint, the user is prompted to set up
a backup

Bug:27419438
Change-Id: I6cfa8c276ae69a0af51580be390c3da4e9596874
parent 4bbf0653
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.app.Fragment;
import android.app.admin.DevicePolicyManager;
import android.content.Intent;
import android.content.IntentSender;
import android.os.UserManager;

import com.android.internal.widget.LockPatternUtils;

@@ -171,7 +172,8 @@ public final class ChooseLockSettingsHelper {
    private boolean launchConfirmationActivity(int request, @Nullable CharSequence title,
            @Nullable CharSequence header, @Nullable CharSequence description,
            boolean returnCredentials, boolean external, boolean hasChallenge,
            long challenge, int effectiveUserId) {
            long challenge, int userId) {
        final int effectiveUserId = UserManager.get(mActivity).getCredentialOwnerProfile(userId);
        boolean launched = false;

        switch (mLockPatternUtils.getKeyguardStoredPasswordQuality(effectiveUserId)) {
@@ -180,7 +182,7 @@ public final class ChooseLockSettingsHelper {
                        returnCredentials || hasChallenge
                                ? ConfirmLockPattern.InternalActivity.class
                                : ConfirmLockPattern.class, external,
                                hasChallenge, challenge, effectiveUserId);
                                hasChallenge, challenge, userId);
                break;
            case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC:
            case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC_COMPLEX:
@@ -191,7 +193,7 @@ public final class ChooseLockSettingsHelper {
                        returnCredentials || hasChallenge
                                ? ConfirmLockPassword.InternalActivity.class
                                : ConfirmLockPassword.class, external,
                                hasChallenge, challenge, effectiveUserId);
                                hasChallenge, challenge, userId);
                break;
        }
        return launched;
+4 −1
Original line number Diff line number Diff line
@@ -70,6 +70,7 @@ public abstract class ConfirmDeviceCredentialBaseFragment extends OptionsMenuFra
    protected Button mCancelButton;
    protected ImageView mFingerprintIcon;
    protected int mEffectiveUserId;
    protected int mUserId;
    protected LockPatternUtils mLockPatternUtils;
    protected TextView mErrorTextView;
    protected final Handler mHandler = new Handler();
@@ -81,7 +82,9 @@ public abstract class ConfirmDeviceCredentialBaseFragment extends OptionsMenuFra
                ALLOW_FP_AUTHENTICATION, false);
        // Only take this argument into account if it belongs to the current profile.
        Intent intent = getActivity().getIntent();
        mEffectiveUserId = Utils.getUserIdFromBundle(getActivity(), intent.getExtras());
        mUserId = Utils.getUserIdFromBundle(getActivity(), intent.getExtras());
        final UserManager userManager = UserManager.get(getActivity());
        mEffectiveUserId = userManager.getCredentialOwnerProfile(mUserId);
        mAllowFpAuthentication = mAllowFpAuthentication && !isFingerprintDisabledByAdmin();
        mLockPatternUtils = new LockPatternUtils(getActivity());
    }
+10 −7
Original line number Diff line number Diff line
@@ -332,11 +332,8 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
            long challenge = getActivity().getIntent().getLongExtra(
                    ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, 0);
            final int localEffectiveUserId = mEffectiveUserId;
            mPendingLockCheck = LockPatternChecker.verifyPassword(
                    mLockPatternUtils,
                    pin,
                    challenge,
                    localEffectiveUserId,
            final int localUserId = mUserId;
            final LockPatternChecker.OnVerifyCallback onVerifyCallback =
                    new LockPatternChecker.OnVerifyCallback() {
                        @Override
                        public void onVerified(byte[] token, int timeoutMs) {
@@ -349,9 +346,15 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
                                        token);
                            }
                            mCredentialCheckResultTracker.setResult(matched, intent, timeoutMs,
                                    localEffectiveUserId);
                        }
                    });
                                    localUserId);
                        }
            };
            mPendingLockCheck = (localEffectiveUserId == localUserId)
                    ? LockPatternChecker.verifyPassword(
                            mLockPatternUtils, pin, challenge, localUserId, onVerifyCallback)
                    : LockPatternChecker.verifyTiedProfileChallenge(
                            mLockPatternUtils, pin, false, challenge, localUserId,
                            onVerifyCallback);
        }

        private void startCheckPassword(final String pin, final Intent intent) {
+23 −19
Original line number Diff line number Diff line
@@ -420,13 +420,10 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity {
            private void startVerifyPattern(final List<LockPatternView.Cell> pattern,
                    final Intent intent) {
                final int localEffectiveUserId = mEffectiveUserId;
                final int localUserId = mUserId;
                long challenge = getActivity().getIntent().getLongExtra(
                        ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, 0);
                mPendingLockCheck = LockPatternChecker.verifyPattern(
                        mLockPatternUtils,
                        pattern,
                        challenge,
                        localEffectiveUserId,
                final LockPatternChecker.OnVerifyCallback onVerifyCallback =
                    new LockPatternChecker.OnVerifyCallback() {
                        @Override
                        public void onVerified(byte[] token, int timeoutMs) {
@@ -441,7 +438,14 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity {
                            mCredentialCheckResultTracker.setResult(matched, intent, timeoutMs,
                                    localEffectiveUserId);
                        }
                        });
                    };
                mPendingLockCheck = (localEffectiveUserId == localUserId)
                        ? LockPatternChecker.verifyPattern(
                                mLockPatternUtils, pattern, challenge, localUserId,
                                onVerifyCallback)
                        : LockPatternChecker.verifyTiedProfileChallenge(
                                mLockPatternUtils, LockPatternUtils.patternToString(pattern),
                                true, challenge, localUserId, onVerifyCallback);
            }

            private void startCheckPattern(final List<LockPatternView.Cell> pattern,
+4 −1
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.graphics.Typeface;
import android.hardware.fingerprint.FingerprintManager;
import android.os.Bundle;
import android.os.UserHandle;
import android.os.UserManager;
import android.text.Annotation;
import android.text.SpannableString;
import android.text.SpannableStringBuilder;
@@ -52,6 +53,7 @@ public class FingerprintEnrollIntroduction extends FingerprintEnrollBase
    protected static final int FINGERPRINT_FIND_SENSOR_REQUEST = 2;
    protected static final int LEARN_MORE_REQUEST = 3;

    private UserManager mUserManager;
    private boolean mHasPassword;

    @Override
@@ -61,6 +63,7 @@ public class FingerprintEnrollIntroduction extends FingerprintEnrollBase
        setHeaderText(R.string.security_settings_fingerprint_enroll_introduction_title);
        final SetupWizardRecyclerLayout layout =
                (SetupWizardRecyclerLayout) findViewById(R.id.setup_wizard_layout);
        mUserManager = UserManager.get(this);
        final RecyclerItemAdapter adapter = (RecyclerItemAdapter) layout.getAdapter();
        adapter.setOnItemSelectedListener(this);
        Item item = (Item) adapter.findItemById(R.id.fingerprint_introduction_message);
@@ -76,7 +79,7 @@ public class FingerprintEnrollIntroduction extends FingerprintEnrollBase

    private void updatePasswordQuality() {
        final int passwordQuality = new ChooseLockSettingsHelper(this).utils()
                .getActivePasswordQuality(mUserId);
                .getActivePasswordQuality(mUserManager.getCredentialOwnerProfile(mUserId));
        mHasPassword = passwordQuality != DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED;
    }