SetWallpaperTool

class SetWallpaperTool(context: Context) : McpTool

Sets the wallpaper from a local image file via WallpaperManager.setBitmap, targeting the home screen, lock screen, or both.

Requires the SET_WALLPAPER permission (normal, granted at install). The path is sandboxed to the external-storage root (canonical-path check); paths outside it are rejected. Also rejected if device policy disallows setting wallpaper (WallpaperManager.isSetWallpaperAllowed) or the image cannot be read/decoded (the error mentions scoped-storage read access as the usual cause).

The image is decoded from the validated canonical path in two passes: bounds first, then with a power-of-two inSampleSize that brings it down to roughly WallpaperManager.getDesiredMinimumWidth/WallpaperManager.getDesiredMinimumHeight (falling back to the display size), so large photos don't exhaust memory. A setBitmap return of 0 is reported as a failure.

Output keys: success, path, target, width/height (the decoded, possibly downsampled bitmap), original_width, original_height, sample_size.

Constructors

Link copied to clipboard
constructor(context: Context)

Properties

Link copied to clipboard
open override val annotations: ToolAnnotations
Link copied to clipboard
open override val description: String
Link copied to clipboard
open override val name: String
Link copied to clipboard
open override val outputSchema: Map<String, Any>
Link copied to clipboard
open override val parameters: List<ToolParameter>

Functions

Link copied to clipboard
open suspend override fun execute(params: Map<String, Any>): ToolResult