• Home
Name Date Size #Lines LOC

..--

figures/12-May-2024-

frameworks/12-May-2024-9,0816,592

services/12-May-2024-3,2092,601

test/12-May-2024-2,3411,537

utils/12-May-2024-1,072732

BUILD.gnD12-May-2024995 2825

CODEOWNERSD12-May-2024763 1614

LICENSED12-May-20249.9 KiB177150

OAT.xmlD12-May-20245.7 KiB8835

README.mdD12-May-20247.7 KiB135119

README_ZH.mdD12-May-20241.4 KiB4430

bundle.jsonD12-May-20242.5 KiB7979

hisysevent.yamlD12-May-20242.4 KiB5210

wallpaper.gniD12-May-20241.1 KiB3121

README.md

1# wallpaper service
2
3#### Introduction
41、Provide wallpaper service capability for the system, and support wallpaper display, setting, switching wallpaper and other functions;
5
62、Provide the framework and interface for developers to develop wallpaper, and develop wallpaper applications;
7
8**subsystem architecture diagram**
9![](figures/subsystem_architecture.png "subsystem architecture diagram")
10
11#### Warehouse path
12/base/theme/wallpaper_mgr
13
14#### Introduction to framework code
15/base/theme/wallpaper_mgr
16├── figures                  # architecture diagram
17├── frameworks
18│   ├── js/napi              # the js interface resolves to the napi interface
19│   ├── kits/extension       # extension
20│   └── native               # interface provided for app
21├── services                 # implementation of wallpaper manager service
22│   ├── profile              # module contains the config files of system services
23│   └── etc                  # module contains the config files of processes
24├── test                     # unit test of interface
25└── utils                    # module contains log printing and constants for ordered commonEvent
26
27#### Interface Introduction
28**Table 1**  Main method of wallpaper service
29
30<a name="table033515471012"></a>
31<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>
32</th>
33<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>
34</th>
35</tr>
36</thead>
37<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>
38</td>
39<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>
40</td>
41</tr>
42<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>
43</td>
44<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>
45</td>
46</tr>
47<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>
48</td>
49<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>
50</td>
51</tr>
52<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>
53</td>
54<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>
55</td>
56</tr>
57<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;
58</p>
59</td>
60<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>
61</td>
62</tr>
63<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;
64</p>
65</td>
66<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>
67</td>
68</tr>
69</tbody>
70</table>
71
72JS APIs instructions
73```
74//get pixelmap callback with callback
75wallpaper.getPixelMap(WALLPAPER_SYSTEM, function (err, data) {
76            console.info('wallpaperXTS ===> testGetPixelMapCallbackSystem err : ' + JSON.stringify(err));
77            console.info('wallpaperXTS ===> testGetPixelMapCallbackSystem data : ' + JSON.stringify(data));
78            if(err){
79                expect(null).assertFail();
80            }
81            if((data != undefined) && (data != null) && (data != '')){
82                expect(true).assertTrue();
83            }
84        })
85
86//get pixelmap callback with Promise
87wallpaper.getPixelMap(WALLPAPER_SYSTEM).then((data) => {
88            console.info('wallpaperXTS ===> testGetPixelMapPromiseSystem data : ' + data);
89            console.info('wallpaperXTS ===> testGetPixelMapPromiseSystem data : ' + JSON.stringify(data));
90            if((data != undefined) && (data != null) && (data != '')){
91                expect(true).assertTrue();
92            }
93        }).catch((err) => {
94            console.info('wallpaperXTS ===> testGetPixelMapPromiseSystem err : ' + err);
95            console.info('wallpaperXTS ===> testGetPixelMapPromiseSystem err : ' + JSON.stringify(err));
96            if(err){
97                expect(null).assertFail();
98            }
99        });
100
101//set pixelmap callback with callback
102wallpaper.setWallpaper(pixelmap, WALLPAPER_SYSTEM, function (err, data) {
103                console.info('wallpaperXTS ===> testSetWallpaperPixelMapCallbackSystem err : ' + JSON.stringify(err));
104                console.info('wallpaperXTS ===> testSetWallpaperPixelMapCallbackSystem data : ' + JSON.stringify(data));
105                if(err){
106                    expect(null).assertFail();
107                }
108                if((data != undefined) && (data != null) && (data != '')){
109                    expect(true).assertTrue();
110                }
111            });
112
113//set pixelmap callback with Promise
114wallpaper.setWallpaper(pixelmap, WALLPAPER_SYSTEM).then((data) => {
115                console.info('wallpaperXTS ===> testSetWallpaperPixelMapPromiseSystem data : ' + JSON.stringify(data));
116                if((data != undefined) && (data != null) && (data != '')){
117                    expect(true).assertTrue();
118                }
119            }).catch((err) => {
120                console.info('wallpaperXTS ===> testSetWallpaperPixelMapPromiseSystem err : ' + JSON.stringify(err));
121                if(err){
122                    expect(null).assertFail();
123                }
124            });
125```
126
127#### Participation contribution
128
1291. Fork warehouse
1302. Submission code
1313. Create a new pull request
1324. Commit is complete
133
134
135

README_ZH.md

1# 主题框架子系统/壁纸管理服务
2
3## 简介
4
5### 内容介绍
6该仓主要为系统提供壁纸管理服务能力,支持系统显示、设置、切换壁纸等功能。
7
8### 架构图介绍
9**图 1** 子系统架构图
10![](figures/subsystem_architecture_zh.png "子系统架构图")
11
12#### 仓路径
13
14/base/theme/wallpaper_mgr
15
16## 目录
17
18```
19/base/theme/wallpaper_mgr
20├── figures                  # 架构图
21├── frameworks
22│   ├── js/napi              # js接口解析成napi接口
23│   ├── kits/extension       # extension扩展
24│   └── native               # 对客户端提供的接口
25├── services                 # 壁纸管理服务实现
26│   ├── profile              # 组件包含的系统服务的配置文件
27│   └── etc                  # 组件包含的进程的配置文件
28├── test                     # 接口的单元测试
29└── utils                    # 组件包含日志打印和有序公共事件定义的常量
30```
31## 说明
32
33### 接口说明
34
35-   Wallpaper接口文档
36    -   [js-apis-wallpaper.md](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-wallpaper.md) 提供从API version 7开始的接口定义和示例代码。
37
38## 相关仓
39
40**主题框架子系统**
41
42[theme_wallpaper_mgr](https://gitee.com/openharmony/theme_wallpaper_mgr)
43
44