From 1a4270ef0ece7440113e8317f5e2f9de0ca6a916 Mon Sep 17 00:00:00 2001 From: "ester.zhou" Date: Thu, 7 Jul 2022 14:55:34 +0800 Subject: [PATCH] uu Signed-off-by: ester.zhou --- .../reference/apis/js-apis-reminderAgent.md | 51 ++-- .../reference/apis/js-apis-screen-lock.md | 229 ++++++++++++++---- 2 files changed, 212 insertions(+), 68 deletions(-) diff --git a/en/application-dev/reference/apis/js-apis-reminderAgent.md b/en/application-dev/reference/apis/js-apis-reminderAgent.md index abcc5caff8..24f01b3f40 100644 --- a/en/application-dev/reference/apis/js-apis-reminderAgent.md +++ b/en/application-dev/reference/apis/js-apis-reminderAgent.md @@ -1,6 +1,11 @@ -# Reminder Agent +# reminderAgent -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +The **reminderAgent** module provides APIs for publishing scheduled reminders through the reminder agent. + +You can set your application to use the reminder agent APIs to create scheduled reminders for countdown timers, calendar events, and alarm clocks. When the created reminders are published, the timing and pop-up notification functions of your application will be taken over by the reminder agent in the background when your application is frozen or exits. + +> **NOTE** +> > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -23,13 +28,13 @@ Publishes an agent-powered reminder. This API uses an asynchronous callback to r **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | reminderReq | [ReminderRequest](#reminderrequest) | Yes| Reminder to be published.| - | callback | AsyncCallback<number> | Yes| Asynchronous callback used to return the published reminder's ID.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| reminderReq | [ReminderRequest](#reminderrequest) | Yes| Reminder to be published.| +| callback | AsyncCallback<number> | Yes| Asynchronous callback used to return the published reminder's ID.| **Example** - ```js +```js let timer = { reminderType: reminderAgent.ReminderType.REMINDER_TYPE_TIMER, triggerTimeInSeconds: 10 @@ -37,7 +42,7 @@ Publishes an agent-powered reminder. This API uses an asynchronous callback to r reminderAgent.publishReminder(timer, (err, reminderId) => { console.log("callback, reminderId = " + reminderId); }); - ``` +``` ## reminderAgent.publishReminder @@ -46,20 +51,22 @@ publishReminder(reminderReq: ReminderRequest): Promise<number> Publishes an agent-powered reminder. This API uses a promise callback to return the result. +**Required permissions**: ohos.permission.PUBLISH_AGENT_REMINDER + **System capability**: SystemCapability.Notification.ReminderAgent **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | reminderReq | [ReminderRequest](#reminderrequest) | Yes| Reminder to be published.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| reminderReq | [ReminderRequest](#reminderrequest) | Yes| Reminder to be published.| **Return value** - | Type| Description| - | -------- | -------- | - | Promise<number> | Promise used to return the published reminder's ID.| +| Type| Description| +| -------- | -------- | +| Promise<number> | Promise used to return the published reminder's ID.| **Example** - ```js +```js let timer = { reminderType: reminderAgent.ReminderType.REMINDER_TYPE_TIMER, triggerTimeInSeconds: 10 @@ -67,7 +74,7 @@ Publishes an agent-powered reminder. This API uses a promise callback to return reminderAgent.publishReminder(timer).then((reminderId) => { console.log("promise, reminderId = " + reminderId); }); - ``` +``` ## reminderAgent.cancelReminder @@ -261,7 +268,7 @@ reminderAgent.cancelAllReminders().then(() => { addNotificationSlot(slot: NotificationSlot, callback: AsyncCallback<void>): void -Adds a reminder notification slot. This API uses an asynchronous callback to return the result. +Adds a notification slot. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.ReminderAgent @@ -269,7 +276,7 @@ Adds a reminder notification slot. This API uses an asynchronous callback to ret | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| slot | [NotificationSlot](js-apis-notification.md#notificationslot) | Yes| Notification slot to add, only support set its type attribute.| +| slot | [NotificationSlot](js-apis-notification.md#notificationslot) | Yes| Notification slot, whose type can be set.| | callback | AsyncCallback<void> | Yes| Asynchronous callback used to return the result.| **Example** @@ -290,7 +297,7 @@ reminderAgent.addNotificationSlot(mySlot, (err, data) => { addNotificationSlot(slot: NotificationSlot): Promise<void> -Adds a reminder notification slot. This API uses a promise to return the result. +Adds a notification slot. This API uses a promise to return the result. **System capability**: SystemCapability.Notification.ReminderAgent @@ -298,7 +305,7 @@ Adds a reminder notification slot. This API uses a promise to return the result. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| slot | [NotificationSlot](js-apis-notification.md#notificationslot) | Yes| notification slot to add, only support set its type attribute.| +| slot | [NotificationSlot](js-apis-notification.md#notificationslot) | Yes| Notification slot, whose type can be set.| **Return value** @@ -332,7 +339,7 @@ Removes a notification slot of a specified type. This API uses an asynchronous c | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| slotType | [notification.SlotType](js-apis-notification.md#slottype) | Yes| Type of the reminder notification slot to remove.| +| slotType | [notification.SlotType](js-apis-notification.md#slottype) | Yes| Type of the notification slot to remove.| | callback | AsyncCallback<void> | Yes| Asynchronous callback used to return the result.| **Example** @@ -358,7 +365,7 @@ Removes a notification slot of a specified type. This API uses a promise to retu | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| slotType | [notification.SlotType](js-apis-notification.md#slottype) | Yes| Type of the reminder notification slot to remove.| +| slotType | [notification.SlotType](js-apis-notification.md#slottype) | Yes| Type of the notification slot to remove.| **Return value** 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 3cbaa21a08..d75b957512 100644 --- a/en/application-dev/reference/apis/js-apis-screen-lock.md +++ b/en/application-dev/reference/apis/js-apis-screen-lock.md @@ -1,8 +1,8 @@ # Screen Lock Management - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** -> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> **NOTE** +> +> The initial APIs of this module are supported since API version … Newly added APIs will be marked with a superscript to indicate their earliest API version. ## Modules to Import @@ -17,17 +17,17 @@ import screenlock from '@ohos.screenLock'; isScreenLocked(callback: AsyncCallback<boolean>): void -Checks whether the screen is locked. This method uses an asynchronous callback to return the result. +Checks whether the screen is locked. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.MiscServices.ScreenLock -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<boolean> | Yes | Callback used to return the result. If **true** is returned, the screen is locked. If **false** is returned, the screen is not locked. | +**Parameters** +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<boolean> | Yes| Returns **true** if the screen is locked; returns **false** otherwise.| + +**Example** -- Example - ```js screenlock.isScreenLocked((err, data)=>{ if (err) { @@ -43,17 +43,17 @@ Checks whether the screen is locked. This method uses an asynchronous callback t isScreenLocked(): Promise<boolean> -Checks whether the screen is locked. This method uses a promise to return the result. +Checks whether the screen is locked. This API uses a promise to return the result. **System capability**: SystemCapability.MiscServices.ScreenLock -- Return Values - | Type | Description | - | -------- | -------- | - | Promise<boolean> | Promise used to return the result. | +**Return value** +| Type| Description| +| -------- | -------- | +| Promise<boolean> | Promise used to return the result.| + +**Example** -- Example - ```js screenlock.isScreenLocked().then((data) => { console.log('isScreenLocked success: data -> ${JSON.stringify(data)}'); @@ -68,19 +68,18 @@ Checks whether the screen is locked. This method uses a promise to return the re isSecureMode(callback: AsyncCallback<boolean>): void -Checks whether a device is in secure mode. This method uses an asynchronous callback to return the result. +Checks whether a device is in secure mode. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.MiscServices.ScreenLock +**Parameters** +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<boolean> | Yes| Returns **true** if the device is in secure mode; returns **false** otherwise.| -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<boolean> | Yes | Callback used to return the result. If **true** is returned, the device is in secure mode. If **false** is returned, the device is not in secure mode. | +**Example** -- Example - ```js screenlock.isSecureMode((err, data)=>{ if (err) { @@ -96,17 +95,17 @@ Checks whether a device is in secure mode. This method uses an asynchronous call isSecureMode(): Promise<boolean> -Checks whether a device is in secure mode. This method uses a promise to return the result. +Checks whether a device is in secure mode. This API uses a promise to return the result. **System capability**: SystemCapability.MiscServices.ScreenLock -- Return Values - | Type | Description | - | -------- | -------- | - | Promise<boolean> | Promise used to return the result. | +**Return value** +| Type| Description| +| -------- | -------- | +| Promise<boolean> | Promise used to return the result.| + +**Example** -- Example - ```js screenlock.isSecureMode().then((data) => { console.log('isSecureMode success: data->${JSON.stringify(data)}'); @@ -121,21 +120,20 @@ Checks whether a device is in secure mode. This method uses a promise to return unlockScreen(callback: AsyncCallback<void>): void -Unlocks the screen. This method uses an asynchronous callback to return the result. +Unlocks the screen. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.MiscServices.ScreenLock +**Parameters** +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the operation failed, an error message is returned.| -- Parameters - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<void> | Yes | Callback function. If the callback fails, an error message is returned. | +**Example** -- Example - ```js - screenlock.unlockScreen((err)=>{ + screenlock.unlockScreen((err) => { if (err) { console.error('unlockScreen callback error -> ${JSON.stringify(err)}'); return; @@ -149,17 +147,17 @@ Unlocks the screen. This method uses an asynchronous callback to return the resu unlockScreen(): Promise<void> -Unlocks the screen. This method uses a promise to return the result. +Unlocks the screen. This API uses a promise to return the result. **System capability**: SystemCapability.MiscServices.ScreenLock -- Return Values - | Type | Description | - | -------- | -------- | - | Promise<void> | Promise used to return the result. | +**Return value** +| Type| Description| +| -------- | -------- | +| Promise<void> | Promise used to return the result.| + +**Example** -- Example - ```js screenlock.unlockScreen().then(() => { console.log('unlockScreen success'); @@ -167,3 +165,142 @@ Unlocks the screen. This method uses a promise to return the result. console.error('unlockScreen fail, promise: err->${JSON.stringify(err)}'); }); ``` + +## screenlock.on9+ + +on(type: 'beginWakeUp' | 'endWakeUp' | 'beginScreenOn' | 'endScreenOn' | 'beginScreenOff' | 'endScreenOff' | 'unlockScreen' | 'beginExitAnimation', callback: Callback\): void + +Subscribes to screen lock status changes. + +**System capability**: SystemCapability.MiscServices.ScreenLock + +**Parameters** +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| type | string | Yes| Event type.
- **'beginWakeUp'**: Wakeup starts.
- **'endWakeUp'**: Wakeup ends.
- **'beginScreenOn'**: Screen turn-on starts.
- **'endScreenOn'**: Screen turn-on ends.
- **'beginScreenOff'**: Screen turn-off starts.
- **'endScreenOff'**: Screen turn-off ends.
- **'unlockScreen'**: The screen is unlocked.
- **'beginExitAnimation'**: Animation starts to exit. | +| callback | Callback\ | Yes| Callback used to return the result.| + +**Example** + + ```js + screenlock.on('beginWakeUp', () => { + console.log('beginWakeUp triggered'); + }); + ``` + +## screenlock.on9+ + +on(type: 'beginSleep' | 'endSleep' | 'changeUser', callback: Callback\): void + +Subscribes to screen lock status changes. + +**System capability**: SystemCapability.MiscServices.ScreenLock + +**Parameters** +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| type | string | Yes| Event type.
- **'beginSleep'**: The screen enters sleep mode.
- **'endSleep'**: The screen exits sleep mode.
- **'changeUser'**: The user is switched.| +| callback | Callback\ | Yes| Callback used to return the result. | + +**Example** + + ```js + screenlock.on('beginSleep', (why) => { + console.log('beginSleep triggered:' + why); + }); + ``` +## screenlock.on9+ + +on(type: 'screenlockEnabled', callback: Callback\): void + +Subscribes to screen lock status changes. + +**System capability**: SystemCapability.MiscServices.ScreenLock + +**Parameters** +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| type | string | Yes| Event type.
- **'screenlockEnabled'**: Screen lock is enabled.| +| callback | Callback\ | Yes| Callback used to return the result. | + +**Example** + + ```js + screenlock.on('screenlockEnabled', (isEnabled) => { + console.log('screenlockEnabled triggered, result:' + isEnabled); + }); + ``` + +## screenlock.off9+ + +off(type: 'beginWakeUp' | 'endWakeUp' | 'beginScreenOn' | 'endScreenOn' | 'beginScreenOff' | 'endScreenOff' + | 'unlockScreen' | 'beginExitAnimation' | 'screenlockEnabled' | 'beginSleep' | 'endSleep' | 'changeUser', callback: Callback\): void + +Unsubscribes from screen lock status changes. + +**System capability**: SystemCapability.MiscServices.ScreenLock + +**Parameters** +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| type | string | Yes| Event type.
- **'beginWakeUp'**: Wakeup starts.
- **'endWakeUp'**: Wakeup ends.
- **'beginScreenOn'**: Screen turn-on starts.
- **'endScreenOn'**: Screen turn-on ends.
- **'beginScreenOff'**: Screen turn-off starts.
- **'endScreenOff'**: Screen turn-off ends.
- **'unlockScreen'**: The screen is unlocked.
- **'beginExitAnimation'**: Animation starts to exit.
- **'screenlockEnabled'**: Screen lock is enabled.
- **'beginSleep'**: The screen enters sleep mode.
- **'endSleep'**: The screen exits sleep mode.
- **'changeUser'**: The user is switched.| +| callback | Callback\ | Yes| Callback used to return the result.| + +**Example** + + ```js + screenlock.off('beginWakeUp', () => { + console.log("callback"); + }); + ``` + +## screenlock.sendScreenLockEvent9+ + +sendScreenLockEvent(event: String, parameter: number, callback: AsyncCallback\): void + +Sends an event to the screen lock service. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.MiscServices.ScreenLock + +**Parameters** +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| event | String | Yes| Event type.
- **'unlockScreenResult'**: Screen unlock result.
- **'screenDrawDone'**: Screen drawing is complete.| +| parameter | number | Yes| Screen unlock status.
- **0**: The unlock is successful.
- **0**: The unlock failed.
- **2**: The unlock was canceled.| +| callback | AsyncCallback\ | Yes| Callback used to return the result.| + +**Example** + + ```js + screenlock.sendScreenLockEvent('unlockScreenResult', 0, (err, result) => { + console.log('sending result:' + result); + }); + ``` + +## screenlock.sendScreenLockEvent9+ + +sendScreenLockEvent(event: String, parameter: number): Promise + +Sends an event to the screen lock service. This API uses a promise to return the result. + +**System capability**: SystemCapability.MiscServices.ScreenLock + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| event | String | Yes| Event type.
- **'unlockScreenResult'**: Screen unlock result.
- **'screenDrawDone'**: Screen drawing is complete.| +| parameter | number | Yes| Screen unlock status.
- **0**: The unlock is successful.
- **0**: The unlock failed.
- **2**: The unlock was canceled.| + +**Return value** +| Type| Description| +| -------- | -------- | +| Promise\ | Promise used to return the result.| + +**Example** + + ```js + screenlock.sendScreenLockEvent('unlockScreenResult', 0).then((err, result) => { + console.log('sending result:' + result); + }); + ``` -- GitLab