diff --git a/en/application-dev/reference/apis/js-apis-WorkSchedulerExtensionAbility.md b/en/application-dev/reference/apis/js-apis-WorkSchedulerExtensionAbility.md index b717abf0ad082e4ea7586cc8713596a08e7b3740..de2f146c7226f3a1ef3d61dad588c84b6cc2a1ab 100644 --- a/en/application-dev/reference/apis/js-apis-WorkSchedulerExtensionAbility.md +++ b/en/application-dev/reference/apis/js-apis-WorkSchedulerExtensionAbility.md @@ -1,15 +1,13 @@ # @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** diff --git a/en/application-dev/reference/apis/js-apis-distributedMissionManager.md b/en/application-dev/reference/apis/js-apis-distributedMissionManager.md index 93e460019144b0e321b1f39b4c41a37f9c908d37..ddc6fb296b8e88bd3866696cb7a0e409918c7745 100644 --- a/en/application-dev/reference/apis/js-apis-distributedMissionManager.md +++ b/en/application-dev/reference/apis/js-apis-distributedMissionManager.md @@ -1,6 +1,6 @@ # @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<void>): 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<void> | Yes | Callback used to return the result.| +| options | [MissionCallback](#missioncallback) | Yes | Callback to register.| +| callback | AsyncCallback<void> | 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 | MissionCallback | Yes | Callback to register.| **Return value** | Type | Description | | ------------------- | ---------------- | -| Promise<void> | Promise used to return the result.| +| Promise<void> | 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<void>): 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<void> | Yes | Callback used to return the result.| +| parameter | [MissionDeviceInfo](#missiondeviceinfo) | Yes | Information about the device to listen for. | +| callback | AsyncCallback<void> | 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<void> @@ -180,7 +177,7 @@ Deregisters a mission status listener. This API uses a promise to return the res | Type | Description | | ------------------- | ---------------- | -| Promise<void> | Promise used to return the result.| +| Promise<void> |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<void> | Yes | Callback used to return the result.| +| callback | AsyncCallback<void> | 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<void> | Promise used to return the result.| +| Promise<void> | 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<void> | Yes | Callback used to return the result.| +| callback | AsyncCallback<void> | 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<void> | Promise used to return the result.| +| Promise<void> | 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<void>): 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<void> | Yes | Callback used to return the result.| +| callback | AsyncCallback<void> | 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<void> -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<void> | Promise used to return the result.| +| Promise<void> |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<void> | Yes | Callback invoked when the mission continuation is complete.| +| callback | AsyncCallback<void> | 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<void> | Promise used to return the result.| +| Promise<void> | 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<{ state: ContinueState, info: ContinuableInfo }>): 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<{ state: [ContinueState](#continuestate10), info: [ContinuableInfo](./js-apis-inner-application-continuableInfo.md) }> | 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<{ state: [ContinueState](#continuestate10), info: [ContinuableInfo](./js-apis-inner-application-continuableInfo.md) }> | 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<{ state: ContinueState, info: ContinuableInfo }>): 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<{ state: [ContinueState](#continuestate10), info: [ContinuableInfo](./js-apis-inner-application-continuableInfo.md) }> | 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<{ state: [ContinueState](#continuestate10), info: [ContinuableInfo](./js-apis-inner-application-continuableInfo.md) }> | No | Callback used to return the continuation state and information of the current mission.
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. | diff --git a/en/application-dev/reference/apis/js-apis-reminderAgentManager.md b/en/application-dev/reference/apis/js-apis-reminderAgentManager.md index 644759435975c722de9fd274b704ecd01804d2fd..de1e1e04ddfc51d5e24ef783f022ab2f400f09dc 100644 --- a/en/application-dev/reference/apis/js-apis-reminderAgentManager.md +++ b/en/application-dev/reference/apis/js-apis-reminderAgentManager.md @@ -1,8 +1,6 @@ -# @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\): 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\ | 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\ | Yes| Callback used to return the published reminder's ID.| **Error codes** @@ -62,26 +63,29 @@ try { }; ``` - ## reminderAgentManager.publishReminder publishReminder(reminderReq: ReminderRequest): Promise\ -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\ | Promise used to return the published reminder's ID.| +| Type| Description| +| -------- | -------- | +| Promise\ | Promise used to return the published reminder's ID.| **Error codes** @@ -115,7 +119,7 @@ try { cancelReminder(reminderId: number, callback: AsyncCallback\): 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\ | Yes| Callback used to return the result.| +| callback | AsyncCallback\ | 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\ -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\ | Promise used to return the result.| +| Promise\ | Promise that returns no value.| **Error codes** @@ -199,8 +202,7 @@ try { getValidReminders(callback: AsyncCallback>): 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\> | Yes| Asynchronous callback used to return an array of all valid reminders set by the current application.| +| callback | AsyncCallback\> | Yes| Callback used to return all the valid reminders.| **Error codes** @@ -259,7 +261,7 @@ try { getValidReminders(): Promise\> -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\> | Promise used to return an array of all valid reminders set by the current application.| +| Promise\> | Promise used to return all the valid reminders.| **Error codes** @@ -312,12 +314,11 @@ try { }; ``` - ## reminderAgentManager.cancelAllReminders cancelAllReminders(callback: AsyncCallback\): 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\ | Yes| Callback used to return the result.| +| callback | AsyncCallback\ | 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\ -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\ | Promise used to return the result.| +| Promise\ | 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\ | 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\ | 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\ | Promise used to return the result.| +| Promise\ | Promise that returns no value.| **Example** @@ -470,7 +470,7 @@ try { removeNotificationSlot(slotType: notification.SlotType, callback: AsyncCallback\): 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\ | Yes| Callback used to return the result.| +| callback | AsyncCallback\ | 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\ -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\ | Promise used to return the result.| +| Promise\ | 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.| -| wantAgent10+ | [WantAgent](#wantagent) | No| Ability information that is displayed after the button is clicked.
**System API**: This is a system API and cannot be called by third-party applications.| +| wantAgent10+ | [WantAgent](#wantagent) | No| Information about the ability that is displayed after the button is clicked.
**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 | [ActionButton](#actionbutton) | No| Buttons displayed for the reminder in the notification panel.
- For common applications, a maximum of two buttons are supported.
- 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.
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.| -| tapDismissed10+ | 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).| -| autoDeletedTime10+ | 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).| +| tapDismissed10+ | boolean | No| Whether the reminder is automatically cleared. For details, see [NotificationRequest.tapDismissed](js-apis-inner-notification-notificationRequest.md#notificationrequest). | +| autoDeletedTime10+ | number | No| Time when the reminder is automatically cleared. For details, see [NotificationRequest.autoDeletedTime](js-apis-inner-notification-notificationRequest.md#notificationrequest).| ## ReminderRequestCalendar diff --git a/en/application-dev/reference/apis/js-apis-resourceschedule-backgroundTaskManager.md b/en/application-dev/reference/apis/js-apis-resourceschedule-backgroundTaskManager.md index d61b8272edee9b2b522139a9976df17027be98a5..99eb42bd5720fa12a833abcc030b45d02c7aefaf 100644 --- a/en/application-dev/reference/apis/js-apis-resourceschedule-backgroundTaskManager.md +++ b/en/application-dev/reference/apis/js-apis-resourceschedule-backgroundTaskManager.md @@ -1,16 +1,9 @@ # @ohos.resourceschedule.backgroundTaskManager (Background Task Management) -The **BackgroundTaskManager** module provides APIs to manage background tasks. - -If a service needs to be continued when the application or service module is running in the background (not visible to users), the application or service module can request a transient task to delay the suspension or a continuous task to prevent the suspension. - -If an application has a task that needs to be continued when the application is switched to the background and can be completed within a short period of time, the application can request a transient task. For example, if a user chooses to clear junk files in the **Files** application and exits the application, the application can request a transient task to complete the cleanup. - -If an application has a service that can be intuitively perceived by users and needs to run in the background for a long period of time (for example, music playback in the background), the application can request a continuous task. - -If a privileged system application needs to use certain system resources (for example, it wants to receive common events when suspended), it can request efficiency resources. +The **backgroundTaskManager** module provides APIs to request background tasks. You can use the APIs to request transient tasks, continuous tasks, or efficiency resources to prevent the application process from being terminated or suspended when your application is switched to the background. > **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. @@ -24,9 +17,11 @@ import backgroundTaskManager from '@ohos.resourceschedule.backgroundTaskManager' requestSuspendDelay(reason: string, callback: Callback<void>): DelaySuspendInfo -Requests delayed suspension after the application switches to the background. +Requests a transient task. -The default duration of delayed suspension is 3 minutes when the battery level is higher than or equal to the broadcast low battery level and 1 minute when the battery level is lower than the broadcast low battery level. +> **NOTE** +> +> The maximum duration of a transient task is 3 minutes in normal cases. In the case of a [low battery](js-apis-battery-info.md), the maximum duration is decreased to 1 minute. **System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask @@ -34,14 +29,14 @@ The default duration of delayed suspension is 3 minutes when the battery level i | Name | Type | Mandatory | Description | | -------- | -------------------- | ---- | ------------------------------ | -| reason | string | Yes | Reason for delayed transition to the suspended state. | -| callback | Callback<void> | Yes | Invoked when a delay is about to time out. Generally, this callback is used to notify the application 6 seconds before the delay times out.| +| reason | string | Yes | Reason for requesting the transient task. | +| callback | Callback<void> | Yes | Callback used to notify the application that the transient task is about to time out. Generally, the callback is invoked 6 seconds before the timeout.| **Return value** | Type | Description | | ------------------------------------- | --------- | -| [DelaySuspendInfo](#delaysuspendinfo) | Information about the suspension delay.| +| [DelaySuspendInfo](#delaysuspendinfo) | Information about the transient task.| **Error codes** @@ -80,7 +75,7 @@ For details about the error codes, see [backgroundTaskManager Error Codes](../er getRemainingDelayTime(requestId: number, callback: AsyncCallback<number>): void -Obtains the remaining duration before the application is suspended. This API uses an asynchronous callback to return the result. +Obtains the remaining time of a transient task. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask @@ -88,8 +83,8 @@ Obtains the remaining duration before the application is suspended. This API use | Name | Type | Mandatory | Description | | --------- | --------------------------- | ---- | ---------------------------------------- | -| requestId | number | Yes | ID of the suspension delay request. | -| callback | AsyncCallback<number> | Yes | Callback used to return the remaining duration before the application is suspended, in milliseconds.| +| requestId | number | Yes | Request ID of the transient task. | +| callback | AsyncCallback<number> | Yes | Callback used to return the remaining time, in milliseconds.| **Error codes** @@ -129,9 +124,7 @@ For details about the error codes, see [backgroundTaskManager Error Codes](../er getRemainingDelayTime(requestId: number): Promise<number> -Obtains the remaining duration before the application is suspended. This API uses a promise to return the result. - - +Obtains the remaining time of a transient task. This API uses a promise to return the result. **System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask @@ -139,13 +132,13 @@ Obtains the remaining duration before the application is suspended. This API use | Name | Type | Mandatory | Description | | --------- | ------ | ---- | ---------- | -| requestId | number | Yes | ID of the suspension delay request.| +| requestId | number | Yes | Request ID of the transient task.| **Return value** | Type | Description | | --------------------- | ---------------------------------------- | -| Promise<number> | Promise used to return the remaining duration before the application is suspended, in milliseconds.| +| Promise<number> | Promise used to return the remaining time, in milliseconds.| **Error codes** @@ -182,7 +175,7 @@ For details about the error codes, see [backgroundTaskManager Error Codes](../er cancelSuspendDelay(requestId: number): void -Cancels the suspension delay. +Cancels a transient task. **System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask @@ -190,7 +183,7 @@ Cancels the suspension delay. | Name | Type | Mandatory | Description | | --------- | ------ | ---- | ---------- | -| requestId | number | Yes | ID of the suspension delay request.| +| requestId | number | Yes | Request ID of the transient task.| **Error codes** @@ -218,12 +211,11 @@ For details about the error codes, see [backgroundTaskManager Error Codes](../er } ``` - ## backgroundTaskManager.startBackgroundRunning startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: WantAgent, callback: AsyncCallback<void>): void -Requests a continuous task from the system. This API uses an asynchronous callback to return the result. +Requests a continuous task. This API uses an asynchronous callback to return the result. **Required permissions**: ohos.permission.KEEP_BACKGROUND_RUNNING @@ -234,9 +226,9 @@ Requests a continuous task from the system. This API uses an asynchronous callba | Name | Type | Mandatory | Description | | --------- | ---------------------------------- | ---- | ---------------------------------------- | | context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-inner-application-context.md).| -| bgMode | [BackgroundMode](#backgroundmode) | Yes | Background mode requested. | -| wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | Yes | Notification parameter, which is used to specify the target page that is redirected to when a continuous task notification is clicked. | -| callback | AsyncCallback<void> | Yes | Callback used to return the result. | +| bgMode | [BackgroundMode](#backgroundmode) | Yes | Continuous task mode. | +| wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | Yes | Notification parameters, which are used to specify the target page that is redirected to when a continuous task notification is clicked. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result. If the continuous task is requested, **err** is **undefined**. Otherwise, **err** is an error object. | **Error codes** @@ -301,7 +293,7 @@ export default class EntryAbility extends UIAbility { startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: WantAgent): Promise<void> -Requests a continuous task from the system. This API uses a promise to return the result. +Requests a continuous task. This API uses a promise to return the result. **Required permissions**: ohos.permission.KEEP_BACKGROUND_RUNNING @@ -312,14 +304,14 @@ Requests a continuous task from the system. This API uses a promise to return th | Name | Type | Mandatory | Description | | --------- | ---------------------------------- | ---- | ---------------------------------------- | | context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-inner-application-context.md).| -| bgMode | [BackgroundMode](#backgroundmode) | Yes | Background mode requested. | -| wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | Yes | Notification parameter, which is used to specify the target page that is redirected to when a continuous task notification is clicked. | +| bgMode | [BackgroundMode](#backgroundmode) | Yes | Continuous task mode. | +| wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | Yes | Notification parameters, which are used to specify the target page that is redirected to when a continuous task notification is clicked. | **Return value** | Type | Description | | -------------- | ---------------- | -| Promise\ | Promise used to return the result.| +| Promise\ | Promise that returns no value.| **Error codes** @@ -380,7 +372,7 @@ export default class EntryAbility extends UIAbility { stopBackgroundRunning(context: Context, callback: AsyncCallback<void>): void -Requests to cancel a continuous task. This API uses an asynchronous callback to return the result. +Cancels a continuous task. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask @@ -389,7 +381,7 @@ Requests to cancel a continuous task. This API uses an asynchronous callback to | Name | Type | Mandatory | Description | | -------- | ------------------------- | ---- | ---------------------------------------- | | context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-inner-application-context.md).| -| callback | AsyncCallback<void> | Yes | Callback used to return the result. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result. If the continuous task is canceled, **err** is **undefined**. Otherwise, **err** is an error object.| **Error codes** @@ -434,9 +426,7 @@ export default class EntryAbility extends UIAbility { stopBackgroundRunning(context: Context): Promise<void> -Requests to cancel a continuous task. This API uses a promise to return the result. - - +Cancels a continuous task. This API uses a promise to return the result. **System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask @@ -450,7 +440,7 @@ Requests to cancel a continuous task. This API uses a promise to return the resu | Type | Description | | -------------- | ---------------- | -| Promise\ | Promise used to return the result.| +| Promise\ | Promise that returns no value.| **Error codes** @@ -489,10 +479,9 @@ export default class EntryAbility extends UIAbility { ## backgroundTaskManager.applyEfficiencyResources -applyEfficiencyResources(request: [EfficiencyResourcesRequest](#efficiencyresourcesrequest)): void +applyEfficiencyResources(request: EfficiencyResourcesRequest): void -Requests efficiency resources from the system. -A process and its application can request the same type of resources at the same time, for example, CPU resources. When the application releases the resources, the same type of resources requested by the process are also released. +Requests efficiency resources. **System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply @@ -502,7 +491,7 @@ A process and its application can request the same type of resources at the same | Name | Type | Mandatory | Description | | ------- | ------- | ---- | ---------------------------------------- | -| request | [EfficiencyResourcesRequest](#efficiencyresourcesrequest) | Yes | Necessary information carried in the request, including the resource type and timeout interval. For details, see [EfficiencyResourcesRequest](#efficiencyresourcesrequest).| +| request | [EfficiencyResourcesRequest](#efficiencyresourcesrequest) | Yes | Necessary information carried in the request, including the resource type and timeout interval.| **Error codes** @@ -542,7 +531,7 @@ try { resetAllEfficiencyResources(): void -Releases all resources that have been requested. +Releases all efficiency resources. **System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply @@ -574,18 +563,19 @@ try { ## DelaySuspendInfo -Provides the information about the suspension delay. +Defines the information about the transient task. **System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask | Name | Type | Mandatory | Description | | --------------- | ------ | ---- | ---------------------------------------- | -| requestId | number | Yes | ID of the suspension delay request. | -| actualDelayTime | number | Yes | Actual suspension delay duration of the application, in milliseconds.
The default duration is 180000 when the battery level is higher than or equal to the broadcast low battery level and 60000 when the battery level is lower than the broadcast low battery level.| - +| requestId | number | Yes | Request ID of the transient task. | +| actualDelayTime | number | Yes | Actual duration of the transient task that the application requests, in milliseconds.
The maximum duration of a transient task is 3 minutes in normal cases. In the case of a [low battery](js-apis-battery-info.md), the maximum duration is decreased to 1 minute.| ## BackgroundMode +Enumerates the continuous task modes. + **System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask | Name | Value | Description | @@ -596,9 +586,9 @@ Provides the information about the suspension delay. | LOCATION | 4 | Positioning and navigation. | | BLUETOOTH_INTERACTION | 5 | Bluetooth-related task. | | MULTI_DEVICE_CONNECTION | 6 | Multi-device connection. | -| WIFI_INTERACTION | 7 | WLAN-related (system API).| -| VOIP | 8 | Audio and video calls (system API). | -| TASK_KEEPING | 9 | Computing task (effective only for specific devices). | +| WIFI_INTERACTION | 7 | WLAN-related.
**System API**: This is a system API.| +| VOIP | 8 |Audio and video calls.
**System API**: This is a system API.| +| TASK_KEEPING | 9 | Computing task (for specific devices only). | ## EfficiencyResourcesRequest @@ -611,10 +601,10 @@ Describes the parameters for requesting efficiency resources. | Name | Type | Mandatory | Description | | --------------- | ------ | ---- | ---------------------------------------- | | resourceTypes | number | Yes | Type of the resource to request. | -| isApply | boolean | Yes | Whether the request is used to apply for resources. The value **true** means that the request is used to apply for resources, and **false** means that the request is used to release resources. | +| isApply | boolean | Yes | Whether the request is used to apply for resources.
The value **true** means that the request is used to apply for resources, and **false** means that the request is used to release resources.| | timeOut | number | Yes | Duration for which the resource will be used, in milliseconds. | -| isPersist | boolean | No | Whether the resource is permanently held. If the value is **true**, **timeOut** is invalid. | -| isProcess | boolean | No | Whether the request is initiated by a process. The value **true** means that the request is initiated by a process, and **false** means that the request is initiated by an application. | +| isPersist | boolean | No | Whether the resource is permanently held. The default value is **false**.
The value **true** means that the resource is permanently held, and **false** means the resource is held within a given period of time.| +| isProcess | boolean | No | Whether the request is initiated by a process. The default value is **false**.
The value **true** means that the request is initiated by a process, and **false** means that the request is initiated by an application. | | reason | string | Yes | Reason for requesting the resource. | ## ResourceType @@ -627,12 +617,12 @@ Enumerates the efficiency resource types. | Name | Value | Description | | ----------------------- | ---- | --------------------- | -| CPU | 1 | CPU resources, which prevent the application from being suspended. | -| COMMON_EVENT | 2 | Common events are not proxied when the application is suspended.| -| TIMER | 4 | System timers are not proxied when the application is suspended.| -| WORK_SCHEDULER | 8 | Work Scheduler uses a loose control policy by default. For details about the constraints on the Work Scheduler usage, see [Constraints](../../task-management/work-scheduler.md#constraints).| -| BLUETOOTH | 16 | Bluetooth resources are not proxied when the application is suspended.| -| GPS | 32 | GPS resources are not proxied when the application is suspended.| -| AUDIO | 64 | Audio resources are not proxied when the application is suspended.| +| CPU | 1 | CPU resource. Such type of resource prevents an application from being suspended. | +| COMMON_EVENT | 2 | Common event resource. Such type of resource ensures that an application in the suspended state can receive common events.| +| TIMER | 4 | Timer resource. Such type of resource ensures that an application in the suspended state can be woken up by system timers.| +| WORK_SCHEDULER | 8 | Deferred task resource. Such type of resource provides a loose control policy for an application.| +| BLUETOOTH | 16 | Bluetooth resource. Such type of resource ensures that an application in the suspended state can be woken up by Bluetooth-related events.| +| GPS | 32 | GPS resource. Such type of resource ensures that an application in the suspended state can be woken up by GPS-related events.| +| AUDIO | 64 | Audio resource. Such type of resource prevents an application from being suspended when the application has an audio being played.| | RUNNING_LOCK10+ | 128 | RUNNING_LOCK resources are not proxied when the application is suspended.| | SENSOR10+ | 256 | Sensor callbacks are not intercepted.| diff --git a/en/application-dev/reference/apis/js-apis-resourceschedule-workScheduler.md b/en/application-dev/reference/apis/js-apis-resourceschedule-workScheduler.md index 85c085f6fb9ef65fb711aecbfe3610ab3d17f5d9..5fad64915cde48a0fe0150e83f1661bc0abb1aaa 100644 --- a/en/application-dev/reference/apis/js-apis-resourceschedule-workScheduler.md +++ b/en/application-dev/reference/apis/js-apis-resourceschedule-workScheduler.md @@ -1,15 +1,12 @@ # @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.
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\): 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\ -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\): Array\ -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\ | Yes | Callback used to return the result. | +| callback | AsyncCallback\ | 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\> -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> | Promise used to return all tasks associated with the application.| +| Promise> | 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\): 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\ | Yes | Callback used to return the result. | +| workId | number | Yes | ID of the deferred task. | +| callback | AsyncCallback\ | 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\ 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\ | Promise used to return the result. If the last execution of the task timed out, **true** is returned. Otherwise, **false** is returned.| +| Promise\ | 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.
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.
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.
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.
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.| diff --git a/en/application-dev/task-management/figures/bgtask_choice.png b/en/application-dev/task-management/figures/bgtask_choice.png index a5200006128dcead88e00da8434b4621e6c36472..8ac048571e10bf6ba902bf844ba2a7e02d5a9ddb 100644 Binary files a/en/application-dev/task-management/figures/bgtask_choice.png and b/en/application-dev/task-management/figures/bgtask_choice.png differ diff --git a/en/application-dev/task-management/work-scheduler.md b/en/application-dev/task-management/work-scheduler.md index ca419ee8142d7cf281b2e0ce30e6e64a37b01694..22c012478ff92d8ab81e0490b8cad570ad17362e 100644 --- a/en/application-dev/task-management/work-scheduler.md +++ b/en/application-dev/task-management/work-scheduler.md @@ -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<WorkInfo>): void; | Obtains the status of a deferred task. This API uses an asynchronous callback to return the result.| -| getWorkStatus(workId: number): Promise<WorkInfo>; | Obtains the status of a deferred task. This API uses a promise to return the result.| +| getWorkStatus(workId: number, callback: AsyncCallback<WorkInfo>): void; | Obtains the information about a deferred task. This API uses an asynchronous callback to return the result.| +| getWorkStatus(workId: number): Promise<WorkInfo>; | Obtains the information about a deferred task. This API uses a promise to return the result.| | obtainAllWorks(callback: AsyncCallback<void>): Array<WorkInfo>; | Obtains all the deferred tasks. This API uses an asynchronous callback to return the result.| | obtainAllWorks(): Promise<Array<WorkInfo>>; | 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.|