提交 521b42b4 编写于 作者: E ester.zhou

update doc

Signed-off-by: Nester.zhou <ester.zhou@huawei.com>
上级 3b0a37bd
master E0523 OpenHarmony-3.1-API8-SDK-Public OpenHarmony-3.2-Beta1 OpenHarmony-3.2-Beta2 OpenHarmony-3.2-Beta3 OpenHarmony-3.2-Beta4 OpenHarmony-3.2-Beta5 OpenHarmony-3.2-Release OpenHarmony-4.0-Beta1 OpenHarmony-4.0-Beta2 OpenHarmony_filemanager_develop_20220505 OpenHarmony_filemanager_develop_20220614 TR4270 bak_OpenHarmony-4.0-Beta1_20230529 docs-modify feature_IDL_20220811 monthly_20220614 monthly_20220816 monthly_20221018 monthly_20230815 revert-merge-17651-master revert-merge-19334-OpenHarmony-4.0-Beta1 revert-merge-19586-master revert-merge-20613-master revert-merge-21757-OpenHarmony-4.0-Beta2 revert-merge-21765-OpenHarmony-4.0-Beta2 revert-merge-23766-master revert-merge-5580-master update_master_0323 weekly_20220406 weekly_20220412 weekly_20220419 weekly_20220426 weekly_20220503 weekly_20220510 weekly_20220524 weekly_20220531 weekly_20220607 weekly_20220614 weekly_20220621 weekly_20220628 weekly_20220705 weekly_20220712 weekly_20220719 weekly_20220726 weekly_20220802 weekly_20220809 weekly_20220816 weekly_20220823 weekly_20220830 weekly_20220906 weekly_20220913 weekly_20220920 weekly_20220927 weekly_20221004 weekly_20221011 weekly_20221018 weekly_20221025 weekly_20221101 weekly_20221108 weekly_20221115 weekly_20221122 weekly_20221129 weekly_20221206 weekly_20221213 weekly_20221220 weekly_20221227 weekly_20230103 weekly_20230110 weekly_20230117 weekly_20230124 weekly_20230131 weekly_20230207 weekly_20230214 weekly_20230221 weekly_20230228 weekly_20230307 weekly_20230314 weekly_20230321 weekly_20230328 weekly_20230404 weekly_20230411 weekly_20230418 weekly_20230425 weekly_20230502 weekly_20230509 weekly_20230516 weekly_20230523 weekly_20230530 weekly_20230606 weekly_20230613 weekly_20230619 weekly_20230626 weekly_20230627 weekly_20230704 weekly_20230712 weekly_20230725 weekly_20230801 weekly_20230808 weekly_20230815 weekly_20230822 weekly_20230829 weekly_20230905 OpenHarmony-v4.0-Beta2 OpenHarmony-v4.0-Beta1 OpenHarmony-v3.2.3-Release OpenHarmony-v3.2.2-Release OpenHarmony-v3.2.1-Release OpenHarmony-v3.2-Release OpenHarmony-v3.2-Beta5 OpenHarmony-v3.2-Beta4 OpenHarmony-v3.2-Beta3 OpenHarmony-v3.2-Beta2 OpenHarmony-v3.2-Beta1 OpenHarmony-v3.1.7-Release OpenHarmony-v3.1.6-Release OpenHarmony-v3.1.5-Release OpenHarmony-v3.1.4-Release OpenHarmony-v3.1.3-Release OpenHarmony-v3.1.2-Release OpenHarmony-v3.1.1-Release OpenHarmony-v3.1-Release
无相关合并请求
......@@ -11,30 +11,27 @@ import workScheduler from '@ohos.workScheduler'
```
## workScheduler.startWork
- **System capability**
SystemCapability.ResourceSchedule.WorkScheduler
startWork(work: WorkInfo): boolean
- **API**
workScheduler.startWork(work: WorkInfo): boolean
- **Description**
Instructs the **WorkSchedulerService** to add the specified task to the execution queue.
- **Parameters**
**System capability**: SystemCapability.ResourceSchedule.WorkScheduler
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| work | WorkInfo | Yes| Task to be added to the execution queue.|
| Name | Type | Mandatory | Description |
| ---- | --------------------- | ---- | -------------- |
| work | [WorkInfo](#workinfo) | Yes | Task to be added to the execution queue.|
- **Return value**
**Return value**
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the task is added to the execution queue; returns **false** otherwise.|
| Type | Description |
| ------- | -------------------------------- |
| boolean | Returns **true** if the task is added to the execution queue; returns **false** otherwise.|
- **Example**
**Example**
```
```
let workInfo = {
workId: 1,
batteryLevel:50,
......@@ -46,34 +43,31 @@ Instructs the **WorkSchedulerService** to add the specified task to the executio
}
var res = workScheduler.startWork(workInfo);
console.info("workschedulerLog res:" + res);
```
```
## workScheduler.stopWork
- **System capability**
SystemCapability.ResourceSchedule.WorkScheduler
- **API**
stopWork(work: WorkInfo, needCancel?: boolean): boolean
- **Description**
Instructs the **WorkSchedulerService** to stop the specified task.
- **Parameters**
**System capability**: SystemCapability.ResourceSchedule.WorkScheduler
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| work | WorkInfo | Yes| Task to stop.|
|needCancel|boolean| Yes| Whether to cancel the task.|
| Name | Type | Mandatory | Description |
| ---------- | --------------------- | ---- | ---------- |
| work | [WorkInfo](#workinfo) | Yes | Task to stop. |
| needCancel | boolean | Yes | Whether to cancel the task.|
- **Return value**
**Return value**
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
| Type | Description |
| ------- | ----------------------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
- **Example**
**Example**
```
```
let workInfo = {
workId: 1,
batteryLevel:50,
......@@ -85,29 +79,25 @@ Instructs the **WorkSchedulerService** to stop the specified task.
}
var res = workScheduler.stopWork(workInfo, false);
console.info("workschedulerLog res:" + res);
```
```
## workScheduler.getWorkStatus
- **System capability**
SystemCapability.ResourceSchedule.WorkScheduler
getWorkStatus(workId: number, callback : AsyncCallback\<WorkInfo>): void
- **API**
getWorkStatus(workId: number, callback : AsyncCallback<WorkInfo>): void
Obtains the latest task status. This API uses an asynchronous callback to return the result.
- **Description**
Obtains the latest task status. This method uses an asynchronous callback to return the result.
**System capability**: SystemCapability.ResourceSchedule.WorkScheduler
- **Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| workId | number | Yes| Task ID.|
|callback|AsyncCallback<WorkInfo>| Yes| Callback used to return the result. Returns the task status obtained from the **WorkSchedulerService** if the specified task ID is valid; returns **null** otherwise.|
| Name | Type | Mandatory | Description |
| -------- | ------------------------------------- | ---- | ---------------------------------------- |
| workId | number | Yes | Task ID. |
| callback | AsyncCallback\<[WorkInfo](#workinfo)> | Yes | Callback used to return the result. Returns the task status obtained from the **WorkSchedulerService** if the specified task ID is valid; returns **null** otherwise.|
**Example**
- **Example**
```
```
workScheduler.getWorkStatus(50, (err, res) => {
if (err) {
console.info('workschedulerLog getWorkStatus failed, because:' + err.data);
......@@ -117,33 +107,30 @@ Obtains the latest task status. This method uses an asynchronous callback to ret
}
}
});
```
```
## workScheduler.getWorkStatus
- **System capability**
SystemCapability.ResourceSchedule.WorkScheduler
getWorkStatus(workId: number): Promise\<WorkInfo>
- **API**
getWorkStatus(workID: number): Promise<WorkInfo>
Obtains the latest task status. This API uses a promise to return the result.
- **Description**
Obtains the latest task status. This method uses a promise to return the result.
**System capability**: SystemCapability.ResourceSchedule.WorkScheduler
- **Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| workId | number | Yes| Task ID.|
| Name | Type | Mandatory | Description |
| ------ | ------ | ---- | -------- |
| workId | number | Yes | Task ID.|
- **Return value**
**Return value**
| Type| Description|
| -------- | -------- |
| Promise<WorkInfo> | Promise used to return the result. Returns the task status obtained from the **WorkSchedulerService** if the specified task ID is valid; returns **null** otherwise.|
| Type | Description |
| ------------------------------- | ---------------------------------------- |
| Promise\<[WorkInfo](#workinfo)> | Promise used to return the result. Returns the task status obtained from the **WorkSchedulerService** if the specified task ID is valid; returns **null** otherwise.|
- **Example**
**Example**
```
```
workScheduler.getWorkStatus(50).then((res) => {
for (let item in res) {
console.info('workschedulerLog getWorkStatus success,' + item + ' is:' + res[item]);
......@@ -151,34 +138,30 @@ Obtains the latest task status. This method uses a promise to return the result.
}).catch((err) => {
console.info('workschedulerLog getWorkStatus failed, because:' + err.data);
})
```
```
## workScheduler.obtainAllWorks
- **System capability**
SystemCapability.ResourceSchedule.WorkScheduler
- **API**
obtainAllWorks(callback : AsyncCallback<void>): Array<WorkInfo>
obtainAllWorks(callback : AsyncCallback\<void>): Array\<WorkInfo>
- **Description**
Obtains all tasks associated with this application. This method uses an asynchronous callback to return the result.
Obtains all tasks associated with this application. This API uses an asynchronous callback to return the result.
- **Parameters**
**System capability**: SystemCapability.ResourceSchedule.WorkScheduler
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
|callback|AsyncCallback<WorkInfo>| Yes| Callback used to return all tasks associated with the current application.|
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------------------- | ---- | ------------------------------- |
| callback | AsyncCallback\<void> | Yes | Callback used to return all tasks associated with the current application.|
- **Return value**
**Return value**
| Type| Description|
| -------- | -------- |
| Array<WorkInfo> | All tasks associated with the current application.|
| Type | Description |
| ----------------------------- | --------------- |
| Array\<[WorkInfo](#workinfo)> | All tasks associated with the current application.|
- **Example**
**Example**
```
```
workScheduler.obtainAllWorks((err, res) =>{
if (err) {
console.info('workschedulerLog obtainAllWorks failed, because:' + err.data);
......@@ -186,77 +169,68 @@ Obtains all tasks associated with this application. This method uses an asynchro
console.info('workschedulerLog obtainAllWorks success, data is:' + JSON.stringify(res));
}
});
```
```
## workScheduler.obtainAllWorks
- **System capability**
SystemCapability.ResourceSchedule.WorkScheduler
obtainAllWorks(): Promise<Array\<WorkInfo>>
- **API**
obtainAllWorks(): Promise<Array<WorkInfo>>
Obtains all tasks associated with this application. This API uses a promise to return the result.
- **Description**
Obtains all tasks associated with this application. This method uses a promise to return the result.
**System capability**: SystemCapability.ResourceSchedule.WorkScheduler
- **Return value**
**Return value**
| Type| Description|
| -------- | -------- |
| Promise<Array<WorkInfo>> | Promise used to return all tasks associated with the current application.|
| Type | Description |
| -------------------------------------- | ------------------------------ |
| Promise<Array\<[WorkInfo](#workinfo)>> | Promise used to return all tasks associated with the current application.|
- **Example**
**Example**
```
```
workScheduler.obtainAllWorks().then((res) => {
console.info('workschedulerLog obtainAllWorks success, data is:' + JSON.stringify(res));
}).catch((err) => {
console.info('workschedulerLog obtainAllWorks failed, because:' + err.data);
})
```
```
## workScheduler.stopAndClearWorks
- **System capability**
SystemCapability.ResourceSchedule.WorkScheduler
- **API**
stopAndClearWorks(): boolean
- **Description**
Stops and cancels all tasks associated with the current application.
- **Example**
**System capability**: SystemCapability.ResourceSchedule.WorkScheduler
```
**Example**
```
let res = workScheduler.stopAndClearWorks();
console.info("workschedulerLog res:" + res);
```
```
## workScheduler.isLastWorkTimeOut
- **System capability**
SystemCapability.ResourceSchedule.WorkScheduler
isLastWorkTimeOut(workId: number, callback : AsyncCallback\<void>): boolean
- **API**
isLastWorkTimeOut(workId: number, callback : AsyncCallback<void>): boolean
Checks whether the last execution of the specified task timed out. This API uses an asynchronous callback to return the result.
- **Description**
Checks whether the last execution of the specified task timed out. This method uses an asynchronous callback to return the result.
**System capability**: SystemCapability.ResourceSchedule.WorkScheduler
- **Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| workId | number | Yes| Task ID.|
|callback|AsyncCallback<WorkInfo>| Yes| Callback used to return the result.|
| Name | Type | Mandatory | Description |
| -------- | -------------------- | ---- | ---------------------------------------- |
| workId | number | Yes | Task ID. |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
- **Return value**
**Return value**
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the last execution of the specified task timed out; returns **false** otherwise.|
| Type | Description |
| ------- | ---------------------------------------- |
| boolean | Returns **true** if the last execution of the specified task timed out; returns **false** otherwise.|
- **Example**
**Example**
```
```
workScheduler.isLastWorkTimeOut(500, (err, res) =>{
if (err) {
console.info('workschedulerLog isLastWorkTimeOut failed, because:' + err.data);
......@@ -264,33 +238,30 @@ Checks whether the last execution of the specified task timed out. This method u
console.info('workschedulerLog isLastWorkTimeOut success, data is:' + res);
}
});
```
```
## workScheduler.isLastWorkTimeOut
- **System capability**
SystemCapability.ResourceSchedule.WorkScheduler
isLastWorkTimeOut(workId: number): Promise\<boolean>
- **API**
isLastWorkTimeOut(workId: number): Promise<boolean>
Checks whether the last execution of the specified task timed out. This API uses a promise to return the result.
- **Description**
Checks whether the last execution of the specified task timed out. This method uses a promise to return the result.
**System capability**: SystemCapability.ResourceSchedule.WorkScheduler
- **Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| workId | number | Yes| Task ID.|
| Name | Type | Mandatory | Description |
| ------ | ------ | ---- | -------- |
| workId | number | Yes | Task ID.|
- **Return value**
**Return value**
| Type| Description|
| -------- | -------- |
| Promise<boolean> | Promise used to return the result. Returns **true** if the last execution of the specified task timed out; returns **false** otherwise.|
| Type | Description |
| ----------------- | ---------------------------------------- |
| Promise\<boolean> | Promise used to return the result. Returns **true** if the last execution of the specified task timed out; returns **false** otherwise.|
- **Example**
**Example**
```
```
workScheduler.isLastWorkTimeOut(500)
.then(res => {
console.info('workschedulerLog isLastWorkTimeOut success, data is:' + res);
......@@ -298,77 +269,71 @@ Checks whether the last execution of the specified task timed out. This method u
.catch(err => {
console.info('workschedulerLog isLastWorkTimeOut failed, because:' + err.data);
});
})
```
## workScheduler.WorkInfo
- **System capability**
SystemCapability.ResourceSchedule.WorkScheduler
```
## WorkInfo
Provides detailed information about the task.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
|workId |number |Yes|Task ID.|
|bundleName |string |Yes| Name of the Work Scheduler task bundle.|
|abilityName | string| Yes| Name of the component to be notified by a Work Scheduler callback.|
|networkType | NetworkType| No| Network type.|
|isCharging | bool| No|Whether the device is charging.|
|chargerType | ChargingType| No|Charging type.|
|batteryLevel | number| No|Battery level.|
|batteryStatus| BatteryStatus| No|Battery status.|
|storageRequest|StorageRequest| No|Storage status.|
|isRepeat|boolean|No|Whether the task is repeated.|
|repeatCycleTime |number|No|Repeat interval.|
|repeatCount |number|No|Number of repeat times.|
## workScheduler.NetworkType
- **System capability**
SystemCapability.ResourceSchedule.WorkScheduler
**System capability**: SystemCapability.ResourceSchedule.WorkScheduler
| Name | Type | Mandatory | Description |
| --------------- | --------------------------------- | ---- | ---------------- |
| workId | number | Yes | Task ID. |
| bundleName | string | Yes | Name of the Work Scheduler task bundle. |
| abilityName | string | Yes | Name of the component to be notified by a Work Scheduler callback.|
| networkType | [NetworkType](#networktype) | No | Network type. |
| isCharging | boolean | No | Whether the device is charging. |
| chargerType | [ChargingType](#chargingtype) | No | Charging type. |
| 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. |
| repeatCycleTime | number | No | Repeat interval. |
| repeatCount | number | No | Number of repeat times. |
## NetworkType
Enumerates the network types that can trigger the task.
|Name|Default Value|Description|
| -------- | -------- | -------- |
|NETWORK_TYPE_ANY |0 |Any network type.|
|NETWORK_TYPE_MOBILE |1| Mobile network.|
|NETWORK_TYPE_WIFI |2 |Wi-Fi network.|
|NETWORK_TYPE_BLUETOOTH |3 |Bluetooth network.|
|NETWORK_TYPE_WIFI_P2P |4 |Wi-Fi P2P network.|
|NETWORK_TYPE_ETHERNET |5 |Ethernet.|
**System capability**: SystemCapability.ResourceSchedule.WorkScheduler
## workScheduler.ChargingType
- **System capability**
SystemCapability.ResourceSchedule.WorkScheduler
| Name | Default Value | Description |
| ---------------------- | ---- | ----------------------- |
| NETWORK_TYPE_ANY | 0 | Any network type. |
| NETWORK_TYPE_MOBILE | 1 | Mobile network. |
| NETWORK_TYPE_WIFI | 2 | Wi-Fi network. |
| NETWORK_TYPE_BLUETOOTH | 3 | Bluetooth network.|
| NETWORK_TYPE_WIFI_P2P | 4 | Wi-Fi P2P network. |
| NETWORK_TYPE_ETHERNET | 5 | Ethernet. |
## ChargingType
Enumerates the charging types that can trigger the task.
|Name|Default Value|Description|
| -------- | -------- | -------- |
|CHARGING_PLUGGED_ANY |0| Any charging type.|
|CHARGING_PLUGGED_AC |1 |DC charging.|
|CHARGING_PLUGGED_USB |2 |USB charging.|
|CHARGING_PLUGGED_WIRELESS |3| Wireless charging.|
**System capability**: SystemCapability.ResourceSchedule.WorkScheduler
## workScheduler.BatteryStatus
- **System capability**
SystemCapability.ResourceSchedule.WorkScheduler
| Name | Default Value | Description |
| ------------------------- | ---- | -------------------- |
| CHARGING_PLUGGED_ANY | 0 | Any charging type.|
| CHARGING_PLUGGED_AC | 1 | DC charging. |
| CHARGING_PLUGGED_USB | 2 | USB charging. |
| CHARGING_PLUGGED_WIRELESS | 3 | Wireless charging. |
## BatteryStatus
Enumerates the battery status that can trigger the task.
|Name|Default Value|Description|
| -------- | -------- | -------- |
|BATTERY_STATUS_LOW |0 |A low battery alert is displayed.|
|BATTERY_STATUS_OKAY |1| The battery level is restored from low to normal.|
|BATTERY_STATUS_LOW_OR_OKAY |2 |The battery level is restored from low to normal, or a low battery alert is displayed.|
**System capability**: SystemCapability.ResourceSchedule.WorkScheduler
## workScheduler.StorageRequest
- **System capability**
SystemCapability.ResourceSchedule.WorkScheduler
| Name | Default Value | Description |
| -------------------------- | ---- | -------------------------- |
| BATTERY_STATUS_LOW | 0 | A low battery alert is displayed. |
| BATTERY_STATUS_OKAY | 1 | The battery level is restored from low to normal. |
| 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 status that can trigger the task.
|Name|Default Value|Description|
**System capability**: SystemCapability.ResourceSchedule.WorkScheduler
|Name |Default Value |Description|
| -------- | -------- | -------- |
|STORAGE_LEVEL_LOW |0 |The storage space is insufficient.
|STORAGE_LEVEL_OKAY |1 |The storage space is restored from insufficient to normal.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册
反馈
建议
客服 返回
顶部