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 SummaryFieldsModifier and TypeFieldDescriptionstatic final longstatic final long
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddStorageStats(UUID storageUuid, String packageName, UserHandle userHandle, StorageStats storageStatsToReturn) voidprotected 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 Details- 
DEFAULT_STORAGE_FREE_BYTESpublic static final long DEFAULT_STORAGE_FREE_BYTES- See Also:
 
- 
DEFAULT_STORAGE_TOTAL_BYTESpublic static final long DEFAULT_STORAGE_TOTAL_BYTES- See Also:
 
 
- 
- 
Constructor Details- 
ShadowStorageStatsManagerpublic ShadowStorageStatsManager()
 
- 
- 
Method Details- 
setStorageDeviceFreeAndTotalBytesSets 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.
- 
removeStorageDeviceRemoves a storage device identified bystorageUuidif it's currently present. Otherwise, this method will be a no-op.
- 
addStorageStatspublic 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.
- 
clearStorageStatspublic void clearStorageStats()
- 
getFreeBytesFake 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
 
- 
getTotalBytesFake 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).
 
-