Package org.robolectric.shadows
Class ShadowWallpaperManager
- java.lang.Object
-
- org.robolectric.shadows.ShadowWallpaperManager
-
@Implements(android.app.WallpaperManager.class) public class ShadowWallpaperManager extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ShadowWallpaperManager.WallpaperCommandRecord
Represents an invocation record ofWallpaperManager.sendWallpaperCommand(android.os.IBinder, java.lang.String, int, int, int, android.os.Bundle)
-
Constructor Summary
Constructors Constructor Description ShadowWallpaperManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Bitmap
getBitmap(int which)
Returns the memory cachedBitmap
associated withwhich
.List<ShadowWallpaperManager.WallpaperCommandRecord>
getWallpaperCommandRecords()
Returns all the invocation records toWallpaperManager.sendWallpaperCommand(android.os.IBinder, java.lang.String, int, int, int, android.os.Bundle)
protected ParcelFileDescriptor
getWallpaperFile(int which)
Gets a wallpaper file associated withwhich
.protected WallpaperInfo
getWallpaperInfo()
Returns the information about the wallpaper if the current wallpaper is a live wallpaper component.protected boolean
isSetWallpaperAllowed()
protected boolean
isWallpaperSupported()
protected void
sendWallpaperCommand(IBinder windowToken, String action, int x, int y, int z, Bundle extras)
protected int
setBitmap(Bitmap fullImage, Rect visibleCropHint, boolean allowBackup, int which)
CachesfullImage
in the memory based onwhich
.void
setIsSetWallpaperAllowed(boolean allowed)
void
setIsWallpaperSupported(boolean supported)
protected int
setStream(InputStream bitmapData, Rect visibleCropHint, boolean allowBackup, int which)
CachesbitmapData
in the memory based onwhich
.protected boolean
setWallpaperComponent(ComponentName wallpaperService)
Sets a live wallpaper,wallpaperService
, as the current wallpaper.
-
-
-
Method Detail
-
sendWallpaperCommand
@Implementation protected void sendWallpaperCommand(IBinder windowToken, String action, int x, int y, int z, Bundle extras)
-
setBitmap
@Implementation(minSdk=28) protected int setBitmap(Bitmap fullImage, Rect visibleCropHint, boolean allowBackup, int which)
CachesfullImage
in 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
- not usedallowBackup
- not usedwhich
- eitherWallpaperManager.FLAG_LOCK
or {WallpaperManager#FLAG_SYSTEM}- Returns:
- 0 if fails to cache. Otherwise, 1.
-
getBitmap
@Nullable public Bitmap getBitmap(int which)
Returns the memory cachedBitmap
associated withwhich
.- Parameters:
which
- eitherWallpaperManager.FLAG_LOCK
or {WallpaperManager#FLAG_SYSTEM}.- Returns:
- The memory cached
Bitmap
associated withwhich
.null
if no bitmap was set.
-
getWallpaperFile
@Implementation(minSdk=28) @Nullable protected ParcelFileDescriptor getWallpaperFile(int which)
Gets a wallpaper file associated withwhich
.- Parameters:
which
- eitherWallpaperManager.FLAG_LOCK
or {WallpaperManager#FLAG_SYSTEM}- Returns:
- An open, readable file descriptor to the requested wallpaper image file;
null
if no such wallpaper is configured.
-
isSetWallpaperAllowed
@Implementation(minSdk=24) protected boolean isSetWallpaperAllowed()
-
setIsSetWallpaperAllowed
public void setIsSetWallpaperAllowed(boolean allowed)
-
isWallpaperSupported
@Implementation(minSdk=23) protected boolean isWallpaperSupported()
-
setIsWallpaperSupported
public void setIsWallpaperSupported(boolean supported)
-
setStream
@Implementation(minSdk=24) protected int setStream(InputStream bitmapData, Rect visibleCropHint, boolean allowBackup, int which)
CachesbitmapData
in the memory based onwhich
.- Parameters:
bitmapData
- the input stream which contains a bitmap image to be cached in the memoryvisibleCropHint
- not usedallowBackup
- not usedwhich
- eitherWallpaperManager.FLAG_LOCK
or {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:
IOException
XmlPullParserException
-
getWallpaperInfo
@Implementation(minSdk=23) protected WallpaperInfo 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.
-
getWallpaperCommandRecords
public List<ShadowWallpaperManager.WallpaperCommandRecord> getWallpaperCommandRecords()
Returns all the invocation records toWallpaperManager.sendWallpaperCommand(android.os.IBinder, java.lang.String, int, int, int, android.os.Bundle)
-
-