Preserve old password when handling SET_NEW_PASSWORD.

Currently the only way mUserPassword can be set is when it comes
from onActivityResult. This way when the user chooses "Continue
without Pixel Imprint", and we switch ChooseLockGeneric->InternalActivity,
mUserPassword becomes null (it is not preserved in intent extras).
And then this null is used in getLockPasswordIntent which causes the issue.

Another issues is that when the user chooses to use fingerprint,
mHasChallenge is set to true and password is not forwarded to
ChooseLock(Password|Pattern). I changed the intent builders so that both
old password and challenge can be sent at the same time, so the password
is not lost when fingerprint is set.

Bug: 67672081
Test: cd packages/apps/Settings/tests/robotests/ && mma
Test: manual, adb shell am start -a android.app.action.SET_NEW_PASSWORD,
      tried setting pin/password with and without fingerprint.
Test: manual, tried to change lock via Settings -> Security&Location
Test: manual, set pin + fingerprint in Setup Wizard, FBE and FDE devices
Test: manual, set pin + added account, used pin to unlock FRP in SUW
Change-Id: I38d56d84f95c63fef24c2aa1a031d629f22756a1
This commit is contained in:
Pavel Grafov
2017-10-11 22:57:09 +01:00
parent 893bdba206
commit 40e187b364
3 changed files with 19 additions and 4 deletions

View File

@@ -179,6 +179,8 @@ public class ChooseLockGeneric extends SettingsActivity {
.getBooleanExtra(CONFIRM_CREDENTIALS, true); .getBooleanExtra(CONFIRM_CREDENTIALS, true);
if (getActivity() instanceof ChooseLockGeneric.InternalActivity) { if (getActivity() instanceof ChooseLockGeneric.InternalActivity) {
mPasswordConfirmed = !confirmCredentials; mPasswordConfirmed = !confirmCredentials;
mUserPassword = getActivity().getIntent().getStringExtra(
ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
} }
mHideDrawer = getActivity().getIntent().getBooleanExtra(EXTRA_HIDE_DRAWER, false); mHideDrawer = getActivity().getIntent().getBooleanExtra(EXTRA_HIDE_DRAWER, false);
@@ -198,6 +200,10 @@ public class ChooseLockGeneric extends SettingsActivity {
mEncryptionRequestQuality = savedInstanceState.getInt(ENCRYPT_REQUESTED_QUALITY); mEncryptionRequestQuality = savedInstanceState.getInt(ENCRYPT_REQUESTED_QUALITY);
mEncryptionRequestDisabled = savedInstanceState.getBoolean( mEncryptionRequestDisabled = savedInstanceState.getBoolean(
ENCRYPT_REQUESTED_DISABLED); ENCRYPT_REQUESTED_DISABLED);
if (mUserPassword == null) {
mUserPassword = savedInstanceState.getString(
ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
}
} }
// a) If this is started from other user, use that user id. // a) If this is started from other user, use that user id.
@@ -268,6 +274,10 @@ public class ChooseLockGeneric extends SettingsActivity {
// Forward the target user id to ChooseLockGeneric. // Forward the target user id to ChooseLockGeneric.
chooseLockGenericIntent.putExtra(Intent.EXTRA_USER_ID, mUserId); chooseLockGenericIntent.putExtra(Intent.EXTRA_USER_ID, mUserId);
chooseLockGenericIntent.putExtra(CONFIRM_CREDENTIALS, !mPasswordConfirmed); chooseLockGenericIntent.putExtra(CONFIRM_CREDENTIALS, !mPasswordConfirmed);
if (mUserPassword != null) {
chooseLockGenericIntent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD,
mUserPassword);
}
startActivityForResult(chooseLockGenericIntent, SKIP_FINGERPRINT_REQUEST); startActivityForResult(chooseLockGenericIntent, SKIP_FINGERPRINT_REQUEST);
return true; return true;
} else { } else {
@@ -393,6 +403,9 @@ public class ChooseLockGeneric extends SettingsActivity {
outState.putBoolean(WAITING_FOR_CONFIRMATION, mWaitingForConfirmation); outState.putBoolean(WAITING_FOR_CONFIRMATION, mWaitingForConfirmation);
outState.putInt(ENCRYPT_REQUESTED_QUALITY, mEncryptionRequestQuality); outState.putInt(ENCRYPT_REQUESTED_QUALITY, mEncryptionRequestQuality);
outState.putBoolean(ENCRYPT_REQUESTED_DISABLED, mEncryptionRequestDisabled); outState.putBoolean(ENCRYPT_REQUESTED_DISABLED, mEncryptionRequestDisabled);
if (mUserPassword != null) {
outState.putString(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD, mUserPassword);
}
} }
private void updatePreferencesOrFinish(boolean isRecreatingActivity) { private void updatePreferencesOrFinish(boolean isRecreatingActivity) {
@@ -580,7 +593,8 @@ public class ChooseLockGeneric extends SettingsActivity {
.setUserId(mUserId); .setUserId(mUserId);
if (mHasChallenge) { if (mHasChallenge) {
builder.setChallenge(mChallenge); builder.setChallenge(mChallenge);
} else { }
if (mUserPassword != null) {
builder.setPassword(mUserPassword); builder.setPassword(mUserPassword);
} }
return builder.build(); return builder.build();
@@ -593,7 +607,8 @@ public class ChooseLockGeneric extends SettingsActivity {
.setUserId(mUserId); .setUserId(mUserId);
if (mHasChallenge) { if (mHasChallenge) {
builder.setChallenge(mChallenge); builder.setChallenge(mChallenge);
} else { }
if (mUserPassword != null) {
builder.setPattern(mUserPassword); builder.setPattern(mUserPassword);
} }
return builder.build(); return builder.build();

View File

@@ -105,6 +105,7 @@ public class ChooseLockPassword extends SettingsActivity {
mIntent = new Intent(context, ChooseLockPassword.class); mIntent = new Intent(context, ChooseLockPassword.class);
mIntent.putExtra(ChooseLockGeneric.CONFIRM_CREDENTIALS, false); mIntent.putExtra(ChooseLockGeneric.CONFIRM_CREDENTIALS, false);
mIntent.putExtra(EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, false); mIntent.putExtra(EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, false);
mIntent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, false);
} }
public IntentBuilder setPasswordQuality(int quality) { public IntentBuilder setPasswordQuality(int quality) {
@@ -130,7 +131,6 @@ public class ChooseLockPassword extends SettingsActivity {
} }
public IntentBuilder setPassword(String password) { public IntentBuilder setPassword(String password) {
mIntent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, false);
mIntent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD, password); mIntent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD, password);
return this; return this;
} }

View File

@@ -95,6 +95,7 @@ public class ChooseLockPattern extends SettingsActivity {
mIntent = new Intent(context, ChooseLockPattern.class); mIntent = new Intent(context, ChooseLockPattern.class);
mIntent.putExtra(EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, false); mIntent.putExtra(EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, false);
mIntent.putExtra(ChooseLockGeneric.CONFIRM_CREDENTIALS, false); mIntent.putExtra(ChooseLockGeneric.CONFIRM_CREDENTIALS, false);
mIntent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, false);
} }
public IntentBuilder setUserId(int userId) { public IntentBuilder setUserId(int userId) {
@@ -109,7 +110,6 @@ public class ChooseLockPattern extends SettingsActivity {
} }
public IntentBuilder setPattern(String pattern) { public IntentBuilder setPattern(String pattern) {
mIntent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, false);
mIntent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD, pattern); mIntent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD, pattern);
return this; return this;
} }