diff --git a/CODEOWNERS b/CODEOWNERS
index 9a557753d3206996fb43ed7fe73d482968fee112..7c6530eb16de9051510d7344025cf8b61c566c78 100644
--- a/CODEOWNERS
+++ b/CODEOWNERS
@@ -29,11 +29,22 @@ zh-cn/device-dev/quick-start/quickstart-lite-env-setup.md @li-yan339 @chenmudan
zh-cn/device-dev/porting/porting-thirdparty-overview.md @Austin23 @chenmudan
zh-cn/device-dev/porting/porting-thirdparty-makefile.md @Austin23 @chenmudan
zh-cn/device-dev/porting/porting-thirdparty-cmake.md @Austin23 @chenmudan
-zh-cn/device-dev/subsystems/subsys-build-mini-lite.md @Austin23 @chenmudan
-zh-cn/device-dev/subsystems/subsys-build-standard-large.md @Austin23 @chenmudan
-zh-cn/device-dev/subsystems/subsys-build-gn-coding-style-and-best-practice.md @Austin23 @chenmudan
-zh-cn/device-dev/subsystems/subsys-build-gn-kconfig-visual-config-guid.md @Austin23 @chenmudan
-zh-cn/device-dev/subsystems/subsys-build-gn-hap-compilation-guide.md @Austin23 @chenmudan
+zh-cn/device-dev/subsystems/subsys-build-all.md @Austin23 @chenmudan
+zh-cn/device-dev/subsystems/subsys-build-gn-coding-style-and-best-practice.md @Austin23 @chenmudan
+zh-cn/device-dev/subsystems/subsys-build-gn-kconfig-visual-config-guide.md @Austin23 @chenmudan
+zh-cn/device-dev/subsystems/subsys-build-product.md @Austin23 @chenmudan
+zh-cn/device-dev/subsystems/subsys-build-zh-cn/device-dev/subsystems/subsystem.md @Austin23 @chenmudan
+zh-cn/device-dev/subsystems/subsys-build-component.md @Austin23 @chenmudan
+zh-cn/device-dev/subsystems/subsys-build-module.md @Austin23 @chenmudan
+zh-cn/device-dev/subsystems/subsys-build-chip_solution.md @Austin23 @chenmudan
+zh-cn/device-dev/subsystems/subsys-build-feature.md @Austin23 @chenmudan
+zh-cn/device-dev/subsystems/subsys-build-syscap.md @Austin23 @chenmudan
+zh-cn/device-dev/subsystems/subsys-build-reference.md @Austin23 @chenmudan
+zh-cn/device-dev/subsystems/subsys-build-reference.md @Austin23 @chenmudan
+zh-cn/device-dev/subsystems/subsys-build-reference.md @Austin23 @chenmudan
+zh-cn/device-dev/subsystems/subsys-build-reference.md @Austin23 @chenmudan
+zh-cn/device-dev/subsystems/subsys-build-gn-hap-compilation-guide.md @Austin23 @chenmudan
+zh-cn/device-dev/subsystems/subsys-build-FAQ.md @Austin23 @chenmudan
zh-cn/device-dev/subsystems/subsys-remote-start.md @duangavin123_admin
zh-cn/device-dev/subsystems/subsys-graphics-overview.md @duangavin123_admin
zh-cn/device-dev/subsystems/subsys-graphics-container-guide.md @duangavin123_admin
@@ -210,6 +221,7 @@ zh-cn/application-dev/reference/apis/js-apis-router.md @HelloCrease
zh-cn/application-dev/reference/apis/js-apis-display.md @ge-yafang
zh-cn/application-dev/reference/apis/js-apis-screenshot.md @ge-yafang
zh-cn/application-dev/reference/apis/js-apis-window.md @ge-yafang
+zh-cn/application-dev/reference/apis/js-apis-effectKit.md @ge-yafang
zh-cn/application-dev/reference/apis/js-apis-application-WindowExtensionAbility.md @ge-yafang
zh-cn/application-dev/reference/apis/js-apis-screen.md @ge-yafang
zh-cn/application-dev/reference/apis/js-apis-windowAnimationManager.md @ge-yafang
@@ -219,7 +231,7 @@ zh-cn/application-dev/reference/apis/js-apis-audio.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-camera.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-image.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-media.md @zengyawen
-zh-cn/application-dev/reference/apis/js-apis-medialibrary.md @qinxiaowang
+zh-cn/application-dev/reference/apis/js-apis-medialibrary.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-i18n.md @HelloCrease
zh-cn/application-dev/reference/apis/js-apis-intl.md @HelloCrease
zh-cn/application-dev/reference/apis/js-apis-resource-manager.md @HelloCrease
@@ -305,6 +317,7 @@ zh-cn/application-dev/reference/apis/js-apis-system-parameter.md @qinxiaowang
zh-cn/application-dev/reference/apis/js-apis-thermal.md @qinxiaowang
zh-cn/application-dev/reference/apis/js-apis-update.md @HelloCrease
zh-cn/application-dev/reference/apis/js-apis-usb.md @ge-yafang
+zh-cn/application-dev/reference/apis/js-apis-colorSpaceManager.mdd @ge-yafang
zh-cn/application-dev/reference/apis/js-apis-vibrator.md @HelloCrease
zh-cn/application-dev/reference/apis/js-apis-appAccount.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-distributed-account.md @zengyawen
@@ -352,4 +365,7 @@ zh-cn/application-dev/reference/apis/js-apis-buffer.md @zengyawen
zh-cn/application-dev/reference/js-service-widget-ui @HelloCrease
zh-cn/application-dev/website.md @zengyawen
zh-cn/application-dev/faqs/ @zengyawen
-zh-cn/application-dev/reference/apis/js-apis-useriam-faceauth.md @zengyawen
\ No newline at end of file
+zh-cn/application-dev/reference/apis/js-apis-useriam-faceauth.md @zengyawen
+zh-cn/application-dev/reference/apis/js-apis-userfilemanager.md @zengyawen
+zh-cn/application-dev/reference/apis/js-apis-cryptoFramework.md @zengyawen
+zh-cn/application-dev/reference/apis/Readme-CN.md @zengyawen
\ No newline at end of file
diff --git a/OAT.xml b/OAT.xml
index 8cc884632d4a963fa921c5905cfbf96e7e22edb7..4edf72f5a3b3e03801bdab83dad547cd7c0c18ef 100644
--- a/OAT.xml
+++ b/OAT.xml
@@ -66,7 +66,7 @@
-
+
diff --git a/en/application-dev/Readme-EN.md b/en/application-dev/Readme-EN.md
index 8e42633391269303e5e8d888561281f57d1718ae..f3fa0e7ac0e9b829f2418e4b1bf96001e66553d2 100644
--- a/en/application-dev/Readme-EN.md
+++ b/en/application-dev/Readme-EN.md
@@ -8,14 +8,14 @@
- Quick Start
- Getting Started
- [Preparations](quick-start/start-overview.md)
- - [Getting Started with eTS in the Traditional Coding Approach](quick-start/start-with-ets.md)
- - [Getting Started with eTS in the Low-Code Approach](quick-start/start-with-ets-low-code.md)
- - [Getting Started with JavaScript in the Traditional Coding Approach](quick-start/start-with-js.md)
- - [Getting Started with JavaScript in the Low-Code Approach](quick-start/start-with-js-low-code.md)
+ - [Getting Started with eTS in Stage Model](quick-start/start-with-ets-stage.md)
+ - [Getting Started with eTS in FA Model](quick-start/start-with-ets-fa.md)
+ - [Getting Started with JavaScript in FA Model](quick-start/start-with-js-fa.md)
- Development Fundamentals
- [Application Package Structure Configuration File (FA Model)](quick-start/package-structure.md)
- [Application Package Structure Configuration File (Stage Model)](quick-start/stage-structure.md)
- [SysCap](quick-start/syscap.md)
+ - [HarmonyAppProvision Configuration File](quick-start/app-provision-structure.md)
- Development
- [Ability Development](ability/Readme-EN.md)
- [UI Development](ui/Readme-EN.md)
@@ -37,12 +37,16 @@
- Tools
- [DevEco Studio (OpenHarmony) User Guide](quick-start/deveco-studio-user-guide-for-openharmony.md)
- Hands-On Tutorials
- - [Samples](https://gitee.com/openharmony/app_samples/blob/master/README.md)
+ - [Samples](https://gitee.com/openharmony/applications_app_samples/blob/master/README.md)
- [Codelabs](https://gitee.com/openharmony/codelabs)
- API References
- [Component Reference (JavaScript-based Web-like Development Paradigm)](reference/arkui-js/Readme-EN.md)
- [Component Reference (TypeScript-based Declarative Development Paradigm)](reference/arkui-ts/Readme-EN.md)
- APIs
- [JS and TS APIs](reference/apis/Readme-EN.md)
+ - Native APIs
+ - [Standard Libraries](reference/native-lib/third_party_libc/musl.md)
+ - [Node_API](reference/native-lib/third_party_napi/napi.md)
+- [FAQs](faqs/Readme-EN.md)
- Contribution
- [How to Contribute](../contribute/documentation-contribution.md)
diff --git a/en/application-dev/ability/context-userguide.md b/en/application-dev/ability/context-userguide.md
index ba95ade27a3c7cb846be2d254fd3b75d65dd8701..d3e681244166cafecff86575dd1850db4ebf7f90 100644
--- a/en/application-dev/ability/context-userguide.md
+++ b/en/application-dev/ability/context-userguide.md
@@ -7,9 +7,11 @@
The OpenHarmony application framework has two models: Feature Ability (FA) model and stage model. Correspondingly, there are two sets of context mechanisms. **application/BaseContext** is a common context base class. It uses the **stageMode** attribute to specify whether the context is used for the stage model.
- FA model
+
Only the methods in **app/Context** can be used for the context in the FA model. Both the application-level context and ability-level context are instances of this type. If an ability-level method is invoked in the application-level context, an error occurs. Therefore, you must pay attention to the actual meaning of the **Context** instance.
- Stage model
+
The stage model has the following types of contexts: **application/Context**, **application/ApplicationContext**, **application/AbilityStageContext**, **application/ExtensionContext**, **application/AbilityContext**, and **application/FormExtensionContext**. For details about these contexts and how to use them, see [Context in the Stage Model](#context-in-the-stage-model).

diff --git a/en/application-dev/ability/figures/contextIntroduction.png b/en/application-dev/ability/figures/contextIntroduction.png
index 9f49f270750549a5326724dc0db1560dbda07c44..7345a1a5a6a3471782e9399129c98f3d529bbfd5 100644
Binary files a/en/application-dev/ability/figures/contextIntroduction.png and b/en/application-dev/ability/figures/contextIntroduction.png differ
diff --git a/en/application-dev/ability/figures/stage-call.png b/en/application-dev/ability/figures/stage-call.png
index 28f2a0f7ea9d86fc81e0c1a37d556384b14a9bdd..4c0c0770a4dce6f275b0fc355f70c5dfca2adb17 100644
Binary files a/en/application-dev/ability/figures/stage-call.png and b/en/application-dev/ability/figures/stage-call.png differ
diff --git a/en/application-dev/ability/stage-ability-continuation.md b/en/application-dev/ability/stage-ability-continuation.md
index 6945f49db8ef05109452fc1b3dcad3dc1e5ddeca..701b730a833a7b97f00398746cddae4d2856a248 100644
--- a/en/application-dev/ability/stage-ability-continuation.md
+++ b/en/application-dev/ability/stage-ability-continuation.md
@@ -41,7 +41,7 @@ The code snippets provided below are all from [Sample](https://gitee.com/openhar
"module": {
"abilities": [
{
- "continuable": true,
+ "continuable": true
}
]
}
@@ -62,7 +62,7 @@ The code snippets provided below are all from [Sample](https://gitee.com/openhar
"module": {
"abilities": [
{
- "launchType": "standard",
+ "launchType": "standard"
}
]
}
@@ -76,7 +76,7 @@ The code snippets provided below are all from [Sample](https://gitee.com/openhar
"module": {
"abilities": [
{
- "launchType": "singleton",
+ "launchType": "singleton"
}
]
}
diff --git a/en/application-dev/ability/stage-call.md b/en/application-dev/ability/stage-call.md
index 6b5823e76db2c95190111a55b9d2ef43ddd2d946..cad2aeddec2ae0782776009d4a8a9b092bace023 100644
--- a/en/application-dev/ability/stage-call.md
+++ b/en/application-dev/ability/stage-call.md
@@ -1,43 +1,63 @@
# Ability Call Development
## When to Use
-Ability call is an extension of the ability capabilities. It enables an ability to be invoked by external systems. In this way, the ability can be displayed as a UI page on the foreground and created and run on the background. You can use the **Call** APIs to implement data sharing between different abilities through inter-process communication (IPC). There are two roles in the ability call: caller and callee. The following scenarios are involved in the ability call development:
-- Creating a callee
-- Accessing the callee
+Ability call is an extension of the ability capability. It enables an ability to be invoked by and communicate with external systems. The ability invoked can be either started in the foreground or created and run in the background. You can use the ability call to implement data sharing between two abilities (caller ability and callee ability) through inter-process communication (IPC).
-The following figure shows the ability call process.
+The core API used for the ability call is `startAbilityByCall`, which differs from `startAbility` in the following ways:
+ - `startAbilityByCall` supports ability startup in the foreground and background, whereas `startAbility` supports ability startup in the foreground only.
+ - The caller ability can use the `Caller` object returned by `startAbilityByCall` to communicate with the callee ability, but `startAbility` does not provide the communication capability.
+Ability call is usually used in the following scenarios:
+- Communicating with the callee ability
+- Starting the callee ability in the background
+
+**Table 1** Terms used in the ability call
+|Term|Description|
+|:------|:------|
+|Caller ability|Ability that triggers the ability call.|
+|Callee ability|Ability invoked by the ability call.|
+|Caller |Object returned by `startAbilityByCall` and used by the caller ability to communicate with the callee ability.|
+|Callee |Object held by the callee ability to communicate with the caller ability.|
+|IPC |Inter-process communication.|
+
+The ability call process is as follows:
+ - The caller ability uses `startAbilityByCall` to obtain a `Caller` object and uses `call()` of the `Caller` object to send data to the callee ability.
+ - The callee ability, which holds a `Callee` object, uses `on()` of the `Callee` object to register a callback. This callback is invoked when the callee ability receives data from the caller ability.

->  **NOTE**
-> The startup mode of the callee must be **singleton**.
-> Currently, only system applications and Service Extension abilities can use the **Call** APIs to access the callee.
+> **NOTE**
+> The launch type of the callee ability must be `singleton`.
+> Currently, only system applications can use the ability call.
## Available APIs
The table below describes the ability call APIs. For details, see [Ability](../reference/apis/js-apis-application-ability.md#caller).
-**Table 1** Ability call APIs
+**Table 2** Ability call APIs
|API|Description|
|:------|:------|
-|startAbilityByCall(want: Want): Promise\|Obtains the caller interface of the specified ability and, if the specified ability is not running, starts the ability in the background.|
-|on(method: string, callback: CalleeCallBack): void|Callback invoked when the callee registers a method.|
-|off(method: string): void|Callback invoked when the callee deregisters a method.|
-|call(method: string, data: rpc.Sequenceable): Promise\|Sends agreed sequenceable data to the callee.|
-|callWithResult(method: string, data: rpc.Sequenceable): Promise\|Sends agreed sequenceable data to the callee and returns the agreed sequenceable data.|
-|release(): void|Releases the caller interface.|
-|onRelease(callback: OnReleaseCallBack): void|Registers a callback that is invoked when the caller is disconnected.|
+|startAbilityByCall(want: Want): Promise\|Starts an ability in the foreground (through the `want` configuration) or background (default) and obtains the `Caller` object for communication with the ability. For details, see [AbilityContext](../reference/apis/js-apis-ability-context.md#abilitycontextstartabilitybycall) or [ServiceExtensionContext](../reference/apis/js-apis-service-extension-context.md#serviceextensioncontextstartabilitybycall).|
+|on(method: string, callback: CalleeCallBack): void|Callback invoked when the callee ability registers a method.|
+|off(method: string): void|Callback invoked when the callee ability deregisters a method.|
+|call(method: string, data: rpc.Sequenceable): Promise\|Sends agreed sequenceable data to the callee ability.|
+|callWithResult(method: string, data: rpc.Sequenceable): Promise\|Sends agreed sequenceable data to the callee ability and obtains the agreed sequenceable data returned by the callee ability.|
+|release(): void|Releases the `Caller` object.|
+|onRelease(callback: OnReleaseCallBack): void|Callback invoked when the `Caller` object is released.|
## How to Develop
->  **NOTE**
-> The sample code snippets provided in the **How to Develop** section are used to show specific development steps. They may not be able to run independently.
-### Creating a Callee
-For the callee, implement the callback to receive data and the methods to marshal and unmarshal data. When data needs to be received, use the **on** API to register a listener. When data does not need to be received, use the **off** API to deregister the listener.
-1. Configure the ability startup mode.
+The procedure for developing the ability call is as follows:
+1. Create a callee ability.
+2. Access the callee ability.
+> **NOTE**
+>
+> The code snippets provided in the **How to Develop** section are used to show specific development steps. They may not be able to run independently.
+### Creating a Callee Ability
+For the callee ability, implement the callback to receive data and the methods to marshal and unmarshal data. When data needs to be received, use `on()` to register a listener. When data does not need to be received, use `off()` to deregister the listener.
+**1. Configure the ability launch type.**
- Set the ability of the callee to **singleton** in the **module.json5** file.
+ Set `launchType` of the callee ability to `singleton` in the `module.json5` file.
|JSON Field|Description|
|:------|:------|
-|"launchType"|Ability startup mode. Set this parameter to **singleton**.|
+|"launchType"|Ability launch type. Set this parameter to `singleton`.|
An example of the ability configuration is as follows:
```json
@@ -51,13 +71,13 @@ An example of the ability configuration is as follows:
"visible": true
}]
```
-2. Import the **Ability** module.
-```
+**2. Import the Ability module.**
+```ts
import Ability from '@ohos.application.Ability'
```
-3. Define the agreed sequenceable data.
+**3. Define the agreed sequenceable data.**
- The data formats sent and received by the caller and callee must be consistent. In the following example, the data consists of numbers and strings. The sample code snippet is as follows:
+ The data formats sent and received by the caller and callee abilities must be consistent. In the following example, the data formats are number and string. The code snippet is as follows:
```ts
export default class MySequenceable {
num: number = 0
@@ -81,23 +101,23 @@ export default class MySequenceable {
}
}
```
-4. Implement **Callee.on** and **Callee.off**.
+**4. Implement `Callee.on` and `Callee.off`.**
- The time to register a listener for the callee depends on your application. The data sent and received before the listener is registered and that after the listener is deregistered are not processed. In the following example, the **MSG_SEND_METHOD** listener is registered in **onCreate** of the ability and deregistered in **onDestroy**. After receiving sequenceable data, the application processes the data and returns the data result. You need to implement processing based on service requirements. The sample code snippet is as follows:
+ The time to register a listener for the callee ability depends on your application. The data sent and received before the listener is registered and that after the listener is deregistered are not processed. In the following example, the `MSG_SEND_METHOD` listener is registered in `onCreate` of the ability and deregistered in `onDestroy`. After receiving sequenceable data, the application processes the data and returns the data result. You need to implement processing based on service requirements. The code snippet is as follows:
```ts
const TAG: string = '[CalleeAbility]'
const MSG_SEND_METHOD: string = 'CallSendMsg'
function sendMsgCallback(data) {
- Logger.log(TAG, 'CalleeSortFunc called')
+ console.log('CalleeSortFunc called')
- // Obtain the sequenceable data sent by the caller.
+ // Obtain the sequenceable data sent by the caller ability.
let receivedData = new MySequenceable(0, '')
data.readSequenceable(receivedData)
- Logger.log(TAG, `receiveData[${receivedData.num}, ${receivedData.str}]`)
+ console.log(`receiveData[${receivedData.num}, ${receivedData.str}]`)
// Process the data.
- // Return the sequenceable data result to the caller.
+ // Return the sequenceable data result to the caller ability.
return new MySequenceable(receivedData.num + 1, `send ${receivedData.str} succeed`)
}
@@ -106,7 +126,7 @@ export default class CalleeAbility extends Ability {
try {
this.callee.on(MSG_SEND_METHOD, sendMsgCallback)
} catch (error) {
- Logger.error(TAG, `${MSG_SEND_METHOD} register failed with error ${JSON.stringify(error)}`)
+ console.log(`${MSG_SEND_METHOD} register failed with error ${JSON.stringify(error)}`)
}
}
@@ -120,15 +140,27 @@ export default class CalleeAbility extends Ability {
}
```
-### Accessing the Callee
-1. Import the **Ability** module.
-```
+### Accessing the Callee Ability
+**1. Import the Ability module.**
+```ts
import Ability from '@ohos.application.Ability'
```
-2. Obtain the caller interface.
+**2. Obtain the `Caller` object.**
- The **context** attribute of the ability implements **startAbilityByCall** to obtain the caller interface of the ability. The following example uses **this.context** to obtain the **context** attribute of the **Ability** instance, uses **startAbilityByCall** to start the callee, obtain the caller interface, and register the **onRelease** listener of the caller. You need to implement processing based on service requirements. The sample code snippet is as follows:
+ The `context` attribute of the ability implements `startAbilityByCall` to obtain the `Caller` object for communication. The following example uses `this.context` to obtain the `context` attribute of the ability, uses `startAbilityByCall` to start the callee ability, obtain the `Caller` object, and register the `onRelease` listener of the caller ability. You need to implement processing based on service requirements. The code snippet is as follows:
```ts
+// Register the onRelease listener of the caller ability.
+private regOnRelease(caller) {
+ try {
+ caller.onRelease((msg) => {
+ console.log(`caller onRelease is called ${msg}`)
+ })
+ console.log('caller register OnRelease succeed')
+ } catch (error) {
+ console.log(`caller register OnRelease failed with ${error}`)
+ }
+}
+
async onButtonGetCaller() {
try {
this.caller = await context.startAbilityByCall({
@@ -136,73 +168,74 @@ async onButtonGetCaller() {
abilityName: 'CalleeAbility'
})
if (this.caller === undefined) {
- Logger.error(TAG, 'get caller failed')
+ console.log('get caller failed')
return
}
- Logger.log(TAG, 'get caller success')
+ console.log('get caller success')
this.regOnRelease(this.caller)
} catch (error) {
- Logger.error(TAG, `get caller failed with ${error}`)
+ console.log(`get caller failed with ${error}`)
}
-}.catch((error) => {
- console.error(TAG + 'get caller failed with ' + error)
-})
+}
```
- In the cross-device scenario, you need to specify the ID of the peer device. The sample code snippet is as follows:
+ In the cross-device scenario, you need to specify the ID of the peer device. The code snippet is as follows:
```ts
-let TAG = '[MainAbility] '
-var caller = undefined
-let context = this.context
-
-context.startAbilityByCall({
- deviceId: getRemoteDeviceId(),
- bundleName: 'com.samples.CallApplication',
- abilityName: 'CalleeAbility'
-}).then((data) => {
- if (data != null) {
- caller = data
- console.log(TAG + 'get remote caller success')
- // Register the onRelease listener of the caller.
- caller.onRelease((msg) => {
- console.log(TAG + 'remote caller onRelease is called ' + msg)
- })
- console.log(TAG + 'remote caller register OnRelease succeed')
- }
-}).catch((error) => {
- console.error(TAG + 'get remote caller failed with ' + error)
-})
+async onButtonGetRemoteCaller() {
+ var caller = undefined
+ var context = this.context
+
+ context.startAbilityByCall({
+ deviceId: getRemoteDeviceId(),
+ bundleName: 'com.samples.CallApplication',
+ abilityName: 'CalleeAbility'
+ }).then((data) => {
+ if (data != null) {
+ caller = data
+ console.log('get remote caller success')
+ // Register the onRelease listener of the caller ability.
+ caller.onRelease((msg) => {
+ console.log(`remote caller onRelease is called ${msg}`)
+ })
+ console.log('remote caller register OnRelease succeed')
+ }
+ }).catch((error) => {
+ console.error(`get remote caller failed with ${error}`)
+ })
+}
```
- Obtain the ID of the peer device from **DeviceManager**. Note that the **getTrustedDeviceListSync** API is open only to system applications. The sample code snippet is as follows:
+ Obtain the ID of the peer device from `DeviceManager`. Note that the `getTrustedDeviceListSync` API is open only to system applications. The code snippet is as follows:
```ts
import deviceManager from '@ohos.distributedHardware.deviceManager';
var dmClass;
function getRemoteDeviceId() {
if (typeof dmClass === 'object' && dmClass != null) {
- var list = dmClass.getTrustedDeviceListSync();
+ var list = dmClass.getTrustedDeviceListSync()
if (typeof (list) == 'undefined' || typeof (list.length) == 'undefined') {
- console.log("MainAbility onButtonClick getRemoteDeviceId err: list is null");
- return;
+ console.log("MainAbility onButtonClick getRemoteDeviceId err: list is null")
+ return
}
- console.log("MainAbility onButtonClick getRemoteDeviceId success:" + list[0].deviceId);
- return list[0].deviceId;
+ console.log("MainAbility onButtonClick getRemoteDeviceId success:" + list[0].deviceId)
+ return list[0].deviceId
} else {
- console.log("MainAbility onButtonClick getRemoteDeviceId err: dmClass is null");
+ console.log("MainAbility onButtonClick getRemoteDeviceId err: dmClass is null")
}
}
```
- In the cross-device scenario, the application must also apply for the data synchronization permission from end users. The sample code snippet is as follows:
+ In the cross-device scenario, your application must also apply for the data synchronization permission from end users. The code snippet is as follows:
```ts
-let context = this.context
-let permissions: Array = ['ohos.permission.DISTRIBUTED_DATASYNC']
-context.requestPermissionsFromUser(permissions).then((data) => {
- console.log("Succeed to request permission from user with data: "+ JSON.stringify(data))
-}).catch((error) => {
- console.log("Failed to request permission from user with error: "+ JSON.stringify(error))
-})
+requestPermission() {
+ let context = this.context
+ let permissions: Array = ['ohos.permission.DISTRIBUTED_DATASYNC']
+ context.requestPermissionsFromUser(permissions).then((data) => {
+ console.log("Succeed to request permission from user with data: "+ JSON.stringify(data))
+ }).catch((error) => {
+ console.log("Failed to request permission from user with error: "+ JSON.stringify(error))
+ })
+}
```
-3. Send agreed sequenceable data.
+**3. Send agreed sequenceable data.**
- The sequenceable data can be sent to the callee with or without a return value. The method and sequenceable data must be consistent with those of the callee. The following example describes how to invoke the **Call** API to send data to the callee. The sample code snippet is as follows:
+ The sequenceable data can be sent to the callee ability with or without a return value. The method and sequenceable data must be consistent with those of the callee ability. The following example describes how to send data to the callee ability. The code snippet is as follows:
```ts
const MSG_SEND_METHOD: string = 'CallSendMsg'
async onButtonCall() {
@@ -210,12 +243,12 @@ async onButtonCall() {
let msg = new MySequenceable(1, 'origin_Msg')
await this.caller.call(MSG_SEND_METHOD, msg)
} catch (error) {
- Logger.error(TAG, `caller call failed with ${error}`)
+ console.log(`caller call failed with ${error}`)
}
}
```
- In the following, **CallWithResult** is used to send data **originMsg** to the callee and assign the data processed by the **CallSendMsg** method to **backMsg**. The sample code snippet is as follows:
+ In the following, `CallWithResult` is used to send data `originMsg` to the callee ability and assign the data processed by the `CallSendMsg` method to `backMsg`. The code snippet is as follows:
```ts
const MSG_SEND_METHOD: string = 'CallSendMsg'
originMsg: string = ''
@@ -224,26 +257,28 @@ async onButtonCallWithResult(originMsg, backMsg) {
try {
let msg = new MySequenceable(1, originMsg)
const data = await this.caller.callWithResult(MSG_SEND_METHOD, msg)
- Logger.log(TAG, 'caller callWithResult succeed')
+ console.log('caller callWithResult succeed')
let result = new MySequenceable(0, '')
data.readSequenceable(result)
backMsg(result.str)
- Logger.log(TAG, `caller result is [${result.num}, ${result.str}]`)
+ console.log(`caller result is [${result.num}, ${result.str}]`)
} catch (error) {
- Logger.error(TAG, `caller callWithResult failed with ${error}`)
+ console.log(`caller callWithResult failed with ${error}`)
}
}
```
-4. Release the caller interface.
+**4. Release the `Caller` object.**
- When the caller interface is no longer required, call the **release** API to release it. The sample code snippet is as follows:
+ When the `Caller` object is no longer required, use `release()` to release it. The code snippet is as follows:
```ts
-try {
- this.caller.release()
- this.caller = undefined
- Logger.log(TAG, 'caller release succeed')
-} catch (error) {
- Logger.error(TAG, `caller release failed with ${error}`)
+releaseCall() {
+ try {
+ this.caller.release()
+ this.caller = undefined
+ console.log('caller release succeed')
+ } catch (error) {
+ console.log(`caller release failed with ${error}`)
+ }
}
```
diff --git a/en/application-dev/ability/wantagent.md b/en/application-dev/ability/wantagent.md
index eacc92936960cca3bd022e6438a63c15a8f2688a..5a85bab15b8422aaabb0a173ad888126e08fc038 100644
--- a/en/application-dev/ability/wantagent.md
+++ b/en/application-dev/ability/wantagent.md
@@ -1,6 +1,8 @@
# WantAgent Development
## When to Use
-The **WantAgent** class encapsulates want information that specifies a particular action, which can be starting an ability or publishing a common event. You can either call **wantAgent.trigger** to trigger a **WantAgent** directly or add a **WantAgent** to a notification so that it will be triggered when users tap the notification.
+The **WantAgent** class encapsulates want information that specifies a particular action, which can be starting an ability or publishing a common event. You can either call **wantAgent.trigger** to trigger a **WantAgent** directly or add a **WantAgent** to a notification so that it will be triggered when users tap the notification.
+
+
## Available APIs
| API | Description|
@@ -21,7 +23,7 @@ The **WantAgent** class encapsulates want information that specifies a particula
```
private wantAgentObj = null // Save the WantAgent object created. It will be used to complete the trigger operations.
- //wantAgentInfo
+ // wantAgentInfo
var wantAgentInfo = {
wants: [
{
@@ -45,7 +47,7 @@ The **WantAgent** class encapsulates want information that specifies a particula
```
private wantAgentObj = null // Save the WantAgent object created. It will be used to complete the trigger operations.
- //wantAgentInfo
+ // wantAgentInfo
var wantAgentInfo = {
wants: [
{
diff --git a/en/application-dev/application-dev-guide-for-gitee.md b/en/application-dev/application-dev-guide-for-gitee.md
index e60f2c01333c1bef7324b3ef6cfe2c83821a95cd..f074e1906535d708b193adea3b1ee3308fb0de4e 100644
--- a/en/application-dev/application-dev-guide-for-gitee.md
+++ b/en/application-dev/application-dev-guide-for-gitee.md
@@ -47,7 +47,7 @@ DevEco Studio is a high-performance integrated development environment (IDE) rec
### Hands-On Tutorials
-To make you better understand how functions work together and jumpstart your application development projects, we provide stripped-down, real-world [samples](https://gitee.com/openharmony/app_samples/blob/master/README.md) and [codelabs](https://gitee.com/openharmony/codelabs).
+To make you better understand how functions work together and jumpstart your application development projects, we provide stripped-down, real-world [samples](https://gitee.com/openharmony/applications_app_samples/blob/master/README.md) and [codelabs](https://gitee.com/openharmony/codelabs).
### API References
diff --git a/en/application-dev/application-dev-guide.md b/en/application-dev/application-dev-guide.md
index 7065480d1c4a12bd0984f4916d678c1bed7a4997..2b22839820539e2919f1a705595a47cc491df8d0 100644
--- a/en/application-dev/application-dev-guide.md
+++ b/en/application-dev/application-dev-guide.md
@@ -47,7 +47,7 @@ DevEco Studio is a high-performance integrated development environment (IDE) rec
### Hands-On Tutorials
-To make you better understand how functions work together and jumpstart your application development projects, we provide stripped-down, real-world [samples](https://gitee.com/openharmony/app_samples/blob/master/README.md) and [codelabs](https://gitee.com/openharmony/codelabs).
+To make you better understand how functions work together and jumpstart your application development projects, we provide stripped-down, real-world [samples](https://gitee.com/openharmony/applications_app_samples/blob/master/README.md) and [codelabs](https://gitee.com/openharmony/codelabs).
### API References
diff --git a/en/application-dev/database/database-datashare-guidelines.md b/en/application-dev/database/database-datashare-guidelines.md
index c8cb5c503329f6dc49c66fe457eb0aa8e6debf78..495f3b538b48b22d2d97f213d0e32189be799560 100644
--- a/en/application-dev/database/database-datashare-guidelines.md
+++ b/en/application-dev/database/database-datashare-guidelines.md
@@ -13,7 +13,7 @@ The **DataShare** module allows an application to manage its own data and share
|query?(uri: string, predicates: DataSharePredicates, columns: Array<string>, callback: AsyncCallback<Object>): void|Queries data from the database.|
|delete?(uri: string, predicates: DataSharePredicates, callback: AsyncCallback<number>): void|Deletes data from the database.|
-For more details, see [DataShareExtensionAbility](../reference/apis/js-apis-application-DataShareExtensionAbility.md).
+For more information, see [DataShareExtensionAbility](../reference/apis/js-apis-application-DataShareExtensionAbility.md).
**Table 2** APIs of the data consumer
@@ -25,11 +25,11 @@ For more details, see [DataShareExtensionAbility](../reference/apis/js-apis-appl
| query(uri: string, predicates: DataSharePredicates, columns: Array<string>, callback: AsyncCallback<DataShareResultSet>): void | Queries data from the database. |
| delete(uri: string, predicates: DataSharePredicates, callback: AsyncCallback<number>): void | Deletes one or more data records from the database.|
-For more details, see [DataShareHelper](../reference/apis/js-apis-data-dataShare.md).
+For more information, see [DataShareHelper](../reference/apis/js-apis-data-dataShare.md).
## When to Use
-There are two roles in **DataShare**.
+There are two roles in **DataShare**:
- Data provider: adds, deletes, modifies, and queries data, opens files, and shares data.
- Data consumer: accesses the data provided by the provider using **DataShareHelper**.
@@ -41,10 +41,10 @@ Examples are given below.
1. Import the dependencies.
```ts
- import Extension from '@ohos.application.DataShareExtensionAbility'
+ import Extension from '@ohos.application.DataShareExtensionAbility';
import rdb from '@ohos.data.rdb';
- import fileIo from '@ohos.fileio'
- import dataSharePredicates from '@ohos.data.dataSharePredicates'
+ import fileIo from '@ohos.fileio';
+ import dataSharePredicates from '@ohos.data.dataSharePredicates';
```
2. Override **DataShareExtensionAbility** APIs based on actual requirements. For example, if the data provider provides only data query, override only the **query()** API.
@@ -80,7 +80,7 @@ Examples are given below.
}
// Override the query() API.
- query(uri, predicates, columns, callback) {
+ query(uri, predicates, columns, callback) {
if (predicates == null || predicates == undefined) {
console.info('invalid predicates');
}
@@ -144,48 +144,49 @@ Examples are given below.
let dseUri = ("datashare:///com.samples.datasharetest.DataShare");
```
-2. Create a **DataShareHelper** instance.
+3. Create a **DataShareHelper** instance.
```ts
let dsHelper;
let abilityContext;
+
export default class MainAbility extends Ability {
onWindowStageCreate(windowStage) {
abilityContext = this.context;
- dataShare.createDataShareHelper(abilityContext, dseUri, (err,data)=>{
+ dataShare.createDataShareHelper(abilityContext, dseUri, (err, data)=>{
dsHelper = data;
});
}
}
```
-3. Use the APIs provided by **DataShareHelper** to access the services provided by the provider, for example, adding, deleting, modifying, and querying data.
+4. Use the APIs provided by **DataShareHelper** to access the services provided by the provider, for example, adding, deleting, modifying, and querying data.
```ts
// Construct a piece of data.
- var valuesBucket = {"name": "ZhangSan", "age": 21, "isStudent": false, "Binary": new Uint8Array([1,2,3])};
- var updateBucket = {"name": "LiSi", "age": 18, "isStudent": true, "Binary": new Uint8Array([1,2,3])};
- let da = new dataSharePredicates.DataSharePredicates();
- var valArray =new Array("*");
+ var valuesBucket = { "name": "ZhangSan", "age": 21, "isStudent": false, "Binary": new Uint8Array([1, 2, 3]) };
+ var updateBucket = { "name": "LiSi", "age": 18, "isStudent": true, "Binary": new Uint8Array([1, 2, 3]) };
+ let da = new dataSharePredicates.DataSharePredicates();
+ var valArray = new Array("*");
let people = new Array(
- {"name": "LiSi", "age": 41, "Binary": ar},
- {"name": "WangWu", "age": 21, "Binary": arr},
- {"name": "ZhaoLiu", "age": 61, "Binary": arr});
+ { "name": "LiSi", "age": 41, "Binary": ar },
+ { "name": "WangWu", "age": 21, "Binary": arr },
+ { "name": "ZhaoLiu", "age": 61, "Binary": arr });
// Insert a piece of data.
- dsHelper.insert(dseUri, valuesBucket, (err,data) => {
- console.log("dsHelper insert result: " + data);
+ dsHelper.insert(dseUri, valuesBucket, (err, data) => {
+ console.log("dsHelper insert result: " + data);
});
// Delete data.
- dsHelper.delete(dseUri, da, (err,data) => {
- console.log("dsHelper delete result: " + data);
+ dsHelper.delete(dseUri, da, (err, data) => {
+ console.log("dsHelper delete result: " + data);
});
// Update data.
- dsHelper.update(dseUri, da, updateBucket, (err,data) => {
- console.log("dsHelper update result: " + data);
+ dsHelper.update(dseUri, da, updateBucket, (err, data) => {
+ console.log("dsHelper update result: " + data);
});
// Query data.
- dsHelper.query(dseUri, da, valArray, (err,data) => {
- console.log("dsHelper query result: " + data);
+ dsHelper.query(dseUri, da, valArray, (err, data) => {
+ console.log("dsHelper query result: " + data);
});
```
diff --git a/en/application-dev/database/database-distributedobject-guidelines.md b/en/application-dev/database/database-distributedobject-guidelines.md
index eca90200a0d711c91f64643f453ff1d22a3a367f..ec77d5330b57751e36b3ba2d96b57028c340dd36 100644
--- a/en/application-dev/database/database-distributedobject-guidelines.md
+++ b/en/application-dev/database/database-distributedobject-guidelines.md
@@ -2,14 +2,13 @@
## When to Use
-Distributed data objects allow data traversing across devices to be processed like local variables by shielding complex data interaction between devices. For the devices that form a Super Device, when data in the distributed data object of an application is added, deleted, or modified on a device, the data for the same application is also updated on the other devices. The devices can listen for data changes and online and offline status changes of other devices.
-
-The distributed data objects support basic data types, such as number, string, and Boolean, as well as complex data types, such as array and nested basic types.
+The **distributedDataObject** module provides APIs to implement data collaboration of the same application across multiple devices. In addition, the devices that form a Super Device can listen for object status and data changes with each other.
+For example, when the data of a distributed data object is added, deleted, or modified for application A on device 1, application A on device 2 can obtain the updated data. In addition, device 2 can listen for data changes and online/offline of the data objects on device 1.
## Available APIs
-For details about the APIs related to the distributed data object, see [Distributed Data Object](../reference/apis/js-apis-data-distributedobject.md).
+For details about the APIs, see [Distributed Data Object](../reference/apis/js-apis-data-distributedobject.md).
### Creating a Distributed Data Object Instance
@@ -17,53 +16,54 @@ Call **createDistributedObject()** to create a distributed data object instance.
**Table 1** API for creating a distributed data object instance
-| Package | API | Description |
+| Package| API| Description|
| -------- | -------- | -------- |
-| ohos.data.distributedDataObject| createDistributedObject(source: object): DistributedObject | Creates a distributed data object instance for data operations.
- **source**: attributes of the **distributedObject** set.
- **DistributedObject**: returns the distributed object created.|
+| ohos.data.distributedDataObject| createDistributedObject(source: object): DistributedObject | Creates a distributed data object instance for data operations.
- **source**: attributes of the distributed data object to set.
- **DistributedObject**: returns the distributed data object created. |
### Generating a Session ID
Call **genSessionId()** to generate a session ID randomly. The generated session ID can be used to set the session ID of a distributed data object.
**Table 2** API for generating a session ID randomly
-| Package | API | Description |
+| Package| API| Description|
| -------- | -------- | -------- |
| ohos.data.distributedDataObject| genSessionId(): string | Generates a session ID, which can be used as the session ID of a distributed data object.|
-### Setting a SessionID for Distributed Data Objects
+### Setting a Session ID for a Distributed Data Object
Call **setSessionId()** to set a session ID for a distributed data object. The session ID is a unique identifier for one collaboration across devices. The distributed data objects to be synchronized must be associated with the same session ID.
**Table 3** API for setting a session ID
| Class| API| Description|
| -------- | -------- | -------- |
-| DistributedDataObject | setSessionId(sessionId?: string): boolean | Sets a session ID for distributed data objects.
**sessionId**: session ID of a distributed object in a trusted network. To remove a distributed data object from the network, set this parameter to "" or leave it empty.|
+| DistributedDataObject | setSessionId(sessionId?: string): boolean | Sets a session ID for a distributed data object.
**sessionId**: session ID of a distributed data object in a trusted network. To remove a distributed data object from the network, set this parameter to "" or leave it empty. |
### Observing Data Changes
-Call **on()** to subscribe to data changes of a distributed data object. In the case of data change, a callback will be invoked to return the data changes. You can use **off()** to unsubscribe from the data changes.
+Call **on()** to subscribe to data changes of a distributed data object. When the data changes, a callback will be invoked to return the data changes. You can use **off()** to unsubscribe from the data changes.
**Table 4** APIs for observing data changes of a distributed data object
-| Class | API | Description |
+
+| Class| API| Description|
| -------- | -------- | -------- |
| DistributedDataObject| on(type: 'change', callback: Callback<{ sessionId: string, fields: Array<string> }>): void | Subscribes to data changes.|
-| DistributedDataObject| off(type: 'change', callback?: Callback<{ sessionId: string, fields: Array<string> }>): void | Unsubscribes from data changes.
**Callback**: specifies callback used to return changes of the distributed data object. If this parameter is not specified, all callbacks related to data changes will be unregistered.|
+| DistributedDataObject| off(type: 'change', callback?: Callback<{ sessionId: string, fields: Array<string> }>): void | Unsubscribes from data changes.
**Callback**: callback to unregister. If this parameter is not specified, all data changes of this distributed data object will be unsubscribed from. |
### Observing Online or Offline Status
Call **on()** to subscribe to status changes of a distributed data object. The status can be online or offline. When the status changes, a callback will be invoked to return the status. You can use **off()** to unsubscribe from the status changes.
**Table 5** APIs for observing status changes of a distributed data object
-| Class | API | Description |
+| Class| API| Description|
| -------- | -------- | -------- |
| DistributedDataObject| on(type: 'status', callback: Callback<{ sessionId: string, networkId: string, status: 'online' \| 'offline' }>): void | Subscribes to the status changes of a distributed data object.|
| DistributedDataObject| off(type: 'status', callback?: Callback<{ sessionId: string, deviceId: string, status: 'online' \| 'offline' }>): void | Unsubscribes from status changes of a distributed data object.|
-### Saving a Distributed Data Object and Revoking the Data Saving Operation
+### Saving or Deleting a Distributed Data Object
Call **save()** to save a distributed data object. When the application is active, the saved data will not be released. When the application exits and restarts, the data saved on the device will be restored.
-Call **revokeSave()** to revoke a distributed data object that is no longer required. If the distributed data object is saved on the local device, **revokeSave()** will delete the data from all trusted devices. If the distributed data object is not saved on the local device, **revokeSave()** will delete the data from the local device.
+Call **revokeSave()** to delete a distributed data object that is no longer required. If the distributed data object is saved on the local device, **revokeSave()** will delete the data from all trusted devices. If the distributed data object is not saved on the local device, **revokeSave()** will delete the data from the local device.
The saved data will be released in the following cases:
@@ -71,13 +71,12 @@ The saved data will be released in the following cases:
- The application has been uninstalled.
- Data is successfully restored.
-**Table 6** APIs for saving a distributed data object and revoking the saving
-| Class | API | Description |
+**Table 6** APIs for saving and deleting a distributed data object
+
+| Class| API| Description|
| -------- | -------- | -------- |
-| DistributedDataObject | save(deviceId: string): Promise<SaveSuccessResponse> | Saves a distributed data object. This API uses a promise to return the result. |
-| DistributedDataObject | save(deviceId: string, callback: AsyncCallback<SaveSuccessResponse>): void | Saves a distributed data object. This API uses an asynchronous callback to return the result. |
-| DistributedDataObject | revokeSave(callback: AsyncCallback<RevokeSaveSuccessResponse>): void | Revokes the data saving operation. This API uses an asynchronous callback to return the result. |
-| DistributedDataObject | revokeSave(): Promise<RevokeSaveSuccessResponse> | Revokes the data saving operation. This API uses a promise to return the result. |
+| DistributedDataObject | save(deviceId: string): Promise<SaveSuccessResponse> | Saves a distributed data object.|
+| DistributedDataObject| revokeSave(): Promise<RevokeSaveSuccessResponse> | Deletes a distributed data object. |
## How to Develop
@@ -89,11 +88,11 @@ The following example shows how to implement distributed data object synchroniza
import distributedObject from '@ohos.data.distributedDataObject';
```
-2. Request the permission.
-
- Add the required permission in the **config.json** file. The sample code is as follows:
-
- ```
+2. Apply for the permission.
+
+ Add the permissions required (FA model) to the **config.json** file. The sample code is as follows:
+
+ ```json
{
"module": {
"reqPermissions": [
@@ -104,11 +103,13 @@ The following example shows how to implement distributed data object synchroniza
}
}
```
- This permission must also be authorized by the user through a dialog box when the application is started for the first time. The sample code is as follows:
-
- ```
+ For the apps based on the stage model, see [Declaring Permissions](../security/accesstoken-guidelines.md#stage-model).
+
+ This permission must also be granted by the user when the application is started for the first time. The sample code is as follows:
+
+ ```js
import featureAbility from '@ohos.ability.featureAbility';
-
+
function grantPermission() {
console.info('grantPermission');
let context = featureAbility.getContext();
@@ -116,93 +117,105 @@ The following example shows how to implement distributed data object synchroniza
console.info(`result.requestCode=${result.requestCode}`)
})
- console.info('end grantPermission');
+ console.info('end grantPermission');
}
+
grantPermission();
```
-
-
-
+
3. Obtain a distributed data object instance.
The sample code is as follows:
```js
- var local_object = distributedObject.createDistributedObject({name:undefined, age:undefined, isVis:true,
- parent:undefined, list:undefined});
+ var local_object = distributedObject.createDistributedObject({
+ name: undefined,
+ age: undefined,
+ isVis: true,
+ parent: undefined,
+ list: undefined
+ });
var sessionId = distributedObject.genSessionId();
```
-
-4. Add the synchronization network. The data objects in the synchronization network include the local and remote objects.
+4. Add the distributed data object instance to a network for data synchronization. The data objects in the synchronization network include the local and remote objects.
The sample code is as follows:
```js
// Local object
- var local_object = distributedObject.createDistributedObject({name:"jack", age:18, isVis:true,
- parent:{mother:"jack mom", father:"jack Dad"}, list:[{mother:"jack mom"}, {father:"jack Dad"}]});
+ var local_object = distributedObject.createDistributedObject({
+ name: "jack",
+ age: 18,
+ isVis: true,
+ parent: { mother: "jack mom", father: "jack Dad" },
+ list: [{ mother: "jack mom" }, { father: "jack Dad" }]
+ });
local_object.setSessionId(sessionId);
// Remote object
- var remote_object = distributedObject.createDistributedObject({name:undefined, age:undefined, isVis:true,
- parent:undefined, list:undefined});
+ var remote_object = distributedObject.createDistributedObject({
+ name: undefined,
+ age: undefined,
+ isVis: true,
+ parent: undefined,
+ list: undefined
+ });
+ // After learning that the local device goes online, the remote object synchronizes data. That is, name changes to jack and age to 18.
remote_object.setSessionId(sessionId);
- // After learning that the device goes online, the remote object synchronizes data. That is, name changes to jack and age to 18.
```
5. Observe the data changes of the distributed data object.
- You can subscribe to data changes of the peer object. When the data in the peer object changes, a callback will be called to return the data changes.
+ You can subscribe to data changes of the remote object. When the data in the remote object changes, a callback will be called to return the data changes.
The sample code is as follows:
```js
function changeCallback(sessionId, changeData) {
- console.info("change" + sessionId);
+ console.info("change" + sessionId);
- if (changeData != null && changeData != undefined) {
- changeData.forEach(element => {
- console.info("changed !" + element + " " + local_object[element]);
- });
- }
- }
+ if (changeData != null && changeData != undefined) {
+ changeData.forEach(element => {
+ console.info("changed !" + element + " " + local_object[element]);
+ });
+ }
+ }
- // To refresh the page in changeCallback, correctly bind (this) to the changeCallback.
- local_object.on("change", this.changeCallback.bind(this));
+ // To refresh the page in changeCallback, correctly bind (this) to the changeCallback.
+ local_object.on("change", this.changeCallback.bind(this));
```
-6. Modify object attributes.
+6. Modify attributes of the distributed data object.
The object attributes support basic data types (such as number, Boolean, and string) and complex data types (array and nested basic types).
The sample code is as follows:
+
```js
local_object.name = "jack";
local_object.age = 19;
local_object.isVis = false;
- local_object.parent = {mother:"jack mom", father:"jack Dad"};
- local_object.list = [{mother:"jack mom"}, {father:"jack Dad"}];
+ local_object.parent = { mother: "jack mom", father: "jack Dad" };
+ local_object.list = [{ mother: "jack mom" }, { father: "jack Dad" }];
```
- >  **NOTE**
- >
- > For the distributed data object of the complex type, only the root attribute can be modified. The subordinate attributes cannot be modified.
-
- Example:
+ > **NOTE**
+ > For the distributed data object of the complex type, only the root attribute can be modified. The subordinate attributes cannot be modified. Example:
```js
// Supported modification.
- local_object.parent = {mother:"mom", father:"dad"};
+ local_object.parent = { mother: "mom", father: "dad" };
// Modification not supported.
local_object.parent.mother = "mom";
```
7. Access the distributed data object.
- Obtain the distributed data object attribute, which is the latest data on the network.
+ Obtain the distributed data object attributes, which are the latest data on the network.
The sample code is as follows:
+
```js
console.info("name " + local_object["name"]);
```
@@ -221,7 +234,6 @@ The following example shows how to implement distributed data object synchroniza
```
9. Subscribe to the status (online/offline) changes of the distributed data object. A callback will be invoked to report the status change when the target distributed data object goes online or offline.
-
The sample code is as follows:
```js
@@ -232,55 +244,31 @@ The following example shows how to implement distributed data object synchroniza
local_object.on("status", this.statusCallback);
```
-10. Save a distributed data object and revoke the data saving operation.
-
- - Callback
+10. Save a distributed data object and delete it.
- ```
- ```js
- // Save a distributed data object.
- local_object.save("local", (result, data) => {
- console.log("save callback");
- console.info("save sessionId " + data.sessionId);
- console.info("save version " + data.version);
- console.info("save deviceId " + data.deviceId);
- });
- // Revoke the data saving operation.
- local_object.revokeSave((result, data) => {
- console.log("revokeSave callback");
- console.info("revokeSave sessionId " + data.sessionId);
- });
- ```
- ```
-
- - Promise
-
- ```
- ```js
- // Save a distributed data object.
- g_object.save("local").then((result) => {
- console.info("save sessionId " + result.sessionId);
- console.info("save version " + result.version);
- console.info("save deviceId " + result.deviceId);
- }, (result)=>{
- console.info("save local failed.");
- });
- // Revoke the data saving operation.
- g_object.revokeSave().then((result) => {
- console.info("revokeSave success.");
- }, (result)=>{
- console.info("revokeSave failed.");
- });
- ```
- ```
-
-
+ ```js
+ // Save a distributed data object.
+ g_object.save("local").then((result) => {
+ console.info("save sessionId " + result.sessionId);
+ console.info("save version " + result.version);
+ console.info("save deviceId " + result.deviceId);
+ }, (result) => {
+ console.info("save local failed.");
+ });
+ // Delete a distributed data object..
+ g_object.revokeSave().then((result) => {
+ console.info("revokeSave success.");
+ }, (result) => {
+ console.info("revokeSave failed.");
+ });
+ ```
11. Unsubscribe from the status changes of the distributed data object.
- You can specify the callback to unregister. If you do not specify the callback, this API unregisters all callbacks of this distributed data object.
+ You can specify the callback to unregister. If you do not specify the callback, all status change callbacks of this distributed data object will be unregistered.
The sample code is as follows:
+
```js
// Unregister the specified status change callback.
local_object.off("status", this.statusCallback);
@@ -290,7 +278,8 @@ The following example shows how to implement distributed data object synchroniza
12. Remove a distributed data object from the synchronization network. Data changes on the local object will not be synchronized to the removed distributed data object.
- The sample code is as follows:
- ```js
- local_object.setSessionId("");
- ```
+ The sample code is as follows:
+
+ ```js
+ local_object.setSessionId("");
+ ```
diff --git a/en/application-dev/database/database-distributedobject-overview.md b/en/application-dev/database/database-distributedobject-overview.md
index 618bc881d563c11c51c9012831f48357a79830b1..80985ed39b8c91a5c9635e0be8fd00f4be2da702 100644
--- a/en/application-dev/database/database-distributedobject-overview.md
+++ b/en/application-dev/database/database-distributedobject-overview.md
@@ -1,29 +1,29 @@
# Distributed Data Object Overview
-The distributed data object management framework is an object-oriented in-memory data management framework. It provides application developers with basic data object management capabilities, such as creating, querying, deleting, modifying, and subscribing to in-memory objects. This management framework also provides distributed capabilities to implement data object collaboration for the same application between multiple devices that form a Super Device.
+The distributed data object management framework provides object-oriented in-memory data management. It provides basic data management capabilities, such as creating, querying, deleting, and modifying distributed data objects, and observing data and status changes of the distributed data objects. This management framework also provides distributed capabilities to implement data object collaboration for the same application between multiple devices that form a Super Device.
-## Key Concepts
+## Basic Concepts
- **Distributed in-memory database**
- The distributed in-memory database caches data in the memory, so that applications can quickly access data. This database, however, does not store data persistently. If the database is closed, the data is not retained.
+ The distributed in-memory database caches data in the memory so that applications can quickly access data. This database, however, does not store data persistently. If the database is closed, the data is not retained.
- **Distributed data object**
- A distributed data object is an encapsulation of the JS object type. Each distributed data object instance creates a data table in the in-memory database. The in-memory databases created for different applications are isolated from each other. Reading or assigning values to distributed data objects is automatically mapped to the **put** or **get** operation of the corresponding database.
+ A distributed data object is an encapsulation of the JS object type. Each distributed data object instance creates a data table in the in-memory database. The in-memory databases created for different applications are isolated from each other. Reading data from and writing data to a distributed data object are mapped to the **put** and **get** operations in the corresponding database, respectively.
The distributed data object can be in the following states in its lifecycle:
- **Uninitialized**: The distributed data object is not instantiated or has been destroyed.
- **Local**: The data table is created, but the data cannot be synchronized.
- - **Distributed**: The data table is created, there are at least two online with the same session ID, and data can be synchronized across devices. If the device is offline or the session ID is empty, the distributed data object changes to the local state.
+ - **Distributed**: The data table is created, and there are at least two online devices with the same session ID. In this case, data can be synchronized across devices. If a device is offline or the session ID is empty, the distributed data object changes to the local state.
## Working Principles
-The distributed data objects are encapsulated into JS objects in distributed in-memory databases, which allows the distributed data objects to be operated in the same way as local variables. The system automatically implements cross-device data synchronization.
+The distributed data objects are encapsulated into JS objects in distributed in-memory databases. This allows the distributed data objects to be operated in the same way as local variables. The system automatically implements cross-device data synchronization.
**Figure 1** Working mechanism
@@ -34,7 +34,7 @@ The distributed data objects are encapsulated into JS objects in distributed in-
## Constraints
-- Data synchronization can be implemented across devices only for the applications with the same bundleName.
+- Data synchronization can be implemented across devices only for the applications with the same **bundleName**.
- Each distributed data object occupies 100 KB to 150 KB of memory. Therefore, you are advised not to create too many distributed data objects.
diff --git a/en/application-dev/database/database-mdds-guidelines.md b/en/application-dev/database/database-mdds-guidelines.md
index dd1594215a10d1c93c9825444253484ed8956e05..2205df9ceffb51c3c6cb7816f6d11784ba532b20 100644
--- a/en/application-dev/database/database-mdds-guidelines.md
+++ b/en/application-dev/database/database-mdds-guidelines.md
@@ -6,113 +6,144 @@ The Distributed Data Service (DDS) implements synchronization of application dat
## Available APIs
-For details about the APIs related to distributed data, see [Distributed Data Management](../reference/apis/js-apis-distributed-data.md).
+For details about the APIs, see [Distributed Data Management](../reference/apis/js-apis-distributed-data.md).
**Table 1** APIs provided by the DDS
| API | Description |
| ------------------------------------------------------------ | ----------------------------------------------- |
-| createKVManager(config:KVManagerConfig,callback:AsyncCallback<KVManager>):void
createKVManager(config:KVManagerConfig):Promise<KVManager> | Creates a **KVManager** object for database management.|
-| getKVStore<TextendsKVStore>(storeId:string,options:Options,callback:AsyncCallback<T>):void
getKVStore<TextendsKVStore>(storeId:string,options:Options):Promise<T> | Obtains a KV store with the specified **Options** and **storeId**.|
-| put(key:string,value:Uint8Array\|string\|number\|boolean,callback:AsyncCallback<void>):void
put(key:string,value:Uint8Array\|string\|number\|boolean):Promise<void> | Inserts and updates data. |
-| delete(key:string,callback:AsyncCallback<void>):void
delete(key:string):Promise<void> | Deletes data. |
-| get(key:string,callback:AsyncCallback<Uint8Array\|string\|boolean\|number>):void
get(key:string):Promise<Uint8Array\|string\|boolean\|number> | Queries data. |
-| on(event:'dataChange',type:SubscribeType,observer:Callback<ChangeNotification>):void
on(event:'syncComplete',syncCallback:Callback<Array<[string,number]>>):void | Subscribes to data changes in the KV store. |
-| sync(deviceIdList:string[],mode:SyncMode,allowedDelayMs?:number):void | Triggers database synchronization in manual mode. |
-
-
-
+| createKVManager(config: KVManagerConfig, callback: AsyncCallback<KVManager>): void
createKVManager(config: KVManagerConfig): Promise<KVManager> | Creates a **KVManager** object for database management.|
+| getKVStore<TextendsKVStore>(storeId: string, options: Options, callback: AsyncCallback<T>): void
getKVStore<TextendsKVStore>(storeId: string, options: Options): Promise<T> | Obtains a KV store with the specified **Options** and **storeId**.|
+| put(key: string, value: Uint8Array\|string\|number\|boolean, callback: AsyncCallback<void>): void
put(key: string, value: Uint8Array\|string\|number\|boolean): Promise<void> | Inserts and updates data. |
+| delete(key: string, callback: AsyncCallback<void>): void
delete(key: string): Promise<void> | Deletes data. |
+| get(key: string, callback: AsyncCallback<Uint8Array\|string\|boolean\|number>): void
get(key: string): Promise<Uint8Array\|string\|boolean\|number> | Queries data. |
+| on(event: 'dataChange', type: SubscribeType, observer: Callback<ChangeNotification>): void
on(event: 'syncComplete', syncCallback: Callback<Array<[string,number]>>): void | Subscribes to data changes in the KV store. |
+| sync(deviceIdList: string[], mode: SyncMode, allowedDelayMs?: number): void | Triggers database synchronization in manual mode. |
## How to Develop
The following uses a single KV store as an example to describe the development procedure.
1. Import the distributed data module.
+
```js
import distributedData from '@ohos.data.distributedData';
```
+2. Apply for the required permission if data synchronization is required.
-2. Create a **KvManager** instance based on the specified **KvManagerConfig** object.
-
- (1) Create a **KvManagerConfig** object based on the application context.
+ Add the permission required (FA model) in the **config.json** file. The sample code is as follows:
+
+ ```json
+ {
+ "module": {
+ "reqPermissions": [
+ {
+ "name": "ohos.permission.DISTRIBUTED_DATASYNC"
+ }
+ ]
+ }
+ }
+ ```
+ For the apps based on the stage model, see [Declaring Permissions](../security/accesstoken-guidelines.md#stage-model).
+
+ This permission must also be granted by the user when the application is started for the first time. The sample code is as follows:
+
+ ```js
+ import featureAbility from '@ohos.ability.featureAbility';
+
+ function grantPermission() {
+ console.info('grantPermission');
+ let context = featureAbility.getContext();
+ context.requestPermissionsFromUser(['ohos.permission.DISTRIBUTED_DATASYNC'], 666, function (result) {
+ console.info(`result.requestCode=${result.requestCode}`)
+
+ })
+ console.info('end grantPermission');
+ }
+
+ grantPermission();
+ ```
+
+3. Create a **kvManager** instance based on the specified **kvManagerConfig** object.
+
+ 1. Create a **kvManagerConfig** object based on the application context.
+ 2. Create a **kvManager** instance.
- (2) Create a **KvManager** instance.
-
The sample code is as follows:
-
- ```
+
+ ```js
let kvManager;
try {
- const kvManagerConfig = {
- bundleName : 'com.example.datamanagertest',
- userInfo : {
- userId : '0',
- userType : distributedData.UserType.SAME_USER_ID
- }
+ const kvManagerConfig = {
+ bundleName: 'com.example.datamanagertest',
+ userInfo: {
+ userId: '0',
+ userType: distributedData.UserType.SAME_USER_ID
}
- distributedData.createKVManager(kvManagerConfig, function (err, manager) {
- if (err) {
- console.log("createKVManager err: " + JSON.stringify(err));
- return;
- }
- console.log("createKVManager success");
- kvManager = manager;
- });
+ }
+ distributedData.createKVManager(kvManagerConfig, function (err, manager) {
+ if (err) {
+ console.log("createKVManager err: " + JSON.stringify(err));
+ return;
+ }
+ console.log("createKVManager success");
+ kvManager = manager;
+ });
} catch (e) {
- console.log("An unexpected error occurred. Error:" + e);
+ console.log("An unexpected error occurred. Error: " + e);
}
```
-
-
-3. Create and obtain a single KV store.
- (1) Declare the ID of the single KV store to create.
+4. Create and obtain a single KV store.
- (2) Create a single KV store. You are advised to disable automatic synchronization (**autoSync:false**) and call **sync** when a synchronization is required.
+ 1. Declare the ID of the single KV store to create.
+ 2. Create a single KV store. You are advised to disable automatic synchronization (`autoSync:false`) and call `sync` when a synchronization is required.
The sample code is as follows:
+
```js
let kvStore;
try {
- const options = {
- createIfMissing : true,
- encrypt : false,
- backup : false,
- autoSync : false,
- kvStoreType : distributedData.KVStoreType.SINGLE_VERSION,
- securityLevel : distributedData.SecurityLevel.S0,
- };
- kvManager.getKVStore('storeId', options, function (err, store) {
- if (err) {
- console.log("getKVStore err: " + JSON.stringify(err));
- return;
- }
- console.log("getKVStore success");
- kvStore = store;
- });
+ const options = {
+ createIfMissing: true,
+ encrypt: false,
+ backup: false,
+ autoSync: false,
+ kvStoreType: distributedData.KVStoreType.SINGLE_VERSION,
+ securityLevel: distributedData.SecurityLevel.S0
+ };
+ kvManager.getKVStore('storeId', options, function (err, store) {
+ if (err) {
+ console.log("getKVStore err: " + JSON.stringify(err));
+ return;
+ }
+ console.log("getKVStore success");
+ kvStore = store;
+ });
} catch (e) {
- console.log("An unexpected error occurred. Error:" + e);
+ console.log("An unexpected error occurred. Error: " + e);
}
```
- > **NOTE**
+ > **NOTE**
>
> For data synchronization between networked devices, you are advised to open the distributed KV store during application startup to obtain the database handle. With this database handle (`kvStore` in this example), you can perform operations, such as inserting data into the KV store, without creating the KV store repeatedly during the lifecycle of the handle.
+
+5. Subscribe to changes in the distributed data.
-4. Subscribe to changes in the distributed data.
The following is the sample code for subscribing to the data changes of a single KV store:
+
```js
kvStore.on('dataChange', distributedData.SubscribeType.SUBSCRIBE_TYPE_ALL, function (data) {
console.log("dataChange callback call data: " + JSON.stringify(data));
});
```
-5. Write data to the single KV store.
-
- (1) Construct the key and value to be written into the single KV store.
+6. Write data to the single KV store.
- (2) Write key-value pairs into the single KV store.
+ 1. Construct the `Key` and `Value` to be written into the single KV store.
+ 2. Write key-value pairs into the single KV store.
The following is the sample code for writing key-value pairs of the string type into the single KV store:
@@ -120,52 +151,54 @@ The following uses a single KV store as an example to describe the development p
const KEY_TEST_STRING_ELEMENT = 'key_test_string';
const VALUE_TEST_STRING_ELEMENT = 'value-test-string';
try {
- kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err,data) {
+ kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err, data) {
if (err != undefined) {
console.log("put err: " + JSON.stringify(err));
return;
}
console.log("put success");
});
- }catch (e) {
- console.log("An unexpected error occurred. Error:" + e);
+ } catch (e) {
+ console.log("An unexpected error occurred. Error: " + e);
}
```
-6. Query data in the single KV store.
-
- (1) Construct the key to be queried from the single KV store.
+7. Query data in the single KV store.
- (2) Query data from the single KV store.
+ 1. Construct the `Key` to be queried from the single KV store.
+ 2. Query data from the single KV store.
The following is the sample code for querying data of the string type from the single KV store:
+
```js
const KEY_TEST_STRING_ELEMENT = 'key_test_string';
const VALUE_TEST_STRING_ELEMENT = 'value-test-string';
try {
- kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err,data) {
+ kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err, data) {
if (err != undefined) {
console.log("put err: " + JSON.stringify(err));
return;
}
console.log("put success");
- kvStore.get(KEY_TEST_STRING_ELEMENT, function (err,data) {
+ kvStore.get(KEY_TEST_STRING_ELEMENT, function (err, data) {
console.log("get success data: " + data);
});
});
- }catch (e) {
- console.log("An unexpected error occurred. Error:" + e);
+ } catch (e) {
+ console.log("An unexpected error occurred. Error: " + e);
}
```
-7. Synchronize data to other devices.
+8. Synchronize data to other devices.
+
Select the devices in the same network and the synchronization mode to synchronize data.
- > **NOTE**
+ > **NOTE**
>
> The APIs of the `deviceManager` module are system interfaces.
+
+ The following is the example code for synchronizing data in a single KV store:
- The following is the sample code for synchronizing data in a single KV store:
```js
import deviceManager from '@ohos.distributedHardware.deviceManager';
@@ -185,8 +218,8 @@ The following uses a single KV store as an example to describe the development p
try{
// 1000 indicates that the maximum delay is 1000 ms.
kvStore.sync(deviceIds, distributedData.SyncMode.PUSH_ONLY, 1000);
- }catch (e) {
- console.log("An unexpected error occurred. Error:" + e);
+ } catch (e) {
+ console.log("An unexpected error occurred. Error: " + e);
}
}
});
diff --git a/en/application-dev/database/database-preference-guidelines.md b/en/application-dev/database/database-preference-guidelines.md
index fdb69297523057f5530ef2f885fbe3e0b5cbf5cf..61aa2294c3f8ee077241e347e47e7780f50c4359 100644
--- a/en/application-dev/database/database-preference-guidelines.md
+++ b/en/application-dev/database/database-preference-guidelines.md
@@ -2,7 +2,7 @@
> **NOTE**
>
-> This feature is supported since API Version 9. For the versions earlier than API version 9, use [Lightweight Storage](../reference/apis/js-apis-data-storage.md) APIs.
+> This feature is supported since API version 9. For the versions earlier than API version 9, use [Lightweight Storage](../reference/apis/js-apis-data-storage.md) APIs.
## When to Use
@@ -88,8 +88,30 @@ Use the following APIs to delete a **Preferences** instance or data file.
2. Obtain a **Preferences** instance.
Read the specified file and load its data to the **Preferences** instance for data operations.
+
+ FA model:
+
```js
- let promise = data_preferences.getPreferences(this.context, 'mystore');
+ // Obtain the context.
+ import featureAbility from '@ohos.ability.featureAbility'
+ var context = featureAbility.getContext()
+
+ let promise = data_preferences.getPreferences(context, 'mystore');
+ ```
+
+ Stage model:
+
+ ```ts
+ // Obtain the context.
+ import Ability from '@ohos.application.Ability'
+ var context
+ class MainAbility extends Ability{
+ onWindowStageCreate(windowStage){
+ context = this.context
+ }
+ }
+
+ let promise = data_preferences.getPreferences(context, 'mystore');
```
3. Write data.
@@ -115,12 +137,12 @@ Use the following APIs to delete a **Preferences** instance or data file.
```js
promise.then((preferences) => {
- let getPromise = preferences.get('startup', 'default');
- getPromise.then((value) => {
- console.info("The value of 'startup' is " + value);
- }).catch((err) => {
- console.info("Failed to get the value of 'startup'. Cause: " + err);
- })
+ let getPromise = preferences.get('startup', 'default');
+ getPromise.then((value) => {
+ console.info("The value of 'startup' is " + value);
+ }).catch((err) => {
+ console.info("Failed to get the value of 'startup'. Cause: " + err);
+ })
}).catch((err) => {
console.info("Failed to get the preferences.")
});
@@ -139,24 +161,24 @@ Use the following APIs to delete a **Preferences** instance or data file.
Specify an observer as the callback to subscribe to data changes for an application. When the value of the subscribed key is changed and saved by **flush()**, the observer callback will be invoked to return the new data.
```js
- var observer = function (key) {
- console.info("The key" + key + " changed.");
- }
- preferences.on('change', observer);
- preferences.put('startup', 'auto', function (err) {
- if (err) {
- console.info("Failed to put the value of 'startup'. Cause: " + err);
- return;
- }
+ var observer = function (key) {
+ console.info("The key" + key + " changed.");
+ }
+ preferences.on('change', observer);
+ preferences.put('startup', 'auto', function (err) {
+ if (err) {
+ console.info("Failed to put the value of 'startup'. Cause: " + err);
+ return;
+ }
console.info("Put the value of 'startup' successfully.");
- preferences.flush(function (err) {
- if (err) {
- console.info("Failed to flush data. Cause: " + err);
- return;
- }
+ preferences.flush(function (err) {
+ if (err) {
+ console.info("Failed to flush data. Cause: " + err);
+ return;
+ }
console.info("Flushed data successfully."); // The observer will be called.
- })
- })
+ })
+ })
```
7. Delete the specified file.
@@ -164,10 +186,10 @@ Use the following APIs to delete a **Preferences** instance or data file.
Use the **deletePreferences** method to delete the **Preferences** instance and its persistent file and backup and corrupted files. After the specified files are deleted, the application cannot use that instance to perform any data operation. Otherwise, data inconsistency will be caused. The deleted data and files cannot be restored.
```js
- let proDelete = data_preferences.deletePreferences(context, 'mystore');
- proDelete.then(() => {
+ let proDelete = data_preferences.deletePreferences(context, 'mystore');
+ proDelete.then(() => {
console.info("Deleted data successfully.");
- }).catch((err) => {
+ }).catch((err) => {
console.info("Failed to delete data. Cause: " + err);
- })
+ })
```
diff --git a/en/application-dev/database/database-relational-guidelines.md b/en/application-dev/database/database-relational-guidelines.md
index f6c7395339d66cb1c79bf71d424c15072f77f1b6..a4acbd9a7b47dca4332c7f6a881939b1928abd78 100644
--- a/en/application-dev/database/database-relational-guidelines.md
+++ b/en/application-dev/database/database-relational-guidelines.md
@@ -30,9 +30,10 @@ The RDB provides APIs for inserting, deleting, updating, and querying data in th
**Table 2** API for inserting data
+
| Class | API | Description |
| -------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
- | RdbStore | insert(table:string,values:ValuesBucket):Promise<number> | Inserts a row of data into a table. This API uses a promise to return the result.
If the operation is successful, the row ID will be returned; otherwise, **-1** will be returned.
- **table**: name of the target table.
- **values**: data to be inserted into the table.|
+ | RdbStore | insert(table: string, values: ValuesBucket): Promise<number> | Inserts a row of data into a table. This API uses a promise to return the result.
If the operation is successful, the row ID will be returned; otherwise, **-1** will be returned.
- **table**: name of the target table.
- **values**: data to be inserted into the table.|
- **Updating Data**
@@ -40,9 +41,10 @@ The RDB provides APIs for inserting, deleting, updating, and querying data in th
**Table 3** API for updating data
- | Class | API | Description |
+
+ | Class | API | Description |
| -------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
- | RdbStore | update(values:ValuesBucket,predicates:RdbPredicates):Promise<number> | Updates data based on the specified **RdbPredicates** object. This API uses a promise to return the result.
- **values**: data to update, which is stored in **ValuesBucket**.
- **predicates**: conditions for updating data.
Return value: number of rows updated. |
+ | RdbStore | update(values: ValuesBucket, predicates: RdbPredicates): Promise<number> | Updates data based on the specified **RdbPredicates** object. This API uses a promise to return the result.
the number of rows updated.
- **values**: data to update, which is stored in **ValuesBucket**.
- **predicates**: conditions for updating data.|
- **Deleting Data**
@@ -50,11 +52,10 @@ The RDB provides APIs for inserting, deleting, updating, and querying data in th
**Table 4** API for deleting data
- | Class | API | Description |
- | -------- | ------------------------------------------------------ | ------------------------------------------------------------ |
- | RdbStore | delete(predicates:RdbPredicates):Promise<number> | Deletes data from the RDB store based on the specified **RdbPredicates** object. This API uses a promise to return the result.
- **predicates**: conditions for deleting data.
Return value: number of rows updated. |
-
-
+
+ | Class | API | Description |
+ | -------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
+ | RdbStore | delete(predicates: RdbPredicates): Promise<number> | Deletes data from the RDB store based on the specified **RdbPredicates** object. This API uses a promise to return
the number of rows updated.
- **predicates**: conditions for deleting data.|
- **Querying Data**
@@ -65,10 +66,11 @@ The RDB provides APIs for inserting, deleting, updating, and querying data in th
**Table 5** APIs for querying data
+
| Class | API | Description |
| -------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
- | RdbStore | query(predicates:RdbPredicates,columns?:Array<string>):Promise<ResultSet> | Queries data from the RDB store based on specified conditions. This API uses a promise to return the result.
- **predicates**: conditions for querying data.
- **columns**: columns to query. If this parameter is not specified, the query applies to all columns.|
- | RdbStore | querySql(sql:string,bindArgs?:Array<ValueType>):Promise<ResultSet> | Queries data using the specified SQL statement. This API uses a promise to return the result.
- **sql**: SQL statement.
- **bindArgs**: arguments in the SQL statement.|
+ | RdbStore | query(predicates: RdbPredicates, columns?: Array<string>): Promise<ResultSet> | Queries data from the RDB store based on specified conditions. This API uses a promise to return the result.
- **predicates**: conditions for querying data.
- **columns**: columns to query. If this parameter is not specified, the query applies to all columns.|
+ | RdbStore | querySql(sql: string, bindArgs?: Array<ValueType>): Promise<ResultSet> | Queries data using the specified SQL statement. This API uses a promise to return the result.
- **sql**: SQL statement.
- **bindArgs**: arguments in the SQL statement.|
| RdbStore | remoteQuery(device: string, table: string, predicates: RdbPredicates, columns: Array<string>): Promise<ResultSet> | Queries data from the database of a remote device based on specified conditions. This API uses a promise to return the result.
- **device**: network ID of the remote device.
- **table**: name of the table to be queried.
- **predicates**: **RdbPredicates** that specifies the query condition.
- **columns**: columns to query. If this parameter is not specified, the query applies to all columns.|
### Using Predicates
@@ -81,11 +83,11 @@ The following lists common predicates. For more information about predicates, se
| Class | API | Description |
| ------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
-| RdbPredicates | equalTo(field:string,value:ValueType):RdbPredicates | Sets an **RdbPredicates** to match the field with data type **ValueType** and value equal to the specified value.
- **field**: column name in the database table.
- **value**: value to match the **RdbPredicates**.
- **RdbPredicates**: **RdbPredicates** object that matches the specified field.|
-| RdbPredicates | notEqualTo(field:string,value:ValueType):RdbPredicates | Sets an **RdbPredicates** to match the field with data type **ValueType** and value not equal to the specified value.
- **field**: column name in the database table.
- **value**: value to match the **RdbPredicates**.
- **RdbPredicates**: **RdbPredicates** object that matches the specified field.|
-| RdbPredicates | or():RdbPredicates | Adds the OR condition to the **RdbPredicates**.
- **RdbPredicates**: **RdbPredicates** with the OR condition.|
-| RdbPredicates | and():RdbPredicates | Adds the AND condition to the **RdbPredicates**.
- **RdbPredicates**: **RdbPredicates** with the AND condition.|
-| RdbPredicates | contains(field:string,value:string):RdbPredicates | Sets an **RdbPredicates** to match a string containing the specified value.
- **field**: column name in the database table.
- **value**: value to match the **RdbPredicates**.
- **RdbPredicates**: **RdbPredicates** object that matches the specified field.|
+| RdbPredicates | equalTo(field: string, value: ValueType): RdbPredicates | Sets an **RdbPredicates** to match the field with data type **ValueType** and value equal to the specified value.
- **field**: column name in the database table.
- **value**: value to match the **RdbPredicates**.
- **RdbPredicates**: **RdbPredicates** object that matches the specified field.|
+| RdbPredicates | notEqualTo(field: string, value: ValueType): RdbPredicates | Sets an **RdbPredicates** to match the field with data type **ValueType** and value not equal to the specified value.
- **field**: column name in the database table.
- **value**: value to match the **RdbPredicates**.
- **RdbPredicates**: **RdbPredicates** object that matches the specified field.|
+| RdbPredicates | or(): RdbPredicates | Adds the OR condition to the **RdbPredicates**.
- **RdbPredicates**: **RdbPredicates** with the OR condition.|
+| RdbPredicates | and(): RdbPredicates | Adds the AND condition to the **RdbPredicates**.
- **RdbPredicates**: **RdbPredicates** with the AND condition.|
+| RdbPredicates | contains(field: string, value: string): RdbPredicates | Sets an **RdbPredicates** to match a string containing the specified value.
- **field**: column name in the database table.
- **value**: value to match the **RdbPredicates**.
- **RdbPredicates**: **RdbPredicates** object that matches the specified field.|
### Using the Result Set
@@ -101,12 +103,12 @@ For details about how to use result set APIs, see [Result Set](../reference/apis
| Class | API | Description |
| --------- | ---------------------------------------------------- | ------------------------------------------ |
-| ResultSet | goToFirstRow():boolean | Moves to the first row of the result set. |
-| ResultSet | getString(columnIndex:number):string | Obtains the value in the form of a string based on the specified column and current row. |
-| ResultSet | getBlob(columnIndex:number):Uint8Array | Obtains the value in the form of a byte array based on the specified column and the current row.|
-| ResultSet | getDouble(columnIndex:number):number | Obtains the value in the form of double based on the specified column and current row. |
-| ResultSet | getLong(columnIndex:number):number | Obtains the value in the form of a long integer based on the specified column and current row. |
-| ResultSet | close():void | Closes the result set. |
+| ResultSet | goToFirstRow(): boolean | Moves to the first row of the result set. |
+| ResultSet | getString(columnIndex: number): string | Obtains the value in the form of a string based on the specified column and current row. |
+| ResultSet | getBlob(columnIndex: number): Uint8Array | Obtains the value in the form of a byte array based on the specified column and the current row.|
+| ResultSet | getDouble(columnIndex: number): number | Obtains the value in the form of double based on the specified column and current row. |
+| ResultSet | getLong(columnIndex: number): number | Obtains the value in the form of a long integer based on the specified column and current row. |
+| ResultSet | close(): void | Closes the result set. |
@@ -164,7 +166,7 @@ You can obtain the distributed table name for a remote device based on the local
| Class | API | Description |
| -------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
-| RdbStore | backup(destName:string): Promise<void> | Backs up an RDB store. This API uses a promise to return the result.
- **destName**: name of the RDB backup file.|
+| RdbStore | backup(destName: string): Promise<void> | Backs up an RDB store. This API uses a promise to return the result.
- **destName**: name of the RDB backup file.|
**Restoring an RDB Store**
@@ -172,7 +174,7 @@ You can obtain the distributed table name for a remote device based on the local
| Class | API | Description |
| -------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
-| RdbStore | restore(srcName:string): Promise<void> | Restores an RDB store from a backup file. This API uses a promise to return the result.
- **srcName**: name of the backup file used to restore the RDB store.|
+| RdbStore | restore(srcName: string): Promise<void> | Restores an RDB store from a backup file. This API uses a promise to return the result.
- **srcName**: name of the backup file used to restore the RDB store.|
**Transaction**
@@ -180,9 +182,9 @@ Table 15 Transaction APIs
| Class | API | Description |
| -------- | ----------------------- | --------------------------------- |
-| RdbStore | beginTransaction():void | Starts the transaction before executing SQL statements.|
-| RdbStore | commit():void | Commits the executed SQL statements. |
-| RdbStore | rollBack():void | Rolls back the SQL statements that have been executed. |
+| RdbStore | beginTransaction(): void | Starts the transaction before executing SQL statements.|
+| RdbStore | commit(): void | Commits the executed SQL statements. |
+| RdbStore | rollBack(): void | Rolls back the SQL statements that have been executed. |
## How to Develop
@@ -200,10 +202,10 @@ Table 15 Transaction APIs
import data_rdb from '@ohos.data.rdb'
const CREATE_TABLE_TEST = "CREATE TABLE IF NOT EXISTS test (" + "id INTEGER PRIMARY KEY AUTOINCREMENT, " + "name TEXT NOT NULL, " + "age INTEGER, " + "salary REAL, " + "blobType BLOB)";
- const STORE_CONFIG = {name: "rdbstore.db"}
+ const STORE_CONFIG = { name: "rdbstore.db" }
data_rdb.getRdbStore(this.context, STORE_CONFIG, 1, function (err, rdbStore) {
- rdbStore.executeSql(CREATE_TABLE_TEST)
- console.info('create table done.')
+ rdbStore.executeSql(CREATE_TABLE_TEST)
+ console.info('create table done.')
})
```
@@ -217,7 +219,7 @@ Table 15 Transaction APIs
```js
var u8 = new Uint8Array([1, 2, 3])
- const valueBucket = {"name": "Tom", "age": 18, "salary": 100.5, "blobType": u8}
+ const valueBucket = { "name": "Tom", "age": 18, "salary": 100.5, "blobType": u8 }
let insertPromise = rdbStore.insert("test", valueBucket)
```
@@ -316,6 +318,7 @@ Table 15 Transaction APIs
console.log('device=' + device[i] + 'data changed')
}
}
+
try {
rdbStore.on('dataChange', data_rdb.SubscribeType.SUBSCRIBE_TYPE_REMOTE, storeObserver)
} catch (err) {
@@ -366,9 +369,7 @@ Table 15 Transaction APIs
(1) Back up the current RDB store.
- (2) Restore the RDB store using the backup file.
-
- The sample code is as follows:
+ The sample code is as follows:
```js
let promiseBackup = rdbStore.backup("dbBackup.db")
@@ -378,6 +379,10 @@ Table 15 Transaction APIs
console.info('Backup failed, err: ' + err)
})
```
+ (2) Restore the RDB store using the backup file.
+
+ The sample code is as follows:
+
```js
let promiseRestore = rdbStore.restore("dbBackup.db")
promiseRestore.then(() => {
@@ -386,4 +391,3 @@ Table 15 Transaction APIs
console.info('Restore failed, err: ' + err)
})
```
-
diff --git a/en/application-dev/device-usage-statistics/device-usage-statistics-overview.md b/en/application-dev/device-usage-statistics/device-usage-statistics-overview.md
index fc2a79e0990457a483c7dc75d3ab1fd88c55f126..69fca5fb8177eddc65ddfc0ffade70350446a8a1 100644
--- a/en/application-dev/device-usage-statistics/device-usage-statistics-overview.md
+++ b/en/application-dev/device-usage-statistics/device-usage-statistics-overview.md
@@ -7,21 +7,21 @@ With device usage statistics APIs, you can have a better understanding of the ap
Currently you can have access to statistics on the application usage, and the notification and system usage statistics feature will be available for use in later versions.
- **The application usage statistics is updated**:
-1. Every 30 minutes
-2. Upon system time change
-3. Upon start of a new day
+ 1. Every 30 minutes
+ 2. Upon system time change
+ 3. Upon start of a new day
- **The application usage statistics can include the following**:
-1. Events of all applications based on the specified start time and end time
-2. Application usage duration statistics based on the specified start time and end time
-3. Events of the current application based on the specified start time and end time
-4. Application usage duration statistics in the specified time frame at the specified interval (daily, weekly, monthly, or annually)
-5. Priority group of the current invoker application
-6. Whether a specific application is in the idle state
-7. Number of FA usage records specified by **maxNum**, sorted by time (most recent first). If **maxNum** is not specified, the default value **1000** will be used.
-8. Number of notifications from applications based on the specified start time and end time
-9. Statistics about system events (hibernation, wakeup, unlocking, and screen locking) that occur between the specified start time and end time
-10. Priority group of the invoker application or a specified application
+ 1. Events of all applications based on the specified start time and end time
+ 2. Application usage duration statistics based on the specified start time and end time
+ 3. Events of the current application based on the specified start time and end time
+ 4. Application usage duration statistics in the specified time frame at the specified interval (daily, weekly, monthly, or annually)
+ 5. Priority group of the current invoker application
+ 6. Whether a specific application is in the idle state
+ 7. Number of FA usage records specified by **maxNum**, sorted by time (most recent first). If **maxNum** is not specified, the default value **1000** will be used.
+ 8. Number of notifications from applications based on the specified start time and end time
+ 9. Statistics about system events (hibernation, wakeup, unlocking, and screen locking) that occur between the specified start time and end time
+ 10. Priority group of the invoker application or a specified application
- **The setters can be used to:**
@@ -35,6 +35,6 @@ Currently you can have access to statistics on the application usage, and the no
Deregister the callback for application group changes.
-### Required Permissions
+## Required Permissions
- Before calling the following system APIs, you need to apply for the **ohos.permission.BUNDLE_ACTIVE_INFO** permission: **queryBundleActiveStates**, **queryBundleStateInfos**, **queryBundleStateInfoByInterval**, **queryBundleActiveEventStates**, **queryAppNotificationNumber**, **queryAppUsagePriorityGroup(bundleName?)**, **setBundleGroup**, **registerGroupCallBack**, and **unRegisterGroupCallBack**.
- This permission is not required for calling third-party APIs: **queryCurrentBundleActiveStates**, **queryAppUsagePriorityGroup()**, and **isIdleState**.
diff --git a/en/application-dev/device/vibrator-guidelines.md b/en/application-dev/device/vibrator-guidelines.md
index 4f49e7996188a7bc668e23fc2a21a1a29ec6e562..97f9f5933b55c9a1b57b5555db5812b6576a262a 100644
--- a/en/application-dev/device/vibrator-guidelines.md
+++ b/en/application-dev/device/vibrator-guidelines.md
@@ -16,7 +16,7 @@ For details about the APIs, see [Vibrator](../reference/apis/js-apis-vibrator.md
| ohos.vibrator | vibrate(duration: number, callback?: AsyncCallback<void>): void | Triggers vibration with the specified duration. This API uses a callback to return the result. |
| ohos.vibrator | vibrate(effectId: EffectId): Promise<void> | Triggers vibration with the specified effect. This API uses a promise to return the result. |
| ohos.vibrator | vibrate(effectId: EffectId, callback?: AsyncCallback<void>): void | Triggers vibration with the specified effect. This API uses a callback to return the result.|
-| ohos.vibrator | stop(stopMode: VibratorStopMode): Promise<void> | Stops vibration. This API uses a promise to return the result. |
+| ohos.vibrator | stop(stopMode: VibratorStopMode): Promise<void>| Stops vibration. This API uses a promise to return the result. |
| ohos.vibrator | stop(stopMode: VibratorStopMode, callback?: AsyncCallback<void>): void | Stops vibration. This API uses a callback to return the result. |
@@ -55,7 +55,7 @@ For details about the APIs, see [Vibrator](../reference/apis/js-apis-vibrator.md
],
"when": "inuse"
}
- },
+ }
]
```
diff --git a/en/application-dev/device/vibrator-overview.md b/en/application-dev/device/vibrator-overview.md
index 889f6b823cc0bbff99cd9bc9cbb2dde641766420..62e0d0d7b99e8bc4eaf5c38b4fc3006a19264df2 100644
--- a/en/application-dev/device/vibrator-overview.md
+++ b/en/application-dev/device/vibrator-overview.md
@@ -23,4 +23,4 @@ The vibrator is a Misc device that consists of four modules: Vibrator API, Vibra
## Constraints
-When using a vibrator, you must declare the **ohos.permission.VIBRATE** permission before you can control the vibration effect. The sensitivity level of this permission is **system_grant**.
+When using a vibrator, you must declare the **ohos.permission.VIBRATE** permission before you can control the vibration effect. The authorization mode of this permission is **system_grant**.
diff --git a/en/application-dev/faqs/Readme-EN.md b/en/application-dev/faqs/Readme-EN.md
new file mode 100644
index 0000000000000000000000000000000000000000..b87a565b6da485ea85add166accd20f25cbb686c
--- /dev/null
+++ b/en/application-dev/faqs/Readme-EN.md
@@ -0,0 +1,13 @@
+# FAQs
+
+- [Ability Framework Development](faqs-ability.md)
+- [ArkUI (JavaScript) Development](faqs-ui-js.md)
+- [ArkUI (eTS) Development](faqs-ui-ets.md)
+- [Graphics and Image Development](faqs-graphics.md)
+- [File Management Development](faqs-file-management.md)
+- [Data Management Development](faqs-data-management.md)
+- [Device Management Development](faqs-device-management.md)
+- [Native API Usage](faqs-native.md)
+- [Usage of Third- and Fourth-Party Libraries](faqs-third-party-library.md)
+- [Development Board](faqs-development-board.md)
+
diff --git a/en/application-dev/faqs/faqs-ability.md b/en/application-dev/faqs/faqs-ability.md
new file mode 100644
index 0000000000000000000000000000000000000000..0cabbba71815d043e29f9c840c8ce7589af76dad
--- /dev/null
+++ b/en/application-dev/faqs/faqs-ability.md
@@ -0,0 +1,60 @@
+# Ability Framework Development
+
+## Is a guide similar to the Data ability development in the FA model available for the stage model?
+
+Applicable to: OpenHarmony SDK 3.2.3.5, stage model of API version 9
+
+A guide is available for the **DataShareExtensionAbility** class in the stage model, which provides APIs for sharing data with other applications and managing the data.
+
+Reference: [DataShare Development](../database/database-datashare-guidelines.md)
+
+## What should I do if the UI does not respond when an ability is started?
+
+Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9
+
+1. If the ability is started using **startAbility**, check whether the **abilityName** field in **want** uses the bundle name as the prefix. If yes, delete the bundle name.
+
+2. Make sure the ability's home page file configured by **onWindowStageCreate** in the **MainAbility.ts** file is defined in the **main_pages.json** file.
+
+3. You are advised to use the SDK and OpenHarmony SDK versions released on the same day.
+
+Reference: [Release Testing Version](https://gitee.com/openharmony-sig/oh-inner-release-management/blob/master/Release-Testing-Version.md)
+
+## How do I prevent "this" in a method from changing to "undefined" when the method is called?
+
+Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9
+
+Method 1: Add **.bind(this)** when calling the method.
+
+Method 2: Use the arrow function.
+
+## What should I do when the message "must have required property 'startWindowIcon'" is displayed?
+
+Applicable to: OpenHarmony SDK 3.2.3.5, stage model of API version 9
+
+Configure the **startWindowIcon** attribute under **abilities** in the **module.json5** file.
+
+Reference: [Application Package Structure Configuration File](../quick-start/stage-structure.md)
+
+ Example:
+
+```
+{
+ "module": {
+ // Do something.
+ "abilities": [{
+ // Do something.
+ "startWindowIcon": "$media:space",
+ "startWindowBackground": "$color:white",
+ }]
+ }
+}
+```
+
+## How do I obtain a notification when the device orientation changes?
+
+Applicable to: OpenHarmony SDK 3.2.3.5, stage model of API version 9
+
+Implement the **onConfigurationUpdated** callback in the **Ability** class. The callback is triggered when the system language, color mode, or display parameters (such as the orientation and density) change.
+
+Reference: [Ability Development](../ability/stage-ability.md)
diff --git a/en/application-dev/faqs/faqs-data-management.md b/en/application-dev/faqs/faqs-data-management.md
new file mode 100644
index 0000000000000000000000000000000000000000..839514879b8198273bc86680614b6b2054f662e2
--- /dev/null
+++ b/en/application-dev/faqs/faqs-data-management.md
@@ -0,0 +1,24 @@
+# Device Management Development
+
+
+
+## How Do I Save PixelMap data to a database?
+
+Applicable to: OpenHarmony SDK 3.2.3.5
+
+You can convert a **PixelMap** into a **ArrayBuffer** and save the **ArrayBuffer** to your database.
+
+Reference: [readPixelsToBuffer](../reference/apis/js-apis-image.md#readpixelstobuffer7-1)
+
+## How Do I Obtain RDB Store Files?
+
+Applicable to: OpenHarmony SDK 3.2.3.5, stage model of API version 9
+
+Run the hdc_std command to copy the .db, .db-shm, and .db-wal files from **/data/app/el2/100/database/Bundle name/entry/db/**, and then use the SQLite tool to open the files.
+
+Example:
+
+
+```
+ hdc_std file recv /data/app/el2/100/database/com.xxxx.xxxx/entry/db/test.db ./test.db
+```
diff --git a/en/application-dev/faqs/faqs-development-board.md b/en/application-dev/faqs/faqs-development-board.md
new file mode 100644
index 0000000000000000000000000000000000000000..4766d4f5271dec2e5ec937477cf1ce1b7946eef6
--- /dev/null
+++ b/en/application-dev/faqs/faqs-development-board.md
@@ -0,0 +1,52 @@
+# Development Board
+
+
+
+## How do I take screenshots on a development board?
+
+Applicable to: OpenHarmony SDK 3.2.2.5, stage model of API version 9
+
+- Method 1: Click the screenshot button in the Control Panel from the development board UI. The screenshot is displayed in Gallery.
+
+- Method 2: Run the screenshot script. Connect to the development board to a computer running Windows. Create a text file on the computer, copy the following script content to the file, change the file name extension to **.bat** (the HDC environment variables must be configured in advance), and click **Run**. The screenshot is saved to the same directory as the **.bat** script file.
+ Example:
+
+
+ ```
+ set filepath=/data/%date:~0,4%%date:~5,2%%date:~8,2%%time:~1,1%%time:~3,2%%time:~6,2%.png
+ echo %filepath%
+ : pause
+ hdc_std shell snapshot_display -f %filepath%
+ : pause
+ hdc_std file recv %filepath% .
+ : pause
+ ```
+
+## How do I adjust Previewer in DevEco Studio so that the preview looks the same as what's displayed on a real RK3568 development board?
+
+Applicable to: DevEco Studio 3.0.0.991
+
+1. Create a profile in Previewer.
+
+ 
+2. Set the profile parameters as follows:
+
+ Device type : default
+
+ Resolution: 720\*1280
+
+ DPI: 240
+
+## What should I do if Device Manager incorrectly identifies a development board as FT232R USB UART even when the development board already has a driver installed?
+
+Possible cause: The USB serial driver of the development version is not installed.
+
+Solution: Search for **FT232R USB UART**, and download and install the driver.
+
+## How do I complete authentication when logging in to the development board?
+
+Applicable to: OpenHarmony SDK 3.2.2.5
+
+When connecting to the network that requires authentication, open any web page in the browser to access the authentication page.
+
+If there is no browser on the development board, you can install the [sample browser application](https://gitee.com/openharmony/app_samples/tree/master/device/Browser).
diff --git a/en/application-dev/faqs/faqs-device-management.md b/en/application-dev/faqs/faqs-device-management.md
new file mode 100644
index 0000000000000000000000000000000000000000..5bb748f758a4636fb40ae5d7fb741eccfb5306fe
--- /dev/null
+++ b/en/application-dev/faqs/faqs-device-management.md
@@ -0,0 +1,24 @@
+# Device Management Development
+
+
+
+## How do I obtain the DPI of a device?
+
+Applicable to: OpenHarmony SDK 3.2.2.5, stage model of API version 9
+
+Import the **@ohos.display** module and call the **getDefaultDisplay** API.
+
+Example:
+
+
+```
+import display from '@ohos.display';
+display.getDefaultDisplay((err, data) => {
+ if (err.code) {
+ console.error('Test Failed to obtain the default display object. Code: ' + JSON.stringify(err));
+ return;
+ }
+ console.info('Test Succeeded in obtaining the default display object. Data:' + JSON.stringify(data));
+ console.info('Test densityDPI:' + JSON.stringify(data.densityDPI));
+});https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-device-info.md)
+```
diff --git a/en/application-dev/faqs/faqs-file-management.md b/en/application-dev/faqs/faqs-file-management.md
new file mode 100644
index 0000000000000000000000000000000000000000..1e3740047768d5d5fefa1420659c64da403ad587
--- /dev/null
+++ b/en/application-dev/faqs/faqs-file-management.md
@@ -0,0 +1,36 @@
+# File Management Development
+
+
+
+## What If There is No Return Value or Error Captured After getAlbums Is Called?
+
+Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9
+
+The **ohos.permission.READ_MEDIA** permission is required for calling **getAlbums**, and this permission needs user authorization. For details, see OpenHarmony [Application Permission List](../security/permission-list.md).
+
+1. Configure the required permission in the **module.json5** file.
+
+ ```
+ "requestPermissions": [
+ {
+ "name": "ohos.permission.READ_MEDIA"
+ }
+ ]
+ ```
+
+2. Add the code for user authorization before the **MainAbility.ts -> onWindowStageCreate** page is loaded.
+
+ ```
+ private requestPermissions() {
+ let permissionList: Array = [
+ "ohos.permission.READ_MEDIA"
+ ];
+ this.context.requestPermissionsFromUser(permissionList)
+ .then(data => {
+ console.info(`request permission data result = ${data.authResults}`)
+ })
+ .catch(err => {
+ console.error(`fail to request permission error:${err}`)
+ })
+ }
+ ```
diff --git a/en/application-dev/faqs/faqs-graphics.md b/en/application-dev/faqs/faqs-graphics.md
new file mode 100644
index 0000000000000000000000000000000000000000..c4e151559b547b2cdb4f8d7cb19b35318203674a
--- /dev/null
+++ b/en/application-dev/faqs/faqs-graphics.md
@@ -0,0 +1,13 @@
+# Graphics and Image Development
+
+## Why do the isStatusBarLightIcon and isNavigationBarLightIcon attributes not take effect when window.setSystemBarProperties() is called?
+
+Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9
+
+In effect, the **isStatusBarLightIcon** and **isNavigationBarLightIcon** attributes turn the font white when set to **true**. If **statusBarContentColor** is also set in **window.setSystemBarProperties()**, the **isStatusBarLightIcon** attribute does not take effect. Similarly, if **navigationBarContentColor** is set, the **isNavigationBarLightIcon** attribute does not take effect.
+
+## How do I set the style of the system bar?
+
+Applicable to: OpenHarmony SDK 3.2.3.5, stage model of API version 9
+
+Import the **\@ohos.window** module, and call **window.setSystemBarProperties()**.
diff --git a/en/application-dev/faqs/faqs-native.md b/en/application-dev/faqs/faqs-native.md
new file mode 100644
index 0000000000000000000000000000000000000000..da00895e4a5b5a532e67f9f709dd84c25abe3205
--- /dev/null
+++ b/en/application-dev/faqs/faqs-native.md
@@ -0,0 +1,55 @@
+# Native API Usage
+
+## When a native HAP is running, the error message "Obj is not a valid object" is displayed for the imported namespace. What should I do?
+
+Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9
+
+Check the **abiFilters** parameter value in the **build-profile.json5** file in the root directory of the module (not the root directory of the project). If the device is 32-bit, the value must be **armeabi-v7a**. If the device is 64-bit, the value must be **arm64-v8a**.
+
+## How do I obtain the value of version in the package.json file of a module in the C++ code developed using native APIs?
+
+Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9
+
+1. In the script file **hvigorfile.js** of Hvigor, use **subModule.getPackageJsonPath** to obtain the location of the **package.json** file in the module.
+
+2. Use Node.js to read the **version** field in the **package.json** file and write the value to the **buildOption.cppFlags** field in the **build-profile.json5** file.
+
+Example
+
+
+```
+// Module-level hvigorfile.js
+const subModule = require('@ohos/hvigor')(__filename)
+
+const fs = require("fs-extra")
+const path = require("path")
+
+const packageJsonPath = subModule.getPackageJsonPath()
+const buildProfilePath = path.resolve(packageJsonPath, '../build-profile.json5')
+const packageJsonData = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'))
+let buildProfileData = fs.readFileSync(buildProfilePath, 'utf8')
+buildProfileData = buildProfileData.replace(/\"cppFlags\"\:(.*)\,/, `"cppFlags": "-D NWEBEX_VERSION=${packageJsonData.version}",`)
+fs.writeFileSync(buildProfilePath, buildProfileData, 'utf8')
+
+const ohosPlugin = require('@ohos/hvigor-ohos-plugin').hapTasks(subModule) // The plug-in executes the C++ build task and reads the build-profile.json5 file.
+
+module.exports = {
+ ohos: ohosPlugin
+}
+```
+
+
+```
+// Read the hello.cpp file.
+#define _NWEBEX_VERSION(v) #v
+#define _NWEBEX_VER2STR(v) _NWEBEX_VERSION(v)
+
+static napi_value Add(napi_env env, napi_callback_info info)
+{
+
+ napi_value fixed_version_value = nullptr;
+ napi_create_string_utf8(env, _NWEBEX_VER2STR(NWEBEX_VERSION), NAPI_AUTO_LENGTH, &fixed_version_value);
+
+ return fixed_version_value;
+}
+```
diff --git a/en/application-dev/faqs/faqs-third-party-library.md b/en/application-dev/faqs/faqs-third-party-library.md
new file mode 100644
index 0000000000000000000000000000000000000000..323269c5e0a4d8c84e9adbb39c4184bba9a00b5e
--- /dev/null
+++ b/en/application-dev/faqs/faqs-third-party-library.md
@@ -0,0 +1,7 @@
+# Usage of Third- and Fourth-Party Libraries
+
+## What does the following error message mean : "Stage model module... does not support including OpenHarmony npm packages or modules in FA model. OpenHarmony build tasks will not be executed, and OpenHarmony resources will not be packed."
+
+Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9
+
+The third- and fourth-party libraries are not yet compatible with the stage model of API version 9 and cannot be used.
diff --git a/en/application-dev/faqs/faqs-ui-ets.md b/en/application-dev/faqs/faqs-ui-ets.md
new file mode 100644
index 0000000000000000000000000000000000000000..fd21421cd95edc2bc838b8401724fae10448d9fd
--- /dev/null
+++ b/en/application-dev/faqs/faqs-ui-ets.md
@@ -0,0 +1,282 @@
+# ArkUI (eTS) Development
+
+
+
+## What are the restrictions on using generator functions in TypeScript?
+
+Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9
+
+Below are the restrictions on using generator functions in TypeScript:
+
+- Expressions can be used only in character strings (in the ${expression} format), **if** conditions, **ForEach** parameters, and component parameters.
+
+- No expressions should cause any application state variables (including **\@State**, **\@Link**, and **\@Prop**) to change. Otherwise, undefined and potentially unstable framework behavior may occur.
+
+- The generator function cannot contain local variables.
+
+None of the above restrictions apply to anonymous function implementations of event handlers (such as **onClick**).
+
+Negative example:
+
+
+```
+build() {
+ let a: number = 1 // invalid: variable declaration not allowed
+ Column() {
+ Text('Hello ${this.myName.toUpperCase()}') // ok.
+ ForEach(this.arr.reverse(), ..., ...) // invalid: Array.reverse modifies the @State array varible in place
+ }
+ buildSpecial() // invalid: no function calls
+ Text(this.calcTextValue()) // this function call is ok.
+}
+```
+
+## How do I use router to implement page redirection in the stage model?
+
+Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9
+
+To implement page redirection through **router**, add all redirected-to pages to the pages list in the **main_pages.json** file.
+
+Page routing APIs in **router** can be invoked only after page rendering is complete. Do not call these APIs in **onInit** or **onReady** when the page is still in the rendering phase.
+
+## Will a page pushed into the stack through router.push be reclaimed?
+
+Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9
+
+After being pushed to the stack through **router.push**, a page can be reclaimed only when it is popped from the stack through **router.back**.
+
+## How do I dynamically replace the %s placeholder in a resource file?
+
+Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9
+
+In an application, you can replace the %s placeholder by using the second parameter in `$r('app.string.xx')`, which is used to reference application resources.
+
+Example:
+
+```
+build() {
+ //do something
+ // The second parameter indicates the referenced string resource, which can be used to replace the %s placeholder.
+ Text($r('app.string.entry_desc','aaa'))
+ .fontSize(100)
+ .fontColor(Color.Black)
+ //do something
+}
+```
+
+## How do I read an XML file in Resource and convert data in it to the string type?
+
+Applicable to: OpenHarmony SDK 3.2.2.5, stage model of API version 9
+
+1. Obtain data in Uint8Array format by calling the **RawFile** API of **resourceManager**.
+
+2. Convert data in Uint8Array format to the string type by calling the **String.fromCharCode** API.
+
+Reference: [Resource Management](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-resource-manager.md)
+
+Example:
+
+
+```
+resourceManager.getRawFile(path, (error, value) => {
+ if (error != null) {
+ console.log("error is " + error);
+ } else {
+ let rawFile = value;
+ let xml = String.fromCharCode.apply(null, rawFile)
+ }
+});
+```
+
+## How do I convert a Resource object to the string type?
+
+Applicable to: OpenHarmony SDK 3.2.3.5, stage model of API version 9
+
+Use the **resourceManager.getString()** API of the **\@ohos.resourceManager** module.
+
+Reference: [Resource Management](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-resource-manager.md#getstring)
+
+## What should I do if the global static variables of a class do not work?
+
+Applicable to: OpenHarmony SDK 3.2.3.5, stage model of API version 9
+
+Objects imported to abilities and pages are packaged into two different closures, that is, two global objects. In this case, a static variable referenced by the abilities is not the same object as that referenced by the pages. Therefore, global variables cannot be defined by defining static variables in the class. You are advised to use AppStorage to manage global variables.
+
+Reference: [AppStorage](https://docs.openharmony.cn/pages/v3.2Beta/en/application-dev/ui/ts-application-states-appstorage.md/)
+
+## How do I obtain resources in the stage model?
+
+Applicable to: OpenHarmony SDK 3.2.3.5, stage model of API version 9
+
+The stage model allows an application to obtain a **ResourceManager** object based on **context** and call its resource management APIs without first importing the required bundle. This method, however, is not applicable to the FA model.
+
+Example:
+
+
+```
+const context = getContext(this) as any
+context
+ .resourceManager
+ .getString($r('app.string.entry_desc').id)
+ .then(value => {
+ this.message = value.toString()
+})
+```
+
+## How do I position a container component to the bottom of the screen?
+
+Applicable to: OpenHarmony SDK 3.2.3.5, stage model of API version 9
+
+Create a **** component, and set the target container at the bottom of the **** component.
+
+Example:
+
+```
+build() {
+ Stack({alignContent : Alignment.Bottom}) {
+ // The container is at the bottom.
+ Stack() {
+ Column()
+ .width('100%')
+ .height('100%')
+ .backgroundColor(Color.Yellow)
+ }
+ .width('100%')
+ .height('10%')
+ }
+ .width('100%')
+ .height('100%')
+ .backgroundColor('rgba(255,255,255, 0)')
+}
+```
+
+## Can CustomDialog be used in TypeScript files?
+
+Applicable to: OpenHarmony SDK 3.2.2.5, stage model of API version 9
+
+No. Currently, **CustomDialog** can be used only on eTS pages.
+
+Reference: [Custom Dialog Box](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md)
+
+## How do I transfer variables in CustomDialog to variables on pages?
+
+Applicable to: OpenHarmony SDK 3.2.2.5, stage model of API version 9
+
+Use a custom callback so that when the confirm button in the custom dialog box is clicked, the value of **data** is transferred from the dialog box to the current page.
+
+Example:
+
+
+```
+// CustomDialog component
+@CustomDialog
+struct MyDialog {
+ controller: CustomDialogController
+ title: string
+ data: string
+ cancel: () => void
+ confirm: (data: string) => void
+ Button('confirm')
+ .onClick(() => {
+ this.controller.close()
+ this.data = 'test'
+ this.confirm(this.data)
+ }).backgroundColor(0xffffff).fontColor(Color.Red)
+// Page
+@Entry
+@Component
+struct DialogTest {
+ dialogController: CustomDialogController = new CustomDialogController({
+ builder: MyDialog({ title:'Custom Title',cancel: this.onCancel,
+ confirm: this.onAccept.bind(this)}), // Bind the custom callback to the button.
+ cancel: this.existApp,
+ autoCancel: true
+ })
+ onAccept(data:string) {
+ console.info('Callback when the second button is clicked ' + data)
+ }
+}
+```
+
+## What should I do if the \ component cannot be dragged to the bottom after it has a \ component added?
+
+Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9
+
+The **\** component is a scrollable container. By default, it taks up the entire screen height. When any component with a fixed height takes up part of the screen height, you need to explicitly specify **layoutWeight(1)** for the parent container of the **\** component to take up the remaining height instead of the entire screen height.
+
+## How do I center child components in a grid container?
+
+Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9
+
+By default, child components in a **\** are horizontally aligned to the left. To center them, perform the following steps:
+
+Nest a **\** component and set it to **justifyContent(FlexAlign.Center)**. For details, see [Grid Layout](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/ui/ui-ts-layout-grid-container.md).
+
+ Example:
+
+```
+GridContainer({ sizeType: SizeType.SM, columns: 12 }) {
+ Row() {
+ Text('1')
+ .useSizeType({
+ sm: { span: 4, offset: 0 },
+ })
+ .backgroundColor(0x46F2B4)
+ }.justifyContent(FlexAlign.Center) // Center child components.
+}
+```
+
+## How do I obtain the height of the status bar and navigation bar?
+
+Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9
+
+Before the window content is loaded, enable listening for the **systemAvoidAreaChange** event.
+
+Example:
+
+```
+// MainAbility.ts
+import window from '@ohos.window';
+
+/**
+ * Set the immersive window and obtain the height of the status bar and navigation bar.
+ * @param mainWindow Indicates the main window.
+ */
+async function enterImmersion(mainWindow: window.Window) {
+ mainWindow.on("systemAvoidAreaChange", (area: window.AvoidArea) => {
+ AppStorage.SetOrCreate("topHeight", area.topRect.height);
+ AppStorage.SetOrCreate("bottomHeight", area.bottomRect.height);
+ })
+ await mainWindow.setFullScreen(true)
+ await mainWindow.setSystemBarEnable(["status", "navigation"])
+ await mainWindow.setSystemBarProperties({
+ navigationBarColor: "#00000000",
+ statusBarColor: "#00000000",
+ navigationBarContentColor: "#FF0000",
+ statusBarContentColor: "#FF0000"
+ })
+}
+export default class MainAbility extends Ability {
+ // do something
+ async onWindowStageCreate(windowStage: window.WindowStage) {
+ let mainWindow = await windowStage.getMainWindow()
+ await enterImmersion(mainWindow)
+ windowStage.loadContent('pages/index')
+ }
+ // do something
+}
+```
+
+## How do I execute JavaScript functions in the \ component in eTS code?
+
+Applicable to: OpenHarmony SDK 3.2.3.5, stage model of API version 9
+
+Call the **runJavaScript** API in the **WebController** to asynchronously execute JavaScript scripts. This API uses a callback to return the execution result. Note: **runJavaScript** can only be called after **loadUrl** has been completed. For example, it can be called in **onPageEnd**.
+
+Reference: [Web](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/arkui-ts/ts-basic-components-web.md)
+
+## How do I fix misidentification of the pan gesture where container nesting is involved?
+
+Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9
+
+Set the **distance** attribute to **1** for the gesture. By default, this attribute is set to **5**.
diff --git a/en/application-dev/faqs/faqs-ui-js.md b/en/application-dev/faqs/faqs-ui-js.md
new file mode 100644
index 0000000000000000000000000000000000000000..5d39db33199fddf298e66e4bd290999b58d6dddb
--- /dev/null
+++ b/en/application-dev/faqs/faqs-ui-js.md
@@ -0,0 +1,96 @@
+# ArkUI (JavaScript) Development
+
+
+
+## How do I convert the fields in an XML file into JavaScript objects?
+
+Applicable to: OpenHarmony SDK 3.2.3.5, stage model of API version 9
+
+To convert fields in an XML file into JavaScript objects, call the **convert** API in the **convertxml** module.
+
+Example:
+
+
+```
+import convertxml from '@ohos.convertxml';
+// Code snippet
+xml =
+ '' +
+ '' +
+ ' Happy' +
+ ' Work' +
+ ' Play' +
+ '';
+let conv = new convertxml.ConvertXML();
+// Options for conversion. For details, see the reference document.
+let options = {trim : false, declarationKey:"_declaration",
+ instructionKey : "_instruction", attributesKey : "_attributes",
+ textKey : "_text", cdataKey:"_cdata", doctypeKey : "_doctype",
+ commentKey : "_comment", parentKey : "_parent", typeKey : "_type",
+ nameKey : "_name", elementsKey : "_elements"}
+let result:any = conv.convert(xml, options) // Convert fields in the XML file into JavaScript objects.
+console.log('Test: ' + JSON.stringify(result))
+console.log('Test: ' + result._declaration._attributes.version) // vesion field in XML file
+console.log('Test: ' + result._elements[0]._elements[0]._elements[0]._text) // title field in XML file
+```
+
+Reference: [XML-to-JavaScript Conversion](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-convertxml.md)
+
+## What are the differences between JavaScript, TypeScript, and eTS?
+
+Applicable to: OpenHarmony SDK 3.2.3.5, stage model of API version 9
+
+- JavaScript: a lightweight, weakly-typed programming language, most commonly known as the scripting language for web pages.
+
+- TypeScript: a superset of JavaScript, with additions of static typing and more object-oriented APIs, enums, etc.
+
+- eTS: a superset of TypeScript and the programming language for OpenHarmony ArkUI development, which powers UI development through a declarative development paradigm.
+
+## How do I convert the time to the HHMMSS format?
+
+Example:
+
+
+```
+export default class DateTimeUtil{
+ /**
+ * HHMMSS
+ */
+ getTime() {
+ const DATETIME = new Date()
+ return this.concatTime(DATETIME.getHours(),DATETIME.getMinutes(),DATETIME.getSeconds())
+ }
+ /**
+ * YYYYMMDD
+ */
+ getDate() {
+ const DATETIME = new Date()
+ return this.concatDate(DATETIME.getFullYear(),DATETIME.getMonth()+1,DATETIME.getDate())
+ }
+ /**
+ * If the date is less than 10, add a leading zero, for example, **07**.
+ * @param value Indicates the value.
+ */
+ fill(value:number) {
+ return (value> 9 ? '' : '0') + value
+ }
+ /**
+ * Concatenate year, month, and date fields.
+ * @param year
+ * @param month
+ * @param date
+ */
+ concatDate(year: number, month: number, date: number){
+ return `${year}${this.fill(month)}${this.fill(date)}`
+ }
+ /**
+ Concatenate hours, minutes, and seconds fields.
+ * @param hours
+ * @param minutes
+ * @param seconds
+ */
+ concatTime(hours:number,minutes:number,seconds:number){
+ return `${this.fill(hours)}${this.fill(minutes)}${this.fill(seconds)}`
+ }
+}
+```
diff --git a/en/application-dev/faqs/figures/en-us_image_0000001361254285.png b/en/application-dev/faqs/figures/en-us_image_0000001361254285.png
new file mode 100644
index 0000000000000000000000000000000000000000..b44ed1b13a0365a7ffaf3fcff1b00b7555e90159
Binary files /dev/null and b/en/application-dev/faqs/figures/en-us_image_0000001361254285.png differ
diff --git a/en/application-dev/media/Readme-EN.md b/en/application-dev/media/Readme-EN.md
index 131114d67cb3e1c8519d6d5f3a85b438e5846f6f..5f6e88fc07c88d3e5913058a26887e818a3cc3bc 100755
--- a/en/application-dev/media/Readme-EN.md
+++ b/en/application-dev/media/Readme-EN.md
@@ -20,4 +20,4 @@
- Camera
- [Camera Development](camera.md)
-
+ - [Distributed Camera Development](remote-camera.md)
diff --git a/en/application-dev/media/audio-capturer.md b/en/application-dev/media/audio-capturer.md
index 64566aba64e213ca8e088ad3a71e036625153187..0815ef31a288440271a27a8f03fb417923a46190 100644
--- a/en/application-dev/media/audio-capturer.md
+++ b/en/application-dev/media/audio-capturer.md
@@ -8,7 +8,7 @@ You can use the APIs provided by **AudioCapturer** to record raw audio files.
During application development, you are advised to use **on('stateChange')** to subscribe to state changes of the **AudioCapturer** instance. This is because some operations can be performed only when the audio capturer is in a given state. If the application performs an operation when the audio capturer is not in the given state, the system may throw an exception or generate other undefined behavior.
-For details about the APIs, see [AudioCapturer in Audio Management](../reference/apis/js-apis-audio.md).
+For details about the APIs, see [AudioCapturer in Audio Management](../reference/apis/js-apis-audio.md#audiocapturer8).
**Figure 1** Audio capturer state
diff --git a/en/application-dev/media/audio-playback.md b/en/application-dev/media/audio-playback.md
index 131cacdb3f39ecf6eafb5088525d97d209c9cf18..5227f6cdd1b9ec89818b0d1762c99267ec7eba97 100644
--- a/en/application-dev/media/audio-playback.md
+++ b/en/application-dev/media/audio-playback.md
@@ -18,7 +18,7 @@ You can use audio playback APIs to convert audio data into audible analog signal
## How to Develop
-For details about the APIs, see [AudioPlayer in the Media API](../reference/apis/js-apis-media.md).
+For details about the APIs, see [AudioPlayer in the Media API](../reference/apis/js-apis-media.md#audioplayer).
### Full-Process Scenario
diff --git a/en/application-dev/media/audio-recorder.md b/en/application-dev/media/audio-recorder.md
index 6fb1c28efa8bd8bd69e16b09cd577ec4bdeff6e6..f465db2b88118b77c9a4e64307170da07c3e8918 100644
--- a/en/application-dev/media/audio-recorder.md
+++ b/en/application-dev/media/audio-recorder.md
@@ -16,7 +16,7 @@ During audio recording, audio signals are captured, encoded, and saved to files.
## How to Develop
-For details about the APIs, see [AudioRecorder in the Media API](../reference/apis/js-apis-media.md).
+For details about the APIs, see [AudioRecorder in the Media API](../reference/apis/js-apis-media.md#audiorecorder).
### Full-Process Scenario
@@ -185,4 +185,3 @@ export class AudioRecorderDemo {
}
}
```
-
diff --git a/en/application-dev/media/audio-stream-manager.md b/en/application-dev/media/audio-stream-manager.md
index 4f0f88c8fa2c3357e7a8d582642cf4efbb7bf1db..eb89957e9b8793b149c368445f1232bf0ff3b563 100644
--- a/en/application-dev/media/audio-stream-manager.md
+++ b/en/application-dev/media/audio-stream-manager.md
@@ -12,7 +12,7 @@ For details about the APIs, see [AudioStreamManager](../reference/apis/js-apis-a
**Figure 1** Audio stream management invoking relationship
-
+
## How to Develop
@@ -117,7 +117,7 @@ This API can be used to obtain the unique ID of the audio stream, UID of the aud
console.info('Address:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].address);
console.info('SampleRates:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].sampleRates[0]);
console.info('ChannelCounts' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].channelCounts[0]);
- console.info('ChannnelMask:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].channelMasks);
+ console.info('ChannelMask:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].channelMasks);
}
}
}
diff --git a/en/application-dev/media/camera.md b/en/application-dev/media/camera.md
index 5af14112df2959acbcfc606c9cd2938860ad6f85..06439dd049be835cdf5a96a35e2a2a42012ee6f8 100644
--- a/en/application-dev/media/camera.md
+++ b/en/application-dev/media/camera.md
@@ -54,7 +54,7 @@ await cameraManager.getCameras((err, cameras) => {
cameraArray = cameras
})
-for(let cameraIndex = 0; cameraIndex < cameraArray.length; cameraIndex) {
+for(let cameraIndex = 0; cameraIndex < cameraArray.length; cameraIndex++) {
console.log('cameraId : ' + cameraArray[cameraIndex].cameraId) // Obtain the camera ID.
console.log('cameraPosition : ' + cameraArray[cameraIndex].cameraPosition) // Obtain the camera position.
console.log('cameraType : ' + cameraArray[cameraIndex].cameraType) // Obtain the camera type.
@@ -292,7 +292,7 @@ await captureSession.start().then(() => {
##### Switching a Session
```js
-// Stop the current session.
+// Stop the session.
await captureSession.stop((err) => {
if (err) {
console.error('Failed to stop the session ${err.message}');
@@ -347,8 +347,8 @@ await captureSession.start().then(() => {
```js
let settings = {
- quality: camera.QualityLevel.QUALITY_LEVEL_HIGH // Set the image quality to high.
- rotation: camera.ImageRotation.ROTATION_0, // Set the image rotation angle to 0.
+ quality: camera.QualityLevel.QUALITY_LEVEL_HIGH, // Set the image quality to high.
+ rotation: camera.ImageRotation.ROTATION_0 // Set the image rotation angle to 0.
}
// Use the current photographing settings to take photos.
photoOutput.capture(settings, (err) => {
@@ -395,7 +395,7 @@ await videoOutput.stop((err) => {
#### Releasing Resources
```js
-// Stop the current session.
+// Stop the session.
await captureSession.stop((err) => {
if (err) {
console.error('Failed to stop the session ${err.message}');
diff --git a/en/application-dev/media/figures/zh-ch_image_audio_stream_manager.png b/en/application-dev/media/figures/en-us_image_audio_stream_manager.png
similarity index 100%
rename from en/application-dev/media/figures/zh-ch_image_audio_stream_manager.png
rename to en/application-dev/media/figures/en-us_image_audio_stream_manager.png
diff --git a/en/application-dev/media/remote-camera.md b/en/application-dev/media/remote-camera.md
index b63946d6a03a9fbb4d4e6b8e20c3e4920364523b..e35950e73b1993b8a446f75e3007a80e4bbaff19 100644
--- a/en/application-dev/media/remote-camera.md
+++ b/en/application-dev/media/remote-camera.md
@@ -5,7 +5,7 @@
You can call the APIs provided by the **Camera** module to develop a distributed camera that provides the basic camera functions such as shooting and video recording.
## How to Develop
-Connect your calculator to a distributed device. Your calculator will call **getCameras()** to obtain the camera list and traverse the returned camera list to check **ConnctionType** of the **Camera** objects. If **ConnctionType** of a **Camera** object is **CAMERA_CONNECTION_REMOTE**, your calculator will use this object to create a **CameraInput** object. The subsequent call process is the same as that of the local camera development. For details about the local camera development, see [Camera Development](./camera.md).
+Connect your calculator to a distributed device. Your calculator will call **getCameras()** to obtain the camera list and traverse the returned camera list to check **ConnectionType** of the **Camera** objects. If **ConnectionType** of a **Camera** object is **CAMERA_CONNECTION_REMOTE**, your calculator will use this object to create a **CameraInput** object. The subsequent call process is the same as that of the local camera development. For details about the local camera development, see [Camera Development](./camera.md).
For details about the APIs, see [Camera Management](../reference/apis/js-apis-camera.md).
@@ -52,7 +52,7 @@ await cameraManager.getCameras((err, cameras) => {
cameraArray = cameras
})
-for(let cameraIndex = 0; cameraIndex < cameraArray.length; cameraIndex) {
+for(let cameraIndex = 0; cameraIndex < cameraArray.length; cameraIndex++) {
console.log('cameraId : ' + cameraArray[cameraIndex].cameraId) // Obtain the camera ID.
console.log('cameraPosition : ' + cameraArray[cameraIndex].cameraPosition) // Obtain the camera position.
console.log('cameraType : ' + cameraArray[cameraIndex].cameraType) // Obtain the camera type.
diff --git a/en/application-dev/media/video-playback.md b/en/application-dev/media/video-playback.md
index cfc09db79fc853066e03205010f43c2f63c27ce5..6ee5cf660069294f717c5cac614ed707db9f1a8c 100644
--- a/en/application-dev/media/video-playback.md
+++ b/en/application-dev/media/video-playback.md
@@ -33,7 +33,7 @@ The table below lists the mainstream playback formats and resolutions.
## How to Develop
-For details about the APIs, see [VideoPlayer in the Media API](../reference/apis/js-apis-media.md).
+For details about the APIs, see [VideoPlayer in the Media API](../reference/apis/js-apis-media.md#videoplayer8).
### Full-Process Scenario
diff --git a/en/application-dev/media/video-recorder.md b/en/application-dev/media/video-recorder.md
index 2982675bd37ff683c83f253d23d3a6c71014d66b..62e81cf05c384a7cd1a780c562697be046153d05 100644
--- a/en/application-dev/media/video-recorder.md
+++ b/en/application-dev/media/video-recorder.md
@@ -14,7 +14,7 @@ During video recording, audio and video signals are captured, encoded, and saved
## How to Develop
-For details about the APIs, see [VideoRecorder in the Media API](../reference/apis/js-apis-media.md).
+For details about the APIs, see [VideoRecorder in the Media API](../reference/apis/js-apis-media.md#videorecorder9).
### Full-Process Scenario
diff --git a/en/application-dev/napi/Readme-EN.md b/en/application-dev/napi/Readme-EN.md
index d5297e9374fdf42b1b50fa2ac6e545fe9766971b..280efd8afa5fa845dab0d607ed94b33e2a75e6d3 100644
--- a/en/application-dev/napi/Readme-EN.md
+++ b/en/application-dev/napi/Readme-EN.md
@@ -2,6 +2,7 @@
- [Using Native APIs in Application Projects](napi-guidelines.md)
- [Drawing Development](drawing-guidelines.md)
-- [Native Window Development](native-window-guidelines.md)
- [Raw File Development](rawfile-guidelines.md)
+- [Native Window Development](native-window-guidelines.md)
+
diff --git a/en/application-dev/napi/napi-guidelines.md b/en/application-dev/napi/napi-guidelines.md
index 86854eb072b19c7ee359dcb70413ce22580cb8f7..f471f4a6eed7d3eb2c96dab8cae4cb7480a13616 100644
--- a/en/application-dev/napi/napi-guidelines.md
+++ b/en/application-dev/napi/napi-guidelines.md
@@ -89,7 +89,7 @@ Register four synchronous APIs (`getSync`, `setSync`, `removeSync`, and`clearSyn
/***********************************************
* Module export and register
***********************************************/
-static napi_value StorgeExport(napi_env env, napi_value exports)
+static napi_value StorageExport(napi_env env, napi_value exports)
{
napi_property_descriptor desc[] = {
DECLARE_NAPI_FUNCTION("get", JSStorageGet),
@@ -110,7 +110,7 @@ static napi_value StorgeExport(napi_env env, napi_value exports)
static napi_module storage_module = {.nm_version = 1,
.nm_flags = 0,
.nm_filename = nullptr,
- .nm_register_func = StorgeExport,
+ .nm_register_func = StorageExport,
.nm_modname = "storage",
.nm_priv = ((void*)0),
.reserved = {0}};
diff --git a/en/application-dev/notification/notification-guidelines.md b/en/application-dev/notification/notification-guidelines.md
index 5630462352d721cb3337bfbe302576dc175e29bd..fb73f274202aafd9ff852201ca2fb8c5116aba50 100644
--- a/en/application-dev/notification/notification-guidelines.md
+++ b/en/application-dev/notification/notification-guidelines.md
@@ -28,14 +28,14 @@ System applications also support notification-related configuration options, suc
## Available APIs
-Certain APIs can be invoked only by system applications that have been granted the **SystemCapability.Notification.Notification** permission. The APIs use either a callback or promise to return the result. The tables below list the APIs that use a callback, which provide same functions as their counterparts that use a promise. For details about the APIs, see the [API document](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-notification.md).
+Certain APIs can be called only by system applications that have been granted the **SystemCapability.Notification.Notification** permission. The APIs use either a callback or promise to return the result. The tables below list the APIs that use a callback, which provide the same functions as their counterparts that use a promise. For details about the APIs, see the [API document](../reference/apis/js-apis-notification.md).
**Table 1** APIs for notification enabling
| API | Description |
| ------------------------------------------------------------ | ---------------- |
-| isNotificationEnabled(bundle: BundleOption, callback: AsyncCallback): void | Checks whether notification is enabled.|
-| enableNotification(bundle: BundleOption, enable: boolean, callback: AsyncCallback): void | Sets whether to enable notification. |
+| isNotificationEnabled(bundle: BundleOption, callback: AsyncCallback\): void | Checks whether notification is enabled.|
+| enableNotification(bundle: BundleOption, enable: boolean, callback: AsyncCallback\): void | Sets whether to enable notification. |
If the notification function of an application is disabled, it cannot send notifications.
@@ -45,11 +45,11 @@ If the notification function of an application is disabled, it cannot send notif
| API | Description |
| ------------------------------------------------------------ | ---------------- |
-| subscribe(subscriber: NotificationSubscriber, info: NotificationSubscribeInfo, callback: AsyncCallback): void | Subscribes to a notification with the subscription information specified.|
-| subscribe(subscriber: NotificationSubscriber, callback: AsyncCallback): void | Subscribes to all notifications. |
-| unsubscribe(subscriber: NotificationSubscriber, callback: AsyncCallback): void | Unsubscribes from a notification. |
+| subscribe(subscriber: NotificationSubscriber, info: NotificationSubscribeInfo, callback: AsyncCallback\): void | Subscribes to a notification with the subscription information specified.|
+| subscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\): void | Subscribes to all notifications. |
+| unsubscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\): void | Unsubscribes from a notification. |
-The subscription APIs support subscription to all notifications or notifications from specific applications.
+The subscription APIs support subscription to all notifications and notifications from specific applications.
@@ -69,10 +69,10 @@ The subscription APIs support subscription to all notifications or notifications
| API | Description |
| ------------------------------------------------------------ | ------------------------ |
-| publish(request: NotificationRequest, callback: AsyncCallback): void | Publishes a notification. |
-| publish(request: NotificationRequest, userId: number, callback: AsyncCallback): void | Publishes a notification to the specified user. |
-| cancel(id: number, label: string, callback: AsyncCallback): void | Cancels a specified notification. |
-| cancelAll(callback: AsyncCallback): void; | Cancels all notifications published by the application.|
+| publish(request: NotificationRequest, callback: AsyncCallback\): void | Publishes a notification. |
+| publish(request: NotificationRequest, userId: number, callback: AsyncCallback\): void | Publishes a notification to the specified user. |
+| cancel(id: number, label: string, callback: AsyncCallback\): void | Cancels a specified notification. |
+| cancelAll(callback: AsyncCallback\): void; | Cancels all notifications published by the application.|
The **publish** API that carries **userId** can be used to publish notifications to subscribers of a specified user.
@@ -136,7 +136,7 @@ var subscriber = {
Before publishing a notification, check whether the notification feature is enabled for your application. By default, the feature is disabled. The application calls **Notification.requestEnableNotification** to prompt the user to enable the feature.
```js
-Notification.requestEnableNotification() .then((data) => {
+Notification.requestEnableNotification().then((data) => {
console.info('===>requestEnableNotification success');
}).catch((err) => {
console.error('===>requestEnableNotification failed because ' + JSON.stringify(err));
@@ -166,7 +166,7 @@ var notificationRequest = {
}
// Publish the notification.
-Notification.publish(notificationRequest) .then((data) => {
+Notification.publish(notificationRequest).then((data) => {
console.info('===>publish promise success req.id : ' + notificationRequest.id);
}).catch((err) => {
console.error('===>publish promise failed because ' + JSON.stringify(err));
@@ -235,7 +235,7 @@ var notificationRequest = {
}
// Publish the notification.
-Notification.publish(notificationRequest) .then((data) => {
+Notification.publish(notificationRequest).then((data) => {
console.info('===>publish promise success req.id : ' + notificationRequest.id);
}).catch((err) => {
console.error('===>publish promise failed because ' + JSON.stringify(err));
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001215066868.png b/en/application-dev/quick-start/figures/en-us_image_0000001215066868.png
deleted file mode 100644
index d3afe4570f4a839aaa531dea2b1889f318c81f71..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001215066868.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001215206886.png b/en/application-dev/quick-start/figures/en-us_image_0000001215206886.png
deleted file mode 100644
index e90d0dbca27908da2964babcba1bc74876b04991..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001215206886.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001215226858.png b/en/application-dev/quick-start/figures/en-us_image_0000001215226858.png
deleted file mode 100644
index e2444e0c8488f6632a098585409352a8ce8c7303..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001215226858.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001215227618.png b/en/application-dev/quick-start/figures/en-us_image_0000001215227618.png
deleted file mode 100644
index d3afe4570f4a839aaa531dea2b1889f318c81f71..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001215227618.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001215386842.png b/en/application-dev/quick-start/figures/en-us_image_0000001215386842.png
deleted file mode 100644
index 335548669bb32a22f146d76f9ab88527e52f515a..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001215386842.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001215388136.png b/en/application-dev/quick-start/figures/en-us_image_0000001215388136.png
deleted file mode 100644
index 890e12eee8b4534a2b94206c6b73edc81d1ee3ee..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001215388136.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001215388262.png b/en/application-dev/quick-start/figures/en-us_image_0000001215388262.png
deleted file mode 100644
index 890e12eee8b4534a2b94206c6b73edc81d1ee3ee..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001215388262.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001216084724.png b/en/application-dev/quick-start/figures/en-us_image_0000001216084724.png
deleted file mode 100644
index a8fac2a024e51aeb0439463dab83f2763fa3fa76..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001216084724.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001216239356.png b/en/application-dev/quick-start/figures/en-us_image_0000001216239356.png
deleted file mode 100644
index fbbde9923a131d3ab69257b28cfe33ca2a1040cf..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001216239356.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001216269940.png b/en/application-dev/quick-start/figures/en-us_image_0000001216269940.png
deleted file mode 100644
index 0b9e04b55e1f9dfca33d97b6b0b80635f6aa1adf..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001216269940.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001216288558.png b/en/application-dev/quick-start/figures/en-us_image_0000001216288558.png
deleted file mode 100644
index 7795d74c5ec4915a1f2d6164e0625e308704528a..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001216288558.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001217047316.png b/en/application-dev/quick-start/figures/en-us_image_0000001217047316.png
deleted file mode 100644
index 6c1ea01d448434e7cfd94e174474e72b57d3b4cc..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001217047316.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001217526428.png b/en/application-dev/quick-start/figures/en-us_image_0000001217526428.png
deleted file mode 100644
index 2c026736133d41d80a1b92eb0db230dd6c0a7feb..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001217526428.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001217527892.png b/en/application-dev/quick-start/figures/en-us_image_0000001217527892.png
deleted file mode 100644
index 0b9e04b55e1f9dfca33d97b6b0b80635f6aa1adf..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001217527892.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001223397122.png b/en/application-dev/quick-start/figures/en-us_image_0000001223397122.png
deleted file mode 100644
index 42b475577bcc805372336be8971afa5c69c284bd..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001223397122.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001223556342.png b/en/application-dev/quick-start/figures/en-us_image_0000001223556342.png
deleted file mode 100644
index ab2ae3c740dfee9b303d6319516c9facb3574184..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001223556342.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001223557290.png b/en/application-dev/quick-start/figures/en-us_image_0000001223557290.png
deleted file mode 100644
index 6e093d7a983e03a37143357001eefd57c3df2c3c..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001223557290.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001223558810.png b/en/application-dev/quick-start/figures/en-us_image_0000001223558810.png
deleted file mode 100644
index b9c3f899421f61b39480b831a662eebf6530100f..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001223558810.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001223558814.png b/en/application-dev/quick-start/figures/en-us_image_0000001223558814.png
deleted file mode 100644
index ab2ae3c740dfee9b303d6319516c9facb3574184..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001223558814.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001223716826.png b/en/application-dev/quick-start/figures/en-us_image_0000001223716826.png
deleted file mode 100644
index 14dc492cb36d22c79d22bea78d0f66508867291e..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001223716826.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001223717294.png b/en/application-dev/quick-start/figures/en-us_image_0000001223717294.png
deleted file mode 100644
index 75910aaf0daa22be2c0b56ae94febaa672df7424..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001223717294.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001223722586.png b/en/application-dev/quick-start/figures/en-us_image_0000001223722586.png
deleted file mode 100644
index 8ed9b0d3565e5fbb2f7897bc876369ebae5a8598..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001223722586.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001223877162.png b/en/application-dev/quick-start/figures/en-us_image_0000001223877162.png
deleted file mode 100644
index 02d730cadf10899edd91f94ce4cb8badd3ba821c..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001223877162.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001223877210.png b/en/application-dev/quick-start/figures/en-us_image_0000001223877210.png
deleted file mode 100644
index 9ce82237297b06c04113d0368d7145661de0d997..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001223877210.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001223882030.png b/en/application-dev/quick-start/figures/en-us_image_0000001223882030.png
deleted file mode 100644
index 045487dc8fa30e8f87cd3fdd5c87e8ec17715c94..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001223882030.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001233048996.png b/en/application-dev/quick-start/figures/en-us_image_0000001233048996.png
deleted file mode 100644
index 6d8b4f343d3744e245a656987a85a6da2c9bb18e..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001233048996.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001233049004.png b/en/application-dev/quick-start/figures/en-us_image_0000001233049004.png
deleted file mode 100644
index b34bfa591849f5f0ffd0cee1fc898ef8d2f5a5cd..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001233049004.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001233049040.png b/en/application-dev/quick-start/figures/en-us_image_0000001233049040.png
deleted file mode 100644
index c340326cce920ed6c55965126d38ddd973d9f50a..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001233049040.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001233209020.png b/en/application-dev/quick-start/figures/en-us_image_0000001233209020.png
deleted file mode 100644
index 890e12eee8b4534a2b94206c6b73edc81d1ee3ee..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001233209020.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001233209024.png b/en/application-dev/quick-start/figures/en-us_image_0000001233209024.png
deleted file mode 100644
index dd28ccedfa20424aad7e01ee52d9246788b72eb8..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001233209024.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001233368860.png b/en/application-dev/quick-start/figures/en-us_image_0000001233368860.png
deleted file mode 100644
index 335548669bb32a22f146d76f9ab88527e52f515a..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001233368860.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001233368868.png b/en/application-dev/quick-start/figures/en-us_image_0000001233368868.png
deleted file mode 100644
index cd1603f14f7a5d30c79613201e85ed240f10a409..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001233368868.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001233368900.png b/en/application-dev/quick-start/figures/en-us_image_0000001233368900.png
deleted file mode 100644
index 890e12eee8b4534a2b94206c6b73edc81d1ee3ee..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001233368900.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001233528152.png b/en/application-dev/quick-start/figures/en-us_image_0000001233528152.png
deleted file mode 100644
index ab2ae3c740dfee9b303d6319516c9facb3574184..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001233528152.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001233528160.png b/en/application-dev/quick-start/figures/en-us_image_0000001233528160.png
deleted file mode 100644
index 6d8b4f343d3744e245a656987a85a6da2c9bb18e..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001233528160.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001233528192.png b/en/application-dev/quick-start/figures/en-us_image_0000001233528192.png
deleted file mode 100644
index dd28ccedfa20424aad7e01ee52d9246788b72eb8..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001233528192.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001259866741.png b/en/application-dev/quick-start/figures/en-us_image_0000001259866741.png
deleted file mode 100644
index 335548669bb32a22f146d76f9ab88527e52f515a..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001259866741.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001259987441.png b/en/application-dev/quick-start/figures/en-us_image_0000001259987441.png
deleted file mode 100644
index 335548669bb32a22f146d76f9ab88527e52f515a..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001259987441.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001260106745.png b/en/application-dev/quick-start/figures/en-us_image_0000001260106745.png
deleted file mode 100644
index d3afe4570f4a839aaa531dea2b1889f318c81f71..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001260106745.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001260107497.png b/en/application-dev/quick-start/figures/en-us_image_0000001260107497.png
deleted file mode 100644
index 335548669bb32a22f146d76f9ab88527e52f515a..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001260107497.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001260226691.png b/en/application-dev/quick-start/figures/en-us_image_0000001260226691.png
deleted file mode 100644
index 6d8b4f343d3744e245a656987a85a6da2c9bb18e..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001260226691.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001260227453.png b/en/application-dev/quick-start/figures/en-us_image_0000001260227453.png
deleted file mode 100644
index d3afe4570f4a839aaa531dea2b1889f318c81f71..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001260227453.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001260684127.png b/en/application-dev/quick-start/figures/en-us_image_0000001260684127.png
deleted file mode 100644
index 2c026736133d41d80a1b92eb0db230dd6c0a7feb..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001260684127.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001261142799.png b/en/application-dev/quick-start/figures/en-us_image_0000001261142799.png
deleted file mode 100644
index 86ff220370fc26319a4a23434d70e2508d8f1b9a..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001261142799.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001261809595.png b/en/application-dev/quick-start/figures/en-us_image_0000001261809595.png
deleted file mode 100644
index 164371727ee8a351e2c42f4b3ecab9175e088e7c..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001261809595.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001261979271.png b/en/application-dev/quick-start/figures/en-us_image_0000001261979271.png
deleted file mode 100644
index 12978dc861aaa1f826404d9c6838bb8628381615..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001261979271.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001262127855.png b/en/application-dev/quick-start/figures/en-us_image_0000001262127855.png
deleted file mode 100644
index 86ff220370fc26319a4a23434d70e2508d8f1b9a..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001262127855.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001262206247.png b/en/application-dev/quick-start/figures/en-us_image_0000001262206247.png
deleted file mode 100644
index 6c1ea01d448434e7cfd94e174474e72b57d3b4cc..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001262206247.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001262207811.png b/en/application-dev/quick-start/figures/en-us_image_0000001262207811.png
deleted file mode 100644
index 6c1ea01d448434e7cfd94e174474e72b57d3b4cc..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001262207811.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001262219043.png b/en/application-dev/quick-start/figures/en-us_image_0000001262219043.png
deleted file mode 100644
index 12978dc861aaa1f826404d9c6838bb8628381615..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001262219043.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001262339067.png b/en/application-dev/quick-start/figures/en-us_image_0000001262339067.png
deleted file mode 100644
index 12978dc861aaa1f826404d9c6838bb8628381615..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001262339067.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001268077317.png b/en/application-dev/quick-start/figures/en-us_image_0000001268077317.png
deleted file mode 100644
index 6e093d7a983e03a37143357001eefd57c3df2c3c..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001268077317.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001268082945.png b/en/application-dev/quick-start/figures/en-us_image_0000001268082945.png
deleted file mode 100644
index 55d41f7eb98b1c80bc5f85ea99be6b73bcdd7c1d..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001268082945.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001268198893.png b/en/application-dev/quick-start/figures/en-us_image_0000001268198893.png
deleted file mode 100644
index ab2ae3c740dfee9b303d6319516c9facb3574184..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001268198893.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001268283201.png b/en/application-dev/quick-start/figures/en-us_image_0000001268283201.png
deleted file mode 100644
index 6e093d7a983e03a37143357001eefd57c3df2c3c..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001268283201.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001277488985.png b/en/application-dev/quick-start/figures/en-us_image_0000001277488985.png
deleted file mode 100644
index 335548669bb32a22f146d76f9ab88527e52f515a..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001277488985.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001277489017.png b/en/application-dev/quick-start/figures/en-us_image_0000001277489017.png
deleted file mode 100644
index c659e54584bf8e78543facc3a1b3f821a6a9571f..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001277489017.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001277608813.png b/en/application-dev/quick-start/figures/en-us_image_0000001277608813.png
deleted file mode 100644
index 335548669bb32a22f146d76f9ab88527e52f515a..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001277608813.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001277608849.png b/en/application-dev/quick-start/figures/en-us_image_0000001277608849.png
deleted file mode 100644
index 12978dc861aaa1f826404d9c6838bb8628381615..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001277608849.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001277728569.png b/en/application-dev/quick-start/figures/en-us_image_0000001277728569.png
deleted file mode 100644
index 4d6994bf5bf8dd05baf7eac6274f56de27fc23b3..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001277728569.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001277728577.png b/en/application-dev/quick-start/figures/en-us_image_0000001277728577.png
deleted file mode 100644
index 6d8b4f343d3744e245a656987a85a6da2c9bb18e..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001277728577.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001277728597.png b/en/application-dev/quick-start/figures/en-us_image_0000001277728597.png
deleted file mode 100644
index 335548669bb32a22f146d76f9ab88527e52f515a..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001277728597.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001277728613.png b/en/application-dev/quick-start/figures/en-us_image_0000001277728613.png
deleted file mode 100644
index cc3ca5fd7274be67f62b32e531fcbbaf294317c1..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001277728613.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001277809333.png b/en/application-dev/quick-start/figures/en-us_image_0000001277809333.png
deleted file mode 100644
index 64bb2a8edf4720cdb4d4d3b6055baa03c81b0a54..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001277809333.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001277809337.png b/en/application-dev/quick-start/figures/en-us_image_0000001277809337.png
deleted file mode 100644
index 335548669bb32a22f146d76f9ab88527e52f515a..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001277809337.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001277809373.png b/en/application-dev/quick-start/figures/en-us_image_0000001277809373.png
deleted file mode 100644
index 6c1ea01d448434e7cfd94e174474e72b57d3b4cc..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001277809373.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001655128646.png b/en/application-dev/quick-start/figures/en-us_image_0000001655128646.png
deleted file mode 100644
index 048b8e07817272b759781df104c1dd4526685d61..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001655128646.png and /dev/null differ
diff --git a/en/application-dev/quick-start/figures/en-us_image_202206250937.png b/en/application-dev/quick-start/figures/en-us_image_202206250937.png
deleted file mode 100644
index c4aa65192d174763ee3b6c74e10274978868ac67..0000000000000000000000000000000000000000
Binary files a/en/application-dev/quick-start/figures/en-us_image_202206250937.png and /dev/null differ
diff --git a/en/application-dev/quick-start/package-structure.md b/en/application-dev/quick-start/package-structure.md
index cae1337dea083ff731be54f0536fa33f6fd64812..076bc9474ba724746938c1a4da837a3679c73d5a 100644
--- a/en/application-dev/quick-start/package-structure.md
+++ b/en/application-dev/quick-start/package-structure.md
@@ -232,7 +232,6 @@ Table 11 Internal structure of the module tag
| distroFilter | Application distribution rules.
AppGallery uses these rules to distribute HAP files to the matching devices. Distribution rules cover three factors: API version, screen shape, and screen resolution. AppGallery distributes a HAP file to the device whose on the mapping between **deviceType** and these three factors. For details, see Table 29. | Object | Yes (initial value: left empty)
Set this attribute when an application has multiple entry modules. |
| reqCapabilities | Device capabilities required for running the application. | String array| Yes (initial value: left empty) |
| commonEvents | Static broadcast. For details, see Table 35. | Object array | Yes (initial value: left empty) |
-| allowClassMap | Metadata of the HAP file. The value can be **true** or **false**. If the value is **true**, the HAP file uses the Java object proxy mechanism provided by the OpenHarmony framework. | Boolean | No (initial value: **false**) |
| entryTheme | Keyword of an OpenHarmony internal theme. Set it to the resource index of the name.| String | Yes (initial value: left empty) |
Example of the **module** tag structure:
@@ -348,7 +347,7 @@ Table 17 Internal structure of the abilities attribute
| Attribute | Description | Data Type | Initial Value Allowed |
| ---------------- | ------------------------------------------------------------ | ---------- | -------------------------------------------------------- |
| process | Name of the process running the application or ability. If the **process** attribute is configured in the **deviceConfig** tag, all abilities of the application run in this process. You can set the **process** attribute for a specific ability in the **abilities** attribute, so that the ability can run in the particular process. If this attribute is set to the name of the process running other applications, all these applications can run in the same process, provided they have the same unified user ID and the same signature. Devices running OpenHarmony do not support this attribute.| String | Yes (initial value: left empty) |
-| name | Name of the ability. The value is a reverse domain name, in the format of "*Bundle name*.*Class name*", for example, **"com.example.myapplication.MainAbility"**. Alternatively, the value can start with a period (.) followed by the class name, for example, **".MainAbility"**.
The ability name must be unique in an application. This attribute applies only to the default, tablet, smart TV, head unit, and wearable device types.
Note: When you use DevEco Studio to create a project, the configuration of the first ability is generated by default, including the **MainAbility.java** file and the class name **MainAbility** defaulted in the **name** string for the **abilities** attribute in **config.json**. The value of this attribute can be customized if you use other IDE tools. The value can contain a maximum of 127 characters.| String | No |
+| name | Name of the ability. The value is a reverse domain name, in the format of "*Bundle name*.*Class name*", for example, **"com.example.myapplication.MainAbility"**. Alternatively, the value can start with a period (.) followed by the class name, for example, **".MainAbility"**.
The ability name must be unique in an application. This attribute applies only to the default, tablet, smart TV, head unit, and wearable device types.
Note: If you use DevEco Studio to create the project, an ability named **MainAbility** will be created together with the default configuration in the **config.json** file. The value of this attribute can be customized if you use other IDE tools. The value can contain a maximum of 127 characters.| String | No |
| description | Description of the ability. The value can be a string or a resource index to descriptions in multiple languages. The value can contain a maximum of 255 characters.| String | Yes (initial value: left empty) |
| icon | Index to the ability icon file. Example value: **$media:ability_icon**. In the **skills** attribute of the ability, if the **actions** value contains **action.system.home** and the **entities** value contains **entity.system.home**, the icon of the ability is also used as the icon of the application. If multiple abilities address this condition, the icon of the first candidate ability is used as the application icon.
Note: The **icon** and **label** values of an application are visible to users. Ensure that at least one of them is different from any existing icons or labels.| String | Yes (initial value: left empty) |
| label | Ability name visible to users. The value can be a name string or a resource index to names in multiple languages. In the **skills** attribute of the ability, if the **actions** value contains **action.system.home** and the **entities** value contains **entity.system.home**, the label of the ability is also used as the label of the application. If multiple abilities address this condition, the label of the first candidate ability is used as the application label.
Note: The **icon** and **label** values of an application are visible to users. Ensure that at least one of them is different from any existing icons or labels. The value can be a reference to a string defined in a resource file or a string enclosed in brackets ({}). The value can contain a maximum of 255 characters.| String | Yes (initial value: left empty) |
@@ -372,7 +371,7 @@ Table 17 Internal structure of the abilities attribute
| supportPipMode | Whether the ability allows the user to enter the Picture in Picture (PiP) mode. The PiP mode enables the user to watch a video in a small window that hovers on top of a full screen window (main window). This attribute applies only to the ability using the Page template. This attribute applies only to the default, tablet, smart TV, head unit, and wearable device types.| Boolean | Yes (initial value: **false**) |
| formsEnabled | Whether the ability can provide forms. This attribute applies only to the ability using the Page template.
**true**: This ability can provide forms.
**false**: This ability cannot provide forms.| Boolean | Yes (initial value: **false**) |
| forms | Details about the forms used by the ability. This attribute is valid only when **formsEnabled** is set to **true**. For details, see Table 27.| Object array | Yes (initial value: left empty) |
-| srcLanguage | Programming language used to develop the ability. | String | The value can be **java**, **js**, or **ets**. |
+| srcLanguage | Programming language used to develop the ability. | String | The value can be **js**, or **ets**. |
| srcPath | Path of the JS code and components corresponding to the ability. | String | Yes (initial value: left empty) |
| uriPermission | Application data that the ability can access. This attribute consists of the **mode** and **path** sub-attributes. This attribute is valid only for the capability of the type provider. Devices running OpenHarmony do not support this attribute. For details, see Table 18.| Object | Yes (initial value: left empty) |
| startWindowIcon | Index to the icon file of the ability startup page. Example value: **$media:icon**. | String | Yes (initial value: left empty) |
@@ -587,12 +586,10 @@ Table 27 Internal structure of the forms attribute
| name | Class name of the widget. The value is a string with a maximum of 127 bytes. | String | No |
| description | Description of the widget. The value can be a string or a resource index to descriptions in multiple languages. The value is a string with a maximum of 255 bytes.| String | Yes (initial value: left empty) |
| isDefault | Whether the widget is a default one. Each ability has only one default widget.
**true**: The widget is the default one.
**false**: The widget is not the default one.| Boolean | No |
-| type | Type of the widget. Available values are as follows:
**Java**: indicates a Java-programmed widget.
**JS**: indicates a JavaScript-programmed widget.| String | No |
+| type | Type of the widget. Available values are as follows:
**JS**: indicates a JavaScript-programmed widget.| String | No |
| colorMode | Color mode of the widget. Available values are as follows:
**auto**: The widget adopts the auto-adaptive color mode.
**dark**: The widget adopts the dark color mode.
**light**: The widget adopts the light color mode.| String | Yes (initial value: **auto**)|
| supportDimensions | Grid styles supported by the widget. Available values are as follows:
1 * 2: indicates a grid with one row and two columns.
2 * 2: indicates a grid with two rows and two columns.
2 * 4: indicates a grid with two rows and four columns.
4 * 4: indicates a grid with four rows and four columns.| String array| No |
| defaultDimension | Default grid style of the widget. The value must be available in the **supportDimensions** array of the widget.| String | No |
-| landscapeLayouts | Landscape layouts for the grid styles. Values in this array must correspond to the values in the **supportDimensions** array. This field is required only by Java-programmed widgets.| String array| No |
-| portraitLayouts | Portrait layouts for the grid styles. Values in this array must correspond to the values in the **supportDimensions** array. This field is required only by Java-programmed widgets.| String array| No |
| updateEnabled | Whether the widget can be updated periodically. Available values are as follows:
**true**: The widget can be updated periodically, depending on the update way you select, either at a specified interval (**updateDuration**) or at the scheduled time (**scheduledUpdateTime**). **updateDuration** is preferentially recommended.
**false**: The widget cannot be updated periodically.| Boolean | No |
| scheduledUpdateTime | Scheduled time to update the widget. The value is in 24-hour format and accurate to minute. | String | Yes (initial value: **0:0**) |
| updateDuration | Interval to update the widget. The value is a natural number, in the unit of 30 minutes.
If the value is **0**, this field does not take effect.
If the value is a positive integer ***N***, the interval is calculated by multiplying ***N*** and 30 minutes.| Number | Yes (initial value: **0**) |
@@ -632,9 +629,9 @@ Example of the **forms** attribute structure:
]
},
{
- "name": "Form_Java",
- "description": "It's Java Form",
- "type": "Java",
+ "name": "Form_JS",
+ "description": "It's JS Form",
+ "type": "JS",
"colorMode": "auto",
"isDefault": false,
"updateEnabled": true,
diff --git a/en/application-dev/quick-start/start-with-ets-fa.md b/en/application-dev/quick-start/start-with-ets-fa.md
index 325f4983f16f0cd48899fb657d3c9e41d2f9c3d8..03ed574bb99bcd65cecf0c6ca4710ab2271db9d3 100644
--- a/en/application-dev/quick-start/start-with-ets-fa.md
+++ b/en/application-dev/quick-start/start-with-ets-fa.md
@@ -187,7 +187,7 @@
## Implementing Page Redirection
-You can implement page redirection through the page router, which finds the target page based on the page URL. Import the **router** module and then perform the steps below:
+You can implement page redirection through the [page router](../reference/apis/js-apis-router.md#routerpush), which finds the target page based on the page URL. Import the **router** module and then perform the steps below:
1. Implement redirection from the first page to the second page.
diff --git a/en/application-dev/quick-start/start-with-ets-stage.md b/en/application-dev/quick-start/start-with-ets-stage.md
index 7703ff56e9336bb5e648a63eb3e7df470f0d88a5..b6b8cd11b8ba18b59931c1bf0244d4af3d7ec888 100644
--- a/en/application-dev/quick-start/start-with-ets-stage.md
+++ b/en/application-dev/quick-start/start-with-ets-stage.md
@@ -185,7 +185,7 @@
## Implementing Page Redirection
-You can implement page redirection through the page router, which finds the target page based on the page URL. Import the **router** module and then perform the steps below:
+You can implement page redirection through the [page router](../reference/apis/js-apis-router.md#routerpush), which finds the target page based on the page URL. Import the **router** module and then perform the steps below:
1. Implement redirection from the first page to the second page.
@@ -285,7 +285,7 @@ You can implement page redirection through the page router, which finds the targ
1. Connect the development board running the OpenHarmony standard system to the computer.
-2. Choose **File** > **Project Structure...** > **Project** > **SigningConfigs**, and select **Automatically generate signaure**. Wait until the automatic signing is complete, and click **OK**. See the following figure.
+2. Choose **File** > **Project Structure...** > **Project** > **SigningConfigs**, and select **Automatically generate signature**. Wait until the automatic signing is complete, and click **OK**. See the following figure.

diff --git a/en/application-dev/quick-start/start-with-js-fa.md b/en/application-dev/quick-start/start-with-js-fa.md
index dbd2931eba6f6de6c6d23777a5c761dc505dc7c4..03b037aeb529dcf7d481caf56db32625943c055b 100644
--- a/en/application-dev/quick-start/start-with-js-fa.md
+++ b/en/application-dev/quick-start/start-with-js-fa.md
@@ -181,7 +181,7 @@
## Implementing Page Redirection
-You can implement page redirection through the [page router](../ui/ui-js-building-ui-routes.md), which finds the target page based on the page URL. Import the **router** module and then perform the steps below:
+You can implement page redirection through the [page router](../reference/apis/js-apis-router.md#routerpush), which finds the target page based on the page URL. Import the **router** module and then perform the steps below:
1. Implement redirection from the first page to the second page.
diff --git a/en/application-dev/reference/apis/Readme-EN.md b/en/application-dev/reference/apis/Readme-EN.md
index fe77dc5347f70c5cbcef596dbd8c3b57df83d9cc..e580b6bbef7bd71869de1da19a3a3d5c4757370d 100644
--- a/en/application-dev/reference/apis/Readme-EN.md
+++ b/en/application-dev/reference/apis/Readme-EN.md
@@ -146,6 +146,7 @@
- [@ohos.privacyManager](js-apis-privacyManager.md)
- [@ohos.security.huks ](js-apis-huks.md)
- [@ohos.userIAM.userAuth ](js-apis-useriam-userauth.md)
+ - [@ohos.userIAM.faceAuth](js-apis-useriam-faceauth.md)
- [@system.cipher](js-apis-system-cipher.md)
- Data Management
diff --git a/en/application-dev/reference/apis/development-intro.md b/en/application-dev/reference/apis/development-intro.md
index 8528a10ab6f4ba3dd14186079357ce28e650ee6a..f1cc73aa8437b7cb20bf5fe16b284da2a788d570 100644
--- a/en/application-dev/reference/apis/development-intro.md
+++ b/en/application-dev/reference/apis/development-intro.md
@@ -26,6 +26,12 @@ A description regarding system APIs will be provided in the document.
- If all the APIs of a module are system APIs, the following description is provided at the beginning of the reference document: "All the APIs of this module are system APIs."
- If a specific API of a module is a system API, the following description is provided individually for the API: "This is a system API."
+Non-system applications are applications whose Ability Privilege Level (APL) is **normal**. The default application level is **normal**.
+
+For details about the APL and how to declare the APL of an application higher than **normal**, see [Access Control Overview - App APLs](../../security/accesstoken-overview.md#app-apls).
+
+The public SDK, which does not include system APIs, is provided as standard in DevEco Studio. To use system APIs, switch to the full SDK. For details on the operation, see [Guide to Switching to Full SDK](../../quick-start/full-sdk-switch-guide.md).
+
## Permission Description
By default, applications can access limited system resources. However, in some cases, an application needs to access excess data (including personal data) and functions of the system or another application to implement extended functions. For details, see [Access Control Overview](../../security/accesstoken-overview.md).
diff --git a/en/application-dev/reference/apis/js-apis-ability-context.md b/en/application-dev/reference/apis/js-apis-ability-context.md
index cd4e27214b3617970071bcfb8e4e5b1c76bc2a2c..9aab0179f06478fef211871d29e90daa33cf5609 100644
--- a/en/application-dev/reference/apis/js-apis-ability-context.md
+++ b/en/application-dev/reference/apis/js-apis-ability-context.md
@@ -5,8 +5,8 @@ The **AbilityContext** module, inherited from **Context**, implements the contex
This module provides APIs for accessing ability-specific resources. You can use the APIs to start and terminate an ability, obtain the caller interface, and request permissions from users by displaying a dialog box.
> **NOTE**
->
-> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+>
+> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The APIs of this module can be used only in the stage model.
## Usage
@@ -78,7 +78,7 @@ Starts an ability with start options specified. This API uses an asynchronous ca
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
**Example**
-
+
```js
var want = {
"deviceId": "",
@@ -127,7 +127,7 @@ Starts an ability. This API uses a promise to return the result.
windowMode: 0,
};
this.context.startAbility(want, options)
- .then((data) => {
+ .then(() => {
console.log('Operation successful.')
}).catch((error) => {
console.log('Operation failed.');
@@ -407,8 +407,8 @@ Starts a new Service Extension ability. This API uses a promise to return the re
"abilityName": "MainAbility"
};
this.context.startServiceExtensionAbility(want)
- .then((data) => {
- console.log('---------- startServiceExtensionAbility success, data: -----------', data);
+ .then(() => {
+ console.log('---------- startServiceExtensionAbility success -----------');
})
.catch((err) => {
console.log('---------- startServiceExtensionAbility fail, err: -----------', err);
@@ -477,8 +477,8 @@ Starts a new Service Extension ability with the account ID specified. This API u
};
var accountId = 100;
this.context.startServiceExtensionAbilityWithAccount(want,accountId)
- .then((data) => {
- console.log('---------- startServiceExtensionAbilityWithAccount success, data: -----------', data);
+ .then(() => {
+ console.log('---------- startServiceExtensionAbilityWithAccount success -----------');
})
.catch((err) => {
console.log('---------- startServiceExtensionAbilityWithAccount fail, err: -----------', err);
@@ -539,8 +539,8 @@ Stops a Service Extension ability in the same application. This API uses a promi
"abilityName": "MainAbility"
};
this.context.stopServiceExtensionAbility(want)
- .then((data) => {
- console.log('---------- stopServiceExtensionAbility success, data: -----------', data);
+ .then(() => {
+ console.log('---------- stopServiceExtensionAbility success -----------');
})
.catch((err) => {
console.log('---------- stopServiceExtensionAbility fail, err: -----------', err);
@@ -610,8 +610,8 @@ Stops a Service Extension ability in the same application with the account ID sp
};
var accountId = 100;
this.context.stopServiceExtensionAbilityWithAccount(want,accountId)
- .then((data) => {
- console.log('---------- stopServiceExtensionAbilityWithAccount success, data: -----------', data);
+ .then(() => {
+ console.log('---------- stopServiceExtensionAbilityWithAccount success -----------');
})
.catch((err) => {
console.log('---------- stopServiceExtensionAbilityWithAccount fail, err: -----------', err);
@@ -658,8 +658,8 @@ Terminates this ability. This API uses a promise to return the result.
**Example**
```js
- this.context.terminateSelf().then((data) => {
- console.log('success:' + JSON.stringify(data));
+ this.context.terminateSelf().then(() => {
+ console.log('success');
}).catch((error) => {
console.log('failed:' + JSON.stringify(error));
});
@@ -848,11 +848,11 @@ Disconnects a connection. This API uses a promise to return the result.
| Promise\ | Promise used to return the result.|
**Example**
-
+
```js
var connectionNumber = 0;
- this.context.disconnectAbility(connectionNumber).then((data) => {
- console.log('disconnectAbility success, data: ', data);
+ this.context.disconnectAbility(connectionNumber).then(() => {
+ console.log('disconnectAbility success');
}).catch((err) => {
console.log('disconnectAbility fail, err: ', err);
});
@@ -888,7 +888,7 @@ Disconnects a connection. This API uses an asynchronous callback to return the r
startAbilityByCall(want: Want): Promise<Caller>;
-Starts an ability in the foreground or background and obtains the caller interface for communication with the ability.
+Starts an ability in the foreground or background and obtains the caller object for communicating with the ability.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
@@ -905,11 +905,11 @@ Starts an ability in the foreground or background and obtains the caller interfa
| Promise<Caller> | Promise used to return the caller object to communicate with.|
**Example**
-
+
```js
let caller = undefined;
- // Start an ability in the background without passing parameters.
+ // Start an ability in the background by not passing parameters.
var wantBackground = {
bundleName: "com.example.myservice",
moduleName: "entry",
@@ -1050,8 +1050,8 @@ Starts an ability with the account ID specified. This API uses a promise to retu
windowMode: 0,
};
this.context.startAbilityWithAccount(want, accountId, options)
- .then((data) => {
- console.log('---------- startAbilityWithAccount success, data: -----------', data);
+ .then(() => {
+ console.log('---------- startAbilityWithAccount success -----------');
})
.catch((err) => {
console.log('---------- startAbilityWithAccount fail, err: -----------', err);
@@ -1074,13 +1074,13 @@ Requests permissions from the user by displaying a dialog box. This API uses an
| callback | AsyncCallback<[PermissionRequestResult](js-apis-permissionrequestresult.md)> | Yes| Callback used to return the result.|
**Example**
-
+
```js
var permissions=['com.example.permission']
this.context.requestPermissionsFromUser(permissions,(result) => {
console.log('requestPermissionsFromUserresult:' + JSON.stringify(result));
});
-
+
```
@@ -1105,7 +1105,7 @@ Requests permissions from the user by displaying a dialog box. This API uses a p
| Promise<[PermissionRequestResult](js-apis-permissionrequestresult.md)> | Promise used to return the result.|
**Example**
-
+
```js
var permissions=['com.example.permission']
this.context.requestPermissionsFromUser(permissions).then((data) => {
@@ -1133,7 +1133,7 @@ Sets a label for this ability in the mission. This API uses an asynchronous call
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
**Example**
-
+
```js
this.context.setMissionLabel("test",(result) => {
console.log('requestPermissionsFromUserresult:' + JSON.stringify(result));
@@ -1162,10 +1162,10 @@ Sets a label for this ability in the mission. This API uses a promise to return
| Promise<void> | Promise used to return the result.|
**Example**
-
+
```js
- this.context.setMissionLabel("test").then((data) => {
- console.log('success:' + JSON.stringify(data));
+ this.context.setMissionLabel("test").then(() => {
+ console.log('success');
}).catch((error) => {
console.log('failed:' + JSON.stringify(error));
});
@@ -1188,7 +1188,7 @@ Sets an icon for this ability in the mission. This API uses an asynchronous call
| callback | AsyncCallback\ | Yes| Callback used to return the result.|
**Example**
-
+
```js
import image from '@ohos.multimedia.image'
var imagePixelMap;
@@ -1235,7 +1235,7 @@ Sets an icon for this ability in the mission. This API uses a promise to return
| Promise<void> | Promise used to return the result.|
**Example**
-
+
```js
import image from '@ohos.multimedia.image'
var imagePixelMap;
@@ -1254,8 +1254,8 @@ Sets an icon for this ability in the mission. This API uses a promise to return
console.log('--------- createPixelMap fail, err: ---------', err)
});
this.context.setMissionIcon(imagePixelMap)
- .then((data) => {
- console.log('-------------- setMissionIcon success, data: -------------', data);
+ .then(() => {
+ console.log('-------------- setMissionIcon success -------------');
})
.catch((err) => {
console.log('-------------- setMissionIcon fail, err: -------------', err);
diff --git a/en/application-dev/reference/apis/js-apis-ability-wantConstant.md b/en/application-dev/reference/apis/js-apis-ability-wantConstant.md
index 545da5d468feefce2440a356812356e6206e11e3..619ed387b6338fa06a064b3848a3491ee7ea08c9 100644
--- a/en/application-dev/reference/apis/js-apis-ability-wantConstant.md
+++ b/en/application-dev/reference/apis/js-apis-ability-wantConstant.md
@@ -32,7 +32,7 @@ Enumerates the action constants of the **Want** object.
| ACTION_DISMISS_ALARM | ohos.want.action.dismissAlarm | Action of launching the UI for deleting an alarm. |
| ACTION_DISMISS_TIMER | ohos.want.action.dismissTimer | Action of launching the UI for dismissing a timer. |
| ACTION_SEND_SMS | ohos.want.action.sendSms | Action of launching the UI for sending an SMS message. |
-| ACTION_CHOOSE | ohos.want.action.choose | Action of launching the UI for openning a contact or picture. |
+| ACTION_CHOOSE | ohos.want.action.choose | Action of launching the UI for opening a contact or picture. |
| ACTION_IMAGE_CAPTURE8+ | ohos.want.action.imageCapture | Action of launching the UI for photographing. |
| ACTION_VIDEO_CAPTURE8+ | ohos.want.action.videoCapture | Action of launching the UI for shooting a video. |
| ACTION_SELECT | ohos.want.action.select | Action of launching the UI for application selection. |
diff --git a/en/application-dev/reference/apis/js-apis-accessibility-extension-context.md b/en/application-dev/reference/apis/js-apis-accessibility-extension-context.md
index f8323a391ace1995486ff721666805a7bbb9b658..6a592ba663ec3723884fd0f44fef90a733230fa7 100644
--- a/en/application-dev/reference/apis/js-apis-accessibility-extension-context.md
+++ b/en/application-dev/reference/apis/js-apis-accessibility-extension-context.md
@@ -9,10 +9,18 @@ You can use the APIs of this module to configure the concerned information, obta
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The APIs of this module can be used only in the stage model.
-## Modules to Import
+## Usage
+
+Before using the **AccessibilityExtensionContext** module, you must define a child class that inherits from **AccessibilityExtensionAbility**.
```js
import AccessibilityExtensionAbility from '@ohos.application.AccessibilityExtensionAbility'
+class MainAbility extends AccessibilityExtensionAbility {
+ onConnect(): void {
+ console.log("AxExtensionAbility onConnect");
+ let axContext = this.context;
+ }
+}
```
## FocusDirection
@@ -203,9 +211,9 @@ this.context.getWindows().then(windows => {
})
```
-## AccessibilityExtensionContext.gestureInject
+## AccessibilityExtensionContext.injectGesture
-gestureInject(gesturePath: GesturePath, listener: Callback\): Promise\): Promise\- **'accessibilityStateChange'** means to listen for enabled status changes of the accessibility application.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
- **'touchGuideStateChange'** means to listen for enabled status changes of the touch guide mode.
**System capability**: SystemCapability.BarrierFree.Accessibility.Vision|
- | callback | Callback<boolean> | Yes| Callback invoked when the enabled status of captions configuration changes.|
+ | type | string | Yes| Type of the event to listen for.
- **'accessibilityStateChange'** means to listen for the enabled status changes of the accessibility application.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
- **'touchGuideStateChange'** means to listen for the enabled status changes of the touch guide mode.
**System capability**: SystemCapability.BarrierFree.Accessibility.Vision|
+ | callback | Callback\ | Yes| Callback invoked when the enabled status of captions configuration changes.|
- **Example**
@@ -456,13 +460,15 @@ Enables listening for the accessibility application or touch guide mode status c
off(type: 'accessibilityStateChange ' | 'touchGuideStateChange', callback?: Callback<boolean>): void
-Disables listening for the accessibility application or touch guide mode status changes.
+Disables listening for the enabled status changes of the accessibility application or touch guide mode.
+
+
- **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
- | type | string | No| Type of the event to listen for.
- **'accessibilityStateChange'** means to listen for enabled status changes of the accessibility application.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
- **'touchGuideStateChange'** means to listen for enabled status changes of the touch guide mode.
**System capability**: SystemCapability.BarrierFree.Accessibility.Vision|
+ | type | string | No| Type of the event to listen for.
- **'accessibilityStateChange'** means to listen for the enabled status changes of the accessibility application.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
- **'touchGuideStateChange'** means to listen for the enabled status changes of the touch guide mode.
**System capability**: SystemCapability.BarrierFree.Accessibility.Vision|
| callback | Callback<boolean> | No| Callback invoked when the enabled status changes.|
- **Example**
diff --git a/en/application-dev/reference/apis/js-apis-appAccount.md b/en/application-dev/reference/apis/js-apis-appAccount.md
index ef0e355c63726bc167dac72801adfdce030827f3..44f96b01b333ed9ad5e1258b0173734c0c7869d7 100644
--- a/en/application-dev/reference/apis/js-apis-appAccount.md
+++ b/en/application-dev/reference/apis/js-apis-appAccount.md
@@ -1,4 +1,4 @@
-# App Account Management
+# App Account Management
The **appAccount** module provides APIs for app account management. You can use the APIs to add, delete, query, modify, and authorize app accounts, write data to disks, and synchronize data.
@@ -154,7 +154,7 @@ Implicitly adds an app account based on the specified account owner, authenticat
}
const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.addAccountImplicitly("LiSi", "readAge", {}, {
+ appAccountManager.addAccountImplicitly("com.example.ohos.accountjsdemo", "getSocialData", {}, {
onResult: onResultCallback,
onRequestRedirected: onRequestRedirectedCallback
});
@@ -321,7 +321,8 @@ Enables an app account to access an app with the given bundle name. This API use
**Example**
```js
- app_account_instance.enableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo").then(() => {
+ const appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.enableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo").then(() => {
console.log('enableAppAccess Success');
}).catch((err) => {
console.log("enableAppAccess err: " + JSON.stringify(err));
@@ -334,7 +335,7 @@ checkAppAccountSyncEnable(name: string, callback: AsyncCallback<boolean>):
Checks whether an app account allows app data synchronization. This API uses an asynchronous callback to return the result.
-**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC (available only to system applications)
+**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
**System capability**: SystemCapability.Account.AppAccount
@@ -361,7 +362,7 @@ checkAppAccountSyncEnable(name: string): Promise<boolean>
Checks whether an app account allows app data synchronization. This API uses a promise to return the result.
-**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC (available only to system applications)
+**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
**System capability**: SystemCapability.Account.AppAccount
@@ -510,7 +511,7 @@ setAppAccountSyncEnable(name: string, isEnable: boolean, callback: AsyncCallback
Sets whether to enable app data synchronization for an app account. This API uses an asynchronous callback to return the result.
-**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC (available only to system applications)
+**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
**System capability**: SystemCapability.Account.AppAccount
@@ -537,7 +538,7 @@ setAppAccountSyncEnable(name: string, isEnable: boolean): Promise<void>
Sets whether to enable app data synchronization for an app account. This API uses a promise to return the result.
-**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC (available only to system applications)
+**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
**System capability**: SystemCapability.Account.AppAccount
@@ -585,7 +586,8 @@ Sets data to be associated with an app account. This API uses an asynchronous ca
**Example**
```js
- app_account_instance.setAssociatedData("ZhangSan", "k001", "v001", (err) => {
+ const appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.setAssociatedData("ZhangSan", "k001", "v001", (err) => {
console.log("setAssociatedData err: " + JSON.stringify(err));
});
```
@@ -795,6 +797,35 @@ Obtains data associated with an app account. This API uses a promise to return t
});
```
+### getAssociatedDataSync9+
+
+getAssociatedDataSync(name: string, key: string): string;
+
+Obtains the data associated with this app account. This API returns the result synchronously.
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ---- | ------ | ---- | --------- |
+| name | string | Yes | Name of the target app account. |
+| key | string | Yes | Key of the data to obtain.|
+
+**Return value**
+
+| Type | Description |
+| :-------------------- | :-------------------- |
+| string | Data obtained.|
+
+**Example**
+
+ ```js
+ const appAccountManager = account_appAccount.createAppAccountManager();
+ var backData = appAccountManager.getAssociatedDataSync("ZhangSan", "k001");
+ console.info("getAssociatedDataSync backData:" + JSON.stringify(backData));
+ ```
+
### getAllAccessibleAccounts
getAllAccessibleAccounts(callback: AsyncCallback<Array<AppAccountInfo>>): void
@@ -868,7 +899,7 @@ Obtains information about all app accounts of the specified app. This API uses a
**Example**
```js
- const appAccountManager = account.createAppAccountManager();
+ const appAccountManager = account_appAccount.createAppAccountManager();
const selfBundle = "com.example.actsgetallaaccounts";
appAccountManager.getAllAccounts(selfBundle, (err, data)=>{
console.debug("getAllAccounts err:" + JSON.stringify(err));
@@ -929,7 +960,7 @@ Subscribes to the account change events of the specified account owners. This AP
**Example**
```js
- const appAccountManager = account.createAppAccountManager();
+ const appAccountManager = account_appAccount.createAppAccountManager();
function changeOnCallback(data){
console.debug("receive change data:" + JSON.stringify(data));
}
@@ -959,7 +990,7 @@ Unsubscribes from the account change events. This API uses an asynchronous callb
**Example**
```js
- const appAccountManager = account.createAppAccountManager();
+ const appAccountManager = account_appAccount.createAppAccountManager();
function changeOnCallback(data){
console.debug("receive change data:" + JSON.stringify(data));
appAccountManager.off('change', function(){
@@ -1010,7 +1041,7 @@ Authenticates an app account to obtain an Open Authorization (OAuth) token. This
}
const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.authenticate("LiSi", "com.example.ohos.accountjsdemo", "readAge", {}, {
+ appAccountManager.authenticate("LiSi", "com.example.ohos.accountjsdemo", "getSocialData", {}, {
onResult: onResultCallback,
onRequestRedirected: onRequestRedirectedCallback
});
@@ -1037,7 +1068,7 @@ Obtains the OAuth token of an app account based on the specified authentication
```js
const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.getOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge", (err, data) => {
+ appAccountManager.getOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "getSocialData", (err, data) => {
console.log('getOAuthToken err: ' + JSON.stringify(err));
console.log('getOAuthToken token: ' + data);
});
@@ -1069,7 +1100,7 @@ Obtains the OAuth token of an app account based on the specified authentication
```js
const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.getOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge").then((data) => {
+ appAccountManager.getOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "getSocialData").then((data) => {
console.log('getOAuthToken token: ' + data);
}).catch((err) => {
console.log("getOAuthToken err: " + JSON.stringify(err));
@@ -1097,7 +1128,7 @@ Sets an OAuth token for an app account. This API uses an asynchronous callback t
```js
const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.setOAuthToken("LiSi", "readAge", "xxxx", (err) => {
+ appAccountManager.setOAuthToken("LiSi", "getSocialData", "xxxx", (err) => {
console.log('setOAuthToken err: ' + JSON.stringify(err));
});
```
@@ -1128,7 +1159,7 @@ Sets an OAuth token for an app account. This API uses a promise to return the re
```js
const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.setOAuthToken("LiSi", "readAge", "xxxx").then(() => {
+ appAccountManager.setOAuthToken("LiSi", "getSocialData", "xxxx").then(() => {
console.log('setOAuthToken successfully');
}).catch((err) => {
console.log('setOAuthToken err: ' + JSON.stringify(err));
@@ -1157,7 +1188,7 @@ Deletes the specified OAuth token for an app account. This API uses an asynchron
```js
const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.deleteOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge", "xxxxx", (err) => {
+ appAccountManager.deleteOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "getSocialData", "xxxxx", (err) => {
console.log('deleteOAuthToken err: ' + JSON.stringify(err));
});
```
@@ -1189,7 +1220,7 @@ Deletes the specified OAuth token for an app account. This API uses a promise to
```js
const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.deleteOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge", "xxxxx").then(() => {
+ appAccountManager.deleteOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "getSocialData", "xxxxx").then(() => {
console.log('deleteOAuthToken successfully');
}).catch((err) => {
console.log("deleteOAuthToken err: " + JSON.stringify(err));
@@ -1218,7 +1249,7 @@ Sets the visibility of an OAuth token to an app. This API uses an asynchronous c
```js
const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.setOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true, (err) => {
+ appAccountManager.setOAuthTokenVisibility("LiSi", "getSocialData", "com.example.ohos.accountjsdemo", true, (err) => {
console.log('setOAuthTokenVisibility err: ' + JSON.stringify(err));
});
```
@@ -1250,7 +1281,7 @@ Sets the visibility of an OAuth token to an app. This API uses a promise to retu
```js
const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.setOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true).then(() => {
+ appAccountManager.setOAuthTokenVisibility("LiSi", "getSocialData", "com.example.ohos.accountjsdemo", true).then(() => {
console.log('setOAuthTokenVisibility successfully');
}).catch((err) => {
console.log('setOAuthTokenVisibility err: ' + JSON.stringify(err));
@@ -1278,7 +1309,7 @@ Checks whether an OAuth token is visible to an app. This API uses an asynchronou
```js
const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.checkOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true, (err, data) => {
+ appAccountManager.checkOAuthTokenVisibility("LiSi", "getSocialData", "com.example.ohos.accountjsdemo", (err, data) => {
console.log('checkOAuthTokenVisibility err: ' + JSON.stringify(err));
console.log('checkOAuthTokenVisibility isVisible: ' + data);
});
@@ -1310,7 +1341,7 @@ Checks whether an OAuth token is visible to an app. This API uses a promise to r
```js
const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.checkOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true).then((data) => {
+ appAccountManager.checkOAuthTokenVisibility("LiSi", "getSocialData", "com.example.ohos.accountjsdemo").then((data) => {
console.log('checkOAuthTokenVisibility isVisible: ' + data);
}).catch((err) => {
console.log('checkOAuthTokenVisibility err: ' + JSON.stringify(err));
@@ -1369,7 +1400,7 @@ Obtains all OAuth tokens visible to the caller for an app account. This API uses
```js
const appAccountManager = account_appAccount.createAppAccountManager();
appAccountManager.getAllOAuthTokens("LiSi", "com.example.ohos.accountjsdemo").then((data) => {
- console.log('getAllOAuthTokens data: ' + JSON.stringify(data));
+ console.log('getAllOAuthTokens data: ' + JSON.stringify(data));
}).catch((err) => {
console.log("getAllOAuthTokens err: " + JSON.stringify(err));
});
@@ -1395,7 +1426,7 @@ Obtains a list of authorized OAuth tokens of an app account. This API uses an as
```js
const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.getOAuthList("com.example.ohos.accountjsdemo", "readAge", (err, data) => {
+ appAccountManager.getOAuthList("com.example.ohos.accountjsdemo", "getSocialData", (err, data) => {
console.log('getOAuthList err: ' + JSON.stringify(err));
console.log('getOAuthList data: ' + JSON.stringify(data));
});
@@ -1426,7 +1457,7 @@ Obtains a list of authorized OAuth tokens of an app account. This API uses a pro
```js
const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.getOAuthList("com.example.ohos.accountjsdemo", "readAge").then((data) => {
+ appAccountManager.getOAuthList("com.example.ohos.accountjsdemo", "getSocialData").then((data) => {
console.log('getOAuthList data: ' + JSON.stringify(data));
}).catch((err) => {
console.log("getOAuthList err: " + JSON.stringify(err));
@@ -1462,9 +1493,9 @@ Obtains the authenticator callback for an authentication session. This API uses
}
var result = {[account_appAccount.Constants.KEY_NAME]: "LiSi",
[account_appAccount.Constants.KEY_OWNER]: "com.example.ohos.accountjsdemo",
- [account_appAccount.Constants.KEY_AUTH_TYPE]: "readAge",
+ [account_appAccount.Constants.KEY_AUTH_TYPE]: "getSocialData",
[account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"};
- callback.OnResult(account_appAccount.ResultCode.SUCCESS, result);
+ callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
});
});
```
@@ -1492,15 +1523,17 @@ Obtains the authenticator callback for an authentication session. This API uses
**Example**
```js
+ import featureAbility from '@ohos.ability.featureAbility';
+
const appAccountManager = account_appAccount.createAppAccountManager();
featureAbility.getWant().then((want) => {
var sessionId = want.parameters[account_appAccount.Constants.KEY_SESSION_ID];
appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => {
var result = {[account_appAccount.Constants.KEY_NAME]: "LiSi",
[account_appAccount.Constants.KEY_OWNER]: "com.example.ohos.accountjsdemo",
- [account_appAccount.Constants.KEY_AUTH_TYPE]: "readAge",
+ [account_appAccount.Constants.KEY_AUTH_TYPE]: "getSocialData",
[account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"};
- callback.OnResult(account_appAccount.ResultCode.SUCCESS, result);
+ callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
}).catch((err) => {
console.log("getAuthenticatorCallback err: " + JSON.stringify(err));
});
@@ -1578,7 +1611,7 @@ Checks whether an app account is authorized to access an app. This API uses an a
| Name | Type | Mandatory | Description |
| ---------- | ---------------------------- | ----- | ---------------- |
| name | string | Yes | Name of the target app account. |
-| bundleName | string | Yes | Bundle name of the app to access.|
+| bundleName | string | Yes | Bundle name of the app to access. |
| callback | AsyncCallback<boolean> | Yes | Callback invoked to return the result. |
**Example**
@@ -1604,7 +1637,7 @@ Checks whether an app account is authorized to access an app. This API uses a pr
| Name | Type | Mandatory | Description |
| ---------- | ------ | ----- | ---------------- |
| name | string | Yes | Name of the target app account. |
-| bundleName | string | Yes | Bundle name of the app to access.|
+| bundleName | string | Yes | Bundle name of the app to access. |
**Parameters**
@@ -1702,7 +1735,8 @@ Checks whether an app account has specific labels. This API uses an asynchronous
```js
const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.checkAccountLabels("zhangsan", "com.example.ohos.accountjsdemo", (err, data) => {
+ var labels = ["student"];
+ appAccountManager.checkAccountLabels("zhangsan", "com.example.ohos.accountjsdemo", labels, (err, data) => {
console.log('checkAccountLabels: ' + JSON.stringify(data));
console.log("checkAccountLabels err: " + JSON.stringify(err));
});
@@ -1734,7 +1768,8 @@ Checks whether an app account has specific labels. This API uses a promise to re
```js
const appAccountManager = account_appAccount.createAppAccountManager();
- appAccountManager.checkAccountLabels("zhangsan", "com.example.ohos.accountjsdemo").then((data) => {
+ var labels = ["student"];
+ appAccountManager.checkAccountLabels("zhangsan", "com.example.ohos.accountjsdemo", labels).then((data) => {
console.log('checkAccountLabels: ' + JSON.stringify(data));
}).catch((err) => {
console.log("checkAccountLabels err: " + JSON.stringify(err));
@@ -1944,7 +1979,7 @@ Defines app account information.
| Name | Type | Mandatory | Description |
| ----- | ------ | ---- | ----------- |
| owner | string | Yes | Owner of the app account. The value is the bundle name of the app.|
-| name | string | Yes | Name of the target app account. |
+| name | string | Yes | Name of the app account. |
## OAuthTokenInfo8+
@@ -1967,8 +2002,8 @@ Defines OAuth authenticator information.
| Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ---------- |
| owner | string | Yes | Owner of the authenticator. The value is the bundle name of the app.|
-| iconId | string | Yes | ID of the authenticator icon. |
-| labelId | string | Yes | ID of the authenticator label. |
+| iconId | number | Yes | ID of the authenticator icon. |
+| labelId | number | Yes | ID of the authenticator label. |
## SelectAccountsOptions9+
@@ -2082,9 +2117,9 @@ Called to return the result of an authentication request.
appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => {
var result = {[account_appAccount.Constants.KEY_NAME]: "LiSi",
[account_appAccount.Constants.KEY_OWNER]: "com.example.ohos.accountjsdemo",
- [account_appAccount.Constants.KEY_AUTH_TYPE]: "readAge",
+ [account_appAccount.Constants.KEY_AUTH_TYPE]: "getSocialData",
[account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"};
- callback.OnResult(account_appAccount.ResultCode.SUCCESS, result);
+ callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
}).catch((err) => {
console.log("getAuthenticatorCallback err: " + JSON.stringify(err));
});
@@ -2137,7 +2172,7 @@ Called to continue to process the request.
const appAccountManager = account_appAccount.createAppAccountManager();
var sessionId = "1234";
appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => {
- callback.OnRequestContinued();
+ callback.onRequestContinued();
}).catch((err) => {
console.log("getAuthenticatorCallback err: " + JSON.stringify(err));
});
@@ -2167,7 +2202,7 @@ Implicitly adds an app account based on the specified authentication type and op
authenticate(name: string, authType: string, callerBundleName: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void
-Authenticates an app account to obtain the OAuth access token. This API uses an asynchronous callback to return the result.
+Authenticates an app account to obtain the OAuth token. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.AppAccount
@@ -2264,7 +2299,7 @@ Obtains the remote object of an authenticator. This API cannot be overloaded.
callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
}
- verifyCredential(name: string, options: VerifyCredentialOptions, callback: AuthenticatorCallback) {
+ verifyCredential(name, options, callback) {
callback.onRequestRedirected({
bundleName: "com.example.ohos.accountjsdemo",
abilityName: "com.example.ohos.accountjsdemo.VerifyAbility",
@@ -2274,11 +2309,11 @@ Obtains the remote object of an authenticator. This API cannot be overloaded.
});
}
- setProperties(options: SetPropertiesOptions, callback: AuthenticatorCallback) {
+ setProperties(options, callback) {
callback.onResult(account_appAccount.ResultCode.SUCCESS, {});
}
- checkAccountLabels(name: string, labels: Array, callback: AuthenticatorCallback) {
+ checkAccountLabels(name, labels, callback) {
var result = {[account_appAccount.Constants.KEY_BOOLEAN_RESULT]: false};
callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
}
diff --git a/en/application-dev/reference/apis/js-apis-application-Want.md b/en/application-dev/reference/apis/js-apis-application-Want.md
index fd15443a5b2ac2b28642a0c89d441cdbee5d6866..b7f2605363e849a8d5531b9ebda7d2277a2fd11c 100644
--- a/en/application-dev/reference/apis/js-apis-application-Want.md
+++ b/en/application-dev/reference/apis/js-apis-application-Want.md
@@ -49,6 +49,7 @@ import Want from '@ohos.application.Want';
- Passing a file descriptor (FD)
``` js
+ import fileio from '@ohos.fileio';
var fd;
try {
fd = fileio.openSync("/data/storage/el2/base/haps/pic.png");
@@ -59,9 +60,9 @@ import Want from '@ohos.application.Want';
"deviceId": "", // An empty deviceId indicates the local device.
"bundleName": "com.extreme.test",
"abilityName": "MainAbility",
- "moduleName": "entry" // moduleName is optional.
+ "moduleName": "entry", // moduleName is optional.
"parameters": {
- "keyFd":{"type":"FD", "value":fd}
+ "keyFd":{"type":"FD", "value":fd}
}
};
this.context.startAbility(want, (error) => {
diff --git a/en/application-dev/reference/apis/js-apis-application-WindowExtensionAbility.md b/en/application-dev/reference/apis/js-apis-application-WindowExtensionAbility.md
index 8a366b1e21bb988c608ba0a5e57251f2bd237d75..3509cdff1bc50c134be76aa4a90742cb3a14f778 100644
--- a/en/application-dev/reference/apis/js-apis-application-WindowExtensionAbility.md
+++ b/en/application-dev/reference/apis/js-apis-application-WindowExtensionAbility.md
@@ -25,56 +25,25 @@ import WindowExtensionAbility from '@ohos.application.WindowExtensionAbility';
## WindowExtensionAbility.onConnect
-onConnect(want: Want): rpc.RemoteObject
+onConnect(want: Want): void
Called when this Window Extension ability is connected to an ability for the first time.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
+**Parameters**
+
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| want | [Want](js-apis-application-Want.md) | Yes| Information related to this Window Extension ability, including the ability name and bundle name. |
-
-**Return value**
-| Type | Description |
-| ----------------------------------------------- | -------------------- |
-| [rpc.RemoteObject](js-apis-rpc.md#remoteobject) | Proxy of this Window Extension ability.|
+| want | [Want](js-apis-application-Want.md) | Yes| Information related to this Window Extension ability, including the ability name and bundle name.|
**Example**
```ts
-import rpc from '@ohos.rpc';
-
-class StubTest extends rpc.RemoteObject {
- constructor(des) {
- super(des);
- }
- onRemoteRequest(code, data, reply, option) {
- return true;
- }
- queryLocalInterface(descriptor) {
- return null;
- }
- getInterfaceDescriptor() {
- return "";
- }
- sendRequest(code, data, reply, options) {
- return null;
- }
- getCallingPid() {
- return 1;
- }
- getCallingUid() {
- return 1;
- }
- attachLocalInterface(localInterface, descriptor){}
-}
-
export default class MyWindowExtensionAbility extends WindowExtensionAbility {
- onConnect(want): rpc.RemoteObject {
+ onConnect(want) {
console.info('WindowExtAbility onConnect ' + want.abilityName);
- return new StubTest("test");
}
}
@@ -88,9 +57,11 @@ Called when this Window Extension ability is disconnected from all connected abi
**System capability**: SystemCapability.WindowManager.WindowManager.Core
+**Parameters**
+
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| want | [Want](js-apis-application-Want.md) | Yes| Information related to this Window Extension ability, including the ability name and bundle name. |
+| want | [Want](js-apis-application-Want.md) | Yes| Information related to this Window Extension ability, including the ability name and bundle name.|
**Example**
@@ -105,7 +76,6 @@ export default class MyWindowExtensionAbility extends WindowExtensionAbility {
}
```
-
## WindowExtensionAbility.onWindowReady
onWindowReady(window: Window): void
@@ -114,6 +84,8 @@ Called when a window is ready.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
+**Parameters**
+
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| window | [Window](js-apis-window.md) | Yes| Current **Window** instance.|
@@ -127,7 +99,7 @@ export default class MyWindowExtensionAbility extends WindowExtensionAbility {
onWindowReady(window) {
window.loadContent('WindowExtAbility/pages/index1').then(() => {
window.getProperties().then((pro) => {
- console.log("WindowExtension " + JSON.stringify(pro));
+ console.log('WindowExtension ' + JSON.stringify(pro));
})
window.show();
})
diff --git a/en/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md b/en/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md
index 7c5ba607718d5d14317a55645627022b78976461..57a313f1f600607c143aaec48205a482221ba355 100644
--- a/en/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md
+++ b/en/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md
@@ -26,7 +26,7 @@ Callback of the common event of a static subscriber.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
- | event | CommonEventData | Yes| Common event of a static subscriber.|
+ | event | [CommonEventData](js-apis-commonEvent.md#commoneventdata) | Yes| Common event of a static subscriber.|
**Example**
diff --git a/en/application-dev/reference/apis/js-apis-audio.md b/en/application-dev/reference/apis/js-apis-audio.md
index f019d61969e28699cc1324a6f8d8af29ba7d60f6..7fa4e76c7a448d1272d1a50b8da71e0303b27762 100644
--- a/en/application-dev/reference/apis/js-apis-audio.md
+++ b/en/application-dev/reference/apis/js-apis-audio.md
@@ -4911,7 +4911,7 @@ audioCapturer.getBufferSize().then((data) => {
console.info(`AudioFrameworkRecLog: getBufferSize: SUCCESS ${data}`);
bufferSize = data;
}).catch((err) => {
- console.error(`AudioFrameworkRecLog: getBufferSize: EROOR: ${err}`);
+ console.error(`AudioFrameworkRecLog: getBufferSize: ERROR: ${err}`);
});
audioCapturer.read(bufferSize, true, async(err, buffer) => {
if (!err) {
diff --git a/en/application-dev/reference/apis/js-apis-buffer.md b/en/application-dev/reference/apis/js-apis-buffer.md
new file mode 100644
index 0000000000000000000000000000000000000000..b1c81e2eecd00b5043bb703b574bcc0c06533373
--- /dev/null
+++ b/en/application-dev/reference/apis/js-apis-buffer.md
@@ -0,0 +1,2445 @@
+# Buffer
+
+> **NOTE**
+>
+> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+
+A **Buffer** object represents a fixed-length sequence of bytes. It is used to store binary data.
+
+You can use the APIs provided by the **Buffer** module to process images and a large amount of binary data, and receive or upload files.
+
+## Modules to Import
+
+```ts
+import buffer from '@ohos.buffer';
+```
+
+## Buffer
+
+### alloc
+
+alloc(size: number, fill?: string | Buffer | number, encoding?: BufferEncoding): Buffer
+
+Allocates and initializes a **Buffer** instance of the specified size.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| size | number | Yes| Size of the **Buffer** instance to allocate, in bytes.|
+| fill | string \| Buffer \| number | No| Pre-filled value. The default value is **0**.|
+| encoding | BufferEncoding | No| Encoding format (valid only when **fill** is a string). The default value is **utf-8**.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Buffer | Initialized **Buffer** instance.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf1 = buffer.alloc(5);
+let buf2 = buffer.alloc(5, 'a');
+let buf3 = buffer.alloc(11, 'aGVsbG8gd29ybGQ=', 'base64');
+```
+
+### allocUninitializedFromPool
+
+allocUninitializedFromPool(size: number): Buffer
+
+Allocates a **Buffer** instance of the specified size from the buffer pool, without initializing it.
+To initialize the **Buffer** instance, call **fill()**.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| size | number | Yes| Size of the **Buffer** instance to allocate, in bytes.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Buffer | Uninitialized **Buffer** instance.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.allocUninitializedFromPool(10);
+buf.fill(0);
+```
+
+### allocUninitialized
+
+allocUninitialized(size: number): Buffer
+
+Allocates a **Buffer** instance of the specified size, without initializing it. This API does not allocate memory from the buffer pool.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| size | number | Yes|Size of the **Buffer** instance to allocate, in bytes.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Buffer | Uninitialized **Buffer** instance.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.allocUninitialized(10);
+buf.fill(0);
+```
+
+### byteLength
+
+byteLength(string: string | Buffer | TypedArray | DataView | ArrayBuffer | SharedArrayBuffer, encoding?: BufferEncoding): number
+
+Obtains the number of bytes of a string based on the encoding format.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| string | string \| Buffer \| TypedArray \| DataView \| ArrayBuffer \| SharedArrayBuffer | Yes| Target string.|
+| encoding | BufferEncoding | No| Encoding format. The default value is **utf-8**.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| number | Number of bytes of the string.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let str = '\u00bd + \u00bc = \u00be';
+console.log(`${str}: ${str.length} characters, ${buffer.byteLength(str, 'utf-8')} bytes`);
+// Print: ½ + ¼ = ¾: 9 characters, 12 bytes
+```
+
+### compare
+
+compare(buf1: Buffer | Uint8Array, buf2: Buffer | Uint8Array): -1 | 0 | 1
+
+Compares two **Buffer** instances. This API is used for sorting **Buffer** instances.
+
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| buf1 | Buffer \| Uint8Array | Yes| **Buffer** instance to compare.|
+| buf2 | Buffer \| Uint8Array | Yes| **Buffer** instance to compare.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| -1 \| 0 \| 1 | Returns **0** if **buf1** is the same as **buf2**.
Returns **1** if **buf1** comes after **buf2** when sorted.
Returns **-1** if **buf1** comes before **buf2** when sorted.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf1 = buffer.from('1234');
+let buf2 = buffer.from('0123');
+let res = buf1.compare(buf2);
+
+console.log(Number(res).toString());
+// Print 1
+```
+
+### concat
+
+concat(list: Buffer[] | Uint8Array[], totalLength?: number): Buffer
+
+Concatenates an array of **Buffer** instances into a new instance of the specified length.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| list | Buffer[] \| Uint8Array[] | Yes| Array of instances to concatenate.|
+| totalLength | number | No| Total length of the new **Buffer** instance, in bytes.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Buffer | **Buffer** instance created.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf1 = buffer.from("1234");
+let buf2 = buffer.from("abcd");
+let buf = buffer.concat([buf1, buf2]);
+console.log(buf.toString('hex')); // 3132333461626364
+```
+
+### from
+
+from(array: number[]): Buffer;
+
+Creates a **Buffer** instance with the specified array.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| array | number[] | Yes| Array to create a **Buffer** instance.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Buffer | **Buffer** instance created.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]);
+console.log(buf.toString('hex')); // 627566666572
+```
+
+### from
+
+from(arrayBuffer: ArrayBuffer | SharedArrayBuffer, byteOffset?: number, length?: number): Buffer
+
+Creates a **Buffer** instance that shares memory with the specified array of **Buffer** instances.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| arrayBuffer | ArrayBuffer \| SharedArrayBuffer | Yes| Array of **Buffer** instances, whose memory is to be shared.|
+| byteOffset | number | No| Byte offset. The default value is **0**.|
+| length | number | No| Length of the **Buffer** instance to create, in bytes. The default value is the length of **arrayBuffer** minus **byteOffset**.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Buffer | **Buffer** instance with shared memory.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let ab = new ArrayBuffer(10);
+let buf = buffer.from(ab, 0, 2);
+```
+
+### from
+
+from(buffer: Buffer | Uint8Array): Buffer
+
+Creates a **Buffer** instance with the copy of another instance.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| buffer | Buffer \| Uint8Array | Yes| **Buffer** instance to copy. |
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Buffer | **Buffer** instance created.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf1 = buffer.from('buffer');
+let buf2 = buffer.from(buf1);
+```
+
+### from
+
+from(object: Object, offsetOrEncoding: number | string, length: number): Buffer
+
+Creates a **Buffer** instance based on the specified object.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| object | Object | Yes| Object that supports **Symbol.toPrimitive** or **valueOf()**.|
+| offsetOrEncoding | number \| string | No| Byte offset or encoding format.|
+| length | number | No| Length of the **Buffer** instance to create.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Buffer | **Buffer** instance created.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.from(new String('this is a test'));
+```
+
+### from
+
+from(string: String, encoding?: BufferEncoding): Buffer
+
+Creates a **Buffer** instance based on a string in the given encoding format.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| string | String | Yes| String.|
+| encoding | BufferEncoding | No| Encoding format of the string. The default value is **utf-8**.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Buffer | **Buffer** instance created.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf1 = buffer.from('this is a test');
+let buf2 = buffer.from('7468697320697320612074c3a97374', 'hex');
+
+console.log (buf1.toString()); // Print: this is a test
+console.log(buf2.toString());
+```
+
+
+### isBuffer
+
+isBuffer(obj: Object): boolean
+
+Checks whether the specified object is a **Buffer** instance.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| obj | Object | Yes| Object to check.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| boolean | Returns **true** if the object is a **Buffer** instance; returns **false** otherwise.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+buffer.isBuffer(buffer.alloc(10)); // true
+buffer.isBuffer(buffer.from('foo')); // true
+buffer.isBuffer('a string'); // false
+buffer.isBuffer([]); // false
+buffer.isBuffer(new Uint8Array(1024)); // false
+```
+
+### isEncoding
+
+isEncoding(encoding: string): boolean
+
+Checks whether the encoding format is supported.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| encoding | string | Yes| Encoding format to check. |
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| boolean | Returns **true** if the encoding format is supported; returns **false** otherwise.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+console.log(buffer.isEncoding('utf-8').toString()); // Print: true
+console.log(buffer.isEncoding('hex').toString()); // Print: true
+console.log(buffer.isEncoding('utf/8').toString()); // Print: false
+console.log(buffer.isEncoding('').toString()); // Print: false
+```
+
+### compare
+
+compare(target: Buffer | Uint8Array, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): -1 | 0 | 1
+
+Compares this **Buffer** instance with another instance.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| target | Buffer \| Uint8Array | Yes| Target **Buffer** instance to compare.|
+| targetStart | number | No| Offset to the start of the data to compare in the target **Buffer** instance. The default value is **0**.|
+| targetEnd | number | No| Offset to the end of the data to compare in the target **Buffer** instance (not inclusive). The default value is the length of the target **Buffer** instance.|
+| sourceStart | number | No| Offset to the start of the data to compare in this **Buffer** instance. The default value is **0**.|
+| sourceEnd | number | No| Offset to the end of the data to compare in this **Buffer** instance (not inclusive). The default value is the length of this **Buffer** instance.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| number | Returns **0** if the two **Buffer** instances are the same.
Returns **1** if this instance comes after the target instance when sorted.
Returns **-1** if this instance comes before the target instance when sorted. |
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf1 = buffer.from([1, 2, 3, 4, 5, 6, 7, 8, 9]);
+let buf2 = buffer.from([5, 6, 7, 8, 9, 1, 2, 3, 4]);
+
+console.log(buf1.compare(buf2, 5, 9, 0, 4).toString()); // Print: 0
+console.log(buf1.compare(buf2, 0, 6, 4).toString()); // Print: -1
+console.log(buf1.compare(buf2, 5, 6, 5).toString()); // Print: 1
+```
+
+### copy
+
+copy(target: Buffer| Uint8Array, targetStart?: number, sourceStart?: number, sourceEnd?: number): number
+
+Copies data at the specified position in this **Buffer** instance to the specified position in another **Buffer** instance.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| target | Buffer \| Uint8Array | Yes| Instance to which data is copied.|
+| targetStart | number | No| Offset to the start position in the target instance where data is copied. The default value is **0**.|
+| sourceStart | number | No| Offset to the start position in this **Buffer** instance where data is copied. The default value is **0**.|
+| sourceEnd | number | No| Offset to the end position in this **Buffer** instance (not inclusive). The default value is the length of this **Buffer** instance.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| number | Total length of the data copied, in bytes.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf1 = buffer.allocUninitializedFromPool(26);
+let buf2 = buffer.allocUninitializedFromPool(26).fill('!');
+
+for (let i = 0; i < 26; i++) {
+ buf1[i] = i + 97;
+}
+
+buf1.copy(buf2, 8, 16, 20);
+console.log(buf2.toString('ascii', 0, 25));
+// Print: !!!!!!! qrst!!!!!!!!!!!!!
+```
+
+### entries
+
+entries(): IterableIterator<[number, number]>
+
+Creates and returns an iterator that contains key-value pairs of this **Buffer** instance.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.from('buffer');
+for (let pair of buf.entries()) {
+ console.log(pair.toString());
+}
+```
+
+### equals
+
+equals(otherBuffer: Uint8Array | Buffer): boolean
+
+Checks whether this **Buffer** instance is the same as another **Buffer** instance.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| otherBuffer | Uint8Array \| Buffer | Yes| **Buffer** instance to compare.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| boolean | Returns **true** if the two instances are the same; returns **false** otherwise.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf1 = buffer.from('ABC');
+let buf2 = buffer.from('414243', 'hex');
+let buf3 = buffer.from('ABCD');
+
+console.log(buf1.equals(buf2).toString()); // Print: true
+console.log(buf1.equals(buf3).toString()); // Print: false
+
+```
+
+### fill
+
+fill(value: string | Buffer | Uint8Array | number, offset?: number, end?: number, encoding?: BufferEncoding): Buffer
+
+Fills this **Buffer** instance at the specified position. By default, data is filled cyclically.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| value | string \| Buffer \| Uint8Array \| number | Yes| Value to fill.|
+| offset | number | No| Offset to the start position in this **Buffer** instance where data is filled. The default value is **0**.|
+| end | number | No| Offset to the end position in this **Buffer** instance (not inclusive). The default value is the length of this **Buffer** instance.|
+| encoding | BufferEncoding | No| Encoding format (valid only when **value** is a string). The default value is **utf-8**.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Buffer | **Buffer** instance filled with the specified value.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let b = buffer.allocUninitializedFromPool(50).fill('h');
+console.log(b.toString());
+```
+
+
+### includes
+
+includes(value: string | number | Buffer | Uint8Array, byteOffset?: number, encoding?: BufferEncoding): boolean
+
+Checks whether this **Buffer** instance contains the specified value.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| value | string \| number \| Buffer \| Uint8Array | Yes| Value to match.|
+| byteOffset | number | No| Number of bytes to skip before starting to check data. If the offset is a negative number, data is checked from the end of the **Buffer** instance. The default value is **0**. |
+| encoding | BufferEncoding | No| Encoding format used if **value** is a string. The default value is **utf-8**.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| boolean | Returns **true** if the instance contains the specified value; returns **false** otherwise.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.from('this is a buffer');
+console.log(buf.includes('this').toString()); // Print: true
+console.log(buf.includes('be').toString()); // Print: false
+```
+
+### indexOf
+
+indexOf(value: string | number | Buffer | Uint8Array, byteOffset?: number, encoding?: BufferEncoding): number
+
+Obtains the index of the first occurrence of the specified value in this **Buffer** instance.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| value | string \| number \| Buffer \| Uint8Array | Yes| Value to match.|
+| byteOffset | number | No| Number of bytes to skip before starting to check data. If the offset is a negative number, data is checked from the end of the **Buffer** instance. The default value is **0**. |
+| encoding | BufferEncoding | No| Encoding format used if **value** is a string. The default value is **utf-8**.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| number | Index obtained.
If **-1** is returned, the **Buffer** instance does not contain the specified value.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.from('this is a buffer');
+console.log(buf.indexOf('this').toString()); // Print: 0
+console.log(buf.indexOf('is').toString()); // Print: 2
+```
+
+### keys
+
+keys(): IterableIterator<number>
+
+Creates and returns an iterator that contains the keys of this **Buffer** instance.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| IterableIterator<number> | Iterator.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.from('buffer');
+for (const key of buf.keys()) {
+ console.log(key.toString());
+}
+```
+
+### lastIndexOf
+
+lastIndexOf(value: string | number | Buffer | Uint8Array, byteOffset?: number, encoding?: BufferEncoding): number
+
+Obtains the index of the last occurrence of the specified value in this **Buffer** instance.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| value | string \| number \| Buffer \| Uint8Array | Yes| Value to match.|
+| byteOffset | number | No| Number of bytes to skip before starting to check data. If the offset is a negative number, data is checked from the end of the **Buffer** instance. The default value is **0**. |
+| encoding | BufferEncoding | No| Encoding format used if **value** is a string. The default value is **utf-8**.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| number | Index obtained.
If **-1** is returned, the **Buffer** instance does not contain the specified value.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.from('this buffer is a buffer');
+console.log(buf.lastIndexOf('this').toString()); // Print: 0
+console.log(buf.lastIndexOf('buffer').toString()); // Print: 17
+```
+
+
+### readBigInt64BE
+
+readBigInt64BE(offset?: number): bigint
+
+Reads a signed, big-endian 64-bit Big integer from this **Buffer** instance at the specified offset.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| offset | number | No| Number of bytes to skip before starting to read data. The default value is **0**.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| bigint | A signed, big-endian 64-bit Big integer. |
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.from([0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x70,
+ 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78]);
+console.log(buf.readBigInt64BE(0).toString());
+```
+
+### readBigInt64LE
+
+readBigInt64LE(offset?: number): bigint
+
+Reads a signed, little-endian 64-bit Big integer from this **Buffer** instance at the specified offset.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| offset | number | No| Number of bytes to skip before starting to read data. The default value is **0**.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| bigint | A signed, little-endian 64-bit Big integer. |
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.from([0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x70,
+ 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78]);
+console.log(buf.readBigInt64LE(0).toString());
+```
+
+### readBigUInt64BE
+
+readBigUInt64BE(offset?: number): bigint
+
+Reads an unsigned, big-endian 64-bit Big integer from this **Buffer** instance at the specified offset.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| offset | number | No| Number of bytes to skip before starting to read data. The default value is **0**.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| bigint | An unsigned, big-endian 64-bit Big integer. |
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.from([0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x70,
+ 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78]);
+console.log(buf.readBigUInt64BE(0).toString());
+```
+
+### readBigUInt64LE
+
+readBigUInt64LE(offset?: number): bigint
+
+Reads an unsigned, little-endian 64-bit Big integer from this **Buffer** instance at the specified offset.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| offset | number | No| Number of bytes to skip before starting to read data. The default value is **0**.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| bigint | An unsigned, little-endian 64-bit Big integer. |
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.from([0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x70,
+ 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78]);
+console.log(buf.readBigUInt64LE(0).toString());
+```
+
+### readDoubleBE
+
+readDoubleBE(offset?: number): number
+
+Reads a big-endian double-precision floating-point number from this **Buffer** instance at the specified offset.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| offset | number | No| Number of bytes to skip before starting to read data. The default value is **0**.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| number | A big-endian double-precision floating-point number. |
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.from([1, 2, 3, 4, 5, 6, 7, 8]);
+console.log(buf.readDoubleBE(0).toString());
+```
+
+### readDoubleLE
+
+readDoubleLE(offset?: number): number
+
+Reads a little-endian double-precision floating-point number from this **Buffer** instance at the specified offset.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| offset | number | No| Number of bytes to skip before starting to read data. The default value is **0**.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| number | A little-endian double-precision floating-point number. |
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.from([1, 2, 3, 4, 5, 6, 7, 8]);
+console.log(buf.readDoubleLE(0).toString());
+```
+
+### readFloatBE
+
+readFloatBE(offset?: number): number
+
+Reads a big-endian single-precision floating-point number from this **Buffer** instance at the specified offset.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| offset | number | No| Number of bytes to skip before starting to read data. The default value is **0**.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| number | A big-endian single-precision floating-point number. |
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.from([1, 2, 3, 4, 5, 6, 7, 8]);
+console.log(buf.readFloatBE(0).toString());
+```
+
+### readFloatLE
+
+readFloatLE(offset?: number): number
+
+Reads a little-endian single-precision floating-point number from this **Buffer** instance at the specified offset.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| offset | number | No| Number of bytes to skip before starting to read data. The default value is **0**.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| number | A little-endian single-precision floating-point number. |
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.from([1, 2, 3, 4, 5, 6, 7, 8]);
+console.log(buf.readFloatLE(0).toString());
+```
+
+### readInt8
+
+readInt8(offset?: number): number
+
+Reads a signed 8-bit integer from this **Buffer** instance at the specified offset.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| offset | number | No| Number of bytes to skip before starting to read data. The default value is **0**.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| number | A signed 8-bit integer. |
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.from([-1, 5]);
+console.log(buf.readInt8(0).toString()); // Print: -1
+console.log(buf.readInt8(1).toString()); // Print: 5
+```
+
+### readInt16BE
+
+readInt16BE(offset?: number): number
+
+Reads a signed, big-endian 16-bit integer from this **Buffer** instance at the specified offset.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| offset | number | No| Number of bytes to skip before starting to read data. The default value is **0**.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| number | A signed, big-endian 16-bit integer.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.from([0, 5]);
+console.log(buf.readInt16BE(0).toString()); // Print: 5
+```
+
+### readInt16LE
+
+readInt16LE(offset?: number): number
+
+Reads a signed, little-endian 16-bit integer from this **Buffer** instance at the specified offset.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| offset | number | No| Number of bytes to skip before starting to read data. The default value is **0**.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| number | A signed, little-endian 16-bit integer.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.from([0, 5]);
+console.log(buf.readInt16LE(0).toString()); // Print: 1280
+```
+
+### readInt32BE
+
+readInt32BE(offset?: number): number
+
+Reads a signed, big-endian 32-bit integer from this **Buffer** instance at the specified offset.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| offset | number | No| Number of bytes to skip before starting to read data. The default value is **0**.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| number | A signed, big-endian 32-bit integer.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.from([0, 0, 0, 5]);
+console.log(buf.readInt32BE(0).toString()); // Print: 5
+```
+
+### readInt32LE
+
+readInt32LE(offset?: number): number
+
+Reads a signed, little-endian 32-bit integer from this **Buffer** instance at the specified offset.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| offset | number | No| Number of bytes to skip before starting to read data. The default value is **0**.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| number | A signed, little-endian 32-bit integer.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.from([0, 0, 0, 5]);
+console.log(buf.readInt32LE(0).toString()); // Print: 83886080
+```
+
+### readIntBE
+
+readIntBE(offset: number, byteLength: number): number
+
+Reads the specified number of bytes from this **Buffer** instance at the specified offset, and interprets the result as a big-endian, two's complement signed value that supports up to 48 bits of precision.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| offset | number | Yes| Number of bytes to skip before starting to read data. The default value is **0**.|
+| byteLength | number | Yes| Number of bytes to read.|
+
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| number | Data read.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.from("ab");
+let num = buf.readIntBE(0, 1);
+console.log(num.toString()); // 97
+```
+
+
+### readIntLE
+
+readIntLE(offset: number, byteLength: number): number
+
+Reads the specified number of bytes from this **Buffer** instance at the specified offset and interprets the result as a little-endian, two's complement signed value that supports up to 48 bits of precision.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| offset | number | Yes| Number of bytes to skip before starting to read data. The default value is **0**.|
+| byteLength | number | Yes| Number of bytes to read.|
+
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| number | Data read.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);
+console.log(buf.readIntLE(0, 6).toString(16));
+```
+
+### readUInt8
+
+readUInt8(offset?: number): number
+
+Reads an unsigned 8-bit integer from this **Buffer** instance at the specified offset.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| offset | number | No| Number of bytes to skip before starting to read data. The default value is **0**.|
+
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| number | An unsigned 8-bit integer.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.from([1, -2]);
+console.log(buf.readUInt8(0).toString());
+console.log(buf.readUInt8(1).toString());
+```
+
+### readUInt16BE
+
+readUInt16BE(offset?: number): number
+
+Reads an unsigned, big-endian 16-bit integer from this **Buffer** instance at the specified offset.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| offset | number | No| Number of bytes to skip before starting to read data. The default value is **0**.|
+
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| number | An unsigned, big-endian 16-bit integer.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.from([0x12, 0x34, 0x56]);
+console.log(buf.readUInt16BE(0).toString(16));
+console.log(buf.readUInt16BE(1).toString(16));
+```
+
+### readUInt16LE
+
+readUInt16LE(offset?: number): number
+
+Reads an unsigned, little-endian 16-bit integer from this **Buffer** instance at the specified offset.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| offset | number | No| Number of bytes to skip before starting to read data. The default value is **0**.|
+
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| number | An unsigned, little-endian 16-bit integer.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.from([0x12, 0x34, 0x56]);
+console.log(buf.readUInt16LE(0).toString(16));
+console.log(buf.readUInt16LE(1).toString(16));
+```
+
+### readUInt32BE
+
+readUInt32BE(offset?: number): number
+
+Reads an unsigned, big-endian 32-bit integer from this **Buffer** instance at the specified offset.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| offset | number | No| Number of bytes to skip before starting to read data. The default value is **0**.|
+
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| number | An unsigned, big-endian 32-bit integer.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.from([0x12, 0x34, 0x56, 0x78]);
+console.log(buf.readUInt32BE(0).toString(16));
+```
+
+### readUInt32LE
+
+readUInt32LE(offset?: number): number
+
+Reads an unsigned, little-endian 32-bit integer from this **Buffer** instance at the specified offset.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| offset | number | No| Number of bytes to skip before starting to read data. The default value is **0**.|
+
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| number | An unsigned, little-endian 32-bit integer.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.from([0x12, 0x34, 0x56, 0x78]);
+console.log(buf.readUInt32LE(0).toString(16));
+```
+
+### readUIntBE
+
+readUIntBE(offset: number, byteLength: number): number
+
+Reads the specified number of bytes from this **Buffer** instance at the specified offset, and interprets the result as an unsigned, big-endian integer that supports up to 48 bits of precision.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| offset | number | Yes| Number of bytes to skip before starting to read data. The default value is **0**.|
+| byteLength | number | Yes| Number of bytes to read.|
+
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| number | Data read.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);
+console.log(buf.readUIntBE(0, 6).toString(16));
+```
+
+### readUIntLE
+
+readUIntLE(offset: number, byteLength: number): number
+
+Reads the specified number of bytes from this **Buffer** instance at the specified offset, and interprets the result as an unsigned, little-endian integer that supports up to 48 bits of precision.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| offset | number | Yes| Number of bytes to skip before starting to read data. The default value is **0**.|
+| byteLength | number | Yes| Number of bytes to read.|
+
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| number | Data read.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);
+console.log(buf.readUIntLE(0, 6).toString(16));
+```
+
+### subarray
+
+subarray(start?: number, end?: number): Buffer
+
+Truncates this **Buffer** instance from the specified position to create a new **Buffer** instance.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| start | number | No| Offset to the start position in this **Buffer** instance where data is truncated. The default value is **0**.|
+| end | number | No| Offset to the end position in this **Buffer** instance (not inclusive). The default value is the length of this **Buffer** instance.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Buffer | **Buffer** instance created.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf1 = buffer.allocUninitializedFromPool(26);
+
+for (let i = 0; i < 26; i++) {
+ buf1[i] = i + 97;
+}
+const buf2 = buf1.subarray(0, 3);
+console.log(buf2.toString('ascii', 0, buf2.length));
+// Print: abc
+```
+
+### swap16
+
+swap16(): Buffer
+
+Interprets this **Buffer** instance as an array of unsigned 16-bit integers and swaps the byte order in place.
+
+**System capability**: SystemCapability.Utils.Lang
+
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Buffer | **Buffer** instance swapped.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf1 = buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]);
+console.log(buf1.toString('hex')); // Print: 0102030405060708
+
+buf1.swap16();
+console.log(buf1.toString('hex')); // Print: 0201040306050807
+```
+
+### swap32
+
+swap32(): Buffer
+
+Interprets this **Buffer** instance as an array of unsigned 32-bit integers and swaps the byte order in place.
+
+**System capability**: SystemCapability.Utils.Lang
+
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Buffer | **Buffer** instance swapped.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf1 = buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]);
+console.log(buf1.toString('hex')); // Print: 0102030405060708
+
+buf1.swap32();
+console.log(buf1.toString('hex')); // Print: 0403020108070605
+```
+
+### swap64
+
+swap64(): Buffer
+
+Interprets this **Buffer** instance as an array of unsigned 64-bit integers and swaps the byte order in place.
+
+**System capability**: SystemCapability.Utils.Lang
+
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Buffer | **Buffer** instance swapped.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf1 = buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]);
+console.log(buf1.toString('hex')); // Print: 0102030405060708
+buf1.swap64();
+console.log(buf1.toString('hex')); // Print: 0807060504030201
+```
+
+### toJSON
+
+toJSON(): Object
+
+Converts this **Buffer** instance into a JSON object.
+
+**System capability**: SystemCapability.Utils.Lang
+
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Object | JSON object.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf1 = buffer.from([0x1, 0x2, 0x3, 0x4, 0x5]);
+let obj = buf1.toJSON();
+console.log(JSON.stringify(obj))
+// Print: {"type":"Buffer","data":[1,2,3,4,5]}
+```
+
+### toString
+
+toString(encoding?: string, start?: number, end?: number): string
+
+Converts the data at the specified position in this **Buffer** instance into a string in the specified encoding format.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| encoding | string | No| Encoding format of the string. The default value is **utf-8**.|
+| start | number | No| Offset to the start position of the data to convert. The default value is **0**.|
+| end | number | No| Offset to the end position of the data to convert. The default value is the length of this **Buffer** instance.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| string | String obtained.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf1 = buffer.allocUninitializedFromPool(26);
+for (let i = 0; i < 26; i++) {
+ buf1[i] = i + 97;
+}
+console.log(buf1.toString('utf-8'));
+// Print: abcdefghijklmnopqrstuvwxyz
+```
+
+### values
+
+values(): IterableIterator<number>
+
+Creates and returns an iterator that contains the values of this **Buffer** instance.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| IterableIterator<number> | Iterator created.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf1 = buffer.from('buffer');
+for (let value of buf1.values()) {
+ console.log(value.toString());
+}
+```
+
+### write
+
+write(str: string, offset?: number, length?: number, encoding?: string): number
+
+Writes a string of the specified length to this **Buffer** instance at the specified position in the given encoding format.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| str | string | Yes| String to write.|
+| offset | number | No| Number of bytes to skip before starting to write data. The default value is **0**.|
+| length | number | No| Maximum number of bytes to write. The default value is the length of the **Buffer** instance minus the offset.|
+| encoding | BufferEncoding | No| Encoding format of the string. The default value is **utf-8**.|
+
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| number | Number of bytes written.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.alloc(256);
+let len = buf.write('\u00bd + \u00bc = \u00be', 0);
+console.log(`${len} bytes: ${buf.toString('utf-8', 0, len)}`);
+// Print: 12 bytes: ½ + ¼ = ¾
+
+let buffer1 = buffer.alloc(10);
+let length = buffer1.write('abcd', 8);
+```
+
+### writeBigInt64BE
+
+writeBigInt64BE(value: bigint, offset?: number): number
+
+Writes a signed, big-endian 64-bit Big integer to this **Buffer** instance at the specified offset.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| value | bigint | Yes| Data to write.|
+| offset | number | No| Number of bytes to skip before starting to write data. The default value is **0**.|
+
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| number | Number of bytes written.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.allocUninitializedFromPool(8);
+buf.writeBigInt64BE(0x0102030405060708n, 0);
+```
+
+### writeBigInt64LE
+
+writeBigInt64LE(value: bigint, offset?: number): number
+
+Writes a signed, little-endian 64-bit Big integer to this **Buffer** instance at the specified offset.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| value | bigint | Yes| Data to write.|
+| offset | number | No| Number of bytes to skip before starting to write data. The default value is **0**.|
+
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| number | Number of bytes written.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.allocUninitializedFromPool(8);
+buf.writeBigInt64LE(0x0102030405060708n, 0);
+```
+
+### writeBigUInt64BE
+
+writeBigUInt64BE(value: bigint, offset?: number): number
+
+Writes an unsigned, big-endian 64-bit Big integer to this **Buffer** instance at the specified offset.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| value | bigint | Yes| Data to write.|
+| offset | number | No| Number of bytes to skip before starting to write data. The default value is **0**.|
+
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| number | Number of bytes written.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.allocUninitializedFromPool(8);
+buf.writeBigUInt64BE(0xdecafafecacefaden, 0);
+```
+
+### writeBigUInt64LE
+
+writeBigUInt64LE(value: bigint, offset?: number): number
+
+Writes an unsigned, little-endian 64-bit Big integer to this **Buffer** instance at the specified offset.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| value | bigint | Yes| Data to write.|
+| offset | number | No| Number of bytes to skip before starting to write data. The default value is **0**.|
+
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| number | Number of bytes written.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.allocUninitializedFromPool(8);
+buf.writeBigUInt64LE(0xdecafafecacefaden, 0);
+```
+
+### writeDoubleBE
+
+writeDoubleBE(value: number, offset?: number): number
+
+Writes a big-endian double-precision floating-point number to this **Buffer** instance at the specified offset.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| value | number | Yes| Data to write.|
+| offset | number | No| Number of bytes to skip before starting to write data. The default value is **0**.|
+
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| number | Number of bytes written.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.allocUninitializedFromPool(8);
+buf.writeDoubleBE(123.456, 0);
+```
+
+### writeDoubleLE
+
+writeDoubleLE(value: number, offset?: number): number
+
+Writes a little-endian double-precision floating-point number to this **Buffer** instance at the specified offset.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| value | number | Yes| Data to write.|
+| offset | number | No| Number of bytes to skip before starting to write data. The default value is **0**.|
+
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| number | Number of bytes written.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.allocUninitializedFromPool(8);
+buf.writeDoubleLE(123.456, 0);
+```
+
+### writeFloatBE
+
+writeFloatBE(value: number, offset?: number): number
+
+Writes a big-endian single-precision floating-point number to this **Buffer** instance at the specified offset.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| value | number | Yes| Data to write.|
+| offset | number | No| Number of bytes to skip before starting to write data. The default value is **0**.|
+
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| number | Number of bytes written.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.allocUninitializedFromPool(8);
+buf.writeFloatBE(0xcafebabe, 0);
+```
+
+
+### writeFloatLE
+
+writeFloatLE(value: number, offset?: number): number
+
+Writes a little-endian single-precision floating-point number to this **Buffer** instance at the specified offset.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| value | number | Yes| Data to write.|
+| offset | number | No| Number of bytes to skip before starting to write data. The default value is **0**.|
+
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| number | Number of bytes written.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.allocUninitializedFromPool(8);
+buf.writeFloatLE(0xcafebabe, 0);
+```
+
+### writeInt8
+
+writeInt8(value: number, offset?: number): number
+
+Writes a signed 8-bit integer to this **Buffer** instance at the specified offset.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| value | number | Yes| Data to write.|
+| offset | number | No| Number of bytes to skip before starting to write data. The default value is **0**.|
+
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| number | Number of bytes written.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.allocUninitializedFromPool(2);
+buf.writeInt8(2, 0);
+buf.writeInt8(-2, 1);
+```
+
+
+### writeInt16BE
+
+writeInt16BE(value: number, offset?: number): number
+
+Writes a signed, big-endian 16-bit integer to this **Buffer** instance at the specified offset.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| value | number | Yes| Data to write.|
+| offset | number | No| Number of bytes to skip before starting to write data. The default value is **0**.|
+
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| number | Number of bytes written.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.allocUninitializedFromPool(2);
+buf.writeInt16BE(0x0102, 0);
+```
+
+
+### writeInt16LE
+
+writeInt16LE(value: number, offset?: number): number
+
+Writes a signed, little-endian 16-bit integer to this **Buffer** instance at the specified offset.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| value | number | Yes| Data to write.|
+| offset | number | No| Number of bytes to skip before starting to write data. The default value is **0**.|
+
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| number | Number of bytes written.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.allocUninitializedFromPool(2);
+buf.writeInt16LE(0x0304, 0);
+```
+
+### writeInt32BE
+
+writeInt32BE(value: number, offset?: number): number
+
+Writes a signed, big-endian 32-bit integer to this **Buffer** instance at the specified offset.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| value | number | Yes| Data to write.|
+| offset | number | No| Number of bytes to skip before starting to write data. The default value is **0**.|
+
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| number | Number of bytes written.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.allocUninitializedFromPool(4);
+buf.writeInt32BE(0x01020304, 0);
+```
+
+
+### writeInt32LE
+
+writeInt32LE(value: number, offset?: number): number
+
+Writes a signed, little-endian 32-bit integer to this **Buffer** instance at the specified offset.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| value | number | Yes| Data to write.|
+| offset | number | No| Number of bytes to skip before starting to write data. The default value is **0**.|
+
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| number | Number of bytes written.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.allocUninitializedFromPool(4);
+buf.writeInt32LE(0x05060708, 0);
+```
+
+### writeIntBE
+
+writeIntBE(value: number, offset: number, byteLength: number): number
+
+Writes a big-endian signed value of the specified length to this **Buffer** instance at the specified offset.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| value | number | Yes| Data to write.|
+| offset | number | Yes| Number of bytes to skip before starting to write data. The default value is **0**.|
+| byteLength | number | Yes| Number of bytes to write.|
+
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| number | Number of bytes written.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.allocUninitializedFromPool(6);
+buf.writeIntBE(0x1234567890ab, 0, 6);
+```
+
+
+### writeIntLE
+
+writeIntLE(value: number, offset: number, byteLength: number): number
+
+Writes a little-endian signed value of the specified length to this **Buffer** instance at the specified offset.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| value | number | Yes| Data to write.|
+| offset | number | Yes| Number of bytes to skip before starting to write data. The default value is **0**.|
+| byteLength | number | Yes| Number of bytes to write.|
+
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| number | Number of bytes written.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.allocUninitializedFromPool(6);
+buf.writeIntLE(0x1234567890ab, 0, 6);
+```
+
+### writeUInt8
+
+writeUInt8(value: number, offset?: number): number
+
+Writes an unsigned 8-bit integer to this **Buffer** instance at the specified offset.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| value | number | Yes| Data to write.|
+| offset | number | No| Number of bytes to skip before starting to write data. The default value is **0**.|
+
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| number | Number of bytes written.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.allocUninitializedFromPool(4);
+buf.writeUInt8(0x3, 0);
+buf.writeUInt8(0x4, 1);
+buf.writeUInt8(0x23, 2);
+buf.writeUInt8(0x42, 3);
+```
+
+### writeUInt16BE
+
+writeUInt16BE(value: number, offset?: number): number
+
+Writes an unsigned, big-endian 16-bit integer to this **Buffer** instance at the specified offset.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| value | number | Yes| Data to write.|
+| offset | number | No| Number of bytes to skip before starting to write data. The default value is **0**.|
+
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| number | Number of bytes written.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.allocUninitializedFromPool(4);
+buf.writeUInt16BE(0xdead, 0);
+buf.writeUInt16BE(0xbeef, 2);
+```
+
+### writeUInt16LE
+
+writeUInt16LE(value: number, offset?: number): number
+
+Writes an unsigned, little-endian 16-bit integer to this **Buffer** instance at the specified offset.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| value | number | Yes| Data to write.|
+| offset | number | No| Number of bytes to skip before starting to write data. The default value is **0**.|
+
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| number | Number of bytes written.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.allocUninitializedFromPool(4);
+buf.writeUInt16LE(0xdead, 0);
+buf.writeUInt16LE(0xbeef, 2);
+```
+
+### writeUInt32BE
+
+writeUInt32BE(value: number, offset?: number): number
+
+Writes an unsigned, big-endian 32-bit integer to this **Buffer** instance at the specified offset.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| value | number | Yes| Data to write.|
+| offset | number | No| Number of bytes to skip before starting to write data. The default value is **0**.|
+
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| number | Number of bytes written.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.allocUninitializedFromPool(4);
+buf.writeUInt32BE(0xfeedface, 0);
+```
+
+### writeUInt32LE
+
+writeUInt32LE(value: number, offset?: number): number
+
+Writes an unsigned, little-endian 32-bit integer to this **Buffer** instance at the specified offset.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| value | number | Yes| Data to write.|
+| offset | number | No| Number of bytes to skip before starting to write data. The default value is **0**.|
+
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| number | Number of bytes written.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.allocUninitializedFromPool(4);
+buf.writeUInt32LE(0xfeedface, 0);
+```
+
+### writeUIntBE
+
+writeUIntBE(value: number, offset: number, byteLength: number): number
+
+Writes an unsigned big-endian value of the specified length to this **Buffer** instance at the specified offset.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| value | number | Yes| Data to write.|
+| offset | number | Yes| Number of bytes to skip before starting to write data. The default value is **0**.|
+| byteLength | number | Yes| Number of bytes to write.|
+
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| number | Number of bytes written.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.allocUninitializedFromPool(6);
+buf.writeUIntBE(0x1234567890ab, 0, 6);
+```
+
+### writeUIntLE
+
+writeUIntLE(value: number, offset: number, byteLength: number): number
+
+Writes an unsigned little-endian value of the specified length to this **Buffer** instance at the specified offset.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| value | number | Yes| Data to write.|
+| offset | number | Yes| Number of bytes to skip before starting to write data. The default value is **0**.|
+| byteLength | number | Yes| Number of bytes to write.|
+
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| number | Number of bytes written.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.allocUninitializedFromPool(6);
+buf.writeUIntLE(0x1234567890ab, 0, 6);
+```
+
+### transcode
+
+transcode(source: Buffer | Uint8Array, fromEnc: string, toEnc: string): Buffer
+
+Transcodes the given **Buffer** or **Uint8Array** instance from one encoding format to another.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| source | Buffer \| Uint8Array | Yes| Instance to transcode. |
+| fromEnc | string | Yes| Current encoding format.|
+| toEnc | string | Yes| Target encoding format.|
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Buffer | New **Buffer** instance in the target encoding format.|
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let buf = buffer.alloc(50);
+let newBuf = buffer.transcode(buffer.from('€'), 'utf-8', 'ascii');
+console.log(newBuf.toString('ascii'));
+```
+
+## Blob
+
+### Attributes
+
+**System capability**: SystemCapability.Utils.Lang
+
+| Name| Type| Readable| Writable| Description|
+| -------- | -------- | -------- | -------- | -------- |
+| size | number | Yes| No| Total size of the **Blob** instance, in bytes.|
+| type | string | Yes| No| Type of the data in the **Blob** instance.|
+
+### constructor
+
+constructor(sources: string[] | ArrayBuffer[] | TypedArray[] | DataView[] | Blob[] , options?: Object)
+
+A constructor used to create a **Blob** instance.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| sources | string[] \| ArrayBuffer[] \| TypedArray[] \| DataView[] \| Blob[] | Yes| Data sources of the **Blob** instance.|
+| options | Object | No| options:
- **endings**: 'transparent' or 'native'.
- **type**: type of the data in **Blob**.|
+
+
+**Example**
+
+```ts
+import buffer from '@ohos.buffer';
+
+let blob = new buffer.Blob(['a', 'b', 'c']);
+let blob1 = new buffer.Blob(['a', 'b', 'c'], {endings:'native', type: 'MIME'});
+```
+
+### encode
+
+arrayBuffer(): Promise<ArrayBuffer>
+
+Puts the **Blob** data into an **ArrayBuffer** instance. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Return value**
+| Type| Description|
+| -------- | -------- |
+| Promise<ArrayBuffer> | Promise used to return the **ArrayBuffer** containing the **Blob** data.|
+
+**Example**
+ ```ts
+ let blob = new buffer.Blob(['a', 'b', 'c']);
+ let pro = blob.arrayBuffer();
+ pro.then(val => {
+ let uintarr = new Uint8Array(val);
+ console.log(uintarr.toString());
+ });
+ ```
+### slice
+
+slice(start?: number, end?: number, type?: string): Blob
+
+Creates a **Blob** instance by copying specified data from this **Blob** instance.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| start | number | No| Offset to the start position of the data to copy.|
+| end | number | No| Offset to the end position of the data to copy.|
+| type | string | No| Type of the data in the new **Blob** instance.|
+
+**Return value**
+| Type| Description|
+| -------- | -------- |
+| Blob | **Blob** instance created. |
+
+**Example**
+ ```ts
+ let blob = new buffer.Blob(['a', 'b', 'c']);
+ let blob2 = blob.slice(0, 2);
+ let blob3 = blob.slice(0, 2, "MIME");
+ ```
+
+ ### text
+
+text(): Promise<string>
+
+Returns text in UTF-8 format.
+
+**System capability**: SystemCapability.Utils.Lang
+
+**Return value**
+| Type| Description|
+| -------- | -------- |
+| Promise<string> | Promise used to return the text encoded in UTF-8.|
+
+**Example**
+ ```ts
+ let blob = new buffer.Blob(['a', 'b', 'c']);
+ let pro = blob.text();
+ pro.then(val => {
+ console.log(val)
+ });
+ ```
diff --git a/en/application-dev/reference/apis/js-apis-bundle-LauncherAbilityInfo.md b/en/application-dev/reference/apis/js-apis-bundle-LauncherAbilityInfo.md
index 7b932cacbc2195e8c52976aa80e71bd3b638921d..3a00ac698a3529d153ef3741979238569555f12c 100644
--- a/en/application-dev/reference/apis/js-apis-bundle-LauncherAbilityInfo.md
+++ b/en/application-dev/reference/apis/js-apis-bundle-LauncherAbilityInfo.md
@@ -10,6 +10,8 @@ The **LauncherAbilityInfo** module provides information about a launcher ability
**System capability**: SystemCapability.BundleManager.BundleFramework
+**System API**: This is a system API and cannot be called by third-party applications.
+
| Name | Type | Readable| Writable| Description |
| --------------- | ---------------------------------------------------- | ---- | ---- | ------------------------------------ |
| applicationInfo | [ApplicationInfo](js-apis-bundle-ApplicationInfo.md) | Yes | No | Application information of the launcher ability.|
diff --git a/en/application-dev/reference/apis/js-apis-call.md b/en/application-dev/reference/apis/js-apis-call.md
index 1631e3318f49bd07012e836449dfa4431a67db65..ac82d0b2e610751bd000849ec35337363b0dcb3a 100644
--- a/en/application-dev/reference/apis/js-apis-call.md
+++ b/en/application-dev/reference/apis/js-apis-call.md
@@ -2810,10 +2810,11 @@ This is a system API.
| Name | Value | Description |
| -------------------- | ---- | ------------ |
-| DEVICE_EARPIECE | 0 | Headset device. |
-| DEVICE_SPEAKER | 1 | Speaker device.|
-| DEVICE_WIRED_HEADSET | 2 | Wired headset device.|
+| DEVICE_EARPIECE | 0 | Earpiece. |
+| DEVICE_SPEAKER | 1 | Speaker.|
+| DEVICE_WIRED_HEADSET | 2 | Wired headset.|
| DEVICE_BLUETOOTH_SCO | 3 | Bluetooth SCO device. |
+| DEVICE_MIC | 4 | Microphone. |
## CallRestrictionType8+
diff --git a/en/application-dev/reference/apis/js-apis-camera.md b/en/application-dev/reference/apis/js-apis-camera.md
index f9c55898029eee1a6782df976cfd40ec43574735..78db0562f97cf687e26c210d870519c829b691ee 100644
--- a/en/application-dev/reference/apis/js-apis-camera.md
+++ b/en/application-dev/reference/apis/js-apis-camera.md
@@ -20,9 +20,9 @@ Obtains a **CameraManager** instance. This API uses an asynchronous callback to
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ----------------------------------------------- | ---- | ---------------------------- |
-| context | Context | Yes | Application context. |
+| Name | Type | Mandatory| Description |
+| -------- | ----------------------------------------------- | ---- | ---------------------------------- |
+| context | Context | Yes | Application context. |
| callback | AsyncCallback<[CameraManager](#cameramanager)\> | Yes | Callback used to return the **CameraManager** instance.|
**Example**
@@ -30,7 +30,7 @@ Obtains a **CameraManager** instance. This API uses an asynchronous callback to
```js
camera.getCameraManager(context, (err, cameraManager) => {
if (err) {
- console.error(`Failed to get the CameraManager instance ${err.message}`);
+ console.error('Failed to get the CameraManager instance ${err.message}');
return;
}
console.log('Callback returned with the CameraManager instance');
@@ -53,8 +53,8 @@ Obtains a **CameraManager** instance. This API uses a promise to return the resu
**Return value**
-| Type | Description |
-| ----------------------------------------- | ----------------------------------- |
+| Type | Description |
+| ----------------------------------------- | ----------------------------------------- |
| Promise<[CameraManager](#cameramanager)\> | Promise used to return the **CameraManager** instance.|
**Example**
@@ -78,1149 +78,947 @@ Enumerates the camera statuses.
| CAMERA_STATUS_AVAILABLE | 2 | The camera is available. |
| CAMERA_STATUS_UNAVAILABLE | 3 | The camera is unavailable.|
-## Profile
-Defines the camera profile.
+## CameraPosition
+
+Enumerates the camera positions.
**System capability**: SystemCapability.Multimedia.Camera.Core
-| Name | Type | Read only| Description |
-| -------- | ----------------------------- |---- | ------------- |
-| format | [CameraFormat](#cameraformat) | Yes | Output format. |
-| size | [Size](#size) | Yes | Resolution. |
+| Name | Value | Description |
+| --------------------------- | ---- | ---------------- |
+| CAMERA_POSITION_UNSPECIFIED | 0 | Unspecified position.|
+| CAMERA_POSITION_BACK | 1 | Rear camera. |
+| CAMERA_POSITION_FRONT | 2 | Front camera. |
-## FrameRateRange
+## CameraType
- Defines the frame rate range.
+Enumerates the camera types.
**System capability**: SystemCapability.Multimedia.Camera.Core
-| Name | Type | Read only| Description |
-| ------------------------- | ------ | ---- | ------------------- |
-| min | number | Yes | Minimum rate, in fps. |
-| max | number | Yes | Maximum rate, in fps. |
+| Name | Value | Description |
+| ----------------------- | ---- | ---------------- |
+| CAMERA_TYPE_UNSPECIFIED | 0 | Unspecified camera type.|
+| CAMERA_TYPE_WIDE_ANGLE | 1 | Wide camera. |
+| CAMERA_TYPE_ULTRA_WIDE | 2 | Ultra wide camera. |
+| CAMERA_TYPE_TELEPHOTO | 3 | Telephoto camera. |
+| CAMERA_TYPE_TRUE_DEPTH | 4 | Camera with depth of field information. |
+
-## VideoProfile
+## ConnectionType
-Defines the video profile.
+Enumerates the camera connection types.
**System capability**: SystemCapability.Multimedia.Camera.Core
-| Name | Type | Read only| Description |
-| ------------------------- | ----------------------------------------- | --- |------------ |
-| frameRateRanges | [FrameRateRange](#frameraterange) | Yes | Frame rate range. |
+| Name | Value | Description |
+| ---------------------------- | ---- | ------------- |
+| CAMERA_CONNECTION_BUILT_IN | 0 | Built-in camera. |
+| CAMERA_CONNECTION_USB_PLUGIN | 1 | Camera connected using USB.|
+| CAMERA_CONNECTION_REMOTE | 2 | Remote camera. |
-## CameraOutputCapability
+## Size
-Defines the camera output capability.
+Defines the image size that can be used in previewing, photographing, and video recording.
**System capability**: SystemCapability.Multimedia.Camera.Core
-| Name | Type | Read only| Description |
-| ----------------------------- | -------------------------------------------------- | --- |------------------- |
-| previewProfiles | Array<[Profile](#profile)\> | Yes | Supported preview profiles. |
-| photoProfiles | Array<[Profile](#profile)\> | Yes | Supported shooting profiles. |
-| videoProfiles | Array<[VideoProfile](#videoprofile)\> | Yes | Supported video recording profiles. |
-| supportedMetadataObjectTypes | Array<[MetadataObjectType](#metadataobjecttype)\> | Yes | Supported metadata object types.|
+| Name | Type | Readable| Writable| Description |
+| ------ | ------ | ---- | ---- | ------------ |
+| height | string | Yes | Yes | Image height.|
+| width | number | Yes | Yes | Image width.|
## CameraManager
Implements camera management. Before calling any API in **CameraManager**, you must use **getCameraManager** to obtain a **CameraManager** instance.
-### getSupportedCameras
+### getCameras
-getSupportedCameras(callback: AsyncCallback\>): void
+getCameras(callback: AsyncCallback\>): void
-Obtains supported cameras. This API uses an asynchronous callback to return the result.
+Obtains all cameras supported by the device. This API uses an asynchronous callback to return the array of supported cameras.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ----------------------------------------------------- | ---- | ------------------------------- |
-| callback | AsyncCallback\> | Yes | Callback used to return the array of supported cameras.|
+| Name | Type | Mandatory| Description |
+| -------- | ----------------------------------------- | ---- | ------------------------------------ |
+| callback | AsyncCallback\> | Yes | Callback used to return the array of supported cameras.|
**Example**
```js
-cameraManager.getSupportedCameras((err, cameras) => {
+cameraManager.getCameras((err, cameras) => {
if (err) {
- console.error(`Failed to get the cameras. ${err.message}`);
+ console.error('Failed to get the cameras. ${err.message}');
return;
}
- console.log(`Callback returned with an array of supported cameras: ${cameras.length}`);
+ console.log('Callback returned with an array of supported cameras: ' + cameras.length);
})
```
-### getSupportedCameras
+### getCameras
-getSupportedCameras(): Promise\>
+getCameras(): Promise\>
-Obtains supported cameras. This API uses a promise to return the result.
+Obtains all cameras supported by the device. This API uses a promise to return the array of supported cameras.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Return value**
-| Type | Description |
-| ----------------------------------------------- | ------------------------- |
-| Promise\> | Promise used to return the array of supported cameras.|
+| Type | Description |
+| ----------------------------------- | ----------------------------- |
+| Promise\> | Promise used to return the array of supported cameras.|
**Example**
```js
-cameraManager.getSupportedCameras().then((cameraArray) => {
- console.log(`Promise returned with an array of supported cameras: ${cameraArray.length}`);
+cameraManager.getCameras().then((cameraArray) => {
+ console.log('Promise returned with an array of supported cameras: ' + cameraArray.length);
})
```
-### getSupportedOutputCapability
+### createCameraInput
+
+createCameraInput(cameraId: string, callback: AsyncCallback): void
-getSupportedOutputCapability(camera:CameraDevice, callback: AsyncCallback): void
+Creates a **CameraInput** instance with the specified camera ID. This API uses an asynchronous callback to return the result.
-Obtains the output capability supported by a camera. This API uses an asynchronous callback to return the result.
+**Required permissions**: ohos.permission.CAMERA
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ---------------------------------------------------------------- | -- | -------------------------- |
-| camera | [CameraDevice](#cameradevice) | Yes| **CameraDevice** object. |
-| callback | AsyncCallback<[CameraOutputCapability](#cameraoutputcapability)\> | Yes| Callback used to return the output capability.|
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------------------------- | ---- | ----------------------------------- |
+| cameraId | string | Yes | ID of the target camera. |
+| callback | AsyncCallback<[CameraInput](#camerainput)\> | Yes | Callback used to return the **CameraInput** instance.|
**Example**
```js
-cameraManager.getSupportedOutputCapability(cameraDevice, (err, cameras) => {
+cameraManager.createCameraInput(cameraId, (err, cameraInput) => {
if (err) {
- console.error(`Failed to get the cameras. ${err.message}`);
+ console.error('Failed to create the CameraInput instance. ${err.message}');
return;
}
- console.log('Callback returned with an array of supported outputCapability');
+ console.log('Callback returned with the CameraInput instance.');
})
```
-### getSupportedOutputCapability
+### createCameraInput
+
+createCameraInput(cameraId: string): Promise
-getSupportedOutputCapability(camera:CameraDevice): Promise
+Creates a **CameraInput** instance with the specified camera ID. This API uses a promise to return the result.
-Obtains the output capability supported by a camera. This API uses a promise to return the result.
+**Required permissions**: ohos.permission.CAMERA
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory | Description |
-| -------- | --------------------------------- | ---- | ---------- |
-| camera | [CameraDevice](#cameradevice) | Yes | **CameraDevice** object.|
+| Name | Type | Mandatory| Description |
+| -------- | ------ | ---- | ------------ |
+| cameraId | string | Yes | ID of the target camera.|
**Return value**
-| Type | Description |
-| -------------------------------------------------------------- | ----------------------------- |
-| Promise<[CameraOutputCapability](#cameraoutputcapability)\> | Promise used to return the output capability.|
-
+| Type | Description |
+| ------------------------------------- | ---------------------------------------- |
+| Promise<[CameraInput](#camerainput)\> | Promise used to return the **CameraInput** instance.|
**Example**
```js
-cameraManager.getSupportedOutputCapability(cameraDevice).then((cameraoutputcapability) => {
- console.log('Promise returned with an array of supported outputCapability');
+cameraManager.createCameraInput(cameraId).then((cameraInput) => {
+ console.log('Promise returned with the CameraInput instance');
})
```
-### getSupportedMetadataObjectType
+### createCameraInput
+
+createCameraInput(position: CameraPosition, type: CameraType, callback: AsyncCallback): void
-getSupportedMetadataObjectType(callback: AsyncCallback\>): void
+Creates a **CameraInput** instance with the specified camera position and type. This API uses an asynchronous callback to return the result.
-Obtains the metadata object types supported by this camera. This API uses an asynchronous callback to return the result.
+**Required permissions**: ohos.permission.CAMERA
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ---------------------------------------------------------------- | -- | -------------------------- |
-| callback | AsyncCallback\> | Yes| Callback used to return the metadata object types.|
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------------------------- | ---- | ----------------------------------- |
+| position | [CameraPosition](#cameraposition) | Yes | Camera position. |
+| type | [CameraType](#cameratype) | Yes | Camera type. |
+| callback | AsyncCallback<[CameraInput](#camerainput)\> | Yes | Callback used to return the **CameraInput** instance.|
**Example**
```js
-cameraManager.getSupportedMetadataObjectType((err, metadataobject) => {
+cameraManager.createCameraInput(camera.CameraPosition.CAMERA_POSITION_BACK, camera.CameraType.CAMERA_TYPE_UNSPECIFIED, (err, cameraInput) => {
if (err) {
- console.error(`Failed to get the supported metadataObjectType. ${err.message}`);
+ console.error('Failed to create the CameraInput instance. ${err.message}');
return;
}
- console.log('Callback returned with an array of supported metadataObjectType.' );
+ console.log('Callback returned with the CameraInput instance');
})
```
-### getSupportedMetadataObjectType
+### createCameraInput
+
+createCameraInput(position: CameraPosition, type: CameraType): Promise
-getSupportedMetadataObjectType(camera:CameraDevice): Promise
+Creates a **CameraInput** instance with the specified camera position and type. This API uses a promise to return the result.
-Obtains the metadata object types supported by this camera. This API uses a promise to return the result.
+**Required permissions**: ohos.permission.CAMERA
**System capability**: SystemCapability.Multimedia.Camera.Core
-**Return value**
+**Parameters**
-| Type | Description |
-| -------------------------------------------------------------- | ----------------------------- |
-| Promise\> | Promise used to return the metadata object types.|
+| Name | Type | Mandatory| Description |
+| -------- | --------------------------------- | ---- | ---------- |
+| position | [CameraPosition](#cameraposition) | Yes | Camera position.|
+| type | [CameraType](#cameratype) | Yes | Camera type.|
+
+**Return value**
+| Type | Description |
+| ------------------------------------- | ---------------------------------------- |
+| Promise<[CameraInput](#camerainput)\> | Promise used to return the **CameraInput** instance.|
**Example**
```js
-cameraManager.getSupportedMetadataObjectType().then((metadataobject) => {
- console.log('Promise returned with an array of supported metadataObjectType.' );
+cameraManager.createCameraInput(camera.CameraPosition.CAMERA_POSITION_BACK, camera.CameraType.CAMERA_TYPE_UNSPECIFIED).then((cameraInput) => {
+ console.log('Promise returned with the CameraInput instance.');
})
```
-### isCameraMuted
+### on('cameraStatus')
-isCameraMuted(callback: AsyncCallback): void
+on(type: 'cameraStatus', callback: AsyncCallback): void
-Checks whether this camera is muted. This API uses an asynchronous callback to return the result.
+Listens for camera status changes. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ---------------------------------------- | ---- | ------------------------------------ |
-| callback | AsyncCallback | Yes | Callback used to return the result. The value **true** means that the camera is muted, and **false** means the opposite.|
+| Name | Type | Mandatory| Description |
+| :------- | :---------------------------------------------------- | :--- | :--------------------------------------------------- |
+| type | string | Yes | Event type. The value is fixed at **`cameraStatus`**, indicating the camera status change event.|
+| callback | AsyncCallback<[CameraStatusInfo](#camerastatusinfo)\> | Yes | Callback used to return the camera status change. |
**Example**
```js
-cameraManager.isCameraMuted((err, status) => {
+cameraManager.on('cameraStatus', (err, cameraStatusInfo) => {
if (err) {
- console.error(`Failed to get the cameraMuted status. ${err.message}`);
+ console.error('Failed to get cameraStatus callback. ${err.message}');
return;
}
- console.log('Callback returned with cameraMuted status');
+ console.log('camera : ' + cameraStatusInfo.camera.cameraId);
+ console.log('status: ' + cameraStatusInfo.status);
})
```
-### isCameraMuted
-
-isCameraMuted(): Promise
+## Camera
-Checks whether this camera is muted. This API uses a promise to return the result.
+After **[camera.getCameraManager](#cameragetcameramanager)** is called, a camera instance is returned, with camera-related metadata such as **cameraId**, **cameraPosition**, **cameraType**, and **connectionType**.
**System capability**: SystemCapability.Multimedia.Camera.Core
-**Return value**
-
-| Type | Description |
-| ------------------------------------ | --------------------------------------------- |
-| Promise | Promise used to return the result. The value **true** means that the camera is muted, and **false** means the opposite. |
-
+| Name | Type | Read only| Description |
+| -------------- | --------------------------------- | ---- | -------------- |
+| cameraId | string | Yes | Camera ID. |
+| cameraPosition | [CameraPosition](#cameraposition) | Yes | Camera position. |
+| cameraType | [CameraType](#cameratype) | Yes | Camera type. |
+| connectionType | [ConnectionType](#connectiontype) | Yes | Camera connection type.|
**Example**
```js
-cameraManager.isCameraMuted().then((status) => {
- console.log('Promise returned with the status whether camera is muted.');
-})
+async function getCameraInfo("cameraId") {
+ var cameraManager = await camera.getCameraManager(context);
+ var cameras = await cameraManager.getCameras();
+ var cameraObj = cameras[0];
+ var cameraId = cameraObj.cameraId;
+ var cameraPosition = cameraObj.cameraPosition;
+ var cameraType = cameraObj.cameraType;
+ var connectionType = cameraObj.connectionType;
+}
```
-### isCameraMuteSupported
+## CameraStatusInfo
+
+Describes the camera status information.
+
+**System capability**: SystemCapability.Multimedia.Camera.Core
-isCameraMuteSupported(callback: AsyncCallback): void
+| Name | Type | Description |
+| ------ | ----------------------------- | ---------- |
+| camera | [Camera](#camera) | Camera object.|
+| status | [CameraStatus](#camerastatus) | Camera status.|
-Checks whether this camera can be muted. This API uses an asynchronous callback to return the result.
-This is a system API.
+## CameraInput
-**Required permissions**: ohos.permission.CAMERA
+Implements a **CameraInput** instance. Before calling any API in **CameraInput**, you must create a **CameraInput** instance.
+
+### getCameraId
+
+getCameraId(callback: AsyncCallback\): void
+
+Obtains the camera ID based on which this **CameraInput** instance is created. This API uses an asynchronous callback to return the camera ID.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | --------------------------------------- | ---- | ------------------------------------ |
-| callback | AsyncCallback | Yes | Callback used to return the result. The value **true** means that the camera can be muted, and **false** means the opposite. |
+| Name | Type | Mandatory| Description |
+| -------- | ---------------------- | ---- | -------------------------- |
+| callback | AsyncCallback | Yes | Callback used to return the camera ID.|
**Example**
```js
-cameraManager.isCameraMuteSupported((err, status) => {
+cameraInput.getCameraId((err, cameraId) => {
if (err) {
- console.error(`Failed to get the cameraMuteSupported. ${err.message}`);
+ console.error('Failed to get the camera ID. ${err.message}');
return;
}
- console.log('Callback returned with the status whether cameraMuteSupported.');
+ console.log('Callback returned with the camera ID: ' + cameraId);
})
```
-### isCameraMuteSupported
+### getCameraId
-isCameraMuteSupported(): Promise
+getCameraId(): Promise
-Checks whether this camera can be muted. This API uses a promise to return the result.
-
-This is a system API.
-
-**Required permissions**: ohos.permission.CAMERA
+Obtains the camera ID based on which this **CameraInput** instance is created. This API uses a promise to return the camera ID.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Return value**
-| Type | Description |
-| --------------------- | ----------------------------- |
-| Promise | Promise used to return the result. The value **true** means that the camera can be muted, and **false** means the opposite.|
-
+| Type | Description |
+| ---------------- | ----------------------------- |
+| Promise | Promise used to return the camera ID.|
**Example**
```js
-cameraManager.isCameraMuteSupported().then((status) => {
- console.log('Promise returned with the status whether cameraMuteSupported.');
+cameraInput.getCameraId().then((cameraId) => {
+ console.log('Promise returned with the camera ID:' + cameraId);
})
```
-### muteCamera
-muteCamera(mute:boolean, callback: AsyncCallback): void
-
-Mutes this camera. This API uses an asynchronous callback to return the result.
+### hasFlash
-This is a system API.
+hasFlash(callback: AsyncCallback): void
-**Required permissions**: ohos.permission.CAMERA
+Checks whether the device has flash. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory | Description |
-| -------- | ----------------------------------------- | ---- | ------------------------------------ |
-| mute | boolean | Yes | Whether to mute the camera. The value **true** means to mute the camera, and **false** means the opposite. |
-| callback | AsyncCallback | Yes | Callback used to return the result.|
+| Name | Type | Mandatory| Description |
+| -------- | ----------------------- | ---- | -------------------------------------- |
+| callback | AsyncCallback | Yes | Callback used to return the flash support status. The value **true** means that the device has flash.|
**Example**
```js
-cameraManager.muteCamera(isMuted, (err) => {
+cameraInput.hasFlash((err, status) => {
if (err) {
- console.error(`Failed to mute the camera. ${err.message}`);
+ console.error('Failed to check whether the device has flash light. ${err.message}');
return;
}
- console.log('Callback returned with the muteCamera.');
+ console.log('Callback returned with flash light support status: ' + status);
})
```
-### muteCamera
-
-muteCamera(mute:boolean): Promise
-
-Mutes this camera. This API uses a promise to return the result.
+### hasFlash
-This is a system API.
+hasFlash(): Promise
-**Required permissions**: ohos.permission.CAMERA
+Checks whether the device has flash. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| -------- | ----------------------------------------- | ---- | ------------ |
-| mute | boolean | Yes | Whether to mute the camera. The value **true** means to mute the camera, and **false** means the opposite. |
-
**Return value**
-| Type | Description |
-| ----------------------------------- | ----------------------------- |
-| Promise | Promise used to return the result.|
-
+| Type | Description |
+| ----------------- | ------------------------------------------------------- |
+| Promise | Promise used to return the flash support status. The value **true** means that the device has flash.|
**Example**
-```js
-cameraManager.muteCamera(isMuted).then(() => {
- console.log('Promise returned muteCamera.');
+```js
+cameraInput.hasFlash().then((status) => {
+ console.log('Promise returned with the flash light support status:' + status);
})
```
-### createCameraInput
-
-createCameraInput(camera: CameraDevice, callback: AsyncCallback): void
-
-Creates a **CameraInput** instance with the specified **CameraDevice** object. This API uses an asynchronous callback to return the result.
+### isFlashModeSupported
-This is a system API.
+isFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback): void
-**Required permissions**: ohos.permission.CAMERA
+Checks whether a specified flash mode is supported. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ------------------------------------------- | ---- | --------------------------------- |
-| camera | [CameraDevice](#cameradevice) | Yes | **CameraDevice** object. |
-| callback | AsyncCallback<[CameraInput](#camerainput)\> | Yes | Callback used to return the **CameraInput** instance. |
+| Name | Type | Mandatory| Description |
+| --------- | ----------------------- | ---- | ---------------------------------------- |
+| flashMode | [FlashMode](#flashmode) | Yes | Flash mode. |
+| callback | AsyncCallback | Yes | Callback used to return the flash mode support status. The value **true** means that the flash mode is supported, and **false** means the opposite.|
**Example**
```js
-cameraManager.createCameraInput(camera, (err, cameraInput) => {
+cameraInput.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO, (err, status) => {
if (err) {
- console.error(`Failed to create the CameraInput instance. ${err.message}`);
+ console.error('Failed to check whether the flash mode is supported. ${err.message}');
return;
}
- console.log('Callback returned with the CameraInput instance.');
+ console.log('Callback returned with the flash mode support status: ' + status);
})
```
-### createCameraInput
-
-createCameraInput(camera: CameraDevice): Promise
-
-Creates a **CameraInput** instance with the specified **CameraDevice** object. This API uses a promise to return the result.
+### isFlashModeSupported
-This is a system API.
+isFlashModeSupported(flashMode: FlashMode): Promise
-**Required permissions**: ohos.permission.CAMERA
+Checks whether a specified flash mode is supported. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ----------------------------- | ---- | ---------- |
-| camera | [CameraDevice](#cameradevice) | Yes | **CameraDevice** object.|
+| Name | Type | Mandatory| Description |
+| --------- | ----------------------- | ---- | ---------------- |
+| flashMode | [FlashMode](#flashmode) | Yes | Flash mode.|
**Return value**
-| Type | Description |
-| ------------------------------------- | ------------------------------------ |
-| Promise<[CameraInput](#camerainput)\> | Promise used to return the **CameraInput** instance.|
+| Type | Description |
+| ----------------- | ------------------------------------------------------------ |
+| Promise | Promise used to return the flash mode support status. The value **true** means that the flash mode is supported, and **false** means the opposite.|
**Example**
```js
-cameraManager.createCameraInput(camera).then((cameraInput) => {
- console.log('Promise returned with the CameraInput instance');
+cameraInput.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO).then((status) => {
+ console.log('Promise returned with flash mode support status.' + status);
})
```
-### createCameraInput
+### setFlashMode
-createCameraInput(position: CameraPosition, type: CameraType, callback: AsyncCallback): void
+setFlashMode(flashMode: FlashMode, callback: AsyncCallback): void
-Creates a **CameraInput** instance with the specified camera position and type. This API uses an asynchronous callback to return the result.
+Sets the flash mode. This API uses an asynchronous callback to return the result.
-This is a system API.
+Before the setting, do the following checks:
-**Required permissions**: ohos.permission.CAMERA
+1. Use **[hasFlash](#hasflash)** to check whether the device has flash.
+2. Use **[isFlashModeSupported](#isflashmodesupported)** to check whether the device supports the flash mode.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ------------------------------------------- | ---- | --------------------------------- |
-| position | [CameraPosition](#cameraposition) | Yes | Camera position. |
-| type | [CameraType](#cameratype) | Yes | Camera type. |
-| callback | AsyncCallback<[CameraInput](#camerainput)\> | Yes | Callback used to return the **CameraInput** instance. |
+| Name | Type | Mandatory| Description |
+| --------- | ----------------------- | ---- | ------------------------ |
+| flashMode | [FlashMode](#flashmode) | Yes | Flash mode. |
+| callback | AsyncCallback | Yes | Callback used to return the result.|
**Example**
```js
-cameraManager.createCameraInput(camera.CameraPosition.CAMERA_POSITION_BACK, camera.CameraType.CAMERA_TYPE_UNSPECIFIED, (err, cameraInput) => {
+cameraInput.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO, (err) => {
if (err) {
- console.error(`Failed to create the CameraInput instance. ${err.message}`);
+ console.error('Failed to set the flash mode ${err.message}');
return;
}
- console.log('Callback returned with the CameraInput instance');
+ console.log('Callback returned with the successful execution of setFlashMode.');
})
```
-### createCameraInput
+### setFlashMode
-createCameraInput(position: CameraPosition, type:CameraType ): Promise
+setFlashMode(flashMode: FlashMode): Promise
-Creates a **CameraInput** instance with the specified camera position and type. This API uses a promise to return the result.
+Sets a flash mode. This API uses a promise to return the result.
-This is a system API.
+Before the setting, do the following checks:
-**Required permissions**: ohos.permission.CAMERA
+1. Use **[hasFlash](#hasflash)** to check whether the device has flash.
+2. Use **[isFlashModeSupported](#isflashmodesupported)** to check whether the device supports the flash mode.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | --------------------------------- | ---- | ------------ |
-| position | [CameraPosition](#cameraposition) | Yes | Camera position. |
-| type | [CameraType](#cameratype) | Yes | Camera type. |
+| Name | Type | Mandatory| Description |
+| --------- | ----------------------- | ---- | ---------------- |
+| flashMode | [FlashMode](#flashmode) | Yes | Flash mode.|
**Return value**
-| Type | Description |
-| ------------------------------------- | ------------------------------------ |
-| Promise<[CameraInput](#camerainput)\> | Promise used to return the **CameraInput** instance.|
+| Type | Description |
+| -------------- | --------------------------- |
+| Promise| Promise used to return the result.|
**Example**
```js
-cameraManager.createCameraInput(camera.CameraPosition.CAMERA_POSITION_BACK, camera.CameraType.CAMERA_TYPE_UNSPECIFIED).then((cameraInput) => {
- console.log('Promise returned with the CameraInput instance');
+cameraInput.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO).then(() => {
+ console.log('Promise returned with the successful execution of setFlashMode.');
})
```
-### createPreviewOutput
+### getFlashMode
-createPreviewOutput(profile: Profile, surfaceId: string, callback: AsyncCallback): void
+getFlashMode(callback: AsyncCallback): void
-Creates a **PreviewOutput** instance. This API uses an asynchronous callback to return the result.
+Obtains the flash mode in use. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ----------------------------------------------- | ---- | ------------------------------- |
-| profile | [Profile](#profile) | Yes | Supported preview profile. |
-| surfaceId| string | Yes | Surface ID, which is obtained from **[XComponent](../arkui-ts/ts-basic-components-xcomponent.md)** or **[ImageReceiver](js-apis-image.md#imagereceiver9)**.|
-| callback | AsyncCallback<[PreviewOutput](#previewoutput)\> | Yes | Callback used to return the **PreviewOutput** instance.|
+| Name | Type | Mandatory| Description |
+| -------- | --------------------------------------- | ---- | ---------------------------------------- |
+| callback | AsyncCallback<[FlashMode](#flashmode)\> | Yes | Callback used to return the flash mode.|
**Example**
```js
-cameraManager.createPreviewOutput(profile, surfaceId, (err, previewoutput) => {
+cameraInput.getFlashMode((err, flashMode) => {
if (err) {
- console.error(`Failed to gcreate previewOutput. ${err.message}`);
+ console.error('Failed to get the flash mode ${err.message}');
return;
}
- console.log('Callback returned with previewOutput created.');
+ console.log('Callback returned with current flash mode: ' + flashMode);
})
```
-### createPreviewOutput
+### getFlashMode
-createPreviewOutput(profile: Profile, surfaceId: string): Promise
+getFlashMode(): Promise
-Creates a **PreviewOutput** instance. This API uses a promise to return the result.
+Obtains the flash mode in use. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| -------- | ---------------------------------| ---- | ----------------- |
-| profile | [Profile](#profile) | Yes | Supported preview profile. |
-| surfaceId| string | Yes | Surface ID, which is obtained from **[XComponent](../arkui-ts/ts-basic-components-xcomponent.md)** or **[ImageReceiver](js-apis-image.md#imagereceiver9)**.|
-
**Return value**
-| Type | Description |
-| ---------------------------------------- | ---------------------------------------- |
-| Promise<[PreviewOutput](#previewoutput)\> | Promise used to return the **PreviewOutput** instance. |
+| Type | Description |
+| --------------------------------- | --------------------------------------- |
+| Promise<[FlashMode](#flashmode)\> | Promise used to return the flash mode.|
**Example**
```js
-cameraManager.createPreviewOutput(profile, survaceId).then((previewoutput) => {
- console.log('Promise returned with previewOutput created.');
+cameraInput.getFlashMode().then((flashMode) => {
+ console.log('Promise returned with current flash mode : ' + flashMode);
})
```
-### createDeferredPreviewOutput
+### isFocusModeSupported
-createDeferredPreviewOutput(profile: Profile, callback: AsyncCallback): void
+isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback): void
-Creates a **PreviewOutput** instance without a surface ID. This API uses an asynchronous callback to return the result.
+Checks whether a specified focus mode is supported. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ----------------------------------------------- | ---- | --------------------------------- |
-| profile | [Profile](#profile) | Yes | Supported preview profile. |
-| callback | AsyncCallback<[PreviewOutput](#previewoutput)\> | Yes | Callback used to return the **PreviewOutput** instance. |
+| Name | Type | Mandatory| Description |
+| -------- | ----------------------- | ---- | -------------------------------------- |
+| afMode | [FocusMode](#focusmode) | Yes | Focus mode. |
+| callback | AsyncCallback | Yes | Callback used to return the focus mode support status. The value **true** means that the focus mode is supported, and **false** means the opposite.|
**Example**
```js
-cameraManager.createDeferredPreviewOutput(profile, (err, previewoutput) => {
+cameraInput.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_AUTO, (err, status) => {
if (err) {
- console.error(`Failed to create deferredPreviewOutput. ${err.message}`);
+ console.error('Failed to check whether the focus mode is supported. ${err.message}');
return;
}
- console.log('Callback returned with deferredPreviewOutput created.');
+ console.log('Callback returned with the focus mode support status: ' + status);
})
```
-### createDeferredPreviewOutput
+### isFocusModeSupported
-createDeferredPreviewOutput(profile: Profile): Promise
+isFocusModeSupported(afMode: FocusMode): Promise
-Creates a **PreviewOutput** instance without a surface ID. This API uses a promise to return the result.
+Checks whether a specified focus mode is supported. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory | Description |
-| -------- | ---------------------------------| ---- | ---------- |
-| profile | [Profile](#profile) | Yes | Supported preview profile. |
+| Name | Type | Mandatory| Description |
+| ------ | ----------------------- | ---- | ---------------- |
+| afMode | [FocusMode](#focusmode) | Yes | Focus mode.|
**Return value**
-| Type | Description |
-| ----------------------------------------- | --------------------------------------- |
-| Promise<[PreviewOutput](#previewoutput)\> | Promise used to return the **PreviewOutput** instance.|
+| Type | Description |
+| ----------------- | ----------------------------------------------------------- |
+| Promise | Promise used to return the focus mode support status. The value **true** means that the focus mode is supported, and **false** means the opposite.|
**Example**
```js
-cameraManager.createDeferredPreviewOutput(profile).then((previewoutput) => {
- console.log('Promise returned with DefeerredPreviewOutput created.');
+cameraInput.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_AUTO).then((status) => {
+ console.log('Promise returned with focus mode support status.' + status);
})
```
-### createPhotoOutput
+### setFocusMode
-createPhotoOutput(profile: Profile, surfaceId: string, callback: AsyncCallback): void
+setFocusMode(afMode: FocusMode, callback: AsyncCallback): void
-Creates a **PhotoOutput** instance. This API uses an asynchronous callback to return the result.
+Sets a focus mode. This API uses an asynchronous callback to return the result.
+
+Before the setting, use **[isFocusModeSupported](#isfocusmodesupported)** to check whether the focus mode is supported.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ------------------------------------------- | ---- | ----------------------------------- |
-| profile | [Profile](#profile) | Yes | Supported shooting profile. |
-| surfaceId| string | Yes | Surface ID, which is obtained from **[ImageReceiver](js-apis-image.md#imagereceiver9)**.|
-| callback | AsyncCallback<[PhotoOutput](#photooutput)\> | Yes | Callback used to return the **PhotoOutput** instance. |
+| Name | Type | Mandatory| Description |
+| -------- | ----------------------- | ---- | ------------------------ |
+| afMode | [FocusMode](#focusmode) | Yes | Focus mode. |
+| callback | AsyncCallback | Yes | Callback used to return the result.|
**Example**
```js
-cameraManager.createPhotoOutput(profile, surfaceId, (err, photooutput) => {
+cameraInput.setFocusMode(camera.FocusMode.FOCUS_MODE_AUTO, (err) => {
if (err) {
- console.error(`Failed to create photoOutput. ${err.message}`);
+ console.error('Failed to set the focus mode ${err.message}');
return;
}
- console.log('Callback returned with photoOutput created.');
+ console.log('Callback returned with the successful execution of setFocusMode.');
})
```
-### createPhotoOutput
+### setFocusMode
+
+setFocusMode(afMode: FocusMode): Promise
-createPhotoOutput(profile: Profile, surfaceId: string): Promise
+Sets a focus mode. This API uses a promise to return the result.
-Creates a **PhotoOutput** instance. This API uses a promise to return the result.
+Before the setting, use **[isFocusModeSupported](#isfocusmodesupported)** to check whether the focus mode is supported.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ---------------------------------| ---- | ----------- |
-| profile | [Profile](#profile) | Yes | Supported shooting profile. |
-| surfaceId| string | Yes | Surface ID, which is obtained from **[ImageReceiver](js-apis-image.md#imagereceiver9)**.|
+| Name | Type | Mandatory| Description |
+| ------ | ----------------------- | ---- | ---------------- |
+| afMode | [FocusMode](#focusmode) | Yes | Focus mode.|
**Return value**
-| Type | Description |
-| ------------------------------------- | -------------------------------------- |
-| Promise<[PhotoOutput](#photooutput)\> | Promise used to return the **PhotoOutput** instance. |
+| Type | Description |
+| -------------- | --------------------------- |
+| Promise| Promise used to return the result.|
**Example**
```js
-cameraManager.createPhotoOutput(profile, surfaceId).then((photooutput) => {
- console.log('Promise returned with photoOutput created.');
+cameraInput.setFocusMode(camera.FocusMode.FOCUS_MODE_AUTO).then(() => {
+ console.log('Promise returned with the successful execution of setFocusMode.');
})
```
-### createVideoOutput
+### getFocusMode
-createVideoOutput(profile: VideoProfile, surfaceId: string, callback: AsyncCallback): void
+getFocusMode(callback: AsyncCallback): void
-Creates a **VideoOutput** instance. This API uses an asynchronous callback to return the result.
+Obtains the focus mode in use. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ------------------------------------------- | ---- | ------------------------------ |
-| profile | [VideoProfile](#videoprofile) | Yes | Supported video recording profile. |
-| surfaceId| string | Yes | Surface ID, which is obtained from **[VideoRecorder](js-apis-media.md#videorecorder9)**.|
-| callback | AsyncCallback<[VideoOutput](#videooutput)\> | Yes | Callback used to return the **VideoOutput** instance.|
+| Name | Type | Mandatory| Description |
+| -------- | --------------------------------------- | ---- | -------------------------------------- |
+| callback | AsyncCallback<[FocusMode](#focusmode)\> | Yes | Callback used to return the focus mode.|
**Example**
```js
-cameraManager.createVideoOutput(profile, surfaceId, (err, videooutput) => {
+cameraInput.getFocusMode((err, afMode) => {
if (err) {
- console.error(`Failed to create videoOutput. ${err.message}`);
+ console.error('Failed to get the focus mode ${err.message}');
return;
}
- console.log('Callback returned with an array of supported outputCapability' );
+ console.log('Callback returned with current focus mode: ' + afMode);
})
```
-### createVideoOutput
+### getFocusMode
-createVideoOutput(profile: VideoProfile, surfaceId: string): Promise
+getFocusMode(): Promise
-Creates a **VideoOutput** instance. This API uses a promise to return the result.
+Obtains the focus mode in use. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| -------- | ---------------------------------| ---- | ---------- |
-| profile | [VideoProfile](#videoprofile) | Yes | Supported video recording profile. |
-| surfaceId| string | Yes | Surface ID, which is obtained from **[VideoRecorder](js-apis-media.md#videorecorder9)**.|
-
**Return value**
-| Type | Description |
-| ------------------------------------- | -------------------------------------- |
-| Promise<[VideoOutput](#videooutput)\> | Promise used to return the **VideoOutput** instance. |
+| Type | Description |
+| ------------------- | ------------------------------------- |
+| Promise | Promise used to return the focus mode.|
**Example**
```js
-cameraManager.createVideoOutput(profile, surfaceId).then((videooutput) => {
- console.log('Promise returned with videoOutput created.');
+cameraInput.getFocusMode().then((afMode) => {
+ console.log('Promise returned with current focus mode : ' + afMode);
})
```
-### createMetadataOutput
+### getZoomRatioRange
-createMetadataOutput(metadataObjectTypes: Array, callback: AsyncCallback): void
+getZoomRatioRange\(callback: AsyncCallback\>\): void
-Creates a **MetadataOutput** instance. This API uses an asynchronous callback to return the result.
+Obtains the zoom ratio range. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------------------- | -------------------------------------------------- | --- | ---------------------------- |
-| metadataObjectTypes | Array<[MetadataObjectType](#metadataobjecttype)\> | Yes | Supported metadata object types. |
-| callback | AsyncCallback<[MetadataOutput](#metadataoutput)\> | Yes | Callback used to return the **MetadataOutput** instance. |
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------------ | ---- | ------------------------ |
+| callback | AsyncCallback\> | Yes | Callback used to return the result.|
**Example**
```js
-cameraManager.createMetadataOutput(metadataObjectTypes, (err, metadataoutput) => {
+cameraInput.getZoomRatioRange((err, zoomRatioRange) => {
if (err) {
- console.error(`Failed to create metadataOutput. ${err.message}`);
+ console.error('Failed to get the zoom ratio range. ${err.message}');
return;
}
- console.log('Callback returned with metadataOutput created.');
+ console.log('Callback returned with zoom ratio range: ' + zoomRatioRange.length);
})
```
-### createMetadataOutput
+### getZoomRatioRange
-createMetadataOutput(metadataObjectTypes: Array): Promise
+getZoomRatioRange\(\): Promise\>
-Creates a **MetadataOutput** instance. This API uses a promise to return the result.
+Obtains the zoom ratio range. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| -------------------- | -------------------------------------------------- | --- | -------------- |
-| metadataObjectTypes | Array<[MetadataObjectType](#metadataobjecttype)\> | Yes | Supported metadata object types.|
-
**Return value**
-| Type | Description |
-| ------------------------------------------ | ----------------------------------------- |
-| Promise<[MetadataOutput](#metadataoutput)\> | Promise used to return the **MetadataOutput** instance.|
+| Type | Description |
+| ------------------------ | ------------------------------------------- |
+| Promise\> | Promise used to return the zoom ratio range.|
**Example**
```js
-cameraManager.createMetadataOutput(metadataObjectTypes).then((metadataoutput) => {
- console.log('Promise returned with metadataOutput created.');
+cameraInput.getZoomRatioRange().then((zoomRatioRange) => {
+ console.log('Promise returned with zoom ratio range: ' + zoomRatioRange.length);
})
```
-### createCaptureSession
+### setZoomRatio
-createCaptureSession(callback: AsyncCallback): void
+setZoomRatio(zoomRatio: number, callback: AsyncCallback): void
-Creates a **CaptureSession** instance. This API uses an asynchronous callback to return the result.
+Sets a zoom ratio. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory | Description |
-| -------------------- | ----------------------------------------- | ----------- | ---------------------------- |
-| callback | AsyncCallback<[CaptureSession](#capturesession)\> | Yes | Callback used to return the **CaptureSession** instance.|
+| Name | Type | Mandatory| Description |
+| --------- | -------------------- | ---- | ------------------------ |
+| zoomRatio | number | Yes | Zoom ratio. |
+| callback | AsyncCallback | Yes | Callback used to return the result.|
**Example**
```js
-cameraManager.createCaptureSession((err, capturesession) => {
+cameraInput.setZoomRatio(1, (err) => {
if (err) {
- console.error(`Failed to create captureSession. ${err.message}`);
+ console.error('Failed to set the zoom ratio value ${err.message}');
return;
}
- console.log('Callback returned with captureSession created.');
-})
-```
-
-### createCaptureSession
-
-createCaptureSession(): Promise
-
-Creates a **CaptureSession** instance. This API uses a promise to return the result.
-
-**System capability**: SystemCapability.Multimedia.Camera.Core
-
-**Return value**
-
-| Type | Description |
-| ------------------------------------------- | ---------------------------------------- |
-| Promise<[CaptureSession](#capturesession)\> | Promise used to return the **CaptureSession** instance.|
-
-**Example**
-
-```js
-cameraManager.createCaptureSession().then((capturesession) => {
- console.log('Promise returned with captureSession created.');
+ console.log('Callback returned with the successful execution of setZoomRatio.');
})
```
-### on('cameraStatus')
+### setZoomRatio
-on(type: 'cameraStatus', callback: AsyncCallback): void
+setZoomRatio(zoomRatio: number): Promise
-Listens for camera status changes. This API uses an asynchronous callback to return the result.
+Sets a zoom ratio. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ----------------------------------------------------- | ---- | --------- |
-| type | string | Yes | Event type. The value is fixed at **'cameraStatus'**, indicating the camera status change event.|
-| callback | AsyncCallback<[CameraStatusInfo](#camerastatusinfo)\> | Yes | Callback used to return the camera status change. |
-
-**Example**
-
-```js
-cameraManager.on('cameraStatus', (err, cameraStatusInfo) => {
- if (err) {
- console.error(`Failed to get cameraStatus callback. ${err.message}`);
- return;
- }
- console.log(`camera : ${cameraStatusInfo.camera.cameraId}`);
- console.log(`status: ${cameraStatusInfo.status}`);
-})
-```
-
-### on('cameraMute')
-
-on(type: 'cameraMute', callback: AsyncCallback): void
-
-Listens for camera mute status changes. This API uses an asynchronous callback to return the result.
-
-This is a system API.
-
-**Required permissions**: ohos.permission.CAMERA
-
-**System capability**: SystemCapability.Multimedia.Camera.Core
+| Name | Type | Mandatory| Description |
+| --------- | ------ | ---- | ------------ |
+| zoomRatio | number | Yes | Zoom ratio.|
-**Parameters**
+**Return value**
-| Name | Type | Mandatory| Description |
-| -------- | --------------------------------------- | ---- | ------------------------------- |
-| type | string | Yes | Event type. The value is fixed at **'cameraMute'**, indicating the camera mute status change event.|
-| callback | AsyncCallback | Yes | Callback used to return the camera mute status. |
+| Type | Description |
+| -------------- | --------------------------- |
+| Promise| Promise used to return the result.|
**Example**
```js
-cameraManager.on('cameraMute', (err, status) => {
- if (err) {
- console.error(`Failed to get cameraMute callback. ${err.message}`);
- return;
- }
- console.log(`status: ${status}`);
+cameraInput.setZoomRatio(1).then(() => {
+ console.log('Promise returned with the successful execution of setZoomRatio.');
})
```
-## CameraStatusInfo
-
-Describes the camera status information.
-
-**System capability**: SystemCapability.Multimedia.Camera.Core
-
-| Name | Type | Description |
-| ------ | ----------------------------- | ---------- |
-| camera | [CameraDevice](#cameradevice) | Camera object.|
-| status | [CameraStatus](#camerastatus) | Camera status.|
-
-## CameraPosition
-
-Enumerates the camera positions.
-
-**System capability**: SystemCapability.Multimedia.Camera.Core
-
-| Name | Value | Description |
-| --------------------------- | ---- | -------------- |
-| CAMERA_POSITION_UNSPECIFIED | 0 | Unspecified position. |
-| CAMERA_POSITION_BACK | 1 | Rear camera. |
-| CAMERA_POSITION_FRONT | 2 | Front camera. |
-
-## CameraType
-
-Enumerates the camera types.
-
-**System capability**: SystemCapability.Multimedia.Camera.Core
-
-| Name | Value | Description |
-| ----------------------- | ---- | -------------- |
-| CAMERA_TYPE_UNSPECIFIED | 0 | Unspecified camera type. |
-| CAMERA_TYPE_WIDE_ANGLE | 1 | Wide camera. |
-| CAMERA_TYPE_ULTRA_WIDE | 2 | Ultra wide camera. |
-| CAMERA_TYPE_TELEPHOTO | 3 | Telephoto camera. |
-| CAMERA_TYPE_TRUE_DEPTH | 4 | Camera with depth of field information.|
-
-## ConnectionType
-
-Enumerates the camera connection types.
-
-**System capability**: SystemCapability.Multimedia.Camera.Core
-
-| Name | Value | Description |
-| ---------------------------- | ---- | ------------- |
-| CAMERA_CONNECTION_BUILT_IN | 0 | Built-in camera. |
-| CAMERA_CONNECTION_USB_PLUGIN | 1 | Camera connected using USB.|
-| CAMERA_CONNECTION_REMOTE | 2 | Remote camera.|
-
-## CameraDevice
-
-Defines the camera device information.
-
-**System capability**: SystemCapability.Multimedia.Camera.Core
-
-| Name | Type | Read only| Description |
-| -------------- | --------------------------------- | ---- | ---------- |
-| cameraId | string | Yes | **CameraDevice** object.|
-| cameraPosition | [CameraPosition](#cameraposition) | Yes | Camera position. |
-| cameraType | [CameraType](#cameratype) | Yes | Camera type. |
-| connectionType | [ConnectionType](#connectiontype) | Yes | Camera connection type.|
-
-**Example**
-
-```js
-async function getCameraInfo("cameraId") {
- let cameraManager = await camera.getCameraManager(context);
- let cameras = await cameraManager.getSupportedCameras();
- let cameraObj = cameras[0];
- let cameraId = cameraObj.cameraId;
- let cameraPosition = cameraObj.cameraPosition;
- let cameraType = cameraObj.cameraType;
- let connectionType = cameraObj.connectionType;
-}
-```
-
-## Size
-
-Enumerates the camera output capability.
-
-**System capability**: SystemCapability.Multimedia.Camera.Core
-
-| Name | Type | Readable| Writable| Description |
-| ------ | ------ | ---- | ---- | ------------ |
-| height | number | Yes | Yes | Image height, in pixels.|
-| width | number | Yes | Yes | Image width, in pixels.|
-
-## Point
-
-Enumerates the point coordinates, which are used for focus and exposure configuration.
-
-**System capability**: SystemCapability.Multimedia.Camera.Core
-
-| Name | Type | Mandatory | Description |
-| ------ | ------ | ---- | ------------ |
-| x | number | Yes | X coordinate of a point. |
-| y | number | Yes | Y coordinate of a point. |
-
-## CameraFormat
-
-Enumerates the camera output formats.
-
-**System capability**: SystemCapability.Multimedia.Camera.Core
-
-| Name | Default Value | Description |
-| ----------------------- | --------- | ------------ |
-| CAMERA_FORMAT_YUV_420_SP| 1003 | YUV 420 SP image. |
-| CAMERA_FORMAT_JPEG | 2000 | JPEG image. |
-
-## CameraInput
-
-Provides camera information used in **[CaptureSession](#capturesession)**.
-
-### open
+### getZoomRatio
-open\(callback: AsyncCallback\): void
+getZoomRatio(callback: AsyncCallback): void
-Opens this camera. This API uses an asynchronous callback to return the result.
+Obtains the zoom ratio in use. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | -------------------- | ---- | ------------------- |
-| callback | AsyncCallback | Yes | Callback used to return the result.|
+| Name | Type | Mandatory| Description |
+| -------- | ---------------------- | ---- | ------------------------ |
+| callback | AsyncCallback | Yes | Callback used to return the result.|
**Example**
```js
-cameraInput.open((err) => {
+cameraInput.getZoomRatio((err, zoomRatio) => {
if (err) {
- console.error(`Failed to open the camera. ${err.message}`);
+ console.error('Failed to get the zoom ratio ${err.message}');
return;
}
- console.log('Callback returned with camera opened.');
+ console.log('Callback returned with current zoom ratio: ' + zoomRatio);
})
```
-### open
+### getZoomRatio
-open(): Promise
+getZoomRatio(): Promise
-Opens this camera. This API uses a promise to return the result.
+Obtains the zoom ratio in use. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Return value**
-| Type | Description |
-| -------------- | ----------------------- |
-| Promise| Promise used to return the result.|
+| Type | Description |
+| ---------------- | --------------------------- |
+| Promise | Promise used to return the zoom ratio.|
**Example**
```js
-cameraInput.open().then(() => {
- console.log('Promise returned with camera opened.');
+cameraInput.getZoomRatio().then((zoomRatio) => {
+ console.log('Promise returned with current zoom ratio : ' + zoomRatio);
})
```
-### close
+### release
-close\(callback: AsyncCallback\): void
+release\(callback: AsyncCallback\): void
-Closes this camera. This API uses an asynchronous callback to return the result.
+Releases this **CameraInput** instance. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | -------------------- | ---- | -------------------- |
+| Name | Type | Mandatory| Description |
+| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback | Yes | Callback used to return the result.|
**Example**
```js
-cameraInput.close((err) => {
+cameraInput.release((err) => {
if (err) {
- console.error(`Failed to close the cameras. ${err.message}`);
+ console.error('Failed to release the CameraInput instance ${err.message}');
return;
}
- console.log('Callback returned with camera closed.');
-})
+ console.log('Callback invoked to indicate that the CameraInput instance is released successfully.');
+});
```
-### close
+### release
-close(): Promise
+release(): Promise
-Closes this camera. This API uses a promise to return the result.
+Releases this **CameraInput** instance. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Return value**
-| Type | Description |
-| -------------- | ----------------------- |
+| Type | Description |
+| -------------- | --------------------------- |
| Promise| Promise used to return the result.|
**Example**
```js
-cameraInput.close().then(() => {
- console.log('Promise returned with camera closed.');
+cameraInput.release().then(() => {
+ console.log('Promise returned to indicate that the CameraInput instance is released successfully.');
})
```
-### release
+### on('focusStateChange')
-release\(callback: AsyncCallback\): void
+on(type: 'focusStateChange', callback: AsyncCallback): void
-Releases this camera. This API uses an asynchronous callback to return the result.
+Listens for focus state changes. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | -------------------- | ---- | ------------------- |
-| callback | AsyncCallback | Yes | Callback used to return the result.|
-
-**Example**
-
-```js
-cameraInput.release((err) => {
- if (err) {
- console.error(`Failed to release the CameraInput instance ${err.message}`);
- return;
- }
- console.log('Callback invoked to indicate that the CameraInput instance is released successfully.');
-});
-```
-
-### release
-
-release(): Promise
-
-Releases this camera. This API uses a promise to return the result.
-
-**System capability**: SystemCapability.Multimedia.Camera.Core
-
-**Return value**
-
-| Type | Description |
-| -------------- | ----------------------- |
-| Promise| Promise used to return the result.|
+| Name | Type | Mandatory| Description |
+| :------- | :---------------------------------------- | :--- | :------------------------------------------------------- |
+| type | string | Yes | Event type. The value is fixed at **'focusStateChange'**, indicating the focus state change event.|
+| callback | AsyncCallback<[FocusState](#focusstate)\> | Yes | Callback used to return the focus state change. |
**Example**
```js
-cameraInput.release().then(() => {
- console.log('Promise returned to indicate that the CameraInput instance is released successfully.');
+cameraInput.on('focusStateChange', (focusState) => {
+ console.log('Focus state : ' + focusState);
})
```
@@ -1234,42 +1032,37 @@ Listens for **CameraInput** errors. This API uses a callback to return the resul
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | -------------------------------- | ---- | ------------------------------------------- |
+| Name | Type | Mandatory| Description |
+| :------- | :------------------------------- | :--- | :----------------------------------------------- |
| type | string | Yes | Event type. The value is fixed at **'error'**, indicating the camera input error event.|
-| callback | ErrorCallback<[CameraInputError](#camerainputerror)\> | Yes | Callback used to return the result. |
+| callback | ErrorCallback<[CameraInputError](#camerainputerror)\> | Yes | Callback used to return the result. |
**Example**
```js
cameraInput.on('error', (cameraInputError) => {
- console.log(`Camera input error code: ${cameraInputError.code}`);
+ console.log('Camera input error code: ' + cameraInputError.code);
})
```
-## CameraInputErrorCode
+## CameraInputErrorCode
-Enumerates the error codes used for camera input.
+Enumerates the error codes used in a **CameraInput** instance.
**System capability**: SystemCapability.Multimedia.Camera.Core
-| Name | Value | Description |
-| ------------------------- | ---- | ---------- |
-| ERROR_UNKNOWN | -1 | Unknown error.|
-| ERROR_NO_PERMISSION | 0 | You do not have the required permission.|
-| ERROR_DEVICE_PREEMPTED | 1 | The camera is preempted.|
-| ERROR_DEVICE_DISCONNECTED | 2 | The camera is disconnected.|
-| ERROR_DEVICE_IN_USE | 3 | The camera is in use.|
-| ERROR_DRIVER_ERROR | 4 | Driver error. |
+| Name | Value | Description |
+| ------------- | ---- | ---------- |
+| ERROR_UNKNOWN | -1 | Unknown error.|
-## CameraInputError
+## CameraInputError
-Defines an error object used for **[CameraInput](#camerainput)**.
+Defines a **CameraInput** error.
**System capability**: SystemCapability.Multimedia.Camera.Core
-| Name| Type | Description |
-| ---- | --------------------------------------------- | --------------------- |
+| Name| Type | Description |
+| ---- | ------------------------------------------- | -------------------------- |
| code | [CameraInputErrorCode](#camerainputerrorcode) | **CameraInput** error code.|
@@ -1279,37 +1072,25 @@ Enumerates the flash modes.
**System capability**: SystemCapability.Multimedia.Camera.Core
-| Name | Value | Description |
-| ---------------------- | ---- | ---------- |
+| Name | Value | Description |
+| ---------------------- | ---- | ------------ |
| FLASH_MODE_CLOSE | 0 | The flash is off.|
| FLASH_MODE_OPEN | 1 | The flash is on.|
| FLASH_MODE_AUTO | 2 | The flash mode is auto, indicating that the flash fires automatically depending on the shooting conditions.|
| FLASH_MODE_ALWAYS_OPEN | 3 | The flash is steady on.|
-## ExposureMode
-
-Enumerates the exposure modes.
-
-**System capability**: SystemCapability.Multimedia.Camera.Core
-
-| Name | Value | Description |
-| ----------------------------- | ---- | ----------- |
-| EXPOSURE_MODE_LOCKED | 0 | Exposure locked.|
-| EXPOSURE_MODE_AUTO | 1 | Auto exposure.|
-| EXPOSURE_MODE_CONTINUOUS_AUTO | 2 | Continuous auto exposure.|
-
## FocusMode
Enumerates the focus modes.
**System capability**: SystemCapability.Multimedia.Camera.Core
-| Name | Value | Description |
-| -------------------------- | ---- | ------------ |
+| Name | Value | Description |
+| -------------------------- | ---- | ------------------ |
| FOCUS_MODE_MANUAL | 0 | Manual focus. |
| FOCUS_MODE_CONTINUOUS_AUTO | 1 | Continuous auto focus.|
| FOCUS_MODE_AUTO | 2 | Auto focus. |
-| FOCUS_MODE_LOCKED | 3 | Focus locked. |
+| FOCUS_MODE_LOCKED | 3 | Focus locked. |
## FocusState
@@ -1317,40 +1098,70 @@ Enumerates the focus states.
**System capability**: SystemCapability.Multimedia.Camera.Core
-| Name | Value | Description |
-| --------------------- | ---- | --------- |
-| FOCUS_STATE_SCAN | 0 | Focusing. |
-| FOCUS_STATE_FOCUSED | 1 | Focused. |
+| Name | Value | Description |
+| --------------------- | ---- | ------------ |
+| FOCUS_STATE_SCAN | 0 | Focusing. |
+| FOCUS_STATE_FOCUSED | 1 | Focused.|
| FOCUS_STATE_UNFOCUSED | 2 | Unfocused.|
-## ExposureState
+## camera.createCaptureSession
+
+createCaptureSession\(context: Context, callback: AsyncCallback\): void
-Enumerates the exposure states.
+Creates a **CaptureSession** instance. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
-| Name | Value | Description |
-| ------------------------- | ---- | -------- |
-| EXPOSURE_STATE_SCAN | 0 | Exposing. |
-| EXPOSURE_STATE_CONVERGED | 1 | Exposure converged.|
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------------------------------- | ---- | -------------------------------------- |
+| context | Context | Yes | Application context. |
+| callback | AsyncCallback<[CaptureSession](#capturesession)\> | Yes | Callback used to return the **CaptureSession** instance.|
+
+**Example**
+
+```js
+camera.createCaptureSession((context), (err, captureSession) => {
+ if (err) {
+ console.error('Failed to create the CaptureSession instance. ${err.message}');
+ return;
+ }
+ console.log('Callback returned with the CaptureSession instance.' + captureSession);
+});
+```
+
+## camera.createCaptureSession
-## VideoStabilizationMode
+createCaptureSession(context: Context\): Promise;
-Enumerates the video stabilization modes.
+Creates a **CaptureSession** instance. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
-| Name | Value | Description |
-| --------- | ---- | ------------ |
-| OFF | 0 | Video stabilization is disabled. |
-| LOW | 1 | The basic video stabilization algorithm is used. |
-| MIDDLE | 2 | A video stabilization algorithm with a stabilization effect better than that of the **LOW** type is used. |
-| HIGH | 3 | A video stabilization algorithm with a stabilization effect better than that of the **MIDDLE** type is used. |
-| AUTO | 4 | Automatic video stabilization is used. |
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ------- | ------- | ---- | ------------ |
+| context | Context | Yes | Application context.|
+
+**Return value**
+
+| Type | Description |
+| ------------------------------------------- | ----------------------------------------- |
+| Promise<[CaptureSession](#capturesession)\> | Promise used to return the **CaptureSession** instance.|
+
+**Example**
+
+```js
+camera.createCaptureSession(context).then((captureSession) => {
+ console.log('Promise returned with the CaptureSession instance');
+})
+```
## CaptureSession
-Implements a shooting session, which saves all **[CameraInput](#camerainput)** and **[CameraOutput](#cameraoutput)** instances required to run the camera and requests the camera to complete shooting or video recording.
+Implements a shooting session.
### beginConfig
@@ -1362,8 +1173,8 @@ Starts configuration for this **CaptureSession** instance. This API uses an asyn
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | -------------------- | ---- | ------------------- |
+| Name | Type | Mandatory| Description |
+| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback | Yes | Callback used to return the result.|
**Example**
@@ -1371,7 +1182,7 @@ Starts configuration for this **CaptureSession** instance. This API uses an asyn
```js
captureSession.beginConfig((err) => {
if (err) {
- console.error(`Failed to start the configuration. ${err.message}`);
+ console.error('Failed to start the configuration. ${err.message}');
return;
}
console.log('Callback invoked to indicate the begin config success.');
@@ -1388,8 +1199,8 @@ Starts configuration for this **CaptureSession** instance. This API uses a promi
**Return value**
-| Type | Description |
-| -------------- | ------------------------ |
+| Type | Description |
+| -------------- | --------------------------- |
| Promise| Promise used to return the result.|
@@ -1411,8 +1222,8 @@ Commits the configuration for this **CaptureSession** instance. This API uses an
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | -------------------- | ---- | -------------------- |
+| Name | Type | Mandatory| Description |
+| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback | Yes | Callback used to return the result.|
**Example**
@@ -1420,7 +1231,7 @@ Commits the configuration for this **CaptureSession** instance. This API uses an
```js
captureSession.commitConfig((err) => {
if (err) {
- console.error(`Failed to commit the configuration. ${err.message}`);
+ console.error('Failed to commit the configuration. ${err.message}');
return;
}
console.log('Callback invoked to indicate the commit config success.');
@@ -1437,8 +1248,8 @@ Commits the configuration for this **CaptureSession** instance. This API uses a
**Return value**
-| Type | Description |
-| -------------- | ------------------------ |
+| Type | Description |
+| -------------- | --------------------------- |
| Promise| Promise used to return the result.|
**Example**
@@ -1449,529 +1260,546 @@ captureSession.commitConfig().then(() => {
})
```
-### canAddInput
+### addInput
-canAddInput(cameraInput: CameraInput, callback: AsyncCallback): void
+addInput\(cameraInput: CameraInput, callback: AsyncCallback\): void
-Checks whether a **[CameraInput](#camerainput)** instance can be added to this **CaptureSession**. This API uses an asynchronous callback to return the result.
+Adds a **CameraInput** instance to this **CaptureSession** instance. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| ----------- | --------------------------- | ---- | ------------------------ |
+| Name | Type | Mandatory| Description |
+| ----------- | --------------------------- | ---- | --------------------------- |
| cameraInput | [CameraInput](#camerainput) | Yes | **CameraInput** instance to add.|
-| callback | AsyncCallback | Yes | Callback used to return the result. |
+| callback | AsyncCallback | Yes | Callback used to return the result. |
**Example**
```js
-captureSession.canAddInput(cameraInput, (err, status) => {
+captureSession.addInput(cameraInput, (err) => {
if (err) {
- console.error(`Can not add cameraInput. ${err.message}`);
+ console.error('Failed to add the CameraInput instance. ${err.message}');
return;
}
- console.log('Callback returned with cameraInput can added.');
-})
+ console.log('Callback invoked to indicate that the CameraInput instance is added.');
+});
```
-### canAddInput
+### addInput
-canAddInput(cameraInput: CameraInput): Promise
+addInput\(cameraInput: CameraInput\): Promise
-Checks whether a **[CameraInput](#camerainput)** instance can be added to this **CaptureSession**. This API uses a promise to return the result.
+Adds a **CameraInput** instance to this **CaptureSession** instance. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| ----------- | --------------------------- | ---- | ------------------------ |
+| Name | Type | Mandatory| Description |
+| ----------- | --------------------------- | ---- | --------------------------- |
| cameraInput | [CameraInput](#camerainput) | Yes | **CameraInput** instance to add.|
**Return value**
-| Type | Description |
-| -------------- | -------------------------- |
-| Promise | Promise used to return the result.|
+| Type | Description |
+| -------------- | --------------------------- |
+| Promise| Promise used to return the result.|
**Example**
```js
-captureSession.canAddInput(cameraInput).then(() => {
- console.log('Promise returned with cameraInput can added.');
+captureSession.addInput(cameraInput).then(() => {
+ console.log('Promise used to indicate that the CameraInput instance is added.');
})
```
-### addInput
+### addOutput
-addInput\(cameraInput: CameraInput, callback: AsyncCallback\): void
+addOutput\(previewOutput: PreviewOutput, callback: AsyncCallback\): void
-Adds a **[CameraInput](#camerainput)** instance to this **CaptureSession**. This API uses an asynchronous callback to return the result.
+Adds a **PreviewOutput** instance to this **CaptureSession** instance. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| ----------- | --------------------------- | ---- | ------------------------ |
-| cameraInput | [CameraInput](#camerainput) | Yes | **CameraInput** instance to add.|
-| callback | AsyncCallback | Yes | Callback used to return the result. |
+| Name | Type | Mandatory| Description |
+| ------------- | ------------------------------- | ---- | ----------------------------- |
+| previewOutput | [PreviewOutput](#previewoutput) | Yes | **PreviewOutput** instance to add.|
+| callback | AsyncCallback | Yes | Callback used to return the result. |
**Example**
```js
-captureSession.addInput(cameraInput, (err) => {
+captureSession.addOutput(previewOutput, (err) => {
if (err) {
- console.error(`Failed to add the CameraInput instance. ${err.message}`);
+ console.error('Failed to add the PreviewOutput instance ${err.message}');
return;
}
- console.log('Callback invoked to indicate that the CameraInput instance is added.');
+ console.log('Callback invoked to indicate that the PreviewOutput instance is added.');
});
```
-### addInput
+### addOutput
-addInput\(cameraInput: CameraInput\): Promise
+addOutput\(previewOutput: PreviewOutput\): Promise
-Adds a **[CameraInput](#camerainput)** instance to this **CaptureSession**. This API uses a promise to return the result.
+Adds a **PreviewOutput** instance to this **CaptureSession** instance. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| ----------- | --------------------------- | ---- | ------------------------ |
-| cameraInput | [CameraInput](#camerainput) | Yes | **CameraInput** instance to add.|
+| Name | Type | Mandatory| Description |
+| ------------- | ------------------------------- | ---- | ----------------------------- |
+| previewOutput | [PreviewOutput](#previewoutput) | Yes | **PreviewOutput** instance to add.|
**Return value**
-| Type | Description |
-| -------------- | ------------------------ |
+| Type | Description |
+| -------------- | --------------------------- |
| Promise| Promise used to return the result.|
**Example**
```js
-captureSession.addInput(cameraInput).then(() => {
- console.log('Promise used to indicate that the CameraInput instance is added.');
+captureSession.addOutput(previewOutput).then(() => {
+ console.log('Promise used to indicate that the PreviewOutput instance is added.');
})
```
-### removeInput
+### addOutput
-removeInput\(cameraInput: CameraInput, callback: AsyncCallback\): void
+addOutput\(photoOutput: PhotoOutput, callback: AsyncCallback\): void
-Removes a **[CameraInput](#camerainput)** instance from this **CaptureSession**. This API uses an asynchronous callback to return the result.
+Adds a **PhotoOutput** instance to this **CaptureSession** instance. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| ----------- | --------------------------- | ---- | ------------------------ |
-| cameraInput | [CameraInput](#camerainput) | Yes | **CameraInput** instance to remove.|
+| Name | Type | Mandatory| Description |
+| ----------- | --------------------------- | ---- | --------------------------- |
+| photoOutput | [PhotoOutput](#photooutput) | Yes | **PhotoOutput** instance to add.|
| callback | AsyncCallback | Yes | Callback used to return the result. |
**Example**
```js
-captureSession.removeInput(cameraInput, (err) => {
+captureSession.addOutput(photoOutput, (err) => {
if (err) {
- console.error(`Failed to remove the CameraInput instance. ${err.message}`);
+ console.error('Failed to add the PhotoOutput instance ${err.message}');
return;
}
- console.log('Callback invoked to indicate that the cameraInput instance is removed.');
+ console.log('Callback invoked to indicate that the PhotoOutput instance is added.');
});
```
-### removeInput
+### addOutput
-removeInput\(cameraInput: CameraInput\): Promise
+addOutput\(photoOutput: PhotoOutput\): Promise
-Removes a **[CameraInput](#camerainput)** instance from this **CaptureSession**. This API uses a promise to return the result.
+Adds a **PhotoOutput** instance to this **CaptureSession** instance. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| ----------- | --------------------------- | ---- | ------------------------ |
-| cameraInput | [CameraInput](#camerainput) | Yes | **CameraInput** instance to remove.|
+| Name | Type | Mandatory| Description |
+| ----------- | --------------------------- | ---- | --------------------------- |
+| photoOutput | [PhotoOutput](#photooutput) | Yes | **PhotoOutput** instance to add.|
**Return value**
-| Type | Description |
-| -------------- | ------------------------- |
-| Promise\ | Promise used to return the result.|
+| Type | Description |
+| -------------- | --------------------------- |
+| Promise\ | Promise used to return the result.|
**Example**
```js
-captureSession.removeInput(cameraInput).then(() => {
- console.log('Promise returned to indicate that the cameraInput instance is removed.');
+captureSession.addOutput(photoOutput).then(() => {
+ console.log('Promise used to indicate that the PhotoOutput instance is added.');
})
```
-### canAddOutput
+### addOutput
-canAddOutput(cameraOutput: CameraOutput, callback: AsyncCallback\): void
+addOutput\(videoOutput: VideoOutput, callback: AsyncCallback\): void
-Checks whether a **[CameraOutput](#cameraoutput)** instance can be added to this **CaptureSession**. This API uses an asynchronous callback to return the result.
+Adds a **VideoOutput** instance to this **CaptureSession** instance. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| ------------- | ------------------------------- | ---- | ------------------------- |
-| cameraOutput | [CameraOutput](#cameraoutput) | Yes | **CameraOutput** instance to add.|
-| callback | AsyncCallback | Yes | Callback used to return the result. |
+| Name | Type | Mandatory| Description |
+| ----------- | --------------------------- | ---- | --------------------------- |
+| videoOutput | [VideoOutput](#videooutput) | Yes | **VideoOutput** instance to add.|
+| callback | AsyncCallback | Yes | Callback used to return the result. |
**Example**
```js
-captureSession.canAddOutput(cameraOutput, (err, status) => {
+captureSession.addOutput(videoOutput, (err) => {
if (err) {
- console.error(`Can not add cameraOutput. ${err.message}`);
+ console.error('Failed to add the VideoOutput instance ${err.message}');
return;
}
- console.log('Callback returned with cameraOutput can added.');
-})
+ console.log('Callback invoked to indicate that the VideoOutput instance is added.');
+});
```
-### canAddOutput
+### addOutput
-canAddOutput(cameraOutput: CameraOutput): Promise
+addOutput\(videoOutput: VideoOutput\): Promise
-Checks whether a **[CameraOutput](#cameraoutput)** instance can be added to this **CaptureSession**. This API uses a promise to return the result.
+Adds a **VideoOutput** instance to this **CaptureSession** instance. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| ------------- | ------------------------------- | ---- | ------------------------- |
-| cameraOutput | [CameraOutput](#cameraoutput) | Yes | **CameraOutput** instance to add.|
-
+| Name | Type | Mandatory| Description |
+| ----------- | --------------------------- | ---- | --------------------------- |
+| videoOutput | [VideoOutput](#videooutput) | Yes | **VideoOutput** instance to add.|
**Return value**
-| Type | Description |
+| Type | Description |
| -------------- | --------------------------- |
-| Promise | Promise used to return the result.|
-
+| Promise\ | Promise used to return the result.|
**Example**
```js
-captureSession.canAddOutput(cameraOutput).then(() => {
- console.log('Promise returned with cameraOutput can added.');
+captureSession.addOutput(videoOutput).then(() => {
+ console.log('Promise used to indicate that the VideoOutput instance is added.');
})
```
-### addOutput
+### removeInput
-addOutput\(cameraOutput: CameraOutput, callback: AsyncCallback\): void
+removeInput\(cameraInput: CameraInput, callback: AsyncCallback\): void
-Adds a **[CameraOutput](#cameraoutput)** instance to this **CaptureSession**. This API uses an asynchronous callback to return the result.
+Removes a **CameraInput** instance from this **CaptureSession** instance. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| ------------- | ------------------------------- | ---- | ------------------------ |
-| cameraOutput | [CameraOutput](#cameraoutput) | Yes | **CameraOutput** instance to add.|
-| callback | AsyncCallback | Yes | Callback used to return the result. |
+| Name | Type | Mandatory| Description |
+| ----------- | --------------------------- | ---- | --------------------------- |
+| cameraInput | [CameraInput](#camerainput) | Yes | **CameraInput** instance to remove.|
+| callback | AsyncCallback | Yes | Callback used to return the result. |
**Example**
```js
-captureSession.addOutput(cameraOutput, (err) => {
+captureSession.removeInput(cameraInput, (err) => {
if (err) {
- console.error(`Failed to add output. ${err.message}`);
+ console.error('Failed to remove the CameraInput instance. ${err.message}');
return;
}
- console.log('Callback returned with output added.');
-})
+ console.log('Callback invoked to indicate that the cameraInput instance is removed.');
+});
```
-### addOutput
+### removeInput
-addOutput\(cameraOutput: CameraOutput\): Promise
+removeInput\(cameraInput: CameraInput\): Promise
-Adds a **[CameraOutput](#cameraoutput)** instance to this **CaptureSession**. This API uses a promise to return the result.
+Removes a **CameraInput** instance from this **CaptureSession** instance. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| ------------- | ------------------------------- | ---- | ------------------------- |
-| cameraOutput | [CameraOutput](#cameraoutput) | Yes | **CameraOutput** instance to add.|
+| Name | Type | Mandatory| Description |
+| ----------- | --------------------------- | ---- | --------------------------- |
+| cameraInput | [CameraInput](#camerainput) | Yes | **CameraInput** instance to remove.|
**Return value**
-| Type | Description |
-| -------------- | ----------------------- |
-| Promise| Promise used to return the result.|
+| Type | Description |
+| -------------- | --------------------------- |
+| Promise\ | Promise used to return the result.|
**Example**
```js
-captureSession.addOutput(cameraOutput).then(() => {
- console.log('Promise returned with cameraOutput added.');
+captureSession.removeInput(cameraInput).then(() => {
+ console.log('Promise returned to indicate that the cameraInput instance is removed.');
})
```
### removeOutput
-removeOutput\(cameraOutput: CameraOutput, callback: AsyncCallback\): void
+removeOutput\(previewOutput: PreviewOutput, callback: AsyncCallback\): void
-Removes a **[CameraOutput](#cameraoutput)** instance from this **CaptureSession**. This API uses an asynchronous callback to return the result.
+Removes a **PreviewOutput** instance from this **CaptureSession** instance. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| ------------- | ------------------------------- | ---- | ------------------------ |
-| cameraOutput | [CameraOutput](#cameraoutput) | Yes | **CameraOutput** instance to remove.|
+| Name | Type | Mandatory| Description |
+| ------------- | ------------------------------- | ---- | ----------------------------- |
+| previewOutput | [PreviewOutput](#previewoutput) | Yes | **PreviewOutput** instance to remove.|
| callback | AsyncCallback | Yes | Callback used to return the result. |
**Example**
```js
-captureSession.removeOutput(cameraOutput, (err) => {
+captureSession.removeOutput(previewOutput, (err) => {
if (err) {
- console.error(`Failed to remove the CameraOutput instance. ${err.message}`);
+ console.error('Failed to remove the PreviewOutput instance. ${err.message}');
return;
}
- console.log('Callback invoked to indicate that the CameraOutput instance is removed.');
+ console.log('Callback invoked to indicate that the PreviewOutput instance is removed.');
});
```
### removeOutput
-removeOutput(cameraOutput: CameraOutput): Promise
+removeOutput(previewOutput: PreviewOutput): Promise
-Removes a **[CameraOutput](#cameraoutput)** instance from this **CaptureSession**. This API uses a promise to return the result.
+Removes a **PreviewOutput** instance from this **CaptureSession** instance. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| ------------- | ------------------------------- | ---- | ------------------------- |
-| cameraOutput | [CameraOutput](#cameraoutput) | Yes | **CameraOutput** instance to remove.|
+| Name | Type | Mandatory| Description |
+| ------------- | ------------------------------- | ---- | ----------------------------- |
+| previewOutput | [PreviewOutput](#previewoutput) | Yes | **PreviewOutput** instance to remove.|
**Return value**
-| Type | Description |
-| -------------- | ------------------------ |
+| Type | Description |
+| -------------- | --------------------------- |
| Promise| Promise used to return the result.|
**Example**
```js
-captureSession.removeOutput(cameraOutput).then(() => {
- console.log('Promise returned to indicate that the CameraOutput instance is removed.');
+captureSession.removeOutput(previewOutput).then(() => {
+ console.log('Promise returned to indicate that the PreviewOutput instance is removed.');
})
```
-### start
+### removeOutput
-start\(callback: AsyncCallback\): void
+removeOutput(photoOutput: PhotoOutput, callback: AsyncCallback): void
-Starts this **CaptureSession**. This API uses an asynchronous callback to return the result.
+Removes a **PhotoOutput** instance from this **CaptureSession** instance. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | -------------------- | ---- | -------------------- |
-| callback | AsyncCallback | Yes | Callback used to return the result.|
+| Name | Type | Mandatory| Description |
+| ----------- | --------------------------- | ---- | --------------------------- |
+| photoOutput | [PhotoOutput](#photooutput) | Yes | **PhotoOutput** instance to remove.|
+| callback | AsyncCallback | Yes | Callback used to return the result. |
**Example**
```js
-captureSession.start((err) => {
+captureSession.removeOutput(photoOutput, (err) => {
if (err) {
- console.error(`Failed to start the session ${err.message}`);
+ console.error('Failed to remove the PhotoOutput instance. ${err.message}');
return;
}
- console.log('Callback invoked to indicate the session start success.');
+ console.log('Callback invoked to indicate that the PhotoOutput instance is removed.');
});
```
-### start
+### removeOutput
-start\(\): Promise
+removeOutput(photoOutput: PhotoOutput): Promise
-Starts this **CaptureSession**. This API uses a promise to return the result.
+Removes a **PhotoOutput** instance from this **CaptureSession** instance. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ----------- | --------------------------- | ---- | --------------------------- |
+| photoOutput | [PhotoOutput](#photooutput) | Yes | **PhotoOutput** instance to remove.|
+
+
**Return value**
-| Type | Description |
-| -------------- | ------------------------ |
+| Type | Description |
+| -------------- | --------------------------- |
| Promise| Promise used to return the result.|
+
**Example**
```js
-captureSession.start().then(() => {
- console.log('Promise returned to indicate the session start success.');
+captureSession.removeOutput(photoOutput).then(() => {
+ console.log('Promise returned to indicate that the PhotoOutput instance is removed.');
})
```
-### stop
+### removeOutput
-stop\(callback: AsyncCallback\): void
+removeOutput(videoOutput: VideoOutput, callback: AsyncCallback): void
-Stops this **CaptureSession**. This API uses an asynchronous callback to return the result.
+Removes a **VideoOutput** instance from this **CaptureSession** instance. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | -------------------- | ---- | ------------------- |
-| callback | AsyncCallback | Yes | Callback used to return the result.|
+| Name | Type | Mandatory| Description |
+| ----------- | --------------------------- | ---- | --------------------------- |
+| videoOutput | [VideoOutput](#videooutput) | Yes | **VideoOutput** instance to remove.|
+| callback | AsyncCallback | Yes | Callback used to return the result. |
**Example**
```js
-captureSession.stop((err) => {
+captureSession.removeOutput(videoOutput, (err) => {
if (err) {
- console.error(`Failed to stop the session ${err.message}`);
+ console.error('Failed to remove the VideoOutput instance. ${err.message}');
return;
}
- console.log('Callback invoked to indicate the session stop success.');
+ console.log('Callback invoked to indicate that the VideoOutput instance is removed.');
});
```
-### stop
+### removeOutput
-stop(): Promise
+removeOutput(videoOutput: VideoOutput): Promise
-Stops this **CaptureSession**. This API uses a promise to return the result.
+Removes a **VideoOutput** instance from this **CaptureSession** instance. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ----------- | --------------------------- | ---- | --------------------------- |
+| videoOutput | [VideoOutput](#videooutput) | Yes | **VideoOutput** instance to remove.|
+
+
**Return value**
-| Type | Description |
-| -------------- | ----------------------- |
+| Type | Description |
+| -------------- | --------------------------- |
| Promise| Promise used to return the result.|
+
**Example**
```js
-captureSession.stop().then(() => {
- console.log('Promise returned to indicate the session stop success.');
+captureSession.removeOutput(videoOutput).then(() => {
+ console.log('Promise returned to indicate that the VideoOutput instance is removed.');
})
```
-### lockForControl
+### start
-lockForControl(callback: AsyncCallback): void
+start\(callback: AsyncCallback\): void
-Requests to exclusively control the hardware attributes **[CameraInput](#camerainput)** of the camera device. This API uses an asynchronous callback to return the result. After the exclusive control is complete, you must call **[unlockForControl](#unlockforcontrol)** to release the exclusive control.
+Starts this **CaptureSession** instance. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | -------------------- | ---- | ------------------- |
+| Name | Type | Mandatory| Description |
+| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback | Yes | Callback used to return the result.|
**Example**
```js
-captureSession.lockForControl((err) => {
+captureSession.start((err) => {
if (err) {
- console.error(`Failed to lock. ${err.message}`);
+ console.error('Failed to start the session ${err.message}');
return;
}
- console.log('Locked.');
-})
+ console.log('Callback invoked to indicate the session start success.');
+});
```
-### lockForControl
+### start
-lockForControl(): Promise
+start\(\): Promise
-Requests to exclusively control the hardware attributes **[CameraInput](#camerainput)** of the camera device. This API uses a promise to return the result. After the exclusive control is complete, you must call **[unlockForControl](#unlockforcontrol)** to release the exclusive control.
+Starts this **CaptureSession** instance. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Return value**
-| Type | Description |
-| -------------- | ------------------------ |
+| Type | Description |
+| -------------- | --------------------------- |
| Promise| Promise used to return the result.|
**Example**
```js
-captureSession.lockForControl().then(() => {
- console.log('Locked.');
+captureSession.start().then(() => {
+ console.log('Promise returned to indicate the session start success.');
})
```
-### unlockForControl
+### stop
-unlockForControl(callback: AsyncCallback): void
+stop\(callback: AsyncCallback\): void
-Releases the exclusive control on the device configuration. This API uses an asynchronous callback to return the result.
+Stops this **CaptureSession** instance. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | -------------------- | ---- | -------------------- |
+
+| Name | Type | Mandatory| Description |
+| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback | Yes | Callback used to return the result.|
**Example**
```js
-captureSession.unlockForControl((err) => {
+captureSession.stop((err) => {
if (err) {
- console.error(`Failed to unlock. ${err.message}`);
+ console.error('Failed to stop the session ${err.message}');
return;
}
- console.log('Unlocked.');
-})
+ console.log('Callback invoked to indicate the session stop success.');
+});
```
-### unlockForControl
+### stop
-unlockForControl(): Promise
+stop(): Promise
-Releases the exclusive control on the device configuration. This API uses a promise to return the result.
+Stops this **CaptureSession** instance. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Return value**
-| Type | Description |
-| -------------- | ------------------------ |
+| Type | Description |
+| -------------- | --------------------------- |
| Promise| Promise used to return the result.|
**Example**
```js
-captureSession.unlockForControl().then(() => {
- console.log('Unlocked.');
+captureSession.stop().then(() => {
+ console.log('Promise returned to indicate the session stop success.');
})
```
@@ -1979,14 +1807,14 @@ captureSession.unlockForControl().then(() => {
release\(callback: AsyncCallback\): void
-Releases this **CaptureSession**. This API uses an asynchronous callback to return the result.
+Releases this **CaptureSession** instance. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | -------------------- | ---- | -------------------- |
+| Name | Type | Mandatory| Description |
+| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback | Yes | Callback used to return the result.|
**Example**
@@ -1994,7 +1822,7 @@ Releases this **CaptureSession**. This API uses an asynchronous callback to retu
```js
captureSession.release((err) => {
if (err) {
- console.error(`Failed to release the CaptureSession instance ${err.message}`);
+ console.error('Failed to release the CaptureSession instance ${err.message}');
return;
}
console.log('Callback invoked to indicate that the CaptureSession instance is released successfully.');
@@ -2005,14 +1833,14 @@ captureSession.release((err) => {
release(): Promise
-Releases this **CaptureSession**. This API uses a promise to return the result.
+Releases this **CaptureSession** instance. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Return value**
-| Type | Description |
-| -------------- | ------------------------ |
+| Type | Description |
+| -------------- | --------------------------- |
| Promise| Promise used to return the result.|
**Example**
@@ -2023,2077 +1851,433 @@ captureSession.release().then(() => {
})
```
-### hasFlash
+### on('error')
-hasFlash(callback: AsyncCallback): void
+on(type: 'error', callback: ErrorCallback): void
-Checks whether the device has flash. This API uses an asynchronous callback to return the result.
+Listens for **CaptureSession** errors. This API uses a callback to return the errors.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ----------------------- | ---- | -------------------------------- |
-| callback | AsyncCallback | Yes | Callback used to return the flash support status. The value **true** means that the device has flash.|
+| Name | Type | Mandatory| Description |
+| :------- | :---------------------------------------------------------- | :--- | :-------------------------------------------- |
+| type | string | Yes | Event type. The value is fixed at **'error'**, indicating the capture session error event.|
+| callback | ErrorCallback<[CaptureSessionError](#capturesessionerror)\> | Yes | Callback used to return the error information. |
**Example**
```js
-cameraInput.hasFlash((err, status) => {
- if (err) {
- console.error(`Failed to check whether the device has flash light. ${err.message}`);
- return;
- }
- console.log(`Callback returned with flash light support status: ${status}`);
+captureSession.on('error', (captureSessionError) => {
+ console.log('Capture session error code: ' + captureSessionError.code);
})
```
-### hasFlash
-
-hasFlash(): Promise
+## CaptureSessionErrorCode
-Checks whether the device has flash. This API uses a promise to return the result.
+Enumerates the error codes used in a **CaptureSession** instance.
**System capability**: SystemCapability.Multimedia.Camera.Core
-**Return value**
+| Name | Value | Description |
+| ------------- | ---- | ---------- |
+| ERROR_UNKNOWN | -1 | Unknown error.|
-| Type | Description |
-| ----------------- | ----------------------------------------------- |
-| Promise | Promise used to return the flash support status. The value **true** means that the device has flash.|
+## CaptureSessionError
-**Example**
+Defines a **CaptureSession** error.
-```js
-cameraInput.hasFlash().then((status) => {
- console.log(`Promise returned with the flash light support status: ${status}`);
-})
-```
+**System capability**: SystemCapability.Multimedia.Camera.Core
-### isFlashModeSupported
+| Name| Type | Description |
+| ---- | ------------------------------------------- | -------------------------- |
+| code | [CaptureSessionError](#capturesessionerror) | **CaptureSession** error code.|
-isFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback): void
+## camera.createPreviewOutput
-Checks whether a specified flash mode is supported. This API uses an asynchronous callback to return the result.
+createPreviewOutput(surfaceId: string, callback: AsyncCallback): void
+
+Creates a **PreviewOutput** instance. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| --------- | ----------------------- | ---- | --------------------------------- |
-| flashMode | [FlashMode](#flashmode) | Yes | Flash mode. |
-| callback | AsyncCallback | Yes | Callback used to return the flash mode support status. The value **true** means that the flash mode is supported, and **false** means the opposite.|
+| Name | Type | Mandatory| Description |
+| --------- | ----------------------------------------------- | ---- | ------------------------------------- |
+| surfaceId | string | Yes | Surface ID, which is obtained from **XComponent**. |
+| callback | AsyncCallback<[PreviewOutput](#previewoutput)\> | Yes | Callback used to return the **PreviewOutput** instance.|
**Example**
```js
-cameraInput.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO, (err, status) => {
+camera.createPreviewOutput(("surfaceId"), (err, previewOutput) => {
if (err) {
- console.error(`Failed to check whether the flash mode is supported. ${err.message}`);
+ console.error('Failed to create the PreviewOutput instance. ${err.message}');
return;
}
- console.log(`Callback returned with the flash mode support status: ${status}`);
-})
+ console.log('Callback returned with previewOutput instance');
+});
```
-### isFlashModeSupported
+## camera.createPreviewOutput
-isFlashModeSupported(flashMode: FlashMode): Promise
+createPreviewOutput(surfaceId: string): Promise\
-Checks whether a specified flash mode is supported. This API uses a promise to return the result.
+Creates a **PreviewOutput** instance. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| --------- | ----------------------- | ---- | ------------- |
-| flashMode | [FlashMode](#flashmode) | Yes | Flash mode.|
+| Name | Type | Mandatory| Description |
+| --------- | ------ | ---- | ---------------------------------- |
+| surfaceId | string | Yes | Surface ID, which is obtained from **XComponent**.|
**Return value**
-| Type | Description |
-| ----------------- | ---------------------------------------------------- |
-| Promise | Promise used to return the flash mode support status. The value **true** means that the flash mode is supported, and **false** means the opposite.|
+| Type | Description |
+| ----------------------------------------- | --------------------------- |
+| Promise<[PreviewOutput](#previewoutput)\> | Promise used to return the result.|
**Example**
```js
-cameraInput.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO).then((status) => {
- console.log(`Promise returned with flash mode support status.${status}`);
+camera.createPreviewOutput("surfaceId").then((previewOutput) => {
+ console.log('Promise returned with the PreviewOutput instance');
})
```
-### setFlashMode
+## PreviewOutput
-setFlashMode(flashMode: FlashMode, callback: AsyncCallback): void
+Implements preview output.
-Sets the flash mode. This API uses an asynchronous callback to return the result.
+### release
-Before the setting, do the following checks:
+release(callback: AsyncCallback): void
-1. Use **[hasFlash](#hasflash)** to check whether the device has flash.
-2. Use **[isFlashModeSupported](#isflashmodesupported)** to check whether the device supports the flash mode.
+Releases this **PreviewOutput** instance. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| --------- | ----------------------- | ---- | --------------------- |
-| flashMode | [FlashMode](#flashmode) | Yes | Flash mode. |
-| callback | AsyncCallback | Yes | Callback used to return the result.|
+| Name | Type | Mandatory| Description |
+| -------- | -------------------- | ---- | ------------------------ |
+| callback | AsyncCallback | Yes | Callback used to return the result.|
**Example**
```js
-cameraInput.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO, (err) => {
+previewOutput.release((err) => {
if (err) {
- console.error(`Failed to set the flash mode ${err.message}`);
+ console.error('Failed to release the PreviewOutput instance ${err.message}');
return;
}
- console.log('Callback returned with the successful execution of setFlashMode.');
-})
+ console.log('Callback invoked to indicate that the PreviewOutput instance is released successfully.');
+});
```
-### setFlashMode
-
-setFlashMode(flashMode: FlashMode): Promise
-
-Sets a flash mode. This API uses a promise to return the result.
+### release
-Before the setting, do the following checks:
+release(): Promise
-1. Use **[hasFlash](#hasflash)** to check whether the device has flash.
-2. Use **[isFlashModeSupported](#isflashmodesupported)** to check whether the device supports the flash mode.
+Releases this **PreviewOutput** instance. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| --------- | ----------------------- | ---- | ------------- |
-| flashMode | [FlashMode](#flashmode) | Yes | Flash mode.|
-
**Return value**
-| Type | Description |
-| -------------- | ------------------------ |
+| Type | Description |
+| -------------- | --------------------------- |
| Promise| Promise used to return the result.|
+
**Example**
```js
-cameraInput.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO).then(() => {
- console.log('Promise returned with the successful execution of setFlashMode.');
+previewOutput.release().then(() => {
+ console.log('Promise returned to indicate that the PreviewOutput instance is released successfully.');
})
```
-### getFlashMode
+### on('frameStart')
-getFlashMode(callback: AsyncCallback): void
+on(type: 'frameStart', callback: AsyncCallback): void
-Obtains the flash mode in use. This API uses an asynchronous callback to return the result.
+Listens for preview frame start events. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | --------------------------------------- | ---- | --------------------------------- |
-| callback | AsyncCallback<[FlashMode](#flashmode)\> | Yes | Callback used to return the flash mode.|
+| Name | Type | Mandatory| Description |
+| :------- | :------------------- | :--- | :------------------------------------------- |
+| type | string | Yes | Event type. The value is fixed at **'frameStart'**, indicating the preview frame start event.|
+| callback | AsyncCallback | Yes | Callback used to return the result. |
**Example**
```js
-cameraInput.getFlashMode((err, flashMode) => {
- if (err) {
- console.error(`Failed to get the flash mode ${err.message}`);
- return;
- }
- console.log(`Callback returned with current flash mode: ${flashMode}`);
+previewOutput.on('frameStart', () => {
+ console.log('Preview frame started');
})
```
-### getFlashMode
+### on('frameEnd')
-getFlashMode(): Promise