summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Daniel Nishi <dhnishi@google.com> 2019-05-08 18:28:00 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2019-05-08 18:28:00 +0000
commit10f78591a7d589fe2fbf171bed7212e219c8303b (patch)
tree746549e3cb33a2d998a8ed8620867c90cf3b4f09
parentb6e2ab9db94359308c03204269c195e5c891ce24 (diff)
parent02917dd5f716a9e95fb60a23580c12b0b75de573 (diff)
Merge "Remove the cache size from internal size." into qt-dev
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/applications/ApplicationsState.java6
-rw-r--r--packages/SettingsLib/tests/robotests/src/com/android/settingslib/applications/ApplicationsStateRoboTest.java3
2 files changed, 6 insertions, 3 deletions
diff --git a/packages/SettingsLib/src/com/android/settingslib/applications/ApplicationsState.java b/packages/SettingsLib/src/com/android/settingslib/applications/ApplicationsState.java
index e02709e10e83..5eaa163db639 100644
--- a/packages/SettingsLib/src/com/android/settingslib/applications/ApplicationsState.java
+++ b/packages/SettingsLib/src/com/android/settingslib/applications/ApplicationsState.java
@@ -707,7 +707,9 @@ public class ApplicationsState {
private long getTotalInternalSize(PackageStats ps) {
if (ps != null) {
- return ps.codeSize + ps.dataSize;
+ // We subtract the cache size because the system can clear it automatically and
+ // |dataSize| is a superset of |cacheSize|.
+ return ps.codeSize + ps.dataSize - ps.cacheSize;
}
return SIZE_INVALID;
}
@@ -715,7 +717,7 @@ public class ApplicationsState {
private long getTotalExternalSize(PackageStats ps) {
if (ps != null) {
// We also include the cache size here because for non-emulated
- // we don't automtically clean cache files.
+ // we don't automatically clean cache files.
return ps.externalCodeSize + ps.externalDataSize
+ ps.externalCacheSize
+ ps.externalMediaSize + ps.externalObbSize;
diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/applications/ApplicationsStateRoboTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/applications/ApplicationsStateRoboTest.java
index b27efd0edc8b..f8697a19c7ab 100644
--- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/applications/ApplicationsStateRoboTest.java
+++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/applications/ApplicationsStateRoboTest.java
@@ -191,8 +191,9 @@ public class ApplicationsStateRoboTest {
shadowContext.setSystemService(Context.STORAGE_STATS_SERVICE, mStorageStatsManager);
StorageStats storageStats = new StorageStats();
storageStats.codeBytes = 10;
- storageStats.dataBytes = 20;
storageStats.cacheBytes = 30;
+ // Data bytes are a superset of cache bytes.
+ storageStats.dataBytes = storageStats.cacheBytes + 20;
when(mStorageStatsManager.queryStatsForPackage(any(UUID.class),
anyString(), any(UserHandle.class))).thenReturn(storageStats);