提交 d2a0a31d 编写于 作者: W wusongqing

updated docs

Signed-off-by: Nwusongqing <wusongqing@huawei.com>
上级 449ce282
...@@ -7,9 +7,10 @@ ...@@ -7,9 +7,10 @@
```js ```js
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
import bundle from '@ohos.bundle'
``` ```
## Usage
The **Context** object is created in a **featureAbility** and returned through its **getContext()** API. Therefore, you must import the **@ohos.ability.featureAbility** package before using the Context module. An example is as follows: The **Context** object is created in a **featureAbility** and returned through its **getContext()** API. Therefore, you must import the **@ohos.ability.featureAbility** package before using the Context module. An example is as follows:
```js ```js
...@@ -30,9 +31,9 @@ If this API is called for the first time, a root directory will be created. ...@@ -30,9 +31,9 @@ If this API is called for the first time, a root directory will be created.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | -------------------------- | | -------- | ---------------------- | ---- | -------------------------- |
| callback | AsyncCallback\<string> | Yes | Callback used to return the local root directory. | | callback | AsyncCallback\<string> | Yes | Callback used to return the local root directory.|
**Example** **Example**
...@@ -58,9 +59,9 @@ If this API is called for the first time, a root directory will be created. ...@@ -58,9 +59,9 @@ If this API is called for the first time, a root directory will be created.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------- | ---------------------- | | ---------------- | ---------------------- |
| Promise\<string> | Promise used to return the local root directory. | | Promise\<string> | Promise used to return the local root directory.|
**Example** **Example**
...@@ -84,11 +85,11 @@ Verifies whether a specific PID and UID have the given permission. This API uses ...@@ -84,11 +85,11 @@ Verifies whether a specific PID and UID have the given permission. This API uses
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| ---------- | --------------------------------------- | ---- | ------------------------------------- | | ---------- | --------------------------------------- | ---- | ------------------------------------- |
| permission | string | Yes | Name of the permission to verify. | | permission | string | Yes | Name of the permission to verify. |
| options | [PermissionOptions](#permissionoptions) | Yes | Permission options. | | options | [PermissionOptions](#permissionoptions) | Yes | Permission options. |
| callback | AsyncCallback\<number> | Yes | Callback used to return the permission verification result. The value **0** indicates that the PID and UID have the given permission, and the value **-1** indicates that the PID and UID do not have the given permission. | | callback | AsyncCallback\<number> | Yes | Callback used to return the permission verification result. The value **0** indicates that the PID and UID have the given permission, and the value **-1** indicates that the PID and UID do not have the given permission.|
**Example** **Example**
...@@ -96,8 +97,8 @@ Verifies whether a specific PID and UID have the given permission. This API uses ...@@ -96,8 +97,8 @@ Verifies whether a specific PID and UID have the given permission. This API uses
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
import bundle from '@ohos.bundle' import bundle from '@ohos.bundle'
var context = featureAbility.getContext(); var context = featureAbility.getContext();
bundle.getBundleInfo('com.context.test', 1, (datainfo) =>{ bundle.getBundleInfo('com.context.test', 1, (err,datainfo) =>{
context.verifyPermission("com.example.permission", datainfo.uid); context.verifyPermission("com.example.permission", {uid:datainfo.uid});
}); });
``` ```
...@@ -113,10 +114,10 @@ Verifies whether the current PID and UID have the given permission. This API use ...@@ -113,10 +114,10 @@ Verifies whether the current PID and UID have the given permission. This API use
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| ---------- | ---------------------- | ---- | ------------------------------------- | | ---------- | ---------------------- | ---- | ------------------------------------- |
| permission | string | Yes | Name of the permission to verify. | | permission | string | Yes | Name of the permission to verify. |
| callback | AsyncCallback\<number> | Yes | Callback used to return the permission verification result. The value **0** indicates that the PID and UID have the given permission, and the value **-1** indicates that the PID and UID do not have the given permission. | | callback | AsyncCallback\<number> | Yes | Callback used to return the permission verification result. The value **0** indicates that the PID and UID have the given permission, and the value **-1** indicates that the PID and UID do not have the given permission.|
**Example** **Example**
...@@ -136,23 +137,23 @@ Verifies whether a specific PID and UID have the given permission. This API uses ...@@ -136,23 +137,23 @@ Verifies whether a specific PID and UID have the given permission. This API uses
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| ---------- | --------------------------------------- | ---- | ---------------- | | ---------- | --------------------------------------- | ---- | ---------------- |
| permission | string | Yes | Name of the permission to verify. | | permission | string | Yes | Name of the permission to verify.|
| options | [PermissionOptions](#permissionoptions) | No | Permission options. | | options | [PermissionOptions](#permissionoptions) | No | Permission options. |
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------- | ----------------------------------------------------------- | | ---------------- | ----------------------------------------------------------- |
| Promise\<number> | Promise used to return the permission verification result. The value **0** indicates that the PID and UID have the given permission, and the value **-1** indicates that the PID and UID do not have the given permission. | | Promise\<number> | Promise used to return the permission verification result. The value **0** indicates that the PID and UID have the given permission, and the value **-1** indicates that the PID and UID do not have the given permission.|
**Example** **Example**
```js ```js
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext(); var context = featureAbility.getContext();
var Permission = context.PermissionOptions(1,1); var Permission = {pid:1};
context.verifyPermission('com.context.permission',Permission).then((data) => { context.verifyPermission('com.context.permission',Permission).then((data) => {
console.info("======================>verifyPermissionCallback====================>"); console.info("======================>verifyPermissionCallback====================>");
console.info("====>data====>" + JSON.stringify(data)); console.info("====>data====>" + JSON.stringify(data));
...@@ -171,11 +172,11 @@ Requests certain permissions from the system. This API uses an asynchronous call ...@@ -171,11 +172,11 @@ Requests certain permissions from the system. This API uses an asynchronous call
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| -------------- | ------------------------------------------------------------ | ---- | ----------------------------------------------- | | -------------- | ------------------------------------------------------------ | ---- | ----------------------------------------------- |
| permissions | Array\<string> | Yes | Permissions to request. This parameter cannot be **null**. | | permissions | Array\<string> | Yes | Permissions to request. This parameter cannot be **null**. |
| requestCode | number | Yes | Request code to be passed to **PermissionRequestResult**. | | requestCode | number | Yes | Request code to be passed to **PermissionRequestResult**.|
| resultCallback | AsyncCallback<[PermissionRequestResult](#permissionrequestresult)> | Yes | Permission request result. | | resultCallback | AsyncCallback<[PermissionRequestResult](#permissionrequestresult)> | Yes | Permission request result. |
**Example** **Example**
...@@ -207,9 +208,9 @@ Obtains information about the current application. This API uses an asynchronous ...@@ -207,9 +208,9 @@ Obtains information about the current application. This API uses an asynchronous
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------- | ---- | ------------------------ | | -------- | ------------------------------- | ---- | ------------------------ |
| callback | AsyncCallback\<ApplicationInfo> | Yes | Callback used to return the application information. | | callback | AsyncCallback\<ApplicationInfo> | Yes | Callback used to return the application information.|
**Example** **Example**
...@@ -231,9 +232,9 @@ Obtains information about the current application. This API uses a promise to re ...@@ -231,9 +232,9 @@ Obtains information about the current application. This API uses a promise to re
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------------- | ------------------ | | ------------------------- | ------------------ |
| Promise\<ApplicationInfo> | Promise used to return the application information. | | Promise\<ApplicationInfo> | Promise used to return the application information.|
**Example** **Example**
...@@ -258,9 +259,9 @@ Obtains the bundle name of the current ability. This API uses an asynchronous ca ...@@ -258,9 +259,9 @@ Obtains the bundle name of the current ability. This API uses an asynchronous ca
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ----------------------------- | | -------- | ---------------------- | ---- | ----------------------------- |
| callback | AsyncCallback\<string> | Yes | Callback used to return the bundle name. | | callback | AsyncCallback\<string> | Yes | Callback used to return the bundle name.|
**Example** **Example**
...@@ -282,9 +283,9 @@ Obtains the bundle name of the current ability. This API uses a promise to retur ...@@ -282,9 +283,9 @@ Obtains the bundle name of the current ability. This API uses a promise to retur
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------- | ------------------------- | | ---------------- | ------------------------- |
| Promise\<string> | Promise used to return the bundle name. | | Promise\<string> | Promise used to return the bundle name.|
**Example** **Example**
...@@ -309,9 +310,9 @@ Obtains information about the current process, including the PID and process nam ...@@ -309,9 +310,9 @@ Obtains information about the current process, including the PID and process nam
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | -------------------- | | -------- | --------------------------- | ---- | -------------------- |
| callback | AsyncCallback\<ProcessInfo> | Yes | Callback used to return the process information. | | callback | AsyncCallback\<ProcessInfo> | Yes | Callback used to return the process information.|
**Example** **Example**
...@@ -333,9 +334,9 @@ Obtains information about the current process, including the PID and process nam ...@@ -333,9 +334,9 @@ Obtains information about the current process, including the PID and process nam
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | -------------- | | --------------------- | -------------- |
| Promise\<ProcessInfo> | Promise used to return the process information. | | Promise\<ProcessInfo> | Promise used to return the process information.|
**Example** **Example**
...@@ -362,9 +363,9 @@ This API is available only to Page abilities. ...@@ -362,9 +363,9 @@ This API is available only to Page abilities.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | ---------------------------------------------- | | -------- | --------------------------- | ---- | ---------------------------------------------- |
| callback | AsyncCallback\<ElementName> | Yes | Callback used to return the **ohos.bundle.ElementName** object. | | callback | AsyncCallback\<ElementName> | Yes | Callback used to return the **ohos.bundle.ElementName** object.|
**Example** **Example**
...@@ -388,9 +389,9 @@ This API is available only to Page abilities. ...@@ -388,9 +389,9 @@ This API is available only to Page abilities.
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------- | ------------------------------------------ | | --------------------- | ------------------------------------------ |
| Promise\<ElementName> | Promise used to return the **ohos.bundle.ElementName** object. | | Promise\<ElementName> | Promise used to return the **ohos.bundle.ElementName** object.|
**Example** **Example**
...@@ -413,9 +414,9 @@ Obtains the name of the current process. This API uses an asynchronous callback ...@@ -413,9 +414,9 @@ Obtains the name of the current process. This API uses an asynchronous callback
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | -------------------- | | -------- | ---------------------- | ---- | -------------------- |
| callback | AsyncCallback\<string> | Yes | Callback used to return the process name. | | callback | AsyncCallback\<string> | Yes | Callback used to return the process name.|
**Example** **Example**
...@@ -437,9 +438,9 @@ Obtains the name of the current process. This API uses a promise to return the r ...@@ -437,9 +438,9 @@ Obtains the name of the current process. This API uses a promise to return the r
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------- | -------------------- | | ---------------- | -------------------- |
| Promise\<string> | Promise used to return the process name. | | Promise\<string> | Promise used to return the process name.|
**Example** **Example**
...@@ -464,9 +465,9 @@ Obtains the bundle name of the calling ability. This API uses an asynchronous ca ...@@ -464,9 +465,9 @@ Obtains the bundle name of the calling ability. This API uses an asynchronous ca
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ------------------------- | | -------- | ---------------------- | ---- | ------------------------- |
| callback | AsyncCallback\<string> | Yes | Callback used to return the bundle name. | | callback | AsyncCallback\<string> | Yes | Callback used to return the bundle name.|
**Example** **Example**
...@@ -488,9 +489,9 @@ Obtains the bundle name of the calling ability. This API uses a promise to retur ...@@ -488,9 +489,9 @@ Obtains the bundle name of the calling ability. This API uses a promise to retur
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------- | ------------------------- | | --------------- | ------------------------- |
| Promise\<string> | Promise used to return the bundle name. | | Promise\<string> | Promise used to return the bundle name.|
**Example** **Example**
...@@ -513,9 +514,9 @@ Obtains the cache directory of the application on the internal storage. This API ...@@ -513,9 +514,9 @@ Obtains the cache directory of the application on the internal storage. This API
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ------------------------- | | -------- | ---------------------- | ---- | ------------------------- |
| callback | AsyncCallback\<string> | Yes | Callback used to return the cache directory. | | callback | AsyncCallback\<string> | Yes | Callback used to return the cache directory.|
**Example** **Example**
...@@ -541,9 +542,9 @@ Obtains the cache directory of the application on the internal storage. This API ...@@ -541,9 +542,9 @@ Obtains the cache directory of the application on the internal storage. This API
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------- | ------------------------- | | --------------- | ------------------------- |
| Promise\<string> | Promise used to return the cache directory. | | Promise\<string> | Promise used to return the cache directory.|
**Example** **Example**
...@@ -566,9 +567,9 @@ Obtains the file directory of the application on the internal storage. This API ...@@ -566,9 +567,9 @@ Obtains the file directory of the application on the internal storage. This API
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ------------------------- | | -------- | ---------------------- | ---- | ------------------------- |
| callback | AsyncCallback\<string> | Yes | Callback used to return the file directory. | | callback | AsyncCallback\<string> | Yes | Callback used to return the file directory.|
**Example** **Example**
...@@ -594,9 +595,9 @@ Obtains the file directory of the application on the internal storage. This API ...@@ -594,9 +595,9 @@ Obtains the file directory of the application on the internal storage. This API
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------- | ------------------------- | | --------------- | ------------------------- |
| Promise\<string> | Promise used to return the file directory. | | Promise\<string> | Promise used to return the file directory.|
**Example** **Example**
...@@ -621,9 +622,9 @@ If the distributed file path does not exist, the system will create one and retu ...@@ -621,9 +622,9 @@ If the distributed file path does not exist, the system will create one and retu
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ------------------------- | | -------- | ---------------------- | ---- | ------------------------- |
| callback | AsyncCallback\<string> | Yes | Callback used to return the distributed file path. If the distributed file path does not exist, the system will create one and return the created path. | | callback | AsyncCallback\<string> | Yes | Callback used to return the distributed file path. If the distributed file path does not exist, the system will create one and return the created path.|
**Example** **Example**
...@@ -651,9 +652,9 @@ If the distributed file path does not exist, the system will create one and retu ...@@ -651,9 +652,9 @@ If the distributed file path does not exist, the system will create one and retu
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------- | ------------------------- | | --------------- | ------------------------- |
| Promise\<string> | Promise used to return the distributed file path. If this API is called for the first time, a new path will be created. | | Promise\<string> | Promise used to return the distributed file path. If this API is called for the first time, a new path will be created.|
**Example** **Example**
...@@ -675,9 +676,9 @@ Obtains the application type. This API uses an asynchronous callback to return t ...@@ -675,9 +676,9 @@ Obtains the application type. This API uses an asynchronous callback to return t
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ------------------------- | | -------- | ---------------------- | ---- | ------------------------- |
| callback | AsyncCallback\<string> | Yes | Callback used to return the application type. | | callback | AsyncCallback\<string> | Yes | Callback used to return the application type.|
**Example** **Example**
...@@ -703,9 +704,9 @@ Obtains the application type. This API uses a promise to return the result. ...@@ -703,9 +704,9 @@ Obtains the application type. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------- | ------------------------- | | --------------- | ------------------------- |
| Promise\<string> | Promise used to return the application type. | | Promise\<string> | Promise used to return the application type.|
**Example** **Example**
...@@ -727,9 +728,9 @@ Obtains the **ModuleInfo** object of the application. This API uses an asynchron ...@@ -727,9 +728,9 @@ Obtains the **ModuleInfo** object of the application. This API uses an asynchron
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ------------------------- | | -------- | ---------------------- | ---- | ------------------------- |
| callback | AsyncCallback\<[HapModuleInfo](#hapmoduleinfo)> | Yes | Callback used to return the **ModuleInfo** object. | | callback | AsyncCallback\<[HapModuleInfo](#hapmoduleinfo)> | Yes | Callback used to return the **ModuleInfo** object.|
**Example** **Example**
...@@ -755,9 +756,9 @@ Obtains the **ModuleInfo** object of the application. This API uses a promise to ...@@ -755,9 +756,9 @@ Obtains the **ModuleInfo** object of the application. This API uses a promise to
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------- | ------------------------- | | --------------- | ------------------------- |
| Promise\<[HapModuleInfo](#hapmoduleinfo)> | Promise used to return the **ModuleInfo** object. | | Promise\<[HapModuleInfo](#hapmoduleinfo)> | Promise used to return the **ModuleInfo** object.|
**Example** **Example**
...@@ -779,9 +780,9 @@ Obtains the version information of the application. This API uses an asynchronou ...@@ -779,9 +780,9 @@ Obtains the version information of the application. This API uses an asynchronou
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ------------------------- | | -------- | ---------------------- | ---- | ------------------------- |
| callback | AsyncCallback\<[AppVersionInfo](#appversioninfo)> | Yes | Callback used to return the version information. | | callback | AsyncCallback\<[AppVersionInfo](#appversioninfo)> | Yes | Callback used to return the version information.|
**Example** **Example**
...@@ -807,9 +808,9 @@ Obtains the version information of the application. This API uses a promise to r ...@@ -807,9 +808,9 @@ Obtains the version information of the application. This API uses a promise to r
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------- | ------------------------- | | --------------- | ------------------------- |
| Promise\<[AppVersionInfo](#appversioninfo)> | Promise used to return the version information. | | Promise\<[AppVersionInfo](#appversioninfo)> | Promise used to return the version information.|
**Example** **Example**
...@@ -831,9 +832,9 @@ Obtains information of the current ability. This API uses an asynchronous callba ...@@ -831,9 +832,9 @@ Obtains information of the current ability. This API uses an asynchronous callba
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ------------------------- | | -------- | ---------------------- | ---- | ------------------------- |
| callback | AsyncCallback\<[AbilityInfo](#abilityInfo)> | Yes |Callback used to return the ability information. | | callback | AsyncCallback\<[AbilityInfo](#abilityInfo)> | Yes |Callback used to return the ability information.|
**Example** **Example**
...@@ -859,9 +860,9 @@ Obtains information of the current ability. This API uses a promise to return th ...@@ -859,9 +860,9 @@ Obtains information of the current ability. This API uses a promise to return th
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------- | ------------------------- | | --------------- | ------------------------- |
| Promise\<[AbilityInfo](#abilityInfo)> | Promise used to return the ability information. | | Promise\<[AbilityInfo](#abilityInfo)> | Promise used to return the ability information.|
**Example** **Example**
...@@ -883,9 +884,9 @@ Obtains the context of the application. ...@@ -883,9 +884,9 @@ Obtains the context of the application.
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------- |------ | | --------- |------ |
| Context |Application context. | | Context |Application context.|
**Example** **Example**
...@@ -898,48 +899,48 @@ var context = featureAbility.getContext().getApplicationContext(); ...@@ -898,48 +899,48 @@ var context = featureAbility.getContext().getApplicationContext();
**System capability**: SystemCapability.Ability.AbilityRuntime.Core **System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name| Readable/Writable | Type | Mandatory | Description | | Name| Readable/Writable| Type | Mandatory| Description |
| ---- | -------- | ------ | ---- | ------ | | ---- | -------- | ------ | ---- | ------ |
| pid | Read-only | number | No | Process ID. | | pid | Read-only | number | No | Process ID.|
| uid | Read-only | number | No | User ID. | | uid | Read-only | number | No | User ID.|
## PermissionRequestResult<sup>7+</sup> ## PermissionRequestResult<sup>7+</sup>
**System capability**: SystemCapability.Ability.AbilityRuntime.Core **System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Readable/Writable | Type | Mandatory | Description | | Name | Readable/Writable| Type | Mandatory| Description |
| ----------- | -------- | -------------- | ---- | ------------------ | | ----------- | -------- | -------------- | ---- | ------------------ |
| requestCode | Read-only | number | Yes | Request code passed. | | requestCode | Read-only | number | Yes | Request code passed.|
| permissions | Read-only | Array\<string> | Yes | Permissions requested. | | permissions | Read-only | Array\<string> | Yes | Permissions requested. |
| authResults | Read-only | Array\<number> | Yes | Permission request result. | | authResults | Read-only | Array\<number> | Yes | Permission request result. |
## HapModuleInfo<sup>7+</sup> ## HapModuleInfo<sup>7+</sup>
Describes the HAP module information. Describes the HAP module information.
| Name | Type| Readable | Writable | Description | | Name | Type| Readable| Writable| Description|
| ------ | ------ | ------ | ------ | ------ | | ------ | ------ | ------ | ------ | ------ |
| name | string | Yes | No | Module name. | | name | string | Yes | No | Module name. |
| description | string | Yes | No | Module description. | | description | string | Yes | No | Module description. |
| descriptionId | number | Yes | No | Module description ID. | | descriptionId | number | Yes | No | Module description ID. |
| icon | string | Yes | No | Module icon. | | icon | string | Yes | No | Module icon. |
| label | string | Yes | No | Module label. | | label | string | Yes | No | Module label. |
| labelId | number | Yes | No | Module label ID. | | labelId | number | Yes | No | Module label ID. |
| iconId | number | Yes | No | Module icon ID. | | iconId | number | Yes | No | Module icon ID. |
| backgroundImg | string | Yes | No | Module background image. | | backgroundImg | string | Yes | No | Module background image. |
| supportedModes | number | Yes | No | Modes supported by the module. | | supportedModes | number | Yes | No | Modes supported by the module. |
| reqCapabilities | Array<string> | Yes | No | Capabilities required for module running. | | reqCapabilities | Array<string> | Yes | No | Capabilities required for module running.|
| deviceTypes | Array<string> | Yes | No | An array of supported device types. | | deviceTypes | Array<string> | Yes | No | An array of supported device types.|
| abilityInfo | Array<AbilityInfo> | Yes | No | Ability information. | | abilityInfo | Array<AbilityInfo> | Yes | No | Ability information. |
| moduleName | string | Yes | No | Module name. | | moduleName | string | Yes | No | Module name. |
| mainAbilityName | string | Yes | No | Name of the entrance ability. | | mainAbilityName | string | Yes | No | Name of the entrance ability. |
| installationFree | boolean | Yes | No | When installation-free is supported. | | installationFree | boolean | Yes | No | When installation-free is supported. |
| mainElementName | string | Yes| No| Information about the entry ability. | | mainElementName | string | Yes| No| Information about the entry ability.|
## AppVersionInfo<sup>7+</sup> ## AppVersionInfo<sup>7+</sup>
| Name | Type| Readable | Writable | Description | | Name | Type| Readable | Writable | Description|
| ------ | ------ | ------| ------ | ------ | | ------ | ------ | ------| ------ | ------ |
| appName | string | Yes | No | Module name. | | appName | string | Yes | No | Module name. |
| versionCode | number | Yes | No | Module description. | | versionCode | number | Yes | No | Module description. |
| versionName | string | Yes | No | Module description ID. | | versionName | string | Yes | No | Module description ID. |
# DataUriUtils Module # DataUriUtils Module
> **NOTE**<br> > **NOTE**<br/>
> 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. > 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 ## Modules to Import
...@@ -19,20 +19,20 @@ Obtains the ID attached to the end of a given URI. ...@@ -19,20 +19,20 @@ Obtains the ID attached to the end of a given URI.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name| Type | Mandatory| Description |
| ---- | ------ | ---- | --------------------------- | | ---- | ------ | ---- | --------------------------- |
| uri | string | Yes | URI object from which the ID is to be obtained. | | uri | string | Yes | URI object from which the ID is to be obtained.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | ------------------------ | | ------ | ------------------------ |
| number | ID obtained from the URI object. | | number | ID obtained from the URI object.|
**Example** **Example**
```js ```js
dataUriUtils.getIdSync("com.example.dataUriUtils/1221") dataUriUtils.getId("com.example.dataUriUtils/1221")
``` ```
...@@ -47,16 +47,16 @@ Attaches an ID to the end of a given URI. ...@@ -47,16 +47,16 @@ Attaches an ID to the end of a given URI.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name| Type | Mandatory| Description |
| ---- | ------ | ---- | --------------------------- | | ---- | ------ | ---- | --------------------------- |
| uri | string | Yes | URI object to which an ID is to be attached. | | uri | string | Yes | URI object to which an ID is to be attached.|
| id | number | Yes | ID to be attached. | | id | number | Yes | ID to be attached. |
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | --------------------- | | ------ | --------------------- |
| string | URI object with the ID attached. | | string | URI object with the ID attached.|
**Example** **Example**
...@@ -80,15 +80,15 @@ Deletes the ID from the end of a given URI. ...@@ -80,15 +80,15 @@ Deletes the ID from the end of a given URI.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name| Type | Mandatory| Description |
| ---- | ------ | ---- | --------------------------- | | ---- | ------ | ---- | --------------------------- |
| uri | string | Yes | URI object from which the ID is to be deleted. | | uri | string | Yes | URI object from which the ID is to be deleted.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | ------------------- | | ------ | ------------------- |
| string | URI object with the ID deleted. | | string | URI object with the ID deleted.|
**Example** **Example**
...@@ -108,16 +108,16 @@ Updates the ID in a given URI. ...@@ -108,16 +108,16 @@ Updates the ID in a given URI.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name| Type | Mandatory| Description |
| ---- | ------ | ---- | ------------------- | | ---- | ------ | ---- | ------------------- |
| uri | string | Yes | URI object to be updated. | | uri | string | Yes | URI object to be updated.|
| id | number | Yes | New ID. | | id | number | Yes | New ID. |
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | --------------- | | ------ | --------------- |
| string | URI object with the new ID. | | string | URI object with the new ID.|
**Example** **Example**
......
# AbilityContext # AbilityContext
> **NOTE**<br> > **NOTE**<br/>
> 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 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.
Implements the ability context. This module is inherited from **Context**. Implements the ability context. This module is inherited from **Context**.
## Modules to Import
```js
import Ability from '@ohos.application.Ability'
```
## Usage ## Usage
Before using the **AbilityContext** module, you must define a child class that inherits from **Ability**. Before using the **AbilityContext** module, you must define a child class that inherits from **Ability**.
```js ```js
import Ability from '@ohos.application.Ability' import Ability from '@ohos.application.Ability'
class MainAbility extends Ability { class MainAbility extends Ability {
...@@ -28,7 +28,7 @@ class MainAbility extends Ability { ...@@ -28,7 +28,7 @@ class MainAbility extends Ability {
**System capability**: SystemCapability.Ability.AbilityRuntime.Core **System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Type | Readable | Writable | Description | | Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| abilityInfo | AbilityInfo | Yes| No| Ability information.| | abilityInfo | AbilityInfo | Yes| No| Ability information.|
| currentHapModuleInfo | HapModuleInfo | Yes| No| Information about the current HAP.| | currentHapModuleInfo | HapModuleInfo | Yes| No| Information about the current HAP.|
...@@ -44,7 +44,7 @@ Starts an ability. This API uses a callback to return the result. ...@@ -44,7 +44,7 @@ Starts an ability. This API uses a callback to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| | want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
...@@ -73,7 +73,7 @@ Starts an ability. This API uses a callback to return the result. ...@@ -73,7 +73,7 @@ Starts an ability. This API uses a callback to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| | want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
| options | StartOptions | Yes| Parameters used for starting the ability.| | options | StartOptions | Yes| Parameters used for starting the ability.|
...@@ -106,14 +106,14 @@ Starts an ability. This API uses a promise to return the result. ...@@ -106,14 +106,14 @@ Starts an ability. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| | want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
| options | StartOptions | No| Parameters used for starting the ability.| | options | StartOptions | No| Parameters used for starting the ability.|
**Return value** **Return value**
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
...@@ -147,7 +147,7 @@ Starts an ability. This API uses a callback to return the execution result when ...@@ -147,7 +147,7 @@ Starts an ability. This API uses a callback to return the execution result when
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| want |[Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| | want |[Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
| callback | AsyncCallback&lt;[AbilityResult](js-apis-featureAbility.md#abilityresult)&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;[AbilityResult](js-apis-featureAbility.md#abilityresult)&gt; | Yes| Callback used to return the result.|
...@@ -157,7 +157,7 @@ Starts an ability. This API uses a callback to return the execution result when ...@@ -157,7 +157,7 @@ Starts an ability. This API uses a callback to return the execution result when
```js ```js
this.context.startAbilityForResult( this.context.startAbilityForResult(
{bundleName: "com.extreme.myapplication", abilityName: "MainAbilityDemo2"}, {deviceId: "", bundleName: "com.extreme.myapplication", abilityName: "MainAbilityDemo2"},
(error, result) => { (error, result) => {
console.log("startAbilityForResult AsyncCallback is called, error.code = " + error.code) console.log("startAbilityForResult AsyncCallback is called, error.code = " + error.code)
console.log("startAbilityForResult AsyncCallback is called, result.resultCode = " + result.resultCode) console.log("startAbilityForResult AsyncCallback is called, result.resultCode = " + result.resultCode)
...@@ -175,7 +175,7 @@ Starts an ability. This API uses a callback to return the execution result when ...@@ -175,7 +175,7 @@ Starts an ability. This API uses a callback to return the execution result when
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| want |[Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| | want |[Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
| options | StartOptions | Yes| Parameters used for starting the ability.| | options | StartOptions | Yes| Parameters used for starting the ability.|
...@@ -189,7 +189,7 @@ Starts an ability. This API uses a callback to return the execution result when ...@@ -189,7 +189,7 @@ Starts an ability. This API uses a callback to return the execution result when
windowMode: 0, windowMode: 0,
}; };
this.context.startAbilityForResult( this.context.startAbilityForResult(
{bundleName: "com.extreme.myapplication", abilityName: "MainAbilityDemo2"}, options, {deviceId: "", bundleName: "com.extreme.myapplication", abilityName: "MainAbilityDemo2"}, options,
(error, result) => { (error, result) => {
console.log("startAbilityForResult AsyncCallback is called, error.code = " + error.code) console.log("startAbilityForResult AsyncCallback is called, error.code = " + error.code)
console.log("startAbilityForResult AsyncCallback is called, result.resultCode = " + result.resultCode) console.log("startAbilityForResult AsyncCallback is called, result.resultCode = " + result.resultCode)
...@@ -208,7 +208,7 @@ Starts an ability. This API uses a promise to return the execution result when t ...@@ -208,7 +208,7 @@ Starts an ability. This API uses a promise to return the execution result when t
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| | want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
| options | StartOptions | No| Parameters used for starting the ability.| | options | StartOptions | No| Parameters used for starting the ability.|
...@@ -216,7 +216,7 @@ Starts an ability. This API uses a promise to return the execution result when t ...@@ -216,7 +216,7 @@ Starts an ability. This API uses a promise to return the execution result when t
**Return value** **Return value**
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;[AbilityResult](js-apis-featureAbility.md#abilityresult)&gt; | Promise used to return the result.| | Promise&lt;[AbilityResult](js-apis-featureAbility.md#abilityresult)&gt; | Promise used to return the result.|
...@@ -226,7 +226,7 @@ Starts an ability. This API uses a promise to return the execution result when t ...@@ -226,7 +226,7 @@ Starts an ability. This API uses a promise to return the execution result when t
var options = { var options = {
windowMode: 0, windowMode: 0,
}; };
this.context.startAbilityForResult({bundleName: "com.extreme.myapplication", abilityName: "MainAbilityDemo2"}, options).then((result) => { this.context.startAbilityForResult({deviceId: "", bundleName: "com.extreme.myapplication", abilityName: "MainAbilityDemo2"}, options).then((result) => {
console.log("startAbilityForResult Promise.resolve is called, result.resultCode = " + result.resultCode) console.log("startAbilityForResult Promise.resolve is called, result.resultCode = " + result.resultCode)
}, (error) => { }, (error) => {
console.log("startAbilityForResult Promise.Reject is called, error.code = " + error.code) console.log("startAbilityForResult Promise.Reject is called, error.code = " + error.code)
...@@ -244,7 +244,7 @@ Terminates this ability. This API uses a callback to return the result. ...@@ -244,7 +244,7 @@ Terminates this ability. This API uses a callback to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result indicating whether the API is successfully called.| | callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result indicating whether the API is successfully called.|
...@@ -267,7 +267,7 @@ Terminates this ability. This API uses a promise to return the result. ...@@ -267,7 +267,7 @@ Terminates this ability. This API uses a promise to return the result.
**Return value** **Return value**
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.| | Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.|
...@@ -292,7 +292,7 @@ Terminates this ability. This API uses a callback to return the information to t ...@@ -292,7 +292,7 @@ Terminates this ability. This API uses a callback to return the information to t
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| parameter | [AbilityResult](js-apis-featureAbility.md#abilityresult) | Yes| Information returned to the caller.| | parameter | [AbilityResult](js-apis-featureAbility.md#abilityresult) | Yes| Information returned to the caller.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
...@@ -321,13 +321,13 @@ Terminates this ability. This API uses a promise to return information to the ca ...@@ -321,13 +321,13 @@ Terminates this ability. This API uses a promise to return information to the ca
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| parameter | [AbilityResult](js-apis-featureAbility.md#abilityresult) | Yes| Information returned to the caller.| | parameter | [AbilityResult](js-apis-featureAbility.md#abilityresult) | Yes| Information returned to the caller.|
**Return value** **Return value**
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
...@@ -355,13 +355,13 @@ Obtains the caller interface of the specified ability, and if the specified abil ...@@ -355,13 +355,13 @@ Obtains the caller interface of the specified ability, and if the specified abil
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information about the ability to start, including the ability name, bundle name, and device ID. If the device ID is left blank or the default value is used, the local ability will be started.| | want | [Want](js-apis-application-Want.md) | Yes| Information about the ability to start, including the ability name, bundle name, and device ID. If the device ID is left blank or the default value is used, the local ability will be started.|
**Return value** **Return value**
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;Caller&gt; | Promise used to return the caller object to communicate with.| | Promise&lt;Caller&gt; | Promise used to return the caller object to communicate with.|
...@@ -378,7 +378,7 @@ Obtains the caller interface of the specified ability, and if the specified abil ...@@ -378,7 +378,7 @@ Obtains the caller interface of the specified ability, and if the specified abil
deviceId: "" deviceId: ""
}).then((obj) => { }).then((obj) => {
caller = obj; caller = obj;
console.log('Caller GetCaller Get ' + call); console.log('Caller GetCaller Get ' + caller);
}).catch((e) => { }).catch((e) => {
console.log('Caller GetCaller error ' + e); console.log('Caller GetCaller error ' + e);
}); });
...@@ -397,17 +397,19 @@ Requests permissions from the user by displaying a pop-up window. This API uses ...@@ -397,17 +397,19 @@ Requests permissions from the user by displaying a pop-up window. This API uses
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| permissions | Array&lt;string&gt; | Yes| Permissions to request.| | permissions | Array&lt;string&gt; | Yes| Permissions to request.|
| callback | AsyncCallback&lt;[PermissionRequestResult](js-apis-permissionrequestresult.md)&gt; | Yes| Callback used to return the result indicating whether the API is successfully called.| | callback | AsyncCallback&lt;[PermissionRequestResult](js-apis-permissionrequestresult.md)&gt; | Yes| Callback used to return the result indicating whether the API is successfully called.|
**Example** **Example**
``` ```js
this.context.requestPermissionsFromUser(permissions,(result) => { var permissions=['com.example.permission']
console.log('requestPermissionsFromUserresult:' + JSON.stringify(result)); this.context.requestPermissionsFromUser(permissions,(result) => {
console.log('requestPermissionsFromUserresult:' + JSON.stringify(result));
}); });
``` ```
...@@ -421,24 +423,26 @@ Requests permissions from the user by displaying a pop-up window. This API uses ...@@ -421,24 +423,26 @@ Requests permissions from the user by displaying a pop-up window. This API uses
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| permissions | Array&lt;string&gt; | Yes| Permissions to request.| | permissions | Array&lt;string&gt; | Yes| Permissions to request.|
**Return value** **Return value**
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;[PermissionRequestResult](js-apis-permissionrequestresult.md)&gt; | Promise used to return the result indicating whether the API is successfully called.| | Promise&lt;[PermissionRequestResult](js-apis-permissionrequestresult.md)&gt; | Promise used to return the result indicating whether the API is successfully called.|
**Example** **Example**
``` ```js
this.context.requestPermissionsFromUser(permissions).then((data) => { var permissions=['com.example.permission']
this.context.requestPermissionsFromUser(permissions).then((data) => {
console.log('success:' + JSON.stringify(data)); console.log('success:' + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
console.log('failed:' + JSON.stringify(error)); console.log('failed:' + JSON.stringify(error));
}); });
``` ```
...@@ -452,7 +456,7 @@ Sets the label of the ability displayed in the task. This API uses a callback to ...@@ -452,7 +456,7 @@ Sets the label of the ability displayed in the task. This API uses a callback to
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| label | string | Yes| Label of the ability to set.| | label | string | Yes| Label of the ability to set.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result indicating whether the API is successfully called.| | callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result indicating whether the API is successfully called.|
...@@ -476,13 +480,13 @@ Sets the label of the ability displayed in the task. This API uses a promise to ...@@ -476,13 +480,13 @@ Sets the label of the ability displayed in the task. This API uses a promise to
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| label | string | Yes| Label of the ability to set.| | label | string | Yes| Label of the ability to set.|
**Return value** **Return value**
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.| | Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.|
......
# Ability Access Control # Ability Access Control
> **NOTE**<br> > **NOTE**<br/>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import ## Modules to Import
...@@ -20,9 +20,9 @@ Creates an **AtManager** instance, which is used for ability access control. ...@@ -20,9 +20,9 @@ Creates an **AtManager** instance, which is used for ability access control.
**Return value** **Return value**
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| [AtManager](#atmanager) | **AtManager** instance obtained. | | [AtManager](#atmanager) | **AtManager** instance obtained.|
**Example** **Example**
...@@ -44,16 +44,16 @@ Checks whether an application has been granted the specified permission. This AP ...@@ -44,16 +44,16 @@ Checks whether an application has been granted the specified permission. This AP
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| -------- | ------------------- | ---- | ------------------------------------------ | | -------- | ------------------- | ---- | ------------------------------------------ |
| tokenID | number | Yes | ID of the application. | | tokenID | number | Yes | ID of the application. |
| permissionName | string | Yes | Name of the permission to verify. | | permissionName | string | Yes | Name of the permission to verify.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| :------------ | :---------------------------------- | | :------------ | :---------------------------------- |
| Promise&lt;GrantStatus&gt; | Promise used to return the result. | | Promise&lt;GrantStatus&gt; | Promise instance used to return the result.|
**Example** **Example**
...@@ -78,24 +78,25 @@ Grants a user granted permission to an application. This API uses a promise to r ...@@ -78,24 +78,25 @@ Grants a user granted permission to an application. This API uses a promise to r
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| --------- | ------------------- | ---- | ------------------------------------------------------------ | | --------- | ------------------- | ---- | ------------------------------------------------------------ |
| tokenID | number | Yes | ID of the application. | | tokenID | number | Yes | ID of the application. |
| permissionName | string | Yes | Name of the permission to grant. | | permissionName | string | Yes | Name of the permission to grant.|
| permissionFlag | number | Yes | Permission flag. The value **1** means that a dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed. | | permissionFlag | number | Yes | Permission flag. The value **1** means that a dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed. |
**Return value** **Return value**
| Type | Description | | Type | Description |
| :------------ | :---------------------------------- | | :------------ | :---------------------------------- |
| Promise&lt;number&gt; | Promise used to return the result. | | Promise&lt;number&gt; | Promise instance used to return the result.|
**Example** **Example**
```js ```js
var AtManager = abilityAccessCtrl.createAtManager(); var AtManager = abilityAccessCtrl.createAtManager();
let tokenID = 0; let tokenID = 0;
let promise = AtManager.grantUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS"); let permissionFlag = 1;
let promise = AtManager.grantUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS",permissionFlag);
promise.then(data => { promise.then(data => {
console.log(`promise: data->${JSON.stringify(data)}`); console.log(`promise: data->${JSON.stringify(data)}`);
}); });
...@@ -115,12 +116,12 @@ Grants a user granted permission to an application. This API uses an asynchronou ...@@ -115,12 +116,12 @@ Grants a user granted permission to an application. This API uses an asynchronou
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| --------- | ------------------- | ---- | ------------------------------------------------------------ | | --------- | ------------------- | ---- | ------------------------------------------------------------ |
| tokenID | number | Yes | ID of the application. | | tokenID | number | Yes | ID of the application. |
| permissionName | string | Yes | Name of the permission to grant. | | permissionName | string | Yes | Name of the permission to grant.|
| permissionFlag | number | Yes | Permission flag. The value **1** means that a dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed. | | permissionFlag | number | Yes | Permission flag. The value **1** means that a dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed. |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;number&gt; | Yes| Callback used to return the result.|
**Example** **Example**
...@@ -145,17 +146,17 @@ Revokes a user granted permission given to an application. This API uses a promi ...@@ -145,17 +146,17 @@ Revokes a user granted permission given to an application. This API uses a promi
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| --------- | ------------------- | ---- | ------------------------------------------------------------ | | --------- | ------------------- | ---- | ------------------------------------------------------------ |
| tokenID | number | Yes | ID of the application. | | tokenID | number | Yes | ID of the application. |
| permissionName | string | Yes | Name of the permission to revoke. | | permissionName | string | Yes | Name of the permission to revoke.|
| permissionFlag | number | Yes | Permission flag. The value **1** means that a dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed. | | permissionFlag | number | Yes | Permission flag. The value **1** means that a dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed. |
**Return value** **Return value**
| Type | Description | | Type | Description |
| :------------ | :---------------------------------- | | :------------ | :---------------------------------- |
| Promise&lt;number&gt; | Promise used to return the result. | | Promise&lt;number&gt; | Promise instance used to return the result.|
**Example** **Example**
...@@ -181,18 +182,19 @@ Revokes a user granted permission given to an application. This API uses an asyn ...@@ -181,18 +182,19 @@ Revokes a user granted permission given to an application. This API uses an asyn
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| --------- | ------------------- | ---- | ------------------------------------------------------------ | | --------- | ------------------- | ---- | ------------------------------------------------------------ |
| tokenID | number | Yes | ID of the application. | | tokenID | number | Yes | ID of the application. |
| permissionName | string | Yes | Name of the permission to revoke. | | permissionName | string | Yes | Name of the permission to revoke.|
| permissionFlag | number | Yes | Permission flag. The value **1** means that a dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed. | | permissionFlag | number | Yes | Permission flag. The value **1** means that a dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed. |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;number&gt; | Yes| Callback used to return the result.|
**Example** **Example**
```js ```js
var AtManager = abilityAccessCtrl.createAtManager(); var AtManager = abilityAccessCtrl.createAtManager();
let tokenID = 0; let tokenID = 0;
let permissionFlag = 1;
AtManager.revokeUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS",permissionFlag, data => { AtManager.revokeUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS",permissionFlag, data => {
console.log(`callback: data->${JSON.stringify(data)}`); console.log(`callback: data->${JSON.stringify(data)}`);
}); });
...@@ -210,16 +212,16 @@ Obtains the flags of the specified permission of a given application. This API u ...@@ -210,16 +212,16 @@ Obtains the flags of the specified permission of a given application. This API u
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| --------- | ------------------- | ---- | ------------------------------------------------------------ | | --------- | ------------------- | ---- | ------------------------------------------------------------ |
| tokenID | number | Yes | ID of the application. | | tokenID | number | Yes | ID of the application. |
| permissionName | string | Yes | Name of the permission to query. | | permissionName | string | Yes | Name of the permission to query.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| :------------ | :---------------------------------- | | :------------ | :---------------------------------- |
| Promise&lt;number&gt; | Promise used to return the result. | | Promise&lt;number&gt; | Promise instance used to return the result.|
**Example** **Example**
...@@ -238,7 +240,7 @@ Enumerates the permission grant states. ...@@ -238,7 +240,7 @@ Enumerates the permission grant states.
**System capability**: SystemCapability.Security.AccessToken **System capability**: SystemCapability.Security.AccessToken
| Name | Default Value | Description | | Name | Default Value | Description |
| ----------------------------- | ---------------------- | ----------------------- | | ----------------------------- | ---------------------- | ----------------------- |
| PERMISSION_DENIED | -1 | Permission denied. | | PERMISSION_DENIED | -1 | Permission denied. |
| PERMISSION_GRANTED | 0 | Permission granted. | | PERMISSION_GRANTED | 0 | Permission granted. |
...@@ -6,7 +6,11 @@ ...@@ -6,7 +6,11 @@
Provides ability running information. Provides ability running information.
## Modules to Import
```js
import abilitymanager from '@ohos.application.abilityManager';
```
## Usage ## Usage
...@@ -25,14 +29,14 @@ abilitymanager.getAbilityRunningInfos((err,data) => { ...@@ -25,14 +29,14 @@ abilitymanager.getAbilityRunningInfos((err,data) => {
**System capability**: SystemCapability.Ability.AbilityRuntime.Core **System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Type | Readable | Writable | Description | | Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| ability | ElementName | Yes | No | Information that matches an ability. | | ability | ElementName | Yes| No| Information that matches an ability. |
| pid | number | Yes | No | Process ID. | | pid | number | Yes| No| Process ID.|
| uid | number | Yes | No | User ID. | | uid | number | Yes| No| User ID. |
| processName | string | Yes | No | Process name. | | processName | string | Yes| No| Process name. |
| startTime | number | Yes | No | Ability start time. | | startTime | number | Yes| No| Ability start time. |
| abilityState | [abilityManager.AbilityState](#abilitymanagerabilitystate) | Yes | No | Ability state. | | abilityState | [abilityManager.AbilityState](#abilitymanagerabilitystate) | Yes| No| Ability state. |
## abilityManager.AbilityState ## abilityManager.AbilityState
...@@ -41,10 +45,10 @@ Enumerates the ability states. ...@@ -41,10 +45,10 @@ Enumerates the ability states.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core **System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Value | Description | | Name| Value| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| INITIAL | 0 | The ability is in the initial state. | | INITIAL | 0 | The ability is in the initial state.|
| FOREGROUND | 9 | The ability is in the foreground state. | | FOREGROUND | 9 | The ability is in the foreground state. |
| BACKGROUND | 10 | The ability is in the background state. | | BACKGROUND | 10 | The ability is in the background state. |
| FOREGROUNDING | 11 | The ability is in the foregrounding state. | | FOREGROUNDING | 11 | The ability is in the foregrounding state. |
| BACKGROUNDING | 12 | The ability is in the backgrounding state. | | BACKGROUNDING | 12 | The ability is in the backgrounding state. |
...@@ -6,6 +6,11 @@ ...@@ -6,6 +6,11 @@
Implements the context of an ability stage. This module is inherited from [Context](js-apis-application-context.md). Implements the context of an ability stage. This module is inherited from [Context](js-apis-application-context.md).
## Modules to Import
```js
import AbilityStage from '@ohos.application.AbilityStage';
```
## Usage ## Usage
...@@ -28,7 +33,7 @@ class MyAbilityStage extends AbilityStage { ...@@ -28,7 +33,7 @@ class MyAbilityStage extends AbilityStage {
**System capability**: SystemCapability.Ability.AbilityRuntime.Core **System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name| Type | Readable | Writable | Description | | Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| currentHapModuleInfo | HapModuleInfo | Yes | No | **ModuleInfo** object corresponding to the **AbilityStage**. | | currentHapModuleInfo | HapModuleInfo | Yes| No| **ModuleInfo** object corresponding to the **AbilityStage**.|
| config | [Configuration](js-apis-configuration.md) | Yes| No| Configuration for the environment where the application is running. | | config | [Configuration](js-apis-configuration.md) | Yes| No| Configuration for the environment where the application is running.|
# MissionSnapshot # MissionSnapshot
> **NOTE**<br> > **NOTE**
>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Provides the snapshot of a mission. Provides the snapshot of a mission.
## Modules to Import ## Modules to Import
``` ```
import { ElementName } from '../bundle/elementName'; import abilitymanager from '@ohos.application.abilityManager';
import { image } from '../@ohos.multimedia.image'; import ElementName from '@ohos.bundle';
import image from '@ohos.multimedia.image';
``` ```
## MissionSnapshot ## MissionSnapshot
Describes the mission snapshot. Describes the mission snapshot.
| Name | Type | Readable | Writable | Description | | Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| ability | ElementName | Yes | Yes | Information that matches an ability. | | ability | ElementName | Yes| Yes| Information that matches an ability.|
| snapshot | [image.PixelMap](js-apis-image.md) | Yes| Yes| Snapshot of the mission. | | snapshot | [image.PixelMap](js-apis-image.md) | Yes| Yes| Snapshot of the mission.|
...@@ -185,7 +185,7 @@ Waits for the ability that matches the **AbilityMonitor** instance to reach the ...@@ -185,7 +185,7 @@ Waits for the ability that matches the **AbilityMonitor** instance to reach the
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| monitor | [AbilityMonitor](js-apis-application-abilityMonitor.md#AbilityMonitor) | Yes | [AbilityMonitor](js-apis-application-abilityMonitor.md#AbilityMonitor) instance.| | monitor | [AbilityMonitor](js-apis-application-abilityMonitor.md#AbilityMonitor) | Yes | [AbilityMonitor](js-apis-application-abilityMonitor.md#AbilityMonitor) instance.|
| callback | AsyncCallback\<[Ability](js-apis-application-ability.md#Ability)> | Yes | Callback used to return the ability. | | callback | AsyncCallback\<[Ability](js-apis-application-ability.md#Ability)> | Yes | Callback used to return the result. |
**Example** **Example**
...@@ -223,7 +223,7 @@ Waits a period of time for the ability that matches the **AbilityMonitor** insta ...@@ -223,7 +223,7 @@ Waits a period of time for the ability that matches the **AbilityMonitor** insta
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| monitor | [AbilityMonitor](js-apis-application-abilityMonitor.md#AbilityMonitor) | Yes | [AbilityMonitor](js-apis-application-abilityMonitor.md#AbilityMonitor) instance.| | monitor | [AbilityMonitor](js-apis-application-abilityMonitor.md#AbilityMonitor) | Yes | [AbilityMonitor](js-apis-application-abilityMonitor.md#AbilityMonitor) instance.|
| timeout | number | Yes | Maximum waiting time, in milliseconds. | | timeout | number | Yes | Maximum waiting time, in milliseconds. |
| callback | AsyncCallback\<[Ability](js-apis-application-ability.md#Ability)> | Yes | Callback used to return the ability. | | callback | AsyncCallback\<[Ability](js-apis-application-ability.md#Ability)> | Yes | Callback used to return the result. |
**Example** **Example**
...@@ -365,7 +365,7 @@ Obtains the top ability of the application. This API uses an asynchronous callba ...@@ -365,7 +365,7 @@ Obtains the top ability of the application. This API uses an asynchronous callba
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------ | | -------- | ------------------------------------------------------------ | ---- | ------------------ |
| callback | AsyncCallback\<[Ability](js-apis-application-ability.md#Ability)> | Yes | Callback used to return the top ability.| | callback | AsyncCallback\<[Ability](js-apis-application-ability.md#Ability)> | Yes | Callback used to return the result.|
**Example** **Example**
...@@ -747,7 +747,7 @@ abilityDelegator.executeShellCommand(cmd, timeout, (err : any, data : any) => { ...@@ -747,7 +747,7 @@ abilityDelegator.executeShellCommand(cmd, timeout, (err : any, data : any) => {
### executeShellCommand ### executeShellCommand
executeShellCommand(cmd: string, timeoutSecs: number): Promise\<ShellCmdResult> executeShellCommand(cmd: string, timeoutSecs?: number): Promise\<ShellCmdResult>
Executes a shell command with the timeout period specified. This API uses a promise to return the result. Executes a shell command with the timeout period specified. This API uses a promise to return the result.
......
# AbilityDelegatorArgs # AbilityDelegatorArgs
> **NOTE** > **NOTE**<br/>
> >
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
......
# Context # Context
> **NOTE**<br> > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> 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 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.
Provides the context for running code, including **applicationInfo** and **resourceManager**. Provides the context for running code, including **applicationInfo** and **resourceManager**.
## Modules to Import
```
import AbilityContext from '@ohos.application.Ability';
```
## Usage ## Usage
You must extend **AbilityContext** to implement this module. You must extend **AbilityContext** to implement this module.
## Attributes ## Attributes
**System capability**: SystemCapability.Ability.AbilityRuntime.Core **System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Type | Readable | Writable | Description | | Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| resourceManager | ResourceManager | Yes | No | **ResourceManager** object. | | resourceManager | ResourceManager | Yes| No| **ResourceManager** object.|
| applicationInfo | ApplicationInfo | Yes | No | Information about the application. | | applicationInfo | ApplicationInfo | Yes| No| Information about the application.|
| cacheDir | string | Yes | No | Cache directory of the application on the internal storage. | | cacheDir | string | Yes| No| Cache directory of the application on the internal storage.|
| tempDir | string | Yes | No | Temporary file directory of the application. | | tempDir | string | Yes| No| Temporary file directory of the application.|
| filesDir | string | Yes | No | File directory of the application on the internal storage. | | filesDir | string | Yes| No| File directory of the application on the internal storage.|
| databaseDir | string | Yes | No | Storage directory of local data. | | databaseDir | string | Yes| No| Storage directory of local data.|
| storageDir | string | Yes | No | Storage directory of lightweight data. | | storageDir | string | Yes| No| Storage directory of lightweight data.|
| bundleCodeDir | string | Yes | No | Application installation path. | | bundleCodeDir | string | Yes| No| Application installation path.|
| distributedFilesDir | string | Yes | No | Storage directory of distributed application data files. | | distributedFilesDir | string | Yes| No| Storage directory of distributed application data files.|
| eventHub | [EventHub](js-apis-eventhub.md) | Yes | No | Event hub information. | | eventHub | [EventHub](js-apis-eventhub.md) | Yes| No| Event hub information.|
| area | [AreaMode](#areamode) | Yes| Yes| Area in which the file to be access is located.|
## Context.createBundleContext ## Context.createBundleContext
...@@ -41,27 +44,33 @@ Creates an application context. ...@@ -41,27 +44,33 @@ Creates an application context.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| bundleName | string | Yes | Application bundle name. | | bundleName | string | Yes| Application bundle name.|
**Return value** **Return value**
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| Context | Context of the application created. | | Context | Context of the application created.|
**Example** **Example**
```js ```js
let test = "com.example.test"; import AbilityContext from '@ohos.application.Ability'
let context = this.context.createBundleContext(test); class MainAbility extends AbilityContext {
onWindowStageCreate(windowStage) {
let test = "com.example.test";
let context = this.context.createBundleContext(test);
}
}
``` ```
## Context.getApplicationContext ## Context.getApplicationContext
getApplicationContext(): Context; getApplicationContext(): ApplicationContext;
Obtains the context of this application. Obtains the context of this application.
...@@ -69,13 +78,25 @@ Obtains the context of this application. ...@@ -69,13 +78,25 @@ Obtains the context of this application.
**Return value** **Return value**
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| Context | Context obtained. | | ApplicationContext | Current application context.|
**Example** **Example**
```js ```js
// This part is mandatory. // This part is mandatory.
let context = this.context.getApplicationContext(); let applicationContext = this.context.getApplicationContext();
``` ```
## AreaMode
Defines the area where the file to be access is located. Each area has its own content.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Value | Description |
| --------------- | ---- | --------------- |
| EL1 | 0 | Device-level encryption area. |
| EL2 | 1 | User credential encryption area. The default value is **EL2**.|
# ShellCmdResult # ShellCmdResult
> **NOTE** > **NOTE**<br>
> >
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
......
# appManager # appManager
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > **NOTE**<br>
> 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. > 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.
...@@ -34,7 +34,7 @@ Checks whether this application is undergoing a stability test. This API uses an ...@@ -34,7 +34,7 @@ Checks whether this application is undergoing a stability test. This API uses an
```js ```js
import app from '@ohos.application.appManager'; import app from '@ohos.application.appManager';
app.isRunningInStabilityTest((err, flag) => { app.isRunningInStabilityTest((err, flag) => {
console.log('startAbility result:' + JSON.stringfy(err)); console.log('startAbility result:' + JSON.stringify(err));
}) })
``` ```
...@@ -58,9 +58,9 @@ Checks whether this application is undergoing a stability test. This API uses a ...@@ -58,9 +58,9 @@ Checks whether this application is undergoing a stability test. This API uses a
```js ```js
import app from '@ohos.application.appManager'; import app from '@ohos.application.appManager';
app.isRunningInStabilityTest().then((flag) => { app.isRunningInStabilityTest().then((flag) => {
console.log('success:' + JSON.stringfy(flag)); console.log('success:' + JSON.stringify(flag));
}).catch((error) => { }).catch((error) => {
console.log('failed:' + JSON.stringfy(error)); console.log('failed:' + JSON.stringify(error));
}); });
``` ```
...@@ -82,7 +82,7 @@ Checks whether this application is running on a RAM constrained device. This API ...@@ -82,7 +82,7 @@ Checks whether this application is running on a RAM constrained device. This API
**Example** **Example**
```js ```js
app.isRamConstrainedDevicePromise().then((data) => { app.isRamConstrainedDevice().then((data) => {
console.log('success:' + JSON.stringify(data)); console.log('success:' + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
console.log('failed:' + JSON.stringify(error)); console.log('failed:' + JSON.stringify(error));
...@@ -106,7 +106,7 @@ Checks whether this application is running on a RAM constrained device. This API ...@@ -106,7 +106,7 @@ Checks whether this application is running on a RAM constrained device. This API
**Example** **Example**
```js ```js
app.isRamConstrainedDevicePromise((err, data) => { app.isRamConstrainedDevice((err, data) => {
console.log('startAbility result failed:' + JSON.stringify(err)); console.log('startAbility result failed:' + JSON.stringify(err));
console.log('startAbility result success:' + JSON.stringify(data)); console.log('startAbility result success:' + JSON.stringify(data));
}) })
...@@ -160,7 +160,7 @@ Obtains the memory size of this application. This API uses an asynchronous callb ...@@ -160,7 +160,7 @@ Obtains the memory size of this application. This API uses an asynchronous callb
``` ```
## appManager.getProcessRunningInfos<sup>8+</sup> ## appManager.getProcessRunningInfos<sup>8+</sup>
getProcessRunningInfos(): Promise<Array<ProcessRunningInfo>>; getProcessRunningInfos(): Promise<Array\<ProcessRunningInfo>>;
Obtains information about the running processes. This API uses a promise to return the result. Obtains information about the running processes. This API uses a promise to return the result.
...@@ -175,7 +175,7 @@ Obtains information about the running processes. This API uses a promise to retu ...@@ -175,7 +175,7 @@ Obtains information about the running processes. This API uses a promise to retu
**Example** **Example**
```js ```js
app.GetProcessRunningInfos().then((data) => { app.getProcessRunningInfos().then((data) => {
console.log('success:' + JSON.stringify(data)); console.log('success:' + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
console.log('failed:' + JSON.stringify(error)); console.log('failed:' + JSON.stringify(error));
...@@ -184,7 +184,7 @@ Obtains information about the running processes. This API uses a promise to retu ...@@ -184,7 +184,7 @@ Obtains information about the running processes. This API uses a promise to retu
## appManager.getProcessRunningInfos<sup>8+</sup> ## appManager.getProcessRunningInfos<sup>8+</sup>
getProcessRunningInfos(callback: AsyncCallback<Array<ProcessRunningInfo>>): void; getProcessRunningInfos(callback: AsyncCallback<Array\<ProcessRunningInfo>>): void;
Obtains information about the running processes. This API uses an asynchronous callback to return the result. Obtains information about the running processes. This API uses an asynchronous callback to return the result.
...@@ -199,7 +199,7 @@ Obtains information about the running processes. This API uses an asynchronous c ...@@ -199,7 +199,7 @@ Obtains information about the running processes. This API uses an asynchronous c
**Example** **Example**
```js ```js
app.GetProcessRunningInfos((err, data) => { app.getProcessRunningInfos((err, data) => {
console.log('startAbility result failed :' + JSON.stringify(err)); console.log('startAbility result failed :' + JSON.stringify(err));
console.log('startAbility result success:' + JSON.stringify(data)); console.log('startAbility result success:' + JSON.stringify(data));
}) })
......
# EventHub # EventHub
> **NOTE**<br> > **NOTE**<br/>
> The initial APIs of this module are supported since API 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Implements event subscription, unsubscription, and triggering. Implements event subscription, unsubscription, and triggering.
## Modules to Import
```js
import Ability from '@ohos.application.Ability'
```
## Usage ## Usage
Before using any APIs in the **EventHub**, you must obtain an **EventHub** instance through the member variable **context** of the **Ability** instance. Before using any APIs in the **EventHub**, you must obtain an **EventHub** instance through the member variable **context** of the **Ability** instance.
```js ```js
import Ability from '@ohos.application.Ability' import Ability from '@ohos.application.Ability'
export default class MainAbility extends Ability { export default class MainAbility extends Ability {
func1(){
console.log("func1 is called");
}
onForeground() { onForeground() {
this.context.eventHub.on("123", this.func1); this.context.eventHub.on("123", this.func1);
} }
...@@ -34,10 +42,10 @@ Subscribes to an event. ...@@ -34,10 +42,10 @@ Subscribes to an event.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| event | string | Yes | Event name. | | event | string | Yes| Event name.|
| callback | Function | Yes | Callback invoked when the event is triggered. | | callback | Function | Yes| Callback invoked when the event is triggered.|
**Example** **Example**
...@@ -72,10 +80,10 @@ Unsubscribes from an event. If **callback** is specified, this API unsubscribes ...@@ -72,10 +80,10 @@ Unsubscribes from an event. If **callback** is specified, this API unsubscribes
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| event | string | Yes | Event name. | | event | string | Yes| Event name.|
| callback | Function | No | Callback for the event. If **callback** is unspecified, all callbacks of the event are unsubscribed. | | callback | Function | No| Callback for the event. If **callback** is unspecified, all callbacks of the event are unsubscribed.|
**Example** **Example**
...@@ -110,10 +118,10 @@ Triggers an event. ...@@ -110,10 +118,10 @@ Triggers an event.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| event | string | Yes | Event name. | | event | string | Yes| Event name.|
| ...args | Object[] | Yes | Variable parameters, which are passed to the callback when the event is triggered. | | ...args | Object[] | Yes| Variable parameters, which are passed to the callback when the event is triggered.|
**Example** **Example**
......
# ExtensionContext # ExtensionContext
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/> > **NOTE**<br/>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > 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.
```js
import DataShareExtensionAbility from '@ohos.application.DataShareExtensionAbility';
```
Implements the extension context. This module is inherited from **Context**. Implements the extension context. This module is inherited from **Context**.
...@@ -11,7 +15,7 @@ Implements the extension context. This module is inherited from **Context**. ...@@ -11,7 +15,7 @@ Implements the extension context. This module is inherited from **Context**.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core **System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Type | Readable | Writable | Description | | Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| currentHapModuleInfo | HapModuleInfo | Yes| No | Information about the current HAP. | | currentHapModuleInfo | HapModuleInfo | Yes| No| Information about the current HAP. |
| config | Configuration | Yes| No | Module configuration information. | | config | Configuration | Yes| No| Module configuration information.|
# ExtensionRunningInfo # ExtensionRunningInfo
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/> > **NOTE**<br/>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > 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.
Provides extension running information. Provides extension running information.
## Modules to Import
```js
import abilitymanager from '@ohos.application.abilityManager';
```
## Usage ## Usage
...@@ -14,8 +19,9 @@ The extension running information is obtained through an **abilityManager** inst ...@@ -14,8 +19,9 @@ The extension running information is obtained through an **abilityManager** inst
``` ```js
import abilitymanager from '@ohos.application.abilityManager'; import abilitymanager from '@ohos.application.abilityManager';
let upperLimit=1
abilitymanager.getExtensionRunningInfos(upperLimit, (err,data) => { abilitymanager.getExtensionRunningInfos(upperLimit, (err,data) => {
console.log("getExtensionRunningInfos err: " + err + " data: " + JSON.stringify(data)); console.log("getExtensionRunningInfos err: " + err + " data: " + JSON.stringify(data));
}); });
......
# FormExtensionContext # FormExtensionContext
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/> > **NOTE**<br/>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > 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.
Implements the context that provides the capabilities and APIs of **FormExtension**. This class is inherited from **ExtensionContext**. Implements the context that provides the capabilities and APIs of **FormExtension**. This class is inherited from **ExtensionContext**.
## Modules to Import
```js
import FormExtension from '@ohos.application.FormExtension';
```
## FormExtensionContext.updateForm ## FormExtensionContext.updateForm
updateForm(formId: string, formBindingData: formBindingData.FormBindingData, callback: AsyncCallback\<void>): void updateForm(formId: string, formBindingData: formBindingData.FormBindingData, callback: AsyncCallback\<void>): void
...@@ -24,10 +30,18 @@ Updates a widget. This method uses a callback to return the result. ...@@ -24,10 +30,18 @@ Updates a widget. This method uses a callback to return the result.
**Example** **Example**
```js ```js
let obj2 = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); import formBindingData from '@ohos.application.formBindingData'
this.context.updateForm(formId, obj2, (data)=>{ export default class MyFormExtension extends FormExtension {
console.log('FormExtension context updateForm, data:' + data); onUpdate(formId) {
}); console.log('FormExtension onUpdate, formId:' + formId);
let obj2 = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"});
this.context.updateForm(formId, obj2, (data)=>{
console.log('FormExtension context updateForm, data:' + data);
});
}
}
``` ```
## FormExtensionContext.updateForm ## FormExtensionContext.updateForm
...@@ -53,11 +67,18 @@ Updates a widget. This method uses a promise to return the result. ...@@ -53,11 +67,18 @@ Updates a widget. This method uses a promise to return the result.
**Example** **Example**
``` ```js
let obj2 = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); import formBindingData from '@ohos.application.formBindingData'
this.context.updateForm(formId, obj2) export default class MyFormExtension extends FormExtension {
.then((data)=>{ onUpdate(formId) {
console.log('FormExtension context updateForm, data:' + data); console.log('FormExtension onUpdate, formId:' + formId);
}).catch((error) => { let obj2 = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"});
console.error('Operation updateForm failed. Cause: ' + error);}); this.context.updateForm(formId, obj2)
.then((data)=>{
console.log('FormExtension context updateForm, data:' + data);
}).catch((error) => {
console.error('Operation updateForm failed. Cause: ' + error);});
}
}
``` ```
# missionManager # missionManager
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br> > **NOTE**<br/>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
missionManager provides APIs to lock, unlock, and clear missions, and switch a mission to the foreground. missionManager provides APIs to lock, unlock, and clear missions, and switch a mission to the foreground.
## Modules to Import ## Modules to Import
``` ```
import missionManager from '@ohos.application.missionManager' import missionManager from '@ohos.application.missionManager'
``` ```
## Required Permissions
ohos.permission.MANAGE_MISSIONS
## missionManager.registerMissionListener ## missionManager.registerMissionListener
...@@ -40,10 +40,11 @@ Registers a listener to observe the mission status. ...@@ -40,10 +40,11 @@ Registers a listener to observe the mission status.
```js ```js
var listener = { var listener = {
onMissionCreated: this.onMissionCreatedCallback, onMissionCreated: function(mission){"--------onMissionCreated-------"},
onMissionDestroyed: this.onMissionDestroyedCallback, onMissionDestroyed: function(mission){"--------onMissionDestroyed-------"},
onMissionSnapshotChanged: this.onMissionSnapshotChangedCallback, onMissionSnapshotChanged: function(mission){"--------onMissionSnapshotChanged-------"},
onMissionMovedToFront: this.onMissionMovedToFrontCallback onMissionMovedToFront: function(mission){"--------onMissionMovedToFront-------"},
onMissionIconUpdated: function(mission,icon){"--------onMissionIconUpdated-------"}
}; };
console.log("registerMissionListener") console.log("registerMissionListener")
var listenerid = missionManager.registerMissionListener(listener); var listenerid = missionManager.registerMissionListener(listener);
...@@ -70,10 +71,11 @@ Deregisters a mission status listener. This API uses an asynchronous callback to ...@@ -70,10 +71,11 @@ Deregisters a mission status listener. This API uses an asynchronous callback to
```js ```js
var listener = { var listener = {
onMissionCreated: this.onMissionCreatedCallback, onMissionCreated: function(mission){"--------onMissionCreated-------"},
onMissionDestroyed: this.onMissionDestroyedCallback, onMissionDestroyed: function(mission){"--------onMissionDestroyed-------"},
onMissionSnapshotChanged: this.onMissionSnapshotChangedCallback, onMissionSnapshotChanged: function(mission){"--------onMissionSnapshotChanged-------"},
onMissionMovedToFront: this.onMissionMovedToFrontCallback onMissionMovedToFront: function(mission){"--------onMissionMovedToFront-------"},
onMissionIconUpdated: function(mission,icon){"--------onMissionIconUpdated-------"}
}; };
console.log("registerMissionListener") console.log("registerMissionListener")
var listenerid = missionManager.registerMissionListener(listener); var listenerid = missionManager.registerMissionListener(listener);
...@@ -108,17 +110,18 @@ Deregisters a mission status listener. This API uses a promise to return the res ...@@ -108,17 +110,18 @@ Deregisters a mission status listener. This API uses a promise to return the res
```js ```js
var listener = { var listener = {
onMissionCreated: this.onMissionCreatedCallback, onMissionCreated: function(mission){"--------onMissionCreated-------"},
onMissionDestroyed: this.onMissionDestroyedCallback, onMissionDestroyed: function(mission){"--------onMissionDestroyed-------"},
onMissionSnapshotChanged: this.onMissionSnapshotChangedCallback, onMissionSnapshotChanged: function(mission){"--------onMissionSnapshotChanged-------"},
onMissionMovedToFront: this.onMissionMovedToFrontCallback onMissionMovedToFront: function(mission){"--------onMissionMovedToFront-------"},
}; onMissionIconUpdated: function(mission,icon){"--------onMissionIconUpdated-------"}
console.log("registerMissionListener") };
var listenerid = missionManager.registerMissionListener(listener); console.log("registerMissionListener")
var listenerid = missionManager.registerMissionListener(listener);
missionManager.unregisterMissionListener(listenerid).catch(function (err){
console.log(err); missionManager.unregisterMissionListener(listenerid).catch(function (err){
}); console.log(err);
});
``` ```
...@@ -143,15 +146,16 @@ Obtains the information about a given mission. This API uses an asynchronous cal ...@@ -143,15 +146,16 @@ Obtains the information about a given mission. This API uses an asynchronous cal
```js ```js
import missionManager from '@ohos.application.missionManager' import missionManager from '@ohos.application.missionManager'
missionManager.getMissionInfo("", allMissions[0].missionId, (error, mission) => { var allMissions=missionManager.getMissionInfos("",10).catch(function(err){console.log(err);});
console.log("getMissionInfo is called, error.code = " + error.code) missionManager.getMissionInfo("", allMissions[0].missionId, (error, mission) => {
console.log("mission.missionId = " + mission.missionId); console.log("getMissionInfo is called, error.code = " + error.code)
console.log("mission.runningState = " + mission.runningState); console.log("mission.missionId = " + mission.missionId);
console.log("mission.lockedState = " + mission.lockedState); console.log("mission.runningState = " + mission.runningState);
console.log("mission.timestamp = " + mission.timestamp); console.log("mission.lockedState = " + mission.lockedState);
console.log("mission.label = " + mission.label); console.log("mission.timestamp = " + mission.timestamp);
console.log("mission.iconPath = " + mission.iconPath); console.log("mission.label = " + mission.label);
}); console.log("mission.iconPath = " + mission.iconPath);
});
``` ```
...@@ -181,7 +185,7 @@ Obtains the information about a given mission. This API uses a promise to return ...@@ -181,7 +185,7 @@ Obtains the information about a given mission. This API uses a promise to return
```js ```js
import missionManager from '@ohos.application.missionManager' import missionManager from '@ohos.application.missionManager'
var mission = missionManager.getMissionInfo("", id).catch(function (err){ var mission = missionManager.getMissionInfo("", 10).catch(function (err){
console.log(err); console.log(err);
}); });
``` ```
...@@ -309,15 +313,17 @@ Obtains the snapshot of a given mission. This API uses a promise to return the r ...@@ -309,15 +313,17 @@ Obtains the snapshot of a given mission. This API uses a promise to return the r
```js ```js
import missionManager from '@ohos.application.missionManager' import missionManager from '@ohos.application.missionManager'
var allMissions = missionManager.getMissionInfos("", 10).catch(function (err){ var allMissions;
console.log(err); missionManager.getMissionInfos("",10).then(function(res){
}); allMissions=res;
console.log("size = " + allMissions.length); }).catch(function(err){console.log(err);});
console.log("missions = " + JSON.stringify(allMissions)); console.log("size = " + allMissions.length);
var id = allMissions[0].missionId; console.log("missions = " + JSON.stringify(allMissions));
var snapshot = missionManager.getMissionSnapShot("", id).catch(function (err){ var id = allMissions[0].missionId;
console.log(err);
}); var snapshot = missionManager.getMissionSnapShot("", id).catch(function (err){
console.log(err);
});
``` ```
...@@ -378,10 +384,10 @@ Locks a given mission. This API uses a promise to return the result. ...@@ -378,10 +384,10 @@ Locks a given mission. This API uses a promise to return the result.
```js ```js
import missionManager from '@ohos.application.missionManager' import missionManager from '@ohos.application.missionManager'
var allMissions;
var allMissions = missionManager.getMissionInfos("", 10).catch(function (err){ missionManager.getMissionInfos("",10).then(function(res){
console.log(err); allMissions=res;
}); }).catch(function(err){console.log(err);});
console.log("size = " + allMissions.length); console.log("size = " + allMissions.length);
console.log("missions = " + JSON.stringify(allMissions)); console.log("missions = " + JSON.stringify(allMissions));
var id = allMissions[0].missionId; var id = allMissions[0].missionId;
...@@ -450,9 +456,10 @@ Unlocks a given mission. This API uses a promise to return the result. ...@@ -450,9 +456,10 @@ Unlocks a given mission. This API uses a promise to return the result.
```js ```js
import missionManager from '@ohos.application.missionManager' import missionManager from '@ohos.application.missionManager'
var allMissions = missionManager.getMissionInfos("", 10).catch(function (err){ var allMissions;
console.log(err); missionManager.getMissionInfos("",10).then(function(res){
}); allMissions=res;
}).catch(function(err){console.log(err);});
console.log("size = " + allMissions.length); console.log("size = " + allMissions.length);
console.log("missions = " + JSON.stringify(allMissions)); console.log("missions = " + JSON.stringify(allMissions));
var id = allMissions[0].missionId; var id = allMissions[0].missionId;
...@@ -524,9 +531,10 @@ Clears a given mission, regardless of whether it is locked. This API uses a prom ...@@ -524,9 +531,10 @@ Clears a given mission, regardless of whether it is locked. This API uses a prom
```js ```js
import missionManager from '@ohos.application.missionManager' import missionManager from '@ohos.application.missionManager'
var allMissions = missionManager.getMissionInfos("", 10).catch(function (err){ var allMissions;
console.log(err); missionManager.getMissionInfos("",10).then(function(res){
}); allMissions=res;
}).catch(function(err){console.log(err);});
console.log("size = " + allMissions.length); console.log("size = " + allMissions.length);
console.log("missions = " + JSON.stringify(allMissions)); console.log("missions = " + JSON.stringify(allMissions));
var id = allMissions[0].missionId; var id = allMissions[0].missionId;
...@@ -673,9 +681,10 @@ Switches a given mission to the foreground, with the startup parameters for the ...@@ -673,9 +681,10 @@ Switches a given mission to the foreground, with the startup parameters for the
```js ```js
import missionManager from '@ohos.application.missionManager' import missionManager from '@ohos.application.missionManager'
var allMissions = missionManager.getMissionInfos("", 10).catch(function (err){ var allMissions;
console.log(err); missionManager.getMissionInfos("",10).then(function(res){
}); allMissions=res;
}).catch(function(err){console.log(err);});
console.log("size = " + allMissions.length); console.log("size = " + allMissions.length);
console.log("missions = " + JSON.stringify(allMissions)); console.log("missions = " + JSON.stringify(allMissions));
var id = allMissions[0].missionId; var id = allMissions[0].missionId;
......
# ParticleAbility Module # ParticleAbility Module
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/> > **NOTE**<br/>
> 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. > 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.
## Constraints ## Constraints
...@@ -226,7 +226,7 @@ let wantAgentInfo = { ...@@ -226,7 +226,7 @@ let wantAgentInfo = {
], ],
operationType: wantAgent.OperationType.START_ABILITY, operationType: wantAgent.OperationType.START_ABILITY,
requestCode: 0, requestCode: 0,
wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESET_FLAG] wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
}; };
wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
...@@ -235,11 +235,11 @@ wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { ...@@ -235,11 +235,11 @@ wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
text: "text" text: "text"
}; };
let notificationContent = { let notificationContent = {
contentType: notification.ContentType.NOTIFICATION_CONTENT_TEXT, contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: basicContent normal: basicContent
}; };
let request = { let request = {
content: notificatonContent, content: notificationContent,
wantAgent: wantAgentObj wantAgent: wantAgentObj
}; };
let id = 1; let id = 1;
...@@ -260,16 +260,16 @@ Requests a continuous task from the system. This API uses a promise to return th ...@@ -260,16 +260,16 @@ Requests a continuous task from the system. This API uses a promise to return th
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| id | number | Yes | Notification ID of a continuous task. | | 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 | Yes| Notification parameter, which is used to display information in the notification bar.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| -------------- | ------------------------- | | -------------- | ------------------------- |
| Promise\<void> | Promise used to return the result. | | Promise\<void> | Promise used to return the result.|
**Example** **Example**
...@@ -287,7 +287,7 @@ let wantAgentInfo = { ...@@ -287,7 +287,7 @@ let wantAgentInfo = {
], ],
operationType: wantAgent.OperationType.START_ABILITY, operationType: wantAgent.OperationType.START_ABILITY,
requestCode: 0, requestCode: 0,
wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESET_FLAG] wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
}; };
wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
...@@ -296,11 +296,11 @@ wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { ...@@ -296,11 +296,11 @@ wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
text: "text" text: "text"
}; };
let notificationContent = { let notificationContent = {
contentType: notification.ContentType.NOTIFICATION_CONTENT_TEXT, contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: basicContent normal: basicContent
}; };
let request = { let request = {
content: notificatonContent, content: notificationContent,
wantAgent: wantAgentObj wantAgent: wantAgentObj
}; };
let id = 1; let id = 1;
...@@ -323,9 +323,9 @@ Requests to cancel a continuous task from the system. This API uses an asynchron ...@@ -323,9 +323,9 @@ Requests to cancel a continuous task from the system. This API uses an asynchron
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example** **Example**
...@@ -354,9 +354,9 @@ Requests a continuous task from the system. This API uses a promise to return th ...@@ -354,9 +354,9 @@ Requests a continuous task from the system. This API uses a promise to return th
**Return value** **Return value**
| Type | Description | | Type | Description |
| -------------- | ------------------------- | | -------------- | ------------------------- |
| Promise\<void> | Promise used to return the result. | | Promise\<void> | Promise used to return the result.|
**Example** **Example**
...@@ -382,25 +382,26 @@ Connects this ability to a specific Service ability. This API uses a callback to ...@@ -382,25 +382,26 @@ Connects this ability to a specific Service ability. This API uses a callback to
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| ------- | -------------- | ---- | ---------------------------- | | ------- | -------------- | ---- | ---------------------------- |
| request | [Want](js-apis-application-Want.md) | Yes | Service ability to connect. | | request | [Want](js-apis-application-Want.md) | Yes | Service ability to connect.|
| options | ConnectOptions | Yes | Callback used to return the result. | | options | ConnectOptions | Yes | Callback used to return the result. |
**ConnectOptions** ConnectOptions
**System capability**: SystemCapability.Ability.AbilityRuntime.Core **System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Readable/Writable | Type | Mandatory | Description | | Name | Readable/Writable| Type | Mandatory | Description |
| ------------ | ---- | -------- | ---- | ------------------------- | | ------------ | ---- | -------- | ---- | ------------------------- |
| onConnect | Read only | function | Yes | Callback invoked when the connection is successful. | | onConnect | Read only | function | Yes | Callback invoked when the connection is successful. |
| onDisconnect | Read only | function | Yes | Callback invoked when the connection fails. | | onDisconnect | Read only | function | Yes | Callback invoked when the connection fails. |
| onFailed | Read only | function | Yes | Callback invoked when **connectAbility** fails to be called. | | onFailed | Read only | function | Yes | Callback invoked when **connectAbility** fails to be called.|
**Example** **Example**
```js ```js
import rpc from '@ohos.rpc'
function onConnectCallback(element, remote){ function onConnectCallback(element, remote){
console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy)); console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy));
} }
...@@ -422,8 +423,10 @@ Connects this ability to a specific Service ability. This API uses a callback to ...@@ -422,8 +423,10 @@ Connects this ability to a specific Service ability. This API uses a callback to
}, },
); );
particleAbility.disconnectAbility(connId).then((error,data)=>{ particleAbility.disconnectAbility(connId).then((data)=>{
console.log('particleAbilityTest result errCode : ' + error.code + " data: " + data); console.log( " data: " + data);
}).catch((error)=>{
console.log('particleAbilityTest result errCode : ' + error.code )
}); });
...@@ -440,13 +443,14 @@ Disconnects this ability from the Service ability. This API uses a callback to r ...@@ -440,13 +443,14 @@ Disconnects this ability from the Service ability. This API uses a callback to r
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example** **Example**
```js ```js
import rpc from '@ohos.rpc'
function onConnectCallback(element, remote){ function onConnectCallback(element, remote){
console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy)); console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy));
} }
...@@ -467,11 +471,11 @@ Disconnects this ability from the Service ability. This API uses a callback to r ...@@ -467,11 +471,11 @@ Disconnects this ability from the Service ability. This API uses a callback to r
onFailed: onFailedCallback, onFailed: onFailedCallback,
}, },
); );
var result = particleAbility.disconnectAbility(connId, var result = particleAbility.disconnectAbility(connId).then((data)=>{
(error,data) => { console.log( " data: " + data);
console.log('particleAbilityTest DisConnectJsSameBundleName result errCode : ' + error.code + " data: " + data) }).catch((error)=>{
}, console.log('particleAbilityTest result errCode : ' + error.code )
); });
``` ```
...@@ -486,13 +490,14 @@ Disconnects this ability from the Service ability. This API uses a promise to re ...@@ -486,13 +490,14 @@ Disconnects this ability from the Service ability. This API uses a promise to re
**Return value** **Return value**
| Type | Description | | Type | Description |
| -------------- | ------------------------- | | -------------- | ------------------------- |
| Promise\<void> | Promise used to return the result. | | Promise\<void> | Promise used to return the result.|
**Example** **Example**
```js ```js
import rpc from '@ohos.rpc'
function onConnectCallback(element, remote){ function onConnectCallback(element, remote){
console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy)); console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy));
} }
...@@ -514,8 +519,10 @@ function onConnectCallback(element, remote){ ...@@ -514,8 +519,10 @@ function onConnectCallback(element, remote){
}, },
); );
particleAbility.disconnectAbility(connId).then((error,data)=>{ particleAbility.disconnectAbility(connId).then((data)=>{
console.log('particleAbilityTest result errCode : ' + error.code + " data: " + data); console.log( " data: " + data);
}).catch((error)=>{
console.log('particleAbilityTest result errCode : ' + error.code )
}); });
``` ```
......
# PermissionRequestResult # PermissionRequestResult
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > **NOTE**<br>
> The initial APIs of this module are supported since API 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Provides the permission request result. Provides the permission request result.
## Modules to Import
```js
import Ability from '@ohos.application.Ability'
```
## Attributes ## Attributes
......
...@@ -11,7 +11,7 @@ Implements URI permission management. ...@@ -11,7 +11,7 @@ Implements URI permission management.
``` ```
import uriPermissionManager from '@ohos.application.uriPermissionManager'; import UriPermissionManager from '@ohos.application.uriPermissionManager';
``` ```
...@@ -27,18 +27,20 @@ SystemCapability.Ability.AbilityRuntime.Core ...@@ -27,18 +27,20 @@ SystemCapability.Ability.AbilityRuntime.Core
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| uri | string | Yes | URI of a file, for example, **fileshare:///com.samples.filesharetest.FileShare/person/10**. | | uri | string | Yes| URI of a file, for example, **fileshare:///com.samples.filesharetest.FileShare/person/10**.|
| flag | wantConstant.Flags | Yes | Read or write permission on the file specified by the URI. | | flag | wantConstant.Flags | Yes| Read or write permission on the file specified by the URI.|
| accessTokenId | number | Yes | Unique ID of an application, which is obtained through the **BundleManager** API. | | accessTokenId | number | Yes| Unique ID of an application, which is obtained through the **BundleManager** API.|
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the check result. The value **0** means that the application has the specified permission, and **-1** means the opposite. | | callback | AsyncCallback&lt;number&gt; | Yes| Callback used to return the check result. The value **0** means that the application has the specified permission, and **-1** means the opposite.|
**Example** **Example**
``` ```js
import WantConstant from '@ohos.ability.wantConstant';
let accessTokenId =1
let uri = "fileshare:///com.samples.filesharetest.FileShare/person/10" let uri = "fileshare:///com.samples.filesharetest.FileShare/person/10"
UriPermissionManager.verifyUriPermission(uri, wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, accessTokenId, (result) => { UriPermissionManager.verifyUriPermission(uri, WantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, accessTokenId, (result) => {
console.log("result.code = " + result.code) console.log("result.code = " + result.code)
}) // accessTokenId is obtained through the **BundleManager** API. }) // accessTokenId is obtained through the **BundleManager** API.
``` ```
...@@ -48,7 +50,7 @@ SystemCapability.Ability.AbilityRuntime.Core ...@@ -48,7 +50,7 @@ SystemCapability.Ability.AbilityRuntime.Core
verifyUriPermission(uri: string, flag: wantConstant.Flags, accessTokenId: number): Promise&lt;number&gt; verifyUriPermission(uri: string, flag: wantConstant.Flags, accessTokenId: number): Promise&lt;number&gt;
Checks whether an application has the permission specified by **flag** for an URI. This API uses a promise to return the result. Checks whether an application has the permission specified by **flag** for an URI. This API uses a callback to return the result.
**System capability**: **System capability**:
...@@ -56,21 +58,23 @@ SystemCapability.Ability.AbilityRuntime.Core ...@@ -56,21 +58,23 @@ SystemCapability.Ability.AbilityRuntime.Core
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| uri | string | Yes | URI of a file, for example, **fileshare:///com.samples.filesharetest.FileShare/person/10**. | | uri | string | Yes| URI of a file, for example, **fileshare:///com.samples.filesharetest.FileShare/person/10**.|
| flag | wantConstant.Flags | Yes | Read or write permission on the file specified by the URI. | | flag | wantConstant.Flags | Yes| Read or write permission on the file specified by the URI.|
| accessTokenId | number | Yes | Unique ID of an application, which is obtained through the **BundleManager** API. | | accessTokenId | number | Yes| Unique ID of an application, which is obtained through the **BundleManager** API.|
**Return value** **Return value**
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;number&gt; | Promise used to return the check result. The value **0** means that the application has the specified permission, and **-1** means the opposite. | | Promise&lt;number&gt; | Promise used to return the check result. The value **0** means that the application has the specified permission, and **-1** means the opposite.|
**Example** **Example**
``` ```js
import WantConstant from '@ohos.ability.wantConstant';
let accessTokenId =1
let uri = "fileshare:///com.samples.filesharetest.FileShare/person/10" let uri = "fileshare:///com.samples.filesharetest.FileShare/person/10"
UriPermissionManager.verifyUriPermission(uri, wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, accessTokenId) UriPermissionManager.verifyUriPermission(uri, wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, accessTokenId)
.then((data) => { .then((data) => {
...@@ -78,4 +82,4 @@ SystemCapability.Ability.AbilityRuntime.Core ...@@ -78,4 +82,4 @@ SystemCapability.Ability.AbilityRuntime.Core
}).catch((error) => { }).catch((error) => {
console.log('Verification failed.'); console.log('Verification failed.');
}) })
``` ```
\ No newline at end of file
...@@ -29,7 +29,6 @@ Obtains a **WantAgent** object. This API uses an asynchronous callback to return ...@@ -29,7 +29,6 @@ Obtains a **WantAgent** object. This API uses an asynchronous callback to return
```js ```js
import WantAgent from '@ohos.wantAgent'; import WantAgent from '@ohos.wantAgent';
import { OperationType, WantAgentFlags } from '@ohos.wantagent';
// getWantAgent callback // getWantAgent callback
function getWantAgentCallback(err, data) { function getWantAgentCallback(err, data) {
...@@ -58,9 +57,9 @@ var wantAgentInfo = { ...@@ -58,9 +57,9 @@ var wantAgentInfo = {
} }
} }
], ],
operationType: OperationType.START_ABILITIES, operationType: WantAgent.OperationType.START_ABILITIES,
requestCode: 0, requestCode: 0,
wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG] wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
} }
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback) WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback)
...@@ -92,7 +91,7 @@ Obtains a **WantAgent** object. This API uses a promise to return the result. ...@@ -92,7 +91,7 @@ Obtains a **WantAgent** object. This API uses a promise to return the result.
```js ```js
import WantAgent from '@ohos.wantAgent'; import WantAgent from '@ohos.wantAgent';
import { OperationType, WantAgentFlags } from '@ohos.wantagent';
// WantAgentInfo object // WantAgentInfo object
var wantAgentInfo = { var wantAgentInfo = {
...@@ -117,9 +116,9 @@ var wantAgentInfo = { ...@@ -117,9 +116,9 @@ var wantAgentInfo = {
} }
} }
], ],
operationType: OperationType.START_ABILITIES, operationType: WantAgent.OperationType.START_ABILITIES,
requestCode: 0, requestCode: 0,
wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG] wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
} }
WantAgent.getWantAgent(wantAgentInfo).then((data) => { WantAgent.getWantAgent(wantAgentInfo).then((data) => {
...@@ -148,7 +147,7 @@ Obtains the bundle name of a **WantAgent** object. This API uses an asynchronous ...@@ -148,7 +147,7 @@ Obtains the bundle name of a **WantAgent** object. This API uses an asynchronous
```js ```js
import WantAgent from '@ohos.wantAgent'; import WantAgent from '@ohos.wantAgent';
import { OperationType, WantAgentFlags } from '@ohos.wantagent';
// WantAgent object // WantAgent object
var wantAgent; var wantAgent;
...@@ -185,9 +184,9 @@ var wantAgentInfo = { ...@@ -185,9 +184,9 @@ var wantAgentInfo = {
} }
} }
], ],
operationType: OperationType.START_ABILITIES, operationType: WantAgent.OperationType.START_ABILITIES,
requestCode: 0, requestCode: 0,
wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG] wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
} }
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback) WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback)
...@@ -225,7 +224,7 @@ Obtains the bundle name of a **WantAgent** object. This API uses a promise to re ...@@ -225,7 +224,7 @@ Obtains the bundle name of a **WantAgent** object. This API uses a promise to re
```js ```js
import WantAgent from '@ohos.wantAgent'; import WantAgent from '@ohos.wantAgent';
import { OperationType, WantAgentFlags } from '@ohos.wantagent';
// WantAgent object // WantAgent object
var wantAgent; var wantAgent;
...@@ -253,9 +252,9 @@ var wantAgentInfo = { ...@@ -253,9 +252,9 @@ var wantAgentInfo = {
} }
} }
], ],
operationType: OperationType.START_ABILITIES, operationType: WantAgent.OperationType.START_ABILITIES,
requestCode: 0, requestCode: 0,
wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG] wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
} }
WantAgent.getWantAgent(wantAgentInfo).then((data) => { WantAgent.getWantAgent(wantAgentInfo).then((data) => {
...@@ -289,7 +288,7 @@ Obtains the user ID of a **WantAgent** object. This API uses an asynchronous cal ...@@ -289,7 +288,7 @@ Obtains the user ID of a **WantAgent** object. This API uses an asynchronous cal
```js ```js
import WantAgent from '@ohos.wantAgent'; import WantAgent from '@ohos.wantAgent';
import { OperationType, WantAgentFlags } from '@ohos.wantagent';
// WantAgent object // WantAgent object
var wantAgent; var wantAgent;
...@@ -326,9 +325,9 @@ var wantAgentInfo = { ...@@ -326,9 +325,9 @@ var wantAgentInfo = {
} }
} }
], ],
operationType: OperationType.START_ABILITIES, operationType: WantAgent.OperationType.START_ABILITIES,
requestCode: 0, requestCode: 0,
wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG] wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
} }
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback) WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback)
...@@ -366,7 +365,7 @@ Obtains the user ID of a **WantAgent** object. This API uses a promise to return ...@@ -366,7 +365,7 @@ Obtains the user ID of a **WantAgent** object. This API uses a promise to return
```js ```js
import WantAgent from '@ohos.wantAgent'; import WantAgent from '@ohos.wantAgent';
import { OperationType, WantAgentFlags } from '@ohos.wantagent';
// WantAgent object // WantAgent object
var wantAgent; var wantAgent;
...@@ -394,9 +393,9 @@ var wantAgentInfo = { ...@@ -394,9 +393,9 @@ var wantAgentInfo = {
} }
} }
], ],
operationType: OperationType.START_ABILITIES, operationType: WantAgent.OperationType.START_ABILITIES,
requestCode: 0, requestCode: 0,
wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG] wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
} }
WantAgent.getWantAgent(wantAgentInfo).then((data) => { WantAgent.getWantAgent(wantAgentInfo).then((data) => {
...@@ -430,7 +429,7 @@ Obtains the want in a **WantAgent** object. This API uses an asynchronous callba ...@@ -430,7 +429,7 @@ Obtains the want in a **WantAgent** object. This API uses an asynchronous callba
```js ```js
import WantAgent from '@ohos.wantAgent'; import WantAgent from '@ohos.wantAgent';
import { OperationType, WantAgentFlags } from '@ohos.wantagent';
// WantAgent object // WantAgent object
var wantAgent; var wantAgent;
...@@ -467,9 +466,9 @@ var wantAgentInfo = { ...@@ -467,9 +466,9 @@ var wantAgentInfo = {
} }
} }
], ],
operationType: OperationType.START_ABILITIES, operationType: WantAgent.OperationType.START_ABILITIES,
requestCode: 0, requestCode: 0,
wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG] wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
} }
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback) WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback)
...@@ -507,7 +506,7 @@ Obtains the want in a **WantAgent** object. This API uses a promise to return th ...@@ -507,7 +506,7 @@ Obtains the want in a **WantAgent** object. This API uses a promise to return th
```js ```js
import WantAgent from '@ohos.wantAgent'; import WantAgent from '@ohos.wantAgent';
import { OperationType, WantAgentFlags } from '@ohos.wantagent';
// WantAgent object // WantAgent object
var wantAgent; var wantAgent;
...@@ -535,9 +534,9 @@ var wantAgentInfo = { ...@@ -535,9 +534,9 @@ var wantAgentInfo = {
} }
} }
], ],
operationType: OperationType.START_ABILITIES, operationType: WantAgent.OperationType.START_ABILITIES,
requestCode: 0, requestCode: 0,
wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG] wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
} }
WantAgent.getWantAgent(wantAgentInfo).then((data) => { WantAgent.getWantAgent(wantAgentInfo).then((data) => {
...@@ -571,7 +570,7 @@ Cancels a **WantAgent** object. This API uses an asynchronous callback to return ...@@ -571,7 +570,7 @@ Cancels a **WantAgent** object. This API uses an asynchronous callback to return
```js ```js
import WantAgent from '@ohos.wantAgent'; import WantAgent from '@ohos.wantAgent';
import { OperationType, WantAgentFlags } from '@ohos.wantagent';
// WantAgent object // WantAgent object
var wantAgent; var wantAgent;
...@@ -608,9 +607,9 @@ var wantAgentInfo = { ...@@ -608,9 +607,9 @@ var wantAgentInfo = {
} }
} }
], ],
operationType: OperationType.START_ABILITIES, operationType: WantAgent.OperationType.START_ABILITIES,
requestCode: 0, requestCode: 0,
wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG] wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
} }
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback) WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback)
...@@ -648,7 +647,7 @@ Cancels a **WantAgent** object. This API uses a promise to return the result. ...@@ -648,7 +647,7 @@ Cancels a **WantAgent** object. This API uses a promise to return the result.
```js ```js
import WantAgent from '@ohos.wantAgent'; import WantAgent from '@ohos.wantAgent';
import { OperationType, WantAgentFlags } from '@ohos.wantagent';
// WantAgent object // WantAgent object
var wantAgent; var wantAgent;
...@@ -676,9 +675,9 @@ var wantAgentInfo = { ...@@ -676,9 +675,9 @@ var wantAgentInfo = {
} }
} }
], ],
operationType: OperationType.START_ABILITIES, operationType: WantAgent.OperationType.START_ABILITIES,
requestCode: 0, requestCode: 0,
wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG] wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
} }
WantAgent.getWantAgent(wantAgentInfo).then((data) => { WantAgent.getWantAgent(wantAgentInfo).then((data) => {
...@@ -713,7 +712,7 @@ Triggers a **WantAgent** object. This API uses an asynchronous callback to retur ...@@ -713,7 +712,7 @@ Triggers a **WantAgent** object. This API uses an asynchronous callback to retur
```js ```js
import WantAgent from '@ohos.wantAgent'; import WantAgent from '@ohos.wantAgent';
import { OperationType, WantAgentFlags } from '@ohos.wantagent';
// WantAgent object // WantAgent object
var wantAgent; var wantAgent;
...@@ -750,15 +749,15 @@ var wantAgentInfo = { ...@@ -750,15 +749,15 @@ var wantAgentInfo = {
} }
} }
], ],
operationType: OperationType.START_ABILITIES, operationType: WantAgent.OperationType.START_ABILITIES,
requestCode: 0, requestCode: 0,
wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG] wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
} }
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback) WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback)
// trigger callback // trigger callback
function triggerCallback(err, data) { function triggerCallback(data) {
console.info("==========================>triggerCallback=======================>"); console.info("==========================>triggerCallback=======================>");
} }
...@@ -783,14 +782,14 @@ Checks whether two **WantAgent** objects are equal. This API uses an asynchronou ...@@ -783,14 +782,14 @@ Checks whether two **WantAgent** objects are equal. This API uses an asynchronou
| Name | Readable| Writable| Type | Mandatory| Description | | Name | Readable| Writable| Type | Mandatory| Description |
| ---------- | --- | ---- | ------------------------ | ---- | --------------------------------------- | | ---------- | --- | ---- | ------------------------ | ---- | --------------------------------------- |
| agent | Yes | No | WantAgent | Yes | The first **WantAgent** object. | | agent | Yes | No | WantAgent | Yes | The first **WantAgent** object. |
| otherAgent | Yes | No | WantAgent | Yes | The second **WantAgent** object. | | otherAgent | Yes | No | WantAgent | Yes | Target **WantAgent** object. |
| callback | Yes | No | AsyncCallback\<boolean\> | Yes | Callback used to return the result.| | callback | Yes | No | AsyncCallback\<boolean\> | Yes | Callback used to return the result.|
**Example** **Example**
```js ```js
import WantAgent from '@ohos.wantAgent'; import WantAgent from '@ohos.wantAgent';
import { OperationType, WantAgentFlags } from '@ohos.wantagent';
// WantAgent object // WantAgent object
var wantAgent1; var wantAgent1;
...@@ -829,9 +828,9 @@ var wantAgentInfo = { ...@@ -829,9 +828,9 @@ var wantAgentInfo = {
} }
} }
], ],
operationType: OperationType.START_ABILITIES, operationType: WantAgent.OperationType.START_ABILITIES,
requestCode: 0, requestCode: 0,
wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG] wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
} }
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback) WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback)
...@@ -858,7 +857,7 @@ Checks whether two **WantAgent** objects are equal. This API uses a promise to r ...@@ -858,7 +857,7 @@ Checks whether two **WantAgent** objects are equal. This API uses a promise to r
| Name | Readable| Writable| Type | Mandatory| Description | | Name | Readable| Writable| Type | Mandatory| Description |
| ---------- | --- | ---- | --------- | ---- | ------------- | | ---------- | --- | ---- | --------- | ---- | ------------- |
| agent | Yes | No | WantAgent | Yes | The first **WantAgent** object.| | agent | Yes | No | WantAgent | Yes | The first **WantAgent** object.|
| otherAgent | Yes | No | WantAgent | Yes | The second **WantAgent** object.| | otherAgent | Yes | No | WantAgent | Yes | Target **WantAgent** object.|
**Return value** **Return value**
...@@ -870,7 +869,7 @@ Checks whether two **WantAgent** objects are equal. This API uses a promise to r ...@@ -870,7 +869,7 @@ Checks whether two **WantAgent** objects are equal. This API uses a promise to r
```js ```js
import WantAgent from '@ohos.wantAgent'; import WantAgent from '@ohos.wantAgent';
import { OperationType, WantAgentFlags } from '@ohos.wantagent';
// WantAgent object // WantAgent object
var wantAgent1; var wantAgent1;
...@@ -899,9 +898,9 @@ var wantAgentInfo = { ...@@ -899,9 +898,9 @@ var wantAgentInfo = {
} }
} }
], ],
operationType: OperationType.START_ABILITIES, operationType: WantAgent.OperationType.START_ABILITIES,
requestCode: 0, requestCode: 0,
wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG] wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
} }
WantAgent.getWantAgent(wantAgentInfo).then((data) => { WantAgent.getWantAgent(wantAgentInfo).then((data) => {
...@@ -915,6 +914,135 @@ WantAgent.equal(wantAgent1, wantAgent2).then((data) => { ...@@ -915,6 +914,135 @@ WantAgent.equal(wantAgent1, wantAgent2).then((data) => {
}); });
``` ```
## WantAgent.getOperationType
getOperationType(agent: WantAgent, callback: AsyncCallback\<number>): void;
Obtains the operation type of a **WantAgent** object. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Readable| Writable| Type | Mandatory| Description |
| ---------- | --- | ---- | ------------------------ | ---- | --------------------------------------- |
| agent | Yes | No | WantAgent | Yes | Target **WantAgent** object. |
| callback | Yes | No | AsyncCallback\<number> | Yes | Callback used to return the operation type.|
**Example**
```js
import WantAgent from '@ohos.wantAgent';
// WantAgent object
var wantAgent;
// WantAgentInfo object
var wantAgentInfo = {
wants: [
{
deviceId: "deviceId",
bundleName: "com.neu.setResultOnAbilityResultTest1",
abilityName: "com.example.test.MainAbility",
action: "action1",
entities: ["entity1"],
type: "MIMETYPE",
uri: "key={true,true,false}",
parameters:
{
mykey0: 2222,
mykey1: [1, 2, 3],
mykey2: "[1, 2, 3]",
mykey3: "ssssssssssssssssssssssssss",
mykey4: [false, true, false],
mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"],
mykey6: true,
}
}
],
operationType: WantAgent.OperationType.START_ABILITIES,
requestCode: 0,
wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
}
WantAgent.getWantAgent(wantAgentInfo).then((data) => {
console.info("==========================>getWantAgentCallback=======================>");
wantAgent = data;
});
WantAgent.getOperationType(wantAgent, (OperationType) => {
console.log('----------- getOperationType ----------, OperationType: ' + OperationType);
})
```
## WantAgent.getOperationType
getOperationType(agent: WantAgent): Promise\<number>;
Obtains the operation type of a **WantAgent** object. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Readable| Writable| Type | Mandatory| Description |
| ---------- | --- | ---- | --------- | ---- | ------------- |
| agent | Yes | No | WantAgent | Yes | Target **WantAgent** object.|
**Return value**
| Type | Description |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<number> | Promise used to return the operation type.|
**Example**
```js
import WantAgent from '@ohos.wantAgent';
// WantAgent object
var wantAgent;
// WantAgentInfo object
var wantAgentInfo = {
wants: [
{
deviceId: "deviceId",
bundleName: "com.neu.setResultOnAbilityResultTest1",
abilityName: "com.example.test.MainAbility",
action: "action1",
entities: ["entity1"],
type: "MIMETYPE",
uri: "key={true,true,false}",
parameters:
{
mykey0: 2222,
mykey1: [1, 2, 3],
mykey2: "[1, 2, 3]",
mykey3: "ssssssssssssssssssssssssss",
mykey4: [false, true, false],
mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"],
mykey6: true,
}
}
],
operationType: WantAgent.OperationType.START_ABILITIES,
requestCode: 0,
wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
}
WantAgent.getWantAgent(wantAgentInfo).then((data) => {
console.info("==========================>getWantAgentCallback=======================>");
wantAgent = data;
});
WantAgent.getOperationType(wantAgent).then((OperationType) => {
console.log('getOperationType success, OperationType: ' + OperationType);
}).catch((err) => {
console.log('getOperationType fail, err: ' + err);
})
```
## WantAgentInfo ## WantAgentInfo
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册