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 of
StorageStatsManager that provides a fake
implementation of query for StorageStats of a package.-
Field Summary
Fields Modifier and Type Field Description static longDEFAULT_STORAGE_FREE_BYTESstatic longDEFAULT_STORAGE_TOTAL_BYTES -
Constructor Summary
Constructors Constructor Description ShadowStorageStatsManager() -
Method Summary
Modifier and Type Method Description voidaddStorageStats(UUID storageUuid, String packageName, UserHandle userHandle, StorageStats storageStatsToReturn)voidclearStorageStats()protected longgetFreeBytes(UUID storageUuid)Fake implementation ofStorageStatsManager.getFreeBytes(java.util.UUID)that returns test setup values.protected longgetTotalBytes(UUID storageUuid)Fake implementation ofStorageStatsManager.getTotalBytes(java.util.UUID)that returns test setup values.protected StorageStatsqueryStatsForPackage(UUID storageUuid, String packageName, UserHandle user)Fake implementation ofStorageStatsManager.queryStatsForPackage(java.util.UUID, java.lang.String, android.os.UserHandle)that returns test setup values.voidremoveStorageDevice(UUID storageUuid)Removes a storage device identified bystorageUuidif it's currently present.voidsetStorageDeviceFreeAndTotalBytes(UUID storageUuid, long freeBytes, long totalBytes)Sets thestorageUuidto return the specifiedfreeBytesandtotalByteswhen queried ingetFreeBytes(java.util.UUID)andgetTotalBytes(java.util.UUID)respectively.
-
Field Details
-
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
-
-
Constructor Details
-
ShadowStorageStatsManager
public ShadowStorageStatsManager()
-
-
Method Details
-
setStorageDeviceFreeAndTotalBytes
Sets thestorageUuidto return the specifiedfreeBytesandtotalByteswhen queried ingetFreeBytes(java.util.UUID)andgetTotalBytes(java.util.UUID)respectively.Both
freeBytesandtotalByteshave to be non-negative, else this method will throwIllegalArgumentException. -
removeStorageDevice
Removes a storage device identified bystorageUuidif 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
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
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, IOExceptionFake 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).
-