From 325d38043f856be7f3e06406e020a9de2d2d93ab Mon Sep 17 00:00:00 2001 From: Daniel Nishi Date: Fri, 10 Mar 2017 15:15:42 -0800 Subject: [PATCH] Category breakdown size should match total size. The system apps' base size was not being properly attributed to the system. This was causing the storage to go totally unattributed (and causing roughly a 1GB gap in sizes.) On my test device, the sizes now sum properly. Change-Id: Ibc13015e40f854090a7a3ec09eef4c5c52918e0f Fixes: 35144717 Test: Settings robo --- .../settings/deviceinfo/storage/StorageAsyncLoader.java | 3 +++ .../deviceinfo/storage/StorageItemPreferenceController.java | 2 +- .../storage/StorageItemPreferenceControllerTest.java | 3 ++- .../settings/deviceinfo/storage/StorageAsyncLoaderTest.java | 3 ++- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/com/android/settings/deviceinfo/storage/StorageAsyncLoader.java b/src/com/android/settings/deviceinfo/storage/StorageAsyncLoader.java index f54c685730d..9867b9d5866 100644 --- a/src/com/android/settings/deviceinfo/storage/StorageAsyncLoader.java +++ b/src/com/android/settings/deviceinfo/storage/StorageAsyncLoader.java @@ -89,6 +89,8 @@ public class StorageAsyncLoader // code size. if (!app.isSystemApp() || app.isUpdatedSystemApp()) { attributedAppSizeInBytes += stats.getCodeBytes(); + } else { + result.systemSize += stats.getCodeBytes(); } switch (app.category) { case CATEGORY_GAME: @@ -117,6 +119,7 @@ public class StorageAsyncLoader public long gamesSize; public long musicAppsSize; public long otherAppsSize; + public long systemSize; public StorageStatsSource.ExternalStorageStats externalStats; } diff --git a/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java b/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java index 2fa1b183bb2..36cf73e4a81 100644 --- a/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java +++ b/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java @@ -181,7 +181,7 @@ public class StorageItemPreferenceController extends PreferenceController { mGamePreference.setStorageSize(data.gamesSize); mAppPreference.setStorageSize(data.otherAppsSize); if (mSystemPreference != null) { - mSystemPreference.setStorageSize(mSystemSize); + mSystemPreference.setStorageSize(mSystemSize + data.systemSize); } long unattributedBytes = data.externalStats.totalBytes - data.externalStats.audioBytes diff --git a/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java index 4622850d6b5..961a6c757d3 100644 --- a/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java @@ -216,6 +216,7 @@ public class StorageItemPreferenceControllerTest { result.gamesSize = KILOBYTE * 8; result.musicAppsSize = KILOBYTE * 4; result.otherAppsSize = KILOBYTE * 9; + result.systemSize = KILOBYTE * 10; result.externalStats = new StorageStatsSource.ExternalStorageStats( KILOBYTE * 50, // total KILOBYTE * 10, // audio @@ -230,7 +231,7 @@ public class StorageItemPreferenceControllerTest { assertThat(image.getSummary().toString()).isEqualTo("35.00KB"); // 15KB video + 20KB images assertThat(games.getSummary().toString()).isEqualTo("8.00KB"); assertThat(apps.getSummary().toString()).isEqualTo("9.00KB"); - assertThat(system.getSummary().toString()).isEqualTo("6.00KB"); + assertThat(system.getSummary().toString()).isEqualTo("16.00KB"); assertThat(files.getSummary().toString()).isEqualTo("5.00KB"); } } \ No newline at end of file diff --git a/tests/unit/src/com/android/settings/deviceinfo/storage/StorageAsyncLoaderTest.java b/tests/unit/src/com/android/settings/deviceinfo/storage/StorageAsyncLoaderTest.java index 10ba293d457..a9ededad119 100644 --- a/tests/unit/src/com/android/settings/deviceinfo/storage/StorageAsyncLoaderTest.java +++ b/tests/unit/src/com/android/settings/deviceinfo/storage/StorageAsyncLoaderTest.java @@ -132,7 +132,7 @@ public class StorageAsyncLoaderTest { } @Test - public void testSystemAppsBaseSizeIsIgnored() throws Exception { + public void testSystemAppsBaseSizeIsAddedToSystem() throws Exception { ApplicationInfo systemApp = addPackage(PACKAGE_NAME_1, 100, 1, 10, ApplicationInfo.CATEGORY_UNDEFINED); systemApp.flags = ApplicationInfo.FLAG_SYSTEM; @@ -141,6 +141,7 @@ public class StorageAsyncLoaderTest { assertThat(result.size()).isEqualTo(1); assertThat(result.get(PRIMARY_USER_ID).otherAppsSize).isEqualTo(10L); + assertThat(result.get(PRIMARY_USER_ID).systemSize).isEqualTo(1L); } @Test