diff --git a/README.md b/README.md index 4752a41df05c7b32fb0530647fa9e5c6b1542d59..ef2aa0809f25ed0fa09a0daa57e403a8389da002 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,6 @@ When an application needs to perform tasks that do not require high real-time pe ├── frameworks # Frameworks ├── interfaces -│ ├── innerkits # Internal APIs │ └── kits # External APIs ├── sa_profile # SA profile ├── services # Services @@ -30,17 +29,44 @@ When an application needs to perform tasks that do not require high real-time pe ### Available APIs -API | Description ----------------------------------------------------------|----------------------------------------- -function startWork(work: WorkInfo): boolean; | work scheduler application -function stopWork(work: WorkInfo, needCancel?: boolean): boolean; | work scheduler cancel -function getWorkStatus(workId: number, callback: AsyncCallback): void;| get the status of work(Callback form) -function getWorkStatus(workId: number): Promise; | get the status of work(Promise form) -function obtainAllWorks(callback: AsyncCallback): Array;| get all works(Callback form) -function obtainAllWorks(): Promise>;| get all works(Promise form) -function stopAndClearWorks(): boolean;| stop and clear work -function isLastWorkTimeOut(workId: number, callback: AsyncCallback): boolean;| Get whether the last task has timed out(Callback form) -function isLastWorkTimeOut(workId: number): Promise;| Get whether the last task has timed out(Promise form) +1. The members of WorkInfo + + API | Description | Type + ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ +workId | The id of work(required)|number +bundleName | The bundle name(required)|string +abilityName | The ability name(required)|string +networkType | The type of network | NetworkType +isCharging | Is charging. | bool +chargerType | The charging type. | ChargingType +batteryLevel | The battery | number +batteryStatus| The battery status | BatteryStatus +storageRequest|The storage status| StorageRequest +isRepeat|Is repeating work | boolean +repeatCycleTime | The repeating cycle time| number +repeatCount | The repeating cycle count| number + + +2. The api of work scheduler for starting, stopping and querying. + + API | Description + ------------------------------------------------------------ | ------------------------------------------------------------ + function startWork(work: WorkInfo): boolean; | work scheduler application + function stopWork(work: WorkInfo, needCancel?: boolean): boolean; | work scheduler cancel + function getWorkStatus(workId: number, callback: AsyncCallback): void; | get the status of work(Callback form) + function getWorkStatus(workId: number): Promise; | get the status of work(Promise form) + function obtainAllWorks(callback: AsyncCallback): Array; | get all works(Callback form) + function obtainAllWorks(): Promise>; | get all works(Promise form) + function stopAndClearWorks(): boolean; | stop and clear work + function isLastWorkTimeOut(workId: number, callback: AsyncCallback): boolean; | Get whether the last task has timed out(For repeat work. Callback form) + function isLastWorkTimeOut(workId: number): Promise; | Get whether the last task has timed out(For repeat work. Promise form) + +3. Callback api of work scheduler + +API | Description + ------------------------------------------------------------ | ------------------------------------------------------------ + function onWorkStart(work: WorkInfo): void; | Callback when work starts. + function onWorkStop(work: WorkInfo): void; | Callback when work stops. ### Usage Guidelines @@ -51,6 +77,13 @@ When an application needs to perform tasks with low real-time performance, work Adhere to the following constraints and rules when using work scheduler: - **Timeout**:The longest running time is 120s each time. +- **Restrict to WorkInfo**: + +(1) WorkId, bundleName and abilityName are required. + +(2) At least one condition must be set. + +(3) Repeatcycletime should be at least 20 minutes. When setting repeatcycletime, you must select one of isrepeat and repeatcount. ## Repositories Involved