未验证 提交 225c4ab8 编写于 作者: O openharmony_ci 提交者: Gitee

!6487 翻译完成 5191:【misc软件服务子系统】screenlock add api docs

Merge pull request !6487 from ester.zhou/TR-5191
# 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**
......
# 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.on<sup>9+</sup>
on(type: 'beginWakeUp' | 'endWakeUp' | 'beginScreenOn' | 'endScreenOn' | 'beginScreenOff' | 'endScreenOff' | 'unlockScreen' | 'beginExitAnimation', callback: Callback\<void\>): void
Subscribes to screen lock status changes.
**System capability**: SystemCapability.MiscServices.ScreenLock
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type.<br>- **'beginWakeUp'**: Wakeup starts.<br>- **'endWakeUp'**: Wakeup ends.<br>- **'beginScreenOn'**: Screen turn-on starts.<br>- **'endScreenOn'**: Screen turn-on ends.<br>- **'beginScreenOff'**: Screen turn-off starts.<br>- **'endScreenOff'**: Screen turn-off ends.<br>- **'unlockScreen'**: The screen is unlocked.<br>- **'beginExitAnimation'**: Animation starts to exit. |
| callback | Callback\<void\> | Yes| Callback used to return the result.|
**Example**
```js
screenlock.on('beginWakeUp', () => {
console.log('beginWakeUp triggered');
});
```
## screenlock.on<sup>9+</sup>
on(type: 'beginSleep' | 'endSleep' | 'changeUser', callback: Callback\<number\>): void
Subscribes to screen lock status changes.
**System capability**: SystemCapability.MiscServices.ScreenLock
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type.<br>- **'beginSleep'**: The screen enters sleep mode.<br>- **'endSleep'**: The screen exits sleep mode.<br>- **'changeUser'**: The user is switched.|
| callback | Callback\<number\> | Yes| Callback used to return the result. |
**Example**
```js
screenlock.on('beginSleep', (why) => {
console.log('beginSleep triggered:' + why);
});
```
## screenlock.on<sup>9+</sup>
on(type: 'screenlockEnabled', callback: Callback\<boolean\>): void
Subscribes to screen lock status changes.
**System capability**: SystemCapability.MiscServices.ScreenLock
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type.<br>- **'screenlockEnabled'**: Screen lock is enabled.|
| callback | Callback\<boolean\> | Yes| Callback used to return the result. |
**Example**
```js
screenlock.on('screenlockEnabled', (isEnabled) => {
console.log('screenlockEnabled triggered, result:' + isEnabled);
});
```
## screenlock.off<sup>9+</sup>
off(type: 'beginWakeUp' | 'endWakeUp' | 'beginScreenOn' | 'endScreenOn' | 'beginScreenOff' | 'endScreenOff'
| 'unlockScreen' | 'beginExitAnimation' | 'screenlockEnabled' | 'beginSleep' | 'endSleep' | 'changeUser', callback: Callback\<void\>): void
Unsubscribes from screen lock status changes.
**System capability**: SystemCapability.MiscServices.ScreenLock
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type.<br>- **'beginWakeUp'**: Wakeup starts.<br>- **'endWakeUp'**: Wakeup ends.<br>- **'beginScreenOn'**: Screen turn-on starts.<br>- **'endScreenOn'**: Screen turn-on ends.<br>- **'beginScreenOff'**: Screen turn-off starts.<br>- **'endScreenOff'**: Screen turn-off ends.<br>- **'unlockScreen'**: The screen is unlocked.<br>- **'beginExitAnimation'**: Animation starts to exit.<br>- **'screenlockEnabled'**: Screen lock is enabled.<br>- **'beginSleep'**: The screen enters sleep mode.<br>- **'endSleep'**: The screen exits sleep mode.<br>- **'changeUser'**: The user is switched.|
| callback | Callback\<void\> | Yes| Callback used to return the result.|
**Example**
```js
screenlock.off('beginWakeUp', () => {
console.log("callback");
});
```
## screenlock.sendScreenLockEvent<sup>9+</sup>
sendScreenLockEvent(event: String, parameter: number, callback: AsyncCallback\<boolean\>): 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.<br>- **'unlockScreenResult'**: Screen unlock result.<br>- **'screenDrawDone'**: Screen drawing is complete.|
| parameter | number | Yes| Screen unlock status.<br>- **0**: The unlock is successful.<br>- **0**: The unlock failed.<br>- **2**: The unlock was canceled.|
| callback | AsyncCallback\<boolean\> | Yes| Callback used to return the result.|
**Example**
```js
screenlock.sendScreenLockEvent('unlockScreenResult', 0, (err, result) => {
console.log('sending result:' + result);
});
```
## screenlock.sendScreenLockEvent<sup>9+</sup>
sendScreenLockEvent(event: String, parameter: number): Promise<boolean>
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.<br>- **'unlockScreenResult'**: Screen unlock result.<br>- **'screenDrawDone'**: Screen drawing is complete.|
| parameter | number | Yes| Screen unlock status.<br>- **0**: The unlock is successful.<br>- **0**: The unlock failed.<br>- **2**: The unlock was canceled.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise\<boolean\> | Promise used to return the result.|
**Example**
```js
screenlock.sendScreenLockEvent('unlockScreenResult', 0).then((err, result) => {
console.log('sending result:' + result);
});
```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册