Correct used size of Storage Settings.

Since StorageManager rounded the totalBytes of device storage but
they don't do that rounding for freeBytes.
So in some cases the freeBytes can be greater than totalBytes.

We propose to get totalBytes of device storage directly to calculate
correct privateUsedBytes.

Test: robotest
Bug: 281955532
Change-Id: I4f137c20e7c2f54f4e037d50e81b3176edc1a83a
(cherry picked from commit e52320e755)
This commit is contained in:
Edgar Wang
2023-05-31 18:42:11 +08:00
parent d42cc8e5e2
commit 3335c72da9
5 changed files with 28 additions and 6 deletions

View File

@@ -387,7 +387,9 @@ public class StorageDashboardFragment extends DashboardFragment
setLoading(false /* loading */, false /* animate */);
final long privateUsedBytes = mStorageInfo.totalBytes - mStorageInfo.freeBytes;
// TODO(b/288103116): replace with new API to get TotalBytes before rounding
// once support by StorageManager.
final long privateUsedBytes = Utils.getPrimaryStorageSize() - mStorageInfo.freeBytes;
mPreferenceController.setVolume(mSelectedStorageEntry.getVolumeInfo());
mPreferenceController.setUsedSize(privateUsedBytes);
mPreferenceController.setTotalSize(mStorageInfo.totalBytes);