The **missionManager** module provides APIs to lock, unlock, and clear missions, and switch a mission to the foreground.
> **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.
## Modules to Import
...
...
@@ -32,7 +32,7 @@ Registers a listener to observe the mission status.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| listener | [MissionListener](js-apis-inner-application-missionListener.md) | Yes| Mission status listener to register.|
| listener | [MissionListener](js-apis-inner-application-missionListener.md) | Yes| Listener to register.|
@@ -631,6 +647,14 @@ Locks a given mission. This API uses an asynchronous callback to return the resu
| missionId | number | Yes| Mission ID.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------- |
| 16300001 | Mission not found. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```ts
...
...
@@ -673,9 +697,17 @@ Locks a given mission. This API uses a promise to return the result.
**Return value**
| Type| Description|
| Type| Description|
| -------- | -------- |
| Promise<void> | Promise used to return the result.|
| Promise<void> | Promise used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------- |
| 16300001 | Mission not found. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
...
...
@@ -719,6 +751,14 @@ Unlocks a given mission. This API uses an asynchronous callback to return the re
| missionId | number | Yes| Mission ID.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------- |
| 16300001 | Mission not found. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```ts
...
...
@@ -761,9 +801,17 @@ Unlocks a given mission. This API uses a promise to return the result.
**Return value**
| Type| Description|
| Type| Description|
| -------- | -------- |
| Promise<void> | Promise used to return the result.|
| Promise<void> | Promise used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------- |
| 16300001 | Mission not found. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
...
...
@@ -852,9 +900,9 @@ Clears a given mission, regardless of whether it is locked. This API uses a prom
**Return value**
| Type| Description|
| Type| Description|
| -------- | -------- |
| Promise<void> | Promise used to return the result.|
| Promise<void> | Promise used to return the result.|
**Example**
...
...
@@ -916,9 +964,9 @@ Clears all unlocked missions. This API uses a promise to return the result.
**Return value**
| Type| Description|
| Type| Description|
| -------- | -------- |
| Promise<void> | Promise used to return the result.|
| Promise<void> | Promise used to return the result.|
**Example**
...
...
@@ -949,6 +997,14 @@ Switches a given mission to the foreground. This API uses an asynchronous callba
| missionId | number | Yes| Mission ID.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------- |
| 16000009 | An ability cannot be started or stopped in Wukong mode. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```ts
...
...
@@ -991,6 +1047,14 @@ Switches a given mission to the foreground, with the startup parameters for the
| options | [StartOptions](js-apis-app-ability-startOptions.md) | Yes| Startup parameters, which are used to specify the window mode and device ID for switching the mission to the foreground.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------- |
| 16000009 | An ability cannot be started or stopped in Wukong mode. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```ts
...
...
@@ -1034,9 +1098,17 @@ Switches a given mission to the foreground, with the startup parameters for the
**Return value**
| Type| Description|
| Type| Description|
| -------- | -------- |
| Promise<void> | Promise used to return the result.|
| Promise<void> | Promise used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------- |
| 16000009 | An ability cannot be started or stopped in Wukong mode. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
@@ -62,6 +62,25 @@ Applies a quick fix patch. This API uses an asynchronous callback to return the
| hapModuleQuickFixFiles | Array\<string> | Yes| Quick fix patch files, each of which must contain a valid file path.|
| callback | AsyncCallback\<void> | Yes| Callback used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------- |
| 18500002 | Copy file failed, maybe not exist or inaccessible. |
| 18500008 | Internal error. |
If an error occurs during patch installation, the error code and message are returned through the common event [COMMON_EVENT_QUICK_FIX_APPLY_RESULT](commonEvent-definitions.md#common_event_quick_fix_apply_result9). The table below lists the possible error codes and messages.
| ID| Error Message|
| ------- | -------- |
| 18500003 | Deploy hqf failed. |
| 18500004 | Switch hqf failed. |
| 18500005 | Delete hqf failed. |
| 18500006 | Load patch failed. |
| 18500007 | Unload patch failed. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
> **NOTE**
>
> The file path passed in the API must be an application sandbox path. For details about how to obtain the sandbox path, see [Obtaining the Sandbox Path](js-apis-bundle-BundleInstaller.md#obtaining-the-sandbox-path). The path mapped to the device is **/proc/<*applicationProcessId*>/root/*sandboxPath***.
...
...
@@ -109,6 +128,25 @@ Applies a quick fix patch. This API uses a promise to return the result.
| -------- | -------- |
| Promise\<void> | Promise used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------- |
| 18500002 | Copy file failed, maybe not exist or inaccessible. |
| 18500008 | Internal error. |
If an error occurs during patch installation, the error code and message are returned through the common event [COMMON_EVENT_QUICK_FIX_APPLY_RESULT](commonEvent-definitions.md#common_event_quick_fix_apply_result9). The table below lists the possible error codes and messages.
| ID| Error Message|
| ------- | -------- |
| 18500003 | Deploy hqf failed. |
| 18500004 | Switch hqf failed. |
| 18500005 | Delete hqf failed. |
| 18500006 | Load patch failed. |
| 18500007 | Unload patch failed. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```ts
...
...
@@ -145,6 +183,15 @@ Obtains the quick fix information of the application. This API uses an asynchron
| bundleName | string | Yes|Bundle name. |
| callback | AsyncCallback\<[ApplicationQuickFixInfo](#applicationquickfixinfo)> | Yes| Callback used to return the quick fix information.|
**Error codes**
| ID| Error Message|
| ------- | -------- |
| 18500001 | The bundle is not exist. |
| 18500008 | Internal error. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```ts
...
...
@@ -188,6 +235,15 @@ Obtains the quick fix information of the application. This API uses a promise to
| -------- | -------- |
| Promise\<[ApplicationQuickFixInfo](#applicationquickfixinfo)> | Promise used to return the quick fix information.|
**Error codes**
| ID| Error Message|
| ------- | -------- |
| 18500001 | The bundle is not exist. |
| 18500008 | Internal error. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
The **WantAgent** module provides APIs for creating and comparing **WantAgent** objects, and obtaining the user ID and bundle name of a **WantAgent** object. You are advised to use this module, since it will replace the [@ohos.wantAgent](js-apis-wantAgent.md) module in the near future.
The **WantAgent** module provides APIs for triggering, canceling, and comparing **WantAgent** objects. You can use the APIs to create a **WantAgent** object, and obtain the user ID, bundle name, and want information of the object.
> **NOTE**
>
...
...
@@ -24,9 +24,18 @@ Obtains a **WantAgent** object. This API uses an asynchronous callback to return
Checks whether two **WantAgent** objects are equal to determine whether the same operation is from the same application. This API uses an asynchronous callback to return the result.
Checks whether two **WantAgent** objects are equal. This API uses an asynchronous callback to return the result.
Checks whether two **WantAgent** objects are equal to determine whether the same operation is from the same application. This API uses a promise to return the result.
Checks whether two **WantAgent** objects are equal. This API uses a promise to return the result.
The **FormHost** module provides APIs related to the widget host, which is an application that displays the widget content and controls the position where the widget is displayed. You can use the APIs to delete, release, and update widgets installed by the same user, and obtain widget information and status.
The **formHost** module provides APIs related to the widget host, which is an application that displays the widget content and controls the position where the widget is displayed. You can use the APIs to delete, release, and update widgets installed by the same user, and obtain widget information and status.
> **NOTE**
>
...
...
@@ -34,8 +34,15 @@ Deletes a widget. After this API is called, the application can no longer use th
| Error Code ID| Error Message|
| -------- | -------- |
| 201 | Permissions denied. |
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
| 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. |
| 202 | The application is not a system application. |
| 16501000 | An internal functional error occurred. |
| 16501001 | The ID of the form to be operated does not exist. |
| 16501003 | The form can not be operated by the current application. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).||
**Example**
...
...
@@ -82,10 +89,17 @@ Deletes a widget. After this API is called, the application can no longer use th
| Error Code ID| Error Message|
| -------- | -------- |
| 201 | Permissions denied. |
| 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
| 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. |
| 16501001 | The ID of the form to be operated does not exist. |
| 16501003 | The form can not be operated by the current application. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).||
**Parameters**
**Example**
```ts
try{
...
...
@@ -121,8 +135,15 @@ Releases a widget. After this API is called, the application can no longer use t
| Error Code ID| Error Message|
| -------- | -------- |
| 201 | Permissions denied. |
| 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
| 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. |
| 16501001 | The ID of the form to be operated does not exist. |
| 16501003 | The form can not be operated by the current application. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).||
**Example**
...
...
@@ -161,8 +182,15 @@ Releases a widget. After this API is called, the application can no longer use t
| Error Code ID| Error Message|
| -------- | -------- |
| 201 | Permissions denied. |
| 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
| 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. |
| 16501001 | The ID of the form to be operated does not exist. |
| 16501003 | The form can not be operated by the current application. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).||
**Example**
...
...
@@ -194,7 +222,7 @@ Releases a widget. After this API is called, the application can no longer use t
| Name | Type | Mandatory| Description |
| -------------- | ------ | ---- | ----------- |
| formId | string | Yes | Widget ID. |
| isReleaseCache | boolean | No | Whether to release the cache.|
| isReleaseCache | boolean | No | Whether to release the cache. The default value is **false**. |
**Return value**
...
...
@@ -206,8 +234,15 @@ Releases a widget. After this API is called, the application can no longer use t
| Error Code ID| Error Message|
| -------- | -------- |
| 201 | Permissions denied. |
| 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
| 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. |
| 16501001 | The ID of the form to be operated does not exist. |
| 16501003 | The form can not be operated by the current application. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).||
**Example**
...
...
@@ -245,8 +280,15 @@ Requests a widget update. This API uses an asynchronous callback to return the r
| Error Code ID| Error Message|
| -------- | -------- |
| 201 | Permissions denied. |
| 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
| 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. |
| 16501001 | The ID of the form to be operated does not exist. |
| 16501003 | The form can not be operated by the current application. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).||
**Example**
...
...
@@ -289,8 +331,15 @@ Requests a widget update. This API uses a promise to return the result.
| Error Code ID| Error Message|
| -------- | -------- |
| 201 | Permissions denied. |
| 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
| 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. |
| 16501001 | The ID of the form to be operated does not exist. |
| 16501003 | The form can not be operated by the current application. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).||
**Example**
...
...
@@ -329,8 +378,15 @@ Converts a temporary widget to a normal one. This API uses an asynchronous callb
| Error Code ID| Error Message|
| -------- | -------- |
| 201 | Permissions denied. |
| 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
| 16500050 | An IPC connection error happened. |
| 16501000 | An internal functional error occurred. |
| 16501001 | The ID of the form to be operated does not exist. |
| 16501002 | The number of forms exceeds upper bound. |
| 16501003 | The form can not be operated by the current application. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).||
**Example**
...
...
@@ -373,8 +429,15 @@ Converts a temporary widget to a normal one. This API uses a promise to return t
| Error Code ID| Error Message|
| -------- | -------- |
| 201 | Permissions denied. |
| 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
| 16500050 | An IPC connection error happened. |
| 16501000 | An internal functional error occurred. |
| 16501001 | The ID of the form to be operated does not exist. |
| 16501002 | The number of forms exceeds upper bound. |
| 16501003 | The form can not be operated by the current application. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).||
**Example**
...
...
@@ -412,8 +475,13 @@ Instructs the widget framework to make a widget visible. After this API is calle
| Error Code ID| Error Message|
| -------- | -------- |
| 201 | Permissions denied. |
| 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
| 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).||
**Example**
...
...
@@ -456,8 +524,13 @@ Instructs the widget framework to make a widget visible. After this API is calle
| Error Code ID| Error Message|
| -------- | -------- |
| 201 | Permissions denied. |
| 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
| 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).||
**Example**
...
...
@@ -495,8 +568,13 @@ Instructs the widget framework to make a widget invisible. After this API is cal
| Error Code ID| Error Message|
| -------- | -------- |
| 201 | Permissions denied. |
| 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
| 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).||
**Example**
...
...
@@ -539,8 +617,13 @@ Instructs the widget framework to make a widget invisible. After this API is cal
| Error Code ID| Error Message|
| -------- | -------- |
| 201 | Permissions denied. |
| 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
| 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).||
**Example**
...
...
@@ -578,8 +661,14 @@ Instructs the widget framework to make a widget updatable. After this API is cal
| Error Code ID| Error Message|
| -------- | -------- |
| 201 | Permissions denied. |
| 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
| 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. |
| 16501003 | The form can not be operated by the current application. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).||
**Example**
...
...
@@ -622,8 +711,14 @@ Instructs the widget framework to make a widget updatable. After this API is cal
| Error Code ID| Error Message|
| -------- | -------- |
| 201 | Permissions denied. |
| 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
| 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. |
| 16501003 | The form can not be operated by the current application. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).||
**Example**
...
...
@@ -661,8 +756,15 @@ Instructs the widget framework to make a widget not updatable. After this API is
| Error Code ID| Error Message|
| -------- | -------- |
| 201 | Permissions denied. |
| 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
| 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. |
| 16501001 | The ID of the form to be operated does not exist. |
| 16501003 | The form can not be operated by the current application. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).||
**Example**
...
...
@@ -705,8 +807,15 @@ Instructs the widget framework to make a widget not updatable. After this API is
| Error Code ID| Error Message|
| -------- | -------- |
| 201 | Permissions denied. |
| 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
| 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. |
| 16501001 | The ID of the form to be operated does not exist. |
| 16501003 | The form can not be operated by the current application. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).||
**Example**
...
...
@@ -737,6 +846,14 @@ Checks whether the system is ready. This API uses an asynchronous callback to re
| ------ | ------ | ---- | ------- |
| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the check is successful, **error** is undefined; otherwise, **error** is an error object.|
**Error codes**
| Error Code ID| Error Message|
| -------- | -------- |
| 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).||
**Example**
```ts
...
...
@@ -766,6 +883,13 @@ Checks whether the system is ready. This API uses a promise to return the result
| -------- | -------- |
| Promise<void> | Promise that returns no value.|
**Error codes**
| Error Code ID| Error Message|
| -------- | -------- |
| 202 | The application is not a system application. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).||
**Example**
```ts
...
...
@@ -791,6 +915,18 @@ Obtains the widget information provided by all applications on the device. This
| 202 | The application is not a system application. |
| 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).||
**Return value**
| Type | Description |
...
...
@@ -858,14 +1005,20 @@ Obtains the widget information provided by a given application on the device. Th
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| bundleName | string | Yes| Bundle name of the application.|
| callback | AsyncCallback<Array<[formInfo.FormInfo](js-apis-app-form-formInfo.md)>> | Yes| Callback used to return the result. If the widget information is obtained, **error** is undefined and **data** is the information obtained; otherwise, **error** is an error object.|
| callback | AsyncCallback<Array<[FormInfo](js-apis-app-form-formInfo.md)>> | Yes| Callback used to return the result. If the widget information is obtained, **error** is undefined and **data** is the information obtained; otherwise, **error** is an error object.|
**Error codes**
| Error Code ID| Error Message|
| -------- | -------- |
| 201 | Permissions denied. |
| 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
| 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. |
| 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).||
**Example**
...
...
@@ -899,14 +1052,20 @@ Obtains the widget information provided by a given application on the device. Th
| ------ | ------ | ---- | ------- |
| bundleName | string | Yes| Bundle name of the application.|
| moduleName | string | Yes| Module name.|
| callback | AsyncCallback<Array<[formInfo.FormInfo](js-apis-app-form-formInfo.md)>> | Yes| Callback used to return the result. If the widget information is obtained, **error** is undefined and **data** is the information obtained; otherwise, **error** is an error object.|
| callback | AsyncCallback<Array<[FormInfo](js-apis-app-form-formInfo.md)>> | Yes| Callback used to return the result. If the widget information is obtained, **error** is undefined and **data** is the information obtained; otherwise, **error** is an error object.|
**Error codes**
| Error Code ID| Error Message|
| -------- | -------- |
| 201 | Permissions denied. |
| 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
| 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. |
| 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).||
**Example**
...
...
@@ -939,7 +1098,7 @@ Obtains the widget information provided by a given application on the device. Th
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| bundleName | string | Yes| Bundle name of the application.|
| moduleName | string | No| Module name.|
| moduleName | string | No| Module name. By default, no value is passed.|
**Return value**
...
...
@@ -951,8 +1110,14 @@ Obtains the widget information provided by a given application on the device. Th
| Error Code ID| Error Message|
| -------- | -------- |
| 201 | Permissions denied. |
| 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
| 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. |
| 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).||
**Example**
...
...
@@ -985,6 +1150,18 @@ Deletes invalid widgets from the list. This API uses an asynchronous callback to
| formIds | Array<string> | Yes | List of valid widget IDs.|
| callback | AsyncCallback<number> | Yes| Callback used to return the result. If the invalid widgets are deleted, **error** is undefined and **data** is the number of widgets deleted; otherwise, **error** is an error object.|
**Error codes**
| Error Code ID| Error Message|
| -------- | -------- |
| 201 | Permissions denied. |
| 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
| 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).||
**Example**
```ts
...
...
@@ -1024,6 +1201,18 @@ Deletes invalid widgets from the list. This API uses a promise to return the res
| Promise<number> | Promise used to return the number of widgets deleted.|
**Error codes**
| Error Code ID| Error Message|
| -------- | -------- |
| 201 | Permissions denied. |
| 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
| 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).||
**Example**
```ts
...
...
@@ -1054,14 +1243,20 @@ Obtains the widget state. This API uses an asynchronous callback to return the r
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| want | [Want](js-apis-application-want.md) | Yes | **Want** information carried to query the widget state. The information must contain the bundle name, ability name, module name, widget name, and widget dimensions.|
| callback | AsyncCallback<[FormInfo](js-apis-app-form-formInfo.md#formstateinfo)> | Yes| Callback used to return the result. If the widget state is obtained, **error** is undefined and **data** is the widget state obtained; otherwise, **error** is an error object.|
| callback | AsyncCallback<[FormStateInfo](js-apis-app-form-formInfo.md#formstateinfo)> | Yes| Callback used to return the result. If the widget state is obtained, **error** is undefined and **data** is the widget state obtained; otherwise, **error** is an error object.|
**Error codes**
| Error Code ID| Error Message|
| -------- | -------- |
| 201 | Permissions denied. |
| 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
| 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. |
| 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).||
**Example**
...
...
@@ -1115,8 +1310,14 @@ Obtains the widget state. This API uses a promise to return the result.
| Error Code ID| Error Message|
| -------- | -------- |
| 201 | Permissions denied. |
| 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
| 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. |
| 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).||
**Example**
...
...
@@ -1157,6 +1358,14 @@ Subscribes to widget uninstall events. This API uses an asynchronous callback to
| type | string | Yes | Event type. The value **'formUninstall'** indicates a widget uninstallation event.|
| callback | Callback<string> | Yes| Callback used to return the widget ID.|
**Error codes**
| Error Code ID| Error Message|
| -------- | -------- |
| 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).||
**Example**
```ts
...
...
@@ -1181,6 +1390,14 @@ Unsubscribes from widget uninstall events. This API uses an asynchronous callbac
| type | string | Yes | Event type. The value **'formUninstall'** indicates a widget uninstallation event.|
| callback | Callback<string> | No| Callback used to return the widget ID. If it is left unspecified, it indicates the callback for all the events that have been subscribed.<br> The value must be the same as that in **on('formUninstall')**.|
**Error codes**
| Error Code ID| Error Message|
| -------- | -------- |
| 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).||
**Example**
```ts
...
...
@@ -1212,8 +1429,14 @@ Instructs the widgets to make themselves visible. This API uses an asynchronous
| Error Code ID| Error Message|
| -------- | -------- |
| 201 | Permissions denied. |
| 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
| 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. |
| 16501003 | The form can not be operated by the current application. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).||
**Example**
...
...
@@ -1257,8 +1480,14 @@ Instructs the widgets to make themselves visible. This API uses a promise to ret
| Error Code ID| Error Message|
| -------- | -------- |
| 201 | Permissions denied. |
| 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
| 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. |
| 16501003 | The form can not be operated by the current application. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).||
**Example**
...
...
@@ -1297,8 +1526,14 @@ Instructs the widgets to enable or disable updates. This API uses an asynchronou
| Error Code ID| Error Message|
| -------- | -------- |
| 201 | Permissions denied. |
| 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
| 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. |
| 16501003 | The form can not be operated by the current application. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).||
**Example**
...
...
@@ -1342,8 +1577,14 @@ Instructs the widgets to enable or disable updates. This API uses a promise to r
| Error Code ID| Error Message|
| -------- | -------- |
| 201 | Permissions denied. |
| 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
| 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. |
| 16501003 | The form can not be operated by the current application. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).||
**Example**
...
...
@@ -1381,9 +1622,14 @@ Shares a specified widget with a remote device. This API uses an asynchronous ca
| Error Code ID| Error Message|
| -------- | -------- |
| 201 | Permissions denied. |
| 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
| 16500050 | An IPC connection error happened. |
| 16501000 | An internal functional error occurred. |
| 16501001 | The ID of the form to be operated does not exist. |
| 16501003 | The form can not be operated by the current application. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).||
**Example**
...
...
@@ -1428,8 +1674,14 @@ Shares a specified widget with a remote device. This API uses a promise to retur
| Error Code ID| Error Message|
| -------- | -------- |
| 201 | Permissions denied. |
| 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
| 16500050 | An IPC connection error happened. |
| 16501000 | An internal functional error occurred. |
| 16501001 | The ID of the form to be operated does not exist. |
| 16501003 | The form can not be operated by the current application. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).||
**Example**
...
...
@@ -1461,11 +1713,78 @@ Notifies that the privacy protection status of the specified widgets changes. Th
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formId | string | Yes | Widget ID.|
| deviceId | string | Yes | Remote device ID. |
| formIds | Array\<string\> | Yes | ID of the widgets.|
| callback | AsyncCallback\<void> | Yes| Callback used to return the result. If privacy protection is set successfully, **error** is undefined; otherwise, **error** is an error object.|
**Error codes**
| Error Code ID| Error Message|
| -------- | -------- |
| 201 | Permissions denied. |
| 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
| 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. |
| For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).| |
The **FormProvider** module provides APIs related to the widget provider. You can use the APIs to update a widget, set the next refresh time for a widget, obtain widget information, and request a widget release.
...
...
@@ -32,19 +32,26 @@ Sets the next refresh time for a widget. This API uses an asynchronous callback
| Error Code ID| Error Message|
| -------- | -------- |
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
| 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. |
| 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. |
| 16501001 | The ID of the form to be operated does not exist. |
| 16501002 | The number of forms exceeds upper bound. |
| 16501003 | The form can not be operated by the current application. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).||
| want | [Want](js-apis-application-want.md) | Yes | Request used for publishing. The following fields must be included:<br>Information about the target widget.<br>**abilityName**: ability of the target widget.<br>**parameters**:<br>'ohos.extra.param.key.form_dimension'<br>'ohos.extra.param.key.form_name'<br>'ohos.extra.param.key.module_name' |
| formBindingData.FormBindingData | [FormBindingData](js-apis-app-form-formBindingData.md#formbindingdata) | Yes | Data used for creating the widget.|
| formBindingData.FormBindingData | [FormBindingData](js-apis-app-form-formBindingData.md#formbindingdata)| Yes | Data used for creating the widget.|
| callback | AsyncCallback<string> | Yes| Callback used to return the widget ID.|
**Error codes**
| Error Code ID| Error Message|
| -------- | -------- |
| 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
| 16500050 | An IPC connection error happened. |
| 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).||
| want | [Want](js-apis-application-want.md) | Yes | Request used for publishing. The following fields must be included:<br>Information about the target widget.<br>**abilityName**: ability of the target widget.<br>**parameters**:<br>'ohos.extra.param.key.form_dimension'<br>'ohos.extra.param.key.form_name'<br>'ohos.extra.param.key.module_name' |
| formBindingData.FormBindingData | [FormBindingData](js-apis-app-form-formBindingData.md#formbindingdata) | No | Data used for creating the widget. |
| formBindingData.FormBindingData | [FormBindingData](js-apis-app-form-formBindingData.md#formbindingdata) | No | Data used for creating the widget. By default, no value is passed, indicating that no data is provided. |
**Return value**
...
...
@@ -436,8 +478,12 @@ Requests to publish a widget to the widget host. This API uses a promise to retu
| Error Code ID| Error Message|
| -------- | -------- |
| 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
| 16500050 | An IPC connection error happened. |
| 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).||
**Example**
...
...
@@ -477,6 +523,16 @@ Checks whether a widget can be published to the widget host. This API uses an as
| ------ | ------ | ---- | ------- |
| callback | AsyncCallback<boolean> | Yes| Callback used to return whether the widget can be published to the widget host.|
**Error codes**
| Error Code ID| Error Message|
| -------- | -------- |
| 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
| 16500050 | An IPC connection error happened. |
| 16501000 | An internal functional error occurred. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).||
**Example**
```ts
...
...
@@ -530,6 +586,15 @@ Checks whether a widget can be published to the widget host. This API uses a pro
@@ -9,6 +9,12 @@ You can use the APIs of this module to start FormExtensionAbilities.
> 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.
## Modules to Import
```ts
importcommonfrom'@ohos.app.ability.common';
```
## Usage
Before using the **ServiceExtensionContext** module, you must first obtain a **FormExtensionAbility** instance.
...
...
@@ -18,7 +24,7 @@ import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';