“90648f336d0a73630d0a862259a4f73ab3c9fe8c”上不存在“paddle/fluid/operators/math/lapack_function.h”
提交 98b1384c 编写于 作者: L lijialang

Merge branch 'master' of gitee.com:lijialang/docs

...@@ -123,7 +123,7 @@ Unsubscribes from the device status. ...@@ -123,7 +123,7 @@ Unsubscribes from the device status.
| -------------------- | -------------------------------------------------- | ---- | ---------------------------- | | -------------------- | -------------------------------------------------- | ---- | ---------------------------- |
| activity | [ActivityType](#activitytype) | Yes | Device status type. | | activity | [ActivityType](#activitytype) | Yes | Device status type. |
| event | [ActivityEvent](#activityevent) | Yes | Event type. | | event | [ActivityEvent](#activityevent) | Yes | Event type. |
| callback | Callback<[ActivityResponse](#activityresponse)\> | No | Callback used to receive reported data. | | callback | Callback<[ActivityResponse](#activityresponse)\> | No | Callback used to receive reported data, if the callback parameter is not passed, all callbacks subscribed to this type under this process will be removed. |
**Example** **Example**
......
...@@ -209,8 +209,8 @@ Removes the permission for the application to access a USB device. ...@@ -209,8 +209,8 @@ Removes the permission for the application to access a USB device.
**Example** **Example**
```js ```js
let devicesName="1-1"; let devicesName= "1-1";
if usb.removeRight(devicesName) { if (usb.removeRight(devicesName)) {
console.log(`Succeed in removing right`); console.log(`Succeed in removing right`);
} }
``` ```
...@@ -245,7 +245,7 @@ Adds the permission for the application to access a USB device. ...@@ -245,7 +245,7 @@ Adds the permission for the application to access a USB device.
```js ```js
let devicesName = "1-1"; let devicesName = "1-1";
let bundleName = "com.example.hello"; let bundleName = "com.example.hello";
if usb.addRight(bundleName, devicesName) { if (usb.addRight(bundleName, devicesName)) {
console.log(`Succeed in adding right`); console.log(`Succeed in adding right`);
} }
``` ```
...@@ -454,7 +454,14 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ...@@ -454,7 +454,14 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**Example** **Example**
```js ```js
let param = new usb.USBControlParams(); let param = {
request: 0,
reqType: 0,
target:0,
value: 0,
index: 0,
data: null
};
usb.controlTransfer(devicepipe, param).then((ret) => { usb.controlTransfer(devicepipe, param).then((ret) => {
console.log(`controlTransfer = ${ret}`); console.log(`controlTransfer = ${ret}`);
}) })
...@@ -579,7 +586,7 @@ Converts the USB function list in the numeric mask format to a string in Device ...@@ -579,7 +586,7 @@ Converts the USB function list in the numeric mask format to a string in Device
**Example** **Example**
```js ```js
let funcs = usb.ACM | usb.ECM; let funcs = usb.FunctionType.ACM | usb.FunctionType.ECM;
let ret = usb.usbFunctionsToString(funcs); let ret = usb.usbFunctionsToString(funcs);
``` ```
...@@ -608,7 +615,7 @@ Sets the current USB function list in Device mode. ...@@ -608,7 +615,7 @@ Sets the current USB function list in Device mode.
**Example** **Example**
```js ```js
let funcs = usb.HDC; let funcs = usb.FunctionType.HDC;
usb.setCurrentFunctions(funcs).then(() => { usb.setCurrentFunctions(funcs).then(() => {
console.info('usb setCurrentFunctions successfully.'); console.info('usb setCurrentFunctions successfully.');
}).catch(err => { }).catch(err => {
......
# app.js # app.js
## Application Lifecycle<sup>4+</sup>
You can implement lifecycle logic specific to your application in the **app.js** file. Available application lifecycle functions are as follows: You can implement lifecycle logic specific to your application in the **app.js** file. Available application lifecycle functions are as follows:
...@@ -11,7 +12,9 @@ You can implement lifecycle logic specific to your application in the **app.js** ...@@ -11,7 +12,9 @@ You can implement lifecycle logic specific to your application in the **app.js**
In the following example, logs are printed only in the lifecycle functions. In the following example, logs are printed only in the lifecycle functions.
```
```js
// app.js // app.js
export default { export default {
onCreate() { onCreate() {
...@@ -22,3 +25,63 @@ export default { ...@@ -22,3 +25,63 @@ export default {
}, },
} }
``` ```
## Application Object<sup>10+</sup>
| Attribute | Type | Description |
| ------ | -------- | ---------------------------------------- |
| getApp | Function | Obtains the data object exposed in **app.js** from the page JS file. This API works globally.|
> **NOTE**
>
> The application object is global data and occupies JS memory before the application exits. Although it facilitates data sharing between different pages, exercise caution when using it on small-system devices, whose memory is small. If they are overused, exceptions may occur due to insufficient memory when the application displays complex pages.
The following is an example:
Declare the application object in **app.js**.
```javascript
// app.js
export default {
data: {
test: "by getAPP"
},
onCreate() {
console.info('Application onCreate');
},
onDestroy() {
console.info('Application onDestroy');
},
};
```
Access the application object on a specific page.
```javascript
// index.js
export default {
data: {
title: ""
},
onInit() {
if (typeof getApp !== 'undefined') {
var appData = getApp().data;
if (typeof appData !== 'undefined') {
this.title = appData.name; // read from app data
}
}
},
clickHandler() {
if (typeof getApp !== 'undefined') {
var appData = getApp().data;
if (typeof appData !== 'undefined') {
appData.name = this.title; // write to app data
}
}
}
}
```
> **NOTE**
>
> To ensure that the application can run properly on an earlier version that does not support **getApp**, compatibility processing must be performed in the code. That is, before using **getApp**, check whether it is available.
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
**Lottie** allows you to implement animation-specific operations. **Lottie** allows you to implement animation-specific operations.
> **NOTE** > **NOTE**
> >
> The APIs of this module are supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. > The APIs of this module are supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version.
...@@ -16,9 +16,7 @@ import lottie from '@ohos/lottieETS' ...@@ -16,9 +16,7 @@ import lottie from '@ohos/lottieETS'
> **NOTE** > **NOTE**
> >
> In the **Terminal** window, run the `npm install @ohos/lottieETS` command to download Lottie. The download requires the related permission. > To use **Lottie**, download it first by running the **ohpm install @ohos/lottieETS** command in the Terminal window.
>
> To install an OpenHarmony npm third-party package, run the `npm config set @ohos:registry=https://repo.harmonyos.com/npm/` command to set the repository address.
## lottie.loadAnimation ## lottie.loadAnimation
...@@ -31,15 +29,15 @@ Loads an animation. Before calling this API, declare the **Animator('__lottie_et ...@@ -31,15 +29,15 @@ Loads an animation. Before calling this API, declare the **Animator('__lottie_et
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| -------------- | --------------------------- | ---- | ------------------------------------------------------------ | | -------------- | --------------------------- | ---- | ---------------------------------------- |
| path | string | Yes | Path of the animation resource file in the HAP file. The resource file must be in JSON format. Example: **path: "common/lottie/data.json"**| | path | string | Yes | Path of the animation resource file in the HAP file. The resource file must be in JSON format. Example: **path: "common/lottie/data.json"**|
| container | object | Yes | Canvas drawing context. A **CanvasRenderingContext2D** object must be declared in advance.| | container | object | Yes | Canvas drawing context. A **CanvasRenderingContext2D** object must be declared in advance.|
| render | string | Yes | Rendering type. The value can only be **"canvas"**. | | render | string | Yes | Rendering type. The value can only be **"canvas"**. |
| loop | boolean \| number | No | If the value is of the Boolean type, this parameter indicates whether to repeat the animation cyclically after the animation ends; the default value is **true**. If the value is of the number type and is greater than or equal to 1, this parameter indicates the number of times the animation plays.| | loop | boolean \| number | No | If the value is of the Boolean type, this parameter indicates whether to repeat the animation cyclically after the animation ends. If the value is of the number type and is greater than or equal to 1, this parameter indicates the number of times the animation plays.<br>Default value: **true**|
| autoplay | boolean | No | Whether to automatically play the animation.<br>Default value: **true** | | autoplay | boolean | No | Whether to automatically play the animation<br>Default value: **true** |
| name | string | No | Custom animation name. In later versions, the name can be used to reference and control the animation.<br/>Default value: null | | name | string | No | Custom animation name. In later versions, the name can be used to reference and control the animation. <br>Default value: **""** |
| initialSegment | [number, number] | No | Start frame and end frame of the animation, respectively. | | initialSegment | [number, number] | No | Start frame and end frame of the animation, respectively. |
## lottie.destroy ## lottie.destroy
...@@ -52,10 +50,9 @@ Destroys the animation. This API must be called when a page exits. This API can ...@@ -52,10 +50,9 @@ Destroys the animation. This API must be called when a page exits. This API can
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ---------------------------------------- | | ---- | ------ | ---- | ---------------------------------------- |
| name | string | Yes | Name of the animation to destroy, which is the same as the **name** in the **loadAnimation** API. By default, all animations are destroyed. | | name | string | Yes | Name of the animation to destroy, which is the same as the **name** in the **loadAnimation** API. By default, all animations are destroyed.|
**Example** **Example**
```ts ```ts
// xxx.ets // xxx.ets
import lottie from '@ohos/lottieETS' import lottie from '@ohos/lottieETS'
...@@ -134,7 +131,7 @@ Plays a specified animation. ...@@ -134,7 +131,7 @@ Plays a specified animation.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ---------------------------------------- | | ---- | ------ | ---- | ---------------------------------------- |
| name | string | Yes | Name of the animation to play, which is the same as the **name** in the **loadAnimation** API. By default, all animations are played. | | name | string | Yes | Name of the animation to play, which is the same as the **name** in the **loadAnimation** API. By default, all animations are played.|
**Example** **Example**
...@@ -153,7 +150,7 @@ Pauses a specified animation. The next time **lottie.play()** is called, the ani ...@@ -153,7 +150,7 @@ Pauses a specified animation. The next time **lottie.play()** is called, the ani
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ---------------------------------------- | | ---- | ------ | ---- | ---------------------------------------- |
| name | string | Yes | Name of the animation to pause, which is the same as the **name** in the **loadAnimation** API. By default, all animations are paused. | | name | string | Yes | Name of the animation to pause, which is the same as the **name** in the **loadAnimation** API. By default, all animations are paused.|
**Example** **Example**
...@@ -172,7 +169,7 @@ Pauses or plays a specified animation. This API is equivalent to the switching b ...@@ -172,7 +169,7 @@ Pauses or plays a specified animation. This API is equivalent to the switching b
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ---------------------------------------- | | ---- | ------ | ---- | ---------------------------------------- |
| name | string | Yes | Name of the target animation, which is the same as the **name** in the **loadAnimation** API. By default, all animations are paused or played. | | name | string | Yes | Name of the target animation, which is the same as the **name** in the **loadAnimation** API. By default, all animations are paused or played.|
**Example** **Example**
...@@ -191,7 +188,7 @@ Stops the specified animation. The next time **lottie.play()** is called, the an ...@@ -191,7 +188,7 @@ Stops the specified animation. The next time **lottie.play()** is called, the an
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ---------------------------------------- | | ---- | ------ | ---- | ---------------------------------------- |
| name | string | Yes | Name of the target animation, which is the same as the **name** in the **loadAnimation** API. By default, all animations are stopped. | | name | string | Yes | Name of the target animation, which is the same as the **name** in the **loadAnimation** API. By default, all animations are stopped.|
**Example** **Example**
...@@ -210,8 +207,8 @@ Sets the playback speed of the specified animation. ...@@ -210,8 +207,8 @@ Sets the playback speed of the specified animation.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ----- | ------ | ---- | ---------------------------------------- | | ----- | ------ | ---- | ---------------------------------------- |
| speed | number | Yes | Playback speed. The value is a floating-point number. If the value is greater than 0, the animation plays in forward direction. If the value is less than 0, the animation plays in reversed direction. If the value is **0**, the animation is paused. If the value is **1.0** or **-1.0**, the animation plays at the normal speed. | | speed | number | Yes | Playback speed. The value is a floating-point number. If the value is greater than 0, the animation plays in forward direction. If the value is less than 0, the animation plays in reversed direction. If the value is **0**, the animation is paused. If the value is **1.0** or **-1.0**, the animation plays at the normal speed.|
| name | string | Yes | Name of the target animation, which is the same as the **name** in the **loadAnimation** API. By default, all animations are set. | | name | string | Yes | Name of the target animation, which is the same as the **name** in the **loadAnimation** API. By default, all animations are set.|
**Example** **Example**
...@@ -231,7 +228,7 @@ Sets the direction in which the specified animation plays. ...@@ -231,7 +228,7 @@ Sets the direction in which the specified animation plays.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| --------- | ------------------ | ---- | ---------------------------------------- | | --------- | ------------------ | ---- | ---------------------------------------- |
| direction | AnimationDirection | Yes | Direction in which the animation plays. **1**: forwards; **-1**: backwards. When set to play backwards, the animation plays from the current playback progress to the first frame. When this setting is combined with **loop** being set to **true**, the animation plays backwards continuously. When the value of **speed** is less than 0, the animation also plays backwards.<br>AnimationDirection: 1 \| -1 | | direction | AnimationDirection | Yes | Direction in which the animation plays. **1**: forwards; **-1**: backwards. When set to play backwards, the animation plays from the current playback progress to the first frame. When this setting is combined with **loop** being set to **true**, the animation plays backwards continuously. When the value of **speed** is less than 0, the animation also plays backwards.<br>AnimationDirection: 1 \| -1 |
| name | string | Yes | Name of the target animation, which is the same as the **name** in the **loadAnimation** API. By default, all animations are set. | | name | string | Yes | Name of the target animation, which is the same as the **name** in the **loadAnimation** API. By default, all animations are set.|
**Example** **Example**
...@@ -254,18 +251,18 @@ Defines an **AnimationItem** object, which is returned by the **loadAnimation** ...@@ -254,18 +251,18 @@ Defines an **AnimationItem** object, which is returned by the **loadAnimation**
| totalFrames | number | Total number of frames in the animation segment that is being played. | | totalFrames | number | Total number of frames in the animation segment that is being played. |
| frameRate | number | Frame rate (frame/s). | | frameRate | number | Frame rate (frame/s). |
| frameMult | number | Frame rate (frame/ms). | | frameMult | number | Frame rate (frame/ms). |
| playSpeed | number | Playback speed. The value is a floating-point number. If the value is greater than 0, the animation plays forward. If the value is less than 0, the animation plays backward. If the value is **0**, the animation is paused. If the value is **1.0** or **-1.0**, the animation plays at the normal speed. | | playSpeed | number | Playback speed. The value is a floating-point number. If the value is greater than 0, the animation plays forward. If the value is less than 0, the animation plays backward. If the value is **0**, the animation is paused. If the value is **1.0** or **-1.0**, the animation plays at the normal speed.|
| playDirection | number | Playback direction.<br>**1**: forward.<br/>**-1**: backward. | | playDirection | number | Playback direction.<br>**1**: forward.<br/>**-1**: backward. |
| playCount | number | Number of times the animation plays. | | playCount | number | Number of times the animation plays. |
| isPaused | boolean | Whether the current animation is paused. The value **true** means that the animation is paused. | | isPaused | boolean | Whether the current animation is paused. The value **true** means that the animation is paused. |
| autoplay | boolean | Whether to automatically play the animation upon completion of the loading. The value **false** means that the **play()** API needs to be called to start playing. | | autoplay | boolean | Whether to automatically play the animation upon completion of the loading. The value **false** means that the **play()** API needs to be called to start playing.|
| loop | boolean \| number | If the value is of the Boolean type, this parameter indicates whether to repeat the animation cyclically after the animation ends. If the value is of the number type and is greater than or equal to 1, this parameter indicates the number of times the animation plays. | | loop | boolean \| number | If the value is of the Boolean type, this parameter indicates whether to repeat the animation cyclically after the animation ends. If the value is of the number type and is greater than or equal to 1, this parameter indicates the number of times the animation plays. |
| renderer | any | Animation rendering object, which depends on the rendering type. | | renderer | any | Animation rendering object, which depends on the rendering type. |
| animationID | string | Animation ID. | | animationID | string | Animation ID. |
| timeCompleted | number | Number of frames that are played for an animation sequence. The value is affected by the setting of **AnimationSegment** and is the same as the value of **totalFrames**.| | timeCompleted | number | Number of frames that are played for an animation sequence. The value is affected by the setting of **AnimationSegment** and is the same as the value of **totalFrames**.|
| segmentPos | number | ID of the current animation segment. The value is a positive integer greater than or equal to 0. | | segmentPos | number | ID of the current animation segment. The value is a positive integer greater than or equal to 0. |
| isSubframeEnabled | boolean | Whether the precision of **currentFrame** is a floating point number. | | isSubframeEnabled | boolean | Whether the precision of **currentFrame** is a floating point number. |
| segments | AnimationSegment \| AnimationSegment[] | Current segment of the animation. | | segments | AnimationSegment \| AnimationSegment[] | Current segment of the animation. |
## AnimationItem.play ## AnimationItem.play
...@@ -278,7 +275,7 @@ Plays an animation. ...@@ -278,7 +275,7 @@ Plays an animation.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---- | ------ | ---- | --------------- | | ---- | ------ | ---- | --------------- |
| name | string | No | Name of the target animation. By default, the value is null.| | name | string | No | Name of the target animation.<br>Default value: **""** |
**Example** **Example**
...@@ -373,7 +370,7 @@ Sets the playback speed of an animation. ...@@ -373,7 +370,7 @@ Sets the playback speed of an animation.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ----- | ------ | ---- | ---------------------------------------- | | ----- | ------ | ---- | ---------------------------------------- |
| speed | number | Yes | Playback speed. The value is a floating-point number. If the value is greater than 0, the animation plays forward. If the value is less than 0, the animation plays backward. If the value is **0**, the animation is paused. If the value is **1.0** or **-1.0**, the animation plays at the normal speed. | | speed | number | Yes | Playback speed. The value is a floating-point number. If the value is greater than 0, the animation plays forward. If the value is less than 0, the animation plays backward. If the value is 0, the animation is paused. If the value is **1.0** or **-1.0**, the animation plays at the normal speed.|
**Example** **Example**
...@@ -412,8 +409,8 @@ Sets the animation to stop at the specified frame or time. ...@@ -412,8 +409,8 @@ Sets the animation to stop at the specified frame or time.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------- | ---- | ---------------------------------------- | | ------- | ------- | ---- | ---------------------------------------- |
| value | number | Yes | Frame ID (greater than or equal to 0) or time progress (ms) at which the animation will stop. | | value | number | Yes | Frame ID (greater than or equal to 0) or time progress (ms) at which the animation will stop. |
| isFrame | boolean | No | Whether to set the animation to stop at the specified frame. The value **true** means to set the animation to stop at the specified frame, and **false** means to set the animation to stop at the specified time progress.<br/>Default value: **false** | | isFrame | boolean | No | Whether to set the animation to stop at the specified frame. The value **true** means to set the animation to stop at the specified frame, and **false** means to set the animation to stop at the specified time progress.<br>Default value: **false**|
| name | string | No | Name of the target animation. By default, the value is null. | | name | string | No | Name of the target animation. By default, the value is null. |
**Example** **Example**
...@@ -436,8 +433,8 @@ Sets the animation to start from the specified frame or time progress. ...@@ -436,8 +433,8 @@ Sets the animation to start from the specified frame or time progress.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------- | ---- | ---------------------------------------- | | ------- | ------- | ---- | ---------------------------------------- |
| value | number | Yes | Frame ID (greater than or equal to 0) or time progress (ms) at which the animation will start. | | value | number | Yes | Frame ID (greater than or equal to 0) or time progress (ms) at which the animation will start. |
| isFrame | boolean | Yes | Whether to set the animation to start from the specified frame. The value **true** means to set the animation to start from the specified frame, and **false** means to set the animation to start from the specified time progress.<br/>Default value: **false** | | isFrame | boolean | Yes | Whether to set the animation to start from the specified frame. The value **true** means to set the animation to start from the specified frame, and **false** means to set the animation to start from the specified time progress.<br>Default value: **false**|
| name | string | No | Name of the target animation.<br/>Default value: null | | name | string | No | Name of the target animation.<br>Default value: **""** |
**Example** **Example**
...@@ -460,7 +457,7 @@ Sets the animation to play only the specified segment. ...@@ -460,7 +457,7 @@ Sets the animation to play only the specified segment.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | ---------------------------------------- | | --------- | ---------------------------------------- | ---- | ---------------------------------------- |
| segments | AnimationSegment = [number, number] \| AnimationSegment[] | Yes | Segment or segment list.<br>If all segments in the segment list are played, only the last segment is played in the next cycle.| | segments | AnimationSegment = [number, number] \| AnimationSegment[] | Yes | Segment or segment list.<br>If all segments in the segment list are played, only the last segment is played in the next cycle.|
| forceFlag | boolean | Yes | Whether the settings take effect immediately. The value **true** means the settings take effect immediately, and **false** means the settings take effect until the current cycle of playback is completed. | | forceFlag | boolean | Yes | Whether the settings take effect immediately. The value **true** means the settings take effect immediately, and **false** means the settings take effect until the current cycle of playback is completed. |
**Example** **Example**
...@@ -533,7 +530,7 @@ Obtains the duration (irrelevant to the playback speed) or number of frames for ...@@ -533,7 +530,7 @@ Obtains the duration (irrelevant to the playback speed) or number of frames for
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ------- | ---- | ---------------------------------------- | | -------- | ------- | ---- | ---------------------------------------- |
| inFrames | boolean | No | Whether to obtain the duration or number of frames.<br>**true**: number of frames.<br>**false**: duration, in ms.<br/>Default value: **false** | | inFrames | boolean | No | Whether to obtain the duration or number of frames.<br>**true**: number of frames.<br>**false**: duration, in ms.<br>Default value: **false**|
**Example** **Example**
...@@ -579,7 +576,7 @@ Removes an event listener. ...@@ -579,7 +576,7 @@ Removes an event listener.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------------- | ---- | ---------------------------------------- | | -------- | ------------------------------- | ---- | ---------------------------------------- |
| name | AnimationEventName | Yes | Animation event type. The available options are as follows:<br>'enterFrame', 'loopComplete', 'complete', 'segmentStart', 'destroy', 'config_ready', 'data_ready', 'DOMLoaded', 'error', 'data_failed', 'loaded_images'| | name | AnimationEventName | Yes | Animation event type. The available options are as follows:<br>'enterFrame', 'loopComplete', 'complete', 'segmentStart', 'destroy', 'config_ready', 'data_ready', 'DOMLoaded', 'error', 'data_failed', 'loaded_images'|
| callback | AnimationEventCallback&lt;T&gt; | No | Custom callback. By default, the value is null, meaning that all callbacks of the event will be removed. | | callback | AnimationEventCallback&lt;T&gt; | No | Custom callback. By default, the value is null, meaning that all callbacks of the event will be removed. |
**Example** **Example**
......
...@@ -63,8 +63,8 @@ ...@@ -63,8 +63,8 @@
- [跨端迁移(仅对系统应用开放)](hop-cross-device-migration.md) - [跨端迁移(仅对系统应用开放)](hop-cross-device-migration.md)
- [多端协同(仅对系统应用开放)](hop-multi-device-collaboration.md) - [多端协同(仅对系统应用开放)](hop-multi-device-collaboration.md)
- [订阅系统环境变量的变化](subscribe-system-environment-variable-changes.md) - [订阅系统环境变量的变化](subscribe-system-environment-variable-changes.md)
- 进程间通信 - 了解进程模型
- [进程模型](process-model-stage.md) - [进程模型概述](process-model-stage.md)
- 公共事件 - 公共事件
- [公共事件简介](common-event-overview.md) - [公共事件简介](common-event-overview.md)
- 公共事件订阅 - 公共事件订阅
...@@ -75,8 +75,8 @@ ...@@ -75,8 +75,8 @@
- [公共事件发布](common-event-publish.md) - [公共事件发布](common-event-publish.md)
- [移除粘性公共事件](common-event-remove-sticky.md) - [移除粘性公共事件](common-event-remove-sticky.md)
- [后台服务](background-services.md) - [后台服务](background-services.md)
- 线程间通信 - 了解线程模型
- [线程模型](thread-model-stage.md) - [线程模型概述](thread-model-stage.md)
- [使用Emitter进行线程间通信](itc-with-emitter.md) - [使用Emitter进行线程间通信](itc-with-emitter.md)
- [使用Worker进行线程间通信](itc-with-worker.md) - [使用Worker进行线程间通信](itc-with-worker.md)
- 任务管理 - 任务管理
...@@ -121,12 +121,12 @@ ...@@ -121,12 +121,12 @@
- [FA模型的Context](application-context-fa.md) - [FA模型的Context](application-context-fa.md)
- [信息传递载体Want](want-fa.md) - [信息传递载体Want](want-fa.md)
- [组件启动规则(FA模型)](component-startup-rules-fa.md) - [组件启动规则(FA模型)](component-startup-rules-fa.md)
- 进程间通信 - 了解进程模型
- [进程模型](process-model-fa.md) - [进程模型概述](process-model-fa.md)
- [公共事件](common-event-fa.md) - [公共事件](common-event-fa.md)
- [后台服务](rpc.md) - [后台服务](rpc.md)
- 线程间通信 - 了解线程模型
- [线程模型](thread-model-fa.md) - [线程模型概述](thread-model-fa.md)
- [线程间通信](itc-fa-overview.md) - [线程间通信](itc-fa-overview.md)
- [任务管理](mission-management-fa.md) - [任务管理](mission-management-fa.md)
- [FA模型应用配置文件](config-file-fa.md) - [FA模型应用配置文件](config-file-fa.md)
......
...@@ -35,7 +35,7 @@ AccessibilityExtensionAbility为无障碍扩展服务框架,允许三方开发 ...@@ -35,7 +35,7 @@ AccessibilityExtensionAbility为无障碍扩展服务框架,允许三方开发
## 如何创建一个无障碍扩展服务 ## 如何创建一个无障碍扩展服务
开发者在创建一个无障碍扩展服务时,如工程满足环境要求,开发者可自主选择是否跳过创建工程步骤,在已有工程中新增无障碍扩展服务。 开发者在创建一个无障碍扩展服务时,如工程满足环境要求,开发者可自主选择是否跳过创建工程步骤,在已有工程中新增无障碍扩展服务。一个工程仅支持创建一个无障碍扩展服务。
### 创建工程 ### 创建工程
......
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
在开发应用时,需要配置应用的一些标签,例如应用的包名、图标等标识特征的属性。本文描述了在开发应用需要配置的一些关键标签。 在开发应用时,需要配置应用的一些标签,例如应用的包名、图标等标识特征的属性。本文描述了在开发应用需要配置的一些关键标签。
图标和标签通常一起配置,可以分为应用图标、应用标签和入口图标、入口标签,分别对应[app.json5配置文件](../quick-start/app-configuration-file.md)[module.json5配置文件](../quick-start/module-configuration-file.md)文件中的icon和label标签。 图标和标签通常一起配置,可以分为应用图标、应用标签和入口图标、入口标签,分别对应[app.json5配置文件](../quick-start/app-configuration-file.md)[module.json5配置文件](../quick-start/module-configuration-file.md)中的icon和label标签。
应用图标和标签是在设置应用中使用,例如设置应用中的应用列表。入口图标是应用安装完成后在设备桌面上显示出来的,如图一所示。入口图标是以[UIAbility](uiability-overview.md)为粒度,支持同一个应用存在多个入口图标和标签,点击后进入对应的UIAbility界面。 应用图标和标签是在设置应用中使用,例如设置应用中的应用列表。入口图标是应用安装完成后在设备桌面上显示出来的,如下图所示。入口图标是以[UIAbility](uiability-overview.md)为粒度,支持同一个应用存在多个入口图标和入口标签,点击后进入对应的UIAbility界面。
**图1** 应用图标和标签   **图1** 应用图标和标签  
![application-component-configuration-stage](figures/application-component-configuration-stage.png) ![application-component-configuration-stage](figures/application-component-configuration-stage.png)
- **应用包名配置** - **应用包名配置**
...@@ -62,6 +62,33 @@ ...@@ -62,6 +62,33 @@
} }
} }
``` ```
OpenHarmony系统对无图标应用严格管控,防止一些恶意应用故意配置无入口图标,导致用户找不到软件所在的位置,无法操作卸载应用,在一定程度上保证用户的手机安全。
如果应用确需隐藏入口图标,需要配置AllowAppDesktopIconHide应用特权,具体配置方式参考[应用特权配置指南](../../device-dev/subsystems/subsys-app-privilege-config-guide.md)。详细的入口图标及入口标签的显示规则如下。
* HAP中包含UIAbility
* 在module.json5配置文件的abilities标签中设置了入口图标
* 该应用没有隐藏图标的特权
* 系统将使用该UIAbility配置的icon作为入口图标,并显示在桌面上。用户点击该图标,页面跳转到该UIAbility首页。
* 系统将使用该UIAbility配置的label作为入口标签,并显示在桌面上,如果没有配置label,系统将使用app.json5中的label作为入口标签,并显示在桌面上。
* 该应用具有隐藏图标的特权
* 桌面应用查询时不返回应用信息,不会在桌面上显示对应的入口图标和标签。
* 在module.json5配置文件的abilities标签中未设置入口图标
* 该应用没有隐藏图标的特权
* 系统将使用app.json5中的icon作为入口图标,并显示在桌面上。用户点击该图标,页面跳转到应用管理中对应的应用详情页面,如下图所示。
* 系统将使用app.json5中的label作为入口标签,并显示在桌面上。
* 该应用具有隐藏图标的特权
* 桌面应用查询时不返回应用信息,不会在桌面上显示对应的入口图标和标签。
* HAP中不包含UIAbility
* 该应用没有隐藏图标的特权
* 系统将使用app.json5中的icon作为入口图标,并显示在桌面上。用户点击该图标,页面跳转到应用管理中对应的应用详情页面,如下图所示。
* 系统将使用app.json5中的label作为入口标签,并显示在桌面上。
* 该应用具有隐藏图标的特权
* 桌面应用查询时不返回应用信息,不会在桌面上显示对应的入口图标和标签。
**图2** 应用的详情页示意图
![应用的详情页例图](figures/application_details.jpg)
- **应用版本声明配置** - **应用版本声明配置**
应用版本声明需要在工程的AppScope目录下的[app.json5配置文件](../quick-start/app-configuration-file.md)中配置versionCode标签和versionName标签。versionCode用于标识应用的版本号,该标签值为32位非负整数。此数字仅用于确定某个版本是否比另一个版本更新,数值越大表示版本越高。versionName标签标识版本号的文字描述。 应用版本声明需要在工程的AppScope目录下的[app.json5配置文件](../quick-start/app-configuration-file.md)中配置versionCode标签和versionName标签。versionCode用于标识应用的版本号,该标签值为32位非负整数。此数字仅用于确定某个版本是否比另一个版本更新,数值越大表示版本越高。versionName标签标识版本号的文字描述。
......
# OpenHarmony应用模型的构成要素 # 应用模型的构成要素
应用模型是OpenHarmony为开发者提供的应用程序所需能力的抽象提炼,它提供了应用程序必备的组件和运行机制。有了应用模型,开发者可以基于一套统一的模型进行应用开发,使应用开发更简单、高效。 应用模型是OpenHarmony为开发者提供的应用程序所需能力的抽象提炼,它提供了应用程序必备的组件和运行机制。有了应用模型,开发者可以基于一套统一的模型进行应用开发,使应用开发更简单、高效。
......
# OpenHarmony应用模型解读 # 应用模型解读
## OpenHarmony应用模型概况 ## OpenHarmony应用模型概况
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
当前卡片框架提供了如下几种按时间刷新卡片的方式: 当前卡片框架提供了如下几种按时间刷新卡片的方式:
- 定时刷新:表示在一定时间间隔内自动刷新卡片内容。可以在form_config.json配置文件的[`updateDuration`](arkts-ui-widget-configuration.md)字段中进行设置。例如,可以将刷新时间设置为每小时一次。 - 定时刷新:表示在一定时间间隔内调用[onUpdateForm](../reference/apis/js-apis-app-form-formExtensionAbility.md#onupdateform)的生命周期回调函数自动刷新卡片内容。可以在form_config.json配置文件的[`updateDuration`](arkts-ui-widget-configuration.md)字段中进行设置。例如,可以将刷新时间设置为每小时一次。
> **说明:** > **说明:**
> >
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
| 任务 | 简介 | 相关指导 | | 任务 | 简介 | 相关指导 |
| -------- | -------- | -------- | | -------- | -------- | -------- |
| 应用组件开发 | 本章节介绍了如何使用FA模型的PageAbility、ServiceAbility、DataAbility以及服务卡片进行应用开发。 | [应用/组件级配置](application-component-configuration-fa.md)<br/>[PageAbility开发指导](pageability-overview.md)<br/>[ServiceAbility开发指导](serviceability-overview.md)<br/>[DataAbility开发指导](dataability-overview.md)<br/>[服务卡片开发指导](widget-development-fa.md)<br/>[FA模型的Context](application-context-fa.md)<br/>[信息传递载体Want](want-fa.md) | | 应用组件开发 | 本章节介绍了如何使用FA模型的PageAbility、ServiceAbility、DataAbility以及服务卡片进行应用开发。 | [应用/组件级配置](application-component-configuration-fa.md)<br/>[PageAbility开发指导](pageability-overview.md)<br/>[ServiceAbility开发指导](serviceability-overview.md)<br/>[DataAbility开发指导](dataability-overview.md)<br/>[服务卡片开发指导](widget-development-fa.md)<br/>[FA模型的Context](application-context-fa.md)<br/>[信息传递载体Want](want-fa.md) |
| 进程间通信 | 本章节介绍了FA模型的进程模型以及几种常用的进程间通信方式。 | [公共事件](common-event-fa.md)<br/>[后台服务](rpc.md) | | 了解进程模型 | 本章节介绍了FA模型的进程模型以及几种常用的进程间通信方式。 | [公共事件](common-event-fa.md)<br/>[后台服务](rpc.md) |
| 线程间通信 | 本章节介绍了FA模型的线程模型以及几种常用的线程间通信方式。 | [线程间通信](itc-fa-overview.md) | | 了解线程模型 | 本章节介绍了FA模型的线程模型以及几种常用的线程间通信方式。 | [线程间通信](itc-fa-overview.md) |
| 任务管理 | 本章节介绍了FA模型中任务管理的基本概念和典型场景。 | [任务管理](mission-management-fa.md) | | 任务管理 | 本章节介绍了FA模型中任务管理的基本概念和典型场景。 | [任务管理](mission-management-fa.md) |
| 应用配置文件 | 本章节介绍FA模型中应用配置文件的开发要求。 | [FA模型应用配置文件](config-file-fa.md) | | 应用配置文件 | 本章节介绍FA模型中应用配置文件的开发要求。 | [FA模型应用配置文件](config-file-fa.md) |
...@@ -81,7 +81,7 @@ Stage卡片开发,即基于[Stage模型](stage-model-development-overview.md) ...@@ -81,7 +81,7 @@ Stage卡片开发,即基于[Stage模型](stage-model-development-overview.md)
- [配置卡片配置文件](#配置卡片配置文件):配置应用配置文件module.json5和profile配置文件。 - [配置卡片配置文件](#配置卡片配置文件):配置应用配置文件module.json5和profile配置文件。
- [卡片数据交互](#卡片数据交互):对卡片信息进行持久化管理。 - [卡片信息的持久化](#卡片数据交互):对卡片信息进行持久化管理。
- [卡片数据交互](#卡片数据交互):通过updateForm更新卡片显示的信息。 - [卡片数据交互](#卡片数据交互):通过updateForm更新卡片显示的信息。
......
# 进程模型 # 进程模型概述
OpenHarmony的进程模型如下图所示: OpenHarmony的进程模型如下图所示:
......
# 进程模型 # 进程模型概述
OpenHarmony的进程模型如下图所示: OpenHarmony的进程模型如下图所示:
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
| 任务 | 简介 | 相关指导 | | 任务 | 简介 | 相关指导 |
| -------- | -------- | -------- | | -------- | -------- | -------- |
| 应用组件开发 | 本章节介绍了如何使用Stage模型的UIAbility组件和ExtensionAbility组件开发应用。 | -&nbsp;[应用/组件级配置](application-component-configuration-stage.md)<br/>-&nbsp;[UIAbility组件](uiability-overview.md)<br/>-&nbsp;[ExtensionAbility组件](extensionability-overview.md)<br/>-&nbsp;[AbilityStage组件容器](abilitystage.md)<br/>-&nbsp;[应用上下文Context](application-context-stage.md)<br/>-&nbsp;[组件启动规则](component-startup-rules.md) | | 应用组件开发 | 本章节介绍了如何使用Stage模型的UIAbility组件和ExtensionAbility组件开发应用。 | -&nbsp;[应用/组件级配置](application-component-configuration-stage.md)<br/>-&nbsp;[UIAbility组件](uiability-overview.md)<br/>-&nbsp;[ExtensionAbility组件](extensionability-overview.md)<br/>-&nbsp;[AbilityStage组件容器](abilitystage.md)<br/>-&nbsp;[应用上下文Context](application-context-stage.md)<br/>-&nbsp;[组件启动规则](component-startup-rules.md) |
| 进程间通信 | 本章节介绍了Stage模型的进程模型以及几种常用的进程间通信方式。 | -&nbsp;[公共事件](common-event-overview.md)<br/>-&nbsp;[后台服务](background-services.md) | | 了解进程模型 | 本章节介绍了Stage模型的进程模型以及几种常用的进程间通信方式。 | -&nbsp;[公共事件](common-event-overview.md)<br/>-&nbsp;[后台服务](background-services.md) |
| 线程间通信 | 本章节介绍了Stage模型的线程模型以及几种常用的线程间通信方式。 | -&nbsp;[Emitter](itc-with-emitter.md)<br/>-&nbsp;[Worker](itc-with-worker.md) | | 了解线程模型 | 本章节介绍了Stage模型的线程模型以及几种常用的线程间通信方式。 | -&nbsp;[Emitter](itc-with-emitter.md)<br/>-&nbsp;[Worker](itc-with-worker.md) |
| 任务管理 | 本章节介绍了Stage模型中任务管理的基本概念和典型场景。 | -&nbsp;[任务管理场景介绍](mission-management-overview.md)<br/>-&nbsp;[任务管理与启动模式](mission-management-launch-type.md)<br/>-&nbsp;[页面栈和任务链](page-mission-stack.md) | | 任务管理 | 本章节介绍了Stage模型中任务管理的基本概念和典型场景。 | -&nbsp;[任务管理场景介绍](mission-management-overview.md)<br/>-&nbsp;[任务管理与启动模式](mission-management-launch-type.md)<br/>-&nbsp;[页面栈和任务链](page-mission-stack.md) |
| 应用配置文件 | 本章节介绍Stage模型中应用配置文件的开发要求。 | [Stage模型应用配置文件](config-file-stage.md) | | 应用配置文件 | 本章节介绍Stage模型中应用配置文件的开发要求。 | [Stage模型应用配置文件](config-file-stage.md) |
# 线程模型 # 线程模型概述
在OpenHarmony应用中,每个进程都会有一个主线程,主线程具有以下职责: 在OpenHarmony应用中,每个进程都会有一个主线程,主线程具有以下职责:
......
...@@ -29,7 +29,7 @@ IPC/RPC的主要工作是让运行在不同进程的Proxy和Stub互相通信, ...@@ -29,7 +29,7 @@ IPC/RPC的主要工作是让运行在不同进程的Proxy和Stub互相通信,
external_deps = [ external_deps = [
"ipc:ipc_single", "ipc:ipc_single",
] ]
#rpc场景 #rpc场景
external_deps = [ external_deps = [
"ipc:ipc_core", "ipc:ipc_core",
...@@ -50,12 +50,12 @@ IPC/RPC的主要工作是让运行在不同进程的Proxy和Stub互相通信, ...@@ -50,12 +50,12 @@ IPC/RPC的主要工作是让运行在不同进程的Proxy和Stub互相通信,
```c++ ```c++
#include "iremote_broker.h" #include "iremote_broker.h"
//定义消息码 //定义消息码
const int TRANS_ID_PING_ABILITY = 5 const int TRANS_ID_PING_ABILITY = 5;
const std::string DESCRIPTOR = "test.ITestAbility"; const std::string DESCRIPTOR = "test.ITestAbility";
class ITestAbility : public IRemoteBroker { class ITestAbility : public IRemoteBroker {
public: public:
// DECLARE_INTERFACE_DESCRIPTOR是必需的,入参需使用std::u16string; // DECLARE_INTERFACE_DESCRIPTOR是必需的,入参需使用std::u16string;
...@@ -71,13 +71,13 @@ IPC/RPC的主要工作是让运行在不同进程的Proxy和Stub互相通信, ...@@ -71,13 +71,13 @@ IPC/RPC的主要工作是让运行在不同进程的Proxy和Stub互相通信,
```c++ ```c++
#include "iability_test.h" #include "iability_test.h"
#include "iremote_stub.h" #include "iremote_stub.h"
class TestAbilityStub : public IRemoteStub<ITestAbility> { class TestAbilityStub : public IRemoteStub<ITestAbility> {
public: public:
virtual int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; virtual int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
int TestPingAbility(const std::u16string &dummy) override; int TestPingAbility(const std::u16string &dummy) override;
}; };
int TestAbilityStub::OnRemoteRequest(uint32_t code, int TestAbilityStub::OnRemoteRequest(uint32_t code,
MessageParcel &data, MessageParcel &reply, MessageOption &option) MessageParcel &data, MessageParcel &reply, MessageOption &option)
{ {
...@@ -98,12 +98,12 @@ IPC/RPC的主要工作是让运行在不同进程的Proxy和Stub互相通信, ...@@ -98,12 +98,12 @@ IPC/RPC的主要工作是让运行在不同进程的Proxy和Stub互相通信,
```c++ ```c++
#include "iability_server_test.h" #include "iability_server_test.h"
class TestAbility : public TestAbilityStub { class TestAbility : public TestAbilityStub {
public: public:
int TestPingAbility(const std::u16string &dummy); int TestPingAbility(const std::u16string &dummy);
} }
int TestAbility::TestPingAbility(const std::u16string &dummy) { int TestAbility::TestPingAbility(const std::u16string &dummy) {
return 0; return 0;
} }
...@@ -117,7 +117,7 @@ IPC/RPC的主要工作是让运行在不同进程的Proxy和Stub互相通信, ...@@ -117,7 +117,7 @@ IPC/RPC的主要工作是让运行在不同进程的Proxy和Stub互相通信,
#include "iability_test.h" #include "iability_test.h"
#include "iremote_proxy.h" #include "iremote_proxy.h"
#include "iremote_object.h" #include "iremote_object.h"
class TestAbilityProxy : public IRemoteProxy<ITestAbility> { class TestAbilityProxy : public IRemoteProxy<ITestAbility> {
public: public:
explicit TestAbilityProxy(const sptr<IRemoteObject> &impl); explicit TestAbilityProxy(const sptr<IRemoteObject> &impl);
...@@ -125,12 +125,12 @@ IPC/RPC的主要工作是让运行在不同进程的Proxy和Stub互相通信, ...@@ -125,12 +125,12 @@ IPC/RPC的主要工作是让运行在不同进程的Proxy和Stub互相通信,
private: private:
static inline BrokerDelegator<TestAbilityProxy> delegator_; // 方便后续使用iface_cast宏 static inline BrokerDelegator<TestAbilityProxy> delegator_; // 方便后续使用iface_cast宏
} }
TestAbilityProxy::TestAbilityProxy(const sptr<IRemoteObject> &impl) TestAbilityProxy::TestAbilityProxy(const sptr<IRemoteObject> &impl)
: IRemoteProxy<ITestAbility>(impl) : IRemoteProxy<ITestAbility>(impl)
{ {
} }
int TestAbilityProxy::TestPingAbility(const std::u16string &dummy){ int TestAbilityProxy::TestPingAbility(const std::u16string &dummy){
MessageOption option; MessageOption option;
MessageParcel dataParcel, replyParcel; MessageParcel dataParcel, replyParcel;
...@@ -149,7 +149,7 @@ IPC/RPC的主要工作是让运行在不同进程的Proxy和Stub互相通信, ...@@ -149,7 +149,7 @@ IPC/RPC的主要工作是让运行在不同进程的Proxy和Stub互相通信,
// 注册到本设备内 // 注册到本设备内
auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
samgr->AddSystemAbility(saId, new TestAbility()); samgr->AddSystemAbility(saId, new TestAbility());
// 在组网场景下,会被同步到其他设备上 // 在组网场景下,会被同步到其他设备上
auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
ISystemAbilityManager::SAExtraProp saExtra; ISystemAbilityManager::SAExtraProp saExtra;
...@@ -166,10 +166,10 @@ IPC/RPC的主要工作是让运行在不同进程的Proxy和Stub互相通信, ...@@ -166,10 +166,10 @@ IPC/RPC的主要工作是让运行在不同进程的Proxy和Stub互相通信,
sptr<ISystemAbilityManager> samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); sptr<ISystemAbilityManager> samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
sptr<IRemoteObject> remoteObject = samgr->GetSystemAbility(saId); sptr<IRemoteObject> remoteObject = samgr->GetSystemAbility(saId);
sptr<ITestAbility> testAbility = iface_cast<ITestAbility>(remoteObject); // 使用iface_cast宏转换成具体类型 sptr<ITestAbility> testAbility = iface_cast<ITestAbility>(remoteObject); // 使用iface_cast宏转换成具体类型
// 获取其他设备注册的SA的proxy // 获取其他设备注册的SA的proxy
sptr<ISystemAbilityManager> samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); sptr<ISystemAbilityManager> samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
// networkId是组网场景下对应设备的标识符,可以通过GetLocalNodeDeviceInfo获取 // networkId是组网场景下对应设备的标识符,可以通过GetLocalNodeDeviceInfo获取
sptr<IRemoteObject> remoteObject = samgr->GetSystemAbility(saId, networkId); sptr<IRemoteObject> remoteObject = samgr->GetSystemAbility(saId, networkId);
sptr<TestAbilityProxy> proxy(new TestAbilityProxy(remoteObject)); // 直接构造具体Proxy sptr<TestAbilityProxy> proxy(new TestAbilityProxy(remoteObject)); // 直接构造具体Proxy
...@@ -180,59 +180,97 @@ IPC/RPC的主要工作是让运行在不同进程的Proxy和Stub互相通信, ...@@ -180,59 +180,97 @@ IPC/RPC的主要工作是让运行在不同进程的Proxy和Stub互相通信,
1. 添加依赖 1. 添加依赖
```ts ```ts
import rpc from "@ohos.rpc" import rpc from "@ohos.rpc";
import featureAbility from "@ohos.ability.featureAbility" // 仅FA模型需要导入@ohos.ability.featureAbility
// import featureAbility from "@ohos.ability.featureAbility";
``` ```
Stage模型需要获取context
```ts
import Ability from "@ohos.app.ability.UIAbility";
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] MainAbility onCreate");
globalThis.context = this.context;
}
onDestroy() {
console.log("[Demo] MainAbility onDestroy");
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility onWindowStageCreate");
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] MainAbility onWindowStageDestroy");
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] MainAbility onForeground");
}
onBackground() {
// Ability has back to background
console.log("[Demo] MainAbility onBackground");
}
}
```
2. 绑定Ability 2. 绑定Ability
首先,构造变量want,指定要绑定的Ability所在应用的包名、组件名,如果是跨设备的场景,还需要绑定目标设备NetworkId(组网场景下对应设备的标识符,可以使用deviceManager获取目标设备的NetworkId);然后,构造变量connect,指定绑定成功、绑定失败、断开连接时的回调函数;最后,使用featureAbility提供的接口绑定Ability。 首先,构造变量want,指定要绑定的Ability所在应用的包名、组件名,如果是跨设备的场景,还需要绑定目标设备NetworkId(组网场景下对应设备的标识符,可以使用deviceManager获取目标设备的NetworkId);然后,构造变量connect,指定绑定成功、绑定失败、断开连接时的回调函数;最后,FA模型使用featureAbility提供的接口绑定Ability,Stage模型通过context获取服务后用提供的接口绑定Ability。
```ts ```ts
import rpc from "@ohos.rpc" import rpc from "@ohos.rpc";
import featureAbility from "@ohos.ability.featureAbility" // 仅FA模型需要导入@ohos.ability.featureAbility
// import featureAbility from "@ohos.ability.featureAbility";
let proxy = null
let connectId = null let proxy = null;
let connectId = null;
// 单个设备绑定Ability // 单个设备绑定Ability
let want = { let want = {
// 包名和组件名写实际的值 // 包名和组件名写实际的值
"bundleName": "ohos.rpc.test.server", "bundleName": "ohos.rpc.test.server",
"abilityName": "ohos.rpc.test.server.ServiceAbility", "abilityName": "ohos.rpc.test.server.ServiceAbility",
} };
let connect = { let connect = {
onConnect:function(elementName, remote) { onConnect:function(elementName, remote) {
proxy = remote proxy = remote;
}, },
onDisconnect:function(elementName) { onDisconnect:function(elementName) {
}, },
onFailed:function() { onFailed:function() {
proxy = null proxy = null;
} }
} };
connectId = featureAbility.connectAbility(want, connect) // FA模型使用此方法连接服务
// connectId = featureAbility.connectAbility(want, connect);
connectId = globalThis.context.connectServiceExtensionAbility(want,connect);
// 如果是跨设备绑定,可以使用deviceManager获取目标设备NetworkId // 如果是跨设备绑定,可以使用deviceManager获取目标设备NetworkId
import deviceManager from '@ohos.distributedHardware.deviceManager' import deviceManager from '@ohos.distributedHardware.deviceManager';
function deviceManagerCallback(deviceManager) { function deviceManagerCallback(deviceManager) {
let deviceList = deviceManager.getTrustedDeviceListSync() let deviceList = deviceManager.getTrustedDeviceListSync();
let networkId = deviceList[0].networkId let networkId = deviceList[0].networkId;
let want = { let want = {
"bundleName": "ohos.rpc.test.server", "bundleName": "ohos.rpc.test.server",
"abilityName": "ohos.rpc.test.service.ServiceAbility", "abilityName": "ohos.rpc.test.service.ServiceAbility",
"networkId": networkId, "networkId": networkId,
"flags": 256 "flags": 256
} };
connectId = featureAbility.connectAbility(want, connect) // 建立连接后返回的Id需要保存下来,在断开连接时需要作为参数传入
// FA模型使用此方法连接服务
// connectId = featureAbility.connectAbility(want, connect);
connectId = globalThis.context.connectServiceExtensionAbility(want,connect);
} }
// 第一个参数是本应用的包名,第二个参数是接收deviceManager的回调函数 // 第一个参数是本应用的包名,第二个参数是接收deviceManager的回调函数
deviceManager.createDeviceManager("ohos.rpc.test", deviceManagerCallback) deviceManager.createDeviceManager("ohos.rpc.test", deviceManagerCallback);
``` ```
3. 服务端处理客户端请求 3. 服务端处理客户端请求
...@@ -240,78 +278,80 @@ IPC/RPC的主要工作是让运行在不同进程的Proxy和Stub互相通信, ...@@ -240,78 +278,80 @@ IPC/RPC的主要工作是让运行在不同进程的Proxy和Stub互相通信,
```ts ```ts
onConnect(want: Want) { onConnect(want: Want) {
var robj:rpc.RemoteObject = new Stub("rpcTestAbility") var robj:rpc.RemoteObject = new Stub("rpcTestAbility");
return robj return robj;
} }
class Stub extends rpc.RemoteObject { class Stub extends rpc.RemoteObject {
constructor(descriptor) { constructor(descriptor) {
super(descriptor) super(descriptor);
} }
onRemoteMessageRequest(code, data, reply, option) { onRemoteMessageRequest(code, data, reply, option) {
// 根据code处理客户端的请求 // 根据code处理客户端的请求
return true return true;
} }
} }
``` ```
4. 客户端处理服务端响应 4. 客户端处理服务端响应
客户端在onConnect回调里接收到代理对象,调用sendRequestAsync方法发起请求,在期约(JavaScript期约:用于表示一个异步操作的最终完成或失败及其结果值)或者回调函数里接收结果。 客户端在onConnect回调里接收到代理对象,调用sendRequest方法发起请求,在期约(JavaScript期约:用于表示一个异步操作的最终完成或失败及其结果值)或者回调函数里接收结果。
```ts ```ts
// 使用期约 // 使用期约
let option = new rpc.MessageOption() let option = new rpc.MessageOption();
let data = rpc.MessageParcel.create() let data = rpc.MessageParcel.create();
let reply = rpc.MessageParcel.create() let reply = rpc.MessageParcel.create();
// 往data里写入参数 // 往data里写入参数
proxy.sendRequestAsync(1, data, reply, option) proxy.sendRequest(1, data, reply, option)
.then(function(result) { .then(function(result) {
if (result.errCode != 0) { if (result.errCode != 0) {
console.error("send request failed, errCode: " + result.errCode) console.error("send request failed, errCode: " + result.errCode);
return return;
} }
// 从result.reply里读取结果 // 从result.reply里读取结果
}) })
.catch(function(e) { .catch(function(e) {
console.error("send request got exception: " + e) console.error("send request got exception: " + e);
} })
.finally(() => { .finally(() => {
data.reclaim() data.reclaim();
reply.reclaim() reply.reclaim();
}) })
// 使用回调函数 // 使用回调函数
function sendRequestCallback(result) { function sendRequestCallback(result) {
try { try {
if (result.errCode != 0) { if (result.errCode != 0) {
console.error("send request failed, errCode: " + result.errCode) console.error("send request failed, errCode: " + result.errCode);
return return;
} }
// 从result.reply里读取结果 // 从result.reply里读取结果
} finally { } finally {
result.data.reclaim() result.data.reclaim();
result.reply.reclaim() result.reply.reclaim();
} }
} }
let option = new rpc.MessageOption() let option = new rpc.MessageOption();
let data = rpc.MessageParcel.create() let data = rpc.MessageParcel.create();
let reply = rpc.MessageParcel.create() let reply = rpc.MessageParcel.create();
// 往data里写入参数 // 往data里写入参数
proxy.sendRequest(1, data, reply, option, sendRequestCallback) proxy.sendRequest(1, data, reply, option, sendRequestCallback);
``` ```
5. 断开连接 5. 断开连接
IPC通信结束后,使用featureAbility的接口断开连接。 IPC通信结束后,FA模型使用featureAbility的接口断开连接,Stage模型在获取context后用提供的接口断开连接。
```ts ```ts
import rpc from "@ohos.rpc" import rpc from "@ohos.rpc";
import featureAbility from "@ohos.ability.featureAbility" // 仅FA模型需要导入@ohos.ability.featureAbility
// import featureAbility from "@ohos.ability.featureAbility";
function disconnectCallback() { function disconnectCallback() {
console.info("disconnect ability done") console.info("disconnect ability done");
} }
featureAbility.disconnectAbility(connectId, disconnectCallback) // FA模型使用此方法断开连接
// featureAbility.disconnectAbility(connectId, disconnectCallback);
globalThis.context.disconnectServiceExtensionAbility(connectId);
``` ```
...@@ -3,35 +3,25 @@ ...@@ -3,35 +3,25 @@
## 基本概念 ## 基本概念
IPC(Inter-Process Communication)与RPC(Remote Procedure Call)用于实现跨进程通信,不同的是前者使用Binder驱动,用于设备内的跨进程通信,后者使用软总线驱动,用于跨设备跨进程通信。需要跨进程通信的原因是因为每个进程都有自己独立的资源和内存空间,其他进程不能随意访问不同进程的内存和资源,IPC/RPC便是为了突破这一点。IPC和RPC通常采用客户端-服务器(Client-Server)模型,在使用时,请求服务的(Client)一端进程可获取提供服务(Server)一端所在进程的代理(Proxy),并通过此代理读写数据来实现进程间的数据通信,更具体的讲,首先请求服务的(Client)一端会建立一个服务提供端(Server)的代理对象,这个代理对象具备和服务提供端(Server)一样的功能,若想访问服务提供端(Server)中的某一个方法,只需访问代理对象中对应的方法即可,代理对象会将请求发送给服务提供端(Server);然后服务提供端(Server)处理接受到的请求,处理完之后通过驱动返回处理结果给代理对象;最后代理对象将请求结果进一步返回给请求服务端(Client)。通常,Server会先注册系统能力(System Ability)到系统能力管理者(System Ability Manager,缩写SAMgr)中,SAMgr负责管理这些SA并向Client提供相关的接口。Client要和某个具体的SA通信,必须先从SAMgr中获取该SA的代理,然后使用代理和SA通信。下文直接使用Proxy表示服务请求方,Stub表示服务提供方。 IPC(Inter-Process Communication)与RPC(Remote Procedure Call)用于实现跨进程通信,不同的是前者使用Binder驱动,用于设备内的跨进程通信,后者使用软总线驱动,用于跨设备跨进程通信。需要跨进程通信的原因是因为每个进程都有自己独立的资源和内存空间,其他进程不能随意访问不同进程的内存和资源,IPC/RPC便是为了突破这一点。
![IPC&RPC通信机制](figures/075sd302-aeb9-481a-bb8f-e552sdb61ead.PNG) > **说明:**
> Stage模型不能直接使用本文介绍的IPC和RPC,需要通过以下能力实现相关业务场景:
>- IPC典型使用场景为[后台服务](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/application-models/background-services.md),后台服务通过IPC机制提供跨进程的服务调用能力。
## 约束与限制 >- RPC典型使用场景为[多端协同](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/application-models/hop-multi-device-collaboration.md),多端协同通过RPC机制提供远端接口调用与数据传递。
- 单个设备上跨进程通信时,传输的数据量最大约为1MB,过大的数据量请使用[匿名共享内存](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-rpc.md#ashmem8)
- 不支持在RPC中订阅匿名Stub对象(没有向SAMgr注册Stub对象)的死亡通知。
- 不支持把跨设备的Proxy对象传递回该Proxy对象所指向的Stub对象所在的设备,即指向远端设备Stub的Proxy对象不能在本设备内进行二次跨进程传递。
## 使用建议
首先,需要编写接口类,接口类中必须定义消息码,供通信双方标识操作,可以有未实现的的方法,因为通信双方均需继承该接口类且双方不能是抽象类,所以此时定义的未实现的方法必须在双方继承时给出实现,这保证了继承双方不是抽象类。然后,需要编写Stub端相关类及其接口,并且实现AsObject方法及OnRemoteRequest方法。同时,也需要编写Proxy端,实现接口类中的方法和AsObject方法,也可以封装一些额外的方法用于调用SendRequest向对端发送数据。以上三者都具备后,便可以向SAMgr注册SA了,此时的注册应该在Stub所在进程完成。最后,在需要的地方从SAMgr中获取Proxy,便可通过Proxy实现与Stub的跨进程通信了。
相关步骤:
- 实现接口类:需继承IRemoteBroker,需定义消息码,可声明不在此类实现的方法。 ## 实现原理
- 实现服务提供端(Stub):需继承IRemoteStub或者RemoteObject,需重写AsObject方法及OnRemoteRequest方法 IPC和RPC通常采用客户端-服务器(Client-Server)模型,在使用时,请求服务的(Client)一端进程可获取提供服务(Server)一端所在进程的代理(Proxy),并通过此代理读写数据来实现进程间的数据通信,更具体的讲,首先请求服务的(Client)一端会建立一个服务提供端(Server)的代理对象,这个代理对象具备和服务提供端(Server)一样的功能,若想访问服务提供端(Server)中的某一个方法,只需访问代理对象中对应的方法即可,代理对象会将请求发送给服务提供端(Server);然后服务提供端(Server)处理接受到的请求,处理完之后通过驱动返回处理结果给代理对象;最后代理对象将请求结果进一步返回给请求服务端(Client)。通常,Server会先注册系统能力(System Ability)到系统能力管理者(System Ability Manager,缩写SAMgr)中,SAMgr负责管理这些SA并向Client提供相关的接口。Client要和某个具体的SA通信,必须先从SAMgr中获取该SA的代理,然后使用代理和SA通信。下文直接使用Proxy表示服务请求方,Stub表示服务提供方
- 实现服务请求端(Proxy):需继承IRemoteProxy或RemoteProxy,需重写AsObject方法,封装所需方法调用SendRequest。 ![IPC&RPC通信机制](figures/075sd302-aeb9-481a-bb8f-e552sdb61ead.PNG)
- 注册SA:申请SA的唯一ID,向SAMgr注册SA。
- 获取SA:通过SA的ID和设备ID获取Proxy,使用Proxy与远端通信 ## 约束与限制
- 单个设备上跨进程通信时,传输的数据量最大约为1MB,过大的数据量请使用[匿名共享内存](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-rpc.md#ashmem8)
## 相关模块 - 不支持在RPC中订阅匿名Stub对象(没有向SAMgr注册Stub对象)的死亡通知。
[分布式任务调度子系统](https://gitee.com/openharmony/ability_dmsfwk) - 不支持把跨设备的Proxy对象传递回该Proxy对象所指向的Stub对象所在的设备,即指向远端设备Stub的Proxy对象不能在本设备内进行二次跨进程传递。
\ No newline at end of file
# 远端状态订阅开发实例 # 远端状态订阅开发实例
IPC/RPC提供对远端Stub对象状态的订阅机制, 在远端Stub对象消亡时,可触发消亡通知告诉本地Proxy对象。这种状态通知订阅需要调用特定接口完成,当不再需要订阅时也需要调用特定接口取消。使用这种订阅机制的用户,需要实现消亡通知接口DeathRecipient并实现onRemoteDied方法清理资源。该方法会在远端Stub对象所在进程消亡或所在设备离开组网时被回调。值得注意的是,调用这些接口有一定的顺序。首先,需要Proxy订阅Stub消亡通知,若在订阅期间Stub状态正常,则在不再需要时取消订阅;若在订阅期间Stub所在进程退出或者所在设备退出组网,则会自动触发Proxy自定义的后续操作。 IPC/RPC提供对远端Stub对象状态的订阅机制,在远端Stub对象消亡时,可触发消亡通知告诉本地Proxy对象。这种状态通知订阅需要调用特定接口完成,当不再需要订阅时也需要调用特定接口取消。使用这种订阅机制的用户,需要实现消亡通知接口DeathRecipient并实现onRemoteDied方法清理资源。该方法会在远端Stub对象所在进程消亡或所在设备离开组网时被回调。值得注意的是,调用这些接口有一定的顺序。首先,需要Proxy订阅Stub消亡通知,若在订阅期间Stub状态正常,则在不再需要时取消订阅;若在订阅期间Stub所在进程退出或者所在设备退出组网,则会自动触发Proxy自定义的后续操作。
## 使用场景 ## 使用场景
...@@ -21,7 +21,6 @@ IPC/RPC提供对远端Stub对象状态的订阅机制, 在远端Stub对象消 ...@@ -21,7 +21,6 @@ IPC/RPC提供对远端Stub对象状态的订阅机制, 在远端Stub对象消
#include "iremote_broker.h" #include "iremote_broker.h"
#include "iremote_stub.h" #include "iremote_stub.h"
//定义消息码 //定义消息码
enum { enum {
TRANS_ID_PING_ABILITY = 5, TRANS_ID_PING_ABILITY = 5,
...@@ -61,9 +60,6 @@ int TestServiceProxy::TestPingAbility(const std::u16string &dummy){ ...@@ -61,9 +60,6 @@ int TestServiceProxy::TestPingAbility(const std::u16string &dummy){
} }
``` ```
```c++ ```c++
#include "iremote_object.h" #include "iremote_object.h"
...@@ -86,16 +82,52 @@ result = object->RemoveDeathRecipient(deathRecipient); // 移除消亡通知 ...@@ -86,16 +82,52 @@ result = object->RemoveDeathRecipient(deathRecipient); // 移除消亡通知
## JS侧接口 ## JS侧接口
| 接口名 | 返回值类型 | 功能描述 | | 接口名 | 返回值类型 | 功能描述 |
| -------------------- | ---------- | ------------------------------------------------------------ | | ------------------------ | ---------- | ----------------------------------------------------------------- |
| addDeathRecippient | boolean | 注册用于接收远程对象消亡通知的回调,增加proxy对象上的消亡通知。 | | registerDeathRecipient | void | 注册用于接收远程对象消亡通知的回调,增加 proxy 对象上的消亡通知。 |
| removeDeathRecipient | boolean | 注销用于接收远程对象消亡通知的回调。 | | unregisterDeathRecipient | void | 注销用于接收远程对象消亡通知的回调。 |
| onRemoteDied | void | 在成功添加死亡通知订阅后,当远端对象死亡时,将自动调用本方法。 | | onRemoteDied | void | 在成功添加死亡通知订阅后,当远端对象死亡时,将自动调用本方法。 |
### 获取context
Stage模型在连接服务前需要先获取context
```ts
import Ability from "@ohos.app.ability.UIAbility";
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] MainAbility onCreate");
globalThis.context = this.context;
}
onDestroy() {
console.log("[Demo] MainAbility onDestroy");
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility onWindowStageCreate");
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] MainAbility onWindowStageDestroy");
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] MainAbility onForeground");
}
onBackground() {
// Ability has back to background
console.log("[Demo] MainAbility onBackground");
}
}
```
### 参考代码 ### 参考代码
```ts ```ts
import FA from "@ohos.ability.featureAbility"; // 仅FA模型需要导入@ohos.ability.featureAbility
// import FA from "@ohos.ability.featureAbility";
let proxy; let proxy;
let connect = { let connect = {
onConnect: function(elementName, remoteProxy) { onConnect: function(elementName, remoteProxy) {
...@@ -113,15 +145,19 @@ let want = { ...@@ -113,15 +145,19 @@ let want = {
"bundleName": "com.ohos.server", "bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility", "abilityName": "com.ohos.server.EntryAbility",
}; };
FA.connectAbility(want, connect); // FA模型通过此方法连接服务
// FA.connectAbility(want, connect);
globalThis.context.connectServiceExtensionAbility(want, connect);
class MyDeathRecipient { class MyDeathRecipient {
onRemoteDied() { onRemoteDied() {
console.log("server died"); console.log("server died");
} }
} }
let deathRecipient = new MyDeathRecipient(); let deathRecipient = new MyDeathRecipient();
proxy.addDeathRecippient(deathRecipient, 0); proxy.registerDeathRecippient(deathRecipient, 0);
proxy.removeDeathRecipient(deathRecipient, 0); proxy.unregisterDeathRecipient(deathRecipient, 0);
``` ```
## Stub感知Proxy消亡(匿名Stub的使用) ## Stub感知Proxy消亡(匿名Stub的使用)
......
...@@ -167,4 +167,4 @@ USB设备可作为Host设备连接Device设备进行数据传输。开发示例 ...@@ -167,4 +167,4 @@ USB设备可作为Host设备连接Device设备进行数据传输。开发示例
针对USB管理开发,有以下相关实例可供参考: 针对USB管理开发,有以下相关实例可供参考:
- [`USBManager`:USB管理(ArkTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/master/code/BasicFeature/DeviceManagement/USBManager) - [`DeviceManagementCollection`:设备管理合集(ArkTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/master/code/BasicFeature/DeviceManagement/DeviceManagementCollection)
\ No newline at end of file \ No newline at end of file
# Stage模型应用程序包结构 # Stage模型应用程序包结构
基于[Stage模型](application-configuration-file-overview-stage.md)开发的应用,经编译打包后,其应用程序包结构如下图**应用程序包结构(Stage模型)**所示。开发者需要熟悉应用程序包结构相关的基本概念。 基于[Stage模型](application-configuration-file-overview-stage.md)开发的应用,经编译打包后,其应用程序包结构如下图“应用程序包结构(Stage模型)”所示。开发者需要熟悉应用程序包结构相关的基本概念。
- 在开发态,一个应用包含一个或者多个Module,可以在[DevEco Studio](https://developer.harmonyos.com/cn/develop/deveco-studio/)工程中[创建一个或者多个Module](https://developer.harmonyos.com/cn/docs/documentation/doc-guides-V3/ohos-adding-deleting-module-0000001218760594-V3)。Module是OpenHarmony应用/服务的基本功能单元,包含了源代码、资源文件、第三方库及应用/服务配置文件,每一个Module都可以独立进行编译和运行。Module分为“Ability”和“Library”两种类型,“Ability”类型的Module对应于编译后的HAP(Harmony Ability Package);“Library”类型的Module对应于[HAR](har-package.md)(Harmony Archive),或者[HSP](shared-guide.md)(Harmony Shared Package)。 - 在开发态,一个应用包含一个或者多个Module,可以在[DevEco Studio](https://developer.harmonyos.com/cn/develop/deveco-studio/)工程中[创建一个或者多个Module](https://developer.harmonyos.com/cn/docs/documentation/doc-guides-V3/add_new_module-0000001053223741-V3)。Module是OpenHarmony应用/服务的基本功能单元,包含了源代码、资源文件、第三方库及应用/服务配置文件,每一个Module都可以独立进行编译和运行。Module分为“Ability”和“Library”两种类型,“Ability”类型的Module对应于编译后的HAP(Harmony Ability Package);“Library”类型的Module对应于[HAR](har-package.md)(Harmony Archive),或者[HSP](shared-guide.md)(Harmony Shared Package)。
一个Module可以包含一个或多个[UIAbility](../application-models/uiability-overview.md)组件,如**Module与UIAbility组件关系示意图**所示。 一个Module可以包含一个或多个[UIAbility](../application-models/uiability-overview.md)组件,如**Module与UIAbility组件关系示意图**所示。
**图1** Module与UIAbility组件关系示意图 **图1** Module与UIAbility组件关系示意图
......
...@@ -228,66 +228,6 @@ deviceTypes示例: ...@@ -228,66 +228,6 @@ deviceTypes示例:
abilities标签描述UIAbility组件的配置信息,标签值为数组类型,该标签下的配置只对当前UIAbility生效。 abilities标签描述UIAbility组件的配置信息,标签值为数组类型,该标签下的配置只对当前UIAbility生效。
**OpenHarmony中不允许应用隐藏入口图标**
OpenHarmony系统对无图标应用严格管控。如果HAP中没有配置入口图标,那么系统将应用app.json中的icon作为入口图标,并显示在桌面上。<br>
用户点击该图标,将跳转到设置应用管理中对应的应用详情页面(图1)中。<br>
如果应用想要隐藏入口图标,需要配置AllowAppDesktopIconHide应用特权,具体配置方式参考[应用特权配置指南](../../device-dev/subsystems/subsys-app-privilege-config-guide.md)
**场景说明:** 该功能能防止一些恶意应用,故意配置无入口图标,导致用户找不到软件所在的位置,无法操作卸载应用,在一定程度上保证用户的手机安全
**入口图标的设置:** 需要在配置文件(module.json5)中abilities配置下设置icon,label以及skills,而且skills的配置下的必须同时包含“ohos.want.action.home” 和 “entity.system.home”:
```
{
"module":{
...
"abilities": [{
"icon": "$media:icon",
"label": "Login",
"skills": [{
"actions": ["ohos.want.action.home"],
"entities": ["entity.system.home"],
"uris": []
}]
}],
...
}
}
```
**入口图标及入口标签的显示规则**
* HAP中包含UIAbility
* 配置文件(module.json5)中abilities配置中设置了入口图标
* 该应用没有隐藏图标的特权
* 显示桌面图标为该UIAbility配置的图标
* 显示桌面Label为该UIAbility配置的Label(如果没有配置Label,返回包名)
* 显示组件名为该UIAbility的组件名
* 用户点击该桌面图标,页面跳转到该UIAbility首页
* 该应用具有隐藏图标的特权
* 桌面查询时不返回应用信息,不会在桌面上显示对应的图标。
* 配置文件(module.json5)中abilities配置中未设置入口图标
* 该应用没有隐藏图标的特权
* 显示桌面图标为app配置下的图标(app.json中icon为必填项)
* 显示桌面Label为app配置下的label(app.json中label为必填项)
* 用户点击该桌面图标,页面跳转到该应用的详情页面(图1)
* 该应用具有隐藏图标的特权
* 桌面查询时不返回应用信息,不会在桌面上显示对应的图标。
* HAP中不包含UIAbility
* 该应用没有隐藏图标的特权
* 显示桌面图标为app配置下的图标(app.json中icon为必填项)
* 显示桌面Label为app配置下的label(app.json中label为必填项)
* 用户点击该桌面图标,页面跳转到该应用的详情页面(图1)
* 该应用具有隐藏图标的特权
* 桌面查询时不返回应用信息,不会在桌面上显示对应的图标。<br><br>
应用的详情页例图
![应用的详情页例图](figures/application_details.jpg)
**表6** **abilities标签说明** **表6** **abilities标签说明**
| 属性名称 | 含义 | 数据类型 | 是否可缺省 | | 属性名称 | 含义 | 数据类型 | 是否可缺省 |
......
...@@ -191,15 +191,46 @@ metadata对象示例: ...@@ -191,15 +191,46 @@ metadata对象示例:
## abilities对象的内部结构 ## abilities对象的内部结构
**OpenHarmony中不允许应用隐藏入口图标** **表8** **abilities对象的内部结构说明**
| 属性名称 | 含义 | 数据类型 | 是否可缺省 |
| -------- | -------- | -------- | -------- |
| process | 运行应用程序或Ability的进程名称。如果在deviceConfig标记中配置了进程,则应用程序的所有能力都在此进程中运行。您还可以为特定能力设置流程属性,以便该能力可以在此流程中运行。如果此属性设置为与其他应用程序相同的进程名称,则所有这些应用程序可以在同一进程中运行,前提是他们具有相同的联合用户ID和相同的签名。该标签最大字节数为31个字节。 | 字符串 | 可缺省,缺省值为空。 |
| name | 标识Ability名称。取值可采用反向域名方式表示,由包名和类名组成,如"com.example.myapplication.EntryAbility";也可采用"."开头的类名方式表示,如".EntryAbility"。<br/>Ability的名称,需在一个应用的范围内保证唯一。说明:在使用DevEco&nbsp;Studio新建项目时,默认生成首个Ability的配置,即"config.json"中"EntryAbility"的配置。如使用其他IDE工具,可自定义名称。该标签最大长度为127个字节。 | 字符串 | 不可缺省 |
| description | 标识对Ability的描述。取值可以是描述性内容,也可以是对描述性内容的资源索引,以支持多语言。该标签最大长度为255个字节。 | 字符串 | 可缺省,缺省值为空。 |
| icon | 标识Ability图标资源文件的索引。取值示例:$media:ability_icon。如果在该Ability的skills属性中,actions的取值包含&nbsp;"action.system.home",entities取值中包含"entity.system.home",则该Ability的icon将同时作为应用的icon。如果存在多个符合条件的Ability,则取位置靠前的Ability的icon作为应用的icon。<br/>说明:应用的"icon"和"label"是用户可感知配置项,需要区别于当前所有已有的应用"icon"或"label"(至少有一个不同)。 | 字符串 | 可缺省,缺省值为空。 |
| label | 标识Ability对用户显示的名称。取值是对该名称的资源索引,支持多语言,例:$string:ability_label。如果在该Ability的skills属性中,actions的取值包含&nbsp;"action.system.home",entities取值中包含"entity.system.home",则该Ability的label将同时作为应用的label。如果存在多个符合条件的Ability,则取位置靠前的Ability的label作为应用的label。<br/>说明:&nbsp;应用的"icon"和"label"是用户可感知配置项,需要区别于当前所有已有的应用"icon"或"label"(至少有一个不同)。该标签为资源文件中定义的字符串的引用,或以"{}"包括的字符串。该标签最大长度为255个字节。 | 字符串 | 可缺省,缺省值为空。 |
| uri | 标识Ability的统一资源标识符。该标签最大长度为255个字节。 | 字符串 | 可缺省,对于data类型的Ability不可缺省。 |
| launchType | 标识Ability的启动模式,支持"standard"和"singleton"两种模式:<br/>standard:表示该Ability可以有多实例。该模式适用于大多数应用场景。<br/>singleton:表示该Ability在所有任务栈中仅可以有一个实例。例如,具有全局唯一性的呼叫来电界面即采用"singleton"模式。该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。 | 字符串 | 可缺省,缺省值为"singleton"。 |
| visible | 标识Ability是否可以被其他应用调用。<br/>true:可以被其他应用调用。<br/>false:不能被其他应用调用。 | 布尔类型 | 可缺省,缺省值为"false"。 |
| permissions | 标识其他应用的Ability调用此Ability时需要申请的权限集合,一个数组元素为一个权限名称。通常采用反向域名格式(最大255字节),取值为系统预定义的权限。 | 字符串数组 | 可缺省,缺省值为空。 |
|skills | 标识Ability能够接收的want的特征。 | 对象数组 | 可缺省,缺省值为空。 |
| deviceCapability | 标识Ability运行时要求设备具有的能力,采用字符串数组的格式表示。该标签为数组,支持最多配置512个元素,单个元素最大字节长度为64。 | 字符串数组 | 可缺省,缺省值为空。 |
| metaData | 元数据。 | 对象 | 可缺省,缺省值为空。 |
| type | 标识Ability的类型。取值范围如下:<br/>page:表示基于Page模板开发的FA,用于提供与用户交互的能力。<br/>service:表示基于Service模板开发的PA,用于提供后台运行任务的能力。<br/>data:表示基于Data模板开发的PA,用于对外部提供统一的数据访问对象。<br/>CA:表示支持其他应用以窗口方式调起该Ability。 | 字符串 | 不可缺省。 |
| orientation | 标识该Ability的显示模式。该标签仅适用于page类型的Ability。取值范围如下:<br/>unspecified:由系统自动判断显示方向。<br/>landscape:横屏模式。<br/>portrait:竖屏模式。<br/>followRecent:跟随栈中最近的应用。 | 字符串 | 可缺省,缺省值为"unspecified"。 |
| backgroundModes | 标识后台服务的类型,可以为一个服务配置多个后台服务类型。该标签仅适用于service类型的Ability。取值范围如下:<br/>dataTransfer:通过网络/对端设备进行数据下载、备份、分享、传输等业务。<br/>audioPlayback:音频输出业务。<br/>audioRecording:音频输入业务。<br/>pictureInPicture:画中画、小窗口播放视频业务。<br/>voip:音视频电话、VOIP业务。<br/>location:定位、导航业务。<br/>bluetoothInteraction:蓝牙扫描、连接、传输业务。<br/>wifiInteraction:WLAN扫描、连接、传输业务。<br/>screenFetch:录屏、截屏业务。<br/>multiDeviceConnection:多设备互联业务 | 字符串数组 | 可缺省,缺省值为空。 |
| grantPermission | 指定是否可以向Ability内任何数据授予权限。 | 布尔值 | 可缺省,缺省值为空。 |
| readPermission | 标识读取Ability的数据所需的权限。该标签仅适用于data类型的Ability。取值为长度不超过255字节的字符串。该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。 | 字符串 | 可缺省,缺省为空。 |
| writePermission | 标识向Ability写数据所需的权限。该标签仅适用于data类型的Ability。取值为长度不超过255字节的字符串。 | 字符串 | 可缺省,缺省为空。 |
| configChanges | 标识Ability关注的系统配置集合。当已关注的配置发生变更后,Ability会收到onConfigurationUpdated回调。取值范围:<br/>mcc:表示IMSI移动设备国家/地区代码(MCC)发生变更。典型场景:检测到SIM并更新MCC。<br/>mnc:IMSI移动设备网络代码(MNC)发生变更。典型场景:检测到SIM并更新MNC。<br/>locale:表示语言区域发生变更。典型场景:用户已为设备文本的文本显示选择新的语言类型。<br/>layout:表示屏幕布局发生变更。典型场景:当前有不同的显示形态都处于活跃状态。<br/>fontSize:表示字号发生变更。典型场景:用户已设置新的全局字号。<br/>orientation:表示屏幕方向发生变更。典型场景:用户旋转设备。<br/>density:表示显示密度发生变更。典型场景:用户可能指定不同的显示比例,或当前有不同的显示形态同时处于活跃状态。<br/>size:显示窗口大小发生变更。<br/>smallestSize:显示窗口较短边的边长发生变更。<br/>colorMode:颜色模式发生变更。 | 字符串数组 | 可缺省,缺省为空。 |
| mission | 标识Ability指定的任务栈。该标签仅适用于page类型的Ability。默认情况下应用中所有Ability同属一个任务栈。 | 字符串 | 可缺省,缺省为应用的包名。 |
| targetAbility | 标识当前Ability重用的目标Ability。该标签仅适用于page类型的Ability。如果配置了targetAbility属性,则当前Ability(即别名Ability)的属性中仅name、icon、label、visible、permissions、skills生效,其他属性均沿用targetAbility中的属性值。目标Ability必须与别名Ability在同一应用中,且在配置文件中目标Ability必须在别名之前进行声明。 | 字符串 | 可缺省,缺省值为空。表示当前Ability不是一个别名Ability。 |
| formsEnabled | 标识Ability是否支持卡片(forms)功能。该标签仅适用于page类型的Ability。<br/>true:支持卡片能力。<br/>false:不支持卡片能力。 | 布尔值 | 可缺省,缺省值为false。 |
| forms | 标识服务卡片的属性。该标签仅当formsEnabled为"true"时,才能生效。 | 对象数组 | 可缺省,缺省值为空。 |
| srcLanguage | Ability开发语言的类型,开发者创建工程时由开发者手动选择开发语言。 | 字符串 | 可缺省,缺省值为“js”。 |
| srcPath | 该标签标识Ability对应的JS组件代码路径,该标签最大长度为127字节。 | 字符串 | 不可缺省。 |
| uriPermission | 标识该Ability有权访问的应用程序数据。此属性由模式和路径子属性组成。此属性仅对类型提供者的能力有效。 | 对象 | 可缺省,缺省值为空。 |
| startWindowIcon | 标识该Ability启动页面图标资源文件的索引。该标签仅适用于page类型的Ability。取值示例:$media:icon。 | 字符串 | 可缺省,缺省值为空。 |
| startWindowBackground | 标识该Ability启动页面背景颜色资源文件的索引。该标签仅适用于page类型的Ability。取值示例:$color:red。 | 字符串 | 可缺省,缺省值为空。 |
| removeMissionAfterTerminate | 该标签标识Ability销毁后是否从任务列表中移除任务。该标签仅适用于page类型的Ability。true表示销毁后移除任务,&nbsp;false表示销毁后不移除任务。 | 布尔值 | 可缺省,缺省值为false。 |
OpenHarmony系统对无图标应用严格管控。如果HAP中没有配置入口图标,那么系统会给该应用创建一个默认的图标显示在桌面上;<br>
用户点击该图标,将跳转到Settings的应用管理中对应的应用详情页面(图1)中。<br>
如果应用想要隐藏入口图标,需要配置AllowAppDesktopIconHide应用特权,具体配置方式参考[应用特权配置指南](../../device-dev/subsystems/subsys-app-privilege-config-guide.md)
**场景说明:** 该功能能防止一些恶意应用,故意配置无入口图标,导致用户找不到软件所在的位置,无法操作卸载应用,在一定程度上保证用户的手机安全 **OpenHarmony中不允许应用隐藏入口图标**
OpenHarmony系统对无图标应用严格管控,防止一些恶意应用故意配置无入口图标,导致用户找不到软件所在的位置,无法操作卸载应用,在一定程度上保证用户的手机安全。
**入口图标的设置:** 需要在配置文件(config.json)中abilities配置下设置icon,label以及skills,而且skills的配置下必须同时包含“ohos.want.action.home” 和 “entity.system.home”: **入口图标的设置:** 需要在配置文件(config.json)中abilities配置下设置icon,label以及skills,而且skills的配置下必须同时包含“ohos.want.action.home” 和 “entity.system.home”。
``` ```
{ {
"module":{ "module":{
...@@ -222,72 +253,32 @@ OpenHarmony系统对无图标应用严格管控。如果HAP中没有配置入口 ...@@ -222,72 +253,32 @@ OpenHarmony系统对无图标应用严格管控。如果HAP中没有配置入口
} }
``` ```
**入口图标及入口标签的显示规则** 如果应用确需隐藏入口图标,需要配置AllowAppDesktopIconHide应用特权,具体配置方式参考[应用特权配置指南](../../device-dev/subsystems/subsys-app-privilege-config-guide.md)。详细的入口图标及入口标签的显示规则如下。
* HAP中包含Page类型的PageAbility * HAP中包含Page类型的PageAbility
* 配置文件(config.json)中abilities配置中设置了入口图标 * 配置文件(config.json)中abilities配置中设置了入口图标
* 该应用没有隐藏图标的特权 * 该应用没有隐藏图标的特权
* 显示桌面图标为该PageAbility配置的图标 * 系统将使用该PageAbility配置的icon作为入口图标,并显示在桌面上。用户点击该图标,页面跳转到该PageAbility首页。
* 显示桌面Label为该PageAbility配置的Label(如果没有配置Label,返回包名) * 系统将使用该PageAbility配置的label作为入口标签,并显示在桌面上(如果没有配置label,返回包名)。
* 显示组件名为该PageAbility的组件名
* 用户点击该桌面图标,页面跳转到该PageAbility首页
* 该应用具有隐藏图标的特权 * 该应用具有隐藏图标的特权
* 桌面查询时不返回应用信息,不会在桌面上显示对应的图标 * 桌面查询时不返回应用信息,不会在桌面上显示对应的入口图标和标签
* 配置文件(config.json)中abilities配置中未设置入口图标 * 配置文件(config.json)中abilities配置中未设置入口图标
* 该应用没有隐藏图标的特权 * 该应用没有隐藏图标的特权
* 显示桌面图标为系统默认图标 * 系统将使用系统默认图标作为入口图标,并显示在桌面上。用户点击该图标,页面跳转到应用管理中对应的应用详情页面(参考下图)。
* 显示桌面Label为该应用的包名 * 系统将使用应用的包名作为入口标签,并显示在桌面上。
* 用户点击该桌面图标,页面跳转到该应用的详情页面(图1)
* 该应用具有隐藏图标的特权 * 该应用具有隐藏图标的特权
* 桌面查询时不返回应用信息,不会在桌面上显示对应的图标 * 桌面查询时不返回应用信息,不会在桌面上显示对应的入口图标和标签
* HAP中不包含Page类型的PageAbility * HAP中不包含Page类型的PageAbility
* 该应用没有隐藏图标的特权 * 该应用没有隐藏图标的特权
* 显示桌面图标为系统默认图标 * 系统将使用系统默认图标作为入口图标,并显示在桌面上。用户点击该图标,页面跳转到应用管理中对应的应用详情页面(参考下图)。
* 显示桌面Label为该应用的包名 * 系统将使用应用的包名作为入口标签,并显示在桌面上。
* 用户点击该桌面图标,页面跳转到该应用的详情页面(图1)
* 该应用具有隐藏图标的特权 * 该应用具有隐藏图标的特权
* 桌面查询时不返回应用信息,不会在桌面上显示对应的图标 * 桌面查询时不返回应用信息,不会在桌面上显示对应的入口图标和标签
注:应用详情页面(图1)中显示的label可能与桌面上显示的不同。如果非Page类型的PageAbility配置了入口图标和label,那么详情页中显示的即为配置的。<br><br> **图1** 应用的详情页示意图
图1
![应用的详情页例图](figures/application_details.jpg) ![应用的详情页例图](figures/application_details.jpg)
注:应用详情页面中显示的label可能与桌面上显示的不同。如果非Page类型的PageAbility配置了入口图标和label,那么详情页中显示的即为配置的。<br>
**表8** **abilities对象的内部结构说明**
| 属性名称 | 含义 | 数据类型 | 是否可缺省 |
| -------- | -------- | -------- | -------- |
| process | 运行应用程序或Ability的进程名称。如果在deviceConfig标记中配置了进程,则应用程序的所有能力都在此进程中运行。您还可以为特定能力设置流程属性,以便该能力可以在此流程中运行。如果此属性设置为与其他应用程序相同的进程名称,则所有这些应用程序可以在同一进程中运行,前提是他们具有相同的联合用户ID和相同的签名。该标签最大字节数为31个字节。 | 字符串 | 可缺省,缺省值为空。 |
| name | 标识Ability名称。取值可采用反向域名方式表示,由包名和类名组成,如"com.example.myapplication.EntryAbility";也可采用"."开头的类名方式表示,如".EntryAbility"。<br/>Ability的名称,需在一个应用的范围内保证唯一。说明:在使用DevEco&nbsp;Studio新建项目时,默认生成首个Ability的配置,即"config.json"中"EntryAbility"的配置。如使用其他IDE工具,可自定义名称。该标签最大长度为127个字节。 | 字符串 | 不可缺省 |
| description | 标识对Ability的描述。取值可以是描述性内容,也可以是对描述性内容的资源索引,以支持多语言。该标签最大长度为255个字节。 | 字符串 | 可缺省,缺省值为空。 |
| icon | 标识Ability图标资源文件的索引。取值示例:$media:ability_icon。如果在该Ability的skills属性中,actions的取值包含&nbsp;"action.system.home",entities取值中包含"entity.system.home",则该Ability的icon将同时作为应用的icon。如果存在多个符合条件的Ability,则取位置靠前的Ability的icon作为应用的icon。<br/>说明:应用的"icon"和"label"是用户可感知配置项,需要区别于当前所有已有的应用"icon"或"label"(至少有一个不同)。 | 字符串 | 可缺省,缺省值为空。 |
| label | 标识Ability对用户显示的名称。取值是对该名称的资源索引,支持多语言,例:$string:ability_label。如果在该Ability的skills属性中,actions的取值包含&nbsp;"action.system.home",entities取值中包含"entity.system.home",则该Ability的label将同时作为应用的label。如果存在多个符合条件的Ability,则取位置靠前的Ability的label作为应用的label。<br/>说明:&nbsp;应用的"icon"和"label"是用户可感知配置项,需要区别于当前所有已有的应用"icon"或"label"(至少有一个不同)。该标签为资源文件中定义的字符串的引用,或以"{}"包括的字符串。该标签最大长度为255个字节。 | 字符串 | 可缺省,缺省值为空。 |
| uri | 标识Ability的统一资源标识符。该标签最大长度为255个字节。 | 字符串 | 可缺省,对于data类型的Ability不可缺省。 |
| launchType | 标识Ability的启动模式,支持"standard"和"singleton"两种模式:<br/>standard:表示该Ability可以有多实例。该模式适用于大多数应用场景。<br/>singleton:表示该Ability在所有任务栈中仅可以有一个实例。例如,具有全局唯一性的呼叫来电界面即采用"singleton"模式。该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。 | 字符串 | 可缺省,缺省值为"singleton"。 |
| visible | 标识Ability是否可以被其他应用调用。<br/>true:可以被其他应用调用。<br/>false:不能被其他应用调用。 | 布尔类型 | 可缺省,缺省值为"false"。 |
| permissions | 标识其他应用的Ability调用此Ability时需要申请的权限集合,一个数组元素为一个权限名称。通常采用反向域名格式(最大255字节),取值为系统预定义的权限。 | 字符串数组 | 可缺省,缺省值为空。 |
|skills | 标识Ability能够接收的want的特征。 | 对象数组 | 可缺省,缺省值为空。 |
| deviceCapability | 标识Ability运行时要求设备具有的能力,采用字符串数组的格式表示。该标签为数组,支持最多配置512个元素,单个元素最大字节长度为64。 | 字符串数组 | 可缺省,缺省值为空。 |
| metaData | 元数据。 | 对象 | 可缺省,缺省值为空。 |
| type | 标识Ability的类型。取值范围如下:<br/>page:表示基于Page模板开发的FA,用于提供与用户交互的能力。<br/>service:表示基于Service模板开发的PA,用于提供后台运行任务的能力。<br/>data:表示基于Data模板开发的PA,用于对外部提供统一的数据访问对象。<br/>CA:表示支持其他应用以窗口方式调起该Ability。 | 字符串 | 不可缺省。 |
| orientation | 标识该Ability的显示模式。该标签仅适用于page类型的Ability。取值范围如下:<br/>unspecified:由系统自动判断显示方向。<br/>landscape:横屏模式。<br/>portrait:竖屏模式。<br/>followRecent:跟随栈中最近的应用。 | 字符串 | 可缺省,缺省值为"unspecified"。 |
| backgroundModes | 标识后台服务的类型,可以为一个服务配置多个后台服务类型。该标签仅适用于service类型的Ability。取值范围如下:<br/>dataTransfer:通过网络/对端设备进行数据下载、备份、分享、传输等业务。<br/>audioPlayback:音频输出业务。<br/>audioRecording:音频输入业务。<br/>pictureInPicture:画中画、小窗口播放视频业务。<br/>voip:音视频电话、VOIP业务。<br/>location:定位、导航业务。<br/>bluetoothInteraction:蓝牙扫描、连接、传输业务。<br/>wifiInteraction:WLAN扫描、连接、传输业务。<br/>screenFetch:录屏、截屏业务。<br/>multiDeviceConnection:多设备互联业务 | 字符串数组 | 可缺省,缺省值为空。 |
| grantPermission | 指定是否可以向Ability内任何数据授予权限。 | 布尔值 | 可缺省,缺省值为空。 |
| readPermission | 标识读取Ability的数据所需的权限。该标签仅适用于data类型的Ability。取值为长度不超过255字节的字符串。该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。 | 字符串 | 可缺省,缺省为空。 |
| writePermission | 标识向Ability写数据所需的权限。该标签仅适用于data类型的Ability。取值为长度不超过255字节的字符串。 | 字符串 | 可缺省,缺省为空。 |
| configChanges | 标识Ability关注的系统配置集合。当已关注的配置发生变更后,Ability会收到onConfigurationUpdated回调。取值范围:<br/>mcc:表示IMSI移动设备国家/地区代码(MCC)发生变更。典型场景:检测到SIM并更新MCC。<br/>mnc:IMSI移动设备网络代码(MNC)发生变更。典型场景:检测到SIM并更新MNC。<br/>locale:表示语言区域发生变更。典型场景:用户已为设备文本的文本显示选择新的语言类型。<br/>layout:表示屏幕布局发生变更。典型场景:当前有不同的显示形态都处于活跃状态。<br/>fontSize:表示字号发生变更。典型场景:用户已设置新的全局字号。<br/>orientation:表示屏幕方向发生变更。典型场景:用户旋转设备。<br/>density:表示显示密度发生变更。典型场景:用户可能指定不同的显示比例,或当前有不同的显示形态同时处于活跃状态。<br/>size:显示窗口大小发生变更。<br/>smallestSize:显示窗口较短边的边长发生变更。<br/>colorMode:颜色模式发生变更。 | 字符串数组 | 可缺省,缺省为空。 |
| mission | 标识Ability指定的任务栈。该标签仅适用于page类型的Ability。默认情况下应用中所有Ability同属一个任务栈。 | 字符串 | 可缺省,缺省为应用的包名。 |
| targetAbility | 标识当前Ability重用的目标Ability。该标签仅适用于page类型的Ability。如果配置了targetAbility属性,则当前Ability(即别名Ability)的属性中仅name、icon、label、visible、permissions、skills生效,其他属性均沿用targetAbility中的属性值。目标Ability必须与别名Ability在同一应用中,且在配置文件中目标Ability必须在别名之前进行声明。 | 字符串 | 可缺省,缺省值为空。表示当前Ability不是一个别名Ability。 |
| formsEnabled | 标识Ability是否支持卡片(forms)功能。该标签仅适用于page类型的Ability。<br/>true:支持卡片能力。<br/>false:不支持卡片能力。 | 布尔值 | 可缺省,缺省值为false。 |
| forms | 标识服务卡片的属性。该标签仅当formsEnabled为"true"时,才能生效。 | 对象数组 | 可缺省,缺省值为空。 |
| srcLanguage | Ability开发语言的类型,开发者创建工程时由开发者手动选择开发语言。 | 字符串 | 可缺省,缺省值为“js”。 |
| srcPath | 该标签标识Ability对应的JS组件代码路径,该标签最大长度为127字节。 | 字符串 | 不可缺省。 |
| uriPermission | 标识该Ability有权访问的应用程序数据。此属性由模式和路径子属性组成。此属性仅对类型提供者的能力有效。 | 对象 | 可缺省,缺省值为空。 |
| startWindowIcon | 标识该Ability启动页面图标资源文件的索引。该标签仅适用于page类型的Ability。取值示例:$media:icon。 | 字符串 | 可缺省,缺省值为空。 |
| startWindowBackground | 标识该Ability启动页面背景颜色资源文件的索引。该标签仅适用于page类型的Ability。取值示例:$color:red。 | 字符串 | 可缺省,缺省值为空。 |
| removeMissionAfterTerminate | 该标签标识Ability销毁后是否从任务列表中移除任务。该标签仅适用于page类型的Ability。true表示销毁后移除任务,&nbsp;false表示销毁后不移除任务。 | 布尔值 | 可缺省,缺省值为false。 |
## uriPermission对象的内部结构 ## uriPermission对象的内部结构
**表9** **uriPermission对象的内部结构说明** **表9** **uriPermission对象的内部结构说明**
......
...@@ -120,6 +120,7 @@ ...@@ -120,6 +120,7 @@
- [@ohos.events.emitter (Emitter)](js-apis-emitter.md) - [@ohos.events.emitter (Emitter)](js-apis-emitter.md)
- [@ohos.notificationManager (NotificationManager模块)(推荐)](js-apis-notificationManager.md) - [@ohos.notificationManager (NotificationManager模块)(推荐)](js-apis-notificationManager.md)
- [@ohos.notificationSubscribe (NotificationSubscribe模块)(推荐)](js-apis-notificationSubscribe.md) - [@ohos.notificationSubscribe (NotificationSubscribe模块)(推荐)](js-apis-notificationSubscribe.md)
- [@ohos.application.StaticSubscriberExtensionContext (NotificationSubscribe模块)(推荐)](js-apis-application-StaticSubscriberExtensionContext.md)
- [系统公共事件定义 (待停用)](commonEvent-definitions.md) - [系统公共事件定义 (待停用)](commonEvent-definitions.md)
- [@ohos.commonEvent (公共事件模块)(待停用)](js-apis-commonEvent.md) - [@ohos.commonEvent (公共事件模块)(待停用)](js-apis-commonEvent.md)
- [@ohos.notification (Notification模块)(待停用)](js-apis-notification.md) - [@ohos.notification (Notification模块)(待停用)](js-apis-notification.md)
......
...@@ -7,6 +7,12 @@ ...@@ -7,6 +7,12 @@
> 本模块首批接口从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > 本模块首批接口从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> 本模块接口仅可在Stage模型下使用。 > 本模块接口仅可在Stage模型下使用。
## 导入模块
```ts
import Ability from '@ohos.app.ability.Ability';
```
## Ability.onConfigurationUpdate ## Ability.onConfigurationUpdate
onConfigurationUpdate(newConfig: Configuration): void; onConfigurationUpdate(newConfig: Configuration): void;
......
...@@ -30,7 +30,7 @@ import AbilityConstant from '@ohos.app.ability.AbilityConstant'; ...@@ -30,7 +30,7 @@ import AbilityConstant from '@ohos.app.ability.AbilityConstant';
Ability初次启动原因,该类型为枚举,可配合[Ability](js-apis-app-ability-uiAbility.md)[onCreate(want, launchParam)](js-apis-app-ability-uiAbility.md#uiabilityoncreate)方法根据launchParam.launchReason的不同类型执行相应操作。 Ability初次启动原因,该类型为枚举,可配合[Ability](js-apis-app-ability-uiAbility.md)[onCreate(want, launchParam)](js-apis-app-ability-uiAbility.md#uiabilityoncreate)方法根据launchParam.launchReason的不同类型执行相应操作。
**系统能力**以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core **系统能力**:SystemCapability.Ability.AbilityRuntime.Core
| 名称 | 值 | 说明 | | 名称 | 值 | 说明 |
| ----------------------------- | ---- | ------------------------------------------------------------ | | ----------------------------- | ---- | ------------------------------------------------------------ |
...@@ -59,7 +59,7 @@ class MyAbility extends UIAbility { ...@@ -59,7 +59,7 @@ class MyAbility extends UIAbility {
Ability上次退出原因,该类型为枚举,可配合[Ability](js-apis-app-ability-uiAbility.md)[onCreate(want, launchParam)](js-apis-app-ability-uiAbility.md#uiabilityoncreate)方法根据launchParam.lastExitReason的不同类型执行相应操作。 Ability上次退出原因,该类型为枚举,可配合[Ability](js-apis-app-ability-uiAbility.md)[onCreate(want, launchParam)](js-apis-app-ability-uiAbility.md#uiabilityoncreate)方法根据launchParam.lastExitReason的不同类型执行相应操作。
**系统能力**以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core **系统能力**:SystemCapability.Ability.AbilityRuntime.Core
| 名称 | 值 | 说明 | | 名称 | 值 | 说明 |
| ----------------------------- | ---- | ------------------------------------------------------------ | | ----------------------------- | ---- | ------------------------------------------------------------ |
...@@ -85,7 +85,7 @@ class MyAbility extends UIAbility { ...@@ -85,7 +85,7 @@ class MyAbility extends UIAbility {
Ability迁移结果,该类型为枚举,可配合[Ability](js-apis-app-ability-uiAbility.md)[onContinue(wantParam)](js-apis-app-ability-uiAbility.md#uiabilityoncontinue)方法进完成相应的返回。 Ability迁移结果,该类型为枚举,可配合[Ability](js-apis-app-ability-uiAbility.md)[onContinue(wantParam)](js-apis-app-ability-uiAbility.md#uiabilityoncontinue)方法进完成相应的返回。
**系统能力**以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core **系统能力**:SystemCapability.Ability.AbilityRuntime.Core
| 名称 | 值 | 说明 | | 名称 | 值 | 说明 |
| ----------------------------- | ---- | ------------------------------------------------------------ | | ----------------------------- | ---- | ------------------------------------------------------------ |
......
...@@ -412,7 +412,7 @@ acquireShareData(missionId: number, callback: AsyncCallback<{[key: string]: Obje ...@@ -412,7 +412,7 @@ acquireShareData(missionId: number, callback: AsyncCallback<{[key: string]: Obje
```ts ```ts
import abilityManager from '@ohos.app.ability.abilityManager'; import abilityManager from '@ohos.app.ability.abilityManager';
abilityManager.acquireShareData(1, (err, wantParam) => { abilityManager.acquireShareData(1, (err, data) => {
if (err) { if (err) {
console.error(`acquireShareData fail, err: ${JSON.stringify(err)}`); console.error(`acquireShareData fail, err: ${JSON.stringify(err)}`);
} else { } else {
...@@ -449,7 +449,7 @@ acquireShareData(missionId: number): Promise<{[key: string]: Object}>; ...@@ -449,7 +449,7 @@ acquireShareData(missionId: number): Promise<{[key: string]: Object}>;
```ts ```ts
import abilityManager from '@ohos.app.ability.abilityManager'; import abilityManager from '@ohos.app.ability.abilityManager';
try { try {
abilityManager.acquireShareData(1).then((wantParam) => { abilityManager.acquireShareData(1).then((data) => {
console.log(`acquireShareData success, data: ${JSON.stringify(data)}`); console.log(`acquireShareData success, data: ${JSON.stringify(data)}`);
}).catch((err) => { }).catch((err) => {
console.error(`acquireShareData fail, err: ${JSON.stringify(err)}`); console.error(`acquireShareData fail, err: ${JSON.stringify(err)}`);
......
...@@ -669,7 +669,11 @@ killProcessWithAccount(bundleName: string, accountId: number): Promise\<void\> ...@@ -669,7 +669,11 @@ killProcessWithAccount(bundleName: string, accountId: number): Promise\<void\>
切断account进程(Promise形式)。 切断account进程(Promise形式)。
**需要权限**:ohos.permission.CLEAN_BACKGROUND_PROCESSES,ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS,当accountId为当前用户时,不需要校验ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS权限。 > **说明:**
>
> 当accountId为当前用户时,不需要校验ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS权限。
**需要权限**:ohos.permission.CLEAN_BACKGROUND_PROCESSES,ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
**系统能力**:SystemCapability.Ability.AbilityRuntime.Core **系统能力**:SystemCapability.Ability.AbilityRuntime.Core
...@@ -715,12 +719,16 @@ killProcessWithAccount(bundleName: string, accountId: number, callback: AsyncCal ...@@ -715,12 +719,16 @@ killProcessWithAccount(bundleName: string, accountId: number, callback: AsyncCal
切断account进程(callback形式)。 切断account进程(callback形式)。
> **说明:**
>
> 当accountId为当前用户时,不需要校验ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS权限。
**需要权限**:ohos.permission.CLEAN_BACKGROUND_PROCESSES,ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
**系统能力**:SystemCapability.Ability.AbilityRuntime.Core **系统能力**:SystemCapability.Ability.AbilityRuntime.Core
**系统API**: 此接口为系统接口,三方应用不支持调用。 **系统API**: 此接口为系统接口,三方应用不支持调用。
**需要权限**:ohos.permission.CLEAN_BACKGROUND_PROCESSES,ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS,当accountId为当前用户时,不需要校验ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS权限。
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
......
...@@ -173,9 +173,17 @@ saveAppState(context?: UIAbilityContext): boolean; ...@@ -173,9 +173,17 @@ saveAppState(context?: UIAbilityContext): boolean;
```ts ```ts
import appRecovery from '@ohos.app.ability.appRecovery'; import appRecovery from '@ohos.app.ability.appRecovery';
onBackground() { let observer = {
hilog.info(0x0000, '[demo]', '%{public}s', 'EntryAbility onBackground'); onUnhandledException(errorMsg) {
appRecovery.saveAppState(this.context) console.log('onUnhandledException, errorMsg: ', errorMsg);
appRecovery.saveAppState(this.context);
}
};
try {
errorManager.on('error', observer);
} catch (paramError) {
console.error('error: ${paramError.code}, ${paramError.message}');
} }
``` ```
......
...@@ -6,6 +6,12 @@ ...@@ -6,6 +6,12 @@
> >
> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块
```ts
import Configuration from '@ohos.app.ability.Configuration';
```
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityBase **系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityBase
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
......
...@@ -22,7 +22,7 @@ getId(uri: string): number ...@@ -22,7 +22,7 @@ getId(uri: string): number
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | --------------------------- | | ---- | ------ | ---- | --------------------------- |
| uri | string | 是 | 表示uri对象。 | | uri | string | 是 | 表示uri对象。 |
...@@ -55,7 +55,7 @@ attachId(uri: string, id: number): string ...@@ -55,7 +55,7 @@ attachId(uri: string, id: number): string
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | --------------------------- | | ---- | ------ | ---- | --------------------------- |
| uri | string | 是 | 表示uri对象。 | | uri | string | 是 | 表示uri对象。 |
| id | number | 是 | 表示要附加的ID。 | | id | number | 是 | 表示要附加的ID。 |
...@@ -94,7 +94,7 @@ deleteId(uri: string): string ...@@ -94,7 +94,7 @@ deleteId(uri: string): string
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | --------------------------- | | ---- | ------ | ---- | --------------------------- |
| uri | string | 是 | 表示要从中删除ID的uri对象。 | | uri | string | 是 | 表示要从中删除ID的uri对象。 |
...@@ -128,7 +128,7 @@ updateId(uri: string, id: number): string ...@@ -128,7 +128,7 @@ updateId(uri: string, id: number): string
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | ------------------- | | ---- | ------ | ---- | ------------------- |
| uri | string | 是 | 表示uri对象 | | uri | string | 是 | 表示uri对象 |
| id | number | 是 | 表示要更新的ID | | id | number | 是 | 表示要更新的ID |
......
...@@ -24,7 +24,7 @@ getRequestInfo(want: Want): RequestInfo ...@@ -24,7 +24,7 @@ getRequestInfo(want: Want): RequestInfo
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | --------------------------- | | ---- | ------ | ---- | --------------------------- |
| want | [Want](js-apis-application-want.md) | 是 | 表示发起方请求弹框时传入的want信息。 | | want | [Want](js-apis-application-want.md) | 是 | 表示发起方请求弹框时传入的want信息。 |
...@@ -41,32 +41,71 @@ getRequestInfo(want: Want): RequestInfo ...@@ -41,32 +41,71 @@ getRequestInfo(want: Want): RequestInfo
import rpc from '@ohos.rpc'; import rpc from '@ohos.rpc';
import dialogRequest from '@ohos.app.ability.dialogRequest'; import dialogRequest from '@ohos.app.ability.dialogRequest';
export default class ServiceExtAbility extends ServiceExtensionAbility { const REQUEST_VALUE = 1;
onCreate(want) {
console.info(TAG, `onCreate, want: ${want.abilityName}`);
}
onRequest(want, startId) { class StubTest extends rpc.RemoteObject {
console.info(TAG, `onRequest, want: ${want.abilityName}`); constructor(des) {
try { super(des);
var requestInfo = dialogRequest.getRequestInfo(want); }
} catch(err) {
console.error('getRequestInfo err= ${JSON.stringify(err)}'); onRemoteRequest(code, data, reply, option) {
if (code === REQUEST_VALUE) {
let optFir = data.readInt();
let optSec = data.readInt();
reply.writeInt(optFir + optSec);
} }
} return true;
}
queryLocallInterface(descriptor) {
return null;
}
getInterfaceDescriptor() {
return "";
}
getCallingPid() {
return REQUEST_VALUE;
}
getCallingUid() {
return REQUEST_VALUE;
}
attachLocalInterface(localInterface, descriptor) {
}
}
let TAG = "getRequestInfoTest";
export default class ServiceExtAbility extends ServiceExtensionAbility {
onCreate(want) {
console.info(TAG, `onCreate, want: ${want.abilityName}`);
}
onRequest(want, startId) {
console.info(TAG, `onRequest, want: ${want.abilityName}`);
try {
var requestInfo = dialogRequest.getRequestInfo(want);
} catch (err) {
console.error('getRequestInfo err= ${JSON.stringify(err)}');
}
}
onConnect(want) { onConnect(want) {
console.info(TAG, `onConnect, want: ${want.abilityName}`); console.info(TAG, `onConnect, want: ${want.abilityName}`);
} return new StubTest("test");
}
onDisconnect(want) { onDisconnect(want) {
console.info(TAG, `onDisconnect, want: ${want.abilityName}`); console.info(TAG, `onDisconnect, want: ${want.abilityName}`);
} }
onDestroy() { onDestroy() {
console.info(TAG, `onDestroy`); console.info(TAG, `onDestroy`);
} }
} }
``` ```
## dialogRequest.getRequestCallback ## dialogRequest.getRequestCallback
...@@ -79,7 +118,7 @@ getRequestCallback(want: Want): RequestCallback ...@@ -79,7 +118,7 @@ getRequestCallback(want: Want): RequestCallback
**参数:** **参数:**
| 名称 | 类型 | 必填 | 描述 | | 参数名 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | --------------------------- | | ---- | ------ | ---- | --------------------------- |
| want | [Want](js-apis-application-want.md) | 是 | 表示发起方请求弹框时传入的want信息。 | | want | [Want](js-apis-application-want.md) | 是 | 表示发起方请求弹框时传入的want信息。 |
...@@ -95,6 +134,44 @@ getRequestCallback(want: Want): RequestCallback ...@@ -95,6 +134,44 @@ getRequestCallback(want: Want): RequestCallback
import ServiceExtensionAbility from '@ohos.app.ability.ServiceExtensionAbility'; import ServiceExtensionAbility from '@ohos.app.ability.ServiceExtensionAbility';
import rpc from '@ohos.rpc'; import rpc from '@ohos.rpc';
import dialogRequest from '@ohos.app.ability.dialogRequest'; import dialogRequest from '@ohos.app.ability.dialogRequest';
let TAG = "getRequestCallbackTest";
const REQUEST_VALUE = 1;
class StubTest extends rpc.RemoteObject {
constructor(des) {
super(des);
}
onRemoteRequest(code, data, reply, option) {
if (code === REQUEST_VALUE) {
let optFir = data.readInt();
let optSec = data.readInt();
reply.writeInt(optFir + optSec);
}
return true;
}
queryLocallInterface(descriptor) {
return null;
}
getInterfaceDescriptor() {
return "";
}
getCallingPid() {
return REQUEST_VALUE;
}
getCallingUid() {
return REQUEST_VALUE;
}
attachLocalInterface(localInterface, descriptor) {
}
}
export default class ServiceExtAbility extends ServiceExtensionAbility { export default class ServiceExtAbility extends ServiceExtensionAbility {
onCreate(want) { onCreate(want) {
...@@ -112,6 +189,7 @@ getRequestCallback(want: Want): RequestCallback ...@@ -112,6 +189,7 @@ getRequestCallback(want: Want): RequestCallback
onConnect(want) { onConnect(want) {
console.info(TAG, `onConnect, want: ${want.abilityName}`); console.info(TAG, `onConnect, want: ${want.abilityName}`);
return new StubTest("test");
} }
onDisconnect(want) { onDisconnect(want) {
...@@ -127,7 +205,7 @@ getRequestCallback(want: Want): RequestCallback ...@@ -127,7 +205,7 @@ getRequestCallback(want: Want): RequestCallback
## RequestInfo ## RequestInfo
表示发起方请求信息,作为窗口绑定模态弹框的入参。 表示发起方请求信息,作为窗口绑定模态弹框的入参。
**系统能力**:SystemCapability.Ability.AbilityRuntime.AbilityCore **系统能力**:SystemCapability.Ability.AbilityRuntime.Core
**示例:** **示例:**
...@@ -136,6 +214,44 @@ getRequestCallback(want: Want): RequestCallback ...@@ -136,6 +214,44 @@ getRequestCallback(want: Want): RequestCallback
import rpc from '@ohos.rpc'; import rpc from '@ohos.rpc';
import dialogRequest from '@ohos.app.ability.dialogRequest'; import dialogRequest from '@ohos.app.ability.dialogRequest';
import window from '@ohos.window'; import window from '@ohos.window';
let TAG = "RequestInfoTest";
const REQUEST_VALUE = 1;
class StubTest extends rpc.RemoteObject {
constructor(des) {
super(des);
}
onRemoteRequest(code, data, reply, option) {
if (code === REQUEST_VALUE) {
let optFir = data.readInt();
let optSec = data.readInt();
reply.writeInt(optFir + optSec);
}
return true;
}
queryLocallInterface(descriptor) {
return null;
}
getInterfaceDescriptor() {
return "";
}
getCallingPid() {
return REQUEST_VALUE;
}
getCallingUid() {
return REQUEST_VALUE;
}
attachLocalInterface(localInterface, descriptor) {
}
}
export default class ServiceExtAbility extends ServiceExtensionAbility { export default class ServiceExtAbility extends ServiceExtensionAbility {
onCreate(want) { onCreate(want) {
...@@ -162,6 +278,8 @@ getRequestCallback(want: Want): RequestCallback ...@@ -162,6 +278,8 @@ getRequestCallback(want: Want): RequestCallback
onConnect(want) { onConnect(want) {
console.info(TAG, `onConnect, want: ${want.abilityName}`); console.info(TAG, `onConnect, want: ${want.abilityName}`);
return new StubTest("test");
} }
onDisconnect(want) { onDisconnect(want) {
...@@ -178,9 +296,9 @@ getRequestCallback(want: Want): RequestCallback ...@@ -178,9 +296,9 @@ getRequestCallback(want: Want): RequestCallback
模态弹框请求结果码。 模态弹框请求结果码。
**系统能力**:SystemCapability.Ability.AbilityRuntime.AbilityCore。 **系统能力**:SystemCapability.Ability.AbilityRuntime.Core
| 名称 | 值 | 说明 | | 参数名 | 值 | 说明 |
| ------------ | ------------------ | ---------------------- | | ------------ | ------------------ | ---------------------- |
| RESULT_OK | 0 | 表示成功。 | | RESULT_OK | 0 | 表示成功。 |
| RESULT_CANCEL | 1 | 表示失败。 | | RESULT_CANCEL | 1 | 表示失败。 |
...@@ -190,7 +308,7 @@ getRequestCallback(want: Want): RequestCallback ...@@ -190,7 +308,7 @@ getRequestCallback(want: Want): RequestCallback
## 属性 ## 属性
**系统能力**:SystemCapability.Ability.AbilityRuntime.AbilityCore **系统能力**:SystemCapability.Ability.AbilityRuntime.Core
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
...@@ -206,7 +324,7 @@ setRequestResult(result: RequestResult): void; ...@@ -206,7 +324,7 @@ setRequestResult(result: RequestResult): void;
设置请求结果 设置请求结果
**系统能力**:SystemCapability.Ability.AbilityRuntime.AbilityCore **系统能力**:SystemCapability.Ability.AbilityRuntime.Core
**参数:** **参数:**
...@@ -228,6 +346,44 @@ setRequestResult(result: RequestResult): void; ...@@ -228,6 +346,44 @@ setRequestResult(result: RequestResult): void;
import ServiceExtensionAbility from '@ohos.app.ability.ServiceExtensionAbility'; import ServiceExtensionAbility from '@ohos.app.ability.ServiceExtensionAbility';
import rpc from '@ohos.rpc'; import rpc from '@ohos.rpc';
import dialogRequest from '@ohos.app.ability.dialogRequest'; import dialogRequest from '@ohos.app.ability.dialogRequest';
let TAG = "setRequestResultTest";
const REQUEST_VALUE = 1;
class StubTest extends rpc.RemoteObject {
constructor(des) {
super(des);
}
onRemoteRequest(code, data, reply, option) {
if (code === REQUEST_VALUE) {
let optFir = data.readInt();
let optSec = data.readInt();
reply.writeInt(optFir + optSec);
}
return true;
}
queryLocallInterface(descriptor) {
return null;
}
getInterfaceDescriptor() {
return "";
}
getCallingPid() {
return REQUEST_VALUE;
}
getCallingUid() {
return REQUEST_VALUE;
}
attachLocalInterface(localInterface, descriptor) {
}
}
export default class ServiceExtAbility extends ServiceExtensionAbility { export default class ServiceExtAbility extends ServiceExtensionAbility {
onCreate(want) { onCreate(want) {
...@@ -249,6 +405,7 @@ setRequestResult(result: RequestResult): void; ...@@ -249,6 +405,7 @@ setRequestResult(result: RequestResult): void;
onConnect(want) { onConnect(want) {
console.info(TAG, `onConnect, want: ${want.abilityName}`); console.info(TAG, `onConnect, want: ${want.abilityName}`);
return new StubTest("test");
} }
onDisconnect(want) { onDisconnect(want) {
......
...@@ -45,8 +45,7 @@ onMemoryLevel(level: AbilityConstant.MemoryLevel): void; ...@@ -45,8 +45,7 @@ onMemoryLevel(level: AbilityConstant.MemoryLevel): void;
**示例:** **示例:**
```ts
```ts
import UIAbility from '@ohos.app.ability.Ability'; import UIAbility from '@ohos.app.ability.Ability';
let callbackId; let callbackId;
...@@ -58,7 +57,7 @@ export default class MyAbility extends UIAbility { ...@@ -58,7 +57,7 @@ export default class MyAbility extends UIAbility {
let environmentCallback = { let environmentCallback = {
onConfigurationUpdated(config){ onConfigurationUpdated(config){
console.log('onConfigurationUpdated config: ${JSON.stringify(config)}'); console.log('onConfigurationUpdated config: ${JSON.stringify(config)}');
} },
onMemoryLevel(level){ onMemoryLevel(level){
console.log('onMemoryLevel level: ${JSON.stringify(level)}'); console.log('onMemoryLevel level: ${JSON.stringify(level)}');
...@@ -81,4 +80,4 @@ export default class MyAbility extends UIAbility { ...@@ -81,4 +80,4 @@ export default class MyAbility extends UIAbility {
}); });
} }
} }
``` ```
\ No newline at end of file \ No newline at end of file
...@@ -311,33 +311,36 @@ getMissionInfo(deviceId: string, missionId: number, callback: AsyncCallback&lt;M ...@@ -311,33 +311,36 @@ getMissionInfo(deviceId: string, missionId: number, callback: AsyncCallback&lt;M
**示例:** **示例:**
```ts ```ts
import missionManager from '@ohos.app.ability.missionManager'; import missionManager from '@ohos.app.ability.missionManager';
let testMissionId = 1; let testMissionId = 1;
try {
let allMissions=await missionManager.getMissionInfos('',10).catch(function(err){console.log(err);});
if (allMissions && allMissions.length > 0) {
testMissionId = allMissions[0].missionId;
}
missionManager.getMissionInfo('', testMissionId, (error, mission) => { missionManager.getMissionInfos('',10)
if (error) { .then((allMissions) => {
try {
if (allMissions && allMissions.length > 0) {
testMissionId = allMissions[0].missionId;
}
missionManager.getMissionInfo('', testMissionId, (error, mission) => {
if (error) {
console.error('getMissionInfo failed, error.code: ${error.code}, error.message: ${error.message}'); console.error('getMissionInfo failed, error.code: ${error.code}, error.message: ${error.message}');
} else { } else {
console.log('mission.missionId = ${mission.missionId}'); console.log('mission.missionId = ${mission.missionId}');
console.log('mission.runningState = ${mission.runningState}'); console.log('mission.runningState = ${mission.runningState}');
console.log('mission.lockedState = ${mission.lockedState}'); console.log('mission.lockedState = ${mission.lockedState}');
console.log('mission.timestamp = ${mission.timestamp}'); console.log('mission.timestamp = ${mission.timestamp}');
console.log('mission.label = ${mission.label}'); console.log('mission.label = ${mission.label}');
console.log('mission.iconPath = ${mission.iconPath}'); console.log('mission.iconPath = ${mission.iconPath}');
}
});
} catch (paramError) {
console.error('error.code: ${paramError.code}, error.message: ${paramError.message}');
} }
}); })
} catch (paramError) { .catch(function(err){console.log(err);});
console.error('error.code: ${paramError.code}, error.message: ${paramError.message}');
}
``` ```
## missionManager.getMissionInfo ## missionManager.getMissionInfo
getMissionInfo(deviceId: string, missionId: number): Promise&lt;MissionInfo&gt;; getMissionInfo(deviceId: string, missionId: number): Promise&lt;MissionInfo&gt;;
...@@ -943,8 +946,8 @@ clearAllMissions(): Promise&lt;void&gt;; ...@@ -943,8 +946,8 @@ clearAllMissions(): Promise&lt;void&gt;;
import missionManager from '@ohos.app.ability.missionManager'; import missionManager from '@ohos.app.ability.missionManager';
try { try {
missionManager.clearAllMissions(bundleName).then(() => { missionManager.clearAllMissions(bundleName).then((data) => {
console.info('clearAllMissions successfully.'); console.info('clearAllMissions successfully. Data: ${JSON.stringify(data)}');
}).catch(err => { }).catch(err => {
console.error('clearAllMissions failed: ${err.message}'); console.error('clearAllMissions failed: ${err.message}');
}); });
......
...@@ -66,7 +66,7 @@ applyQuickFix(hapModuleQuickFixFiles: Array\<string>, callback: AsyncCallback\<v ...@@ -66,7 +66,7 @@ applyQuickFix(hapModuleQuickFixFiles: Array\<string>, callback: AsyncCallback\<v
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------- | | ------- | -------- |
| 18500002 | Copy file failed, maybe not exist or inaccessible. | | 18500002 | The specified quick fix is invalid. It may not exist or inaccessible. |
| 18500008 | Internal error. | | 18500008 | Internal error. |
在打补丁过程中发生的错误,其错误码及错误信息通过公共事件[COMMON_EVENT_QUICK_FIX_APPLY_RESULT](commonEvent-definitions.md#common_event_quick_fix_apply_result9)的参数返回给应用开发者。这部分错误码及错误信息如下: 在打补丁过程中发生的错误,其错误码及错误信息通过公共事件[COMMON_EVENT_QUICK_FIX_APPLY_RESULT](commonEvent-definitions.md#common_event_quick_fix_apply_result9)的参数返回给应用开发者。这部分错误码及错误信息如下:
...@@ -128,7 +128,7 @@ applyQuickFix(hapModuleQuickFixFiles: Array\<string>): Promise\<void>; ...@@ -128,7 +128,7 @@ applyQuickFix(hapModuleQuickFixFiles: Array\<string>): Promise\<void>;
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------- | | ------- | -------- |
| 18500002 | Copy file failed, maybe not exist or inaccessible. | | 18500002 | The specified quick fix is invalid. It may not exist or inaccessible. |
| 18500008 | Internal error. | | 18500008 | Internal error. |
在打补丁过程中发生的错误,其错误码及错误信息通过公共事件[COMMON_EVENT_QUICK_FIX_APPLY_RESULT](commonEvent-definitions.md#common_event_quick_fix_apply_result9)的参数返回给应用开发者。这部分错误码及错误信息如下: 在打补丁过程中发生的错误,其错误码及错误信息通过公共事件[COMMON_EVENT_QUICK_FIX_APPLY_RESULT](commonEvent-definitions.md#common_event_quick_fix_apply_result9)的参数返回给应用开发者。这部分错误码及错误信息如下:
...@@ -181,7 +181,7 @@ getApplicationQuickFixInfo(bundleName: string, callback: AsyncCallback\<Applicat ...@@ -181,7 +181,7 @@ getApplicationQuickFixInfo(bundleName: string, callback: AsyncCallback\<Applicat
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------- | | ------- | -------- |
| 18500001 | The bundle is not exist. | | 18500001 | The specified bundleName is invalid. |
| 18500008 | Internal error. | | 18500008 | Internal error. |
以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) 以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)
...@@ -231,7 +231,7 @@ getApplicationQuickFixInfo(bundleName: string): Promise\<ApplicationQuickFixInfo ...@@ -231,7 +231,7 @@ getApplicationQuickFixInfo(bundleName: string): Promise\<ApplicationQuickFixInfo
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------- | | ------- | -------- |
| 18500001 | The bundle is not exist. | | 18500001 | The specified bundleName is invalid. |
| 18500008 | Internal error. | | 18500008 | Internal error. |
以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) 以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)
......
...@@ -15,11 +15,8 @@ import StartOptions from '@ohos.app.ability.StartOptions'; ...@@ -15,11 +15,8 @@ import StartOptions from '@ohos.app.ability.StartOptions';
## 属性 ## 属性
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core **系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core
**系统API**: 此接口为系统接口,三方应用不支持调用。
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| [windowMode](js-apis-app-ability-abilityConstant.md#abilityconstantwindowmode) | number | 否 | 窗口模式。 | | [windowMode](js-apis-app-ability-abilityConstant.md#abilityconstantwindowmode) | number | 否 | 窗口模式。 |
......
...@@ -371,7 +371,7 @@ call(method: string, data: rpc.Parcelable): Promise&lt;void&gt;; ...@@ -371,7 +371,7 @@ call(method: string, data: rpc.Parcelable): Promise&lt;void&gt;;
| ------- | -------------------------------- | | ------- | -------------------------------- |
| 16200001 | Caller released. The caller has been released. | | 16200001 | Caller released. The caller has been released. |
| 16200002 | Callee invalid. The callee does not exist. | | 16200002 | Callee invalid. The callee does not exist. |
| 16000050 | Internal Error. | | 16000050 | Internal error. |
以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) 以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)
...@@ -452,7 +452,7 @@ callWithResult(method: string, data: rpc.Parcelable): Promise&lt;rpc.MessageSequ ...@@ -452,7 +452,7 @@ callWithResult(method: string, data: rpc.Parcelable): Promise&lt;rpc.MessageSequ
| ------- | -------------------------------- | | ------- | -------------------------------- |
| 16200001 | Caller released. The caller has been released. | | 16200001 | Caller released. The caller has been released. |
| 16200002 | Callee invalid. The callee does not exist. | | 16200002 | Callee invalid. The callee does not exist. |
| 16000050 | Internal Error. | | 16000050 | Internal error. |
以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) 以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)
...@@ -597,9 +597,9 @@ release(): void; ...@@ -597,9 +597,9 @@ release(): void;
} }
``` ```
## Caller.onRemoteStateChange ## Caller.onRemoteStateChange<sup>10+</sup>
onRemoteStateChange(callback: OnRemoteStateChangeCallback): void; onRemoteStateChange(callback: OnRemoteStateChangeCallback): void;
注册协同场景下跨设备组件状态变化监听通知。 注册协同场景下跨设备组件状态变化监听通知。
...@@ -650,7 +650,7 @@ release(): void; ...@@ -650,7 +650,7 @@ release(): void;
## Caller.on ## Caller.on
on(type: 'release', callback: OnReleaseCallback): void; on(type: 'release', callback: OnReleaseCallback): void;
注册通用组件服务端Stub(桩)断开监听通知。 注册通用组件服务端Stub(桩)断开监听通知。
...@@ -667,6 +667,7 @@ release(): void; ...@@ -667,6 +667,7 @@ release(): void;
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| ------- | -------------------------------- | | ------- | -------------------------------- |
| 401 | If the input parameter is not valid parameter. |
| 16200001 | Caller released. The caller has been released. | | 16200001 | Caller released. The caller has been released. |
以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) 以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)
...@@ -712,6 +713,12 @@ off(type: 'release', callback: OnReleaseCallback): void; ...@@ -712,6 +713,12 @@ off(type: 'release', callback: OnReleaseCallback): void;
| type | string | 是 | 监听releaseCall事件,固定为'release'。 | | type | string | 是 | 监听releaseCall事件,固定为'release'。 |
| callback | [OnReleaseCallback](#onreleasecallback) | 是 | 返回off回调结果。 | | callback | [OnReleaseCallback](#onreleasecallback) | 是 | 返回off回调结果。 |
**错误码:**
| 错误码ID | 错误信息 |
| ------- | -------------------------------- |
| 401 | If the input parameter is not valid parameter. |
**示例:** **示例:**
```ts ```ts
...@@ -903,7 +910,7 @@ off(method: string): void; ...@@ -903,7 +910,7 @@ off(method: string): void;
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| (msg: string) | 是 | 否 | function | 调用者注册的侦听器函数接口的原型。 | | (msg: string) | 是 | 否 | function | 调用者注册的侦听器函数接口的原型。 |
## OnRemoteStateChangeCallback ## OnRemoteStateChangeCallback<sup>10+</sup>
(msg: string): void; (msg: string): void;
......
...@@ -26,7 +26,7 @@ import Want from '@ohos.app.ability.Want'; ...@@ -26,7 +26,7 @@ import Want from '@ohos.app.ability.Want';
| entities | Array\<string> | 否 | 表示目标Ability额外的类别信息(如:浏览器、视频播放器)。在隐式Want中是对action字段的补充。在隐式Want中,您可以定义该字段,来过滤匹配Ability类型。 | | entities | Array\<string> | 否 | 表示目标Ability额外的类别信息(如:浏览器、视频播放器)。在隐式Want中是对action字段的补充。在隐式Want中,您可以定义该字段,来过滤匹配Ability类型。 |
| uri | string | 否 | 表示携带的数据,一般配合type使用,指明待处理的数据类型。如果在Want中指定了uri,则Want将匹配指定的Uri信息,包括`scheme``schemeSpecificPart``authority``path`信息。 | | uri | string | 否 | 表示携带的数据,一般配合type使用,指明待处理的数据类型。如果在Want中指定了uri,则Want将匹配指定的Uri信息,包括`scheme``schemeSpecificPart``authority``path`信息。 |
| type | string | 否 | 表示MIME type类型描述,打开文件的类型,主要用于文管打开文件。比如:'text/xml' 、 'image/*'等,MIME定义请参见https://www.iana.org/assignments/media-types/media-types.xhtml?utm_source=ld246.com。 | | type | string | 否 | 表示MIME type类型描述,打开文件的类型,主要用于文管打开文件。比如:'text/xml' 、 'image/*'等,MIME定义请参见https://www.iana.org/assignments/media-types/media-types.xhtml?utm_source=ld246.com。 |
| parameters | {[key: string]: any} | 否 | 表示WantParams描述,由开发者自行决定传入的键值对。默认会携带以下key值:<br />- ohos.aafwk.callerPid:表示拉起方的pid。<br />- ohos.aafwk.param.callerBundleName:表示拉起方的Bundle Name。<br />- ohos.aafwk.param.callerToken:表示拉起方的token。<br />- ohos.aafwk.param.callerUid:表示[BundleInfo](js-apis-bundleManager-bundleInfo.md#bundleinfo-1)中的uid,应用包里应用程序的uid。<br />- component.startup.newRules:表示是否启用新的管控规则。<br />- moduleName:表示拉起方的模块名,该字段的值即使定义成其他字符串,在传递到另一端时会被修改为正确的值。<br />- ohos.dlp.params.sandbox:表示dlp文件才会有。 | | parameters | {[key: string]: any} | 否 | 表示WantParams描述,由开发者自行决定传入的键值对。默认会携带以下key值:<br />- ohos.aafwk.callerPid:表示拉起方的pid。<br />- ohos.aafwk.param.callerBundleName:表示拉起方的Bundle Name。<br />- ohos.aafwk.param.callerToken:表示拉起方的token。<br />- ohos.aafwk.param.callerUid:表示[BundleInfo](js-apis-bundleManager-bundleInfo.md#bundleinfo-1)中的uid,应用包里应用程序的uid。<br />- component.startup.newRules:表示是否启用新的管控规则。<br />- moduleName:表示拉起方的模块名,该字段的值即使定义成其他字符串,在传递到另一端时会被修改为正确的值。<br />- ohos.dlp.params.sandbox:表示dlp文件才会有。<br />- ability.params.backToOtherMissionStack:表示是否支持跨任务链返回。 |
| [flags](js-apis-ability-wantConstant.md#wantconstantflags) | number | 否 | 表示处理Want的方式。默认传数字。<br />例如通过wantConstant.Flags.FLAG_ABILITY_CONTINUATION表示是否以设备间迁移方式启动Ability。 | | [flags](js-apis-ability-wantConstant.md#wantconstantflags) | number | 否 | 表示处理Want的方式。默认传数字。<br />例如通过wantConstant.Flags.FLAG_ABILITY_CONTINUATION表示是否以设备间迁移方式启动Ability。 |
**示例:** **示例:**
...@@ -34,7 +34,8 @@ import Want from '@ohos.app.ability.Want'; ...@@ -34,7 +34,8 @@ import Want from '@ohos.app.ability.Want';
- 基础用法:在UIAbility对象中调用,示例中的context的获取方式请参见[获取UIAbility的上下文信息](../../application-models/uiability-usage.md#获取uiability的上下文信息) - 基础用法:在UIAbility对象中调用,示例中的context的获取方式请参见[获取UIAbility的上下文信息](../../application-models/uiability-usage.md#获取uiability的上下文信息)
```ts ```ts
let context = ...; // UIAbilityContext import common from '@ohos.app.ability.common';
let context = getContext(this) as common.UIAbilityContext; // UIAbilityContext
let want = { let want = {
'deviceId': '', // deviceId为空表示本设备 'deviceId': '', // deviceId为空表示本设备
'bundleName': 'com.example.myapplication', 'bundleName': 'com.example.myapplication',
...@@ -52,7 +53,8 @@ import Want from '@ohos.app.ability.Want'; ...@@ -52,7 +53,8 @@ import Want from '@ohos.app.ability.Want';
* 字符串(String) * 字符串(String)
```ts ```ts
let context = ...; // UIAbilityContext import common from '@ohos.app.ability.common';
let context = getContext(this) as common.UIAbilityContext; // UIAbilityContext
let want = { let want = {
bundleName: 'com.example.myapplication', bundleName: 'com.example.myapplication',
abilityName: 'FuncAbility', abilityName: 'FuncAbility',
...@@ -67,7 +69,8 @@ import Want from '@ohos.app.ability.Want'; ...@@ -67,7 +69,8 @@ import Want from '@ohos.app.ability.Want';
``` ```
* 数字(Number) * 数字(Number)
```ts ```ts
let context = ...; // UIAbilityContext import common from '@ohos.app.ability.common';
let context = getContext(this) as common.UIAbilityContext; // UIAbilityContext
let want = { let want = {
bundleName: 'com.example.myapplication', bundleName: 'com.example.myapplication',
abilityName: 'FuncAbility', abilityName: 'FuncAbility',
...@@ -83,7 +86,8 @@ import Want from '@ohos.app.ability.Want'; ...@@ -83,7 +86,8 @@ import Want from '@ohos.app.ability.Want';
``` ```
* 布尔(Boolean) * 布尔(Boolean)
```ts ```ts
let context = ...; // UIAbilityContext import common from '@ohos.app.ability.common';
let context = getContext(this) as common.UIAbilityContext; // UIAbilityContext
let want = { let want = {
bundleName: 'com.example.myapplication', bundleName: 'com.example.myapplication',
abilityName: 'FuncAbility', abilityName: 'FuncAbility',
...@@ -98,7 +102,8 @@ import Want from '@ohos.app.ability.Want'; ...@@ -98,7 +102,8 @@ import Want from '@ohos.app.ability.Want';
``` ```
* 对象(Object) * 对象(Object)
```ts ```ts
let context = ...; // UIAbilityContext import common from '@ohos.app.ability.common';
let context = getContext(this) as common.UIAbilityContext; // UIAbilityContext
let want = { let want = {
bundleName: 'com.example.myapplication', bundleName: 'com.example.myapplication',
abilityName: 'FuncAbility', abilityName: 'FuncAbility',
...@@ -118,7 +123,8 @@ import Want from '@ohos.app.ability.Want'; ...@@ -118,7 +123,8 @@ import Want from '@ohos.app.ability.Want';
``` ```
* 数组(Array) * 数组(Array)
```ts ```ts
let context = ...; // UIAbilityContext import common from '@ohos.app.ability.common';
let context = getContext(this) as common.UIAbilityContext; // UIAbilityContext
let want = { let want = {
bundleName: 'com.example.myapplication', bundleName: 'com.example.myapplication',
abilityName: 'FuncAbility', abilityName: 'FuncAbility',
...@@ -138,7 +144,8 @@ import Want from '@ohos.app.ability.Want'; ...@@ -138,7 +144,8 @@ import Want from '@ohos.app.ability.Want';
```ts ```ts
import fs from '@ohos.file.fs'; import fs from '@ohos.file.fs';
let context = ...; // UIAbilityContext import common from '@ohos.app.ability.common';
let context = getContext(this) as common.UIAbilityContext; // UIAbilityContext
let fd; let fd;
try { try {
...@@ -160,3 +167,33 @@ import Want from '@ohos.app.ability.Want'; ...@@ -160,3 +167,33 @@ import Want from '@ohos.app.ability.Want';
console.error(`Failed to startAbility. Code: ${err.code}, message: ${err.message}`); console.error(`Failed to startAbility. Code: ${err.code}, message: ${err.message}`);
}); });
``` ```
- parameter参数用法:以ability.params.backToOtherMissionStack为例,ServiceExtension在拉起UIAbility的时候,可以支持跨任务链返回。
```ts
// (1) UIAbility1启动一个ServiceExtension
let context = getContext(this) as common.UIAbilityContext; // UIAbilityContext
let want = {
bundleName: 'com.example.myapplication1',
abilityName: 'ServiceExtensionAbility',
};
context.startAbility(want, (err) => {
console.error(`Failed to startAbility. Code: ${err.code}, message: ${err.message}`);
});
// (2) 该ServiceExtension去启动另一个UIAbility2,并在启动的时候携带参数ability.params.backToOtherMissionStack为true
let context = ...; // ServiceExtensionContext
let want = {
bundleName: 'com.example.myapplication2',
abilityName: 'MainAbility',
parameters: {
"ability.params.backToOtherMissionStack": true,
},
};
context.startAbility(want, (err) => {
console.error(`Failed to startAbility. Code: ${err.code}, message: ${err.message}`);
});
```
说明:上例中,如果ServiceExtension启动UIAbility2时不携带ability.params.backToOtherMissionStack参数,或者携带的ability.params.backToOtherMissionStack参数为false,则UIAbility1和UIAbility2不在同一个任务栈里面,在UIAbility2的界面点back键,不会回到UIAbility1的界面。如果携带的ability.params.backToOtherMissionStack参数为true,则表示支持跨任务链返回,此时在UIAbility2的界面点back键,会回到UIAbility1的界面。
...@@ -118,6 +118,7 @@ getWantAgent(info: WantAgentInfo): Promise\<WantAgent\> ...@@ -118,6 +118,7 @@ getWantAgent(info: WantAgentInfo): Promise\<WantAgent\>
**示例:** **示例:**
```ts ```ts
let wantAgent;
//WantAgentInfo对象 //WantAgentInfo对象
let wantAgentInfo = { let wantAgentInfo = {
wants: [ wants: [
...@@ -1181,7 +1182,7 @@ function getWantAgentCallback(err, data) { ...@@ -1181,7 +1182,7 @@ function getWantAgentCallback(err, data) {
} }
} }
try { try {
WantAgent.getOperationTypeCallback(wantAgent, getOperationTypeCallback); WantAgent.getOperationType(wantAgent, getOperationTypeCallback);
} catch(err) { } catch(err) {
console.error('getOperationTypeCallback failed! ${err.code} ${err.message}'); console.error('getOperationTypeCallback failed! ${err.code} ${err.message}');
} }
......
...@@ -16,6 +16,8 @@ import wantConstant from '@ohos.app.ability.wantConstant'; ...@@ -16,6 +16,8 @@ import wantConstant from '@ohos.app.ability.wantConstant';
want的Params操作的常量。 want的Params操作的常量。
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityBase
| 名称 | 值 | 说明 | | 名称 | 值 | 说明 |
| ----------------------- | ---------------------------------- | ------------------------------------------------------------------------------ | | ----------------------- | ---------------------------------- | ------------------------------------------------------------------------------ |
| DLP_PARAMS_SANDBOX | ohos.dlp.params.sandbox | 指示沙盒标志的参数的操作。<br>**系统API**:该接口为系统接口,三方应用不支持调用。 | | DLP_PARAMS_SANDBOX | ohos.dlp.params.sandbox | 指示沙盒标志的参数的操作。<br>**系统API**:该接口为系统接口,三方应用不支持调用。 |
...@@ -23,10 +25,11 @@ want的Params操作的常量。 ...@@ -23,10 +25,11 @@ want的Params操作的常量。
| DLP_PARAMS_MODULE_NAME | ohos.dlp.params.moduleName | 指示DLP模块名称的参数的操作。 <br>**系统API**:该接口为系统接口,三方应用不支持调用。 | | DLP_PARAMS_MODULE_NAME | ohos.dlp.params.moduleName | 指示DLP模块名称的参数的操作。 <br>**系统API**:该接口为系统接口,三方应用不支持调用。 |
| DLP_PARAMS_ABILITY_NAME | ohos.dlp.params.abilityName | 指示DLP能力名称的参数的操作。 <br>**系统API**:该接口为系统接口,三方应用不支持调用。 | | DLP_PARAMS_ABILITY_NAME | ohos.dlp.params.abilityName | 指示DLP能力名称的参数的操作。 <br>**系统API**:该接口为系统接口,三方应用不支持调用。 |
| DLP_PARAMS_INDEX | ohos.dlp.params.index | 指示DLP索引参数的操作。 <br>**系统API**:该接口为系统接口,三方应用不支持调用。 | | DLP_PARAMS_INDEX | ohos.dlp.params.index | 指示DLP索引参数的操作。 <br>**系统API**:该接口为系统接口,三方应用不支持调用。 |
| ABILITY_RECOVERY_RESTART | ohos.ability.params.abilityRecoveryRestart | 指示当前Ability是否发生了故障恢复重启。 | | ABILITY_BACK_TO_OTHER_MISSION_STACK | ability.params.backToOtherMissionStack | 表示是否支持跨任务链返回。 <br>**系统API**:该接口为系统接口,三方应用不支持调用。 |
| CONTENT_TITLE_KEY | ohos.extra.param.key.contentTitle | 指示原子化服务支持分享标题的参数的操作。 <br>**系统API**:该接口为系统接口,三方应用不支持调用。 | | ABILITY_RECOVERY_RESTART<sup>10+</sup> | ohos.ability.params.abilityRecoveryRestart | 指示当前Ability是否发生了故障恢复重启。 |
| SHARE_ABSTRACT_KEY | ohos.extra.param.key.shareAbstract | 指示原子化服务支持分享内容的参数的操作。 <br>**系统API**:该接口为系统接口,三方应用不支持调用。 | | CONTENT_TITLE_KEY<sup>10+</sup> | ohos.extra.param.key.contentTitle | 指示原子化服务支持分享标题的参数的操作。 |
| SHARE_URL_KEY | ohos.extra.param.key.shareUrl | 指示原子化服务支持分享链接的参数的操作。 <br>**系统API**:该接口为系统接口,三方应用不支持调用。 | | SHARE_ABSTRACT_KEY<sup>10+</sup> | ohos.extra.param.key.shareAbstract | 指示原子化服务支持分享内容的参数的操作。 |
| SHARE_URL_KEY<sup>10+</sup> | ohos.extra.param.key.shareUrl | 指示原子化服务支持分享链接的参数的操作。 |
## wantConstant.Flags ## wantConstant.Flags
......
...@@ -35,14 +35,15 @@ deleteForm(formId: string, callback: AsyncCallback&lt;void&gt;): void ...@@ -35,14 +35,15 @@ deleteForm(formId: string, callback: AsyncCallback&lt;void&gt;): void
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------- | | -------- | -------- |
| 201 | Permissions denied. | | 201 | Permissions denied. |
| 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. | | 401 | If the input parameter is not valid parameter. |
| 16500050 | An IPC connection error happened. | | 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. | | 16500060 | A service connection error happened, please try again later. |
| 202 | The application is not a system application. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
| 16501001 | The ID of the form to be operated does not exist. | | 16501001 | The ID of the form to be operated does not exist. |
| 16501003 | The form can not be operated by the current application. | | 16501003 | The form can not be operated by the current application. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -98,7 +99,8 @@ deleteForm(formId: string): Promise&lt;void&gt; ...@@ -98,7 +99,8 @@ deleteForm(formId: string): Promise&lt;void&gt;
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
| 16501001 | The ID of the form to be operated does not exist. | | 16501001 | The ID of the form to be operated does not exist. |
| 16501003 | The form can not be operated by the current application. | | 16501003 | The form can not be operated by the current application. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**参数:** **参数:**
...@@ -146,7 +148,8 @@ releaseForm(formId: string, callback: AsyncCallback&lt;void&gt;): void ...@@ -146,7 +148,8 @@ releaseForm(formId: string, callback: AsyncCallback&lt;void&gt;): void
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
| 16501001 | The ID of the form to be operated does not exist. | | 16501001 | The ID of the form to be operated does not exist. |
| 16501003 | The form can not be operated by the current application. | | 16501003 | The form can not be operated by the current application. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -195,7 +198,8 @@ releaseForm(formId: string, isReleaseCache: boolean, callback: AsyncCallback&lt; ...@@ -195,7 +198,8 @@ releaseForm(formId: string, isReleaseCache: boolean, callback: AsyncCallback&lt;
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
| 16501001 | The ID of the form to be operated does not exist. | | 16501001 | The ID of the form to be operated does not exist. |
| 16501003 | The form can not be operated by the current application. | | 16501003 | The form can not be operated by the current application. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -249,7 +253,8 @@ releaseForm(formId: string, isReleaseCache?: boolean): Promise&lt;void&gt; ...@@ -249,7 +253,8 @@ releaseForm(formId: string, isReleaseCache?: boolean): Promise&lt;void&gt;
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
| 16501001 | The ID of the form to be operated does not exist. | | 16501001 | The ID of the form to be operated does not exist. |
| 16501003 | The form can not be operated by the current application. | | 16501003 | The form can not be operated by the current application. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -297,7 +302,8 @@ requestForm(formId: string, callback: AsyncCallback&lt;void&gt;): void ...@@ -297,7 +302,8 @@ requestForm(formId: string, callback: AsyncCallback&lt;void&gt;): void
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
| 16501001 | The ID of the form to be operated does not exist. | | 16501001 | The ID of the form to be operated does not exist. |
| 16501003 | The form can not be operated by the current application. | | 16501003 | The form can not be operated by the current application. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -350,7 +356,8 @@ requestForm(formId: string): Promise&lt;void&gt; ...@@ -350,7 +356,8 @@ requestForm(formId: string): Promise&lt;void&gt;
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
| 16501001 | The ID of the form to be operated does not exist. | | 16501001 | The ID of the form to be operated does not exist. |
| 16501003 | The form can not be operated by the current application. | | 16501003 | The form can not be operated by the current application. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -399,7 +406,8 @@ castToNormalForm(formId: string, callback: AsyncCallback&lt;void&gt;): void ...@@ -399,7 +406,8 @@ castToNormalForm(formId: string, callback: AsyncCallback&lt;void&gt;): void
| 16501001 | The ID of the form to be operated does not exist. | | 16501001 | The ID of the form to be operated does not exist. |
| 16501002 | The number of forms exceeds upper bound. | | 16501002 | The number of forms exceeds upper bound. |
| 16501003 | The form can not be operated by the current application. | | 16501003 | The form can not be operated by the current application. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -452,7 +460,8 @@ castToNormalForm(formId: string): Promise&lt;void&gt; ...@@ -452,7 +460,8 @@ castToNormalForm(formId: string): Promise&lt;void&gt;
| 16501001 | The ID of the form to be operated does not exist. | | 16501001 | The ID of the form to be operated does not exist. |
| 16501002 | The number of forms exceeds upper bound. | | 16501002 | The number of forms exceeds upper bound. |
| 16501003 | The form can not be operated by the current application. | | 16501003 | The form can not be operated by the current application. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -498,7 +507,8 @@ notifyVisibleForms(formIds: Array&lt;string&gt;, callback: AsyncCallback&lt;void ...@@ -498,7 +507,8 @@ notifyVisibleForms(formIds: Array&lt;string&gt;, callback: AsyncCallback&lt;void
| 16500050 | An IPC connection error happened. | | 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. | | 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -549,7 +559,8 @@ notifyVisibleForms(formIds: Array&lt;string&gt;): Promise&lt;void&gt; ...@@ -549,7 +559,8 @@ notifyVisibleForms(formIds: Array&lt;string&gt;): Promise&lt;void&gt;
| 16500050 | An IPC connection error happened. | | 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. | | 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -595,7 +606,8 @@ notifyInvisibleForms(formIds: Array&lt;string&gt;, callback: AsyncCallback&lt;vo ...@@ -595,7 +606,8 @@ notifyInvisibleForms(formIds: Array&lt;string&gt;, callback: AsyncCallback&lt;vo
| 16500050 | An IPC connection error happened. | | 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. | | 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -646,7 +658,8 @@ notifyInvisibleForms(formIds: Array&lt;string&gt;): Promise&lt;void&gt; ...@@ -646,7 +658,8 @@ notifyInvisibleForms(formIds: Array&lt;string&gt;): Promise&lt;void&gt;
| 16500050 | An IPC connection error happened. | | 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. | | 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -693,7 +706,8 @@ enableFormsUpdate(formIds: Array&lt;string&gt;, callback: AsyncCallback&lt;void& ...@@ -693,7 +706,8 @@ enableFormsUpdate(formIds: Array&lt;string&gt;, callback: AsyncCallback&lt;void&
| 16500060 | A service connection error happened, please try again later. | | 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
| 16501003 | The form can not be operated by the current application. | | 16501003 | The form can not be operated by the current application. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -745,7 +759,8 @@ enableFormsUpdate(formIds: Array&lt;string&gt;): Promise&lt;void&gt; ...@@ -745,7 +759,8 @@ enableFormsUpdate(formIds: Array&lt;string&gt;): Promise&lt;void&gt;
| 16500060 | A service connection error happened, please try again later. | | 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
| 16501003 | The form can not be operated by the current application. | | 16501003 | The form can not be operated by the current application. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -793,7 +808,8 @@ disableFormsUpdate(formIds: Array&lt;string&gt;, callback: AsyncCallback&lt;void ...@@ -793,7 +808,8 @@ disableFormsUpdate(formIds: Array&lt;string&gt;, callback: AsyncCallback&lt;void
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
| 16501001 | The ID of the form to be operated does not exist. | | 16501001 | The ID of the form to be operated does not exist. |
| 16501003 | The form can not be operated by the current application. | | 16501003 | The form can not be operated by the current application. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -846,7 +862,8 @@ disableFormsUpdate(formIds: Array&lt;string&gt;): Promise&lt;void&gt; ...@@ -846,7 +862,8 @@ disableFormsUpdate(formIds: Array&lt;string&gt;): Promise&lt;void&gt;
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
| 16501001 | The ID of the form to be operated does not exist. | | 16501001 | The ID of the form to be operated does not exist. |
| 16501003 | The form can not be operated by the current application. | | 16501003 | The form can not be operated by the current application. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -885,7 +902,8 @@ isSystemReady(callback: AsyncCallback&lt;void&gt;): void ...@@ -885,7 +902,8 @@ isSystemReady(callback: AsyncCallback&lt;void&gt;): void
| -------- | -------- | | -------- | -------- |
| 202 | The application is not a system application. | | 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. | | 401 | If the input parameter is not valid parameter. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -922,7 +940,8 @@ isSystemReady(): Promise&lt;void&gt; ...@@ -922,7 +940,8 @@ isSystemReady(): Promise&lt;void&gt;
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------- | | -------- | -------- |
| 202 | The application is not a system application. | | 202 | The application is not a system application. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -960,7 +979,8 @@ getAllFormsInfo(callback: AsyncCallback&lt;Array&lt;formInfo.FormInfo&gt;&gt;): ...@@ -960,7 +979,8 @@ getAllFormsInfo(callback: AsyncCallback&lt;Array&lt;formInfo.FormInfo&gt;&gt;):
| 16500050 | An IPC connection error happened. | | 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. | | 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**参数:** **参数:**
...@@ -1005,7 +1025,8 @@ getAllFormsInfo(): Promise&lt;Array&lt;formInfo.FormInfo&gt;&gt; ...@@ -1005,7 +1025,8 @@ getAllFormsInfo(): Promise&lt;Array&lt;formInfo.FormInfo&gt;&gt;
| 16500050 | An IPC connection error happened. | | 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. | | 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**返回值:** **返回值:**
...@@ -1057,7 +1078,8 @@ getFormsInfo(bundleName: string, callback: AsyncCallback&lt;Array&lt;formInfo.Fo ...@@ -1057,7 +1078,8 @@ getFormsInfo(bundleName: string, callback: AsyncCallback&lt;Array&lt;formInfo.Fo
| 16500060 | A service connection error happened, please try again later. | | 16500060 | A service connection error happened, please try again later. |
| 16500100 | Failed to obtain the configuration information. | | 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -1106,7 +1128,8 @@ getFormsInfo(bundleName: string, moduleName: string, callback: AsyncCallback&lt; ...@@ -1106,7 +1128,8 @@ getFormsInfo(bundleName: string, moduleName: string, callback: AsyncCallback&lt;
| 16500060 | A service connection error happened, please try again later. | | 16500060 | A service connection error happened, please try again later. |
| 16500100 | Failed to obtain the configuration information. | | 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -1160,7 +1183,8 @@ getFormsInfo(bundleName: string, moduleName?: string): Promise&lt;Array&lt;formI ...@@ -1160,7 +1183,8 @@ getFormsInfo(bundleName: string, moduleName?: string): Promise&lt;Array&lt;formI
| 16500060 | A service connection error happened, please try again later. | | 16500060 | A service connection error happened, please try again later. |
| 16500100 | Failed to obtain the configuration information. | | 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -1294,7 +1318,8 @@ deleteInvalidForms(formIds: Array&lt;string&gt;, callback: AsyncCallback&lt;numb ...@@ -1294,7 +1318,8 @@ deleteInvalidForms(formIds: Array&lt;string&gt;, callback: AsyncCallback&lt;numb
| 16500050 | An IPC connection error happened. | | 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. | | 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -1347,7 +1372,8 @@ deleteInvalidForms(formIds: Array&lt;string&gt;): Promise&lt;number&gt; ...@@ -1347,7 +1372,8 @@ deleteInvalidForms(formIds: Array&lt;string&gt;): Promise&lt;number&gt;
| 16500050 | An IPC connection error happened. | | 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. | | 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -1394,7 +1420,8 @@ acquireFormState(want: Want, callback: AsyncCallback&lt;formInfo.FormStateInfo&g ...@@ -1394,7 +1420,8 @@ acquireFormState(want: Want, callback: AsyncCallback&lt;formInfo.FormStateInfo&g
| 16500060 | A service connection error happened, please try again later. | | 16500060 | A service connection error happened, please try again later. |
| 16500100 | Failed to obtain the configuration information. | | 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -1457,7 +1484,8 @@ acquireFormState(want: Want): Promise&lt;formInfo.FormStateInfo&gt; ...@@ -1457,7 +1484,8 @@ acquireFormState(want: Want): Promise&lt;formInfo.FormStateInfo&gt;
| 16500060 | A service connection error happened, please try again later. | | 16500060 | A service connection error happened, please try again later. |
| 16500100 | Failed to obtain the configuration information. | | 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -1506,7 +1534,8 @@ on(type: 'formUninstall', callback: Callback&lt;string&gt;): void ...@@ -1506,7 +1534,8 @@ on(type: 'formUninstall', callback: Callback&lt;string&gt;): void
| -------- | -------- | | -------- | -------- |
| 202 | The application is not a system application. | | 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. | | 401 | If the input parameter is not valid parameter. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -1540,7 +1569,8 @@ off(type: 'formUninstall', callback?: Callback&lt;string&gt;): void ...@@ -1540,7 +1569,8 @@ off(type: 'formUninstall', callback?: Callback&lt;string&gt;): void
| -------- | -------- | | -------- | -------- |
| 202 | The application is not a system application. | | 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. | | 401 | If the input parameter is not valid parameter. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -1714,7 +1744,8 @@ notifyFormsVisible(formIds: Array&lt;string&gt;, isVisible: boolean, callback: A ...@@ -1714,7 +1744,8 @@ notifyFormsVisible(formIds: Array&lt;string&gt;, isVisible: boolean, callback: A
| 16500060 | A service connection error happened, please try again later. | | 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
| 16501003 | The form can not be operated by the current application. | | 16501003 | The form can not be operated by the current application. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -1767,7 +1798,8 @@ notifyFormsVisible(formIds: Array&lt;string&gt;, isVisible: boolean): Promise&lt ...@@ -1767,7 +1798,8 @@ notifyFormsVisible(formIds: Array&lt;string&gt;, isVisible: boolean): Promise&lt
| 16500060 | A service connection error happened, please try again later. | | 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
| 16501003 | The form can not be operated by the current application. | | 16501003 | The form can not be operated by the current application. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -1815,7 +1847,8 @@ notifyFormsEnableUpdate(formIds: Array&lt;string&gt;, isEnableUpdate: boolean, c ...@@ -1815,7 +1847,8 @@ notifyFormsEnableUpdate(formIds: Array&lt;string&gt;, isEnableUpdate: boolean, c
| 16500060 | A service connection error happened, please try again later. | | 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
| 16501003 | The form can not be operated by the current application. | | 16501003 | The form can not be operated by the current application. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -1868,7 +1901,8 @@ notifyFormsEnableUpdate(formIds: Array&lt;string&gt;, isEnableUpdate: boolean): ...@@ -1868,7 +1901,8 @@ notifyFormsEnableUpdate(formIds: Array&lt;string&gt;, isEnableUpdate: boolean):
| 16500060 | A service connection error happened, please try again later. | | 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
| 16501003 | The form can not be operated by the current application. | | 16501003 | The form can not be operated by the current application. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -1915,7 +1949,8 @@ shareForm(formId: string, deviceId: string, callback: AsyncCallback&lt;void&gt;) ...@@ -1915,7 +1949,8 @@ shareForm(formId: string, deviceId: string, callback: AsyncCallback&lt;void&gt;)
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
| 16501001 | The ID of the form to be operated does not exist. | | 16501001 | The ID of the form to be operated does not exist. |
| 16501003 | The form can not be operated by the current application. | | 16501003 | The form can not be operated by the current application. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -1969,7 +2004,8 @@ shareForm(formId: string, deviceId: string): Promise&lt;void&gt; ...@@ -1969,7 +2004,8 @@ shareForm(formId: string, deviceId: string): Promise&lt;void&gt;
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
| 16501001 | The ID of the form to be operated does not exist. | | 16501001 | The ID of the form to be operated does not exist. |
| 16501003 | The form can not be operated by the current application. | | 16501003 | The form can not be operated by the current application. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -2017,7 +2053,8 @@ notifyFormsPrivacyProtected(formIds: Array\<string>, isProtected: boolean, callb ...@@ -2017,7 +2053,8 @@ notifyFormsPrivacyProtected(formIds: Array\<string>, isProtected: boolean, callb
| 16500050 | An IPC connection error happened. | | 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. | | 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
| 以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。 | |
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
...@@ -2038,7 +2075,7 @@ try { ...@@ -2038,7 +2075,7 @@ try {
## notifyFormsPrivacyProtected ## notifyFormsPrivacyProtected
function notifyFormsPrivacyProtected(formIds: Array\<string\>, isProtected: boolean): Promise\<void\>; notifyFormsPrivacyProtected(formIds: Array\<string\>, isProtected: boolean): Promise\<void\>;
通知指定卡片隐私保护状态改变。使用Promise异步回调。 通知指定卡片隐私保护状态改变。使用Promise异步回调。
...@@ -2069,7 +2106,8 @@ function notifyFormsPrivacyProtected(formIds: Array\<string\>, isProtected: bool ...@@ -2069,7 +2106,8 @@ function notifyFormsPrivacyProtected(formIds: Array\<string\>, isProtected: bool
| 16500050 | An IPC connection error happened. | | 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. | | 16500060 | A service connection error happened, please try again later. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
| 以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。 | |
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
```ts ```ts
import formHost from '@ohos.app.form.formHost'; import formHost from '@ohos.app.form.formHost';
...@@ -2088,7 +2126,7 @@ try { ...@@ -2088,7 +2126,7 @@ try {
## acquireFormData<sup>10+</sup> ## acquireFormData<sup>10+</sup>
acquireFormData(formId: string, callback: AsyncCallback\<void>): void acquireFormData(formId: string, callback: AsyncCallback<{[key: string]: Object}>): void;
请求卡片提供方数据。使用callback异步回调。 请求卡片提供方数据。使用callback异步回调。
...@@ -2104,8 +2142,6 @@ acquireFormData(formId: string, callback: AsyncCallback\<void>): void ...@@ -2104,8 +2142,6 @@ acquireFormData(formId: string, callback: AsyncCallback\<void>): void
**错误码:** **错误码:**
以下错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------- | | -------- | -------- |
| 16500050 | An IPC connection error happened. | | 16500050 | An IPC connection error happened. |
...@@ -2113,6 +2149,8 @@ acquireFormData(formId: string, callback: AsyncCallback\<void>): void ...@@ -2113,6 +2149,8 @@ acquireFormData(formId: string, callback: AsyncCallback\<void>): void
| 16500100 | Failed to obtain the configuration information. | | 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
```ts ```ts
...@@ -2132,7 +2170,7 @@ try { ...@@ -2132,7 +2170,7 @@ try {
## acquireFormData<sup>10+</sup> ## acquireFormData<sup>10+</sup>
function acquireFormData(formId: string): Promise\<void\>; acquireFormData(formId: string): Promise<{[key: string]: Object}>;
请求卡片提供方数据。使用Promise异步回调。 请求卡片提供方数据。使用Promise异步回调。
...@@ -2154,8 +2192,6 @@ function acquireFormData(formId: string): Promise\<void\>; ...@@ -2154,8 +2192,6 @@ function acquireFormData(formId: string): Promise\<void\>;
**错误码:** **错误码:**
以下错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------- | | -------- | -------- |
| 16500050 | An IPC connection error happened. | | 16500050 | An IPC connection error happened. |
...@@ -2163,6 +2199,8 @@ function acquireFormData(formId: string): Promise\<void\>; ...@@ -2163,6 +2199,8 @@ function acquireFormData(formId: string): Promise\<void\>;
| 16500100 | Failed to obtain the configuration information. | | 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
```ts ```ts
import formHost from '@ohos.app.form.formHost'; import formHost from '@ohos.app.form.formHost';
......
...@@ -18,6 +18,8 @@ import formInfo from '@ohos.app.form.formInfo'; ...@@ -18,6 +18,8 @@ import formInfo from '@ohos.app.form.formInfo';
**系统能力**:SystemCapability.Ability.Form **系统能力**:SystemCapability.Ability.Form
**系统API**: 此接口为系统接口,三方应用不支持调用。
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| ----------- | -------- | -------- | -------------------- | ------------------------------------------------------------ | | ----------- | -------- | -------- | -------------------- | ------------------------------------------------------------ |
| bundleName | string | 是 | 否 | 卡片所属包的Bundle名称。 | | bundleName | string | 是 | 否 | 卡片所属包的Bundle名称。 |
...@@ -100,7 +102,7 @@ import formInfo from '@ohos.app.form.formInfo'; ...@@ -100,7 +102,7 @@ import formInfo from '@ohos.app.form.formInfo';
| HEIGHT_KEY | 'ohos.extra.param.key.form_height' | 卡片高度。 | | HEIGHT_KEY | 'ohos.extra.param.key.form_height' | 卡片高度。 |
| TEMPORARY_KEY | 'ohos.extra.param.key.form_temporary' | 临时卡片。 | | TEMPORARY_KEY | 'ohos.extra.param.key.form_temporary' | 临时卡片。 |
| ABILITY_NAME_KEY | 'ohos.extra.param.key.ability_name' | ability名称。 | | ABILITY_NAME_KEY | 'ohos.extra.param.key.ability_name' | ability名称。 |
| DEVICE_ID_KEY | 'ohos.extra.param.key.device_id' | 设备标识。 | | DEVICE_ID_KEY | 'ohos.extra.param.key.device_id' <br>**系统API**: 此接口为系统接口,三方应用不支持调用。 | 设备标识。 |
| BUNDLE_NAME_KEY | 'ohos.extra.param.key.bundle_name' | 指示指定要获取的捆绑Bundle名称的键。 | | BUNDLE_NAME_KEY | 'ohos.extra.param.key.bundle_name' | 指示指定要获取的捆绑Bundle名称的键。 |
| LAUNCH_REASON_KEY<sup>10+</sup> | 'ohos.extra.param.key.form_launch_reason' | 卡片创建原因。 | | LAUNCH_REASON_KEY<sup>10+</sup> | 'ohos.extra.param.key.form_launch_reason' | 卡片创建原因。 |
| PARAM_FORM_CUSTOMIZE_KEY<sup>10+</sup> | 'ohos.extra.param.key.form_customize' | 自定义数据。 | | PARAM_FORM_CUSTOMIZE_KEY<sup>10+</sup> | 'ohos.extra.param.key.form_customize' | 自定义数据。 |
...@@ -138,6 +140,7 @@ import formInfo from '@ohos.app.form.formInfo'; ...@@ -138,6 +140,7 @@ import formInfo from '@ohos.app.form.formInfo';
| 名称 | 值 | 说明 | | 名称 | 值 | 说明 |
| ----------- | ---- | ------------ | | ----------- | ---- | ------------ |
| UNKNOWN | 0 | 表示卡片为未知。 |
| FORM_VISIBLE | 1 | 表示卡片为可见。 | | FORM_VISIBLE | 1 | 表示卡片为可见。 |
| FORM_INVISIBLE | 2 | 表示卡片为不可见。 | | FORM_INVISIBLE | 2 | 表示卡片为不可见。 |
......
...@@ -39,13 +39,12 @@ setFormNextRefreshTime(formId: string, minute: number, callback: AsyncCallback&l ...@@ -39,13 +39,12 @@ setFormNextRefreshTime(formId: string, minute: number, callback: AsyncCallback&l
| 16501001 | The ID of the form to be operated does not exist. | | 16501001 | The ID of the form to be operated does not exist. |
| 16501002 | The number of forms exceeds upper bound. | | 16501002 | The number of forms exceeds upper bound. |
| 16501003 | The form can not be operated by the current application. | | 16501003 | The form can not be operated by the current application. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
```ts ```ts
import formProvider from '@ohos.app.form.formProvider';
let formId = '12400633174999288'; let formId = '12400633174999288';
try { try {
formProvider.setFormNextRefreshTime(formId, 5, (error) => { formProvider.setFormNextRefreshTime(formId, 5, (error) => {
...@@ -93,13 +92,12 @@ setFormNextRefreshTime(formId: string, minute: number): Promise&lt;void&gt; ...@@ -93,13 +92,12 @@ setFormNextRefreshTime(formId: string, minute: number): Promise&lt;void&gt;
| 16501001 | The ID of the form to be operated does not exist. | | 16501001 | The ID of the form to be operated does not exist. |
| 16501002 | The number of forms exceeds upper bound. | | 16501002 | The number of forms exceeds upper bound. |
| 16501003 | The form can not be operated by the current application. | | 16501003 | The form can not be operated by the current application. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
```ts ```ts
import formProvider from '@ohos.app.form.formProvider';
let formId = '12400633174999288'; let formId = '12400633174999288';
try { try {
formProvider.setFormNextRefreshTime(formId, 5).then(() => { formProvider.setFormNextRefreshTime(formId, 5).then(() => {
...@@ -139,13 +137,13 @@ updateForm(formId: string, formBindingData: formBindingData.FormBindingData,call ...@@ -139,13 +137,13 @@ updateForm(formId: string, formBindingData: formBindingData.FormBindingData,call
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
| 16501001 | The ID of the form to be operated does not exist. | | 16501001 | The ID of the form to be operated does not exist. |
| 16501003 | The form can not be operated by the current application. | | 16501003 | The form can not be operated by the current application. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
```ts ```ts
import formBindingData from '@ohos.app.form.formBindingData'; import formBindingData from '@ohos.app.form.formBindingData';
import formProvider from '@ohos.app.form.formProvider';
let formId = '12400633174999288'; let formId = '12400633174999288';
try { try {
...@@ -194,13 +192,13 @@ updateForm(formId: string, formBindingData: formBindingData.FormBindingData): Pr ...@@ -194,13 +192,13 @@ updateForm(formId: string, formBindingData: formBindingData.FormBindingData): Pr
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
| 16501001 | The ID of the form to be operated does not exist. | | 16501001 | The ID of the form to be operated does not exist. |
| 16501003 | The form can not be operated by the current application. | | 16501003 | The form can not be operated by the current application. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
```ts ```ts
import formBindingData from '@ohos.app.form.formBindingData'; import formBindingData from '@ohos.app.form.formBindingData';
import formProvider from '@ohos.app.form.formProvider';
let formId = '12400633174999288'; let formId = '12400633174999288';
let obj = formBindingData.createFormBindingData({ temperature: '22c', time: '22:00' }); let obj = formBindingData.createFormBindingData({ temperature: '22c', time: '22:00' });
...@@ -236,14 +234,13 @@ getFormsInfo(callback: AsyncCallback&lt;Array&lt;formInfo.FormInfo&gt;&gt;): voi ...@@ -236,14 +234,13 @@ getFormsInfo(callback: AsyncCallback&lt;Array&lt;formInfo.FormInfo&gt;&gt;): voi
| 16500050 | An IPC connection error happened. | | 16500050 | An IPC connection error happened. |
| 16500100 | Failed to obtain the configuration information. | | 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
```ts ```ts
import formProvider from '@ohos.app.form.formProvider';
try { try {
formProvider.getFormsInfo((error, data) => { formProvider.getFormsInfo((error, data) => {
if (error) { if (error) {
...@@ -279,13 +276,13 @@ getFormsInfo(filter: formInfo.FormInfoFilter, callback: AsyncCallback&lt;Array&l ...@@ -279,13 +276,13 @@ getFormsInfo(filter: formInfo.FormInfoFilter, callback: AsyncCallback&lt;Array&l
| 16500050 | An IPC connection error happened. | | 16500050 | An IPC connection error happened. |
| 16500100 | Failed to obtain the configuration information. | | 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
```ts ```ts
import formInfo from '@ohos.app.form.formInfo'; import formInfo from '@ohos.app.form.formInfo';
import formProvider from '@ohos.app.form.formProvider';
const filter: formInfo.FormInfoFilter = { const filter: formInfo.FormInfoFilter = {
// get info of forms belong to module entry. // get info of forms belong to module entry.
...@@ -332,13 +329,13 @@ getFormsInfo(filter?: formInfo.FormInfoFilter): Promise&lt;Array&lt;formInfo.For ...@@ -332,13 +329,13 @@ getFormsInfo(filter?: formInfo.FormInfoFilter): Promise&lt;Array&lt;formInfo.For
| 16500050 | An IPC connection error happened. | | 16500050 | An IPC connection error happened. |
| 16500100 | Failed to obtain the configuration information. | | 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
```ts ```ts
import formInfo from '@ohos.app.form.formInfo'; import formInfo from '@ohos.app.form.formInfo';
import formProvider from '@ohos.app.form.formProvider';
const filter: formInfo.FormInfoFilter = { const filter: formInfo.FormInfoFilter = {
// get info of forms belong to module entry. // get info of forms belong to module entry.
...@@ -382,13 +379,13 @@ requestPublishForm(want: Want, formBindingData: formBindingData.FormBindingData, ...@@ -382,13 +379,13 @@ requestPublishForm(want: Want, formBindingData: formBindingData.FormBindingData,
| 16500050 | An IPC connection error happened. | | 16500050 | An IPC connection error happened. |
| 16500100 | Failed to obtain the configuration information. | | 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
```ts ```ts
import formBindingData from '@ohos.app.form.formBindingData'; import formBindingData from '@ohos.app.form.formBindingData';
import formProvider from '@ohos.app.form.formProvider';
let want = { let want = {
abilityName: 'FormAbility', abilityName: 'FormAbility',
...@@ -438,13 +435,12 @@ requestPublishForm(want: Want, callback: AsyncCallback&lt;string&gt;): void ...@@ -438,13 +435,12 @@ requestPublishForm(want: Want, callback: AsyncCallback&lt;string&gt;): void
| 16500050 | An IPC connection error happened. | | 16500050 | An IPC connection error happened. |
| 16500100 | Failed to obtain the configuration information. | | 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
```ts ```ts
import formProvider from '@ohos.app.form.formProvider';
let want = { let want = {
abilityName: 'FormAbility', abilityName: 'FormAbility',
parameters: { parameters: {
...@@ -498,13 +494,12 @@ requestPublishForm(want: Want, formBindingData?: formBindingData.FormBindingData ...@@ -498,13 +494,12 @@ requestPublishForm(want: Want, formBindingData?: formBindingData.FormBindingData
| 16500050 | An IPC connection error happened. | | 16500050 | An IPC connection error happened. |
| 16500100 | Failed to obtain the configuration information. | | 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
```ts ```ts
import formProvider from '@ohos.app.form.formProvider';
let want = { let want = {
abilityName: 'FormAbility', abilityName: 'FormAbility',
parameters: { parameters: {
...@@ -548,13 +543,12 @@ isRequestPublishFormSupported(callback: AsyncCallback&lt;boolean&gt;): void ...@@ -548,13 +543,12 @@ isRequestPublishFormSupported(callback: AsyncCallback&lt;boolean&gt;): void
| 401 | If the input parameter is not valid parameter. | | 401 | If the input parameter is not valid parameter. |
| 16500050 | An IPC connection error happened. | | 16500050 | An IPC connection error happened. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
```ts ```ts
import formProvider from '@ohos.app.form.formProvider';
try { try {
formProvider.isRequestPublishFormSupported((error, isSupported) => { formProvider.isRequestPublishFormSupported((error, isSupported) => {
if (error) { if (error) {
...@@ -611,13 +605,12 @@ isRequestPublishFormSupported(): Promise&lt;boolean&gt; ...@@ -611,13 +605,12 @@ isRequestPublishFormSupported(): Promise&lt;boolean&gt;
| 202 | The application is not a system application. | | 202 | The application is not a system application. |
| 16500050 | An IPC connection error happened. | | 16500050 | An IPC connection error happened. |
| 16501000 | An internal functional error occurred. | | 16501000 | An internal functional error occurred. |
|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。||
以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)
**示例:** **示例:**
```ts ```ts
import formProvider from '@ohos.app.form.formProvider';
try { try {
formProvider.isRequestPublishFormSupported().then((isSupported) => { formProvider.isRequestPublishFormSupported().then((isSupported) => {
if (isSupported) { if (isSupported) {
......
# @ohos.application.StaticSubscriberExtensionContext (StaticSubscriberExtensionContext)
StaticSubscriberExtensionContext模块是StaticSubscriberExtensionAbility的上下文环境,继承自ExtensionContext。
StaticSubscriberExtensionContext模块提供StaticSubscriberExtensionAbility具有的接口和能力。
> **说明:**
>
> 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> 本模块接口仅可在Stage模型下使用。
## 使用说明
在使用StaticSubscriberExtensionContext的功能前,需要通过StaticSubscriberExtensionAbility获取。
```ts
import StaticSubscriberExtensionAbility from '@ohos.application.StaticSubscriberExtensionAbility'
export default class MyStaticSubscriberExtensionAbility extends StaticSubscriberExtensionAbility {
context = this.context;
};
```
## StaticSubscriberExtensionContext.startAbility
startAbility(want: Want, callback: AsyncCallback&lt;void&gt;): void;
拉起一个静态订阅所属的同应用的Ability。使用callback异步回调。
使用规则:
- 调用方应用位于后台时,使用该接口启动Ability需申请`ohos.permission.START_ABILITIES_FROM_BACKGROUND`权限
- 跨应用场景下,目标Ability的visible属性若配置为false,调用方应用需申请`ohos.permission.START_INVISIBLE_ABILITY`权限
**系统能力**:SystemCapability.Ability.AbilityRuntime.Core
**系统API**:该接口为系统接口,三方应用不支持调用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------------- | ---- | -------------------------- |
| want | [Want](js-apis-application-want.md) | 是 | 启动Ability的want信息。 |
| callback | AsyncCallback&lt;void&gt; | 是 | callback形式返回启动结果。 |
**错误码:**
以下错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)
| 错误码ID | 错误信息 |
| -------- | ------------------------------------------------------------ |
| 16000001 | The specified ability does not exist. |
| 16000002 | Incorrect ability type. |
| 16000004 | Can not start invisible component. |
| 16000005 | The specified process does not have the permission. |
| 16000006 | Cross-user operations are not allowed. |
| 16000008 | The crowdtesting application expires. |
| 16000009 | An ability cannot be started or stopped in Wukong mode. |
| 16000011 | The context does not exist. |
| 16000050 | Internal error. |
| 16000053 | The ability is not on the top of the UI. |
| 16000055 | Installation-free timed out. |
| 16200001 | The caller has been released. |
| 16300003 | The target application is not self application. |
**示例:**
```ts
let want = {
bundleName: "com.example.myapp",
abilityName: "MyAbility"
};
try {
this.context.startAbility(want, (error) => {
if (error) {
// 处理业务逻辑错误
console.log('startAbility failed, error.code: ' + JSON.stringify(error.code) +
' error.message: ' + JSON.stringify(error.message));
return;
}
// 执行正常业务
console.log('startAbility succeed');
});
} catch (paramError) {
// 处理入参错误异常
console.log('startAbility failed, error.code: ' + JSON.stringify(paramError.code) +
' error.message: ' + JSON.stringify(paramError.message));
}
```
## StaticSubscriberExtensionContext.startAbility
startAbility(want: Want): Promise&lt;void&gt;;
拉起一个静态订阅所属的同应用的Ability。使用Promise异步回调。
使用规则:
- 调用方应用位于后台时,使用该接口启动Ability需申请`ohos.permission.START_ABILITIES_FROM_BACKGROUND`权限
- 跨应用场景下,目标Ability的visible属性若配置为false,调用方应用需申请`ohos.permission.START_INVISIBLE_ABILITY`权限
**系统能力**:SystemCapability.Ability.AbilityRuntime.Core
**系统API**:该接口为系统接口,三方应用不支持调用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ----------------------------------- | ---- | ----------------------- |
| want | [Want](js-apis-application-want.md) | 是 | 启动Ability的want信息。 |
**返回值:**
| 类型 | 说明 |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise形式返回启动结果。 |
**错误码:**
以下错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)
| 错误码ID | 错误信息 |
| -------- | ------------------------------------------------------------ |
| 16000001 | The specified ability does not exist. |
| 16000002 | Incorrect ability type. |
| 16000004 | Can not start invisible component. |
| 16000005 | The specified process does not have the permission. |
| 16000006 | Cross-user operations are not allowed. |
| 16000008 | The crowdtesting application expires. |
| 16000009 | An ability cannot be started or stopped in Wukong mode. |
| 16000011 | The context does not exist. |
| 16000050 | Internal error. |
| 16000053 | The ability is not on the top of the UI. |
| 16000055 | Installation-free timed out. |
| 16200001 | The caller has been released. |
| 16300003 | The target application is not self application. |
**示例:**
```ts
let want = {
bundleName: "com.example.myapp",
abilityName: "MyAbility"
};
try {
this.context.startAbility(want)
.then(() => {
// 执行正常业务
console.log('startAbility succeed');
})
.catch((error) => {
// 处理业务逻辑错误
console.log('startAbility failed, error.code: ' + JSON.stringify(error.code) +
' error.message: ' + JSON.stringify(error.message));
});
} catch (paramError) {
// 处理入参错误异常
console.log('startAbility failed, error.code: ' + JSON.stringify(paramError.code) +
' error.message: ' + JSON.stringify(paramError.message));
}
```
\ No newline at end of file
...@@ -400,7 +400,11 @@ killProcessWithAccount(bundleName: string, accountId: number): Promise\<void\> ...@@ -400,7 +400,11 @@ killProcessWithAccount(bundleName: string, accountId: number): Promise\<void\>
切断account进程(Promise形式)。 切断account进程(Promise形式)。
**需要权限**:ohos.permission.CLEAN_BACKGROUND_PROCESSES,ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS,当accountId为当前用户时,不需要校验ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS权限。 > **说明:**
>
> 当accountId为当前用户时,不需要校验ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS权限。
**需要权限**:ohos.permission.CLEAN_BACKGROUND_PROCESSES,ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
**系统能力**:SystemCapability.Ability.AbilityRuntime.Core **系统能力**:SystemCapability.Ability.AbilityRuntime.Core
...@@ -434,11 +438,15 @@ killProcessWithAccount(bundleName: string, accountId: number, callback: AsyncCal ...@@ -434,11 +438,15 @@ killProcessWithAccount(bundleName: string, accountId: number, callback: AsyncCal
切断account进程(callback形式)。 切断account进程(callback形式)。
> **说明:**
>
> 当accountId为当前用户时,不需要校验ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS权限。
**系统能力**:SystemCapability.Ability.AbilityRuntime.Core **系统能力**:SystemCapability.Ability.AbilityRuntime.Core
**系统API**: 此接口为系统接口,三方应用不支持调用。 **系统API**: 此接口为系统接口,三方应用不支持调用。
**需要权限**:ohos.permission.CLEAN_BACKGROUND_PROCESSES,ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS,当accountId为当前用户时,不需要校验ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS权限。 **需要权限**:ohos.permission.CLEAN_BACKGROUND_PROCESSES,ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
**参数:** **参数:**
......
...@@ -3,9 +3,16 @@ ...@@ -3,9 +3,16 @@
定义环境变化信息。Configuration是接口定义,仅做字段声明。 定义环境变化信息。Configuration是接口定义,仅做字段声明。
> **说明:** > **说明:**
>
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> 本模块从API version 9废弃,替换模块为[@ohos.app.ability.Configuration (Configuration)](js-apis-app-ability-configuration.md) > 本模块从API version 9废弃,替换模块为[@ohos.app.ability.Configuration (Configuration)](js-apis-app-ability-configuration.md)
## 导入模块
```ts
import Configuration from '@ohos.app.application.Configuration';
```
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityBase **系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityBase
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
......
# @ohos.application.EnvironmentCallback (EnvironmentCallback)
EnvironmentCallback模块提供应用上下文ApplicationContext对系统环境变化监听回调的能力,包括onConfigurationUpdated、onMemoryLevel方法。
> **说明:**
>
> 本模块首批接口从API version 9 开始支持,从API version 9后续版本废弃,替换模块为[@ohos.app.ability.EnvironmentCallback](js-apis-app-ability-environmentCallback.md)。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> 本模块接口仅可在Stage模型下使用。
## 导入模块
```ts
import EnvironmentCallback from '@ohos.application.EnvironmentCallback';
```
## EnvironmentCallback.onConfigurationUpdated
onConfigurationUpdated(config: Configuration): void;
注册系统环境变化的监听后,在系统环境变化时触发回调。
**系统能力**:SystemCapability.Ability.AbilityRuntime.AbilityCore
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| config | [Configuration](js-apis-application-configuration.md) | 是 | 变化后的Configuration对象。 |
## EnvironmentCallback.onMemoryLevel
onMemoryLevel(level: number): void;
注册系统内存基线水平变化监听后,在系统内存基线水平变化时触发回调。
**系统能力**:SystemCapability.Ability.AbilityRuntime.AbilityCore
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| level | [MemoryLevel](js-apis-app-ability-abilityConstant.md#abilityconstantmemorylevel) | 是 | 表示当前内存的基线水平。 |
**示例:**
```ts
import UIAbility from '@ohos.app.ability.UIAbility';
let callbackId;
export default class EntryAbility extends UIAbility {
onCreate() {
console.log('MyAbility onCreate');
globalThis.applicationContext = this.context.getApplicationContext();
let environmentCallback = {
onConfigurationUpdated(config){
console.log('onConfigurationUpdated config: ${JSON.stringify(config)}');
},
onMemoryLevel(level){
console.log('onMemoryLevel level: ${level}');
}
};
// 1.获取applicationContext
let applicationContext = globalThis.applicationContext;
// 2.通过applicationContext注册监听应用内生命周期
callbackId = applicationContext.registerEnvironmentCallback(environmentCallback);
console.log('registerEnvironmentCallback number: ${JSON.stringify(callbackId)}');
}
onDestroy() {
let applicationContext = globalThis.applicationContext;
applicationContext.unregisterEnvironmentCallback(callbackId, (error, data) => {
if (error && error.code !== 0) {
console.error('unregisterEnvironmentCallback fail, error: ${JSON.stringify(error)}');
} else {
console.log('unregisterEnvironmentCallback success, data: ${JSON.stringify(data)}');
}
});
}
}
```
\ No newline at end of file
...@@ -12,6 +12,14 @@ StaticSubscriberExtensionAbility模块提供静态订阅者ExtensionAbility的 ...@@ -12,6 +12,14 @@ StaticSubscriberExtensionAbility模块提供静态订阅者ExtensionAbility的
import StaticSubscriberExtensionAbility from '@ohos.application.StaticSubscriberExtensionAbility'; import StaticSubscriberExtensionAbility from '@ohos.application.StaticSubscriberExtensionAbility';
``` ```
## 属性
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.AbilityCore
| 名称 | 类型 | 可读 | 可写 | 说明 |
| ------- | ------------------------------------------------------------ | ---- | ---- | -------- |
| context | [StaticSubscriberExtensionContext](js-apis-application-StaticSubscriberExtensionContext.md) | 是 | 否 | 上下文。 |
## StaticSubscriberExtensionAbility.onReceiveEvent ## StaticSubscriberExtensionAbility.onReceiveEvent
onReceiveEvent(event: CommonEventData): void; onReceiveEvent(event: CommonEventData): void;
......
...@@ -49,7 +49,7 @@ struct SnapshotExample { ...@@ -49,7 +49,7 @@ struct SnapshotExample {
// ...Components // ...Components
Button("click to generate UI snapshot") Button("click to generate UI snapshot")
.onClick(() => { .onClick(() => {
componentSnapshot.get("root", (error: BusinessError, pixmap: image.PixelMap) => { componentSnapshot.get("root", (error: Error, pixmap: image.PixelMap) => {
this.pixmap = pixmap this.pixmap = pixmap
// save pixmap to file // save pixmap to file
// .... // ....
...@@ -85,6 +85,12 @@ get(id: string): Promise<image.PixelMap> ...@@ -85,6 +85,12 @@ get(id: string): Promise<image.PixelMap>
| ----------------------------- | -------------- | | ----------------------------- | -------------- |
| Promise&lt;image.PixelMap&gt; | 截图返回的结果。 | | Promise&lt;image.PixelMap&gt; | 截图返回的结果。 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | ------------------- |
| 100001 | if id is not valid. |
**示例:** **示例:**
```js ```js
...@@ -139,9 +145,10 @@ createFromBuilder(builder: CustomBuilder, callback: AsyncCallback<image.PixelMap ...@@ -139,9 +145,10 @@ createFromBuilder(builder: CustomBuilder, callback: AsyncCallback<image.PixelMap
**示例:** **示例:**
```js ```ts
import componentSnapshot from '@ohos.arkui.componentSnapshot' import componentSnapshot from '@ohos.arkui.componentSnapshot'
import image from '@ohos.multimedia.image' import image from '@ohos.multimedia.image'
@Entry @Entry
@Component @Component
struct OffscreenSnapshotExample { struct OffscreenSnapshotExample {
...@@ -149,7 +156,7 @@ struct OffscreenSnapshotExample { ...@@ -149,7 +156,7 @@ struct OffscreenSnapshotExample {
@Builder @Builder
RandomBuilder() { RandomBuilder() {
Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Text('Test menu item 1') Text('Test menu item 1')
.fontSize(20) .fontSize(20)
.width(100) .width(100)
...@@ -163,16 +170,17 @@ struct OffscreenSnapshotExample { ...@@ -163,16 +170,17 @@ struct OffscreenSnapshotExample {
.textAlign(TextAlign.Center) .textAlign(TextAlign.Center)
}.width(100) }.width(100)
} }
build() { build() {
Column() { Column() {
Button("click to generate offscreen UI snapshot") Button("click to generate offscreen UI snapshot")
.onClick(()=> { .onClick(() => {
componentSnapshot.createFromBuilder(this.RandomBuilder.bind(this), componentSnapshot.createFromBuilder(this.RandomBuilder.bind(this),
(error: BusinessError, pixmap: image.PixelMap) => { (error: Error, pixmap: image.PixelMap) => {
this.pixmap = pixmap this.pixmap = pixmap
// save pixmap to file // save pixmap to file
// .... // ....
}) })
}) })
}.width('80%').margin({ left: 10, top: 5, bottom: 5 }).height(200) }.width('80%').margin({ left: 10, top: 5, bottom: 5 }).height(200)
.border({ color: '#880606', width: 2 }) .border({ color: '#880606', width: 2 })
...@@ -200,11 +208,18 @@ createFromBuilder(builder: CustomBuilder): Promise<image.PixelMap> ...@@ -200,11 +208,18 @@ createFromBuilder(builder: CustomBuilder): Promise<image.PixelMap>
| ----------------------------- | -------------- | | ----------------------------- | -------------- |
| Promise&lt;image.PixelMap&gt; | 截图返回的结果。 | | Promise&lt;image.PixelMap&gt; | 截图返回的结果。 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | ----------------------------------------- |
| 100001 | if builder is not a valid build function. |
**示例:** **示例:**
```js ```ts
import componentSnapshot from '@ohos.arkui.componentSnapshot' import componentSnapshot from '@ohos.arkui.componentSnapshot'
import image from '@ohos.multimedia.image' import image from '@ohos.multimedia.image'
@Entry @Entry
@Component @Component
struct OffscreenSnapshotExample { struct OffscreenSnapshotExample {
...@@ -212,7 +227,7 @@ struct OffscreenSnapshotExample { ...@@ -212,7 +227,7 @@ struct OffscreenSnapshotExample {
@Builder @Builder
RandomBuilder() { RandomBuilder() {
Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Text('Test menu item 1') Text('Test menu item 1')
.fontSize(20) .fontSize(20)
.width(100) .width(100)
...@@ -226,16 +241,17 @@ struct OffscreenSnapshotExample { ...@@ -226,16 +241,17 @@ struct OffscreenSnapshotExample {
.textAlign(TextAlign.Center) .textAlign(TextAlign.Center)
}.width(100) }.width(100)
} }
build() { build() {
Column() { Column() {
Button("click to generate offscreen UI snapshot") Button("click to generate offscreen UI snapshot")
.onClick(()=> { .onClick(() => {
componentSnapshot.createFromBuilder(this.RandomBuilder.bind(this)) componentSnapshot.createFromBuilder(this.RandomBuilder.bind(this))
.then((pixmap: image.PixelMap) { .then((pixmap: image.PixelMap) => {
this.pixmap = pixmap this.pixmap = pixmap
// save pixmap to file // save pixmap to file
// .... // ....
}) })
}) })
}.width('80%').margin({ left: 10, top: 5, bottom: 5 }).height(200) }.width('80%').margin({ left: 10, top: 5, bottom: 5 }).height(200)
.border({ color: '#880606', width: 2 }) .border({ color: '#880606', width: 2 })
......
...@@ -32,16 +32,25 @@ constructor() ...@@ -32,16 +32,25 @@ constructor()
当传入资源id或name为包含前景和背景资源的json文件时,生成LayeredDrawableDescriptor对象。 当传入资源id或name为包含前景和背景资源的json文件时,生成LayeredDrawableDescriptor对象。
**示例:** **示例:**
```js ```ts
// xxx.ets
import { DrawableDescriptor, LayeredDrawableDescriptor } from '@ohos.arkui.drawableDescriptor'
@Entry @Entry
@Component @Component
struct Index { struct Index {
private resManager = getContext().resourceManager private resManager = getContext().resourceManager
let drawable1 = resManager.getDrawableDescriptor($r('app.media.icon').id)
let drawable2 = resManager.getDrawableDescriptorByName(icon) build() {
let layeredDrawable1 = resManager.getDrawableDescriptor($r('app.media.file').id) Row() {
let layeredDrawable1 = resManager.getDrawableDescriptor(file) Column() {
} Image((<LayeredDrawableDescriptor> (this.resManager.getDrawableDescriptor($r('app.media.icon').id))))
Image(((<LayeredDrawableDescriptor> (this.resManager.getDrawableDescriptor($r('app.media.icon')
.id))).getForeground()).getPixelMap())
}.height('50%')
}.width('50%')
}
}
``` ```
## DrawableDescriptor.getPixelMap ## DrawableDescriptor.getPixelMap
...@@ -58,8 +67,8 @@ getPixelMap(): image.PixelMap; ...@@ -58,8 +67,8 @@ getPixelMap(): image.PixelMap;
| [image.PixelMap](../apis/js-apis-image.md#pixelmap7) | PixelMap | | [image.PixelMap](../apis/js-apis-image.md#pixelmap7) | PixelMap |
**示例:** **示例:**
```js ```ts
@State pixmap: PixelMap = drawable1.getPixelMap(); pixmap: PixelMap = drawable1.getPixelMap();
``` ```
## LayeredDrawableDescriptor.getPixelMap ## LayeredDrawableDescriptor.getPixelMap
...@@ -76,8 +85,8 @@ getPixelMap(): image.PixelMap; ...@@ -76,8 +85,8 @@ getPixelMap(): image.PixelMap;
| [image.PixelMap](../apis/js-apis-image.md#pixelmap7) | PixelMap | | [image.PixelMap](../apis/js-apis-image.md#pixelmap7) | PixelMap |
**示例:** **示例:**
```js ```ts
@State pixmap: PixelMap = layeredDrawable1.getPixelMap(); pixmap: PixelMap = layeredDrawable1.getPixelMap();
``` ```
## LayeredDrawableDescriptor.getForeground ## LayeredDrawableDescriptor.getForeground
...@@ -94,8 +103,8 @@ getForeground(): DrawableDescriptor; ...@@ -94,8 +103,8 @@ getForeground(): DrawableDescriptor;
| [DrawableDescriptor](#drawabledescriptor) | DrawableDescriptor对象 | | [DrawableDescriptor](#drawabledescriptor) | DrawableDescriptor对象 |
**示例:** **示例:**
```js ```ts
@State drawable: DrawableDescriptor = layeredDrawable1.getForeground(); drawable: DrawableDescriptor = layeredDrawable1.getForeground();
``` ```
## LayeredDrawableDescriptor.getBackground ## LayeredDrawableDescriptor.getBackground
...@@ -112,8 +121,8 @@ getBackground(): DrawableDescriptor; ...@@ -112,8 +121,8 @@ getBackground(): DrawableDescriptor;
| [DrawableDescriptor](#drawabledescriptor) | DrawableDescriptor对象 | | [DrawableDescriptor](#drawabledescriptor) | DrawableDescriptor对象 |
**示例:** **示例:**
```js ```ts
@State drawable: DrawableDescriptor = layeredDrawable1.getBackground(); drawable: DrawableDescriptor = layeredDrawable1.getBackground();
``` ```
## LayeredDrawableDescriptor.getMask ## LayeredDrawableDescriptor.getMask
...@@ -130,6 +139,6 @@ getMask(): DrawableDescriptor; ...@@ -130,6 +139,6 @@ getMask(): DrawableDescriptor;
| [DrawableDescriptor](#drawabledescriptor) | DrawableDescriptor对象 | | [DrawableDescriptor](#drawabledescriptor) | DrawableDescriptor对象 |
**示例:** **示例:**
```js ```ts
@State drawable: DrawableDescriptor = layeredDrawable1.getMask(); drawable: DrawableDescriptor = layeredDrawable1.getMask();
``` ```
...@@ -1091,6 +1091,8 @@ setAVQueueItems(items: Array\<AVQueueItem>): Promise<void\> ...@@ -1091,6 +1091,8 @@ setAVQueueItems(items: Array\<AVQueueItem>): Promise<void\>
**系统能力:** SystemCapability.Multimedia.AVSession.Core **系统能力:** SystemCapability.Multimedia.AVSession.Core
**系统接口:** 该接口为系统接口
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
...@@ -1114,12 +1116,14 @@ setAVQueueItems(items: Array\<AVQueueItem>): Promise<void\> ...@@ -1114,12 +1116,14 @@ setAVQueueItems(items: Array\<AVQueueItem>): Promise<void\>
**示例:** **示例:**
```js ```js
let imageSource : imageImageSource = image.createImageSource(value.buffer);
let imagePixel : image.PixelMap = await imageSource.createPixelMap({desiredSize:{width: 150, height: 150}});
let queueItemDescription_1 = { let queueItemDescription_1 = {
mediaId: '001', mediaId: '001',
title: 'music_name', title: 'music_name',
subtitle: 'music_sub_name', subtitle: 'music_sub_name',
description: 'music_description', description: 'music_description',
icon: PIXELMAP_OBJECT, icon : imagePixel,
iconUri: 'http://www.icon.uri.com', iconUri: 'http://www.icon.uri.com',
extras: {'extras':'any'} extras: {'extras':'any'}
}; };
...@@ -1156,6 +1160,8 @@ setAVQueueItems(items: Array\<AVQueueItem>, callback: AsyncCallback<void\>): voi ...@@ -1156,6 +1160,8 @@ setAVQueueItems(items: Array\<AVQueueItem>, callback: AsyncCallback<void\>): voi
**系统能力:** SystemCapability.Multimedia.AVSession.Core **系统能力:** SystemCapability.Multimedia.AVSession.Core
**系统接口:** 该接口为系统接口
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
...@@ -1174,12 +1180,14 @@ setAVQueueItems(items: Array\<AVQueueItem>, callback: AsyncCallback<void\>): voi ...@@ -1174,12 +1180,14 @@ setAVQueueItems(items: Array\<AVQueueItem>, callback: AsyncCallback<void\>): voi
**示例:** **示例:**
```js ```js
let imageSource : imageImageSource = image.createImageSource(value.buffer);
let imagePixel : image.PixelMap = await imageSource.createPixelMap({desiredSize:{width: 150, height: 150}});
let queueItemDescription_1 = { let queueItemDescription_1 = {
mediaId: '001', mediaId: '001',
title: 'music_name', title: 'music_name',
subtitle: 'music_sub_name', subtitle: 'music_sub_name',
description: 'music_description', description: 'music_description',
icon: PIXELMAP_OBJECT, icon: imagePixel,
iconUri: 'http://www.icon.uri.com', iconUri: 'http://www.icon.uri.com',
extras: {'extras':'any'} extras: {'extras':'any'}
}; };
...@@ -1218,6 +1226,8 @@ setAVQueueTitle(title: string): Promise\<void> ...@@ -1218,6 +1226,8 @@ setAVQueueTitle(title: string): Promise\<void>
**系统能力:** SystemCapability.Multimedia.AVSession.Core **系统能力:** SystemCapability.Multimedia.AVSession.Core
**系统接口:** 该接口为系统接口
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
...@@ -1257,6 +1267,8 @@ setAVQueueTitle(title: string, callback: AsyncCallback\<void\>): void ...@@ -1257,6 +1267,8 @@ setAVQueueTitle(title: string, callback: AsyncCallback\<void\>): void
**系统能力:** SystemCapability.Multimedia.AVSession.Core **系统能力:** SystemCapability.Multimedia.AVSession.Core
**系统接口:** 该接口为系统接口
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
...@@ -1434,6 +1446,8 @@ dispatchSessionEvent(event: string, args: {[key: string]: Object}): Promise\<voi ...@@ -1434,6 +1446,8 @@ dispatchSessionEvent(event: string, args: {[key: string]: Object}): Promise\<voi
**系统能力:** SystemCapability.Multimedia.AVSession.Core **系统能力:** SystemCapability.Multimedia.AVSession.Core
**系统接口:** 该接口为系统接口
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
...@@ -1478,6 +1492,8 @@ dispatchSessionEvent(event: string, args: {[key: string]: Object}, callback: Asy ...@@ -1478,6 +1492,8 @@ dispatchSessionEvent(event: string, args: {[key: string]: Object}, callback: Asy
**系统能力:** SystemCapability.Multimedia.AVSession.Core **系统能力:** SystemCapability.Multimedia.AVSession.Core
**系统接口:** 该接口为系统接口
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
...@@ -1519,6 +1535,8 @@ setExtras(extras: {[key: string]: Object}): Promise\<void> ...@@ -1519,6 +1535,8 @@ setExtras(extras: {[key: string]: Object}): Promise\<void>
**系统能力:** SystemCapability.Multimedia.AVSession.Core **系统能力:** SystemCapability.Multimedia.AVSession.Core
**系统接口:** 该接口为系统接口
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
...@@ -2520,7 +2538,7 @@ session.off('outputDeviceChange'); ...@@ -2520,7 +2538,7 @@ session.off('outputDeviceChange');
### off('commonCommand')<sup>10+</sup> ### off('commonCommand')<sup>10+</sup>
off(type: 'commonCommand', callback?: (commonCommand: string, args: {[key:string]: Object}) => void): void off(type: 'commonCommand', callback?: (command: string, args: {[key:string]: Object}) => void): void
取消监听自定义控制命令的变化。 取消监听自定义控制命令的变化。
...@@ -2533,7 +2551,7 @@ off(type: 'commonCommand', callback?: (commonCommand: string, args: {[key:string ...@@ -2533,7 +2551,7 @@ off(type: 'commonCommand', callback?: (commonCommand: string, args: {[key:string
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------- | | -------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------- |
| type | string | 是 | 取消对应的监听事件,支持事件`'commonCommand'`。 | | type | string | 是 | 取消对应的监听事件,支持事件`'commonCommand'`。 |
| callback | (commonCommand: string, args: {[key:string]: Object}) => void | 否 | 回调函数,参数commonCommand是变化的自定义控制命令名,args为自定义控制命令的参数。<br>该参数为可选参数,若不填写该参数,则认为取消所有对commonCommand事件的监听。 | | callback | (command: string, args: {[key:string]: Object}) => void | 否 | 回调函数,参数command是变化的自定义控制命令名,args为自定义控制命令的参数。<br>该参数为可选参数,若不填写该参数,则认为取消所有对command事件的监听。 |
**错误码:** **错误码:**
以下错误码的详细介绍请参见[媒体会话管理错误码](../errorcodes/errorcode-avsession.md) 以下错误码的详细介绍请参见[媒体会话管理错误码](../errorcodes/errorcode-avsession.md)
...@@ -2558,6 +2576,8 @@ session.off('commonCommand'); ...@@ -2558,6 +2576,8 @@ session.off('commonCommand');
**系统能力:** SystemCapability.Multimedia.AVSession.Core **系统能力:** SystemCapability.Multimedia.AVSession.Core
**系统接口:** 该接口为系统接口
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| :-------- | :----- | :--- | :--- | :-------------------------------------- | | :-------- | :----- | :--- | :--- | :-------------------------------------- |
...@@ -3061,6 +3081,22 @@ getExtras(callback: AsyncCallback\<{[key: string]: Object}>): void ...@@ -3061,6 +3081,22 @@ getExtras(callback: AsyncCallback\<{[key: string]: Object}>): void
**示例:** **示例:**
```js ```js
let metadata = {
assetId: "121278",
title: "lose yourself",
artist: "Eminem",
author: "ST",
album: "Slim shady",
writer: "ST",
composer: "ST",
duration: 2222,
mediaImage: "https://www.example.com/example.jpg",
subtitle: "8 Mile",
description: "Rap",
lyric: "https://www.example.com/example.lrc",
previousAssetId: "121277",
nextAssetId: "121279",
};
controller.getExtras(function (err, extras) { controller.getExtras(function (err, extras) {
if (err) { if (err) {
console.info(`getExtras BusinessError: code: ${err.code}, message: ${err.message}`); console.info(`getExtras BusinessError: code: ${err.code}, message: ${err.message}`);
...@@ -3602,6 +3638,8 @@ sendCommonCommand(command: string, args: {[key: string]: Object}): Promise\<void ...@@ -3602,6 +3638,8 @@ sendCommonCommand(command: string, args: {[key: string]: Object}): Promise\<void
**系统能力:** SystemCapability.Multimedia.AVSession.Core **系统能力:** SystemCapability.Multimedia.AVSession.Core
**系统接口:** 该接口为系统接口
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
...@@ -3650,6 +3688,8 @@ sendCommonCommand(command: string, args: {[key: string]: Object}, callback: Asyn ...@@ -3650,6 +3688,8 @@ sendCommonCommand(command: string, args: {[key: string]: Object}, callback: Asyn
**系统能力:** SystemCapability.Multimedia.AVSession.Core **系统能力:** SystemCapability.Multimedia.AVSession.Core
**系统接口:** 该接口为系统接口
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
......
...@@ -26,9 +26,9 @@ import businessAbilityRouter from '@ohos.app.businessAbilityRouter'; ...@@ -26,9 +26,9 @@ import businessAbilityRouter from '@ohos.app.businessAbilityRouter';
此枚举值用于标识过滤条件类型。 此枚举值用于标识过滤条件类型。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core
**系统接口:** 此接口为系统接口。 **系统API:** 此接口为系统接口。
| 名称 | 值 | 说明 | | 名称 | 值 | 说明 |
| ----------- | ---- | ------------------------------------ | | ----------- | ---- | ------------------------------------ |
...@@ -39,9 +39,9 @@ import businessAbilityRouter from '@ohos.app.businessAbilityRouter'; ...@@ -39,9 +39,9 @@ import businessAbilityRouter from '@ohos.app.businessAbilityRouter';
此过滤值用于过滤查询的ability类型。 此过滤值用于过滤查询的ability类型。
**系统能力:** SystemCapability.BundleManager.BundleFrameWork.FreeInstall **系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**系统接口:** 此接口为系统接口。 **系统API:** 此接口为系统接口。
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| ------------ | ------------ | ---- | ---- | -------------------------------------- | | ------------ | ------------ | ---- | ---- | -------------------------------------- |
......
...@@ -550,7 +550,7 @@ on(type: 'cameraStatus', callback: AsyncCallback\<CameraStatusInfo\>): void ...@@ -550,7 +550,7 @@ on(type: 'cameraStatus', callback: AsyncCallback\<CameraStatusInfo\>): void
**示例:** **示例:**
```js ```js
cameraManager.on('cameraStatus', (cameraStatusInfo) => { cameraManager.on('cameraStatus', (err, cameraStatusInfo) => {
console.log(`camera : ${cameraStatusInfo.camera.cameraId}`); console.log(`camera : ${cameraStatusInfo.camera.cameraId}`);
console.log(`status: ${cameraStatusInfo.status}`); console.log(`status: ${cameraStatusInfo.status}`);
}) })
...@@ -1680,7 +1680,7 @@ setMeteringPoint(point: Point): void ...@@ -1680,7 +1680,7 @@ setMeteringPoint(point: Point): void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------------- | -------------------------------| ---- | ------------------- | | ------------- | -------------------------------| ---- | ------------------- |
| exposurePoint | [Point](#point) | 是 | 曝光点 | | exposurePoint | [Point](#point) | 是 | 曝光点,x,y设置范围应在[0,1]之内,超过范围,如果小于0设置0,大于1设置1。 |
**返回值:** **返回值:**
...@@ -1755,7 +1755,7 @@ setExposureBias(exposureBias: number): void ...@@ -1755,7 +1755,7 @@ setExposureBias(exposureBias: number): void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------| ---- | ------------------- | | -------- | -------------------------------| ---- | ------------------- |
| exposureBias | number | 是 | 曝光补偿,getExposureBiasRange查询支持的范围,接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode) | | exposureBias | number | 是 | 曝光补偿,getExposureBiasRange查询支持的范围,接口调用失败会返回相应错误码,错误码类型[CameraErrorCode](#cameraerrorcode),如果设置超过支持范围的值,自动匹配到就近临界点。 |
**错误码:** **错误码:**
...@@ -1938,7 +1938,7 @@ setFocusPoint(point: Point): void ...@@ -1938,7 +1938,7 @@ setFocusPoint(point: Point): void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------- | ---- | ------------------- | | -------- | ----------------------- | ---- | ------------------- |
| Point1 | [Point](#point) | 是 | 焦点。 | | Point1 | [Point](#point) | 是 | 焦点。x,y设置范围应在[0,1]之内,超过范围,如果小于0设置0,大于1设置1。 |
**返回值:** **返回值:**
...@@ -2077,7 +2077,7 @@ setZoomRatio(zoomRatio: number): void ...@@ -2077,7 +2077,7 @@ setZoomRatio(zoomRatio: number): void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| --------- | -------------------- | ---- | ------------------- | | --------- | -------------------- | ---- | ------------------- |
| zoomRatio | number | 是 | 可变焦距比,通过getZoomRatioRange获取支持的变焦范围 | | zoomRatio | number | 是 | 可变焦距比,通过getZoomRatioRange获取支持的变焦范围,如果设置超过支持范围的值,自动匹配到就近临界点。 |
**返回值:** **返回值:**
...@@ -2737,7 +2737,7 @@ capture(setting?: PhotoCaptureSetting): Promise\<void\> ...@@ -2737,7 +2737,7 @@ capture(setting?: PhotoCaptureSetting): Promise\<void\>
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------- | ------------------------------------------- | ---- | -------- | | ------- | ------------------------------------------- | ---- | -------- |
| setting | [PhotoCaptureSetting](#photocapturesetting) | 否 | 拍照设置。 | | setting | [PhotoCaptureSetting](#photocapturesetting) | 否 | 拍照设置,传入undefined类型数据按默认无参处理。 |
**返回值:** **返回值:**
......
...@@ -575,3 +575,85 @@ commonEventManager.removeStickyCommonEvent("sticky_event").then(() => { ...@@ -575,3 +575,85 @@ commonEventManager.removeStickyCommonEvent("sticky_event").then(() => {
}); });
``` ```
## CommonEventManager.setStaticSubscriberState<sup>10+</sup>
setStaticSubscriberState(enable: boolean, callback: AsyncCallback<void>): void;
方法介绍:为当前应用设置静态订阅事件使能或去使能状态。使用callback异步回调。
**系统能力:** SystemCapability.Notification.CommonEvent
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------- | ---- | -------------------------------- |
| enable | bool | 是 | 表示静态订阅事件使能状态。 true:使能 false:去使能 |
| callback | AsyncCallback\<void> | 是 | 表示设置静态订阅事件使能状态的回调方法。 |
**错误码:**
错误码介绍请参考[@ohos.commonEventManager(事件)](../errorcodes/errorcode-CommonEventService.md)
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 1500007 | The message send error. |
| 1500008 | The CEMS error. |
**示例:**
```ts
CommonEventManager.setStaticSubscriberState(true, (err) => {
if (!err) {
console.info(`Set static subscriber state callback failed, err is null.`);
return;
}
if (err.code) {
console.info(`Set static subscriber state callback failed, errCode: ${err.code}, errMes: ${err.message}`);
return;
}
console.info(`Set static subscriber state callback success`);
});
```
## CommonEventManager.setStaticSubscriberState<sup>10+</sup>
setStaticSubscriberState(enable: boolean): Promise<void>;
方法介绍:为当前应用设置静态订阅事件使能或去使能状态。使用Promise异步回调。
**系统能力:** SystemCapability.Notification.CommonEvent
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | -------------------------- |
| enable | bool | 是 | 表示静态订阅事件使能状态。true:使能 false:去使能 |
**返回值:**
| 类型 | 说明 |
| -------------- | ---------------------------- |
| Promise\<void> | 表示设置静态订阅事件使能状态的对象。 |
**错误码:**
错误码介绍请参考[@ohos.commonEventManager(事件)](../errorcodes/errorcode-CommonEventService.md)
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 1500007 | The message send error. |
| 1500008 | The CEMS error. |
**示例:**
```ts
CommonEventManager.setStaticSubscriberState(false).then(() => {
console.info(`Set static subscriber state promise success`);
}).catch ((err) => {
console.info(`Set static subscriber state promise failed, errCode: ${err.code}, errMes: ${err.message}`);
});
```
\ No newline at end of file
...@@ -197,7 +197,7 @@ import featureAbility from '@ohos.ability.featureAbility'; ...@@ -197,7 +197,7 @@ import featureAbility from '@ohos.ability.featureAbility';
let context = featureAbility.getContext(); let context = featureAbility.getContext();
try { try {
data_preferences.deletePreferences(context, 'mystore', function (err, val) { data_preferences.deletePreferences(context, 'mystore', function (err) {
if (err) { if (err) {
console.info("Failed to delete preferences. code =" + err.code + ", message =" + err.message); console.info("Failed to delete preferences. code =" + err.code + ", message =" + err.message);
return; return;
...@@ -217,7 +217,7 @@ import UIAbility from '@ohos.app.ability.UIAbility'; ...@@ -217,7 +217,7 @@ import UIAbility from '@ohos.app.ability.UIAbility';
class EntryAbility extends UIAbility { class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
try { try {
data_preferences.deletePreferences(this.context, 'mystore', function (err, val) { data_preferences.deletePreferences(this.context, 'mystore', function (err) {
if (err) { if (err) {
console.info("Failed to delete preferences. code =" + err.code + ", message =" + err.message); console.info("Failed to delete preferences. code =" + err.code + ", message =" + err.message);
return; return;
...@@ -334,7 +334,7 @@ import featureAbility from '@ohos.ability.featureAbility'; ...@@ -334,7 +334,7 @@ import featureAbility from '@ohos.ability.featureAbility';
let context = featureAbility.getContext(); let context = featureAbility.getContext();
try { try {
data_preferences.removePreferencesFromCache(context, 'mystore', function (err, val) { data_preferences.removePreferencesFromCache(context, 'mystore', function (err) {
if (err) { if (err) {
console.info("Failed to remove preferences. code =" + err.code + ", message =" + err.message); console.info("Failed to remove preferences. code =" + err.code + ", message =" + err.message);
return; return;
...@@ -354,7 +354,7 @@ import UIAbility from '@ohos.app.ability.UIAbility'; ...@@ -354,7 +354,7 @@ import UIAbility from '@ohos.app.ability.UIAbility';
class EntryAbility extends UIAbility { class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
try { try {
data_preferences.removePreferencesFromCache(this.context, 'mystore', function (err, val) { data_preferences.removePreferencesFromCache(this.context, 'mystore', function (err) {
if (err) { if (err) {
console.info("Failed to remove preferences. code =" + err.code + ", message =" + err.message); console.info("Failed to remove preferences. code =" + err.code + ", message =" + err.message);
return; return;
......
...@@ -199,7 +199,7 @@ createDeviceManager(bundleName: string, callback: AsyncCallback&lt;DeviceManager ...@@ -199,7 +199,7 @@ createDeviceManager(bundleName: string, callback: AsyncCallback&lt;DeviceManager
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| --------- | -------------------- | ---- | ---------- | | --------- | -------------------- | ---- | ---------- |
| authType | number | 是 | 认证类型。 | | authType | number | 是 | 认证类型。 |
| extraInfo | {[key:string]&nbsp;:&nbsp;any} | 否 | 认证参数可扩展字段。 | | extraInfo | {[key:string]&nbsp;:&nbsp;any} | 否 | 认证参数可扩展字段。可选,默认为undefined。 |
## AuthInfo ## AuthInfo
...@@ -211,7 +211,7 @@ createDeviceManager(bundleName: string, callback: AsyncCallback&lt;DeviceManager ...@@ -211,7 +211,7 @@ createDeviceManager(bundleName: string, callback: AsyncCallback&lt;DeviceManager
| --------- | -------------------- | ---- | ---------- | | --------- | -------------------- | ---- | ---------- |
| authType | number | 是 | 认证类型。 | | authType | number | 是 | 认证类型。 |
| token | number | 是 | 认证Token。 | | token | number | 是 | 认证Token。 |
| extraInfo | {[key:string]&nbsp;:&nbsp;any} | 否 | 认证信息可扩展字段。 | | extraInfo | {[key:string]&nbsp;:&nbsp;any} | 否 | 认证信息可扩展字段。可选,默认为undefined。 |
## PublishInfo<sup>9+</sup> ## PublishInfo<sup>9+</sup>
...@@ -487,6 +487,8 @@ getDeviceInfo(networkId: string, callback:AsyncCallback&lt;DeviceInfo&gt;): void ...@@ -487,6 +487,8 @@ getDeviceInfo(networkId: string, callback:AsyncCallback&lt;DeviceInfo&gt;): void
```js ```js
try { try {
// 设备网络标识,可以从可信设备列表中获取
let networkId = "xxxxxxx"
dmInstance.getDeviceInfo(networkId, (err, data) => { dmInstance.getDeviceInfo(networkId, (err, data) => {
if (err) { if (err) {
console.error("getDeviceInfo errCode:" + err.code + ",errMessage:" + err.message); console.error("getDeviceInfo errCode:" + err.code + ",errMessage:" + err.message);
...@@ -530,6 +532,8 @@ getDeviceInfo(networkId: string): Promise&lt;DeviceInfo&gt; ...@@ -530,6 +532,8 @@ getDeviceInfo(networkId: string): Promise&lt;DeviceInfo&gt;
**示例:** **示例:**
```js ```js
// 设备网络标识,可以从可信设备列表中获取
let networkId = "xxxxxxx"
dmInstance.getDeviceInfo(networkId).then((data) => { dmInstance.getDeviceInfo(networkId).then((data) => {
console.log('get device info: ' + JSON.stringify(data)); console.log('get device info: ' + JSON.stringify(data));
}).catch((err) => { }).catch((err) => {
...@@ -541,7 +545,7 @@ getDeviceInfo(networkId: string): Promise&lt;DeviceInfo&gt; ...@@ -541,7 +545,7 @@ getDeviceInfo(networkId: string): Promise&lt;DeviceInfo&gt;
startDeviceDiscovery(subscribeInfo: SubscribeInfo): void startDeviceDiscovery(subscribeInfo: SubscribeInfo): void
发现周边设备。 发现周边设备。发现状态持续两分钟,超过两分钟,会停止发现,最大发现数量99个。
**系统能力**:SystemCapability.DistributedHardware.DeviceManager **系统能力**:SystemCapability.DistributedHardware.DeviceManager
...@@ -585,7 +589,7 @@ startDeviceDiscovery(subscribeInfo: SubscribeInfo): void ...@@ -585,7 +589,7 @@ startDeviceDiscovery(subscribeInfo: SubscribeInfo): void
startDeviceDiscovery(subscribeInfo: SubscribeInfo, filterOptions?: string): void startDeviceDiscovery(subscribeInfo: SubscribeInfo, filterOptions?: string): void
发现周边设备。 发现周边设备。发现状态持续两分钟,超过两分钟,会停止发现,最大发现数量99个。
**系统能力**:SystemCapability.DistributedHardware.DeviceManager **系统能力**:SystemCapability.DistributedHardware.DeviceManager
...@@ -594,7 +598,7 @@ startDeviceDiscovery(subscribeInfo: SubscribeInfo, filterOptions?: string): void ...@@ -594,7 +598,7 @@ startDeviceDiscovery(subscribeInfo: SubscribeInfo, filterOptions?: string): void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------------- | ------------------------------- | ---- | ----- | | ------------- | ------------------------------- | ---- | ----- |
| subscribeInfo | [SubscribeInfo](#subscribeinfo) | 是 | 发现信息。 | | subscribeInfo | [SubscribeInfo](#subscribeinfo) | 是 | 发现信息。 |
| filterOptions | string | 否 | 发现设备过滤信息。| | filterOptions | string | 否 | 发现设备过滤信息。可选,默认为undefined,发现未上线设备。|
**错误码:** **错误码:**
...@@ -673,7 +677,7 @@ stopDeviceDiscovery(subscribeId: number): void ...@@ -673,7 +677,7 @@ stopDeviceDiscovery(subscribeId: number): void
publishDeviceDiscovery(publishInfo: PublishInfo): void publishDeviceDiscovery(publishInfo: PublishInfo): void
发布设备发现。 发布设备发现。发布状态持续两分钟,超过两分钟会停止发布。
**系统能力**:SystemCapability.DistributedHardware.DeviceManager **系统能力**:SystemCapability.DistributedHardware.DeviceManager
...@@ -944,11 +948,11 @@ requestCredentialRegisterInfo(requestInfo: string, callback: AsyncCallback<{regi ...@@ -944,11 +948,11 @@ requestCredentialRegisterInfo(requestInfo: string, callback: AsyncCallback<{regi
"userId" : "123" "userId" : "123"
} }
try { try {
dmClass.requestCredentialRegisterInfo(credentialInfo, (data) => { dmInstance.requestCredentialRegisterInfo(credentialInfo, (data) => {
if (data) { if (data) {
console.info("requestCredentialRegisterInfo result:" + JSON.stringify(data)); console.info("requestCredentialRegisterInfo result:" + JSON.stringify(data));
} else { } else {
console.info.push("requestCredentialRegisterInfo result: data is null"); console.info("requestCredentialRegisterInfo result: data is null");
} }
}); });
} catch (err) { } catch (err) {
...@@ -995,11 +999,11 @@ importCredential(credentialInfo: string, callback: AsyncCallback<{resultInfo: st ...@@ -995,11 +999,11 @@ importCredential(credentialInfo: string, callback: AsyncCallback<{resultInfo: st
] ]
} }
try { try {
dmClass.importCredential(credentialInfo, (data) => { dmInstance.importCredential(credentialInfo, (data) => {
if (data) { if (data) {
console.info("importCredential result:" + JSON.stringify(data)); console.info("importCredential result:" + JSON.stringify(data));
} else { } else {
console.info.push("importCredential result: data is null"); console.info("importCredential result: data is null");
} }
}); });
} catch (err) { } catch (err) {
...@@ -1031,11 +1035,11 @@ deleteCredential(queryInfo: string, callback: AsyncCallback<{resultInfo: string} ...@@ -1031,11 +1035,11 @@ deleteCredential(queryInfo: string, callback: AsyncCallback<{resultInfo: string}
"userId" : "123" "userId" : "123"
} }
try { try {
dmClass.deleteCredential(queryInfo, (data) => { dmInstance.deleteCredential(queryInfo, (data) => {
if (data) { if (data) {
console.info("deleteCredential result:" + JSON.stringify(data)); console.info("deleteCredential result:" + JSON.stringify(data));
} else { } else {
console.info.push("deleteCredential result: data is null"); console.info("deleteCredential result: data is null");
} }
}); });
} catch (err) { } catch (err) {
......
...@@ -360,7 +360,7 @@ continueMission(parameter: ContinueDeviceInfo, options: ContinueCallback, callba ...@@ -360,7 +360,7 @@ continueMission(parameter: ContinueDeviceInfo, options: ContinueCallback, callba
迁移任务,以回调函数的方式返回。 迁移任务,以回调函数的方式返回。
**需要权限**:ohos.permission.MANAGE_MISSIONS and ohos.permission.DISTRIBUTED_DATASYNC **需要权限**:ohos.permission.MANAGE_MISSIONSohos.permission.DISTRIBUTED_DATASYNC
**系统能力**:SystemCapability.Ability.AbilityRuntime.Mission **系统能力**:SystemCapability.Ability.AbilityRuntime.Mission
...@@ -418,7 +418,7 @@ continueMission(parameter: ContinueDeviceInfo, options: ContinueCallback): Promi ...@@ -418,7 +418,7 @@ continueMission(parameter: ContinueDeviceInfo, options: ContinueCallback): Promi
迁移任务,以promise方式返回执行结果。 迁移任务,以promise方式返回执行结果。
**需要权限**:ohos.permission.MANAGE_MISSIONS and ohos.permission.DISTRIBUTED_DATASYNC **需要权限**:ohos.permission.MANAGE_MISSIONSohos.permission.DISTRIBUTED_DATASYNC
**系统能力**:SystemCapability.Ability.AbilityRuntime.Mission **系统能力**:SystemCapability.Ability.AbilityRuntime.Mission
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
> **说明:** > **说明:**
> >
> 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> 本模块接口需激活为[设备管理员应用](js-apis-enterprise-adminManager.md#adminmanagerenableadmin)后才能调用,实现相应功能。
## 导入模块 ## 导入模块
...@@ -48,7 +49,7 @@ let wantTemp = { ...@@ -48,7 +49,7 @@ let wantTemp = {
bundleName: "com.example.myapplication", bundleName: "com.example.myapplication",
abilityName: "EntryAbility", abilityName: "EntryAbility",
}; };
accountManager.disallowAddLocalAccount(admin, true, (error) => { accountManager.disallowAddLocalAccount(wantTemp, true, (error) => {
if (error != null) { if (error != null) {
console.log("error code:" + error.code + " error message:" + error.message); console.log("error code:" + error.code + " error message:" + error.message);
} }
......
...@@ -54,7 +54,7 @@ let enterpriseInfo = { ...@@ -54,7 +54,7 @@ let enterpriseInfo = {
name: "enterprise name", name: "enterprise name",
description: "enterprise description" description: "enterprise description"
} }
adminManager.enableAdmin(wantTemp, enterpriseInfo, adminManager.AdminType.ADMIN_TYPE_NORMAL, error => { adminManager.enableAdmin(wantTemp, enterpriseInfo, adminManager.AdminType.ADMIN_TYPE_SUPER, error => {
if (error != null) { if (error != null) {
console.log("error occurs" + error); console.log("error occurs" + error);
return; return;
...@@ -955,6 +955,6 @@ adminManager.unsubscribeManagedEvent(wantTemp, events).then(() => { ...@@ -955,6 +955,6 @@ adminManager.unsubscribeManagedEvent(wantTemp, events).then(() => {
| -------------------------- | ---- | ------------- | | -------------------------- | ---- | ------------- |
| MANAGED_EVENT_BUNDLE_ADDED | 0 | 应用安装事件。 | | MANAGED_EVENT_BUNDLE_ADDED | 0 | 应用安装事件。 |
| MANAGED_EVENT_BUNDLE_REMOVED | 1 | 应用卸载事件。 | | MANAGED_EVENT_BUNDLE_REMOVED | 1 | 应用卸载事件。 |
| MANAGED_EVENT_APP_START | 2 | 应用启动事件。 | | MANAGED_EVENT_APP_START<sup>10+</sup> | 2 | 应用启动事件。 |
| MANAGED_EVENT_APP_STOP | 3 | 应用停止事件。 | | MANAGED_EVENT_APP_STOP<sup>10+</sup> | 3 | 应用停止事件。 |
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
> **说明:** > **说明:**
> >
> 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> 本模块接口需激活为[设备管理员应用](js-apis-enterprise-adminManager.md#adminmanagerenableadmin)后才能调用,实现相应功能。
## 导入模块 ## 导入模块
...@@ -49,7 +50,7 @@ let wantTemp = { ...@@ -49,7 +50,7 @@ let wantTemp = {
bundleName: "com.example.myapplication", bundleName: "com.example.myapplication",
abilityName: "EntryAbility", abilityName: "EntryAbility",
}; };
let appIds = {"com.example.myapplication"}; let appIds = ["com.example.myapplication"];
applicationManager.addDisallowedRunningBundles(wantTemp, appIds, (error) => { applicationManager.addDisallowedRunningBundles(wantTemp, appIds, (error) => {
if (error != null) { if (error != null) {
...@@ -95,7 +96,7 @@ let wantTemp = { ...@@ -95,7 +96,7 @@ let wantTemp = {
bundleName: "com.example.myapplication", bundleName: "com.example.myapplication",
abilityName: "EntryAbility", abilityName: "EntryAbility",
}; };
let appIds = {"com.example.myapplication"}; let appIds = ["com.example.myapplication"];
applicationManager.addDisallowedRunningBundles(wantTemp, appIds, 100, (error) => { applicationManager.addDisallowedRunningBundles(wantTemp, appIds, 100, (error) => {
if (error != null) { if (error != null) {
...@@ -146,7 +147,7 @@ let wantTemp = { ...@@ -146,7 +147,7 @@ let wantTemp = {
bundleName: "com.example.myapplication", bundleName: "com.example.myapplication",
abilityName: "EntryAbility", abilityName: "EntryAbility",
}; };
let appIds = {"com.example.myapplication"}; let appIds = ["com.example.myapplication"];
applicationManager.addDisallowedRunningBundles(wantTemp, appIds, 100).then(() => { applicationManager.addDisallowedRunningBundles(wantTemp, appIds, 100).then(() => {
console.log("success"); console.log("success");
...@@ -191,7 +192,7 @@ let wantTemp = { ...@@ -191,7 +192,7 @@ let wantTemp = {
bundleName: "com.example.myapplication", bundleName: "com.example.myapplication",
abilityName: "EntryAbility", abilityName: "EntryAbility",
}; };
let appIds = {"com.example.myapplication"}; let appIds = ["com.example.myapplication"];
applicationManager.removeDisallowedRunningBundles(wantTemp, appIds, (error) => { applicationManager.removeDisallowedRunningBundles(wantTemp, appIds, (error) => {
if (error != null) { if (error != null) {
...@@ -237,7 +238,7 @@ let wantTemp = { ...@@ -237,7 +238,7 @@ let wantTemp = {
bundleName: "com.example.myapplication", bundleName: "com.example.myapplication",
abilityName: "EntryAbility", abilityName: "EntryAbility",
}; };
let appIds = {"com.example.myapplication"}; let appIds = ["com.example.myapplication"];
applicationManager.removeDisallowedRunningBundles(wantTemp, appIds, 100, (error) => { applicationManager.removeDisallowedRunningBundles(wantTemp, appIds, 100, (error) => {
if (error != null) { if (error != null) {
...@@ -288,7 +289,7 @@ let wantTemp = { ...@@ -288,7 +289,7 @@ let wantTemp = {
bundleName: "com.example.myapplication", bundleName: "com.example.myapplication",
abilityName: "EntryAbility", abilityName: "EntryAbility",
}; };
let appIds = {"com.example.myapplication"}; let appIds = ["com.example.myapplication"];
applicationManager.removeDisallowedRunningBundles(wantTemp, appIds, 100).then(() => { applicationManager.removeDisallowedRunningBundles(wantTemp, appIds, 100).then(() => {
console.log("success"); console.log("success");
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
> **说明:** > **说明:**
> >
> 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> 本模块接口需激活为[设备管理员应用](js-apis-enterprise-adminManager.md#adminmanagerenableadmin)后才能调用,实现相应功能。
## 导入模块 ## 导入模块
...@@ -48,9 +49,9 @@ let wantTemp = { ...@@ -48,9 +49,9 @@ let wantTemp = {
bundleName: "com.example.myapplication", bundleName: "com.example.myapplication",
abilityName: "EntryAbility", abilityName: "EntryAbility",
}; };
let appIds = {"com.example.myapplication"}; let appIds = ["com.example.myapplication"];
bundleManager.AddAllowedInstallBundles(wantTemp, appIds, (error) => { bundleManager.addAllowedInstallBundles(wantTemp, appIds, (error) => {
if (error != null) { if (error != null) {
console.log("error code:" + error.code + " error message:" + error.message); console.log("error code:" + error.code + " error message:" + error.message);
} }
...@@ -94,9 +95,9 @@ let wantTemp = { ...@@ -94,9 +95,9 @@ let wantTemp = {
bundleName: "com.example.myapplication", bundleName: "com.example.myapplication",
abilityName: "EntryAbility", abilityName: "EntryAbility",
}; };
let appIds = {"com.example.myapplication"}; let appIds = ["com.example.myapplication"];
bundleManager.AddAllowedInstallBundles(wantTemp, appIds, 100, (error) => { bundleManager.addAllowedInstallBundles(wantTemp, appIds, 100, (error) => {
if (error != null) { if (error != null) {
console.log("error code:" + error.code + " error message:" + error.message); console.log("error code:" + error.code + " error message:" + error.message);
} }
...@@ -145,7 +146,7 @@ let wantTemp = { ...@@ -145,7 +146,7 @@ let wantTemp = {
bundleName: "com.example.myapplication", bundleName: "com.example.myapplication",
abilityName: "EntryAbility", abilityName: "EntryAbility",
}; };
let appIds = {"com.example.myapplication"}; let appIds = ["com.example.myapplication"];
bundleManager.addAllowedInstallBundles(wantTemp, appIds, 100).then(() => { bundleManager.addAllowedInstallBundles(wantTemp, appIds, 100).then(() => {
console.log("success"); console.log("success");
...@@ -190,7 +191,7 @@ let wantTemp = { ...@@ -190,7 +191,7 @@ let wantTemp = {
bundleName: "com.example.myapplication", bundleName: "com.example.myapplication",
abilityName: "EntryAbility", abilityName: "EntryAbility",
}; };
let appIds = {"com.example.myapplication"}; let appIds = ["com.example.myapplication"];
bundleManager.removeAllowedInstallBundles(wantTemp, appIds, (error) => { bundleManager.removeAllowedInstallBundles(wantTemp, appIds, (error) => {
if (error != null) { if (error != null) {
...@@ -236,7 +237,7 @@ let wantTemp = { ...@@ -236,7 +237,7 @@ let wantTemp = {
bundleName: "com.example.myapplication", bundleName: "com.example.myapplication",
abilityName: "EntryAbility", abilityName: "EntryAbility",
}; };
let appIds = {"com.example.myapplication"}; let appIds = ["com.example.myapplication"];
bundleManager.removeAllowedInstallBundles(wantTemp, appIds, 100, (error) => { bundleManager.removeAllowedInstallBundles(wantTemp, appIds, 100, (error) => {
if (error != null) { if (error != null) {
...@@ -287,7 +288,7 @@ let wantTemp = { ...@@ -287,7 +288,7 @@ let wantTemp = {
bundleName: "com.example.myapplication", bundleName: "com.example.myapplication",
abilityName: "EntryAbility", abilityName: "EntryAbility",
}; };
let appIds = {"com.example.myapplication"}; let appIds = ["com.example.myapplication"];
bundleManager.removeAllowedInstallBundles(wantTemp, appIds, 100).then(() => { bundleManager.removeAllowedInstallBundles(wantTemp, appIds, 100).then(() => {
console.log("success"); console.log("success");
...@@ -467,7 +468,7 @@ let wantTemp = { ...@@ -467,7 +468,7 @@ let wantTemp = {
bundleName: "com.example.myapplication", bundleName: "com.example.myapplication",
abilityName: "EntryAbility", abilityName: "EntryAbility",
}; };
let appIds = {"com.example.myapplication"}; let appIds = ["com.example.myapplication"];
bundleManager.AddDisallowedInstallBundles(wantTemp, appIds, (error) => { bundleManager.AddDisallowedInstallBundles(wantTemp, appIds, (error) => {
if (error != null) { if (error != null) {
...@@ -513,7 +514,7 @@ let wantTemp = { ...@@ -513,7 +514,7 @@ let wantTemp = {
bundleName: "com.example.myapplication", bundleName: "com.example.myapplication",
abilityName: "EntryAbility", abilityName: "EntryAbility",
}; };
let appIds = {"com.example.myapplication"}; let appIds = ["com.example.myapplication"];
bundleManager.AddDisallowedInstallBundles(wantTemp, appIds, 100, (error) => { bundleManager.AddDisallowedInstallBundles(wantTemp, appIds, 100, (error) => {
if (error != null) { if (error != null) {
...@@ -564,7 +565,7 @@ let wantTemp = { ...@@ -564,7 +565,7 @@ let wantTemp = {
bundleName: "com.example.myapplication", bundleName: "com.example.myapplication",
abilityName: "EntryAbility", abilityName: "EntryAbility",
}; };
let appIds = {"com.example.myapplication"}; let appIds = ["com.example.myapplication"];
bundleManager.addDisallowedInstallBundles(wantTemp, appIds, 100).then(() => { bundleManager.addDisallowedInstallBundles(wantTemp, appIds, 100).then(() => {
console.log("success"); console.log("success");
...@@ -609,7 +610,7 @@ let wantTemp = { ...@@ -609,7 +610,7 @@ let wantTemp = {
bundleName: "com.example.myapplication", bundleName: "com.example.myapplication",
abilityName: "EntryAbility", abilityName: "EntryAbility",
}; };
let appIds = {"com.example.myapplication"}; let appIds = ["com.example.myapplication"];
bundleManager.removeDisallowedInstallBundles(wantTemp, appIds, (error) => { bundleManager.removeDisallowedInstallBundles(wantTemp, appIds, (error) => {
if (error != null) { if (error != null) {
...@@ -655,7 +656,7 @@ let wantTemp = { ...@@ -655,7 +656,7 @@ let wantTemp = {
bundleName: "com.example.myapplication", bundleName: "com.example.myapplication",
abilityName: "EntryAbility", abilityName: "EntryAbility",
}; };
let appIds = {"com.example.myapplication"}; let appIds = ["com.example.myapplication"];
bundleManager.removeDisallowedInstallBundles(wantTemp, appIds, 100, (error) => { bundleManager.removeDisallowedInstallBundles(wantTemp, appIds, 100, (error) => {
if (error != null) { if (error != null) {
...@@ -706,7 +707,7 @@ let wantTemp = { ...@@ -706,7 +707,7 @@ let wantTemp = {
bundleName: "com.example.myapplication", bundleName: "com.example.myapplication",
abilityName: "EntryAbility", abilityName: "EntryAbility",
}; };
let appIds = {"com.example.myapplication"}; let appIds = ["com.example.myapplication"];
bundleManager.removeDisallowedInstallBundles(wantTemp, appIds, 100).then(() => { bundleManager.removeDisallowedInstallBundles(wantTemp, appIds, 100).then(() => {
console.log("success"); console.log("success");
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
> **说明**: > **说明**:
> >
> 本模块首批接口从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > 本模块首批接口从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> 本模块接口需激活为[设备管理员应用](js-apis-enterprise-adminManager.md#adminmanagerenableadmin)后才能调用,实现相应功能。
## 导入模块 ## 导入模块
...@@ -274,7 +275,7 @@ let wantTemp = { ...@@ -274,7 +275,7 @@ let wantTemp = {
bundleName: "bundleName", bundleName: "bundleName",
abilityName: "abilityName", abilityName: "abilityName",
}; };
dateTimeManager.disallowModifyDateTime(wantTemp).then(() => { dateTimeManager.isModifyDateTimeDisallowed(wantTemp).then(() => {
}).catch((error) => { }).catch((error) => {
console.log("error code:" + error.code + " error message:" + error.message); console.log("error code:" + error.code + " error message:" + error.message);
}) })
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
> **说明**: > **说明**:
> >
> 本模块首批接口从API version 10 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > 本模块首批接口从API version 10 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> 本模块接口需激活为[设备管理员应用](js-apis-enterprise-adminManager.md#adminmanagerenableadmin)后才能调用,实现相应功能。
## 导入模块 ## 导入模块
...@@ -14,7 +15,7 @@ import deviceControl from '@ohos.enterprise.deviceControl' ...@@ -14,7 +15,7 @@ import deviceControl from '@ohos.enterprise.deviceControl'
## deviceControl.resetFactory ## deviceControl.resetFactory
resetFactory(admin: Want, callback: AsyncCallback<void>): void resetFactory(admin: Want, callback: AsyncCallback\<void>): void
指定设备管理员应用恢复出厂设置。使用callback异步回调。 指定设备管理员应用恢复出厂设置。使用callback异步回调。
...@@ -56,7 +57,7 @@ deviceControl.resetFactory(wantTemp, (error) => { ...@@ -56,7 +57,7 @@ deviceControl.resetFactory(wantTemp, (error) => {
## deviceControl.resetFactory ## deviceControl.resetFactory
resetFactory(admin: Want): Promise<void> resetFactory(admin: Want): Promise\<void>
恢复出厂设置。使用Promise形式返回设置结果。 恢复出厂设置。使用Promise形式返回设置结果。
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
> **说明:** > **说明:**
> >
> 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> 本模块接口需激活为[设备管理员应用](js-apis-enterprise-adminManager.md#adminmanagerenableadmin)后才能调用,实现相应功能。
## 导入模块 ## 导入模块
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
> **说明:** > **说明:**
> >
> 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> 本模块接口需激活为[设备管理员应用](js-apis-enterprise-adminManager.md#adminmanagerenableadmin)后才能调用,实现相应功能。
## 导入模块 ## 导入模块
...@@ -47,7 +48,7 @@ let wantTemp = { ...@@ -47,7 +48,7 @@ let wantTemp = {
bundleName: "com.example.myapplication", bundleName: "com.example.myapplication",
abilityName: "EntryAbility", abilityName: "EntryAbility",
}; };
networkManager.getAllNetworkInterfaces(admin, (error, result) => { networkManager.getAllNetworkInterfaces(wantTemp, (error, result) => {
if (error != null) { if (error != null) {
console.log("error code:" + error.code + " error message:" + error.message); console.log("error code:" + error.code + " error message:" + error.message);
return; return;
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
> **说明:** > **说明:**
> >
> 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> 本模块接口需激活为[设备管理员应用](js-apis-enterprise-adminManager.md#adminmanagerenableadmin)后才能调用,实现相应功能。
## 导入模块 ## 导入模块
...@@ -139,7 +140,7 @@ let wantTemp = { ...@@ -139,7 +140,7 @@ let wantTemp = {
bundleName: "com.example.myapplication", bundleName: "com.example.myapplication",
abilityName: "EntryAbility", abilityName: "EntryAbility",
}; };
let profile : WifiProfile = { let profile : wifiManager.WifiProfile = {
"ssid": "name", "ssid": "name",
"preSharedKey": "passwd", "preSharedKey": "passwd",
"securityType": wifiManager.WifiSecurityType.WIFI_SEC_TYPE_PSK "securityType": wifiManager.WifiSecurityType.WIFI_SEC_TYPE_PSK
...@@ -194,12 +195,12 @@ let wantTemp = { ...@@ -194,12 +195,12 @@ let wantTemp = {
bundleName: "com.example.myapplication", bundleName: "com.example.myapplication",
abilityName: "EntryAbility", abilityName: "EntryAbility",
}; };
let profile : WifiProfile = { let profile : wifiManager.WifiProfile = {
"ssid": "name", "ssid": "name",
"preSharedKey": "passwd", "preSharedKey": "passwd",
"securityType": wifiManager.WifiSecurityType.WIFI_SEC_TYPE_PSK "securityType": wifiManager.WifiSecurityType.WIFI_SEC_TYPE_PSK
}; };
wifiManager.isWifiActive(wantTemp, profile).then(() => { wifiManager.setWifiProfile(wantTemp, profile).then(() => {
console.log("set wifi success"); console.log("set wifi success");
}).catch(error => { }).catch(error => {
console.log("error code:" + error.code + " error message:" + error.message); console.log("error code:" + error.code + " error message:" + error.message);
......
...@@ -77,6 +77,25 @@ generateKeyItem(keyAlias: string, options: HuksOptions, callback: AsyncCallback\ ...@@ -77,6 +77,25 @@ generateKeyItem(keyAlias: string, options: HuksOptions, callback: AsyncCallback\
| options | [HuksOptions](#huksoptions) | 是 | 用于存放生成key所需TAG。其中密钥使用的算法、密钥用途、密钥长度为必选参数。 | | options | [HuksOptions](#huksoptions) | 是 | 用于存放生成key所需TAG。其中密钥使用的算法、密钥用途、密钥长度为必选参数。 |
| callback | AsyncCallback\<void> | 是 | 回调函数。未捕获error时代表用户指定别名的密钥生成成功,基于密钥不出TEE原则,此接口不会返回密钥材料内容,若捕获error,则为生成阶段出现异常。 | | callback | AsyncCallback\<void> | 是 | 回调函数。未捕获error时代表用户指定别名的密钥生成成功,基于密钥不出TEE原则,此接口不会返回密钥材料内容,若捕获error,则为生成阶段出现异常。 |
**错误码:**
以下错误码的详细介绍请参见[HUKS错误码](../errorcodes/errorcode-huks.md)
| 错误码ID | 错误信息 |
| -------- | ------------- |
| 401 | argument is invalid. |
| 801 | api is not supported. |
| 12000001 | algorithm mode is not supported. |
| 12000002 | algorithm param is missing. |
| 12000003 | algorithm param is invalid. |
| 12000004 | operating file failed. |
| 12000005 | IPC communication failed. |
| 12000006 | error occured in crypto engine. |
| 12000012 | external error. |
| 12000013 | queried credential does not exist. |
| 12000014 | memory is insufficient. |
| 12000015 | call service failed. |
**示例:** **示例:**
```js ```js
...@@ -132,6 +151,25 @@ generateKeyItem(keyAlias: string, options: HuksOptions) : Promise\<void> ...@@ -132,6 +151,25 @@ generateKeyItem(keyAlias: string, options: HuksOptions) : Promise\<void>
| keyAlias | string | 是 | 密钥别名。 | | keyAlias | string | 是 | 密钥别名。 |
| options | [HuksOptions](#huksoptions) | 是 | 用于存放生成key所需TAG。其中密钥使用的算法、密钥用途、密钥长度为必选参数。 | | options | [HuksOptions](#huksoptions) | 是 | 用于存放生成key所需TAG。其中密钥使用的算法、密钥用途、密钥长度为必选参数。 |
**错误码:**
以下错误码的详细介绍请参见[HUKS错误码](../errorcodes/errorcode-huks.md)
| 错误码ID | 错误信息 |
| -------- | ------------- |
| 401 | argument is invalid. |
| 801 | api is not supported. |
| 12000001 | algorithm mode is not supported. |
| 12000002 | algorithm param is missing. |
| 12000003 | algorithm param is invalid. |
| 12000004 | operating file failed. |
| 12000005 | IPC communication failed. |
| 12000006 | error occured in crypto engine. |
| 12000012 | external error. |
| 12000013 | queried credential does not exist. |
| 12000014 | memory is insufficient. |
| 12000015 | call service failed. |
**示例:** **示例:**
```js ```js
...@@ -188,6 +226,20 @@ deleteKeyItem(keyAlias: string, options: HuksOptions, callback: AsyncCallback\<v ...@@ -188,6 +226,20 @@ deleteKeyItem(keyAlias: string, options: HuksOptions, callback: AsyncCallback\<v
| options | [HuksOptions](#huksoptions) | 是 | 空对象(此处传空即可)。 | | options | [HuksOptions](#huksoptions) | 是 | 空对象(此处传空即可)。 |
| callback | AsyncCallback\<void> | 是 | 回调函数。不返回err值时表示接口使用成功,其他时为错误。 | | callback | AsyncCallback\<void> | 是 | 回调函数。不返回err值时表示接口使用成功,其他时为错误。 |
**错误码:**
以下错误码的详细介绍请参见[HUKS错误码](../errorcodes/errorcode-huks.md)
| 错误码ID | 错误信息 |
| -------- | ------------- |
| 401 | argument is invalid. |
| 801 | api is not supported. |
| 12000004 | operating file failed. |
| 12000005 | IPC communication failed. |
| 12000011 | queried entity does not exist. |
| 12000012 | external error. |
| 12000014 | memory is insufficient. |
**示例:** **示例:**
```js ```js
...@@ -224,6 +276,20 @@ deleteKeyItem(keyAlias: string, options: HuksOptions) : Promise\<void> ...@@ -224,6 +276,20 @@ deleteKeyItem(keyAlias: string, options: HuksOptions) : Promise\<void>
| keyAlias | string | 是 | 密钥别名,应为生成key时传入的别名。 | | keyAlias | string | 是 | 密钥别名,应为生成key时传入的别名。 |
| options | [HuksOptions](#huksoptions) | 是 | 空对象(此处传空即可)。 | | options | [HuksOptions](#huksoptions) | 是 | 空对象(此处传空即可)。 |
**错误码:**
以下错误码的详细介绍请参见[HUKS错误码](../errorcodes/errorcode-huks.md)
| 错误码ID | 错误信息 |
| -------- | ------------- |
| 401 | argument is invalid. |
| 801 | api is not supported. |
| 12000004 | operating file failed. |
| 12000005 | IPC communication failed. |
| 12000011 | queried entity does not exist. |
| 12000012 | external error. |
| 12000014 | memory is insufficient. |
**示例:** **示例:**
```js ```js
...@@ -291,6 +357,26 @@ importKeyItem(keyAlias: string, options: HuksOptions, callback: AsyncCallback\<v ...@@ -291,6 +357,26 @@ importKeyItem(keyAlias: string, options: HuksOptions, callback: AsyncCallback\<v
| options | [HuksOptions](#huksoptions) | 是 | 用于导入时所需TAG和需要导入的密钥。其中密钥使用的算法、密钥用途、密钥长度为必选参数。 | | options | [HuksOptions](#huksoptions) | 是 | 用于导入时所需TAG和需要导入的密钥。其中密钥使用的算法、密钥用途、密钥长度为必选参数。 |
| callback | AsyncCallback\<void> | 是 | 回调函数。不返回err值时表示接口使用成功,其他时为错误。 | | callback | AsyncCallback\<void> | 是 | 回调函数。不返回err值时表示接口使用成功,其他时为错误。 |
**错误码:**
以下错误码的详细介绍请参见[HUKS错误码](../errorcodes/errorcode-huks.md)
| 错误码ID | 错误信息 |
| -------- | ------------- |
| 401 | argument is invalid. |
| 801 | api is not supported. |
| 12000001 | algorithm mode is not supported. |
| 12000002 | algorithm param is missing. |
| 12000003 | algorithm param is invalid. |
| 12000004 | operating file failed. |
| 12000005 | IPC communication failed. |
| 12000006 | error occured in crypto engine. |
| 12000011 | queried entity does not exist. |
| 12000012 | external error. |
| 12000013 | queried credential does not exist. |
| 12000014 | memory is insufficient. |
| 12000015 | call service failed. |
**示例:** **示例:**
```js ```js
...@@ -358,6 +444,26 @@ importKeyItem(keyAlias: string, options: HuksOptions) : Promise\<void> ...@@ -358,6 +444,26 @@ importKeyItem(keyAlias: string, options: HuksOptions) : Promise\<void>
| keyAlias | string | 是 | 密钥别名。 | | keyAlias | string | 是 | 密钥别名。 |
| options | [HuksOptions](#huksoptions) | 是 | 用于导入时所需TAG和需要导入的密钥。其中密钥使用的算法、密钥用途、密钥长度为必选参数。 | | options | [HuksOptions](#huksoptions) | 是 | 用于导入时所需TAG和需要导入的密钥。其中密钥使用的算法、密钥用途、密钥长度为必选参数。 |
**错误码:**
以下错误码的详细介绍请参见[HUKS错误码](../errorcodes/errorcode-huks.md)
| 错误码ID | 错误信息 |
| -------- | ------------- |
| 401 | argument is invalid. |
| 801 | api is not supported. |
| 12000001 | algorithm mode is not supported. |
| 12000002 | algorithm param is missing. |
| 12000003 | algorithm param is invalid. |
| 12000004 | operating file failed. |
| 12000005 | IPC communication failed. |
| 12000006 | error occured in crypto engine. |
| 12000011 | queried entity does not exist. |
| 12000012 | external error. |
| 12000013 | queried credential does not exist. |
| 12000014 | memory is insufficient. |
| 12000015 | call service failed. |
**示例:** **示例:**
```js ```js
...@@ -428,6 +534,25 @@ attestKeyItem(keyAlias: string, options: HuksOptions, callback: AsyncCallback\<H ...@@ -428,6 +534,25 @@ attestKeyItem(keyAlias: string, options: HuksOptions, callback: AsyncCallback\<H
| options | [HuksOptions](#huksoptions) | 是 | 用于获取证书时指定所需参数与数据。 | | options | [HuksOptions](#huksoptions) | 是 | 用于获取证书时指定所需参数与数据。 |
| callback | AsyncCallback<[HuksReturnResult](#huksreturnresult9)> | 是 | 回调函数。不返回err值时表示接口使用成功,其他时为错误。 | | callback | AsyncCallback<[HuksReturnResult](#huksreturnresult9)> | 是 | 回调函数。不返回err值时表示接口使用成功,其他时为错误。 |
**错误码:**
以下错误码的详细介绍请参见[HUKS错误码](../errorcodes/errorcode-huks.md)
| 错误码ID | 错误信息 |
| -------- | ------------- |
| 201 | check permission failed. |
| 401 | argument is invalid. |
| 801 | api is not supported. |
| 12000001 | algorithm mode is not supported. |
| 12000002 | algorithm param is missing. |
| 12000003 | algorithm param is invalid. |
| 12000004 | operating file failed. |
| 12000005 | IPC communication failed. |
| 12000006 | error occured in crypto engine. |
| 12000011 | queried entity does not exist. |
| 12000012 | external error. |
| 12000014 | memory is insufficient. |
**示例:** **示例:**
```js ```js
...@@ -555,6 +680,25 @@ attestKeyItem(keyAlias: string, options: HuksOptions) : Promise\<HuksReturnResul ...@@ -555,6 +680,25 @@ attestKeyItem(keyAlias: string, options: HuksOptions) : Promise\<HuksReturnResul
| ---------------------------------------------- | --------------------------------------------- | | ---------------------------------------------- | --------------------------------------------- |
| Promise<[HuksReturnResult](#huksreturnresult9)> | Promise对象。不返回err值时表示接口使用成功,其他时为错误。 | | Promise<[HuksReturnResult](#huksreturnresult9)> | Promise对象。不返回err值时表示接口使用成功,其他时为错误。 |
**错误码:**
以下错误码的详细介绍请参见[HUKS错误码](../errorcodes/errorcode-huks.md)
| 错误码ID | 错误信息 |
| -------- | ------------- |
| 201 | check permission failed. |
| 401 | argument is invalid. |
| 801 | api is not supported. |
| 12000001 | algorithm mode is not supported. |
| 12000002 | algorithm param is missing. |
| 12000003 | algorithm param is invalid. |
| 12000004 | operating file failed. |
| 12000005 | IPC communication failed. |
| 12000006 | error occured in crypto engine. |
| 12000011 | queried entity does not exist. |
| 12000012 | external error. |
| 12000014 | memory is insufficient. |
**示例:** **示例:**
```js ```js
...@@ -678,6 +822,26 @@ importWrappedKeyItem(keyAlias: string, wrappingKeyAlias: string, options: HuksOp ...@@ -678,6 +822,26 @@ importWrappedKeyItem(keyAlias: string, wrappingKeyAlias: string, options: HuksOp
| options | [HuksOptions](#huksoptions) | 是 | 用于导入时所需TAG和需要导入的加密的密钥数据。其中密钥使用的算法、密钥用途、密钥长度为必选参数。 | | options | [HuksOptions](#huksoptions) | 是 | 用于导入时所需TAG和需要导入的加密的密钥数据。其中密钥使用的算法、密钥用途、密钥长度为必选参数。 |
| callback | AsyncCallback\<void> | 是 | 回调函数。不返回err值时表示接口使用成功,其他时为错误。 | | callback | AsyncCallback\<void> | 是 | 回调函数。不返回err值时表示接口使用成功,其他时为错误。 |
**错误码:**
以下错误码的详细介绍请参见[HUKS错误码](../errorcodes/errorcode-huks.md)
| 错误码ID | 错误信息 |
| -------- | ------------- |
| 401 | argument is invalid. |
| 801 | api is not supported. |
| 12000001 | algorithm mode is not supported. |
| 12000002 | algorithm param is missing. |
| 12000003 | algorithm param is invalid. |
| 12000004 | operating file failed. |
| 12000005 | IPC communication failed. |
| 12000006 | error occured in crypto engine. |
| 12000011 | queried entity does not exist. |
| 12000012 | external error. |
| 12000013 | queried credential does not exist. |
| 12000014 | memory is insufficient. |
| 12000015 | call service failed. |
**示例:** **示例:**
```js ```js
...@@ -893,6 +1057,26 @@ importWrappedKeyItem(keyAlias: string, wrappingKeyAlias: string, options: HuksOp ...@@ -893,6 +1057,26 @@ importWrappedKeyItem(keyAlias: string, wrappingKeyAlias: string, options: HuksOp
| wrappingKeyAlias | string | 是 | 密钥别名,对应密钥用于解密加密的密钥数据。 | | wrappingKeyAlias | string | 是 | 密钥别名,对应密钥用于解密加密的密钥数据。 |
| options | [HuksOptions](#huksoptions) | 是 | 用于导入时所需TAG和需要导入的加密的密钥数据。其中密钥使用的算法、密钥用途、密钥长度为必选参数。 | | options | [HuksOptions](#huksoptions) | 是 | 用于导入时所需TAG和需要导入的加密的密钥数据。其中密钥使用的算法、密钥用途、密钥长度为必选参数。 |
**错误码:**
以下错误码的详细介绍请参见[HUKS错误码](../errorcodes/errorcode-huks.md)
| 错误码ID | 错误信息 |
| -------- | ------------- |
| 401 | argument is invalid. |
| 801 | api is not supported. |
| 12000001 | algorithm mode is not supported. |
| 12000002 | algorithm param is missing. |
| 12000003 | algorithm param is invalid. |
| 12000004 | operating file failed. |
| 12000005 | IPC communication failed. |
| 12000006 | error occured in crypto engine. |
| 12000011 | queried entity does not exist. |
| 12000012 | external error. |
| 12000013 | queried credential does not exist. |
| 12000014 | memory is insufficient. |
| 12000015 | call service failed. |
**示例:** **示例:**
```js ```js
...@@ -928,6 +1112,24 @@ exportKeyItem(keyAlias: string, options: HuksOptions, callback: AsyncCallback\<H ...@@ -928,6 +1112,24 @@ exportKeyItem(keyAlias: string, options: HuksOptions, callback: AsyncCallback\<H
| options | [HuksOptions](#huksoptions) | 是 | 空对象(此处传空即可)。 | | options | [HuksOptions](#huksoptions) | 是 | 空对象(此处传空即可)。 |
| callback | AsyncCallback<[HuksReturnResult](#huksreturnresult9)> | 是 | 回调函数。不返回err值时表示接口使用成功,其他时为错误。outData:返回从密钥中导出的公钥。 | | callback | AsyncCallback<[HuksReturnResult](#huksreturnresult9)> | 是 | 回调函数。不返回err值时表示接口使用成功,其他时为错误。outData:返回从密钥中导出的公钥。 |
**错误码:**
以下错误码的详细介绍请参见[HUKS错误码](../errorcodes/errorcode-huks.md)
| 错误码ID | 错误信息 |
| -------- | ------------- |
| 401 | argument is invalid. |
| 801 | api is not supported. |
| 12000001 | algorithm mode is not supported. |
| 12000002 | algorithm param is missing. |
| 12000003 | algorithm param is invalid. |
| 12000004 | operating file failed. |
| 12000005 | IPC communication failed. |
| 12000006 | error occured in crypto engine. |
| 12000011 | queried entity does not exist. |
| 12000012 | external error. |
| 12000014 | memory is insufficient. |
**示例:** **示例:**
```js ```js
...@@ -970,6 +1172,24 @@ exportKeyItem(keyAlias: string, options: HuksOptions) : Promise\<HuksReturnResul ...@@ -970,6 +1172,24 @@ exportKeyItem(keyAlias: string, options: HuksOptions) : Promise\<HuksReturnResul
| ---------------------------------------------- | ------------------------------------------------------------ | | ---------------------------------------------- | ------------------------------------------------------------ |
| Promise<[HuksReturnResult](#huksreturnresult9)> | Promise对象。不返回err值时表示接口使用成功,其他时为错误。outData:返回从密钥中导出的公钥。 | | Promise<[HuksReturnResult](#huksreturnresult9)> | Promise对象。不返回err值时表示接口使用成功,其他时为错误。outData:返回从密钥中导出的公钥。 |
**错误码:**
以下错误码的详细介绍请参见[HUKS错误码](../errorcodes/errorcode-huks.md)
| 错误码ID | 错误信息 |
| -------- | ------------- |
| 401 | argument is invalid. |
| 801 | api is not supported. |
| 12000001 | algorithm mode is not supported. |
| 12000002 | algorithm param is missing. |
| 12000003 | algorithm param is invalid. |
| 12000004 | operating file failed. |
| 12000005 | IPC communication failed. |
| 12000006 | error occured in crypto engine. |
| 12000011 | queried entity does not exist. |
| 12000012 | external error. |
| 12000014 | memory is insufficient. |
**示例:** **示例:**
```js ```js
...@@ -1007,6 +1227,24 @@ getKeyItemProperties(keyAlias: string, options: HuksOptions, callback: AsyncCall ...@@ -1007,6 +1227,24 @@ getKeyItemProperties(keyAlias: string, options: HuksOptions, callback: AsyncCall
| options | [HuksOptions](#huksoptions) | 是 | 空对象(此处传空即可)。 | | options | [HuksOptions](#huksoptions) | 是 | 空对象(此处传空即可)。 |
| callback | AsyncCallback<[HuksReturnResult](#huksreturnresult9)> | 是 | 回调函数。不返回err值时表示接口使用成功,其他时为错误。properties:返回值为生成密钥时所需参数。 | | callback | AsyncCallback<[HuksReturnResult](#huksreturnresult9)> | 是 | 回调函数。不返回err值时表示接口使用成功,其他时为错误。properties:返回值为生成密钥时所需参数。 |
**错误码:**
以下错误码的详细介绍请参见[HUKS错误码](../errorcodes/errorcode-huks.md)
| 错误码ID | 错误信息 |
| -------- | ------------- |
| 401 | argument is invalid. |
| 801 | api is not supported. |
| 12000001 | algorithm mode is not supported. |
| 12000002 | algorithm param is missing. |
| 12000003 | algorithm param is invalid. |
| 12000004 | operating file failed. |
| 12000005 | IPC communication failed. |
| 12000006 | error occured in crypto engine. |
| 12000011 | queried entity does not exist. |
| 12000012 | external error. |
| 12000014 | memory is insufficient. |
**示例:** **示例:**
```js ```js
...@@ -1049,6 +1287,24 @@ getKeyItemProperties(keyAlias: string, options: HuksOptions) : Promise\<HuksRetu ...@@ -1049,6 +1287,24 @@ getKeyItemProperties(keyAlias: string, options: HuksOptions) : Promise\<HuksRetu
| ----------------------------------------------- | ------------------------------------------------------------ | | ----------------------------------------------- | ------------------------------------------------------------ |
| Promise\<[HuksReturnResult](#huksreturnresult9)> | Promise对象。不返回err值时表示接口使用成功,其他时为错误。properties:返回值为生成密钥时所需参数。 | | Promise\<[HuksReturnResult](#huksreturnresult9)> | Promise对象。不返回err值时表示接口使用成功,其他时为错误。properties:返回值为生成密钥时所需参数。 |
**错误码:**
以下错误码的详细介绍请参见[HUKS错误码](../errorcodes/errorcode-huks.md)
| 错误码ID | 错误信息 |
| -------- | ------------- |
| 401 | argument is invalid. |
| 801 | api is not supported. |
| 12000001 | algorithm mode is not supported. |
| 12000002 | algorithm param is missing. |
| 12000003 | algorithm param is invalid. |
| 12000004 | operating file failed. |
| 12000005 | IPC communication failed. |
| 12000006 | error occured in crypto engine. |
| 12000011 | queried entity does not exist. |
| 12000012 | external error. |
| 12000014 | memory is insufficient. |
**示例:** **示例:**
```js ```js
...@@ -1086,6 +1342,22 @@ isKeyItemExist(keyAlias: string, options: HuksOptions, callback: AsyncCallback\< ...@@ -1086,6 +1342,22 @@ isKeyItemExist(keyAlias: string, options: HuksOptions, callback: AsyncCallback\<
| options | [HuksOptions](#huksoptions) | 是 | 空对象(此处传空即可)。 | | options | [HuksOptions](#huksoptions) | 是 | 空对象(此处传空即可)。 |
| callback | AsyncCallback\<boolean> | 是 | 回调函数。若密钥存在,data为true,若密钥不存在,则error中会输出密钥不存在的error code。 | | callback | AsyncCallback\<boolean> | 是 | 回调函数。若密钥存在,data为true,若密钥不存在,则error中会输出密钥不存在的error code。 |
**错误码:**
以下错误码的详细介绍请参见[HUKS错误码](../errorcodes/errorcode-huks.md)
| 错误码ID | 错误信息 |
| -------- | ------------- |
| 401 | argument is invalid. |
| 801 | api is not supported. |
| 12000002 | algorithm param is missing. |
| 12000003 | algorithm param is invalid. |
| 12000004 | operating file failed. |
| 12000005 | IPC communication failed. |
| 12000006 | error occured in crypto engine. |
| 12000012 | external error. |
| 12000014 | memory is insufficient. |
**示例:** **示例:**
```js ```js
...@@ -1132,6 +1404,22 @@ isKeyItemExist(keyAlias: string, options: HuksOptions) : Promise\<boolean> ...@@ -1132,6 +1404,22 @@ isKeyItemExist(keyAlias: string, options: HuksOptions) : Promise\<boolean>
| ----------------- | --------------------------------------- | | ----------------- | --------------------------------------- |
| Promise\<boolean> | Promise对象。密钥存在时,可通过then进行密钥存在后的相关处理,若不存在,可通过error处理密钥不存在后的相关业务操作。 | | Promise\<boolean> | Promise对象。密钥存在时,可通过then进行密钥存在后的相关处理,若不存在,可通过error处理密钥不存在后的相关业务操作。 |
**错误码:**
以下错误码的详细介绍请参见[HUKS错误码](../errorcodes/errorcode-huks.md)
| 错误码ID | 错误信息 |
| -------- | ------------- |
| 401 | argument is invalid. |
| 801 | api is not supported. |
| 12000002 | algorithm param is missing. |
| 12000003 | algorithm param is invalid. |
| 12000004 | operating file failed. |
| 12000005 | IPC communication failed. |
| 12000006 | error occured in crypto engine. |
| 12000012 | external error. |
| 12000014 | memory is insufficient. |
**示例:** **示例:**
```js ```js
...@@ -1171,6 +1459,25 @@ initSession操作密钥接口,使用Callback回调异步返回结果。huks.in ...@@ -1171,6 +1459,25 @@ initSession操作密钥接口,使用Callback回调异步返回结果。huks.in
| options | [HuksOptions](#huksoptions) | 是 | initSession操作的参数集合。 | | options | [HuksOptions](#huksoptions) | 是 | initSession操作的参数集合。 |
| callback | AsyncCallback\<[HuksSessionHandle](#hukssessionhandle9)> | 是 | 回调函数。将initSession操作返回的handle添加到密钥管理系统的回调。 | | callback | AsyncCallback\<[HuksSessionHandle](#hukssessionhandle9)> | 是 | 回调函数。将initSession操作返回的handle添加到密钥管理系统的回调。 |
**错误码:**
以下错误码的详细介绍请参见[HUKS错误码](../errorcodes/errorcode-huks.md)
| 错误码ID | 错误信息 |
| -------- | ------------- |
| 401 | argument is invalid. |
| 801 | api is not supported. |
| 12000001 | algorithm mode is not supported. |
| 12000002 | algorithm param is missing. |
| 12000003 | algorithm param is invalid. |
| 12000004 | operating file failed. |
| 12000005 | IPC communication failed. |
| 12000006 | error occured in crypto engine. |
| 12000010 | the number of sessions has reached limit. |
| 12000011 | queried entity does not exist. |
| 12000012 | external error. |
| 12000014 | memory is insufficient. |
## huks.initSession<sup>9+</sup> ## huks.initSession<sup>9+</sup>
initSession(keyAlias: string, options: HuksOptions) : Promise\<HuksSessionHandle> initSession(keyAlias: string, options: HuksOptions) : Promise\<HuksSessionHandle>
...@@ -1192,6 +1499,25 @@ initSession操作密钥接口,使用Promise方式异步返回结果。huks.ini ...@@ -1192,6 +1499,25 @@ initSession操作密钥接口,使用Promise方式异步返回结果。huks.ini
| ----------------------------------- | -------------------------------------------------- | | ----------------------------------- | -------------------------------------------------- |
| Promise\<[HuksSessionHandle](#hukssessionhandle9)> | Promise对象。将initSession操作返回的handle添加到密钥管理系统的回调。 | | Promise\<[HuksSessionHandle](#hukssessionhandle9)> | Promise对象。将initSession操作返回的handle添加到密钥管理系统的回调。 |
**错误码:**
以下错误码的详细介绍请参见[HUKS错误码](../errorcodes/errorcode-huks.md)
| 错误码ID | 错误信息 |
| -------- | ------------- |
| 401 | argument is invalid. |
| 801 | api is not supported. |
| 12000001 | algorithm mode is not supported. |
| 12000002 | algorithm param is missing. |
| 12000003 | algorithm param is invalid. |
| 12000004 | operating file failed. |
| 12000005 | IPC communication failed. |
| 12000006 | error occured in crypto engine. |
| 12000010 | the number of sessions has reached limit. |
| 12000011 | queried entity does not exist. |
| 12000012 | external error. |
| 12000014 | memory is insufficient. |
## huks.updateSession<sup>9+</sup> ## huks.updateSession<sup>9+</sup>
updateSession(handle: number, options: HuksOptions, callback: AsyncCallback\<HuksReturnResult>) : void updateSession(handle: number, options: HuksOptions, callback: AsyncCallback\<HuksReturnResult>) : void
...@@ -1208,6 +1534,26 @@ updateSession操作密钥接口,使用Callback回调异步返回结果。huks. ...@@ -1208,6 +1534,26 @@ updateSession操作密钥接口,使用Callback回调异步返回结果。huks.
| options | [HuksOptions](#huksoptions) | 是 | updateSession的参数集合。 | | options | [HuksOptions](#huksoptions) | 是 | updateSession的参数集合。 |
| callback | AsyncCallback<[HuksReturnResult](#huksreturnresult9)> | 是 | 回调函数。将updateSession操作的结果添加到密钥管理系统的回调。 | | callback | AsyncCallback<[HuksReturnResult](#huksreturnresult9)> | 是 | 回调函数。将updateSession操作的结果添加到密钥管理系统的回调。 |
**错误码:**
以下错误码的详细介绍请参见[HUKS错误码](../errorcodes/errorcode-huks.md)
| 错误码ID | 错误信息 |
| -------- | ------------- |
| 401 | argument is invalid. |
| 801 | api is not supported. |
| 12000001 | algorithm mode is not supported. |
| 12000002 | algorithm param is missing. |
| 12000003 | algorithm param is invalid. |
| 12000004 | operating file failed. |
| 12000005 | IPC communication failed. |
| 12000006 | error occured in crypto engine. |
| 12000007 | this credential is already invalidated permanently. |
| 12000008 | verify authtoken failed. |
| 12000009 | authtoken is already timeout. |
| 12000011 | queried entity does not exist. |
| 12000012 | external error. |
| 12000014 | memory is insufficient. |
## huks.updateSession<sup>9+</sup> ## huks.updateSession<sup>9+</sup>
...@@ -1226,6 +1572,27 @@ updateSession操作密钥接口,使用Callback回调异步返回结果。huks. ...@@ -1226,6 +1572,27 @@ updateSession操作密钥接口,使用Callback回调异步返回结果。huks.
| token | Uint8Array | 是 | updateSession操作的token。 | | token | Uint8Array | 是 | updateSession操作的token。 |
| callback | AsyncCallback<[HuksReturnResult](#huksreturnresult9)> | 是 | 回调函数。将updateSession操作的结果添加到密钥管理系统的回调。 | | callback | AsyncCallback<[HuksReturnResult](#huksreturnresult9)> | 是 | 回调函数。将updateSession操作的结果添加到密钥管理系统的回调。 |
**错误码:**
以下错误码的详细介绍请参见[HUKS错误码](../errorcodes/errorcode-huks.md)
| 错误码ID | 错误信息 |
| -------- | ------------- |
| 401 | argument is invalid. |
| 801 | api is not supported. |
| 12000001 | algorithm mode is not supported. |
| 12000002 | algorithm param is missing. |
| 12000003 | algorithm param is invalid. |
| 12000004 | operating file failed. |
| 12000005 | IPC communication failed. |
| 12000006 | error occured in crypto engine. |
| 12000007 | this credential is already invalidated permanently. |
| 12000008 | verify authtoken failed. |
| 12000009 | authtoken is already timeout. |
| 12000011 | queried entity does not exist. |
| 12000012 | external error. |
| 12000014 | memory is insufficient. |
## huks.updateSession<sup>9+</sup> ## huks.updateSession<sup>9+</sup>
updateSession(handle: number, options: HuksOptions, token?: Uint8Array) : Promise\<HuksReturnResult> updateSession(handle: number, options: HuksOptions, token?: Uint8Array) : Promise\<HuksReturnResult>
...@@ -1248,6 +1615,27 @@ updateSession操作密钥接口,使用Promise方式异步返回结果。huks.i ...@@ -1248,6 +1615,27 @@ updateSession操作密钥接口,使用Promise方式异步返回结果。huks.i
| ----------------------------------- | -------------------------------------------------- | | ----------------------------------- | -------------------------------------------------- |
| Promise<[HuksReturnResult](#huksreturnresult9)> | Promise对象。将updateSession操作的结果添加到密钥管理系统的回调。 | | Promise<[HuksReturnResult](#huksreturnresult9)> | Promise对象。将updateSession操作的结果添加到密钥管理系统的回调。 |
**错误码:**
以下错误码的详细介绍请参见[HUKS错误码](../errorcodes/errorcode-huks.md)
| 错误码ID | 错误信息 |
| -------- | ------------- |
| 401 | argument is invalid. |
| 801 | api is not supported. |
| 12000001 | algorithm mode is not supported. |
| 12000002 | algorithm param is missing. |
| 12000003 | algorithm param is invalid. |
| 12000004 | operating file failed. |
| 12000005 | IPC communication failed. |
| 12000006 | error occured in crypto engine. |
| 12000007 | this credential is already invalidated permanently. |
| 12000008 | verify authtoken failed. |
| 12000009 | authtoken is already timeout. |
| 12000011 | queried entity does not exist. |
| 12000012 | external error. |
| 12000014 | memory is insufficient. |
## huks.finishSession<sup>9+</sup> ## huks.finishSession<sup>9+</sup>
finishSession(handle: number, options: HuksOptions, callback: AsyncCallback\<HuksReturnResult>) : void finishSession(handle: number, options: HuksOptions, callback: AsyncCallback\<HuksReturnResult>) : void
...@@ -1265,6 +1653,27 @@ finishSession操作密钥接口,使用Callback回调异步返回结果。huks. ...@@ -1265,6 +1653,27 @@ finishSession操作密钥接口,使用Callback回调异步返回结果。huks.
| token | Uint8Array | 是 | finishSession操作的token。 | | token | Uint8Array | 是 | finishSession操作的token。 |
| callback | AsyncCallback<[HuksReturnResult](#huksreturnresult9)> | 是 | 回调函数。将finishSession操作的结果添加到密钥管理系统的回调。 | | callback | AsyncCallback<[HuksReturnResult](#huksreturnresult9)> | 是 | 回调函数。将finishSession操作的结果添加到密钥管理系统的回调。 |
**错误码:**
以下错误码的详细介绍请参见[HUKS错误码](../errorcodes/errorcode-huks.md)
| 错误码ID | 错误信息 |
| -------- | ------------- |
| 401 | argument is invalid. |
| 801 | api is not supported. |
| 12000001 | algorithm mode is not supported. |
| 12000002 | algorithm param is missing. |
| 12000003 | algorithm param is invalid. |
| 12000004 | operating file failed. |
| 12000005 | IPC communication failed. |
| 12000006 | error occured in crypto engine. |
| 12000007 | this credential is already invalidated permanently. |
| 12000008 | verify authtoken failed. |
| 12000009 | authtoken is already timeout. |
| 12000011 | queried entity does not exist. |
| 12000012 | external error. |
| 12000014 | memory is insufficient. |
## huks.finishSession<sup>9+</sup> ## huks.finishSession<sup>9+</sup>
finishSession(handle: number, options: HuksOptions, token: Uint8Array, callback: AsyncCallback\<HuksReturnResult>) : void finishSession(handle: number, options: HuksOptions, token: Uint8Array, callback: AsyncCallback\<HuksReturnResult>) : void
...@@ -1282,6 +1691,27 @@ finishSession操作密钥接口,使用Callback回调异步返回结果。huks. ...@@ -1282,6 +1691,27 @@ finishSession操作密钥接口,使用Callback回调异步返回结果。huks.
| token | Uint8Array | 是 | finishSession操作的token。 | | token | Uint8Array | 是 | finishSession操作的token。 |
| callback | AsyncCallback\<[HuksReturnResult](#huksreturnresult9)> | 是 | 回调函数。将finishSession操作的结果添加到密钥管理系统的回调。 | | callback | AsyncCallback\<[HuksReturnResult](#huksreturnresult9)> | 是 | 回调函数。将finishSession操作的结果添加到密钥管理系统的回调。 |
**错误码:**
以下错误码的详细介绍请参见[HUKS错误码](../errorcodes/errorcode-huks.md)
| 错误码ID | 错误信息 |
| -------- | ------------- |
| 401 | argument is invalid. |
| 801 | api is not supported. |
| 12000001 | algorithm mode is not supported. |
| 12000002 | algorithm param is missing. |
| 12000003 | algorithm param is invalid. |
| 12000004 | operating file failed. |
| 12000005 | IPC communication failed. |
| 12000006 | error occured in crypto engine. |
| 12000007 | this credential is already invalidated permanently. |
| 12000008 | verify authtoken failed. |
| 12000009 | authtoken is already timeout. |
| 12000011 | queried entity does not exist. |
| 12000012 | external error. |
| 12000014 | memory is insufficient. |
## huks.finishSession<sup>9+</sup> ## huks.finishSession<sup>9+</sup>
finishSession(handle: number, options: HuksOptions, token?: Uint8Array) : Promise\<HuksReturnResult> finishSession(handle: number, options: HuksOptions, token?: Uint8Array) : Promise\<HuksReturnResult>
...@@ -1304,6 +1734,27 @@ finishSession操作密钥接口,使用Promise方式异步返回结果。huks.i ...@@ -1304,6 +1734,27 @@ finishSession操作密钥接口,使用Promise方式异步返回结果。huks.i
| ----------------------------------- | -------------------------------------------------- | | ----------------------------------- | -------------------------------------------------- |
| Promise\<[HuksReturnResult](#huksreturnresult9)> | Promise对象,用于获取异步返回结果。 | | Promise\<[HuksReturnResult](#huksreturnresult9)> | Promise对象,用于获取异步返回结果。 |
**错误码:**
以下错误码的详细介绍请参见[HUKS错误码](../errorcodes/errorcode-huks.md)
| 错误码ID | 错误信息 |
| -------- | ------------- |
| 401 | argument is invalid. |
| 801 | api is not supported. |
| 12000001 | algorithm mode is not supported. |
| 12000002 | algorithm param is missing. |
| 12000003 | algorithm param is invalid. |
| 12000004 | operating file failed. |
| 12000005 | IPC communication failed. |
| 12000006 | error occured in crypto engine. |
| 12000007 | this credential is already invalidated permanently. |
| 12000008 | verify authtoken failed. |
| 12000009 | authtoken is already timeout. |
| 12000011 | queried entity does not exist. |
| 12000012 | external error. |
| 12000014 | memory is insufficient. |
## huks.abortSession<sup>9+</sup> ## huks.abortSession<sup>9+</sup>
abortSession(handle: number, options: HuksOptions, callback: AsyncCallback\<void>) : void abortSession(handle: number, options: HuksOptions, callback: AsyncCallback\<void>) : void
...@@ -1320,6 +1771,20 @@ abortSession操作密钥接口,使用Callback回调异步返回结果 。 ...@@ -1320,6 +1771,20 @@ abortSession操作密钥接口,使用Callback回调异步返回结果 。
| options | [HuksOptions](#huksoptions) | 是 | abortSession操作的参数集合。 | | options | [HuksOptions](#huksoptions) | 是 | abortSession操作的参数集合。 |
| callback | AsyncCallback\<void> | 是 | 回调函数。将abortSession操作的结果添加到密钥管理系统的回调。 | | callback | AsyncCallback\<void> | 是 | 回调函数。将abortSession操作的结果添加到密钥管理系统的回调。 |
**错误码:**
以下错误码的详细介绍请参见[HUKS错误码](../errorcodes/errorcode-huks.md)
| 错误码ID | 错误信息 |
| -------- | ------------- |
| 401 | argument is invalid. |
| 801 | api is not supported. |
| 12000004 | operating file failed. |
| 12000005 | IPC communication failed. |
| 12000006 | error occured in crypto engine. |
| 12000012 | external error. |
| 12000014 | memory is insufficient. |
**示例:** **示例:**
```js ```js
...@@ -1470,6 +1935,20 @@ abortSession操作密钥接口,使用Promise方式异步返回结果。 ...@@ -1470,6 +1935,20 @@ abortSession操作密钥接口,使用Promise方式异步返回结果。
| ----------------------------------- | -------------------------------------------------- | | ----------------------------------- | -------------------------------------------------- |
| Promise\<void> | Promise对象。将abortSession操作的结果添加到密钥管理系统的回调。 | | Promise\<void> | Promise对象。将abortSession操作的结果添加到密钥管理系统的回调。 |
**错误码:**
以下错误码的详细介绍请参见[HUKS错误码](../errorcodes/errorcode-huks.md)
| 错误码ID | 错误信息 |
| -------- | ------------- |
| 401 | argument is invalid. |
| 801 | api is not supported. |
| 12000004 | operating file failed. |
| 12000005 | IPC communication failed. |
| 12000006 | error occured in crypto engine. |
| 12000012 | external error. |
| 12000014 | memory is insufficient. |
**示例:** **示例:**
```js ```js
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
在连接指定的后台服务时作为入参,用于接收连接过程中的状态变化,如作为[connectServiceExtensionAbility](js-apis-inner-application-uiAbilityContext.md#uiabilitycontextconnectserviceextensionability)的入参,连接指定的ServiceExtensionAbility。 在连接指定的后台服务时作为入参,用于接收连接过程中的状态变化,如作为[connectServiceExtensionAbility](js-apis-inner-application-uiAbilityContext.md#uiabilitycontextconnectserviceextensionability)的入参,连接指定的ServiceExtensionAbility。
> **说明:**
>
> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块 ## 导入模块
```ts ```ts
......
...@@ -2,13 +2,16 @@ ...@@ -2,13 +2,16 @@
提供用于匹配满足指定条件的受监视的AbilityStage对象的方法。最近匹配的AbilityStage对象将保存在AbilityStageMonitor对象中。 提供用于匹配满足指定条件的受监视的AbilityStage对象的方法。最近匹配的AbilityStage对象将保存在AbilityStageMonitor对象中。
> **说明:**
>
> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core **系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| ------------------------------------------------------------ | -------- | ---- | ---- | ------------------------------------------------------------ | | ------------------------------------------------------------ | -------- | ---- | ---- | ------------------------------------------------------------ |
| moduleName<sup>9+</sup> | string | 是 | 是 | 要监视的abilityStage的模块名。 | | moduleName | string | 是 | 是 | 要监视的abilityStage的模块名。 |
| srcEntrance<sup>9+</sup> | string | 是 | 是 | 要监视的abilityStage的源路径。 | | srcEntrance | string | 是 | 是 | 要监视的abilityStage的源路径。 |
**示例:** **示例:**
```ts ```ts
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
定义Ability状态信息,可以通过[registerApplicationStateObserver](js-apis-application-appManager.md#appmanagerregisterapplicationstateobserver8)注册生命周期变化监听后,通过[ApplicationStateObserver](js-apis-inner-application-applicationStateObserver.md)的onAbilityStateChanged生命周期回调获取。 定义Ability状态信息,可以通过[registerApplicationStateObserver](js-apis-application-appManager.md#appmanagerregisterapplicationstateobserver8)注册生命周期变化监听后,通过[ApplicationStateObserver](js-apis-inner-application-applicationStateObserver.md)的onAbilityStateChanged生命周期回调获取。
> **说明:**
>
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块 ## 导入模块
```ts ```ts
...@@ -12,13 +16,13 @@ import appManager from '@ohos.application.appManager'; ...@@ -12,13 +16,13 @@ import appManager from '@ohos.application.appManager';
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| ----------------------- | ---------| ---- | ---- | ------------------------- | | ----------------------- | ---------| ---- | ---- | ------------------------- |
| pid<sup>8+</sup> | number | 是 | 否 | 进程ID。 | | pid | number | 是 | 否 | 进程ID。 |
| bundleName<sup>8+</sup> | string | 是 | 否 | 应用Bundle名称。 | | bundleName | string | 是 | 否 | 应用Bundle名称。 |
| abilityName<sup>8+</sup> | string | 是 | 否 | Ability名称。 | | abilityName | string | 是 | 否 | Ability名称。 |
| uid<sup>8+</sup> | number | 是 | 否 | 用户ID。 | | uid | number | 是 | 否 | 用户ID。 |
| state<sup>8+</sup> | number | 是 | 否 | [Ability状态](#ability状态)。 | | state | number | 是 | 否 | [Ability状态](#ability状态)。 |
| moduleName<sup>9+</sup> | string | 是 | 否 | Ability所属的HAP的名称。 | | moduleName<sup>9+</sup> | string | 是 | 否 | Ability所属的HAP的名称。 |
| abilityType<sup>8+</sup> | number | 是 | 否 | [Ability类型](#ability类型):页面或服务等。 | | abilityType | number | 是 | 否 | [Ability类型](#ability类型):页面或服务等。 |
#### Ability状态 #### Ability状态
......
...@@ -309,7 +309,6 @@ getRunningProcessInformation(): Promise\<Array\<ProcessInformation>>; ...@@ -309,7 +309,6 @@ getRunningProcessInformation(): Promise\<Array\<ProcessInformation>>;
**示例:** **示例:**
```ts ```ts
let applicationContext = this.context.getApplicationContext();
applicationContext.getRunningProcessInformation().then((data) => { applicationContext.getRunningProcessInformation().then((data) => {
console.log('The process running information is: ${JSON.stringify(data)}'); console.log('The process running information is: ${JSON.stringify(data)}');
}).catch((error) => { }).catch((error) => {
...@@ -347,7 +346,6 @@ getRunningProcessInformation(callback: AsyncCallback\<Array\<ProcessInformation> ...@@ -347,7 +346,6 @@ getRunningProcessInformation(callback: AsyncCallback\<Array\<ProcessInformation>
**示例:** **示例:**
```ts ```ts
let applicationContext = this.context.getApplicationContext();
applicationContext.getRunningProcessInformation((err, data) => { applicationContext.getRunningProcessInformation((err, data) => {
if (err) { if (err) {
console.error('getRunningProcessInformation faile, err: ${JSON.stringify(err)}'); console.error('getRunningProcessInformation faile, err: ${JSON.stringify(err)}');
...@@ -382,7 +380,6 @@ killAllProcesses(): Promise\<void\>; ...@@ -382,7 +380,6 @@ killAllProcesses(): Promise\<void\>;
**示例:** **示例:**
```ts ```ts
let applicationContext = this.context.getApplicationContext();
applicationContext.killAllProcesses(); applicationContext.killAllProcesses();
``` ```
...@@ -411,7 +408,6 @@ killAllProcesses(callback: AsyncCallback\<void\>); ...@@ -411,7 +408,6 @@ killAllProcesses(callback: AsyncCallback\<void\>);
**示例:** **示例:**
```ts ```ts
let applicationContext = this.context.getApplicationContext();
applicationContext.killAllProcesses(error => { applicationContext.killAllProcesses(error => {
if (error) { if (error) {
console.error('killAllProcesses fail, error: ${JSON.stringify(error)}'); console.error('killAllProcesses fail, error: ${JSON.stringify(error)}');
......
...@@ -2,10 +2,14 @@ ...@@ -2,10 +2,14 @@
定义应用状态监听,可以作为[registerApplicationStateObserver](js-apis-application-appManager.md#appmanagerregisterapplicationstateobserver8)的入参监听当前应用的生命周期变化。 定义应用状态监听,可以作为[registerApplicationStateObserver](js-apis-application-appManager.md#appmanagerregisterapplicationstateobserver8)的入参监听当前应用的生命周期变化。
> **说明:**
>
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块 ## 导入模块
```ts ```ts
import appManager from '@ohos.application.appManager'; import appManager from '@ohos.app.ability.appManager';
``` ```
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core **系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core
...@@ -14,16 +18,14 @@ import appManager from '@ohos.application.appManager'; ...@@ -14,16 +18,14 @@ import appManager from '@ohos.application.appManager';
| 名称 | | 类型 | 可读 | 可写 | 说明 | | 名称 | | 类型 | 可读 | 可写 | 说明 |
| ----------------------- | ---------| ---- | ---- | ------------------------- | ------------------------- | | ----------------------- | ---------| ---- | ---- | ------------------------- | ------------------------- |
| onForegroundApplicationChanged<sup>8+</sup> | [AppStateData](js-apis-inner-application-appStateData.md) | AsyncCallback\<void> | 是 | 否 | 应用前后台状态发生变化时执行的回调函数。 | | onForegroundApplicationChanged | [AppStateData](js-apis-inner-application-appStateData.md) | AsyncCallback\<void> | 是 | 否 | 应用前后台状态发生变化时执行的回调函数。 |
| onAbilityStateChanged<sup>8+</sup> | [AbilityStateData](js-apis-inner-application-abilityStateData.md) | AsyncCallback\<void> | 是 | 否 | ability状态发生变化时执行的回调函数。 | | onAbilityStateChanged | [AbilityStateData](js-apis-inner-application-abilityStateData.md) | AsyncCallback\<void> | 是 | 否 | ability状态发生变化时执行的回调函数。 |
| onProcessCreated<sup>8+</sup> | [ProcessData](js-apis-inner-application-processData.md) | AsyncCallback\<void> | 是 | 否 | 进程创建时执行的回调函数。 | | onProcessCreated | [ProcessData](js-apis-inner-application-processData.md) | AsyncCallback\<void> | 是 | 否 | 进程创建时执行的回调函数。 |
| onProcessDied<sup>8+</sup> | [ProcessData](js-apis-inner-application-processData.md) | AsyncCallback\<void> | 是 | 否 | 进程销毁时执行的回调函数。 | | onProcessDied | [ProcessData](js-apis-inner-application-processData.md) | AsyncCallback\<void> | 是 | 否 | 进程销毁时执行的回调函数。 |
| onProcessStateChanged<sup>8+</sup> | [ProcessData](js-apis-inner-application-processData.md) | AsyncCallback\<void> | 是 | 否 | 进程状态更新时执行的回调函数。 | | onProcessStateChanged<sup>9+</sup> | [ProcessData](js-apis-inner-application-processData.md) | AsyncCallback\<void> | 是 | 否 | 进程状态更新时执行的回调函数。 |
**示例:** **示例:**
```ts ```ts
import appManager from '@ohos.app.ability.appManager';
let applicationStateObserver = { let applicationStateObserver = {
onForegroundApplicationChanged(appStateData) { onForegroundApplicationChanged(appStateData) {
console.log('onForegroundApplicationChanged appStateData: ${JSON.stringify(appStateData)}'); console.log('onForegroundApplicationChanged appStateData: ${JSON.stringify(appStateData)}');
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
表示跨设备迁移Mission完成后,返回迁移结果的回调函数,迁移Mission详见:[continueMission接口](js-apis-distributedMissionManager.md#distributedmissionmanagercontinuemission) 表示跨设备迁移Mission完成后,返回迁移结果的回调函数,迁移Mission详见:[continueMission接口](js-apis-distributedMissionManager.md#distributedmissionmanagercontinuemission)
> **说明:**
>
> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## ContinueCallback.onContinueDone ## ContinueCallback.onContinueDone
onContinueDone(result: number): void; onContinueDone(result: number): void;
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
表示发起Mission迁移时所需参数的枚举,迁移Mission详见:[continueMission接口](js-apis-distributedMissionManager.md#distributedmissionmanagercontinuemission) 表示发起Mission迁移时所需参数的枚举,迁移Mission详见:[continueMission接口](js-apis-distributedMissionManager.md#distributedmissionmanagercontinuemission)
> **说明:**
>
> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
**系统能力**:SystemCapability.Ability.AbilityRuntime.Mission **系统能力**:SystemCapability.Ability.AbilityRuntime.Mission
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
定义异常监听,可以作为[ErrorManager.on](js-apis-app-ability-errorManager.md#errormanageron)的入参监听当前应用发生的异常。 定义异常监听,可以作为[ErrorManager.on](js-apis-app-ability-errorManager.md#errormanageron)的入参监听当前应用发生的异常。
> **说明:**
>
> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块 ## 导入模块
```ts ```ts
...@@ -40,7 +44,7 @@ try { ...@@ -40,7 +44,7 @@ try {
} }
``` ```
## ErrorObserver.onException ## ErrorObserver.onException<sup>10+</sup>
onException?(errObject: Error): void; onException?(errObject: Error): void;
......
...@@ -23,7 +23,7 @@ import common from '@ohos.app.ability.common'; ...@@ -23,7 +23,7 @@ import common from '@ohos.app.ability.common';
import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility'; import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
import formBindingData from '@ohos.app.form.formBindingData'; import formBindingData from '@ohos.app.form.formBindingData';
export default class MyFormExtensionAbility extends FormExtensionAbility { class MyFormExtensionAbility extends FormExtensionAbility {
onAddForm(want) { onAddForm(want) {
let formContext = this.context; // 获取FormExtensionContext let formContext = this.context; // 获取FormExtensionContext
// ... // ...
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
作为可以[registerMissionListener](js-apis-distributedMissionManager.md#distributedmissionmanagerregistermissionlistener)的入参,表示开始同步后,建立的回调函数。 作为可以[registerMissionListener](js-apis-distributedMissionManager.md#distributedmissionmanagerregistermissionlistener)的入参,表示开始同步后,建立的回调函数。
> **说明:**
>
> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
**系统能力**:SystemCapability.Ability.AbilityRuntime.Mission **系统能力**:SystemCapability.Ability.AbilityRuntime.Mission
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
表示任务的详细信息,可以通过[getMissionInfo](js-apis-app-ability-missionManager.md#missionmanagergetmissioninfo)获取。 表示任务的详细信息,可以通过[getMissionInfo](js-apis-app-ability-missionManager.md#missionmanagergetmissioninfo)获取。
> **说明:**
>
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块 ## 导入模块
```ts ```ts
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
定义系统任务状态监听,可以通过[on](js-apis-app-ability-missionManager.md#missionmanageron)注册。 定义系统任务状态监听,可以通过[on](js-apis-app-ability-missionManager.md#missionmanageron)注册。
> **说明:**
>
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块 ## 导入模块
```ts ```ts
...@@ -16,9 +20,9 @@ import missionManager from '@ohos.app.ability.missionManager'; ...@@ -16,9 +20,9 @@ import missionManager from '@ohos.app.ability.missionManager';
| onMissionDestroyed | function | 否 | 表示当系统销毁任务时回调执行。 | | onMissionDestroyed | function | 否 | 表示当系统销毁任务时回调执行。 |
| onMissionSnapshotChanged | function | 否 | 表示当系统更新任务缩略图时回调执行。 | | onMissionSnapshotChanged | function | 否 | 表示当系统更新任务缩略图时回调执行。 |
| onMissionMovedToFront | function | 否 | 表示当系统将任务移动到前台时回调执行。 | | onMissionMovedToFront | function | 否 | 表示当系统将任务移动到前台时回调执行。 |
| onMissionLabelUpdated | function | 否 | 表示当系统更新任务标签时回调执行。 | | onMissionLabelUpdated<sup>9+</sup> | function | 否 | 表示当系统更新任务标签时回调执行。 |
| onMissionIconUpdated | function | 否 | 表示当系统更新任务图标时回调执行。 | | onMissionIconUpdated<sup>9+</sup> | function | 否 | 表示当系统更新任务图标时回调执行。 |
| onMissionClosed | function | 否 | 表示当系统关闭任务时回调执行。 | | onMissionClosed<sup>9+</sup> | function | 否 | 表示当系统关闭任务时回调执行。 |
**示例:** **示例:**
```ts ```ts
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
作为[startSyncRemoteMissions](js-apis-distributedMissionManager.md#distributedmissionmanagerstartsyncremotemissions)的入参,表示同步时所需参数的枚举。 作为[startSyncRemoteMissions](js-apis-distributedMissionManager.md#distributedmissionmanagerstartsyncremotemissions)的入参,表示同步时所需参数的枚举。
> **说明:**
>
> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
**系统能力**:SystemCapability.Ability.AbilityRuntime.Mission **系统能力**:SystemCapability.Ability.AbilityRuntime.Mission
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
......
...@@ -2,10 +2,14 @@ ...@@ -2,10 +2,14 @@
进程数据的对象定义。使用接口[registerApplicationStateObserver](js-apis-application-appManager.md#appmanagerregisterapplicationstateobserver8)注册生命周期变化监听后,当应用或组件的生命周期变化时,系统通过[ApplicationStateObserver](js-apis-inner-application-applicationStateObserver.md)的onProcessCreated等方法回调给开发者。 进程数据的对象定义。使用接口[registerApplicationStateObserver](js-apis-application-appManager.md#appmanagerregisterapplicationstateobserver8)注册生命周期变化监听后,当应用或组件的生命周期变化时,系统通过[ApplicationStateObserver](js-apis-inner-application-applicationStateObserver.md)的onProcessCreated等方法回调给开发者。
> **说明:**
>
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块 ## 导入模块
```ts ```ts
import appManager from '@ohos.app.ability.appManager'; import appManager from '@ohos.application.appManager';
``` ```
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core **系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core
...@@ -14,16 +18,16 @@ import appManager from '@ohos.app.ability.appManager'; ...@@ -14,16 +18,16 @@ import appManager from '@ohos.app.ability.appManager';
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| ----------------------- | ---------| ---- | ---- | ------------------------- | | ----------------------- | ---------| ---- | ---- | ------------------------- |
| pid<sup>8+</sup> | number | 是 | 否 | 进程ID。 | | pid | number | 是 | 否 | 进程ID。 |
| bundleName<sup>8+</sup> | string | 是 | 否 | 应用包名。 | | bundleName | string | 是 | 否 | 应用包名。 |
| uid<sup>8+</sup> | number | 是 | 否 | 应用的uid。 | | uid | number | 是 | 否 | 应用的uid。 |
| isContinuousTask<sup>9+</sup> | boolean | 是 | 否 | 是否为长时任务,true表示是,false表示不是 | | isContinuousTask<sup>9+</sup> | boolean | 是 | 否 | 是否为长时任务,true表示是,false表示不是 |
| isKeepAlive<sup>9+</sup> | boolean | 是 | 否 | 是否为常驻进程,true表示是,false表示不是 | | isKeepAlive<sup>9+</sup> | boolean | 是 | 否 | 是否为常驻进程,true表示是,false表示不是 |
| state<sup>9+</sup> | number | 是 | 否 | 应用的状态,取值及对应的状态为:0(刚创建),2(前台),4(后台),5(已终止)。 | | state<sup>9+</sup> | number | 是 | 否 | 应用的状态,取值及对应的状态为:0(刚创建),2(前台),4(后台),5(已终止)。 |
**示例:** **示例:**
```ts ```ts
import appManager from '@ohos.app.ability.appManager'; import appManager from '@ohos.application.appManager';
let applicationStateObserver = { let applicationStateObserver = {
onForegroundApplicationChanged(appStateData) { onForegroundApplicationChanged(appStateData) {
......
...@@ -367,7 +367,7 @@ try { ...@@ -367,7 +367,7 @@ try {
// 执行正常业务 // 执行正常业务
console.info('startAbilityForResult succeed'); console.info('startAbilityForResult succeed');
}); });
} catch (paramError) { } catch (err) {
// 处理入参错误异常 // 处理入参错误异常
console.error(`startAbilityForResult failed, code is ${err.code}, message is ${err.message}`); console.error(`startAbilityForResult failed, code is ${err.code}, message is ${err.message}`);
} }
...@@ -785,7 +785,7 @@ try { ...@@ -785,7 +785,7 @@ try {
// 处理业务逻辑错误 // 处理业务逻辑错误
console.error(`startServiceExtensionAbility failed, code is ${err.code}, message is ${err.message}`); console.error(`startServiceExtensionAbility failed, code is ${err.code}, message is ${err.message}`);
}); });
} catch (paramError) { } catch (err) {
// 处理入参错误异常 // 处理入参错误异常
console.error(`startServiceExtensionAbility failed, code is ${err.code}, message is ${err.message}`); console.error(`startServiceExtensionAbility failed, code is ${err.code}, message is ${err.message}`);
} }
...@@ -1397,6 +1397,7 @@ let want = { ...@@ -1397,6 +1397,7 @@ let want = {
bundleName: 'com.example.myapplication', bundleName: 'com.example.myapplication',
abilityName: 'ServiceExtensionAbility' abilityName: 'ServiceExtensionAbility'
}; };
let commRemote;
let options = { let options = {
onConnect(elementName, remote) { onConnect(elementName, remote) {
commRemote = remote; commRemote = remote;
...@@ -1466,6 +1467,7 @@ let want = { ...@@ -1466,6 +1467,7 @@ let want = {
abilityName: 'ServiceExtensionAbility' abilityName: 'ServiceExtensionAbility'
}; };
let accountId = 100; let accountId = 100;
let commRemote;
let options = { let options = {
onConnect(elementName, remote) { onConnect(elementName, remote) {
commRemote = remote; commRemote = remote;
...@@ -1522,6 +1524,7 @@ disconnectServiceExtensionAbility(connection: number): Promise\<void>; ...@@ -1522,6 +1524,7 @@ disconnectServiceExtensionAbility(connection: number): Promise\<void>;
```ts ```ts
// connection为connectServiceExtensionAbility中的返回值 // connection为connectServiceExtensionAbility中的返回值
let connection = 1; let connection = 1;
let commRemote;
try { try {
this.context.disconnectServiceExtensionAbility(connection, (err) => { this.context.disconnectServiceExtensionAbility(connection, (err) => {
...@@ -1570,6 +1573,24 @@ disconnectServiceExtensionAbility(connection: number, callback:AsyncCallback\<vo ...@@ -1570,6 +1573,24 @@ disconnectServiceExtensionAbility(connection: number, callback:AsyncCallback\<vo
```ts ```ts
// connection为connectServiceExtensionAbility中的返回值 // connection为connectServiceExtensionAbility中的返回值
let connection = 1; let connection = 1;
let commRemote;
try {
this.context.disconnectServiceExtensionAbility(connection, (err) => {
commRemote = null;
if (err.code) {
// 处理业务逻辑错误
console.error(`disconnectServiceExtensionAbility failed, code is ${err.code}, message is ${err.message}`);
return;
}
// 执行正常业务
console.info('disconnectServiceExtensionAbility succeed');
});
} catch (err) {
commRemote = null;
// 处理入参错误异常
console.error(`disconnectServiceExtensionAbility failed, code is ${err.code}, message is ${err.message}`);
}
try { try {
this.context.disconnectServiceExtensionAbility(connection, (err) => { this.context.disconnectServiceExtensionAbility(connection, (err) => {
...@@ -1683,11 +1704,11 @@ try { ...@@ -1683,11 +1704,11 @@ try {
// 执行正常业务 // 执行正常业务
caller = obj; caller = obj;
console.info('startAbilityByCall succeed'); console.info('startAbilityByCall succeed');
}).catch((error) => { }).catch((err) => {
// 处理业务逻辑错误 // 处理业务逻辑错误
console.error(`startAbilityByCall failed, code is ${err.code}, message is ${err.message}`); console.error(`startAbilityByCall failed, code is ${err.code}, message is ${err.message}`);
}); });
} catch (paramError) { } catch (err) {
// 处理入参错误异常 // 处理入参错误异常
console.error(`startAbilityByCall failed, code is ${err.code}, message is ${err.message}`); console.error(`startAbilityByCall failed, code is ${err.code}, message is ${err.message}`);
} }
...@@ -2071,6 +2092,8 @@ setMissionIcon(icon: image.PixelMap): Promise\<void>; ...@@ -2071,6 +2092,8 @@ setMissionIcon(icon: image.PixelMap): Promise\<void>;
**示例:** **示例:**
```ts ```ts
import image from '@ohos.multimedia.image';
let imagePixelMap; let imagePixelMap;
let color = new ArrayBuffer(0); let color = new ArrayBuffer(0);
let initializationOptions = { let initializationOptions = {
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
作为[trigger](js-apis-app-ability-wantAgent.md#wantagenttrigger)的入参定义触发WantAgent所需要的信息。 作为[trigger](js-apis-app-ability-wantAgent.md#wantagenttrigger)的入参定义触发WantAgent所需要的信息。
> **说明:**
>
> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块 ## 导入模块
```ts ```ts
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
定义触发WantAgent所需要的信息,可以作为[getWantAgent](js-apis-app-ability-wantAgent.md#wantagentgetwantagent)的入参创建指定的WantAgent对象。 定义触发WantAgent所需要的信息,可以作为[getWantAgent](js-apis-app-ability-wantAgent.md#wantagentgetwantagent)的入参创建指定的WantAgent对象。
> **说明:**
>
> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块 ## 导入模块
```ts ```ts
......
...@@ -112,7 +112,7 @@ struct Index { ...@@ -112,7 +112,7 @@ struct Index {
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| -------------- | -------------------------------------------------------------------------------------------------- | ---- | ----------------------------------------------- | | -------------- | -------------------------------------------------------------------------------------------------- | ---- | ----------------------------------------------- |
| textContent | string | 是 | 设置被计算文本内容。 | | textContent<sup>10+</sup> | string | 是 | 设置被计算文本内容。 |
| constraintWidth<sup>10+</sup> | number&nbsp;\|&nbsp;string&nbsp;\|&nbsp;[Resource](../arkui-ts/ts-types.md#resource) | 否 | 设置被计算文本布局宽度。<br/>**说明:** 默认单位为vp | | constraintWidth<sup>10+</sup> | number&nbsp;\|&nbsp;string&nbsp;\|&nbsp;[Resource](../arkui-ts/ts-types.md#resource) | 否 | 设置被计算文本布局宽度。<br/>**说明:** 默认单位为vp |
| fontSize | number&nbsp;\|&nbsp;string&nbsp;\|&nbsp;[Resource](../arkui-ts/ts-types.md#resource) | 否 | 设置被计算文本字体大小,fontSize为number类型时,使用fp单位。<br/>默认值:16fp。<br/>**说明:** 不支持设置百分比字符串。 | | fontSize | number&nbsp;\|&nbsp;string&nbsp;\|&nbsp;[Resource](../arkui-ts/ts-types.md#resource) | 否 | 设置被计算文本字体大小,fontSize为number类型时,使用fp单位。<br/>默认值:16fp。<br/>**说明:** 不支持设置百分比字符串。 |
| fontStyle | number&nbsp;\|&nbsp;[FontStyle](../arkui-ts/ts-appendix-enums.md#fontstyle) | 否 | 设置被计算文本字体样式。<br>默认值:FontStyle.Normal | | fontStyle | number&nbsp;\|&nbsp;[FontStyle](../arkui-ts/ts-appendix-enums.md#fontstyle) | 否 | 设置被计算文本字体样式。<br>默认值:FontStyle.Normal |
......
...@@ -45,15 +45,15 @@ createAVPlayer(callback: AsyncCallback\<AVPlayer>): void ...@@ -45,15 +45,15 @@ createAVPlayer(callback: AsyncCallback\<AVPlayer>): void
**示例:** **示例:**
```js ```js
let avPlayer let avPlayer;
media.createAVPlayer((error, video) => { media.createAVPlayer((error, video) => {
if (video != null) { if (video != null) {
avPlayer = video; avPlayer = video;
console.info('createAVPlayer success'); console.info('createAVPlayer success');
} else { } else {
console.info(`createAVPlayer fail, error:${error}`); console.error(`createAVPlayer fail, error message:${error.message}`);
} }
}); });
``` ```
...@@ -82,17 +82,17 @@ createAVPlayer(): Promise\<AVPlayer> ...@@ -82,17 +82,17 @@ createAVPlayer(): Promise\<AVPlayer>
**示例:** **示例:**
```js ```js
let avPlayer let avPlayer;
media.createAVPlayer().then((video) => { media.createAVPlayer().then((video) => {
if (video != null) { if (video != null) {
avPlayer = video; avPlayer = video;
console.info('createAVPlayer success'); console.info('createAVPlayer success');
} else { } else {
console.info('createAVPlayer fail'); console.error('createAVPlayer fail');
} }
}).catch((error) => { }).catch((error) => {
console.info(`AVPlayer catchCallback, error:${error}`); console.error(`AVPlayer catchCallback, error message:${error.message}`);
}); });
``` ```
...@@ -122,15 +122,15 @@ createAVRecorder(callback: AsyncCallback\<AVRecorder>): void ...@@ -122,15 +122,15 @@ createAVRecorder(callback: AsyncCallback\<AVRecorder>): void
**示例:** **示例:**
```js ```js
let avRecorder let avRecorder;
media.createAVRecorder((error, recorder) => { media.createAVRecorder((error, recorder) => {
if (recorder != null) { if (recorder != null) {
avRecorder = recorder; avRecorder = recorder;
console.info('createAVRecorder success'); console.info('createAVRecorder success');
} else { } else {
console.info(`createAVRecorder fail, error:${error}`); console.error(`createAVRecorder fail, error message:${error.message}`);
} }
}); });
``` ```
...@@ -160,17 +160,17 @@ createAVRecorder(): Promise\<AVRecorder> ...@@ -160,17 +160,17 @@ createAVRecorder(): Promise\<AVRecorder>
**示例:** **示例:**
```js ```js
let avRecorder let avRecorder;
media.createAVRecorder().then((recorder) => { media.createAVRecorder().then((recorder) => {
if (recorder != null) { if (recorder != null) {
avRecorder = recorder; avRecorder = recorder;
console.info('createAVRecorder success'); console.info('createAVRecorder success');
} else { } else {
console.info('createAVRecorder fail'); console.error('createAVRecorder fail');
} }
}).catch((error) => { }).catch((error) => {
console.info(`createAVRecorder catchCallback, error:${error}`); console.error(`createAVRecorder catchCallback, error message:${error.message}`);
}); });
``` ```
...@@ -202,15 +202,15 @@ createVideoRecorder(callback: AsyncCallback\<VideoRecorder>): void ...@@ -202,15 +202,15 @@ createVideoRecorder(callback: AsyncCallback\<VideoRecorder>): void
**示例:** **示例:**
```js ```js
let videoRecorder let videoRecorder;
media.createVideoRecorder((error, video) => { media.createVideoRecorder((error, video) => {
if (video != null) { if (video != null) {
videoRecorder = video; videoRecorder = video;
console.info('video createVideoRecorder success'); console.info('video createVideoRecorder success');
} else { } else {
console.info(`video createVideoRecorder fail, error:${error}`); console.error(`video createVideoRecorder fail, error message:${error.message}`);
} }
}); });
``` ```
...@@ -242,17 +242,17 @@ createVideoRecorder(): Promise\<VideoRecorder> ...@@ -242,17 +242,17 @@ createVideoRecorder(): Promise\<VideoRecorder>
**示例:** **示例:**
```js ```js
let videoRecorder let videoRecorder;
media.createVideoRecorder().then((video) => { media.createVideoRecorder().then((video) => {
if (video != null) { if (video != null) {
videoRecorder = video; videoRecorder = video;
console.info('video createVideoRecorder success'); console.info('video createVideoRecorder success');
} else { } else {
console.info('video createVideoRecorder fail'); console.error('video createVideoRecorder fail');
} }
}).catch((error) => { }).catch((error) => {
console.info(`video catchCallback, error:${error}`); console.error(`video catchCallback, error message:${error.message}`);
}); });
``` ```
...@@ -395,38 +395,38 @@ on(type: 'stateChange', callback: (state: AVPlayerState, reason: StateChangeReas ...@@ -395,38 +395,38 @@ on(type: 'stateChange', callback: (state: AVPlayerState, reason: StateChangeReas
```js ```js
avPlayer.on('stateChange', async (state, reason) => { avPlayer.on('stateChange', async (state, reason) => {
switch (state) { switch (state) {
case 'idle': case 'idle':
console.info('state idle called') console.info('state idle called')
break; break;
case 'initialized': case 'initialized':
console.info('initialized prepared called') console.info('initialized prepared called')
break; break;
case 'prepared': case 'prepared':
console.info('state prepared called') console.info('state prepared called')
break; break;
case 'playing': case 'playing':
console.info('state playing called') console.info('state playing called')
break; break;
case 'paused': case 'paused':
console.info('state paused called') console.info('state paused called')
break; break;
case 'completed': case 'completed':
console.info('state completed called') console.info('state completed called')
break; break;
case 'stopped': case 'stopped':
console.info('state stopped called') console.info('state stopped called')
break; break;
case 'released': case 'released':
console.info('state released called') console.info('state released called')
break; break;
case 'error': case 'error':
console.info('state error called') console.info('state error called')
break; break;
default: default:
console.info('unkown state :' + state) console.info('unkown state :' + state)
break; break;
} }
}) })
``` ```
...@@ -483,8 +483,8 @@ AVPlayer回调的**错误分类**<a name = error_info></a>可以分为以下几 ...@@ -483,8 +483,8 @@ AVPlayer回调的**错误分类**<a name = error_info></a>可以分为以下几
```js ```js
avPlayer.on('error', (error) => { avPlayer.on('error', (error) => {
console.info('error happened,and error message is :' + error.message) console.error('error happened,and error message is :' + error.message)
console.info('error happened,and error code is :' + error.code) console.error('error happened,and error code is :' + error.code)
}) })
``` ```
...@@ -535,11 +535,11 @@ prepare(callback: AsyncCallback\<void>): void ...@@ -535,11 +535,11 @@ prepare(callback: AsyncCallback\<void>): void
```js ```js
avPlayer.prepare((err) => { avPlayer.prepare((err) => {
if (err == null) { if (err == null) {
console.info('prepare success'); console.info('prepare success');
} else { } else {
console.error('prepare filed,error message is :' + err.message) console.error('prepare filed,error message is :' + err.message)
} }
}) })
``` ```
...@@ -570,9 +570,9 @@ prepare(): Promise\<void> ...@@ -570,9 +570,9 @@ prepare(): Promise\<void>
```js ```js
avPlayer.prepare().then(() => { avPlayer.prepare().then(() => {
console.info('prepare success'); console.info('prepare success');
}, (err) => { }, (err) => {
console.error('prepare filed,error message is :' + err.message) console.error('prepare filed,error message is :' + err.message)
}) })
``` ```
...@@ -602,11 +602,11 @@ play(callback: AsyncCallback\<void>): void ...@@ -602,11 +602,11 @@ play(callback: AsyncCallback\<void>): void
```js ```js
avPlayer.play((err) => { avPlayer.play((err) => {
if (err == null) { if (err == null) {
console.info('play success'); console.info('play success');
} else { } else {
console.error('play filed,error message is :' + err.message) console.error('play filed,error message is :' + err.message)
} }
}) })
``` ```
...@@ -636,9 +636,9 @@ play(): Promise\<void> ...@@ -636,9 +636,9 @@ play(): Promise\<void>
```js ```js
avPlayer.play().then(() => { avPlayer.play().then(() => {
console.info('play success'); console.info('play success');
}, (err) => { }, (err) => {
console.error('play filed,error message is :' + err.message) console.error('play filed,error message is :' + err.message)
}) })
``` ```
...@@ -668,11 +668,11 @@ pause(callback: AsyncCallback\<void>): void ...@@ -668,11 +668,11 @@ pause(callback: AsyncCallback\<void>): void
```js ```js
avPlayer.pause((err) => { avPlayer.pause((err) => {
if (err == null) { if (err == null) {
console.info('pause success'); console.info('pause success');
} else { } else {
console.error('pause filed,error message is :' + err.message) console.error('pause filed,error message is :' + err.message)
} }
}) })
``` ```
...@@ -702,9 +702,9 @@ pause(): Promise\<void> ...@@ -702,9 +702,9 @@ pause(): Promise\<void>
```js ```js
avPlayer.pause().then(() => { avPlayer.pause().then(() => {
console.info('pause success'); console.info('pause success');
}, (err) => { }, (err) => {
console.error('pause filed,error message is :' + err.message) console.error('pause filed,error message is :' + err.message)
}) })
``` ```
...@@ -734,11 +734,11 @@ stop(callback: AsyncCallback\<void>): void ...@@ -734,11 +734,11 @@ stop(callback: AsyncCallback\<void>): void
```js ```js
avPlayer.stop((err) => { avPlayer.stop((err) => {
if (err == null) { if (err == null) {
console.info('stop success'); console.info('stop success');
} else { } else {
console.error('stop filed,error message is :' + err.message) console.error('stop filed,error message is :' + err.message)
} }
}) })
``` ```
...@@ -768,9 +768,9 @@ stop(): Promise\<void> ...@@ -768,9 +768,9 @@ stop(): Promise\<void>
```js ```js
avPlayer.stop().then(() => { avPlayer.stop().then(() => {
console.info('stop success'); console.info('stop success');
}, (err) => { }, (err) => {
console.error('stop filed,error message is :' + err.message) console.error('stop filed,error message is :' + err.message)
}) })
``` ```
...@@ -800,11 +800,11 @@ reset(callback: AsyncCallback\<void>): void ...@@ -800,11 +800,11 @@ reset(callback: AsyncCallback\<void>): void
```js ```js
avPlayer.reset((err) => { avPlayer.reset((err) => {
if (err == null) { if (err == null) {
console.info('reset success'); console.info('reset success');
} else { } else {
console.error('reset filed,error message is :' + err.message) console.error('reset filed,error message is :' + err.message)
} }
}) })
``` ```
...@@ -834,9 +834,9 @@ reset(): Promise\<void> ...@@ -834,9 +834,9 @@ reset(): Promise\<void>
```js ```js
avPlayer.reset().then(() => { avPlayer.reset().then(() => {
console.info('reset success'); console.info('reset success');
}, (err) => { }, (err) => {
console.error('reset filed,error message is :' + err.message) console.error('reset filed,error message is :' + err.message)
}) })
``` ```
...@@ -866,11 +866,11 @@ release(callback: AsyncCallback\<void>): void ...@@ -866,11 +866,11 @@ release(callback: AsyncCallback\<void>): void
```js ```js
avPlayer.release((err) => { avPlayer.release((err) => {
if (err == null) { if (err == null) {
console.info('reset success'); console.info('reset success');
} else { } else {
console.error('release filed,error message is :' + err.message) console.error('release filed,error message is :' + err.message)
} }
}) })
``` ```
...@@ -900,9 +900,9 @@ release(): Promise\<void> ...@@ -900,9 +900,9 @@ release(): Promise\<void>
```js ```js
avPlayer.release().then(() => { avPlayer.release().then(() => {
console.info('release success'); console.info('release success');
}, (err) => { }, (err) => {
console.error('release filed,error message is :' + err.message) console.error('release filed,error message is :' + err.message)
}) })
``` ```
...@@ -931,22 +931,22 @@ getTrackDescription(callback: AsyncCallback\<Array\<MediaDescription>>): void ...@@ -931,22 +931,22 @@ getTrackDescription(callback: AsyncCallback\<Array\<MediaDescription>>): void
**示例:** **示例:**
```js ```js
printfDescription(obj) { function printfDescription(obj) {
for (let item in obj) { for (let item in obj) {
let property = obj[item]; let property = obj[item];
console.info('audio key is ' + item); console.info('audio key is ' + item);
console.info('audio value is ' + property); console.info('audio value is ' + property);
} }
} }
avPlayer.getTrackDescription((error, arrList) => { avPlayer.getTrackDescription((error, arrList) => {
if ((arrList) != null) { if ((arrList) != null) {
for (let i = 0; i < arrList.length; i++) { for (let i = 0; i < arrList.length; i++) {
printfDescription(arrList[i]); printfDescription(arrList[i]);
}
} else {
console.log(`video getTrackDescription fail, error:${error}`);
} }
} else {
console.log(`video getTrackDescription fail, error:${error}`);
}
}); });
``` ```
...@@ -977,24 +977,24 @@ getTrackDescription(): Promise\<Array\<MediaDescription>> ...@@ -977,24 +977,24 @@ getTrackDescription(): Promise\<Array\<MediaDescription>>
```js ```js
let arrayDescription; let arrayDescription;
printfDescription(obj) { function printfDescription(obj) {
for (let item in obj) { for (let item in obj) {
let property = obj[item]; let property = obj[item];
console.info('audio key is ' + item); console.info('audio key is ' + item);
console.info('audio value is ' + property); console.info('audio value is ' + property);
} }
} }
avPlayer.getTrackDescription().then((arrList) => { avPlayer.getTrackDescription().then((arrList) => {
if (arrList != null) { if (arrList != null) {
arrayDescription = arrList; arrayDescription = arrList;
} else { } else {
console.log('video getTrackDescription fail'); console.log('video getTrackDescription fail');
} }
}).catch((error) => { }).catch((error) => {
console.info(`video catchCallback, error:${error}`); console.info(`video catchCallback, error:${error}`);
}); });
for (let i = 0; i < arrayDescription.length; i++) { for (let i = 0; i < arrayDescription.length; i++) {
printfDescription(arrayDescription[i]); printfDescription(arrayDescription[i]);
} }
``` ```
...@@ -1040,7 +1040,7 @@ on(type: 'seekDone', callback: Callback\<number>): void ...@@ -1040,7 +1040,7 @@ on(type: 'seekDone', callback: Callback\<number>): void
```js ```js
avPlayer.on('seekDone', (seekDoneTime:number) => { avPlayer.on('seekDone', (seekDoneTime:number) => {
console.info('seekDone success,and seek time is:' + seekDoneTime) console.info('seekDone success,and seek time is:' + seekDoneTime)
}) })
``` ```
...@@ -1104,7 +1104,7 @@ on(type: 'speedDone', callback: Callback\<number>): void ...@@ -1104,7 +1104,7 @@ on(type: 'speedDone', callback: Callback\<number>): void
```js ```js
avPlayer.on('speedDone', (speed:number) => { avPlayer.on('speedDone', (speed:number) => {
console.info('speedDone success,and speed value is:' + speed) console.info('speedDone success,and speed value is:' + speed)
}) })
``` ```
...@@ -1168,7 +1168,7 @@ on(type: 'bitrateDone', callback: Callback\<number>): void ...@@ -1168,7 +1168,7 @@ on(type: 'bitrateDone', callback: Callback\<number>): void
```js ```js
avPlayer.on('bitrateDone', (bitrate:number) => { avPlayer.on('bitrateDone', (bitrate:number) => {
console.info('bitrateDone success,and bitrate value is:' + bitrate) console.info('bitrateDone success,and bitrate value is:' + bitrate)
}) })
``` ```
...@@ -1211,7 +1211,7 @@ on(type: 'availableBitrates', callback: (bitrates: Array\<number>) => void): voi ...@@ -1211,7 +1211,7 @@ on(type: 'availableBitrates', callback: (bitrates: Array\<number>) => void): voi
```js ```js
avPlayer.on('availableBitrates', (bitrates: Array<number>) => { avPlayer.on('availableBitrates', (bitrates: Array<number>) => {
console.info('availableBitrates success,and availableBitrates length is:' + bitrates.length) console.info('availableBitrates success,and availableBitrates length is:' + bitrates.length)
}) })
``` ```
...@@ -1275,7 +1275,7 @@ on(type: 'volumeChange', callback: Callback\<number>): void ...@@ -1275,7 +1275,7 @@ on(type: 'volumeChange', callback: Callback\<number>): void
```js ```js
avPlayer.on('volumeChange', (vol:number) => { avPlayer.on('volumeChange', (vol:number) => {
console.info('volumeChange success,and new volume is :' + vol) console.info('volumeChange success,and new volume is :' + vol)
}) })
``` ```
...@@ -1318,7 +1318,7 @@ on(type: 'endOfStream', callback: Callback\<void>): void ...@@ -1318,7 +1318,7 @@ on(type: 'endOfStream', callback: Callback\<void>): void
```js ```js
avPlayer.on('endOfStream', () => { avPlayer.on('endOfStream', () => {
console.info('endOfStream success') console.info('endOfStream success')
}) })
``` ```
...@@ -1362,7 +1362,7 @@ on(type: 'timeUpdate', callback: Callback\<number>): void ...@@ -1362,7 +1362,7 @@ on(type: 'timeUpdate', callback: Callback\<number>): void
```js ```js
avPlayer.on('timeUpdate', (time:number) => { avPlayer.on('timeUpdate', (time:number) => {
console.info('timeUpdate success,and new time is :' + time) console.info('timeUpdate success,and new time is :' + time)
}) })
``` ```
...@@ -1406,7 +1406,7 @@ on(type: 'durationUpdate', callback: Callback\<number>): void ...@@ -1406,7 +1406,7 @@ on(type: 'durationUpdate', callback: Callback\<number>): void
```js ```js
avPlayer.on('durationUpdate', (duration) => { avPlayer.on('durationUpdate', (duration) => {
console.info('durationUpdate success,new duration is :' + duration) console.info('durationUpdate success,new duration is :' + duration)
}) })
``` ```
...@@ -1449,7 +1449,7 @@ on(type: 'bufferingUpdate', callback: (infoType: BufferingInfoType, value: numbe ...@@ -1449,7 +1449,7 @@ on(type: 'bufferingUpdate', callback: (infoType: BufferingInfoType, value: numbe
```js ```js
avPlayer.on('bufferingUpdate', (infoType: media.BufferingInfoType, value: number) => { avPlayer.on('bufferingUpdate', (infoType: media.BufferingInfoType, value: number) => {
console.info('bufferingUpdate success,and infoType value is:' + infoType + ', value is :' + value) console.info('bufferingUpdate success,and infoType value is:' + infoType + ', value is :' + value)
}) })
``` ```
...@@ -1492,7 +1492,7 @@ on(type: 'startRenderFrame', callback: Callback\<void>): void ...@@ -1492,7 +1492,7 @@ on(type: 'startRenderFrame', callback: Callback\<void>): void
```js ```js
avPlayer.on('startRenderFrame', () => { avPlayer.on('startRenderFrame', () => {
console.info('startRenderFrame success') console.info('startRenderFrame success')
}) })
``` ```
...@@ -1535,7 +1535,7 @@ on(type: 'videoSizeChange', callback: (width: number, height: number) => void): ...@@ -1535,7 +1535,7 @@ on(type: 'videoSizeChange', callback: (width: number, height: number) => void):
```js ```js
avPlayer.on('videoSizeChange', (width: number, height: number) => { avPlayer.on('videoSizeChange', (width: number, height: number) => {
console.info('videoSizeChange success,and width is:' + width + ', height is :' + height) console.info('videoSizeChange success,and width is:' + width + ', height is :' + height)
}) })
``` ```
...@@ -1580,7 +1580,7 @@ on(type: 'audioInterrupt', callback: (info: audio.InterruptEvent) => void): void ...@@ -1580,7 +1580,7 @@ on(type: 'audioInterrupt', callback: (info: audio.InterruptEvent) => void): void
import audio from '@ohos.multimedia.audio'; import audio from '@ohos.multimedia.audio';
avPlayer.on('audioInterrupt', (info: audio.InterruptEvent) => { avPlayer.on('audioInterrupt', (info: audio.InterruptEvent) => {
console.info('audioInterrupt success,and InterruptEvent info is:' + info) console.info('audioInterrupt success,and InterruptEvent info is:' + info)
}) })
``` ```
...@@ -1693,19 +1693,19 @@ avPlayer.off('audioInterrupt') ...@@ -1693,19 +1693,19 @@ avPlayer.off('audioInterrupt')
```js ```js
import media from '@ohos.multimedia.media' import media from '@ohos.multimedia.media'
function printfItemDescription(obj, key) { function printfItemDescription(obj, key) {
let property = obj[key]; let property = obj[key];
console.info('audio key is ' + key); // 通过key值获取对应的value。key值具体可见[MediaDescriptionKey] console.info('audio key is ' + key); // 通过key值获取对应的value。key值具体可见[MediaDescriptionKey]
console.info('audio value is ' + property); //对应key值得value。其类型可为任意类型,具体key对应value的类型可参考[MediaDescriptionKey] console.info('audio value is ' + property); //对应key值得value。其类型可为任意类型,具体key对应value的类型可参考[MediaDescriptionKey]
} }
let audioPlayer = media.createAudioPlayer(); let audioPlayer = media.createAudioPlayer();
audioPlayer.getTrackDescription((error, arrList) => { audioPlayer.getTrackDescription((error, arrList) => {
if (arrList != null) { if (arrList != null) {
for (let i = 0; i < arrList.length; i++) { for (let i = 0; i < arrList.length; i++) {
printfItemDescription(arrList[i], media.MediaDescriptionKey.MD_KEY_TRACK_TYPE); //打印出每条轨道MD_KEY_TRACK_TYPE的值 printfItemDescription(arrList[i], media.MediaDescriptionKey.MD_KEY_TRACK_TYPE); //打印出每条轨道MD_KEY_TRACK_TYPE的值
}
} else {
console.log(`audio getTrackDescription fail, error:${error}`);
} }
} else {
console.log(`audio getTrackDescription fail, error:${error}`);
}
}); });
``` ```
...@@ -1764,32 +1764,32 @@ prepare(config: AVRecorderConfig, callback: AsyncCallback\<void>): void ...@@ -1764,32 +1764,32 @@ prepare(config: AVRecorderConfig, callback: AsyncCallback\<void>): void
```js ```js
// 配置参数以实际硬件设备支持的范围为准 // 配置参数以实际硬件设备支持的范围为准
let AVRecorderProfile = { let AVRecorderProfile = {
audioBitrate : 48000, audioBitrate : 48000,
audioChannels : 2, audioChannels : 2,
audioCodec : media.CodecMimeType.AUDIO_AAC, audioCodec : media.CodecMimeType.AUDIO_AAC,
audioSampleRate : 48000, audioSampleRate : 48000,
fileFormat : media.ContainerFormatType.CFT_MPEG_4, fileFormat : media.ContainerFormatType.CFT_MPEG_4,
videoBitrate : 2000000, videoBitrate : 2000000,
videoCodec : media.CodecMimeType.VIDEO_AVC, videoCodec : media.CodecMimeType.VIDEO_AVC,
videoFrameWidth : 640, videoFrameWidth : 640,
videoFrameHeight : 480, videoFrameHeight : 480,
videoFrameRate : 30 videoFrameRate : 30
} }
let AVRecorderConfig = { let AVRecorderConfig = {
audioSourceType : media.AudioSourceType.AUDIO_SOURCE_TYPE_MIC, audioSourceType : media.AudioSourceType.AUDIO_SOURCE_TYPE_MIC,
videoSourceType : media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_YUV, videoSourceType : media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_YUV,
profile : AVRecorderProfile, profile : AVRecorderProfile,
url : 'fd://', // 文件需先由调用者创建,赋予读写权限,将文件fd传给此参数,eg.fd://45 url : 'fd://', // 文件需先由调用者创建,赋予读写权限,将文件fd传给此参数,eg.fd://45
rotation : 0, // 合理值0、90、180、270,非合理值prepare接口将报错 rotation : 0, // 合理值0、90、180、270,非合理值prepare接口将报错
location : { latitude : 30, longitude : 130 } location : { latitude : 30, longitude : 130 }
} }
avRecorder.prepare(AVRecorderConfig, (err) => { avRecorder.prepare(AVRecorderConfig, (err) => {
if (err == null) { if (err == null) {
console.info('prepare success'); console.info('prepare success');
} else { } else {
console.info('prepare failed and error is ' + err.message); console.error('prepare failed and error is ' + err.message);
} }
}) })
``` ```
...@@ -1835,30 +1835,30 @@ prepare(config: AVRecorderConfig): Promise\<void> ...@@ -1835,30 +1835,30 @@ prepare(config: AVRecorderConfig): Promise\<void>
```js ```js
// 配置参数以实际硬件设备支持的范围为准 // 配置参数以实际硬件设备支持的范围为准
let AVRecorderProfile = { let AVRecorderProfile = {
audioBitrate : 48000, audioBitrate : 48000,
audioChannels : 2, audioChannels : 2,
audioCodec : media.CodecMimeType.AUDIO_AAC, audioCodec : media.CodecMimeType.AUDIO_AAC,
audioSampleRate : 48000, audioSampleRate : 48000,
fileFormat : media.ContainerFormatType.CFT_MPEG_4, fileFormat : media.ContainerFormatType.CFT_MPEG_4,
videoBitrate : 2000000, videoBitrate : 2000000,
videoCodec : media.CodecMimeType.VIDEO_AVC, videoCodec : media.CodecMimeType.VIDEO_AVC,
videoFrameWidth : 640, videoFrameWidth : 640,
videoFrameHeight : 480, videoFrameHeight : 480,
videoFrameRate : 30 videoFrameRate : 30
} }
let AVRecorderConfig = { let AVRecorderConfig = {
audioSourceType : media.AudioSourceType.AUDIO_SOURCE_TYPE_MIC, audioSourceType : media.AudioSourceType.AUDIO_SOURCE_TYPE_MIC,
videoSourceType : media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_YUV, videoSourceType : media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_YUV,
profile : AVRecorderProfile, profile : AVRecorderProfile,
url : 'fd://', // 文件需先由调用者创建,赋予读写权限,将文件fd传给此参数,eg.fd://45 url : 'fd://', // 文件需先由调用者创建,赋予读写权限,将文件fd传给此参数,eg.fd://45
rotation : 0, // 合理值0、90、180、270,非合理值prepare接口报错 rotation : 0, // 合理值0、90、180、270,非合理值prepare接口报错
location : { latitude : 30, longitude : 130 } location : { latitude : 30, longitude : 130 }
} }
avRecorder.prepare(AVRecorderConfig).then(() => { avRecorder.prepare(AVRecorderConfig).then(() => {
console.info('prepare success'); console.info('prepare success');
}).catch((err) => { }).catch((err) => {
console.info('prepare failed and catch error is ' + err.message); console.error('prepare failed and catch error is ' + err.message);
}); });
``` ```
...@@ -1897,12 +1897,12 @@ getInputSurface(callback: AsyncCallback\<string>): void ...@@ -1897,12 +1897,12 @@ getInputSurface(callback: AsyncCallback\<string>): void
let surfaceID = null; // 该surfaceID用于传递给相机接口创造videoOutput let surfaceID = null; // 该surfaceID用于传递给相机接口创造videoOutput
avRecorder.getInputSurface((err, surfaceId) => { avRecorder.getInputSurface((err, surfaceId) => {
if (err == null) { if (err == null) {
console.info('getInputSurface success'); console.info('getInputSurface success');
surfaceID = surfaceId; surfaceID = surfaceId;
} else { } else {
console.info('getInputSurface failed and error is ' + err.message); console.error('getInputSurface failed and error is ' + err.message);
} }
}); });
``` ```
...@@ -1941,10 +1941,10 @@ getInputSurface(): Promise\<string> ...@@ -1941,10 +1941,10 @@ getInputSurface(): Promise\<string>
let surfaceID = null; // 该surfaceID用于传递给相机接口创造videoOutput let surfaceID = null; // 该surfaceID用于传递给相机接口创造videoOutput
avRecorder.getInputSurface().then((surfaceId) => { avRecorder.getInputSurface().then((surfaceId) => {
console.info('getInputSurface success'); console.info('getInputSurface success');
surfaceID = surfaceId; surfaceID = surfaceId;
}).catch((err) => { }).catch((err) => {
console.info('getInputSurface failed and catch error is ' + err.message); console.error('getInputSurface failed and catch error is ' + err.message);
}); });
``` ```
...@@ -1978,11 +1978,11 @@ start(callback: AsyncCallback\<void>): void ...@@ -1978,11 +1978,11 @@ start(callback: AsyncCallback\<void>): void
```js ```js
avRecorder.start((err) => { avRecorder.start((err) => {
if (err == null) { if (err == null) {
console.info('start AVRecorder success'); console.info('start AVRecorder success');
} else { } else {
console.info('start AVRecorder failed and error is ' + err.message); console.error('start AVRecorder failed and error is ' + err.message);
} }
}); });
``` ```
...@@ -2016,9 +2016,9 @@ start(): Promise\<void> ...@@ -2016,9 +2016,9 @@ start(): Promise\<void>
```js ```js
avRecorder.start().then(() => { avRecorder.start().then(() => {
console.info('start AVRecorder success'); console.info('start AVRecorder success');
}).catch((err) => { }).catch((err) => {
console.info('start AVRecorder failed and catch error is ' + err.message); console.error('start AVRecorder failed and catch error is ' + err.message);
}); });
``` ```
...@@ -2052,11 +2052,11 @@ pause(callback: AsyncCallback\<void>): void ...@@ -2052,11 +2052,11 @@ pause(callback: AsyncCallback\<void>): void
```js ```js
avRecorder.pause((err) => { avRecorder.pause((err) => {
if (err == null) { if (err == null) {
console.info('pause AVRecorder success'); console.info('pause AVRecorder success');
} else { } else {
console.info('pause AVRecorder failed and error is ' + err.message); console.error('pause AVRecorder failed and error is ' + err.message);
} }
}); });
``` ```
...@@ -2090,9 +2090,9 @@ pause(): Promise\<void> ...@@ -2090,9 +2090,9 @@ pause(): Promise\<void>
```js ```js
avRecorder.pause().then(() => { avRecorder.pause().then(() => {
console.info('pause AVRecorder success'); console.info('pause AVRecorder success');
}).catch((err) => { }).catch((err) => {
console.info('pause AVRecorder failed and catch error is ' + err.message); console.error('pause AVRecorder failed and catch error is ' + err.message);
}); });
``` ```
...@@ -2126,11 +2126,11 @@ resume(callback: AsyncCallback\<void>): void ...@@ -2126,11 +2126,11 @@ resume(callback: AsyncCallback\<void>): void
```js ```js
avRecorder.resume((err) => { avRecorder.resume((err) => {
if (err == null) { if (err == null) {
console.info('resume AVRecorder success'); console.info('resume AVRecorder success');
} else { } else {
console.info('resume AVRecorder failed and error is ' + err.message); console.error('resume AVRecorder failed and error is ' + err.message);
} }
}); });
``` ```
...@@ -2164,9 +2164,9 @@ resume(): Promise\<void> ...@@ -2164,9 +2164,9 @@ resume(): Promise\<void>
```js ```js
avRecorder.resume().then(() => { avRecorder.resume().then(() => {
console.info('resume AVRecorder success'); console.info('resume AVRecorder success');
}).catch((err) => { }).catch((err) => {
console.info('resume AVRecorder failed and catch error is ' + err.message); console.error('resume AVRecorder failed and catch error is ' + err.message);
}); });
``` ```
...@@ -2202,11 +2202,11 @@ stop(callback: AsyncCallback\<void>): void ...@@ -2202,11 +2202,11 @@ stop(callback: AsyncCallback\<void>): void
```js ```js
avRecorder.stop((err) => { avRecorder.stop((err) => {
if (err == null) { if (err == null) {
console.info('stop AVRecorder success'); console.info('stop AVRecorder success');
} else { } else {
console.info('stop AVRecorder failed and error is ' + err.message); console.error('stop AVRecorder failed and error is ' + err.message);
} }
}); });
``` ```
...@@ -2242,9 +2242,9 @@ stop(): Promise\<void> ...@@ -2242,9 +2242,9 @@ stop(): Promise\<void>
```js ```js
avRecorder.stop().then(() => { avRecorder.stop().then(() => {
console.info('stop AVRecorder success'); console.info('stop AVRecorder success');
}).catch((err) => { }).catch((err) => {
console.info('stop AVRecorder failed and catch error is ' + err.message); console.error('stop AVRecorder failed and catch error is ' + err.message);
}); });
``` ```
...@@ -2277,11 +2277,11 @@ reset(callback: AsyncCallback\<void>): void ...@@ -2277,11 +2277,11 @@ reset(callback: AsyncCallback\<void>): void
```js ```js
avRecorder.reset((err) => { avRecorder.reset((err) => {
if (err == null) { if (err == null) {
console.info('reset AVRecorder success'); console.info('reset AVRecorder success');
} else { } else {
console.info('reset AVRecorder failed and error is ' + err.message); console.error('reset AVRecorder failed and error is ' + err.message);
} }
}); });
``` ```
...@@ -2314,9 +2314,9 @@ reset(): Promise\<void> ...@@ -2314,9 +2314,9 @@ reset(): Promise\<void>
```js ```js
avRecorder.reset().then(() => { avRecorder.reset().then(() => {
console.info('reset AVRecorder success'); console.info('reset AVRecorder success');
}).catch((err) => { }).catch((err) => {
console.info('reset AVRecorder failed and catch error is ' + err.message); console.error('reset AVRecorder failed and catch error is ' + err.message);
}); });
``` ```
...@@ -2348,11 +2348,11 @@ release(callback: AsyncCallback\<void>): void ...@@ -2348,11 +2348,11 @@ release(callback: AsyncCallback\<void>): void
```js ```js
avRecorder.release((err) => { avRecorder.release((err) => {
if (err == null) { if (err == null) {
console.info('release AVRecorder success'); console.info('release AVRecorder success');
} else { } else {
console.info('release AVRecorder failed and error is ' + err.message); console.error('release AVRecorder failed and error is ' + err.message);
} }
}); });
``` ```
...@@ -2384,9 +2384,9 @@ release(): Promise\<void> ...@@ -2384,9 +2384,9 @@ release(): Promise\<void>
```js ```js
avRecorder.release().then(() => { avRecorder.release().then(() => {
console.info('release AVRecorder success'); console.info('release AVRecorder success');
}).catch((err) => { }).catch((err) => {
console.info('release AVRecorder failed and catch error is ' + err.message); console.error('release AVRecorder failed and catch error is ' + err.message);
}); });
``` ```
...@@ -2409,7 +2409,7 @@ on(type: 'stateChange', callback: (state: AVRecorderState, reason: StateChangeRe ...@@ -2409,7 +2409,7 @@ on(type: 'stateChange', callback: (state: AVRecorderState, reason: StateChangeRe
```js ```js
avRecorder.on('stateChange', async (state, reason) => { avRecorder.on('stateChange', async (state, reason) => {
console.info('case state has changed, new state is :' + state + ',and new reason is : ' + reason); console.info('case state has changed, new state is :' + state + ',and new reason is : ' + reason);
}); });
``` ```
...@@ -2463,7 +2463,7 @@ on(type: 'error', callback: ErrorCallback): void ...@@ -2463,7 +2463,7 @@ on(type: 'error', callback: ErrorCallback): void
```js ```js
avRecorder.on('error', (err) => { avRecorder.on('error', (err) => {
console.info('case avRecorder.on(error) called, errMessage is ' + err.message); console.error('case avRecorder.on(error) called, errMessage is ' + err.message);
}); });
``` ```
...@@ -2644,34 +2644,34 @@ prepare(config: VideoRecorderConfig, callback: AsyncCallback\<void>): void; ...@@ -2644,34 +2644,34 @@ prepare(config: VideoRecorderConfig, callback: AsyncCallback\<void>): void;
```js ```js
// 配置参数以实际硬件设备支持的范围为准 // 配置参数以实际硬件设备支持的范围为准
let videoProfile = { let videoProfile = {
audioBitrate : 48000, audioBitrate : 48000,
audioChannels : 2, audioChannels : 2,
audioCodec : 'audio/mp4a-latm', audioCodec : 'audio/mp4a-latm',
audioSampleRate : 48000, audioSampleRate : 48000,
fileFormat : 'mp4', fileFormat : 'mp4',
videoBitrate : 2000000, videoBitrate : 2000000,
videoCodec : 'video/avc', videoCodec : 'video/avc',
videoFrameWidth : 640, videoFrameWidth : 640,
videoFrameHeight : 480, videoFrameHeight : 480,
videoFrameRate : 30 videoFrameRate : 30
} }
let videoConfig = { let videoConfig = {
audioSourceType : 1, audioSourceType : 1,
videoSourceType : 0, videoSourceType : 0,
profile : videoProfile, profile : videoProfile,
url : 'fd://xx', // 文件需先由调用者创建,并给予适当的权限 url : 'fd://xx', // 文件需先由调用者创建,并给予适当的权限
orientationHint : 0, orientationHint : 0,
location : { latitude : 30, longitude : 130 }, location : { latitude : 30, longitude : 130 },
} }
// asyncallback // asyncallback
videoRecorder.prepare(videoConfig, (err) => { videoRecorder.prepare(videoConfig, (err) => {
if (err == null) { if (err == null) {
console.info('prepare success'); console.info('prepare success');
} else { } else {
console.info('prepare failed and error is ' + err.message); console.error('prepare failed and error is ' + err.message);
} }
}) })
``` ```
...@@ -2715,32 +2715,32 @@ prepare(config: VideoRecorderConfig): Promise\<void>; ...@@ -2715,32 +2715,32 @@ prepare(config: VideoRecorderConfig): Promise\<void>;
```js ```js
// 配置参数以实际硬件设备支持的范围为准 // 配置参数以实际硬件设备支持的范围为准
let videoProfile = { let videoProfile = {
audioBitrate : 48000, audioBitrate : 48000,
audioChannels : 2, audioChannels : 2,
audioCodec : 'audio/mp4a-latm', audioCodec : 'audio/mp4a-latm',
audioSampleRate : 48000, audioSampleRate : 48000,
fileFormat : 'mp4', fileFormat : 'mp4',
videoBitrate : 2000000, videoBitrate : 2000000,
videoCodec : 'video/avc', videoCodec : 'video/avc',
videoFrameWidth : 640, videoFrameWidth : 640,
videoFrameHeight : 480, videoFrameHeight : 480,
videoFrameRate : 30 videoFrameRate : 30
} }
let videoConfig = { let videoConfig = {
audioSourceType : 1, audioSourceType : 1,
videoSourceType : 0, videoSourceType : 0,
profile : videoProfile, profile : videoProfile,
url : 'fd://xx', // 文件需先由调用者创建,并给予适当的权限 url : 'fd://xx', // 文件需先由调用者创建,并给予适当的权限
orientationHint : 0, orientationHint : 0,
location : { latitude : 30, longitude : 130 }, location : { latitude : 30, longitude : 130 },
} }
// promise // promise
videoRecorder.prepare(videoConfig).then(() => { videoRecorder.prepare(videoConfig).then(() => {
console.info('prepare success'); console.info('prepare success');
}).catch((err) => { }).catch((err) => {
console.info('prepare failed and catch error is ' + err.message); console.error('prepare failed and catch error is ' + err.message);
}); });
``` ```
...@@ -2780,12 +2780,12 @@ getInputSurface(callback: AsyncCallback\<string>): void; ...@@ -2780,12 +2780,12 @@ getInputSurface(callback: AsyncCallback\<string>): void;
// asyncallback // asyncallback
let surfaceID = null; // 传递给外界的surfaceID let surfaceID = null; // 传递给外界的surfaceID
videoRecorder.getInputSurface((err, surfaceId) => { videoRecorder.getInputSurface((err, surfaceId) => {
if (err == null) { if (err == null) {
console.info('getInputSurface success'); console.info('getInputSurface success');
surfaceID = surfaceId; surfaceID = surfaceId;
} else { } else {
console.info('getInputSurface failed and error is ' + err.message); console.error('getInputSurface failed and error is ' + err.message);
} }
}); });
``` ```
...@@ -2825,10 +2825,10 @@ getInputSurface(): Promise\<string>; ...@@ -2825,10 +2825,10 @@ getInputSurface(): Promise\<string>;
// promise // promise
let surfaceID = null; // 传递给外界的surfaceID let surfaceID = null; // 传递给外界的surfaceID
videoRecorder.getInputSurface().then((surfaceId) => { videoRecorder.getInputSurface().then((surfaceId) => {
console.info('getInputSurface success'); console.info('getInputSurface success');
surfaceID = surfaceId; surfaceID = surfaceId;
}).catch((err) => { }).catch((err) => {
console.info('getInputSurface failed and catch error is ' + err.message); console.error('getInputSurface failed and catch error is ' + err.message);
}); });
``` ```
...@@ -2865,11 +2865,11 @@ start(callback: AsyncCallback\<void>): void; ...@@ -2865,11 +2865,11 @@ start(callback: AsyncCallback\<void>): void;
```js ```js
// asyncallback // asyncallback
videoRecorder.start((err) => { videoRecorder.start((err) => {
if (err == null) { if (err == null) {
console.info('start videorecorder success'); console.info('start videorecorder success');
} else { } else {
console.info('start videorecorder failed and error is ' + err.message); console.error('start videorecorder failed and error is ' + err.message);
} }
}); });
``` ```
...@@ -2906,9 +2906,9 @@ start(): Promise\<void>; ...@@ -2906,9 +2906,9 @@ start(): Promise\<void>;
```js ```js
// promise // promise
videoRecorder.start().then(() => { videoRecorder.start().then(() => {
console.info('start videorecorder success'); console.info('start videorecorder success');
}).catch((err) => { }).catch((err) => {
console.info('start videorecorder failed and catch error is ' + err.message); console.error('start videorecorder failed and catch error is ' + err.message);
}); });
``` ```
...@@ -2945,11 +2945,11 @@ pause(callback: AsyncCallback\<void>): void; ...@@ -2945,11 +2945,11 @@ pause(callback: AsyncCallback\<void>): void;
```js ```js
// asyncallback // asyncallback
videoRecorder.pause((err) => { videoRecorder.pause((err) => {
if (err == null) { if (err == null) {
console.info('pause videorecorder success'); console.info('pause videorecorder success');
} else { } else {
console.info('pause videorecorder failed and error is ' + err.message); console.error('pause videorecorder failed and error is ' + err.message);
} }
}); });
``` ```
...@@ -2986,9 +2986,9 @@ pause(): Promise\<void>; ...@@ -2986,9 +2986,9 @@ pause(): Promise\<void>;
```js ```js
// promise // promise
videoRecorder.pause().then(() => { videoRecorder.pause().then(() => {
console.info('pause videorecorder success'); console.info('pause videorecorder success');
}).catch((err) => { }).catch((err) => {
console.info('pause videorecorder failed and catch error is ' + err.message); console.error('pause videorecorder failed and catch error is ' + err.message);
}); });
``` ```
...@@ -3023,11 +3023,11 @@ resume(callback: AsyncCallback\<void>): void; ...@@ -3023,11 +3023,11 @@ resume(callback: AsyncCallback\<void>): void;
```js ```js
// asyncallback // asyncallback
videoRecorder.resume((err) => { videoRecorder.resume((err) => {
if (err == null) { if (err == null) {
console.info('resume videorecorder success'); console.info('resume videorecorder success');
} else { } else {
console.info('resume videorecorder failed and error is ' + err.message); console.error('resume videorecorder failed and error is ' + err.message);
} }
}); });
``` ```
...@@ -3062,9 +3062,9 @@ resume(): Promise\<void>; ...@@ -3062,9 +3062,9 @@ resume(): Promise\<void>;
```js ```js
// promise // promise
videoRecorder.resume().then(() => { videoRecorder.resume().then(() => {
console.info('resume videorecorder success'); console.info('resume videorecorder success');
}).catch((err) => { }).catch((err) => {
console.info('resume videorecorder failed and catch error is ' + err.message); console.error('resume videorecorder failed and catch error is ' + err.message);
}); });
``` ```
...@@ -3101,11 +3101,11 @@ stop(callback: AsyncCallback\<void>): void; ...@@ -3101,11 +3101,11 @@ stop(callback: AsyncCallback\<void>): void;
```js ```js
// asyncallback // asyncallback
videoRecorder.stop((err) => { videoRecorder.stop((err) => {
if (err == null) { if (err == null) {
console.info('stop videorecorder success'); console.info('stop videorecorder success');
} else { } else {
console.info('stop videorecorder failed and error is ' + err.message); console.error('stop videorecorder failed and error is ' + err.message);
} }
}); });
``` ```
...@@ -3142,9 +3142,9 @@ stop(): Promise\<void>; ...@@ -3142,9 +3142,9 @@ stop(): Promise\<void>;
```js ```js
// promise // promise
videoRecorder.stop().then(() => { videoRecorder.stop().then(() => {
console.info('stop videorecorder success'); console.info('stop videorecorder success');
}).catch((err) => { }).catch((err) => {
console.info('stop videorecorder failed and catch error is ' + err.message); console.error('stop videorecorder failed and catch error is ' + err.message);
}); });
``` ```
...@@ -3177,11 +3177,11 @@ release(callback: AsyncCallback\<void>): void; ...@@ -3177,11 +3177,11 @@ release(callback: AsyncCallback\<void>): void;
```js ```js
// asyncallback // asyncallback
videoRecorder.release((err) => { videoRecorder.release((err) => {
if (err == null) { if (err == null) {
console.info('release videorecorder success'); console.info('release videorecorder success');
} else { } else {
console.info('release videorecorder failed and error is ' + err.message); console.error('release videorecorder failed and error is ' + err.message);
} }
}); });
``` ```
...@@ -3214,9 +3214,9 @@ release(): Promise\<void>; ...@@ -3214,9 +3214,9 @@ release(): Promise\<void>;
```js ```js
// promise // promise
videoRecorder.release().then(() => { videoRecorder.release().then(() => {
console.info('release videorecorder success'); console.info('release videorecorder success');
}).catch((err) => { }).catch((err) => {
console.info('release videorecorder failed and catch error is ' + err.message); console.error('release videorecorder failed and catch error is ' + err.message);
}); });
``` ```
...@@ -3252,11 +3252,11 @@ reset(callback: AsyncCallback\<void>): void; ...@@ -3252,11 +3252,11 @@ reset(callback: AsyncCallback\<void>): void;
```js ```js
// asyncallback // asyncallback
videoRecorder.reset((err) => { videoRecorder.reset((err) => {
if (err == null) { if (err == null) {
console.info('reset videorecorder success'); console.info('reset videorecorder success');
} else { } else {
console.info('reset videorecorder failed and error is ' + err.message); console.error('reset videorecorder failed and error is ' + err.message);
} }
}); });
``` ```
...@@ -3292,9 +3292,9 @@ reset(): Promise\<void>; ...@@ -3292,9 +3292,9 @@ reset(): Promise\<void>;
```js ```js
// promise // promise
videoRecorder.reset().then(() => { videoRecorder.reset().then(() => {
console.info('reset videorecorder success'); console.info('reset videorecorder success');
}).catch((err) => { }).catch((err) => {
console.info('reset videorecorder failed and catch error is ' + err.message); console.error('reset videorecorder failed and catch error is ' + err.message);
}); });
``` ```
...@@ -3327,7 +3327,7 @@ on(type: 'error', callback: ErrorCallback): void ...@@ -3327,7 +3327,7 @@ on(type: 'error', callback: ErrorCallback): void
```js ```js
// 当获取videoRecordState接口出错时通过此订阅事件上报 // 当获取videoRecordState接口出错时通过此订阅事件上报
videoRecorder.on('error', (error) => { // 设置'error'事件回调 videoRecorder.on('error', (error) => { // 设置'error'事件回调
console.info(`audio error called, error: ${error}`); console.error(`audio error called, error: ${error}`);
}) })
``` ```
...@@ -3429,15 +3429,15 @@ createVideoPlayer(callback: AsyncCallback\<VideoPlayer>): void ...@@ -3429,15 +3429,15 @@ createVideoPlayer(callback: AsyncCallback\<VideoPlayer>): void
**示例:** **示例:**
```js ```js
let videoPlayer let videoPlayer;
media.createVideoPlayer((error, video) => { media.createVideoPlayer((error, video) => {
if (video != null) { if (video != null) {
videoPlayer = video; videoPlayer = video;
console.info('video createVideoPlayer success'); console.info('video createVideoPlayer success');
} else { } else {
console.info(`video createVideoPlayer fail, error:${error}`); console.error(`video createVideoPlayer fail, error:${error}`);
} }
}); });
``` ```
...@@ -3461,17 +3461,17 @@ createVideoPlayer(): Promise\<VideoPlayer> ...@@ -3461,17 +3461,17 @@ createVideoPlayer(): Promise\<VideoPlayer>
**示例:** **示例:**
```js ```js
let videoPlayer let videoPlayer;
media.createVideoPlayer().then((video) => { media.createVideoPlayer().then((video) => {
if (video != null) { if (video != null) {
videoPlayer = video; videoPlayer = video;
console.info('video createVideoPlayer success'); console.info('video createVideoPlayer success');
} else { } else {
console.info('video createVideoPlayer fail'); console.error('video createVideoPlayer fail');
} }
}).catch((error) => { }).catch((error) => {
console.info(`video catchCallback, error:${error}`); console.error(`video catchCallback, error:${error}`);
}); });
``` ```
...@@ -3554,7 +3554,7 @@ play(): void ...@@ -3554,7 +3554,7 @@ play(): void
```js ```js
audioPlayer.on('play', () => { //设置'play'事件回调 audioPlayer.on('play', () => { //设置'play'事件回调
console.log('audio play success'); console.log('audio play success');
}); });
audioPlayer.play(); audioPlayer.play();
``` ```
...@@ -3571,7 +3571,7 @@ pause(): void ...@@ -3571,7 +3571,7 @@ pause(): void
```js ```js
audioPlayer.on('pause', () => { //设置'pause'事件回调 audioPlayer.on('pause', () => { //设置'pause'事件回调
console.log('audio pause success'); console.log('audio pause success');
}); });
audioPlayer.pause(); audioPlayer.pause();
``` ```
...@@ -3588,7 +3588,7 @@ stop(): void ...@@ -3588,7 +3588,7 @@ stop(): void
```js ```js
audioPlayer.on('stop', () => { //设置'stop'事件回调 audioPlayer.on('stop', () => { //设置'stop'事件回调
console.log('audio stop success'); console.log('audio stop success');
}); });
audioPlayer.stop(); audioPlayer.stop();
``` ```
...@@ -3605,7 +3605,7 @@ reset(): void ...@@ -3605,7 +3605,7 @@ reset(): void
```js ```js
audioPlayer.on('reset', () => { //设置'reset'事件回调 audioPlayer.on('reset', () => { //设置'reset'事件回调
console.log('audio reset success'); console.log('audio reset success');
}); });
audioPlayer.reset(); audioPlayer.reset();
``` ```
...@@ -3628,11 +3628,11 @@ seek(timeMs: number): void ...@@ -3628,11 +3628,11 @@ seek(timeMs: number): void
```js ```js
audioPlayer.on('timeUpdate', (seekDoneTime) => { //设置'timeUpdate'事件回调 audioPlayer.on('timeUpdate', (seekDoneTime) => { //设置'timeUpdate'事件回调
if (seekDoneTime == null) { if (seekDoneTime == null) {
console.info('audio seek fail'); console.info('audio seek fail');
return; return;
} }
console.log('audio seek success. seekDoneTime: ' + seekDoneTime); console.log('audio seek success. seekDoneTime: ' + seekDoneTime);
}); });
audioPlayer.seek(30000); //seek到30000ms的位置 audioPlayer.seek(30000); //seek到30000ms的位置
``` ```
...@@ -3655,7 +3655,7 @@ setVolume(vol: number): void ...@@ -3655,7 +3655,7 @@ setVolume(vol: number): void
```js ```js
audioPlayer.on('volumeChange', () => { //设置'volumeChange'事件回调 audioPlayer.on('volumeChange', () => { //设置'volumeChange'事件回调
console.log('audio volumeChange success'); console.log('audio volumeChange success');
}); });
audioPlayer.setVolume(1); //设置音量到100% audioPlayer.setVolume(1); //设置音量到100%
``` ```
...@@ -3693,21 +3693,21 @@ getTrackDescription(callback: AsyncCallback\<Array\<MediaDescription>>): void ...@@ -3693,21 +3693,21 @@ getTrackDescription(callback: AsyncCallback\<Array\<MediaDescription>>): void
```js ```js
function printfDescription(obj) { function printfDescription(obj) {
for (let item in obj) { for (let item in obj) {
let property = obj[item]; let property = obj[item];
console.info('audio key is ' + item); console.info('audio key is ' + item);
console.info('audio value is ' + property); console.info('audio value is ' + property);
} }
} }
audioPlayer.getTrackDescription((error, arrList) => { audioPlayer.getTrackDescription((error, arrList) => {
if (arrList != null) { if (arrList != null) {
for (let i = 0; i < arrList.length; i++) { for (let i = 0; i < arrList.length; i++) {
printfDescription(arrList[i]); printfDescription(arrList[i]);
}
} else {
console.log(`audio getTrackDescription fail, error:${error}`);
} }
} else {
console.log(`audio getTrackDescription fail, error:${error}`);
}
}); });
``` ```
...@@ -3729,25 +3729,25 @@ getTrackDescription(): Promise\<Array\<MediaDescription>> ...@@ -3729,25 +3729,25 @@ getTrackDescription(): Promise\<Array\<MediaDescription>>
```js ```js
function printfDescription(obj) { function printfDescription(obj) {
for (let item in obj) { for (let item in obj) {
let property = obj[item]; let property = obj[item];
console.info('audio key is ' + item); console.info('audio key is ' + item);
console.info('audio value is ' + property); console.info('audio value is ' + property);
} }
} }
let arrayDescription = null let arrayDescription = null
audioPlayer.getTrackDescription().then((arrList) => { audioPlayer.getTrackDescription().then((arrList) => {
if (arrList != null) { if (arrList != null) {
arrayDescription = arrList; arrayDescription = arrList;
} else { } else {
console.log('audio getTrackDescription fail'); console.log('audio getTrackDescription fail');
} }
}).catch((error) => { }).catch((error) => {
console.info(`audio catchCallback, error:${error}`); console.info(`audio catchCallback, error:${error}`);
}); });
for (let i = 0; i < arrayDescription.length; i++) { for (let i = 0; i < arrayDescription.length; i++) {
printfDescription(arrayDescription[i]); printfDescription(arrayDescription[i]);
} }
``` ```
...@@ -3770,8 +3770,8 @@ on(type: 'bufferingUpdate', callback: (infoType: BufferingInfoType, value: numbe ...@@ -3770,8 +3770,8 @@ on(type: 'bufferingUpdate', callback: (infoType: BufferingInfoType, value: numbe
```js ```js
audioPlayer.on('bufferingUpdate', (infoType, value) => { audioPlayer.on('bufferingUpdate', (infoType, value) => {
console.log('audio bufferingInfo type: ' + infoType); console.log('audio bufferingInfo type: ' + infoType);
console.log('audio bufferingInfo value: ' + value); console.log('audio bufferingInfo value: ' + value);
}); });
``` ```
...@@ -3797,40 +3797,40 @@ import fs from '@ohos.file.fs'; ...@@ -3797,40 +3797,40 @@ import fs from '@ohos.file.fs';
let audioPlayer = media.createAudioPlayer(); //创建一个音频播放实例 let audioPlayer = media.createAudioPlayer(); //创建一个音频播放实例
audioPlayer.on('dataLoad', () => { //设置'dataLoad'事件回调,src属性设置成功后,触发此回调 audioPlayer.on('dataLoad', () => { //设置'dataLoad'事件回调,src属性设置成功后,触发此回调
console.info('audio set source success'); console.info('audio set source success');
audioPlayer.play(); //开始播放,并触发'play'事件回调 audioPlayer.play(); //开始播放,并触发'play'事件回调
}); });
audioPlayer.on('play', () => { //设置'play'事件回调 audioPlayer.on('play', () => { //设置'play'事件回调
console.info('audio play success'); console.info('audio play success');
audioPlayer.seek(30000); //调用seek方法,并触发'timeUpdate'事件回调 audioPlayer.seek(30000); //调用seek方法,并触发'timeUpdate'事件回调
}); });
audioPlayer.on('pause', () => { //设置'pause'事件回调 audioPlayer.on('pause', () => { //设置'pause'事件回调
console.info('audio pause success'); console.info('audio pause success');
audioPlayer.stop(); //停止播放,并触发'stop'事件回调 audioPlayer.stop(); //停止播放,并触发'stop'事件回调
}); });
audioPlayer.on('reset', () => { //设置'reset'事件回调 audioPlayer.on('reset', () => { //设置'reset'事件回调
console.info('audio reset success'); console.info('audio reset success');
audioPlayer.release(); //释放播放实例资源 audioPlayer.release(); //释放播放实例资源
audioPlayer = undefined; audioPlayer = undefined;
}); });
audioPlayer.on('timeUpdate', (seekDoneTime) => { //设置'timeUpdate'事件回调 audioPlayer.on('timeUpdate', (seekDoneTime) => { //设置'timeUpdate'事件回调
if (seekDoneTime == null) { if (seekDoneTime == null) {
console.info('audio seek fail'); console.info('audio seek fail');
return; return;
} }
console.info('audio seek success, and seek time is ' + seekDoneTime); console.info('audio seek success, and seek time is ' + seekDoneTime);
audioPlayer.setVolume(0.5); //设置音量为50%,并触发'volumeChange'事件回调 audioPlayer.setVolume(0.5); //设置音量为50%,并触发'volumeChange'事件回调
}); });
audioPlayer.on('volumeChange', () => { //设置'volumeChange'事件回调 audioPlayer.on('volumeChange', () => { //设置'volumeChange'事件回调
console.info('audio volumeChange success'); console.info('audio volumeChange success');
audioPlayer.pause(); //暂停播放,并触发'pause'事件回调 audioPlayer.pause(); //暂停播放,并触发'pause'事件回调
}); });
audioPlayer.on('finish', () => { //设置'finish'事件回调 audioPlayer.on('finish', () => { //设置'finish'事件回调
console.info('audio play finish'); console.info('audio play finish');
audioPlayer.stop(); //停止播放,并触发'stop'事件回调 audioPlayer.stop(); //停止播放,并触发'stop'事件回调
}); });
audioPlayer.on('error', (error) => { //设置'error'事件回调 audioPlayer.on('error', (error) => { //设置'error'事件回调
console.info(`audio error called, error: ${error}`); console.error(`audio error called, error: ${error}`);
}); });
// 用户选择音频设置fd(本地播放) // 用户选择音频设置fd(本地播放)
...@@ -3838,13 +3838,13 @@ let fdPath = 'fd://'; ...@@ -3838,13 +3838,13 @@ let fdPath = 'fd://';
// path路径的码流可通过"hdc file send D:\xxx\01.mp3 /data/accounts/account_0/appdata" 命令,将其推送到设备上 // path路径的码流可通过"hdc file send D:\xxx\01.mp3 /data/accounts/account_0/appdata" 命令,将其推送到设备上
let path = '/data/accounts/account_0/appdata/ohos.xxx.xxx.xxx/01.mp3'; let path = '/data/accounts/account_0/appdata/ohos.xxx.xxx.xxx/01.mp3';
fs.open(path).then((file) => { fs.open(path).then((file) => {
fdPath = fdPath + '' + file.fd; fdPath = fdPath + '' + file.fd;
console.info('open fd success fd is' + fdPath); console.info('open fd success fd is' + fdPath);
audioPlayer.src = fdPath; //设置src属性,并触发'dataLoad'事件回调 audioPlayer.src = fdPath; //设置src属性,并触发'dataLoad'事件回调
}, (err) => { }, (err) => {
console.info('open fd failed err is' + err); console.info('open fd failed err is' + err);
}).catch((err) => { }).catch((err) => {
console.info('open fd failed err is' + err); console.info('open fd failed err is' + err);
}); });
``` ```
...@@ -3867,11 +3867,11 @@ on(type: 'timeUpdate', callback: Callback\<number>): void ...@@ -3867,11 +3867,11 @@ on(type: 'timeUpdate', callback: Callback\<number>): void
```js ```js
audioPlayer.on('timeUpdate', (newTime) => { //设置'timeUpdate'事件回调 audioPlayer.on('timeUpdate', (newTime) => { //设置'timeUpdate'事件回调
if (newTime == null) { if (newTime == null) {
console.info('audio timeUpadate fail'); console.info('audio timeUpadate fail');
return; return;
} }
console.log('audio timeUpadate success. seekDoneTime: ' + newTime); console.log('audio timeUpadate success. seekDoneTime: ' + newTime);
}); });
audioPlayer.play(); //开始播放后,自动触发时间戳更新事件 audioPlayer.play(); //开始播放后,自动触发时间戳更新事件
``` ```
...@@ -3895,7 +3895,7 @@ on(type: 'error', callback: ErrorCallback): void ...@@ -3895,7 +3895,7 @@ on(type: 'error', callback: ErrorCallback): void
```js ```js
audioPlayer.on('error', (error) => { //设置'error'事件回调 audioPlayer.on('error', (error) => { //设置'error'事件回调
console.info(`audio error called, error: ${error}`); console.error(`audio error called, error: ${error}`);
}); });
audioPlayer.setVolume(3); //设置volume为无效值,触发'error'事件 audioPlayer.setVolume(3); //设置volume为无效值,触发'error'事件
``` ```
...@@ -3963,11 +3963,11 @@ setDisplaySurface(surfaceId: string, callback: AsyncCallback\<void>): void ...@@ -3963,11 +3963,11 @@ setDisplaySurface(surfaceId: string, callback: AsyncCallback\<void>): void
```js ```js
let surfaceId = null; let surfaceId = null;
videoPlayer.setDisplaySurface(surfaceId, (err) => { videoPlayer.setDisplaySurface(surfaceId, (err) => {
if (err == null) { if (err == null) {
console.info('setDisplaySurface success!'); console.info('setDisplaySurface success!');
} else { } else {
console.info('setDisplaySurface fail!'); console.error('setDisplaySurface fail!');
} }
}); });
``` ```
...@@ -3998,9 +3998,9 @@ setDisplaySurface(surfaceId: string): Promise\<void> ...@@ -3998,9 +3998,9 @@ setDisplaySurface(surfaceId: string): Promise\<void>
```js ```js
let surfaceId = null; let surfaceId = null;
videoPlayer.setDisplaySurface(surfaceId).then(() => { videoPlayer.setDisplaySurface(surfaceId).then(() => {
console.info('setDisplaySurface success'); console.info('setDisplaySurface success');
}).catch((error) => { }).catch((error) => {
console.info(`video catchCallback, error:${error}`); console.error(`video catchCallback, error:${error}`);
}); });
``` ```
...@@ -4022,11 +4022,11 @@ prepare(callback: AsyncCallback\<void>): void ...@@ -4022,11 +4022,11 @@ prepare(callback: AsyncCallback\<void>): void
```js ```js
videoPlayer.prepare((err) => { videoPlayer.prepare((err) => {
if (err == null) { if (err == null) {
console.info('prepare success!'); console.info('prepare success!');
} else { } else {
console.info('prepare fail!'); console.error('prepare fail!');
} }
}); });
``` ```
...@@ -4048,9 +4048,9 @@ prepare(): Promise\<void> ...@@ -4048,9 +4048,9 @@ prepare(): Promise\<void>
```js ```js
videoPlayer.prepare().then(() => { videoPlayer.prepare().then(() => {
console.info('prepare success'); console.info('prepare success');
}).catch((error) => { }).catch((error) => {
console.info(`video catchCallback, error:${error}`); console.error(`video catchCallback, error:${error}`);
}); });
``` ```
...@@ -4072,11 +4072,11 @@ play(callback: AsyncCallback\<void>): void; ...@@ -4072,11 +4072,11 @@ play(callback: AsyncCallback\<void>): void;
```js ```js
videoPlayer.play((err) => { videoPlayer.play((err) => {
if (err == null) { if (err == null) {
console.info('play success!'); console.info('play success!');
} else { } else {
console.info('play fail!'); console.error('play fail!');
} }
}); });
``` ```
...@@ -4098,9 +4098,9 @@ play(): Promise\<void>; ...@@ -4098,9 +4098,9 @@ play(): Promise\<void>;
```js ```js
videoPlayer.play().then(() => { videoPlayer.play().then(() => {
console.info('play success'); console.info('play success');
}).catch((error) => { }).catch((error) => {
console.info(`video catchCallback, error:${error}`); console.error(`video catchCallback, error:${error}`);
}); });
``` ```
...@@ -4122,11 +4122,11 @@ pause(callback: AsyncCallback\<void>): void ...@@ -4122,11 +4122,11 @@ pause(callback: AsyncCallback\<void>): void
```js ```js
videoPlayer.pause((err) => { videoPlayer.pause((err) => {
if (err == null) { if (err == null) {
console.info('pause success!'); console.info('pause success!');
} else { } else {
console.info('pause fail!'); console.info('pause fail!');
} }
}); });
``` ```
...@@ -4148,9 +4148,9 @@ pause(): Promise\<void> ...@@ -4148,9 +4148,9 @@ pause(): Promise\<void>
```js ```js
videoPlayer.pause().then(() => { videoPlayer.pause().then(() => {
console.info('pause success'); console.info('pause success');
}).catch((error) => { }).catch((error) => {
console.info(`video catchCallback, error:${error}`); console.error(`video catchCallback, error:${error}`);
}); });
``` ```
...@@ -4172,11 +4172,11 @@ stop(callback: AsyncCallback\<void>): void ...@@ -4172,11 +4172,11 @@ stop(callback: AsyncCallback\<void>): void
```js ```js
videoPlayer.stop((err) => { videoPlayer.stop((err) => {
if (err == null) { if (err == null) {
console.info('stop success!'); console.info('stop success!');
} else { } else {
console.info('stop fail!'); console.error('stop fail!');
} }
}); });
``` ```
...@@ -4198,9 +4198,9 @@ stop(): Promise\<void> ...@@ -4198,9 +4198,9 @@ stop(): Promise\<void>
```js ```js
videoPlayer.stop().then(() => { videoPlayer.stop().then(() => {
console.info('stop success'); console.info('stop success');
}).catch((error) => { }).catch((error) => {
console.info(`video catchCallback, error:${error}`); console.error(`video catchCallback, error:${error}`);
}); });
``` ```
...@@ -4222,11 +4222,11 @@ reset(callback: AsyncCallback\<void>): void ...@@ -4222,11 +4222,11 @@ reset(callback: AsyncCallback\<void>): void
```js ```js
videoPlayer.reset((err) => { videoPlayer.reset((err) => {
if (err == null) { if (err == null) {
console.info('reset success!'); console.info('reset success!');
} else { } else {
console.info('reset fail!'); console.error('reset fail!');
} }
}); });
``` ```
...@@ -4248,9 +4248,9 @@ reset(): Promise\<void> ...@@ -4248,9 +4248,9 @@ reset(): Promise\<void>
```js ```js
videoPlayer.reset().then(() => { videoPlayer.reset().then(() => {
console.info('reset success'); console.info('reset success');
}).catch((error) => { }).catch((error) => {
console.info(`video catchCallback, error:${error}`); console.error(`video catchCallback, error:${error}`);
}); });
``` ```
...@@ -4274,11 +4274,11 @@ seek(timeMs: number, callback: AsyncCallback\<number>): void ...@@ -4274,11 +4274,11 @@ seek(timeMs: number, callback: AsyncCallback\<number>): void
```js ```js
let seekTime = 5000; let seekTime = 5000;
videoPlayer.seek(seekTime, (err, result) => { videoPlayer.seek(seekTime, (err, result) => {
if (err == null) { if (err == null) {
console.info('seek success!'); console.info('seek success!');
} else { } else {
console.info('seek fail!'); console.error('seek fail!');
} }
}); });
``` ```
...@@ -4304,11 +4304,11 @@ seek(timeMs: number, mode:SeekMode, callback: AsyncCallback\<number>): void ...@@ -4304,11 +4304,11 @@ seek(timeMs: number, mode:SeekMode, callback: AsyncCallback\<number>): void
import media from '@ohos.multimedia.media' import media from '@ohos.multimedia.media'
let seekTime = 5000; let seekTime = 5000;
videoPlayer.seek(seekTime, media.SeekMode.SEEK_NEXT_SYNC, (err, result) => { videoPlayer.seek(seekTime, media.SeekMode.SEEK_NEXT_SYNC, (err, result) => {
if (err == null) { if (err == null) {
console.info('seek success!'); console.info('seek success!');
} else { } else {
console.info('seek fail!'); console.error('seek fail!');
} }
}); });
``` ```
...@@ -4339,15 +4339,15 @@ seek(timeMs: number, mode?:SeekMode): Promise\<number> ...@@ -4339,15 +4339,15 @@ seek(timeMs: number, mode?:SeekMode): Promise\<number>
import media from '@ohos.multimedia.media' import media from '@ohos.multimedia.media'
let seekTime = 5000; let seekTime = 5000;
videoPlayer.seek(seekTime).then((seekDoneTime) => { // seekDoneTime表示seek完成后的时间点 videoPlayer.seek(seekTime).then((seekDoneTime) => { // seekDoneTime表示seek完成后的时间点
console.info('seek success'); console.info('seek success');
}).catch((error) => { }).catch((error) => {
console.info(`video catchCallback, error:${error}`); console.error(`video catchCallback, error:${error}`);
}); });
videoPlayer.seek(seekTime, media.SeekMode.SEEK_NEXT_SYNC).then((seekDoneTime) => { videoPlayer.seek(seekTime, media.SeekMode.SEEK_NEXT_SYNC).then((seekDoneTime) => {
console.info('seek success'); console.info('seek success');
}).catch((error) => { }).catch((error) => {
console.info(`video catchCallback, error:${error}`); console.error(`video catchCallback, error:${error}`);
}); });
``` ```
...@@ -4371,11 +4371,11 @@ setVolume(vol: number, callback: AsyncCallback\<void>): void ...@@ -4371,11 +4371,11 @@ setVolume(vol: number, callback: AsyncCallback\<void>): void
```js ```js
let vol = 0.5; let vol = 0.5;
videoPlayer.setVolume(vol, (err, result) => { videoPlayer.setVolume(vol, (err, result) => {
if (err == null) { if (err == null) {
console.info('setVolume success!'); console.info('setVolume success!');
} else { } else {
console.info('setVolume fail!'); console.error('setVolume fail!');
} }
}); });
``` ```
...@@ -4404,9 +4404,9 @@ setVolume(vol: number): Promise\<void> ...@@ -4404,9 +4404,9 @@ setVolume(vol: number): Promise\<void>
```js ```js
let vol = 0.5; let vol = 0.5;
videoPlayer.setVolume(vol).then(() => { videoPlayer.setVolume(vol).then(() => {
console.info('setVolume success'); console.info('setVolume success');
}).catch((error) => { }).catch((error) => {
console.info(`video catchCallback, error:${error}`); console.error(`video catchCallback, error:${error}`);
}); });
``` ```
...@@ -4428,11 +4428,11 @@ release(callback: AsyncCallback\<void>): void ...@@ -4428,11 +4428,11 @@ release(callback: AsyncCallback\<void>): void
```js ```js
videoPlayer.release((err) => { videoPlayer.release((err) => {
if (err == null) { if (err == null) {
console.info('release success!'); console.info('release success!');
} else { } else {
console.info('release fail!'); console.error('release fail!');
} }
}); });
``` ```
...@@ -4454,9 +4454,9 @@ release(): Promise\<void> ...@@ -4454,9 +4454,9 @@ release(): Promise\<void>
```js ```js
videoPlayer.release().then(() => { videoPlayer.release().then(() => {
console.info('release success'); console.info('release success');
}).catch((error) => { }).catch((error) => {
console.info(`video catchCallback, error:${error}`); console.error(`video catchCallback, error:${error}`);
}); });
``` ```
...@@ -4478,21 +4478,21 @@ getTrackDescription(callback: AsyncCallback\<Array\<MediaDescription>>): void ...@@ -4478,21 +4478,21 @@ getTrackDescription(callback: AsyncCallback\<Array\<MediaDescription>>): void
```js ```js
function printfDescription(obj) { function printfDescription(obj) {
for (let item in obj) { for (let item in obj) {
let property = obj[item]; let property = obj[item];
console.info('video key is ' + item); console.info('video key is ' + item);
console.info('video value is ' + property); console.info('video value is ' + property);
} }
} }
videoPlayer.getTrackDescription((error, arrList) => { videoPlayer.getTrackDescription((error, arrList) => {
if ((arrList) != null) { if ((arrList) != null) {
for (let i = 0; i < arrList.length; i++) { for (let i = 0; i < arrList.length; i++) {
printfDescription(arrList[i]); printfDescription(arrList[i]);
}
} else {
console.log(`video getTrackDescription fail, error:${error}`);
} }
} else {
console.log(`video getTrackDescription fail, error:${error}`);
}
}); });
``` ```
...@@ -4514,25 +4514,25 @@ getTrackDescription(): Promise\<Array\<MediaDescription>> ...@@ -4514,25 +4514,25 @@ getTrackDescription(): Promise\<Array\<MediaDescription>>
```js ```js
function printfDescription(obj) { function printfDescription(obj) {
for (let item in obj) { for (let item in obj) {
let property = obj[item]; let property = obj[item];
console.info('video key is ' + item); console.info('video key is ' + item);
console.info('video value is ' + property); console.info('video value is ' + property);
} }
} }
let arrayDescription; let arrayDescription;
videoPlayer.getTrackDescription().then((arrList) => { videoPlayer.getTrackDescription().then((arrList) => {
if (arrList != null) { if (arrList != null) {
arrayDescription = arrList; arrayDescription = arrList;
} else { } else {
console.log('video getTrackDescription fail'); console.log('video getTrackDescription fail');
} }
}).catch((error) => { }).catch((error) => {
console.info(`video catchCallback, error:${error}`); console.info(`video catchCallback, error:${error}`);
}); });
for (let i = 0; i < arrayDescription.length; i++) { for (let i = 0; i < arrayDescription.length; i++) {
printfDescription(arrayDescription[i]); printfDescription(arrayDescription[i]);
} }
``` ```
...@@ -4558,11 +4558,11 @@ import media from '@ohos.multimedia.media' ...@@ -4558,11 +4558,11 @@ import media from '@ohos.multimedia.media'
let speed = media.PlaybackSpeed.SPEED_FORWARD_2_00_X; let speed = media.PlaybackSpeed.SPEED_FORWARD_2_00_X;
videoPlayer.setSpeed(speed, (err, result) => { videoPlayer.setSpeed(speed, (err, result) => {
if (err == null) { if (err == null) {
console.info('setSpeed success!'); console.info('setSpeed success!');
} else { } else {
console.info('setSpeed fail!'); console.error('setSpeed fail!');
} }
}); });
``` ```
...@@ -4593,9 +4593,9 @@ import media from '@ohos.multimedia.media' ...@@ -4593,9 +4593,9 @@ import media from '@ohos.multimedia.media'
let speed = media.PlaybackSpeed.SPEED_FORWARD_2_00_X; let speed = media.PlaybackSpeed.SPEED_FORWARD_2_00_X;
videoPlayer.setSpeed(speed).then(() => { videoPlayer.setSpeed(speed).then(() => {
console.info('setSpeed success'); console.info('setSpeed success');
}).catch((error) => { }).catch((error) => {
console.info(`video catchCallback, error:${error}`); console.error(`video catchCallback, error:${error}`);
}); });
``` ```
...@@ -4618,7 +4618,7 @@ on(type: 'playbackCompleted', callback: Callback\<void>): void ...@@ -4618,7 +4618,7 @@ on(type: 'playbackCompleted', callback: Callback\<void>): void
```js ```js
videoPlayer.on('playbackCompleted', () => { videoPlayer.on('playbackCompleted', () => {
console.info('playbackCompleted success!'); console.info('playbackCompleted success!');
}); });
``` ```
...@@ -4641,8 +4641,8 @@ on(type: 'bufferingUpdate', callback: (infoType: BufferingInfoType, value: numbe ...@@ -4641,8 +4641,8 @@ on(type: 'bufferingUpdate', callback: (infoType: BufferingInfoType, value: numbe
```js ```js
videoPlayer.on('bufferingUpdate', (infoType, value) => { videoPlayer.on('bufferingUpdate', (infoType, value) => {
console.log('video bufferingInfo type: ' + infoType); console.log('video bufferingInfo type: ' + infoType);
console.log('video bufferingInfo value: ' + value); console.log('video bufferingInfo value: ' + value);
}); });
``` ```
...@@ -4665,7 +4665,7 @@ on(type: 'startRenderFrame', callback: Callback\<void>): void ...@@ -4665,7 +4665,7 @@ on(type: 'startRenderFrame', callback: Callback\<void>): void
```js ```js
videoPlayer.on('startRenderFrame', () => { videoPlayer.on('startRenderFrame', () => {
console.info('startRenderFrame success!'); console.info('startRenderFrame success!');
}); });
``` ```
...@@ -4688,8 +4688,8 @@ on(type: 'videoSizeChanged', callback: (width: number, height: number) => void): ...@@ -4688,8 +4688,8 @@ on(type: 'videoSizeChanged', callback: (width: number, height: number) => void):
```js ```js
videoPlayer.on('videoSizeChanged', (width, height) => { videoPlayer.on('videoSizeChanged', (width, height) => {
console.log('video width is: ' + width); console.log('video width is: ' + width);
console.log('video height is: ' + height); console.log('video height is: ' + height);
}); });
``` ```
...@@ -4712,7 +4712,7 @@ on(type: 'error', callback: ErrorCallback): void ...@@ -4712,7 +4712,7 @@ on(type: 'error', callback: ErrorCallback): void
```js ```js
videoPlayer.on('error', (error) => { // 设置'error'事件回调 videoPlayer.on('error', (error) => { // 设置'error'事件回调
console.info(`video error called, error: ${error}`); console.error(`video error called, error: ${error}`);
}); });
videoPlayer.url = 'fd://error'; //设置错误的播放地址,触发'error'事件 videoPlayer.url = 'fd://error'; //设置错误的播放地址,触发'error'事件
``` ```
...@@ -4762,16 +4762,16 @@ prepare(config: AudioRecorderConfig): void ...@@ -4762,16 +4762,16 @@ prepare(config: AudioRecorderConfig): void
```js ```js
let audioRecorderConfig = { let audioRecorderConfig = {
audioEncoder : media.AudioEncoder.AAC_LC, audioEncoder : media.AudioEncoder.AAC_LC,
audioEncodeBitRate : 22050, audioEncodeBitRate : 22050,
audioSampleRate : 22050, audioSampleRate : 22050,
numberOfChannels : 2, numberOfChannels : 2,
format : media.AudioOutputFormat.AAC_ADTS, format : media.AudioOutputFormat.AAC_ADTS,
uri : 'fd://1', // 文件需先由调用者创建,并给予适当的权限 uri : 'fd://1', // 文件需先由调用者创建,并给予适当的权限
location : { latitude : 30, longitude : 130}, location : { latitude : 30, longitude : 130},
} }
audioRecorder.on('prepare', () => { //设置'prepare'事件回调 audioRecorder.on('prepare', () => { //设置'prepare'事件回调
console.log('prepare success'); console.log('prepare success');
}); });
audioRecorder.prepare(audioRecorderConfig); audioRecorder.prepare(audioRecorderConfig);
``` ```
...@@ -4789,7 +4789,7 @@ start(): void ...@@ -4789,7 +4789,7 @@ start(): void
```js ```js
audioRecorder.on('start', () => { //设置'start'事件回调 audioRecorder.on('start', () => { //设置'start'事件回调
console.log('audio recorder start success'); console.log('audio recorder start success');
}); });
audioRecorder.start(); audioRecorder.start();
``` ```
...@@ -4806,7 +4806,7 @@ pause():void ...@@ -4806,7 +4806,7 @@ pause():void
```js ```js
audioRecorder.on('pause', () => { //设置'pause'事件回调 audioRecorder.on('pause', () => { //设置'pause'事件回调
console.log('audio recorder pause success'); console.log('audio recorder pause success');
}); });
audioRecorder.pause(); audioRecorder.pause();
``` ```
...@@ -4823,7 +4823,7 @@ resume():void ...@@ -4823,7 +4823,7 @@ resume():void
```js ```js
audioRecorder.on('resume', () => { //设置'resume'事件回调 audioRecorder.on('resume', () => { //设置'resume'事件回调
console.log('audio recorder resume success'); console.log('audio recorder resume success');
}); });
audioRecorder.resume(); audioRecorder.resume();
``` ```
...@@ -4840,7 +4840,7 @@ stop(): void ...@@ -4840,7 +4840,7 @@ stop(): void
```js ```js
audioRecorder.on('stop', () => { //设置'stop'事件回调 audioRecorder.on('stop', () => { //设置'stop'事件回调
console.log('audio recorder stop success'); console.log('audio recorder stop success');
}); });
audioRecorder.stop(); audioRecorder.stop();
``` ```
...@@ -4857,7 +4857,7 @@ release(): void ...@@ -4857,7 +4857,7 @@ release(): void
```js ```js
audioRecorder.on('release', () => { //设置'release'事件回调 audioRecorder.on('release', () => { //设置'release'事件回调
console.log('audio recorder release success'); console.log('audio recorder release success');
}); });
audioRecorder.release(); audioRecorder.release();
audioRecorder = undefined; audioRecorder = undefined;
...@@ -4877,7 +4877,7 @@ reset(): void ...@@ -4877,7 +4877,7 @@ reset(): void
```js ```js
audioRecorder.on('reset', () => { //设置'reset'事件回调 audioRecorder.on('reset', () => { //设置'reset'事件回调
console.log('audio recorder reset success'); console.log('audio recorder reset success');
}); });
audioRecorder.reset(); audioRecorder.reset();
``` ```
...@@ -4902,38 +4902,38 @@ on(type: 'prepare' | 'start' | 'pause' | 'resume' | 'stop' | 'release' | 'reset' ...@@ -4902,38 +4902,38 @@ on(type: 'prepare' | 'start' | 'pause' | 'resume' | 'stop' | 'release' | 'reset'
```js ```js
let audioRecorder = media.createAudioRecorder(); // 创建一个音频录制实例 let audioRecorder = media.createAudioRecorder(); // 创建一个音频录制实例
let audioRecorderConfig = { let audioRecorderConfig = {
audioEncoder : media.AudioEncoder.AAC_LC, audioEncoder : media.AudioEncoder.AAC_LC,
audioEncodeBitRate : 22050, audioEncodeBitRate : 22050,
audioSampleRate : 22050, audioSampleRate : 22050,
numberOfChannels : 2, numberOfChannels : 2,
format : media.AudioOutputFormat.AAC_ADTS, format : media.AudioOutputFormat.AAC_ADTS,
uri : 'fd://xx', // 文件需先由调用者创建,并给予适当的权限 uri : 'fd://xx', // 文件需先由调用者创建,并给予适当的权限
location : { latitude : 30, longitude : 130}, location : { latitude : 30, longitude : 130},
} }
audioRecorder.on('error', (error) => { // 设置'error'事件回调 audioRecorder.on('error', (error) => { // 设置'error'事件回调
console.info(`audio error called, error: ${error}`); console.info(`audio error called, error: ${error}`);
}); });
audioRecorder.on('prepare', () => { // 设置'prepare'事件回调 audioRecorder.on('prepare', () => { // 设置'prepare'事件回调
console.log('prepare success'); console.log('prepare success');
audioRecorder.start(); // 开始录制,并触发'start'事件回调 audioRecorder.start(); // 开始录制,并触发'start'事件回调
}); });
audioRecorder.on('start', () => { // 设置'start'事件回调 audioRecorder.on('start', () => { // 设置'start'事件回调
console.log('audio recorder start success'); console.log('audio recorder start success');
}); });
audioRecorder.on('pause', () => { // 设置'pause'事件回调 audioRecorder.on('pause', () => { // 设置'pause'事件回调
console.log('audio recorder pause success'); console.log('audio recorder pause success');
}); });
audioRecorder.on('resume', () => { // 设置'resume'事件回调 audioRecorder.on('resume', () => { // 设置'resume'事件回调
console.log('audio recorder resume success'); console.log('audio recorder resume success');
}); });
audioRecorder.on('stop', () => { // 设置'stop'事件回调 audioRecorder.on('stop', () => { // 设置'stop'事件回调
console.log('audio recorder stop success'); console.log('audio recorder stop success');
}); });
audioRecorder.on('release', () => { // 设置'release'事件回调 audioRecorder.on('release', () => { // 设置'release'事件回调
console.log('audio recorder release success'); console.log('audio recorder release success');
}); });
audioRecorder.on('reset', () => { // 设置'reset'事件回调 audioRecorder.on('reset', () => { // 设置'reset'事件回调
console.log('audio recorder reset success'); console.log('audio recorder reset success');
}); });
audioRecorder.prepare(audioRecorderConfig) // 设置录制参数 ,并触发'prepare'事件回调 audioRecorder.prepare(audioRecorderConfig) // 设置录制参数 ,并触发'prepare'事件回调
``` ```
...@@ -4957,16 +4957,16 @@ on(type: 'error', callback: ErrorCallback): void ...@@ -4957,16 +4957,16 @@ on(type: 'error', callback: ErrorCallback): void
```js ```js
let audioRecorderConfig = { let audioRecorderConfig = {
audioEncoder : media.AudioEncoder.AAC_LC, audioEncoder : media.AudioEncoder.AAC_LC,
audioEncodeBitRate : 22050, audioEncodeBitRate : 22050,
audioSampleRate : 22050, audioSampleRate : 22050,
numberOfChannels : 2, numberOfChannels : 2,
format : media.AudioOutputFormat.AAC_ADTS, format : media.AudioOutputFormat.AAC_ADTS,
uri : 'fd://xx', // 文件需先由调用者创建,并给予适当的权限 uri : 'fd://xx', // 文件需先由调用者创建,并给予适当的权限
location : { latitude : 30, longitude : 130}, location : { latitude : 30, longitude : 130},
} }
audioRecorder.on('error', (error) => { // 设置'error'事件回调 audioRecorder.on('error', (error) => { // 设置'error'事件回调
console.info(`audio error called, error: ${error}`); console.error(`audio error called, error: ${error}`);
}); });
audioRecorder.prepare(audioRecorderConfig); // prepare不设置参数,触发'error'事件 audioRecorder.prepare(audioRecorderConfig); // prepare不设置参数,触发'error'事件
``` ```
......
...@@ -3975,6 +3975,87 @@ notificationManager.getSyncNotificationEnabledWithoutApp(userId).then((data) => ...@@ -3975,6 +3975,87 @@ notificationManager.getSyncNotificationEnabledWithoutApp(userId).then((data) =>
}); });
``` ```
## notificationManager.on<sup>10+</sup>
on(type: 'checkNotification', callback: (checkInfo: NotificationCheckInfo) => NotificationCheckResult): void;
注册通知监听回调。通知服务将通知信息回调给校验程序,校验程序返回校验结果决定该通知是否发布,如营销类通知发布频率控制等。
**系统能力**:SystemCapability.Notification.Notification
**系统API**:此接口为系统接口,三方应用不支持调用。
**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER and ohos.permission.NOTIFICATION_AGENT_CONTROLLER
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ----------------------------- | ---- | -------------- |
| type | string | 是 | 回调函数类型名,固定为'checkNotification'。 |
| callback | (checkInfo: [NotificationCheckInfo](#notificationcheckinfo)) => [NotificationCheckResult](#notificationcheckresult) | 是 | 消息验证函数指针。 |
**错误码:**
错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)
| 错误码ID | 错误信息 |
| -------- | --------------- |
| 1600001 | Internal error. |
**示例:**
```ts
try{
notificationManager.on("checkNotification", OnCheckNotification);
} catch (error){
console.info(`notificationManager.on error: ${JSON.stringify(error)}`);
}
function OnCheckNotification(info : notificationManager.NotificationCheckInfo) {
console.info(`====>OnCheckNotification info: ${JSON.stringify(info)}`);
if(info.notificationId == 1){
return { code: 1, message: "testMsg1"}
} else {
return { code: 0, message: "testMsg0"}
}
}
```
## notificationManager.off<sup>10+</sup>
off(type: 'checkNotification', callback?: (checkInfo: NotificationCheckInfo) => NotificationCheckResult): void;
取消通知监听回调。
**系统能力**:SystemCapability.Notification.Notification
**系统API**:此接口为系统接口,三方应用不支持调用。
**需要权限**:ohos.permission.NOTIFICATION_CONTROLLER and ohos.permission.NOTIFICATION_AGENT_CONTROLLER
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ----------------------------- | ---- | -------------- |
| type | string | 是 | 回调函数类型名,固定为'checkNotification'。 |
| callback | (checkInfo: [NotificationCheckInfo](#notificationcheckinfo)) => [NotificationCheckResult](#notificationcheckresult) | 否 | 消息验证函数指针。 |
**错误码:**
错误码详细介绍请参考[errcode-notification](../errorcodes/errorcode-notification.md)
| 错误码ID | 错误信息 |
| -------- | --------------- |
| 1600001 | Internal error. |
**示例:**
```ts
try{
notificationManager.off("checkNotification");
} catch (error){
console.info(`notificationManager.off error: ${JSON.stringify(error)}`);
}
```
## DoNotDisturbDate ## DoNotDisturbDate
...@@ -4067,3 +4148,23 @@ notificationManager.getSyncNotificationEnabledWithoutApp(userId).then((data) => ...@@ -4067,3 +4148,23 @@ notificationManager.getSyncNotificationEnabledWithoutApp(userId).then((data) =>
| TYPE_NORMAL | 0 | 一般通知。 | | TYPE_NORMAL | 0 | 一般通知。 |
| TYPE_CONTINUOUS | 1 | 连续通知。 | | TYPE_CONTINUOUS | 1 | 连续通知。 |
| TYPE_TIMER | 2 | 计划通知。 | | TYPE_TIMER | 2 | 计划通知。 |
## NotificationCheckInfo
用于校验通知的参数。
| 名称 | 类型 | 可读 | 可写 | 说明 |
| -------------------- | -------- | ---------- | ---------- | ---------- |
| bundleName | string | 是 | 否 | bundle名称。 |
| notificationId | number | 是 | 否 | 通知Id。 |
| contentType | [ContentType](#contenttype) | 是 | 否 | 通知类型。 |
## NotificationCheckResult
通知校验结果。
| 名称 | 类型 | 可读 | 可写 | 说明 |
| -------------------- | -------- | ---------- | ---------- | ---------- |
| code | number | 是 | 否 | 0-display, 1-no display。 |
| message | string | 是 | 否 | 结果信息。 |
...@@ -483,9 +483,9 @@ record.convertToText().then((data) => { ...@@ -483,9 +483,9 @@ record.convertToText().then((data) => {
## PasteData ## PasteData
剪贴板内容对象。 剪贴板内容对象。剪贴板内容包含一个或者多个内容条目([PasteDataRecord](#pastedatarecord7))以及属性描述对象([PasteDataProperty](#pastedataproperty7))。
在调用PasteData的接口前,需要先获取一个PasteData对象。 在调用PasteData的接口前,需要先通过[createData()](#pasteboardcreatedata9)[getData()](#getdata9)获取一个PasteData对象。
**系统能力:** SystemCapability.MiscServices.Pasteboard **系统能力:** SystemCapability.MiscServices.Pasteboard
......
...@@ -155,11 +155,11 @@ OnPushEventCallback = (source: Want, template: PluginComponentTemplate, data: KV ...@@ -155,11 +155,11 @@ OnPushEventCallback = (source: Want, template: PluginComponentTemplate, data: KV
```js ```js
function onPushListener(source, template, data, extraData) { function onPushListener(source, template, data, extraData) {
console.log("onPushListener template.source=" + template.source) console.log("onPushListener template.source=" + template.source)
console.log("onPushListener source=" + JSON.stringify(source)) console.log("onPushListener source=" + JSON.stringify(source))
console.log("onPushListener template=" + JSON.stringify(template)) console.log("onPushListener template=" + JSON.stringify(template))
console.log("onPushListener data=" + JSON.stringify(data)) console.log("onPushListener data=" + JSON.stringify(data))
console.log("onPushListener extraData=" + JSON.stringify(extraData)) console.log("onPushListener extraData=" + JSON.stringify(extraData))
} }
``` ```
...@@ -181,14 +181,13 @@ OnRequestEventCallback = (source: Want, name: string, data: KVObject) => Request ...@@ -181,14 +181,13 @@ OnRequestEventCallback = (source: Want, name: string, data: KVObject) => Request
**示例:** **示例:**
```js ```js
function onRequestListener(source, name, data) function onRequestListener(source, name, data) {
{ console.error("onRequestListener");
console.error("onRequestListener"); console.log("onRequestListener source=" + JSON.stringify(source));
console.log("onRequestListener source=" + JSON.stringify(source)); console.log("onRequestListener name=" + name);
console.log("onRequestListener name=" + name); console.log("onRequestListener data=" + JSON.stringify(data));
console.log("onRequestListener data=" + JSON.stringify(data));
return {template:"ets/pages/plugin.js", data:data}; return { template: "ets/pages/plugin.js", data: data };
} }
``` ```
...@@ -210,24 +209,24 @@ push(param: PushParameters , callback: AsyncCallback&lt;void&gt;): void ...@@ -210,24 +209,24 @@ push(param: PushParameters , callback: AsyncCallback&lt;void&gt;): void
```js ```js
pluginComponentManager.push( pluginComponentManager.push(
{ {
want: { want: {
bundleName: "com.example.provider", bundleName: "com.example.provider",
abilityName: "com.example.provider.MainAbility", abilityName: "com.example.provider.MainAbility",
}, },
name: "plugintemplate", name: "plugintemplate",
data: { data: {
"key_1": "plugin component test", "key_1": "plugin component test",
"key_2": 34234 "key_2": 34234
}, },
extraData: { extraData: {
"extra_str": "this is push event" "extra_str": "this is push event"
}, },
jsonPath: "", jsonPath: "",
}, },
(err, data) => { (err, data) => {
console.log("push_callback: push ok!"); console.log("push_callback: push ok!");
} }
) )
``` ```
...@@ -251,30 +250,30 @@ push(param: PushParameterForStage, callback: AsyncCallback&lt;void&gt;): void ...@@ -251,30 +250,30 @@ push(param: PushParameterForStage, callback: AsyncCallback&lt;void&gt;): void
```js ```js
pluginComponentManager.push( pluginComponentManager.push(
{ {
owner:{ owner: {
bundleName:"com.example.provider", bundleName: "com.example.provider",
abilityName:"com.example.provider.MainAbility" abilityName: "com.example.provider.MainAbility"
}, },
target: { target: {
bundleName: "com.example.provider", bundleName: "com.example.provider",
abilityName: "com.example.provider.MainAbility", abilityName: "com.example.provider.MainAbility",
}, },
name: "ets/pages/plugin2.js", name: "ets/pages/plugin2.js",
data: { data: {
"js": "ets/pages/plugin.js", "js": "ets/pages/plugin.js",
"key_1": 1111, , "key_1": 1111, ,
}, },
extraData: { extraData: {
"extra_str": "this is push event" "extra_str": "this is push event"
},
jsonPath: "",
}, },
(err, data) => { jsonPath: "",
console.log("push_callback:err: " ,JSON.stringify(err)); },
console.log("push_callback:data: " , JSON.stringify(data)); (err, data) => {
console.log("push_callback: push ok!"); console.log("push_callback:err: ", JSON.stringify(err));
} console.log("push_callback:data: ", JSON.stringify(data));
console.log("push_callback: push ok!");
}
) )
``` ```
...@@ -299,24 +298,24 @@ request(param: RequestParameters, callback: AsyncCallback&lt;RequestCallbackPara ...@@ -299,24 +298,24 @@ request(param: RequestParameters, callback: AsyncCallback&lt;RequestCallbackPara
```js ```js
pluginComponentManager.request( pluginComponentManager.request(
{ {
want: { want: {
bundleName: "com.example.provider", bundleName: "com.example.provider",
abilityName: "com.example.provider.MainAbility", abilityName: "com.example.provider.MainAbility",
},
name: "plugintemplate",
data: {
"key_1": "plugin component test",
"key_2": 1111111
},
jsonPath: "",
}, },
(err, data) => { name: "plugintemplate",
console.log("request_callback: componentTemplate.ability=" + data.componentTemplate.ability) data: {
console.log("request_callback: componentTemplate.source=" + data.componentTemplate.source) "key_1": "plugin component test",
console.log("request_callback: data=" + JSON.stringify(data.data)) "key_2": 1111111
console.log("request_callback: extraData=" + JSON.stringify(data.extraData)) },
} jsonPath: "",
},
(err, data) => {
console.log("request_callback: componentTemplate.ability=" + data.componentTemplate.ability)
console.log("request_callback: componentTemplate.source=" + data.componentTemplate.source)
console.log("request_callback: data=" + JSON.stringify(data.data))
console.log("request_callback: extraData=" + JSON.stringify(data.extraData))
}
) )
``` ```
...@@ -342,25 +341,25 @@ request(param: RequestParameterForStage, callback: AsyncCallback&lt;RequestCallb ...@@ -342,25 +341,25 @@ request(param: RequestParameterForStage, callback: AsyncCallback&lt;RequestCallb
```js ```js
pluginComponentManager.request( pluginComponentManager.request(
{ {
owner:{ owner: {
bundleName:"com.example.provider", bundleName: "com.example.provider",
abilityName:"com.example.provider.MainAbility" abilityName: "com.example.provider.MainAbility"
}, },
target: { target: {
bundleName: "com.example.provider", bundleName: "com.example.provider",
abilityName: "ets/pages/plugin2.js", abilityName: "ets/pages/plugin2.js",
},
name: "plugintemplate",
data: {
"key_1": " myapplication plugin component test",
},
jsonPath: "",
}, },
(err, data) => { name: "plugintemplate",
console.log("request_callback: componentTemplate.ability=" + data.componentTemplate.ability) data: {
console.log("request_callback: componentTemplate.source=" + data.componentTemplate.source) "key_1": " myapplication plugin component test",
} },
jsonPath: "",
},
(err, data) => {
console.log("request_callback: componentTemplate.ability=" + data.componentTemplate.ability)
console.log("request_callback: componentTemplate.source=" + data.componentTemplate.source)
}
) )
``` ```
...@@ -381,8 +380,8 @@ on(eventType: string, callback: OnPushEventCallback | OnRequestEventCallback ): ...@@ -381,8 +380,8 @@ on(eventType: string, callback: OnPushEventCallback | OnRequestEventCallback ):
**示例:** **示例:**
```js ```js
pluginComponentManager.on("push", onPushListener) pluginComponentManager.on("push", onPushListener)
pluginComponentManager.on("request", onRequestListener) pluginComponentManager.on("request", onRequestListener)
``` ```
## external.json文件说明 ## external.json文件说明
...@@ -396,3 +395,5 @@ external.json文件由开发者创建。external.json中以键值对形式存放 ...@@ -396,3 +395,5 @@ external.json文件由开发者创建。external.json中以键值对形式存放
"PluginProviderExample": "ets/pages/PluginProviderExample.js", "PluginProviderExample": "ets/pages/PluginProviderExample.js",
"plugintemplate2": "ets/pages/plugintemplate2.js" "plugintemplate2": "ets/pages/plugintemplate2.js"
} }
```
\ No newline at end of file
...@@ -80,7 +80,7 @@ stopWork(work: WorkInfo, needCancel?: boolean): void ...@@ -80,7 +80,7 @@ stopWork(work: WorkInfo, needCancel?: boolean): void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ---------- | --------------------- | ---- | ---------- | | ---------- | --------------------- | ---- | ---------- |
| work | [WorkInfo](#workinfo) | 是 | 指示要停止的工作。 | | work | [WorkInfo](#workinfo) | 是 | 指示要停止的工作。 |
| needCancel | boolean | 是 | 是否需要取消的工作。 | | needCancel | boolean | 否 | 是否需要取消的工作,默认为不取消。 |
**错误码** **错误码**
...@@ -432,7 +432,7 @@ isLastWorkTimeOut(workId: number): Promise\<boolean> ...@@ -432,7 +432,7 @@ isLastWorkTimeOut(workId: number): Promise\<boolean>
| isPersisted | boolean | 否 | 是否持久化保存工作 | | isPersisted | boolean | 否 | 是否持久化保存工作 |
| isDeepIdle | boolean | 否 | 是否要求设备进入空闲状态 | | isDeepIdle | boolean | 否 | 是否要求设备进入空闲状态 |
| idleWaitTime | number | 否 | 空闲等待时间 | | idleWaitTime | number | 否 | 空闲等待时间 |
| parameters | {[key: string]: number | string | boolean} | 否 | 携带参数信息 | | parameters | {[key: string]: number \| string \| boolean} | 否 | 携带参数信息 |
## NetworkType ## NetworkType
触发工作的网络类型。 触发工作的网络类型。
......
...@@ -320,7 +320,7 @@ replaceUrl(options: RouterOptions, mode: RouterMode): Promise&lt;void&gt; ...@@ -320,7 +320,7 @@ replaceUrl(options: RouterOptions, mode: RouterMode): Promise&lt;void&gt;
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| --------- | ------- | | --------- | ------- |
| 100001 | if UI execution context not found, only throw in standard system. | | 100001 | if can not get the delegate, only throw in standard system. |
| 200002 | if the uri is not exist. | | 200002 | if the uri is not exist. |
**示例:** **示例:**
...@@ -362,7 +362,7 @@ replaceUrl(options: RouterOptions, mode: RouterMode, callback: AsyncCallback&lt; ...@@ -362,7 +362,7 @@ replaceUrl(options: RouterOptions, mode: RouterMode, callback: AsyncCallback&lt;
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| --------- | ------- | | --------- | ------- |
| 100001 | if can not get the delegate, only throw in standard system. | | 100001 | if UI execution context not found, only throw in standard system. |
| 200002 | if the uri is not exist. | | 200002 | if the uri is not exist. |
**示例:** **示例:**
...@@ -660,8 +660,8 @@ struct Second { ...@@ -660,8 +660,8 @@ struct Second {
private content: string = "这是第二页" private content: string = "这是第二页"
@State text: string = router.getParams()['text'] @State text: string = router.getParams()['text']
@State data: object = router.getParams()['data'] @State data: object = router.getParams()['data']
@State secondData : string = '' @State secondData: string = ''
build() { build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text(`${this.content}`) Text(`${this.content}`)
...@@ -669,14 +669,14 @@ struct Second { ...@@ -669,14 +669,14 @@ struct Second {
.fontWeight(FontWeight.Bold) .fontWeight(FontWeight.Bold)
Text(this.text) Text(this.text)
.fontSize(30) .fontSize(30)
.onClick(()=>{ .onClick(() => {
this.secondData = (this.data.['array'][1]).toString() this.secondData = (this.data.['array'][1]).toString()
}) })
.margin({top:20}) .margin({ top: 20 })
Text(`第一页传来的数值:${this.secondData}`) Text(`第一页传来的数值:${this.secondData}`)
.fontSize(20) .fontSize(20)
.margin({top:20}) .margin({ top: 20 })
.backgroundColor('red') .backgroundColor('red')
} }
.width('100%') .width('100%')
.height('100%') .height('100%')
...@@ -761,9 +761,9 @@ enableAlertBeforeBackPage(options: EnableAlertOptions): void ...@@ -761,9 +761,9 @@ enableAlertBeforeBackPage(options: EnableAlertOptions): void
**示例:** **示例:**
```js ```js
router.enableAlertBeforeBackPage({ router.enableAlertBeforeBackPage({
message: 'Message Info' message: 'Message Info'
}); });
``` ```
## router.disableAlertBeforeBackPage<sup>(deprecated)</sup> ## router.disableAlertBeforeBackPage<sup>(deprecated)</sup>
......
...@@ -2396,7 +2396,7 @@ readException(): void ...@@ -2396,7 +2396,7 @@ readException(): void
```ts ```ts
// 仅FA模型需要导入@ohos.ability.featureAbility // 仅FA模型需要导入@ohos.ability.featureAbility
// import FA from "@ohos.ability.featureAbility"; // import FA from "@ohos.ability.featureAbility";
let proxy; let proxy;
let connect = { let connect = {
onConnect: function(elementName, remoteProxy) { onConnect: function(elementName, remoteProxy) {
...@@ -2414,10 +2414,10 @@ readException(): void ...@@ -2414,10 +2414,10 @@ readException(): void
"bundleName": "com.ohos.server", "bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility", "abilityName": "com.ohos.server.EntryAbility",
}; };
// FA模型使用此方法连接服务 // FA模型使用此方法连接服务
// FA.connectAbility(want,connect); // FA.connectAbility(want,connect);
globalThis.context.connectServiceExtensionAbility(want, connect); globalThis.context.connectServiceExtensionAbility(want, connect);
``` ```
...@@ -4856,9 +4856,9 @@ readException(): void ...@@ -4856,9 +4856,9 @@ readException(): void
Stage模型的应用在获取服务前需要先获取context,具体方法可参考[获取context](#获取context) Stage模型的应用在获取服务前需要先获取context,具体方法可参考[获取context](#获取context)
```ts ```ts
// 仅FA模型需要导入@ohos.ability.;featureAbility // 仅FA模型需要导入@ohos.ability.featureAbility
// import FA from "@ohos.ability.featureAbility"; // import FA from "@ohos.ability.featureAbility";
let proxy; let proxy;
let connect = { let connect = {
onConnect: function(elementName, remoteProxy) { onConnect: function(elementName, remoteProxy) {
...@@ -4876,10 +4876,10 @@ readException(): void ...@@ -4876,10 +4876,10 @@ readException(): void
"bundleName": "com.ohos.server", "bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility", "abilityName": "com.ohos.server.EntryAbility",
}; };
// FA模型使用此方法连接服务 // FA模型使用此方法连接服务
// FA.connectAbility(want,connect); // FA.connectAbility(want,connect);
globalThis.context.connectServiceExtensionAbility(want, connect); globalThis.context.connectServiceExtensionAbility(want, connect);
``` ```
...@@ -5450,6 +5450,7 @@ marshalling(dataOut: MessageSequence): boolean ...@@ -5450,6 +5450,7 @@ marshalling(dataOut: MessageSequence): boolean
| 类型 | 说明 | | 类型 | 说明 |
| ------- | -------------------------------- | | ------- | -------------------------------- |
| boolean | true:封送成功,false:封送失败。| | boolean | true:封送成功,false:封送失败。|
**示例:** **示例:**
```ts ```ts
...@@ -5555,6 +5556,7 @@ marshalling(dataOut: MessageParcel): boolean ...@@ -5555,6 +5556,7 @@ marshalling(dataOut: MessageParcel): boolean
| 类型 | 说明 | | 类型 | 说明 |
| ------- | -------------------------------- | | ------- | -------------------------------- |
| boolean | true:封送成功,false:封送失败。 | | boolean | true:封送成功,false:封送失败。 |
**示例:** **示例:**
```ts ```ts
...@@ -5671,7 +5673,7 @@ asObject(): IRemoteObject ...@@ -5671,7 +5673,7 @@ asObject(): IRemoteObject
```ts ```ts
// 仅FA模型需要导入@ohos.ability.featureAbility // 仅FA模型需要导入@ohos.ability.featureAbility
// import FA from "@ohos.ability.featureAbility"; // import FA from "@ohos.ability.featureAbility";
let proxy; let proxy;
let connect = { let connect = {
onConnect: function(elementName, remoteProxy) { onConnect: function(elementName, remoteProxy) {
...@@ -5689,10 +5691,10 @@ asObject(): IRemoteObject ...@@ -5689,10 +5691,10 @@ asObject(): IRemoteObject
"bundleName": "com.ohos.server", "bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility", "abilityName": "com.ohos.server.EntryAbility",
}; };
// FA模型使用此方法连接服务 // FA模型使用此方法连接服务
// FA.connectAbility(want,connect); // FA.connectAbility(want,connect);
globalThis.context.connectServiceExtensionAbility(want, connect); globalThis.context.connectServiceExtensionAbility(want, connect);
``` ```
...@@ -6115,7 +6117,7 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me ...@@ -6115,7 +6117,7 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me
```ts ```ts
// 仅FA模型需要导入@ohos.ability.featureAbility // 仅FA模型需要导入@ohos.ability.featureAbility
// import FA from "@ohos.ability.featureAbility"; // import FA from "@ohos.ability.featureAbility";
let proxy; let proxy;
let connect = { let connect = {
onConnect: function(elementName, remoteProxy) { onConnect: function(elementName, remoteProxy) {
...@@ -6133,10 +6135,10 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me ...@@ -6133,10 +6135,10 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me
"bundleName": "com.ohos.server", "bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility", "abilityName": "com.ohos.server.EntryAbility",
}; };
// FA模型使用此方法连接服务 // FA模型使用此方法连接服务
// FA.connectAbility(want,connect); // FA.connectAbility(want,connect);
globalThis.context.connectServiceExtensionAbility(want, connect); globalThis.context.connectServiceExtensionAbility(want, connect);
``` ```
...@@ -6191,7 +6193,7 @@ sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, ...@@ -6191,7 +6193,7 @@ sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence,
```ts ```ts
// 仅FA模型需要导入@ohos.ability.featureAbility // 仅FA模型需要导入@ohos.ability.featureAbility
// import FA from "@ohos.ability.featureAbility"; // import FA from "@ohos.ability.featureAbility";
let proxy; let proxy;
let connect = { let connect = {
onConnect: function(elementName, remoteProxy) { onConnect: function(elementName, remoteProxy) {
...@@ -6209,10 +6211,10 @@ sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, ...@@ -6209,10 +6211,10 @@ sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence,
"bundleName": "com.ohos.server", "bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility", "abilityName": "com.ohos.server.EntryAbility",
}; };
// FA模型使用此方法连接服务 // FA模型使用此方法连接服务
// FA.connectAbility(want,connect); // FA.connectAbility(want,connect);
globalThis.context.connectServiceExtensionAbility(want, connect); globalThis.context.connectServiceExtensionAbility(want, connect);
``` ```
...@@ -6275,7 +6277,7 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me ...@@ -6275,7 +6277,7 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me
```ts ```ts
// 仅FA模型需要导入@ohos.ability.featureAbility // 仅FA模型需要导入@ohos.ability.featureAbility
// import FA from "@ohos.ability.featureAbility"; // import FA from "@ohos.ability.featureAbility";
let proxy; let proxy;
let connect = { let connect = {
onConnect: function(elementName, remoteProxy) { onConnect: function(elementName, remoteProxy) {
...@@ -6293,10 +6295,10 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me ...@@ -6293,10 +6295,10 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me
"bundleName": "com.ohos.server", "bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility", "abilityName": "com.ohos.server.EntryAbility",
}; };
// FA模型使用此方法连接服务 // FA模型使用此方法连接服务
// FA.connectAbility(want,connect); // FA.connectAbility(want,connect);
globalThis.context.connectServiceExtensionAbility(want, connect); globalThis.context.connectServiceExtensionAbility(want, connect);
``` ```
...@@ -6352,7 +6354,7 @@ sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, ...@@ -6352,7 +6354,7 @@ sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence,
```ts ```ts
// 仅FA模型需要导入@ohos.ability.featureAbility // 仅FA模型需要导入@ohos.ability.featureAbility
// import FA from "@ohos.ability.featureAbility"; // import FA from "@ohos.ability.featureAbility";
let proxy; let proxy;
let connect = { let connect = {
onConnect: function(elementName, remoteProxy) { onConnect: function(elementName, remoteProxy) {
...@@ -6383,10 +6385,10 @@ sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, ...@@ -6383,10 +6385,10 @@ sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence,
result.data.reclaim(); result.data.reclaim();
result.reply.reclaim(); result.reply.reclaim();
} }
// FA模型使用此方法连接服务 // FA模型使用此方法连接服务
// FA.connectAbility(want,connect); // FA.connectAbility(want,connect);
globalThis.context.connectServiceExtensionAbility(want, connect); globalThis.context.connectServiceExtensionAbility(want, connect);
``` ```
...@@ -6433,7 +6435,7 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me ...@@ -6433,7 +6435,7 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me
```ts ```ts
// 仅FA模型需要导入@ohos.ability.featureAbility // 仅FA模型需要导入@ohos.ability.featureAbility
// import FA from "@ohos.ability.featureAbility"; // import FA from "@ohos.ability.featureAbility";
let proxy; let proxy;
let connect = { let connect = {
onConnect: function(elementName, remoteProxy) { onConnect: function(elementName, remoteProxy) {
...@@ -6464,10 +6466,10 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me ...@@ -6464,10 +6466,10 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me
result.data.reclaim(); result.data.reclaim();
result.reply.reclaim(); result.reply.reclaim();
} }
// FA模型使用此方法连接服务 // FA模型使用此方法连接服务
// FA.connectAbility(want,connect); // FA.connectAbility(want,connect);
globalThis.context.connectServiceExtensionAbility(want, connect); globalThis.context.connectServiceExtensionAbility(want, connect);
``` ```
...@@ -6517,7 +6519,7 @@ getLocalInterface(interface: string): IRemoteBroker ...@@ -6517,7 +6519,7 @@ getLocalInterface(interface: string): IRemoteBroker
```ts ```ts
// 仅FA模型需要导入@ohos.ability.featureAbility // 仅FA模型需要导入@ohos.ability.featureAbility
// import FA from "@ohos.ability.featureAbility"; // import FA from "@ohos.ability.featureAbility";
let proxy; let proxy;
let connect = { let connect = {
onConnect: function(elementName, remoteProxy) { onConnect: function(elementName, remoteProxy) {
...@@ -6535,10 +6537,10 @@ getLocalInterface(interface: string): IRemoteBroker ...@@ -6535,10 +6537,10 @@ getLocalInterface(interface: string): IRemoteBroker
"bundleName": "com.ohos.server", "bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility", "abilityName": "com.ohos.server.EntryAbility",
}; };
// FA模型使用此方法连接服务 // FA模型使用此方法连接服务
// FA.connectAbility(want,connect); // FA.connectAbility(want,connect);
globalThis.context.connectServiceExtensionAbility(want, connect); globalThis.context.connectServiceExtensionAbility(want, connect);
``` ```
...@@ -6583,7 +6585,7 @@ queryLocalInterface(interface: string): IRemoteBroker ...@@ -6583,7 +6585,7 @@ queryLocalInterface(interface: string): IRemoteBroker
```ts ```ts
// 仅FA模型需要导入@ohos.ability.featureAbility // 仅FA模型需要导入@ohos.ability.featureAbility
// import FA from "@ohos.ability.featureAbility"; // import FA from "@ohos.ability.featureAbility";
let proxy; let proxy;
let connect = { let connect = {
onConnect: function(elementName, remoteProxy) { onConnect: function(elementName, remoteProxy) {
...@@ -6601,10 +6603,10 @@ queryLocalInterface(interface: string): IRemoteBroker ...@@ -6601,10 +6603,10 @@ queryLocalInterface(interface: string): IRemoteBroker
"bundleName": "com.ohos.server", "bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility", "abilityName": "com.ohos.server.EntryAbility",
}; };
// FA模型使用此方法连接服务 // FA模型使用此方法连接服务
// FA.connectAbility(want,connect); // FA.connectAbility(want,connect);
globalThis.context.connectServiceExtensionAbility(want, connect); globalThis.context.connectServiceExtensionAbility(want, connect);
``` ```
...@@ -6645,7 +6647,7 @@ registerDeathRecipient(recipient: DeathRecipient, flags: number): void ...@@ -6645,7 +6647,7 @@ registerDeathRecipient(recipient: DeathRecipient, flags: number): void
```ts ```ts
// 仅FA模型需要导入@ohos.ability.featureAbility // 仅FA模型需要导入@ohos.ability.featureAbility
// import FA from "@ohos.ability.featureAbility"; // import FA from "@ohos.ability.featureAbility";
let proxy; let proxy;
let connect = { let connect = {
onConnect: function(elementName, remoteProxy) { onConnect: function(elementName, remoteProxy) {
...@@ -6663,10 +6665,10 @@ registerDeathRecipient(recipient: DeathRecipient, flags: number): void ...@@ -6663,10 +6665,10 @@ registerDeathRecipient(recipient: DeathRecipient, flags: number): void
"bundleName": "com.ohos.server", "bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility", "abilityName": "com.ohos.server.EntryAbility",
}; };
// FA模型使用此方法连接服务 // FA模型使用此方法连接服务
// FA.connectAbility(want,connect); // FA.connectAbility(want,connect);
globalThis.context.connectServiceExtensionAbility(want, connect); globalThis.context.connectServiceExtensionAbility(want, connect);
``` ```
...@@ -6717,7 +6719,7 @@ addDeathRecipient(recipient: DeathRecipient, flags: number): boolean ...@@ -6717,7 +6719,7 @@ addDeathRecipient(recipient: DeathRecipient, flags: number): boolean
```ts ```ts
// 仅FA模型需要导入@ohos.ability.featureAbility // 仅FA模型需要导入@ohos.ability.featureAbility
// import FA from "@ohos.ability.featureAbility"; // import FA from "@ohos.ability.featureAbility";
let proxy; let proxy;
let connect = { let connect = {
onConnect: function(elementName, remoteProxy) { onConnect: function(elementName, remoteProxy) {
...@@ -6735,10 +6737,10 @@ addDeathRecipient(recipient: DeathRecipient, flags: number): boolean ...@@ -6735,10 +6737,10 @@ addDeathRecipient(recipient: DeathRecipient, flags: number): boolean
"bundleName": "com.ohos.server", "bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility", "abilityName": "com.ohos.server.EntryAbility",
}; };
// FA模型使用此方法连接服务 // FA模型使用此方法连接服务
// FA.connectAbility(want,connect); // FA.connectAbility(want,connect);
globalThis.context.connectServiceExtensionAbility(want, connect); globalThis.context.connectServiceExtensionAbility(want, connect);
``` ```
...@@ -6784,7 +6786,7 @@ unregisterDeathRecipient(recipient: DeathRecipient, flags: number): void ...@@ -6784,7 +6786,7 @@ unregisterDeathRecipient(recipient: DeathRecipient, flags: number): void
```ts ```ts
// 仅FA模型需要导入@ohos.ability.featureAbility // 仅FA模型需要导入@ohos.ability.featureAbility
// import FA from "@ohos.ability.featureAbility"; // import FA from "@ohos.ability.featureAbility";
let proxy; let proxy;
let connect = { let connect = {
onConnect: function(elementName, remoteProxy) { onConnect: function(elementName, remoteProxy) {
...@@ -6802,10 +6804,10 @@ unregisterDeathRecipient(recipient: DeathRecipient, flags: number): void ...@@ -6802,10 +6804,10 @@ unregisterDeathRecipient(recipient: DeathRecipient, flags: number): void
"bundleName": "com.ohos.server", "bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility", "abilityName": "com.ohos.server.EntryAbility",
}; };
// FA模型使用此方法连接服务 // FA模型使用此方法连接服务
// FA.connectAbility(want,connect); // FA.connectAbility(want,connect);
globalThis.context.connectServiceExtensionAbility(want, connect); globalThis.context.connectServiceExtensionAbility(want, connect);
``` ```
...@@ -6857,7 +6859,7 @@ removeDeathRecipient(recipient: DeathRecipient, flags: number): boolean ...@@ -6857,7 +6859,7 @@ removeDeathRecipient(recipient: DeathRecipient, flags: number): boolean
```ts ```ts
// 仅FA模型需要导入@ohos.ability.featureAbility // 仅FA模型需要导入@ohos.ability.featureAbility
// import FA from "@ohos.ability.featureAbility"; // import FA from "@ohos.ability.featureAbility";
let proxy; let proxy;
let connect = { let connect = {
onConnect: function(elementName, remoteProxy) { onConnect: function(elementName, remoteProxy) {
...@@ -6875,10 +6877,10 @@ removeDeathRecipient(recipient: DeathRecipient, flags: number): boolean ...@@ -6875,10 +6877,10 @@ removeDeathRecipient(recipient: DeathRecipient, flags: number): boolean
"bundleName": "com.ohos.server", "bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility", "abilityName": "com.ohos.server.EntryAbility",
}; };
// FA模型使用此方法连接服务 // FA模型使用此方法连接服务
// FA.connectAbility(want,connect); // FA.connectAbility(want,connect);
globalThis.context.connectServiceExtensionAbility(want, connect); globalThis.context.connectServiceExtensionAbility(want, connect);
``` ```
...@@ -6925,7 +6927,7 @@ getDescriptor(): string ...@@ -6925,7 +6927,7 @@ getDescriptor(): string
```ts ```ts
// 仅FA模型需要导入@ohos.ability.featureAbility // 仅FA模型需要导入@ohos.ability.featureAbility
// import FA from "@ohos.ability.featureAbility"; // import FA from "@ohos.ability.featureAbility";
let proxy; let proxy;
let connect = { let connect = {
onConnect: function(elementName, remoteProxy) { onConnect: function(elementName, remoteProxy) {
...@@ -6943,10 +6945,10 @@ getDescriptor(): string ...@@ -6943,10 +6945,10 @@ getDescriptor(): string
"bundleName": "com.ohos.server", "bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility", "abilityName": "com.ohos.server.EntryAbility",
}; };
// FA模型使用此方法连接服务 // FA模型使用此方法连接服务
// FA.connectAbility(want,connect); // FA.connectAbility(want,connect);
globalThis.context.connectServiceExtensionAbility(want, connect); globalThis.context.connectServiceExtensionAbility(want, connect);
``` ```
上述onConnect回调函数中的proxy对象需要等ability异步连接成功后才会被赋值,然后才可调用proxy对象的getDescriptor接口方法获取对象的接口描述符 上述onConnect回调函数中的proxy对象需要等ability异步连接成功后才会被赋值,然后才可调用proxy对象的getDescriptor接口方法获取对象的接口描述符
...@@ -6984,7 +6986,7 @@ getInterfaceDescriptor(): string ...@@ -6984,7 +6986,7 @@ getInterfaceDescriptor(): string
```ts ```ts
// 仅FA模型需要导入@ohos.ability.featureAbility // 仅FA模型需要导入@ohos.ability.featureAbility
// import FA from "@ohos.ability.featureAbility"; // import FA from "@ohos.ability.featureAbility";
let proxy; let proxy;
let connect = { let connect = {
onConnect: function(elementName, remoteProxy) { onConnect: function(elementName, remoteProxy) {
...@@ -7002,10 +7004,10 @@ getInterfaceDescriptor(): string ...@@ -7002,10 +7004,10 @@ getInterfaceDescriptor(): string
"bundleName": "com.ohos.server", "bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility", "abilityName": "com.ohos.server.EntryAbility",
}; };
// FA模型使用此方法连接服务 // FA模型使用此方法连接服务
// FA.connectAbility(want,connect); // FA.connectAbility(want,connect);
globalThis.context.connectServiceExtensionAbility(want, connect); globalThis.context.connectServiceExtensionAbility(want, connect);
``` ```
...@@ -7037,7 +7039,7 @@ isObjectDead(): boolean ...@@ -7037,7 +7039,7 @@ isObjectDead(): boolean
```ts ```ts
// 仅FA模型需要导入@ohos.ability.featureAbility // 仅FA模型需要导入@ohos.ability.featureAbility
// import FA from "@ohos.ability.featureAbility"; // import FA from "@ohos.ability.featureAbility";
let proxy; let proxy;
let connect = { let connect = {
onConnect: function(elementName, remoteProxy) { onConnect: function(elementName, remoteProxy) {
...@@ -7055,10 +7057,10 @@ isObjectDead(): boolean ...@@ -7055,10 +7057,10 @@ isObjectDead(): boolean
"bundleName": "com.ohos.server", "bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility", "abilityName": "com.ohos.server.EntryAbility",
}; };
// FA模型使用此方法连接服务 // FA模型使用此方法连接服务
// FA.connectAbility(want,connect); // FA.connectAbility(want,connect);
globalThis.context.connectServiceExtensionAbility(want, connect); globalThis.context.connectServiceExtensionAbility(want, connect);
``` ```
...@@ -7093,9 +7095,9 @@ MessageOption构造函数。 ...@@ -7093,9 +7095,9 @@ MessageOption构造函数。
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| --------- | ------ | ---- | -------------------------------------- | | ------ | ------- | ---- | -------------------------------------- |
| syncFlags | number | 否 | 同步调用或异步调用标志。默认同步调用。 | | async | boolean | 否 | 同步调用或异步调用标志。默认同步调用。 |
**示例:** **示例:**
...@@ -7823,7 +7825,7 @@ sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, ...@@ -7823,7 +7825,7 @@ sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence,
| 类型 | 说明 | | 类型 | 说明 |
| ---------------------------- | --------------------------------------------- | | ---------------------------- | --------------------------------------------- |
| Promise&lt;RequestResult&gt; | 返回一个期约,兑现值是sendRequestResult实例。 | | Promise&lt;RequestResult&gt; | 返回一个期约,兑现值是RequestResult实例。 |
**示例:** **示例:**
...@@ -9099,30 +9101,31 @@ readFromAshmem(size: number, offset: number): number[] ...@@ -9099,30 +9101,31 @@ readFromAshmem(size: number, offset: number): number[]
```ts ```ts
import Ability from '@ohos.app.ability.UIAbility'; import Ability from '@ohos.app.ability.UIAbility';
export default class MainAbility extends Ability { export default class MainAbility extends Ability {
onCreate(want, launchParam) { onCreate(want, launchParam) {
console.log("[Demo] MainAbility onCreate"); console.log("[Demo] MainAbility onCreate");
globalThis.context = this.context; globalThis.context = this.context;
} }
onDestroy() { onDestroy() {
console.log("[Demo] MainAbility onDestroy"); console.log("[Demo] MainAbility onDestroy");
} }
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability // Main window is created, set main page for this ability
console.log("[Demo] MainAbility onWindowStageCreate"); console.log("[Demo] MainAbility onWindowStageCreate");
} }
onWindowStageDestroy() { onWindowStageDestroy() {
// Main window is destroyed, release UI related resources // Main window is destroyed, release UI related resources
console.log("[Demo] MainAbility onWindowStageDestroy"); console.log("[Demo] MainAbility onWindowStageDestroy");
} }
onForeground() { onForeground() {
// Ability has brought to foreground // Ability has brought to foreground
console.log("[Demo] MainAbility onForeground"); console.log("[Demo] MainAbility onForeground");
} }
onBackground() { onBackground() {
// Ability has back to background // Ability has back to background
console.log("[Demo] MainAbility onBackground"); console.log("[Demo] MainAbility onBackground");
} }
}; };
``` ```
...@@ -123,7 +123,7 @@ off(activity: ActivityType, event: ActivityEvent, callback?: Callback&lt;Activit ...@@ -123,7 +123,7 @@ off(activity: ActivityType, event: ActivityEvent, callback?: Callback&lt;Activit
| -------------------- | -------------------------------------------------- | ---- | ---------------------------- | | -------------------- | -------------------------------------------------- | ---- | ---------------------------- |
| activity | [ActivityType](#activitytype) | 是 | 设备状态能力类型。 | | activity | [ActivityType](#activitytype) | 是 | 设备状态能力类型。 |
| event | [ActivityEvent](#activityevent) | 是 | 事件类型。 | | event | [ActivityEvent](#activityevent) | 是 | 事件类型。 |
| callback | Callback<[ActivityResponse](#activityresponse)\> | 否 | 回调函数,接收上报状态变化事件。 | | callback | Callback<[ActivityResponse](#activityresponse)\> | 否 | 回调函数,接收上报状态变化事件,如果没有传递callback参数,会移除该进程下订阅该类型得所有callback。 |
**示例:** **示例:**
......
...@@ -341,8 +341,8 @@ export default { ...@@ -341,8 +341,8 @@ export default {
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| ------ | -------- | ---- | ------------------------------------------------------------ | | ------ | -------- | ---- | ------------------------------------------------------------ |
| uri | string | 是 | 目标页面的uri,可以是以下的两种格式:<br/>1. 页面的绝对路径,由config.json文件中的页面列表提供。例如:<br/>- pages/index/index<br/> -pages/detail/detail<br/>2. 特定路径。如果URI为斜杠(/),则显示主页。 | | uri<sup>7+</sup> | string | 是 | 目标页面的uri,可以是以下的两种格式:<br/>1. 页面的绝对路径,由config.json文件中的页面列表提供。例如:<br/>- pages/index/index<br/> -pages/detail/detail<br/>2. 特定路径。如果URI为斜杠(/),则显示主页。 |
| params | object | 否 | 表示路由跳转时要同时传递到目标页面的数据。跳转到目标页面后,使用router.getParams()获取传递的参数,此外,在类web范式中,参数也可以在页面中直接使用,如this.keyValue(keyValue为跳转时params参数中的key值),如果目标页面中已有该字段,则其值会被传入的字段值覆盖。 | | params<sup>7+</sup> | object | 否 | 表示路由跳转时要同时传递到目标页面的数据。跳转到目标页面后,使用router.getParams()获取传递的参数,此外,在类web范式中,参数也可以在页面中直接使用,如this.keyValue(keyValue为跳转时params参数中的key值),如果目标页面中已有该字段,则其值会被传入的字段值覆盖。 |
## BackRouterOptions ## BackRouterOptions
...@@ -353,8 +353,8 @@ export default { ...@@ -353,8 +353,8 @@ export default {
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| ------ | -------- | ---- | ------------------------------------------------------------ | | ------ | -------- | ---- | ------------------------------------------------------------ |
| uri | string | 否 | 返回到指定uri的界面,如果页面栈上没有uri页面,则不响应该情况。如果uri未设置,则返回上一页。 <br>**系统能力:** SystemCapability.ArkUI.ArkUI.Full | | uri<sup>7+</sup> | string | 否 | 返回到指定uri的界面,如果页面栈上没有uri页面,则不响应该情况。如果uri未设置,则返回上一页。 <br>**系统能力:** SystemCapability.ArkUI.ArkUI.Full |
| params | object | 否 | 跳转时要同时传递到目标页面的数据。 <br>**系统能力:** SystemCapability.ArkUI.ArkUI.Lite | | params<sup>7+</sup> | object | 否 | 跳转时要同时传递到目标页面的数据。 <br>**系统能力:** SystemCapability.ArkUI.ArkUI.Lite |
## RouterState ## RouterState
......
...@@ -11,7 +11,7 @@ URI权限管理模块。用于应用A授权/撤销授权URI给应用B ...@@ -11,7 +11,7 @@ URI权限管理模块。用于应用A授权/撤销授权URI给应用B
```js ```js
import UriPermissionManager from '@ohos.application.uriPermissionManager'; import uriPermissionManager from '@ohos.application.uriPermissionManager';
``` ```
......
...@@ -209,8 +209,8 @@ removeRight(deviceName: string): boolean ...@@ -209,8 +209,8 @@ removeRight(deviceName: string): boolean
**示例:** **示例:**
```js ```js
let devicesName="1-1"; let devicesName= "1-1";
if usb.removeRight(devicesName) { if (usb.removeRight(devicesName)) {
console.log(`Succeed in removing right`); console.log(`Succeed in removing right`);
} }
``` ```
...@@ -245,7 +245,7 @@ addRight(bundleName: string, deviceName: string): boolean ...@@ -245,7 +245,7 @@ addRight(bundleName: string, deviceName: string): boolean
```js ```js
let devicesName = "1-1"; let devicesName = "1-1";
let bundleName = "com.example.hello"; let bundleName = "com.example.hello";
if usb.addRight(bundleName, devicesName) { if (usb.addRight(bundleName, devicesName)) {
console.log(`Succeed in adding right`); console.log(`Succeed in adding right`);
} }
``` ```
...@@ -454,7 +454,14 @@ controlTransfer(pipe: USBDevicePipe, controlparam: USBControlParams, timeout ?: ...@@ -454,7 +454,14 @@ controlTransfer(pipe: USBDevicePipe, controlparam: USBControlParams, timeout ?:
**示例:** **示例:**
```js ```js
let param = new usb.USBControlParams(); let param = {
request: 0,
reqType: 0,
target:0,
value: 0,
index: 0,
data: null
};
usb.controlTransfer(devicepipe, param).then((ret) => { usb.controlTransfer(devicepipe, param).then((ret) => {
console.log(`controlTransfer = ${ret}`); console.log(`controlTransfer = ${ret}`);
}) })
...@@ -579,7 +586,7 @@ usbFunctionsToString(funcs: FunctionType): string ...@@ -579,7 +586,7 @@ usbFunctionsToString(funcs: FunctionType): string
**示例:** **示例:**
```js ```js
let funcs = usb.ACM | usb.ECM; let funcs = usb.FunctionType.ACM | usb.FunctionType.ECM;
let ret = usb.usbFunctionsToString(funcs); let ret = usb.usbFunctionsToString(funcs);
``` ```
...@@ -608,7 +615,7 @@ setCurrentFunctions(funcs: FunctionType): Promise\<void\> ...@@ -608,7 +615,7 @@ setCurrentFunctions(funcs: FunctionType): Promise\<void\>
**示例:** **示例:**
```js ```js
let funcs = usb.HDC; let funcs = usb.FunctionType.HDC;
usb.setCurrentFunctions(funcs).then(() => { usb.setCurrentFunctions(funcs).then(() => {
console.info('usb setCurrentFunctions successfully.'); console.info('usb setCurrentFunctions successfully.');
}).catch(err => { }).catch(err => {
......
...@@ -20,6 +20,8 @@ getWant(agent: WantAgent, callback: AsyncCallback\<Want\>): void ...@@ -20,6 +20,8 @@ getWant(agent: WantAgent, callback: AsyncCallback\<Want\>): void
**系统能力**:SystemCapability.Ability.AbilityRuntime.Core **系统能力**:SystemCapability.Ability.AbilityRuntime.Core
**系统API**:该接口为系统接口,三方应用不支持调用。
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
...@@ -91,6 +93,8 @@ getWant(agent: WantAgent): Promise\<Want\> ...@@ -91,6 +93,8 @@ getWant(agent: WantAgent): Promise\<Want\>
**系统能力**:SystemCapability.Ability.AbilityRuntime.Core **系统能力**:SystemCapability.Ability.AbilityRuntime.Core
**系统API**:该接口为系统接口,三方应用不支持调用。
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
......
...@@ -2037,7 +2037,7 @@ createWebMessagePorts(isExtentionType?: boolean): Array\<WebMessagePort> ...@@ -2037,7 +2037,7 @@ createWebMessagePorts(isExtentionType?: boolean): Array\<WebMessagePort>
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ---------------------- | ---- | :------------------------------| | ------ | ---------------------- | ---- | :------------------------------|
| isExtentionType<sup>10+</sup> | boolean | 否 | 是否使用扩展增强接口,默认false不使用。 | | isExtentionType<sup>10+</sup> | boolean | 否 | 是否使用扩展增强接口,默认false不使用。 从API version 10开始,该接口支持此参数。|
**返回值:** **返回值:**
......
# Blank # Blank
空白填充组件,在容器主轴方向上,空白填充组件具有自动填充容器空余部分的能力。仅当父组件为Row/Column时生效。 空白填充组件,在容器主轴方向上,空白填充组件具有自动填充容器空余部分的能力。仅当父组件为Row/Column/Flex时生效。
> **说明:** > **说明:**
> >
......
...@@ -105,7 +105,7 @@ struct ClipAndMaskExample { ...@@ -105,7 +105,7 @@ struct ClipAndMaskExample {
```ts ```ts
@Entry @Entry
@Component @Component
struct ProgressMask { struct ProgressMaskExample {
@State progressflag1: boolean = true; @State progressflag1: boolean = true;
@State color: Color = 0x01006CDE; @State color: Color = 0x01006CDE;
@State value: number = 10.0; @State value: number = 10.0;
......
...@@ -17,10 +17,19 @@ ...@@ -17,10 +17,19 @@
| size | {<br/>width?:&nbsp;[Length](ts-types.md#length),<br/>height?:&nbsp;[Length](ts-types.md#length)<br/>} | 设置高宽尺寸。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。<br />从API version 10开始,该接口支持calc计算特性。 | | size | {<br/>width?:&nbsp;[Length](ts-types.md#length),<br/>height?:&nbsp;[Length](ts-types.md#length)<br/>} | 设置高宽尺寸。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。<br />从API version 10开始,该接口支持calc计算特性。 |
| padding | [Padding](ts-types.md#padding)&nbsp;\|&nbsp;[Length](ts-types.md#length) | 设置内边距属性。<br/>参数为Length类型时,四个方向内边距同时生效。<br>默认值:0 <br>padding设置百分比时,上下左右内边距均以父容器的width作为基础值。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。<br />从API version 10开始,该接口支持calc计算特性。 | | padding | [Padding](ts-types.md#padding)&nbsp;\|&nbsp;[Length](ts-types.md#length) | 设置内边距属性。<br/>参数为Length类型时,四个方向内边距同时生效。<br>默认值:0 <br>padding设置百分比时,上下左右内边距均以父容器的width作为基础值。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。<br />从API version 10开始,该接口支持calc计算特性。 |
| margin | [Margin](ts-types.md#margin)&nbsp;\|&nbsp;[Length](ts-types.md#length) | 设置外边距属性。<br/>参数为Length类型时,四个方向外边距同时生效。<br>默认值:0 <br>margin设置百分比时,上下左右外边距均以父容器的width作为基础值。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。<br />从API version 10开始,该接口支持calc计算特性。 | | margin | [Margin](ts-types.md#margin)&nbsp;\|&nbsp;[Length](ts-types.md#length) | 设置外边距属性。<br/>参数为Length类型时,四个方向外边距同时生效。<br>默认值:0 <br>margin设置百分比时,上下左右外边距均以父容器的width作为基础值。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。<br />从API version 10开始,该接口支持calc计算特性。 |
| constraintSize | {<br/>minWidth?:&nbsp;[Length](ts-types.md#length),<br/>maxWidth?:&nbsp;[Length](ts-types.md#length),<br/>minHeight?:&nbsp;[Length](ts-types.md#length),<br/>maxHeight?:&nbsp;[Length](ts-types.md#length)<br/>} | 设置约束尺寸,组件布局时,进行尺寸范围限制。constraintSize的优先级高于Width和Height。若设置的minWidth大于maxWidth,则minWidth生效,minHeight与maxHeight同理<br>默认值:<br>{<br/>minWidth:&nbsp;0,<br/>maxWidth:&nbsp;Infinity,<br/>minHeight:&nbsp;0,<br/>maxHeight:&nbsp;Infinity<br/>}<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。<br />从API version 10开始,该接口支持calc计算特性。 | | constraintSize | {<br/>minWidth?:&nbsp;[Length](ts-types.md#length),<br/>maxWidth?:&nbsp;[Length](ts-types.md#length),<br/>minHeight?:&nbsp;[Length](ts-types.md#length),<br/>maxHeight?:&nbsp;[Length](ts-types.md#length)<br/>} | 设置约束尺寸,组件布局时,进行尺寸范围限制。constraintSize的优先级高于Width和Height。取值结果[参考](ts-universal-attributes-size.md##constraintSize取值对width/height影响)<br>默认值:<br>{<br/>minWidth:&nbsp;0,<br/>maxWidth:&nbsp;Infinity,<br/>minHeight:&nbsp;0,<br/>maxHeight:&nbsp;Infinity<br/>}<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。<br />从API version 10开始,该接口支持calc计算特性。 |
| layoutWeight | number&nbsp;\|&nbsp;string | 父容器尺寸确定时,设置了layoutWeight属性的子元素与兄弟元素占主轴尺寸按照权重进行分配,忽略元素本身尺寸设置,表示自适应占满剩余空间。<br>默认值:0<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。<br/>**说明:**<br/>仅在Row/Column/Flex布局中生效。<br/>可选值为大于等于0的数字,或者可以转换为数字的字符串。 | | layoutWeight | number&nbsp;\|&nbsp;string | 父容器尺寸确定时,设置了layoutWeight属性的子元素与兄弟元素占主轴尺寸按照权重进行分配,忽略元素本身尺寸设置,表示自适应占满剩余空间。<br>默认值:0<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。<br/>**说明:**<br/>仅在Row/Column/Flex布局中生效。<br/>可选值为大于等于0的数字,或者可以转换为数字的字符串。 |
## constraintSize取值对width/height影响
|大小排列|结果|
|-----|------|
|minWidth/minHeight < width/height< maxWidth/maxHeight|width/height|
|minWidth/minHeight < maxWidth/maxHeight < width/height| maxWidth/maxHeight|
|maxWidth/maxHeight < minWidth/minHeight < width/height| minWidth/minHeight|
|maxWidth/maxHeight < width/height< minWidth/minHeight| minWidth/minHeight|
|width/height < maxWidth/maxHeight < minWidth/minHeight| minWidth/minHeight|
|width/height < minWidth/minHeight < maxWidth/maxHeight| minWidth/minHeight|
## 示例 ## 示例
```ts ```ts
......
...@@ -583,6 +583,24 @@ The specified mission listener does not exist. ...@@ -583,6 +583,24 @@ The specified mission listener does not exist.
确认操作的任务监听器是否存在。 确认操作的任务监听器是否存在。
## 16300003 目标应用程序不是自身应用程序
**错误信息**
The target application is not self application.
**错误描述**
当被拉起的应用程序不是自身应用程序时,方法将返回该错误码。
**可能原因**
被拉起的应用和发起调用的应用不是同一个应用程序。
**处理步骤**
确认被拉起的应用程序是否为自身应用程序。
## 18500001 指定的包名无效 ## 18500001 指定的包名无效
**错误信息** **错误信息**
......
...@@ -1013,14 +1013,6 @@ TS/JS语言基础库 ...@@ -1013,14 +1013,6 @@ TS/JS语言基础库
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | | ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
| 是 | 否 | 是 | 是 | 否 | 是 | 否 | 否 | | 是 | 否 | 是 | 是 | 否 | 是 | 否 | 否 |
## SystemCapability.UserIAM.UserAuth.FingerprintAuth
指纹认证
| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router |
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
| 是 | 否 | 否 | 是 | 否 | 否 | 否 | 否 |
## SystemCapability.MiscServices.InputMethodFramework ## SystemCapability.MiscServices.InputMethodFramework
输入法框架 输入法框架
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
开发者若使用低性能的代码实现功能场景可能不会影响应用的正常运行,但却会对应用的性能造成负面影响。本章节列举出了一些可提升性能的场景供开发者参考,以避免应用实现上带来的性能劣化。 开发者若使用低性能的代码实现功能场景可能不会影响应用的正常运行,但却会对应用的性能造成负面影响。本章节列举出了一些可提升性能的场景供开发者参考,以避免应用实现上带来的性能劣化。
## 推荐使用数据懒加载 ## 使用数据懒加载
开发者在使用长列表时,如果直接采用循环渲染方式,如下所示,会一次性加载所有的列表元素,一方面会导致页面启动时间过长,影响用户体验,另一方面也会增加服务器的压力和流量,加重系统负担。 开发者在使用长列表时,如果直接采用循环渲染方式,如下所示,会一次性加载所有的列表元素,一方面会导致页面启动时间过长,影响用户体验,另一方面也会增加服务器的压力和流量,加重系统负担。
......
...@@ -26,8 +26,7 @@ ...@@ -26,8 +26,7 @@
| -------- | | -------- |
| ![阿斯顿](figures/阿斯顿.png) | | ![阿斯顿](figures/阿斯顿.png) |
有关时间选择器的软件实现,请参阅详见... 有关时间选择器的软件实现,请参阅[“TimePicker”](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-timepicker.md)
## 日期选择器 ## 日期选择器
...@@ -39,7 +38,7 @@ ...@@ -39,7 +38,7 @@
- 操作区:操作为“取消”、“确定”。 - 操作区:操作为“取消”、“确定”。
![v的v分](figures/v的v分.png) ![v的v分](figures/v的v分.png)
有关日期选择器的软件实现,请参阅datapicker 有关日期选择器的软件实现,请参阅[“DatePicker”](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-datepicker.md)
## 资源 ## 资源
......
...@@ -17,16 +17,16 @@ ...@@ -17,16 +17,16 @@
| 名称 | 描述 | | 名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| [streamId_](#streamid) | 流的ID,用于在设备内唯一标识一条流。 | | [streamId_](#streamid_) | 流的ID,用于在设备内唯一标识一条流。 |
| [width_](#width) | 图像宽度。 | | [width_](#width_) | 图像宽度。 |
| [height_](#height) | 图像高度。 | | [height_](#height_) | 图像高度。 |
| [format_](#format) | 图像格式。 | | [format_](#format_) | 图像格式。 |
| [dataspace_](#dataspace) | 图像颜色空间。 | | [dataspace_](#dataspace_) | 图像颜色空间。 |
| [intent_](#intent) | 流类型。 | | [intent_](#intent_) | 流类型。 |
| [tunneledMode_](#tunneledmode) | 隧道模式,值为true时开启,false关闭。 | | [tunneledMode_](#tunneledmode_) | 隧道模式,值为true时开启,false关闭。 |
| [bufferQueue_](#bufferqueue) | 图形提供的生产者句柄。 | | [bufferQueue_](#bufferqueue_) | 图形提供的生产者句柄。 |
| [minFrameDuration_](#minframeduration) | 最小帧间隔。 | | [minFrameDuration_](#minframeduration_) | 最小帧间隔。 |
| [encodeType_](#encodetype) | 编码类型。 | | [encodeType_](#encodetype_) | 编码类型。 |
## **类成员变量说明** ## **类成员变量说明**
......
...@@ -4,7 +4,9 @@ ...@@ -4,7 +4,9 @@
OpenHarmony提供通用的应用特权和可由设备厂商针对不同设备单独配置的应用特权。当签名证书中配置的特权与白名单(install_list_capability.json)中特权相同时,以白名单的配置为主。 OpenHarmony提供通用的应用特权和可由设备厂商针对不同设备单独配置的应用特权。当签名证书中配置的特权与白名单(install_list_capability.json)中特权相同时,以白名单的配置为主。
> 说明:应当注意不要滥用应用特权,避免造成用户反感甚至对用户造成侵权。 > **说明:**
> - 应当注意不要滥用应用特权,避免造成用户反感甚至对用户造成侵权。
> - 直接修改应用Profile文件的方式,仅用于应用/服务调试阶段使用,不可用于发布上架应用市场。如果需要开发商用版本的应用,请在对应的应用市场进行发布证书和Profile文件的申请。
## 通用应用特权 ## 通用应用特权
......
...@@ -81,10 +81,6 @@ C HiSysEvent查询开发能力如下:具体API详见接口目录(/base/hivie ...@@ -81,10 +81,6 @@ C HiSysEvent查询开发能力如下:具体API详见接口目录(/base/hivie
"and":[ "and":[
{"param":"type_","op":">","value":0}, {"param":"type_","op":">","value":0},
{"param":"uid_","op":"=","value":1201} {"param":"uid_","op":"=","value":1201}
],
"or":[
{"param":"NAME","op":"=","value":"SysEventService"},
{"param":"NAME","op":"=","value":"SysEventSource"}
] ]
} }
} }
...@@ -93,7 +89,6 @@ C HiSysEvent查询开发能力如下:具体API详见接口目录(/base/hivie ...@@ -93,7 +89,6 @@ C HiSysEvent查询开发能力如下:具体API详见接口目录(/base/hivie
- version字段是必选字段,表示传入条件的支持版本,当前只支持V1版本。 - version字段是必选字段,表示传入条件的支持版本,当前只支持V1版本。
- condition字段是必选字段,表示传入条件的具体内容。 - condition字段是必选字段,表示传入条件的具体内容。
- and字段是可选字段,表示条件之间是与的关系。 - and字段是可选字段,表示条件之间是与的关系。
- or字段是可选字段,表示条件之间是或的关系。
- param字段是必选字段,表示条件匹配的参数名称,必须为字符串类型。 - param字段是必选字段,表示条件匹配的参数名称,必须为字符串类型。
- op字段是必选字段,表示条件匹配的参数比较符,必须为字符串类型,支持的比较符包括=、>、<>=、<=。 - op字段是必选字段,表示条件匹配的参数比较符,必须为字符串类型,支持的比较符包括=、>、<>=、<=。
- value字段是必选字段,表示条件匹配的参数值,必须为字符串类型或整型。 - value字段是必选字段,表示条件匹配的参数值,必须为字符串类型或整型。
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册