@Implements(value=android.app.usage.StorageStatsManager.class, minSdk=26) public class ShadowStorageStatsManager extends Object
StorageStatsManager
that provides a fake
implementation of query for StorageStats
of a package.Modifier and Type | Field | Description |
---|---|---|
static long |
DEFAULT_STORAGE_FREE_BYTES |
|
static long |
DEFAULT_STORAGE_TOTAL_BYTES |
Constructor | Description |
---|---|
ShadowStorageStatsManager() |
Modifier and Type | Method | Description |
---|---|---|
void |
addStorageStats(UUID storageUuid,
String packageName,
UserHandle userHandle,
StorageStats storageStatsToReturn) |
|
void |
clearStorageStats() |
|
protected long |
getFreeBytes(UUID storageUuid) |
Fake implementation of
StorageStatsManager.getFreeBytes(java.util.UUID) that returns test setup values. |
protected long |
getTotalBytes(UUID storageUuid) |
Fake implementation of
StorageStatsManager.getTotalBytes(java.util.UUID) that returns test setup
values. |
protected StorageStats |
queryStatsForPackage(UUID storageUuid,
String packageName,
UserHandle user) |
Fake implementation of
StorageStatsManager.queryStatsForPackage(java.util.UUID, java.lang.String, android.os.UserHandle) that returns test setup
values. |
void |
removeStorageDevice(UUID storageUuid) |
Removes a storage device identified by
storageUuid if it's currently present. |
void |
setStorageDeviceFreeAndTotalBytes(UUID storageUuid,
long freeBytes,
long totalBytes) |
Sets the
storageUuid to return the specified freeBytes and totalBytes
when queried in getFreeBytes(java.util.UUID) and getTotalBytes(java.util.UUID) respectively. |
public static final long DEFAULT_STORAGE_FREE_BYTES
public static final long DEFAULT_STORAGE_TOTAL_BYTES
public void setStorageDeviceFreeAndTotalBytes(UUID storageUuid, long freeBytes, long totalBytes)
storageUuid
to return the specified freeBytes
and totalBytes
when queried in getFreeBytes(java.util.UUID)
and getTotalBytes(java.util.UUID)
respectively.
Both freeBytes
and totalBytes
have to be non-negative, else this method will
throw IllegalArgumentException
.
public void removeStorageDevice(UUID storageUuid)
storageUuid
if it's currently present.
Otherwise, this method will be a no-op.public void addStorageStats(UUID storageUuid, String packageName, UserHandle userHandle, StorageStats storageStatsToReturn)
public void clearStorageStats()
@Implementation protected long getFreeBytes(UUID storageUuid) throws IOException
StorageStatsManager.getFreeBytes(java.util.UUID)
that returns test setup values.
This fake implementation does not check for access permission. It only checks for arguments
matching those set in setStorageDeviceFreeAndTotalBytes(java.util.UUID, long, long)
.IOException
@Implementation protected long getTotalBytes(UUID storageUuid) throws IOException
StorageStatsManager.getTotalBytes(java.util.UUID)
that returns test setup
values. This fake implementation does not check for access permission. It only checks for
arguments matching those set in setStorageDeviceFreeAndTotalBytes(java.util.UUID, long, long)
.IOException
@Implementation protected StorageStats queryStatsForPackage(UUID storageUuid, String packageName, UserHandle user) throws PackageManager.NameNotFoundException, IOException
StorageStatsManager.queryStatsForPackage(java.util.UUID, java.lang.String, android.os.UserHandle)
that returns test setup
values. This fake implementation does not check for access permission. It only checks for
arguments matching those set in addStorageStats(java.util.UUID, java.lang.String, android.os.UserHandle, android.app.usage.StorageStats)
.