1e41f4b71Sopenharmony_ci# Theme Framework Subsystem – Wallpaper Management Service Changelog 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci 4e41f4b71Sopenharmony_ci## cl.wallpaper.1 Permission Change of getColorsSync, getMinHeightSync, getMinWidthSync, restore, and setImage 5e41f4b71Sopenharmony_ciChanged the **getColorsSync**, **getMinHeightSync**, **getMinWidthSync**, restore, and **setImage** APIs to system APIs since API version 9. 6e41f4b71Sopenharmony_ci 7e41f4b71Sopenharmony_ciYou need to adapt your application based on the following information. 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ci**Change Impact** 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_ciThe JS API needs to be adapted for applications developed based on earlier versions. Otherwise, relevant functions will be affected. 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ci- Involved APIs: 14e41f4b71Sopenharmony_ci 15e41f4b71Sopenharmony_ci```js 16e41f4b71Sopenharmony_ci function getColorsSync(wallpaperType: WallpaperType): Array<RgbaColor>; 17e41f4b71Sopenharmony_ci function getMinHeightSync(): number; 18e41f4b71Sopenharmony_ci function getMinWidthSync(): number; 19e41f4b71Sopenharmony_ci function restore(wallpaperType: WallpaperType, callback: AsyncCallback<void>): void; 20e41f4b71Sopenharmony_ci function restore(wallpaperType: WallpaperType): Promise<void>; 21e41f4b71Sopenharmony_ci function setImage(source: string | image.PixelMap, wallpaperType: WallpaperType, callback: AsyncCallback<void>): void; 22e41f4b71Sopenharmony_ci function setImage(source: string | image.PixelMap, wallpaperType: WallpaperType): Promise<void>; 23e41f4b71Sopenharmony_ci``` 24e41f4b71Sopenharmony_ci 25e41f4b71Sopenharmony_ci- Before change: 26e41f4b71Sopenharmony_ci 27e41f4b71Sopenharmony_ci```js 28e41f4b71Sopenharmony_ci /** 29e41f4b71Sopenharmony_ci * Obtains the wallpaper colors for the wallpaper of the specified type. Returns rgbaColor type of array callback function. 30e41f4b71Sopenharmony_ci * @param wallpaperType Indicates the wallpaper type. 31e41f4b71Sopenharmony_ci * @returns { Array<RgbaColor> } the Array<RgbaColor> returned by the function. 32e41f4b71Sopenharmony_ci * @throws {BusinessError} 401 - parameter error. 33e41f4b71Sopenharmony_ci * @throws {BusinessError} 202 - permission verification failed, application which is not a system application uses system API. 34e41f4b71Sopenharmony_ci * @syscap SystemCapability.MiscServices.Wallpaper 35e41f4b71Sopenharmony_ci * @systemapi Hide this for inner system use. 36e41f4b71Sopenharmony_ci * @since 9 37e41f4b71Sopenharmony_ci */ 38e41f4b71Sopenharmony_ci function getColorsSync(wallpaperType: WallpaperType): Array<RgbaColor>; 39e41f4b71Sopenharmony_ci 40e41f4b71Sopenharmony_ci /** 41e41f4b71Sopenharmony_ci * Obtains the minimum height of the wallpaper. in pixels. returns 0 if no wallpaper has been set. 42e41f4b71Sopenharmony_ci * @returns { number } the number returned by the function. 43e41f4b71Sopenharmony_ci * @throws {BusinessError} 202 - permission verification failed, application which is not a system application uses system API. 44e41f4b71Sopenharmony_ci * @syscap SystemCapability.MiscServices.Wallpaper 45e41f4b71Sopenharmony_ci * @systemapi Hide this for inner system use. 46e41f4b71Sopenharmony_ci * @since 9 47e41f4b71Sopenharmony_ci */ 48e41f4b71Sopenharmony_ci function getMinHeightSync(): number; 49e41f4b71Sopenharmony_ci 50e41f4b71Sopenharmony_ci /** 51e41f4b71Sopenharmony_ci * Obtains the minimum width of the wallpaper. in pixels. returns 0 if no wallpaper has been set. 52e41f4b71Sopenharmony_ci * @returns { number } the number returned by the function. 53e41f4b71Sopenharmony_ci * @throws {BusinessError} 202 - permission verification failed, application which is not a system application uses system API. 54e41f4b71Sopenharmony_ci * @syscap SystemCapability.MiscServices.Wallpaper 55e41f4b71Sopenharmony_ci * @systemapi Hide this for inner system use. 56e41f4b71Sopenharmony_ci * @since 9 57e41f4b71Sopenharmony_ci */ 58e41f4b71Sopenharmony_ci function getMinWidthSync(): number; 59e41f4b71Sopenharmony_ci 60e41f4b71Sopenharmony_ci /** 61e41f4b71Sopenharmony_ci * Removes a wallpaper of the specified type and restores the default one. 62e41f4b71Sopenharmony_ci * @param wallpaperType Indicates the wallpaper type. 63e41f4b71Sopenharmony_ci * @throws {BusinessError} 401 - parameter error. 64e41f4b71Sopenharmony_ci * @throws {BusinessError} 201 - permission denied. 65e41f4b71Sopenharmony_ci * @throws {BusinessError} 202 - permission verification failed, application which is not a system application uses system API. 66e41f4b71Sopenharmony_ci * @permission ohos.permission.SET_WALLPAPER 67e41f4b71Sopenharmony_ci * @syscap SystemCapability.MiscServices.Wallpaper 68e41f4b71Sopenharmony_ci * @systemapi Hide this for inner system use. 69e41f4b71Sopenharmony_ci * @since 9 70e41f4b71Sopenharmony_ci */ 71e41f4b71Sopenharmony_ci function restore(wallpaperType: WallpaperType, callback: AsyncCallback<void>): void; 72e41f4b71Sopenharmony_ci 73e41f4b71Sopenharmony_ci /** 74e41f4b71Sopenharmony_ci * Removes a wallpaper of the specified type and restores the default one. 75e41f4b71Sopenharmony_ci * @param wallpaperType Indicates the wallpaper type. 76e41f4b71Sopenharmony_ci * @throws {BusinessError} 401 - parameter error. 77e41f4b71Sopenharmony_ci * @throws {BusinessError} 201 - permission denied. 78e41f4b71Sopenharmony_ci * @throws {BusinessError} 202 - permission verification failed, application which is not a system application uses system API. 79e41f4b71Sopenharmony_ci * @permission ohos.permission.SET_WALLPAPER 80e41f4b71Sopenharmony_ci * @syscap SystemCapability.MiscServices.Wallpaper 81e41f4b71Sopenharmony_ci * @systemapi Hide this for inner system use. 82e41f4b71Sopenharmony_ci * @since 9 83e41f4b71Sopenharmony_ci */ 84e41f4b71Sopenharmony_ci function restore(wallpaperType: WallpaperType): Promise<void>; 85e41f4b71Sopenharmony_ci 86e41f4b71Sopenharmony_ci /** 87e41f4b71Sopenharmony_ci * 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 file. 88e41f4b71Sopenharmony_ci * @param source Indicates the uri path from a JPEG or PNG file or the pixel map of the PNG file. 89e41f4b71Sopenharmony_ci * @param wallpaperType Indicates the wallpaper type. 90e41f4b71Sopenharmony_ci * @throws {BusinessError} 401 - parameter error. 91e41f4b71Sopenharmony_ci * @throws {BusinessError} 201 - permission denied. 92e41f4b71Sopenharmony_ci * @throws {BusinessError} 202 - permission verification failed, application which is not a system application uses system API. 93e41f4b71Sopenharmony_ci * @permission ohos.permission.SET_WALLPAPER 94e41f4b71Sopenharmony_ci * @syscap SystemCapability.MiscServices.Wallpaper 95e41f4b71Sopenharmony_ci * @systemapi Hide this for inner system use. 96e41f4b71Sopenharmony_ci * @since 9 97e41f4b71Sopenharmony_ci */ 98e41f4b71Sopenharmony_ci function setImage(source: string | image.PixelMap, wallpaperType: WallpaperType, callback: AsyncCallback<void>): void; 99e41f4b71Sopenharmony_ci 100e41f4b71Sopenharmony_ci /** 101e41f4b71Sopenharmony_ci * 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 file. 102e41f4b71Sopenharmony_ci * @param source Indicates the uri path from a JPEG or PNG file or the pixel map of the PNG file. 103e41f4b71Sopenharmony_ci * @param wallpaperType Indicates the wallpaper type. 104e41f4b71Sopenharmony_ci * @throws {BusinessError} 401 - parameter error. 105e41f4b71Sopenharmony_ci * @throws {BusinessError} 201 - permission denied. 106e41f4b71Sopenharmony_ci * @throws {BusinessError} 202 - permission verification failed, application which is not a system application uses system API. 107e41f4b71Sopenharmony_ci * @permission ohos.permission.SET_WALLPAPER 108e41f4b71Sopenharmony_ci * @syscap SystemCapability.MiscServices.Wallpaper 109e41f4b71Sopenharmony_ci * @systemapi Hide this for inner system use. 110e41f4b71Sopenharmony_ci * @since 9 111e41f4b71Sopenharmony_ci */ 112e41f4b71Sopenharmony_ci function setImage(source: string | image.PixelMap, wallpaperType: WallpaperType): Promise<void>; 113e41f4b71Sopenharmony_ci``` 114e41f4b71Sopenharmony_ci 115e41f4b71Sopenharmony_ci- After change: 116e41f4b71Sopenharmony_ci 117e41f4b71Sopenharmony_ci```js 118e41f4b71Sopenharmony_ci /** 119e41f4b71Sopenharmony_ci * Obtains the wallpaper colors for the wallpaper of the specified type. Returns rgbaColor type of array callback function. 120e41f4b71Sopenharmony_ci * @param wallpaperType Indicates the wallpaper type. 121e41f4b71Sopenharmony_ci * @returns { Array<RgbaColor> } the Array<RgbaColor> returned by the function. 122e41f4b71Sopenharmony_ci * @throws {BusinessError} 401 - parameter error. 123e41f4b71Sopenharmony_ci * @syscap SystemCapability.MiscServices.Wallpaper 124e41f4b71Sopenharmony_ci * @since 9 125e41f4b71Sopenharmony_ci */ 126e41f4b71Sopenharmony_ci function getColorsSync(wallpaperType: WallpaperType): Array<RgbaColor>; 127e41f4b71Sopenharmony_ci 128e41f4b71Sopenharmony_ci /** 129e41f4b71Sopenharmony_ci * Obtains the minimum height of the wallpaper. in pixels. returns 0 if no wallpaper has been set. 130e41f4b71Sopenharmony_ci * @returns { number } the number returned by the function. 131e41f4b71Sopenharmony_ci * @syscap SystemCapability.MiscServices.Wallpaper 132e41f4b71Sopenharmony_ci * @since 9 133e41f4b71Sopenharmony_ci */ 134e41f4b71Sopenharmony_ci function getMinHeightSync(): number; 135e41f4b71Sopenharmony_ci 136e41f4b71Sopenharmony_ci /** 137e41f4b71Sopenharmony_ci * Obtains the minimum width of the wallpaper. in pixels. returns 0 if no wallpaper has been set. 138e41f4b71Sopenharmony_ci * @returns { number } the number returned by the function. 139e41f4b71Sopenharmony_ci * @syscap SystemCapability.MiscServices.Wallpaper 140e41f4b71Sopenharmony_ci * @since 9 141e41f4b71Sopenharmony_ci */ 142e41f4b71Sopenharmony_ci function getMinWidthSync(): number; 143e41f4b71Sopenharmony_ci 144e41f4b71Sopenharmony_ci /** 145e41f4b71Sopenharmony_ci * Removes a wallpaper of the specified type and restores the default one. 146e41f4b71Sopenharmony_ci * @param wallpaperType Indicates the wallpaper type. 147e41f4b71Sopenharmony_ci * @throws {BusinessError} 401 - parameter error. 148e41f4b71Sopenharmony_ci * @throws {BusinessError} 201 - permission denied. 149e41f4b71Sopenharmony_ci * @permission ohos.permission.SET_WALLPAPER 150e41f4b71Sopenharmony_ci * @syscap SystemCapability.MiscServices.Wallpaper 151e41f4b71Sopenharmony_ci * @since 9 152e41f4b71Sopenharmony_ci */ 153e41f4b71Sopenharmony_ci function restore(wallpaperType: WallpaperType, callback: AsyncCallback<void>): void; 154e41f4b71Sopenharmony_ci 155e41f4b71Sopenharmony_ci /** 156e41f4b71Sopenharmony_ci * Removes a wallpaper of the specified type and restores the default one. 157e41f4b71Sopenharmony_ci * @param wallpaperType Indicates the wallpaper type. 158e41f4b71Sopenharmony_ci * @throws {BusinessError} 401 - parameter error. 159e41f4b71Sopenharmony_ci * @throws {BusinessError} 201 - permission denied. 160e41f4b71Sopenharmony_ci * @permission ohos.permission.SET_WALLPAPER 161e41f4b71Sopenharmony_ci * @syscap SystemCapability.MiscServices.Wallpaper 162e41f4b71Sopenharmony_ci * @since 9 163e41f4b71Sopenharmony_ci */ 164e41f4b71Sopenharmony_ci function restore(wallpaperType: WallpaperType): Promise<void>; 165e41f4b71Sopenharmony_ci 166e41f4b71Sopenharmony_ci /** 167e41f4b71Sopenharmony_ci * 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 file. 168e41f4b71Sopenharmony_ci * @param source Indicates the uri path from a JPEG or PNG file or the pixel map of the PNG file. 169e41f4b71Sopenharmony_ci * @param wallpaperType Indicates the wallpaper type. 170e41f4b71Sopenharmony_ci * @throws {BusinessError} 401 - parameter error. 171e41f4b71Sopenharmony_ci * @throws {BusinessError} 201 - permission denied. 172e41f4b71Sopenharmony_ci * @permission ohos.permission.SET_WALLPAPER 173e41f4b71Sopenharmony_ci * @syscap SystemCapability.MiscServices.Wallpaper 174e41f4b71Sopenharmony_ci * @since 9 175e41f4b71Sopenharmony_ci */ 176e41f4b71Sopenharmony_ci function setImage(source: string | image.PixelMap, wallpaperType: WallpaperType, callback: AsyncCallback<void>): void; 177e41f4b71Sopenharmony_ci 178e41f4b71Sopenharmony_ci /** 179e41f4b71Sopenharmony_ci * 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 file. 180e41f4b71Sopenharmony_ci * @param source Indicates the uri path from a JPEG or PNG file or the pixel map of the PNG file. 181e41f4b71Sopenharmony_ci * @param wallpaperType Indicates the wallpaper type. 182e41f4b71Sopenharmony_ci * @throws {BusinessError} 401 - parameter error. 183e41f4b71Sopenharmony_ci * @throws {BusinessError} 201 - permission denied. 184e41f4b71Sopenharmony_ci * @permission ohos.permission.SET_WALLPAPER 185e41f4b71Sopenharmony_ci * @syscap SystemCapability.MiscServices.Wallpaper 186e41f4b71Sopenharmony_ci * @since 9 187e41f4b71Sopenharmony_ci */ 188e41f4b71Sopenharmony_ci function setImage(source: string | image.PixelMap, wallpaperType: WallpaperType): Promise<void>; 189e41f4b71Sopenharmony_ci``` 190e41f4b71Sopenharmony_ci 191e41f4b71Sopenharmony_ci 192e41f4b71Sopenharmony_ci**Adaptation Guide** 193e41f4b71Sopenharmony_ci 194e41f4b71Sopenharmony_ciMake sure the APIs are only invoked by system applications. 195e41f4b71Sopenharmony_ci 196e41f4b71Sopenharmony_ciThe code snippet is as follows: 197e41f4b71Sopenharmony_ci 198e41f4b71Sopenharmony_ci```js 199e41f4b71Sopenharmony_ci try { 200e41f4b71Sopenharmony_ci let colors = wallpaper.getColorsSync(wallpaper.WallpaperType.WALLPAPER_SYSTEM); 201e41f4b71Sopenharmony_ci console.log(`success to getColorsSync: ${JSON.stringify(colors)}`); 202e41f4b71Sopenharmony_ci } catch (error) { 203e41f4b71Sopenharmony_ci console.error(`failed to getColorsSync because: ${JSON.stringify(error)}`); 204e41f4b71Sopenharmony_ci } 205e41f4b71Sopenharmony_ci``` 206e41f4b71Sopenharmony_ci 207e41f4b71Sopenharmony_ci```js 208e41f4b71Sopenharmony_ci let minHeight = wallpaper.getMinHeightSync(); 209e41f4b71Sopenharmony_ci``` 210e41f4b71Sopenharmony_ci 211e41f4b71Sopenharmony_ci```js 212e41f4b71Sopenharmony_ci let minWidth = wallpaper.getMinWidthSync(); 213e41f4b71Sopenharmony_ci``` 214e41f4b71Sopenharmony_ci 215e41f4b71Sopenharmony_ci```js 216e41f4b71Sopenharmony_ci wallpaper.restore(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error) => { 217e41f4b71Sopenharmony_ci if (error) { 218e41f4b71Sopenharmony_ci console.error(`failed to restore because: ${JSON.stringify(error)}`); 219e41f4b71Sopenharmony_ci return; 220e41f4b71Sopenharmony_ci } 221e41f4b71Sopenharmony_ci console.log(`success to restore.`); 222e41f4b71Sopenharmony_ci }); 223e41f4b71Sopenharmony_ci``` 224e41f4b71Sopenharmony_ci 225e41f4b71Sopenharmony_ci```js 226e41f4b71Sopenharmony_ci wallpaper.restore(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then(() => { 227e41f4b71Sopenharmony_ci console.log(`success to restore.`); 228e41f4b71Sopenharmony_ci }).catch((error) => { 229e41f4b71Sopenharmony_ci console.error(`failed to restore because: ${JSON.stringify(error)}`); 230e41f4b71Sopenharmony_ci }); 231e41f4b71Sopenharmony_ci``` 232e41f4b71Sopenharmony_ci 233e41f4b71Sopenharmony_ci```js 234e41f4b71Sopenharmony_ci // The source type is string. 235e41f4b71Sopenharmony_ci let wallpaperPath = "/data/data/ohos.acts.aafwk.plrdtest.form/files/Cup_ic.jpg"; 236e41f4b71Sopenharmony_ci wallpaper.setImage(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error) => { 237e41f4b71Sopenharmony_ci if (error) { 238e41f4b71Sopenharmony_ci console.error(`failed to setImage because: ${JSON.stringify(error)}`); 239e41f4b71Sopenharmony_ci return; 240e41f4b71Sopenharmony_ci } 241e41f4b71Sopenharmony_ci console.log(`success to setImage.`); 242e41f4b71Sopenharmony_ci }); 243e41f4b71Sopenharmony_ci``` 244e41f4b71Sopenharmony_ci 245e41f4b71Sopenharmony_ci```js 246e41f4b71Sopenharmony_ci // The source type is string. 247e41f4b71Sopenharmony_ci let wallpaperPath = "/data/data/ohos.acts.aafwk.plrdtest.form/files/Cup_ic.jpg"; 248e41f4b71Sopenharmony_ci wallpaper.setImage(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then(() => { 249e41f4b71Sopenharmony_ci console.log(`success to setImage.`); 250e41f4b71Sopenharmony_ci }).catch((error) => { 251e41f4b71Sopenharmony_ci console.error(`failed to setImage because: ${JSON.stringify(error)}`); 252e41f4b71Sopenharmony_ci }); 253e41f4b71Sopenharmony_ci``` 254e41f4b71Sopenharmony_ci 255e41f4b71Sopenharmony_ci 256e41f4b71Sopenharmony_ci## cl.wallpaper.2 Deprecation of getIdSync, getFileSync, isChangeAllowed, isUserChangeAllowed, on, off, and RgbaColor 257e41f4b71Sopenharmony_ciDeprecated the **getIdSync**, **getFileSync**, **isChangeAllowed**, **isUserChangeAllowed**, **on**, **off**, and **RgbaColor** APIs since API version 9. 258e41f4b71Sopenharmony_ci 259e41f4b71Sopenharmony_ciYou need to adapt your application based on the following information. 260e41f4b71Sopenharmony_ci 261e41f4b71Sopenharmony_ci**Change Impact** 262e41f4b71Sopenharmony_ci 263e41f4b71Sopenharmony_ciThe APIs can no longer be used after being deleted. 264e41f4b71Sopenharmony_ci 265e41f4b71Sopenharmony_ci- Involved APIs: 266e41f4b71Sopenharmony_ci 267e41f4b71Sopenharmony_ci```js 268e41f4b71Sopenharmony_ci function getIdSync(wallpaperType: WallpaperType): number; 269e41f4b71Sopenharmony_ci function getFileSync(wallpaperType: WallpaperType): number; 270e41f4b71Sopenharmony_ci function isChangeAllowed(): boolean; 271e41f4b71Sopenharmony_ci function isUserChangeAllowed(): boolean; 272e41f4b71Sopenharmony_ci function on(type: 'colorChange', callback: (colors: Array<RgbaColor>, wallpaperType: WallpaperType) => void): void; 273e41f4b71Sopenharmony_ci function off(type: 'colorChange', callback?: (colors: Array<RgbaColor>, wallpaperType: WallpaperType) => void): void; 274e41f4b71Sopenharmony_ci interface RgbaColor { 275e41f4b71Sopenharmony_ci red: number; 276e41f4b71Sopenharmony_ci green: number; 277e41f4b71Sopenharmony_ci blue: number; 278e41f4b71Sopenharmony_ci alpha: number; 279e41f4b71Sopenharmony_ci } 280e41f4b71Sopenharmony_ci``` 281e41f4b71Sopenharmony_ci 282e41f4b71Sopenharmony_ci- Before change: 283e41f4b71Sopenharmony_ci 284e41f4b71Sopenharmony_ci```js 285e41f4b71Sopenharmony_ci function getIdSync(wallpaperType: WallpaperType): number; 286e41f4b71Sopenharmony_ci function getFileSync(wallpaperType: WallpaperType): number; 287e41f4b71Sopenharmony_ci function isChangeAllowed(): boolean; 288e41f4b71Sopenharmony_ci function isUserChangeAllowed(): boolean; 289e41f4b71Sopenharmony_ci function on(type: 'colorChange', callback: (colors: Array<RgbaColor>, wallpaperType: WallpaperType) => void): void; 290e41f4b71Sopenharmony_ci function off(type: 'colorChange', callback?: (colors: Array<RgbaColor>, wallpaperType: WallpaperType) => void): void; 291e41f4b71Sopenharmony_ci interface RgbaColor { 292e41f4b71Sopenharmony_ci red: number; 293e41f4b71Sopenharmony_ci green: number; 294e41f4b71Sopenharmony_ci blue: number; 295e41f4b71Sopenharmony_ci alpha: number; 296e41f4b71Sopenharmony_ci } 297e41f4b71Sopenharmony_ci``` 298e41f4b71Sopenharmony_ci 299e41f4b71Sopenharmony_ci- After change: 300e41f4b71Sopenharmony_ci 301e41f4b71Sopenharmony_ci The APIs are deleted. 302e41f4b71Sopenharmony_ci 303e41f4b71Sopenharmony_ci 304e41f4b71Sopenharmony_ci**Adaptation Guide** 305e41f4b71Sopenharmony_ci 306e41f4b71Sopenharmony_ciUpdate the code so that the deprecated APIs are not used. 307