Package org.robolectric.shadows
Class ShadowStorageStatsManager
- java.lang.Object
-
- org.robolectric.shadows.ShadowStorageStatsManager
-
@Implements(value=android.app.usage.StorageStatsManager.class, minSdk=26) public class ShadowStorageStatsManager extends Object
Fake implementation ofStorageStatsManager
that provides a fake implementation of query forStorageStats
of a package.
-
-
Field Summary
Fields Modifier and Type Field Description static long
DEFAULT_STORAGE_FREE_BYTES
static long
DEFAULT_STORAGE_TOTAL_BYTES
-
Constructor Summary
Constructors Constructor Description ShadowStorageStatsManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addStorageStats(UUID storageUuid, String packageName, UserHandle userHandle, StorageStats storageStatsToReturn)
void
clearStorageStats()
protected long
getFreeBytes(UUID storageUuid)
Fake implementation ofStorageStatsManager.getFreeBytes(java.util.UUID)
that returns test setup values.protected long
getTotalBytes(UUID storageUuid)
Fake implementation ofStorageStatsManager.getTotalBytes(java.util.UUID)
that returns test setup values.protected StorageStats
queryStatsForPackage(UUID storageUuid, String packageName, UserHandle user)
Fake implementation ofStorageStatsManager.queryStatsForPackage(java.util.UUID, java.lang.String, android.os.UserHandle)
that returns test setup values.void
removeStorageDevice(UUID storageUuid)
Removes a storage device identified bystorageUuid
if it's currently present.void
setStorageDeviceFreeAndTotalBytes(UUID storageUuid, long freeBytes, long totalBytes)
Sets thestorageUuid
to return the specifiedfreeBytes
andtotalBytes
when queried ingetFreeBytes(java.util.UUID)
andgetTotalBytes(java.util.UUID)
respectively.
-
-
-
Field Detail
-
DEFAULT_STORAGE_FREE_BYTES
public static final long DEFAULT_STORAGE_FREE_BYTES
- See Also:
- Constant Field Values
-
DEFAULT_STORAGE_TOTAL_BYTES
public static final long DEFAULT_STORAGE_TOTAL_BYTES
- See Also:
- Constant Field Values
-
-
Method Detail
-
setStorageDeviceFreeAndTotalBytes
public void setStorageDeviceFreeAndTotalBytes(UUID storageUuid, long freeBytes, long totalBytes)
Sets thestorageUuid
to return the specifiedfreeBytes
andtotalBytes
when queried ingetFreeBytes(java.util.UUID)
andgetTotalBytes(java.util.UUID)
respectively.Both
freeBytes
andtotalBytes
have to be non-negative, else this method will throwIllegalArgumentException
.
-
removeStorageDevice
public void removeStorageDevice(UUID storageUuid)
Removes a storage device identified bystorageUuid
if it's currently present. Otherwise, this method will be a no-op.
-
addStorageStats
public void addStorageStats(UUID storageUuid, String packageName, UserHandle userHandle, StorageStats storageStatsToReturn)
-
clearStorageStats
public void clearStorageStats()
-
getFreeBytes
@Implementation protected long getFreeBytes(UUID storageUuid) throws IOException
Fake implementation ofStorageStatsManager.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 insetStorageDeviceFreeAndTotalBytes(java.util.UUID, long, long)
.- Throws:
IOException
-
getTotalBytes
@Implementation protected long getTotalBytes(UUID storageUuid) throws IOException
Fake implementation ofStorageStatsManager.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 insetStorageDeviceFreeAndTotalBytes(java.util.UUID, long, long)
.- Throws:
IOException
-
queryStatsForPackage
@Implementation protected StorageStats queryStatsForPackage(UUID storageUuid, String packageName, UserHandle user) throws PackageManager.NameNotFoundException, IOException
Fake implementation ofStorageStatsManager.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 inaddStorageStats(java.util.UUID, java.lang.String, android.os.UserHandle, android.app.usage.StorageStats)
.
-
-