diff --git a/CODEOWNERS b/CODEOWNERS
index 4f7ab1dad900229e988205402075da217e03f536..b3a89aecb5c1bf1907db23aabcb7d61adecc8ab3 100644
--- a/CODEOWNERS
+++ b/CODEOWNERS
@@ -435,6 +435,7 @@ zh-cn/application-dev/reference/apis/js-apis-system-bluetooth.md @cheng_guohong
zh-cn/application-dev/reference/apis/js-apis-system-brightness.md @aqxyjay @zengyawen @aqxyjay @alien0208
zh-cn/application-dev/reference/apis/js-apis-system-cipher.md @gaoyong @zengyawen @niejiteng @jumozhanjiang
zh-cn/application-dev/reference/apis/js-apis-system-configuration.md @Buda-Liu @ningningW @budda-wang @tomatodevboy
+zh-cn/application-dev/reference/apis/js-apis-system-date-time.md @feng-aiwen @ningningW @illybyy @murphy1984
zh-cn/application-dev/reference/apis/js-apis-system-device.md @mupceet @zengyawen @handyohos @nan-xiansen
zh-cn/application-dev/reference/apis/js-apis-system-fetch.md @zhang-hai-feng @zengyawen @jyh926 @gaoxi785
zh-cn/application-dev/reference/apis/js-apis-system-file.md @panqinxu @zengyawen @bubble_mao @jinhaihw
@@ -520,7 +521,7 @@ zh-cn/application-dev/reference/apis/js-apis-bundleManager.md @shuaytao @RayShih
zh-cn/application-dev/reference/apis/js-apis-bundleMonitor.md @shuaytao @RayShih @wangzhen107 @inter515
zh-cn/application-dev/reference/apis/js-apis-colorSpaceManager.md @zhangqiang183 @ge-yafang @wind_zj @zxg-gitee
zh-cn/application-dev/reference/apis/js-apis-commonEventManager.md @jayleehw @RayShih @li-weifeng2 @currydavids
-zh-cn/application-dev/reference/apis/js-apis-configPolicy.md @Buda-Liu @ningningW @budda-wang @yangqing3
+zh-cn/application-dev/reference/apis/js-apis-configPolicy.md @liuzuming @ningningW @yangqing3
zh-cn/application-dev/reference/apis/js-apis-cooperate.md @yuanxinying @ningningW @cococoler @alien0208
zh-cn/application-dev/reference/apis/js-apis-cryptoFramework.md @gaoyong @zengyawen @niejiteng @jumozhanjiang
zh-cn/application-dev/reference/apis/js-apis-cert.md @gaoyong @zengyawen @niejiteng @jumozhanjiang
@@ -528,8 +529,13 @@ zh-cn/application-dev/reference/apis/js-apis-curve.md @huaweimaxuchu @HelloCreas
zh-cn/application-dev/reference/apis/js-apis-defaultAppManager.md @shuaytao @RayShih @wangzhen107 @inter515
zh-cn/application-dev/reference/apis/js-apis-distributedBundle.md @shuaytao @RayShih @wangzhen107 @inter515
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-adminManager.md @Buda-Liu @ningningW @budda-wang @yangqing3
-zh-cn/application-dev/reference/apis/js-apis-enterprise-dateTimeManager.md @Buda-Liu @ningningW @budda-wang @yangqing3
+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-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
+zh-cn/application-dev/reference/apis/js-apis-enterprise-networkManager.md @liuzuming @ningningW @yangqing3
+zh-cn/application-dev/reference/apis/js-apis-enterprise-wifiManager.md @liuzuming @ningningW @yangqing3
zh-cn/application-dev/reference/apis/js-apis-fileAccess.md @panqinxu @zengyawen @bubble_mao @jinhaihw
zh-cn/application-dev/reference/apis/js-apis-fileExtensionInfo.md @panqinxu @zengyawen @bubble_mao @jinhaihw
zh-cn/application-dev/reference/apis/js-apis-freeInstall.md @shuaytao @RayShih @wangzhen107 @inter515
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/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/ability-deprecated/context-userguide.md b/en/application-dev/ability-deprecated/context-userguide.md
index 1340e72918e141dd3b95b5ddc8dbc11258f83493..79cae1da5611b0736f7d11a5bb0cfb9b48df3f0a 100644
--- a/en/application-dev/ability-deprecated/context-userguide.md
+++ b/en/application-dev/ability-deprecated/context-userguide.md
@@ -250,9 +250,9 @@ In the stage model, in the onWindowStageCreate lifecycle of an ability, you can
Use the API described in the table below to obtain the context associated with an ArkTS page.
-| API | Description |
-| :------------------------------------ | :--------------------------- |
-| getContext(component: Object): Object | Obtains the **Context** object associated with a component on the page.|
+| API | Description |
+| :------------------------------------ | :----------------------------------------------------------- |
+| getContext(component: Object): Object | Obtains the **Context** object associated with a component on the page.
Since API version 9, this API is supported in ArkTS widgets.|
**Example**
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 efc515db54971c76432f02b5f409990ecbd767b7..2c1505fc1c12e57a96f22fcda7faf92ba9ea7418 100644
--- a/en/application-dev/application-models/Readme-EN.md
+++ b/en/application-dev/application-models/Readme-EN.md
@@ -17,9 +17,12 @@
- ExtensionAbility Component
- [ExtensionAbility Component Overview](extensionability-overview.md)
- [ServiceExtensionAbility](serviceextensionability.md)
- - [DataShareExtensionAbility](datashareextensionability.md)
+ - [DataShareExtensionAbility (for 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)
- Want
@@ -32,15 +35,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](hop-cross-device-migration.md)
- - [Multi-device Collaboration](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)
- - [Publishing Common Events](common-event-publish.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)
- [Background Services](background-services.md)
- Inter-Thread Communication
- [Thread Model](thread-model-stage.md)
@@ -50,6 +57,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)
@@ -63,7 +71,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](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..231610ad52a5ff53ce75b96277a18e4430c65d87 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,80 @@
# 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",
+ "type": "text/*"
+ },
+ {
+ "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",
+ "type": "text/plain"
+ }
+ 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.
+When there are multiple matching applications, a dialog box is displayed 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/common-event-overview.md b/en/application-dev/application-models/common-event-overview.md
index 0d3788b41b516d0af9619d320ceeefc3f52c74c5..d54fcf4786f0e22077cda0e6aae2d211bb2d0e90 100644
--- a/en/application-dev/application-models/common-event-overview.md
+++ b/en/application-dev/application-models/common-event-overview.md
@@ -15,11 +15,11 @@ 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 based on the subscription sequence, regardless of whether subscribers receive 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.
-- 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 they initiate a subscription. Only system applications and system services can send sticky common events, 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).
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.
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/data-share-via-want.md b/en/application-dev/application-models/data-share-via-want.md
index c04bea2916647804b51022cee1853f3b5d0a7d90..a057eb5c2b4796201cdd8bf35344ab600cfe0be0 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,132 @@
# 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 selector). 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 selector.
+- **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 selector 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 selector. 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 selector. 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 selector.
+ 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 selector.
+ 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 selector:
+
+- **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 5b07ba68180fbcc2a51047d37ca9a82addd89cd8..f671848f890277af92fc23869c5db0d57b02a316 100644
--- a/en/application-dev/application-models/datashareextensionability.md
+++ b/en/application-dev/application-models/datashareextensionability.md
@@ -1,4 +1,4 @@
-# DataShareExtensionAbility
+# DataShareExtensionAbility (for System Applications Only)
-DataShareExtensionAbility is available only for system application. It 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).
+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/extensionability-overview.md b/en/application-dev/application-models/extensionability-overview.md
index 8b3197383e17810cfee7c044611cf2286f4a987d..809e4e8f70ed31ad361e18dd8cb7e079ddf93086 100644
--- a/en/application-dev/application-models/extensionability-overview.md
+++ b/en/application-dev/application-models/extensionability-overview.md
@@ -9,7 +9,7 @@ An [ExtensionAbilityType](../reference/apis/js-apis-bundleManager.md#extensionab
- [FormExtensionAbility](../reference/apis/js-apis-app-form-formExtensionAbility.md): ExtensionAbility component of the form type, which provides APIs related to widgets.
-- [WorkSchedulerExtensionAbility](../reference/apis/js-apis-resourceschedule-workScheduler.md): ExtensionAbility component of the work_scheduler type, which provides callbacks for Work Scheduler tasks.
+- [WorkSchedulerExtensionAbility](../reference/apis/js-apis-WorkSchedulerExtensionAbility.md): ExtensionAbility component of the work_scheduler type, which provides callbacks for Work Scheduler tasks.
- [InputMethodExtensionAbility](../reference/apis/js-apis-inputmethod.md): ExtensionAbility component of the input_method type, which provides an input method framework that can be used to hide the keyboard, obtain the list of installed input methods, display the dialog box for input method selection, and more.
@@ -21,7 +21,7 @@ An [ExtensionAbilityType](../reference/apis/js-apis-bundleManager.md#extensionab
- [StaticSubscriberExtensionAbility](../reference/apis/js-apis-application-staticSubscriberExtensionAbility.md): ExtensionAbility component of the static_subscriber type, which provides APIs for static broadcast.
-- [WindowExtensionAbility](../reference/apis/js-apis-application-windowExtensionAbility.md): ExtensionAbility component of the window type, which allows system applications to display UIs of other applications.
+- [WindowExtensionAbility](../reference/apis/js-apis-application-windowExtensionAbility.md): ExtensionAbility component of the window type, which allows a system application to be embedded in and displayed over another application.
- [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.
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/mission-chain3.png b/en/application-dev/application-models/figures/mission-chain3.png
index e02c135ad4a90f99bb65bdccd821d29990b9536e..0357874ea633a490da800ef5baa2e70d53ce6a2d 100644
Binary files a/en/application-dev/application-models/figures/mission-chain3.png and b/en/application-dev/application-models/figures/mission-chain3.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/hop-cross-device-migration.md b/en/application-dev/application-models/hop-cross-device-migration.md
index 6d30435a819da49855cf9ae818bac419a1c0b614..d90a10995f0aeba773179fc7807ab25711b4594c 100644
--- a/en/application-dev/application-models/hop-cross-device-migration.md
+++ b/en/application-dev/application-models/hop-cross-device-migration.md
@@ -1,9 +1,9 @@
-# Cross-Device Migration
+# Cross-Device Migration (for System Applications Only)]
## When to Use
-Cross-device migration is available only for system applications. The main task is to migrate the current task (including the page control status) of an application to the target device so that the task can continue on it. Cross-device migration supports the following functionalities:
+The main task of cross-device migration is to migrate the current task (including the page control status) of an application to the target device so that the task can continue on it. Cross-device migration supports the following functionalities:
- Storage and restoration of custom data
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 fe22c3b33db46b5a353295582a5cc6a27f690d20..f5d82af32da86796d81dc1bebed1d6ff804f2532 100644
--- a/en/application-dev/application-models/hop-multi-device-collaboration.md
+++ b/en/application-dev/application-models/hop-multi-device-collaboration.md
@@ -1,9 +1,9 @@
-# Multi-device Collaboration
+# Multi-device Collaboration (for System Applications Only)
## When to Use
-Multi-device coordination is available only for system applications. It involves the following scenarios:
+Multi-device coordination involves the following scenarios:
- [Starting UIAbility and ServiceExtensionAbility Across Devices (No Data Returned)](#starting-uiability-and-serviceextensionability-across-devices-no-data-returned)
@@ -305,7 +305,7 @@ A system application can connect to a service on another device by calling [conn
## Using Cross-Device Ability 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](uiability-intra-device-interaction.md#using-ability-call-to-implement-uiability-interaction).
+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 (for System Applications Only)](uiability-intra-device-interaction.md#using-ability-call-to-implement-uiability-interaction-for-system-applications-only).
The following describes how to implement multi-device collaboration through cross-device ability call.
@@ -319,10 +319,10 @@ The following describes how to implement multi-device collaboration through cros
| 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.|
+| call(method: string, data: rpc.Parcelable): Promise<void> | Sends agreed parcelable data to the callee ability.|
+| callWithResult(method: string, data: rpc.Parcelable): Promise<rpc.MessageSequence>| Sends agreed parcelable data to the callee ability and obtains the agreed parcelable data returned by the callee ability.|
| 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
@@ -348,16 +348,15 @@ The following describes how to implement multi-device collaboration through cros
For the callee ability, implement the callback to receive data and the methods to marshal and unmarshal data. When data needs to be received, use **on()** to register a listener. When data does not need to be received, use **off()** to deregister the listener.
1. Configure the launch type of the UIAbility.
+ Set **launchType** of the callee ability to **singleton** in the **module.json5** file.
- Set **launchType** of the callee ability to **singleton** in the **module.json5** file.
+ | JSON Field| Description|
+ | -------- | -------- |
+ | "launchType"| Ability launch type. Set this parameter to **singleton**.|
- | JSON Field| Description|
- | -------- | -------- |
- | "launchType"| Ability 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",
@@ -369,19 +368,18 @@ The following describes how to implement multi-device collaboration through cros
"visible": true
}]
```
-
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.
-
+ 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.
+
+
```ts
- export default class MySequenceable {
+ export default class MyParcelable {
num: number = 0;
str: string = "";
@@ -390,71 +388,69 @@ The following describes how to implement multi-device collaboration through cros
this.str = string;
}
- marshalling(messageParcel) {
- messageParcel.writeInt(this.num);
- messageParcel.writeString(this.str);
+ marshalling(messageSequence) {
+ messageSequence.writeInt(this.num);
+ messageSequence.writeString(this.str);
return true;
}
- unmarshalling(messageParcel) {
- this.num = messageParcel.readInt();
- this.str = messageParcel.readString();
+ 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 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
- const TAG: string = '[CalleeAbility]';
- const MSG_SEND_METHOD: string = 'CallSendMsg';
-
- function sendMsgCallback(data) {
- 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}]`);
-
- // Process the data.
- // Return the sequenceable data result to the caller ability.
- return new MySequenceable(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)}`);
- }
- }
+
+ In the following example, the **MSG_SEND_METHOD** listener is registered in **onCreate()** of the ability 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.
- onDestroy() {
- try {
- this.callee.off(MSG_SEND_METHOD);
- } catch (error) {
- console.error(TAG, `${MSG_SEND_METHOD} unregister failed with error ${JSON.stringify(error)}`);
- }
- }
- }
- ```
-
+ ```ts
+ const TAG: string = '[CalleeAbility]';
+ const MSG_SEND_METHOD: string = 'CallSendMsg';
+
+ function sendMsgCallback(data) {
+ console.info('CalleeSortFunc called');
+
+ // Obtain the parcelable data sent by the caller ability.
+ let receivedData = new MyParcelable(0, '');
+ data.readParcelable(receivedData);
+ console.info(`receiveData[${receivedData.num}, ${receivedData.str}]`);
+
+ // Process the data.
+ // Return the parcelable data result to the caller ability.
+ 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)}`);
+ }
+ }
+
+ onDestroy() {
+ try {
+ 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.
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.
-
+
```ts
async onButtonGetRemoteCaller() {
@@ -483,14 +479,14 @@ 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 callee ability.
+ 1. The parcelable data can be sent to the callee ability with or without a return value. The method and parcelable data must be consistent with those of the callee ability. The following example describes how to send data to the callee ability.
```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}`);
@@ -505,12 +501,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) {
@@ -521,8 +517,8 @@ The following describes how to implement multi-device collaboration through cros
6. Release the caller object.
- When the caller object is no longer required, use **release()** to release it.
-
+ When the caller object is no longer required, use **release()** to release it.
+
```ts
releaseCall() {
try {
diff --git a/en/application-dev/application-models/inputmethodextentionability.md b/en/application-dev/application-models/inputmethodextentionability.md
new file mode 100644
index 0000000000000000000000000000000000000000..9a025339cab6a5f555fd61b15597400b31affeb7
--- /dev/null
+++ b/en/application-dev/application-models/inputmethodextentionability.md
@@ -0,0 +1,366 @@
+# InputMethodExtensionAbility Development
+
+[InputMethodExtensionAbility](../reference/apis/js-apis-inputmethod-extension-ability.md) is an ExtensionAbility component of the inputMethod type that provides extension capabilities for the input method framework.
+
+InputMethodExtensionAbility can be started or connected by other application components to process transactions in the background based on the request of the caller.
+
+
+InputMethodExtensionAbility provides related capabilities through the [InputMethodExtensionContext](../reference/apis/js-apis-inputmethod-extension-context.md).
+
+
+## Implementing an Input Method Application
+
+InputMethodExtensionAbility provides the **onCreate()** and **onDestory()** callbacks, as described below. Override them as required.
+
+- **onCreate**
+
+ This callback is triggered when a service is created for the first time. You can perform initialization operations, for example, registering a common event listener.
+
+ > **NOTE**
+ >
+ > If a service has been created, starting it again does not trigger the **onCreate()** callback.
+
+- **onDestroy**
+
+ This callback is triggered when the service is no longer used and the instance is ready for destruction. You can clear resources in this callback, for example, deregister the listener.
+
+
+## How to Develop
+
+To implement an input method application, manually create an InputMethodExtensionAbility component in DevEco Studio. The procedure is as follows:
+
+In the **ets** directory of the target module, right-click and choose **New** > **Extention Ability** > **InputMethod** to a minimum template of InputMethodExtensionAbility.
+
+> **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.
+
+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.
+
+The minimum template contains four files: **KeyboardController.ts**, **InputMethodService.ts**, **Index.ets**, and **KeyboardKeyData.ts**. The file directory is as follows:
+
+```
+/src/main/
+├── ets/inputmethodextability
+│ └──model/KeyboardController.ts # Shows the keyboard.
+│ └──InputMethodService.ts # Customizes a class that inherits from InputMethodExtensionAbility and add the required lifecycle callbacks.
+│ └──pages
+│ └── Index.ets # Draws the keyboard and adds the input and deletion features.
+│ └── KeyboardKeyData.ts # Defines keyboard attributes.
+├── resources/base/profile/main_pages.json
+```
+
+## File Introduction
+
+1. **InputMethodService.ts** file:
+
+ In this file, add the dependency package for importing InputMethodExtensionAbility. Customize a class that inherits from InputMethodExtensionAbility and add the required lifecycle callbacks.
+
+ ```ts
+ import InputMethodExtensionAbility from '@ohos.InputMethodExtensionAbility';
+ import { KeyboardController } from './model/KeyboardController'
+
+ export default class InputDemoService extends InputMethodExtensionAbility {
+ private keyboardController: KeyboardController;
+
+ onCreate(want) {
+ this.keyboardController = new KeyboardController(this.context);
+ this.keyboardController.onCreate(); // Initialize the window and register an event listener for the input method framework.
+ }
+
+ onDestroy() {
+ console.log("onDestroy.");
+ this.context.destroy();
+ }
+ }
+ ```
+
+2. **KeyboardController.ts** file:
+
+ ```ts
+ import inputMethodEngine from '@ohos.inputMethodEngine';
+ import display from '@ohos.display';
+ import windowManager from '@ohos.window';
+
+ // Call the getInputMethodAbility API to obtain an instance, and then call the other APIs of the input method framework based on the instance.
+ globalThis.inputAbility = inputMethodEngine.getInputMethodAbility();
+
+ export class KeyboardController {
+ mContext; // Save the context attribute in InputMethodExtensionAbility.
+ WINDOW_TYPE_INPUT_METHOD_FLOAT = 2105; // Define the window type. The value 2105 indicates the input method window type, which is used to create an input method application window.
+ windowName = 'inputApp';
+ private windowHeight: number = 0;
+ private windowWidth: number = 0;
+ private nonBarPosition: number = 0;
+ private isWindowShowing: boolean = false;
+
+ constructor(context) {
+ this.mContext = context;
+ }
+
+ public onCreate(): void
+ {
+ this.initWindow(); // Initialize the window.
+ this.registerListener(); // Register an event listener for the input method framework.
+ }
+
+ public onDestroy(): void // Destroy the instance.
+ {
+ this.unRegisterListener(); // Deregister the event listener.
+ let win = windowManager.findWindow(this.windowName);
+ win.destroyWindow(); // Destroy the window.
+ this.mContext.terminateSelf(); // Terminate the InputMethodExtensionAbility service.
+ }
+
+ private initWindow(): void // Initialize the window.
+ {
+ let dis = display.getDefaultDisplaySync();
+ let dWidth = dis.width;
+ let dHeight = dis.height;
+ let keyHeightRate = 0.47;
+ let keyHeight = dHeight * keyHeightRate;
+ this.windowWidth = dWidth;
+ this.windowHeight = keyHeight;
+ this.nonBarPosition = dHeight - keyHeight;
+
+ let config = {
+ name: this.windowName,
+ windowType: this.WINDOW_TYPE_INPUT_METHOD_FLOAT,
+ ctx: this.mContext
+ }
+ windowManager.createWindow(config).then((win) => { // Create a window of the specified type.
+ win.resize(dWidth, keyHeight).then(() => {
+ win.moveWindowTo(0, this.nonBarPosition).then(() => {
+ win.setUIContent('pages/InputMethodExtAbility/Index').then(() => {
+ });
+ });
+ });
+ });
+ }
+
+ private registerListener(): void
+ {
+ this.registerInputListener(); // Register an event listener for the input method framework service.
+ globalThis.inputAbility.on('keyboardShow', () => {// Register an event listener for the keyboard .
+ if (this.isWindowShowing) {
+ return;
+ }
+ this.isWindowShowing = true;
+ this.showHighWindow(); // Show the window.
+ });
+ ...
+ // Register a listener for keyboard hiding.
+ }
+
+ private registerInputListener() { // Register a listener for the enabling and disabling events of the input method framework service.
+ globalThis.inputAbility.on('inputStart', (kbController, textInputClient) => {
+ globalThis.textInputClient = textInputClient; // This is an input method client instance, based on which you can call the functional APIs that the input method framework provides for the input method application.
+ globalThis.keyboardController = kbController;
+ })
+ globalThis.inputAbility.on('inputStop', (imeId) => {
+ if (imeId == "Bundle name/Ability name") {
+ this.onDestroy();
+ }
+ });
+ }
+
+ private unRegisterListener(): void
+ {
+ globalThis.inputAbility.off('inputStart');
+ globalThis.inputAbility.off('inputStop', () => {});
+ globalThis.inputAbility.off('keyboardShow');
+ }
+
+ private showHighWindow() {
+ let win = windowManager.findWindow(this.windowName)
+ win.resize(this.windowWidth, this.windowHeight).then(() => {
+ win.moveWindowTo(0, this.nonBarPosition).then(() => {
+ win.showWindow().then(() => {
+ this.isWindowShowing = false;
+ })
+ })
+ })
+ }
+ }
+ ```
+
+3. **KeyboardKeyData.ts** file:
+
+ In this file you can define the content displayed on the soft keyboard.
+
+ ```ts
+ export interface sourceListType {
+ content: string,
+ }
+
+ export let numberSourceListData: sourceListType[] = [
+ {
+ content: '1'
+ },
+ {
+ content: '2'
+ },
+ {
+ content: '3'
+ },
+ {
+ content: '4'
+ },
+ {
+ content: '5'
+ },
+ {
+ content: '6'
+ },
+ {
+ content: '7'
+ },
+ {
+ content: '8'
+ },
+ {
+ content: '9'
+ },
+ {
+ content: '0'
+ }
+ ]
+ ```
+
+4. **Index.ets** file:
+
+ This file describes the functions of keys. For example, the number keys print numbers in the text box, and the delete key deletes what's entered.
+
+ Add the path to this file to the **src** field in the **resources/base/profile/main_pages.json** file.
+
+ ```ets
+ import { numberSourceListData, sourceListType } from './keyboardKeyData'
+
+ @Component
+ struct keyItem {
+ private keyValue: sourceListType
+ @State keyBgc: string = "#fff"
+ @State keyFontColor: string = "#000"
+
+ build() {
+ Column() {
+ Flex({ direction: FlexDirection.Column,
+ alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
+ Text(this.keyValue.content).fontSize(20).fontColor(this.keyFontColor)
+ }
+ }
+ .backgroundColor(this.keyBgc)
+ .borderRadius(6)
+ .width("8%")
+ .height("65%")
+ .onTouch((event: TouchEvent) => {
+ if (event.type === TouchType.Down) {
+ globalThis.textInputClient.insertText(this.keyValue.content);
+ }
+ })
+ }
+ }
+
+ // Component used for deletion.
+ @Component
+ export struct deleteItem {
+ @State keyBgc: string = "#fff"
+ @State keyFontColor: string = "#000"
+
+ build() {
+ Column() {
+ Flex({ direction: FlexDirection.Column,
+ alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
+ Text("Delete").fontSize(20).fontColor(this.keyFontColor)
+ }
+ }
+ .backgroundColor(this.keyBgc)
+ .width("13%")
+ .borderRadius(6)
+ .onTouch((event: TouchEvent) => {
+ if (event.type === TouchType.Down) {
+ globalThis.textInputClient.deleteForward(1);
+ }
+ })
+ }
+ }
+
+ // Numeric keyboard
+ @Component
+ struct numberMenu {
+ private numberList: sourceListType[]
+
+ build() {
+ Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceEvenly }) {
+ Flex({ justifyContent: FlexAlign.SpaceBetween }) {
+ ForEach(this.numberList, (item: sourceListType) => { // First row on the numeric keyboard
+ keyItem({ keyValue: item })
+ }, (item: sourceListType) => item.content);
+ }
+ .padding({ top: "2%" })
+ .width("96%")
+ .height("25%")
+
+ Flex({ justifyContent: FlexAlign.SpaceBetween }) {
+ deleteItem()
+ }
+ .width("96%")
+ .height("25%")
+ }
+ }
+ }
+
+ @Entry
+ @Component
+ struct Index {
+ private numberList: sourceListType[] = numberSourceListData
+
+ build() {
+ Stack() {
+ Flex({
+ direction: FlexDirection.Column,
+ alignItems: ItemAlign.Center,
+ justifyContent: FlexAlign.End
+ }) {
+ Flex({
+ direction: FlexDirection.Column,
+ alignItems: ItemAlign.Center,
+ justifyContent: FlexAlign.SpaceBetween
+ }) {
+ numberMenu({
+ numberList: this.numberList
+ })
+ }
+ .align(Alignment.End)
+ .width("100%")
+ .height("75%")
+ }
+ .height("100%").align(Alignment.End).backgroundColor("#cdd0d7")
+ }
+ .position({ x: 0, y: 0 }).zIndex(99999)
+ }
+ }
+ ```
+
+ Register the InputMethodExtensionAbility in the [module.json5 file](../quick-start/module-configuration-file.md) corresponding to the target module. Set **type** to **"inputMethod"** and **srcEntrance** to the code path of the InputMethodExtensionAbility component.
+
+ ```ts
+ {
+ "module": {
+ // ...
+ "extensionAbilities": [
+ {
+ "description": "inputMethod",
+ "icon": "$media:icon",
+ "name": "InputMethodExtAbility",
+ "srcEntrance": "./ets/inputmethodextability/InputMethodService.ts",
+ "type": "inputMethod",
+ "visible": true,
+ }
+ ]
+ }
+ }
+ ```
+
+
+
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-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/serviceextensionability.md b/en/application-dev/application-models/serviceextensionability.md
index d64d884b1e3021193f63445913886830218df6e1..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](#implementing-a-background-service)
+- [Implementing a Background Service (for System Applications Only)](#implementing-a-background-service-for-system-applications-only)
-- [Starting a Background Service](#starting-a-background-service)
+- [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,9 +33,9 @@ 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
+## Implementing a Background Service (for System Applications Only)
-This feature applies only to system applications. [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.
+[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.
**Figure 1** ServiceExtensionAbility lifecycle

@@ -164,9 +164,9 @@ To implement a background service, manually create a ServiceExtensionAbility com
```
-## Starting a Background Service
+## Starting a Background Service (for System Applications Only)
-This feature applies only to system applications. 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.
+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.
> **NOTE**
>
diff --git a/en/application-dev/application-models/start-remote-pageability.md b/en/application-dev/application-models/start-remote-pageability.md
index 4e998a15d23d298bfdb402bd18ea0db2a9f819eb..36ee305b49698c1f6e6cf216174f77212f1d53e4 100644
--- a/en/application-dev/application-models/start-remote-pageability.md
+++ b/en/application-dev/application-models/start-remote-pageability.md
@@ -1,7 +1,7 @@
-# Starting a Remote PageAbility
+# Starting a Remote PageAbility (for System Applications Only)
-This feature applies only to system applications. The **startAbility()** method in the **featureAbility** class is used to start a remote PageAbility.
+The **startAbility()** method in the **featureAbility** class is used to start a remote PageAbility.
In addition to **'\@ohos.ability.featureAbility'**, you must import **'\@ohos.distributedHardware.deviceManager'**, which provides account-independent distributed device networking capabilities. Then you can use **getTrustedDeviceListSync** of the **DeviceManager** module to obtain the remote device ID and pass the remote device ID in the **want** parameter for starting the 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-intra-device-interaction.md b/en/application-dev/application-models/uiability-intra-device-interaction.md
index ac3c18e36de67e66e496a92da2269c063503ce7e..25f509e9032a3670664937307fe4691b6a09bc28 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](#using-ability-call-to-implement-uiability-interaction)
+- [Using Ability Call to Implement UIAbility Interaction (for System Applications Only)](#using-ability-call-to-implement-uiability-interaction-for-system-applications-only)
## Starting UIAbility in the Same Application
@@ -202,8 +204,7 @@ This section describes how to start the UIAbility of another application through
```
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).
@@ -307,6 +308,55 @@ If you want to obtain the return result when using implicit Want to start the UI
})
```
+## 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 tag](../quick-start/module-configuration-file.md#abilities) 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 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 ability-level context of the initiator UIAbility.
+this.context.startAbility(wantInfo, options).then(() => {
+ // ...
+}).catch((err) => {
+ // ...
+})
+```
+
+The display effect is shown below.
+
## Starting a Specified Page of UIAbility
@@ -422,9 +472,9 @@ In summary, when a UIAbility instance of application A has been created and the
> 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.
-## Using Ability Call to Implement UIAbility Interaction
+## Using Ability Call to Implement UIAbility Interaction (for System Applications Only)
-This feature applies only to system applications. 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.
+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.
The core API used for the ability call is **startAbilityByCall**, which differs from **startAbility** in the following ways:
@@ -449,9 +499,9 @@ Ability call is usually used in the following scenarios:
The following figure shows the ability call process.
-Figure 1 Ability call process
+ Figure 1 Ability 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.
@@ -476,8 +526,8 @@ The following table describes the main APIs used for the ability call. For detai
| 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.|
+| call(method: string, data: rpc.Parcelable): Promise<void> | Sends agreed parcelable data to the callee ability.|
+| callWithResult(method: string, data: rpc.Parcelable): Promise<rpc.MessageSequence> | Sends agreed parcelable data to the callee ability and obtains the agreed parcelable data returned by the callee ability.|
| release(): void | Releases the caller object.|
| on(type: "release", callback: OnReleaseCallback): void | Callback invoked when the caller object is released.|
@@ -495,37 +545,39 @@ For the callee ability, implement the callback to receive data and the methods t
1. Configure the ability launch type.
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
- }]
- ```
-
+
+
+ ```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 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.
-
+
+
```ts
- export default class MySequenceable {
+ export default class MyParcelable {
num: number = 0
str: string = ""
@@ -534,15 +586,15 @@ For the callee ability, implement the callback to receive data and the methods t
this.str = string
}
- marshalling(messageParcel) {
- messageParcel.writeInt(this.num)
- messageParcel.writeString(this.str)
+ marshalling(messageSequence) {
+ messageSequence.writeInt(this.num)
+ messageSequence.writeString(this.str)
return true
}
- unmarshalling(messageParcel) {
- this.num = messageParcel.readInt()
- this.str = messageParcel.readString()
+ unmarshalling(messageSequence) {
+ this.num = messageSequence.readInt()
+ this.str = messageSequence.readString()
return true
}
}
@@ -550,8 +602,7 @@ For the callee ability, implement the callback to receive data and the methods t
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 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 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';
@@ -559,14 +610,14 @@ For the callee ability, implement the callback to receive data and the methods t
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 caller ability.
+ 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 caller ability.
+ return new MyParcelable(receivedData.num + 1, `send ${receivedData.str} succeed`);
}
export default class CalleeAbility extends Ability {
@@ -588,7 +639,6 @@ For the callee ability, implement the callback to receive data and the methods t
}
```
-
### Accessing the Callee Ability
1. Import the **UIAbility** module.
@@ -598,9 +648,9 @@ For the callee ability, implement the callback to receive data and the methods t
```
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 **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.
+
```ts
// Register the onRelease() listener of the caller ability.
private regOnRelease(caller) {
diff --git a/en/application-dev/application-models/uiability-launch-type.md b/en/application-dev/application-models/uiability-launch-type.md
index 70c212ed46e769dbdf4e0c1fd347403c463f6004..5f2f21b1aff90a27e7307d82045941ec76b98475 100644
--- a/en/application-dev/application-models/uiability-launch-type.md
+++ b/en/application-dev/application-models/uiability-launch-type.md
@@ -17,13 +17,10 @@ The launch type of the UIAbility component refers to the state of the UIAbility
Each time [startAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability) is called, if a UIAbility instance of this type already exists in the application process, the instance is reused. Therefore, only one UIAbility instance of this type exists in the system, that is, displayed in **Recents**.
-**Figure 1** Demonstration effect in singleton mode
+**Figure 1** Demonstration effect in singleton mode
+
-
-
-> **NOTE**
->
-> Assume that the application already has a UIAbility instance created, and the launch type of the UIAbility instance is set to **singleton**. If [startAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability) is called again to start the 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.
+> **NOTE**
Assume that the application already has a UIAbility instance created, and the launch type of the UIAbility instance is set to **singleton**. If [startAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability) is called again to start the 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.
To use the singleton mode, set **launchType** in the [module.json5 configuration file](../quick-start/module-configuration-file.md) to **singleton**.
@@ -47,9 +44,8 @@ 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**.
@@ -73,14 +69,13 @@ To use the standard mode, set **launchType** in the [module.json5 configuration
The **specified** mode is used in some special scenarios. For example, in a document application, you want a document instance to be created each time you create a document, but you want to use the same document instance when you repeatedly open an existing document.
-**Figure 3** Demonstration effect in specified mode
+**Figure 3** Demonstration effect in specified mode
+
-
+For example, there are two UIAbility components: EntryAbility and SpecifiedAbility (with the launch type **specified**). You are required to start SpecifiedAbility from EntryAbility.
-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.
+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 +90,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.
@@ -121,10 +115,11 @@ For example, there are EntryAbility and SpecifiedAbility, and the launch type of
// ...
})
```
-
-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 +128,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 +136,17 @@ For example, there are EntryAbility and SpecifiedAbility, and the launch type of
}
}
```
-
- > **NOTE**
+
+ > **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 14cb5c4652749c97dd6e50c4232b6f65fb6feaab..7e31ab130df2ba9eaf959d1bfb3ddccfb7172480 100644
--- a/en/application-dev/application-models/uiability-overview.md
+++ b/en/application-dev/application-models/uiability-overview.md
@@ -3,9 +3,11 @@
## Overview
-UIAbility has the UI and is mainly used for user interaction.
+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. A UIAbility component can implement a functional module through multiple pages. Each UIAbility component instance corresponds to a mission in **Recents**.
+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).
+
+Each UIAbility component instance is displayed as a mission in Recents.
## Privacy Statement Configuration
@@ -32,8 +34,3 @@ To enable an application to properly use a UIAbility component, declare the UIAb
}
}
```
-
-> **NOTE**
->
-> For the ability composition, see [Adding an Ability to a Module](https://developer.harmonyos.com/en/docs/documentation/doc-guides-V3/ohos-adding-ability-0000001218280664-V3).
-
diff --git a/en/application-dev/application-models/windowextensionability.md b/en/application-dev/application-models/windowextensionability.md
new file mode 100644
index 0000000000000000000000000000000000000000..069897ad02435070ac470f5d2d3d528c76b417e8
--- /dev/null
+++ b/en/application-dev/application-models/windowextensionability.md
@@ -0,0 +1,112 @@
+# WindowExtensionAbility
+
+[WindowExtensionAbility](../reference/apis/js-apis-application-windowExtensionAbility.md) is a type of ExtensionAbility component that allows a system application to be embedded in and displayed over another application.
+
+
+The WindowExtensionAbility component must be used together with the [AbilityComponent](../reference/arkui-ts/ts-container-ability-component.md) to process services of the started application. WindowExtensionAbility is run in connection mode. A system application must use the AbilityComponent to start the WindowExtensionAbility component.
+
+Each ExtensionAbility has its own context. For WindowExtensionAbility,
+the context is [WindowExtensionContext](../reference/apis/js-apis-inner-application-windowExtensionContext.md).
+
+> **NOTE**
+>
+> **WindowExtensionAbility** is a system API. To embed a third-party application in another application and display it over the application, switch to the full SDK by following the instructions provided in [Guide to Switching to Full SDK](../../application-dev/quick-start/full-sdk-switch-guide.md).
+>
+
+
+## Setting an Embedded Ability (for System Applications Only)
+
+The **WindowExtensionAbility** class provides **onConnect()**, **onDisconnect()**, and **onWindowReady()** lifecycle callbacks, which can be overridden.
+
+- The **onWindowReady()** callback is invoked when a window is created for the ability.
+
+- The **onConnect()** callback is invoked when the AbilityComponent corresponding to the window connects to the ability.
+
+- The **onDisconnect()** callback is invoked when the AbilityComponent disconnects from the ability.
+
+
+**How to Develop**
+
+To implement an embedded application, manually create a WindowExtensionAbility in DevEco Studio as follows:
+
+1. In the **ets** directory of the **Module** project, right-click and choose **New > Directory** to create a directory named **WindowExtAbility**.
+
+2. Right-click the **WindowExtAbility** directory, and choose **New > TypeScript File** to create a file named **WindowExtAbility.ts**.
+
+3. Open the **WindowExtAbility.ts** file and import the dependency package of **WindowExtensionAbility**. Customize a class that inherits from **WindowExtensionAbility** and implement the **onWindowReady()**, **onConnect()**, and **onDisconnect()** lifecycle callbacks.
+
+ ```ts
+ import Extension from '@ohos.application.WindowExtensionAbility'
+
+ export default class WindowExtAbility extends Extension {
+ onWindowReady(window) {
+ window.loadContent('WindowExtAbility/pages/index1').then(() => {
+ window.getProperties().then((pro) => {
+ console.log("WindowExtension " + JSON.stringify(pro));
+ })
+ window.show();
+ })
+ }
+
+ onConnect(want) {
+ console.info('JSWindowExtension onConnect ' + want.abilityName);
+ }
+
+ onDisconnect(want) {
+ console.info('JSWindowExtension onDisconnect ' + want.abilityName);
+ }
+ }
+ ```
+
+4. Register the WindowExtensionAbility in the [module.json5 file](../quick-start/module-configuration-file.md) corresponding to the **Module** project. Set **type** to **"window"** and **srcEntrance** to the code path of the ExtensionAbility component.
+
+ ```json
+ {
+ "module": {
+ "extensionAbilities": [
+ {
+ "name": "WindowExtAbility",
+ "srcEntrance": "./ets/WindowExtAbility/WindowExtAbility.ts",
+ "icon": "$media:icon",
+ "description": "WindowExtension",
+ "type": "window",
+ "visible": true,
+ }
+ ],
+ }
+ }
+ ```
+
+
+## Starting an Embedded Ability (for System Applications Only)
+
+System applications can load the created WindowExtensionAbility through the AbilityComponent.
+
+**How to Develop**
+
+1. To connect to an embedded application, add the AbilityComponent to the corresponding pages in the DevEco Studio project.
+
+2. Set **bundleName** and **abilityName** in the AbilityComponent.
+
+3. Set the width and height. The sample code is as follows:
+
+```ts
+@Entry
+@Component
+struct Index {
+ @State message: string = 'Hello World'
+
+ build() {
+ Row() {
+ Column() {
+ AbilityComponent({ abilityName: "WindowExtAbility", bundleName: "com.example.WindowExtAbility"})
+ .width(500)
+ .height(500)
+ }
+ .width('100%')
+ }
+ .height('100%')
+ .backgroundColor(0x64BB5c)
+ }
+}
+```
diff --git a/en/application-dev/application-test/arkxtest-guidelines.md b/en/application-dev/application-test/arkxtest-guidelines.md
index bd82cae45fb4c673f014bcc13cfc02beb3853a2e..64edba5e9f4d4ebbd6b7bfbff44c4b01c8a67d4d 100644
--- a/en/application-dev/application-test/arkxtest-guidelines.md
+++ b/en/application-dev/application-test/arkxtest-guidelines.md
@@ -108,7 +108,7 @@ You write a UI test script based on the unit test framework, adding the invoking
In this example, the UI test script is written based on the preceding unit test script. First, add the dependency package, as shown below:
```js
-import {UiDriver,BY,UiComponent,MatchPattern} from '@ohos.uitest'
+import {Driver,ON,Component,MatchPattern} from '@ohos.uitest'
```
Then, write specific test code. Specifically, implement the click action on the started application page and add checkpoint check cases.
@@ -131,16 +131,16 @@ export default function abilityTest() {
expect(Ability.context.abilityInfo.name).assertEqual('EntryAbility');
})
//ui test code
- //init uidriver
- var driver = await UiDriver.create();
+ //init driver
+ var driver = await Driver.create();
await driver.delayMs(1000);
- //find button by text 'Next'
- var button = await driver.findComponent(BY.text('Next'));
+ //find button on text 'Next'
+ var button = await driver.findComponent(ON.text('Next'));
//click button
await button.click();
await driver.delayMs(1000);
//check text
- await driver.assertComponentExist(BY.text('after click'));
+ await driver.assertComponentExist(ON.text('after click'));
await driver.pressBack();
done();
})
@@ -195,14 +195,15 @@ The framework supports multiple test case execution modes, which are triggered b
| itName | Test case to be executed. | {itName} | -s itName testAttributeIt |
| timeout | Timeout interval for executing a test case. | Positive integer (unit: ms). If no value is set, the default value 5000 is used. | -s timeout 15000 |
| breakOnError | Whether to enable break-on-error mode. When this mode is enabled, the test execution process exits if a test assertion error or any other error occurs.| **true**/**false** (default value) | -s breakOnError true |
+| random | Whether to execute test cases in random sequence.| **true**/**false** (default value) | -s random true |
| testType | Type of the test case to be executed. | function, performance, power, reliability, security, global, compatibility, user, standard, safety, resilience| -s testType function |
| level | Level of the test case to be executed. | 0, 1, 2, 3, 4 | -s level 0 |
-| size | Size of the test case to be executed. | small, medium, large | -s size small |
+| size | Size of the test case to be executed. | small, medium, large | -s size small |
| stress | Number of times that the test case is executed. | Positive integer | -s stress 1000 |
**Running Commands**
-> Configure hdc-related environment variables, and then perform the following:
+> Before running commands in the CLI, make sure hdc-related environment variables have been configured.
- Open the CLI.
- Run the **aa test** commands.
diff --git a/en/application-dev/application-test/figures/Execute.PNG b/en/application-dev/application-test/figures/Execute.PNG
index ba96bdfdaf430249f3506153a45c6fe439eda5cc..0260b7983a13851dc1ef8e45928f952eb509a7d8 100644
Binary files a/en/application-dev/application-test/figures/Execute.PNG and b/en/application-dev/application-test/figures/Execute.PNG differ
diff --git a/en/application-dev/connectivity/Readme-EN.md b/en/application-dev/connectivity/Readme-EN.md
index 578e2a3c56c8a1f6cce377eb39ef9a7756d74491..7176cb8fb438cbe8beec5b36bdd290c0b01bbd1f 100755
--- a/en/application-dev/connectivity/Readme-EN.md
+++ b/en/application-dev/connectivity/Readme-EN.md
@@ -5,6 +5,10 @@
- [HTTP Data Request](http-request.md)
- [WebSocket Connection](websocket-connection.md)
- [Socket Connection](socket-connection.md)
+ - [Network Policy Management](net-policy-management.md)
+ - [Network Sharing](net-sharing.md)
+ - [Ethernet Connection](net-ethernet.md)
+ - [Network Connection Management](net-connection-manager.md)
- IPC & RPC
- [IPC & RPC Overview](ipc-rpc-overview.md)
- [IPC & RPC Development](ipc-rpc-development-guideline.md)
diff --git a/en/application-dev/connectivity/net-connection-manager.md b/en/application-dev/connectivity/net-connection-manager.md
new file mode 100644
index 0000000000000000000000000000000000000000..1eddb3b5bbe47cb4d02123986647955d0492629e
--- /dev/null
+++ b/en/application-dev/connectivity/net-connection-manager.md
@@ -0,0 +1,246 @@
+# Network Connection Management
+
+## Introduction
+The Network Connection Management module provides basic network management capabilities, including management of Wi-Fi/cellular/Ethernet connection priorities, network quality evaluation, subscription to network connection status changes, query of network connection information, and DNS resolution.
+
+> **NOTE**
+> To maximize the application running efficiency, most API calls are called asynchronously in callback or promise mode. The following code examples use the callback mode. For details about the APIs, see [sms API Reference](../reference/apis/js-apis-net-connection.md).
+
+## Basic Concepts
+- Producer: a provider of data networks, such as Wi-Fi, cellular, and Ethernet.
+- Consumer: a user of data networks, for example, an application or a system service.
+- Network probe: a mechanism used to detect the network availability to prevent the switch from an available network to an unavailable network. The probe type can be binding network detection, DNS detection, HTTP detection, or HTTPS detection.
+- Network selection: a mechanism used to select the optimal network when multiple networks coexist. It is triggered when the network status, network information, or network quality evaluation score changes.
+
+## **Constraints**
+- Programming language: C++ and JS
+- System: Linux kernel
+- The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+
+## When to Use
+Typical application scenarios of network connection management are as follows:
+- Subscribing to status changes of the specified network
+- Obtaining the list of all registered networks
+- Querying network connection information based on the data network
+- Resolving the domain name of a network to obtain all IP addresses
+
+The following describes the development procedure specific to each application scenario.
+## Available APIs
+For the complete list of APIs and example code, see [Network Connection Management](../reference/apis/js-apis-net-connection.md).
+
+| Type| API| Description|
+| ---- | ---- | ---- |
+| ohos.net.connection | function getDefaultNet(callback: AsyncCallback\): void; |Creates a **NetHandle** object that contains the **netId** of the default network. This API uses an asynchronous callback to return the result.|
+| ohos.net.connection | function getGlobalHttpProxy10+(callback: AsyncCallback\): void;| Obtains the global HTTP proxy for the network. This API uses an asynchronous callback to return the result.|
+| ohos.net.connection | function setGlobalHttpProxy10+(httpProxy: HttpProxy, callback: AsyncCallback): void;| Sets the global HTTP proxy for the network. This API uses an asynchronous callback to return the result.|
+| ohos.net.connection | function getAppNet9+(callback: AsyncCallback\): void;| Obtains a **NetHandle** object that contains the **netId** of the network bound to the application. This API uses an asynchronous callback to return the result.|
+| ohos.net.connection | function setAppNet9+(netHandle: NetHandle, callback: AsyncCallback\): void;| Binds an application to the specified network. The application can access the external network only through this network. This API uses an asynchronous callback to return the result.|
+| ohos.net.connection | function getDefaultNetSync9+(): NetHandle; |Obtains the default active data network in synchronous mode. You can use **getNetCapabilities** to obtain information such as the network type and capabilities.|
+| ohos.net.connection | function hasDefaultNet(callback: AsyncCallback\): void; |Checks whether the default network is available. This API uses an asynchronous callback to return the result.|
+| ohos.net.connection | function getAllNets(callback: AsyncCallback\>): void;| Obtains the list of **NetHandle** objects of the connected network. This API uses an asynchronous callback to return the result.|
+| ohos.net.connection | function getConnectionProperties(netHandle: NetHandle, callback: AsyncCallback\): void; |Obtains link information of the default network. This API uses an asynchronous callback to return the result.|
+| ohos.net.connection | function getNetCapabilities(netHandle: NetHandle, callback: AsyncCallback\): void; |Obtains the capability set of the default network. This API uses an asynchronous callback to return the result.|
+| ohos.net.connection | function isDefaultNetMetered9+(callback: AsyncCallback): void; |Checks whether the data traffic usage on the current network is metered. This API uses an asynchronous callback to return the result.|
+| ohos.net.connection | function reportNetConnected(netHandle: NetHandle, callback: AsyncCallback\): void;| Reports a **netAavailable** event to NetManager. If this API is called, the application considers that its network status (ohos.net.connection.NetCap.NET_CAPABILITY_VAILDATED) is inconsistent with that of NetManager. This API uses an asynchronous callback to return the result.|
+| ohos.net.connection | function reportNetDisconnected(netHandle: NetHandle, callback: AsyncCallback\): void;| Reports a **netAavailable** event to NetManager. If this API is called, the application considers that its network status (ohos.net.connection.NetCap.NET_CAPABILITY_VAILDATED) is inconsistent with that of NetManager. This API uses an asynchronous callback to return the result.|
+| ohos.net.connection | function getAddressesByName(host: string, callback: AsyncCallback\>): void; |Obtains all IP addresses of the specified network by resolving the domain name. This API uses an asynchronous callback to return the result.|
+| ohos.net.connection | function enableAirplaneMode(callback: AsyncCallback\): void; | Enables the airplane mode. This API uses an asynchronous callback to return the result.|
+| ohos.net.connection | function disableAirplaneMode(callback: AsyncCallback\): void;| Disables the airplane mode. This API uses an asynchronous callback to return the result.|
+| ohos.net.connection | function createNetConnection(netSpecifier?: NetSpecifier, timeout?: number): NetConnection; | Creates a **NetConnection** object. **netSpecifier** specifies the network, and **timeout** specifies the timeout interval in ms. **timeout** is configurable only when **netSpecifier** is specified. If neither of them is present, the default network is used.|
+| ohos.net.connection.NetHandle | bindSocket(socketParam: TCPSocket \| UDPSocket, callback: AsyncCallback\): void; | Binds a **TCPSocket** or **UDPSocket** to the current network. This API uses an asynchronous callback to return the result.|
+| ohos.net.connection.NetHandle | getAddressesByName(host: string, callback: AsyncCallback\>): void; |Obtains all IP addresses of the default network by resolving the domain name. This API uses an asynchronous callback to return the result.|
+| ohos.net.connection.NetHandle | getAddressByName(host: string, callback: AsyncCallback\): void; |Obtains an IP address of the specified network by resolving the domain name. This API uses an asynchronous callback to return the result.|
+| ohos.net.connection.NetConnection | on(type: 'netAvailable', callback: Callback\): void; |Subscribes to **netAvailable** events.|
+| ohos.net.connection.NetConnection | on(type: 'netCapabilitiesChange', callback: Callback\<{ netHandle: NetHandle, netCap: NetCapabilities }>): void; |Subscribes to **netCapabilitiesChange** events.|
+| ohos.net.connection.NetConnection | on(type: 'netConnectionPropertiesChange', callback: Callback\<{ netHandle: NetHandle, connectionProperties: ConnectionProperties }>): void; |Subscribes to **netConnectionPropertiesChange** events.|
+| ohos.net.connection.NetConnection | on(type: 'netBlockStatusChange', callback: Callback<{ netHandle: NetHandle, blocked: boolean }>): void; |Subscribes to **netBlockStatusChange** events.|
+| ohos.net.connection.NetConnection | on(type: 'netLost', callback: Callback\): void; |Subscribes to **netLost** events.|
+| ohos.net.connection.NetConnection | on(type: 'netUnavailable', callback: Callback\): void; |Subscribes to **netUnavailable** events.|
+| ohos.net.connection.NetConnection | register(callback: AsyncCallback\): void; |Registers an observer for the default network or the network specified in **createNetConnection**.|
+| ohos.net.connection.NetConnection | unregister(callback: AsyncCallback\): void; |Unregisters the observer for the default network or the network specified in **createNetConnection**.|
+
+## Subscribing to Status Changes of the Specified Network
+
+1. Import the connection namespace from **@ohos.net.connection.d.ts**.
+
+2. Call **createNetConnection()** to create a **NetConnection** object. You can specify the network type, capability, and timeout interval. If you do not specify parameters, the default values will be used.
+
+3. Call **conn.on()** to subscribe to the target event. You must pass in **type** and **callback**.
+
+4. Call **conn.register()** to subscribe to network status changes of the specified network.
+
+5. When the network is available, the callback will be invoked to return the **netAvailable** event. When the network is unavailable, the callback will be invoked to return the **netUnavailable** event.
+
+6. Call **conn.unregister()** to unsubscribe from the network status changes if required.
+
+```js
+ // Import the connection namespace.
+ import connection from '@ohos.net.connection'
+
+ let netCap = {
+ // Assume that the default network is Wi-Fi. If you need to create a cellular network connection, set the network type to CELLULAR.
+ bearerTypes: [connection.NetBearType.BEARER_CELLULAR],
+ // Set the network capability to INTERNET.
+ networkCap: [connection.NetCap.NET_CAPABILITY_INTERNET],
+ };
+ let netSpec = {
+ netCapabilities: netCap,
+ };
+
+ // Set the timeout value to 10s. The default value is 0.
+ let timeout = 10 * 1000;
+
+ // Create a NetConnection object.
+ let conn = connection.createNetConnection(netSpec, timeout);
+
+ // Listen to network status change events. If the network is available, an on_netAvailable event is returned.
+ conn.on('netAvailable', (data=> {
+ console.log("net is available, netId is " + data.netId);
+ }));
+
+ // Listen to network status change events. If the network is unavailable, an on_netUnavailable event is returned.
+ conn.on('netUnavailable', (data=> {
+ console.log("net is unavailable, netId is " + data.netId);
+ }));
+
+ // Register an observer for network status changes.
+ conn.register((err, data) => {});
+
+ // Unregister the observer for network status changes.
+ conn.unregister((err, data) => {});
+```
+
+## Obtaining the List of All Registered Networks
+
+### How to Develop
+
+1. Import the connection namespace from **@ohos.net.connection.d.ts**.
+
+2. Call **getAllNets** to obtain the list of all connected networks.
+
+```js
+ // Import the connection namespace.
+ import connection from '@ohos.net.connection'
+
+ // Obtain the list of all connected networks.
+ connection.getAllNets((err, data) => {
+ console.log(JSON.stringify(err));
+ console.log(JSON.stringify(data));
+ if (data) {
+ this.netList = data;
+ }
+ })
+```
+
+## Querying Network Capability Information and Connection Information of Specified Data Network
+
+### How to Develop
+
+1. Import the connection namespace from **@ohos.net.connection.d.ts**.
+
+2. Call **getDefaultNet** to obtain the default data network via **NetHandle** or call **getAllNets** to obtain the list of all connected networks via **Array\**.
+
+3. Call **getNetCapabilities** to obtain the network capability information of the data network specified by **NetHandle**. The capability information includes information such as the network type (cellular, Wi-Fi, or Ethernet network) and the specific network capabilities.
+
+4. Call **getConnectionProperties** to obtain the connection information of the data network specified by **NetHandle**.
+
+```js
+ // Import the connection namespace.
+ import connection from '@ohos.net.connection'
+
+ // Call getDefaultNet to obtain the default data network specified by **NetHandle**.
+ connection.getDefaultNet((err, data) => {
+ console.log(JSON.stringify(err));
+ console.log(JSON.stringify(data));
+ if (data) {
+ this.netHandle = data;
+ }
+ })
+
+ // Obtain the network capability information of the data network specified by **NetHandle**. The capability information includes information such as the network type and specific network capabilities.
+ connection.getNetCapabilities(this.netHandle, (err, data) => {
+ console.log(JSON.stringify(err));
+
+ // Obtain the network type via bearerTypes.
+ for (let item of data.bearerTypes) {
+ if (item == 0) {
+ // Cellular network
+ console.log(JSON.stringify("BEARER_CELLULAR"));
+ } else if (item == 1) {
+ // Wi-Fi network
+ console.log(JSON.stringify("BEARER_WIFI"));
+ } else if (item == 3) {
+ // Ethernet network
+ console.log(JSON.stringify("BEARER_ETHERNET"));
+ }
+ }
+
+ // Obtain the specific network capabilities via networkCap.
+ for (let item of data.networkCap) {
+ if (item == 0) {
+ // The network can connect to the carrier's Multimedia Messaging Service Center (MMSC) to send and receive multimedia messages.
+ console.log(JSON.stringify("NET_CAPABILITY_MMS"));
+ } else if (item == 11) {
+ // The network traffic is not metered.
+ console.log(JSON.stringify("NET_CAPABILITY_NOT_METERED"));
+ } else if (item == 12) {
+ // The network has the Internet access capability, which is set by the network provider.
+ console.log(JSON.stringify("NET_CAPABILITY_INTERNET"));
+ } else if (item == 15) {
+ // The network does not use a Virtual Private Network (VPN).
+ console.log(JSON.stringify("NET_CAPABILITY_NOT_VPN"));
+ } else if (item == 16) {
+ // The Internet access capability of the network is successfully verified by the connection management module.
+ console.log(JSON.stringify("NET_CAPABILITY_VALIDATED"));
+ }
+ }
+ })
+
+ // Obtain the connection information of the data network specified by NetHandle. Connection information includes link and route information.
+ connection.getConnectionProperties(this.netHandle, (err, data) => {
+ console.log(JSON.stringify(err));
+ console.log(JSON.stringify(data));
+ })
+
+ // Call getAllNets to obtain the list of all connected networks via Array.
+ connection.getAllNets((err, data) => {
+ console.log(JSON.stringify(err));
+ console.log(JSON.stringify(data));
+ if (data) {
+ this.netList = data;
+ }
+ })
+
+ for (let item of this.netList) {
+ // Obtain the network capability information of the network specified by each netHandle on the network list cyclically.
+ connection.getNetCapabilities(item, (err, data) => {
+ console.log(JSON.stringify(err));
+ console.log(JSON.stringify(data));
+ })
+
+ // Obtain the connection information of the network specified by each netHandle on the network list cyclically.
+ connection.getConnectionProperties(item, (err, data) => {
+ console.log(JSON.stringify(err));
+ console.log(JSON.stringify(data));
+ })
+ }
+```
+
+## Resolving the domain name of a network to obtain all IP addresses
+
+### How to Develop
+
+1. Import the connection namespace from **@ohos.net.connection.d.ts**.
+
+2. Call **getAddressesByName** to use the default network to resolve the host name to obtain the list of all IP addresses.
+
+```js
+ // Import the connection namespace.
+ import connection from '@ohos.net.connection'
+
+ // Use the default network to resolve the host name to obtain the list of all IP addresses.
+ connection.getAddressesByName(this.host, (err, data) => {
+ console.log(JSON.stringify(err));
+ console.log(JSON.stringify(data));
+ })
+```
diff --git a/en/application-dev/connectivity/net-ethernet.md b/en/application-dev/connectivity/net-ethernet.md
new file mode 100644
index 0000000000000000000000000000000000000000..85c4ef4fc15f4c2228eb8351ddb5cd730ff5fe94
--- /dev/null
+++ b/en/application-dev/connectivity/net-ethernet.md
@@ -0,0 +1,140 @@
+# Ethernet Connection
+
+## Introduction
+The Ethernet Connection module allows a device to access the Internet through a network cable.
+After a device is connected to the Ethernet through a network cable, the device can obtain a series of network attributes, such as the dynamically allocated IP address, subnet mask, gateway, and DNS. You can manually configure and obtain the network attributes of the device in static mode.
+
+> **NOTE**
+> To maximize the application running efficiency, most API calls are called asynchronously in callback or promise mode. The following code examples use the callback mode. For details about the APIs, see [sms API Reference](../reference/apis/js-apis-net-ethernet.md).
+
+## **Constraints**
+- Programming language: C++ and JS
+- System: Linux kernel
+- 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.
+
+## When to Use
+Typical application scenarios of Ethernet connection are as follows:
+- Dynamically assigning a series of network attributes, such as the IP address, subnet mask, gateway, and DNS in DHCP mode to enable network access
+- Configuring a series of network attributes, such as the IP address, subnet mask, gateway, and DNS, in static mode to enable network access.
+
+The following describes the development procedure specific to each application scenario.
+
+## Available APIs
+For the complete list of APIs and example code, see [Ethernet Connection](../reference/apis/js-apis-net-ethernet.md).
+
+| Type| API| Description|
+| ---- | ---- | ---- |
+| ohos.net.ethernet | function setIfaceConfig(iface: string, ic: InterfaceConfiguration, callback: AsyncCallback\): void | Configures the network attributes of the specified Ethernet network. This API uses an asynchronous callback to return the result.|
+| ohos.net.ethernet | function getIfaceConfig(iface: string, callback: AsyncCallback\): void | Obtains the network attributes of the specified Ethernet network. This API uses an asynchronous callback to return the result.|
+| ohos.net.ethernet | function isIfaceActive(iface: string, callback: AsyncCallback\): void | Checks whether the specified network port is active. This API uses an asynchronous callback to return the result.|
+| ohos.net.ethernet | function getAllActiveIfaces(callback: AsyncCallback\>): void; | Obtains the list of all active network ports. This API uses an asynchronous callback to return the result.|
+
+## Ethernet Connection – DHCP Mode
+
+1. Use a network cable to connect the device to a network port.
+2. Import the **ethernet** namespace from **@ohos.net.ethernet**.
+3. Call **getAllActiveIfaces** to obtain the list of all active network ports, for example, **eth0** and **eth1**.
+4. Call **isIfaceActive** in user mode to check whether the **eth0** port is active.
+5. Call **getIfaceConfig** in user mode to obtain the static network attributes of the **eth0** port. By default, an unconfigured Ethernet network uses the DHCP mode, in which the Ethernet network obtains the automatically assigned network attributes.
+
+```js
+ // Import the ethernet namespace from @ohos.net.ethernet.
+ import ethernet from '@ohos.net.ethernet'
+
+ // Call getAllActiveIfaces to obtain the list of all active network ports.
+ ethernet.getAllActiveIfaces((error, data) => {
+ if (error) {
+ console.log("getAllActiveIfaces callback error = " + error);
+ } else {
+ console.log("getAllActiveIfaces callback data.length = " + data.length);
+ for (let i = 0; i < data.length; i++) {
+ console.log("getAllActiveIfaces callback = " + data[i]);
+ }
+ }
+ });
+
+ // Call isIfaceActive to check whether the specified network port is active.
+ ethernet.isIfaceActive("eth0", (error, data) => {
+ if (error) {
+ console.log("isIfaceActive callback error = " + error);
+ } else {
+ console.log("isIfaceActive callback = " + data);
+ }
+ });
+
+ // Call getIfaceConfig to obtain the network attributes of the specified Ethernet network.
+ ethernet.getIfaceConfig("eth0", (error, data) => {
+ if (error) {
+ console.log("getIfaceConfig callback error = " + error);
+ } else {
+ console.log("getIfaceConfig callback mode = " + data.mode);
+ console.log("getIfaceConfig callback ipAddr = " + data.ipAddr);
+ console.log("getIfaceConfig callback routeAddr = " + data.routeAddr);
+ console.log("getIfaceConfig callback gateAddr = " + data.gateAddr);
+ console.log("getIfaceConfig callback maskAddr = " + data.maskAddr);
+ console.log("getIfaceConfig callback dns0Addr = " + data.dns0Addr);
+ console.log("getIfaceConfig callback dns1Addr = " + data.dns1Addr);
+ }
+ });
+```
+## Ethernet Connection – Static Mode
+
+### How to Develop
+
+1. Use a network cable to connect the device to a network port.
+2. Import the **ethernet** namespace from **@ohos.net.ethernet**.
+3. Call **getAllActiveIfaces** in user mode to obtain the list of all active network ports, for example, **eth0** and **eth1**.
+4. Call **isIfaceActive** in user mode to check whether the **eth0** port is active.
+5. Call **setIfaceConfig** in user mode to set the **eth0** port to the static mode, in which you need to manually assign the network attributes (including the IP address, subnet mask, gateway, and DNS).
+6. Call **getIfaceConfig** in user mode to obtain the static network attributes of the **eth0** port.
+
+```js
+ // Import the ethernet namespace from @ohos.net.ethernet.
+ import ethernet from '@ohos.net.ethernet'
+
+ // Call getAllActiveIfaces to obtain the list of all active network ports.
+ ethernet.getAllActiveIfaces((error, data) => {
+ if (error) {
+ console.log("getAllActiveIfaces callback error = " + error);
+ } else {
+ console.log("getAllActiveIfaces callback data.length = " + data.length);
+ for (let i = 0; i < data.length; i++) {
+ console.log("getAllActiveIfaces callback = " + data[i]);
+ }
+ }
+ });
+
+ // Call isIfaceActive to check whether the specified network port is active.
+ ethernet.isIfaceActive("eth0", (error, data) => {
+ if (error) {
+ console.log("isIfaceActive callback error = " + error);
+ } else {
+ console.log("isIfaceActive callback = " + data);
+ }
+ });
+
+ // Call setIfaceConfig to configure the network attributes of the specified Ethernet network.
+ ethernet.setIfaceConfig("eth0", {mode:ethernet.STATIC,ipAddr:"192.168.xx.xx", routeAddr:"192.168.xx.xx",
+ gateAddr:"192.168.xx.xx", maskAddr:"255.255.xx.xx", dnsAddr0:"1.1.xx.xx", dnsAddr1:"2.2.xx.xx"},(error) => {
+ if (error) {
+ console.log("setIfaceConfig callback error = " + error);
+ } else {
+ console.log("setIfaceConfig callback ok ");
+ }
+ });
+
+ // Call getIfaceConfig to obtain the network attributes of the specified Ethernet network.
+ ethernet.getIfaceConfig("eth0", (error, data) => {
+ if (error) {
+ console.log("getIfaceConfig callback error = " + error);
+ } else {
+ console.log("getIfaceConfig callback mode = " + data.mode);
+ console.log("getIfaceConfig callback ipAddr = " + data.ipAddr);
+ console.log("getIfaceConfig callback routeAddr = " + data.routeAddr);
+ console.log("getIfaceConfig callback gateAddr = " + data.gateAddr);
+ console.log("getIfaceConfig callback maskAddr = " + data.maskAddr);
+ console.log("getIfaceConfig callback dns0Addr = " + data.dns0Addr);
+ console.log("getIfaceConfig callback dns1Addr = " + data.dns1Addr);
+ }
+ });
+```
diff --git a/en/application-dev/connectivity/net-mgmt-overview.md b/en/application-dev/connectivity/net-mgmt-overview.md
index 3c8eeb552b811344396afcc6e5316e5daa24ee8b..0ad30c35cc9b4d5e90b2c8fe90cac7ca2e413a57 100644
--- a/en/application-dev/connectivity/net-mgmt-overview.md
+++ b/en/application-dev/connectivity/net-mgmt-overview.md
@@ -2,15 +2,19 @@
Network management functions include:
-- [HTTP Data Request](http-request.md): Initiates a data request through HTTP.
-- [WebSocket Connection](websocket-connection.md): Establishes a bidirectional connection between the server and client through WebSocket.
-- [Socket Connection](socket-connection.md): Transmits data through Socket.
+- [HTTP data request](http-request.md): Initiates a data request through HTTP.
+- [WebSocket connection](websocket-connection.md): Establishes a bidirectional connection between the server and client through WebSocket.
+- [Socket connection](socket-connection.md): Transmits data through Socket.
+- [Network policy management](net-policy-management.md): Restricts network capabilities by setting network policies, including cellular network policy, sleep/power-saving mode policy, and background network policy, and resets network policies as needed.
+- [Network sharing](net-sharing.md): Shares a device's Internet connection with other connected devices by means of Wi-Fi hotspot, Bluetooth, and USB sharing, and queries the network sharing state and shared mobile data volume.
+- [Ethernet connection](net-ethernet.md): Provides wired network capabilities, which allow you to set the IP address, subnet mask, gateway, and Domain Name System (DNS) server of a wired network.
+- [Network connection management](net-connection-manager.md): Provides basic network management capabilities, including management of Wi-Fi/cellular/Ethernet connection priorities, network quality evaluation, subscription to network connection status changes, query of network connection information, and DNS resolution.
## Constraints
To use the functions of the network management module, you must obtain the permissions listed in the following table.
-| Permission | Description |
+| Permission | Description |
| -------------------------------- | -------------------------------------- |
| ohos.permission.GET_NETWORK_INFO | Allows an application to obtain the network connection information. |
| ohos.permission.SET_NETWORK_INFO | Allows an application to modify the network connection state. |
diff --git a/en/application-dev/connectivity/net-policy-management.md b/en/application-dev/connectivity/net-policy-management.md
new file mode 100644
index 0000000000000000000000000000000000000000..6450bd671e565fdffafb7eeed499e123893a45a3
--- /dev/null
+++ b/en/application-dev/connectivity/net-policy-management.md
@@ -0,0 +1,402 @@
+# Network Policy Management
+
+## Introduction
+
+The Network Policy Management module allows you to restrict network capabilities by setting network policies, including cellular network policy, sleep/power-saving mode policy, and background network policy, and to reset network policies as needed.
+
+> **NOTE**
+> To maximize the application running efficiency, most API calls are called asynchronously in callback or promise mode. The following code examples use the callback mode. For details about the APIs, see [sms API Reference](../reference/apis/js-apis-net-policy.md).
+
+## Basic Concepts
+
+- Sleep mode: A mode in which the system shuts down some idle components and peripherals to enter the low-power mode and restricts some applications from accessing the network.
+- Power-saving mode: A mode in which the system disables certain functions and features to save power. When this mode is enabled, the system performance deteriorates and some applications are restricted from accessing the network.
+- Traffic-saving mode: A mode in which the system restricts background applications that use the metering network. It is equivalent to the background network policy.
+- Cellular network: A mobile communication network.
+- Metering network: A mobile network with preconfigured traffic quota, WLAN network, or Ethernet network.
+
+## **Constraints**
+
+- Programming language: C++ and JS
+- System: Linux kernel
+- 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.
+
+## When to Use
+
+Typical application scenarios of network policy management are as follows:
+
+- Managing the metering network policy: Set the metering network quota and obtain the configured metering network policy.
+- Managing network access for an application in the background: Set and obtain the status of the background network restriction switch, and check whether the application indicated by the specified UID can access the network in the background.
+- Managing the metering network access policy: Set and obtain the policy for the application indicated by the specified UID to access the metering network, and obtain the UIDs of the applications for which the policy is configured.
+- Restoring network policies
+- Checking whether an application indicated by the specified UID can access a metering or non-metering network
+- Adding a UID to or removing a UID from the sleep mode allowlist, and obtaining the sleep mode allowlist
+- Adding a UID to or removing a UID from the power-saving mode allowlist, and obtaining the power-saving mode allowlist
+- Updating the network notification policy
+
+The following describes the development procedure specific to each application scenario.
+
+## Available APIs
+
+For the complete list of APIs and example code, see [Network Policy Management](../reference/apis/js-apis-net-policy.md).
+
+| Type| API| Description|
+| ---- | ---- | ---- |
+| ohos.net.policy | function setBackgroundPolicy(isAllowed: boolean, callback: AsyncCallback\): void |Sets a background network policy. This API uses an asynchronous callback to return the result.|
+| ohos.net.policy | function isBackgroundAllowed(callback: AsyncCallback\): void; |Obtains the background network policy. This API uses an asynchronous callback to return the result.|
+| ohos.net.policy | function setPolicyByUid(uid: number, policy: NetUidPolicy, callback: AsyncCallback\): void; |Sets an application-specific network policy by **uid**. This API uses an asynchronous callback to return the result.|
+| ohos.net.policy | function getPolicyByUid(uid: number, callback: AsyncCallback\): void;| Obtains an application-specific network policy by **uid**. This API uses an asynchronous callback to return the result.|
+| ohos.net.policy | function getUidsByPolicy(policy: NetUidPolicy, callback: AsyncCallback\>): void; | Obtains the UID array of applications configured with a certain application-specific network policy. This API uses an asynchronous callback to return the result.|
+| ohos.net.policy | function getNetQuotaPolicies(callback: AsyncCallback\>): void; |Obtains the network quota policies. This API uses an asynchronous callback to return the result.|
+| ohos.net.policy | function setNetQuotaPolicies(quotaPolicies: Array\, callback: AsyncCallback\): void; |Sets an array of network quota policies. This API uses an asynchronous callback to return the result.|
+| ohos.net.policy | function restoreAllPolicies(iccid: string, callback: AsyncCallback\): void; | Restores all the policies (cellular network, background network, firewall, and application-specific network policies) for the given SIM card. This API uses an asynchronous callback to return the result.|
+| ohos.net.policy | function isUidNetAllowed(uid: number, isMetered: boolean, callback: AsyncCallback\): void; | Checks whether an application is allowed to access metering or non-metering networks. This API uses an asynchronous callback to return the result.|
+| ohos.net.policy | function isUidNetAllowed(uid: number, iface: string, callback: AsyncCallback\): void; | Checks whether an application is allowed to access the given network. This API uses an asynchronous callback to return the result.|
+| ohos.net.policy | function setDeviceIdleAllowList(uid: number, isAllowed: boolean, callback: AsyncCallback\): void; | Sets whether to add an application to the device idle allowlist. This API uses an asynchronous callback to return the result.|
+| ohos.net.policy | function getDeviceIdleAllowList(callback: AsyncCallback\>): void; | Obtains the UID array of applications that are on the device idle allowlist. This API uses an asynchronous callback to return the result.|
+| ohos.net.policy | function getBackgroundPolicyByUid(uid: number, callback: AsyncCallback\): void; | Obtains the background network policies configured for the given application. This API uses an asynchronous callback to return the result.|
+| ohos.net.policy | function resetPolicies(iccid: string, callback: AsyncCallback\): void; | Restores all the policies (cellular network, background network, firewall, and application-specific network policies) for the given SIM card. This API uses an asynchronous callback to return the result.|
+| ohos.net.policy | function updateRemindPolicy(netType: NetBearType, iccid: string, remindType: RemindType, callback: AsyncCallback\): void; | Updates a reminder policy. This API uses an asynchronous callback to return the result.|
+| ohos.net.policy | function setPowerSaveAllowList(uid: number, isAllowed: boolean, callback: AsyncCallback\): void; | Sets whether to add an application to the power-saving allowlist. This API uses an asynchronous callback to return the result.|
+| ohos.net.policy | function getPowerSaveAllowList(callback: AsyncCallback\>): void; | Obtains the UID array of applications that are on the power-saving allowlist. This API uses an asynchronous callback to return the result.|
+| ohos.net.policy | function on(type: "netUidPolicyChange", callback: Callback\<{ uid: number, policy: NetUidPolicy }>): void; | Subscribes to policy changes. This API uses an asynchronous callback to return the result.|
+| ohos.net.policy | function off(type: "netUidPolicyChange", callback: Callback\<{ uid: number, policy: NetUidPolicy }>): void; | Unsubscribes from policy changes. This API uses an asynchronous callback to return the result.|
+| ohos.net.policy | function on(type: "netUidRuleChange", callback: Callback\<{ uid: number, rule: NetUidRule }>): void; | Subscribes to rule changes. This API uses an asynchronous callback to return the result.|
+| ohos.net.policy | function off(type: "netUidRuleChange", callback: Callback\<{ uid: number, rule: NetUidRule }>): void; | Unsubscribes from rule changes. This API uses an asynchronous callback to return the result.|
+| ohos.net.policy | function on(type: "netMeteredIfacesChange", callback: Callback\>): void; | Subscribes to metered **iface** changes. This API uses an asynchronous callback to return the result.|
+| ohos.net.policy | function off(type: "netMeteredIfacesChange", callback: Callback\>): void; | Unsubscribes from metered **iface** changes. This API uses an asynchronous callback to return the result.|
+| ohos.net.policy | function on(type: "netQuotaPolicyChange", callback: Callback\>): void; | Subscribes to network quota policy changes. This API uses an asynchronous callback to return the result.|
+| ohos.net.policy | function off(type: "netQuotaPolicyChange", callback: Callback\>): void; | Unsubscribes from network quota policy changes. This API uses an asynchronous callback to return the result.|
+| ohos.net.policy | function on(type: "netBackgroundPolicyChange", callback: Callback\): void; | Subscribes to background network policy changes. This API uses an asynchronous callback to return the result.|
+| ohos.net.policy | function off(type: "netBackgroundPolicyChange", callback: Callback\): void; | Unsubscribes from background network policy changes. This API uses an asynchronous callback to return the result.|
+
+## Managing the Metering Network Policy
+
+1. Import the **policy** namespace from **@ohos.net.policy.d.ts**.
+
+2. Call **setNetQuotaPolicies** to configure the metering network policy.
+
+3. Call **getNetQuotaPolicies** to obtain the configured metering network policy.
+
+```js
+ // Import the policy namespace.
+ import policy from '@ohos.net.policy';
+
+ addNetQuotaPolicy(){
+ let param = {
+ // For details about the value of netType, see [NetBearType](../reference/apis/js-apis-net-connection.md#netbeartype).
+ netType:Number.parseInt(this.netType),
+
+ // Integrated circuit card identifier (ICCID) of the SIM card on the metering cellular network. It is not available for an Ethernet or Wi-Fi network.
+ iccid:this.iccid,
+
+ // Used together with ICCID on the metering cellular network. It is used independently on an Ethernet or Wi-Fi network.
+ ident:this.ident,
+
+ // Metering start time, for example, M1, D1, and Y1.
+ periodDuration:this.periodDuration,
+
+ // Set the traffic threshold for generating an alarm to an integer greater than 0.
+ warningBytes:Number.parseInt(this.warningBytes),
+
+ // Set the traffic quota to an integer greater than 0.
+ limitBytes:Number.parseInt(this.limitBytes),
+
+ // Specify whether the network is a metering network. The value true means a metering network and false means a non-metering network.
+ metered:Boolean(Number.parseInt(this.metered)),https://gitee.com/openharmony/docs/pulls/14404
+ // For details about the action triggered after the traffic limit is reached, see [LimitAction](../reference/apis/js-apis-net-policy.md#limitaction).
+ limitAction:Number.parseInt(this.limitAction)
+ };
+ this.netQuotaPolicyList.push(param);
+ },
+
+ // Subscribe to metered iface changes.
+ policy.on('netMeteredIfacesChange', (data) => {
+ this.log('on netMeteredIfacesChange: ' + JSON.stringify(data));
+ });
+
+ // Subscribe to metering network policy changes.
+ policy.on('netQuotaPolicyChange', (data) => {
+ this.log('on netQuotaPolicyChange: ' + JSON.stringify(data));
+ });
+
+ // Call setNetQuotaPolicies to configure the metering network policy.
+ setNetQuotaPolicies(){
+ this.dialogType = DialogType.HIDE;
+ policy.setNetQuotaPolicies(this.netQuotaPolicyList, (err, data) => {
+ console.log(JSON.stringify(err));
+ console.log(JSON.stringify(data));
+ });
+ },
+
+ // Call getNetQuotaPolicies to obtain the configured metering network policy.
+ getNetQuotaPolicies(){
+ policy.getNetQuotaPolicies((err, data) => {
+ this.callBack(err, data);
+ if(data){
+ this.netQuotaPolicyList = data;
+ }
+ });
+ },
+
+ // Unsubscribe from metered iface changes.
+ policy.off('netMeteredIfacesChange', (data) => {
+ this.log('off netMeteredIfacesChange: ' + JSON.stringify(data));
+ });
+
+ // Unsubscribe from metering network policy changes.
+ policy.off('netQuotaPolicyChange', (data) => {
+ this.log('off netQuotaPolicyChange: ' + JSON.stringify(data));
+ });
+```
+
+## Managing Network Access for an Application in the Background
+
+### How to Develop
+
+1. Import the **policy** namespace from **@ohos.net.policy.d.ts**.
+
+2. Call **setBackgroundAllowed** to enable or disable the background network restriction switch.
+
+3. Call **isBackgroundAllowed** to check whether the background network restriction switch is enabled or disabled.
+
+4. Call **getBackgroundPolicyByUid** to check whether the application indicated b the specified UID can access the network in the background.
+
+```js
+ // Import the policy namespace.
+ import policy from '@ohos.net.policy'
+
+ // Subscribe to background network policy changes.
+ policy.on('netBackgroundPolicyChange', (data) => {
+ this.log('on netBackgroundPolicyChange: ' + JSON.stringify(data));
+ });
+
+ // Call setBackgroundAllowed to enable or disable the background network restriction switch.
+ setBackgroundAllowed() {
+ policy.setBackgroundAllowed(Boolean(Number.parseInt(this.isBoolean)), (err, data) => {
+ console.log(JSON.stringify(err));
+ console.log(JSON.stringify(data))
+ });
+ },
+
+ // Call isBackgroundAllowed to check whether the background network restriction switch is enabled or disabled.
+ isBackgroundAllowed() {
+ policy.isBackgroundAllowed((err, data) => {
+ console.log(JSON.stringify(err));
+ console.log(JSON.stringify(data))
+ });
+ },
+
+ // Call getBackgroundPolicyByUid to check whether the application indicated b the specified UID can access the network in the background.
+ getBackgroundPolicyByUid() {
+ policy.getBackgroundPolicyByUid(Number.parseInt(this.firstParam), (err, data) => {
+ console.log(JSON.stringify(err));
+ console.log(JSON.stringify(data))
+ });
+ },
+
+ // Unsubscribe from background network policy changes.
+ policy.off('netBackgroundPolicyChange', (data) => {
+ this.log('off netBackgroundPolicyChange: ' + JSON.stringify(data));
+ });
+```
+
+## Managing the Metering Network Access Policy
+
+### How to Develop
+
+1. Import the **policy** namespace from **@ohos.net.policy.d.ts**.
+
+2. Call **setPolicyByUid** to set whether the application indicated by the specified UID can access the network in the background.
+
+3. Call **getPolicyByUid** to check whether the metering network access policy for the application indicated by the specified UID.
+
+4. Call **getUidsByPolicy** to obtain the UIDs of the applications for which the metering network access policy is configured.
+
+```js
+ // Import the policy namespace.
+ import policy from '@ohos.net.policy'
+
+ // Subscribe to policy changes of the application indicated by the specified UID.
+ policy.on('netUidPolicyChange', (data) => {
+ this.log('on netUidPolicyChange: ' + JSON.stringify(data));
+ });
+
+ // Subscribe to rule changes of the application indicated by the specified UID.
+ policy.on('netUidRuleChange', (data) => {
+ this.log('on netUidRuleChange: ' + JSON.stringify(data));
+ });
+
+ // Call setPolicyByUid to set whether the application indicated by the specified UID can access the network in the background.
+ setPolicyByUid() {
+ let param = {
+ uid: Number.parseInt(this.firstParam), policy: Number.parseInt(this.currentNetUidPolicy)
+ }
+ policy.setPolicyByUid(Number.parseInt(this.firstParam), Number.parseInt(this.currentNetUidPolicy), (err, data) => {
+ console.log(JSON.stringify(err));
+ console.log(JSON.stringify(data))
+ });
+ },
+
+ // Call getPolicyByUid to check whether the metering network access policy for the application indicated by the specified UID.
+ getPolicyByUid() {
+ policy.getPolicyByUid(Number.parseInt(this.firstParam), (err, data) => {
+ console.log(JSON.stringify(err));
+ console.log(JSON.stringify(data))
+ });
+ },
+
+ // Call getUidsByPolicy to obtain the UIDs of the applications for which the metering network access policy is configured.
+ getUidsByPolicy(){
+ policy.getUidsByPolicy(Number.parseInt(this.currentNetUidPolicy), (err, data) => {
+ console.log(JSON.stringify(err));
+ console.log(JSON.stringify(data))
+ });
+ },
+
+ // Unsubscribe from policy changes of the application indicated by the specified UID.
+ policy.off('netUidPolicyChange', (data) => {
+ this.log('off netUidPolicyChange: ' + JSON.stringify(data));
+ });
+
+ // Unsubscribe from rule changes of the application indicated by the specified UID.
+ policy.off('netUidRuleChange', (data) => {
+ this.log('off netUidRuleChange: ' + JSON.stringify(data));
+ });
+
+```
+
+## Restoring Network Policies
+
+### How to Develop
+
+1. Import the **policy** namespace from **@ohos.net.policy.d.ts**.
+
+2. Call **restoreAllPolicies** to restore all network policies.
+
+```js
+ // Import the policy namespace.
+ import policy from '@ohos.net.policy'
+
+ // Call restoreAllPolicies to restore all network policies.
+ restoreAllPolicies(){
+ policy.restoreAllPolicies(this.firstParam, (err, data) => {
+ console.log(JSON.stringify(err));
+ console.log(JSON.stringify(data))
+ });
+ },
+```
+
+## Checking Access to a Metering or Non-metering Network
+
+### How to Develop
+
+1. Import the **policy** namespace from **@ohos.net.policy.d.ts**.
+
+2. Call **isUidNetAllowed** to check whether the UID can access the metering or non-metering network.
+
+```js
+ // Import the policy namespace.
+ import policy from '@ohos.net.policy'
+
+ // Call isUidNetAllowed to check whether the application indicated by the specified UID can access the metering or non-metering network.
+ isUidNetAllowedIsMetered(){
+ let param = {
+ uid: Number.parseInt(this.firstParam), isMetered: Boolean(Number.parseInt(this.isBoolean))
+ }
+ policy.isUidNetAllowed(Number.parseInt(this.firstParam), Boolean(Number.parseInt(this.isBoolean)), (err, data) => {
+ console.log(JSON.stringify(err));
+ console.log(JSON.stringify(data))
+ });
+ },
+```
+
+## Managing the Sleep Mode Allowlist
+
+### How to Develop
+
+1. Import the **policy** namespace from **@ohos.net.policy.d.ts**.
+
+2. Call **setDeviceIdleAllowList** to add a UID to or remove a UID from the sleep mode allowlist.
+
+3. Call **getDeviceIdleAllowList** to obtain the UIDs added to the sleep mode allowlist.
+
+```js
+ // Import the policy namespace.
+ import policy from '@ohos.net.policy'
+
+ // Call setDeviceIdleAllowList to add a UID to or remove a UID from the sleep mode allowlist.
+ setDeviceIdleAllowList(){
+ let param = {
+ uid: Number.parseInt(this.firstParam), isAllowed: Boolean(Number.parseInt(this.isBoolean))
+ }
+ policy.setDeviceIdleAllowList(Number.parseInt(this.firstParam), Boolean(Number.parseInt(this.isBoolean)), (err, data) => {
+ console.log(JSON.stringify(err));
+ console.log(JSON.stringify(data))
+ });
+ },
+
+ // Call getDeviceIdleAllowList to obtain the UIDs added to the sleep mode allowlist.
+ getDeviceIdleAllowList(){
+ policy.getDeviceIdleAllowList((err, data) => {
+ console.log(JSON.stringify(err));
+ console.log(JSON.stringify(data))
+ });
+ },
+```
+
+## Managing the Power-saving Mode Allowlist
+
+### How to Develop
+
+1. Import the **policy** namespace from **@ohos.net.policy.d.ts**.
+2. Call **setPowerSaveAllowList** to add a UID to or remove a UID from the power-saving mode allowlist.
+3. Call **getPowerSaveAllowList** to obtain the UIDs added to the power-saving mode allowlist.
+
+```js
+ // Import the policy namespace.
+ import policy from '@ohos.net.policy'
+
+ // Call setPowerSaveAllowList to add a UID to or remove a UID from the power-saving mode allowlist.
+ setPowerSaveAllowList(){
+ let param = {
+ uid: Number.parseInt(this.firstParam), isAllowed: Boolean(Number.parseInt(this.isBoolean))
+ }
+ policy.setPowerSaveAllowList(Number.parseInt(this.firstParam), Boolean(Number.parseInt(this.isBoolean)), (err, data) => {
+ console.log(JSON.stringify(err));
+ console.log(JSON.stringify(data))
+ });
+ },
+
+ // Call getPowerSaveAllowList to obtain the UIDs added to the power-saving mode allowlist.
+ getPowerSaveAllowList(){
+ policy.getPowerSaveAllowList((err, data) => {
+ console.log(JSON.stringify(err));
+ console.log(JSON.stringify(data))
+ });
+ },
+```
+
+## Updating the Network Notification Policy
+
+### How to Develop
+
+1. Import the **policy** namespace from **@ohos.net.policy.d.ts**.
+
+2. Call **updateRemindPolicy** to update the network notification policy.
+
+```js
+ // Import the policy namespace.
+ import policy from '@ohos.net.policy'
+
+ // Call updateRemindPolicy to update the network notification policy.
+ updateRemindPolicy() {
+ let param = {
+ netType: Number.parseInt(this.netType), iccid: this.firstParam, remindType: this.currentRemindType
+ }
+ policy.updateRemindPolicy(Number.parseInt(this.netType), this.firstParam, Number.parseInt(this.currentRemindType), (err, data) => {
+ console.log(JSON.stringify(err));
+ console.log(JSON.stringify(data))
+ });
+ },
+```
diff --git a/en/application-dev/connectivity/net-sharing.md b/en/application-dev/connectivity/net-sharing.md
new file mode 100644
index 0000000000000000000000000000000000000000..d81e8f59ecfb538ececb78afc83941d52f330eda
--- /dev/null
+++ b/en/application-dev/connectivity/net-sharing.md
@@ -0,0 +1,130 @@
+# Network Sharing
+
+## Introduction
+The Network Sharing module allows you to share your device's Internet connection with other connected devices by means of Wi-Fi hotspot, Bluetooth, and USB sharing. It also allows you to query the network sharing state and shared mobile data volume.
+
+> **NOTE**
+> To maximize the application running efficiency, most API calls are called asynchronously in callback or promise mode. The following code examples use the callback mode. For details about the APIs, see [sms API Reference](../reference/apis/js-apis-net-sharing.md).
+
+## Basic Concepts
+- Wi-Fi sharing: Shares the network through a Wi-Fi hotspot.
+- Bluetooth sharing: Shares the network through Bluetooth.
+- USB tethering: Shares the network using a USB flash drive.
+
+## **Constraints**
+- Programming language: C++ and JS
+- System: Linux kernel
+- 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.
+
+## When to Use
+Typical network sharing scenarios are as follows:
+- Enabling network sharing
+- Disabling network sharing
+- Obtaining the data traffic of the shared network
+
+The following describes the development procedure specific to each application scenario.
+## Available APIs
+For the complete list of APIs and example code, see [Network Sharing](../reference/apis/js-apis-net-sharing.md).
+
+| Type| API| Description|
+| ---- | ---- | ---- |
+| ohos.net.sharing | function isSharingSupported(callback: AsyncCallback\): void; | Checks whether the system supports network sharing. This API uses an asynchronous callback to return the result.|
+| ohos.net.sharing | function isSharing(callback: AsyncCallback\): void; | Checks whether network sharing is active. This API uses an asynchronous callback to return the result.|
+| ohos.net.sharing | function startSharing(type: SharingIfaceType, callback: AsyncCallback\): void; | Starts network sharing. This API uses an asynchronous callback to return the result.|
+| ohos.net.sharing | function stopSharing(type: SharingIfaceType, callback: AsyncCallback\): void; | Stops network sharing. This API uses an asynchronous callback to return the result.|
+| ohos.net.sharing | function getStatsRxBytes(callback: AsyncCallback\): void; | Obtains the received data traffic during network sharing, in KB. This API uses an asynchronous callback to return the result.|
+| ohos.net.sharing | function getStatsTxBytes(callback: AsyncCallback\): void; | Obtains the sent data traffic during network sharing, in KB. This API uses an asynchronous callback to return the result.|
+| ohos.net.sharing | function getStatsTotalBytes(callback: AsyncCallback\): void; | Obtains the total data traffic during network sharing, in KB. This API uses an asynchronous callback to return the result.|
+| ohos.net.sharing | function getSharingIfaces(state: SharingIfaceState, callback: AsyncCallback\>): void; | Obtains the names of network interface cards (NICs) in the specified network sharing state.. This API uses an asynchronous callback to return the result.|
+| ohos.net.sharing | function getSharingState(type: SharingIfaceType, callback: AsyncCallback\): void; | Obtains the network sharing state of the specified type. This API uses an asynchronous callback to return the result.|
+| ohos.net.sharing | function getSharableRegexes(type: SharingIfaceType, callback: AsyncCallback\>): void; | Obtains regular expressions of NICs of a specified type. This API uses an asynchronous callback to return the result.|
+| ohos.net.sharing | function on(type: 'sharingStateChange', callback: Callback\): void; | Subscribes to network sharing state changes.|
+| ohos.net.sharing | function off(type: 'sharingStateChange', callback?: Callback\): void; | Unsubscribes from network sharing state changes.|
+| ohos.net.sharing | unction on(type: 'interfaceSharingStateChange', callback: Callback\<{ type: SharingIfaceType, iface: string, state: SharingIfaceState }>): void; | Subscribes to network sharing state changes of the specified NIC.|
+| ohos.net.sharing | function off(type: 'interfaceSharingStateChange', callback?: Callback\<{ type: SharingIfaceType, iface: string, state: SharingIfaceState }>): void; | Unsubscribes from network sharing state changes of the specified NIC.|
+| ohos.net.sharing | function on(type: 'sharingUpstreamChange', callback: Callback\): void; | Subscribes to upstream NIC changes.|
+| ohos.net.sharing | function off(type: 'sharingUpstreamChange', callback?: Callback\): void; | Unsubscribes from upstream NIC changes.|
+
+## Enabling Network Sharing
+
+1. Import the **sharing** namespace from **@ohos.net.sharing**.
+2. Subscribe to network sharing state changes.
+3. Call **startSharing** to start network sharing of the specified type.
+4. Return the callback for successfully starting network sharing.
+
+```js
+ // Import the sharing namespace from @ohos.net.sharing.
+ import sharing from '@ohos.net.sharing'
+
+ // Subscribe to network sharing state changes.
+ sharing.on('sharingStateChange', (error, data) => {
+ console.log(JSON.stringify(error));
+ console.log(JSON.stringify(data));
+ });
+
+ // Call startSharing to start network sharing of the specified type.
+ sharing.startSharing(SharingIfaceType.SHARING_WIFI, (error) => {
+ console.log(JSON.stringify(error));
+ });
+```
+
+## Disabling network sharing
+
+### How to Develop
+
+1. Import the **sharing** namespace from **@ohos.net.sharing**.
+2. Subscribe to network sharing state changes.
+3. Call **stopSharing** to stop network sharing of the specified type.
+4. Return the callback for successfully stopping network sharing.
+
+```js
+ // Import the sharing namespace from @ohos.net.sharing.
+ import sharing from '@ohos.net.sharing'
+
+ // Subscribe to network sharing state changes.
+ sharing.on('sharingStateChange', (error, data) => {
+ console.log(JSON.stringify(error));
+ console.log(JSON.stringify(data));
+ });
+
+ // Call stopSharing to stop network sharing of the specified type.
+ sharing.stopSharing(SharingIfaceType.SHARING_WIFI, (error) => {
+ console.log(JSON.stringify(error));
+ });
+```
+
+## Obtaining the data traffic of the shared network
+
+### How to Develop
+
+1. Import the **sharing** namespace from **@ohos.net.sharing**.
+2. Call **startSharing** to start network sharing of the specified type.
+3. Call **getStatsTotalBytes** to obtain the data traffic generated during data sharing.
+4. Call **stopSharing** to stop network sharing of the specified type and clear the data volume of network sharing.
+
+```js
+ // Import the sharing namespace from @ohos.net.sharing.
+ import sharing from '@ohos.net.sharing'
+
+ // Call startSharing to start network sharing of the specified type.
+ sharing.startSharing(SharingIfaceType.SHARING_WIFI, (error) => {
+ console.log(JSON.stringify(error));
+ });
+
+ // Call getStatsTotalBytes to obtain the data traffic generated during data sharing.
+ sharing.getStatsTotalBytes((error, data) => {
+ console.log(JSON.stringify(error));
+ console.log(JSON.stringify(data));
+ });
+
+ // Call stopSharing to stop network sharing of the specified type and clear the data volume of network sharing.
+ sharing.stopSharing(SharingIfaceType.SHARING_WIFI, (error) => {
+ console.log(JSON.stringify(error));
+ });
+
+ // Call getStatsTotalBytes again. The data volume of network sharing has been cleared.
+ sharing.getStatsTotalBytes((error, data) => {
+ console.log(JSON.stringify(error));
+ console.log(JSON.stringify(data));
+ });
+```
diff --git a/en/application-dev/connectivity/socket-connection.md b/en/application-dev/connectivity/socket-connection.md
index da5bea318e2b60da5641b9cf01ee73c926802c16..96c802d565d0e58201b627d18be1e59093919a07 100644
--- a/en/application-dev/connectivity/socket-connection.md
+++ b/en/application-dev/connectivity/socket-connection.md
@@ -1,46 +1,82 @@
# Socket Connection
+## Introduction
-## Use Cases
+The Socket Connection module allows an application to transmit data over a Socket connection through the TCP, UDP, or TLS protocol.
-Your application can transmit data through Socket connections. Currently, the TCP and UDP protocols are supported.
+## Basic Concepts
+- Socket: An abstraction of endpoints for bidirectional communication between application processes running on different hosts in a network.
+- TCP: Transmission Control Protocol, which is a byte stream–based transport layer communication protocol that is connection-oriented and reliable.
+- UDP: User Datagram Protocol, which is a simple datagram-oriented transport layer communication protocol.
+- TLS: Transport Layer Security, which is a protocol that ensures the data confidentiality and integrity between communication programs.
+
+## When to Use
+
+Applications transmit data over TCP, UDP, or TLS Socket connections. The main application scenarios are as follows:
+
+- Implementing data transmission over TCP/UDP Socket connections
+- Implementing encrypted data transmission over TLS Socket connections
## Available APIs
-The Socket connection function is mainly implemented by the Socket module. The following table describes the related APIs.
+For the complete list of APIs and example code, see [Socket Connection](../reference/apis/js-apis-socket.md).
+
+Socket connection functions are mainly implemented by the **socket** module. The following table describes the related APIs.
-| API| Description |
+| API| Description|
| -------- | -------- |
-| constructUDPSocketInstance() | Creates a **UDPSocket** object. |
-| constructTCPSocketInstance() | Creates a **TCPSocket** object. |
-| bind() | Binds the IP address and port number. |
+| constructUDPSocketInstance() | Creates a **UDPSocket** object.|
+| constructTCPSocketInstance() | Creates a **TCPSocket** object.|
+| bind() | Binds the IP address and port number.|
| send() | Sends data.|
-| close() | Closes a Socket connection. |
-| getState() | Obtains the Socket connection status. |
-| connect() | Connects to the specified IP address and port. This function is supported only for TCP. |
-| getRemoteAddress() | Obtains the peer address of the Socket connection. This function is supported only for TCP. The **connect** API must have been called before you use this API. |
-| on(type: 'message') | Enables listening for **message** events of the Socket connection. |
-| off(type: 'message') | Disables listening for **message** events of the Socket connection. |
-| on(type: 'close') | Enables listening for **close** events of the Socket connection. |
-| off(type: 'close') | Disables listening for **close** events of the Socket connection. |
-| on(type: 'error') | Enables listening for **error** events of the Socket connection. |
-| off(type: 'error') | Disables listening for **error** events of the Socket connection. |
-| on(type: 'listening') | Enables listening for **listening** events of the UDPSocket connection. |
-| off(type: 'listening') | Disables listening for **listening** events of the UDPSocket connection. |
-| on(type: 'connect') | Enables listening for **connect** events of the TCPSocket connection. |
-| off(type: 'connect') | Disables listening for **connect** events of the TCPSocket connection. |
+| close() | Closes a Socket connection.|
+| getState() | Obtains the Socket connection status.|
+| connect() | Connects to the specified IP address and port. This function is supported only for TCP.|
+| getRemoteAddress() | Obtains the peer address of the Socket connection. This function is supported only for TCP. The **connect** API must have been called before you use this API.|
+| on(type: 'message') | Subscribes to **message** events of the Socket connection.|
+| off(type: 'message') | Unsubscribes from **message** events of the Socket connection.|
+| on(type: 'close') | Subscribes to **close** events of the Socket connection.|
+| off(type: 'close') | Unsubscribes from **close** events of the Socket connection.|
+| on(type: 'error') | Subscribes to **error** events of the Socket connection.|
+| off(type: 'error') | Unsubscribes from **error** events of the Socket connection.|
+| on(type: 'listening') | Subscribes to **listening** events of the UDP Socket connection. |
+| off(type: 'listening') | Unsubscribes from **listening** events of the UDP Socket connection. |
+| on(type: 'connect') | Subscribes to **connect** events of the TCP Socket connection. |
+| off(type: 'connect') | Unsubscribes from **connect** events of the TCP Socket connection.|
+TLS Socket connection functions are mainly provided by the **tls_socket** module. The following table describes the related APIs.
+
+| API| Description|
+| -------- | -------- |
+| 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.|
+| getCertificate() | Obtains an object representing the local certificate.|
+| getCipherSuite() | Obtains a list containing information about the negotiated cipher suite.|
+| getProtocol() | Obtains a string containing the SSL/TLS protocol version negotiated for the current connection.|
+| getRemoteAddress() | Obtains the peer address of the TLS Socket connection.|
+| getRemoteCertificate() | Obtains an object representing a peer certificate.|
+| getSignatureAlgorithms() | Obtains a list containing signature algorithms shared between the server and client, in descending order of priority.|
+| getState() | Obtains the TLS Socket connection status.|
+| off(type: 'close') | Unsubscribes from **close** events of the TLS Socket connection.|
+| off(type: 'error') | Unsubscribes from **error** events of the TLS Socket connection.|
+| off(type: 'message') | Unsubscribes from **message** events of the TLS Socket connection.|
+| on(type: 'close') | Subscribes to **close** events of the TLS Socket connection.|
+| on(type: 'error') | Subscribes to **error** events of the TLS Socket connection.|
+| on(type: 'message') | Subscribes to **message** events of the TLS Socket connection.|
+| send() | Sends data.|
+| setExtraOptions() | Sets other properties of the TLS Socket connection.|
-## How to Develop
+## Transmitting Data over TCP/UDP Socket Connections
-The implementation is similar for UDPSocket and TCPSocket. The following uses the TCPSocket as an example.
+The implementation is similar for UDP Socket and TCP Socket connections. The following uses data transmission over a TCP Socket connection as an example.
-1. Import the required Socket module.
+1. Import the required **socket** module.
2. Create a **TCPSocket** object.
-3. (Optional) Enable listening for TCPSocket events.
+3. (Optional) Subscribe to TCP Socket connection events.
4. Bind the IP address and port number. The port number can be specified or randomly allocated by the system.
@@ -48,15 +84,15 @@ The implementation is similar for UDPSocket and TCPSocket. The following uses th
6. Send data.
-7. Enable the TCPSocket connection to be automatically closed after use.
-
+7. Enable the TCP Socket connection to be automatically closed after use.
+
```js
import socket from '@ohos.net.socket'
-
+
// Create a TCPSocket object.
let tcp = socket.constructTCPSocketInstance();
-
- // Enable listening for TCPSocket events.
+
+ // Subscribe to TCP Socket connection events.
tcp.on('message', value => {
console.log("on message")
let buffer = value.message
@@ -73,7 +109,7 @@ The implementation is similar for UDPSocket and TCPSocket. The following uses th
tcp.on('close', () => {
console.log("on close")
});
-
+
// Bind the local IP address and port number.
let bindAddress = {
address: '192.168.xx.xx',
@@ -86,6 +122,7 @@ The implementation is similar for UDPSocket and TCPSocket. The following uses th
return;
}
console.log('bind success');
+
// Set up a connection to the specified IP address and port number.
let connectAddress = {
address: '192.168.xx.xx',
@@ -100,6 +137,7 @@ The implementation is similar for UDPSocket and TCPSocket. The following uses th
return;
}
console.log('connect success');
+
// Send data.
tcp.send({
data: 'Hello, server!'
@@ -112,7 +150,8 @@ The implementation is similar for UDPSocket and TCPSocket. The following uses th
})
});
});
- // Enable the TCPSocket connection to be automatically closed after use. Then, disable listening for TCPSocket events.
+
+ // Enable the TCP Socket connection to be automatically closed after use. Then, disable listening for TCP Socket connection events.
setTimeout(() => {
tcp.close((err) => {
console.log('close socket.')
@@ -122,3 +161,167 @@ The implementation is similar for UDPSocket and TCPSocket. The following uses th
tcp.off('close');
}, 30 * 1000);
```
+
+## Implementing Encrypted Data Transmission over TLS Socket Connections
+
+### How to Develop
+
+TLS Socket connection process on the client:
+
+1. Import the required **socket** module.
+
+2. Bind the IP address and port number of the server.
+
+3. For two-way authentication, upload the client CA certificate and digital certificate. For one-way authentication, upload the client CA certificate.
+
+4. Create a **TLSSocket** object.
+
+5. (Optional) Subscribe to TLS Socket connection events.
+
+6. Send data.
+
+7. Enable the TLS Socket connection to be automatically closed after use.
+
+```js
+ import socket from '@ohos.net.socket'
+
+ // Create a TLS Socket connection (for two-way authentication).
+ let tlsTwoWay = socket.constructTLSSocketInstance();
+
+ // Subscribe to TLS Socket connection events.
+ tcp.on('message', value => {
+ console.log("on message")
+ let buffer = value.message
+ let dataView = new DataView(buffer)
+ let str = ""
+ for (let i = 0; i < dataView.byteLength; ++i) {
+ str += String.fromCharCode(dataView.getUint8(i))
+ }
+ console.log("on connect received:" + str)
+ });
+ tcp.on('connect', () => {
+ console.log("on connect")
+ });
+ tcp.on('close', () => {
+ console.log("on close")
+ });
+
+ // Bind the local IP address and port number.
+ tlsTwoWay.bind({address: '192.168.xxx.xxx', port: xxxx, family: 1}, err => {
+ if (err) {
+ console.log('bind fail');
+ return;
+ }
+ console.log('bind success');
+ });
+
+ // Set the communication parameters.
+ let options = {
+ ALPNProtocols: ["spdy/1", "http/1.1"],
+
+ // Set up a connection to the specified IP address and port number.
+ address: {
+ address: "192.168.xx.xxx",
+ port: xxxx, // Port
+ family: 1,
+ },
+
+ // Set the parameters used for authentication during communication.
+ secureOptions: {
+ key: "xxxx", // Key
+ cert: "xxxx", // Digital certificate
+ ca: ["xxxx"], // CA certificate
+ passwd: "xxxx", // Password for generating the key
+ protocols: [socket.Protocol.TLSv12], // Communication protocol
+ useRemoteCipherPrefer: true, // Whether to preferentially use the peer cipher suite
+ signatureAlgorithms: "rsa_pss_rsae_sha256:ECDSA+SHA256", // Signature algorithm
+ cipherSuite: "AES256-SHA256", // Cipher suite
+ },
+ };
+
+ // Set up a connection.
+ tlsTwoWay.connect(options, (err, data) => {
+ console.error(err);
+ 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) => {
+ if (err) {
+ console.log("close callback error = " + err);
+ } else {
+ console.log("close success");
+ }
+ tls.off('message');
+ tls.off('connect');
+ tls.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 => {
+ console.log("on message")
+ let buffer = value.message
+ let dataView = new DataView(buffer)
+ let str = ""
+ for (let i = 0;i < dataView.byteLength; ++i) {
+ str += String.fromCharCode(dataView.getUint8(i))
+ }
+ console.log("on connect received:" + str)
+ });
+ tcp.on('connect', () => {
+ console.log("on connect")
+ });
+ tcp.on('close', () => {
+ console.log("on close")
+ });
+
+ // Bind the local IP address and port number.
+ tlsOneWay.bind({address: '192.168.xxx.xxx', port: xxxx, family: 1}, err => {
+ if (err) {
+ console.log('bind fail');
+ return;
+ }
+ console.log('bind success');
+ });
+
+ // Set the communication parameters.
+ let oneWayOptions = {
+ address: {
+ address: "192.168.xxx.xxx",
+ port: xxxx,
+ family: 1,
+ },
+ secureOptions: {
+ ca: ["xxxx","xxxx"], // CA certificate
+ cipherSuite: "AES256-SHA256", // Cipher suite
+ },
+ };
+
+ // Set up a connection.
+ tlsOneWay.connect(oneWayOptions, (err, data) => {
+ console.error(err);
+ 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) => {
+ if (err) {
+ console.log("close callback error = " + err);
+ } else {
+ console.log("close success");
+ }
+ tls.off('message');
+ tls.off('connect');
+ tls.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 b72874536b968593cbb7a3c8d5fd865eb1720b35..70c0ee209975ff3322210041e123afbeec3b5e6f 100644
--- a/en/application-dev/database/database-mdds-guidelines.md
+++ b/en/application-dev/database/database-mdds-guidelines.md
@@ -13,7 +13,7 @@ For details about the APIs, see [Distributed KV Store](../reference/apis/js-apis
| API | Description |
| ------------------------------------------------------------ | ------------------------------------------------------------ |
-| createKVManager(config: KVManagerConfig, callback: AsyncCallback<KVManager>): void
createKVManager(config: KVManagerConfig): Promise<KVManager> | Creates a **KvManager** object for database management. |
+| createKVManager(config: KVManagerConfig): KVManager | Creates a **KvManager** object for database management. |
| getKVStore<T extends KVStore>(storeId: string, options: Options, callback: AsyncCallback<T>): void
getKVStore<T extends KVStore>(storeId: string, options: Options): Promise<T> | Creates and obtains a KV store.|
| put(key: string, value: Uint8Array\|string\|number\|boolean, callback: AsyncCallback<void>): void
put(key: string, value: Uint8Array\|string\|number\|boolean): Promise<void> | Inserts and updates data. |
| delete(key: string, callback: AsyncCallback<void>): void
delete(key: string): Promise<void> | Deletes data. |
@@ -117,16 +117,10 @@ The following uses a single KV store as an example to describe the development p
bundleName: 'com.example.datamanagertest',
context:context,
}
- distributedKVStore.createKVManager(kvManagerConfig, function (err, manager) {
- if (err) {
- console.error(`Failed to create KVManager. code is ${err.code},message is ${err.message}`);
- return;
- }
- console.log('Created KVManager successfully');
- kvManager = manager;
- });
+ kvManager = distributedKVStore.createKVManager(kvManagerConfig);
+ console.log("Created KVManager successfully");
} catch (e) {
- console.error(`An unexpected error occurred.code is ${e.code},message is ${e.message}`);
+ console.error(`Failed to create KVManager. Code is ${e.code}, message is ${e.message}`);
}
```
@@ -150,14 +144,14 @@ The following uses a single KV store as an example to describe the development p
};
kvManager.getKVStore('storeId', options, function (err, store) {
if (err) {
- console.error(`Failed to get KVStore: code is ${err.code},message is ${err.message}`);
+ console.error(`Failed to get KVStore: code is ${err.code}, message is ${err.message}`);
return;
}
console.log('Obtained KVStore successfully');
kvStore = store;
});
} catch (e) {
- console.error(`An unexpected error occurred.code is ${e.code},message is ${e.message}`);
+ console.error(`An unexpected error occurred. Code is ${e.code}, message is ${e.message}`);
}
```
@@ -175,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 occured. Code is ${e.code}, message is ${e.message}`);
}
```
@@ -192,13 +186,13 @@ The following uses a single KV store as an example to describe the development p
try {
kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err,data) {
if (err != undefined) {
- console.error(`Failed to put.code is ${err.code},message is ${err.message}`);
+ console.error(`Failed to put data. Code is ${err.code}, message is ${err.message}`);
return;
}
- console.log('Put data successfully');
+ console.log("Put data successfully");
});
}catch (e) {
- console.error(`An unexpected error occurred.code is ${e.code},message is ${e.message}`);
+ console.error(`An unexpected error occurred. Code is ${e.code}, message is ${e.message}`);
}
```
@@ -215,20 +209,20 @@ The following uses a single KV store as an example to describe the development p
try {
kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err,data) {
if (err != undefined) {
- console.error(`Failed to put.code is ${err.code},message is ${err.message}`);
+ console.error(`Failed to put data. Code is ${err.code}, message is ${err.message}`);
return;
}
- console.log('Put data successfully');
+ console.log("Put data successfully");
kvStore.get(KEY_TEST_STRING_ELEMENT, function (err,data) {
if (err != undefined) {
- console.error(`Failed to get data.code is ${err.code},message is ${err.message}`);
+ console.error(`Failed to obtain data. Code is ${err.code}, message is ${err.message}`);
return;
}
console.log(`Obtained data successfully:${data}`);
});
});
}catch (e) {
- console.error(`Failed to get.code is ${e.code},message is ${e.message}`);
+ console.error(`Failed to obtain data. Code is ${e.code}, message is ${e.message}`);
}
```
@@ -262,7 +256,7 @@ The following uses a single KV store as an example to describe the development p
// 1000 indicates that the maximum delay is 1000 ms.
kvStore.sync(deviceIds, distributedKVStore.SyncMode.PUSH_ONLY, 1000);
} catch (e) {
- console.error(`An unexpected error occurred. 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/database/database-preference-guidelines.md b/en/application-dev/database/database-preference-guidelines.md
index e5c9faa1477565541a94076e2fb568e69b2f5cf6..724e273675061c4b6969fb3fcd6f6cbdd984a15f 100644
--- a/en/application-dev/database/database-preference-guidelines.md
+++ b/en/application-dev/database/database-preference-guidelines.md
@@ -114,21 +114,19 @@ You can use the following APIs to delete a **Preferences** instance or data file
```ts
// Obtain the context.
import UIAbility from '@ohos.app.ability.UIAbility';
- let context = null;
let preferences = null;
export default class EntryAbility extends UIAbility {
- onWindowStageCreate(windowStage){
- context = this.context;
+ onWindowStageCreate(windowStage) {
+ let promise = data_preferences.getPreferences(this.context, 'mystore');
+ promise.then((pref) => {
+ preferences = pref;
+ }).catch((err) => {
+ console.info("Failed to get the preferences.");
+ })
}
}
- let promise = data_preferences.getPreferences(context, 'mystore');
- promise.then((pref) => {
- preferences = pref;
- }).catch((err) => {
- console.info("Failed to get the preferences.");
- })
```
3. Write data.
diff --git a/en/application-dev/device/Readme-EN.md b/en/application-dev/device/Readme-EN.md
index abf5154a8caa1473367960eea7b9118598ce706a..6ce8d1b16951d5fb739d97c102cb8d3be3f628d7 100644
--- a/en/application-dev/device/Readme-EN.md
+++ b/en/application-dev/device/Readme-EN.md
@@ -1,19 +1,21 @@
-# Device
+# Device Management
+- USB Service
+ - [USB Service Overview](usb-overview.md)
+ - [USB Service Development](usb-guidelines.md)
- Location
- [Location Service Development](location-guidelines.md)
-- Multimodal Input
- - [Input Device Development](inputdevice-guidelines.md)
- - [Mouse Pointer Development](pointerstyle-guidelines.md)
- Sensor
- [Sensor Overview](sensor-overview.md)
- [Sensor Development](sensor-guidelines.md)
+- Vibrator
+ - [Vibrator Overview](vibrator-overview.md)
+ - [Vibrator Development](vibrator-guidelines.md)
+- Multimodal Input
+ - [Input Device Development](inputdevice-guidelines.md)
+ - [Mouse Pointer Development](pointerstyle-guidelines.md)
- Update Service
- [Sample Server Overview](sample-server-overview.md)
- [Sample Server Development](sample-server-guidelines.md)
-- USB Service
- - [USB Service Overview](usb-overview.md)
- - [USB Service Development](usb-guidelines.md)
-- Vibrator
- - [Vibrator Overview](vibrator-overview.md)
- - [Vibrator Development](vibrator-guidelines.md)
\ No newline at end of file
+- Stationary
+ - [Stationary Development](stationary-guidelines.md)
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/stationary-guidelines.md b/en/application-dev/device/stationary-guidelines.md
new file mode 100644
index 0000000000000000000000000000000000000000..9f6693027a29f48c2c434b842df74beb5209f319
--- /dev/null
+++ b/en/application-dev/device/stationary-guidelines.md
@@ -0,0 +1,84 @@
+# Stationary Development
+
+
+## When to Use
+
+An application can call the **Stationary** module to obtain the device status, for example, whether the device is absolutely or relatively still.
+
+For details about the APIs, see [Stationary](../reference/apis/js-apis-stationary.md).
+
+## Device Status Type Parameters
+
+| Name| Description|
+| -------- | -------- |
+| still | Absolutely still.|
+| relativeStill | Relatively still.|
+
+## Parameters for Subscribing to Device Status events
+
+| Name | Value | Description |
+| ------------------------------ | ---- | ---------------------------------------- |
+| ENTER | 1 | Event indicating entering device status. |
+| EXIT | 2 | Event indicating exiting device status.|
+| ENTER_EXIT | 3 | Event indicating entering and exiting device status.|
+
+## Returned Device Status Parameters
+
+| Name | Value | Description |
+| ------------------------------ | ---- | ---------------------------------------- |
+| ENTER | 1 | Entering device status. |
+| EXIT | 2 | Exiting device status.|
+
+## Available APIs
+
+| Module | Name | Description |
+| ------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
+| ohos.stationary | on(activity: ActivityType, event: ActivityEvent, reportLatencyNs: number, callback: Callback<ActivityResponse>): void | Subscribes to the device status. This API uses an asynchronous callback to return the result.|
+| ohos.stationary | once(activity: ActivityType, callback: Callback<ActivityResponse>): void | Obtains the device status. This API uses an asynchronous callback to return the result.|
+| ohos.stationary | off(activity: ActivityType, event: ActivityEvent, callback?: Callback<ActivityResponse>): void | Unsubscribes from the device status. |
+
+## Constraints
+
+The device must support the acceleration sensor.
+
+## How to Develop
+
+1. Subscribe to the event indicating entering the absolute still state, and the event is reported every 1 second.
+
+ ```js
+ import stationary from '@ohos.stationary';
+ var reportLatencyNs = 1000000000;
+ try {
+ stationary.on('still', stationary.ActivityEvent.ENTER, reportLatencyNs, (data) => {
+ console.log('data='+ JSON.stringify(data));
+ })
+ } catch (err) {
+ console.error('errCode: ' + err.code + ' ,msg: ' + err.message);
+ }
+ ```
+
+2. Obtain the event indicating entering the absolute still state.
+
+ ```js
+ import stationary from '@ohos.stationary';
+ try {
+ stationary.once('still', (data) => {
+ console.log('data='+ JSON.stringify(data));
+ })
+ } catch (err) {
+ console.error('errCode: ' + err.code + ' ,msg: ' + err.message);
+ }
+ ```
+
+3. Unsubscribe from the event indicating entering the absolute still state.
+
+ ```js
+ import stationary from '@ohos.stationary';
+ try {
+ stationary.off('still', stationary.ActivityEvent.ENTER, (data) => {
+ console.log('data='+ JSON.stringify(data));
+ })
+ } catch (err) {
+ console.error('errCode: ' + err.code + ' ,msg: ' + err.message);
+ }
+ ```
diff --git a/en/application-dev/device/vibrator-guidelines.md b/en/application-dev/device/vibrator-guidelines.md
index 36b08b2acd96e2d65fc14a936f1c3e9c9dd31a88..c028f5be4890c476bab762cfc8b0f0d12d9fdda8 100644
--- a/en/application-dev/device/vibrator-guidelines.md
+++ b/en/application-dev/device/vibrator-guidelines.md
@@ -16,6 +16,10 @@ For details about the APIs, see [Vibrator](../reference/apis/js-apis-vibrator.md
| ohos.vibrator | startVibration(effect: VibrateEffect, attribute: VibrateAttribute, callback: AsyncCallback<void>): void | Starts vibration with the specified effect and attribute. This API uses an asynchronous callback to return the result.|
| ohos.vibrator | stopVibration(stopMode: VibratorStopMode): Promise<void> | Stops vibration in the specified mode. This API uses a promise to return the result. |
| ohos.vibrator | stopVibration(stopMode: VibratorStopMode, callback: AsyncCallback<void>): void | Stops vibration in the specified mode. This API uses an asynchronous callback to return the result. |
+| ohos.vibrator | stopVibration(): Promise<void> | Stops vibration in all modes. This API uses a promise to return the result. |
+| ohos.vibrator | stopVibration(callback: AsyncCallback<void>): void | Stops vibration in all modes. This API uses an asynchronous callback to return the result. |
+| ohos.vibrator | isSupportEffect(effectId: string): Promise<boolean> | Checks whether the passed effect ID is supported. This API uses a promise to return the result. The value **true** means that the passed effect ID is supported, and **false** means the opposite. |
+| ohos.vibrator | isSupportEffect(effectId: string, callback: AsyncCallback<boolean>): void | Checks whether the passed effect ID is supported. This API uses an asynchronous callback to return the result. The value **true** means that the passed effect ID is supported, and **false** means the opposite. |
## How to Develop
@@ -27,7 +31,7 @@ For details about the APIs, see [Vibrator](../reference/apis/js-apis-vibrator.md
```js
import vibrator from '@ohos.vibrator';
try {
- vibrator.startVibration({
+ vibrator.startVibration({ // To use startVibration, you must configure the ohos.permission.VIBRATE permission.
type: 'time',
duration: 1000,
}, {
@@ -50,7 +54,7 @@ For details about the APIs, see [Vibrator](../reference/apis/js-apis-vibrator.md
```js
import vibrator from '@ohos.vibrator';
try {
- // Stop vibration in VIBRATOR_STOP_MODE_TIME mode.
+ // Stop vibration in VIBRATOR_STOP_MODE_TIME mode. To use stopVibration, you must configure the ohos.permission.VIBRATE permission.
vibrator.stopVibration(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_TIME, function (error) {
if (error) {
console.log('error.code' + error.code + 'error.message' + error.message);
@@ -62,3 +66,72 @@ For details about the APIs, see [Vibrator](../reference/apis/js-apis-vibrator.md
console.info('errCode: ' + err.code + ' ,msg: ' + err.message);
}
```
+
+4. Stop vibration in all modes.
+
+ ```js
+ import vibrator from '@ohos.vibrator';
+ // To use startVibration and stopVibration, you must configure the ohos.permission.VIBRATE permission.
+ try {
+ vibrator.startVibration({
+ type: 'time',
+ duration: 1000,
+ }, {
+ id: 0,
+ usage: 'alarm'
+ }, (error) => {
+ if (error) {
+ console.error('vibrate fail, error.code: ' + error.code + 'error.message: ', + error.message);
+ return;
+ }
+ console.log('Callback returned to indicate a successful vibration.');
+ });
+ // Stop vibration in all modes.
+ vibrator.stopVibration(function (error) {
+ if (error) {
+ console.log('error.code' + error.code + 'error.message' + error.message);
+ return;
+ }
+ console.log('Callback returned to indicate successful.');
+ })
+ } catch (error) {
+ console.info('errCode: ' + error.code + ' ,msg: ' + error.message);
+ }
+ ```
+
+5. Check whether the passed effect ID is supported.
+
+ ```js
+ import vibrator from '@ohos.vibrator';
+ try {
+ // Check whether 'haptic.clock.timer' is supported.
+ vibrator.isSupportEffect('haptic.clock.timer', function (err, state) {
+ if (err) {
+ console.error('isSupportEffect failed, error:' + JSON.stringify(err));
+ return;
+ }
+ console.log('The effectId is ' + (state ? 'supported' : 'unsupported'));
+ if (state) {
+ try {
+ vibrator.startVibration({ // To use startVibration, you must configure the ohos.permission.VIBRATE permission.
+ type: 'preset',
+ effectId: 'haptic.clock.timer',
+ count: 1,
+ }, {
+ usage: 'unknown'
+ }, (error) => {
+ if(error) {
+ console.error('haptic.clock.timer vibrator error:' + JSON.stringify(error));
+ } else {
+ console.log('haptic.clock.timer vibrator success');
+ }
+ });
+ } catch (error) {
+ console.error('Exception in, error:' + JSON.stringify(error));
+ }
+ }
+ })
+ } catch (error) {
+ console.error('Exception in, error:' + JSON.stringify(error));
+ }
+ ```
diff --git a/en/application-dev/dfx/Readme-EN.md b/en/application-dev/dfx/Readme-EN.md
index 4ed700a49b94ef0c296ec27eaf9c5cde96575234..c6b449f197ba66d8bd6f4021abffe6ce31a69028 100644
--- a/en/application-dev/dfx/Readme-EN.md
+++ b/en/application-dev/dfx/Readme-EN.md
@@ -1,13 +1,9 @@
# DFX
-- Application Event Logging
- - [Development of Application Event Logging](hiappevent-guidelines.md)
-- Distributed Call Chain Tracing
- - [Development of Distributed Call Chain Tracing](hitracechain-guidelines.md)
-- HiLog
- - [HiLog Development](hilog-guidelines.md)
-- Performance Tracing
- - [Development of Performance Tracing](hitracemeter-guidelines.md)
+- [Development of Application Event Logging](hiappevent-guidelines.md)
+- [Development of Performance Tracing](hitracemeter-guidelines.md)
+- [Development of Distributed Call Chain Tracing](hitracechain-guidelines.md)
+- [HiLog Development (Native)](hilog-guidelines.md)
- Error Management
- [Development of Error Manager](errormanager-guidelines.md)
- - [Development of Application Recovery](apprecovery-guidelines.md)
+ - [Development of Application Recovery](apprecovery-guidelines.md)
\ No newline at end of file
diff --git a/en/application-dev/dfx/errormanager-guidelines.md b/en/application-dev/dfx/errormanager-guidelines.md
index 667339c3b3dbaa101cfbda8eeacbc8f11c2fd03d..4679cfcfc78893590fe73eab770e49fc68a1a828 100644
--- a/en/application-dev/dfx/errormanager-guidelines.md
+++ b/en/application-dev/dfx/errormanager-guidelines.md
@@ -12,11 +12,11 @@ Application error management APIs are provided by the **errorManager** module. F
| API | Description |
| ------------------------------------------------------------ | ---------------------------------------------------- |
-| registerErrorObserver(observer: ErrorObserver): number | Registers an observer for application errors. A callback will be invoked when an application error is detected. This API works in a synchronous manner. The return value is the SN of the registered observer.|
-| unregisterErrorObserver(observerId: number, callback: AsyncCallback\): void | Unregisters an observer in callback mode. The number passed to this API is the SN of the registered observer. |
-| unregisterErrorObserver(observerId: number): Promise\ | Unregisters an observer in promise mode. The number passed to this API is the SN of the registered observer. |
+| on(type: "error", observer: ErrorObserver): number | Registers an observer for application errors. A callback will be invoked when an application error is detected. This API works in a synchronous manner. The return value is the SN of the registered observer.|
+| off(type: "error", observerId: number, callback: AsyncCallback\): void | Unregisters an observer in callback mode. The number passed to this API is the SN of the registered observer. |
+| off(type: "error", observerId: number): Promise\ | Unregisters an observer in promise mode. The number passed to this API is the SN of the registered observer. |
-When an asynchronous callback is used, the return value can be processed directly in the callback. If a promise is used, the return value can also be processed in the promise in a similar way. For details about the result codes, see [Result Codes for Unregistering an Observer](#result-codes-for-unregistering-an-observer).
+When an asynchronous callback is used, the return value can be processed directly in the callback. If a promise is used, the return value can also be processed in the promise in a similar way. For details about the result codes, see [Result Codes for Unregistering an Observer](#result codes-for-unregistering-an-observer).
**Table 2** Description of the ErrorObserver API
@@ -39,22 +39,23 @@ When an asynchronous callback is used, the return value can be processed directl
import UIAbility from '@ohos.app.ability.UIAbility';
import errorManager from '@ohos.app.ability.errorManager';
-var registerId = -1;
-var callback = {
+let registerId = -1;
+let callback = {
onUnhandledException: function (errMsg) {
console.log(errMsg);
}
}
-export default class EntryAbility extends Ability {
+
+export default class EntryAbility extends UIAbility {
onCreate(want, launchParam) {
console.log("[Demo] EntryAbility onCreate")
- registerId = errorManager.registerErrorObserver(callback);
+ registerId = errorManager.on("error", callback);
globalThis.abilityWant = want;
}
onDestroy() {
console.log("[Demo] EntryAbility onDestroy")
- errorManager.unregisterErrorObserver(registerId, (result) => {
+ errorManager.off("error", registerId, (result) => {
console.log("[Demo] result " + result.code + ";" + result.message)
});
}
diff --git a/en/application-dev/file-management/medialibrary-filepath-guidelines.md b/en/application-dev/file-management/medialibrary-filepath-guidelines.md
index 4c7e2ecd4db6723a66930e624bd4b36b556330d1..1e310ef9312499bb131affb620ac7758e5033778 100644
--- a/en/application-dev/file-management/medialibrary-filepath-guidelines.md
+++ b/en/application-dev/file-management/medialibrary-filepath-guidelines.md
@@ -136,7 +136,7 @@ async function copySandbox2Public() {
console.error('file asset get failed, message = ' + err);
}
let fdPub = await fileAsset.open('rw');
- let fdSand = await fs.open(sandboxDirPath + 'testFile.txt', OpenMode.READ_WRITE);
+ let fdSand = await fs.open(sandboxDirPath + 'testFile.txt', fs.OpenMode.READ_WRITE);
await fs.copyFile(fdSand.fd, fdPub);
await fileAsset.close(fdPub);
await fs.close(fdSand.fd);
@@ -174,7 +174,7 @@ async function example() {
const context = getContext(this);
let media = mediaLibrary.getMediaLibrary(context);
const path = await media.getPublicDirectory(DIR_DOCUMENTS);
- media.createAsset(mediaType, "testFile.text", path).then((asset) => {
+ media.createAsset(mediaType, "testFile.txt", path).then((asset) => {
console.info("createAsset successfully:" + JSON.stringify(asset));
}).catch((err) => {
console.error("createAsset failed with error: " + err);
diff --git a/en/application-dev/file-management/medialibrary-resource-guidelines.md b/en/application-dev/file-management/medialibrary-resource-guidelines.md
index 7d120ec9a4fa9fd38ba92be97ee7fdd5a6f33816..054591847ffa156f5ee85cf5e2412b215750e283 100644
--- a/en/application-dev/file-management/medialibrary-resource-guidelines.md
+++ b/en/application-dev/file-management/medialibrary-resource-guidelines.md
@@ -42,14 +42,11 @@ async function example() {
const context = getContext(this);
let media = mediaLibrary.getMediaLibrary(context);
const fetchFileResult = await media.getFileAssets(option);
- fetchFileResult.getFirstObject().then((fileAsset) => {
+ fetchFileResult.getFirstObject().then(async (fileAsset) => {
console.log('getFirstObject.displayName : ' + fileAsset.displayName);
for (let i = 1; i < fetchFileResult.getCount(); i++) {
- fetchFileResult.getNextObject().then((fileAsset) => {
- console.info('fileAsset.displayName ' + i + ': ' + fileAsset.displayName);
- }).catch((err) => {
- console.error('Failed to get next object: ' + err);
- });
+ let fileAsset = await fetchFileResult.getNextObject();
+ console.info('fileAsset.displayName ' + i + ': ' + fileAsset.displayName);
}
}).catch((err) => {
console.error('Failed to get first object: ' + err);
@@ -75,14 +72,11 @@ async function example() {
const context = getContext(this);
let media = mediaLibrary.getMediaLibrary(context);
const fetchFileResult = await media.getFileAssets(option);
- fetchFileResult.getFirstObject().then((fileAsset) => {
+ fetchFileResult.getFirstObject().then(async (fileAsset) => {
console.info('getFirstObject.displayName : ' + fileAsset.displayName);
for (let i = 1; i < fetchFileResult.getCount(); i++) {
- fetchFileResult.getNextObject().then((fileAsset) => {
- console.info('fileAsset.displayName ' + i + ': ' + fileAsset.displayName);
- }).catch((err) => {
- console.error('Failed to get next object: ' + err);
- });
+ let fileAsset = await fetchFileResult.getNextObject();
+ console.info('fileAsset.displayName ' + i + ': ' + fileAsset.displayName);
}
}).catch((err) => {
console.error('Failed to get first object: ' + err);
@@ -108,14 +102,11 @@ async function example() {
const context = getContext(this);
let media = mediaLibrary.getMediaLibrary(context);
const fetchFileResult = await media.getFileAssets(option);
- fetchFileResult.getFirstObject().then((fileAsset) => {
+ fetchFileResult.getFirstObject().then(async (fileAsset) => {
console.info('getFirstObject.displayName : ' + fileAsset.displayName);
for (let i = 1; i < fetchFileResult.getCount(); i++) {
- fetchFileResult.getNextObject().then((fileAsset) => {
- console.info('fileAsset.displayName ' + i + ': ' + fileAsset.displayName);
- }).catch((err) => {
- console.error('Failed to get next object: ' + err);
- });
+ let fileAsset = await fetchFileResult.getNextObject();
+ console.info('fileAsset.displayName ' + i + ': ' + fileAsset.displayName);
}
}).catch((err) => {
console.error('Failed to get first object: ' + err);
diff --git a/en/application-dev/internationalization/i18n-guidelines.md b/en/application-dev/internationalization/i18n-guidelines.md
index 8218f2561376c4119f66be0175c5c9ea16c7d024..e78bdb6437b26b8a30ee23f9fdec380087297b33 100644
--- a/en/application-dev/internationalization/i18n-guidelines.md
+++ b/en/application-dev/internationalization/i18n-guidelines.md
@@ -6,7 +6,7 @@ The [intl](intl-guidelines.md) module provides basic i18n capabilities through t
## Obtaining and Setting i18n Information
-The system provides APIs to configure information such as the system language, preferred language, country or region, 24-hour clock, and local digit switch.
+The following table lists the APIs used to configure information such as the system language, preferred language, country or region, 24-hour clock, and use of local digits.
### Available APIs
@@ -30,15 +30,15 @@ The system provides APIs to configure information such as the system language, p
| System | getPreferredLanguageList()9+ | Obtains the preferred language list. |
| System | getFirstPreferredLanguage()9+ | Obtains the first language in the preferred language list. |
| System | getAppPreferredLanguage()9+ | Obtains the preferred language of an application. |
-| System | setUsingLocalDigit(flag: boolean)9+ | Sets whether to enable the local digit switch. |
-| System | getUsingLocalDigit()9+ | Checks whether the local digit switch is turned on. |
+| System | setUsingLocalDigit(flag: boolean)9+ | Specifies whether to enable use of local digits. |
+| System | getUsingLocalDigit()9+ | Checks whether use of local digits is enabled. |
| | isRTL(locale:string):boolean9+ | Checks whether the locale uses a right-to-left (RTL) language.|
### How to Develop
1. Import the **i18n** module.
```js
- import I18n from '@ohos.i18n'
+ import I18n from '@ohos.i18n';
```
2. Obtain and set the system language.
@@ -51,7 +51,7 @@ The system provides APIs to configure information such as the system language, p
I18n.System.setSystemLanguage("en"); // Set the system language to en.
let language = I18n.System.getSystemLanguage(); // language = "en"
} catch(error) {
- console.error(`call i18n.System interface failed, error code: ${error.code}, message: ${error.message}`)
+ console.error(`call i18n.System interface failed, error code: ${error.code}, message: ${error.message}`);
}
```
@@ -65,7 +65,7 @@ The system provides APIs to configure information such as the system language, p
I18n.System.setSystemRegion("CN"); // Set the system country to CN.
let region = I18n.System.getSystemRegion(); // region = "CN"
} catch(error) {
- console.error(`call i18n.System interface failed, error code: ${error.code}, message: ${error.message}`)
+ console.error(`call i18n.System interface failed, error code: ${error.code}, message: ${error.message}`);
}
```
@@ -79,7 +79,7 @@ The system provides APIs to configure information such as the system language, p
I18n.System.setSystemLocale("zh-Hans-CN"); // Set the system locale to zh-Hans-CN.
let locale = I18n.System.getSystemLocale(); // locale = "zh-Hans-CN"
} catch(error) {
- console.error(`call i18n.System interface failed, error code: ${error.code}, message: ${error.message}`)
+ console.error(`call i18n.System interface failed, error code: ${error.code}, message: ${error.message}`);
}
```
@@ -92,7 +92,7 @@ The system provides APIs to configure information such as the system language, p
let rtl = I18n.isRTL("zh-CN"); // rtl = false
rtl = I18n.isRTL("ar"); // rtl = true
} catch(error) {
- console.error(`call i18n.System interface failed, error code: ${error.code}, message: ${error.message}`)
+ console.error(`call i18n.System interface failed, error code: ${error.code}, message: ${error.message}`);
}
```
@@ -106,7 +106,7 @@ The system provides APIs to configure information such as the system language, p
I18n.System.set24HourClock(true);
let hourClock = I18n.System.is24HourClock(); // hourClock = true
} catch(error) {
- console.error(`call i18n.System interface failed, error code: ${error.code}, message: ${error.message}`)
+ console.error(`call i18n.System interface failed, error code: ${error.code}, message: ${error.message}`);
}
```
@@ -121,7 +121,7 @@ The system provides APIs to configure information such as the system language, p
let sentenceCase = false;
let localizedLanguage = I18n.System.getDisplayLanguage(language, locale, sentenceCase); // localizedLanguage = "English"
} catch(error) {
- console.error(`call i18n.System interface failed, error code: ${error.code}, message: ${error.message}`)
+ console.error(`call i18n.System interface failed, error code: ${error.code}, message: ${error.message}`);
}
```
@@ -136,7 +136,7 @@ The system provides APIs to configure information such as the system language, p
let sentenceCase = false;
let localizedCountry = I18n.System.getDisplayCountry(country, locale, sentenceCase); // localizedCountry = "U.S."
} catch(error) {
- console.error(`call i18n.System interface failed, error code: ${error.code}, message: ${error.message}`)
+ console.error(`call i18n.System interface failed, error code: ${error.code}, message: ${error.message}`);
}
```
@@ -150,7 +150,7 @@ The system provides APIs to configure information such as the system language, p
let languageList = I18n.System.getSystemLanguages(); // languageList = ["en-Latn-US", "zh-Hans"]
let countryList = I18n.System.getSystemCountries("zh"); // countryList = ["ZW", "YT", ..., "CN", "DE"], 240 countries and regions in total
} catch(error) {
- console.error(`call i18n.System interface failed, error code: ${error.code}, message: ${error.message}`)
+ console.error(`call i18n.System interface failed, error code: ${error.code}, message: ${error.message}`);
}
```
@@ -162,7 +162,7 @@ The system provides APIs to configure information such as the system language, p
try {
let isSuggest = I18n.System.isSuggested("zh", "CN"); // isSuggest = true
} catch(error) {
- console.error(`call i18n.System interface failed, error code: ${error.code}, message: ${error.message}`)
+ console.error(`call i18n.System interface failed, error code: ${error.code}, message: ${error.message}`);
}
```
@@ -182,7 +182,7 @@ The system provides APIs to configure information such as the system language, p
let firstPreferredLanguage = I18n.System.getFirstPreferredLanguage(); // firstPreferredLanguage = "en-GB"
let appPreferredLanguage = I18n.System.getAppPreferredLanguage(); // Set the preferred language of the application to en-GB if the application contains en-GB resources.
} catch(error) {
- console.error(`call i18n.System interface failed, error code: ${error.code}, message: ${error.message}`)
+ console.error(`call i18n.System interface failed, error code: ${error.code}, message: ${error.message}`);
}
```
@@ -190,14 +190,14 @@ The system provides APIs to configure information such as the system language, p
Call **setUsingLocalDigit** to enable the local digit switch. (This is a system API and can be called only by system applications with the UPDATE_CONFIGURATION permission.)
Call **getUsingLocalDigit** to check whether the local digit switch is enabled.
- Currently, the local digit switch applies only to the following languages: "ar", "as", "bn", "fa", "mr", "my", "ne", and "ur".
+ Currently, use of local digits is supported only for the following languages: **ar**, **as**, **bn**, **fa**, **mr**, **my**, **ne**, **ur**.
```js
try {
I18n.System.setUsingLocalDigit(true); // Enable the local digit switch.
let status = I18n.System.getUsingLocalDigit(); // status = true
} catch(error) {
- console.error(`call i18n.System interface failed, error code: ${error.code}, message: ${error.message}`)
+ console.error(`call i18n.System interface failed, error code: ${error.code}, message: ${error.message}`);
}
```
@@ -220,14 +220,14 @@ try {
| Calendar | getMinimalDaysInFirstWeek():number8+ | Obtains the minimum number of days in the first week of a year. |
| Calendar | setMinimalDaysInFirstWeek(value:number): void8+ | Sets the minimum number of days in the first week of a year. |
| Calendar | getDisplayName(locale:string):string8+ | Obtains the localized display of the **Calendar** object. |
-| Calendar | isWeekend(date?:Date):boolean8+ | Checks whether the specified date in this **Calendar** object is a weekend. |
+| Calendar | isWeekend(date?:Date):boolean8+ | Checks whether a given date is a weekend in the calendar. |
### How to Develop
1. Import the **i18n** module.
```js
- import I18n from '@ohos.i18n'
+ import I18n from '@ohos.i18n';
```
2. Instantiate a **Calendar** object.
@@ -254,7 +254,7 @@ try {
Call **set** to set the year, month, day, hour, minute, and second for the **Calendar** object.
```js
- calendar.set(2021, 12, 21, 6, 0, 0)
+ calendar.set(2021, 12, 21, 6, 0, 0);
```
5. Set and obtain the time zone for the **Calendar** object.
@@ -317,7 +317,7 @@ try {
1. Import the **i18n** module.
```js
- import I18n from '@ohos.i18n'
+ import I18n from '@ohos.i18n';
```
2. Instantiate a **PhoneNumberFormat** object.
@@ -359,7 +359,7 @@ The **I18NUtil** class provides an API to implement measurement conversion.
1. Import the **i18n** module.
```js
- import I18n from '@ohos.i18n'
+ import I18n from '@ohos.i18n';
```
2. Convert a measurement unit.
@@ -393,7 +393,7 @@ The **I18NUtil** class provides an API to implement measurement conversion.
1. Import the **i18n** module.
```js
- import I18n from '@ohos.i18n'
+ import I18n from '@ohos.i18n';
```
2. Instantiates an **IndexUtil** object.
@@ -418,7 +418,7 @@ The **I18NUtil** class provides an API to implement measurement conversion.
Call **addLocale** to add the alphabet index of a new locale to the current index list.
```js
- indexUtil.addLocale("ar")
+ indexUtil.addLocale("ar");
```
5. Obtain the index of a string.
@@ -454,7 +454,7 @@ When a text is displayed in more than one line, use [BreakIterator8](../referenc
1. Import the **i18n** module.
```js
- import I18n from '@ohos.i18n'
+ import I18n from '@ohos.i18n';
```
2. Instantiate a **BreakIterator** object.
@@ -462,7 +462,7 @@ When a text is displayed in more than one line, use [BreakIterator8](../referenc
Call **getLineInstance** to instantiate a **BreakIterator** object.
```js
- let locale = "en-US"
+ let locale = "en-US";
let breakIterator = I18n.getLineInstance(locale);
```
@@ -531,7 +531,7 @@ When a text is displayed in more than one line, use [BreakIterator8](../referenc
1. Import the **i18n** module.
```js
- import I18n from '@ohos.i18n'
+ import I18n from '@ohos.i18n';
```
2. Instantiate the **TimeZone** object, and obtain the time zone information.
@@ -592,7 +592,7 @@ Call [Transliterator](../reference/apis/js-apis-i18n.md#transliterator9) APIs to
1. Import the **i18n** module.
```js
- import I18n from '@ohos.i18n'
+ import I18n from '@ohos.i18n';
```
2. Obtains the transliterator ID list.
@@ -637,7 +637,7 @@ Call [Transliterator](../reference/apis/js-apis-i18n.md#transliterator9) APIs to
1. Import the **i18n** module.
```js
- import I18n from '@ohos.i18n'
+ import I18n from '@ohos.i18n';
```
2. Check the input character has a certain attribute.
@@ -719,7 +719,7 @@ Call [Transliterator](../reference/apis/js-apis-i18n.md#transliterator9) APIs to
1. Import the **i18n** module.
```js
- import I18n from '@ohos.i18n'
+ import I18n from '@ohos.i18n';
```
2. Check the sequence of year, month, and day in a date.
diff --git a/en/application-dev/internationalization/intl-guidelines.md b/en/application-dev/internationalization/intl-guidelines.md
index 609af84500cecb0ce5bda8409216b6957182885f..7274514385795ec42b6e81924e34e71070a71ebf 100644
--- a/en/application-dev/internationalization/intl-guidelines.md
+++ b/en/application-dev/internationalization/intl-guidelines.md
@@ -25,7 +25,7 @@ The [I18N](i18n-guidelines.md) module provides enhanced I18N capabilities throug
Importing an incorrect bundle can lead to unexpected API behavior.
```js
- import Intl from '@ohos.intl'
+ import Intl from '@ohos.intl';
```
2. Instantiates a **Locale** object.
@@ -100,7 +100,7 @@ The [I18N](i18n-guidelines.md) module provides enhanced I18N capabilities throug
Importing an incorrect bundle can lead to unexpected API behavior.
```js
- import Intl from '@ohos.intl'
+ import Intl from '@ohos.intl';
```
2. Instantiate a **DateTimeFormat** object.
@@ -170,7 +170,7 @@ The [I18N](i18n-guidelines.md) module provides enhanced I18N capabilities throug
Importing an incorrect bundle can lead to unexpected API behavior.
```js
- import Intl from '@ohos.intl'
+ import Intl from '@ohos.intl';
```
2. Instantiate a **NumberFormat** object.
@@ -195,7 +195,7 @@ The [I18N](i18n-guidelines.md) module provides enhanced I18N capabilities throug
```js
let options = {compactDisplay: "short", notation: "compact"};
let numberFormat = new Intl.NumberFormat("zh-CN", options);
- let number = 1234.5678
+ let number = 1234.5678;
let formatResult = numberFormat.format(number); // formatResult = "1235"
```
@@ -229,7 +229,7 @@ Users in different regions have different requirements for string sorting. [Coll
Importing an incorrect bundle can lead to unexpected API behavior.
```js
- import Intl from '@ohos.intl'
+ import Intl from '@ohos.intl';
```
2. Instantiate a **Collator** object.
@@ -240,7 +240,7 @@ Users in different regions have different requirements for string sorting. [Coll
let collator = new Intl.Collator();
```
- Alternatively, use your own locale and formatting parameters to create a **Collator** object. For a full list of parameters, see [CollatorOptions](../reference/apis/js-apis-intl.md#collatoroptions8).
+ Alternatively, use your own locale and formatting parameters to create a **Collator** object. For a full list of parameters, see [CollatorOptions](../reference/apis/js-apis-intl.md#collatoroptions9).
The **sensitivity** parameter is used to specify the levels of differences that will be used for string comparison. The value **base** indicates that only characters are compared, but not the accent and capitalization. For example, 'a' != 'b', 'a' == '', 'a'=='A'. The value **accent** indicates that the accent is considered, but not the capitalization. For example, 'a' != 'b', 'a' == '', 'a'=='A'. The value **case** indicates that the capitalization is considered, but the accent. For example, 'a' != 'b', 'a' == '', 'a'=='A'. The value **variant** indicates that the accent and capitalization are considered. For example, 'a' != 'b', 'a' == '', 'a'=='A'.
```js
@@ -290,7 +290,7 @@ According to grammars in certain languages, the singular or plural form of a nou
Importing an incorrect bundle can lead to unexpected API behavior.
```js
- import Intl from '@ohos.intl'
+ import Intl from '@ohos.intl';
```
2. Instantiate a **PluralRules** object.
@@ -301,7 +301,7 @@ According to grammars in certain languages, the singular or plural form of a nou
let pluralRules = new Intl.PluralRules();
```
- Alternatively, use your own locale and formatting parameters to create a **PluralRules** object. For a full list of parameters, see [PluralRulesOptions](../reference/apis/js-apis-intl.md#pluralrulesoptions8).
+ Alternatively, use your own locale and formatting parameters to create a **PluralRules** object. For a full list of parameters, see [PluralRulesOptions](../reference/apis/js-apis-intl.md#pluralrulesoptions9).
```js
let pluralRules = new Intl.PluralRules("zh-CN", {localeMatcher: "best fit", type: "cardinal"});
@@ -313,7 +313,7 @@ According to grammars in certain languages, the singular or plural form of a nou
```js
let pluralRules = new Intl.PluralRules("zh-CN", {localeMatcher: "best fit", type: "cardinal"});
- let number = 1234.5678
+ let number = 1234.5678;
let categoryResult = pluralRules.select(number); // categoryResult = "other"
```
@@ -338,7 +338,7 @@ According to grammars in certain languages, the singular or plural form of a nou
Importing an incorrect bundle can lead to unexpected API behavior.
```js
- import Intl from '@ohos.intl'
+ import Intl from '@ohos.intl';
```
2. Instantiate a **RelativeTimeFormat** object.
@@ -349,7 +349,7 @@ According to grammars in certain languages, the singular or plural form of a nou
let relativeTimeFormat = new Intl.RelativeTimeFormat();
```
- Alternatively, use your own locale and formatting parameters to create a **RelativeTimeFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [RelativeTimeFormatInputOptions](../reference/apis/js-apis-intl.md#relativetimeformatinputoptions8).
+ Alternatively, use your own locale and formatting parameters to create a **RelativeTimeFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [RelativeTimeFormatInputOptions](../reference/apis/js-apis-intl.md#relativetimeformatinputoptions9).
```js
let relativeTimeFormat = new Intl.RelativeTimeFormat("zh-CN", {numeric: "always", style: "long"});
@@ -362,7 +362,7 @@ According to grammars in certain languages, the singular or plural form of a nou
```js
let relativeTimeFormat = new Intl.RelativeTimeFormat("zh-CN", {numeric: "always", style: "long"});
let number = 2;
- let unit = "year"
+ let unit = "year";
let formatResult = relativeTimeFormat.format(number, unit); // 2 years later
```
@@ -373,7 +373,7 @@ According to grammars in certain languages, the singular or plural form of a nou
```js
let relativeTimeFormat = new Intl.RelativeTimeFormat("zh-CN", {numeric: "always", style: "long"});
let number = 2;
- let unit = "year"
+ let unit = "year";
let formatPartsResult = relativeTimeFormat.formatToParts(number, unit); // formatPartsResult = [{"type": "integer", "value": "2", "unit": "year"}, {"type":"literal", "value": "years later"}]
```
@@ -390,6 +390,4 @@ According to grammars in certain languages, the singular or plural form of a nou
The following sample is provided to help you better understand how to develop internationalization capabilities:
--[`International`: Internationalization (JS) (API8)](https://gitee.com/openharmony/applications_app_samples/tree/master/UI/International)
-
--[`International`: Internationalization (ArkTS) (API8) (Full SDK)](https://gitee.com/openharmony/applications_app_samples/tree/master/common/International)
+-[`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 926a2718a48dcefd217e503932f9d9f997d1275e..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](audio-playback.md)
- - [Audio Recording Development](audio-recorder.md)
- - [Video Playback Development](video-playback.md)
- - [Video Recording Development](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/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/progress-bar-notification.md b/en/application-dev/notification/progress-bar-notification.md
index d79f09578a0dc58b0aa53e45b68264f85e67e2c2..8090e7e835dae7f0658127fafbf04680a4e81114 100644
--- a/en/application-dev/notification/progress-bar-notification.md
+++ b/en/application-dev/notification/progress-bar-notification.md
@@ -27,7 +27,7 @@ In the [NotificationTemplate](../reference/apis/js-apis-notificationManager.md#n
```ts
notificationManager.isSupportTemplate('downloadTemplate').then((data) => {
console.info(`[ANS] isSupportTemplate success`);
- let isSupportTpl: boolean = data; // The value **true** means that the template of the **downloadTemplate** type is supported; and false means the opposite.
+ let isSupportTpl: boolean = data; // The value true means that the template of the downloadTemplate type is supported, and false means the opposite.
// ...
}).catch((err) => {
console.error(`[ANS] isSupportTemplate failed, code is ${err.code}, message is ${err.message}`);
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..e0350b4c4ab31285f37eb18e819a4e84ad0759a7 100644
--- a/en/application-dev/quick-start/Readme-EN.md
+++ b/en/application-dev/quick-start/Readme-EN.md
@@ -10,7 +10,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)
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..c59ee04dccef3411c25326851c446dcdd3f7164f 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 |
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
new file mode 100644
index 0000000000000000000000000000000000000000..d706c76afd647d0e96c039175f0682ed203c78b2
--- /dev/null
+++ b/en/application-dev/quick-start/full-sdk-compile-guide.md
@@ -0,0 +1,29 @@
+# Full SDK Compilation Guide
+
+The full SDK provides a full set of APIs available in OpenHarmony, including system APIs required by system applications. Vendors can leverage this SDK to develop applications.
+
+Since OpenHarmony 3.2 Beta5, the full SDK is not provided with the version. If necessary, you can compile the SDK using the full source code.
+
+## Compiling the Full SDK
+
+**Preparation**
+
+1. Register an SSH public key for access to Gitee.
+2. Configure the server environment. For details, see [Setting Up the Ubuntu Environment](../../device-dev/quick-start/quickstart-ide-env-ubuntu.md).
+
+**Procedure**
+
+1. Download and initialize the manifest repository: **repo init -u https://gitee.com/openharmony/manifest.git -b $manifest_branch --no-repo-verify --repo-url=https://gitee.com/oschina/repo --no-clone-bundle**
+
+2. Download source code based on the downloaded manifest repository: **repo sync -c -d --force-sync**
+
+3. Perform precompilation: **yes y | apt install libxinerama-dev libxcursor-dev libxrandr-dev libxi-dev && rm -rf prebuilts/clang/ohos/darwin-x86_64/clang-480513 && rm -rf prebuilts/clang/ohos/windows-x86_64/clang-480513 && rm -rf prebuilts/clang/ohos/linux-x86_64/clang-480513 && bash build/prebuilts_download.sh -ndk && apt-get update -qqy && apt-get install doxygen -y --force-yes**
+
+4. Perform compilation: **./build.sh --product-name ohos-sdk**
+
+
+If the compilation is successful, export the files in the **out/sdk/packages/ohos-sdk/** directory.
+
+## 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).
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/module-configuration-file.md b/en/application-dev/quick-start/module-configuration-file.md
index 67361fccfd749495e2f5825d5ccac6efe1505ed9..2f308d7e5936d4fd62fbf5c22cee827e7bbc38a4 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**)|
@@ -540,7 +539,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 +698,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/resource-categories-and-access.md b/en/application-dev/quick-start/resource-categories-and-access.md
index 56e8209a5c19e353a21b80ff8b34dd51885db310..aa5e53ae90c1794125f5b6ae8a8f7a5115128743 100644
--- a/en/application-dev/quick-start/resource-categories-and-access.md
+++ b/en/application-dev/quick-start/resource-categories-and-access.md
@@ -35,7 +35,7 @@ resources
| Category | base Subdirectory | Qualifiers Subdirectory | rawfile Subdirectory |
| ---- | ---------------------------------------- | ---------------------------------------- | ---------------------------------------- |
-| Structure| The **base** subdirectory is a default directory. If no qualifiers subdirectories in the **resources** directory of the application match the device status, the resource file in the **base** subdirectory will be automatically referenced.
Resource group subdirectories are located at the second level of subdirectories to store basic elements such as strings, colors, and boolean values, as well as resource files such as media, animations, and layouts. For details, see [Resource Group Subdirectories](#resource-group-subdirectories).| You need to create qualifiers subdirectories on your own. Each directory name consists of one or more qualifiers that represent the application scenarios or device characteristics. For details, see [Qualifiers Subdirectories](#qualifiers-subdirectories).
Resource group subdirectories are located at the second level of subdirectories to store basic elements such as strings, colors, and boolean values, as well as resource files such as media, animations, and layouts. For details, see [Resource Group Subdirectories](#resource-group-subdirectories). | You can create multiple levels of subdirectories with custom directory names. They can be used to store various resource files.
However, resource files in the **rawfile** subdirectory will not be matched based on the device status.|
+| Structure| The **base** subdirectory is a default directory. If no qualifiers subdirectories in the **resources** directory of the application match the device status, the resource file in the **base** subdirectory will be automatically referenced.
Resource group subdirectories are located at the second level of subdirectories to store basic elements such as strings, colors, and boolean values, as well as resource files such as media, animations, and layouts. For details, see [Resource Group Subdirectories](#resource-group-subdirectories).| You need to create qualifiers subdirectories on your own. Each directory name consists of one or more qualifiers that represent the application scenarios or device characteristics. For details, see [Qualifiers Subdirectories](#qualifiers-subdirectories).
Resource group subdirectories are located at the second level of subdirectories to store basic elements such as strings, colors, and boolean values, as well as resource files such as media, animations, and layouts. For details, see [Resource Group Subdirectories](#resource-group-subdirectories).| You can create multiple levels of subdirectories with custom directory names. They can be used to store various resource files.
However, resource files in the **rawfile** subdirectory will not be matched based on the device status.|
| Compilation| Resource files in the subdirectory are compiled into binary files, and each resource file is assigned an ID. | Resource files in the subdirectory are compiled into binary files, and each resource file is assigned an ID. | Resource files in the subdirectory are directly packed into the application without being compiled, and no IDs will be assigned to the resource files. |
| Reference| Resource files in the subdirectory are referenced based on the resource type and resource name. | Resource files in the subdirectory are referenced based on the resource type and resource name. | Resource files in the subdirectory are referenced based on the file path and file name. |
@@ -81,9 +81,9 @@ You can create resource group subdirectories (including element, media, and prof
| Resource Group Subdirectory | Description | Resource File |
| ------- | ---------------------------------------- | ---------------------------------------- |
-| element | Indicates element resources. Each type of data is represented by a JSON file. The options are as follows:
- **boolean**: boolean data
- **color**: color data
- **float**: floating-point data
- **intarray**: array of integers
- **integer**: integer data
- **pattern**: pattern data
- **plural**: plural form data
- **strarray**: array of strings
- **string**: string data| It is recommended that files in the **element** subdirectory be named the same as the following files, each of which can contain only data of the same type:
- boolean.json
- color.json
- float.json
- intarray.json
- integer.json
- pattern.json
- plural.json
- strarray.json
- string.json |
-| media | Indicates media resources, including non-text files such as images, audios, and videos. | The file name can be customized, for example, **icon.png**. |
-| profile | Indicates a user-defined configuration file. You can obtain the file content by using the [getProfileByAbility](../reference/apis/js-apis-bundleManager.md#bundlemanagergetprofilebyability) API. | The file name can be customized, for example, **test_profile.json**. |
+| element | Indicates element resources. Each type of data is represented by a JSON file. (Only files are supported in this directory.) The options are as follows:
- **boolean**: boolean data
- **color**: color data
- **float**: floating-point data
- **intarray**: array of integers
- **integer**: integer data
- **pattern**: pattern data
- **plural**: plural form data
- **strarray**: array of strings
- **string**: string data| It is recommended that files in the **element** subdirectory be named the same as the following files, each of which can contain only data of the same type:
- boolean.json
- color.json
- float.json
- intarray.json
- integer.json
- pattern.json
- plural.json
- strarray.json
- string.json |
+| media | Indicates media resources, including non-text files such as images, audios, and videos. (Only files are supported in this directory.) | The file name can be customized, for example, **icon.png**. |
+| profile | Indicates a custom configuration file. You can obtain the file content by using the [getProfileByAbility](../reference/apis/js-apis-bundleManager.md#bundlemanagergetprofilebyability) API. (Only files are supported in this directory.) | The file name can be customized, for example, **test_profile.json**. |
| rawfile | Indicates other types of files, which are stored in their raw formats after the application is built as an HAP file. They will not be integrated into the **resources.index** file.| The file name can be customized. |
**Media Resource Types**
@@ -229,7 +229,7 @@ When referencing resources in the **rawfile** subdirectory, use the **"$rawfile(
>
> Resource descriptors accept only strings, such as **'app.type.name'**, and cannot be combined.
>
-> The return value of **$r** is a **Resource** object. You can obtain the corresponding string by using the [getStringValue](../reference/apis/js-apis-resource-manager.md) API.
+> The return value of **$r** is a **Resource** object. You can obtain the corresponding string by using the [getStringValue](../reference/apis/js-apis-resource-manager.md#getstringvalue9) API.
In the **.ets** file, you can use the resources defined in the **resources** directory. The following is a resource usage example based on the resource file examples in [Resource Group Sub-directories](#resource-group-subdirectories):
@@ -252,7 +252,6 @@ Text($r('app.string.message_arrive', "five'o clock"))
Text($r('app.plural.eat_apple', 5, 5))
.fontColor($r('app.color.color_world'))
.fontSize($r('app.float.font_world'))
-}
Image($r('app.media.my_background_image')) // Reference media resources.
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/reference/apis/Readme-EN.md b/en/application-dev/reference/apis/Readme-EN.md
index 0de7d46e88f8a4d568593616b1bf73bf4c44b95e..4f2555b95a8651ade5b99ec329033dd7bfdb184f 100644
--- a/en/application-dev/reference/apis/Readme-EN.md
+++ b/en/application-dev/reference/apis/Readme-EN.md
@@ -125,6 +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)
@@ -149,13 +163,17 @@
- [permissionDef](js-apis-bundleManager-permissionDef.md)
- [remoteAbilityInfo](js-apis-bundleManager-remoteAbilityInfo.md)
- [shortcutInfo](js-apis-bundleManager-shortcutInfo.md)
+
- UI Page
- [@ohos.animator (Animator)](js-apis-animator.md)
- [@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)
+
- Graphics
- [@ohos.animation.windowAnimationManager (Window Animation Management)](js-apis-windowAnimationManager.md)
- [@ohos.application.WindowExtensionAbility (WindowExtensionAbility)](js-apis-application-windowExtensionAbility.md)
@@ -168,24 +186,29 @@
- webgl
- [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)
- [@ohos.resourceschedule.workScheduler (Work Scheduler)](js-apis-resourceschedule-workScheduler.md)
- [@ohos.resourceschedule.usageStatistics (Device Usage Statistics)](js-apis-resourceschedule-deviceUsageStatistics.md)
- [@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)
@@ -194,9 +217,9 @@
- [@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)
+
- Data Management
- [@ohos.data.dataAbility (DataAbility Predicates)](js-apis-data-ability.md)
- [@ohos.data.dataShare (DataShare)](js-apis-data-dataShare.md)
@@ -209,18 +232,19 @@
- [@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.fs (File Management)](js-apis-file-fs.md)
- [@ohos.file.hash (File Hash Processing)](js-apis-file-hash.md)
+ - [@ohos.file.picker (Picker)](js-apis-file-picker.md)
- [@ohos.file.securityLabel (Data Label)](js-apis-file-securityLabel.md)
- [@ohos.file.statvfs (File System Space Statistics)](js-apis-file-statvfs.md)
- [@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)
- Telephony Service
- [@ohos.contact (Contacts)](js-apis-contact.md)
@@ -230,14 +254,17 @@
- [@ohos.telephony.radio (Network Search)](js-apis-radio.md)
- [@ohos.telephony.sim (SIM Management)](js-apis-sim.md)
- [@ohos.telephony.sms (SMS)](js-apis-sms.md)
+
- Network Management
- [@ohos.net.connection (Network Connection Management)](js-apis-net-connection.md)
- [@ohos.net.ethernet (Ethernet Connection Management)](js-apis-net-ethernet.md)
- [@ohos.net.http (Data Request)](js-apis-http.md)
+ - [@ohos.net.policy (Network Policy Management)](js-apis-net-policy.md)
- [@ohos.net.sharing (Network Sharing)](js-apis-net-sharing.md)
- [@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)
+
- Connectivity
- [@ohos.bluetooth (Bluetooth)](js-apis-bluetooth.md)
- [@ohos.connectedTag (Active Tags)](js-apis-connectedTag.md)
@@ -247,11 +274,12 @@
- [@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 (To Be Deprecated Soon)](js-apis-wifi.md)
+ - [@ohos.wifiext (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)
+
- Basic Features
- [@ohos.accessibility (Accessibility)](js-apis-accessibility.md)
- [@ohos.accessibility.config (System Accessibility Configuration)](js-apis-accessibility-config.md)
@@ -280,7 +308,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)
@@ -288,6 +316,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)
@@ -313,19 +342,24 @@
- [@ohos.update (Update)](js-apis-update.md)
- [@ohos.usbManager (USB Management)](js-apis-usbManager.md)
- [@ohos.vibrator (Vibrator)](js-apis-vibrator.md)
+
- Account Management
- [@ohos.account.appAccount (App Account Management)](js-apis-appAccount.md)
- [@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)
- [@ohos.enterprise.dateTimeManager (System Time Management)](js-apis-enterprise-dateTimeManager.md)
- [@ohos.enterprise.deviceControl (Device Control Management)](js-apis-enterprise-deviceControl.md)
- [@ohos.enterprise.deviceInfo (Device Information Management)](js-apis-enterprise-deviceInfo.md)
- [@ohos.enterprise.EnterpriseAdminExtensionAbility (EnterpriseAdminExtensionAbility)](js-apis-EnterpriseAdminExtensionAbility.md)
+ - [@ohos.enterprise.networkManager (Network Management)](js-apis-enterprise-networkManager.md)
+ - [@ohos.enterprise.wifiManager (Wi-Fi Management)](js-apis-enterprise-wifiManager.md)
- - Language Base Class Library
+- Language Base Class Library
- [@ohos.buffer (Buffer)](js-apis-buffer.md)
- [@ohos.convertxml (XML-to-JavaScript Conversion)](js-apis-convertxml.md)
- [@ohos.process (Obtaining Process Information)](js-apis-process.md)
@@ -349,9 +383,11 @@
- [@ohos.util.Vector (Linear Container Vector)](js-apis-vector.md)
- [@ohos.worker (Worker Startup)](js-apis-worker.md)
- [@ohos.xml (XML Parsing and Generation)](js-apis-xml.md)
+
- Test
- [@ohos.application.testRunner (TestRunner)](js-apis-application-testRunner.md)
- [@ohos.uitest (UiTest)](js-apis-uitest.md)
+
- APIs No Longer Maintained
- [@ohos.backgroundTaskManager (Background Task Management)](js-apis-backgroundTaskManager.md)
- [@ohos.bundle (Bundle)](js-apis-Bundle.md)
@@ -366,6 +402,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)
@@ -377,6 +414,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)
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..0670b6ca701ef78962deea0085dfbe2db1cbe863 100644
--- a/en/application-dev/reference/apis/commonEventManager-definitions.md
+++ b/en/application-dev/reference/apis/commonEventManager-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
@@ -658,6 +658,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 +849,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 +909,23 @@ 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
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_0000001219864133.PNG b/en/application-dev/reference/apis/figures/en-us_image_0000001219864133.PNG
index 14f81499ff0b1b8ef46257bc35a79e94775cd2ba..54be7ed38fa40349036e18b962ee52deb579a033 100644
Binary files a/en/application-dev/reference/apis/figures/en-us_image_0000001219864133.PNG and b/en/application-dev/reference/apis/figures/en-us_image_0000001219864133.PNG differ
diff --git a/en/application-dev/reference/apis/js-apis-Bundle.md b/en/application-dev/reference/apis/js-apis-Bundle.md
index f537fc5fe11a199afab4821b29b199499faa6c97..0051896a67f1dd2c9e662ed1ac503259ad6a7997 100644
--- a/en/application-dev/reference/apis/js-apis-Bundle.md
+++ b/en/application-dev/reference/apis/js-apis-Bundle.md
@@ -157,7 +157,7 @@ bundle.getApplicationInfo(bundleName, bundleFlags, (err, data) => {
> This API is deprecated since API version 9. You are advised to use [bundleManager.getAllBundleInfo](js-apis-bundleManager.md#bundlemanagergetallbundleinfo) instead.
-getAllBundleInfo(bundleFlag: BundleFlag, userId?: number): Promise>
+getAllBundleInfo(bundleFlag: BundleFlag, userId?: number): Promise\\>
Obtains the information of all bundles of the specified user. This API uses a promise to return the result.
@@ -201,7 +201,7 @@ bundle.getAllBundleInfo(bundleFlag, userId)
> This API is deprecated since API version 9. You are advised to use [bundleManager.getAllBundleInfo](js-apis-bundleManager.md#bundlemanagergetallbundleinfo) instead.
-getAllBundleInfo(bundleFlag: BundleFlag, callback: AsyncCallback>): void
+getAllBundleInfo(bundleFlag: BundleFlag, callback: AsyncCallback\\>): void
Obtains the information of all bundles of the current user. This API uses an asynchronous callback to return the result.
@@ -238,7 +238,7 @@ bundle.getAllBundleInfo(bundleFlag, (err, data) => {
> This API is deprecated since API version 9. You are advised to use [bundleManager.getAllBundleInfo](js-apis-bundleManager.md#bundlemanagergetallbundleinfo) instead.
-getAllBundleInfo(bundleFlag: BundleFlag, userId: number, callback: AsyncCallback>): void
+getAllBundleInfo(bundleFlag: BundleFlag, userId: number, callback: AsyncCallback\\>): void
Obtains the information of all bundles of the specified user. This API uses an asynchronous callback to return the result.
@@ -823,7 +823,7 @@ bundle.getPermissionDef(permissionName).then((data) => {
> This API is deprecated since API version 9. You are advised to use [bundleManager.getAllApplicationInfo](js-apis-bundleManager.md#bundlemanagergetallapplicationinfo) instead.
-getAllApplicationInfo(bundleFlags: number, userId?: number): Promise>
+getAllApplicationInfo(bundleFlags: number, userId?: number): Promise\\>
Obtains the information about all applications of the specified user. This API uses a promise to return the result.
@@ -865,7 +865,7 @@ bundle.getAllApplicationInfo(bundleFlags, userId)
> This API is deprecated since API version 9. You are advised to use [bundleManager.getAllApplicationInfo](js-apis-bundleManager.md#bundlemanagergetallapplicationinfo) instead.
-getAllApplicationInfo(bundleFlags: number, userId: number, callback: AsyncCallback>): void
+getAllApplicationInfo(bundleFlags: number, userId: number, callback: AsyncCallback\\>): void
Obtains the information about all applications. This API uses an asynchronous callback to return the result.
@@ -1320,7 +1320,7 @@ bundle.isApplicationEnabled(bundleName, (err, data) => {
> This API is deprecated since API version 9. You are advised to use [bundleManager.queryAbilityInfo](js-apis-bundleManager.md#bundlemanagerqueryabilityinfo) instead.
-queryAbilityByWant(want: Want, bundleFlags: number, userId?: number): Promise>
+queryAbilityByWant(want: Want, bundleFlags: number, userId?: number): Promise\\>
Obtains the ability information based on given Want. This API uses a promise to return the result.
@@ -1371,7 +1371,7 @@ bundle.queryAbilityByWant(want, bundleFlags, userId)
> This API is deprecated since API version 9. You are advised to use [bundleManager.queryAbilityInfo](js-apis-bundleManager.md#bundlemanagerqueryabilityinfo) instead.
-queryAbilityByWant(want: Want, bundleFlags: number, userId: number, callback: AsyncCallback>): void
+queryAbilityByWant(want: Want, bundleFlags: number, userId: number, callback: AsyncCallback\\>): void
Obtains the ability information of the specified user based on given Want. This API uses an asynchronous callback to return the result.
@@ -1416,7 +1416,7 @@ bundle.queryAbilityByWant(want, bundleFlags, userId, (err, data) => {
> This API is deprecated since API version 9. You are advised to use [bundleManager.queryAbilityInfo](js-apis-bundleManager.md#bundlemanagerqueryabilityinfo) instead.
-queryAbilityByWant(want: Want, bundleFlags: number, callback: AsyncCallback>): void;
+queryAbilityByWant(want: Want, bundleFlags: number, callback: AsyncCallback\\>): void;
Obtains the ability information based on given Want. This API uses an asynchronous callback to return the result.
diff --git a/en/application-dev/reference/apis/js-apis-WorkSchedulerExtensionAbility.md b/en/application-dev/reference/apis/js-apis-WorkSchedulerExtensionAbility.md
index a22f7b48a977066e085da4b9ddfcdeb24f21463f..33555ada83df3e20766793df3208f250ac612a00 100644
--- a/en/application-dev/reference/apis/js-apis-WorkSchedulerExtensionAbility.md
+++ b/en/application-dev/reference/apis/js-apis-WorkSchedulerExtensionAbility.md
@@ -16,6 +16,14 @@ When developing an application, you can override the APIs of this module and add
import WorkSchedulerExtensionAbility from '@ohos.WorkSchedulerExtensionAbility'
```
+## Attributes
+
+**System capability**: SystemCapability.ResourceSchedule.WorkScheduler
+
+| Name| Type| Readable| Writable| Description|
+| -------- | -------- | -------- | -------- | -------- |
+| context | [WorkSchedulerExtensionContext](js-apis-inner-application-WorkSchedulerExtensionContext.md) | Yes| No| Context of the **WorkSchedulerExtension**. This context is inherited from **ExtensionContext**.|
+
## WorkSchedulerExtensionAbility.onWorkStart
onWorkStart(work: workScheduler.WorkInfo): void
diff --git a/en/application-dev/reference/apis/js-apis-ability-featureAbility.md b/en/application-dev/reference/apis/js-apis-ability-featureAbility.md
index 836f07ef61ee7b5801fe86b3dbbaed72c017e466..262899f64ed644007d28d1dce9b53c369a830f12 100644
--- a/en/application-dev/reference/apis/js-apis-ability-featureAbility.md
+++ b/en/application-dev/reference/apis/js-apis-ability-featureAbility.md
@@ -57,8 +57,12 @@ featureAbility.startAbility(
uri: ''
},
},
- (err, data) => {
- console.info('startAbility err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}');
+ (error, data) => {
+ if (error && error.code !== 0) {
+ console.error('startAbility fail, error: ${JSON.stringify(error)}');
+ } else {
+ console.log('startAbility success, data: ${JSON.stringify(data)}');
+ }
}
);
```
@@ -99,7 +103,7 @@ featureAbility.startAbility(
{
want:
{
- action: 'action.system.home',
+ action: 'ohos.want.action.home',
entities: ['entity.system.home'],
type: 'MIMETYPE',
flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION,
@@ -182,7 +186,7 @@ featureAbility.startAbilityForResult(
{
want:
{
- action: 'action.system.home',
+ action: 'ohos.want.action.home',
entities: ['entity.system.home'],
type: 'MIMETYPE',
flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION,
@@ -193,8 +197,12 @@ featureAbility.startAbilityForResult(
uri:''
},
},
- (err, data) => {
- console.info('startAbilityForResult err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}');
+ (error, data) => {
+ if (error && error.code !== 0) {
+ console.error('startAbilityForResult fail, error: ${JSON.stringify(error)}');
+ } else {
+ console.log('startAbilityForResult success, data: ${JSON.stringify(data)}');
+ }
}
);
```
@@ -236,7 +244,7 @@ featureAbility.startAbilityForResult(
{
want:
{
- action: 'action.system.home',
+ action: 'ohos.want.action.home',
entities: ['entity.system.home'],
type: 'MIMETYPE',
flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION,
@@ -288,7 +296,7 @@ featureAbility.terminateSelfWithResult(
resultCode: 1,
want:
{
- action: 'action.system.home',
+ action: 'ohos.want.action.home',
entities: ['entity.system.home'],
type: 'MIMETYPE',
flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION,
@@ -309,8 +317,8 @@ featureAbility.terminateSelfWithResult(
}
},
},
- (err) => {
- console.error('err: ${JSON.stringify(err)}');
+ (error) => {
+ console.error('error: ${JSON.stringify(error)}');
}
);
```
@@ -345,7 +353,7 @@ featureAbility.terminateSelfWithResult(
resultCode: 1,
want:
{
- action: 'action.system.home',
+ action: 'ohos.want.action.home',
entities: ['entity.system.home'],
type: 'MIMETYPE',
flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION,
@@ -389,8 +397,12 @@ Checks whether the main window of this ability has the focus. This API uses an a
```ts
import featureAbility from '@ohos.ability.featureAbility';
-featureAbility.hasWindowFocus((err, data) => {
- console.info('hasWindowFocus err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}');
+featureAbility.hasWindowFocus((error, data) => {
+ if (error && error.code !== 0) {
+ console.error('hasWindowFocus fail, error: ${JSON.stringify(error)}');
+ } else {
+ console.log('hasWindowFocus success, data: ${JSON.stringify(data)}');
+ }
});
```
@@ -435,8 +447,12 @@ Obtains the Want corresponding to the ability to start. This API uses an asynchr
```ts
import featureAbility from '@ohos.ability.featureAbility';
-featureAbility.getWant((err, data) => {
- console.info('getWant err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}');
+featureAbility.getWant((error, data) => {
+ if (error && error.code !== 0) {
+ console.error('getWant fail, error: ${JSON.stringify(error)}');
+ } else {
+ console.log('getWant success, data: ${JSON.stringify(data)}');
+ }
});
```
@@ -482,8 +498,12 @@ Obtains the application context.
```ts
import featureAbility from '@ohos.ability.featureAbility';
let context = featureAbility.getContext();
-context.getBundleName((err, data) => {
- console.info('getBundleName err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}');
+context.getBundleName((error, data) => {
+ if (error && error.code !== 0) {
+ console.error('getBundleName fail, error: ${JSON.stringify(error)}');
+ } else {
+ console.log('getBundleName success, data: ${JSON.stringify(data)}');
+ }
});
```
@@ -506,8 +526,8 @@ Terminates this ability. This API uses an asynchronous callback to return the re
```ts
import featureAbility from '@ohos.ability.featureAbility';
featureAbility.terminateSelf(
- (err) => {
- console.error('err: ${JSON.stringify(err)}');
+ (error) => {
+ console.error('error: ${JSON.stringify(error)}');
}
)
```
@@ -574,7 +594,7 @@ function onDisconnectCallback(element){
console.log('ConnectAbility onDisconnect element.deviceId : ${element.deviceId}')
}
function onFailedCallback(code){
- console.log('featureAbilityTest ConnectAbility onFailed errCode : ${code}')
+ console.error('featureAbilityTest ConnectAbility onFailed errCode : ${code}')
}
let connectId = featureAbility.connectAbility(
{
@@ -617,7 +637,7 @@ function onDisconnectCallback(element){
console.log('ConnectAbility onDisconnect element.deviceId : ${element.deviceId}');
}
function onFailedCallback(code){
- console.log('featureAbilityTest ConnectAbility onFailed errCode : ${code}');
+ console.error('featureAbilityTest ConnectAbility onFailed errCode : ${code}');
}
let connectId = featureAbility.connectAbility(
{
@@ -631,8 +651,12 @@ let connectId = featureAbility.connectAbility(
},
);
-featureAbility.disconnectAbility(connectId, (err) => {
- console.error('featureAbilityTest disconnectAbility err: ${JSON.stringify(err)}');
+featureAbility.disconnectAbility(connectId, (error) => {
+ if (error && error.code !== 0) {
+ console.error('disconnectAbility fail, connectId: ${connectId}, error: ${JSON.stringify(error)}');
+ } else {
+ console.log('disconnectAbility success, connectId: ${connectId}');
+ }
});
```
@@ -668,7 +692,7 @@ function onDisconnectCallback(element){
console.log('ConnectAbility onDisconnect element.deviceId : ${element.deviceId}');
}
function onFailedCallback(code){
- console.log('featureAbilityTest ConnectAbility onFailed errCode : ${code}');
+ console.error('featureAbilityTest ConnectAbility onFailed errCode : ${code}');
}
let connectId = featureAbility.connectAbility(
{
@@ -707,8 +731,12 @@ Obtains the window corresponding to this ability. This API uses an asynchronous
**Example**
```ts
-featureAbility.getWindow((err, data) => {
- console.info('getWindow err: ${JSON.stringify(err)}, data: ${typeof(data)}');
+featureAbility.getWindow((error, data) => {
+ if (error && error.code !== 0) {
+ console.error('getWindow fail, error: ${JSON.stringify(error)}');
+ } else {
+ console.log('getWindow success, data: ${JSON.stringify(data)}');
+ }
});
```
@@ -823,6 +851,6 @@ Enumerates the flags that specify how the Want will be handled.
| FLAG_ABILITY_CONTINUATION_REVERSIBLE | 0x00000400 | Indicates that the migration is reversible. |
| FLAG_INSTALL_ON_DEMAND | 0x00000800 | Indicates that the specific ability will be installed if it has not been installed. |
| FLAG_INSTALL_WITH_BACKGROUND_MODE | 0x80000000 | Indicates that the specific ability will be installed in the background if it has not been installed. |
-| FLAG_ABILITY_CLEAR_MISSION | 0x00008000 | Clears other operation missions. This flag can be set for the **Want** object in the **startAbility** API passed to [ohos.app.Context](js-apis-ability-context.md) and must be used together with **flag_ABILITY_NEW_MISSION**.|
+| FLAG_ABILITY_CLEAR_MISSION | 0x00008000 | Clears other operation missions. This flag can be set for [Want](js-apis-application-want.md) under the [parameter](js-apis-inner-ability-startAbilityParameter.md) object passed to the [startAbility](#featureabilitystartability) API in **FeatureAbility**. It must be used together with **flag_ABILITY_NEW_MISSION**.|
| FLAG_ABILITY_NEW_MISSION | 0x10000000 | Creates a mission on an existing 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-ability-particleAbility.md b/en/application-dev/reference/apis/js-apis-ability-particleAbility.md
index d4c5a739a80f7976f1581454423cc8c4d824035d..1afa116d859733011cd323f6eda58b7dea225d96 100644
--- a/en/application-dev/reference/apis/js-apis-ability-particleAbility.md
+++ b/en/application-dev/reference/apis/js-apis-ability-particleAbility.md
@@ -47,7 +47,7 @@ particleAbility.startAbility(
{
want:
{
- action: 'action.system.home',
+ action: 'ohos.want.action.home',
entities: ['entity.system.home'],
type: 'MIMETYPE',
flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION,
@@ -57,8 +57,12 @@ particleAbility.startAbility(
uri: ''
},
},
- (error, result) => {
- console.error('particleAbility startAbility errCode: ${JSON.stringify(error)}, result: ${JSON.stringify(result)}');
+ (error, data) => {
+ if (error && error.code !== 0) {
+ console.error('startAbility fail, error: ${JSON.stringify(error)}');
+ } else {
+ console.log('startAbility success, data: ${JSON.stringify(data)}');
+ }
},
);
```
@@ -98,7 +102,7 @@ particleAbility.startAbility(
{
want:
{
- action: 'action.system.home',
+ action: 'ohos.want.action.home',
entities: ['entity.system.home'],
type: 'MIMETYPE',
flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION,
@@ -133,8 +137,12 @@ Terminates this ParticleAbility. This API uses an asynchronous callback to retur
import particleAbility from '@ohos.ability.particleAbility';
particleAbility.terminateSelf(
- (error, result) => {
- console.log('particleAbility terminateSelf errCode: ${JSON.stringify(error)}, result: ${JSON.stringify(result)}');
+ (error, data) => {
+ if (error && error.code !== 0) {
+ console.error('terminateSelf fail, error: ${JSON.stringify(error)}');
+ } else {
+ console.log('terminateSelf success, data: ${JSON.stringify(data)}');
+ }
}
);
```
@@ -226,11 +234,11 @@ import notification from '@ohos.notification';
import particleAbility from '@ohos.ability.particleAbility';
import wantAgent from '@ohos.app.ability.wantAgent';
-function callback(err, data) {
- if (err) {
- console.error('Operation failed cause: ${JSON.stringify(err)}');
+function callback(error, data) {
+ if (error && error.code !== 0) {
+ console.error('Operation failed error: ${JSON.stringify(error)}');
} else {
- console.info('Operation succeeded');
+ console.info('Operation succeeded, data: ${data}');
}
}
@@ -349,11 +357,11 @@ Requests to cancel a continuous task from the system. This API uses an asynchron
```ts
import particleAbility from '@ohos.ability.particleAbility';
-function callback(err, data) {
- if (err) {
- console.error('Operation failed cause: ${JSON.stringify(err)}');
+function callback(error, data) {
+ if (error && error.code !== 0) {
+ console.error('Operation failed error: ${JSON.stringify(error)}');
} else {
- console.info('Operation succeeded');
+ console.info('Operation succeeded, data: ${data}');
}
}
@@ -421,11 +429,11 @@ function onConnectCallback(element, remote) {
}
function onDisconnectCallback(element) {
- console.log('ConnectAbility onDisconnect element.deviceId : ${element.deviceId}');
+ console.log('ConnectAbility onDisconnect element.deviceId: ${element.deviceId}');
}
function onFailedCallback(code) {
- console.log('particleAbilityTest ConnectAbility onFailed errCode : ${code}');
+ console.error('particleAbilityTest ConnectAbility onFailed errCode: ${code}');
}
let connId = particleAbility.connectAbility(
@@ -441,9 +449,9 @@ let connId = particleAbility.connectAbility(
);
particleAbility.disconnectAbility(connId).then((data) => {
- console.log(' data: ${data}');
+ console.log('data: ${data}');
}).catch((error) => {
- console.log('particleAbilityTest result errCode : ${error.code}');
+ console.error('particleAbilityTest result errCode: ${error.code}');
});
```
@@ -472,11 +480,11 @@ function onConnectCallback(element, remote) {
}
function onDisconnectCallback(element) {
- console.log('ConnectAbility onDisconnect element.deviceId : ${element.deviceId}');
+ console.log('ConnectAbility onDisconnect element.deviceId: ${element.deviceId}');
}
function onFailedCallback(code) {
- console.log('particleAbilityTest ConnectAbility onFailed errCode : ${code}');
+ console.error('particleAbilityTest ConnectAbility onFailed errCode: ${code}');
}
let connId = particleAbility.connectAbility(
@@ -492,7 +500,7 @@ let connId = particleAbility.connectAbility(
);
particleAbility.disconnectAbility(connId, (err) => {
- console.log('particleAbilityTest disconnectAbility err: ${JSON.stringify(err)}');
+ console.error('particleAbilityTest disconnectAbility err: ${JSON.stringify(err)}');
});
```
@@ -522,11 +530,11 @@ function onConnectCallback(element, remote) {
}
function onDisconnectCallback(element) {
- console.log('ConnectAbility onDisconnect element.deviceId : ${element.deviceId}');
+ console.log('ConnectAbility onDisconnect element.deviceId: ${element.deviceId}');
}
function onFailedCallback(code) {
- console.log('particleAbilityTest ConnectAbility onFailed errCode : ${code}');
+ console.error('particleAbilityTest ConnectAbility onFailed errCode: ${code}');
}
let connId = particleAbility.connectAbility(
@@ -544,7 +552,7 @@ let connId = particleAbility.connectAbility(
particleAbility.disconnectAbility(connId).then((data) => {
console.log(' data: ${data}');
}).catch((error) => {
- console.log('particleAbilityTest result errCode : ${error.code}');
+ console.error('particleAbilityTest result errCode : ${error.code}');
});
```
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 ff89b62d12e370ccaa046c40576405e8cfe72c22..54cea921d80648b17fe5384e4ea9e57336d32fc1 100644
--- a/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md
+++ b/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md
@@ -3,6 +3,7 @@
The **AbilityAccessCtrl** module provides APIs for application permission management, including authentication, authorization, and revocation.
> **NOTE**
+>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
@@ -15,7 +16,7 @@ import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
createAtManager(): AtManager
-Creates an **AtManager** instance, which is used for ability access control.
+Creates an **AtManager** instance, which is used for application access control.
**System capability**: SystemCapability.Security.AccessToken
@@ -34,7 +35,7 @@ let atManager = abilityAccessCtrl.createAtManager();
## AtManager
-Implements ability access control.
+Provides APIs for application access control.
### checkAccessToken9+
@@ -59,11 +60,11 @@ Checks whether a permission is granted to an application. This API uses a promis
**Error codes**
-For details about the error codes, see [Ability Access Control Error Codes](../errorcodes/errorcode-access-token.md).
+For details about the error codes, see [Application Access Control Error Codes](../errorcodes/errorcode-access-token.md).
| ID| Error Message|
| -------- | -------- |
-| 12100001 | The parameter is invalid. The tokenID is 0 |
+| 12100001 | The parameter is invalid. The tokenID is 0, or the string size of permissionName is larger than 256. |
**Example**
@@ -106,11 +107,11 @@ Verifies whether a permission is granted to an application. This API returns the
**Error codes**
-For details about the error codes, see [Ability Access Control Error Codes](../errorcodes/errorcode-access-token.md).
+For details about the error codes, see [Application Access Control Error Codes](../errorcodes/errorcode-access-token.md).
| ID| Error Message|
| -------- | -------- |
-| 12100001 | The parameter is invalid. The tokenID is 0 |
+| 12100001 | The parameter is invalid. The tokenID is 0, or the string size of permissionName is larger than 256. |
**Example**
@@ -123,7 +124,7 @@ console.log(`data->${JSON.stringify(data)}`);
### grantUserGrantedPermission
-grantUserGrantedPermission(tokenID: number, permissionName: Permissions, permissionFlag: number): Promise<void>
+grantUserGrantedPermission(tokenID: number, permissionName: Permissions, permissionFlags: number): Promise<void>
Grants a user_grant permission to an application. This API uses a promise to return the result.
@@ -139,7 +140,7 @@ Grants a user_grant permission to an application. This API uses a promise to ret
| --------- | ------------------- | ---- | ------------------------------------------------------------ |
| tokenID | number | Yes | Token ID of the application. The value can be obtained from [ApplicationInfo](js-apis-bundleManager-applicationInfo.md). |
| permissionName | Permissions | Yes | Permission to grant. For details about the permissions, see the [Application Permission List](../../security/permission-list.md).|
-| permissionFlag | number | Yes | Permission flag. The value **1** means that the permission request dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed. |
+| permissionFlags | number | Yes | Permission flag.
- **0**: The permission is not set by the user.
- **1**: A dialog box for user authorization will be displayed the next time if the user denies authorization for the permission.
- **2**: No dialog box will be displayed the next time if the user denies authorization for the permission. The permission must be granted by the user in **Settings**.
- **4**: The permission is authorized by the system and cannot be changed.|
**Return value**
@@ -149,11 +150,11 @@ Grants a user_grant permission to an application. This API uses a promise to ret
**Error codes**
-For details about the error codes, see [Ability Access Control Error Codes](../errorcodes/errorcode-access-token.md).
+For details about the error codes, see [Application Access Control Error Codes](../errorcodes/errorcode-access-token.md).
| ID| Error Message|
| -------- | -------- |
-| 12100001 | The parameter is invalid. The tokenID is 0 |
+| 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. |
| 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. |
@@ -166,9 +167,9 @@ import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
let atManager = abilityAccessCtrl.createAtManager();
let tokenID = 0; // Use bundleManager.getApplicationInfo() to obtain the token ID for a system application, and use bundleManager.getBundleInfoForSelf() to obtain the token ID for a non-system application.
-let permissionFlag = 1;
+let permissionFlags = 1;
try {
- atManager.grantUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", permissionFlag).then(() => {
+ atManager.grantUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", permissionFlags).then(() => {
console.log('grantUserGrantedPermission success');
}).catch((err) => {
console.log(`grantUserGrantedPermission fail, err->${JSON.stringify(err)}`);
@@ -180,7 +181,7 @@ try {
### grantUserGrantedPermission
-grantUserGrantedPermission(tokenID: number, permissionName: Permissions, permissionFlag: number, callback: AsyncCallback<void>): void
+grantUserGrantedPermission(tokenID: number, permissionName: Permissions, permissionFlags: number, callback: AsyncCallback<void>): void
Grants a user_grant permission to an application. This API uses an asynchronous callback to return the result.
@@ -196,16 +197,16 @@ Grants a user_grant permission to an application. This API uses an asynchronous
| --------- | ------------------- | ---- | ------------------------------------------------------------ |
| tokenID | number | Yes | Token ID of the application. The value can be obtained from [ApplicationInfo](js-apis-bundleManager-applicationInfo.md).|
| permissionName | Permissions | Yes | Permission to grant. For details about the permissions, see the [Application Permission List](../../security/permission-list.md).|
-| permissionFlag | number | Yes | Permission flag. The value **1** means that the permission request dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed. |
-| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the permission is granted successfully, **err** is **undefined**. Otherwise, **err** is an error object.|
+| permissionFlags | number | Yes | Permission flag.
- **0**: The permission is not set by the user.
- **1**: A dialog box for user authorization will be displayed the next time if the user denies authorization for the permission.
- **2**: No dialog box will be displayed the next time if the user denies authorization for the permission. The permission must be granted by the user in **Settings**.
- **4**: The permission is authorized by the system and cannot be changed.|
+| callback | AsyncCallback<void> | Yes| Callback invoked to return the result. If the permission is granted, **err** is **undefined**. Otherwise, **err** is an error object.|
**Error codes**
-For details about the error codes, see [Ability Access Control Error Codes](../errorcodes/errorcode-access-token.md).
+For details about the error codes, see [Application Access Control Error Codes](../errorcodes/errorcode-access-token.md).
| ID| Error Message|
| -------- | -------- |
-| 12100001 | The parameter is invalid. The tokenID is 0 |
+| 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. |
| 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. |
@@ -218,9 +219,9 @@ import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
let atManager = abilityAccessCtrl.createAtManager();
let tokenID = 0; // Use bundleManager.getApplicationInfo() to obtain the token ID for a system application, and use bundleManager.getBundleInfoForSelf() to obtain the token ID for a non-system application.
-let permissionFlag = 1;
+let permissionFlags = 1;
try {
- atManager.grantUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", permissionFlag, (err, data) => {
+ atManager.grantUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", permissionFlags, (err, data) => {
if (err) {
console.log(`grantUserGrantedPermission fail, err->${JSON.stringify(err)}`);
} else {
@@ -234,7 +235,7 @@ try {
### revokeUserGrantedPermission
-revokeUserGrantedPermission(tokenID: number, permissionName: Permissions, permissionFlag: number): Promise<void>
+revokeUserGrantedPermission(tokenID: number, permissionName: Permissions, permissionFlags: number): Promise<void>
Revokes a user_grant permission from an application. This API uses a promise to return the result.
@@ -250,7 +251,7 @@ Revokes a user_grant permission from an application. This API uses a promise to
| --------- | ------------------- | ---- | ------------------------------------------------------------ |
| tokenID | number | Yes | Token ID of the application. The value can be obtained from [ApplicationInfo](js-apis-bundleManager-applicationInfo.md). |
| permissionName | Permissions | Yes | Permission to revoke. For details about the permissions, see the [Application Permission List](../../security/permission-list.md).|
-| permissionFlag | number | Yes | Permission flag. The value **1** means that the permission request dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed. |
+| permissionFlags | number | Yes | Permission flag.
- **0**: The permission is not set by the user.
- **1**: A dialog box for user authorization will be displayed the next time if the user denies authorization for the permission.
- **2**: No dialog box will be displayed the next time if the user denies authorization for the permission. The permission must be granted by the user in **Settings**.
- **4**: The permission is authorized by the system and cannot be changed.|
**Return value**
@@ -260,11 +261,11 @@ Revokes a user_grant permission from an application. This API uses a promise to
**Error codes**
-For details about the error codes, see [Ability Access Control Error Codes](../errorcodes/errorcode-access-token.md).
+For details about the error codes, see [Application Access Control Error Codes](../errorcodes/errorcode-access-token.md).
| ID| Error Message|
| -------- | -------- |
-| 12100001 | The parameter is invalid. The tokenID is 0 |
+| 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. |
| 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. |
@@ -277,9 +278,9 @@ import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
let atManager = abilityAccessCtrl.createAtManager();
let tokenID = 0; // Use bundleManager.getApplicationInfo() to obtain the token ID for a system application, and use bundleManager.getBundleInfoForSelf() to obtain the token ID for a non-system application.
-let permissionFlag = 1;
+let permissionFlags = 1;
try {
- atManager.revokeUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", permissionFlag).then(() => {
+ atManager.revokeUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", permissionFlags).then(() => {
console.log('revokeUserGrantedPermission success');
}).catch((err) => {
console.log(`revokeUserGrantedPermission fail, err->${JSON.stringify(err)}`);
@@ -291,7 +292,7 @@ try {
### revokeUserGrantedPermission
-revokeUserGrantedPermission(tokenID: number, permissionName: Permissions, permissionFlag: number, callback: AsyncCallback<void>): void
+revokeUserGrantedPermission(tokenID: number, permissionName: Permissions, permissionFlags: number, callback: AsyncCallback<void>): void
Revokes a user_grant permission from an application. This API uses an asynchronous callback to return the result.
@@ -307,16 +308,16 @@ Revokes a user_grant permission from an application. This API uses an asynchrono
| --------- | ------------------- | ---- | ------------------------------------------------------------ |
| tokenID | number | Yes | Token ID of the application. The value can be obtained from [ApplicationInfo](js-apis-bundleManager-applicationInfo.md). |
| permissionName | Permissions | Yes | Permission to revoke. For details about the permissions, see the [Application Permission List](../../security/permission-list.md).|
-| permissionFlag | number | Yes | Permission flag. The value **1** means that the permission request dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed. |
-| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the permission is revoked successfully, **err** is **undefined**. Otherwise, **err** is an error object.|
+| permissionFlags | number | Yes | Permission flag.
- **0**: The permission is not set by the user.
- **1**: A dialog box for user authorization will be displayed the next time if the user denies authorization for the permission.
- **2**: No dialog box will be displayed the next time if the user denies authorization for the permission. The permission must be granted by the user in **Settings**.
- **4**: The permission is authorized by the system and cannot be changed.|
+| callback | AsyncCallback<void> | Yes| Callback invoked to return the result. If the permission is revoked, **err** is **undefined**. Otherwise, **err** is an error object.|
**Error codes**
-For details about the error codes, see [Ability Access Control Error Codes](../errorcodes/errorcode-access-token.md).
+For details about the error codes, see [Application Access Control Error Codes](../errorcodes/errorcode-access-token.md).
| ID| Error Message|
| -------- | -------- |
-| 12100001 | The parameter is invalid. The tokenID is 0 |
+| 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. |
| 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. |
@@ -329,9 +330,9 @@ import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
let atManager = abilityAccessCtrl.createAtManager();
let tokenID = 0; // Use bundleManager.getApplicationInfo() to obtain the token ID for a system application, and use bundleManager.getBundleInfoForSelf() to obtain the token ID for a non-system application.
-let permissionFlag = 1;
+let permissionFlags = 1;
try {
- atManager.revokeUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", permissionFlag, (err, data) => {
+ atManager.revokeUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", permissionFlags, (err, data) => {
if (err) {
console.log(`revokeUserGrantedPermission fail, err->${JSON.stringify(err)}`);
} else {
@@ -347,7 +348,7 @@ try {
getPermissionFlags(tokenID: number, permissionName: Permissions): Promise<number>
-Obtains the flags of the specified permission of an application. This API uses a promise to return the result.
+Obtains the permission flag of an application. This API uses a promise to return the result.
**System API**: This is a system API.
@@ -366,15 +367,15 @@ Obtains the flags of the specified permission of an application. This API uses a
| Type | Description |
| :------------ | :---------------------------------- |
-| Promise<number> | Promise used to return the result.|
+| Promise<number> | Promise used to return the permission flag obtained. |
**Error codes**
-For details about the error codes, see [Ability Access Control Error Codes](../errorcodes/errorcode-access-token.md).
+For details about the error codes, see [Application Access Control Error Codes](../errorcodes/errorcode-access-token.md).
| ID| Error Message|
| -------- | -------- |
-| 12100001 | The parameter is invalid. The tokenID is 0 |
+| 12100001 | The parameter is invalid. The tokenID is 0, or the string size of permissionName is larger than 256. |
| 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. |
@@ -426,9 +427,9 @@ promise.then(data => {
### on9+
-on(type: 'permissionStateChange', tokenIDList: Array<number>, permissionNameList: Array<Permissions>, callback: Callback<PermissionStateChangeInfo>): void;
+on(type: 'permissionStateChange', tokenIDList: Array<number>, permissionList: Array<Permissions>, callback: Callback<PermissionStateChangeInfo>): void;
-Subscribes to permission grant state changes of the specified applications and permissions.
+Subscribes to permission state changes of the specified applications and permissions.
**System API**: This is a system API.
@@ -440,18 +441,18 @@ Subscribes to permission grant state changes of the specified applications and p
| Name | Type | Mandatory| Description |
| ------------------ | --------------------- | ---- | ------------------------------------------------------------ |
-| type | string | Yes | Event type. The value is fixed at **'permissionStateChange'**, indicating the permission grant state change event. |
-| tokenIDList | Array<number> | Yes | List of token IDs. If this parameter is left empty, the permission grant state changes of all applications are subscribed to. |
-| permissionNameList | Array<Permissions> | Yes | List of permission names. If this parameter is left empty, the permission grant state changes of all permissions are subscribed to. |
-| callback | Callback<[PermissionStateChangeInfo](#permissionstatechangeinfo9)> | Yes| Callback used to return the permission grant state change information.|
+| type | string | Yes | Event type to subscribe to. The value is **'permissionStateChange'**, which indicates the permission grant state change. |
+| tokenIDList | Array<number> | Yes | Token IDs of the applications to observe. If this parameter is left empty, the permission grant state changes of all applications are observed. |
+| permissionList | Array<Permissions> | Yes | Permissions to observe. If this parameter is left empty, the grant state changes of all permissions are observed. |
+| callback | Callback<[PermissionStateChangeInfo](#permissionstatechangeinfo9)> | Yes| Callback invoked to return the permission grant state change.|
**Error codes**
-For details about the error codes, see [Ability Access Control Error Codes](../errorcodes/errorcode-access-token.md).
+For details about the error codes, see [Application Access Control Error Codes](../errorcodes/errorcode-access-token.md).
| ID| Error Message|
| -------- | -------- |
-| 12100001 | The parameter is invalid. The tokenID is 0 |
+| 12100001 | The parameter is invalid. The tokenID is 0, or the string size of permissionName is larger than 256. |
| 12100004 | The interface is called repeatedly with the same input. |
| 12100005 | The registration time has exceeded the limitation. |
| 12100007 | Service is abnormal. |
@@ -461,13 +462,14 @@ For details about the error codes, see [Ability Access Control Error Codes](../e
```js
import abilityAccessCtrl, {Permissions} from '@ohos.abilityAccessCtrl';
+import bundle from '@ohos.bundle.bundleManager';
let atManager = abilityAccessCtrl.createAtManager();
let appInfo = bundle.getApplicationInfoSync('com.example.myapplication', 0, 100);
let tokenIDList: Array = [appInfo.accessTokenId];
-let permissionNameList: Array = ["ohos.permission.DISTRIBUTED_DATASYNC"];
+let permissionList: Array = ["ohos.permission.DISTRIBUTED_DATASYNC"];
try {
- atManager.on('permissionStateChange', tokenIDList, permissionNameList, (data) => {
+ atManager.on('permissionStateChange', tokenIDList, permissionList, (data) => {
console.debug("receive permission state change, data:" + JSON.stringify(data));
});
} catch(err) {
@@ -477,9 +479,9 @@ try {
### off9+
-off(type: 'permissionStateChange', tokenIDList: Array<number>, permissionNameList: Array<Permissions>, callback?: Callback<PermissionStateChangeInfo>): void;
+off(type: 'permissionStateChange', tokenIDList: Array<number>, permissionList: Array<Permissions>, callback?: Callback<PermissionStateChangeInfo>): void;
-Unsubscribes from permission grant state changes of the specified applications and permissions. This API uses an asynchronous callback to return the result.
+Unsubscribes from permission grant state changes of the specified applications and permissions. This API uses a callback to return the result.
**System API**: This is a system API.
@@ -491,19 +493,19 @@ Unsubscribes from permission grant state changes of the specified applications a
| Name | Type | Mandatory| Description |
| ------------------ | --------------------- | ---- | ------------------------------------------------------------ |
-| type | string | Yes | Event type. The value is fixed at **'permissionStateChange'**, indicating the permission grant state change event. |
-| tokenIDList | Array<number> | Yes | List of token IDs. If this parameter is left empty, the permission grant state changes of all applications are unsubscribed from. The value must be the same as that passed in **on()**.|
-| permissionNameList | Array<Permissions> | Yes | List of permission names. If this parameter is left empty, the permission grant state changes of all permissions are unsubscribed from. The value must be the same as that passed in **on()**.|
-| callback | Callback<[PermissionStateChangeInfo](#permissionstatechangeinfo9)> | No| Callback used to return the permission grant state change information.|
+| type | string | Yes | Event type to unsubscribe from. The value is **'permissionStateChange'**, which indicates the permission grant state change. |
+| tokenIDList | Array<number> | Yes | Token IDs of the applications. If this parameter is left empty, the permission grant state changes of all applications are unsubscribed from. The value must be the same as that passed in **on()**. |
+| permissionList | Array<Permissions> | Yes | Permission names. If this parameter is left empty, the grant state changes of all permissions are unsubscribed from. The value must be the same as that passed in **on()**. |
+| callback | Callback<[PermissionStateChangeInfo](#permissionstatechangeinfo9)> | No| Callback for the permission grant state change. |
**Error codes**
-For details about the error codes, see [Ability Access Control Error Codes](../errorcodes/errorcode-access-token.md).
+For details about the error codes, see [Application Access Control Error Codes](../errorcodes/errorcode-access-token.md).
| ID| Error Message|
| -------- | -------- |
-| 12100001 | The parameter is invalid. The tokenID in list is all invalid |
-| 12100004 | The interface is not used with |
+| 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()". |
| 12100007 | Service is abnormal. |
| 12100008 | Out of memory. |
@@ -511,13 +513,14 @@ For details about the error codes, see [Ability Access Control Error Codes](../e
```js
import abilityAccessCtrl, {Permissions} from '@ohos.abilityAccessCtrl';
+import bundle from '@ohos.bundle.bundleManager';
let atManager = abilityAccessCtrl.createAtManager();
let appInfo = bundle.getApplicationInfoSync('com.example.myapplication', 0, 100);
let tokenIDList: Array = [appInfo.accessTokenId];
-let permissionNameList: Array = ["ohos.permission.DISTRIBUTED_DATASYNC"];
+let permissionList: Array = ["ohos.permission.DISTRIBUTED_DATASYNC"];
try {
- atManager.off('permissionStateChange', tokenIDList, permissionNameList);
+ atManager.off('permissionStateChange', tokenIDList, permissionList);
} catch(err) {
console.log(`catch err->${JSON.stringify(err)}`);
}
@@ -538,7 +541,7 @@ Verifies whether a permission is granted to an application. This API uses a prom
| Name | Type | Mandatory| Description |
| -------- | ------------------- | ---- | ------------------------------------------ |
| tokenID | number | Yes | Token ID of the application. The value can be obtained from [ApplicationInfo](js-apis-bundleManager-applicationInfo.md). |
-| permissionName | Permissions | Yes | Permission to verify. For details about the permissions, see the [Application Permission List](../../security/permission-list.md).|
+| permissionName | Permissions | Yes | Permission to verify. For details about the permissions, see the [Application Permission List](../../security/permission-list.md). |
**Return value**
@@ -561,9 +564,9 @@ promise.then(data => {
### requestPermissionsFromUser9+
-requestPermissionsFromUser(context: Context, permissions: Array<Permissions>, requestCallback: AsyncCallback<PermissionRequestResult>) : void;
+requestPermissionsFromUser(context: Context, permissionList: Array<Permissions>, requestCallback: AsyncCallback<PermissionRequestResult>) : void;
-Requests user authorization in a dialog box. This API uses an asynchronous callback to return the result.
+Requests permissions from the user in a dialog box. This API uses an asynchronous callback to return the result.
**Model restriction**: This API can be used only in the stage model.
@@ -573,16 +576,17 @@ Requests user authorization in a dialog box. This API uses an asynchronous callb
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| context | Context | Yes| Ability context of the application that requests the permission.|
-| permissions | Array<Permissions> | Yes| Permissions requested. For details about the permissions, see the [Application Permission List](../../security/permission-list.md).|
+| 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).|
| callback | AsyncCallback<[PermissionRequestResult](js-apis-permissionrequestresult.md)> | Yes| Callback invoked to return the result.|
**Error codes**
-For details about the error codes, see [Ability Access Control Error Codes](../errorcodes/errorcode-access-token.md).
+For details about the error codes, see [Application Access Control Error Codes](../errorcodes/errorcode-access-token.md).
+
| ID| Error Message|
| -------- | -------- |
-| 12100001 | Parameter invalid. |
+| 12100001 | The parameter is invalid. The context is invalid when it does not belong to the application itself. |
**Example**
@@ -602,9 +606,9 @@ try {
### requestPermissionsFromUser9+
-requestPermissionsFromUser(context: Context, permissions: Array<Permissions>) : Promise<PermissionRequestResult>;
+requestPermissionsFromUser(context: Context, permissionList: Array<Permissions>) : Promise<PermissionRequestResult>;
-Requests user authorization in a dialog box. This API uses a promise to return the result.
+Requests permissions from the user in a dialog box. This API uses a promise to return the result.
**Model restriction**: This API can be used only in the stage model.
@@ -614,8 +618,8 @@ Requests user authorization in a dialog box. This API uses a promise to return
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| context | Context | Yes| Ability context of the application that requests the permission.|
-| permissions | Array<Permissions> | Yes| Permissions requested. For details about the permissions, see the [Application Permission List](../../security/permission-list.md).|
+| 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). |
**Return value**
@@ -625,10 +629,11 @@ Requests user authorization in a dialog box. This API uses a promise to return
**Error codes**
-For details about the error codes, see [Ability Access Control Error Codes](../errorcodes/errorcode-access-token.md).
+For details about the error codes, see [Application Access Control Error Codes](../errorcodes/errorcode-access-token.md).
+
| ID| Error Message|
| -------- | -------- |
-| 12100001 | Parameter invalid. |
+| 12100001 | The parameter is invalid. The context is invalid when it does not belong to the application itself. |
**Example**
@@ -710,7 +715,7 @@ Enumerates the operations that trigger permission grant state changes.
### PermissionStateChangeInfo9+
-Defines the detailed permission grant state change information.
+Defines detailed information about the permission grant state change.
**System API**: This is a system API.
@@ -719,5 +724,6 @@ Defines the detailed permission grant state change information.
| Name | Type | Readable| Writable| Description |
| -------------- | ------------------------- | ---- | ---- | ------------------ |
| change | [PermissionStateChangeType](#permissionstatechangetype9) | Yes | No | Operation that triggers the permission grant state change. |
-| tokenID | number | Yes | No | Token ID of the application whose permission grant state changes are subscribed.|
-| permissionName | Permissions | Yes | No | Permission whose authorization status changes. For details about the permissions, see the [Application Permission List](../../security/permission-list.md).|
+| tokenID | number | Yes | No | Token ID of the application. |
+| permissionName | Permissions | Yes | No | Permission whose grant state changes. For details about the permissions, see the [Application Permission List](../../security/permission-list.md). |
+
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 62d38c714940a754e566bbdebadac2e3fcbccec2..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
@@ -35,8 +35,8 @@ Enumerates the initial ability launch reasons. You can use it together with [onC
| Name | Value | Description |
| ----------------------------- | ---- | ------------------------------------------------------------ |
| UNKNOWN | 0 | Unknown reason.|
-| START_ABILITY | 1 | The ability is started by calling [startAbility](js-apis-ability-context.md#abilitycontextstartability).|
-| CALL | 2 | The ability is started by calling [startAbilityByCall](js-apis-ability-context.md#abilitycontextstartabilitybycall).|
+| START_ABILITY | 1 | The ability is started by calling [startAbility](js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability).|
+| CALL | 2 | The ability is started by calling [startAbilityByCall](js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartabilitybycall).|
| CONTINUATION | 3 | The ability is started by means of cross-device migration.|
| APP_RECOVERY | 4 | The ability is automatically started when the application is restored from a fault.|
@@ -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,10 +132,10 @@ 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.log('Failed to start ability with error: ${JSON.stringify(error)}');
+ console.error('Failed to start ability with error: ${JSON.stringify(error)}');
});
```
diff --git a/en/application-dev/reference/apis/js-apis-app-ability-abilityDelegatorRegistry.md b/en/application-dev/reference/apis/js-apis-app-ability-abilityDelegatorRegistry.md
index fe6bec9f550bef9bdeb6a3c61c8a1c5adc810f10..76614085293fe0065dafea4a2e3a9d0d8559be0f 100644
--- a/en/application-dev/reference/apis/js-apis-app-ability-abilityDelegatorRegistry.md
+++ b/en/application-dev/reference/apis/js-apis-app-ability-abilityDelegatorRegistry.md
@@ -56,7 +56,7 @@ abilityDelegator.startAbility(want, (err) => {
if (!err || err.code === 0) {
console.log('Success start ability.');
} else {
- console.log('Failed start ability, error: ${JSON.stringify(err)}');
+ console.error('Failed start ability, error: ${JSON.stringify(err)}');
}
});
```
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 df7b07b2d0303bf9310cfdd354d50b1db9239ece..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,9 +275,9 @@ 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.log('error: ${paramError.code}, ${paramError.message}');
+ 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() {
@@ -293,7 +293,7 @@ export default class MySecondAbility extends UIAbility {
// 3. Deregister the listener for the ability lifecycle changes through the applicationContext object.
applicationContext.off('abilityLifecycle', globalThis.lifecycleId, (error) => {
if (error && error.code !== 0) {
- console.log('unregisterAbilityLifecycleCallback fail, error: ${JSON.stringify(error)}');
+ console.error('unregisterAbilityLifecycleCallback fail, error: ${JSON.stringify(error)}');
} else {
console.log('unregisterAbilityLifecycleCallback success.');
}
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..73d21161ce9aa37f7242b49f615759e547c1925a 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.
};
@@ -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.
};
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 5a07867e6f5c28213e5cc48b07ef6a0958eb9426..d03dcb8185338c328e279df4b03849c434f1da6d 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
@@ -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
);
}
}
@@ -105,7 +105,7 @@ let observer = {
try {
errorManager.on('error', observer);
} catch (paramError) {
- console.log('error: ${paramError.code}, ${paramError.message}');
+ console.error('error: ${paramError.code}, ${paramError.message}');
}
```
@@ -139,6 +139,6 @@ let observer = {
try {
errorManager.on('error', observer);
} catch (paramError) {
- console.log('error: ${paramError.code}, ${paramError.message}');
+ console.error('error: ${paramError.code}, ${paramError.message}');
}
```
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..3304f535b5fd5fe52562e237a9f48c60cd794067 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**
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 54200ed3e7e27043eb2798522a3fd1c991eca5a3..b57435673e0d2372d4980c5a540fea618719c839 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.log('getMissionInfos failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
+ console.error('getMissionInfos failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
return;
}
console.log('size = ${missions.length}');
@@ -49,6 +49,6 @@ import StartOptions from '@ohos.app.ability.StartOptions';
});
});
} catch (paramError) {
- console.log('error: ${paramError.code}, ${paramError.message}');
+ console.error('error: ${paramError.code}, ${paramError.message}');
}
```
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..b85364df96d39f3b8bd66f64910f3e15e5867ca7 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,7 +369,7 @@ 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');
@@ -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,7 +453,7 @@ 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)}');
@@ -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**
@@ -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**
@@ -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**
@@ -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 {
@@ -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-want.md b/en/application-dev/reference/apis/js-apis-app-ability-want.md
index 0411725e055551e68d2902705f3e904592587a1d..a052c4dbec6fdb7c790c7195baf763f96dd90dad 100644
--- a/en/application-dev/reference/apis/js-apis-app-ability-want.md
+++ b/en/application-dev/reference/apis/js-apis-app-ability-want.md
@@ -136,7 +136,7 @@ import Want from '@ohos.app.ability.Want';
try {
fd = fileio.openSync('/data/storage/el2/base/haps/pic.png');
} catch(e) {
- console.log('openSync fail: ${JSON.stringify(e)}');
+ console.error('openSync fail: ${JSON.stringify(e)}');
}
let want = {
'deviceId': '', // An empty deviceId indicates the local device.
diff --git a/en/application-dev/reference/apis/js-apis-app-form-formBindingData.md b/en/application-dev/reference/apis/js-apis-app-form-formBindingData.md
index fa8e44aa0b0e5a06d88891214baab112d0ce47b6..dbef711c25369d3eac61ca1b6516a7c43d8ecbc2 100644
--- a/en/application-dev/reference/apis/js-apis-app-form-formBindingData.md
+++ b/en/application-dev/reference/apis/js-apis-app-form-formBindingData.md
@@ -59,6 +59,6 @@ try {
};
formBindingData.createFormBindingData(obj);
} catch (error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.error(`catch error, code: ${error.code}, message: ${error.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-formHost.md b/en/application-dev/reference/apis/js-apis-app-form-formHost.md
index e54e2cc798f8774fcc487d94c2ad9b514c42f897..bba49ff8ca2d8c96fd89e07b59c488d5cea12054 100644
--- a/en/application-dev/reference/apis/js-apis-app-form-formHost.md
+++ b/en/application-dev/reference/apis/js-apis-app-form-formHost.md
@@ -46,13 +46,13 @@ try {
let formId = '12400633174999288';
formHost.deleteForm(formId, (error) => {
if (error) {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.error(`error, code: ${error.code}, message: ${error.message}`);
} else {
console.log('formHost deleteForm success');
}
});
} catch (error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
@@ -96,10 +96,10 @@ try {
formHost.deleteForm(formId).then(() => {
console.log('formHost deleteForm success');
}).catch((error) => {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
@@ -136,11 +136,11 @@ try {
let formId = '12400633174999288';
formHost.releaseForm(formId, (error) => {
if (error) {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.error(`error, code: ${error.code}, message: ${error.message}`);
}
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
@@ -178,11 +178,11 @@ try {
let formId = '12400633174999288';
formHost.releaseForm(formId, true, (error) => {
if (error) {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.error(`error, code: ${error.code}, message: ${error.message}`);
}
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
@@ -226,10 +226,10 @@ try {
formHost.releaseForm(formId, true).then(() => {
console.log('formHost releaseForm success');
}).catch((error) => {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
@@ -266,11 +266,11 @@ try {
let formId = '12400633174999288';
formHost.requestForm(formId, (error) => {
if (error) {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.error(`error, code: ${error.code}, message: ${error.message}`);
}
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
@@ -313,10 +313,10 @@ try {
formHost.requestForm(formId).then(() => {
console.log('formHost requestForm success');
}).catch((error) => {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
@@ -354,11 +354,11 @@ try {
let formId = '12400633174999288';
formHost.castToNormalForm(formId, (error) => {
if (error) {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.error(`error, code: ${error.code}, message: ${error.message}`);
}
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
@@ -401,10 +401,10 @@ try {
formHost.castToNormalForm(formId).then(() => {
console.log('formHost castTempForm success');
}).catch((error) => {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
@@ -441,11 +441,11 @@ try {
let formId = ['12400633174999288'];
formHost.notifyVisibleForms(formId, (error) => {
if (error) {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.error(`error, code: ${error.code}, message: ${error.message}`);
}
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
@@ -488,10 +488,10 @@ try {
formHost.notifyVisibleForms(formId).then(() => {
console.log('formHost notifyVisibleForms success');
}).catch((error) => {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
@@ -528,11 +528,11 @@ try {
let formId = ['12400633174999288'];
formHost.notifyInvisibleForms(formId, (error) => {
if (error) {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.error(`error, code: ${error.code}, message: ${error.message}`);
}
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
@@ -575,10 +575,10 @@ try {
formHost.notifyInvisibleForms(formId).then(() => {
console.log('formHost notifyInvisibleForms success');
}).catch((error) => {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
@@ -615,11 +615,11 @@ try {
let formId = ['12400633174999288'];
formHost.enableFormsUpdate(formId, (error) => {
if (error) {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.error(`error, code: ${error.code}, message: ${error.message}`);
}
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
@@ -662,10 +662,10 @@ try {
formHost.enableFormsUpdate(formId).then(() => {
console.log('formHost enableFormsUpdate success');
}).catch((error) => {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
@@ -702,11 +702,11 @@ try {
let formId = ['12400633174999288'];
formHost.disableFormsUpdate(formId, (error) => {
if (error) {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.error(`error, code: ${error.code}, message: ${error.message}`);
}
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
@@ -749,10 +749,10 @@ try {
formHost.disableFormsUpdate(formId).then(() => {
console.log('formHost disableFormsUpdate success');
}).catch((error) => {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
@@ -778,11 +778,11 @@ import formHost from '@ohos.app.form.formHost';
try {
formHost.isSystemReady((error, data) => {
if (error) {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.error(`error, code: ${error.code}, message: ${error.message}`);
}
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
@@ -809,10 +809,10 @@ try {
formHost.isSystemReady().then(() => {
console.log('formHost isSystemReady success');
}).catch((error) => {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
@@ -840,13 +840,13 @@ import formHost from '@ohos.app.form.formHost';
try {
formHost.getAllFormsInfo((error, data) => {
if (error) {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.error(`error, code: ${error.code}, message: ${error.message}`);
} else {
console.log('formHost getAllFormsInfo, data: ${JSON.stringify(data)}');
}
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
@@ -875,10 +875,10 @@ try {
formHost.getAllFormsInfo().then((data) => {
console.log('formHost getAllFormsInfo data: ${JSON.stringify(data)}');
}).catch((error) => {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
@@ -914,13 +914,13 @@ import formHost from '@ohos.app.form.formHost';
try {
formHost.getFormsInfo('com.example.ohos.formjsdemo', (error, data) => {
if (error) {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.error(`error, code: ${error.code}, message: ${error.message}`);
} else {
console.log('formHost getFormsInfo, data: ${JSON.stringify(data)}');
}
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
@@ -957,13 +957,13 @@ import formHost from '@ohos.app.form.formHost';
try {
formHost.getFormsInfo('com.example.ohos.formjsdemo', 'entry', (error, data) => {
if (error) {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.error(`error, code: ${error.code}, message: ${error.message}`);
} else {
console.log('formHost getFormsInfo, data: ${JSON.stringify(data)}');
}
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
@@ -1006,10 +1006,10 @@ try {
formHost.getFormsInfo('com.example.ohos.formjsdemo', 'entry').then((data) => {
console.log('formHost getFormsInfo, data: ${JSON.stringify(data)}');
}).catch((error) => {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
@@ -1039,13 +1039,13 @@ try {
let formIds = new Array('12400633174999288', '12400633174999289');
formHost.deleteInvalidForms(formIds, (error, data) => {
if (error) {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.error(`error, code: ${error.code}, message: ${error.message}`);
} else {
console.log('formHost deleteInvalidForms, data: ${JSON.stringify(data)}');
}
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
@@ -1081,10 +1081,10 @@ try {
formHost.deleteInvalidForms(formIds).then((data) => {
console.log('formHost deleteInvalidForms, data: ${JSON.stringify(data)}');
}).catch((error) => {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
@@ -1130,13 +1130,13 @@ let want = {
try {
formHost.acquireFormState(want, (error, data) => {
if (error) {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.error(`error, code: ${error.code}, message: ${error.message}`);
} else {
console.log('formHost acquireFormState, data: ${JSON.stringify(data)}');
}
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
@@ -1188,10 +1188,10 @@ try {
formHost.acquireFormState(want).then((data) => {
console.log('formHost acquireFormState, data: ${JSON.stringify(data)}');
}).catch((error) => {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
@@ -1281,11 +1281,11 @@ let formIds = new Array('12400633174999288', '12400633174999289');
try {
formHost.notifyFormsVisible(formIds, true, (error) => {
if (error) {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.error(`error, code: ${error.code}, message: ${error.message}`);
}
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
@@ -1329,10 +1329,10 @@ try {
formHost.notifyFormsVisible(formIds, true).then(() => {
console.log('formHost notifyFormsVisible success');
}).catch((error) => {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
@@ -1370,11 +1370,11 @@ let formIds = new Array('12400633174999288', '12400633174999289');
try {
formHost.notifyFormsEnableUpdate(formIds, true, (error) => {
if (error) {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.error(`error, code: ${error.code}, message: ${error.message}`);
}
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
@@ -1418,10 +1418,10 @@ try {
formHost.notifyFormsEnableUpdate(formIds, true).then(() => {
console.log('formHost notifyFormsEnableUpdate success');
}).catch((error) => {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
## shareForm
@@ -1459,11 +1459,11 @@ let deviceId = 'EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2
try {
formHost.shareForm(formId, deviceId, (error) => {
if (error) {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.error(`error, code: ${error.code}, message: ${error.message}`);
}
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
@@ -1508,10 +1508,10 @@ try {
formHost.shareForm(formId, deviceId).then(() => {
console.log('formHost shareForm success');
}).catch((error) => {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
@@ -1549,11 +1549,11 @@ let formIds = new Array('12400633174999288', '12400633174999289');
try {
formHost.notifyFormsPrivacyProtected(formIds, true, (error) => {
if (error) {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.error(`error, code: ${error.code}, message: ${error.message}`);
}
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
@@ -1595,9 +1595,9 @@ try {
formHost.notifyFormsPrivacyProtected(formIds, true).then(() => {
console.log('formHost notifyFormsPrivacyProtected success');
}).catch((error) => {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
diff --git a/en/application-dev/reference/apis/js-apis-app-form-formProvider.md b/en/application-dev/reference/apis/js-apis-app-form-formProvider.md
index 5815289bcf5258156932e938843bdb3d0ff4c441..908c5a428a1a5f6cccd3f5ae2bc04e01ffa29716 100644
--- a/en/application-dev/reference/apis/js-apis-app-form-formProvider.md
+++ b/en/application-dev/reference/apis/js-apis-app-form-formProvider.md
@@ -43,13 +43,13 @@ let formId = '12400633174999288';
try {
formProvider.setFormNextRefreshTime(formId, 5, (error, data) => {
if (error) {
- console.log(`callback error, code: ${error.code}, message: ${error.message})`);
+ console.error(`callback error, code: ${error.code}, message: ${error.message})`);
} else {
console.log(`formProvider setFormNextRefreshTime success`);
}
});
} catch (error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message})`);
+ console.error(`catch error, code: ${error.code}, message: ${error.message})`);
}
```
@@ -91,10 +91,10 @@ try {
formProvider.setFormNextRefreshTime(formId, 5).then(() => {
console.log(`formProvider setFormNextRefreshTime success`);
}).catch((error) => {
- console.log(`promise error, code: ${error.code}, message: ${error.message})`);
+ console.error(`promise error, code: ${error.code}, message: ${error.message})`);
});
} catch (error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message})`);
+ console.error(`catch error, code: ${error.code}, message: ${error.message})`);
}
```
@@ -132,13 +132,13 @@ try {
let obj = formBindingData.createFormBindingData({temperature:'22c', time:'22:00'});
formProvider.updateForm(formId, obj, (error, data) => {
if (error) {
- console.log(`callback error, code: ${error.code}, message: ${error.message})`);
+ console.error(`callback error, code: ${error.code}, message: ${error.message})`);
} else {
console.log(`formProvider updateForm success`);
}
});
} catch (error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message})`);
+ console.error(`catch error, code: ${error.code}, message: ${error.message})`);
}
```
@@ -182,10 +182,10 @@ try {
formProvider.updateForm(formId, obj).then(() => {
console.log(`formProvider updateForm success`);
}).catch((error) => {
- console.log(`promise error, code: ${error.code}, message: ${error.message})`);
+ console.error(`promise error, code: ${error.code}, message: ${error.message})`);
});
} catch (error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message})`);
+ console.error(`catch error, code: ${error.code}, message: ${error.message})`);
}
```
@@ -219,13 +219,13 @@ import formProvider from '@ohos.app.form.formProvider';
try {
formProvider.getFormsInfo((error, data) => {
if (error) {
- console.log(`callback error, code: ${error.code}, message: ${error.message})`);
+ console.error(`callback error, code: ${error.code}, message: ${error.message})`);
} else {
console.log('formProvider getFormsInfo, data: ${JSON.stringify(data)}');
}
});
} catch (error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message})`);
+ console.error(`catch error, code: ${error.code}, message: ${error.message})`);
}
```
## getFormsInfo
@@ -263,13 +263,13 @@ const filter: formInfo.FormInfoFilter = {
try {
formProvider.getFormsInfo(filter, (error, data) => {
if (error) {
- console.log(`callback error, code: ${error.code}, message: ${error.message})`);
+ console.error(`callback error, code: ${error.code}, message: ${error.message})`);
} else {
console.log('formProvider getFormsInfo, data: ${JSON.stringify(data)}');
}
});
} catch (error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message})`);
+ console.error(`catch error, code: ${error.code}, message: ${error.message})`);
}
```
@@ -314,10 +314,10 @@ try {
formProvider.getFormsInfo(filter).then((data) => {
console.log('formProvider getFormsInfo, data: ${JSON.stringify(data)}');
}).catch((error) => {
- console.log(`promise error, code: ${error.code}, message: ${error.message})`);
+ console.error(`promise error, code: ${error.code}, message: ${error.message})`);
});
} catch (error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message})`);
+ console.error(`catch error, code: ${error.code}, message: ${error.message})`);
}
```
@@ -364,13 +364,13 @@ try {
let obj = formBindingData.createFormBindingData({ temperature: '22c', time: '22:00' });
formProvider.requestPublishForm(want, obj, (error, data) => {
if (error) {
- console.log(`callback error, code: ${error.code}, message: ${error.message})`);
+ console.error(`callback error, code: ${error.code}, message: ${error.message})`);
} else {
console.log('formProvider requestPublishForm, form ID is: ${JSON.stringify(data)}');
}
});
} catch (error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message})`);
+ console.error(`catch error, code: ${error.code}, message: ${error.message})`);
}
```
@@ -414,13 +414,13 @@ let want = {
try {
formProvider.requestPublishForm(want, (error, data) => {
if (error) {
- console.log(`callback error, code: ${error.code}, message: ${error.message})`);
+ console.error(`callback error, code: ${error.code}, message: ${error.message})`);
} else {
console.log('formProvider requestPublishForm, form ID is: ${JSON.stringify(data)}');
}
});
} catch (error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message})`);
+ console.error(`catch error, code: ${error.code}, message: ${error.message})`);
}
```
@@ -471,10 +471,10 @@ try {
formProvider.requestPublishForm(want).then((data) => {
console.log('formProvider requestPublishForm success, form ID is : ${JSON.stringify(data)}');
}).catch((error) => {
- console.log(`promise error, code: ${error.code}, message: ${error.message})`);
+ console.error(`promise error, code: ${error.code}, message: ${error.message})`);
});
} catch (error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message})`);
+ console.error(`catch error, code: ${error.code}, message: ${error.message})`);
}
```
@@ -502,7 +502,7 @@ import formProvider from '@ohos.app.form.formProvider';
try {
formProvider.isRequestPublishFormSupported((error, isSupported) => {
if (error) {
- console.log(`callback error, code: ${error.code}, message: ${error.message})`);
+ console.error(`callback error, code: ${error.code}, message: ${error.message})`);
} else {
if (isSupported) {
var want = {
@@ -516,19 +516,19 @@ try {
try {
formProvider.requestPublishForm(want, (error, data) => {
if (error) {
- console.log(`callback error, code: ${error.code}, message: ${error.message})`);
+ console.error(`callback error, code: ${error.code}, message: ${error.message})`);
} else {
console.log('formProvider requestPublishForm, form ID is: ${JSON.stringify(data)}');
}
});
} catch (error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message})`);
+ console.error(`catch error, code: ${error.code}, message: ${error.message})`);
}
}
}
});
} catch (error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message})`);
+ console.error(`catch error, code: ${error.code}, message: ${error.message})`);
}
```
@@ -568,16 +568,16 @@ try {
formProvider.requestPublishForm(want).then((data) => {
console.log('formProvider requestPublishForm success, form ID is : ${JSON.stringify(data)}');
}).catch((error) => {
- console.log(`promise error, code: ${error.code}, message: ${error.message})`);
+ console.error(`promise error, code: ${error.code}, message: ${error.message})`);
});
} catch (error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message})`);
+ console.error(`catch error, code: ${error.code}, message: ${error.message})`);
}
}
}).catch((error) => {
- console.log(`promise error, code: ${error.code}, message: ${error.message})`);
+ console.error(`promise error, code: ${error.code}, message: ${error.message})`);
});
} catch (error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message})`);
+ console.error(`catch error, code: ${error.code}, message: ${error.message})`);
}
```
diff --git a/en/application-dev/reference/apis/js-apis-application-abilityManager.md b/en/application-dev/reference/apis/js-apis-application-abilityManager.md
index 5edd8883d8f9d294f6f1408821efa95289108123..23bd66e43063c5e2ea38b65d38da68272b041adb 100644
--- a/en/application-dev/reference/apis/js-apis-application-abilityManager.md
+++ b/en/application-dev/reference/apis/js-apis-application-abilityManager.md
@@ -90,7 +90,7 @@ let config = {
abilityManager.updateConfiguration(config).then(() => {
console.log('updateConfiguration success');
}).catch((err) => {
- console.log('updateConfiguration fail');
+ console.error('updateConfiguration fail');
});
```
@@ -140,6 +140,6 @@ Obtains the ability running information. This API uses a promise to return the r
abilityManager.getAbilityRunningInfos().then((data) => {
console.log('getAbilityRunningInfos data: ${JSON.stringify(data)}');
}).catch((err) => {
- console.log('getAbilityRunningInfos err: ${JSON.stringify(err)}');
+ console.error('getAbilityRunningInfos err: ${JSON.stringify(err)}');
});
```
diff --git a/en/application-dev/reference/apis/js-apis-application-accessibilityExtensionAbility.md b/en/application-dev/reference/apis/js-apis-application-accessibilityExtensionAbility.md
index e9327b99666d40cb367e54ec351048af3d384cd3..7f03efce9a0fcec4585e4c3f7ebbb3d67a4fbe64 100644
--- a/en/application-dev/reference/apis/js-apis-application-accessibilityExtensionAbility.md
+++ b/en/application-dev/reference/apis/js-apis-application-accessibilityExtensionAbility.md
@@ -42,22 +42,22 @@ Enumerates gesture types.
| Name | Description |
| ------------- | ------------ |
-| left | Left gesture. |
-| leftThenRight | Left-then-right gesture.|
-| leftThenUp | Left-then-up gesture.|
-| leftThenDown | Left-then-down gesture.|
-| right | Right gesture. |
-| rightThenLeft | Right-then-left gesture.|
-| rightThenUp | Right-then-up gesture.|
-| rightThenDown | Right-then-down gesture.|
-| up | Up gesture. |
-| upThenLeft | Up-then-left gesture.|
-| upThenRight | Up-then-right gesture.|
-| upThenDown | Up-then-down gesture.|
-| down | Down gesture. |
-| downThenLeft | Down-then-left gesture.|
-| downThenRight | Down-then-right gesture.|
-| downThenUp | Down-then-up gesture.|
+| left | Left gesture. String type. |
+| leftThenRight | Left-then-right gesture. String type. |
+| leftThenUp | Left-then-up gesture. String type. |
+| leftThenDown | Left-then-down gesture. String type. |
+| right | Right gesture. String type. |
+| rightThenLeft | Right-then-left gesture. String type. |
+| rightThenUp | Right-then-up gesture. String type. |
+| rightThenDown | Right-then-down gesture. String type. |
+| up | Up gesture. String type. |
+| upThenLeft | Up-then-left gesture. String type. |
+| upThenRight | Up-then-right gesture. String type. |
+| upThenDown | Up-then-down gesture. String type. |
+| down | Down gesture. String type. |
+| downThenLeft | Down-then-left gesture. String type. |
+| downThenRight | Down-then-right gesture. String type. |
+| downThenUp | Down-then-up gesture. String type. |
## PageUpdateType
@@ -67,8 +67,8 @@ Enumerates the page update types.
| Name | Description |
| ----------------- | --------- |
-| pageContentUpdate | Update of the page content.|
-| pageStateUpdate | Update of the page status.|
+| pageContentUpdate | Update of the page content. String type. |
+| pageStateUpdate | Update of the page status. String type. |
## TouchGuideType
@@ -78,8 +78,8 @@ Enumerates the touch guide event types.
| Name | Description |
| ---------- | ------------ |
-| touchBegin | Start of touch in touch guide mode.|
-| touchEnd | End of touch in touch guide mode.|
+| touchBegin | Start of touch in touch guide mode. String type. |
+| touchEnd | End of touch in touch guide mode. String type. |
## AccessibilityExtensionAbility.onConnect
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-formBindingData.md b/en/application-dev/reference/apis/js-apis-application-formBindingData.md
index c7c5e55ff067afe25c43e57b0ce2491090324101..539d728f614c4c56655eb390e427febf63c16841 100644
--- a/en/application-dev/reference/apis/js-apis-application-formBindingData.md
+++ b/en/application-dev/reference/apis/js-apis-application-formBindingData.md
@@ -59,6 +59,6 @@ try {
};
formBindingData.createFormBindingData(obj);
} catch (error) {
- console.log('catch error, error: ${JSON.stringify(error)}');
+ console.error('catch error, error: ${JSON.stringify(error)}');
}
```
diff --git a/en/application-dev/reference/apis/js-apis-application-formProvider.md b/en/application-dev/reference/apis/js-apis-application-formProvider.md
index 81b1711b18d198350e0ee6f759a7587b805cc66c..80f45e11e8d85b07f240b0f036aa4c86b2329b8a 100644
--- a/en/application-dev/reference/apis/js-apis-application-formProvider.md
+++ b/en/application-dev/reference/apis/js-apis-application-formProvider.md
@@ -36,7 +36,7 @@ Sets the next refresh time for a widget. This API uses an asynchronous callback
let formId = '12400633174999288';
formProvider.setFormNextRefreshTime(formId, 5, (error, data) => {
if (error.code) {
- console.log('formProvider setFormNextRefreshTime, error: ${JSON.stringify(error)}');
+ console.error('formProvider setFormNextRefreshTime, error: ${JSON.stringify(error)}');
}
});
```
@@ -71,7 +71,7 @@ Sets the next refresh time for a widget. This API uses a promise to return the r
formProvider.setFormNextRefreshTime(formId, 5).then(() => {
console.log('formProvider setFormNextRefreshTime success');
}).catch((error) => {
- console.log('formProvider setFormNextRefreshTime, error: ${JSON.stringify(error)}');
+ console.error('formProvider setFormNextRefreshTime, error: ${JSON.stringify(error)}');
});
```
@@ -101,7 +101,7 @@ Updates a widget. This API uses an asynchronous callback to return the result.
let obj = formBindingData.createFormBindingData({temperature:'22c', time:'22:00'});
formProvider.updateForm(formId, obj, (error, data) => {
if (error.code) {
- console.log('formProvider updateForm, error: ${JSON.stringify(error)}');
+ console.error('formProvider updateForm, error: ${JSON.stringify(error)}');
}
});
```
@@ -138,6 +138,6 @@ Updates a widget. This API uses a promise to return the result.
formProvider.updateForm(formId, obj).then(() => {
console.log('formProvider updateForm success');
}).catch((error) => {
- console.log('formProvider updateForm, error: ${JSON.stringify(error)}');
+ console.error('formProvider updateForm, error: ${JSON.stringify(error)}');
});
```
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..97ea9181621dbc9b95d355762cb839af903771cc 100644
--- a/en/application-dev/reference/apis/js-apis-application-missionManager.md
+++ b/en/application-dev/reference/apis/js-apis-application-missionManager.md
@@ -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;
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 d5fd64638541acdb567b3d2a04d4bf5933c822f1..7844ed3008796cf449c32d09c246af86b65338d8 100644
--- a/en/application-dev/reference/apis/js-apis-application-want.md
+++ b/en/application-dev/reference/apis/js-apis-application-want.md
@@ -25,9 +25,8 @@ import Want from '@ohos.application.Want';
| type | string | No | MIME type, that is, the type of the file to open, for example, **'text/xml'** and **'image/*'**. For details about the MIME type definition, see https://www.iana.org/assignments/media-types/media-types.xhtml?utm_source=ld246.com. |
| flags | number | No | How the **Want** object will be handled. By default, numbers are passed in. For details, see [flags](js-apis-ability-wantConstant.md#wantConstant.Flags).|
| 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. |
+| 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**
@@ -42,7 +41,7 @@ import Want from '@ohos.application.Want';
};
this.context.startAbility(want, (error) => {
// Start an ability explicitly. The bundleName, abilityName, and moduleName parameters work together to uniquely identify an ability.
- console.log('error.code = ${error.code}');
+ console.error('error.code = ${error.code}');
});
```
@@ -114,7 +113,7 @@ import Want from '@ohos.application.Want';
try {
fd = fileio.openSync('/data/storage/el2/base/haps/pic.png');
} catch(e) {
- console.log('openSync fail: ${JSON.stringify(e)}');
+ console.error('openSync fail: ${JSON.stringify(e)}');
}
let want = {
'deviceId': '', // An empty deviceId indicates the local device.
@@ -127,7 +126,7 @@ import Want from '@ohos.application.Want';
};
this.context.startAbility(want, (error) => {
// Start an ability explicitly. The bundleName, abilityName, and moduleName parameters work together to uniquely identify an ability.
- console.log('error.code = ${error.code}');
+ console.error('error.code = ${error.code}');
});
```
diff --git a/en/application-dev/reference/apis/js-apis-audio.md b/en/application-dev/reference/apis/js-apis-audio.md
index 4abed77e24d5c6cf16d7fd84ce36cf806d06ce4e..b3f5def410251e954ee3f7b00c211e2f7f5116a0 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**
@@ -1763,7 +1763,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 +1795,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 +1829,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 +1860,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**
@@ -3956,6 +3956,7 @@ Describes the audio renderer change event.
**Example**
```js
+
import audio from '@ohos.multimedia.audio';
const audioManager = audio.getAudioManager();
@@ -4240,7 +4241,6 @@ audioRenderer.getStreamInfo().then((streamInfo) => {
}).catch((err) => {
console.error(`ERROR: ${err}`);
});
-
```
### getAudioStreamId9+
@@ -4263,7 +4263,6 @@ Obtains the stream ID of this **AudioRenderer** instance. This API uses an async
audioRenderer.getAudioStreamId((err, streamid) => {
console.info(`Renderer GetStreamId: ${streamid}`);
});
-
```
### getAudioStreamId9+
@@ -4288,7 +4287,6 @@ audioRenderer.getAudioStreamId().then((streamid) => {
}).catch((err) => {
console.error(`ERROR: ${err}`);
});
-
```
### start8+
@@ -4315,7 +4313,6 @@ audioRenderer.start((err) => {
console.info('Renderer start success.');
}
});
-
```
### start8+
@@ -4340,7 +4337,6 @@ audioRenderer.start().then(() => {
}).catch((err) => {
console.error(`ERROR: ${err}`);
});
-
```
### pause8+
@@ -4367,7 +4363,6 @@ audioRenderer.pause((err) => {
console.info('Renderer paused.');
}
});
-
```
### pause8+
@@ -4392,7 +4387,6 @@ audioRenderer.pause().then(() => {
}).catch((err) => {
console.error(`ERROR: ${err}`);
});
-
```
### drain8+
@@ -4419,7 +4413,6 @@ audioRenderer.drain((err) => {
console.info('Renderer drained.');
}
});
-
```
### drain8+
@@ -4444,7 +4437,6 @@ audioRenderer.drain().then(() => {
}).catch((err) => {
console.error(`ERROR: ${err}`);
});
-
```
### stop8+
@@ -4471,7 +4463,6 @@ audioRenderer.stop((err) => {
console.info('Renderer stopped.');
}
});
-
```
### stop8+
@@ -4496,7 +4487,6 @@ audioRenderer.stop().then(() => {
}).catch((err) => {
console.error(`ERROR: ${err}`);
});
-
```
### release8+
@@ -4523,7 +4513,6 @@ audioRenderer.release((err) => {
console.info('Renderer released.');
}
});
-
```
### release8+
@@ -4548,7 +4537,6 @@ audioRenderer.release().then(() => {
}).catch((err) => {
console.error(`ERROR: ${err}`);
});
-
```
### write8+
@@ -4586,15 +4574,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{
@@ -4604,7 +4592,6 @@ for (let i = 0;i < len; i++) {
})
}
-
```
### write8+
@@ -4641,20 +4628,19 @@ 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}`);
}
}
-
```
### getAudioTime8+
@@ -4677,7 +4663,6 @@ Obtains the number of nanoseconds elapsed from the Unix epoch (January 1, 1970).
audioRenderer.getAudioTime((err, timestamp) => {
console.info(`Current timestamp: ${timestamp}`);
});
-
```
### getAudioTime8+
@@ -4702,7 +4687,6 @@ audioRenderer.getAudioTime().then((timestamp) => {
}).catch((err) => {
console.error(`ERROR: ${err}`);
});
-
```
### getBufferSize8+
@@ -4727,7 +4711,6 @@ let bufferSize = audioRenderer.getBufferSize(async(err, bufferSize) => {
console.error('getBufferSize error');
}
});
-
```
### getBufferSize8+
@@ -4754,7 +4737,6 @@ audioRenderer.getBufferSize().then((data) => {
}).catch((err) => {
console.error(`AudioFrameworkRenderLog: getBufferSize: ERROR: ${err}`);
});
-
```
### setRenderRate8+
@@ -4782,7 +4764,6 @@ audioRenderer.setRenderRate(audio.AudioRendererRate.RENDER_RATE_NORMAL, (err) =>
console.info('Callback invoked to indicate a successful render rate setting.');
}
});
-
```
### setRenderRate8+
@@ -4813,7 +4794,6 @@ audioRenderer.setRenderRate(audio.AudioRendererRate.RENDER_RATE_NORMAL).then(()
}).catch((err) => {
console.error(`ERROR: ${err}`);
});
-
```
### getRenderRate8+
@@ -4836,7 +4816,6 @@ Obtains the current render rate. This API uses an asynchronous callback to retur
audioRenderer.getRenderRate((err, renderrate) => {
console.info(`getRenderRate: ${renderrate}`);
});
-
```
### getRenderRate8+
@@ -4861,9 +4840,7 @@ audioRenderer.getRenderRate().then((renderRate) => {
}).catch((err) => {
console.error(`ERROR: ${err}`);
});
-
```
-
### setInterruptMode9+
setInterruptMode(mode: InterruptMode): Promise<void>
@@ -4893,9 +4870,7 @@ audioRenderer.setInterruptMode(mode).then(data=>{
}).catch((err) => {
console.error(`setInterruptMode Fail: ${err}`);
});
-
```
-
### setInterruptMode9+
setInterruptMode(mode: InterruptMode, callback: AsyncCallback\): void
@@ -4921,7 +4896,6 @@ audioRenderer.setInterruptMode(mode, (err, data)=>{
}
console.info('setInterruptMode Success!');
});
-
```
### setVolume9+
@@ -4952,9 +4926,7 @@ audioRenderer.setVolume(0.5).then(data=>{
}).catch((err) => {
console.error(`setVolume Fail: ${err}`);
});
-
```
-
### setVolume9+
setVolume(volume: number, callback: AsyncCallback\): void
@@ -4979,7 +4951,6 @@ audioRenderer.setVolume(0.5, (err, data)=>{
}
console.info('setVolume Success!');
});
-
```
### on('audioInterrupt')9+
@@ -5005,7 +4976,7 @@ For details about the error codes, see [Audio Error Codes](../errorcodes/errorco
| ID | Error Message |
| ------- | ------------------------------ |
-| 6800101 | if input parameter value error |
+| 6800101 | if input parameter value error |
**Example**
@@ -5059,7 +5030,6 @@ async function onAudioInterrupt(){
}
});
}
-
```
### on('markReach')8+
@@ -5086,7 +5056,6 @@ audioRenderer.on('markReach', 1000, (position) => {
console.info('ON Triggered successfully');
}
});
-
```
@@ -5108,7 +5077,6 @@ Unsubscribes from mark reached events.
```js
audioRenderer.off('markReach');
-
```
### on('periodReach') 8+
@@ -5135,7 +5103,6 @@ audioRenderer.on('periodReach', 1000, (position) => {
console.info('ON Triggered successfully');
}
});
-
```
### off('periodReach') 8+
@@ -5156,10 +5123,9 @@ Unsubscribes from period reached events.
```js
audioRenderer.off('periodReach')
-
```
-### on('stateChange')8+
+### on('stateChange') 8+
on(type: 'stateChange', callback: Callback): void
@@ -5185,7 +5151,6 @@ audioRenderer.on('stateChange', (state) => {
console.info('audio renderer state is: STATE_RUNNING');
}
});
-
```
## AudioCapturer8+
@@ -5204,7 +5169,6 @@ Provides APIs for audio capture. Before calling any API in **AudioCapturer**, yo
```js
let state = audioCapturer.state;
-
```
### getCapturerInfo8+
@@ -5233,7 +5197,6 @@ audioCapturer.getCapturerInfo((err, capturerInfo) => {
console.info(`Capturer flags: ${capturerInfo.capturerFlags}`);
}
});
-
```
@@ -5266,7 +5229,6 @@ audioCapturer.getCapturerInfo().then((audioParamsGet) => {
}).catch((err) => {
console.error(`AudioFrameworkRecLog: CapturerInfo :ERROR: ${err}`);
});
-
```
### getStreamInfo8+
@@ -5297,7 +5259,6 @@ audioCapturer.getStreamInfo((err, streamInfo) => {
console.info(`Capturer encoding type: ${streamInfo.encodingType}`);
}
});
-
```
### getStreamInfo8+
@@ -5326,7 +5287,6 @@ audioCapturer.getStreamInfo().then((audioParamsGet) => {
}).catch((err) => {
console.error(`getStreamInfo :ERROR: ${err}`);
});
-
```
### getAudioStreamId9+
@@ -5349,7 +5309,6 @@ Obtains the stream ID of this **AudioCapturer** instance. This API uses an async
audioCapturer.getAudioStreamId((err, streamid) => {
console.info(`audioCapturer GetStreamId: ${streamid}`);
});
-
```
### getAudioStreamId9+
@@ -5374,7 +5333,6 @@ audioCapturer.getAudioStreamId().then((streamid) => {
}).catch((err) => {
console.error(`ERROR: ${err}`);
});
-
```
### start8+
@@ -5401,7 +5359,6 @@ audioCapturer.start((err) => {
console.info('Capturer start success.');
}
});
-
```
@@ -5433,7 +5390,6 @@ audioCapturer.start().then(() => {
}).catch((err) => {
console.info(`AudioFrameworkRecLog: Capturer start :ERROR : ${err}`);
});
-
```
### stop8+
@@ -5460,7 +5416,6 @@ audioCapturer.stop((err) => {
console.info('Capturer stopped.');
}
});
-
```
@@ -5490,7 +5445,6 @@ audioCapturer.stop().then(() => {
}).catch((err) => {
console.info(`AudioFrameworkRecLog: Capturer stop: ERROR: ${err}`);
});
-
```
### release8+
@@ -5517,7 +5471,6 @@ audioCapturer.release((err) => {
console.info('capturer released.');
}
});
-
```
@@ -5547,7 +5500,6 @@ audioCapturer.release().then(() => {
}).catch((err) => {
console.info(`AudioFrameworkRecLog: Capturer stop: ERROR: ${err}`);
});
-
```
### read8+
@@ -5581,7 +5533,6 @@ audioCapturer.read(bufferSize, true, async(err, buffer) => {
console.info('Success in reading the buffer data');
}
});
-
```
### read8+
@@ -5621,7 +5572,6 @@ audioCapturer.read(bufferSize, true).then((buffer) => {
}).catch((err) => {
console.info(`ERROR : ${err}`);
});
-
```
### getAudioTime8+
@@ -5644,7 +5594,6 @@ Obtains the number of nanoseconds elapsed from the Unix epoch (January 1, 1970).
audioCapturer.getAudioTime((err, timestamp) => {
console.info(`Current timestamp: ${timestamp}`);
});
-
```
### getAudioTime8+
@@ -5669,7 +5618,6 @@ audioCapturer.getAudioTime().then((audioTime) => {
}).catch((err) => {
console.info(`AudioFrameworkRecLog: AudioCapturer Created : ERROR : ${err}`);
});
-
```
### getBufferSize8+
@@ -5699,7 +5647,6 @@ audioCapturer.getBufferSize((err, bufferSize) => {
});
}
});
-
```
### getBufferSize8+
@@ -5726,7 +5673,6 @@ audioCapturer.getBufferSize().then((data) => {
}).catch((err) => {
console.info(`AudioFrameworkRecLog: getBufferSize :ERROR : ${err}`);
});
-
```
### on('markReach')8+
@@ -5753,7 +5699,6 @@ audioCapturer.on('markReach', 1000, (position) => {
console.info('ON Triggered successfully');
}
});
-
```
### off('markReach')8+
@@ -5774,7 +5719,6 @@ Unsubscribes from mark reached events.
```js
audioCapturer.off('markReach');
-
```
### on('periodReach')8+
@@ -5801,7 +5745,6 @@ audioCapturer.on('periodReach', 1000, (position) => {
console.info('ON Triggered successfully');
}
});
-
```
### off('periodReach')8+
@@ -5822,10 +5765,9 @@ Unsubscribes from period reached events.
```js
audioCapturer.off('periodReach')
-
```
-### on('stateChange')8+
+### on('stateChange') 8+
on(type: 'stateChange', callback: Callback): void
@@ -5851,7 +5793,6 @@ audioCapturer.on('stateChange', (state) => {
console.info('audio capturer state is: STATE_RUNNING');
}
});
-
```
## ToneType9+
@@ -5926,7 +5867,6 @@ tonePlayer.load(audio.ToneType.TONE_TYPE_DIAL_5, (err) => {
console.info('callback call load success');
}
});
-
```
### load9+
@@ -5959,7 +5899,6 @@ tonePlayer.load(audio.ToneType.TONE_TYPE_DIAL_1).then(() => {
}).catch(() => {
console.error('promise call load fail');
});
-
```
### start9+
@@ -5989,7 +5928,6 @@ tonePlayer.start((err) => {
console.info('callback call start success');
}
});
-
```
### start9+
@@ -6016,7 +5954,6 @@ tonePlayer.start().then(() => {
}).catch(() => {
console.error('promise call start fail');
});
-
```
### stop9+
@@ -6046,7 +5983,6 @@ tonePlayer.stop((err) => {
console.error('callback call stop success ');
}
});
-
```
### stop9+
@@ -6073,7 +6009,6 @@ tonePlayer.stop().then(() => {
}).catch(() => {
console.error('promise call stop fail');
});
-
```
### release9+
@@ -6103,7 +6038,6 @@ tonePlayer.release((err) => {
console.info('callback call release success ');
}
});
-
```
### release9+
@@ -6130,7 +6064,6 @@ tonePlayer.release().then(() => {
}).catch(() => {
console.error('promise call release fail');
});
-
```
## ActiveDeviceType(deprecated)
diff --git a/en/application-dev/reference/apis/js-apis-avsession.md b/en/application-dev/reference/apis/js-apis-avsession.md
index 86fc2ceeebebd248a2e51f6454ea74dbc2f80602..b89eb42bc8793b9d28f1682ab87b1ac9f157c14d 100644
--- a/en/application-dev/reference/apis/js-apis-avsession.md
+++ b/en/application-dev/reference/apis/js-apis-avsession.md
@@ -2,7 +2,7 @@
The **avSession** module provides APIs for media playback control so that applications can access the system's Media Controller.
-This module provides the following common features related to media sessions:
+This module provides the following typical features related to media sessions:
- [AVSession](#avsession): used to set session metadata, playback state information, and more.
- [AVSessionController](#avsessioncontroller): used to obtain session IDs, send commands and events to sessions, and obtain the session metadata and playback state information.
@@ -26,6 +26,8 @@ Creates a media session. This API uses a promise to return the result. An abilit
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Parameters**
| Name| Type | Mandatory| Description |
@@ -41,8 +43,8 @@ Creates a media session. This API uses a promise to return the result. An abilit
| --------------------------------- | ------------------------------------------------------------ |
| Promise<[AVSession](#avsession)\> | Promise used to return the media session obtained, which can be used to obtain the session ID, set the metadata and playback state information, and send key events.|
-
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -74,6 +76,8 @@ Creates a media session. This API uses an asynchronous callback to return the re
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Parameters**
| Name | Type | Mandatory| Description |
@@ -84,6 +88,7 @@ Creates a media session. This API uses an asynchronous callback to return the re
| callback | AsyncCallback<[AVSession](#avsession)\> | Yes | Callback used to return the media session obtained, which can be used to obtain the session ID, set the metadata and playback state information, and send key events.|
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -128,6 +133,7 @@ Obtains the descriptors of all sessions. This API uses a promise to return the r
| Promise\\>\> | Promise used to return an array of **AVSessionDescriptor** objects, each of which is read only.|
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -155,7 +161,7 @@ getAllSessionDescriptors(callback: AsyncCallback\\>\> | Yes | Callback used to return an array of **AVSessionDescriptor** objects, each of which is read only.|
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -191,6 +198,101 @@ avSession.getAllSessionDescriptors(function (err, descriptors) {
});
```
+## avSession.getHistoricalSessionDescriptors10+
+
+getHistoricalSessionDescriptors(maxSize?: number): Promise\>>
+
+Obtains the descriptors of all sessions. This API uses a promise to return the result.
+
+**Required permissions**: ohos.permission.MANAGE_MEDIA_RESOURCES
+
+**System capability**: SystemCapability.Multimedia.AVSession.Manager
+
+**System API**: This is a system API.
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ------ | ---- | -----------------------------------------------------------------|
+| maxSize | number | No | Maximum number of descriptors to obtain. The value ranges from 0 to 10. If this parameter is left blank, the default value **3** is used.|
+
+**Return value**
+
+| Type | Description |
+| --------------------------------------------------------------------------- | -------------------------------------- |
+| Promise\\>\> | Promise used to return an array of **AVSessionDescriptor** objects, each of which is read only.|
+
+**Error codes**
+
+For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
+
+| ID| Error Message|
+| -------- | ---------------------------------------- |
+| 6600101 | Session service exception. |
+
+**Example**
+
+```js
+avSession.getHistoricalSessionDescriptors().then((descriptors) => {
+ console.info(`getHistoricalSessionDescriptors : SUCCESS : descriptors.length : ${descriptors.length}`);
+ if(descriptors.length > 0 ){
+ console.info(`getHistoricalSessionDescriptors : SUCCESS : descriptors[0].isActive : ${descriptors[0].isActive}`);
+ console.info(`getHistoricalSessionDescriptors : SUCCESS : descriptors[0].type : ${descriptors[0].type}`);
+ console.info(`getHistoricalSessionDescriptors : SUCCESS : descriptors[0].sessionTag : ${descriptors[0].sessionTag}`);
+ console.info(`getHistoricalSessionDescriptors : SUCCESS : descriptors[0].sessionId : ${descriptors[0].sessionId}`);
+ console.info(`getHistoricalSessionDescriptors : SUCCESS : descriptors[0].elementName.bundleName : ${descriptors[0].elementName.bundleName}`);
+ }
+}).catch((err) => {
+ console.info(`getHistoricalSessionDescriptors BusinessError: code: ${err.code}, message: ${err.message}`);
+});
+```
+
+## avSession.getHistoricalSessionDescriptors10+
+
+getHistoricalSessionDescriptors(maxSize: number, callback: AsyncCallback\>>): void
+
+Obtains the descriptors of all sessions. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.MANAGE_MEDIA_RESOURCES
+
+**System capability**: SystemCapability.Multimedia.AVSession.Manager
+
+**System API**: This is a system API.
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------------------------------------------------------------ | ---- | -----------------------------------------------------------------|
+| maxSize | number | Yes | Maximum number of descriptors to obtain. The value ranges from 0 to 10. If this parameter is left blank, the default value **3** is used.|
+| callback | AsyncCallback\>\> | Yes | Callback used to return an array of **AVSessionDescriptor** objects, each of which is read only. |
+
+**Error codes**
+
+For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
+
+| ID| Error Message|
+| -------- | ---------------------------------------- |
+| 6600101 |Session service exception. |
+
+**Example**
+
+```js
+avSession.getHistoricalSessionDescriptors(1, function (err, descriptors) {
+ if (err) {
+ console.info(`getHistoricalSessionDescriptors BusinessError: code: ${err.code}, message: ${err.message}`);
+ } else {
+ console.info(`getHistoricalSessionDescriptors : SUCCESS : descriptors.length : ${descriptors.length}`);
+ if(descriptors.length > 0 ){
+ console.info(`getHistoricalSessionDescriptors : SUCCESS : descriptors[0].isActive : ${descriptors[0].isActive}`);
+ console.info(`getHistoricalSessionDescriptors : SUCCESS : descriptors[0].type : ${descriptors[0].type}`);
+ console.info(`getHistoricalSessionDescriptors : SUCCESS : descriptors[0].sessionTag : ${descriptors[0].sessionTag}`);
+ console.info(`getHistoricalSessionDescriptors : SUCCESS : descriptors[0].sessionId : ${descriptors[0].sessionId}`);
+ console.info(`getHistoricalSessionDescriptors : SUCCESS : descriptors[0].elementName.bundleName : ${descriptors[0].elementName.bundleName}`);
+ }
+ }
+});
+```
+
## avSession.createController
createController(sessionId: string): Promise\
@@ -216,6 +318,7 @@ Creates a session controller based on the session ID. Multiple session controlle
| Promise<[AVSessionController](#avsessioncontroller)\> | Promise used to return the session controller created, which can be used to obtain the session ID,
send commands and events to sessions, and obtain metadata and playback state information.|
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -268,6 +371,7 @@ Creates a session controller based on the session ID. Multiple session controlle
| callback | AsyncCallback<[AVSessionController](#avsessioncontroller)\> | Yes | Callback used to return the session controller created, which can be used to obtain the session ID,
send commands and events to sessions, and obtain metadata and playback state information.|
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -327,9 +431,10 @@ Before calling this API, import the **ohos.multimedia.audio** module to obtain t
| Type | Description |
| -------------- | ----------------------------- |
-| Promise | Promise used to return the result. If the cast is successful, no value is returned; otherwise, an error object is returned.|
+| Promise | Promise used to return the result. If the casting is successful, no value is returned; otherwise, an error object is returned.|
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -382,6 +487,7 @@ Before calling this API, import the **ohos.multimedia.audio** module to obtain t
| callback | AsyncCallback | Yes | Callback used to return the result. If the casting is successful, **err** is **undefined**; otherwise, **err** is an error object. |
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -433,6 +539,7 @@ Subscribes to session creation, session destruction, and top session change even
| callback | (session: [AVSessionDescriptor](#avsessiondescriptor)) => void | Yes | Callback used to report the session descriptor. |
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -478,9 +585,10 @@ Unsubscribes from session creation, session destruction, and top session change
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| type | string | Yes | Event type.
- **'sessionCreate'**: session creation event, which is reported when a session is created.
- **'sessionDestroy'**: session destruction event, which is reported when a session is destroyed.
- **'topSessionChange'**: top session change event, which is reported when the top session is changed.|
-| callback | (session: [AVSessionDescriptor](#avsessiondescriptor)) => void | No | Callback used for unsubscription. If the unsubscription is successful, **err** is **undefined**; otherwise, **err** is an error object.
The **session** parameter in the callback describes a media session. The callback parameter is optional. If it is not specified, the specified event is no longer listened for all sessions. |
+| callback | (session: [AVSessionDescriptor](#avsessiondescriptor)) => void | No | Callback used for unsubscription. If the unsubscription is successful, **err** is **undefined**; otherwise, **err** is an error object.
The **session** parameter in the callback describes a media session. The **callback** parameter is optional. If it is not specified, all the subscriptions to the specified event are canceled for this session. |
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -503,6 +611,8 @@ Subscribes to session service death events.
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Parameters**
| Name | Type | Mandatory| Description |
@@ -511,6 +621,7 @@ Subscribes to session service death events.
| callback | callback: () => void | Yes | Callback used for subscription. If the subscription is successful, **err** is **undefined**; otherwise, **err** is an error object. |
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -533,14 +644,17 @@ Unsubscribes from session service death events.
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Parameters**
| Name | Type | Mandatory | Description |
| ------ | ---------------------- | ---- | ------------------------------------------------------- |
| type | string | Yes | Event type. The event **'sessionServiceDie'** is reported when the session service dies.|
-| callback | callback: () => void | No | Callback used for unsubscription. If the unsubscription is successful, **err** is **undefined**; otherwise, **err** is an error object.
The callback parameter is optional. If it is not specified, the specified event is no longer listened for all sessions. |
+| callback | callback: () => void | No | Callback used for unsubscription. If the unsubscription is successful, **err** is **undefined**; otherwise, **err** is an error object.
The **callback** parameter is optional. If it is not specified, all the subscriptions to the specified event are canceled for this session. |
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -578,6 +692,7 @@ Sends a system key event to the top session. This API uses a promise to return t
| Promise | Promise used to return the result. If the event is sent, no value is returned; otherwise, an error object is returned.|
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -620,6 +735,7 @@ Sends a system key event to the top session. This API uses an asynchronous callb
| callback | AsyncCallback | Yes | Callback used to return the result. If the event is sent, **err** is **undefined**; otherwise, **err** is an error object.|
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -667,6 +783,7 @@ Sends a system control command to the top session. This API uses a promise to re
| Promise | Promise used to return the result. If the command is sent, no value is returned; otherwise, an error object is returned.|
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -721,6 +838,7 @@ Sends a system control command to the top session. This API uses an asynchronous
| callback | AsyncCallback | Yes | Callback used to return the result. If the command is sent, **err** is **undefined**; otherwise, **err** is an error object.|
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -765,6 +883,8 @@ An **AVSession** object is created by calling [avSession.createAVSession](#avses
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
| Name | Type | Readable| Writable| Description |
| :-------- | :----- | :--- | :--- | :---------------------------- |
@@ -784,6 +904,8 @@ Sets session metadata. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Parameters**
| Name| Type | Mandatory| Description |
@@ -797,6 +919,7 @@ Sets session metadata. This API uses a promise to return the result.
| Promise | Promise used to return the result. If the setting is successful, no value is returned; otherwise, an error object is returned.|
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -838,6 +961,8 @@ Sets session metadata. This API uses an asynchronous callback to return the resu
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Parameters**
| Name | Type | Mandatory| Description |
@@ -846,6 +971,7 @@ Sets session metadata. This API uses an asynchronous callback to return the resu
| callback | AsyncCallback | Yes | Callback used to return the result. If the setting is successful, **err** is **undefined**; otherwise, **err** is an error object.|
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -889,6 +1015,8 @@ Sets information related to the session playback state. This API uses a promise
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Parameters**
| Name| Type | Mandatory| Description |
@@ -902,6 +1030,7 @@ Sets information related to the session playback state. This API uses a promise
| Promise | Promise used to return the result. If the setting is successful, no value is returned; otherwise, an error object is returned.|
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -935,6 +1064,8 @@ Sets information related to the session playback state. This API uses an asynchr
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Parameters**
| Name | Type | Mandatory| Description |
@@ -943,6 +1074,7 @@ Sets information related to the session playback state. This API uses an asynchr
| callback | AsyncCallback | Yes | Callback used to return the result. If the setting is successful, **err** is **undefined**; otherwise, **err** is an error object. |
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -970,6 +1102,220 @@ session.setAVPlaybackState(PlaybackState, function (err) {
});
```
+### setAVQueueItems10+
+
+setAVQueueItems(items: Array\): Promise
+
+Sets a playlist. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Multimedia.AVSession.Core
+
+**System API**: This is a system API.
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ------ | ------------------------------------ | ---- | ---------------------------------- |
+| items | Array<[AVQueueItem](#avqueueitem10)\> | Yes | Playlist to set.|
+
+**Return value**
+
+| Type | Description |
+| -------------- | ----------------------------- |
+| Promise | Promise used to return the result. If the setting is successful, no value is returned; otherwise, an error object is returned.|
+
+**Error codes**
+
+For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
+
+| ID| Error Message|
+| -------- | ---------------------------------------- |
+| 6600101 | Session service exception. |
+| 6600102 | The session does not exist. |
+
+**Example**
+
+```js
+let queueItemDescription_1 = {
+ mediaId: '001',
+ title: 'music_name',
+ subtitle: 'music_sub_name',
+ description: 'music_description',
+ icon: PIXELMAP_OBJECT,
+ iconUri: 'http://www.icon.uri.com',
+ extras: {'extras':'any'}
+};
+let queueItem_1 = {
+ itemId: 1,
+ description: queueItemDescription_1
+};
+let queueItemDescription_2 = {
+ mediaId: '002',
+ title: 'music_name',
+ subtitle: 'music_sub_name',
+ description: 'music_description',
+ icon: PIXELMAP_OBJECT,
+ iconUri: 'http://www.icon.uri.com',
+ extras: {'extras':'any'}
+};
+let queueItem_2 = {
+ itemId: 2,
+ description: queueItemDescription_2
+};
+let queueItemsArray = [queueItem_1, queueItem_2];
+session.setAVQueueItems(queueItemsArray).then(() => {
+ console.info('SetAVQueueItems successfully');
+}).catch((err) => {
+ console.info(`SetAVQueueItems BusinessError: code: ${err.code}, message: ${err.message}`);
+});
+```
+
+### setAVQueueItems10+
+
+setAVQueueItems(items: Array\, callback: AsyncCallback): void
+
+Sets a playlist. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Multimedia.AVSession.Core
+
+**System API**: This is a system API.
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------------------ | ---- | ----------------------------------------------------------- |
+| items | Array<[AVQueueItem](#avqueueitem10)\> | Yes | Playlist to set. |
+| callback | AsyncCallback | Yes | Callback used to return the result. If the setting is successful, **err** is **undefined**; otherwise, **err** is an error object.|
+
+**Error codes**
+
+For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
+
+| ID| Error Message|
+| -------- | ---------------------------------------- |
+| 6600101 | Session service exception. |
+| 6600102 | The session does not exist. |
+
+**Example**
+
+```js
+let queueItemDescription_1 = {
+ mediaId: '001',
+ title: 'music_name',
+ subtitle: 'music_sub_name',
+ description: 'music_description',
+ icon: PIXELMAP_OBJECT,
+ iconUri: 'http://www.icon.uri.com',
+ extras: {'extras':'any'}
+};
+let queueItem_1 = {
+ itemId: 1,
+ description: queueItemDescription_1
+};
+let queueItemDescription_2 = {
+ mediaId: '002',
+ title: 'music_name',
+ subtitle: 'music_sub_name',
+ description: 'music_description',
+ icon: PIXELMAP_OBJECT,
+ iconUri: 'http://www.icon.uri.com',
+ extras: {'extras':'any'}
+};
+let queueItem_2 = {
+ itemId: 2,
+ description: queueItemDescription_2
+};
+let queueItemsArray = [queueItem_1, queueItem_2];
+session.setAVQueueItems(queueItemsArray, function (err) {
+ if (err) {
+ console.info(`SetAVQueueItems BusinessError: code: ${err.code}, message: ${err.message}`);
+ } else {
+ console.info('SetAVQueueItems successfully');
+ }
+});
+```
+
+### setAVQueueTitle10+
+
+setAVQueueTitle(title: string): Promise\
+
+Sets a name for the playlist. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Multimedia.AVSession.Core
+
+**System API**: This is a system API.
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ------ | ------ | ---- | -------------- |
+| title | string | Yes | Name of the playlist.|
+
+**Return value**
+
+| Type | Description |
+| -------------- | ----------------------------- |
+| Promise | Promise used to return the result. If the setting is successful, no value is returned; otherwise, an error object is returned.|
+
+**Error codes**
+
+For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
+
+| ID| Error Message|
+| -------- | ---------------------------------------- |
+| 6600101 | Session service exception. |
+| 6600102 | The session does not exist. |
+
+**Example**
+
+```js
+let queueTitle = 'QUEUE_TITLE';
+session.setAVQueueTitle(queueTitle).then(() => {
+ console.info('SetAVQueueTitle successfully');
+}).catch((err) => {
+ console.info(`SetAVQueueTitle BusinessError: code: ${err.code}, message: ${err.message}`);
+});
+```
+
+### setAVQueueTitle10+
+
+setAVQueueTitle(title: string, callback: AsyncCallback\): void
+
+Sets a name for the playlist. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Multimedia.AVSession.Core
+
+**System API**: This is a system API.
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | --------------------- | ---- | ----------------------------------------------------------- |
+| title | string | Yes | Name of the playlist. |
+| callback | AsyncCallback | Yes | Callback used to return the result. If the setting is successful, **err** is **undefined**; otherwise, **err** is an error object.|
+
+**Error codes**
+
+For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
+
+| ID| Error Message|
+| -------- | ---------------------------------------- |
+| 6600101 | Session service exception. |
+| 6600102 | The session does not exist. |
+
+**Example**
+
+```js
+let queueTitle = 'QUEUE_TITLE';
+session.setAVQueueTitle(queueTitle, function (err) {
+ if (err) {
+ console.info(`SetAVQueueTitle BusinessError: code: ${err.code}, message: ${err.message}`);
+ } else {
+ console.info('SetAVQueueTitle successfully');
+ }
+});
+```
+
### setLaunchAbility
setLaunchAbility(ability: WantAgent): Promise\
@@ -978,6 +1324,8 @@ Sets a launcher ability. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Parameters**
| Name | Type | Mandatory| Description |
@@ -991,6 +1339,7 @@ Sets a launcher ability. This API uses a promise to return the result.
| Promise | Promise used to return the result. If the setting is successful, no value is returned; otherwise, an error object is returned.|
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -1048,6 +1397,8 @@ Sets a launcher ability. This API uses an asynchronous callback to return the re
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Parameters**
| Name | Type | Mandatory| Description |
@@ -1056,6 +1407,7 @@ Sets a launcher ability. This API uses an asynchronous callback to return the re
| callback | AsyncCallback | Yes | Callback used to return the result. If the setting is successful, **err** is **undefined**; otherwise, **err** is an error object.|
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -1107,21 +1459,31 @@ wantAgent.getWantAgent(wantAgentInfo).then((agent) => {
});
```
-### getController
+### dispatchSessionEvent10+
-getController(): Promise\
+dispatchSessionEvent(event: string, args: {[key: string]: Object}): Promise\
-Obtains the controller corresponding to this session. This API uses a promise to return the result.
+Dispatches a custom event in the session, including the event name and event content in key-value pair format. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ------- | --------------------------------------------- | ---- | ----------------------------------------------------------- |
+| event | string | Yes | Name of the session event.|
+| args | {[key: string]: any} | Yes | Event content in key-value pair format.|
+
**Return value**
-| Type | Description |
-| ---------------------------------------------------- | ----------------------------- |
-| Promise<[AVSessionController](#avsessioncontroller)> | Promise used to return the session controller.|
+| Type | Description |
+| -------------- | ----------------------------- |
+| Promise | Promise used to return the result. If the setting is successful, no value is returned; otherwise, an error object is returned.|
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -1132,7 +1494,85 @@ For details about the error codes, see [AVSession Management Error Codes](../err
**Example**
```js
-let controller;
+let eventName = "dynamic_lyric";
+let args = {
+ lyric : "This is lyric"
+}
+await session.dispatchSessionEvent(eventName, args).catch((err) => {
+ console.info(`dispatchSessionEvent BusinessError: code: ${err.code}, message: ${err.message}`);
+})
+```
+
+### dispatchSessionEvent10+
+
+dispatchSessionEvent(event: string, args: {[key: string]: Object}, callback: AsyncCallback): void
+
+Dispatches a custom event in the session, including the event name and event content in key-value pair format. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Multimedia.AVSession.Core
+
+**System API**: This is a system API.
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ------- | --------------------------------------------- | ---- | ----------------------------------------------------------- |
+| event | string | Yes | Name of the session event.|
+| args | {[key: string]: any} | Yes | Event content in key-value pair format.|
+| callback | AsyncCallback | Yes | Callback used to return the result. If the setting is successful, **err** is **undefined**; otherwise, **err** is an error object.|
+
+**Error codes**
+
+For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
+
+| ID| Error Message|
+| -------- | ---------------------------------------- |
+| 6600101 | Session service exception. |
+| 6600102 | The session does not exist. |
+
+**Example**
+
+```js
+let eventName = "dynamic_lyric";
+let args = {
+ lyric : "This is lyric"
+}
+await session.dispatchSessionEvent(eventName, args, (err) => {
+ if(err) {
+ console.info(`dispatchSessionEvent BusinessError: code: ${err.code}, message: ${err.message}`);
+ }
+})
+```
+
+### getController
+
+getController(): Promise\
+
+Obtains the controller corresponding to this session. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Multimedia.AVSession.Core
+
+**System API**: This is a system API.
+
+**Return value**
+
+| Type | Description |
+| ---------------------------------------------------- | ----------------------------- |
+| Promise<[AVSessionController](#avsessioncontroller)> | Promise used to return the session controller.|
+
+**Error codes**
+
+For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
+
+| ID| Error Message|
+| -------- | ---------------------------------------- |
+| 6600101 | Session service exception. |
+| 6600102 | The session does not exist. |
+
+**Example**
+
+```js
+let controller;
session.getController().then((avcontroller) => {
controller = avcontroller;
console.info(`GetController : SUCCESS : sessionid : ${controller.sessionId}`);
@@ -1149,6 +1589,8 @@ Obtains the controller corresponding to this session. This API uses an asynchron
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Parameters**
| Name | Type | Mandatory| Description |
@@ -1156,6 +1598,7 @@ Obtains the controller corresponding to this session. This API uses an asynchron
| callback | AsyncCallback<[AVSessionController](#avsessioncontroller)\> | Yes | Callback used to return the session controller.|
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -1185,6 +1628,8 @@ Obtains information about the output device for this session. This API uses a pr
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Return value**
| Type | Description |
@@ -1192,6 +1637,7 @@ Obtains information about the output device for this session. This API uses a pr
| Promise<[OutputDeviceInfo](#outputdeviceinfo)> | Promise used to return the output device information.|
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -1217,6 +1663,8 @@ Obtains information about the output device for this session. This API uses an a
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Parameters**
| Name | Type | Mandatory| Description |
@@ -1224,6 +1672,7 @@ Obtains information about the output device for this session. This API uses an a
| callback | AsyncCallback<[OutputDeviceInfo](#outputdeviceinfo)\> | Yes | Callback used to return the information obtained.|
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -1251,6 +1700,8 @@ Activates this session. A session can be used only after being activated. This A
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Return value**
| Type | Description |
@@ -1258,6 +1709,7 @@ Activates this session. A session can be used only after being activated. This A
| Promise | Promise used to return the result. If the session is activated, no value is returned; otherwise, an error object is returned.|
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -1283,6 +1735,8 @@ Activates this session. A session can be used only after being activated. This A
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Parameters**
| Name | Type | Mandatory| Description |
@@ -1290,6 +1744,7 @@ Activates this session. A session can be used only after being activated. This A
| callback | AsyncCallback | Yes | Callback used to return the result. If the session is activated, **err** is **undefined**; otherwise, **err** is an error object.|
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -1317,6 +1772,8 @@ Deactivates this session. You can use [activate](#activate) to activate the sess
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Return value**
| Type | Description |
@@ -1324,6 +1781,7 @@ Deactivates this session. You can use [activate](#activate) to activate the sess
| Promise | Promise used to return the result. If the session is deactivated, no value is returned; otherwise, an error object is returned.|
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -1351,6 +1809,8 @@ Deactivates this session. You can use [activate](#activate) to activate the sess
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Parameters**
| Name | Type | Mandatory| Description |
@@ -1358,6 +1818,7 @@ Deactivates this session. You can use [activate](#activate) to activate the sess
| callback | AsyncCallback | Yes | Callback used to return the result. If the session is deactivated, **err** is **undefined**; otherwise, **err** is an error object.|
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -1385,6 +1846,8 @@ Destroys this session. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Return value**
| Type | Description |
@@ -1392,6 +1855,7 @@ Destroys this session. This API uses a promise to return the result.
| Promise | Promise used to return the result. If the session is destroyed, no value is returned; otherwise, an error object is returned.|
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -1415,9 +1879,10 @@ destroy(callback: AsyncCallback\): void
Destroys this session. This API uses an asynchronous callback to return the result.
-
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Parameters**
| Name | Type | Mandatory| Description |
@@ -1425,6 +1890,7 @@ Destroys this session. This API uses an asynchronous callback to return the resu
| callback | AsyncCallback | Yes | Callback used to return the result. If the session is destroyed, **err** is **undefined**; otherwise, **err** is an error object.|
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -1452,6 +1918,8 @@ Subscribes to playback command events.
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Parameters**
| Name | Type | Mandatory| Description |
@@ -1460,6 +1928,7 @@ Subscribes to playback command events.
| callback | callback: () => void | Yes | Callback used for subscription. If the subscription is successful, **err** is **undefined**; otherwise, **err** is an error object. |
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -1501,6 +1970,8 @@ Subscribes to the seek event.
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Parameters**
| Name | Type | Mandatory| Description |
@@ -1509,6 +1980,7 @@ Subscribes to the seek event.
| callback | (time: number) => void | Yes | Callback used for subscription. The **time** parameter in the callback indicates the time to seek to, in milliseconds. |
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -1532,6 +2004,8 @@ Subscribes to the event for setting the playback speed.
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Parameters**
| Name | Type | Mandatory| Description |
@@ -1540,6 +2014,7 @@ Subscribes to the event for setting the playback speed.
| callback | (speed: number) => void | Yes | Callback used for subscription. The **speed** parameter in the callback indicates the playback speed. |
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -1563,6 +2038,8 @@ Subscribes to the event for setting the loop mode.
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Parameters**
| Name | Type | Mandatory| Description |
@@ -1571,6 +2048,7 @@ Subscribes to the event for setting the loop mode.
| callback | (mode: [LoopMode](#loopmode)) => void | Yes | Callback used for subscription. The **mode** parameter in the callback indicates the loop mode. |
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -1594,6 +2072,8 @@ Subscribes to the event for favoriting a media asset.
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Parameters**
| Name | Type | Mandatory| Description |
@@ -1602,6 +2082,7 @@ Subscribes to the event for favoriting a media asset.
| callback | (assetId: string) => void | Yes | Callback used for subscription. The **assetId** parameter in the callback indicates the media asset ID. |
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -1617,6 +2098,40 @@ session.on('toggleFavorite', (assetId) => {
});
```
+### on('skipToQueueItem')10+
+
+on(type: 'skipToQueueItem', callback: (itemId: number) => void): void
+
+Subscribes to the event that indicates an item in the playlist is selected. The session can play the selected item.
+
+**System capability**: SystemCapability.Multimedia.AVSession.Core
+
+**System API**: This is a system API.
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------ | ---- | ---------------------------------------------------------------------------------------- |
+| type | string | Yes | Event type. The event **'skipToQueueItem'** is reported when the command for selecting an item in the playlist is sent to the session.|
+| callback | (itemId: number) => void | Yes | Callback used for subscription. The **itemId** parameter in the callback indicates the ID of the selected item. |
+
+**Error codes**
+
+For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
+
+| ID| Error Message|
+| -------- | ---------------------------------------- |
+| 6600101 | Session service exception. |
+| 6600102 | The session does not exist. |
+
+**Example**
+
+```js
+session.on('skipToQueueItem', (itemId) => {
+ console.info(`on skipToQueueItem id : ${itemId}`);
+});
+```
+
### on('handleKeyEvent')
on(type: 'handleKeyEvent', callback: (event: KeyEvent) => void): void
@@ -1625,6 +2140,8 @@ Subscribes to the key event.
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Parameters**
| Name | Type | Mandatory| Description |
@@ -1633,6 +2150,7 @@ Subscribes to the key event.
| callback | (event: [KeyEvent](js-apis-keyevent.md)) => void | Yes | Callback used for subscription. The **event** parameter in the callback indicates the key event. |
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -1656,6 +2174,8 @@ Subscribes to output device changes.
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Parameters**
| Name | Type | Mandatory| Description |
@@ -1664,6 +2184,7 @@ Subscribes to output device changes.
| callback | (device: [OutputDeviceInfo](#outputdeviceinfo)) => void | Yes | Callback used for subscription. The **device** parameter in the callback indicates the output device information. |
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -1679,6 +2200,40 @@ session.on('outputDeviceChange', (device) => {
});
```
+### on('commonCommand')10+
+
+on(type: 'commonCommand', callback: (command: string, args: {[key: string]: Object}) => void): void
+
+Subscribes to custom control command changes.
+
+**System capability**: SystemCapability.Multimedia.AVSession.Core
+
+**System API**: This is a system API.
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
+| type | string | Yes | Event type. The event **'commonCommand'** is reported when a custom control command changes.|
+| callback | (commonCommand: string, args: {[key:string]: Object}) => void | Yes | Callback used for subscription. The **commonCommand** parameter in the callback indicates the name of the changed custom control command, and **args** indicates the parameters carried in the command. |
+
+**Error codes**
+
+For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
+
+| ID| Error Message|
+| -------- | ------------------------------ |
+| 6600101 | Session service exception. |
+| 6600103 | The session controller does not exist. |
+
+**Example**
+
+```js
+session.on('commonCommand', (commonCommand, args) => {
+ console.info(`OnCommonCommand, the command is ${commonCommand}, args: ${JSON.stringify(args)}`);
+});
+```
+
### off('play'|'pause'|'stop'|'playNext'|'playPrevious'|'fastForward'|'rewind')
off(type: 'play' | 'pause' | 'stop' | 'playNext' | 'playPrevious' | 'fastForward' | 'rewind', callback?: () => void): void
@@ -1687,14 +2242,17 @@ Unsubscribes from playback command events.
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ---------------------------------------------------------------------------------------------------------------------------- |
| type | string | Yes | Event type. The following events are supported: **'play'**, **'pause'**, **'stop'**, **'playNext'**, **'playPrevious'**, **'fastForward'**, and **'rewind'**.|
-| callback | callback: () => void | No | Callback used for unsubscription. If the unsubscription is successful, **err** is **undefined**; otherwise, **err** is an error object.
The callback parameter is optional. If it is not specified, the specified event is no longer listened for all sessions. |
+| callback | callback: () => void | No | Callback used for unsubscription. If the unsubscription is successful, **err** is **undefined**; otherwise, **err** is an error object.
The **callback** parameter is optional. If it is not specified, all the subscriptions to the specified event are canceled for this session. |
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -1722,14 +2280,17 @@ Unsubscribes from the seek event.
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ----------------------------------------- |
| type | string | Yes | Event type. The value is fixed at **'seek'**. |
-| callback | (time: number) => void | No | Callback used for unsubscription. The **time** parameter in the callback indicates the time to seek to, in milliseconds.
If the unsubscription is successful, **err** is **undefined**; otherwise, **err** is an error object.
The callback parameter is optional. If it is not specified, the specified event is no longer listened for all sessions. |
+| callback | (time: number) => void | No | Callback used for unsubscription. The **time** parameter in the callback indicates the time to seek to, in milliseconds.
If the unsubscription is successful, **err** is **undefined**; otherwise, **err** is an error object.
The **callback** parameter is optional. If it is not specified, all the subscriptions to the specified event are canceled for this session. |
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -1751,14 +2312,17 @@ Unsubscribes from the event for setting the playback speed.
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | -------------------------------------------|
| type | string | Yes | Event type. The value is fixed at **'setSpeed'**. |
-| callback | (speed: number) => void | No | Callback used for unsubscription. The **speed** parameter in the callback indicates the playback speed.
If the unsubscription is successful, **err** is **undefined**; otherwise, **err** is an error object.
The callback parameter is optional. If it is not specified, the specified event is no longer listened for all sessions. |
+| callback | (speed: number) => void | No | Callback used for unsubscription. The **speed** parameter in the callback indicates the playback speed.
If the unsubscription is successful, **err** is **undefined**; otherwise, **err** is an error object.
The **callback** parameter is optional. If it is not specified, all the subscriptions to the specified event are canceled for this session. |
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -1780,14 +2344,17 @@ Unsubscribes from the event for setting loop mode.
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------- | ---- | ----- |
| type | string | Yes | Event type. The value is fixed at **'setLoopMode'**.|
-| callback | (mode: [LoopMode](#loopmode)) => void | No | Callback used for unsubscription. The **mode** parameter in the callback indicates the loop mode.
If the unsubscription is successful, **err** is **undefined**; otherwise, **err** is an error object.
The callback parameter is optional. If it is not specified, the specified event is no longer listened for all sessions.|
+| callback | (mode: [LoopMode](#loopmode)) => void | No | Callback used for unsubscription. The **mode** parameter in the callback indicates the loop mode.
If the unsubscription is successful, **err** is **undefined**; otherwise, **err** is an error object.
The **callback** parameter is optional. If it is not specified, all the subscriptions to the specified event are canceled for this session.|
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -1809,14 +2376,17 @@ Unsubscribes from the event for favoriting a media asset.
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | -------------------------------------------------------- |
| type | string | Yes | Event type. The value is fixed at **'toggleFavorite'**. |
-| callback | (assetId: string) => void | No | Callback used for unsubscription. The **assetId** parameter in the callback indicates the media asset ID.
If the unsubscription is successful, **err** is **undefined**; otherwise, **err** is an error object.
The callback parameter is optional. If it is not specified, the specified event is no longer listened for all sessions. |
+| callback | (assetId: string) => void | No | Callback used for unsubscription. The **assetId** parameter in the callback indicates the media asset ID.
If the unsubscription is successful, **err** is **undefined**; otherwise, **err** is an error object.
The **callback** parameter is optional. If it is not specified, all the subscriptions to the specified event are canceled for this session. |
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -1830,6 +2400,38 @@ For details about the error codes, see [AVSession Management Error Codes](../err
session.off('toggleFavorite');
```
+### off('skipToQueueItem')10+
+
+off(type: 'skipToQueueItem', callback?: (itemId: number) => void): void
+
+Unsubscribes from the event that indicates an item in the playlist is selected.
+
+**System capability**: SystemCapability.Multimedia.AVSession.Core
+
+**System API**: This is a system API.
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------ | ---- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| type | string | Yes | Event type. The value is fixed at **'skipToQueueItem'**. |
+| callback | (itemId: number) => void | No | Callback used for unsubscription. The **itemId** parameter in the callback indicates the ID of the item.
If the unsubscription is successful, **err** is **undefined**; otherwise, **err** is an error object.
The **callback** parameter is optional. If it is not specified, all the subscriptions to the specified event are canceled for this session.|
+
+**Error codes**
+
+For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
+
+| ID| Error Message|
+| -------- | ---------------------------------------- |
+| 6600101 | Session service exception. |
+| 6600102 | The session does not exist. |
+
+**Example**
+
+```js
+session.off('skipToQueueItem');
+```
+
### off('handleKeyEvent')
off(type: 'handleKeyEvent', callback?: (event: KeyEvent) => void): void
@@ -1838,14 +2440,17 @@ Unsubscribes from the key event.
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| type | string | Yes | Event type. The value is fixed at **'handleKeyEvent'**. |
-| callback | (event: [KeyEvent](js-apis-keyevent.md)) => void | No | Callback used for unsubscription. The **event** parameter in the callback indicates the key event.
If the unsubscription is successful, **err** is **undefined**; otherwise, **err** is an error object.
The callback parameter is optional. If it is not specified, the specified event is no longer listened for all sessions. |
+| callback | (event: [KeyEvent](js-apis-keyevent.md)) => void | No | Callback used for unsubscription. The **event** parameter in the callback indicates the key event.
If the unsubscription is successful, **err** is **undefined**; otherwise, **err** is an error object.
The **callback** parameter is optional. If it is not specified, all the subscriptions to the specified event are canceled for this session. |
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -1867,14 +2472,17 @@ Unsubscribes from playback device changes.
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------ |
| type | string | Yes | Event type. The value is fixed at **'outputDeviceChange'**. |
-| callback | (device: [OutputDeviceInfo](#outputdeviceinfo)) => void | No | Callback used for unsubscription. The **device** parameter in the callback indicates the output device information.
If the unsubscription is successful, **err** is **undefined**; otherwise, **err** is an error object.
The callback parameter is optional. If it is not specified, the specified event is no longer listened for all sessions. |
+| callback | (device: [OutputDeviceInfo](#outputdeviceinfo)) => void | No | Callback used for unsubscription. The **device** parameter in the callback indicates the output device information.
If the unsubscription is successful, **err** is **undefined**; otherwise, **err** is an error object.
The **callback** parameter is optional. If it is not specified, all the subscriptions to the specified event are canceled for this session. |
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -1889,6 +2497,38 @@ session.off('outputDeviceChange');
```
+### off('commonCommand')10+
+
+off(type: 'commonCommand', callback?: (commonCommand: string, args: {[key:string]: Object}) => void): void
+
+Unsubscribes from custom control command changes.
+
+**System capability**: SystemCapability.Multimedia.AVSession.Core
+
+**System API**: This is a system API.
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------- |
+| type | string | Yes | Event type. The value is fixed at **'commonCommand'**. |
+| callback | (commonCommand: string, args: {[key:string]: Object}) => void | No | Callback used for unsubscription. The **commonCommand** parameter in the callback indicates the name of the changed custom control command, and **args** indicates the parameters carried in the command.
The **callback** parameter is optional. If it is not specified, all the subscriptions to the specified event are canceled for this session. |
+
+**Error codes**
+
+For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
+
+| ID| Error Message|
+| -------- | ---------------- |
+| 6600101 | Session service exception. |
+
+**Example**
+
+```js
+session.off('commonCommand');
+```
+
+
## AVSessionController
@@ -1922,6 +2562,8 @@ Obtains the information related to the playback state. This API uses a promise t
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Return value**
| Type | Description |
@@ -1929,6 +2571,7 @@ Obtains the information related to the playback state. This API uses a promise t
| Promise<[AVPlaybackState](#avplaybackstate)\> | Promise used to return the **AVPlaybackState** object.|
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -1954,6 +2597,8 @@ Obtains the information related to the playback state. This API uses an asynchro
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Parameters**
| Name | Type | Mandatory| Description |
@@ -1961,6 +2606,7 @@ Obtains the information related to the playback state. This API uses an asynchro
| callback | AsyncCallback<[AVPlaybackState](#avplaybackstate)\> | Yes | Callback used to return the **AVPlaybackState** object.|
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -1980,21 +2626,24 @@ controller.getAVPlaybackState(function (err, playbackState) {
});
```
-### getAVMetadata
+### getAVQueueItems10+
-getAVMetadata(): Promise\
+getAVQueueItems(): Promise\>
-Obtains the session metadata. This API uses a promise to return the result.
+Obtains the information related to the items in the queue. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Return value**
-| Type | Description |
-| ----------------------------------- | ----------------------------- |
-| Promise<[AVMetadata](#avmetadata)\> | Promise used to return the metadata obtained.|
+| Type | Description |
+| --------------------------------------------- | ----------------------------- |
+| Promise\> | Promise used to return the items in the queue.|
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -2005,21 +2654,248 @@ For details about the error codes, see [AVSession Management Error Codes](../err
**Example**
```js
-controller.getAVMetadata().then((metadata) => {
- console.info(`GetAVMetadata : SUCCESS : assetId : ${metadata.assetId}`);
+controller.getAVQueueItems().then((items) => {
+ console.info(`GetAVQueueItems : SUCCESS : length : ${items.length}`);
}).catch((err) => {
- console.info(`GetAVMetadata BusinessError: code: ${err.code}, message: ${err.message}`);
+ console.info(`GetAVQueueItems BusinessError: code: ${err.code}, message: ${err.message}`);
});
```
-### getAVMetadata
+### getAVQueueItems10+
-getAVMetadata(callback: AsyncCallback\): void
+getAVQueueItems(callback: AsyncCallback\>): void
-Obtains the session metadata. This API uses an asynchronous callback to return the result.
+Obtains the information related to the items in the playlist. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | --------------------------------------------------- | ---- | ------------------------- |
+| callback | AsyncCallback\> | Yes | Callback used to return the items in the playlist.|
+
+**Error codes**
+
+For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
+
+| ID| Error Message|
+| -------- | ---------------------------------------- |
+| 6600101 | Session service exception. |
+| 6600102 | The session does not exist. |
+| 6600103 | The session controller does not exist. |
+
+**Example**
+```js
+controller.getAVQueueItems(function (err, items) {
+ if (err) {
+ console.info(`GetAVQueueItems BusinessError: code: ${err.code}, message: ${err.message}`);
+ } else {
+ console.info(`GetAVQueueItems : SUCCESS : length : ${items.length}`);
+ }
+});
+```
+
+### getAVQueueTitle10+
+
+getAVQueueTitle(): Promise\
+
+Obtains the name of the playlist. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Multimedia.AVSession.Core
+
+**System API**: This is a system API.
+
+**Return value**
+
+| Type | Description |
+| ---------------- | ----------------------------- |
+| Promise | Promise used to return the playlist name.|
+
+**Error codes**
+
+For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
+
+| ID| Error Message|
+| -------- | ---------------------------------------- |
+| 6600101 | Session service exception. |
+| 6600102 | The session does not exist. |
+| 6600103 | The session controller does not exist. |
+
+**Example**
+```js
+controller.getAVQueueTitle().then((title) => {
+ console.info(`GetAVQueueTitle : SUCCESS : title : ${title}`);
+}).catch((err) => {
+ console.info(`GetAVQueueTitle BusinessError: code: ${err.code}, message: ${err.message}`);
+});
+```
+
+### getAVQueueTitle10+
+
+getAVQueueTitle(callback: AsyncCallback\): void
+
+Obtains the name of the playlist. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Multimedia.AVSession.Core
+
+**System API**: This is a system API.
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ---------------------- | ---- | ------------------------- |
+| callback | AsyncCallback | Yes | Callback used to return the playlist name.|
+
+**Error codes**
+
+For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
+
+| ID| Error Message|
+| -------- | ---------------------------------------- |
+| 6600101 | Session service exception. |
+| 6600102 | The session does not exist. |
+| 6600103 | The session controller does not exist. |
+
+**Example**
+```js
+controller.getAVQueueTitle(function (err, title) {
+ if (err) {
+ console.info(`GetAVQueueTitle BusinessError: code: ${err.code}, message: ${err.message}`);
+ } else {
+ console.info(`GetAVQueueTitle : SUCCESS : title : ${title}`);
+ }
+});
+```
+
+### skipToQueueItem10+
+
+skipToQueueItem(itemId: number): Promise\
+
+Sends the ID of an item in the playlist to the session for processing. The session can play the song. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Multimedia.AVSession.Core
+
+**System API**: This is a system API.
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ------ | ------- | ---- | ------------------------------------------- |
+| itemId | number | Yes | ID of an item in the playlist.|
+
+**Return value**
+
+| Type | Description |
+| -------------- | --------------------------------------------------------------- |
+| Promise | Promise used to return the result. If the item ID is sent, no value is returned; otherwise, an error object is returned.|
+
+**Error codes**
+
+For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
+
+| ID| Error Message|
+| -------- | ---------------------------------------- |
+| 6600101 | Session service exception. |
+| 6600102 | The session does not exist. |
+
+**Example**
+
+```js
+let queueItemId = 0;
+controller.skipToQueueItem(queueItemId).then(() => {
+ console.info('SkipToQueueItem successfully');
+}).catch((err) => {
+ console.info(`SkipToQueueItem BusinessError: code: ${err.code}, message: ${err.message}`);
+});
+```
+
+### skipToQueueItem10+
+
+skipToQueueItem(itemId: number, callback: AsyncCallback\): void
+
+Sends the ID of an item in the playlist to the session for processing. The session can play the song. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Multimedia.AVSession.Core
+
+**System API**: This is a system API.
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | --------------------- | ---- | ----------------------------------------------------------- |
+| itemId | number | Yes | ID of an item in the playlist. |
+| callback | AsyncCallback | Yes | Callback used to return the result. If the setting is successful, **err** is **undefined**; otherwise, **err** is an error object.|
+
+**Error codes**
+
+For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
+
+| ID| Error Message|
+| -------- | ---------------------------------------- |
+| 6600101 | Session service exception. |
+| 6600102 | The session does not exist. |
+
+**Example**
+
+```js
+let queueItemId = 0;
+controller.skipToQueueItem(queueItemId, function (err) {
+ if (err) {
+ console.info(`SkipToQueueItem BusinessError: code: ${err.code}, message: ${err.message}`);
+ } else {
+ console.info('SkipToQueueItem successfully');
+ }
+});
+```
+
+### getAVMetadata
+
+getAVMetadata(): Promise\
+
+Obtains the session metadata. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Multimedia.AVSession.Core
+
+**System API**: This is a system API.
+
+**Return value**
+
+| Type | Description |
+| ----------------------------------- | ----------------------------- |
+| Promise<[AVMetadata](#avmetadata)\> | Promise used to return the metadata obtained.|
+
+**Error codes**
+
+For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
+
+| ID| Error Message|
+| -------- | ---------------------------------------- |
+| 6600101 | Session service exception. |
+| 6600102 | The session does not exist. |
+| 6600103 | The session controller does not exist. |
+
+**Example**
+```js
+controller.getAVMetadata().then((metadata) => {
+ console.info(`GetAVMetadata : SUCCESS : assetId : ${metadata.assetId}`);
+}).catch((err) => {
+ console.info(`GetAVMetadata BusinessError: code: ${err.code}, message: ${err.message}`);
+});
+```
+
+### getAVMetadata
+
+getAVMetadata(callback: AsyncCallback\): void
+
+Obtains the session metadata. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Multimedia.AVSession.Core
+
+**System API**: This is a system API.
+
**Parameters**
| Name | Type | Mandatory| Description |
@@ -2027,6 +2903,7 @@ Obtains the session metadata. This API uses an asynchronous callback to return t
| callback | AsyncCallback<[AVMetadata](#avmetadata)\> | Yes | Callback used to return the metadata obtained.|
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -2054,6 +2931,8 @@ Obtains the output device information. This API uses a promise to return the res
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Return value**
| Type | Description |
@@ -2061,6 +2940,7 @@ Obtains the output device information. This API uses a promise to return the res
| Promise<[OutputDeviceInfo](#outputdeviceinfo)\> | Promise used to return the information obtained.|
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -2085,6 +2965,8 @@ Obtains the output device information. This API uses an asynchronous callback to
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Parameters**
| Name | Type | Mandatory| Description |
@@ -2092,6 +2974,7 @@ Obtains the output device information. This API uses an asynchronous callback to
| callback | AsyncCallback<[OutputDeviceInfo](#outputdeviceinfo)\> | Yes | Callback used to return the information obtained.|
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -2119,6 +3002,8 @@ Sends a key event to the session corresponding to this controller. This API uses
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Parameters**
| Name| Type | Mandatory| Description |
@@ -2126,6 +3011,7 @@ Sends a key event to the session corresponding to this controller. This API uses
| event | [KeyEvent](js-apis-keyevent.md) | Yes | Key event.|
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -2163,6 +3049,8 @@ Sends a key event to the session corresponding to this controller. This API uses
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Parameters**
| Name | Type | Mandatory| Description |
@@ -2171,6 +3059,7 @@ Sends a key event to the session corresponding to this controller. This API uses
| callback | AsyncCallback | Yes | Callback used to return the result. If the event is sent, **err** is **undefined**; otherwise, **err** is an error object.|
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -2204,6 +3093,8 @@ Obtains the **WantAgent** object saved by the application in the session. This A
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Return value**
| Type | Description |
@@ -2211,6 +3102,7 @@ Obtains the **WantAgent** object saved by the application in the session. This A
| Promise<[WantAgent](js-apis-app-ability-wantAgent.md)\> | Promise used to return the object saved by calling [setLaunchAbility](#setlaunchability). The object includes the application attribute, such as the bundle name, ability name, and device ID.|
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -2239,6 +3131,8 @@ Obtains the **WantAgent** object saved by the application in the session. This A
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Parameters**
| Name | Type | Mandatory| Description |
@@ -2246,6 +3140,7 @@ Obtains the **WantAgent** object saved by the application in the session. This A
| callback | AsyncCallback<[WantAgent](js-apis-app-ability-wantAgent.md)\> | Yes | Callback used to return the object saved by calling [setLaunchAbility](#setlaunchability). The object includes the application attribute, such as the bundle name, ability name, and device ID.|
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -2276,6 +3171,8 @@ Obtains the playback position.
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Return value**
| Type | Description |
@@ -2283,6 +3180,7 @@ Obtains the playback position.
| number | Playback position, in milliseconds.|
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -2304,6 +3202,8 @@ Checks whether the session is activated. This API uses a promise to return the r
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Return value**
| Type | Description |
@@ -2311,6 +3211,7 @@ Checks whether the session is activated. This API uses a promise to return the r
| Promise | Promise used to return the activation state. If the session is activated, **true** is returned; otherwise, **false** is returned.|
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -2337,6 +3238,8 @@ Checks whether the session is activated. This API uses an asynchronous callback
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Parameters**
| Name | Type | Mandatory| Description |
@@ -2344,6 +3247,7 @@ Checks whether the session is activated. This API uses an asynchronous callback
| callback | AsyncCallback | Yes | Callback used to return the activation state. If the session is activated, **true** is returned; otherwise, **false** is returned.|
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -2372,6 +3276,8 @@ Destroys this controller. A controller can no longer be used after being destroy
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Return value**
| Type | Description |
@@ -2379,6 +3285,7 @@ Destroys this controller. A controller can no longer be used after being destroy
| Promise | Promise used to return the result. If the controller is destroyed, no value is returned; otherwise, an error object is returned.|
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -2404,6 +3311,8 @@ Destroys this controller. A controller can no longer be used after being destroy
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Parameters**
| Name | Type | Mandatory| Description |
@@ -2411,6 +3320,7 @@ Destroys this controller. A controller can no longer be used after being destroy
| callback | AsyncCallback | Yes | Callback used to return the result. If the controller is destroyed, **err** is **undefined**; otherwise, **err** is an error object.|
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -2438,6 +3348,8 @@ Obtains valid commands supported by the session. This API uses a promise to retu
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Return value**
| Type | Description |
@@ -2445,6 +3357,7 @@ Obtains valid commands supported by the session. This API uses a promise to retu
| Promise\> | Promise used to return a set of valid commands.|
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -2471,6 +3384,8 @@ Obtains valid commands supported by the session. This API uses an asynchronous c
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Parameters**
| Name | Type | Mandatory| Description |
@@ -2478,6 +3393,7 @@ Obtains valid commands supported by the session. This API uses an asynchronous c
| callback | AsyncCallback\\> | Yes | Callback used to return a set of valid commands.|
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -2506,6 +3422,8 @@ Sends a control command to the session through the controller. This API uses a p
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Parameters**
| Name | Type | Mandatory| Description |
@@ -2519,6 +3437,7 @@ Sends a control command to the session through the controller. This API uses a p
| Promise | Promise used to return the result. If the command is sent, no value is returned; otherwise, an error object is returned.|
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -2559,6 +3478,8 @@ Sends a control command to the session through the controller. This API uses an
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Parameters**
| Name | Type | Mandatory| Description |
@@ -2567,6 +3488,7 @@ Sends a control command to the session through the controller. This API uses an
| callback | AsyncCallback | Yes | Callback used to return the result. If the command is sent, **err** is **undefined**; otherwise, **err** is an error object. |
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -2601,6 +3523,95 @@ controller.sendControlCommand(avCommand, function (err) {
});
```
+### sendCommonCommand10+
+
+sendCommonCommand(command: string, args: {[key: string]: Object}): Promise\
+
+Sends a custom control command to the session through the controller. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Multimedia.AVSession.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ------- | ------------------------------------- | ---- | ------------------------------ |
+| command | string | Yes | Name of the custom control command.|
+| args | {[key: string]: any} | Yes | Parameters in key-value pair format carried in the custom control command.|
+
+**Return value**
+
+| Type | Description |
+| -------------- | ----------------------------- |
+| Promise | Promise used to return the result. If the command is sent, no value is returned; otherwise, an error object is returned.|
+
+**Error codes**
+
+For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
+
+| ID| Error Message|
+| -------- | ---------------------------------------- |
+| 6600101 | Session service exception. |
+| 6600102 | The session does not exist. |
+| 6600103 | The session controller does not exist. |
+| 6600105 | Invalid session command. |
+| 6600106 | The session is not activated. |
+| 6600107 | Too many commands or events. |
+
+**Example**
+
+```js
+let commandName = "my_command";
+let args = {
+ command : "This is my command"
+}
+await controller.sendCommonCommand(commandName, args).catch((err) => {
+ console.info(`SendCommonCommand BusinessError: code: ${err.code}, message: ${err.message}`);
+})
+```
+
+### sendCommonCommand10+
+
+sendCommonCommand(command: string, args: {[key: string]: Object}, callback: AsyncCallback\): void
+
+Sends a custom control command to the session through the controller. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Multimedia.AVSession.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ------- | ------------------------------------- | ---- | ------------------------------ |
+| command | string | Yes | Name of the custom control command.|
+| args | {[key: string]: any} | Yes | Parameters in key-value pair format carried in the custom control command.|
+| callback | AsyncCallback | Yes | Callback used to return the result. If the command is sent, **err** is **undefined**; otherwise, **err** is an error object. |
+
+**Error codes**
+
+For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
+
+| ID| Error Message|
+| -------- | ------------------------------- |
+| 6600101 | Session service exception. |
+| 6600102 | The session does not exist. |
+| 6600103 | The session controller does not exist. |
+| 6600105 | Invalid session command. |
+| 6600106 | The session is not activated. |
+| 6600107 | Too many commands or events. |
+
+**Example**
+
+```js
+let commandName = "my_command";
+let args = {
+ command : "This is my command"
+}
+controller.sendCommonCommand(commandName, args, (err) => {
+ if(err) {
+ console.info(`SendCommonCommand BusinessError: code: ${err.code}, message: ${err.message}`);
+ }
+})
+```
+
### on('metadataChange')
on(type: 'metadataChange', filter: Array\ | 'all', callback: (data: AVMetadata) => void)
@@ -2609,6 +3620,8 @@ Subscribes to the metadata change event.
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Parameters**
| Name | Type | Mandatory| Description |
@@ -2618,6 +3631,7 @@ Subscribes to the metadata change event.
| callback | (data: [AVMetadata](#avmetadata)) => void | Yes | Callback used for subscription. The **data** parameter in the callback indicates the changed metadata. |
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -2646,6 +3660,8 @@ Subscribes to the playback state change event.
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Parameters**
| Name | Type | Mandatory| Description |
@@ -2655,6 +3671,7 @@ Subscribes to the playback state change event.
| callback | (state: [AVPlaybackState](#avplaybackstate)) => void | Yes | Callback used for subscription. The **state** parameter in the callback indicates the changed playback state. |
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -2675,6 +3692,108 @@ controller.on('playbackStateChange', playbackFilter, (playbackState) => {
});
```
+### on('sessionEvent')10+
+
+on(type: 'sessionEvent', callback: (sessionEvent: string, args: {[key:string]: Object}) => void): void
+
+Subscribes to session event changes.
+
+**System capability**: SystemCapability.Multimedia.AVSession.Core
+
+**System API**: This is a system API.
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
+| type | string | Yes | Event type. The event **'sessionEvent'** is reported when the session event changes.|
+| callback | (sessionEvent: string, args: {[key:string]: object}) => void | Yes | Callback used for subscription. **sessionEvent** in the callback indicates the name of the session event that changes, and **args** indicates the parameters carried in the event. |
+
+**Error codes**
+
+For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
+
+| ID| Error Message|
+| -------- | ------------------------------ |
+| 6600101 | Session service exception. |
+| 6600103 | The session controller does not exist. |
+
+**Example**
+
+```js
+controller.on('sessionEvent', (sessionEvent, args) => {
+ console.info(`OnSessionEvent, sessionEvent is ${sessionEvent}, args: ${JSON.stringify(args)}`);
+});
+```
+
+### on('queueItemsChange')10+
+
+on(type: 'queueItemsChange', callback: (items: Array<[AVQueueItem](#avqueueitem10)\>) => void): void
+
+Subscribes to playlist item changes.
+
+**System capability**: SystemCapability.Multimedia.AVSession.Core
+
+**System API**: This is a system API.
+
+**Parameters**
+
+| 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. The **items** parameter in the callback indicates the changed items in the playlist. |
+
+**Error codes**
+
+For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
+
+| ID| Error Message|
+| -------- | ------------------------------ |
+| 6600101 | Session service exception. |
+| 6600103 | The session controller does not exist. |
+
+**Example**
+
+```js
+controller.on('queueItemsChange', (items) => {
+ console.info(`OnQueueItemsChange, items length is ${items.length}`);
+});
+```
+
+### on('queueTitleChange')10+
+
+on(type: 'queueTitleChange', callback: (title: string) => void): void
+
+Subscribes to playlist name changes.
+
+**System capability**: SystemCapability.Multimedia.AVSession.Core
+
+**System API**: This is a system API.
+
+**Parameters**
+
+| 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. The **title** parameter in the callback indicates the changed playlist name. |
+
+**Error codes**
+
+For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
+
+| ID| Error Message|
+| -------- | ------------------------------ |
+| 6600101 | Session service exception. |
+| 6600103 | The session controller does not exist. |
+
+**Example**
+
+```js
+controller.on('queueTitleChange', (title) => {
+ console.info(`queueTitleChange, title is ${title}`);
+});
+```
+
### on('sessionDestroy')
on(type: 'sessionDestroy', callback: () => void)
@@ -2683,6 +3802,8 @@ Subscribes to the session destruction event.
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Parameters**
| Name | Type | Mandatory| Description |
@@ -2691,6 +3812,7 @@ Subscribes to the session destruction event.
| callback | () => void | Yes | Callback used for subscription. If the subscription is successful, **err** is **undefined**; otherwise, **err** is an error object. |
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -2714,6 +3836,8 @@ Subscribes to the session activation state change event.
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Parameters**
| Name | Type | Mandatory| Description |
@@ -2722,6 +3846,7 @@ Subscribes to the session activation state change event.
| callback | (isActive: boolean) => void | Yes | Callback used for subscription. The **isActive** parameter in the callback specifies whether the session is activated. The value **true** means that the service is activated, and **false** means the opposite. |
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -2745,6 +3870,8 @@ Subscribes to valid command changes.
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Parameters**
| Name | Type | Mandatory| Description |
@@ -2753,6 +3880,7 @@ Subscribes to valid command changes.
| callback | (commands: Array<[AVControlCommandType](#avcontrolcommandtype)\>) => void | Yes | Callback used for subscription. The **commands** parameter in the callback is a set of valid commands. |
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -2777,6 +3905,8 @@ Subscribes to output device changes.
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Parameters**
| Name | Type | Mandatory| Description |
@@ -2785,6 +3915,7 @@ Subscribes to output device changes.
| callback | (device: [OutputDeviceInfo](#outputdeviceinfo)) => void | Yes | Callback used for subscription. The **device** parameter in the callback indicates the output device information. |
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -2808,14 +3939,17 @@ Unsubscribes from metadata changes.
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------ | ---- | ------------------------------------------------------ |
| type | string | Yes | Event type. The event **'metadataChange'** is reported when the session metadata changes. |
-| callback | (data: [AVMetadata](#avmetadata)) => void | No | Callback used for subscription. The **data** parameter in the callback indicates the changed metadata.
The callback parameter is optional. If it is not specified, the specified event is no longer listened for all sessions. |
+| callback | (data: [AVMetadata](#avmetadata)) => void | No | Callback used for subscription. The **data** parameter in the callback indicates the changed metadata.
The **callback** parameter is optional. If it is not specified, all the subscriptions to the specified event are canceled for this session. |
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -2836,14 +3970,17 @@ Unsubscribes from playback state changes.
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------- |
| type | string | Yes | Event type. The event **'playbackStateChange'** is reported when the playback state changes. |
-| callback | (state: [AVPlaybackState](#avplaybackstate)) => void | No | Callback used for subscription. The **state** parameter in the callback indicates the changed playback state.
The callback parameter is optional. If it is not specified, the specified event is no longer listened for all sessions. |
+| callback | (state: [AVPlaybackState](#avplaybackstate)) => void | No | Callback used for subscription. The **state** parameter in the callback indicates the changed playback state.
The **callback** parameter is optional. If it is not specified, all the subscriptions to the specified event are canceled for this session. |
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -2856,6 +3993,99 @@ For details about the error codes, see [AVSession Management Error Codes](../err
controller.off('playbackStateChange');
```
+### off('sessionEvent')10+
+
+off(type: 'sessionEvent', callback?: (sessionEvent: string, args: {[key:string]: Obejct}) => void): void
+
+Unsubscribes from session event changes.
+
+**System capability**: SystemCapability.Multimedia.AVSession.Core
+
+**System API**: This is a system API.
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------- |
+| type | string | Yes | Event type. The value is fixed at **'sessionEvent'**. |
+| callback | (sessionEvent: string, args: {[key:string]: object}) => void | No | Callback used for unsubscription. **sessionEvent** in the callback indicates the name of the session event that changes, and **args** indicates the parameters carried in the event.
The **callback** parameter is optional. If it is not specified, all the subscriptions to the specified event are canceled for this session. |
+
+**Error codes**
+
+For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
+
+| ID| Error Message|
+| -------- | ---------------- |
+| 6600101 | Session service exception. |
+
+**Example**
+
+```js
+controller.off('sessionEvent');
+```
+
+### off('queueItemsChange')10+
+
+off(type: 'queueItemsChange', callback?: (items: Array<[AVQueueItem](#avqueueitem10)\>) => void): void
+
+Unsubscribes from playback item changes.
+
+**System capability**: SystemCapability.Multimedia.AVSession.Core
+
+**System API**: This is a system API.
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ---------------------------------------------------- | ---- | --------------------------------------------------------------------------------------------------- |
+| type | string | Yes | Event type. The value is fixed at **'queueItemsChange'**. |
+| callback | (items: Array<[AVQueueItem](#avqueueitem10)\>) => void | No | Callback used for unsubscription. The **items** parameter in the callback indicates the changed items in the playback.
The **callback** parameter is optional. If it is not specified, all the subscriptions to the specified event are canceled for this session.|
+
+**Error codes**
+
+For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
+
+| ID| Error Message|
+| -------- | ---------------- |
+| 6600101 | Session service exception. |
+
+**Example**
+
+```js
+controller.off('queueItemsChange');
+```
+
+### off('queueTitleChange')10+
+
+off(type: 'queueTitleChange', callback?: (title: string) => void): void
+
+Unsubscribes from playlist name changes.
+
+**System capability**: SystemCapability.Multimedia.AVSession.Core
+
+**System API**: This is a system API.
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ----------------------- | ---- | ------------------------------------------------------------------------------------------------------- |
+| type | string | Yes | Event type. The value is fixed at **'queueTitleChange'**. |
+| callback | (title: string) => void | No | Callback used for unsubscription. The **items** parameter in the callback indicates the changed playlist name.
The **callback** parameter is optional. If it is not specified, all the subscriptions to the specified event are canceled for this session.|
+
+**Error codes**
+
+For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
+
+| ID| Error Message|
+| -------- | ---------------- |
+| 6600101 | Session service exception. |
+
+**Example**
+
+```js
+controller.off('queueTitleChange');
+```
+
### off('sessionDestroy')
off(type: 'sessionDestroy', callback?: () => void)
@@ -2864,14 +4094,17 @@ Unsubscribes from the session destruction event.
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------- | ---- | ----------------------------------------------------- |
| type | string | Yes | Event type. The event **'sessionDestroy'** is reported when the session is destroyed. |
-| callback | () => void | No | Callback used for unsubscription. If the unsubscription is successful, **err** is **undefined**; otherwise, **err** is an error object.
The callback parameter is optional. If it is not specified, the specified event is no longer listened for all sessions. |
+| callback | () => void | No | Callback used for unsubscription. If the unsubscription is successful, **err** is **undefined**; otherwise, **err** is an error object.
The **callback** parameter is optional. If it is not specified, all the subscriptions to the specified event are canceled for this session. |
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -2892,14 +4125,17 @@ Unsubscribes from session activation state changes.
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | ----------------------------------------------------- |
| type | string | Yes | Event type. The event **'activeStateChange'** is reported when the session activation state changes. |
-| callback | (isActive: boolean) => void | No | Callback used for unsubscription. The **isActive** parameter in the callback specifies whether the session is activated. The value **true** means that the session is activated, and **false** means the opposite.
The callback parameter is optional. If it is not specified, the specified event is no longer listened for all sessions. |
+| callback | (isActive: boolean) => void | No | Callback used for unsubscription. The **isActive** parameter in the callback specifies whether the session is activated. The value **true** means that the session is activated, and **false** means the opposite.
The **callback** parameter is optional. If it is not specified, all the subscriptions to the specified event are canceled for this session. |
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -2920,14 +4156,17 @@ Unsubscribes from valid command changes.
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | -------------------------------------------------------- |
| type | string | Yes | Event type. The event **'validCommandChange'** is reported when the supported commands change. |
-| callback | (commands: Array<[AVControlCommandType](#avcontrolcommandtype)\>) => void | No | Callback used for unsubscription. The **commands** parameter in the command is a set of valid commands.
The callback parameter is optional. If it is not specified, the specified event is no longer listened for all sessions. |
+| callback | (commands: Array<[AVControlCommandType](#avcontrolcommandtype)\>) => void | No | Callback used for unsubscription. The **commands** parameter in the callback is a set of valid commands.
The **callback** parameter is optional. If it is not specified, all the subscriptions to the specified event are canceled for this session. |
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message |
@@ -2948,14 +4187,17 @@ Unsubscribes from output device changes.
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------ |
| type | string | Yes | Event type. The event **'outputDeviceChange'** is reported when the output device changes. |
-| callback | (device: [OutputDeviceInfo](#outputdeviceinfo)) => void | No | Callback used for unsubscription. The **device** parameter in the callback indicates the output device information.
The callback parameter is optional. If it is not specified, the specified event is no longer listened for all sessions. |
+| callback | (device: [OutputDeviceInfo](#outputdeviceinfo)) => void | No | Callback used for unsubscription. The **device** parameter in the callback indicates the output device information.
The **callback** parameter is optional. If it is not specified, all the subscriptions to the specified event are canceled for this session. |
**Error codes**
+
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID | Error Message |
@@ -2989,6 +4231,8 @@ Enumerates the session types supported by the session.
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
| Name | Type | Description|
| ----- | ------ | ---- |
| audio | string | Audio session.|
@@ -3018,6 +4262,8 @@ Enumerates the commands that can be sent to a session.
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
| Name | Type | Description |
| -------------- | ------ | ------------ |
| play | string | Play the media. |
@@ -3038,6 +4284,8 @@ Describes the command that can be sent to the session.
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
| Name | Type | Mandatory| Description |
| --------- | ------------------------------------------------- | ---- | -------------- |
| command | [AVControlCommandType](#avcontrolcommandtype) | Yes | Command. |
@@ -3049,6 +4297,8 @@ Describes the media metadata.
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
| Name | Type | Mandatory| Description |
| --------------- |-------------------------| ---- |---------------------------------------------------------------------|
| assetId | string | Yes | Media ID. |
@@ -3067,12 +4317,42 @@ Describes the media metadata.
| previousAssetId | string | No | ID of the previous media asset. |
| nextAssetId | string | No | ID of the next media asset. |
+## AVMediaDescription10+
+
+Describes the attributes related to the media metadata of the playlist.
+
+**System capability**: SystemCapability.Multimedia.AVSession.Core
+
+| Name | Type | Mandatory | Description |
+| ------------ | ----------------------- | ---- | ----------------------- |
+| mediaId | string | Yes | Media ID of the playlist. |
+| title | string | No | Name of the playlist. |
+| subtitle | string | No | Subname of the playlist. |
+| description | string | No | Description of the playlist. |
+| icon | image.PixelMap | No | Pixel map of the image of the playlist.|
+| iconUri | string | No | Path of the image of the playlist.|
+| extras | {[key: string]: any} | No | Additional fields of the playlist. |
+| mediaUri | string | No | Media URI. |
+
+## AVQueueItem10+
+
+Describes the attributes of an item in the playlist.
+
+**System capability**: SystemCapability.Multimedia.AVSession.Core
+
+| Name | Type | Mandatory| Description |
+| ------------ | ------------------------------------------ | ---- | --------------------------- |
+| itemId | number | Yes | ID of an item in the playlist. |
+| description | [AVMediaDescription](#avmediadescription10) | Yes | Media metadata of the item in the playlist. |
+
## AVPlaybackState
Describes the information related to the media playback state.
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
| Name | Type | Mandatory| Description |
| ------------ | ------------------------------------- | ---- | ------- |
| state | [PlaybackState](#playbackstate) | No | Playback state.|
@@ -3088,6 +4368,8 @@ Describes the information related to the playback position.
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
| Name | Type | Mandatory| Description |
| ----------- | ------ | ---- | ------------------ |
| elapsedTime | number | Yes | Elapsed time, in ms.|
@@ -3099,6 +4381,8 @@ Describes the information related to the output device.
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
| Name | Type | Mandatory| Description |
| ---------- | -------------- | ---- | ---------------------- |
| isRemote | boolean | Yes | Whether the device is connected. |
@@ -3111,6 +4395,8 @@ Enumerates the media playback states.
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
| Name | Value | Description |
| --------------------------- | ---- | ----------- |
| PLAYBACK_STATE_INITIAL | 0 | Initial. |
@@ -3128,6 +4414,8 @@ Enumerates the loop modes of media playback.
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
| Name | Value | Description |
| ------------------ | ---- | -------- |
| LOOP_MODE_SEQUENCE | 0 | Sequential playback.|
@@ -3141,6 +4429,8 @@ Enumerates the error codes used in the media session.
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
| Name | Value | Description |
| ------------------------------ | ------- | ------------------------------- |
| ERR_CODE_SERVICE_EXCEPTION | 6600101 | Session service exception. |
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-battery-info.md b/en/application-dev/reference/apis/js-apis-battery-info.md
index 6231cab50066c32fcbed5bfaf11def7838b0329e..4e4a654f4f314d0447c3cf5bd32c6f7f550affc8 100644
--- a/en/application-dev/reference/apis/js-apis-battery-info.md
+++ b/en/application-dev/reference/apis/js-apis-battery-info.md
@@ -30,10 +30,10 @@ Describes battery information.
| batteryTemperature | number | Yes | No | Battery temperature of the device, in unit of 0.1°C. |
| isBatteryPresent7+ | boolean | Yes | No | Whether the battery is supported or present. |
| batteryCapacityLevel9+ | [BatteryCapacityLevel](#batterycapacitylevel9) | Yes | No | Battery level of the device. |
-| estimatedRemainingChargeTime9+ | number | Yes | No | Estimated time for fully charging the current device, in unit of milliseconds. **System API**: This is a system API. |
-| totalEnergy9+ | number | Yes | No | Total battery capacity of the device, in unit of mAh. **System API**: This is a system API. |
-| nowCurrent9+ | number | Yes | No | Battery current of the device, in unit of mA. **System API**: This is a system API. |
-| remainingEnergy9+ | number | Yes | No | Remaining battery capacity of the device, in unit of mAh. **System API**: This is a system API.|
+| estimatedRemainingChargeTime9+ | number | Yes | No | Estimated time for fully charging the current device, in unit of milliseconds. This is a system API. |
+| totalEnergy9+ | number | Yes | No | Total battery capacity of the device, in unit of mAh. This is a system API. |
+| nowCurrent9+ | number | Yes | No | Battery current of the device, in unit of mA. This is a system API. |
+| remainingEnergy9+ | number | Yes | No | Remaining battery capacity of the device, in unit of mAh. This is a system API.|
## BatteryPluggedType
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-applicationInfo.md b/en/application-dev/reference/apis/js-apis-bundleManager-applicationInfo.md
index 2537274b8d5bd50d6c47258be2770bd5d51a9733..8997e94099071ce9b4e806f06b008477352af187 100644
--- a/en/application-dev/reference/apis/js-apis-bundleManager-applicationInfo.md
+++ b/en/application-dev/reference/apis/js-apis-bundleManager-applicationInfo.md
@@ -9,16 +9,15 @@ The **ApplicationInfo** module defines the application information. A system app
## ApplicationInfo
**System capability**: SystemCapability.BundleManager.BundleFramework.Core
-
| Name | Type | Readable| Writable| Description |
| -------------------------- | ------------------------------------------------------------ | ---- | ---- | ------------------------------------------------------------ |
| name | string | Yes | No | Application name. |
-| description | string | Yes | No | Application description. |
+| description | string | Yes | No | Description of the application, for example, "description": $string: mainability_description". |
| descriptionId | number | Yes | No | ID of the application description. |
| enabled | boolean | Yes | No | Whether the application is enabled. The default value is **true**. |
-| label | string | Yes | No | Application label. |
+| label | string | Yes | No | Application name, for example, "label": "$string: mainability_description".|
| labelId | number | Yes | No | ID of the application label. |
-| icon | string | Yes | No | Application icon. |
+| icon | string | Yes | No | Application icon, for example, "icon": "$media:icon". |
| iconId | number | Yes | No | ID of the application icon. |
| process | string | Yes | No | Process in which the application runs. If this parameter is not set, the bundle name is used. |
| permissions | Array\ | Yes | No | Permissions required for accessing the application. The permissions can be obtained by passing in **GET_APPLICATION_INFO_WITH_PERMISSION** to the **appFlags** parameter of [bundleManager.getApplicationInfo](js-apis-bundleManager.md#bundlemanagergetapplicationinfo).|
@@ -27,9 +26,9 @@ The **ApplicationInfo** module defines the application information. A system app
| removable | boolean | Yes | No | Whether the application is removable. |
| accessTokenId | number | Yes | No | Access token ID of the application. |
| uid | number | Yes | No | UID of the application. |
-| iconResource | [Resource](js-apis-resource-manager.md#resource9) | Yes| No| Icon resource of the application. |
-| labelResource | [Resource](js-apis-resource-manager.md#resource9) | Yes| No| Label resource of the application. |
-| descriptionResource | [Resource](js-apis-resource-manager.md#resource9) | Yes| No| Description resource of the application. |
+| iconResource | [Resource](js-apis-resource-manager.md#resource9) | Yes| No| Resource information of the application icon. The resource information obtained contains the bundle name, module name, and ID of the resource. You can call **getMediaContent** in [@ohos.resourceManager.d.ts](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.resourceManager.d.ts) to obtain the resource details. |
+| labelResource | [Resource](js-apis-resource-manager.md#resource9) | Yes| No| Resource information of the application label. The resource information obtained contains the bundle name, module name, and ID of the resource. You can call **getMediaContent** in [@ohos.resourceManager.d.ts](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.resourceManager.d.ts) to obtain the resource details. |
+| descriptionResource | [Resource](js-apis-resource-manager.md#resource9) | Yes| No| Resource information of the application description. The resource information obtained contains the bundle name, module name, and ID of the resource. You can call **getMediaContent** in [@ohos.resourceManager.d.ts](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.resourceManager.d.ts) to obtain the resource details.|
| 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. |
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.md b/en/application-dev/reference/apis/js-apis-bundleManager.md
index a346a61081df95cc18e35898c07674db7bd3f318..1503f821c413923f28e11a31a77c5cd2eb07c101 100644
--- a/en/application-dev/reference/apis/js-apis-bundleManager.md
+++ b/en/application-dev/reference/apis/js-apis-bundleManager.md
@@ -2215,7 +2215,7 @@ try {
### bundleManager.getProfileByAbility
-getProfileByAbility(moduleName: string, abilityName: string, metadataName: string, callback: AsyncCallback>): void;
+getProfileByAbility(moduleName: string, abilityName: string, metadataName: string, callback: AsyncCallback\\>): void;
Obtains the JSON strings of the configuration file based on the given module ame, ability name, and metadata name. This API uses an asynchronous callback to return the result.
@@ -2266,7 +2266,7 @@ try {
### bundleManager.getProfileByAbility
-getProfileByAbility(moduleName: string, abilityName: string, metadataName?: string): Promise>;
+getProfileByAbility(moduleName: string, abilityName: string, metadataName?: string): Promise\\>;
Obtains the JSON strings of the configuration file based on the given module ame, ability name, and metadata name. This API uses a promise to return the result.
@@ -2336,7 +2336,7 @@ try {
### bundleManager.getProfileByExtensionAbility
-getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, metadataName: string, callback: AsyncCallback>): void;
+getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, metadataName: string, callback: AsyncCallback\\>): void;
Obtains the JSON strings of the configuration file based on the given module ame, Extension ability name, and metadata name. This API uses an asynchronous callback to return the result.
@@ -2386,7 +2386,7 @@ try {
### bundleManager.getProfileByExtensionAbility
-getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, metadataName?: string): Promise>;
+getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, metadataName?: string): Promise\\>;
Obtains the JSON strings of the configuration file based on the given module ame, Extension ability name, and metadata name. This API uses a promise to return the result.
@@ -2659,7 +2659,6 @@ try {
### bundleManager.getApplicationInfoSync
getApplicationInfoSync(bundleName: string, applicationFlags: number, userId: number) : [ApplicationInfo](js-apis-bundleManager-applicationInfo.md);
-getApplicationInfoSync(bundleName: string, applicationFlags: number) : [ApplicationInfo](js-apis-bundleManager-applicationInfo.md);
Synchronously obtains the application information based on the given bundle name, application flags, and user ID.
@@ -2710,6 +2709,42 @@ try {
}
```
+### bundleManager.getApplicationInfoSync
+
+getApplicationInfoSync(bundleName: string, applicationFlags: number) : [ApplicationInfo](js-apis-bundleManager-applicationInfo.md);
+
+Synchronously obtains the application information based on the given bundle name and application flags.
+
+**System API**: This is a system API.
+
+**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
+
+**System capability**: SystemCapability.BundleManager.BundleFramework.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ---------------- | -------------------------- | ---- | ----------------------------------------------------- |
+| bundleName | string | Yes | Bundle name. |
+| applicationFlags | [number](#applicationflag) | Yes | Type of the application information to obtain.|
+
+**Return value**
+
+| Type | Description |
+| ----------------------------------------------------------- | ------------------------- |
+| [ApplicationInfo](js-apis-bundleManager-applicationInfo.md) | Application 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. |
+| 17700026 | The specified bundle is disabled. |
+
+**Example**
+
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
@@ -2727,7 +2762,6 @@ try {
### bundleManager.getBundleInfoSync
getBundleInfoSync(bundleName: string, bundleFlags: [number](#bundleflag), userId: number): [BundleInfo](js-apis-bundleManager-bundleInfo.md);
-getBundleInfoSync(bundleName: string, bundleFlags: [number](#bundleflag)): [BundleInfo](js-apis-bundleManager-bundleInfo.md);
Synchronously obtains the bundle information based on the given bundle name, bundle flags, and user ID.
@@ -2743,7 +2777,7 @@ Synchronously obtains the bundle information based on the given bundle name, bun
| ----------- | ------ | ---- | -------------------------------------------------------- |
| bundleName | string | Yes | Bundle name. |
| bundleFlags | [number](#bundleflag) | Yes | Type of the bundle information to obtain.|
-| userId | number | No | User ID. |
+| userId | number | Yes | User ID. |
**Return value**
@@ -2778,6 +2812,42 @@ try {
}
```
+### bundleManager.getBundleInfoSync
+
+getBundleInfoSync(bundleName: string, bundleFlags: [number](#bundleflag)): [BundleInfo](js-apis-bundleManager-bundleInfo.md);
+
+Synchronously obtains the bundle information based on the given bundle name and bundle flags.
+
+**System API**: This is a system API.
+
+**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
+
+**System capability**: SystemCapability.BundleManager.BundleFramework.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ----------- | --------------------- | ---- | ------------------------------------------------------ |
+| bundleName | string | Yes | Bundle name. |
+| bundleFlags | [number](#bundleflag) | Yes | Type of the bundle information to obtain.|
+
+**Return value**
+
+| Type | Description |
+| ------------------------------------------------- | -------------------- |
+| [BundleInfo](js-apis-bundleManager-bundleInfo.md) | 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. |
+| 17700026 | The specified bundle is disabled. |
+
+**Example**
+
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
@@ -2790,3 +2860,37 @@ try {
hilog.error(0x0000, 'testTag', 'getBundleInfoSync failed: %{public}s', err.message);
}
```
+
+## 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.|
+
+## AtomicServiceModuleType
+
+Enumerates the module types of an atomic service.
+
+ **System capability**: SystemCapability.BundleManager.BundleFramework.Core
+
+| Name | Value | Description |
+| ------ | ---- | --------------------------- |
+| NORMAL | 0 | Page package in the atomic service. |
+| MAIN | 1 | Landing page package in the atomic service.|
diff --git a/en/application-dev/reference/apis/js-apis-bundleMonitor.md b/en/application-dev/reference/apis/js-apis-bundleMonitor.md
index 11f54832d6556e24f35cd1baedee0d9abfe39079..bf20a7708d16aa7a8f8daeb7f43c8f5fb60580c3 100644
--- a/en/application-dev/reference/apis/js-apis-bundleMonitor.md
+++ b/en/application-dev/reference/apis/js-apis-bundleMonitor.md
@@ -16,7 +16,7 @@ import bundleMonitor from '@ohos.bundle.bundleMonitor';
| Permission | Permission Level | Description |
| ------------------------------------ | ----------- | ------------------------------ |
-| ohos.permission.LISTEN_BUNDLE_CHANGE | system_core | Permission to listen for bundle installation, uninstall, and updates.|
+| ohos.permission.LISTEN_BUNDLE_CHANGE | system_basic | Permission to listen for bundle installation, uninstall, and updates.|
For details, see [Permission Levels](../../security/accesstoken-overview.md).
@@ -33,7 +33,7 @@ For details, see [Permission Levels](../../security/accesstoken-overview.md).
## bundleMonitor.on
-on(type: BundleChangedEvent, callback: callback\): void;
+on(type: BundleChangedEvent, callback: Callback\): void;
Subscribes to bundle installation, uninstall, and update events.
@@ -66,7 +66,7 @@ try {
## bundleMonitor.off
-off(type: BundleChangedEvent, callback?: callback\): void;
+off(type: BundleChangedEvent, callback?: Callback\