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:
Rubin Xu
2021-04-06 14:18:13 +01:00
parent 495c51e3ac
commit da09a8547d
3 changed files with 10 additions and 13 deletions

View File

@@ -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