1# Theme Framework ChangeLog 2 3## cl.theme.1 Support of Exception Handling for APIs in API Version 9 4 5The 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. 6 - Wallpaper management service: **@ohos.wallpaper.d.ts** 7 8 - Lock screen management service: **@ohos.screenLock.d.ts** 9 10APIs in the preceding modules are changed as follows: 11Synchronous API: An error message is returned via an exception. 12Asynchronous API: A parameter check error is returned synchronously. A service logic error is returned via **AsyncCallback** or the **error** object of **Promise**. 13 14**Change Impacts** 15 16The application developed based on earlier versions needs to adapt the method for returning API error information. Otherwise, the original service logic will be affected. 17 18**Key API/Component Changes** 19 20Deprecated APIs of the wallpaper management service: 21 - getColors(wallpaperType: WallpaperType, callback: AsyncCallback<Array<RgbaColor>>): void; 22 - getColors(wallpaperType: WallpaperType): Promise<Array<RgbaColor>>; 23 - getId(wallpaperType: WallpaperType, callback: AsyncCallback<number>): void; 24 - getId(wallpaperType: WallpaperType): Promise<number>; 25 - getMinHeight(callback: AsyncCallback<number>): void; 26 - getMinHeight(): Promise<number>; 27 - getMinWidth(callback: AsyncCallback<number>): void; 28 - getMinWidth(): Promise<number>; 29 - isChangePermitted(callback: AsyncCallback<boolean>): void; 30 - isChangePermitted(): Promise<boolean>; 31 - isOperationAllowed(callback: AsyncCallback<boolean>): void; 32 - isOperationAllowed(): Promise<boolean>; 33 - reset(wallpaperType: WallpaperType, callback: AsyncCallback<void>): void; 34 - reset(wallpaperType: WallpaperType): Promise<void>; 35 - setWallpaper(source: string | image.PixelMap, wallpaperType: WallpaperType, callback: AsyncCallback<void>): void; 36 - setWallpaper(source: string | image.PixelMap, wallpaperType: WallpaperType): Promise<void>; 37 - getFile(wallpaperType: WallpaperType, callback: AsyncCallback<number>): void; 38 - getFile(wallpaperType: WallpaperType): Promise<number>; 39 - getPixelMap(wallpaperType: WallpaperType, callback: AsyncCallback<image.PixelMap>): void; 40 - getPixelMap(wallpaperType: WallpaperType): Promise<image.PixelMap>; 41 42Substitute APIs of the wallpaper management service: 43 - getColorsSync(wallpaperType: WallpaperType): Array<RgbaColor>; 44 - getIdSync(wallpaperType: WallpaperType): number; 45 - getMinHeightSync(): number; 46 - getMinWidthSync(): number; 47 - isChangeAllowed(): boolean; 48 - isUserChangeAllowed(): boolean; 49 - restore(wallpaperType: WallpaperType, callback: AsyncCallback<void>): void; 50 - restore(wallpaperType: WallpaperType): Promise<void>; 51 - setImage(source: string | image.PixelMap, wallpaperType: WallpaperType, callback: AsyncCallback<void>): void; 52 - setImage(source: string | image.PixelMap, wallpaperType: WallpaperType): Promise<void>; 53 - getFileSync(wallpaperType: WallpaperType): number; 54 - getImage(wallpaperType: WallpaperType, callback: AsyncCallback<image.PixelMap>): void; 55 - getImage(wallpaperType: WallpaperType): Promise<image.PixelMap>; 56 57Changed APIs of the wallpaper management service: 58 - on(type: 'colorChange', callback: (colors: Array<RgbaColor>, wallpaperType: WallpaperType) => void): void 59 - off(type: 'colorChange', callback?: (colors: Array<RgbaColor>, wallpaperType: WallpaperType) => void): void 60 61Deprecated APIs of the lock screen management service: 62 - isScreenLocked(callback: AsyncCallback<boolean>): void; 63 - isScreenLocked(): Promise<boolean>; 64 - isSecureMode(callback: AsyncCallback<boolean>): void; 65 - isSecureMode(): Promise<boolean>; 66 - unlockScreen(callback: AsyncCallback<void>): void; 67 - unlockScreen(): Promise<void>; 68 69Substitute APIs of the lock screen management service: 70 - isLocked(): boolean; 71 - isSecure(): boolean; 72 - unlock(callback: AsyncCallback<boolean>): void; 73 - unlock():Promise<boolean>; 74 75Deleted APIs of the lock screen management service: 76 - lockScreen(callback: AsyncCallback<void>): void; 77 - lockScreen(): Promise<void>; 78 79The following APIs are added for the lock screen management service: 80 - lock(callback: AsyncCallback<boolean>): void; 81 - lock():Promise<boolean>; 82 83Changed APIs of the lock screen management service: 84 - onSystemEvent(callback: Callback<SystemEvent>): boolean; 85 - sendScreenLockEvent(event: String, parameter: number, callback: AsyncCallback<boolean>): void; 86 - sendScreenLockEvent(event: String, parameter: number): Promise<boolean>; 87 88**Adaption Guide for the Wallpaper Management Service** 89 90The following uses **getImage** as an example for asynchronous APIs: 91 92```ts 93import pointer from '@ohos.wallpaper'; 94try { 95 wallpaper.getImage(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { 96 console.log(`success to getImage: ${JSON.stringify(data)}`); 97 }).catch((error) => { 98 console.error(`failed to getImage because: ${JSON.stringify(error)}`); 99 }); 100} catch (err) { 101 console.error(`failed to getImage because: ${JSON.stringify(err)}`); 102} 103 104``` 105 106The following uses **getFileSync** as an example for synchronous APIs: 107 108```ts 109import pointer from '@ohos.wallpaper'; 110try { 111 let file = wallpaper.getFileSync(wallpaper.WallpaperType.WALLPAPER_SYSTEM); 112} catch (err) { 113 console.error(`failed to getFileSync because: ${err.message}`); 114} 115``` 116 117**Adaption Guide for the Lock Screen Management Service** 118 119The following uses **lock** as an example for asynchronous APIs: 120 121```ts 122import screenLock from '@ohos.screenlock'; 123try { 124 screenLock.lock((err, data) => { 125 if (err) { 126 console.error(`Failed to lock the screen, because: ${err.message}`); 127 return; 128 } 129 console.info(`lock the screen successfully. result: ${data}`); 130 }); 131} catch (err) { 132 console.error(`Failed to lock the screen, because: ${err.message}`); 133} 134 135``` 136 137The following uses **onSystemEvent** as an example for synchronous APIs: 138 139```ts 140import screenLock from '@ohos.screenlock'; 141try { 142 let isSuccess = screenLock.onSystemEvent((event) => { 143 console.log(`Register the system event which related to screenlock successfully. eventType: ${event.eventType}`) 144 }); 145} catch (err) { 146 console.error(`Failed to register the system event which related to screenlock, because: ${err.message}`) 147} 148``` 149