openharmony_ci 89ca1dc824
!642 新增json模块
Merge pull request !642 from guochao/0513
2025-05-14 09:11:55 +00:00
2025-03-27 11:05:41 +00:00
2025-05-08 15:41:14 +08:00
2025-05-13 20:44:12 +08:00
2025-05-07 11:48:00 +08:00
2025-04-15 15:24:56 +00:00
2024-05-21 16:48:41 +08:00
2025-05-13 20:44:12 +08:00
2025-03-27 06:16:37 +00:00
2022-03-09 16:05:58 +08:00
fix
2024-11-30 15:28:14 +08:00
2024-09-24 08:45:07 +00:00
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
Description
No description provided
Readme Pixar 12 MiB
Languages
C++ 76.1%
JavaScript 20.7%
C 3.2%