Go to file
openharmony_ci 10a2b7ed25
!601 revert test file
Merge pull request !601 from LVB8189/master
2024-11-30 08:18:33 +00:00
figures Signed-off-by: LVB8189 <lvbai1@huawei.com> 2022-08-09 15:03:30 +08:00
frameworks fix 2024-11-30 15:28:14 +08:00
interfaces/inner_api/include feat:自模糊接口 2024-11-15 21:13:16 +08:00
services feat:ROM优化 2024-11-29 19:14:15 +08:00
test fix 2024-11-30 15:28:14 +08:00
utils feat:ROM优化 2024-11-29 19:14:15 +08:00
BUILD.gn fix:删除系统参数 2024-05-21 16:48:41 +08:00
bundle.json fix 2024-11-30 15:28:14 +08:00
CODEOWNERS Signed-off-by: wangdongqi <wangdongqi2@huawei.com> 2023-06-20 21:57:03 +08:00
hisysevent.yaml Signed-off-by: weishaoxiong <weishaoxiong1@huawei.com> 2023-08-17 14:07:06 +08:00
LICENSE change README 2022-03-09 16:05:58 +08:00
OAT.xml fix 2024-11-30 15:28:14 +08:00
README_ZH.md update README_ZH.md. 2024-09-24 08:45:07 +00:00
README.md Signed-off-by: weishaoxiong <weishaoxiong1@huawei.com> 2023-02-18 11:17:44 +08:00
wallpaper.gni format gni 2023-11-13 12:20:25 +08:00

wallpaper service

Introduction

1、Provide wallpaper service capability for the system, and support wallpaper display, setting, switching wallpaper and other functions;

2、Provide the framework and interface for developers to develop wallpaper, and develop wallpaper applications;

subsystem architecture diagram

Warehouse path

/base/theme/wallpaper_mgr

Introduction to framework code

/base/theme/wallpaper_mgr ├── figures # architecture diagram ├── frameworks │ ├── js/napi # the js interface resolves to the napi interface │ ├── kits/extension # extension │ └── native # interface provided for app ├── services # implementation of wallpaper manager service │ ├── profile # module contains the config files of system services │ └── etc # module contains the config files of processes ├── test # unit test of interface └── utils # module contains log printing and constants for ordered commonEvent

Interface Introduction

Table 1 Main method of wallpaper service

Interface Name

Description

function getColors(wallpaperType: WallpaperType): Promise<Array<RgbaColor>>

Obtains the wallpaper colors for the wallpaper of the specified typesystem screen or lockscreenPromise

function getId(wallpaperType: WallpaperType): Promise<number>

Obtains the ID of the wallpaper of the specified typesystem screen or lockscreenPromise

function getPixelMap(wallpaperType: WallpaperType): Promise<image.PixelMap>

Obtains the default pixel map of a wallpaper of the specified typesystem screen or lockscreenPromise

function setWallpaper(source: string | image.PixelMap, wallpaperType: WallpaperType): Promise<void>

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 filewallpaper path or pixelmapPromise

function on(type: 'colorChange', callback: (colors: Array<RgbaColor>, wallpaperType: WallpaperType) => void): void;

Registers a listener for wallpaper color changes to receive notifications about the changescallback

function off(type: 'colorChange', callback?: (colors: Array<RgbaColor>, wallpaperType: WallpaperType) => void): void;

Unregisters a listener for wallpaper color changescallback

JS APIs instructions

//get pixelmap callback with callback
wallpaper.getPixelMap(WALLPAPER_SYSTEM, function (err, data) {
            console.info('wallpaperXTS ===> testGetPixelMapCallbackSystem err : ' + JSON.stringify(err));
            console.info('wallpaperXTS ===> testGetPixelMapCallbackSystem data : ' + JSON.stringify(data));
            if(err){
                expect(null).assertFail();
            }
            if((data != undefined) && (data != null) && (data != '')){
                expect(true).assertTrue();
            }
        })

//get pixelmap callback with Promise
wallpaper.getPixelMap(WALLPAPER_SYSTEM).then((data) => {
            console.info('wallpaperXTS ===> testGetPixelMapPromiseSystem data : ' + data);
            console.info('wallpaperXTS ===> testGetPixelMapPromiseSystem data : ' + JSON.stringify(data));
            if((data != undefined) && (data != null) && (data != '')){
                expect(true).assertTrue();
            }
        }).catch((err) => {
            console.info('wallpaperXTS ===> testGetPixelMapPromiseSystem err : ' + err);
            console.info('wallpaperXTS ===> testGetPixelMapPromiseSystem err : ' + JSON.stringify(err));
            if(err){
                expect(null).assertFail();
            }
        });

//set pixelmap callback with callback
wallpaper.setWallpaper(pixelmap, WALLPAPER_SYSTEM, function (err, data) {
                console.info('wallpaperXTS ===> testSetWallpaperPixelMapCallbackSystem err : ' + JSON.stringify(err));
                console.info('wallpaperXTS ===> testSetWallpaperPixelMapCallbackSystem data : ' + JSON.stringify(data));
                if(err){
                    expect(null).assertFail();
                }
                if((data != undefined) && (data != null) && (data != '')){
                    expect(true).assertTrue();
                }
            });

//set pixelmap callback with Promise
wallpaper.setWallpaper(pixelmap, WALLPAPER_SYSTEM).then((data) => {
                console.info('wallpaperXTS ===> testSetWallpaperPixelMapPromiseSystem data : ' + JSON.stringify(data));
                if((data != undefined) && (data != null) && (data != '')){
                    expect(true).assertTrue();
                }
            }).catch((err) => {
                console.info('wallpaperXTS ===> testSetWallpaperPixelMapPromiseSystem err : ' + JSON.stringify(err));
                if(err){
                    expect(null).assertFail();
                }
            });

Participation contribution

  1. Fork warehouse
  2. Submission code
  3. Create a new pull request
  4. Commit is complete