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) {
|
if (savedInstanceState != null) {
|
||||||
mPasswordConfirmed = savedInstanceState.getBoolean(PASSWORD_CONFIRMED);
|
mPasswordConfirmed = savedInstanceState.getBoolean(PASSWORD_CONFIRMED);
|
||||||
mWaitingForConfirmation = savedInstanceState.getBoolean(WAITING_FOR_CONFIRMATION);
|
mWaitingForConfirmation = savedInstanceState.getBoolean(WAITING_FOR_CONFIRMATION);
|
||||||
if (mUserPassword == null) {
|
mUserPassword = savedInstanceState.getParcelable(
|
||||||
mUserPassword = savedInstanceState.getParcelable(
|
ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
|
||||||
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.
|
||||||
@@ -512,7 +510,8 @@ public class ChooseLockGeneric extends SettingsActivity {
|
|||||||
outState.putBoolean(PASSWORD_CONFIRMED, mPasswordConfirmed);
|
outState.putBoolean(PASSWORD_CONFIRMED, mPasswordConfirmed);
|
||||||
outState.putBoolean(WAITING_FOR_CONFIRMATION, mWaitingForConfirmation);
|
outState.putBoolean(WAITING_FOR_CONFIRMATION, mWaitingForConfirmation);
|
||||||
if (mUserPassword != null) {
|
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);
|
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.
|
// Re-attach to the exiting worker if there is one.
|
||||||
mSaveAndFinishWorker = (SaveAndFinishWorker) getFragmentManager().findFragmentByTag(
|
mSaveAndFinishWorker = (SaveAndFinishWorker) getFragmentManager().findFragmentByTag(
|
||||||
@@ -646,7 +644,9 @@ public class ChooseLockPassword extends SettingsActivity {
|
|||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
outState.putString(KEY_UI_STAGE, mUiStage.name());
|
outState.putString(KEY_UI_STAGE, mUiStage.name());
|
||||||
outState.putParcelable(KEY_FIRST_PASSWORD, mFirstPassword);
|
outState.putParcelable(KEY_FIRST_PASSWORD, mFirstPassword);
|
||||||
outState.putParcelable(KEY_CURRENT_CREDENTIAL, mCurrentCredential);
|
if (mCurrentCredential != null) {
|
||||||
|
outState.putParcelable(KEY_CURRENT_CREDENTIAL, mCurrentCredential.duplicate());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -611,10 +611,8 @@ public class ChooseLockPattern extends SettingsActivity {
|
|||||||
} else {
|
} else {
|
||||||
// restore from previous state
|
// restore from previous state
|
||||||
mChosenPattern = savedInstanceState.getParcelable(KEY_PATTERN_CHOICE);
|
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)]);
|
updateStage(Stage.values()[savedInstanceState.getInt(KEY_UI_STAGE)]);
|
||||||
|
|
||||||
// Re-attach to the exiting worker if there is one.
|
// Re-attach to the exiting worker if there is one.
|
||||||
@@ -729,7 +727,7 @@ public class ChooseLockPattern extends SettingsActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mCurrentCredential != null) {
|
if (mCurrentCredential != null) {
|
||||||
outState.putParcelable(KEY_CURRENT_PATTERN, mCurrentCredential);
|
outState.putParcelable(KEY_CURRENT_PATTERN, mCurrentCredential.duplicate());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user