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
This commit is contained in:
Ricky Wai
2016-04-05 16:33:47 +01:00
parent 4bbf0653c0
commit 996d0dfa6e
5 changed files with 46 additions and 31 deletions

View File

@@ -22,6 +22,7 @@ import android.app.Fragment;
import android.app.admin.DevicePolicyManager; import android.app.admin.DevicePolicyManager;
import android.content.Intent; import android.content.Intent;
import android.content.IntentSender; import android.content.IntentSender;
import android.os.UserManager;
import com.android.internal.widget.LockPatternUtils; import com.android.internal.widget.LockPatternUtils;
@@ -171,7 +172,8 @@ public final class ChooseLockSettingsHelper {
private boolean launchConfirmationActivity(int request, @Nullable CharSequence title, private boolean launchConfirmationActivity(int request, @Nullable CharSequence title,
@Nullable CharSequence header, @Nullable CharSequence description, @Nullable CharSequence header, @Nullable CharSequence description,
boolean returnCredentials, boolean external, boolean hasChallenge, 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; boolean launched = false;
switch (mLockPatternUtils.getKeyguardStoredPasswordQuality(effectiveUserId)) { switch (mLockPatternUtils.getKeyguardStoredPasswordQuality(effectiveUserId)) {
@@ -180,7 +182,7 @@ public final class ChooseLockSettingsHelper {
returnCredentials || hasChallenge returnCredentials || hasChallenge
? ConfirmLockPattern.InternalActivity.class ? ConfirmLockPattern.InternalActivity.class
: ConfirmLockPattern.class, external, : ConfirmLockPattern.class, external,
hasChallenge, challenge, effectiveUserId); hasChallenge, challenge, userId);
break; break;
case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC: case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC:
case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC_COMPLEX: case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC_COMPLEX:
@@ -191,7 +193,7 @@ public final class ChooseLockSettingsHelper {
returnCredentials || hasChallenge returnCredentials || hasChallenge
? ConfirmLockPassword.InternalActivity.class ? ConfirmLockPassword.InternalActivity.class
: ConfirmLockPassword.class, external, : ConfirmLockPassword.class, external,
hasChallenge, challenge, effectiveUserId); hasChallenge, challenge, userId);
break; break;
} }
return launched; return launched;

View File

@@ -70,6 +70,7 @@ public abstract class ConfirmDeviceCredentialBaseFragment extends OptionsMenuFra
protected Button mCancelButton; protected Button mCancelButton;
protected ImageView mFingerprintIcon; protected ImageView mFingerprintIcon;
protected int mEffectiveUserId; protected int mEffectiveUserId;
protected int mUserId;
protected LockPatternUtils mLockPatternUtils; protected LockPatternUtils mLockPatternUtils;
protected TextView mErrorTextView; protected TextView mErrorTextView;
protected final Handler mHandler = new Handler(); protected final Handler mHandler = new Handler();
@@ -81,7 +82,9 @@ public abstract class ConfirmDeviceCredentialBaseFragment extends OptionsMenuFra
ALLOW_FP_AUTHENTICATION, false); ALLOW_FP_AUTHENTICATION, false);
// Only take this argument into account if it belongs to the current profile. // Only take this argument into account if it belongs to the current profile.
Intent intent = getActivity().getIntent(); 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(); mAllowFpAuthentication = mAllowFpAuthentication && !isFingerprintDisabledByAdmin();
mLockPatternUtils = new LockPatternUtils(getActivity()); mLockPatternUtils = new LockPatternUtils(getActivity());
} }

View File

@@ -332,11 +332,8 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
long challenge = getActivity().getIntent().getLongExtra( long challenge = getActivity().getIntent().getLongExtra(
ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, 0); ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, 0);
final int localEffectiveUserId = mEffectiveUserId; final int localEffectiveUserId = mEffectiveUserId;
mPendingLockCheck = LockPatternChecker.verifyPassword( final int localUserId = mUserId;
mLockPatternUtils, final LockPatternChecker.OnVerifyCallback onVerifyCallback =
pin,
challenge,
localEffectiveUserId,
new LockPatternChecker.OnVerifyCallback() { new LockPatternChecker.OnVerifyCallback() {
@Override @Override
public void onVerified(byte[] token, int timeoutMs) { public void onVerified(byte[] token, int timeoutMs) {
@@ -349,9 +346,15 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
token); token);
} }
mCredentialCheckResultTracker.setResult(matched, intent, timeoutMs, 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) { private void startCheckPassword(final String pin, final Intent intent) {

View File

@@ -420,28 +420,32 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity {
private void startVerifyPattern(final List<LockPatternView.Cell> pattern, private void startVerifyPattern(final List<LockPatternView.Cell> pattern,
final Intent intent) { final Intent intent) {
final int localEffectiveUserId = mEffectiveUserId; final int localEffectiveUserId = mEffectiveUserId;
final int localUserId = mUserId;
long challenge = getActivity().getIntent().getLongExtra( long challenge = getActivity().getIntent().getLongExtra(
ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, 0); ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, 0);
mPendingLockCheck = LockPatternChecker.verifyPattern( final LockPatternChecker.OnVerifyCallback onVerifyCallback =
mLockPatternUtils, new LockPatternChecker.OnVerifyCallback() {
pattern, @Override
challenge, public void onVerified(byte[] token, int timeoutMs) {
localEffectiveUserId, mPendingLockCheck = null;
new LockPatternChecker.OnVerifyCallback() { boolean matched = false;
@Override if (token != null) {
public void onVerified(byte[] token, int timeoutMs) { matched = true;
mPendingLockCheck = null; intent.putExtra(
boolean matched = false; ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN,
if (token != null) { token);
matched = true;
intent.putExtra(
ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN,
token);
}
mCredentialCheckResultTracker.setResult(matched, intent, timeoutMs,
localEffectiveUserId);
} }
}); 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, private void startCheckPattern(final List<LockPatternView.Cell> pattern,

View File

@@ -24,6 +24,7 @@ import android.graphics.Typeface;
import android.hardware.fingerprint.FingerprintManager; import android.hardware.fingerprint.FingerprintManager;
import android.os.Bundle; import android.os.Bundle;
import android.os.UserHandle; import android.os.UserHandle;
import android.os.UserManager;
import android.text.Annotation; import android.text.Annotation;
import android.text.SpannableString; import android.text.SpannableString;
import android.text.SpannableStringBuilder; 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 FINGERPRINT_FIND_SENSOR_REQUEST = 2;
protected static final int LEARN_MORE_REQUEST = 3; protected static final int LEARN_MORE_REQUEST = 3;
private UserManager mUserManager;
private boolean mHasPassword; private boolean mHasPassword;
@Override @Override
@@ -61,6 +63,7 @@ public class FingerprintEnrollIntroduction extends FingerprintEnrollBase
setHeaderText(R.string.security_settings_fingerprint_enroll_introduction_title); setHeaderText(R.string.security_settings_fingerprint_enroll_introduction_title);
final SetupWizardRecyclerLayout layout = final SetupWizardRecyclerLayout layout =
(SetupWizardRecyclerLayout) findViewById(R.id.setup_wizard_layout); (SetupWizardRecyclerLayout) findViewById(R.id.setup_wizard_layout);
mUserManager = UserManager.get(this);
final RecyclerItemAdapter adapter = (RecyclerItemAdapter) layout.getAdapter(); final RecyclerItemAdapter adapter = (RecyclerItemAdapter) layout.getAdapter();
adapter.setOnItemSelectedListener(this); adapter.setOnItemSelectedListener(this);
Item item = (Item) adapter.findItemById(R.id.fingerprint_introduction_message); Item item = (Item) adapter.findItemById(R.id.fingerprint_introduction_message);
@@ -76,7 +79,7 @@ public class FingerprintEnrollIntroduction extends FingerprintEnrollBase
private void updatePasswordQuality() { private void updatePasswordQuality() {
final int passwordQuality = new ChooseLockSettingsHelper(this).utils() final int passwordQuality = new ChooseLockSettingsHelper(this).utils()
.getActivePasswordQuality(mUserId); .getActivePasswordQuality(mUserManager.getCredentialOwnerProfile(mUserId));
mHasPassword = passwordQuality != DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED; mHasPassword = passwordQuality != DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED;
} }