diff --git a/CODEOWNERS b/CODEOWNERS
index b3a89aecb5c1bf1907db23aabcb7d61adecc8ab3..e62f30a3bd5e21f7ed3f181a108e770f518ac4da 100644
--- a/CODEOWNERS
+++ b/CODEOWNERS
@@ -397,7 +397,7 @@ zh-cn/application-dev/reference/apis/js-apis-notification.md @jayleehw @RayShih
zh-cn/application-dev/reference/apis/js-apis-observer.md @zhang-hai-feng @zengyawen @jyh926 @gaoxi785
zh-cn/application-dev/reference/apis/js-apis-osAccount.md @nianCode @zengyawen @JiDong-CS @murphy1984
zh-cn/application-dev/reference/apis/js-apis-particleAbility.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen
-zh-cn/application-dev/reference/apis/js-apis-pasteboard.md @feng-aiwen @ge-yafang @gong-a-shi @logic42
+zh-cn/application-dev/reference/apis/js-apis-pasteboard.md @han-zhengshi @ge-yafang @logic42
zh-cn/application-dev/reference/apis/js-apis-permissionrequestresult.md @littlejerry1 @RayShih @gwang2008 @chengxingzhen
zh-cn/application-dev/reference/apis/js-apis-plainarray.md @gongjunsong @ge-yafang @flyingwolf @BlackStone
zh-cn/application-dev/reference/apis/js-apis-pointer.md @yuanxinying @ningningW @cococoler @alien0208
@@ -415,7 +415,7 @@ zh-cn/application-dev/reference/apis/js-apis-resource-manager.md @Buda-Liu @ning
zh-cn/application-dev/reference/apis/js-apis-router.md @huaweimaxuchu @HelloCrease @niulihua @tomatodevboy
zh-cn/application-dev/reference/apis/js-apis-rpc.md @xuepianpian @RayShih @zhaopeng_gitee @vagrant_world
zh-cn/application-dev/reference/apis/js-apis-runninglock.md @aqxyjay @zengyawen @aqxyjay @alien0208
-zh-cn/application-dev/reference/apis/js-apis-screen-lock.md @feng-aiwen @ningningW @wangzhangjun @murphy1984
+
zh-cn/application-dev/reference/apis/js-apis-screen.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee
zh-cn/application-dev/reference/apis/js-apis-screenshot.md @zhangqiang183 @ge-yafang @zhouyaoying @zxg-gitee
zh-cn/application-dev/reference/apis/js-apis-securityLabel.md @panqinxu @zengyawen @bubble_mao @jinhaihw
@@ -531,6 +531,7 @@ zh-cn/application-dev/reference/apis/js-apis-distributedBundle.md @shuaytao @Ray
zh-cn/application-dev/reference/apis/js-apis-distributedKVStore.md @feng-aiwen @ge-yafang @gong-a-shi @logic42
zh-cn/application-dev/reference/apis/js-apis-enterprise-accountManager.md @liuzuming @ningningW @yangqing3
zh-cn/application-dev/reference/apis/js-apis-enterprise-adminManager.md @liuzuming @ningningW @yangqing3
+zh-cn/application-dev/reference/apis/js-apis-enterprise-bundleManager.md @liuzuming @ningningW @yangqing3
zh-cn/application-dev/reference/apis/js-apis-enterprise-dateTimeManager.md @liuzuming @ningningW @yangqing3
zh-cn/application-dev/reference/apis/js-apis-enterprise-deviceControl.md @liuzuming @ningningW @yangqing3
zh-cn/application-dev/reference/apis/js-apis-enterprise-deviceInfo.md @liuzuming @ningningW @yangqing3
diff --git a/README_zh.md b/README_zh.md
index 6e71a0abd9fba5cbe4b4de47c77437d3a851aa45..b69235fdbdc19771dbae119f8873b610a7adf65c 100644
--- a/README_zh.md
+++ b/README_zh.md
@@ -18,7 +18,7 @@
- master:最新开发版本。
- - OpenHarmony 3.2 Beta5版本:点击[此处](zh-cn/release-notes/OpenHarmony-v3.2-beta5.md)了解版本详情。
+ - OpenHarmony 3.2 Release版本:点击[此处](zh-cn/release-notes/OpenHarmony-v3.2-release.md)了解版本详情。
- OpenHarmony 3.1 Release版本:点击[此处](zh-cn/release-notes/OpenHarmony-v3.1-release.md)了解版本详情。
diff --git a/en/OpenHarmony-Overview.md b/en/OpenHarmony-Overview.md
index 594fb355e417b047d93b1de9d413540a2c839190..a8dbb1b636a19fe6a2b7e6dee741b56dac0e6289 100644
--- a/en/OpenHarmony-Overview.md
+++ b/en/OpenHarmony-Overview.md
@@ -127,7 +127,7 @@ The following table describes the subsystems of OpenHarmony. For details about t
| Build | Provides a compilation and building framework based on Generate Ninja (GN) and Ninja. | All systems |
| Test | The test-driven development mode is used during the development process. You can develop new cases or modify existing cases to test new or enhanced system features. The test helps you develop high-quality code in the development phase.| All systems |
| Data Management | Provides local data management and distributed data management:
- Local application data management for lightweight preference databases and relational databases
- Distributed data service to provide applications with the capability to store data in the databases of different devices| Standard system |
-| Programming Language Runtime| Provides the compilation and execution environment for programs developed with JavaScript or C/C++, basic libraries that support the runtime, and the runtime-associated APIs, compilers, and auxiliary tools.| All systems |
+| Compiler and Runtime | Provides the compilation and execution environment for programs developed with JavaScript or C/C++, basic libraries that support the runtime, and the runtime-associated APIs, compilers, and auxiliary tools.| All systems |
| Distributed Scheduler| Starts, registers, queries, and manages system services. | All systems |
| JS UI Framework | OpenHarmony JS UI framework supports web-development-like paradigm. | All systems |
| Multimedia | Provides easy-to-use APIs for developing multimedia components such as audio, video, and camera, and enables applications to use multimedia resources of the system.| All systems |
diff --git a/en/application-dev/IDL/idl-guidelines.md b/en/application-dev/IDL/idl-guidelines.md
index f165215bad4d663b794c249f8029d33aeeda5863..a7ce0ec46adeeca0dd697cd8dabde834b7cc14fc 100644
--- a/en/application-dev/IDL/idl-guidelines.md
+++ b/en/application-dev/IDL/idl-guidelines.md
@@ -3,7 +3,7 @@
## IDL Overview
To ensure successful communications between the client and server, interfaces recognized by both parties must be defined. The OpenHarmony Interface Definition Language (IDL) is a tool for defining such interfaces. OpenHarmony IDL decomposes objects to be transferred into primitives that can be understood by the operating system and encapsulates cross-boundary objects based on developers' requirements.
- **Figure 1** IDL interface description
+**Figure 1** IDL interface description

@@ -156,11 +156,13 @@ On DevEco Studio, choose **Tools > SDK Manager** to view the local installation
Go to the local installation path, choose **toolchains > 3.x.x.x** (the folder named after the version number), and check whether the executable file of IDL exists.
-> **NOTE**: Use the SDK of the latest version. The use of an earlier version may cause errors in some statements.
+> **NOTE**
+>
+> Use the SDK of the latest version. The use of an earlier version may cause errors in some statements.
-If the executable file does not exist, download the SDK package from the mirror as instructed in the [Release Notes](../../release-notes). The following uses the [3.2 Beta3](../../release-notes/OpenHarmony-v3.2-beta3.md#acquiring-source-code-from-mirrors) as an example.
+If the executable file does not exist, download the SDK package from the mirror as instructed in the [Release Notes](../../release-notes). The following uses [3.2 Beta3](../../release-notes/OpenHarmony-v3.2-beta3.md) as an example.
-For details about how to replace the SDK package, see [Guide to Switching to Full SDK](../quick-start/full-sdk-switch-guide.md).
+For details about how to replace the SDK package, see [Full SDK Compilation Guide](../quick-start/full-sdk-compile-guide.md).
After obtaining the executable file, perform subsequent development steps based on your scenario.
@@ -176,6 +178,8 @@ You can use TS to create IDL files.
interface OHOS.IIdlTestService {
int TestIntTransaction([in] int data);
void TestStringTransaction([in] String data);
+ void TestMapTransaction([in] Map data);
+ int TestArrayTransaction([in] String[] data);
}
```
@@ -183,7 +187,9 @@ Run the **idl -gen-ts -d *dir* -c dir/IIdlTestService.idl** command in the folde
-*dir* next to **d** is the target output folder. For example, if the target output folder is **IIdlTestServiceTs**, run the **idl -gen-ts -d IIdlTestServiceTs -c IIdlTestServiceTs/IIdlTestService.idl** command in the folder where the executable file is located. The interface file, stub file, and proxy file are generated in the *dir* directory (**IIdlTestServiceTs** directory in this example) in the execution environment.
-> **NOTE**: The generated interface class file name must be the same as that of the .idl file. Otherwise, an error occurs during code generation.
+> **NOTE**
+>
+> The generated interface class file name must be the same as that of the .idl file. Otherwise, an error occurs during code generation.
For example, for an .idl file named **IIdlTestService.idl** and target output directory named **IIdlTestServiceTs**, the directory structure is similar to the following:
@@ -203,6 +209,8 @@ The stub class generated by IDL is an abstract implementation of the interface c
```ts
import {testIntTransactionCallback} from "./i_idl_test_service";
import {testStringTransactionCallback} from "./i_idl_test_service";
+import {testMapTransactionCallback} from "./i_idl_test_service";
+import {testArrayTransactionCallback} from "./i_idl_test_service";
import IIdlTestService from "./i_idl_test_service";
import rpc from "@ohos.rpc";
@@ -211,8 +219,8 @@ export default class IdlTestServiceStub extends rpc.RemoteObject implements IIdl
super(des);
}
- async onRemoteRequestEx(code: number, data, reply, option): Promise {
- console.log("onRemoteRequestEx called, code = " + code);
+ async onRemoteMessageRequest(code: number, data, reply, option): Promise {
+ console.log("onRemoteMessageRequest called, code = " + code);
switch(code) {
case IdlTestServiceStub.COMMAND_TEST_INT_TRANSACTION: {
let _data = data.readInt();
@@ -231,6 +239,29 @@ export default class IdlTestServiceStub extends rpc.RemoteObject implements IIdl
});
return true;
}
+ case IdlTestServiceStub.COMMAND_TEST_MAP_TRANSACTION: {
+ let _data = new Map();
+ let _dataSize = data.readInt();
+ for (let i = 0; i < _dataSize; ++i) {
+ let key = data.readInt();
+ let value = data.readInt();
+ _data.set(key, value);
+ }
+ this.testMapTransaction(_data, (errCode) => {
+ reply.writeInt(errCode);
+ });
+ return true;
+ }
+ case IdlTestServiceStub.COMMAND_TEST_ARRAY_TRANSACTION: {
+ let _data = data.readStringArray();
+ this.testArrayTransaction(_data, (errCode, returnValue) => {
+ reply.writeInt(errCode);
+ if (errCode == 0) {
+ reply.writeInt(returnValue);
+ }
+ });
+ return true;
+ }
default: {
console.log("invalid request code" + code);
break;
@@ -241,17 +272,23 @@ export default class IdlTestServiceStub extends rpc.RemoteObject implements IIdl
testIntTransaction(data: number, callback: testIntTransactionCallback): void{}
testStringTransaction(data: string, callback: testStringTransactionCallback): void{}
+ testMapTransaction(data: Map, callback: testMapTransactionCallback): void{}
+ testArrayTransaction(data: string[], callback: testArrayTransactionCallback): void{}
static readonly COMMAND_TEST_INT_TRANSACTION = 1;
static readonly COMMAND_TEST_STRING_TRANSACTION = 2;
+ static readonly COMMAND_TEST_MAP_TRANSACTION = 3;
+ static readonly COMMAND_TEST_ARRAY_TRANSACTION = 4;
}
```
-You need to inherit the interface class defined in the IDL file and implement the methods in the class. The following code snippet shows how to inherit the **IdlTestServiceStub** interface class and implement the **testIntTransaction** and **testStringTransaction** methods.
+You need to inherit the interface class defined in the IDL file and implement the methods in the class. The following code snippet shows how to inherit the **IdlTestServiceStub** interface class and implement the **testIntTransaction**, **testStringTransaction**, **testMapTransaction**, and **testArrayTransaction** methods.
```ts
import {testIntTransactionCallback} from "./i_idl_test_service"
import {testStringTransactionCallback} from "./i_idl_test_service"
+import {testMapTransactionCallback} from "./i_idl_test_service";
+import {testArrayTransactionCallback} from "./i_idl_test_service";
import IdlTestServiceStub from "./idl_test_service_stub"
@@ -265,6 +302,14 @@ class IdlTestImp extends IdlTestServiceStub {
{
callback(0);
}
+ testMapTransaction(data: Map, callback: testMapTransactionCallback): void
+ {
+ callback(0);
+ }
+ testArrayTransaction(data: string[], callback: testArrayTransactionCallback): void
+ {
+ callback(0, 1);
+ }
}
```
@@ -320,11 +365,28 @@ function callbackTestStringTransaction(result: number): void {
}
}
+function callbackTestMapTransaction(result: number): void {
+ if (result == 0) {
+ console.log('case 3 success');
+ }
+}
+
+function callbackTestArrayTransaction(result: number, ret: number): void {
+ if (result == 0 && ret == 124) {
+ console.log('case 4 success');
+ }
+}
+
var onAbilityConnectDone = {
onConnect:function (elementName, proxy) {
let testProxy = new IdlTestServiceProxy(proxy);
+ let testMap = new Map();
+ testMap.set(1, 1);
+ testMap.set(1, 2);
testProxy.testIntTransaction(123, callbackTestIntTransaction);
testProxy.testStringTransaction('hello', callbackTestStringTransaction);
+ testProxy.testMapTransaction(testMap, callbackTestMapTransaction);
+ testProxy.testArrayTransaction(['1','2'], callbackTestMapTransaction);
},
onDisconnect:function (elementName) {
console.log('onDisconnectService onDisconnect');
diff --git a/en/application-dev/Readme-EN.md b/en/application-dev/Readme-EN.md
index a627e1116a792c5d4fc885ae01aa6ccb172b7b1d..73bbd2d608562535e3272c1a659bcebbd39b125a 100644
--- a/en/application-dev/Readme-EN.md
+++ b/en/application-dev/Readme-EN.md
@@ -17,7 +17,6 @@
- Application Package Structure
- [Application Package Structure in Stage Model)](quick-start/application-package-structure-stage.md)
- [Application Package Structure in FA Model](quick-start/application-package-structure-fa.md)
- - [HAR File Structure](quick-start/har-structure.md)
- Multi-HAP Mechanism
- [Multi-HAP Design Objectives](quick-start/multi-hap-objective.md)
- [Multi-HAP Build View](quick-start/multi-hap-build-view.md)
@@ -49,7 +48,7 @@
- Development
- [Application Models](application-models/Readme-EN.md)
- [UI Development](ui/Readme-EN.md)
- - [Common Event and Notification](notification/Readme-EN.md)
+ - [Notification](notification/Readme-EN.md)
- [Window Manager](windowmanager/Readme-EN.md)
- [WebGL](webgl/Readme-EN.md)
- [Media](media/Readme-EN.md)
@@ -57,7 +56,7 @@
- [Connectivity](connectivity/Readme-EN.md)
- [Data Management](database/Readme-EN.md)
- [File Management](file-management/Readme-EN.md)
- - [Telephony](telephony/Readme-EN.md)
+ - [Telephony Service](telephony/Readme-EN.md)
- [Task Management](task-management/Readme-EN.md)
- [Device Management](device/Readme-EN.md)
- [Device Usage Statistics](device-usage-statistics/Readme-EN.md)
diff --git a/en/application-dev/application-dev-guide-for-gitee.md b/en/application-dev/application-dev-guide-for-gitee.md
index 96e956f86e1528c5946c094b204c83e6e7d96222..ca206e65fd11a48631e950f26c1c9b656f298e13 100644
--- a/en/application-dev/application-dev-guide-for-gitee.md
+++ b/en/application-dev/application-dev-guide-for-gitee.md
@@ -24,13 +24,13 @@ First thing first, familiarize yourself with the two cornerstone frameworks in O
All applications should be developed on top of these frameworks.
Then, equip yourself for developing the key features, with the following guidelines:
-- [Common Event and Notification](notification/Readme-EN.md)
+- [Notification](notification/Readme-EN.md)
- [Window Manager](windowmanager/Readme-EN.md)
- [WebGL](webgl/Readme-EN.md)
- [Media](media/Readme-EN.md)
- [Security](security/Readme-EN.md)
- [Connectivity](connectivity/Readme-EN.md)
-- [Telephony](telephony/Readme-EN.md)
+- [Telephony Service](telephony/Readme-EN.md)
- [Data Management](database/Readme-EN.md)
- [Task Management](task-management/Readme-EN.md)
- [Device Management](device/Readme-EN.md)
@@ -40,6 +40,7 @@ Then, equip yourself for developing the key features, with the following guideli
- [Application Test](application-test/Readme-EN.md)
- [IDL Specifications and User Guide](IDL/idl-guidelines.md)
- [Using Native APIs in Application Projects](napi/Readme-EN.md)
+- [File Management](file-management/medialibrary-overview.md)
### Tools
diff --git a/en/application-dev/application-dev-guide.md b/en/application-dev/application-dev-guide.md
index 650eaf0b956e544bd19e8892b0c6946a6839beb5..c7b49ac56b0638e8c4ba9908582683f9c4c46d21 100644
--- a/en/application-dev/application-dev-guide.md
+++ b/en/application-dev/application-dev-guide.md
@@ -24,13 +24,13 @@ First thing first, familiarize yourself with the two cornerstone frameworks in O
All applications should be developed on top of these frameworks.
Then, equip yourself for developing the key features, with the following guidelines:
-- [Common Event and Notification](notification/notification-overview.md)
+- [Notification](notification/notification-overview.md)
- [Window Manager](windowmanager/window-overview.md)
- [WebGL](webgl/webgl-overview.md)
- [Media](media/audio-overview.md)
- [Security](security/userauth-overview.md)
- [Connectivity](connectivity/ipc-rpc-overview.md)
-- [Telephony](telephony/telephony-overview.md)
+- [Telephony Service](telephony/telephony-overview.md)
- [Data Management](database/database-mdds-overview.md)
- [Task Management](task-management/background-task-overview.md)
- [Device](device/usb-overview.md)
@@ -40,6 +40,7 @@ Then, equip yourself for developing the key features, with the following guideli
- [Application Test](application-test/arkxtest-guidelines.md)
- [OpenHarmony IDL Specifications and User Guide](IDL/idl-guidelines.md)
- [Using Native APIs in Application Projects](napi/napi-guidelines.md)
+- [File Management](file-management/medialibrary-overview.md)
### Tools
diff --git a/en/application-dev/application-models/Readme-EN.md b/en/application-dev/application-models/Readme-EN.md
index b7ffad31601a940e3025dc7c01a45bb1a8202d42..b38074f214762a1d42474e7e12005314427d3ee1 100644
--- a/en/application-dev/application-models/Readme-EN.md
+++ b/en/application-dev/application-models/Readme-EN.md
@@ -17,10 +17,10 @@
- ExtensionAbility Component
- [ExtensionAbility Component Overview](extensionability-overview.md)
- [ServiceExtensionAbility](serviceextensionability.md)
- - [DataShareExtensionAbility (System Applications Only)](datashareextensionability.md)
- [FormExtensionAbility (Widget)](widget-development-stage.md)
- - [StaticSubscriberExtensionAbility](static-subscriber-extension-ability.md)
- [AccessibilityExtensionAbility](accessibilityextensionability.md)
+ - [EnterpriseAdminExtensionAbility](enterprise-extensionAbility.md)
+ - [InputMethodExtensionAbility](inputmethodextentionability.md)
- [WindowExtensionAbility](windowextensionability.md)
- [AbilityStage Component Container](abilitystage.md)
- [Context](application-context-stage.md)
@@ -34,15 +34,19 @@
- [Component Startup Rules](component-startup-rules.md)
- Inter-Device Application Component Interaction (Continuation)
- [Continuation Overview](inter-device-interaction-hop-overview.md)
- - [Cross-Device Migration (System Applications Only)](hop-cross-device-migration.md)
- - [Multi-device Collaboration (System Applications Only)](hop-multi-device-collaboration.md)
+ - [Cross-Device Migration (for System Applications Only)](hop-cross-device-migration.md)
+ - [Multi-device Collaboration (for System Applications Only)](hop-multi-device-collaboration.md)
+ - [Subscribing to System Environment Variable Changes](subscribe-system-environment-variable-changes.md)
- IPC
- [Process Model](process-model-stage.md)
- Common Events
- [Introduction to Common Events](common-event-overview.md)
- - [Subscribing to Common Events](common-event-subscription.md)
+ - Common Event Subscription
+ - [Common Event Subscription Overview](common-event-subscription-overview.md)
+ - [Subscribing to Common Events in Dynamic Mode](common-event-subscription.md)
+ - [Subscribing to Common Events in Static Mode (for System Applications Only)](common-event-static-subscription.md)
+ - [Unsubscribing from Common Events](common-event-unsubscription.md)
- [Publishing Common Events](common-event-publish.md)
- - [Unsubscribing from Common Events](common-event-unsubscription.md)
- [Background Services](background-services.md)
- Inter-Thread Communication
- [Thread Model](thread-model-stage.md)
@@ -52,6 +56,7 @@
- [Mission Management Scenarios](mission-management-overview.md)
- [Mission Management and Launch Type](mission-management-launch-type.md)
- [Page Stack and MissionList](page-mission-stack.md)
+ - [Setting the Icon and Name of a Mission Snapshot](mission-set-icon-name-for-task-snapshot.md)
- [Application Configuration File](config-file-stage.md)
- FA Model Development
- [FA Model Development Overview](fa-model-development-overview.md)
@@ -65,7 +70,7 @@
- [Creating a PageAbility](create-pageability.md)
- [Starting a Local PageAbility](start-local-pageability.md)
- [Stopping a PageAbility](stop-pageability.md)
- - [Starting a Remote PageAbility (System Applications Only)](start-remote-pageability.md)
+ - [Starting a Remote PageAbility (for System Applications Only)](start-remote-pageability.md)
- [Starting a Specified Page](start-page.md)
- [Window Properties](window-properties.md)
- [Requesting Permissions](request-permissions.md)
diff --git a/en/application-dev/application-models/ability-startup-with-explicit-want.md b/en/application-dev/application-models/ability-startup-with-explicit-want.md
index 9186379f32299ee7a42b7f82af4fc7f464c160d1..6b61b06311a519e959e87d826e4a27c8b2b3d208 100644
--- a/en/application-dev/application-models/ability-startup-with-explicit-want.md
+++ b/en/application-dev/application-models/ability-startup-with-explicit-want.md
@@ -1,4 +1,7 @@
# Using Explicit Want to Start an Ability
+When a user touches a button in an application, the application often needs to start a UIAbility component to complete a specific task. If the **abilityName** and **bundleName** parameters are specified when starting a UIAbility, then the explicit Want is used.
-When a user touches a button in an application, the application often needs to start a UIAbility component to complete a specific task. If the **abilityName** and **bundleName** parameters are specified when starting a UIAbility, the explicit Want is used. For details about how to use the explicit Want, see [Starting UIAbility in the Same Application](uiability-intra-device-interaction.md#starting-uiability-in-the-same-application).
+## Using Explicit Want
+
+The user touches a button in the application to start the UIAbility component to complete a specific task. To start the UIAbility component in explicit Want mode, the **abilityName** and **bundleName** parameters must be specified. For details, see [Starting UIAbility in the Same Application](uiability-intra-device-interaction.md#starting-uiability-in-the-same-application).
diff --git a/en/application-dev/application-models/ability-startup-with-implicit-want.md b/en/application-dev/application-models/ability-startup-with-implicit-want.md
index 6550e5c628c642cf227cfde5f74eef7b61c8a52b..dbd65bb560d7531bb6e00b21c004815fda1a997c 100644
--- a/en/application-dev/application-models/ability-startup-with-implicit-want.md
+++ b/en/application-dev/application-models/ability-startup-with-implicit-want.md
@@ -1,77 +1,78 @@
# Using Implicit Want to Open a Website
-
-## Prerequisites
-
-One or more browsers are installed on your device.
-
-The **module.json5** of a browser application is as follows:
+This section uses the operation of using a browser to open a website as an example. It is assumed that one or more browser applications are installed on the device. To ensure that the browser application can work properly, configure the [module.json5 file](../quick-start/module-configuration-file.md) as follows:
```json
-"skills": [
- {
- "entities": [
- "entity.system.browsable"
- // ...
- ],
- "actions": [
- "ohos.want.action.viewData"
- // ...
- ],
- "uris": [
- {
- "scheme": "https",
- "host": "www.test.com",
- "port": "8080",
- // Prefix matching is used.
- "pathStartWith": "query",
- "type": "text/*"
- },
+{
+ "module": {
+ // ...
+ "abilities": [
{
- "scheme": "http",
// ...
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home",
+ "entity.system.browsable"
+ // ...
+ ],
+ "actions": [
+ "action.system.home",
+ "ohos.want.action.viewData"
+ // ...
+ ],
+ "uris": [
+ {
+ "scheme": "https",
+ "host": "www.test.com",
+ "port": "8080",
+ // Prefix matching is used.
+ "pathStartWith": "query"
+ },
+ {
+ "scheme": "http",
+ // ...
+ }
+ // ...
+ ]
+ }
+ ]
}
- // ...
]
- },
-]
+ }
+}
```
+In the initiator UIAbility, use implicit Want to start the browser application.
-## How to Develop
+```ts
+import common from '@ohos.app.ability.common';
-1. Use the custom function **implicitStartAbility** to start an ability.
-
- ```ts
- async implicitStartAbility() {
- try {
- let want = {
- // Uncomment the line below if you want to implicitly query data only in the specific bundle.
- // bundleName: "com.example.myapplication",
- "action": "ohos.want.action.viewData",
- // entities can be omitted.
- "entities": [ "entity.system.browsable" ],
- "uri": "https://www.test.com:8080/query/student",
- "type": "text/plain"
- }
- let context = getContext(this) as common.UIAbilityContext;
- await context.startAbility(want)
- console.info(`explicit start ability succeed`)
- } catch (error) {
- console.info(`explicit start ability failed with ${error.code}`)
- }
- }
- ```
-
- The matching process is as follows:
- 1. If **action** in the passed **want** parameter is specified and is included in **actions** under **skills**, the matching is successful.
-
- 2. If **entities** in the passed **want** parameter is specified and is included in **entities** under **skills**, the matching is successful.
+function implicitStartAbility() {
+ let context = getContext(this) as common.UIAbilityContext;
+ let wantInfo = {
+ // Uncomment the line below if you want to implicitly query data only in the specific bundle.
+ // bundleName: 'com.example.myapplication',
+ 'action': 'ohos.want.action.viewData',
+ // entities can be omitted.
+ 'entities': ['entity.system.browsable'],
+ 'uri': 'https://www.test.com:8080/query/student'
+ }
+ context.startAbility(wantInfo).then(() => {
+ // ...
+ }).catch((err) => {
+ // ...
+ })
+}
+```
- 3. If **uri** in the passed **want** parameter is included in **uris** under **skills**, which is concatenated into `https://www.test.com:8080/query*` (where \* is a wildcard), the matching is successful.
+The matching process is as follows:
- 4. If **type** in the passed **want** parameter is specified and is included in **type** under **skills**, the matching is successful.
+1. If **action** in the passed **want** parameter is specified and is included in **actions** under **skills** of the ability to match, the matching is successful.
+2. If **entities** in the passed **want** parameter is specified and is included in **entities** under **skills** of the ability to match, the matching is successful.
+3. If **uri** in the passed **want** parameter is included in **uris** under **skills** of the ability to match, which is concatenated into https://www.test.com:8080/query* (where * is a wildcard), the matching is successful.
+4. If **type** in the passed **want** parameter is specified and is included in **type** under **skills** of the ability to match, the matching is successful.
-2. When there are multiple matching applications, a dialog box is displayed for you to select one of them.
+If there are multiple matching applications, the system displays a dialog box for you to select one of them. The following figure shows an example.
- 
+
\ No newline at end of file
diff --git a/en/application-dev/application-models/abilitystage.md b/en/application-dev/application-models/abilitystage.md
index 4e0a273f850b4919d0964580ebed89c053c273f7..9a4e71d3fa696ee6f2707545b80456df34fe85ac 100644
--- a/en/application-dev/application-models/abilitystage.md
+++ b/en/application-dev/application-models/abilitystage.md
@@ -29,6 +29,18 @@ AbilityStage is not automatically generated in the default project of DevEco Stu
}
}
```
+
+4. Set **srcEntry** in the [module.json5 file](../quick-start/module-configuration-file.md) to the code path of the module.
+ ```json
+ {
+ "module": {
+ "name": "entry",
+ "type": "entry",
+ "srcEntry": "./ets/myabilitystage/MyAbilityStage.ts",
+ // ...
+ }
+ }
+ ```
[AbilityStage](../reference/apis/js-apis-app-ability-abilityStage.md) has the lifecycle callback [onCreate()](../reference/apis/js-apis-app-ability-abilityStage.md#abilitystageoncreate) and the event callbacks [onAcceptWant()](../reference/apis/js-apis-app-ability-abilityStage.md#abilitystageonacceptwant), [onConfigurationUpdated()](../reference/apis/js-apis-app-ability-abilityStage.md#abilitystageonconfigurationupdate), and [onMemoryLevel()](../reference/apis/js-apis-app-ability-abilityStage.md#abilitystageonmemorylevel).
@@ -41,6 +53,7 @@ AbilityStage is not automatically generated in the default project of DevEco Stu
- **onConfigurationUpdated()** event callback: triggered when the global system configuration changes. The global system configuration, such as the system language and theme, are defined in the [Configuration](../reference/apis/js-apis-app-ability-configuration.md) class before project configuration.
- **onMemoryLevel()** event callback: triggered when the system adjusts the memory.
+
When an application is switched to the background, it is cached in the background. This adversely affects the overall system performance. When system resources are insufficient, the system reclaims memory from applications in multiple ways. For example, the system may stop applications to release memory for executing key tasks. To further maintain the balance of the system memory and prevent the system from stopping application processes, you can subscribe to the system memory changes in the **onMemoryLevel()** lifecycle callback of AbilityStage to release unnecessary resources.
@@ -54,4 +67,3 @@ When an application is switched to the background, it is cached in the backgroun
}
}
```
-
diff --git a/en/application-dev/application-models/application-context-stage.md b/en/application-dev/application-models/application-context-stage.md
index de07a3600a27b619f144a4f22223e17616f80805..5308d1899a46ffb9907a18bd74a7920627ac720b 100644
--- a/en/application-dev/application-models/application-context-stage.md
+++ b/en/application-dev/application-models/application-context-stage.md
@@ -19,10 +19,10 @@
```ts
import UIAbility from '@ohos.app.ability.UIAbility';
export default class EntryAbility extends UIAbility {
- onCreate(want, launchParam) {
- let uiAbilityContext = this.context;
- // ...
- }
+ onCreate(want, launchParam) {
+ let uiAbilityContext = this.context;
+ // ...
+ }
}
```
@@ -34,21 +34,21 @@
```ts
import ServiceExtensionAbility from '@ohos.app.ability.ServiceExtensionAbility';
export default class MyService extends ServiceExtensionAbility {
- onCreate(want) {
- let serviceExtensionContext = this.context;
- // ...
- }
+ onCreate(want) {
+ let serviceExtensionContext = this.context;
+ // ...
+ }
}
```
- [AbilityStageContext](../reference/apis/js-apis-inner-application-abilityStageContext.md): module-level context. It provides **HapModuleInfo** and **Configuration** in addition to those provided by the base class **Context**.
```ts
- import AbilityStage from "@ohos.app.ability.AbilityStage";
+ import AbilityStage from '@ohos.app.ability.AbilityStage';
export default class MyAbilityStage extends AbilityStage {
- onCreate() {
- let abilityStageContext = this.context;
- // ...
- }
+ onCreate() {
+ let abilityStageContext = this.context;
+ // ...
+ }
}
```
- [ApplicationContext](../reference/apis/js-apis-inner-application-applicationContext.md): application-level context. It provides APIs for subscribing to application component lifecycle changes, system memory changes, and system environment changes. The application-level context can be obtained from UIAbility, ExtensionAbility, and AbilityStage.
@@ -56,10 +56,10 @@
```ts
import UIAbility from '@ohos.app.ability.UIAbility';
export default class EntryAbility extends UIAbility {
- onCreate(want, launchParam) {
- let applicationContext = this.context.getApplicationContext();
- // ...
- }
+ onCreate(want, launchParam) {
+ let applicationContext = this.context.getApplicationContext();
+ // ...
+ }
}
```
@@ -71,7 +71,7 @@ This topic describes how to use the context in the following scenarios:
- [Obtaining the Application Development Path](#obtaining-the-application-development-path)
-- [Obtaining and Modifying Encrypted Areas](#obtaining-and-modifying-encrypted-areas)
+- [Obtaining and Modifying Encryption Areas](#obtaining-and-modifying-encryption-areas)
- [Creating Context of Another Application or Module](#creating-context-of-another-application-or-module)
- [Subscribing to UIAbility Lifecycle Changes in a Process](#subscribing-to-uiability-lifecycle-changes-in-a-process)
@@ -84,13 +84,13 @@ The following table describes the application development paths obtained from co
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| cacheDir | string | Yes| No| Cache directory of the application on the internal storage.
It is the content of **Storage** of an application under **Settings > Apps & services > Apps**.|
-| tempDir | string | Yes| No| Temporary file directory of the application.
Files in this directory are deleted after the application is uninstalled.|
-| filesDir | string | Yes| No| File directory of the application on the internal storage.
Files in this directory may be synchronized to other directories during application migration or backup.|
-| databaseDir | string | Yes| No| Storage directory of the local database.|
-| bundleCodeDir | string | Yes| No| Installation directory of the application on the internal storage.|
-| distributedFilesDir | string | Yes| No| Storage directory of distributed application data files.|
-| preferencesDir | string | Yes| Yes| Preferences directory of the application.|
+| bundleCodeDir | string | Yes | No | Path for storing the application's installation package, that is, installation directory of the application on the internal storage. |
+| cacheDir | string | Yes| No| Path for storing the application's cache files, that is, cache directory of the application on the internal storage.
It is the content of **Storage** of an application under **Settings > Apps & services > Apps**.|
+| filesDir | string | Yes | No | Path for storing the application's common files, that is, file directory of the application on the internal storage.
Files in this directory may be synchronized to other directories during application migration or backup.|
+| preferencesDir | string | Yes | Yes | Path for storing the application's preference files, that is, preferences directory of the application. |
+| tempDir | string | Yes | No | Path for storing the application's temporary files.
Files in this directory are deleted after the application is uninstalled.|
+| databaseDir | string | Yes | No | Path for storing the application's database, that is, storage directory of the local database. |
+| distributedFilesDir | string | Yes| No| Path for storing the application's distributed files.|
The capability of obtaining the application development path is provided by the base class **Context**. This capability is also provided by **ApplicationContext**, **AbilityStageContext**, **UIAbilityContext**, and **ExtensionContext**. However, the paths obtained from different contexts may differ, as shown below.
@@ -127,16 +127,16 @@ The sample code for obtaining the application development paths is as follows:
import UIAbility from '@ohos.app.ability.UIAbility';
export default class EntryAbility extends UIAbility {
- onCreate(want, launchParam) {
- let cacheDir = this.context.cacheDir;
- let tempDir = this.context.tempDir;
- let filesDir = this.context.filesDir;
- let databaseDir = this.context.databaseDir;
- let bundleCodeDir = this.context.bundleCodeDir;
- let distributedFilesDir = this.context.distributedFilesDir;
- let preferencesDir = this.context.preferencesDir;
- // ...
- }
+ onCreate(want, launchParam) {
+ let cacheDir = this.context.cacheDir;
+ let tempDir = this.context.tempDir;
+ let filesDir = this.context.filesDir;
+ let databaseDir = this.context.databaseDir;
+ let bundleCodeDir = this.context.bundleCodeDir;
+ let distributedFilesDir = this.context.distributedFilesDir;
+ let preferencesDir = this.context.preferencesDir;
+ // ...
+ }
}
```
@@ -144,45 +144,52 @@ export default class EntryAbility extends UIAbility {
>
> The sample code obtains the sandbox path of the application development path. The absolute path can be obtained by running the **find / -name ** command in the hdc shell after file creation or modification.
-### Obtaining and Modifying Encrypted Areas
+### Obtaining and Modifying Encryption Areas
-You can read and write [the area attribute in the context](../reference/apis/js-apis-inner-application-context.md) to obtain and set an encrypted area. Two encryption levels are supported:
+Encrypting application files enhances data security by preventing files from unauthorized access. Different application files require different levels of protection. For private files, such as alarms and wallpapers, the application must place them in the device-level encryption area (EL1) to ensure that they can be accessed before the user enters the password. For sensitive files, such as personal privacy data, the application must place them in the user-level encryption area (EL2).
-- AreaMode.EL1: device-level encryption area, which is accessible after the device is powered on.
+In practice, you need to select a proper encrypted area based on scenario-specific requirements to protect application data security. The proper use of EL1 and the EL2 can efficiently improve the security.
-- AreaMode.EL2: user-level encryption area, which is accessible only after the device is powered on and the password is entered (for the first time).
+> **NOTE**
+>
+> - AreaMode.EL1: device-level encryption area, which is accessible after the device is powered on.
+>
+> - AreaMode.EL2: user-level encryption area, which is accessible only after the device is powered on and the password is entered (for the first time).
+
+You can obtain and set the encryption area by reading and writing the [area attribute in Context](../reference/apis/js-apis-inner-application-context.md).
```ts
import UIAbility from '@ohos.app.ability.UIAbility';
export default class EntryAbility extends UIAbility {
- onCreate(want, launchParam) {
- // Before storing common information, switch the encryption level to EL1.
- if (this.context.area === 1) {// Obtain the area.
- this.context.area = 0; // Modify the area.
- }
- // Store common information.
-
- // Before storing sensitive information, switch the encryption level to EL2.
- if (this.context.area === 0) { // Obtain the area.
- this.context.area = 1; // Modify the area.
- }
- // Store sensitive information.
+ onCreate(want, launchParam) {
+ // Before storing common information, switch the encryption level to EL1.
+ if (this.context.area === 1) {// Obtain the area.
+ this.context.area = 0; // Modify the area.
}
+ // Store common information.
+
+ // Before storing sensitive information, switch the encryption level to EL2.
+ if (this.context.area === 0) { // Obtain the area.
+ this.context.area = 1; // Modify the area.
+ }
+ // Store sensitive information.
+ }
}
```
### Creating Context of Another Application or Module
-The base class **Context** provides the [createBundleContext(bundleName:string)](../reference/apis/js-apis-inner-application-context.md#contextcreatebundlecontext), [createModuleContext(moduleName:string)](../reference/apis/js-apis-inner-application-context.md#contextcreatemodulecontext), and [createModuleContext(bundleName:string, moduleName:string)](../reference/apis/js-apis-inner-application-context.md#contextcreatemodulecontext-1) methods for creating the context of other applications or modules, so as to obtain the resource information, for example, [obtaining the application development paths](#obtaining-the-application-development-path) of other modules.
+The base class **Context** provides [createBundleContext(bundleName:string)](../reference/apis/js-apis-inner-application-context.md#contextcreatebundlecontext), [createModuleContext(moduleName:string)](../reference/apis/js-apis-inner-application-context.md#contextcreatemodulecontext), and [createModuleContext(bundleName:string, moduleName:string)](../reference/apis/js-apis-inner-application-context.md#contextcreatemodulecontext-1) to create the context of other applications or modules, so as to obtain the resource information, for example, [obtaining the application development paths](#obtaining-the-application-development-path) of other modules.
- Call **createBundleContext(bundleName:string)** to create the context of another application.
> **NOTE**
>
> To obtain the context of another application:
>
- > - Request the **ohos.permission.GET_BUNDLE_INFO_PRIVILEGED** permission. For details, see [Permission Application Guide](../security/accesstoken-guidelines.md#declaring-permissions-in-the-configuration-file).
+ > - Request the **ohos.permission.GET_BUNDLE_INFO_PRIVILEGED** permission. For details, see [Declaring Permissions in the Configuration File](../security/accesstoken-guidelines.md#declaring-permissions-in-the-configuration-file).
+ >
> - This is a system API and cannot be called by third-party applications.
For example, application information displayed on the home screen includes the application name and icon. The home screen application calls the foregoing method to obtain the context information, so as to obtain the resource information including the application name and icon.
@@ -191,12 +198,12 @@ The base class **Context** provides the [createBundleContext(bundleName:string)]
import UIAbility from '@ohos.app.ability.UIAbility';
export default class EntryAbility extends UIAbility {
- onCreate(want, launchParam) {
- let bundleName2 = "com.example.application";
- let context2 = this.context.createBundleContext(bundleName2);
- let label2 = context2.applicationInfo.label;
- // ...
- }
+ onCreate(want, launchParam) {
+ let bundleName2 = 'com.example.application';
+ let context2 = this.context.createBundleContext(bundleName2);
+ let label2 = context2.applicationInfo.label;
+ // ...
+ }
}
```
@@ -205,99 +212,113 @@ The base class **Context** provides the [createBundleContext(bundleName:string)]
>
> To obtain the context of a specified module of another application:
>
- > - Request the **ohos.permission.GET_BUNDLE_INFO_PRIVILEGED** permission. For details, see [Permission Application Guide](../security/accesstoken-guidelines.md#declaring-permissions-in-the-configuration-file).
+ > - Request the **ohos.permission.GET_BUNDLE_INFO_PRIVILEGED** permission. For details, see [Declaring Permissions in the Configuration File](../security/accesstoken-guidelines.md#declaring-permissions-in-the-configuration-file).
+ >
> - This is a system API and cannot be called by third-party applications.
-
+
```ts
import UIAbility from '@ohos.app.ability.UIAbility';
export default class EntryAbility extends UIAbility {
- onCreate(want, launchParam) {
- let bundleName2 = "com.example.application";
- let moduleName2 = "module1";
- let context2 = this.context.createModuleContext(bundleName2, moduleName2);
- // ...
- }
+ onCreate(want, launchParam) {
+ let bundleName2 = 'com.example.application';
+ let moduleName2 = 'module1';
+ let context2 = this.context.createModuleContext(bundleName2, moduleName2);
+ // ...
+ }
}
```
-
+
- Call **createModuleContext(moduleName:string)** to obtain the context of another module in the current application. After obtaining the context, you can obtain the resource information of that module.
```ts
import UIAbility from '@ohos.app.ability.UIAbility';
export default class EntryAbility extends UIAbility {
- onCreate(want, launchParam) {
- let moduleName2 = "module1";
- let context2 = this.context.createModuleContext(moduleName2);
- // ...
- }
+ onCreate(want, launchParam) {
+ let moduleName2 = 'module1';
+ let context2 = this.context.createModuleContext(moduleName2);
+ // ...
+ }
}
```
### Subscribing to UIAbility Lifecycle Changes in a Process
-In the DFX statistics scenario of an application, if you need to collect statistics on the stay duration and access frequency of a page, you can subscribe to UIAbility lifecycle changes.
+In the DFX statistics scenario of an application, if you need to collect statistics on the stay duration and access frequency of a page, you can subscribe to UIAbility lifecycle changes in a process.
-[ApplicationContext](../reference/apis/js-apis-inner-application-applicationContext.md) provides APIs for subscribing to UIAbility lifecycle changes in a process. When the UIAbility lifecycle changes in a process, for example, being created or destroyed, becoming visible or invisible, or gaining or losing focus, the corresponding callback is triggered, and a listener ID is returned. The ID is incremented by 1 each time the listener is registered. When the number of listeners exceeds the upper limit (2^63-1), -1 is returned. The following uses [UIAbilityContext](../reference/apis/js-apis-inner-application-uiAbilityContext.md) as an example.
+[ApplicationContext](../reference/apis/js-apis-inner-application-applicationContext) provides APIs for subscribing to UIAbility lifecycle changes in a process. When the UIAbility lifecycle changes in a process, for example, being created or destroyed, becoming visible or invisible, or gaining or losing focus, the corresponding callback is triggered. Each time the callback is registered, a listener lifecycle ID is returned, with the value incremented by 1 each time. When the number of listeners exceeds the upper limit (2^63-1), **-1** is returned. The following uses [UIAbilityContext](../reference/apis/js-apis-inner-application-uiAbilityContext.md) as an example.
```ts
import UIAbility from '@ohos.app.ability.UIAbility';
import window from '@ohos.window';
-const TAG: string = "[Example].[Entry].[EntryAbility]";
+const TAG: string = '[Example].[Entry].[EntryAbility]';
export default class EntryAbility extends UIAbility {
- lifecycleId: number;
-
- onCreate(want, launchParam) {
- let abilityLifecycleCallback = {
- onAbilityCreate(uiability) {
- console.info(TAG, "onAbilityCreate uiability:" + JSON.stringify(uiability));
- },
- onWindowStageCreate(uiability, windowStage) {
- console.info(TAG, "onWindowStageCreate uiability:" + JSON.stringify(uiability));
- console.info(TAG, "onWindowStageCreate windowStage:" + JSON.stringify(windowStage));
- },
- onWindowStageActive(uiability, windowStage) {
- console.info(TAG, "onWindowStageActive uiability:" + JSON.stringify(uiability));
- console.info(TAG, "onWindowStageActive windowStage:" + JSON.stringify(windowStage));
- },
- onWindowStageInactive(uiability, windowStage) {
- console.info(TAG, "onWindowStageInactive uiability:" + JSON.stringify(uiability));
- console.info(TAG, "onWindowStageInactive windowStage:" + JSON.stringify(windowStage));
- },
- onWindowStageDestroy(uiability, windowStage) {
- console.info(TAG, "onWindowStageDestroy uiability:" + JSON.stringify(uiability));
- console.info(TAG, "onWindowStageDestroy windowStage:" + JSON.stringify(windowStage));
- },
- onAbilityDestroy(uiability) {
- console.info(TAG, "onAbilityDestroy uiability:" + JSON.stringify(uiability));
- },
- onAbilityForeground(uiability) {
- console.info(TAG, "onAbilityForeground uiability:" + JSON.stringify(uiability));
- },
- onAbilityBackground(uiability) {
- console.info(TAG, "onAbilityBackground uiability:" + JSON.stringify(uiability));
- },
- onAbilityContinue(uiability) {
- console.info(TAG, "onAbilityContinue uiability:" + JSON.stringify(uiability));
- }
- }
- // 1. Obtain the application context through the context attribute.
- let applicationContext = this.context.getApplicationContext();
- // 2. Register a listener for the lifecycle changes through the application context.
- this.lifecycleId = applicationContext.on("abilityLifecycle", abilityLifecycleCallback);
- console.info(TAG, "register callback number: " + JSON.stringify(this.lifecycleId));
+ // Define a lifecycle ID.
+ lifecycleId: number;
+
+ onCreate(want, launchParam) {
+ // Define a lifecycle callback object.
+ let abilityLifecycleCallback = {
+ // Called when a UIAbility is created.
+ onAbilityCreate(uiAbility) {
+ console.log(TAG, `onAbilityCreate uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`);
+ },
+ // Called when a window is created.
+ onWindowStageCreate(uiAbility, windowStage: window.WindowStage) {
+ console.log(TAG, `onWindowStageCreate uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`);
+ console.log(TAG, `onWindowStageCreate windowStage: ${JSON.stringify(windowStage)}`);
+ },
+ // Called when the window becomes active.
+ onWindowStageActive(uiAbility, windowStage: window.WindowStage) {
+ console.log(TAG, `onWindowStageActive uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`);
+ console.log(TAG, `onWindowStageActive windowStage: ${JSON.stringify(windowStage)}`);
+ },
+ // Called when the window becomes inactive.
+ onWindowStageInactive(uiAbility, windowStage: window.WindowStage) {
+ console.log(TAG, `onWindowStageInactive uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`);
+ console.log(TAG, `onWindowStageInactive windowStage: ${JSON.stringify(windowStage)}`);
+ },
+ // Called when the window is destroyed.
+ onWindowStageDestroy(uiAbility, windowStage: window.WindowStage) {
+ console.log(TAG, `onWindowStageDestroy uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`);
+ console.log(TAG, `onWindowStageDestroy windowStage: ${JSON.stringify(windowStage)}`);
+ },
+ // Called when the UIAbility is destroyed.
+ onAbilityDestroy(uiAbility) {
+ console.log(TAG, `onAbilityDestroy uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`);
+ },
+ // Called when the UIAbility is switched from the background to the foreground.
+ onAbilityForeground(uiAbility) {
+ console.log(TAG, `onAbilityForeground uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`);
+ },
+ // Called when the UIAbility is switched from the foreground to the background.
+ onAbilityBackground(uiAbility) {
+ console.log(TAG, `onAbilityBackground uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`);
+ },
+ // Called when UIAbility is continued on another device.
+ onAbilityContinue(uiAbility) {
+ console.log(TAG, `onAbilityContinue uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`);
+ }
}
+ // Obtain the application context.
+ let applicationContext = this.context.getApplicationContext();
+ // Register the application lifecycle callback.
+ this.lifecycleId = applicationContext.on('abilityLifecycle', abilityLifecycleCallback);
+ console.log(TAG, `register callback number: ${this.lifecycleId}`);
+ }
- onDestroy() {
- let applicationContext = this.context.getApplicationContext();
- applicationContext.off("abilityLifecycle", this.lifecycleId, (error, data) => {
- console.info(TAG, "unregister callback success, err: " + JSON.stringify(error));
- });
- }
+ // ...
+
+ onDestroy() {
+ // Obtain the application context.
+ let applicationContext = this.context.getApplicationContext();
+ // Deregister the application lifecycle callback.
+ applicationContext.off('abilityLifecycle', this.lifecycleId);
+ }
}
```
diff --git a/en/application-dev/application-models/common-event-overview.md b/en/application-dev/application-models/common-event-overview.md
index 0d3788b41b516d0af9619d320ceeefc3f52c74c5..e8be9abaa3015a5512c47af55d2f364be0de79ad 100644
--- a/en/application-dev/application-models/common-event-overview.md
+++ b/en/application-dev/application-models/common-event-overview.md
@@ -15,14 +15,15 @@ Common events are classified into system common events and custom common events.
Common events are also classified into unordered, ordered, and sticky common events.
-- Unordered common events: CES forwards common events based on the subscription sequence, regardless of whether subscribers receive the events.
+- Unordered common events: common events that CES forwards regardless of whether subscribers receive the events and when they subscribe to the events.
-- Ordered common event: CES forwards common events to the next subscriber only after receiving a reply from the previous subscriber.
+- Ordered common events: common events that CES forwards based on the subscriber priority. CES forwards common events to the subscriber with lower priority only after receiving a reply from the previous subscriber with higher priority. Subscribers with the same priority receive common events in a random order.
-- Sticky common event: a public event that can be sent to a subscriber before they initiate a subscription. Only system applications or system services can send sticky common event, and they must request the **ohos.permission.COMMONEVENT_STICKY** permission. For details about the configuration, see [Permission Application Guide](../security/accesstoken-guidelines.md#declaring-permissions-in-the-configuration-file).
+- Sticky common events: common events that can be sent to a subscriber before or after they initiate a subscription. Only system applications and system services can send sticky common events, which remain in the system after being sent. The sends must first request the **ohos.permission.COMMONEVENT_STICKY** permission. For details about the configuration, see [Permission Application Guide](../security/accesstoken-guidelines.md#declaring-permissions-in-the-configuration-file).
Each application can subscribe to common events as required. After your application subscribes to a common event, the system sends it to your application every time the event is published. Such an event may be published by the system, other applications, or your own application.
**Figure 1** Common events
+

\ No newline at end of file
diff --git a/en/application-dev/application-models/common-event-static-subscription.md b/en/application-dev/application-models/common-event-static-subscription.md
new file mode 100644
index 0000000000000000000000000000000000000000..85852f5712df84107c6593160d276ed33557baf9
--- /dev/null
+++ b/en/application-dev/application-models/common-event-static-subscription.md
@@ -0,0 +1,105 @@
+# Subscribing to Common Events in Static Mode (for System Applications Only)
+
+## When to Use
+
+A static subscriber is started once it receives a target event published by the system or application. At the same time, the **onReceiveEvent** callback is triggered, in which you can implement the service logic. For example, if an application needs to execute some initialization tasks during device power-on, the application can subscribe to the power-on event in static mode. After receiving the power-on event, the application is started to execute the initialization tasks. Subscribing to a common event in static mode is achieved by configuring a declaration file and implementing a class that inherits from **StaticSubscriberExtensionAbility**. Note that this subscribing mode has negative impact on system power consumption. Therefore, exercise caution when using this mode.
+
+## How to Develop
+
+1. Declaring a Static Subscriber
+
+ To declare a static subscriber, create an ExtensionAbility, which is derived from the **StaticSubscriberExtensionAbility** class, in the project. The sample code is as follows:
+
+ ```ts
+ import StaticSubscriberExtensionAbility from '@ohos.application.StaticSubscriberExtensionAbility'
+
+ export default class StaticSubscriber extends StaticSubscriberExtensionAbility {
+ onReceiveEvent(event) {
+ console.log('onReceiveEvent, event:' + event.event);
+ }
+ }
+ ```
+
+ You can implement service logic in the **onReceiveEvent** callback.
+
+
+
+2. Project Configuration for a Static Subscriber
+
+ After writing the static subscriber code, configure the subscriber in the **module.json5** file. The configuration format is as follows:
+
+ ```ts
+ {
+ "module": {
+ ......
+ "extensionAbilities": [
+ {
+ "name": "StaticSubscriber",
+ "srcEntrance": "./ets/StaticSubscriber/StaticSubscriber.ts",
+ "description": "$string:StaticSubscriber_desc",
+ "icon": "$media:icon",
+ "label": "$string:StaticSubscriber_label",
+ "type": "staticSubscriber",
+ "visible": true,
+ "metadata": [
+ {
+ "name": "ohos.extension.staticSubscriber",
+ "resource": "$profile:subscribe"
+ }
+ ]
+ }
+ ]
+ ......
+ }
+ }
+ ```
+
+ Pay attention to the following fields in the JSON file:
+
+ - **srcEntrance**: entry file path of the ExtensionAbility, that is, the file path of the static subscriber declared in Step 2.
+
+ - **type**: ExtensionAbility type. For a static subscriber, set this field to **staticSubscriber**.
+
+ - **metadata**: level-2 configuration file information of the ExtensionAbility. The configuration information varies according to the ExtensionAbility type. Therefore, you must use different config files to indicate the specific configuration.
+ - **name**: name of the ExtensionAbility. For a static subscriber, declare the name as **ohos.extension.staticSubscriber** for successful identification.
+ - **resource**: path that stores the ExtensionAbility configuration, which is customizable. In this example, the path is **resources/base/profile/subscribe.json**.
+
+ A level-2 configuration file pointed to by **metadata** must be in the following format:
+
+ ```ts
+ {
+ "commonEvents": [
+ {
+ "name": "xxx",
+ "permission": "xxx",
+ "events":[
+ "xxx"
+ ]
+ }
+ ]
+ }
+ ```
+
+ If the level-2 configuration file is not declared in this format, the file cannot be identified. The fields are described as follows:
+
+ - **name**: name of the ExtensionAbility, which must be the same as the name of **extensionAbility** declared in **module.json5**.
+
+ - **permission**: permission required for the publisher. If a publisher without the required permission attempts to publish an event, the event is regarded as invalid and will not be published.
+
+ - **events**: list of target events to subscribe to.
+
+3. Device System Configuration
+
+ In the device system configuration file **/system/etc/app/install_list_capability.json**, add the bundle name of the static subscriber.
+
+ ```json
+ {
+ "install_list": [
+ {
+ "bundleName": "ohos.extension.staticSubscriber",
+ "allowCommonEvent": ["usual.event.A", "usual.event.B"],
+ }
+ ]
+ }
+ ```
+
diff --git a/en/application-dev/application-models/common-event-subscription-overview.md b/en/application-dev/application-models/common-event-subscription-overview.md
new file mode 100644
index 0000000000000000000000000000000000000000..20064af92d3df2e6f7ab7d62c4f71f911848057a
--- /dev/null
+++ b/en/application-dev/application-models/common-event-subscription-overview.md
@@ -0,0 +1,7 @@
+# Common Event Subscription Overview
+
+The common event service provides two subscription modes: dynamic and static. The biggest difference between these two modes is that dynamic subscription requires the application to be running, while static subscription does not.
+
+- In dynamic subscription mode, a subscriber subscribes to common events by calling an API during the running period. For details, see [Subscribing to Common Events in Dynamic Mode](common-event-subscription.md).
+
+- In static subscription mode, a subscriber subscribes to common events by configuring a declaration file and implementing a class that inherits from StaticSubscriberExtensionAbility. For details, see [Subscribing to Common Events in Static Mode](common-event-static-subscription.md).
diff --git a/en/application-dev/application-models/common-event-subscription.md b/en/application-dev/application-models/common-event-subscription.md
index ce61e40458a7cbd5c9ec226138535da93d3766b1..6cdc52ef9b798e48a911892f965db8fbf2aaa67f 100644
--- a/en/application-dev/application-models/common-event-subscription.md
+++ b/en/application-dev/application-models/common-event-subscription.md
@@ -1,9 +1,9 @@
-# Subscribing to Common Events
+# Subscribing to Common Events in Dynamic Mode
## When to Use
-You can create a subscriber object to subscribe to a common event so as to obtain the parameters passed in the event. Certain system common events [require specific permissions](../security/accesstoken-guidelines.md) to subscribe to. For details, see [Required Permissions](../reference/apis/js-apis-commonEventManager.md#support).
+In dynamic subscription mode, an application subscribes to a common event when it is running. If the subscribed event is published during the running period, the subscriber application will receive the event, together with the parameters passed in the event. For example, if an application expects to be notified of low battery so that it can reduce power consumption accordingly when running, then the application can subscribe to the low-battery event. Upon receiving the event, the application can close some unnecessary tasks to reduce power consumption. Certain system common events [require specific permissions](../security/accesstoken-guidelines.md) to subscribe to. For details, see [Required Permissions](../reference/apis/js-apis-commonEventManager.md#support).
## Available APIs
diff --git a/en/application-dev/application-models/common-event-unsubscription.md b/en/application-dev/application-models/common-event-unsubscription.md
index c87017ef08c05e8a22097c4bd2a05f52fc758134..1a44675d61947325a8c1a8790ff5f53626e43f57 100644
--- a/en/application-dev/application-models/common-event-unsubscription.md
+++ b/en/application-dev/application-models/common-event-unsubscription.md
@@ -1,9 +1,9 @@
-# Unsubscribing from Common Events
+# Unsubscribing from Common Events in Dynamic Mode
## When to Use
-You can call [unsubscribe()](../reference/apis/js-apis-commonEventManager.md#commoneventmanagerunsubscribe) to unsubscribe from a common event that is no longer required.
+You can call [unsubscribe()](../reference/apis/js-apis-commonEventManager.md#commoneventmanagerunsubscribe) to unsubscribe from a common event that is no longer required in dynamic mode.
## Available APIs
@@ -21,12 +21,12 @@ You can call [unsubscribe()](../reference/apis/js-apis-commonEventManager.md#com
import commonEventManager from '@ohos.commonEventManager';
```
-2. Subscribe to an event by following the procedure described in [Subscribing to Common Events](common-event-subscription.md).
+2. Subscribe to an event by following the procedure described in [Subscribing to Common Events in Dynamic Mode](common-event-subscription.md).
3. Call **unsubscribe** in **CommonEvent** to unsubscribe from the common event.
```ts
- // The subscriber object iscreated during event subscription.
+ // The subscriber object is created during event subscription.
if (subscriber !== null) {
commonEventManager.unsubscribe(subscriber, (err) => {
if (err) {
diff --git a/en/application-dev/application-models/component-startup-rules.md b/en/application-dev/application-models/component-startup-rules.md
index 0e6c2ce33c68913221c7b09f02e96327b0ea1c30..26b2446893aea096611f896e878ef15888830afa 100644
--- a/en/application-dev/application-models/component-startup-rules.md
+++ b/en/application-dev/application-models/component-startup-rules.md
@@ -30,7 +30,7 @@ In view of this, OpenHarmony formulates a set of component startup rules, as fol
- An application is considered as a foreground application only when the application process gains focus or its UIAbility component is running in the foreground.
- Verify the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
-- **When the startAbilityByCall() method is used, verify the call permission.** For details, see [Using Ability Call to Implement UIAbility Interaction](uiability-intra-device-interaction.md#using-ability-call-to-implement-uiability-interaction) and [Using Cross-Device Ability Call](hop-multi-device-collaboration.md#using-cross-device-ability-call).
+- **When the startAbilityByCall() method is used, verify the call permission.** For details, see [Using Call to Implement UIAbility Interaction](uiability-intra-device-interaction.md#using-call-to-implement-uiability-interaction) and [Using Cross-Device Call](hop-multi-device-collaboration.md#using-cross-device-call).
- Verify the **ohos.permission.ABILITY_BACKGROUND_COMMUNICATION** permission.
diff --git a/en/application-dev/application-models/create-pageability.md b/en/application-dev/application-models/create-pageability.md
index 783646ff4cfd5fa2ab193005bfa9d182dc75b70c..d0f308ebc08e035d5568ee0e127a9739e400d124 100644
--- a/en/application-dev/application-models/create-pageability.md
+++ b/en/application-dev/application-models/create-pageability.md
@@ -76,22 +76,22 @@ In the FA model, you can call **getContext** of **featureAbility** to obtain the
The following code snippet shows how to use **getContext()** to obtain the application context and distributed directory:
```ts
-import featureAbility from '@ohos.ability.featureAbility'
-import fileIo from '@ohos.fileio'
+import featureAbility from '@ohos.ability.featureAbility';
+import fs from '@ohos.file.fs';
(async () => {
- let dir: string
+ let dir: string;
try {
- console.info('Begin to getOrCreateDistributedDir')
- dir = await featureAbility.getContext().getOrCreateDistributedDir()
+ console.info('Begin to getOrCreateDistributedDir');
+ dir = await featureAbility.getContext().getOrCreateDistributedDir();
console.info('distribute dir is ' + dir)
} catch (error) {
- console.error('getOrCreateDistributedDir failed with ' + error)
+ console.error('getOrCreateDistributedDir failed with ' + error);
}
let fd: number;
let path = dir + "/a.txt";
- fd = fileIo.openSync(path, 0o2 | 0o100, 0o666);
- fileIo.close(fd);
+ fd = fs.openSync(path, fs.OpenMode.READ_WRITE).fd;
+ fs.close(fd);
})()
```
diff --git a/en/application-dev/application-models/data-share-via-want.md b/en/application-dev/application-models/data-share-via-want.md
index c04bea2916647804b51022cee1853f3b5d0a7d90..d5512e0c446b94dcf384504f11ff25d458cfeafc 100644
--- a/en/application-dev/application-models/data-share-via-want.md
+++ b/en/application-dev/application-models/data-share-via-want.md
@@ -1,111 +1,133 @@
# Using Want to Share Data Between Applications
-
Users often need to share data (such as a text or an image) from one application to another. The following uses PDF file sharing as an example to describe how to use Want to share data between applications.
+Data sharing requires two UIAbility components (one for the sharing party and the other for the shared party) and one system component (used as the application sharing box). When the sharing party initiates data sharing by calling **startAbility()**, the system implicitly matches and displays all applications that support the type of data to share. After the user selects an application, the system starts the application to complete data sharing.
-## Prerequisites
-
-1. There are two UIAbility components (one for the sharing party and the other for the shared party) and one system component (used as the application selector). When the sharing party initiates data sharing through **startAbility()**, the application selector is started. The system implicitly matches and displays all applications that support the type of data to share. After the user selects an application, the system starts that application to complete data sharing.
-
-2. In this section, data sharing is triggered by touching a button. You can use other ways to trigger data sharing during application development. This section focuses on the Want configuration used for data sharing.
-
-3. The following actions are involved in this section:
- - **ACTION_SELECT (ohos.want.action.select)**: action of displaying the application selector.
- - **ACTION_SEND_DATA (ohos.want.action.sendData)**: action of launching the UI for sending a single data record. It is used to transfer data to the shared party.
-
-
-## How to Develop
-
-- Sharing party
- 1. In the stage mode, the [File Descriptor (FD)](../reference/apis/js-apis-fileio.md#fileioopensync) is used for file transfer. This example assumes that the path of the file to share is obtained.
-
- ```ts
- import fileIO from '@ohos.fileio';
-
- // let path = ...
- // Open the file whose path is a variable.
- let fileFd = fileIO.openSync(path, 0o102, 0o666);
- ```
-
- 2. As described in the prerequisites, the sharing party starts an application selector and shares the data to the selector, and the selector transfers the data to the shared party. Want of the sharing party must be nested at two layers. At the first layer, implicit Want is used together with the **ohos.want.action.select** action to display the application selector. At the second layer, complete Want is declared in the custom field **parameters** to transfer the data to share.
-
- ```ts
- import wantConstant from '@ohos.app.ability.wantConstant';
-
- // let path = ...
- // let fileFd = ...
- // let fileSize = ...
- let want = {
- / This action is used to implicitly match the application selector.
- action: wantConstant.Action.ACTION_SELECT,
- // This is the custom parameter in the first layer of Want,
- / which is intended to add information to the application selector.
- parameters: {
- // MIME type of PDF.
- "ability.picker.type": "application/pdf",
- "ability.picker.fileNames": [path],
- "ability.picker.fileSizes": [fileSize],
- // This nested Want ,which will be directly sent to the selected application.
- "ability.want.params.INTENT": {
- "action": "ohos.want.action.sendData",
- "type": "application/pdf",
- "parameters": {
- "keyFd": {"type": "FD", "value": fileFd}
- }
- }
- }
+In this section, data sharing is triggered by touching a button. You can use other ways to trigger data sharing during application development. This section focuses on how to configure Want to implement data sharing.
+
+The following actions are involved for data sharing:
+
+- **ohos.want.action.select**: action of starting the application sharing box.
+- **ohos.want.action.sendData**: action of sending a single data record, that is, transferring data to the shared party.
+
+## Sharing Party
+
+The sharing party starts an application sharing box and transfers the data to the shared party. Therefore, Want of the sharing party must be nested at two layers. In the first layer, implicit Want is used together with the **ohos.want.action.select** action to display the application sharing box. In the second layer, the data to share is declared
+
+in the custom field **parameters**, and then the Want that includes the **ohos.want.action.sendData** action and the **parameters** field is transferred to the application sharing box. The shared party obtains the shared data from **parameters**.
+
+```ts
+import common from '@ohos.app.ability.common';
+
+let fileType = 'application/pdf';
+let fileName = 'TestFile.pdf';
+let fileFd = -1; // Obtain the file descriptor (FD) of the file to share.
+let fileSize; // Obtain the size of the file to share.
+
+function implicitStartAbility() {
+ let context = getContext(this) as common.UIAbilityContext;
+ let wantInfo = {
+ / This action is used to implicitly match the application sharing box.
+ action: 'ohos.want.action.select',
+ // This is the custom parameter in the first layer of Want,
+ / which is intended to add information to the application sharing box.
+ parameters: {
+ // MIME type of PDF.
+ 'ability.picker.type': fileType,
+ 'ability.picker.fileNames': [fileName],
+ 'ability.picker.fileSizes': [fileSize],
+ // This is nested Want ,which will be directly sent to the selected application.
+ 'ability.want.params.INTENT': {
+ 'action': 'ohos.want.action.sendData',
+ 'type': 'application/pdf',
+ 'parameters': {
+ 'keyFd': { 'type': 'FD', 'value': fileFd }
+ }
}
- ```
-
- In the preceding code, the custom field **parameters** is used. The **ability.picker.\*** fields in the first-layer **parameters** are used to pass the information to be displayed on the application selector. The following fields are involved:
-
- - **"ability.picker.type"**: The application selector renders the file type icon based on this field.
- - **"ability.picker.fileNames"**: The application selector displays the file name based on this field.
- - **"ability.picker.fileSizes"**: The application selector displays the file size based on this field. The unit is byte.
- - **"ability.picker.fileNames"** and **"ability.picker.fileSizes"** are arrays and have a one-to-one mapping.
-
- For example, when **"ability.picker.type"** is **"application/pdf"**, **"ability.picker.fileNames"** is **"["APIs.pdf"]"**, and **"ability.picker.fileSizes"** is **"[350 \* 1024]"**, the application selector is displayed as follows:
-
- 
-
- In the preceding code, the **ability.want.params.INTENT** field is nested Want. In this field, **action** and **type** are used for implicit matching by the application selector. For details about implicit matching, see [Matching Rules of Implicit Want](explicit-implicit-want-mappings.md#matching-rules-of-implicit-want). After the user selects an application, the nested Want of the **ability.want.params.INTENT** field is passed to that application.
-
-- Shared party
- 1. As mentioned above, the application selector performs implicit matching based on the **ability.want.params.INTENT** field. Therefore, you must set **skills** in the ability configuration file (**module.json5** file in the stage model) of the shared party as follows:
-
- ```ts
- "skills": [
- {
- "entities": [
+ }
+ }
+ context.startAbility(wantInfo).then(() => {
+ // ...
+ }).catch((err) => {
+ // ...
+ })
+}
+```
+
+> **NOTE**
+>
+> Data sharing can be implemented only in FD format. For details about how to obtain the FD and file name, see [File Management](../reference/apis/js-apis-file-fs.md).
+
+In the preceding code, under the custom field **parameters**, the following **ability.picker.*** fields are used to pass the information to be displayed on the application sharing box:
+
+- **ability.picker.type**: file type icon.
+- **ability.picker.fileNames**: file name.
+- **ability.picker.fileSizes**: file size, in bytes.
+- **ability.picker.fileNames** and **ability.picker.fileSizes** are arrays and have a one-to-one mapping.
+
+The following figure shows an example.
+
+
+
+## Shared Party
+
+To enable the shared party to identify the shared content, configure **skills** in the [module.json5 file](../quick-start/module-configuration-file.md) of the UIAbility of the shared party. The **actions** and **type** fields in **uris** match the **action** and **type** fields in **ability.want.params.INTENT** of the sharing party, respectively.
+
+```json
+{
+ "module": {
+ // ...
+ "abilities": [
+ {
+ // ...
+ "skills": [
+ {
// ...
- ],
- "actions": [
+ "actions": [
+ "action.system.home",
"ohos.want.action.sendData"
// ...
- ],
- "uris": [
- {
- "type": "application/pdf"
- },
- // ...
- ]
- },
- ]
- ```
-
- The **actions** and **type** fields in **uris** match the **action** and **type** fields in **ability.want.params.INTENT**, respectively.
-
- Files can be transferred in FD mode, but not URI mode. In implicit matching, the **type** field in Want must match the **type** field in **uris** under **skills** of the shared party. Therefore, specify only the **type** field in **uris**. If **host** and **port** are specified, the matching fails. The application selector initiates implicit matching based on **ability.want.params.INTENT**. Therefore, when the **uri** field added to **ability.want.params.INTENT** matches the **uris** field under **skills**, the matching is successful and additional data can be transferred.
- 2. After the application selector starts the shared party, the system calls **onCreate** and passes **ability.want.params.INTENT** to the **want** parameter.
-
- ```ts
- onCreate(want, launchParam) {
- // When keyFd is undefined, the application crashes.
- if (want["parameters"]["keyFd"] !== undefined) {
- // Receive the file descriptor.
- let fd = want["parameters"]["keyFd"].value;
- // ...
- }
+ ],
+ "uris": [
+ {
+ "type": "application/pdf"
+ },
+ ]
+ }
+ ]
}
- ```
+ ]
+ }
+}
+```
+
+After the user selects an application, the Want nested in the **ability.want.params.INTENT** field is passed to that application. The UIAbility of the shared party, after being started, can call [onCreate()](../reference/apis/js-apis-app-ability-uiAbility.md#uiabilityoncreate) or [onNewWant()](../reference/apis/js-apis-app-ability-uiAbility.md#uiabilityonnewwant) to obtain the passed Want.
+
+The following is an example of the Want obtained. You can use the FD of the shared file to perform required operations.
+
+```json
+{
+ "deviceId": "",
+ "bundleName": "com.example.myapplication",
+ "abilityName": "EntryAbility",
+ "moduleName": "entry",
+ "uri": "",
+ "type": "application/pdf",
+ "flags": 0,
+ "action": "ohos.want.action.sendData",
+ "parameters": {
+ "component.startup.newRules": true,
+ "keyFd": {
+ "type": "FD",
+ "value": 36
+ },
+ "mime-type": "application/pdf",
+ "moduleName": "entry",
+ "ohos.aafwk.param.callerPid": 3488,
+ "ohos.aafwk.param.callerToken": 537379209,
+ "ohos.aafwk.param.callerUid": 20010014
+ },
+ "entities": []
+}
+```
diff --git a/en/application-dev/application-models/datashareextensionability.md b/en/application-dev/application-models/datashareextensionability.md
index 1f968abfa743d7fb917fb7db3e0e41342e41c848..f671848f890277af92fc23869c5db0d57b02a316 100644
--- a/en/application-dev/application-models/datashareextensionability.md
+++ b/en/application-dev/application-models/datashareextensionability.md
@@ -1,4 +1,4 @@
-# DataShareExtensionAbility (System Applications Only)
+# DataShareExtensionAbility (for System Applications Only)
DataShareExtensionAbility provides the data sharing capability. System applications can implement a DataShareExtensionAbility or access an existing DataShareExtensionAbility in the system. Third-party applications can only access an existing DataShareExtensionAbility. For details, see [DataShare Development](../database/database-datashare-guidelines.md).
diff --git a/en/application-dev/application-models/enterprise-extensionAbility.md b/en/application-dev/application-models/enterprise-extensionAbility.md
index 514e254f77981977c7c425a4ea2ddbebbcff9ca8..0038b41e5b4f654d8c7924ec1232bb342dd616cb 100644
--- a/en/application-dev/application-models/enterprise-extensionAbility.md
+++ b/en/application-dev/application-models/enterprise-extensionAbility.md
@@ -1,54 +1,51 @@
# EnterpriseAdminExtensionAbility Development
-## Introduction
+## Introduction to EnterpriseAdminExtensionAbility
-**EnterpriseAdminExtensionAbility** is essential to a mobile device management (MDM) application. When developing an MDM application for an enterprise, you must inherit the **EnterpriseAdminExtensionAbility** class and have the MDM service logic implemented in an **EnterpriseAdminExtensionAbility** instance. The **EnterpriseAdminExtensionAbility** class provides callbacks for the enable, disable, install, and uninstall events of a device administrator application, implementing notification of system administrator status changes.
+EnterpriseAdminExtensionAbility is a mandatory component for Mobile Device Management (MDM) applications. When developing MDM applications for enterprises, you need to inherit EnterpriseAdminExtensionAbility and implement MDM service logic in the EnterpriseAdminExtensionAbility instance. EnterpriseAdminExtensionAbility implements notifications of system management status changes and defines the callbacks for when a device administrator application is enabled or disabled or an application is installed or uninstalled.
## Constraints
-- ***Function constraints***
+EnterpriseAdminExtensionAbility is applicable only to enterprise administrator applications.
- The APIs provided can be used only by device administrator applications.
-
-
-## Scenarios: Listening for the Enable, Disable, Install, and Uninstall Events of a Device Administrator Application
+## Observing Activation/Deactivation of a Device Administrator Application and Installation/Removal of an Application
### Overview
-**onAdminEnabled**: called when the enterprise administrator or employee deploys an MDM application and enables the DeviceAdmin permission for the application. The MDM application can set the initialization policy in the **onAdminEnabled** callback.
+**onAdminEnabled**: When an enterprise administrator or employee deploys an MDM application and activates the device administrator application, this callback is invoked to notify the MDM application that the DeviceAdmin permission is activated. The initialization policy of the MDM application can set in **onAdminEnabled**.
-**onAdminDisabled**: called when the system or employee disables the DeviceAdmin permission to notify the enterprise administrator that the device is no longer managed.
+**onAdminDisabled**: When the device administrator application is deactivated, the callback is invoked to notify the MDM application that the DeviceAdmin permission is deactivated.
-**onBundleAdded**: called to notify the enterprise administrator that the specified MDM application is installed on the device. In enterprise application administration settings, after the enterprise administrator subscribes to application installation and uninstallation events, the MDM application reports the events through the callbacks.
+**onBundleAdded**: The enterprise administrator can subscribe to application installation and uninstallation events. When an application is installed on an enterprise device, the MDM application reports the event in this callback to notify the enterprise administrator.
-**onBundleRemoved**: called to notify the enterprise administrator that the specified MDM application is uninstalled on the device.
+**onBundleRemoved**: When an application is removed from an enterprise device, the MDM application reports the event in this callback to notify the enterprise administrator.
### Available APIs
| Class | API | Description |
-| :------------------------------ | ----------------------------------------- | ---------------------------- |
-| EnterpriseAdminExtensionAbility | onAdminDisabled(): void | Called when the device administrator application is enabled.|
-| EnterpriseAdminExtensionAbility | onBundleAdded(bundleName: string): void | Called when the MDM application is installed. |
-| EnterpriseAdminExtensionAbility | onAdminEnabled(): void | Called when the device administrator application is disabled. |
-| EnterpriseAdminExtensionAbility | onBundleRemoved(bundleName: string): void | Called when the MDM application is uninstalled. |
+| ------------------------------ | ----------------------------------------- | ---------------------------- |
+| EnterpriseAdminExtensionAbility | onAdminEnabled(): void | Called when a device administrator application is activated. |
+| EnterpriseAdminExtensionAbility | onAdminDisabled(): void | Called when a device administrator application is deactivated.|
+| EnterpriseAdminExtensionAbility | onBundleAdded(bundleName: string): void | Called when an application is installed on a device. |
+| EnterpriseAdminExtensionAbility | onBundleRemoved(bundleName: string): void | Called when an application is removed from a device. |
### How to Develop
-To implement **EnterpriseAdminExtensionAbility**, enable the device administrator application and create an **ExtensionAbility** instance from the code directory of the device administrator application. The procedure is as follows:
+To implement EnterpriseAdminExtensionAbility, you need to activate the device administrator application and create **ExtensionAbility** in the code directory of the device administrator application. The procedure is as follows:
1. In the **ets** directory of the target module, right-click and choose **New > Directory** to create a directory named **EnterpriseExtAbility**.
-2. Right-click the **EnterpriseExtAbility** directory and choose **New > TypeScript File** to create a file named **EnterpriseExtAbility.ts**.
-3. Open the **EnterpriseExtAbility.ts** file and import the **EnterpriseAdminExtensionAbility** module. Customize a class that inherits from **EnterpriseAdminExtensionAbility** and add the required callbacks, such as **onAdminEnabled()** and **onAdminDisabled()**, through which the enterprise administrator can receive notification when the device administrator application is enabled or disabled.
+2. Right-click the **EnterpriseExtAbility** directory, and choose **New > TypeScript File** to create a file named **EnterpriseExtAbility.ts**.
+3. Open the **EnterpriseExtAbility.ts** file and import the **EnterpriseAdminExtensionAbility** module. Inherit the **EnterpriseAdminExtensionAbility** module to the custom class and add application notification callbacks, such as **onAdminEnabled()** and **onAdminDisabled()**. When the device administrator application is activated or deactivated, the device administrator can receive notifications.
```ts
import EnterpriseAdminExtensionAbility from '@ohos.enterprise.EnterpriseAdminExtensionAbility';
-
+
export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbility {
-
+
onAdminEnabled() {
console.info("onAdminEnabled");
}
-
+
onAdminDisabled() {
console.info("onAdminDisabled");
}
@@ -56,14 +53,14 @@ To implement **EnterpriseAdminExtensionAbility**, enable the device administrato
onBundleAdded(bundleName: string) {
console.info("EnterpriseAdminAbility onBundleAdded bundleName:" + bundleName)
}
-
+
onBundleRemoved(bundleName: string) {
console.info("EnterpriseAdminAbility onBundleRemoved bundleName" + bundleName)
}
};
```
-4. Register **ServiceExtensionAbility** in the [module.json5](../quick-start/module-configuration-file.md) file of the target module. Among the parameters, set **type** to **enterpriseAdmin** and **srcEntrance** to the code path of the current ExtensionAbility.
+4. Register **ServiceExtensionAbility** in the [**module.json5**](../quick-start/module-configuration-file.md) file corresponding to the project module. Set **type** to **enterpriseAdmin** and **srcEntrance** to the path of the ExtensionAbility code.
```ts
"extensionAbilities": [
@@ -78,10 +75,9 @@ To implement **EnterpriseAdminExtensionAbility**, enable the device administrato
## Example
-Use the **subscribeManagedEvent** and **unsubscribeManagedEvent** APIs in the **@ohos.enterprise.adminManager** module to subscribe to and unsubscribe from the application installation and uninstallation event, respectively. After the subscription is successful, the MDM application notifies the enterprise administrator when it is installed or uninstalled on the device.
+Use **subscribeManagedEvent** in the **@ohos.enterprise.adminManager** module to subscribe to application installation and removal events. When an application is installed or removed, the MDM application is notified of the event. Then, the MDM application reports the event in the callback to notify the enterprise administrator. To unsubscribe from events, use **unsubscribeManagedEvent**.
```ts
- @State managedEvents: Array = [0,1]
@State subscribeManagedEventMsg: string = ""
@State unsubscribeManagedEventMsg: string = ""
@@ -108,4 +104,3 @@ Use the **subscribeManagedEvent** and **unsubscribeManagedEvent** APIs in the **
}
```
-
diff --git a/en/application-dev/application-models/explicit-implicit-want-mappings.md b/en/application-dev/application-models/explicit-implicit-want-mappings.md
index 16854efb9236dc6bdc9fbe990c9cbe3581495633..9e748a31795e3afc713e7091067a8164e8a623cc 100644
--- a/en/application-dev/application-models/explicit-implicit-want-mappings.md
+++ b/en/application-dev/application-models/explicit-implicit-want-mappings.md
@@ -62,7 +62,7 @@ The system matches the **action** attribute in the **want** parameter passed by
**Figure 1** Matching rules of action in the want parameter
- 
+ 
### Matching Rules of entities in the want Parameter
@@ -79,19 +79,15 @@ The system matches the **entities** attribute in the **want** parameter passed b
- If **entities** in the passed **want** parameter is specified, and **entities** under **skills** of an ability is specified but does not contain **entities** in the passed **want** parameter, the matching fails.
- Figure 2 Matching rule of entities in the want parameter
+ **Figure 2** Matching rule of entities in the want parameter
- 
+ 
### Matching Rules of uri and type in the want Parameter
When the **uri** and **type** parameters are specified in the **want** parameter to initiate a component startup request, the system traverses the list of installed components and matches the **uris** array under **skills** of the abilities one by one. If one of the **uris** arrays under **skills** matches the **uri** and **type** in the passed **want**, the matching is successful.
-Figure 3 Matching rules when uri and type are specified in the want parameter
-
-
-
There are four combinations of **uri** and **type** settings. The matching rules are as follows:
- Neither **uri** or **type** is specified in the **want** parameter.
@@ -111,11 +107,17 @@ There are four combinations of **uri** and **type** settings. The matching rules
- If the **uris** array under **skills** of an ability is unspecified, the matching fails.
- If the **uris** array under **skills** of an ability contains an element whose [uri is matched](#matching-rules-of-uri) and [type is matched](#matching-rules-of-type), the matching is successful. Otherwise, the matching fails.
+Leftmost URI matching: When only **scheme**, a combination of **scheme** and **host**, or a combination of **scheme**, **host**, and **port** is configured in the **uris** array under **skills** of the ability,
+the matching is successful only if the leftmost URI in the passed **want** parameter matches **scheme**, the combination of **scheme** and **host**, or the combination of **scheme**, **host**, and **port**.
-To simplify the description, **uri** and **type** passed in the **want** parameter are called **w_uri** and **w_type**, respectively; the **uris** array under **skills** of an ability to match is called **s_uris**; each element in the array is called **s_uri**. Matching is performed from top to bottom.
+**Figure 3** Matching rules when uri and type are specified in the want parameter
+ 
+
+
+To simplify the description, **uri** and **type** passed in the **want** parameter are called **w_uri** and **w_type**, respectively; the **uris** array under **skills** of an ability to match is called **s_uris**; each element in the array is called **s_uri**. Matching is performed from top to bottom.
-Figure 4 Matching rules of uri and type in the want parameter
+**Figure 4** Matching rules of uri and type in the want parameter

@@ -128,7 +130,9 @@ To simplify the description, **uri** in the passed **want** parameter is called
- If **host** of **s_uri** is unspecified and **scheme** of **w_uri** and **scheme** of **s_uri** are the same, the matching is successful. Otherwise, the matching fails.
-- If **path**, **pathStartWith**, and **pathRegex** of **s_uri** are unspecified and **w_uri** and **s_uri** are the same, the matching is successful. Otherwise, the matching fails.
+- If **port** of **s_uri** is unspecified and the combination of **scheme** and **host** of **w_uri** is the same as the combination of **scheme** and **host** of **s_uri**, the matching is successful. Otherwise, the matching fails.
+
+- If **path**, **pathStartWith**, and **pathRegex** of **s_uri** are unspecified and the combination of **scheme**, **host**, and **port** of **w_uri** is the same as the combination of **scheme**, **host**, and **port** of **s_uri**, the matching is successful. Otherwise, the matching fails.
- If **path** of **s_uri** is specified and the **full path expressions** of **w_uri** and **s_uri** are the same, the matching is successful. Otherwise, the matching of **pathStartWith** continues.
@@ -139,12 +143,17 @@ To simplify the description, **uri** in the passed **want** parameter is called
> **NOTE**
>
> The **scheme**, **host**, **port**, **path**, **pathStartWith**, and **pathRegex** attributes of **uris** under **skills** of an ability are concatenated. If **path**, **pathStartWith**, and **pathRegex** are declared in sequence, **uris** can be concatenated into the following expressions:
->
+>
> - **Full path expression**: `scheme://host:port/path`
->
+>
> - **Prefix expression**: `scheme://host:port/pathStartWith`
->
+>
> - **Regular expression**: `scheme://host:port/pathRegex`
+>
+> - **Prefix URI expression**: When only **scheme**, a combination of **scheme** and **host**, or a combination of **scheme**, **host**, and **port** is configured in the configuration file, the matching is successful if a URI prefixed with the configuration file is passed in.
+> * `scheme://`
+> * `scheme://host`
+> * `scheme://host:port`
### Matching Rules of type
diff --git a/en/application-dev/application-models/extensionability-overview.md b/en/application-dev/application-models/extensionability-overview.md
index 809e4e8f70ed31ad361e18dd8cb7e079ddf93086..a287fe9ac7a590bb8675a0ae0f459463ade4ff1b 100644
--- a/en/application-dev/application-models/extensionability-overview.md
+++ b/en/application-dev/application-models/extensionability-overview.md
@@ -25,6 +25,12 @@ An [ExtensionAbilityType](../reference/apis/js-apis-bundleManager.md#extensionab
- [EnterpriseAdminExtensionAbility](../reference/apis/js-apis-EnterpriseAdminExtensionAbility.md): ExtensionAbility component of the enterprise_admin type, which provides APIs for processing enterprise management events, such as application installation events on devices and events indicating too many incorrect screen-lock password attempts.
+> **NOTE**
+> 1. Third-party applications cannot implement ServiceExtensionAbility, DataShareExtensionAbility, StaticSubscriberExtensionAbility, or WindowExtensionAbility.
+>
+> 2. To implement transaction processing in the background for a third-party application, use background tasks rather than ServiceExtensionAbility. For details, see [Background Task](../task-management/background-task-overview.md).
+>
+> 3. Third-party applications can use other types of ExtensionAbility components that have been defined.
## Using ExtensionAbility of the Specified Type
diff --git a/en/application-dev/application-models/figures/ability-startup-with-implicit-want1.png b/en/application-dev/application-models/figures/ability-startup-with-implicit-want1.png
new file mode 100644
index 0000000000000000000000000000000000000000..3f871f4816dfcf60a5c30e39b6d0ead2f8eb711e
Binary files /dev/null and b/en/application-dev/application-models/figures/ability-startup-with-implicit-want1.png differ
diff --git a/en/application-dev/application-models/figures/ability-startup-with-implicit-want2.png b/en/application-dev/application-models/figures/ability-startup-with-implicit-want2.png
new file mode 100644
index 0000000000000000000000000000000000000000..4f1656a3c20e472e260e8e125c42b47c11a35abb
Binary files /dev/null and b/en/application-dev/application-models/figures/ability-startup-with-implicit-want2.png differ
diff --git a/en/application-dev/application-models/figures/common-event.png b/en/application-dev/application-models/figures/common-event.png
index 24b51ff8718ae504ba69c1e12656d4daad797a62..fe2591d12d5f2c570d7be942d33ec330a6eb6c98 100644
Binary files a/en/application-dev/application-models/figures/common-event.png and b/en/application-dev/application-models/figures/common-event.png differ
diff --git a/en/application-dev/application-models/figures/mission-list-recent.png b/en/application-dev/application-models/figures/mission-list-recent.png
new file mode 100644
index 0000000000000000000000000000000000000000..bfc35532ad4907fd3a1bfcb61110ed393ea19d1c
Binary files /dev/null and b/en/application-dev/application-models/figures/mission-list-recent.png differ
diff --git a/en/application-dev/application-models/figures/mission-set-task-snapshot-icon.png b/en/application-dev/application-models/figures/mission-set-task-snapshot-icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..9d1ba2503f4e1a5d3b2aafdd93923c3f6c411998
Binary files /dev/null and b/en/application-dev/application-models/figures/mission-set-task-snapshot-icon.png differ
diff --git a/en/application-dev/application-models/figures/mission-set-task-snapshot-label.png b/en/application-dev/application-models/figures/mission-set-task-snapshot-label.png
new file mode 100644
index 0000000000000000000000000000000000000000..c8348685cc0fd521186aa10e8d04495422fc0206
Binary files /dev/null and b/en/application-dev/application-models/figures/mission-set-task-snapshot-label.png differ
diff --git a/en/application-dev/application-models/figures/stage-want1.png b/en/application-dev/application-models/figures/stage-want1.png
deleted file mode 100644
index 558f0a8588d7785eaad1402e68d6ba60c3118f27..0000000000000000000000000000000000000000
Binary files a/en/application-dev/application-models/figures/stage-want1.png and /dev/null differ
diff --git a/en/application-dev/application-models/figures/stage-want2.png b/en/application-dev/application-models/figures/stage-want2.png
deleted file mode 100644
index 72829adade52ee11419d726f19e218ec4de15220..0000000000000000000000000000000000000000
Binary files a/en/application-dev/application-models/figures/stage-want2.png and /dev/null differ
diff --git a/en/application-dev/application-models/figures/start-uiability-floating-window.png b/en/application-dev/application-models/figures/start-uiability-floating-window.png
new file mode 100644
index 0000000000000000000000000000000000000000..8626c3704f3e60c8efb3d6b6ea0468a7c2958a4f
Binary files /dev/null and b/en/application-dev/application-models/figures/start-uiability-floating-window.png differ
diff --git a/en/application-dev/application-models/figures/uiability-intra-device-interaction.png b/en/application-dev/application-models/figures/uiability-intra-device-interaction.png
index 92292f2c6ef4c9cbd06da2a523f27b571a957e2b..344cf05e96c539ca73fdb9282625a1d1cb8584e7 100644
Binary files a/en/application-dev/application-models/figures/uiability-intra-device-interaction.png and b/en/application-dev/application-models/figures/uiability-intra-device-interaction.png differ
diff --git a/en/application-dev/application-models/figures/want-uri-type1.png b/en/application-dev/application-models/figures/want-uri-type1.png
index e0fe40d1a3cd40b72379bd947aaf2e3977021b32..ed53694a9608e8529c5e4633fca42b041bc7ab76 100644
Binary files a/en/application-dev/application-models/figures/want-uri-type1.png and b/en/application-dev/application-models/figures/want-uri-type1.png differ
diff --git a/en/application-dev/application-models/hop-cross-device-migration.md b/en/application-dev/application-models/hop-cross-device-migration.md
index a482ae26ced4987d0b0c02382ac132c42ea932c0..c51e82e15f4e14f4b42b25e656543a01d84406fb 100644
--- a/en/application-dev/application-models/hop-cross-device-migration.md
+++ b/en/application-dev/application-models/hop-cross-device-migration.md
@@ -1,4 +1,4 @@
-# Cross-Device Migration (System Applications Only)]
+# Cross-Device Migration (for System Applications Only)
## When to Use
@@ -47,25 +47,16 @@ The table below describes the main APIs used for cross-device migration. For det
## How to Develop
-1. Configure the data synchronization permission in the **module.json5** file. The sample code is as follows:
-
- ```json
- {
- "module": {
- "requestPermissions":[
- {
- "name" : "ohos.permission.DISTRIBUTED_DATASYNC",
- }
- ]
- }
- }
- ```
+1. Request the **ohos.permission.DISTRIBUTED_DATASYNC** permission. For details, see [Declaring Permissions in the Configuration File](../security/accesstoken-guidelines.md#declaring-permissions-in-the-configuration-file).
-2. Configure the fields related to cross-device migration in the configuration file.
- - Configure the application to support migration.
-
+2. Display a dialog box to ask authorization from the user when the application is started for the first time. For details, see [Requesting User Authorization](../security/accesstoken-guidelines.md#requesting-user-authorization).
- Set the **continuable** field in the **module.json5** file to **true**. The default value is **false**. If this parameter is set to **false**, the application cannot be continued on the target device.
+3. Configure the fields related to cross-device migration in the configuration file.
+
+ Configure the application to support migration.
+ Set the **continuable** field in the **module.json5** file to **true**. The default value is **false**. If this parameter is set to **false**, the application cannot be continued on the target device.
+
+
```json
{
"module": {
@@ -80,47 +71,31 @@ The table below describes the main APIs used for cross-device migration. For det
}
```
- - Configure the application launch type. For details, see [UIAbility Component Launch Type](uiability-launch-type.md).
-
-3. Request the data synchronization permission. The sample code for displaying a dialog box to request the permission is as follows:
-
- ```ts
- requestPermission() {
- let context = this.context
- let permissions: Array = ['ohos.permission.DISTRIBUTED_DATASYNC']
- context.requestPermissionsFromUser(permissions).then((data) => {
- console.info("Succeed to request permission from user with data: "+ JSON.stringify(data))
- }).catch((error) => {
- console.info("Failed to request permission from user with error: "+ JSON.stringify(error))
- })
- }
- ```
+ Configure the application launch type. For details, see [UIAbility Component Launch Type](uiability-launch-type.md).
4. Implement [onContinue()](../reference/apis/js-apis-app-ability-uiAbility.md#abilityoncontinue) in the UIAbility of the initiator.
-
[onContinue()](../reference/apis/js-apis-app-ability-uiAbility.md#abilityoncontinue) is called on the initiator. You can save the data in this method to implement application compatibility check and migration decision.
-
- Saving migrated data: You can save the data to be migrated in key-value pairs in **wantParam**.
- Checking application compatibility: You can obtain the version number of the target application from **wantParam** and check the compatibility between the target application and the current application.
- Making a migration decision: You can determine whether to support the migration based on the return value of **onContinue()**. For details about the return value, see [Available APIs](#available-apis).
- The sample code is as follows:
-
- ```ts
- import UIAbility from '@ohos.app.ability.UIAbility';
- import AbilityConstant from '@ohos.app.ability.AbilityConstant';
-
- onContinue(wantParam : {[key: string]: any}) {
- console.info(`onContinue version = ${wantParam.version}, targetDevice: ${wantParam.targetDevice}`)
- let workInput = AppStorage.Get('ContinueWork');
- // Set the user input data into wantParam.
- wantParam["work"] = workInput // set user input data into want params
- console.info(`onContinue input = ${wantParam["input"]}`);
- return AbilityConstant.OnContinueResult.AGREE
- }
- ```
+ The sample code is as follows:
+
+ ```ts
+ import UIAbility from '@ohos.app.ability.UIAbility';
+ import AbilityConstant from '@ohos.app.ability.AbilityConstant';
+
+ onContinue(wantParam : {[key: string]: any}) {
+ console.info(`onContinue version = ${wantParam.version}, targetDevice: ${wantParam.targetDevice}`)
+ let workInput = AppStorage.Get('ContinueWork');
+ // Set the user input data into wantParam.
+ wantParam["work"] = workInput // set user input data into want params
+ console.info(`onContinue input = ${wantParam["input"]}`);
+ return AbilityConstant.OnContinueResult.AGREE
+ }
+ ```
5. Implement **onCreate()** and **onNewWant()** in the UIAbility of the target application to implement data restoration.
- Implementation example of **onCreate** in the multi-instance scenario
diff --git a/en/application-dev/application-models/hop-multi-device-collaboration.md b/en/application-dev/application-models/hop-multi-device-collaboration.md
index 49ef26a7a11ca28273a92786eac230f5801d05cd..adbaef7a927f61bc04b7b9066264f8367ef90d76 100644
--- a/en/application-dev/application-models/hop-multi-device-collaboration.md
+++ b/en/application-dev/application-models/hop-multi-device-collaboration.md
@@ -1,4 +1,4 @@
-# Multi-device Collaboration (System Applications Only)
+# Multi-device Collaboration (for System Applications Only)
## When to Use
@@ -11,7 +11,7 @@ Multi-device coordination involves the following scenarios:
- [Connecting to ServiceExtensionAbility Across Devices](#connecting-to-serviceextensionability-across-devices)
-- [Using Cross-Device Ability Call](#using-cross-device-ability-call)
+- [Using Cross-Device Call](#using-cross-device-call)
## Multi-Device Collaboration Process
@@ -47,24 +47,12 @@ On device A, touch the **Start** button provided by the initiator application to
### How to Develop
-1. Request the **ohos.permission.DISTRIBUTED_DATASYNC** permission. For details, see [Permission Application Guide](../security/accesstoken-guidelines.md#declaring-permissions-in-the-configuration-file).
+1. Request the **ohos.permission.DISTRIBUTED_DATASYNC** permission. For details, see [Declaring Permissions in the Configuration File](../security/accesstoken-guidelines.md#declaring-permissions-in-the-configuration-file).
-2. Request the data synchronization permission. The sample code for displaying a dialog box to request the permission is as follows:
-
- ```ts
- requestPermission() {
- let context = this.context;
- let permissions: Array = ['ohos.permission.DISTRIBUTED_DATASYNC'];
- context.requestPermissionsFromUser(permissions).then((data) => {
- console.info("Succeed to request permission from user with data: "+ JSON.stringify(data));
- }).catch((error) => {
- console.info("Failed to request permission from user with error: "+ JSON.stringify(error));
- })
- }
- ```
+2. Display a dialog box to ask authorization from the user when the application is started for the first time. For details, see [Requesting User Authorization](../security/accesstoken-guidelines.md#requesting-user-authorization).
3. Obtain the device ID of the target device.
-
+
```ts
import deviceManager from '@ohos.distributedHardware.deviceManager';
@@ -94,7 +82,7 @@ On device A, touch the **Start** button provided by the initiator application to
```
4. Set the target component parameters, and call [startAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability) to start UIAbility or ServiceExtensionAbility.
-
+
```ts
let want = {
deviceId: getRemoteDeviceId(),
@@ -102,7 +90,7 @@ On device A, touch the **Start** button provided by the initiator application to
abilityName: 'FuncAbility',
moduleName: 'module1', // moduleName is optional.
}
- // context is the ability-level context of the initiator UIAbility.
+ // context is the AbilityContext of the initiator UIAbility.
this.context.startAbility(want).then(() => {
// ...
}).catch((err) => {
@@ -118,35 +106,23 @@ On device A, touch the **Start** button provided by the initiator application to
### Available APIs
-**Table 2** APIs for starting an ability across devices and returning the result data
+**Table 2** APIs for starting a UIAbility across devices and returning the result data
| API| Description|
| -------- | -------- |
| startAbilityForResult(want: Want, callback: AsyncCallback<AbilityResult>): void; | Starts a UIAbility. This API uses an asynchronous callback to return the result when the UIAbility is terminated.|
-| terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback<void>): void;| Terminates this UIAbility. This API uses an asynchronous callback to return the ability result information. It is used together with **startAbilityForResult**.|
-| terminateSelfWithResult(parameter: AbilityResult): Promise<void>; | Terminates this UIAbility. This API uses a promise to return the ability result information. It is used together with **startAbilityForResult**.|
+| terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback<void>): void;| Terminates this UIAbility. This API uses an asynchronous callback to return the result information. It is used together with **startAbilityForResult**.|
+| terminateSelfWithResult(parameter: AbilityResult): Promise<void>; | Terminates this UIAbility. This API uses a promise to return the result information. It is used together with **startAbilityForResult**.|
### How to Develop
-1. Request the **ohos.permission.DISTRIBUTED_DATASYNC** permission. For details, see [Permission Application Guide](../security/accesstoken-guidelines.md#declaring-permissions-in-the-configuration-file).
+1. Request the **ohos.permission.DISTRIBUTED_DATASYNC** permission. For details, see [Declaring Permissions in the Configuration File](../security/accesstoken-guidelines.md#declaring-permissions-in-the-configuration-file).
-2. Request the data synchronization permission. The sample code for displaying a dialog box to request the permission is as follows:
-
- ```ts
- requestPermission() {
- let context = this.context;
- let permissions: Array = ['ohos.permission.DISTRIBUTED_DATASYNC'];
- context.requestPermissionsFromUser(permissions).then((data) => {
- console.info("Succeed to request permission from user with data: "+ JSON.stringify(data));
- }).catch((error) => {
- console.info("Failed to request permission from user with error: "+ JSON.stringify(error));
- })
- }
- ```
+2. Display a dialog box to ask authorization from the user when the application is started for the first time. For details, see [Requesting User Authorization](../security/accesstoken-guidelines.md#requesting-user-authorization).
3. Set the target component parameters on the initiator, and call **startAbilityForResult()** to start the target UIAbility. **data** in the asynchronous callback is used to receive the information returned by the target UIAbility to the initiator UIAbility after the target UIAbility terminates itself. For details about how to implement **getRemoteDeviceId()**, see [Starting UIAbility and ServiceExtensionAbility Across Devices (No Data Returned)](#starting-uiability-and-serviceextensionability-across-devices-no-data-returned).
-
+
```ts
let want = {
deviceId: getRemoteDeviceId(),
@@ -154,7 +130,7 @@ On device A, touch the **Start** button provided by the initiator application to
abilityName: 'FuncAbility',
moduleName: 'module1', // moduleName is optional.
}
- // context is the ability-level context of the initiator UIAbility.
+ // context is the AbilityContext of the initiator UIAbility.
this.context.startAbilityForResult(want).then((data) => {
// ...
}).catch((err) => {
@@ -163,7 +139,7 @@ On device A, touch the **Start** button provided by the initiator application to
```
4. After the UIAbility task at the target device is complete, call **terminateSelfWithResult()** to return the data to the initiator UIAbility.
-
+
```ts
const RESULT_CODE: number = 1001;
let abilityResult = {
@@ -174,20 +150,20 @@ On device A, touch the **Start** button provided by the initiator application to
moduleName: 'module1',
},
}
- // context is the ability-level context of the target UIAbility.
+ // context is the AbilityContext of the target UIAbility.
this.context.terminateSelfWithResult(abilityResult, (err) => {
// ...
});
```
5. The initiator UIAbility receives the information returned by the target UIAbility and processes the information.
-
+
```ts
const RESULT_CODE: number = 1001;
// ...
- // context is the ability-level context of the initiator UIAbility.
+ // context is the UIAbilityContext of the initiator UIAbility.
this.context.startAbilityForResult(want).then((data) => {
if (data?.resultCode === RESULT_CODE) {
// Parse the information returned by the target UIAbility.
@@ -218,21 +194,9 @@ A system application can connect to a service on another device by calling [conn
### How to Develop
-1. Request the **ohos.permission.DISTRIBUTED_DATASYNC** permission. For details, see [Permission Application Guide](../security/accesstoken-guidelines.md#declaring-permissions-in-the-configuration-file).
-
-2. Request the data synchronization permission. The sample code for displaying a dialog box to request the permission is as follows:
-
- ```ts
- requestPermission() {
- let context = this.context;
- let permissions: Array = ['ohos.permission.DISTRIBUTED_DATASYNC'];
- context.requestPermissionsFromUser(permissions).then((data) => {
- console.info("Succeed to request permission from user with data: "+ JSON.stringify(data));
- }).catch((error) => {
- console.info("Failed to request permission from user with error: "+ JSON.stringify(error));
- })
- }
- ```
+1. Request the **ohos.permission.DISTRIBUTED_DATASYNC** permission. For details, see [Declaring Permissions in the Configuration File](../security/accesstoken-guidelines.md#declaring-permissions-in-the-configuration-file).
+
+2. Display a dialog box to ask authorization from the user when the application is started for the first time. For details, see [Requesting User Authorization](../security/accesstoken-guidelines.md#requesting-user-authorization).
3. (Optional) [Implement a background service](serviceextensionability.md#implementing-a-background-service). Perform this operation only if no background service is available.
@@ -292,7 +256,7 @@ A system application can connect to a service on another device by calling [conn
For details about how to implement **getRemoteDeviceId()**, see [Starting UIAbility and ServiceExtensionAbility Across Devices (No Data Returned)](#starting-uiability-and-serviceextensionability-across-devices-no-data-returned).
5. Disconnect the connection. Use **disconnectServiceExtensionAbility()** to disconnect from the background service.
-
+
```ts
let connectionId = 1 // ID returned when the service is connected through connectServiceExtensionAbility.
this.context.disconnectServiceExtensionAbility(connectionId).then((data) => {
@@ -303,111 +267,97 @@ A system application can connect to a service on another device by calling [conn
```
-## Using Cross-Device Ability Call
+## Using Cross-Device Call
-The basic principle of cross-device ability call is the same as that of intra-device ability call. For details, see [Using Ability Call to Implement UIAbility Interaction (System Applications Only)](uiability-intra-device-interaction.md#using-ability-call-to-implement-uiability-interaction-system-applications-only).
+The basic principle of cross-device call is the same as that of intra-device call. For details, see [Using Call to Implement UIAbility Interaction (for System Applications Only)](uiability-intra-device-interaction.md#using-call-to-implement-uiability-interaction-for-system-applications-only).
-The following describes how to implement multi-device collaboration through cross-device ability call.
+The following describes how to implement multi-device collaboration through cross-device call.
### Available APIs
-**Table 4** Ability call APIs
+**Table 4** Call APIs
| API| Description|
| -------- | -------- |
| startAbilityByCall(want: Want): Promise<Caller>; | Starts a UIAbility in the foreground or background and obtains the caller object for communicating with the UIAbility.|
-| 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<void> | Sends agreed sequenceable data to the callee ability.|
-| callWithResult(method: string, data: rpc.Sequenceable): Promise<rpc.MessageParcel> | Sends agreed sequenceable data to the callee ability and obtains the agreed sequenceable data returned by the callee ability.|
+| on(method: string, callback: CalleeCallBack): void | Callback invoked when the CalleeAbility registers a method.|
+| off(method: string): void | Callback invoked when the CalleeAbility deregisters a method.|
+| call(method: string, data: rpc.Parcelable): Promise<void> | Sends agreed parcelable data to the CalleeAbility.|
+| callWithResult(method: string, data: rpc.Parcelable): Promise<rpc.MessageSequence>| Sends agreed parcelable data to the CalleeAbility and obtains the agreed parcelable data returned by the CalleeAbility.|
| release(): void | Releases the caller object.|
-| on(type: "release", callback: OnReleaseCallback): void | Callback invoked when the caller object is released.|
+| on(type: "release", callback: OnReleaseCallback): void | Callback invoked when the caller object is released.|
### How to Develop
-1. Request the **ohos.permission.DISTRIBUTED_DATASYNC** permission. For details, see [Permission Application Guide](../security/accesstoken-guidelines.md#declaring-permissions-in-the-configuration-file).
-
-2. Request the data synchronization permission. The sample code for displaying a dialog box to request the permission is as follows:
-
- ```ts
- requestPermission() {
- let context = this.context;
- let permissions: Array = ['ohos.permission.DISTRIBUTED_DATASYNC'];
- context.requestPermissionsFromUser(permissions).then((data) => {
- console.info("Succeed to request permission from user with data: "+ JSON.stringify(data));
- }).catch((error) => {
- console.info("Failed to request permission from user with error: "+ JSON.stringify(error));
- })
- }
- ```
+1. Request the **ohos.permission.DISTRIBUTED_DATASYNC** permission. For details, see [Declaring Permissions in the Configuration File](../security/accesstoken-guidelines.md#declaring-permissions-in-the-configuration-file).
-3. Create the callee ability.
+2. Display a dialog box to ask authorization from the user when the application is started for the first time. For details, see [Requesting User Authorization](../security/accesstoken-guidelines.md#requesting-user-authorization).
+
+3. Create the CalleeAbility.
- 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.
+ For the CalleeAbility, 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 launch type of the UIAbility.
+ 1. Configure the launch type of the UIAbility.
- Set **launchType** of the callee ability to **singleton** in the **module.json5** file.
+ Set **launchType** of the CalleeAbility to **singleton** in the **module.json5** file.
- | JSON Field| Description|
- | -------- | -------- |
- | "launchType"| Ability launch type. Set this parameter to **singleton**.|
+ | JSON Field| Description|
+ | -------- | -------- |
+ | "launchType"| UIAbility launch type. Set this parameter to **singleton**.|
- An example of the UIAbility configuration is as follows:
+ An example of the UIAbility configuration is as follows:
-
- ```json
- "abilities":[{
- "name": ".CalleeAbility",
- "srcEntrance": "./ets/CalleeAbility/CalleeAbility.ts",
- "launchType": "singleton",
- "description": "$string:CalleeAbility_desc",
- "icon": "$media:icon",
- "label": "$string:CalleeAbility_label",
- "visible": true
- }]
- ```
+
+ ```json
+ "abilities":[{
+ "name": ".CalleeAbility",
+ "srcEntrance": "./ets/CalleeAbility/CalleeAbility.ts",
+ "launchType": "singleton",
+ "description": "$string:CalleeAbility_desc",
+ "icon": "$media:icon",
+ "label": "$string:CalleeAbility_label",
+ "visible": true
+ }]
+ ```
+ 2. Import the **UIAbility** module.
+
+ ```ts
+ import Ability from '@ohos.app.ability.UIAbility';
+ ```
+ 3. Define the agreed parcelable data.
- 2. Import the **UIAbility** module.
-
- ```ts
- import Ability from '@ohos.app.ability.UIAbility';
- ```
-
- 3. Define the agreed sequenceable data.
-
- 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.
-
- ```ts
- export default class MySequenceable {
- num: number = 0;
- str: string = "";
-
- constructor(num, string) {
- this.num = num;
- this.str = string;
- }
-
- marshalling(messageParcel) {
- messageParcel.writeInt(this.num);
- messageParcel.writeString(this.str);
- return true;
- }
-
- unmarshalling(messageParcel) {
- this.num = messageParcel.readInt();
- this.str = messageParcel.readString();
- return true;
- }
- }
- ```
+ The data formats sent and received by the CallerAbility and CalleeAbility must be consistent. In the following example, the data formats are number and string.
- 4. Implement **Callee.on** and **Callee.off**.
-
- 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.
-
+
+ ```ts
+ export default class MyParcelable {
+ num: number = 0;
+ str: string = "";
+
+ constructor(num, string) {
+ this.num = num;
+ this.str = string;
+ }
+
+ marshalling(messageSequence) {
+ messageSequence.writeInt(this.num);
+ messageSequence.writeString(this.str);
+ return true;
+ }
+
+ unmarshalling(messageSequence) {
+ this.num = messageSequence.readInt();
+ this.str = messageSequence.readString();
+ return true;
+ }
+ }
+ ```
+ 4. Implement **Callee.on** and **Callee.off**.
+
+ In the following example, the **MSG_SEND_METHOD** listener is registered in **onCreate()** of the UIAbility and deregistered in **onDestroy()**. After receiving parcelable data, the application processes the data and returns the data result. You need to implement processing based on service requirements.
+
```ts
const TAG: string = '[CalleeAbility]';
const MSG_SEND_METHOD: string = 'CallSendMsg';
@@ -415,14 +365,14 @@ The following describes how to implement multi-device collaboration through cros
function sendMsgCallback(data) {
console.info('CalleeSortFunc called');
- // Obtain the sequenceable data sent by the caller ability.
- let receivedData = new MySequenceable(0, '');
- data.readSequenceable(receivedData);
+ // Obtain the parcelable data sent by the CallerAbility.
+ let receivedData = new MyParcelable(0, '');
+ data.readParcelable(receivedData);
console.info(`receiveData[${receivedData.num}, ${receivedData.str}]`);
// Process the data.
- // Return the sequenceable data result to the caller ability.
- return new MySequenceable(receivedData.num + 1, `send ${receivedData.str} succeed`);
+ // Return the parcelable data result to the CallerAbility.
+ return new MyParcelable(receivedData.num + 1, `send ${receivedData.str} succeed`);
}
export default class CalleeAbility extends Ability {
@@ -436,25 +386,24 @@ The following describes how to implement multi-device collaboration through cros
onDestroy() {
try {
- this.callee.off(MSG_SEND_METHOD);
+ this.callee.off(MSG_SEND_METHOD);
} catch (error) {
console.error(TAG, `${MSG_SEND_METHOD} unregister failed with error ${JSON.stringify(error)}`);
}
}
}
```
-
-4. Obtain the caller object and access the callee ability.
+
+4. Obtain the caller object and access the CalleeAbility.
1. Import the **UIAbility** module.
```ts
import Ability from '@ohos.app.ability.UIAbility';
```
-
2. Obtain the caller object.
-
- 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 **context** attribute of the UIAbility implements **startAbilityByCall** to obtain the caller object for communication. The following example uses **this.context** to obtain the **context** attribute of the UIAbility, uses **startAbilityByCall** to start the CalleeAbility, obtain the caller object, and register the **onRelease** and **onRemoteStateChange** listeners of the CallerAbility. You need to implement processing based on service requirements.
+
```ts
async onButtonGetRemoteCaller() {
@@ -469,11 +418,19 @@ The following describes how to implement multi-device collaboration through cros
if (data != null) {
caller = data;
console.info('get remote caller success');
- // Register the onRelease() listener of the caller ability.
+ // Register the onRelease listener of the CallerAbility.
caller.onRelease((msg) => {
console.info(`remote caller onRelease is called ${msg}`);
})
console.info('remote caller register OnRelease succeed');
+ // Register the onRemoteStateChange listener of the CallerAbility.
+ try {
+ caller.onRemoteStateChange((str) => {
+ console.log('Remote state changed ' + str);
+ });
+ } catch (error) {
+ console.log('Caller.onRemoteStateChange catch error, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
+ }
}
}).catch((error) => {
console.error(`get remote caller failed with ${error}`);
@@ -483,21 +440,21 @@ The following describes how to implement multi-device collaboration through cros
For details about how to implement **getRemoteDeviceId()**, see [Starting UIAbility and ServiceExtensionAbility Across Devices (No Data Returned)](#starting-uiability-and-serviceextensionability-across-devices-no-data-returned).
-5. Sends agreed sequenceable data to the callee ability.
- 1. 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.
+5. Sends agreed parcelable data to the CalleeAbility.
+ 1. The parcelable data can be sent to the CalleeAbility with or without a return value. The method and parcelable data must be consistent with those of the CalleeAbility. The following example describes how to send data to the CalleeAbility.
```ts
const MSG_SEND_METHOD: string = 'CallSendMsg';
async onButtonCall() {
try {
- let msg = new MySequenceable(1, 'origin_Msg');
+ let msg = new MyParcelable(1, 'origin_Msg');
await this.caller.call(MSG_SEND_METHOD, msg);
} catch (error) {
console.info(`caller call failed with ${error}`);
}
}
```
- 2. 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**.
+ 2. In the following, **CallWithResult** is used to send data **originMsg** to the CalleeAbility and assign the data processed by the **CallSendMsg** method to **backMsg**.
```ts
const MSG_SEND_METHOD: string = 'CallSendMsg';
@@ -505,12 +462,12 @@ The following describes how to implement multi-device collaboration through cros
backMsg: string = '';
async onButtonCallWithResult(originMsg, backMsg) {
try {
- let msg = new MySequenceable(1, originMsg);
+ let msg = new MyParcelable(1, originMsg);
const data = await this.caller.callWithResult(MSG_SEND_METHOD, msg);
console.info('caller callWithResult succeed');
- let result = new MySequenceable(0, '');
- data.readSequenceable(result);
+ let result = new MyParcelable(0, '');
+ data.readParcelable(result);
backMsg(result.str);
console.info(`caller result is [${result.num}, ${result.str}]`);
} catch (error) {
diff --git a/en/application-dev/application-models/inputmethodextentionability.md b/en/application-dev/application-models/inputmethodextentionability.md
index 9a025339cab6a5f555fd61b15597400b31affeb7..8a7856f402bf30b1610521e3cf05dda7145c3509 100644
--- a/en/application-dev/application-models/inputmethodextentionability.md
+++ b/en/application-dev/application-models/inputmethodextentionability.md
@@ -33,7 +33,7 @@ In the **ets** directory of the target module, right-click and choose **New** >
> **NOTE**
>
-> When compiling the input method application, use the signature at the system_core level. Otherwise, the application will not be able to start the keyboard.
+> When compiling the input method application, use the signature at the system_basic level. Otherwise, the application will not be able to start the keyboard.
The minimum template implements an input method application with the most basic features, such as starting the keyboard, entering text, and deleting input. You can diversify the feature set of the application by, for example, adding the feature to hide the keyboard.
diff --git a/en/application-dev/application-models/itc-with-worker.md b/en/application-dev/application-models/itc-with-worker.md
index 8cbe53eeea067ae1875a8ff4b73bc4cde7bdd629..996ab941b0244571dff6116a45ab5e2165cf1184 100644
--- a/en/application-dev/application-models/itc-with-worker.md
+++ b/en/application-dev/application-models/itc-with-worker.md
@@ -18,7 +18,7 @@ To develop the Worker mode, perform the following steps:
}
```
-2. Create the **worker.js** file based on the configuration in **build-profile.json5**.
+2. Create the **worker.ts** file based on the configuration in **build-profile.json5**.
```ts
import worker from '@ohos.worker';
@@ -58,7 +58,7 @@ To develop the Worker mode, perform the following steps:
```ts
import worker from '@ohos.worker';
- let wk = new worker.ThreadWorker("../workers/worker.js");
+ let wk = new worker.ThreadWorker("../workers/worker.ts");
// Send a message to the worker thread.
wk.postMessage("message from main thread.")
@@ -74,6 +74,6 @@ To develop the Worker mode, perform the following steps:
> **NOTE**
>
-> - If the relative path of **worker.ts** configured in **build-profile.json5** is **./src/main/ets/workers/worker.ts**, pass in the path **entry/ets/workers/worker.ts** when creating a worker thread in the stage model, and pass in the path **../workers/worker.js** when creating a worker thread in the FA model.
+> - If the relative path of **worker.ts** configured in **build-profile.json5** is **./src/main/ets/workers/worker.ts**, pass in the path **entry/ets/workers/worker.ts** when creating a worker thread in the stage model, and pass in the path **../workers/worker.ts** when creating a worker thread in the FA model.
>
> - For details about the data types supported between the main thread and worker thread, see [Sequenceable Data Types](../reference/apis/js-apis-worker.md#sequenceable-data-types).
diff --git a/en/application-dev/application-models/mission-management-overview.md b/en/application-dev/application-models/mission-management-overview.md
index 3346e8105deef0dce6dc785b7e88b10e2a4ce3e1..ba55ebb136ebffca0294bf69013f2f2ab4392e7f 100644
--- a/en/application-dev/application-models/mission-management-overview.md
+++ b/en/application-dev/application-models/mission-management-overview.md
@@ -30,102 +30,100 @@ Missions are managed by system applications (such as home screen), rather than t
A UIAbility instance corresponds to an independent mission. Therefore, when an application calls [startAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability) to start a UIAbility, a mission is created.
-
-To call [missionManager](../reference/apis/js-apis-application-missionManager.md) to manage missions, the home screen application must request the **ohos.permission.MANAGE_MISSIONS** permission. For details about the configuration, see [Permission Application Guide](../security/accesstoken-guidelines.md#declaring-permissions-in-the-configuration-file).
-
-
-You can use **missionManager** to manage missions, for example, listening for mission changes, obtaining mission information or snapshots, and clearing, locking, or unlocking missions. The sample code is as follows:
-
-
-
-```ts
-import missionManager from '@ohos.app.ability.missionManager'
-
-let listener = {
- // Listen for mission creation.
- onMissionCreated: function (mission) {
- console.info("--------onMissionCreated-------")
- },
- // Listen for mission destruction.
- onMissionDestroyed: function (mission) {
- console.info("--------onMissionDestroyed-------")
- },
- // Listen for mission snapshot changes.
- onMissionSnapshotChanged: function (mission) {
- console.info("--------onMissionSnapshotChanged-------")
- },
- // Listen for switching the mission to the foreground.
- onMissionMovedToFront: function (mission) {
- console.info("--------onMissionMovedToFront-------")
- },
- // Listen for mission icon changes.
- onMissionIconUpdated: function (mission, icon) {
- console.info("--------onMissionIconUpdated-------")
- },
- // Listen for mission name changes.
- onMissionLabelUpdated: function (mission) {
- console.info("--------onMissionLabelUpdated-------")
- },
- // Listen for mission closure events.
- onMissionClosed: function (mission) {
- console.info("--------onMissionClosed-------")
- }
-};
-
-// 1. Register a mission change listener.
-let listenerId = missionManager.on('mission', listener);
-
-// 2. Obtain the latest 20 missions in the system.
-missionManager.getMissionInfos("", 20, (error, missions) => {
- console.info("getMissionInfos is called, error.code = " + error.code);
- console.info("size = " + missions.length);
- console.info("missions = " + JSON.stringify(missions));
-});
-
-// 3. Obtain the detailed information about a mission.
-let missionId = 11; // The mission ID 11 is only an example.
-let mission = missionManager.getMissionInfo("", missionId).catch(function (err) {
- console.info(err);
-});
-
-// 4. Obtain the mission snapshot.
-missionManager.getMissionSnapShot("", missionId, (error, snapshot) => {
- console.info("getMissionSnapShot is called, error.code = " + error.code);
- console.info("bundleName = " + snapshot.ability.bundleName);
-})
-
-// 5. Obtain the low-resolution mission snapshot.
-missionManager.getLowResolutionMissionSnapShot("", missionId, (error, snapshot) => {
- console.info("getLowResolutionMissionSnapShot is called, error.code = " + error.code);
- console.info("bundleName = " + snapshot.ability.bundleName);
-})
-
-// 6. Lock or unlock the mission.
-missionManager.lockMission(missionId).then(() => {
- console.info("lockMission is called ");
-});
-
-missionManager.unlockMission(missionId).then(() => {
- console.info("unlockMission is called ");
-});
-
-// 7. Switch the mission to the foreground.
-missionManager.moveMissionToFront(missionId).then(() => {
- console.info("moveMissionToFront is called ");
-});
-
-// 8. Clear a single mission.
-missionManager.clearMission(missionId).then(() => {
- console.info("clearMission is called ");
-});
-
-// 9. Clear all missions.
-missionManager.clearAllMissions().catch(function (err) {
- console.info(err);
-});
-
-// 10. Deregister the mission change listener.
-missionManager.off('mission', listenerId, (error) => {
- console.info("unregisterMissionListener");
-})
-```
+To call [missionManager](../reference/apis/js-apis-application-missionManager.md) to manage missions, the home screen application must request the **ohos.permission.MANAGE_MISSIONS** permission. For details about the configuration, see [Declaring Permissions in the Configuration File](../security/accesstoken-guidelines.md#declaring-permissions-in-the-configuration-file).
+
+You can use **missionManager** to manage missions, for example, listening for mission changes, obtaining mission information or snapshots, and clearing, locking, or unlocking missions.
+
+ ```ts
+ import missionManager from '@ohos.app.ability.missionManager'
+
+ let listener = {
+ // Listen for mission creation.
+ onMissionCreated: function (mission) {
+ console.info("--------onMissionCreated-------")
+ },
+ // Listen for mission destruction.
+ onMissionDestroyed: function (mission) {
+ console.info("--------onMissionDestroyed-------")
+ },
+ // Listen for mission snapshot changes.
+ onMissionSnapshotChanged: function (mission) {
+ console.info("--------onMissionSnapshotChanged-------")
+ },
+ // Listen for switching the mission to the foreground.
+ onMissionMovedToFront: function (mission) {
+ console.info("--------onMissionMovedToFront-------")
+ },
+ // Listen for mission icon changes.
+ onMissionIconUpdated: function (mission, icon) {
+ console.info("--------onMissionIconUpdated-------")
+ },
+ // Listen for mission name changes.
+ onMissionLabelUpdated: function (mission) {
+ console.info("--------onMissionLabelUpdated-------")
+ },
+ // Listen for mission closure events.
+ onMissionClosed: function (mission) {
+ console.info("--------onMissionClosed-------")
+ }
+ };
+
+ // 1. Register a mission change listener.
+ let listenerId = missionManager.on('mission', listener);
+
+ // 2. Obtain the latest 20 missions in the system.
+ missionManager.getMissionInfos("", 20, (error, missions) => {
+ console.info("getMissionInfos is called, error.code = " + error.code);
+ console.info("size = " + missions.length);
+ console.info("missions = " + JSON.stringify(missions));
+ });
+
+ // 3. Obtain the detailed information about a mission.
+ let missionId = 11; // The mission ID 11 is only an example.
+ let mission = missionManager.getMissionInfo("", missionId).catch(function (err) {
+ console.info(err);
+ });
+
+ // 4. Obtain the mission snapshot.
+ missionManager.getMissionSnapShot("", missionId, (error, snapshot) => {
+ console.info("getMissionSnapShot is called, error.code = " + error.code);
+ console.info("bundleName = " + snapshot.ability.bundleName);
+ })
+
+ // 5. Obtain the low-resolution mission snapshot.
+ missionManager.getLowResolutionMissionSnapShot("", missionId, (error, snapshot) => {
+ console.info("getLowResolutionMissionSnapShot is called, error.code = " + error.code);
+ console.info("bundleName = " + snapshot.ability.bundleName);
+ })
+
+ // 6. Lock or unlock the mission.
+ missionManager.lockMission(missionId).then(() => {
+ console.info("lockMission is called ");
+ });
+
+ missionManager.unlockMission(missionId).then(() => {
+ console.info("unlockMission is called ");
+ });
+
+ // 7. Switch the mission to the foreground.
+ missionManager.moveMissionToFront(missionId).then(() => {
+ console.info("moveMissionToFront is called ");
+ });
+
+ // 8. Clear a single mission.
+ missionManager.clearMission(missionId).then(() => {
+ console.info("clearMission is called ");
+ });
+
+ // 9. Clear all missions.
+ missionManager.clearAllMissions().catch(function (err) {
+ console.info(err);
+ });
+
+ // 10. Deregister the mission change listener.
+ missionManager.off('mission', listenerId, (error) => {
+ console.info("unregisterMissionListener");
+ })
+ ```
+
+
diff --git a/en/application-dev/application-models/mission-set-icon-name-for-task-snapshot.md b/en/application-dev/application-models/mission-set-icon-name-for-task-snapshot.md
new file mode 100644
index 0000000000000000000000000000000000000000..9fdc03477c0552f523a0ee9c40c6fa5b8d7c4363
--- /dev/null
+++ b/en/application-dev/application-models/mission-set-icon-name-for-task-snapshot.md
@@ -0,0 +1,51 @@
+# Setting the Icon and Name of a Mission Snapshot
+
+Setting a unique icon and name for each mission snapshot of an application helps you better manage the missions and functions of the application.
+
+By default, the **icon** and **label** fields in the [abilities tag](../quick-start/module-configuration-file.md#abilities) of the [module.json5 file](../quick-start/module-configuration-file.md) are used to set the icon and label.
+
+Figure 1 Mission snapshot of a UIAbility
+
+
+
+You can also use [UIAbilityContext.setMissionIcon()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextsetmissionicon) and [UIAbilityContext.setMissionLabel()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextsetmissionlabel) to customize the icon and name for a mission snapshot. For example, for a UIAbility instance with the launch type set to **standard**, you can configure the icon and name for each mission snapshot based on different functions.
+
+This document describes the following operations:
+
+- [Setting a Mission Snapshot Icon (for System Applications Only)](#setting-a-mission-snapshot-icon-for-system-applications-only)
+- [Setting a Mission Snapshot Name](#setting-a-mission-snapshot-name)
+
+## Setting a Mission Snapshot Icon (for System Applications Only)
+
+Call [UIAbilityContext.setMissionIcon()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextsetmissionicon) to set the icon of a mission snapshot. The icon is an object of the [PixelMap](../reference/apis/js-apis-image.md#pixelmap7) type. For details about how to obtain the context, see [Obtaining the Context of UIAbility](uiability-usage.md#obtaining-the-context-of-uiability).
+```ts
+let imagePixelMap: PixelMap = undefined; // Obtain the PixelMap information.
+
+this.context.setMissionIcon(imagePixelMap, (err) => {
+ console.error(`setMissionLabel failed, code is ${err.code}, message is ${err.message}`);
+})
+```
+
+The display effect is shown below.
+
+Figure 2 Mission snapshot icon
+
+
+
+## Setting a Mission Snapshot Name
+
+Call [UIAbilityContext.setMissionLabel()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextsetmissionlabel) to set the name of a mission snapshot.
+
+```ts
+this.context.setMissionLabel('test').then(() => {
+ console.info('setMissionLabel succeeded.');
+}).catch((err) => {
+ console.error(`setMissionLabel failed, code is ${err.code}, message is ${err.message}`);
+});
+```
+
+The display effect is shown below.
+
+Figure 3 Mission snapshot name
+
+
\ No newline at end of file
diff --git a/en/application-dev/application-models/request-permissions.md b/en/application-dev/application-models/request-permissions.md
index 670860d87dbb56adceb02f4ca350c24b61260d30..a29b793c9949d1080c8322681ba27cf6495f29ac 100644
--- a/en/application-dev/application-models/request-permissions.md
+++ b/en/application-dev/application-models/request-permissions.md
@@ -9,37 +9,7 @@ During application development, you must declare the required permission in the
To declare a permission in **config.json**, add **reqPermissions** under **module** and list the permission.
+For example, to request the permission to access the calendar, perform the following steps:
-For example, to declare the permission to access the calendar, request the **ohos.permission.READ_CALENDAR** permission. For details, see [Permission Application Guide](../security/accesstoken-guidelines.md#declaring-permissions-in-the-configuration-file).
-
-
-The sample code in the **config.json** file is as follows:
-
-```json
-{
- "module": {
- // ...
- "reqPermissions": [
- {
- "name": "ohos.permission.READ_CALENDAR"
- // ...
- }
- ]
- }
-}
-```
-
-
-Request the permission from uses in the form of a dialog box:
-
-```ts
-import featureAbility from '@ohos.ability.featureAbility';
-
-let context = featureAbility.getContext();
-let permissions: Array = ['ohos.permission.READ_CALENDAR']
-context.requestPermissionsFromUser(permissions, 1).then((data) => {
- console.info("Succeed to request permission from user with data: " + JSON.stringify(data))
-}).catch((error) => {
- console.info("Failed to request permission from user with error: " + JSON.stringify(error))
-})
-```
+1. Request the **ohos.permission.DISTRIBUTED_DATASYNC** permission. For details, see [Declaring Permissions in the Configuration File](../security/accesstoken-guidelines.md#declaring-permissions-in-the-configuration-file).
+2. Display a dialog box to ask authorization from the user when the application is started for the first time. For details, see [Requesting User Authorization](../security/accesstoken-guidelines.md#requesting-user-authorization).
diff --git a/en/application-dev/application-models/serviceextensionability.md b/en/application-dev/application-models/serviceextensionability.md
index edccb0b736c9ad81f5ae316e7310b6cc35ae34e0..9ff7a0ae5d6df7574da19565c81411236dba3dda 100644
--- a/en/application-dev/application-models/serviceextensionability.md
+++ b/en/application-dev/application-models/serviceextensionability.md
@@ -18,9 +18,9 @@ Each type of ExtensionAbility has its own context. ServiceExtensionAbility has [
This topic describes how to use ServiceExtensionAbility in the following scenarios:
-- [Implementing a Background Service (System Applications Only)](#implementing-a-background-service-system-applications-only)
+- [Implementing a Background Service (for System Applications Only)](#implementing-a-background-service-for-system-applications-only)
-- [Starting a Background Service (System Applications Only)](#starting-a-background-service-system-applications-only)
+- [Starting a Background Service (for System Applications Only)](#starting-a-background-service-for-system-applications-only)
- [Connecting to a Background Service](#connecting-to-a-background-service)
@@ -33,7 +33,7 @@ This topic describes how to use ServiceExtensionAbility in the following scenari
> - Third-party applications can connect to ServiceExtensionAbility provided by the system only when they gain focus in the foreground.
-## Implementing a Background Service (System Applications Only)
+## Implementing a Background Service (for System Applications Only)
[ServiceExtensionAbility](../reference/apis/js-apis-app-ability-serviceExtensionAbility.md) provides the callbacks **onCreate()**, **onRequest()**, **onConnect()**, **onDisconnect()**, and **onDestory()**. Override them as required. The following figure shows the lifecycle of ServiceExtensionAbility.
@@ -164,7 +164,7 @@ To implement a background service, manually create a ServiceExtensionAbility com
```
-## Starting a Background Service (System Applications Only)
+## Starting a Background Service (for System Applications Only)
A system application uses the [startServiceExtensionAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#abilitycontextstartserviceextensionability) method to start a background service. The [onRequest()](../reference/apis/js-apis-app-ability-serviceExtensionAbility.md#serviceextensionabilityonrequest) callback is invoked, and the **Want** object passed by the caller is received through the callback. After the background service is started, its lifecycle is independent of that of the client. In other words, even if the client is destroyed, the background service can still run. Therefore, the background service must be stopped by calling [terminateSelf()](../reference/apis/js-apis-inner-application-serviceExtensionContext.md#serviceextensioncontextterminateself) when its work is complete. Alternatively, another component can call [stopServiceExtensionAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#abilitycontextstopserviceextensionability) to stop the background service.
diff --git a/en/application-dev/application-models/stage-model-development-overview.md b/en/application-dev/application-models/stage-model-development-overview.md
index d7f8123a379fc7950820e531a14f45dfca68f961..451649bdb1a63147b79f8c7e2d4523d6c651c548 100644
--- a/en/application-dev/application-models/stage-model-development-overview.md
+++ b/en/application-dev/application-models/stage-model-development-overview.md
@@ -10,7 +10,7 @@ The following figure shows the basic concepts used in the stage model.
- [UIAbility component](uiability-overview.md) and [ExtensionAbility component](extensionability-overview.md)
- The stage model provides two types of application components: UIAbility and ExtensionAbility. Both have specific classes and support object-oriented development. They are the specific implementation of the abstract ability concept on the stage model. They are also units scheduled by the Ability Manager Service (AMS), which schedules their lifecycles as well.
+ The stage model provides two types of application components: UIAbility and ExtensionAbility. Both have specific classes and support object-oriented development.
- UIAbility has the UI and is mainly used for user interaction. For example, with UIAbility, the Gallery application can display images in the liquid layout. After a user selects an image, it uses a new UI to display the image details. The user can touch the **Back** button to return to the liquid layout. The lifecycle of the UIAbility component contains the creation, destruction, foreground, and background states. Display-related states are exposed through WindowStage events.
@@ -22,6 +22,7 @@ The following figure shows the basic concepts used in the stage model.
- [Context](application-context-stage.md)
In the stage model, Context and its derived classes provide a variety of resources and capabilities that can be called during the runtime. The UIAbility component and ExtensionAbility derived classes have different Context classes. These classes, which all inherit from the base class Context, provide different capabilities.
+
- [AbilityStage](abilitystage.md)
Each HAP of the Entry or Feature type has an AbilityStage class instance during the runtime. When the code in the HAP is loaded to the process for the first time, the system creates an AbilityStage class instance first. Each UIAbility class defined in the HAP is associated with this class instance after instantiation. Through this class instance, you can obtain the runtime information of the UIAbility instances in the HAP.
diff --git a/en/application-dev/application-models/start-remote-pageability.md b/en/application-dev/application-models/start-remote-pageability.md
index 7d270a68058448025def436e71ace635b4a1297c..36ee305b49698c1f6e6cf216174f77212f1d53e4 100644
--- a/en/application-dev/application-models/start-remote-pageability.md
+++ b/en/application-dev/application-models/start-remote-pageability.md
@@ -1,4 +1,4 @@
-# Starting a Remote PageAbility (System Applications Only)
+# Starting a Remote PageAbility (for System Applications Only)
The **startAbility()** method in the **featureAbility** class is used to start a remote PageAbility.
diff --git a/en/application-dev/application-models/static-subscriber-extension-ability.md b/en/application-dev/application-models/static-subscriber-extension-ability.md
deleted file mode 100644
index ae6d9a80b7ab6c693d06e7bfe8bfb11b4db94ab8..0000000000000000000000000000000000000000
--- a/en/application-dev/application-models/static-subscriber-extension-ability.md
+++ /dev/null
@@ -1,107 +0,0 @@
-# StaticSubscriberExtensionAbility Development
-
-## Scenario Description
-
-The common event service provides two subscription modes: dynamic and static. In dynamic subscription mode, a subscriber calls an API during the running period to subscribe to common events. For details, see [Subscribing to Common Events](common-event-subscription.md). In static subscription mode, no common event subscription API is called. A common event is subscribed by configuring a declaration file and implementing a class that inherits from **StaticSubscriberExtensionAbility**. A static subscriber is started once it receives a target event (for example, a power-on event) published by the system or application. At the same time, the **onReceiveEvent** callback is triggered, in which you can implement the service logic. **The static subscriber APIs are system APIs and can be used only by system applications that have passed the system-level power consumption review.**
-
-
-
-## How to Develop
-
-1. Prerequisites
-
- The application must meet the following requirements:
-
- The application is a system application.
-
- The application is developed using the full SDK.
-
- The application's power consumption has passed the system-level power consumption review. If you want to use static subscription in the debugging phase, add the bundle name of your application to the system configuration file **/etc/static_subscriber_config.json**.
-
-
-
-2. Declaring a Static Subscriber
-
- To declare a static subscriber, create an ExtensionAbility, which is derived from the **StaticSubscriberExtensionAbility** class, in the project. The sample code is as follows:
-
- ```ts
- import StaticSubscriberExtensionAbility from '@ohos.application.StaticSubscriberExtensionAbility'
-
- export default class StaticSubscriber extends StaticSubscriberExtensionAbility {
- onReceiveEvent(event) {
- console.log('onReceiveEvent, event:' + event.event);
- }
- }
- ```
-
- You can implement service logic in the **onReceiveEvent** callback.
-
-
-
-3. Project Configuration for a Static Subscriber
-
- After writing the static subscriber code, configure the subscriber in the **module.json5** file. The configuration format is as follows:
-
- ```ts
- {
- "module": {
- ......
- "extensionAbilities": [
- {
- "name": "StaticSubscriber",
- "srcEntrance": "./ets/StaticSubscriber/StaticSubscriber.ts",
- "description": "$string:StaticSubscriber_desc",
- "icon": "$media:icon",
- "label": "$string:StaticSubscriber_label",
- "type": "staticSubscriber",
- "visible": true,
- "metadata": [
- {
- "name": "ohos.extension.staticSubscriber",
- "resource": "$profile:subscribe"
- }
- ]
- }
- ]
- ......
- }
- }
- ```
-
- Pay attention to the following fields in the JSON file:
-
- **srcEntrance**: entry file path of the ExtensionAbility, that is, the file path of the static subscriber declared in Step 2.
-
- **type**: ExtensionAbility type. For a static subscriber, set this field to **staticSubscriber**.
-
- **metadata**: level-2 configuration file information of the ExtensionAbility. The configuration information varies according to the ExtensionAbility type. Therefore, you must use different config files to indicate the specific configuration. The **metadata** field contains two keywords: **name** and **resource**. The **name** field indicates the ExtensionAbility type name. For a static subscriber, declare the name as **ohos.extension.staticSubscriber** for successful identification. The **resource** field indicates the path that stores the ExtensionAbility configuration, which is customizable. In this example, the path is **resources/base/profile/subscribe.json**.
-
- A level-2 configuration file pointed to by **metadata** must be in the following format:
-
- ```ts
- {
- "commonEvents": [
- {
- "name": "xxx",
- "permission": "xxx",
- "events":[
- "xxx"
- ]
- }
- ]
- }
- ```
-
- If the level-2 configuration file is not declared in this format, the file cannot be identified. The fields are described as follows:
-
- **name**: name of the ExtensionAbility, which must be the same as the name of **extensionAbility** declared in **module.json5**.
-
- **permission**: permission required by the publisher. If a publisher without the required permission attempts to publish an event, the event is regarded as invalid and will not be published.
-
- **events**: list of subscribed target events
-
-
-
-## Samples
-
-For details about how to develop StaticSubscriberExtensionAbility, see [StaticSubscriber (ArkTS, API version 9, Full SDK)](https://gitee.com/openharmony/applications_app_samples/tree/master/ability/StaticSubscriber).
diff --git a/en/application-dev/application-models/subscribe-system-environment-variable-changes.md b/en/application-dev/application-models/subscribe-system-environment-variable-changes.md
new file mode 100644
index 0000000000000000000000000000000000000000..c231f483e9bcd8f83faf49d40007730d0f854de5
--- /dev/null
+++ b/en/application-dev/application-models/subscribe-system-environment-variable-changes.md
@@ -0,0 +1,172 @@
+# Subscribing to System Environment Variable Changes
+
+System environment variables are system settings (for example, the system language or screen direction) of a device that may change during the running of an application.
+
+By subscribing to the changes of system environment variables, the application can detect the changes in a timely manner and process the changes accordingly, providing better user experience. For example, when the system language changes, the application can display the UI in the new language; when the user rotates the device to landscape or portrait mode, the application can re-arrange the UI to adapt to the new screen orientation and size.
+
+The system environment variable changes are usually triggered by options in **Settings** or icons in **Control Panel**. For details about the system environment variables that support subscription, see [Configuration](../reference/apis/js-apis-app-ability-configuration.md).
+
+In OpenHarmony, you can subscribe to system environment variable changes in the following ways:
+
+- [Using ApplicationContext for Subscription](#using-applicationcontext-for-subscription)
+- [Using AbilityStage for Subscription](#using-abilitystage-for-subscription)
+- [Using UIAbility for Subscription](#using-uiability-for-subscription)
+- [Using ExtensionAbility for Subscription](#using-extensionability-for-subscription)
+
+## Using ApplicationContext for Subscription
+
+[ApplicationContext](../reference/apis/js-apis-inner-application-applicationContext.md) provides an API for registering a callback function to subscribe to the system environment variable changes. It also provides an API for deregistration so you can release related resources when they are no longer needed.
+
+1. Call **ApplicationContext.on(type: 'environment', callback: EnvironmentCallback)** to subscribe to changes in system environment variables. The code snippet below is used to subscribe to system language changes on a page.
+
+ ```ts
+ import common from '@ohos.app.ability.common';
+
+ @Entry
+ @Component
+ struct Index {
+ private context = getContext(this) as common.UIAbilityContext;
+ private callbackId: number; // ID of the subscription for system environment variable changes.
+
+ subscribeConfigurationUpdate() {
+ let systemLanguage: string = this.context.config.language; // Obtain the system language in use.
+
+ // 1. Obtain an ApplicationContext object.
+ let applicationContext = this.context.getApplicationContext();
+
+ // 2. Subscribe to system environment variable changes through ApplicationContext.
+ let environmentCallback = {
+ onConfigurationUpdated(newConfig) {
+ console.info(`onConfigurationUpdated systemLanguage is ${systemLanguage}, newConfig: ${JSON.stringify(newConfig)}`);
+
+ if (this.systemLanguage !== newConfig.language) {
+ console.info(`systemLanguage from ${systemLanguage} changed to ${newConfig.language}`);
+ systemLanguage = newConfig.language; // Save the new system language as the system language in use, which will be used for comparison.
+ }
+ },
+ onMemoryLevel(level) {
+ console.info(`onMemoryLevel level: ${level}`);
+ }
+ }
+
+ this.callbackId = applicationContext.on('environment', environmentCallback);
+ }
+
+ // Page display.
+ build() {
+ // ...
+ }
+ }
+ ```
+
+2. Call **ApplicationContext.off(type: 'environment', callbackId: number)** to release the resources.
+
+ ```ts
+ import common from '@ohos.app.ability.common';
+
+ @Entry
+ @Component
+ struct Index {
+ private context = getContext(this) as common.UIAbilityContext;
+ private callbackId: number; // ID of the subscription for system environment variable changes.
+
+ unsubscribeConfigurationUpdate() {
+ let applicationContext = this.context.getApplicationContext();
+ applicationContext.off('environment', this.callbackId);
+ }
+
+ // Page display.
+ build() {
+ // ...
+ }
+ }
+ ```
+
+## Using AbilityStage for Subscription
+
+The AbilityStage component provides the [AbilityStage.onConfigurationUpdate()](../reference/apis/js-apis-app-ability-abilityStage.md#abilitystageonconfigurationupdate) callback for subscribing to system environment variable changes. This callback is invoked when a system environment variable changes. In this callback, the latest system environment configuration is obtained through the [Configuration](../reference/apis/js-apis-app-ability-configuration.md) object.
+
+> **NOTE**
+>
+> - AbilityStage is not automatically generated in the default project of DevEco Studio. For details about how to create an AbilityStage file, see [AbilityStage Component Container](abilitystage.md).
+> - The callback used to subscribe to system environment variable changes has the same lifecycle as the [AbilityStage](../reference/apis/js-apis-app-ability-abilityStage.md) instance and will be destroyed when the instance is destroyed.
+
+The code snippet below uses the [AbilityStage.onConfigurationUpdate()](../reference/apis/js-apis-app-ability-abilityStage.md#abilitystageonconfigurationupdate) callback to subscribe to the system language changes.
+
+```ts
+import AbilityStage from '@ohos.app.ability.AbilityStage';
+
+let systemLanguage: string; // System language in use.
+
+export default class MyAbilityStage extends AbilityStage {
+ onCreate() {
+ systemLanguage = this.context.config.language; // Obtain the system language in use when the AbilityStage instance is loaded for the first time.
+ console.info(`systemLanguage is ${systemLanguage} `);
+ }
+
+ onConfigurationUpdate(newConfig) {
+ console.info(`onConfigurationUpdated systemLanguage is ${systemLanguage}, newConfig: ${JSON.stringify(newConfig)}`);
+
+ if (systemLanguage !== newConfig.language) {
+ console.info(`systemLanguage from ${systemLanguage} changed to ${newConfig.language}`);
+ systemLanguage = newConfig.language; // Save the new system language as the system language in use, which will be used for comparison.
+ }
+ }
+}
+```
+
+## Using UIAbility for Subscription
+
+The UIAbility component provides the **UIAbility.onConfigurationUpdate()** callback for subscribing to system environment variable changes. This callback is invoked when a system environment variable changes. In this callback, the latest system environment configuration is obtained through the [Configuration](../reference/apis/js-apis-app-ability-configuration.md) object, without restarting the UIAbility.
+
+> **NOTE**
+>
+> The callback used to subscribe to system environment variable changes has the same lifecycle as the UIAbility instance and will be destroyed when the instance is destroyed.
+
+The code snippet below uses the **onConfigurationUpdate()** callback to subscribe to the system language changes.
+
+```ts
+import UIAbility from '@ohos.app.ability.UIAbility';
+
+let systemLanguage: string; // System language in use.
+
+export default class EntryAbility extends UIAbility {
+ onCreate(want, launchParam) {
+ systemLanguage = this.context.config.language; // Obtain the system language in use when the UIAbility instance is loaded for the first time.
+ console.info(`systemLanguage is ${systemLanguage} `);
+ }
+
+ onConfigurationUpdate(newConfig) {
+ console.info(`onConfigurationUpdated systemLanguage is ${systemLanguage}, newConfig: ${JSON.stringify(newConfig)}`);
+
+ if (systemLanguage !== newConfig.language) {
+ console.info(`systemLanguage from ${systemLanguage} changed to ${newConfig.language}`);
+ systemLanguage = newConfig.language; // Save the new system language as the system language in use, which will be used for comparison.
+ }
+ }
+
+ // ...
+}
+```
+
+## Using ExtensionAbility for Subscription
+
+The ExtensionAbility component provides the **onConfigurationUpdate()** callback for subscribing system environment variable changes. This callback is invoked when a system environment variable changes. In this callback, the latest system environment configuration is obtained through the [Configuration](../reference/apis/js-apis-app-ability-configuration.md) object.
+
+> **NOTE**
+>
+> The callback used to subscribe to system environment variable changes has the same lifecycle as the ExtensionAbility instance and will be destroyed when the instance is destroyed.
+
+The code snippet below uses FormExtensionAbility as an example to describe how to use the **onConfigurationUpdate()** callback to subscribe to system environment variable changes.
+
+```ts
+import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
+
+export default class EntryFormAbility extends FormExtensionAbility {
+ onConfigurationUpdate(newConfig) {
+ console.info(`newConfig is ${JSON.stringify(newConfig)}`);
+ }
+
+ // ...
+}
+```
diff --git a/en/application-dev/application-models/uiability-data-sync-with-ui.md b/en/application-dev/application-models/uiability-data-sync-with-ui.md
index 9ed8c8d6f3b307ef44097f1ff67e6dcf472f91a5..e5e5b7b54f2ad8e98048a08599360806e3ea578d 100644
--- a/en/application-dev/application-models/uiability-data-sync-with-ui.md
+++ b/en/application-dev/application-models/uiability-data-sync-with-ui.md
@@ -80,7 +80,7 @@ Before using the APIs provided by **EventHub**, you must obtain an **EventHub**
4. After **event1** is used, you can call [eventHub.off()](../reference/apis/js-apis-inner-application-eventHub.md#eventhuboff) to unsubscribe from the event.
```ts
- // context is the ability-level context of the UIAbility instance.
+ // context is the AbilityContext of the UIAbility instance.
this.context.eventHub.off('event1');
```
@@ -240,10 +240,6 @@ The following provides an example to describe the object overwritten problem in
struct Index {
onPageShow() {
let ctx = globalThis.context; // Obtain the context from globalThis and use it.
- let permissions = ['com.example.permission']
- ctx.requestPermissionsFromUser(permissions,(result) => {
- // ...
- });
}
// Page display.
build() {
@@ -251,7 +247,7 @@ The following provides an example to describe the object overwritten problem in
}
}
```
-
+
3. In the UIAbilityB file, [UIAbilityContext](../reference/apis/js-apis-inner-application-uiAbilityContext.md) is stored in **globalThis** and has the same name as that in the UIAbilityA file.
```ts
@@ -274,10 +270,6 @@ The following provides an example to describe the object overwritten problem in
struct Index {
onPageShow() {
let ctx = globalThis.context; // Obtain the context from globalThis and use it.
- let permissions = ['com.example.permission']
- ctx.requestPermissionsFromUser(permissions,(result) => {
- console.info('requestPermissionsFromUser result:' + JSON.stringify(result));
- });
}
// Page display.
build() {
@@ -285,7 +277,7 @@ The following provides an example to describe the object overwritten problem in
}
}
```
-
+
5. Switch the UIAbilityB instance to the background and switch the UIAbilityA instance to the foreground. In this case, UIAbilityA will not enter the **onCreate()** lifecycle again.
```ts
@@ -307,10 +299,6 @@ The following provides an example to describe the object overwritten problem in
struct Index {
onPageShow() {
let ctx = globalThis.context; // The context in globalThis is the context of UIAbilityB.
- let permissions=['com.example.permission'];
- ctx.requestPermissionsFromUser(permissions,(result) => { // Using this object causes a process breakdown.
- console.info('requestPermissionsFromUser result:' + JSON.stringify(result));
- });
}
// Page display.
build() {
diff --git a/en/application-dev/application-models/uiability-intra-device-interaction.md b/en/application-dev/application-models/uiability-intra-device-interaction.md
index 84942ca0d94c3ee8d5f6d2d00fe05b14fefcc8b3..c8ba4ec50fa9b67805685468f0b3ab5cdada2377 100644
--- a/en/application-dev/application-models/uiability-intra-device-interaction.md
+++ b/en/application-dev/application-models/uiability-intra-device-interaction.md
@@ -15,9 +15,11 @@ This topic describes the UIAbility interaction modes in the following scenarios.
- [Starting UIAbility of Another Application and Obtaining the Return Result](#starting-uiability-of-another-application-and-obtaining-the-return-result)
+- [Starting UIAbility with Window Mode Specified (for System Applications Only)](#starting-uiability-with-window-mode-specified-for-system-applications-only)
+
- [Starting a Specified Page of UIAbility](#starting-a-specified-page-of-uiability)
-- [Using Ability Call to Implement UIAbility Interaction (System Applications Only)](#using-ability-call-to-implement-uiability-interaction-system-applications-only)
+- [Using Call to Implement UIAbility Interaction (for System Applications Only)](#using-call-to-implement-uiability-interaction-for-system-applications-only)
## Starting UIAbility in the Same Application
@@ -29,45 +31,52 @@ Assume that your application has two UIAbility components: EntryAbility and Func
1. In EntryAbility, call [startAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability) to start UIAbility. The [want](../reference/apis/js-apis-app-ability-want.md) parameter is the entry parameter for starting the UIAbility instance. In the **want** parameter, **bundleName** indicates the bundle name of the application to start; **abilityName** indicates the name of the UIAbility to start; **moduleName** is required only when the target UIAbility belongs to a different module; **parameters** is used to carry custom information. For details about how to obtain the context, see [Obtaining the Context of UIAbility](uiability-usage.md#obtaining-the-context-of-uiability).
```ts
+ let context = ...; // UIAbilityContext
let wantInfo = {
- deviceId: '', // An empty deviceId indicates the local device.
- bundleName: 'com.example.myapplication',
- abilityName: 'FuncAbility',
- moduleName: 'module1', // moduleName is optional.
- parameters: {// Custom information.
- info: 'From the Index page of EntryAbility',
- },
+ deviceId: '', // An empty deviceId indicates the local device.
+ bundleName: 'com.example.myapplication',
+ abilityName: 'FuncAbility',
+ moduleName: 'module1', // moduleName is optional.
+ parameters: {// Custom information.
+ info: 'From the Index page of EntryAbility',
+ },
}
- // context is the ability-level context of the initiator UIAbility.
- this.context.startAbility(wantInfo).then(() => {
- // ...
+ // context is the UIAbilityContext of the initiator UIAbility.
+ context.startAbility(wantInfo).then(() => {
+ // ...
}).catch((err) => {
- // ...
+ // ...
})
```
-
-2. Use the FuncAbility lifecycle callback to receive the parameters passed from EntryAbility.
+
+2. In FuncAbility, use [onCreate()](../reference/apis/js-apis-app-ability-uiAbility.md#uiabilityoncreate) or [onNewWant()](../reference/apis/js-apis-app-ability-uiAbility.md#uiabilityonnewwant) to receive the parameters passed in by EntryAbility.
```ts
import UIAbility from '@ohos.app.ability.UIAbility';
import window from '@ohos.window';
export default class FuncAbility extends UIAbility {
- onCreate(want, launchParam) {
- // Receive the parameters passed by the caller UIAbility.
- let funcAbilityWant = want;
- let info = funcAbilityWant?.parameters?.info;
- // ...
- }
+ onCreate(want, launchParam) {
+ // Receive the parameters passed by the initiator UIAbility.
+ let funcAbilityWant = want;
+ let info = funcAbilityWant?.parameters?.info;
+ // ...
+ }
}
```
+ > **NOTE**
+ >
+ > In FuncAbility started, you can obtain the PID and bundle name of the UIAbility through **parameters** in the passed **want** parameter.
+
3. To stop the **UIAbility** instance after the FuncAbility service is complete, call [terminateSelf()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextterminateself) in FuncAbility.
```ts
- // context is the ability-level context of the UIAbility instance to stop.
- this.context.terminateSelf((err) => {
- // ...
+ let context = ...; // UIAbilityContext
+
+ // context is the UIAbilityContext of the UIAbility instance to stop.
+ context.terminateSelf((err) => {
+ // ...
});
```
@@ -85,67 +94,70 @@ When starting FuncAbility from EntryAbility, you want the result to be returned
1. In EntryAbility, call [startAbilityForResult()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextterminateselfwithresult) to start FuncAbility. Use **data** in the asynchronous callback to receive information returned after FuncAbility stops itself. For details about how to obtain the context, see [Obtaining the Context of UIAbility](uiability-usage.md#obtaining-the-context-of-uiability).
```ts
+ let context = ...; // UIAbilityContext
let wantInfo = {
- deviceId: '', // An empty deviceId indicates the local device.
- bundleName: 'com.example.myapplication',
- abilityName: 'FuncAbility',
- moduleName: 'module1', // moduleName is optional.
- parameters: {// Custom information.
- info: 'From the Index page of EntryAbility',
- },
+ deviceId: '', // An empty deviceId indicates the local device.
+ bundleName: 'com.example.myapplication',
+ abilityName: 'FuncAbility',
+ moduleName: 'module1', // moduleName is optional.
+ parameters: {// Custom information.
+ info: 'From the Index page of EntryAbility',
+ },
}
- // context is the ability-level context of the initiator UIAbility.
- this.context.startAbilityForResult(wantInfo).then((data) => {
- // ...
+ // context is the UIAbilityContext of the initiator UIAbility.
+ context.startAbilityForResult(wantInfo).then((data) => {
+ // ...
}).catch((err) => {
- // ...
+ // ...
})
```
-
+
2. Call [terminateSelfWithResult()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextterminateselfwithresult) to stop FuncAbility. Use the input parameter **abilityResult** to carry the information that FuncAbility needs to return to EntryAbility.
```ts
+ let context = ...; // UIAbilityContext
const RESULT_CODE: number = 1001;
let abilityResult = {
- resultCode: RESULT_CODE,
- want: {
- bundleName: 'com.example.myapplication',
- abilityName: 'FuncAbility',
- moduleName: 'module1',
- parameters: {
- info: 'From the Index page of FuncAbility',
- },
+ resultCode: RESULT_CODE,
+ want: {
+ bundleName: 'com.example.myapplication',
+ abilityName: 'FuncAbility',
+ moduleName: 'module1',
+ parameters: {
+ info: 'From the Index page of FuncAbility',
},
+ },
}
- // context is the ability-level context of the callee UIAbility.
- this.context.terminateSelfWithResult(abilityResult, (err) => {
- // ...
+ // context is the AbilityContext of the target UIAbility.
+ context.terminateSelfWithResult(abilityResult, (err) => {
+ // ...
});
```
-
+
3. After FuncAbility stops itself, EntryAbility uses [startAbilityForResult()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextterminateselfwithresult) to receive the information returned by FuncAbility. The value of **RESULT_CODE** must be the same as the preceding value.
```ts
+ let context = ...; // UIAbilityContext
const RESULT_CODE: number = 1001;
// ...
- // context is the ability-level context of the initiator UIAbility.
- this.context.startAbilityForResult(want).then((data) => {
- if (data?.resultCode === RESULT_CODE) {
- // Parse the information returned by the callee UIAbility.
- let info = data.want?.parameters?.info;
- // ...
- }
- }).catch((err) => {
+ // context is the UIAbilityContext of the initiator UIAbility.
+ context.startAbilityForResult(wantInfo).then((data) => {
+ if (data?.resultCode === RESULT_CODE) {
+ // Parse the information returned by the target UIAbility.
+ let info = data.want?.parameters?.info;
// ...
+ }
+ }).catch((err) => {
+ // ...
})
```
## Starting UIAbility of Another Application
-Generally, the user only needs to do a common operation (for example, selecting a document application to view the document content) to start the UIAbility of another application. The [implicit Want launch mode](want-overview.md#types-of-want) is recommended. The system identifies a matched UIAbility and starts it based on the **want** parameter of the caller.
+Generally, the user only needs to do a common operation (for example, selecting a document application to view the document content) to start the UIAbility of another application. The [implicit Want launch mode](want-overview.md#types-of-want) is recommended. The system identifies a matched UIAbility and starts it based on the **want** parameter of the initiator UIAbility.
There are two ways to start **UIAbility**: [explicit and implicit](want-overview.md).
@@ -181,36 +193,38 @@ This section describes how to start the UIAbility of another application through
}
```
-2. Include **entities** and **actions** of the caller's **want** parameter into **entities** and **actions** under **skills** of the target UIAbility. After the system matches the UIAbility that meets the **entities** and **actions** information, a dialog box is displayed, showing the list of matched UIAbility instances for users to select. For details about how to obtain the context, see [Obtaining the Context of UIAbility](uiability-usage.md#obtaining-the-context-of-uiability).
+2. Include **entities** and **actions** of the initiator UIAbility's **want** parameter into **entities** and **actions** under **skills** of the target UIAbility. After the system matches the UIAbility that meets the **entities** and **actions** information, a dialog box is displayed, showing the list of matched UIAbility instances for users to select. For details about how to obtain the context, see [Obtaining the Context of UIAbility](uiability-usage.md#obtaining-the-context-of-uiability).
```ts
+ let context = ...; // UIAbilityContext
let wantInfo = {
- deviceId: '', // An empty deviceId indicates the local device.
- // Uncomment the line below if you want to implicitly query data only in the specific bundle.
- // bundleName: 'com.example.myapplication',
- action: 'ohos.want.action.viewData',
- // entities can be omitted.
- entities: ['entity.system.default'],
+ deviceId: '', // An empty deviceId indicates the local device.
+ // Uncomment the line below if you want to implicitly query data only in the specific bundle.
+ // bundleName: 'com.example.myapplication',
+ action: 'ohos.want.action.viewData',
+ // entities can be omitted.
+ entities: ['entity.system.default'],
}
- // context is the ability-level context of the initiator UIAbility.
- this.context.startAbility(wantInfo).then(() => {
- // ...
+ // context is the UIAbilityContext of the initiator UIAbility.
+ context.startAbility(wantInfo).then(() => {
+ // ...
}).catch((err) => {
- // ...
+ // ...
})
```
-
- The following figure shows the effect. When you click **Open PDF**, a dialog box is displayed for you to select.
-
- 
+
+ The following figure shows the effect. When you click **Open PDF**, a dialog box is displayed for you to select.
+ 
3. To stop the **UIAbility** instance after the document application is used, call [terminateSelf()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextterminateself).
```ts
- // context is the ability-level context of the UIAbility instance to stop.
- this.context.terminateSelf((err) => {
- // ...
+ let context = ...; // UIAbilityContext
+
+ // context is the AbilityContext of the UIAbility instance to stop.
+ context.terminateSelf((err) => {
+ // ...
});
```
@@ -245,68 +259,121 @@ If you want to obtain the return result when using implicit Want to start the UI
}
```
-2. Call [startAbilityForResult()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextterminateselfwithresult) to start the UIAbility of the payment application. Include **entities** and **actions** of the caller's **want** parameter into **entities** and **actions** under **skills** of the target UIAbility. Use **data** in the asynchronous callback to receive the information returned to the caller after the payment UIAbility stops itself. After the system matches the UIAbility that meets the **entities** and **actions** information, a dialog box is displayed, showing the list of matched UIAbility instances for users to select.
+2. Call [startAbilityForResult()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextterminateselfwithresult) to start the UIAbility of the payment application. Include **entities** and **actions** of the initiator UIAbility's **want** parameter into **entities** and **actions** under **skills** of the target UIAbility. Use **data** in the asynchronous callback to receive the information returned to the initiator UIAbility after the payment UIAbility stops itself. After the system matches the UIAbility that meets the **entities** and **actions** information, a dialog box is displayed, showing the list of matched UIAbility instances for users to select.
```ts
+ let context = ...; // UIAbilityContext
let wantInfo = {
- deviceId: '', // An empty deviceId indicates the local device.
- // Uncomment the line below if you want to implicitly query data only in the specific bundle.
- // bundleName: 'com.example.myapplication',
- action: 'ohos.want.action.editData',
- // entities can be omitted.
- entities: ['entity.system.default'],
+ deviceId: '', // An empty deviceId indicates the local device.
+ // Uncomment the line below if you want to implicitly query data only in the specific bundle.
+ // bundleName: 'com.example.myapplication',
+ action: 'ohos.want.action.editData',
+ // entities can be omitted.
+ entities: ['entity.system.default'],
}
- // context is the ability-level context of the initiator UIAbility.
- this.context.startAbilityForResult(wantInfo).then((data) => {
- // ...
+ // context is the UIAbilityContext of the initiator UIAbility.
+ context.startAbilityForResult(wantInfo).then((data) => {
+ // ...
}).catch((err) => {
- // ...
+ // ...
})
```
-
+
3. After the payment is finished, call [terminateSelfWithResult()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextterminateselfwithresult) to stop the payment UIAbility and return the **abilityResult** parameter.
```ts
+ let context = ...; // UIAbilityContext
const RESULT_CODE: number = 1001;
let abilityResult = {
- resultCode: RESULT_CODE,
- want: {
- bundleName: 'com.example.myapplication',
- abilityName: 'EntryAbility',
- moduleName: 'entry',
- parameters: {
- payResult: 'OKay',
- },
+ resultCode: RESULT_CODE,
+ want: {
+ bundleName: 'com.example.myapplication',
+ abilityName: 'EntryAbility',
+ moduleName: 'entry',
+ parameters: {
+ payResult: 'OKay',
},
+ },
}
- // context is the ability-level context of the callee UIAbility.
- this.context.terminateSelfWithResult(abilityResult, (err) => {
- // ...
+ // context is the AbilityContext of the target UIAbility.
+ context.terminateSelfWithResult(abilityResult, (err) => {
+ // ...
});
```
-
+
4. Receive the information returned by the payment application in the callback of the [startAbilityForResult()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextterminateselfwithresult) method. The value of **RESULT_CODE** must be the same as that returned by [terminateSelfWithResult()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextterminateselfwithresult).
```ts
+ let context = ...; // UIAbilityContext
const RESULT_CODE: number = 1001;
let want = {
// Want parameter information.
};
- // context is the ability-level context of the initiator UIAbility.
- this.context.startAbilityForResult(want).then((data) => {
- if (data?.resultCode === RESULT_CODE) {
- // Parse the information returned by the callee UIAbility.
- let payResult = data.want?.parameters?.payResult;
- // ...
- }
- }).catch((err) => {
+ // context is the UIAbilityContext of the initiator UIAbility.
+ context.startAbilityForResult(want).then((data) => {
+ if (data?.resultCode === RESULT_CODE) {
+ // Parse the information returned by the target UIAbility.
+ let payResult = data.want?.parameters?.payResult;
// ...
+ }
+ }).catch((err) => {
+ // ...
})
```
+## Starting UIAbility with Window Mode Specified (for System Applications Only)
+
+By specifying the window mode when starting the UIAbility of an application, the application can be displayed in different window modes, which can be full-screen, floating window, or split-screen.
+
+In full-screen mode, an application occupies the entire screen after being started. Users cannot view other windows or applications. This mode is suitable for an application that requires users to focus on a specific task or UI.
+
+In floating window mode, an application is displayed on the screen as a floating window after being started. Users can easily switch to other windows or applications. The mode is suitable for an application that requires users to process multiple tasks at the same time.
+
+In split-screen mode, two applications occupy the entire screen, with one on the left or in the upper part of the screen and the other on the right or in the lower part. This mode helps users improve multi-task processing efficiency.
+
+The window mode is specified by the **windowMode** field in the [StartOptions](../reference/apis/js-apis-app-ability-startOptions.md) parameter of [startAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability).
+
+> **NOTE**
+>
+> 1. If the **windowMode** field is not specified, the UIAbility is started in the default window mode.
+> 2. To ensure that the application can be displayed in the required window mode, check the **supportWindowMode** field in the [abilities](../quick-start/module-configuration-file.md#abilities) tag in the [module.json5 file](../quick-start/module-configuration-file.md) of the UIAbility and make sure the specified window mode is supported.
+
+The following uses the floating window mode as an example to describe how to start the FuncAbility from the EntryAbility page.
+
+1. Add the [StartOptions](../reference/apis/js-apis-app-ability-startOptions.md) parameter in [startAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability).
+2. Set the **windowMode** field in the [StartOptions](../reference/apis/js-apis-app-ability-startOptions.md) parameter to **WINDOW_MODE_FLOATING**, indicating that the UIAbility will be displayed in a floating window.
+
+For details about how to obtain the context, see [Obtaining the Context of UIAbility](uiability-usage.md#obtaining-the-context-of-uiability).
+
+```ts
+import AbilityConstant from '@ohos.app.ability.AbilityConstant';
+
+let context = ...; // UIAbilityContext
+let wantInfo = {
+ deviceId: '', // An empty deviceId indicates the local device.
+ bundleName: 'com.example.myapplication',
+ abilityName: 'FuncAbility',
+ moduleName: 'module1', // moduleName is optional.
+ parameters: {// Custom information.
+ info: 'From the Index page of EntryAbility',
+ },
+}
+let options = {
+ windowMode: AbilityConstant.WindowMode.WINDOW_MODE_FLOATING
+}
+// context is the UIAbilityContext of the initiator UIAbility.
+context.startAbility(wantInfo, options).then(() => {
+ // ...
+}).catch((err) => {
+ // ...
+})
+```
+
+The display effect is shown below.
+
## Starting a Specified Page of UIAbility
@@ -315,10 +382,11 @@ A UIAbility component can have multiple pages. When it is started in different s
### Specifying a Startup Page
-When the caller UIAbility starts another UIAbility, it usually needs to redirect to a specified page. For example, FuncAbility contains two pages: Index (corresponding to the home page) and Second (corresponding to function A page). You can configure the specified page URL in the **want** parameter by adding a custom parameter to **parameters** in **want**. For details about how to obtain the context, see [Obtaining the Context of UIAbility](uiability-usage.md#obtaining-the-context-of-uiability).
+When the initiator UIAbility starts another UIAbility, it usually needs to redirect to a specified page. For example, FuncAbility contains two pages: Index (corresponding to the home page) and Second (corresponding to function A page). You can configure the specified page URL in the **want** parameter by adding a custom parameter to **parameters** in **want**. For details about how to obtain the context, see [Obtaining the Context of UIAbility](uiability-usage.md#obtaining-the-context-of-uiability).
```ts
+let context = ...; // UIAbilityContext
let wantInfo = {
deviceId: '', // An empty deviceId indicates the local device.
bundleName: 'com.example.myapplication',
@@ -328,8 +396,8 @@ let wantInfo = {
router: 'funcA',
},
}
-// context is the ability-level context of the initiator UIAbility.
-this.context.startAbility(wantInfo).then(() => {
+// context is the UIAbilityContext of the initiator UIAbility.
+context.startAbility(wantInfo).then(() => {
// ...
}).catch((err) => {
// ...
@@ -347,25 +415,25 @@ import UIAbility from '@ohos.app.ability.UIAbility'
import Window from '@ohos.window'
export default class FuncAbility extends UIAbility {
- funcAbilityWant;
-
- onCreate(want, launchParam) {
- // Receive the parameters passed by the caller UIAbility.
- this.funcAbilityWant = want;
- }
-
- onWindowStageCreate(windowStage: Window.WindowStage) {
- // Main window is created. Set a main page for this ability.
- let url = 'pages/Index';
- if (this.funcAbilityWant?.parameters?.router) {
- if (this.funcAbilityWant.parameters.router === 'funA') {
- url = 'pages/Second';
- }
- }
- windowStage.loadContent(url, (err, data) => {
- // ...
- });
+ funcAbilityWant;
+
+ onCreate(want, launchParam) {
+ // Receive the parameters passed by the initiator UIAbility.
+ this.funcAbilityWant = want;
+ }
+
+ onWindowStageCreate(windowStage: Window.WindowStage) {
+ // Main window is created. Set a main page for this UIAbility.
+ let url = 'pages/Index';
+ if (this.funcAbilityWant?.parameters?.router) {
+ if (this.funcAbilityWant.parameters.router === 'funA') {
+ url = 'pages/Second';
+ }
}
+ windowStage.loadContent(url, (err, data) => {
+ // ...
+ });
+ }
}
```
@@ -384,11 +452,11 @@ In summary, when a UIAbility instance of application A has been created and the
import UIAbility from '@ohos.app.ability.UIAbility'
export default class FuncAbility extends UIAbility {
- onNewWant(want, launchParam) {
- // Receive the parameters passed by the caller UIAbility.
- globalThis.funcAbilityWant = want;
- // ...
- }
+ onNewWant(want, launchParam) {
+ // Receive the parameters passed by the initiator UIAbility.
+ globalThis.funcAbilityWant = want;
+ // ...
+ }
}
```
@@ -419,215 +487,200 @@ In summary, when a UIAbility instance of application A has been created and the
> **NOTE**
>
-> When the [launch type of the callee UIAbility](uiability-launch-type.md) is set to **standard**, a new instance is created each time the callee UIAbility is started. In this case, the [onNewWant()](../reference/apis/js-apis-app-ability-uiAbility.md#abilityonnewwant) callback will not be invoked.
+> When the [launch type of the target UIAbility](uiability-launch-type.md) is set to **standard**, a new instance is created each time the target UIAbility is started. In this case, the [onNewWant()](../reference/apis/js-apis-app-ability-uiAbility.md#abilityonnewwant) callback will not be invoked.
-## Using Ability Call to Implement UIAbility Interaction (System Applications Only)
+## Using Call to Implement UIAbility Interaction (for System Applications Only)
-Ability call is an extension of the UIAbility capability. It enables the UIAbility to be invoked by and communicate with external systems. The UIAbility 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 UIAbility instances (caller ability and callee ability) through IPC.
+Call is an extension of the UIAbility capability. It enables the UIAbility to be invoked by and communicate with external systems. The UIAbility invoked can be either started in the foreground or created and run in the background. You can use the call to implement data sharing between two UIAbility instances (CallerAbility and CalleeAbility) through IPC.
-The core API used for the ability call is **startAbilityByCall**, which differs from **startAbility** in the following ways:
+The core API used for the call is **startAbilityByCall**, which differs from **startAbility** in the following ways:
-- **startAbilityByCall** supports ability launch in the foreground and background, whereas **startAbility** supports ability launch in the foreground only.
+- **startAbilityByCall** supports UIAbility launch in the foreground and background, whereas **startAbility** supports UIAbility launch 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.
+- The CallerAbility can use the caller object returned by **startAbilityByCall** to communicate with the CalleeAbility, but **startAbility** does not provide the communication capability.
-Ability call is usually used in the following scenarios:
+Call is usually used in the following scenarios:
-- Communicating with the callee ability
+- Communicating with the CalleeAbility
-- Starting the callee ability in the background
+- Starting the CalleeAbility in the background
-**Table 1** Terms used in the ability call
+**Table 1** Terms used in the call
| **Term**| Description|
| -------- | -------- |
-| CallerAbility | UIAbility that triggers the ability call.|
-| CalleeAbility | UIAbility 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.|
+| CallerAbility| UIAbility that triggers the call.|
+| CalleeAbility | UIAbility invoked by the call.|
+| Caller | Object returned by **startAbilityByCall** and used by the CallerAbility to communicate with the CalleeAbility.|
+| Callee | Object held by the CalleeAbility to communicate with the CallerAbility.|
-The following figure shows the ability call process.
+The following figure shows the call process.
-Figure 1 Ability call process
+ Figure 1 Call process
-
+ 
-- 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 CallerAbility uses **startAbilityByCall** to obtain a caller object and uses **call()** of the caller object to send data to the CalleeAbility.
-- 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.
+- The CalleeAbility, which holds a **Callee** object, uses **on()** of the **Callee** object to register a callback. This callback is invoked when the CalleeAbility receives data from the CallerAbility.
> **NOTE**
-> 1. Currently, only system applications can use the ability call.
+> 1. Currently, only system applications can use the call.
>
-> 2. The launch type of the callee ability must be **singleton**.
+> 2. The launch type of the CalleeAbility must be **singleton**.
>
-> 3. Both local (intra-device) and cross-device ability calls are supported. The following describes how to initiate a local call. For details about how to initiate a cross-device ability call, see [Using Cross-Device Ability Call](hop-multi-device-collaboration.md#using-cross-device-ability-call).
+> 3. Both local (intra-device) and cross-device calls are supported. The following describes how to initiate a local call. For details about how to initiate a cross-device call, see [Using Cross-Device Call](hop-multi-device-collaboration.md#using-cross-device-call).
### Available APIs
-The following table describes the main APIs used for the ability call. For details, see [AbilityContext](../reference/apis/js-apis-app-ability-uiAbility.md#caller).
+The following table describes the main APIs used for the call. For details, see [AbilityContext](../reference/apis/js-apis-app-ability-uiAbility.md#caller).
-**Table 2** Ability call APIs
+ **Table 2** Call APIs
| API| Description|
| -------- | -------- |
| startAbilityByCall(want: Want): Promise<Caller> | Starts a UIAbility in the foreground (through the **want** configuration) or background (default) and obtains the caller object for communication with the UIAbility. For details, see [AbilityContext](../reference/apis/js-apis-inner-application-uiAbilityContext.md#abilitycontextstartabilitybycall) or [ServiceExtensionContext](../reference/apis/js-apis-inner-application-serviceExtensionContext.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<void> | Sends agreed sequenceable data to the callee ability.|
-| callWithResult(method: string, data: rpc.Sequenceable): Promise<rpc.MessageParcel> | Sends agreed sequenceable data to the callee ability and obtains the agreed sequenceable data returned by the callee ability.|
+| on(method: string, callback: CalleeCallBack): void | Callback invoked when the CalleeAbility registers a method.|
+| off(method: string): void | Callback invoked when the CalleeAbility deregisters a method.|
+| call(method: string, data: rpc.Parcelable): Promise<void> | Sends agreed parcelable data to the CalleeAbility.|
+| callWithResult(method: string, data: rpc.Parcelable): Promise<rpc.MessageSequence> | Sends agreed parcelable data to the CalleeAbility and obtains the agreed parcelable data returned by the CalleeAbility.|
| release(): void | Releases the caller object.|
| on(type: "release", callback: OnReleaseCallback): void | Callback invoked when the caller object is released.|
-The implementation of using the ability call for UIAbility interaction involves two parts.
+The implementation of using the call for UIAbility interaction involves two parts.
-- [Creating a Callee Ability](#creating-a-callee-ability)
+- [Creating a CalleeAbility](#creating-a-calleeability)
-- [Accessing the Callee Ability](#accessing-the-callee-ability)
+- [Accessing the CalleeAbility](#accessing-the-calleeability)
-### Creating a Callee Ability
+### Creating a CalleeAbility
-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.
+For the CalleeAbility, 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.
+1. Configure the launch type of the UIAbility.
+
+ For example, set the launch type of the CalleeAbility to **singleton**. For details, see [UIAbility Component Launch Type](uiability-launch-type.md).
- Set **launchType** of the callee ability to **singleton** in the **module.json5** file.
-
- | JSON Field| Description|
- | -------- | -------- |
- | "launchType" | Ability launch type. Set this parameter to **singleton**.|
-
- An example of the ability configuration is as follows:
-
- ```json
- "abilities":[{
- "name": ".CalleeAbility",
- "srcEntrance": "./ets/CalleeAbility/CalleeAbility.ts",
- "launchType": "singleton",
- "description": "$string:CalleeAbility_desc",
- "icon": "$media:icon",
- "label": "$string:CalleeAbility_label",
- "visible": true
- }]
- ```
-
2. Import the **UIAbility** module.
-
+
```ts
- import Ability from '@ohos.app.ability.UIAbility';
+ import UIAbility from '@ohos.app.ability.UIAbility';
```
-3. Define the agreed sequenceable data.
+3. Define the agreed parcelable data.
- 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 data formats sent and received by the CallerAbility and CalleeAbility must be consistent. In the following example, the data formats are number and string.
+
```ts
- export default class MySequenceable {
- num: number = 0
- str: string = ""
+ export default class MyParcelable {
+ num: number = 0;
+ str: string = '';
- constructor(num, string) {
- this.num = num
- this.str = string
- }
+ constructor(num, string) {
+ this.num = num;
+ this.str = string;
+ }
- marshalling(messageParcel) {
- messageParcel.writeInt(this.num)
- messageParcel.writeString(this.str)
- return true
- }
+ marshalling(messageSequence) {
+ messageSequence.writeInt(this.num);
+ messageSequence.writeString(this.str);
+ return true
+ }
- unmarshalling(messageParcel) {
- this.num = messageParcel.readInt()
- this.str = messageParcel.readString()
- return true
- }
+ unmarshalling(messageSequence) {
+ this.num = messageSequence.readInt();
+ this.str = messageSequence.readString();
+ return true;
+ }
}
```
4. Implement **Callee.on** and **Callee.off**.
- 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 sample code is as follows:
+ The time to register a listener for the CalleeAbility 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 UIAbility and deregistered in **onDestroy**. After receiving parcelable data, the application processes the data and returns the data result. You need to implement processing based on service requirements. The sample code is as follows:
+
```ts
const TAG: string = '[CalleeAbility]';
const MSG_SEND_METHOD: string = 'CallSendMsg';
function sendMsgCallback(data) {
- console.info('CalleeSortFunc called');
+ console.info('CalleeSortFunc called');
- // Obtain the sequenceable data sent by the caller ability.
- let receivedData = new MySequenceable(0, '');
- data.readSequenceable(receivedData);
- console.info(`receiveData[${receivedData.num}, ${receivedData.str}]`);
+ // Obtain the parcelable data sent by the CallerAbility.
+ let receivedData = new MyParcelable(0, '');
+ data.readParcelable(receivedData);
+ console.info(`receiveData[${receivedData.num}, ${receivedData.str}]`);
- // Process the data.
- // Return the sequenceable data result to the caller ability.
- return new MySequenceable(receivedData.num + 1, `send ${receivedData.str} succeed`);
+ // Process the data.
+ // Return the parcelable data result to the CallerAbility.
+ return new MyParcelable(receivedData.num + 1, `send ${receivedData.str} succeed`);
}
- export default class CalleeAbility extends Ability {
- onCreate(want, launchParam) {
- try {
- this.callee.on(MSG_SEND_METHOD, sendMsgCallback);
- } catch (error) {
- console.info(`${MSG_SEND_METHOD} register failed with error ${JSON.stringify(error)}`);
- }
+ export default class CalleeAbility extends UIAbility {
+ onCreate(want, launchParam) {
+ try {
+ this.callee.on(MSG_SEND_METHOD, sendMsgCallback);
+ } catch (error) {
+ console.info(`${MSG_SEND_METHOD} register failed with error ${JSON.stringify(error)}`);
}
+ }
- onDestroy() {
- try {
- this.callee.off(MSG_SEND_METHOD);
- } catch (error) {
- console.error(TAG, `${MSG_SEND_METHOD} unregister failed with error ${JSON.stringify(error)}`);
- }
+ onDestroy() {
+ try {
+ this.callee.off(MSG_SEND_METHOD);
+ } catch (error) {
+ console.error(TAG, `${MSG_SEND_METHOD} unregister failed with error ${JSON.stringify(error)}`);
}
+ }
}
```
-### Accessing the Callee Ability
+### Accessing the CalleeAbility
1. Import the **UIAbility** module.
```ts
- import Ability from '@ohos.app.ability.UIAbility';
+ import UIAbility from '@ohos.app.ability.UIAbility';
```
2. Obtain the caller interface.
-
- 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 **UIAbilityContext** attribute implements **startAbilityByCall** to obtain the caller object for communication. The following example uses **this.context** to obtain the **UIAbilityContext**, uses **startAbilityByCall** to start the CalleeAbility, obtain the caller object, and register the **onRelease** listener of the CallerAbility. You need to implement processing based on service requirements.
+
+
```ts
- // Register the onRelease() listener of the caller ability.
+ // Register the onRelease() listener of the CallerAbility.
private regOnRelease(caller) {
- try {
- caller.on("release", (msg) => {
- console.info(`caller onRelease is called ${msg}`);
- })
- console.info('caller register OnRelease succeed');
- } catch (error) {
- console.info(`caller register OnRelease failed with ${error}`);
- }
+ try {
+ caller.on('release', (msg) => {
+ console.info(`caller onRelease is called ${msg}`);
+ })
+ console.info('caller register OnRelease succeed');
+ } catch (error) {
+ console.info(`caller register OnRelease failed with ${error}`);
+ }
}
async onButtonGetCaller() {
- try {
- this.caller = await context.startAbilityByCall({
- bundleName: 'com.samples.CallApplication',
- abilityName: 'CalleeAbility'
- })
- if (this.caller === undefined) {
- console.info('get caller failed')
- return
- }
- console.info('get caller success')
- this.regOnRelease(this.caller)
- } catch (error) {
- console.info(`get caller failed with ${error}`)
+ try {
+ this.caller = await context.startAbilityByCall({
+ bundleName: 'com.samples.CallApplication',
+ abilityName: 'CalleeAbility'
+ })
+ if (this.caller === undefined) {
+ console.info('get caller failed')
+ return
}
+ console.info('get caller success')
+ this.regOnRelease(this.caller)
+ } catch (error) {
+ console.info(`get caller failed with ${error}`)
+ }
}
```
diff --git a/en/application-dev/application-models/uiability-launch-type.md b/en/application-dev/application-models/uiability-launch-type.md
index 70c212ed46e769dbdf4e0c1fd347403c463f6004..6442ffc4359254bbed7d7da85ec4b753f0f3eea4 100644
--- a/en/application-dev/application-models/uiability-launch-type.md
+++ b/en/application-dev/application-models/uiability-launch-type.md
@@ -19,7 +19,7 @@ Each time [startAbility()](../reference/apis/js-apis-inner-application-uiAbility
**Figure 1** Demonstration effect in singleton mode
-
+
> **NOTE**
>
@@ -47,9 +47,9 @@ To use the singleton mode, set **launchType** in the [module.json5 configuration
In standard mode, each time [startAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability) is called, a new UIAbility instance of this type is created in the application process. Multiple UIAbility instances of this type are displayed in **Recents**.
-**Figure 2** Demonstration effect in standard mode
+**Figure 2** Demonstration effect in standard mode
-
+
To use the standard mode, set **launchType** in the [module.json5 configuration file](../quick-start/module-configuration-file.md) to **standard**.
@@ -75,12 +75,12 @@ The **specified** mode is used in some special scenarios. For example, in a docu
**Figure 3** Demonstration effect in specified mode
-
+
-For example, there are EntryAbility and SpecifiedAbility, and the launch type of SpecifiedAbility is set to **specified**. You are required to start SpecifiedAbility from EntryAbility.
+For example, there are two UIAbility components: EntryAbility and SpecifiedAbility (with the launch type **specified**). You are required to start SpecifiedAbility from EntryAbility.
+
+1. In SpecifiedAbility, set the **launchType** field in the [module.json5 file](../quick-start/module-configuration-file.md) to **specified**.
-1. In SpecifiedAbility, set the **launchType** field in the [module.json5 configuration file](../quick-start/module-configuration-file.md) to **specified**.
-
```json
{
"module": {
@@ -95,9 +95,8 @@ For example, there are EntryAbility and SpecifiedAbility, and the launch type of
}
```
-2. Before a UIAbility instance is created, you can create a unique string key for the instance. The key is bound to the UIAbility instance when it is created. Each time [startAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability) is called, the application is asked which UIAbility instance is used to respond to the [startAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability) request.
- In EntryAbility, add a custom parameter, for example, **instanceKey**, to the [want](want-overview.md) parameter in [startAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability) to distinguish the UIAbility instances.
-
+2. Create a unique string key for the instance. Each time [startAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability) is called, the application, based on the key, identifies the UIAbility instance used to respond to the request. In EntryAbility, add a custom parameter, for example, **instanceKey**, to the **want** parameter in [startAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability) to distinguish the UIAbility instance.
+
```ts
// Configure an independent key for each UIAbility instance.
// For example, in the document usage scenario, use the document path as the key.
@@ -114,17 +113,18 @@ For example, there are EntryAbility and SpecifiedAbility, and the launch type of
instanceKey: getInstance(),
},
}
- // context is the ability-level context of the initiator UIAbility.
+ // context is the UIAbilityContext of the initiator UIAbility.
this.context.startAbility(want).then(() => {
// ...
}).catch((err) => {
// ...
})
```
-
-3. During running, the internal service of UIAbility determines whether to create multiple instances. If the key is matched, the UIAbility instance bound to the key is started. Otherwise, a new UIAbility instance is created.
- The launch type of SpecifiedAbility is set to **specified**. Before SpecifiedAbility is started, the [onAcceptWant()](../reference/apis/js-apis-app-ability-abilityStage.md#abilitystageonacceptwant) callback of the corresponding AbilityStage instance is invoked to parse the input **want** parameter and obtain the custom parameter **instanceKey**. A string key identifier is returned through the [onAcceptWant()](../reference/apis/js-apis-app-ability-abilityStage.md#abilitystageonacceptwant) callback of the AbilityStage instance. [If the returned key corresponds to a started UIAbility instance](mission-management-launch-type.md#fig14520125175314), that UIAbility instance is switched to the foreground and gains focus again. Otherwise, a new instance is created and started.
-
+
+3. Before SpecifiedAbility is started, the [onAcceptWant()](../reference/apis/js-apis-app-ability-abilityStage.md#abilitystageonacceptwant) callback of the corresponding AbilityStage instance is invoked to obtain the key of the UIAbility, because the launch type of SpecifiedAbility is set to **specified**. If a UIAbility instance matching the key exists, the system starts the UIAbility instance and invokes its [onNewWant()](../reference/apis/js-apis-app-ability-uiAbility.md#abilityonnewwant) callback. Otherwise, the system creates a new UIAbility instance and invokes its [onCreate()](../reference/apis/js-apis-app-ability-uiAbility.md#uiabilityoncreate) and [onWindowStageCreate()](../reference/apis/js-apis-app-ability-uiAbility.md#uiabilityonwindowstagecreate) callbacks.
+
+ In the sample code, the [onAcceptWant()](../reference/apis/js-apis-app-ability-abilityStage.md#abilitystageonacceptwant) callback parses the **want** parameter to obtain the custom parameter **instanceKey**. The service logic returns a key string based on **instanceKey** parameter to identify the UIAbility instance. If the returned key maps to a started UIAbility instance, the system pulls the UIAbility instance back to the foreground and obtains the focus. If the returned key does not map to a started UIAbility instance, the system creates a new UIAbility instance and starts it.
+
```ts
import AbilityStage from '@ohos.app.ability.AbilityStage';
@@ -133,7 +133,7 @@ For example, there are EntryAbility and SpecifiedAbility, and the launch type of
// In the AbilityStage instance of the callee, a key value corresponding to a UIAbility instance is returned for UIAbility whose launch type is specified.
// In this example, SpecifiedAbility of module1 is returned.
if (want.abilityName === 'SpecifiedAbility') {
- // The returned string key is a custom string.
+ // The returned key string is a custom string.
return `SpecifiedAbilityInstance_${want.parameters.instanceKey}`;
}
@@ -141,22 +141,17 @@ For example, there are EntryAbility and SpecifiedAbility, and the launch type of
}
}
```
-
+
> **NOTE**
>
> 1. Assume that the application already has a UIAbility instance created, and the launch type of the UIAbility instance is set to **specified**. If [startAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability) is called again to start the UIAbility instance, and the [onAcceptWant()](../reference/apis/js-apis-app-ability-abilityStage.md#abilitystageonacceptwant) callback of [AbilityStage](../reference/apis/js-apis-app-ability-abilityStage.md) matches a created UIAbility instance, the original UIAbility instance is started, and no new UIAbility instance is created. In this case, the [onNewWant()](../reference/apis/js-apis-app-ability-uiAbility.md#abilityonnewwant) callback is invoked, but the [onCreate()](../reference/apis/js-apis-app-ability-uiAbility.md#uiabilityoncreate) and [onWindowStageCreate()](../reference/apis/js-apis-app-ability-uiAbility.md#uiabilityonwindowstagecreate) callbacks are not.
> 2. AbilityStage is not automatically generated in the default project of DevEco Studio. For details about how to create an AbilityStage file, see [AbilityStage Component Container](abilitystage.md).
-
- For example, in the document application, different key values are bound to different document instances. Each time a document is created, a new key value (for example, file path) is passed, and a new UIAbility instance is created when UIAbility is started in AbilityStage. However, when you open an existing document, the same UIAbility instance is started again in AbilityStage.
-
-The following steps are used as an example.
+ For example, in the document application, different keys are bound to different document instances. Each time a document is created, a new key (for example, file path) is passed, and a new UIAbility instance is created when UIAbility is started in AbilityStage. However, when you open an existing document, the same UIAbility instance is started again in AbilityStage.
+
+ The following steps are used as an example.
+
1. Open file A. A UIAbility instance, for example, UIAbility instance 1, is started.
-
2. Close the process of file A in **Recents**. UIAbility instance 1 is destroyed. Return to the home screen and open file A again. A new UIAbility instance is started, for example, UIAbility instance 2.
-
3. Return to the home screen and open file B. A new UIAbility instance is started, for example, UIAbility instance 3.
-
- 4. Return to the home screen and open file A again. UIAbility instance 2 is started.
-
-
\ No newline at end of file
+ 4. Return to the home screen and open file A again. UIAbility instance 2 is started. This is because the system automatically matches the key of the UIAbility instance and starts the UIAbility instance that has a matching key. In this example, UIAbility instance 2 has the same key as file A. Therefore, the system pulls back UIAbility instance 2 and focuses it without creating a new instance.
diff --git a/en/application-dev/application-models/uiability-overview.md b/en/application-dev/application-models/uiability-overview.md
index 7e31ab130df2ba9eaf959d1bfb3ddccfb7172480..cd059b9555bfd80c02c9bce66f4c50cd58fff568 100644
--- a/en/application-dev/application-models/uiability-overview.md
+++ b/en/application-dev/application-models/uiability-overview.md
@@ -5,10 +5,25 @@
UIAbility is a type of application component that provides the UI for user interaction.
-UIAbility is the basic unit scheduled by the system and provides a window for applications to draw UIs. An application can contain one or more UIAbility components. For example, for a payment application, you can use two UIAbility components to carry the entry and payment functionalities. You are advised to use one UIAbility component to carry the same functional module, with multiple pages (if necessary).
+The following design philosophy is behind UIAbility:
+
+1. Native support for [cross-device migration](hop-cross-device-migration.md) and [multi-device collaboration](hop-multi-device-collaboration.md) at the application component level
+
+2. Support for multiple device types and window forms
+
+For details, see [Interpretation of the Application Model](application-model-description.md).
+
+The UIAbility division principles and suggestions are as follows:
+
+UIAbility is the basic unit scheduled by the system and provides a window for applications to draw UIs. An application can contain one or more UIAbility components. For example, for a payment application, you can use two UIAbility components to carry the entry and payment functionalities.
Each UIAbility component instance is displayed as a mission in Recents.
+You can develop a single UIAbility or multiple UIAbilities for your application based on service requirements.
+
+- If you want only one mission to be displayed in Recents, use one UIAbility and multiple pages.
+
+- If you want multiple missions to be displayed in Recents or multiple windows to be opened simultaneously, use multiple UIAbilities.
## Privacy Statement Configuration
diff --git a/en/application-dev/application-models/windowextensionability.md b/en/application-dev/application-models/windowextensionability.md
index cf2ce01947412e479d29516601c45aebc2b55b17..069897ad02435070ac470f5d2d3d528c76b417e8 100644
--- a/en/application-dev/application-models/windowextensionability.md
+++ b/en/application-dev/application-models/windowextensionability.md
@@ -14,7 +14,7 @@ the context is [WindowExtensionContext](../reference/apis/js-apis-inner-applicat
>
-## Setting an Embedded Ability (System Applications Only)
+## Setting an Embedded Ability (for System Applications Only)
The **WindowExtensionAbility** class provides **onConnect()**, **onDisconnect()**, and **onWindowReady()** lifecycle callbacks, which can be overridden.
@@ -78,7 +78,7 @@ To implement an embedded application, manually create a WindowExtensionAbility i
```
-## Starting an Embedded Ability (System Applications Only)
+## Starting an Embedded Ability (for System Applications Only)
System applications can load the created WindowExtensionAbility through the AbilityComponent.
diff --git a/en/application-dev/connectivity/http-request.md b/en/application-dev/connectivity/http-request.md
index da1a7e1c517f284037a41a88e2167b6d1d2406aa..39ada2bc9b21b8e5d157806f5164c02219c65296 100644
--- a/en/application-dev/connectivity/http-request.md
+++ b/en/application-dev/connectivity/http-request.md
@@ -1,6 +1,6 @@
# HTTP Data Request
-## Use Cases
+## When to Use
An application can initiate a data request over HTTP. Common HTTP methods include **GET**, **POST**, **OPTIONS**, **HEAD**, **PUT**, **DELETE**, **TRACE**, and **CONNECT**.
@@ -14,40 +14,49 @@ For details about how to apply for permissions, see [Access Control Development]
The following table provides only a simple description of the related APIs. For details, see [API Reference](../reference/apis/js-apis-http.md).
-| API | Description |
-| ----------------------------------------- | --------------------------------------------------------- |
-| createHttp() | Creates an HTTP request. |
-| request() | Initiates an HTTP request to a given URL. |
-| destroy() | Destroys an HTTP request. |
+| API | Description |
+| ----------------------------------------- | ----------------------------------- |
+| createHttp() | Creates an HTTP request. |
+| request() | Initiates an HTTP request to a given URL. |
+| request2()10+ | Initiates an HTTP network request based on the URL and returns a streaming response.|
+| destroy() | Destroys an HTTP request. |
| on(type: 'headersReceive') | Registers an observer for HTTP Response Header events. |
-| off(type: 'headersReceive') | Unregisters the observer for HTTP Response Header events. |
+| off(type: 'headersReceive') | Unregisters the observer for HTTP Response Header events.|
+| once\('headersReceive'\)8+ | Registers a one-time observer for HTTP Response Header events.|
+| on\('dataReceive'\)10+ | Registers an observer for events indicating receiving of HTTP streaming responses. |
+| off\('dataReceive'\)10+ | Unregisters the observer for events indicating receiving of HTTP streaming responses. |
+| on\('dataEnd'\)10+ | Registers an observer for events indicating completion of receiving HTTP streaming responses. |
+| off\('dataEnd'\)10+ | Unregisters the observer for events indicating completion of receiving HTTP streaming responses.|
+| on\('dataProgress'\)10+ | Registers an observer for events indicating progress of receiving HTTP streaming responses. |
+| off\('dataProgress'\)10+ | Unregisters the observer for events indicating progress of receiving HTTP streaming responses.|
-## How to Develop
+## How to Develop request APIs
-1. Import the required HTTP module.
-2. Create an **HttpRequest** object.
-3. (Optional) Listen for HTTP Response Header events.
-4. Initiate an HTTP request to a given URL.
-5. (Optional) Process the HTTP Response Header event and the return result of the HTTP request.
+1. Import the **http** namespace from **@ohos.net.http.d.ts**.
+2. Call **createHttp()** to create an **HttpRequest** object.
+3. Call **httpRequest.on()** to subscribe to HTTP response header events. This API returns a response earlier than the request. You can subscribe to HTTP response header events based on service requirements.
+4. Call **httpRequest.request()** to initiate a network request. You need to pass in the URL and optional parameters of the HTTP request.
+5. Parse the returned result based on service requirements.
+6. Call **off()** to unsubscribe from HTTP response header events.
+7. Call **httpRequest.destroy()** to release resources after the request is processed.
```js
+// Import the http namespace.
import http from '@ohos.net.http';
-// Each HttpRequest corresponds to an HttpRequestTask object and cannot be reused.
+// Each httpRequest corresponds to an HTTP request task and cannot be reused.
let httpRequest = http.createHttp();
-
-// Subscribe to the HTTP response header, which is returned earlier than HttpRequest. You can subscribe to HTTP Response Header events based on service requirements.
-// on('headerReceive', AsyncCallback) will be replaced by on('headersReceive', Callback) in API version 8. 8+
+// This API is used to listen for the HTTP Response Header event, which is returned earlier than the result of the HTTP request. It is up to you whether to listen for HTTP Response Header events.
+// on('headerReceive', AsyncCallback) is replaced by on('headersReceive', Callback) since API version 8.
httpRequest.on('headersReceive', (header) => {
console.info('header: ' + JSON.stringify(header));
});
-
httpRequest.request(
- // Set the URL of the HTTP request. You need to define the URL. Set the parameters of the request in extraData.
+ // Customize EXAMPLE_URL in extraData on your own. It is up to you whether to add parameters to the URL.
"EXAMPLE_URL",
{
method: http.RequestMethod.POST, // Optional. The default value is http.RequestMethod.GET.
- // You can add the header field based on service requirements.
+ // You can add header fields based on service requirements.
header: {
'Content-Type': 'application/json'
},
@@ -55,21 +64,105 @@ httpRequest.request(
extraData: {
"data": "data to send",
},
- connectTimeout: 60000, // Optional. The default value is 60000, in ms.
+ expectDataType: http.HttpDataType.STRING, // Optional. This field specifies the type of the return data.
+ usingCache: true, // Optional. The default value is true.
+ priority: 1, // Optional. The default value is 1.
+ connectTimeout: 60000 // Optional. The default value is 60000, in ms.
readTimeout: 60000, // Optional. The default value is 60000, in ms.
+ usingProtocol: http.HttpProtocol.HTTP1_1, // Optional. The default protocol type is automatically specified by the system.
+ usingProxy: false, // Optional. By default, network proxy is not used. This field is supported since API 10.
}, (err, data) => {
if (!err) {
- // data.result contains the HTTP response. Parse the response based on service requirements.
- console.info('Result:' + data.result);
- console.info('code:' + data.responseCode);
- // data.header contains the HTTP response header. Parse the content based on service requirements.
+ // data.result carries the HTTP response. Parse the response based on service requirements.
+ console.info('Result:' + JSON.stringify(data.result));
+ console.info('code:' + JSON.stringify(data.responseCode));
+ // data.header carries the HTTP response header. Parse the content based on service requirements.
console.info('header:' + JSON.stringify(data.header));
- console.info('cookies:' + data.cookies); // 8+
+ console.info('cookies:' + JSON.stringify(data.cookies)); // 8+
} else {
console.info('error:' + JSON.stringify(err));
- // Call the destroy() method to destroy the request if it is no longer needed.
+ // Unsubscribe from HTTP Response Header events.
+ httpRequest.off('headersReceive');
+ // Call the destroy() method to release resources after HttpRequest is complete.
httpRequest.destroy();
}
}
);
```
+
+## How to Develop request2 APIs
+
+1. Import the **http** namespace from **@ohos.net.http.d.ts**.
+2. Call **createHttp()** to create an **HttpRequest** object.
+3. Depending on your need, call **on()** of the **HttpRequest** object to subscribe to HTTP response header events as well as events indicating receiving of HTTP streaming responses, progress of receiving HTTP streaming responses, and completion of receiving HTTP streaming responses.
+4. Call **request2()** to initiate a network request. You need to pass in the URL and optional parameters of the HTTP request.
+5. Parse the returned response code as needed.
+6. Call **off()** of the **HttpRequest** object to unsubscribe from the related events.
+7. Call **httpRequest.destroy()** to release resources after the request is processed.
+
+```js
+// Import the http namespace.
+import http from '@ohos.net.http'
+
+// Each httpRequest corresponds to an HTTP request task and cannot be reused.
+let httpRequest = http.createHttp();
+// Subscribe to HTTP response header events.
+httpRequest.on('headersReceive', (header) => {
+ console.info('header: ' + JSON.stringify(header));
+});
+// Subscribe to events indicating receiving of HTTP streaming responses.
+let res = '';
+httpRequest.on('dataReceive', (data) => {
+ res += data;
+ console.info('res: ' + res);
+});
+// Subscribe to events indicating completion of receiving HTTP streaming responses.
+httpRequest.on('dataEnd', () => {
+ console.info('No more data in response, data receive end');
+});
+// Subscribe to events indicating progress of receiving HTTP streaming responses.
+httpRequest.on('dataProgress', (data) => {
+ console.log("dataProgress receiveSize:" + data.receiveSize+ ", totalSize:" + data.totalSize);
+});
+
+httpRequest.request2(
+ // Customize EXAMPLE_URL in extraData on your own. It is up to you whether to add parameters to the URL.
+ "EXAMPLE_URL",
+ {
+ method: http.RequestMethod.POST, // Optional. The default value is http.RequestMethod.GET.
+ // You can add header fields based on service requirements.
+ header: {
+ 'Content-Type': 'application/json'
+ },
+ // This field is used to transfer data when the POST request is used.
+ extraData: {
+ "data": "data to send",
+ },
+ expectDataType: http.HttpDataType.STRING, // Optional. This field specifies the type of the return data.
+ usingCache: true, // Optional. The default value is true.
+ priority: 1, // Optional. The default value is 1.
+ connectTimeout: 60000 // Optional. The default value is 60000, in ms.
+ readTimeout: 60000, // Optional. The default value is 60000, in ms. If a large amount of data needs to be transmitted, you are advised to set this parameter to a larger value to ensure normal data transmission.
+ usingProtocol: http.HttpProtocol.HTTP1_1, // Optional. The default protocol type is automatically specified by the system.
+ }, (err, data) => {
+ console.info('error:' + JSON.stringify(err));
+ console.info('ResponseCode :' + JSON.stringify(data));
+ // Unsubscribe from HTTP Response Header events.
+ httpRequest.off('headersReceive');
+ // Unregister the observer for events indicating receiving of HTTP streaming responses.
+ httpRequest.off('dataReceive');
+ // Unregister the observer for events indicating progress of receiving HTTP streaming responses.
+ httpRequest.off('dataProgress');
+ // Unregister the observer for events indicating completion of receiving HTTP streaming responses.
+ httpRequest.off('dataEnd');
+ // Call the destroy() method to release resources after HttpRequest is complete.
+ httpRequest.destroy();
+ }
+);
+
+```
+
+## Samples
+The following sample is provided to help you better understand how to develop the HTTP data request feature:
+- [HTTP Data Request (ArkTS) (API9)](https://gitee.com/openharmony/applications_app_samples/tree/master/code/BasicFeature/Connectivity/Http)
+- [HTTP Communication (ArkTS) (API9)](https://gitee.com/openharmony/codelabs/tree/master/NetworkManagement/SmartChatEtsOH)
diff --git a/en/application-dev/connectivity/ipc-rpc-development-guideline.md b/en/application-dev/connectivity/ipc-rpc-development-guideline.md
index 5512d7a016754c94174fe269d5ed58424a218fb6..89bff0d4a168c74309f6bc711a3725fd4c9aad1b 100644
--- a/en/application-dev/connectivity/ipc-rpc-development-guideline.md
+++ b/en/application-dev/connectivity/ipc-rpc-development-guideline.md
@@ -1,4 +1,4 @@
-# IPC & RPC Development Guidelines
+# IPC & RPC Development
## When to Use
diff --git a/en/application-dev/connectivity/net-sharing.md b/en/application-dev/connectivity/net-sharing.md
index d81e8f59ecfb538ececb78afc83941d52f330eda..d5bc9cf2f8817723f0f23d666c45997a6735f706 100644
--- a/en/application-dev/connectivity/net-sharing.md
+++ b/en/application-dev/connectivity/net-sharing.md
@@ -63,7 +63,7 @@ For the complete list of APIs and example code, see [Network Sharing](../referen
});
// Call startSharing to start network sharing of the specified type.
- sharing.startSharing(SharingIfaceType.SHARING_WIFI, (error) => {
+ sharing.startSharing(sharing.SharingIfaceType.SHARING_WIFI, (error) => {
console.log(JSON.stringify(error));
});
```
@@ -88,7 +88,7 @@ For the complete list of APIs and example code, see [Network Sharing](../referen
});
// Call stopSharing to stop network sharing of the specified type.
- sharing.stopSharing(SharingIfaceType.SHARING_WIFI, (error) => {
+ sharing.stopSharing(sharing.SharingIfaceType.SHARING_WIFI, (error) => {
console.log(JSON.stringify(error));
});
```
@@ -107,7 +107,7 @@ For the complete list of APIs and example code, see [Network Sharing](../referen
import sharing from '@ohos.net.sharing'
// Call startSharing to start network sharing of the specified type.
- sharing.startSharing(SharingIfaceType.SHARING_WIFI, (error) => {
+ sharing.startSharing(sharing.SharingIfaceType.SHARING_WIFI, (error) => {
console.log(JSON.stringify(error));
});
@@ -118,7 +118,7 @@ For the complete list of APIs and example code, see [Network Sharing](../referen
});
// Call stopSharing to stop network sharing of the specified type and clear the data volume of network sharing.
- sharing.stopSharing(SharingIfaceType.SHARING_WIFI, (error) => {
+ sharing.stopSharing(sharing.SharingIfaceType.SHARING_WIFI, (error) => {
console.log(JSON.stringify(error));
});
diff --git a/en/application-dev/connectivity/socket-connection.md b/en/application-dev/connectivity/socket-connection.md
index 96c802d565d0e58201b627d18be1e59093919a07..5cae73b2a5c84f280aea80e299605ee80ac2553a 100644
--- a/en/application-dev/connectivity/socket-connection.md
+++ b/en/application-dev/connectivity/socket-connection.md
@@ -49,6 +49,7 @@ TLS Socket connection functions are mainly provided by the **tls_socket** module
| API| Description|
| -------- | -------- |
+| constructTLSSocketInstance() | Creates a **TLSSocket** object.|
| bind() | Binds the IP address and port number.|
| close(type: 'error') | Closes a Socket connection.|
| connect() | Sets up a connection to the specified IP address and port number.|
@@ -189,7 +190,7 @@ TLS Socket connection process on the client:
let tlsTwoWay = socket.constructTLSSocketInstance();
// Subscribe to TLS Socket connection events.
- tcp.on('message', value => {
+ tlsTwoWay.on('message', value => {
console.log("on message")
let buffer = value.message
let dataView = new DataView(buffer)
@@ -199,10 +200,10 @@ TLS Socket connection process on the client:
}
console.log("on connect received:" + str)
});
- tcp.on('connect', () => {
+ tlsTwoWay.on('connect', () => {
console.log("on connect")
});
- tcp.on('close', () => {
+ tlsTwoWay.on('close', () => {
console.log("on close")
});
@@ -245,23 +246,23 @@ TLS Socket connection process on the client:
console.log(data);
});
- // Enable the TLS Socket connection to be automatically closed after use. Then, disable listening for TLS Socket connection events.
- tls.close((err) => {
+ // Enable the TCP Socket connection to be automatically closed after use. Then, disable listening for TCP Socket connection events.
+ tlsTwoWay.close((err) => {
if (err) {
console.log("close callback error = " + err);
} else {
console.log("close success");
}
- tls.off('message');
- tls.off('connect');
- tls.off('close');
+ tlsTwoWay.off('message');
+ tlsTwoWay.off('connect');
+ tlsTwoWay.off('close');
});
// Create a TLS Socket connection (for one-way authentication).
let tlsOneWay = socket.constructTLSSocketInstance(); // One way authentication
// Subscribe to TLS Socket connection events.
- tcp.on('message', value => {
+ tlsTwoWay.on('message', value => {
console.log("on message")
let buffer = value.message
let dataView = new DataView(buffer)
@@ -271,10 +272,10 @@ TLS Socket connection process on the client:
}
console.log("on connect received:" + str)
});
- tcp.on('connect', () => {
+ tlsTwoWay.on('connect', () => {
console.log("on connect")
});
- tcp.on('close', () => {
+ tlsTwoWay.on('close', () => {
console.log("on close")
});
@@ -306,22 +307,15 @@ TLS Socket connection process on the client:
console.log(data);
});
- // Enable the TLS Socket connection to be automatically closed after use. Then, disable listening for TLS Socket connection events.
- tls.close((err) => {
+ // Enable the TCP Socket connection to be automatically closed after use. Then, disable listening for TCP Socket connection events.
+ tlsTwoWay.close((err) => {
if (err) {
console.log("close callback error = " + err);
} else {
console.log("close success");
}
- tls.off('message');
- tls.off('connect');
- tls.off('close');
+ tlsTwoWay.off('message');
+ tlsTwoWay.off('connect');
+ tlsTwoWay.off('close');
});
```
-
-## Samples
-
-The following samples are provided to help you better understand how to develop Socket connection features:
-- [`Socket`: Socket Connection (ArkTS) (API9)](https://gitee.com/openharmony/applications_app_samples/tree/master/Network/Socket)
-- [UDP Socket (ArkTS) (API9)](https://gitee.com/openharmony/codelabs/tree/master/NetworkManagement/UdpDemoOH)
-- [TCP Socket (ArkTS) (API9)](https://gitee.com/openharmony/codelabs/tree/master/NetworkManagement/TcpSocketDemo)
diff --git a/en/application-dev/database/database-datashare-guidelines.md b/en/application-dev/database/database-datashare-guidelines.md
index 1f25dccf2a36f3bbedb5728291e8e11b3292476e..580811158051b5b6d5d2137f4b14654a46e891b9 100644
--- a/en/application-dev/database/database-datashare-guidelines.md
+++ b/en/application-dev/database/database-datashare-guidelines.md
@@ -34,7 +34,7 @@ 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**.
-### Data Provider Application Development (Only for System Applications)
+### Data Provider Application Development (for System Applications Only)
[DataShareExtensionAbility](../reference/apis/js-apis-application-dataShareExtensionAbility.md) provides the following APIs. You can override these APIs as required.
diff --git a/en/application-dev/database/database-mdds-guidelines.md b/en/application-dev/database/database-mdds-guidelines.md
index 70c0ee209975ff3322210041e123afbeec3b5e6f..b84b668ce377b03561f7f7fdd3cdd6eb5fb0d796 100644
--- a/en/application-dev/database/database-mdds-guidelines.md
+++ b/en/application-dev/database/database-mdds-guidelines.md
@@ -169,7 +169,7 @@ The following uses a single KV store as an example to describe the development p
console.log(`dataChange callback call data: ${data}`);
});
}catch(e){
- console.error(`An unexpected error occured. Code is ${e.code}, message is ${e.message}`);
+ console.error(`An unexpected error occurred. Code is ${e.code}, message is ${e.message}`);
}
```
diff --git a/en/application-dev/device/pointerstyle-guidelines.md b/en/application-dev/device/pointerstyle-guidelines.md
index cecab92b282e2da7a3bb966bcedeefa84768f22e..bcc09093eed4440a0c5e62c5d4cfe37a3f954c87 100644
--- a/en/application-dev/device/pointerstyle-guidelines.md
+++ b/en/application-dev/device/pointerstyle-guidelines.md
@@ -15,11 +15,11 @@ import pointer from '@ohos.multimodalInput.pointer';
The following table lists the common APIs for mouse pointer management. For details about the APIs, see [ohos.multimodalInput.pointer](../reference/apis/js-apis-pointer.md).
| Instance | API | Description |
-| ------- | ------------------------------------------------------------ | --------------------------------------------------------------- |
-| pointer | function isPointerVisible(callback: AsyncCallback\): void; | Checks the visible status of the mouse pointer. |
-| pointer | function setPointerVisible(visible: boolean, callback: AsyncCallback\): void; | Sets the visible status of the mouse pointer. This setting takes effect for the mouse pointer globally. |
+| ------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
+| pointer | function isPointerVisible(callback: AsyncCallback\): void; | Checks the visible status of the mouse pointer. |
+| pointer | function setPointerVisible(visible: boolean, callback: AsyncCallback\): void; | Sets the visible status of the mouse pointer. This setting takes effect for the mouse pointer globally.|
| pointer | function setPointerStyle(windowId: number, pointerStyle: PointerStyle, callback: AsyncCallback\): void; | Sets the mouse pointer style. This setting takes effect for the mouse pointer style of a specified window. |
-| pointer | function getPointerStyle(windowId: number, callback: AsyncCallback\): void; | Obtains the mouse pointer style. |
+| pointer | function getPointerStyle(windowId: number, callback: AsyncCallback\): void; | Obtains the mouse pointer style. |
## Hiding the Mouse Pointer
@@ -77,43 +77,48 @@ When designing a color picker, you can have the mouse pointer switched to the co
5. Set the mouse pointer to the default style.
```js
+import pointer from '@ohos.multimodalInput.pointer';
import window from '@ohos.window';
// 1. Enable the color pickup function.
// 2. Obtain the window ID.
-window.getTopWindow((error, windowClass) => {
- windowClass.getProperties((error, data) => {
- var windowId = data.id;
- if (windowId < 0) {
- console.log(`Invalid windowId`);
- return;
- }
- try {
- // 3. Set the mouse pointer to the color picker style.
- pointer.setPointerStyle(windowId, pointer.PointerStyle.COLOR_SUCKER).then(() => {
- console.log(`Successfully set mouse pointer style`);
- });
- } catch (error) {
- console.log(`Failed to set the pointer style, error=${JSON.stringify(error)}, msg=${JSON.stringify(message)}`);
- }
- });
+window.getLastWindow(this.context, (error, windowClass) => {
+ if (error.code) {
+ console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(error));
+ return;
+ }
+ var windowId = windowClass.getWindowProperties().id;
+ if (windowId < 0) {
+ console.log(`Invalid windowId`);
+ return;
+ }
+ try {
+ // 3. Set the mouse pointer to the color picker style.
+ pointer.setPointerStyle(windowId, pointer.PointerStyle.COLOR_SUCKER).then(() => {
+ console.log(`Successfully set mouse pointer style`);
+ });
+ } catch (error) {
+ console.log(`Failed to set the pointer style, error=${JSON.stringify(error)}, msg=${JSON.stringify(`message`)}`);
+ }
});
// 4. End color pickup.
-window.getTopWindow((error, windowClass) => {
- windowClass.getProperties((error, data) => {
- var windowId = data.id;
- if (windowId < 0) {
- console.log(`Invalid windowId`);
- return;
- }
- try {
- // 5. Set the mouse pointer to the default style.
- pointer.setPointerStyle(windowId, pointer.PointerStyle.DEFAULT).then(() => {
- console.log(`Successfully set mouse pointer style`);
- });
- } catch (error) {
- console.log(`Failed to set the pointer style, error=${JSON.stringify(error)}, msg=${JSON.stringify(message)}`);
- }
- });
+window.getLastWindow(this.context, (error, windowClass) => {
+ if (error.code) {
+ console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(error));
+ return;
+ }
+ var windowId = windowClass.getWindowProperties().id;
+ if (windowId < 0) {
+ console.log(`Invalid windowId`);
+ return;
+ }
+ try {
+ // 5. Set the mouse pointer to the default style.
+ pointer.setPointerStyle(windowId, pointer.PointerStyle.DEFAULT).then(() => {
+ console.log(`Successfully set mouse pointer style`);
+ });
+ } catch (error) {
+ console.log(`Failed to set the pointer style, error=${JSON.stringify(error)}, msg=${JSON.stringify(`message`)}`);
+ }
});
```
diff --git a/en/application-dev/device/usb-guidelines.md b/en/application-dev/device/usb-guidelines.md
index c4f5131536a1f0b55ae973bdf7cdf04d2b8f0980..68c8c3de013e75d56854bf0cf0e3a71aca9eb261 100644
--- a/en/application-dev/device/usb-guidelines.md
+++ b/en/application-dev/device/usb-guidelines.md
@@ -130,8 +130,6 @@ You can set a USB device as the USB host to connect to other USB devices for dat
usb.bulkTransfer(pipe, inEndpoint, dataUint8Array, 15000).then(dataLength => {
if (dataLength >= 0) {
console.info("usb readData result Length : " + dataLength);
- let resultStr = this.ab2str(dataUint8Array); // Convert uint8 data into a string.
- console.info("usb readData buffer : " + resultStr);
} else {
console.info("usb readData failed : " + dataLength);
}
diff --git a/en/application-dev/dfx/apprecovery-guidelines.md b/en/application-dev/dfx/apprecovery-guidelines.md
index 67176a77ff4cacda15de76a3390275f59f3a6aa4..cf31f6ae4c18f0de1e850cad5cb34be2122bc0d0 100644
--- a/en/application-dev/dfx/apprecovery-guidelines.md
+++ b/en/application-dev/dfx/apprecovery-guidelines.md
@@ -1,62 +1,80 @@
-# Development of Application Recovery
+# Application Recovery Development
## When to Use
-During application running, some unexpected behaviors are inevitable. For example, unprocessed exceptions and errors are thrown, and the call or running constraints of the framework are violated.
+During application running, some unexpected behaviors are inevitable. For example, unprocessed exceptions and errors are thrown, and the call or running constraints of the recovery framework are violated.
-By default, the processes will exit as exception handling. However, if user data is generated during application use, process exits may interrupt user operations and cause data loss.
-In this way, application recovery APIs may help you save temporary data, restart an application after it exits, and restore its status and data, which deliver a better user experience.
+Process exit is treated as the default exception handling method. However, if user data is generated during application use, process exit may interrupt user operations and cause data loss.
+Application recovery helps to restore the application state and save temporary data upon next startup in the case of an abnormal process exit, thus providing more consistent user experience. The application state includes two parts, namely, the page stack of the and the data saved in **onSaveState**.
-Currently, the APIs support only the development of an application that adopts the stage model, single process, and single ability.
+In API version 9, application recovery is supported only for a single ability of the application developed using the stage model. Application state saving and automatic restart are performed when a JsError occurs.
+
+In API version 10, application recovery is also supported for multiple abilities of the application developed using the stage model. Application state storage and restore are performed when an AppFreeze occurs. If an application is killed in control mode, the application state will be restored upon next startup.
## Available APIs
-The application recovery APIs are provided by the **appRecovery** module, which can be imported via **import**. For details, please refer to [Development Example](#development-example). This document describes behaviors of APIs in API version 9, and the content will update with changes.
+The application recovery APIs are provided by the **appRecovery** module, which can be imported via **import**. For details, see [Development Example](#development-example).
### Available APIs
-| API | Description |
-| ------------------------------------------------------------ | ------------------------------------------------------------ |
-| enableAppRecovery(restart?: RestartFlag, saveOccasion?: SaveOccasionFlag, saveMode?: SaveModeFlag) : void; | Enables the application recovery function. |
-| saveAppState(): boolean; | Saves the ability status of an application. |
-| restartApp(): void; | Restarts the current process. If there is saved ability status, it will be passed to the **want** parameter's **wantParam** attribute of the **onCreate** lifecycle callback of the ability.|
+| API | Description |
+| ------------------------------------------------------------ | ---------------------------------------------------- |
+| enableAppRecovery(restart?: RestartFlag, saveOccasion?: SaveOccasionFlag, saveMode?: SaveModeFlag) : void;9+ | Enables application recovery. After this API is called, the first ability that is displayed when the application is started from the initiator can be restored.|
+| saveAppState(): boolean;9+ | Saves the state of the ability that supports recovery in the current application.|
+| restartApp(): void;9+ | Restarts the current process and starts the ability specified by **setRestartWant**. If no ability is specified, a foreground ability that supports recovery is restarted.|
+| saveAppState(context?: UIAbilityContext): boolean;10+ | Saves the ability state specified by **Context**.|
+| setRestartWant(want: Want): void;10+ | Sets the abilities to restart when **restartApp** is actively called and **RestartFlag** is not **NO_RESTART**. The abilities must be under the same bundle name and must be a **UiAbility**.|
+
+No error will be thrown if the preceding APIs are used in the troubleshooting scenario. The following are some notes on API usage:
+
+**enableAppRecovery**: This API should be called during application initialization. For example, you can call this API in **onCreate** of **AbilityStage**. For details, see [Parameter Description](../reference/apis/js-apis-app-ability-appRecovery.md).
+
+**saveAppState**: After this API is called, the recovery framework invokes **onSaveState** for all abilities that support recovery in the current process. If you choose to save data in **onSaveState**, the related data and ability page stack are persistently stored in the local cache of the application. To save data of the specified ability, you need to specify the context corresponding to that ability.
+
+**setRestartWant**: This API specifies the ability to be restarted by **appRecovery**.
-The APIs are used for troubleshooting and do not return any exception. Therefore, you need to be familiar with when they are used.
+**restartApp**: After this API is called, the recovery framework kills the current process and restarts the ability specified by **setRestartWant**, with **APP_RECOVERY** set as the startup cause. In API version 9 and scenarios where an ability is not specified by **setRestartWant**, the last foreground ability that supports recovery is started. If the no foreground ability supports recovery, the application crashes. If a saved state is available for the restarted ability, the saved state is passed as the **wantParam** attribute in the **want** parameter of the ability's **onCreate** callback.
-**enableAppRecovery**: This API should be called during application initialization. For example, you can call this API in **onCreate** of **AbilityStage**. For details, please refer to the [parameter description](../reference/apis/js-apis-app-ability-appRecovery.md).
+### Application State Management
+Since API version 10, application recovery is not limited to automatic restart in the case of an exception. Therefore, you need to understand when the application will load the saved state.
+If the last exit of an application is not initiated by a user and a saved state is available for recovery, the startup reason is set to **APP_RECOVERY** when the application is started by the user next time, and the recovery state of the application is cleared.
+The application recovery status flag is set when **saveAppState** is actively or passively called. The flag is cleared when the application exits normally or the saved state is consumed. (A normal exit is usually triggered by pressing the back key or clearing recent tasks.)
-**saveAppState**: After this API is called, the framework calls back **onSaveState** of the ability. If data saving is agreed to in this method, relevant data and the page stack of the ability are persisted to the local cache of the application.
+
-**restartApp**: After this API is called, the framework kills the current application process and restarts the ability in the foreground, with **APP_RECOVERY** specified as the startup cause.
+### Application State Saving and Restore
+API version 10 or later supports saving of the application state when an application is suspended. If a JsError occurs, **onSaveState** is called in the main thread. If an AppFreeze occurs, however, the main thread may be suspended, and therefore **onSaveState** is called in a non-main thread. The following figure shows the main service flow.
-### Framework Fault Management Process
+
+When the application is suspended, the callback is not executed in the JS thread. Therefore, you are advised not to use the imported dynamic Native library or access the **thread_local** object created by the main thread in the code of the **onSaveState** callback.
+
+### Framework Fault Management
Fault management is an important way for applications to deliver a better user experience. The application framework offers three methods for application fault management: fault listening, fault rectification, and fault query.
-- Fault listening refers to the process of registering [ErrorObserver](../reference/apis/js-apis-application-errorManager.md#errorobserver) via [errorManager](../reference/apis/js-apis-application-errorManager.md), listening for fault occurrence, and notifying the fault listener.
+- Fault listening refers to the process of registering an [ErrorObserver](../reference/apis/js-apis-inner-application-errorObserver.md) via [errorManager](../reference/apis/js-apis-app-ability-errorManager.md), listening for faults, and notifying the listener of the faults.
-- Fault rectification refers to [appRecovery](../reference/apis/js-apis-app-ability-appRecovery.md) and restarts an application to restore its status previous to a fault.
+- Fault rectification refers to the process of restoring the application state and data through [appRecovery](../reference/apis/js-apis-app-ability-appRecovery.md).
-- Fault query indicates that [faultLogger](../reference/apis/js-apis-faultLogger.md) obtains the fault information using its query API.
+- Fault query is the process of calling APIs of [faultLogger](../reference/apis/js-apis-faultLogger.md) to obtain the fault information.
-The figure below does not illustrate the time when [faultLogger](../reference/apis/js-apis-faultLogger.md) is called. You can refer to [LastExitReason](../reference/apis/js-apis-app-ability-abilityConstant.md#abilityconstantlastexitreason) passed during application initialization to determine whether to call [faultLogger](../reference/apis/js-apis-faultLogger.md) to query the information about the last fault.
+The figure below does not illustrate the time when [faultLogger](../reference/apis/js-apis-faultLogger.md) is called. You can refer to the [LastExitReason](../reference/apis/js-apis-app-ability-abilityConstant.md#abilityconstantlastexitreason) passed during application initialization to determine whether to call [faultLogger](../reference/apis/js-apis-faultLogger.md) to query information about the previous fault.

+It is recommended that you call [errorManager](../reference/apis/js-apis-app-ability-errorManager.md) to handle the exception. After the processing is complete, you can call the **saveAppState** API and restart the application.
+If you do not register [ErrorObserver](../reference/apis/js-apis-inner-application-errorObserver.md) or enable application recovery, the application process will exit according to the default processing logic of the system. Users can restart the application from the home screen.
+If you have enabled application recovery, the recovery framework first checks whether application state saving is supported and whether the application state saving is enabled. If so, the recovery framework invokes [onSaveState](../reference/apis/js-apis-app-ability-uiAbility.md#uiabilityonsavestate) of the [Ability](../reference/apis/js-apis-app-ability-uiAbility.md). Finally, the application is restarted.
-It is recommended that you call [errorManager](../reference/apis/js-apis-application-errorManager.md) to process the exception. After the processing is complete, you can call the status saving API and restart the application.
-If you do not register [ErrorObserver](../reference/apis/js-apis-application-errorManager.md#errorobserver) or enable application recovery, the application process will exit according to the default processing logic of the system. Users can restart the application from the home screen.
-If you have enabled application recovery, the framework first checks whether a fault allows for ability status saving and whether you have configured ability status saving. If so, [onSaveState](../reference/apis/js-apis-application-ability.md#abilityonsavestate) of [Ability](../reference/apis/js-apis-application-ability.md#ability) is called back. Finally, the application is restarted.
-
-### Scenarios Supported by Application Fault Management APIs
+### Supported Application Recovery Scenarios
Common fault types include JavaScript application crash, application freezing, and C++ application crash. Generally, an application is closed when a crash occurs. Application freezing occurs when the application does not respond. The fault type can be ignored for the upper layer of an application. The recovery framework implements fault management in different scenarios based on the fault type.
-| Fault | Fault Listening| Status Saving| Automatic Restart| Log Query|
-| ------------------------------------------------------------ | -------- | -------- | -------- | -------- |
-| [JS_CRASH](../reference/apis/js-apis-faultLogger.md#faulttype) | Supported | Supported | Supported | Supported |
-| [APP_FREEZE](../reference/apis/js-apis-faultLogger.md#faulttype) | Not supported | Not supported | Supported | Supported |
-| [CPP_CRASH](../reference/apis/js-apis-faultLogger.md#faulttype) | Not supported | Not supported | Not supported | Supported |
+| Fault | Fault Listening | State Saving| Automatic Restart| Log Query|
+| ----------|--------- |--------- |--------- |--------- |
+| [JS_CRASH](../reference/apis/js-apis-faultLogger.md#faulttype) | Supported|Supported|Supported|Supported|
+| [APP_FREEZE](../reference/apis/js-apis-faultLogger.md#faulttype) | Not supported|Supported|Supported|Supported|
+| [CPP_CRASH](../reference/apis/js-apis-faultLogger.md#faulttype) | Not supported|Not supported|Not supported|Supported|
-**Status Saving** in the table header means status saving when a fault occurs. To protect user data as much as possible in the application freezing fault, you can adopt either the periodic or automatic way, and the latter will save user data when an ability is switched to the background.
+**State Saving** in the table header means saving of the application state when a fault occurs. To protect user data as much as possible when an AppFreeze occurs, you can adopt either the periodic or automatic way, and the latter will save user data when an ability is switched to the background.
@@ -78,11 +96,23 @@ export default class MyAbilityStage extends AbilityStage {
appRecovery.SaveModeFlag.SAVE_WITH_FILE);
}
}
+```
+### Enabling Application Recovery for the Specified Abilities
+Generally, the ability configuration list is named **module.json5**.
+```json
+{
+ "abilities": [
+ {
+ "name": "EntryAbility",
+ "recoverable": true,
+ }]
+}
+
```
### Saving and Restoring Data
-After enabling **appRecovery**, you can use this function by either actively or passively saving the status and restoring data in the ability.
+After enabling **appRecovery**, you can use this function by either actively or passively saving the application state and restoring data in the ability.
The following is an example of **EntryAbility**:
#### Importing the Service Package
@@ -93,9 +123,9 @@ import appRecovery from '@ohos.app.ability.appRecovery';
import AbilityConstant from '@ohos.app.ability.AbilityConstant';
```
-#### Actively Saving Status and Restoring Data
+#### Actively Saving the Application State and Restoring Data
-- Define and register the [ErrorObserver](../reference/apis/js-apis-application-errorManager.md#errorobserver) callback.
+- Define and register the [ErrorObserver](../reference/apis/js-apis-inner-application-errorObserver.md) callback.
```ts
var registerId = -1;
@@ -108,7 +138,7 @@ import AbilityConstant from '@ohos.app.ability.AbilityConstant';
}
onWindowStageCreate(windowStage) {
- // Main window is created. Set a main page for this ability.
+ // Main window is created, set main page for this ability
console.log("[Demo] EntryAbility onWindowStageCreate")
globalThis.registerObserver = (() => {
@@ -125,7 +155,7 @@ After the callback triggers **appRecovery.saveAppState()**, **onSaveState(state,
```ts
onSaveState(state, wantParams) {
- // Save application data.
+ // Ability has called to save app data
console.log("[Demo] EntryAbility onSaveState")
wantParams["myData"] = "my1234567";
return AbilityConstant.onSaveResult.ALL_AGREE;
@@ -134,7 +164,7 @@ After the callback triggers **appRecovery.saveAppState()**, **onSaveState(state,
- Restore data.
-After the callback triggers **appRecovery.restartApp()**, the application is restarted. After the restart, **onCreate(want, launchParam)** of **EntryAbility** is called, and the saved data is in **parameters** of **want**.
+After the callback triggers **appRecovery.restartApp()**, the application is restarted. After the restart, **onCreate(want, launchParam)** of **EntryAbility** is called, and the saved data is stored in **parameters** of **want**.
```ts
storage: LocalStorage
@@ -150,11 +180,11 @@ onCreate(want, launchParam) {
}
```
-- Deregister **ErrorObserver callback**.
+- Unregister the **ErrorObserver** callback.
```ts
onWindowStageDestroy() {
- // Main window is destroyed to release UI resources.
+ // Main window is destroyed, release UI related resources
console.log("[Demo] EntryAbility onWindowStageDestroy")
globalThis.unRegisterObserver = (() => {
@@ -165,9 +195,9 @@ onWindowStageDestroy() {
}
```
-#### Passively Saving Status and Restoring Data
+#### Passively Saving the Application State and Restoring Data
-This is triggered by the recovery framework. You do not need to register **ErrorObserver callback**. You only need to implement **onSaveState** of the ability for status saving and **onCreate** of the ability for data restoration.
+This is triggered by the recovery framework. You do not need to register an **ErrorObserver** callback. You only need to implement **onSaveState** for application state saving and **onCreate** for data restore.
```ts
export default class EntryAbility extends Ability {
@@ -184,7 +214,7 @@ export default class EntryAbility extends Ability {
}
onSaveState(state, wantParams) {
- // Save application data.
+ // Ability has called to save app data
console.log("[Demo] EntryAbility onSaveState")
wantParams["myData"] = "my1234567";
return AbilityConstant.onSaveResult.ALL_AGREE;
diff --git a/en/application-dev/dfx/figures/application_recovery_from_freezing.png b/en/application-dev/dfx/figures/application_recovery_from_freezing.png
new file mode 100644
index 0000000000000000000000000000000000000000..968b4cefc5e898209cdae117c7f9f667bc9fbd64
Binary files /dev/null and b/en/application-dev/dfx/figures/application_recovery_from_freezing.png differ
diff --git a/en/application-dev/dfx/figures/application_recovery_status_management.png b/en/application-dev/dfx/figures/application_recovery_status_management.png
new file mode 100644
index 0000000000000000000000000000000000000000..762504c1d1027be87233e589988be2091640191b
Binary files /dev/null and b/en/application-dev/dfx/figures/application_recovery_status_management.png differ
diff --git a/en/application-dev/dfx/figures/fault_rectification.png b/en/application-dev/dfx/figures/fault_rectification.png
index 67aa40592f7bcad23e216222e898c1f1327a4efb..a178b2691616d406d2668806ffcd4f89c8ca82a3 100644
Binary files a/en/application-dev/dfx/figures/fault_rectification.png and b/en/application-dev/dfx/figures/fault_rectification.png differ
diff --git a/en/application-dev/dfx/hiappevent-guidelines.md b/en/application-dev/dfx/hiappevent-guidelines.md
index 9991e10c731d9130a7c1f52154e18ac19bce336d..640b9185ee236dbe0fb5dfe3808b14322a401a23 100644
--- a/en/application-dev/dfx/hiappevent-guidelines.md
+++ b/en/application-dev/dfx/hiappevent-guidelines.md
@@ -45,7 +45,7 @@ The following table provides only a brief description of related APIs. For detai
The following example illustrates how to log and subscribe to button click events of users.
-1. Create an eTS application project. In the displayed **Project** window, choose **entry** > **src** > **main** > **ets** > **entryability** > **EntryAbility.ts**, and double-click **EntryAbility.ts**. Then, add an event watcher to subscribe to button click events. The complete sample code is as follows:
+1. Create an ArkTS application project. In the displayed **Project** window, choose **entry** > **src** > **main** > **ets** > **entryability** > **EntryAbility.ts**, and double-click **EntryAbility.ts**. Then, add an event watcher to subscribe to button click events. The complete sample code is as follows:
```js
import hilog from '@ohos.hilog';
diff --git a/en/application-dev/faqs/Readme-EN.md b/en/application-dev/faqs/Readme-EN.md
index 7eb9cad6b546996a47e92cd01b03f783a1f4a6d2..63535a32ae16eca13b03d20b4bce93569e2fe1d0 100644
--- a/en/application-dev/faqs/Readme-EN.md
+++ b/en/application-dev/faqs/Readme-EN.md
@@ -18,5 +18,4 @@
- [Native API Usage](faqs-native.md)
- [Usage of Third- and Fourth-Party Libraries](faqs-third-party-library.md)
- [IDE Usage](faqs-ide.md)
-- [hdc_std Command Usage](faqs-hdc-std.md)
- [Development Board](faqs-development-board.md)
\ No newline at end of file
diff --git a/en/application-dev/faqs/faqs-device-management.md b/en/application-dev/faqs/faqs-device-management.md
index dd836eb11abfbee3979f5a604eb5aa734d0d9112..ea71edd6c9940437e197be35e60a6638c73ae88d 100644
--- a/en/application-dev/faqs/faqs-device-management.md
+++ b/en/application-dev/faqs/faqs-device-management.md
@@ -2,23 +2,21 @@
## 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.
+Applicable to: OpenHarmony 3.2 Beta5, stage model of API version 9
-Example:
+Import the **@ohos.display** module and call the **getDefaultDisplaySync** 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));
-});
+let displayClass = null;
+try {
+ displayClass = display.getDefaultDisplaySync();
+ console.info('Test densityDPI:' + JSON.stringify(data.densityDPI));
+} catch (exception) {
+ console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
+}
```
## How do I obtain the type of the device where the application is running?
diff --git a/en/application-dev/faqs/faqs-hdc-std.md b/en/application-dev/faqs/faqs-hdc-std.md
deleted file mode 100644
index 60f93da61d7d78a4e148b65c0e30d379b1e1206d..0000000000000000000000000000000000000000
--- a/en/application-dev/faqs/faqs-hdc-std.md
+++ /dev/null
@@ -1,87 +0,0 @@
-# hdc_std Command Usage
-
-## Common Log Commands
-
-Applicable to: OpenHarmony SDK 3.2.2.5
-
-Clearing logs: hdc_std shell hilog -r
-
-Increasing the buffer size to 20 MB: hdc_std shell hilog -G 20M
-
-Capturing logs: hdc_std shell hilog > log.txt
-
-## What should I do to avoid log flow control?
-
-Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9
-
-- Disabling log flow control: hdc_std shell hilog -Q pidoff
-
-- Disabling the privacy flag: hdc_std shell hilog -p off
-
-- Increasing the log buffer to 200 MB: hdc_std shell hilog -G 200M
-
-- Enabling the log function of the specific domain (that is, disabling the global log function): hdc_std shell hilog –b D –D 0xd0xxxxx
-
-After performing the preceding operations, restart the DevEco Studio.
-
-## What should I do if the HAP installed on the development board through the IDE cannot be opened?
-
-Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9
-
-Check whether the SDK version is consistent with the system version on the development board. You are advised to use the SDK version and system version that are released on the same day.
-
-## How do I upload files using the hdc command?
-
-Applicable to: OpenHarmony SDK 3.2.2.5
-
-Run the **hdc_std file send** command.
-
-## How do I prevent the screen of the RK3568 development board from turning off?
-
-Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9
-
-Run the **hdc_std shell "power-shell setmode 602"** command.
-
-## How do I start an ability using the hdc command?
-
-Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9
-
-Run the **hdc\_std shell aa start -a AbilityName -b bundleName -m moduleName** command.
-
-## How do I change the read and write permissions on a file directory on the development board?
-
-Applicable to: OpenHarmony SDK 3.2.5.6, stage model of API version 9
-
-Run the **hdc\_std shell mount -o remount,rw /** command.
-
-## What should I do if the error message "Unknown file option -r" is displayed when hdc_std file recv is run?
-
-Applicable to: OpenHarmony SDK 3.2.5.6, stage model of API version 9
-
-1. Use the the hdc tool in the device image or SDK of the same version.
-
-2. Remove any Chinese characters or spaces from the directory specified for the hdc tool.
-
-## How do I uninstall an application using the hdc command?
-
-Applicable to: OpenHarmony SDK 3.2.2.5
-
-Run the **hdc\_std uninstall [-k] [package_name]** command.
-
-## How do I check whether the system is 32-bit or 64-bit?
-
-Applicable to: OpenHarmony SDK 3.2.5.5
-
-Run the **hdc\_std shell getconf LONG_BIT** command.
-
-If **64** is returned, the system is a 64-bit one. Otherwise, the system is a 32-bit one.
-
-## How do I view the component tree structure?
-
-Applicable to: OpenHarmony SDK 3.2.5.5
-
-1. Run the **hdc\_std shell** command to launch the CLI.
-
-2. Run the **aa dump -a** command to find **abilityID**.
-
-3. Run the **aa dump -i [abilityID] -c -render** command to view the component tree.
diff --git a/en/application-dev/file-management/medialibrary-resource-guidelines.md b/en/application-dev/file-management/medialibrary-resource-guidelines.md
index 054591847ffa156f5ee85cf5e2412b215750e283..b5691ad2e7505f0b1df617dd94c933b09de350e7 100644
--- a/en/application-dev/file-management/medialibrary-resource-guidelines.md
+++ b/en/application-dev/file-management/medialibrary-resource-guidelines.md
@@ -147,7 +147,7 @@ async function example() {
## Obtaining Images and Videos in an Album
You can obtain media assets in an album in either of the following ways:
-- Call [MediaLibrary.getFileAssets](../reference/apis/js-apis-medialibrary.md#getfileassets7-1) with an album specified, as described in [Querying Media Assets with the Specfied Album Name](#querying-media-assets-with-the-specified-album-name).
+- Call [MediaLibrary.getFileAssets](../reference/apis/js-apis-medialibrary.md#getfileassets7-1) with an album specified, as described in [Querying Media Assets with the Specified Album Name](#querying-media-assets-with-the-specified-album-name).
- Call [Album.getFileAssets](../reference/apis/js-apis-medialibrary.md#getfileassets7-3) to obtain an **Album** instance, so as to obtain the media assets in it.
**Prerequisites**
diff --git a/en/application-dev/internationalization/intl-guidelines.md b/en/application-dev/internationalization/intl-guidelines.md
index 7274514385795ec42b6e81924e34e71070a71ebf..fcac5325292b27f349f6c3dcadb627dca2dd0c03 100644
--- a/en/application-dev/internationalization/intl-guidelines.md
+++ b/en/application-dev/internationalization/intl-guidelines.md
@@ -2,7 +2,7 @@
The **intl** module provides basic i18n capabilities, such as time and date formatting, number formatting, and string sorting, through the standard i18n APIs defined in ECMA 402. For more details about APIs and their usage, see [intl](../reference/apis/js-apis-intl.md).
-The [I18N](i18n-guidelines.md) module provides enhanced I18N capabilities through supplementary interfaces that are not defined in ECMA 402. It works with the Intl module to provide a complete suite of I18N capabilities.
+The [i18n](../reference/apis/js-apis-i18n.md) module provides enhanced I18N capabilities through supplementary interfaces that are not defined in ECMA 402. It works with the Intl module to provide a complete suite of I18N capabilities.
## Setting Locale Information
@@ -111,7 +111,7 @@ The [I18N](i18n-guidelines.md) module provides enhanced I18N capabilities throug
let dateTimeFormat = new Intl.DateTimeFormat();
```
- Alternatively, use your own locale and formatting parameters to create a **DateTimeFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [DateTimeOptions](../reference/apis/js-apis-intl.md#datetimeoptions).
+ Alternatively, use your own locale and formatting parameters to create a **DateTimeFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [DateTimeOptions](../reference/apis/js-apis-intl.md#datetimeoptions9).
```js
let options = {dateStyle: "full", timeStyle: "full"};
@@ -150,7 +150,7 @@ The [I18N](i18n-guidelines.md) module provides enhanced I18N capabilities throug
let resolvedOptions = dateTimeFormat.resolvedOptions(); // resolvedOptions = {"locale": "zh-CN", "calendar": "gregorian", "dateStyle":"full", "timeStyle":"full", "timeZone": "CST"}
```
-## Number Formatting
+## Formatting Numbers
[NumberFormat](../reference/apis/js-apis-intl.md#numberformat) provides APIs to implement the number formatting specific to a locale.
@@ -181,7 +181,7 @@ The [I18N](i18n-guidelines.md) module provides enhanced I18N capabilities throug
let numberFormat = new Intl.NumberFormat();
```
- Alternatively, use your own locale and formatting parameters to create a **NumberFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [NumberOptions](../reference/apis/js-apis-intl.md#numberoptions).
+ Alternatively, use your own locale and formatting parameters to create a **NumberFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [NumberOptions](../reference/apis/js-apis-intl.md#numberoptions9).
```js
let options = {compactDisplay: "short", notation: "compact"};
@@ -209,7 +209,7 @@ The [I18N](i18n-guidelines.md) module provides enhanced I18N capabilities throug
let resolvedOptions = numberFormat.resolvedOptions(); // resolvedOptions = {"locale": "zh-CN", "compactDisplay": "short", "notation": "compact", "numberingSystem": "Latn"}
```
-## String Sorting
+## Sorting Strings
Users in different regions have different requirements for string sorting. [Collator](../reference/apis/js-apis-intl.md#collator8) provides APIs to sort character strings specific to a locale.
@@ -317,7 +317,7 @@ According to grammars in certain languages, the singular or plural form of a nou
let categoryResult = pluralRules.select(number); // categoryResult = "other"
```
-## Formatting Relative Time
+## Formatting the Relative Time
[RelativeTimeFormat](../reference/apis/js-apis-intl.md#relativetimeformat8) provides APIs to format the relative time for a specific locale.
@@ -385,9 +385,3 @@ According to grammars in certain languages, the singular or plural form of a nou
let relativeTimeFormat = new Intl.RelativeTimeFormat("zh-CN", {numeric: "always", style: "long"});
let options = relativeTimeFormat.resolvedOptions(); // options = {"locale": "zh-CN", "style": "long", "numeric": "always", "numberingSystem": "latn"}
```
-
-## Samples
-
-The following sample is provided to help you better understand how to develop internationalization capabilities:
-
--[`International`: Internationalization (ArkTS) (API9) (Full SDK)] (https://gitee.com/openharmony/applications_app_samples/tree/master/code/SystemFeature/Internationalnation/International)
diff --git a/en/application-dev/media/Readme-EN.md b/en/application-dev/media/Readme-EN.md
index 94f8605a284976058c8df8537a5ae9aa4a624740..f6902595cadbea27765ebf1812544821b3c68a09 100755
--- a/en/application-dev/media/Readme-EN.md
+++ b/en/application-dev/media/Readme-EN.md
@@ -12,10 +12,10 @@
- [Audio Routing and Device Management Development](audio-routing-manager.md)
- [AVPlayer Development (Recommended)](avplayer-playback.md)
- [AVRecorder Development (Recommended)](avrecorder.md)
- - [Audio Playback Development (To Be Deprecated)](audio-playback.md)
- - [Audio Recording Development (To Be Deprecated)](audio-recorder.md)
- - [Video Playback Development (To Be Deprecated)](video-playback.md)
- - [Video Recording Development (To Be Deprecated)](video-recorder.md)
+ - [Audio Playback Development (To Be Deprecated Soon)](audio-playback.md)
+ - [Audio Recording Development (To Be Deprecated Soon)](audio-recorder.md)
+ - [Video Playback Development (To Be Deprecated Soon)](video-playback.md)
+ - [Video Recording Development (To Be Deprecated Soon)](video-recorder.md)
- AVSession
- [AVSession Overview](avsession-overview.md)
diff --git a/en/application-dev/media/audio-capturer.md b/en/application-dev/media/audio-capturer.md
index 8371b6248d71f48e9088da849dc36c3edb2be3cf..f7b01ce2a387af3471b297de329fe3267b9e9785 100644
--- a/en/application-dev/media/audio-capturer.md
+++ b/en/application-dev/media/audio-capturer.md
@@ -27,32 +27,43 @@ Before developing the audio data collection feature, configure the **ohos.permis
For details about the APIs, see [AudioCapturer in Audio Management](../reference/apis/js-apis-audio.md#audiocapturer8).
-1. Use **createAudioCapturer()** to create an **AudioCapturer** instance.
+1. Use **createAudioCapturer()** to create a global **AudioCapturer** instance.
Set parameters of the **AudioCapturer** instance in **audioCapturerOptions**. This instance is used to capture audio, control and obtain the recording state, and register a callback for notification.
```js
- import audio from '@ohos.multimedia.audio';
+ import audio from '@ohos.multimedia.audio';
+ import fs from '@ohos.file.fs'; // It will be used for the call of the read function in step 3.
+
+ // Perform a self-test on APIs related to audio rendering.
+ @Entry
+ @Component
+ struct AudioRenderer {
+ @State message: string = 'Hello World'
+ private audioCapturer: audio.AudioCapturer; // It will be called globally.
+
+ async initAudioCapturer(){
+ let audioStreamInfo = {
+ samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100,
+ channels: audio.AudioChannel.CHANNEL_1,
+ sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE,
+ encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW
+ }
+
+ let audioCapturerInfo = {
+ source: audio.SourceType.SOURCE_TYPE_MIC,
+ capturerFlags: 0 // 0 is the extended flag bit of the audio capturer. The default value is 0.
+ }
+
+ let audioCapturerOptions = {
+ streamInfo: audioStreamInfo,
+ capturerInfo: audioCapturerInfo
+ }
+
+ this.audioCapturer = await audio.createAudioCapturer(audioCapturerOptions);
+ console.log('AudioRecLog: Create audio capturer success.');
+ }
- let audioStreamInfo = {
- samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100,
- channels: audio.AudioChannel.CHANNEL_1,
- sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE,
- encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW
- }
-
- let audioCapturerInfo = {
- source: audio.SourceType.SOURCE_TYPE_MIC,
- capturerFlags: 0 // 0 is the extended flag bit of the audio capturer. The default value is 0.
- }
-
- let audioCapturerOptions = {
- streamInfo: audioStreamInfo,
- capturerInfo: audioCapturerInfo
- }
-
- let audioCapturer = await audio.createAudioCapturer(audioCapturerOptions);
- console.log('AudioRecLog: Create audio capturer success.');
```
2. Use **start()** to start audio recording.
@@ -60,23 +71,18 @@ For details about the APIs, see [AudioCapturer in Audio Management](../reference
The capturer state will be **STATE_RUNNING** once the audio capturer is started. The application can then begin reading buffers.
```js
- import audio from '@ohos.multimedia.audio';
-
- async function startCapturer() {
- let state = audioCapturer.state;
+ async startCapturer() {
+ let state = this.audioCapturer.state;
// The audio capturer should be in the STATE_PREPARED, STATE_PAUSED, or STATE_STOPPED state after being started.
- if (state != audio.AudioState.STATE_PREPARED || state != audio.AudioState.STATE_PAUSED ||
- state != audio.AudioState.STATE_STOPPED) {
- console.info('Capturer is not in a correct state to start');
- return;
- }
- await audioCapturer.start();
-
- state = audioCapturer.state;
- if (state == audio.AudioState.STATE_RUNNING) {
- console.info('AudioRecLog: Capturer started');
- } else {
- console.error('AudioRecLog: Capturer start failed');
+ if (state == audio.AudioState.STATE_PREPARED || state == audio.AudioState.STATE_PAUSED ||
+ state == audio.AudioState.STATE_STOPPED) {
+ await this.audioCapturer.start();
+ state = this.audioCapturer.state;
+ if (state == audio.AudioState.STATE_RUNNING) {
+ console.info('AudioRecLog: Capturer started');
+ } else {
+ console.error('AudioRecLog: Capturer start failed');
+ }
}
}
```
@@ -86,91 +92,88 @@ For details about the APIs, see [AudioCapturer in Audio Management](../reference
The following example shows how to write recorded data into a file.
```js
- import fs from '@ohos.file.fs';
-
- let state = audioCapturer.state;
- // The read operation can be performed only when the state is STATE_RUNNING.
- if (state != audio.AudioState.STATE_RUNNING) {
- console.info('Capturer is not in a correct state to read');
- return;
- }
-
- const path = '/data/data/.pulse_dir/capture_js.wav'; // Path for storing the collected audio file.
- let file = fs.openSync(filePath, 0o2);
- let fd = file.fd;
- if (file !== null) {
- console.info('AudioRecLog: file created');
- } else {
- console.info('AudioRecLog: file create : FAILED');
- return;
- }
-
- if (fd !== null) {
- console.info('AudioRecLog: file fd opened in append mode');
- }
-
- let numBuffersToCapture = 150; // Write data for 150 times.
- let count = 0;
- while (numBuffersToCapture) {
- let bufferSize = await audioCapturer.getBufferSize();
- let buffer = await audioCapturer.read(bufferSize, true);
- let options = {
- offset: count * this.bufferSize,
- length: this.bufferSize
+ async readData(){
+ let state = this.audioCapturer.state;
+ // The read operation can be performed only when the state is STATE_RUNNING.
+ if (state != audio.AudioState.STATE_RUNNING) {
+ console.info('Capturer is not in a correct state to read');
+ return;
}
- if (typeof(buffer) == undefined) {
- console.info('AudioRecLog: read buffer failed');
+ const path = '/data/data/.pulse_dir/capture_js.wav'; // Path for storing the collected audio file.
+ let file = fs.openSync(path, 0o2);
+ let fd = file.fd;
+ if (file !== null) {
+ console.info('AudioRecLog: file created');
} else {
- let number = fs.writeSync(fd, buffer, options);
- console.info(`AudioRecLog: data written: ${number}`);
- }
- numBuffersToCapture--;
- count++;
+ console.info('AudioRecLog: file create : FAILED');
+ return;
+ }
+ if (fd !== null) {
+ console.info('AudioRecLog: file fd opened in append mode');
+ }
+ let numBuffersToCapture = 150; // Write data for 150 times.
+ let count = 0;
+ while (numBuffersToCapture) {
+ this.bufferSize = await this.audioCapturer.getBufferSize();
+ let buffer = await this.audioCapturer.read(this.bufferSize, true);
+ let options = {
+ offset: count * this.bufferSize,
+ length: this.bufferSize
+ }
+ if (typeof(buffer) == undefined) {
+ console.info('AudioRecLog: read buffer failed');
+ } else {
+ let number = fs.writeSync(fd, buffer, options);
+ console.info(`AudioRecLog: data written: ${number}`);
+ }
+ numBuffersToCapture--;
+ count++;
+ }
}
```
4. Once the recording is complete, call **stop()** to stop the recording.
```js
- async function StopCapturer() {
- let state = audioCapturer.state;
- // The audio capturer can be stopped only when it is in STATE_RUNNING or STATE_PAUSED state.
- if (state != audio.AudioState.STATE_RUNNING && state != audio.AudioState.STATE_PAUSED) {
- console.info('AudioRecLog: Capturer is not running or paused');
- return;
- }
-
- await audioCapturer.stop();
-
- state = audioCapturer.state;
- if (state == audio.AudioState.STATE_STOPPED) {
- console.info('AudioRecLog: Capturer stopped');
- } else {
- console.error('AudioRecLog: Capturer stop failed');
- }
- }
+ async StopCapturer() {
+ let state = this.audioCapturer.state;
+ // The audio capturer can be stopped only when it is in STATE_RUNNING or STATE_PAUSED state.
+ if (state != audio.AudioState.STATE_RUNNING && state != audio.AudioState.STATE_PAUSED) {
+ console.info('AudioRecLog: Capturer is not running or paused');
+ return;
+ }
+
+ await this.audioCapturer.stop();
+
+ state = this.audioCapturer.state;
+ if (state == audio.AudioState.STATE_STOPPED) {
+ console.info('AudioRecLog: Capturer stopped');
+ } else {
+ console.error('AudioRecLog: Capturer stop failed');
+ }
+ }
```
5. After the task is complete, call **release()** to release related resources.
```js
- async function releaseCapturer() {
- let state = audioCapturer.state;
- // The audio capturer can be released only when it is not in the STATE_RELEASED or STATE_NEW state.
- if (state == audio.AudioState.STATE_RELEASED || state == audio.AudioState.STATE_NEW) {
- console.info('AudioRecLog: Capturer already released');
- return;
- }
-
- await audioCapturer.release();
-
- state = audioCapturer.state;
- if (state == audio.AudioState.STATE_RELEASED) {
- console.info('AudioRecLog: Capturer released');
- } else {
- console.info('AudioRecLog: Capturer release failed');
- }
- }
+ async releaseCapturer() {
+ let state = this.audioCapturer.state;
+ // The audio capturer can be released only when it is not in the STATE_RELEASED or STATE_NEW state.
+ if (state == audio.AudioState.STATE_RELEASED || state == audio.AudioState.STATE_NEW) {
+ console.info('AudioRecLog: Capturer already released');
+ return;
+ }
+
+ await this.audioCapturer.release();
+
+ state = this.audioCapturer.state;
+ if (state == audio.AudioState.STATE_RELEASED) {
+ console.info('AudioRecLog: Capturer released');
+ } else {
+ console.info('AudioRecLog: Capturer release failed');
+ }
+ }
```
6. (Optional) Obtain the audio capturer information.
@@ -178,23 +181,20 @@ For details about the APIs, see [AudioCapturer in Audio Management](../reference
You can use the following code to obtain the audio capturer information:
```js
- // Obtain the audio capturer state.
- let state = audioCapturer.state;
-
- // Obtain the audio capturer information.
- let audioCapturerInfo : audio.AuduioCapturerInfo = await audioCapturer.getCapturerInfo();
-
- // Obtain the audio stream information.
- let audioStreamInfo : audio.AudioStreamInfo = await audioCapturer.getStreamInfo();
-
- // Obtain the audio stream ID.
- let audioStreamId : number = await audioCapturer.getAudioStreamId();
-
- // Obtain the Unix timestamp, in nanoseconds.
- let audioTime : number = await audioCapturer.getAudioTime();
-
- // Obtain a proper minimum buffer size.
- let bufferSize : number = await audioCapturer.getBufferSize();
+ async getAudioCapturerInfo(){
+ // Obtain the audio capturer state.
+ let state = this.audioCapturer.state;
+ // Obtain the audio capturer information.
+ let audioCapturerInfo : audio.AudioCapturerInfo = await this.audioCapturer.getCapturerInfo();
+ // Obtain the audio stream information.
+ let audioStreamInfo : audio.AudioStreamInfo = await this.audioCapturer.getStreamInfo();
+ // Obtain the audio stream ID.
+ let audioStreamId : number = await this.audioCapturer.getAudioStreamId();
+ // Obtain the Unix timestamp, in nanoseconds.
+ let audioTime : number = await this.audioCapturer.getAudioTime();
+ // Obtain a proper minimum buffer size.
+ let bufferSize : number = await this.audioCapturer.getBufferSize();
+ }
```
7. (Optional) Use **on('markReach')** to subscribe to the mark reached event, and use **off('markReach')** to unsubscribe from the event.
@@ -202,12 +202,13 @@ For details about the APIs, see [AudioCapturer in Audio Management](../reference
After the mark reached event is subscribed to, when the number of frames collected by the audio capturer reaches the specified value, a callback is triggered and the specified value is returned.
```js
- audioCapturer.on('markReach', (reachNumber) => {
- console.info('Mark reach event Received');
- console.info(`The Capturer reached frame: ${reachNumber}`);
- });
-
- audioCapturer.off('markReach'); // Unsubscribe from the mark reached event. This event will no longer be listened for.
+ async markReach(){
+ this.audioCapturer.on('markReach', 10, (reachNumber) => {
+ console.info('Mark reach event Received');
+ console.info(`The Capturer reached frame: ${reachNumber}`);
+ });
+ this.audioCapturer.off('markReach'); // Unsubscribe from the mark reached event. This event will no longer be listened for.
+ }
```
8. (Optional) Use **on('periodReach')** to subscribe to the period reached event, and use **off('periodReach')** to unsubscribe from the event.
@@ -215,40 +216,43 @@ For details about the APIs, see [AudioCapturer in Audio Management](../reference
After the period reached event is subscribed to, each time the number of frames collected by the audio capturer reaches the specified value, a callback is triggered and the specified value is returned.
```js
- audioCapturer.on('periodReach', (reachNumber) => {
- console.info('Period reach event Received');
- console.info(`In this period, the Capturer reached frame: ${reachNumber}`);
- });
-
- audioCapturer.off('periodReach'); // Unsubscribe from the period reached event. This event will no longer be listened for.
+ async periodReach(){
+ this.audioCapturer.on('periodReach', 10, (reachNumber) => {
+ console.info('Period reach event Received');
+ console.info(`In this period, the Capturer reached frame: ${reachNumber}`);
+ });
+ this.audioCapturer.off('periodReach'); // Unsubscribe from the period reached event. This event will no longer be listened for.
+ }
```
9. If your application needs to perform some operations when the audio capturer state is updated, it can subscribe to the state change event. When the audio capturer state is updated, the application receives a callback containing the event type.
```js
- audioCapturer.on('stateChange', (state) => {
- console.info(`AudioCapturerLog: Changed State to : ${state}`)
- switch (state) {
- case audio.AudioState.STATE_PREPARED:
- console.info('--------CHANGE IN AUDIO STATE----------PREPARED--------------');
- console.info('Audio State is : Prepared');
- break;
- case audio.AudioState.STATE_RUNNING:
- console.info('--------CHANGE IN AUDIO STATE----------RUNNING--------------');
- console.info('Audio State is : Running');
- break;
- case audio.AudioState.STATE_STOPPED:
- console.info('--------CHANGE IN AUDIO STATE----------STOPPED--------------');
- console.info('Audio State is : stopped');
- break;
- case audio.AudioState.STATE_RELEASED:
- console.info('--------CHANGE IN AUDIO STATE----------RELEASED--------------');
- console.info('Audio State is : released');
- break;
- default:
- console.info('--------CHANGE IN AUDIO STATE----------INVALID--------------');
- console.info('Audio State is : invalid');
- break;
- }
- });
+ async stateChange(){
+ this.audioCapturer.on('stateChange', (state) => {
+ console.info(`AudioCapturerLog: Changed State to : ${state}`)
+ switch (state) {
+ case audio.AudioState.STATE_PREPARED:
+ console.info('--------CHANGE IN AUDIO STATE----------PREPARED--------------');
+ console.info('Audio State is : Prepared');
+ break;
+ case audio.AudioState.STATE_RUNNING:
+ console.info('--------CHANGE IN AUDIO STATE----------RUNNING--------------');
+ console.info('Audio State is : Running');
+ break;
+ case audio.AudioState.STATE_STOPPED:
+ console.info('--------CHANGE IN AUDIO STATE----------STOPPED--------------');
+ console.info('Audio State is : stopped');
+ break;
+ case audio.AudioState.STATE_RELEASED:
+ console.info('--------CHANGE IN AUDIO STATE----------RELEASED--------------');
+ console.info('Audio State is : released');
+ break;
+ default:
+ console.info('--------CHANGE IN AUDIO STATE----------INVALID--------------');
+ console.info('Audio State is : invalid');
+ break;
+ }
+ });
+ }
```
diff --git a/en/application-dev/media/audio-renderer.md b/en/application-dev/media/audio-renderer.md
index 4a39544e7483b68d0bc15b00d643c8403dbded46..0a58ea5251744162d9948c23e75351b298a95bb8 100644
--- a/en/application-dev/media/audio-renderer.md
+++ b/en/application-dev/media/audio-renderer.md
@@ -19,61 +19,68 @@ The following figure shows the audio renderer state transitions.

- **PREPARED**: The audio renderer enters this state by calling **create()**.
-
- **RUNNING**: The audio renderer enters this state by calling **start()** when it is in the **PREPARED** state or by calling **start()** when it is in the **STOPPED** state.
-
- **PAUSED**: The audio renderer enters this state by calling **pause()** when it is in the **RUNNING** state. When the audio playback is paused, it can call **start()** to resume the playback.
-
- **STOPPED**: The audio renderer enters this state by calling **stop()** when it is in the **PAUSED** or **RUNNING** state.
-
- **RELEASED**: The audio renderer enters this state by calling **release()** when it is in the **PREPARED**, **PAUSED**, or **STOPPED** state. In this state, the audio renderer releases all occupied hardware and software resources and will not transit to any other state.
## How to Develop
For details about the APIs, see [AudioRenderer in Audio Management](../reference/apis/js-apis-audio.md#audiorenderer8).
-1. Use **createAudioRenderer()** to create an **AudioRenderer** instance.
-
+1. Use **createAudioRenderer()** to create a global **AudioRenderer** instance.
Set parameters of the **AudioRenderer** instance in **audioRendererOptions**. This instance is used to render audio, control and obtain the rendering status, and register a callback for notification.
```js
- import audio from '@ohos.multimedia.audio';
-
+ import audio from '@ohos.multimedia.audio';
+ import fs from '@ohos.file.fs';
+
+ // Perform a self-test on APIs related to audio rendering.
+ @Entry
+ @Component
+ struct AudioRenderer1129 {
+ private audioRenderer: audio.AudioRenderer;
+ private bufferSize; // It will be used for the call of the write function in step 3.
+ private audioRenderer1: audio.AudioRenderer; // It will be used for the call in the complete example in step 14.
+ private audioRenderer2: audio.AudioRenderer; // It will be used for the call in the complete example in step 14.
+
+ async initAudioRender(){
let audioStreamInfo = {
- samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100,
- channels: audio.AudioChannel.CHANNEL_1,
- sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE,
- encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW
+ samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100,
+ channels: audio.AudioChannel.CHANNEL_1,
+ sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE,
+ encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW
}
let audioRendererInfo = {
- content: audio.ContentType.CONTENT_TYPE_SPEECH,
- usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION,
- rendererFlags: 0 // 0 is the extended flag bit of the audio renderer. The default value is 0.
+ content: audio.ContentType.CONTENT_TYPE_SPEECH,
+ usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION,
+ rendererFlags: 0 // 0 is the extended flag bit of the audio renderer. The default value is 0.
}
let audioRendererOptions = {
- streamInfo: audioStreamInfo,
- rendererInfo: audioRendererInfo
- }
-
- let audioRenderer = await audio.createAudioRenderer(audioRendererOptions);
+ streamInfo: audioStreamInfo,
+ rendererInfo: audioRendererInfo
+ }
+ this.audioRenderer = await audio.createAudioRenderer(audioRendererOptions);
console.log("Create audio renderer success.");
+ }
+ }
```
2. Use **start()** to start audio rendering.
-
+
```js
- async function startRenderer() {
- let state = audioRenderer.state;
+ async startRenderer() {
+ let state = this.audioRenderer.state;
// The audio renderer should be in the STATE_PREPARED, STATE_PAUSED, or STATE_STOPPED state when start() is called.
if (state != audio.AudioState.STATE_PREPARED && state != audio.AudioState.STATE_PAUSED &&
- state != audio.AudioState.STATE_STOPPED) {
+ state != audio.AudioState.STATE_STOPPED) {
console.info('Renderer is not in a correct state to start');
return;
}
- await audioRenderer.start();
+ await this.audioRenderer.start();
- state = audioRenderer.state;
+ state = this.audioRenderer.state;
if (state == audio.AudioState.STATE_RUNNING) {
console.info('Renderer started');
} else {
@@ -81,116 +88,102 @@ For details about the APIs, see [AudioRenderer in Audio Management](../reference
}
}
```
+
The renderer state will be **STATE_RUNNING** once the audio renderer is started. The application can then begin reading buffers.
-
-
+
3. Call **write()** to write data to the buffer.
- Read the audio data to be played to the buffer. Call **write()** repeatedly to write the data to the buffer.
+ Read the audio data to be played to the buffer. Call **write()** repeatedly to write the data to the buffer. Import fs from '@ohos.file.fs'; as step 1.
```js
- import fs from '@ohos.file.fs';
- import audio from '@ohos.multimedia.audio';
-
- async function writeBuffer(buf) {
- // The write operation can be performed only when the state is STATE_RUNNING.
- if (audioRenderer.state != audio.AudioState.STATE_RUNNING) {
- console.error('Renderer is not running, do not write');
- return;
- }
- let writtenbytes = await audioRenderer.write(buf);
- console.info(`Actual written bytes: ${writtenbytes} `);
- if (writtenbytes < 0) {
- console.error('Write buffer failed. check the state of renderer');
- }
- }
+ async writeData(){
+ // Set a proper buffer size for the audio renderer. You can also select a buffer of another size.
+ this.bufferSize = await this.audioRenderer.getBufferSize();
+ let dir = globalThis.fileDir; // You must use the sandbox path.
+ const filePath = dir + '/file_example_WAV_2MG.wav'; // The file to render is in the following path: /data/storage/el2/base/haps/entry/files/file_example_WAV_2MG.wav
+ console.info(`file filePath: ${ filePath}`);
- // Set a proper buffer size for the audio renderer. You can also select a buffer of another size.
- const bufferSize = await audioRenderer.getBufferSize();
- let dir = globalThis.fileDir; // You must use the sandbox path.
- const filePath = dir + '/file_example_WAV_2MG.wav'; // The file to render is in the following path: /data/storage/el2/base/haps/entry/files/file_example_WAV_2MG.wav
- console.info(`file filePath: ${ filePath}`);
-
- let file = fs.openSync(filePath, fs.OpenMode.READ_ONLY);
- let stat = await fs.stat(filePath); // Music file information.
- let buf = new ArrayBuffer(bufferSize);
- let len = stat.size % this.bufferSize == 0 ? Math.floor(stat.size / this.bufferSize) : Math.floor(stat.size / this.bufferSize + 1);
- for (let i = 0;i < len; i++) {
- let options = {
- offset: i * this.bufferSize,
- length: this.bufferSize
- }
- let readsize = await fs.read(file.fd, buf, options)
- let writeSize = await new Promise((resolve,reject)=>{
- this.audioRenderer.write(buf,(err,writeSize)=>{
- if(err){
- reject(err)
- }else{
- resolve(writeSize)
- }
+ let file = fs.openSync(filePath, fs.OpenMode.READ_ONLY);
+ let stat = await fs.stat(filePath); // Music file information.
+ let buf = new ArrayBuffer(this.bufferSize);
+ let len = stat.size % this.bufferSize == 0 ? Math.floor(stat.size / this.bufferSize) : Math.floor(stat.size / this.bufferSize + 1);
+ for (let i = 0;i < len; i++) {
+ let options = {
+ offset: i * this.bufferSize,
+ length: this.bufferSize
+ }
+ let readsize = await fs.read(file.fd, buf, options)
+ let writeSize = await new Promise((resolve,reject)=>{
+ this.audioRenderer.write(buf,(err,writeSize)=>{
+ if(err){
+ reject(err)
+ }else{
+ resolve(writeSize)
+ }
+ })
})
- })
+ }
+
+ fs.close(file)
+ await this.audioRenderer.stop(); // Stop rendering.
+ await this.audioRenderer.release(); // Release the resources.
}
-
- fs.close(file)
- await audioRenderer.stop(); // Stop rendering.
- await audioRenderer.release(); // Releases the resources.
```
4. (Optional) Call **pause()** or **stop()** to pause or stop rendering.
```js
- async function pauseRenderer() {
- let state = audioRenderer.state;
- // The audio renderer can be paused only when it is in the STATE_RUNNING state.
- if (state != audio.AudioState.STATE_RUNNING) {
- console.info('Renderer is not running');
- return;
- }
-
- await audioRenderer.pause();
-
- state = audioRenderer.state;
- if (state == audio.AudioState.STATE_PAUSED) {
- console.info('Renderer paused');
- } else {
- console.error('Renderer pause failed');
- }
- }
-
- async function stopRenderer() {
- let state = audioRenderer.state;
- // The audio renderer can be stopped only when it is in STATE_RUNNING or STATE_PAUSED state.
- if (state != audio.AudioState.STATE_RUNNING && state != audio.AudioState.STATE_PAUSED) {
- console.info('Renderer is not running or paused');
- return;
- }
-
- await audioRenderer.stop();
-
- state = audioRenderer.state;
- if (state == audio.AudioState.STATE_STOPPED) {
- console.info('Renderer stopped');
- } else {
- console.error('Renderer stop failed');
- }
- }
+ async pauseRenderer() {
+ let state = this.audioRenderer.state;
+ // The audio renderer can be paused only when it is in the STATE_RUNNING state.
+ if (state != audio.AudioState.STATE_RUNNING) {
+ console.info('Renderer is not running');
+ return;
+ }
+
+ await this.audioRenderer.pause();
+
+ state = this.audioRenderer.state;
+ if (state == audio.AudioState.STATE_PAUSED) {
+ console.info('Renderer paused');
+ } else {
+ console.error('Renderer pause failed');
+ }
+ }
+
+ async stopRenderer() {
+ let state = this.audioRenderer.state;
+ // The audio renderer can be stopped only when it is in STATE_RUNNING or STATE_PAUSED state.
+ if (state != audio.AudioState.STATE_RUNNING && state != audio.AudioState.STATE_PAUSED) {
+ console.info('Renderer is not running or paused');
+ return;
+ }
+
+ await this.audioRenderer.stop();
+
+ state = this.audioRenderer.state;
+ if (state == audio.AudioState.STATE_STOPPED) {
+ console.info('Renderer stopped');
+ } else {
+ console.error('Renderer stop failed');
+ }
+ }
```
5. (Optional) Call **drain()** to clear the buffer.
```js
- async function drainRenderer() {
- let state = audioRenderer.state;
- // drain() can be used only when the audio renderer is in the STATE_RUNNING state.
- if (state != audio.AudioState.STATE_RUNNING) {
- console.info('Renderer is not running');
- return;
- }
-
- await audioRenderer.drain();
- state = audioRenderer.state;
+ async drainRenderer() {
+ let state = this.audioRenderer.state;
+ // drain() can be used only when the audio renderer is in the STATE_RUNNING state.
+ if (state != audio.AudioState.STATE_RUNNING) {
+ console.info('Renderer is not running');
+ return;
}
+
+ await this.audioRenderer.drain();
+ state = this.audioRenderer.state;
+ }
```
6. After the task is complete, call **release()** to release related resources.
@@ -198,67 +191,63 @@ For details about the APIs, see [AudioRenderer in Audio Management](../reference
**AudioRenderer** uses a large number of system resources. Therefore, ensure that the resources are released after the task is complete.
```js
- async function releaseRenderer() {
- let state = audioRenderer.state;
- // The audio renderer can be released only when it is not in the STATE_RELEASED or STATE_NEW state.
- if (state == audio.AudioState.STATE_RELEASED || state == audio.AudioState.STATE_NEW) {
- console.info('Renderer already released');
- return;
- }
- await audioRenderer.release();
-
- state = audioRenderer.state;
- if (state == audio.AudioState.STATE_RELEASED) {
- console.info('Renderer released');
- } else {
- console.info('Renderer release failed');
- }
+ async releaseRenderer() {
+ let state = this.audioRenderer.state;
+ // The audio renderer can be released only when it is not in the STATE_RELEASED or STATE_NEW state.
+ if (state == audio.AudioState.STATE_RELEASED || state == audio.AudioState.STATE_NEW) {
+ console.info('Renderer already released');
+ return;
+ }
+ await this.audioRenderer.release();
+
+ state = this.audioRenderer.state;
+ if (state == audio.AudioState.STATE_RELEASED) {
+ console.info('Renderer released');
+ } else {
+ console.info('Renderer release failed');
+ }
}
```
7. (Optional) Obtain the audio renderer information.
-
+
You can use the following code to obtain the audio renderer information:
```js
- // Obtain the audio renderer state.
- let state = audioRenderer.state;
-
- // Obtain the audio renderer information.
- let audioRendererInfo : audio.AudioRendererInfo = await audioRenderer.getRendererInfo();
-
- // Obtain the audio stream information.
- let audioStreamInfo : audio.AudioStreamInfo = await audioRenderer.getStreamInfo();
-
- // Obtain the audio stream ID.
- let audioStreamId : number = await audioRenderer.getAudioStreamId();
-
- // Obtain the Unix timestamp, in nanoseconds.
- let audioTime : number = await audioRenderer.getAudioTime();
-
- // Obtain a proper minimum buffer size.
- let bufferSize : number = await audioRenderer.getBufferSize();
-
- // Obtain the audio renderer rate.
- let renderRate : audio.AudioRendererRate = await audioRenderer.getRenderRate();
+ async getRenderInfo(){
+ // Obtain the audio renderer state.
+ let state = this.audioRenderer.state;
+ // Obtain the audio renderer information.
+ let audioRendererInfo : audio.AudioRendererInfo = await this.audioRenderer.getRendererInfo();
+ // Obtain the audio stream information.
+ let audioStreamInfo : audio.AudioStreamInfo = await this.audioRenderer.getStreamInfo();
+ // Obtain the audio stream ID.
+ let audioStreamId : number = await this.audioRenderer.getAudioStreamId();
+ // Obtain the Unix timestamp, in nanoseconds.
+ let audioTime : number = await this.audioRenderer.getAudioTime();
+ // Obtain a proper minimum buffer size.
+ let bufferSize : number = await this.audioRenderer.getBufferSize();
+ // Obtain the audio renderer rate.
+ let renderRate : audio.AudioRendererRate = await this.audioRenderer.getRenderRate();
+ }
```
8. (Optional) Set the audio renderer information.
-
+
You can use the following code to set the audio renderer information:
```js
- // Set the audio renderer rate to RENDER_RATE_NORMAL.
- let renderRate : audio.AudioRendererRate = audio.AudioRendererRate.RENDER_RATE_NORMAL;
- await audioRenderer.setRenderRate(renderRate);
-
- // Set the interruption mode of the audio renderer to SHARE_MODE.
- let interruptMode : audio.InterruptMode = audio.InterruptMode.SHARE_MODE;
- await audioRenderer.setInterruptMode(interruptMode);
-
- // Set the volume of the stream to 0.5.
- let volume : number = 0.5;
- await audioRenderer.setVolume(volume);
+ async setAudioRenderInfo(){
+ // Set the audio renderer rate to RENDER_RATE_NORMAL.
+ let renderRate : audio.AudioRendererRate = audio.AudioRendererRate.RENDER_RATE_NORMAL;
+ await this.audioRenderer.setRenderRate(renderRate);
+ // Set the interruption mode of the audio renderer to SHARE_MODE.
+ let interruptMode : audio.InterruptMode = audio.InterruptMode.SHARE_MODE;
+ await this.audioRenderer.setInterruptMode(interruptMode);
+ // Set the volume of the stream to 0.5.
+ let volume : number = 0.5;
+ await this.audioRenderer.setVolume(volume);
+ }
```
9. (Optional) Use **on('audioInterrupt')** to subscribe to the audio interruption event, and use **off('audioInterrupt')** to unsubscribe from the event.
@@ -270,110 +259,116 @@ For details about the APIs, see [AudioRenderer in Audio Management](../reference
In the case of audio interruption, the application may encounter write failures. To avoid such failures, interruption-unaware applications can use **audioRenderer.state** to check the audio renderer state before writing audio data. The applications can obtain more details by subscribing to the audio interruption events. For details, see [InterruptEvent](../reference/apis/js-apis-audio.md#interruptevent9).
It should be noted that the audio interruption event subscription of the **AudioRenderer** module is slightly different from **on('interrupt')** in [AudioManager](../reference/apis/js-apis-audio.md#audiomanager). The **on('interrupt')** and **off('interrupt')** APIs are deprecated since API version 9. In the **AudioRenderer** module, you only need to call **on('audioInterrupt')** to listen for focus change events. When the **AudioRenderer** instance created by the application performs actions such as start, stop, and pause, it requests the focus, which triggers focus transfer and in return enables the related **AudioRenderer** instance to receive a notification through the callback. For instances other than **AudioRenderer**, such as frequency modulation (FM) and voice wakeup, the application does not create an instance. In this case, the application can call **on('interrupt')** in **AudioManager** to receive a focus change notification.
-
+
```js
- audioRenderer.on('audioInterrupt', (interruptEvent) => {
- console.info('InterruptEvent Received');
- console.info(`InterruptType: ${interruptEvent.eventType}`);
- console.info(`InterruptForceType: ${interruptEvent.forceType}`);
- console.info(`AInterruptHint: ${interruptEvent.hintType}`);
-
- if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_FORCE) {
- switch (interruptEvent.hintType) {
+ async subscribeAudioRender(){
+ this.audioRenderer.on('audioInterrupt', (interruptEvent) => {
+ console.info('InterruptEvent Received');
+ console.info(`InterruptType: ${interruptEvent.eventType}`);
+ console.info(`InterruptForceType: ${interruptEvent.forceType}`);
+ console.info(`AInterruptHint: ${interruptEvent.hintType}`);
+
+ if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_FORCE) {
+ switch (interruptEvent.hintType) {
// Forcible pausing initiated by the audio framework. To prevent data loss, stop the write operation.
- case audio.InterruptHint.INTERRUPT_HINT_PAUSE:
- isPlay = false;
- break;
+ case audio.InterruptHint.INTERRUPT_HINT_PAUSE:
+ console.info('isPlay is false');
+ break;
// Forcible stopping initiated by the audio framework. To prevent data loss, stop the write operation.
- case audio.InterruptHint.INTERRUPT_HINT_STOP:
- isPlay = false;
- break;
+ case audio.InterruptHint.INTERRUPT_HINT_STOP:
+ console.info('isPlay is false');
+ break;
// Forcible ducking initiated by the audio framework.
- case audio.InterruptHint.INTERRUPT_HINT_DUCK:
- break;
+ case audio.InterruptHint.INTERRUPT_HINT_DUCK:
+ break;
// Undocking initiated by the audio framework.
- case audio.InterruptHint.INTERRUPT_HINT_UNDUCK:
- break;
- }
- } else if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_SHARE) {
- switch (interruptEvent.hintType) {
+ case audio.InterruptHint.INTERRUPT_HINT_UNDUCK:
+ break;
+ }
+ } else if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_SHARE) {
+ switch (interruptEvent.hintType) {
// Notify the application that the rendering starts.
- case audio.InterruptHint.INTERRUPT_HINT_RESUME:
- startRenderer();
- break;
+ case audio.InterruptHint.INTERRUPT_HINT_RESUME:
+ this.startRenderer();
+ break;
// Notify the application that the audio stream is interrupted. The application then determines whether to continue. (In this example, the application pauses the rendering.)
- case audio.InterruptHint.INTERRUPT_HINT_PAUSE:
- isPlay = false;
- pauseRenderer();
- break;
+ case audio.InterruptHint.INTERRUPT_HINT_PAUSE:
+ console.info('isPlay is false');
+ this.pauseRenderer();
+ break;
+ }
}
- }
- });
-
- audioRenderer.off('audioInterrupt'); // Unsubscribe from the audio interruption event. This event will no longer be listened for.
+ });
+ }
```
10. (Optional) Use **on('markReach')** to subscribe to the mark reached event, and use **off('markReach')** to unsubscribe from the event.
After the mark reached event is subscribed to, when the number of frames rendered by the audio renderer reaches the specified value, a callback is triggered and the specified value is returned.
-
- ```js
- audioRenderer.on('markReach', (reachNumber) => {
- console.info('Mark reach event Received');
- console.info(`The renderer reached frame: ${reachNumber}`);
- });
- audioRenderer.off('markReach'); // Unsubscribe from the mark reached event. This event will no longer be listened for.
+ ```js
+ async markReach(){
+ this.audioRenderer.on('markReach', 50, (position) => {
+ if (position == 50) {
+ console.info('ON Triggered successfully');
+ }
+ });
+ this.audioRenderer.off('markReach'); // Unsubscribe from the mark reached event. This event will no longer be listened for.
+ }
```
11. (Optional) Use **on('periodReach')** to subscribe to the period reached event, and use **off('periodReach')** to unsubscribe from the event.
After the period reached event is subscribed to, each time the number of frames rendered by the audio renderer reaches the specified value, a callback is triggered and the specified value is returned.
-
- ```js
- audioRenderer.on('periodReach', (reachNumber) => {
- console.info('Period reach event Received');
- console.info(`In this period, the renderer reached frame: ${reachNumber} `);
- });
- audioRenderer.off('periodReach'); // Unsubscribe from the period reached event. This event will no longer be listened for.
+ ```js
+ async periodReach(){
+ this.audioRenderer.on('periodReach',10, (reachNumber) => {
+ console.info(`In this period, the renderer reached frame: ${reachNumber} `);
+ });
+
+ this.audioRenderer.off('periodReach'); // Unsubscribe from the period reached event. This event will no longer be listened for.
+ }
```
12. (Optional) Use **on('stateChange')** to subscribe to audio renderer state changes.
After the **stateChange** event is subscribed to, when the audio renderer state changes, a callback is triggered and the audio renderer state is returned.
-
+
```js
- audioRenderer.on('stateChange', (audioState) => {
- console.info('State change event Received');
- console.info(`Current renderer state is: ${audioState}`);
- });
+ async stateChange(){
+ this.audioRenderer.on('stateChange', (audioState) => {
+ console.info('State change event Received');
+ console.info(`Current renderer state is: ${audioState}`);
+ });
+ }
```
13. (Optional) Handle exceptions of **on()**.
If the string or the parameter type passed in **on()** is incorrect , the application throws an exception. In this case, you can use **try catch** to capture the exception.
-
+
```js
- try {
- audioRenderer.on('invalidInput', () => { // The string is invalid.
- })
- } catch (err) {
- console.info(`Call on function error, ${err}`); // The application throws exception 401.
- }
- try {
- audioRenderer.on(1, () => { // The type of the input parameter is incorrect.
- })
- } catch (err) {
- console.info(`Call on function error, ${err}`); // The application throws exception 6800101.
+ async errorCall(){
+ try {
+ this.audioRenderer.on('invalidInput', () => { // The string is invalid.
+ })
+ } catch (err) {
+ console.info(`Call on function error, ${err}`); // The application throws exception 401.
+ }
+ try {
+ this.audioRenderer.on(1, () => { // The type of the input parameter is incorrect.
+ })
+ } catch (err) {
+ console.info(`Call on function error, ${err}`); // The application throws exception 6800101.
+ }
}
```
14. (Optional) Refer to the complete example of **on('audioInterrupt')**.
-
- Create **AudioRender1** and **AudioRender2** in an application, configure the independent interruption mode, and call **on('audioInterrupt')** to subscribe to audio interruption events. At the beginning, **AudioRender1** has the focus. When **AudioRender2** attempts to obtain the focus, **AudioRender1** receives a focus transfer notification and the related log information is printed. If the shared mode is used, the log information will not be printed during application running.
-
- ```js
+ Declare audioRenderer1 and audioRenderer2 first. For details, see step 1.
+ Create **AudioRender1** and **AudioRender2** in an application, configure the independent interruption mode, and call **on('audioInterrupt')** to subscribe to audio interruption events. At the beginning, **AudioRender1** has the focus. When **AudioRender2** attempts to obtain the focus, **AudioRender1** receives a focus transfer notification and the related log information is printed. If the shared mode is used, the log information will not be printed during application running.
+ ```js
async runningAudioRender1(){
let audioStreamInfo = {
samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000,
@@ -388,33 +383,33 @@ For details about the APIs, see [AudioRenderer in Audio Management](../reference
}
let audioRendererOptions = {
streamInfo: audioStreamInfo,
- rendererInfo: audioRendererInfo
+ rendererInfo: audioRendererInfo
}
-
+
// 1.1 Create an instance.
- audioRenderer1 = await audio.createAudioRenderer(audioRendererOptions);
+ this.audioRenderer1 = await audio.createAudioRenderer(audioRendererOptions);
console.info("Create audio renderer 1 success.");
-
+
// 1.2 Set the independent mode.
- audioRenderer1.setInterruptMode(1).then( data => {
+ this.audioRenderer1.setInterruptMode(1).then( data => {
console.info('audioRenderer1 setInterruptMode Success!');
}).catch((err) => {
- console.error(`audioRenderer1 setInterruptMode Fail: ${err}`);
+ console.error(`audioRenderer1 setInterruptMode Fail: ${err}`);
});
-
+
// 1.3 Set the listener.
- audioRenderer1.on('audioInterrupt', async(interruptEvent) => {
- console.info(`audioRenderer1 on audioInterrupt : ${JSON.stringify(interruptEvent)}`)
+ this.audioRenderer1.on('audioInterrupt', async(interruptEvent) => {
+ console.info(`audioRenderer1 on audioInterrupt : ${JSON.stringify(interruptEvent)}`)
});
-
+
// 1.4 Start rendering.
- await audioRenderer1.start();
+ await this.audioRenderer1.start();
console.info('startAudioRender1 success');
-
+
// 1.5 Obtain the buffer size, which is the proper minimum buffer size of the audio renderer. You can also select a buffer of another size.
- const bufferSize = await audioRenderer1.getBufferSize();
+ const bufferSize = await this.audioRenderer1.getBufferSize();
console.info(`audio bufferSize: ${bufferSize}`);
-
+
// 1.6 Obtain the original audio data file.
let dir = globalThis.fileDir; // You must use the sandbox path.
const path1 = dir + '/music001_48000_32_1.wav'; // The file to render is in the following path: /data/storage/el2/base/haps/entry/files/music001_48000_32_1.wav
@@ -423,14 +418,14 @@ For details about the APIs, see [AudioRenderer in Audio Management](../reference
let stat = await fs.stat(path1); // Music file information.
let buf = new ArrayBuffer(bufferSize);
let len = stat.size % this.bufferSize == 0 ? Math.floor(stat.size / this.bufferSize) : Math.floor(stat.size / this.bufferSize + 1);
-
+
// 1.7 Render the original audio data in the buffer by using audioRender.
for (let i = 0;i < len; i++) {
let options = {
offset: i * this.bufferSize,
length: this.bufferSize
}
- let readsize = await fs.read(file.fd, buf, options)
+ let readsize = await fs.read(file1.fd, buf, options)
let writeSize = await new Promise((resolve,reject)=>{
this.audioRenderer1.write(buf,(err,writeSize)=>{
if(err){
@@ -439,13 +434,13 @@ For details about the APIs, see [AudioRenderer in Audio Management](../reference
resolve(writeSize)
}
})
- })
+ })
}
fs.close(file1)
- await audioRenderer1.stop(); // Stop rendering.
- await audioRenderer1.release(); Releases the resources.
+ await this.audioRenderer1.stop(); // Stop rendering.
+ await this.audioRenderer1.release(); // Release the resources.
}
-
+
async runningAudioRender2(){
let audioStreamInfo = {
samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000,
@@ -460,33 +455,33 @@ For details about the APIs, see [AudioRenderer in Audio Management](../reference
}
let audioRendererOptions = {
streamInfo: audioStreamInfo,
- rendererInfo: audioRendererInfo
+ rendererInfo: audioRendererInfo
}
-
+
// 2.1 Create another instance.
- audioRenderer2 = await audio.createAudioRenderer(audioRendererOptions);
+ this.audioRenderer2 = await audio.createAudioRenderer(audioRendererOptions);
console.info("Create audio renderer 2 success.");
-
+
// 2.2 Set the independent mode.
- audioRenderer2.setInterruptMode(1).then( data => {
+ this.audioRenderer2.setInterruptMode(1).then( data => {
console.info('audioRenderer2 setInterruptMode Success!');
}).catch((err) => {
- console.error(`audioRenderer2 setInterruptMode Fail: ${err}`);
+ console.error(`audioRenderer2 setInterruptMode Fail: ${err}`);
});
-
+
// 2.3 Set the listener.
- audioRenderer2.on('audioInterrupt', async(interruptEvent) => {
- console.info(`audioRenderer2 on audioInterrupt : ${JSON.stringify(interruptEvent)}`)
+ this.audioRenderer2.on('audioInterrupt', async(interruptEvent) => {
+ console.info(`audioRenderer2 on audioInterrupt : ${JSON.stringify(interruptEvent)}`)
});
-
+
// 2.4 Start rendering.
- await audioRenderer2.start();
+ await this.audioRenderer2.start();
console.info('startAudioRender2 success');
-
+
// 2.5 Obtain the buffer size.
- const bufferSize = await audioRenderer2.getBufferSize();
+ const bufferSize = await this.audioRenderer2.getBufferSize();
console.info(`audio bufferSize: ${bufferSize}`);
-
+
// 2.6 Read the original audio data file.
let dir = globalThis.fileDir; // You must use the sandbox path.
const path2 = dir + '/music002_48000_32_1.wav'; // The file to render is in the following path: /data/storage/el2/base/haps/entry/files/music002_48000_32_1.wav
@@ -495,14 +490,14 @@ For details about the APIs, see [AudioRenderer in Audio Management](../reference
let stat = await fs.stat(path2); // Music file information.
let buf = new ArrayBuffer(bufferSize);
let len = stat.size % this.bufferSize == 0 ? Math.floor(stat.size / this.bufferSize) : Math.floor(stat.size / this.bufferSize + 1);
-
+
// 2.7 Render the original audio data in the buffer by using audioRender.
for (let i = 0;i < len; i++) {
let options = {
offset: i * this.bufferSize,
length: this.bufferSize
}
- let readsize = await fs.read(file.fd, buf, options)
+ let readsize = await fs.read(file2.fd, buf, options)
let writeSize = await new Promise((resolve,reject)=>{
this.audioRenderer2.write(buf,(err,writeSize)=>{
if(err){
@@ -511,28 +506,17 @@ For details about the APIs, see [AudioRenderer in Audio Management](../reference
resolve(writeSize)
}
})
- })
+ })
}
fs.close(file2)
- await audioRenderer2.stop(); // Stop rendering.
- await audioRenderer2.release(); // Releases the resources.
+ await this.audioRenderer2.stop(); // Stop rendering.
+ await this.audioRenderer2.release(); // Release the resources.
}
-
- async writeBuffer(buf, audioRender) {
- let writtenbytes;
- await audioRender.write(buf).then((value) => {
- writtenbytes = value;
- console.info(`Actual written bytes: ${writtenbytes} `);
- });
- if (typeof(writtenbytes) != 'number' || writtenbytes < 0) {
- console.error('get Write buffer failed. check the state of renderer');
- }
- }
-
+
// Integrated invoking entry.
async test(){
- await runningAudioRender1();
- await runningAudioRender2();
+ await this.runningAudioRender1();
+ await this.runningAudioRender2();
}
-
- ```
+
+ ```
\ No newline at end of file
diff --git a/en/application-dev/media/avplayer-playback.md b/en/application-dev/media/avplayer-playback.md
index 324dd43e6f73d46e5f0d264ae81ba36802ee6021..9a7d9ffa10e2de83e676adbd2c5af7f9b3ba35af 100644
--- a/en/application-dev/media/avplayer-playback.md
+++ b/en/application-dev/media/avplayer-playback.md
@@ -292,13 +292,13 @@ export class AVPlayerDemo {
async avPlayerDemo() {
// Create an AVPlayer instance.
this.avPlayer = await media.createAVPlayer()
- let fdPath = 'fd://'
- let pathDir = "/data/storage/el2/base/haps/entry/files" // The path used here is an example. Obtain the path based on project requirements.
- // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\H264_AAC.mp4 /data/app/el2/100/base/ohos.acts.multimedia.media.avplayer/haps/entry/files" command.
- let path = pathDir + '/H264_AAC.mp4'
- let file = await fs.open(path)
- fdPath = fdPath + '' + file.fd
- this.avPlayer.url = fdPath
+ let fileDescriptor = undefined
+ // Use getRawFileDescriptor of the resource management module to obtain the media assets in the application, and use the fdSrc attribute of the AVPlayer to initialize the media assets.
+ // For details on the fd/offset/length parameter, see the Media API. The globalThis.abilityContext parameter is a system environment variable and is saved as a global variable on the main page during the system boost.
+ await globalThis.abilityContext.resourceManager.getRawFileDescriptor('H264_AAC.mp4').then((value) => {
+ fileDescriptor = {fd: value.fd, offset: value.offset, length: value.length}
+ })
+ this.avPlayer.fdSrc = fileDescriptor
}
}
```
diff --git a/en/application-dev/media/opensles-capture.md b/en/application-dev/media/opensles-capture.md
index 4e1775e178db20e01f15ee7a9b8f685a5c47b07b..3c33b37076ac14d98b550ba7b1a7e36bfe1cb048 100644
--- a/en/application-dev/media/opensles-capture.md
+++ b/en/application-dev/media/opensles-capture.md
@@ -53,10 +53,10 @@ To use OpenSL ES to develop the audio recording function in OpenHarmony, perform
// Configure the parameters based on the audio file format.
SLDataFormat_PCM format_pcm = {
- SL_DATAFORMAT_PCM,
- OHOS::AudioStandard::AudioChannel::MONO,
- OHOS::AudioStandard::AudioSamplingRate::SAMPLE_RATE_44100,
- OHOS::AudioStandard::AudioSampleFormat::SAMPLE_S16LE,
+ SL_DATAFORMAT_PCM, // Input audio format.
+ 1, // Mono channel.
+ SL_SAMPLINGRATE_44_1, // Sampling rate, 44100 Hz.
+ SL_PCMSAMPLEFORMAT_FIXED_16, // Audio sampling format, a signed 16-bit integer in little-endian format.
0,
0,
0
diff --git a/en/application-dev/napi/Readme-EN.md b/en/application-dev/napi/Readme-EN.md
index b7e5367f1697800cafe3094c5a5a8f2cdb56677e..c6bdba99546cafb30a88b9b39c3cd552dfd4419e 100644
--- a/en/application-dev/napi/Readme-EN.md
+++ b/en/application-dev/napi/Readme-EN.md
@@ -1,6 +1,65 @@
# Native APIs
+Native APIs are a set of native development interfaces and tools provided by the OHOS SDK. It enables the use of C or C++ code to implement key application functionalities. Native APIs provide part of basic underlying capabilities of OHOS, such as libc, graphics library, window system, multimedia, and compression library. They do not provide complete OHOS platform capabilities as JS APIs do. Native APIs are compiled into a dynamic library before being packed into the application.
+## Native API Composition
+
+### Native API Directory Structure
+
+Native APIs are stored in the **$(SDK_ROOT)/native** directory of the SDK. They consist of the following parts:
+
+|Directory|Description|
+|--|--|
+|build|Used to build the toolchain.cmake script of the dynamic library in the application. The **ohos.toolchain.cmake** file in this directory defines OHOS cross compilation options.|
+|build-tools|Stores build tools, such as CMake.|
+|docs|Stores Native API reference documents, which is extracted from the header files using Doxgen.|
+|llvm|Stores LLVM, a cross compiler that supports OHOS ABIs.|
+|sysroot|Stores dependent files of build links, including header files and dynamic libraries.|
+
+### Native APIs
+
+|Category|Function|Introduced In|
+|--|--|--|
+|C standard library|C standard library interfaces based on musl. Currently, more than 1500 interfaces are provided.|API version 8|
+|C++ standard library|C++ runtime library libc++_shared. This library must be packed or statically linked to the application during packing.|API version 8|
+|Log|HiLog interfaces for printing logs to the system|API version 8|
+|napi|A group of Node-APIs provided by ArkUI to facilitate access to the JS application environment during application development. Node-APIs are part of native APIs.|API version 8|
+|XComponent|Provides surface and touchscreen event interfaces for developing high-performance graphics applications.|API version 8|
+|libuv|Third-party asynchronous I/O library integrated by ArkUI.|API version 8|
+|libz|zlib library that provides basic compression and decompression interfaces.|API version 8|
+|Drawing|2D graphics library that can be used for drawing on the surface.|API version 8|
+|OpenGL|OpenGL 3.0 interfaces.|API version 8|
+|Rawfile|Application resource access interfaces that can be used to read various resources packed in the application.|API version 8|
+|OpenSLES|Interface library used for 2D and 3D audio acceleration.|API version 8|
+|Mindspore|AI model interface library.|API version 9|
+|Bundle management|Bundle service interfaces that can be used to query bundle information of the application.|API version 8|
+
+Some native APIs use open source standards. For details, see [Native Standard Libraries Supported by OpenHarmony](https://docs.openharmony.cn/pages/v3.1/en/application-dev/reference/native-lib/third_party_libc/musl.md/) and [Node_API](https://docs.openharmony.cn/pages/v3.1/en/application-dev/reference/native-lib/third_party_napi/napi.md/).
+
+## Usage Guidelines
+
+### Scenarios Where Native APIs Are Recommended
+
+You can use native APIs when you want to:
+
+1. Develop performance-sensitive code in computing-intensive scenarios such as gaming and physical simulation.
+2. Reuse the existing C or C++ library.
+3. Customize libraries related to CPU features, such as neon acceleration.
+
+### Scenarios Where Native APIs Are Not Recommended
+
+You do not need to use native APIs when you want to:
+
+1. Write a native OHOS application.
+2. Develop an application compatible on as many OHOS devices as possible.
+
+# Native API References
+
+- [Native API hello world]()
+
+ This sample shows how to develop a hello native API library, which can display strings obtained from the hello library on the TS page.
- [Using Native APIs in Application Projects](napi-guidelines.md)
+
+ This document describes how to use native APIs to interact with modules, interfaces, and asynchronous tasks in JS.
- [Drawing Development](drawing-guidelines.md)
- [Raw File Development](rawfile-guidelines.md)
- [Native Window Development](native-window-guidelines.md)
diff --git a/en/application-dev/napi/neural-network-runtime-guidelines.md b/en/application-dev/napi/neural-network-runtime-guidelines.md
index 9ae694fc12449634a75fae260050188b68e97804..0c86fd05801197bdd63a885c2071f258687a768e 100644
--- a/en/application-dev/napi/neural-network-runtime-guidelines.md
+++ b/en/application-dev/napi/neural-network-runtime-guidelines.md
@@ -244,7 +244,7 @@ The development process of the Neural Network Runtime consists of three phases:
// Create a compilation instance to pass the model to the underlying hardware for compilation.
OH_NNCompilation* compilation = OH_NNCompilation_Construct(model);
if (compilation == nullptr) {
- std::cout << "CreateCompilation failed, error happended when creating compilation." << std::endl;
+ std::cout << "CreateCompilation failed, error happened when creating compilation." << std::endl;
return OH_NN_MEMORY_ERROR;
}
diff --git a/en/application-dev/notification/Readme-EN.md b/en/application-dev/notification/Readme-EN.md
index bf85581053f30d6aa56e0218c51339ef6ee3f268..55070f9e38666be2c6cd5cf87b3d3680df0293ba 100644
--- a/en/application-dev/notification/Readme-EN.md
+++ b/en/application-dev/notification/Readme-EN.md
@@ -1,7 +1,7 @@
# Notification
- [Notification Overview](notification-overview.md)
-- [Notification Subscription (Open Only to System Applications)](notification-subscription.md)
+- [Notification Subscription (for System Applications)](notification-subscription.md)
- [Enabling Notification](notification-enable.md)
- Publishing a Notification
- [Publishing a Basic Notification](text-notification.md)
diff --git a/en/application-dev/notification/notification-subscription.md b/en/application-dev/notification/notification-subscription.md
index c62b65a25c4d80b37610449e6309e05ef259893f..95fe77de7feead97208082c12519523588cd6521 100644
--- a/en/application-dev/notification/notification-subscription.md
+++ b/en/application-dev/notification/notification-subscription.md
@@ -1,4 +1,4 @@
-# Notification Subscription (Open Only to System Applications)
+# Notification Subscription (for System Applications Only)
To receive notifications, an application must subscribe to notifications first. The notification subsystem provides two types of subscription APIs, allowing applications to subscribe to notifications from all applications or notifications from a specific application.
diff --git a/en/application-dev/notification/text-notification.md b/en/application-dev/notification/text-notification.md
index a9d9bdaaaccc731f0e7cec7e3f7a7e74a3aa41d6..7901a78a4c547ca02caae191b551d27f6cae3e3a 100644
--- a/en/application-dev/notification/text-notification.md
+++ b/en/application-dev/notification/text-notification.md
@@ -127,10 +127,10 @@ The following table describes the APIs for notification publishing. You specify
Below is an example of the multi-line notification.

- - In addition to the parameters in the normal text notification, the picture-attached text notification provides the **picture**, **briefText**, and **expandedTitle** parameters. The value of **picture** is a pixel map that does not exceed 2 MB.
+ - In addition to the parameters in the normal text notification, the picture-attached text notification provides the **picture**, **briefText**, and **expandedTitle** parameters. The value of **picture** is a [PixelMap](../reference/apis/js-apis-image.md#pixelmap7) object that does not exceed 2 MB.
```ts
- let notificationPicture: PixelMap = undefined; // Obtain the pixel map information.
+ let imagePixelMap: PixelMap = undefined; // Obtain the PixelMap information.
let notificationRequest: notificationManager.NotificationRequest = {
id: 1,
content: {
@@ -141,7 +141,7 @@ The following table describes the APIs for notification publishing. You specify
additionalText: 'test_additionalText',
briefText: 'test_briefText',
expandedTitle: 'test_expandedTitle',
- picture: notificationPicture
+ picture: imagePixelMap
}
}
}
diff --git a/en/application-dev/quick-start/Readme-EN.md b/en/application-dev/quick-start/Readme-EN.md
index 439bbdcb9d9455a36c75ceb8ba39e728d1aecebd..91136d49f0db6aa18ecc86447894b922f9c263ff 100644
--- a/en/application-dev/quick-start/Readme-EN.md
+++ b/en/application-dev/quick-start/Readme-EN.md
@@ -1,4 +1,5 @@
# Quick Start
+
- Getting Started
- [Before You Start](start-overview.md)
- [Getting Started with ArkTS in Stage Model](start-with-ets-stage.md)
@@ -10,7 +11,6 @@
- Application Package Structure
- [Application Package Structure in Stage Model](application-package-structure-stage.md)
- [Application Package Structure in FA Model](application-package-structure-fa.md)
- - [HAR File Structure](har-structure.md)
- Multi-HAP Mechanism
- [Multi-HAP Design Objectives](multi-hap-objective.md)
- [Multi-HAP Build View](multi-hap-build-view.md)
@@ -18,6 +18,16 @@
- [Multi-HAP Usage Rules](multi-hap-rules.md)
- [Multi-HAP Operation Mechanism and Data Communication Modes](multi-hap-principles.md)
- [Application Installation and Uninstallation Process](application-package-install-uninstall.md)
+ - [Application Package Update Process](application-package-update.md)
+ - Shared Package
+ - [Shared Package Overview](shared-guide.md)
+ - [HAR](har-package.md)
+ - HSP
+ - [In-Application HSP Development](in-app-hsp.md)
+ - [Inter-Application HSP Development (for System Applications Only)](cross-app-hsp.md)
+ - Quick Fix
+ - [Quick Fix Overview](quickfix-principles.md)
+ - [CLI-based Quick Fix Development](quickfix-debug.md)
- Application Configuration Files in Stage Model
- [Application Configuration File Overview (Stage Model)](application-configuration-file-overview-stage.md)
- [app.json5 Configuration File](app-configuration-file.md)
diff --git a/en/application-dev/quick-start/application-package-structure-stage.md b/en/application-dev/quick-start/application-package-structure-stage.md
index b9bd91d798c6a57c06c74cebb38bf558c8fa011d..cb6dc3b12ef12ff249d8afaa9871f901babd9412 100644
--- a/en/application-dev/quick-start/application-package-structure-stage.md
+++ b/en/application-dev/quick-start/application-package-structure-stage.md
@@ -1,17 +1,17 @@
# Application Package Structure in Stage Model
-To develop an application based on the [stage model](application-configuration-file-overview-stage.md), it is essential to understand the structure of the application package created after the application is built and packaged.
+To develop an application based on the [stage model](application-configuration-file-overview-stage.md), it will be helpful if you have a basic understanding of the structure of the application package created after the application is built and packaged, as well as the related basic concepts.
-- In development, an application contains one or more modules. You can [create modules](https://developer.harmonyos.com/en/docs/documentation/doc-guides-V3/ohos-adding-deleting-module-0000001218760594-V3) in the application project in [DevEco Studio](https://developer.harmonyos.com/en/develop/deveco-studio/). As a basic functional unit of an OpenHarmony application/service, a module contains source code, resource files, third-party libraries, and application/service configuration files, and can be built and run independently. Modules can be classified as Ability or Library. A module of the Ability type is built into a Harmony Ability Package (HAP) file in .hap format, and a module of the Library type is built into a [Harmony Ability Resources (HAR) file](har-structure.md) in .tgz format.
+- In development, an application contains one or more modules. You can [create modules](https://developer.harmonyos.com/en/docs/documentation/doc-guides-V3/ohos-adding-deleting-module-0000001218760594-V3) in the application project in [DevEco Studio](https://developer.harmonyos.com/en/develop/deveco-studio/). As a basic functional unit of an OpenHarmony application/service, a module contains source code, resource files, third-party libraries, and application/service configuration files, and can be built and run independently. Modules can be classified as Ability or Library. A module of the Ability type is built into a Harmony Ability Package (HAP) file, and a module of the Library type is built into a [Harmony Archive (HAR)](har-package.md) file or a [Harmony Shared Package (HSP)](shared-guide.md).
A module can contain one or more [UIAbility](../application-models/uiability-overview.md) components, as shown in the figure below.
- **Figure 1** Relationship between modules and UIAbility components
+ **Figure 1** Relationship between modules and UIAbility components

- Unless otherwise specified, the modules described in this document refer to the modules of the Ability type.
+ Unless otherwise specified, the modules described in this document refer to the modules of the Ability type.
- As aforementioned, you can build an application into one or more HAP files. The HAP file is the basic unit for installing an application. It provides code, resources, third-party libraries, and a configuration file. HAP files can be classified as Entry or Feature.
- HAP of the entry type: main module of the application, whose **type** field is set to **"entry"** in the [module.json5](module-configuration-file.md) file. In an application, each type of device supports only one HAP of the entry type, which is typically used to implement the application's entry screen, entry icon, or headline feature.
@@ -27,6 +27,6 @@ To develop an application based on the [stage model](application-configuration-f
- The **module.json** file is the configuration file indispensable in a HAP file. It consists of **module.json5** and **app.json5** in the project configuration. While DevEco Studio provides default configuration, you must modify the configuration as needed. For details about the configuration fields, see [Application Configuration Files in Stage Model](application-configuration-file-overview-stage.md).
- The **pack.info** file describes the HAP attributes in the bundle, for example, **bundleName** and **versionCode** in **app** and **name**, **type**, and **abilities** in **module**. The file is automatically generated when DevEco Studio generates the bundle.
- **Figure 2** Application package structure in stage model
-
- 
\ No newline at end of file
+ **Figure 2** Application package structure in stage model
+
+ 
diff --git a/en/application-dev/quick-start/application-package-update.md b/en/application-dev/quick-start/application-package-update.md
new file mode 100644
index 0000000000000000000000000000000000000000..0137bc47e7ad78345da1128cf423e445d8456f97
--- /dev/null
+++ b/en/application-dev/quick-start/application-package-update.md
@@ -0,0 +1,5 @@
+# Application Package Update Process
+The OpenHarmony bundle manager service allows application packages to be updated under the following scenarios:
+
+1. In the application market: The application market notifies the user of an available update, and the user can install the update by following the onscreen instructions.
+2. In the application: When the application for which an update is available starts up, the application market notifies the user of the update, and the user can install the update by following the onscreen instructions.
diff --git a/en/application-dev/quick-start/arkts-rendering-control.md b/en/application-dev/quick-start/arkts-rendering-control.md
index 0cb38c2c123171b7ebe05df263b7275445542986..13904097ef69fc988fe3b1ed8d5a98714c38c2aa 100644
--- a/en/application-dev/quick-start/arkts-rendering-control.md
+++ b/en/application-dev/quick-start/arkts-rendering-control.md
@@ -42,6 +42,8 @@ ForEach(
)
```
+Since API version 9, this API is supported in ArkTS widgets.
+
**Parameters**
| Name | Type | Mandatory| Description |
@@ -254,7 +256,7 @@ struct MyComponent {
this.data.pushData('/path/image' + this.data.totalCount() + '.png')
})
}, item => item)
- }
+ }.height('100%').width('100%')
}
}
```
diff --git a/en/application-dev/quick-start/arkts-restrictions-and-extensions.md b/en/application-dev/quick-start/arkts-restrictions-and-extensions.md
index fa62ed392100f7ff0b60dcc6e8ee66ef465fbb3a..b2f31f9aae3188dddfb011f94d971c0db3855d99 100644
--- a/en/application-dev/quick-start/arkts-restrictions-and-extensions.md
+++ b/en/application-dev/quick-start/arkts-restrictions-and-extensions.md
@@ -232,3 +232,26 @@ struct Child {
}
}
```
+
+## Restrictions on Naming Custom Components, Classes, and Functions
+
+The name of a custom component, class, or function cannot be the same as any system component name.
+
+Example:
+
+```
+// Rect.ets
+export class Rect {
+ constructor(){}
+}
+// Index.ets
+// ERROR: The module name 'Rect' can not be the same as the inner component name.
+import { Rect } from './Rect';
+@Entry
+@Component
+struct Index {
+ build() {
+
+ }
+}
+```
diff --git a/en/application-dev/quick-start/cross-app-hsp.md b/en/application-dev/quick-start/cross-app-hsp.md
new file mode 100644
index 0000000000000000000000000000000000000000..db971e348908dbc6f6ca87f5d84d162b6bac0997
--- /dev/null
+++ b/en/application-dev/quick-start/cross-app-hsp.md
@@ -0,0 +1,224 @@
+# Inter-Application HSP Development
+
+An inter-application Harmony Shared Package (HSP) is a file used for code and resource sharing between the host application and other applications.
+The host application of an inter-application HSP is a special form of application, which consists of only one HSP. Instead of running independently on a device, the host application runs by being referenced by dependencies of common application modules. When a common application is running, it can invoke capabilities provided by the inter-application HSP dynamically as needed.
+
+## Precautions
+1. The code of an inter-application HSP runs in the application process. When invoking the code, implement an exception capture and fault tolerance mechanism to avoid stability issues caused by malfunctioning of the inter-application HSP.
+2. An application can depend on multiple inter-application HSP files at the same time.
+3. The inter-application HSP may slow down the startup of the application that depends on it. To avoid significant increase in the startup delay, limit the number of inter-application HSP dependencies within 16.
+4. Privilege verification is conducted during inter-application HSP installation. To develop an inter-application HSP, you must configure the **allowAppShareLibrary** application privilege. For details, see [Application Privilege Configuration Guide](../../device-dev/subsystems/subsys-app-privilege-config-guide.md).
+
+## Inter-Application HSP Usage
+An inter-application HSP works by combining the following parts:
+
+[HAR](har-package.md): contains only objects and methods to be exported and therefore comes in a small size. By integrating the HAR into your application project, you can call the objects and methods therein to implement features.
+
+HSP: contains the actual implementation code, including the JS/TS code, C++ libraries, resources, and configuration files. It is either released to the application market or integrated into the system version.
+
+### Integrating the HAR in an Inter-Application HSP
+Define the interfaces to be exported in the **index.d.ets** file in the HAR, which is the entry to the declaration file exported by the inter-application HSP. The path of the **index.d.ets** file is as follows:
+```
+src
+├── main
+| └── module.json5
+├── index.d.ets
+└── oh-package.json5
+```
+Below is an example of the **index.d.ets** file content:
+```ts
+@Component
+export declare struct UIComponent {
+ build():void;
+}
+
+export declare function hello(): string;
+
+export declare function foo1(): string;
+
+export declare function foo2(): string;
+
+export declare function nativeHello(): string;
+```
+In the example, **UIComponent** is an ArkUI component, **hello()**, **foo1()**, and **foo2()** are TS methods, and **nativeHello()** is a native method. Specific implementation is as follows:
+#### ArkUI Components
+The following is an implementation example of ArkUI components in the HSP:
+```ts
+// lib/src/main/ets/ui/MyUIComponent.ets
+@Component
+export struct UIComponent {
+ @State message: string = 'Hello World'
+ build() {
+ Column() {
+ Text(this.message)
+ .fontSize(32)
+ .padding(8)
+ .fontColor(0xffffff)
+ .backgroundColor(0x0000ff)
+ }.padding(8).width('100%')
+ }
+}
+```
+
+#### **TS Methods**
+The following is an implementation example of TS methods in the HSP:
+```ts
+export function hello(name: string): string {
+ return "hello + " + name;
+}
+
+export function foo1() {
+ return "foo1";
+}
+
+export function foo2() {
+ return "foo2";
+}
+```
+#### **Native Methods**
+The following is an implementation example of native methods in the HSP:
+```C++
+#include "napi/native_api.h"
+#include
+#include
+#include
+
+const std::string libname = "liba";
+const std::string version = "v10001";
+
+static napi_value Hello(napi_env env, napi_callback_info info) {
+ napi_value ret;
+ std::string msg = libname + ":native hello, " + version;
+ napi_create_string_utf8(env, msg.c_str(), msg.length(), &ret);
+ return ret;
+}
+
+EXTERN_C_START
+static napi_value Init(napi_env env, napi_value exports) {
+ napi_property_descriptor desc[] = {
+ {"nativeHello", nullptr, Hello, nullptr, nullptr, nullptr, napi_default, nullptr}};
+ napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc);
+ return exports;
+}
+EXTERN_C_END
+
+static napi_module demoModule = {
+ .nm_version = 1,
+ .nm_flags = 0,
+ .nm_filename = nullptr,
+ .nm_register_func = Init,
+ .nm_modname = "liba",
+ .nm_priv = ((void *)0),
+ .reserved = {0},
+};
+
+extern "C" __attribute__((constructor)) void RegisterLibaModule(void) {
+ napi_module_register(&demoModule);
+}
+```
+### Using the Capabilities Exported from the HAR
+To start with, [configure dependency](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-development-npm-package-0000001222578434#section89674298391) on the HAR. The dependency information will then be generated in the **module.json5** file of the corresponding module, as shown in the following:
+```json
+"dependencies": [
+ {
+ "bundleName": "com.share.liba",
+ "moduleName": "liba",
+ "versionCode": 10001
+ }
+]
+```
+In the preceding information, **bundleName**, **moduleName**, and **versionCode** indicate the bundle name, module name, and version number of the inter-application HSP, respectively.
+#### Referencing ArkUI Components in the HAR
+After configuring the dependency on the HAR, you can reference ArkUI components exported from the HAR by using **import**. The sample code is as follows:
+``` ts
+import { UIComponent } from 'liba'
+
+@Entry
+@Component
+struct Index {
+ @State message: string = 'Hello World'
+ build() {
+ Row() {
+ // Reference the ArkUI component in the HAR.
+ UIComponent()
+ Column() {
+ Text(this.message)
+ .fontSize(50)
+ .fontWeight(FontWeight.Bold)
+ }
+ .width('100%')
+ }
+ .height('100%')
+ }
+}
+```
+
+#### Referencing TS Classes and Methods in the HAR
+To reference the TS classes and methods exported from the HAR, use **import** as follows:
+``` ts
+import { foo1 } from 'liba'
+import { foo2 } from 'liba'
+
+@Component
+struct Index {
+ build() {
+ Row() {
+ Column() {
+ Button('Button')
+ .onClick(()=>{
+ // Reference the TS methods in the HAR.
+ foo1();
+ foo2();
+ })
+ }
+ .width('100%')
+ }
+ .height('100%')
+ }
+}
+```
+#### Referencing Native Methods in the HAR
+To reference the native methods exported from the HAR, use **import** as follows:
+``` ts
+import { nativeHello } from 'liba'
+
+@Component
+struct Index {
+ build() {
+ Row() {
+ Column() {
+ Button('Button')
+ .onClick(()=>{
+ // Reference the native method in the HAR.
+ nativeHello();
+ })
+ }
+ .width('100%')
+ }
+ .height('100%')
+ }
+}
+```
+
+## Inter-Application HSP Distribution
+Inter-application HSPs are not completely integrated into an application. They are distributed by being preset in the system version or installed with an application on the device. To be specific:
+1. Some frequently-used inter-application HSPs are preset in the system version.
+2. When a user downloads an application from the application market, if the application market detects that the application depends on one or more inter-application HSPs and any of these HSPs are not installed on the target device, it will download the application as well as the missing HSPs for the user. In this way, the application can use the features shared through the HSPs properly.
+
+### Inter-Application HSP Debugging Mode
+You can debug an inter-application HSP after it is distributed to a device. If the aforementioned distribution methods are not applicable, you can distribute the HSP by running **bm** commands. The procedure is as follows:
+
+> **NOTE**
+>
+> Do not reverse steps 2 and 3. Otherwise, your application will fail to be installed due to a lack of the required inter-application HSP. For more information about the **bm** commands, see [Bundle Management](../../readme/bundle-management.md).
+
+1. Obtain the inter-application HSP installation package.
+2. Run the following **bm** command to install the inter-application HSP.
+```
+bm install -s sharebundle.hsp
+```
+3. Run the following **bm** command to install the HAP file of your application.
+```
+bm install -p feature.hap
+```
+4. Start your application and start debugging.
diff --git a/en/application-dev/quick-start/figures/in-app-hsp-har.png b/en/application-dev/quick-start/figures/in-app-hsp-har.png
new file mode 100644
index 0000000000000000000000000000000000000000..b4473deed92ed251cff11bee403c32cdd39556d8
Binary files /dev/null and b/en/application-dev/quick-start/figures/in-app-hsp-har.png differ
diff --git a/en/application-dev/quick-start/figures/quick-fix-debug.png b/en/application-dev/quick-start/figures/quick-fix-debug.png
new file mode 100644
index 0000000000000000000000000000000000000000..4e7084f30e2d2b26be811c8b8a6c9ec34a005c9e
Binary files /dev/null and b/en/application-dev/quick-start/figures/quick-fix-debug.png differ
diff --git a/en/application-dev/quick-start/figures/quick-fix-devel_release.png b/en/application-dev/quick-start/figures/quick-fix-devel_release.png
new file mode 100644
index 0000000000000000000000000000000000000000..34b701fafe5d319da6b552c5d86305151e8e28b3
Binary files /dev/null and b/en/application-dev/quick-start/figures/quick-fix-devel_release.png differ
diff --git a/en/application-dev/quick-start/figures/quick_fix_bundle_struct.png b/en/application-dev/quick-start/figures/quick_fix_bundle_struct.png
new file mode 100644
index 0000000000000000000000000000000000000000..730414e3ba2fccbb58a27f83ce1afc572544f366
Binary files /dev/null and b/en/application-dev/quick-start/figures/quick_fix_bundle_struct.png differ
diff --git a/en/application-dev/quick-start/figures/quick_fix_gen_abc.png b/en/application-dev/quick-start/figures/quick_fix_gen_abc.png
new file mode 100644
index 0000000000000000000000000000000000000000..3e549ec79cad4a76a55ccab4dbb769b756d9936a
Binary files /dev/null and b/en/application-dev/quick-start/figures/quick_fix_gen_abc.png differ
diff --git a/en/application-dev/quick-start/figures/quick_fix_gen_so.png b/en/application-dev/quick-start/figures/quick_fix_gen_so.png
new file mode 100644
index 0000000000000000000000000000000000000000..31717ca38c7e64983b9b3c95672fe966decf6945
Binary files /dev/null and b/en/application-dev/quick-start/figures/quick_fix_gen_so.png differ
diff --git a/en/application-dev/quick-start/full-sdk-compile-guide.md b/en/application-dev/quick-start/full-sdk-compile-guide.md
index d706c76afd647d0e96c039175f0682ed203c78b2..dc5e4747476a2799654b317c24ee92ba3f4471c2 100644
--- a/en/application-dev/quick-start/full-sdk-compile-guide.md
+++ b/en/application-dev/quick-start/full-sdk-compile-guide.md
@@ -26,4 +26,4 @@ If the compilation is successful, export the files in the **out/sdk/packages/oho
## Replacing the SDK
-After the full SDK is compiled, switch to it in DevEco Studio. For details, see [Guide to Switching to Full SDK](../../application-dev/quick-start/full-sdk-switch-guide.md).
+After the full SDK is compiled, switch to it in DevEco Studio. For details, see [Guide to Switching to Full SDK](full-sdk-switch-guide.md).
diff --git a/en/application-dev/quick-start/full-sdk-switch-guide.md b/en/application-dev/quick-start/full-sdk-switch-guide.md
index 87289c7776cb3dc33b73abc25cb3ef2da06e6eca..c5b0788516215c4ccd7a53fd0482afa4221b9644 100644
--- a/en/application-dev/quick-start/full-sdk-switch-guide.md
+++ b/en/application-dev/quick-start/full-sdk-switch-guide.md
@@ -16,7 +16,7 @@ Manually download the system-specific full SDK package from the mirror. For deta
## Checking the Local SDK Location
-In this example, an eTS project is used. For a JS project, replace **ets** with **js**.
+In this example, an ArkTS project is used. For a JS project, replace **ets** with **js**.
In DevEco Studio, choose **Tools** > **OpenHarmony SDK Manager** to check the location of the local SDK.
diff --git a/en/application-dev/quick-start/har-package.md b/en/application-dev/quick-start/har-package.md
new file mode 100644
index 0000000000000000000000000000000000000000..63b5fcfd10437ac2140a17bcc1daf690e780c791
--- /dev/null
+++ b/en/application-dev/quick-start/har-package.md
@@ -0,0 +1,172 @@
+# HAR
+A Harmony Archive (HAR) is a static shared package that can contain code, C++ libraries, resources, and configuration files. It enables modules and projects to share code related to ArkUI components, resources, and more. Unlike a Harmony Ability Package (HAP), a HAR cannot be independently installed on a device. Instead, it can be referenced only as the dependency of an application module.
+
+## Creating a HAR Module
+You can kickstart your HAR module development with the module template of the **Library** type in DevEco Studio. By default, obfuscation is disabled for the HAR module. To enable this feature, set **artifactType** in the **build-profile.json5** file of the HAR module to **obfuscation** as follows:
+
+```json
+{
+ "apiType": "stageMode",
+ "buildOption": {
+ "artifactType": "obfuscation"
+ }
+}
+```
+The value options of **artifactType** are as follows, and the default value is **original**:
+- **original**: Code is not obfuscated.
+- **obfuscation**: Code is obfuscated using Uglify.
+
+When obfuscation is enabled, DevEco Studio compiles, obfuscates, and compresses code during HAR building, thereby protecting your code assets.
+
+> **NOTE**
+>
+> If **artifactType** is set to **obfuscation**, **apiType** must be set to **stageMode**, because obfuscation is available only in the stage model.
+
+## Precautions for HAR Development
+- The HAR does not support the declaration of **abilities** and **extensionAbilities** in its configuration file.
+- The HAR does not support the declaration of pages in its configuration file.
+- The HAR does not support **worker** configuration under **buildOption** in the **build-profile.json5** file.
+- The HAR of the FA model and that of the stage model cannot be referenced by each other.
+- The HAR of the stage model cannot reference content in the **AppScope** folder. This is because the content in the **AppScope** folder is not packaged into the HAR during compilation and building.
+
+## Exporting ArkUI Components, APIs, and Resources of the HAR
+The **index.ets** file acts as the entry of the HAR export declaration file and is where the HAR exports APIs. This file is automatically generated by DevEco Studio by default. You can specify another file as the entry declaration file in the **main** field in the **oh-package.json5** file of the module. The code snippet is as follows:
+```json
+{
+ "main": "index.ets"
+}
+```
+### Exporting ArkUI Components
+Use **export** to export the ArkUI components. The code snippet is as follows:
+```js
+// library/src/main/ets/components/MainPage/MainPage.ets
+@Component
+export struct MainPage {
+ @State message: string = 'Hello World'
+ build() {
+ Row() {
+ Column() {
+ Text(this.message)
+ .fontSize(50)
+ .fontWeight(FontWeight.Bold)
+ }
+ .width('100%')
+ }
+ .height('100%')
+ }
+}
+```
+In the **index.ets** file, declare the APIs that the HAR exposes to external systems. The code snippet is as follows:
+```js
+// library/index.ets
+export { MainPage } from './src/main/ets/components/MainPage/MainPage'
+```
+### Exporting TS Classes and Methods
+Use **export** to export TS classes and methods. Multiple TS classes and methods can be exported at the same time. The code snippet is as follows:
+```js
+// library/src/main/ts/test.ets
+export class Log {
+ static info(msg) {
+ console.info(msg);
+ }
+}
+
+export function func() {
+ return "har func";
+}
+
+export function func2() {
+ return "har func2";
+}
+```
+In the **index.ets** file, declare the APIs that the HAR exposes to external systems. The code snippet is as follows:
+```js
+// library/index.ets
+export { Log } from './src/main/ts/test'
+export { func } from './src/main/ts/test'
+export { func2 } from './src/main/ts/test'
+```
+### Resources
+Resources are packed into the HAR when it is being compiled and packaged. During compilation and building of a HAP, DevEco Studio collects resource files from the HAP module and its dependent modules. If the resource files of different modules have the same name, DevEco Studio overwrites the resource files based on the following priorities (in descending order):
+- AppScope (supported only by the stage model of API version 9)
+- Modules in the HAP file
+- If resource conflicts occur between dependent HAR modules, they are overwritten based on the dependency sequence. (The module that is higher in the dependency sequence list has higher priority.)
+
+## Referencing ArkUI Components, APIs, and Resources in the HAR
+To start with, [configure dependency](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-development-npm-package-0000001222578434#section89674298391) on the HAR.
+
+### Reference ArkUI Components in the HAR
+
+After configuring the dependency on the HAR, you can reference ArkUI components exported from the HAR by using **import**. The sample code is as follows:
+```js
+// entry/src/main/ets/pages/index.ets
+import { MainPage } from "@ohos/library"
+
+@Entry
+@Component
+struct Index {
+ @State message: string = 'Hello World'
+ build() {
+ Row() {
+ // Reference the ArkUI component in the HAR.
+ MainPage()
+ Column() {
+ Text(this.message)
+ .fontSize(50)
+ .fontWeight(FontWeight.Bold)
+ }
+ .width('100%')
+ }
+ .height('100%')
+ }
+}
+```
+### Referencing TS Classes and Methods in the HAR
+To reference the TS classes and methods exported from the HAR, use **import** as follows:
+```js
+// entry/src/main/ets/pages/index.ets
+import { Log } from "@ohos/library"
+import { func } from "@ohos/library"
+
+@Entry
+@Component
+struct Index {
+ build() {
+ Row() {
+ Column() {
+ Button('Button')
+ .onClick(()=>{
+ // Reference TS classes and methods in the HAR.
+ Log.info("har msg");
+ func();
+ })
+ }
+ .width('100%')
+ }
+ .height('100%')
+ }
+}
+```
+### Referencing Resources in the HAR
+Use **$r** to reference resources in the HAR. For example, add the **name: hello_har** string (defined in the **string.json** file) and **icon_har.png** image to the **src/main/resources** directory of the HAR module, and then reference the string and image in the entry module. The code snippet is as follows:
+```js
+// entry/src/main/ets/pages/index.ets
+@Entry
+@Component
+struct Index {
+ build() {
+ Row() {
+ Column() {
+ // Reference the string in the HAR.
+ Text($r("app.string.hello_har"))
+ .fontSize(50)
+ .fontWeight(FontWeight.Bold)
+ // Reference the image in the HAR.
+ Image($r("app.media.icon_har"))
+ }
+ .width('100%')
+ }
+ .height('100%')
+ }
+}
+```
diff --git a/en/application-dev/quick-start/har-structure.md b/en/application-dev/quick-start/har-structure.md
deleted file mode 100644
index 1d479b504a48752fdcb4ff033e81103efa134da2..0000000000000000000000000000000000000000
--- a/en/application-dev/quick-start/har-structure.md
+++ /dev/null
@@ -1,10 +0,0 @@
-# HAR File Structure
-
-
-The OpenHarmony Archive (HAR) file enables code to be shared among multiple modules or projects. Unlike a Harmony Ability Package (HAP) file, a HAR file cannot be independently installed on a device. Instead, it can only be referenced as the dependency of an application module.
-
-
-A HAR file is the build product of a [module](https://developer.harmonyos.com/en/docs/documentation/doc-guides-V3/ohos-adding-deleting-module-0000001218760594-V3) of the Library type in a DevEco Studio project.
-
-
-As a static shared package in OpenHarmony, the [HAR file](https://developer.harmonyos.com/en/docs/documentation/doc-guides/ohos-development-npm-package-0000001222578434) can contain the source code, C++ libraries, resource files, and the **module.json** file (in stage model) or **config.json** file (in FA model).
diff --git a/en/application-dev/quick-start/in-app-hsp.md b/en/application-dev/quick-start/in-app-hsp.md
new file mode 100644
index 0000000000000000000000000000000000000000..cdd06b5dfb59a2c9609a7f327c95bae710943d3d
--- /dev/null
+++ b/en/application-dev/quick-start/in-app-hsp.md
@@ -0,0 +1,153 @@
+# In-Application HSP Development
+
+An in-application Harmony Shared Package (HSP) is a file used for code and resource sharing within an application (called the host application) and can only be invoked by a HAP or HSP of the same application.
+The in-application HSP is released with the Application Package (App Pack) of the host application and has the same bundle name and lifecycle as the host application.
+
+## Developing an In-Application HSP
+
+You can kickstart your HSP development with the HSP template in DevEco Studio. In this example, an HSP module named **library** is created. The basic project directory structure is as follows:
+```
+library
+├── src
+│ └── main
+│ ├── ets
+│ │ ├── pages
+│ │ └── index.ets
+│ ├── resources
+│ └── module.json5
+└── oh-package.json5
+```
+In the **module.json5** file, set **type** to **shared** for the HSP.
+```json
+{
+ "type": "shared"
+}
+```
+
+The HSP provides capabilities for external systems by exporting APIs in the entry file. Specify the entry file in **main** in the **oh-package.json5** file. For example:
+```json
+{
+ "main": "./src/main/ets/index.ets"
+}
+```
+
+### Exporting TS Classes and Methods
+Use **export** to export TS classes and methods. The sample code is as follows:
+```ts
+// library/src/main/ets/utils/test.ts
+export class Log {
+ static info(msg) {
+ console.info(msg);
+ }
+}
+
+export function add(a: number, b: number) {
+ return a + b;
+}
+
+export function minus(a: number, b: number) {
+ return a - b;
+}
+```
+In the entry file **index.ets**, declare the APIs to be exposed.
+```ts
+// library/src/main/ets/index.ets
+export { Log, add, minus } from './utils/test'
+```
+
+### Exporting ArkUI Components
+Use **export** to export ArkUI components. The sample code is as follows:
+```ts
+// library/src/main/ets/components/MyTitleBar.ets
+@Component
+export struct MyTitleBar {
+ build() {
+ Row() {
+ Text($r('app.string.library_title'))
+ .fontColor($r('app.color.white'))
+ .fontSize(25)
+ .margin({left:15})
+ }
+ .width('100%')
+ .height(50)
+ .padding({left:15})
+ .backgroundColor('#0D9FFB')
+ }
+}
+```
+In the entry file **index.ets**, declare the APIs to be exposed.
+```ts
+// library/src/main/ets/index.ets
+export { MyTitleBar } from './components/MyTitleBar'
+```
+#### About Using Resources in the HSP
+To reference resources in the **resources** directory of the current HSP module, use **$r** or **$rawfile**.
+If a relative path is used, the resources in the HSP caller are referenced instead. For example,
+if **Image("common/example.png")** is used in the HSP module, the **\** component will reference the resource **entry/src/main/ets/common/example.png** in the HSP caller (which is **entry** in this example).
+
+### Exporting Native Methods
+The HSP can contain .so files compiled in C++. The HSP indirectly exports the native method in the .so file. In this example, the **multi** method in the **libnative.so** file is exported.
+```ts
+// ibrary/src/main/ets/utils/nativeTest.ts
+import native from "libnative.so"
+
+export function nativeMulti(a: number, b: number) {
+ return native.multi(a, b);
+}
+```
+
+In the entry file **index.ets**, declare the APIs to be exposed.
+```ts
+// library/src/main/ets/index.ets
+export { nativeMulti } from './utils/nativeTest'
+```
+
+## Using the In-Application HSP
+To use APIs in the HSP, first configure the dependency on the HSP in the **oh-package.json5** file of the module that needs to call the APIs (called the invoking module). If the HSP and the invoking module are in the same project, the APIs can be referenced locally. The sample code is as follows:
+```json
+// entry/oh-package.json5
+"dependencies": {
+ "library": "file:../library"
+}
+```
+You can now call the external APIs of the HSP in the same way as calling the APIs in the HAR.
+In this example, the external APIs are the following ones exported from **library**:
+```ts
+// library/src/main/ets/index.ets
+export { Log, add, minus } from './utils/test'
+export { MyTitleBar } from './components/MyTitleBar'
+export { nativeMulti } from './utils/nativeTest'
+```
+The APIs can be used as follows in the code of the invoking module:
+```ts
+// entry/src/main/ets/pages/index.ets
+import { Log, add, MyTitleBar, nativeMulti } from "library"
+
+@Entry
+@Component
+struct Index {
+ @State message: string = 'Hello World'
+ build() {
+ Row() {
+ Column() {
+ MyTitleBar()
+ Text(this.message)
+ .fontSize(30)
+ .fontWeight(FontWeight.Bold)
+ Button('add(1, 2)')
+ .onClick(()=>{
+ Log.info("add button click!");
+ this.message = "result: " + add(1, 2);
+ })
+ Button('nativeMulti(3, 4)')
+ .onClick(()=>{
+ Log.info("nativeMulti button click!");
+ this.message = "result: " + nativeMulti(3, 4);
+ })
+ }
+ .width('100%')
+ }
+ .height('100%')
+ }
+}
+```
diff --git a/en/application-dev/quick-start/module-configuration-file.md b/en/application-dev/quick-start/module-configuration-file.md
index 67361fccfd749495e2f5825d5ccac6efe1505ed9..8fca81167d6d016376877602de947c4c9cc83bd1 100644
--- a/en/application-dev/quick-start/module-configuration-file.md
+++ b/en/application-dev/quick-start/module-configuration-file.md
@@ -72,7 +72,7 @@ As shown above, the **module.json5** file contains several tags.
| Name| Description| Data Type| Initial Value Allowed|
| -------- | -------- | -------- | -------- |
| name | Name of the module. The value is a string with a maximum of 31 bytes and must be unique in the entire application. Chinese characters are not allowed.| String| No|
-| type | Type of the module. The value can be **entry** or **feature**.
- **entry**: main module of the application.
- **feature**: dynamic feature module of the application.| String| No|
+| type | Type of the module. The options are as follows:
- **entry**: main module of the application.
- **feature**: dynamic feature module of the application.
- **har**: static shared module.
- **shared**: dynamic shared module.| String| No|
| srcEntry | Code path corresponding to the module. The value is a string with a maximum of 127 bytes.| String| Yes (initial value: left empty)|
| description | Description of the module. The value is a string with a maximum of 255 bytes or a string resource index.| String| Yes (initial value: left empty)|
| process | Process name of the current module. The value is a string with a maximum of 31 bytes. If **process** is configured under **HAP**, all UIAbility, DataShareExtensionAbility, and ServiceExtensionAbility components of the application run in the specified process.
**NOTE**
This tag applies only to system applications and does not take effect for third-party applications.| String| Yes (initial value: value of **bundleName** under **app** in the **app.json5** file)|
@@ -150,7 +150,7 @@ Define the **main_pages.json** file under **resources/base/profile** in the deve
The **metadata** tag represents the custom metadata of the HAP file. The tag value is an array and contains three subtags: **name**, **value**, and **resource**.
- **Table 3** metadata
+**Table 3** metadata
| Name| Description| Data Type| Initial Value Allowed|
| -------- | -------- | -------- | -------- |
@@ -210,9 +210,10 @@ Touching this icon will direct the user to the application details screen in **S
To hide an application icon from the home screen, you must configure the **AllowAppDesktopIconHide** privilege. For details, see [Application Privilege Configuration Guide](../../device-dev/subsystems/subsys-app-privilege-config-guide.md).
+
**Setting the application icon to be displayed on the home screen**:
-Set **icon**, **label**, and **skills** under **abilities** in the **module.json5** file. In addition, the **skills** configuration must contain **ohos.want.action.home **and **entity.system.home**.
+Set **icon**, **label**, and **skills** under **abilities** in the **module.json5** file. In addition, make sure the **skills** configuration contains **ohos.want.action.home** and **entity.system.home**.
```
{
@@ -284,7 +285,7 @@ Set **icon**, **label**, and **skills** under **abilities** in the **module.json
| removeMissionAfterTerminate | Whether to remove the relevant task from the task list after the UIAbility component is destroyed.
- **true**: Remove the relevant task from the task list after the UIAbility component is destroyed.
- **false**: Do not remove the relevant task from the task list after the UIAbility component is destroyed.| Boolean| Yes (initial value: **false**)|
| orientation | Orientation of the UIAbility component when it is started. The options are as follows:
- **unspecified**: automatically determined by the system.
- **landscape**: landscape mode.
- **portrait**: portrait mode.
- **landscape_inverted**: inverted landscape mode.
- **portrait_inverted**: inverted portrait mode.
- **auto_rotation**: determined by the sensor.
- **auto_rotation_landscape**: determined by the sensor in the horizontal direction, including landscape and inverted landscape modes.
- **auto_rotation_portrait**: determined by the sensor in the vertical direction, including portrait and inverted portrait modes.
- **auto_rotation_restricted**: determined by the sensor when the sensor switch is enabled.
- **auto_rotation_landscape_restricted**: determined by the sensor in the horizontal direction, including landscape and inverted landscape modes, when the sensor switch is enabled.
- **auto_rotation_portrait_restricted**: determined by the sensor in the vertical direction, including portrait and inverted portrait modes, when the sensor switch is enabled.
- **locked**: auto rotation disabled.| String| Yes (initial value: **"unspecified"**)|
| supportWindowMode | Window mode supported by the UIAbility component. The options are as follows:
- **fullscreen**: full-screen mode.
- **split**: split-screen mode.
- **floating**: floating window mode.| String array| Yes (initial value:
["fullscreen", "split", "floating"])|
-| priority | Priority of the UIAbility component. This attribute applies only to system applications and does not take effect for third-party applications. In the case of [implicit query](../application-models/explicit-implicit-want-mappings.md), UIAbility components with a higher priority are at the higher place of the returned list. The value is an integer ranging from 0 to 10. The greater the value, the higher the priority.| Number| Yes (initial value: **0**)|
+| priority | Priority of the UIAbility component. In the case of [implicit query](../application-models/explicit-implicit-want-mappings.md), UIAbility components with a higher priority are at the higher place of the returned list. The value is an integer ranging from 0 to 10. The greater the value, the higher the priority.
**NOTE**
This tag applies only to system applications and does not take effect for third-party applications.| Number| Yes (initial value: **0**)|
| maxWindowRatio | Maximum aspect ratio supported by the UIAbility component. The minimum value is 0.| Number| Yes (initial value: maximum aspect ratio supported by the platform)|
| minWindowRatio | Minimum aspect ratio supported by the UIAbility component. The minimum value is 0.| Number| Yes (initial value: minimum aspect ratio supported by the platform)|
| maxWindowWidth | Maximum window width supported by the UIAbility component, in vp. The minimum value is 0, and the value cannot be less than the value of **minWindowWidth** or greater than the maximum window width allowed by the platform. For details about the window size, see [Constraints](../windowmanager/window-overview.md#constraints).| Number| Yes (initial value: maximum window width supported by the platform)|
@@ -396,22 +397,22 @@ Example of the **skills** structure:
}
```
-**Enhance implicit query**
+**Enhanced implicit query**
URI-level prefix matching is supported.
-When only **scheme** or a combination of **scheme** and **host** or **scheme**, **host**, and **port** are configured in the configuration file, the configuration is successful if the URI prefixed with the configuration file is passed in.
+When only **scheme** or a combination of **scheme** and **host** or **scheme**, **host**, and **port** are configured in the configuration file, the configuration is successful if a URI prefixed with the configuration file is passed in.
* The query enhancement involves the following APIs:
[@ohos.bundle.bundleManager](../reference/apis/js-apis-bundleManager.md#bundlemanagerqueryabilityinfo)
- 1. function queryAbilityInfo(want: Want, abilityFlags: number, callback: AsyncCallback>): void;
- 2. function queryAbilityInfo(want: Want, abilityFlags: number, userId: number, callback: AsyncCallback>): void;
- 3. function queryAbilityInfo(want: Want, abilityFlags: number, userId?: number): Promise>;
+ 1. function queryAbilityInfo(want: Want, abilityFlags: number, callback: AsyncCallback>): void;
+ 2. function queryAbilityInfo(want: Want, abilityFlags: number, userId: number, callback: AsyncCallback>): void;
+ 3. function queryAbilityInfo(want: Want, abilityFlags: number, userId?: number): Promise>;
* Configuration requirements
abilities -> skills -> uris object
Configuration 1: only **scheme = 'http'**
- Configuration 2: only **(scheme = 'http' ) + ( host = 'example.com')**
- Configuration 3: only **(scheme = 'http' ) + ( host = 'example.com' ) + ( port = '8080')**
+ Configuration 2: only **(scheme = 'http') + (host = 'example.com')**
+ Configuration 3: only **(scheme = 'http') + (host = 'example.com') + (port = '8080')**
* Prefix match
If the value of **uri** under [want](../application-models/want-overview.md) is obtained by calling the **queryAbilityInfo** API:
1. uri = 'https://': No matches
@@ -429,8 +430,6 @@ When only **scheme** or a combination of **scheme** and **host** or **scheme**,
13. uri = 'http://example.com:9180/path': Matches configuration 1 and configuration 2
14. uri = 'http://example.com:8080/path': Matches configuration 1, configuration 2, and configuration 3
-
-
## extensionAbilities
The **extensionAbilities** tag represents the configuration of extensionAbilities, which is valid only for the current extensionAbility.
@@ -446,8 +445,8 @@ The **extensionAbilities** tag represents the configuration of extensionAbilitie
| label | Name of the ExtensionAbility component displayed to users. The value is a string resource index.
**NOTE**
If **ExtensionAbility** is set to **MainElement** of the current module, this attribute is mandatory and its value must be unique in the application.| String| No|
| type | Type of the ExtensionAbility component. The options are as follows:
- **form**: ExtensionAbility of a widget.
- **workScheduler**: ExtensionAbility of a Work Scheduler task.
- **inputMethod**: ExtensionAbility of an input method.
- **service**: service component running in the background.
- **accessibility**: ExtensionAbility of an accessibility feature.
- **dataShare**: ExtensionAbility for data sharing.
- **fileShare**: ExtensionAbility for file sharing.
- **staticSubscriber**: ExtensionAbility for static broadcast.
- **wallpaper**: ExtensionAbility of the wallpaper.
- **backup**: ExtensionAbility for data backup.
- **window**: ExtensionAbility of a window. This type of ExtensionAbility creates a window during startup for which you can develop the GUI. The window is then combined with other application windows through **abilityComponent**.
- **thumbnail**: ExtensionAbility for obtaining file thumbnails. You can provide thumbnails for files of customized file types.
- **preview**: ExtensionAbility for preview. This type of ExtensionAbility can parse the file and display it in a window. You can combine the window with other application windows.
- **print**: ExtensionAbility for the print framework.
**NOTE**
The **service** and **dataShare** types apply only to system applications and do not take effect for third-party applications.| String| No|
| permissions | Permissions required for another application to access the ExtensionAbility component.
The value is generally in the reverse domain name notation and contains a maximum of 255 bytes. It is an array of permission names predefined by the system or customized. The name of a customized permission must be the same as the **name** value of a permission defined in the **defPermissions** attribute.| String array| Yes (initial value: left empty)|
-| uri | Data URI provided by the ExtensionAbility component. The value is a string with a maximum of 255 bytes, in the reverse domain name notation.
**NOTE**
This attribute is mandatory when **type** of the ExtensionAbility component is set to **dataShare**.| String| Yes (initial value: left empty)|
-|skills | Feature set of [wants](../application-models/want-overview.md) that can be received by the ExtensionAbility component.
Configuration rule: In an entry package, you can configure multiple **skills** attributes with the entry capability. (A **skills** attribute with the entry capability is the one that has **ohos.want.action.home** and **entity.system.home** configured.) The **label** and **icon** in the first ExtensionAbility that has **skills** configured are used as the **label** and **icon** of the entire OpenHarmony service/application.
**NOTE**
The **skills** attribute with the entry capability can be configured for the feature-type package of an OpenHarmony application,
but not for an OpenHarmony service.| Array| Yes (initial value: left empty)|
+| uri | Data URI provided by the ExtensionAbility component. The value is a string with a maximum of 255 bytes, in the reverse domain name notation.
**NOTE**
This attribute is mandatory when the type of the **ExtensionAbility** component is set to **dataShare**. | String| Yes (initial value: left empty)|
+|skills | Feature set of [wants](../application-models/want-overview.md) that can be received by the ExtensionAbility component.
Configuration rule: In an entry package, you can configure multiple **skills** attributes with the entry capability. (A **skills** attribute with the entry capability is the one that has **ohos.want.action.home** and **entity.system.home** configured.) The **label** and **icon** in the first ExtensionAbility that has **skills** configured are used as the **label** and **icon** of the entire OpenHarmony service/application.
**NOTE**
The **skills** attribute with the entry capability can be configured for the feature-type package of an OpenHarmony application, but not for an OpenHarmony service. | Array| Yes (initial value: left empty)|
| [metadata](#metadata)| Metadata of the ExtensionAbility component.| Object| Yes (initial value: left empty)|
| exported | Whether the ExtensionAbility component can be called by other applications.
- **true**: The ExtensionAbility component can be called by other applications.
- **false**: The UIAbility component cannot be called by other applications.| Boolean| Yes (initial value: **false**)|
@@ -488,11 +487,12 @@ Example of the **extensionAbilities** structure:
## requestPermissions
-The **requestPermissions** tage represents a set of permissions that the application needs to request from the system for running correctly.
+The **requestPermissions** tag represents a set of permissions that the application needs to request from the system for running correctly.
> **NOTE**
>
-> The permission settings configured in the **requestPermissions** tag apply to the entire application.
+> - The permission settings configured in the **requestPermissions** tag apply to the entire application.
+> - If your application needs to subscribe to an event published by itself and the permissions required for accessing the application are set in the **permissions** tag under **extensionAbilities**, then the application must register the related permissions in the **requestPermissions** tag to receive the event.
**Table 8** requestPermissions
@@ -540,7 +540,7 @@ The **shortcut** information is identified in **metadata**, where:
| shortcutId | ID of the shortcut. The value is a string with a maximum of 63 bytes.| String| No|
| label | Label of the shortcut, that is, the text description displayed for the shortcut. The value can be a string or a resource index to the label, with a maximum of 255 bytes.| String| Yes (initial value: left empty)|
| icon | Icon of the shortcut. The value is an icon resource index.| String| Yes (initial value: left empty)|
-| [wants](../application-models/want-overview.md) | Wants to which the shortcut points. Each want consists of the **bundleName** and **abilityName** sub-attributes.
**bundleName**: target bundle name of the shortcut. The value is a string.
**abilityName**: target component name of the shortcut. The value is a string.| Object| Yes (initial value: left empty)|
+| [wants](../application-models/want-overview.md) | Wants to which the shortcut points. Each want consists of the **bundleName** and **abilityName** sub-attributes.
- **bundleName**: target bundle name of the shortcut. The value is a string.
- **abilityName**: target component name of the shortcut. The value is a string.| Object| Yes (initial value: left empty)|
1. Configure the **shortcuts_config.json** file in **/resource/base/profile/**.
@@ -699,7 +699,7 @@ Configure **metadata** in the **module** tag in the **module.json5** file.
The **testRunner** tag represents the supported test runner.
- **Table 14** testRunner
+**Table 14** testRunner
| Name| Description| Data Type| Initial Value Allowed|
| -------- | -------- | -------- | -------- |
diff --git a/en/application-dev/quick-start/module-structure.md b/en/application-dev/quick-start/module-structure.md
index e4aee36db107109fcaa7e6d068cbc907009c69d4..352a993d5042116105ef5c50ae9138df51c622c9 100644
--- a/en/application-dev/quick-start/module-structure.md
+++ b/en/application-dev/quick-start/module-structure.md
@@ -21,7 +21,7 @@ The **module** tag contains the HAP configuration.
| reqPermissions | Permissions that the application requests from the system when it is running.| Object array| Yes (initial value: left empty)|
| colorMode | Color mode of the application. The options are as follows:
- **dark**: Resources applicable for the dark mode are used.
- **light**: Resources applicable for the light mode are used.
- **auto**: Resources are used based on the color mode of the system.| String| Yes (initial value: **auto**)|
| distroFilter | Distribution rules of the application. This attribute defines the rules for distributing HAP files based on different device specifications, so that precise matching can be performed when the application market distributes applications. Distribution rules cover three factors: API version, screen shape, and screen resolution. During distribution, a unique HAP is determined based on the mapping between **deviceType** and these three factors.| Object| Yes (initial value: left empty) Set this attribute when an application has multiple entry modules.|
-|commonEvents | Information about the common event static subscriber, which must contain the subscriber name, required permissions, and list of the subscribed common events. When a subscribed event is sent, the static subscriber is started. Unlike the common dynamic subscriber, the static subscriber does not need to actively call the common event subscription API in the service code, and may not be started when the common event is released. In constrast, the dynamic subscriber actively calls the common event subscription API and therefore requires the application to stay active.| Object array| Yes (initial value: left empty)|
+|commonEvents | Information about the common event static subscriber, which must contain the subscriber name, required permissions, and list of the common events subscribed to. When a subscribed event is sent, the static subscriber is started. Unlike the dynamic subscriber, the static subscriber does not need to proactively call the common event subscription API in the service code, and may not be running when the common event is published.| Object array| Yes (initial value: left empty)|
| entryTheme | Keyword of an OpenHarmony internal theme. Set it to the resource index of the name.| String| Yes (initial value: left empty)|
|testRunner | Test runner configuration.| Object| Yes (initial value: left empty)|
@@ -190,12 +190,73 @@ Example of the metadata attribute:
## Internal Structure of the abilities Attribute
+**By default, application icons cannot be hidden from the home screen in OpenHarmony.**
+
+The OpenHarmony system imposes a strict rule on the presence of application icons. If no icon is configured in the HAP file of an application, the system creates a default icon for the application and displays it on the home screen.
+Touching this icon will direct the user to the application details screen in **Settings**.
+To hide an application icon from the home screen, you must configure the **AllowAppDesktopIconHide** privilege. For details, see [Application Privilege Configuration Guide](../../device-dev/subsystems/subsys-app-privilege-config-guide.md).
+
+
+**Setting the application icon to be displayed on the home screen**:
Set **icon**, **label**, and **skills** under **abilities** in the **config.json** file. In addition, make sure the **skills** configuration contains **ohos.want.action.home** and **entity.system.home**.
+```
+{
+ "module":{
+
+ ...
+
+ "abilities": [{
+ "icon": "$media:icon",
+ "label": "Login",
+ "skills": [{
+ "actions": ["ohos.want.action.home"],
+ "entities": ["entity.system.home"],
+ "uris": []
+ }]
+ }],
+
+ ...
+
+ }
+}
+```
+
+**Querying an application icon:**
+* The HAP file contains Page ability configuration.
+ * The application icon is set under **abilities** in the **config.json** file.
+ * The application does not have the privilege to hide its icon from the home screen.
+ * The returned home screen icon is the icon configured for the ability.
+ * The returned home screen label is the label configured for the ability. If no label is configured, the bundle name is returned.
+ * The returned component name is the component name of the ability.
+ * When the user touches the home screen icon, the home screen of the ability is displayed.
+ * The application has the privilege to hide its icon from the home screen.
+ * The information about the application is not returned during home screen information query, and the icon of the application is not displayed on the home screen.
+ * The application icon is not set under **abilities** in the **config.json** file.
+ * The application does not have the privilege to hide its icon from the home screen.
+ * The returned home screen icon is the default icon.
+ *The returned home screen label is the bundle name of the application.
+ * The returned component name is the component name displayed on the application details screen (this component is built in the system).
+ * Touching the home screen icon will direct the user to the application details screen.
+ * The application has the privilege to hide its icon from the home screen.
+ * The information about the application is not returned during home screen information query, and the icon of the application is not displayed on the home screen.
+* The HAP file does not contain Page ability configuration.
+ * The application does not have the privilege to hide its icon from the home screen.
+ * The returned home screen icon is the default icon.
+ *The returned home screen label is the bundle name of the application.
+ * The returned component name is the component name displayed on the application details screen (this component is built in the system).
+ * Touching the home screen icon will direct the user to the application details screen.
+ * The application has the privilege to hide its icon from the home screen.
+ * The information about the application is not returned during home screen information query, and the icon of the application is not displayed on the home screen.
+
+> **NOTE**
+>
+> The icon and label displayed on the application details page may be different from those displayed on the home screen. For non-Page abilities, they are the entry icon and label set under **abilities**, if any.
+
**Table 8** Internal structure of the abilities attribute
| Name| 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. The value can contain a maximum of 31 bytes.| String| Yes (initial value: left empty)|
-| name | Ability name. The value can be a reverse domain name, in the format of "*bundleName*.*className*", for example, **"com.example.myapplication.EntryAbility"**. Alternatively, the value can start with a period (.) followed by the class name, for example, **".EntryAbility"**.
The ability name must be unique in an application. Note: If you use DevEco Studio to create the project, an ability named **EntryAbility** will be created by default, and its configuration will be saved to the **config.json** file. The value of this attribute can be customized if you use other IDEs. The value can contain a maximum of 127 bytes.| String| No|
+| name | Ability name. The value can be a reverse domain name, in the format of "*bundleName*.*className*", for example, **"com.example.myapplication.EntryAbility"**. Alternatively, the value can start with a period (.) followed by the class name, for example, **".EntryAbility"**.
The ability name must be unique in an application. Note: If you use DevEco Studio to create the project, an ability named **EntryAbility** will be created by default, and its configuration will be saved to the **config.json** file. If you use other IDEs, the value of this attribute can be customized. The value can contain a maximum of 127 bytes.| 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 bytes.| 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 displayed 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)|
@@ -212,13 +273,13 @@ Example of the metadata attribute:
| grantPermission | Whether permissions can be granted for any data in the ability.| Boolean| Yes (initial value: left empty)|
| readPermission | Permission required for reading data in the ability. This attribute applies only to the ability using the Data template. The value is a string with a maximum of 255 bytes. This attribute applies only to the default, tablet, smart TV, head unit, and wearable device types.| String| Yes (initial value: left empty)|
| writePermission | Permission required for writing data to the ability. This attribute applies only to the ability using the Data template. The value is a string with a maximum of 255 bytes.| String| Yes (initial value: left empty)|
-| configChanges | System configurations that the ability concerns. Upon any changes on the concerned configurations, the **onConfigurationUpdated** callback will be invoked to notify the ability. The options are as follows:
**mcc**: indicates that the mobile country code (MCC) of the IMSI is changed. Typical scenario: A SIM card is detected, and the MCC is updated.
**mnc**: indicates that the mobile network code (MNC) of the IMSI is changed. Typical scenario: A SIM card is detected, and the MNC is updated.
**locale**: indicates that the locale is changed. Typical scenario: The user selectes a new language for the text display of the device.
**layout**: indicates that the screen layout is changed. Typical scenario: Currently, different display forms are all in the active state.
**fontSize**: indicates that font size is changed. Typical scenario: A new global font size is set.
**orientation**: indicates that the screen orientation is changed. Typical scenario: The user rotates the device.
**density**: indicates that the display density is changed. Typical scenario: The user may specify different display ratios, or different display forms are active at the same time.
**size**: indicates that the size of the display window is changed.
**smallestSize**: indicates that the length of the shorter side of the display window is changed.
**colorMode**: indicates that the color mode is changed.| String array| Yes (initial value: left empty)|
+| configChanges | System configurations that the ability concerns. Upon any changes on the concerned configurations, the **onConfigurationUpdated** callback will be invoked to notify the ability. The options are as follows:
**mcc**: indicates that the mobile country code (MCC) of the IMSI is changed. Typical scenario: A SIM card is detected, and the MCC is updated.
**mnc**: indicates that the mobile network code (MNC) of the IMSI is changed. Typical scenario: A SIM card is detected, and the MNC is updated.
**locale**: indicates that the locale is changed. Typical scenario: The user selects a new language for the text display of the device.
**layout**: indicates that the screen layout is changed. Typical scenario: Currently, different display forms are all in the active state.
**fontSize**: indicates that font size is changed. Typical scenario: A new global font size is set.
**orientation**: indicates that the screen orientation is changed. Typical scenario: The user rotates the device.
**density**: indicates that the display density is changed. Typical scenario: The user may specify different display ratios, or different display forms are active at the same time.
**size**: indicates that the size of the display window is changed.
**smallestSize**: indicates that the length of the shorter side of the display window is changed.
**colorMode**: indicates that the color mode is changed.| String array| Yes (initial value: left empty)|
| mission | Task stack of the ability. This attribute applies only to the ability using the Page template. By default, all abilities in an application belong to the same task stack.| String| Yes (initial value: bundle name of the application)|
| targetAbility | Target ability that this ability alias points to. This attribute applies only to the ability using the Page template. If the **targetAbility** attribute is set, only **name**, **icon**, **label**, **visible**, **permissions**, and **skills** take effect in the current ability (ability alias). Other attributes use the values of the **targetAbility** attribute. The target ability must belong to the same application as the alias and must be declared in **config.json** ahead of the alias.| String| Yes (initial value: left empty, indicating that the current ability is not an alias)|
| formsEnabled | Whether the ability can provide widgets. This attribute applies only to the ability using the Page template.
**true**: This ability can provide widgets.
**false**: This ability cannot provide widgets.| Boolean| Yes (initial value: **false**)|
| forms | Information about the widgets used by the ability. This attribute is valid only when **formsEnabled** is set to **true**.| Object array| Yes (initial value: left empty)|
| srcLanguage | Programming language of the ability, which you can specify when creating the project.| String| Yes (initial value: **"js"**)|
-| srcPath | JS code path corresponding to the ability. The value can contain maximum of 127 bytes.| String| No|
+| srcPath | JS code path corresponding to the ability. The value can contain a maximum of 127 bytes.| String| No|
| 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.| Object| Yes (initial value: left empty)|
| startWindowIcon | Index to the icon file of the ability startup page. This attribute applies only to the ability using the Page template. Example: **$media:icon**.| String| Yes (initial value: left empty)|
| startWindowBackground | Index to the background color resource file of the ability startup page. This attribute applies only to the ability using the Page template. Example: **$color:red**.| String| Yes (initial value: left empty)|
@@ -351,9 +412,42 @@ Example of the **skills** attribute structure:
]
```
-## reqPermissions Attributes
-
-**Table 12** reqPermissions attributes
+**Enhanced implicit query**
+
+URI-level prefix matching is supported.
+
+When only **scheme** or a combination of **scheme** and **host** or **scheme**, **host**, and **port** are configured in the configuration file, the configuration is successful if a URI prefixed with the configuration file is passed in.
+
+ * The query enhancement involves the following APIs:
+ [@ohos.bundle.bundleManager](../reference/apis/js-apis-bundleManager.md#bundlemanagerqueryabilityinfo)
+ 1. function queryAbilityInfo(want: Want, abilityFlags: number, callback: AsyncCallback>): void;
+ 2. function queryAbilityInfo(want: Want, abilityFlags: number, userId: number, callback: AsyncCallback>): void;
+ 3. function queryAbilityInfo(want: Want, abilityFlags: number, userId?: number): Promise>;
+ * Configuration requirements
+ abilities -> skills -> uris object
+ Configuration 1: only **scheme = 'http'**
+ Configuration 2: only **(scheme = 'http') + (host = 'www.example.com')**
+ Configuration 3: only **(scheme = 'http') + (host = 'www.example.com') + (port = '8080')**
+ * Prefix match
+ If the value of **uri** under [want](../application-models/want-overview.md) is obtained by calling the **queryAbilityInfo** API:
+ 1. uri = 'https://': No matches
+ 2. uri = 'http://': Matches configuration 1
+ 3. uri = 'https://www.example.com': No matches
+ 4. uri = 'https://www.exa.com': No matches
+ 5. uri = 'http://www.exa.com': Matches configuration 1
+ 6. uri = 'http://www.example.com': Matches configuration 1 and configuration 2
+ 7. uri = 'https://www.example.com:8080': No matches
+ 8. uri = 'http://www.exampleaa.com:8080': Matches configuration 1
+ 9. uri = 'http://www.example.com:9180': Matches configuration 1 and configuration 2
+ 10. uri = 'http://www.example.com:8080': Matches configuration 1, configuration 2, and configuration 3
+ 11. uri = 'https://www.example.com:9180/query/student/name' : No matches
+ 12. uri = 'http://www.exampleap.com:8080/query/student/name': Matches configuration 1
+ 13. uri = 'http://www.example.com:9180/query/student/name': Matches configuration 1 and configuration 2
+ 14. uri = 'http://www.example.com:8080/query/student/name': Matches configuration 1, configuration 2, and configuration 3
+
+## Internal Structure of the reqPermissions Attribute
+
+**Table 12** Internal structure of the reqPermissions attribute
| Name| Description| Data Type| Initial Value Allowed|
| -------- | -------- | -------- | -------- |
@@ -687,7 +781,7 @@ Example of the **commonEvents** attribute structure:
| -------- | -------- | -------- | -------- |
| name | Name of a permission. The value can contain a maximum of 255 bytes.| String| No|
| grantMode | Permission grant mode. The options are as follows:
- **system_grant**: The permission is automatically granted by the system after the application is installed.
- **user_grant**: The permission is dynamically requested when needed and must be granted by the user.| String| Yes (initial value: **"system_grant"**)|
-| availableLevel | Permission type. The options are as follows:
- **system_core**: system core permission.
- **system_basic**: basic system permission.
- **normal**: normal permission, which can be requsted by all applications.| String| Yes (initial value: **"normal"**)|
+| availableLevel | Permission type. The options are as follows:
- **system_core**: system core permission.
- **system_basic**: basic system permission.
- **normal**: normal permission, which can be requested by all applications.| String| Yes (initial value: **"normal"**)|
| provisionEnable | Whether the permission can be requested in provision mode, including high-level permissions. The value **true** means that the permission can be requested in provision mode.| Boolean| Yes (initial value: **true**)|
| distributedSceneEnabled | Whether the permission can be used in distributed scenarios.| Boolean| Yes (initial value: **false**)|
| label | Brief description of the permission. The value is a resource index to the description.| String| Yes (initial value: left empty)|
diff --git a/en/application-dev/quick-start/quickfix-debug.md b/en/application-dev/quick-start/quickfix-debug.md
new file mode 100644
index 0000000000000000000000000000000000000000..b7cdf872c72198e796be1f1b65e635cb52ce04e6
--- /dev/null
+++ b/en/application-dev/quick-start/quickfix-debug.md
@@ -0,0 +1,92 @@
+# CLI-based Quick Fix Development
+
+You can use the command-line tool to develop a quick fix file, an expeditious approach to resolve application bugs. In this document, an application with the bundle name of **com.ohos.quickfix** in version 1000000 is used as an example to describe how to develop a quick fix file with the command-line tool.
+
+## Writing the patch.json File
+
+Write a **patch.json** file that meets your project requirements and place it in any directory of the project. (Configuring the **patch.json** file is not supported in DevEco Studio.) Create a **patch.json** file on the local computer. Below is an example of the file content:
+```json
+{
+ "app" : {
+ "bundleName" : "com.ohos.quickfix",
+ "versionCode": 1000000, // Application version
+ "versionName" : "1.0.0.1",
+ "patchVersionCode": 1000000, // Patch version
+ "patchVersionName" : "1.0.0.1"
+ },
+ "module" : {
+ "name" : "entry",
+ "type" : "patch",
+ "deviceTypes" : [
+ "default",
+ "tablet"
+ ],
+ "originalModuleHash": "11223344556677889900" // SHA-256 value of the HAP file to restore
+ }
+}
+```
+
+## Generating a Quick Fix File
+### Quick Fix for TS Code
+* After modifying the TS code file in DevEco Studio and build it into a HAP file, you can find the corresponding .abc file in the project directory, for example, **build\default\cache\default\LegacyCompileETS\jsbundle\temporary\pages\index.abc**.
+
+### Quick Fix for C++ Code
+
+* In DevEco Studio, build the original C++ code into a .so file. Fix bugs in the code and rebuild the code into a new .so file. You can find this .so file in the project directory, for example, **build\default\intermediates\libs\default\arm64-v8a\libentry.so**.
+* Locate the **diff.exe** tool in the **toolchains** folder in the local OpenHarmony SDK path. Use this tool to generate a quick fix .so file based on the old and new .so files. The command is as follows:
+```shell
+$ diff.exe -s Example.z.so -d Example.z.so -p Example.z.so.diff
+```
+The command contains the following options:
+- -**s**: path to the old .so file
+- -**d**: path to the new .so file
+- -**p**: path of the generated differential file
+
+## Generating a Quick Fix File in .hqf Format
+
+With the preceding **patch.json**, .abc, and .so files, run the following command to generate an .hqf file using the **app_packing_tool.jar** tool in the **toolchains** folder in the local OpenHarmony SDK path:
+```shell
+$ java -jar app_packing_tool.jar --mode hqf --json-path patch.json --lib-path libs --ets-patch patchs --out-path entry-default-unsigned.hqf --force true
+```
+
+The command contains the following options.
+| Option|Description | Remarks|
+| --- | --- |---|
+| mode |Mode. | Mandatory|
+| json-path|Path to the **patch.json** file.|Mandatory|
+| lib-path|Path to the quick fix .so file. For details about the path, see [Structure of the Quick Fix Package](quickfix-principles.md#structure-of-the-quick-fix-package).|Optional|
+| ets-path|Path to the quick fix .abc file.|Optional|
+
+## Signing the Quick Fix File
+
+Use the [hapsigner](../security/hapsigntool-guidelines.md) tool to sign the **entry-default-unsigned.hqf** file, in the same way you sign a HAP file. To be specific, run the following command to use **hap-sign-tool.jar** in the **toolchains** folder in the local OpenHarmony SDK path:
+
+```shell
+$ java -jar hap-sign-tool.jar sign-app -keyAlias "OpenHarmony Application Release" -signAlg "SHA256withECDSA" -mode "localSign" -appCertFile "OpenHarmonyApplication.pem" -profileFile "ohos_provision_release.p7b" -inFile "entry-default-unsigned.hqf" -keystoreFile "OpenHarmony.p12" -outFile "entry-signed-release.hqf" -keyPwd "123456" -keystorePwd "123456"
+```
+
+## Installing the Quick Fix File
+
+Push the **entry-signed-release.hqf** file to the device.
+```shell
+hdc.exe file send .\entry-signed-release.hqf /data/
+```
+
+Run the following command to install the quick fix file as a patch:
+```shell
+$ bm quickfix -a -f /data/entry-signed-release.hqf
+```
+
+The complete commands are as follows:
+```
+$ bm quickfix -h
+usage: bm quickfix
+options list:
+-h, --help list available commands
+-q, --query indicates query quickfix, used with -b or --bundle-name
+-b, --bundle-name query quickfix status and information by a specified bundle name
+-a, --apply indicates apply quickfix, used with -f or --file-path
+-f, --file-path apply a quickfix file by a specified path
+-f, --file-path ... apply some quickfix files of one bundle
+-f, --file-path apply quickfix files by direction, under which are quickfix files
+```
diff --git a/en/application-dev/quick-start/quickfix-principles.md b/en/application-dev/quick-start/quickfix-principles.md
new file mode 100644
index 0000000000000000000000000000000000000000..4c0a1f684cfc1ff71c5ad9a2594ae8823e178e82
--- /dev/null
+++ b/en/application-dev/quick-start/quickfix-principles.md
@@ -0,0 +1,105 @@
+# Quick Fix Overview
+
+Quick fix is a technical means provided by the OpenHarmony system for developers to fix application bugs in a manner that is far faster than application upgrades. Compared with the full application upgrade, the quick fix provides a better user experience by being smaller and faster. It allows users to fix application bugs quickly, without restarting their application.
+
+## Rules for Using Quick Fix
+
+* The quick fix only works for TypeScript (TS) and C++ code of applications, that is, .abc files (created after TS code compilation) and .so files (created after C++ code compilation). It does not work for resource files.
+* No new .abc and .so files are allowed.
+* Before deploying a quick fix package, make sure the corresponding application has been installed. Otherwise, the deployment will fail.
+* The bundle name and application version number configured in the quick fix package must be the same as those of the installed application. Otherwise, the deployment will fail.
+* Make sure the version of the quick fix package to deploy is later than that of the one previously deployed. Otherwise, the deployment will fail.
+* The signature information of the quick fix package must be the same as that of the application to be fixed. Otherwise, the deployment will fail.
+* Installing an application update will delete quick fix package.
+
+## Structure of the Quick Fix Package
+
+
+
The preceding figure shows the structure of the quick fix package released by an OpenHarmony application.
+* As shown in the figure, the quick fix package comes in two formats:
+ * .appqf (Application Quick Fix)
+
There is a one-to-one mapping between the .appqf file and App Pack of an application. For details, see [Application Package Structure in Stage Model](application-package-structure-stage).
+ * The .appqf file is used to release OpenHarmony applications to the application market and cannot be directly installed on devices.
+ * An .appqf file consists of one or more .hqf (Harmony Ability Package Quick Fix) files, which are extracted from the .appqf file by the application market and then distributed to specific devices.
+ * The .appqf file must contain the developer's signature information before being released to the application market. For details about how to sign the file, see [hapsigner Overview](../security/hapsigntool-overview.md).
+ * .hqf (Harmony Ability Package Quick Fix)
+
The .hqf file is a quick fix to bugs in a HAP file. It can be installed on devices. An .hqf file contains .abc and .so files. The .abc files provide the quick fix, and the .so files provide package configuration information as well as the quick fix.
+ * .abc file: modified TS code in the application, which is a bytecode file created after the build.
+ * **libs** directory: a collection of .so.diff files, which are differential files of the .so library files, organized by system CPU architecture, such as arm and x86.
+ * **patch.json**:
+
This file is used to describe the version information of the .hqf file and is filled in by developers. The details are as follows:
+ ```json
+ {
+ "app" : {
+ "bundleName" : "com.ohos.quickfix",
+ "versionCode" : 1000000,
+ "versionName" : "1.0.0",
+ "patchVersionCode" : 1000000,
+ "patchVersionName" : "1.0.0"
+ },
+ "module" : {
+ "name" : "entry",
+ "type" : "patch",
+ "deviceTypes" : [
+ "default",
+ "tablet"
+ ],
+ "originalModuleHash" : "11223344556677889900"
+ }
+ }
+ ```
+ The following describes the parameters:
+ | Parameter|Type |Description |Initial Value Allowed|
+ | --- | --- | --- | --- |
+ |bundleName | string | Bundle name of the application. | No|
+ |versionCode | int |Version of the application. | No |
+ |versionName |string |Version name of the application.| No for the patch|
+ |patchVersionCode |int |Version of the patch. | No|
+ |patchVersionName |string |Version name of the patch.| No for the patch|
+ |name |string |Module name of the application, which is used to restore the module.| No|
+ |type | string|Type of the patch. The value can only be **patch**.| No|
+ |deviceTypes |array |Device types supported by the patch.| No|
+ |originalModuleHash| string |Hash value of the bundle corresponding to the original module name.| No|
+
+## Quick Fix to .abc Files Created After TS Code Compilation
+
+
+
+The preceding figure shows the process of creating an .abc file quick fix using the TS compiler.
+* An application build creates .abc and .map files. The .abc file is a bytecode file created after TS code compilation. It is used when the application is running. The .map file is an intermediate file created when the TS code is compiled using the TS compiler. It stores information such as functions and classes in the code.
+* After bugs in the application are fixed, the application code is compiled again. During the compilation, the difference between the source and the target is obtained based on the preceding .map file and the current TS code, and an .abc file for quick fix is generated based on the difference. This .abc file will be placed in the .hqf file.
+
+## Quick Fix to .so Files Created After C++ Code Compilation
+
+
+
+The preceding figure shows the process of creating a .so file quick fix using the differential tool.
+* The C++ source code of the original application is built into a .so file by using a compiler. The .so file is used when the application is running.
+* After bugs in the application are fixed, the C++ code is compiled again into a .so file. With the two .so files before and after bug fixes, the differential tool generates a .so file for quick fix. This .so file will also be placed in the .hqf file.
+
+## Quick Fix Release and Deployment Process
+
+
+
+As shown above, the modules involved in the release process are as follows:
+* DevEco Studio: an integrated development environment for developing code projects. It can be used to create a quick fix file based on the original application code and the code after bug fixes, and sign the created quick repair file for release to the application market.
+* Application market server: place where you release the quick fix file. It verifies the signature, scans for risks, unpacks and resigns the file, and then distributes the file to the client.
+* Application market client: tool that receives the quick fix file from the application market server and triggers installation.
+* Bundle manager service: system service used to manage the installation and uninstallation of application packages and quick fix files on the device.
+* Quick fix engine: system service used to manage switching to quick fix code on the device. If the target application is running, the quick fix engine instructs it to switch to the quick fix file upon completion of the quick fix file deployment.
+* File system: location where the application package and quick repair file are deployed on the device.
+
+In the end-to-end release and deployment process of the quick repair file:
+1. DevEco Studio is used to create a quick fix file through building and packaging based on the original application source code and the source code after bug fixes, and sign the created quick fix file.
+2. The signed quick repair file is released to the application market, which then distributes the file after verifying the signature, scanning for risks, and unpacking and resigning the file.
+3. When the on-device application market client detects that a new quick fix file is available on the application market server, it downloads the file, and then installs and deploys the file through the bundle manager service in the system.
+4. After the quick fix file is deployed, the quick fix engine triggers the application to switch to the quick fix file, ensuring that the user can instantly use the functions where bugs are fixed.
+
+## Quick Fix File Debugging Process
+
+
+
+* As the quick fix capability is not yet available in DevEco Studio, for the time being, you can use the provided command-line tool to develop a quick fix file. The procedure is as follows:
+1. With the original application source code and the source code after bug fixes, use the command-line tool to build and create quick fix files in .hpf format. Sign the .hpf files before installing them on the device. As aforementioned, the .appqf file cannot be installed on the device.
+2. Install and deploy the .hqf files on the device using the command-line tool.
+3. After the .hqf files are deployed, a callback is called to instruct the quick fix engine to trigger the application to switch to the quick fix file, ensuring that the user can instantly use the functions where bugs are fixed.
diff --git a/en/application-dev/quick-start/shared-guide.md b/en/application-dev/quick-start/shared-guide.md
new file mode 100644
index 0000000000000000000000000000000000000000..b73ad743a97d97b1ba9fc286c68e3b25d6f053d4
--- /dev/null
+++ b/en/application-dev/quick-start/shared-guide.md
@@ -0,0 +1,20 @@
+# Shared Package Overview
+
+OpenHarmony provides two types of shared packages: [Harmony Achive (HAR)](har-package.md) static shared package and Harmony Shared Package (HSP) dynamic shared package.
+
+Both the HAR and HSP are used to share code and resources and can contain code, C++ libraries, resources, and configuration files. The biggest differences between them are as follows: The code and resources in the HAR are compiled with the invoking module, and if there are multiple invoking modules, the build product contains multiple copies of the same code and resources; the code and resources in the HSP can be compiled independently, and the build product contains only one copy of the code and resources.
+
+**Figure 1** HAR and HSP in the App Pack
+
+
+
+The HSP is designed to solve the following issues with the HAR:
+- When multiple HAPs reference the same HAR, the size of the App Pack swells.
+- When multiple HAPs reference the same HAR, some state variables in the HAR cannot be shared.
+
+Restrictions on the HSP:
+- The HSP and its invoking modules must be in the stage model.
+- The HSP and its invoking modules must use the **esmodule **compilation mode.
+- The HSP does not support the declaration of **abilities** and **extensionAbilities** in its configuration file.
+
+The HSP can be classified as [in-application HSP](in-app-hsp.md) or [inter-application HSP](cross-app-hsp.md), depending on the configuration files and usage methods.
diff --git a/en/application-dev/quick-start/stage-structure.md b/en/application-dev/quick-start/stage-structure.md
deleted file mode 100644
index ff66e3d405738a44f0c645593ffb0dbfb5beca97..0000000000000000000000000000000000000000
--- a/en/application-dev/quick-start/stage-structure.md
+++ /dev/null
@@ -1,25 +0,0 @@
-# Application Configuration File Overview (Stage Model)
-
-
-Each application project must have configuration files in its code directory. These configuration files provide basic application information for build tools, operating systems, and application markets.
-
-
-In the code directory of an application project developed in stage model, there are two types of configuration files: one **app.json5** file and one or more **module.json5** files.
-
-
-The [app.json5](app-configuration-file.md) file contains the following contents:
-
-
-- Application-wide configuration, including the bundle name, developer, and version number.
-
-- Device-specific configuration.
-
-
-The [module.json5](module-configuration-file.md) file contains the following contents:
-
-
-- Basic module configuration, such as the name, type, description, and supported device types of the module.
-
-- Information about the [application components](../application-models/stage-model-development-overview.md), including the descriptions of the UIAbility and ExtensionAbility components.
-
-- Information about the permissions required during application running.
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 23709abc5c2ba7e9b14ef9f396e9731a9f94e136..c806eebac3e5f266cd0ba6859ef7eb75727af243 100644
--- a/en/application-dev/quick-start/start-with-ets-fa.md
+++ b/en/application-dev/quick-start/start-with-ets-fa.md
@@ -20,7 +20,7 @@
> **NOTE**
>
- > If you are using DevEco Studio V3.0 Beta3 or later, you can use the [low-code development](https://developer.harmonyos.com/en/docs/documentation/doc-guides/ohos-low-code-development-0000001218440652) mode apart from the traditional coding approach.
+ > If you are using DevEco Studio V3.0 Beta3 or later, you can use the low-code development mode apart from the traditional coding approach.
>
> On the low-code development pages, you can design your application UI in an efficient, intuitive manner, with a wide array of UI editing features.
>
@@ -34,7 +34,7 @@

- **entry**: OpenHarmony project module, which can be built into an OpenHarmony Ability Package ([HAP](../../glossary.md#hap)).
- - **src > main > ets**: a collection of eTS source code.
+ - **src > main > ets**: a collection of ArkTS source code.
- **src > main > ets > MainAbility**: entry to your application/service.
- **src > main > ets > MainAbility > pages**: pages contained in **MainAbility**.
- **src > main > ets > MainAbility > pages > index.ets**: the first page in the **pages** list, also referred to as the entry to the application.
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 d9527e8fe83bf0173e688296c5cab2e8aff651b8..eece0ad295ee138ccf353345a78fc1eca7cf3715 100644
--- a/en/application-dev/quick-start/start-with-ets-stage.md
+++ b/en/application-dev/quick-start/start-with-ets-stage.md
@@ -20,7 +20,7 @@
> **NOTE**
>
- > You can use the [low-code development](https://developer.harmonyos.com/en/docs/documentation/doc-guides/ohos-low-code-development-0000001218440652) mode apart from the traditional coding approach.
+ > You can use the low-code development mode apart from the traditional coding approach.
>
> On the low-code development pages, you can design your application UI in an efficient, intuitive manner, with a wide array of UI editing features.
>
@@ -34,7 +34,7 @@

- **entry**: OpenHarmony project module, which can be built into an OpenHarmony Ability Package ([HAP](../../glossary.md#hap)).
- - **src > main > ets**: a collection of eTS source code.
+ - **src > main > ets**: a collection of ArkTS source code.
- **src > main > ets > entryability**: entry to your application/service.
- **src > main > ets > pages**: pages included in your application/service.
- **src > main > resources**: a collection of resource files used by your application/service, such as graphics, multimedia, character strings, and layout files. For details about resource files, see [Resource Categories and Access](resource-categories-and-access.md#resource-categories).
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 7e1123d97f8af188bbb97849551cd6a499042a9f..15af85cd0dfadab9573d38e3d95e3671448550de 100644
--- a/en/application-dev/quick-start/start-with-js-fa.md
+++ b/en/application-dev/quick-start/start-with-js-fa.md
@@ -18,7 +18,7 @@
> **NOTE**
>
- > If you are using DevEco Studio V2.2 Beta1 or later, you can use the [low-code development](https://developer.harmonyos.com/en/docs/documentation/doc-guides/ohos-low-code-development-0000001218440652) mode apart from the traditional coding approach.
+ > If you are using DevEco Studio V2.2 Beta1 or later, you can use the low-code development mode apart from the traditional coding approach.
>
> On the low-code development pages, you can design your application UI in an efficient, intuitive manner, with a wide array of UI editing features.
>
diff --git a/en/application-dev/reference/apis/Readme-EN.md b/en/application-dev/reference/apis/Readme-EN.md
index 1c150a3d12f708d525d9bb6453d0f2e69ceb0f37..3d791befc09e01d9dda38f359d68485cd97eb2a2 100644
--- a/en/application-dev/reference/apis/Readme-EN.md
+++ b/en/application-dev/reference/apis/Readme-EN.md
@@ -125,7 +125,20 @@
- [@ohos.notification (Notification) (To Be Deprecated Soon)](js-apis-notification.md)
- application
- [EventHub](js-apis-inner-application-eventHub.md)
-
+ - commonEvent
+ - [CommonEventData](js-apis-inner-commonEvent-commonEventData.md)
+ - [CommonEventPublishData](js-apis-inner-commonEvent-commonEventPublishData.md)
+ - [CommonEventSubscriber](js-apis-inner-commonEvent-commonEventSubscriber.md)
+ - [CommonEventSubscribeInfo](js-apis-inner-commonEvent-commonEventSubscribeInfo.md)
+ - notification
+ - [NotificationActionButton](js-apis-inner-notification-notificationActionButton.md)
+ - [NotificationCommonDef](js-apis-inner-notification-notificationCommonDef.md)
+ - [NotificationContent](js-apis-inner-notification-notificationContent.md)
+ - [NotificationFlags](js-apis-inner-notification-notificationFlags.md)
+ - [NotificationRequest](js-apis-inner-notification-notificationRequest.md)
+ - [NotificationSlot](js-apis-inner-notification-notificationSlot.md)
+ - [NotificationTemplate](js-apis-inner-notification-notificationTemplate.md)
+ - [NotificationUserInput](js-apis-inner-notification-notificationUserInput.md)
- Bundle Management
- [@ohos.bundle.appControl (appControl)](js-apis-appControl.md)
- [@ohos.bundle.bundleManager (bundleManager)](js-apis-bundleManager.md)
@@ -156,8 +169,11 @@
- [@ohos.curves (Interpolation Calculation)](js-apis-curve.md)
- [@ohos.matrix4 (Matrix Transformation)](js-apis-matrix4.md)
- [@ohos.mediaquery (Media Query)](js-apis-mediaquery.md)
+ - [@ohos.pluginComponent (PluginComponentManager)](js-apis-plugincomponent.md)
- [@ohos.promptAction (Prompt)](js-apis-promptAction.md)
- [@ohos.router (Page Routing)](js-apis-router.md)
+ - [@ohos.measure (Text Measurement)](js-apis-measure.md)
+ - [@ohos.uiAppearance (UI Appearance)](js-apis-uiappearance.md)
- Graphics
- [@ohos.animation.windowAnimationManager (Window Animation Management)](js-apis-windowAnimationManager.md)
@@ -172,19 +188,19 @@
- [WebGL](js-apis-webgl.md)
- [WebGL2](js-apis-webgl2.md)
-- Media
+- Multimedia
- [@ohos.multimedia.audio (Audio Management)](js-apis-audio.md)
- [@ohos.multimedia.avsession (AVSession Management)](js-apis-avsession.md)
- [@ohos.multimedia.camera (Camera Management)](js-apis-camera.md)
- [@ohos.multimedia.image (Image Processing)](js-apis-image.md)
- [@ohos.multimedia.media (Media)](js-apis-media.md)
-- Resource Management
+- Resource Manager
- [@ohos.i18n (Internationalization)](js-apis-i18n.md)
- [@ohos.intl (Internationalization)](js-apis-intl.md)
- [@ohos.resourceManager (Resource Manager)](js-apis-resource-manager.md)
-- Background Tasks
+- Background Task
- [@ohos.distributedMissionManager (Distributed Mission Management)](js-apis-distributedMissionManager.md)
- [@ohos.reminderAgentManager (Reminder Agent Management)](js-apis-reminderAgentManager.md)
- [@ohos.resourceschedule.backgroundTaskManager (Background Task Management)](js-apis-resourceschedule-backgroundTaskManager.md)
@@ -193,7 +209,7 @@
- [@ohos.WorkSchedulerExtensionAbility (Work Scheduler Callbacks)](js-apis-WorkSchedulerExtensionAbility.md)
- application
- [WorkSchedulerExtensionContext](js-apis-inner-application-WorkSchedulerExtensionContext.md)
-
+
- Security
- [@ohos.abilityAccessCtrl (Ability Access Control)](js-apis-abilityAccessCtrl.md)
- [@ohos.privacyManager (Privacy Management)](js-apis-privacyManager.md)
@@ -202,7 +218,6 @@
- [@ohos.security.huks (HUKS)](js-apis-huks.md)
- [@ohos.userIAM.faceAuth (Facial Authentication)](js-apis-useriam-faceauth.md)
- [@ohos.userIAM.userAuth (User Authentication)](js-apis-useriam-userauth.md)
- - [@system.cipher (Cipher Algorithm)](js-apis-system-cipher.md)
- security
- [PermissionRequestResult](js-apis-permissionrequestresult.md)
@@ -213,16 +228,15 @@
- [@ohos.data.dataShareResultSet (DataShare Result Set)](js-apis-data-DataShareResultSet.md)
- [@ohos.data.distributedDataObject (Distributed Data Object)](js-apis-data-distributedobject.md)
- [@ohos.data.distributedKVStore (Distributed KV Store)](js-apis-distributedKVStore.md)
- - [@ohos.data.preferences (Preferences)](js-apis-data-preferences.md)
+ - [@ohos.data.preferences (User Preferences)](js-apis-data-preferences.md)
- [@ohos.data.relationalStore (RDB Store)](js-apis-data-relationalStore.md)
- [@ohos.data.ValuesBucket (Value Bucket)](js-apis-data-valuesBucket.md)
- - data/rdb
- - [resultSet (Result Set)](js-apis-data-resultset.md)
- File Management
- [@ohos.file.environment (Directory Environment Capability)](js-apis-file-environment.md)
- [@ohos.file.fileAccess (User File Access and Management)](js-apis-fileAccess.md)
- [@ohos.file.fileExtensionInfo (User File Extension Information)](js-apis-fileExtensionInfo.md)
+ - [@ohos.file.fileUri (File URI)](js-apis-file-fileUri.md)
- [@ohos.file.fs (File Management)](js-apis-file-fs.md)
- [@ohos.file.hash (File Hash Processing)](js-apis-file-hash.md)
- [@ohos.file.picker (File Picker)](js-apis-file-picker.md)
@@ -231,7 +245,7 @@
- [@ohos.file.storageStatistics (Application Storage Statistics)](js-apis-file-storage-statistics.md)
- [@ohos.file.volumeManager (Volume Management)](js-apis-file-volumemanager.md)
- [@ohos.filemanagement.userFileManager (User Data Management)](js-apis-userFileManager.md)
- - [@ohos.multimedia.medialibrary (Media Library Management)](js-apis-medialibrary.md)
+ - [@ohos.fileShare (File Sharing)](js-apis-fileShare.md)
- Telephony Service
- [@ohos.contact (Contacts)](js-apis-contact.md)
@@ -251,9 +265,11 @@
- [@ohos.net.socket (Socket Connection)](js-apis-socket.md)
- [@ohos.net.webSocket (WebSocket Connection)](js-apis-webSocket.md)
- [@ohos.request (Upload and Download)](js-apis-request.md)
+ - [@ohos.net.mdns (mDNS Management)](js-apis-net-mdns.md)
- Connectivity
- - [@ohos.bluetooth (Bluetooth)](js-apis-bluetooth.md)
+ - [@ohos.bluetooth (Bluetooth)(To Be Deprecated Soon)](js-apis-bluetooth.md)
+ - [@ohos.bluetoothManager (Bluetooth)(js-apis-bluetoothManager.md)
- [@ohos.connectedTag (Active Tags)](js-apis-connectedTag.md)
- [@ohos.nfc.cardEmulation (Standard NFC Card Emulation)](js-apis-cardEmulation.md)
- [@ohos.nfc.controller (Standard NFC)](js-apis-nfcController.md)
@@ -261,8 +277,8 @@
- [@ohos.rpc (RPC)](js-apis-rpc.md)
- [@ohos.wifiManager (WLAN)](js-apis-wifiManager.md)
- [@ohos.wifiManagerExt (WLAN Extension)](js-apis-wifiManagerExt.md)
- - [@ohos.wifi (To Be Deprecated)](js-apis-wifi.md)
- - [@ohos.wifiext (To Be Deprecated)](js-apis-wifiext.md)
+ - [@ohos.wifi (WLAN)(To Be Deprecated Soon)](js-apis-wifi.md)
+ - [@ohos.wifiext (WLAN Extension)(To Be Deprecated Soon)](js-apis-wifiext.md)
- tag
- [nfctech (Standard NFC Technologies)](js-apis-nfctech.md)
- [tagSession (Standard NFC Tag Session)](js-apis-tagSession.md)
@@ -295,7 +311,7 @@
- [console (Log)](js-apis-logs.md)
- [Timer](js-apis-timer.md)
- application
- - [AccessibilityExtensionContext](js-apis-inner-application-accessibilityExtensionContext.md)
+ - [AccessibilityExtensionContext (Accessibility Extension Context)](js-apis-inner-application-accessibilityExtensionContext.md)
- imf
- [InputMethodCommon](js-apis-inputmethod-InputMethodCommon.md)
@@ -303,6 +319,7 @@
- [@ohos.batteryInfo (Battery Information)](js-apis-battery-info.md)
- [@ohos.batteryStatistics (Battery Statistics)](js-apis-batteryStatistics.md)
- [@ohos.brightness (Screen Brightness)](js-apis-brightness.md)
+ - [@ohos.charger (Charging Type)](js-apis-charger.md)
- [@ohos.deviceInfo (Device Information)](js-apis-device-info.md)
- [@ohos.distributedHardware.deviceManager (Device Management)](js-apis-device-manager.md)
- [@ohos.geoLocationManager (Geolocation Manager)](js-apis-geoLocationManager.md)
@@ -326,7 +343,7 @@
- [@ohos.systemParameterEnhance (System Parameter)](js-apis-system-parameterEnhance.md)
- [@ohos.thermal (Thermal Management)](js-apis-thermal.md)
- [@ohos.update (Update)](js-apis-update.md)
- - [@ohos.usbManager (USB Management)](js-apis-usbManager.md)
+ - [@ohos.usbManager (USB Manager)](js-apis-usbManager.md)
- [@ohos.vibrator (Vibrator)](js-apis-vibrator.md)
- Account Management
@@ -334,7 +351,7 @@
- [@ohos.account.distributedAccount (Distributed Account Management)](js-apis-distributed-account.md)
- [@ohos.account.osAccount (OS Account Management)](js-apis-osAccount.md)
-- Custom Management
+- Customization
- [@ohos.configPolicy (Configuration Policy)](js-apis-configPolicy.md)
- [@ohos.enterprise.accountManager (Account Management)](js-apis-enterprise-accountManager.md)
- [@ohos.enterprise.adminManager (Enterprise Device Management)](js-apis-enterprise-adminManager.md)
@@ -388,6 +405,7 @@
- [@ohos.fileio (File Management)](js-apis-fileio.md)
- [@ohos.geolocation (Geolocation)](js-apis-geolocation.md)
- [@ohos.hiAppEvent (Application Event Logging)](js-apis-hiappevent.md)
+ - [@ohos.multimedia.medialibrary (Media Library Management)](js-apis-medialibrary.md)
- [@ohos.prompt (Prompt)](js-apis-prompt.md)
- [@ohos.reminderAgent (Reminder Agent)](js-apis-reminderAgent.md)
- [@ohos.statfs (statfs)](js-apis-statfs.md)
@@ -399,6 +417,7 @@
- [@system.battery (Battery Information)](js-apis-system-battery.md)
- [@system.bluetooth (Bluetooth)](js-apis-system-bluetooth.md)
- [@system.brightness (Screen Brightness)](js-apis-system-brightness.md)
+ - [@system.cipher (Cipher Algorithm)](js-apis-system-cipher.md)
- [@system.configuration (Application Configuration)](js-apis-system-configuration.md)
- [@system.device (Device Information)](js-apis-system-device.md)
- [@system.fetch (Data Request)](js-apis-system-fetch.md)
@@ -428,3 +447,5 @@
- [PermissionDef](js-apis-bundle-PermissionDef.md)
- [remoteAbilityInfo](js-apis-bundle-remoteAbilityInfo.md)
- [shortcutInfo](js-apis-bundle-ShortcutInfo.md)
+ - data/rdb
+ - [resultSet (Result Set)](js-apis-data-resultset.md)
\ No newline at end of file
diff --git a/en/application-dev/reference/apis/commonEvent-definitions.md b/en/application-dev/reference/apis/commonEvent-definitions.md
index b7cfc06174bbd90c193b1e98d4aa5330597a4b8f..39aa5fa3df076dde861d8020f0066f0dadd6b800 100644
--- a/en/application-dev/reference/apis/commonEvent-definitions.md
+++ b/en/application-dev/reference/apis/commonEvent-definitions.md
@@ -59,7 +59,7 @@ Indicates that the device screen is on and the device is in interactive state.
- Required subscriber permissions: none
-## COMMON_EVENT_THERMAL_LEVEL_CHANGED8+
+## COMMON_EVENT_THERMAL_LEVEL_CHANGED8+
Indicates that the device's thermal level has changed.
- Value: **usual.event.THERMAL_LEVEL_CHANGED**
- Required subscriber permissions: none
@@ -810,7 +810,7 @@ Indicates that a USB device has been detached from the device functioning as a U
## COMMON_EVENT_DISK_BAD_REMOVAL
(Reserved, not supported yet) Indicates that an external storage device was removed without being unmounted.
-- Value: usual.event.data.DISK_BAD_REMOVAL
+- Value: **usual.event.data.DISK_BAD_REMOVAL**
- Required subscriber permissions: ohos.permission.STORAGE_MANAGER
@@ -826,33 +826,33 @@ Indicates that a USB device has been detached from the device functioning as a U
- Required subscriber permissions: ohos.permission.STORAGE_MANAGER
-## COMMON_EVENT_VOLUME_REMOVED9+
+## COMMON_EVENT_VOLUME_REMOVED9+
Indicates that an external storage device was removed.
- Value: **usual.event.data.VOLUME_REMOVED**
- Required subscriber permissions: ohos.permission.STORAGE_MANAGER
-## COMMON_EVENT_VOLUME_UNMOUNTED9+
+## COMMON_EVENT_VOLUME_UNMOUNTED9+
Indicates that an external storage device was unmounted.
- Value: **usual.event.data.VOLUME_UNMOUNTED**
- Required subscriber permissions: ohos.permission.STORAGE_MANAGER
-## COMMON_EVENT_VOLUME_MOUNTED9+
+## COMMON_EVENT_VOLUME_MOUNTED9+
Indicates that an external storage device was mounted.
- Value: **usual.event.data.VOLUME_MOUNTED**
- Required subscriber permissions: ohos.permission.STORAGE_MANAGER
-## COMMON_EVENT_VOLUME_BAD_REMOVAL9+
+## COMMON_EVENT_VOLUME_BAD_REMOVAL9+
Indicates that an external storage device was removed without being unmounted.
- Value: **usual.event.data.VOLUME_BAD_REMOVAL**
- Required subscriber permissions: ohos.permission.STORAGE_MANAGER
-## COMMON_EVENT_VOLUME_EJECT9+
+## COMMON_EVENT_VOLUME_EJECT9+
Indicates that an external storage device was ejected (at the software level).
-- Value: usual.event.data.VOLUME_EJECT
+- **Value: usual.event.data.VOLUME_EJECT**
- Required subscriber permissions: ohos.permission.STORAGE_MANAGER
@@ -880,25 +880,30 @@ Indicates that the airplane mode of the device has changed.
- Required subscriber permissions: none
-## COMMON_EVENT_SPLIT_SCREEN8+
+## COMMON_EVENT_SPLIT_SCREEN8+
Indicates that the screen has been split.
- Value: **usual.event.SPLIT_SCREEN**
- Required subscriber permissions: none
-## COMMON_EVENT_SLOT_CHANGE9+
+## COMMON_EVENT_SLOT_CHANGE9+
Indicates that the notification slot has been updated.
- Value: **usual.event.SLOT_CHANGE**
- Required subscriber permissions: ohos.permission.NOTIFICATION_CONTROLLER
-## COMMON_EVENT_SPN_INFO_CHANGED9+
+## COMMON_EVENT_SPN_INFO_CHANGED9+
Indicates that the SPN displayed has been updated.
- Value: **usual.event.SPN_INFO_CHANGED**
- Required subscriber permissions: none
-## COMMON_EVENT_QUICK_FIX_APPLY_RESULT9+
+## COMMON_EVENT_QUICK_FIX_APPLY_RESULT9+
Indicates the result of applying a quick fix to the application.
- Value: **usual.event.QUICK_FIX_APPLY_RESULT**
- Required subscriber permissions: none
+
+## COMMON_EVENT_USER_INFO_UPDATED9+
+Indicates that the user information has been updated.
+- Value: **usual.event.USER_INFO_UPDATED**
+- Required subscriber permissions: none
diff --git a/en/application-dev/reference/apis/commonEventManager-definitions.md b/en/application-dev/reference/apis/commonEventManager-definitions.md
index 3701910204a1a924986d9d6ff8ae144886cc5856..4d400882bb09448ae379336329c873651601060e 100644
--- a/en/application-dev/reference/apis/commonEventManager-definitions.md
+++ b/en/application-dev/reference/apis/commonEventManager-definitions.md
@@ -59,17 +59,19 @@ Indicates that the device screen is on and the device is in interactive state.
- Required subscriber permissions: none
-## COMMON_EVENT_THERMAL_LEVEL_CHANGED8+
+## COMMON_EVENT_THERMAL_LEVEL_CHANGED8+
Indicates that the device's thermal level has changed.
- Value: **usual.event.THERMAL_LEVEL_CHANGED**
- Required subscriber permissions: none
-## COMMON_EVENT_USER_PRESENT
+## COMMON_EVENT_USER_PRESENT(deprecated)
(Reserved, not supported yet) Indicates that the user unlocks the device.
- Value: **usual.event.USER_PRESENT**
- Required subscriber permissions: none
-
+> NOTE
+>
+> This API is deprecated since API version 10.
## COMMON_EVENT_TIME_TICK
Indicates that the system time has changed as time ticks by.
@@ -658,6 +660,10 @@ Indicates that the system starts charging the battery.
- Value: **usual.event.CHARGING**
- Required subscriber permissions: none
+## COMMON_EVENT_CHARGE_TYPE_CHANGED
+Indicates that the system charging type has changed. This event is available only for system applications.
+- Value: **usual.event.CHARGE_TYPE_CHANGED**
+- Required subscriber permissions: none
## COMMON_EVENT_DEVICE_IDLE_MODE_CHANGED
(Reserved, not supported yet) Indicates that the system idle mode has changed.
@@ -845,31 +851,31 @@ Indicates that a USB device has been detached from the device functioning as a U
- Required subscriber permissions: ohos.permission.STORAGE_MANAGER
-## COMMON_EVENT_VOLUME_REMOVED9+
+## COMMON_EVENT_VOLUME_REMOVED9+
Indicates that an external storage device was removed.
- Value: **usual.event.data.VOLUME_REMOVED**
- Required subscriber permissions: ohos.permission.STORAGE_MANAGER
-## COMMON_EVENT_VOLUME_UNMOUNTED9+
+## COMMON_EVENT_VOLUME_UNMOUNTED9+
Indicates that an external storage device was unmounted.
- Value: **usual.event.data.VOLUME_UNMOUNTED**
- Required subscriber permissions: ohos.permission.STORAGE_MANAGER
-## COMMON_EVENT_VOLUME_MOUNTED9+
+## COMMON_EVENT_VOLUME_MOUNTED9+
Indicates that an external storage device was mounted.
- Value: **usual.event.data.VOLUME_MOUNTED**
- Required subscriber permissions: ohos.permission.STORAGE_MANAGER
-## COMMON_EVENT_VOLUME_BAD_REMOVAL9+
+## COMMON_EVENT_VOLUME_BAD_REMOVAL9+
Indicates that an external storage device was removed without being unmounted.
- Value: **usual.event.data.VOLUME_BAD_REMOVAL**
- Required subscriber permissions: ohos.permission.STORAGE_MANAGER
-## COMMON_EVENT_VOLUME_EJECT9+
+## COMMON_EVENT_VOLUME_EJECT9+
Indicates that an external storage device was ejected (at the software level).
- Value: usual.event.data.VOLUME_EJECT
- Required subscriber permissions: ohos.permission.STORAGE_MANAGER
@@ -905,23 +911,136 @@ Indicates that the screen has been split.
- Required subscriber permissions: ohos.permission.RECEIVER_SPLIT_SCREEN
-## COMMON_EVENT_SLOT_CHANGE9+
+## COMMON_EVENT_SLOT_CHANGE9+
Indicates that the notification slot has been updated.
- Value: **usual.event.SLOT_CHANGE**
- Required subscriber permissions: ohos.permission.NOTIFICATION_CONTROLLER
-## COMMON_EVENT_SPN_INFO_CHANGED9+
+## COMMON_EVENT_SPN_INFO_CHANGED9+
Indicates that the SPN displayed has been updated.
- Value: **usual.event.SPN_INFO_CHANGED**
- Required subscriber permissions: none
-## COMMON_EVENT_QUICK_FIX_APPLY_RESULT9+
+## COMMON_EVENT_QUICK_FIX_APPLY_RESULT9+
Indicates the result of applying a quick fix to the application.
- Value: **usual.event.QUICK_FIX_APPLY_RESULT**
- Required subscriber permissions: none
-## COMMON_EVENT_HTTP_PROXY_CHANGE10+
+## COMMON_EVENT_HTTP_PROXY_CHANGE10+
Indicates that the HTTP proxy configuration has changed.
- Value: **usual.event.HTTP_PROXY_CHANGE**
- Required subscriber permissions: none
+
+## COMMON_EVENT_SIM_STATE_CHANGED10+
+Indicates that the SIM card state has changed.
+- Value: **usual.event.SIM_STATE_CHANGED**
+- Required subscriber permissions: none
+
+## COMMON_EVENT_SMS_RECEIVED_COMPLETED10+
+Indicates that the SMS message is received.
+- Value: **usual.event.SMS_RECEIVED_COMPLETED**
+- Required subscriber permissions: ohos.permission.RECEIVE_SMS
+
+## COMMON_EVENT_SMS_EMERGENCY_CB_RECEIVE_COMPLETED10+
+Indicates that an emergency cell broadcast message is received.
+- Value: **usual.event.SMS_EMERGENCY_CB_RECEIVE_COMPLETED**
+- Required subscriber permissions: ohos.permission.RECEIVE_SMS
+
+## COMMON_EVENT_SMS_CB_RECEIVE_COMPLETED10+
+Indicates that a cell broadcast message is received.
+- Value: **usual.event.SMS_CB_RECEIVE_COMPLETED**
+- Required subscriber permissions: ohos.permission.RECEIVE_SMS
+
+## COMMON_EVENT_STK_COMMAND10+
+(Reserved, not supported yet) Indicates the STK command.
+- Value: **usual.event.STK_COMMAND**
+- Required subscriber permissions: none
+
+## COMMON_EVENT_STK_SESSION_END10+
+(Reserved, not supported yet) Indicates that an STK session ends.
+- Value: **usual.event.STK_SESSION_END**
+- Required subscriber permissions: none
+
+## COMMON_EVENT_STK_CARD_STATE_CHANGED10+
+(Reserved, not supported yet) Indicates that the STK card state has changed.
+- Value: **usual.event.STK_CARD_STATE_CHANGED**
+- Required subscriber permissions: ohos.permission
+
+## COMMON_EVENT_STK_ALPHA_IDENTIFIER10+
+(Reserved, not supported yet) Indicates the STK alpha indicator.
+- Value: **usual.event.STK_ALPHA_IDENTIFIER**
+- Required subscriber permissions: none
+
+## COMMON_EVENT_SMS_WAPPUSH_RECEIVE_COMPLETED10+
+Indicates that a WAP push message is received.
+- Value: **usual.event.SMS_WAPPUSH_RECEIVE_COMPLETED**
+- Required subscriber permissions: ohos.permission.RECEIVE_SMS
+
+## COMMON_EVENT_OPERATOR_CONFIG_CHANGED10+
+Indicates that the carrier configuration has been updated.
+- Value: **usual.event.OPERATOR_CONFIG_CHANGED**
+- Required subscriber permissions: none
+
+## COMMON_EVENT_SIM_CARD_DEFAULT_SMS_SUBSCRIPTION_CHANGED10+
+Indicates that the default SIM card for the SMS service has changed.
+- Value: **usual.event.DEFAULT_SMS_SUBSCRIPTION_CHANGED**
+- Required subscriber permissions: none
+
+## COMMON_EVENT_SIM_CARD_DEFAULT_DATA_SUBSCRIPTION_CHANGED10+
+Indicates that the default SIM card for the mobile data service has changed.
+- Value: **usual.event.DEFAULT_DATA_SUBSCRIPTION_CHANGED**
+- Required subscriber permissions: none
+
+## COMMON_EVENT_SIM_CARD_DEFAULT_MAIN_SUBSCRIPTION_CHANGED10+
+Indicates that the default primary SIM card has changed.
+- Value: **usual.event.SIM.DEFAULT_MAIN_SUBSCRIPTION_CHANGED**
+- Required subscriber permissions: none
+
+## COMMON_EVENT_SIM_CARD_DEFAULT_VOICE_SUBSCRIPTION_CHANGED10+
+Indicates that the default SIM card for the voice service has changed.
+- Value: **usual.event.DEFAULT_VOICE_SUBSCRIPTION_CHANGED**
+- Required subscriber permissions: none
+
+## COMMON_EVENT_CALL_STATE_CHANGED10+
+Indicates that the call state has changed.
+- Value: **usual.event.CALL_STATE_CHANGED**
+- Required subscriber permissions: ohos.permission.GET_TELEPHONY_STATE
+
+## COMMON_EVENT_CELLULAR_DATA_STATE_CHANGED10+
+Indicates that the cellular data state has changed.
+- Value: **usual.event.CELLULAR_DATA_STATE_CHANGED**
+- Required subscriber permissions: none
+
+## COMMON_EVENT_NETWORK_STATE_CHANGED10+
+Indicates that the network state has changed.
+- Value: **usual.event.NETWORK_STATE_CHANGED**
+- Required subscriber permissions: none
+
+## COMMON_EVENT_SIGNAL_INFO_CHANGED10+
+Indicates that the signal information is updated.
+- Value: **usual.event.SIGNAL_INFO_CHANGED**
+- Required subscriber permissions: none
+
+## COMMON_EVENT_INCOMING_CALL_MISSED10+
+Indicates a missed call.
+- Value: **usual.event.INCOMING_CALL_MISSED**
+- Required subscriber permissions: ohos.permission.GET_TELEPHONY_STATE
+
+## COMMON_EVENT_RADIO_STATE_CHANGE10+
+Indicates that the power-on and power-off status of the modem has changed.
+- Value: **usual.event.RADIO_STATE_CHANGE**
+
+## COMMON_EVENT_SCREEN_LOCKED 10+
+
+Indicates that the screen is locked.
+
+- Value: **usual.event.SCREEN_LOCKED**
+- Required subscriber permissions: none
+
+## COMMON_EVENT_SCREEN_UNLOCKED10+
+
+Indicates that the screen is unlocked.
+
+- Value: **usual.event.SCREEN_UNLOCKED**
+- Required subscriber permissions: none
diff --git a/en/application-dev/reference/apis/figures/Colorsucker.png b/en/application-dev/reference/apis/figures/Colorsucker.png
new file mode 100644
index 0000000000000000000000000000000000000000..40e19e94e129682fdeb461cceef0f0a57c64d66d
Binary files /dev/null and b/en/application-dev/reference/apis/figures/Colorsucker.png differ
diff --git a/en/application-dev/reference/apis/figures/Copy.png b/en/application-dev/reference/apis/figures/Copy.png
new file mode 100644
index 0000000000000000000000000000000000000000..212517131bf176661ae85c7513def022dbb50559
Binary files /dev/null and b/en/application-dev/reference/apis/figures/Copy.png differ
diff --git a/en/application-dev/reference/apis/figures/Cross.png b/en/application-dev/reference/apis/figures/Cross.png
new file mode 100644
index 0000000000000000000000000000000000000000..58625855d1cd96ea8a29ab9c3c201d90ac717e83
Binary files /dev/null and b/en/application-dev/reference/apis/figures/Cross.png differ
diff --git a/en/application-dev/reference/apis/figures/Default.png b/en/application-dev/reference/apis/figures/Default.png
new file mode 100644
index 0000000000000000000000000000000000000000..6308171fe9d612050376f6a5dfdc870e51bc92db
Binary files /dev/null and b/en/application-dev/reference/apis/figures/Default.png differ
diff --git a/en/application-dev/reference/apis/figures/East.png b/en/application-dev/reference/apis/figures/East.png
new file mode 100644
index 0000000000000000000000000000000000000000..4942bc948a17e78c68538ccc3ae886bc0a548737
Binary files /dev/null and b/en/application-dev/reference/apis/figures/East.png differ
diff --git a/en/application-dev/reference/apis/figures/Forbid.png b/en/application-dev/reference/apis/figures/Forbid.png
new file mode 100644
index 0000000000000000000000000000000000000000..c5c43d4b4b8aaf6d53931586e519a583d064fec7
Binary files /dev/null and b/en/application-dev/reference/apis/figures/Forbid.png differ
diff --git a/en/application-dev/reference/apis/figures/Hand_Grabbing.png b/en/application-dev/reference/apis/figures/Hand_Grabbing.png
new file mode 100644
index 0000000000000000000000000000000000000000..09ab3121d15e27a975fbaa228aadb2399e4492b9
Binary files /dev/null and b/en/application-dev/reference/apis/figures/Hand_Grabbing.png differ
diff --git a/en/application-dev/reference/apis/figures/Hand_Open.png b/en/application-dev/reference/apis/figures/Hand_Open.png
new file mode 100644
index 0000000000000000000000000000000000000000..e1cb7a972ec2d372f0d75cbe80159c4a66e74e10
Binary files /dev/null and b/en/application-dev/reference/apis/figures/Hand_Open.png differ
diff --git a/en/application-dev/reference/apis/figures/Hand_Pointing.png b/en/application-dev/reference/apis/figures/Hand_Pointing.png
new file mode 100644
index 0000000000000000000000000000000000000000..f0daa0dad6154a1846fb9fe4b7f441b3ab6f8b5b
Binary files /dev/null and b/en/application-dev/reference/apis/figures/Hand_Pointing.png differ
diff --git a/en/application-dev/reference/apis/figures/Help.png b/en/application-dev/reference/apis/figures/Help.png
new file mode 100644
index 0000000000000000000000000000000000000000..ffea2f1c072f1682ca8e837ddb947352a553917e
Binary files /dev/null and b/en/application-dev/reference/apis/figures/Help.png differ
diff --git a/en/application-dev/reference/apis/figures/MID_Btn_East.png b/en/application-dev/reference/apis/figures/MID_Btn_East.png
new file mode 100644
index 0000000000000000000000000000000000000000..921cd4ceea8d97ffb6d4c45008d6428cda998cce
Binary files /dev/null and b/en/application-dev/reference/apis/figures/MID_Btn_East.png differ
diff --git a/en/application-dev/reference/apis/figures/MID_Btn_North.png b/en/application-dev/reference/apis/figures/MID_Btn_North.png
new file mode 100644
index 0000000000000000000000000000000000000000..5769575ddb435f5e8f5f8993d9edc13749376293
Binary files /dev/null and b/en/application-dev/reference/apis/figures/MID_Btn_North.png differ
diff --git a/en/application-dev/reference/apis/figures/MID_Btn_North_East.png b/en/application-dev/reference/apis/figures/MID_Btn_North_East.png
new file mode 100644
index 0000000000000000000000000000000000000000..3daf141241dec309c98ae10266bb153af163f3d9
Binary files /dev/null and b/en/application-dev/reference/apis/figures/MID_Btn_North_East.png differ
diff --git a/en/application-dev/reference/apis/figures/MID_Btn_North_South.png b/en/application-dev/reference/apis/figures/MID_Btn_North_South.png
new file mode 100644
index 0000000000000000000000000000000000000000..1f56c4cd8f1498293f5fc4a5ab2c321159fb07dd
Binary files /dev/null and b/en/application-dev/reference/apis/figures/MID_Btn_North_South.png differ
diff --git a/en/application-dev/reference/apis/figures/MID_Btn_North_South_West_East.png b/en/application-dev/reference/apis/figures/MID_Btn_North_South_West_East.png
new file mode 100644
index 0000000000000000000000000000000000000000..b45dbde27e59121bdfc4e1752759176fb835027c
Binary files /dev/null and b/en/application-dev/reference/apis/figures/MID_Btn_North_South_West_East.png differ
diff --git a/en/application-dev/reference/apis/figures/MID_Btn_North_West.png b/en/application-dev/reference/apis/figures/MID_Btn_North_West.png
new file mode 100644
index 0000000000000000000000000000000000000000..bde82d08f7a098106b4f4c31d55a84a989e25a8d
Binary files /dev/null and b/en/application-dev/reference/apis/figures/MID_Btn_North_West.png differ
diff --git a/en/application-dev/reference/apis/figures/MID_Btn_South.png b/en/application-dev/reference/apis/figures/MID_Btn_South.png
new file mode 100644
index 0000000000000000000000000000000000000000..e7d5afb6f8f8b1b2939b9e18bdb8b8b3d9729f4d
Binary files /dev/null and b/en/application-dev/reference/apis/figures/MID_Btn_South.png differ
diff --git a/en/application-dev/reference/apis/figures/MID_Btn_South_East.png b/en/application-dev/reference/apis/figures/MID_Btn_South_East.png
new file mode 100644
index 0000000000000000000000000000000000000000..44284a6e04a19ca8453b46ea81db099ad84cfaa2
Binary files /dev/null and b/en/application-dev/reference/apis/figures/MID_Btn_South_East.png differ
diff --git a/en/application-dev/reference/apis/figures/MID_Btn_South_West.png b/en/application-dev/reference/apis/figures/MID_Btn_South_West.png
new file mode 100644
index 0000000000000000000000000000000000000000..c8632f09160c51ca573d58d3ffb1370058b880ce
Binary files /dev/null and b/en/application-dev/reference/apis/figures/MID_Btn_South_West.png differ
diff --git a/en/application-dev/reference/apis/figures/MID_Btn_West.png b/en/application-dev/reference/apis/figures/MID_Btn_West.png
new file mode 100644
index 0000000000000000000000000000000000000000..7460bc18d63e000689755b39b8ead3c3609ee4f5
Binary files /dev/null and b/en/application-dev/reference/apis/figures/MID_Btn_West.png differ
diff --git a/en/application-dev/reference/apis/figures/Move.png b/en/application-dev/reference/apis/figures/Move.png
new file mode 100644
index 0000000000000000000000000000000000000000..00f64e54dca0d0731b595b4ddc9e0f7294c40c72
Binary files /dev/null and b/en/application-dev/reference/apis/figures/Move.png differ
diff --git a/en/application-dev/reference/apis/figures/North.png b/en/application-dev/reference/apis/figures/North.png
new file mode 100644
index 0000000000000000000000000000000000000000..b022ac2e92d4cfb07efde7f3bf4b7ada8454e594
Binary files /dev/null and b/en/application-dev/reference/apis/figures/North.png differ
diff --git a/en/application-dev/reference/apis/figures/North_East.png b/en/application-dev/reference/apis/figures/North_East.png
new file mode 100644
index 0000000000000000000000000000000000000000..f6134237f38cd681b319c95bf1b77017bc1524b4
Binary files /dev/null and b/en/application-dev/reference/apis/figures/North_East.png differ
diff --git a/en/application-dev/reference/apis/figures/North_East_South_West.png b/en/application-dev/reference/apis/figures/North_East_South_West.png
new file mode 100644
index 0000000000000000000000000000000000000000..908886aeb3f8df976bb67b2261e8e52e7222e622
Binary files /dev/null and b/en/application-dev/reference/apis/figures/North_East_South_West.png differ
diff --git a/en/application-dev/reference/apis/figures/North_South.png b/en/application-dev/reference/apis/figures/North_South.png
new file mode 100644
index 0000000000000000000000000000000000000000..b15678a6b178ca0d9b13f7c7f58d025ab7a1ce12
Binary files /dev/null and b/en/application-dev/reference/apis/figures/North_South.png differ
diff --git a/en/application-dev/reference/apis/figures/North_West.png b/en/application-dev/reference/apis/figures/North_West.png
new file mode 100644
index 0000000000000000000000000000000000000000..cfbe4c8910575c12afde4b5904d79b5beda0c162
Binary files /dev/null and b/en/application-dev/reference/apis/figures/North_West.png differ
diff --git a/en/application-dev/reference/apis/figures/North_West_South_East.png b/en/application-dev/reference/apis/figures/North_West_South_East.png
new file mode 100644
index 0000000000000000000000000000000000000000..09fa728fbb45082a0524c284b8906b91d7b3a6f7
Binary files /dev/null and b/en/application-dev/reference/apis/figures/North_West_South_East.png differ
diff --git a/en/application-dev/reference/apis/figures/Resize_Left_Right.png b/en/application-dev/reference/apis/figures/Resize_Left_Right.png
new file mode 100644
index 0000000000000000000000000000000000000000..83e7671e3ffea65260bdb36d8b392fa78d55cd4e
Binary files /dev/null and b/en/application-dev/reference/apis/figures/Resize_Left_Right.png differ
diff --git a/en/application-dev/reference/apis/figures/Resize_Up_Down.png b/en/application-dev/reference/apis/figures/Resize_Up_Down.png
new file mode 100644
index 0000000000000000000000000000000000000000..db8bccf89b6e5260db3875a22b5200fabd30c23c
Binary files /dev/null and b/en/application-dev/reference/apis/figures/Resize_Up_Down.png differ
diff --git a/en/application-dev/reference/apis/figures/Screenshot_Cross.png b/en/application-dev/reference/apis/figures/Screenshot_Cross.png
new file mode 100644
index 0000000000000000000000000000000000000000..27460c082507e71082d11cd8a20eee2fc24da28d
Binary files /dev/null and b/en/application-dev/reference/apis/figures/Screenshot_Cross.png differ
diff --git a/en/application-dev/reference/apis/figures/Screenshot_Cursor.png b/en/application-dev/reference/apis/figures/Screenshot_Cursor.png
new file mode 100644
index 0000000000000000000000000000000000000000..71abea4ca351988a92b8a5b2b2228321df31aecc
Binary files /dev/null and b/en/application-dev/reference/apis/figures/Screenshot_Cursor.png differ
diff --git a/en/application-dev/reference/apis/figures/South.png b/en/application-dev/reference/apis/figures/South.png
new file mode 100644
index 0000000000000000000000000000000000000000..205f5cf5f59ce8318357e168eee0d66c119c233d
Binary files /dev/null and b/en/application-dev/reference/apis/figures/South.png differ
diff --git a/en/application-dev/reference/apis/figures/South_East.png b/en/application-dev/reference/apis/figures/South_East.png
new file mode 100644
index 0000000000000000000000000000000000000000..f4a70d2d068271bfe10e4ce724ae27e4e5ba96d9
Binary files /dev/null and b/en/application-dev/reference/apis/figures/South_East.png differ
diff --git a/en/application-dev/reference/apis/figures/South_West.png b/en/application-dev/reference/apis/figures/South_West.png
new file mode 100644
index 0000000000000000000000000000000000000000..2ae8e9a9fa396bb6ed0f385b7b99b66830357a40
Binary files /dev/null and b/en/application-dev/reference/apis/figures/South_West.png differ
diff --git a/en/application-dev/reference/apis/figures/Text_Cursor.png b/en/application-dev/reference/apis/figures/Text_Cursor.png
new file mode 100644
index 0000000000000000000000000000000000000000..7cd8d2200bc7455e562da003069702832db4eb20
Binary files /dev/null and b/en/application-dev/reference/apis/figures/Text_Cursor.png differ
diff --git a/en/application-dev/reference/apis/figures/West.png b/en/application-dev/reference/apis/figures/West.png
new file mode 100644
index 0000000000000000000000000000000000000000..2cad91aca31f2e2b257c523e80e6fc2d71fa2cee
Binary files /dev/null and b/en/application-dev/reference/apis/figures/West.png differ
diff --git a/en/application-dev/reference/apis/figures/West_East.png b/en/application-dev/reference/apis/figures/West_East.png
new file mode 100644
index 0000000000000000000000000000000000000000..6be4aa9d05f22a10cd00fa6aec36f95aee2b332d
Binary files /dev/null and b/en/application-dev/reference/apis/figures/West_East.png differ
diff --git a/en/application-dev/reference/apis/figures/Zoom_In.png b/en/application-dev/reference/apis/figures/Zoom_In.png
new file mode 100644
index 0000000000000000000000000000000000000000..2e928ec070fcd05a44cd9b1abd041128287b0528
Binary files /dev/null and b/en/application-dev/reference/apis/figures/Zoom_In.png differ
diff --git a/en/application-dev/reference/apis/figures/Zoom_Out.png b/en/application-dev/reference/apis/figures/Zoom_Out.png
new file mode 100644
index 0000000000000000000000000000000000000000..d675d0e517ba436724540a39f60dfa75c256f0d0
Binary files /dev/null and b/en/application-dev/reference/apis/figures/Zoom_Out.png differ
diff --git a/en/application-dev/reference/apis/figures/en-us_image_Average_Color.png b/en/application-dev/reference/apis/figures/en-us_image_Average_Color.png
new file mode 100644
index 0000000000000000000000000000000000000000..db2d6dca8a84f09b59aaa1affb5caf5deb289669
Binary files /dev/null and b/en/application-dev/reference/apis/figures/en-us_image_Average_Color.png differ
diff --git a/en/application-dev/reference/apis/figures/en-us_image_Highest_Saturation_Color.png b/en/application-dev/reference/apis/figures/en-us_image_Highest_Saturation_Color.png
new file mode 100644
index 0000000000000000000000000000000000000000..6bf7c7ba71bee89b092cdf9a8e6a5e786b8e389b
Binary files /dev/null and b/en/application-dev/reference/apis/figures/en-us_image_Highest_Saturation_Color.png differ
diff --git a/en/application-dev/reference/apis/figures/en-us_image_Largest_Proportion_Color.png b/en/application-dev/reference/apis/figures/en-us_image_Largest_Proportion_Color.png
new file mode 100644
index 0000000000000000000000000000000000000000..93f347b1abf77970d9f84569423f0ea1673ecf9a
Binary files /dev/null and b/en/application-dev/reference/apis/figures/en-us_image_Largest_Proportion_Color.png differ
diff --git a/en/application-dev/reference/apis/js-apis-EnterpriseAdminExtensionAbility.md b/en/application-dev/reference/apis/js-apis-EnterpriseAdminExtensionAbility.md
index a55ab990ef39072d83989526e66723eab794ca63..3b42c32bc9e19c19810017a2a7d7cab637619dc6 100644
--- a/en/application-dev/reference/apis/js-apis-EnterpriseAdminExtensionAbility.md
+++ b/en/application-dev/reference/apis/js-apis-EnterpriseAdminExtensionAbility.md
@@ -105,3 +105,55 @@ export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbil
}
};
```
+
+## EnterpriseAdminExtensionAbility.onAppStart10+
+
+onAppStart(bundleName: string): void
+
+Called when an application is started.
+
+**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
+
+**System API**: This is a system API.
+
+**Parameters**
+
+| Parameter | Type | Mandatory | Description |
+| ----- | ----------------------------------- | ---- | ------- |
+| bundleName | string | Yes | Bundle name of the application started.|
+
+**Example**
+
+```ts
+export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbility {
+ onAppStart(bundleName: string) {
+ console.log("started bundle name: " + bundleName);
+ }
+};
+```
+
+## EnterpriseAdminExtensionAbility.onAppStop10+
+
+onAppStop(bundleName: string): void
+
+Called when an application is stopped.
+
+**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
+
+**System API**: This is a system API.
+
+**Parameters**
+
+| Parameter | Type | Mandatory | Description |
+| ----- | ----------------------------------- | ---- | ------- |
+| bundleName | string | Yes | Bundle name of the application stopped.|
+
+**Example**
+
+```ts
+export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbility {
+ onAppStop(bundleName: string) {
+ console.log("stopped bundle name: " + bundleName);
+ }
+};
+```
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 776faa162b5178cec3bf003aedc018c17ab17084..55074a510f56e2580d8e57da59ca72bb3209876f 100644
--- a/en/application-dev/reference/apis/js-apis-ability-wantConstant.md
+++ b/en/application-dev/reference/apis/js-apis-ability-wantConstant.md
@@ -46,13 +46,6 @@ Enumerates the action constants of the **Want** object. **action** specifies the
| ACTION_FILE_SELECT7+ | ohos.action.fileSelect | Action of selecting a file. |
| PARAMS_STREAM7+ | ability.params.stream | URI of the data stream associated with the target when the data is sent. The value must be an array of the string type. |
| ACTION_APP_ACCOUNT_OAUTH 8+ | ohos.account.appAccount.action.oauth | Action of providing the OAuth service. |
-| ACTION_APP_ACCOUNT_AUTH 9+ | account.appAccount.action.auth | Action of providing the authentication service. |
-| ACTION_MARKET_DOWNLOAD 9+ | ohos.want.action.marketDownload | Action of downloading an application from the application market.
**System API**: This is a system API and cannot be called by third-party applications. |
-| ACTION_MARKET_CROWDTEST 9+ | ohos.want.action.marketCrowdTest | Action of crowdtesting an application from the application market.
**System API**: This is a system API and cannot be called by third-party applications. |
-| DLP_PARAMS_SANDBOX9+ |ohos.dlp.params.sandbox | Action of obtaining the sandbox flag.
**System API**: This is a system API and cannot be called by third-party applications. |
-| DLP_PARAMS_BUNDLE_NAME9+ |ohos.dlp.params.bundleName |Action of obtaining the DLP bundle name.
**System API**: This is a system API and cannot be called by third-party applications. |
-| DLP_PARAMS_MODULE_NAME9+ |ohos.dlp.params.moduleName |Action of obtaining the DLP module name.
**System API**: This is a system API and cannot be called by third-party applications. |
-| DLP_PARAMS_ABILITY_NAME9+ |ohos.dlp.params.abilityName |Action of obtaining the DLP ability name.
**System API**: This is a system API and cannot be called by third-party applications. |
| DLP_PARAMS_INDEX9+ |ohos.dlp.params.index |Action of obtaining the DLP index.
**System API**: This is a system API and cannot be called by third-party applications. |
## wantConstant.Entity
@@ -72,7 +65,7 @@ Enumerates the entity constants of the **Want** object. **entity** specifies add
## wantConstant.Flags
-Enumerates the flags that specify how the Want will be handled.
+ Enumerates the flags that specify how the Want will be handled.
**System capability**: SystemCapability.Ability.AbilityBase
@@ -91,6 +84,6 @@ Enumerates the flags that specify how the Want will be handled.
| FLAG_ABILITY_CONTINUATION_REVERSIBLE | 0x00000400 | Indicates that ability continuation is reversible.
**System API**: This is a system API and cannot be called by third-party applications. |
| FLAG_INSTALL_ON_DEMAND | 0x00000800 | Indicates that the specific ability will be installed if it has not been installed. |
| FLAG_INSTALL_WITH_BACKGROUND_MODE | 0x80000000 | Indicates that the specific ability will be installed in the background if it has not been installed. |
-| FLAG_ABILITY_CLEAR_MISSION | 0x00008000 | Clears other operation missions. This flag can be set for the **Want** object in the **startAbility** API passed to [ohos.app.Context](js-apis-ability-context.md) and must be used together with **flag_ABILITY_NEW_MISSION**.|
+| FLAG_ABILITY_CLEAR_MISSION | 0x00008000 | Clears other operation missions. This flag can be set for **Want** in the [startAbility](js-apis-ability-featureAbility.md#startability) API passed to the FeatureAbility module. It must be used together with **flag_ABILITY_NEW_MISSION**. |
| FLAG_ABILITY_NEW_MISSION | 0x10000000 | Creates a mission on the history mission stack. |
| FLAG_ABILITY_MISSION_TOP | 0x20000000 | Reuses an ability instance if it is on the top of an existing mission stack; creates an ability instance otherwise.|
diff --git a/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md b/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md
index 54cea921d80648b17fe5384e4ea9e57336d32fc1..d4b34e125d2d723f1825aca53a801b1a729c5b9b 100644
--- a/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md
+++ b/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md
@@ -64,7 +64,7 @@ For details about the error codes, see [Application Access Control Error Codes](
| ID| Error Message|
| -------- | -------- |
-| 12100001 | The parameter is invalid. The tokenID is 0, or the string size of permissionName is larger than 256. |
+| 12100001 | The parameter is invalid. The tokenID is 0, or the permissionName is greater than 256 bytes. |
**Example**
@@ -111,7 +111,7 @@ For details about the error codes, see [Application Access Control Error Codes](
| ID| Error Message|
| -------- | -------- |
-| 12100001 | The parameter is invalid. The tokenID is 0, or the string size of permissionName is larger than 256. |
+| 12100001 | The parameter is invalid. The tokenID is 0, or the permissionName is greater than 256 bytes. |
**Example**
@@ -154,7 +154,7 @@ For details about the error codes, see [Application Access Control Error Codes](
| ID| Error Message|
| -------- | -------- |
-| 12100001 | The parameter is invalid. The tokenID is 0, or the string size of permissionName is larger than 256, or the flags value is invalid. |
+| 12100001 | The parameter is invalid. The tokenID is 0, the permissionName is greater than 256 bytes, or the flags value is invalid. |
| 12100002 | The specified tokenID does not exist. |
| 12100003 | The specified permission does not exist. |
| 12100006 | The application specified by the tokenID is not allowed to be granted with the specified permission. Either the application is a sandbox or the tokenID is from a remote device. |
@@ -206,7 +206,7 @@ For details about the error codes, see [Application Access Control Error Codes](
| ID| Error Message|
| -------- | -------- |
-| 12100001 | The parameter is invalid. The tokenID is 0, or the string size of permissionName is larger than 256, or the flags value is invalid. |
+| 12100001 | The parameter is invalid. The tokenID is 0, the permissionName is greater than 256 bytes, or the flags value is invalid. |
| 12100002 | TokenId does not exist. |
| 12100003 | Permission does not exist. |
| 12100006 | The application specified by the tokenID is not allowed to be granted with the specified permission. Either the application is a sandbox or the tokenID is from a remote device. |
@@ -265,7 +265,7 @@ For details about the error codes, see [Application Access Control Error Codes](
| ID| Error Message|
| -------- | -------- |
-| 12100001 | The parameter is invalid. The tokenID is 0, or the string size of permissionName is larger than 256, or the flags value is invalid. |
+| 12100001 | The parameter is invalid. The tokenID is 0, the permissionName is greater than 256 bytes, or the flags value is invalid. |
| 12100002 | The specified tokenID does not exist. |
| 12100003 | The specified permission does not exist. |
| 12100006 | The application specified by the tokenID is not allowed to be revoked with the specified permission. Either the application is a sandbox or the tokenID is from a remote device. |
@@ -317,7 +317,7 @@ For details about the error codes, see [Application Access Control Error Codes](
| ID| Error Message|
| -------- | -------- |
-| 12100001 | The parameter is invalid. The tokenID is 0, or the string size of permissionName is larger than 256, or the flags value is invalid. |
+| 12100001 | The parameter is invalid. The tokenID is 0, the permissionName is greater than 256 bytes, or the flags value is invalid. |
| 12100002 | TokenId does not exist. |
| 12100003 | Permission does not exist. |
| 12100006 | The application specified by the tokenID is not allowed to be revoked with the specified permission. Either the application is a sandbox or the tokenID is from a remote device. |
@@ -375,7 +375,7 @@ For details about the error codes, see [Application Access Control Error Codes](
| ID| Error Message|
| -------- | -------- |
-| 12100001 | The parameter is invalid. The tokenID is 0, or the string size of permissionName is larger than 256. |
+| 12100001 | The parameter is invalid. The tokenID is 0, or the permissionName is greater than 256 bytes. |
| 12100002 | The specified tokenID does not exist. |
| 12100003 | The specified permission does not exist. |
| 12100006 | The operation is not allowed. Either the application is a sandbox or the tokenID is from a remote device. |
@@ -452,7 +452,7 @@ For details about the error codes, see [Application Access Control Error Codes](
| ID| Error Message|
| -------- | -------- |
-| 12100001 | The parameter is invalid. The tokenID is 0, or the string size of permissionName is larger than 256. |
+| 12100001 | The parameter is invalid. The tokenID is 0, or the permissionName is greater than 256 bytes. |
| 12100004 | The interface is called repeatedly with the same input. |
| 12100005 | The registration time has exceeded the limitation. |
| 12100007 | Service is abnormal. |
@@ -504,8 +504,8 @@ For details about the error codes, see [Application Access Control Error Codes](
| ID| Error Message|
| -------- | -------- |
-| 12100001 | The parameter is invalid. The tokenID in list is all invalid, or the permissionName in list is all invalid. |
-| 12100004 | The API is not used together with "on()". |
+| 12100001 | The parameter is invalid. The tokenIDs or permissionNames in the list are all invalid. |
+| 12100004 | The interface is not used together with "on". |
| 12100007 | Service is abnormal. |
| 12100008 | Out of memory. |
@@ -532,7 +532,9 @@ verifyAccessToken(tokenID: number, permissionName: Permissions): Promise<Gran
Verifies whether a permission is granted to an application. This API uses a promise to return the result.
-> **NOTE**
You are advised to use [checkAccessToken](#checkaccesstoken9).
+> **NOTE**
+>
+> You are advised to use [checkAccessToken](#checkaccesstoken9).
**System capability**: SystemCapability.Security.AccessToken
@@ -619,7 +621,7 @@ Requests permissions from the user in a dialog box. This API uses a promise to
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| context | Context | Yes| Ability context of the application that requests the permissions. |
-| permissionList | Array<Permissions> | Yes| Permissions requested. For details about the permissions, see the [Application Permission List](../../security/permission-list.md). |
+| permissionList | Array<Permissions> | Yes| Permissions requested. For details about the permissions, see the [Application Permission List](../../security/permission-list.md).|
**Return value**
@@ -659,7 +661,9 @@ verifyAccessToken(tokenID: number, permissionName: string): Promise<GrantStat
Verifies whether a permission is granted to an application. This API uses a promise to return the result.
-> NOTE
This API is deprecated since API version 9. You are advised to use [checkAccessToken](#checkaccesstoken9).
+> **NOTE**
+>
+> This API is no longer maintained since API version 9. You are advised to use [checkAccessToken](#checkaccesstoken9).
**System capability**: SystemCapability.Security.AccessToken
diff --git a/en/application-dev/reference/apis/js-apis-app-ability-abilityConstant.md b/en/application-dev/reference/apis/js-apis-app-ability-abilityConstant.md
index 027f3a0e0f338e89b0a4783a3367506c09973992..ff1bbfa2187c2a5ad868e28e11e08ae1a77ed705 100644
--- a/en/application-dev/reference/apis/js-apis-app-ability-abilityConstant.md
+++ b/en/application-dev/reference/apis/js-apis-app-ability-abilityConstant.md
@@ -99,7 +99,7 @@ import UIAbility from '@ohos.app.ability.UIAbility';
class MyAbility extends UIAbility {
onContinue(wantParam) {
- return AbilityConstant.OnConinueResult.AGREE;
+ return AbilityConstant.OnContinueResult.AGREE;
}
}
```
@@ -132,7 +132,7 @@ let option = {
};
// Ensure that the context is obtained.
-this.context.startAbility(want, option).then(()={
+this.context.startAbility(want, option).then(()=>{
console.log('Succeed to start ability.');
}).catch((error)=>{
console.error('Failed to start ability with error: ${JSON.stringify(error)}');
diff --git a/en/application-dev/reference/apis/js-apis-app-ability-abilityLifecycleCallback.md b/en/application-dev/reference/apis/js-apis-app-ability-abilityLifecycleCallback.md
index e2ed27300bc211a232eafb878ccc4ca38851ae50..28c0772d7d5718cd328f318535bb276ff32550cf 100644
--- a/en/application-dev/reference/apis/js-apis-app-ability-abilityLifecycleCallback.md
+++ b/en/application-dev/reference/apis/js-apis-app-ability-abilityLifecycleCallback.md
@@ -275,7 +275,7 @@ export default class MyFirstAbility extends UIAbility {
// 2. Register the listener for the ability lifecycle changes through the applicationContext object.
try {
globalThis.lifecycleId = applicationContext.on('abilityLifecycle', abilityLifecycleCallback);
- console.log('registerAbilityLifecycleCallback number: ${JSON.stringify(lifecycleId)}');
+ console.log('registerAbilityLifecycleCallback lifecycleId: ${globalThis.lifecycleId}');
} catch (paramError) {
console.error('error: ${paramError.code}, ${paramError.message}');
}
@@ -285,7 +285,7 @@ export default class MyFirstAbility extends UIAbility {
MySecondAbility.ts
```ts
-import UIAbility from 'ohos.app.ability.UIAbility';
+import UIAbility from '@ohos.app.ability.UIAbility';
export default class MySecondAbility extends UIAbility {
onDestroy() {
diff --git a/en/application-dev/reference/apis/js-apis-app-ability-abilityManager.md b/en/application-dev/reference/apis/js-apis-app-ability-abilityManager.md
index 3bfd14ef61cbd5995d4d5b8a0e93a08cfbeaaac5..3cb32c4a2cdcbf7dbe451e3a8e880bc3414cc689 100644
--- a/en/application-dev/reference/apis/js-apis-app-ability-abilityManager.md
+++ b/en/application-dev/reference/apis/js-apis-app-ability-abilityManager.md
@@ -59,12 +59,13 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
```ts
import abilityManager from '@ohos.app.ability.abilityManager';
+import ConfigurationConstant from '@ohos.app.ability.ConfigurationConstant';
const config = {
language: 'Zh-Hans', // Simplified Chinese.
- colorMode: COLOR_MODE_LIGHT, // Light theme.
- direction: DIRECTION_VERTICAL, // Vertical direction.
- screenDensity: SCREEN_DENSITY_SDPI, // The screen pixel density is 'sdpi'.
+ colorMode: ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT, // Light theme.
+ direction: ConfigurationConstant.Direction.DIRECTION_VERTICAL, // Vertical direction.
+ screenDensity: ConfigurationConstant.ScreenDensity.SCREEN_DENSITY_SDPI, // The screen pixel density is 'sdpi'.
displayId: 1, // The application is displayed on the display with ID 1.
hasPointerDevice: true, // A pointer device is connected.
};
@@ -78,7 +79,7 @@ try {
}
});
} catch (paramError) {
- console.error('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
+ console.error('error.code: ${paramError.code}, error.message: ${paramError.message}');
}
```
@@ -116,12 +117,13 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
```ts
import abilityManager from '@ohos.app.ability.abilityManager';
+import ConfigurationConstant from '@ohos.app.ability.ConfigurationConstant';
const config = {
language: 'Zh-Hans', // Simplified Chinese.
- colorMode: COLOR_MODE_LIGHT, // Light theme.
- direction: DIRECTION_VERTICAL, // Vertical direction.
- screenDensity: SCREEN_DENSITY_SDPI, // The screen pixel density is 'sdpi'.
+ colorMode: ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT, // Light theme.
+ direction: ConfigurationConstant.Direction.DIRECTION_VERTICAL, // Vertical direction.
+ screenDensity: ConfigurationConstant.ScreenDensity.SCREEN_DENSITY_SDPI, // The screen pixel density is 'sdpi'.
displayId: 1, // The application is displayed on the display with ID 1.
hasPointerDevice: true, // A pointer device is connected.
};
@@ -133,7 +135,7 @@ try {
console.error('updateConfiguration fail, err: ${JSON.stringify(err)}');
});
} catch (paramError) {
- console.error('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
+ console.error('error.code: ${paramError.code}, error.message: ${paramError.message}');
}
```
@@ -175,7 +177,7 @@ try {
}
});
} catch (paramError) {
- console.error('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
+ console.error('error.code: ${paramError.code}, error.message: ${paramError.message}');
}
```
@@ -215,7 +217,7 @@ try {
console.error('getAbilityRunningInfos fail, err: ${JSON.stringify(err)}');
});
} catch (paramError) {
- console.error('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
+ console.error('error.code: ${paramError.code}, error.message: ${paramError.message}');
}
```
@@ -260,7 +262,7 @@ try {
}
});
} catch (paramError) {
- console.error('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
+ console.error('error.code: ${paramError.code}, error.message: ${paramError.message}');
}
```
@@ -308,7 +310,7 @@ try {
console.error('getExtensionRunningInfos fail, err: ${JSON.stringify(err)}');
});
} catch (paramError) {
- console.error('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
+ console.error('error.code: ${paramError.code}, error.message: ${paramError.message}');
}
```
diff --git a/en/application-dev/reference/apis/js-apis-app-ability-appManager.md b/en/application-dev/reference/apis/js-apis-app-ability-appManager.md
index c3d5a93c0f73f2b4e2e06caf8d1f45d9fd637f9f..f3e739c76ad25996ed767b71c0099ee7ca425abc 100644
--- a/en/application-dev/reference/apis/js-apis-app-ability-appManager.md
+++ b/en/application-dev/reference/apis/js-apis-app-ability-appManager.md
@@ -459,7 +459,7 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
```ts
import appManager from '@ohos.app.ability.appManager';
-let observeId = 0;
+let observerId = 0;
// 1. Register an application state observer.
let applicationStateObserver = {
@@ -540,7 +540,7 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
```ts
import appManager from '@ohos.app.ability.appManager';
-let observeId = 0;
+let observerId = 0;
// 1. Register an application state observer.
let applicationStateObserver = {
diff --git a/en/application-dev/reference/apis/js-apis-app-ability-appRecovery.md b/en/application-dev/reference/apis/js-apis-app-ability-appRecovery.md
index b57ce848be1321026c5f408e21c7d892a1887bf1..6931cfe50da06cdd9b7526344a47eae29c3c8ef8 100644
--- a/en/application-dev/reference/apis/js-apis-app-ability-appRecovery.md
+++ b/en/application-dev/reference/apis/js-apis-app-ability-appRecovery.md
@@ -4,7 +4,7 @@ The **appRecovery** module provides APIs for recovering faulty applications.
> **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. In the current version, only applications with a single ability in a single process can be recovered.
+> 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. In API version 9, only applications with a single ability in a process can be recovered. In API version 10, applications with multiple abilities in a process can be recovered.
## Modules to Import
```ts
@@ -51,7 +51,7 @@ Enumerates the application state saving modes. This enum is used as an input par
enableAppRecovery(restart?: [RestartFlag](#apprecoveryrestartflag), saveOccasion?: [SaveOccasionFlag](#apprecoverysaveoccasionflag), saveMode?: [SaveModeFlag](#apprecoverysavemodeflag)) : void;
-Enables application recovery.
+Enables application recovery. After this API is called, the first ability that is displayed when the application is started from the initiator can be restored.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
@@ -63,8 +63,8 @@ Enables application recovery.
| saveOccasion | [SaveOccasionFlag](#apprecoverysaveoccasionflag) | No| Scenario for saving the application state. By default, the state is saved when a fault occurs.|
| saveMode | [SaveModeFlag](#apprecoverysavemodeflag) | No| Application state saving mode. By default, the application state is written to the local file cache.|
-**Example**
-
+**Example**
+
```ts
import appRecovery from '@ohos.app.ability.appRecovery';
import AbilityStage from '@ohos.app.ability.AbilityStage';
@@ -72,9 +72,9 @@ import AbilityStage from '@ohos.app.ability.AbilityStage';
export default class MyAbilityStage extends AbilityStage {
onCreate() {
appRecovery.enableAppRecovery(
- appRecovery.RestartFlag::ALWAYS_RESTART,
- appRecovery.SaveOccasionFlag::SAVE_WHEN_ERROR,
- appRecovery.SaveModeFlag::SAVE_WITH_FILE
+ appRecovery.RestartFlag.ALWAYS_RESTART,
+ appRecovery.SaveOccasionFlag.SAVE_WHEN_ERROR,
+ appRecovery.SaveModeFlag.SAVE_WITH_FILE
);
}
}
@@ -84,13 +84,22 @@ export default class MyAbilityStage extends AbilityStage {
restartApp(): void;
-Restarts the application. This API can be used together with APIs of [errorManager](js-apis-app-ability-errorManager.md).
+Restarts the current process and starts the first ability that is displayed when the application is started. If the state of this ability is saved, the saved state data is passed into the **wantParam** attribute in the **want** parameter of the **OnCreate** lifecycle callback of the ability.
+
+In API version 10, the ability specified by [setRestartWant](#apprecoverysetrestartwant) is started. If no ability is specified, the following rules are used:
+
+- If the ability of the current application running in the foreground supports recovery, that ability is started.
+
+- If multiple abilities that support recovery is running in the foreground, only the last ability is started.
+
+- If no ability is running in the foreground, none of them is started.
+
+This API can be used together with the APIs of [errorManager](js-apis-app-ability-errorManager.md).
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+**Example**
-**Example**
-
```ts
import appRecovery from '@ohos.app.ability.appRecovery';
import errorManager from '@ohos.app.ability.errorManager';
@@ -113,7 +122,7 @@ try {
saveAppState(): boolean;
-Saves the application state. This API can be used together with APIs of [errorManager](js-apis-app-ability-errorManager.md).
+Saves the application state. This API can be used together with the APIs of [errorManager](js-apis-app-ability-errorManager.md).
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
@@ -123,8 +132,8 @@ Saves the application state. This API can be used together with APIs of [errorMa
| -------- | -------- |
| boolean | Whether the application state is saved. The value **true** is returned if the application state is saved, and **false** is returned otherwise.|
-**Example**
-
+**Example**
+
```ts
import appRecovery from '@ohos.app.ability.appRecovery';
import errorManager from '@ohos.app.ability.errorManager';
@@ -142,3 +151,53 @@ try {
console.error('error: ${paramError.code}, ${paramError.message}');
}
```
+
+## appRecovery.saveAppState10+
+
+saveAppState(context?: UIAbilityContext): boolean;
+
+Saves the ability state, which will be used for recovery. This API can be used together with the APIs of [errorManager](js-apis-app-ability-errorManager.md).
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| boolean | Whether the application state is saved. The value **true** is returned if the application state is saved, and **false** is returned otherwise.|
+
+**Example**
+
+```ts
+import appRecovery from '@ohos.app.ability.appRecovery';
+onBackground() {
+ hilog.info(0x0000, '[demo]', '%{public}s', 'EntryAbility onBackground');
+ appRecovery.saveAppState(this.context)
+}
+```
+
+## appRecovery.setRestartWant10+
+
+setRestartWant(want: Want): void;
+
+Sets an ability that will be recovered. The ability must be a UIAbility in the current bundle.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Example**
+
+```ts
+import appRecovery from '@ohos.app.ability.appRecovery';
+Button ("Start to Recover Ability")
+ .fontSize(40)
+ .fontWeight(FontWeight.Bold)
+ .onClick(()=> {
+ // set restart want
+ let want = {
+ bundleName: "ohos.samples.recovery",
+ abilityName: "RecoveryAbility"
+ };
+
+ appRecovery.setRestartWant(want);
+ })
+```
diff --git a/en/application-dev/reference/apis/js-apis-app-ability-dialogRequest.md b/en/application-dev/reference/apis/js-apis-app-ability-dialogRequest.md
index 989796d48ee22b34bd28b63b74fe20270d367577..49c3191c660f1848ffca26c13f8bebb2bfb754d0 100644
--- a/en/application-dev/reference/apis/js-apis-app-ability-dialogRequest.md
+++ b/en/application-dev/reference/apis/js-apis-app-ability-dialogRequest.md
@@ -127,6 +127,7 @@ Obtains the request callback from Want.
## RequestInfo
Defines the request information, which is used as an input parameter for binding the modal dialog box.
+
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Example**
diff --git a/en/application-dev/reference/apis/js-apis-app-ability-environmentCallback.md b/en/application-dev/reference/apis/js-apis-app-ability-environmentCallback.md
index 96c67de7c5cc52b781f55add22b59859560ee9d5..53d009a28bb9be2f62a6dfee2540a7e0de184e39 100644
--- a/en/application-dev/reference/apis/js-apis-app-ability-environmentCallback.md
+++ b/en/application-dev/reference/apis/js-apis-app-ability-environmentCallback.md
@@ -35,7 +35,7 @@ onMemoryLevel(level: AbilityConstant.MemoryLevel): void;
Called when the system memory level changes.
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Parameters**
@@ -55,7 +55,7 @@ export default class MyAbility extends UIAbility {
onCreate() {
console.log('MyAbility onCreate');
globalThis.applicationContext = this.context.getApplicationContext();
- let EnvironmentCallback = {
+ let environmentCallback = {
onConfigurationUpdated(config){
console.log('onConfigurationUpdated config: ${JSON.stringify(config)}');
}
@@ -67,7 +67,7 @@ export default class MyAbility extends UIAbility {
// 1. Obtain an applicationContext object.
let applicationContext = globalThis.applicationContext;
// 2. Register a listener for the environment changes through the applicationContext object.
- callbackId = applicationContext.registerEnvironmentCallback(EnvironmentCallback);
+ callbackId = applicationContext.registerEnvironmentCallback(environmentCallback);
console.log('registerEnvironmentCallback number: ${JSON.stringify(callbackId)}');
}
onDestroy() {
diff --git a/en/application-dev/reference/apis/js-apis-app-ability-missionManager.md b/en/application-dev/reference/apis/js-apis-app-ability-missionManager.md
index 1224636ae4c0aa4ceb8634b244cd088257b64331..eb92543feba85b2ce4abe3cb0f213fd19dccffe4 100644
--- a/en/application-dev/reference/apis/js-apis-app-ability-missionManager.md
+++ b/en/application-dev/reference/apis/js-apis-app-ability-missionManager.md
@@ -290,7 +290,7 @@ Obtains the information about a given mission. This API uses an asynchronous cal
| -------- | -------- | -------- | -------- |
| deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
| missionId | number | Yes| Mission ID.|
- | callback | AsyncCallback<[MissionInfo](./js-apis-inner-application-missionInfo.md))> | Yes| Callback used to return the mission information obtained.|
+ | callback | AsyncCallback<[MissionInfo](./js-apis-inner-application-missionInfo.md)> | Yes| Callback used to return the mission information obtained.|
**Example**
@@ -306,7 +306,7 @@ Obtains the information about a given mission. This API uses an asynchronous cal
missionManager.getMissionInfo('', testMissionId, (error, mission) => {
if (error) {
- console.error('getMissionInfo failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
+ console.error('getMissionInfo failed, error.code: ${error.code}, error.message: ${error.message}');
} else {
console.log('mission.missionId = ${mission.missionId}');
console.log('mission.runningState = ${mission.runningState}');
@@ -392,7 +392,7 @@ Obtains information about all missions. This API uses an asynchronous callback t
try {
missionManager.getMissionInfos('', 10, (error, missions) => {
if (error) {
- console.error('getMissionInfos failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
+ console.error('getMissionInfos failed, error.code: ${error.code}, error.message: ${error.message}');
} else {
console.log('size = ${missions.length}');
console.log('missions = ${JSON.stringify(missions)}');
diff --git a/en/application-dev/reference/apis/js-apis-app-ability-serviceExtensionAbility.md b/en/application-dev/reference/apis/js-apis-app-ability-serviceExtensionAbility.md
index 74686becf7e0f2a20d5a3f8efb07071589296330..c041a599c6f9857db40e530f1e888c2a12f47f54 100644
--- a/en/application-dev/reference/apis/js-apis-app-ability-serviceExtensionAbility.md
+++ b/en/application-dev/reference/apis/js-apis-app-ability-serviceExtensionAbility.md
@@ -106,7 +106,7 @@ Called following **onCreate()** when a ServiceExtensionAbility is started by cal
## ServiceExtensionAbility.onConnect
-onConnect(want: Want): rpc.RemoteObject;
+onConnect(want: Want): rpc.RemoteObject | Promise;
Called following **onCreate()** when a ServiceExtensionAbility is started by calling **connectAbility()**. A **RemoteObject** object is returned for communication between the server and client.
@@ -148,7 +148,7 @@ Called following **onCreate()** when a ServiceExtensionAbility is started by cal
## ServiceExtensionAbility.onDisconnect
-onDisconnect(want: Want): void;
+onDisconnect(want: Want): void | Promise;
Called when a client is disconnected from this ServiceExtensionAbility.
diff --git a/en/application-dev/reference/apis/js-apis-app-ability-startOptions.md b/en/application-dev/reference/apis/js-apis-app-ability-startOptions.md
index b57435673e0d2372d4980c5a540fea618719c839..d50bb380f662b1c992b10ef8f8b2b8ff7088d061 100644
--- a/en/application-dev/reference/apis/js-apis-app-ability-startOptions.md
+++ b/en/application-dev/reference/apis/js-apis-app-ability-startOptions.md
@@ -33,7 +33,7 @@ import StartOptions from '@ohos.app.ability.StartOptions';
try {
missionManager.getMissionInfos('', 10, (error, missions) => {
if (error.code) {
- console.error('getMissionInfos failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
+ console.error('getMissionInfos failed, error.code: ${error.code}, error.message: ${error.message}');
return;
}
console.log('size = ${missions.length}');
diff --git a/en/application-dev/reference/apis/js-apis-app-ability-uiAbility.md b/en/application-dev/reference/apis/js-apis-app-ability-uiAbility.md
index d840fd6854292aa876ecd3777e7cedc96b5e95bb..fbf50f68387385c7d69c02ce599285a5b8ad2310 100644
--- a/en/application-dev/reference/apis/js-apis-app-ability-uiAbility.md
+++ b/en/application-dev/reference/apis/js-apis-app-ability-uiAbility.md
@@ -124,7 +124,7 @@ Called when the **WindowStage** is restored during the migration of this UIAbili
## UIAbility.onDestroy
-onDestroy(): void;
+onDestroy(): void | Promise<void>;
Called when this UIAbility is destroyed to clear resources.
@@ -181,7 +181,7 @@ Called when this UIAbility is switched from the foreground to the background.
## UIAbility.onContinue
-onContinue(wantParam : {[key: string]: any}): AbilityConstant.OnContinueResult;
+onContinue(wantParam: { [key: string]: Object }): AbilityConstant.OnContinueResult;
Called to save data during the ability migration preparation process.
@@ -267,7 +267,7 @@ Dumps client information.
## UIAbility.onSaveState
-onSaveState(reason: AbilityConstant.StateType, wantParam : {[key: string]: any}): AbilityConstant.OnSaveResult;
+onSaveState(reason: AbilityConstant.StateType, wantParam : {[key: string]: Object}): AbilityConstant.OnSaveResult;
Called when the framework automatically saves the UIAbility state in the case of an application fault. This API is used together with [appRecovery](js-apis-app-ability-appRecovery.md). If automatic state saving is enabled, **onSaveState** is called to save the state of this UIAbility.
@@ -308,7 +308,7 @@ Implements sending of sequenceable data to the target ability when the CallerAbi
## Caller.call
-call(method: string, data: rpc.Sequenceable): Promise<void>;
+call(method: string, data: rpc.Parcelable): Promise<void>;
Sends sequenceable data to the target ability.
@@ -319,7 +319,7 @@ Sends sequenceable data to the target ability.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| method | string | Yes| Notification message string negotiated between the two abilities. The message is used to instruct the callee to register a function to receive the sequenceable data.|
-| data | [rpc.Sequenceable](js-apis-rpc.md#sequenceabledeprecated) | Yes| Sequenceable data. You need to customize the data.|
+| data | [rpc.Parcelable](js-apis-rpc.md#parcelable9) | Yes| Parcelable data. You need to customize the data.|
**Return value**
@@ -338,7 +338,7 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
**Example**
```ts
- class MyMessageAble{ // Custom sequenceable data structure.
+ class MyMessageAble{ // Custom parcelable data structure.
name:''
str:''
num: 1
@@ -346,15 +346,15 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
this.name = name;
this.str = str;
}
- marshalling(messageParcel) {
- messageParcel.writeInt(this.num);
- messageParcel.writeString(this.str);
+ marshalling(messageSequence) {
+ messageSequence.writeInt(this.num);
+ messageSequence.writeString(this.str);
console.log('MyMessageAble marshalling num[${this.num}] str[${this.str}]');
return true;
}
- unmarshalling(messageParcel) {
- this.num = messageParcel.readInt();
- this.str = messageParcel.readString();
+ unmarshalling(messageSequence) {
+ this.num = messageSequence.readInt();
+ this.str = messageSequence.readString();
console.log('MyMessageAble unmarshalling num[${this.num}] str[${this.str}]');
return true;
}
@@ -369,16 +369,16 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
deviceId: ''
}).then((obj) => {
caller = obj;
- let msg = new MyMessageAble('msg', 'world'); // See the definition of Sequenceable.
+ let msg = new MyMessageAble('msg', 'world'); // See the definition of Parcelable.
caller.call(method, msg)
.then(() => {
console.log('Caller call() called');
})
.catch((callErr) => {
- console.log('Caller.call catch error, error.code: ${JSON.stringify(callErr.code)}, error.message: ${JSON.stringify(callErr.message)}');
+ console.log('Caller.call catch error, error.code: ${callErr.code}, error.message: ${callErr.message}');
});
}).catch((err) => {
- console.log('Caller GetCaller error, error.code: ${JSON.stringify(err.code)}, error.message: ${JSON.stringify(err.message)}');
+ console.log('Caller GetCaller error, error.code: ${err.code}, error.message: ${err.message}');
});
}
}
@@ -387,7 +387,7 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
## Caller.callWithResult
-callWithResult(method: string, data: rpc.Sequenceable): Promise<rpc.MessageParcel>;
+callWithResult(method: string, data: rpc.Parcelable): Promise<rpc.MessageSequence>;
Sends sequenceable data to the target ability and obtains the sequenceable data returned by the target ability.
@@ -398,13 +398,13 @@ Sends sequenceable data to the target ability and obtains the sequenceable data
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| method | string | Yes| Notification message string negotiated between the two abilities. The message is used to instruct the callee to register a function to receive the sequenceable data.|
-| data | [rpc.Sequenceable](js-apis-rpc.md#sequenceabledeprecated) | Yes| Sequenceable data. You need to customize the data.|
+| data | [rpc.Parcelable](js-apis-rpc.md#parcelable9) | Yes| Parcelable data. You need to customize the data.|
**Return value**
| Type| Description|
| -------- | -------- |
-| Promise<[rpc.MessageParcel](js-apis-rpc.md#sequenceabledeprecated)> | Promise used to return the sequenceable data from the target ability.|
+| Promise<[rpc.MessageSequence](js-apis-rpc.md#messagesequence9)> | Promise used to return the sequenceable data from the target ability.|
**Error codes**
@@ -425,15 +425,15 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
this.name = name;
this.str = str;
}
- marshalling(messageParcel) {
- messageParcel.writeInt(this.num);
- messageParcel.writeString(this.str);
+ marshalling(messageSequence) {
+ messageSequence.writeInt(this.num);
+ messageSequence.writeString(this.str);
console.log('MyMessageAble marshalling num[${this.num}] str[${this.str}]');
return true;
}
- unmarshalling(messageParcel) {
- this.num = messageParcel.readInt();
- this.str = messageParcel.readString();
+ unmarshalling(messageSequence) {
+ this.num = messageSequence.readInt();
+ this.str = messageSequence.readString();
console.log('MyMessageAble unmarshalling num[${this.num] str[${this.str}]');
return true;
}
@@ -453,13 +453,13 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
.then((data) => {
console.log('Caller callWithResult() called');
let retmsg = new MyMessageAble(0, '');
- data.readSequenceable(retmsg);
+ data.readParcelable(retmsg);
})
.catch((callErr) => {
- console.log('Caller.callWithResult catch error, error.code: ${JSON.stringify(callErr.code)}, error.message: ${JSON.stringify(callErr.message)}');
+ console.log('Caller.callWithResult catch error, error.code: ${callErr.code}, error.message: ${callErr.message}');
});
}).catch((err) => {
- console.log('Caller GetCaller error, error.code: ${JSON.stringify(err.code)}, error.message: ${JSON.stringify(err.message)}');
+ console.log('Caller GetCaller error, error.code: ${err.code}, error.message: ${err.message}');
});
}
}
@@ -498,10 +498,10 @@ Releases the caller interface of the target ability.
try {
caller.release();
} catch (releaseErr) {
- console.log('Caller.release catch error, error.code: ${JSON.stringify(releaseErr.code)}, error.message: ${JSON.stringify(releaseErr.message)}');
+ console.log('Caller.release catch error, error.code: ${releaseErr.code}, error.message: ${releaseErr.message}');
}
}).catch((err) => {
- console.log('Caller GetCaller error, error.code: ${JSON.stringify(err.code)}, error.message: ${JSON.stringify(err.message)}');
+ console.log('Caller GetCaller error, error.code: ${err.code}, error.message: ${err.message}');
});
}
}
@@ -509,7 +509,7 @@ Releases the caller interface of the target ability.
## Caller.onRelease
- onRelease(callback: OnReleaseCallBack): void;
+ onRelease(callback: OnReleaseCallback): void;
Registers a callback that is invoked when the stub on the target ability is disconnected.
@@ -519,7 +519,7 @@ Registers a callback that is invoked when the stub on the target ability is disc
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| callback | [OnReleaseCallBack](#onreleasecallback) | Yes| Callback used to return the result.|
+| callback | [OnReleaseCallback](#onreleasecallback) | Yes| Callback used to return the result.|
**Example**
@@ -538,10 +538,10 @@ Registers a callback that is invoked when the stub on the target ability is disc
console.log(' Caller OnRelease CallBack is called ${str}');
});
} catch (error) {
- console.log('Caller.onRelease catch error, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
+ console.log('Caller.onRelease catch error, error.code: ${error.code}, error.message: ${error.message}');
}
}).catch((err) => {
- console.log('Caller GetCaller error, error.code: ${JSON.stringify(err.code)}, error.message: ${JSON.stringify(err.message)}');
+ console.log('Caller GetCaller error, error.code: ${err.code}, error.message: ${err.message}');
});
}
}
@@ -560,7 +560,7 @@ Registers a callback that is invoked when the stub on the target ability is disc
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is fixed at **release**.|
-| callback | [OnReleaseCallBack](#onreleasecallback) | Yes| Callback used to return the result.|
+| callback | [OnReleaseCallback](#onreleasecallback) | Yes| Callback used to return the result.|
**Error codes**
@@ -587,10 +587,10 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
console.log(' Caller OnRelease CallBack is called ${str}');
});
} catch (error) {
- console.log('Caller.on catch error, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
+ console.log('Caller.on catch error, error.code: ${error.code}, error.message: ${error.message}');
}
}).catch((err) => {
- console.log('Caller GetCaller error, error.code: ${JSON.stringify(err.code)}, error.message: ${JSON.stringify(err.message)}');
+ console.log('Caller GetCaller error, error.code: ${err.code}, error.message: ${err.message}');
});
}
}
@@ -609,7 +609,7 @@ Deregisters a callback that is invoked when the stub on the target ability is di
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is fixed at **release**.|
-| callback | [OnReleaseCallBack](#onreleasecallback) | Yes| Callback used to return the result.|
+| callback | [OnReleaseCallback](#onreleasecallback) | Yes| Callback used to return the result.|
**Error codes**
@@ -637,10 +637,10 @@ For other IDs, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
caller.on('release', onReleaseCallBack);
caller.off('release', onReleaseCallBack);
} catch (error) {
- console.log('Caller.on or Caller.off catch error, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
+ console.log('Caller.on or Caller.off catch error, error.code: ${error.code}, error.message: ${error.message}');
}
}).catch((err) => {
- console.log('Caller GetCaller error, error.code: ${JSON.stringify(err.code)}, error.message: ${JSON.stringify(err.message)}');
+ console.log('Caller GetCaller error, error.code: ${err.code}, error.message: ${err.message}');
});
}
}
@@ -686,10 +686,10 @@ For other IDs, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
caller.on('release', onReleaseCallBack);
caller.off('release');
} catch (error) {
- console.error('Caller.on or Caller.off catch error, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
+ console.error('Caller.on or Caller.off catch error, error.code: ${error.code}, error.message: ${error.message}');
}
}).catch((err) => {
- console.error('Caller GetCaller error, error.code: ${JSON.stringify(err.code)}, error.message: ${JSON.stringify(err.message)}');
+ console.error('Caller GetCaller error, error.code: ${err.code}, error.message: ${err.message}');
});
}
}
@@ -712,7 +712,7 @@ Registers a caller notification callback, which is invoked when the target abili
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| method | string | Yes| Notification message string negotiated between the two abilities.|
-| callback | [CalleeCallback](#calleecallback) | Yes| JS notification synchronization callback of the [rpc.MessageParcel](js-apis-rpc.md#messageparceldeprecated) type. The callback must return at least one empty [rpc.Sequenceable](js-apis-rpc.md#sequenceabledeprecated) object. Otherwise, the function execution fails.|
+| callback | [CalleeCallback](#calleecallback) | Yes| JS notification synchronization callback of the [rpc.MessageSequence](js-apis-rpc.md#messagesequence9) type. The callback must return at least one empty [rpc.Parcelable](js-apis-rpc.md#parcelable9) object. Otherwise, the function execution fails.|
**Error codes**
@@ -733,15 +733,15 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
this.name = name;
this.str = str;
}
- marshalling(messageParcel) {
- messageParcel.writeInt(this.num);
- messageParcel.writeString(this.str);
+ marshalling(messageSequence) {
+ messageSequence.writeInt(this.num);
+ messageSequence.writeString(this.str);
console.log('MyMessageAble marshalling num[${this.num}] str[${this.str}]');
return true;
}
- unmarshalling(messageParcel) {
- this.num = messageParcel.readInt();
- this.str = messageParcel.readString();
+ unmarshalling(messageSequence) {
+ this.num = messageSequence.readInt();
+ this.str = messageSequence.readString();
console.log('MyMessageAble unmarshalling num[${this.num}] str[${this.str}]');
return true;
}
@@ -750,7 +750,7 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
function funcCallBack(pdata) {
console.log('Callee funcCallBack is called ${pdata}');
let msg = new MyMessageAble('test', '');
- pdata.readSequenceable(msg);
+ pdata.readParcelable(msg);
return new MyMessageAble('test1', 'Callee test');
}
export default class MainUIAbility extends UIAbility {
@@ -759,7 +759,7 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
try {
this.callee.on(method, funcCallBack);
} catch (error) {
- console.log('Callee.on catch error, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
+ console.log('Callee.on catch error, error.code: ${error.code}, error.message: ${error.message}');
}
}
}
@@ -798,7 +798,7 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
try {
this.callee.off(method);
} catch (error) {
- console.log('Callee.off catch error, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
+ console.log('Callee.off catch error, error.code: ${error.code}, error.message: ${error.message}');
}
}
}
@@ -816,10 +816,10 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
## CalleeCallback
-(indata: rpc.MessageParcel): rpc.Sequenceable;
+(indata: rpc.MessageSequence): rpc.Parcelable;
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
| Name| Readable| Writable| Type| Description|
| -------- | -------- | -------- | -------- | -------- |
-| (indata: [rpc.MessageParcel](js-apis-rpc.md#messageparceldeprecated)) | Yes| No| [rpc.Sequenceable](js-apis-rpc.md#sequenceabledeprecated) | Prototype of the listener function registered by the callee.|
+| (indata: [rpc.MessageSequence](js-apis-rpc.md#messagesequence9)) | Yes| No| [rpc.Parcelable](js-apis-rpc.md#parcelable9) | Prototype of the listener function registered by the callee.|
diff --git a/en/application-dev/reference/apis/js-apis-app-ability-wantAgent.md b/en/application-dev/reference/apis/js-apis-app-ability-wantAgent.md
index c7fd0b0f4a3f21eec8dbf66c51f890d6436b08f0..89c8919f494252120fff49a42cc8335c29ec702b 100644
--- a/en/application-dev/reference/apis/js-apis-app-ability-wantAgent.md
+++ b/en/application-dev/reference/apis/js-apis-app-ability-wantAgent.md
@@ -186,10 +186,10 @@ try {
WantAgent.getWantAgent(wantAgentInfo).then((data) => {
wantAgent = data;
}).catch((err) => {
- console.error('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
+ console.error('getWantAgent failed! ${err.code} ${err.message}');
});
} catch (err) {
- console.error('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
+ console.error('getWantAgent failed! ${err.code} ${err.message}');
}
```
@@ -280,7 +280,7 @@ function getWantAgentCallback(err, data) {
// getBundleName callback
function getBundleNameCallback(err, data) {
if(err) {
- console.error('getBundleName failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
+ console.error('getBundleName failed! ${err.code} ${err.message}');
} else {
console.info('getBundleName ok! ${JSON.stringify(data)}');
}
@@ -288,13 +288,13 @@ function getWantAgentCallback(err, data) {
try {
WantAgent.getBundleName(wantAgent, getBundleNameCallback);
} catch(err) {
- console.error('getBundleName failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
+ console.error('getBundleName failed! ${err.code} ${err.message}');
}
}
try {
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
} catch(err) {
- console.error('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
+ console.error('getWantAgent failed! ${err.code} ${err.message}');
}
```
@@ -391,16 +391,16 @@ function getWantAgentCallback(err, data) {
WantAgent.getBundleName(wantAgent).then((data)=>{
console.info('getBundleName ok! ${JSON.stringify(data)}');
}).catch((err)=>{
- console.error('getBundleName failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
+ console.error('getBundleName failed! ${err.code} ${err.message}');
});
} catch(err){
- console.error('getBundleName failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
+ console.error('getBundleName failed! ${err.code} ${err.message}');
}
}
try {
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
} catch(err) {
- console.error('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
+ console.error('getWantAgent failed! ${err.code} ${err.message}');
}
```
@@ -492,7 +492,7 @@ function getWantAgentCallback(err, data) {
// getUid callback
function getUidCallback(err, data) {
if(err) {
- console.error('getUid failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
+ console.error('getUid failed! ${err.code} ${err.message}');
} else {
console.info('getUid ok! ${JSON.stringify(data)}');
}
@@ -500,13 +500,13 @@ function getWantAgentCallback(err, data) {
try {
WantAgent.getUid(wantAgent, getUidCallback);
} catch(err) {
- console.error('getUid failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
+ console.error('getUid failed! ${err.code} ${err.message}');
}
}
try {
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
} catch(err) {
- console.error('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
+ console.error('getWantAgent failed! ${err.code} ${err.message}');
}
```
@@ -603,16 +603,16 @@ function getWantAgentCallback(err, data) {
WantAgent.getUid(wantAgent).then((data)=>{
console.info('getUid ok! ${JSON.stringify(data)}');
}).catch((err)=>{
- console.error('getUid failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
+ console.error('getUid failed! ${err.code} ${err.message}');
});
} catch(err){
- console.error('getUid failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
+ console.error('getUid failed! ${err.code} ${err.message}');
}
}
try {
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
} catch(err) {
- console.error('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
+ console.error('getWantAgent failed! ${err.code} ${err.message}');
}
```
@@ -704,7 +704,7 @@ function getWantAgentCallback(err, data) {
// getWant callback
function getWantCallback(err, data) {
if(err) {
- console.error('getWant failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
+ console.error('getWant failed! ${err.code} ${err.message}');
} else {
console.info('getWant ok! ${JSON.stringify(data)}');
}
@@ -712,13 +712,13 @@ function getWantAgentCallback(err, data) {
try {
WantAgent.getWant(wantAgent, getWantCallback);
} catch(err) {
- console.error('getWant failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
+ console.error('getWant failed! ${err.code} ${err.message}');
}
}
try {
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
} catch(err) {
- console.error('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
+ console.error('getWantAgent failed! ${err.code} ${err.message}');
}
```
@@ -817,16 +817,16 @@ function getWantAgentCallback(err, data) {
WantAgent.getUid(wantAgent).then((data)=>{
console.info('getUid ok! ${JSON.stringify(data)}');
}).catch((err)=>{
- console.error('getUid failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
+ console.error('getUid failed! ${err.code} ${err.message}');
});
} catch(err){
- console.error('getUid failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
+ console.error('getUid failed! ${err.code} ${err.message}');
}
}
try {
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
} catch(err) {
- console.error('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
+ console.error('getWantAgent failed! ${err.code} ${err.message}');
}
```
@@ -917,7 +917,7 @@ function getWantAgentCallback(err, data) {
// cancel callback
function cancelCallback(err, data) {
if(err) {
- console.error('cancel failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
+ console.error('cancel failed! ${err.code} ${err.message}');
} else {
console.info('cancel ok!');
}
@@ -925,13 +925,13 @@ function getWantAgentCallback(err, data) {
try {
WantAgent.cancel(wantAgent, cancelCallback);
} catch(err) {
- console.error('cancel failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
+ console.error('cancel failed! ${err.code} ${err.message}');
}
}
try {
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
} catch(err) {
- console.error('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
+ console.error('getWantAgent failed! ${err.code} ${err.message}');
}
```
@@ -1028,16 +1028,16 @@ function getWantAgentCallback(err, data) {
WantAgent.cancel(wantAgent).then((data)=>{
console.info('cancel ok!');
}).catch((err)=>{
- console.error('cancel failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
+ console.error('cancel failed! ${err.code} ${err.message}');
});
} catch(err){
- console.error('cancel failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
+ console.error('cancel failed! ${err.code} ${err.message}');
}
}
try {
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
} catch(err) {
- console.error('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
+ console.error('getWantAgent failed! ${err.code} ${err.message}');
}
```
@@ -1131,7 +1131,7 @@ function getWantAgentCallback(err, data) {
// trigger callback
function triggerCallback(err, data) {
if(err) {
- console.error('getUid failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
+ console.error('getUid failed! ${err.code} ${err.message}');
} else {
console.info('getUid ok! ${JSON.stringify(data)}');
}
@@ -1139,13 +1139,13 @@ function getWantAgentCallback(err, data) {
try {
WantAgent.trigger(wantAgent, triggerInfo, triggerCallback);
} catch(err) {
- console.error('getUid failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
+ console.error('getUid failed! ${err.code} ${err.message}');
}
}
try {
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
} catch(err) {
- console.error('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
+ console.error('getWantAgent failed! ${err.code} ${err.message}');
}
```
@@ -1239,7 +1239,7 @@ function getWantAgentCallback(err, data) {
// equal callback
function equalCallback(err, data) {
if(err) {
- console.error('equal failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
+ console.error('equal failed! ${err.code} ${err.message}');
} else {
console.info('equal ok! ${JSON.stringify(data)}');
}
@@ -1247,13 +1247,13 @@ function getWantAgentCallback(err, data) {
try {
WantAgent.equal(wantAgent1,wantAgent2,equalCallback);
} catch(err) {
- console.error('equal failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
+ console.error('equal failed! ${err.code} ${err.message}');
}
}
try {
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
} catch(err) {
- console.error('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
+ console.error('getWantAgent failed! ${err.code} ${err.message}');
}
```
@@ -1353,16 +1353,16 @@ function getWantAgentCallback(err, data) {
WantAgent.equal(wantAgent1,wantAgent2).then((data)=>{
console.info('equal ok! ${JSON.stringify(data)}');
}).catch((err)=>{
- console.error('equal failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
+ console.error('equal failed! ${err.code} ${err.message}');
})
} catch(err){
- console.error('equal failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
+ console.error('equal failed! ${err.code} ${err.message}');
}
}
try {
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
} catch(err) {
- console.error('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
+ console.error('getWantAgent failed! ${err.code} ${err.message}');
}
```
@@ -1451,7 +1451,7 @@ function getWantAgentCallback(err, data) {
// getOperationTypeCallback callback
function getOperationTypeCallback(err, data) {
if(err) {
- console.error('getOperationType failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
+ console.error('getOperationType failed! ${err.code} ${err.message}');
} else {
console.info('getOperationType ok! ${JSON.stringify(data)}');
}
@@ -1459,13 +1459,13 @@ function getWantAgentCallback(err, data) {
try {
WantAgent.getOperationTypeCallback(wantAgent, getOperationTypeCallback);
} catch(err) {
- console.error('getOperationTypeCallback failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
+ console.error('getOperationTypeCallback failed! ${err.code} ${err.message}');
}
}
try {
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
} catch(err) {
- console.error('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
+ console.error('getWantAgent failed! ${err.code} ${err.message}');
}
```
@@ -1560,16 +1560,16 @@ function getWantAgentCallback(err, data) {
WantAgent.getOperationType(wantAgent).then((data)=>{
console.info('getOperationType ok! ${JSON.stringify(data)}');
}).catch((err)=>{
- console.error('getOperationType failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
+ console.error('getOperationType failed! ${err.code} ${err.message}');
});
} catch(err){
- console.error('getOperationType failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
+ console.error('getOperationType failed! ${err.code} ${err.message}');
}
}
try {
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
} catch(err) {
- console.error('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
+ console.error('getWantAgent failed! ${err.code} ${err.message}');
}
```
diff --git a/en/application-dev/reference/apis/js-apis-app-form-formExtensionAbility.md b/en/application-dev/reference/apis/js-apis-app-form-formExtensionAbility.md
index 345f889f31e3d31cb834b03e9b5ecbde12aaabfe..7ea0a7024970cffde1434f76ce911cce28dbcd2e 100644
--- a/en/application-dev/reference/apis/js-apis-app-form-formExtensionAbility.md
+++ b/en/application-dev/reference/apis/js-apis-app-form-formExtensionAbility.md
@@ -273,7 +273,7 @@ export default class MyFormExtensionAbility extends FormExtensionAbility {
## onShareForm
-onShareForm?(formId: string): { [key: string]: any }
+onShareForm?(formId: string): { [key: string]: Object }
Called by the widget provider to receive shared widget data.
diff --git a/en/application-dev/reference/apis/js-apis-app-form-formInfo.md b/en/application-dev/reference/apis/js-apis-app-form-formInfo.md
index 09a6ae02c63c18073836925ad9b6399e48fdd67d..ab73d920af1c1b76825049c63b5560d8e82390ac 100644
--- a/en/application-dev/reference/apis/js-apis-app-form-formInfo.md
+++ b/en/application-dev/reference/apis/js-apis-app-form-formInfo.md
@@ -47,7 +47,7 @@ Enumerates the widget types.
| Name | Value | Description |
| ----------- | ---- | ------------ |
| JS | 1 | JS widget. |
-| eTS | 2 | eTS widget.|
+| eTS | 2 | ArkTS widget.|
## ColorMode
diff --git a/en/application-dev/reference/apis/js-apis-appAccount.md b/en/application-dev/reference/apis/js-apis-appAccount.md
index 5b2b923deeb737e90cd173b822e65a35b00e741a..8c8b4c4c6e4bf167b513a2956e3a5df8c282fa22 100644
--- a/en/application-dev/reference/apis/js-apis-appAccount.md
+++ b/en/application-dev/reference/apis/js-apis-appAccount.md
@@ -148,7 +148,6 @@ Creates an app account with custom data. This API uses a promise to return the r
| 12300002 | Invalid name or options. |
| 12300004 | Account already exists. |
| 12300007 | The number of accounts reaches the upper limit. |
-| 12400003 | The number of custom data reaches the upper limit. |
**Example**
@@ -248,7 +247,7 @@ Creates an app account implicitly based on the specified account owner and optio
| ID| Error Message|
| ------- | ------- |
| 12300001 | System service exception. |
-| 12300002 | Invalid name or options. |
+| 12300002 | Invalid owner or options. |
| 12300007 | The number of accounts reaches the upper limit. |
| 12300010 | Account service busy. |
| 12300113 | Authenticator service not found. |
@@ -481,7 +480,6 @@ Checks whether an app can access the data of an account. This API uses an asynch
| 12300001 | System service exception. |
| 12300002 | Invalid name or bundleName. |
| 12300003 | Account not found. |
-| 12400001 | Application not found. |
**Example**
@@ -527,7 +525,6 @@ Checks whether an app can access the data of an account. This API uses a promise
| 12300001 | System service exception. |
| 12300002 | Invalid name or bundleName. |
| 12300003 | Account not found. |
-| 12400001 | Application not found. |
**Example**
@@ -903,7 +900,7 @@ Sets custom data for an app account. This API uses an asynchronous callback to r
| ID| Error Message|
| ------- | -------|
| 12300001 | System service exception. |
-| 12300002 | Invalid name or key or value. |
+| 12300002 | Invalid name, key, or value. |
| 12300003 | Account not found. |
| 12400003 | The number of custom data reaches the upper limit. |
@@ -950,7 +947,7 @@ Sets custom data for an app account. This API uses a promise to return the resul
| ID| Error Message|
| ------- | -------|
| 12300001 | System service exception. |
-| 12300002 | Invalid name or key or value. |
+| 12300002 | Invalid name, key, or value. |
| 12300003 | Account not found. |
| 12400003 | The number of custom data reaches the upper limit. |
@@ -1267,7 +1264,6 @@ Subscribes to account information changes of apps.
| ------- | ------- |
| 12300001 | System service exception. |
| 12300002 | Invalid type or owners. |
-| 12300011 | Callback has been registered. |
| 12400001 | Application not found. |
**Example**
@@ -1304,7 +1300,6 @@ Unsubscribes from account information changes.
| ------- | -------|
| 12300001 | System service exception. |
| 12300002 | Invalid type. |
-| 12300012 | Callback has not been registered. |
**Example**
@@ -1347,7 +1342,7 @@ Authenticates an app account. This API uses an asynchronous callback to return t
| ID| Error Message|
| ------- | -------|
| 12300001 | System service exception. |
-| 12300002 | Invalid name or owner or authType. |
+| 12300002 | Invalid name, owner, or authType. |
| 12300003 | Account not found. |
| 12300010 | Account service busy. |
| 12300113 | Authenticator service not found. |
@@ -1410,8 +1405,8 @@ Authenticates an app account with customized options. This API uses an asynchron
| ID| Error Message|
| ------- | -------|
| 12300001 | System service exception. |
-| 12300002 | Invalid name or owner or authType. |
-| 12300003 | Account not exist. |
+| 12300002 | Invalid name, owner, authType, or options. |
+| 12300003 | Account not found. |
| 12300010 | Account service busy. |
| 12300113 | Authenticator service not found. |
| 12300114 | Authenticator service exception. |
@@ -1522,7 +1517,7 @@ Obtains the authorization token of the specified authentication type for an app
| ID| Error Message|
| ------- | ------- |
| 12300001 | System service exception. |
-| 12300002 | Invalid name or owner or authType. |
+| 12300002 | Invalid name, owner, or authType. |
| 12300003 | Account not found. |
| 12300107 | AuthType not found. |
@@ -1562,7 +1557,7 @@ Sets an authorization token of the specific authentication type for an app accou
| ID| Error Message|
| ------- | -------|
| 12300001 | System service exception. |
-| 12300002 | Invalid name or authType or token. |
+| 12300002 | Invalid name, authType, or token. |
| 12300003 | Account not found. |
| 12400004 | The number of token reaches the upper limit. |
@@ -1609,7 +1604,7 @@ Sets an authorization token of the specific authentication type for an app accou
| ID| Error Message|
| ------- | -------|
| 12300001 | System service exception. |
-| 12300002 | Invalid name or authType or token. |
+| 12300002 | Invalid name, authType, or token. |
| 12300003 | Account not found. |
| 12400004 | The number of token reaches the upper limit. |
@@ -1650,7 +1645,7 @@ Deletes the authorization token of the specified authentication type for an app
| ID| Error Message|
| ------- | ------- |
| 12300001 | System service exception. |
-| 12300002 | Invalid name or owner or authType or token. |
+| 12300002 | Invalid name, owner, authType, or token. |
| 12300003 | Account not found. |
| 12300107 | AuthType not found. |
@@ -1698,7 +1693,7 @@ Deletes the authorization token of the specified authentication type for an app
| ID| Error Message|
| ------- | ------- |
| 12300001 | System service exception. |
-| 12300002 | Invalid name or owner or authType or token. |
+| 12300002 | Invalid name, owner, authType, or token. |
| 12300003 | Account not found. |
| 12300107 | AuthType not found. |
@@ -1739,7 +1734,7 @@ Sets the visibility of an authorization token to an app. This API uses an asynch
| ID| Error Message|
| ------- | -------|
| 12300001 | System service exception. |
-| 12300002 | Invalid name or authType or bundleName. |
+| 12300002 | Invalid name, authType, or bundleName. |
| 12300003 | Account not found. |
| 12300107 | AuthType not found. |
| 12400001 | Application not found. |
@@ -1789,7 +1784,7 @@ Sets the visibility of an authorization token to an app. This API uses a promise
| ID| Error Message|
| ------- | -------|
| 12300001 | System service exception. |
-| 12300002 | Invalid name or authType or bundleName. |
+| 12300002 | Invalid name, authType, or bundleName. |
| 12300003 | Account not found. |
| 12300107 | AuthType not found. |
| 12400001 | Application not found. |
@@ -1831,10 +1826,9 @@ Checks the visibility of an authorization token of the specified authentication
| ID| Error Message|
| ------- | -------|
| 12300001 | System service exception. |
-| 12300002 | Invalid name or authType or bundleName. |
+| 12300002 | Invalid name, authType, or bundleName. |
| 12300003 | Account not found. |
| 12300107 | AuthType not found. |
-| 12400001 | Application not found. |
**Example**
@@ -1879,10 +1873,9 @@ Checks the visibility of an authorization token of the specified authentication
| ID| Error Message|
| ------- | -------|
| 12300001 | System service exception. |
-| 12300002 | Invalid name or authType or bundleName. |
+| 12300002 | Invalid name, authType, or bundleName. |
| 12300003 | Account not found. |
| 12300107 | AuthType not found. |
-| 12400001 | Application not found. |
**Example**
@@ -2281,7 +2274,7 @@ Checks whether an app account has specific labels. This API uses an asynchronous
| ID| Error Message|
| ------- | ------- |
| 12300001 | System service exception. |
-| 12300002 | Invalid name or owner or labels. |
+| 12300002 | Invalid name, owner, or labels. |
| 12300003 | Account not found. |
| 12300010 | Account service busy. |
| 12300113 | Authenticator service not found. |
@@ -2331,7 +2324,7 @@ Checks whether an app account has specific labels. This API uses a promise to re
| ID| Error Message|
| ------- | ------- |
| 12300001 | System service exception. |
-| 12300002 | Invalid name or owner or labels. |
+| 12300002 | Invalid name, owner, or labels. |
| 12300003 | Account not found. |
| 12300010 | Account service busy. |
| 12300113 | Authenticator service not found. |
@@ -2594,7 +2587,7 @@ Verifies the user credential. This API uses an asynchronous callback to return t
| ID| Error Message|
| ------- | -------|
| 12300001 | System service exception. |
-| 12300002 | Invalid name or owner or options. |
+| 12300002 | Invalid name, owner, or options. |
| 12300003 | Account not found. |
| 12300010 | Account service busy. |
| 12300113 | Authenticator service not found. |
diff --git a/en/application-dev/reference/apis/js-apis-application-appManager.md b/en/application-dev/reference/apis/js-apis-application-appManager.md
index f32952bbbf73311db85ce014fbd4c8892f3b1d56..7b8e75b6bbc6d503f5f0d61409a77ff6d9374658 100644
--- a/en/application-dev/reference/apis/js-apis-application-appManager.md
+++ b/en/application-dev/reference/apis/js-apis-application-appManager.md
@@ -263,49 +263,6 @@ Registers an observer to listen for the state changes of all applications.
console.log('-------- observerCode: ---------', observerCode);
```
-## appManager.registerApplicationStateObserver9+
-
-registerApplicationStateObserver(observer: ApplicationStateObserver, bundleNameList: Array\): number;
-
-Registers an observer to listen for the state changes of a specified application.
-
-**Required permissions**: ohos.permission.RUNNING_STATE_OBSERVER
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-**System API**: This is a system API and cannot be called by third-party applications.
-
-**Parameters**
-
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| observer | [ApplicationStateObserver](js-apis-inner-application-applicationStateObserver.md) | Yes| Numeric code of the observer.|
-| bundleNameList | Array | Yes| **bundleName** array of the application. A maximum of 128 bundle names can be passed.|
-
-**Example**
-
- ```ts
- let applicationStateObserver = {
- onForegroundApplicationChanged(appStateData) {
- console.log('------------ onForegroundApplicationChanged -----------', appStateData);
- },
- onAbilityStateChanged(abilityStateData) {
- console.log('------------ onAbilityStateChanged -----------', abilityStateData);
- },
- onProcessCreated(processData) {
- console.log('------------ onProcessCreated -----------', processData);
- },
- onProcessDied(processData) {
- console.log('------------ onProcessDied -----------', processData);
- },
- onProcessStateChanged(processData) {
- console.log('------------ onProcessStateChanged -----------', processData);
- }
- };
- let bundleNameList = ['bundleName1', 'bundleName2'];
- const observerCode = appManager.registerApplicationStateObserver(applicationStateObserver, bundleNameList);
- console.log('-------- observerCode: ---------', observerCode);
- ```
## appManager.unregisterApplicationStateObserver8+
unregisterApplicationStateObserver(observerId: number, callback: AsyncCallback\): void;
diff --git a/en/application-dev/reference/apis/js-apis-application-configuration.md b/en/application-dev/reference/apis/js-apis-application-configuration.md
index 624d5946bdb8988dccc8709701d44ae1c9addd96..a8831b7f3b41a316356f6d7d660594414d5d3d10 100644
--- a/en/application-dev/reference/apis/js-apis-application-configuration.md
+++ b/en/application-dev/reference/apis/js-apis-application-configuration.md
@@ -33,11 +33,14 @@ export default class EntryAbility extends UIAbility {
console.info(`envCallback onConfigurationUpdated success: ${JSON.stringify(config)}`);
let language = config.language;
let colorMode = config.colorMode;
+ },
+ onMemoryLevel(level){
+ console.log('onMemoryLevel level: ${JSON.stringify(level)}');
}
};
let applicationContext = this.context.getApplicationContext();
- applicationContext.registerEnvironmentCallback(envCallback);
+ applicationContext.on('environment',envCallback);
windowStage.loadContent('pages/index', (err, data) => {
if (err.code) {
diff --git a/en/application-dev/reference/apis/js-apis-application-dataShareExtensionAbility.md b/en/application-dev/reference/apis/js-apis-application-dataShareExtensionAbility.md
index ee7ba37cdd08795b0ea33e09dc687b7ccd4712bc..0a97689f23cdf69527c61dfc8dfba28e6869badf 100644
--- a/en/application-dev/reference/apis/js-apis-application-dataShareExtensionAbility.md
+++ b/en/application-dev/reference/apis/js-apis-application-dataShareExtensionAbility.md
@@ -81,7 +81,7 @@ export default class DataShareExtAbility extends DataShareExtensionAbility {
console.log('getRdbStore done, data : ${data}');
rdbStore = data;
rdbStore.executeSql(DDL_TBL_CREATE, [], function (err) {
- console.log('executeSql done, error message : ${err}');
+ console.error('executeSql done, error message : ${err}');
});
if (callback) {
callback();
diff --git a/en/application-dev/reference/apis/js-apis-application-missionManager.md b/en/application-dev/reference/apis/js-apis-application-missionManager.md
index c09b0387f8aa1bff0b9f084136ad6ed70859c71f..9cc1ecce166669fa3962ba8a32007f81c43a7af8 100644
--- a/en/application-dev/reference/apis/js-apis-application-missionManager.md
+++ b/en/application-dev/reference/apis/js-apis-application-missionManager.md
@@ -170,7 +170,7 @@ Obtains the information about a given mission. This API uses an asynchronous cal
let allMissions=missionManager.getMissionInfos('',10).catch(function(err){console.log(err);});
missionManager.getMissionInfo('', allMissions[0].missionId, (error, mission) => {
if (error.code) {
- console.error('getMissionInfo failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
+ console.error('getMissionInfo failed, error.code: ${error.code}, error.message: ${error.message}');
return;
}
@@ -247,7 +247,7 @@ Obtains information about all missions. This API uses an asynchronous callback t
missionManager.getMissionInfos('', 10, (error, missions) => {
if (error.code) {
- console.error('getMissionInfos failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
+ console.error('getMissionInfos failed, error.code: ${error.code}, error.message: ${error.message}');
return;
}
console.log('size = ${missions.length}');
@@ -319,7 +319,7 @@ Obtains the snapshot of a given mission. This API uses an asynchronous callback
missionManager.getMissionInfos('', 10, (error, missions) => {
if (error.code) {
- console.error('getMissionInfos failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
+ console.error('getMissionInfos failed, error.code: ${error.code}, error.message: ${error.message}');
return;
}
console.log('size = ${missions.length}');
@@ -328,7 +328,7 @@ Obtains the snapshot of a given mission. This API uses an asynchronous callback
missionManager.getMissionSnapShot('', id, (error, snapshot) => {
if (error.code) {
- console.error('getMissionSnapShot failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
+ console.error('getMissionSnapShot failed, error.code: ${error.code}, error.message: ${error.message}');
return;
}
console.log('bundleName = ${snapshot.ability.bundleName}');
@@ -382,97 +382,6 @@ Obtains the snapshot of a given mission. This API uses a promise to return the r
});
```
-## missionManager.getLowResolutionMissionSnapShot9+
-
-getLowResolutionMissionSnapShot(deviceId: string, missionId: number, callback: AsyncCallback\): void;
-
-Obtains the low-resolution snapshot of a given mission. This API uses an asynchronous callback to return the result.
-
-**Required permissions**: ohos.permission.MANAGE_MISSIONS
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
-
-**System API**: This is a system API and cannot be called by third-party applications.
-
-**Parameters**
-
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
- | missionId | number | Yes| Mission ID.|
- | callback | AsyncCallback<[MissionSnapshot](js-apis-inner-application-missionSnapshot.md)> | Yes| Callback used to return the snapshot information obtained.|
-
-**Example**
-
- ```ts
- import missionManager from '@ohos.application.missionManager';
-
- missionManager.getMissionInfos('', 10, (error, missions) => {
- if (error.code) {
- console.error('getMissionInfos failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
- return;
- }
- console.log('size = ${missions.length}');
- console.log('missions = ${JSON.stringify(missions)}');
- let id = missions[0].missionId;
-
- missionManager.getLowResolutionMissionSnapShot('', id, (error, snapshot) => {
- if (error.code) {
- console.error('getLowResolutionMissionSnapShot failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
- return;
- }
- console.log('bundleName = ${snapshot.ability.bundleName}');
- });
- });
- ```
-
-
-## missionManager.getLowResolutionMissionSnapShot9+
-
-getLowResolutionMissionSnapShot(deviceId: string, missionId: number): Promise\;
-
-Obtains the low-resolution snapshot of a given mission. This API uses a promise to return the result.
-
-**Required permissions**: ohos.permission.MANAGE_MISSIONS
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
-
-**System API**: This is a system API and cannot be called by third-party applications.
-
-**Parameters**
-
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
- | missionId | number | Yes| Mission ID.|
-
-**Return value**
-
- | Type| Description|
- | -------- | -------- |
- | Promise<[MissionSnapshot](js-apis-inner-application-missionSnapshot.md)> | Promise used to return the snapshot information obtained.|
-
-**Example**
-
- ```ts
- import missionManager from '@ohos.application.missionManager';
-
- let allMissions;
- missionManager.getMissionInfos('',10).then(function(res){
- allMissions=res;
- }).catch(function(error) {
- console.error('getMissionInfos fail, error: ${error}');
- });
- console.log('size = ${allMissions.length}');
- console.log('missions = ${JSON.stringify(allMissions)}');
- let id = allMissions[0].missionId;
-
- let snapshot = missionManager.getLowResolutionMissionSnapShot('', id).catch(function (error){
- console.error('getLowResolutionMissionSnapShot fail, error: ${error}');
- });
- ```
-
-
## missionManager.lockMission
lockMission(missionId: number, callback: AsyncCallback<void>): void;
@@ -499,7 +408,7 @@ Locks a given mission. This API uses an asynchronous callback to return the resu
missionManager.getMissionInfos('', 10, (error, missions) => {
if (error.code) {
- console.error('getMissionInfos failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
+ console.error('getMissionInfos failed, error.code: ${error.code}, error.message: ${error.message}');
return;
}
console.log('size = ${missions.length}');
@@ -583,7 +492,7 @@ Unlocks a given mission. This API uses an asynchronous callback to return the re
missionManager.getMissionInfos('', 10, (error, missions) => {
if (error.code) {
- console.error('getMissionInfos failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
+ console.error('getMissionInfos failed, error.code: ${error.code}, error.message: ${error.message}');
return;
}
console.log('size = ${missions.length}');
@@ -671,7 +580,7 @@ Clears a given mission, regardless of whether it is locked. This API uses an asy
missionManager.getMissionInfos('', 10, (error, missions) => {
if (error.code) {
- console.error('getMissionInfos failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
+ console.error('getMissionInfos failed, error.code: ${error.code}, error.message: ${error.message}');
return;
}
console.log('size = ${missions.length}');
@@ -807,7 +716,7 @@ Switches a given mission to the foreground. This API uses an asynchronous callba
missionManager.getMissionInfos('', 10, (error, missions) => {
if (error.code) {
- console.error('getMissionInfos failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
+ console.error('getMissionInfos failed, error.code: ${error.code}, error.message: ${error.message}');
return;
}
console.log('size = ${missions.length}');
@@ -848,7 +757,7 @@ Switches a given mission to the foreground, with the startup parameters for the
missionManager.getMissionInfos('', 10, (error, missions) => {
if (error.code) {
- console.error('getMissionInfos failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
+ console.error('getMissionInfos failed, error.code: ${error.code}, error.message: ${error.message}');
return;
}
console.log('size = ${missions.length}');
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 e0aeababdf7186ba26db281d2465e3f033392a51..7844ed3008796cf449c32d09c246af86b65338d8 100644
--- a/en/application-dev/reference/apis/js-apis-application-want.md
+++ b/en/application-dev/reference/apis/js-apis-application-want.md
@@ -27,7 +27,6 @@ import Want from '@ohos.application.Want';
| action | string | No | Action to take, such as viewing and sharing application details. In implicit **Want**, you can define this attribute and use it together with **uri** or **parameters** to specify the operation to be performed on the data. For details, see [action](js-apis-app-ability-wantConstant.md#wantConstant.Action). For details about the definition and matching rules of implicit Want, see [Matching Rules of Explicit Want and Implicit Want](application-models/explicit-implicit-want-mappings.md). |
| parameters | {[key: string]: any} | No | Want parameters in the form of custom key-value (KV) pairs. By default, the following keys are carried:
- **ohos.aafwk.callerPid**: PID of the caller.
- **ohos.aafwk.param.callerToken**: token of the caller.
- **ohos.aafwk.param.callerUid**: UID in [bundleInfo](js-apis-bundle-BundleInfo.md#bundleinfo-1), that is, the application UID in the bundle information.
- **component.startup.newRules**: whether to enable the new control rule.
- **moduleName**: module name of the caller. No matter what this field is set to, the correct module name will be sent to the peer.
- **ohos.dlp.params.sandbox**: available only for DLP files. |
| entities | Array\ | No | Additional category information (such as browser and video player) of the ability. It is a supplement to the **action** field for implicit Want. and is used to filter ability types. For details, see [entity](js-apis-app-ability-wantConstant.md#wantConstant.Entity). |
-| moduleName9+ | string | No | Module to which the ability belongs.|
**Example**
diff --git a/en/application-dev/reference/apis/js-apis-audio.md b/en/application-dev/reference/apis/js-apis-audio.md
index 4abed77e24d5c6cf16d7fd84ce36cf806d06ce4e..1b41dfffac05d2d5af6c7d080860f89bec12d762 100644
--- a/en/application-dev/reference/apis/js-apis-audio.md
+++ b/en/application-dev/reference/apis/js-apis-audio.md
@@ -23,9 +23,9 @@ import audio from '@ohos.multimedia.audio';
| Name | Type | Readable | Writable| Description |
| --------------------------------------- | ----------| ---- | ---- | ------------------ |
-| LOCAL_NETWORK_ID9+ | string | Yes | No | Network ID of the local device.
This is a system API.
**System capability**: SystemCapability.Multimedia.Audio.Device |
-| DEFAULT_VOLUME_GROUP_ID9+ | number | Yes | No | Default volume group ID.
**System capability**: SystemCapability.Multimedia.Audio.Volume |
-| DEFAULT_INTERRUPT_GROUP_ID9+ | number | Yes | No | Default audio interruption group ID.
**System capability**: SystemCapability.Multimedia.Audio.Interrupt |
+| LOCAL_NETWORK_ID9+ | string | Yes | No | Network ID of the local device.
This is a system API.
**System capability**: SystemCapability.Multimedia.Audio.Device |
+| DEFAULT_VOLUME_GROUP_ID9+ | number | Yes | No | Default volume group ID.
**System capability**: SystemCapability.Multimedia.Audio.Volume |
+| DEFAULT_INTERRUPT_GROUP_ID9+ | number | Yes | No | Default audio interruption group ID.
**System capability**: SystemCapability.Multimedia.Audio.Interrupt |
**Example**
@@ -690,21 +690,19 @@ Describes the interruption event received by the application when playback is in
| forceType | [InterruptForceType](#interruptforcetype9) | Yes | Whether the interruption is taken by the system or to be taken by the application.|
| hintType | [InterruptHint](#interrupthint) | Yes | Hint provided along the interruption. |
-## VolumeEvent8+
+## VolumeEvent9+
Describes the event received by the application when the volume is changed.
-**System API**: This is a system API.
-
**System capability**: SystemCapability.Multimedia.Audio.Volume
| Name | Type | Mandatory | Description |
| ---------- | ----------------------------------- | ---- | -------------------------------------------------------- |
-| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. |
-| volume | number | Yes | Volume to set. The value range can be obtained by calling **getMinVolume** and **getMaxVolume**.|
-| updateUi | boolean | Yes | Whether to show the volume change in UI. |
-| volumeGroupId9+ | number | Yes | Volume group ID. It can be used as an input parameter of **getGroupManager**. |
-| networkId9+ | string | Yes | Network ID. |
+| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. |
+| volume | number | Yes | Volume to set. The value range can be obtained by calling **getMinVolume** and **getMaxVolume**. |
+| updateUi | boolean | Yes | Whether to show the volume change in UI. |
+| volumeGroupId | number | Yes | Volume group ID. It can be used as an input parameter of **getGroupManager**.
This is a system API. |
+| networkId | string | Yes | Network ID.
This is a system API. |
## MicStateChangeEvent9+
@@ -1112,7 +1110,7 @@ Sets the volume for a stream. This API uses an asynchronous callback to return t
> **NOTE**
>
-> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setVolume](#setvolume9) in **AudioVolumeGroupManager**.
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setVolume](#setvolume9) in **AudioVolumeGroupManager**. The substitute API is available only for system applications.
**Required permissions**: ohos.permission.ACCESS_NOTIFICATION_POLICY
@@ -1148,7 +1146,7 @@ Sets the volume for a stream. This API uses a promise to return the result.
> **NOTE**
>
-> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setVolume](#setvolume9) in **AudioVolumeGroupManager**.
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setVolume](#setvolume9) in **AudioVolumeGroupManager**. The substitute API is available only for system applications.
**Required permissions**: ohos.permission.ACCESS_NOTIFICATION_POLICY
@@ -1374,7 +1372,7 @@ Mutes or unmutes a stream. This API uses an asynchronous callback to return the
> **NOTE**
>
-> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [mute](#mute9) in **AudioVolumeGroupManager**.
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [mute](#mute9) in **AudioVolumeGroupManager**. The substitute API is available only for system applications.
**System capability**: SystemCapability.Multimedia.Audio.Volume
@@ -1406,7 +1404,7 @@ Mutes or unmutes a stream. This API uses a promise to return the result.
> **NOTE**
>
-> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [mute](#mute9) in **AudioVolumeGroupManager**.
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [mute](#mute9) in **AudioVolumeGroupManager**. The substitute API is available only for system applications.
**System capability**: SystemCapability.Multimedia.Audio.Volume
@@ -1566,7 +1564,7 @@ Sets the ringer mode. This API uses an asynchronous callback to return the resul
> **NOTE**
>
-> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setRingerMode](#setringermode9) in **AudioVolumeGroupManager**.
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setRingerMode](#setringermode9) in **AudioVolumeGroupManager**. The substitute API is available only for system applications.
**Required permissions**: ohos.permission.ACCESS_NOTIFICATION_POLICY
@@ -1601,7 +1599,8 @@ Sets the ringer mode. This API uses a promise to return the result.
> **NOTE**
>
-> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setRingerMode](#setringermode9) in **AudioVolumeGroupManager**.
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setRingerMode](#setringermode9) in **AudioVolumeGroupManager**. The substitute API is available only for system applications.
+
**Required permissions**: ohos.permission.ACCESS_NOTIFICATION_POLICY
@@ -1763,7 +1762,7 @@ Sets a device to the active state. This API uses an asynchronous callback to ret
| Name | Type | Mandatory| Description |
| ---------- | ------------------------------------- | ---- | ------------------------ |
-| deviceType | [ActiveDeviceType](#activedevicetypedeprecated) | Yes | Active audio device type. |
+| deviceType | [ActiveDeviceType](#activedevicetypedeprecated) | Yes | Active audio device type. |
| active | boolean | Yes | Active state to set. The value **true** means to set the device to the active state, and **false** means the opposite. |
| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
@@ -1795,7 +1794,7 @@ Sets a device to the active state. This API uses a promise to return the result.
| Name | Type | Mandatory| Description |
| ---------- | ------------------------------------- | ---- | ------------------ |
-| deviceType | [ActiveDeviceType](#activedevicetypedeprecated) | Yes | Active audio device type. |
+| deviceType | [ActiveDeviceType](#activedevicetypedeprecated) | Yes | Active audio device type.|
| active | boolean | Yes | Active state to set. The value **true** means to set the device to the active state, and **false** means the opposite. |
**Return value**
@@ -1829,7 +1828,7 @@ Checks whether a device is active. This API uses an asynchronous callback to ret
| Name | Type | Mandatory| Description |
| ---------- | ------------------------------------- | ---- | ------------------------ |
-| deviceType | [ActiveDeviceType](#activedevicetypedeprecated) | Yes | Active audio device type. |
+| deviceType | [ActiveDeviceType](#activedevicetypedeprecated) | Yes | Active audio device type. |
| callback | AsyncCallback<boolean> | Yes | Callback used to return the active state of the device.|
**Example**
@@ -1860,7 +1859,7 @@ Checks whether a device is active. This API uses a promise to return the result.
| Name | Type | Mandatory| Description |
| ---------- | ------------------------------------- | ---- | ------------------ |
-| deviceType | [ActiveDeviceType](#activedevicetypedeprecated) | Yes | Active audio device type. |
+| deviceType | [ActiveDeviceType](#activedevicetypedeprecated) | Yes | Active audio device type.|
**Return value**
@@ -2003,13 +2002,13 @@ audioManager.isMicrophoneMute().then((value) => {
});
```
-### on('volumeChange')(deprecated)
+### on('volumeChange')9+
on(type: 'volumeChange', callback: Callback\): void
> **NOTE**
>
-> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [on](#on9) in **AudioVolumeManager**.
+> You are advised to use [on('volumeChange')](#onvolumechange9) in **AudioVolumeManager**.
Subscribes to system volume change events.
@@ -2024,7 +2023,7 @@ Currently, when multiple **AudioManager** instances are used in a single process
| Name | Type | Mandatory| Description |
| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Event type. The value **'volumeChange'** means the system volume change event, which is triggered when a system volume change is detected.|
-| callback | Callback<[VolumeEvent](#volumeevent8)> | Yes | Callback used to return the system volume change event. |
+| callback | Callback<[VolumeEvent](#volumeevent9)> | Yes | Callback used to return the system volume change event. |
**Example**
@@ -2073,7 +2072,7 @@ Subscribes to device change events. When a device is connected or disconnected,
> **NOTE**
>
-> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [on](#on9) in **AudioRoutingManager**.
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [on('deviceChange')](#ondevicechange9) in **AudioRoutingManager**.
**System capability**: SystemCapability.Multimedia.Audio.Device
@@ -2103,7 +2102,7 @@ Unsubscribes from device change events.
> **NOTE**
>
-> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [off](#off9) in **AudioRoutingManager**.
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [off('deviceChange')](#offdevicechange9) in **AudioRoutingManager**.
**System capability**: SystemCapability.Multimedia.Audio.Device
@@ -2122,7 +2121,7 @@ audioManager.off('deviceChange', (deviceChanged) => {
});
```
-### on('interrupt')(deprecated)
+### on('interrupt')
on(type: 'interrupt', interrupt: AudioInterrupt, callback: Callback\): void
@@ -2130,10 +2129,6 @@ Subscribes to audio interruption events. When the application's audio is interru
Same as [on('audioInterrupt')](#onaudiointerrupt9), this API is used to listen for focus changes. However, this API is used in scenarios without audio streams (no **AudioRenderer** instance is created), such as frequency modulation (FM) and voice wakeup.
-> **NOTE**
->
-> This API is supported since API version 7 and deprecated since API version 9.
-
**System capability**: SystemCapability.Multimedia.Audio.Renderer
**Parameters**
@@ -2164,16 +2159,12 @@ audioManager.on('interrupt', interAudioInterrupt, (InterruptAction) => {
});
```
-### off('interrupt')(deprecated)
+### off('interrupt')
off(type: 'interrupt', interrupt: AudioInterrupt, callback?: Callback\): void
Unsubscribes from audio interruption events.
-> **NOTE**
->
-> This API is supported since API version 7 and deprecated since API version 9.
-
**System capability**: SystemCapability.Multimedia.Audio.Renderer
**Parameters**
@@ -2338,7 +2329,7 @@ Subscribes to system volume change events. This API uses an asynchronous callbac
| Name | Type | Mandatory| Description |
| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Event type. The value **'volumeChange'** means the system volume change event, which is triggered when the system volume changes.|
-| callback | Callback<[VolumeEvent](#volumeevent8)> | Yes | Callback used to return the system volume change event. |
+| callback | Callback<[VolumeEvent](#volumeevent9)> | Yes | Callback used to return the system volume change event. |
**Error codes**
@@ -3465,7 +3456,7 @@ audioRoutingManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG).then((data)
});
```
-### on9+
+### on('deviceChange')9+
on(type: 'deviceChange', deviceFlag: DeviceFlag, callback: Callback): void
@@ -3500,7 +3491,7 @@ audioRoutingManager.on('deviceChange', audio.DeviceFlag.OUTPUT_DEVICES_FLAG, (de
});
```
-### off9+
+### off('deviceChange')9+
off(type: 'deviceChange', callback?: Callback): void
@@ -3934,6 +3925,151 @@ async function selectOutputDeviceByFilter(){
}
```
+### getPreferOutputDeviceForRendererInfo10+
+
+getPreferOutputDeviceForRendererInfo(rendererInfo: AudioRendererInfo, callback: AsyncCallback<AudioDeviceDescriptors>): void
+
+Obtains the output device with the highest priority based on the audio renderer information. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Multimedia.Audio.Device
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| --------------------------- | ------------------------------------------------------------ | ---- | ------------------------- |
+| rendererInfo | [AudioRendererInfo](#audiorendererinfo8) | Yes | Audio renderer information. |
+| callback | AsyncCallback<[AudioDeviceDescriptors](#audiodevicedescriptors)> | Yes | Callback used to return the information about the output device with the highest priority.|
+
+**Example**
+```js
+let rendererInfo = {
+ content : audio.ContentType.CONTENT_TYPE_MUSIC,
+ usage : audio.StreamUsage.STREAM_USAGE_MEDIA,
+ rendererFlags : 0 }
+
+async function getPreferOutputDevice() {
+ audioRoutingManager.getPreferOutputDeviceForRendererInfo(rendererInfo, (err, desc) => {
+ if (err) {
+ console.error(`Result ERROR: ${err}`);
+ } else {
+ console.info(`device descriptor: ${desc}`);
+ }
+ });
+}
+```
+
+### getPreferOutputDeviceForRendererInfo10+
+getPreferOutputDeviceForRendererInfo(rendererInfo: AudioRendererInfo): Promise<AudioDeviceDescriptors>
+
+Obtains the output device with the highest priority based on the audio renderer information. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Multimedia.Audio.Device
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ----------------------| ------------------------------------------------------------ | ---- | ------------------------- |
+| rendererInfo | [AudioRendererInfo](#audiorendererinfo8) | Yes | Audio renderer information. |
+
+**Return value**
+
+| Type | Description |
+| --------------------- | --------------------------- |
+| Promise<[AudioDeviceDescriptors](#audiodevicedescriptors)> | Promise used to return the information about the output device with the highest priority.|
+
+**Error codes**
+
+For details about the error codes, see [Audio Error Codes](../errorcodes/errorcode-audio.md).
+
+| ID| Error Message|
+| ------- | --------------------------------------------|
+| 6800101 | if input parameter value error |
+
+**Example**
+
+```js
+let rendererInfo = {
+ content : audio.ContentType.CONTENT_TYPE_MUSIC,
+ usage : audio.StreamUsage.STREAM_USAGE_MEDIA,
+ rendererFlags : 0 }
+
+async function getPreferOutputDevice() {
+ audioRoutingManager.getPreferOutputDeviceForRendererInfo(rendererInfo).then((desc) => {
+ console.info(`device descriptor: ${desc}`);
+ }).catch((err) => {
+ console.error(`Result ERROR: ${err}`);
+ })
+}
+```
+
+### on('preferOutputDeviceChangeForRendererInfo')10+
+
+on(type: 'preferOutputDeviceChangeForRendererInfo', rendererInfo: AudioRendererInfo, callback: Callback): void
+
+Subscribes to the change of the output device with the highest priority. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Multimedia.Audio.Device
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| :------- | :--------------------------------------------------- | :--- | :----------------------------------------- |
+| type | string | Yes | Event type. The value **'preferOutputDeviceChangeForRendererInfo'** means the event triggered when the output device with the highest priority changes.|
+| rendererInfo | [AudioRendererInfo](#audiorendererinfo8) | Yes | Audio renderer information. |
+| callback | Callback<[AudioDeviceDescriptors](#audiodevicedescriptors)\> | Yes | Callback used to return the information about the output device with the highest priority. |
+
+**Error codes**
+
+For details about the error codes, see [Audio Error Codes](../errorcodes/errorcode-audio.md).
+
+| ID| Error Message|
+| ------- | --------------------------------------------|
+| 6800101 | if input parameter value error |
+
+**Example**
+
+```js
+let rendererInfo = {
+ content : audio.ContentType.CONTENT_TYPE_MUSIC,
+ usage : audio.StreamUsage.STREAM_USAGE_MEDIA,
+ rendererFlags : 0 }
+
+audioRoutingManager.on('preferOutputDeviceChangeForRendererInfo', rendererInfo, (desc) => {
+ console.info(`device descriptor: ${desc}`);
+});
+```
+
+### off('preferOutputDeviceChangeForRendererInfo')10+
+
+off(type: 'preferOutputDeviceChangeForRendererInfo', callback?: Callback): void
+
+Unsubscribes from the change of the output device with the highest priority.
+
+**System capability**: SystemCapability.Multimedia.Audio.Device
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | --------------------------------------------------- | ---- | ------------------------------------------ |
+| type | string | Yes | Event type. The value **'preferOutputDeviceChangeForRendererInfo'** means the event triggered when the output device with the highest priority changes.|
+| callback | Callback<[AudioDeviceDescriptors](#audiodevicedescriptors)> | No | Callback used for unsubscription. |
+
+**Error codes**
+
+For details about the error codes, see [Audio Error Codes](../errorcodes/errorcode-audio.md).
+
+| ID| Error Message|
+| ------- | --------------------------------------------|
+| 6800101 | if input parameter value error |
+
+**Example**
+
+```js
+audioRoutingManager.off('preferOutputDeviceChangeForRendererInfo', () => {
+ console.info('Should be no callback.');
+});
+```
+
## AudioRendererChangeInfoArray9+
Defines an **AudioRenderChangeInfo** array, which is read-only.
@@ -3946,12 +4082,13 @@ Describes the audio renderer change event.
**System capability**: SystemCapability.Multimedia.Audio.Renderer
-| Name | Type | Readable | Writable | Description |
-| ------------- | ---------------------------------------- | -------- | -------- | ---------------------------------------------------------- |
-| streamId | number | Yes | No | Unique ID of an audio stream. |
-| clientUid | number | Yes | No | UID of the audio renderer client.
This is a system API. |
-| rendererInfo | [AudioRendererInfo](#audiorendererinfo8) | Yes | No | Audio renderer information. |
-| rendererState | [AudioState](#audiostate) | Yes | No | Audio state.
This is a system API. |
+| Name | Type | Readable | Writable | Description |
+| ----------------- | ------------------------------------------------- | -------- | -------- | ---------------------------------------------------------- |
+| streamId | number | Yes | No | Unique ID of an audio stream. |
+| clientUid | number | Yes | No | UID of the audio renderer client.
This is a system API. |
+| rendererInfo | [AudioRendererInfo](#audiorendererinfo8) | Yes | No | Audio renderer information. |
+| rendererState | [AudioState](#audiostate) | Yes | No | Audio state.
This is a system API. |
+| deviceDescriptors | [AudioDeviceDescriptors](#audiodevicedescriptors) | Yes | No | Audio device description. |
**Example**
@@ -4003,12 +4140,13 @@ Describes the audio capturer change event.
**System capability**: SystemCapability.Multimedia.Audio.Capturer
-| Name | Type | Readable | Writable | Description |
-| ------------- | ---------------------------------------- | -------- | -------- | ---------------------------------------------------------- |
-| streamId | number | Yes | No | Unique ID of an audio stream. |
-| clientUid | number | Yes | No | UID of the audio capturer client.
This is a system API. |
-| capturerInfo | [AudioCapturerInfo](#audiocapturerinfo8) | Yes | No | Audio capturer information. |
-| capturerState | [AudioState](#audiostate) | Yes | No | Audio state.
This is a system API. |
+| Name | Type | Readable | Writable | Description |
+| ----------------- | ------------------------------------------------- | -------- | -------- | ---------------------------------------------------------- |
+| streamId | number | Yes | No | Unique ID of an audio stream. |
+| clientUid | number | Yes | No | UID of the audio capturer client.
This is a system API. |
+| capturerInfo | [AudioCapturerInfo](#audiocapturerinfo8) | Yes | No | Audio capturer information. |
+| capturerState | [AudioState](#audiostate) | Yes | No | Audio state.
This is a system API. |
+| deviceDescriptors | [AudioDeviceDescriptors](#audiodevicedescriptors) | Yes | No | Audio device description. |
**Example**
@@ -4102,7 +4240,7 @@ Implements filter criteria. Before calling **selectOutputDeviceByFilter**, you m
| Name | Type | Mandatory | Description |
| ------------ | ---------------------------------------- | --------- | ------------------------------------------------------------ |
-| uid | number | Yes | Application ID.
**System capability**: SystemCapability.Multimedia.Audio.Core |
+| uid | number | No | Application ID.
**System capability**: SystemCapability.Multimedia.Audio.Core |
| rendererInfo | [AudioRendererInfo](#audiorendererinfo8) | No | Audio renderer information.
**System capability**: SystemCapability.Multimedia.Audio.Renderer |
| rendererId | number | No | Unique ID of an audio stream.
**System capability**: SystemCapability.Multimedia.Audio.Renderer |
@@ -4586,15 +4724,15 @@ let filePath = path + '/StarWars10s-2C-48000-4SW.wav';
let file = fs.openSync(filePath, fs.OpenMode.READ_ONLY);
let stat = await fs.stat(path);
let buf = new ArrayBuffer(bufferSize);
-let len = stat.size % this.bufferSize == 0 ? Math.floor(stat.size / this.bufferSize) : Math.floor(stat.size / this.bufferSize + 1);
+let len = stat.size % bufferSize == 0 ? Math.floor(stat.size / bufferSize) : Math.floor(stat.size / bufferSize + 1);
for (let i = 0;i < len; i++) {
let options = {
- offset: i * this.bufferSize,
- length: this.bufferSize
+ offset: i * bufferSize,
+ length: bufferSize
}
let readsize = await fs.read(file.fd, buf, options)
let writeSize = await new Promise((resolve,reject)=>{
- this.audioRenderer.write(buf,(err,writeSize)=>{
+ audioRenderer.write(buf,(err,writeSize)=>{
if(err){
reject(err)
}else{
@@ -4641,15 +4779,15 @@ let filePath = path + '/StarWars10s-2C-48000-4SW.wav';
let file = fs.openSync(filePath, fs.OpenMode.READ_ONLY);
let stat = await fs.stat(path);
let buf = new ArrayBuffer(bufferSize);
-let len = stat.size % this.bufferSize == 0 ? Math.floor(stat.size / this.bufferSize) : Math.floor(stat.size / this.bufferSize + 1);
+let len = stat.size % bufferSize == 0 ? Math.floor(stat.size / bufferSize) : Math.floor(stat.size / bufferSize + 1);
for (let i = 0;i < len; i++) {
let options = {
- offset: i * this.bufferSize,
- length: this.bufferSize
+ offset: i * bufferSize,
+ length: bufferSize
}
let readsize = await fs.read(file.fd, buf, options)
try{
- let writeSize = await this.audioRenderer.write(buf);
+ let writeSize = await audioRenderer.write(buf);
} catch(err) {
console.error(`audioRenderer.write err: ${err}`);
}
@@ -4986,18 +5124,18 @@ audioRenderer.setVolume(0.5, (err, data)=>{
on(type: 'audioInterrupt', callback: Callback\): void
-Subscribes to audio interruption events. This API uses a callback to get interrupt events.
+Subscribes to audio interruption events. This API uses a callback to obtain interrupt events.
-Same as [on('interrupt')](#oninterruptdeprecated), this API has obtained the focus before **start**, **pause**, or **stop** of **AudioRenderer** is called. Therefore, you do not need to request the focus.
+Same as [on('interrupt')](#oninterrupt), this API is used to listen for focus changes. The **AudioRenderer** instance proactively gains the focus when the **start** event occurs and releases the focus when the **pause** or **stop** event occurs. Therefore, you do not need to request to gain or release the focus.
**System capability**: SystemCapability.Multimedia.Audio.Interrupt
**Parameters**
-| Name | Type | Mandatory | Description |
-| -------- | -------------------------------------------- | --------- | ------------------------------------------------------------ |
-| type | string | Yes | Event type. The value **'audioInterrupt'** means the audio interruption event, which is triggered when audio playback is interrupted. |
-| callback | Callback<[InterruptEvent](#interruptevent9)> | Yes | Callback used to return the audio interruption event. |
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------------- | --------- | ------------------------------------------------------------ |
+| type | string | Yes | Event type. The value **'audioInterrupt'** means the audio interruption event, which is triggered when audio rendering is interrupted. |
+| callback | Callback\<[InterruptEvent](#interruptevent9)\> | Yes | Callback used to return the audio interruption event. |
**Error codes**
@@ -5010,50 +5148,68 @@ For details about the error codes, see [Audio Error Codes](../errorcodes/errorco
**Example**
```js
-let isPlay;
-let started;
+let isPlaying; // An identifier specifying whether rendering is in progress.
+let isDucked; // An identifier specifying whether the audio volume is reduced.
onAudioInterrupt();
async function onAudioInterrupt(){
audioRenderer.on('audioInterrupt', async(interruptEvent) => {
if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_FORCE) {
+ // The system forcibly interrupts audio rendering. The application must update the status and displayed content accordingly.
switch (interruptEvent.hintType) {
case audio.InterruptHint.INTERRUPT_HINT_PAUSE:
- console.info('Force paused. Stop writing');
- isPlay = false;
+ // The audio stream has been paused and temporarily loses the focus. It will receive the interruptEvent corresponding to resume when it is able to regain the focus.
+ console.info('Force paused. Update playing status and stop writing');
+ isPlaying = false; // A simplified processing indicating several operations for switching the application to the paused state.
break;
case audio.InterruptHint.INTERRUPT_HINT_STOP:
- console.info('Force stopped. Stop writing');
- isPlay = false;
+ // The audio stream has been stopped and permanently loses the focus. The user must manually trigger the operation to resume rendering.
+ console.info('Force stopped. Update playing status and stop writing');
+ isPlaying = false; // A simplified processing indicating several operations for switching the application to the paused state.
+ break;
+ case audio.InterruptHint.INTERRUPT_HINT_DUCK:
+ // The audio stream is rendered at a reduced volume.
+ console.info('Force ducked. Update volume status');
+ isDucked = true; // A simplified processing indicating several operations for updating the volume status.
+ break;
+ case audio.InterruptHint.INTERRUPT_HINT_UNDUCK:
+ // The audio stream is rendered at the normal volume.
+ console.info('Force ducked. Update volume status');
+ isDucked = false; // A simplified processing indicating several operations for updating the volume status.
+ break;
+ default:
+ console.info('Invalid interruptEvent');
break;
}
} else if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_SHARE) {
+ // The application can choose to take action or ignore.
switch (interruptEvent.hintType) {
case audio.InterruptHint.INTERRUPT_HINT_RESUME:
+ // It is recommended that the application continue rendering. (The audio stream has been forcibly paused and temporarily lost the focus. It can resume rendering now.)
console.info('Resume force paused renderer or ignore');
- await audioRenderer.start().then(async function () {
- console.info('AudioInterruptMusic: renderInstant started :SUCCESS ');
- started = true;
- }).catch((err) => {
- console.error(`AudioInterruptMusic: renderInstant start :ERROR : ${err}`);
- started = false;
- });
- if (started) {
- isPlay = true;
- console.info(`AudioInterruptMusic Renderer started : isPlay : ${isPlay}`);
- } else {
- console.error('AudioInterruptMusic Renderer start failed');
- }
+ // To continue rendering, the application must perform the required operations.
break;
case audio.InterruptHint.INTERRUPT_HINT_PAUSE:
+ // It is recommended that the application pause rendering.
console.info('Choose to pause or ignore');
- if (isPlay == true) {
- isPlay == false;
- console.info('AudioInterruptMusic: Media PAUSE : TRUE');
- } else {
- isPlay = true;
- console.info('AudioInterruptMusic: Media PLAY : TRUE');
- }
+ // To pause rendering, the application must perform the required operations.
+ break;
+ case audio.InterruptHint.INTERRUPT_HINT_STOP:
+ // It is recommended that the application stop rendering.
+ console.info('Choose to stop or ignore');
+ // To stop rendering, the application must perform the required operations.
+ break;
+ case audio.InterruptHint.INTERRUPT_HINT_DUCK:
+ // It is recommended that the application reduce the volume for rendering.
+ console.info('Choose to duck or ignore');
+ // To decrease the volume for rendering, the application must perform the required operations.
+ break;
+ case audio.InterruptHint.INTERRUPT_HINT_UNDUCK:
+ // It is recommended that the application resume rendering at the normal volume.
+ console.info('Choose to unduck or ignore');
+ // To resume rendering at the normal volume, the application must perform the required operations.
+ break;
+ default:
break;
}
}
@@ -5729,6 +5885,84 @@ audioCapturer.getBufferSize().then((data) => {
```
+### on('audioInterrupt')10+
+
+on(type: 'audioInterrupt', callback: Callback\): void
+
+Subscribes to audio interruption events. This API uses a callback to get interrupt events.
+
+Same as [on('interrupt')](#oninterrupt), this API is used to listen for focus changes. The **AudioCapturer** instance proactively gains the focus when the **start** event occurs and releases the focus when the **pause** or **stop** event occurs. Therefore, you do not need to request to gain or release the focus.
+
+**System capability**: SystemCapability.Multimedia.Audio.Interrupt
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------------- | --------- | ------------------------------------------------------------ |
+| type | string | Yes | Event type. The value **'audioInterrupt'** means the audio interruption event, which is triggered when audio capturing is interrupted. |
+| callback | Callback\<[InterruptEvent](#interruptevent9)\> | Yes | Callback used to return the audio interruption event. |
+
+**Error codes**
+
+For details about the error codes, see [Audio Error Codes](../errorcodes/errorcode-audio.md).
+
+| ID | Error Message |
+| ------- | ------------------------------ |
+| 6800101 | if input parameter value error |
+
+**Example**
+
+```js
+let isCapturing; // An identifier specifying whether capturing is in progress.
+onAudioInterrupt();
+
+async function onAudioInterrupt(){
+ audioCapturer.on('audioInterrupt', async(interruptEvent) => {
+ if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_FORCE) {
+ // The system forcibly interrupts audio capturing. The application must update the status and displayed content accordingly.
+ switch (interruptEvent.hintType) {
+ case audio.InterruptHint.INTERRUPT_HINT_PAUSE:
+ // The audio stream has been paused and temporarily loses the focus. It will receive the interruptEvent corresponding to resume when it is able to regain the focus.
+ console.info('Force paused. Update capturing status and stop reading');
+ isCapturing = false; // A simplified processing indicating several operations for switching the application to the paused state.
+ break;
+ case audio.InterruptHint.INTERRUPT_HINT_STOP:
+ // The audio stream has been stopped and permanently loses the focus. The user must manually trigger the operation to resume capturing.
+ console.info('Force stopped. Update capturing status and stop reading');
+ isCapturing = false; // A simplified processing indicating several operations for switching the application to the paused state.
+ break;
+ default:
+ console.info('Invalid interruptEvent');
+ break;
+ }
+ } else if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_SHARE) {
+ // The application can choose to take action or ignore.
+ switch (interruptEvent.hintType) {
+ case audio.InterruptHint.INTERRUPT_HINT_RESUME:
+ // It is recommended that the application continue capturing. (The audio stream has been forcibly paused and temporarily lost the focus. It can resume capturing now.)
+ console.info('Resume force paused renderer or ignore');
+ // To continue capturing, the application must perform the required operations.
+ break;
+ case audio.InterruptHint.INTERRUPT_HINT_PAUSE:
+ // It is recommended that the application pause capturing.
+ console.info('Choose to pause or ignore');
+ // To pause capturing, the application must perform the required operations.
+ break;
+ case audio.InterruptHint.INTERRUPT_HINT_STOP:
+ // It is recommended that the application stop capturing.
+ console.info('Choose to stop or ignore');
+ // To stop capturing, the application must perform the required operations.
+ break;
+ default:
+ break;
+ }
+ }
+ });
+}
+
+```
+
+
### on('markReach')8+
on(type: "markReach", frame: number, callback: Callback<number>): void
@@ -6185,7 +6419,7 @@ Describes the callback invoked for audio interruption or focus gain events.
> **NOTE**
>
-> This API is supported since API version 7 and deprecated since API version 9.
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [InterruptEvent](#interruptevent9).
**System capability**: SystemCapability.Multimedia.Audio.Renderer
diff --git a/en/application-dev/reference/apis/js-apis-avsession.md b/en/application-dev/reference/apis/js-apis-avsession.md
index c614dddd308d3cb727c8c1acb2ce474380b3ccc5..b89eb42bc8793b9d28f1682ab87b1ac9f157c14d 100644
--- a/en/application-dev/reference/apis/js-apis-avsession.md
+++ b/en/application-dev/reference/apis/js-apis-avsession.md
@@ -3741,7 +3741,7 @@ Subscribes to playlist item changes.
| Name | Type | Mandatory| Description |
| -------- | ----------------------------------------------------- | ---- | ---------------------------------------------------------------------------- |
| type | string | Yes | Event type. The event **'queueItemsChange'** is reported when one or more items in the playlist changes.|
-| callback | (items: Array<[AVQueueItem](#avqueueitem10)\>) => void | Yes | Callback used for subscription. **items** in the callback indicates the names of the items that change, and **args** indicates the parameters carried in the event. |
+| callback | (items: Array<[AVQueueItem](#avqueueitem10)\>) => void | Yes | Callback used for subscription. The **items** parameter in the callback indicates the changed items in the playlist. |
**Error codes**
@@ -3775,7 +3775,7 @@ Subscribes to playlist name changes.
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | ------------------------------------------------------------------------------- |
| type | string | Yes | Event type. The event **'queueTitleChange'** is reported when the playlist name changes.|
-| callback | (title: string) => void | Yes | Callback used for subscription. **items** in the callback indicates the name of the playlist that changes, and **args** indicates the parameters carried in the event. |
+| callback | (title: string) => void | Yes | Callback used for subscription. The **title** parameter in the callback indicates the changed playlist name. |
**Error codes**
diff --git a/en/application-dev/reference/apis/js-apis-backgroundTaskManager.md b/en/application-dev/reference/apis/js-apis-backgroundTaskManager.md
index 775bc6665152c9d2870e28f677022d8734a551fe..325b32ef4780b5a884cdb2f07b0eaf73c124fcc4 100644
--- a/en/application-dev/reference/apis/js-apis-backgroundTaskManager.md
+++ b/en/application-dev/reference/apis/js-apis-backgroundTaskManager.md
@@ -161,7 +161,7 @@ Requests a continuous task from the system. This API uses an asynchronous callba
| Name | Type | Mandatory| Description |
| --------- | --------------------------------------------- | ---- | ------------------------------------------------------------ |
-| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-ability-context.md).|
+| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-inner-application-context.md).|
| bgMode | [BackgroundMode](#backgroundmode8) | Yes | Background mode requested. |
| wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | Yes | Notification parameter, which is used to specify the target page that is redirected to when a continuous task notification is clicked. |
| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
@@ -253,7 +253,7 @@ Requests a continuous task from the system. This API uses a promise to return th
| Name | Type | Mandatory| Description |
| --------- | --------------------------------------------- | ---- | ------------------------------------------------------------ |
-| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-ability-context.md).|
+| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-inner-application-context.md).|
| bgMode | [BackgroundMode](#backgroundmode8) | Yes | Background mode requested. |
| wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | Yes | Notification parameter, which is used to specify the target page that is redirected to when a continuous task notification is clicked. |
@@ -339,7 +339,7 @@ Requests to cancel a continuous task. This API uses an asynchronous callback to
| Name | Type | Mandatory | Description |
| -------- | ------------------------- | ---- | ---------------------------------------- |
-| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-ability-context.md).|
+| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-inner-application-context.md).|
| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
**Example**
@@ -395,7 +395,7 @@ Requests to cancel a continuous task. This API uses a promise to return the resu
| Name | Type | Mandatory | Description |
| ------- | ------- | ---- | ---------------------------------------- |
-| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-ability-context.md).|
+| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-inner-application-context.md).|
**Return value**
diff --git a/en/application-dev/reference/apis/js-apis-batteryStatistics.md b/en/application-dev/reference/apis/js-apis-batteryStatistics.md
index 89cd4ab39ee2d9a7c7e0a4f9b03a4755b55b864f..721a432caaf67116a6df882c0e8995e76b893a7e 100644
--- a/en/application-dev/reference/apis/js-apis-batteryStatistics.md
+++ b/en/application-dev/reference/apis/js-apis-batteryStatistics.md
@@ -18,7 +18,7 @@ import batteryStats from '@ohos.batteryStatistics';
getBatteryStats(): Promise
-Obtains the power consumption information list, using a promise to return the result.
+Obtains the power consumption information list. This API uses a promise to return the result.
**System API**: This is a system API.
@@ -34,9 +34,9 @@ Obtains the power consumption information list, using a promise to return the re
For details about the error codes, see [Thermal Manager Error Codes](../errorcodes/errorcode-batteryStatistics.md).
-| Code| Error Message |
-| -------- | -------------- |
-| 4600101 | Operation failed. Cannot connect to service.|
+| Code | Error Message |
+|---------|---------|
+| 4600101 | Operation failed. Cannot connect to service.|
**Example**
@@ -64,15 +64,15 @@ Obtains the power consumption information list. This API uses an asynchronous ca
| Name | Type | Mandatory| Description |
| -------- | ----------------------------------------------------------- | ---- | ------------------------------------------------------------ |
-| callback | AsyncCallback> | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is the array of power consumption information obtained. If the operation failed, **err** is an error object.|
+| callback | AsyncCallback> | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is the array of power consumption information obtained (that is, **Array<[BatteryStatsInfo](#batterystatsinfo)>>**). If the operation failed, **err** is an error object.|
**Error codes**
For details about the error codes, see [Thermal Manager Error Codes](../errorcodes/errorcode-batteryStatistics.md).
-| Code| Error Message |
-| -------- | -------------- |
-| 4600101 | Operation failed. Cannot connect to service.|
+| Code | Error Message |
+|---------|---------|
+| 4600101 | Operation failed. Cannot connect to service.|
**Example**
@@ -112,9 +112,9 @@ Obtains the power consumption of an application.
For details about the error codes, see [Thermal Manager Error Codes](../errorcodes/errorcode-batteryStatistics.md).
-| Code| Error Message |
-| -------- | -------------- |
-| 4600101 | Operation failed. Cannot connect to service.|
+| Code | Error Message |
+|---------|---------|
+| 4600101 | Operation failed. Cannot connect to service.|
**Example**
@@ -153,9 +153,9 @@ Obtains the proportion of the power consumption of an application.
For details about the error codes, see [Thermal Manager Error Codes](../errorcodes/errorcode-batteryStatistics.md).
-| Code| Error Message |
-| -------- | -------------- |
-| 4600101 | Operation failed. Cannot connect to service.|
+| Code | Error Message |
+|---------|---------|
+| 4600101 | Operation failed. Cannot connect to service.|
**Example**
@@ -194,16 +194,16 @@ Obtains the power consumption of a hardware unit according to the consumption ty
For details about the error codes, see [Thermal Manager Error Codes](../errorcodes/errorcode-batteryStatistics.md).
-| Code| Error Message |
-| -------- | -------------- |
-| 4600101 | Operation failed. Cannot connect to service.|
+| Code | Error Message |
+|---------|---------|
+| 4600101 | Operation failed. Cannot connect to service.|
**Example**
```js
try {
var value = batteryStats.getHardwareUnitPowerValue(ConsumptionType.CONSUMPTION_TYPE_SCREEN);
- console.info('battery statistics percent of hardware is: ' + percent);
+ console.info('battery statistics value of hardware is: ' + value);
} catch(err) {
console.error('get battery statistics percent of hardware failed, err: ' + err);
}
@@ -235,15 +235,15 @@ Obtains the proportion of the power consumption of a hardware unit according to
For details about the error codes, see [Thermal Manager Error Codes](../errorcodes/errorcode-batteryStatistics.md).
-| Code| Error Message |
-| -------- | -------------- |
-| 4600101 | Operation failed. Cannot connect to service.|
+| Code | Error Message |
+|---------|---------|
+| 4600101 | Operation failed. Cannot connect to service.|
**Example**
```js
try {
- var value = batteryStats.getHardwareUnitPowerPercent(ConsumptionType.CONSUMPTION_TYPE_SCREEN);
+ var percent = batteryStats.getHardwareUnitPowerPercent(ConsumptionType.CONSUMPTION_TYPE_SCREEN);
console.info('battery statistics percent of hardware is: ' + percent);
} catch(err) {
console.error('get battery statistics percent of hardware failed, err: ' + err);
diff --git a/en/application-dev/reference/apis/js-apis-bluetooth.md b/en/application-dev/reference/apis/js-apis-bluetooth.md
index b1528f9e2fa160f1616ba9a86370d4a6d721546b..f22961f16809055e3ab560afb78750e42030aec3 100644
--- a/en/application-dev/reference/apis/js-apis-bluetooth.md
+++ b/en/application-dev/reference/apis/js-apis-bluetooth.md
@@ -4,7 +4,8 @@ The **Bluetooth** module provides classic Bluetooth capabilities and Bluetooth L
> **NOTE**
>
-> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+> - The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+> - The APIs provided by this module are no longer maintained since API version 9. You are advised to use [bluetoothManager](js-apis-bluetoothManager.md).
@@ -15,12 +16,15 @@ import bluetooth from '@ohos.bluetooth';
```
-## bluetooth.enableBluetooth8+
+## bluetooth.enableBluetooth8+(deprecated)
enableBluetooth(): boolean
Enables Bluetooth.
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.enableBluetooth](js-apis-bluetoothManager.md#bluetoothmanagerenablebluetooth).
+
**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -38,12 +42,15 @@ let enable = bluetooth.enableBluetooth();
```
-## bluetooth.disableBluetooth8+
+## bluetooth.disableBluetooth8+(deprecated)
disableBluetooth(): boolean
Disables Bluetooth.
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.disableBluetooth](js-apis-bluetoothManager.md#bluetoothmanagerdisablebluetooth).
+
**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -61,12 +68,15 @@ let disable = bluetooth.disableBluetooth();
```
-## bluetooth.getLocalName8+
+## bluetooth.getLocalName8+(deprecated)
getLocalName(): string
Obtains the name of the local Bluetooth device.
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.getLocalName](js-apis-bluetoothManager.md#bluetoothmanagergetlocalname).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -84,12 +94,15 @@ let localName = bluetooth.getLocalName();
```
-## bluetooth.getState
+## bluetooth.getState(deprecated)
getState(): BluetoothState
Obtains the Bluetooth state.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.getState](js-apis-bluetoothManager.md#bluetoothmanagergetstate).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -107,11 +120,14 @@ let state = bluetooth.getState();
```
-## bluetooth.getBtConnectionState
+## bluetooth.getBtConnectionState(deprecated)
getBtConnectionState(): ProfileConnectionState
-Obtains the profile connection state of this Bluetooth device.
+Obtains the local profile connection state.
+
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.getBtConnectionState](js-apis-bluetoothManager.md#bluetoothmanagergetbtconnectionstate).
**Required permissions**: ohos.permission.USE_BLUETOOTH
@@ -130,12 +146,15 @@ let connectionState = bluetooth.getBtConnectionState();
```
-## bluetooth.setLocalName8+
+## bluetooth.setLocalName8+(deprecated)
setLocalName(name: string): boolean
Sets the name of the local Bluetooth device.
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.setLocalName](js-apis-bluetoothManager.md#bluetoothmanagersetlocalname).
+
**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -159,12 +178,15 @@ let ret = bluetooth.setLocalName('device_name');
```
-## bluetooth.pairDevice
+## bluetooth.pairDevice(deprecated)
pairDevice(deviceId: string): boolean
Initiates Bluetooth pairing.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.pairDevice](js-apis-bluetoothManager.md#bluetoothmanagerpairdevice).
+
**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -189,11 +211,14 @@ let result = bluetooth.pairDevice("XX:XX:XX:XX:XX:XX");
```
-## bluetooth.getProfileConnState8+
+## bluetooth.getProfileConnState8+(deprecated)
getProfileConnState(profileId: ProfileId): ProfileConnectionState
-Obtains the connection state of a profile.
+Obtains the connection status of a specified profile.
+
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.getProfileConnectionState](js-apis-bluetoothManager.md#bluetoothmanagergetprofileconnectionstate).
**Required permissions**: ohos.permission.USE_BLUETOOTH
@@ -218,12 +243,15 @@ let result = bluetooth.getProfileConnState(bluetooth.ProfileId.PROFILE_A2DP_SOUR
```
-## bluetooth.cancelPairedDevice8+
+## bluetooth.cancelPairedDevice8+(deprecated)
cancelPairedDevice(deviceId: string): boolean
Cancels a paired remote device.
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.cancelPairedDevice](js-apis-bluetoothManager.md#bluetoothmanagercancelpaireddevice).
+
**System API**: This is a system API.
**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
@@ -249,12 +277,15 @@ let result = bluetooth.cancelPairedDevice("XX:XX:XX:XX:XX:XX");
```
-## bluetooth.getRemoteDeviceName8+
+## bluetooth.getRemoteDeviceName8+(deprecated)
getRemoteDeviceName(deviceId: string): string
Obtains the name of the remote Bluetooth device.
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.getRemoteDeviceName](js-apis-bluetoothManager.md#bluetoothmanagergetremotedevicename).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -278,12 +309,15 @@ let remoteDeviceName = bluetooth.getRemoteDeviceName("XX:XX:XX:XX:XX:XX");
```
-## bluetooth.getRemoteDeviceClass8+
+## bluetooth.getRemoteDeviceClass8+(deprecated)
getRemoteDeviceClass(deviceId: string): DeviceClass
Obtains the class of the remote Bluetooth device.
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.getRemoteDeviceClass](js-apis-bluetoothManager.md#bluetoothmanagergetremotedeviceclass).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -307,12 +341,15 @@ let remoteDeviceClass = bluetooth.getRemoteDeviceClass("XX:XX:XX:XX:XX:XX");
```
-## bluetooth.getPairedDevices8+
+## bluetooth.getPairedDevices8+(deprecated)
getPairedDevices(): Array<string>
Obtains the paired devices.
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.getPairedDevices](js-apis-bluetoothManager.md#bluetoothmanagergetpaireddevices).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -330,12 +367,15 @@ let devices = bluetooth.getPairedDevices();
```
-## bluetooth.setBluetoothScanMode8+
+## bluetooth.setBluetoothScanMode8+(deprecated)
setBluetoothScanMode(mode: ScanMode, duration: number): boolean
Sets the Bluetooth scan mode so that the device can be discovered by a remote device.
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.setBluetoothScanMode](js-apis-bluetoothManager.md#bluetoothmanagersetbluetoothscanmode).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -361,12 +401,15 @@ let result = bluetooth.setBluetoothScanMode(bluetooth.ScanMode.SCAN_MODE_CONNECT
```
-## bluetooth.getBluetoothScanMode8+
+## bluetooth.getBluetoothScanMode8+(deprecated)
getBluetoothScanMode(): ScanMode
Obtains the Bluetooth scan mode.
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.getBluetoothScanMode](js-apis-bluetoothManager.md#bluetoothmanagergetbluetoothscanmode).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -384,12 +427,15 @@ let scanMode = bluetooth.getBluetoothScanMode();
```
-## bluetooth.startBluetoothDiscovery8+
+## bluetooth.startBluetoothDiscovery8+(deprecated)
startBluetoothDiscovery(): boolean
Starts Bluetooth scan to discover remote devices.
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.startBluetoothDiscovery](js-apis-bluetoothManager.md#bluetoothmanagerstartbluetoothdiscovery).
+
**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH and ohos.permission.LOCATION
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -412,12 +458,15 @@ let result = bluetooth.startBluetoothDiscovery();
```
-## bluetooth.stopBluetoothDiscovery8+
+## bluetooth.stopBluetoothDiscovery8+(deprecated)
stopBluetoothDiscovery(): boolean
Stops Bluetooth scan.
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.stopBluetoothDiscovery](js-apis-bluetoothManager.md#bluetoothmanagerstopbluetoothdiscovery).
+
**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -435,12 +484,15 @@ let result = bluetooth.stopBluetoothDiscovery();
```
-## bluetooth.setDevicePairingConfirmation8+
+## bluetooth.setDevicePairingConfirmation8+(deprecated)
setDevicePairingConfirmation(device: string, accept: boolean): boolean
Sets the device pairing confirmation.
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.setDevicePairingConfirmation](js-apis-bluetoothManager.md#bluetoothmanagersetdevicepairingconfirmation).
+
**Required permissions**: ohos.permission.MANAGE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -470,12 +522,15 @@ bluetooth.on("pinRequired", onReceivePinRequiredEvent);
```
-## bluetooth.on('bluetoothDeviceFind')8+
+## bluetooth.on('bluetoothDeviceFind')8+(deprecated)
on(type: "bluetoothDeviceFind", callback: Callback<Array<string>>): void
Subscribes to the Bluetooth device discovery events.
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.on('bluetoothDeviceFind')](js-apis-bluetoothManager.md#bluetoothmanageronbluetoothdevicefind).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -501,12 +556,15 @@ bluetooth.on('bluetoothDeviceFind', onReceiveEvent);
```
-## bluetooth.off('bluetoothDeviceFind')8+
+## bluetooth.off('bluetoothDeviceFind')8+(deprecated)
off(type: "bluetoothDeviceFind", callback?: Callback<Array<string>>): void
Unsubscribes from the Bluetooth device discovery events.
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.off('bluetoothDeviceFind')](js-apis-bluetoothManager.md#bluetoothmanageroffbluetoothdevicefind).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -533,12 +591,15 @@ bluetooth.off('bluetoothDeviceFind', onReceiveEvent);
```
-## bluetooth.on('pinRequired')8+
+## bluetooth.on('pinRequired')8+(deprecated)
on(type: "pinRequired", callback: Callback<PinRequiredParam>): void
Subscribes to the pairing request events of the remote Bluetooth device.
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.on('pinRequired')](js-apis-bluetoothManager.md#bluetoothmanageronpinrequired).
+
**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -564,12 +625,15 @@ bluetooth.on('pinRequired', onReceiveEvent);
```
-## bluetooth.off('pinRequired')8+
+## bluetooth.off('pinRequired')8+(deprecated)
off(type: "pinRequired", callback?: Callback<PinRequiredParam>): void
Unsubscribes from the pairing request events of the remote Bluetooth device.
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.off('pinRequired')](js-apis-bluetoothManager.md#bluetoothmanageroffpinrequired).
+
**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -596,12 +660,15 @@ bluetooth.off('pinRequired', onReceiveEvent);
```
-## bluetooth.on('bondStateChange')8+
+## bluetooth.on('bondStateChange')8+(deprecated)
on(type: "bondStateChange", callback: Callback<BondStateParam>): void
Subscribes to the Bluetooth pairing state change events.
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.on('bondStateChange')](js-apis-bluetoothManager.md#bluetoothmanageronbondstatechange).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -627,12 +694,15 @@ bluetooth.on('bondStateChange', onReceiveEvent);
```
-## bluetooth.off('bondStateChange')8+
+## bluetooth.off('bondStateChange')8+(deprecated)
off(type: "bondStateChange", callback?: Callback<BondStateParam>): void
Unsubscribes from the Bluetooth pairing state change events.
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.off('bondStateChange')](js-apis-bluetoothManager.md#bluetoothmanageroffbondstatechange).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -659,12 +729,15 @@ bluetooth.off('bondStateChange', onReceiveEvent);
```
-## bluetooth.on('stateChange')8+
+## bluetooth.on('stateChange')8+(deprecated)
on(type: "stateChange", callback: Callback<BluetoothState>): void
Subscribes to the Bluetooth connection state change events.
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.on('stateChange')](js-apis-bluetoothManager.md#bluetoothmanageronstatechange).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -690,12 +763,15 @@ bluetooth.on('stateChange', onReceiveEvent);
```
-## bluetooth.off('stateChange')8+
+## bluetooth.off('stateChange')8+(deprecated)
off(type: "stateChange", callback?: Callback<BluetoothState>): void
Unsubscribes from the Bluetooth connection state change events.
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.off('stateChange')](js-apis-bluetoothManager.md#bluetoothmanageroffstatechange).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -722,12 +798,15 @@ bluetooth.off('stateChange', onReceiveEvent);
```
-## bluetooth.sppListen8+
+## bluetooth.sppListen8+(deprecated)
sppListen(name: string, option: SppOption, callback: AsyncCallback<number>): void
Creates a server listening socket.
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.sppListen](js-apis-bluetoothManager.md#bluetoothmanagerspplisten).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -757,12 +836,15 @@ bluetooth.sppListen('server1', sppOption, serverSocket);
```
-## bluetooth.sppAccept8+
+## bluetooth.sppAccept8+(deprecated)
sppAccept(serverSocket: number, callback: AsyncCallback<number>): void
Listens for a connection to be made to this socket from the client and accepts it.
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.sppAccept](js-apis-bluetoothManager.md#bluetoothmanagersppaccept).
+
**System capability**: SystemCapability.Communication.Bluetooth.Core
**Parameters**
@@ -796,12 +878,15 @@ bluetooth.sppAccept(serverNumber, acceptClientSocket);
```
-## bluetooth.sppConnect8+
+## bluetooth.sppConnect8+(deprecated)
sppConnect(device: string, option: SppOption, callback: AsyncCallback<number>): void
Initiates an SPP connection to a remote device from the client.
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.sppConnect](js-apis-bluetoothManager.md#bluetoothmanagersppconnect).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -832,12 +917,15 @@ bluetooth.sppConnect('XX:XX:XX:XX:XX:XX', sppOption, clientSocket);
```
-## bluetooth.sppCloseServerSocket8+
+## bluetooth.sppCloseServerSocket8+(deprecated)
sppCloseServerSocket(socket: number): void
Closes the listening socket of the server.
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.sppCloseServerSocket](js-apis-bluetoothManager.md#bluetoothmanagersppcloseserversocket).
+
**System capability**: SystemCapability.Communication.Bluetooth.Core
**Parameters**
@@ -861,12 +949,15 @@ bluetooth.sppCloseServerSocket(serverNumber);
```
-## bluetooth.sppCloseClientSocket8+
+## bluetooth.sppCloseClientSocket8+(deprecated)
sppCloseClientSocket(socket: number): void
Closes the client socket.
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.sppCloseClientSocket](js-apis-bluetoothManager.md#bluetoothmanagersppcloseclientsocket).
+
**System capability**: SystemCapability.Communication.Bluetooth.Core
**Parameters**
@@ -892,12 +983,15 @@ bluetooth.sppCloseClientSocket(clientNumber);
```
-## bluetooth.sppWrite8+
+## bluetooth.sppWrite8+(deprecated)
sppWrite(clientSocket: number, data: ArrayBuffer): boolean
Writes data to the remote device through the socket.
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.sppWrite](js-apis-bluetoothManager.md#bluetoothmanagersppwrite).
+
**System capability**: SystemCapability.Communication.Bluetooth.Core
**Parameters**
@@ -937,10 +1031,13 @@ if (ret) {
```
-## bluetooth.on('sppRead')8+
+## bluetooth.on('sppRead')8+(deprecated)
on(type: "sppRead", clientSocket: number, callback: Callback<ArrayBuffer>): void
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.on('sppRead')](js-apis-bluetoothManager.md#bluetoothmanageronsppread).
+
Subscribes to the SPP read request events.
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -977,12 +1074,15 @@ bluetooth.on('sppRead', clientNumber, dataRead);
```
-## bluetooth.off('sppRead')8+
+## bluetooth.off('sppRead')8+(deprecated)
off(type: "sppRead", clientSocket: number, callback?: Callback<ArrayBuffer>): void
Unsubscribes from the SPP read request events.
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.off('sppRead')](js-apis-bluetoothManager.md#bluetoothmanageroffsppread).
+
**System capability**: SystemCapability.Communication.Bluetooth.Core
**Parameters**
@@ -1013,12 +1113,15 @@ bluetooth.off('sppRead', clientNumber);
```
-## bluetooth.getProfile8+
+## bluetooth.getProfile8+(deprecated)
getProfile(profileId: ProfileId): A2dpSourceProfile | HandsFreeAudioGatewayProfile
Obtains a profile object.
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.getProfileInstance](js-apis-bluetoothManager.md#bluetoothmanagergetprofileinstance).
+
**System capability**: SystemCapability.Communication.Bluetooth.Core
**Parameters**
@@ -1039,41 +1142,18 @@ Obtains a profile object.
let a2dpSrc = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE);
```
-## bluetooth.getProfileInst9+
-
-getProfileInst(profileId: ProfileId): A2dpSourceProfile | HandsFreeAudioGatewayProfile | HidHostProfile | PanProfile
-
-Obtains a profile instance. API version 9 is added with **HidHostProfile** and **PanProfile**.
-
-**System capability**: SystemCapability.Communication.Bluetooth.Core
-
-**Parameters**
-
-| Name | Type | Mandatory | Description |
-| --------- | --------- | ---- | ------------------------------------- |
-| profileId | [ProfileId](#ProfileId) | Yes | ID of the profile to obtain, for example, **PROFILE_A2DP_SOURCE**.|
-
-**Return value**
-
-| Type | Description |
-| ------------------------------------------------------------ | ------------------------------------------------------------ |
-| [A2dpSourceProfile](#a2dpsourceprofile), [HandsFreeAudioGatewayProfile](#handsfreeaudiogatewayprofile), [HidHostProfile](#hidhostprofile), or [PanProfile](#panprofile)| Profile instance obtained, which can be **A2dpSourceProfile**, **HandsFreeAudioGatewayProfile**, **HidHostProfile**, or **PanProfile**.|
-
-**Example**
-
-```js
-let hidHost = bluetooth.getProfileInst(bluetooth.ProfileId.PROFILE_HID_HOST);
-```
-
## bluetooth.BLE
-### bluetooth.BLE.createGattServer
+### bluetooth.BLE.createGattServer(deprecated)
createGattServer(): GattServer
Creates a **GattServer** instance.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.BLE.createGattServer](js-apis-bluetoothManager.md#bluetoothmanagerblecreategattserver).
+
**System capability**: SystemCapability.Communication.Bluetooth.Core
**Return value**
@@ -1089,12 +1169,15 @@ let gattServer = bluetooth.BLE.createGattServer();
```
-### bluetooth.BLE.createGattClientDevice
+### bluetooth.BLE.createGattClientDevice(deprecated)
createGattClientDevice(deviceId: string): GattClientDevice
Creates a **GattClientDevice** instance.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.BLE.createGattClientDevice](js-apis-bluetoothManager.md#bluetoothmanagerblecreategattclientdevice).
+
**System capability**: SystemCapability.Communication.Bluetooth.Core
**Parameters**
@@ -1116,12 +1199,15 @@ let device = bluetooth.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
```
-### bluetooth.BLE.getConnectedBLEDevices
+### bluetooth.BLE.getConnectedBLEDevices(deprecated)
getConnectedBLEDevices(): Array<string>
Obtains the BLE devices connected to this device.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.BLE.getConnectedBLEDevices](js-apis-bluetoothManager.md#bluetoothmanagerblegetconnectedbledevices).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -1139,12 +1225,15 @@ let result = bluetooth.BLE.getConnectedBLEDevices();
```
-### bluetooth.BLE.startBLEScan
+### bluetooth.BLE.startBLEScan(deprecated)
startBLEScan(filters: Array<ScanFilter>, options?: ScanOptions): void
Starts a BLE scan.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.BLE.startBLEScan](js-apis-bluetoothManager.md#bluetoothmanagerblestartblescan).
+
**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH, ohos.permission.MANAGE_BLUETOOTH, and ohos.permission.LOCATION
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -1182,12 +1271,15 @@ bluetooth.BLE.startBLEScan(
```
-### bluetooth.BLE.stopBLEScan
+### bluetooth.BLE.stopBLEScan(deprecated)
stopBLEScan(): void
Stops the BLE scan.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.BLE.stopBLEScan](js-apis-bluetoothManager.md#bluetoothmanagerblestopblescan).
+
**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -1203,12 +1295,15 @@ bluetooth.BLE.stopBLEScan();
```
-### bluetooth.BLE.on('BLEDeviceFind')
+### bluetooth.BLE.on('BLEDeviceFind')(deprecated)
on(type: "BLEDeviceFind", callback: Callback<Array<ScanResult>>): void
Subscribe to the BLE device discovery events.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.BLE.on('BLEDeviceFind')](js-apis-bluetoothManager.md#bluetoothmanagerbleonbledevicefind).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -1234,12 +1329,15 @@ bluetooth.BLE.on('BLEDeviceFind', onReceiveEvent);
```
-### bluetooth.BLE.off('BLEDeviceFind')
+### bluetooth.BLE.off('BLEDeviceFind')(deprecated)
off(type: "BLEDeviceFind", callback?: Callback<Array<ScanResult>>): void
Unsubscribes from the BLE device discovery events.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.BLE.off('BLEDeviceFind')](js-apis-bluetoothManager.md#bluetoothmanagerbleoffbledevicefind).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -1271,12 +1369,15 @@ bluetooth.BLE.off('BLEDeviceFind', onReceiveEvent);
Provides the profile base class.
-### getConnectionDevices8+
+### getConnectionDevices8+(deprecated)
getConnectionDevices(): Array<string>
Obtains the connected devices.
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.BaseProfile.getConnectionDevices](js-apis-bluetoothManager.md#getconnectiondevices).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -1294,12 +1395,15 @@ let a2dpSrc = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE) as b
let retArray = a2dpSrc.getConnectionDevices();
```
-### getDeviceState8+
+### getDeviceState8+(deprecated)
getDeviceState(device: string): ProfileConnectionState
Obtains the connection state of the profile.
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.BaseProfile.getDeviceState](js-apis-bluetoothManager.md#getdevicestate).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -1328,12 +1432,15 @@ let ret = a2dpSrc.getDeviceState('XX:XX:XX:XX:XX:XX');
Before using a method of **A2dpSourceProfile**, you need to create an instance of this class by using the **getProfile()** method.
-### connect8+
+### connect8+(deprecated)
connect(device: string): boolean
Sets up an Advanced Audio Distribution Profile (A2DP) connection.
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.A2dpSourceProfile.connect](js-apis-bluetoothManager.md#connect).
+
**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -1358,12 +1465,15 @@ let ret = a2dpSrc.connect('XX:XX:XX:XX:XX:XX');
```
-### disconnect8+
+### disconnect8+(deprecated)
disconnect(device: string): boolean
Disconnects an A2DP connection.
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.A2dpSourceProfile.disconnect](js-apis-bluetoothManager.md#disconnect).
+
**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -1388,12 +1498,15 @@ let ret = a2dpSrc.disconnect('XX:XX:XX:XX:XX:XX');
```
-### on('connectionStateChange')8+
+### on('connectionStateChange')8+(deprecated)
on(type: "connectionStateChange", callback: Callback<[StateChangeParam](#StateChangeParam)>): void
Subscribes to the A2DP connection state change events.
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.A2dpSourceProfile.on('connectionStateChange')](js-apis-bluetoothManager.md#onconnectionstatechange).
+
**System capability**: SystemCapability.Communication.Bluetooth.Core
**Parameters**
@@ -1418,12 +1531,15 @@ a2dpSrc.on('connectionStateChange', onReceiveEvent);
```
-### off('connectionStateChange')8+
+### off('connectionStateChange')8+(deprecated)
off(type: "connectionStateChange", callback?: Callback<[StateChangeParam](#StateChangeParam)>): void
Unsubscribes from the A2DP connection state change events.
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.A2dpSourceProfile.off('connectionStateChange')](js-apis-bluetoothManager.md#offconnectionstatechange).
+
**System capability**: SystemCapability.Communication.Bluetooth.Core
**Parameters**
@@ -1431,7 +1547,7 @@ Unsubscribes from the A2DP connection state change events.
| Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type | string | Yes | Event type. The value **connectionStateChange** indicates an A2DP connection state change event.|
-| callback | Callback<[StateChangeParam](#StateChangeParam)> | No | Callback used to return the A2DP connection state change event. |
+| callback | Callback<[StateChangeParam](#StateChangeParam)> | No | Callback for the A2DP connection state change event. |
**Return value**
@@ -1449,12 +1565,15 @@ a2dpSrc.off('connectionStateChange', onReceiveEvent);
```
-### getPlayingState8+
+### getPlayingState8+(deprecated)
getPlayingState(device: string): PlayingState
Obtains the playing state of a device.
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.A2dpSourceProfile.getPlayingState](js-apis-bluetoothManager.md#getplayingstate).
+
**System capability**: SystemCapability.Communication.Bluetooth.Core
**Parameters**
@@ -1482,12 +1601,15 @@ let state = a2dpSrc.getPlayingState('XX:XX:XX:XX:XX:XX');
Before using a method of **HandsFreeAudioGatewayProfile**, you need to create an instance of this class by using the **getProfile()** method.
-### connect8+
+### connect8+(deprecated)
connect(device: string): boolean
Sets up a Hands-free Profile (HFP) connection of a device.
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.HandsFreeAudioGatewayProfile.connect](js-apis-bluetoothManager.md#connect-1).
+
**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -1513,12 +1635,15 @@ let ret = hfpAg.connect('XX:XX:XX:XX:XX:XX');
```
-### disconnect8+
+### disconnect8+(deprecated)
disconnect(device: string): boolean
Disconnects the HFP connection of a device.
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.HandsFreeAudioGatewayProfile.disconnect](js-apis-bluetoothManager.md#disconnect-1).
+
**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -1544,12 +1669,15 @@ let ret = hfpAg.disconnect('XX:XX:XX:XX:XX:XX');
```
-### on('connectionStateChange')8+
+### on('connectionStateChange')8+(deprecated)
on(type: "connectionStateChange", callback: Callback<[StateChangeParam](#StateChangeParam)>): void
Subscribes to the HFP connection state change events.
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.HandsFreeAudioGatewayProfile.on('connectionStateChange')](js-apis-bluetoothManager.md#onconnectionstatechange-1).
+
**System capability**: SystemCapability.Communication.Bluetooth.Core
**Parameters**
@@ -1575,12 +1703,15 @@ hfpAg.on('connectionStateChange', onReceiveEvent);
```
-### off('connectionStateChange')8+
+### off('connectionStateChange')8+(deprecated)
off(type: "connectionStateChange", callback?: Callback<[StateChangeParam](#StateChangeParam)>): void
Unsubscribes from the HFP connection state change events.
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.HandsFreeAudioGatewayProfile.off('connectionStateChange')](js-apis-bluetoothManager.md#offconnectionstatechange-1).
+
**System capability**: SystemCapability.Communication.Bluetooth.Core
**Parameters**
@@ -1607,301 +1738,20 @@ hfpAg.off('connectionStateChange', onReceiveEvent);
```
-## HidHostProfile
-
-Before using a method of **HidHostProfile**, you need to create an instance of this class by using the **getProfile()** method.
-
-
-### connect9+
-
-connect(device: string): boolean
-
-Connects to the HidHost service of a device.
-
-**System API**: This is a system API.
-
-**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
-
-**System capability**: SystemCapability.Communication.Bluetooth.Core
-
-**Parameters**
-
-| Name | Type | Mandatory | Description |
-| ------ | ------ | ---- | ------- |
-| device | string | Yes | Address of the target device.|
-
-**Return value**
-
-| Type | Description |
-| --------------------- | --------------------------------- |
-| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
-
-**Example**
-
-```js
-let hidHostProfile = bluetooth.getProfileInst(bluetooth.ProfileId.PROFILE_HID_HOST) as bluetooth.HidHostProfile;
-let ret = hidHostProfile.connect('XX:XX:XX:XX:XX:XX');
-```
-
-
-### disconnect9+
-
-disconnect(device: string): boolean
-
-Disconnects from the HidHost service of a device.
-
-**System API**: This is a system API.
-
-**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
-
-**System capability**: SystemCapability.Communication.Bluetooth.Core
-
-**Parameters**
-
-| Name | Type | Mandatory | Description |
-| ------ | ------ | ---- | ------- |
-| device | string | Yes | Address of the target device.|
-
-**Return value**
-
-| Type | Description |
-| --------------------- | --------------------------------- |
-| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
-
-**Example**
-
-```js
-let hidHostProfile = bluetooth.getProfileInst(bluetooth.ProfileId.PROFILE_HID_HOST) as bluetooth.HidHostProfile;
-let ret = hidHostProfile.disconnect('XX:XX:XX:XX:XX:XX');
-```
-
-
-### on('connectionStateChange')9+
-
-on(type: "connectionStateChange", callback: Callback<[StateChangeParam](#StateChangeParam)>): void
-
-Subscribes to the HidHost connection state change events.
-
-**System capability**: SystemCapability.Communication.Bluetooth.Core
-
-**Parameters**
-
-| Name | Type | Mandatory | Description |
-| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
-| type | string | Yes | Event type. The value **connectionStateChange** indicates a HidHost connection state change event.|
-| callback | Callback<[StateChangeParam](#StateChangeParam)> | Yes | Callback invoked to return the HidHost connection state change event. |
-
-**Return value**
-
-No value is returned.
-
-**Example**
-
-```js
-function onReceiveEvent(data) {
- console.info('hidHost state = '+ JSON.stringify(data));
-}
-let hidHost = bluetooth.getProfileInst(bluetooth.ProfileId.PROFILE_HID_HOST) as bluetooth.HidHostProfile;
-hidHost.on('connectionStateChange', onReceiveEvent);
-```
-
-
-### off('connectionStateChange')9+
-
-off(type: "connectionStateChange", callback?: Callback<[StateChangeParam](#StateChangeParam)>): void
-
-Unsubscribes from the HidHost connection state change events.
-
-**System capability**: SystemCapability.Communication.Bluetooth.Core
-
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| -------- | ----------------------------------------------------- | ---- | --------------------------------------------------------- |
-| type | string | Yes | Event type. The value **connectionStateChange** indicates a HidHost connection state change event.|
-| callback | Callback<[StateChangeParam](#StateChangeParam)> | No | Callback for the HidHost connection state change event. |
-
-**Return value**
-
-No value is returned.
-
-**Example**
-
-```js
-function onReceiveEvent(data) {
- console.info('hidHost state = '+ JSON.stringify(data));
-}
-let hidHost = bluetooth.getProfileInst(bluetooth.ProfileId.PROFILE_HID_HOST) as bluetooth.HidHostProfile;
-hidHost.on('connectionStateChange', onReceiveEvent);
-hidHost.off('connectionStateChange', onReceiveEvent);
-```
-
-
-## PanProfile
-
-Before using a method of **PanProfile**, you need to create an instance of this class by using the **getProfile()** method.
-
-
-### disconnect9+
-
-disconnect(device: string): boolean
-
-Disconnects from the Personal Area Network (PAN) service of a device.
-
-**System API**: This is a system API.
-
-**Required permissions**: ohos.permission.USE_BLUETOOTH
-
-**System capability**: SystemCapability.Communication.Bluetooth.Core
-
-**Parameters**
-
-| Name | Type | Mandatory | Description |
-| ------ | ------ | ---- | ------- |
-| device | string | Yes | Address of the target device.|
-
-**Return value**
-
-| Type | Description |
-| --------------------- | --------------------------------- |
-| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
-
-**Example**
-
-```js
-let panProfile = bluetooth.getProfileInst(bluetooth.ProfileId.PROFILE_PAN_NETWORK) as bluetooth.PanProfile;
-let ret = panProfile.disconnect('XX:XX:XX:XX:XX:XX');
-```
-
-
-### on('connectionStateChange')9+
-
-on(type: "connectionStateChange", callback: Callback<[StateChangeParam](#StateChangeParam)>): void
-
-Subscribes to the PAN connection state change events.
-
-**System capability**: SystemCapability.Communication.Bluetooth.Core
-
-**Parameters**
-
-| Name | Type | Mandatory | Description |
-| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
-| type | string | Yes | Event type. The value **connectionStateChange** indicates a PAN connection state change event.|
-| callback | Callback<[StateChangeParam](#StateChangeParam)> | Yes | Callback invoked to return the PAN connection state change event. |
-
-**Return value**
-
-No value is returned.
-
-**Example**
-
-```js
-function onReceiveEvent(data) {
- console.info('pan state = '+ JSON.stringify(data));
-}
-let panProfile = bluetooth.getProfileInst(bluetooth.ProfileId.PROFILE_PAN_NETWORK) as bluetooth.PanProfile;
-panProfile.on('connectionStateChange', onReceiveEvent);
-```
-
-
-### off('connectionStateChange')9+
-
-off(type: "connectionStateChange", callback?: Callback<[StateChangeParam](#StateChangeParam)>): void
-
-Unsubscribes from the PAN connection state change events.
-
-**System capability**: SystemCapability.Communication.Bluetooth.Core
-
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| -------- | ----------------------------------------------------- | ---- | --------------------------------------------------------- |
-| type | string | Yes | Event type. The value **connectionStateChange** indicates a PAN connection state change event.|
-| callback | Callback<[StateChangeParam](#StateChangeParam)> | No | Callback for the PAN connection state change event. |
-
-**Return value**
-
-No value is returned.
-
-**Example**
-
-```js
-function onReceiveEvent(data) {
- console.info('pan state = '+ JSON.stringify(data));
-}
-let panProfile = bluetooth.getProfileInst(bluetooth.ProfileId.PROFILE_PAN_NETWORK) as bluetooth.PanProfile;
-panProfile.on('connectionStateChange', onReceiveEvent);
-panProfile.off('connectionStateChange', onReceiveEvent);
-```
-
-
-### setTethering9+
-
-setTethering(enable: boolean): void
-
-Sets tethering.
-
-**System API**: This is a system API.
-
-**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
-
-**System capability**: SystemCapability.Communication.Bluetooth.Core
-
-**Parameters**
-
-| Name | Type | Mandatory | Description |
-| ------ | ------ | ---- | ------- |
-| value | boolean | Yes | Whether to set tethering over a Bluetooth PAN.|
-
-**Return value**
-
-| Type | Description |
-| --------------------- | --------------------------------- |
-| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
-
-**Example**
-
-```js
-let panProfile = bluetooth.getProfileInst(bluetooth.ProfileId.PROFILE_PAN_NETWORK) as bluetooth.PanProfile;
-let ret = panProfile.setTethering(true);
-```
-
-
-### isTetheringOn9+
-
-isTetheringOn(): boolean
-
-Obtains the tethering state.
-
-**System API**: This is a system API.
-
-**System capability**: SystemCapability.Communication.Bluetooth.Core
-
-**Return value**
-
-| Type | Description |
-| --------------------- | --------------------------------- |
-| boolean | Returns **true** if tethering is available over a Bluetooth PAN; return **false** otherwise.|
-
-**Example**
-
-```js
-let panProfile = bluetooth.getProfileInst(bluetooth.ProfileId.PROFILE_PAN_NETWORK) as bluetooth.PanProfile;
-let ret = panProfile.isTetheringOn();
-```
-
-
## GattServer
Implements the Generic Attribute Profile (GATT) server. Before using a method of this class, you need to create a **GattServer** instance using the **createGattServer()** method.
-### startAdvertising
+### startAdvertising(deprecated)
startAdvertising(setting: AdvertiseSetting, advData: AdvertiseData, advResponse?: AdvertiseData): void
Starts BLE advertising.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.GattServer.startAdvertising](js-apis-bluetoothManager.md#startadvertising).
+
**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -1963,12 +1813,15 @@ gattServer.startAdvertising({
```
-### stopAdvertising
+### stopAdvertising(deprecated)
stopAdvertising(): void
Stops BLE advertising.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.GattServer.stopAdvertising](js-apis-bluetoothManager.md#stopadvertising).
+
**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -1985,12 +1838,15 @@ server.stopAdvertising();
```
-### addService
+### addService(deprecated)
addService(service: GattService): boolean
Adds a service to this GATT server.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.GattServer.addService](js-apis-bluetoothManager.md#addservice).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -2044,12 +1900,15 @@ if (ret) {
```
-### removeService
+### removeService(deprecated)
removeService(serviceUuid: string): boolean
Removes a service from this GATT server.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.GattServer.removeService](js-apis-bluetoothManager.md#removeservice).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -2074,12 +1933,15 @@ server.removeService('00001810-0000-1000-8000-00805F9B34FB');
```
-### close
+### close(deprecated)
close(): void
Closes this GATT server to unregister it from the protocol stack. After this method is called, this [GattServer](#gattserver) cannot be used.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.GattServer.close](js-apis-bluetoothManager.md#close).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -2092,12 +1954,15 @@ server.close();
```
-### notifyCharacteristicChanged
+### notifyCharacteristicChanged(deprecated)
notifyCharacteristicChanged(deviceId: string, notifyCharacteristic: NotifyCharacteristic): boolean
Notifies the connected client device when a characteristic value changes.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.GattServer.notifyCharacteristicChanged](js-apis-bluetoothManager.md#notifycharacteristicchanged).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -2137,12 +2002,15 @@ server.notifyCharacteristicChanged('XX:XX:XX:XX:XX:XX', notifyCharacteristic);
```
-### sendResponse
+### sendResponse(deprecated)
sendResponse(serverResponse: ServerResponse): boolean
Sends a response to a read or write request from the GATT client.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.GattServer.sendResponse](js-apis-bluetoothManager.md#sendresponse).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -2184,12 +2052,15 @@ if (ret) {
```
-### on('characteristicRead')
+### on('characteristicRead')(deprecated)
on(type: "characteristicRead", callback: Callback<CharacteristicReadReq>): void
Subscribes to the characteristic read request events.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.GattServer.on('characteristicRead')](js-apis-bluetoothManager.md#oncharacteristicread).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -2232,12 +2103,15 @@ gattServer.on("characteristicRead", ReadCharacteristicReq);
```
-### off('characteristicRead')
+### off('characteristicRead')(deprecated)
off(type: "characteristicRead", callback?: Callback<CharacteristicReadReq>): void
Unsubscribes from the characteristic read request events.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.GattServer.off('characteristicRead')](js-apis-bluetoothManager.md#offcharacteristicread).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -2261,12 +2135,15 @@ gattServer.off("characteristicRead");
```
-### on('characteristicWrite')
+### on('characteristicWrite')(deprecated)
on(type: "characteristicWrite", callback: Callback<CharacteristicWriteReq>): void
Subscribes to the characteristic write request events.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.GattServer.on('characteristicWrite')](js-apis-bluetoothManager.md#oncharacteristicwrite).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -2312,12 +2189,15 @@ gattServer.on("characteristicWrite", WriteCharacteristicReq);
```
-### off('characteristicWrite')
+### off('characteristicWrite')(deprecated)
off(type: "characteristicWrite", callback?: Callback<CharacteristicWriteReq>): void
Unsubscribes from the characteristic write request events.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.GattServer.off('characteristicWrite')](js-apis-bluetoothManager.md#offcharacteristicwrite).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -2341,12 +2221,15 @@ gattServer.off("characteristicWrite");
```
-### on('descriptorRead')
+### on('descriptorRead')(deprecated)
on(type: "descriptorRead", callback: Callback<DescriptorReadReq>): void
Subscribes to the descriptor read request events.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.GattServer.on('descriptorRead')](js-apis-bluetoothManager.md#ondescriptorread).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -2389,12 +2272,15 @@ gattServer.on("descriptorRead", ReadDescriptorReq);
```
-### off('descriptorRead')
+### off('descriptorRead')(deprecated)
off(type: "descriptorRead", callback?: Callback<DescriptorReadReq>): void
Unsubscribes from the descriptor read request events.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.GattServer.off('descriptorRead')](js-apis-bluetoothManager.md#offdescriptorread).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -2418,12 +2304,15 @@ gattServer.off("descriptorRead");
```
-### on('descriptorWrite')
+### on('descriptorWrite')(deprecated)
on(type: "descriptorWrite", callback: Callback<DescriptorWriteReq>): void
Subscribes to the descriptor write request events.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.GattServer.on('descriptorWrite')](js-apis-bluetoothManager.md#ondescriptorwrite).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -2469,12 +2358,15 @@ gattServer.on("descriptorRead", WriteDescriptorReq);
```
-### off('descriptorWrite')
+### off('descriptorWrite')(deprecated)
off(type: "descriptorWrite", callback?: Callback<DescriptorWriteReq>): void
Unsubscribes from the descriptor write request events.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.GattServer.off('descriptorWrite')](js-apis-bluetoothManager.md#offdescriptorwrite).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -2498,12 +2390,15 @@ gattServer.off("descriptorWrite");
```
-### on('connectStateChange')
+### on('connectStateChange')(deprecated)
on(type: "connectStateChange", callback: Callback<BLEConnectChangedState>): void
Subscribes to the BLE connection state change events.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.GattServer.on('connectStateChange')](js-apis-bluetoothManager.md#onconnectstatechange).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -2532,12 +2427,15 @@ gattServer.on("connectStateChange", Connected);
```
-### off('connectStateChange')
+### off('connectStateChange')(deprecated)
off(type: "connectStateChange", callback?: Callback<BLEConnectChangedState>): void
Unsubscribes from the BLE connection state change events.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.GattServer.off('connectStateChange')](js-apis-bluetoothManager.md#offconnectstatechange).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -2566,12 +2464,15 @@ gattServer.off("connectStateChange");
Implements the GATT client. Before using a method of this class, you must create a **GattClientDevice** instance using the **createGattClientDevice(deviceId: string)** method.
-### connect
+### connect(deprecated)
connect(): boolean
Initiates a connection to the remote BLE device.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.GattClientDevice.connect](js-apis-bluetoothManager.md#connect-3).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -2590,12 +2491,15 @@ let ret = device.connect();
```
-### disconnect
+### disconnect(deprecated)
disconnect(): boolean
Disconnects from the remote BLE device.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.GattClientDevice.disconnect](js-apis-bluetoothManager.md#disconnect-4).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -2614,12 +2518,15 @@ let ret = device.disconnect();
```
-### close
+### close(deprecated)
close(): boolean
Closes this GATT client to unregister it from the protocol stack. After this method is called, this [GattClientDevice](#gattclientdevice) instance cannot be used.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.GattClientDevice.close](js-apis-bluetoothManager.md#close-1).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -2640,12 +2547,15 @@ let ret = device.close();
-### getServices
+### getServices(deprecated)
getServices(callback: AsyncCallback<Array<GattService>>): void
Obtains all services of the remote BLE device. This API uses an asynchronous callback to return the result.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.GattClientDevice.getServices](js-apis-bluetoothManager.md#getservices).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -2682,12 +2592,15 @@ device.getServices(getServices);
```
-### getServices
+### getServices(deprecated)
getServices(): Promise<Array<GattService>>
Obtains all services of the remote BLE device. This API uses a promise to return the result.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.GattClientDevice.getServices](js-apis-bluetoothManager.md#getservices-1).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -2710,12 +2623,15 @@ device.getServices().then(result => {
```
-### readCharacteristicValue
+### readCharacteristicValue(deprecated)
readCharacteristicValue(characteristic: BLECharacteristic, callback: AsyncCallback<BLECharacteristic>): void
Reads the characteristic value of the specific service of the remote BLE device. This API uses an asynchronous callback to return the result.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.GattClientDevice.readCharacteristicValue](js-apis-bluetoothManager.md#readcharacteristicvalue).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -2764,12 +2680,15 @@ device.readCharacteristicValue(characteristic, readCcc);
```
-### readCharacteristicValue
+### readCharacteristicValue(deprecated)
readCharacteristicValue(characteristic: BLECharacteristic): Promise<BLECharacteristic>
Reads the characteristic value of the specific service of the remote BLE device. This API uses a promise to return the result.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.GattClientDevice.readCharacteristicValue](js-apis-bluetoothManager.md#readcharacteristicvalue-1).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -2810,12 +2729,15 @@ device.readCharacteristicValue(characteristic);
```
-### readDescriptorValue
+### readDescriptorValue(deprecated)
readDescriptorValue(descriptor: BLEDescriptor, callback: AsyncCallback<BLEDescriptor>): void
Reads the descriptor contained in the specific characteristic of the remote BLE device. This API uses an asynchronous callback to return the result.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.GattClientDevice.readDescriptorValue](js-apis-bluetoothManager.md#readdescriptorvalue).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -2854,12 +2776,15 @@ device.readDescriptorValue(descriptor, readDesc);
```
-### readDescriptorValue
+### readDescriptorValue(deprecated)
readDescriptorValue(descriptor: BLEDescriptor): Promise<BLEDescriptor>
Reads the descriptor contained in the specific characteristic of the remote BLE device. This API uses a promise to return the result.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.GattClientDevice.readDescriptorValue](js-apis-bluetoothManager.md#readdescriptorvalue-1).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -2890,12 +2815,15 @@ device.readDescriptorValue(descriptor);
```
-### writeCharacteristicValue
+### writeCharacteristicValue(deprecated)
writeCharacteristicValue(characteristic: BLECharacteristic): boolean
Writes a characteristic value to the remote BLE device.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.GattClientDevice.writeCharacteristicValue](js-apis-bluetoothManager.md#writecharacteristicvalue).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -2940,12 +2868,15 @@ if (retWriteCcc) {
```
-### writeDescriptorValue
+### writeDescriptorValue(deprecated)
writeDescriptorValue(descriptor: BLEDescriptor): boolean
Writes binary data to the specific descriptor of the remote BLE device.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.GattClientDevice.writeDescriptorValue](js-apis-bluetoothManager.md#writedescriptorvalue).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -2981,12 +2912,15 @@ if (retWriteDesc) {
```
-### setBLEMtuSize
+### setBLEMtuSize(deprecated)
setBLEMtuSize(mtu: number): boolean
Sets the maximum transmission unit (MTU) that can be transmitted between the GATT client and its remote BLE device. This API can be used only after a connection is set up by calling [connect](#connect).
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.GattClientDevice.setBLEMtuSize](js-apis-bluetoothManager.md#setblemtusize).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -3011,12 +2945,15 @@ device.setBLEMtuSize(128);
```
-### setNotifyCharacteristicChanged
+### setNotifyCharacteristicChanged(deprecated)
setNotifyCharacteristicChanged(characteristic: BLECharacteristic, enable: boolean): boolean
Sets the function of notifying the GATT client when the characteristic value of the remote BLE device changes.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.GattClientDevice.setNotifyCharacteristicChanged](js-apis-bluetoothManager.md#setnotifycharacteristicchanged).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -3054,12 +2991,15 @@ device.setNotifyCharacteristicChanged(characteristic, false);
```
-### on('BLECharacteristicChange')
+### on('BLECharacteristicChange')(deprecated)
on(type: "BLECharacteristicChange", callback: Callback<BLECharacteristic>): void
Subscribes to the BLE characteristic change events. The client can receive a notification from the server only after the **setNotifyCharacteristicChanged** method is called.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.GattClientDevice.on('BLECharacteristicChange')](js-apis-bluetoothManager.md#onblecharacteristicchange).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -3088,12 +3028,15 @@ device.on('BLECharacteristicChange', CharacteristicChange);
```
-### off('BLECharacteristicChange')
+### off('BLECharacteristicChange')(deprecated)
off(type: "BLECharacteristicChange", callback?: Callback<BLECharacteristic>): void
Unsubscribes from the BLE characteristic change events.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.GattClientDevice.off('BLECharacteristicChange')](js-apis-bluetoothManager.md#offblecharacteristicchange).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -3117,12 +3060,15 @@ device.off('BLECharacteristicChange');
```
-### on('BLEConnectionStateChange')
+### on('BLEConnectionStateChange')(deprecated)
on(type: "BLEConnectionStateChange", callback: Callback<BLEConnectChangedState>): void
Subscribes to the BLE connection state change events.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.GattClientDevice.on('BLEConnectionStateChange')](js-apis-bluetoothManager.md#onbleconnectionstatechange).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -3150,12 +3096,15 @@ device.on('BLEConnectionStateChange', ConnectStateChanged);
```
-### off('BLEConnectionStateChange')
+### off('BLEConnectionStateChange')(deprecated)
off(type: "BLEConnectionStateChange", callback?: Callback<BLEConnectChangedState>): void
Unsubscribes from the BLE connection state change events.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.GattClientDevice.off('BLEConnectionStateChange')](js-apis-bluetoothManager.md#offbleconnectionstatechange).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -3179,12 +3128,15 @@ device.off('BLEConnectionStateChange');
```
-### getDeviceName
+### getDeviceName(deprecated)
getDeviceName(callback: AsyncCallback<string>): void
Obtains the name of the remote BLE device. This API uses an asynchronous callback to return the result.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.GattClientDevice.getDeviceName](js-apis-bluetoothManager.md#getdevicename).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -3211,12 +3163,15 @@ let deviceName = gattClient.getDeviceName((err, data)=> {
```
-### getDeviceName
+### getDeviceName(deprecated)
getDeviceName(): Promise<string>
Obtains the name of the remote BLE device. This API uses a promise to return the result.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.GattClientDevice.getDeviceName](js-apis-bluetoothManager.md#getdevicename-1).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -3239,12 +3194,15 @@ let deviceName = gattClient.getDeviceName().then((data) => {
```
-### getRssiValue
+### getRssiValue(deprecated)
getRssiValue(callback: AsyncCallback<number>): void
Obtains the received signal strength indication (RSSI) of the remote BLE device. This API uses an asynchronous callback to return the result. It can be used only after a connection is set up by calling [connect](#connect).
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.GattClientDevice.getRssiValue](js-apis-bluetoothManager.md#getrssivalue).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -3272,12 +3230,15 @@ let rssi = gattClient.getRssiValue((err, data)=> {
```
-### getRssiValue
+### getRssiValue(deprecated)
getRssiValue(): Promise<number>
Obtains the RSSI of the remote BLE device. This API uses a promise to return the result. It can be used only after a connection is set up by calling [connect](#connect).
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.GattClientDevice.getRssiValue](js-apis-bluetoothManager.md#getrssivalue-1).
+
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -3298,10 +3259,13 @@ let rssi = gattClient.getRssiValue().then((data) => {
})
```
-## ScanMode8+
+## ScanMode8+(deprecated)
Enumerates the scan modes.
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.ScanMode](js-apis-bluetoothManager.md#scanmode).
+
**System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Value | Description |
@@ -3313,10 +3277,13 @@ Enumerates the scan modes.
| SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE | 4 | General connectable and discoverable mode.|
| SCAN_MODE_CONNECTABLE_LIMITED_DISCOVERABLE | 5 | Limited connectable and discoverable mode.|
-## BondState8+
+## BondState8+(deprecated)
Enumerates the pairing states.
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.BondState](js-apis-bluetoothManager.md#bondstate).
+
**System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Value | Description |
@@ -3326,10 +3293,13 @@ Enumerates the pairing states.
| BOND_STATE_BONDED | 2 | Paired. |
-## SppOption8+
+## SppOption8+(deprecated)
Defines the SPP configuration parameters.
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.SppOption](js-apis-bluetoothManager.md#sppoption).
+
**System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Type | Readable | Writable | Description |
@@ -3339,10 +3309,13 @@ Defines the SPP configuration parameters.
| type | [SppType](#spptype) | Yes | Yes | Type of the SPP link. |
-## SppType8+
+## SppType8+(deprecated)
Enumerates the SPP link types.
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.SppType](js-apis-bluetoothManager.md#spptype).
+
**System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Value | Description |
@@ -3350,10 +3323,13 @@ Enumerates the SPP link types.
| SPP_RFCOMM | 0 | Radio frequency communication (RFCOMM) link type.|
-## GattService
+## GattService(deprecated)
Defines the GATT service API parameters.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.GattService](js-apis-bluetoothManager.md#gattservice).
+
**System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Type | Readable | Writable | Description |
@@ -3364,10 +3340,13 @@ Defines the GATT service API parameters.
| includeServices | Array<[GattService](#gattservice)> | Yes | Yes | Services on which the service depends. |
-## BLECharacteristic
+## BLECharacteristic(deprecated)
Defines the characteristic API parameters.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.BLECharacteristic](js-apis-bluetoothManager.md#blecharacteristic).
+
**System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Type | Readable | Writable | Description |
@@ -3378,10 +3357,13 @@ Defines the characteristic API parameters.
| descriptors | Array<[BLEDescriptor](#bledescriptor)> | Yes | Yes | List of descriptors of the characteristic. |
-## BLEDescriptor
+## BLEDescriptor(deprecated)
Defines the descriptor API parameters.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.BLEDescriptor](js-apis-bluetoothManager.md#bledescriptor).
+
**System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Type | Readable | Writable | Description |
@@ -3392,10 +3374,13 @@ Defines the descriptor API parameters.
| descriptorValue | ArrayBuffer | Yes | Yes | Binary value of the descriptor. |
-## NotifyCharacteristic
+## NotifyCharacteristic(deprecated)
Defines the parameters in the notifications sent when the server characteristic value changes.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.NotifyCharacteristic](js-apis-bluetoothManager.md#notifycharacteristic).
+
**System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Type | Readable | Writable | Description |
@@ -3406,10 +3391,13 @@ Defines the parameters in the notifications sent when the server characteristic
| confirm | boolean | Yes | Yes | Whether the notification needs to be confirmed by the remote end. For a notification, set it to **true**. In this case, the remote end must confirm the receipt of the notification. For an indication, set it to **false**. In this case, the remote end does not need to confirm the receipt of the notification.|
-## CharacteristicReadReq
+## CharacteristicReadReq(deprecated)
Defines the parameters of the **CharacteristicReadReq** event received by the server.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.CharacteristicReadRequest](js-apis-bluetoothManager.md#characteristicreadrequest).
+
**System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Type | Readable | Writable | Description |
@@ -3421,10 +3409,13 @@ Defines the parameters of the **CharacteristicReadReq** event received by the se
| serviceUuid | string | Yes | No | UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**.|
-## CharacteristicWriteReq
+## CharacteristicWriteReq(deprecated)
Defines the parameters of the **CharacteristicWriteReq** event received by the server.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.CharacteristicWriteRequest](js-apis-bluetoothManager.md#characteristicwriterequest).
+
**System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Type | Readable | Writable | Description |
@@ -3437,10 +3428,13 @@ Defines the parameters of the **CharacteristicWriteReq** event received by the s
| serviceUuid | string | Yes | No | UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**.|
-## DescriptorReadReq
+## DescriptorReadReq(deprecated)
Defines the parameters of the **DescriptorReadReq** event received by the server.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.DescriptorReadRequest](js-apis-bluetoothManager.md#descriptorreadrequest).
+
**System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Type | Readable | Writable | Description |
@@ -3453,10 +3447,13 @@ Defines the parameters of the **DescriptorReadReq** event received by the server
| serviceUuid | string | Yes | No | UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**.|
-## DescriptorWriteReq
+## DescriptorWriteReq(deprecated)
Defines the parameters of the **DescriptorWriteReq** event received by the server.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.DescriptorWriteRequest](js-apis-bluetoothManager.md#descriptorwriterequest).
+
**System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Type | Readable | Writable | Description |
@@ -3472,10 +3469,13 @@ Defines the parameters of the **DescriptorWriteReq** event received by the serve
| serviceUuid | string | Yes | No | UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**.|
-## ServerResponse
+## ServerResponse(deprecated)
Defines the parameters of the server's response to the GATT client's read/write request.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.ServerResponse](js-apis-bluetoothManager.md#serverresponse).
+
**System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Type | Readable | Writable | Description |
@@ -3487,10 +3487,13 @@ Defines the parameters of the server's response to the GATT client's read/write
| value | ArrayBuffer | Yes | No | Binary data in the response. |
-## BLEConnectChangedState
+## BLEConnectChangedState(deprecated)
Defines the parameters of **BLEConnectChangedState**.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.BLEConnectChangedState](js-apis-bluetoothManager.md#bleconnectchangedstate).
+
**System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Type | Readable| Writable| Description |
@@ -3499,10 +3502,13 @@ Defines the parameters of **BLEConnectChangedState**.
| state | [ProfileConnectionState](#profileconnectionstate) | Yes | Yes | BLE connection state. |
-## ProfileConnectionState
+## ProfileConnectionState(deprecated)
Enumerates the profile connection states.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.ProfileConnectionState](js-apis-bluetoothManager.md#profileconnectionstate).
+
**System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Value | Description |
@@ -3513,10 +3519,13 @@ Enumerates the profile connection states.
| STATE_DISCONNECTING | 3 | Disconnecting.|
-## ScanFilter
+## ScanFilter(deprecated)
Defines the scan filter parameters.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.ScanFilter](js-apis-bluetoothManager.md#scanfilter).
+
**System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Type | Readable| Writable| Description |
@@ -3524,20 +3533,15 @@ Defines the scan filter parameters.
| deviceId | string | Yes | Yes | Address of the BLE device to filter, for example, XX:XX:XX:XX:XX:XX. |
| name | string | Yes | Yes | Name of the BLE device to filter. |
| serviceUuid | string | Yes | Yes | Service UUID of the device to filter, for example, **00001888-0000-1000-8000-00805f9b34fb**.|
-| serviceUuidMask9+ | string | Yes | Yes | Service UUID mask of the device to filter, for example, **FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF**.|
-| serviceSolicitationUuid9+ | string | Yes | Yes | Service solicitation UUID of the device to filter, for example, **00001888-0000-1000-8000-00805F9B34FB**.|
-| serviceSolicitationUuidMask9+ | string | Yes | Yes | Service solicitation UUID mask of the device to filter, for example, **FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF**.|
-| serviceData9+ | ArrayBuffer | Yes | Yes | Service data of the device to filter, for example, **[0x90, 0x00, 0xF1, 0xF2]**.|
-| serviceDataMask9+ | ArrayBuffer | Yes | Yes | Service data mask of the device to filter, for example, **[0xFF,0xFF,0xFF,0xFF]**.|
-| manufactureId9+ | number | Yes | Yes | Manufacturer ID of the device to filter, for example, **0x0006**. |
-| manufactureData9+ | ArrayBuffer | Yes | Yes | Manufacturer data of the device to filter, for example, **[0x1F,0x2F,0x3F]**.|
-| manufactureDataMask9+ | ArrayBuffer | Yes | Yes | Manufacturer data mask of the device to filter, for example, **[0xFF, 0xFF, 0xFF]**.|
-## ScanOptions
+## ScanOptions(deprecated)
Defines the scan configuration parameters.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.ScanOptions](js-apis-bluetoothManager.md#scanoptions).
+
**System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Type | Readable | Writable | Description |
@@ -3547,10 +3551,13 @@ Defines the scan configuration parameters.
| matchMode | [MatchMode](#matchmode) | Yes | Yes | Hardware filtering match mode. The default value is **MATCH_MODE_AGGRESSIVE**.|
-## ScanDuty
+## ScanDuty(deprecated)
Enumerates the scan duty options.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.ScanDuty](js-apis-bluetoothManager.md#scanduty).
+
**System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Value | Description |
@@ -3560,10 +3567,13 @@ Enumerates the scan duty options.
| SCAN_MODE_LOW_LATENCY | 2 | Low-latency mode. |
-## MatchMode
+## MatchMode(deprecated)
Enumerates the hardware match modes of BLE scan filters.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.MatchMode](js-apis-bluetoothManager.md#matchmode).
+
**System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Value | Description |
@@ -3572,10 +3582,13 @@ Enumerates the hardware match modes of BLE scan filters.
| MATCH_MODE_STICKY | 2 | Hardware reports the scan result with a higher threshold of signal strength and sightings. |
-## ScanResult
+## ScanResult(deprecated)
Defines the scan result.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.ScanResult](js-apis-bluetoothManager.md#scanresult).
+
**System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Type | Readable | Writable | Description |
@@ -3585,10 +3598,13 @@ Defines the scan result.
| data | ArrayBuffer | Yes | No | Advertisement packets sent by the device. |
-## BluetoothState
+## BluetoothState(deprecated)
Enumerates the Bluetooth states.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.BluetoothState](js-apis-bluetoothManager.md#bluetoothstate).
+
**System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Value | Description |
@@ -3602,10 +3618,13 @@ Enumerates the Bluetooth states.
| STATE_BLE_TURNING_OFF | 6 | The LE-only mode is being turned off for Bluetooth.|
-## AdvertiseSetting
+## AdvertiseSetting(deprecated)
Defines the BLE advertising parameters.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.AdvertiseSetting](js-apis-bluetoothManager.md#advertisesetting).
+
**System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Type | Readable | Writable | Description |
@@ -3615,10 +3634,13 @@ Defines the BLE advertising parameters.
| connectable | boolean | Yes | Yes | Whether the advertisement is connectable. The default value is **true**. |
-## AdvertiseData
+## AdvertiseData(deprecated)
Defines the content of a BLE advertisement packet.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.AdvertiseData](js-apis-bluetoothManager.md#advertisedata).
+
**System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Type | Readable | Writable | Description |
@@ -3628,10 +3650,13 @@ Defines the content of a BLE advertisement packet.
| serviceData | Array<[ServiceData](#servicedata)> | Yes | Yes | List of service data to broadcast. |
-## ManufactureData
+## ManufactureData(deprecated)
Defines the content of a BLE advertisement packet.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.ManufactureData](js-apis-bluetoothManager.md#manufacturedata).
+
**System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Type | Readable | Writable | Description |
@@ -3640,10 +3665,13 @@ Defines the content of a BLE advertisement packet.
| manufactureValue | ArrayBuffer | Yes | Yes | Manufacturer data. |
-## ServiceData
+## ServiceData(deprecated)
Defines the service data contained in an advertisement packet.
+> **NOTE**
+> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [bluetoothManager.ServiceData](js-apis-bluetoothManager.md#servicedata).
+
**System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Type | Readable | Writable | Description |
@@ -3652,10 +3680,13 @@ Defines the service data contained in an advertisement packet.
| serviceValue | ArrayBuffer | Yes | Yes | Service data. |
-## PinRequiredParam8+
+## PinRequiredParam8+(deprecated)
Defines the pairing request parameters.
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.PinRequiredParam](js-apis-bluetoothManager.md#pinrequiredparam).
+
**System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Type | Readable | Writable | Description |
@@ -3664,10 +3695,13 @@ Defines the pairing request parameters.
| pinCode | string | Yes | No | Key for the device pairing. |
-## BondStateParam8+
+## BondStateParam8+(deprecated)
Defines the pairing state parameters.
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.BondStateParam](js-apis-bluetoothManager.md#bondstateparam).
+
**System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Type | Readable | Writable | Description |
@@ -3676,10 +3710,13 @@ Defines the pairing state parameters.
| state | BondState | Yes | No | State of the device.|
-## StateChangeParam8+
+## StateChangeParam8+(deprecated)
Defines the profile state change parameters.
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.StateChangeParam](js-apis-bluetoothManager.md#statechangeparam).
+
**System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Type | Readable| Writable| Description |
@@ -3688,10 +3725,13 @@ Defines the profile state change parameters.
| state | [ProfileConnectionState](#profileconnectionstate) | Yes | No | Profile connection state of the device.|
-## DeviceClass8+
+## DeviceClass8+(deprecated)
Defines the class of a Bluetooth device.
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.DeviceClass](js-apis-bluetoothManager.md#deviceclass).
+
**System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Type | Readable | Writable | Description |
@@ -3702,10 +3742,13 @@ Defines the class of a Bluetooth device.
-## MajorClass8+
+## MajorClass8+(deprecated)
Enumerates the major classes of Bluetooth devices.
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.MajorClass](js-apis-bluetoothManager.md#majorclass).
+
**System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Value | Description |
@@ -3723,10 +3766,13 @@ Enumerates the major classes of Bluetooth devices.
| MAJOR_UNCATEGORIZED | 0x1F00 | Unclassified device. |
-## MajorMinorClass8+
+## MajorMinorClass8+(deprecated)
Enumerates the major and minor classes of Bluetooth devices.
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.MajorMinorClass](js-apis-bluetoothManager.md#majorminorclass).
+
**System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Value | Description |
@@ -3819,10 +3865,13 @@ Enumerates the major and minor classes of Bluetooth devices.
| HEALTH_PERSONAL_MOBILITY_DEVICE | 0x093C | Personal mobility device. |
-## PlayingState8+
+## PlayingState8+(deprecated)
Enumerates the A2DP playing states.
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.PlayingState](js-apis-bluetoothManager.md#playingstate).
+
**System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Value | Description |
@@ -3831,15 +3880,16 @@ Enumerates the A2DP playing states.
| STATE_PLAYING | 0x0001 | Playing.|
-## ProfileId8+
+## ProfileId8+(deprecated)
Enumerates the Bluetooth profiles. API version 9 is added with **PROFILE_HID_HOST** and **PROFILE_PAN_NETWORK**.
+> **NOTE**
+> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [bluetoothManager.ProfileId](js-apis-bluetoothManager.md#profileid).
+
**System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Value | Description |
| -------------------------------- | ------ | --------------- |
| PROFILE_A2DP_SOURCE | 1 | A2DP profile.|
| PROFILE_HANDS_FREE_AUDIO_GATEWAY | 4 | HFP profile. |
-| PROFILE_HID_HOST9+ | 6 | Human Interface Device (HID) profile. |
-| PROFILE_PAN_NETWORK9+ | 7 | PAN profile. |
diff --git a/en/application-dev/reference/apis/js-apis-bluetoothManager.md b/en/application-dev/reference/apis/js-apis-bluetoothManager.md
new file mode 100644
index 0000000000000000000000000000000000000000..7ec3e7b70c6671ddf6b58313e1a7c86cb98e2978
--- /dev/null
+++ b/en/application-dev/reference/apis/js-apis-bluetoothManager.md
@@ -0,0 +1,4607 @@
+# @ohos.bluetoothManager (Bluetooth)
+
+The **Bluetooth** module provides classic Bluetooth capabilities and Bluetooth Low Energy (BLE) scan and advertising.
+
+> **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.
+
+
+
+## Modules to Import
+
+```js
+import bluetoothManager from '@ohos.bluetoothManager';
+```
+
+
+## bluetoothManager.enableBluetooth
+
+enableBluetooth(): void
+
+Enables Bluetooth.
+
+**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+try {
+ bluetoothManager.enableBluetooth();
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+## bluetoothManager.disableBluetooth
+
+disableBluetooth(): void
+
+Disables Bluetooth.
+
+**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+try {
+ bluetoothManager.disableBluetooth();
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+## bluetoothManager.getLocalName
+
+getLocalName(): string
+
+Obtains the name of the local Bluetooth device.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Return value**
+
+| Type | Description |
+| ------ | --------- |
+| string | Name of the local Bluetooth device obtained.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+try {
+ let localName = bluetoothManager.getLocalName();
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+## bluetoothManager.getState
+
+getState(): BluetoothState
+
+Obtains the Bluetooth state.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Return value**
+
+| Type | Description |
+| --------------------------------- | --------- |
+| [BluetoothState](#bluetoothstate) | Bluetooth state obtained.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+try {
+ let state = bluetoothManager.getState();
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+## bluetoothManager.getBtConnectionState
+
+getBtConnectionState(): ProfileConnectionState
+
+Obtains the local profile connection status.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Return value**
+
+| Type | Description |
+| ---------------------------------------- | ------------------- |
+| [ProfileConnectionState](#profileconnectionstate) | Profile connection state obtained.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900003 | Bluetooth switch is off. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+try {
+ let connectionState = bluetoothManager.getBtConnectionState();
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+## bluetoothManager.setLocalName
+
+setLocalName(name: string): void
+
+Sets the name of the local Bluetooth device.
+
+**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ---- | ------ | ---- | --------------------- |
+| name | string | Yes | Bluetooth device name to set. It cannot exceed 248 bytes.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900003 | Bluetooth switch is off. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+try {
+ bluetoothManager.setLocalName('device_name');
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+## bluetoothManager.pairDevice
+
+pairDevice(deviceId: string): void
+
+Initiates Bluetooth pairing.
+
+**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ------ | ---- | ----------------------------------- |
+| deviceId | string | Yes | Address of the remote device to pair, for example, XX:XX:XX:XX:XX:XX.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900003 | Bluetooth switch is off. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+try {
+ // The address can be scanned.
+ bluetoothManager.pairDevice("XX:XX:XX:XX:XX:XX");
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+## bluetoothManager.getProfileConnectionState
+
+getProfileConnectionState(profileId: ProfileId): ProfileConnectionState
+
+Obtains the connection status of the specified profile.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| --------- | --------- | ---- | ------------------------------------- |
+| ProfileId | profileId | Yes | ID of the profile to obtain, for example, **PROFILE_A2DP_SOURCE**.|
+
+**Return value**
+
+| Type | Description |
+| ------------------------------------------------- | ------------------- |
+| [ProfileConnectionState](#profileconnectionstate) | Profile connection state obtained.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900003 | Bluetooth switch is off. |
+|2900004 | Profile is not supported. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+try {
+ let result = bluetoothManager.getProfileConnectionState(bluetoothManager.ProfileId.PROFILE_A2DP_SOURCE);
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+## bluetoothManager.cancelPairedDevice
+
+cancelPairedDevice(deviceId: string): void
+
+Cancels a paired remote device.
+
+**System API**: This is a system API.
+
+**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ------ | ---- | ------------------------------------- |
+| deviceId | string | Yes | Address of the remote device to cancel, for example, XX:XX:XX:XX:XX:XX.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900003 | Bluetooth switch is off. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+try {
+ bluetoothManager.cancelPairedDevice("XX:XX:XX:XX:XX:XX");
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+## bluetoothManager.getRemoteDeviceName
+
+getRemoteDeviceName(deviceId: string): string
+
+Obtains the name of the remote Bluetooth device.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ------ | ---- | --------------------------------- |
+| deviceId | string | Yes | Address of the target remote device, for example, XX:XX:XX:XX:XX:XX.|
+
+**Return value**
+
+| Type | Description |
+| ------ | ------------- |
+| string | Device name (a string) obtained.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900003 | Bluetooth switch is off. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+try {
+ let remoteDeviceName = bluetoothManager.getRemoteDeviceName("XX:XX:XX:XX:XX:XX");
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+## bluetoothManager.getRemoteDeviceClass
+
+getRemoteDeviceClass(deviceId: string): DeviceClass
+
+Obtains the class of the remote Bluetooth device.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ------ | ---- | --------------------------------- |
+| deviceId | string | Yes | Address of the target remote device, for example, XX:XX:XX:XX:XX:XX.|
+
+**Return value**
+
+| Type | Description |
+| --------------------------- | -------- |
+| [DeviceClass](#deviceclass) | Class of the remote device obtained.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900003 | Bluetooth switch is off. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+try {
+ let remoteDeviceClass = bluetoothManager.getRemoteDeviceClass("XX:XX:XX:XX:XX:XX");
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+## bluetoothManager.getPairedDevices
+
+getPairedDevices(): Array<string>
+
+Obtains the paired devices.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Return value**
+
+| Type | Description |
+| ------------------- | ------------- |
+| Array<string> | Addresses of the paired Bluetooth devices.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900003 | Bluetooth switch is off. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+try {
+ let devices = bluetoothManager.getPairedDevices();
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+## bluetoothManager.setBluetoothScanMode
+
+setBluetoothScanMode(mode: ScanMode, duration: number): void
+
+Sets the Bluetooth scan mode so that the device can be discovered by a remote device.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | --------------------- | ---- | ---------------------------- |
+| mode | [ScanMode](#scanmode) | Yes | Bluetooth scan mode to set. |
+| duration | number | Yes | Duration (in ms) in which the device can be discovered. The value **0** indicates unlimited time.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900003 | Bluetooth switch is off. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+try {
+ // The device can be discovered and connected only when the discoverable and connectable mode is used.
+ bluetoothManager.setBluetoothScanMode(bluetoothManager.ScanMode.SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE, 100);
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+## bluetoothManager.getBluetoothScanMode
+
+getBluetoothScanMode(): ScanMode
+
+Obtains the Bluetooth scan mode.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Return value**
+
+| Type | Description |
+| --------------------- | ------- |
+| [ScanMode](#scanmode) | Bluetooth scan mode to set.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900003 | Bluetooth switch is off. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+try {
+ let scanMode = bluetoothManager.getBluetoothScanMode();
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+## bluetoothManager.startBluetoothDiscovery
+
+startBluetoothDiscovery(): void
+
+Starts Bluetooth scan to discover remote devices.
+
+**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH and ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900003 | Bluetooth switch is off. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+let deviceId;
+function onReceiveEvent(data) {
+ deviceId = data;
+}
+try {
+ bluetoothManager.on('bluetoothDeviceFind', onReceiveEvent);
+ bluetoothManager.startBluetoothDiscovery();
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+## bluetoothManager.stopBluetoothDiscovery
+
+stopBluetoothDiscovery(): void
+
+Stops Bluetooth scan.
+
+**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900003 | Bluetooth switch is off. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+try {
+ bluetoothManager.stopBluetoothDiscovery();
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+## bluetoothManager.setDevicePairingConfirmation
+
+setDevicePairingConfirmation(device: string, accept: boolean): void
+
+Sets the device pairing confirmation.
+
+**Required permissions**: ohos.permission.MANAGE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ------ | ------- | ---- | -------------------------------- |
+| device | string | Yes | Address of the remote device, for example, XX:XX:XX:XX:XX:XX.|
+| accept | boolean | Yes | Whether to accept the pairing request. The value **true** means to accept the pairing request, and the value **false** means the opposite. |
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900003 | Bluetooth switch is off. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+
+try {
+ // Subscribe to the pinRequired event and configure the pairing confirmation after receiving a pairing request from the remote device.
+ function onReceivePinRequiredEvent(data) { // data is the input parameter for the pairing request.
+ console.info('pin required = '+ JSON.stringify(data));
+ bluetoothManager.setDevicePairingConfirmation(data.deviceId, true);
+ }
+ bluetoothManager.on("pinRequired", onReceivePinRequiredEvent);
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+## bluetoothManager.setDevicePinCode10+
+
+setDevicePinCode(device: string, code: string, callback: AsyncCallback<void>): void
+
+Sets the PIN for the device when [PinType](#pintype10) is **PIN_TYPE_ENTER_PIN_CODE** or **PIN_TYPE_PIN_16_DIGITS**.
+
+**Required permissions**: ohos.permission.MANAGE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ------ | ------- | ---- | -------------------------------- |
+| device | string | Yes | MAC address of the remote device, for example, XX:XX:XX:XX:XX:XX.|
+| code | string | Yes | PIN to set. |
+| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object. |
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900003 | Bluetooth switch is off. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+//callback
+try {
+ bluetoothManager.setDevicePinCode('11:22:33:44:55:66', '12345', (err, data) => {
+ console.info('setDevicePinCode,device name err:' + JSON.stringify(err) + ',device name:' + JSON.stringify(data));
+ });
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+## bluetoothManager.setDevicePinCode10+
+
+setDevicePinCode(device: string, code: string): Promise<void>
+
+Sets the PIN for the device when [PinType](#pintype10) is **PIN_TYPE_ENTER_PIN_CODE** or **PIN_TYPE_PIN_16_DIGITS**. This API uses a promise to return the result.
+
+**Required permissions**: ohos.permission.MANAGE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ------ | ------- | ---- | -------------------------------- |
+| device | string | Yes | MAC address of the remote device, for example, XX:XX:XX:XX:XX:XX.|
+| code | string | Yes | PIN to set. |
+
+**Return value**
+
+| Type | Description |
+| ------------------- | ------------- |
+| Promise<void> | Promise used to return the result.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900003 | Bluetooth switch is off. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+//promise
+try {
+ bluetoothManager.setDevicePinCode('11:22:33:44:55:66', '12345').then(() => {
+ console.info('setDevicePinCode');
+ }, error => {
+ console.info('setDevicePinCode: errCode:' + error.code + ',errMessage' + error.message);
+ })
+
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+## bluetoothManager.on('bluetoothDeviceFind')
+
+on(type: "bluetoothDeviceFind", callback: Callback<Array<string>>): void
+
+Subscribes to the Bluetooth device discovery events.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ----------------------------------- | ---- | -------------------------------------- |
+| type | string | Yes | Event type. The value **bluetoothDeviceFind** indicates an event reported when a Bluetooth device is discovered.|
+| callback | Callback<Array<string>> | Yes | Callback invoked to return the discovered devices. You need to implement this callback. |
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+function onReceiveEvent(data) { // data is a set of Bluetooth device addresses.
+ console.info('bluetooth device find = '+ JSON.stringify(data));
+}
+try {
+ bluetoothManager.on('bluetoothDeviceFind', onReceiveEvent);
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+## bluetoothManager.off('bluetoothDeviceFind')
+
+off(type: "bluetoothDeviceFind", callback?: Callback<Array<string>>): void
+
+Unsubscribes from the Bluetooth device discovery events.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ----------------------------------- | ---- | ---------------------------------------- |
+| type | string | Yes | Event type. The value **bluetoothDeviceFind** indicates an event reported when a Bluetooth device is discovered. |
+| callback | Callback<Array<string>> | No | Callback for the **bluetoothDeviceFind** event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+function onReceiveEvent(data) {
+ console.info('bluetooth device find = '+ JSON.stringify(data));
+}
+try {
+ bluetoothManager.on('bluetoothDeviceFind', onReceiveEvent);
+ bluetoothManager.off('bluetoothDeviceFind', onReceiveEvent);
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+## bluetoothManager.on('pinRequired')
+
+on(type: "pinRequired", callback: Callback<PinRequiredParam>): void
+
+Subscribes to the pairing request events of the remote Bluetooth device.
+
+**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | -------------------------------- |
+| type | string | Yes | Event type. The value **pinRequired** indicates a pairing request event. |
+| callback | Callback<[PinRequiredParam](#pinrequiredparam)> | Yes | Callback invoked to return the pairing request. You need to implement this callback.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+function onReceiveEvent(data) { // data is the pairing request parameter.
+ console.info('pin required = '+ JSON.stringify(data));
+}
+try {
+ bluetoothManager.on('pinRequired', onReceiveEvent);
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+## bluetoothManager.off('pinRequired')
+
+off(type: "pinRequired", callback?: Callback<PinRequiredParam>): void
+
+Unsubscribes from the pairing request events of the remote Bluetooth device.
+
+**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
+| type | string | Yes | Event type. The value **pinRequired** indicates a pairing request event. |
+| callback | Callback<[PinRequiredParam](#pinrequiredparam)> | No | Callback for the Bluetooth pairing request event. The input parameter is the pairing request parameter. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+function onReceiveEvent(data) {
+ console.info('pin required = '+ JSON.stringify(data));
+}
+try {
+ bluetoothManager.on('pinRequired', onReceiveEvent);
+ bluetoothManager.off('pinRequired', onReceiveEvent);
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+## bluetoothManager.on('bondStateChange')
+
+on(type: "bondStateChange", callback: Callback<BondStateParam>): void
+
+Subscribes to the Bluetooth pairing state change events.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | ------------------------------------ |
+| type | string | Yes | Event type. The value **bondStateChange** indicates a Bluetooth pairing state change event.|
+| callback | Callback<[BondStateParam](#BondStateParam)> | Yes | Callback invoked to return the pairing state. You need to implement this callback. |
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+function onReceiveEvent(data) { // data, as the input parameter of the callback, indicates the pairing state.
+ console.info('pair state = '+ JSON.stringify(data));
+}
+try {
+ bluetoothManager.on('bondStateChange', onReceiveEvent);
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+## bluetoothManager.off('bondStateChange')
+
+off(type: "bondStateChange", callback?: Callback<BondStateParam>): void
+
+Unsubscribes from the Bluetooth pairing state change events.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
+| type | string | Yes | Event type. The value **bondStateChange** indicates a Bluetooth pairing state change event. |
+| callback | Callback<[BondStateParam](#BondStateParam)> | No | Callback for the change of the Bluetooth pairing state. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+function onReceiveEvent(data) {
+ console.info('bond state = '+ JSON.stringify(data));
+}
+try {
+ bluetoothManager.on('bondStateChange', onReceiveEvent);
+ bluetoothManager.off('bondStateChange', onReceiveEvent);
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+## bluetoothManager.on('stateChange')
+
+on(type: "stateChange", callback: Callback<BluetoothState>): void
+
+Subscribes to the Bluetooth connection state change events.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | -------------------------------- |
+| type | string | Yes | Event type. The value **stateChange** indicates a Bluetooth connection state change event. |
+| callback | Callback<[BluetoothState](#bluetoothstate)> | Yes | Callback invoked to return the Bluetooth connection state. You need to implement this callback.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+function onReceiveEvent(data) {
+ console.info('bluetooth state = '+ JSON.stringify(data));
+}
+try {
+ bluetoothManager.on('stateChange', onReceiveEvent);
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+## bluetoothManager.off('stateChange')
+
+off(type: "stateChange", callback?: Callback<BluetoothState>): void
+
+Unsubscribes from the Bluetooth connection state change events.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
+| type | string | Yes | Event type. The value **stateChange** indicates a Bluetooth connection state change event. |
+| callback | Callback<[BluetoothState](#bluetoothstate)> | No | Callback for the Bluetooth connection state change event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+function onReceiveEvent(data) {
+ console.info('bluetooth state = '+ JSON.stringify(data));
+}
+try {
+ bluetoothManager.on('stateChange', onReceiveEvent);
+ bluetoothManager.off('stateChange', onReceiveEvent);
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+## bluetoothManager.sppListen
+
+sppListen(name: string, option: SppOption, callback: AsyncCallback<number>): void
+
+Creates a server listening socket.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | --------------------------- | ---- | ----------------------- |
+| name | string | Yes | Name of the service. |
+| option | [SppOption](#sppoption) | Yes | Serial port profile (SPP) listening configuration. |
+| callback | AsyncCallback<number> | Yes | Callback invoked to return the server socket ID.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900003 | Bluetooth switch is off. |
+|2900004 | Profile is not supported. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+let serverNumber = -1;
+function serverSocket(code, number) {
+ console.log('bluetooth error code: ' + code.code);
+ if (code.code == 0) {
+ console.log('bluetooth serverSocket Number: ' + number);
+ serverNumber = number;
+ }
+}
+
+let sppOption = {uuid: '00001810-0000-1000-8000-00805F9B34FB', secure: false, type: 0};
+try {
+ bluetoothManager.sppListen('server1', sppOption, serverSocket);
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+## bluetoothManager.sppAccept
+
+sppAccept(serverSocket: number, callback: AsyncCallback<number>): void
+
+Listens for a connection to be made to this socket from the client and accepts it.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ------------ | --------------------------- | ---- | ----------------------- |
+| serverSocket | number | Yes | Server socket ID. |
+| callback | AsyncCallback<number> | Yes | Callback invoked to return the client socket ID.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900003 | Bluetooth switch is off. |
+|2900004 | Profile is not supported. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+let serverNumber = -1;
+function serverSocket(code, number) {
+ console.log('bluetooth error code: ' + code.code);
+ if (code.code == 0) {
+ console.log('bluetooth serverSocket Number: ' + number);
+ serverNumber = number;
+ }
+}
+let clientNumber = -1;
+function acceptClientSocket(code, number) {
+ console.log('bluetooth error code: ' + code.code);
+ if (code.code == 0) {
+ console.log('bluetooth clientSocket Number: ' + number);
+ // The obtained clientNumber is used as the socket ID for subsequent read/write operations on the server.
+ clientNumber = number;
+ }
+}
+try {
+ bluetoothManager.sppAccept(serverNumber, acceptClientSocket);
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+## bluetoothManager.sppConnect
+
+sppConnect(device: string, option: SppOption, callback: AsyncCallback<number>): void
+
+Initiates an SPP connection to a remote device from the client.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | --------------------------- | ---- | ------------------------------ |
+| device | string | Yes | Address of the remote device, for example, XX:XX:XX:XX:XX:XX.|
+| option | [SppOption](#sppoption) | Yes | Configuration for connecting to the SPP client. |
+| callback | AsyncCallback<number> | Yes | Callback invoked to return the client socket ID. |
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900003 | Bluetooth switch is off. |
+|2900004 | Profile is not supported. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+
+let clientNumber = -1;
+function clientSocket(code, number) {
+ if (code.code != 0) {
+ return;
+ }
+ console.log('bluetooth serverSocket Number: ' + number);
+ // The obtained clientNumber is used as the socket ID for subsequent read/write operations on the client.
+ clientNumber = number;
+}
+let sppOption = {uuid: '00001810-0000-1000-8000-00805F9B34FB', secure: false, type: 0};
+try {
+ bluetoothManager.sppConnect('XX:XX:XX:XX:XX:XX', sppOption, clientSocket);
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+## bluetoothManager.sppCloseServerSocket
+
+sppCloseServerSocket(socket: number): void
+
+Closes the listening socket of the server.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ------ | ------ | ---- | --------------- |
+| socket | number | Yes | ID of the listening socket on the server. The ID is obtained by **sppListen**.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+let serverNumber = -1;
+function serverSocket(code, number) {
+ console.log('bluetooth error code: ' + code.code);
+ if (code.code == 0) {
+ console.log('bluetooth serverSocket Number: ' + number);
+ serverNumber = number;
+ }
+}
+try {
+ bluetoothManager.sppCloseServerSocket(serverNumber);
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+## bluetoothManager.sppCloseClientSocket
+
+sppCloseClientSocket(socket: number): void
+
+Closes the client socket.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ------ | ------ | ---- | ------------- |
+| Name | Type | Mandatory | Description |
+| socket | number | Yes | Client socket ID, which is obtained by **sppAccept** or **sppConnect**.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+let clientNumber = -1;
+function clientSocket(code, number) {
+ if (code.code != 0) {
+ return;
+ }
+ console.log('bluetooth serverSocket Number: ' + number);
+ // The obtained clientNumber is used as the socket ID for subsequent read/write operations on the client.
+ clientNumber = number;
+}
+try {
+ bluetoothManager.sppCloseClientSocket(clientNumber);
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+## bluetoothManager.sppWrite
+
+sppWrite(clientSocket: number, data: ArrayBuffer): void
+
+Writes data to the remote device through the socket.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ------------ | ----------- | ---- | ------------- |
+| clientSocket | number | Yes | Client socket ID, which is obtained by **sppAccept** or **sppConnect**.|
+| data | ArrayBuffer | Yes | Data to write. |
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2901054 | IO error. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+let clientNumber = -1;
+function clientSocket(code, number) {
+ if (code.code != 0) {
+ return;
+ }
+ console.log('bluetooth serverSocket Number: ' + number);
+ // The obtained clientNumber is used as the socket ID for subsequent read/write operations on the client.
+ clientNumber = number;
+}
+let arrayBuffer = new ArrayBuffer(8);
+let data = new Uint8Array(arrayBuffer);
+data[0] = 123;
+try {
+ bluetoothManager.sppWrite(clientNumber, arrayBuffer);
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+## bluetoothManager.on('sppRead')
+
+on(type: "sppRead", clientSocket: number, callback: Callback<ArrayBuffer>): void
+
+Subscribes to the SPP read request events.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ------------ | --------------------------- | ---- | -------------------------- |
+| type | string | Yes | Event type. The value **sppRead** indicates an SPP read request event.|
+| clientSocket | number | Yes | Client socket ID, which is obtained by **sppAccept** or **sppConnect**. |
+| callback | Callback<ArrayBuffer> | Yes | Callback invoked to return the data read. |
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2901054 | IO error. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+let clientNumber = -1;
+function clientSocket(code, number) {
+ if (code.code != 0) {
+ return;
+ }
+ console.log('bluetooth serverSocket Number: ' + number);
+ // The obtained clientNumber is used as the socket ID for subsequent read/write operations on the client.
+ clientNumber = number;
+}
+function dataRead(dataBuffer) {
+ let data = new Uint8Array(dataBuffer);
+ console.log('bluetooth data is: ' + data[0]);
+}
+try {
+ bluetoothManager.on('sppRead', clientNumber, dataRead);
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+## bluetoothManager.off('sppRead')
+
+off(type: "sppRead", clientSocket: number, callback?: Callback<ArrayBuffer>): void
+
+Unsubscribes from the SPP read request events.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ------------ | --------------------------- | ---- | ---------------------------------------- |
+| type | string | Yes | Event type. The value **sppRead** indicates an SPP read request event. |
+| clientSocket | number | Yes | Client socket ID, which is obtained by **sppAccept** or **sppConnect**. |
+| callback | Callback<ArrayBuffer> | No | Callback for the SPP read request event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.|
+
+**Example**
+
+```js
+let clientNumber = -1;
+function clientSocket(code, number) {
+ if (code.code != 0) {
+ return;
+ }
+ console.log('bluetooth serverSocket Number: ' + number);
+ // The obtained clientNumber is used as the socket ID for subsequent read/write operations on the client.
+ clientNumber = number;
+}
+try {
+ bluetoothManager.off('sppRead', clientNumber);
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+## bluetoothManager.getProfileInstance
+
+getProfileInstance(profileId: ProfileId): A2dpSourceProfile | HandsFreeAudioGatewayProfile | HidHostProfile | PanProfile
+
+Obtains a profile instance. API version 9 is added with **HidHostProfile** and **PanProfile**.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| --------- | --------- | ---- | ------------------------------------- |
+| profileId | [ProfileId](#ProfileId) | Yes | ID of the profile to obtain, for example, **PROFILE_A2DP_SOURCE**.|
+
+**Return value**
+
+| Type | Description |
+| ------------------------------------------------------------ | ------------------------------------------------------------ |
+| [A2dpSourceProfile](#a2dpsourceprofile), [HandsFreeAudioGatewayProfile](#handsfreeaudiogatewayprofile), [HidHostProfile](#hidhostprofile), or [PanProfile](#panprofile)| Profile instance obtained, which can be **A2dpSourceProfile**, **HandsFreeAudioGatewayProfile**, **HidHostProfile**, or **PanProfile**.|
+
+**Example**
+
+```js
+try {
+ let hidHost = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_HID_HOST);
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+## bluetoothManager.BLE
+
+### bluetoothManager.BLE.createGattServer
+
+createGattServer(): GattServer
+
+Creates a **GattServer** instance.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Return value**
+
+| Type | Description |
+| ------------------------- | ------------------------------------ |
+| [GattServer](#gattserver) | **GattServer** instance created. Before using an API of this class, you must create a **GattSever** instance.|
+
+**Example**
+
+```js
+let gattServer = bluetoothManager.BLE.createGattServer();
+```
+
+
+### bluetoothManager.BLE.createGattClientDevice
+
+createGattClientDevice(deviceId: string): GattClientDevice
+
+Creates a **GattClientDevice** instance.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ------ | ---- | ------------------------------------ |
+| deviceId | string | Yes | Address of the remote device, for example, XX:XX:XX:XX:XX:XX.|
+
+**Return value**
+
+| Type | Description |
+| ------------------------------------- | ------------------------------------ |
+| [GattClientDevice](#gattclientdevice) | **GattClientDevice** instance created. Before using an API of the client, you must create a **GattClientDevice** instance.|
+
+**Example**
+
+```js
+try {
+ let device = bluetoothManager.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+### bluetoothManager.BLE.getConnectedBLEDevices
+
+getConnectedBLEDevices(): Array<string>
+
+Obtains the BLE devices connected to this device.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Return value**
+
+| Type | Description |
+| ------------------- | ------------------- |
+| Array<string> | Addresses of the BLE devices connected to this device.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900003 | Bluetooth switch is off. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+try {
+ let result = bluetoothManager.BLE.getConnectedBLEDevices();
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+### bluetoothManager.BLE.startBLEScan
+
+startBLEScan(filters: Array<ScanFilter>, options?: ScanOptions): void
+
+Starts a BLE scan.
+
+**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH, ohos.permission.MANAGE_BLUETOOTH, ohos.permission.LOCATION, and ohos.permission.APPROXIMATELY_LOCATION
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ------- | -------------------------------------- | ---- | ----------------------------------- |
+| filters | Array<[ScanFilter](#scanfilter)> | Yes | Criteria for filtering the scan result. Set this parameter to **null** if you do not want to filter the scan result.|
+| options | [ScanOptions](#scanoptions) | No | Scan options. |
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900003 | Bluetooth switch is off. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+function onReceiveEvent(data) {
+ console.info('BLE scan device find result = '+ JSON.stringify(data));
+}
+try {
+ bluetoothManager.BLE.on("BLEDeviceFind", onReceiveEvent);
+ bluetoothManager.BLE.startBLEScan(
+ [{
+ deviceId:"XX:XX:XX:XX:XX:XX",
+ name:"test",
+ serviceUuid:"00001888-0000-1000-8000-00805f9b34fb"
+ }],
+ {
+ interval: 500,
+ dutyMode: bluetoothManager.ScanDuty.SCAN_MODE_LOW_POWER,
+ matchMode: bluetoothManager.MatchMode.MATCH_MODE_AGGRESSIVE,
+ }
+ );
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+### bluetoothManager.BLE.stopBLEScan
+
+stopBLEScan(): void
+
+Stops the BLE scan.
+
+**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900003 | Bluetooth switch is off. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+try {
+ bluetoothManager.BLE.stopBLEScan();
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+### bluetoothManager.BLE.on('BLEDeviceFind')
+
+on(type: "BLEDeviceFind", callback: Callback<Array<ScanResult>>): void
+
+Subscribe to the BLE device discovery events.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | ----------------------------------- |
+| type | string | Yes | Event type. The value **BLEDeviceFind** indicates an event reported when a BLE device is discovered. |
+| callback | Callback<Array<[ScanResult](#scanresult)>> | Yes | Callback invoked to return the discovered devices. You need to implement this callback.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+function onReceiveEvent(data) {
+ console.info('bluetooth device find = '+ JSON.stringify(data));
+}
+try {
+ bluetoothManager.BLE.on('BLEDeviceFind', onReceiveEvent);
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+### bluetoothManager.BLE.off('BLEDeviceFind')
+
+off(type: "BLEDeviceFind", callback?: Callback<Array<ScanResult>>): void
+
+Unsubscribes from the BLE device discovery events.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
+| type | string | Yes | Event type. The value **BLEDeviceFind** indicates an event reported when a BLE device is discovered. |
+| callback | Callback<Array<[ScanResult](#scanresult)>> | No | Callback for the **BLEDeviceFind** event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+function onReceiveEvent(data) {
+ console.info('bluetooth device find = '+ JSON.stringify(data));
+}
+try {
+ bluetoothManager.BLE.on('BLEDeviceFind', onReceiveEvent);
+ bluetoothManager.BLE.off('BLEDeviceFind', onReceiveEvent);
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+## BaseProfile
+
+Provides the profile base class.
+
+
+### getConnectionDevices
+
+getConnectionDevices(): Array<string>
+
+Obtains the connected devices.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Return value**
+
+| Type | Description |
+| ------------------- | ------------- |
+| Array<string> | Addresses of the connected devices.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900003 | Bluetooth switch is off. |
+|2900004 | Profile is not supported. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+try {
+ let a2dpSrc = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_A2DP_SOURCE) as bluetoothManager.A2dpSourceProfile;
+ let retArray = a2dpSrc.getConnectionDevices();
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+### getDeviceState
+
+getDeviceState(device: string): ProfileConnectionState
+
+Obtains the connection state of the profile.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ------ | ------ | ---- | ------- |
+| device | string | Yes | Address of the target device.|
+
+**Return value**
+
+| Type | Description |
+| ------------------------------------------------- | ----------------------- |
+| [ProfileConnectionState](#profileconnectionstate) | Profile connection state obtained.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900003 | Bluetooth switch is off. |
+|2900004 | Profile is not supported. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+try {
+ let a2dpSrc = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_A2DP_SOURCE) as bluetoothManager.A2dpSourceProfile;
+ let ret = a2dpSrc.getDeviceState('XX:XX:XX:XX:XX:XX');
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+## A2dpSourceProfile
+
+Before using an API of **A2dpSourceProfile**, you need to create an instance of this class by using **getProfile()**.
+
+
+### connect
+
+connect(device: string): void
+
+Sets up an Advanced Audio Distribution Profile (A2DP) connection.
+
+**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ------ | ------ | ---- | ------- |
+| device | string | Yes | Address of the target device.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900003 | Bluetooth switch is off. |
+|2900004 | Profile is not supported. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+try {
+ let a2dpSrc = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_A2DP_SOURCE) as bluetoothManager.A2dpSourceProfile;
+ a2dpSrc.connect('XX:XX:XX:XX:XX:XX');
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+### disconnect
+
+disconnect(device: string): void
+
+Disconnects an A2DP connection.
+
+**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ------ | ------ | ---- | ------- |
+| device | string | Yes | Address of the target device.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900003 | Bluetooth switch is off. |
+|2900004 | Profile is not supported. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+try {
+ let a2dpSrc = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_A2DP_SOURCE) as bluetoothManager.A2dpSourceProfile;
+ a2dpSrc.disconnect('XX:XX:XX:XX:XX:XX');
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+### on('connectionStateChange')
+
+on(type: "connectionStateChange", callback: Callback<[StateChangeParam](#StateChangeParam)>): void
+
+Subscribes to the A2DP connection state change events.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
+| type | string | Yes | Event type. The value **connectionStateChange** indicates an A2DP connection state change event.|
+| callback | Callback<[StateChangeParam](#StateChangeParam)> | Yes | Callback invoked to return the A2DP connection state change event. |
+
+**Return value**
+
+No value is returned.
+
+**Example**
+
+```js
+function onReceiveEvent(data) {
+ console.info('a2dp state = '+ JSON.stringify(data));
+}
+let a2dpSrc = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_A2DP_SOURCE) as bluetoothManager.A2dpSourceProfile;
+a2dpSrc.on('connectionStateChange', onReceiveEvent);
+```
+
+
+### off('connectionStateChange')
+
+off(type: "connectionStateChange", callback?: Callback<[StateChangeParam](#StateChangeParam)>): void
+
+Unsubscribes from the A2DP connection state change events.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
+| type | string | Yes | Event type. The value **connectionStateChange** indicates an A2DP connection state change event.|
+| callback | Callback<[StateChangeParam](#StateChangeParam)> | No | Callback for the A2DP connection state change event. |
+
+**Return value**
+
+No value is returned.
+
+**Example**
+
+```js
+function onReceiveEvent(data) {
+ console.info('a2dp state = '+ JSON.stringify(data));
+}
+let a2dpSrc = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_A2DP_SOURCE) as bluetoothManager.A2dpSourceProfile;
+a2dpSrc.on('connectionStateChange', onReceiveEvent);
+a2dpSrc.off('connectionStateChange', onReceiveEvent);
+```
+
+
+### getPlayingState
+
+getPlayingState(device: string): PlayingState
+
+Obtains the playing state of a device.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ------ | ------ | ---- | ------- |
+| device | string | Yes | Address of the target device.|
+
+**Return value**
+
+| Type | Description |
+| ----------------------------- | ---------- |
+| [PlayingState](#PlayingState) | Playing state of the remote device obtained.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900003 | Bluetooth switch is off. |
+|2900004 | Profile is not supported. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+try {
+ let a2dpSrc = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_A2DP_SOURCE) as bluetoothManager.A2dpSourceProfile;
+ let state = a2dpSrc.getPlayingState('XX:XX:XX:XX:XX:XX');
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+## HandsFreeAudioGatewayProfile
+
+Before using an API of **HandsFreeAudioGatewayProfile**, you need to create an instance of this class by using **getProfile()**.
+
+
+### connect
+
+connect(device: string): void
+
+Sets up a Hands-free Profile (HFP) connection of a device.
+
+**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ------ | ------ | ---- | ------- |
+| device | string | Yes | Address of the target device.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900003 | Bluetooth switch is off. |
+|2900004 | Profile is not supported. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+try {
+ let hfpAg = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_HANDS_FREE_AUDIO_GATEWAY) as bluetoothManager.HandsFreeAudioGatewayProfile;
+ hfpAg.connect('XX:XX:XX:XX:XX:XX');
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+### disconnect
+
+disconnect(device: string): void
+
+Disconnects the HFP connection of a device.
+
+**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ------ | ------ | ---- | ------- |
+| device | string | Yes | Address of the target device.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900003 | Bluetooth switch is off. |
+|2900004 | Profile is not supported. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+try {
+ let hfpAg = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_HANDS_FREE_AUDIO_GATEWAY) as bluetoothManager.HandsFreeAudioGatewayProfile;
+ hfpAg.disconnect('XX:XX:XX:XX:XX:XX');
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+### on('connectionStateChange')
+
+on(type: "connectionStateChange", callback: Callback<[StateChangeParam](#StateChangeParam)>): void
+
+Subscribes to the HFP connection state change events.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
+| type | string | Yes | Event type. The value **connectionStateChange** indicates an HFP connection state change event. |
+| callback | Callback<[StateChangeParam](#StateChangeParam)> | Yes | Callback invoked to return the HFP connection state change event. |
+
+**Example**
+
+```js
+function onReceiveEvent(data) {
+ console.info('hfp state = '+ JSON.stringify(data));
+}
+let hfpAg = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_HANDS_FREE_AUDIO_GATEWAY) as
+ bluetoothManager.HandsFreeAudioGatewayProfile;
+hfpAg.on('connectionStateChange', onReceiveEvent);
+```
+
+
+### off('connectionStateChange')
+
+off(type: "connectionStateChange", callback?: Callback<[StateChangeParam](#StateChangeParam)>): void
+
+Unsubscribes from the HFP connection state change events.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
+| type | string | Yes | Event type. The value **connectionStateChange** indicates an HFP connection state change event. |
+| callback | Callback<[StateChangeParam](#StateChangeParam)> | No | Callback for the HFP connection state change event. |
+
+**Example**
+
+```js
+function onReceiveEvent(data) {
+ console.info('hfp state = '+ JSON.stringify(data));
+}
+let hfpAg = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_HANDS_FREE_AUDIO_GATEWAY) as
+ bluetoothManager.HandsFreeAudioGatewayProfile;
+hfpAg.on('connectionStateChange', onReceiveEvent);
+hfpAg.off('connectionStateChange', onReceiveEvent);
+```
+
+
+## HidHostProfile
+
+Before using an API of **HidHostProfile**, you need to create an instance of this class by using **getProfile()**.
+
+
+### connect
+
+connect(device: string): void
+
+Connects to the HidHost service of a device.
+
+**System API**: This is a system API.
+
+**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ------ | ------ | ---- | ------- |
+| device | string | Yes | Address of the target device.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900003 | Bluetooth switch is off. |
+|2900004 | Profile is not supported. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+try {
+ let hidHostProfile = bluetoothManager.getProfileInst(bluetoothManager.ProfileId.PROFILE_HID_HOST) as bluetoothManager.HidHostProfile;
+ hidHostProfile.connect('XX:XX:XX:XX:XX:XX');
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+### disconnect
+
+disconnect(device: string): void
+
+Disconnects from the HidHost service of a device.
+
+**System API**: This is a system API.
+
+**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ------ | ------ | ---- | ------- |
+| device | string | Yes | Address of the target device.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900003 | Bluetooth switch is off. |
+|2900004 | Profile is not supported. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+try {
+ let hidHostProfile = bluetoothManager.getProfileInst(bluetoothManager.ProfileId.PROFILE_HID_HOST) as bluetoothManager.HidHostProfile;
+ hidHostProfile.disconnect('XX:XX:XX:XX:XX:XX');
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+### on('connectionStateChange')
+
+on(type: "connectionStateChange", callback: Callback<[StateChangeParam](#StateChangeParam)>): void
+
+Subscribes to the HidHost connection state change events.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
+| type | string | Yes | Event type. The value **connectionStateChange** indicates a HidHost connection state change event. |
+| callback | Callback<[StateChangeParam](#StateChangeParam)> | Yes | Callback invoked to return the HidHost connection state change event. |
+
+**Example**
+
+```js
+function onReceiveEvent(data) {
+ console.info('hidHost state = '+ JSON.stringify(data));
+}
+let hidHost = bluetoothManager.getProfileInst(bluetoothManager.ProfileId.PROFILE_HID_HOST) as bluetoothManager.HidHostProfile;
+hidHost.on('connectionStateChange', onReceiveEvent);
+```
+
+
+### off('connectionStateChange')
+
+off(type: "connectionStateChange", callback?: Callback<[StateChangeParam](#StateChangeParam)>): void
+
+Unsubscribes from the HidHost connection state change events.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ----------------------------------------------------- | ---- | --------------------------------------------------------- |
+| type | string | Yes | Event type. The value **connectionStateChange** indicates a HidHost connection state change event. |
+| callback | Callback<[StateChangeParam](#StateChangeParam)> | No | Callback for the HidHost connection state change event. |
+
+**Example**
+
+```js
+function onReceiveEvent(data) {
+ console.info('hidHost state = '+ JSON.stringify(data));
+}
+let hidHost = bluetoothManager.getProfileInst(bluetoothManager.ProfileId.PROFILE_HID_HOST) as bluetoothManager.HidHostProfile;
+hidHost.on('connectionStateChange', onReceiveEvent);
+hidHost.off('connectionStateChange', onReceiveEvent);
+```
+
+
+## PanProfile
+
+Before using an API of **PanProfile**, you need to create an instance of this class by using **getProfile()**.
+
+
+### disconnect
+
+disconnect(device: string): void
+
+Disconnects from the Personal Area Network (PAN) service of a device.
+
+**System API**: This is a system API.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ------ | ------ | ---- | ------- |
+| device | string | Yes | Address of the target device.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900003 | Bluetooth switch is off. |
+|2900004 | Profile is not supported. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+try {
+ let panProfile = bluetoothManager.getProfileInst(bluetoothManager.ProfileId.PROFILE_PAN_NETWORK) as bluetoothManager.PanProfile;
+ panProfile.disconnect('XX:XX:XX:XX:XX:XX');
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+### on('connectionStateChange')
+
+on(type: "connectionStateChange", callback: Callback<[StateChangeParam](#StateChangeParam)>): void
+
+Subscribes to the PAN connection state change events.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
+| type | string | Yes | Event type. The value **connectionStateChange** indicates a PAN connection state change event. |
+| callback | Callback<[StateChangeParam](#StateChangeParam)> | Yes | Callback invoked to return the PAN connection state change event. |
+
+**Example**
+
+```js
+function onReceiveEvent(data) {
+ console.info('pan state = '+ JSON.stringify(data));
+}
+let panProfile = bluetoothManager.getProfileInst(bluetoothManager.ProfileId.PROFILE_PAN_NETWORK) as bluetoothManager.PanProfile;
+panProfile.on('connectionStateChange', onReceiveEvent);
+```
+
+
+### off('connectionStateChange')
+
+off(type: "connectionStateChange", callback?: Callback<[StateChangeParam](#StateChangeParam)>): void
+
+Unsubscribes from the PAN connection state change events.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ----------------------------------------------------- | ---- | --------------------------------------------------------- |
+| type | string | Yes | Event type. The value **connectionStateChange** indicates a PAN connection state change event. |
+| callback | Callback<[StateChangeParam](#StateChangeParam)> | No | Callback for the PAN connection state change event. |
+
+**Example**
+
+```js
+function onReceiveEvent(data) {
+ console.info('pan state = '+ JSON.stringify(data));
+}
+let panProfile = bluetoothManager.getProfileInst(bluetoothManager.ProfileId.PROFILE_PAN_NETWORK) as bluetoothManager.PanProfile;
+panProfile.on('connectionStateChange', onReceiveEvent);
+panProfile.off('connectionStateChange', onReceiveEvent);
+```
+
+
+### setTethering
+
+setTethering(enable: boolean): void
+
+Sets tethering.
+
+**System API**: This is a system API.
+
+**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ------ | ------ | ---- | ------- |
+| value | boolean | Yes | Whether to set tethering over a Bluetooth PAN.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900003 | Bluetooth switch is off. |
+|2900004 | Profile is not supported. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+try {
+ let panProfile = bluetoothManager.getProfileInst(bluetoothManager.ProfileId.PROFILE_PAN_NETWORK) as bluetoothManager.PanProfile;
+ panProfile.setTethering(true);
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+### isTetheringOn
+
+isTetheringOn(): boolean
+
+Obtains the network sharing status.
+
+**System API**: This is a system API.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Return value**
+
+| Type | Description |
+| --------------------- | --------------------------------- |
+| boolean | Returns **true** if tethering is available over a Bluetooth PAN; return **false** otherwise.|
+
+**Example**
+
+```js
+try {
+ let panProfile = bluetoothManager.getProfileInst(bluetoothManager.ProfileId.PROFILE_PAN_NETWORK) as bluetoothManager.PanProfile;
+ let ret = panProfile.isTetheringOn();
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+## GattServer
+
+Implements the Generic Attribute Profile (GATT) server. Before using an API of this class, you need to create a **GattServer** instance using **createGattServer()**.
+
+
+### startAdvertising
+
+startAdvertising(setting: AdvertiseSetting, advData: AdvertiseData, advResponse?: AdvertiseData): void
+
+Starts BLE advertising.
+
+**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ----------- | ------------------------------------- | ---- | -------------- |
+| setting | [AdvertiseSetting](#advertisesetting) | Yes | Settings related to BLE advertising. |
+| advData | [AdvertiseData](#advertisedata) | Yes | Content of the BLE advertisement packet. |
+| advResponse | [AdvertiseData](#advertisedata) | No | Response to the BLE scan request.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900003 | Bluetooth switch is off. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+let manufactureValueBuffer = new Uint8Array(4);
+manufactureValueBuffer[0] = 1;
+manufactureValueBuffer[1] = 2;
+manufactureValueBuffer[2] = 3;
+manufactureValueBuffer[3] = 4;
+
+let serviceValueBuffer = new Uint8Array(4);
+serviceValueBuffer[0] = 4;
+serviceValueBuffer[1] = 6;
+serviceValueBuffer[2] = 7;
+serviceValueBuffer[3] = 8;
+console.info('manufactureValueBuffer = '+ JSON.stringify(manufactureValueBuffer));
+console.info('serviceValueBuffer = '+ JSON.stringify(serviceValueBuffer));
+let gattServer = bluetoothManager.BLE.createGattServer();
+try {
+ gattServer.startAdvertising({
+ interval:150,
+ txPower:60,
+ connectable:true,
+ },{
+ serviceUuids:["00001888-0000-1000-8000-00805f9b34fb"],
+ manufactureData:[{
+ manufactureId:4567,
+ manufactureValue:manufactureValueBuffer.buffer
+ }],
+ serviceData:[{
+ serviceUuid:"00001888-0000-1000-8000-00805f9b34fb",
+ serviceValue:serviceValueBuffer.buffer
+ }],
+ },{
+ serviceUuids:["00001889-0000-1000-8000-00805f9b34fb"],
+ manufactureData:[{
+ manufactureId:1789,
+ manufactureValue:manufactureValueBuffer.buffer
+ }],
+ serviceData:[{
+ serviceUuid:"00001889-0000-1000-8000-00805f9b34fb",
+ serviceValue:serviceValueBuffer.buffer
+ }],
+ });
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+### stopAdvertising
+
+stopAdvertising(): void
+
+Stops BLE advertising.
+
+**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900003 | Bluetooth switch is off. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+let server = bluetoothManager.BLE.createGattServer();
+try {
+ server.stopAdvertising();
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+### addService
+
+addService(service: GattService): void
+
+Adds a service to this GATT server.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ------- | --------------------------- | ---- | ------------------------ |
+| service | [GattService](#gattservice) | Yes | Service to add. Settings related to BLE advertising.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900003 | Bluetooth switch is off. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+// Create descriptors.
+let descriptors = [];
+let arrayBuffer = new ArrayBuffer(8);
+let descV = new Uint8Array(arrayBuffer);
+descV[0] = 11;
+let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
+descriptors[0] = descriptor;
+
+// Create characteristics.
+let characteristics = [];
+let arrayBufferC = new ArrayBuffer(8);
+let cccV = new Uint8Array(arrayBufferC);
+cccV[0] = 1;
+let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB', characteristicValue: arrayBufferC, descriptors:descriptors};
+let characteristicN = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001821-0000-1000-8000-00805F9B34FB', characteristicValue: arrayBufferC, descriptors:descriptors};
+characteristics[0] = characteristic;
+
+// Create a gattService instance.
+let gattService = {serviceUuid:'00001810-0000-1000-8000-00805F9B34FB', isPrimary: true, characteristics:characteristics, includeServices:[]};
+
+let gattServer = bluetoothManager.BLE.createGattServer();
+try {
+ gattServer.addService(gattService);
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+### removeService
+
+removeService(serviceUuid: string): void
+
+Removes a service from this GATT server.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ----------- | ------ | ---- | ---------------------------------------- |
+| serviceUuid | string | Yes | Universally unique identifier (UUID) of the service to remove, for example, **00001810-0000-1000-8000-00805F9B34FB**.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900003 | Bluetooth switch is off. |
+|2900004 | Profile is not supported. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+let server = bluetoothManager.BLE.createGattServer();
+try {
+ server.removeService('00001810-0000-1000-8000-00805F9B34FB');
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+### close
+
+close(): void
+
+Closes this GATT server to unregister it from the protocol stack. After this method is called, this [GattServer](#gattserver) cannot be used.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900003 | Bluetooth switch is off. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+let server = bluetoothManager.BLE.createGattServer();
+try {
+ server.close();
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+### notifyCharacteristicChanged
+
+notifyCharacteristicChanged(deviceId: string, notifyCharacteristic: NotifyCharacteristic): void
+
+Notifies the connected client device when a characteristic value changes.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------------------- | ---------------------------------------- | ---- | --------------------------------------- |
+| deviceId | string | Yes | Address of the client that receives notifications, for example, XX:XX:XX:XX:XX:XX.|
+| notifyCharacteristic | [NotifyCharacteristic](#notifycharacteristic) | Yes | New characteristic value. |
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900003 | Bluetooth switch is off. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+// Create descriptors.
+let descriptors = [];
+let arrayBuffer = new ArrayBuffer(8);
+let descV = new Uint8Array(arrayBuffer);
+descV[0] = 11;
+let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
+descriptors[0] = descriptor;
+let arrayBufferC = new ArrayBuffer(8);
+let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB', characteristicValue: arrayBufferC, descriptors:descriptors};
+let notifyCharacteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001821-0000-1000-8000-00805F9B34FB', characteristicValue: characteristic.characteristicValue, confirm: false};
+let server = bluetoothManager.BLE.createGattServer();
+try {
+ server.notifyCharacteristicChanged('XX:XX:XX:XX:XX:XX', notifyCharacteristic);
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+### sendResponse
+
+sendResponse(serverResponse: ServerResponse): void
+
+Sends a response to a read or write request from the GATT client.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------------- | --------------------------------- | ---- | --------------- |
+| serverResponse | [ServerResponse](#serverresponse) | Yes | Response returned by the GATT server.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900003 | Bluetooth switch is off. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+/* send response */
+let arrayBufferCCC = new ArrayBuffer(8);
+let cccValue = new Uint8Array(arrayBufferCCC);
+cccValue[0] = 1123;
+let serverResponse = {
+ "deviceId": "XX:XX:XX:XX:XX:XX",
+ "transId": 0,
+ "status": 0,
+ "offset": 0,
+ "value": arrayBufferCCC,
+};
+
+let gattServer = bluetoothManager.BLE.createGattServer();
+try {
+ gattServer.sendResponse(serverResponse);
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+### on('characteristicRead')
+
+on(type: "characteristicRead", callback: Callback<CharacteristicReadRequest>): void
+
+Subscribes to the characteristic read request events.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | ------------------------------------- |
+| type | string | Yes | Event type. The value **characteristicRead** indicates a characteristic read request event.|
+| callback | Callback<[CharacteristicReadRequest](#characteristicreadrequest)> | Yes | Callback invoked to return a characteristic read request event from the GATT client. |
+
+**Example**
+
+```js
+let arrayBufferCCC = new ArrayBuffer(8);
+let cccValue = new Uint8Array(arrayBufferCCC);
+cccValue[0] = 1123;
+function ReadCharacteristicReq(CharacteristicReadRequest) {
+ let deviceId = CharacteristicReadRequest.deviceId;
+ let transId = CharacteristicReadRequest.transId;
+ let offset = CharacteristicReadRequest.offset;
+ let characteristicUuid = CharacteristicReadRequest.characteristicUuid;
+
+ let serverResponse = {deviceId: deviceId, transId: transId, status: 0, offset: offset, value:arrayBufferCCC};
+
+ try {
+ gattServer.sendResponse(serverResponse);
+ } catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+ }
+}
+
+let gattServer = bluetoothManager.BLE.createGattServer();
+gattServer.on("characteristicRead", ReadCharacteristicReq);
+```
+
+
+### off('characteristicRead')
+
+off(type: "characteristicRead", callback?: Callback<CharacteristicReadRequest>): void
+
+Unsubscribes from the characteristic read request events.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
+| type | string | Yes | Event type. The value **characteristicRead** indicates a characteristic read request event. |
+| callback | Callback<[CharacteristicReadRequest](#characteristicreadrequest)> | No | Callback for the characteristic read request event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.|
+
+**Example**
+
+```js
+let gattServer = bluetoothManager.BLE.createGattServer();
+gattServer.off("characteristicRead");
+```
+
+
+### on('characteristicWrite')
+
+on(type: "characteristicWrite", callback: Callback<CharacteristicWriteRequest>): void
+
+Subscribes to the characteristic write request events.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | -------------------------------------- |
+| type | string | Yes | Event type. The value **characteristicWrite** indicates a characteristic write request event.|
+| callback | Callback<[CharacteristicWriteRequest](#characteristicwriterequest)> | Yes | Callback invoked to return a characteristic write request from the GATT client. |
+
+**Example**
+
+```js
+let arrayBufferCCC = new ArrayBuffer(8);
+let cccValue = new Uint8Array(arrayBufferCCC);
+function WriteCharacteristicReq(CharacteristicWriteRequest) {
+ let deviceId = CharacteristicWriteRequest.deviceId;
+ let transId = CharacteristicWriteRequest.transId;
+ let offset = CharacteristicWriteRequest.offset;
+ let isPrep = CharacteristicWriteRequest.isPrep;
+ let needRsp = CharacteristicWriteRequest.needRsp;
+ let value = new Uint8Array(CharacteristicWriteRequest.value);
+ let characteristicUuid = CharacteristicWriteRequest.characteristicUuid;
+
+ cccValue[0] = value[0];
+ let serverResponse = {deviceId: deviceId, transId: transId, status: 0, offset: offset, value:arrayBufferCCC};
+
+ try {
+ gattServer.sendResponse(serverResponse);
+ } catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+ }
+}
+
+let gattServer = bluetoothManager.BLE.createGattServer();
+gattServer.on("characteristicWrite", WriteCharacteristicReq);
+```
+
+
+### off('characteristicWrite')
+
+off(type: "characteristicWrite", callback?: Callback<CharacteristicWriteRequest>): void
+
+Unsubscribes from the characteristic write request events.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
+| type | string | Yes | Event type. The value **characteristicWrite** indicates a characteristic write request event. |
+| callback | Callback<[CharacteristicWriteRequest](#characteristicwriterequest)> | No | Callback for the characteristic write request event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.|
+
+**Example**
+
+```js
+let gattServer = bluetoothManager.BLE.createGattServer();
+gattServer.off("characteristicWrite");
+```
+
+
+### on('descriptorRead')
+
+on(type: "descriptorRead", callback: Callback<DescriptorReadRequest>): void
+
+Subscribes to the descriptor read request events.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | --------------------------------- |
+| type | string | Yes | Event type. The value **descriptorRead** indicates a descriptor read request event.|
+| callback | Callback<[DescriptorReadRequest](#descriptorreadrequest)> | Yes | Callback invoked to return a descriptor read request event from the GATT client. |
+
+**Example**
+
+```js
+let arrayBufferDesc = new ArrayBuffer(8);
+let descValue = new Uint8Array(arrayBufferDesc);
+descValue[0] = 1101;
+function ReadDescriptorReq(DescriptorReadRequest) {
+ let deviceId = DescriptorReadRequest.deviceId;
+ let transId = DescriptorReadRequest.transId;
+ let offset = DescriptorReadRequest.offset;
+ let descriptorUuid = DescriptorReadRequest.descriptorUuid;
+
+ let serverResponse = {deviceId: deviceId, transId: transId, status: 0, offset: offset, value:arrayBufferDesc};
+
+ try {
+ gattServer.sendResponse(serverResponse);
+ } catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+ }
+}
+
+let gattServer = bluetoothManager.BLE.createGattServer();
+gattServer.on("descriptorRead", ReadDescriptorReq);
+```
+
+
+### off('descriptorRead')
+
+off(type: "descriptorRead", callback?: Callback<DescriptorReadRequest>): void
+
+Unsubscribes from the descriptor read request events.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
+| type | string | Yes | Event type. The value **descriptorRead** indicates a descriptor read request event. |
+| callback | Callback<[DescriptorReadRequest](#descriptorreadrequest)> | No | Callback for the descriptor read request event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.|
+
+**Example**
+
+```js
+let gattServer = bluetoothManager.BLE.createGattServer();
+gattServer.off("descriptorRead");
+```
+
+
+### on('descriptorWrite')
+
+on(type: "descriptorWrite", callback: Callback<DescriptorWriteRequest>): void
+
+Subscribes to the descriptor write request events.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | ---------------------------------- |
+| type | string | Yes | Event type. The value **descriptorWrite** indicates a descriptor write request event.|
+| callback | Callback<[DescriptorWriteRequest](#descriptorwriterequest)> | Yes | Callback invoked to return a descriptor write request from the GATT client. |
+
+**Example**
+
+```js
+let arrayBufferDesc = new ArrayBuffer(8);
+let descValue = new Uint8Array(arrayBufferDesc);
+function WriteDescriptorReq(DescriptorWriteRequest) {
+ let deviceId = DescriptorWriteRequest.deviceId;
+ let transId = DescriptorWriteRequest.transId;
+ let offset = DescriptorWriteRequest.offset;
+ let isPrep = DescriptorWriteRequest.isPrep;
+ let needRsp = DescriptorWriteRequest.needRsp;
+ let value = new Uint8Array(DescriptorWriteRequest.value);
+ let descriptorUuid = DescriptorWriteRequest.descriptorUuid;
+
+ descValue[0] = value[0];
+ let serverResponse = {deviceId: deviceId, transId: transId, status: 0, offset: offset, value:arrayBufferDesc};
+
+ try {
+ gattServer.sendResponse(serverResponse);
+ } catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+ }
+}
+
+let gattServer = bluetoothManager.BLE.createGattServer();
+gattServer.on("descriptorRead", WriteDescriptorReq);
+```
+
+
+### off('descriptorWrite')
+
+off(type: "descriptorWrite", callback?: Callback<DescriptorWriteRequest>): void
+
+Unsubscribes from the descriptor write request events.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
+| type | string | Yes | Event type. The value **descriptorWrite** indicates a descriptor write request event. |
+| callback | Callback<[DescriptorWriteRequest](#descriptorwriterequest)> | No | Callback for the descriptor write request event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.|
+
+**Example**
+
+```js
+let gattServer = bluetoothManager.BLE.createGattServer();
+gattServer.off("descriptorWrite");
+```
+
+
+### on('connectStateChange')
+
+on(type: "connectStateChange", callback: Callback<BLEConnectChangedState>): void
+
+Subscribes to the BLE connection state change events.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
+| type | string | Yes | Event type. The value **connectStateChange** indicates a BLE connection state change event.|
+| callback | Callback<[BLEConnectChangedState](#bleconnectchangedstate)> | Yes | Callback invoked to return the BLE connection state. |
+
+**Example**
+
+```js
+function Connected(BLEConnectChangedState) {
+ let deviceId = BLEConnectChangedState.deviceId;
+ let status = BLEConnectChangedState.state;
+}
+
+let gattServer = bluetoothManager.BLE.createGattServer();
+gattServer.on("connectStateChange", Connected);
+```
+
+
+### off('connectStateChange')
+
+off(type: "connectStateChange", callback?: Callback<BLEConnectChangedState>): void
+
+Unsubscribes from the BLE connection state change events.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
+| type | string | Yes | Event type. The value **connectStateChange** indicates a BLE connection state change event.|
+| callback | Callback<[BLEConnectChangedState](#bleconnectchangedstate)> | No | Callback for the BLE connection state change event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.|
+
+**Example**
+
+```js
+let gattServer = bluetoothManager.BLE.createGattServer();
+gattServer.off("connectStateChange");
+```
+
+
+## GattClientDevice
+
+Implements the GATT client. Before using an API of this class, you must create a **GattClientDevice** instance using **createGattClientDevice(deviceId: string)**.
+
+
+### connect
+
+connect(): void
+
+Initiates a connection to the remote BLE device.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900003 | Bluetooth switch is off. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+try {
+ let device = bluetoothManager.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
+ device.connect();
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+### disconnect
+
+disconnect(): void
+
+Disconnects from the remote BLE device.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900003 | Bluetooth switch is off. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+try {
+ let device = bluetoothManager.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
+ device.disconnect();
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+### close
+
+close(): void
+
+Closes this GATT client to unregister it from the protocol stack. After this method is called, this [GattClientDevice](#gattclientdevice) instance cannot be used.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900003 | Bluetooth switch is off. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+try {
+ let device = bluetoothManager.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
+ device.close();
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+
+
+### getServices
+
+getServices(callback: AsyncCallback<Array<GattService>>): void
+
+Obtains all services of the remote BLE device. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | ------------------------ |
+| callback | AsyncCallback<Array<[GattService](#gattservice)>> | Yes | Callback invoked to return the services obtained.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+// Callback
+function getServices(code, gattServices) {
+ if (code.code == 0) {
+ let services = gattServices;
+ console.log('bluetooth code is ' + code.code);
+ console.log("bluetooth services size is ", services.length);
+
+ for (let i = 0; i < services.length; i++) {
+ console.log('bluetooth serviceUuid is ' + services[i].serviceUuid);
+ }
+ }
+}
+
+try {
+ let device = bluetoothManager.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
+ device.connect();
+ device.getServices(getServices);
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+### getServices
+
+getServices(): Promise<Array<GattService>>
+
+Obtains all services of the remote BLE device. This API uses a promise to return the result.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Return value**
+
+| Type | Description |
+| ---------------------------------------- | --------------------------- |
+| Promise<Array<[GattService](#gattservice)>> | Promise used to return the services obtained.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+// Promise
+try {
+ let device = bluetoothManager.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
+ device.connect();
+ device.getServices().then(result => {
+ console.info("getServices successfully:" + JSON.stringify(result));
+ });
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+### readCharacteristicValue
+
+readCharacteristicValue(characteristic: BLECharacteristic, callback: AsyncCallback<BLECharacteristic>): void
+
+Reads the characteristic value of the specific service of the remote BLE device. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------------- | ---------------------------------------- | ---- | ----------------------- |
+| characteristic | [BLECharacteristic](#blecharacteristic) | Yes | Characteristic value to read. |
+| callback | AsyncCallback<[BLECharacteristic](#blecharacteristic)> | Yes | Callback invoked to return the characteristic value read.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2901000 | Read forbidden. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+function readCcc(code, BLECharacteristic) {
+ if (code.code != 0) {
+ return;
+ }
+ console.log('bluetooth characteristic uuid: ' + BLECharacteristic.characteristicUuid);
+ let value = new Uint8Array(BLECharacteristic.characteristicValue);
+ console.log('bluetooth characteristic value: ' + value[0] +','+ value[1]+','+ value[2]+','+ value[3]);
+}
+
+let descriptors = [];
+let bufferDesc = new ArrayBuffer(8);
+let descV = new Uint8Array(bufferDesc);
+descV[0] = 11;
+let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+descriptorUuid: '00002903-0000-1000-8000-00805F9B34FB', descriptorValue: bufferDesc};
+descriptors[0] = descriptor;
+
+let bufferCCC = new ArrayBuffer(8);
+let cccV = new Uint8Array(bufferCCC);
+cccV[0] = 1;
+let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+characteristicValue: bufferCCC, descriptors:descriptors};
+
+try {
+ let device = bluetoothManager.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
+ device.readCharacteristicValue(characteristic, readCcc);
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+### readCharacteristicValue
+
+readCharacteristicValue(characteristic: BLECharacteristic): Promise<BLECharacteristic>
+
+Reads the characteristic value of the specific service of the remote BLE device. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------------- | --------------------------------------- | ---- | -------- |
+| characteristic | [BLECharacteristic](#blecharacteristic) | Yes | Characteristic value to read.|
+
+**Return value**
+
+| Type | Description |
+| ---------------------------------------- | -------------------------- |
+| Promise<[BLECharacteristic](#blecharacteristic)> | Promise used to return the characteristic value read.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2901000 | Read forbidden. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+let descriptors = [];
+let bufferDesc = new ArrayBuffer(8);
+let descV = new Uint8Array(bufferDesc);
+descV[0] = 11;
+let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+descriptorUuid: '00002903-0000-1000-8000-00805F9B34FB', descriptorValue: bufferDesc};
+descriptors[0] = descriptor;
+
+let bufferCCC = new ArrayBuffer(8);
+let cccV = new Uint8Array(bufferCCC);
+cccV[0] = 1;
+let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+characteristicValue: bufferCCC, descriptors:descriptors};
+
+try {
+ let device = bluetoothManager.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
+ device.readCharacteristicValue(characteristic);
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+### readDescriptorValue
+
+readDescriptorValue(descriptor: BLEDescriptor, callback: AsyncCallback<BLEDescriptor>): void
+
+Reads the descriptor contained in the specific characteristic of the remote BLE device. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ---------- | ---------------------------------------- | ---- | ----------------------- |
+| descriptor | [BLEDescriptor](#bledescriptor) | Yes | Descriptor to read. |
+| callback | AsyncCallback<[BLEDescriptor](#bledescriptor)> | Yes | Callback invoked to return the descriptor read.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2901000 | Read forbidden. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+function readDesc(code, BLEDescriptor) {
+ if (code.code != 0) {
+ return;
+ }
+ console.log('bluetooth descriptor uuid: ' + BLEDescriptor.descriptorUuid);
+ let value = new Uint8Array(BLEDescriptor.descriptorValue);
+ console.log('bluetooth descriptor value: ' + value[0] +','+ value[1]+','+ value[2]+','+ value[3]);
+}
+
+let bufferDesc = new ArrayBuffer(8);
+let descV = new Uint8Array(bufferDesc);
+descV[0] = 11;
+let descriptor = {
+ serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00002903-0000-1000-8000-00805F9B34FB',
+ descriptorValue: bufferDesc
+};
+try {
+ let device = bluetoothManager.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
+ device.readDescriptorValue(descriptor, readDesc);
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+### readDescriptorValue
+
+readDescriptorValue(descriptor: BLEDescriptor): Promise<BLEDescriptor>
+
+Reads the descriptor contained in the specific characteristic of the remote BLE device. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ---------- | ------------------------------- | ---- | -------- |
+| descriptor | [BLEDescriptor](#bledescriptor) | Yes | Descriptor to read.|
+
+**Return value**
+
+| Type | Description |
+| ---------------------------------------- | -------------------------- |
+| Promise<[BLEDescriptor](#bledescriptor)> | Promise used to return the descriptor read.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2901000 | Read forbidden. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+let bufferDesc = new ArrayBuffer(8);
+let descV = new Uint8Array(bufferDesc);
+descV[0] = 11;
+let descriptor = {
+ serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00002903-0000-1000-8000-00805F9B34FB',
+ descriptorValue: bufferDesc
+};
+try {
+ let device = bluetoothManager.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
+ device.readDescriptorValue(descriptor);
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+### writeCharacteristicValue
+
+writeCharacteristicValue(characteristic: BLECharacteristic): void
+
+Writes a characteristic value to the remote BLE device.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------------- | --------------------------------------- | ---- | ------------------- |
+| characteristic | [BLECharacteristic](#blecharacteristic) | Yes | Binary value and other parameters of the BLE device characteristic.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2901001 | Write forbidden. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+let descriptors = [];
+let bufferDesc = new ArrayBuffer(8);
+let descV = new Uint8Array(bufferDesc);
+descV[0] = 11;
+let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00002903-0000-1000-8000-00805F9B34FB', descriptorValue: bufferDesc};
+descriptors[0] = descriptor;
+
+let bufferCCC = new ArrayBuffer(8);
+let cccV = new Uint8Array(bufferCCC);
+cccV[0] = 1;
+let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ characteristicValue: bufferCCC, descriptors:descriptors};
+try {
+ let device = bluetoothManager.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
+ device.writeCharacteristicValue(characteristic);
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+### writeDescriptorValue
+
+writeDescriptorValue(descriptor: BLEDescriptor): void
+
+Writes binary data to the specific descriptor of the remote BLE device.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ---------- | ------------------------------- | ---- | ------------------ |
+| descriptor | [BLEDescriptor](#bledescriptor) | Yes | Binary value and other parameters of the BLE device descriptor.|
+| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2901001 | Write forbidden. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+let bufferDesc = new ArrayBuffer(8);
+let descV = new Uint8Array(bufferDesc);
+descV[0] = 22;
+let descriptor = {
+ serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00002903-0000-1000-8000-00805F9B34FB',
+ descriptorValue: bufferDesc
+};
+try {
+ let device = bluetoothManager.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
+ device.writeDescriptorValue(descriptor);
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+### setBLEMtuSize
+
+setBLEMtuSize(mtu: number): void
+
+Sets the maximum transmission unit (MTU) that can be transmitted between the GATT client and its remote BLE device. This API can be used only after a connection is set up by calling [connect](#connect).
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ---- | ------ | ---- | -------------- |
+| mtu | number | Yes | MTU to set, which ranges from 22 to 512 bytes.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+try {
+ let device = bluetoothManager.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
+ device.setBLEMtuSize(128);
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+### setNotifyCharacteristicChanged
+
+setNotifyCharacteristicChanged(characteristic: BLECharacteristic, enable: boolean): void
+
+Sets the function of notifying the GATT client when the characteristic value of the remote BLE device changes.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------------- | --------------------------------------- | ---- | ----------------------------- |
+| characteristic | [BLECharacteristic](#blecharacteristic) | Yes | BLE characteristic to listen for. |
+| enable | boolean | Yes | Whether to enable the notify function. The value **true** means to enable the notify function, and the value **false** means the opposite.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+// Create descriptors.
+let descriptors = [];
+let arrayBuffer = new ArrayBuffer(8);
+let descV = new Uint8Array(arrayBuffer);
+descV[0] = 11;
+let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
+ descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
+descriptors[0] = descriptor;
+let arrayBufferC = new ArrayBuffer(8);
+let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB', characteristicValue: arrayBufferC, descriptors:descriptors};
+try {
+ let device = bluetoothManager.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
+ device.setNotifyCharacteristicChanged(characteristic, false);
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+
+```
+
+
+### on('BLECharacteristicChange')
+
+on(type: "BLECharacteristicChange", callback: Callback<BLECharacteristic>): void
+
+Subscribes to the BLE characteristic change events. The client can receive a notification from the server only after the **setNotifyCharacteristicChanged** method is called.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
+| type | string | Yes | Event type. The value **BLECharacteristicChange** indicates a characteristic value change event.|
+| callback | Callback<[BLECharacteristic](#blecharacteristic)> | Yes | Callback invoked to return the characteristic value changes. |
+
+**Example**
+
+```js
+function CharacteristicChange(CharacteristicChangeReq) {
+ let serviceUuid = CharacteristicChangeReq.serviceUuid;
+ let characteristicUuid = CharacteristicChangeReq.characteristicUuid;
+ let value = new Uint8Array(CharacteristicChangeReq.characteristicValue);
+}
+try {
+ let device = bluetoothManager.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
+ device.on('BLECharacteristicChange', CharacteristicChange);
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+### off('BLECharacteristicChange')
+
+off(type: "BLECharacteristicChange", callback?: Callback<BLECharacteristic>): void
+
+Unsubscribes from the BLE characteristic change events.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
+| type | string | Yes | Event type. The value **BLECharacteristicChange** indicates a characteristic value change event.|
+| callback | Callback<[BLECharacteristic](#blecharacteristic)> | No | Callback for the characteristic value change event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.|
+
+**Example**
+
+```js
+try {
+ let device = bluetoothManager.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
+ device.off('BLECharacteristicChange');
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+### on('BLEConnectionStateChange')
+
+on(type: "BLEConnectionStateChange", callback: Callback<BLEConnectChangedState>): void
+
+Subscribes to the BLE connection state change events.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
+| type | string | Yes | Event type. The value **BLEConnectionStateChange** indicates a BLE connection state change event.|
+| callback | Callback<[BLEConnectChangedState](#bleconnectchangedstate)> | Yes | Callback invoked to return the BLE connection state. |
+
+**Example**
+
+```js
+function ConnectStateChanged(state) {
+ console.log('bluetooth connect state changed');
+ let connectState = state.state;
+}
+try {
+ let device = bluetoothManager.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
+ device.on('BLEConnectionStateChange', ConnectStateChanged);
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+### off('BLEConnectionStateChange')
+
+off(type: "BLEConnectionStateChange", callback?: Callback<BLEConnectChangedState>): void
+
+Unsubscribes from the BLE connection state change events.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
+| type | string | Yes | Event type. The value **BLEConnectionStateChange** indicates a BLE connection state change event.|
+| callback | Callback<[BLEConnectChangedState](#bleconnectchangedstate)> | No | Callback for the BLE connection state change event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.|
+
+**Example**
+
+```js
+try {
+ let device = bluetoothManager.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
+ device.off('BLEConnectionStateChange');
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+### getDeviceName
+
+getDeviceName(callback: AsyncCallback<string>): void
+
+Obtains the name of the remote BLE device. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | --------------------------- | ---- | ------------------------------- |
+| callback | AsyncCallback<string> | Yes | Callback invoked to return the remote BLE device name obtained.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+// callback
+try {
+ let gattClient = bluetoothManager.BLE.createGattClientDevice("XX:XX:XX:XX:XX:XX");
+ gattClient.connect();
+ let deviceName = gattClient.getDeviceName((err, data)=> {
+ console.info('device name err ' + JSON.stringify(err));
+ console.info('device name' + JSON.stringify(data));
+ })
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+### getDeviceName
+
+getDeviceName(): Promise<string>
+
+Obtains the name of the remote BLE device. This API uses a promise to return the result.
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Return value**
+
+| Type | Description |
+| --------------------- | ---------------------------------- |
+| Promise<string> | Promise used to return the remote BLE device name.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900001 | Service stopped. |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+// promise
+try {
+ let gattClient = bluetoothManager.BLE.createGattClientDevice("XX:XX:XX:XX:XX:XX");
+ gattClient.connect();
+ let deviceName = gattClient.getDeviceName().then((data) => {
+ console.info('device name' + JSON.stringify(data));
+ })
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+### getRssiValue
+
+getRssiValue(callback: AsyncCallback<number>): void
+
+Obtains the received signal strength indication (RSSI) of the remote BLE device. This API uses an asynchronous callback to return the result. It can be used only after a connection is set up by calling [connect](#connect).
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | --------------------------- | ---- | ------------------------------ |
+| callback | AsyncCallback<number> | Yes | Callback invoked to return the RSSI, in dBm.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+// callback
+try {
+ let gattClient = bluetoothManager.BLE.createGattClientDevice("XX:XX:XX:XX:XX:XX");
+ gattClient.connect();
+ let rssi = gattClient.getRssiValue((err, data)=> {
+ console.info('rssi err ' + JSON.stringify(err));
+ console.info('rssi value' + JSON.stringify(data));
+ })
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+
+### getRssiValue
+
+getRssiValue(): Promise<number>
+
+Obtains the RSSI of the remote BLE device. This API uses a promise to return the result. It can be used only after a connection is set up by calling [connect](#connect).
+
+**Required permissions**: ohos.permission.USE_BLUETOOTH
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+**Return value**
+
+| Type | Description |
+| --------------------- | --------------------------------- |
+| Promise<number> | Promise used to return the RSSI, in dBm.|
+
+**Error codes**
+
+For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
+
+| ID| Error Message|
+| -------- | ---------------------------- |
+|2900099 | Operation failed. |
+
+**Example**
+
+```js
+// promise
+try {
+ let gattClient = bluetoothManager.BLE.createGattClientDevice("XX:XX:XX:XX:XX:XX");
+ let rssi = gattClient.getRssiValue().then((data) => {
+ console.info('rssi' + JSON.stringify(data));
+ })
+} catch (err) {
+ console.error("errCode:" + err.code + ",errMessage:" + err.message);
+}
+```
+
+## ScanMode
+
+Enumerates the scan modes.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name | Value | Description |
+| ---------------------------------------- | ---- | --------------- |
+| SCAN_MODE_NONE | 0 | No scan mode. |
+| SCAN_MODE_CONNECTABLE | 1 | Connectable mode. |
+| SCAN_MODE_GENERAL_DISCOVERABLE | 2 | General discoverable mode. |
+| SCAN_MODE_LIMITED_DISCOVERABLE | 3 | Limited discoverable mode. |
+| SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE | 4 | General connectable and discoverable mode.|
+| SCAN_MODE_CONNECTABLE_LIMITED_DISCOVERABLE | 5 | Limited connectable and discoverable mode.|
+
+## BondState
+
+Enumerates the pairing states.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name | Value | Description |
+| ------------------ | ---- | ------ |
+| BOND_STATE_INVALID | 0 | Invalid pairing.|
+| BOND_STATE_BONDING | 1 | Pairing. |
+| BOND_STATE_BONDED | 2 | Paired. |
+
+
+## SppOption
+
+Defines the SPP configuration parameters.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name | Type | Readable | Writable | Description |
+| ------ | ------------------- | ---- | ---- | ----------- |
+| uuid | string | Yes | Yes | UUID of the SPP.|
+| secure | boolean | Yes | Yes | Whether it is a secure channel. |
+| type | [SppType](#spptype) | Yes | Yes | Type of the SPP link. |
+
+
+## SppType
+
+Enumerates the SPP link types.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name | Value | Description |
+| ---------- | ---- | ------------- |
+| SPP_RFCOMM | 0 | Radio frequency communication (RFCOMM) link type.|
+
+
+## GattService
+
+Defines the GATT service API parameters.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name | Type | Readable | Writable | Description |
+| --------------- | ---------------------------------------- | ---- | ---- | ---------------------------------------- |
+| serviceUuid | string | Yes | Yes | UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**.|
+| isPrimary | boolean | Yes | Yes | Whether the service is a primary service. The value **true** means a primary service. |
+| characteristics | Array<[BLECharacteristic](#blecharacteristic)> | Yes | Yes | List of characteristics of the service. |
+| includeServices | Array<[GattService](#gattservice)> | Yes | Yes | Services on which the service depends. |
+
+
+## BLECharacteristic
+
+Defines the characteristic API parameters.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name | Type | Readable | Writable | Description |
+| ------------------- | ---------------------------------------- | ---- | ---- | ---------------------------------------- |
+| serviceUuid | string | Yes | Yes | UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**.|
+| characteristicUuid | string | Yes | Yes | UUID of the characteristic, for example, **00002a11-0000-1000-8000-00805f9b34fb**.|
+| characteristicValue | ArrayBuffer | Yes | Yes | Binary value of the characteristic. |
+| descriptors | Array<[BLEDescriptor](#bledescriptor)> | Yes | Yes | List of descriptors of the characteristic. |
+| properties10+ | [GattProperties](#gattproperties10) | Yes | Yes | Properties of the characteristic. |
+
+
+## BLEDescriptor
+
+Defines the BLE descriptor.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name | Type | Readable | Writable | Description |
+| ------------------ | ----------- | ---- | ---- | ---------------------------------------- |
+| serviceUuid | string | Yes | Yes | UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**.|
+| characteristicUuid | string | Yes | Yes | UUID of the characteristic, for example, **00002a11-0000-1000-8000-00805f9b34fb**.|
+| descriptorUuid | string | Yes | Yes | UUID of the descriptor, for example, **00002902-0000-1000-8000-00805f9b34fb**.|
+| descriptorValue | ArrayBuffer | Yes | Yes | Binary value of the descriptor. |
+
+
+## NotifyCharacteristic
+
+Defines the parameters in the notifications sent when the server characteristic value changes.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name | Type | Readable | Writable | Description |
+| ------------------- | ----------- | ---- | ---- | ---------------------------------------- |
+| serviceUuid | string | Yes | Yes | UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**.|
+| characteristicUuid | string | Yes | Yes | UUID of the characteristic, for example, **00002a11-0000-1000-8000-00805f9b34fb**.|
+| characteristicValue | ArrayBuffer | Yes | Yes | Binary value of the characteristic. |
+| confirm | boolean | Yes | Yes | Whether the notification needs to be confirmed by the remote end. For a notification, set it to **true**. In this case, the remote end must confirm the receipt of the notification. For an indication, set it to **false**. In this case, the remote end does not need to confirm the receipt of the notification.|
+
+
+## CharacteristicReadRequest
+
+Defines the parameters of the **CharacteristicReadReq** event received by the server.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name | Type | Readable | Writable | Description |
+| ------------------ | ------ | ---- | ---- | ---------------------------------------- |
+| deviceId | string | Yes | No | Address of the remote device that sends the **CharacteristicReadReq** event, for example, XX:XX:XX:XX:XX:XX.|
+| transId | number | Yes | No | Transmission ID of the read request. The response returned by the server must use the same transmission ID. |
+| offset | number | Yes | No | Position from which the characteristic value is read. For example, **k** means to read from the kth byte. The response returned by the server must use the same offset.|
+| characteristicUuid | string | Yes | No | UUID of the characteristic, for example, **00002a11-0000-1000-8000-00805f9b34fb**.|
+| serviceUuid | string | Yes | No | UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**.|
+
+
+## CharacteristicWriteRequest
+
+Defines the parameters of the **CharacteristicWriteReq** event received by the server.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name | Type | Readable | Writable | Description |
+| ------------------ | ------ | ---- | ---- | ---------------------------------------- |
+| deviceId | string | Yes | No | Address of the remote device that sends the **CharacteristicWriteReq** event, for example, XX:XX:XX:XX:XX:XX.|
+| transId | number | Yes | No | Transmission ID of the write request. The response returned by the server must use the same transmission ID. |
+| offset | number | Yes | No | Start position for writing the characteristic value. For example, **k** means to write from the kth byte. The response returned by the server must use the same offset.|
+| descriptorUuid | string | Yes | No | UUID of the descriptor, for example, **00002902-0000-1000-8000-00805f9b34fb**.|
+| characteristicUuid | string | Yes | No | UUID of the characteristic, for example, **00002a11-0000-1000-8000-00805f9b34fb**.|
+| serviceUuid | string | Yes | No | UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**.|
+
+
+## DescriptorReadRequest
+
+Defines the parameters of the **DescriptorReadReq** event received by the server.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name | Type | Readable | Writable | Description |
+| ------------------ | ------ | ---- | ---- | ---------------------------------------- |
+| deviceId | string | Yes | No | Address of the remote device that sends a **DescriptorReadReq** event, for example, XX:XX:XX:XX:XX:XX.|
+| transId | number | Yes | No | Transmission ID of the read request. The response returned by the server must use the same transmission ID. |
+| offset | number | Yes | No | Position from which the descriptor is read. For example, **k** means to read from the kth byte. The response returned by the server must use the same offset.|
+| descriptorUuid | string | Yes | No | UUID of the descriptor, for example, **00002902-0000-1000-8000-00805f9b34fb**.|
+| characteristicUuid | string | Yes | No | UUID of the characteristic, for example, **00002a11-0000-1000-8000-00805f9b34fb**.|
+| serviceUuid | string | Yes | No | UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**.|
+
+
+## DescriptorWriteRequest
+
+Defines the parameters of the **DescriptorWriteReq** event received by the server.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name | Type | Readable | Writable | Description |
+| ------------------ | ----------- | ---- | ---- | ---------------------------------------- |
+| deviceId | string | Yes | No | Address of the remote device that sends a **DescriptorWriteReq** event, for example, XX:XX:XX:XX:XX:XX.|
+| transId | number | Yes | No | Transmission ID of the write request. The response returned by the server must use the same transmission ID. |
+| offset | number | Yes | No | Start position for writing the descriptor. For example, **k** means to write from the kth byte. The response returned by the server must use the same offset.|
+| isPrep | boolean | Yes | No | Whether the write request is executed immediately. |
+| needRsp | boolean | Yes | No | Whether to send a response to the GATT client. |
+| value | ArrayBuffer | Yes | No | Binary value of the descriptor to write. |
+| descriptorUuid | string | Yes | No | UUID of the descriptor, for example, **00002902-0000-1000-8000-00805f9b34fb**.|
+| characteristicUuid | string | Yes | No | UUID of the characteristic, for example, **00002a11-0000-1000-8000-00805f9b34fb**.|
+| serviceUuid | string | Yes | No | UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**.|
+
+
+## ServerResponse
+
+Defines the parameters of the server's response to the GATT client's read/write request.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name | Type | Readable | Writable | Description |
+| -------- | ----------- | ---- | ---- | -------------------------------------- |
+| deviceId | string | Yes | No | Address of the remote device, for example, XX:XX:XX:XX:XX:XX. |
+| transId | number | Yes | No | Transmission ID of the request. The value must be the same as the ID carried in the read/write request received. |
+| status | number | Yes | No | Response state. Set this parameter to **0**, which indicates a normal response. |
+| offset | number | Yes | No | Start read/write position. The value must be the same as the offset carried in the read/write request.|
+| value | ArrayBuffer | Yes | No | Binary data in the response. |
+
+
+## BLEConnectChangedState
+
+Defines the parameters of **BLEConnectChangedState**.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name | Type | Readable| Writable| Description |
+| -------- | ------------------------------------------------- | ---- | ---- | --------------------------------------------- |
+| deviceId | string | Yes | No | Address of the remote device, for example, XX:XX:XX:XX:XX:XX.|
+| state | [ProfileConnectionState](#profileconnectionstate) | Yes | Yes | BLE connection state. |
+
+
+## ProfileConnectionState
+
+Enumerates the profile connection states.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name | Value | Description |
+| ------------------- | ---- | -------------- |
+| STATE_DISCONNECTED | 0 | Disconnected. |
+| STATE_CONNECTING | 1 | Connecting.|
+| STATE_CONNECTED | 2 | Connected. |
+| STATE_DISCONNECTING | 3 | Disconnecting.|
+
+
+## ScanFilter
+
+Defines the scan filter parameters.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name | Type | Readable| Writable| Description |
+| ---------------------------------------- | ----------- | ---- | ---- | ------------------------------------------------------------ |
+| deviceId | string | Yes | Yes | Address of the BLE device to filter, for example, XX:XX:XX:XX:XX:XX. |
+| name | string | Yes | Yes | Name of the BLE device to filter. |
+| serviceUuid | string | Yes | Yes | Service UUID of the device to filter, for example, **00001888-0000-1000-8000-00805f9b34fb**.|
+| serviceUuidMask | string | Yes | Yes | Service UUID mask of the device to filter, for example, **FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF**.|
+| serviceSolicitationUuid | string | Yes | Yes | Service solicitation UUID of the device to filter, for example, **00001888-0000-1000-8000-00805F9B34FB**.|
+| serviceSolicitationUuidMask | string | Yes | Yes | Service solicitation UUID mask of the device to filter, for example, **FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF**.|
+| serviceData | ArrayBuffer | Yes | Yes | Service data of the device to filter, for example, **[0x90, 0x00, 0xF1, 0xF2]**.|
+| serviceDataMask | ArrayBuffer | Yes | Yes | Service data mask of the device to filter, for example, **[0xFF,0xFF,0xFF,0xFF]**.|
+| manufactureId | number | Yes | Yes | Manufacturer ID of the device to filter, for example, **0x0006**. |
+| manufactureData | ArrayBuffer | Yes | Yes | Manufacturer data of the device to filter, for example, **[0x1F,0x2F,0x3F]**.|
+| manufactureDataMask | ArrayBuffer | Yes | Yes | Manufacturer data mask of the device to filter, for example, **[0xFF, 0xFF, 0xFF]**.|
+
+
+## ScanOptions
+
+Defines the scan configuration parameters.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name | Type | Readable | Writable | Description |
+| --------- | ----------------------- | ---- | ---- | -------------------------------------- |
+| interval | number | Yes | Yes | Delay in reporting the scan result. The default value is **0**. |
+| dutyMode | [ScanDuty](#scanduty) | Yes | Yes | Scan duty. The default value is SCAN_MODE_LOW_POWER. |
+| matchMode | [MatchMode](#matchmode) | Yes | Yes | Hardware filtering match mode. The default value is **MATCH_MODE_AGGRESSIVE**.|
+
+
+## ScanDuty
+
+Enumerates the scan duty options.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name | Value | Description |
+| --------------------- | ---- | ------------ |
+| SCAN_MODE_LOW_POWER | 0 | Low-power mode, which is the default value.|
+| SCAN_MODE_BALANCED | 1 | Balanced mode. |
+| SCAN_MODE_LOW_LATENCY | 2 | Low-latency mode. |
+
+
+## MatchMode
+
+Enumerates the hardware match modes of BLE scan filters.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name | Value | Description |
+| --------------------- | ---- | ---------------------------------------- |
+| MATCH_MODE_AGGRESSIVE | 1 | Hardware reports the scan result with a lower threshold of signal strength and few number of matches in a duration. This is the default value.|
+| MATCH_MODE_STICKY | 2 | Hardware reports the scan result with a higher threshold of signal strength and sightings. |
+
+
+## ScanResult
+
+Defines the scan result.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name | Type | Readable | Writable | Description |
+| -------- | ----------- | ---- | ---- | ---------------------------------- |
+| deviceId | string | Yes | No | Address of the scanned device, for example, XX:XX:XX:XX:XX:XX.|
+| rssi | number | Yes | No | RSSI of the device. |
+| data | ArrayBuffer | Yes | No | Advertisement packets sent by the device. |
+| deviceName10+ | string | Yes | No | Name of the device detected. |
+
+
+## BluetoothState
+
+Enumerates the Bluetooth states.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name | Value | Description |
+| --------------------- | ---- | ------------------ |
+| STATE_OFF | 0 | Bluetooth is turned off. |
+| STATE_TURNING_ON | 1 | Bluetooth is being turned on. |
+| STATE_ON | 2 | Bluetooth is turned on. |
+| STATE_TURNING_OFF | 3 | Bluetooth is being turned off. |
+| STATE_BLE_TURNING_ON | 4 | The LE-only mode is being turned on for Bluetooth.|
+| STATE_BLE_ON | 5 | Bluetooth is in LE-only mode. |
+| STATE_BLE_TURNING_OFF | 6 | The LE-only mode is being turned off for Bluetooth.|
+
+
+## AdvertiseSetting
+
+Defines the BLE advertising parameters.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name | Type | Readable | Writable | Description |
+| ----------- | ------- | ---- | ---- | ---------------------------------------- |
+| interval | number | Yes | Yes | Interval for BLE advertising. The minimum value is **32** slots (20 ms). The maximum value is **16384** slots. The default value is **1600** slots (1s).|
+| txPower | number | Yes | Yes | Transmit power, in dBm. The value range is -127 to 1. The default value is **-7**. |
+| connectable | boolean | Yes | Yes | Whether the advertisement is connectable. The default value is **true**. |
+
+
+## AdvertiseData
+
+Defines the content of a BLE advertisement packet.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name | Type | Readable | Writable | Description |
+| --------------- | ---------------------------------------- | ---- | ---- | --------------------------- |
+| serviceUuids | Array<string> | Yes | Yes | List of service UUIDs to broadcast.|
+| manufactureData | Array<[ManufactureData](#manufacturedata)> | Yes | Yes | List of manufacturers to broadcast. |
+| serviceData | Array<[ServiceData](#servicedata)> | Yes | Yes | List of service data to broadcast. |
+
+
+## ManufactureData
+
+Defines the content of a BLE advertisement packet.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name | Type | Readable | Writable | Description |
+| ---------------- | ------------------- | ---- | ---- | ------------------ |
+| manufactureId | number | Yes | Yes | Manufacturer ID allocated by the Bluetooth SIG.|
+| manufactureValue | ArrayBuffer | Yes | Yes | Manufacturer data. |
+
+
+## ServiceData
+
+Defines the service data contained in an advertisement packet.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name | Type | Readable | Writable | Description |
+| ------------ | ----------- | ---- | ---- | ---------- |
+| serviceUuid | string | Yes | Yes | Service UUID.|
+| serviceValue | ArrayBuffer | Yes | Yes | Service data. |
+
+
+## PinRequiredParam
+
+Defines the pairing request parameters.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name | Type | Readable | Writable | Description |
+| -------- | ------ | ---- | ---- | ----------- |
+| deviceId | string | Yes | No | ID of the device to pair.|
+| pinCode | string | Yes | No | Key for the device pairing. |
+| pinType10+ | [PinType](#pintype10) | Yes | No | Type of the device to pair. |
+
+
+## BondStateParam
+
+Defines the pairing state parameters.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name | Type | Readable | Writable | Description |
+| -------- | ------ | ---- | ---- | ----------- |
+| deviceId | string | Yes | No | ID of the device to pair.|
+| state | BondState | Yes | No | State of the device.|
+
+
+## StateChangeParam
+
+Defines the profile state change parameters.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name | Type | Readable| Writable| Description |
+| -------- | ------------------------------------------------- | ---- | ---- | ------------------------------- |
+| deviceId | string | Yes | No | Address of a Bluetooth device. |
+| state | [ProfileConnectionState](#profileconnectionstate) | Yes | No | Profile connection state of the device.|
+
+
+## GattProperties10+
+
+Defines the properties of a GATT characteristic.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name | Type | Read-only | Mandatory | Description |
+| -------- | ------ | ---- | ---- | ----------- |
+| write10+ | boolean | Yes | Yes | Permits writes of the characteristic value (with a response).|
+| writeNoResponse10+ | boolean | Yes | Yes | Permits writes of the characteristic value (without a response).|
+| read10+ | boolean | Yes | Yes | Permits reads of the characteristic value.|
+| notify10+ | boolean | Yes | Yes | Permits notifications of the characteristic value.|
+| indicate10+ | boolean | Yes | Yes | Permits notifications of the characteristic value without acknowledgement.|
+
+
+## DeviceClass
+
+Defines the class of a Bluetooth device.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name | Type | Readable | Writable | Description |
+| --------------- | ----------------------------------- | ---- | ---- | ---------------- |
+| majorClass | [MajorClass](#majorclass) | Yes | No | Major classes of Bluetooth devices. |
+| majorMinorClass | [MajorMinorClass](#majorminorclass) | Yes | No | Major and minor classes of Bluetooth devices.|
+| classOfDevice | number | Yes | No | Class of the device. |
+
+
+## MajorClass
+
+Enumerates the major classes of Bluetooth devices.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name | Value | Description |
+| ------------------- | ------ | ---------- |
+| MAJOR_MISC | 0x0000 | Miscellaneous device. |
+| MAJOR_COMPUTER | 0x0100 | Computer. |
+| MAJOR_PHONE | 0x0200 | Mobile phone. |
+| MAJOR_NETWORKING | 0x0300 | Network device. |
+| MAJOR_AUDIO_VIDEO | 0x0400 | Audio or video device.|
+| MAJOR_PERIPHERAL | 0x0500 | Peripheral device. |
+| MAJOR_IMAGING | 0x0600 | Imaging device. |
+| MAJOR_WEARABLE | 0x0700 | Wearable device. |
+| MAJOR_TOY | 0x0800 | Toy. |
+| MAJOR_HEALTH | 0x0900 | Health device. |
+| MAJOR_UNCATEGORIZED | 0x1F00 | Unclassified device. |
+
+
+## MajorMinorClass
+
+Enumerates the major and minor classes of Bluetooth devices.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name | Value | Description |
+| ---------------------------------------- | ------ | --------------- |
+| COMPUTER_UNCATEGORIZED | 0x0100 | Unclassified computer. |
+| COMPUTER_DESKTOP | 0x0104 | Desktop computer. |
+| COMPUTER_SERVER | 0x0108 | Server. |
+| COMPUTER_LAPTOP | 0x010C | Laptop. |
+| COMPUTER_HANDHELD_PC_PDA | 0x0110 | Hand-held computer. |
+| COMPUTER_PALM_SIZE_PC_PDA | 0x0114 | Palmtop computer. |
+| COMPUTER_WEARABLE | 0x0118 | Wearable computer. |
+| COMPUTER_TABLET | 0x011C | Tablet. |
+| PHONE_UNCATEGORIZED | 0x0200 | Unclassified mobile phone. |
+| PHONE_CELLULAR | 0x0204 | Portable phone. |
+| PHONE_CORDLESS | 0x0208 | Cordless phone. |
+| PHONE_SMART | 0x020C | Smartphone. |
+| PHONE_MODEM_OR_GATEWAY | 0x0210 | Modem or gateway phone.|
+| PHONE_ISDN | 0x0214 | ISDN phone. |
+| NETWORK_FULLY_AVAILABLE | 0x0300 | Device with network fully available. |
+| NETWORK_1_TO_17_UTILIZED | 0x0320 | Device used on network 1 to 17. |
+| NETWORK_17_TO_33_UTILIZED | 0x0340 | Device used on network 17 to 33. |
+| NETWORK_33_TO_50_UTILIZED | 0x0360 | Device used on network 33 to 50. |
+| NETWORK_60_TO_67_UTILIZED | 0x0380 | Device used on network 60 to 67. |
+| NETWORK_67_TO_83_UTILIZED | 0x03A0 | Device used on network 67 to 83. |
+| NETWORK_83_TO_99_UTILIZED | 0x03C0 | Device used on network 83 to 99. |
+| NETWORK_NO_SERVICE | 0x03E0 | Device without network service |
+| AUDIO_VIDEO_UNCATEGORIZED | 0x0400 | Unclassified audio or video device. |
+| AUDIO_VIDEO_WEARABLE_HEADSET | 0x0404 | Wearable audio or video headset. |
+| AUDIO_VIDEO_HANDSFREE | 0x0408 | Hands-free audio or video device. |
+| AUDIO_VIDEO_MICROPHONE | 0x0410 | Audio or video microphone. |
+| AUDIO_VIDEO_LOUDSPEAKER | 0x0414 | Audio or video loudspeaker. |
+| AUDIO_VIDEO_HEADPHONES | 0x0418 | Audio or video headphones. |
+| AUDIO_VIDEO_PORTABLE_AUDIO | 0x041C | Portable audio or video device. |
+| AUDIO_VIDEO_CAR_AUDIO | 0x0420 | In-vehicle audio or video device. |
+| AUDIO_VIDEO_SET_TOP_BOX | 0x0424 | Audio or video STB device. |
+| AUDIO_VIDEO_HIFI_AUDIO | 0x0428 | High-fidelity speaker device. |
+| AUDIO_VIDEO_VCR | 0x042C | Video cassette recording (VCR) device. |
+| AUDIO_VIDEO_VIDEO_CAMERA | 0x0430 | Camera. |
+| AUDIO_VIDEO_CAMCORDER | 0x0434 | Camcorder |
+| AUDIO_VIDEO_VIDEO_MONITOR | 0x0438 | Audio or video monitor. |
+| AUDIO_VIDEO_VIDEO_DISPLAY_AND_LOUDSPEAKER | 0x043C | Video display or loudspeaker. |
+| AUDIO_VIDEO_VIDEO_CONFERENCING | 0x0440 | Video conferencing device. |
+| AUDIO_VIDEO_VIDEO_GAMING_TOY | 0x0448 | Audio or video gaming toy. |
+| PERIPHERAL_NON_KEYBOARD_NON_POINTING | 0x0500 | Non-keyboard or non-pointing peripheral device. |
+| PERIPHERAL_KEYBOARD | 0x0540 | Keyboard device. |
+| PERIPHERAL_POINTING_DEVICE | 0x0580 | Pointing peripheral device. |
+| PERIPHERAL_KEYBOARD_POINTING | 0x05C0 | Keyboard pointing device. |
+| PERIPHERAL_UNCATEGORIZED | 0x0500 | Unclassified peripheral device. |
+| PERIPHERAL_JOYSTICK | 0x0504 | Peripheral joystick. |
+| PERIPHERAL_GAMEPAD | 0x0508 | Peripheral game pad |
+| PERIPHERAL_REMOTE_CONTROL | 0x05C0 | Peripheral remote control device |
+| PERIPHERAL_SENSING_DEVICE | 0x0510 | Peripheral sensing device. |
+| PERIPHERAL_DIGITIZER_TABLET | 0x0514 | Peripheral digitizer tablet.|
+| PERIPHERAL_CARD_READER | 0x0518 | Peripheral card reader. |
+| PERIPHERAL_DIGITAL_PEN | 0x051C | Peripheral digital pen. |
+| PERIPHERAL_SCANNER_RFID | 0x0520 | Peripheral RFID scanner. |
+| PERIPHERAL_GESTURAL_INPUT | 0x0522 | Gesture input device. |
+| IMAGING_UNCATEGORIZED | 0x0600 | Unclassified imaging device. |
+| IMAGING_DISPLAY | 0x0610 | Imaging display device. |
+| IMAGING_CAMERA | 0x0620 | Imaging camera device. |
+| IMAGING_SCANNER | 0x0640 | Imaging scanner. |
+| IMAGING_PRINTER | 0x0680 | Imaging printer. |
+| WEARABLE_UNCATEGORIZED | 0x0700 | Unclassified wearable device. |
+| WEARABLE_WRIST_WATCH | 0x0704 | Smart watch. |
+| WEARABLE_PAGER | 0x0708 | Wearable pager. |
+| WEARABLE_JACKET | 0x070C | Smart jacket. |
+| WEARABLE_HELMET | 0x0710 | Wearable helmet. |
+| WEARABLE_GLASSES | 0x0714 | Wearable glasses. |
+| TOY_UNCATEGORIZED | 0x0800 | Unclassified toy. |
+| TOY_ROBOT | 0x0804 | Toy robot. |
+| TOY_VEHICLE | 0x0808 | Toy vehicle. |
+| TOY_DOLL_ACTION_FIGURE | 0x080C | Humanoid toy doll. |
+| TOY_CONTROLLER | 0x0810 | Toy controller. |
+| TOY_GAME | 0x0814 | Toy gaming device. |
+| HEALTH_UNCATEGORIZED | 0x0900 | Unclassified health devices. |
+| HEALTH_BLOOD_PRESSURE | 0x0904 | Blood pressure device. |
+| HEALTH_THERMOMETER | 0x0908 | Thermometer |
+| HEALTH_WEIGHING | 0x090C | Body scale. |
+| HEALTH_GLUCOSE | 0x0910 | Blood glucose monitor. |
+| HEALTH_PULSE_OXIMETER | 0x0914 | Pulse oximeter. |
+| HEALTH_PULSE_RATE | 0x0918 | Heart rate monitor. |
+| HEALTH_DATA_DISPLAY | 0x091C | Health data display. |
+| HEALTH_STEP_COUNTER | 0x0920 | Step counter. |
+| HEALTH_BODY_COMPOSITION_ANALYZER | 0x0924 | Body composition analyzer. |
+| HEALTH_PEAK_FLOW_MONITOR | 0x0928 | Hygrometer. |
+| HEALTH_MEDICATION_MONITOR | 0x092C | Medication monitor. |
+| HEALTH_KNEE_PROSTHESIS | 0x0930 | Prosthetic knee. |
+| HEALTH_ANKLE_PROSTHESIS | 0x0934 | Prosthetic ankle. |
+| HEALTH_GENERIC_HEALTH_MANAGER | 0x0938 | Generic health management device. |
+| HEALTH_PERSONAL_MOBILITY_DEVICE | 0x093C | Personal mobility device. |
+
+
+## PlayingState
+
+Enumerates the A2DP playing states.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name | Value | Description |
+| ----------------- | ------ | ------- |
+| STATE_NOT_PLAYING | 0x0000 | Not playing. |
+| STATE_PLAYING | 0x0001 | Playing.|
+
+
+## ProfileId
+
+Enumerates the Bluetooth profiles. API version 9 is added with **PROFILE_HID_HOST** and **PROFILE_PAN_NETWORK**.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name | Value | Description |
+| -------------------------------- | ------ | --------------- |
+| PROFILE_A2DP_SOURCE | 1 | A2DP profile.|
+| PROFILE_HANDS_FREE_AUDIO_GATEWAY | 4 | HFP profile. |
+| PROFILE_HID_HOST | 6 | Human Interface Device (HID) profile. |
+| PROFILE_PAN_NETWORK | 7 | PAN profile. |
+
+
+## PinType10+
+
+Enumerates the Bluetooth pairing types.
+
+**System capability**: SystemCapability.Communication.Bluetooth.Core
+
+| Name | Value | Description |
+| -------------------------------- | ------ | --------------- |
+| PIN_TYPE_ENTER_PIN_CODE10+ | 0 | The user needs to enter the PIN displayed on the peer device.|
+| PIN_TYPE_ENTER_PASSKEY10+ | 1 | The user needs to enter the PASSKEY displayed on the peer device. |
+| PIN_TYPE_CONFIRM_PASSKEY10+ | 2 | The user needs to confirm the PASSKEY displayed on the local device. |
+| PIN_TYPE_NO_PASSKEY_CONSENT10+ | 3 | There is no PASSKEY, and the user needs to accept or reject the pairing request. |
+| PIN_TYPE_NOTIFY_PASSKEY10+ | 4 | The user needs to enter the PASSKEY displayed on the local device on the peer device. |
+| PIN_TYPE_DISPLAY_PIN_CODE10+ | 5 | The user needs to enter the PIN displayed on the peer device for Bluetooth 2.0 devices. |
+| PIN_TYPE_OOB_CONSENT10+ | 6 | The user needs to accept or reject the out of band (OOB) pairing request. |
+| PIN_TYPE_PIN_16_DIGITS10+ | 7 | The user needs to enter the 16-digit PIN displayed on the peer device. |
diff --git a/en/application-dev/reference/apis/js-apis-bundle-BundleInstaller.md b/en/application-dev/reference/apis/js-apis-bundle-BundleInstaller.md
index 7523cde56562a53a6129d810dff30ba95a718a64..ff1c5faec320b9c7deb874eee5f8329df524a735 100644
--- a/en/application-dev/reference/apis/js-apis-bundle-BundleInstaller.md
+++ b/en/application-dev/reference/apis/js-apis-bundle-BundleInstaller.md
@@ -160,9 +160,9 @@ bundle.getBundleInstaller().then(installer => {
Describes the parameters required for bundle installation, recovery, or uninstall.
- **System capability**: SystemCapability.BundleManager.BundleFramework
+**System capability**: SystemCapability.BundleManager.BundleFramework
- **System API**: This is a system API and cannot be called by third-party applications.
+**System API**: This is a system API and cannot be called by third-party applications.
| Name | Type | Readable| Writable| Description |
| ----------- | ------- | ---- | ---- | ------------------ |
@@ -174,17 +174,17 @@ Describes the parameters required for bundle installation, recovery, or uninstal
Describes the bundle installation or uninstall status.
- **System capability**: SystemCapability.BundleManager.BundleFramework
+**System capability**: SystemCapability.BundleManager.BundleFramework
- **System API**: This is a system API and cannot be called by third-party applications.
+**System API**: This is a system API and cannot be called by third-party applications.
| Name | Type | Readable| Writable| Description |
| ------------- | ------------------------------------------------------------ | ---- | ---- | ------------------------------ |
-| status | bundle.[InstallErrorCode](js-apis-Bundle.md#installerrorcode) | Yes | No | Installation or uninstall error code. The value must be defined in [InstallErrorCode](js-apis-Bundle.md#installerrorcode). |
+| status | bundle.[InstallErrorCode](js-apis-Bundle.md#installerrorcode) | Yes | No | Installation or uninstall error code. The value must be defined in [InstallErrorCode](js-apis-Bundle.md#installerrorcode)|
| statusMessage | string | Yes | No | Installation or uninstall status message.
**SUCCESS**: install_succeed
**STATUS_INSTALL_FAILURE**: Installation failed (no installation file exists).
**STATUS_INSTALL_FAILURE_ABORTED**: Installation aborted.
**STATUS_INSTALL_FAILURE_INVALID**: Invalid installation parameter.
**STATUS_INSTALL_FAILURE_CONFLICT**: Installation conflict. (The basic information of the application to update is inconsistent with that of the existing application.)
**STATUS_INSTALL_FAILURE_STORAGE**: Failed to store the bundle information.
**STATUS_INSTALL_FAILURE_INCOMPATIBLE**: Installation incompatibility. (A downgrade occurs or the signature information is incorrect.)
**STATUS_UNINSTALL_FAILURE**: Uninstallation failed. (The application to be uninstalled is not found.)
**STATUS_UNINSTALL_FAILURE_ABORTED**: Uninstallation aborted. (This error code is not in use.)
**STATUS_UNINSTALL_FAILURE_ABORTED**: Uninstallation conflict. (Failed to uninstall a system application or end the application process.)
**STATUS_INSTALL_FAILURE_DOWNLOAD_TIMEOUT**: Installation failed. (Download timed out.)
**STATUS_INSTALL_FAILURE_DOWNLOAD_FAILED**: Installation failed. (Download failed.)
**STATUS_RECOVER_FAILURE_INVALID**: Failed to restore the pre-installed application.
**STATUS_ABILITY_NOT_FOUND**: Ability not found.
**STATUS_BMS_SERVICE_ERROR**: BMS service error.
**STATUS_FAILED_NO_SPACE_LEFT**: Insufficient device space.
**STATUS_GRANT_REQUEST_PERMISSIONS_FAILED**: Application authorization failed.
**STATUS_INSTALL_PERMISSION_DENIED**: No installation permission.
**STATUS_UNINSTALL_PERMISSION_DENIED**: No uninstallation permission. |
## Obtaining the Sandbox Path
-For the FA model, the sandbox path of a bundle can be obtained using the APIs in [Context](js-apis-inner-app-context.md). For the stage model, the sandbox path can be obtained using the attribute in [Context](js-apis-ability-context.md#abilitycontext). The following describes how to obtain the sandbox path.
+For the FA model, the sandbox path of a bundle can be obtained using the APIs in [Context](js-apis-inner-app-context.md). For the stage model, the sandbox path can be obtained using the attribute in [Context](js-apis-inner-application-uiAbilityContext.md#abilitycontext). The following describes how to obtain the sandbox path.
**Example**
``` ts
diff --git a/en/application-dev/reference/apis/js-apis-bundleManager-BundlePackInfo.md b/en/application-dev/reference/apis/js-apis-bundleManager-BundlePackInfo.md
index e6fd8bd2c8cd018a0ed0fe0d5cfdb226f542b438..1724888a4d646c1f105fdb9b60ef1be7d098dc3d 100644
--- a/en/application-dev/reference/apis/js-apis-bundleManager-BundlePackInfo.md
+++ b/en/application-dev/reference/apis/js-apis-bundleManager-BundlePackInfo.md
@@ -5,6 +5,8 @@ The **BundlePackInfo** module provides information in the **pack.info** file. Th
> **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 APIs provided by this module are system APIs.
## BundlePackInfo
@@ -63,10 +65,10 @@ The **BundlePackInfo** module provides information in the **pack.info** file. Th
| ------------------ | ------------------------------------------------- | ---- | ---- | ---------------------------------- |
| mainAbility | string | Yes| No| Name of the main ability.|
| apiVersion | [ApiVersion](#apiversion) | Yes | No | API version of the module. |
-| deviceType | Array\ | Yes | No | Device types supported by the module. |
+| deviceTypes | Array\ | Yes | No | Device types supported by the module. |
| distro | [ModuleDistroInfo](#moduledistroinfo) | Yes | No | Distribution information of the module. |
| abilities | Array\<[ModuleAbilityInfo](#moduleabilityinfo)> | Yes | No | Ability information of the module. |
-| extensionAbilities | Array\<[ExtensionAbilities](#extensionability)> | Yes | No | ExtensionAbility information of the module.|
+| extensionAbilities | Array\<[ExtensionAbility](#extensionability)> | Yes | No | ExtensionAbility information of the module.|
## ModuleDistroInfo
@@ -123,7 +125,7 @@ The **BundlePackInfo** module provides information in the **pack.info** file. Th
## ApiVersion
-**System API**: This is a system API and cannot be called by third-party applications.
+**System API**: This is a system API.
**System capability**: SystemCapability.BundleManager.BundleFrameWork.FreeInstall
diff --git a/en/application-dev/reference/apis/js-apis-bundleManager-applicationInfo.md b/en/application-dev/reference/apis/js-apis-bundleManager-applicationInfo.md
index 8997e94099071ce9b4e806f06b008477352af187..3447ba9b6dacd6a5606902caa24269931ff0d09e 100644
--- a/en/application-dev/reference/apis/js-apis-bundleManager-applicationInfo.md
+++ b/en/application-dev/reference/apis/js-apis-bundleManager-applicationInfo.md
@@ -32,3 +32,4 @@ The **ApplicationInfo** module defines the application information. A system app
| appDistributionType | string | Yes | No | Distribution type of the application signing certificate. The options are **app_gallery**, **enterprise**, **os_integration**, and **crowdtesting**. |
| appProvisionType | string | Yes | No | Type of the application signing certificate file. The options are **debug** and **release**. |
| systemApp | boolean | Yes | No | Whether the application is a system application. |
+| bundleType |[BundleType](js-apis-bundleManager.md#bundletype) | Yes | No | Bundle type, which can be **APP** (common application) or **ATOMIC_SERVICE** (atomic service). |
diff --git a/en/application-dev/reference/apis/js-apis-bundleManager-hapModuleInfo.md b/en/application-dev/reference/apis/js-apis-bundleManager-hapModuleInfo.md
index 146e3da56069f96ce10e20a62b9d2474bc51508a..d5962d34571e7c1cafdcb520643c029812603d12 100644
--- a/en/application-dev/reference/apis/js-apis-bundleManager-hapModuleInfo.md
+++ b/en/application-dev/reference/apis/js-apis-bundleManager-hapModuleInfo.md
@@ -26,3 +26,28 @@ The **HapModuleInfo** module defines the HAP module information. A system applic
| deviceTypes | Array\ | Yes | No | Types of devices where the module can run. |
| installationFree | boolean | Yes | No | Whether installation-free is supported. |
| hashValue | string | Yes | No | Hash value of the module. |
+| moduleType | [ModuleType](js-apis-bundleManager.md#moduletype) | Yes | No | Type of the module. |
+| preloads | Array\<[PreloadItem](#preloaditem)> | Yes | No | Preloaded modules in the atomic service.|
+| dependencies | Array\<[Dependency](#dependency)> | Yes | No | Dynamic shared libraries on which the module depends. |
+
+## PreloadItem
+
+Describes the preloaded module information in the atomic service.
+
+ **System capability**: SystemCapability.BundleManager.BundleFramework.Core
+
+| Name | Type | Readable| Writable| Description |
+| --------- | -------------- | ---- | ---- | --------------------------- |
+|moduleName | string | Yes | No | Name of the module automatically preloaded by the system.|
+
+## Dependency
+
+Describes the information about the dynamic shared library on which the module depends.
+
+ **System capability**: SystemCapability.BundleManager.BundleFramework.Core
+
+| Name | Type | Readable| Writable| Description |
+| ----------- | ------ | ---- | ---- | ---------------------- |
+| bundleName | string | Yes | No | Name of the shared bundle on which the current module depends. |
+| moduleName | string | Yes | No | Module name of the shared bundle on which the current module depends.|
+| versionCode | number | Yes | No | Version number of the shared bundle. |
diff --git a/en/application-dev/reference/apis/js-apis-bundleManager-overlayModuleInfo.md b/en/application-dev/reference/apis/js-apis-bundleManager-overlayModuleInfo.md
new file mode 100644
index 0000000000000000000000000000000000000000..5e16b3342c0f6a196c3da5362f950eecacf4c4a5
--- /dev/null
+++ b/en/application-dev/reference/apis/js-apis-bundleManager-overlayModuleInfo.md
@@ -0,0 +1,19 @@
+# OverlayModuleInfo
+
+> **NOTE**
+>
+> The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+
+The **OverlayModuleInfo** module provides information about a module with the overlay feature. A system application can obtain such information of the specified application through [overlay.getOverlayModuleInfoByBundleName](js-apis-overlay.md#overlaygetoverlaymoduleinfobybundlename), and a third-party application can obtain such information of the current application through [overlay.getOverlayModuleInfo](js-apis-overlay.md#overlaygetoverlaymoduleinfo).
+
+## OverlayModuleInfo
+
+ **System capability**: SystemCapability.BundleManager.BundleFramework.Overlay
+
+| Name | Type | Readable| Writable| Description |
+| --------------------- | ---------------------------------------------------| ---- | ---- | ---------------------------------------------- |
+| bundleName | string | Yes | No | Bundle name of the application to which the module with the overlay feature belongs. |
+| moduleName | string | Yes | No | HAP name of the module with the overlay feature. |
+| targetModuleName | string | Yes | No | HAP name of the target module specified by the module with the overlay feature. |
+| priority | number | Yes | No | Priority of the module with the overlay feature. |
+| state | number | Yes | No | Whether the module with the overlay feature is disabled. The value **0** means that the module is disabled, and **1** means the opposite. |
diff --git a/en/application-dev/reference/apis/js-apis-bundleManager-sharedBundleInfo.md b/en/application-dev/reference/apis/js-apis-bundleManager-sharedBundleInfo.md
new file mode 100644
index 0000000000000000000000000000000000000000..ad5ee9f5503d04a49060f69b40f4883a0af0773e
--- /dev/null
+++ b/en/application-dev/reference/apis/js-apis-bundleManager-sharedBundleInfo.md
@@ -0,0 +1,33 @@
+# SharedBundleInfo
+
+The **SharedBundleInfo** module provides information about the shared bundle. The information can be obtained by calling [bundleManager.getSharedBundleInfo](js-apis-bundleManager.md).
+
+> **NOTE**
+>
+> The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+
+## SharedBundleInfo
+
+Defines the shared bundle information.
+
+**System capability**: SystemCapability.BundleManager.BundleFramework.Core
+
+| Name | Type | Readable| Writable| Description |
+| ---------------- | ------------------------------ | ---- | ---- | ---------------------- |
+| name | string | Yes | No | Name of the shared bundle. |
+| compatiblePolicy | bundleManager.CompatiblePolicy | Yes | No | Compatibility type of the shared bundle.|
+| sharedModuleInfo | Array\ | Yes | No | Information about the shared module. |
+
+## SharedModuleInfo
+
+Defines the shared module information.
+
+**System capability**: SystemCapability.BundleManager.BundleFramework.Core
+
+| Name | Type | Readable| Writable| Description |
+| ------------- | ------ | ---- | ---- | -------------------------- |
+| name | string | Yes | No | Module name of the shared bundle. |
+| versionCode | number | Yes | No | Version number of the shared bundle. |
+| versionName | string | Yes | No | Version description of the shared bundle.|
+| description | string | Yes | No | Description of the shared bundle. |
+| descriptionId | number | Yes | No | Description ID of the shared bundle. |
diff --git a/en/application-dev/reference/apis/js-apis-bundleManager.md b/en/application-dev/reference/apis/js-apis-bundleManager.md
index 1503f821c413923f28e11a31a77c5cd2eb07c101..e7d165f90fb2fade864f2e7bf2d5408d6fd190ae 100644
--- a/en/application-dev/reference/apis/js-apis-bundleManager.md
+++ b/en/application-dev/reference/apis/js-apis-bundleManager.md
@@ -49,7 +49,7 @@ Enumerates the application flags, which indicate the type of application informa
**System capability**: SystemCapability.BundleManager.BundleFramework.Core
- **System API**: This is a system API and cannot be called by third-party applications.
+ **System API**: This is a system API.
| Name | Value | Description |
| ------------------------------------ | ---------- | ------------------------------------------------------------ |
@@ -64,7 +64,7 @@ Enumerates the ability flags, which indicate the type of ability information to
**System capability**: SystemCapability.BundleManager.BundleFramework.Core
- **System API**: This is a system API and cannot be called by third-party applications.
+ **System API**: This is a system API.
| Name | Value | Description |
| --------------------------------- | ---------- | ------------------------------------------------------------ |
@@ -81,7 +81,7 @@ Enumerates the Extension ability flags, which indicate the type of Extension abi
**System capability**: SystemCapability.BundleManager.BundleFramework.Core
- **System API**: This is a system API and cannot be called by third-party applications.
+ **System API**: This is a system API.
| Name | Value | Description |
| ------------------------------------------- | ---------- | ------------------------------------------------------------ |
@@ -112,6 +112,7 @@ Enumerates the types of Extension abilities.
| ENTERPRISE_ADMIN | 11 | [EnterpriseAdminExtensionAbility](js-apis-EnterpriseAdminExtensionAbility.md): provides APIs for processing enterprise management events, such as application installation events on devices and events indicating too many incorrect screen-lock password attempts.|
| THUMBNAIL | 13 | ThumbnailExtensionAbility: provides thumbnails for files. This ability is reserved.|
| PREVIEW | 14 | PreviewExtensionAbility: provides APIs for file preview so that other applications can be embedded and displayed in the current application. This ability is reserved.|
+| PRINT10+ | 15 | PrintExtensionAbility: provides APIs for printing images. Printing documents is not supported yet.|
| UNSPECIFIED | 255 | No type is specified. It is used together with **queryExtensionAbilityInfo** to query all types of Extension abilities.|
@@ -186,6 +187,39 @@ Enumerates the display orientations of the ability. This attribute applies only
| AUTO_ROTATION_PORTRAIT_RESTRICTED |11|Switched-determined auto rotation in the vertical direction.|
| LOCKED |12|Locked.|
+### CompatiblePolicy
+
+Defines the version compatibility type of the shared library.
+
+ **System capability**: SystemCapability.BundleManager.BundleFramework.Core
+
+| Name | Value | Description |
+| ---------------------- | ---- | -------------------------------- |
+| BACKWARD_COMPATIBILITY | 1 | The shared library is backward compatible.|
+
+### ModuleType
+
+Enumerates the module types.
+
+ **System capability**: SystemCapability.BundleManager.BundleFramework.Core
+
+| Name | Value | Description |
+| ------- | ---- | -------------------- |
+| ENTRY | 1 | Main module of the application. |
+| FEATURE | 2 | Dynamic feature module of the application.|
+| SHARED | 3 | Dynamic shared library module of the application. |
+
+### BundleType
+
+Enumerates the bundle types.
+
+ **System capability**: SystemCapability.BundleManager.BundleFramework.Core
+
+| Name | Value | Description |
+| -------------- | ---- | --------------- |
+| APP | 0 | The bundle is a common application. |
+| ATOMIC_SERVICE | 1 | The bundle is an atomic service.|
+
## APIs
### bundleManager.getBundleInfoForSelf
@@ -1076,7 +1110,7 @@ For details about the error codes, see [Bundle Error Codes](../errorcodes/errorc
| ID| Error Message |
| -------- | ------------------------------------- |
| 17700001 | The specified bundleName is not found. |
-| 17700003 | The specified extensionAbility is not found. |
+| 17700003 | The specified ability is not found. |
| 17700004 | The specified userId is invalid. |
| 17700026 | The specified bundle is disabled. |
| 17700029 | The specified ability is disabled. |
@@ -2861,36 +2895,177 @@ try {
}
```
-## ModuleType
+### bundleManager.getSharedBundleInfo10+
-Enumerates the module types.
+getSharedBundleInfo(bundleName: string, moduleName: string, callback: AsyncCallback\\>): void;
- **System capability**: SystemCapability.BundleManager.BundleFramework.Core
+Obtains the shared bundle information based on the given bundle name. This API uses an asynchronous callback to return the result.
-| Name | Value | Description |
-| ------- | ---- | -------------------- |
-| ENTRY | 1 | Main module of the application. |
-| FEATURE | 2 | Dynamic feature module of the application.|
-| SHARED | 3 | Dynamic shared library module of the application. |
+**System API**: This is a system API.
-## BundleType
+**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
-Enumerates the bundle types.
+**System capability**: SystemCapability.BundleManager.BundleFramework.Core
- **System capability**: SystemCapability.BundleManager.BundleFramework.Core
+**Parameters**
-| Name | Value | Description |
-| -------------- | ---- | --------------- |
-| APP | 0 | The bundle is a common application. |
-| ATOMIC_SERVICE | 1 | The bundle is an atomic service.|
+| Name | Type | Mandatory| Description |
+| ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
+| bundleName | string | Yes | Bundle name. |
+| moduleName | string | Yes | Module name. |
+| callback | AsyncCallback\\> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null** and **data** is the shared bundle information obtained.|
-## AtomicServiceModuleType
+**Error codes**
-Enumerates the module types of an atomic service.
+For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
- **System capability**: SystemCapability.BundleManager.BundleFramework.Core
+| ID| Error Message |
+| -------- | -------------------------------------- |
+| 17700001 | The specified bundleName is not found. |
+| 17700002 | The specified moduleName is not found. |
+
+**Example**
+
+```ts
+import bundleManager from '@ohos.bundle.bundleManager';
+import hilog from '@ohos.hilog';
+let bundleName = 'com.example.myapplication';
+let moduleName = 'library';
+
+try {
+ bundleManager.getSharedBundleInfo(bundleName, moduleName, (err, data) => {
+ if (err) {
+ hilog.error(0x0000, 'testTag', 'getSharedBundleInfo failed: %{public}s', err.message);
+ } else {
+ hilog.info(0x0000, 'testTag', 'getSharedBundleInfo successfully: %{public}s', JSON.stringify(data));
+ }
+ });
+} catch (err) {
+ hilog.error(0x0000, 'testTag', 'getSharedBundleInfo failed: %{public}s', err.message);
+}
+```
+
+### bundleManager.getSharedBundleInfo10+
+
+function getSharedBundleInfo(bundleName: string, moduleName: string): Promise\\>;
+
+Obtains the shared bundle information based on the given bundle name. This API uses a promise to return the result.
+
+**System API**: This is a system API.
+
+**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
+
+**System capability**: SystemCapability.BundleManager.BundleFramework.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ---------- | ------ | ---- | -------------------------- |
+| bundleName | string | Yes | Bundle name.|
+| moduleName | string | Yes | Module name.|
+
+**Return value**
+
+| Type | Description |
+| ------------------------------------------------------------ | ----------------------------------- |
+| Promise\\> | Promise used to return the shared bundle information obtained.|
+
+**Error codes**
+
+For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------- |
+| 17700001 | The specified bundleName is not found. |
+| 17700002 | The specified moduleName is not found. |
+
+**Example**
+
+```ts
+import bundleManager from '@ohos.bundle.bundleManager';
+import hilog from '@ohos.hilog';
+let bundleName = 'com.example.myapplication';
+let moduleName = 'library';
-| Name | Value | Description |
-| ------ | ---- | --------------------------- |
-| NORMAL | 0 | Page package in the atomic service. |
-| MAIN | 1 | Landing page package in the atomic service.|
+try {
+ bundleManager.getSharedBundleInfo(bundleName, moduleName).then((data) => {
+ hilog.info(0x0000, 'testTag', 'getSharedBundleInfo successfully. Data: %{public}s', JSON.stringify(data));
+ }).catch(err => {
+ hilog.error(0x0000, 'testTag', 'getSharedBundleInfo failed. Cause: %{public}s', err.message);
+ });
+} catch (err) {
+ hilog.error(0x0000, 'testTag', 'getSharedBundleInfo failed. Cause: %{public}s', err.message);
+}
+```
+
+### bundleManager.getAllSharedBundleInfo10+
+
+getAllSharedBundleInfo(callback: AsyncCallback\\>): void;
+
+Obtains the information about all shared bundles. This API uses an asynchronous callback to return the result.
+
+**System API**: This is a system API.
+
+**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
+
+**System capability**: SystemCapability.BundleManager.BundleFramework.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
+| callback | AsyncCallback\\> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null** and **data** is an array of the shared bundle information obtained.|
+
+**Example**
+
+```ts
+import bundleManager from '@ohos.bundle.bundleManager';
+import hilog from '@ohos.hilog';
+
+try {
+ bundleManager.getAllSharedBundleInfo((err, data) => {
+ if (err) {
+ hilog.error(0x0000, 'testTag', 'getAllSharedBundleInfo failed: %{public}s', err.message);
+ } else {
+ hilog.info(0x0000, 'testTag', 'getAllSharedBundleInfo successfully: %{public}s', JSON.stringify(data));
+ }
+ });
+} catch (err) {
+ hilog.error(0x0000, 'testTag', 'getAllSharedBundleInfo failed: %{public}s', err.message);
+}
+```
+
+### bundleManager.getAllSharedBundleInfo10+
+
+function getAllSharedBundleInfo(): Promise\\>;
+
+Obtains the information about all shared bundles. This API uses a promise to return the result.
+
+**System API**: This is a system API.
+
+**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
+
+**System capability**: SystemCapability.BundleManager.BundleFramework.Core
+
+**Return value**
+
+| Type | Description |
+| ------------------------------------------------------------ | ----------------------------------- |
+| Promise\\> | Promise used to return an array of the shared bundle information obtained.|
+
+**Example**
+
+```ts
+import bundleManager from '@ohos.bundle.bundleManager';
+import hilog from '@ohos.hilog';
+
+try {
+ bundleManager.getAllSharedBundleInfo().then((data) => {
+ hilog.info(0x0000, 'testTag', 'getAllSharedBundleInfo successfully. Data: %{public}s', JSON.stringify(data));
+ }).catch(err => {
+ hilog.error(0x0000, 'testTag', 'getAllSharedBundleInfo failed. Cause: %{public}s', err.message);
+ });
+} catch (err) {
+ hilog.error(0x0000, 'testTag', 'getAllSharedBundleInfo failed. Cause: %{public}s', err.message);
+}
+```
diff --git a/en/application-dev/reference/apis/js-apis-call.md b/en/application-dev/reference/apis/js-apis-call.md
index 6b6222abe96a415e28290892f8e6a215c1e98478..068a12cd46efce13b68a4fcf697306c4b5d8f256 100644
--- a/en/application-dev/reference/apis/js-apis-call.md
+++ b/en/application-dev/reference/apis/js-apis-call.md
@@ -14,12 +14,14 @@ To subscribe to the call status, use [`observer.on('callStateChange')`](js-apis-
import call from '@ohos.telephony.call';
```
-## call.dial(deprecated)
+## call.dialCall9+
-dial\(phoneNumber: string, callback: AsyncCallback\): void
+dialCall\(phoneNumber: string, callback: AsyncCallback\): void
Initiates a call. This API uses an asynchronous callback to return the result.
+**System API**: This is a system API.
+
**Required Permissions**: ohos.permission.PLACE_CALL
**System capability**: SystemCapability.Telephony.CallManager
@@ -27,92 +29,142 @@ Initiates a call. This API uses an asynchronous callback to return the result.
**Parameters**
| Name | Type | Mandatory| Description |
-| ----------- | ---------------------------- | ---- | --------------------------------------- |
+| ----------- | ---------------------------- | ---- | -------------------------------------- |
| phoneNumber | string | Yes | Phone number. |
-| callback | AsyncCallback<boolean> | Yes | Callback used to return the result.
- **true**: success
- **false**: failure|
+| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
+
+**Error codes**
+
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
**Example**
```js
-call.dial("138xxxxxxxx", (err, data) => {
- console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
+call.dialCall("138xxxxxxxx", (err) => {
+ console.log(`callback: err->${JSON.stringify(err)}`);
});
```
-## call.dial(deprecated)
+## call.dialCall9+
-dial\(phoneNumber: string, options: DialOptions, callback: AsyncCallback\): void
+dialCall\(phoneNumber: string, options: DialCallOptions, callback: AsyncCallback\): void
Initiates a call. You can set call options as needed. This API uses an asynchronous callback to return the result.
+**System API**: This is a system API.
+
**Required Permissions**: ohos.permission.PLACE_CALL
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
-| Name | Type | Mandatory| Description |
-| ----------- | ---------------------------- | ---- | --------------------------------------- |
-| phoneNumber | string | Yes | Phone number. |
-| options | [DialOptions](#dialoptions) | Yes | Call option, which indicates whether the call is a voice call or video call. |
-| callback | AsyncCallback<boolean> | Yes | Callback used to return the result.
- **true**: success
- **false**: failure|
+| Name | Type | Mandatory| Description |
+| ----------- | ----------------------------------- | ---- | ----------------------------------- |
+| phoneNumber | string | Yes | Phone number. |
+| options | [DialCallOptions](#dialcalloptions9)| Yes | Call options, which carry other configuration information of the call. |
+| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
+
+**Error codes**
+
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
**Example**
```js
-call.dial("138xxxxxxxx", {
- extras: false
-}, (err, data) => {
- console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
+call.dialCall("138xxxxxxxx", {
+ accountId: 0,
+ videoState: 0,
+ dialScene: 0,
+ dialType: 0,
+}, (err) => {
+ console.log(`callback: err->${JSON.stringify(err)}`);
});
```
-## call.dial(deprecated)
+## call.dialCall9+
-dial\(phoneNumber: string, options?: DialOptions\): Promise
+dialCall\(phoneNumber: string, options?: DialCallOptions\): Promise
Initiates a call. You can set call options as needed. This API uses a promise to return the result.
+**System API**: This is a system API.
+
**Required Permissions**: ohos.permission.PLACE_CALL
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
-| Name | Type | Mandatory| Description |
-| ----------- | --------------------------- | ---- | -------------------------------------- |
-| phoneNumber | string | Yes | Phone number. |
-| options | [DialOptions](#dialoptions) | No | Call option, which indicates whether the call is a voice call or video call.|
+| Name | Type | Mandatory| Description |
+| ----------- | ----------------------------------- | ---- | -------------------------------------- |
+| phoneNumber | string | Yes | Phone number. |
+| options | [DialCallOptions](#dialcalloptions9)| No | Call options, which carry other configuration information of the call.|
**Return value**
-| Type | Description |
-| ---------------------- | ------------------------------------------------------------ |
-| Promise<boolean> | Promise used to return the result.
- **true**: success
- **false**: failure|
+| Type | Description |
+| ---------------------- | ---------------------------- |
+| Promise<void> | Promise used to return the result.|
+
+**Error codes**
+
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
**Example**
```js
-let promise = call.dial("138xxxxxxxx", {
- extras: false
+let promise = call.dialCall("138xxxxxxxx", {
+ accountId: 0,
+ videoState: 0,
+ dialScene: 0,
+ dialType: 0,
});
-promise.then(data => {
- console.log(`dial success, promise: data->${JSON.stringify(data)}`);
-}).catch(err => {
- console.error(`dial fail, promise: err->${JSON.stringify(err)}`);
+promise.then(() => {
+ console.log(`dialCall success.`);
+}).catch((err) => {
+ console.error(`dialCall fail, promise: err->${JSON.stringify(err)}`);
});
```
+## call.dial(deprecated)
-## call.dialCall9+
-
-dialCall\(phoneNumber: string, callback: AsyncCallback\): void
+dial\(phoneNumber: string, callback: AsyncCallback\): void
Initiates a call. This API uses an asynchronous callback to return the result.
-**System API**: This is a system API.
+> **NOTE**
+>
+> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [dialCall](#calldialcall9). The substitute API is available only for system applications.
**Required Permissions**: ohos.permission.PLACE_CALL
@@ -123,36 +175,26 @@ Initiates a call. This API uses an asynchronous callback to return the result.
| Name | Type | Mandatory| Description |
| ----------- | ---------------------------- | ---- | --------------------------------------- |
| phoneNumber | string | Yes | Phone number. |
-| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
-
-**Error codes**
-For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
-
-| ID| Error Message |
-| -------- | -------------------------------------------- |
-| 201 | Permission denied. |
-| 401 | Parameter error. |
-| 8300001 | Invalid parameter value. |
-| 8300002 | Operation failed. Cannot connect to service. |
-| 8300003 | System internal error. |
-| 8300999 | Unknown error code. |
+| callback | AsyncCallback<boolean> | Yes | Callback used to return the result.
- **true**: success
- **false**: failure|
**Example**
```js
-call.dialCall("138xxxxxxxx", (err, data) => {
+call.dial("138xxxxxxxx", (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
-## call.dialCall9+
+## call.dial(deprecated)
-dialCall\(phoneNumber: string, options: DialCallOptions, callback: AsyncCallback\): void
+dial\(phoneNumber: string, options: DialOptions, callback: AsyncCallback\): void
Initiates a call. You can set call options as needed. This API uses an asynchronous callback to return the result.
-**System API**: This is a system API.
+> **NOTE**
+>
+> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [dialCall](#calldialcall9). The substitute API is available only for system applications.
**Required Permissions**: ohos.permission.PLACE_CALL
@@ -160,45 +202,31 @@ Initiates a call. You can set call options as needed. This API uses an asynchron
**Parameters**
-| Name | Type | Mandatory| Description |
-| ----------- | ----------------------------------- | ---- | ------------------------------------ |
-| phoneNumber | string | Yes | Phone number. |
-| options | [DialCallOptions](#dialcalloptions9)| Yes | Call options, which carry other configuration information of the call. |
-| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
-
-**Error codes**
-For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
-
-| ID| Error Message |
-| -------- | -------------------------------------------- |
-| 201 | Permission denied. |
-| 401 | Parameter error. |
-| 8300001 | Invalid parameter value. |
-| 8300002 | Operation failed. Cannot connect to service. |
-| 8300003 | System internal error. |
-| 8300999 | Unknown error code. |
+| Name | Type | Mandatory| Description |
+| ----------- | ---------------------------- | ---- | --------------------------------------- |
+| phoneNumber | string | Yes | Phone number. |
+| options | [DialOptions](#dialoptions) | Yes | Call option, which indicates whether the call is a voice call or video call. |
+| callback | AsyncCallback<boolean> | Yes | Callback used to return the result.
- **true**: success
- **false**: failure|
**Example**
```js
-call.dialCall("138xxxxxxxx", {
- accountId: 0,
- videoState: 0,
- dialScene: 0,
- dialType: 0,
+call.dial("138xxxxxxxx", {
+ extras: false
}, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
+## call.dial(deprecated)
-## call.dialCall9+
-
-dialCall\(phoneNumber: string, options?: DialCallOptions\): Promise
+dial\(phoneNumber: string, options?: DialOptions\): Promise
Initiates a call. You can set call options as needed. This API uses a promise to return the result.
-**System API**: This is a system API.
+> **NOTE**
+>
+> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [dialCall](#calldialcall9). The substitute API is available only for system applications.
**Required Permissions**: ohos.permission.PLACE_CALL
@@ -206,41 +234,30 @@ Initiates a call. You can set call options as needed. This API uses a promise to
**Parameters**
-| Name | Type | Mandatory| Description |
-| ----------- | ----------------------------------- | ---- | -------------------------------------- |
-| phoneNumber | string | Yes | Phone number. |
-| options | [DialCallOptions](#dialcalloptions9)| No | Call option, which indicates whether the call is a voice call or video call.|
+| Name | Type | Mandatory| Description |
+| ----------- | --------------------------- | ---- | -------------------------------------- |
+| phoneNumber | string | Yes | Phone number. |
+| options | [DialOptions](#dialoptions) | No | Call option, which indicates whether the call is a voice call or video call.|
**Return value**
| Type | Description |
| ---------------------- | ------------------------------------------------------------ |
-| Promise<void> | Promise used to return the result. |
-
-**Error codes**
-For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
-
-| ID| Error Message |
-| -------- | -------------------------------------------- |
-| 201 | Permission denied. |
-| 401 | Parameter error. |
-| 8300001 | Invalid parameter value. |
-| 8300002 | Operation failed. Cannot connect to service. |
-| 8300003 | System internal error. |
-| 8300999 | Unknown error code. |
+| Promise<boolean> | Promise used to return the result.
- **true**: success
- **false**: failure|
**Example**
```js
-try {
- call.dialCall('138xxxxxxxx');
- console.log(`dialCall success, promise: data->${JSON.stringify(data)}`);
-} catch (error) {
- console.log(`dialCall fail, promise: err->${JSON.stringify(error)}`);
-}
+let promise = call.dial("138xxxxxxxx", {
+ extras: false
+});
+promise.then(data => {
+ console.log(`dial success, promise: data->${JSON.stringify(data)}`);
+}).catch(err => {
+ console.error(`dial fail, promise: err->${JSON.stringify(err)}`);
+});
```
-
## call.makeCall7+
makeCall(phoneNumber: string, callback: AsyncCallback\): void
@@ -257,6 +274,7 @@ Launches the call screen and displays the dialed number. This API uses an asynch
| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -297,6 +315,7 @@ Launches the call screen and displays the dialed number. This API uses a promise
| Promise<void> | Promise used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -450,6 +469,7 @@ Checks whether the called number is an emergency number. This API uses an asynch
| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. - **true**: The called number is an emergency number.
- **false**: The called number is not an emergency number.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -486,6 +506,7 @@ Checks whether the called number is an emergency number based on the phone numbe
| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. - **true**: The called number is an emergency number.
- **false**: The called number is not an emergency number.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -527,6 +548,7 @@ Checks whether the called number is an emergency number based on the phone numbe
| Promise<boolean> | Promise used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -566,6 +588,7 @@ A formatted phone number is a standard numeric string, for example, 555 0100.
| callback | AsyncCallback<string> | Yes | Callback used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -603,6 +626,7 @@ A formatted phone number is a standard numeric string, for example, 555 0100.
| callback | AsyncCallback<string> | Yes | Callback used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -648,6 +672,7 @@ A formatted phone number is a standard numeric string, for example, 555 0100.
| Promise<string> | Promise used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -690,6 +715,7 @@ The phone number must match the specified country code. For example, for a China
| callback | AsyncCallback<string> | Yes | Callback used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -735,6 +761,7 @@ All country codes are supported.
| Promise<string> | Promise used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -775,10 +802,12 @@ Mutes the ringtone while it is playing. It does not work if the ringtone has bee
| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
@@ -788,8 +817,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example**
```js
-call.muteRinger((err, data) => {
- console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
+call.muteRinger((err) => {
+ console.log(`callback: err->${JSON.stringify(err)}`);
});
```
@@ -813,13 +842,12 @@ Mutes the ringtone while it is playing. It does not work if the ringtone has bee
| Promise<void> | Promise used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
| -------- | -------------------------------------------- |
| 201 | Permission denied. |
-| 401 | Parameter error. |
-| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300999 | Unknown error code. |
@@ -827,16 +855,15 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example**
```js
-let promise = call.muteRinger();
-promise.then(data => {
- console.log(`muteRinger success, promise: data->${JSON.stringify(data)}`);
-}).catch(err => {
+call.muteRinger().then(() => {
+ console.log(`muteRinger success.`);
+}).catch((err) => {
console.error(`muteRinger fail, promise: err->${JSON.stringify(err)}`);
});
```
-## call.answerCall7+
+## call.answerCall9+
answerCall\(callId: number, callback: AsyncCallback\): void
@@ -856,6 +883,7 @@ Answers a call. This API uses an asynchronous callback to return the result.
| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -870,13 +898,13 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example**
```js
-call.answerCall(1, (err, data) => {
- console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
+call.answerCall(1, (err) => {
+ console.log(`callback: err->${JSON.stringify(err)}`);
});
```
-## call.answerCall7+
+## call.answerCall9+
answerCall(callId?: number\): Promise
@@ -901,6 +929,7 @@ Answers a call. This API uses a promise to return the result.
| Promise<void> | Promise used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -915,10 +944,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example**
```js
-let promise = call.answerCall(1);
-promise.then(data => {
- console.log(`answerCall success, promise: data->${JSON.stringify(data)}`);
-}).catch(err => {
+call.answerCall(1).then(() => {
+ console.log(`answerCall success.`);
+}).catch((err) => {
console.error(`answerCall fail, promise: err->${JSON.stringify(err)}`);
});
```
@@ -943,6 +971,7 @@ Answers a call. This API uses an asynchronous callback to return the result.
| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -957,13 +986,13 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example**
```js
-call.answerCall((err, data) => {
- console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
+call.answerCall((err) => {
+ console.log(`callback: err->${JSON.stringify(err)}`);
});
```
-## call.hangUpCall7+
+## call.hangUpCall9+
hangUpCall\(callId: number, callback: AsyncCallback\): void
@@ -983,6 +1012,7 @@ Ends a call. This API uses an asynchronous callback to return the result.
| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -997,13 +1027,13 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example**
```js
-call.hangUpCall(1, (err, data) => {
- console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
+call.hangUpCall(1, (err) => {
+ console.log(`callback: err->${JSON.stringify(err)}`);
});
```
-## call.hangUpCall7+
+## call.hangUpCall9+
hangUpCall\(callId?: number\): Promise
@@ -1028,6 +1058,7 @@ Ends a call. This API uses a promise to return the result.
| Promise<void> | Promise used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -1042,10 +1073,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example**
```js
-let promise = call.hangUpCall(1);
-promise.then(data => {
- console.log(`hangUpCall success, promise: data->${JSON.stringify(data)}`);
-}).catch(err => {
+call.hangUpCall(1).then(() => {
+ console.log(`hangUpCall success.`);
+}).catch((err) => {
console.error(`hangUpCall fail, promise: err->${JSON.stringify(err)}`);
});
```
@@ -1070,6 +1100,7 @@ Ends a call. This API uses an asynchronous callback to return the result.
| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -1085,13 +1116,13 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example**
```js
-call.hangUpCall((err, data) => {
- console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
+call.hangUpCall((err) => {
+ console.log(`callback: err->${JSON.stringify(err)}`);
});
```
-## call.rejectCall7+
+## call.rejectCall9+
rejectCall(callId: number, callback: AsyncCallback\): void
@@ -1111,6 +1142,7 @@ Rejects a call. This API uses an asynchronous callback to return the result.
| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -1126,13 +1158,13 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example**
```js
-call.rejectCall(1, (err, data) => {
- console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
+call.rejectCall(1, (err) => {
+ console.log(`callback: err->${JSON.stringify(err)}`);
});
```
-## call.rejectCall7+
+## call.rejectCall9+
rejectCall\(callId: number, options: RejectMessageOptions, callback: AsyncCallback\): void
@@ -1153,6 +1185,7 @@ Rejects a call. This API uses an asynchronous callback to return the result.
| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -1170,13 +1203,13 @@ For details about the following error codes, see [Telephony Error Codes](../../r
let rejectMessageOptions={
messageContent: "Unknown number blocked"
}
-call.rejectCall(1, rejectMessageOptions, (err, data) => {
- console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
+call.rejectCall(1, rejectMessageOptions, (err) => {
+ console.log(`callback: err->${JSON.stringify(err)}`);
});
```
-## call.rejectCall7+
+## call.rejectCall9+
rejectCall(callId?: number, options?: RejectMessageOptions\): Promise
@@ -1202,6 +1235,7 @@ Rejects a call. This API uses a promise to return the result.
| Promise<void> | Promise used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -1219,11 +1253,10 @@ For details about the following error codes, see [Telephony Error Codes](../../r
let rejectMessageOptions={
messageContent: "Unknown number blocked"
}
-let promise = call.rejectCall(1, rejectMessageOptions);
-promise.then(data => {
- console.log(`rejectCall success, promise: data->${JSON.stringify(data)}`);
-}).catch(err => {
- console.error(`rejectCall fail, promise: err->${JSON.stringify(err)}`);
+call.reject(1, rejectMessageOptions).then(() => {
+ console.log(`reject success.`);
+}).catch((err) => {
+ console.error(`reject fail, promise: err->${JSON.stringify(err)}`);
});
```
@@ -1247,6 +1280,7 @@ Rejects a call. This API uses an asynchronous callback to return the result.
| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -1261,8 +1295,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example**
```js
-call.rejectCall((err, data) => {
- console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
+call.rejectCall((err) => {
+ console.log(`callback: err->${JSON.stringify(err)}`);
});
```
@@ -1287,6 +1321,7 @@ Rejects a call. This API uses an asynchronous callback to return the result.
| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -1304,8 +1339,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r
let rejectMessageOptions={
messageContent: "Unknown number blocked"
}
-call.rejectCall(rejectMessageOptions, (err, data) => {
- console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
+call.rejectCall(rejectMessageOptions, (err) => {
+ console.log(`callback: err->${JSON.stringify(err)}`);
});
```
@@ -1330,6 +1365,7 @@ Holds a call based on the specified call ID. This API uses an asynchronous callb
| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -1344,8 +1380,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example**
```js
-call.holdCall(1, (err, data) => {
- console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
+call.holdCall(1, (err) => {
+ console.log(`callback: err->${JSON.stringify(err)}`);
});
```
@@ -1375,6 +1411,7 @@ Holds a call based on the specified call ID. This API uses a promise to return t
| Promise<void> | Promise used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -1389,10 +1426,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example**
```js
-let promise = call.holdCall(1);
-promise.then(data => {
- console.log(`holdCall success, promise: data->${JSON.stringify(data)}`);
-}).catch(err => {
+call.holdCall(1).then(() => {
+ console.log(`holdCall success.`);
+}).catch((err) => {
console.error(`holdCall fail, promise: err->${JSON.stringify(err)}`);
});
```
@@ -1417,6 +1453,7 @@ Unholds a call based on the specified call ID. This API uses an asynchronous cal
| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -1431,8 +1468,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example**
```js
-call.unHoldCall(1, (err, data) => {
- console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
+call.unHoldCall(1, (err) => {
+ console.log(`callback: err->${JSON.stringify(err)}`);
});
```
@@ -1462,6 +1499,7 @@ Unholds a call based on the specified call ID. This API uses a promise to return
| Promise<void> | Promise used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -1476,10 +1514,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example**
```js
-let promise = call.unHoldCall(1);
-promise.then(data => {
- console.log(`unHoldCall success, promise: data->${JSON.stringify(data)}`);
-}).catch(err => {
+call.unHoldCall(1).then(() => {
+ console.log(`unHoldCall success.`);
+}).catch((err) => {
console.error(`unHoldCall fail, promise: err->${JSON.stringify(err)}`);
});
```
@@ -1504,6 +1541,7 @@ Switches a call. This API uses an asynchronous callback to return the result.
| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -1518,8 +1556,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example**
```js
-call.switchCall(1, (err, data) => {
- console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
+call.switchCall(1, (err) => {
+ console.log(`callback: err->${JSON.stringify(err)}`);
});
```
@@ -1549,6 +1587,7 @@ Switches a call. This API uses a promise to return the result.
| Promise<void> | Promise used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -1563,10 +1602,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example**
```js
-let promise = call.switchCall(1);
-promise.then(data => {
- console.log(`switchCall success, promise: data->${JSON.stringify(data)}`);
-}).catch(err => {
+call.switchCall(1).then(() => {
+ console.log(`switchCall success.`);
+}).catch((err) => {
console.error(`switchCall fail, promise: err->${JSON.stringify(err)}`);
});
```
@@ -1589,6 +1627,7 @@ Combines two calls into a conference call. This API uses an asynchronous callbac
| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -1602,8 +1641,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example**
```js
-call.combineConference(1, (err, data) => {
- console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
+call.combineConference(1, (err) => {
+ console.log(`callback: err->${JSON.stringify(err)}`);
});
```
@@ -1631,6 +1670,7 @@ Combines two calls into a conference call. This API uses a promise to return the
| Promise<void> | Promise used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -1644,10 +1684,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example**
```js
-let promise = call.combineConference(1);
-promise.then(data => {
- console.log(`combineConference success, promise: data->${JSON.stringify(data)}`);
-}).catch(err => {
+call.combineConference(1).then(() => {
+ console.log(`combineConference success.`);
+}).catch((err) => {
console.error(`combineConference fail, promise: err->${JSON.stringify(err)}`);
});
```
@@ -1670,6 +1709,7 @@ Obtains the main call ID. This API uses an asynchronous callback to return the r
| callback | AsyncCallback<number> | Yes | Callback used to return the result. |
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -1713,6 +1753,7 @@ Obtains the main call ID. This API uses a promise to return the result.
| Promise<void> | Promise used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -1752,6 +1793,7 @@ Obtains the list of subcall IDs. This API uses an asynchronous callback to retur
| callback | AsyncCallback\> | Yes | Callback used to return the result. |
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -1794,6 +1836,7 @@ Obtains the list of subcall IDs. This API uses a promise to return the result.
| Promise<Array> | Promise used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -1833,6 +1876,7 @@ Obtains the list of call IDs in a conference. This API uses an asynchronous call
| callback | AsyncCallback<Array> | Yes | Callback used to return the result. |
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -1875,6 +1919,7 @@ Obtains the list of call IDs in a conference. This API uses a promise to return
| Promise<Array> | Promise used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -1916,6 +1961,7 @@ Obtains the call waiting status. This API uses an asynchronous callback to retur
| callback | AsyncCallback<[CallWaitingStatus](#callwaitingstatus7)\> | Yes | Callback used to return the result.
- **0**: Call waiting is disabled.
- **1**: Call waiting is enabled.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -1961,6 +2007,7 @@ Obtains the call waiting status. This API uses a promise to return the result.
| Promise<[CallWaitingStatus](#callwaitingstatus7)> | Promise used to return the result.
- **0**: Call waiting is disabled.
- **1**: Call waiting is enabled.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -2004,6 +2051,7 @@ Sets the call waiting switch. This API uses an asynchronous callback to return t
| callback | AsyncCallback | Yes | Callback used to return the result. |
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -2018,8 +2066,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example**
```js
-call.setCallWaiting(0, true, (err, data) => {
- console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
+call.setCallWaiting(0, true, (err) => {
+ console.log(`callback: err->${JSON.stringify(err)}`);
});
```
@@ -2050,6 +2098,7 @@ Sets the call waiting switch. This API uses a promise to return the result.
| Promise<void> | Promise used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -2064,10 +2113,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example**
```js
-let promise = call.setCallWaiting(0, true);
-promise.then(data => {
- console.log(`setCallWaiting success, promise: data->${JSON.stringify(data)}`);
-}).catch(err => {
+call.setCallWaiting(0, true).then(() => {
+ console.log(`setCallWaiting success.`);
+}).catch((err) => {
console.error(`setCallWaiting fail, promise: err->${JSON.stringify(err)}`);
});
```
@@ -2091,6 +2139,7 @@ Enables DTMF. This API uses an asynchronous callback to return the result.
| callback | AsyncCallback | Yes | Callback used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -2104,8 +2153,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example**
```js
-call.startDTMF(1, "0", (err, data) => {
- console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
+call.startDTMF(1, "0", (err) => {
+ console.log(`callback: err->${JSON.stringify(err)}`);
});
```
@@ -2134,6 +2183,7 @@ Enables DTMF. This API uses a promise to return the result.
| Promise<void> | Promise used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -2147,10 +2197,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example**
```js
-let promise = call.startDTMF(1, "0");
-promise.then(data => {
- console.log(`startDTMF success, promise: data->${JSON.stringify(data)}`);
-}).catch(err => {
+call.startDTMF(1, "0").then(() => {
+ console.log(`startDTMF success.`);
+}).catch((err) => {
console.error(`startDTMF fail, promise: err->${JSON.stringify(err)}`);
});
```
@@ -2173,6 +2222,7 @@ Stops DTMF. This API uses an asynchronous callback to return the result.
| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -2186,8 +2236,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example**
```js
-call.stopDTMF(1, (err, data) => {
- console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
+call.stopDTMF(1, (err) => {
+ console.log(`callback: err->${JSON.stringify(err)}`);
});
```
@@ -2215,6 +2265,7 @@ Stops DTMF. This API uses a promise to return the result.
| Promise<void> | Promise used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -2228,10 +2279,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example**
```js
-let promise = call.stopDTMF(1);
-promise.then(data => {
- console.log(`stopDTMF success, promise: data->${JSON.stringify(data)}`);
-}).catch(err => {
+call.stopDTMF(1).then(() => {
+ console.log(`stopDTMF success.`);
+}).catch((err) => {
console.error(`stopDTMF fail, promise: err->${JSON.stringify(err)}`);
});
```
@@ -2255,6 +2305,7 @@ Checks whether a call is an emergency call. This API uses an asynchronous callba
| callback | AsyncCallback<boolean> | Yes | Callback used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -2294,6 +2345,7 @@ Checks whether a call is an emergency call. This API uses a promise to return th
| Promise<boolean> | Promise used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -2332,10 +2384,11 @@ Subscribes to **callDetailsChange** events. This API uses an asynchronous callba
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------- | ---- | -------------------------- |
-| type | string | Yes | Call details change during a call.|
-| callback | Callback<[CallAttributeOptions](#callattributeoptions7)> | Yes | Callback used to return the result. |
+| type | string | Yes | Call event change. This field has a fixed value of **callDetailsChange**.|
+| callback | Callback<[CallAttributeOptions](#callattributeoptions7)> | Yes | Callback used to return the result. |
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -2371,10 +2424,11 @@ Subscribes to **callEventChange** events. This API uses an asynchronous callback
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------ | ---- | -------------------------- |
-| type | string | Yes | Call event change during a call.|
+| type | string | Yes | Call event change. This field has a fixed value of **callEventChange**.|
| callback | Callback<[CallEventOptions](#calleventoptions8)> | Yes | Callback used to return the result. |
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -2410,10 +2464,11 @@ Subscribes to **callDisconnectedCause** events. This API uses an asynchronous ca
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------ | ---- | -------------------------- |
-| type | string | Yes | Cause of the call disconnection.|
+| type | string | Yes | Call disconnection cause. This field has a fixed value of **callDisconnectedCause**.|
| callback | Callback<[DisconnectedDetails](#disconnecteddetails9)> | Yes | Callback used to return the result. |
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -2449,10 +2504,11 @@ Subscribes to **mmiCodeResult** events. This API uses an asynchronous callback t
| Name | Type | Mandatory| Description |
| -------- | -------------------------------------------- | ---- | --------------------- |
-| type | string | Yes | Man-machine interface (MMI) code result.|
+| type | string | Yes | MMI code result. This field has a fixed value of **mmiCodeResult**.|
| callback | Callback<[MmiCodeResults](#mmicoderesults9)> | Yes | Callback used to return the result. |
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -2488,10 +2544,11 @@ Unsubscribes from **callDetailsChange** events. This API uses an asynchronous ca
| Name | Type | Mandatory| Description |
| -------- | -------------------------------------------------------- | ---- | ---------------------------------- |
-| type | string | Yes | IMS registration status changes.|
+| type | string | Yes | Call details change. This field has a fixed value of **callDetailsChange**.|
| callback | Callback<[CallAttributeOptions](#callattributeoptions7)> | No | Callback used to return the result. |
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -2527,10 +2584,11 @@ Unsubscribes from **callEventChange** events. This API uses an asynchronous call
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------ | ---- | ---------------------------------- |
-| type | string | Yes | Unsubscription from call event changes when a call ends.|
+| type | string | Yes | Call event change. This field has a fixed value of **callEventChange**.|
| callback | Callback<[CallEventOptions](#calleventoptions8)> | No | Callback used to return the result. |
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -2565,11 +2623,12 @@ Unsubscribes from **callDisconnectedCause** events. This API uses an asynchronou
**Parameters**
| Name | Type | Mandatory| Description |
-| -------- | ---------------------------------------------------------- | ---- | -------------------- |
-| type | 'callDisconnectedCause' | Yes | Unsubscription from the call disconnection cause when a call ends.|
-| callback | Callback**<**[DisconnectedDetails](#disconnecteddetails9)> | No | Callback used to return the result. |
+| -------- | ---------------------------------------------------------- | ---- | ------------------- |
+| type | string | Yes | Call disconnection cause. This field has a fixed value of **callDisconnectedCause**.|
+| callback | Callback<[DisconnectedDetails](#disconnecteddetails9)> | No | Callback used to return the result. |
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -2603,12 +2662,13 @@ Unsubscribes from **mmiCodeResult** events. This API uses an asynchronous callba
**Parameters**
-| Name | Type | Mandatory| Description |
+| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------ | ---- | ----------- |
-| type | 'mmiCodeResult' | Yes | MMI code result.|
-| callback | Callback<[MmiCodeResults](#mmicoderesults9)> | No | Callback used to return the result. |
+| type | string | Yes | MMI code result. This field has a fixed value of **mmiCodeResult**.|
+| callback | Callback<[MmiCodeResults](#mmicoderesults9)> | No | Callback used to return the result. |
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -2645,6 +2705,7 @@ Checks whether a new call is allowed. This API uses an asynchronous callback to
| callback | AsyncCallback<boolean> | Yes | Callback used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -2681,6 +2742,7 @@ Checks whether a new call is allowed. This API uses a promise to return the resu
| Promise<boolean> | Promise used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -2720,6 +2782,7 @@ Separates calls from a conference call. This API uses an asynchronous callback t
| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -2733,8 +2796,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example**
```js
-call.separateConference(1, (err, data) => {
- console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
+call.separateConference(1, (err) => {
+ console.log(`callback: err->${JSON.stringify(err)}`);
});
```
@@ -2762,6 +2825,7 @@ Separates calls from a conference call. This API uses a promise to return the re
| Promise<void> | Promise used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -2775,10 +2839,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example**
```js
-let promise = call.separateConference(1);
-promise.then(data => {
- console.log(`separateConference success, promise: data->${JSON.stringify(data)}`);
-}).catch(err => {
+call.separateConference(1).then(() => {
+ console.log(`separateConference success.`);
+}).catch((err) => {
console.error(`separateConference fail, promise: err->${JSON.stringify(err)}`);
});
```
@@ -2804,6 +2867,7 @@ Obtains the call restriction status. This API uses an asynchronous callback to r
| callback | AsyncCallback<[RestrictionStatus](#restrictionstatus8)> | Yes | Callback used to return the result. |
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -2850,6 +2914,7 @@ Obtains the call restriction status. This API uses a promise to return the resul
| Promise<[RestrictionStatus](#restrictionstatus8)> | Promise used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -2893,6 +2958,7 @@ Sets the call restriction status. This API uses an asynchronous callback to retu
| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -2912,8 +2978,8 @@ let callRestrictionInfo={
password: "123456",
mode: 1
}
-call.setCallRestriction(0, callRestrictionInfo, (err, data) => {
- console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
+call.setCallRestriction(0, callRestrictionInfo, (err) => {
+ console.log(`callback: err->${JSON.stringify(err)}`);
});
```
@@ -2944,6 +3010,7 @@ Sets the call restriction status. This API uses a promise to return the result.
| Promise<void> | Promise used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -2963,10 +3030,9 @@ let callRestrictionInfo={
password: "123456",
mode: 1
}
-let promise = call.setCallRestriction(0, callRestrictionInfo);
-promise.then(data => {
- console.log(`setCallRestriction success, promise: data->${JSON.stringify(data)}`);
-}).catch(err => {
+call.setCallRestriction(0, callRestrictionInfo).then(() => {
+ console.log(`setCallRestriction success.`);
+}).catch((err) => {
console.error(`setCallRestriction fail, promise: err->${JSON.stringify(err)}`);
});
```
@@ -2992,6 +3058,7 @@ Obtains call transfer information. This API uses an asynchronous callback to ret
| callback | AsyncCallback<[CallTransferResult](#calltransferresult8)> | Yes | Callback used to return the result. |
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -3038,6 +3105,7 @@ Obtains call transfer information. This API uses a promise to return the result.
| Promise<[CallTransferResult](#calltransferresult8)> | Promise used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -3081,6 +3149,7 @@ Sets call transfer information. This API uses an asynchronous callback to return
| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -3100,8 +3169,8 @@ let callTransferInfo={
type: 1,
settingType: 1
}
-call.setCallTransfer(0, callTransferInfo, (err, data) => {
- console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
+call.setCallTransfer(0, callTransferInfo, (err) => {
+ console.log(`callback: err->${JSON.stringify(err)}`);
});
```
@@ -3132,6 +3201,7 @@ Sets call transfer information. This API uses a promise to return the result.
| Promise<void> | Promise used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -3151,10 +3221,9 @@ let callTransferInfo={
type: 1,
settingType: 1
}
-let promise = call.setCallTransfer(0, callTransferInfo);
-promise.then(data => {
- console.log(`setCallTransfer success, promise: data->${JSON.stringify(data)}`);
-}).catch(err => {
+call.setCallTransfer(0, callTransferInfo).then(() => {
+ console.log(`setCallTransfer success.`);
+}).catch((err) => {
console.error(`setCallTransfer fail, promise: err->${JSON.stringify(err)}`);
});
```
@@ -3178,6 +3247,7 @@ Checks whether the ringtone is playing. This API uses an asynchronous callback t
| callback | AsyncCallback<boolean> | Yes | Callback used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -3217,6 +3287,7 @@ Checks whether the ringtone is playing. This API uses a promise to return the re
| Promise<boolean> | Promise used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -3256,6 +3327,7 @@ Sets call muting. This API uses an asynchronous callback to return the result.
| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -3269,8 +3341,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example**
```js
-call.setMuted((err, data) => {
- console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
+call.setMuted((err) => {
+ console.log(`callback: err->${JSON.stringify(err)}`);
});
```
@@ -3292,6 +3364,7 @@ Sets call muting. This API uses a promise to return the result.
| Promise<void> | Promise used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -3305,10 +3378,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example**
```js
-let promise = call.setMuted();
-promise.then(data => {
- console.log(`setMuted success, promise: data->${JSON.stringify(data)}`);
-}).catch(err => {
+call.setMuted().then(() => {
+ console.log(`setMuted success.`);
+}).catch((err) => {
console.error(`setMuted fail, promise: err->${JSON.stringify(err)}`);
});
```
@@ -3330,6 +3402,7 @@ Cancels call muting. This API uses an asynchronous callback to return the result
| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -3343,8 +3416,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example**
```js
-call.cancelMuted((err, data) => {
- console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
+call.cancelMuted((err) => {
+ console.log(`callback: err->${JSON.stringify(err)}`);
});
```
@@ -3366,6 +3439,7 @@ Cancels call muting. This API uses a promise to return the result.
| Promise<void> | Promise used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -3379,10 +3453,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example**
```js
-let promise = call.cancelMuted();
-promise.then(data => {
- console.log(`cancelMuted success, promise: data->${JSON.stringify(data)}`);
-}).catch(err => {
+call.cancelMuted().then(() => {
+ console.log(`cancelMuted success.`);
+}).catch((err) => {
console.error(`cancelMuted fail, promise: err->${JSON.stringify(err)}`);
});
```
@@ -3405,6 +3478,7 @@ Sets the audio device for a call. This API uses an asynchronous callback to retu
| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -3418,8 +3492,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example**
```js
-call.setAudioDevice(1, (err, data) => {
- console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
+call.setAudioDevice(1, (err) => {
+ console.log(`callback: err->${JSON.stringify(err)}`);
});
```
@@ -3443,6 +3517,7 @@ Sets the audio device for a call based on the specified options. This API uses a
| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -3459,8 +3534,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r
let audioDeviceOptions={
bluetoothAddress: "IEEE 802-2014"
}
-call.setAudioDevice(1, audioDeviceOptions, (err, data) => {
- console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
+call.setAudioDevice(1, audioDeviceOptions, (err) => {
+ console.log(`callback: err->${JSON.stringify(err)}`);
});
```
@@ -3489,6 +3564,7 @@ Sets the audio device for a call based on the specified options. This API uses a
| Promise<void> | Promise used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -3505,10 +3581,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r
let audioDeviceOptions={
bluetoothAddress: "IEEE 802-2014"
}
-let promise = call.setAudioDevice(1, audioDeviceOptions);
-promise.then(data => {
- console.log(`setAudioDevice success, promise: data->${JSON.stringify(data)}`);
-}).catch(err => {
+call.setAudioDevice(1, audioDeviceOptions).then(() => {
+ console.log(`setAudioDevice success.`);
+}).catch((err) => {
console.error(`setAudioDevice fail, promise: err->${JSON.stringify(err)}`);
});
```
@@ -3532,6 +3607,7 @@ Joins a conference call. This API uses an asynchronous callback to return the re
| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -3548,8 +3624,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r
let callNumberList: Array = [
"138XXXXXXXX"
];
-call.joinConference(1, callNumberList, (err, data) => {
- console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
+call.joinConference(1, callNumberList, (err) => {
+ console.log(`callback: err->${JSON.stringify(err)}`);
});
```
@@ -3577,6 +3653,7 @@ Joins a conference call. This API uses a promise to return the result.
| Promise<void> | Promise used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -3593,10 +3670,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r
let callNumberList: Array = [
"138XXXXXXXX"
];
-let promise = call.joinConference(1, callNumberList);
-promise.then(data => {
- console.log(`joinConference success, promise: data->${JSON.stringify(data)}`);
-}).catch(err => {
+call.joinConference(1, callNumberList).then(() => {
+ console.log(`joinConference success.`);
+}).catch((err) => {
console.error(`joinConference fail, promise: err->${JSON.stringify(err)}`);
});
```
@@ -3620,6 +3696,7 @@ Updates the IMS call mode. This API uses an asynchronous callback to return the
| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -3633,8 +3710,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example**
```js
-call.updateImsCallMode(1, 1, (err, data) => {
- console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
+call.updateImsCallMode(1, 1, (err) => {
+ console.log(`callback: err->${JSON.stringify(err)}`);
});
```
@@ -3662,6 +3739,7 @@ Updates the IMS call mode. This API uses a promise to return the result.
| Promise<void> | Promise used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -3675,10 +3753,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example**
```js
-let promise = call.updateImsCallMode(1, 1);
-promise.then(data => {
- console.log(`updateImsCallMode success, promise: data->${JSON.stringify(data)}`);
-}).catch(err => {
+call.updateImsCallMode(1, 1).then(() => {
+ console.log(`updateImsCallMode success.`);
+}).catch((err) => {
console.error(`updateImsCallMode fail, promise: err->${JSON.stringify(err)}`);
});
```
@@ -3703,6 +3780,7 @@ Enables the IMS switch. This API uses an asynchronous callback to return the res
| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -3717,8 +3795,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example**
```js
-call.enableImsSwitch(0, (err, data) => {
- console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
+call.enableImsSwitch(0, (err) => {
+ console.log(`callback: err->${JSON.stringify(err)}`);
});
```
@@ -3747,6 +3825,7 @@ Enables the IMS switch. This API uses a promise to return the result.
| Promise<void> | Promise used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -3761,10 +3840,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example**
```js
-let promise = call.enableImsSwitch(0);
-promise.then(data => {
- console.log(`enableImsSwitch success, promise: data->${JSON.stringify(data)}`);
-}).catch(err => {
+call.enableImsSwitch(0).then(() => {
+ console.log(`enableImsSwitch success.`);
+}).catch((err) => {
console.error(`enableImsSwitch fail, promise: err->${JSON.stringify(err)}`);
});
```
@@ -3789,6 +3867,7 @@ Disables the IMS switch. This API uses an asynchronous callback to return the re
| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -3803,8 +3882,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example**
```js
-call.disableImsSwitch(0, (err, data) => {
- console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
+call.disableImsSwitch(0, (err) => {
+ console.log(`callback: err->${JSON.stringify(err)}`);
});
```
@@ -3822,20 +3901,21 @@ Disables the IMS switch. This API uses a promise to return the result.
**Parameters**
-| Name| Type | Mandatory| Description |
+| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------------------------- |
-| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2|
+| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2 |
**Return value**
-| Type | Description |
+| Type | Description |
| ------------------- | --------------------------- |
-| Promise<void> | Promise used to return the result.|
+| Promise<void> | Promise used to return the result. |
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
-| ID| Error Message |
+| ID| Error Message |
| -------- | -------------------------------------------- |
| 201 | Permission denied. |
| 401 | Parameter error. |
@@ -3847,10 +3927,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example**
```js
-let promise = call.disableImsSwitch(0);
-promise.then(data => {
- console.log(`disableImsSwitch success, promise: data->${JSON.stringify(data)}`);
-}).catch(err => {
+call.disableImsSwitch(0).then(() => {
+ console.log(`disableImsSwitch success.`);
+}).catch((err) => {
console.error(`disableImsSwitch fail, promise: err->${JSON.stringify(err)}`);
});
```
@@ -3873,6 +3952,7 @@ Checks whether the IMS switch is enabled. This API uses an asynchronous callback
| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. |
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
@@ -3914,6 +3994,7 @@ Checks whether the IMS switch is enabled. This API uses a promise to return the
| Promise<void> | Promise used to return the result.|
**Error codes**
+
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
diff --git a/en/application-dev/reference/apis/js-apis-camera.md b/en/application-dev/reference/apis/js-apis-camera.md
index ec4684a53f03a85706e29f6fc918371ab54d5363..106aa2ecdcea58b97966a46e1f4ea38bcb2432eb 100644
--- a/en/application-dev/reference/apis/js-apis-camera.md
+++ b/en/application-dev/reference/apis/js-apis-camera.md
@@ -31,6 +31,15 @@ Obtains a **CameraManager** instance. This API returns the result synchronously.
| ----------------------------------------------- | ---------------------------- |
| [CameraManager](#cameramanager) | **CameraManager** instance obtained. |
+**Error codes**
+
+For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
+
+| ID | Error Message |
+| --------------- | --------------- |
+| 7400101 | Parameter missing or parameter type incorrect |
+| 7400201 | Camera service fatal error. |
+
**Example**
```js
@@ -90,10 +99,10 @@ Defines the camera output capability.
| Name | Type | Mandatory| 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.|
+| 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.|
## CameraErrorCode
@@ -119,7 +128,7 @@ Implements camera management. Before calling any API in **CameraManager**, you m
### getSupportedCameras
-getSupportedCameras(): Array
+getSupportedCameras(): Array\
Obtains supported cameras. This API returns the result synchronously.
@@ -129,7 +138,7 @@ Obtains supported cameras. This API returns the result synchronously.
| Type | Description |
| ----------------------------------------------- | ---------------------------- |
-| Array<[CameraDevice](#cameradevice)> | An array of supported cameras. |
+| Array\<[CameraDevice](#cameradevice)> | An array of supported cameras. |
**Example**
@@ -140,7 +149,7 @@ let cameras = cameraManager.getSupportedCameras();
### getSupportedOutputCapability
-getSupportedOutputCapability(cameraDevice:CameraDevice): CameraOutputCapability
+getSupportedOutputCapability(camera:CameraDevice): CameraOutputCapability
Obtains the output capability supported by a camera. This API returns the result synchronously.
@@ -255,6 +264,14 @@ Creates a **CameraInput** instance with the specified **CameraDevice** object. T
| ---------- | ----------------------------- |
| [CameraInput](#camerainput) | **CameraInput** instance created. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+**Error codes**
+
+For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
+
+| ID | Error Message |
+| --------------- | --------------- |
+| 7400101 | Parameter missing or parameter type incorrect |
+
**Example**
```js
@@ -291,6 +308,14 @@ Creates a **CameraInput** instance with the specified camera position and type.
| ---------- | ----------------------------- |
| [CameraInput](#camerainput) | **CameraInput** instance created. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+**Error codes**
+
+For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
+
+| ID | Error Message |
+| --------------- | --------------- |
+| 7400101 | Parameter missing or parameter type incorrect |
+
**Example**
```js
@@ -327,6 +352,14 @@ Creates a **PreviewOutput** instance. This API returns the result synchronously.
| ---------- | ----------------------------- |
| [PreviewOutput](#previewoutput) | **PreviewOutput** instance created. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+**Error codes**
+
+For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
+
+| ID | Error Message |
+| --------------- | --------------- |
+| 7400101 | Parameter missing or parameter type incorrect |
+
**Example**
```js
@@ -361,6 +394,14 @@ Creates a **PhotoOutput** instance. This API returns the result synchronously.
| ---------- | ----------------------------- |
| [PhotoOutput](#photooutput) | **PhotoOutput** instance created. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+**Error codes**
+
+For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
+
+| ID | Error Message |
+| --------------- | --------------- |
+| 7400101 | Parameter missing or parameter type incorrect |
+
**Example**
```js
@@ -395,6 +436,14 @@ Creates a **VideoOutput** instance. This API returns the result synchronously.
| ---------- | ----------------------------- |
| [VideoOutput](#videooutput) | **VideoOutput** instance created. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+**Error codes**
+
+For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
+
+| ID | Error Message |
+| --------------- | --------------- |
+| 7400101 | Parameter missing or parameter type incorrect |
+
**Example**
```js
@@ -410,7 +459,7 @@ try {
### createMetadataOutput
-createMetadataOutput(metadataObjectTypes:Array): MetadataOutput
+createMetadataOutput(metadataObjectTypes:Array\): MetadataOutput
Creates a **MetadataOutput** instance. This API returns the result synchronously.
@@ -420,7 +469,7 @@ Creates a **MetadataOutput** instance. This API returns the result synchronously
| Name | Type | Mandatory| Description |
| -------------------- | -------------------------------------------------- | --- | ---------------------------- |
-| metadataObjectTypes | Array<[MetadataObjectType](#metadataobjecttype)\> | Yes | Metadata object types, which are obtained through **getSupportedOutputCapability**.|
+| metadataObjectTypes | Array\<[MetadataObjectType](#metadataobjecttype)\> | Yes | Metadata object types, which are obtained through **getSupportedOutputCapability**.|
**Return value**
@@ -428,6 +477,14 @@ Creates a **MetadataOutput** instance. This API returns the result synchronously
| ---------- | ----------------------------- |
| [MetadataOutput](#metadataoutput) | **MetadataOutput** instance created. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+**Error codes**
+
+For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
+
+| ID | Error Message |
+| --------------- | --------------- |
+| 7400101 | Parameter missing or parameter type incorrect |
+
**Example**
```js
@@ -455,6 +512,14 @@ Creates a **CaptureSession** instance. This API returns the result synchronously
| ---------- | ----------------------------- |
| [CaptureSession](#capturesession) | **CaptureSession** instance created. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+**Error codes**
+
+For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
+
+| ID | Error Message |
+| --------------- | --------------- |
+| 7400201 | Camera service fatal error. |
+
**Example**
```js
@@ -469,7 +534,7 @@ try {
### on('cameraStatus')
-on(type: 'cameraStatus', callback: AsyncCallback): void
+on(type: 'cameraStatus', callback: AsyncCallback\): void
Listens for camera status changes. This API uses an asynchronous callback to return the result.
@@ -480,7 +545,7 @@ Listens for camera status changes. This API uses an asynchronous callback to ret
| Name | Type | Mandatory| Description |
| -------- | -----------------| ---- | --------- |
| type | string | Yes | Event type. The value is fixed at **'cameraStatus'**. The event can be listened for when a **CameraManager** instance is obtained. This event is triggered and the corresponding information is returned only when the device is enabled or disabled.|
-| callback | AsyncCallback<[CameraStatusInfo](#camerastatusinfo)\> | Yes | Callback used to return the camera status change.| |
+| callback | AsyncCallback\<[CameraStatusInfo](#camerastatusinfo)\> | Yes | Callback used to return the camera status change.| |
**Example**
@@ -493,7 +558,7 @@ cameraManager.on('cameraStatus', (cameraStatusInfo) => {
### on('cameraMute')
-on(type: 'cameraMute', callback: AsyncCallback): void
+on(type: 'cameraMute', callback: AsyncCallback\): void
Listens for camera mute status changes. This API uses an asynchronous callback to return the result.
@@ -618,7 +683,7 @@ Provides camera information used in **[CaptureSession](#capturesession)**.
### open
-open\(callback: AsyncCallback\): void
+open\(callback: AsyncCallback\\): void
Opens this camera. This API uses an asynchronous callback to return the result.
@@ -628,7 +693,17 @@ Opens this camera. This API uses an asynchronous callback to return the result.
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ------------------- |
-| callback | AsyncCallback | Yes | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+| callback | AsyncCallback\ | Yes | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+
+**Error codes**
+
+For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
+
+| ID | Error Message |
+| --------------- | --------------- |
+| 7400107 | Can not use camera cause of conflict. |
+| 7400108 | Camera disabled cause of security reason. |
+| 7400201 | Camera service fatal error. |
**Example**
@@ -644,7 +719,7 @@ cameraInput.open((err) => {
### open
-open(): Promise
+open(): Promise\
Opens this camera. This API uses a promise to return the result.
@@ -654,7 +729,17 @@ Opens this camera. This API uses a promise to return the result.
| Type | Description |
| -------------- | ----------------------- |
-| Promise| Promise used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+| Promise\ | Promise used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+
+**Error codes**
+
+For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
+
+| ID | Error Message |
+| --------------- | --------------- |
+| 7400107 | Can not use camera cause of conflict. |
+| 7400108 | Camera disabled cause of security reason. |
+| 7400201 | Camera service fatal error. |
**Example**
@@ -668,7 +753,7 @@ cameraInput.open().then(() => {
### close
-close\(callback: AsyncCallback\): void
+close\(callback: AsyncCallback\\): void
Closes this camera. This API uses an asynchronous callback to return the result.
@@ -678,7 +763,15 @@ Closes this camera. This API uses an asynchronous callback to return the result.
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | -------------------- |
-| callback | AsyncCallback | Yes | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+| callback | AsyncCallback\ | Yes | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+
+**Error codes**
+
+For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
+
+| ID | Error Message |
+| --------------- | --------------- |
+| 7400201 | Camera service fatal error. |
**Example**
@@ -694,7 +787,7 @@ cameraInput.close((err) => {
### close
-close(): Promise
+close(): Promise\
Closes this camera. This API uses a promise to return the result.
@@ -704,7 +797,15 @@ Closes this camera. This API uses a promise to return the result.
| Type | Description |
| -------------- | ----------------------- |
-| Promise| Promise used to return the result.|
+| Promise\ | Promise used to return the result.|
+
+**Error codes**
+
+For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
+
+| ID | Error Message |
+| --------------- | --------------- |
+| 7400201 | Camera service fatal error. |
**Example**
@@ -718,7 +819,7 @@ cameraInput.close().then(() => {
### on('error')
-on(type: 'error', cameraDevice:CameraDevice, callback: ErrorCallback): void
+on(type: 'error', camera:CameraDevice, callback: ErrorCallback\): void
Listens for **CameraInput** errors. This API uses a callback to return the result.
@@ -730,7 +831,7 @@ Listens for **CameraInput** errors. This API uses a callback to return the resul
| -------- | -------------------------------- | --- | ------------------------------------------- |
| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a **CameraInput** instance is created. This event is triggered and the result is returned when an error occurs on the camera. For example, if the device is unavailable or a conflict occurs, the error information is returned.|
| cameraDevice | [CameraDevice](#cameradevice) | Yes | **CameraDevice** object.|
-| callback | ErrorCallback | Yes | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode). |
+| callback | ErrorCallback\ | Yes | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode). |
**Example**
@@ -774,7 +875,7 @@ Enumerates the focus modes.
| Name | Value | Description |
| -------------------------- | ---- | ------------ |
-| FOCUS_MODE_MANUAL | 0 | Manual focus. The focal length of the camera can be manually set to change the focus position. However, the focal point cannot be set. |
+| FOCUS_MODE_MANUAL | 0 | Manual focus. The focal length of the camera can be manually set to change the focus position. However, the focal point cannot be set. |
| FOCUS_MODE_CONTINUOUS_AUTO | 1 | Continuous auto focus. The focal point cannot be set.|
| FOCUS_MODE_AUTO | 2 | Auto focus. The focal point can be set by calling [setFocusPoint](#setfocuspoint), and auto focus is performed once based on the focal point. After the auto focus operation is complete (regardless of whether the focus is successful or fails), the focus mode is locked. To enable the camera to initiate another auto focus, the application must call **CONTINUOUS_AUTO** again. |
| FOCUS_MODE_LOCKED | 3 | Focus locked. The focal point cannot be set. |
@@ -823,6 +924,14 @@ Starts configuration for the session.
| ---------- | ----------------------------- |
| [CameraErrorCode](#cameraerrorcode) | If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+**Error codes**
+
+For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
+
+| ID | Error Message |
+| --------------- | --------------- |
+| 7400105 | Session config locked. |
+
**Example**
```js
@@ -836,7 +945,7 @@ try {
### commitConfig
-commitConfig(callback: AsyncCallback): void
+commitConfig(callback: AsyncCallback\): void
Commits the configuration for this **CaptureSession** instance. This API uses an asynchronous callback to return the result.
@@ -846,7 +955,16 @@ Commits the configuration for this **CaptureSession** instance. This API uses an
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | -------------------- |
-| callback | AsyncCallback | Yes | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+| callback | AsyncCallback\ | Yes | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+
+**Error codes**
+
+For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
+
+| ID | Error Message |
+| --------------- | --------------- |
+| 7400102 | Operation not allow. |
+| 7400201 | Camera service fatal error. |
**Example**
@@ -862,7 +980,7 @@ captureSession.commitConfig((err) => {
### commitConfig
-commitConfig(): Promise
+commitConfig(): Promise\
Commits the configuration for this **CaptureSession** instance. This API uses a promise to return the result.
@@ -872,7 +990,16 @@ Commits the configuration for this **CaptureSession** instance. This API uses a
| Type | Description |
| -------------- | ------------------------ |
-| Promise| Promise used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+| Promise\ | Promise used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+
+**Error codes**
+
+For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
+
+| ID | Error Message |
+| --------------- | --------------- |
+| 7400102 | Operation not allow. |
+| 7400201 | Camera service fatal error. |
**Example**
@@ -905,6 +1032,15 @@ Adds a [CameraInput](#camerainput) instance to the session.
| ---------- | ----------------------------- |
| [CameraErrorCode](#cameraerrorcode) | If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+**Error codes**
+
+For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
+
+| ID | Error Message |
+| --------------- | --------------- |
+| 7400101 | Parameter missing or parameter type incorrect |
+| 7400102 | Operation not allow. |
+
**Example**
```js
@@ -936,6 +1072,15 @@ Removes a [CameraInput](#camerainput) instance from the session.
| ---------- | ----------------------------- |
| [CameraErrorCode](#cameraerrorcode) | If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+**Error codes**
+
+For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
+
+| ID | Error Message |
+| --------------- | --------------- |
+| 7400101 | Parameter missing or parameter type incorrect |
+| 7400102 | Operation not allow. |
+
**Example**
```js
@@ -949,7 +1094,7 @@ try {
### addOutput
-addOutput(previewOutput: CameraOutput): void
+addOutput(cameraOutput: CameraOutput): void
Adds a [CameraOutput](#cameraoutput) instance to the session.
@@ -959,7 +1104,7 @@ Adds a [CameraOutput](#cameraoutput) instance to the session.
| Name | Type | Mandatory| Description |
| ------------- | ------------------------------- | ---- | ------------------------ |
-| previewOutput | [PreviewOutput](#previewoutput) | Yes | **PreviewOutput** instance to add.|
+| cameraOutput | [CameraOutput](#cameraoutput) | Yes | **CameraOutput** instance to add.|
**Return value**
@@ -967,11 +1112,20 @@ Adds a [CameraOutput](#cameraoutput) instance to the session.
| ---------- | ----------------------------- |
| [CameraErrorCode](#cameraerrorcode) | If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+**Error codes**
+
+For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
+
+| ID | Error Message |
+| --------------- | --------------- |
+| 7400101 | Parameter missing or parameter type incorrect |
+| 7400102 | Operation not allow. |
+
**Example**
```js
try {
- captureSession.addOutput(previewOutput);
+ captureSession.addOutput(cameraOutput);
} catch (error) {
// If the operation fails, error.code is returned and processed.
console.log(error.code);
@@ -980,7 +1134,7 @@ try {
### removeOutput
-removeOutput(previewOutput: CameraOutput): void
+removeOutput(cameraOutput: CameraOutput): void
Removes a [CameraOutput](#cameraoutput) instance from the session.
@@ -990,7 +1144,7 @@ Removes a [CameraOutput](#cameraoutput) instance from the session.
| Name | Type | Mandatory| Description |
| ------------- | ------------------------------- | ---- | ------------------------ |
-| previewOutput | [PreviewOutput](#previewoutput) | Yes | **PreviewOutput** instance to remove.|
+| cameraOutput | [CameraOutput](#cameraoutput) | Yes | **CameraOutput** instance to remove.|
**Return value**
@@ -998,6 +1152,15 @@ Removes a [CameraOutput](#cameraoutput) instance from the session.
| ---------- | ----------------------------- |
| [CameraErrorCode](#cameraerrorcode) | If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+**Error codes**
+
+For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
+
+| ID | Error Message |
+| --------------- | --------------- |
+| 7400101 | Parameter missing or parameter type incorrect |
+| 7400102 | Operation not allow. |
+
**Example**
```js
@@ -1011,7 +1174,7 @@ try {
### start
-start\(callback: AsyncCallback\): void
+start\(callback: AsyncCallback\\): void
Starts this **CaptureSession**. This API uses an asynchronous callback to return the result.
@@ -1021,7 +1184,16 @@ Starts this **CaptureSession**. This API uses an asynchronous callback to return
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | -------------------- |
-| callback | AsyncCallback | Yes | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+| callback | AsyncCallback\ | Yes | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+
+**Error codes**
+
+For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
+
+| ID | Error Message |
+| --------------- | --------------- |
+| 7400103 | Session not config. |
+| 7400201 | Camera service fatal error. |
**Example**
@@ -1037,7 +1209,7 @@ captureSession.start((err) => {
### start
-start\(\): Promise
+start\(\): Promise\
Starts this **CaptureSession**. This API uses a promise to return the result.
@@ -1047,7 +1219,16 @@ Starts this **CaptureSession**. This API uses a promise to return the result.
| Type | Description |
| -------------- | ------------------------ |
-| Promise| Promise used to return the result.|
+| Promise\ | Promise used to return the result.|
+
+**Error codes**
+
+For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
+
+| ID | Error Message |
+| --------------- | --------------- |
+| 7400103 | Session not config. |
+| 7400201 | Camera service fatal error. |
**Example**
@@ -1061,7 +1242,7 @@ captureSession.start().then(() => {
### stop
-stop\(callback: AsyncCallback\): void
+stop\(callback: AsyncCallback\\): void
Stops this **CaptureSession**. This API uses an asynchronous callback to return the result.
@@ -1071,7 +1252,15 @@ Stops this **CaptureSession**. This API uses an asynchronous callback to return
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ------------------- |
-| callback | AsyncCallback | Yes | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+| callback | AsyncCallback\ | Yes | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+
+**Error codes**
+
+For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
+
+| ID | Error Message |
+| --------------- | --------------- |
+| 7400201 | Camera service fatal error. |
**Example**
@@ -1087,7 +1276,7 @@ captureSession.stop((err) => {
### stop
-stop(): Promise
+stop(): Promise\
Stops this **CaptureSession**. This API uses a promise to return the result.
@@ -1097,7 +1286,15 @@ Stops this **CaptureSession**. This API uses a promise to return the result.
| Type | Description |
| -------------- | ----------------------- |
-| Promise| Promise used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+| Promise\ | Promise used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+
+**Error codes**
+
+For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
+
+| ID | Error Message |
+| --------------- | --------------- |
+| 7400201 | Camera service fatal error. |
**Example**
@@ -1111,7 +1308,7 @@ captureSession.stop().then(() => {
### release
-release\(callback: AsyncCallback\): void
+release\(callback: AsyncCallback\\): void
Releases this **CaptureSession**. This API uses an asynchronous callback to return the result.
@@ -1121,7 +1318,15 @@ Releases this **CaptureSession**. This API uses an asynchronous callback to retu
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | -------------------- |
-| callback | AsyncCallback | Yes | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+| callback | AsyncCallback\ | Yes | Callback used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+
+**Error codes**
+
+For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
+
+| ID | Error Message |
+| --------------- | --------------- |
+| 7400201 | Camera service fatal error. |
**Example**
@@ -1137,7 +1342,7 @@ captureSession.release((err) => {
### release
-release(): Promise
+release(): Promise\
Releases this **CaptureSession**. This API uses a promise to return the result.
@@ -1147,7 +1352,15 @@ Releases this **CaptureSession**. This API uses a promise to return the result.
| Type | Description |
| -------------- | ------------------------ |
-| Promise| Promise used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+| Promise\ | Promise used to return the result. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+
+**Error codes**
+
+For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
+
+| ID | Error Message |
+| --------------- | --------------- |
+| 7400201 | Camera service fatal error. |
**Example**
@@ -1173,6 +1386,14 @@ Checks whether the device has flash. This API uses an asynchronous callback to r
| ---------- | ----------------------------- |
| boolean | Returns **true** if the device has flash; returns **false** otherwise. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+**Error codes**
+
+For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
+
+| ID | Error Message |
+| --------------- | --------------- |
+| 7400103 | Session not config. |
+
**Example**
```js
@@ -1204,6 +1425,14 @@ Checks whether a flash mode is supported.
| ---------- | ----------------------------- |
| boolean | Returns **true** if the flash mode is supported; returns **false** otherwise. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+**Error codes**
+
+For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
+
+| ID | Error Message |
+| --------------- | --------------- |
+| 7400103 | Session not config. |
+
**Example**
```js
@@ -1240,6 +1469,14 @@ Before the setting, do the following checks:
| ---------- | ----------------------------- |
| [CameraErrorCode](#cameraerrorcode) | If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+**Error codes**
+
+For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
+
+| ID | Error Message |
+| --------------- | --------------- |
+| 7400103 | Session not config. |
+
**Example**
```js
@@ -1265,6 +1502,14 @@ Obtains the flash mode in use.
| ---------- | ----------------------------- |
| [FlashMode](#flashmode) | Flash mode obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+**Error codes**
+
+For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
+
+| ID | Error Message |
+| --------------- | --------------- |
+| 7400103 | Session not config. |
+
**Example**
```js
@@ -1296,6 +1541,14 @@ Checks whether an exposure mode is supported.
| ---------- | ----------------------------- |
| boolean | Returns **true** if the exposure mode is supported; returns **false** otherwise. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+**Error codes**
+
+For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
+
+| ID | Error Message |
+| --------------- | --------------- |
+| 7400103 | Session not config. |
+
**Example**
```js
@@ -1321,6 +1574,14 @@ Obtains the exposure mode in use.
| ---------- | ----------------------------- |
| [ExposureMode](#exposuremode) | Exposure mode obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+**Error codes**
+
+For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
+
+| ID | Error Message |
+| --------------- | --------------- |
+| 7400103 | Session not config. |
+
**Example**
```js
@@ -1352,6 +1613,14 @@ Sets an exposure mode for the device.
| ---------- | ----------------------------- |
| [CameraErrorCode](#cameraerrorcode) | If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+**Error codes**
+
+For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
+
+| ID | Error Message |
+| --------------- | --------------- |
+| 7400103 | Session not config. |
+
**Example**
```js
@@ -1377,6 +1646,14 @@ Obtains the metering point of the device.
| ---------- | ----------------------------- |
| [Point](#point) | Metering point obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+**Error codes**
+
+For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
+
+| ID | Error Message |
+| --------------- | --------------- |
+| 7400103 | Session not config. |
+
**Example**
```js
@@ -1410,6 +1687,14 @@ The coordinate system is based on the horizontal device direction with the devic
| ---------- | ----------------------------- |
| [CameraErrorCode](#cameraerrorcode) | If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+**Error codes**
+
+For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
+
+| ID | Error Message |
+| --------------- | --------------- |
+| 7400103 | Session not config. |
+
**Example**
```js
@@ -1424,7 +1709,7 @@ try {
### getExposureBiasRange
-getExposureBiasRange(): Array
+getExposureBiasRange(): Array\
Obtains the exposure compensation values of the device.
@@ -1434,7 +1719,15 @@ Obtains the exposure compensation values of the device.
| Type | Description |
| ---------- | ----------------------------- |
-| Array | An array of compensation values. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+| Array\ | An array of compensation values. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+
+**Error codes**
+
+For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
+
+| ID | Error Message |
+| --------------- | --------------- |
+| 7400103 | Session not config. |
**Example**
@@ -1463,6 +1756,14 @@ Before the setting, you are advised to use **[getExposureBiasRange](#getexposure
| -------- | -------------------------------| ---- | ------------------- |
| exposureBias | number | Yes | Exposure bias to set, which must be within the range obtained by running **getExposureBiasRange** interface. If the API call fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+**Error codes**
+
+For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
+
+| ID | Error Message |
+| --------------- | --------------- |
+| 7400103 | Session not config. |
+
**Example**
```js
@@ -1489,6 +1790,14 @@ Obtains the exposure value in use.
| ---------- | ----------------------------- |
| number | Exposure value obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+**Error codes**
+
+For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
+
+| ID | Error Message |
+| --------------- | --------------- |
+| 7400103 | Session not config. |
+
**Example**
```js
@@ -1520,6 +1829,14 @@ Checks whether a focus mode is supported.
| ---------- | ----------------------------- |
| boolean | Returns **true** if the focus mode is supported; returns **false** otherwise. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+**Error codes**
+
+For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
+
+| ID | Error Message |
+| --------------- | --------------- |
+| 7400103 | Session not config. |
+
**Example**
```js
@@ -1553,6 +1870,14 @@ Before the setting, use **[isFocusModeSupported](#isfocusmodesupported)** to che
| ---------- | ----------------------------- |
| [CameraErrorCode](#cameraerrorcode) | If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+**Error codes**
+
+For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
+
+| ID | Error Message |
+| --------------- | --------------- |
+| 7400103 | Session not config. |
+
**Example**
```js
@@ -1578,6 +1903,14 @@ Obtains the focus mode in use.
| ---------- | ----------------------------- |
| [FocusMode](#focusmode) | Focus mode obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+**Error codes**
+
+For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
+
+| ID | Error Message |
+| --------------- | --------------- |
+| 7400103 | Session not config. |
+
**Example**
```js
@@ -1611,6 +1944,14 @@ The coordinate system is based on the horizontal device direction with the devic
| ---------- | ----------------------------- |
| [CameraErrorCode](#cameraerrorcode) | If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+**Error codes**
+
+For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
+
+| ID | Error Message |
+| --------------- | --------------- |
+| 7400103 | Session not config. |
+
**Example**
```js
@@ -1637,6 +1978,14 @@ Obtains the focal point of the device.
| ---------- | ----------------------------- |
| [Point](#point) | Focal point obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+**Error codes**
+
+For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
+
+| ID | Error Message |
+| --------------- | --------------- |
+| 7400103 | Session not config. |
+
**Example**
```js
@@ -1662,6 +2011,14 @@ Obtains the focal length of the device.
| ---------- | ----------------------------- |
| number | Focal length obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+**Error codes**
+
+For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
+
+| ID | Error Message |
+| --------------- | --------------- |
+| 7400103 | Session not config. |
+
**Example**
```js
@@ -1675,7 +2032,7 @@ try {
### getZoomRatioRange
-getZoomRatioRange(): Array
+getZoomRatioRange(): Array\
Obtains the supported zoom ratio range.
@@ -1685,7 +2042,15 @@ Obtains the supported zoom ratio range.
| Type | Description |
| ---------- | ----------------------------- |
-| Array | Callback used to return an array containing the minimum and maximum zoom ratios. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+| Array\ | Callback used to return an array containing the minimum and maximum zoom ratios. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+
+**Error codes**
+
+For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
+
+| ID | Error Message |
+| --------------- | --------------- |
+| 7400103 | Session not config. |
**Example**
@@ -1718,6 +2083,14 @@ Sets a zoom ratio, with a maximum precision of two decimal places.
| ---------- | ----------------------------- |
| [CameraErrorCode](#cameraerrorcode) | If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+**Error codes**
+
+For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
+
+| ID | Error Message |
+| --------------- | --------------- |
+| 7400103 | Session not config. |
+
**Example**
```js
@@ -1744,6 +2117,14 @@ Obtains the zoom ratio in use.
| ---------- | ----------------------------- |
| number | Zoom ratio obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+**Error codes**
+
+For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
+
+| ID | Error Message |
+| --------------- | --------------- |
+| 7400103 | Session not config. |
+
**Example**
```js
@@ -1775,6 +2156,14 @@ Checks whether the specified video stabilization mode is supported.
| ---------- | ----------------------------- |
| boolean | Returns **true** if the video stabilization mode is supported; returns **false** otherwise. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+**Error codes**
+
+For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
+
+| ID | Error Message |
+| --------------- | --------------- |
+| 7400103 | Session not config. |
+
**Example**
```js
@@ -1800,6 +2189,14 @@ Obtains the video stabilization mode in use.
| ---------- | ----------------------------- |
| VideoStabilizationMode | Video stabilization mode obtained. If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+**Error codes**
+
+For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
+
+| ID | Error Message |
+| --------------- | --------------- |
+| 7400103 | Session not config. |
+
**Example**
```js
@@ -1831,6 +2228,14 @@ Sets a video stabilization mode for the device.
| ---------- | ----------------------------- |
| [CameraErrorCode](#cameraerrorcode) | If the operation fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+**Error codes**
+
+For details about the error codes, see [CameraErrorCode](#cameraerrorcode).
+
+| ID | Error Message |
+| --------------- | --------------- |
+| 7400103 | Session not config. |
+
**Example**
```js
@@ -1844,7 +2249,7 @@ try {
### on('focusStateChange')
-on(type: 'focusStateChange', callback: AsyncCallback