Fix NPE at Storage Settings configuration change
At configuration change, both StorageCategoryFragment and ProfileSelectStorageFragment are re-created and there is a different callback sequence than normal case. This change save/restore mSelectedStorageEntry in instance state bundle to fix the NPE. Bug: 189108700 Test: manual Install work profile and rotate Storage Settings. Change-Id: I39d7ef7ced22188ee66216d57518198d63671e0e
This commit is contained in:
@@ -73,6 +73,7 @@ public class StorageCategoryFragment extends DashboardFragment
|
||||
LoaderManager.LoaderCallbacks<SparseArray<StorageAsyncLoader.StorageResult>>,
|
||||
Preference.OnPreferenceClickListener {
|
||||
private static final String TAG = "StorageCategoryFrag";
|
||||
private static final String SELECTED_STORAGE_ENTRY_KEY = "selected_storage_entry_key";
|
||||
private static final String SUMMARY_PREF_KEY = "storage_summary";
|
||||
private static final String FREE_UP_SPACE_PREF_KEY = "free_up_space";
|
||||
private static final int STORAGE_JOB_ID = 0;
|
||||
@@ -127,6 +128,10 @@ public class StorageCategoryFragment extends DashboardFragment
|
||||
|
||||
mStorageManager = getActivity().getSystemService(StorageManager.class);
|
||||
|
||||
if (icicle != null) {
|
||||
mSelectedStorageEntry = icicle.getParcelable(SELECTED_STORAGE_ENTRY_KEY);
|
||||
}
|
||||
|
||||
initializePreference();
|
||||
}
|
||||
|
||||
@@ -167,6 +172,12 @@ public class StorageCategoryFragment extends DashboardFragment
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
outState.putParcelable(SELECTED_STORAGE_ENTRY_KEY, mSelectedStorageEntry);
|
||||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
private void onReceivedSizes() {
|
||||
boolean stopLoading = false;
|
||||
if (mStorageInfo != null) {
|
||||
|
Reference in New Issue
Block a user