Package org.robolectric.shadows
Class ShadowWallpaperManager
java.lang.Object
org.robolectric.shadows.ShadowWallpaperManager
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRepresents an invocation record ofWallpaperManager.sendWallpaperCommand(android.os.IBinder, java.lang.String, int, int, int, android.os.Bundle) -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns a list of all dim amounts set from calls to setWallpaperDimAmount.getBitmap(int which) Returns the memory cachedBitmapassociated withwhich.getCropHints(int which) Returns the memory cachedSparseArray<Rect>associated withwhich.getDescription(int which) Returns the memory cachedWallpaperDescriptionassociated withwhich.getVisibleCropHint(int which) Returns the memory cachedRectassociated withwhich.Returns all the invocation records toWallpaperManager.sendWallpaperCommand(android.os.IBinder, java.lang.String, int, int, int, android.os.Bundle)getWallpaperDescription(int which) Returns the memory cachedWallpaperDescriptionassociated withwhich.protected floatprotected ParcelFileDescriptorgetWallpaperFile(int which) Gets a wallpaper file associated withwhich.protected ParcelFileDescriptorgetWallpaperFile(int which, boolean getCropped) Gets a wallpaper file associated withwhich.protected intgetWallpaperId(int which) Returns the id of the current wallpaper associated withwhich.protected WallpaperInfoReturns the information about the wallpaper if the current wallpaper is a live wallpaper component.protected booleanhasResourceWallpaper(int resid) Returns whether the current wallpaper has been set throughsetResource(int)orsetResource(int, int)with the same resource id.protected booleanprotected booleanisWallpaperBackupEligible(int which) Returns whether the current wallpaper is backup eligible.protected booleanstatic voidreset()protected voidsendWallpaperCommand(IBinder windowToken, String action, int x, int y, int z, Bundle extras) protected intCachesfullImagein the memory based onwhich.protected intsetBitmapWithDescription(Bitmap fullImage, WallpaperDescription description, boolean allowBackup, int which) CachesfullImageanddescriptionin the memory based onwhich.voidsetIsSetWallpaperAllowed(boolean allowed) voidsetIsWallpaperSupported(boolean supported) protected voidsetResource(int resid) Sets a resource id as the current wallpaper.protected intsetResource(int resid, int which) protected intsetStream(InputStream bitmapData, Rect visibleCropHint, boolean allowBackup, int which) CachesbitmapDatain the memory based onwhich.protected intsetStreamWithDescription(InputStream bitmapData, WallpaperDescription description, boolean allowBackup, int which) CachesbitmapDataanddescriptionin the memory based onwhich.protected booleansetWallpaperComponent(ComponentName wallpaperService) Sets a live wallpaper,wallpaperService, as the current wallpaper.protected voidsetWallpaperDimAmount(float dimAmount)
-
Constructor Details
-
ShadowWallpaperManager
public ShadowWallpaperManager()
-
-
Method Details
-
sendWallpaperCommand
@Implementation protected void sendWallpaperCommand(IBinder windowToken, String action, int x, int y, int z, Bundle extras) -
setResource
Sets a resource id as the current wallpaper.This only caches the resource id in memory. Calling this will override any previously set resource and does not differentiate between users.
-
setResource
-
hasResourceWallpaper
Returns whether the current wallpaper has been set throughsetResource(int)orsetResource(int, int)with the same resource id. -
setBitmapWithDescription
@Implementation(minSdk=36) protected int setBitmapWithDescription(Bitmap fullImage, WallpaperDescription description, boolean allowBackup, int which) throws IOException CachesfullImageanddescriptionin the memory based onwhich.After a success call, any previously set live wallpaper is removed,
- Parameters:
fullImage- the bitmap image to be cached in the memorydescription- the wallpaper description to be cached in the memoryallowBackup- whether the wallpaper is backup eligiblewhich- flag indicating which wallpaper to configure with the new bitmap, eitherWallpaperManager.FLAG_LOCKorWallpaperManager.FLAG_SYSTEMare valid- Returns:
- 0 if fails to cache. Otherwise, 1.
-
setStreamWithDescription
@Implementation(minSdk=36) protected int setStreamWithDescription(InputStream bitmapData, WallpaperDescription description, boolean allowBackup, int which) throws IOException CachesbitmapDataanddescriptionin the memory based onwhich.After a success call, any previously set live wallpaper is removed,
- Parameters:
bitmapData- the input stream which contains a bitmap image to be cached in the memorydescription- the wallpaper description to be cached in the memoryallowBackup- whether the wallpaper is backup eligiblewhich- flag indicating which wallpaper to configure with the input stream, eitherWallpaperManager.FLAG_LOCKorWallpaperManager.FLAG_SYSTEMare valid- Returns:
- 0 if fails to cache. Otherwise, 1.
-
setBitmap
@Implementation(minSdk=24) protected int setBitmap(Bitmap fullImage, Rect visibleCropHint, boolean allowBackup, int which) CachesfullImagein the memory based onwhich.After a success call, any previously set live wallpaper is removed,
- Parameters:
fullImage- the bitmap image to be cached in the memoryvisibleCropHint- the visible crop hint to be cached in the memoryallowBackup- whether the wallpaper is backup eligiblewhich- eitherWallpaperManager.FLAG_LOCKor {WallpaperManager#FLAG_SYSTEM}- Returns:
- 0 if fails to cache. Otherwise, 1.
-
getBitmap
Returns the memory cachedBitmapassociated withwhich.- Parameters:
which- eitherWallpaperManager.FLAG_LOCKorWallpaperManager.FLAG_SYSTEM.- Returns:
- The memory cached
Bitmapassociated withwhich.nullif no bitmap was set.
-
getVisibleCropHint
Returns the memory cachedRectassociated withwhich.- Parameters:
which- eitherWallpaperManager.FLAG_LOCKorWallpaperManager.FLAG_SYSTEM.- Returns:
- The memory cached
Rectassociated withwhich.nullif no rect was set.
-
getCropHints
Returns the memory cachedSparseArray<Rect>associated withwhich.- Parameters:
which- eitherWallpaperManager.FLAG_LOCKor {WallpaperManager#FLAG_SYSTEM}.- Returns:
- The memory cached
SparseArray<Rect>associated withwhich.nullif no sparse array was set.
-
getDescription
Returns the memory cachedWallpaperDescriptionassociated withwhich.- Parameters:
which- eitherWallpaperManager.FLAG_LOCKorWallpaperManager.FLAG_SYSTEM.- Returns:
- The memory cached
WallpaperDescriptionassociated withwhich.nullif no wallpaper description was set.
-
getWallpaperDescription
Returns the memory cachedWallpaperDescriptionassociated withwhich.- Parameters:
which- eitherWallpaperManager.FLAG_LOCKorWallpaperManager.FLAG_SYSTEM.- Returns:
- The memory cached
WallpaperDescriptionassociated withwhich.nullif no wallpaper description was set.
-
getWallpaperFile
Gets a wallpaper file associated withwhich.- Parameters:
which- eitherWallpaperManager.FLAG_LOCKor {WallpaperManager#FLAG_SYSTEM}- Returns:
- An open, readable file descriptor to the requested wallpaper image file;
nullif no such wallpaper is configured.
-
getWallpaperFile
@Implementation(minSdk=36) protected ParcelFileDescriptor getWallpaperFile(int which, boolean getCropped) Gets a wallpaper file associated withwhich.- Parameters:
which- eitherWallpaperManager.FLAG_LOCKor {WallpaperManager#FLAG_SYSTEM}getCropped- not used.- Returns:
- An open, readable file descriptor to the requested wallpaper image file;
nullif no such wallpaper is configured.
-
isWallpaperBackupEligible
Returns whether the current wallpaper is backup eligible. -
getWallpaperId
Returns the id of the current wallpaper associated withwhich. If there is no such wallpaper configured, returns a negative number. -
isSetWallpaperAllowed
-
setIsSetWallpaperAllowed
public void setIsSetWallpaperAllowed(boolean allowed) -
isWallpaperSupported
-
setIsWallpaperSupported
public void setIsWallpaperSupported(boolean supported) -
setStream
@Implementation(minSdk=24) protected int setStream(InputStream bitmapData, Rect visibleCropHint, boolean allowBackup, int which) CachesbitmapDatain the memory based onwhich.- Parameters:
bitmapData- the input stream which contains a bitmap image to be cached in the memoryvisibleCropHint- not usedallowBackup- whether the wallpaper is backup eligiblewhich- eitherWallpaperManager.FLAG_LOCKor {WallpaperManager#FLAG_SYSTEM}- Returns:
- 0 if fails to cache. Otherwise, 1.
-
setWallpaperComponent
@Implementation(minSdk=23) protected boolean setWallpaperComponent(ComponentName wallpaperService) throws IOException, XmlPullParserException Sets a live wallpaper,wallpaperService, as the current wallpaper.This only caches the live wallpaper info in the memory. Calling this will remove any previously set static wallpaper.
- Throws:
IOExceptionXmlPullParserException
-
getWallpaperInfo
Returns the information about the wallpaper if the current wallpaper is a live wallpaper component. Otherwise, if the wallpaper is a static image, this returns null. -
setWallpaperDimAmount
-
getAllWallpaperDimAmounts
Returns a list of all dim amounts set from calls to setWallpaperDimAmount. This can be used to verify that repeated calls to setWallpaperDimAmount are not done which can cause issues. -
getWallpaperDimAmount
-
getWallpaperCommandRecords
Returns all the invocation records toWallpaperManager.sendWallpaperCommand(android.os.IBinder, java.lang.String, int, int, int, android.os.Bundle) -
reset
-