提交 49c181a2 编写于 作者: G Gloria

Update docs against 10631+10688+10667+10699+10630+11124++10576+11145

Signed-off-by: wusongqing<wusongqing@huawei.com>
上级 b0fa0e39
# Device Usage Statistics
- [Device Usage Statistics Overview](device-usage-statistics-overview.md)
- [Device Usage Statistics Development](device-usage-statistics-dev-guide.md)
- [Device Usage Statistics Development](device-usage-statistics-use-guide.md)
......@@ -6,13 +6,14 @@
- [@ohos.ability.featureAbility](js-apis-featureAbility.md)
- [@ohos.ability.particleAbility](js-apis-particleAbility.md)
- ability/[dataAbilityHelper](js-apis-dataAbilityHelper.md)
- app/[context](js-apis-Context.md)
- app/[context](js-apis-Context.md)
- Stage Model
- [@ohos.application.Ability](js-apis-application-ability.md)
- [@ohos.application.AbilityConstant](js-apis-application-abilityConstant.md)
- [@ohos.application.AbilityStage](js-apis-application-abilitystage.md)
- [@ohos.application.abilityLifecycleCallback](js-apis-application-abilityLifecycleCallback.md)
- [@ohos.application.DataShareExtensionAbility](js-apis-application-DataShareExtensionAbility.md)
- [@ohos.application.EnvironmentCallback](js-apis-application-EnvironmentCallback.md)
- [@ohos.application.FormExtension](js-apis-formextension.md)
- [@ohos.application.ServiceExtensionAbility](js-apis-service-extension-ability.md)
- [@ohos.application.StartOptions](js-apis-application-StartOptions.md)
......@@ -25,19 +26,14 @@
- application/[ExtensionContext](js-apis-extension-context.md)
- application/[FormExtensionContext](js-apis-formextensioncontext.md)
- application/[PermissionRequestResult](js-apis-permissionrequestresult.md)
- application/[ServiceExtensionContext](js-apis-service-extension-context.md)
- application/[ServiceExtensionContext](js-apis-service-extension-context.md)
- FA and Stage Models
- [@ohos.ability.dataUriUtils](js-apis-DataUriUtils.md)
- [@ohos.ability.errorCode](js-apis-ability-errorCode.md)
- [@ohos.ability.wantConstant](js-apis-ability-wantConstant.md)
- [@ohos.application.abilityDelegatorRegistry](js-apis-abilityDelegatorRegistry.md)
- [@ohos.application.abilityManager](js-apis-application-abilityManager.md)
- [@ohos.application.AccessibilityExtensionAbility](js-apis-accessibility-extension-context.md)
- [@ohos.application.AccessibilityExtensionAbility](js-apis-application-AccessibilityExtensionAbility.md)
- [@ohos.application.appManager](js-apis-appmanager.md)
- [@ohos.application.Configuration](js-apis-configuration.md)
- [@ohos.application.ConfigurationConstant](js-apis-configurationconstant.md)
- [@ohos.application.EnvironmentCallback](js-apis-application-EnvironmentCallback.md)
- [@ohos.application.errorManager](js-apis-errorManager.md)
- [@ohos.application.formBindingData](js-apis-formbindingdata.md)
- [@ohos.application.formError](js-apis-formerror.md)
......@@ -47,7 +43,6 @@
- [@ohos.application.missionManager](js-apis-missionManager.md)
- [@ohos.application.quickFixManager](js-apis-application-quickFixManager.md)
- [@ohos.application.Want](js-apis-application-Want.md)
- [@ohos.continuation.continuationManager](js-apis-continuation-continuationExtraParams.md)
- [@ohos.continuation.continuationManager](js-apis-continuation-continuationManager.md)
- [@ohos.wantAgent](js-apis-wantAgent.md)
- application/[abilityDelegator](js-apis-application-abilityDelegator.md)
......@@ -56,38 +51,16 @@
- application/[AbilityRunningInfo](js-apis-abilityrunninginfo.md)
- application/[ExtensionRunningInfo](js-apis-extensionrunninginfo.md)
- application/[MissionSnapshot](js-apis-application-MissionSnapshot.md)
- application/[ProcessRunningInfo](js-apis-processrunninginfo.md)
- application/[ProcessRunningInformation](js-apis-processrunninginformation.md)
- application/[shellCmdResult](js-apis-application-shellCmdResult.md)
- continuation/[continuationExtraParams](js-apis-continuation-continuationExtraParams.md)
- continuation/[ContinuationResult](js-apis-continuation-continuationResult.md)
- Common Event and Notification
- [@ohos.commonEvent](js-apis-commonEvent.md)
- [@ohos.events.emitter](js-apis-emitter.md)
- [@ohos.notification](js-apis-notification.md)
- application/[EventHub](js-apis-eventhub.md)
- Bundle Management
- [@ohos.bundle](js-apis-Bundle.md)
- [@ohos.bundle.defaultAppManager](js-apis-bundle-defaultAppManager.md)
- [@ohos.bundle.innerBundleManager)](js-apis-Bundle-InnerBundleManager.md)
- [@ohos.distributedBundle)](js-apis-Bundle-distributedBundle.md)
- Bundle Management
- [@ohos.zlib](js-apis-zlib.md)
- bundle/[AbilityInfo](js-apis-bundle-AbilityInfo.md)
- bundle/[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)
- bundle/[BundleInfo](js-apis-bundle-BundleInfo.md)
- bundle/[BundleInstaller](js-apis-bundle-BundleInstaller.md)
- bundle/[BundleStatusCallback](js-apis-Bundle-BundleStatusCallback.md)
- bundle/[CustomizeData](js-apis-bundle-CustomizeData.md)
- bundle/[DispatchInfo](js-apis-dispatchInfo.md)
- bundle/[ElementName](js-apis-bundle-ElementName.md)
- bundle/[ExtensionAbilityInfo](js-apis-bundle-ExtensionAbilityInfo.md)
- bundle/[HapModuleInfo](js-apis-bundle-HapModuleInfo.md)
- bundle/[LauncherAbilityInfo](js-apis-bundle-LauncherAbilityInfo.md)
- bundle/[Metadata](js-apis-bundle-Metadata.md)
- bundle/[ModuleInfo](js-apis-bundle-ModuleInfo.md)
- bundle/[PermissionDef](js-apis-bundle-PermissionDef.md)
- bundle/[RemoteAbilityInfo](js-apis-bundle-remoteAbilityInfo.md)
- bundle/[ShortcutInfo<sup>(deprecated)</sup>](js-apis-bundle-ShortcutInfo.md)
- bundle/[PackInfo](js-apis-bundle-PackInfo.md)
- UI Page
- [@ohos.animator](js-apis-animator.md)
- [@ohos.mediaquery](js-apis-mediaquery.md)
......@@ -115,13 +88,11 @@
- Resource Scheduling
- [@ohos.backgroundTaskManager](js-apis-backgroundTaskManager.md)
- [@ohos.distributedMissionManager](js-apis-distributedMissionManager.md)
- [@ohos.workScheduler ](js-apis-workScheduler.md)
- [@ohos.reminderAgentManager](js-apis-reminderAgentManager.md)
- [@ohos.resourceschedule.backgroundTaskManager](js-apis-resourceschedule-backgroundTaskManager.md)
- [@ohos.resourceschedule.workScheduler](js-apis-resourceschedule-workScheduler.md)
- [@ohos.resourceschedule.usageStatistics](js-apis-resourceschedule-deviceUsageStatistics.md)
- [@ohos.WorkSchedulerExtensionAbility](js-apis-WorkSchedulerExtensionAbility.md)
- Custom Management
- [@ohos.configPolicy](js-apis-config-policy.md)
- [@ohos.EnterpriseAdminExtensionAbility](js-apis-EnterpriseAdminExtensionAbility.md)
- [@ohos.enterpriseDeviceManager](js-apis-enterprise-device-manager.md)
- enterpriseDeviceManager/[DeviceSettingsManager](js-apis-enterpriseDeviceManager-DeviceSettingsManager.md)
- Security
- [@ohos.abilityAccessCtrl](js-apis-abilityAccessCtrl.md)
- [@ohos.privacyManager](js-apis-privacyManager.md)
......@@ -129,9 +100,7 @@
- [@ohos.userIAM.faceAuth](js-apis-useriam-faceauth.md)
- [@ohos.userIAM.userAuth ](js-apis-useriam-userauth.md)
- [@system.cipher](js-apis-system-cipher.md)
- Data Management
- [@ohos.data.dataAbility ](js-apis-data-ability.md)
- [@ohos.data.dataShare](js-apis-data-dataShare.md)
- [@ohos.data.dataSharePredicates](js-apis-data-dataSharePredicates.md)
......@@ -141,9 +110,7 @@
- [@ohos.data.rdb](js-apis-data-rdb.md)
- [@ohos.data.ValuesBucket](js-apis-data-ValuesBucket.md)
- data/rdb/[resultSet](js-apis-data-resultset.md)
- File Management
- [@ohos.document](js-apis-document.md)
- [@ohos.environment](js-apis-environment.md)
- [@ohos.data.fileAccess](js-apis-fileAccess.md)
......@@ -188,8 +155,8 @@
- Basic Features
- [@ohos.accessibility](js-apis-accessibility.md)
- [@ohos.accessibility.config](js-apis-accessibility-config.md)
- [@ohos.application.AccessibilityExtensionAbility](js-apis-application-AccessibilityExtensionAbility.md)
- [@ohos.faultLogger](js-apis-faultLogger.md)
- [@ohos.hiAppEvent](js-apis-hiappevent.md)
- [@ohos.hichecker](js-apis-hichecker.md)
- [@ohos.hidebug](js-apis-hidebug.md)
- [@ohos.hilog](js-apis-hilog.md)
......@@ -207,14 +174,12 @@
- [@ohos.wallpaper](js-apis-wallpaper.md)
- [console](js-apis-logs.md)
- [Timer](js-apis-timer.md)
- application/[AccessibilityExtensionContext](js-apis-accessibility-extension-context.md)
- Device Management
- [@ohos.batteryInfo ](js-apis-battery-info.md)
- [@ohos.brightness](js-apis-brightness.md)
- [@ohos.deviceInfo](js-apis-device-info.md)
- [@ohos.distributedHardware.deviceManager](js-apis-device-manager.md)
- [@ohos.geolocation](js-apis-geolocation.md)
- [@ohos.multimodalInput.inputConsumer](js-apis-inputconsumer.md)
- [@ohos.multimodalInput.inputDevice](js-apis-inputdevice.md)
- [@ohos.multimodalInput.inputDeviceCooperate](js-apis-cooperate.md)
......@@ -230,7 +195,6 @@
- [@ohos.runningLock](js-apis-runninglock.md)
- [@ohos.sensor](js-apis-sensor.md)
- [@ohos.settings](js-apis-settings.md)
- [@ohos.systemParameter](js-apis-system-parameter.md)
- [@ohos.thermal](js-apis-thermal.md)
- [@ohos.update](js-apis-update.md)
- [@ohos.usb](js-apis-usb.md)
......@@ -239,6 +203,11 @@
- [@ohos.account.appAccount](js-apis-appAccount.md)
- [@ohos.account.distributedAccount](js-apis-distributed-account.md)
- [@ohos.account.osAccount](js-apis-osAccount.md)
- Custom Management
- [@ohos.configPolicy](js-apis-config-policy.md)
- [@ohos.EnterpriseAdminExtensionAbility](js-apis-EnterpriseAdminExtensionAbility.md)
- [@ohos.enterpriseDeviceManager](js-apis-enterprise-device-manager.md)
- enterpriseDeviceManager/[DeviceSettingsManager](js-apis-enterpriseDeviceManager-DeviceSettingsManager.md)
- Language Base Class Library
- [@ohos.buffer](js-apis-buffer.md)
- [@ohos.convertxml](js-apis-convertxml.md)
......@@ -266,12 +235,21 @@
- [@ohos.application.testRunner](js-apis-testRunner.md)
- [@ohos.uitest](js-apis-uitest.md)
- APIs No Longer Maintained
- [@ohos.backgroundTaskManager](js-apis-backgroundTaskManager.md)
- [@ohos.bundle](js-apis-Bundle.md)
- [@ohos.bundle.innerBundleManager](js-apis-Bundle-InnerBundleManager.md)
- [@ohos.bundleState](js-apis-deviceUsageStatistics.md)
- [@ohos.bytrace](js-apis-bytrace.md)
- [@ohos.commonEvent](js-apis-commonEvent.md)
- [@ohos.data.storage](js-apis-data-storage.md)
- [@ohos.data.distributedData](js-apis-distributed-data.md)
- [@ohos.distributedBundle](js-apis-Bundle-distributedBundle.md)
- [@ohos.document](js-apis-document.md)
- [@ohos.geolocation](js-apis-geolocation.md)
- [@ohos.hiAppEvent](js-apis-hiappevent.md)
- [@ohos.prompt](js-apis-prompt.md)
- [@ohos.reminderAgent](js-apis-reminderAgent.md)
- [@ohos.systemParameter](js-apis-system-parameter.md)
- [@system.app](js-apis-system-app.md)
- [@system.battery](js-apis-system-battery.md)
- [@system.bluetooth](js-apis-system-bluetooth.md)
......@@ -291,4 +269,16 @@
- [@system.sensor](js-apis-system-sensor.md)
- [@system.storage](js-apis-system-storage.md)
- [@system.vibrator](js-apis-system-vibrate.md)
- [console](js-apis-logs.md)
- application/[ProcessRunningInfo](js-apis-processrunninginfo.md)
- bundle/[abilityInfo](js-apis-bundle-AbilityInfo.md)
- bundle/[applicationInfo](js-apis-bundle-ApplicationInfo.md)
- bundle/[bundleInfo](js-apis-bundle-BundleInfo.md)
- bundle/[bundleInstaller](js-apis-bundle-BundleInstaller.md)
- bundle/[bundleStatusCallback](js-apis-Bundle-BundleStatusCallback.md)
- bundle/[elementName](js-apis-bundle-ElementName.md)
- bundle/[hapModuleInfo](js-apis-bundle-HapModuleInfo.md)
- bundle/[launcherAbilityInfo](js-apis-bundle-LauncherAbilityInfo.md)
- bundle/[moduleInfo](js-apis-bundle-ModuleInfo.md)
- bundle/[PermissionDef](js-apis-bundle-PermissionDef.md)
- bundle/[remoteAbilityInfo](js-apis-bundle-remoteAbilityInfo.md)
- bundle/[shortcutInfo](js-apis-bundle-ShortcutInfo.md)
......@@ -28,7 +28,7 @@ Triggered when the Work Scheduler task starts.
| Name | Type | Mandatory | Description |
| ---- | ---------------------------------------- | ---- | -------------- |
| work | [workScheduler.WorkInfo](js-apis-workScheduler.md#workinfo) | Yes | Target task. |
| work | [workScheduler.WorkInfo](js-apis-resourceschedule-workScheduler.md#workinfo) | Yes | Target task.|
**Example**
......@@ -52,7 +52,7 @@ Triggered when the Work Scheduler task stops.
| Name | Type | Mandatory | Description |
| ---- | ---------------------------------------- | ---- | -------------- |
| work | [workScheduler.WorkInfo](js-apis-workScheduler.md#workinfo) | Yes | Target task. |
| work | [workScheduler.WorkInfo](js-apis-resourceschedule-workScheduler.md#workinfo) | Yes | Target task.|
**Example**
......
......@@ -203,7 +203,7 @@ Requests a continuous task from the system. This API uses an asynchronous callba
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| id | number | Yes| Notification ID of a continuous task.|
| request | NotificationRequest | Yes| Notification parameter, which is used to display information in the notification bar.|
| request | [NotificationRequest](js-apis-notification.md#notificationrequest) | Yes| Notification parameter, which is used to display information in the notification bar.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example**
......@@ -215,7 +215,7 @@ import wantAgent from '@ohos.wantAgent';
function callback(err, data) {
if (err) {
console.error("Operation failed Cause: " + err);
console.error("Operation failed cause: " + JSON.stringify(err));
} else {
console.info("Operation succeeded");
}
......@@ -267,7 +267,7 @@ Requests a continuous task from the system. This API uses a promise to return th
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| id | number | Yes| Notification ID of a continuous task.|
| request | NotificationRequest | Yes| Notification parameter, which is used to display information in the notification bar.|
| request | [NotificationRequest](js-apis-notification.md#notificationrequest) | Yes| Notification parameter, which is used to display information in the notification bar.|
**Return value**
......@@ -311,7 +311,7 @@ wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
particleAbility.startBackgroundRunning(id, request).then(() => {
console.info("Operation succeeded");
}).catch((err) => {
console.error("Operation failed Cause: " + err);
console.error("Operation failed cause: " + JSON.stringify(err));
});
});
......@@ -338,7 +338,7 @@ import particleAbility from '@ohos.ability.particleAbility';
function callback(err, data) {
if (err) {
console.error("Operation failed Cause: " + err);
console.error("Operation failed cause: " + JSON.stringify(err));
} else {
console.info("Operation succeeded");
}
......@@ -370,7 +370,7 @@ import particleAbility from '@ohos.ability.particleAbility';
particleAbility.cancelBackgroundRunning().then(() => {
console.info("Operation succeeded");
}).catch((err) => {
console.error("Operation failed Cause: " + err);
console.error("Operation failed cause: " + JSON.stringify(err));
});
```
......
......@@ -6,12 +6,14 @@ You can set your application to use the reminder agent APIs to create scheduled
> **NOTE**
>
> This module is deprecated since API version 9. You are advised to use [@ohos.reminderAgentManager](js-apis-reminderAgentManager.md) instead.
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```
```js
import reminderAgent from'@ohos.reminderAgent';
```
......@@ -20,7 +22,7 @@ import reminderAgent from'@ohos.reminderAgent';
publishReminder(reminderReq: ReminderRequest, callback: AsyncCallback&lt;number&gt;): 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](../reference/apis/js-apis-notification.md#notificationrequestenablenotification8).
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).
**Required permissions**: ohos.permission.PUBLISH_AGENT_REMINDER
......@@ -28,10 +30,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&lt;number&gt; | Yes| Asynchronous callback used to return the published reminder's ID.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| reminderReq | [ReminderRequest](#reminderrequest) | Yes| Reminder to be published.|
| callback | AsyncCallback&lt;number&gt; | Yes| Asynchronous callback used to return the published reminder's ID.|
**Example**
```js
......@@ -49,21 +51,21 @@ Publishes a reminder through the reminder agent. This API uses an asynchronous c
publishReminder(reminderReq: ReminderRequest): Promise&lt;number&gt;
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](../reference/apis/js-apis-notification.md#notificationrequestenablenotification8).
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).
**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| Reminder to be published.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;number&gt; | Promise used to return the published reminder's ID.|
| Type| Description|
| -------- | -------- |
| Promise&lt;number&gt; | Promise used to return the published reminder's ID.|
**Example**
```js
......@@ -89,7 +91,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.|
| reminderId | number | Yes| ID of the reminder to cancel. The value is obtained by calling [publishReminder](#reminderagentpublishreminder).|
| callback | AsyncCallback&lt;void&gt; | Yes| Asynchronous callback used to return the result.|
**Example**
......@@ -113,7 +115,7 @@ Cancels the reminder with the specified ID. This API uses a promise to return th
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| reminderId | number | Yes| ID of the reminder to cancel.|
| reminderId | number | Yes| ID of the reminder to cancel. The value is obtained by calling [publishReminder](#reminderagentpublishreminder).|
**Return value**
......@@ -453,10 +455,10 @@ Defines the reminder to publish.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| reminderType | ReminderType | Yes| Type of the reminder.|
| actionButton | [ActionButton?,&nbsp;ActionButton?] | No| Button displayed in the reminder notification. (The parameter is optional. Up to two buttons are supported.)|
| wantAgent | WantAgent | No| Information about the ability that is redirected to when the notification is clicked.|
| 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.|
| reminderType | [ReminderType](#remindertype) | Yes| Type of the reminder.|
| actionButton | [ActionButton](#actionbutton) | No| Button displayed in the reminder notification. (The parameter is optional. Up to two buttons are supported.)|
| wantAgent | [WantAgent](#wantagent) | No| Information about the ability that is redirected to when the notification 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.|
| ringDuration | number | No| Ringing duration.|
| snoozeTimes | number | No| Number of reminder snooze times.|
| timeInterval | number | No| Reminder snooze interval.|
......
# Work Scheduler
The **workScheduler** module provides the APIs for registering, canceling, and querying Work Scheduler tasks, which do not have real-time constraints.
The system executes Work Scheduler tasks at an appropriate time, subject to the storage space, power consumption, temperature, 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 restrictions, see [Restrictions on Using Work Scheduler Tasks](../../task-management/background-task-overview.md#restrictions-on-using-work-scheduler-tasks).
## Modules to Import
```js
import workScheduler from '@ohos.resourceschedule.workScheduler';
```
## workScheduler.startWork
startWork(work: WorkInfo): void
Instructs the **WorkSchedulerService** to add the specified task to the execution queue.
**System capability**: SystemCapability.ResourceSchedule.WorkScheduler
**Parameters**
| Name | Type | Mandatory | Description |
| ---- | --------------------- | ---- | -------------- |
| work | [WorkInfo](#workinfo) | Yes | Task to be added to the execution queue.|
**Error codes**
For details about the error codes, see [workScheduler Error Codes](../errorcodes/errorcode-workScheduler.md).
| ID | Error Message |
| ---- | --------------------- |
| 9700001 | Memory operation failed. |
| 9700002 | Parcel operation failed. |
| 9700003 | System service operation failed. |
| 9700004 | Checking workInfo failed. |
| 9700005 | StartWork failed. |
**Example**
```js
let workInfo = {
workId: 1,
batteryStatus:workScheduler.BatteryStatus.BATTERY_STATUS_LOW,
isRepeat: false,
isPersisted: true,
bundleName: "com.example.myapplication",
abilityName: "MyExtension",
parameters: {
mykey0: 1,
mykey1: "string value",
mykey2: true,
mykey3: 1.5
}
}
try{
workScheduler.startWork(workInfo);
console.info('workschedulerLog startWork success');
} catch (error) {
console.error(`workschedulerLog startwork failed. code is ${error.code} message is ${error.message}`);
}
```
## workScheduler.stopWork
stopWork(work: WorkInfo, needCancel?: boolean): void
Instructs the **WorkSchedulerService** to stop the specified task.
**System capability**: SystemCapability.ResourceSchedule.WorkScheduler
**Parameters**
| Name | Type | Mandatory | Description |
| ---------- | --------------------- | ---- | ---------- |
| work | [WorkInfo](#workinfo) | Yes | Task to stop. |
| needCancel | boolean | Yes | Whether to cancel the task.|
**Error codes**
For details about the error codes, see [workScheduler Error Codes](../errorcodes/errorcode-workScheduler.md).
| ID | Error Message |
| ---- | --------------------- |
| 9700001 | Memory operation failed. |
| 9700002 | Parcel operation failed. |
| 9700003 | System service operation failed. |
| 9700004 | Checking workInfo failed. |
**Example**
```js
let workInfo = {
workId: 1,
batteryStatus:workScheduler.BatteryStatus.BATTERY_STATUS_LOW,
isRepeat: false,
isPersisted: true,
bundleName: "com.example.myapplication",
abilityName: "MyExtension",
parameters: {
mykey0: 1,
mykey1: "string value",
mykey2: true,
mykey3: 1.5
}
}
try{
workScheduler.stopWork(workInfo, false);
console.info('workschedulerLog stopWork success');
} catch (error) {
console.error(`workschedulerLog stopWork failed. code is ${error.code} message is ${error.message}`);
}
```
## workScheduler.getWorkStatus:callback
getWorkStatus(workId: number, callback : AsyncCallback\<WorkInfo>): void
Obtains the latest task status. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.ResourceSchedule.WorkScheduler
**Parameters**
| 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.|
**Error codes**
For details about the error codes, see [workScheduler Error Codes](../errorcodes/errorcode-workScheduler.md).
| ID | Error Message |
| ---- | --------------------- |
| 9700001 | Memory operation failed. |
| 9700002 | Parcel operation failed. |
| 9700003 | System service operation failed. |
| 9700004 | Checking workInfo failed. |
**Example**
```js
try{
workScheduler.getWorkStatus(50, (error, res) => {
if (error) {
console.error(`workschedulerLog getWorkStatus failed. code is ${error.code} message is ${error.message}`);
} else {
for (let item in res) {
console.info(`workschedulerLog getWorkStatus success, ${item} is: ${res[item]}`);
}
}
});
} catch (error) {
console.error(`workschedulerLog getWorkStatus failed. code is ${error.code} message is ${error.message}`);
}
```
## workScheduler.getWorkStatus:promise
getWorkStatus(workId: number): Promise\<WorkInfo>
Obtains the latest task status. This API uses a promise to return the result.
**System capability**: SystemCapability.ResourceSchedule.WorkScheduler
**Parameters**
| Name | Type | Mandatory | Description |
| ------ | ------ | ---- | -------- |
| workId | number | Yes | Task ID.|
**Return value**
| 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.|
**Error codes**
For details about the error codes, see [workScheduler Error Codes](../errorcodes/errorcode-workScheduler.md).
| ID | Error Message |
| ---- | --------------------- |
| 9700001 | Memory operation failed. |
| 9700002 | Parcel operation failed. |
| 9700003 | System service operation failed. |
| 9700004 | Checking workInfo failed. |
**Example**
```js
try{
workScheduler.getWorkStatus(50).then((res) => {
for (let item in res) {
console.info(`workschedulerLog getWorkStatus success, ${item} is: ${res[item]}`);
}
}).catch((error) => {
console.error(`workschedulerLog getWorkStatus failed. code is ${error.code} message is ${error.message}`);
})
} catch (error) {
console.error(`workschedulerLog getWorkStatus failed. code is ${error.code} message is ${error.message}`);
}
```
## workScheduler.obtainAllWorks:callback
obtainAllWorks(callback : AsyncCallback\<void>): Array\<WorkInfo>
Obtains all tasks associated with this application. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.ResourceSchedule.WorkScheduler
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------------------- | ---- | ------------------------------- |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result. All tasks associated with the current application.|
**Return value**
| Type | Description |
| ----------------------------- | --------------- |
| Array\<[WorkInfo](#workinfo)> | All tasks associated with the current application.|
**Error codes**
For details about the error codes, see [workScheduler Error Codes](../errorcodes/errorcode-workScheduler.md).
| ID | Error Message |
| ---- | --------------------- |
| 9700001 | Memory operation failed. |
| 9700002 | Parcel operation failed. |
| 9700003 | System service operation failed. |
**Example**
```js
try{
workScheduler.obtainAllWorks((error, res) =>{
if (error) {
console.error(`workschedulerLog obtainAllWorks failed. code is ${error.code} message is ${error.message}`);
} else {
console.info(`workschedulerLog obtainAllWorks success, data is: ${JSON.stringify(res)}`);
}
});
} catch (error) {
console.error(`workschedulerLog obtainAllWorks failed. code is ${error.code} message is ${error.message}`);
}
```
## workScheduler.obtainAllWorks:promise
obtainAllWorks(): Promise<Array\<WorkInfo>>
Obtains all tasks associated with this application. This API uses a promise to return the result.
**System capability**: SystemCapability.ResourceSchedule.WorkScheduler
**Return value**
| Type | Description |
| -------------------------------------- | ------------------------------ |
| Promise<Array\<[WorkInfo](#workinfo)>> | Promise used to return the result. All tasks associated with the current application.|
**Error codes**
For details about the error codes, see [workScheduler Error Codes](../errorcodes/errorcode-workScheduler.md).
| ID | Error Message |
| ---- | --------------------- |
| 9700001 | Memory operation failed. |
| 9700002 | Parcel operation failed. |
| 9700003 | System service operation failed. |
**Example**
```js
try{
workScheduler.obtainAllWorks().then((res) => {
console.info(`workschedulerLog obtainAllWorks success, data is: ${JSON.stringify(res)}`);
}).catch((error) => {
console.error(`workschedulerLog obtainAllWorks failed. code is ${error.code} message is ${error.message}`);
})
} catch (error) {
console.error(`workschedulerLog obtainAllWorks failed. code is ${error.code} message is ${error.message}`);
}
```
## workScheduler.stopAndClearWorks
stopAndClearWorks(): void
Stops and cancels all tasks associated with the current application.
**System capability**: SystemCapability.ResourceSchedule.WorkScheduler
**Error codes**
For details about the error codes, see [workScheduler Error Codes](../errorcodes/errorcode-workScheduler.md).
| ID | Error Message |
| ---- | --------------------- |
| 9700001 | Memory operation failed. |
| 9700002 | Parcel operation failed. |
| 9700003 | System service operation failed. |
**Example**
```js
try{
workScheduler.stopAndClearWorks();
console.info(`workschedulerLog stopAndClearWorks success`);
} catch (error) {
console.error(`workschedulerLog stopAndClearWorks failed. code is ${error.code} message is ${error.message}`);
}
```
## workScheduler.isLastWorkTimeOut:callback
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.
**System capability**: SystemCapability.ResourceSchedule.WorkScheduler
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------------------- | ---- | ---------------------------------------- |
| workId | number | Yes | Task ID. |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result. Returns **true** if the last execution of the specified task timed out; returns **false** otherwise.|
**Return value**
| Type | Description |
| ------- | ---------------------------------------- |
| boolean | Callback used to return the result. Returns **true** if the last execution of the specified task timed out; returns **false** otherwise.|
**Error codes**
For details about the error codes, see [workScheduler Error Codes](../errorcodes/errorcode-workScheduler.md).
| ID | Error Message |
| ---- | --------------------- |
| 9700001 | Memory operation failed. |
| 9700002 | Parcel operation failed. |
| 9700003 | System service operation failed. |
**Example**
```js
try{
workScheduler.isLastWorkTimeOut(500, (error, res) =>{
if (error) {
console.error(`workschedulerLog isLastWorkTimeOut failed. code is ${error.code} message is ${error.message}`);
} else {
console.info(`workschedulerLog isLastWorkTimeOut success, data is: ${res}`);
}
});
} catch (error) {
console.error(`workschedulerLog isLastWorkTimeOut failed. code is ${error.code} message is ${error.message}`);
}
```
## workScheduler.isLastWorkTimeOut:promise
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.
**System capability**: SystemCapability.ResourceSchedule.WorkScheduler
**Parameters**
| Name | Type | Mandatory | Description |
| ------ | ------ | ---- | -------- |
| workId | number | Yes | Task ID.|
**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.|
**Error codes**
For details about the error codes, see [workScheduler Error Codes](../errorcodes/errorcode-workScheduler.md).
| ID | Error Message |
| ---- | --------------------- |
| 9700001 | Memory operation failed. |
| 9700002 | Parcel operation failed. |
| 9700003 | System service operation failed. |
**Example**
```js
try{
workScheduler.isLastWorkTimeOut(500)
.then(res => {
console.info(`workschedulerLog isLastWorkTimeOut success, data is: ${res}`);
})
.catch(error => {
console.error(`workschedulerLog isLastWorkTimeOut failed. code is ${error.code} message is ${error.message}`);
});
} catch (error) {
console.error(`workschedulerLog isLastWorkTimeOut failed. code is ${error.code} message is ${error.message}`);
}
```
## WorkInfo
Provides detailed information about the task. For details about the constraints on configuring **WorkInfo**, see [Restrictions on Using Work Scheduler Tasks](../../task-management/background-task-overview.md#restrictions-on-using-work-scheduler-tasks).
**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. |
| 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]: any} | No | Carried parameters. |
## NetworkType
Enumerates the network types that can trigger the task.
**System capability**: SystemCapability.ResourceSchedule.WorkScheduler
| Name | Description |
| ---------------------- | ----------------------- |
| NETWORK_TYPE_ANY | Any network type. |
| NETWORK_TYPE_MOBILE | Mobile network. |
| NETWORK_TYPE_WIFI | Wi-Fi network. |
| NETWORK_TYPE_BLUETOOTH | Bluetooth network.|
| NETWORK_TYPE_WIFI_P2P | Wi-Fi P2P network. |
| NETWORK_TYPE_ETHERNET | Ethernet. |
## ChargingType
Enumerates the charging types that can trigger the task.
**System capability**: SystemCapability.ResourceSchedule.WorkScheduler
| Name | Description |
| ------------------------- | -------------------- |
| CHARGING_PLUGGED_ANY | Any charging type.|
| CHARGING_PLUGGED_AC | DC charging. |
| CHARGING_PLUGGED_USB | USB charging. |
| CHARGING_PLUGGED_WIRELESS | Wireless charging. |
## BatteryStatus
Enumerates the battery states that can trigger the task.
**System capability**: SystemCapability.ResourceSchedule.WorkScheduler
| Name | Description |
| -------------------------- | -------------------------- |
| BATTERY_STATUS_LOW | A low battery alert is displayed. |
| BATTERY_STATUS_OKAY | The battery level is restored from low to normal. |
| BATTERY_STATUS_LOW_OR_OKAY | The battery level is restored from low to normal, or a low battery alert is displayed.|
## StorageRequest
Enumerates the storage states that can trigger the task.
**System capability**: SystemCapability.ResourceSchedule.WorkScheduler
| Name | Description |
| ------------------------- | ------------------------------ |
| STORAGE_LEVEL_LOW | The storage space is insufficient. |
| STORAGE_LEVEL_OKAY | The storage space is restored from insufficient to normal. |
| STORAGE_LEVEL_LOW_OR_OKAY | The storage space is restored from insufficient to normal, or the storage space is insufficient.|
# DeviceUsageStatistics Error Codes
## 10000001 Memory Operation Failure
**Error Message**
Memory operation failed.
**Description**
Creating an instance fails.
**Possible Causes**
The system memory is insufficient.
**Solution**
Check whether memory leak occurs.
## 10000002 IPC Parcel Write Failure
**Error Message**
Parcel operation failed. Failed to write the parcel.
**Description**
Failed to write the data object during the IPC.
**Possible Causes**
Failed to write the object.
**Solution**
Check whether the object value is normal.
## 10000003 System Service Operation Failure
**Error Message**
System service operation failed.
**Description**
The client process fails to obtain the system service.
**Possible Causes**
The dependent service process is faulty.
**Solution**
Try again later or restart the device.
## 10000004 IPC Failure
**Error Message**
IPC communication failed.
**Description**
The IPC fails.
**Possible Causes**
The system service is abnormal or the IPC data is abnormal.
**Solution**
Try again later or restart the device.
## 10000005 Application Not Installed
**Error Message**
The application is not installed.
**Description**
The application is not installed.
**Possible Causes**
The application is not installed or has been uninstalled.
**Solution**
Check whether the application exists.
## 10000006 Failed to Obtain Application Information
**Error Message**
Get application info failed.
**Description**
The client process fails to obtain application information from the service.
**Possible Causes**
1. The value of **beginTime** or **endTime** is invalid.
2. The application is not installed or has been uninstalled.
3. The value of **intervalType** is invalid.
**Solution**
Check whether the input parameters are valid and whether the application exists.
## 10000007 Time Operation Failure
**Error Message**
Get system or actual time operation failed.
**Description**
The system service fails to obtain the system time.
**Possible Causes**
The system is abnormal.
**Solution**
Try again later or restart the device.
## 10100001 Duplicate Application Group Operation
**Error Message**
Application group operation failed. The application group are the the same or do not need te be updated.
**Description**
Operating the application group, for example, setting an application group or registering or deregistering a callback for application group changes, fails.
**Possible Causes**
The application group to set already exists, or the callback for application group changes to register or deregister has already been registered or deregistered.
**Solution**
Do not repeatedly set application groups, or register or deregister a callback for application group changes.
## 10100002 Failed to Obtain Application Group Information
**Error Message**
Get application group info failed. The application group infomation cannot be found.
**Description**
The client process fails to obtain the application group information.
**Possible Causes**
1. An incorrect bundle name is passed.
2. The application is not installed or has been uninstalled.
**Solution**
Check whether the bundle name is valid and whether the application exists.
# backgroundTaskManager Error Codes
## 9800001 Memory Operation Failure
**Error Message**
Memory operation failed.
**Possible Causes**
1. A memory leak occurs.
2. The system memory is insufficient.
**Solution**
1. Release the memory.
2. Check whether memory leak occurs.
## 9800002 Parcel Operation Failure
**Error Message**
Parcel operation failed.
**Possible Causes**
An exception occurs when invoking the **MessageParcel** object to read or write an object.
**Solution**
Try again later or restart the device.
## 9800003 IPC Failure
**Error Message**
IPC failed.
**Possible Causes**
IPC fails.
**Solution**
Try again later or restart the device.
## 9800004 System Service Failure
**Error Message**
System service operation failed.
**Possible Causes**
1. The system service is not started.
2. The system service is abnormal.
**Solution**
Try again later or restart the device.
## 9800005 Continuous Task Verification Failure
**Error Message**
Continuous task verification failed.
**Possible Causes**
1. The application repeatedly requests a continuous task.
2. The application repeatedly cancels a continuous task.
3. The value of **bgMode** is invalid because no continuous task type is configured for **backgroundModes** in the application's configuration file.
4. A non-PC device requests the continuous task **KEEPING_TASK**, which is available only for PCs.
5. A third-party application requests the continuous task **WIFI_INTERACTION** or **VOIP**, which is available only for system applications.
**Solution**
1. Check the application code.
2. Check whether the application has the system permissions.
3. Check the type of the device where the application is located.
4. Check the value of **backgroundModes**.
## 9800006 Notification Verification Failure
**Error Message**
Notification verification failed.
**Possible Causes**
1. The continuous task resources cached in the resource subsystem fail to be loaded.
2. The notification subsystem functions abnormally.
**Solution**
1. Check for the continuous task resources **ohos.backgroundtaskmgr.resources**.
2. Try again later or restart the device.
## 9800007 Continuous Task Storage Failure
**Error Message**
Task storage failed.
**Possible Causes**
1. Failed to create a file to store the task information.
2. Failed to obtain the file path.
3. Failed to open the file that stores the task information.
**Solution**
1. Check the **/data/service/el1/public/background_task_mgr/running_task** file.
2. Try again later or restart the device.
## 9900001 Caller Information Verification Failure for a Transient Task
**Error Message**
Caller information verification failed for a transient task.
**Possible Causes**
1. Failed to obtain the UID or PID of the caller.
2. Failed to obtain the bundle name of the caller.
3. The request ID passed in the API used to cancel the transient task is invalid.
**Solution**
1. Check whether the application UID exists.
2. Check whether the application has requested a transient task.
3. Try again later or restart the device.
## 9900002 Continuous Task Verification Failure
**Error Message**
Transient task verification failed.
**Possible Causes**
1. The callback passed in **requestSuspendDelay()** already exists.
2. The callback passed in **cancelSuspendDelay()** does not exist.
3. The application attempts to request a transient task 5 seconds after it switches to the background.
4. The application has already requested three transient tasks.
5. The application's daily quota for transient tasks is used up.
**Solution**
1. Check the application code.
2. The application should cancel transient tasks immediately after they are complete.
## 18700001 Caller Information Verification Failure for an Energy Resource Request
**Error Message**
Caller information verification failed when applying for efficiency resources.
**Possible Causes**
1. Failed to obtain the UID or PID of the caller.
2. The value of **resourceTypes **for requesting energy resources exceeds the upper limit.
**Solution**
Check the input parameters.
# reminderAgentManager Error Codes
## 1700001 Notification Disabled
**Error Message**
Notification does not enable.
**Description**
The application is not allowed to send notifications when **publishReminder()** is called.
**Possible Causes**
1. The application has not requested notification to be enabled.
2. The reminder function is disabled.
**Solution**
1. Call [Notification.requestEnableNotification](../apis/js-apis-notification.md#notificationrequestenablenotification8) to request notification to be enabled for the application.
2. Check whether the notification function is disabled.
## 1700002 Too Many Reminders
**Error Message**
The number of reminders exceeds the limit.
**Description**
The number of reminders exceeds the limit when **publishReminder()** is called.
**Possible Causes**
1. There are already 2000 reminders for the entire system.
2. There are already 30 reminders for the application.
**Solution**
Delete unnecessary reminders.
## 1700003 Nonexistent Reminder
**Error Message**
The reminder does not exist.
**Description**
The reminder passed in **cancelReminder()** does not exist.
**Possible Causes**
1. The reminder has expired.
2. The reminder has been deleted.
**Solution**
1. Check whether the reminder is valid.
2. Check whether the reminder has been deleted.
## 1700004 Nonexistent Bundle Name
**Error Message**
The package name does not exist.
**Description**
The bundle name passed is not found.
**Possible Causes**
1. The bundle name is incorrect.
2. The application is not installed.
**Solution**
Check whether the bundle name exists.
# workScheduler Error Codes
## 9700001 Memory Operation Failure
**Error Message**
Memory operation failed.
**Possible Causes**
1. A memory leak occurs.
2. The system memory is insufficient.
**Solution**
1. Release the memory.
2. Check whether memory leak occurs.
## 9700002 Parcel Operation Failure
**Error Message**
Parcel operation failed.
**Possible Causes**
An exception occurs when invoking the **MessageParcel** object to read or write an object.
**Solution**
Try again later or restart the device.
## 9700003 System Service Failure
**Error Message**
System service operation failed.
**Possible Causes**
1. The system service is not started.
2. The system service is abnormal.
**Solution**
Try again later or restart the device.
## 9700004 workInfo Verification Failure
**Error Message**
Checking workInfo failed.
**Possible Causes**
1. The value of **bundleName** in **workInfo** does not match the UID of the application.
2. The Work Scheduler task to cancel or query does not exist.
**Solution**
Check the **workInfo** parameters.
## 9700005 startWork Failure
**Error Message**
StartWork failed.
**Possible Causes**
1. The Work Scheduler task already exists.
2. The application has already requested 10 Work Scheduler tasks.
3. The repeat interval of a Work Scheduler task must be at least 20 minutes.
**Solution**
Check the input parameters and application code.
# Task Management
- Background Task Management
- Background Task
- [Background Task Management Overview](background-task-overview.md)
- [Background Task Management Development](background-task-dev-guide.md)
- Work Scheduler
- [Work Scheduler Overview](work-scheduler-overview.md)
- [Transient Task Development](transient-task-dev-guide.md)
- [Continuous Task Development](continuous-task-dev-guide.md)
- [Work Scheduler Development](work-scheduler-dev-guide.md)
- [Efficiency Resource Request Development](efficiency-resources-apply-dev-guide.md)
- Agent-Powered Scheduled Reminder
- [Agent-Powered Scheduled Reminder Overview](background-agent-scheduled-reminder-overview.md)
- [Agent-Powered Scheduled Reminder Development](background-agent-scheduled-reminder-guide.md)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册