Add storage fullness methods to volume provider.
This allows us to mock them out for use in unit tests. Fixes: 36858638 Change-Id: I2509d9704b531cf3594790f738aaedb7ed5db443 Test: Thin wrapper is used in Settings unittest
This commit is contained in:
@@ -41,8 +41,8 @@ public class PrivateStorageInfo {
|
||||
long privateTotalBytes = 0;
|
||||
for (VolumeInfo info : sm.getVolumes()) {
|
||||
if (info.getType() == VolumeInfo.TYPE_PRIVATE && info.isMountedReadable()) {
|
||||
privateTotalBytes += stats.getTotalBytes(info.getFsUuid());
|
||||
privateFreeBytes += stats.getFreeBytes(info.getFsUuid());
|
||||
privateTotalBytes += sm.getTotalBytes(stats, info);
|
||||
privateFreeBytes += sm.getFreeBytes(stats, info);
|
||||
}
|
||||
}
|
||||
return new PrivateStorageInfo(privateFreeBytes, privateTotalBytes);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.settingslib.deviceinfo;
|
||||
|
||||
import android.app.usage.StorageStatsManager;
|
||||
import android.os.storage.StorageManager;
|
||||
import android.os.storage.VolumeInfo;
|
||||
|
||||
@@ -46,4 +47,14 @@ public class StorageManagerVolumeProvider implements StorageVolumeProvider {
|
||||
public VolumeInfo findEmulatedForPrivate(VolumeInfo privateVolume) {
|
||||
return mStorageManager.findEmulatedForPrivate(privateVolume);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTotalBytes(StorageStatsManager stats, VolumeInfo volume) {
|
||||
return stats.getTotalBytes(volume.getFsUuid());
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getFreeBytes(StorageStatsManager stats, VolumeInfo volume) {
|
||||
return stats.getFreeBytes(volume.getFsUuid());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.settingslib.deviceinfo;
|
||||
|
||||
import android.app.usage.StorageStatsManager;
|
||||
import android.os.storage.VolumeInfo;
|
||||
|
||||
import java.util.List;
|
||||
@@ -39,4 +40,18 @@ public interface StorageVolumeProvider {
|
||||
* Returns the emulated volume for a given private volume.
|
||||
*/
|
||||
VolumeInfo findEmulatedForPrivate(VolumeInfo privateVolume);
|
||||
|
||||
/**
|
||||
* Returns the total bytes for a given storage volume.
|
||||
*
|
||||
* @pre The volume is a private volume and is readable.
|
||||
*/
|
||||
long getTotalBytes(StorageStatsManager stats, VolumeInfo volume);
|
||||
|
||||
/**
|
||||
* Returns the free bytes for a given storage volume.
|
||||
*
|
||||
* @pre The volume is a private volume and is readable.
|
||||
*/
|
||||
long getFreeBytes(StorageStatsManager stats, VolumeInfo volume);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user