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 ofStorageStatsManagerthat provides a fake implementation of query forStorageStatsof 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
All Methods Instance Methods Concrete Methods 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.protected StorageStatsqueryStatsForUser(UUID storageUuid, UserHandle user)Fake implementation ofStorageStatsManager.queryStatsForUser(java.util.UUID, android.os.UserHandle)that returns an accumulatedStorageStatsbased on the setup values for the user.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 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 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
public void removeStorageDevice(UUID storageUuid)
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)
Sets theStorageStatsfor givenstorageUuid,packageNameanduserHandle. IfqueryStatsForPackageis called with matchingstorageUuid,packageNameanduserHandle, thestorageStatsToReturnwill be returned directly. IfqueryStatsForUseris called with matchingstorageUuidanduserHandle, then an accumulatedStorageStatswill be returned.
-
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).
-
queryStatsForUser
@Implementation protected StorageStats queryStatsForUser(UUID storageUuid, UserHandle user) throws PackageManager.NameNotFoundException, IOException
Fake implementation ofStorageStatsManager.queryStatsForUser(java.util.UUID, android.os.UserHandle)that returns an accumulatedStorageStatsbased on the setup values for the user. 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).
-
-