diff options
author | Jeff Sharkey <jsharkey@android.com> | 2012-09-14 13:03:27 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-09-14 13:03:27 -0700 |
commit | 3a932f33223e54d619014afa3e34799bc6256b69 (patch) | |
tree | df1dce2cf349101a8eb9f68e2584c51dd39bc365 | |
parent | 8227e303850d7c1162c62947b70d0592432b455e (diff) | |
parent | ec6e66268829e09df3f2b9d68500e672d35a8008 (diff) | |
download | packages_apps_settings-3a932f33223e54d619014afa3e34799bc6256b69.zip packages_apps_settings-3a932f33223e54d619014afa3e34799bc6256b69.tar.gz packages_apps_settings-3a932f33223e54d619014afa3e34799bc6256b69.tar.bz2 |
Merge "Treat cache storage usage as available space." into jb-mr1-dev
-rw-r--r-- | src/com/android/settings/deviceinfo/StorageMeasurement.java | 43 | ||||
-rw-r--r-- | src/com/android/settings/deviceinfo/StorageVolumePreferenceCategory.java | 6 |
2 files changed, 33 insertions, 16 deletions
diff --git a/src/com/android/settings/deviceinfo/StorageMeasurement.java b/src/com/android/settings/deviceinfo/StorageMeasurement.java index 50238f3..772ac0d 100644 --- a/src/com/android/settings/deviceinfo/StorageMeasurement.java +++ b/src/com/android/settings/deviceinfo/StorageMeasurement.java @@ -96,6 +96,9 @@ public class StorageMeasurement { } public static class MeasurementDetails { + public long totalSize; + public long availSize; + /** * Total apps disk usage. * <p> @@ -111,6 +114,11 @@ public class StorageMeasurement { public long appsSize; /** + * Total cache disk usage by apps. + */ + public long cacheSize; + + /** * Total media disk usage, categorized by types such as * {@link Environment#DIRECTORY_MUSIC}. * <p> @@ -237,34 +245,36 @@ public class StorageMeasurement { } private void addStatsLocked(PackageStats stats) { - final long externalSize = stats.externalCodeSize + stats.externalDataSize - + stats.externalCacheSize + stats.externalMediaSize; - if (mIsInternal) { - final long codeSize; - final long dataSize; + long codeSize = stats.codeSize; + long dataSize = stats.dataSize; + long cacheSize = stats.cacheSize; if (Environment.isExternalStorageEmulated()) { - // OBB is shared on emulated storage, so count once as code, - // and data includes emulated storage. - codeSize = stats.codeSize + stats.externalObbSize; - dataSize = stats.dataSize + externalSize; - } else { - codeSize = stats.codeSize; - dataSize = stats.dataSize; + // Include emulated storage when measuring internal. OBB is + // shared on emulated storage, so treat as code. + codeSize += stats.externalCodeSize + stats.externalObbSize; + dataSize += stats.externalDataSize + stats.externalMediaSize; + cacheSize += stats.externalCacheSize; } - // Include code and combined data for current user + // Count code and data for current user if (stats.userHandle == mCurrentUser) { mDetails.appsSize += codeSize; mDetails.appsSize += dataSize; } - // Include combined data for user summary + // User summary only includes data (code is only counted once + // for the current user) addValue(mDetails.usersSize, stats.userHandle, dataSize); + // Include cache for all users + mDetails.cacheSize += cacheSize; + } else { // Physical storage; only count external sizes - mDetails.appsSize += externalSize + stats.externalObbSize; + mDetails.appsSize += stats.externalCodeSize + stats.externalDataSize + + stats.externalMediaSize + stats.externalObbSize; + mDetails.cacheSize += stats.externalCacheSize; } } } @@ -389,6 +399,9 @@ public class StorageMeasurement { final MeasurementDetails details = new MeasurementDetails(); final Message finished = obtainMessage(MSG_COMPLETED, details); + details.totalSize = mTotalSize; + details.availSize = mAvailSize; + final UserManager userManager = (UserManager) context.getSystemService( Context.USER_SERVICE); final List<UserInfo> users = userManager.getUsers(); diff --git a/src/com/android/settings/deviceinfo/StorageVolumePreferenceCategory.java b/src/com/android/settings/deviceinfo/StorageVolumePreferenceCategory.java index 469dbc7..44d40a0 100644 --- a/src/com/android/settings/deviceinfo/StorageVolumePreferenceCategory.java +++ b/src/com/android/settings/deviceinfo/StorageVolumePreferenceCategory.java @@ -312,6 +312,10 @@ public class StorageVolumePreferenceCategory extends PreferenceCategory { final boolean showDetails = mVolume == null || mVolume.isPrimary(); if (!showDetails) return; + // Count caches as available space, since system manages them + mItemTotal.setSummary(formatSize(details.totalSize)); + mItemAvailable.setSummary(formatSize(details.availSize + details.cacheSize)); + mUsageBarPreference.clear(); updatePreference(mItemApps, details.appsSize); @@ -326,7 +330,7 @@ public class StorageVolumePreferenceCategory extends PreferenceCategory { updatePreference(mItemMusic, musicSize); final long downloadsSize = totalValues(details.mediaSize, Environment.DIRECTORY_DOWNLOADS); - updatePreference(mItemDownloads, musicSize); + updatePreference(mItemDownloads, downloadsSize); updatePreference(mItemMisc, details.miscSize); |