Update storage usage to be consistent in settings

Storage usage is calculated differently accross multiple settings pages.
Update the logic to be consistent throughout.

Bug: 70475659
Test: Manual
Change-Id: Id01f39ead76fac505daa20998b0b326b1947a6a4
This commit is contained in:
Akshay Joshi
2018-01-16 14:23:19 -08:00
parent c261912301
commit 787bca627f
2 changed files with 31 additions and 11 deletions

View File

@@ -160,8 +160,11 @@ public class StorageSettings extends SettingsPreferenceFragment implements Index
mInternalCategory.addPreference(mInternalSummary);
int privateCount = 0;
long privateUsedBytes = 0;
long privateTotalBytes = 0;
final StorageManagerVolumeProvider smvp = new StorageManagerVolumeProvider(mStorageManager);
final PrivateStorageInfo info = PrivateStorageInfo.getPrivateStorageInfo(smvp);
final long privateTotalBytes = info.totalBytes;
final long privateUsedBytes = info.totalBytes - info.freeBytes;
final List<VolumeInfo> volumes = mStorageManager.getVolumes();
Collections.sort(volumes, VolumeInfo.getDescriptionComparator());
@@ -173,11 +176,6 @@ public class StorageSettings extends SettingsPreferenceFragment implements Index
final int color = COLOR_PRIVATE[privateCount++ % COLOR_PRIVATE.length];
mInternalCategory.addPreference(
new StorageVolumePreference(context, vol, color, volumeTotalBytes));
if (vol.isMountedReadable()) {
final File path = vol.getPath();
privateUsedBytes += (volumeTotalBytes - path.getFreeSpace());
privateTotalBytes += volumeTotalBytes;
}
} else if (vol.getType() == VolumeInfo.TYPE_PUBLIC) {
mExternalCategory.addPreference(
new StorageVolumePreference(context, vol, COLOR_PUBLIC, 0));