harmony 鸿蒙Theme Framework ChangeLog

  • 2023-02-03
  • 浏览 (392)

Theme Framework ChangeLog

cl.theme.1 Support of Exception Handling for APIs in API Version 9

The internal APIs of the following modules used service logic return values to indicate error information, which did not comply with the error code specifications of OpenHarmony. Therefore, they are modified in API version 9 and later. - Wallpaper management service: @ohos.wallpaper.d.ts

  • Lock screen management service: @ohos.screenLock.d.ts

APIs in the preceding modules are changed as follows: Synchronous API: An error message is returned via an exception. Asynchronous API: A parameter check error is returned synchronously. A service logic error is returned via AsyncCallback or the error object of Promise.

Change Impacts

The application developed based on earlier versions needs to adapt the method for returning API error information. Otherwise, the original service logic will be affected.

Key API/Component Changes

Deprecated APIs of the wallpaper management service: - getColors(wallpaperType: WallpaperType, callback: AsyncCallback>): void; - getColors(wallpaperType: WallpaperType): Promise>; - getId(wallpaperType: WallpaperType, callback: AsyncCallback): void; - getId(wallpaperType: WallpaperType): Promise; - getMinHeight(callback: AsyncCallback): void; - getMinHeight(): Promise; - getMinWidth(callback: AsyncCallback): void; - getMinWidth(): Promise; - isChangePermitted(callback: AsyncCallback): void; - isChangePermitted(): Promise; - isOperationAllowed(callback: AsyncCallback): void; - isOperationAllowed(): Promise; - reset(wallpaperType: WallpaperType, callback: AsyncCallback): void; - reset(wallpaperType: WallpaperType): Promise; - setWallpaper(source: string|image.PixelMap, wallpaperType: WallpaperType, callback: AsyncCallback): void; - setWallpaper(source: string|image.PixelMap, wallpaperType: WallpaperType): Promise; - getFile(wallpaperType: WallpaperType, callback: AsyncCallback): void; - getFile(wallpaperType: WallpaperType): Promise; - getPixelMap(wallpaperType: WallpaperType, callback: AsyncCallback): void; - getPixelMap(wallpaperType: WallpaperType): Promise;

Substitute APIs of the wallpaper management service: - getColorsSync(wallpaperType: WallpaperType): Array; - getIdSync(wallpaperType: WallpaperType): number; - getMinHeightSync(): number; - getMinWidthSync(): number; - isChangeAllowed(): boolean; - isUserChangeAllowed(): boolean; - restore(wallpaperType: WallpaperType, callback: AsyncCallback): void; - restore(wallpaperType: WallpaperType): Promise; - setImage(source: string|image.PixelMap, wallpaperType: WallpaperType, callback: AsyncCallback): void; - setImage(source: string|image.PixelMap, wallpaperType: WallpaperType): Promise; - getFileSync(wallpaperType: WallpaperType): number; - getImage(wallpaperType: WallpaperType, callback: AsyncCallback): void; - getImage(wallpaperType: WallpaperType): Promise;

Changed APIs of the wallpaper management service: - on(type: ‘colorChange’, callback: (colors: Array, wallpaperType: WallpaperType) => void): void - off(type: ‘colorChange’, callback?: (colors: Array, wallpaperType: WallpaperType) => void): void

Deprecated APIs of the lock screen management service: - isScreenLocked(callback: AsyncCallback): void; - isScreenLocked(): Promise; - isSecureMode(callback: AsyncCallback): void; - isSecureMode(): Promise; - unlockScreen(callback: AsyncCallback): void; - unlockScreen(): Promise;

Substitute APIs of the lock screen management service: - isLocked(): boolean; - isSecure(): boolean; - unlock(callback: AsyncCallback): void; - unlock():Promise;

Deleted APIs of the lock screen management service: - lockScreen(callback: AsyncCallback): void; - lockScreen(): Promise;

The following APIs are added for the lock screen management service: - lock(callback: AsyncCallback): void; - lock():Promise;

Changed APIs of the lock screen management service: - onSystemEvent(callback: Callback): boolean; - sendScreenLockEvent(event: String, parameter: number, callback: AsyncCallback): void; - sendScreenLockEvent(event: String, parameter: number): Promise;

Adaption Guide for the Wallpaper Management Service

The following uses getImage as an example for asynchronous APIs:

import pointer from '@ohos.wallpaper';
try {
    wallpaper.getImage(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => {
        console.log(`success to getImage: ${JSON.stringify(data)}`);
    }).catch((error) => {
        console.error(`failed to getImage because: ${JSON.stringify(error)}`);
    });
} catch (err) {
    console.error(`failed to getImage because: ${JSON.stringify(err)}`);
}

The following uses getFileSync as an example for synchronous APIs:

import pointer from '@ohos.wallpaper';
try {
    let file = wallpaper.getFileSync(wallpaper.WallpaperType.WALLPAPER_SYSTEM);
} catch (err) {
    console.error(`failed to getFileSync because: ${err.message}`);
}

Adaption Guide for the Lock Screen Management Service

The following uses lock as an example for asynchronous APIs:

import screenLock from '@ohos.screenlock';
try {
  screenLock.lock((err, data) => {      
    if (err) {
        console.error(`Failed to lock the screen, because: ${err.message}`);
        return;    
    }
    console.info(`lock the screen successfully. result: ${data}`);
  });
} catch (err) {
    console.error(`Failed to lock the screen, because: ${err.message}`);
}

The following uses onSystemEvent as an example for synchronous APIs:

import screenLock from '@ohos.screenlock';
try {
   let isSuccess = screenLock.onSystemEvent((event) => {
       console.log(`Register the system event which related to screenlock successfully. eventType: ${event.eventType}`)
   });
} catch (err) {
   console.error(`Failed to register the system event which related to screenlock, because: ${err.message}`)
}

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Account Subsystem ChangeLog

harmony 鸿蒙ChangeLog of JS API Changes in the Multimedia Subsystem

harmony 鸿蒙Device Manager ChangeLog

harmony 鸿蒙USB Manager ChangeLog

harmony 鸿蒙DSoftBus Subsystem ChangeLog

harmony 鸿蒙File Management Subsystem ChangeLog

harmony 鸿蒙Globalization Subsystem ChangeLog

harmony 鸿蒙Input Method Framework ChangeLog

harmony 鸿蒙Multimodal Input ChangeLog

harmony 鸿蒙Power Subsystem ChangeLog

0  赞