提交 48446478 编写于 作者: W wusongqing

updated docs

Signed-off-by: Nwusongqing <wusongqing@huawei.com>
上级 62b028de
......@@ -120,7 +120,7 @@ For details about **wantAgent**, see [WantAgent](../reference/apis/js-apis-wantA
| MULTI_DEVICE_CONNECTION | 6 | Multi-device connection.| multiDeviceConnection |
| WIFI_INTERACTION | 7 | WLAN-related task (reserved).| wifiInteraction |
| VOIP | 8 | Voice and video call (reserved).| voip |
| TASK_KEEPING | 9 | Computing task (for PC only).| taskKeeping |
| TASK_KEEPING | 9 | Computing task (for specific devices only).| taskKeeping |
## How to Develop
......
......@@ -28,9 +28,9 @@ Adhere to the following constraints and rules when using transient tasks:
- **When to request**: An application can request a transient task only when it is running in the foreground or before it is suspended in the background. Otherwise, the application may be suspended, resulting in request failure. By default, an application has 6–12 seconds of running time (subject to the application scenario) before it is suspended in the background.
- **Timeout**: The system notifies the application of the suspension delay timeout by using a callback. The application must then cancel the delayed suspension or apply for delayed suspension again. Otherwise, the application will be forcibly suspended.
- **Timeout**: If a suspension delay is about to time out, the system notifies the application of the timeout by using a callback. The application must then cancel the delayed suspension. Otherwise, the application will be forcibly terminated.
- **When to cancel**: The requesting application shall cancel the request when the transient task is complete. If the request is forcibly canceled by the system, the time frame allowed for the application to run in the background will be affected.
- **When to cancel**: The requesting application shall proactively cancel the request when the transient task is complete, rather than waiting for a system callback. Otherwise, the time frame allowed for the application to run in the background will be affected.
- **Quota mechanism**: To prevent abuse of the keepalive, each application has a certain quota every day (dynamically adjusted based on user habits). After using up the quota, an application cannot request transient tasks. Therefore, applications should cancel their request immediately after the transient tasks are complete, to avoid quota consumption. (Note: The quota refers to the requested duration and does not include the time when the application runs in the background.)
......@@ -52,7 +52,7 @@ OpenHarmony provides 9 background modes for services that require continuous tas
| multiDeviceConnection | Distributed interconnection| A distributed task is running.| |
| wifiInteraction | WLAN transmission| A WLAN-related task is running.| System API, which is available only to system applications|
| voip | Voice and video calls over VoIP| A call-related task is running.| System API, which is available only to system applications|
| taskKeeping | Computing task| A computing task is running| PC-specific, valid only on PCs|
| taskKeeping | Computing task| A computing task is running| Effective only for specific devices|
### Restrictions on Using Continuous Tasks
- If a user triggers a perceivable task, such as broadcasting and navigation, the corresponding background mode is triggered. When the task is started, the system forcibly displays a notification to the user.
......
......@@ -22,15 +22,15 @@ The default duration of delayed suspension is 180000 when the battery level is h
**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------------------- | --------- | ---------------------------------------- |
| reason | string | Yes | Reason for delayed transition to the suspended state. |
| callback | Callback&lt;void&gt; | 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. |
| Name | Type | Mandatory | Description |
| -------- | -------------------- | ---- | ------------------------------ |
| reason | string | Yes | Reason for delayed transition to the suspended state. |
| callback | Callback&lt;void&gt; | 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.|
**Return value**
| Type | Description |
| ------------------------------------- | --------------------------------------- |
| [DelaySuspendInfo](#delaysuspendinfo) | Information about the suspension delay. |
| Type | Description |
| ------------------------------------- | --------- |
| [DelaySuspendInfo](#delaysuspendinfo) | Information about the suspension delay.|
**Example**
```js
......@@ -50,10 +50,10 @@ Obtains the remaining duration before the application is suspended. This API use
**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | --------------------------- | --------- | ---------------------------------------- |
| requestId | number | Yes | ID of the suspension delay request. |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the remaining duration before the application is suspended, in milliseconds. |
| Name | Type | Mandatory | Description |
| --------- | --------------------------- | ---- | ---------------------------------------- |
| requestId | number | Yes | ID of the suspension delay request. |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the remaining duration before the application is suspended, in milliseconds.|
**Example**
......@@ -78,14 +78,14 @@ Obtains the remaining duration before the application is suspended. This API use
**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ------ | --------- | ----------------------------------- |
| requestId | number | Yes | ID of the suspension delay request. |
| Name | Type | Mandatory | Description |
| --------- | ------ | ---- | ---------- |
| requestId | number | Yes | ID of the suspension delay request.|
**Return value**
| Type | Description |
| Type | Description |
| --------------------- | ---------------------------------------- |
| Promise&lt;number&gt; | Promise used to return the remaining duration before the application is suspended, in milliseconds. |
| Promise&lt;number&gt; | Promise used to return the remaining duration before the application is suspended, in milliseconds.|
**Example**
```js
......@@ -107,9 +107,9 @@ Cancels the suspension delay.
**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ------ | --------- | ----------------------------------- |
| requestId | number | Yes | ID of the suspension delay request. |
| Name | Type | Mandatory | Description |
| --------- | ------ | ---- | ---------- |
| requestId | number | Yes | ID of the suspension delay request.|
**Example**
```js
......@@ -128,12 +128,12 @@ Requests a continuous task from the system. This API uses an asynchronous callba
**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------- | --------- | ---------------------------------------- |
| context | [Context](js-apis-Context.md) | Yes | Application context. |
| bgMode | [BackgroundMode](#backgroundmode8) | Yes | Background mode requested. |
| wantAgent | [WantAgent](js-apis-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&lt;void&gt; | Yes | Callback used to return the result. |
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------- | ---- | ------------------------ |
| context | [Context](js-apis-Context.md) | Yes | Application context. |
| bgMode | [BackgroundMode](#backgroundmode8) | Yes | Background mode requested. |
| wantAgent | [WantAgent](js-apis-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&lt;void&gt; | Yes | Callback used to return the result. |
**Example**
```js
......@@ -180,15 +180,15 @@ Requests a continuous task from the system. This API uses a promise to return th
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------- | --------- | ---------------------------------------- |
| context | [Context](js-apis-Context.md) | Yes | Application context. |
| bgMode | [BackgroundMode](#backgroundmode8) | Yes | Background mode requested. |
| wantAgent | [WantAgent](js-apis-wantAgent.md) | Yes | Notification parameter, which is used to specify the target page when a continuous task notification is clicked. |
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------- | ---- | ----------------------- |
| context | [Context](js-apis-Context.md) | Yes | Application context. |
| bgMode | [BackgroundMode](#backgroundmode8) | Yes | Background mode requested. |
| wantAgent | [WantAgent](js-apis-wantAgent.md) | Yes | Notification parameter, which is used to specify the target page that is redirected to when a continuous task notification is clicked. |
**Return value**
| Type | Description |
| -------------- | ---------------------------------- |
| Type | Description |
| -------------- | ---------------- |
| Promise\<void> | Promise used to return the result. |
**Example**
......@@ -229,10 +229,10 @@ Requests to cancel a continuous task. This API uses an asynchronous callback to
**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ----------------------------- | --------- | ----------------------------------- |
| context | [Context](js-apis-Context.md) | Yes | Application context. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
| Name | Type | Mandatory | Description |
| -------- | ----------------------------- | ---- | ---------------------- |
| context | [Context](js-apis-Context.md) | Yes | Application context. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example**
```js
......@@ -260,13 +260,13 @@ Requests to cancel a continuous task. This API uses a promise to return the resu
**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
**Parameters**
| Name | Type | Mandatory | Description |
| ------- | ----------------------------- | --------- | -------------------- |
| context | [Context](js-apis-Context.md) | Yes | Application context. |
| Name | Type | Mandatory | Description |
| ------- | ----------------------------- | ---- | --------- |
| context | [Context](js-apis-Context.md) | Yes | Application context. |
**Return value**
| Type | Description |
| -------------- | ---------------------------------- |
| Type | Description |
| -------------- | ---------------- |
| Promise\<void> | Promise used to return the result. |
**Example**
......@@ -288,24 +288,24 @@ Provides the information about the suspension delay.
**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.<br>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. |
| 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.<br>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.|
## BackgroundMode<sup>8+</sup>
**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
| Name | Value | Description |
| ----------------------- | ----- | -------------------------------- |
| DATA_TRANSFER | 1 | Data transfer. |
| AUDIO_PLAYBACK | 2 | Audio playback. |
| AUDIO_RECORDING | 3 | Audio recording. |
| LOCATION | 4 | Positioning and navigation. |
| BLUETOOTH_INTERACTION | 5 | Bluetooth-related task. |
| MULTI_DEVICE_CONNECTION | 6 | Multi-device connection. |
| WIFI_INTERACTION | 7 | WLAN-related (reserved). |
| VOIP | 8 | Voice and video call (reserved). |
| TASK_KEEPING | 9 | Computing task. |
| Name | Value| Description |
| ----------------------- | ------ | ---------------------------- |
| DATA_TRANSFER | 1 | Data transfer. |
| AUDIO_PLAYBACK | 2 | Audio playback. |
| AUDIO_RECORDING | 3 | Audio recording. |
| LOCATION | 4 | Positioning and navigation. |
| BLUETOOTH_INTERACTION | 5 | Bluetooth-related task. |
| MULTI_DEVICE_CONNECTION | 6 | Multi-device connection. |
| WIFI_INTERACTION | 7 | WLAN-related (reserved). |
| VOIP | 8 | Voice and video call (reserved). |
| TASK_KEEPING | 9 | Computing task (effective only for specific devices).|
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册