Merge "Fix storage settings crash."

This commit is contained in:
Daniel Nishi
2017-04-11 18:13:07 +00:00
committed by Android (Google) Code Review
3 changed files with 23 additions and 3 deletions

View File

@@ -180,6 +180,20 @@ public class StorageAsyncLoaderTest {
assertThat(result.get(PRIMARY_USER_ID).otherAppsSize).isEqualTo(0);
}
@Test
public void testRemovedPackageDoesNotCrash() throws Exception {
ApplicationInfo info = new ApplicationInfo();
info.packageName = PACKAGE_NAME_1;
info.category = ApplicationInfo.CATEGORY_UNDEFINED;
mInfo.add(info);
when(mSource.getStatsForPackage(anyString(), anyString(), any(UserHandle.class)))
.thenThrow(new IllegalStateException());
SparseArray<StorageAsyncLoader.AppsStorageResult> result = mLoader.loadInBackground();
// Should not crash.
}
private ApplicationInfo addPackage(
String packageName, long cacheSize, long codeSize, long dataSize, int category) {
StorageStatsSource.AppStorageStats storageStats =