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

@@ -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());
}
}