Correctly save credential on config changes
Need to make a copy of the LockscreenCredential in onSaveInstanceState() since the credential will be zeroized in onDestroy() while Bundle.putParcelable() only keeps a reference of the object without any copying. Bug: 179108398 Test: manual Change-Id: I090b691630f82406d1ae2f625dd2e0d578b83707
This commit is contained in:
@@ -248,10 +248,8 @@ public class ChooseLockGeneric extends SettingsActivity {
|
||||
if (savedInstanceState != null) {
|
||||
mPasswordConfirmed = savedInstanceState.getBoolean(PASSWORD_CONFIRMED);
|
||||
mWaitingForConfirmation = savedInstanceState.getBoolean(WAITING_FOR_CONFIRMATION);
|
||||
if (mUserPassword == null) {
|
||||
mUserPassword = savedInstanceState.getParcelable(
|
||||
ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
|
||||
}
|
||||
mUserPassword = savedInstanceState.getParcelable(
|
||||
ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
|
||||
}
|
||||
|
||||
// a) If this is started from other user, use that user id.
|
||||
@@ -512,7 +510,8 @@ public class ChooseLockGeneric extends SettingsActivity {
|
||||
outState.putBoolean(PASSWORD_CONFIRMED, mPasswordConfirmed);
|
||||
outState.putBoolean(WAITING_FOR_CONFIRMATION, mWaitingForConfirmation);
|
||||
if (mUserPassword != null) {
|
||||
outState.putParcelable(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD, mUserPassword);
|
||||
outState.putParcelable(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD,
|
||||
mUserPassword.duplicate());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -567,9 +567,7 @@ public class ChooseLockPassword extends SettingsActivity {
|
||||
updateStage(mUiStage);
|
||||
}
|
||||
|
||||
if (mCurrentCredential == null) {
|
||||
mCurrentCredential = savedInstanceState.getParcelable(KEY_CURRENT_CREDENTIAL);
|
||||
}
|
||||
mCurrentCredential = savedInstanceState.getParcelable(KEY_CURRENT_CREDENTIAL);
|
||||
|
||||
// Re-attach to the exiting worker if there is one.
|
||||
mSaveAndFinishWorker = (SaveAndFinishWorker) getFragmentManager().findFragmentByTag(
|
||||
@@ -646,7 +644,9 @@ public class ChooseLockPassword extends SettingsActivity {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putString(KEY_UI_STAGE, mUiStage.name());
|
||||
outState.putParcelable(KEY_FIRST_PASSWORD, mFirstPassword);
|
||||
outState.putParcelable(KEY_CURRENT_CREDENTIAL, mCurrentCredential);
|
||||
if (mCurrentCredential != null) {
|
||||
outState.putParcelable(KEY_CURRENT_CREDENTIAL, mCurrentCredential.duplicate());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -611,10 +611,8 @@ public class ChooseLockPattern extends SettingsActivity {
|
||||
} else {
|
||||
// restore from previous state
|
||||
mChosenPattern = savedInstanceState.getParcelable(KEY_PATTERN_CHOICE);
|
||||
mCurrentCredential = savedInstanceState.getParcelable(KEY_CURRENT_PATTERN);
|
||||
|
||||
if (mCurrentCredential == null) {
|
||||
mCurrentCredential = savedInstanceState.getParcelable(KEY_CURRENT_PATTERN);
|
||||
}
|
||||
updateStage(Stage.values()[savedInstanceState.getInt(KEY_UI_STAGE)]);
|
||||
|
||||
// Re-attach to the exiting worker if there is one.
|
||||
@@ -729,7 +727,7 @@ public class ChooseLockPattern extends SettingsActivity {
|
||||
}
|
||||
|
||||
if (mCurrentCredential != null) {
|
||||
outState.putParcelable(KEY_CURRENT_PATTERN, mCurrentCredential);
|
||||
outState.putParcelable(KEY_CURRENT_PATTERN, mCurrentCredential.duplicate());
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user