harmony 鸿蒙Theme Framework ChangeLog
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
Substitute APIs of the wallpaper management service:
- getColorsSync(wallpaperType: WallpaperType): Array
Changed APIs of the wallpaper management service:
- on(type: ‘colorChange’, callback: (colors: Array
Deprecated APIs of the lock screen management service:
- isScreenLocked(callback: AsyncCallback
Substitute APIs of the lock screen management service:
- isLocked(): boolean;
- isSecure(): boolean;
- unlock(callback: AsyncCallback
Deleted APIs of the lock screen management service:
- lockScreen(callback: AsyncCallback
The following APIs are added for the lock screen management service:
- lock(callback: AsyncCallback
Changed APIs of the lock screen management service:
- onSystemEvent(callback: Callback
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
- 所属分类: 后端技术
- 本文标签:
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
8、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦