SetWallpaperTool
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.