Display total storage for Internal shared storage.

Prior to this change, Settings was using
volume.getPath().getTotalBytes() to calculate the total, which includes
the user-accessible storage, but not the internal partitions. As such,
the total displayed was often missing many GBs (for example, in a 32GB
device, it could display "12.09GB of 25.01GB used".

This change fix this problem by using the total size and creating a
"System" section containing the "missing" storage.

BUG: 24128505

Change-Id: Ic35cd7c8406eff16ac1d97c4b4c233ecde64a6e1
This commit is contained in:
Felipe Leme
2016-05-11 13:58:41 -07:00
parent 41dffe632f
commit 9c7bb2775a
4 changed files with 81 additions and 15 deletions

View File

@@ -46,7 +46,8 @@ public class StorageVolumePreference extends Preference {
private int mColor;
private int mUsedPercent = -1;
public StorageVolumePreference(Context context, VolumeInfo volume, int color) {
// TODO: ideally, VolumeInfo should have a total physical size.
public StorageVolumePreference(Context context, VolumeInfo volume, int color, long totalBytes) {
super(context);
mStorageManager = context.getSystemService(StorageManager.class);
@@ -68,8 +69,10 @@ public class StorageVolumePreference extends Preference {
if (volume.isMountedReadable()) {
// TODO: move statfs() to background thread
final File path = volume.getPath();
if (totalBytes <= 0) {
totalBytes = path.getTotalSpace();
}
final long freeBytes = path.getFreeSpace();
final long totalBytes = path.getTotalSpace();
final long usedBytes = totalBytes - freeBytes;
final String used = Formatter.formatFileSize(context, usedBytes);