openharmony_ci 6c35c18831 !121 Gitee Review - change_misc_components
Merge pull request !121 from 鲍亚永/change_misc_components
2022-07-22 06:18:37 +00:00
2022-07-20 21:37:54 +08:00
2022-03-16 20:06:18 +08:00
2022-07-20 21:37:54 +08:00
2022-07-20 21:37:54 +08:00
2022-07-20 21:37:54 +08:00
2022-07-20 21:37:54 +08:00
2022-07-20 21:37:54 +08:00
2022-07-20 21:37:54 +08:00
2022-07-20 22:24:45 +08:00
2022-03-09 16:05:58 +08:00
2022-03-09 08:18:25 +00:00
2022-03-10 18:32:43 +08:00
2022-07-20 21:37:54 +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/miscservices/wallpaper

Introduction to framework code

/base/miscservices/wallpaper ├── figures # architecture diagram ├── frameworks/innerkitsimpl # interface provided for app ├── interfaces # interface code provided by module │ ├── innerkits # inter service interface │ └── kits # napi interface ├── sa_profile # module contains the config files of system services and processes ├── services # implementation of wallpaper manager service ├── 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 lockscreen),Promise

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

Obtains the ID of the wallpaper of the specified typesystem screen or lockscreen),Promise

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

Obtains the default pixel map of a wallpaper of the specified typesystem screen or lockscreen),Promise

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 pixelmap),Promise

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
S
Description
Wallpaper Framework | 壁纸框架
Readme 1.9 MiB
Languages
C++ 98%
JavaScript 1.7%
C 0.3%