提交 d8d794cc 编写于 作者: W wusongqing

updated docs

Signed-off-by: Nwusongqing <wusongqing@huawei.com>
上级 ec434260
# Want
> ![icon-note.gif](public_sys-resources/icon-note.gif) **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.
**Want** is the basic communication component of the system.
## Modules to Import
```
import Want from '@ohos.application.Want';
```
## Attributes
**System capability**: SystemCapability.Ability.AbilityBase
| Name | Readable/Writable| Type | Mandatory| Description |
| ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ |
| deviceId | Read only | string | No | ID of the device running the ability. |
| bundleName | Read only | string | No | Bundle name of the ability. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can directly match the specified ability.|
| abilityName | Read only | string | No | Name of the ability. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can directly match the specified ability.|
| uri | Read only | string | No | URI information to match. If **uri** is specified in a **Want** object, the **Want** object will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path**.|
| type | Read only | string | No | MIME type, for example, **text/plain** or **image/***. |
| flags | Read only | number | No | How the **Want** object will be handled. By default, numbers are passed in. For details, see [flags](js-apis-featureAbility.md#flags).|
| action | Read only | string | No | Action option. |
| parameters | Read only | {[key: string]: any} | No | List of parameters in the **Want** object. |
| entities | Read only | Array\<string> | No | List of entities. | |
# appManager
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> The initial APIs of this module are supported since API 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.
Implements application management.
......@@ -9,7 +9,7 @@ Implements application management.
## Modules to Import
```js
import app from '@ohos.application.appManager';
```
......@@ -77,18 +77,16 @@ Checks whether this application is running in a RAM constrained device. This API
| Type| Description|
| -------- | -------- |
| Promise&lt;boolean&gt; | Promise used to return whether the the application is running in a RAM constrained device. If the the application is running in a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.|
| Promise&lt;boolean&gt; | Promise used to return whether the application is running in a RAM constrained device. If the application is running in a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.|
**Example**
```js
IsRamConstrainedDevicePromise(){
app.isRamConstrainedDevicePromise().then((data) => {
console.log('success:' + JSON.stringify(data));
}).catch((error) => {
console.log('failed:' + JSON.stringify(error));
});
}
```
## appManager.isRamConstrainedDevice
......@@ -103,17 +101,15 @@ Checks whether this application is running in a RAM constrained device. This API
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | No| Callback used to return whether the the application is running in a RAM constrained device. If the the application is running in a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.|
| callback | AsyncCallback&lt;boolean&gt; | No| Callback used to return whether the application is running in a RAM constrained device. If the application is running in a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.|
**Example**
```js
IsRamConstrainedDeviceCallBack(){
app.isRamConstrainedDevicePromise((err, data) => {
console.log('startAbility result failed:' + JSON.stringify(err));
console.log('startAbility result success:' + JSON.stringify(data));
})
}
```
## appManager.getAppMemorySize
......@@ -133,13 +129,11 @@ Obtains the memory size of this application. This API uses a promise to return t
**Example**
```js
GetAppMemorySize(){
app.getAppMemorySize().then((data) => {
console.log('success:' + JSON.stringify(data));
}).catch((error) => {
console.log('failed:' + JSON.stringify(error));
});
}
```
## appManager.getAppMemorySize
......@@ -159,10 +153,65 @@ Obtains the memory size of this application. This API uses an asynchronous callb
**Example**
```js
GetAppMemorySizeCallBack(){
app.getAppMemorySize((err, data) => {
console.log('startAbility result failed :' + JSON.stringify(err));
console.log('startAbility result success:' + JSON.stringify(data));
})
}
```
## appManager.getProcessRunningInfos<sup>8+</sup>
getProcessRunningInfos(): Promise<Array<ProcessRunningInfo>>;
Obtains information about the running processes. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Return value**
| Type| Description|
| -------- | -------- |
| Promise<Array\<ProcessRunningInfo>> | Promise used to return the process information.|
**Example**
```js
app.GetProcessRunningInfos().then((data) => {
console.log('success:' + JSON.stringify(data));
}).catch((error) => {
console.log('failed:' + JSON.stringify(error));
});
```
## appManager.getProcessRunningInfos<sup>8+</sup>
getProcessRunningInfos(callback: AsyncCallback<Array<ProcessRunningInfo>>): void;
Obtains information about the running processes. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<Array\<ProcessRunningInfo>> | No| Callback used to return the process information.|
**Example**
```js
app.GetProcessRunningInfos((err, data) => {
console.log('startAbility result failed :' + JSON.stringify(err));
console.log('startAbility result success:' + JSON.stringify(data));
})
```
## ProcessRunningInfo
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Readable/Writable| Type | Mandatory| Description |
| ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ |
| pid<sup>8+</sup> | Read only | number | No | Process ID. |
| uid<sup>8+</sup> | Read only | number | No | User ID.|
| processName<sup>8+</sup> | Read only | string | No | Process name.|
| bundleNames<sup>8+</sup> | Read only | Array\<string> | No | **bundleName** array in the running process.|
......@@ -23,10 +23,10 @@ Starts an ability. This method uses a callback to return the result.
**Parameters**
| Name | Type | Mandatory| Description |
| --------- | --------------------- | ---- | ------------------- |
| parameter | [StartAbilityParameter](#startabilityparameter) | Yes | Ability to start.|
| callback | AsyncCallback\<number> | Yes | Callback used to return the result. |
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | -------------- |
| parameter | [StartAbilityParameter](#startabilityparameter) | Yes | Ability to start.|
| callback | AsyncCallback\<number> | Yes | Callback used to return the result. |
**Example**
......@@ -62,9 +62,9 @@ Starts an ability. This method uses a promise to return the result.
**Parameters**
| Name | Type | Mandatory| Description |
| --------- | ----------------------------------------------- | ---- | --------------------- |
| parameter | [StartAbilityParameter](#startabilityparameter) | Yes | Ability to start.|
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | -------------- |
| parameter | [StartAbilityParameter](#startabilityparameter) | Yes | Ability to start.|
**Example**
......@@ -100,14 +100,14 @@ Obtains a **dataAbilityHelper** object.
**Parameters**
| Name| Type | Mandatory| Description |
| ---- | ------ | ---- | ------------------------ |
| uri | string | Yes | URI of the file to open.|
| Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ------------ |
| uri | string | Yes | URI of the file to open.|
**Return value**
| Type | Description |
| ----------------- | -------------------------------------------- |
| Type | Description |
| ----------------- | ------------------------------- |
| DataAbilityHelper | A utility class used to help other abilities access the Data ability.|
**Example**
......@@ -129,10 +129,10 @@ Starts an ability. This method uses a callback to return the execution result wh
**Parameters**
| Name | Type | Mandatory| Description |
| --------- | ----------------------------------------------- | ---- | --------------------- |
| parameter | [StartAbilityParameter](#startabilityparameter) | Yes | Ability to start.|
| callback | AsyncCallback\<[AbilityResult](#abilityresult)> | Yes | Callback used to return the result. |
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | -------------- |
| parameter | [StartAbilityParameter](#startabilityparameter) | Yes | Ability to start.|
| callback | AsyncCallback\<[AbilityResult](#abilityresult)> | Yes | Callback used to return the result. |
**Example**
......@@ -166,14 +166,14 @@ Starts an ability. This method uses a promise to return the execution result whe
**Parameters**
| Name | Type | Mandatory| Description |
| --------- | ----------------------------------------------- | ---- | ------------------- |
| parameter | [StartAbilityParameter](#startabilityparameter) | Yes | Ability to start.|
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | ------------- |
| parameter | [StartAbilityParameter](#startabilityparameter) | Yes | Ability to start.|
**Return value**
| Type | Description |
| ----------------------------------------- | -------------- |
| Type | Description |
| ---------------------------------------- | ------- |
| Promise\<[AbilityResult](#abilityresult)> | Promised returned with the execution result.|
**Example**
......@@ -222,10 +222,10 @@ Destroys this Page ability, with the result code and data sent to the caller. Th
**Parameters**
| Name | Type | Mandatory| Description |
| --------- | ------------- | ---- | ------------------- |
| parameter | [AbilityResult](#abilityresult) | Yes | Ability to start.|
| callback | AsyncCallback\<void> | Yes | Callback used to return the result. |
| Name | Type | Mandatory | Description |
| --------- | ------------------------------- | ---- | -------------- |
| parameter | [AbilityResult](#abilityresult) | Yes | Ability to start.|
| callback | AsyncCallback\<void> | Yes | Callback used to return the result. |
**Example**
......@@ -270,14 +270,14 @@ Destroys this Page ability, with the result code and data sent to the caller. Th
**Parameters**
| Name | Type | Mandatory| Description |
| --------- | ------------------------------- | ---- | ------------------- |
| parameter | [AbilityResult](#abilityresult) | Yes | Ability to start.|
| Name | Type | Mandatory | Description |
| --------- | ------------------------------- | ---- | ------------- |
| parameter | [AbilityResult](#abilityresult) | Yes | Ability to start.|
**Return value**
| Type | Description |
| -------------- | ----------------------- |
| Type | Description |
| -------------- | --------------- |
| Promise\<void> | Promise used to return the result.|
**Example**
......@@ -327,9 +327,9 @@ Checks whether the main window of this ability has the focus. This method uses a
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | ------------------------------------------------------------ |
| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result.<br>Returns **true** if the main window of this ability has the focus; returns **false** otherwise.|
| Name | Type | Mandatory | Description |
| -------- | ----------------------- | ---- | ---------------------------------------- |
| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result.<br>Returns **true** if the main window of this ability has the focus; returns **false** otherwise.|
**Example**
......@@ -350,8 +350,8 @@ Checks whether the main window of this ability has the focus. This method uses a
**Return value**
| Type | Description |
| ----------------- | ---------------------------------------------------------- |
| Type | Description |
| ----------------- | ------------------------------------- |
| Promise\<boolean> | Returns **true** if the main window of this ability has the focus; returns **false** otherwise.|
**Example**
......@@ -375,9 +375,9 @@ Obtains the **Want** object sent from this ability. This method uses a callback
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------------- | ---- | ------------------ |
| callback | AsyncCallback\<[Want](#want)> | Yes | Callback used to return the result.|
| Name | Type | Mandatory | Description |
| -------- | ----------------------------- | ---- | --------- |
| callback | AsyncCallback\<[Want](#want)> | Yes | Callback used to return the result.|
**Example**
......@@ -398,8 +398,8 @@ Obtains the **Want** object sent from this ability. This method uses a promise t
**Return value**
| Type | Description |
| ----------------------- | ------------------------- |
| Type | Description |
| ----------------------- | ---------------- |
| Promise\<[Want](#want)> | Promise used to return the result.|
**Example**
......@@ -421,8 +421,8 @@ Obtains the application context.
**Return value**
| Type | Description |
| ------- | -------------------- |
| Type | Description |
| ------- | ---------- |
| Context | Application context returned.|
**Example**
......@@ -445,9 +445,9 @@ Destroys this Page ability, with the result code and data sent to the caller. Th
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ---------------- |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
| Name | Type | Mandatory | Description |
| -------- | -------------------- | ---- | -------- |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Example**
......@@ -468,8 +468,8 @@ Destroys this Page ability, with the result code and data sent to the caller. Th
**Return value**
| Type | Description |
| -------------- | ------------------------- |
| Type | Description |
| -------------- | ---------------- |
| Promise\<void> | Promise used to return the result.|
**Example**
......@@ -490,35 +490,35 @@ Connects this ability to a specific Service ability. This method uses a callback
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | -------------- | ---- | ---------------------------- |
| request | [Want](#want) | Yes | Service ability to connect.|
| options | ConnectOptions | Yes | Callback used to return the result. |
| Name | Type | Mandatory | Description |
| ------- | -------------- | ---- | --------------------- |
| request | [Want](#want) | Yes | Service ability to connect.|
| options | ConnectOptions | Yes | Callback used to return the result. |
Want
**System capability**: SystemCapability.Ability.AbilityBase
| Name | Readable/Writable | Type | Mandatory| Description |
| ------------ | -------- | -------- | ---- | ---------------------------------- |
| deviceId | Read-only | string | No | Device ID of the Service ability to connect. The default value is the local device ID.|
| bundleName | Read-only | string | Yes | Bundle name of the Service ability to connect. |
| abilityName | Read-only | string | Yes | Class name of the Service ability to connect. |
| Name | Readable/Writable| Type | Mandatory | Description |
| ----------- | ---- | ------ | ---- | ---------------------------------------- |
| deviceId | Read-only | string | No | Device ID of the Service ability to connect. The default value is the local device ID.|
| bundleName | Read-only | string | Yes | Bundle name of the Service ability to connect. |
| abilityName | Read-only | string | Yes | Class name of the Service ability to connect. |
ConnectOptions
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Readable/Writable| Type | Mandatory| Description |
| ------------ | -------- | -------- | ---- | ---------------------------------- |
| onConnect | Read-only | function | Yes | Callback invoked when the connection is successful. |
| onDisconnect | Read-only | function | Yes | Callback invoked when the connection fails. |
| onFailed | Read-only | function | Yes | Callback invoked when **connectAbility** fails to be called.|
| Name | Readable/Writable| Type | Mandatory | Description |
| ------------ | ---- | -------- | ---- | ------------------------- |
| onConnect | Read-only | function | Yes | Callback invoked when the connection is successful. |
| onDisconnect | Read-only | function | Yes | Callback invoked when the connection fails. |
| onFailed | Read-only | function | Yes | Callback invoked when **connectAbility** fails to be called.|
**Return value**
| Type | Description |
| ------ | ------------------------ |
| Type | Description |
| ------ | -------------------- |
| number | Returns the ID of the Service ability connected.|
**Example**
......@@ -559,10 +559,10 @@ Disconnects this ability from a specific Service ability. This method uses a cal
**Parameters**
| Name | Type | Mandatory| Description |
| ---------- | ------------- | ---- | ------------------------------ |
| connection | number | Yes | ID of the Service ability to disconnect.|
| callback | AsyncCallback\<void> | Yes | Callback used to return the result. |
| Name | Type | Mandatory | Description |
| ---------- | -------------------- | ---- | ----------------------- |
| connection | number | Yes | ID of the Service ability to disconnect.|
| callback | AsyncCallback\<void> | Yes | Callback used to return the result. |
**Example**
......@@ -606,14 +606,14 @@ Disconnects this ability from a specific Service ability. This method uses a pro
**Parameters**
| Name | Type | Mandatory| Description |
| ---------- | ------ | ---- | ------------------------------ |
| connection | number | Yes | ID of the Service ability to disconnect.|
| Name | Type | Mandatory | Description |
| ---------- | ------ | ---- | ----------------------- |
| connection | number | Yes | ID of the Service ability to disconnect.|
**Return value**
| Type | Description |
| -------------- | ----------------------- |
| Type | Description |
| -------------- | --------------- |
| Promise\<void> | Promise used to return the result.|
**Example**
......@@ -658,16 +658,14 @@ Obtains the window corresponding to this ability. This method uses a callback to
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | ------------------------------------------------------------ |
| Name | Type | Mandatory| Description |
| -------- | ----------------------------- | ---- | ----------------------------- |
| callback | AsyncCallback\<window.Window> | Yes | Callback used to return the window.|
**Example**
```javascript
GetWindow(){
featureAbility.getWindow()
}
featureAbility.getWindow()
```
## featureAbility.getWindow<sup>7+</sup>
......@@ -680,20 +678,148 @@ Obtains the window corresponding to this ability. This method uses a promise to
**Return value**
| Type | Description |
| ----------------- | ---------------------------------------------------------- |
| Type | Description |
| ----------------------- | ----------------------------- |
| Promise\<window.Window> | Promise used to return the window.|
**Example**
```javascript
GetWindowPromise(){
featureAbility.getWindow().then((data) => {
console.info("=============getWindowPromise========== " + JSON.stringify(data));
});
}
featureAbility.getWindow().then((data) => {
console.info("=============getWindowPromise========== " + JSON.stringify(data));
});
```
## ConnectOptions.onConnect<sup>7+</sup>
onConnect(elementName: ElementName, remote: rpc.IRemoteObject): void;
Callback invoked when the connection is successful.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory | Description |
| ----------- | ----------------- | ---- | -------- |
| elementName | ElementName | Yes | Element name. |
| remote | rpc.IRemoteObject | Yes | RPC remote object.|
**Example**
```javascript
import rpc from '@ohos.rpc'
import featureAbility from '@ohos.ability.featureAbility'
function onConnectCallback(element, remote){
console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy));
}
function onDisconnectCallback(element){
console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId)
}
function onFailedCallback(code){
console.log('featureAbilityTest ConnectAbility onFailed errCode : ' + code)
}
var connId = featureAbility.connectAbility(
{
deviceId: "",
bundleName: "com.ix.ServiceAbility",
abilityName: "ServiceAbilityA",
},
{
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback,
},
);
```
## ConnectOptions.onDisconnect<sup>7+</sup>
onDisconnect(elementName: ElementName): void;
Callback invoked when the connection fails.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory | Description |
| ----------- | ----------- | ---- | ---- |
| elementName | ElementName | Yes | Element name.|
**Example**
```javascript
import rpc from '@ohos.rpc'
import featureAbility from '@ohos.ability.featureAbility'
function onConnectCallback(element, remote){
console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy));
}
function onDisconnectCallback(element){
console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId)
}
function onFailedCallback(code){
console.log('featureAbilityTest ConnectAbility onFailed errCode : ' + code)
}
var connId = featureAbility.connectAbility(
{
deviceId: "",
bundleName: "com.ix.ServiceAbility",
abilityName: "ServiceAbilityA",
},
{
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback,
},
);
```
## ConnectOptions.onFailed<sup>7+</sup>
onFailed(code: number): void;
Callback invoked when **connectAbility** fails to be called.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory | Description |
| ---- | ------ | ---- | --------- |
| code | number | Yes | Number type.|
**Example**
```javascript
import rpc from '@ohos.rpc'
import featureAbility from '@ohos.ability.featureAbility'
function onConnectCallback(element, remote){
console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy));
}
function onDisconnectCallback(element){
console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId)
}
function onFailedCallback(code){
console.log('featureAbilityTest ConnectAbility onFailed errCode : ' + code)
}
var connId = featureAbility.connectAbility(
{
deviceId: "",
bundleName: "com.ix.ServiceAbility",
abilityName: "ServiceAbilityA",
},
{
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback,
},
);
```
## AbilityWindowConfiguration
......@@ -705,13 +831,15 @@ The value is obtained through the **featureAbility.AbilityWindowConfiguration**
featureAbility.AbilityWindowConfiguration.WINDOW_MODE_UNDEFINED
```
| Name | Name| Description |
| --------------------------- | ---- | ---------- |
| WINDOW_MODE_UNDEFINED<sup>7+</sup> | 0 | The Page ability is in an undefined window display mode.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel |
| WINDOW_MODE_FULLSCREEN<sup>7+</sup> | 1 | The Page ability is in full screen mode.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel |
| WINDOW_MODE_SPLIT_PRIMARY<sup>7+</sup> | 100 | The Page ability is displayed in the primary window when it is in split-screen mode.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel|
| WINDOW_MODE_SPLIT_SECONDARY<sup>7+</sup> | 101 | The Page ability is displayed in the secondary window when it is in split-screen mode.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel|
| WINDOW_MODE_FLOATING<sup>7+</sup> | 102 | The Page ability is displayed in floating window mode.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel |
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
| Name | Name | Description |
| ---------------------------------------- | ---- | ---------------------------------------- |
| WINDOW_MODE_UNDEFINED<sup>7+</sup> | 0 | The Page ability is in an undefined window display mode.|
| WINDOW_MODE_FULLSCREEN<sup>7+</sup> | 1 | The Page ability is in full screen mode. |
| WINDOW_MODE_SPLIT_PRIMARY<sup>7+</sup> | 100 | The Page ability is displayed in the primary window when it is in split-screen mode.|
| WINDOW_MODE_SPLIT_SECONDARY<sup>7+</sup> | 101 | The Page ability is displayed in the secondary window when it is in split-screen mode.|
| WINDOW_MODE_FLOATING<sup>7+</sup> | 102 | The Page ability is displayed in floating window mode.|
## AbilityStartSetting
......@@ -726,34 +854,40 @@ The value is obtained through the **featureAbility.AbilityStartSetting** API.
featureAbility.AbilityStartSetting.BOUNDS_KEY
```
| Name | Name | Description |
| --------------- | --------------- | -------------------------- |
| BOUNDS_KEY<sup>7+</sup> | "abilityBounds" | Ability window size.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel |
| WINDOW_MODE_KEY<sup>7+</sup> | "windowMode" | Ability window display mode.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel |
| DISPLAY_ID_KEY<sup>7+</sup> | "displayId" | Display device ID.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel|
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
| Name | Name | Description |
| ---------------------------- | --------------- | ---------------------------------------- |
| BOUNDS_KEY<sup>7+</sup> | "abilityBounds" | Ability window size.|
| WINDOW_MODE_KEY<sup>7+</sup> | "windowMode" | Ability window display mode.|
| DISPLAY_ID_KEY<sup>7+</sup> | "displayId" | Display device ID.|
## ErrorCode
Enumerates error codes.
| Variable | Value | Description |
| ----------------------------- | ---- | ------------------------------------------------------------ |
| NO_ERROR<sup>7+</sup> | 0 | No error occurs.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel|
| INVALID_PARAMETER<sup>7+</sup> | -1 | Invalid parameter.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel|
| ABILITY_NOT_FOUND<sup>7+</sup> | -2 | The ability is not found.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel|
| PERMISSION_DENY<sup>7+</sup> | -3 | The request is denied.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel|
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
| Variable | Value | Description |
| ------------------------------ | ---- | ---------------------------------------- |
| NO_ERROR<sup>7+</sup> | 0 | No error occurs.|
| INVALID_PARAMETER<sup>7+</sup> | -1 | Invalid parameter.|
| ABILITY_NOT_FOUND<sup>7+</sup> | -2 | The ability is not found.|
| PERMISSION_DENY<sup>7+</sup> | -3 | The request is denied.|
## DataAbilityOperationType
Enumerates operation types of the Data ability.
| Variable | Value | Description |
| ----------------------------- | ---- | ------------------------------------------------------------ |
| TYPE_INSERT<sup>7+</sup> | 1 | Insert operation.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel|
| TYPE_UPDATE<sup>7+</sup> | 2 | Update operation.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel|
| TYPE_DELETE<sup>7+</sup> | 3 | Deletion operation.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel|
| TYPE_ASSERT<sup>7+</sup> | 4 | Assert operation.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel|
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
| Variable | Value | Description |
| ------------------------ | ---- | ---------------------------------------- |
| TYPE_INSERT<sup>7+</sup> | 1 | Insert operation.|
| TYPE_UPDATE<sup>7+</sup> | 2 | Update operation.|
| TYPE_DELETE<sup>7+</sup> | 3 | Deletion operation.|
| TYPE_ASSERT<sup>7+</sup> | 4 | Assert operation.|
......@@ -761,56 +895,58 @@ Enumerates operation types of the Data ability.
**System capability**: SystemCapability.Ability.AbilityBase
| Name | Readable/Writable| Type | Mandatory| Description |
| ---------- | -------- | --------------------- | ---- | ------------------------------------------------------------ |
| resultCode<sup>7+</sup> | Read-only | number | Yes | Result code returned after the ability is destroyed. The feature for defining error-specific result codes is coming soon.|
| want<sup>7+</sup> | Read-only | [Want](#want) | No | Data returned after the ability is destroyed. You can define the data to be returned. This parameter can be **null**. |
| Name | Readable/Writable| Type | Mandatory | Description |
| ----------------------- | ---- | ------------- | ---- | ------------------------------------- |
| resultCode<sup>7+</sup> | Read-only | number | Yes | Result code returned after the ability is destroyed. The feature for defining error-specific result codes is coming soon.|
| want<sup>7+</sup> | Read-only | [Want](#want) | No | Data returned after the ability is destroyed. You can define the data to be returned. This parameter can be **null**. |
## StartAbilityParameter
**System capability**: SystemCapability.AbilityRuntime.FAModel
| Name | Readable/Writable| Type | Mandatory| Description |
| ------------------- | -------- | -------------------- | ---- | ------------------------------------------------------------ |
| want | Read-only | [Want](#want) | Yes | Information about the ability to start. |
| abilityStartSetting | Read-only | {[key: string]: any} | No | Special attribute of the ability to start. This attribute can be passed in the method call.|
| Name | Readable/Writable| Type | Mandatory | Description |
| ------------------- | ---- | -------------------- | ---- | -------------------------------------- |
| want | Read-only | [Want](#want) | Yes | Information about the ability to start. |
| abilityStartSetting | Read-only | {[key: string]: any} | No | Special attribute of the ability to start. This attribute can be passed in the method call.|
## Want
**System capability**: SystemCapability.Ability.AbilityBase
| Name | Readable/Writable| Type | Mandatory| Description |
| ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ |
| deviceId<sup>8+</sup> | Read-only | string | No | ID of the device that runs the ability. |
| bundleName<sup>8+</sup> | Read-only | string | No | Bundle name of the ability to start. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can directly match the specified ability.|
| abilityName<sup>8+</sup> | Read-only | string | No | Name of the ability to start. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can directly match the specified ability.|
| uri<sup>8+</sup> | Read-only | string | No | URI information to match. If **uri** is specified in a **Want** object, the **Want** object will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path**.|
| type<sup>8+</sup> | Read-only | string | No | MIME type, for example, text/plain or image/*. |
| flags<sup>8+</sup> | Read-only | number | No | How the **Want** object will be handled. By default, a number is passed. For details, see [flags](#flags).|
| action<sup>8+</sup> | Read-only | string | No | Action option. |
| parameters<sup>8+</sup> | Read-only | {[key: string]: any} | No | List of parameters in a **Want** object. |
| entities<sup>8+</sup> | Read-only | Array\<string> | No | List of entities. |
| Name | Readable/Writable| Type | Mandatory| Description |
| -------------------------------- | -------- | -------------------- | ---- | ------------------------------------------------------------ |
| deviceId | Read-only | string | No | ID of the device that runs the ability. |
| bundleName | Read-only | string | No | Bundle name of the ability to start. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can directly match the specified ability.|
| abilityName | Read-only | string | No | Name of the ability to start. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can directly match the specified ability.|
| uri | Read-only | string | No | URI information to match. If **uri** is specified in a **Want** object, the **Want** object will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path**.|
| type | Read-only | string | No | MIME type, for example, text/plain or image/*. |
| flags | Read-only | number | No | How the **Want** object will be handled. By default, a number is passed. For details, see [flags](#flags).|
| action | Read-only | string | No | Action option. |
| parameters | Read-only | {[key: string]: any} | No | List of parameters in the **Want** object. |
| entities | Read-only | Array\<string> | No | List of entities. |
| extensionAbilityName<sup>9+<sup> | Read-only | string | No | Description of the Extension ability name in the **Want** object. |
| extensionAbilityType<sup>9+<sup> | Read-only | number | No | Description of the Extension ability type in the **Want** object. |
## flags
**System capability**: SystemCapability.Ability.AbilityBase
| Name | Name | Description |
| ------------------------------------ | ---------- | ------------------------------------------------------------ |
| FLAG_AUTH_READ_URI_PERMISSION | 0x00000001 | Indicates the permission to read the URI. |
| FLAG_AUTH_WRITE_URI_PERMISSION | 0x00000002 | Indicates the permission to write the URI. |
| FLAG_ABILITY_FORWARD_RESULT | 0x00000004 | Returns the result to the ability. |
| FLAG_ABILITY_CONTINUATION | 0x00000008 | Indicates whether the ability on the local device can be migrated to a remote device. |
| FLAG_NOT_OHOS_COMPONENT | 0x00000010 | Indicates that a component does not belong to OHOS. |
| FLAG_ABILITY_FORM_ENABLED | 0x00000020 | Indicates whether to enable an ability. |
| FLAG_AUTH_PERSISTABLE_URI_PERMISSION | 0x00000040 | Indicates the permission to make the URI persistent. |
| FLAG_AUTH_PREFIX_URI_PERMISSION | 0x00000080 | Indicates the permission to verify URIs by prefix matching. |
| FLAG_ABILITYSLICE_MULTI_DEVICE | 0x00000100 | Supports cross-device startup in a distributed scheduler. |
| FLAG_START_FOREGROUND_ABILITY | 0x00000200 | Indicates that the Service ability is started regardless of whether the host application has been started. |
| FLAG_ABILITY_CONTINUATION_REVERSIBLE | 0x00000400 | Indicates that the migration is reversible. |
| FLAG_INSTALL_ON_DEMAND | 0x00000800 | Indicates that the specific ability will be installed if it has not been installed. |
| FLAG_INSTALL_WITH_BACKGROUND_MODE | 0x80000000 | Indicates that the specific ability will be installed in the background if it has not been installed. |
| FLAG_ABILITY_CLEAR_MISSION | 0x00008000 | Clears other operation missions. This flag can be set for the **Want** object passed to **ohos.app.Context#startAbility** and must be used together with **flag_ABILITY_NEW_MISSION**.|
| FLAG_ABILITY_NEW_MISSION | 0x10000000 | Creates a mission on the historical mission stack. |
| Name | Name | Description |
| ------------------------------------ | ---------- | ---------------------------------------- |
| FLAG_AUTH_READ_URI_PERMISSION | 0x00000001 | Indicates the permission to read the URI. |
| FLAG_AUTH_WRITE_URI_PERMISSION | 0x00000002 | Indicates the permission to write the URI. |
| FLAG_ABILITY_FORWARD_RESULT | 0x00000004 | Returns the result to the ability. |
| FLAG_ABILITY_CONTINUATION | 0x00000008 | Indicates whether the ability on the local device can be migrated to a remote device. |
| FLAG_NOT_OHOS_COMPONENT | 0x00000010 | Indicates that a component does not belong to OHOS. |
| FLAG_ABILITY_FORM_ENABLED | 0x00000020 | Indicates whether to enable an ability. |
| FLAG_AUTH_PERSISTABLE_URI_PERMISSION | 0x00000040 | Indicates the permission to make the URI persistent. |
| FLAG_AUTH_PREFIX_URI_PERMISSION | 0x00000080 | Indicates the permission to verify URIs by prefix matching. |
| FLAG_ABILITYSLICE_MULTI_DEVICE | 0x00000100 | Supports cross-device startup in a distributed scheduler. |
| FLAG_START_FOREGROUND_ABILITY | 0x00000200 | Indicates that the Service ability is started regardless of whether the host application has been started. |
| FLAG_ABILITY_CONTINUATION_REVERSIBLE | 0x00000400 | Indicates that the migration is reversible. |
| FLAG_INSTALL_ON_DEMAND | 0x00000800 | Indicates that the specific ability will be installed if it has not been installed. |
| FLAG_INSTALL_WITH_BACKGROUND_MODE | 0x80000000 | Indicates that the specific ability will be installed in the background if it has not been installed. |
| FLAG_ABILITY_CLEAR_MISSION | 0x00008000 | Clears other operation missions. This flag can be set for the **Want** object in the **startAbility** API passed to [ohos.app.Context](js-apis-ability-context.md) and must be used together with **flag_ABILITY_NEW_MISSION**.|
| FLAG_ABILITY_NEW_MISSION | 0x10000000 | Creates a mission on the historical mission stack. |
| FLAG_ABILITY_MISSION_TOP | 0x20000000 | Starts the mission on the top of the existing mission stack; creates an ability instance if no mission exists.|
......@@ -25,7 +25,7 @@ Creates a **FormBindingData** object.
| Name| Type | Mandatory| Description |
| ------ | -------------- | ---- | ------------------------------------------------------------ |
| obj | Object or string| No | Data to be displayed on the JS service widget. The value can be an object containing multiple key-value pairs or a string in JSON format.|
| obj | Object or string| No | Data to be displayed on the JS service widget. The value can be an object containing multiple key-value pairs or a string in JSON format. The image data is identified by "formImages", and the content is multiple key-value pairs, each of which consists of an image identifier and image file descriptor. The final format is {"formImages": {"key1": fd1, "key2": fd2}}.|
**Return value**
......@@ -38,20 +38,20 @@ Creates a **FormBindingData** object.
**Example**
```js
let obj = {"temperature": "21°"};
let fd = fileio.openSync(path);
let obj = {
"temperature": "21°",
"formImages": {"image": fd}
};
let formBindingDataObj = formBindingData.createFormBindingData(obj);
```
## formBindingData.FormBindingData
data: Object
## Attributes
Describes a **FormBindingData** object.
**System capability**: SystemCapability.Ability.Form
**Parameters**
| Name| Type | Description |
| ---- | -------------- | ------------------------------------------------------------ |
| data | Object or string| Data to be displayed on the JS service widget. The value can be an object containing multiple key-value pairs or a string in JSON format.|
| Name| Readable| Writable| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | -------- | -------- |
| data | Yes| No| Object | Yes| Data to be displayed on the JS service widget. The value can be an object containing multiple key-value pairs or a string in JSON format.|
......@@ -17,7 +17,7 @@ import particleAbility from '@ohos.ability.particleAbility'
startAbility(parameter: StartAbilityParameter, callback: AsyncCallback\<void>): void
Starts a particle ability. This API uses an asynchronous callback to return the result.
Starts a Particle ability. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
......@@ -58,9 +58,9 @@ particleAbility.startAbility(
## particleAbility.startAbility
startAbility(parameter: StartAbilityParameter): Promise<void>;
startAbility(parameter: StartAbilityParameter): Promise\<void>;
Starts a particle ability. This API uses a promise to return the result.
Starts a Particle ability. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
......@@ -107,7 +107,7 @@ particleAbility.startAbility(
terminateSelf(callback: AsyncCallback\<void>): void
Terminates this particle ability. This API uses an asynchronous callback to return the result.
Terminates this Particle ability. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
......@@ -134,7 +134,7 @@ particleAbility.terminateSelf(
terminateSelf(): Promise\<void>
Terminates this particle ability. This API uses a promise to return the result.
Terminates this Particle ability. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
......@@ -188,7 +188,9 @@ particleAbility.acquireDataAbilityHelper(uri)
startBackgroundRunning(id: number, request: NotificationRequest, callback: AsyncCallback&lt;void&gt;): void;
Requests a continuous task from the system. This API uses an asynchronous callback to return the result. (This method is of API 7 and will be deprecated. Use the counterpart in API 8.)
Requests a continuous task from the system. This API uses an asynchronous callback to return the result. You are advised to use the new API [backgroundTaskManager.startBackgroundRunning](js-apis-backgroundTaskManager.md#backgroundtaskmanagerstartbackgroundrunning8).
**Required permissions**: ohos.permission.KEEP_BACKGROUND_RUNNING
**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
......@@ -250,9 +252,11 @@ wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
startBackgroundRunning(id: number, request: NotificationRequest): Promise&lt;void&gt;
**Required permissions**: ohos.permission.KEEP_BACKGROUND_RUNNING
**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
Requests a continuous task from the system. This API uses a promise to return the result. (This method is of API 7 and will be deprecated. Use the counterpart in API 8.)
Requests a continuous task from the system. This API uses a promise to return the result. You are advised to use the new API [backgroundTaskManager.startBackgroundRunning](js-apis-backgroundTaskManager.md#backgroundtaskmanagerstartbackgroundrunning8-1).
**Parameters**
......@@ -313,7 +317,7 @@ wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
cancelBackgroundRunning(callback: AsyncCallback&lt;void&gt;): void;
Requests to cancel a continuous task from the system. This API uses an asynchronous callback to return the result. (This method is of API 7 and will be deprecated. Use the counterpart in API 8.)
Requests to cancel a continuous task from the system. This API uses an asynchronous callback to return the result. You are advised to use the new API [backgroundTaskManager.stopBackgroundRunning](js-apis-backgroundTaskManager.md#backgroundtaskmanagerstopbackgroundrunning8).
**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
......@@ -344,7 +348,7 @@ particleAbility.cancelBackgroundRunning(callback);
cancelBackgroundRunning(): Promise&lt;void&gt;;
Requests to cancel a continuous task from the system. This API uses a promise to return the result. (This method is of API 7 and will be deprecated. Use the counterpart in API 8.)
Requests a continuous task from the system. This API uses a promise to return the result. You are advised to use the new API [backgroundTaskManager.stopBackgroundRunning](js-apis-backgroundTaskManager.md#backgroundtaskmanagerstopbackgroundrunning8-1).
**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
......@@ -383,6 +387,17 @@ Connects this ability to a specific Service ability. This API uses a callback to
| request | [Want](#want) | Yes | Service ability to connect.|
| options | ConnectOptions | Yes | Callback used to return the result. |
ConnectOptions
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Readable/Writable| Type | Mandatory | Description |
| ------------ | ---- | -------- | ---- | ------------------------- |
| onConnect | Read only | function | Yes | Callback invoked when the connection is successful. |
| onDisconnect | Read only | function | Yes | Callback invoked when the connection fails. |
| onFailed | Read only | function | Yes | Callback invoked when **connectAbility** fails to be called.|
**Example**
```js
......@@ -509,11 +524,8 @@ function onConnectCallback(element, remote){
Enumerates error codes.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
| Name | Value | Description |
| ----------------------------- | ---- | ------------------------------------------------------------ |
| INVALID_PARAMETER | -1 | Invalid parameter.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel|
| INVALID_PARAMETER | -1 | Invalid parameter.|
# UriPermissionManager
# uriPermissionManager
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> 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 version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Implements URI permission management.
......@@ -11,11 +11,11 @@ Implements URI permission management.
```
import UriPermissionManager from '@@ohos.application.UriPermissionManager';
import uriPermissionManager from '@ohos.application.uriPermissionManager';
```
## verifyUriPermission
## uriPermissionManager.verifyUriPermission
verifyUriPermission(uri: string, flag: wantConstant.Flags, accessTokenId: number, callback: AsyncCallback&lt;number&gt;): void
......@@ -25,15 +25,16 @@ Checks whether an application has the permission specified by **flag** for an UR
SystemCapability.Ability.AbilityRuntime.Core
- Parameters
| Name| Type| Mandatory| Description|
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| 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.|
| 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.|
- Example
**Example**
```
let uri = "fileshare:///com.samples.filesharetest.FileShare/person/10"
......@@ -43,7 +44,7 @@ SystemCapability.Ability.AbilityRuntime.Core
```
## verifyUriPermission
## uriPermissionManager.verifyUriPermission
verifyUriPermission(uri: string, flag: wantConstant.Flags, accessTokenId: number): Promise&lt;number&gt;
......@@ -53,19 +54,21 @@ Checks whether an application has the permission specified by **flag** for an UR
SystemCapability.Ability.AbilityRuntime.Core
- Parameters
| Name| Type| Mandatory| Description|
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| 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.|
| accessTokenId | number | Yes| Unique ID of an application, which is obtained through the **BundleManager** API.|
- Return value
| Type| Description|
**Return value**
| 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.|
- Example
**Example**
```
let uri = "fileshare:///com.samples.filesharetest.FileShare/person/10"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册