diff --git a/en/application-dev/reference/apis/js-apis-screen-lock.md b/en/application-dev/reference/apis/js-apis-screen-lock.md index 832d9754db5e41a11d38b020e77673ee5fe4d346..bc42373a4589e4ab2fa4b268d1472a1c7bb60ad2 100644 --- a/en/application-dev/reference/apis/js-apis-screen-lock.md +++ b/en/application-dev/reference/apis/js-apis-screen-lock.md @@ -170,6 +170,63 @@ Unlocks the screen. This API uses a promise to return the result. }); ``` + +## screenlock.lockScreen9+ + +lockScreen(callback: AsyncCallback<void>): void + + +Locks the screen. This API uses an asynchronous callback to return the result. + + +**System capability**: SystemCapability.MiscServices.ScreenLock + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the operation failed, an error message is returned.| + +**Example** + + ```js + screenlock.lockScreen((err) => { + if (err) { + console.error('lockScreen callback error -> ${JSON.stringify(err)}'); + return; + } + console.info('lockScreen callback success'); + }); + ``` + +## screenlock.lockScreen9+ + +lockScreen(): Promise<void> + +Locks the screen. This API uses a promise to return the result. + +**System capability**: SystemCapability.MiscServices.ScreenLock + +**System API**: This is a system API and cannot be called by third-party applications. + +**Return value** + +| Type| Description| +| -------- | -------- | +| Promise<void> | Promise used to return the result.| + +**Example** + + ```js + screenlock.lockScreen().then(() => { + console.log('lockScreen success'); + }).catch((err) => { + console.error('lockScreen fail, promise: err->${JSON.stringify(err)}'); + }); + ``` + + ## screenlock.on9+ on(type: 'beginWakeUp' | 'endWakeUp' | 'beginScreenOn' | 'endScreenOn' | 'beginScreenOff' | 'endScreenOff' | 'unlockScreen' | 'beginExitAnimation', callback: Callback\): void @@ -231,7 +288,7 @@ Subscribes to screen lock status changes. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | type | string | Yes| Event type.
- **"screenlockEnabled"**: Screen lock is enabled.| -| callback | Callback\ | Yes| Callback used to return the result.| +| callback | Callback\ | Yes| Callback used to return the result. | **Example**