• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15import {AsyncCallback} from './basic';
16import image from './@ohos.multimedia.image';
17
18/**
19 * System wallpaper
20 * @syscap SystemCapability.MiscServices.Wallpaper
21 * @since 7
22 */
23declare namespace wallpaper {
24    /**
25     * RgbaColor definition
26     * @syscap SystemCapability.MiscServices.Wallpaper
27     * @since 7
28     * @deprecated since 9
29     */
30     interface RgbaColor {
31        /**
32         * The range is 0 to 255.
33         */
34        red: number;
35        /**
36         * The range is 0 to 255.
37         */
38        green: number;
39        /**
40         * The range is 0 to 255.
41         */
42        blue: number;
43        /**
44         * The range is 0 to 255.
45         */
46        alpha: number;
47    }
48
49    /**
50     * Indicates wallpaper type.
51     * @syscap SystemCapability.MiscServices.Wallpaper
52     * @since 7
53     */
54    enum WallpaperType {
55        /**
56         * Indicates the home screen wallpaper.
57         */
58        WALLPAPER_SYSTEM,
59        /**
60         * Indicates the lock screen wallpaper.
61         */
62        WALLPAPER_LOCKSCREEN
63    }
64
65    /**
66     * Obtains the wallpaper colors for the wallpaper of the specified type. Returns rgbaColor type of array callback function.
67     * @param wallpaperType Indicates the wallpaper type.
68     * @syscap SystemCapability.MiscServices.Wallpaper
69     * @since 7
70     * @deprecated since 9
71     */
72    function getColors(wallpaperType: WallpaperType, callback: AsyncCallback<Array<RgbaColor>>): void;
73
74    /**
75     * Obtains the wallpaper colors for the wallpaper of the specified type. Returns rgbaColor type of array callback function.
76     * @param wallpaperType Indicates the wallpaper type.
77     * @returns { Promise<Array<RgbaColor>> } the Promise<Array<RgbaColor>> returned by the function.
78     * @syscap SystemCapability.MiscServices.Wallpaper
79     * @since 7
80     * @deprecated since 9
81     */
82    function getColors(wallpaperType: WallpaperType): Promise<Array<RgbaColor>>;
83
84    /**
85     * Obtains the wallpaper colors for the wallpaper of the specified type. Returns rgbaColor type of array callback function.
86     * @param wallpaperType Indicates the wallpaper type.
87     * @returns { Array<RgbaColor> } the Array<RgbaColor> returned by the function.
88     * @throws {BusinessError} 401 - parameter error.
89     * @throws {BusinessError} 202 - permission verification failed, application which is not a system application uses system API.
90     * @syscap SystemCapability.MiscServices.Wallpaper
91     * @systemapi Hide this for inner system use.
92     * @since 9
93     */
94    function getColorsSync(wallpaperType: WallpaperType): Array<RgbaColor>;
95
96    /**
97     * Obtains the ID of the wallpaper of the specified type. Returns an integer greater than or equal to {@code 0} representing the wallpaper ID.
98     * if the specified type of wallpaper has been set; returns {@code -1} otherwise. The return value is an integer ranging from -1 to 2^31 - 1.
99     * @param wallpaperType Indicates the wallpaper type.
100     * @syscap SystemCapability.MiscServices.Wallpaper
101     * @since 7
102     * @deprecated since 9
103     */
104    function getId(wallpaperType: WallpaperType, callback: AsyncCallback<number>): void;
105
106    /**
107     * Obtains the ID of the wallpaper of the specified type. Returns an integer greater than or equal to {@code 0} representing the wallpaper ID.
108     * if the specified type of wallpaper has been set; returns {@code -1} otherwise. The return value is an integer ranging from -1 to 2^31 - 1.
109     * @param wallpaperType Indicates the wallpaper type.
110     * @returns { Promise<number> } the Promise<number> returned by the function.
111     * @syscap SystemCapability.MiscServices.Wallpaper
112     * @since 7
113     * @deprecated since 9
114     */
115    function getId(wallpaperType: WallpaperType): Promise<number>;
116
117    /**
118     * Obtains a file of the wallpaper of the specified type. Returns the file descriptor.
119     * @param wallpaperType Indicates the wallpaper type.
120     * @permission ohos.permission.GET_WALLPAPER
121     * @syscap SystemCapability.MiscServices.Wallpaper
122     * @since 8
123     * @deprecated since 9
124     */
125    function getFile(wallpaperType: WallpaperType, callback: AsyncCallback<number>): void;
126
127    /**
128     * Obtains a file of the wallpaper of the specified type. Returns the file descriptor.
129     * @param wallpaperType Indicates the wallpaper type.
130     * @permission ohos.permission.GET_WALLPAPER
131     * @returns { Promise<number> } the Promise<number> returned by the function.
132     * @syscap SystemCapability.MiscServices.Wallpaper
133     * @since 8
134     * @deprecated since 9
135     */
136    function getFile(wallpaperType: WallpaperType): Promise<number>;
137
138    /**
139     * Obtains the minimum height of the wallpaper. in pixels. returns 0 if no wallpaper has been set.
140     * @syscap SystemCapability.MiscServices.Wallpaper
141     * @since 7
142     * @deprecated since 9
143     */
144    function getMinHeight(callback: AsyncCallback<number>): void;
145
146    /**
147     * Obtains the minimum height of the wallpaper. in pixels. returns 0 if no wallpaper has been set.
148     * @returns { Promise<number> } the Promise<number> returned by the function.
149     * @syscap SystemCapability.MiscServices.Wallpaper
150     * @since 7
151     * @deprecated since 9
152     */
153    function getMinHeight(): Promise<number>;
154
155    /**
156     * Obtains the minimum height of the wallpaper. in pixels. returns 0 if no wallpaper has been set.
157     * @returns { number } the number returned by the function.
158     * @throws {BusinessError} 202 - permission verification failed, application which is not a system application uses system API.
159     * @syscap SystemCapability.MiscServices.Wallpaper
160     * @systemapi Hide this for inner system use.
161     * @since 9
162     */
163    function getMinHeightSync(): number;
164
165    /**
166     * Obtains the minimum width of the wallpaper. in pixels. returns 0 if no wallpaper has been set.
167     * @syscap SystemCapability.MiscServices.Wallpaper
168     * @since 7
169     * @deprecated since 9
170     */
171    function getMinWidth(callback: AsyncCallback<number>): void;
172
173    /**
174     * Obtains the minimum width of the wallpaper. in pixels. returns 0 if no wallpaper has been set.
175     * @returns { Promise<number> } the Promise<number> returned by the function.
176     * @syscap SystemCapability.MiscServices.Wallpaper
177     * @since 7
178     * @deprecated since 9
179     */
180    function getMinWidth(): Promise<number>;
181
182    /**
183     * Obtains the minimum width of the wallpaper. in pixels. returns 0 if no wallpaper has been set.
184     * @returns { number } the number returned by the function.
185     * @throws {BusinessError} 202 - permission verification failed, application which is not a system application uses system API.
186     * @syscap SystemCapability.MiscServices.Wallpaper
187     * @systemapi Hide this for inner system use.
188     * @since 9
189     */
190    function getMinWidthSync(): number;
191
192    /**
193     * Checks whether to allow the application to change the wallpaper for the current user.
194     * Returns true if the application is allowed to set a wallpaper for the current user. returns false otherwise.
195     * @syscap SystemCapability.MiscServices.Wallpaper
196     * @since 7
197     * @deprecated since 9
198     */
199    function isChangePermitted(callback: AsyncCallback<boolean>): void;
200
201    /**
202     * Checks whether to allow the application to change the wallpaper for the current user.
203     * Returns true if the application is allowed to set a wallpaper for the current user. returns false otherwise.
204     * @returns { Promise<boolean> } the Promise<boolean> returned by the function.
205     * @syscap SystemCapability.MiscServices.Wallpaper
206     * @since 7
207     * @deprecated since 9
208     */
209    function isChangePermitted(): Promise<boolean>;
210
211    /**
212     * Checks whether a user is allowed to set wallpapers.
213     * Returns true if a user is allowed to set wallpapers. returns false otherwise.
214     * @syscap SystemCapability.MiscServices.Wallpaper
215     * @since 7
216     * @deprecated since 9
217     */
218    function isOperationAllowed(callback: AsyncCallback<boolean>): void;
219
220    /**
221     * Checks whether a user is allowed to set wallpapers.
222     * Returns true if a user is allowed to set wallpapers. returns false otherwise.
223     * @returns { Promise<boolean> } the Promise<boolean> returned by the function.
224     * @syscap SystemCapability.MiscServices.Wallpaper
225     * @since 7
226     * @deprecated since 9
227     */
228    function isOperationAllowed(): Promise<boolean>;
229
230    /**
231     * Removes a wallpaper of the specified type and restores the default one.
232     * @param wallpaperType Indicates the wallpaper type.
233     * @permission ohos.permission.SET_WALLPAPER
234     * @syscap SystemCapability.MiscServices.Wallpaper
235     * @since 7
236     * @deprecated since 9
237     */
238    function reset(wallpaperType: WallpaperType, callback: AsyncCallback<void>): void;
239
240    /**
241     * Removes a wallpaper of the specified type and restores the default one.
242     * @param wallpaperType Indicates the wallpaper type.
243     * @permission ohos.permission.SET_WALLPAPER
244     * @syscap SystemCapability.MiscServices.Wallpaper
245     * @since 7
246     * @deprecated since 9
247     */
248    function reset(wallpaperType: WallpaperType): Promise<void>;
249
250    /**
251     * Removes a wallpaper of the specified type and restores the default one.
252     * @param wallpaperType Indicates the wallpaper type.
253     * @throws {BusinessError} 401 - parameter error.
254     * @throws {BusinessError} 201 - permission denied.
255     * @throws {BusinessError} 202 - permission verification failed, application which is not a system application uses system API.
256     * @permission ohos.permission.SET_WALLPAPER
257     * @syscap SystemCapability.MiscServices.Wallpaper
258     * @systemapi Hide this for inner system use.
259     * @since 9
260     */
261    function restore(wallpaperType: WallpaperType, callback: AsyncCallback<void>): void;
262
263    /**
264     * Removes a wallpaper of the specified type and restores the default one.
265     * @param wallpaperType Indicates the wallpaper type.
266     * @throws {BusinessError} 401 - parameter error.
267     * @throws {BusinessError} 201 - permission denied.
268     * @throws {BusinessError} 202 - permission verification failed, application which is not a system application uses system API.
269     * @permission ohos.permission.SET_WALLPAPER
270     * @syscap SystemCapability.MiscServices.Wallpaper
271     * @systemapi Hide this for inner system use.
272     * @since 9
273     */
274    function restore(wallpaperType: WallpaperType): Promise<void>;
275
276    /**
277     * Sets a wallpaper of the specified type based on the uri path from a JPEG or PNG file or the pixel map of a PNG file.
278     * @param source Indicates the uri path from a JPEG or PNG file or the pixel map of the PNG file.
279     * @param wallpaperType Indicates the wallpaper type.
280     * @permission ohos.permission.SET_WALLPAPER
281     * @syscap SystemCapability.MiscServices.Wallpaper
282     * @since 7
283     * @deprecated since 9
284     */
285    function setWallpaper(source: string | image.PixelMap, wallpaperType: WallpaperType, callback: AsyncCallback<void>): void;
286
287    /**
288     * Sets a wallpaper of the specified type based on the uri path from a JPEG or PNG file or the pixel map of a PNG file.
289     * @param source Indicates the uri path from a JPEG or PNG file or the pixel map of the PNG file.
290     * @param wallpaperType Indicates the wallpaper type.
291     * @permission ohos.permission.SET_WALLPAPER
292     * @syscap SystemCapability.MiscServices.Wallpaper
293     * @since 7
294     * @deprecated since 9
295     */
296    function setWallpaper(source: string | image.PixelMap, wallpaperType: WallpaperType): Promise<void>;
297
298    /**
299     * Sets a wallpaper of the specified type based on the uri path from a JPEG or PNG file or the pixel map of a PNG file.
300     * @param source Indicates the uri path from a JPEG or PNG file or the pixel map of the PNG file.
301     * @param wallpaperType Indicates the wallpaper type.
302     * @throws {BusinessError} 401 - parameter error.
303     * @throws {BusinessError} 201 - permission denied.
304     * @throws {BusinessError} 202 - permission verification failed, application which is not a system application uses system API.
305     * @permission ohos.permission.SET_WALLPAPER
306     * @syscap SystemCapability.MiscServices.Wallpaper
307     * @systemapi Hide this for inner system use.
308     * @since 9
309     */
310    function setImage(source: string | image.PixelMap, wallpaperType: WallpaperType, callback: AsyncCallback<void>): void;
311
312    /**
313     * Sets a wallpaper of the specified type based on the uri path from a JPEG or PNG file or the pixel map of a PNG file.
314     * @param source Indicates the uri path from a JPEG or PNG file or the pixel map of the PNG file.
315     * @param wallpaperType Indicates the wallpaper type.
316     * @throws {BusinessError} 401 - parameter error.
317     * @throws {BusinessError} 201 - permission denied.
318     * @throws {BusinessError} 202 - permission verification failed, application which is not a system application uses system API.
319     * @permission ohos.permission.SET_WALLPAPER
320     * @syscap SystemCapability.MiscServices.Wallpaper
321     * @systemapi Hide this for inner system use.
322     * @since 9
323     */
324    function setImage(source: string | image.PixelMap, wallpaperType: WallpaperType): Promise<void>;
325
326    /**
327     * Obtains the default pixel map of a wallpaper of the specified type. Returns the default pixel map.
328     * @param wallpaperType Indicates the wallpaper type.
329     * @permission ohos.permission.GET_WALLPAPER
330     * @syscap SystemCapability.MiscServices.Wallpaper
331     * @systemapi Hide this for inner system use.
332     * @since 7
333     * @deprecated since 9
334     */
335    function getPixelMap(wallpaperType: WallpaperType, callback: AsyncCallback<image.PixelMap>): void;
336
337    /**
338     * Obtains the default pixel map of a wallpaper of the specified type. Returns the default pixel map.
339     * @param wallpaperType Indicates the wallpaper type.
340     * @returns { Promise<image.PixelMap> } the Promise<image.PixelMap> returned by the function.
341     * @permission ohos.permission.GET_WALLPAPER
342     * @syscap SystemCapability.MiscServices.Wallpaper
343     * @systemapi Hide this for inner system use.
344     * @since 7
345     * @deprecated since 9
346     */
347    function getPixelMap(wallpaperType: WallpaperType): Promise<image.PixelMap>;
348
349    /**
350     * Obtains the default pixel map of a wallpaper of the specified type. Returns the default pixel map.
351     * @param wallpaperType Indicates the wallpaper type.
352     * @throws {BusinessError} 401 - parameter error.
353     * @throws {BusinessError} 201 - permission denied.
354     * @permission ohos.permission.GET_WALLPAPER
355     * @syscap SystemCapability.MiscServices.Wallpaper
356     * @systemapi Hide this for inner system use.
357     * @since 9
358     */
359    function getImage(wallpaperType: WallpaperType, callback: AsyncCallback<image.PixelMap>): void;
360
361    /**
362     * Obtains the default pixel map of a wallpaper of the specified type. Returns the default pixel map.
363     * @param wallpaperType Indicates the wallpaper type.
364     * @returns { Promise<image.PixelMap> } the Promise<image.PixelMap> returned by the function.
365     * @throws {BusinessError} 401 - parameter error.
366     * @throws {BusinessError} 201 - permission denied.
367     * @permission ohos.permission.GET_WALLPAPER
368     * @syscap SystemCapability.MiscServices.Wallpaper
369     * @systemapi Hide this for inner system use.
370     * @since 9
371     */
372    function getImage(wallpaperType: WallpaperType): Promise<image.PixelMap>;
373
374    /**
375     * Registers a listener for wallpaper color changes to receive notifications about the changes.
376     * @param type The incoming colorChange table open receiver pick a color change wallpaper wallpaper color changes
377     * @param callback Provides dominant colors of the wallpaper.
378     * @syscap SystemCapability.MiscServices.Wallpaper
379     * @since 7
380     * @deprecated since 9
381     */
382    function on(type: 'colorChange', callback: (colors: Array<RgbaColor>, wallpaperType: WallpaperType) => void): void;
383
384    /**
385     * Unregisters a listener for wallpaper color changes.
386     * @param type Incoming 'colorChange' table delete receiver to pick up a color change wallpaper wallpaper color changes
387     * @param callback Provides dominant colors of the wallpaper.
388     * @syscap SystemCapability.MiscServices.Wallpaper
389     * @since 7
390     * @deprecated since 9
391     */
392    function off(type: 'colorChange', callback?: (colors: Array<RgbaColor>, wallpaperType: WallpaperType) => void): void;
393}
394
395export default wallpaper;
396