提交 0a3a4d75 编写于 作者: E ester.zhou

update docs

Signed-off-by: Nester.zhou <ester.zhou@huawei.com>
上级 0112189b
# Work Scheduler # Work Scheduler
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/> > **NOTE**<br/>
> The initial APIs of this module are supported since API version 9. API version 9 is a canary version for trial use. The APIs of this version may be unstable. > The initial APIs of this module are supported since API version 9. API version 9 is a canary version for trial use. The APIs of this version may be unstable.
...@@ -100,7 +100,7 @@ Obtains the latest task status. This API uses an asynchronous callback to return ...@@ -100,7 +100,7 @@ Obtains the latest task status. This API uses an asynchronous callback to return
``` ```
workScheduler.getWorkStatus(50, (err, res) => { workScheduler.getWorkStatus(50, (err, res) => {
if (err) { if (err) {
console.info('workschedulerLog getWorkStatus failed, because:' + err.data); console.info('workschedulerLog getWorkStatus failed, because:' + err.code);
} else { } else {
for (let item in res) { for (let item in res) {
console.info('workschedulerLog getWorkStatus success,' + item + ' is:' + res[item]); console.info('workschedulerLog getWorkStatus success,' + item + ' is:' + res[item]);
...@@ -136,7 +136,7 @@ Obtains the latest task status. This API uses a promise to return the result. ...@@ -136,7 +136,7 @@ Obtains the latest task status. This API uses a promise to return the result.
console.info('workschedulerLog getWorkStatus success,' + item + ' is:' + res[item]); console.info('workschedulerLog getWorkStatus success,' + item + ' is:' + res[item]);
} }
}).catch((err) => { }).catch((err) => {
console.info('workschedulerLog getWorkStatus failed, because:' + err.data); console.info('workschedulerLog getWorkStatus failed, because:' + err.code);
}) })
``` ```
...@@ -151,7 +151,7 @@ Obtains all tasks associated with this application. This API uses an asynchronou ...@@ -151,7 +151,7 @@ Obtains all tasks associated with this application. This API uses an asynchronou
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | -------------------- | ---- | ------------------------------- | | -------- | -------------------- | ---- | ------------------------------- |
| callback | AsyncCallback\<void> | Yes | Callback used to return all tasks associated with the current application.| | callback | AsyncCallback\<void> | Yes | Callback used to return all tasks associated with the current application. |
**Return value** **Return value**
...@@ -164,7 +164,7 @@ Obtains all tasks associated with this application. This API uses an asynchronou ...@@ -164,7 +164,7 @@ Obtains all tasks associated with this application. This API uses an asynchronou
``` ```
workScheduler.obtainAllWorks((err, res) =>{ workScheduler.obtainAllWorks((err, res) =>{
if (err) { if (err) {
console.info('workschedulerLog obtainAllWorks failed, because:' + err.data); console.info('workschedulerLog obtainAllWorks failed, because:' + err.code);
} else { } else {
console.info('workschedulerLog obtainAllWorks success, data is:' + JSON.stringify(res)); console.info('workschedulerLog obtainAllWorks success, data is:' + JSON.stringify(res));
} }
...@@ -182,7 +182,7 @@ Obtains all tasks associated with this application. This API uses a promise to r ...@@ -182,7 +182,7 @@ Obtains all tasks associated with this application. This API uses a promise to r
| Type | Description | | Type | Description |
| -------------------------------------- | ------------------------------ | | -------------------------------------- | ------------------------------ |
| Promise<Array\<[WorkInfo](#workinfo)>> | Promise used to return all tasks associated with the current application.| | Promise<Array\<[WorkInfo](#workinfo)>> | Promise used to return all tasks associated with the current application. |
**Example** **Example**
...@@ -190,7 +190,7 @@ Obtains all tasks associated with this application. This API uses a promise to r ...@@ -190,7 +190,7 @@ Obtains all tasks associated with this application. This API uses a promise to r
workScheduler.obtainAllWorks().then((res) => { workScheduler.obtainAllWorks().then((res) => {
console.info('workschedulerLog obtainAllWorks success, data is:' + JSON.stringify(res)); console.info('workschedulerLog obtainAllWorks success, data is:' + JSON.stringify(res));
}).catch((err) => { }).catch((err) => {
console.info('workschedulerLog obtainAllWorks failed, because:' + err.data); console.info('workschedulerLog obtainAllWorks failed, because:' + err.code);
}) })
``` ```
...@@ -233,7 +233,7 @@ Checks whether the last execution of the specified task timed out. This API uses ...@@ -233,7 +233,7 @@ Checks whether the last execution of the specified task timed out. This API uses
``` ```
workScheduler.isLastWorkTimeOut(500, (err, res) =>{ workScheduler.isLastWorkTimeOut(500, (err, res) =>{
if (err) { if (err) {
console.info('workschedulerLog isLastWorkTimeOut failed, because:' + err.data); console.info('workschedulerLog isLastWorkTimeOut failed, because:' + err.code);
} else { } else {
console.info('workschedulerLog isLastWorkTimeOut success, data is:' + res); console.info('workschedulerLog isLastWorkTimeOut success, data is:' + res);
} }
...@@ -267,7 +267,7 @@ Checks whether the last execution of the specified task timed out. This API uses ...@@ -267,7 +267,7 @@ Checks whether the last execution of the specified task timed out. This API uses
console.info('workschedulerLog isLastWorkTimeOut success, data is:' + res); console.info('workschedulerLog isLastWorkTimeOut success, data is:' + res);
}) })
.catch(err => { .catch(err => {
console.info('workschedulerLog isLastWorkTimeOut failed, because:' + err.data); console.info('workschedulerLog isLastWorkTimeOut failed, because:' + err.code);
}); });
``` ```
...@@ -291,6 +291,8 @@ Provides detailed information about the task. ...@@ -291,6 +291,8 @@ Provides detailed information about the task.
| repeatCycleTime | number | No | Repeat interval. | | repeatCycleTime | number | No | Repeat interval. |
| repeatCount | number | No | Number of repeat times. | | repeatCount | number | No | Number of repeat times. |
| isPersisted | boolean | No | Whether to enable persistent storage for the task. | | 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. |
## NetworkType ## NetworkType
Enumerates the network types that can trigger the task. Enumerates the network types that can trigger the task.
...@@ -319,7 +321,7 @@ Enumerates the charging types that can trigger the task. ...@@ -319,7 +321,7 @@ Enumerates the charging types that can trigger the task.
| CHARGING_PLUGGED_WIRELESS | 3 | Wireless charging. | | CHARGING_PLUGGED_WIRELESS | 3 | Wireless charging. |
## BatteryStatus ## BatteryStatus
Enumerates the battery status that can trigger the task. Enumerates the battery states that can trigger the task.
**System capability**: SystemCapability.ResourceSchedule.WorkScheduler **System capability**: SystemCapability.ResourceSchedule.WorkScheduler
...@@ -330,7 +332,7 @@ Enumerates the battery status that can trigger the task. ...@@ -330,7 +332,7 @@ Enumerates the battery status that can trigger the task.
| BATTERY_STATUS_LOW_OR_OKAY | 2 | The battery level is restored from low to normal, or a low battery alert is displayed.| | BATTERY_STATUS_LOW_OR_OKAY | 2 | The battery level is restored from low to normal, or a low battery alert is displayed.|
## StorageRequest ## StorageRequest
Enumerates the storage status that can trigger the task. Enumerates the storage states that can trigger the task.
**System capability**: SystemCapability.ResourceSchedule.WorkScheduler **System capability**: SystemCapability.ResourceSchedule.WorkScheduler
......
...@@ -115,7 +115,7 @@ function onWorkStop(work: WorkInfo): void; | Triggered when the Work Scheduler t ...@@ -115,7 +115,7 @@ function onWorkStop(work: WorkInfo): void; | Triggered when the Work Scheduler t
workScheduler.getWorkStatus(50, (err, res) => { workScheduler.getWorkStatus(50, (err, res) => {
if (err) { if (err) {
console.info('workschedulerLog getWorkStatus failed, because:' + err.data); console.info('workschedulerLog getWorkStatus failed, because:' + err.code);
} else { } else {
for (let item in res) { for (let item in res) {
console.info('workschedulerLog getWorkStatuscallback success,' + item + ' is:' + res[item]); console.info('workschedulerLog getWorkStatuscallback success,' + item + ' is:' + res[item]);
...@@ -131,7 +131,7 @@ function onWorkStop(work: WorkInfo): void; | Triggered when the Work Scheduler t ...@@ -131,7 +131,7 @@ function onWorkStop(work: WorkInfo): void; | Triggered when the Work Scheduler t
console.info('workschedulerLog getWorkStatus success,' + item + ' is:' + res[item]); console.info('workschedulerLog getWorkStatus success,' + item + ' is:' + res[item]);
} }
}).catch((err) => { }).catch((err) => {
console.info('workschedulerLog getWorkStatus failed, because:' + err.data); console.info('workschedulerLog getWorkStatus failed, because:' + err.code);
}) })
...@@ -141,7 +141,7 @@ function onWorkStop(work: WorkInfo): void; | Triggered when the Work Scheduler t ...@@ -141,7 +141,7 @@ function onWorkStop(work: WorkInfo): void; | Triggered when the Work Scheduler t
workScheduler.obtainAllWorks((err, res) =>{ workScheduler.obtainAllWorks((err, res) =>{
if (err) { if (err) {
console.info('workschedulerLog obtainAllWorks failed, because:' + err.data); console.info('workschedulerLog obtainAllWorks failed, because:' + err.code);
} else { } else {
console.info('workschedulerLog obtainAllWorks success, data is:' + JSON.stringify(res)); console.info('workschedulerLog obtainAllWorks success, data is:' + JSON.stringify(res));
} }
...@@ -152,7 +152,7 @@ function onWorkStop(work: WorkInfo): void; | Triggered when the Work Scheduler t ...@@ -152,7 +152,7 @@ function onWorkStop(work: WorkInfo): void; | Triggered when the Work Scheduler t
workScheduler.obtainAllWorks().then((res) => { workScheduler.obtainAllWorks().then((res) => {
console.info('workschedulerLog obtainAllWorks success, data is:' + JSON.stringify(res)); console.info('workschedulerLog obtainAllWorks success, data is:' + JSON.stringify(res));
}).catch((err) => { }).catch((err) => {
console.info('workschedulerLog obtainAllWorks failed, because:' + err.data); console.info('workschedulerLog obtainAllWorks failed, because:' + err.code);
}) })
**Stopping and Clearing Work Scheduler Tasks** **Stopping and Clearing Work Scheduler Tasks**
...@@ -166,7 +166,7 @@ function onWorkStop(work: WorkInfo): void; | Triggered when the Work Scheduler t ...@@ -166,7 +166,7 @@ function onWorkStop(work: WorkInfo): void; | Triggered when the Work Scheduler t
workScheduler.isLastWorkTimeOut(500, (err, res) =>{ workScheduler.isLastWorkTimeOut(500, (err, res) =>{
if (err) { if (err) {
console.info('workschedulerLog isLastWorkTimeOut failed, because:' + err.data); console.info('workschedulerLog isLastWorkTimeOut failed, because:' + err.code);
} else { } else {
console.info('workschedulerLog isLastWorkTimeOut success, data is:' + res); console.info('workschedulerLog isLastWorkTimeOut success, data is:' + res);
} }
...@@ -179,6 +179,6 @@ function onWorkStop(work: WorkInfo): void; | Triggered when the Work Scheduler t ...@@ -179,6 +179,6 @@ function onWorkStop(work: WorkInfo): void; | Triggered when the Work Scheduler t
console.info('workschedulerLog isLastWorkTimeOut success, data is:' + res); console.info('workschedulerLog isLastWorkTimeOut success, data is:' + res);
}) })
.catch(err => { .catch(err => {
console.info('workschedulerLog isLastWorkTimeOut failed, because:' + err.data); console.info('workschedulerLog isLastWorkTimeOut failed, because:' + err.code);
}); });
}) })
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册