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