提交 c7c15466 编写于 作者: W wuzhihuitmac

Merge branch 'master' of gitee.com:openharmony/docs into wzh

Change-Id: If3f7866f92bec0216f759ff39040d2e93dcf143f
...@@ -314,6 +314,8 @@ Stops synchronizing the remote mission list. This API uses a promise to return t ...@@ -314,6 +314,8 @@ Stops synchronizing the remote mission list. This API uses a promise to return t
Defines the callbacks that can be registered as a mission status listener. Defines the callbacks that can be registered as a mission status listener.
**Required permissions**: ohos.permission.MANAGE_MISSIONS
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission **System capability**: SystemCapability.Ability.AbilityRuntime.Mission
| Name | Type | Readable | Writable | Description | | Name | Type | Readable | Writable | Description |
...@@ -326,6 +328,8 @@ Defines the callbacks that can be registered as a mission status listener. ...@@ -326,6 +328,8 @@ Defines the callbacks that can be registered as a mission status listener.
Defines the parameters required for mission synchronization. Defines the parameters required for mission synchronization.
**Required permissions**: ohos.permission.MANAGE_MISSIONS
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission **System capability**: SystemCapability.Ability.AbilityRuntime.Mission
| Name | Type | Readable | Writable | Description | | Name | Type | Readable | Writable | Description |
...@@ -338,6 +342,8 @@ Defines the parameters required for mission synchronization. ...@@ -338,6 +342,8 @@ Defines the parameters required for mission synchronization.
Defines the parameters required for registering a listener. Defines the parameters required for registering a listener.
**Required permissions**: ohos.permission.MANAGE_MISSIONS
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission **System capability**: SystemCapability.Ability.AbilityRuntime.Mission
| Name | Type | Readable | Writable | Description | | Name | Type | Readable | Writable | Description |
......
...@@ -7,6 +7,8 @@ This module provides WebGL APIs that correspond to the OpenGL ES 2.0 feature set ...@@ -7,6 +7,8 @@ This module provides WebGL APIs that correspond to the OpenGL ES 2.0 feature set
> **NOTE** > **NOTE**
> >
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> WebGL complies with the OpenGL protocol and does not support multi-thread calling.
## Invoking Method ## Invoking Method
...@@ -90,7 +92,7 @@ gl.clearColor(0.0, 0.0, 0.0, 1.0); ...@@ -90,7 +92,7 @@ gl.clearColor(0.0, 0.0, 0.0, 1.0);
WebGLContextAttributes WebGLContextAttributes
| Name| Type| Mandatory| | Name| Type| Mandatory|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| alpha | boolean | No| | alpha | boolean | No|
| depth | boolean | No| | depth | boolean | No|
...@@ -107,7 +109,7 @@ WebGLContextAttributes ...@@ -107,7 +109,7 @@ WebGLContextAttributes
WebGLActiveInfo WebGLActiveInfo
| Name| Type| Mandatory| | Name| Type| Mandatory|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| size | GLint | Yes| | size | GLint | Yes|
| type | GLenum | Yes| | type | GLenum | Yes|
...@@ -118,7 +120,7 @@ WebGLActiveInfo ...@@ -118,7 +120,7 @@ WebGLActiveInfo
WebGLShaderPrecisionFormat WebGLShaderPrecisionFormat
| Name| Type| Mandatory| | Name| Type| Mandatory|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| rangeMin | GLint | Yes| | rangeMin | GLint | Yes|
| rangeMax | GLint | Yes| | rangeMax | GLint | Yes|
...@@ -132,7 +134,7 @@ WebGLRenderingContextBase ...@@ -132,7 +134,7 @@ WebGLRenderingContextBase
### Attributes ### Attributes
| Name| Type| Mandatory| | Name| Type| Mandatory|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| DEPTH_BUFFER_BIT | GLenum | Yes| | DEPTH_BUFFER_BIT | GLenum | Yes|
| STENCIL_BUFFER_BIT | GLenum | Yes| | STENCIL_BUFFER_BIT | GLenum | Yes|
...@@ -435,7 +437,7 @@ WebGLRenderingContextBase ...@@ -435,7 +437,7 @@ WebGLRenderingContextBase
### Methods ### Methods
| Method| Return Value Type| | Method| Return Value Type|
| -------- | -------- | | -------- | -------- |
| getContextAttributes() | WebGLContextAttributes \| null | | getContextAttributes() | WebGLContextAttributes \| null |
| isContextLost() | boolean | | isContextLost() | boolean |
...@@ -561,14 +563,14 @@ WebGLRenderingContextBase ...@@ -561,14 +563,14 @@ WebGLRenderingContextBase
WebGLRenderingContextOverloads WebGLRenderingContextOverloads
| Method| Return Value Type| | Method| Return Value Type|
| -------- | -------- | | -------- | -------- |
| bufferData(target: GLenum, size: GLsizeiptr, usage: GLenum) | void | | bufferData(target: GLenum, size: GLsizeiptr, usage: GLenum) | void |
| bufferData(target: GLenum, data: BufferSource \| null, usage: GLenum) | void | | bufferData(target: GLenum, data: BufferSource \| null, usage: GLenum) | void |
| bufferSubData(target: GLenum, offset: GLintptr, data: BufferSource) | void | | bufferSubData(target: GLenum, offset: GLintptr, data: BufferSource) | void |
| compressedTexImage2D(target: GLenum, level: GLint, internalformat: GLenum, width: GLsizei, height: GLsizei, border: GLint, data: ArrayBufferView) | void | | compressedTexImage2D(target: GLenum, level: GLint, internalformat: GLenum, width: GLsizei, height: GLsizei, border: GLint, data: ArrayBufferView) | void |
| compressedTexSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, data: ArrayBufferView) | void | | compressedTexSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, data: ArrayBufferView) | void |
| readPixels(x: GLint, y: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, pixels: ArrayBufferView \| null) | void; | | readPixels(x: GLint, y: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, pixels: ArrayBufferView \| null) | void |
| texImage2D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, border: GLint, format: GLenum, type: GLenum, pixels: ArrayBufferView \| null) | void | | texImage2D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, border: GLint, format: GLenum, type: GLenum, pixels: ArrayBufferView \| null) | void |
| texImage2D(target: GLenum, level: GLint, internalformat: GLint, format: GLenum, type: GLenum, source: TexImageSource) | void | | texImage2D(target: GLenum, level: GLint, internalformat: GLint, format: GLenum, type: GLenum, source: TexImageSource) | void |
| texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, pixels: ArrayBufferView \| null) | void | | texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, pixels: ArrayBufferView \| null) | void |
......
...@@ -7,6 +7,8 @@ This module provides WebGL APIs that correspond to the OpenGL ES 3.0 feature set ...@@ -7,6 +7,8 @@ This module provides WebGL APIs that correspond to the OpenGL ES 3.0 feature set
> **NOTE** > **NOTE**
> >
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> WebGL2 complies with the OpenGL protocol and does not support multi-thread calling.
## Invoking Method ## Invoking Method
......
...@@ -182,12 +182,12 @@ The table below provides only the sites for downloading the latest OpenHarmony L ...@@ -182,12 +182,12 @@ The table below provides only the sites for downloading the latest OpenHarmony L
| Hi3516 solution-Linux (binary)| 3.0 | [Download](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_taurus_linux.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_taurus_linux.tar.gz.sha256) | | Hi3516 solution-Linux (binary)| 3.0 | [Download](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_taurus_linux.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_taurus_linux.tar.gz.sha256) |
| RELEASE-NOTES | 3.0 | [Download](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.0-LTS/en/release-notes/OpenHarmony-v3.0-LTS.md)| - | | RELEASE-NOTES | 3.0 | [Download](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.0-LTS/en/release-notes/OpenHarmony-v3.0-LTS.md)| - |
| **Source code of the Latest Release**| **Version Information**| **Site**| **SHA-256 Verification Code**| | **Source code of the Latest Release**| **Version Information**| **Site**| **SHA-256 Verification Code**|
| Full code base (for mini, small, and standard systems)| 3.2 Beta1 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta1/code-v3.2-Beta1.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta1/code-v3.2-Beta1.tar.gz.sha256)| | Full code base (for mini, small, and standard systems)| 3.2 Beta2 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta2/code-v3.2-Beta2.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta2/code-v3.2-Beta2.tar.gz.sha256)|
| RK3568 standard system solution (binary)| 3.2 Beta1 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta1/standard_rk3568.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.1.1/standard_rk3568.tar.gz.sha256)| | RK3568 standard system solution (binary)| 3.2 Beta2 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta2/standard_rk3568.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.1.1/standard_rk3568.tar.gz.sha256)|
| Hi3861 solution (binary)| 3.2 Beta1 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta1/hispark_pegasus.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta1/hispark_pegasus.tar.gz.sha256) | | Hi3861 solution (binary)| 3.2 Beta2 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta2/hispark_pegasus.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta2/hispark_pegasus.tar.gz.sha256) |
| Hi3516 solution-LiteOS (binary)| 3.2 Beta1 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta1/hispark_taurus.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta1/hispark_taurus.tar.gz.sha256)| | Hi3516 solution-LiteOS (binary)| 3.2 Beta2 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta2/hispark_taurus.tar.gz)| [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/hispark_taurus_LiteOS.tar.gz.sha256)|
| Hi3516 solution-Linux (binary)| 3.2 Beta1 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta1/hispark_taurus_linux.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta1/hispark_taurus_linux.tar.gz.sha256)| | Hi3516 solution-Linux (binary)| 3.2 Beta2 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta2/hispark_taurus_linux.tar.gz)| [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/hispark_taurus_Linux.tar.gz.sha256)|
| RELEASE-NOTES | 3.2 Beta1 | [Download](../../release-notes/OpenHarmony-v3.2-beta1.md)| - | | RELEASE-NOTES | 3.2 Beta2 | [Download](../../release-notes/OpenHarmony-v3.2-beta2.md)| - |
| **Compiler Toolchain**| **Version Information**| **Site**| **SHA-256 Verification Code**| | **Compiler Toolchain**| **Version Information**| **Site**| **SHA-256 Verification Code**|
| Compiler toolchain| - | [Download](https://repo.huaweicloud.com/openharmony/os/2.0/tool_chain/)| - | | Compiler toolchain| - | [Download](https://repo.huaweicloud.com/openharmony/os/2.0/tool_chain/)| - |
...@@ -197,7 +197,7 @@ The table below provides only the sites for downloading the latest OpenHarmony L ...@@ -197,7 +197,7 @@ The table below provides only the sites for downloading the latest OpenHarmony L
> >
> The image repository is synchronized at 23:00 (UTC +8:00) every day. > The image repository is synchronized at 23:00 (UTC +8:00) every day.
Method 1 \(recommended\): Use the **repo** tool to download the source code over SSH. \(You must have registered an SSH public key for access to GitHub. For details, see [Adding a new SSH key to your GitHub account](https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account).\) Method 1 \(recommended\): Use the **repo** tool to download the source code over SSH. \(You must have registered an SSH public key for access to GitHub. For details, see [Adding a new SSH key to your GitHub account](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account).\)
``` ```
repo init -u git@github.com:openharmony/manifest.git -b master --no-repo-verify repo init -u git@github.com:openharmony/manifest.git -b master --no-repo-verify
......
# OpenHarmony 3.2 Beta2
## Version Description
OpenHarmony 3.2 Beta2 provides the following enhancements over OpenHarmony 3.2 Beta1:
**Enhanced basic capabilities for the standard system**
Added the multi-hotspot distribution mechanism for the window.
Added the restart recovery mechanism for power management.
Added the stylus pressure and tilt in events, and added key input support for multimodal input.
Added the preset application pre-authorization mechanism and fingerprint enrolling/authentication/identification framework to the security domain.
Added selfie mirroring in recording mode, audio control and audio effect control, infrared device input, audio USB insertion/removal identification, and event reporting to the driver.
**Enhanced application framework capabilities for the standard system**
The ability allows addition of static and dynamic widgets, startup of abilities that are not locally installed, SA-initiated ability startup and access, singleton ability continuation, sandbox application opening during running management, and no display of system application abilities in the latest mission list.
Bundle management provides NDK interfaces for obtaining the bundle name and certificate fingerprint information of the current bundle, querying the pack information of a specified application, and aging and uninstalling atomic services.
**Application development samples for the standard system**
Added samples such as Gobang, QR code generation and parsing, widget usage, multimedia, short video, and facial recognition, helping developers quickly use basic capabilities of OpenHarmony.
## Version Mapping
**Table 1** Version mapping of software and tools
| Software/Tool| Version| Remarks|
| -------- | -------- | -------- |
| OpenHarmony | 3.2 Beta2 | NA |
| Public SDK | Ohos_sdk_public 3.2.5.5 (API Version 9 Beta2) | This toolkit is intended for application developers and does not contain system APIs that require system permissions.<br>It is provided as standard in DevEco Studio.|
| Full SDK | Ohos_sdk_full 3.2.5.5 (API Version 9 Beta2) | This toolkit is intended for original equipment manufacturers (OEMs) and contains system APIs that require system permissions.<br>To use the full SDK, manually obtain it from the mirror and switch to it in DevEco Studio. For details, see [Guide to Switching to Full SDK](../application-dev/quick-start/full-sdk-switch-guide.md).|
| (Optional) HUAWEI DevEco Studio| 3.0 Beta4 | This tool is recommended for developing OpenHarmony applications.|
| (Optional) HUAWEI DevEco Device Tool| 3.0 Release | This tool is recommended for developing OpenHarmony smart devices.|
## Source Code Acquisition
### Prerequisites
1. Register your account with Gitee.
2. Register an SSH public key for access to Gitee.
3. Install the [git client](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) and [git-lfs](https://gitee.com/vcs-all-in-one/git-lfs?_from=gitee_search#downloading), and configure user information.
```
git config --global user.name "yourname"
git config --global user.email "your-email-address"
git config --global credential.helper store
```
4. Run the following commands to install the **repo** tool:
```
curl -s https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 > /usr/local/bin/repo # If you do not have the permission, download the tool to another directory and configure it as an environment variable by running the chmod a+x /usr/local/bin/repo command.
pip3 install -i https://repo.huaweicloud.com/repository/pypi/simple requests
```
### Acquiring Source Code Using the repo Tool
**Method 1 (recommended)**
Use the **repo** tool to download the source code over SSH. (You must have an SSH public key for access to Gitee.)
- Obtain the source code from the version branch. You can obtain the latest source code of the version branch, which includes the code that has been incorporated into the branch up until the time you run the following commands:
```
repo init -u git@gitee.com:openharmony/manifest.git -b OpenHarmony-3.2-Beta2 --no-repo-verify
repo sync -c
repo forall -c 'git lfs pull'
```
- Obtain the source code from the version tag, which is the same as that released with the version.
```
repo init -u git@gitee.com:openharmony/manifest.git -b refs/tags/OpenHarmony-v3.2-Beta2 --no-repo-verify
repo sync -c
repo forall -c 'git lfs pull'
```
**Method 2**
Use the **repo** tool to download the source code over HTTPS.
- Obtain the source code from the version branch. You can obtain the latest source code of the version branch, which includes the code that has been incorporated into the branch up until the time you run the following commands:
```
repo init -u https://gitee.com/openharmony/manifest -b OpenHarmony-3.2-Beta2 --no-repo-verify
repo sync -c
repo forall -c 'git lfs pull'
```
- Obtain the source code from the version tag, which is the same as that released with the version.
```
repo init -u https://gitee.com/openharmony/manifest -b refs/tags/OpenHarmony-v3.2-Beta2 --no-repo-verify
repo sync -c
repo forall -c 'git lfs pull'
```
### Acquiring Source Code from Mirrors
**Table 2** Mirrors for acquiring source code
| Source Code | Version| Mirror | SHA-256 Checksum |
| --------------------------------------- | ------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
| Full code base (for mini, small, and standard systems) | 3.2 Beta2 | [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/code-v3.2-Beta2.tar.gz)| [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/code-v3.2-Beta2.tar.gz.sha256)|
| Hi3861 mini system solution (binary) | 3.2 Beta2 | [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/hispark_pegasus.tar.gz)| [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/hispark_pegasus.tar.gz.sha256)|
| Hi3516 mini system solution - LiteOS (binary)| 3.2 Beta2 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta1/hispark_taurus.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta1/hispark_taurus.tar.gz.sha256)|
| Hi3516 mini system solution - Linux (binary) | 3.2 Beta2 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta1/hispark_taurus_linux.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta1/hispark_taurus_linux.tar.gz.sha256)|
| RK3568 standard system solution (binary) | 3.2 Beta2 | [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/dayu200_standard_arm64.tar.gz)| [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/dayu200_standard_arm64.tar.gz.sha256)|
| Full SDK package for the standard system (macOS) | 3.2 Beta2 | [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/ohos-sdk-mac-full.tar.gz)| [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/ohos-sdk-mac-full.tar.gz.sha256)|
| Full SDK package for the standard system (Windows/Linux) | 3.2 Beta2 | [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/ohos-sdk-windows_linux-full.tar.gz)| [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/ohos-sdk-windows_linux-full.tar.gz.sha256)|
| Public SDK package for the standard system (macOS) | 3.2 Beta2 | [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/ohos-sdk-mac-public.tar.gz)| [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/ohos-sdk-mac-public.tar.gz.sha256)|
| Public SDK package for the standard system (Windows/Linux) | 3.2 Beta2 | [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/ohos-sdk-windows_linux-public.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/ohos-sdk-windows_linux-public.tar.gz.sha256)|
## What's New
This version has the following updates to OpenHarmony 3.2 Beta1.
### SDK Updates
From this version onwards, both the Public SDK and Full SDK are provided. The Public SDK is provided as standard in DevEco Studio.
If an application developed using the SDK of an earlier version calls system APIs, you must manually switch to the Full SDK by following the instructions provided in [Guide to Switching to Full SDK](../application-dev/quick-start/full-sdk-switch-guide.md) after the version upgrade. This operation ensures successful build of your application project.
### Feature Updates
**Table 3** New and enhanced features
| Subsystem| Standard System| Mini and Small Systems|
| -------- | -------- | -------- |
| Ability| - To support UI-free application development for IoT devices, the graphics and power modules are decoupled.<br>- Basic capabilities such as DFX, mission management, and application thread model management are enhanced.<br>The following requirements are involved:<br>I57ZUI [New feature] UI-free application development for IoT devices - graphics module decoupling<br>I57ZVC [New feature] UI-free application development for IoT devices - power module decoupling<br>I5805B [Enhanced feature] AMS ANR optimization<br>I581M3 [New feature] Application selection box<br>I580JM [New feature] No display of abilities of system applications in the latest mission list<br>I5FHNH [Enhanced feature] Passing the **Context** object of the stage model to the worker<br>I58034 [Enhanced feature] Using JS looper of libuv<br>I57ZZH [New feature] Providing APIs to create context for different HAP files| NA |
| Bundle management| The default application management capability is added, and basic capabilities such as crowdtesting applications and obtaining bundle fingerprint information are also provided.<br>The following requirements are involved:<br>I56WD7 [New feature] Querying the default application<br>I56WDJ [New feature] Changing the default application<br>I56WDR [New feature] Restoring the default system application<br>I56WEK [New feature] Setting the default application by file type<br>I59ZMR [New feature] Crowdtesting applications<br>I5A7OV [New feature] Providing NDK interfaces to obtain the bundle name and certificate fingerprint information of the current bundle| NA |
| Power subsystem| Resource management and logs are added for thermal management. Power consumption statistics is now available for more modules.<br>The following requirements are involved:<br>I5AOM8 [New feature] Action hub<br>I5DC5E [Enhanced feature] Camera power consumption statistics<br>I5DC7M [Enhanced feature] Audio power consumption statistics<br>I5DC8L [Enhanced feature] Timer power consumption DFX<br>I5DC9H [Enhanced feature] Distributed Scheduler power consumption DFX<br>I5DOP4 [New feature] Thermal maintenance and debugging DFX<br>I5DONL [New feature] Charging resource management framework<br>I5DOLA [New feature] Adaptation to the SOC resource management framework| NA |
| System Ability Management Subsystem (SAMGR)| - The basic distributed capabilities are continuously built.<br>- The stability and security of system service processes are hardened, and the process memory is optimized.<br>The following requirements are involved:<br>I5FLTY [New feature] Component collaboration relationship management<br>I5DP1O [New feature] System events, SA dump, and tracing provided by DMS<br>I5CEMN [New feature] Installation-free feature of **startAbilityForResult**<br>I5BAP0 [New Feature] Cross-device installation-free feature of **startAbility**<br>I5B2PK [New feature] Adaptation of cross-device migration to persistent storage of distributed objects<br>I59XYB [New feature] Group verification<br>I592I5 [New feature] Memory baseline of the distributedsche process<br>I5E4KV [New feature] System events, SA dump, and tracing provided by SAMGR| NA |
| Common event and notification subsystem| - The tool supports multi-user scenarios.<br>- The basic capabilities of the common event and notification subsystems are enhanced.<br>The following requirements are involved:<br>I582V2 [New specifications] Sending events in point-to-point mode<br>I582XB [New specifications] Multi-user support of the tool<br>I582UL [Enhanced feature] Enhancement of distributed notification synchronization<br>I582QQ [New specifications] Carrying application icon badges in notifications<br>I582XB [New specifications] Multi-user support of the tool<br>I582SD [DFX] [Enhanced feature] Enhanced notification DFX capability<br>I582ST [New specifications] Configuration of notification clearance events<br>I582TF [Enhanced feature] Enhancement of notification slot setting and query<br>I58418 [New specifications] SELinux policy configuration<br>I582Y4 [DFX dotting] System events, SA dump, and tracing| NA |
| Distributed hardware subsystem| DeviceManager supports requesting and importing of credential parameters of the same account.<br>I5IUUS [DFX dotting] System events, SA dump, and tracing<br>I5IUVN [New feature] Requesting and importing credential parameters of the same account| NA |
| User IAM subsystem| - The basic capabilities of user authentication are continuously enhanced.<br>- The user IAM framework now supports fingerprint enrolling, authentication, identification, and deletion.<br>I5EPCD [Framework] Fingerprint enrolling for specified users<br>I5EPCM [Framework] Fingerprint authentication and identification for specified users <br>I5EPCU [Framework] Fingerprint deletion for specified users| NA |
| Build subsystem| - The Python and Gn versions are updated.<br>- System components can be independently built.<br>- The module dependency and compiler cache (ccache) are optimized, and a compilation function switch is provided.<br>The following requirements are involved:<br>I5IZC2 Independent build of system components and chip components<br>I5IZD9 [Integration optimization] Optimized module dependency<br>I5IZI0 [Integration optimization] Compilation function switch<br>I5IZH2 [Integration optimization] Optimized ccache| NA |
| Multimode input subsystem| - JS APIs are provided for obtaining input device information.<br>- The stylus can be used as an input device.<br>- An event can be reported to indicate that a key is repeatedly pressed.<br>- SELinux is now supported.<br>The following requirements are involved:<br>I530UN [New feature] Multi-hotspot distribution of the window<br>I530UT [New feature] JS API Mock<br>I530VY [New feature] Using JS APIs to obtain basic information about the stylus input device<br>I530W0 [New feature] Using JS APIs to obtain extended information about the mouse input device<br>I530WA [New feature] Using JS APIs to obtain extended information about the touchpad input device<br>I530WD [New feature] Using JS APIs to obtain extended information about the touchscreen input device<br>I530WH [New feature] Receiving and distributing key input events of the Linux stylus input<br>I530WI [New Feature] Carrying the pressure of the Linux stylus input in events<br>I530WJ [New Feature] Carrying the tilt of the Linux stylus input in events<br>I530WK [New Feature] Providing the pressure attribute of the touch point<br>I530WM [New Feature] Providing the touch area attribute of the touch point<br>I530WO [New feature] Providing the tool area attribute of the touch point<br>I530WP [New feature] Providing the tool type attribute of the touch point<br>I530X8 [New feature] Setting of key mapping rules in the configuration file<br>I530XH [New feature] Setting of key mapping rules for system keys in the configuration file<br>I530XJ [New feature] Automatic repeat of system keys<br>I530XK [New feature] Keyboard type identification<br>I530XL [New feature] Key capability identification<br>I530XM [New feature] Setting of key mapping rules for the keyboard in the configuration file<br>I530XN [New feature] Automatic repeat of keys on the keyboard<br>I530XT [New feature] Using C++ APIs to adjust the mouse cursor position based on relative coordinates<br>I530XX [New feature] Providing the pressure attribute of the touch point<br>I530XZ [New feature] Providing the touch area attribute of the touch point<br>I530Y1 [New feature] Providing the tool area attribute of the touch point<br>I530Y2 [New feature] Providing the tool type attribute of the touch point<br>I530Y7 [New specifications] Support for 64-bit<br>I530YB [DFX dotting] System events, SA dump, and tracing<br>I530YF [New specifications] [Input] SELinux policy configuration<br>I5HMBS [Input] Adaptive keyboard and mouse layout adaptation| NA |
| Pan-sensor subsystem| - Data of more types of sensors can be reported.<br>- SELinux is supported.<br>The following requirements are involved:<br>I53SFI [DFX dotting] System events, SA dump, and tracing<br>I537CB [New specifications] Continuous integration of pan-sensor capabilities - rotation vector sensor<br>I537AN [New specifications] Continuous integration of pan-sensor capabilities - gravity sensor<br>I5379T [New specifications] Continuous integration of pan-sensor capabilities - geomagnetic sensor<br>I5379C [New specifications] Continuous integration of pan-sensor capabilities - orientation sensor<br>I53784 [New specifications] Continuous integration of pan-sensor capabilities - ambient light sensor<br>I53SFS [New specifications] SELinux policy configuration| NA |
| Distributed data management subsystem| Multiple data types are supported by DataShare.<br>The following requirement is involved:<br>I5EHGF [DataShare] Support for multiple data types.| NA |
| Web subsystem| - JS-related interaction capabilities are supported.<br>- The network, keyboard, mouse, web storage, and SELinux policies are supported.<br>The following requirements are involved:<br>I5DM1E [New specifications] JS window management of web components<br>I5DNG2 [New specifications] Full set of JS hit-testing interfaces and APIs for obtaining the default user agent<br>I5EK53 [New specifications] [Web components] HTTP verification management<br>I5EGBB [New specifications] [Web components] SELinux policy configuration<br>I5EBG1 [New specifications] Adaptation to the W3C network information APIs<br>I5EVEC [New specifications] Web kernel connection to peripherals such as the mouse and keyboard<br>I5FF2L [New specifications] [Web components] Web storage| NA |
| Driver subsystem| - Dynamic loading of kernel-mode drivers and DFX capabilities are supported.<br>- Codec 2.0 interfaces and codec driver models are provided.<br>- The driver capabilities of the camera, display, audio, sensor, and WLAN modules are enhanced.<br>The following requirements are involved:<br>I536FN [New feature] HDI passthrough<br>I5DJE5 [Enhanced feature] Compatibility with Linux uevent reporting, and enhancement to device plug-and-play<br>I550OL [New feature] DFX tracing and locating<br>I544XP [New feature] SELinux permission check for the HDF service<br>I528DG [New feature] Implementation of Codec 2.0 interfaces<br>I50I6S [New feature] Unified audio HDIs for the IPC mode and direct calling mode<br>I5A6H6 [Enhanced feature] Enhanced display management, and support for multi-screen display<br>I5B0C5 [New feature] Support for the metadata streams of the camera<br>I5B0BR [New feature] Selfie mirroring in recording mode<br>I5AJW1 [New feature] Linux libALSA audio interface compatibility<br>I56V2N [New feature] Definition and development of interfaces related to the HDF WLAN DAL HDI power mode<br>I5F411 [Enhanced feature] Enhanced vibrator effect capability| NA |
| USB subsystem| - Broadcast messages are provided for USB service events.<br>- The SELinux security policy is enhanced.<br>The following requirements are involved:<br>I59MYK [New feature] Broadcast messages for USB service events<br>I5AR8N [New specifications] SELinux policy configuration| NA |
| Kernel subsystem| - Refined memory management is supported.<br>- The adjustment mechanism is added for associated services.<br>The following requirements are involved:<br>I58LOD [New feature] Adjustment mechanism of associated services<br>I54Y5J [New feature] memtrack memory usage and adj query interface by process<br>I56B3Q [New feature] OnMemoryLevel<br>I5B694 [New feature] Refined memory management<br>I59O8H [New feature] Purgeable memory<br>I5CXOK [New feature] Hyperhold for reliability improvement| NA |
###
### Chip and Development Board Adaptation
For details about the adaptation status, see [SIG-Devboard](https://gitee.com/openharmony/community/blob/master/sig/sig-devboard/sig_devboard.md).
### Samples
**Table 4** New samples
| Subsystem| Name| Introduction| Programming Language|
| -------- | -------- | -------- | -------- |
| Ability| MissionManager | This sample calls APIs related to the mission manager to lock, unlock, and clear missions, and switch them to the foreground.| eTS |
| Network management| AirQuality | This sample implements a simple air quality app using JS. The app displays air quality information using line wrapping and historical data in a bar chart.| eTS |
| ArkUI | TransitionAnimation | This sample shows how to implement page transition, component transition, and transition of shared elements.| eTS |
| Application package management| ZipLib | This sample demonstrates the use of **\@ohos.zlib** by constructing the compression and decompression scenarios.| eTS |
| Engineering capabilities| Npm | This sample shows how npm references third-party JS class libraries (mathjs and dayjs) and local libraries.| eTS |
| Data management| DistributedMusicPlayer | In this sample, **fileIo** is used to obtain an audio file; **AudioPlayer** is used to play music, pause the playback, and play the next or previous song; **DeviceManager** is used to display the distributed device list and hop music playback across devices.| eTS |
| ArkUI | PatternLock | This sample shows how to use the **\<PatternLock>** component to implement password setting, verification, and resetting.| eTS |
| Security| UserAuth | This sample shows how to implement facial authentication.| eTS |
| Security| Cipher | This sample shows how to use cipher algorithms, including Rivest-Shamir-Adleman (RSA) and Advanced Encryption Standard (AES).| eTS |
| Graphics| Screen | This sample shows how to use APIs to listen for screen quantity changes, create and destroy virtual screens, and read and display screen attributes.| eTS |
| ArkUI | Search | This sample shows how to use the **\<Search>** component to implement a search page.| eTS |
| Device management| USBManager | This sample shows how to use USB device management, including listening for USB device insertion and removal events and display of USB device information.| eTS |
| Data management| DistributedDataGobang | This sample shows Gobang, a popular game played with black and white stones on a go board, developed using the distributed data management function. | eTS |
| Multimedia| Image | This sample provides an Image Processing app, using which you can read images from the local device, obtain image information, and rotate images.| eTS |
| Security| AbilityAccessCtrl | This sample shows how **@ohos.abilityAccessCtrl** works to implement application permission control.| eTS |
| Network management| WebSocket | This sample shows how to use WebSocket, including the connection and disconnection between the client and the server, and the receiving and sending of client data.| eTS |
| Connectivity| Bluetooth | Bluetooth is a short-range wireless technology used to implement communication between fixed and mobile devices over low-cost short-distance wireless connections. This sample describes how to discover, pair, and unpair Bluetooth devices.| eTS |
| Multimedia| GamePuzzle | This puzzle game app is developed based on the **\<Grid>** component. It uses the `Image` and `MediaLibrary` APIs to obtain and crop images.| eTS |
| Network management| UploadDownload | This sample uses the upload and download APIs to implement file storage.| eTS |
| Device management| Location | This sample uses the orientation sensor and GPS to obtain the current location information.| eTS |
| Telephony| Observer | This sample demonstrates how to use observer APIs to subscribe to network status, signal status, call status, cellular data, and SIM card status changes.| eTS |
| ArkUI | AdaptiveCapabilities | This sample shows multi-device adaptation in eTS, including resource qualifiers, atomic layouts, and responsive layouts.| eTS |
| ArkUI | JsAdaptiveCapabilities | This sample shows multi-device adaptation in JS, including resource qualifiers, atomic layouts, and responsive layouts.| JS |
For more information, visit [Samples](https://gitee.com/openharmony/app_samples).
## Resolved Issues
**Table 5** Resolved issues
| Issue No.| Description|
| -------- | -------- |
| [I4Z3G9](https://gitee.com/openharmony/graphic_graphic_2d/issues/I4Z3G9) | [RK3568] Screen flickering occurs when the secondary window is opened in the immersive primary window.|
| [I59M4Q](https://gitee.com/openharmony/developtools_hdc/issues/I59M4Q) | There is a low probability of device disconnection when hdc_std of API version 9 is used.|
| [I54D32](https://gitee.com/openharmony/multimedia_camera_standard/issues/I54D32) | [RK3568] [Mandatory] A black screen is displayed when the camera has been recording videos for multiple consecutive times.|
## Known Issues
**Table 6** Known issues
| ISSUE | Description| Impact| To Be Resolved By|
| -------- | -------- | -------- | -------- |
| I5I4GJ | There is a possibility that the RK3568 device is disconnected from DevEco Studio.| When DevEco Studio is used for application debugging, there is a possibility (1/25) that the device is disconnected. The device can be reconnected, and therefore the impact is controllable.| August 15, 2022|
| I5HTGF | The photo taken is rotated by 90 degrees clockwise when compared with the preview image.| User experience is affected.| August 15, 2022|
| I5FUNB | There are no patches for the known Linux kernel vulnerabilities yet.<br>CVE-2022-1462 | No patch is available in the kernel community for the kernel CVE vulnerabilities. After the patch is released in the community, it will be synchronized to OpenHarmony 3.2 Beta2.| Subject to the patch release time of the kernel community|
| I5FUO1 | There are no patches for the known Linux kernel vulnerabilities yet.<br>CVE-2022-21127 | No patch is available in the kernel community for the kernel CVE vulnerabilities. After the patch is released in the community, it will be synchronized to OpenHarmony 3.2 Beta2.| Subject to the patch release time of the kernel community|
# OpenHarmony Release Notes # OpenHarmony Release Notes
## OpenHarmony 3.x Releases ## OpenHarmony 3.x Releases
- [OpenHarmony v3.2 Beta2 (2022-07-30)](OpenHarmony-v3.2-beta2.md)
- [OpenHarmony v3.2 Beta1 (2022-05-31)](OpenHarmony-v3.2-beta1.md) - [OpenHarmony v3.2 Beta1 (2022-05-31)](OpenHarmony-v3.2-beta1.md)
- [OpenHarmony v3.1.1 Release (2022-05-31)](OpenHarmony-v3.1.1-release.md) - [OpenHarmony v3.1.1 Release (2022-05-31)](OpenHarmony-v3.1.1-release.md)
- [OpenHarmony v3.1 Release (2022-03-30)](OpenHarmony-v3.1-release.md) - [OpenHarmony v3.1 Release (2022-03-30)](OpenHarmony-v3.1-release.md)
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
- [Glossary](glossary.md) - [Glossary](glossary.md)
- OpenHarmony Release Notes - OpenHarmony Release Notes
- OpenHarmony 3.x Releases - OpenHarmony 3.x Releases
- [OpenHarmony v3.2 Beta2 (2022-07-30)](release-notes/OpenHarmony-v3.2-beta2.md)
- [OpenHarmony v3.2 Beta1 (2022-05-31)](release-notes/OpenHarmony-v3.2-beta1.md) - [OpenHarmony v3.2 Beta1 (2022-05-31)](release-notes/OpenHarmony-v3.2-beta1.md)
- [OpenHarmony v3.1.1 Release (2022-05-31)](release-notes/OpenHarmony-v3.1.1-release.md) - [OpenHarmony v3.1.1 Release (2022-05-31)](release-notes/OpenHarmony-v3.1.1-release.md)
- [OpenHarmony v3.1 Release (2022-03-30)](release-notes/OpenHarmony-v3.1-release.md) - [OpenHarmony v3.1 Release (2022-03-30)](release-notes/OpenHarmony-v3.1-release.md)
...@@ -123,6 +124,9 @@ ...@@ -123,6 +124,9 @@
- [JS API Differences](release-notes/api-change/v2.2-beta2/js-apidiff-v2.2-beta2.md) - [JS API Differences](release-notes/api-change/v2.2-beta2/js-apidiff-v2.2-beta2.md)
- [Native API Differences](release-notes/api-change/v2.2-beta2/native-apidiff-v2.2-beta2.md) - [Native API Differences](release-notes/api-change/v2.2-beta2/native-apidiff-v2.2-beta2.md)
- ChangeLog - ChangeLog
- OpenHamrony 3.2 Beta2
- [Updates Between OpenHarmony 3.2 Beta2 and OpenHarmony 3.2 Beta1](release-notes/changelog/v3.2-beta2/changelog-v3.2-beta2.md)
- [Adaptation Guide for the Application Sandbox](release-notes/changelog/v3.2-beta2/application-sandbox-adaptation-guide.md)
- OpenHarmony 3.1 Beta - OpenHarmony 3.1 Beta
- [Updates Between OpenHarmony 3.1 Beta and OpenHarmony 3.0](release-notes/api-change/v3.1-beta/changelog-v3.1-beta.md) - [Updates Between OpenHarmony 3.1 Beta and OpenHarmony 3.0](release-notes/api-change/v3.1-beta/changelog-v3.1-beta.md)
- OpenHarmony Third-Party Components - OpenHarmony Third-Party Components
......
# I18n开发指导 # I18n开发指导
本模块提供系统相关的或者增强的国际化能力,包括区域管理、电话号码处理、日历等,相关接口为ECMA 402标准中未定义的补充接口。 本模块提供系统相关的或者增强的国际化能力,包括区域管理、电话号码处理、日历等,相关接口为ECMA 402标准中未定义的补充接口。更多接口和使用方式请见[I18N](../reference/apis/js-apis-i18n.md)
[Intl](intl-guidelines.md)模块提供了ECMA 402标准定义的基础国际化接口,与本模块共同使用可提供完整地国际化支持能力。 [Intl](intl-guidelines.md)模块提供了ECMA 402标准定义的基础国际化接口,与本模块共同使用可提供完整地国际化支持能力。
## 获取系统语言区域信息 ## 获取系统语言区域信息
...@@ -85,7 +86,7 @@ ...@@ -85,7 +86,7 @@
## 获取日历信息 ## 获取日历信息
调用日历[Calendar](../reference/apis/js-apis-intl.md)相关接口来获取日历的相关信息,例如获取日历的本地化显示、一周起始日、一年中第一周的最小天数等。 调用日历[Calendar](../reference/apis/js-apis-i18n.md#calendar8)相关接口来获取日历的相关信息,例如获取日历的本地化显示、一周起始日、一年中第一周的最小天数等。
### 接口说明 ### 接口说明
...@@ -111,7 +112,7 @@ ...@@ -111,7 +112,7 @@
调用getCalendar方法获取指定locale和type的时区对象(i18n为导入的模块)。其中,type表示合法的日历类型,目前合法的日历类型包括:"buddhist", "chinese", "coptic", "ethiopic", "hebrew", "gregory", "indian", "islamic_civil", "islamic_tbla", "islamic_umalqura", "japanese", "persian"。当type没有给出时,采用区域默认的日历类型。 调用getCalendar方法获取指定locale和type的时区对象(i18n为导入的模块)。其中,type表示合法的日历类型,目前合法的日历类型包括:"buddhist", "chinese", "coptic", "ethiopic", "hebrew", "gregory", "indian", "islamic_civil", "islamic_tbla", "islamic_umalqura", "japanese", "persian"。当type没有给出时,采用区域默认的日历类型。
```js ```js
var calendar = i18n.getCalendar("zh-CN", "gregory); var calendar = i18n.getCalendar("zh-CN", "gregory");
``` ```
2. 设置日历对象的时间。 2. 设置日历对象的时间。
...@@ -177,7 +178,7 @@ ...@@ -177,7 +178,7 @@
## 电话号码格式化 ## 电话号码格式化
调用电话号码格式化[PhoneNumberFormat](../reference/apis/js-apis-intl.md)的接口,实现对针对不同国家电话号码的格式化以及判断电话号码格式是否正确的功能。 调用电话号码格式化[PhoneNumberFormat](../reference/apis/js-apis-i18n.md#phonenumberformat8)的接口,实现对针对不同国家电话号码的格式化以及判断电话号码格式是否正确的功能。
### 接口说明 ### 接口说明
...@@ -194,7 +195,7 @@ ...@@ -194,7 +195,7 @@
调用PhoneNumberFormat的构造函数来实例化电话号码格式化对象,需要传入电话号码的国家代码及格式化选项。其中,格式化选项是可选的,包括style选项,该选项的取值包括:"E164", "INTERNATIONAL", "NATIONAL", "RFC3966"。 调用PhoneNumberFormat的构造函数来实例化电话号码格式化对象,需要传入电话号码的国家代码及格式化选项。其中,格式化选项是可选的,包括style选项,该选项的取值包括:"E164", "INTERNATIONAL", "NATIONAL", "RFC3966"。
```js ```js
var phoneNumberFormat = new i18n.PhoneNubmerFormat("CN", {type: "E164"}); var phoneNumberFormat = new i18n.PhoneNumberFormat("CN", {type: "E164"});
``` ```
2. 判断电话号码格式是否正确。 2. 判断电话号码格式是否正确。
...@@ -227,7 +228,7 @@ ...@@ -227,7 +228,7 @@
1. 度量衡单位转换。 1. 度量衡单位转换。
调用[unitConvert](../reference/apis/js-apis-intl.md)方法实现度量衡单位转换,并进行格式化显示的功能。 调用[unitConvert](../reference/apis/js-apis-i18n.md#unitconvert8)方法实现度量衡单位转换,并进行格式化显示的功能。
```js ```js
var fromUnit = {unit: "cup", measureSystem: "US"}; var fromUnit = {unit: "cup", measureSystem: "US"};
...@@ -240,7 +241,7 @@ ...@@ -240,7 +241,7 @@
## 字母表索引 ## 字母表索引
调用字母表索引[IndexUtil](../reference/apis/js-apis-intl.md)的接口可以获取不同Locale的字母表索引,以及实现计算字符串所属索引的功能。 调用字母表索引[IndexUtil](../reference/apis/js-apis-i18n.md#indexutil8)的接口可以获取不同Locale的字母表索引,以及实现计算字符串所属索引的功能。
### 接口说明 ### 接口说明
...@@ -259,7 +260,7 @@ ...@@ -259,7 +260,7 @@
```js ```js
var indexUtil = getInstance("zh-CN"); var indexUtil = i18n.getInstance("zh-CN");
``` ```
2. 获取索引列表。 2. 获取索引列表。
...@@ -289,7 +290,7 @@ ...@@ -289,7 +290,7 @@
## 获取文本断点位置 ## 获取文本断点位置
当文本比较长无法在一行进行显示时,调用文本断点[BreakIterator8](../reference/apis/js-apis-intl.md)的接口,来获取文本可以断行的位置。 当文本比较长无法在一行进行显示时,调用文本断点[BreakIterator8](../reference/apis/js-apis-i18n.md#breakiterator8)的接口,来获取文本可以断行的位置。
### 接口说明 ### 接口说明
......
# Intl开发指导 # Intl开发指导
本模块提供提供基础的应用国际化能力,包括时间日期格式化、数字格式化、排序等,相关接口在ECMA 402标准中定义。 本模块提供提供基础的应用国际化能力,包括时间日期格式化、数字格式化、排序等,相关接口在ECMA 402标准中定义。更多接口和使用方式请见[Intl](../reference/apis/js-apis-intl.md)
[I18N](i18n-guidelines.md)模块提供其他非ECMA 402定义的国际化接口,与本模块共同使用可提供完整地国际化支持能力。 [I18N](i18n-guidelines.md)模块提供其他非ECMA 402定义的国际化接口,与本模块共同使用可提供完整地国际化支持能力。
## 设置区域信息 ## 设置区域信息
调用[Locale](../reference/apis/js-apis-intl.md)的相关接口实现最大化区域信息或最小化区域信息。 调用[Locale](../reference/apis/js-apis-intl.md#locale)的相关接口实现最大化区域信息或最小化区域信息。
### 接口说明 ### 接口说明
...@@ -21,7 +22,7 @@ ...@@ -21,7 +22,7 @@
1. 实例化Locale对象。 1. 实例化Locale对象。
使用Locale的构造函数创建Locale对象,该方法接收一个表示Locale的字符串及可选的[属性](../reference/apis/js-apis-intl.md)列表(intl为导入的模块名)。 使用Locale的构造函数创建Locale对象,该方法接收一个表示Locale的字符串及可选的[属性](../reference/apis/js-apis-intl.md#localeoptions)列表(intl为导入的模块名)。
表示Locale的字符串参数可以分为以下四部分:语言、脚本、地区、扩展参数。各个部分按照顺序使用中划线“-”进行连接。 表示Locale的字符串参数可以分为以下四部分:语言、脚本、地区、扩展参数。各个部分按照顺序使用中划线“-”进行连接。
- 语言:必选,使用2个或3个小写英文字母表示(可参考ISO-639标准),例如英文使用“en”表示,中文使用“zh”表示。 - 语言:必选,使用2个或3个小写英文字母表示(可参考ISO-639标准),例如英文使用“en”表示,中文使用“zh”表示。
...@@ -40,7 +41,7 @@ ...@@ -40,7 +41,7 @@
```js ```js
var locale = "zh-CN"; var locale = "zh-CN";
var options = {caseFirst: false, calendar: "chinese", collation: pinyin}; var options = {caseFirst: false, calendar: "chinese", collation: "pinyin"};
var localeObj = new intl.Locale(locale, options); var localeObj = new intl.Locale(locale, options);
``` ```
...@@ -70,7 +71,7 @@ ...@@ -70,7 +71,7 @@
## 格式化日期时间 ## 格式化日期时间
调用日期时间格式化[DateTimeFormat](../reference/apis/js-apis-intl.md)的接口,实现针对特定Locale的日期格式化以及时间段格式化功能。 调用日期时间格式化[DateTimeFormat](../reference/apis/js-apis-intl.md#datetimeformat)的接口,实现针对特定Locale的日期格式化以及时间段格式化功能。
### 接口说明 ### 接口说明
...@@ -92,7 +93,7 @@ ...@@ -92,7 +93,7 @@
var dateTimeFormat = new intl.DateTimeFormat(); var dateTimeFormat = new intl.DateTimeFormat();
``` ```
另一种方法是使用开发者提供的Locale和格式化参数来创建日期时间格式化对象。其中,格式化参数是可选的,完整的格式化参数列表见[DateTimeOptions](../reference/apis/js-apis-intl.md)。 另一种方法是使用开发者提供的Locale和格式化参数来创建日期时间格式化对象。其中,格式化参数是可选的,完整的格式化参数列表见[DateTimeOptions](../reference/apis/js-apis-intl.md#datetimeoptions)。
```js ```js
var options = {dateStyle: "full", timeStyle: "full"}; var options = {dateStyle: "full", timeStyle: "full"};
...@@ -104,18 +105,19 @@ ...@@ -104,18 +105,19 @@
使用DateTimeFormat的format方法对一个Date对象进行格式化,该方法会返回一个字符串作为格式化的结果。 使用DateTimeFormat的format方法对一个Date对象进行格式化,该方法会返回一个字符串作为格式化的结果。
```js ```js
Date date = new Date(); var date = new Date();
var formatResult = dateTimeFormat.format(date); var formatResult = dateTimeFormat.format(date);
``` ```
3. 格式化时间段。 3. 格式化时间段。
使用DateTimeFormat的formatRange方法对一个时间段进行格式化。该方法需要传入两个Date对象,分别表示时间段的起止时间,返回一个字符串作为格式化的结果。 使用DateTimeFormat的formatRange方法对一个时间段进行格式化。该方法需要传入两个Date对象,分别表示时间段的起止日期,返回一个字符串作为格式化的结果。
```js ```js
Date startDate = new Date(); var startDate = new Date(2021, 11, 17, 3, 24, 0);
Date endDate = new Date(); var endDate = new Date(2021, 11, 18, 3, 24, 0);
var formatResult = dateTimeFormat.formatRange(startDate, endDate); var datefmt = new Intl.DateTimeFormat("en-GB");
datefmt.formatRange(startDate, endDate);
``` ```
4. 访问日期时间格式化对象的相关属性。 4. 访问日期时间格式化对象的相关属性。
...@@ -128,7 +130,7 @@ ...@@ -128,7 +130,7 @@
## 数字格式化 ## 数字格式化
调用数字格式化[NumberFormat](../reference/apis/js-apis-intl.md)的接口,实现针对特定Locale的数字格式化功能。 调用数字格式化[NumberFormat](../reference/apis/js-apis-intl.md#numberformat)的接口,实现针对特定Locale的数字格式化功能。
### 接口说明 ### 接口说明
...@@ -149,7 +151,7 @@ ...@@ -149,7 +151,7 @@
var numberFormat = new intl.NumberFormat(); var numberFormat = new intl.NumberFormat();
``` ```
另一种方法是使用开发者提供的Locale和格式化参数来创建数字格式化对象。其中,格式化参数是可选的,完整的格式化参数列表参见[NumberOptions](../reference/apis/js-apis-intl.md)。 另一种方法是使用开发者提供的Locale和格式化参数来创建数字格式化对象。其中,格式化参数是可选的,完整的格式化参数列表参见[NumberOptions](../reference/apis/js-apis-intl.md#numberoptions)。
```js ```js
var options = {compactDisplay: "short", notation: "compact"}; var options = {compactDisplay: "short", notation: "compact"};
...@@ -175,7 +177,7 @@ ...@@ -175,7 +177,7 @@
## 字符串排序 ## 字符串排序
不同区域的用户对于字符串排序具有不同的需求。调用字符串排序[Collator](../reference/apis/js-apis-intl.md)的接口,实现针对特定Locale的字符串排序功能。 不同区域的用户对于字符串排序具有不同的需求。调用字符串排序[Collator](../reference/apis/js-apis-intl.md#collator8)的接口,实现针对特定Locale的字符串排序功能。
### 接口说明 ### 接口说明
...@@ -196,7 +198,7 @@ ...@@ -196,7 +198,7 @@
var collator = new intl.Collator(); var collator = new intl.Collator();
``` ```
另一种方法是使用开发者提供的Locale和其他相关参数来创建Collator对象,完整的参数列表参见[CollatorOptions](../reference/apis/js-apis-intl.md)。 另一种方法是使用开发者提供的Locale和其他相关参数来创建Collator对象,完整的参数列表参见[CollatorOptions](../reference/apis/js-apis-intl.md#collatoroptions8)。
```js ```js
var collator= new intl.Collator("zh-CN", {localeMatcher: "best fit", usage: "sort"}); var collator= new intl.Collator("zh-CN", {localeMatcher: "best fit", usage: "sort"});
...@@ -204,7 +206,7 @@ ...@@ -204,7 +206,7 @@
2. 比较字符串。 2. 比较字符串。
使用Collator的compare方法对传入的两个字符串进行比较。该方法返回一个数值作为比较的结果,返回-1表示第一个字符串小于第二个字符串,返回1表示第一个字符大于第二个字符串,返回0表示两个字符串相同。 使用Collator的compare方法对传入的两个字符串进行比较。该方法返回一个数值作为比较的结果,返回-1表示第一个字符串小于第二个字符串,返回1表示第一个字符大于第二个字符串,返回0表示两个字符串相同。基于两个字符串的比较结果,开发者可以字符串集合进行排序。
```js ```js
var str1 = "first string"; var str1 = "first string";
...@@ -222,7 +224,7 @@ ...@@ -222,7 +224,7 @@
## 判定单复数类别 ## 判定单复数类别
在一些语言的语法中,当数字后面存在名词时,名词需要根据数字的值采用不同的形式。调用单复数[PluralRules](../reference/apis/js-apis-intl.md)的接口,可以实现针对特定Locale计算数字单复数类别的功能,从而选择合适的名词单复数表示。 在一些语言的语法中,当数字后面存在名词时,名词需要根据数字的值采用不同的形式。调用单复数[PluralRules](../reference/apis/js-apis-intl.md#pluralrules8)的接口,可以实现针对特定Locale计算数字单复数类别的功能,从而选择合适的名词单复数表示。
### 接口说明 ### 接口说明
...@@ -243,10 +245,10 @@ ...@@ -243,10 +245,10 @@
var pluralRules = new intl.PluralRules(); var pluralRules = new intl.PluralRules();
``` ```
另一种方法是使用开发者提供的Locale和其他相关参数来创建单复数对象。完整的参数列表参见[PluralRulesOptions](../reference/apis/js-apis-intl.md)。 另一种方法是使用开发者提供的Locale和其他相关参数来创建单复数对象。完整的参数列表参见[PluralRulesOptions](../reference/apis/js-apis-intl.md#pluralrulesoptions8)。
```js ```js
var plurals = new intl.PluralRules("zh-CN", {localeMatcher: "best fit", type: "cardinal"}); var pluralRules = new intl.PluralRules("zh-CN", {localeMatcher: "best fit", type: "cardinal"});
``` ```
2. 计算数字单复数类别。 2. 计算数字单复数类别。
...@@ -260,7 +262,7 @@ ...@@ -260,7 +262,7 @@
## 相对时间格式化 ## 相对时间格式化
调用相对时间格式化[RelativeTimeFormat](../reference/apis/js-apis-intl.md)的接口,实现针对特定Locale的相对时间格式化功能。 调用相对时间格式化[RelativeTimeFormat](../reference/apis/js-apis-intl.md#relativetimeformat8)的接口,实现针对特定Locale的相对时间格式化功能。
### 接口说明 ### 接口说明
...@@ -282,7 +284,7 @@ ...@@ -282,7 +284,7 @@
var relativeTimeFormat = new intl.RelativeTimeFormat(); var relativeTimeFormat = new intl.RelativeTimeFormat();
``` ```
另一种方法是使用开发者提供的Locale和格式化参数来创建相对时间格式化对象。其中,格式化参数是可选的,完整的参数列表参见[ RelativeTimeFormatInputOptions](../reference/apis/js-apis-intl.md)。 另一种方法是使用开发者提供的Locale和格式化参数来创建相对时间格式化对象。其中,格式化参数是可选的,完整的参数列表参见[ RelativeTimeFormatInputOptions](../reference/apis/js-apis-intl.md#relativetimeformatinputoptions8)。
``` ```
var relativeTimeFormat = new intl.RelativeTimeFormat("zh-CN", {numeric: "always", style: "long"}); var relativeTimeFormat = new intl.RelativeTimeFormat("zh-CN", {numeric: "always", style: "long"});
...@@ -310,7 +312,7 @@ ...@@ -310,7 +312,7 @@
4. 访问相对时间格式化对象的相关属性。 4. 访问相对时间格式化对象的相关属性。
RelativeTimeFormat的resolvedOptions方法会返回一个对象,该对象包含了RelativeTimeFormat对象的所有相关属性及其值,完整的属性列表参见[ RelativeTimeFormatResolvedOptions](../reference/apis/js-apis-intl.md)。 RelativeTimeFormat的resolvedOptions方法会返回一个对象,该对象包含了RelativeTimeFormat对象的所有相关属性及其值,完整的属性列表参见[ RelativeTimeFormatResolvedOptions](../reference/apis/js-apis-intl.md#relativetimeformatresolvedoptions8)。
```js ```js
var options = numberFormat.resolvedOptions(); var options = numberFormat.resolvedOptions();
......
...@@ -21,15 +21,15 @@ Ability是系统调度应用的最小单元,是能够完成一个独立功能 ...@@ -21,15 +21,15 @@ Ability是系统调度应用的最小单元,是能够完成一个独立功能
OpenHarmony中提供的接口,部分是仅供OEM厂商使用的system api,普通应用无法使用。 OpenHarmony中提供的接口,部分是仅供OEM厂商使用的system api,普通应用无法使用。
普通应用即应用APL等级为normal的应用。默认情况下,应用的等级都为normal应用。
APL等级的详细说明及如何将应用的APL等级声明为normal以上,请参考[访问控制开发概述-应用APL等级说明](../../security/accesstoken-overview.md#应用apl等级说明)
针对这种情况,在文档中会进行系统接口的声明: 针对这种情况,在文档中会进行系统接口的声明:
- 如果某个模块的接口均为system api,会在文档开头说明:该模块接口为系统接口。 - 如果某个模块的接口均为system api,会在文档开头说明:该模块接口为系统接口。
- 如果某个接口为system api,会在具体的接口描述中说明:此接口为系统接口。 - 如果某个接口为system api,会在具体的接口描述中说明:此接口为系统接口。
普通应用即应用APL等级为normal的应用。默认情况下,应用的等级都为normal应用。
APL等级的详细说明及如何将应用的APL等级声明为normal以上,请参考[访问控制开发概述-应用APL等级说明](../../security/accesstoken-overview.md#应用apl等级说明)
## 权限说明 ## 权限说明
默认情况下,应用只能访问有限的系统资源。但某些情况下,应用为了扩展功能的诉求,需要访问额外的系统或其他应用的数据(包括用户个人数据)、功能。具体可参考[访问控制开发概述](../../security/accesstoken-overview.md) 默认情况下,应用只能访问有限的系统资源。但某些情况下,应用为了扩展功能的诉求,需要访问额外的系统或其他应用的数据(包括用户个人数据)、功能。具体可参考[访问控制开发概述](../../security/accesstoken-overview.md)
......
...@@ -73,7 +73,7 @@ getStreamManager(callback: AsyncCallback\<AudioStreamManager>): void ...@@ -73,7 +73,7 @@ getStreamManager(callback: AsyncCallback\<AudioStreamManager>): void
```js ```js
audio.getStreamManager((err, data) => { audio.getStreamManager((err, data) => {
if (err) { if (err) {
console.error(`getStreamManager : Error: ${err.message}`); console.error(`getStreamManager : Error: ${err}`);
} else { } else {
console.info('getStreamManager : Success : SUCCESS'); console.info('getStreamManager : Success : SUCCESS');
let audioStreamManager = data; let audioStreamManager = data;
...@@ -103,7 +103,7 @@ audio.getStreamManager().then((data) => { ...@@ -103,7 +103,7 @@ audio.getStreamManager().then((data) => {
audioStreamManager = data; audioStreamManager = data;
console.info('getStreamManager: Success!'); console.info('getStreamManager: Success!');
}).catch((err) => { }).catch((err) => {
console.error(`getStreamManager: ERROR : ${err.message}`); console.error(`getStreamManager: ERROR : ${err}`);
}); });
``` ```
...@@ -147,7 +147,7 @@ var audioRendererOptions = { ...@@ -147,7 +147,7 @@ var audioRendererOptions = {
audio.createAudioRenderer(audioRendererOptions,(err, data) => { audio.createAudioRenderer(audioRendererOptions,(err, data) => {
if (err) { if (err) {
console.error(`AudioRenderer Created: Error: ${err.message}`); console.error(`AudioRenderer Created: Error: ${err}`);
} else { } else {
console.info('AudioRenderer Created: Success: SUCCESS'); console.info('AudioRenderer Created: Success: SUCCESS');
let audioRenderer = data; let audioRenderer = data;
...@@ -203,7 +203,7 @@ audio.createAudioRenderer(audioRendererOptions).then((data) => { ...@@ -203,7 +203,7 @@ audio.createAudioRenderer(audioRendererOptions).then((data) => {
audioRenderer = data; audioRenderer = data;
console.info('AudioFrameworkRenderLog: AudioRenderer Created : Success : Stream Type: SUCCESS'); console.info('AudioFrameworkRenderLog: AudioRenderer Created : Success : Stream Type: SUCCESS');
}).catch((err) => { }).catch((err) => {
console.error(`AudioFrameworkRenderLog: AudioRenderer Created : ERROR : ${err.message}`); console.error(`AudioFrameworkRenderLog: AudioRenderer Created : ERROR : ${err}`);
}); });
``` ```
...@@ -245,7 +245,7 @@ var audioCapturerOptions = { ...@@ -245,7 +245,7 @@ var audioCapturerOptions = {
audio.createAudioCapturer(audioCapturerOptions, (err, data) => { audio.createAudioCapturer(audioCapturerOptions, (err, data) => {
if (err) { if (err) {
console.error(`AudioCapturer Created : Error: ${err.message}`); console.error(`AudioCapturer Created : Error: ${err}`);
} else { } else {
console.info('AudioCapturer Created : Success : SUCCESS'); console.info('AudioCapturer Created : Success : SUCCESS');
let audioCapturer = data; let audioCapturer = data;
...@@ -300,7 +300,7 @@ audio.createAudioCapturer(audioCapturerOptions).then((data) => { ...@@ -300,7 +300,7 @@ audio.createAudioCapturer(audioCapturerOptions).then((data) => {
audioCapturer = data; audioCapturer = data;
console.info('AudioCapturer Created : Success : Stream Type: SUCCESS'); console.info('AudioCapturer Created : Success : Stream Type: SUCCESS');
}).catch((err) => { }).catch((err) => {
console.error(`AudioCapturer Created : ERROR : ${err.message}`); console.error(`AudioCapturer Created : ERROR : ${err}`);
}); });
``` ```
...@@ -336,14 +336,14 @@ audio.createAudioCapturer(audioCapturerOptions).then((data) => { ...@@ -336,14 +336,14 @@ audio.createAudioCapturer(audioCapturerOptions).then((data) => {
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Device **系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Device
| 名称 | 默认值 | 描述 | | 名称 | 默认值 | 描述 |
| ------------------- | ------ | ---------- | | --------------------------- ----| ------ | ---------- |
| NONE_DEVICES_FLAG<sup>9+</sup> | 0 | 无 | | NONE_DEVICES_FLAG<sup>9+</sup> | 0 | 无 <br/>此接口为系统接口,三方应用不支持调用。 |
| OUTPUT_DEVICES_FLAG | 1 | 输出设备。 | | OUTPUT_DEVICES_FLAG | 1 | 输出设备。 |
| INPUT_DEVICES_FLAG | 2 | 输入设备。 | | INPUT_DEVICES_FLAG | 2 | 输入设备。 |
| ALL_DEVICES_FLAG | 3 | 所有设备。 | | ALL_DEVICES_FLAG | 3 | 所有设备。 |
| DISTRIBUTED_OUTPUT_DEVICES_FLAG<sup>9+</sup> | 4 | 分布式输出设备。 | | DISTRIBUTED_OUTPUT_DEVICES_FLAG<sup>9+</sup> | 4 | 分布式输出设备。<br/>此接口为系统接口,三方应用不支持调用。 |
| DISTRIBUTED_INPUT_DEVICES_FLAG<sup>9+</sup> | 8 | 分布式输入设备。 | | DISTRIBUTED_INPUT_DEVICES_FLAG<sup>9+</sup> | 8 | 分布式输入设备。<br/>此接口为系统接口,三方应用不支持调用。 |
| ALL_DISTRIBUTED_DEVICES_FLAG<sup>9+</sup> | 12 | 分布式输入和输出设备。 | | ALL_DISTRIBUTED_DEVICES_FLAG<sup>9+</sup> | 12 | 分布式输入和输出设备。<br/>此接口为系统接口,三方应用不支持调用。 |
## DeviceRole ## DeviceRole
...@@ -365,7 +365,7 @@ audio.createAudioCapturer(audioCapturerOptions).then((data) => { ...@@ -365,7 +365,7 @@ audio.createAudioCapturer(audioCapturerOptions).then((data) => {
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Device **系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Device
| 名称 | 默认值 | 描述 | | 名称 | 默认值 | 描述 |
| ---------------- | ------ | --------------------------------------------------------- | | ---------------------| ------ | --------------------------------------------------------- |
| INVALID | 0 | 无效设备。 | | INVALID | 0 | 无效设备。 |
| EARPIECE | 1 | 听筒。 | | EARPIECE | 1 | 听筒。 |
| SPEAKER | 2 | 扬声器。 | | SPEAKER | 2 | 扬声器。 |
...@@ -375,7 +375,7 @@ audio.createAudioCapturer(audioCapturerOptions).then((data) => { ...@@ -375,7 +375,7 @@ audio.createAudioCapturer(audioCapturerOptions).then((data) => {
| BLUETOOTH_A2DP | 8 | 蓝牙设备A2DP(Advanced Audio Distribution Profile)连接。 | | BLUETOOTH_A2DP | 8 | 蓝牙设备A2DP(Advanced Audio Distribution Profile)连接。 |
| MIC | 15 | 麦克风。 | | MIC | 15 | 麦克风。 |
| USB_HEADSET | 22 | USB耳机,带麦克风。 | | USB_HEADSET | 22 | USB耳机,带麦克风。 |
| DEFAULT | 1000 | 默认设备类型。 | | DEFAULT<sup>9+</sup> | 1000 | 默认设备类型。 |
## ActiveDeviceType ## ActiveDeviceType
...@@ -798,9 +798,9 @@ getRoutingManager(callback: AsyncCallback&lt;AudioRoutingManager&gt;): void ...@@ -798,9 +798,9 @@ getRoutingManager(callback: AsyncCallback&lt;AudioRoutingManager&gt;): void
**示例:** **示例:**
```js ```js
await audioManager.getRoutingManager((err,callback) => { await audioManager.getRoutingManager((err, callback) => {
if (err) { if (err) {
console.error(`Result ERROR: ${err.message}`); console.error(`Result ERROR: ${err}`);
} }
console.info('getRoutingManager Callback SUCCESS.'); console.info('getRoutingManager Callback SUCCESS.');
var audioRoutingManager; var audioRoutingManager;
...@@ -828,7 +828,7 @@ await audioManager.getRoutingManager().then((value) => { ...@@ -828,7 +828,7 @@ await audioManager.getRoutingManager().then((value) => {
var routingManager = value; var routingManager = value;
console.info('getRoutingManager Promise SUCCESS.'); console.info('getRoutingManager Promise SUCCESS.');
}).catch((err) => { }).catch((err) => {
console.error(`Result ERROR: ${err.message}`); console.error(`Result ERROR: ${err}`);
}); });
``` ```
...@@ -857,7 +857,7 @@ setVolume(volumeType: AudioVolumeType, volume: number, callback: AsyncCallback&l ...@@ -857,7 +857,7 @@ setVolume(volumeType: AudioVolumeType, volume: number, callback: AsyncCallback&l
```js ```js
audioManager.setVolume(audio.AudioVolumeType.MEDIA, 10, (err) => { audioManager.setVolume(audio.AudioVolumeType.MEDIA, 10, (err) => {
if (err) { if (err) {
console.error(`Failed to set the volume. ${err.message}`); console.error(`Failed to set the volume. ${err}`);
return; return;
} }
console.info('Callback invoked to indicate a successful volume setting.'); console.info('Callback invoked to indicate a successful volume setting.');
...@@ -917,7 +917,7 @@ getVolume(volumeType: AudioVolumeType, callback: AsyncCallback&lt;number&gt;): v ...@@ -917,7 +917,7 @@ getVolume(volumeType: AudioVolumeType, callback: AsyncCallback&lt;number&gt;): v
```js ```js
audioManager.getVolume(audio.AudioVolumeType.MEDIA, (err, value) => { audioManager.getVolume(audio.AudioVolumeType.MEDIA, (err, value) => {
if (err) { if (err) {
console.error(`Failed to obtain the volume. ${err.message}`); console.error(`Failed to obtain the volume. ${err}`);
return; return;
} }
console.info('Callback invoked to indicate that the volume is obtained.'); console.info('Callback invoked to indicate that the volume is obtained.');
...@@ -972,7 +972,7 @@ getMinVolume(volumeType: AudioVolumeType, callback: AsyncCallback&lt;number&gt;) ...@@ -972,7 +972,7 @@ getMinVolume(volumeType: AudioVolumeType, callback: AsyncCallback&lt;number&gt;)
```js ```js
audioManager.getMinVolume(audio.AudioVolumeType.MEDIA, (err, value) => { audioManager.getMinVolume(audio.AudioVolumeType.MEDIA, (err, value) => {
if (err) { if (err) {
console.error(`Failed to obtain the minimum volume. ${err.message}`); console.error(`Failed to obtain the minimum volume. ${err}`);
return; return;
} }
console.info(`Callback invoked to indicate that the minimum volume is obtained. ${value}`); console.info(`Callback invoked to indicate that the minimum volume is obtained. ${value}`);
...@@ -1027,7 +1027,7 @@ getMaxVolume(volumeType: AudioVolumeType, callback: AsyncCallback&lt;number&gt;) ...@@ -1027,7 +1027,7 @@ getMaxVolume(volumeType: AudioVolumeType, callback: AsyncCallback&lt;number&gt;)
```js ```js
audioManager.getMaxVolume(audio.AudioVolumeType.MEDIA, (err, value) => { audioManager.getMaxVolume(audio.AudioVolumeType.MEDIA, (err, value) => {
if (err) { if (err) {
console.error(`Failed to obtain the maximum volume. ${err.message}`); console.error(`Failed to obtain the maximum volume. ${err}`);
return; return;
} }
console.info(`Callback invoked to indicate that the maximum volume is obtained. ${value}`); console.info(`Callback invoked to indicate that the maximum volume is obtained. ${value}`);
...@@ -1087,7 +1087,7 @@ mute(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback&lt;void ...@@ -1087,7 +1087,7 @@ mute(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback&lt;void
```js ```js
audioManager.mute(audio.AudioVolumeType.MEDIA, true, (err) => { audioManager.mute(audio.AudioVolumeType.MEDIA, true, (err) => {
if (err) { if (err) {
console.error(`Failed to mute the stream. ${err.message}`); console.error(`Failed to mute the stream. ${err}`);
return; return;
} }
console.info('Callback invoked to indicate that the stream is muted.'); console.info('Callback invoked to indicate that the stream is muted.');
...@@ -1149,7 +1149,7 @@ isMute(volumeType: AudioVolumeType, callback: AsyncCallback&lt;boolean&gt;): voi ...@@ -1149,7 +1149,7 @@ isMute(volumeType: AudioVolumeType, callback: AsyncCallback&lt;boolean&gt;): voi
```js ```js
audioManager.isMute(audio.AudioVolumeType.MEDIA, (err, value) => { audioManager.isMute(audio.AudioVolumeType.MEDIA, (err, value) => {
if (err) { if (err) {
console.error(`Failed to obtain the mute status. ${err.message}`); console.error(`Failed to obtain the mute status. ${err}`);
return; return;
} }
console.info(`Callback invoked to indicate that the mute status of the stream is obtained. ${value}`); console.info(`Callback invoked to indicate that the mute status of the stream is obtained. ${value}`);
...@@ -1205,7 +1205,7 @@ isActive(volumeType: AudioVolumeType, callback: AsyncCallback&lt;boolean&gt;): v ...@@ -1205,7 +1205,7 @@ isActive(volumeType: AudioVolumeType, callback: AsyncCallback&lt;boolean&gt;): v
```js ```js
audioManager.isActive(audio.AudioVolumeType.MEDIA, (err, value) => { audioManager.isActive(audio.AudioVolumeType.MEDIA, (err, value) => {
if (err) { if (err) {
console.error(`Failed to obtain the active status of the stream. ${err.message}`); console.error(`Failed to obtain the active status of the stream. ${err}`);
return; return;
} }
console.info(`Callback invoked to indicate that the active status of the stream is obtained ${value}.`); console.info(`Callback invoked to indicate that the active status of the stream is obtained ${value}.`);
...@@ -1264,7 +1264,7 @@ setRingerMode(mode: AudioRingMode, callback: AsyncCallback&lt;void&gt;): void ...@@ -1264,7 +1264,7 @@ setRingerMode(mode: AudioRingMode, callback: AsyncCallback&lt;void&gt;): void
```js ```js
audioManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL, (err) => { audioManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL, (err) => {
if (err) { if (err) {
console.error(`Failed to set the ringer mode.​ ${err.message}`); console.error(`Failed to set the ringer mode.​ ${err}`);
return; return;
} }
console.info('Callback invoked to indicate a successful setting of the ringer mode.'); console.info('Callback invoked to indicate a successful setting of the ringer mode.');
...@@ -1323,7 +1323,7 @@ getRingerMode(callback: AsyncCallback&lt;AudioRingMode&gt;): void ...@@ -1323,7 +1323,7 @@ getRingerMode(callback: AsyncCallback&lt;AudioRingMode&gt;): void
```js ```js
audioManager.getRingerMode((err, value) => { audioManager.getRingerMode((err, value) => {
if (err) { if (err) {
console.error(`Failed to obtain the ringer mode.​ ${err.message}`); console.error(`Failed to obtain the ringer mode.​ ${err}`);
return; return;
} }
console.info(`Callback invoked to indicate that the ringer mode is obtained ${value}.`); console.info(`Callback invoked to indicate that the ringer mode is obtained ${value}.`);
...@@ -1378,7 +1378,7 @@ setAudioParameter(key: string, value: string, callback: AsyncCallback&lt;void&gt ...@@ -1378,7 +1378,7 @@ setAudioParameter(key: string, value: string, callback: AsyncCallback&lt;void&gt
```js ```js
audioManager.setAudioParameter('key_example', 'value_example', (err) => { audioManager.setAudioParameter('key_example', 'value_example', (err) => {
if (err) { if (err) {
console.error(`Failed to set the audio parameter. ${err.message}`); console.error(`Failed to set the audio parameter. ${err}`);
return; return;
} }
console.info('Callback invoked to indicate a successful setting of the audio parameter.'); console.info('Callback invoked to indicate a successful setting of the audio parameter.');
...@@ -1440,7 +1440,7 @@ getAudioParameter(key: string, callback: AsyncCallback&lt;string&gt;): void ...@@ -1440,7 +1440,7 @@ getAudioParameter(key: string, callback: AsyncCallback&lt;string&gt;): void
```js ```js
audioManager.getAudioParameter('key_example', (err, value) => { audioManager.getAudioParameter('key_example', (err, value) => {
if (err) { if (err) {
console.error(`Failed to obtain the value of the audio parameter. ${err.message}`); console.error(`Failed to obtain the value of the audio parameter. ${err}`);
return; return;
} }
console.info(`Callback invoked to indicate that the value of the audio parameter is obtained ${value}.`); console.info(`Callback invoked to indicate that the value of the audio parameter is obtained ${value}.`);
...@@ -1496,7 +1496,7 @@ getDevices(deviceFlag: DeviceFlag, callback: AsyncCallback&lt;AudioDeviceDescrip ...@@ -1496,7 +1496,7 @@ getDevices(deviceFlag: DeviceFlag, callback: AsyncCallback&lt;AudioDeviceDescrip
```js ```js
audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG, (err, value) => { audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG, (err, value) => {
if (err) { if (err) {
console.error(`Failed to obtain the device list. ${err.message}`); console.error(`Failed to obtain the device list. ${err}`);
return; return;
} }
console.info('Callback invoked to indicate that the device list is obtained.'); console.info('Callback invoked to indicate that the device list is obtained.');
...@@ -1552,7 +1552,7 @@ setDeviceActive(deviceType: ActiveDeviceType, active: boolean, callback: AsyncCa ...@@ -1552,7 +1552,7 @@ setDeviceActive(deviceType: ActiveDeviceType, active: boolean, callback: AsyncCa
```js ```js
audioManager.setDeviceActive(audio.ActiveDeviceType.SPEAKER, true, (err) => { audioManager.setDeviceActive(audio.ActiveDeviceType.SPEAKER, true, (err) => {
if (err) { if (err) {
console.error(`Failed to set the active status of the device. ${err.message}`); console.error(`Failed to set the active status of the device. ${err}`);
return; return;
} }
console.info('Callback invoked to indicate that the device is set to the active status.'); console.info('Callback invoked to indicate that the device is set to the active status.');
...@@ -1609,7 +1609,7 @@ isDeviceActive(deviceType: ActiveDeviceType, callback: AsyncCallback&lt;boolean& ...@@ -1609,7 +1609,7 @@ isDeviceActive(deviceType: ActiveDeviceType, callback: AsyncCallback&lt;boolean&
```js ```js
audioManager.isDeviceActive(audio.ActiveDeviceType.SPEAKER, (err, value) => { audioManager.isDeviceActive(audio.ActiveDeviceType.SPEAKER, (err, value) => {
if (err) { if (err) {
console.error(`Failed to obtain the active status of the device. ${err.message}`); console.error(`Failed to obtain the active status of the device. ${err}`);
return; return;
} }
console.info('Callback invoked to indicate that the active status of the device is obtained.'); console.info('Callback invoked to indicate that the active status of the device is obtained.');
...@@ -1667,7 +1667,7 @@ setMicrophoneMute(mute: boolean, callback: AsyncCallback&lt;void&gt;): void ...@@ -1667,7 +1667,7 @@ setMicrophoneMute(mute: boolean, callback: AsyncCallback&lt;void&gt;): void
```js ```js
audioManager.setMicrophoneMute(true, (err) => { audioManager.setMicrophoneMute(true, (err) => {
if (err) { if (err) {
console.error(`Failed to mute the microphone. ${err.message}`); console.error(`Failed to mute the microphone. ${err}`);
return; return;
} }
console.info('Callback invoked to indicate that the microphone is muted.'); console.info('Callback invoked to indicate that the microphone is muted.');
...@@ -1725,7 +1725,7 @@ isMicrophoneMute(callback: AsyncCallback&lt;boolean&gt;): void ...@@ -1725,7 +1725,7 @@ isMicrophoneMute(callback: AsyncCallback&lt;boolean&gt;): void
```js ```js
audioManager.isMicrophoneMute((err, value) => { audioManager.isMicrophoneMute((err, value) => {
if (err) { if (err) {
console.error(`Failed to obtain the mute status of the microphone. ${err.message}`); console.error(`Failed to obtain the mute status of the microphone. ${err}`);
return; return;
} }
console.info(`Callback invoked to indicate that the mute status of the microphone is obtained ${value}.`); console.info(`Callback invoked to indicate that the mute status of the microphone is obtained ${value}.`);
...@@ -1950,7 +1950,7 @@ setAudioScene\(scene: AudioScene, callback: AsyncCallback<void\>\): void ...@@ -1950,7 +1950,7 @@ setAudioScene\(scene: AudioScene, callback: AsyncCallback<void\>\): void
```js ```js
audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_PHONE_CALL, (err) => { audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_PHONE_CALL, (err) => {
if (err) { if (err) {
console.error(`Failed to set the audio scene mode.​ ${err.message}`); console.error(`Failed to set the audio scene mode.​ ${err}`);
return; return;
} }
console.info('Callback invoked to indicate a successful setting of the audio scene mode.'); console.info('Callback invoked to indicate a successful setting of the audio scene mode.');
...@@ -1985,7 +1985,7 @@ setAudioScene\(scene: AudioScene\): Promise<void\> ...@@ -1985,7 +1985,7 @@ setAudioScene\(scene: AudioScene\): Promise<void\>
audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_PHONE_CALL).then(() => { audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_PHONE_CALL).then(() => {
console.info('Promise returned to indicate a successful setting of the audio scene mode.'); console.info('Promise returned to indicate a successful setting of the audio scene mode.');
}).catch ((err) => { }).catch ((err) => {
console.error(`Failed to set the audio scene mode ${err.message}`); console.error(`Failed to set the audio scene mode ${err}`);
}); });
``` ```
...@@ -2008,7 +2008,7 @@ getAudioScene\(callback: AsyncCallback<AudioScene\>\): void ...@@ -2008,7 +2008,7 @@ getAudioScene\(callback: AsyncCallback<AudioScene\>\): void
```js ```js
audioManager.getAudioScene((err, value) => { audioManager.getAudioScene((err, value) => {
if (err) { if (err) {
console.error(`Failed to obtain the audio scene mode.​ ${err.message}`); console.error(`Failed to obtain the audio scene mode.​ ${err}`);
return; return;
} }
console.info(`Callback invoked to indicate that the audio scene mode is obtained ${value}.`); console.info(`Callback invoked to indicate that the audio scene mode is obtained ${value}.`);
...@@ -2036,7 +2036,7 @@ getAudioScene\(\): Promise<AudioScene\> ...@@ -2036,7 +2036,7 @@ getAudioScene\(\): Promise<AudioScene\>
audioManager.getAudioScene().then((value) => { audioManager.getAudioScene().then((value) => {
console.info(`Promise returned to indicate that the audio scene mode is obtained ${value}.`); console.info(`Promise returned to indicate that the audio scene mode is obtained ${value}.`);
}).catch ((err) => { }).catch ((err) => {
console.error(`Failed to obtain the audio scene mode ${err.message}`); console.error(`Failed to obtain the audio scene mode ${err}`);
}); });
``` ```
...@@ -2061,7 +2061,7 @@ getVolumeGroups(networkId: string, callback: AsyncCallback<VolumeGroupInfos\>\): ...@@ -2061,7 +2061,7 @@ getVolumeGroups(networkId: string, callback: AsyncCallback<VolumeGroupInfos\>\):
```js ```js
audioManager.getVolumeGroups(audio.LOCAL_NETWORK_ID, (err, value) => { audioManager.getVolumeGroups(audio.LOCAL_NETWORK_ID, (err, value) => {
if (err) { if (err) {
console.error(`Failed to obtain the volume group infos list. ${err.message}`); console.error(`Failed to obtain the volume group infos list. ${err}`);
return; return;
} }
console.info('Callback invoked to indicate that the volume group infos list is obtained.'); console.info('Callback invoked to indicate that the volume group infos list is obtained.');
...@@ -2125,7 +2125,7 @@ async function getGroupManager(){ ...@@ -2125,7 +2125,7 @@ async function getGroupManager(){
let groupid = value[0].groupId; let groupid = value[0].groupId;
audioManager.getGroupManager(groupid, (err, value) => { audioManager.getGroupManager(groupid, (err, value) => {
if (err) { if (err) {
console.error(`Failed to obtain the volume group infos list. ${err.message}`); console.error(`Failed to obtain the volume group infos list. ${err}`);
return; return;
} }
audioGroupManager = value audioGroupManager = value
...@@ -2202,10 +2202,10 @@ setVolume(volumeType: AudioVolumeType, volume: number, callback: AsyncCallback&l ...@@ -2202,10 +2202,10 @@ setVolume(volumeType: AudioVolumeType, volume: number, callback: AsyncCallback&l
```js ```js
audioGroupManager.setVolume(audio.AudioVolumeType.MEDIA, 10, (err) => { audioGroupManager.setVolume(audio.AudioVolumeType.MEDIA, 10, (err) => {
if (err) { if (err) {
console.error(`Failed to set the volume. ${err.message}`); console.error(`Failed to set the volume. ${err}`);
return; return;
} }
console.log(`Callback invoked to indicate a successful volume setting.`); console.info('Callback invoked to indicate a successful volume setting.');
}); });
``` ```
...@@ -2238,7 +2238,7 @@ setVolume(volumeType: AudioVolumeType, volume: number): Promise&lt;void&gt; ...@@ -2238,7 +2238,7 @@ setVolume(volumeType: AudioVolumeType, volume: number): Promise&lt;void&gt;
```js ```js
audioGroupManager.setVolume(audio.AudioVolumeType.MEDIA, 10).then(() => { audioGroupManager.setVolume(audio.AudioVolumeType.MEDIA, 10).then(() => {
console.log(`Promise returned to indicate a successful volume setting.`); console.info('Promise returned to indicate a successful volume setting.');
}); });
``` ```
...@@ -2262,10 +2262,10 @@ getVolume(volumeType: AudioVolumeType, callback: AsyncCallback&lt;number&gt;): v ...@@ -2262,10 +2262,10 @@ getVolume(volumeType: AudioVolumeType, callback: AsyncCallback&lt;number&gt;): v
```js ```js
audioGroupManager.getVolume(audio.AudioVolumeType.MEDIA, (err, value) => { audioGroupManager.getVolume(audio.AudioVolumeType.MEDIA, (err, value) => {
if (err) { if (err) {
console.error(`Failed to obtain the volume. ${err.message}`); console.error(`Failed to obtain the volume. ${err}`);
return; return;
} }
console.log(`Callback invoked to indicate that the volume is obtained.`); console.info('Callback invoked to indicate that the volume is obtained.');
}); });
``` ```
...@@ -2293,7 +2293,7 @@ getVolume(volumeType: AudioVolumeType): Promise&lt;number&gt; ...@@ -2293,7 +2293,7 @@ getVolume(volumeType: AudioVolumeType): Promise&lt;number&gt;
```js ```js
audioGroupManager.getVolume(audio.AudioVolumeType.MEDIA).then((value) => { audioGroupManager.getVolume(audio.AudioVolumeType.MEDIA).then((value) => {
console.log(`Promise returned to indicate that the volume is obtained.` + value); console.info(`Promise returned to indicate that the volume is obtained ${value}.`);
}); });
``` ```
...@@ -2317,10 +2317,10 @@ getMinVolume(volumeType: AudioVolumeType, callback: AsyncCallback&lt;number&gt;) ...@@ -2317,10 +2317,10 @@ getMinVolume(volumeType: AudioVolumeType, callback: AsyncCallback&lt;number&gt;)
```js ```js
audioGroupManager.getMinVolume(audio.AudioVolumeType.MEDIA, (err, value) => { audioGroupManager.getMinVolume(audio.AudioVolumeType.MEDIA, (err, value) => {
if (err) { if (err) {
console.error(`Failed to obtain the minimum volume. ${err.message}`); console.error(`Failed to obtain the minimum volume. ${err}`);
return; return;
} }
console.log(`Callback invoked to indicate that the minimum volume is obtained.` + value); console.info(`Callback invoked to indicate that the minimum volume is obtained. ${value}`);
}); });
``` ```
...@@ -2348,7 +2348,7 @@ getMinVolume(volumeType: AudioVolumeType): Promise&lt;number&gt; ...@@ -2348,7 +2348,7 @@ getMinVolume(volumeType: AudioVolumeType): Promise&lt;number&gt;
```js ```js
audioGroupManager.getMinVolume(audio.AudioVolumeType.MEDIA).then((value) => { audioGroupManager.getMinVolume(audio.AudioVolumeType.MEDIA).then((value) => {
console.log(`Promised returned to indicate that the minimum volume is obtained.` + value); console.info(`Promised returned to indicate that the minimum volume is obtained ${value}.`);
}); });
``` ```
...@@ -2372,10 +2372,10 @@ getMaxVolume(volumeType: AudioVolumeType, callback: AsyncCallback&lt;number&gt;) ...@@ -2372,10 +2372,10 @@ getMaxVolume(volumeType: AudioVolumeType, callback: AsyncCallback&lt;number&gt;)
```js ```js
audioGroupManager.getMaxVolume(audio.AudioVolumeType.MEDIA, (err, value) => { audioGroupManager.getMaxVolume(audio.AudioVolumeType.MEDIA, (err, value) => {
if (err) { if (err) {
console.error(`Failed to obtain the maximum volume. ${err.message}`); console.error(`Failed to obtain the maximum volume. ${err}`);
return; return;
} }
console.log(`Callback invoked to indicate that the maximum volume is obtained.` + value); console.info(`Callback invoked to indicate that the maximum volume is obtained. ${value}`);
}); });
``` ```
...@@ -2403,7 +2403,7 @@ getMaxVolume(volumeType: AudioVolumeType): Promise&lt;number&gt; ...@@ -2403,7 +2403,7 @@ getMaxVolume(volumeType: AudioVolumeType): Promise&lt;number&gt;
```js ```js
audioGroupManager.getMaxVolume(audio.AudioVolumeType.MEDIA).then((data) => { audioGroupManager.getMaxVolume(audio.AudioVolumeType.MEDIA).then((data) => {
console.log(`Promised returned to indicate that the maximum volume is obtained.`); console.info('Promised returned to indicate that the maximum volume is obtained.');
}); });
``` ```
...@@ -2432,10 +2432,10 @@ mute(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback&lt;void ...@@ -2432,10 +2432,10 @@ mute(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback&lt;void
```js ```js
audioGroupManager.mute(audio.AudioVolumeType.MEDIA, true, (err) => { audioGroupManager.mute(audio.AudioVolumeType.MEDIA, true, (err) => {
if (err) { if (err) {
console.error(`Failed to mute the stream. ${err.message}`); console.error(`Failed to mute the stream. ${err}`);
return; return;
} }
console.log(`Callback invoked to indicate that the stream is muted.`); console.info('Callback invoked to indicate that the stream is muted.');
}); });
``` ```
...@@ -2468,7 +2468,7 @@ mute(volumeType: AudioVolumeType, mute: boolean): Promise&lt;void&gt; ...@@ -2468,7 +2468,7 @@ mute(volumeType: AudioVolumeType, mute: boolean): Promise&lt;void&gt;
```js ```js
audioGroupManager.mute(audio.AudioVolumeType.MEDIA, true).then(() => { audioGroupManager.mute(audio.AudioVolumeType.MEDIA, true).then(() => {
console.log(`Promise returned to indicate that the stream is muted.`); console.info('Promise returned to indicate that the stream is muted.');
}); });
``` ```
...@@ -2492,10 +2492,10 @@ isMute(volumeType: AudioVolumeType, callback: AsyncCallback&lt;boolean&gt;): voi ...@@ -2492,10 +2492,10 @@ isMute(volumeType: AudioVolumeType, callback: AsyncCallback&lt;boolean&gt;): voi
```js ```js
audioGroupManager.isMute(audio.AudioVolumeType.MEDIA, (err, value) => { audioGroupManager.isMute(audio.AudioVolumeType.MEDIA, (err, value) => {
if (err) { if (err) {
console.error(`Failed to obtain the mute status. ${err.message}`); console.error(`Failed to obtain the mute status. ${err}`);
return; return;
} }
console.log(`Callback invoked to indicate that the mute status of the stream is obtained.` + value); console.info(`Callback invoked to indicate that the mute status of the stream is obtained ${value}.`);
}); });
``` ```
...@@ -2523,7 +2523,7 @@ isMute(volumeType: AudioVolumeType): Promise&lt;boolean&gt; ...@@ -2523,7 +2523,7 @@ isMute(volumeType: AudioVolumeType): Promise&lt;boolean&gt;
```js ```js
audioGroupManager.isMute(audio.AudioVolumeType.MEDIA).then((value) => { audioGroupManager.isMute(audio.AudioVolumeType.MEDIA).then((value) => {
console.log(`Promise returned to indicate that the mute status of the stream is obtained.` + value); console.info(`Promise returned to indicate that the mute status of the stream is obtained ${value}.`);
}); });
``` ```
...@@ -2551,7 +2551,7 @@ getCurrentAudioRendererInfoArray(callback: AsyncCallback&lt;AudioRendererChangeI ...@@ -2551,7 +2551,7 @@ getCurrentAudioRendererInfoArray(callback: AsyncCallback&lt;AudioRendererChangeI
let audioStreamManager; let audioStreamManager;
audio.getStreamManager((err, data) => { audio.getStreamManager((err, data) => {
if (err) { if (err) {
console.error(`getStreamManager : Error: ${err.message}`); console.error(`getStreamManager : Error: ${err}`);
} else { } else {
console.info('getStreamManager : Success : SUCCESS'); console.info('getStreamManager : Success : SUCCESS');
audioStreamManager = data; audioStreamManager = data;
...@@ -2561,7 +2561,7 @@ audio.getStreamManager((err, data) => { ...@@ -2561,7 +2561,7 @@ audio.getStreamManager((err, data) => {
audioStreamManager.getCurrentAudioRendererInfoArray(async (err, AudioRendererChangeInfoArray) => { audioStreamManager.getCurrentAudioRendererInfoArray(async (err, AudioRendererChangeInfoArray) => {
console.info('getCurrentAudioRendererInfoArray **** Get Callback Called ****'); console.info('getCurrentAudioRendererInfoArray **** Get Callback Called ****');
if (err) { if (err) {
console.error(`getCurrentAudioRendererInfoArray :ERROR: ${err.message}`); console.error(`getCurrentAudioRendererInfoArray :ERROR: ${err}`);
} else { } else {
if (AudioRendererChangeInfoArray != null) { if (AudioRendererChangeInfoArray != null) {
for (let i = 0; i < AudioRendererChangeInfoArray.length; i++) { for (let i = 0; i < AudioRendererChangeInfoArray.length; i++) {
...@@ -2608,7 +2608,7 @@ getCurrentAudioRendererInfoArray(): Promise&lt;AudioRendererChangeInfoArray&gt; ...@@ -2608,7 +2608,7 @@ getCurrentAudioRendererInfoArray(): Promise&lt;AudioRendererChangeInfoArray&gt;
let audioStreamManager; let audioStreamManager;
audio.getStreamManager((err, data) => { audio.getStreamManager((err, data) => {
if (err) { if (err) {
console.error(`getStreamManager : Error: ${err.message}`); console.error(`getStreamManager : Error: ${err}`);
} else { } else {
console.info('getStreamManager : Success : SUCCESS'); console.info('getStreamManager : Success : SUCCESS');
audioStreamManager = data; audioStreamManager = data;
...@@ -2639,7 +2639,7 @@ await audioStreamManager.getCurrentAudioRendererInfoArray().then( function (Audi ...@@ -2639,7 +2639,7 @@ await audioStreamManager.getCurrentAudioRendererInfoArray().then( function (Audi
} }
} }
}).catch((err) => { }).catch((err) => {
console.error(`getCurrentAudioRendererInfoArray :ERROR: ${err.message}`); console.error(`getCurrentAudioRendererInfoArray :ERROR: ${err}`);
}); });
``` ```
...@@ -2663,7 +2663,7 @@ getCurrentAudioCapturerInfoArray(callback: AsyncCallback&lt;AudioCapturerChangeI ...@@ -2663,7 +2663,7 @@ getCurrentAudioCapturerInfoArray(callback: AsyncCallback&lt;AudioCapturerChangeI
let audioStreamManager; let audioStreamManager;
audio.getStreamManager((err, data) => { audio.getStreamManager((err, data) => {
if (err) { if (err) {
console.error(`getStreamManager : Error: ${err.message}`); console.error(`getStreamManager : Error: ${err}`);
} else { } else {
console.info('getStreamManager : Success : SUCCESS'); console.info('getStreamManager : Success : SUCCESS');
audioStreamManager = data; audioStreamManager = data;
...@@ -2673,7 +2673,7 @@ audio.getStreamManager((err, data) => { ...@@ -2673,7 +2673,7 @@ audio.getStreamManager((err, data) => {
audioStreamManager.getCurrentAudioCapturerInfoArray(async (err, AudioCapturerChangeInfoArray) => { audioStreamManager.getCurrentAudioCapturerInfoArray(async (err, AudioCapturerChangeInfoArray) => {
console.info('getCurrentAudioCapturerInfoArray **** Get Callback Called ****'); console.info('getCurrentAudioCapturerInfoArray **** Get Callback Called ****');
if (err) { if (err) {
console.error(`getCurrentAudioCapturerInfoArray :ERROR: ${err.message}`); console.error(`getCurrentAudioCapturerInfoArray :ERROR: ${err}`);
} else { } else {
if (AudioCapturerChangeInfoArray != null) { if (AudioCapturerChangeInfoArray != null) {
for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) {
...@@ -2718,7 +2718,7 @@ getCurrentAudioCapturerInfoArray(): Promise&lt;AudioCapturerChangeInfoArray&gt; ...@@ -2718,7 +2718,7 @@ getCurrentAudioCapturerInfoArray(): Promise&lt;AudioCapturerChangeInfoArray&gt;
let audioStreamManager; let audioStreamManager;
audio.getStreamManager((err, data) => { audio.getStreamManager((err, data) => {
if (err) { if (err) {
console.error(`getStreamManager : Error: ${err.message}`); console.error(`getStreamManager : Error: ${err}`);
} else { } else {
console.info('getStreamManager : Success : SUCCESS'); console.info('getStreamManager : Success : SUCCESS');
audioStreamManager = data; audioStreamManager = data;
...@@ -2747,7 +2747,7 @@ await audioStreamManager.getCurrentAudioCapturerInfoArray().then( function (Audi ...@@ -2747,7 +2747,7 @@ await audioStreamManager.getCurrentAudioCapturerInfoArray().then( function (Audi
} }
} }
}).catch((err) => { }).catch((err) => {
console.error(`getCurrentAudioCapturerInfoArray :ERROR: ${err.message}`); console.error(`getCurrentAudioCapturerInfoArray :ERROR: ${err}`);
}); });
``` ```
...@@ -2772,7 +2772,7 @@ on(type: "audioRendererChange", callback: Callback&lt;AudioRendererChangeInfoArr ...@@ -2772,7 +2772,7 @@ on(type: "audioRendererChange", callback: Callback&lt;AudioRendererChangeInfoArr
let audioStreamManager; let audioStreamManager;
audio.getStreamManager((err, data) => { audio.getStreamManager((err, data) => {
if (err) { if (err) {
console.error(`getStreamManager : Error: ${err.message}`); console.error(`getStreamManager : Error: ${err}`);
} else { } else {
console.info('getStreamManager : Success : SUCCESS'); console.info('getStreamManager : Success : SUCCESS');
audioStreamManager = data; audioStreamManager = data;
...@@ -2823,7 +2823,7 @@ off(type: "audioRendererChange"); ...@@ -2823,7 +2823,7 @@ off(type: "audioRendererChange");
let audioStreamManager; let audioStreamManager;
audio.getStreamManager((err, data) => { audio.getStreamManager((err, data) => {
if (err) { if (err) {
console.error(`getStreamManager : Error: ${err.message}`); console.error(`getStreamManager : Error: ${err}`);
} else { } else {
console.info('getStreamManager : Success : SUCCESS'); console.info('getStreamManager : Success : SUCCESS');
audioStreamManager = data; audioStreamManager = data;
...@@ -2855,7 +2855,7 @@ on(type: "audioCapturerChange", callback: Callback&lt;AudioCapturerChangeInfoArr ...@@ -2855,7 +2855,7 @@ on(type: "audioCapturerChange", callback: Callback&lt;AudioCapturerChangeInfoArr
let audioStreamManager; let audioStreamManager;
audio.getStreamManager((err, data) => { audio.getStreamManager((err, data) => {
if (err) { if (err) {
console.error(`getStreamManager : Error: ${err.message}`); console.error(`getStreamManager : Error: ${err}`);
} else { } else {
console.info('getStreamManager : Success : SUCCESS'); console.info('getStreamManager : Success : SUCCESS');
audioStreamManager = data; audioStreamManager = data;
...@@ -2905,7 +2905,7 @@ off(type: "audioCapturerChange"); ...@@ -2905,7 +2905,7 @@ off(type: "audioCapturerChange");
let audioStreamManager; let audioStreamManager;
audio.getStreamManager((err, data) => { audio.getStreamManager((err, data) => {
if (err) { if (err) {
console.error(`getStreamManager : Error: ${err.message}`); console.error(`getStreamManager : Error: ${err}`);
} else { } else {
console.info('getStreamManager : Success : SUCCESS'); console.info('getStreamManager : Success : SUCCESS');
audioStreamManager = data; audioStreamManager = data;
...@@ -2941,15 +2941,15 @@ getDevices(deviceFlag: DeviceFlag, callback: AsyncCallback&lt;AudioDeviceDescrip ...@@ -2941,15 +2941,15 @@ getDevices(deviceFlag: DeviceFlag, callback: AsyncCallback&lt;AudioDeviceDescrip
```js ```js
audioManager.getRoutingManager((err,AudioRoutingManager)=>{ audioManager.getRoutingManager((err,AudioRoutingManager)=>{
if (err) { if (err) {
console.error(`AudioFrameworkTest:Callback:failed to get RoutingManager ${err.message}`); console.error(`AudioFrameworkTest:Callback:failed to get RoutingManager ${err}`);
} }
else { else {
AudioRoutingManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG, (err, value) => { AudioRoutingManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG, (err, value) => {
if (err) { if (err) {
console.error(`Failed to obtain the device list. ${err.message}`); console.error(`Failed to obtain the device list. ${err}`);
return; return;
} }
console.log(`Callback invoked to indicate that the device list is obtained.`); console.info('Callback invoked to indicate that the device list is obtained.');
}); });
} }
}) })
...@@ -2980,11 +2980,11 @@ getDevices(deviceFlag: DeviceFlag): Promise&lt;AudioDeviceDescriptors&gt; ...@@ -2980,11 +2980,11 @@ getDevices(deviceFlag: DeviceFlag): Promise&lt;AudioDeviceDescriptors&gt;
```js ```js
audioManager.getRoutingManager((err,AudioRoutingManager)=>{ audioManager.getRoutingManager((err,AudioRoutingManager)=>{
if (err) { if (err) {
console.error(`AudioFrameworkTest:Callback:failed to get RoutingManager ${err.message}`); console.error(`AudioFrameworkTest:Callback:failed to get RoutingManager ${err}`);
} }
else { else {
AudioRoutingManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG).then((data) => { AudioRoutingManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG).then((data) => {
console.log(`Promise returned to indicate that the device list is obtained.`); console.info('Promise returned to indicate that the device list is obtained.');
}); });
} }
}); });
...@@ -2992,7 +2992,7 @@ audioManager.getRoutingManager((err,AudioRoutingManager)=>{ ...@@ -2992,7 +2992,7 @@ audioManager.getRoutingManager((err,AudioRoutingManager)=>{
### on<sup>9+</sup> ### on<sup>9+</sup>
on(type: 'deviceChange', deviceFlag: DeviceFlag,, callback: Callback<DeviceChangeAction\>): void on(type: 'deviceChange', deviceFlag: DeviceFlag, callback: Callback<DeviceChangeAction\>): void
设备更改。音频设备连接状态变化。 设备更改。音频设备连接状态变化。
...@@ -3011,7 +3011,7 @@ on(type: 'deviceChange', deviceFlag: DeviceFlag,, callback: Callback<DeviceChang ...@@ -3011,7 +3011,7 @@ on(type: 'deviceChange', deviceFlag: DeviceFlag,, callback: Callback<DeviceChang
```js ```js
audioManager.getRoutingManager((err,AudioRoutingManager)=>{ audioManager.getRoutingManager((err,AudioRoutingManager)=>{
if (err) { if (err) {
console.error(`AudioFrameworkTest:Callback:failed to get RoutingManager ${err.message}`); console.error(`AudioFrameworkTest:Callback:failed to get RoutingManager ${err}`);
} }
else { else {
AudioRoutingManager.on('deviceChange', audio.DeviceFlag.OUTPUT_DEVICES_FLAG, (deviceChanged) => { AudioRoutingManager.on('deviceChange', audio.DeviceFlag.OUTPUT_DEVICES_FLAG, (deviceChanged) => {
...@@ -3045,11 +3045,11 @@ off(type: 'deviceChange', callback?: Callback<DeviceChangeAction\>): void ...@@ -3045,11 +3045,11 @@ off(type: 'deviceChange', callback?: Callback<DeviceChangeAction\>): void
```js ```js
audioManager.getRoutingManager((err,AudioRoutingManager)=>{ audioManager.getRoutingManager((err,AudioRoutingManager)=>{
if (err) { if (err) {
console.error(`AudioFrameworkTest:Callback:failed to get RoutingManager ${err.message}`); console.error(`AudioFrameworkTest:Callback:failed to get RoutingManager ${err}`);
} }
else { else {
AudioRoutingManager.off('deviceChange', audio.DeviceFlag.OUTPUT_DEVICES_FLAG, (deviceChanged) => { AudioRoutingManager.off('deviceChange', audio.DeviceFlag.OUTPUT_DEVICES_FLAG, (deviceChanged) => {
console.log('Should be no callback.'); console.info('Should be no callback.');
}); });
} }
}); });
...@@ -3084,7 +3084,7 @@ await audioManager.getRoutingManager().then((value) => { ...@@ -3084,7 +3084,7 @@ await audioManager.getRoutingManager().then((value) => {
audioRoutingManager = value; audioRoutingManager = value;
audioRoutingManager.selectOutputDevice(outputAudioDeviceDescriptor, (err) => { audioRoutingManager.selectOutputDevice(outputAudioDeviceDescriptor, (err) => {
if (err) { if (err) {
console.error(`Result ERROR: ${err.message}`); console.error(`Result ERROR: ${err}`);
} else { } else {
console.info('Select output devices result callback: SUCCESS'); } console.info('Select output devices result callback: SUCCESS'); }
}); });
...@@ -3127,14 +3127,14 @@ await audioManager.getRoutingManager().then((value) => { ...@@ -3127,14 +3127,14 @@ await audioManager.getRoutingManager().then((value) => {
audioRoutingManager.selectOutputDevice(outputAudioDeviceDescriptor).then(() => { audioRoutingManager.selectOutputDevice(outputAudioDeviceDescriptor).then(() => {
console.info('Select output devices result promise: SUCCESS'); console.info('Select output devices result promise: SUCCESS');
}).catch((err) => { }).catch((err) => {
console.error(`Result ERROR: ${err.message}`); console.error(`Result ERROR: ${err}`);
}); });
}); });
``` ```
### selectOutputDeviceByFilter<sup>9+</sup> ### selectOutputDeviceByFilter<sup>9+</sup>
selectOutputDeviceByFilter(audiorendererfilter: AudioRendererFilter, outputAudioDevices: AudioDeviceDescriptors, callback: AsyncCallback&lt;void&gt;): void selectOutputDeviceByFilter(filter: AudioRendererFilter, outputAudioDevices: AudioDeviceDescriptors, callback: AsyncCallback&lt;void&gt;): void
**系统接口:** 该接口为系统接口 **系统接口:** 该接口为系统接口
...@@ -3146,7 +3146,7 @@ selectOutputDeviceByFilter(audiorendererfilter: AudioRendererFilter, outputAudio ...@@ -3146,7 +3146,7 @@ selectOutputDeviceByFilter(audiorendererfilter: AudioRendererFilter, outputAudio
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| --------------------------- | ------------------------------------------------------------ | ---- | ------------------------- | | --------------------------- | ------------------------------------------------------------ | ---- | ------------------------- |
| audiorendererfilter | [AudioRendererFilter](#audiorendererfilter9) | 是 | 过滤条件类。 | | filter | [AudioRendererFilter](#audiorendererfilter9) | 是 | 过滤条件类。 |
| outputAudioDevices | [AudioDeviceDescriptors](#audiodevicedescriptors) | 是 | 输出设备类。 | | outputAudioDevices | [AudioDeviceDescriptors](#audiodevicedescriptors) | 是 | 输出设备类。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调,返回获取输出设备结果。 | | callback | AsyncCallback&lt;void&gt; | 是 | 回调,返回获取输出设备结果。 |
...@@ -3169,7 +3169,7 @@ await audioManager.getRoutingManager().then((value) => { ...@@ -3169,7 +3169,7 @@ await audioManager.getRoutingManager().then((value) => {
audioRoutingManager = value; audioRoutingManager = value;
audioRoutingManager.selectOutputDeviceByFilter(outputAudioRendererFilter, outputAudioDeviceDescriptor, (err) => { audioRoutingManager.selectOutputDeviceByFilter(outputAudioRendererFilter, outputAudioDeviceDescriptor, (err) => {
if (err) { if (err) {
console.error(`Result ERROR: ${err.message}`); console.error(`Result ERROR: ${err}`);
} else { } else {
console.info('Select output devices by filter result callback: SUCCESS'); } console.info('Select output devices by filter result callback: SUCCESS'); }
}); });
...@@ -3178,7 +3178,7 @@ await audioManager.getRoutingManager().then((value) => { ...@@ -3178,7 +3178,7 @@ await audioManager.getRoutingManager().then((value) => {
### selectOutputDeviceByFilter<sup>9+</sup> ### selectOutputDeviceByFilter<sup>9+</sup>
selectOutputDeviceByFilter(audiorendererfilter: AudioRendererFilter, outputAudioDevices: AudioDeviceDescriptors): Promise&lt;void&gt; selectOutputDeviceByFilter(filter: AudioRendererFilter, outputAudioDevices: AudioDeviceDescriptors): Promise&lt;void&gt;
**系统接口:** 该接口为系统接口 **系统接口:** 该接口为系统接口
...@@ -3189,8 +3189,8 @@ selectOutputDeviceByFilter(audiorendererfilter: AudioRendererFilter, outputAudio ...@@ -3189,8 +3189,8 @@ selectOutputDeviceByFilter(audiorendererfilter: AudioRendererFilter, outputAudio
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ---------------------------- | ------------------------------------------------------------ | ---- | ------------------------- | | ----------------------| ------------------------------------------------------------ | ---- | ------------------------- |
| audiorendererfilter | [AudioRendererFilter](#audiorendererfilter9) | 是 | 过滤条件类。 | | filter | [AudioRendererFilter](#audiorendererfilter9) | 是 | 过滤条件类。 |
| outputAudioDevices | [AudioDeviceDescriptors](#audiodevicedescriptors) | 是 | 输出设备类。 | | outputAudioDevices | [AudioDeviceDescriptors](#audiodevicedescriptors) | 是 | 输出设备类。 |
**返回值:** **返回值:**
...@@ -3220,7 +3220,7 @@ await audioManager.getRoutingManager().then((value) => { ...@@ -3220,7 +3220,7 @@ await audioManager.getRoutingManager().then((value) => {
audioRoutingManager.selectOutputDeviceByFilter(outputAudioRendererFilter, outputAudioDeviceDescriptor).then(() => { audioRoutingManager.selectOutputDeviceByFilter(outputAudioRendererFilter, outputAudioDeviceDescriptor).then(() => {
console.info('Select output devices by filter result promise: SUCCESS'); console.info('Select output devices by filter result promise: SUCCESS');
}).catch((err) => { }).catch((err) => {
console.error(`Result ERROR: ${err.message}`); console.error(`Result ERROR: ${err}`);
}) })
}); });
``` ```
...@@ -3257,12 +3257,12 @@ await audioManager.getStreamManager().then(async function (data) { ...@@ -3257,12 +3257,12 @@ await audioManager.getStreamManager().then(async function (data) {
audioStreamManager = data; audioStreamManager = data;
console.info('Get AudioStream Manager : Success'); console.info('Get AudioStream Manager : Success');
}).catch((err) => { }).catch((err) => {
console.error(`Get AudioStream Manager : ERROR : ${err.message}`); console.error(`Get AudioStream Manager : ERROR : ${err}`);
}); });
audioManager.getStreamManager((err, data) => { audioManager.getStreamManager((err, data) => {
if (err) { if (err) {
console.error(`Get AudioStream Manager : ERROR : ${err.message}`); console.error(`Get AudioStream Manager : ERROR : ${err}`);
} else { } else {
audioStreamManagerCB = data; audioStreamManagerCB = data;
console.info('Get AudioStream Manager : Success'); console.info('Get AudioStream Manager : Success');
...@@ -3490,7 +3490,7 @@ audioRenderer.getRendererInfo().then((rendererInfo) => { ...@@ -3490,7 +3490,7 @@ audioRenderer.getRendererInfo().then((rendererInfo) => {
console.info(`Renderer usage: ${rendererInfo.usage}`); console.info(`Renderer usage: ${rendererInfo.usage}`);
console.info(`Renderer flags: ${rendererInfo.rendererFlags}`) console.info(`Renderer flags: ${rendererInfo.rendererFlags}`)
}).catch((err) => { }).catch((err) => {
console.error(`AudioFrameworkRenderLog: RendererInfo :ERROR: ${err.message}`); console.error(`AudioFrameworkRenderLog: RendererInfo :ERROR: ${err}`);
}); });
``` ```
...@@ -3544,7 +3544,7 @@ audioRenderer.getStreamInfo().then((streamInfo) => { ...@@ -3544,7 +3544,7 @@ audioRenderer.getStreamInfo().then((streamInfo) => {
console.info(`Renderer format: ${streamInfo.sampleFormat}`); console.info(`Renderer format: ${streamInfo.sampleFormat}`);
console.info(`Renderer encoding type: ${streamInfo.encodingType}`); console.info(`Renderer encoding type: ${streamInfo.encodingType}`);
}).catch((err) => { }).catch((err) => {
console.error(`ERROR: ${err.message}`); console.error(`ERROR: ${err}`);
}); });
``` ```
...@@ -3594,7 +3594,7 @@ start(): Promise<void\> ...@@ -3594,7 +3594,7 @@ start(): Promise<void\>
audioRenderer.start().then(() => { audioRenderer.start().then(() => {
console.info('Renderer started'); console.info('Renderer started');
}).catch((err) => { }).catch((err) => {
console.error(`ERROR: ${err.message}`); console.error(`ERROR: ${err}`);
}); });
``` ```
...@@ -3644,7 +3644,7 @@ pause(): Promise\<void> ...@@ -3644,7 +3644,7 @@ pause(): Promise\<void>
audioRenderer.pause().then(() => { audioRenderer.pause().then(() => {
console.info('Renderer paused'); console.info('Renderer paused');
}).catch((err) => { }).catch((err) => {
console.error(`ERROR: ${err.message}`); console.error(`ERROR: ${err}`);
}); });
``` ```
...@@ -3694,7 +3694,7 @@ drain(): Promise\<void> ...@@ -3694,7 +3694,7 @@ drain(): Promise\<void>
audioRenderer.drain().then(() => { audioRenderer.drain().then(() => {
console.info('Renderer drained successfully'); console.info('Renderer drained successfully');
}).catch((err) => { }).catch((err) => {
console.error(`ERROR: ${err.message}`); console.error(`ERROR: ${err}`);
}); });
``` ```
...@@ -3744,7 +3744,7 @@ stop(): Promise\<void> ...@@ -3744,7 +3744,7 @@ stop(): Promise\<void>
audioRenderer.stop().then(() => { audioRenderer.stop().then(() => {
console.info('Renderer stopped successfully'); console.info('Renderer stopped successfully');
}).catch((err) => { }).catch((err) => {
console.error(`ERROR: ${err.message}`); console.error(`ERROR: ${err}`);
}); });
``` ```
...@@ -3794,7 +3794,7 @@ release(): Promise\<void> ...@@ -3794,7 +3794,7 @@ release(): Promise\<void>
audioRenderer.release().then(() => { audioRenderer.release().then(() => {
console.info('Renderer released successfully'); console.info('Renderer released successfully');
}).catch((err) => { }).catch((err) => {
console.error(`ERROR: ${err.message}`); console.error(`ERROR: ${err}`);
}); });
``` ```
...@@ -3842,14 +3842,14 @@ audio.createAudioRenderer(audioRendererOptions).then((data)=> { ...@@ -3842,14 +3842,14 @@ audio.createAudioRenderer(audioRendererOptions).then((data)=> {
audioRenderer = data; audioRenderer = data;
console.info('AudioFrameworkRenderLog: AudioRenderer Created: SUCCESS'); console.info('AudioFrameworkRenderLog: AudioRenderer Created: SUCCESS');
}).catch((err) => { }).catch((err) => {
console.error(`AudioFrameworkRenderLog: AudioRenderer Created: ERROR: ${err.message}`); console.error(`AudioFrameworkRenderLog: AudioRenderer Created: ERROR: ${err}`);
}); });
var bufferSize; var bufferSize;
audioRenderer.getBufferSize().then((data)=> { audioRenderer.getBufferSize().then((data)=> {
console.info(`AudioFrameworkRenderLog: getBufferSize: SUCCESS ${data}`); console.info(`AudioFrameworkRenderLog: getBufferSize: SUCCESS ${data}`);
bufferSize = data; bufferSize = data;
}).catch((err) => { }).catch((err) => {
console.error.(`AudioFrameworkRenderLog: getBufferSize: ERROR: ${err.message}`); console.error.(`AudioFrameworkRenderLog: getBufferSize: ERROR: ${err}`);
}); });
console.info(`Buffer size: ${bufferSize}`); console.info(`Buffer size: ${bufferSize}`);
var context = featureAbility.getContext(); var context = featureAbility.getContext();
...@@ -3910,14 +3910,14 @@ audio.createAudioRenderer(audioRendererOptions).then((data) => { ...@@ -3910,14 +3910,14 @@ audio.createAudioRenderer(audioRendererOptions).then((data) => {
audioRenderer = data; audioRenderer = data;
console.info('AudioFrameworkRenderLog: AudioRenderer Created: SUCCESS'); console.info('AudioFrameworkRenderLog: AudioRenderer Created: SUCCESS');
}).catch((err) => { }).catch((err) => {
console.error(`AudioFrameworkRenderLog: AudioRenderer Created: ERROR: ${err.message}`); console.error(`AudioFrameworkRenderLog: AudioRenderer Created: ERROR: ${err}`);
}); });
var bufferSize; var bufferSize;
audioRenderer.getBufferSize().then((data) => { audioRenderer.getBufferSize().then((data) => {
console.info(`AudioFrameworkRenderLog: getBufferSize: SUCCESS ${data}`); console.info(`AudioFrameworkRenderLog: getBufferSize: SUCCESS ${data}`);
bufferSize = data; bufferSize = data;
}).catch((err) => { }).catch((err) => {
console.info(`AudioFrameworkRenderLog: getBufferSize: ERROR: ${err.message}`); console.info(`AudioFrameworkRenderLog: getBufferSize: ERROR: ${err}`);
}); });
console.info(`BufferSize: ${bufferSize}`); console.info(`BufferSize: ${bufferSize}`);
var context = featureAbility.getContext(); var context = featureAbility.getContext();
...@@ -3933,7 +3933,7 @@ audioRenderer.write(buf).then((writtenbytes) => { ...@@ -3933,7 +3933,7 @@ audioRenderer.write(buf).then((writtenbytes) => {
console.info(`Actual written bytes: ${writtenbytes}`); console.info(`Actual written bytes: ${writtenbytes}`);
} }
}).catch((err) => { }).catch((err) => {
console.error(`ERROR: ${err.message}`); console.error(`ERROR: ${err}`);
}); });
``` ```
...@@ -3979,7 +3979,7 @@ getAudioTime(): Promise\<number> ...@@ -3979,7 +3979,7 @@ getAudioTime(): Promise\<number>
audioRenderer.getAudioTime().then((timestamp) => { audioRenderer.getAudioTime().then((timestamp) => {
console.info(`Current timestamp: ${timestamp}`); console.info(`Current timestamp: ${timestamp}`);
}).catch((err) => { }).catch((err) => {
console.error(`ERROR: ${err.message}`); console.error(`ERROR: ${err}`);
}); });
``` ```
...@@ -4049,14 +4049,14 @@ audio.createAudioRenderer(audioRendererOptions).then((data) => { ...@@ -4049,14 +4049,14 @@ audio.createAudioRenderer(audioRendererOptions).then((data) => {
audioRenderer = data; audioRenderer = data;
console.info('AudioFrameworkRenderLog: AudioRenderer Created: SUCCESS'); console.info('AudioFrameworkRenderLog: AudioRenderer Created: SUCCESS');
}).catch((err) => { }).catch((err) => {
console.info(`AudioFrameworkRenderLog: AudioRenderer Created: ERROR: ${err.message}`); console.info(`AudioFrameworkRenderLog: AudioRenderer Created: ERROR: ${err}`);
}); });
var bufferSize; var bufferSize;
audioRenderer.getBufferSize().then((data) => { audioRenderer.getBufferSize().then((data) => {
console.info(`AudioFrameworkRenderLog: getBufferSize: SUCCESS ${data}`); console.info(`AudioFrameworkRenderLog: getBufferSize: SUCCESS ${data}`);
bufferSize = data; bufferSize = data;
}).catch((err) => { }).catch((err) => {
console.error(`AudioFrameworkRenderLog: getBufferSize: ERROR: ${err.message}`); console.error(`AudioFrameworkRenderLog: getBufferSize: ERROR: ${err}`);
}); });
``` ```
...@@ -4113,7 +4113,7 @@ setRenderRate(rate: AudioRendererRate): Promise\<void> ...@@ -4113,7 +4113,7 @@ setRenderRate(rate: AudioRendererRate): Promise\<void>
audioRenderer.setRenderRate(audio.AudioRendererRate.RENDER_RATE_NORMAL).then(() => { audioRenderer.setRenderRate(audio.AudioRendererRate.RENDER_RATE_NORMAL).then(() => {
console.info('setRenderRate SUCCESS'); console.info('setRenderRate SUCCESS');
}).catch((err) => { }).catch((err) => {
console.error(`ERROR: ${err.message}`); console.error(`ERROR: ${err}`);
}); });
``` ```
...@@ -4159,7 +4159,7 @@ getRenderRate(): Promise\<AudioRendererRate> ...@@ -4159,7 +4159,7 @@ getRenderRate(): Promise\<AudioRendererRate>
audioRenderer.getRenderRate().then((renderRate) => { audioRenderer.getRenderRate().then((renderRate) => {
console.info(`getRenderRate: ${renderRate}`); console.info(`getRenderRate: ${renderRate}`);
}).catch((err) => { }).catch((err) => {
console.error(`ERROR: ${err.message}`); console.error(`ERROR: ${err}`);
}); });
``` ```
### setInterruptMode<sup>9+</sup> ### setInterruptMode<sup>9+</sup>
...@@ -4205,7 +4205,7 @@ let mode = 0; ...@@ -4205,7 +4205,7 @@ let mode = 0;
audioRenderer.setInterruptMode(mode).then(data=>{ audioRenderer.setInterruptMode(mode).then(data=>{
console.info('setInterruptMode Success!'); console.info('setInterruptMode Success!');
}).catch((err) => { }).catch((err) => {
console.error(`setInterruptMode Fail: ${err.message}`); console.error(`setInterruptMode Fail: ${err}`);
}); });
``` ```
### setInterruptMode<sup>9+</sup> ### setInterruptMode<sup>9+</sup>
...@@ -4245,7 +4245,7 @@ let audioRenderer = await audio.createAudioRenderer(audioRendererOptions); ...@@ -4245,7 +4245,7 @@ let audioRenderer = await audio.createAudioRenderer(audioRendererOptions);
let mode = 1; let mode = 1;
audioRenderer.setInterruptMode(mode, (err, data)=>{ audioRenderer.setInterruptMode(mode, (err, data)=>{
if(err){ if(err){
console.error(`setInterruptMode Fail: ${err.message}`); console.error(`setInterruptMode Fail: ${err}`);
} }
console.info('setInterruptMode Success!'); console.info('setInterruptMode Success!');
}); });
...@@ -4290,7 +4290,7 @@ audioRenderer.on('interrupt', async(interruptEvent) => { ...@@ -4290,7 +4290,7 @@ audioRenderer.on('interrupt', async(interruptEvent) => {
console.info('AudioInterruptMusic: renderInstant started :SUCCESS '); console.info('AudioInterruptMusic: renderInstant started :SUCCESS ');
started = true; started = true;
}).catch((err) => { }).catch((err) => {
console.error(`AudioInterruptMusic: renderInstant start :ERROR : ${err.message}`); console.error(`AudioInterruptMusic: renderInstant start :ERROR : ${err}`);
started = false; started = false;
}); });
if (started) { if (started) {
...@@ -4510,7 +4510,7 @@ audioCapturer.getCapturerInfo().then((audioParamsGet) => { ...@@ -4510,7 +4510,7 @@ audioCapturer.getCapturerInfo().then((audioParamsGet) => {
console.info('AudioFrameworkRecLog: audioParams getCapturerInfo are incorrect'); console.info('AudioFrameworkRecLog: audioParams getCapturerInfo are incorrect');
} }
}).catch((err) => { }).catch((err) => {
console.error(`AudioFrameworkRecLog: CapturerInfo :ERROR: ${err.message}`); console.error(`AudioFrameworkRecLog: CapturerInfo :ERROR: ${err}`);
}); });
``` ```
...@@ -4568,7 +4568,7 @@ audioCapturer.getStreamInfo().then((audioParamsGet) => { ...@@ -4568,7 +4568,7 @@ audioCapturer.getStreamInfo().then((audioParamsGet) => {
console.info(`channels: ${audioParamsGet.channels}`); console.info(`channels: ${audioParamsGet.channels}`);
console.info(`encodingType: ${audioParamsGet.encodingType}`); console.info(`encodingType: ${audioParamsGet.encodingType}`);
}).catch((err) => { }).catch((err) => {
console.error(`getStreamInfo :ERROR: ${err.message}`); console.error(`getStreamInfo :ERROR: ${err}`);
}); });
``` ```
...@@ -4636,7 +4636,7 @@ audio.createAudioCapturer(audioCapturerOptions).then((data) => { ...@@ -4636,7 +4636,7 @@ audio.createAudioCapturer(audioCapturerOptions).then((data) => {
audioCapturer = data; audioCapturer = data;
console.info('AudioFrameworkRecLog: AudioCapturer Created: SUCCESS'); console.info('AudioFrameworkRecLog: AudioCapturer Created: SUCCESS');
}).catch((err) => { }).catch((err) => {
console.info(`AudioFrameworkRecLog: AudioCapturer Created: ERROR: ${err.message}`); console.info(`AudioFrameworkRecLog: AudioCapturer Created: ERROR: ${err}`);
}); });
audioCapturer.start().then(() => { audioCapturer.start().then(() => {
console.info('AudioFrameworkRecLog: ---------START---------'); console.info('AudioFrameworkRecLog: ---------START---------');
...@@ -4647,7 +4647,7 @@ audioCapturer.start().then(() => { ...@@ -4647,7 +4647,7 @@ audioCapturer.start().then(() => {
console.info('AudioFrameworkRecLog: AudioCapturer is in Running State'); console.info('AudioFrameworkRecLog: AudioCapturer is in Running State');
} }
}).catch((err) => { }).catch((err) => {
console.info(`AudioFrameworkRecLog: Capturer start :ERROR : ${err.message}`); console.info(`AudioFrameworkRecLog: Capturer start :ERROR : ${err}`);
}); });
``` ```
...@@ -4702,7 +4702,7 @@ audioCapturer.stop().then(() => { ...@@ -4702,7 +4702,7 @@ audioCapturer.stop().then(() => {
console.info('AudioFrameworkRecLog: State is Stopped:'); console.info('AudioFrameworkRecLog: State is Stopped:');
} }
}).catch((err) => { }).catch((err) => {
console.info(`AudioFrameworkRecLog: Capturer stop: ERROR: ${err.message}`); console.info(`AudioFrameworkRecLog: Capturer stop: ERROR: ${err}`);
}); });
``` ```
...@@ -4757,7 +4757,7 @@ audioCapturer.release().then(() => { ...@@ -4757,7 +4757,7 @@ audioCapturer.release().then(() => {
console.info(`AudioFrameworkRecLog: AudioCapturer : STATE : ${audioCapturer.state}`); console.info(`AudioFrameworkRecLog: AudioCapturer : STATE : ${audioCapturer.state}`);
console.info(`AudioFrameworkRecLog: stateFlag : ${stateFlag}`); console.info(`AudioFrameworkRecLog: stateFlag : ${stateFlag}`);
}).catch((err) => { }).catch((err) => {
console.info(`AudioFrameworkRecLog: Capturer stop: ERROR: ${err.message}`); console.info(`AudioFrameworkRecLog: Capturer stop: ERROR: ${err}`);
}); });
``` ```
...@@ -4786,7 +4786,7 @@ audioCapturer.getBufferSize().then((data) => { ...@@ -4786,7 +4786,7 @@ audioCapturer.getBufferSize().then((data) => {
console.info(`AudioFrameworkRecLog: getBufferSize: SUCCESS ${data}`); console.info(`AudioFrameworkRecLog: getBufferSize: SUCCESS ${data}`);
bufferSize = data; bufferSize = data;
}).catch((err) => { }).catch((err) => {
console.error(`AudioFrameworkRecLog: getBufferSize: EROOR: ${err.message}`); console.error(`AudioFrameworkRecLog: getBufferSize: EROOR: ${err}`);
}); });
audioCapturer.read(bufferSize, true, async(err, buffer) => { audioCapturer.read(bufferSize, true, async(err, buffer) => {
if (!err) { if (!err) {
...@@ -4825,13 +4825,13 @@ audioCapturer.getBufferSize().then((data) => { ...@@ -4825,13 +4825,13 @@ audioCapturer.getBufferSize().then((data) => {
console.info(`AudioFrameworkRecLog: getBufferSize: SUCCESS ${data}`); console.info(`AudioFrameworkRecLog: getBufferSize: SUCCESS ${data}`);
bufferSize = data; bufferSize = data;
}).catch((err) => { }).catch((err) => {
console.info(`AudioFrameworkRecLog: getBufferSize: ERROR ${err.message}`); console.info(`AudioFrameworkRecLog: getBufferSize: ERROR ${err}`);
}); });
console.info(`Buffer size: ${bufferSize}`); console.info(`Buffer size: ${bufferSize}`);
audioCapturer.read(bufferSize, true).then((buffer) => { audioCapturer.read(bufferSize, true).then((buffer) => {
console.info('buffer read successfully'); console.info('buffer read successfully');
}).catch((err) => { }).catch((err) => {
console.info(`ERROR : ${err.message}`); console.info(`ERROR : ${err}`);
}); });
``` ```
...@@ -4879,7 +4879,7 @@ getAudioTime(): Promise<number\> ...@@ -4879,7 +4879,7 @@ getAudioTime(): Promise<number\>
audioCapturer.getAudioTime().then((audioTime) => { audioCapturer.getAudioTime().then((audioTime) => {
console.info(`AudioFrameworkRecLog: AudioCapturer getAudioTime : Success ${audioTime}`); console.info(`AudioFrameworkRecLog: AudioCapturer getAudioTime : Success ${audioTime}`);
}).catch((err) => { }).catch((err) => {
console.info(`AudioFrameworkRecLog: AudioCapturer Created : ERROR : ${err.message}`); console.info(`AudioFrameworkRecLog: AudioCapturer Created : ERROR : ${err}`);
}); });
``` ```
...@@ -4907,7 +4907,7 @@ audioCapturer.getBufferSize((err, bufferSize) => { ...@@ -4907,7 +4907,7 @@ audioCapturer.getBufferSize((err, bufferSize) => {
audioCapturer.read(bufferSize, true).then((buffer) => { audioCapturer.read(bufferSize, true).then((buffer) => {
console.info(`Buffer read is ${buffer}`); console.info(`Buffer read is ${buffer}`);
}).catch((err) => { }).catch((err) => {
console.error(`AudioFrameworkRecLog: AudioCapturer Created : ERROR : ${err.message}`); console.error(`AudioFrameworkRecLog: AudioCapturer Created : ERROR : ${err}`);
}); });
} }
}); });
...@@ -4936,7 +4936,7 @@ audioCapturer.getBufferSize().then((data) => { ...@@ -4936,7 +4936,7 @@ audioCapturer.getBufferSize().then((data) => {
console.info(`AudioFrameworkRecLog: getBufferSize :SUCCESS ${data}`); console.info(`AudioFrameworkRecLog: getBufferSize :SUCCESS ${data}`);
bufferSize = data; bufferSize = data;
}).catch((err) => { }).catch((err) => {
console.info(`AudioFrameworkRecLog: getBufferSize :ERROR : ${err.message}`); console.info(`AudioFrameworkRecLog: getBufferSize :ERROR : ${err}`);
}); });
``` ```
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
> 该组件从API Version 6开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 > 该组件从API Version 6开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
## 导入模块 ## 导入模块
``` ```js
import mediaLibrary from '@ohos.multimedia.mediaLibrary'; import mediaLibrary from '@ohos.multimedia.mediaLibrary';
``` ```
...@@ -32,13 +32,13 @@ getMediaLibrary(context: Context): MediaLibrary ...@@ -32,13 +32,13 @@ getMediaLibrary(context: Context): MediaLibrary
**示例:(从API Version 9开始)** **示例:(从API Version 9开始)**
``` ```ts
var media = mediaLibrary.getMediaLibrary(this.context); var media = mediaLibrary.getMediaLibrary(this.context);
``` ```
**示例:(API Version 8)** **示例:(API Version 8)**
``` ```js
import featureAbility from '@ohos.ability.featureAbility'; import featureAbility from '@ohos.ability.featureAbility';
var context = featureAbility.getContext() var context = featureAbility.getContext()
...@@ -90,7 +90,7 @@ getFileAssets(options: MediaFetchOptions, callback: AsyncCallback&lt;FetchFileRe ...@@ -90,7 +90,7 @@ getFileAssets(options: MediaFetchOptions, callback: AsyncCallback&lt;FetchFileRe
**示例:** **示例:**
``` ```js
let fileKeyObj = mediaLibrary.FileKey let fileKeyObj = mediaLibrary.FileKey
let imageType = mediaLibrary.MediaType.IMAGE let imageType = mediaLibrary.MediaType.IMAGE
let imagesfetchOp = { let imagesfetchOp = {
...@@ -134,7 +134,7 @@ getFileAssets(options: MediaFetchOptions): Promise&lt;FetchFileResult&gt; ...@@ -134,7 +134,7 @@ getFileAssets(options: MediaFetchOptions): Promise&lt;FetchFileResult&gt;
**示例:** **示例:**
``` ```js
let fileKeyObj = mediaLibrary.FileKey let fileKeyObj = mediaLibrary.FileKey
let imageType = mediaLibrary.MediaType.IMAGE let imageType = mediaLibrary.MediaType.IMAGE
let imagesfetchOp = { let imagesfetchOp = {
...@@ -165,7 +165,7 @@ on(type: 'deviceChange'|'albumChange'|'imageChange'|'audioChange'|'videoChange'| ...@@ -165,7 +165,7 @@ on(type: 'deviceChange'|'albumChange'|'imageChange'|'audioChange'|'videoChange'|
**示例:** **示例:**
``` ```js
media.on('imageChange', () => { media.on('imageChange', () => {
// image file had changed, do something // image file had changed, do something
}) })
...@@ -187,7 +187,7 @@ off(type: 'deviceChange'|'albumChange'|'imageChange'|'audioChange'|'videoChange' ...@@ -187,7 +187,7 @@ off(type: 'deviceChange'|'albumChange'|'imageChange'|'audioChange'|'videoChange'
**示例:** **示例:**
``` ```js
media.off('imageChange', () => { media.off('imageChange', () => {
// stop listening success // stop listening success
}) })
...@@ -214,7 +214,7 @@ createAsset(mediaType: MediaType, displayName: string, relativePath: string, cal ...@@ -214,7 +214,7 @@ createAsset(mediaType: MediaType, displayName: string, relativePath: string, cal
**示例:** **示例:**
``` ```js
async function example() { async function example() {
// 使用Callback方式创建Image类型文件 // 使用Callback方式创建Image类型文件
let mediaType = mediaLibrary.MediaType.IMAGE; let mediaType = mediaLibrary.MediaType.IMAGE;
...@@ -256,7 +256,7 @@ createAsset(mediaType: MediaType, displayName: string, relativePath: string): Pr ...@@ -256,7 +256,7 @@ createAsset(mediaType: MediaType, displayName: string, relativePath: string): Pr
**示例:** **示例:**
``` ```js
let DIR_CAMERA = mediaLibrary.DirectoryType.DIR_CAMERA; let DIR_CAMERA = mediaLibrary.DirectoryType.DIR_CAMERA;
media.getPublicDirectory(DIR_CAMERA).then(function(dicResult){ media.getPublicDirectory(DIR_CAMERA).then(function(dicResult){
console.info("getPublicDirectory successfully:"+ JSON.stringify(dicResult)); console.info("getPublicDirectory successfully:"+ JSON.stringify(dicResult));
...@@ -282,7 +282,7 @@ getPublicDirectory(type: DirectoryType, callback: AsyncCallback&lt;string&gt;): ...@@ -282,7 +282,7 @@ getPublicDirectory(type: DirectoryType, callback: AsyncCallback&lt;string&gt;):
**示例:** **示例:**
``` ```js
let DIR_CAMERA = mediaLibrary.DirectoryType.DIR_CAMERA; let DIR_CAMERA = mediaLibrary.DirectoryType.DIR_CAMERA;
media.getPublicDirectory(DIR_CAMERA, (err, dicResult) => { media.getPublicDirectory(DIR_CAMERA, (err, dicResult) => {
if (dicResult == 'Camera/') { if (dicResult == 'Camera/') {
...@@ -315,7 +315,7 @@ getPublicDirectory(type: DirectoryType): Promise&lt;string&gt; ...@@ -315,7 +315,7 @@ getPublicDirectory(type: DirectoryType): Promise&lt;string&gt;
**示例:** **示例:**
``` ```js
async function example() { async function example() {
let DIR_CAMERA = mediaLibrary.DirectoryType.DIR_CAMERA; let DIR_CAMERA = mediaLibrary.DirectoryType.DIR_CAMERA;
const dicResult = await media.getPublicDirectory(DIR_CAMERA); const dicResult = await media.getPublicDirectory(DIR_CAMERA);
...@@ -346,7 +346,7 @@ getAlbums(options: MediaFetchOptions, callback: AsyncCallback<Array&lt;Album&gt; ...@@ -346,7 +346,7 @@ getAlbums(options: MediaFetchOptions, callback: AsyncCallback<Array&lt;Album&gt;
**示例:** **示例:**
``` ```js
let AlbumNoArgsfetchOp = { let AlbumNoArgsfetchOp = {
selections: '', selections: '',
selectionArgs: [], selectionArgs: [],
...@@ -386,7 +386,7 @@ getAlbums(options: MediaFetchOptions): Promise<Array&lt;Album&gt;> ...@@ -386,7 +386,7 @@ getAlbums(options: MediaFetchOptions): Promise<Array&lt;Album&gt;>
**示例:** **示例:**
``` ```js
let AlbumNoArgsfetchOp = { let AlbumNoArgsfetchOp = {
selections: '', selections: '',
selectionArgs: [], selectionArgs: [],
...@@ -415,7 +415,7 @@ release(callback: AsyncCallback&lt;void&gt;): void ...@@ -415,7 +415,7 @@ release(callback: AsyncCallback&lt;void&gt;): void
**示例:** **示例:**
``` ```js
var media = mediaLibrary.getMediaLibrary(context); var media = mediaLibrary.getMediaLibrary(context);
media.release((err) => { media.release((err) => {
// do something // do something
...@@ -439,7 +439,7 @@ release(): Promise&lt;void&gt; ...@@ -439,7 +439,7 @@ release(): Promise&lt;void&gt;
**示例:** **示例:**
``` ```js
media.release() media.release()
``` ```
...@@ -462,7 +462,7 @@ storeMediaAsset(option: MediaAssetOption, callback: AsyncCallback&lt;string&gt;) ...@@ -462,7 +462,7 @@ storeMediaAsset(option: MediaAssetOption, callback: AsyncCallback&lt;string&gt;)
**示例:** **示例:**
``` ```js
let option = { let option = {
src : "/data/storage/el2/base/haps/entry/image.png", src : "/data/storage/el2/base/haps/entry/image.png",
mimeType : "image/*", mimeType : "image/*",
...@@ -476,7 +476,7 @@ mediaLibrary.getMediaLibrary().storeMediaAsset(option, (err, value) => { ...@@ -476,7 +476,7 @@ mediaLibrary.getMediaLibrary().storeMediaAsset(option, (err, value) => {
console.log("Media resources stored. "); console.log("Media resources stored. ");
// Obtain the URI that stores media resources. // Obtain the URI that stores media resources.
}); });
``` ```
### storeMediaAsset<sup>(deprecated)</sup> ### storeMediaAsset<sup>(deprecated)</sup>
...@@ -503,7 +503,7 @@ storeMediaAsset(option: MediaAssetOption): Promise&lt;string&gt; ...@@ -503,7 +503,7 @@ storeMediaAsset(option: MediaAssetOption): Promise&lt;string&gt;
**示例:** **示例:**
``` ```js
let option = { let option = {
src : "/data/storage/el2/base/haps/entry/image.png", src : "/data/storage/el2/base/haps/entry/image.png",
mimeType : "image/*", mimeType : "image/*",
...@@ -515,7 +515,7 @@ mediaLibrary.getMediaLibrary().storeMediaAsset(option).then((value) => { ...@@ -515,7 +515,7 @@ mediaLibrary.getMediaLibrary().storeMediaAsset(option).then((value) => {
}).catch((err) => { }).catch((err) => {
console.log("An error occurred when storing media resources."); console.log("An error occurred when storing media resources.");
}); });
``` ```
### startImagePreview<sup>(deprecated)</sup> ### startImagePreview<sup>(deprecated)</sup>
...@@ -538,7 +538,7 @@ startImagePreview(images: Array&lt;string&gt;, index: number, callback: AsyncCal ...@@ -538,7 +538,7 @@ startImagePreview(images: Array&lt;string&gt;, index: number, callback: AsyncCal
**示例:** **示例:**
``` ```js
let images = [ let images = [
"dataability:///media/xxxx/2", "dataability:///media/xxxx/2",
"dataability:///media/xxxx/3" "dataability:///media/xxxx/3"
...@@ -557,7 +557,7 @@ mediaLibrary.getMediaLibrary().startImagePreview(images, index, (err) => { ...@@ -557,7 +557,7 @@ mediaLibrary.getMediaLibrary().startImagePreview(images, index, (err) => {
} }
console.log("Succeeded in previewing the images."); console.log("Succeeded in previewing the images.");
}); });
``` ```
### startImagePreview<sup>(deprecated)</sup> ### startImagePreview<sup>(deprecated)</sup>
...@@ -579,7 +579,7 @@ startImagePreview(images: Array&lt;string&gt;, callback: AsyncCallback&lt;void&g ...@@ -579,7 +579,7 @@ startImagePreview(images: Array&lt;string&gt;, callback: AsyncCallback&lt;void&g
**示例:** **示例:**
``` ```js
let images = [ let images = [
"dataability:///media/xxxx/2", "dataability:///media/xxxx/2",
"dataability:///media/xxxx/3" "dataability:///media/xxxx/3"
...@@ -597,7 +597,7 @@ mediaLibrary.getMediaLibrary().startImagePreview(images, (err) => { ...@@ -597,7 +597,7 @@ mediaLibrary.getMediaLibrary().startImagePreview(images, (err) => {
} }
console.log("Succeeded in previewing the images."); console.log("Succeeded in previewing the images.");
}); });
``` ```
### startImagePreview<sup>(deprecated)</sup> ### startImagePreview<sup>(deprecated)</sup>
...@@ -625,7 +625,7 @@ startImagePreview(images: Array&lt;string&gt;, index?: number): Promise&lt;void& ...@@ -625,7 +625,7 @@ startImagePreview(images: Array&lt;string&gt;, index?: number): Promise&lt;void&
**示例:** **示例:**
``` ```js
let images = [ let images = [
"dataability:///media/xxxx/2", "dataability:///media/xxxx/2",
"dataability:///media/xxxx/3" "dataability:///media/xxxx/3"
...@@ -642,7 +642,7 @@ mediaLibrary.getMediaLibrary().startImagePreview(images, index).then(() => { ...@@ -642,7 +642,7 @@ mediaLibrary.getMediaLibrary().startImagePreview(images, index).then(() => {
}).catch((err) => { }).catch((err) => {
console.log("An error occurred when previewing the images."); console.log("An error occurred when previewing the images.");
}); });
``` ```
### startMediaSelect<sup>(deprecated)</sup> ### startMediaSelect<sup>(deprecated)</sup>
...@@ -664,7 +664,7 @@ startMediaSelect(option: MediaSelectOption, callback: AsyncCallback&lt;Array&lt; ...@@ -664,7 +664,7 @@ startMediaSelect(option: MediaSelectOption, callback: AsyncCallback&lt;Array&lt;
**示例:** **示例:**
``` ```js
let option = { let option = {
type : "media", type : "media",
count : 2 count : 2
...@@ -677,7 +677,7 @@ mediaLibrary.getMediaLibrary().startMediaSelect(option, (err, value) => { ...@@ -677,7 +677,7 @@ mediaLibrary.getMediaLibrary().startMediaSelect(option, (err, value) => {
console.log("Media resources selected."); console.log("Media resources selected.");
// Obtain the media selection value. // Obtain the media selection value.
}); });
``` ```
### startMediaSelect<sup>(deprecated)</sup> ### startMediaSelect<sup>(deprecated)</sup>
...@@ -704,7 +704,7 @@ startMediaSelect(option: MediaSelectOption): Promise&lt;Array&lt;string&gt;&gt; ...@@ -704,7 +704,7 @@ startMediaSelect(option: MediaSelectOption): Promise&lt;Array&lt;string&gt;&gt;
**示例:** **示例:**
``` ```js
let option = { let option = {
type : "media", type : "media",
count : 2 count : 2
...@@ -716,7 +716,7 @@ mediaLibrary.getMediaLibrary().startMediaSelect(option).then((value) => { ...@@ -716,7 +716,7 @@ mediaLibrary.getMediaLibrary().startMediaSelect(option).then((value) => {
console.log("An error occurred when selecting media resources."); console.log("An error occurred when selecting media resources.");
}); });
``` ```
## FileAsset<sup>7+</sup> ## FileAsset<sup>7+</sup>
...@@ -769,7 +769,7 @@ isDirectory(callback: AsyncCallback&lt;boolean&gt;): void ...@@ -769,7 +769,7 @@ isDirectory(callback: AsyncCallback&lt;boolean&gt;): void
**示例:** **示例:**
``` ```js
async function example() { async function example() {
let fileKeyObj = mediaLibrary.FileKey let fileKeyObj = mediaLibrary.FileKey
let imageType = mediaLibrary.MediaType.IMAGE; let imageType = mediaLibrary.MediaType.IMAGE;
...@@ -805,7 +805,7 @@ isDirectory():Promise&lt;boolean&gt; ...@@ -805,7 +805,7 @@ isDirectory():Promise&lt;boolean&gt;
**示例:** **示例:**
``` ```js
async function example() { async function example() {
let fileKeyObj = mediaLibrary.FileKey let fileKeyObj = mediaLibrary.FileKey
let imageType = mediaLibrary.MediaType.IMAGE; let imageType = mediaLibrary.MediaType.IMAGE;
...@@ -843,7 +843,7 @@ commitModify(callback: AsyncCallback&lt;void&gt;): void ...@@ -843,7 +843,7 @@ commitModify(callback: AsyncCallback&lt;void&gt;): void
**示例:** **示例:**
``` ```js
async function example() { async function example() {
let fileKeyObj = mediaLibrary.FileKey let fileKeyObj = mediaLibrary.FileKey
let imageType = mediaLibrary.MediaType.IMAGE; let imageType = mediaLibrary.MediaType.IMAGE;
...@@ -880,7 +880,7 @@ commitModify(): Promise&lt;void&gt; ...@@ -880,7 +880,7 @@ commitModify(): Promise&lt;void&gt;
**示例:** **示例:**
``` ```js
async function example() { async function example() {
let fileKeyObj = mediaLibrary.FileKey let fileKeyObj = mediaLibrary.FileKey
let imageType = mediaLibrary.MediaType.IMAGE; let imageType = mediaLibrary.MediaType.IMAGE;
...@@ -918,7 +918,7 @@ open(mode: string, callback: AsyncCallback&lt;number&gt;): void ...@@ -918,7 +918,7 @@ open(mode: string, callback: AsyncCallback&lt;number&gt;): void
**示例:** **示例:**
``` ```js
async function example() { async function example() {
let mediaType = mediaLibrary.MediaType.IMAGE; let mediaType = mediaLibrary.MediaType.IMAGE;
let DIR_IMAGE = mediaLibrary.DirectoryType.DIR_IMAGE; let DIR_IMAGE = mediaLibrary.DirectoryType.DIR_IMAGE;
...@@ -960,7 +960,7 @@ open(mode: string): Promise&lt;number&gt; ...@@ -960,7 +960,7 @@ open(mode: string): Promise&lt;number&gt;
**示例:** **示例:**
``` ```js
async function example() { async function example() {
let mediaType = mediaLibrary.MediaType.IMAGE; let mediaType = mediaLibrary.MediaType.IMAGE;
let DIR_IMAGE = mediaLibrary.DirectoryType.DIR_IMAGE; let DIR_IMAGE = mediaLibrary.DirectoryType.DIR_IMAGE;
...@@ -995,7 +995,7 @@ close(fd: number, callback: AsyncCallback&lt;void&gt;): void ...@@ -995,7 +995,7 @@ close(fd: number, callback: AsyncCallback&lt;void&gt;): void
**示例:** **示例:**
``` ```js
async function example() { async function example() {
let fileKeyObj = mediaLibrary.FileKey let fileKeyObj = mediaLibrary.FileKey
let imageType = mediaLibrary.MediaType.IMAGE; let imageType = mediaLibrary.MediaType.IMAGE;
...@@ -1048,7 +1048,7 @@ close(fd: number): Promise&lt;void&gt; ...@@ -1048,7 +1048,7 @@ close(fd: number): Promise&lt;void&gt;
**示例:** **示例:**
``` ```js
async function example() { async function example() {
let fileKeyObj = mediaLibrary.FileKey let fileKeyObj = mediaLibrary.FileKey
let imageType = mediaLibrary.MediaType.IMAGE; let imageType = mediaLibrary.MediaType.IMAGE;
...@@ -1096,7 +1096,7 @@ getThumbnail(callback: AsyncCallback&lt;image.PixelMap&gt;): void ...@@ -1096,7 +1096,7 @@ getThumbnail(callback: AsyncCallback&lt;image.PixelMap&gt;): void
**示例:** **示例:**
``` ```js
async function example() { async function example() {
let fileKeyObj = mediaLibrary.FileKey let fileKeyObj = mediaLibrary.FileKey
let imageType = mediaLibrary.MediaType.IMAGE; let imageType = mediaLibrary.MediaType.IMAGE;
...@@ -1133,7 +1133,7 @@ getThumbnail(size: Size, callback: AsyncCallback&lt;image.PixelMap&gt;): void ...@@ -1133,7 +1133,7 @@ getThumbnail(size: Size, callback: AsyncCallback&lt;image.PixelMap&gt;): void
**示例:** **示例:**
``` ```js
async function example() { async function example() {
let fileKeyObj = mediaLibrary.FileKey let fileKeyObj = mediaLibrary.FileKey
let imageType = mediaLibrary.MediaType.IMAGE; let imageType = mediaLibrary.MediaType.IMAGE;
...@@ -1176,7 +1176,7 @@ getThumbnail(size?: Size): Promise&lt;image.PixelMap&gt; ...@@ -1176,7 +1176,7 @@ getThumbnail(size?: Size): Promise&lt;image.PixelMap&gt;
**示例:** **示例:**
``` ```js
async function example() { async function example() {
let fileKeyObj = mediaLibrary.FileKey let fileKeyObj = mediaLibrary.FileKey
let imageType = mediaLibrary.MediaType.IMAGE; let imageType = mediaLibrary.MediaType.IMAGE;
...@@ -1218,7 +1218,7 @@ favorite(isFavorite: boolean, callback: AsyncCallback&lt;void&gt;): void ...@@ -1218,7 +1218,7 @@ favorite(isFavorite: boolean, callback: AsyncCallback&lt;void&gt;): void
**示例:** **示例:**
``` ```js
async function example() { async function example() {
let fileKeyObj = mediaLibrary.FileKey let fileKeyObj = mediaLibrary.FileKey
let imageType = mediaLibrary.MediaType.IMAGE; let imageType = mediaLibrary.MediaType.IMAGE;
...@@ -1260,7 +1260,7 @@ favorite(isFavorite: boolean): Promise&lt;void&gt; ...@@ -1260,7 +1260,7 @@ favorite(isFavorite: boolean): Promise&lt;void&gt;
**示例:** **示例:**
``` ```js
async function example() { async function example() {
let fileKeyObj = mediaLibrary.FileKey let fileKeyObj = mediaLibrary.FileKey
let imageType = mediaLibrary.MediaType.IMAGE; let imageType = mediaLibrary.MediaType.IMAGE;
...@@ -1298,7 +1298,7 @@ isFavorite(callback: AsyncCallback&lt;boolean&gt;): void ...@@ -1298,7 +1298,7 @@ isFavorite(callback: AsyncCallback&lt;boolean&gt;): void
**示例:** **示例:**
``` ```js
async function example() { async function example() {
let fileKeyObj = mediaLibrary.FileKey let fileKeyObj = mediaLibrary.FileKey
let imageType = mediaLibrary.MediaType.IMAGE; let imageType = mediaLibrary.MediaType.IMAGE;
...@@ -1338,7 +1338,7 @@ isFavorite():Promise&lt;boolean&gt; ...@@ -1338,7 +1338,7 @@ isFavorite():Promise&lt;boolean&gt;
**示例:** **示例:**
``` ```js
async function example() { async function example() {
let fileKeyObj = mediaLibrary.FileKey let fileKeyObj = mediaLibrary.FileKey
let imageType = mediaLibrary.MediaType.IMAGE; let imageType = mediaLibrary.MediaType.IMAGE;
...@@ -1379,7 +1379,7 @@ trash(isTrash: boolean, callback: AsyncCallback&lt;void&gt;): void ...@@ -1379,7 +1379,7 @@ trash(isTrash: boolean, callback: AsyncCallback&lt;void&gt;): void
**示例:** **示例:**
``` ```js
async function example() { async function example() {
let fileKeyObj = mediaLibrary.FileKey let fileKeyObj = mediaLibrary.FileKey
let imageType = mediaLibrary.MediaType.IMAGE; let imageType = mediaLibrary.MediaType.IMAGE;
...@@ -1424,7 +1424,7 @@ trash(isTrash: boolean): Promise&lt;void&gt; ...@@ -1424,7 +1424,7 @@ trash(isTrash: boolean): Promise&lt;void&gt;
**示例:** **示例:**
``` ```js
async function example() { async function example() {
let fileKeyObj = mediaLibrary.FileKey let fileKeyObj = mediaLibrary.FileKey
let imageType = mediaLibrary.MediaType.IMAGE; let imageType = mediaLibrary.MediaType.IMAGE;
...@@ -1462,7 +1462,7 @@ isTrash(callback: AsyncCallback&lt;boolean&gt;): void ...@@ -1462,7 +1462,7 @@ isTrash(callback: AsyncCallback&lt;boolean&gt;): void
**示例:** **示例:**
``` ```js
async function example() { async function example() {
let fileKeyObj = mediaLibrary.FileKey let fileKeyObj = mediaLibrary.FileKey
let imageType = mediaLibrary.MediaType.IMAGE; let imageType = mediaLibrary.MediaType.IMAGE;
...@@ -1507,7 +1507,7 @@ isTrash():Promise&lt;boolean&gt; ...@@ -1507,7 +1507,7 @@ isTrash():Promise&lt;boolean&gt;
**示例:** **示例:**
``` ```js
async function example() { async function example() {
let fileKeyObj = mediaLibrary.FileKey let fileKeyObj = mediaLibrary.FileKey
let imageType = mediaLibrary.MediaType.IMAGE; let imageType = mediaLibrary.MediaType.IMAGE;
...@@ -1527,6 +1527,239 @@ async function example() { ...@@ -1527,6 +1527,239 @@ async function example() {
} }
``` ```
### deleteAsset<sup>8+</sup>
deleteAsset(uri: string): Promise<void>;
删除媒体文件资源
**系统接口**:此接口为系统接口。
**需要权限**:ohos.permission.READ_MEDIA and ohos.permission.WRITE_MEDIA
**系统能力**:SystemCapability.Multimedia.MediaLibrary.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------- | ---- | --------------- |
| uri | string | 是 | 需要删除的媒体文件资源的uri |
**示例:**
```js
async function example() {
let fileKeyObj = mediaLibrary.FileKey
let fileType = mediaLibrary.MediaType.FILE
let option = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [fileType.toString()],
};
const context = getContext(this);
var media = mediaLibrary.getMediaLibrary(context);
const fetchFileResult = await media.getFileAssets(option);
let asset = await fetchFileResult.getFirstObject();
if (asset == undefined) {
console.error('asset not exist')
return
}
media.deleteAsset(asset.uri).then(() => {
console.info("deleteAsset successfully");
}).catch((err) => {
console.info("deleteAsset failed with error:"+ err);
});
}
```
deleteAsset(uri: string, callback: AsyncCallback<void>): void;
删除媒体文件资源
**系统接口**:此接口为系统接口。
**需要权限**:ohos.permission.READ_MEDIA and ohos.permission.WRITE_MEDIA
**系统能力**:SystemCapability.Multimedia.MediaLibrary.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------- | ---- | --------------- |
| uri | string | 是 | 需要删除的媒体文件资源的uri |
**示例:**
```js
async function example() {
let fileKeyObj = mediaLibrary.FileKey
let fileType = mediaLibrary.MediaType.FILE
let option = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [fileType.toString()],
};
const context = getContext(this);
var media = mediaLibrary.getMediaLibrary(context);
const fetchFileResult = await media.getFileAssets(option);
let asset = await fetchFileResult.getFirstObject();
if (asset == undefined) {
console.error('asset not exist')
return
}
media.deleteAsset(asset.uri, (err) => {
if (err != undefined) {
console.info("deleteAsset successfully");
} else {
console.info("deleteAsset failed with error:"+ err);
}
});
}
```
### getActivePeers<sup>8+</sup>
getActivePeers(): Promise<Array<PeerInfo>>;
获取在线对端设备的信息,使用Promise方式返回异步结果
**系统接口**:此接口为系统接口。
**需要权限**:ohos.permission.READ_MEDIA
**系统能力**:SystemCapability.Multimedia.MediaLibrary.DistributedCore
**返回值:**
| 类型 | 说明 |
| ------------------- | -------------------- |
| Promise<Array<PeerInfo>> | 返回获取的所有在线对端设备的PeerInfo |
**示例:**
```js
async function example() {
const context = getContext(this);
var media = mediaLibrary.getMediaLibrary(context);
media.getActivePeers().then((devicesInfo) => {
if (devicesInfo != undefined) {
for (let i = 0; i < devicesInfo.length; i++) {
console.info('get distributed info ' + devicesInfo[i].deviceName + devicesInfo[i].networkId);
}
} else {
console.info('get distributed info is undefined!')
}
}).catch((err) => {
console.info("get distributed info failed with error:" + err);
});
}
```
getActivePeers(callback: AsyncCallback<Array<PeerInfo>>): void;
获取在线对端设备的信息,使用callback方式返回异步结果。
**系统接口**:此接口为系统接口。
**需要权限**:ohos.permission.READ_MEDIA
**系统能力**:SystemCapability.Multimedia.MediaLibrary.DistributedCore
**返回值:**
| 类型 | 说明 |
| ------------------- | -------------------- |
| callback: AsyncCallback<Array<PeerInfo>> | 返回获取的所有在线对端设备的PeerInfo |
**示例:**
```js
async function example() {
const context = getContext(this);
var media = mediaLibrary.getMediaLibrary(context);
media.getActivePeers((err, devicesInfo) => {
if (devicesInfo != undefined) {
for (let i = 0; i < devicesInfo.length; i++) {
console.info('get distributed info ' + devicesInfo[i].deviceName + devicesInfo[i].networkId);
}
} else {
console.info('get distributed fail, message = ' + err)
}
})
}
```
### getAllPeers<sup>8+</sup>
getAllPeers(): Promise<Array<PeerInfo>>;
获取所有对端设备的信息,使用Promise方式返回异步结果
**系统接口**:此接口为系统接口。
**需要权限**:ohos.permission.READ_MEDIA
**系统能力**:SystemCapability.Multimedia.MediaLibrary.DistributedCore
**返回值:**
| 类型 | 说明 |
| ------------------- | -------------------- |
| Promise<Array<PeerInfo>> | 返回获取的所有对端设备的PeerInfo |
**示例:**
```js
async function example() {
const context = getContext(this);
var media = mediaLibrary.getMediaLibrary(context);
media.getAllPeers().then((devicesInfo) => {
if (devicesInfo != undefined) {
for (let i = 0; i < devicesInfo.length; i++) {
console.info('get distributed info ' + devicesInfo[i].deviceName + devicesInfo[i].networkId);
}
} else {
console.info('get distributed info is undefined!')
}
}).catch((err) => {
console.info("get distributed info failed with error:" + err);
});
}
```
getAllPeers(callback: AsyncCallback<Array<PeerInfo>>): void;
获取所有对端设备的信息,使用callback方式返回异步结果。
**系统接口**:此接口为系统接口。
**需要权限**:ohos.permission.READ_MEDIA
**系统能力**:SystemCapability.Multimedia.MediaLibrary.DistributedCore
**返回值:**
| 类型 | 说明 |
| ------------------- | -------------------- |
| callback: AsyncCallback<Array<PeerInfo>> | 返回获取的所有对端设备的PeerInfo |
**示例:**
```js
async function example() {
const context = getContext(this);
var media = mediaLibrary.getMediaLibrary(context);
media.getAllPeers((err, devicesInfo) => {
if (devicesInfo != undefined) {
for (let i = 0; i < devicesInfo.length; i++) {
console.info('get distributed info ' + devicesInfo[i].deviceName + devicesInfo[i].networkId);
}
} else {
console.info('get distributed fail, message = ' + err)
}
})
}
```
## FetchFileResult<sup>7+</sup> ## FetchFileResult<sup>7+</sup>
文件检索结果集。 文件检索结果集。
...@@ -1547,7 +1780,7 @@ getCount(): number ...@@ -1547,7 +1780,7 @@ getCount(): number
**示例** **示例**
``` ```js
async function example() { async function example() {
let fileKeyObj = mediaLibrary.FileKey let fileKeyObj = mediaLibrary.FileKey
let fileType = mediaLibrary.MediaType.FILE; let fileType = mediaLibrary.MediaType.FILE;
...@@ -1578,7 +1811,7 @@ isAfterLast(): boolean ...@@ -1578,7 +1811,7 @@ isAfterLast(): boolean
**示例** **示例**
``` ```js
async function example() { async function example() {
let fileKeyObj = mediaLibrary.FileKey let fileKeyObj = mediaLibrary.FileKey
let imageType = mediaLibrary.MediaType.IMAGE; let imageType = mediaLibrary.MediaType.IMAGE;
...@@ -1616,7 +1849,7 @@ close(): void ...@@ -1616,7 +1849,7 @@ close(): void
**示例** **示例**
``` ```js
async function example() { async function example() {
let fileKeyObj = mediaLibrary.FileKey let fileKeyObj = mediaLibrary.FileKey
let imageType = mediaLibrary.MediaType.IMAGE; let imageType = mediaLibrary.MediaType.IMAGE;
...@@ -1647,7 +1880,7 @@ getFirstObject(callback: AsyncCallback&lt;FileAsset&gt;): void ...@@ -1647,7 +1880,7 @@ getFirstObject(callback: AsyncCallback&lt;FileAsset&gt;): void
**示例** **示例**
``` ```js
async function example() { async function example() {
let fileKeyObj = mediaLibrary.FileKey let fileKeyObj = mediaLibrary.FileKey
let imageType = mediaLibrary.MediaType.IMAGE; let imageType = mediaLibrary.MediaType.IMAGE;
...@@ -1684,7 +1917,7 @@ getFirstObject(): Promise&lt;FileAsset&gt; ...@@ -1684,7 +1917,7 @@ getFirstObject(): Promise&lt;FileAsset&gt;
**示例** **示例**
``` ```js
async function example() { async function example() {
let fileKeyObj = mediaLibrary.FileKey let fileKeyObj = mediaLibrary.FileKey
let imageType = mediaLibrary.MediaType.IMAGE; let imageType = mediaLibrary.MediaType.IMAGE;
...@@ -1719,7 +1952,7 @@ async function example() { ...@@ -1719,7 +1952,7 @@ async function example() {
**示例** **示例**
``` ```js
async function example() { async function example() {
let fileKeyObj = mediaLibrary.FileKey let fileKeyObj = mediaLibrary.FileKey
let imageType = mediaLibrary.MediaType.IMAGE; let imageType = mediaLibrary.MediaType.IMAGE;
...@@ -1756,7 +1989,7 @@ async function example() { ...@@ -1756,7 +1989,7 @@ async function example() {
**示例** **示例**
``` ```js
async function example() { async function example() {
let fileKeyObj = mediaLibrary.FileKey let fileKeyObj = mediaLibrary.FileKey
let imageType = mediaLibrary.MediaType.IMAGE; let imageType = mediaLibrary.MediaType.IMAGE;
...@@ -1789,7 +2022,7 @@ getLastObject(callback: AsyncCallback&lt;FileAsset&gt;): void ...@@ -1789,7 +2022,7 @@ getLastObject(callback: AsyncCallback&lt;FileAsset&gt;): void
**示例** **示例**
``` ```js
async function example() { async function example() {
let fileKeyObj = mediaLibrary.FileKey let fileKeyObj = mediaLibrary.FileKey
let imageType = mediaLibrary.MediaType.IMAGE; let imageType = mediaLibrary.MediaType.IMAGE;
...@@ -1826,7 +2059,7 @@ getLastObject(): Promise&lt;FileAsset&gt; ...@@ -1826,7 +2059,7 @@ getLastObject(): Promise&lt;FileAsset&gt;
**示例** **示例**
``` ```js
async function example() { async function example() {
let fileKeyObj = mediaLibrary.FileKey let fileKeyObj = mediaLibrary.FileKey
let imageType = mediaLibrary.MediaType.IMAGE; let imageType = mediaLibrary.MediaType.IMAGE;
...@@ -1858,7 +2091,7 @@ getPositionObject(index: number, callback: AsyncCallback&lt;FileAsset&gt;): void ...@@ -1858,7 +2091,7 @@ getPositionObject(index: number, callback: AsyncCallback&lt;FileAsset&gt;): void
**示例** **示例**
``` ```js
async function example() { async function example() {
let fileKeyObj = mediaLibrary.FileKey let fileKeyObj = mediaLibrary.FileKey
let imageType = mediaLibrary.MediaType.IMAGE; let imageType = mediaLibrary.MediaType.IMAGE;
...@@ -1901,7 +2134,7 @@ getPositionObject(index: number): Promise&lt;FileAsset&gt; ...@@ -1901,7 +2134,7 @@ getPositionObject(index: number): Promise&lt;FileAsset&gt;
**示例** **示例**
``` ```js
async function example() { async function example() {
let fileKeyObj = mediaLibrary.FileKey let fileKeyObj = mediaLibrary.FileKey
let imageType = mediaLibrary.MediaType.IMAGE; let imageType = mediaLibrary.MediaType.IMAGE;
...@@ -1913,9 +2146,9 @@ async function example() { ...@@ -1913,9 +2146,9 @@ async function example() {
}; };
let fetchFileResult = await media.getFileAssets(getImageOp); let fetchFileResult = await media.getFileAssets(getImageOp);
fetchFileResult.getPositionObject(1) .then(function (fileAsset){ fetchFileResult.getPositionObject(1) .then(function (fileAsset){
console.log('[Demo] fileAsset.displayName : ' + fileAsset.displayName); console.log('fileAsset.displayName : ' + fileAsset.displayName);
}).catch(function (err) { }).catch(function (err) {
console.info("[Demo] getFileAssets failed with error:" + err); console.info("getFileAssets failed with error:" + err);
}); });
} }
``` ```
...@@ -1936,7 +2169,7 @@ getAllObject(callback: AsyncCallback&lt;Array&lt;FileAsset&gt;&gt;): void ...@@ -1936,7 +2169,7 @@ getAllObject(callback: AsyncCallback&lt;Array&lt;FileAsset&gt;&gt;): void
**示例** **示例**
``` ```js
async function example() { async function example() {
let fileKeyObj = mediaLibrary.FileKey let fileKeyObj = mediaLibrary.FileKey
let imageType = mediaLibrary.MediaType.IMAGE; let imageType = mediaLibrary.MediaType.IMAGE;
...@@ -1973,7 +2206,7 @@ getAllObject(): Promise&lt;Array&lt;FileAsset&gt;&gt; ...@@ -1973,7 +2206,7 @@ getAllObject(): Promise&lt;Array&lt;FileAsset&gt;&gt;
**示例** **示例**
``` ```js
async function example() { async function example() {
let fileKeyObj = mediaLibrary.FileKey let fileKeyObj = mediaLibrary.FileKey
let imageType = mediaLibrary.MediaType.IMAGE; let imageType = mediaLibrary.MediaType.IMAGE;
...@@ -2024,7 +2257,7 @@ commitModify(callback: AsyncCallback&lt;void&gt;): void ...@@ -2024,7 +2257,7 @@ commitModify(callback: AsyncCallback&lt;void&gt;): void
**示例** **示例**
``` ```js
async function example() { async function example() {
let AlbumNoArgsfetchOp = { let AlbumNoArgsfetchOp = {
selections: '', selections: '',
...@@ -2061,7 +2294,7 @@ commitModify(): Promise&lt;void&gt; ...@@ -2061,7 +2294,7 @@ commitModify(): Promise&lt;void&gt;
**示例** **示例**
``` ```js
async function example() { async function example() {
let AlbumNoArgsfetchOp = { let AlbumNoArgsfetchOp = {
selections: '', selections: '',
...@@ -2097,7 +2330,7 @@ getFileAssets(options: MediaFetchOptions, callback: AsyncCallback&lt;FetchFileRe ...@@ -2097,7 +2330,7 @@ getFileAssets(options: MediaFetchOptions, callback: AsyncCallback&lt;FetchFileRe
**示例** **示例**
``` ```js
async function example() { async function example() {
let AlbumNoArgsfetchOp = { let AlbumNoArgsfetchOp = {
selections: '', selections: '',
...@@ -2140,7 +2373,7 @@ async function example() { ...@@ -2140,7 +2373,7 @@ async function example() {
**示例** **示例**
``` ```js
async function example() { async function example() {
let AlbumNoArgsfetchOp = { let AlbumNoArgsfetchOp = {
selections: '', selections: '',
...@@ -2163,7 +2396,8 @@ async function example() { ...@@ -2163,7 +2396,8 @@ async function example() {
## PeerInfo<sup>8+</sup> ## PeerInfo<sup>8+</sup>
注册设备的信息。 注册设备的信息。
此接口为系统接口。
**系统接口**:此接口为系统接口。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.MediaLibrary.DistributedCore **系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.MediaLibrary.DistributedCore
...@@ -2235,7 +2469,8 @@ async function example() { ...@@ -2235,7 +2469,8 @@ async function example() {
## DeviceType<sup>8+</sup> ## DeviceType<sup>8+</sup>
枚举,设备类型。 枚举,设备类型。
此接口为系统接口。
**系统接口**:此接口为系统接口。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.MediaLibrary.DistributedCore **系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.MediaLibrary.DistributedCore
...@@ -2267,7 +2502,8 @@ async function example() { ...@@ -2267,7 +2502,8 @@ async function example() {
## Size<sup>8+</sup> ## Size<sup>8+</sup>
图片尺寸。 图片尺寸。
系统能力: 以下各项对应的系统能力均为SystemCapability.Multimedia.MediaLibrary.Core
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.MediaLibrary.Core
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| ------ | ------ | ---- | ---- | -------- | | ------ | ------ | ---- | ---- | -------- |
...@@ -2302,3 +2538,4 @@ async function example() { ...@@ -2302,3 +2538,4 @@ async function example() {
| type | string | 是 | 媒体类型,包括:image, video, media,当前仅支持media类型 | | type | string | 是 | 媒体类型,包括:image, video, media,当前仅支持media类型 |
| count | number | 是 | 媒体选择,count = 1表示单选,count大于1表示多选。 | | count | number | 是 | 媒体选择,count = 1表示单选,count大于1表示多选。 |
...@@ -16,7 +16,8 @@ import wifi from '@ohos.wifi'; ...@@ -16,7 +16,8 @@ import wifi from '@ohos.wifi';
enableWifi(): boolean enableWifi(): boolean
使能WLAN。 使能WLAN。
此接口为系统接口。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.SET_WIFI_INFO 和 ohos.permission.MANAGE_WIFI_CONNECTION,仅系统应用可用。 **需要权限:** ohos.permission.SET_WIFI_INFO 和 ohos.permission.MANAGE_WIFI_CONNECTION,仅系统应用可用。
...@@ -33,7 +34,8 @@ enableWifi(): boolean ...@@ -33,7 +34,8 @@ enableWifi(): boolean
disableWifi(): boolean disableWifi(): boolean
去使能WLAN。 去使能WLAN。
此接口为系统接口。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.SET_WIFI_INFO 和 ohos.permission.MANAGE_WIFI_CONNECTION,仅系统应用可用。 **需要权限:** ohos.permission.SET_WIFI_INFO 和 ohos.permission.MANAGE_WIFI_CONNECTION,仅系统应用可用。
...@@ -197,6 +199,8 @@ WLAN热点信息。 ...@@ -197,6 +199,8 @@ WLAN热点信息。
WLAN热点信息。 WLAN热点信息。
**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.Communication.WiFi.STA **系统能力:** SystemCapability.Communication.WiFi.STA
| **参数名** | **类型** | **读写属性** | **说明** | | **参数名** | **类型** | **读写属性** | **说明** |
...@@ -242,7 +246,8 @@ getScanInfosSync(): &nbsp;Array&lt;[WifiScanInfo](#wifiscaninfo)&gt; ...@@ -242,7 +246,8 @@ getScanInfosSync(): &nbsp;Array&lt;[WifiScanInfo](#wifiscaninfo)&gt;
addDeviceConfig(config: WifiDeviceConfig): Promise&lt;number&gt; addDeviceConfig(config: WifiDeviceConfig): Promise&lt;number&gt;
添加网络配置,使用Promise异步回调。 添加网络配置,使用Promise异步回调。
此接口为系统接口。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.SET_WIFI_INFO 和 ohos.permission.SET_WIFI_CONFIG **需要权限:** ohos.permission.SET_WIFI_INFO 和 ohos.permission.SET_WIFI_CONFIG
...@@ -271,20 +276,22 @@ WLAN配置信息。 ...@@ -271,20 +276,22 @@ WLAN配置信息。
| preSharedKey | string | 只读 | 热点的密钥。 | | preSharedKey | string | 只读 | 热点的密钥。 |
| isHiddenSsid | boolean | 只读 | 是否是隐藏网络。 | | isHiddenSsid | boolean | 只读 | 是否是隐藏网络。 |
| securityType | [WifiSecurityType](#wifisecuritytype) | 只读 | 加密类型。 | | securityType | [WifiSecurityType](#wifisecuritytype) | 只读 | 加密类型。 |
| creatorUid | number | 只读 | 创建用户的ID,仅系统应用可用。 | | creatorUid | number | 只读 | 创建用户的ID<br /> **系统接口:** 此接口为系统接口。 |
| disableReason | number | 只读 | 禁用原因,仅系统应用可用。 | | disableReason | number | 只读 | 禁用原因<br /> **系统接口:** 此接口为系统接口。 |
| netId | number | 只读 | 分配的网络ID, 仅系统应用可用。 | | netId | number | 只读 | 分配的网络ID<br /> **系统接口:** 此接口为系统接口。 |
| randomMacType | number | 只读 | 随机MAC类型,仅系统应用可用。 | | randomMacType | number | 只读 | 随机MAC类型<br /> **系统接口:** 此接口为系统接口。 |
| randomMacAddr | string | 只读 | 随机MAC地址,仅系统应用可用。 | | randomMacAddr | string | 只读 | 随机MAC地址<br /> **系统接口:** 此接口为系统接口。 |
| ipType | [IpType](#iptype7) | 只读 | IP地址类型,仅系统应用可用。 | | ipType | [IpType](#iptype7) | 只读 | IP地址类型<br /> **系统接口:** 此接口为系统接口。 |
| staticIp | [IpConfig](#ipconfig7) | 只读 | 静态IP配置信息,仅系统应用可用。 | | staticIp | [IpConfig](#ipconfig7) | 只读 | 静态IP配置信息<br /> **系统接口:** 此接口为系统接口。 |
| eapConfig<sup>9+</sup> | [WifiEapConfig](#wifieapconfig9) | 只读 | 可扩展身份验证协议配置,仅系统应用可用。 | | eapConfig<sup>9+</sup> | [WifiEapConfig](#wifieapconfig9) | 只读 | 可扩展身份验证协议配置<br /> **系统接口:** 此接口为系统接口。 |
## IpType<sup>7+</sup> ## IpType<sup>7+</sup>
表示IP类型的枚举。 表示IP类型的枚举。
**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.Communication.WiFi.STA **系统能力:** SystemCapability.Communication.WiFi.STA
| 名称 | 默认值 | 说明 | | 名称 | 默认值 | 说明 |
...@@ -298,6 +305,8 @@ WLAN配置信息。 ...@@ -298,6 +305,8 @@ WLAN配置信息。
IP配置信息。 IP配置信息。
**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.Communication.WiFi.STA **系统能力:** SystemCapability.Communication.WiFi.STA
| **参数名** | **类型** | **读写属性** | **说明** | | **参数名** | **类型** | **读写属性** | **说明** |
...@@ -312,6 +321,8 @@ IP配置信息。 ...@@ -312,6 +321,8 @@ IP配置信息。
可扩展身份验证协议配置信息。 可扩展身份验证协议配置信息。
**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.Communication.WiFi.STA **系统能力:** SystemCapability.Communication.WiFi.STA
| **参数名** | **类型** | **读写属性** | **说明** | | **参数名** | **类型** | **读写属性** | **说明** |
...@@ -335,6 +346,8 @@ IP配置信息。 ...@@ -335,6 +346,8 @@ IP配置信息。
表示EAP认证方式的枚举。 表示EAP认证方式的枚举。
**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.Communication.WiFi.STA **系统能力:** SystemCapability.Communication.WiFi.STA
| 名称 | 默认值 | 说明 | | 名称 | 默认值 | 说明 |
...@@ -354,6 +367,8 @@ IP配置信息。 ...@@ -354,6 +367,8 @@ IP配置信息。
表示第二阶段认证方式的枚举。 表示第二阶段认证方式的枚举。
**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.Communication.WiFi.STA **系统能力:** SystemCapability.Communication.WiFi.STA
| 名称 | 默认值 | 说明 | | 名称 | 默认值 | 说明 |
...@@ -373,7 +388,8 @@ IP配置信息。 ...@@ -373,7 +388,8 @@ IP配置信息。
addDeviceConfig(config: WifiDeviceConfig, callback: AsyncCallback&lt;number&gt;): void addDeviceConfig(config: WifiDeviceConfig, callback: AsyncCallback&lt;number&gt;): void
添加网络配置,使用callback异步回调。 添加网络配置,使用callback异步回调。
此接口为系统接口。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.SET_WIFI_INFO 和 ohos.permission.SET_WIFI_CONFIG **需要权限:** ohos.permission.SET_WIFI_INFO 和 ohos.permission.SET_WIFI_CONFIG
...@@ -556,7 +572,7 @@ getCandidateConfigs(): &nbsp;Array&lt;[WifiDeviceConfig](#wifideviceconfig)&gt; ...@@ -556,7 +572,7 @@ getCandidateConfigs(): &nbsp;Array&lt;[WifiDeviceConfig](#wifideviceconfig)&gt;
## wifi.connectToCandidateConfig<sup>9+</sup> ## wifi.connectToCandidateConfig<sup>9+</sup>
connectToCandidateConfig(networkId: number): boolean connectToCandidateConfig(networkId: number): void
连接到候选网络。 连接到候选网络。
...@@ -569,18 +585,14 @@ connectToCandidateConfig(networkId: number): boolean ...@@ -569,18 +585,14 @@ connectToCandidateConfig(networkId: number): boolean
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| networkId | number | 是 | 候选网络配置的ID。 | | networkId | number | 是 | 候选网络配置的ID。 |
**返回值:**
| **类型** | **说明** |
| -------- | -------- |
| boolean | true:操作成功,&nbsp;false:操作失败。 |
## wifi.connectToNetwork ## wifi.connectToNetwork
connectToNetwork(networkId: number): boolean connectToNetwork(networkId: number): boolean
连接到指定网络。 连接到指定网络。
此接口为系统接口。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.MANAGE_WIFI_CONNECTION,仅系统应用可用。 **需要权限:** ohos.permission.MANAGE_WIFI_CONNECTION,仅系统应用可用。
...@@ -602,10 +614,10 @@ connectToNetwork(networkId: number): boolean ...@@ -602,10 +614,10 @@ connectToNetwork(networkId: number): boolean
connectToDevice(config: WifiDeviceConfig): boolean connectToDevice(config: WifiDeviceConfig): boolean
连接到指定网络。 连接到指定网络。
此接口为系统接口。
**需要权限:** **系统接口:** 此接口为系统接口。
ohos.permission.SET_WIFI_INFO 和 ohos.permission.SET_WIFI_CONFIG 和 ohos.permissio.MANAGE_WIFI_CONNECTION,仅系统应用可用。
**需要权限:** ohos.permission.SET_WIFI_INFO 和 ohos.permission.SET_WIFI_CONFIG 和 ohos.permissio.MANAGE_WIFI_CONNECTION,仅系统应用可用。
**系统能力:** **系统能力:**
SystemCapability.Communication.WiFi.STA SystemCapability.Communication.WiFi.STA
...@@ -626,10 +638,10 @@ connectToDevice(config: WifiDeviceConfig): boolean ...@@ -626,10 +638,10 @@ connectToDevice(config: WifiDeviceConfig): boolean
disconnect(): boolean disconnect(): boolean
连接到指定网络。 连接到指定网络。
此接口为系统接口。
**需要权限:** **系统接口:** 此接口为系统接口。
ohos.permission.SET_WIFI_INFO 和 ohos.permissio.MANAGE_WIFI_CONNECTION,仅系统应用可用。
**需要权限:** ohos.permission.SET_WIFI_INFO 和 ohos.permission.MANAGE_WIFI_CONNECTION,仅系统应用可用。
**系统能力:** **系统能力:**
SystemCapability.Communication.WiFi.STA SystemCapability.Communication.WiFi.STA
...@@ -723,19 +735,19 @@ getLinkedInfo(callback: AsyncCallback&lt;WifiLinkedInfo&gt;): void ...@@ -723,19 +735,19 @@ getLinkedInfo(callback: AsyncCallback&lt;WifiLinkedInfo&gt;): void
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| ssid | string | 只读 | 热点的SSID,编码格式为UTF-8。 | | ssid | string | 只读 | 热点的SSID,编码格式为UTF-8。 |
| bssid | string | 只读 | 热点的BSSID。 | | bssid | string | 只读 | 热点的BSSID。 |
| networkId | number | 只读 | 网络配置ID, 仅系统应用可用。 | | networkId | number | 只读 | 网络配置ID<br /> **系统接口:** 此接口为系统接口。 |
| rssi | number | 只读 | 热点的信号强度(dBm)。 | | rssi | number | 只读 | 热点的信号强度(dBm)。 |
| band | number | 只读 | WLAN接入点的频段。 | | band | number | 只读 | WLAN接入点的频段。 |
| linkSpeed | number | 只读 | WLAN接入点的速度。 | | linkSpeed | number | 只读 | WLAN接入点的速度。 |
| frequency | number | 只读 | WLAN接入点的频率。 | | frequency | number | 只读 | WLAN接入点的频率。 |
| isHidden | boolean | 只读 | WLAN接入点是否是隐藏网络。 | | isHidden | boolean | 只读 | WLAN接入点是否是隐藏网络。 |
| isRestricted | boolean | 只读 | WLAN接入点是否限制数据量。 | | isRestricted | boolean | 只读 | WLAN接入点是否限制数据量。 |
| chload | number | 只读 | 连接负载,值越大表示负载约高,仅系统应用可用。 | | chload | number | 只读 | 连接负载,值越大表示负载约高<br /> **系统接口:** 此接口为系统接口。 |
| snr | number | 只读 | 信噪比,仅系统应用可用。 | | snr | number | 只读 | 信噪比<br /> **系统接口:** 此接口为系统接口。 |
| macType<sup>9+</sup> | number | 只读 | MAC地址类型。 | | macType<sup>9+</sup> | number | 只读 | MAC地址类型。 |
| macAddress | string | 只读 | 设备的MAC地址。 | | macAddress | string | 只读 | 设备的MAC地址。 |
| ipAddress | number | 只读 | WLAN连接的IP地址。 | | ipAddress | number | 只读 | WLAN连接的IP地址。 |
| suppState | [SuppState](#suppstate) | 只读 | 请求状态,仅系统应用可用。| | suppState | [SuppState](#suppstate) | 只读 | 请求状态<br /> **系统接口:** 此接口为系统接口。 |
| connState | [ConnState](#connstate) | 只读 | WLAN连接状态。 | | connState | [ConnState](#connstate) | 只读 | WLAN连接状态。 |
...@@ -761,6 +773,8 @@ getLinkedInfo(callback: AsyncCallback&lt;WifiLinkedInfo&gt;): void ...@@ -761,6 +773,8 @@ getLinkedInfo(callback: AsyncCallback&lt;WifiLinkedInfo&gt;): void
表示请求状态的枚举。 表示请求状态的枚举。
**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.Communication.WiFi.STA **系统能力:** SystemCapability.Communication.WiFi.STA
| 名称 | 默认值 | 说明 | | 名称 | 默认值 | 说明 |
...@@ -800,7 +814,8 @@ isConnected(): boolean ...@@ -800,7 +814,8 @@ isConnected(): boolean
getSupportedFeatures(): number getSupportedFeatures(): number
查询设备支持的特性。 查询设备支持的特性。
此接口为系统接口。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_WIFI_INFO **需要权限:** ohos.permission.GET_WIFI_INFO
...@@ -854,7 +869,8 @@ isFeatureSupported(featureId: number): boolean ...@@ -854,7 +869,8 @@ isFeatureSupported(featureId: number): boolean
getDeviceMacAddress(): string[] getDeviceMacAddress(): string[]
获取设备的MAC地址。 获取设备的MAC地址。
此接口为系统接口。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_WIFI_LOCAL_MAC 和 ohos.permission.GET_WIFI_INFO,仅系统应用可用。 **需要权限:** ohos.permission.GET_WIFI_LOCAL_MAC 和 ohos.permission.GET_WIFI_INFO,仅系统应用可用。
...@@ -920,7 +936,8 @@ getCountryCode(): string ...@@ -920,7 +936,8 @@ getCountryCode(): string
reassociate(): boolean reassociate(): boolean
重新关联网络。 重新关联网络。
此接口为系统接口。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.SET_WIFI_INFO 和 ohos.permission.MANAGE_WIFI_CONNECTION,仅系统应用可用。 **需要权限:** ohos.permission.SET_WIFI_INFO 和 ohos.permission.MANAGE_WIFI_CONNECTION,仅系统应用可用。
...@@ -937,7 +954,8 @@ reassociate(): boolean ...@@ -937,7 +954,8 @@ reassociate(): boolean
reconnect(): boolean reconnect(): boolean
重新连接网络。 重新连接网络。
此接口为系统接口。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.SET_WIFI_INFO 和 ohos.permission.MANAGE_WIFI_CONNECTION,仅系统应用可用。 **需要权限:** ohos.permission.SET_WIFI_INFO 和 ohos.permission.MANAGE_WIFI_CONNECTION,仅系统应用可用。
...@@ -954,7 +972,8 @@ reconnect(): boolean ...@@ -954,7 +972,8 @@ reconnect(): boolean
getDeviceConfigs(): &nbsp;Array&lt;[WifiDeviceConfig](#wifideviceconfig)&gt; getDeviceConfigs(): &nbsp;Array&lt;[WifiDeviceConfig](#wifideviceconfig)&gt;
获取网络配置。 获取网络配置。
此接口为系统接口。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_WIFI_INFO 和 ohos.permission.LOCATION 和 ohos.permission.GET_WIFI_CONFIG **需要权限:** ohos.permission.GET_WIFI_INFO 和 ohos.permission.LOCATION 和 ohos.permission.GET_WIFI_CONFIG
...@@ -968,10 +987,11 @@ getDeviceConfigs(): &nbsp;Array&lt;[WifiDeviceConfig](#wifideviceconfig)&gt; ...@@ -968,10 +987,11 @@ getDeviceConfigs(): &nbsp;Array&lt;[WifiDeviceConfig](#wifideviceconfig)&gt;
## wifi.updateNetwork<sup>7+</sup> ## wifi.updateNetwork<sup>7+</sup>
updateNetwork(config: WifiDeviceConfig): boolean updateNetwork(config: WifiDeviceConfig): number
更新网络配置。 更新网络配置。
此接口为系统接口。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.SET_WIFI_INFO 和 ohos.permission.SET_WIFI_CONFIG **需要权限:** ohos.permission.SET_WIFI_INFO 和 ohos.permission.SET_WIFI_CONFIG
...@@ -985,7 +1005,7 @@ updateNetwork(config: WifiDeviceConfig): boolean ...@@ -985,7 +1005,7 @@ updateNetwork(config: WifiDeviceConfig): boolean
**返回值:** **返回值:**
| **类型** | **说明** | | **类型** | **说明** |
| -------- | -------- | | -------- | -------- |
| boolean | true:操作成功,&nbsp;false:操作失败。 | | number | 返回更新的网络配置ID,如果值为-1表示更新失败。 |
## wifi.disableNetwork<sup>7+</sup> ## wifi.disableNetwork<sup>7+</sup>
...@@ -993,7 +1013,8 @@ updateNetwork(config: WifiDeviceConfig): boolean ...@@ -993,7 +1013,8 @@ updateNetwork(config: WifiDeviceConfig): boolean
disableNetwork(netId: number): boolean disableNetwork(netId: number): boolean
去使能网络配置。 去使能网络配置。
此接口为系统接口。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.SET_WIFI_INFO 和 ohos.permission.MANAGE_WIFI_CONNECTION,仅系统应用可用。 **需要权限:** ohos.permission.SET_WIFI_INFO 和 ohos.permission.MANAGE_WIFI_CONNECTION,仅系统应用可用。
...@@ -1015,7 +1036,8 @@ disableNetwork(netId: number): boolean ...@@ -1015,7 +1036,8 @@ disableNetwork(netId: number): boolean
removeAllNetwork(): boolean removeAllNetwork(): boolean
移除所有网络配置。 移除所有网络配置。
此接口为系统接口。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.SET_WIFI_INFO 和 ohos.permission.MANAGE_WIFI_CONNECTION,仅系统应用可用。 **需要权限:** ohos.permission.SET_WIFI_INFO 和 ohos.permission.MANAGE_WIFI_CONNECTION,仅系统应用可用。
...@@ -1032,7 +1054,8 @@ removeAllNetwork(): boolean ...@@ -1032,7 +1054,8 @@ removeAllNetwork(): boolean
removeDevice(id: number): boolean removeDevice(id: number): boolean
移除指定的网络配置。 移除指定的网络配置。
此接口为系统接口。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.SET_WIFI_INFO 和 ohos.permission.MANAGE_WIFI_CONNECTION,仅系统应用可用。 **需要权限:** ohos.permission.SET_WIFI_INFO 和 ohos.permission.MANAGE_WIFI_CONNECTION,仅系统应用可用。
...@@ -1054,7 +1077,8 @@ removeDevice(id: number): boolean ...@@ -1054,7 +1077,8 @@ removeDevice(id: number): boolean
enableHotspot(): boolean enableHotspot(): boolean
使能热点。 使能热点。
此接口为系统接口。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.MANAGE_WIFI_HOTSPOT,仅系统应用可用。 **需要权限:** ohos.permission.MANAGE_WIFI_HOTSPOT,仅系统应用可用。
...@@ -1071,7 +1095,8 @@ enableHotspot(): boolean ...@@ -1071,7 +1095,8 @@ enableHotspot(): boolean
disableHotspot(): boolean disableHotspot(): boolean
去使能热点。 去使能热点。
此接口为系统接口。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.MANAGE_WIFI_HOTSPOT,仅系统应用可用。 **需要权限:** ohos.permission.MANAGE_WIFI_HOTSPOT,仅系统应用可用。
...@@ -1088,7 +1113,8 @@ disableHotspot(): boolean ...@@ -1088,7 +1113,8 @@ disableHotspot(): boolean
isHotspotDualBandSupported(): boolean isHotspotDualBandSupported(): boolean
热点是否支持双频。 热点是否支持双频。
此接口为系统接口。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_WIFI_INFO 和 ohos.permission.MANAGE_WIFI_HOTSPOT,仅系统应用可用。 **需要权限:** ohos.permission.GET_WIFI_INFO 和 ohos.permission.MANAGE_WIFI_HOTSPOT,仅系统应用可用。
...@@ -1105,7 +1131,8 @@ isHotspotDualBandSupported(): boolean ...@@ -1105,7 +1131,8 @@ isHotspotDualBandSupported(): boolean
isHotspotActive(): boolean isHotspotActive(): boolean
热点是否已使能。 热点是否已使能。
此接口为系统接口。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_WIFI_INFO **需要权限:** ohos.permission.GET_WIFI_INFO
...@@ -1122,7 +1149,8 @@ isHotspotActive(): boolean ...@@ -1122,7 +1149,8 @@ isHotspotActive(): boolean
setHotspotConfig(config: HotspotConfig): boolean setHotspotConfig(config: HotspotConfig): boolean
设置热点配置信息。 设置热点配置信息。
此接口为系统接口。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.SET_WIFI_INFO 和 ohos.permission.GET_WIFI_CONFIG **需要权限:** ohos.permission.SET_WIFI_INFO 和 ohos.permission.GET_WIFI_CONFIG
...@@ -1143,6 +1171,8 @@ setHotspotConfig(config: HotspotConfig): boolean ...@@ -1143,6 +1171,8 @@ setHotspotConfig(config: HotspotConfig): boolean
热点配置信息。 热点配置信息。
**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.Communication.WiFi.AP.Core **系统能力:** SystemCapability.Communication.WiFi.AP.Core
| **参数名** | **类型** | **读写属性** | **说明** | | **参数名** | **类型** | **读写属性** | **说明** |
...@@ -1159,7 +1189,8 @@ setHotspotConfig(config: HotspotConfig): boolean ...@@ -1159,7 +1189,8 @@ setHotspotConfig(config: HotspotConfig): boolean
getHotspotConfig(): HotspotConfig getHotspotConfig(): HotspotConfig
获取热点配置信息。 获取热点配置信息。
此接口为系统接口。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_WIFI_INFO 和 ohos.permission.GET_WIFI_CONFIG **需要权限:** ohos.permission.GET_WIFI_INFO 和 ohos.permission.GET_WIFI_CONFIG
...@@ -1176,7 +1207,8 @@ getHotspotConfig(): HotspotConfig ...@@ -1176,7 +1207,8 @@ getHotspotConfig(): HotspotConfig
getStations(): &nbsp;Array&lt;[StationInfo](#stationinfo7)&gt; getStations(): &nbsp;Array&lt;[StationInfo](#stationinfo7)&gt;
获取连接的设备。 获取连接的设备。
此接口为系统接口。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_WIFI_INFO 和 ohos.permission.LOCATION 和 ohos.permission.MANAGE_WIFI_HOTSPOT,仅系统应用可用。 **需要权限:** ohos.permission.GET_WIFI_INFO 和 ohos.permission.LOCATION 和 ohos.permission.MANAGE_WIFI_HOTSPOT,仅系统应用可用。
...@@ -1192,6 +1224,8 @@ getStations(): &nbsp;Array&lt;[StationInfo](#stationinfo7)&gt; ...@@ -1192,6 +1224,8 @@ getStations(): &nbsp;Array&lt;[StationInfo](#stationinfo7)&gt;
接入的设备信息。 接入的设备信息。
**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.Communication.WiFi.AP.Core **系统能力:** SystemCapability.Communication.WiFi.AP.Core
| **参数名** | **类型** | **读写属性** | **说明** | | **参数名** | **类型** | **读写属性** | **说明** |
...@@ -1594,7 +1628,7 @@ deletePersistentGroup(netId: number): boolean ...@@ -1594,7 +1628,7 @@ deletePersistentGroup(netId: number): boolean
删除永久组。 删除永久组。
**需要权限:** ohos.permission.GET_WIFI_INFO **需要权限:** ohos.permission.SET_WIFI_INFO 和 ohos.permission.MANAGE_WIFI_CONNECTION
**系统能力:** SystemCapability.Communication.WiFi.P2P **系统能力:** SystemCapability.Communication.WiFi.P2P
...@@ -1611,7 +1645,8 @@ deletePersistentGroup(netId: number): boolean ...@@ -1611,7 +1645,8 @@ deletePersistentGroup(netId: number): boolean
## wifi.getP2pGroups<sup>9+</sup> ## wifi.getP2pGroups<sup>9+</sup>
此接口为系统接口。
**系统接口:** 此接口为系统接口。
getP2pGroups(): Promise&lt;Array&lt;WifiP2pGroupInfo&gt;&gt; getP2pGroups(): Promise&lt;Array&lt;WifiP2pGroupInfo&gt;&gt;
...@@ -1667,10 +1702,10 @@ getP2pGroups(callback: AsyncCallback&lt;Array&lt;WifiP2pGroupInfo&gt;&gt;): void ...@@ -1667,10 +1702,10 @@ getP2pGroups(callback: AsyncCallback&lt;Array&lt;WifiP2pGroupInfo&gt;&gt;): void
setDeviceName(devName: string): boolean setDeviceName(devName: string): boolean
设置设备名称。 设置设备名称。
此接口为系统接口。
**需要权限:** **系统接口:** 此接口为系统接口。
ohos.permission.SET_WIFI_INFO 和 ohos.permission.MANAGE_WIFI_CONNECTION,仅系统应用可用。
**需要权限:** ohos.permission.SET_WIFI_INFO 和 ohos.permission.MANAGE_WIFI_CONNECTION,仅系统应用可用。
**系统能力:** SystemCapability.Communication.WiFi.P2P **系统能力:** SystemCapability.Communication.WiFi.P2P
......
文件模式从 100755 更改为 100644
...@@ -65,48 +65,46 @@ WLAN Driver框架主要由如下模块组成: ...@@ -65,48 +65,46 @@ WLAN Driver框架主要由如下模块组成:
WLAN模块有三部分对外开放的API接口,如下图所示: WLAN模块有三部分对外开放的API接口,如下图所示:
1. 驱动直接调用WLAN模块能力接口。 1. 对上层服务提供HDI以及HAL能力接口。
2. 提供给各厂商实现的能力接口。 2. 提供给各厂商实现的能力接口。
3. 对HDI层提供的能力接口 3. 驱动直接调用WLAN模块能力接口。
**图3** WLAN驱动接口框架图 **图3** WLAN驱动接口框架图
![image](figures/WLAN驱动接口框架图.png "WLAN驱动接口框架图") ![image](figures/WLAN驱动接口框架图.png "WLAN驱动接口框架图")
- WLAN驱动模块提供给驱动开发人员可直接调用的能力接口,主要功能有:创建/释放WifiModule、关联/取消关联、申请/释放NetBuf、lwip的pbuf和NetBuf的相互转换等。 - WLAN驱动模块对上层服务提供的HDI能力接口(适用于标准系统),主要功能有:创建/销毁ifeature对象、设置/获取功率模式等。提供的部分接口说明如表1所示:
可直接调用的接口如表1、表2和表3所示。
**表1** wifi_module.h **表1** IWlanInterface.idl
| 接口名称 | 功能描述 | | 接口名称 | 功能描述 |
| -------- | -------- | | -------- | -------- |
| struct&nbsp;WifiModule&nbsp;\*WifiModuleCreate(const&nbsp;struct&nbsp;HdfConfigWifiModuleConfig&nbsp;\*config) | 基于HDF开发WLAN驱动时,创建一个WifiModule。 | | CreateFeature([in]&nbsp;int&nbsp;type,&nbsp;[out]&nbsp;struct&nbsp;HdfFeatureInfo&nbsp;ifeature); | 创建ifeature对象。 |
| void&nbsp;WifiModuleDelete(struct&nbsp;WifiModule&nbsp;\*module) | 基于HDF开发WLAN驱动时,删除并释放WifiModule所有数据。 | | DestroyFeature([in]&nbsp;struct&nbsp;HdfFeatureInfo&nbsp;ifeature); | 销毁ifeature对象。 |
| int32_t&nbsp;DelFeature(struct&nbsp;WifiModule&nbsp;\*module,&nbsp;uint16_t&nbsp;featureType) | 基于HDF开发WLAN驱动时,从WifiModule删除一个功能组件。 | | GetPowerMode([in]&nbsp;struct&nbsp;HdfFeatureInfo&nbsp;ifeature,&nbsp;[out]&nbsp;unsigned&nbsp;char&nbsp;mode); | 获取功率模式。 |
| int32_t&nbsp;AddFeature(struct&nbsp;WifiModule&nbsp;\*module,&nbsp;uint16_t&nbsp;featureType,<br>&nbsp;struct&nbsp;WifiFeature&nbsp;\*featureData) | 基于HDF开发WLAN驱动时,注册一个功能组件到WifiModule。 | | SetPowerMode([in]&nbsp;struct&nbsp;HdfFeatureInfo&nbsp;ifeature,&nbsp;[in]&nbsp;unsigned&nbsp;char&nbsp;mode); | 设置功率模式。 |
**表2** wifi_mac80211_ops.h - WLAN驱动模块对上层服务提供的HAL能力接口(适用于小型系统及轻量系统),主要功能有:创建/销毁 IWiFi对象、设置MAC地址等。提供的部分接口说明如表2、表3所示:
**表2** wifi_hal.h
| 接口名称 | 功能描述 | | 接口名称 | 功能描述 |
| -------- | -------- | | -------- | -------- |
| int32_t&nbsp;(\*startAp)(NetDevice&nbsp;\*netDev) | 启动AP。 | | int32_t&nbsp;WifiConstruct(struct&nbsp;IWiFi&nbsp;\*\*wifiInstance) | 创建IWiFi对象,提供IWiFi基本能力。 |
| int32_t&nbsp;(\*stopAp)(NetDevice&nbsp;\*netDev) | 停止AP。 | | int32_t&nbsp;WifiDestruct(struct&nbsp;IWiFi&nbsp;\*\*wifiInstance) | 销毁IWiFi对象。 |
| int32_t&nbsp;(\*connect)(NetDevice&nbsp;\*netDev,&nbsp;WifiConnectParams&nbsp;\*param) | 开始关联。 | | int32_t&nbsp;(\*start)(struct&nbsp;IWiFi&nbsp;\*) | 创建HAL和驱动之间的通道及获取驱动支持的网卡信息。 |
| int32_t&nbsp;(\*disconnect)(NetDevice&nbsp;\*netDev,&nbsp;uint16_t&nbsp;reasonCode) | 取消关联。 | | int32_t&nbsp;(\*stop)(struct&nbsp;IWiFi&nbsp;\*) | 销毁通道。 |
**表3** hdf_netbuf.h **表3** wifi_hal_base_feature.h
| 接口名称 | 功能描述 | | 接口名称 | 功能描述 |
| -------- | -------- | | -------- | -------- |
| static&nbsp;inline&nbsp;void&nbsp;NetBufQueueInit(struct&nbsp;NetBufQueue&nbsp;\*q) | 初始化NetBuf队列。 | | int32_t&nbsp;(\*getFeatureType)(const&nbsp;struct&nbsp;IWiFiBaseFeature&nbsp;\*) | 获取特性的类型。 |
| struct&nbsp;NetBuf&nbsp;\*NetBufAlloc(uint32_t&nbsp;size) | 申请NetBuf。 | | int32_t&nbsp;(\*setMacAddress)(const&nbsp;struct&nbsp;IWiFiBaseFeature&nbsp;\*,&nbsp;unsigned&nbsp;char&nbsp;\*,&nbsp;uint8_t) | 设置MAC地址。 |
| void&nbsp;NetBufFree(struct&nbsp;NetBuf&nbsp;\*nb) | 释放NetBuf | | int32_t&nbsp;(\*getDeviceMacAddress)(const&nbsp;struct&nbsp;IWiFiBaseFeature&nbsp;\*,&nbsp;unsigned&nbsp;char&nbsp;\*,&nbsp;uint8_t) | 获取设备持久化的MAC地址。 |
| struct&nbsp;NetBuf&nbsp;\*Pbuf2NetBuf(const&nbsp;struct&nbsp;NetDevice&nbsp;\*netdev,&nbsp;struct&nbsp;pbuf&nbsp;\*lwipBuf) | lwip的pbuf转换为NetBuf。 | | int32_t&nbsp;(\*setTxPower)(const&nbsp;struct&nbsp;IWiFiBaseFeature&nbsp;\*,&nbsp;int32_t) | 设置发射功率。 |
| struct&nbsp;pbuf&nbsp;\*NetBuf2Pbuf(const&nbsp;struct&nbsp;NetBuf&nbsp;\*nb) | NetBuf转换为lwip的pbuf。 |
- WLAN驱动模块也提供了需要驱动开发人员自行去填充具体实现内容的能力接口,主要功能有:初始化/注销NetDevice、打开/关闭NetDevice、获取NetDevice的状态等。提供的部分接口说明如表4所示: - WLAN驱动模块也提供了需要驱动开发人员自行去填充具体实现内容的能力接口,主要功能有:初始化/注销NetDevice、打开/关闭NetDevice、获取NetDevice的状态等。提供的部分接口说明如表4所示:
...@@ -121,133 +119,142 @@ WLAN模块有三部分对外开放的API接口,如下图所示: ...@@ -121,133 +119,142 @@ WLAN模块有三部分对外开放的API接口,如下图所示:
| int32_t&nbsp;(\*open)(struct&nbsp;NetDevice&nbsp;\*netDev) | 打开NetDevice。 | | int32_t&nbsp;(\*open)(struct&nbsp;NetDevice&nbsp;\*netDev) | 打开NetDevice。 |
| int32_t&nbsp;(\*stop)(struct&nbsp;NetDevice&nbsp;\*netDev) | 关闭NetDevice。 | | int32_t&nbsp;(\*stop)(struct&nbsp;NetDevice&nbsp;\*netDev) | 关闭NetDevice。 |
- WLAN驱动模块对HDI层提供的能力接口,主要功能有:创建/销毁 IWiFi对象、设置MAC地址等。提供的部分接口说明如表5、表6所示: - WLAN驱动模块提供给驱动开发人员可直接调用的能力接口,主要功能有:创建/释放WifiModule、关联/取消关联、申请/释放NetBuf、lwip的pbuf和NetBuf的相互转换等。
可直接调用的接口如表5、表6和表7所示。
**表5** wifi_hal.h **表5** wifi_module.h
| 接口名称 | 功能描述 | | 接口名称 | 功能描述 |
| -------- | -------- | | -------- | -------- |
| int32_t&nbsp;WifiConstruct(struct&nbsp;IWiFi&nbsp;\*\*wifiInstance) | 创建IWiFi对象,提供IWiFi基本能力。 | | struct&nbsp;WifiModule&nbsp;\*WifiModuleCreate(const&nbsp;struct&nbsp;HdfConfigWifiModuleConfig&nbsp;\*config) | 基于HDF开发WLAN驱动时,创建一个WifiModule。 |
| int32_t&nbsp;WifiDestruct(struct&nbsp;IWiFi&nbsp;\*\*wifiInstance) | 销毁IWiFi对象。 | | void&nbsp;WifiModuleDelete(struct&nbsp;WifiModule&nbsp;\*module) | 基于HDF开发WLAN驱动时,删除并释放WifiModule所有数据。 |
| int32_t&nbsp;(\*start)(struct&nbsp;IWiFi&nbsp;\*) | 创建HAL和驱动之间的通道及获取驱动支持的网卡信息。 | | int32_t&nbsp;DelFeature(struct&nbsp;WifiModule&nbsp;\*module,&nbsp;uint16_t&nbsp;featureType) | 基于HDF开发WLAN驱动时,从WifiModule删除一个功能组件。 |
| int32_t&nbsp;(\*stop)(struct&nbsp;IWiFi&nbsp;\*) | 销毁通道。 | | int32_t&nbsp;AddFeature(struct&nbsp;WifiModule&nbsp;\*module,&nbsp;uint16_t&nbsp;featureType,<br>&nbsp;struct&nbsp;WifiFeature&nbsp;\*featureData) | 基于HDF开发WLAN驱动时,注册一个功能组件到WifiModule。 |
**表6** wifi_hal_base_feature.h **表6** wifi_mac80211_ops.h
| 接口名称 | 功能描述 | | 接口名称 | 功能描述 |
| -------- | -------- | | -------- | -------- |
| int32_t&nbsp;(\*getFeatureType)(const&nbsp;struct&nbsp;IWiFiBaseFeature&nbsp;\*) | 获取特性的类型。 | | int32_t&nbsp;(\*startAp)(NetDevice&nbsp;\*netDev) | 启动AP。 |
| int32_t&nbsp;(\*setMacAddress)(const&nbsp;struct&nbsp;IWiFiBaseFeature&nbsp;\*,&nbsp;unsigned&nbsp;char&nbsp;\*,&nbsp;uint8_t) | 设置MAC地址。 | | int32_t&nbsp;(\*stopAp)(NetDevice&nbsp;\*netDev) | 停止AP。 |
| int32_t&nbsp;(\*getDeviceMacAddress)(const&nbsp;struct&nbsp;IWiFiBaseFeature&nbsp;\*,&nbsp;unsigned&nbsp;char&nbsp;\*,&nbsp;uint8_t) | 获取设备持久化的MAC地址。 | | int32_t&nbsp;(\*connect)(NetDevice&nbsp;\*netDev,&nbsp;WifiConnectParams&nbsp;\*param) | 开始关联。 |
| int32_t&nbsp;(\*setTxPower)(const&nbsp;struct&nbsp;IWiFiBaseFeature&nbsp;\*,&nbsp;int32_t) | 设置发射功率。 | | int32_t&nbsp;(\*disconnect)(NetDevice&nbsp;\*netDev,&nbsp;uint16_t&nbsp;reasonCode) | 取消关联。 |
**表7** hdf_netbuf.h
### 开发步骤 | 接口名称 | 功能描述 |
| -------- | -------- |
| static&nbsp;inline&nbsp;void&nbsp;NetBufQueueInit(struct&nbsp;NetBufQueue&nbsp;\*q) | 初始化NetBuf队列。 |
| struct&nbsp;NetBuf&nbsp;\*NetBufAlloc(uint32_t&nbsp;size) | 申请NetBuf。 |
| void&nbsp;NetBufFree(struct&nbsp;NetBuf&nbsp;\*nb) | 释放NetBuf |
| struct&nbsp;NetBuf&nbsp;\*Pbuf2NetBuf(const&nbsp;struct&nbsp;NetDevice&nbsp;\*netdev,&nbsp;struct&nbsp;pbuf&nbsp;\*lwipBuf) | lwip的pbuf转换为NetBuf。 |
| struct&nbsp;pbuf&nbsp;\*NetBuf2Pbuf(const&nbsp;struct&nbsp;NetBuf&nbsp;\*nb) | NetBuf转换为lwip的pbuf。 |
WLAN驱动基于HDF框架和PLATFORM框架开发,不区分OS和芯片平台,为不同厂商的WLAN模组提供统一的驱动模型,各WLAN模组厂商根据如下指导适配WLAN驱动框架。 ### 开发步骤
WLAN驱动基于HDF框架和Platform框架开发,不区分OS和芯片平台,为不同厂商的WLAN模组提供统一的驱动模型,各WLAN模组厂商根据如下指导适配WLAN驱动框架。
1. 通过wifi_config.hcs文件,配置硬件(例如module、芯片等)相关的参数。此配置文件通过HDF框架中对应的接口解析后,生成全量配置的结构体对象。 1. 配置硬件(例如module、芯片等)相关的参数。在wlan_platform.hcs文件中对参数进行配置,该文件会通过HDF框架中对应的接口解析后,生成全量配置的结构体对象。
2. Module初始化,创建Module 2. 初始化和去初始化WLAN模块相关适配(如WLAN芯片初始化和去初始化、WLAN芯片驱动初始化和去初始化)
3. 挂接Chip,初始化Chip 3. 控制流命令下发的适配
4. 挂接上层WPA(Wi-Fi Protected Access)业务 4. 事件上报的调用
### 开发实例 ### 开发实例
本例程提供WLAN模块初始化过程的完整使用流程。示例如下(以Hi3881WLAN芯片为例): 本例程提供WLAN模块初始化过程的完整使用流程。示例如下(以Hi3881WLAN芯片为例):
1、根据硬件,修改配置参数。 1. 根据硬件具体情况修改配置参数。
``` ```text
/* 根据硬件参数,通过wlan_platform.hcs配置相关参数,以下是WLAN平台配置的示例 */ /* 根据硬件具体情况,在wlan_platform.hcs中配置相关参数,以下是WLAN平台配置的示例 */
hisi :& deviceList { hisi :& deviceList {
device0 :: deviceInst { device0 :: deviceInst {
deviceInstId = 0; deviceInstId = 0;
powers { powers {
power0 { power0 {
powerSeqDelay = 0; /* 电源序列延时 */ powerSeqDelay = 0; /* 电源序列延时 */
powerType = 1; /* 电源类型:0--总是打开;1--GPIO */ powerType = 1; /* 电源类型,0表示总是打开;1表示GPIO */
gpioId = 1; /* GPIO管脚号 */ gpioId = 1; /* GPIO管脚号 */
activeLevel=1; /* 有效电平:0--低;1--高 */ activeLevel=1; /* 有效电平,0表示低电平有效;1表示高电平有效 */
} }
power1 { power1 {
powerSeqDelay = 0; /* 电源序列延时 */ powerSeqDelay = 0; /* 电源序列延时 */
powerType = 0; /* 电源类型:0--总是打开;1--GPIO */ powerType = 0; /* 电源类型,0表示总是打开;1表示GPIO */
} }
} }
reset { reset {
resetType = 0; /* 复位类型:0--不管理;1--GPIO */ resetType = 0; /* 复位类型,0表示不管理;1表示GPIO */
gpioId = 2; /* GPIO管脚号 */ gpioId = 2; /* GPIO管脚号 */
activeLevel=1; /* 有效电平:0--低;1--高 */ activeLevel=1; /* 有效电平,0表示低电平有效;1表示高电平有效 */
resetHoldTime = 30; /* 复位配置后的等待时间(ms) */ resetHoldTime = 30; /* 复位配置后的等待时间(ms) */
} }
bootUpTimeout = 30; /* 启动超时时间(ms) */ bootUpTimeout = 30; /* 启动超时时间(ms) */
bus { bus {
busType = 0; /* 总线类型:0-sdio */ busEnable = 1; /* bus总线是否初始化,0-表示不初始化; 1表示初始化 */
busType = 0; /* 总线类型,0表示sdio */
busId = 2; /* 总线号 */ busId = 2; /* 总线号 */
funcNum = [1]; /* SDIO功能号 */ funcNum = [1]; /* SDIO功能号 */
timeout = 1000; /* 读/写数据的超时时间 */ timeout = 1000; /* 读/写数据的超时时间 */
blockSize = 512; /* 读/写数据的块大小 */ blockSize = 512; /* 读/写数据的块大小 */
} }
} }
} }
/* 每一块芯片添加配置文件wlan_chip_<芯片名>.hcs(如:wlan_chip_hi3881.hcs),配置相关参数。以下是hi3881的配置示例 */ /* 每一块芯片添加配置文件wlan_chip_<芯片名>.hcs(如:wlan_chip_hi3881.hcs),配置相关参数。以下是hi3881的配置示例 */
root { root {
wlan_config { wlan_config {
hi3881 :& chipList { hi3881 :& chipList {
chipHi3881 :: chipInst { chipHi3881 :: chipInst {
match_attr = "hdf_wlan_chips_hi3881"; /* 配置匹配标识 */ match_attr = "hdf_wlan_chips_hi3881"; /* 配置匹配标识 */
chipName = "hi3881"; /* WLAN芯片的名称 */ chipName = "hi3881"; /* WLAN芯片的名称 */
sdio { bus {
vendorId = 0x0296; /* 厂商Id */ vendorId = 0x0296; /* 厂商ID */
deviceId = [0x5347]; /* 设备Id */ deviceId = [0x5347]; /* 设备ID */
} }
} }
} }
} }
} }
``` ```
2、适配挂接WLAN芯片的初始化和去初始化、WLAN芯片驱动的初始化和去初始化。 2. 适配挂接WLAN芯片的初始化和去初始化、WLAN芯片驱动的初始化和去初始化。
``` ```c
/* WLAN初始化挂接流程 */ #include "hdf_device_desc.h"
#include "hdf_device_desc.h" #include "hdf_wifi_product.h"
#include "hdf_wifi_product.h" #include "hdf_log.h"
#include "hdf_log.h" #include "osal_mem.h"
#include "osal_mem.h" #include "hdf_wlan_chipdriver_manager.h"
#include "hdf_wlan_chipdriver_manager.h" #include "securec.h"
#include "securec.h" #include "wifi_module.h"
#include "wifi_module.h" #include "hi_wifi_api.h"
#include "hi_wifi_api.h" #include "hi_types_base.h"
#include "hi_types_base.h"
#define HDF_LOG_TAG Hi3881Driver
#define HDF_LOG_TAG Hi3881Driver
/* WLAN芯片的初始化和去初始化函数。 */
/* WLAN芯片的初始化和去初始化函数 */ int32_t InitHi3881Chip(struct HdfWlanDevice *device);
int32_t InitHi3881Chip(struct HdfWlanDevice *device); int32_t DeinitHi3881Chip(struct HdfWlanDevice *device);
int32_t DeinitHi3881Chip(struct HdfWlanDevice *device); /* WLAN芯片驱动的初始化和去初始化函数。 */
/* WLAN芯片驱动的初始化和去初始化函数 */ int32_t Hi3881Deinit(struct HdfChipDriver* chipDriver, struct NetDevice *netDevice);
int32_t Hi3881Deinit(struct HdfChipDriver* chipDriver, struct NetDevice *netDevice); int32_t Hi3881Init(struct HdfChipDriver* chipDriver, struct NetDevice *netDevice);
int32_t Hi3881Init(struct HdfChipDriver* chipDriver, struct NetDevice *netDevice);
/* 初始化Mac80211与芯片侧的函数挂接。 */
/* 初始化mac80211与芯片侧的函数挂接 */ hi_void HiMac80211Init(struct HdfChipDriver *chipDriver);
hi_void HiMac80211Init(struct HdfChipDriver *chipDriver);
static const char* const HI3881_DRIVER_NAME = "hisi";
static const char* const HI3881_DRIVER_NAME = "hisi";
/* WLAN芯片驱动挂接以及Mac80211与芯片侧的函数挂接。 */
/* WLAN芯片驱动挂接以及mac80211与芯片侧的函数挂接 */ static struct HdfChipDriver *BuildHi3881Driver(struct HdfWlanDevice *device, uint8_t ifIndex)
static struct HdfChipDriver *BuildHi3881Driver(struct HdfWlanDevice *device, uint8_t ifIndex) {
{
struct HdfChipDriver *specificDriver = NULL; struct HdfChipDriver *specificDriver = NULL;
if (device == NULL) { if (device == NULL) {
HDF_LOGE("%s fail : channel is NULL", __func__); HDF_LOGE("%s fail: channel is NULL!", __func__);
return NULL; return NULL;
} }
(void)device;
(void)ifIndex; (void)ifIndex;
specificDriver = (struct HdfChipDriver *)OsalMemCalloc(sizeof(struct HdfChipDriver)); specificDriver = (struct HdfChipDriver *)OsalMemCalloc(sizeof(struct HdfChipDriver));
if (specificDriver == NULL) { if (specificDriver == NULL) {
...@@ -261,7 +268,7 @@ static struct HdfChipDriver *BuildHi3881Driver(struct HdfWlanDevice *device, uin ...@@ -261,7 +268,7 @@ static struct HdfChipDriver *BuildHi3881Driver(struct HdfWlanDevice *device, uin
} }
if (strcpy_s(specificDriver->name, MAX_WIFI_COMPONENT_NAME_LEN, HI3881_DRIVER_NAME) != EOK) { if (strcpy_s(specificDriver->name, MAX_WIFI_COMPONENT_NAME_LEN, HI3881_DRIVER_NAME) != EOK) {
HDF_LOGE("%s fail : strcpy_s fail", __func__); HDF_LOGE("%s fail: strcpy_s fail!", __func__);
OsalMemFree(specificDriver); OsalMemFree(specificDriver);
return NULL; return NULL;
} }
...@@ -271,11 +278,11 @@ static struct HdfChipDriver *BuildHi3881Driver(struct HdfWlanDevice *device, uin ...@@ -271,11 +278,11 @@ static struct HdfChipDriver *BuildHi3881Driver(struct HdfWlanDevice *device, uin
HiMac80211Init(specificDriver); HiMac80211Init(specificDriver);
return specificDriver; return specificDriver;
} }
/* 释放WLAN芯片驱动 */ /* 释放WLAN芯片驱动。 */
static void ReleaseHi3881Driver(struct HdfChipDriver *chipDriver) static void ReleaseHi3881Driver(struct HdfChipDriver *chipDriver)
{ {
if (chipDriver == NULL) { if (chipDriver == NULL) {
return; return;
} }
...@@ -284,20 +291,20 @@ static void ReleaseHi3881Driver(struct HdfChipDriver *chipDriver) ...@@ -284,20 +291,20 @@ static void ReleaseHi3881Driver(struct HdfChipDriver *chipDriver)
return; return;
} }
OsalMemFree(chipDriver); OsalMemFree(chipDriver);
} }
static uint8_t GetHi3881GetMaxIFCount(struct HdfChipDriverFactory *factory) { static uint8_t GetHi3881GetMaxIFCount(struct HdfChipDriverFactory *factory) {
(void)factory; (void)factory;
return 1; return 1;
} }
/* WLAN芯片相关函数的注册 */ /* WLAN芯片相关函数的注册。 */
static int32_t HDFWlanRegHisiDriverFactory(void) static int32_t HDFWlanRegHisiDriverFactory(void)
{ {
static struct HdfChipDriverFactory tmpFactory = { 0 }; static struct HdfChipDriverFactory tmpFactory = { 0 };
struct HdfChipDriverManager *driverMgr = NULL; struct HdfChipDriverManager *driverMgr = NULL;
driverMgr = HdfWlanGetChipDriverMgr(); driverMgr = HdfWlanGetChipDriverMgr();
if (driverMgr == NULL && driverMgr->RegChipDriver != NULL) { if (driverMgr == NULL) {
HDF_LOGE("%s fail: driverMgr is NULL!", __func__); HDF_LOGE("%s fail: driverMgr is NULL!", __func__);
return HDF_FAILURE; return HDF_FAILURE;
} }
...@@ -314,45 +321,48 @@ static int32_t HDFWlanRegHisiDriverFactory(void) ...@@ -314,45 +321,48 @@ static int32_t HDFWlanRegHisiDriverFactory(void)
} }
return HDF_SUCCESS; return HDF_SUCCESS;
} }
static int32_t HdfWlanHisiChipDriverInit(struct HdfDeviceObject *device) static int32_t HdfWlanHisiChipDriverInit(struct HdfDeviceObject *device)
{ {
(void)device; (void)device;
return HDFWlanRegHisiDriverFactory(); return HDFWlanRegHisiDriverFactory();
} }
struct HdfDriverEntry g_hdfHisiChipEntry = { struct HdfDriverEntry g_hdfHisiChipEntry = {
.moduleVersion = 1, .moduleVersion = 1,
.Bind = HdfWlanHisiDriverBind,
.Init = HdfWlanHisiChipDriverInit, .Init = HdfWlanHisiChipDriverInit,
.Release = HdfWlanHisiChipRelease,
.moduleName = "HDF_WLAN_CHIPS" .moduleName = "HDF_WLAN_CHIPS"
}; };
HDF_INIT(g_hdfHisiChipEntry); HDF_INIT(g_hdfHisiChipEntry);
``` ```
芯片初始化和芯片驱动初始化相关内容详见hdfinit_3881.c,具体函数分解如下:
```
#include "hdf_wifi_product.h" ```c
#include "hi_wifi_api.h" #include "hdf_wifi_product.h"
#if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION) #include "hi_wifi_api.h"
#include "oal_thread.h" #if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
#include "osal_time.h" #include "oal_thread.h"
#endif #include "osal_time.h"
#include "wifi_mac80211_ops.h" #endif
#include "wal_cfg80211.h" #include "wifi_mac80211_ops.h"
#include "net_adapter.h" #include "wal_cfg80211.h"
#include "hdf_wlan_utils.h" #include "net_adapter.h"
#include "hdf_wlan_utils.h"
#define HDF_LOG_TAG Hi3881Driver
#define HDF_LOG_TAG Hi3881Driver
/* WLAN芯片的初始化函数 */
int32_t InitHi3881Chip(struct HdfWlanDevice *device) /* WLAN芯片的初始化函数。 */
{ int32_t InitHi3881Chip(struct HdfWlanDevice *device)
uint8_t maxPortCount = 1; {
uint8_t maxPortCount = 3;
int32_t ret = HI_SUCCESS; int32_t ret = HI_SUCCESS;
uint8_t maxRetryCount = 2; uint8_t maxRetryCount = 3;
if (device == NULL) { if (device == NULL || device->bus == NULL) {
HDF_LOGE("%s:NULL ptr!", __func__); HDF_LOGE("%s:NULL ptr!", __func__);
return HI_FAIL; return HI_FAIL;
} }
...@@ -364,7 +374,7 @@ int32_t InitHi3881Chip(struct HdfWlanDevice *device) ...@@ -364,7 +374,7 @@ int32_t InitHi3881Chip(struct HdfWlanDevice *device)
} }
HDF_LOGE("%s:Retry init hi3881!last ret=%d", __func__, ret); HDF_LOGE("%s:Retry init hi3881!last ret=%d", __func__, ret);
} }
ret = hi_wifi_init(maxPortCount); ret = hi_wifi_init(maxPortCount, device->bus);
} while (ret != 0 && --maxRetryCount > 0); } while (ret != 0 && --maxRetryCount > 0);
if (ret != 0) { if (ret != 0) {
...@@ -372,81 +382,113 @@ int32_t InitHi3881Chip(struct HdfWlanDevice *device) ...@@ -372,81 +382,113 @@ int32_t InitHi3881Chip(struct HdfWlanDevice *device)
return ret; return ret;
} }
return HI_SUCCESS; return HI_SUCCESS;
} }
/* WLAN芯片的去初始化函数 */ /* WLAN芯片的去初始化函数。 */
int32_t DeinitHi3881Chip(struct HdfWlanDevice *device) int32_t DeinitHi3881Chip(struct HdfWlanDevice *device)
{ {
(void)device; (void)device;
int32_t ret = hi_wifi_deinit(); int32_t ret = hi_wifi_deinit();
if (ret != 0) { if (ret != 0) {
HDF_LOGE("%s:Deinit failed!ret=%d", __func__, ret); HDF_LOGE("%s:Deinit failed!ret=%d", __func__, ret);
} }
return ret; return ret;
} }
/* WLAN芯片驱动的初始化函数 */ /* WLAN芯片驱动的初始化函数。 */
int32_t Hi3881Init(struct HdfChipDriver *chipDriver, struct NetDevice *netDevice) int32_t Hi3881Init(struct HdfChipDriver *chipDriver, struct NetDevice *netDevice)
{ {
HDF_LOGI("%s: start...", __func__); hi_u16 mode;
hi_u16 mode = wal_get_vap_mode();
int32_t ret; int32_t ret;
nl80211_iftype_uint8 type; nl80211_iftype_uint8 type;
(void)chipDriver; (void)chipDriver;
HDF_LOGI("%s: start...", __func__);
mode = wal_get_vap_mode();
if (mode >= WAL_WIFI_MODE_BUTT) { if (mode >= WAL_WIFI_MODE_BUTT) {
oam_error_log1(0, 0, "wal_init_drv_netdev:: invalid mode[%d]", mode); oam_error_log1(0, 0, "wal_init_drv_netdev:: invalid mode[%d]", mode);
return HI_FAIL; return HI_FAIL;
} }
if (mode == WAL_WIFI_MODE_STA) { if (mode == WAL_WIFI_MODE_STA) {
type = NL80211_IFTYPE_STATION; type = NL80211_IFTYPE_STATION;
#ifdef _PRE_WLAN_FEATURE_P2P
if (InitNetdev(netDevice, NL80211_IFTYPE_P2P_DEVICE) != HI_SUCCESS) {
return HI_FAIL;
}
#endif
} else if (mode == WAL_WIFI_MODE_AP) { } else if (mode == WAL_WIFI_MODE_AP) {
type = NL80211_IFTYPE_AP; type = NL80211_IFTYPE_AP;
} else { } else {
oam_error_log1(0, 0, "wal_init_drv_netdev:: invalid mode[%d]", mode); oam_error_log1(0, 0, "wal_init_drv_netdev:: invalid mode[%d]", mode);
return HI_FAIL; return HI_FAIL;
} }
ret = wal_init_drv_wlan_netdev(type, WAL_PHY_MODE_11N, netDevice); ret = wal_init_drv_wlan_netdev(type, WAL_PHY_MODE_11N, netDevice);
if (ret != HI_SUCCESS) { if (ret != HI_SUCCESS) {
oam_error_log2(0, OAM_SF_ANY, "wal_init_drv_netdev %s failed.l_return:%d\n", netDevice->name, ret); oam_error_log2(0, OAM_SF_ANY, "wal_init_drv_netdev %s failed.l_return:%d\n", netDevice->name, ret);
} }
return ret; return ret;
} }
/* WLAN芯片驱动的去初始化函数 */ /* WLAN芯片驱动的去初始化函数。 */
int32_t Hi3881Deinit(struct HdfChipDriver *chipDriver, struct NetDevice *netDevice) int32_t Hi3881Deinit(struct HdfChipDriver *chipDriver, struct NetDevice *netDevice)
{ {
int32_t ret;
(void)chipDriver; (void)chipDriver;
int32_t ret = wal_deinit_drv_wlan_netdev(netDevice); ret = DeinitNetdev(NL80211_IFTYPE_P2P_DEVICE);
if (ret != HDF_SUCCESS) { if (ret != HI_SUCCESS) {
oam_error_log1(0, OAM_SF_ANY, "Hi3881Deinit: DeinitNetdev p2p device fail, ret = %d\n", ret);
return ret; return ret;
} }
return ReleasePlatformNetDevice(netDevice); return wal_deinit_drv_wlan_netdev(netDevice);
} }
```
3、在芯片侧初始化过程中调用netdev的init和add接口进行初始化netdev,并挂接netdev的一些函数指针。 ```
``` 在芯片侧初始化过程中调用netdev的init和add接口进行初始化netdev,并挂接netdev的一些函数指针。
hi_s32 wal_init_drv_wlan_netdev(nl80211_iftype_uint8 type, wal_phy_mode mode, hi_char* ifname, hi_u32* len)
{
oal_net_device_stru *netdev = HI_NULL;
...... ```c
/* 初始化网络设备,获取对应的实例 */ hi_s32 wal_init_drv_wlan_netdev(nl80211_iftype_uint8 type, wal_phy_mode mode, oal_net_device_stru *netdev)
netdev = NetDeviceInit(ifname, *len, LITE_OS); {
oal_wireless_dev *wdev = (oal_wireless_dev *)oal_mem_alloc(OAL_MEM_POOL_ID_LOCAL, sizeof(oal_wireless_dev)); hi_char *ac_mode_str = NULL;
ret = wal_init_netif(type, netdev, wdev); hi_s32 ret;
if (oal_unlikely(netdev == HI_NULL)) {
oam_error_log0(0, OAM_SF_ANY, "{netdev is null!}");
return HI_ERR_CODE_PTR_NULL;
}
...... do {
/* 初始化网络设备。 */
ret = wal_init_netdev(type, netdev);
if (ret != HI_SUCCESS) {
break;
}
ret = wal_init_netif(type, netdev);
if (ret != HI_SUCCESS) {
break;
}
ac_mode_str = "11bgn";
if (mode == WAL_PHY_MODE_11G) {
ac_mode_str = "11bg";
} else if (mode == WAL_PHY_MODE_11B) {
ac_mode_str = "11b";
}
ret = wal_ioctl_set_mode(netdev, ac_mode_str);
} while (false);
if (ret != HI_SUCCESS) {
wal_deinit_wlan_vap(netdev);
oal_net_unregister_netdev(netdev);
oal_net_clear_netdev(netdev);
return HI_FAIL;
}
return HI_SUCCESS; return HI_SUCCESS;
} }
/* 挂接netdev的一些函数指针,详细挂接函数{@link NetDeviceInterFace} */
oal_net_device_ops_stru g_wal_net_dev_ops = /* 挂接netdev的一些函数指针,详细挂接函数请参考NetDeviceInterFace。 */
{ oal_net_device_ops_stru g_wal_net_dev_ops =
{
.getStats = wal_netdev_get_stats, .getStats = wal_netdev_get_stats,
.open = wal_netdev_open, .open = wal_netdev_open,
.stop = wal_netdev_stop, .stop = wal_netdev_stop,
...@@ -455,35 +497,32 @@ oal_net_device_ops_stru g_wal_net_dev_ops = ...@@ -455,35 +497,32 @@ oal_net_device_ops_stru g_wal_net_dev_ops =
.changeMtu = oal_net_device_change_mtu, .changeMtu = oal_net_device_change_mtu,
.init = oal_net_device_init, .init = oal_net_device_init,
.deInit = oal_net_free_netdev, .deInit = oal_net_free_netdev,
#if (defined(_PRE_WLAN_FEATURE_FLOWCTL) || defined(_PRE_WLAN_FEATURE_OFFLOAD_FLOWCTL)) #if (defined(_PRE_WLAN_FEATURE_FLOWCTL) || defined(_PRE_WLAN_FEATURE_OFFLOAD_FLOWCTL))
.selectQueue = wal_netdev_select_queue, .selectQueue = wal_netdev_select_queue,
#endif #endif
.setMacAddr = wal_netdev_set_mac_addr, .setMacAddr = wal_netdev_set_mac_addr,
#if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION) #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION)
.netifNotify = HI_NULL, .netifNotify = HI_NULL,
#endif #endif
.specialEtherTypeProcess = SpecialEtherTypeProcess, .specialEtherTypeProcess = SpecialEtherTypeProcess,
}; };
hi_s32 wal_init_netif(nl80211_iftype_uint8 type, oal_net_device_stru *netdev, const oal_wireless_dev *wdev) hi_s32 wal_init_netif(nl80211_iftype_uint8 type, oal_net_device_stru *netdev, const oal_wireless_dev *wdev)
{ {
/* 添加网络设备到协议栈 */ /* 添加网络设备到协议栈。 */
hi_u32 ret = NetDeviceAdd(netdev, (Protocol80211IfType)type); hi_u32 ret = NetDeviceAdd(netdev, (Protocol80211IfType)type);
...... ......
return HI_SUCCESS; return HI_SUCCESS;
} }
``` ```
4、WifiMac80211Ops中的函数挂接实现。
``` 3. 命令下发绑定,包括具有公共能力的设置MAC地址、设置发射功率等;STA相关的连接、扫描等;AP相关的启动AP、设置国家码等。
/* 挂接mac80211的一些函数指针 */
/* 驱动需要实现的MAC层基本能力的控制接口 */ ```c
static struct HdfMac80211BaseOps g_baseOps = { /* 驱动需要实现的MAC层基本能力的控制接口。 */
static struct HdfMac80211BaseOps g_baseOps = {
.SetMode = WalSetMode, .SetMode = WalSetMode,
.AddKey = WalAddKey, .AddKey = WalAddKey,
.DelKey = WalDelKey, .DelKey = WalDelKey,
...@@ -493,19 +532,19 @@ static struct HdfMac80211BaseOps g_baseOps = { ...@@ -493,19 +532,19 @@ static struct HdfMac80211BaseOps g_baseOps = {
.SetTxPower = WalSetTxPower, .SetTxPower = WalSetTxPower,
.GetValidFreqsWithBand = WalGetValidFreqsWithBand, .GetValidFreqsWithBand = WalGetValidFreqsWithBand,
.GetHwCapability = WalGetHwCapability .GetHwCapability = WalGetHwCapability
}; };
/* 驱动需要实现的MAC层STA能力的控制接口 */ /* 驱动需要实现的MAC层STA能力的控制接口。 */
static struct HdfMac80211STAOps g_staOps = { static struct HdfMac80211STAOps g_staOps = {
.Connect = WalConnect, .Connect = WalConnect,
.Disconnect = WalDisconnect, .Disconnect = WalDisconnect,
.StartScan = WalStartScan, .StartScan = WalStartScan,
.AbortScan = WalAbortScan, .AbortScan = WalAbortScan,
.SetScanningMacAddress = WalSetScanningMacAddress, .SetScanningMacAddress = WalSetScanningMacAddress,
}; };
/* 驱动需要实现的MAC层AP能力的控制接口 */ /* 驱动需要实现的MAC层AP能力的控制接口。 */
static struct HdfMac80211APOps g_apOps = { static struct HdfMac80211APOps g_apOps = {
.ConfigAp = WalConfigAp, .ConfigAp = WalConfigAp,
.StartAp = WalStartAp, .StartAp = WalStartAp,
.StopAp = WalStopAp, .StopAp = WalStopAp,
...@@ -514,35 +553,412 @@ static struct HdfMac80211APOps g_apOps = { ...@@ -514,35 +553,412 @@ static struct HdfMac80211APOps g_apOps = {
.SetCountryCode = WalSetCountryCode, .SetCountryCode = WalSetCountryCode,
.GetAssociatedStasCount = WalGetAssociatedStasCount, .GetAssociatedStasCount = WalGetAssociatedStasCount,
.GetAssociatedStasInfo = WalGetAssociatedStasInfo .GetAssociatedStasInfo = WalGetAssociatedStasInfo
}; };
/* 初始化mac80211与芯片侧的函数挂接 */ static struct HdfMac80211P2POps g_p2pOps = {
hi_void HiMac80211Init(struct HdfChipDriver *chipDriver) .RemainOnChannel = WalRemainOnChannel,
{ .CancelRemainOnChannel = WalCancelRemainOnChannel,
.ProbeReqReport = WalProbeReqReport,
.AddIf = WalAddIf,
.RemoveIf = WalRemoveIf,
.SetApWpsP2pIe = WalSetApWpsP2pIe,
.GetDriverFlag = WalGetDriverFlag
};
/* 初始化Mac80211与芯片侧的函数挂接。 */
void HiMac80211Init(struct HdfChipDriver *chipDriver)
{
if (chipDriver == NULL) { if (chipDriver == NULL) {
oam_error_log(0, OAM_SF_ANY, "%s:input is NULL!", __func__); HDF_LOGE("%s:input is NULL!", __func__);
return; return;
} }
chipDriver->ops = &g_baseOps; chipDriver->ops = &g_baseOps;
chipDriver->staOps = &g_staOps; chipDriver->staOps = &g_staOps;
chipDriver->apOps = &g_apOps; chipDriver->apOps = &g_apOps;
} chipDriver->p2pOps = &g_p2pOps;
``` }
```
4. 事件上报接口调用,WLAN框架提供了event事件的上报接口,详情见hdf_wifi_event.c,例:调用HdfWiFiEventNewSta AP上报新关联的某个STA的情况。
```c
hi_u32 oal_cfg80211_new_sta(oal_net_device_stru *net_device, const hi_u8 *mac_addr, hi_u8 addr_len,
oal_station_info_stru *station_info, oal_gfp_enum_uint8 en_gfp)
{
#if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION) && !defined(_PRE_HDF_LINUX)
cfg80211_new_sta(net_device, mac_addr, station_info, en_gfp);
hi_unref_param(addr_len);
#elif (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION) || defined(_PRE_HDF_LINUX)
struct StationInfo info = { 0 };
info.assocReqIes = station_info->assoc_req_ies;
info.assocReqIesLen = station_info->assoc_req_ies_len;
HdfWifiEventNewSta(net_device, mac_addr, WLAN_MAC_ADDR_LEN, &info);
hi_unref_param(en_gfp);
hi_unref_param(addr_len);
#endif
return HI_SUCCESS;
}
```
## 调测验证
驱动开发完成后,在WLAN模块单元测试里面开发自测试用例以及验证WLAN模块基本功能。测试环境采用开发者自测试平台(这里以Hi3516DV300标准系统为例)。
1. 测试验证环境准备。
- 新建hostapd.conf文件(启动AP配置文件)并将以下内容复制到该文件中。
```text
interface=wlan0
driver=hdf wifi
ctrl_interface=udp
#WiFi名称
ssid=test
hw_mode=g
channel=1
ignore_broadcast_ssid=0
wpa=2
rsn_pairwise=CCMP
# WiFi密码
wpa_passphrase=12345678
```
- 新建wpa_supplicant.conf文件(启动STA配置文件)并将以下内容复制到该文件中。
```text
country=GB
network={
#热点名称
ssid="test"
#热点密码
psk="12345678"
}
```
- 新建dhcpc.sh文件(将UDHCPC分配的IP地址等写入到设备中)并将以下内容复制到该文件中。
```shell
#!/system/bin/sh
[ -z "$1" ] && echo "Error: should be called from udhcpc" && exit 1
RESOLV_CONF="/etc/resolv.conf"
[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
[ -n "$subnet" ] && NETMASK="netmask $subnet"
case "$1" in
deconfig)
/system/bin/ifconfig $interface 0.0.0.0
;;
renew|bound)
/system/bin/ifconfig $interface $ip $BROADCAST $NETMASK
if [ -n "$router" ] ; then
echo "deleting routers"
while busybox route del default gw 0.0.0.0 dev $interface ; do
:
done
for i in $router ; do
busybox route add default gw $i dev $interface
done
fi
echo -n > $RESOLV_CONF
[ -n "$domain" ] && echo search $domain >> $RESOLV_CONF
for i in $dns ; do
echo adding dns $i
echo nameserver $i >> $RESOLV_CONF
done
;;
esac
exit 0
```
- 新建udhcpd.conf文件(启动UDHCPD配置文件)并将以下内容复制到该文件中。
```text
start 192.168.12.2
end 192.168.12.100
interface wlan0 #default: eth0
max_leases 20 #default: 254
remaining yes #default: yes
auto_time 7200 #default: 7200 (2 hours)
decline_time 3600 #default: 3600 (1 hour)
conflict_time 3600 #default: 3600 (1 hour)
offer_time 60 #default: 60 (1 minute)
min_lease 60 #defult: 60
lease_file /vendor/etc/udhcpd.leases
opt dns 10.221.0.11 8.8.8.8
option subnet 255.255.255.0
opt router 192.168.12.1
```
- 执行下列命令将测试所需文件推送到开发板。
```shell
hdc shell "mount -o rw,remount /"
timeout /T 1
hdc file send dhcpc.sh /system/lib/
hdc shell "chmod 777 /system/lib/dhcpc.sh"
hdc file send wpa_supplicant.conf /
hdc shell "mount -o rw,remount /vendor"
hdc file send hostapd.conf /
hdc file send udhcpd.conf /vendor/etc
hdc shell "touch /vendor/etc/udhcpd.leases"
hdc shell "chmod 777 /vendor/etc/udhcpd.leases"
```
2. 验证WiFi基本功能。
- 验证AP基本功能
1. 开发板启动AP,测试终端(例如手机)打开WiFi开关(设置 -> WLAN -> 打开WiFi开关)。
2. 使用cmd窗口输入如下命令。
```shell
hdc shell
hostapd ./hostapd.conf
```
3. 使用另一个cmd窗口执行下列命令。
```shell
hdc shell
ifconfig wlan0 192.168.12.1 netmask 255.255.255.0
busybox udhcpd /vendor/etc/udhcpd.conf
```
4. 在手机的WiFi列表中找到对应名称为test的网络,并输入密码(网络名称及密码均在在hostapd.conf中进行配置,成功连接后,手机上可看到已连接)。
5. 使用开发板ping测试终端。
```shell
busybox ping xxx.xxx.xxx.xxx
```
上述xxx.xxx.xxx.xxx为当前测试终端的IP地址,若测试能够ping通测试终端则表示,WLAN驱动基本功能正常。
- 验证STA基本功能
1. 开发板启动STA,测试终端(例如手机)打开热点(网络名称及密码均在在hostapd.conf中进行配置,热点名称为test,密码为12345678)。
2. 使用cmd窗口输入如下命令。
```shell
hdc shell
wpa_supplicant -i wlan0 -d -c wpa_supplicant.conf
```
3. 使用另一个cmd窗口执行下列命令。
```shell
hdc shell
mount -o rw,remount /
mount -o rw,remount /vendor
busybox udhcpc -i wlan0 -s system/lib/dhcpc.sh
```
上述命令执行成功后,回显信息中可以看到单板及测试终端IP地址。
4. 使用开发板ping测试终端。
```shell
busybox ping xxx.xxx.xxx.xxx
```
上述xxx.xxx.xxx.xxx为当前测试终端的IP地址,若测试能够ping通测试终端则表示,WLAN驱动基本功能正常。
3. 验证单元测试用例
HDI模块用例开发步骤(需要测试HDI模块指定接口时,可采用下列步骤):
- 使用WlanInterfaceGetInstance获取WLAN服务对象。
- 使用Start创建HAL和驱动之间的通道及获取驱动网卡信息。
- 通过GetSupportFeature获取该设备支持的WLAN特性。
- 调用Stop,销毁HAL和驱动之间的通道。
- 执行WlanInterfaceRelease销毁WLAN服务对象。
HDI模块用例开发实例:
```c
#include "v1_0/iwlan_interface.h"
#include "wlan_callback_impl.h"
#include "wlan_impl.h"
#define PROTOCOL_80211_IFTYPE_NUM 11;
#define HDF_SUCCESS 0
#define HDF_FAILURE (-1)
static int32_t hdi_main()
{
int32_t rc;
const char *WLAN_SERVICE_NAME = "wlan_hal_c_service";
static struct IWlanInterface *g_wlanObj = NULL;
uint8_t supType[PROTOCOL_80211_IFTYPE_NUM + 1] = {0};
uint32_t supTypeLen = PROTOCOL_80211_IFTYPE_NUM + 1;
/* 获取WLAN服务对象。*/
g_wlanObj = WlanInterfaceGetInstance(WLAN_SERVICE_NAME);
if (g_wlanObj == NULL)
{
return HDF_FAILURE;
}
/* 创建HAL和驱动之间的通道及获取驱动网卡信息。 */
rc = g_wlanObj->Start(g_wlanObj);
if (rc != HDF_SUCCESS)
{
return HDF_FAILURE;
}
/* 获取该设备支持的WLAN特性(不考虑当前的使用状态)。 */
rc = g_wlanObj->GetSupportFeature(g_wlanObj, supType, &supTypeLen);
if (rc != HDF_SUCCESS)
{
return HDF_FAILURE;
}
/* 销毁HAL和驱动之间的通道。 */
rc = g_wlanObj->Stop(g_wlanObj);
if (rc != HDF_SUCCESS)
{
return HDF_FAILURE;
}
/* 销毁WLAN服务对象。 */
rc = WlanInterfaceRelease(g_wlanObj);
if (rc != HDF_SUCCESS)
{
return HDF_FAILURE;
}
return rc;
}
```
HAL模块用例开发步骤(需要测试HAL模块指定接口时,可采用下列步骤):
- 使用WifiConstruct创建一个WiFi实体。
- 用创建的WiFi实体调用start开启HAL和驱动之间的通道,获得驱动网卡的信息。
- 通过createFeature创建一个apFeature或者staFeature。后面可通过这些Feature去调用具体的实现接口,下面基于创建的apFeature为例进行介绍。
- 调用和使用相关接口:如setMacAddress设置MAC地址、getDeviceMacAddress获取设备的MAC地址等。
- 调用destroyFeature,销毁掉创建的apFeature。
- 调用stop销毁创建的通道。
- 执行WifiDestruct销毁创建的WiFi实体。
HAL模块用例开发实例:
```c
#include "wifi_hal.h"
#include "wifi_hal_sta_feature.h"
#include "wifi_hal_ap_feature.h"
#include "wifi_hal_cmd.h"
#include "wifi_hal_event.h"
#define MAC_LEN 6
#define HDF_SUCCESS 0
#define HDF_FAILURE (-1)
static int32_t hal_main()
{
int32_t ret;
struct IWiFi *wifi;
/* 创建一个wifi实体。 */
ret = WifiConstruct(&wifi);
if (ret != HDF_SUCCESS || wifi == NULL) {
return HDF_FAILURE;
}
/* 开启HAL和驱动之间的通道,获得驱动网卡的信息。 */
ret = wifi->start(wifi);
if (ret != HDF_SUCCESS) {
return HDF_FAILURE;
}
/* 创建apFeature。 */
ret = wifi->createFeature(PROTOCOL_80211_IFTYPE_AP, (struct IWiFiBaseFeature **)&apFeature);
if (ret != HDF_SUCCESS) {
return HDF_FAILURE;
}
/* 获取设备MAC地址。 */
unsigned char mac[MAC_LEN] = {0};
ret = apFeature->baseFeature.getDeviceMacAddress((struct IWiFiBaseFeature *)apFeature, mac, MAC_LEN);
if (ret != HDF_SUCCESS) {
return HDF_FAILURE;
}
/* 销毁创建的apFeature。 */
ret = wifi->destroyFeature((struct IWiFiBaseFeature *)apFeature);
if (ret != HDF_SUCCESS) {
return HDF_FAILURE;
}
/* 销毁HAL和驱动之间的通道。 */
ret = wifi->stop(wifi);
if (ret != HDF_SUCCESS) {
return HDF_FAILURE;
}
/* 销毁创建的WiFi实体。 */
ret = WifiDestruct(&wifi);
if (ret != HDF_SUCCESS) {
return HDF_FAILURE;
}
return ret;
}
```
4. 验证测试用例方法如下
1. 将测试用例推送到单板。
```shell
hdc file send /xxx /data
```
xxx表示需要推送到单板根目录的测试用例路径。
2. 修改测试用例权限并执行该用例。
```shell
hdc shell
cd data
chmod 777 测试用例名称
./测试用例名称
```
查看测试用例执行结果是否正确。
## 参考 ## 参考
- 代码仓库如下: - 代码仓库如下:
[drivers\_hdf\_core](https://gitee.com/openharmony/drivers_hdf_core) **[drivers\_hdf\_core](https://gitee.com/openharmony/drivers_hdf_core)**
[drivers\_peripheral](https://gitee.com/openharmony/drivers_peripheral) [drivers\_peripheral](https://gitee.com/openharmony/drivers_peripheral)
[drivers\_interface](https://gitee.com/openharmony/drivers_interface)
- 代码路径如下: - 代码路径如下:
WLAN模块流控组件liteos适配://drivers/hdf_core/adapter/khdf/liteos/model/network/wifi WLAN模块流控组件liteos适配://drivers/hdf_core/adapter/khdf/liteos/model/network/wifi
HDF网络模型liteos适配://drivers/hdf_core/adapter/khdf/liteos/model/network HDF网络模型liteos适配://drivers/hdf_core/adapter/khdf/liteos/model/network
WLAN模块流控组件Linux适配、HDF WLAN模型VENDOR WLAN驱动编译: WLAN模块流控组件Linux适配、HDF WLAN模型VENDOR WLAN驱动编译:
//drivers/hdf_core/adapter/khdf/linux/model/network/wifi //drivers/hdf_core/adapter/khdf/linux/model/network/wifi
...@@ -552,4 +968,6 @@ hi_void HiMac80211Init(struct HdfChipDriver *chipDriver) ...@@ -552,4 +968,6 @@ hi_void HiMac80211Init(struct HdfChipDriver *chipDriver)
HDF网络模型接口://drivers/hdf_core/framework/include/net HDF网络模型接口://drivers/hdf_core/framework/include/net
WLAN HDI接口及具体实现://drivers/peripheral/wlan WLAN HDI服务端实现://drivers/peripheral/wlan
WLAN HDI对外接口://out/{product_name}/gen/drivers/interface/wlan/v1_0
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册