提交 7a40b8c1 编写于 作者: G Gloria

Update docs against 21875+22433

Signed-off-by: wusongqing<wusongqing@huawei.com>
上级 71938187
# @ohos.WorkSchedulerExtensionAbility (Deferred Task Scheduling Callbacks)
The **WorkSchedulerExtensionAbility** module provides callbacks for deferred task scheduling.
When developing an application, you can override the APIs of this module and add your own task logic to the APIs.
The **WorkSchedulerExtensionAbility** module provides callbacks for deferred task scheduling. You can override the APIs provided by this module. When a deferred task is triggered, the system calls back the application through the APIs and processes the task logic in the callback.
> **NOTE**
>
> - The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> - The APIs of this module can be used only in the stage model.
## Modules to Import
```ts
......@@ -36,7 +34,7 @@ Called when the system starts scheduling the deferred task.
| Name | Type | Mandatory | Description |
| ---- | ---------------------------------------- | ---- | -------------- |
| work | [workScheduler.WorkInfo](js-apis-resourceschedule-workScheduler.md#workinfo) | Yes | Target task.|
| work | [workScheduler.WorkInfo](js-apis-resourceschedule-workScheduler.md#workinfo) | Yes | Deferred task that starts.|
**Example**
......@@ -60,7 +58,7 @@ Called when the system stops scheduling the deferred task.
| Name | Type | Mandatory | Description |
| ---- | ---------------------------------------- | ---- | -------------- |
| work | [workScheduler.WorkInfo](js-apis-resourceschedule-workScheduler.md#workinfo) | Yes | Target task.|
| work | [workScheduler.WorkInfo](js-apis-resourceschedule-workScheduler.md#workinfo) | Yes | Deferred task that stops.|
**Example**
......
# @ohos.distributedMissionManager (Distributed Mission Management)
The **distributedMissionManager** module implements system mission management across devices. You can use the APIs provided by this module to register or deregister a mission status listener, start or stop synchronizing a remote mission list, and continue a mission on a remote device.
The **distributedMissionManager** module implements mission management across devices. You can use the APIs provided by this module to register or deregister a mission status listener, start or stop synchronizing a remote mission list, and continue a mission on a remote device by mission ID or bundle name.
> **NOTE**
>
......@@ -14,7 +14,6 @@ The **distributedMissionManager** module implements system mission management ac
import distributedMissionManager from '@ohos.distributedMissionManager'
```
## distributedMissionManager.registerMissionListener
registerMissionListener(parameter: MissionDeviceInfo, options: MissionCallback, callback: AsyncCallback&lt;void&gt;): void;
......@@ -30,8 +29,8 @@ Registers a mission status listener. This API uses an asynchronous callback to r
| Name | Type | Mandatory | Description |
| --------- | --------------------------------------- | ---- | --------- |
| parameter | [MissionDeviceInfo](#missiondeviceinfo) | Yes | Information about the device to listen for.|
| options | [MissionCallback](#missioncallback) | Yes | Callback to register. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
| options | [MissionCallback](#missioncallback) | Yes | Callback to register.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. If the listener is registered, **err** is **undefined**. Otherwise, **err** is an error object.|
**Example**
......@@ -80,14 +79,14 @@ Registers a mission status listener. This API uses a promise to return the resul
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | -------- |
| parameter | [MissionDeviceInfo](#missiondeviceinfo) | Yes | Information about the device to listen for. |
| parameter | [MissionDeviceInfo](#missiondeviceinfo) | Yes | Information about the device to listen for. |
| options | <a href="#missioncallback">MissionCallback</a> | Yes | Callback to register.|
**Return value**
| Type | Description |
| ------------------- | ---------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
| Promise&lt;void&gt; | Promise that returns no value.|
**Example**
......@@ -123,7 +122,6 @@ Registers a mission status listener. This API uses a promise to return the resul
}
```
## distributedMissionManager.unRegisterMissionListener
unRegisterMissionListener(parameter: MissionDeviceInfo, callback: AsyncCallback&lt;void&gt;): void;
......@@ -138,8 +136,8 @@ Deregisters a mission status listener. This API uses an asynchronous callback to
| Name | Type | Mandatory | Description |
| --------- | --------------------------------------- | ---- | --------- |
| parameter | [MissionDeviceInfo](#missiondeviceinfo) | Yes | Information about the device to listen for. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
| parameter | [MissionDeviceInfo](#missiondeviceinfo) | Yes | Information about the device to listen for. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. If the listener is deregistered, **err** is **undefined**. Otherwise, **err** is an error object.|
**Example**
......@@ -159,7 +157,6 @@ Deregisters a mission status listener. This API uses an asynchronous callback to
}
```
## distributedMissionManager.unRegisterMissionListener
unRegisterMissionListener(parameter: MissionDeviceInfo): Promise&lt;void&gt;
......@@ -180,7 +177,7 @@ Deregisters a mission status listener. This API uses a promise to return the res
| Type | Description |
| ------------------- | ---------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
| Promise&lt;void&gt; |Promise that returns no value.|
**Example**
......@@ -215,7 +212,7 @@ Starts to synchronize the remote mission list. This API uses an asynchronous cal
| Name | Type | Mandatory | Description |
| --------- | ------------------------------------- | ---- | --------- |
| parameter | [MissionParameter](#missionparameter) | Yes | Parameters required for synchronization. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. If the synchronization is started, **err** is **undefined**. Otherwise, **err** is an error object.|
**Example**
......@@ -257,7 +254,7 @@ Starts to synchronize the remote mission list. This API uses a promise to return
| Type | Description |
| ------------------- | ---------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
| Promise&lt;void&gt; | Promise that returns no value.|
**Example**
......@@ -294,7 +291,7 @@ Stops synchronizing the remote mission list. This API uses an asynchronous callb
| Name | Type | Mandatory | Description |
| --------- | --------------------------------------- | ---- | --------- |
| parameter | [MissionDeviceInfo](#missiondeviceinfo) | Yes | Parameters required for synchronization. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. If the synchronization is stopped, **err** is **undefined**. Otherwise, **err** is an error object.|
**Example**
......@@ -334,7 +331,7 @@ Stops synchronizing the remote mission list. This API uses a promise to return t
| Type | Description |
| ------------------- | ---------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
| Promise&lt;void&gt; | Promise that returns no value.|
**Example**
......@@ -358,7 +355,7 @@ Stops synchronizing the remote mission list. This API uses a promise to return t
continueMission(parameter: ContinueDeviceInfo, options: ContinueCallback, callback: AsyncCallback&lt;void&gt;): void;
Continues a mission on a remote device. This API uses an asynchronous callback to return the result.
Continues a mission on a remote device, with the mission ID specified. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.MANAGE_MISSIONS and ohos.permission.DISTRIBUTED_DATASYNC
......@@ -370,7 +367,7 @@ Continues a mission on a remote device. This API uses an asynchronous callback t
| --------- | --------------------------------------- | ---- | ----- |
| parameter | [ContinueDeviceInfo](js-apis-inner-application-continueDeviceInfo.md) | Yes | Parameters required for mission continuation.|
| options | [ContinueCallback](js-apis-inner-application-continueCallback.md) | Yes | Callback invoked when the mission continuation is complete.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. If the mission is continued, **err** is **undefined**. Otherwise, **err** is an error object.|
**Error codes**
......@@ -416,7 +413,7 @@ For details about the error codes, see [Distributed Scheduler Error Codes](../er
continueMission(parameter: ContinueDeviceInfo, options: ContinueCallback): Promise&lt;void&gt;
Continues a mission on a remote device. This API uses a promise to return the result.
Continues a mission on a remote device, with the mission ID specified. This API uses a promise to return the result.
**Required permissions**: ohos.permission.MANAGE_MISSIONS and ohos.permission.DISTRIBUTED_DATASYNC
......@@ -433,7 +430,7 @@ Continues a mission on a remote device. This API uses a promise to return the re
| Type | Description |
| ------------------- | ---------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
| Promise&lt;void&gt; |Promise that returns no value.|
**Error codes**
......@@ -490,7 +487,7 @@ Continues a mission on a remote device, with the bundle name specified. This API
| Name | Type | Mandatory | Description |
| --------- | --------------------------------------- | ---- | ----- |
| parameter | [ContinueMissionInfo](./js-apis-inner-application-continueMissionInfo.md) | Yes | Parameters required for mission continuation.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked when the mission continuation is complete.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. If the mission is continued, **err** is **undefined**. Otherwise, **err** is an error object.|
**Error codes**
......@@ -546,7 +543,7 @@ Continues a mission on a remote device, with the bundle name specified. This API
| Type | Description |
| ------------------- | ---------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
| Promise&lt;void&gt; | Promise that returns no value.|
**Error codes**
......@@ -586,7 +583,7 @@ For details about the error codes, see [Distributed Scheduler Error Codes](../er
on(type: 'continueStateChange', callback: Callback&lt;{ state: ContinueState, info: ContinuableInfo }&gt;): void
Registers a listener for the mission continuation state of the current application.
Subscribes to continuation state change events of the current mission.
**Required permissions**: ohos.permission.MANAGE_MISSIONS
......@@ -596,8 +593,8 @@ Registers a listener for the mission continuation state of the current applicati
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | -------- |
| type | string | Yes | Type of the listener. The value is fixed at **'continueStateChange'**. |
| callback | Callback&lt;{&nbsp;state:&nbsp;[ContinueState](#continuestate10),&nbsp;info:&nbsp;[ContinuableInfo](./js-apis-inner-application-continuableInfo.md)&nbsp;}&gt; | Yes | Callback used to return the mission continuation state and information. |
| type | string | Yes | Event type. The value **'continueStateChange'** indicates the continuation state change event of the current mission. |
| callback | Callback&lt;{&nbsp;state:&nbsp;[ContinueState](#continuestate10),&nbsp;info:&nbsp;[ContinuableInfo](./js-apis-inner-application-continuableInfo.md)&nbsp;}&gt; | Yes | Callback used to return the continuation state and information of the current mission. |
**Example**
......@@ -615,7 +612,7 @@ Registers a listener for the mission continuation state of the current applicati
off(type: 'continueStateChange', callback?: Callback&lt;{ state: ContinueState, info: ContinuableInfo }&gt;): void
Deregisters a listener for the mission continuation state of the current application.
Unsubscribes from continuation state change events of the current mission.
**Required permissions**: ohos.permission.MANAGE_MISSIONS
......@@ -625,8 +622,8 @@ Deregisters a listener for the mission continuation state of the current applica
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | -------- |
| type | string | Yes | Type of the listener. The value is fixed at **'continueStateChange'**. |
| callback | Callback&lt;{&nbsp;state:&nbsp;[ContinueState](#continuestate10),&nbsp;info:&nbsp;[ContinuableInfo](./js-apis-inner-application-continuableInfo.md)&nbsp;}&gt; | No | Callback used for the listener to be deregistered. |
| type | string | Yes | Event type. The value **'continueStateChange'** indicates the continuation state change event of the current mission. |
| callback | Callback&lt;{&nbsp;state:&nbsp;[ContinueState](#continuestate10),&nbsp;info:&nbsp;[ContinuableInfo](./js-apis-inner-application-continuableInfo.md)&nbsp;}&gt; | No | Callback used to return the continuation state and information of the current mission.<br>If the callback is unspecified, all subscriptions to the specified event are canceled. |
**Example**
......@@ -688,5 +685,5 @@ Enumerates the mission continuation states.
| Name | Value | Description |
| ------------- | --------- | ------------------------------------------------------------ |
| ACTIVE | 0 | Mission continuation is activated for the current application. |
| INACTIVE | 1 | Mission continuation is not activated for the current application. |
| ACTIVE | 0 | Continuation is activated for the current mission. |
| INACTIVE | 1 | Continuation is not activated for the current mission. |
# @ohos.reminderAgentManager (reminderAgentManager)
# @ohos.reminderAgentManager (Agent-Powered Reminders)
The **reminderAgentManager** module provides APIs for publishing scheduled reminders through the reminder agent.
You can use the 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.
The **reminderAgentManager** module provides APIs related to agent-powered reminders. When your application is frozen or exits, the timing and notification functions of your application will be taken over by a system service running in the background. You can use the APIs to create scheduled reminders for countdown timers, calendar events, and alarm clocks.
> **NOTE**
>
......@@ -15,12 +13,15 @@ You can use the APIs to create scheduled reminders for countdown timers, calenda
import reminderAgentManager from'@ohos.reminderAgentManager';
```
## reminderAgentManager.publishReminder
publishReminder(reminderReq: ReminderRequest, callback: AsyncCallback\<number>): void
Publishes a reminder through the reminder agent. This API uses an asynchronous callback to return the result. It can be called only when notification is enabled for the application through [Notification.requestEnableNotification](js-apis-notification.md#notificationrequestenablenotification8).
Publishes a reminder. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> This API can be called only after the [Notification.requestEnableNotification](js-apis-notification.md#notificationrequestenablenotification8) permission is obtained.
**Required permissions**: ohos.permission.PUBLISH_AGENT_REMINDER
......@@ -28,10 +29,10 @@ Publishes a reminder through the reminder agent. This API uses an asynchronous c
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| reminderReq | [ReminderRequest](#reminderrequest) | Yes| Reminder to be published.|
| callback | AsyncCallback\<number> | Yes| Callback used to return the published reminder's ID.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| reminderReq | [ReminderRequest](#reminderrequest) | Yes| Request used for publishing the reminder.|
| callback | AsyncCallback\<number> | Yes| Callback used to return the published reminder's ID.|
**Error codes**
......@@ -62,26 +63,29 @@ try {
};
```
## reminderAgentManager.publishReminder
publishReminder(reminderReq: ReminderRequest): Promise\<number>
Publishes a reminder through the reminder agent. This API uses a promise to return the result. It can be called only when notification is enabled for the application through [Notification.requestEnableNotification](js-apis-notification.md#notificationrequestenablenotification8).
Publishes a reminder. This API uses a promise to return the result.
> **NOTE**
>
> This API can be called only after the [Notification.requestEnableNotification](js-apis-notification.md#notificationrequestenablenotification8) permission is obtained.
**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| Request used for publishing the reminder.|
**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.|
**Error codes**
......@@ -115,7 +119,7 @@ try {
cancelReminder(reminderId: number, callback: AsyncCallback\<void>): void
Cancels the reminder with the specified ID. This API uses an asynchronous callback to return the cancellation result.
Cancels a reminder published. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.ReminderAgent
......@@ -124,7 +128,7 @@ Cancels the reminder with the specified ID. This API uses an asynchronous callba
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| reminderId | number | Yes| ID of the reminder to cancel.|
| callback | AsyncCallback\<void> | Yes| Callback used to return the result.|
| callback | AsyncCallback\<void> | Yes| Callback used to return the result. If the reminder is canceled, **err** is **undefined**. Otherwise, **err** is an error object.|
**Error codes**
......@@ -151,12 +155,11 @@ try {
};
```
## reminderAgentManager.cancelReminder
cancelReminder(reminderId: number): Promise\<void>
Cancels the reminder with the specified ID. This API uses a promise to return the cancellation result.
Cancels a reminder published. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.ReminderAgent
......@@ -170,7 +173,7 @@ Cancels the reminder with the specified ID. This API uses a promise to return th
| Type| Description|
| -------- | -------- |
| Promise\<void> | Promise used to return the result.|
| Promise\<void> | Promise that returns no value.|
**Error codes**
......@@ -199,8 +202,7 @@ try {
getValidReminders(callback: AsyncCallback<Array\<ReminderRequest>>): void
Obtains all valid (not yet expired) reminders set by the current application. This API uses an asynchronous callback to return the reminders.
Obtains all valid (not yet expired) reminders set by the current application. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.ReminderAgent
......@@ -208,7 +210,7 @@ Obtains all valid (not yet expired) reminders set by the current application. Th
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback\<Array\<[ReminderRequest](#reminderrequest)>> | Yes| Asynchronous callback used to return an array of all valid reminders set by the current application.|
| callback | AsyncCallback\<Array\<[ReminderRequest](#reminderrequest)>> | Yes| Callback used to return all the valid reminders.|
**Error codes**
......@@ -259,7 +261,7 @@ try {
getValidReminders(): Promise\<Array\<ReminderRequest>>
Obtains all valid (not yet expired) reminders set by the current application. This API uses a promise to return the reminders.
Obtains all valid (not yet expired) reminders set by the current application. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.ReminderAgent
......@@ -267,7 +269,7 @@ Obtains all valid (not yet expired) reminders set by the current application. Th
| Type| Description|
| -------- | -------- |
| Promise\<Array\<[ReminderRequest](#reminderrequest)>> | Promise used to return an array of all valid reminders set by the current application.|
| Promise\<Array\<[ReminderRequest](#reminderrequest)>> | Promise used to return all the valid reminders.|
**Error codes**
......@@ -312,12 +314,11 @@ try {
};
```
## reminderAgentManager.cancelAllReminders
cancelAllReminders(callback: AsyncCallback\<void>): void
Cancels all reminders set by the current application. This API uses an asynchronous callback to return the cancellation result.
Cancels all reminders set by the current application. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.ReminderAgent
......@@ -325,7 +326,7 @@ Cancels all reminders set by the current application. This API uses an asynchron
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback\<void> | Yes| Callback used to return the result.|
| callback | AsyncCallback\<void> | Yes| Callback used to return the result. If all the reminders are canceled, **err** is **undefined**. Otherwise, **err** is an error object. |
**Error codes**
......@@ -351,12 +352,11 @@ try {
};
```
## reminderAgentManager.cancelAllReminders
cancelAllReminders(): Promise\<void>
Cancels all reminders set by the current application. This API uses a promise to return the cancellation result.
Cancels all reminders set by the current application. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.ReminderAgent
......@@ -364,7 +364,7 @@ Cancels all reminders set by the current application. This API uses a promise to
| Type| Description|
| -------- | -------- |
| Promise\<void> | Promise used to return the result.|
| Promise\<void> | Promise that returns no value.|
**Error codes**
......@@ -401,8 +401,8 @@ Adds a notification slot. This API uses an asynchronous callback to return the r
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| slot | [NotificationSlot](js-apis-notification.md#notificationslot) | Yes| Notification slot, whose type can be set.|
| callback | AsyncCallback\<void> | Yes| Callback used to return the result.|
| slot | [NotificationSlot](js-apis-notification.md#notificationslot) | Yes| Notification slot. Only the type can be set.|
| callback | AsyncCallback\<void> | Yes| Callback used to return the result. If the notification slot is added, **err** is **undefined**. Otherwise, **err** is an error object.|
**Example**
......@@ -438,13 +438,13 @@ Adds a 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, whose type can be set.|
| slot | [NotificationSlot](js-apis-notification.md#notificationslot) | Yes| Notification slot. Only the type can be set.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise\<void> | Promise used to return the result.|
| Promise\<void> | Promise that returns no value.|
**Example**
......@@ -470,7 +470,7 @@ try {
removeNotificationSlot(slotType: notification.SlotType, callback: AsyncCallback\<void>): void
Removes a notification slot of a specified type. This API uses an asynchronous callback to return the result.
Removes a notification slot. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.ReminderAgent
......@@ -479,7 +479,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 notification slot to remove.|
| callback | AsyncCallback\<void> | Yes| Callback used to return the result.|
| callback | AsyncCallback\<void> | Yes| Callback used to return the result. If the notification slot is removed, **err** is **undefined**. Otherwise, **err** is an error object.|
**Example**
......@@ -504,7 +504,7 @@ try {
removeNotificationSlot(slotType: notification.SlotType): Promise\<void>
Removes a notification slot of a specified type. This API uses a promise to return the result.
Removes a notification slot. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.ReminderAgent
......@@ -518,7 +518,7 @@ Removes a notification slot of a specified type. This API uses a promise to retu
| Type| Description|
| -------- | -------- |
| Promise\<void> | Promise used to return the result.|
| Promise\<void> | Promise that returns no value.|
**Example**
......@@ -538,7 +538,7 @@ try {
## ActionButtonType
Enumerates button types.
Enumerates the button types.
**System capability**: SystemCapability.Notification.ReminderAgent
......@@ -551,7 +551,7 @@ Enumerates button types.
## ReminderType
Enumerates reminder types.
Enumerates the reminder types.
**System capability**: SystemCapability.Notification.ReminderAgent
......@@ -564,8 +564,7 @@ Enumerates reminder types.
## ActionButton
Defines a button displayed for the reminder in the notification panel.
Defines the button on the reminder displayed.
**System capability**: SystemCapability.Notification.ReminderAgent
......@@ -573,7 +572,7 @@ Defines a button displayed for the reminder in the notification panel.
| -------- | -------- | -------- | -------- |
| title | string | Yes| Text on the button.|
| type | [ActionButtonType](#actionbuttontype) | Yes| Button type.|
| wantAgent<sup>10+</sup> | [WantAgent](#wantagent) | No| Ability information that is displayed after the button is clicked.<br>**System API**: This is a system API and cannot be called by third-party applications.|
| wantAgent<sup>10+</sup> | [WantAgent](#wantagent) | No| Information about the ability that is displayed after the button is clicked.<br>**System API**: This is a system API and cannot be called by third-party applications.|
## WantAgent
......@@ -592,19 +591,19 @@ Defines the information about the redirected-to ability.
## MaxScreenWantAgent
Provides the information about the target package and ability to start automatically when the reminder is displayed in full-screen mode. This API is reserved.
Provides the information about the ability that is started automatically and displayed in full-screen mode when the reminder arrives. This API is reserved.
**System capability**: SystemCapability.Notification.ReminderAgent
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| pkgName | string | Yes| Name of the package that is automatically started when the reminder arrives and the device is not in use.|
| abilityName | string | Yes| Name of the ability that is automatically started when the reminder arrives and the device is not in use.|
| pkgName | string | Yes| Name of the target package. (If the device is in use, only a notification banner is displayed.)|
| abilityName | string | Yes| Name of the target ability. (If the device is in use, only a notification banner is displayed.)|
## ReminderRequest
Defines the reminder to publish.
Defines the request for publishing a reminder.
**System capability**: SystemCapability.Notification.ReminderAgent
......@@ -613,7 +612,7 @@ Defines the reminder to publish.
| reminderType | [ReminderType](#remindertype) | Yes| Type of the reminder.|
| actionButton<sup></sup> | [ActionButton](#actionbutton) | No| Buttons displayed for the reminder in the notification panel.<br>- For common applications, a maximum of two buttons are supported.<br>- For system applications, a maximum of two buttons are supported in API version 9, and a maximum of three buttons are supported in API version 10 and later versions.|
| wantAgent | [WantAgent](#wantagent) | No| Information about the ability that is redirected to when the reminder is clicked.|
| maxScreenWantAgent | [MaxScreenWantAgent](#maxscreenwantagent) | No| Information about the ability that is automatically started when the reminder arrives. If the device is in use, a notification will be displayed.|
| maxScreenWantAgent | [MaxScreenWantAgent](#maxscreenwantagent) | No| Information about the ability that is started automatically and displayed in full-screen mode when the reminder arrives. If the device is in use, only a notification banner is displayed.<br> This API is reserved.|
| ringDuration | number | No| Ringing duration, in seconds. The default value is **1**.|
| snoozeTimes | number | No| Number of reminder snooze times. The default value is **0**.|
| timeInterval | number | No| Reminder snooze interval, in seconds. The minimum value is 5 minutes.|
......@@ -623,8 +622,8 @@ Defines the reminder to publish.
| snoozeContent | string | No| Content to be displayed when the reminder is snoozing.|
| notificationId | number | No| Notification ID used by the reminder. If there are reminders with the same notification ID, the later one will overwrite the earlier one.|
| slotType | [notification.SlotType](js-apis-notificationManager.md#slottype) | No| Type of the slot used by the reminder.|
| tapDismissed<sup>10+</sup> | boolean | No| Whether the notification is automatically cleared. The value is the same as that of [NotificationRequest.tapDismissed](js-apis-inner-notification-notificationRequest.md#notificationrequest).|
| autoDeletedTime<sup>10+</sup> | number | No| Time when the notification is automatically cleared. The value is the same as that of [NotificationRequest.autoDeletedTime](js-apis-inner-notification-notificationRequest.md#notificationrequest).|
| tapDismissed<sup>10+</sup> | boolean | No| Whether the reminder is automatically cleared. For details, see [NotificationRequest.tapDismissed](js-apis-inner-notification-notificationRequest.md#notificationrequest). |
| autoDeletedTime<sup>10+</sup> | number | No| Time when the reminder is automatically cleared. For details, see [NotificationRequest.autoDeletedTime](js-apis-inner-notification-notificationRequest.md#notificationrequest).|
## ReminderRequestCalendar
......
# @ohos.resourceschedule.workScheduler (Deferred Task Scheduling)
The **workScheduler** module provides the APIs for registering, canceling, and querying deferred tasks.
The system schedules and executes deferred tasks at an appropriate time, subject to the storage space, power consumption, temperature, and more.
The **workScheduler** module provides the APIs for registering, canceling, and querying deferred tasks. You can use the APIs to register tasks that do not have high requirements on real-time performance as deferred tasks. The system schedules and executes the deferred tasks at an appropriate time, subject to the storage space, power consumption, and more.
> **NOTE**
>
> - The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> - The APIs of this module can be used only in the stage model.
> - For details about the constraints on deferred task scheduling, see [Constraints](../../task-management/work-scheduler.md#constraints).
## Modules to Import
......@@ -18,9 +15,10 @@ import workScheduler from '@ohos.resourceschedule.workScheduler';
```
## workScheduler.startWork
startWork(work: WorkInfo): void
Instructs the WorkSchedulerService to add a task to the execution queue.
Starts a deferred task.
**System capability**: SystemCapability.ResourceSchedule.WorkScheduler
......@@ -28,7 +26,7 @@ Instructs the WorkSchedulerService to add a task to the execution queue.
| Name | Type | Mandatory | Description |
| ---- | --------------------- | ---- | -------------- |
| work | [WorkInfo](#workinfo) | Yes | Task to be added to the execution queue.|
| work | [WorkInfo](#workinfo) | Yes | Deferred task to start.|
**Error codes**
......@@ -42,7 +40,6 @@ For details about the error codes, see [workScheduler Error Codes](../errorcodes
| 9700004 | Check workInfo failed. |
| 9700005 | StartWork failed. |
**Example**
```js
......@@ -69,9 +66,10 @@ For details about the error codes, see [workScheduler Error Codes](../errorcodes
```
## workScheduler.stopWork
stopWork(work: WorkInfo, needCancel?: boolean): void
Instructs the WorkSchedulerService to stop a task.
Stops a deferred task.
**System capability**: SystemCapability.ResourceSchedule.WorkScheduler
......@@ -79,8 +77,8 @@ Instructs the WorkSchedulerService to stop a task.
| Name | Type | Mandatory | Description |
| ---------- | --------------------- | ---- | ---------- |
| work | [WorkInfo](#workinfo) | Yes | Task to stop. |
| needCancel | boolean | No | Whether to cancel the task. The default value is **false**.|
| work | [WorkInfo](#workinfo) | Yes | Deferred task to stop.|
| needCancel | boolean | No | Whether to clear the task while stopping it.<br>The value **true** means to clear the task while stopping it, and **false** means to stop the task only. The default value is **false**.|
**Error codes**
......@@ -119,9 +117,10 @@ For details about the error codes, see [workScheduler Error Codes](../errorcodes
```
## workScheduler.getWorkStatus
getWorkStatus(workId: number, callback : AsyncCallback\<WorkInfo>): void
Obtains the latest task status. This API uses an asynchronous callback to return the result.
Obtains the information a deferred task. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.ResourceSchedule.WorkScheduler
......@@ -129,8 +128,8 @@ Obtains the latest task status. This API uses an asynchronous callback to return
| Name | Type | Mandatory | Description |
| -------- | ------------------------------------- | ---- | ---------------------------------------- |
| workId | number | Yes | Task ID. |
| callback | AsyncCallback\<[WorkInfo](#workinfo)> | Yes | Callback used to return the result. If the specified task ID is valid, the task status obtained from the WorkSchedulerService is returned. Otherwise, an exception is thrown.|
| workId | number | Yes | ID of the deferred task. |
| callback | AsyncCallback\<[WorkInfo](#workinfo)> | Yes | Callback used to return the result. If **workId** is valid, the task information obtained from WorkSchedulerService is returned. Otherwise, an exception is thrown.|
**Error codes**
......@@ -162,9 +161,10 @@ For details about the error codes, see [workScheduler Error Codes](../errorcodes
```
## workScheduler.getWorkStatus
getWorkStatus(workId: number): Promise\<WorkInfo>
Obtains the latest task status. This API uses a promise to return the result.
Obtains the information a deferred task. This API uses a promise to return the result.
**System capability**: SystemCapability.ResourceSchedule.WorkScheduler
......@@ -172,13 +172,13 @@ Obtains the latest task status. This API uses a promise to return the result.
| Name | Type | Mandatory | Description |
| ------ | ------ | ---- | -------- |
| workId | number | Yes | Task ID.|
| workId | number | Yes | ID of the deferred task.|
**Return value**
| Type | Description |
| ------------------------------- | ---------------------------------------- |
| Promise\<[WorkInfo](#workinfo)> | Promise used to return the result. If the specified task ID is valid, the task status obtained from the WorkSchedulerService is returned. Otherwise, an exception is thrown.|
| Promise\<[WorkInfo](#workinfo)> | Promise used to return the result. If **workId** is valid, the task information obtained from WorkSchedulerService is returned.|
**Error codes**
......@@ -208,9 +208,10 @@ For details about the error codes, see [workScheduler Error Codes](../errorcodes
```
## workScheduler.obtainAllWorks
obtainAllWorks(callback : AsyncCallback\<void>): Array\<WorkInfo>
Obtains all tasks associated with the application. This API uses an asynchronous callback to return the result.
Obtains all the deferred tasks. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.ResourceSchedule.WorkScheduler
......@@ -218,13 +219,13 @@ Obtains all tasks associated with the application. This API uses an asynchronous
| Name | Type | Mandatory | Description |
| -------- | -------------------- | ---- | ------------------------------- |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result. |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If all the deferred tasks are obtained, **err** is **undefined**. Otherwise, **err** is an error object.|
**Return value**
| Type | Description |
| ----------------------------- | --------------- |
| Array\<[WorkInfo](#workinfo)> | All tasks associated with the application.|
| Array\<[WorkInfo](#workinfo)> | All the deferred tasks.|
**Error codes**
......@@ -253,9 +254,10 @@ For details about the error codes, see [workScheduler Error Codes](../errorcodes
```
## workScheduler.obtainAllWorks
obtainAllWorks(): Promise\<Array\<WorkInfo>>
Obtains all tasks associated with the application. This API uses a promise to return the result.
Obtains all the deferred tasks. This API uses a promise to return the result.
**System capability**: SystemCapability.ResourceSchedule.WorkScheduler
......@@ -263,7 +265,7 @@ Obtains all tasks associated with the application. This API uses a promise to re
| Type | Description |
| -------------------------------------- | ------------------------------ |
| Promise<Array\<[WorkInfo](#workinfo)>> | Promise used to return all tasks associated with the application.|
| Promise<Array\<[WorkInfo](#workinfo)>> | Promise used to return all the deferred tasks.|
**Error codes**
......@@ -290,9 +292,10 @@ For details about the error codes, see [workScheduler Error Codes](../errorcodes
```
## workScheduler.stopAndClearWorks
stopAndClearWorks(): void
Stops and cancels all tasks associated with the application.
Stops and clears all the deferred tasks.
**System capability**: SystemCapability.ResourceSchedule.WorkScheduler
......@@ -318,6 +321,7 @@ For details about the error codes, see [workScheduler Error Codes](../errorcodes
```
## workScheduler.isLastWorkTimeOut
isLastWorkTimeOut(workId: number, callback : AsyncCallback\<void>): boolean
Checks whether the last execution of a task timed out. This API uses an asynchronous callback to return the result.
......@@ -328,14 +332,14 @@ Checks whether the last execution of a task timed out. This API uses an asynchro
| Name | Type | Mandatory | Description |
| -------- | -------------------- | ---- | ---------------------------------------- |
| workId | number | Yes | Task ID. |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result. |
| workId | number | Yes | ID of the deferred task. |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Return value**
| Type | Description |
| ------- | ---------------------------------------- |
| boolean | Returns **true** if the last execution of the task timed out; returns **false** otherwise.|
| boolean | The value **true** means that the last execution of the specified task times out, and **false** means the opposite.|
**Error codes**
......@@ -365,6 +369,7 @@ For details about the error codes, see [workScheduler Error Codes](../errorcodes
```
## workScheduler.isLastWorkTimeOut
isLastWorkTimeOut(workId: number): Promise\<boolean>
Checks whether the last execution of a task timed out. This API uses a promise to return the result.
......@@ -375,13 +380,13 @@ Checks whether the last execution of a task timed out. This API uses a promise t
| Name | Type | Mandatory | Description |
| ------ | ------ | ---- | -------- |
| workId | number | Yes | Task ID.|
| workId | number | Yes | ID of the deferred task.|
**Return value**
| Type | Description |
| ----------------- | ---------------------------------------- |
| Promise\<boolean> | Promise used to return the result. If the last execution of the task timed out, **true** is returned. Otherwise, **false** is returned.|
| Promise\<boolean> | Promise used to return the result. The value **true** means that the last execution of the specified task times out, and **false** means the opposite.|
**Error codes**
......@@ -411,31 +416,33 @@ For details about the error codes, see [workScheduler Error Codes](../errorcodes
```
## WorkInfo
Provides detailed information about the task. For details about the constraints on setting the **WorkInfo** parameter, see [Constraints](../../task-management/work-scheduler.md#constraints).
Defines the information about the deferred task.
**System capability**: SystemCapability.ResourceSchedule.WorkScheduler
| Name | Type | Mandatory | Description |
| --------------- | --------------------------------- | ---- | ---------------- |
| workId | number | Yes | Task ID. |
| workId | number | Yes | ID of the deferred task. |
| bundleName | string | Yes | Bundle name of the application that requests the task. |
| abilityName | string | Yes | Name of the component to be notified by a deferred task scheduling callback.|
| networkType | [NetworkType](#networktype) | No | Network type. |
| isCharging | boolean | No | Whether the device is charging. |
| isCharging | boolean | No | Whether the device needs to enter the charging state to trigger deferred task scheduling.<br>The value **true** means that the device needs to enter the charging state to trigger deferred task scheduling, and **false** means the opposite.|
| chargerType | [ChargingType](#chargingtype) | No | Charging type. |
| batteryLevel | number | No | Battery level. |
| batteryLevel | number | No | Battery level. |
| batteryStatus | [BatteryStatus](#batterystatus) | No | Battery status. |
| storageRequest | [StorageRequest](#storagerequest) | No | Storage status. |
| isRepeat | boolean | No | Whether the task is repeated. |
| isRepeat | boolean | No | Whether the task is repeated.<br>The value** true** means that the task is repeated, and **false** means the opposite.|
| repeatCycleTime | number | No | Repeat interval. |
| repeatCount | number | No | Number of repeat times. |
| isPersisted | boolean | No | Whether to enable persistent storage for the task. |
| isDeepIdle | boolean | No | Whether the device needs to enter the idle state. |
| idleWaitTime | number | No | Time to wait in the idle state. |
| parameters | {[key: string]: number \| string \| boolean} | No | Carried parameters. |
| isPersisted | boolean | No | Whether to enable persistent storage for the task.<br>The value **true** means to enable persistent storage for the task, and **false** means the opposite.|
| isDeepIdle | boolean | No | Whether the device needs to enter the idle state to trigger deferred task scheduling.<br>The value **true** means that the device needs to enter the idle state to trigger deferred task scheduling, and **false** means the opposite. |
| idleWaitTime | number | No | Time to wait in the idle state before triggering deferred task scheduling. |
| parameters | [key: string]: number \| string \| boolean | No | Carried parameters.|
## NetworkType
Enumerates the network types that can trigger task scheduling.
Enumerates the network types that can trigger deferred task scheduling.
**System capability**: SystemCapability.ResourceSchedule.WorkScheduler
......@@ -449,7 +456,8 @@ Enumerates the network types that can trigger task scheduling.
| NETWORK_TYPE_ETHERNET | 5 | Ethernet. |
## ChargingType
Enumerates the charging types that can trigger task scheduling.
Enumerates the charging types that can trigger deferred task scheduling.
**System capability**: SystemCapability.ResourceSchedule.WorkScheduler
......@@ -461,7 +469,8 @@ Enumerates the charging types that can trigger task scheduling.
| CHARGING_PLUGGED_WIRELESS | 3 | Wireless charging. |
## BatteryStatus
Enumerates the battery states that can trigger task scheduling.
Enumerates the battery statuses that can trigger deferred task scheduling.
**System capability**: SystemCapability.ResourceSchedule.WorkScheduler
......@@ -472,7 +481,8 @@ Enumerates the battery states that can trigger task scheduling.
| BATTERY_STATUS_LOW_OR_OKAY | 2 | The battery level is restored from low to normal, or a low battery alert is displayed.|
## StorageRequest
Enumerates the storage states that can trigger task scheduling.
Enumerates the storage statuses that can trigger deferred task scheduling.
**System capability**: SystemCapability.ResourceSchedule.WorkScheduler
......@@ -480,4 +490,4 @@ Enumerates the storage states that can trigger task scheduling.
| ------------------------- | ---- | ------------------------------ |
| STORAGE_LEVEL_LOW | 0 | The storage space is insufficient. |
| STORAGE_LEVEL_OKAY | 1 | The storage space is restored from insufficient to normal. |
| STORAGE_LEVEL_LOW_OR_OKAY | 2 | The storage space is restored from insufficient to normal, or the storage space is insufficient.|
| STORAGE_LEVEL_LOW_OR_OKAY | 2 | The storage space is insufficient, or the storage space is restored from insufficient to normal.|
......@@ -62,8 +62,8 @@ The table below lists the APIs used for developing deferred tasks. For details a
| -------- | -------- |
| startWork(work: WorkInfo): void; | Starts a deferred task.|
| stopWork(work: WorkInfo, needCancel?: boolean): void; | Stops a deferred task.|
| getWorkStatus(workId: number, callback: AsyncCallback&lt;WorkInfo&gt;): void; | Obtains the status of a deferred task. This API uses an asynchronous callback to return the result.|
| getWorkStatus(workId: number): Promise&lt;WorkInfo&gt;; | Obtains the status of a deferred task. This API uses a promise to return the result.|
| getWorkStatus(workId: number, callback: AsyncCallback&lt;WorkInfo&gt;): void; | Obtains the information about a deferred task. This API uses an asynchronous callback to return the result.|
| getWorkStatus(workId: number): Promise&lt;WorkInfo&gt;; | Obtains the information about a deferred task. This API uses a promise to return the result.|
| obtainAllWorks(callback: AsyncCallback&lt;void&gt;): Array&lt;WorkInfo&gt;; | Obtains all the deferred tasks. This API uses an asynchronous callback to return the result.|
| obtainAllWorks(): Promise&lt;Array&lt;WorkInfo&gt;&gt;; | Obtains all the deferred tasks. This API uses a promise to return the result.|
| stopAndClearWorks(): void; | Stops and clears all the deferred tasks.|
......@@ -77,7 +77,7 @@ The table below lists the APIs used for developing deferred tasks. For details a
| bundleName | string | Bundle name of the application that requests the deferred task.|
| abilityName | string | Name of the ability to be notified by a deferred task scheduling callback. This parameter is mandatory.|
| networkType | [NetworkType](../reference/apis/js-apis-resourceschedule-workScheduler.md#networktype) | Network type.|
| isCharging | boolean | Whether the device is charging.|
| isCharging | boolean | Whether the device needs to enter the charging state to trigger deferred task scheduling.|
| chargerType | [ChargingType](../reference/apis/js-apis-resourceschedule-workScheduler.md#chargingtype) | Charging type.|
| batteryLevel | number | Battery level.|
| batteryStatus | [BatteryStatus](../reference/apis/js-apis-resourceschedule-workScheduler.md#batterystatus) | Battery status.|
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册