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