1ce968135Sopenharmony_ci# wallpaper service
2ce968135Sopenharmony_ci
3ce968135Sopenharmony_ci#### Introduction
4ce968135Sopenharmony_ci1、Provide wallpaper service capability for the system, and support wallpaper display, setting, switching wallpaper and other functions;
5ce968135Sopenharmony_ci
6ce968135Sopenharmony_ci2、Provide the framework and interface for developers to develop wallpaper, and develop wallpaper applications;
7ce968135Sopenharmony_ci
8ce968135Sopenharmony_ci**subsystem architecture diagram**   
9ce968135Sopenharmony_ci![](figures/subsystem_architecture.png "subsystem architecture diagram")
10ce968135Sopenharmony_ci
11ce968135Sopenharmony_ci#### Warehouse path
12ce968135Sopenharmony_ci/base/theme/wallpaper_mgr
13ce968135Sopenharmony_ci
14ce968135Sopenharmony_ci#### Introduction to framework code
15ce968135Sopenharmony_ci/base/theme/wallpaper_mgr
16ce968135Sopenharmony_ci├── figures                  # architecture diagram
17ce968135Sopenharmony_ci├── frameworks
18ce968135Sopenharmony_ci│   ├── js/napi              # the js interface resolves to the napi interface
19ce968135Sopenharmony_ci│   ├── kits/extension       # extension
20ce968135Sopenharmony_ci│   └── native               # interface provided for app
21ce968135Sopenharmony_ci├── services                 # implementation of wallpaper manager service
22ce968135Sopenharmony_ci│   ├── profile              # module contains the config files of system services
23ce968135Sopenharmony_ci│   └── etc                  # module contains the config files of processes
24ce968135Sopenharmony_ci├── test                     # unit test of interface
25ce968135Sopenharmony_ci└── utils                    # module contains log printing and constants for ordered commonEvent
26ce968135Sopenharmony_ci
27ce968135Sopenharmony_ci#### Interface Introduction
28ce968135Sopenharmony_ci**Table 1**  Main method of wallpaper service
29ce968135Sopenharmony_ci
30ce968135Sopenharmony_ci<a name="table033515471012"></a>
31ce968135Sopenharmony_ci<table><thead align="left"><tr id="row143351854201012"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p103351154121010"><a name="p103351154121010"></a><a name="p103351154121010"></a>Interface Name</p>
32ce968135Sopenharmony_ci</th>
33ce968135Sopenharmony_ci<th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.2"><p id="p1033585416105"><a name="p1033585416105"></a><a name="p1033585416105"></a>Description</p>
34ce968135Sopenharmony_ci</th>
35ce968135Sopenharmony_ci</tr>
36ce968135Sopenharmony_ci</thead>
37ce968135Sopenharmony_ci<tbody><tr id="row204321219393"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1893413268144"><a name="p1893413268144"></a><a name="p1893413268144"></a>function getColors(wallpaperType: WallpaperType): Promise&lt;Array&lt;RgbaColor&gt;&gt;</p>
38ce968135Sopenharmony_ci</td>
39ce968135Sopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p18761104812149"><a name="p18761104812149"></a><a name="p18761104812149"></a>Obtains the wallpaper colors for the wallpaper of the specified type(system screen or lockscreen),Promise </p>
40ce968135Sopenharmony_ci</td>
41ce968135Sopenharmony_ci</tr>
42ce968135Sopenharmony_ci<tr id="row13335054111018"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p12832214151418"><a name="p12832214151418"></a><a name="p12832214151418"></a>function getId(wallpaperType: WallpaperType): Promise&lt;number&gt;</p>
43ce968135Sopenharmony_ci</td>
44ce968135Sopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p3335145451011"><a name="p3335145451011"></a><a name="p3335145451011"></a>Obtains the ID of the wallpaper of the specified type(system screen or lockscreen),Promise </p>
45ce968135Sopenharmony_ci</td>
46ce968135Sopenharmony_ci</tr>
47ce968135Sopenharmony_ci<tr id="row204321219393"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1893413268144"><a name="p1893413268144"></a><a name="p1893413268144"></a>function getPixelMap(wallpaperType: WallpaperType): Promise&lt;image.PixelMap&gt;</p>
48ce968135Sopenharmony_ci</td>
49ce968135Sopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p18761104812149"><a name="p18761104812149"></a><a name="p18761104812149"></a>Obtains the default pixel map of a wallpaper of the specified type(system screen or lockscreen),Promise</p>
50ce968135Sopenharmony_ci</td>
51ce968135Sopenharmony_ci</tr>
52ce968135Sopenharmony_ci<tr id="row204321219393"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1893413268144"><a name="p1893413268144"></a><a name="p1893413268144"></a>function setWallpaper(source: string | image.PixelMap, wallpaperType: WallpaperType): Promise&lt;void&gt;</p>
53ce968135Sopenharmony_ci</td>
54ce968135Sopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p18761104812149"><a name="p18761104812149"></a><a name="p18761104812149"></a>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(wallpaper path or pixelmap),Promise</p>
55ce968135Sopenharmony_ci</td>
56ce968135Sopenharmony_ci</tr>
57ce968135Sopenharmony_ci<tr id="row204321219393"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1893413268144"><a name="p1893413268144"></a><a name="p1893413268144"></a>function on(type: 'colorChange', callback: (colors: Array&lt;RgbaColor&gt;, wallpaperType: WallpaperType) => void): void;
58ce968135Sopenharmony_ci</p>
59ce968135Sopenharmony_ci</td>
60ce968135Sopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p18761104812149"><a name="p18761104812149"></a><a name="p18761104812149"></a>Registers a listener for wallpaper color changes to receive notifications about the changes,callback</p>
61ce968135Sopenharmony_ci</td>
62ce968135Sopenharmony_ci</tr>
63ce968135Sopenharmony_ci<tr id="row204321219393"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1893413268144"><a name="p1893413268144"></a><a name="p1893413268144"></a>function off(type: 'colorChange', callback?: (colors: Array&lt;RgbaColor&gt;, wallpaperType: WallpaperType) => void): void;
64ce968135Sopenharmony_ci</p>
65ce968135Sopenharmony_ci</td>
66ce968135Sopenharmony_ci<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p18761104812149"><a name="p18761104812149"></a><a name="p18761104812149"></a>Unregisters a listener for wallpaper color changes,callback</p>
67ce968135Sopenharmony_ci</td>
68ce968135Sopenharmony_ci</tr>
69ce968135Sopenharmony_ci</tbody>
70ce968135Sopenharmony_ci</table>
71ce968135Sopenharmony_ci
72ce968135Sopenharmony_ciJS APIs instructions
73ce968135Sopenharmony_ci```
74ce968135Sopenharmony_ci//get pixelmap callback with callback
75ce968135Sopenharmony_ciwallpaper.getPixelMap(WALLPAPER_SYSTEM, function (err, data) {
76ce968135Sopenharmony_ci            console.info('wallpaperXTS ===> testGetPixelMapCallbackSystem err : ' + JSON.stringify(err));
77ce968135Sopenharmony_ci            console.info('wallpaperXTS ===> testGetPixelMapCallbackSystem data : ' + JSON.stringify(data));
78ce968135Sopenharmony_ci            if(err){
79ce968135Sopenharmony_ci                expect(null).assertFail();
80ce968135Sopenharmony_ci            }
81ce968135Sopenharmony_ci            if((data != undefined) && (data != null) && (data != '')){
82ce968135Sopenharmony_ci                expect(true).assertTrue();
83ce968135Sopenharmony_ci            }
84ce968135Sopenharmony_ci        })
85ce968135Sopenharmony_ci
86ce968135Sopenharmony_ci//get pixelmap callback with Promise
87ce968135Sopenharmony_ciwallpaper.getPixelMap(WALLPAPER_SYSTEM).then((data) => {
88ce968135Sopenharmony_ci            console.info('wallpaperXTS ===> testGetPixelMapPromiseSystem data : ' + data);
89ce968135Sopenharmony_ci            console.info('wallpaperXTS ===> testGetPixelMapPromiseSystem data : ' + JSON.stringify(data));
90ce968135Sopenharmony_ci            if((data != undefined) && (data != null) && (data != '')){
91ce968135Sopenharmony_ci                expect(true).assertTrue();
92ce968135Sopenharmony_ci            }
93ce968135Sopenharmony_ci        }).catch((err) => {
94ce968135Sopenharmony_ci            console.info('wallpaperXTS ===> testGetPixelMapPromiseSystem err : ' + err);
95ce968135Sopenharmony_ci            console.info('wallpaperXTS ===> testGetPixelMapPromiseSystem err : ' + JSON.stringify(err));
96ce968135Sopenharmony_ci            if(err){
97ce968135Sopenharmony_ci                expect(null).assertFail();
98ce968135Sopenharmony_ci            }
99ce968135Sopenharmony_ci        });
100ce968135Sopenharmony_ci
101ce968135Sopenharmony_ci//set pixelmap callback with callback
102ce968135Sopenharmony_ciwallpaper.setWallpaper(pixelmap, WALLPAPER_SYSTEM, function (err, data) {
103ce968135Sopenharmony_ci                console.info('wallpaperXTS ===> testSetWallpaperPixelMapCallbackSystem err : ' + JSON.stringify(err));
104ce968135Sopenharmony_ci                console.info('wallpaperXTS ===> testSetWallpaperPixelMapCallbackSystem data : ' + JSON.stringify(data));
105ce968135Sopenharmony_ci                if(err){
106ce968135Sopenharmony_ci                    expect(null).assertFail();
107ce968135Sopenharmony_ci                }
108ce968135Sopenharmony_ci                if((data != undefined) && (data != null) && (data != '')){
109ce968135Sopenharmony_ci                    expect(true).assertTrue();
110ce968135Sopenharmony_ci                }
111ce968135Sopenharmony_ci            });
112ce968135Sopenharmony_ci
113ce968135Sopenharmony_ci//set pixelmap callback with Promise
114ce968135Sopenharmony_ciwallpaper.setWallpaper(pixelmap, WALLPAPER_SYSTEM).then((data) => {
115ce968135Sopenharmony_ci                console.info('wallpaperXTS ===> testSetWallpaperPixelMapPromiseSystem data : ' + JSON.stringify(data));
116ce968135Sopenharmony_ci                if((data != undefined) && (data != null) && (data != '')){
117ce968135Sopenharmony_ci                    expect(true).assertTrue();
118ce968135Sopenharmony_ci                }
119ce968135Sopenharmony_ci            }).catch((err) => {
120ce968135Sopenharmony_ci                console.info('wallpaperXTS ===> testSetWallpaperPixelMapPromiseSystem err : ' + JSON.stringify(err));
121ce968135Sopenharmony_ci                if(err){
122ce968135Sopenharmony_ci                    expect(null).assertFail();
123ce968135Sopenharmony_ci                }
124ce968135Sopenharmony_ci            });
125ce968135Sopenharmony_ci```
126ce968135Sopenharmony_ci
127ce968135Sopenharmony_ci#### Participation contribution
128ce968135Sopenharmony_ci
129ce968135Sopenharmony_ci1. Fork warehouse
130ce968135Sopenharmony_ci2. Submission code
131ce968135Sopenharmony_ci3. Create a new pull request
132ce968135Sopenharmony_ci4. Commit is complete
133ce968135Sopenharmony_ci
134ce968135Sopenharmony_ci
135