1e41f4b71Sopenharmony_ci# @ohos.wallpaper (Wallpaper) (System API)
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ciThe **wallpaper** module provides APIs for switching between wallpapers. Since API version 9, the APIs of this module function as system APIs, and only system applications are allowed to switch between wallpapers. Applications that use the wallpaper, for example, the home screen, need to subscribe to wallpaper changes and update the wallpaper accordingly.
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci> **NOTE**
6e41f4b71Sopenharmony_ci> 
7e41f4b71Sopenharmony_ci> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8e41f4b71Sopenharmony_ci> This topic describes only system APIs provided by the module. For details about its public APIs, see [@ohos.wallpaper (Wallpaper)](js-apis-wallpaper.md).
9e41f4b71Sopenharmony_ci
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ci## Modules to Import
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ci
14e41f4b71Sopenharmony_ci```ts
15e41f4b71Sopenharmony_ciimport { wallpaper } from '@kit.BasicServicesKit';
16e41f4b71Sopenharmony_ci```
17e41f4b71Sopenharmony_ci## WallpaperResourceType<sup>10+</sup>
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ciEnumerates the types of wallpaper resources.
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.Wallpaper
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ci**System API**: This is a system API.
24e41f4b71Sopenharmony_ci
25e41f4b71Sopenharmony_ci| Name| Value|Description|
26e41f4b71Sopenharmony_ci| -------- | -------- |-------- |
27e41f4b71Sopenharmony_ci| DEFAULT | 0 |Default type (image resource).|
28e41f4b71Sopenharmony_ci| PICTURE | 1 |Image resource.|
29e41f4b71Sopenharmony_ci| VIDEO | 2 |Video resource.|
30e41f4b71Sopenharmony_ci| PACKAGE | 3 |Package resource.|
31e41f4b71Sopenharmony_ci
32e41f4b71Sopenharmony_ci## wallpaper.setVideo<sup>10+</sup>
33e41f4b71Sopenharmony_ci
34e41f4b71Sopenharmony_cisetVideo(source: string, wallpaperType: WallpaperType, callback: AsyncCallback&lt;void&gt;): void
35e41f4b71Sopenharmony_ci
36e41f4b71Sopenharmony_ciSets a video resource as the home screen wallpaper or lock screen wallpaper. This API uses an asynchronous callback to return the result.
37e41f4b71Sopenharmony_ci
38e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.SET_WALLPAPER
39e41f4b71Sopenharmony_ci
40e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.Wallpaper
41e41f4b71Sopenharmony_ci
42e41f4b71Sopenharmony_ci**System API**: This is a system API.
43e41f4b71Sopenharmony_ci
44e41f4b71Sopenharmony_ci**Parameters**
45e41f4b71Sopenharmony_ci
46e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
47e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
48e41f4b71Sopenharmony_ci| source | string | Yes| URI of an MP4 file.|
49e41f4b71Sopenharmony_ci| wallpaperType | [WallpaperType](js-apis-wallpaper.md#wallpapertype7) | Yes| Wallpaper type.|
50e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result. If the wallpaper is set, **err** is **undefined**. Otherwise, **err** is an error object.|
51e41f4b71Sopenharmony_ci
52e41f4b71Sopenharmony_ci**Error codes**
53e41f4b71Sopenharmony_ci
54e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
55e41f4b71Sopenharmony_ci
56e41f4b71Sopenharmony_ci| **ID**| **Error Message**                               |
57e41f4b71Sopenharmony_ci| ------------ | ------------------------------------------- |
58e41f4b71Sopenharmony_ci| 201          | permission denied.                                                                              |
59e41f4b71Sopenharmony_ci| 202          | permission verification failed, application which is not a system application uses system API.  |
60e41f4b71Sopenharmony_ci| 401          | 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.  |
61e41f4b71Sopenharmony_ci
62e41f4b71Sopenharmony_ci**Example**
63e41f4b71Sopenharmony_ci
64e41f4b71Sopenharmony_ci```ts
65e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
66e41f4b71Sopenharmony_ci
67e41f4b71Sopenharmony_cilet wallpaperPath = "/data/storage/el2/base/haps/entry/files/test.mp4";
68e41f4b71Sopenharmony_citry {
69e41f4b71Sopenharmony_ci    wallpaper.setVideo(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error: BusinessError) => {
70e41f4b71Sopenharmony_ci        if (error) {
71e41f4b71Sopenharmony_ci            console.error(`failed to setVideo because: ${JSON.stringify(error)}`);
72e41f4b71Sopenharmony_ci            return;
73e41f4b71Sopenharmony_ci        }
74e41f4b71Sopenharmony_ci        console.log(`success to setVideo.`);
75e41f4b71Sopenharmony_ci    });
76e41f4b71Sopenharmony_ci} catch (error) {
77e41f4b71Sopenharmony_ci    console.error(`failed to setVideo because: ${JSON.stringify(error)}`);
78e41f4b71Sopenharmony_ci}
79e41f4b71Sopenharmony_ci
80e41f4b71Sopenharmony_ci```
81e41f4b71Sopenharmony_ci
82e41f4b71Sopenharmony_ci## wallpaper.setVideo<sup>10+</sup>
83e41f4b71Sopenharmony_ci
84e41f4b71Sopenharmony_cisetVideo(source: string, wallpaperType: WallpaperType): Promise&lt;void&gt;
85e41f4b71Sopenharmony_ci
86e41f4b71Sopenharmony_ciSets a video resource as the home screen wallpaper or lock screen wallpaper. This API uses a promise to return the result.
87e41f4b71Sopenharmony_ci
88e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.SET_WALLPAPER
89e41f4b71Sopenharmony_ci
90e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.Wallpaper
91e41f4b71Sopenharmony_ci
92e41f4b71Sopenharmony_ci**System API**: This is a system API.
93e41f4b71Sopenharmony_ci
94e41f4b71Sopenharmony_ci**Parameters**
95e41f4b71Sopenharmony_ci
96e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
97e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
98e41f4b71Sopenharmony_ci| source | string | Yes| URI of an MP4 file.|
99e41f4b71Sopenharmony_ci| wallpaperType | [WallpaperType](js-apis-wallpaper.md#wallpapertype7) | Yes| Wallpaper type.|
100e41f4b71Sopenharmony_ci
101e41f4b71Sopenharmony_ci**Error codes**
102e41f4b71Sopenharmony_ci
103e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
104e41f4b71Sopenharmony_ci
105e41f4b71Sopenharmony_ci| **ID**| **Error Message**                               |
106e41f4b71Sopenharmony_ci| ------------ | ------------------------------------------- |
107e41f4b71Sopenharmony_ci| 201          | permission denied.                                                                              |
108e41f4b71Sopenharmony_ci| 202          | permission verification failed, application which is not a system application uses system API.  |
109e41f4b71Sopenharmony_ci| 401          | 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.  |
110e41f4b71Sopenharmony_ci
111e41f4b71Sopenharmony_ci**Return value**
112e41f4b71Sopenharmony_ci
113e41f4b71Sopenharmony_ci| Type| Description|
114e41f4b71Sopenharmony_ci| -------- | -------- |
115e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise that returns no value.|
116e41f4b71Sopenharmony_ci
117e41f4b71Sopenharmony_ci**Example**
118e41f4b71Sopenharmony_ci
119e41f4b71Sopenharmony_ci```ts
120e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
121e41f4b71Sopenharmony_ci
122e41f4b71Sopenharmony_cilet wallpaperPath = "/data/storage/el2/base/haps/entry/files/test.mp4";
123e41f4b71Sopenharmony_citry {
124e41f4b71Sopenharmony_ci    wallpaper.setVideo(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then(() => {
125e41f4b71Sopenharmony_ci        console.log(`success to setVideo.`);
126e41f4b71Sopenharmony_ci    }).catch((error: BusinessError) => {
127e41f4b71Sopenharmony_ci        console.error(`failed to setVideo because: ${JSON.stringify(error)}`);
128e41f4b71Sopenharmony_ci    });
129e41f4b71Sopenharmony_ci} catch (error) {
130e41f4b71Sopenharmony_ci    console.error(`failed to setVideo because: ${JSON.stringify(error)}`);
131e41f4b71Sopenharmony_ci}
132e41f4b71Sopenharmony_ci```
133e41f4b71Sopenharmony_ci
134e41f4b71Sopenharmony_ci## wallpaper.setCustomWallpaper<sup>10+</sup>
135e41f4b71Sopenharmony_ci
136e41f4b71Sopenharmony_cisetCustomWallpaper(source: string, wallpaperType: WallpaperType, callback: AsyncCallback&lt;void&gt;): void
137e41f4b71Sopenharmony_ci
138e41f4b71Sopenharmony_ciSets a specific ZIP file as the wallpaper. This API works only when **com.ohos.sceneboard** is set. Applications with the **ohos.permission.GET_WALLPAPER** permission have access to the **/data/wallpaper/** directory. This API uses an asynchronous callback to return the result.
139e41f4b71Sopenharmony_ci
140e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.SET_WALLPAPER
141e41f4b71Sopenharmony_ci
142e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.Wallpaper
143e41f4b71Sopenharmony_ci
144e41f4b71Sopenharmony_ci**System API**: This is a system API.
145e41f4b71Sopenharmony_ci
146e41f4b71Sopenharmony_ci**Parameters**
147e41f4b71Sopenharmony_ci
148e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
149e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
150e41f4b71Sopenharmony_ci| source | string | Yes| ZIP file to set as the wallpaper.|
151e41f4b71Sopenharmony_ci| wallpaperType | [WallpaperType](js-apis-wallpaper.md#wallpapertype7) | Yes| Wallpaper type.|
152e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result. If the wallpaper is set, **err** is **undefined**. Otherwise, **err** is an error object.|
153e41f4b71Sopenharmony_ci
154e41f4b71Sopenharmony_ci**Error codes**
155e41f4b71Sopenharmony_ci
156e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
157e41f4b71Sopenharmony_ci
158e41f4b71Sopenharmony_ci| **ID**| **Error Message**                               |
159e41f4b71Sopenharmony_ci| ------------ | ------------------------------------------- |
160e41f4b71Sopenharmony_ci| 201          | permission denied.                                                                              |
161e41f4b71Sopenharmony_ci| 202          | permission verification failed, application which is not a system application uses system API.  |
162e41f4b71Sopenharmony_ci| 401          | 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.  |
163e41f4b71Sopenharmony_ci
164e41f4b71Sopenharmony_ci**Example**
165e41f4b71Sopenharmony_ci
166e41f4b71Sopenharmony_ci```ts
167e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
168e41f4b71Sopenharmony_ci
169e41f4b71Sopenharmony_cilet wallpaperPath = "/data/storage/el2/base/haps/entry/files/test.zip";
170e41f4b71Sopenharmony_citry {
171e41f4b71Sopenharmony_ci    wallpaper.setCustomWallpaper(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error: BusinessError) => {
172e41f4b71Sopenharmony_ci        if (error) {
173e41f4b71Sopenharmony_ci            console.error(`failed to setCustomWallpaper because: ${JSON.stringify(error)}`);
174e41f4b71Sopenharmony_ci            return;
175e41f4b71Sopenharmony_ci        }
176e41f4b71Sopenharmony_ci        console.log(`success to setCustomWallpaper.`);
177e41f4b71Sopenharmony_ci    });
178e41f4b71Sopenharmony_ci} catch (error) {
179e41f4b71Sopenharmony_ci    console.error(`failed to setCustomWallpaper because: ${JSON.stringify(error)}`);
180e41f4b71Sopenharmony_ci}
181e41f4b71Sopenharmony_ci
182e41f4b71Sopenharmony_ci```
183e41f4b71Sopenharmony_ci
184e41f4b71Sopenharmony_ci## wallpaper.setCustomWallpaper<sup>10+</sup>
185e41f4b71Sopenharmony_ci
186e41f4b71Sopenharmony_cisetCustomWallpaper(source: string, wallpaperType: WallpaperType): Promise&lt;void&gt;
187e41f4b71Sopenharmony_ci
188e41f4b71Sopenharmony_ciSets a specific ZIP file as the wallpaper. This API works only when **com.ohos.sceneboard** is set. Applications with the **ohos.permission.GET_WALLPAPER** permission have access to the **/data/wallpaper/** directory. This API uses a promise to return the result.
189e41f4b71Sopenharmony_ci
190e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.SET_WALLPAPER
191e41f4b71Sopenharmony_ci
192e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.Wallpaper
193e41f4b71Sopenharmony_ci
194e41f4b71Sopenharmony_ci**System API**: This is a system API.
195e41f4b71Sopenharmony_ci
196e41f4b71Sopenharmony_ci**Parameters**
197e41f4b71Sopenharmony_ci
198e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
199e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
200e41f4b71Sopenharmony_ci| source | string | Yes| ZIP file to set as the wallpaper.|
201e41f4b71Sopenharmony_ci| wallpaperType | [WallpaperType](js-apis-wallpaper.md#wallpapertype7) | Yes| Wallpaper type.|
202e41f4b71Sopenharmony_ci
203e41f4b71Sopenharmony_ci**Return value**
204e41f4b71Sopenharmony_ci
205e41f4b71Sopenharmony_ci| Type| Description|
206e41f4b71Sopenharmony_ci| -------- | -------- |
207e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise that returns no value.|
208e41f4b71Sopenharmony_ci
209e41f4b71Sopenharmony_ci**Error codes**
210e41f4b71Sopenharmony_ci
211e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
212e41f4b71Sopenharmony_ci
213e41f4b71Sopenharmony_ci| **ID**| **Error Message**                               |
214e41f4b71Sopenharmony_ci| ------------ | ------------------------------------------- |
215e41f4b71Sopenharmony_ci| 201          | permission denied.                                                                              |
216e41f4b71Sopenharmony_ci| 202          | permission verification failed, application which is not a system application uses system API.  |
217e41f4b71Sopenharmony_ci| 401          | 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.  |
218e41f4b71Sopenharmony_ci
219e41f4b71Sopenharmony_ci**Example**
220e41f4b71Sopenharmony_ci
221e41f4b71Sopenharmony_ci```ts
222e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
223e41f4b71Sopenharmony_ci
224e41f4b71Sopenharmony_cilet wallpaperPath = "/data/storage/el2/base/haps/entry/files/test.zip";
225e41f4b71Sopenharmony_citry {
226e41f4b71Sopenharmony_ci    wallpaper.setCustomWallpaper(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then(() => {
227e41f4b71Sopenharmony_ci        console.log(`success to setCustomWallpaper.`);
228e41f4b71Sopenharmony_ci    }).catch((error: BusinessError) => {
229e41f4b71Sopenharmony_ci        console.error(`failed to setCustomWallpaper because: ${JSON.stringify(error)}`);
230e41f4b71Sopenharmony_ci    });
231e41f4b71Sopenharmony_ci} catch (error) {
232e41f4b71Sopenharmony_ci    console.error(`failed to setCustomWallpaper because: ${JSON.stringify(error)}`);
233e41f4b71Sopenharmony_ci}
234e41f4b71Sopenharmony_ci```
235e41f4b71Sopenharmony_ci
236e41f4b71Sopenharmony_ci## wallpaper.on('wallpaperChange')<sup>10+</sup>
237e41f4b71Sopenharmony_ci
238e41f4b71Sopenharmony_cion(type: 'wallpaperChange', callback: (wallpaperType: WallpaperType, resourceType: WallpaperResourceType, uri?: string) =&gt; void): void
239e41f4b71Sopenharmony_ci
240e41f4b71Sopenharmony_ciSubscribes to wallpaper change events. Multi-thread concurrent calls are not supported.
241e41f4b71Sopenharmony_ci
242e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.Wallpaper
243e41f4b71Sopenharmony_ci
244e41f4b71Sopenharmony_ci**System API**: This is a system API.
245e41f4b71Sopenharmony_ci
246e41f4b71Sopenharmony_ci**Parameters**
247e41f4b71Sopenharmony_ci
248e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
249e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
250e41f4b71Sopenharmony_ci| type | string | Yes| Event type. The value is fixed at **'wallpaperChange'**.|
251e41f4b71Sopenharmony_ci| callback | function | Yes| Callback used to return the wallpaper type and wallpaper resource type.<br>- **wallpaperType**: wallpaper type.<br>- **resourceType**: wallpaper resource type.<br>- **uri**: URI of the wallpaper resource.|
252e41f4b71Sopenharmony_ci
253e41f4b71Sopenharmony_ci**Error codes**
254e41f4b71Sopenharmony_ci
255e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
256e41f4b71Sopenharmony_ci
257e41f4b71Sopenharmony_ci| **ID**| **Error Message**                               |
258e41f4b71Sopenharmony_ci| ------------ | ------------------------------------------- |
259e41f4b71Sopenharmony_ci| 202          | permission verification failed, application which is not a system application uses system API.  |
260e41f4b71Sopenharmony_ci| 401          | 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.  |
261e41f4b71Sopenharmony_ci
262e41f4b71Sopenharmony_ci**Example**
263e41f4b71Sopenharmony_ci
264e41f4b71Sopenharmony_ci```ts
265e41f4b71Sopenharmony_citry {
266e41f4b71Sopenharmony_ci    let listener = (wallpaperType: wallpaper.WallpaperType, resourceType: wallpaper.WallpaperResourceType): void => {
267e41f4b71Sopenharmony_ci        console.log(`wallpaper color changed.`);
268e41f4b71Sopenharmony_ci    };
269e41f4b71Sopenharmony_ci    wallpaper.on('wallpaperChange', listener);
270e41f4b71Sopenharmony_ci} catch (error) {
271e41f4b71Sopenharmony_ci    console.error(`failed to on because: ${JSON.stringify(error)}`);
272e41f4b71Sopenharmony_ci}
273e41f4b71Sopenharmony_ci```
274e41f4b71Sopenharmony_ci
275e41f4b71Sopenharmony_ci## wallpaper.off('wallpaperChange')<sup>10+</sup>
276e41f4b71Sopenharmony_ci
277e41f4b71Sopenharmony_cioff(type: 'wallpaperChange', callback?: (wallpaperType: WallpaperType, resourceType: WallpaperResourceType, uri?: string) =&gt; void): void
278e41f4b71Sopenharmony_ci
279e41f4b71Sopenharmony_ciUnsubscribes from wallpaper change events. Multi-thread concurrent calls are not supported.
280e41f4b71Sopenharmony_ci
281e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.Wallpaper
282e41f4b71Sopenharmony_ci
283e41f4b71Sopenharmony_ci**System API**: This is a system API.
284e41f4b71Sopenharmony_ci
285e41f4b71Sopenharmony_ci**Parameters**
286e41f4b71Sopenharmony_ci
287e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
288e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
289e41f4b71Sopenharmony_ci| type | string | Yes| Event type. The value is fixed at **'wallpaperChange'**.|
290e41f4b71Sopenharmony_ci| callback | function | No|   Callback used for unsubscription. If this parameter is not set, this API unsubscribes from all callbacks of the specified event type.<br>- **wallpaperType**: wallpaper type.<br>- **resourceType**: wallpaper resource type.<br>- **uri**: URI of the wallpaper resource.|
291e41f4b71Sopenharmony_ci
292e41f4b71Sopenharmony_ci**Error codes**
293e41f4b71Sopenharmony_ci
294e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
295e41f4b71Sopenharmony_ci
296e41f4b71Sopenharmony_ci| **ID**| **Error Message**                               |
297e41f4b71Sopenharmony_ci| ------------ | ------------------------------------------- |
298e41f4b71Sopenharmony_ci| 202          | permission verification failed, application which is not a system application uses system API.  |
299e41f4b71Sopenharmony_ci| 401          | 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.  |
300e41f4b71Sopenharmony_ci
301e41f4b71Sopenharmony_ci**Example**
302e41f4b71Sopenharmony_ci
303e41f4b71Sopenharmony_ci```ts
304e41f4b71Sopenharmony_cilet listener = (wallpaperType: wallpaper.WallpaperType, resourceType: wallpaper.WallpaperResourceType): void => {
305e41f4b71Sopenharmony_ci    console.log(`wallpaper color changed.`);
306e41f4b71Sopenharmony_ci};
307e41f4b71Sopenharmony_citry {
308e41f4b71Sopenharmony_ci    wallpaper.on('wallpaperChange', listener);
309e41f4b71Sopenharmony_ci} catch (error) {
310e41f4b71Sopenharmony_ci    console.error(`failed to on because: ${JSON.stringify(error)}`);
311e41f4b71Sopenharmony_ci}
312e41f4b71Sopenharmony_ci
313e41f4b71Sopenharmony_citry {
314e41f4b71Sopenharmony_ci    // Unsubscribe from the listener.
315e41f4b71Sopenharmony_ci    wallpaper.off('wallpaperChange', listener);
316e41f4b71Sopenharmony_ci} catch (error) {
317e41f4b71Sopenharmony_ci    console.error(`failed to off because: ${JSON.stringify(error)}`);
318e41f4b71Sopenharmony_ci}
319e41f4b71Sopenharmony_ci
320e41f4b71Sopenharmony_citry {
321e41f4b71Sopenharmony_ci    // Unsubscribe from all callbacks of the 'wallpaperChange' event type.
322e41f4b71Sopenharmony_ci    wallpaper.off('wallpaperChange');
323e41f4b71Sopenharmony_ci} catch (error) {
324e41f4b71Sopenharmony_ci    console.error(`failed to off because: ${JSON.stringify(error)}`);
325e41f4b71Sopenharmony_ci}
326e41f4b71Sopenharmony_ci```
327e41f4b71Sopenharmony_ci
328e41f4b71Sopenharmony_ci## wallpaper.getColorsSync<sup>9+</sup>
329e41f4b71Sopenharmony_ci
330e41f4b71Sopenharmony_cigetColorsSync(wallpaperType: WallpaperType): Array&lt;RgbaColor&gt;
331e41f4b71Sopenharmony_ci
332e41f4b71Sopenharmony_ciObtains the main color information of the wallpaper of the specified type.
333e41f4b71Sopenharmony_ci
334e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.Wallpaper
335e41f4b71Sopenharmony_ci
336e41f4b71Sopenharmony_ci**System API**: This is a system API.
337e41f4b71Sopenharmony_ci
338e41f4b71Sopenharmony_ci**Parameters**
339e41f4b71Sopenharmony_ci
340e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
341e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
342e41f4b71Sopenharmony_ci| wallpaperType | [WallpaperType](js-apis-wallpaper.md#wallpapertype7) | Yes| Wallpaper type.|
343e41f4b71Sopenharmony_ci
344e41f4b71Sopenharmony_ci**Return value**
345e41f4b71Sopenharmony_ci
346e41f4b71Sopenharmony_ci| Type| Description|
347e41f4b71Sopenharmony_ci| -------- | -------- |
348e41f4b71Sopenharmony_ci| Array&lt;[RgbaColor](js-apis-wallpaper.md#rgbacolordeprecated)&gt; | Promise used to return the main color information of the wallpaper.|
349e41f4b71Sopenharmony_ci
350e41f4b71Sopenharmony_ci**Error codes**
351e41f4b71Sopenharmony_ci
352e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
353e41f4b71Sopenharmony_ci
354e41f4b71Sopenharmony_ci| **ID**| **Error Message**                               |
355e41f4b71Sopenharmony_ci| ------------ | ------------------------------------------- |
356e41f4b71Sopenharmony_ci| 202          | permission verification failed, application which is not a system application uses system API.  |
357e41f4b71Sopenharmony_ci| 401          | 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.  |
358e41f4b71Sopenharmony_ci
359e41f4b71Sopenharmony_ci**Example**
360e41f4b71Sopenharmony_ci
361e41f4b71Sopenharmony_ci```ts
362e41f4b71Sopenharmony_citry {
363e41f4b71Sopenharmony_ci    let colors = wallpaper.getColorsSync(wallpaper.WallpaperType.WALLPAPER_SYSTEM);
364e41f4b71Sopenharmony_ci    console.log(`success to getColorsSync: ${JSON.stringify(colors)}`);
365e41f4b71Sopenharmony_ci} catch (error) {
366e41f4b71Sopenharmony_ci    console.error(`failed to getColorsSync because: ${JSON.stringify(error)}`);
367e41f4b71Sopenharmony_ci}
368e41f4b71Sopenharmony_ci```
369e41f4b71Sopenharmony_ci
370e41f4b71Sopenharmony_ci## wallpaper.getMinHeightSync<sup>9+</sup>
371e41f4b71Sopenharmony_ci
372e41f4b71Sopenharmony_cigetMinHeightSync(): number
373e41f4b71Sopenharmony_ci
374e41f4b71Sopenharmony_ciObtains the minimum height of this wallpaper.
375e41f4b71Sopenharmony_ci
376e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.Wallpaper
377e41f4b71Sopenharmony_ci
378e41f4b71Sopenharmony_ci**System API**: This is a system API.
379e41f4b71Sopenharmony_ci
380e41f4b71Sopenharmony_ci**Return value**
381e41f4b71Sopenharmony_ci
382e41f4b71Sopenharmony_ci| Type| Description|
383e41f4b71Sopenharmony_ci| -------- | -------- |
384e41f4b71Sopenharmony_ci| number | Promise used to return the minimum wallpaper height, in pixels. If the return value is **0**, no wallpaper is set. In this case, the default height should be used instead.|
385e41f4b71Sopenharmony_ci
386e41f4b71Sopenharmony_ci**Error codes**
387e41f4b71Sopenharmony_ci
388e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
389e41f4b71Sopenharmony_ci
390e41f4b71Sopenharmony_ci| **ID**| **Error Message**                               |
391e41f4b71Sopenharmony_ci| ------------ | ------------------------------------------- |
392e41f4b71Sopenharmony_ci| 202          | permission verification failed, application which is not a system application uses system API.  |
393e41f4b71Sopenharmony_ci
394e41f4b71Sopenharmony_ci**Example**
395e41f4b71Sopenharmony_ci
396e41f4b71Sopenharmony_ci```ts
397e41f4b71Sopenharmony_cilet minHeight = wallpaper.getMinHeightSync();
398e41f4b71Sopenharmony_ci```
399e41f4b71Sopenharmony_ci
400e41f4b71Sopenharmony_ci## wallpaper.getMinWidthSync<sup>9+</sup>
401e41f4b71Sopenharmony_ci
402e41f4b71Sopenharmony_cigetMinWidthSync(): number
403e41f4b71Sopenharmony_ci
404e41f4b71Sopenharmony_ciObtains the minimum width of this wallpaper.
405e41f4b71Sopenharmony_ci
406e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.Wallpaper
407e41f4b71Sopenharmony_ci
408e41f4b71Sopenharmony_ci**System API**: This is a system API.
409e41f4b71Sopenharmony_ci
410e41f4b71Sopenharmony_ci**Return value**
411e41f4b71Sopenharmony_ci
412e41f4b71Sopenharmony_ci| Type| Description|
413e41f4b71Sopenharmony_ci| -------- | -------- |
414e41f4b71Sopenharmony_ci| number | Promise used to return the minimum wallpaper width, in pixels. If the return value is **0**, no wallpaper is set. In this case, the default width should be used instead.|
415e41f4b71Sopenharmony_ci
416e41f4b71Sopenharmony_ci**Error codes**
417e41f4b71Sopenharmony_ci
418e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
419e41f4b71Sopenharmony_ci
420e41f4b71Sopenharmony_ci| **ID**| **Error Message**                               |
421e41f4b71Sopenharmony_ci| ------------ | ------------------------------------------- |
422e41f4b71Sopenharmony_ci| 202          | permission verification failed, application which is not a system application uses system API.  |
423e41f4b71Sopenharmony_ci
424e41f4b71Sopenharmony_ci**Example**
425e41f4b71Sopenharmony_ci
426e41f4b71Sopenharmony_ci```ts
427e41f4b71Sopenharmony_cilet minWidth = wallpaper.getMinWidthSync();
428e41f4b71Sopenharmony_ci```
429e41f4b71Sopenharmony_ci
430e41f4b71Sopenharmony_ci## wallpaper.restore<sup>9+</sup>
431e41f4b71Sopenharmony_ci
432e41f4b71Sopenharmony_cirestore(wallpaperType: WallpaperType, callback: AsyncCallback&lt;void&gt;): void
433e41f4b71Sopenharmony_ci
434e41f4b71Sopenharmony_ciResets the wallpaper of the specified type to the default wallpaper. This API uses an asynchronous callback to return the result.
435e41f4b71Sopenharmony_ci
436e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.SET_WALLPAPER
437e41f4b71Sopenharmony_ci
438e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.Wallpaper
439e41f4b71Sopenharmony_ci
440e41f4b71Sopenharmony_ci**System API**: This is a system API.
441e41f4b71Sopenharmony_ci
442e41f4b71Sopenharmony_ci**Parameters**
443e41f4b71Sopenharmony_ci
444e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
445e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
446e41f4b71Sopenharmony_ci| wallpaperType | [WallpaperType](js-apis-wallpaper.md#wallpapertype7) | Yes| Wallpaper type.|
447e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result. If the wallpaper is reset, **err** is **undefined**. Otherwise, **err** is an error object.|
448e41f4b71Sopenharmony_ci
449e41f4b71Sopenharmony_ci**Error codes**
450e41f4b71Sopenharmony_ci
451e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
452e41f4b71Sopenharmony_ci
453e41f4b71Sopenharmony_ci| **ID**| **Error Message**                               |
454e41f4b71Sopenharmony_ci| ------------ | ------------------------------------------- |
455e41f4b71Sopenharmony_ci| 201          | permission denied.                                                                              |
456e41f4b71Sopenharmony_ci| 202          | permission verification failed, application which is not a system application uses system API.  |
457e41f4b71Sopenharmony_ci| 401          | 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.  |
458e41f4b71Sopenharmony_ci
459e41f4b71Sopenharmony_ci**Example**
460e41f4b71Sopenharmony_ci
461e41f4b71Sopenharmony_ci```ts
462e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
463e41f4b71Sopenharmony_ci
464e41f4b71Sopenharmony_ciwallpaper.restore(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error: BusinessError) => {
465e41f4b71Sopenharmony_ci    if (error) {
466e41f4b71Sopenharmony_ci        console.error(`failed to restore because: ${JSON.stringify(error)}`);
467e41f4b71Sopenharmony_ci        return;
468e41f4b71Sopenharmony_ci    }
469e41f4b71Sopenharmony_ci    console.log(`success to restore.`);
470e41f4b71Sopenharmony_ci});
471e41f4b71Sopenharmony_ci```
472e41f4b71Sopenharmony_ci
473e41f4b71Sopenharmony_ci## wallpaper.restore<sup>9+</sup>
474e41f4b71Sopenharmony_ci
475e41f4b71Sopenharmony_cirestore(wallpaperType: WallpaperType): Promise&lt;void&gt;
476e41f4b71Sopenharmony_ci
477e41f4b71Sopenharmony_ciResets the wallpaper of the specified type to the default wallpaper. This API uses a promise to return the result.
478e41f4b71Sopenharmony_ci
479e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.SET_WALLPAPER
480e41f4b71Sopenharmony_ci
481e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.Wallpaper
482e41f4b71Sopenharmony_ci
483e41f4b71Sopenharmony_ci**System API**: This is a system API.
484e41f4b71Sopenharmony_ci
485e41f4b71Sopenharmony_ci**Parameters**
486e41f4b71Sopenharmony_ci
487e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
488e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
489e41f4b71Sopenharmony_ci| wallpaperType | [WallpaperType](js-apis-wallpaper.md#wallpapertype7) | Yes| Wallpaper type.|
490e41f4b71Sopenharmony_ci
491e41f4b71Sopenharmony_ci**Return value**
492e41f4b71Sopenharmony_ci
493e41f4b71Sopenharmony_ci| Type| Description|
494e41f4b71Sopenharmony_ci| -------- | -------- |
495e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise that returns no value.|
496e41f4b71Sopenharmony_ci
497e41f4b71Sopenharmony_ci**Error codes**
498e41f4b71Sopenharmony_ci
499e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
500e41f4b71Sopenharmony_ci
501e41f4b71Sopenharmony_ci| **ID**| **Error Message**                               |
502e41f4b71Sopenharmony_ci| ------------ | ------------------------------------------- |
503e41f4b71Sopenharmony_ci| 201          | permission denied.                                                                              |
504e41f4b71Sopenharmony_ci| 202          | permission verification failed, application which is not a system application uses system API.  |
505e41f4b71Sopenharmony_ci| 401          | 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.  |
506e41f4b71Sopenharmony_ci
507e41f4b71Sopenharmony_ci**Example**
508e41f4b71Sopenharmony_ci
509e41f4b71Sopenharmony_ci```ts
510e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
511e41f4b71Sopenharmony_ci 
512e41f4b71Sopenharmony_ciwallpaper.restore(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then(() => {
513e41f4b71Sopenharmony_ci    console.log(`success to restore.`);
514e41f4b71Sopenharmony_ci  }).catch((error: BusinessError) => {
515e41f4b71Sopenharmony_ci    console.error(`failed to restore because: ${JSON.stringify(error)}`);
516e41f4b71Sopenharmony_ci});
517e41f4b71Sopenharmony_ci```
518e41f4b71Sopenharmony_ci
519e41f4b71Sopenharmony_ci## wallpaper.setImage<sup>9+</sup>
520e41f4b71Sopenharmony_ci
521e41f4b71Sopenharmony_cisetImage(source: string | image.PixelMap, wallpaperType: WallpaperType, callback: AsyncCallback&lt;void&gt;): void
522e41f4b71Sopenharmony_ci
523e41f4b71Sopenharmony_ciSets a specified source as the wallpaper of a specified type. This API uses an asynchronous callback to return the result.
524e41f4b71Sopenharmony_ci
525e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.SET_WALLPAPER
526e41f4b71Sopenharmony_ci
527e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.Wallpaper
528e41f4b71Sopenharmony_ci
529e41f4b71Sopenharmony_ci**System API**: This is a system API.
530e41f4b71Sopenharmony_ci
531e41f4b71Sopenharmony_ci**Parameters**
532e41f4b71Sopenharmony_ci
533e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
534e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
535e41f4b71Sopenharmony_ci| source | string \| [image.PixelMap](../apis-image-kit/js-apis-image.md) | Yes| URI of a JPEG or PNG file, or pixel map of a PNG file.|
536e41f4b71Sopenharmony_ci| wallpaperType | [WallpaperType](js-apis-wallpaper.md#wallpapertype7) | Yes| Wallpaper type.|
537e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result. If the wallpaper is set, **err** is **undefined**. Otherwise, **err** is an error object.|
538e41f4b71Sopenharmony_ci
539e41f4b71Sopenharmony_ci**Error codes**
540e41f4b71Sopenharmony_ci
541e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
542e41f4b71Sopenharmony_ci
543e41f4b71Sopenharmony_ci| **ID**| **Error Message**                               |
544e41f4b71Sopenharmony_ci| ------------ | ------------------------------------------- |
545e41f4b71Sopenharmony_ci| 201          | permission denied.                                                                              |
546e41f4b71Sopenharmony_ci| 202          | permission verification failed, application which is not a system application uses system API.  |
547e41f4b71Sopenharmony_ci| 401          | 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.  |
548e41f4b71Sopenharmony_ci
549e41f4b71Sopenharmony_ci**Example**
550e41f4b71Sopenharmony_ci
551e41f4b71Sopenharmony_ci```ts
552e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
553e41f4b71Sopenharmony_ciimport { image } from '@kit.ImageKit';
554e41f4b71Sopenharmony_ci
555e41f4b71Sopenharmony_ci// The source type is string.
556e41f4b71Sopenharmony_cilet wallpaperPath = "/data/storage/el2/base/haps/entry/files/js.jpeg";
557e41f4b71Sopenharmony_ciwallpaper.setImage(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error: BusinessError) => {
558e41f4b71Sopenharmony_ci    if (error) {
559e41f4b71Sopenharmony_ci        console.error(`failed to setImage because: ${JSON.stringify(error)}`);
560e41f4b71Sopenharmony_ci        return;
561e41f4b71Sopenharmony_ci     }
562e41f4b71Sopenharmony_ci    console.log(`success to setImage.`);
563e41f4b71Sopenharmony_ci});
564e41f4b71Sopenharmony_ci  
565e41f4b71Sopenharmony_ci// The source type is image.PixelMap.
566e41f4b71Sopenharmony_cilet imageSource = image.createImageSource("file://" + wallpaperPath);
567e41f4b71Sopenharmony_cilet opts: image.DecodingOptions = {
568e41f4b71Sopenharmony_ci    desiredSize: {
569e41f4b71Sopenharmony_ci        height: 3648,
570e41f4b71Sopenharmony_ci        width: 2736
571e41f4b71Sopenharmony_ci    }
572e41f4b71Sopenharmony_ci};
573e41f4b71Sopenharmony_ciimageSource.createPixelMap(opts).then((pixelMap: image.PixelMap) => {
574e41f4b71Sopenharmony_ci    wallpaper.setImage(pixelMap, wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error: BusinessError) => {
575e41f4b71Sopenharmony_ci        if (error) {
576e41f4b71Sopenharmony_ci            console.error(`failed to setImage because: ${JSON.stringify(error)}`);
577e41f4b71Sopenharmony_ci            return;
578e41f4b71Sopenharmony_ci        }
579e41f4b71Sopenharmony_ci        console.log(`success to setImage.`);
580e41f4b71Sopenharmony_ci    });
581e41f4b71Sopenharmony_ci}).catch((error: BusinessError) => {
582e41f4b71Sopenharmony_ci    console.error(`failed to createPixelMap because: ${JSON.stringify(error)}`);
583e41f4b71Sopenharmony_ci});
584e41f4b71Sopenharmony_ci```
585e41f4b71Sopenharmony_ci
586e41f4b71Sopenharmony_ci## wallpaper.setImage<sup>9+</sup>
587e41f4b71Sopenharmony_ci
588e41f4b71Sopenharmony_cisetImage(source: string | image.PixelMap, wallpaperType: WallpaperType): Promise&lt;void&gt;
589e41f4b71Sopenharmony_ci
590e41f4b71Sopenharmony_ciSets a specified source as the wallpaper of a specified type. This API uses a promise to return the result.
591e41f4b71Sopenharmony_ci
592e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.SET_WALLPAPER
593e41f4b71Sopenharmony_ci
594e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.Wallpaper
595e41f4b71Sopenharmony_ci
596e41f4b71Sopenharmony_ci**System API**: This is a system API.
597e41f4b71Sopenharmony_ci
598e41f4b71Sopenharmony_ci**Parameters**
599e41f4b71Sopenharmony_ci
600e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
601e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
602e41f4b71Sopenharmony_ci| source | string \| [image.PixelMap](../apis-image-kit/js-apis-image.md) | Yes| URI of a JPEG or PNG file, or pixel map of a PNG file.|
603e41f4b71Sopenharmony_ci| wallpaperType | [WallpaperType](js-apis-wallpaper.md#wallpapertype7) | Yes| Wallpaper type.|
604e41f4b71Sopenharmony_ci
605e41f4b71Sopenharmony_ci**Return value**
606e41f4b71Sopenharmony_ci
607e41f4b71Sopenharmony_ci| Type| Description|
608e41f4b71Sopenharmony_ci| -------- | -------- |
609e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise that returns no value.|
610e41f4b71Sopenharmony_ci
611e41f4b71Sopenharmony_ci**Error codes**
612e41f4b71Sopenharmony_ci
613e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
614e41f4b71Sopenharmony_ci
615e41f4b71Sopenharmony_ci| **ID**| **Error Message**                               |
616e41f4b71Sopenharmony_ci| ------------ | ------------------------------------------- |
617e41f4b71Sopenharmony_ci| 201          | permission denied.                                                                              |
618e41f4b71Sopenharmony_ci| 202          | permission verification failed, application which is not a system application uses system API.  |
619e41f4b71Sopenharmony_ci| 401          | 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.  |
620e41f4b71Sopenharmony_ci
621e41f4b71Sopenharmony_ci**Example**
622e41f4b71Sopenharmony_ci
623e41f4b71Sopenharmony_ci```ts
624e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
625e41f4b71Sopenharmony_ciimport { image } from '@kit.ImageKit';
626e41f4b71Sopenharmony_ci
627e41f4b71Sopenharmony_ci// The source type is string.
628e41f4b71Sopenharmony_cilet wallpaperPath = "/data/storage/el2/base/haps/entry/files/js.jpeg";
629e41f4b71Sopenharmony_ciwallpaper.setImage(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then(() => {
630e41f4b71Sopenharmony_ci    console.log(`success to setImage.`);
631e41f4b71Sopenharmony_ci}).catch((error: BusinessError) => {
632e41f4b71Sopenharmony_ci    console.error(`failed to setImage because: ${JSON.stringify(error)}`);
633e41f4b71Sopenharmony_ci});
634e41f4b71Sopenharmony_ci
635e41f4b71Sopenharmony_ci// The source type is image.PixelMap.
636e41f4b71Sopenharmony_cilet imageSource = image.createImageSource("file://" + wallpaperPath);
637e41f4b71Sopenharmony_cilet opts: image.DecodingOptions = {
638e41f4b71Sopenharmony_ci    desiredSize: {
639e41f4b71Sopenharmony_ci        height: 3648,
640e41f4b71Sopenharmony_ci        width: 2736
641e41f4b71Sopenharmony_ci    }
642e41f4b71Sopenharmony_ci};
643e41f4b71Sopenharmony_ciimageSource.createPixelMap(opts).then((pixelMap: image.PixelMap) => {
644e41f4b71Sopenharmony_ci    wallpaper.setImage(pixelMap, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then(() => {
645e41f4b71Sopenharmony_ci        console.log(`success to setImage.`);
646e41f4b71Sopenharmony_ci    }).catch((error: BusinessError) => {
647e41f4b71Sopenharmony_ci        console.error(`failed to setImage because: ${JSON.stringify(error)}`);
648e41f4b71Sopenharmony_ci    });
649e41f4b71Sopenharmony_ci}).catch((error: BusinessError) => {
650e41f4b71Sopenharmony_ci    console.error(`failed to createPixelMap because: ${JSON.stringify(error)}`);
651e41f4b71Sopenharmony_ci});
652e41f4b71Sopenharmony_ci```
653e41f4b71Sopenharmony_ci
654e41f4b71Sopenharmony_ci## wallpaper.getImage<sup>9+</sup>
655e41f4b71Sopenharmony_ci
656e41f4b71Sopenharmony_cigetImage(wallpaperType: WallpaperType, callback: AsyncCallback&lt;image.PixelMap&gt;): void;
657e41f4b71Sopenharmony_ci
658e41f4b71Sopenharmony_ciObtains the pixel map for the wallpaper of the specified type. This API only works for the static wallpaper set using **setImage**. This API uses an asynchronous callback to return the result.
659e41f4b71Sopenharmony_ci
660e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.GET_WALLPAPER
661e41f4b71Sopenharmony_ci
662e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.Wallpaper
663e41f4b71Sopenharmony_ci
664e41f4b71Sopenharmony_ci**System API**: This is a system API.
665e41f4b71Sopenharmony_ci
666e41f4b71Sopenharmony_ci**Parameters**
667e41f4b71Sopenharmony_ci
668e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
669e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
670e41f4b71Sopenharmony_ci| wallpaperType | [WallpaperType](js-apis-wallpaper.md#wallpapertype7) | Yes| Wallpaper type.|
671e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;[image.PixelMap](../apis-image-kit/js-apis-image.md)&gt; | Yes| Callback used to return the result. If the operation is successful, the pixel map of the wallpaper is returned. Otherwise, error information is returned.|
672e41f4b71Sopenharmony_ci
673e41f4b71Sopenharmony_ci**Error codes**
674e41f4b71Sopenharmony_ci
675e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
676e41f4b71Sopenharmony_ci
677e41f4b71Sopenharmony_ci| **ID**| **Error Message**                               |
678e41f4b71Sopenharmony_ci| ------------ | ------------------------------------------- |
679e41f4b71Sopenharmony_ci| 201          | permission denied.                                                                              |
680e41f4b71Sopenharmony_ci| 202          | permission verification failed, application which is not a system application uses system API.  |
681e41f4b71Sopenharmony_ci| 401          | 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.  |
682e41f4b71Sopenharmony_ci
683e41f4b71Sopenharmony_ci**Example**
684e41f4b71Sopenharmony_ci
685e41f4b71Sopenharmony_ci```ts
686e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
687e41f4b71Sopenharmony_ciimport { image } from '@kit.ImageKit';
688e41f4b71Sopenharmony_ci
689e41f4b71Sopenharmony_ciwallpaper.getImage(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error: BusinessError, data: image.PixelMap) => {
690e41f4b71Sopenharmony_ci    if (error) {
691e41f4b71Sopenharmony_ci        console.error(`failed to getImage because: ${JSON.stringify(error)}`);
692e41f4b71Sopenharmony_ci        return;
693e41f4b71Sopenharmony_ci    }
694e41f4b71Sopenharmony_ci    console.log(`success to getImage: ${JSON.stringify(data)}`);
695e41f4b71Sopenharmony_ci});
696e41f4b71Sopenharmony_ci```
697e41f4b71Sopenharmony_ci
698e41f4b71Sopenharmony_ci
699e41f4b71Sopenharmony_ci## wallpaper.getImage<sup>9+</sup>
700e41f4b71Sopenharmony_ci
701e41f4b71Sopenharmony_cigetImage(wallpaperType: WallpaperType): Promise&lt;image.PixelMap&gt;
702e41f4b71Sopenharmony_ci
703e41f4b71Sopenharmony_ciObtains the pixel map for the wallpaper of the specified type. This API only works for the static wallpaper set using **setImage**. This API uses a promise to return the result.
704e41f4b71Sopenharmony_ci
705e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.GET_WALLPAPER
706e41f4b71Sopenharmony_ci
707e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.Wallpaper
708e41f4b71Sopenharmony_ci
709e41f4b71Sopenharmony_ci**System API**: This is a system API.
710e41f4b71Sopenharmony_ci
711e41f4b71Sopenharmony_ci**Parameters**
712e41f4b71Sopenharmony_ci
713e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
714e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
715e41f4b71Sopenharmony_ci| wallpaperType | [WallpaperType](js-apis-wallpaper.md#wallpapertype7) | Yes| Wallpaper type.|
716e41f4b71Sopenharmony_ci
717e41f4b71Sopenharmony_ci**Return value**
718e41f4b71Sopenharmony_ci
719e41f4b71Sopenharmony_ci| Type| Description|
720e41f4b71Sopenharmony_ci| -------- | -------- |
721e41f4b71Sopenharmony_ci| Promise&lt;[image.PixelMap](../apis-image-kit/js-apis-image.md)&gt; | Promise used to return the result. If the operation is successful, the pixel map of the wallpaper is returned. Otherwise, error information is returned.|
722e41f4b71Sopenharmony_ci
723e41f4b71Sopenharmony_ci**Error codes**
724e41f4b71Sopenharmony_ci
725e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
726e41f4b71Sopenharmony_ci
727e41f4b71Sopenharmony_ci| **ID**| **Error Message**                               |
728e41f4b71Sopenharmony_ci| ------------ | ------------------------------------------- |
729e41f4b71Sopenharmony_ci| 201          | permission denied.                                                                              |
730e41f4b71Sopenharmony_ci| 202          | permission verification failed, application which is not a system application uses system API.  |
731e41f4b71Sopenharmony_ci| 401          | 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.  |
732e41f4b71Sopenharmony_ci
733e41f4b71Sopenharmony_ci**Example**
734e41f4b71Sopenharmony_ci
735e41f4b71Sopenharmony_ci```ts
736e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
737e41f4b71Sopenharmony_ciimport { image } from '@kit.ImageKit';
738e41f4b71Sopenharmony_ci
739e41f4b71Sopenharmony_ciwallpaper.getImage(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data: image.PixelMap) => {
740e41f4b71Sopenharmony_ci    console.log(`success to getImage: ${JSON.stringify(data)}`);
741e41f4b71Sopenharmony_ci  }).catch((error: BusinessError) => {
742e41f4b71Sopenharmony_ci    console.error(`failed to getImage because: ${JSON.stringify(error)}`);
743e41f4b71Sopenharmony_ci});
744e41f4b71Sopenharmony_ci```
745e41f4b71Sopenharmony_ci
746e41f4b71Sopenharmony_ci
747e41f4b71Sopenharmony_ci
748e41f4b71Sopenharmony_ci## wallpaper.getPixelMap<sup>(deprecated)</sup>
749e41f4b71Sopenharmony_ci
750e41f4b71Sopenharmony_cigetPixelMap(wallpaperType: WallpaperType, callback: AsyncCallback&lt;image.PixelMap&gt;): void;
751e41f4b71Sopenharmony_ci
752e41f4b71Sopenharmony_ciObtains the pixel map for the wallpaper of the specified type.
753e41f4b71Sopenharmony_ci
754e41f4b71Sopenharmony_ci> **NOTE**
755e41f4b71Sopenharmony_ci>
756e41f4b71Sopenharmony_ci> This API is supported since API version 7 and deprecated since API version 9.
757e41f4b71Sopenharmony_ci
758e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.GET_WALLPAPER
759e41f4b71Sopenharmony_ci
760e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.Wallpaper
761e41f4b71Sopenharmony_ci
762e41f4b71Sopenharmony_ci**System API**: This is a system API.
763e41f4b71Sopenharmony_ci
764e41f4b71Sopenharmony_ci**Parameters**
765e41f4b71Sopenharmony_ci
766e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
767e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
768e41f4b71Sopenharmony_ci| wallpaperType | [WallpaperType](js-apis-wallpaper.md#wallpapertype7) | Yes| Wallpaper type.|
769e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;image.PixelMap&gt; | Yes| Callback used to return the result. If the operation is successful, the pixel map of the wallpaper is returned. Otherwise, error information is returned.|
770e41f4b71Sopenharmony_ci
771e41f4b71Sopenharmony_ci**Example**
772e41f4b71Sopenharmony_ci
773e41f4b71Sopenharmony_ci```ts
774e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
775e41f4b71Sopenharmony_ciimport { image } from '@kit.ImageKit';
776e41f4b71Sopenharmony_ci
777e41f4b71Sopenharmony_ciwallpaper.getPixelMap(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error: BusinessError, data: image.PixelMap) => {
778e41f4b71Sopenharmony_ci    if (error) {
779e41f4b71Sopenharmony_ci        console.error(`failed to getPixelMap because: ${JSON.stringify(error)}`);
780e41f4b71Sopenharmony_ci        return;
781e41f4b71Sopenharmony_ci    }
782e41f4b71Sopenharmony_ci    console.log(`success to getPixelMap : ${JSON.stringify(data)}`);
783e41f4b71Sopenharmony_ci  });
784e41f4b71Sopenharmony_ci```
785e41f4b71Sopenharmony_ci
786e41f4b71Sopenharmony_ci## wallpaper.getPixelMap<sup>(deprecated)</sup>
787e41f4b71Sopenharmony_ci
788e41f4b71Sopenharmony_cigetPixelMap(wallpaperType: WallpaperType): Promise&lt;image.PixelMap&gt;
789e41f4b71Sopenharmony_ci
790e41f4b71Sopenharmony_ciObtains the pixel map for the wallpaper of the specified type.
791e41f4b71Sopenharmony_ci
792e41f4b71Sopenharmony_ci> **NOTE**
793e41f4b71Sopenharmony_ci>
794e41f4b71Sopenharmony_ci> This API is supported since API version 7 and deprecated since API version 9.
795e41f4b71Sopenharmony_ci
796e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.GET_WALLPAPER
797e41f4b71Sopenharmony_ci
798e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.Wallpaper
799e41f4b71Sopenharmony_ci
800e41f4b71Sopenharmony_ci**System API**: This is a system API.
801e41f4b71Sopenharmony_ci
802e41f4b71Sopenharmony_ci**Parameters**
803e41f4b71Sopenharmony_ci
804e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
805e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
806e41f4b71Sopenharmony_ci| wallpaperType | [WallpaperType](js-apis-wallpaper.md#wallpapertype7) | Yes| Wallpaper type.|
807e41f4b71Sopenharmony_ci
808e41f4b71Sopenharmony_ci**Return value**
809e41f4b71Sopenharmony_ci
810e41f4b71Sopenharmony_ci| Type| Description|
811e41f4b71Sopenharmony_ci| -------- | -------- |
812e41f4b71Sopenharmony_ci| Promise&lt;image.PixelMap&gt; | Promise used to return the result. If the operation is successful, the pixel map of the wallpaper is returned. Otherwise, error information is returned.|
813e41f4b71Sopenharmony_ci
814e41f4b71Sopenharmony_ci**Example**
815e41f4b71Sopenharmony_ci
816e41f4b71Sopenharmony_ci```ts
817e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
818e41f4b71Sopenharmony_ciimport { image } from '@kit.ImageKit';
819e41f4b71Sopenharmony_ci
820e41f4b71Sopenharmony_ciwallpaper.getPixelMap(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data: image.PixelMap) => {
821e41f4b71Sopenharmony_ci    console.log(`success to getPixelMap : ${JSON.stringify(data)}`);
822e41f4b71Sopenharmony_ci  }).catch((error: BusinessError) => {
823e41f4b71Sopenharmony_ci    console.error(`failed to getPixelMap because: ${JSON.stringify(error)}`);
824e41f4b71Sopenharmony_ci});
825e41f4b71Sopenharmony_ci```
826