提交 60a11bdc 编写于 作者: W wusongqing

update docs against 8626

Signed-off-by: Nwusongqing <wusongqing@huawei.com>
上级 bfc98e13
......@@ -7,7 +7,7 @@ import featureAbility from '@ohos.ability.featureAbility'
import bundle from '@ohos.bundle'
```
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
import featureAbility from '@ohos.ability.featureAbility'
......@@ -27,9 +27,9 @@ If this API is called for the first time, a root directory will be created.
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | -------------------------- |
| callback | AsyncCallback\<string> | Yes | Callback used to return the local root directory.|
| Name | Type | Mandatory | Description |
| -------- | ---------------------- | ---- | ------------- |
| callback | AsyncCallback\<string> | Yes | Callback used to return the local root directory.|
**Example**
......@@ -55,8 +55,8 @@ If this API is called for the first time, a root directory will be created.
**Return value**
| Type | Description |
| ---------------- | ---------------------- |
| Type | Description |
| ---------------- | ----------- |
| Promise\<string> | Promise used to return the local root directory.|
**Example**
......@@ -81,11 +81,11 @@ Verifies whether a specific PID and UID have the given permission. This API uses
**Parameters**
| Name | Type | Mandatory| Description |
| ---------- | --------------------------------------- | ---- | ------------------------------------- |
| permission | string | Yes | Name of the permission to verify. |
| 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.|
| Name | Type | Mandatory | Description |
| ---------- | --------------------------------------- | ---- | -------------------- |
| permission | string | Yes | Name of the permission to verify. |
| options | [PermissionOptions](#permissionoptions) | Yes | Permission options. |
| callback | AsyncCallback\<number> | Yes | Callback used to return the permission verification result. The value **0** means that the PID and UID have the given permission, and the value **-1** means the opposite.|
**Example**
......@@ -110,10 +110,10 @@ Verifies whether the current PID and UID have the given permission. This API use
**Parameters**
| Name | Type | Mandatory| Description |
| ---------- | ---------------------- | ---- | ------------------------------------- |
| 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.|
| Name | Type | Mandatory | Description |
| ---------- | ---------------------- | ---- | -------------------- |
| permission | string | Yes | Name of the permission to verify. |
| callback | AsyncCallback\<number> | Yes | Callback used to return the permission verification result. The value **0** means that the PID and UID have the given permission, and the value **-1** means the opposite.|
**Example**
......@@ -133,16 +133,16 @@ Verifies whether a specific PID and UID have the given permission. This API uses
**Parameters**
| Name | Type | Mandatory| Description |
| ---------- | --------------------------------------- | ---- | ---------------- |
| permission | string | Yes | Name of the permission to verify.|
| options | [PermissionOptions](#permissionoptions) | No | Permission options. |
| Name | Type | Mandatory | Description |
| ---------- | --------------------------------------- | ---- | -------- |
| permission | string | Yes | Name of the permission to verify.|
| options | [PermissionOptions](#permissionoptions) | No | Permission options. |
**Return value**
| 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.|
| Type | Description |
| ---------------- | ---------------------------------- |
| Promise\<number> | Promise used to return the permission verification result. The value **0** means that the PID and UID have the given permission, and the value **-1** means the opposite.|
**Example**
......@@ -168,11 +168,11 @@ Requests certain permissions from the system. This API uses an asynchronous call
**Parameters**
| Name | Type | Mandatory| Description |
| -------------- | ------------------------------------------------------------ | ---- | ----------------------------------------------- |
| permissions | Array\<string> | Yes | Permissions to request. This parameter cannot be **null**. |
| requestCode | number | Yes | Request code to be passed to **PermissionRequestResult**.|
| resultCallback | AsyncCallback<[PermissionRequestResult](#permissionrequestresult)> | Yes | Permission request result. |
| Name | Type | Mandatory | Description |
| -------------- | ---------------------------------------- | ---- | ----------------------------------- |
| permissions | Array\<string> | Yes | Permissions to request. This parameter cannot be **null**. |
| requestCode | number | Yes | Request code to be passed to **PermissionRequestResult**.|
| resultCallback | AsyncCallback<[PermissionRequestResult](#permissionrequestresult)> | Yes | Callback used to return the permission request result. |
**Example**
......@@ -193,6 +193,44 @@ context.requestPermissionsFromUser(
```
## Context.requestPermissionsFromUser<sup>7+</sup>
requestPermissionsFromUser(permissions: Array\<string>, requestCode: number): Promise\<[PermissionRequestResult](#permissionrequestresult7)>
Requests certain permissions from the system. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory | Description |
| -------------- | ------------------- | ----- | -------------------------------------------- |
| permissions | Array\<string> | Yes | Permissions to request. This parameter cannot be **null**. |
| requestCode | number | Yes | Request code to be passed to **PermissionRequestResult**.|
**Return value**
| Type | Description |
| ------------------------------------------------------------- | ---------------- |
| Promise\<[PermissionRequestResult](#permissionrequestresult7)> | Promise used to return the permission request result.|
**Example**
```js
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext();
context.requestPermissionsFromUser(
["com.example.permission1",
"com.example.permission2",
"com.example.permission3",
"com.example.permission4",
"com.example.permission5"],
1).then((data)=>{
console.info("====>requestdata====>" + JSON.stringify(data));
});
```
## Context.getApplicationInfo
......@@ -204,9 +242,9 @@ Obtains information about the current application. This API uses an asynchronous
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------- | ---- | ------------------------ |
| callback | AsyncCallback\<ApplicationInfo> | Yes | Callback used to return the application information.|
| Name | Type | Mandatory | Description |
| -------- | ------------------------------- | ---- | ------------ |
| callback | AsyncCallback\<ApplicationInfo> | Yes | Callback used to return the application information.|
**Example**
......@@ -228,8 +266,8 @@ Obtains information about the current application. This API uses a promise to re
**Return value**
| Type | Description |
| ------------------------- | ------------------ |
| Type | Description |
| ------------------------- | --------- |
| Promise\<ApplicationInfo> | Promise used to return the application information.|
**Example**
......@@ -249,15 +287,15 @@ context.getApplicationInfo().then((data) => {
getBundleName(callback: AsyncCallback\<string>): void
Obtains the bundle name of the current ability. This API uses an asynchronous callback to return the result.
Obtains the bundle name of this ability. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ----------------------------- |
| callback | AsyncCallback\<string> | Yes | Callback used to return the bundle name.|
| Name | Type | Mandatory | Description |
| -------- | ---------------------- | ---- | ------------------ |
| callback | AsyncCallback\<string> | Yes | Callback used to return the bundle name.|
**Example**
......@@ -273,14 +311,14 @@ context.getBundleName()
getBundleName(): Promise\<string>
Obtains the bundle name of the current ability. This API uses a promise to return the result.
Obtains the bundle name of this ability. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Return value**
| Type | Description |
| ---------------- | ------------------------- |
| Type | Description |
| ---------------- | ---------------- |
| Promise\<string> | Promise used to return the bundle name.|
**Example**
......@@ -306,9 +344,9 @@ Obtains information about the current process, including the PID and process nam
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | -------------------- |
| callback | AsyncCallback\<ProcessInfo> | Yes | Callback used to return the process information.|
| Name | Type | Mandatory | Description |
| -------- | --------------------------- | ---- | ---------- |
| callback | AsyncCallback\<ProcessInfo> | Yes | Callback used to return the process information.|
**Example**
......@@ -330,8 +368,8 @@ Obtains information about the current process, including the PID and process nam
**Return value**
| Type | Description |
| --------------------- | -------------- |
| Type | Description |
| --------------------- | ------- |
| Promise\<ProcessInfo> | Promise used to return the process information.|
**Example**
......@@ -351,7 +389,7 @@ context.getProcessInfo().then((data) => {
getElementName(callback: AsyncCallback\<ElementName>): void
Obtains the **ohos.bundle.ElementName** object of the current ability. This API uses an asynchronous callback to return the result.
Obtains the **ohos.bundle.ElementName** object of this ability. This API uses an asynchronous callback to return the result.
This API is available only to Page abilities.
......@@ -359,9 +397,9 @@ This API is available only to Page abilities.
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | ---------------------------------------------- |
| callback | AsyncCallback\<ElementName> | Yes | Callback used to return the **ohos.bundle.ElementName** object.|
| Name | Type | Mandatory | Description |
| -------- | --------------------------- | ---- | -------------------------------------- |
| callback | AsyncCallback\<ElementName> | Yes | Callback used to return the **ohos.bundle.ElementName** object.|
**Example**
......@@ -377,7 +415,7 @@ context.getElementName()
getElementName(): Promise\<ElementName>
Obtains the **ohos.bundle.ElementName** object of the current ability. This API uses a promise to return the result.
Obtains the **ohos.bundle.ElementName** object of this ability. This API uses a promise to return the result.
This API is available only to Page abilities.
......@@ -385,8 +423,8 @@ This API is available only to Page abilities.
**Return value**
| Type | Description |
| --------------------- | ------------------------------------------ |
| Type | Description |
| --------------------- | ------------------------------------ |
| Promise\<ElementName> | Promise used to return the **ohos.bundle.ElementName** object.|
**Example**
......@@ -410,9 +448,9 @@ Obtains the name of the current process. This API uses an asynchronous callback
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | -------------------- |
| callback | AsyncCallback\<string> | Yes | Callback used to return the process name.|
| Name | Type | Mandatory | Description |
| -------- | ---------------------- | ---- | ---------- |
| callback | AsyncCallback\<string> | Yes | Callback used to return the process name.|
**Example**
......@@ -434,8 +472,8 @@ Obtains the name of the current process. This API uses a promise to return the r
**Return value**
| Type | Description |
| ---------------- | -------------------- |
| Type | Description |
| ---------------- | ---------- |
| Promise\<string> | Promise used to return the process name.|
**Example**
......@@ -461,9 +499,9 @@ Obtains the bundle name of the calling ability. This API uses an asynchronous ca
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ------------------------- |
| callback | AsyncCallback\<string> | Yes | Callback used to return the bundle name.|
| Name | Type | Mandatory | Description |
| -------- | ---------------------- | ---- | ---------------- |
| callback | AsyncCallback\<string> | Yes | Callback used to return the bundle name.|
**Example**
......@@ -485,8 +523,8 @@ Obtains the bundle name of the calling ability. This API uses a promise to retur
**Return value**
| Type | Description |
| --------------- | ------------------------- |
| Type | Description |
| ---------------- | -------------- |
| Promise\<string> | Promise used to return the bundle name.|
**Example**
......@@ -504,15 +542,15 @@ context.getCallingBundle().then((data) => {
getCacheDir(callback: AsyncCallback\<string>): void
Obtains the cache directory of the application on the internal storage. This API uses an asynchronous callback to return the result.
Obtains the cache directory of the application in the internal storage. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ------------------------- |
| callback | AsyncCallback\<string> | Yes | Callback used to return the cache directory.|
| Name | Type | Mandatory | Description |
| -------- | ---------------------- | ---- | --------------- |
| callback | AsyncCallback\<string> | Yes | Callback used to return the cache directory.|
**Example**
......@@ -532,14 +570,14 @@ context.getCacheDir((err, data) => {
getCacheDir(): Promise\<string>
Obtains the cache directory of the application on the internal storage. This API uses a promise to return the result.
Obtains the cache directory of the application in the internal storage. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Return value**
| Type | Description |
| --------------- | ------------------------- |
| Type | Description |
| ---------------- | --------------- |
| Promise\<string> | Promise used to return the cache directory.|
**Example**
......@@ -557,15 +595,15 @@ context.getCacheDir().then((data) => {
getFilesDir(callback: AsyncCallback\<string>): void
Obtains the file directory of the application on the internal storage. This API uses an asynchronous callback to return the result.
Obtains the file directory of the application in the internal storage. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ------------------------- |
| callback | AsyncCallback\<string> | Yes | Callback used to return the file directory.|
| Name | Type | Mandatory | Description |
| -------- | ---------------------- | ---- | ------------------- |
| callback | AsyncCallback\<string> | Yes | Callback used to return the file directory.|
**Example**
......@@ -585,14 +623,14 @@ context.getFilesDir((err, data) => {
getFilesDir(): Promise\<string>
Obtains the file directory of the application on the internal storage. This API uses a promise to return the result.
Obtains the file directory of the application in the internal storage. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Return value**
| Type | Description |
| --------------- | ------------------------- |
| Type | Description |
| ---------------- | ------------------- |
| Promise\<string> | Promise used to return the file directory.|
**Example**
......@@ -618,9 +656,9 @@ If the distributed file path does not exist, the system will create one and retu
**Parameters**
| 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.|
| 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.|
**Example**
......@@ -648,8 +686,8 @@ If the distributed file path does not exist, the system will create one and retu
**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.|
**Example**
......@@ -672,9 +710,9 @@ Obtains the application type. This API uses an asynchronous callback to return t
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ------------------------- |
| callback | AsyncCallback\<string> | Yes | Callback used to return the application type.|
| Name | Type | Mandatory | Description |
| -------- | ---------------------- | ---- | -------------------------------- |
| callback | AsyncCallback\<string> | Yes | Callback used to return the application type.|
**Example**
......@@ -700,8 +738,8 @@ Obtains the application type. This API uses a promise to return the result.
**Return value**
| Type | Description |
| --------------- | ------------------------- |
| Type | Description |
| ---------------- | ------------------ |
| Promise\<string> | Promise used to return the application type.|
**Example**
......@@ -724,9 +762,9 @@ Obtains the **ModuleInfo** object of the application. This API uses an asynchron
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ------------------------- |
| callback | AsyncCallback\<[HapModuleInfo](#hapmoduleinfo)> | Yes | Callback used to return the **ModuleInfo** object.|
| Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | --------------------------------------- |
| callback | AsyncCallback\<[HapModuleInfo](#hapmoduleinfo)> | Yes | Callback used to return the **ModuleInfo** object.|
**Example**
......@@ -752,8 +790,8 @@ Obtains the **ModuleInfo** object of the application. This API uses a promise to
**Return value**
| Type | Description |
| --------------- | ------------------------- |
| Type | Description |
| ---------------------------------------- | ------------------ |
| Promise\<[HapModuleInfo](#hapmoduleinfo)> | Promise used to return the **ModuleInfo** object.|
**Example**
......@@ -776,9 +814,9 @@ Obtains the version information of the application. This API uses an asynchronou
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ------------------------- |
| callback | AsyncCallback\<[AppVersionInfo](#appversioninfo)> | Yes | Callback used to return the version information.|
| Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ------------------------------ |
| callback | AsyncCallback\<[AppVersionInfo](#appversioninfo)> | Yes | Callback used to return the version information.|
**Example**
......@@ -804,8 +842,8 @@ Obtains the version information of the application. This API uses a promise to r
**Return value**
| Type | Description |
| --------------- | ------------------------- |
| Type | Description |
| ---------------------------------------- | --------- |
| Promise\<[AppVersionInfo](#appversioninfo)> | Promise used to return the version information.|
**Example**
......@@ -822,15 +860,15 @@ context.getAppVersionInfo().then((data) => {
getAbilityInfo(callback: AsyncCallback\<AbilityInfo>): void
Obtains information of the current ability. This API uses an asynchronous callback to return the result.
Obtains information about this ability. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ------------------------- |
| callback | AsyncCallback\<[AbilityInfo](#abilityInfo)> | Yes |Callback used to return the ability information.|
| Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | --------------------------------------- |
| callback | AsyncCallback\<[AbilityInfo](#abilityInfo)> | Yes | Callback used to return the ability information.|
**Example**
......@@ -850,14 +888,14 @@ context.getAbilityInfo((err, data) => {
getAbilityInfo(): Promise\<AbilityInfo>
Obtains information of the current ability. This API uses a promise to return the result.
Obtains information about this ability. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Return value**
| Type | Description |
| --------------- | ------------------------- |
| Type | Description |
| ---------------------------------------- | ------------------ |
| Promise\<[AbilityInfo](#abilityInfo)> | Promise used to return the ability information.|
**Example**
......@@ -880,9 +918,9 @@ Obtains the context of the application.
**Return value**
| Type | Description |
| --------- |------ |
| Context |Application context.|
| Type | Description |
| ------- | ---------- |
| Context | Application context.|
**Example**
......@@ -895,48 +933,49 @@ var context = featureAbility.getContext().getApplicationContext();
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name| Readable/Writable| Type | Mandatory| Description |
| ---- | -------- | ------ | ---- | ------ |
| pid | Read-only | number | No | Process ID.|
| uid | Read-only | number | No | User ID.|
| Name | Readable/Writable| Type | Mandatory | Description |
| ---- | ---- | ------ | ---- | ----- |
| pid | Read-only | number | No | Process ID.|
| uid | Read-only | number | No | User ID.|
## PermissionRequestResult
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Readable/Writable| Type | Mandatory| Description |
| ----------- | -------- | -------------- | ---- | ------------------ |
| requestCode | Read-only | number | Yes | Request code passed.|
| permissions | Read-only | Array\<string> | Yes | Permissions requested. |
| authResults | Read-only | Array\<number> | Yes | Permission request result. |
| Name | Readable/Writable| Type | Mandatory | Description |
| ----------- | ---- | -------------- | ---- | ---------- |
| requestCode | Read-only | number | Yes | Request code passed.|
| permissions | Read-only | Array\<string> | Yes | Permissions requested. |
| authResults | Read-only | Array\<number> | Yes | Permission request result. |
## HapModuleInfo
Describes the HAP module information.
| Name | Type| Readable| Writable| Description|
| ------ | ------ | ------ | ------ | ------ |
| name | string | Yes | No | Module name. |
| description | string | Yes | No | Module description. |
| descriptionId | number | Yes | No | Module description ID. |
| icon | string | Yes | No | Module icon. |
| label | string | Yes | No | Module label. |
| labelId | number | Yes | No | Module label ID. |
| iconId | number | Yes | No | Module icon ID. |
| backgroundImg | string | Yes | No | Module background image. |
| supportedModes | number | Yes | No | Running modes supported by the module. |
| reqCapabilities | Array\<string> | Yes | No | Capabilities required for module running.|
| deviceTypes | Array\<string> | Yes | No | Device types supported by the module.|
| abilityInfo | Array\<AbilityInfo> | Yes | No | Ability information. |
| moduleName | string | Yes | No | Module name. |
| mainAbilityName | string | Yes | No | Name of the main ability. |
| installationFree | boolean | Yes | No | Whether installation-free is supported. |
| mainElementName | string | Yes| No| Information about the main ability.|
| Name | Type | Readable | Writable | Description |
| ---------------- | ------------------- | -------- | -------- | ----------------------------------------- |
| name | string | Yes | No | Module name. |
| description | string | Yes | No | Module description. |
| descriptionId | number | Yes | No | Module description ID. |
| icon | string | Yes | No | Module icon. |
| label | string | Yes | No | Module label. |
| labelId | number | Yes | No | Module label ID. |
| iconId | number | Yes | No | Module icon ID. |
| backgroundImg | string | Yes | No | Module background image. |
| supportedModes | number | Yes | No | Running modes supported by the module. |
| reqCapabilities | Array\<string> | Yes | No | Capabilities required for module running. |
| deviceTypes | Array\<string> | Yes | No | Device types supported by the module. |
| abilityInfo | Array\<AbilityInfo> | Yes | No | Ability information. |
| moduleName | string | Yes | No | Module name. |
| mainAbilityName | string | Yes | No | Name of the main ability. |
| installationFree | boolean | Yes | No | Whether installation-free is supported. |
| mainElementName | string | Yes | No | Information about the main ability. |
## AppVersionInfo
| Name | Type| Readable | Writable | Description|
| ------ | ------ | ------| ------ | ------ |
| appName | string | Yes | No | Module name. |
| versionCode | number | Yes | No | Module description. |
| versionName | string | Yes | No | Module description ID. |
| Name | Type | Readable | Writable | Description |
| ----------- | ------ | ---- | ---- | ------- |
| appName | string | Yes | No | Module name. |
| versionCode | number | Yes | No | Module description.|
| versionName | string | Yes | No | Module description ID.|
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册