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