Fix storage settings crash.
It may crash if opened during the uninstall of an app. By catching the exception which may occur, we can just skip the uninstalled app and avoid crashing. Change-Id: If556db7b5a299ba53a29baefbbe9709ba6d12190 Fixes: 36793223 Fixes: 36793372 Test: Settings unit test
This commit is contained in:
@@ -117,7 +117,7 @@ public class StorageDashboardFragment extends DashboardFragment
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
getLoaderManager().initLoader(STORAGE_JOB_ID, Bundle.EMPTY, this);
|
||||
getLoaderManager().restartLoader(STORAGE_JOB_ID, Bundle.EMPTY, this);
|
||||
getLoaderManager().initLoader(ICON_JOB_ID, Bundle.EMPTY, new IconLoaderCallbacks());
|
||||
}
|
||||
|
||||
|
@@ -79,8 +79,14 @@ public class StorageAsyncLoader
|
||||
UserHandle myUser = UserHandle.of(userId);
|
||||
for (int i = 0, size = applicationInfos.size(); i < size; i++) {
|
||||
ApplicationInfo app = applicationInfos.get(i);
|
||||
StorageStatsSource.AppStorageStats stats =
|
||||
mStatsManager.getStatsForPackage(mUuid, app.packageName, myUser);
|
||||
|
||||
StorageStatsSource.AppStorageStats stats;
|
||||
try {
|
||||
stats = mStatsManager.getStatsForPackage(mUuid, app.packageName, myUser);
|
||||
} catch (IllegalStateException e) {
|
||||
// This may happen if the package was removed during our calculation.
|
||||
continue;
|
||||
}
|
||||
|
||||
long attributedAppSizeInBytes = stats.getDataBytes();
|
||||
// This matches how the package manager calculates sizes -- by zeroing out code sizes of
|
||||
|
Reference in New Issue
Block a user