From 40e187b3641ac3084c706b10d2213b91a53da5d1 Mon Sep 17 00:00:00 2001 From: Pavel Grafov Date: Wed, 11 Oct 2017 22:57:09 +0100 Subject: 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 --- .../android/settings/password/ChooseLockGeneric.java | 19 +++++++++++++++++-- .../android/settings/password/ChooseLockPassword.java | 2 +- .../android/settings/password/ChooseLockPattern.java | 2 +- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/com/android/settings/password/ChooseLockGeneric.java b/src/com/android/settings/password/ChooseLockGeneric.java index 5126727bbe..a694603fd9 100644 --- a/src/com/android/settings/password/ChooseLockGeneric.java +++ b/src/com/android/settings/password/ChooseLockGeneric.java @@ -179,6 +179,8 @@ public class ChooseLockGeneric extends SettingsActivity { .getBooleanExtra(CONFIRM_CREDENTIALS, true); if (getActivity() instanceof ChooseLockGeneric.InternalActivity) { mPasswordConfirmed = !confirmCredentials; + mUserPassword = getActivity().getIntent().getStringExtra( + ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD); } mHideDrawer = getActivity().getIntent().getBooleanExtra(EXTRA_HIDE_DRAWER, false); @@ -198,6 +200,10 @@ public class ChooseLockGeneric extends SettingsActivity { mEncryptionRequestQuality = savedInstanceState.getInt(ENCRYPT_REQUESTED_QUALITY); mEncryptionRequestDisabled = savedInstanceState.getBoolean( 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. @@ -268,6 +274,10 @@ public class ChooseLockGeneric extends SettingsActivity { // Forward the target user id to ChooseLockGeneric. chooseLockGenericIntent.putExtra(Intent.EXTRA_USER_ID, mUserId); chooseLockGenericIntent.putExtra(CONFIRM_CREDENTIALS, !mPasswordConfirmed); + if (mUserPassword != null) { + chooseLockGenericIntent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD, + mUserPassword); + } startActivityForResult(chooseLockGenericIntent, SKIP_FINGERPRINT_REQUEST); return true; } else { @@ -393,6 +403,9 @@ public class ChooseLockGeneric extends SettingsActivity { outState.putBoolean(WAITING_FOR_CONFIRMATION, mWaitingForConfirmation); outState.putInt(ENCRYPT_REQUESTED_QUALITY, mEncryptionRequestQuality); outState.putBoolean(ENCRYPT_REQUESTED_DISABLED, mEncryptionRequestDisabled); + if (mUserPassword != null) { + outState.putString(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD, mUserPassword); + } } private void updatePreferencesOrFinish(boolean isRecreatingActivity) { @@ -580,7 +593,8 @@ public class ChooseLockGeneric extends SettingsActivity { .setUserId(mUserId); if (mHasChallenge) { builder.setChallenge(mChallenge); - } else { + } + if (mUserPassword != null) { builder.setPassword(mUserPassword); } return builder.build(); @@ -593,7 +607,8 @@ public class ChooseLockGeneric extends SettingsActivity { .setUserId(mUserId); if (mHasChallenge) { builder.setChallenge(mChallenge); - } else { + } + if (mUserPassword != null) { builder.setPattern(mUserPassword); } return builder.build(); diff --git a/src/com/android/settings/password/ChooseLockPassword.java b/src/com/android/settings/password/ChooseLockPassword.java index d89095691a..9f5192d044 100644 --- a/src/com/android/settings/password/ChooseLockPassword.java +++ b/src/com/android/settings/password/ChooseLockPassword.java @@ -105,6 +105,7 @@ public class ChooseLockPassword extends SettingsActivity { mIntent = new Intent(context, ChooseLockPassword.class); mIntent.putExtra(ChooseLockGeneric.CONFIRM_CREDENTIALS, false); mIntent.putExtra(EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, false); + mIntent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, false); } public IntentBuilder setPasswordQuality(int quality) { @@ -130,7 +131,6 @@ public class ChooseLockPassword extends SettingsActivity { } public IntentBuilder setPassword(String password) { - mIntent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, false); mIntent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD, password); return this; } diff --git a/src/com/android/settings/password/ChooseLockPattern.java b/src/com/android/settings/password/ChooseLockPattern.java index 9d0072961d..7df8974faa 100644 --- a/src/com/android/settings/password/ChooseLockPattern.java +++ b/src/com/android/settings/password/ChooseLockPattern.java @@ -95,6 +95,7 @@ public class ChooseLockPattern extends SettingsActivity { mIntent = new Intent(context, ChooseLockPattern.class); mIntent.putExtra(EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, false); mIntent.putExtra(ChooseLockGeneric.CONFIRM_CREDENTIALS, false); + mIntent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, false); } public IntentBuilder setUserId(int userId) { @@ -109,7 +110,6 @@ public class ChooseLockPattern extends SettingsActivity { } public IntentBuilder setPattern(String pattern) { - mIntent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, false); mIntent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD, pattern); return this; } -- cgit v1.2.3