1 /** 2 * Copyright (c) 2008, The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.app; 18 19 import android.graphics.Point; 20 import android.graphics.Rect; 21 import android.graphics.RectF; 22 import android.os.Bundle; 23 import android.os.ParcelFileDescriptor; 24 import android.app.IWallpaperManagerCallback; 25 import android.app.ILocalWallpaperColorConsumer; 26 import android.app.WallpaperInfo; 27 import android.app.wallpaper.WallpaperDescription; 28 import android.app.wallpaper.WallpaperInstance; 29 import android.content.ComponentName; 30 import android.app.WallpaperColors; 31 32 import java.util.List; 33 34 /** @hide */ 35 interface IWallpaperManager { 36 37 /** 38 * Set the wallpaper for the current user. 39 * 40 * If 'extras' is non-null, on successful return it will contain: 41 * EXTRA_SET_WALLPAPER_ID : integer ID that the new wallpaper will have 42 * 43 * 'which' is some combination of: 44 * FLAG_SET_SYSTEM 45 * FLAG_SET_LOCK 46 * 47 * 'screenOrientations' and 'crops' define how the wallpaper will be positioned for 48 * different screen orientations. If some screen orientations are missing, crops for these 49 * orientations will be added by the system. 50 * 51 * If 'screenOrientations' is null, 'crops' can be null or a singleton list. The system will 52 * fit the provided crop (or the whole image, if 'crops' is 'null') for the current device 53 * orientation, and add crops for the missing orientations. 54 * 55 * The completion callback's "onWallpaperChanged()" method is invoked when the 56 * new wallpaper content is ready to display. 57 */ 58 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.SET_WALLPAPER)") setWallpaper(String name, in String callingPackage, in int[] screenOrientations, in List<Rect> crops, boolean allowBackup, out Bundle extras, int which, IWallpaperManagerCallback completion, int userId)59 ParcelFileDescriptor setWallpaper(String name, in String callingPackage, 60 in int[] screenOrientations, in List<Rect> crops, boolean allowBackup, 61 out Bundle extras, int which, IWallpaperManagerCallback completion, int userId); 62 63 /** 64 * Set the live wallpaper. 65 */ setWallpaperComponentChecked(in WallpaperDescription description, in String callingPackage, int which, int userId)66 void setWallpaperComponentChecked(in WallpaperDescription description, in String callingPackage, 67 int which, int userId); 68 69 /** 70 * Set the live wallpaper. This only affects the system wallpaper. 71 */ 72 @UnsupportedAppUsage setWallpaperComponent(in ComponentName name)73 void setWallpaperComponent(in ComponentName name); 74 75 76 /** 77 * @deprecated Use {@link #getWallpaperWithFeature(String, IWallpaperManagerCallback, int, 78 * Bundle, int)} 79 */ 80 @UnsupportedAppUsage getWallpaper(String callingPkg, IWallpaperManagerCallback cb, int which, out Bundle outParams, int userId)81 ParcelFileDescriptor getWallpaper(String callingPkg, IWallpaperManagerCallback cb, int which, 82 out Bundle outParams, int userId); 83 84 /** 85 * Get the wallpaper for a given user. 86 */ getWallpaperWithFeature(String callingPkg, String callingFeatureId, IWallpaperManagerCallback cb, int which, out Bundle outParams, int userId, boolean getCropped)87 ParcelFileDescriptor getWallpaperWithFeature(String callingPkg, String callingFeatureId, 88 IWallpaperManagerCallback cb, int which, out Bundle outParams, int userId, 89 boolean getCropped); 90 91 /** 92 * For a given user and a list of display sizes, get a list of Rect representing the 93 * area of the current wallpaper that is displayed for each display size. 94 */ 95 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.READ_WALLPAPER_INTERNAL)") 96 @SuppressWarnings(value={"untyped-collection"}) getBitmapCrops(in List<Point> displaySizes, int which, boolean originalBitmap, int userId)97 List getBitmapCrops(in List<Point> displaySizes, int which, boolean originalBitmap, int userId); 98 99 /** 100 * For a given user, if the wallpaper of the specified which is an ImageWallpaper, return 101 * a bundle which is a Map<Integer, Rect> containing the custom cropHints that were sent to 102 * setBitmapWithCrops or setStreamWithCrops. These crops are relative to the original bitmap. 103 * If the wallpaper isn't an ImageWallpaper, return null. 104 */ 105 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.READ_WALLPAPER_INTERNAL)") 106 @SuppressWarnings(value={"untyped-collection"}) getCurrentBitmapCrops(int which, int userId)107 Bundle getCurrentBitmapCrops(int which, int userId); 108 109 /** 110 * Return how a bitmap of a given size would be cropped for a given list of display sizes when 111 * set with the given suggested crops. 112 * @hide 113 */ 114 @SuppressWarnings(value={"untyped-collection"}) getFutureBitmapCrops(in Point bitmapSize, in List<Point> displaySizes, in int[] screenOrientations, in List<Rect> crops)115 List getFutureBitmapCrops(in Point bitmapSize, in List<Point> displaySizes, 116 in int[] screenOrientations, in List<Rect> crops); 117 118 /** 119 * Return how a bitmap of a given size would be cropped when set with the given suggested crops. 120 * @hide 121 */ 122 @SuppressWarnings(value={"untyped-collection"}) getBitmapCrop(in Point bitmapSize, in int[] screenOrientations, in List<Rect> crops)123 Rect getBitmapCrop(in Point bitmapSize, in int[] screenOrientations, in List<Rect> crops); 124 125 /** 126 * Retrieve the given user's current wallpaper ID of the given kind. 127 */ getWallpaperIdForUser(int which, int userId)128 int getWallpaperIdForUser(int which, int userId); 129 130 /** 131 * If the current system wallpaper is a live wallpaper component, return the 132 * information about that wallpaper. Otherwise, if it is a static image, 133 * simply return null. 134 */ 135 @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553) getWallpaperInfo(int userId)136 WallpaperInfo getWallpaperInfo(int userId); 137 138 /** 139 * If the current wallpaper for destination `which` is a live wallpaper component, return the 140 * information about that wallpaper. Otherwise, if it is a static image, simply return null. 141 */ getWallpaperInfoWithFlags(int which, int userId)142 WallpaperInfo getWallpaperInfoWithFlags(int which, int userId); 143 144 /** 145 * Return the instance information about the wallpaper described by `which`, or null if lock 146 * screen is requested and it is the same as home. 147 */ 148 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.READ_WALLPAPER_INTERNAL)") getWallpaperInstance(int which, int userId)149 WallpaperInstance getWallpaperInstance(int which, int userId); 150 151 /** 152 * Return a file descriptor for the file that contains metadata about the given user's 153 * wallpaper. 154 */ getWallpaperInfoFile(int userId)155 ParcelFileDescriptor getWallpaperInfoFile(int userId); 156 157 /** 158 * Clear the system wallpaper. 159 */ clearWallpaper(in String callingPackage, int which, int userId)160 void clearWallpaper(in String callingPackage, int which, int userId); 161 162 /** 163 * Return whether the current system wallpaper has the given name. 164 */ 165 @UnsupportedAppUsage hasNamedWallpaper(String name)166 boolean hasNamedWallpaper(String name); 167 168 /** 169 * Sets the dimension hint for the wallpaper. These hints indicate the desired 170 * minimum width and height for the wallpaper in a particular display. 171 */ setDimensionHints(in int width, in int height, in String callingPackage, int displayId)172 void setDimensionHints(in int width, in int height, in String callingPackage, int displayId); 173 174 /** 175 * Returns the desired minimum width for the wallpaper in a particular display. 176 */ 177 @UnsupportedAppUsage getWidthHint(int displayId)178 int getWidthHint(int displayId); 179 180 /** 181 * Returns the desired minimum height for the wallpaper in a particular display. 182 */ 183 @UnsupportedAppUsage getHeightHint(int displayId)184 int getHeightHint(int displayId); 185 186 /** 187 * Sets extra padding that we would like the wallpaper to have outside of the display. 188 */ setDisplayPadding(in Rect padding, in String callingPackage, int displayId)189 void setDisplayPadding(in Rect padding, in String callingPackage, int displayId); 190 191 /** 192 * Returns the name of the wallpaper. Private API. 193 */ getName()194 String getName(); 195 196 /** 197 * Informs the service that wallpaper settings have been restored. Private API. 198 */ settingsRestored()199 void settingsRestored(); 200 201 /** 202 * Check whether wallpapers are supported for the calling user. 203 */ isWallpaperSupported(in String callingPackage)204 boolean isWallpaperSupported(in String callingPackage); 205 206 /** 207 * Check whether setting of wallpapers are allowed for the calling user. 208 */ isSetWallpaperAllowed(in String callingPackage)209 boolean isSetWallpaperAllowed(in String callingPackage); 210 211 /* 212 * Backup: is the current system wallpaper image eligible for off-device backup? 213 */ isWallpaperBackupEligible(int which, int userId)214 boolean isWallpaperBackupEligible(int which, int userId); 215 216 /** 217 * Returns the colors used by the lock screen or system wallpaper. 218 * 219 * @param which either {@link WallpaperManager#FLAG_LOCK} 220 * or {@link WallpaperManager#FLAG_SYSTEM} 221 * @param displayId Which display is interested 222 * @return colors of chosen wallpaper 223 */ getWallpaperColors(int which, int userId, int displayId)224 WallpaperColors getWallpaperColors(int which, int userId, int displayId); 225 226 /** 227 * @hide 228 */ removeOnLocalColorsChangedListener( in ILocalWallpaperColorConsumer callback, in List<RectF> area, int which, int userId, int displayId)229 void removeOnLocalColorsChangedListener( 230 in ILocalWallpaperColorConsumer callback, in List<RectF> area, 231 int which, int userId, int displayId); 232 233 /** 234 * @hide 235 */ addOnLocalColorsChangedListener(in ILocalWallpaperColorConsumer callback, in List<RectF> regions, int which, int userId, int displayId)236 void addOnLocalColorsChangedListener(in ILocalWallpaperColorConsumer callback, 237 in List<RectF> regions, int which, int userId, int displayId); 238 239 /** 240 * Register a callback to receive color updates from a display 241 */ registerWallpaperColorsCallback(IWallpaperManagerCallback cb, int userId, int displayId)242 void registerWallpaperColorsCallback(IWallpaperManagerCallback cb, int userId, int displayId); 243 244 /** 245 * Unregister a callback that was receiving color updates from a display 246 */ unregisterWallpaperColorsCallback(IWallpaperManagerCallback cb, int userId, int displayId)247 void unregisterWallpaperColorsCallback(IWallpaperManagerCallback cb, int userId, int displayId); 248 249 /** 250 * Called from SystemUI when it shows the AoD UI. 251 */ setInAmbientMode(boolean inAmbientMode, long animationDuration)252 oneway void setInAmbientMode(boolean inAmbientMode, long animationDuration); 253 254 /** 255 * Called from SystemUI when the device is waking up. 256 * 257 * @hide 258 */ notifyWakingUp(int x, int y, in Bundle extras)259 oneway void notifyWakingUp(int x, int y, in Bundle extras); 260 261 /** 262 * Called from SystemUI when the device is going to sleep. 263 * 264 * @hide 265 */ notifyGoingToSleep(int x, int y, in Bundle extras)266 void notifyGoingToSleep(int x, int y, in Bundle extras); 267 268 /** 269 * Sets the wallpaper dim amount between [0f, 1f] which would be blended with the system default 270 * dimming. 0f doesn't add any additional dimming and 1f makes the wallpaper fully black. 271 * 272 * @hide 273 */ 274 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.SET_WALLPAPER_DIM_AMOUNT)") setWallpaperDimAmount(float dimAmount)275 oneway void setWallpaperDimAmount(float dimAmount); 276 277 /** 278 * Gets the current additional dim amount set on the wallpaper. 0f means no application has 279 * added any dimming on top of the system default dim amount. 280 * 281 * @hide 282 */ 283 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.SET_WALLPAPER_DIM_AMOUNT)") getWallpaperDimAmount()284 float getWallpaperDimAmount(); 285 286 /** 287 * Whether the lock screen wallpaper is different from the system wallpaper. 288 * 289 * @hide 290 */ lockScreenWallpaperExists()291 boolean lockScreenWallpaperExists(); 292 293 /** 294 * Return true if there is a static wallpaper on the specified screen. With which=FLAG_LOCK, 295 * always return false if the lock screen doesn't run its own wallpaper engine. 296 * 297 * @hide 298 */ isStaticWallpaper(int which)299 boolean isStaticWallpaper(int which); 300 } 301