diff --git a/en/application-dev/application-models/Readme-EN.md b/en/application-dev/application-models/Readme-EN.md
index 65f2b4c16ea42ecdf37082a5a9f8e26eb20dd6e6..79230cf32f010ee568575817643996f15b0bf007 100644
--- a/en/application-dev/application-models/Readme-EN.md
+++ b/en/application-dev/application-models/Readme-EN.md
@@ -17,11 +17,10 @@
- ExtensionAbility Component
- [ExtensionAbility Component Overview](extensionability-overview.md)
- [ServiceExtensionAbility](serviceextensionability.md)
- - [DataShareExtensionAbility (for System Applications Only)](datashareextensionability.md)
- [AccessibilityExtensionAbility](accessibilityextensionability.md)
- [EnterpriseAdminExtensionAbility](enterprise-extensionAbility.md)
- [InputMethodExtensionAbility](inputmethodextentionability.md)
- - [WindowExtensionAbility](windowextensionability.md)
+ - [WindowExtensionAbility (for System Applications Only)](windowextensionability.md)
- Service Widget Development in Stage Model
- [Service Widget Overview](service-widget-overview.md)
- Developing an ArkTS Widget
@@ -37,9 +36,9 @@
- [Applying Custom Drawing in the Widget](arkts-ui-widget-page-custom-drawing.md)
- Widget Event Development
- [Widget Event Capability Overview](arkts-ui-widget-event-overview.md)
+ - [Redirecting to a Specified Page Through the Router Event](arkts-ui-widget-event-router.md)
- [Updating Widget Content Through FormExtensionAbility](arkts-ui-widget-event-formextensionability.md)
- [Updating Widget Content Through UIAbility](arkts-ui-widget-event-uiability.md)
- - [Redirecting to a Specified Page Through the Router Event](arkts-ui-widget-event-router.md)
- Widget Data Interaction
- [Widget Data Interaction Overview](arkts-ui-widget-interaction-overview.md)
- [Configuring a Widget to Update Periodically](arkts-ui-widget-update-by-time.md)
@@ -53,7 +52,7 @@
- [Want Overview](want-overview.md)
- [Matching Rules of Explicit Want and Implicit Want](explicit-implicit-want-mappings.md)
- [Common action and entities Values](actions-entities.md)
- - [Using Explicit Want to Start an Ability](ability-startup-with-explicit-want.md)
+ - [Using Explicit Want to Start an Application Component](ability-startup-with-explicit-want.md)
- [Using Implicit Want to Open a Website](ability-startup-with-implicit-want.md)
- [Using Want to Share Data Between Applications](data-share-via-want.md)
- [Component Startup Rules](component-startup-rules.md)
@@ -62,8 +61,8 @@
- [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)
+ - Process Model
+ - [Process Model Overview](process-model-stage.md)
- Common Events
- [Introduction to Common Events](common-event-overview.md)
- Common Event Subscription
@@ -72,15 +71,15 @@
- [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)
- - [Removing Sticky Common Events](common-event-remove-sticky.md)
+ - [Removing Sticky Common Events (for System Applications Only)](common-event-remove-sticky.md)
- [Background Services](background-services.md)
- - Inter-Thread Communication
- - [Thread Model](thread-model-stage.md)
+ - Thread Model
+ - [Thread Model Overview](thread-model-stage.md)
- [Using Emitter for Inter-Thread Communication](itc-with-emitter.md)
- [Using Worker for Inter-Thread Communication](itc-with-worker.md)
- Mission Management
- [Mission Management Scenarios](mission-management-overview.md)
- - [Mission Management and Launch Type](mission-management-launch-type.md)
+ - [Mission 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)
@@ -120,12 +119,12 @@
- [Context](application-context-fa.md)
- [Want](want-fa.md)
- [Component Startup Rules](component-startup-rules-fa.md)
- - IPC
- - [Process Model](process-model-fa.md)
+ - Process Model
+ - [Process Model Overview](process-model-fa.md)
- [Common Events](common-event-fa.md)
- [Background Services](rpc.md)
- - Inter-Thread Communication
- - [Thread Model](thread-model-fa.md)
+ - Thread Model
+ - [Thread Model Overview](thread-model-fa.md)
- [Inter-Thread Communication](itc-fa-overview.md)
- [Mission Management](mission-management-fa.md)
- [Application Configuration File](config-file-fa.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 6b61b06311a519e959e87d826e4a27c8b2b3d208..36d41c555bd8d4a5cd0d4d0b7bd291bb2569cee3 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,4 @@
-# Using Explicit Want to Start an Ability
+# Using Explicit Want to Start an Application Component
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.
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 dbd65bb560d7531bb6e00b21c004815fda1a997c..7d92fbccbd1ebb49dc2a89de0ea825a1e2a8c873 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
@@ -5,21 +5,21 @@ This section uses the operation of using a browser to open a website as an examp
```json
{
"module": {
- // ...
+ ...
"abilities": [
{
- // ...
+ ...
"skills": [
{
"entities": [
"entity.system.home",
"entity.system.browsable"
- // ...
+ ...
],
"actions": [
"action.system.home",
"ohos.want.action.viewData"
- // ...
+ ...
],
"uris": [
{
@@ -31,9 +31,9 @@ This section uses the operation of using a browser to open a website as an examp
},
{
"scheme": "http",
- // ...
+ ...
}
- // ...
+ ...
]
}
]
@@ -59,19 +59,18 @@ function implicitStartAbility() {
'uri': 'https://www.test.com:8080/query/student'
}
context.startAbility(wantInfo).then(() => {
- // ...
+ ...
}).catch((err) => {
- // ...
+ ...
})
}
```
The matching process is as follows:
-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.
+1. If **action** in the passed **want** parameter is specified and is included in **actions** under **skills** of the application component 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 application component to match, the matching is successful.
+3. If **uri** in the passed **want** parameter is included in **uris** under **skills** of the application component to match, which is concatenated into https://www.test.com:8080/query* (where * is a wildcard), the matching is successful.
If there are multiple matching applications, the system displays a dialog box for you to select one of them. The following figure shows an example.
diff --git a/en/application-dev/application-models/abilitystage.md b/en/application-dev/application-models/abilitystage.md
index 769c6b4540856a553ca30f02c0a689e1c32f2307..da764a445a6d1a79a601719f069798191641a986 100644
--- a/en/application-dev/application-models/abilitystage.md
+++ b/en/application-dev/application-models/abilitystage.md
@@ -24,7 +24,7 @@ AbilityStage is not automatically generated in the default project of DevEco Stu
// When the HAP of the application is loaded for the first time, initialize the module.
}
onAcceptWant(want) {
- // Triggered only for the ability with the specified launch type.
+ // Triggered only for the UIAbility with the specified launch type.
return "MyAbilityStage";
}
}
@@ -37,7 +37,7 @@ AbilityStage is not automatically generated in the default project of DevEco Stu
"name": "entry",
"type": "entry",
"srcEntry": "./ets/myabilitystage/MyAbilityStage.ts",
- // ...
+ ...
}
}
```
diff --git a/en/application-dev/application-models/actions-entities.md b/en/application-dev/application-models/actions-entities.md
index 5c5aed302c6f8f570238fac6bd73c263840244d6..38119a1b1fe16067f7e89629811327ad079a5d15 100644
--- a/en/application-dev/application-models/actions-entities.md
+++ b/en/application-dev/application-models/actions-entities.md
@@ -1,9 +1,8 @@
# Common action and entities Values
-**action**: Action to take, such as viewing, sharing, and application details, by the caller. In implicit Want, you can define this field and use it together with **uri** or **parameters** to specify the operation to be performed on the data, for example, viewing URI data. For example, if the URI is a website and the action is **ohos.want.action.viewData**, the ability that supports website viewing is matched. Declaring the **action** field in Want indicates that the invoked application should support the declared operation. The **actions** field under **skills** in the configuration file indicates the operations supported by the application.
+The **action** field specifies the common operation (such as viewing, sharing, and application details) to be performed by the caller. In implicit [Want](../reference/apis/js-apis-app-ability-want.md), you can define this field and use it together with **uri** or **parameters** to specify the operation to be performed on the data, for example, viewing URI data. For example, if the URI is a website and the action is **ohos.want.action.viewData**, the application component that supports website viewing is matched. Declaring the **action** field in [Want](../reference/apis/js-apis-app-ability-want.md) indicates that the invoked application is expected to support the declared operation. The **actions** field under **skills** in the configuration file indicates the operations supported by the application.
-
-**Common action Values**
+The following **action** values are available:
- **ACTION_HOME**: action of starting the application entry component. It must be used together with **ENTITY_HOME**. The application icon on the home screen is an explicit entry component. Users can touch the icon to start the entry component. Multiple entry components can be configured for an application.
@@ -14,14 +13,13 @@
- **ACTION_VIEW_MULTIPLE_DATA**: action of launching the UI for sending multiple data records.
-**entities**: Category information (such as browser and video player) of the target ability. It is a supplement to **action** in implicit Want. You can define this field to filter application categories, for example, browser. Declaring the **entities** field in Want indicates that the invoked application should belong to the declared category. The **entities** field under **skills** in the configuration file indicates the categories supported by the application.
-
+The **entities** field specify the category information (such as browser and video player) of the target application component. It is a supplement to **action** in implicit Want. You can define this field to filter application categories, for example, browser. Declaring the **entities** field in Want indicates that the invoked application should belong to the declared category. The **entities** field under **skills** in the configuration file indicates the categories supported by the application.
-**Common entities Values**
+The following **entities** values are available:
- **ENTITY_DEFAULT**: default category, which is meaningless.
-- **ENTITY_HOME**: abilities with an icon displayed on the home screen.
+- **ENTITY_HOME**: application components with an icon displayed on the home screen.
- **ENTITY_BROWSABLE**: browser type.
diff --git a/en/application-dev/application-models/app-deviceconfig-switch.md b/en/application-dev/application-models/app-deviceconfig-switch.md
index 1092c21081cd9a8d62c92a1a68ba434efee7c8c9..6c872f0c167bd4779516d611ee07d9036ca550ee 100644
--- a/en/application-dev/application-models/app-deviceconfig-switch.md
+++ b/en/application-dev/application-models/app-deviceconfig-switch.md
@@ -22,7 +22,7 @@ OpenHarmony has reconstructed the [deviceConfig](../quick-start/deviceconfig-str
| deviceConfig in the FA Model| Description| Stage Model| Difference|
| -------- | -------- | -------- | -------- |
| deviceConfig| Device information.| / | This tag is no longer available in the stage model. In the stage model, device information is configured under the **app** tag.|
-| 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.| / | The stage model does not support the configuration of process names.|
+| process | Name of the process running the application or UIAbility. If the **process** attribute is configured in the **deviceConfig** tag, all UIAbilities of the application run in this process. You can set the **process** attribute for a specific UIAbility in the **abilities** attribute, so that the UIAbility can run in the particular process.| / | The stage model does not support the configuration of process names.|
| keepAlive | Whether the application is always running. This attribute applies only to system applications and does not take effect for third-party applications.| / | The stage model does not support changing of the model control mode for system applications.|
| supportBackup | Whether the application supports data backup and restore.| / | This configuration is not supported in the stage model.|
| compressNativeLibs | Whether the **libs** libraries are packaged in the HAP file after being compressed.| / | This configuration is not supported in the stage model.|
diff --git a/en/application-dev/application-models/application-component-configuration-fa.md b/en/application-dev/application-models/application-component-configuration-fa.md
index 4cc1c9ad6831f0e54ae4c70f4f7229a7abc7c62f..336ad698d0f2298045b00fe0af1563574bccfd24 100644
--- a/en/application-dev/application-models/application-component-configuration-fa.md
+++ b/en/application-dev/application-models/application-component-configuration-fa.md
@@ -22,7 +22,7 @@ When developing an application, you may need to configure certain tags to identi
"actions": ["action.system.home"]
}
]
- // ...
+ ...
}
```
diff --git a/en/application-dev/application-models/application-component-configuration-stage.md b/en/application-dev/application-models/application-component-configuration-stage.md
index bcf9b095464ba0110c35be9cfef44b078a091ffb..b50d40b4a694ecdf55338d249a20ff458d36ba20 100644
--- a/en/application-dev/application-models/application-component-configuration-stage.md
+++ b/en/application-dev/application-models/application-component-configuration-stage.md
@@ -1,10 +1,12 @@
# Application- or Component-Level Configuration (Stage Model)
+When developing an application, you may need to configure certain tags to identify the application, such as the bundle name and application icon. This topic describes key tags that need to be configured during application development.
-When developing an application, you may need to configure certain tags to identify the application, such as the bundle name and application icon. This topic describes key tags that need to be configured during application development. Icons and labels are usually configured together. There is the application icon, application label, entry icon, and entry label, which correspond to the **icon** and **label** fields in the [app.json5 file](../quick-start/app-configuration-file.md) and [module.json5 file](../quick-start/module-configuration-file.md). The application icon and label are used in **Settings**. For example, they are displayed in the application list in **Settings**. The entry icon is displayed on the device's home screen after the application is installed. The entry icon maps to a [UIAbility](uiability-overview.md) component. Therefore, an application can have multiple entry icons and labels. When you touch one of them, the corresponding UIAbility page is displayed.
+Icons and labels are usually configured together. There is the application icon, application label, entry icon, and entry label, which correspond to the **icon** and **label** fields in the [app.json5 file](../quick-start/app-configuration-file.md) and [module.json5 file](../quick-start/module-configuration-file.md).
+The application icon and label are used in **Settings**. For example, they are displayed in the application list in **Settings**. The entry icon is displayed on the device's home screen after the application is installed. The entry icon maps to a [UIAbility](uiability-overview.md) component. Therefore, an application can have multiple entry icons and entry labels. When you touch one of them, the corresponding UIAbility page is displayed.
- **Figure 1** Icons and labels
+**Figure 1** Icons and labels
![application-component-configuration-stage](figures/application-component-configuration-stage.png)
@@ -22,13 +24,13 @@ When developing an application, you may need to configure certain tags to identi
The application label is specified by the **label** field in the [app.json5 file](../quick-start/app-configuration-file.md) in the **AppScope** module of the project. The **label** field specifies the application name displayed to users. It must be set to the index of a string resource.
```json
- {
- "app": {
- "icon": "$media:app_icon",
- "label": "$string:app_name"
- // ...
- }
+ {
+ "app": {
+ "icon": "$media:app_icon",
+ "label": "$string:app_name"
+ ...
}
+ }
```
- **Configuring the entry icon and label**
@@ -40,7 +42,7 @@ When developing an application, you may need to configure certain tags to identi
```json
{
"module": {
- // ...
+ ...
"abilities": [
{
// The information starting with $ is the resource value.
@@ -61,6 +63,35 @@ When developing an application, you may need to configure certain tags to identi
}
}
```
+ OpenHarmony strictly controls applications without icons to prevent malicious applications from deliberately configuring no icon to block uninstall attempts.
+
+ 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). The rules for displaying the entry icon and entry label are as follows:
+
+ 1. The HAP file contains UIAbility configuration.
+ * An entry icon is set in the **abilities** field of the **module.json5** file.
+ * The application does not have the privilege to hide its icon from the home screen.
+ * The system uses the icon configured for the UIAbility as the entry icon and displays it on the home screen. Touching this icon will direct the user to the home page of the UIAbility.
+ * The system uses the label configured for the UIAbility as the entry label and displays it on the home screen. If no label is configured, the system uses the label specified in the **app.json5** file as the entry label and displays it on the home screen.
+ * The application has the privilege to hide its icon from the home screen.
+ * The application information is not returned when the home screen queries the information, and the entry icon and label of the application are not displayed on the home screen.
+ * No entry icon is set in the **abilities** field of the **module.json5** file.
+ * The application does not have the privilege to hide its icon from the home screen.
+ * The system uses the icon specified in the **app.json5** file as the entry icon and displays it on the home screen. Touching this icon will direct the user to the application details page, as shown below.
+ * The system uses the label specified in the **app.json5** file as the entry label and displays it on the home screen.
+ * The application has the privilege to hide its icon from the home screen.
+ * The application information is not returned when the home screen queries the information, and the entry icon and label of the application are not displayed on the home screen.
+
+ 2. The HAP file does not contain UIAbility configuration.
+ * The application does not have the privilege to hide its icon from the home screen.
+ * The system uses the icon specified in the **app.json5** file as the entry icon and displays it on the home screen. Touching this icon will direct the user to the application details page, as shown below.
+ * The system uses the label specified in the **app.json5** file as the entry label and displays it on the home screen.
+ * The application has the privilege to hide its icon from the home screen.
+ * The application information is not returned when the home screen queries the information, and the entry icon and label of the application are not displayed on the home screen.
+
+ **Figure 2** Application details page
+
+ ![Application details page](figures/application_details.jpg)
+
- **Configuring application version declaration**
To declare the application version, configure the **versionCode** and **versionName** fields in the [app.json5 file](../quick-start/app-configuration-file.md) in the **AppScope** directory of the project. **versionCode** specifies the version number of the application. The value is a 32-bit non-negative integer. It is used only to determine whether a version is later than another version. A larger value indicates a later version. **versionName** provides the text description of the version number.
diff --git a/en/application-dev/application-models/application-context-stage.md b/en/application-dev/application-models/application-context-stage.md
index 3fc6df944c5b9b137c585f59a8f83cd61db226f9..2063eee286c25e360a1700d3e1771d865b875f1c 100644
--- a/en/application-dev/application-models/application-context-stage.md
+++ b/en/application-dev/application-models/application-context-stage.md
@@ -1,19 +1,16 @@
# Context (Stage Model)
-
## Overview
-[Context](../reference/apis/js-apis-inner-application-context.md) is the context of an object in an application. It provides basic information about the application, for example, **resourceManager**, **applicationInfo**, **dir** (application development path), and **area** (encryption level). It also provides basic methods such as **createBundleContext()** and **getApplicationContext()**. The UIAbility component and ExtensionAbility derived class components have their own **Context** classes, for example, the base class **Context**, **ApplicationContext**, **AbilityStageContext**, **UIAbilityContext**, **ExtensionContext**, and **ServiceExtensionContext**.
+[Context](../reference/apis/js-apis-inner-application-context.md) is the context of an object in an application. It provides basic information about the application, for example, **resourceManager**, **applicationInfo**, **dir** (application development path), and **area** (encrypted level). It also provides basic methods such as **createBundleContext()** and **getApplicationContext()**. The UIAbility component and ExtensionAbility derived class components have their own **Context** classes, for example, the base class **Context**, **ApplicationContext**, **AbilityStageContext**, **UIAbilityContext**, **ExtensionContext**, and **ServiceExtensionContext**.
- The figure below illustrates the inheritance relationship of contexts.
-
![context-inheritance](figures/context-inheritance.png)
-
+
- The figure below illustrates the holding relationship of contexts.
-
![context-holding](figures/context-holding.png)
-- The following describes the information provided by different contexts.
+The following describes the information provided by different contexts.
- [UIAbilityContext](../reference/apis/js-apis-inner-application-uiAbilityContext.md): Each UIAbility has the **Context** attribute, which provides APIs to operate an application component, obtain the application component configuration, and more.
```ts
@@ -21,7 +18,7 @@
export default class EntryAbility extends UIAbility {
onCreate(want, launchParam) {
let uiAbilityContext = this.context;
- // ...
+ ...
}
}
```
@@ -36,7 +33,7 @@
export default class MyService extends ServiceExtensionAbility {
onCreate(want) {
let serviceExtensionContext = this.context;
- // ...
+ ...
}
}
```
@@ -47,7 +44,7 @@
export default class MyAbilityStage extends AbilityStage {
onCreate() {
let abilityStageContext = this.context;
- // ...
+ ...
}
}
```
@@ -58,7 +55,7 @@
export default class EntryAbility extends UIAbility {
onCreate(want, launchParam) {
let applicationContext = this.context.getApplicationContext();
- // ...
+ ...
}
}
```
@@ -84,13 +81,13 @@ The following table describes the application development paths obtained from co
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| bundleCodeDir | string | Yes | No | Path for storing the application's installation package, that is, installation directory of the application on the internal storage. Do not access resource files by concatenating paths. Use [@ohos.resourceManager] instead. |
-| cacheDir | string | Yes| No| Path for storing the application's cache files, that is, cache directory of the application on the internal storage.
It is the content of **Storage** of an application under **Settings > Apps & services > Apps**.|
-| filesDir | string | Yes | No | Path for storing the application's common files, that is, file directory of the application on the internal storage.
Files in this directory may be synchronized to other directories during application migration or backup.|
-| preferencesDir | string | Yes | Yes | Path for storing the application's preference files, that is, preferences directory of the application. |
-| tempDir | string | Yes | No | Path for storing the application's temporary files.
Files in this directory are deleted after the application is uninstalled.|
+| bundleCodeDir | string | Yes | No | Path for storing the application's installation package, that is, installation directory of the application on the internal storage. |
+| cacheDir | string | Yes| No| Path for storing the cache files, that is, cache directory of the application on the internal storage.
It is the content of **Storage** of an application under **Settings > Apps & services > Apps**.|
+| filesDir | string | Yes | No | Path for storing the common files, that is, file directory of the application on the internal storage.
Files in this directory may be synchronized to other directories during application migration or backup.|
+| preferencesDir | string | Yes | Yes | Path for storing the preference files, that is, preferences directory of the application. |
+| tempDir | string | Yes | No | Path for storing the temporary files.
Files in this directory are deleted after the application is uninstalled.|
| databaseDir | string | Yes | No | Path for storing the application's database, that is, storage directory of the local database. |
-| distributedFilesDir | string | Yes| No| Path for storing the application's distributed files.|
+| distributedFilesDir | string | Yes| No| Path for storing the distributed files.|
The capability of obtaining the application development path is provided by the base class **Context**. This capability is also provided by **ApplicationContext**, **AbilityStageContext**, **UIAbilityContext**, and **ExtensionContext**. However, the paths obtained from different contexts may differ, as shown below.
@@ -135,7 +132,7 @@ export default class EntryAbility extends UIAbility {
let bundleCodeDir = this.context.bundleCodeDir;
let distributedFilesDir = this.context.distributedFilesDir;
let preferencesDir = this.context.preferencesDir;
- // ...
+ ...
}
}
```
@@ -187,13 +184,13 @@ The base class **Context** provides [createBundleContext(bundleName:string)](../
> **NOTE**
>
> To obtain the context of another application:
- >
+ >
> - Request the **ohos.permission.GET_BUNDLE_INFO_PRIVILEGED** permission. For details, see [Declaring Permissions in the Configuration File](../security/accesstoken-guidelines.md#declaring-permissions-in-the-configuration-file).
- >
+ >
> - This is a system API and cannot be called by third-party applications.
For example, application information displayed on the home screen includes the application name and icon. The home screen application calls the foregoing method to obtain the context information, so as to obtain the resource information including the application name and icon.
-
+
```ts
import UIAbility from '@ohos.app.ability.UIAbility';
@@ -202,7 +199,7 @@ The base class **Context** provides [createBundleContext(bundleName:string)](../
let bundleName2 = 'com.example.application';
let context2 = this.context.createBundleContext(bundleName2);
let label2 = context2.applicationInfo.label;
- // ...
+ ...
}
}
```
@@ -224,7 +221,7 @@ The base class **Context** provides [createBundleContext(bundleName:string)](../
let bundleName2 = 'com.example.application';
let moduleName2 = 'module1';
let context2 = this.context.createModuleContext(bundleName2, moduleName2);
- // ...
+ ...
}
}
```
@@ -238,7 +235,7 @@ The base class **Context** provides [createBundleContext(bundleName:string)](../
onCreate(want, launchParam) {
let moduleName2 = 'module1';
let context2 = this.context.createModuleContext(moduleName2);
- // ...
+ ...
}
}
```
@@ -266,53 +263,53 @@ export default class EntryAbility extends UIAbility {
let abilityLifecycleCallback = {
// Called when a UIAbility is created.
onAbilityCreate(uiAbility) {
- console.log(TAG, `onAbilityCreate uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`);
+ console.info(TAG, `onAbilityCreate uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`);
},
// Called when a window is created.
onWindowStageCreate(uiAbility, windowStage: window.WindowStage) {
- console.log(TAG, `onWindowStageCreate uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`);
- console.log(TAG, `onWindowStageCreate windowStage: ${JSON.stringify(windowStage)}`);
+ console.info(TAG, `onWindowStageCreate uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`);
+ console.info(TAG, `onWindowStageCreate windowStage: ${JSON.stringify(windowStage)}`);
},
// Called when the window becomes active.
onWindowStageActive(uiAbility, windowStage: window.WindowStage) {
- console.log(TAG, `onWindowStageActive uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`);
- console.log(TAG, `onWindowStageActive windowStage: ${JSON.stringify(windowStage)}`);
+ console.info(TAG, `onWindowStageActive uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`);
+ console.info(TAG, `onWindowStageActive windowStage: ${JSON.stringify(windowStage)}`);
},
// Called when the window becomes inactive.
onWindowStageInactive(uiAbility, windowStage: window.WindowStage) {
- console.log(TAG, `onWindowStageInactive uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`);
- console.log(TAG, `onWindowStageInactive windowStage: ${JSON.stringify(windowStage)}`);
+ console.info(TAG, `onWindowStageInactive uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`);
+ console.info(TAG, `onWindowStageInactive windowStage: ${JSON.stringify(windowStage)}`);
},
// Called when the window is destroyed.
onWindowStageDestroy(uiAbility, windowStage: window.WindowStage) {
- console.log(TAG, `onWindowStageDestroy uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`);
- console.log(TAG, `onWindowStageDestroy windowStage: ${JSON.stringify(windowStage)}`);
+ console.info(TAG, `onWindowStageDestroy uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`);
+ console.info(TAG, `onWindowStageDestroy windowStage: ${JSON.stringify(windowStage)}`);
},
// Called when the UIAbility is destroyed.
onAbilityDestroy(uiAbility) {
- console.log(TAG, `onAbilityDestroy uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`);
+ console.info(TAG, `onAbilityDestroy uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`);
},
// Called when the UIAbility is switched from the background to the foreground.
onAbilityForeground(uiAbility) {
- console.log(TAG, `onAbilityForeground uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`);
+ console.info(TAG, `onAbilityForeground uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`);
},
// Called when the UIAbility is switched from the foreground to the background.
onAbilityBackground(uiAbility) {
- console.log(TAG, `onAbilityBackground uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`);
+ console.info(TAG, `onAbilityBackground uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`);
},
// Called when UIAbility is continued on another device.
onAbilityContinue(uiAbility) {
- console.log(TAG, `onAbilityContinue uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`);
+ console.info(TAG, `onAbilityContinue uiAbility.launchWant: ${JSON.stringify(uiAbility.launchWant)}`);
}
}
// Obtain the application context.
let applicationContext = this.context.getApplicationContext();
// Register the application lifecycle callback.
this.lifecycleId = applicationContext.on('abilityLifecycle', abilityLifecycleCallback);
- console.log(TAG, `register callback number: ${this.lifecycleId}`);
+ console.info(TAG, `register callback number: ${this.lifecycleId}`);
}
- // ...
+ ...
onDestroy() {
// Obtain the application context.
diff --git a/en/application-dev/application-models/application-model-description.md b/en/application-dev/application-models/application-model-description.md
index 0cdfa7323c6ef367a47a44e2c30104d3201ca159..20fa9019d10c8d242e34b309debec78e722e6c27 100644
--- a/en/application-dev/application-models/application-model-description.md
+++ b/en/application-dev/application-models/application-model-description.md
@@ -12,10 +12,9 @@ Along its evolution, OpenHarmony has provided two application models:
The stage model is designed based on the following considerations, which make it become the recommended model:
1. **Designed for complex applications**
-
- In the stage model, multiple application components share an ArkTS engine (VM running the programming language ArkTS) instance, making it easy for application components to share objects and status while requiring less memory.
- The object-oriented development mode makes the code of complex applications easy to read, maintain, and scale.
-
+
2. **Native support for [cross-device migration](hop-cross-device-migration.md) and [multi-device collaboration](hop-multi-device-collaboration.md) at the application component level**
The stage model decouples application components from User Interfaces (UIs).
@@ -38,7 +37,7 @@ The stage model is designed based on the following considerations, which make it
The stage model redefines the boundary of application capabilities to well balance application capabilities and system management costs.
- - Diverse application components (such as widgets and input methods) for specific scenarios.
+ - Diverse application components (such as service widgets and input methods) for specific scenarios.
- Standardized background process management. To deliver a better user experience, the stage model manages background application processes in a more orderly manner. Applications cannot reside in the background randomly, and their background behavior is strictly managed to minimize malicious behavior.
@@ -52,8 +51,8 @@ The table below describes their differences in detail.
| Item| FA model| Stage model|
| -------- | -------- | -------- |
-| **Application component**| 1. Component classification
![fa-model-component](figures/fa-model-component.png)
- PageAbility: has the UI and supports user interaction For details, see [PageAbility Component Overview](pageability-overview.md).
- ServiceAbility: provides background services and has no UI. For details, see [ServiceAbility Component Overview](serviceability-overview.md).
- DataAbility: provides the data sharing capability and has no UI. For details, see [DataAbility Component Overview](dataability-overview.md).
2. Development mode
Application components are specified by exporting anonymous objects and fixed entry files. You cannot perform derivation. It is inconvenient for capability expansion. | 1. Component classification
![stage-model-component](figures/stage-model-component.png)
- UIAbility: has the UI and supports user interaction. For details, see [UIAbility Component Overview](uiability-overview.md).
- ExtensionAbility: provides extension capabilities (such as widget and input methods) for specific scenarios. For details, see [ExtensionAbility Component Overview](extensionability-overview.md).
2. Development mode
The object-oriented mode is used to provide open application components as classes. You can derive application components for capability expansion. |
-| **Process model**| There are two types of processes:
1. Main process
2. Rendering process
For details, see [Process Model (FA Model)](process-model-fa.md).| There are three types of processes:
1. Main process
2. ExtensionAbility process
3. Rendering process
For details, see [Process Model (Stage Model)](process-model-stage.md).|
-| **Thread model**| 1. ArkTS engine instance creation
A process can run multiple application component instances, and each application component instance runs in an independent ArkTS engine instance.
2. Thread model
Each ArkTS engine instance is created on an independent thread (non-main thread). The main thread does not have an ArkTS engine instance.
3. Intra-process object sharing: not supported.
For details, see [Thread Model (FA Model)](thread-model-fa.md).| 1. ArkTS engine instance creation
A process can run multiple application component instances, and all application component instances share one ArkTS engine instance.
2. Thread model
The ArkTS engine instance is created on the main thread.
3. Intra-process object sharing: supported.
For details, see [Thread Model (Stage Model)](thread-model-stage.md).|
+| **Application component**| 1. Component classification
![fa-model-component](figures/fa-model-component.png)
- PageAbility: has the UI and supports user interaction For details, see [PageAbility Component Overview](pageability-overview.md).
- ServiceAbility: provides background services and has no UI. For details, see [ServiceAbility Component Overview](serviceability-overview.md).
- DataAbility: provides the data sharing capability and has no UI. For details, see [DataAbility Component Overview](dataability-overview.md).
2. Development mode
Application components are specified by exporting anonymous objects and fixed entry files. You cannot perform derivation. It is inconvenient for capability expansion.| 1. Component classification
![stage-model-component](figures/stage-model-component.png)
- UIAbility: has the UI and supports user interaction. For details, see [UIAbility Component Overview](uiability-overview.md).
- ExtensionAbility: provides extension capabilities (such as widget and input methods) for specific scenarios. For details, see [ExtensionAbility Component Overview](extensionability-overview.md).
2. Development mode
The object-oriented mode is used to provide open application components as classes. You can derive application components for capability expansion.|
+| **Process model**| There are two types of processes:
1. Main process
2. Rendering process
For details, see [Process Model Overview (FA Model)](process-model-fa.md). | There are three types of processes:
1. Main process
2. ExtensionAbility process
3. Rendering process
For details, see [Process Model Overview (Stage Model)](process-model-stage.md). |
+| **Thread model**| 1. ArkTS engine instance creation
A process can run multiple application component instances, and each application component instance runs in an independent ArkTS engine instance.
2. Thread model
Each ArkTS engine instance is created on an independent thread (non-main thread). The main thread does not have an ArkTS engine instance.
3. Intra-process object sharing: not supported.
For details, see [Thread Model Overview (FA Model)](thread-model-fa.md). | 1. ArkTS engine instance creation
A process can run multiple application component instances, and all application component instances share one ArkTS engine instance.
2. Thread model
The ArkTS engine instance is created on the main thread.
3. Intra-process object sharing: supported.
For details, see [Thread Model Overview (Stage Model)](thread-model-stage.md). |
| **Mission management model**| - A mission is created for each PageAbility component instance.
- Missions are stored persistently until the number of missions exceeds the maximum (customized based on the product configuration) or users delete missions.
- PageAbility components do not form a stack structure.
For details, see [Mission Management Scenarios](mission-management-overview.md).| - A mission is created for each UIAbility component instance.
- Missions are stored persistently until the number of missions exceeds the maximum (customized based on the product configuration) or users delete missions.
- UIAbility components do not form a stack structure.
For details, see [Mission Management Scenarios](mission-management-overview.md).|
| **Application configuration file**| The **config.json** file is used to describe the application, HAP, and application component information.
For details, see [Application Configuration File Overview (FA Model)](../quick-start/application-configuration-file-overview-fa.md).| The **app.json5** file is used to describe the application information, and the **module.json5** file is used to describe the HAP and application component information.
For details, see [Application Configuration File Overview (Stage Model)](../quick-start/application-configuration-file-overview-stage.md).|
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 d5512e0c446b94dcf384504f11ff25d458cfeafc..28184edbc9304e7c6fbfbfe673cf1b8deca7d635 100644
--- a/en/application-dev/application-models/data-share-via-want.md
+++ b/en/application-dev/application-models/data-share-via-want.md
@@ -48,9 +48,9 @@ function implicitStartAbility() {
}
}
context.startAbility(wantInfo).then(() => {
- // ...
+ ...
}).catch((err) => {
- // ...
+ ...
})
}
```
@@ -66,8 +66,7 @@ In the preceding code, under the custom field **parameters**, the following **ab
- **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.
-
+The following figure shows an example.
![](figures/ability-startup-with-implicit-want2.png)
## Shared Party
@@ -77,17 +76,17 @@ To enable the shared party to identify the shared content, configure **skills**
```json
{
"module": {
- // ...
+ ...
"abilities": [
{
- // ...
+ ...
"skills": [
{
- // ...
+ ...
"actions": [
"action.system.home",
"ohos.want.action.sendData"
- // ...
+ ...
],
"uris": [
{
@@ -102,7 +101,7 @@ To enable the shared party to identify the shared content, configure **skills**
}
```
-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.
+After the user selects an application, the Want nested in the **ability.want.params.INTENT** field is passed to that application. After the UIAbility of the application starts, the application obtains **want** information from [**onCreate()**](../reference/apis/js-apis-app-ability-uiAbility.md#uiabilityoncreate) or [**onNewWant()**](../reference/apis/js-apis-app-ability-uiAbility.md#uiabilityonnewwant).
The following is an example of the Want obtained. You can use the FD of the shared file to perform required operations.
diff --git a/en/application-dev/application-models/datashareextensionability.md b/en/application-dev/application-models/datashareextensionability.md
deleted file mode 100644
index bea3de69c6d7ad375206fb1d53bcc36c2624989d..0000000000000000000000000000000000000000
--- a/en/application-dev/application-models/datashareextensionability.md
+++ /dev/null
@@ -1,4 +0,0 @@
-# DataShareExtensionAbility (for System Applications Only)
-
-
-DataShareExtensionAbility provides the data sharing capability. System applications can implement a DataShareExtensionAbility or access an existing DataShareExtensionAbility in the system. Third-party applications can only access an existing DataShareExtensionAbility. For details, see [Cross-Application Data Sharing Overview](../database/share-device-data-across-apps-overview.md).
diff --git a/en/application-dev/application-models/explicit-implicit-want-mappings.md b/en/application-dev/application-models/explicit-implicit-want-mappings.md
index 9e748a31795e3afc713e7091067a8164e8a623cc..454fc89d718fb4adfe84c0eab67ebc332117ed26 100644
--- a/en/application-dev/application-models/explicit-implicit-want-mappings.md
+++ b/en/application-dev/application-models/explicit-implicit-want-mappings.md
@@ -1,28 +1,28 @@
# Matching Rules of Explicit Want and Implicit Want
-Both explicit Want and implicit Want can be used to match an ability to start based on certain rules. These rules determine how the parameters set in Want match the configuration file declared by the target ability.
+Both explicit [Want](../reference/apis/js-apis-app-ability-want.md) and implicit [Want](../reference/apis/js-apis-app-ability-want.md) can be used to match an application component to start based on certain rules. These rules determine how the parameters set in [want](../reference/apis/js-apis-app-ability-want.md) match the configuration file declared by the target application component.
## Matching Rules of Explicit Want
-The table below describes the matching rules of explicit Want.
+The table below describes the matching rules of explicit [Want](../reference/apis/js-apis-app-ability-want.md).
| Name| Type| Matching Item| Mandatory| Rule Description|
| -------- | -------- | -------- | -------- | -------- |
-| deviceId | string | Yes| No| If this field is unspecified, only abilities on the local device are matched.|
+| deviceId | string | Yes| No| If this field is unspecified, only application components on the local device are matched.|
| bundleName | string | Yes| Yes| If **abilityName** is specified but **bundleName** is unspecified, the matching fails.|
-| moduleName | string | Yes| No| If this field is unspecified and multiple modules with the same ability name exist in the application, the first ability is matched by default.|
+| moduleName | string | Yes| No| If this field is unspecified and multiple modules with the same ability name exist in the application, the first application component is matched by default.|
| abilityName | string | Yes| Yes| To use explicit Want, this field must be specified.|
-| uri | string | No| No| This field is not used for matching. It is passed to the target ability as a parameter.|
-| type | string | No| No| This field is not used for matching. It is passed to the target ability as a parameter.|
-| action | string | No| No| This field is not used for matching. It is passed to the target ability as a parameter.|
-| entities | Array<string> | No| No| This field is not used for matching. It is passed to the target ability as a parameter.|
+| uri | string | No| No| This field is not used for matching. It is passed to the target application component as a parameter.|
+| type | string | No| No| This field is not used for matching. It is passed to the target application component as a parameter.|
+| action | string | No| No| This field is not used for matching. It is passed to the target application component as a parameter.|
+| entities | Array<string> | No| No| This field is not used for matching. It is passed to the target application component as a parameter.|
| flags | number | No| No| This field is not used for matching and is directly transferred to the system for processing. It is generally used to set runtime information, such as URI data authorization.|
-| parameters | {[key: string]: any} | No| No| This field is not used for matching. It is passed to the target ability as a parameter.|
+| parameters | {[key: string]: any} | No| No| This field is not used for matching. It is passed to the target application component as a parameter.|
## Matching Rules for Implicit Want
-The table below describes the matching rules of implicit Want.
+The table below describes the matching rules of implicit [Want](../reference/apis/js-apis-app-ability-want.md).
| Name | Type | Matching Item| Mandatory| Rule Description |
| ----------- | ------------------------------ | ------ | ---- | ------------------------------------------------------------ |
@@ -35,30 +35,32 @@ The table below describes the matching rules of implicit Want.
| action | string | Yes | No | |
| entities | Array<string> | Yes | No | |
| flags | number | No | No | This field is not used for matching and is directly transferred to the system for processing. It is generally used to set runtime information, such as URI data authorization.|
-| parameters | {[key: string]: any} | No | No | This field is not used for matching. It is passed to the target ability as a parameter. |
+| parameters | {[key: string]: any} | No | No | This field is not used for matching. It is passed to the target application component as a parameter. |
Get familiar with the following about implicit Want:
- The **want** parameter passed by the caller indicates the operation to be performed by the caller. It also provides data and application type restrictions.
-- The **skills** field declares the capabilities of the target ability. For details, see [the skills tag](../quick-start/module-configuration-file.md#skills) in the [module.json5 file](../quick-start/module-configuration-file.md).
+- The **skills** field declares the capabilities of the target application component. For details, see [the skills tag](../quick-start/module-configuration-file.md#skills) in the [module.json5 file](../quick-start/module-configuration-file.md).
-The system matches the **want** parameter (including the **action**, **entities**, **uri**, and **type** attributes) passed by the caller against the **skills** configuration (including the **actions**, **entities**, **uris**, and **type** attributes) of the abilities one by one. When all the four attributes are matched, a dialog box is displayed for users to select a matched application.
+The system matches the **want** parameter (including the **action**, **entities**, **uri**, and **type** attributes) passed by the caller against the **skills** configuration (including the **actions**, **entities**, **uris**, and **type** attributes) of the application components one by one. When all the four attributes are matched, a dialog box is displayed for users to select a matched application.
### Matching Rules of action in the want Parameter
-The system matches the **action** attribute in the **want** parameter passed by the caller against **actions** under **skills** of the abilities.
+The system matches the **action** attribute in the **want** parameter passed by the caller against **actions** under **skills** of the application components.
-- If **action** in the passed **want** parameter is specified but **actions** under **skills** of an ability is unspecified, the matching fails.
+- If **action** in the passed **want** parameter is unspecified and **actions** under **skills** of an application component is unspecified, the matching fails.
-- If **action** in the passed **want** parameter is unspecified but **actions** under **skills** of an ability is specified, the matching is successful.
+- If **action** in the passed **want** parameter is specified but **actions** under **skills** of an application component is unspecified, the matching fails.
-- If **action** in the passed **want** parameter is specified, and **actions** under **skills** of an ability is specified and contains **action** in the passed **want** parameter, the matching is successful.
+- If **action** in the passed **want** parameter is unspecified but **actions** under **skills** of an application component is specified, the matching is successful.
-- If **action** in the passed **want** parameter is specified, and **actions** under **skills** of an ability is specified but does not contain **action** in the passed **want** parameter, the matching fails.
+- If **action** in the passed **want** parameter is specified, and **actions** under **skills** of an application component is specified and contains **action** in the passed **want** parameter, the matching is successful.
+
+- If **action** in the passed **want** parameter is specified, and **actions** under **skills** of an application component is specified but does not contain **action** in the passed **want** parameter, the matching fails.
**Figure 1** Matching rules of action in the want parameter
@@ -67,55 +69,56 @@ The system matches the **action** attribute in the **want** parameter passed by
### Matching Rules of entities in the want Parameter
-The system matches the **entities** attribute in the **want** parameter passed by the caller against **entities** under **skills** of the abilities.
+The system matches the **entities** attribute in the **want** parameter passed by the caller against **entities** under **skills** of the application components.
-- If **entities** in the passed **want** parameter is unspecified but **entities** under **skills** of an ability is specified, the matching is successful.
+- If **entities** in the passed **want** parameter is unspecified but **entities** under **skills** of an application component is specified, the matching is successful.
-- If **entities** in the passed **want** parameter is unspecified but **entities** under **skills** of an ability is unspecified, the matching is successful.
+- If **entities** in the passed **want** parameter is unspecified but **entities** under **skills** of an application component is unspecified, the matching is successful.
-- If **entities** in the passed **want** parameter is specified but **entities** under **skills** of an ability is unspecified, the matching fails.
+- If **entities** in the passed **want** parameter is specified but **entities** under **skills** of an application component is unspecified, the matching fails.
-- If **entities** in the passed **want** parameter is specified, and **entities** under **skills** of an ability is specified and contains **entities** in the passed **want** parameter, the matching is successful.
+- If **entities** in the passed **want** parameter is specified, and **entities** under **skills** of an application component is specified and contains **entities** in the passed **want** parameter, the matching is successful.
-- If **entities** in the passed **want** parameter is specified, and **entities** under **skills** of an ability is specified but does not contain **entities** in the passed **want** parameter, the matching fails.
+- If **entities** in the passed **want** parameter is specified, and **entities** under **skills** of an application component is specified but does not contain **entities** in the passed **want** parameter, the matching fails.
- **Figure 2** Matching rule of entities in the want parameter
+ **Figure 2** Matching rules of entities in the want parameter
![want-entities](figures/want-entities.png)
### Matching Rules of uri and type in the want Parameter
-When the **uri** and **type** parameters are specified in the **want** parameter to initiate a component startup request, the system traverses the list of installed components and matches the **uris** array under **skills** of the abilities one by one. If one of the **uris** arrays under **skills** matches the **uri** and **type** in the passed **want**, the matching is successful.
+When the **uri** and **type** parameters are specified in the **want** parameter to initiate an application component startup request, the system traverses the list of installed components and matches the **uris** array under **skills** of the application components one by one. If one of the **uris** arrays under **skills** matches the **uri** and **type** in the passed **want**, the matching is successful.
There are four combinations of **uri** and **type** settings. The matching rules are as follows:
- Neither **uri** or **type** is specified in the **want** parameter.
- - If the **uris** array under **skills** of an ability is unspecified, the matching is successful.
- - If the **uris** array under **skills** of an ability contains an URI element whose **scheme** and **type** are unspecified, the matching is successful.
+ - If the **uris** array under **skills** of an application component is unspecified, the matching is successful.
+ - If the **uris** array under **skills** of an application component contains an URI element whose **scheme** and **type** are unspecified, the matching is successful.
- In other cases, the matching fails.
- Only **uri** is specified in the **want** parameter.
- - If the **uris** array under **skills** of an ability is unspecified, the matching fails.
- - If the **uris** array under **skills** of an ability contains an element whose [uri is matched](#matching-rules-of-uri) and **type** is unspecified, the matching is successful. Otherwise, the matching fails.
+ - If the **uris** array under **skills** of an application component is unspecified, the matching fails.
+ - If the **uris** array under **skills** of an application component contains an element whose [uri is matched](#matching-rules-of-uri) and **type** is unspecified, the matching is successful. Otherwise, the matching fails.
- Only **type** is specified in the **want** parameter.
- - If the **uris** array under **skills** of an ability is unspecified, the matching fails.
- - If the **uris** array under **skills** of an ability contains an URI element whose **scheme** is unspecified and [type is matched](#matching-rules-of-type), the matching is successful. Otherwise, the matching fails.
+ - If the **uris** array under **skills** of an application component is unspecified, the matching fails.
+ - If the **uris** array under **skills** of an application component contains an URI element whose **scheme** is unspecified and [type is matched](#matching-rules-of-type), the matching is successful. Otherwise, the matching fails.
-- Both **uri** and **type** are specified in the **want** parameter, as shown in Figure 3.
- - If the **uris** array under **skills** of an ability is unspecified, the matching fails.
- - If the **uris** array under **skills** of an ability contains an element whose [uri is matched](#matching-rules-of-uri) and [type is matched](#matching-rules-of-type), the matching is successful. Otherwise, the matching fails.
+- Both **uri** and **type** are specified in the **want** parameter, as shown below.
+ - If the **uris** array under **skills** of an application component is unspecified, the matching fails.
+ - If the **uris** array under **skills** of an application component contains an element whose [uri is matched](#matching-rules-of-uri) and [type is matched](#matching-rules-of-type), the matching is successful. Otherwise, the matching fails.
-Leftmost URI matching: When only **scheme**, a combination of **scheme** and **host**, or a combination of **scheme**, **host**, and **port** is configured in the **uris** array under **skills** of the ability,
-the matching is successful only if the leftmost URI in the passed **want** parameter matches **scheme**, the combination of **scheme** and **host**, or the combination of **scheme**, **host**, and **port**.
+Leftmost URI matching: When only **scheme**, a combination of **scheme** and **host**, or a combination of **scheme**, **host**, and **port** is configured in the **uris** array under **skills** of the application component, the matching is successful only if the leftmost URI in the passed **want** parameter matches **scheme**, the combination of **scheme** and **host**, or the combination of **scheme**, **host**, and **port**.
**Figure 3** Matching rules when uri and type are specified in the want parameter
- ![want-uri-type1](figures/want-uri-type1.png)
+![want-uri-type1](figures/want-uri-type1.png)
+To simplify the description:
-To simplify the description, **uri** and **type** passed in the **want** parameter are called **w_uri** and **w_type**, respectively; the **uris** array under **skills** of an ability to match is called **s_uris**; each element in the array is called **s_uri**. Matching is performed from top to bottom.
+- **uri** in the **want** parameter passed in by the caller is called **w_uri**; each element in the **uris** array under **skills** of the application component to match is called **s_uri**.
+- **type** in the **want** parameter passed in by the caller is called **w_type**; the type in the **uris** array under **skills** of the application component to match is called **s_type**.
**Figure 4** Matching rules of uri and type in the want parameter
@@ -124,7 +127,7 @@ To simplify the description, **uri** and **type** passed in the **want** paramet
### Matching Rules of uri
-To simplify the description, **uri** in the passed **want** parameter is called **w_uri**; **uri** under **skills** of an ability to match is called **s_uri**. The matching rules are as follows:
+The rules are as follows:
- If **scheme** of **s_uri** is unspecified and **w_uri** is unspecified, the matching is successful. Otherwise, the matching fails.
@@ -142,18 +145,15 @@ To simplify the description, **uri** in the passed **want** parameter is called
> **NOTE**
>
-> The **scheme**, **host**, **port**, **path**, **pathStartWith**, and **pathRegex** attributes of **uris** under **skills** of an ability are concatenated. If **path**, **pathStartWith**, and **pathRegex** are declared in sequence, **uris** can be concatenated into the following expressions:
->
-> - **Full path expression**: `scheme://host:port/path`
->
-> - **Prefix expression**: `scheme://host:port/pathStartWith`
->
-> - **Regular expression**: `scheme://host:port/pathRegex`
+> The **scheme**, **host**, **port**, **path**, **pathStartWith**, and **pathRegex** attributes of **uris** under **skills** of an application component are concatenated. If **path**, **pathStartWith**, and **pathRegex** are declared in sequence, **uris** can be concatenated into the following expressions:
>
> - **Prefix URI expression**: When only **scheme**, a combination of **scheme** and **host**, or a combination of **scheme**, **host**, and **port** is configured in the configuration file, the matching is successful if a URI prefixed with the configuration file is passed in.
> * `scheme://`
> * `scheme://host`
> * `scheme://host:port`
+> - **Full path expression**: `scheme://host:port/path`
+> - **Prefix expression**: `scheme://host:port/pathStartWith`
+> - **Regular expression**: `scheme://host:port/pathRegex`
### Matching Rules of type
@@ -162,7 +162,7 @@ To simplify the description, **uri** in the passed **want** parameter is called
>
> The matching rules of **type** described in this section are based on the fact that **type** in the **want** parameter is specified. If **type** is unspecified, follow the [matching rules of uri and type in the want parameter](#matching-rules-of-uri-and-type-in-the-want-parameter).
-To simplify the description, **uri** in the passed **want** parameter is called **w_type**, and **type** of **uris** under **skills** of an ability to match is called **s_type**. The matching rules are as follows:
+The matching rules are as follows:
- If **s_type** is unspecified, the matching fails.
diff --git a/en/application-dev/application-models/extensionability-overview.md b/en/application-dev/application-models/extensionability-overview.md
index d176b2d5322b215ab3d730b59cfc5a8e1f6dfb99..f55686f33a6d37917b8d7ff75d441d6f5c6c921f 100644
--- a/en/application-dev/application-models/extensionability-overview.md
+++ b/en/application-dev/application-models/extensionability-overview.md
@@ -11,17 +11,17 @@ An [ExtensionAbilityType](../reference/apis/js-apis-bundleManager.md#extensionab
- [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.
+- [InputMethodExtensionAbility](../reference/apis/js-apis-inputmethod.md): ExtensionAbility component of the input_method type, which is used to develop input method applications.
- [ServiceExtensionAbility](../reference/apis/js-apis-app-ability-serviceExtensionAbility.md): ExtensionAbility component of the service type, which provides APIs related to background service scenarios.
- [AccessibilityExtensionAbility](../reference/apis/js-apis-application-accessibilityExtensionAbility.md): ExtensionAbility component of the accessibility type, which provides APIs related to the accessibility feature.
-- [DataShareExtensionAbility](../reference/apis/js-apis-application-dataShareExtensionAbility.md): ExtensionAbility component of the data_share type, which provides APIs for data sharing.
+- [DataShareExtensionAbility (for system applications only)](../reference/apis/js-apis-application-dataShareExtensionAbility.md): ExtensionAbility component of the data_share type, which provides APIs for data sharing.
- [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 a system application to be embedded in and displayed over another application.
+- [WindowExtensionAbility (for system applications only)](../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.
@@ -56,13 +56,11 @@ You do not need to care when to add or delete a widget. The lifecycle of the For
> **NOTE**
>
> For an application, all ExtensionAbility components of the same type run in an independent process, whereas UIAbility, ServiceExtensionAbility, and DataShareExtensionAbility run in another independent process. For details, see [Process Model (Stage Model)](process-model-stage.md).
->
+>
> For example, an application has one UIAbility component, one ServiceExtensionAbility, one DataShareExtensionAbility, two FormExtensionAbility, and one ImeExtensionAbility. When the application is running, there are three processes:
->
+>
> - UIAbility, ServiceExtensionAbility, and DataShareExtensionAbility run in an independent process.
->
+>
> - The two FormExtensionAbility components run in an independent process.
->
+>
> - The two ImeExtensionAbility components run in an independent process.
-
-
\ No newline at end of file
diff --git a/en/application-dev/application-models/fa-model-development-overview.md b/en/application-dev/application-models/fa-model-development-overview.md
index 07e7ef8a0bdaea927762c15e4123ae728c026cb7..295e1863556cd37c7bc7e8cb588eaabbb9decb14 100644
--- a/en/application-dev/application-models/fa-model-development-overview.md
+++ b/en/application-dev/application-models/fa-model-development-overview.md
@@ -8,8 +8,8 @@ During application development based on the Feature Ability (FA) model, the foll
| Task| Introduction| Guide|
| -------- | -------- | -------- |
-| Application component development| Use the PageAbility, ServiceAbility, DataAbility, and widgets of the FA model to develop applications.| - [Application- or Component-Level Configuration](application-component-configuration-fa.md)
- [PageAbility Component](pageability-overview.md)
- [ServiceAbility Component](serviceability-overview.md)
- [DataAbility Component](dataability-overview.md)
- [Widget Development](Widget-development-fa.md)
- [Context](application-context-fa.md)
- [Want](want-fa.md) |
-| Inter-process communication (IPC)| Learn the process model and common IPC modes of the FA model.| [Common Events](common-event-fa.md)
[Background Services](rpc.md) |
-| Inter-thread communication| Learn the thread model and common inter-thread communication modes of the FA model.| [Inter-Thread Communication](itc-fa-overview.md)|
+| Application component development| Use the PageAbility, ServiceAbility, DataAbility, and widgets of the FA model to develop applications.| - [Application- or Component-Level Configuration](application-component-configuration-fa.md)
- [PageAbility Component](pageability-overview.md)
- [ServiceAbility Component](serviceability-overview.md)
- [DataAbility Component](dataability-overview.md)
- [Widget Development](widget-development-fa.md)
- [Context](application-context-fa.md)
- [Want](want-fa.md)|
+| Process model| Learn the process model and common IPC modes of the FA model.| [Common Events](common-event-fa.md)
[Background Services](rpc.md)|
+| Thread model| Learn the thread model and common inter-thread communication modes of the FA model.| [Inter-Thread Communication](itc-fa-overview.md)|
| Mission management| Learn the basic concepts and typical scenarios of mission management in the FA model.| [Mission Management](mission-management-fa.md)|
-| Application configuration file| Learn the requirements for developing application configuration files in the FA model.| [Application Configuration File](config-file-fa.md) |
+| Application configuration file| Learn the requirements for developing application configuration files in the FA model.| [Application Configuration File](config-file-fa.md)|
diff --git a/en/application-dev/application-models/figures/application_details.jpg b/en/application-dev/application-models/figures/application_details.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..e849a47b3d10faefafbf76a7b6309da305a2e9b0
Binary files /dev/null and b/en/application-dev/application-models/figures/application_details.jpg differ
diff --git a/en/application-dev/application-models/figures/stage-concepts.png b/en/application-dev/application-models/figures/stage-concepts.png
index 42e99447a780b167adaf6ddd196bea4437dfa1a7..9d753f27fca4d507da20b5d5060f9b3d28e616b0 100644
Binary files a/en/application-dev/application-models/figures/stage-concepts.png and b/en/application-dev/application-models/figures/stage-concepts.png differ
diff --git a/en/application-dev/application-models/figures/want-action.png b/en/application-dev/application-models/figures/want-action.png
index 0d8e18ce5870bea777c26b832d3f29674c2fa261..b907e8158bd9fd183ceabb181a13aa813f01e77e 100644
Binary files a/en/application-dev/application-models/figures/want-action.png and b/en/application-dev/application-models/figures/want-action.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 c51e82e15f4e14f4b42b25e656543a01d84406fb..418eac519cb62c7339048df4f8663e20df8ef185 100644
--- a/en/application-dev/application-models/hop-cross-device-migration.md
+++ b/en/application-dev/application-models/hop-cross-device-migration.md
@@ -55,21 +55,21 @@ The table below describes the main APIs used for cross-device migration. For det
Configure the application to support migration.
Set the **continuable** field in the **module.json5** file to **true**. The default value is **false**. If this parameter is set to **false**, the application cannot be continued on the target device.
-
-
- ```json
- {
- "module": {
- // ...
- "abilities": [
- {
- // ...
- "continuable": true,
- }
- ]
- }
- }
- ```
+
+
+ ```json
+ {
+ "module": {
+ ...
+ "abilities": [
+ {
+ ...
+ "continuable": true,
+ }
+ ]
+ }
+ }
+ ```
Configure the application launch type. For details, see [UIAbility Component Launch Type](uiability-launch-type.md).
@@ -83,19 +83,19 @@ The table below describes the main APIs used for cross-device migration. For det
The sample code is as follows:
- ```ts
- import UIAbility from '@ohos.app.ability.UIAbility';
- import AbilityConstant from '@ohos.app.ability.AbilityConstant';
-
- onContinue(wantParam : {[key: string]: any}) {
- console.info(`onContinue version = ${wantParam.version}, targetDevice: ${wantParam.targetDevice}`)
- let workInput = AppStorage.Get('ContinueWork');
- // Set the user input data into wantParam.
- wantParam["work"] = workInput // set user input data into want params
- console.info(`onContinue input = ${wantParam["input"]}`);
- return AbilityConstant.OnContinueResult.AGREE
- }
- ```
+ ```ts
+ import UIAbility from '@ohos.app.ability.UIAbility';
+ import AbilityConstant from '@ohos.app.ability.AbilityConstant';
+
+ onContinue(wantParam : {[key: string]: any}) {
+ console.info(`onContinue version = ${wantParam.version}, targetDevice: ${wantParam.targetDevice}`)
+ let workInput = AppStorage.Get('ContinueWork');
+ // Set the user input data into wantParam.
+ wantParam["work"] = workInput // set user input data into want params
+ console.info(`onContinue input = ${wantParam["input"]}`);
+ return AbilityConstant.OnContinueResult.AGREE
+ }
+ ```
5. Implement **onCreate()** and **onNewWant()** in the UIAbility of the target application to implement data restoration.
- Implementation example of **onCreate** in the multi-instance scenario
diff --git a/en/application-dev/application-models/hop-multi-device-collaboration.md b/en/application-dev/application-models/hop-multi-device-collaboration.md
index b761037182f27367e9c01488de41aaa23b6b25d2..a6e767964e4d1ee83fb1e837b2ddeb55786c9739 100644
--- a/en/application-dev/application-models/hop-multi-device-collaboration.md
+++ b/en/application-dev/application-models/hop-multi-device-collaboration.md
@@ -63,7 +63,7 @@ On device A, touch the **Start** button provided by the initiator application to
// createDeviceManager is a system API.
deviceManager.createDeviceManager('ohos.samples.demo', (err, dm) => {
if (err) {
- // ...
+ ...
return
}
dmClass = dm
@@ -94,13 +94,13 @@ On device A, touch the **Start** button provided by the initiator application to
}
// context is the AbilityContext of the initiator UIAbility.
this.context.startAbility(want).then(() => {
- // ...
+ ...
}).catch((err) => {
- // ...
+ ...
})
```
-5. Call stopServiceExtensionAbility(../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstopserviceextensionability) to stop the ServiceExtensionAbility when it is no longer required on device B. (This API cannot be used to stop a UIAbility. Users must manually stop a UIAbility through task management.)
+5. Call [stopServiceExtensionAbility](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstopserviceextensionability) to stop the ServiceExtensionAbility when it is no longer required on device B. (This API cannot be used to stop a UIAbility. Users must manually stop a UIAbility through task management.)
```ts
let want = {
@@ -150,9 +150,9 @@ On device A, touch the **Start** button provided by the initiator application to
}
// context is the AbilityContext of the initiator UIAbility.
this.context.startAbilityForResult(want).then((data) => {
- // ...
+ ...
}).catch((err) => {
- // ...
+ ...
})
```
@@ -170,7 +170,7 @@ On device A, touch the **Start** button provided by the initiator application to
}
// context is the AbilityContext of the target UIAbility.
this.context.terminateSelfWithResult(abilityResult, (err) => {
- // ...
+ ...
});
```
@@ -179,17 +179,17 @@ On device A, touch the **Start** button provided by the initiator application to
```ts
const RESULT_CODE: number = 1001;
- // ...
+ ...
// context is the UIAbilityContext of the initiator UIAbility.
this.context.startAbilityForResult(want).then((data) => {
if (data?.resultCode === RESULT_CODE) {
// Parse the information returned by the target UIAbility.
let info = data.want?.parameters?.info
- // ...
+ ...
}
}).catch((err) => {
- // ...
+ ...
})
```
@@ -444,10 +444,10 @@ The following describes how to implement multi-device collaboration through cros
// Register the onRemoteStateChange listener of the CallerAbility.
try {
caller.onRemoteStateChange((str) => {
- console.log('Remote state changed ' + str);
+ console.info('Remote state changed ' + str);
});
} catch (error) {
- console.log('Caller.onRemoteStateChange catch error, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
+ console.info('Caller.onRemoteStateChange catch error, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
}
}
}).catch((error) => {
diff --git a/en/application-dev/application-models/itc-with-emitter.md b/en/application-dev/application-models/itc-with-emitter.md
index 2966bd8eea41e04893814f20a3c5b2f9e4e456c9..43a5dc67be7349bb1d51a7e4141920b8739f7beb 100644
--- a/en/application-dev/application-models/itc-with-emitter.md
+++ b/en/application-dev/application-models/itc-with-emitter.md
@@ -13,12 +13,12 @@ To develop the Emitter mode, perform the following steps:
// Define an event with eventId 1.
let event = {
- eventId: 1
+ eventId: 1
};
// Trigger the callback after the event with eventId 1 is received.
let callback = (eventData) => {
- console.info('event callback');
+ console.info('event callback');
};
// Subscribe to the event with eventId 1.
@@ -29,21 +29,21 @@ To develop the Emitter mode, perform the following steps:
```ts
import emitter from "@ohos.events.emitter";
-
+
// Define an event with eventId 1 and priority Low.
let event = {
- eventId: 1,
- priority: emitter.EventPriority.LOW
+ eventId: 1,
+ priority: emitter.EventPriority.LOW
};
-
+
let eventData = {
- data: {
- "content": "c",
- "id": 1,
- "isEmpty": false,
- }
+ data: {
+ "content": "c",
+ "id": 1,
+ "isEmpty": false,
+ }
};
-
+
// Emit the event with eventId 1 and event content eventData.
emitter.emit(event, eventData);
```
diff --git a/en/application-dev/application-models/itc-with-worker.md b/en/application-dev/application-models/itc-with-worker.md
index 996ab941b0244571dff6116a45ab5e2165cf1184..1f105d4f0ce31acdf135ab254e7bdb66e30d1ecf 100644
--- a/en/application-dev/application-models/itc-with-worker.md
+++ b/en/application-dev/application-models/itc-with-worker.md
@@ -9,13 +9,13 @@ To develop the Worker mode, perform the following steps:
1. Configure the **buildOption** field in the [module-level build-profile.json5](https://developer.harmonyos.com/en/docs/documentation/doc-guides/ohos-building-configuration-0000001218440654#section6887184182020) file of the project.
```ts
- "buildOption": {
- "sourceOption": {
- "workers": [
- "./src/main/ets/workers/worker.ts"
- ]
- }
+ "buildOption": {
+ "sourceOption": {
+ "workers": [
+ "./src/main/ets/workers/worker.ts"
+ ]
}
+ }
```
2. Create the **worker.ts** file based on the configuration in **build-profile.json5**.
@@ -27,9 +27,9 @@ To develop the Worker mode, perform the following steps:
// Process messages from the main thread.
parent.onmessage = function(message) {
- console.info("onmessage: " + message)
- // Send a message to the main thread.
- parent.postMessage("message from worker thread.")
+ console.info("onmessage: " + message)
+ // Send a message to the main thread.
+ parent.postMessage("message from worker thread.")
}
```
@@ -46,10 +46,10 @@ To develop the Worker mode, perform the following steps:
// Process messages from the worker thread.
wk.onmessage = function(message) {
- console.info("message from worker: " + message)
+ console.info("message from worker: " + message)
- // Stop the worker thread based on service requirements.
- wk.terminate()
+ // Stop the worker thread based on service requirements.
+ wk.terminate();
}
```
@@ -57,23 +57,22 @@ To develop the Worker mode, perform the following steps:
```ts
import worker from '@ohos.worker';
-
+
let wk = new worker.ThreadWorker("../workers/worker.ts");
-
+
// Send a message to the worker thread.
wk.postMessage("message from main thread.")
-
+
// Process messages from the worker thread.
wk.onmessage = function(message) {
- console.info("message from worker: " + message)
-
- // Stop the worker thread based on service requirements.
- wk.terminate()
+ console.info("message from worker: " + message)
+
+ // Stop the worker thread based on service requirements.
+ wk.terminate();
}
```
> **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.ts** when creating a worker thread in the FA model.
->
> - For details about the data types supported between the main thread and worker thread, see [Sequenceable Data Types](../reference/apis/js-apis-worker.md#sequenceable-data-types).
diff --git a/en/application-dev/application-models/mission-management-launch-type.md b/en/application-dev/application-models/mission-management-launch-type.md
index 199de6eefead9fc056adf8d08c49f792a54a4a83..56a389cc52e093008491f75e01144bd7635b94eb 100644
--- a/en/application-dev/application-models/mission-management-launch-type.md
+++ b/en/application-dev/application-models/mission-management-launch-type.md
@@ -1,4 +1,4 @@
-# Mission Management and Launch Type
+# Mission and Launch Type
One UIAbility instance corresponds to one mission. The number of UIAbility instances is related to the UIAbility launch type, specified by **launchType**, which is configured in the **config.json** file in the FA model and the [module.json5](../quick-start/module-configuration-file.md) file in the stage model.
@@ -11,13 +11,13 @@ The following describes how the mission list manager manages the UIAbility insta
![mission-and-singleton](figures/mission-and-singleton.png)
-- **multiton**: Each time [startAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability) is called, a **UIAbility** instance is created in the application process.
+- **multiton**: Each time [startAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability) is called, a UIAbility instance is created in the application process.
**Figure 2** Missions and multiton mode
![mission-and-multiton](figures/mission-and-multiton.png)
-- **specified**: The ([onAcceptWant()](../reference/apis/js-apis-app-ability-abilityStage.md#abilitystageonacceptwant)) method of [AbilityStage](abilitystage.md) determines whether to create an instance.
+- **specified**: The ([onAcceptWant()](../reference/apis/js-apis-app-ability-abilityStage.md#abilitystageonacceptwant)) method of [AbilityStage](abilitystage.md) determines whether to create a UIAbility instance.
**Figure 3** Missions and specified mode
diff --git a/en/application-dev/application-models/mission-management-overview.md b/en/application-dev/application-models/mission-management-overview.md
index ba55ebb136ebffca0294bf69013f2f2ab4392e7f..785a9f8291ea43e756ebed07843ceef23570160d 100644
--- a/en/application-dev/application-models/mission-management-overview.md
+++ b/en/application-dev/application-models/mission-management-overview.md
@@ -4,7 +4,7 @@
Before getting started with the development of mission management, be familiar with the following concepts related to mission management:
-- AbilityRecord: minimum unit for the system service to manage a UIAbility instance. It corresponds to a UIAbility component instance of an application.
+- AbilityRecord: minimum unit for the system service to manage a UIAbility instance. It corresponds to a UIAbility component instance of an application. A maximum of 512 UIAbility instances can be managed on the system service side.
- MissionRecord: minimum unit for mission management. One MissionRecord has only one AbilityRecord. In other words, a UIAbility component instance corresponds to a mission.
@@ -30,42 +30,42 @@ Missions are managed by system applications (such as home screen), rather than t
A UIAbility instance corresponds to an independent mission. Therefore, when an application calls [startAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability) to start a UIAbility, a mission is created.
-To call [missionManager](../reference/apis/js-apis-application-missionManager.md) to manage missions, the home screen application must request the **ohos.permission.MANAGE_MISSIONS** permission. For details about the configuration, see [Declaring Permissions in the Configuration File](../security/accesstoken-guidelines.md#declaring-permissions-in-the-configuration-file).
+1. To call [missionManager](../reference/apis/js-apis-application-missionManager.md) to manage missions, the home screen application must request the **ohos.permission.MANAGE_MISSIONS** permission. For details about the configuration, see [Declaring Permissions in the Configuration File](../security/accesstoken-guidelines.md#declaring-permissions-in-the-configuration-file).
-You can use **missionManager** to manage missions, for example, listening for mission changes, obtaining mission information or snapshots, and clearing, locking, or unlocking missions.
+2. You can use **missionManager** to manage missions, for example, listening for mission changes, obtaining mission information or snapshots, and clearing, locking, or unlocking missions.
```ts
import missionManager from '@ohos.app.ability.missionManager'
let listener = {
- // Listen for mission creation.
- onMissionCreated: function (mission) {
- console.info("--------onMissionCreated-------")
- },
- // Listen for mission destruction.
- onMissionDestroyed: function (mission) {
- console.info("--------onMissionDestroyed-------")
- },
- // Listen for mission snapshot changes.
- onMissionSnapshotChanged: function (mission) {
- console.info("--------onMissionSnapshotChanged-------")
- },
- // Listen for switching the mission to the foreground.
- onMissionMovedToFront: function (mission) {
- console.info("--------onMissionMovedToFront-------")
- },
- // Listen for mission icon changes.
- onMissionIconUpdated: function (mission, icon) {
- console.info("--------onMissionIconUpdated-------")
- },
- // Listen for mission name changes.
- onMissionLabelUpdated: function (mission) {
- console.info("--------onMissionLabelUpdated-------")
- },
- // Listen for mission closure events.
- onMissionClosed: function (mission) {
- console.info("--------onMissionClosed-------")
- }
+ // Listen for mission creation.
+ onMissionCreated: function (mission) {
+ console.info("--------onMissionCreated-------")
+ },
+ // Listen for mission destruction.
+ onMissionDestroyed: function (mission) {
+ console.info("--------onMissionDestroyed-------")
+ },
+ // Listen for mission snapshot changes.
+ onMissionSnapshotChanged: function (mission) {
+ console.info("--------onMissionSnapshotChanged-------")
+ },
+ // Listen for switching the mission to the foreground.
+ onMissionMovedToFront: function (mission) {
+ console.info("--------onMissionMovedToFront-------")
+ },
+ // Listen for mission icon changes.
+ onMissionIconUpdated: function (mission, icon) {
+ console.info("--------onMissionIconUpdated-------")
+ },
+ // Listen for mission name changes.
+ onMissionLabelUpdated: function (mission) {
+ console.info("--------onMissionLabelUpdated-------")
+ },
+ // Listen for mission closure events.
+ onMissionClosed: function (mission) {
+ console.info("--------onMissionClosed-------")
+ }
};
// 1. Register a mission change listener.
@@ -73,56 +73,56 @@ You can use **missionManager** to manage missions, for example, listening for mi
// 2. Obtain the latest 20 missions in the system.
missionManager.getMissionInfos("", 20, (error, missions) => {
- console.info("getMissionInfos is called, error.code = " + error.code);
- console.info("size = " + missions.length);
- console.info("missions = " + JSON.stringify(missions));
+ console.info("getMissionInfos is called, error.code = " + error.code);
+ console.info("size = " + missions.length);
+ console.info("missions = " + JSON.stringify(missions));
});
// 3. Obtain the detailed information about a mission.
let missionId = 11; // The mission ID 11 is only an example.
let mission = missionManager.getMissionInfo("", missionId).catch(function (err) {
- console.info(err);
+ console.info(err);
});
// 4. Obtain the mission snapshot.
missionManager.getMissionSnapShot("", missionId, (error, snapshot) => {
- console.info("getMissionSnapShot is called, error.code = " + error.code);
- console.info("bundleName = " + snapshot.ability.bundleName);
+ console.info("getMissionSnapShot is called, error.code = " + error.code);
+ console.info("bundleName = " + snapshot.ability.bundleName);
})
// 5. Obtain the low-resolution mission snapshot.
missionManager.getLowResolutionMissionSnapShot("", missionId, (error, snapshot) => {
- console.info("getLowResolutionMissionSnapShot is called, error.code = " + error.code);
- console.info("bundleName = " + snapshot.ability.bundleName);
+ console.info("getLowResolutionMissionSnapShot is called, error.code = " + error.code);
+ console.info("bundleName = " + snapshot.ability.bundleName);
})
// 6. Lock or unlock the mission.
missionManager.lockMission(missionId).then(() => {
- console.info("lockMission is called ");
+ console.info("lockMission is called ");
});
missionManager.unlockMission(missionId).then(() => {
- console.info("unlockMission is called ");
+ console.info("unlockMission is called ");
});
// 7. Switch the mission to the foreground.
missionManager.moveMissionToFront(missionId).then(() => {
- console.info("moveMissionToFront is called ");
+ console.info("moveMissionToFront is called ");
});
// 8. Clear a single mission.
missionManager.clearMission(missionId).then(() => {
- console.info("clearMission is called ");
+ console.info("clearMission is called ");
});
// 9. Clear all missions.
missionManager.clearAllMissions().catch(function (err) {
- console.info(err);
+ console.info(err);
});
// 10. Deregister the mission change listener.
missionManager.off('mission', listenerId, (error) => {
- console.info("unregisterMissionListener");
+ console.info("unregisterMissionListener");
})
```
diff --git a/en/application-dev/application-models/mission-set-icon-name-for-task-snapshot.md b/en/application-dev/application-models/mission-set-icon-name-for-task-snapshot.md
index c98d39ff8348f330d58138db89afcc2a0d5995ca..a5da1eeaa1d232b943f388b714b5a06f10d77be0 100644
--- 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
@@ -21,8 +21,10 @@ Call [UIAbilityContext.setMissionIcon()](../reference/apis/js-apis-inner-applica
```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}`);
+context.setMissionIcon(imagePixelMap, (err) => {
+ if (err.code) {
+ console.error(`Failed to set mission icon. Code is ${err.code}, message is ${err.message}`);
+ }
})
```
@@ -38,9 +40,9 @@ Call [UIAbilityContext.setMissionLabel()](../reference/apis/js-apis-inner-applic
```ts
this.context.setMissionLabel('test').then(() => {
- console.info('setMissionLabel succeeded.');
+ console.info('Succeeded in seting mission label.');
}).catch((err) => {
- console.error(`setMissionLabel failed, code is ${err.code}, message is ${err.message}`);
+ console.error(`Failed to set mission label. Code is ${err.code}, message is ${err.message}`);
});
```
diff --git a/en/application-dev/application-models/module-switch.md b/en/application-dev/application-models/module-switch.md
index 9f31f892cda1a077301773a129f4f7915cd25c82..749c41ebdd4ebe5c4c2a1e0b9628c5fbfe74cea4 100644
--- a/en/application-dev/application-models/module-switch.md
+++ b/en/application-dev/application-models/module-switch.md
@@ -3,7 +3,7 @@
When switching an application from the FA model to the stage model, you must migrate the configurations under the **module** tag in the **config.json** file to the **module** tag in the **module.json5** file.
-### Table 1 module Comparison
+**Table 1** module comparison
| Field Name in the FA Model| Field Description| Field Name in the Stage Model| Difference|
| -------- | -------- | -------- | -------- |
@@ -15,8 +15,8 @@ When switching an application from the FA model to the stage model, you must mig
| moduleType in the distro object| Type of the HAP file. The value can be **entry** or **feature**. For the HAR type, set this field to **har**.| type | The field name is changed.|
| installationFree in the distro object| Whether the HAP file supports the installation-free feature.| installationFree | The field name is changed.|
| deliveryWithInstall in the distro object| Whether the HAP file is installed with the application.| deliveryWithInstall | The field name is changed.|
-| metaData | Metadata of the HAP file.| metadata | See [Table 2](#table-2-metadata-comparison).|
-| abilities | All abilities in the current module.| abilities | See [Table 5](#table-5-abilities-comparison).|
+| metaData | Metadata of the HAP file.| metadata | For details, see Table 2.|
+| abilities | All abilities in the current module.| abilities | For details, see Table 5.|
| js | A set of JS modules developed using ArkUI. Each element in the set represents the information about a JS module.| pages | The stage model retains **pages** under the **module** tag. The window configuration is the lower level of **pages**.|
| shortcuts | Shortcuts of the application.| shortcut_config.json| In the stage model, the **shortcut_config.json** file is defined in **resources/base/profile** in the development view.|
| reqPermissions | Permissions that the application requests from the system when it is running.| requestPermissions | The field name is changed.|
@@ -27,38 +27,38 @@ When switching an application from the FA model to the stage model, you must mig
| entryTheme | Keyword of an OpenHarmony internal theme.| / | This configuration is not supported in the stage model.|
-### Table 2 metaData Comparison
+**Table 2** metaData comparison
-| Field Name Under metaData in the FA Model| Field Description| Field Name Under metaData in the Stage Model| Difference|
+| Field Name in the FA Model| Field Description| Field Name in the Stage Model| Difference|
| -------- | -------- | -------- | -------- |
| parameters | Metadata of the parameters to be passed for calling the ability.| / | This configuration is not supported in the stage model.|
| results | Metadata of the ability return value.| / | This configuration is not supported in the stage model.|
-| customizeData | Custom metadata of the parent component. **parameters** and **results** cannot be configured in **application**.| metadata | See [Table 3](#table-3-comparison-between-customizedata-under-metadata-in-the-fa-model-and-metadata-in-the-stage-model).|
+| customizeData | Custom metadata of the parent component. **parameters** and **results** cannot be configured in **application**.| metadata | **For details**, see Table 3.|
-### Table 3 Comparison Between customizeData Under metaData in the FA Model and metadata in the Stage Model
+**Table 3** Comparison between customizeData under metaData in the FA model and metadata in the stage Model
-| Field Name Under customizeData in metaData in the FA Model| Field Description| Field Name Under metaData in the Stage Model| Difference|
+| Field Name in the FA Model| Field Description| Field Name in the Stage Model| Difference|
| -------- | -------- | -------- | -------- |
| name | Key name that identifies a data item. The value is a string with a maximum of 255 bytes.| name | None.|
| value | Value of the data item. The value is a string with a maximum of 255 bytes.| value | None.|
-| extra | Format of the current custom data. The value is the resource value of **extra**.| resource | The field name is changed. For details, see [Table 4](#table 4-metadata-examples).|
+| extra | Format of the current custom data. The value is the resource value of **extra**.| resource | The field name is changed. For details, see Table 4.|
-### Table 4 metaData Examples
+**Table 4** metaData examples
| Example in the FA Model| Example in the Stage Model|
| -------- | -------- |
| "meteData": {
"customizeDate": [{
"name": "label",
"value": "string",
"extra": "$string:label",
}]
} | "meteData": [{
"name": "label",
"value": "string",
"resource": "$string:label",
}] |
-### Table 5 abilities Comparison
+**Table 5** abilities comparison
| Field Name Under abilities in the FA Model| Field Description| Field Name Under abilities in the Stage Model| Difference|
| -------- | -------- | -------- | -------- |
| process | Name of the process running the application or ability.| / | The stage model does not support configuration of **process** under **abilities**. The configuration of **process** is available under the **module** tag.|
| uri | URI of the ability.| / | This configuration is not supported in the stage model.|
| deviceCapability | Device capabilities required to run the ability.| / | This configuration is not supported in the stage model.|
-| metaData | Metadata of the ability.| metadata | See [Table 2](#table-2-metadata-comparison).|
+| metaData | Metadata of the ability.| metadata | For details, see Table 2.|
| type | Ability type.| / | This configuration is not supported in the stage model.|
| grantPermission | Whether permissions can be granted for any data in the ability.| / | The stage model does not support such a configuration under **abilities**.|
| readPermission | Permission required for reading data in the ability. This field applies only to the ability using the Data template.| / | In the stage model, this configuration is available under **extensionAbilities**, but not **abilities**.|
diff --git a/en/application-dev/application-models/page-mission-stack.md b/en/application-dev/application-models/page-mission-stack.md
index 702cb9ba928d5266ce6720d10538df6109b0cbeb..cdb7ce724f2a29c711d4d056bcda5716f265ba48 100644
--- a/en/application-dev/application-models/page-mission-stack.md
+++ b/en/application-dev/application-models/page-mission-stack.md
@@ -5,7 +5,8 @@
A single UIAbility component can implement multiple pages and redirection between these pages. The redirection relationship inside the UIAbility component is called page stack, which is managed by the ArkUI framework. For example, Page1 -> Page2 -> Page3 of UIAbility1 and PageA -> PageB -> PageC of UIAbility2 in the figure below are two page stacks.
- **Figure 1** Page stack
+**Figure 1** Page stack
+
![mission-record](figures/mission-record.png)
- A page stack is formed as follows (Steps 2, 3, 5, and 6 are page redirection and managed by ArkUI):
diff --git a/en/application-dev/application-models/pageability-launch-type.md b/en/application-dev/application-models/pageability-launch-type.md
index 3b75ff6a60899f19f08aad5235fb3dc49632cb01..1e5d14c3037261e66fb2decdede6779c079651bc 100644
--- a/en/application-dev/application-models/pageability-launch-type.md
+++ b/en/application-dev/application-models/pageability-launch-type.md
@@ -5,7 +5,7 @@ Depending on the launch type, the action performed when the PageAbility starts d
**Table 1** PageAbility launch types
-| Launch Type| Meaning | Description|
+| Launch Type| Meaning| Description |
| -------- | -------- | -------- |
| singleton | Singleton mode| Each time **startAbility()** is called, if an ability instance of this type already exists in the application process, the instance is reused. There is only one ability instance of this type in **Recents**.
A typical scenario is as follows: When a user opens a video playback application and watches a video, returns to the home screen, and opens the video playback application again, the video that the user watched before returning to the home screen is still played.|
| standard | Multiton mode| Default type. Each time **startAbility()** is called, a new ability instance is created in the application process. Multiple ability instances of this type are displayed in **Recents**.
A typical scenario is as follows: When a user opens a document application and touches **New**, a new document task is created. Multiple new document missions are displayed in **Recents**.|
@@ -16,13 +16,13 @@ You can set **launchType** in the **config.json** file to configure the launch t
```json
{
"module": {
- // ...
+ ...
"abilities": [
{
// singleton means the singleton mode.
// standard means the multiton mode.
"launchType": "standard",
- // ...
+ ...
}
]
}
diff --git a/en/application-dev/application-models/process-model-fa.md b/en/application-dev/application-models/process-model-fa.md
index 699643031121521fbf95d26a949df906fa175a18..ce4c9778d3bf678c7ecb8094477050a42eebb7d7 100644
--- a/en/application-dev/application-models/process-model-fa.md
+++ b/en/application-dev/application-models/process-model-fa.md
@@ -1,4 +1,4 @@
-# Process Model (FA Model)
+# Process Model Overview (FA Model)
The OpenHarmony process model is shown below.
diff --git a/en/application-dev/application-models/process-model-stage.md b/en/application-dev/application-models/process-model-stage.md
index 03da480722de124a1ede58da52e74cd48c5f23f0..cf758d94636773dfd190366d0e215de655902abd 100644
--- a/en/application-dev/application-models/process-model-stage.md
+++ b/en/application-dev/application-models/process-model-stage.md
@@ -1,4 +1,4 @@
-# Process Model (Stage Model)
+# Process Model Overview (Stage Model)
The OpenHarmony process model is shown below.
diff --git a/en/application-dev/application-models/redirection-rules.md b/en/application-dev/application-models/redirection-rules.md
index 4e9f65a8b3439fe4dde4761fbcb3d341151ba4f3..19c74c605cd7ca1451cef6809f6ec5238cec36df 100644
--- a/en/application-dev/application-models/redirection-rules.md
+++ b/en/application-dev/application-models/redirection-rules.md
@@ -21,11 +21,11 @@ To enable an ability to be called by any application, configure the **config.jso
```ts
{
"module": {
- // ...
+ ...
"abilities": [
{
"visible": "true",
- // ...
+ ...
}
]
}
diff --git a/en/application-dev/application-models/serviceextensionability.md b/en/application-dev/application-models/serviceextensionability.md
index 2e9aaeb48100d86d0cd1c7a0e69ea01bf4ef2340..3f9e96cf03318d900b428348bdb1bdfb0151f611 100644
--- a/en/application-dev/application-models/serviceextensionability.md
+++ b/en/application-dev/application-models/serviceextensionability.md
@@ -29,6 +29,7 @@ Note the following:
[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
+
![ServiceExtensionAbility-lifecycle](figures/ServiceExtensionAbility-lifecycle.png)
- **onCreate**
@@ -61,7 +62,7 @@ Note the following:
Only system applications can implement ServiceExtensionAbility. You must make the following preparations before development:
-- **Switching to the full SDK**: All APIs related to ServiceExtensionAbility are marked as system APIs and hidden by default. Therefore, you must manually obtain the full SDK from the mirror and switch to it in DevEco Studio. For details, see [Guide to Switching to Full SDK](../quick-start/full-sdk-switch-guide.md).
+- **Switching to the full SDK**: All APIs related to ServiceExtensionAbility are marked as system APIs and hidden by default. Therefore, you must manually obtain the full SDK from the mirror and switch to it in DevEco Studio. For details, see [Guide to Switching to Full SDK](../faqs/full-sdk-switch-guide.md).
- **Requesting the AllowAppUsePrivilegeExtension privilege**: Only applications with the **AllowAppUsePrivilegeExtension** privilege can develop ServiceExtensionAbility. For details about how to request the privilege, see [Application Privilege Configuration Guide](../../device-dev/subsystems/subsys-app-privilege-config-guide.md).
@@ -109,7 +110,7 @@ export default class ServiceExtImpl extends IdlServiceExtStub {
insertDataToMap(key: string, val: number, callback: insertDataToMapCallback): void {
// Implement service logic.
- console.log(TAG, `insertDataToMap, key: ${key} val: ${val}`);
+ console.info(TAG, `insertDataToMap, key: ${key} val: ${val}`);
callback(ERR_OK);
}
}
@@ -175,7 +176,7 @@ To manually create a ServiceExtensionAbility in the DevEco Studio project, perfo
```json
{
"module": {
- // ...
+ ...
"extensionAbilities": [
{
"name": "ServiceExtAbility",
@@ -201,41 +202,43 @@ A system application uses the [startServiceExtensionAbility()](../reference/apis
1. Start a new ServiceExtensionAbility in a system application. For details about how to obtain the context, see [Obtaining the Context of UIAbility](uiability-usage.md#obtaining-the-context-of-uiability).
```ts
+ let context = ...; // UIAbilityContext
let want = {
- "deviceId": "",
- "bundleName": "com.example.myapplication",
- "abilityName": "ServiceExtAbility"
+ "deviceId": "",
+ "bundleName": "com.example.myapplication",
+ "abilityName": "ServiceExtAbility"
};
- this.context.startServiceExtensionAbility(want).then(() => {
- console.info('startServiceExtensionAbility success');
- }).catch((error) => {
- console.info('startServiceExtensionAbility failed');
+ context.startServiceExtensionAbility(want).then(() => {
+ console.info('Succeeded in starting ServiceExtensionAbility.');
+ }).catch((err) => {
+ console.error(`Failed to start ServiceExtensionAbility. Code is ${err.code}, message is ${err.message}`);
})
```
2. Stop ServiceExtensionAbility in the system application.
```ts
+ let context = ...; // UIAbilityContext
let want = {
- "deviceId": "",
- "bundleName": "com.example.myapplication",
- "abilityName": "ServiceExtAbility"
+ "deviceId": "",
+ "bundleName": "com.example.myapplication",
+ "abilityName": "ServiceExtAbility"
};
- this.context.stopServiceExtensionAbility(want).then(() => {
- console.info('stopServiceExtensionAbility success');
- }).catch((error) => {
- console.info('stopServiceExtensionAbility failed');
+ context.stopServiceExtensionAbility(want).then(() => {
+ console.info('Succeeded in stoping ServiceExtensionAbility.');
+ }).catch((err) => {
+ console.error(`Failed to stop ServiceExtensionAbility. Code is ${err.code}, message is ${err.message}`);
})
```
3. ServiceExtensionAbility stops itself.
```ts
- // this is the current ServiceExtensionAbility component.
- this.context.terminateSelf().then(() => {
- console.info('terminateSelf success');
- }).catch((error) => {
- console.info('terminateSelf failed');
+ let context = ...; // ServiceExtensionContext
+ context.terminateSelf().then(() => {
+ console.info('Succeeded in terminating self.');
+ }).catch((err) => {
+ console.error(`Failed to terminate self. Code is ${err.code}, message is ${err.message}`);
})
```
@@ -257,27 +260,27 @@ The ServiceExtensionAbility component returns an IRemoteObject in the **onConnec
```ts
let want = {
- "deviceId": "",
- "bundleName": "com.example.myapplication",
- "abilityName": "ServiceExtAbility"
+ "deviceId": "",
+ "bundleName": "com.example.myapplication",
+ "abilityName": "ServiceExtAbility"
};
let options = {
- onConnect(elementName, remote) {
- /* The input parameter remote is the object returned by ServiceExtensionAbility in the onConnect lifecycle callback.
- * This object is used for communication with ServiceExtensionAbility. For details, see the section below.
- */
- console.info('onConnect callback');
- if (remote === null) {
- console.info(`onConnect remote is null`);
- return;
- }
- },
- onDisconnect(elementName) {
- console.info('onDisconnect callback')
- },
- onFailed(code) {
- console.info('onFailed callback')
+ onConnect(elementName, remote) {
+ /* The input parameter remote is the object returned by ServiceExtensionAbility in the onConnect lifecycle callback.
+ * This object is used for communication with ServiceExtensionAbility. For details, see the section below.
+ */
+ console.info('onConnect callback');
+ if (remote === null) {
+ console.info(`onConnect remote is null`);
+ return;
}
+ },
+ onDisconnect(elementName) {
+ console.info('onDisconnect callback')
+ },
+ onFailed(code) {
+ console.info('onFailed callback')
+ }
}
// The ID returned after the connection is set up must be saved. The ID will be passed for service disconnection.
let connectionId = this.context.connectServiceExtensionAbility(want, options);
@@ -288,9 +291,9 @@ The ServiceExtensionAbility component returns an IRemoteObject in the **onConnec
```ts
// connectionId is returned when connectServiceExtensionAbility is called and needs to be manually maintained.
this.context.disconnectServiceExtensionAbility(connectionId).then((data) => {
- console.info('disconnectServiceExtensionAbility success');
+ console.info('disconnectServiceExtensionAbility success');
}).catch((error) => {
- console.error('disconnectServiceExtensionAbility failed');
+ console.error('disconnectServiceExtensionAbility failed');
})
```
@@ -305,27 +308,27 @@ After obtaining the [rpc.RemoteObject](../reference/apis/js-apis-rpc.md#iremoteo
import IdlServiceExtProxy from '../IdlServiceExt/idl_service_ext_proxy';
let options = {
- onConnect(elementName, remote) {
- console.info('onConnect callback');
- if (remote === null) {
- console.info(`onConnect remote is null`);
- return;
- }
- let serviceExtProxy = new IdlServiceExtProxy(remote);
- // Communication is carried out by interface calling, without exposing RPC details.
- serviceExtProxy.processData(1, (errorCode, retVal) => {
- console.log(`processData, errorCode: ${errorCode}, retVal: ${retVal}`);
- });
- serviceExtProxy.insertDataToMap('theKey', 1, (errorCode) => {
- console.log(`insertDataToMap, errorCode: ${errorCode}`);
- })
- },
- onDisconnect(elementName) {
- console.info('onDisconnect callback')
- },
- onFailed(code) {
- console.info('onFailed callback')
+ onConnect(elementName, remote) {
+ console.info('onConnect callback');
+ if (remote === null) {
+ console.info(`onConnect remote is null`);
+ return;
}
+ let serviceExtProxy = new IdlServiceExtProxy(remote);
+ // Communication is carried out by interface calling, without exposing RPC details.
+ serviceExtProxy.processData(1, (errorCode, retVal) => {
+ console.info(`processData, errorCode: ${errorCode}, retVal: ${retVal}`);
+ });
+ serviceExtProxy.insertDataToMap('theKey', 1, (errorCode) => {
+ console.info(`insertDataToMap, errorCode: ${errorCode}`);
+ })
+ },
+ onDisconnect(elementName) {
+ console.info('onDisconnect callback')
+ },
+ onFailed(code) {
+ console.info('onFailed callback')
+ }
}
```
@@ -333,40 +336,40 @@ After obtaining the [rpc.RemoteObject](../reference/apis/js-apis-rpc.md#iremoteo
```ts
import rpc from '@ohos.rpc';
-
+
const REQUEST_CODE = 1;
let options = {
- onConnect(elementName, remote) {
- console.info('onConnect callback');
- if (remote === null) {
- console.info(`onConnect remote is null`);
- return;
- }
- // Directly call the RPC interface to send messages to the server. The client needs to serialize the input parameters and deserialize the return values. The process is complex.
- let option = new rpc.MessageOption();
- let data = new rpc.MessageSequence();
- let reply = new rpc.MessageSequence();
- data.writeInt(100);
-
- // @param code Indicates the service request code sent by the client.
- // @param data Indicates the {@link MessageSequence} object sent by the client.
- // @param reply Indicates the response message object sent by the remote service.
- // @param options Specifies whether the operation is synchronous or asynchronous.
- //
- // @return Returns {@code true} if the operation is successful; returns {@code false} otherwise.
- remote.sendMessageRequest(REQUEST_CODE, data, reply, option).then((ret) => {
- let msg = reply.readInt();
- console.info(`sendMessageRequest ret:${ret} msg:${msg}`);
- }).catch((error) => {
- console.info('sendMessageRequest failed');
- });
- },
- onDisconnect(elementName) {
- console.info('onDisconnect callback')
- },
- onFailed(code) {
- console.info('onFailed callback')
+ onConnect(elementName, remote) {
+ console.info('onConnect callback');
+ if (remote === null) {
+ console.info(`onConnect remote is null`);
+ return;
}
+ // Directly call the RPC interface to send messages to the server. The client needs to serialize the input parameters and deserialize the return values. The process is complex.
+ let option = new rpc.MessageOption();
+ let data = new rpc.MessageSequence();
+ let reply = new rpc.MessageSequence();
+ data.writeInt(100);
+
+ // @param code Indicates the service request code sent by the client.
+ // @param data Indicates the {@link MessageSequence} object sent by the client.
+ // @param reply Indicates the response message object sent by the remote service.
+ // @param options Specifies whether the operation is synchronous or asynchronous.
+ //
+ // @return Returns {@code true} if the operation is successful; returns {@code false} otherwise.
+ remote.sendMessageRequest(REQUEST_CODE, data, reply, option).then((ret) => {
+ let msg = reply.readInt();
+ console.info(`sendMessageRequest ret:${ret} msg:${msg}`);
+ }).catch((error) => {
+ console.info('sendMessageRequest failed');
+ });
+ },
+ onDisconnect(elementName) {
+ console.info('onDisconnect callback')
+ },
+ onFailed(code) {
+ console.info('onFailed callback')
+ }
}
```
@@ -381,8 +384,8 @@ When ServiceExtensionAbility is used to provide sensitive services, the client i
```ts
import rpc from '@ohos.rpc';
import bundleManager from '@ohos.bundle.bundleManager';
- import {processDataCallback} from './i_idl_service_ext';
- import {insertDataToMapCallback} from './i_idl_service_ext';
+ import { processDataCallback } from './i_idl_service_ext';
+ import { insertDataToMapCallback } from './i_idl_service_ext';
import IdlServiceExtStub from './idl_service_ext_stub';
const ERR_OK = 0;
@@ -397,7 +400,7 @@ When ServiceExtensionAbility is used to provide sensitive services, the client i
bundleManager.getBundleNameByUid(callerUid).then((callerBundleName) => {
console.info(TAG, 'getBundleNameByUid: ' + callerBundleName);
// Identify the bundle name of the client.
- if (callerBundleName != 'com.example.connectextapp') { // The verification fails.
+ if (callerBundleName != 'com.example.connectextapp') { // The verification fails.
console.info(TAG, 'The caller bundle is not in whitelist, reject');
return;
}
@@ -409,7 +412,7 @@ When ServiceExtensionAbility is used to provide sensitive services, the client i
insertDataToMap(key: string, val: number, callback: insertDataToMapCallback): void {
// Implement service logic.
- console.log(TAG, `insertDataToMap, key: ${key} val: ${val}`);
+ console.info(TAG, `insertDataToMap, key: ${key} val: ${val}`);
callback(ERR_OK);
}
}
@@ -425,15 +428,15 @@ When ServiceExtensionAbility is used to provide sensitive services, the client i
import {processDataCallback} from './i_idl_service_ext';
import {insertDataToMapCallback} from './i_idl_service_ext';
import IdlServiceExtStub from './idl_service_ext_stub';
-
+
const ERR_OK = 0;
const ERR_DENY = -1;
const TAG: string = "[IdlServiceExtImpl]";
-
+
export default class ServiceExtImpl extends IdlServiceExtStub {
processData(data: number, callback: processDataCallback): void {
console.info(TAG, `processData: ${data}`);
-
+
let callerTokenId = rpc.IPCSkeleton.getCallingTokenId();
let accessManger = abilityAccessCtrl.createAtManager();
// The permission to be verified varies depending on the service requirements. ohos.permission.SET_WALLPAPER is only an example.
@@ -446,10 +449,10 @@ When ServiceExtensionAbility is used to provide sensitive services, the client i
}
callback(ERR_OK, data + 1); // The verification is successful, and service logic is executed normally.
}
-
+
insertDataToMap(key: string, val: number, callback: insertDataToMapCallback): void {
// Implement service logic.
- console.log(TAG, `insertDataToMap, key: ${key} val: ${val}`);
+ console.info(TAG, `insertDataToMap, key: ${key} val: ${val}`);
callback(ERR_OK);
}
}
diff --git a/en/application-dev/application-models/stage-model-development-overview.md b/en/application-dev/application-models/stage-model-development-overview.md
index 451649bdb1a63147b79f8c7e2d4523d6c651c548..d4ad1d87c602c169e13b9ff99b8b491a33babd0a 100644
--- a/en/application-dev/application-models/stage-model-development-overview.md
+++ b/en/application-dev/application-models/stage-model-development-overview.md
@@ -12,7 +12,7 @@ The following figure shows the basic concepts used in the stage model.
The stage model provides two types of application components: UIAbility and ExtensionAbility. Both have specific classes and support object-oriented development.
- - UIAbility has the UI and is mainly used for user interaction. For example, with UIAbility, the Gallery application can display images in the liquid layout. After a user selects an image, it uses a new UI to display the image details. The user can touch the **Back** button to return to the liquid layout. The lifecycle of the UIAbility component contains the creation, destruction, foreground, and background states. Display-related states are exposed through WindowStage events.
+ - UIAbility is a type of application component that provides the UI for user interaction. For example, with UIAbility, the Gallery application can display images in the liquid layout. After a user selects an image, it uses a new UI to display the image details. The user can touch the **Back** button to return to the liquid layout. The lifecycle of the UIAbility component contains the creation, destruction, foreground, and background states. Display-related states are exposed through WindowStage events.
- ExtensionAbility is oriented to specific scenarios. You cannot derive directly from ExtensionAbility. Instead, use the derived classes of ExtensionAbility for your scenarios, such as FormExtensionAbility for widget scenarios, InputMethodExtensionAbility for input method scenarios, and WorkSchedulerExtensionAbility for Work Scheduled task scenarios. For example, to enable a user to create an application widget on the home screen, you must derive FormExtensionAbility, implement the callback functions, and configure the capability in the configuration file. The derived class instances are created by developers and their lifecycles are managed by the system. In the stage model, you must use the derived classes of ExtensionAbility to develop custom services based on your service scenarios.
- [WindowStage](../windowmanager/application-window-stage.md)
@@ -37,7 +37,7 @@ During application development based on the stage model, the following tasks are
| Task| Introduction| Guide|
| -------- | -------- | -------- |
| Application component development| Use the UIAbility and ExtensionAbility components of the stage model to develop applications.| - [Application- or Component-Level Configuration](application-component-configuration-stage.md)
- [UIAbility Component](uiability-overview.md)
- [ExtensionAbility Component](extensionability-overview.md)
- [AbilityStage Container Component](abilitystage.md)
- [Context](application-context-stage.md)
- [Component Startup Rules](component-startup-rules.md)|
-| Inter-process communication (IPC)| Learn the process model and common IPC modes of the stage model.| - [Common Events](common-event-overview.md)
- [Background Services](background-services.md)|
-| Inter-thread communication| Learn the thread model and common inter-thread communication modes of the stage model.| - [Emitter](itc-with-emitter.md)
- [Worker](itc-with-worker.md)|
+| Process model| Learn the process model and common IPC modes of the stage model.| - [Common Events](common-event-overview.md)
- [Background Services](background-services.md)|
+| Thread model| Learn the thread model and common inter-thread communication modes of the stage model.| - [Emitter](itc-with-emitter.md)
- [Worker](itc-with-worker.md)|
| Mission management| Learn the basic concepts and typical scenarios of mission management in the stage model.| - [Mission Management Scenarios](mission-management-overview.md)
- [Mission Management and Launch Type](mission-management-launch-type.md)
- [Page Stack and Mission List](page-mission-stack.md)|
| Application configuration file| Learn the requirements for developing application configuration files in the stage model.| [Application Configuration File](config-file-stage.md)|
diff --git a/en/application-dev/application-models/start-page.md b/en/application-dev/application-models/start-page.md
index 5831ea0c6f6b6fa9d954134ef723f70e925e3ed7..1def472cd5fa2567fda123fc272542787b1f985c 100644
--- a/en/application-dev/application-models/start-page.md
+++ b/en/application-dev/application-models/start-page.md
@@ -83,7 +83,7 @@ struct Index {
@State message: string = 'Hello World'
build() {
- // ...
+ ...
Button("startAbility")
.onClick(() => {
featureAbility.startAbility({
@@ -98,7 +98,7 @@ struct Index {
console.info("startAbility failed errcode:" + err.code)
})
})
- // ...
+ ...
Button("page2")
.onClick(() => {
featureAbility.startAbility({
@@ -113,7 +113,7 @@ struct Index {
console.info("startAbility failed errcode:" + err.code)
})
})
- // ...
+ ...
}
}
```
@@ -136,7 +136,7 @@ export default {
})
},
onDestroy() {
- // ...
+ ...
},
}
```
diff --git a/en/application-dev/application-models/start-pageability-from-stage.md b/en/application-dev/application-models/start-pageability-from-stage.md
index 9d1b7ed27f6780ce56d1e90b3be5d196cf3b1187..bd6a11187fdfbc81c63bcc6601f8a8e82b0dbe4c 100644
--- a/en/application-dev/application-models/start-pageability-from-stage.md
+++ b/en/application-dev/application-models/start-pageability-from-stage.md
@@ -21,7 +21,7 @@ export default class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage) {
console.info("EntryAbility onWindowStageCreate")
windowStage.loadContent('pages/Index', (err, data) => {
- // ...
+ ...
});
let want = {
bundleName: "com.ohos.fa",
@@ -66,7 +66,7 @@ export default class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage) {
console.info("EntryAbility onWindowStageCreate")
windowStage.loadContent('pages/Index', (err, data) => {
- // ...
+ ...
});
let want = {
bundleName: "com.ohos.fa",
diff --git a/en/application-dev/application-models/start-remote-pageability.md b/en/application-dev/application-models/start-remote-pageability.md
index 36ee305b49698c1f6e6cf216174f77212f1d53e4..a52378af306c9719b086b23f0909f87d7bf376b3 100644
--- a/en/application-dev/application-models/start-remote-pageability.md
+++ b/en/application-dev/application-models/start-remote-pageability.md
@@ -83,28 +83,31 @@ After obtaining the data synchronization permission, obtain the trusted device l
The following sample code shows how to use **getTrustedDeviceListSync()** to obtain the trusted device list.
```ts
-import deviceManager from '@ohos.distributedHardware.deviceManager';
-let dmClass;
+import deviceManager from '@ohos.distributedHardware.deviceManager';
+
+let dmClass;
+
function getDeviceManager() {
- deviceManager.createDeviceManager('ohos.example.distributedService', (error, dm) => {
- if (error) {
- console.info('create device manager failed with ' + error)
- }
- dmClass = dm;
- })
+ deviceManager.createDeviceManager('ohos.example.distributedService', (error, dm) => {
+ if (error) {
+ console.info('create device manager failed with ' + error)
+ }
+ dmClass = dm;
+ })
}
-function getRemoteDeviceId() {
- if (typeof dmClass === 'object' && dmClass != null) {
- let list = dmClass.getTrustedDeviceListSync();
- if (typeof (list) == 'undefined' || typeof (list.length) == 'undefined') {
- console.info("EntryAbility onButtonClick getRemoteDeviceId err: list is null");
- return;
- }
- console.info("EntryAbility onButtonClick getRemoteDeviceId success:" + list[0].deviceId);
- return list[0].deviceId;
- } else {
- console.info("EntryAbility onButtonClick getRemoteDeviceId err: dmClass is null");
- }
+
+function getRemoteDeviceId() {
+ if (typeof dmClass === 'object' && dmClass != null) {
+ let list = dmClass.getTrustedDeviceListSync();
+ if (typeof (list) == 'undefined' || typeof (list.length) == 'undefined') {
+ console.info("EntryAbility onButtonClick getRemoteDeviceId err: list is null");
+ return;
+ }
+ console.info("EntryAbility onButtonClick getRemoteDeviceId success:" + list[0].deviceId);
+ return list[0].deviceId;
+ } else {
+ console.info("EntryAbility onButtonClick getRemoteDeviceId err: dmClass is null");
+ }
}
```
@@ -116,21 +119,22 @@ The following sample code shows how to explicitly start a remote PageAbility thr
```ts
import featureAbility from '@ohos.ability.featureAbility';
-function onStartRemoteAbility() {
- console.info('onStartRemoteAbility begin');
- let params;
- let wantValue = {
- bundleName: 'ohos.samples.etsDemo',
- abilityName: 'ohos.samples.etsDemo.RemoteAbility',
- deviceId: getRemoteDeviceId(), // getRemoteDeviceId is defined in the preceding sample code.
- parameters: params
- };
- console.info('onStartRemoteAbility want=' + JSON.stringify(wantValue));
- featureAbility.startAbility({
- want: wantValue
- }).then((data) => {
- console.info('onStartRemoteAbility finished, ' + JSON.stringify(data));
- });
- console.info('onStartRemoteAbility end');
+
+function onStartRemoteAbility() {
+ console.info('onStartRemoteAbility begin');
+ let params;
+ let wantValue = {
+ bundleName: 'ohos.samples.etsDemo',
+ abilityName: 'ohos.samples.etsDemo.RemoteAbility',
+ deviceId: getRemoteDeviceId(), // getRemoteDeviceId is defined in the preceding sample code.
+ parameters: params
+ };
+ console.info('onStartRemoteAbility want=' + JSON.stringify(wantValue));
+ featureAbility.startAbility({
+ want: wantValue
+ }).then((data) => {
+ console.info('onStartRemoteAbility finished, ' + JSON.stringify(data));
+ });
+ console.info('onStartRemoteAbility end');
}
```
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
index c231f483e9bcd8f83faf49d40007730d0f854de5..4eecf15808da492ca69d933fdabf39aa82347ce5 100644
--- a/en/application-dev/application-models/subscribe-system-environment-variable-changes.md
+++ b/en/application-dev/application-models/subscribe-system-environment-variable-changes.md
@@ -54,7 +54,7 @@ In OpenHarmony, you can subscribe to system environment variable changes in the
// Page display.
build() {
- // ...
+ ...
}
}
```
@@ -77,7 +77,7 @@ In OpenHarmony, you can subscribe to system environment variable changes in the
// Page display.
build() {
- // ...
+ ...
}
}
```
@@ -99,19 +99,19 @@ 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} `);
- }
+ 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)}`);
+ 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.
- }
+ 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.
}
+ }
}
```
@@ -131,21 +131,21 @@ 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} `);
- }
+ 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)}`);
+ 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.
- }
+ 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.
}
+ }
- // ...
+ ...
}
```
@@ -163,10 +163,10 @@ The code snippet below uses FormExtensionAbility as an example to describe how t
import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
export default class EntryFormAbility extends FormExtensionAbility {
- onConfigurationUpdate(newConfig) {
- console.info(`newConfig is ${JSON.stringify(newConfig)}`);
- }
+ onConfigurationUpdate(newConfig) {
+ console.info(`newConfig is ${JSON.stringify(newConfig)}`);
+ }
- // ...
+ ...
}
```
diff --git a/en/application-dev/application-models/thread-model-fa.md b/en/application-dev/application-models/thread-model-fa.md
index 75401be69cba994ac631b6da997fb6ce2ea35a2f..f6b335f8932ee1ebd5bb9bdf11db99ff354a1470 100644
--- a/en/application-dev/application-models/thread-model-fa.md
+++ b/en/application-dev/application-models/thread-model-fa.md
@@ -1,13 +1,11 @@
-# Thread Model (FA Model)
-
+# Thread Model Overview (FA Model)
There are three types of threads in the FA model:
-
- Main thread
-
-Manages other threads.
-
+
+ Manages other threads.
+
- Ability thread
- One ability thread for each ability.
- Distributes input events.
@@ -19,10 +17,8 @@ Manages other threads.
Performs time-consuming operations
-
Based on the OpenHarmony thread model, different services run on different threads. Service interaction requires inter-thread communication. Threads can communicate with each other in Emitter or Worker mode. Emitter is mainly used for event synchronization between threads, and Worker is mainly used to execute time-consuming tasks.
-
> **NOTE**
>
> The FA model provides an independent thread for each ability. Emitter is mainly used for event synchronization within the ability thread, between a pair of ability threads, or between the ability thread and worker thread.
diff --git a/en/application-dev/application-models/thread-model-stage.md b/en/application-dev/application-models/thread-model-stage.md
index 4ca9fb3ed369f78cf12054c7b6da085b8640b1db..2b1f855980a14eeba89a18184c69d46eebaea6ac 100644
--- a/en/application-dev/application-models/thread-model-stage.md
+++ b/en/application-dev/application-models/thread-model-stage.md
@@ -1,4 +1,4 @@
-# Thread Model (Stage Model)
+# Thread Model Overview (Stage Model)
For an OpenHarmony application, each process has a main thread to provide the following functionalities:
@@ -17,5 +17,6 @@ Based on the OpenHarmony thread model, different services run on different threa
> **NOTE**
>
-> - The stage model provides only the main thread and worker thread. Emitter is mainly used for event synchronization within the main thread or between the main thread and worker thread.
-> - To view thread information about an application process, run the **hdc shell** command to enter the shell CLI of the device, and then run the **ps -p ** -T command**, where ** indicates the ID of the application process.
+> - The stage model provides only the main thread and worker thread. Emitter is mainly used for event synchronization within the worker thread or between the main thread and worker thread.
+> - The UIAbility and UI are in the main thread. For details about data synchronization between them, see [Data Synchronization Between UIAbility and UI](uiability-data-sync-with-ui.md).
+> - To view thread information about an application process, run the **hdc shell** command to enter the shell CLI of the device, and then run the **ps -p ** -T command**, where ** indicates the [process ID](process-model-stage.md) of the application.
diff --git a/en/application-dev/application-models/uiability-data-sync-with-ui.md b/en/application-dev/application-models/uiability-data-sync-with-ui.md
index 52967c25c86966710853378c95c74d5e6e13e432..6998001c763a464e51f8cef4a0c64aec6f1db5e8 100644
--- a/en/application-dev/application-models/uiability-data-sync-with-ui.md
+++ b/en/application-dev/application-models/uiability-data-sync-with-ui.md
@@ -22,21 +22,21 @@ Before using the APIs provided by **EventHub**, you must obtain an **EventHub**
const TAG: string = '[Example].[Entry].[EntryAbility]';
export default class EntryAbility extends UIAbility {
- func1(...data) {
- // Trigger the event to complete the service operation.
- console.info(TAG, '1. ' + JSON.stringify(data));
- }
-
- onCreate(want, launch) {
- // Obtain an eventHub object.
- let eventhub = this.context.eventHub;
- // Subscribe to the event.
- eventhub.on('event1', this.func1);
- eventhub.on('event1', (...data) => {
- // Trigger the event to complete the service operation.
- console.info(TAG, '2. ' + JSON.stringify(data));
- });
- }
+ func1(...data) {
+ // Trigger the event to complete the service operation.
+ console.info(TAG, '1. ' + JSON.stringify(data));
+ }
+
+ onCreate(want, launch) {
+ // Obtain an eventHub object.
+ let eventhub = this.context.eventHub;
+ // Subscribe to the event.
+ eventhub.on('event1', this.func1);
+ eventhub.on('event1', (...data) => {
+ // Trigger the event to complete the service operation.
+ console.info(TAG, '2. ' + JSON.stringify(data));
+ });
+ }
}
```
@@ -62,7 +62,7 @@ Before using the APIs provided by **EventHub**, you must obtain an **EventHub**
// Page display.
build() {
- // ...
+ ...
}
}
```
@@ -90,8 +90,7 @@ Before using the APIs provided by **EventHub**, you must obtain an **EventHub**
**globalThis** is a global object inside the [ArkTS engine instance](thread-model-stage.md) and can be used by UIAbility, ExtensionAbility, and Page inside the engine. Therefore, you can use **globalThis** for data synchronization.
**Figure 1** Using globalThis for data synchronization
-
- ![globalThis1](figures/globalThis1.png)
+![globalThis1](figures/globalThis1.png)
The following describes how to use **globalThis** in three scenarios. Precautions are provided as well.
@@ -105,18 +104,18 @@ The following describes how to use **globalThis** in three scenarios. Precaution
By binding attributes or methods to **globalThis**, you can implement data synchronization between the UIAbility component and UI. For example, if you bind the **want** parameter in the UIAbility component, you can use the **want** parameter information on the UI corresponding to the UIAbility component.
-1. When [startAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability) is called to start a UIAbility instance, the **onCreate()** callback is invoked, and the **want** parameter can be passed in the callback. Therefore, you can bind the **want** parameter to **globalThis**.
+1. When [startAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability) is called to start a UIAbility instance, the [onCreate()](../reference/apis/js-apis-app-ability-uiAbility.md#uiabilityoncreate) callback is invoked, and the **want** parameter can be passed in the callback. Therefore, you can bind the **want** parameter to **globalThis**.
```ts
import UIAbility from '@ohos.app.ability.UIAbility';
export default class EntryAbility extends UIAbility {
- onCreate(want, launch) {
- globalThis.entryAbilityWant = want;
- // ...
- }
+ onCreate(want, launch) {
+ globalThis.entryAbilityWant = want;
+ ...
+ }
- // ...
+ ...
}
```
@@ -124,17 +123,17 @@ By binding attributes or methods to **globalThis**, you can implement data synch
```ts
let entryAbilityWant;
-
+
@Entry
@Component
struct Index {
aboutToAppear() {
entryAbilityWant = globalThis.entryAbilityWant;
}
-
+
// Page display.
build() {
- // ...
+ ...
}
}
```
@@ -150,10 +149,10 @@ To implement data synchronization between two UIAbility components in the same a
import UIAbility from '@ohos.app.ability.UIAbility'
export default class UIAbilityA extends UIAbility {
- onCreate(want, launch) {
- globalThis.entryAbilityStr = 'UIAbilityA'; // UIAbilityA stores the string "UIAbilityA" to globalThis.
- // ...
- }
+ onCreate(want, launch) {
+ globalThis.entryAbilityStr = 'UIAbilityA'; // UIAbilityA stores the string "UIAbilityA" to globalThis.
+ ...
+ }
}
```
@@ -161,13 +160,13 @@ To implement data synchronization between two UIAbility components in the same a
```ts
import UIAbility from '@ohos.app.ability.UIAbility'
-
+
export default class UIAbilityB extends UIAbility {
- onCreate(want, launch) {
- // UIAbilityB reads name from globalThis and outputs it.
- console.info('name from entryAbilityStr: ' + globalThis.entryAbilityStr);
- // ...
- }
+ onCreate(want, launch) {
+ // UIAbilityB reads name from globalThis and outputs it.
+ console.info('name from entryAbilityStr: ' + globalThis.entryAbilityStr);
+ ...
+ }
}
```
@@ -182,11 +181,11 @@ To implement data synchronization between the UIAbility and ExtensionAbility com
import UIAbility from '@ohos.app.ability.UIAbility'
export default class UIAbilityA extends UIAbility {
- onCreate(want, launch) {
- // UIAbilityA stores the string "UIAbilityA" to globalThis.
- globalThis.entryAbilityStr = 'UIAbilityA';
- // ...
- }
+ onCreate(want, launch) {
+ // UIAbilityA stores the string "UIAbilityA" to globalThis.
+ globalThis.entryAbilityStr = 'UIAbilityA';
+ ...
+ }
}
```
@@ -194,21 +193,20 @@ To implement data synchronization between the UIAbility and ExtensionAbility com
```ts
import Extension from '@ohos.app.ability.ServiceExtensionAbility'
-
+
export default class ServiceExtAbility extends Extension {
- onCreate(want) {
- / / ServiceExtAbility reads name from globalThis and outputs it.
- console.info('name from entryAbilityStr: ' + globalThis.entryAbilityStr);
- // ...
- }
+ onCreate(want) {
+ / / ServiceExtAbility reads name from globalThis and outputs it.
+ console.info('name from entryAbilityStr: ' + globalThis.entryAbilityStr);
+ ...
+ }
}
```
### Precautions for Using globalThis
-**Figure 2** Precautions for globalThis
-
+**Figure 2** Precautions for globalThis
![globalThis2](figures/globalThis2.png)
- In the stage model, all the UIAbility components in a process share one ArkTS engine instance. When using **globalThis**, do not store objects with the same name. For example, if UIAbilityA and UIAbilityB use **globalThis** to store two objects with the same name, the object stored earlier will be overwritten.
@@ -225,10 +223,10 @@ The following provides an example to describe the object overwritten problem in
import UIAbility from '@ohos.app.ability.UIAbility'
export default class UIAbilityA extends UIAbility {
- onCreate(want, launch) {
- globalThis.context = this.context; // UIAbilityA stores the context in globalThis.
- // ...
- }
+ onCreate(want, launch) {
+ globalThis.context = this.context; // UIAbilityA stores the context in globalThis.
+ ...
+ }
}
```
@@ -243,7 +241,7 @@ The following provides an example to describe the object overwritten problem in
}
// Page display.
build() {
- // ...
+ ...
}
}
```
@@ -254,11 +252,11 @@ The following provides an example to describe the object overwritten problem in
import UIAbility from '@ohos.app.ability.UIAbility'
export default class UIAbilityB extends UIAbility {
- onCreate(want, launch) {
- // UIAbilityB overwrites the context stored by UIAbilityA in globalThis.
- globalThis.context = this.context;
- // ...
- }
+ onCreate(want, launch) {
+ // UIAbilityB overwrites the context stored by UIAbilityA in globalThis.
+ globalThis.context = this.context;
+ ...
+ }
}
```
@@ -273,7 +271,7 @@ The following provides an example to describe the object overwritten problem in
}
// Page display.
build() {
- // ...
+ ...
}
}
```
@@ -284,10 +282,10 @@ The following provides an example to describe the object overwritten problem in
import UIAbility from '@ohos.app.ability.UIAbility'
export default class UIAbilityA extends UIAbility {
- onCreate(want, launch) { // UIAbilityA will not enter this lifecycle.
- globalThis.context = this.context;
- // ...
- }
+ onCreate(want, launch) { // UIAbilityA will not enter this lifecycle.
+ globalThis.context = this.context;
+ ...
+ }
}
```
@@ -302,7 +300,7 @@ The following provides an example to describe the object overwritten problem in
}
// Page display.
build() {
- // ...
+ ...
}
}
```
@@ -310,5 +308,3 @@ The following provides an example to describe the object overwritten problem in
## Using AppStorage or LocalStorage for Data Synchronization
ArkUI provides AppStorage and LocalStorage to implement application- and UIAbility-level data synchronization, respectively. Both solutions can be used to manage the application state, enhance application performance, and improve user experience. The AppStorage is a global state manager and is applicable when multiple UIAbilities share the same state data. The LocalStorage is a local state manager that manages state data used inside a single UIAbility. They help you control the application state more flexibly and improve the maintainability and scalability of applications. For details, see [State Management of Application-Level Variables](../quick-start/arkts-application-state-management-overview.md).
-
-
\ No newline at end of file
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 9dbbc2be90107d2131a1cdae21e576cb4771966e..208fd1af3bb9912439a8a50d3ce35f5a5d58596e 100644
--- a/en/application-dev/application-models/uiability-intra-device-interaction.md
+++ b/en/application-dev/application-models/uiability-intra-device-interaction.md
@@ -32,20 +32,20 @@ Assume that your application has two UIAbility components: EntryAbility and Func
```ts
let context = ...; // UIAbilityContext
- let wantInfo = {
+ let want = {
deviceId: '', // An empty deviceId indicates the local device.
bundleName: 'com.example.myapplication',
abilityName: 'FuncAbility',
- moduleName: 'module1', // moduleName is optional.
+ moduleName: 'func', // moduleName is optional.
parameters: {// Custom information.
info: 'From the Index page of EntryAbility',
},
}
// context is the UIAbilityContext of the initiator UIAbility.
- context.startAbility(wantInfo).then(() => {
- // ...
+ context.startAbility(want).then(() => {
+ console.info('Succeeded in starting ability.');
}).catch((err) => {
- // ...
+ console.error(`Failed to start ability. Code is ${err.code}, message is ${err.message}`);
})
```
@@ -53,18 +53,17 @@ Assume that your application has two UIAbility components: EntryAbility and Func
```ts
import UIAbility from '@ohos.app.ability.UIAbility';
- import window from '@ohos.window';
export default class FuncAbility extends UIAbility {
onCreate(want, launchParam) {
// Receive the parameters passed by the initiator UIAbility.
let funcAbilityWant = want;
let info = funcAbilityWant?.parameters?.info;
- // ...
+ ...
}
}
```
-
+
> **NOTE**
>
> In FuncAbility started, you can obtain the PID and bundle name of the UIAbility through **parameters** in the passed **want** parameter.
@@ -76,11 +75,14 @@ Assume that your application has two UIAbility components: EntryAbility and Func
// context is the UIAbilityContext of the UIAbility instance to stop.
context.terminateSelf((err) => {
- // ...
+ if (err.code) {
+ console.error(`Failed to terminate Self. Code is ${err.code}, message is ${err.message}`);
+ return;
+ }
});
```
- > **NOTE**
+ > **NOTE**
>
> When [terminateSelf()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextterminateself) is called to stop the **UIAbility** instance, the snapshot of the instance is retained by default. That is, the mission corresponding to the instance is still displayed in Recents. If you do not want to retain the snapshot, set **removeMissionAfterTerminate** under the [abilities](../quick-start/module-configuration-file.md#abilities) tag to **true** in the [module.json5 file](../quick-start/module-configuration-file.md) of the corresponding UIAbility.
@@ -95,20 +97,20 @@ When starting FuncAbility from EntryAbility, you want the result to be returned
```ts
let context = ...; // UIAbilityContext
- let wantInfo = {
+ let want = {
deviceId: '', // An empty deviceId indicates the local device.
bundleName: 'com.example.myapplication',
abilityName: 'FuncAbility',
- moduleName: 'module1', // moduleName is optional.
+ moduleName: 'func', // moduleName is optional.
parameters: {// Custom information.
info: 'From the Index page of EntryAbility',
},
}
// context is the UIAbilityContext of the initiator UIAbility.
- context.startAbilityForResult(wantInfo).then((data) => {
- // ...
+ context.startAbilityForResult(want).then((data) => {
+ ...
}).catch((err) => {
- // ...
+ console.error(`Failed to start ability for result. Code is ${err.code}, message is ${err.message}`);
})
```
@@ -122,7 +124,7 @@ When starting FuncAbility from EntryAbility, you want the result to be returned
want: {
bundleName: 'com.example.myapplication',
abilityName: 'FuncAbility',
- moduleName: 'module1',
+ moduleName: 'func',
parameters: {
info: 'From the Index page of FuncAbility',
},
@@ -130,7 +132,10 @@ When starting FuncAbility from EntryAbility, you want the result to be returned
}
// context is the AbilityContext of the target UIAbility.
context.terminateSelfWithResult(abilityResult, (err) => {
- // ...
+ if (err.code) {
+ console.error(`Failed to terminate self with result. Code is ${err.code}, message is ${err.message}`);
+ return;
+ }
});
```
@@ -140,17 +145,17 @@ When starting FuncAbility from EntryAbility, you want the result to be returned
let context = ...; // UIAbilityContext
const RESULT_CODE: number = 1001;
- // ...
+ ...
// context is the UIAbilityContext of the initiator UIAbility.
- context.startAbilityForResult(wantInfo).then((data) => {
+ context.startAbilityForResult(want).then((data) => {
if (data?.resultCode === RESULT_CODE) {
// Parse the information returned by the target UIAbility.
let info = data.want?.parameters?.info;
- // ...
+ ...
}
}).catch((err) => {
- // ...
+ console.error(`Failed to start ability for result. Code is ${err.code}, message is ${err.message}`);
})
```
@@ -174,15 +179,15 @@ This section describes how to start the UIAbility of another application through
"module": {
"abilities": [
{
- // ...
+ ...
"skills": [
{
"entities": [
- // ...
+ ...
"entity.system.default"
],
"actions": [
- // ...
+ ...
"ohos.want.action.viewData"
]
}
@@ -197,7 +202,7 @@ This section describes how to start the UIAbility of another application through
```ts
let context = ...; // UIAbilityContext
- let wantInfo = {
+ let want = {
deviceId: '', // An empty deviceId indicates the local device.
// Uncomment the line below if you want to implicitly query data only in the specific bundle.
// bundleName: 'com.example.myapplication',
@@ -207,14 +212,14 @@ This section describes how to start the UIAbility of another application through
}
// context is the UIAbilityContext of the initiator UIAbility.
- context.startAbility(wantInfo).then(() => {
- // ...
+ context.startAbility(want).then(() => {
+ console.info('Succeeded in starting ability.');
}).catch((err) => {
- // ...
+ console.error(`Failed to start ability. Code is ${err.code}, message is ${err.message}`);
})
```
- The following figure shows the effect. When you click **Open PDF**, a dialog box is displayed for you to select.
+ The following figure shows the effect. When you click **Open PDF**, a dialog box is displayed for you to select.
![](figures/uiability-intra-device-interaction.png)
3. To stop the **UIAbility** instance after the document application is used, call [terminateSelf()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextterminateself).
@@ -224,7 +229,10 @@ This section describes how to start the UIAbility of another application through
// context is the UIAbilityContext of the UIAbility instance to stop.
context.terminateSelf((err) => {
- // ...
+ if (err.code) {
+ console.error(`Failed to terminate self. Code is ${err.code}, message is ${err.message}`);
+ return;
+ }
});
```
@@ -240,15 +248,15 @@ If you want to obtain the return result when using implicit Want to start the UI
"module": {
"abilities": [
{
- // ...
+ ...
"skills": [
{
"entities": [
- // ...
+ ...
"entity.system.default"
],
"actions": [
- // ...
+ ...
"ohos.want.action.editData"
]
}
@@ -263,20 +271,20 @@ If you want to obtain the return result when using implicit Want to start the UI
```ts
let context = ...; // UIAbilityContext
- let wantInfo = {
+ let want = {
deviceId: '', // An empty deviceId indicates the local device.
// Uncomment the line below if you want to implicitly query data only in the specific bundle.
// bundleName: 'com.example.myapplication',
action: 'ohos.want.action.editData',
// entities can be omitted.
- entities: ['entity.system.default'],
+ entities: ['entity.system.default']
}
// context is the UIAbilityContext of the initiator UIAbility.
- context.startAbilityForResult(wantInfo).then((data) => {
- // ...
+ context.startAbilityForResult(want).then((data) => {
+ ...
}).catch((err) => {
- // ...
+ console.error(`Failed to start ability for result. Code is ${err.code}, message is ${err.message}`);
})
```
@@ -298,7 +306,10 @@ If you want to obtain the return result when using implicit Want to start the UI
}
// context is the AbilityContext of the target UIAbility.
context.terminateSelfWithResult(abilityResult, (err) => {
- // ...
+ if (err.code) {
+ console.error(`Failed to terminate self with result. Code is ${err.code}, message is ${err.message}`);
+ return;
+ }
});
```
@@ -317,10 +328,10 @@ If you want to obtain the return result when using implicit Want to start the UI
if (data?.resultCode === RESULT_CODE) {
// Parse the information returned by the target UIAbility.
let payResult = data.want?.parameters?.payResult;
- // ...
+ ...
}
}).catch((err) => {
- // ...
+ console.error(`Failed to start ability for result. Code is ${err.code}, message is ${err.message}`);
})
```
@@ -352,27 +363,28 @@ For details about how to obtain the context, see [Obtaining the Context of UIAbi
import AbilityConstant from '@ohos.app.ability.AbilityConstant';
let context = ...; // UIAbilityContext
-let wantInfo = {
+let want = {
deviceId: '', // An empty deviceId indicates the local device.
bundleName: 'com.example.myapplication',
abilityName: 'FuncAbility',
- moduleName: 'module1', // moduleName is optional.
+ moduleName: 'func', // moduleName is optional.
parameters: {// Custom information.
info: 'From the Index page of EntryAbility',
},
}
let options = {
windowMode: AbilityConstant.WindowMode.WINDOW_MODE_FLOATING
-}
+};
// context is the UIAbilityContext of the initiator UIAbility.
-context.startAbility(wantInfo, options).then(() => {
- // ...
+context.startAbility(want, options).then(() => {
+ console.info('Succeeded in starting ability.');
}).catch((err) => {
- // ...
+ console.error(`Failed to start ability. Code is ${err.code}, message is ${err.message}`);
})
```
-The display effect is shown below.
+The display effect is shown below.
+
![](figures/start-uiability-floating-window.png)
## Starting a Specified Page of UIAbility
@@ -387,20 +399,20 @@ When the initiator UIAbility starts another UIAbility, it usually needs to redir
```ts
let context = ...; // UIAbilityContext
-let wantInfo = {
+let want = {
deviceId: '', // An empty deviceId indicates the local device.
bundleName: 'com.example.myapplication',
abilityName: 'FuncAbility',
- moduleName: 'module1', // moduleName is optional.
+ moduleName: 'func', // moduleName is optional.
parameters: {// Custom parameter used to pass the page information.
router: 'funcA',
},
}
// context is the UIAbilityContext of the initiator UIAbility.
-context.startAbility(wantInfo).then(() => {
- // ...
+context.startAbility(want).then(() => {
+ console.info('Succeeded in starting ability.');
}).catch((err) => {
- // ...
+ console.error(`Failed to start ability. Code is ${err.code}, message is ${err.message}`);
})
```
@@ -431,7 +443,7 @@ export default class FuncAbility extends UIAbility {
}
}
windowStage.loadContent(url, (err, data) => {
- // ...
+ ...
});
}
}
@@ -455,7 +467,7 @@ In summary, when a UIAbility instance of application A has been created and the
onNewWant(want, launchParam) {
// Receive the parameters passed by the initiator UIAbility.
globalThis.funcAbilityWant = want;
- // ...
+ ...
}
}
```
@@ -480,7 +492,7 @@ In summary, when a UIAbility instance of application A has been created and the
// Page display.
build() {
- // ...
+ ...
}
}
```
@@ -494,11 +506,11 @@ In summary, when a UIAbility instance of application A has been created and the
Call is an extension of the UIAbility capability. It enables the UIAbility to be invoked by and communicate with external systems. The UIAbility invoked can be either started in the foreground or created and run in the background. You can use the call to implement data sharing between two UIAbility instances (CallerAbility and CalleeAbility) through IPC.
-The core API used for the call is **startAbilityByCall**, which differs from **startAbility** in the following ways:
+The core API used for the call is **startAbilityByCall()**, which differs from **startAbility()** in the following ways:
-- **startAbilityByCall** supports UIAbility launch in the foreground and background, whereas **startAbility** supports UIAbility launch in the foreground only.
+- **startAbilityByCall()** supports UIAbility launch in the foreground and background, whereas **startAbility()** supports UIAbility launch in the foreground only.
-- The CallerAbility can use the caller object returned by **startAbilityByCall** to communicate with the CalleeAbility, but **startAbility** does not provide the communication capability.
+- The CallerAbility can use the caller object returned by **startAbilityByCall()** to communicate with the CalleeAbility, but **startAbility()** does not provide the communication capability.
Call is usually used in the following scenarios:
@@ -506,6 +518,7 @@ Call is usually used in the following scenarios:
- Starting the CalleeAbility in the background
+
**Table 1** Terms used in the call
| **Term**| Description|
@@ -517,9 +530,9 @@ Call is usually used in the following scenarios:
The following figure shows the call process.
- Figure 1 Call process
+Figure 1 Call process
- ![call](figures/call.png)
+![call](figures/call.png)
- The CallerAbility uses **startAbilityByCall** to obtain a caller object and uses **call()** of the caller object to send data to the CalleeAbility.
@@ -537,7 +550,7 @@ The following figure shows the call process.
The following table describes the main APIs used for the call. For details, see [AbilityContext](../reference/apis/js-apis-app-ability-uiAbility.md#caller).
- **Table 2** Call APIs
+**Table 2** Call APIs
| API| Description|
| -------- | -------- |
@@ -571,7 +584,6 @@ For the CalleeAbility, implement the callback to receive data and the methods to
```
3. Define the agreed parcelable data.
-
The data formats sent and received by the CallerAbility and CalleeAbility must be consistent. In the following example, the data formats are number and string.
@@ -588,7 +600,7 @@ For the CalleeAbility, implement the callback to receive data and the methods to
marshalling(messageSequence) {
messageSequence.writeInt(this.num);
messageSequence.writeString(this.str);
- return true
+ return true;
}
unmarshalling(messageSequence) {
@@ -600,9 +612,9 @@ For the CalleeAbility, implement the callback to receive data and the methods to
```
4. Implement **Callee.on** and **Callee.off**.
-
+
The time to register a listener for the CalleeAbility depends on your application. The data sent and received before the listener is registered and that after the listener is deregistered are not processed. In the following example, the **MSG_SEND_METHOD** listener is registered in **onCreate** of the UIAbility and deregistered in **onDestroy**. After receiving parcelable data, the application processes the data and returns the data result. You need to implement processing based on service requirements. The sample code is as follows:
-
+
```ts
const TAG: string = '[CalleeAbility]';
@@ -625,16 +637,16 @@ For the CalleeAbility, implement the callback to receive data and the methods to
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)}`);
+ } catch (err) {
+ console.error(`Failed to register. Code is ${err.code}, message is ${err.message}`);
}
}
onDestroy() {
try {
this.callee.off(MSG_SEND_METHOD);
- } catch (error) {
- console.error(TAG, `${MSG_SEND_METHOD} unregister failed with error ${JSON.stringify(error)}`);
+ } catch (err) {
+ console.error(`Failed to unregister. Code is ${err.code}, message is ${err.message}`);
}
}
}
@@ -661,9 +673,9 @@ For the CalleeAbility, implement the callback to receive data and the methods to
caller.on('release', (msg) => {
console.info(`caller onRelease is called ${msg}`);
})
- console.info('caller register OnRelease succeed');
- } catch (error) {
- console.info(`caller register OnRelease failed with ${error}`);
+ console.info('Succeeded in registering on release.');
+ } catch (err) {
+ console.err(`Failed to caller register on release. Code is ${err.code}, message is ${err.message}`);
}
}
@@ -672,15 +684,15 @@ For the CalleeAbility, implement the callback to receive data and the methods to
this.caller = await context.startAbilityByCall({
bundleName: 'com.samples.CallApplication',
abilityName: 'CalleeAbility'
- })
+ });
if (this.caller === undefined) {
console.info('get caller failed')
- return
+ return;
}
console.info('get caller success')
this.regOnRelease(this.caller)
- } catch (error) {
- console.info(`get caller failed with ${error}`)
+ } (err) {
+ console.err(`Failed to get caller. Code is ${err.code}, message is ${err.message}`);
}
}
```
diff --git a/en/application-dev/application-models/uiability-launch-type.md b/en/application-dev/application-models/uiability-launch-type.md
index 8f5762fcde0a766f454a2540708368048e1b01aa..c7aac3d4bc3acdb2601580646024ec1f8117473f 100644
--- a/en/application-dev/application-models/uiability-launch-type.md
+++ b/en/application-dev/application-models/uiability-launch-type.md
@@ -17,7 +17,8 @@ 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
+
![uiability-launch-type1](figures/uiability-launch-type1.gif)
> **NOTE**
@@ -30,11 +31,11 @@ To use the singleton mode, set **launchType** in the [module.json5 configuration
```json
{
"module": {
- // ...
+ ...
"abilities": [
{
"launchType": "singleton",
- // ...
+ ...
}
]
}
@@ -56,11 +57,11 @@ To use the multiton mode, set **launchType** in the [module.json5 file](../quick
```json
{
"module": {
- // ...
+ ...
"abilities": [
{
"launchType": "multiton",
- // ...
+ ...
}
]
}
@@ -73,6 +74,7 @@ To use the multiton mode, set **launchType** in the [module.json5 file](../quick
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
+
![uiability-launch-type3](figures/uiability-launch-type3.gif)
For example, there are two UIAbility components: EntryAbility and SpecifiedAbility (with the launch type **specified**). You are required to start SpecifiedAbility from EntryAbility.
@@ -82,11 +84,11 @@ For example, there are two UIAbility components: EntryAbility and SpecifiedAbili
```json
{
"module": {
- // ...
+ ...
"abilities": [
{
"launchType": "specified",
- // ...
+ ...
}
]
}
@@ -99,23 +101,24 @@ For example, there are two UIAbility components: EntryAbility and SpecifiedAbili
// Configure an independent key for each UIAbility instance.
// For example, in the document usage scenario, use the document path as the key.
function getInstance() {
- // ...
+ ...
}
+ let context =...; // context is the UIAbilityContext of the initiator UIAbility.
let want = {
- deviceId: '', // An empty deviceId indicates the local device.
- bundleName: 'com.example.myapplication',
- abilityName: 'SpecifiedAbility',
- moduleName: 'module1', // moduleName is optional.
- parameters: {// Custom information.
- instanceKey: getInstance(),
- },
+ deviceId: '', // An empty deviceId indicates the local device.
+ bundleName: 'com.example.myapplication',
+ abilityName: 'SpecifiedAbility',
+ moduleName: 'specified', // moduleName is optional.
+ parameters: {// Custom information.
+ instanceKey: getInstance(),
+ },
}
- // context is the UIAbilityContext of the initiator UIAbility.
- this.context.startAbility(want).then(() => {
- // ...
+
+ context.startAbility(want).then(() => {
+ console.info('Succeeded in starting ability.');
}).catch((err) => {
- // ...
+ console.error(`Failed to start ability. Code is ${err.code}, message is ${err.message}`);
})
```
@@ -127,16 +130,16 @@ For example, there are two UIAbility components: EntryAbility and SpecifiedAbili
import AbilityStage from '@ohos.app.ability.AbilityStage';
export default class MyAbilityStage extends AbilityStage {
- onAcceptWant(want): string {
- // 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 key string is a custom string.
- return `SpecifiedAbilityInstance_${want.parameters.instanceKey}`;
- }
-
- return '';
+ onAcceptWant(want): string {
+ // 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 key string is a custom string.
+ return `SpecifiedAbilityInstance_${want.parameters.instanceKey}`;
}
+
+ return '';
+ }
}
```
@@ -154,4 +157,3 @@ For example, there are two UIAbility components: EntryAbility and SpecifiedAbili
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. 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.
-
\ No newline at end of file
diff --git a/en/application-dev/application-models/uiability-lifecycle.md b/en/application-dev/application-models/uiability-lifecycle.md
index 57200abb8fbfb625e2e6c8999da5ad817e2e85b4..8a8506a71ffe130d4f39ed10a8fe60fbdead281e 100644
--- a/en/application-dev/application-models/uiability-lifecycle.md
+++ b/en/application-dev/application-models/uiability-lifecycle.md
@@ -9,7 +9,7 @@ The lifecycle of UIAbility has four states: **Create**, **Foreground**, **Backgr
**Figure 1** UIAbility lifecycle states
-![Ability-Life-Cycle](figures/Ability-Life-Cycle.png)
+![Ability-Life-Cycle](figures/Ability-Life-Cycle.png)
## Description of Lifecycle States
@@ -22,24 +22,25 @@ The **Create** state is triggered when the UIAbility instance is created during
```ts
import UIAbility from '@ohos.app.ability.UIAbility';
-import window from '@ohos.window';
export default class EntryAbility extends UIAbility {
- onCreate(want, launchParam) {
- // Initialize the application.
- }
- // ...
+ onCreate(want, launchParam) {
+ // Initialize the application.
+ }
+ ...
}
```
+> **NOTE**
+>
+> [Want](../reference/apis/js-apis-app-ability-want.md) is used as the carrier to transfer information between application components. For details, see [Want](want-overview.md).
### WindowStageCreate and WindowStageDestory
After the UIAbility instance is created but before it enters the **Foreground** state, the system creates a WindowStage instance and triggers the **onWindowStageCreate()** callback. You can set UI loading and WindowStage event subscription in the callback.
-**Figure 2** WindowStageCreate and WindowStageDestory
-
-![Ability-Life-Cycle-WindowStage](figures/Ability-Life-Cycle-WindowStage.png)
+**Figure 2** WindowStageCreate and WindowStageDestory
+![Ability-Life-Cycle-WindowStage](figures/Ability-Life-Cycle-WindowStage.png)
In the **onWindowStageCreate()** callback, use [loadContent()](../reference/apis/js-apis-window.md#loadcontent9-2) to set the page to be loaded, and call [on('windowStageEvent')](../reference/apis/js-apis-window.md#onwindowstageevent9) to subscribe to [WindowStage events](../reference/apis/js-apis-window.md#windowstageeventtype9), for example, having or losing focus, or becoming visible or invisible.
@@ -48,29 +49,44 @@ import UIAbility from '@ohos.app.ability.UIAbility';
import window from '@ohos.window';
export default class EntryAbility extends UIAbility {
- // ...
-
- onWindowStageCreate(windowStage: Window.WindowStage) {
- // Subscribe to the WindowStage events (having or losing focus, or becoming visible or invisible).
- try {
- windowStage.on('windowStageEvent', (data) => {
- console.info('Succeeded in enabling the listener for window stage event changes. Data: ' +
- JSON.stringify(data));
- });
- } catch (exception) {
- console.error('Failed to enable the listener for window stage event changes. Cause:' +
- JSON.stringify(exception));
- };
-
- // Set the UI loading.
- windowStage.loadContent('pages/Index', (err, data) => {
- // ...
- });
+ ...
+
+ onWindowStageCreate(windowStage: window.WindowStage) {
+ // Subscribe to the WindowStage events (having or losing focus, or becoming visible or invisible).
+ try {
+ windowStage.on('windowStageEvent', (data) => {
+ let stageEventType: window.WindowStageEventType = data;
+ switch (stageEventType) {
+ case window.WindowStageEventType.SHOWN: // Switch to the foreground.
+ console.info('windowStage foreground.');
+ break;
+ case window.WindowStageEventType.ACTIVE: // Gain focus.
+ console.info('windowStage active.');
+ break;
+ case window.WindowStageEventType.INACTIVE: // Lose focus.
+ console.info('windowStage inactive.');
+ break;
+ case window.WindowStageEventType.HIDDEN: // Switch to the background.
+ console.info('windowStage background.');
+ break;
+ default:
+ break;
+ }
+ });
+ } catch (exception) {
+ console.error('Failed to enable the listener for window stage event changes. Cause:' +
+ JSON.stringify(exception));
}
+
+ // Set UI loading.
+ windowStage.loadContent('pages/Index', (err, data) => {
+ ...
+ });
+ }
}
```
-> **NOTE**
+> **NOTE**
>
> For details about how to use WindowStage, see [Window Development](../windowmanager/application-window-stage.md).
@@ -82,18 +98,23 @@ import UIAbility from '@ohos.app.ability.UIAbility';
import window from '@ohos.window';
export default class EntryAbility extends UIAbility {
- // ...
-
- onWindowStageDestroy() {
- // Release UI resources.
- // Unsubscribe from the WindowStage events such as having or losing focus in the onWindowStageDestroy() callback.
- try {
- windowStage.off('windowStageEvent');
- } catch (exception) {
- console.error('Failed to disable the listener for window stage event changes. Cause:' +
- JSON.stringify(exception));
- };
- }
+ windowStage: window.WindowStage;
+ ...
+
+ onWindowStageCreate(windowStage: window.WindowStage) {
+ this.windowStage = windowStage;
+ ...
+ }
+
+ onWindowStageDestroy() {
+ // Release UIresources.
+ // Unsubscribe from the WindowStage events such as having or losing focus in the onWindowStageDestroy() callback.
+ try {
+ this.windowStage.off('windowStageEvent');
+ } catch (err) {
+ console.error(`Failed to disable the listener for window stage event changes. Code is ${err.code}, message is ${err.message}`);
+ };
+ }
}
```
@@ -115,16 +136,16 @@ When the application is switched to the background, you can disable positioning
import UIAbility from '@ohos.app.ability.UIAbility';
export default class EntryAbility extends UIAbility {
- // ...
+ ...
- onForeground() {
- // Apply for the resources required by the system or re-apply for the resources released in onBackground().
- }
+ onForeground() {
+ // Apply for the resources required by the system or re-apply for the resources released in onBackground().
+ }
- onBackground() {
- // Release useless resources when the UI is invisible, or perform time-consuming operations in this callback,
- // for example, saving the status.
- }
+ onBackground() {
+ // Release useless resources when the UI is invisible, or perform time-consuming operations in this callback,
+ // for example, saving the status.
+ }
}
```
@@ -137,13 +158,12 @@ The UIAbility instance is destroyed when **terminateSelf()** is called or the us
```ts
import UIAbility from '@ohos.app.ability.UIAbility';
-import window from '@ohos.window';
export default class EntryAbility extends UIAbility {
- // ...
+ ...
- onDestroy() {
- // Release system resources and save data.
- }
+ onDestroy() {
+ // Release system resources and save data.
+ }
}
```
diff --git a/en/application-dev/application-models/uiability-overview.md b/en/application-dev/application-models/uiability-overview.md
index e9a904e060e30e2523902aa4014664f6f0100e3a..5aa0ca79c49bd9f7566e7e0cc1ea977cea8c83d5 100644
--- a/en/application-dev/application-models/uiability-overview.md
+++ b/en/application-dev/application-models/uiability-overview.md
@@ -11,7 +11,9 @@ The following design philosophy is behind UIAbility:
2. Support for multiple device types and window forms
-For details, see [Interpretation of the Application Model] (application-model-description.md).
+> **NOTE**
+>
+> For details, see [Interpretation of the Application Model](application-model-description.md).
The UIAbility division principles and suggestions are as follows:
@@ -33,7 +35,7 @@ To enable an application to properly use a UIAbility component, declare the UIAb
```json
{
"module": {
- // ...
+ ...
"abilities": [
{
"name": "EntryAbility", // Name of the UIAbility component.
@@ -43,7 +45,7 @@ To enable an application to properly use a UIAbility component, declare the UIAb
"label": "$string:EntryAbility_label", // Label of the UIAbility component.
"startWindowIcon": "$media:icon", // Index of the icon resource file.
"startWindowBackground": "$color:start_window_background", // Index of the background color resource file.
- // ...
+ ...
}
]
}
diff --git a/en/application-dev/application-models/uiability-usage.md b/en/application-dev/application-models/uiability-usage.md
index fa8badc6d48c7e550922cb60a15d02eab9cc80b6..46959284ef3bfe179d465f5dae92b6f8538f680a 100644
--- a/en/application-dev/application-models/uiability-usage.md
+++ b/en/application-dev/application-models/uiability-usage.md
@@ -14,14 +14,14 @@ import UIAbility from '@ohos.app.ability.UIAbility';
import window from '@ohos.window';
export default class EntryAbility extends UIAbility {
- onWindowStageCreate(windowStage: window.WindowStage) {
- // Main window is created. Set a main page for this ability.
- windowStage.loadContent('pages/Index', (err, data) => {
- // ...
- });
- }
+ onWindowStageCreate(windowStage: window.WindowStage) {
+ // Main window is created. Set a main page for this ability.
+ windowStage.loadContent('pages/Index', (err, data) => {
+ ...
+ });
+ }
- // ...
+ ...
}
```
@@ -40,15 +40,14 @@ The UIAbility class has its own context, which is an instance of the [UIAbilityC
import UIAbility from '@ohos.app.ability.UIAbility';
export default class EntryAbility extends UIAbility {
- onCreate(want, launchParam) {
- // Obtain the context of the UIAbility instance.
- let context = this.context;
-
- // ...
- }
+ onCreate(want, launchParam) {
+ // Obtain the context of the UIAbility instance.
+ let context = this.context;
+ ...
+ }
}
```
-
+
- Import the context module and define the **context** variable in the component.
```ts
@@ -68,7 +67,7 @@ The UIAbility class has its own context, which is an instance of the [UIAbilityC
// Page display.
build() {
- // ...
+ ...
}
}
```
@@ -93,7 +92,7 @@ The UIAbility class has its own context, which is an instance of the [UIAbilityC
// Page display.
build() {
- // ...
+ ...
}
}
```
diff --git a/en/application-dev/application-models/want-overview.md b/en/application-dev/application-models/want-overview.md
index 1ce771daf195a09250a5fde05e0ce5a7acc60355..cf5cac43999a5efbe59659252b6b3db325cacd8a 100644
--- a/en/application-dev/application-models/want-overview.md
+++ b/en/application-dev/application-models/want-overview.md
@@ -6,43 +6,46 @@
[Want](../reference/apis/js-apis-app-ability-want.md) is an object that transfers information between application components. It is often used as a parameter of [startAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability). For example, when UIAbilityA needs to start UIAbilityB and transfer some data to UIAbilityB, it can use the **want** parameter in **startAbility()** to transfer the data.
**Figure 1** Want usage
+
![usage-of-want](figures/usage-of-want.png)
## Types of Want
-- **Explicit Want**: If **abilityName** and **bundleName** are specified when starting an ability, explicit Want is used.
- Explicit Want is usually used to start a known target ability in the same application. The target ability is started by specifying **bundleName** of the application where the target ability is located and **abilityName** in the **Want** object. When there is an explicit object to process the request, explicit Want is a simple and effective way to start the target ability.
-
+- **Explicit Want**: If **abilityName** and **bundleName** are specified in the **want** parameter when starting an an application component, explicit Want is used.
+
+ Explicit Want is usually used to start a known target application component in the same application. The target application component is started by specifying **bundleName** of the application where the target application component is located and **abilityName** in the **Want** object. When there is an explicit object to process the request, explicit Want is a simple and effective way to start the target application component.
+
```ts
let wantInfo = {
- deviceId: '', // An empty deviceId indicates the local device.
- bundleName: 'com.example.myapplication',
- abilityName: 'FuncAbility',
+ deviceId: '', // An empty deviceId indicates the local device.
+ bundleName: 'com.example.myapplication',
+ abilityName: 'FuncAbility',
}
```
-
-- **Implicit Want**: If **abilityName** is not specified when starting the ability, implicit Want is used.
+
+- **Implicit Want**: If **abilityName** is not specified in the **want** parameter when starting the an application component, implicit Want is used.
+
Implicit Want can be used when the object used to process the request is unclear and the current application wants to use a capability (defined by the [skills tag](../quick-start/module-configuration-file.md#skills)) provided by another application. The system matches all applications that declare to support the capability. For example, for a link open request, the system matches all applications that support the request and provides the available ones for users to select.
-
+
```ts
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.search',
- // entities can be omitted.
- entities: [ 'entity.system.browsable' ],
- uri: 'https://www.test.com:8080/query/student',
- type: 'text/plain',
+ // Uncomment the line below if you want to implicitly query data only in the specific bundle.
+ // bundleName: 'com.example.myapplication',
+ action: 'ohos.want.action.search',
+ // entities can be omitted.
+ entities: [ 'entity.system.browsable' ],
+ uri: 'https://www.test.com:8080/query/student',
+ type: 'text/plain',
};
```
-
+
> **NOTE**
- > - Depending on the ability matching result, the following cases may be possible when you attempt to use implicit Want to start the ability.
- > - No ability is matched. The startup fails.
- > - An ability that meets the conditions is matched. That ability is started.
- > - Multiple abilities that meet the conditions are matched. A dialog box is displayed for users to select one of them.
+ > - Depending on the application component matching result, the following cases may be possible when you attempt to use implicit Want to start the application component.
+ > - No application component is matched. The startup fails.
+ > - An application component that meets the conditions is matched. That application component is started.
+ > - Multiple application components that meet the conditions are matched. A dialog box is displayed for users to select one of them.
>
> - If the **want** parameter passed does not contain **abilityName** or **bundleName**, the ServiceExtensionAbility components of all applications cannot be started through implicit Want.
>
diff --git a/en/application-dev/application-models/widget-development-fa.md b/en/application-dev/application-models/widget-development-fa.md
index b766c3420f56a7406bc345911a09bbf91bb6a187..3aa1a9fd29495b36a02d155e5d2ad48e94bce5ad 100644
--- a/en/application-dev/application-models/widget-development-fa.md
+++ b/en/application-dev/application-models/widget-development-fa.md
@@ -20,7 +20,7 @@ Before you get started, it would be helpful if you have a basic understanding of
Figure 1 shows the working principles of the widget framework.
-**Figure 1** Widget framework working principles in the FA model
+**Figure 1** Widget framework working principles in the FA model
![form-extension](figures/form-extension.png)
The widget host consists of the following modules:
@@ -122,48 +122,48 @@ To create a widget in the FA model, implement the widget lifecycle callbacks. Ge
```ts
export default {
- onCreate(want) {
- console.info('FormAbility onCreate');
- // Called when the widget is created. The widget provider should return the widget data binding class.
- let obj = {
- "title": "titleOnCreate",
- "detail": "detailOnCreate"
- };
- let formData = formBindingData.createFormBindingData(obj);
- return formData;
- },
- onCastToNormal(formId) {
- // Called when the widget host converts the temporary widget into a normal one. The widget provider should do something to respond to the conversion.
- console.info('FormAbility onCastToNormal');
- },
- onUpdate(formId) {
- // Override this method to support scheduled updates, periodic updates, or updates requested by the widget host.
- console.info('FormAbility onUpdate');
- let obj = {
- "title": "titleOnUpdate",
- "detail": "detailOnUpdate"
- };
- let formData = formBindingData.createFormBindingData(obj);
- formProvider.updateForm(formId, formData).catch((error) => {
- console.info('FormAbility updateForm, error:' + JSON.stringify(error));
- });
- },
- onVisibilityChange(newStatus) {
- // Called when the widget host initiates an event about visibility changes. The widget provider should do something to respond to the notification. This callback takes effect only for system applications.
- console.info('FormAbility onVisibilityChange');
- },
- onEvent(formId, message) {
- // If the widget supports event triggering, override this method and implement the trigger.
- console.info('FormAbility onEvent');
- },
- onDestroy(formId) {
- // Delete widget data.
- console.info('FormAbility onDestroy');
- },
- onAcquireFormState(want) {
- console.info('FormAbility onAcquireFormState');
- return formInfo.FormState.READY;
- },
+ onCreate(want) {
+ console.info('FormAbility onCreate');
+ // Called when the widget is created. The widget provider should return the widget data binding class.
+ let obj = {
+ "title": "titleOnCreate",
+ "detail": "detailOnCreate"
+ };
+ let formData = formBindingData.createFormBindingData(obj);
+ return formData;
+ },
+ onCastToNormal(formId) {
+ // Called when the widget host converts the temporary widget into a normal one. The widget provider should do something to respond to the conversion.
+ console.info('FormAbility onCastToNormal');
+ },
+ onUpdate(formId) {
+ // Override this method to support scheduled updates, periodic updates, or updates requested by the widget host.
+ console.info('FormAbility onUpdate');
+ let obj = {
+ "title": "titleOnUpdate",
+ "detail": "detailOnUpdate"
+ };
+ let formData = formBindingData.createFormBindingData(obj);
+ formProvider.updateForm(formId, formData).catch((error) => {
+ console.info('FormAbility updateForm, error:' + JSON.stringify(error));
+ });
+ },
+ onVisibilityChange(newStatus) {
+ // Called when the widget host initiates an event about visibility changes. The widget provider should do something to respond to the notification. This callback takes effect only for system applications.
+ console.info('FormAbility onVisibilityChange');
+ },
+ onEvent(formId, message) {
+ // If the widget supports event triggering, override this method and implement the trigger.
+ console.info('FormAbility onEvent');
+ },
+ onDestroy(formId) {
+ // Delete widget data.
+ console.info('FormAbility onDestroy');
+ },
+ onAcquireFormState(want) {
+ console.info('FormAbility onAcquireFormState');
+ return formInfo.FormState.READY;
+ },
}
```
@@ -188,15 +188,15 @@ The widget configuration file is named **config.json**. Find the **config.json**
```json
- "js": [{
- "name": "widget",
- "pages": ["pages/index/index"],
- "window": {
- "designWidth": 720,
- "autoDesignWidth": true
- },
- "type": "form"
- }]
+ "js": [{
+ "name": "widget",
+ "pages": ["pages/index/index"],
+ "window": {
+ "designWidth": 720,
+ "autoDesignWidth": true
+ },
+ "type": "form"
+ }]
```
- The **abilities** module in the **config.json** file corresponds to **FormAbility** of the widget. The internal structure is described as follows:
@@ -275,7 +275,7 @@ async function storeFormInfo(formId: string, formName: string, tempFlag: boolean
}
}
-// ...
+...
onCreate(want) {
console.info('FormAbility onCreate');
@@ -293,7 +293,7 @@ async function storeFormInfo(formId: string, formName: string, tempFlag: boolean
let formData = formBindingData.createFormBindingData(obj);
return formData;
}
-// ...
+...
```
You should override **onDestroy** to implement widget data deletion.
@@ -313,14 +313,14 @@ async function deleteFormInfo(formId: string) {
}
}
-// ...
+...
onDestroy(formId) {
console.info('FormAbility onDestroy');
// Delete the persistent widget instance data.
// Implement this API based on project requirements.
deleteFormInfo(formId);
}
-// ...
+...
```
For details about how to implement persistent data storage, see [Application Data Persistence Overview](../database/app-data-persistence-overview.md).
@@ -543,4 +543,3 @@ The following is an example:
}
}
```
-
diff --git a/en/application-dev/application-models/windowextensionability.md b/en/application-dev/application-models/windowextensionability.md
index 0f6e28b89790cfa1dd7dc471ed3a450280f19a4a..3c1d364cd50e73c8232c5ba2482e04b2ca2a6077 100644
--- a/en/application-dev/application-models/windowextensionability.md
+++ b/en/application-dev/application-models/windowextensionability.md
@@ -11,7 +11,7 @@ the context is [WindowExtensionContext](../reference/apis/js-apis-inner-applicat
> **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).
+> **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](../faqs/full-sdk-switch-guide.md).
>
@@ -43,7 +43,7 @@ To implement an embedded application, manually create a WindowExtensionAbility i
onWindowReady(window) {
window.loadContent('WindowExtAbility/pages/index1').then(() => {
window.getProperties().then((pro) => {
- console.log("WindowExtension " + JSON.stringify(pro));
+ console.info("WindowExtension " + JSON.stringify(pro));
})
window.show();
})
@@ -110,4 +110,5 @@ System applications can load the created WindowExtensionAbility through the Abil
.backgroundColor(0x64BB5c)
}
}
- ```
\ No newline at end of file
+ ```
+
diff --git a/en/application-dev/file-management/share-app-file.md b/en/application-dev/file-management/share-app-file.md
index d9ee1d90904f5cdb43cd1987a66b09668200bc81..c2f8f8d12f5ff056e043fb632cff9752c95256ce 100644
--- a/en/application-dev/file-management/share-app-file.md
+++ b/en/application-dev/file-management/share-app-file.md
@@ -12,7 +12,7 @@ You can use the related APIs to [share a file with another application](#sharing
The file URIs are in the following format:
- file://<bundleName>/<path>/\#networkid=<networkid>
+ file://<bundleName>/<path>
- **file**: indicates a file URI.
@@ -20,8 +20,6 @@ The file URIs are in the following format:
- *path*: specifies the application sandbox path of the file.
-- *networkid* (optional): specifies the device to which the file belongs in a distributed file system. Leave this parameter unspecified if the file location does not need to be set.
-
## Sharing a File with Another Application
Before sharing application files, you need to [obtain the application file path](../application-models/application-context-stage.md#obtaining-the-application-development-path).
diff --git a/en/application-dev/media/audio-playback-concurrency.md b/en/application-dev/media/audio-playback-concurrency.md
index 0b36594f6bef62c7ba7588bc8977af67609a6c9d..fee7e776d68914ad376e01b8fe40ee84e3da4224 100644
--- a/en/application-dev/media/audio-playback-concurrency.md
+++ b/en/application-dev/media/audio-playback-concurrency.md
@@ -14,7 +14,7 @@ The audio interruption policy determines the operations (for example, pause, res
Two audio interruption modes, specified by [InterruptMode](../reference/apis/js-apis-audio.md#interruptmode9), are preset in the audio interruption policy:
-- **SHARED_MODE**: Multiple audio streams created by an application share one audio focus. The concurrency rules between these audio streams are determined by the application, without the use of the audio interruption policy. However, if another application needs to play audio while one of these audio streams is being played, the audio interruption policy is triggered.
+- **SHARE_MODE**: Multiple audio streams created by an application share one audio focus. The concurrency rules between these audio streams are determined by the application, without the use of the audio interruption policy. However, if another application needs to play audio while one of these audio streams is being played, the audio interruption policy is triggered.
- **INDEPENDENT_MODE**: Each audio stream created by an application has an independent audio focus. When multiple audio streams are played concurrently, the audio interruption policy is triggered.
diff --git a/en/application-dev/media/audio-playback-overview.md b/en/application-dev/media/audio-playback-overview.md
index d17970d6de9b8b238db74d971ad5f58c605462eb..5ef7a6f9c4d08719a71c9e07f34fa1104802fcc6 100644
--- a/en/application-dev/media/audio-playback-overview.md
+++ b/en/application-dev/media/audio-playback-overview.md
@@ -8,7 +8,7 @@ OpenHarmony provides multiple classes for you to develop audio playback applicat
- [AudioRenderer](using-audiorenderer-for-playback.md): provides ArkTS and JS API to implement audio output. It supports only the PCM format and requires applications to continuously write audio data. The applications can perform data preprocessing, for example, setting the sampling rate and bit width of audio files, before audio input. This class can be used to develop more professional and diverse playback applications. To use this class, you must have basic audio processing knowledge.
-- [OpenSLES](using-opensl-es-for-playback.md): provides a set of standard, cross-platform, yet unique native audio APIs. It supports audio output in PCM format and is applicable to playback applications that are ported from other embedded platforms or that implements audio output at the native layer.
+- [OpenSL ES](using-opensl-es-for-playback.md): provides a set of standard, cross-platform, yet unique native audio APIs. It supports audio output in PCM format and is applicable to playback applications that are ported from other embedded platforms or that implements audio output at the native layer.
- [TonePlayer](using-toneplayer-for-playback.md): provides ArkTS and JS API to implement the playback of dialing tones and ringback tones. It can be used to play the content selected from a fixed type range, without requiring the input of media assets or audio data. This class is application to specific scenarios where dialing tones and ringback tones are played. is available only to system applications.
diff --git a/en/application-dev/media/audio-recording-overview.md b/en/application-dev/media/audio-recording-overview.md
index 698255fddd78d98f9e635b16b3db94e6980bd4a0..2c6fb6fe5b8ffd0e82478d450e64bfc0e10257c6 100644
--- a/en/application-dev/media/audio-recording-overview.md
+++ b/en/application-dev/media/audio-recording-overview.md
@@ -8,7 +8,7 @@ OpenHarmony provides multiple classes for you to develop audio recording applica
- [AudioCapturer](using-audiocapturer-for-recording.md): provides ArkTS and JS API to implement audio input. It supports only the PCM format and requires applications to continuously read audio data. The application can perform data processing after audio output. This class can be used to develop more professional and diverse recording applications. To use this class, you must have basic audio processing knowledge.
-- [OpenSLES](using-opensl-es-for-recording.md): provides a set of standard, cross-platform, yet unique native audio APIs. It supports audio input in PCM format and is applicable to recording applications that are ported from other embedded platforms or that implements audio input at the native layer.
+- [OpenSL ES](using-opensl-es-for-recording.md): provides a set of standard, cross-platform, yet unique native audio APIs. It supports audio input in PCM format and is applicable to recording applications that are ported from other embedded platforms or that implements audio input at the native layer.
## Precautions for Developing Audio Recording Applications
diff --git a/en/application-dev/media/avplayer-avrecorder-overview.md b/en/application-dev/media/avplayer-avrecorder-overview.md
index 051ca3b66ce1839046a2e783a8c274c304625045..3bf9b785b93a32b60b73c902449b9b019e651a2b 100644
--- a/en/application-dev/media/avplayer-avrecorder-overview.md
+++ b/en/application-dev/media/avplayer-avrecorder-overview.md
@@ -59,6 +59,7 @@ The table below lists the supported protocols.
| -------- | -------- |
| Local VOD| The file descriptor is supported, but the file path is not.|
| Network VoD| HTTP, HTTPS, and HLS are supported.|
+| Live webcasting| HLS is supported.|
The table below lists the supported audio playback formats.
diff --git a/en/application-dev/media/figures/audiocapturer-status-change.png b/en/application-dev/media/figures/audiocapturer-status-change.png
index aadbc4fb6470b7cdc0f399ee5954a96c01a7f7c3..ff76a8414f7a254af7d2796e44f2c2555dc9185f 100644
Binary files a/en/application-dev/media/figures/audiocapturer-status-change.png and b/en/application-dev/media/figures/audiocapturer-status-change.png differ
diff --git a/en/application-dev/media/media-application-overview.md b/en/application-dev/media/media-application-overview.md
index d350482e61e7bc9659054b0426c10ce07da88045..6ca7bbd61bccab668076da76841e785d1918abe9 100644
--- a/en/application-dev/media/media-application-overview.md
+++ b/en/application-dev/media/media-application-overview.md
@@ -2,7 +2,7 @@
## Multimedia Subsystem Architecture
-The multimedia subsystem provides the capability of processing users' visual and auditory information. For example, it can be used to collect, compress, store, decompress, and play audio and video information. Based on the type of media information to process, the media system is usually divided into four modules: audio, media, camera, and image.
+The multimedia subsystem provides the capability of processing users' visual and auditory information. For example, it can be used to collect, compress, store, decompress, and play audio and video information. Based on the type of media information to process, the multimedia subsystem subsystem is usually divided into four modules: audio, media, camera, and image.
As shown in the figure below, the multimedia subsystem provides APIs for developing audio/video, camera, and gallery applications, and provides adaptation and acceleration for different hardware chips. In the middle part, it provides core media functionalities and management mechanisms in the form of services.
diff --git a/en/application-dev/media/using-audiorenderer-for-playback.md b/en/application-dev/media/using-audiorenderer-for-playback.md
index 11934e669813fa7a89ceef43bd2c3795db6bad75..d72637819259e3752a33b37d6f645786793cfc38 100644
--- a/en/application-dev/media/using-audiorenderer-for-playback.md
+++ b/en/application-dev/media/using-audiorenderer-for-playback.md
@@ -151,9 +151,6 @@ export default class AudioRendererDemo {
console.info(`${TAG}: creating AudioRenderer success`);
this.renderModel = renderer;
this.renderModel.on('stateChange', (state) => { // Set the events to listen for. A callback is invoked when the AudioRenderer is switched to the specified state.
- if (state == 1) {
- console.info('audio renderer state is: STATE_PREPARED');
- }
if (state == 2) {
console.info('audio renderer state is: STATE_RUNNING');
}
diff --git a/en/application-dev/media/using-avplayer-for-playback.md b/en/application-dev/media/using-avplayer-for-playback.md
index 6cb6ab1e67ef0ae8a44e04fa915ad87bcc9ed024..9af55fb71b489f7b3ece342969c72d18ed90eaab 100644
--- a/en/application-dev/media/using-avplayer-for-playback.md
+++ b/en/application-dev/media/using-avplayer-for-playback.md
@@ -12,7 +12,7 @@ During application development, you can use the **state** attribute of the AVPla
**Figure 1** Playback state transition
-![Playback state change](figures/playback-status-change.png)
+![Playback status change](figures/playback-status-change.png)
For details about the state, see [AVPlayerState](../reference/apis/js-apis-media.md#avplayerstate9). When the AVPlayer is in the **prepared**, **playing**, **paused**, or **completed** state, the playback engine is working and a large amount of RAM is occupied. If your application does not need to use the AVPlayer, call **reset()** or **release()** to release the instance.
@@ -68,7 +68,9 @@ import common from '@ohos.app.ability.common';
export class AVPlayerDemo {
private avPlayer;
private count: number = 0;
-
+ private isSeek: boolean = true; // Specify whether the seek operation is supported.
+ private fileSize: number = -1;
+ private fd: number = 0;
// Set AVPlayer callback functions.
setAVPlayerCallback() {
// Callback function for the seek operation.
@@ -102,8 +104,13 @@ export class AVPlayerDemo {
case 'playing': // This state is reported upon a successful callback of play().
console.info('AVPlayer state playing called.');
if (this.count !== 0) {
- console.info('AVPlayer start to seek.');
- this.avPlayer.seek (this.avPlayer.duration); // Call seek() to seek to the end of the audio clip.
+ if (this.isSeek) {
+ console.info('AVPlayer start to seek.');
+ this.avPlayer.seek (this.avPlayer.duration); // Call seek() to seek to the end of the audio clip.
+ } else {
+ // When the seek operation is not supported, the playback continues until it reaches the end.
+ console.info('AVPlayer wait to play end.');
+ }
} else {
this.avPlayer.pause(); // Call pause() to pause the playback.
}
@@ -145,6 +152,7 @@ export class AVPlayerDemo {
// Open the corresponding file address to obtain the file descriptor and assign a value to the URL to trigger the reporting of the initialized state.
let file = await fs.open(path);
fdPath = fdPath + '' + file.fd;
+ this.isSeek = true; // The seek operation is supported.
this.avPlayer.url = fdPath;
}
@@ -158,10 +166,85 @@ export class AVPlayerDemo {
// The return type is {fd,offset,length}, where fd indicates the file descriptor address of the HAP file, offset indicates the media asset offset, and length indicates the duration of the media asset to play.
let context = getContext(this) as common.UIAbilityContext;
let fileDescriptor = await context.resourceManager.getRawFd('01.mp3');
+ this.isSeek = true; // The seek operation is supported.
// Assign a value to fdSrc to trigger the reporting of the initialized state.
this.avPlayer.fdSrc = fileDescriptor;
}
+
+ // The following demo shows how to use the file system to open the sandbox address, obtain the media file address, and play the media file with the seek operation using the dataSrc attribute.
+ async avPlayerDataSrcSeekDemo() {
+ // Create an AVPlayer instance.
+ this.avPlayer = await media.createAVPlayer();
+ // Set a callback function for state changes.
+ this.setAVPlayerCallback();
+ // dataSrc indicates the playback source address. When the seek operation is supported, fileSize indicates the size of the file to be played. The following describes how to assign a value to fileSize.
+ let src = {
+ fileSize: -1,
+ callback: (buf, length, pos) => {
+ let num = 0;
+ if (buf == undefined || length == undefined || pos == undefined) {
+ return -1;
+ }
+ num = fs.readSync(this.fd, buf, { offset: pos, length: length });
+ if (num > 0 && (this.fileSize >= pos)) {
+ return num;
+ }
+ return -1;
+ }
+ }
+ let context = getContext(this) as common.UIAbilityContext;
+ // Obtain the sandbox address filesDir through UIAbilityContext. The stage model is used as an example.
+ let pathDir = context.filesDir;
+ let path = pathDir + '/01.mp3';
+ await fs.open(path).then((file) => {
+ this.fd = file.fd;
+ })
+ // Obtain the size of the file to be played.
+ this.fileSize = fs.statSync(path).size;
+ src.fileSize = this.fileSize;
+ this.isSeek = true; // The seek operation is supported.
+ this.avPlayer.dataSrc = src;
+ }
+
+ // The following demo shows how to use the file system to open the sandbox address, obtain the media file address, and play the media file without the seek operation using the dataSrc attribute.
+ async avPlayerDataSrcNoSeekDemo() {
+ // Create an AVPlayer instance.
+ this.avPlayer = await media.createAVPlayer();
+ // Set a callback function for state changes.
+ this.setAVPlayerCallback();
+ let context = getContext(this) as common.UIAbilityContext;
+ let src: object = {
+ fileSize: -1,
+ callback: (buf, length, pos) => {
+ let num = 0;
+ if (buf == undefined || length == undefined) {
+ return -1;
+ }
+ num = fs.readSync(this.fd, buf);
+ if (num > 0) {
+ return num;
+ }
+ return -1;
+ }
+ }
+ // Obtain the sandbox address filesDir through UIAbilityContext. The stage model is used as an example.
+ let pathDir = context.filesDir;
+ let path = pathDir + '/01.mp3';
+ await fs.open(path).then((file) => {
+ this.fd = file.fd;
+ })
+ this.isSeek = false; // The seek operation is not supported.
+ this.avPlayer.dataSrc = src;
+ }
+
+ // The following demo shows how to play live streams by setting the network address through the URL.
+ async avPlayerLiveDemo() {
+ // Create an AVPlayer instance.
+ this.avPlayer = await media.createAVPlayer();
+ // Set a callback function for state changes.
+ this.setAVPlayerCallback();
+ this.isSeek = false; // The seek operation is not supported.
+ this.avPlayer.url = 'http://xxx.xxx.xxx.xxx:xx/xx/index.m3u8';
+ }
}
```
-
-
\ No newline at end of file
diff --git a/en/application-dev/media/using-avsession-controller.md b/en/application-dev/media/using-avsession-controller.md
index 5e4b69d8b48f5acad64f120892062e66d67c6b12..958661d90cec031cbbca1bb7c11ccb80e4dc0e66 100644
--- a/en/application-dev/media/using-avsession-controller.md
+++ b/en/application-dev/media/using-avsession-controller.md
@@ -1,6 +1,6 @@
# AVSession Controller
-Media Controller preset in OpenHarmony functions as the controller to interact with audio and video applications, for example, obtaining and displaying media information and delivering control commands.
+Media Controller preset in OpenHarmony functions as the controller to interact with audio and video applications, for example, obtaining and displaying media information and delivering playback control commands.
You can develop a system application (for example, a new playback control center or voice assistant) as the controller to interact with audio and video applications in the system.
@@ -8,24 +8,50 @@ You can develop a system application (for example, a new playback control center
- AVSessionDescriptor: session information, including the session ID, session type (audio/video), custom session name (**sessionTag**), information about the corresponding application (**elementName**), and whether the session is pined on top (isTopSession).
-- Top session: session with the highest priority in the system, for example, a session that is being played. Generally, the controller must hold an **AVSessionController** object to communicate with a session. However, the controller can directly communicate with the top session, for example, directly sending a control command or key event, without holding an **AVSessionController** object.
+- Top session: session with the highest priority in the system, for example, a session that is being played. Generally, the controller must hold an **AVSessionController** object to communicate with a session. However, the controller can directly communicate with the top session, for example, directly sending a playback control command or key event, without holding an **AVSessionController** object.
## Available APIs
-The table below lists the key APIs used by the controller. The APIs use either a callback or promise to return the result. The APIs listed below use a callback. They provide the same functions as their counterparts that use a promise.
+The key APIs used by the controller are classified into the following types:
+1. APIs called by the **AVSessionManager** object, which is obtained by means of import. An example API is **AVSessionManager.createController(sessionId)**.
+2. APIs called by the **AVSessionController** object. An example API is **controller.getAVPlaybackState()**.
+
+Asynchronous JavaScript APIs use either a callback or promise to return the result. The APIs listed below use a callback. They provide the same functions as their counterparts that use a promise.
For details, see [AVSession Management](../reference/apis/js-apis-avsession.md).
-| API| Description|
+### APIs Called by the AVSessionManager Object
+
+| API| Description|
+| -------- | -------- |
+| getAllSessionDescriptors(callback: AsyncCallback<Array<Readonly<AVSessionDescriptor>>>): void | Obtains the descriptors of all AVSessions in the system.|
+| createController(sessionId: string, callback: AsyncCallback<AVSessionController>): void | Creates an AVSessionController.|
+| getValidCommands(callback: AsyncCallback<Array<AVControlCommandType>>): void | Obtains valid commands supported by the AVSession.
Playback control commands listened by an audio and video application when it accesses the AVSession are considered as valid commands supported by the AVSession. For details, see [Provider of AVSession](using-avsession-developer.md).|
+| getLaunchAbility(callback: AsyncCallback<WantAgent>): void | Obtains the UIAbility that is configured in the AVSession and can be started.
The UIAbility configured here is started when a user operates the UI of the controller, for example, clicking a widget in Media Controller.|
+| sendAVKeyEvent(event: KeyEvent, callback: AsyncCallback<void>): void | Sends a key event to an AVSession through the AVSessionController object.|
+| sendSystemAVKeyEvent(event: KeyEvent, callback: AsyncCallback<void>): void | Sends a key event to the top session.|
+| sendControlCommand(command: AVControlCommand, callback: AsyncCallback<void>): void | Sends a playback control command to an AVSession through the AVSessionController object.|
+| sendSystemControlCommand(command: AVControlCommand, callback: AsyncCallback<void>): void | Sends a playback control command to the top session.|
+| getHistoricalSessionDescriptors(maxSize: number, callback: AsyncCallback\>>): void10+ | Obtains the descriptors of historical sessions.|
+
+### APIs Called by the AVSessionController Object
+
+| API| Description|
| -------- | -------- |
-| getAllSessionDescriptors(callback: AsyncCallback<Array<Readonly<AVSessionDescriptor>>>): void | Obtains the descriptors of all AVSessions in the system.|
-| createController(sessionId: string, callback: AsyncCallback<AVSessionController>): void | Creates an AVSessionController.|
-| getValidCommands(callback: AsyncCallback<Array<AVControlCommandType>>): void | Obtains valid commands supported by the AVSession.
Control commands listened by an audio and video application when it accesses the AVSession are considered as valid commands supported by the AVSession. For details, see [Provider of AVSession](using-avsession-developer.md).|
-| getLaunchAbility(callback: AsyncCallback<WantAgent>): void | Obtains the UIAbility that is configured in the AVSession and can be started.
The UIAbility configured here is started when a user operates the UI of the controller, for example, clicking a widget in Media Controller.|
-| sendAVKeyEvent(event: KeyEvent, callback: AsyncCallback<void>): void | Sends a key event to an AVSession through the AVSessionController object.|
-| sendSystemAVKeyEvent(event: KeyEvent, callback: AsyncCallback<void>): void | Sends a key event to the top session.|
-| sendControlCommand(command: AVControlCommand, callback: AsyncCallback<void>): void | Sends a control command to an AVSession through the AVSessionController object.|
-| sendSystemControlCommand(command: AVControlCommand, callback: AsyncCallback<void>): void | Sends a control command to the top session.|
+| getAVPlaybackState(callback: AsyncCallback<AVPlaybackState>): void | Obtains the information related to the playback state.|
+| getAVMetadata(callback: AsyncCallback<AVMetadata>): void | Obtains the session metadata.|
+| getOutputDevice(callback: AsyncCallback<OutputDeviceInfo>): void | Obtains the output device information.|
+| sendAVKeyEvent(event: KeyEvent, callback: AsyncCallback<void>): void | Sends a key event to the session corresponding to this controller.|
+| getLaunchAbility(callback: AsyncCallback<WantAgent>): void | Obtains the **WantAgent** object saved by the application in the session.|
+| isActive(callback: AsyncCallback<boolean>): void | Checks whether the session is activated.|
+| destroy(callback: AsyncCallback<void>): void | Destroys this controller. A controller can no longer be used after being destroyed.|
+| getValidCommands(callback: AsyncCallback<Array<AVControlCommandType>>): void | Obtains valid commands supported by the session.|
+| sendControlCommand(command: AVControlCommand, callback: AsyncCallback<void>): void | Sends a playback control command to the session through the controller.|
+| sendCommonCommand(command: string, args: {[key: string]: Object}, callback: AsyncCallback<void>): void10+ | Sends a custom playback control command to the session through the controller.|
+| getAVQueueItems(callback: AsyncCallback<Array<AVQueueItem>>): void10+ | Obtains the information related to the items in the playlist.|
+| getAVQueueTitle(callback: AsyncCallback<string>): void10+ | Obtains the name of the playlist.|
+| skipToQueueItem(itemId: number, callback: AsyncCallback<void>): void10+ | Sends the ID of an item in the playlist to the session for processing. The session can play the song.|
+| getExtras(callback: AsyncCallback<{[key: string]: Object}>): void10+ | Obtains the custom media packet set by the provider.|
## How to Develop
@@ -48,13 +74,26 @@ To enable a system application to access the AVSession service as a controller,
AVSessionManager.createController(descriptor.sessionId).then((controller) => {
g_controller.push(controller);
}).catch((err) => {
- console.error(`createController : ERROR : ${err.message}`);
+ console.error(`Failed to create controller. Code: ${err.code}, message: ${err.message}`);
});
});
}).catch((err) => {
- console.error(`getAllSessionDescriptors : ERROR : ${err.message}`);
+ console.error(`Failed to get all session descriptors. Code: ${err.code}, message: ${err.message}`);
});
+ // Obtain the descriptors of historical sessions.
+ 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.error(`Failed to get historical session descriptors, error code: ${err.code}, error message: ${err.message}`);
+ });
```
2. Listen for the session state and service state events.
@@ -74,7 +113,7 @@ To enable a system application to access the AVSession service as a controller,
AVSessionManager.createController(session.sessionId).then((controller) => {
g_controller.push(controller);
}).catch((err) => {
- console.info(`createController : ERROR : ${err.message}`);
+ console.error(`Failed to create controller. Code: ${err.code}, message: ${err.message}`);
});
});
@@ -103,7 +142,7 @@ To enable a system application to access the AVSession service as a controller,
// Subscribe to the 'sessionServiceDie' event.
AVSessionManager.on('sessionServiceDie', () => {
// The server is abnormal, and the application clears resources.
- console.info("Server exception.");
+ console.info(`Server exception.`);
})
```
@@ -117,6 +156,10 @@ To enable a system application to access the AVSession service as a controller,
- **validCommandChange**: triggered when the valid commands supported by the session changes.
- **outputDeviceChange**: triggered when the output device changes.
- **sessionDestroy**: triggered when a session is destroyed.
+ - **sessionEvent**: triggered when the custom session event changes.
+ - **extrasChange**: triggered when the custom media packet of the session changes.
+ - **queueItemsChange**: triggered when one or more items in the custom playlist of the session changes.
+ - **queueTitleChange**: triggered when the custom playlist name of the session changes.
The controller can listen for events as required.
@@ -124,18 +167,18 @@ To enable a system application to access the AVSession service as a controller,
// Subscribe to the 'activeStateChange' event.
controller.on('activeStateChange', (isActive) => {
if (isActive) {
- console.info("The widget corresponding to the controller is highlighted.");
+ console.info(`The widget corresponding to the controller is highlighted.`);
} else {
- console.info("The widget corresponding to the controller is invalid.");
+ console.info(`The widget corresponding to the controller is invalid.`);
}
});
// Subscribe to the 'sessionDestroy' event to enable the controller to get notified when the session dies.
controller.on('sessionDestroy', () => {
- console.info('on sessionDestroy : SUCCESS ');
+ info(`on sessionDestroy : SUCCESS `);
controller.destroy().then(() => {
- console.info('destroy : SUCCESS ');
+ console.info(`destroy : SUCCESS`);
}).catch((err) => {
- console.info(`destroy : ERROR :${err.message}`);
+ console.error(`Failed to destroy session. Code: ${err.code}, message: ${err.message}`);
});
});
@@ -164,10 +207,26 @@ To enable a system application to access the AVSession service as a controller,
controller.on('outputDeviceChange', (device) => {
console.info(`on outputDeviceChange device isRemote : ${device.isRemote}`);
});
+ // Subscribe to custom session event changes.
+ controller.on('sessionEvent', (eventName, eventArgs) => {
+ console.info(`Received new session event, event name is ${eventName}, args are ${JSON.stringify(eventArgs)}`);
+ });
+ // Subscribe to custom media packet changes.
+ controller.on('extrasChange', (extras) => {
+ console.info(`Received custom media packet, packet data is ${JSON.stringify(extras)}`);
+ });
+ // Subscribe to custom playlist item changes.
+ controller.on('queueItemsChange', (items) => {
+ console.info(`Caught queue items change, items length is ${items.length}`);
+ });
+ // Subscribe to custom playback name changes.
+ controller.on('queueTitleChange', (title) => {
+ console.info(`Caught queue title change, title is ${title}`);
+ });
```
4. Obtain the media information transferred by the provider for display on the UI, for example, displaying the track being played and the playback state in Media Controller.
-
+
```ts
async getInfoFromSessionByController() {
// It is assumed that an AVSessionController object corresponding to the session already exists. For details about how to create an AVSessionController object, see the code snippet above.
@@ -186,19 +245,36 @@ To enable a system application to access the AVSession service as a controller,
let avPlaybackState: AVSessionManager.AVPlaybackState = await controller.getAVPlaybackState();
console.info(`get playbackState by controller : ${avPlaybackState.state}`);
console.info(`get favoriteState by controller : ${avPlaybackState.isFavorite}`);
+ // Obtain the playlist items of the session.
+ let queueItems: Array = await controller.getAVQueueItems();
+ console.info(`get queueItems length by controller : ${queueItems.length}`);
+ // Obtain the playlist name of the session.
+ let queueTitle: string = await controller.getAVQueueTitle();
+ console.info(`get queueTitle by controller : ${queueTitle}`);
+ // Obtain the custom media packet of the session.
+ let extras: any = await controller.getExtras();
+ console.info(`get custom media packets by controller : ${JSON.stringify(extras)}`);
+ // Obtain the ability information provided by the application corresponding to the session.
+ let agent: WantAgent = await controller.getLaunchAbility();
+ console.info(`get want agent info by controller : ${JSON.stringify(agent)}`);
+ // Obtain the current playback position of the session.
+ let currentTime: number = controller.getRealPlaybackPositionSync();
+ console.info(`get current playback time by controller : ${currentTime}`);
+ // Obtain valid commands supported by the session.
+ let validCommands: Array = await controller.getValidCommands();
+ console.info(`get valid commands by controller : ${JSON.stringify(validCommands)}`);
}
```
5. Control the playback behavior, for example, sending a command to operate (play/pause/previous/next) the item being played in Media Controller.
- After listening for the control command event, the audio and video application serving as the provider needs to implement the corresponding operation.
+ After listening for the playback control command event, the audio and video application serving as the provider needs to implement the corresponding operation.
-
```ts
async sendCommandToSessionByController() {
// It is assumed that an AVSessionController object corresponding to the session already exists. For details about how to create an AVSessionController object, see the code snippet above.
let controller: AVSessionManager.AVSessionController = ALLREADY_HAVE_A_CONTROLLER;
- // Obtain the commands supported by the session.
+ // Obtain valid commands supported by the session.
let validCommandTypeArray: Array = await controller.getValidCommands();
console.info(`get validCommandArray by controller : length : ${validCommandTypeArray.length}`);
// Deliver the 'play' command.
@@ -222,11 +298,28 @@ To enable a system application to access the AVSession service as a controller,
let avCommand: AVSessionManager.AVControlCommand = {command:'playNext'};
controller.sendControlCommand(avCommand);
}
+ // Deliver a custom playback control command.
+ let commandName: string = 'custom command';
+ let args = {
+ command : 'This is my custom command'
+ }
+ await controller.sendCommonCommand(commandName, args).then(() => {
+ console.info(`SendCommonCommand successfully`);
+ }).catch((err) => {
+ console.error(`Failed to send common command. Code: ${err.code}, message: ${err.message}`);
+ })
+ // Set the ID of an item in the specified playlist for the session to play.
+ let queueItemId: number = 0;
+ await controller.skipToQueueItem(queueItemId).then(() => {
+ console.info(`SkipToQueueItem successfully`);
+ }).catch((err) => {
+ console.error(`Failed to skip to queue item. Code: ${err.code}, message: ${err.message}`);
+ });
}
```
6. When the audio and video application exits, cancel the listener and release the resources.
-
+
```ts
async destroyController() {
// It is assumed that an AVSessionController object corresponding to the session already exists. For details about how to create an AVSessionController object, see the code snippet above.
@@ -235,9 +328,9 @@ To enable a system application to access the AVSession service as a controller,
// Destroy the AVSessionController object. After being destroyed, it is no longer available.
controller.destroy(function (err) {
if (err) {
- console.info(`Destroy controller ERROR : code: ${err.code}, message: ${err.message}`);
+ console.error(`Failed to destroy controller. Code: ${err.code}, message: ${err.message}`);
} else {
- console.info('Destroy controller SUCCESS');
+ console.info(`Destroy controller SUCCESS`);
}
});
}
diff --git a/en/application-dev/media/using-avsession-developer.md b/en/application-dev/media/using-avsession-developer.md
index 077f0b956a5fb6abaf26c647132bdbb81e78fc63..bf0b914647b9c364bea0ac86a30def88fe3c0f52 100644
--- a/en/application-dev/media/using-avsession-developer.md
+++ b/en/application-dev/media/using-avsession-developer.md
@@ -1,12 +1,12 @@
# AVSession Provider
-An audio and video application needs to access the AVSession service as a provider in order to display media information in the controller (for example, Media Controller) and respond to control commands delivered by the controller.
+An audio and video application needs to access the AVSession service as a provider in order to display media information in the controller (for example, Media Controller) and respond to playback control commands delivered by the controller.
## Basic Concepts
- AVMetadata: media data related attributes, including the IDs of the current media asset (assetId), previous media asset (previousAssetId), and next media asset (nextAssetId), title, author, album, writer, and duration.
-- AVPlaybackState: playback state attributes, including the playback state, position, speed, buffered time, loop mode, and whether the media asset is favorited (**isFavorite**).
+- AVPlaybackState: playback state attributes, including the playback state, position, speed, buffered time, loop mode, media item being played (activeItemId), custom media data (extras), and whether the media asset is favorited (isFavorite).
## Available APIs
@@ -14,28 +14,43 @@ The table below lists the key APIs used by the provider. The APIs use either a c
For details, see [AVSession Management](../reference/apis/js-apis-avsession.md).
-| API| Description|
+| API| Description|
| -------- | -------- |
-| createAVSession(context: Context, tag: string, type: AVSessionType, callback: AsyncCallback<AVSession>): void | Creates an AVSession.
Only one AVSession can be created for a UIAbility.|
-| setAVMetadata(data: AVMetadata, callback: AsyncCallback<void>): void | Sets AVSession metadata.|
-| setAVPlaybackState(state: AVPlaybackState, callback: AsyncCallback<void>): void | Sets the AVSession playback state.|
-| setLaunchAbility(ability: WantAgent, callback: AsyncCallback<void>): void | Starts a UIAbility.|
-| getController(callback: AsyncCallback<AVSessionController>): void | Obtains the controller of the AVSession.|
-| activate(callback: AsyncCallback<void>): void | Activates the AVSession.|
-| destroy(callback: AsyncCallback<void>): void | Destroys the AVSession.|
+| createAVSession(context: Context, tag: string, type: AVSessionType, callback: AsyncCallback<AVSession>): void | Creates an AVSession.
Only one AVSession can be created for a UIAbility.|
+| setAVMetadata(data: AVMetadata, callback: AsyncCallback<void>): void | Sets AVSession metadata.|
+| setAVPlaybackState(state: AVPlaybackState, callback: AsyncCallback<void>): void | Sets the AVSession playback state.|
+| setLaunchAbility(ability: WantAgent, callback: AsyncCallback<void>): void | Starts a UIAbility.|
+| getController(callback: AsyncCallback<AVSessionController>): void | Obtains the controller of the AVSession.|
+| getOutputDevice(callback: AsyncCallback<OutputDeviceInfo>): void | Obtains the output device information.|
+| activate(callback: AsyncCallback<void>): void | Activates the AVSession.|
+| deactivate(callback: AsyncCallback<void>): void | Deactivates this session.|
+| destroy(callback: AsyncCallback<void>): void | Destroys the AVSession.|
+| setAVQueueItems(items: Array<AVQueueItem>, callback: AsyncCallback<void>): void 10+ | Sets a playlist.|
+| setAVQueueTitle(title: string, callback: AsyncCallback<void>): void10+ | Sets a name for the playlist.|
+| dispatchSessionEvent(event: string, args: {[key: string]: Object}, callback: AsyncCallback<void>): void10+ | Dispatches a custom session event.|
+| setExtras(extras: {[key: string]: Object}, callback: AsyncCallback<void>): void10+ | Sets a custom media packet in the form of a key-value pair.|
## How to Develop
To enable an audio and video application to access the AVSession service as a provider, proceed as follows:
1. Call an API in the **AVSessionManager** class to create and activate an **AVSession** object.
-
+
```ts
+ // To create an AVSession object, you must first obtain the application context. You can set a global variable in the EntryAbility file of the application to store the application context.
+ export default class EntryAbility extends UIAbility {
+ onCreate(want, launchParam) {
+ globalThis.context = this.context; // Set the global variable globalThis.context to store the application context.
+ }
+ // Other APIs of the EntryAbility class.
+ }
+
+ // Start to create and activate an AVSession object.
import AVSessionManager from '@ohos.multimedia.avsession'; // Import the AVSessionManager module.
// Create an AVSession object.
async createSession() {
- let session: AVSessionManager.AVSession = await AVSessionManager.createAVSession(this.context, 'SESSION_NAME', 'audio');
+ let session: AVSessionManager.AVSession = await AVSessionManager.createAVSession(globalThis.context, 'SESSION_NAME', 'audio');
session.activate();
console.info(`session create done : sessionId : ${session.sessionId}`);
}
@@ -46,22 +61,22 @@ To enable an audio and video application to access the AVSession service as a pr
- AVPlaybackState
The controller will call an API in the **AVSessionController** class to obtain the information and display or process the information.
-
+
```ts
async setSessionInfo() {
- // It is assumed that an AVSession object has been created. For details about how to create an AVSession object, see the node snippet above.
- let session: AVSessionManager.AVSession = ALLREADY_CREATE_A_SESSION;
+ // It is assumed that an AVSession object has been created. For details about how to create an AVSession object, see the node snippet in step 1.
+ let session: AVSessionManager.AVSession = ALREADY_CREATE_A_SESSION;
// The player logic that triggers changes in the session metadata and playback state is omitted here.
// Set necessary session metadata.
let metadata: AVSessionManager.AVMetadata = {
- assetId: "0",
- title: "TITLE",
- artist: "ARTIST"
+ assetId: '0',
+ title: 'TITLE',
+ artist: 'ARTIST'
};
session.setAVMetadata(metadata).then(() => {
- console.info('SetAVMetadata successfully');
+ console.info(`SetAVMetadata successfully`);
}).catch((err) => {
- console.info(`SetAVMetadata BusinessError: code: ${err.code}, message: ${err.message}`);
+ console.error(`Failed to set AVMetadata. Code: ${err.code}, message: ${err.message}`);
});
// Set the playback state to paused and set isFavorite to false.
let playbackState: AVSessionManager.AVPlaybackState = {
@@ -70,86 +85,230 @@ To enable an audio and video application to access the AVSession service as a pr
};
session.setAVPlaybackState(playbackState, function (err) {
if (err) {
- console.info(`SetAVPlaybackState BusinessError: code: ${err.code}, message: ${err.message}`);
+ console.error(`Failed to set AVPlaybackState. Code: ${err.code}, message: ${err.message}`);
} else {
- console.info('SetAVPlaybackState successfully');
+ console.info(`SetAVPlaybackState successfully`);
}
});
+ // Set a playlist.
+ let queueItemDescription_1 = {
+ mediaId: '001',
+ title: 'music_name',
+ subtitle: 'music_sub_name',
+ description: 'music_description',
+ icon: PIXELMAP_OBJECT,
+ iconUri: 'http://www.xxx.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.xxx.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.error(`Failed to set AVQueueItem, error code: ${err.code}, error message: ${err.message}`);
+ });
+ // Set a name for the playlist.
+ let queueTitle = 'QUEUE_TITLE';
+ session.setAVQueueTitle(queueTitle).then(() => {
+ console.info(`SetAVQueueTitle successfully`);
+ }).catch((err) => {
+ console.info(`Failed to set AVQueueTitle, error code: ${err.code}, error message: ${err.message}`);
+ });
}
```
3. Set the UIAbility to be started by the controller. The UIAbility configured here is started when a user operates the UI of the controller, for example, clicking a widget in Media Controller.
The UIAbility is set through the **WantAgent** API. For details, see [WantAgent](../reference/apis/js-apis-app-ability-wantAgent.md).
-
+
```ts
- import WantAgent from "@ohos.app.ability.wantAgent";
+ import wantAgent from "@ohos.app.ability.wantAgent";
```
```ts
- // It is assumed that an AVSession object has been created. For details about how to create an AVSession object, see the node snippet above.
- let session: AVSessionManager.AVSession = ALLREADY_CREATE_A_SESSION;
+ // It is assumed that an AVSession object has been created. For details about how to create an AVSession object, see the node snippet in step 1.
+ let session: AVSessionManager.AVSession = ALREADY_CREATE_A_SESSION;
let wantAgentInfo = {
wants: [
{
- bundleName: "com.example.musicdemo",
- abilityName: "com.example.musicdemo.MainAbility"
+ bundleName: 'com.example.musicdemo',
+ abilityName: 'com.example.musicdemo.MainAbility'
}
],
- operationType: WantAgent.OperationType.START_ABILITIES,
+ operationType: wantAgent.OperationType.START_ABILITIES,
requestCode: 0,
- wantAgentFlags: [WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
+ wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
}
- WantAgent.getWantAgent(wantAgentInfo).then((agent) => {
- session.setLaunchAbility(agent)
+ wantAgent.getWantAgent(wantAgentInfo).then((agent) => {
+ session.setLaunchAbility(agent);
})
```
-4. Listen for control commands delivered by the controller, for example, Media Controller.
+4. Set a custom session event. The controller performs an operation after receiving the event.
+
> **NOTE**
>
- > After the provider registers a listener for the control command event, the event will be reflected in **getValidCommands()** of the controller. In other words, the controller determines that the command is valid and triggers the corresponding event as required. To ensure that the control commands delivered by the controller can be executed normally, the provider should not use a null implementation for listening.
-
+ > The data set through **dispatchSessionEvent** is not saved in the **AVSession** object or AVSession service.
+
```ts
- async setListenerForMesFromController() {
- // It is assumed that an AVSession object has been created. For details about how to create an AVSession object, see the node snippet above.
- let session: AVSessionManager.AVSession = ALLREADY_CREATE_A_SESSION;
- // Generally, logic processing on the player is implemented in the listener.
- // After the processing is complete, use the setter to synchronize the playback information. For details, see the code snippet above.
- session.on('play', () => {
- console.info('on play , do play task');
-
- // do some tasks ···
- });
- session.on('pause', () => {
- console.info('on pause , do pause task');
- // do some tasks ···
- });
- session.on('stop', () => {
- console.info('on stop , do stop task');
- // do some tasks ···
- });
- session.on('playNext', () => {
- console.info('on playNext , do playNext task');
- // do some tasks ···
- });
- session.on('playPrevious', () => {
- console.info('on playPrevious , do playPrevious task');
- // do some tasks ···
- });
+ // It is assumed that an AVSession object has been created. For details about how to create an AVSession object, see the node snippet in step 1.
+ let session: AVSessionManager.AVSession = ALREADY_CREATE_A_SESSION;
+ let eventName = 'dynamic_lyric';
+ let args = {
+ lyric : 'This is my lyric'
}
+ await session.dispatchSessionEvent(eventName, args).then(() => {
+ console.info(`Dispatch session event successfully`);
+ }).catch((err) => {
+ console.error(`Failed to dispatch session event. Code: ${err.code}, message: ${err.message}`);
+ })
```
-5. Obtain an **AVSessionController** object for this **AVSession** object for interaction.
-
+5. Set a custom media packet. The controller performs an operation after receiving the event.
+
+ > **NOTE**
+ >
+ > The data set by using **setExtras** is stored in the AVSession service. The data lifecycle is the same as that of the **AVSession** object, and the controller corresponding to the object can use **getExtras** to obtain the data.
+
+ ```ts
+ // It is assumed that an AVSession object has been created. For details about how to create an AVSession object, see the node snippet in step 1.
+ let session: AVSessionManager.AVSession = ALREADY_CREATE_A_SESSION;
+ let extras = {
+ extra : 'This is my custom meida packet'
+ }
+ await session.setExtras(extras).then(() => {
+ console.info(`Set extras successfully`);
+ }).catch((err) => {
+ console.error(`Failed to set extras. Code: ${err.code}, message: ${err.message}`);
+ })
+ ```
+
+6. Listen for playback control commands or events delivered by the controller, for example, Media Controller.
+
+ Both fixed playback control commands and advanced playback control events can be listened for.
+
+ - Listening for Fixed Playback Control Commands
+
+ > **NOTE**
+ >
+ > After the provider registers a listener for fixed playback control commands, the commands will be reflected in **getValidCommands()** of the controller. In other words, the controller determines that the command is valid and triggers the corresponding event as required. To ensure that the playback control commands delivered by the controller can be executed normally, the provider should not use a null implementation for listening.
+
+ Fixed playback control commands on the session side include basic operation commands such as play, pause, previous, and next. For details, see [AVControlCommand](../reference/apis/js-apis-avsession.md).
+
+ ```ts
+ async setListenerForMesFromController() {
+ // It is assumed that an AVSession object has been created. For details about how to create an AVSession object, see the node snippet in step 1.
+ let session: AVSessionManager.AVSession = ALREADY_CREATE_A_SESSION;
+ // Generally, logic processing on the player is implemented in the listener.
+ // After the processing is complete, use the setter to synchronize the playback information. For details, see the code snippet above.
+ session.on('play', () => {
+ console.info(`on play , do play task`);
+ // do some tasks ···
+ });
+ session.on('pause', () => {
+ console.info(`on pause , do pause task`);
+ // do some tasks ···
+ });
+ session.on('stop', () => {
+ console.info(`on stop , do stop task`);
+ // do some tasks ···
+ });
+ session.on('playNext', () => {
+ console.info(`on playNext , do playNext task`);
+ // do some tasks ···
+ });
+ session.on('playPrevious', () => {
+ console.info(`on playPrevious , do playPrevious task`);
+ // do some tasks ···
+ });
+ session.on('fastForward', () => {
+ console.info(`on fastForward , do fastForward task`);
+ // do some tasks ···
+ });
+ session.on('rewind', () => {
+ console.info(`on rewind , do rewind task`);
+ // do some tasks ···
+ });
+
+ session.on('seek', (time) => {
+ console.info(`on seek , the seek time is ${time}`);
+ // do some tasks ···
+ });
+ session.on('setSpeed', (speed) => {
+ console.info(`on setSpeed , the speed is ${speed}`);
+ // do some tasks ···
+ });
+ session.on('setLoopMode', (mode) => {
+ console.info(`on setLoopMode , the loop mode is ${mode}`);
+ // do some tasks ···
+ });
+ session.on('toggleFavorite', (assetId) => {
+ console.info(`on toggleFavorite , the target asset Id is ${assetId}`);
+ // do some tasks ···
+ });
+ }
+ ```
+
+ - Listening for Advanced Playback Control Events
+
+ The following advanced playback control events can be listened for:
+
+ - **skipToQueueItem**: triggered when an item in the playlist is selected.
+ - **handleKeyEvent**: triggered when a key is pressed.
+ - **outputDeviceChange**: triggered when the output device changes.
+ - **commonCommand**: triggered when a custom playback control command changes.
+
+ ```ts
+ async setListenerForMesFromController() {
+ // It is assumed that an AVSession object has been created. For details about how to create an AVSession object, see the node snippet in step 1.
+ let session: AVSessionManager.AVSession = ALREADY_CREATE_A_SESSION;
+ // Generally, logic processing on the player is implemented in the listener.
+ // After the processing is complete, use the setter to synchronize the playback information. For details, see the code snippet above.
+ session.on('skipToQueueItem', (itemId) => {
+ console.info(`on skipToQueueItem , do skip task`);
+ // do some tasks ···
+ });
+ session.on('handleKeyEvent', (event) => {
+ console.info(`on handleKeyEvent , the event is ${JSON.stringify(event)}`);
+ // do some tasks ···
+ });
+ session.on('outputDeviceChange', (device) => {
+ console.info(`on outputDeviceChange , the device info is ${JSON.stringify(device)}`);
+ // do some tasks ···
+ });
+ session.on('commonCommand', (commandString, args) => {
+ console.info(`on commonCommand , command is ${commandString}, args are ${JSON.stringify(args)}`);
+ // do some tasks ···
+ });
+ }
+ ```
+
+7. Obtain an **AVSessionController** object for this **AVSession** object for interaction.
+
```ts
async createControllerFromSession() {
- // It is assumed that an AVSession object has been created. For details about how to create an AVSession object, see the node snippet above.
- let session: AVSessionManager.AVSession = ALLREADY_CREATE_A_SESSION;
+ // It is assumed that an AVSession object has been created. For details about how to create an AVSession object, see the node snippet in step 1.
+ let session: AVSessionManager.AVSession = ALREADY_CREATE_A_SESSION;
// Obtain an AVSessionController object for this AVSession object.
let controller: AVSessionManager.AVSessionController = await session.getController();
- // The AVSessionController object can interact with the AVSession object, for example, by delivering a control command.
+ // The AVSessionController object can interact with the AVSession object, for example, by delivering a playback control command.
let avCommand: AVSessionManager.AVControlCommand = {command:'play'};
controller.sendControlCommand(avCommand);
@@ -163,13 +322,14 @@ To enable an audio and video application to access the AVSession service as a pr
}
```
-6. When the audio and video application exits and does not need to continue playback, cancel the listener and destroy the **AVSession** object.
- The code snippet below is used for canceling the listener for control commands:
+8. When the audio and video application exits and does not need to continue playback, cancel the listener and destroy the **AVSession** object.
+
+ The code snippet below is used for canceling the listener for playback control commands:
```ts
async unregisterSessionListener() {
- // It is assumed that an AVSession object has been created. For details about how to create an AVSession object, see the node snippet above.
- let session: AVSessionManager.AVSession = ALLREADY_CREATE_A_SESSION;
+ // It is assumed that an AVSession object has been created. For details about how to create an AVSession object, see the node snippet in step 1.
+ let session: AVSessionManager.AVSession = ALREADY_CREATE_A_SESSION;
// Cancel the listener of the AVSession object.
session.off('play');
@@ -177,22 +337,27 @@ To enable an audio and video application to access the AVSession service as a pr
session.off('stop');
session.off('playNext');
session.off('playPrevious');
+ session.off('skipToQueueItem');
+ session.off('handleKeyEvent');
+ session.off('outputDeviceChange');
+ session.off('commonCommand');
}
```
-
- The code snippet below is used for destroying the AVSession object:
-
- ```ts
+
+
+ The code snippet below is used for destroying the AVSession object:
+
+ ```ts
async destroySession() {
- // It is assumed that an AVSession object has been created. For details about how to create an AVSession object, see the node snippet above.
- let session: AVSessionManager.AVSession = ALLREADY_CREATE_A_SESSION;
- // Destroy the AVSession object.
- session.destroy(function (err) {
- if (err) {
- console.info(`Destroy BusinessError: code: ${err.code}, message: ${err.message}`);
- } else {
- console.info('Destroy : SUCCESS ');
- }
- });
+ // It is assumed that an AVSession object has been created. For details about how to create an AVSession object, see the node snippet in step 1.
+ let session: AVSessionManager.AVSession = ALREADY_CREATE_A_SESSION;
+ // Destroy the AVSession object.
+ session.destroy(function (err) {
+ if (err) {
+ console.error(`Failed to destroy session. Code: ${err.code}, message: ${err.message}`);
+ } else {
+ console.info(`Destroy : SUCCESS `);
+ }
+ });
}
- ```
+ ```
\ No newline at end of file
diff --git a/en/application-dev/media/using-distributed-avsession.md b/en/application-dev/media/using-distributed-avsession.md
index c1835d661fdd2b57b7dce0f2507dbea748eaea7e..fc5c49b9804b67750228a010c1c53d58a2086bbf 100644
--- a/en/application-dev/media/using-distributed-avsession.md
+++ b/en/application-dev/media/using-distributed-avsession.md
@@ -36,15 +36,15 @@ To enable a system application that accesses the AVSession service as the contro
let audioDevices;
await audioRoutingManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG).then((data) => {
audioDevices = data;
- console.info('Promise returned to indicate that the device list is obtained.');
+ console.info(`Promise returned to indicate that the device list is obtained.`);
}).catch((err) => {
- console.info(`getDevices : ERROR : ${err.message}`);
+ console.error(`Failed to get devices. Code: ${err.code}, message: ${err.message}`);
});
AVSessionManager.castAudio('all', audioDevices).then(() => {
- console.info('createController : SUCCESS');
+ console.info(`createController : SUCCESS`);
}).catch((err) => {
- console.info(`createController : ERROR : ${err.message}`);
+ console.error(`Failed to cast audio. Code: ${err.code}, message: ${err.message}`);
});
```
diff --git a/en/application-dev/media/video-playback.md b/en/application-dev/media/video-playback.md
index fff4aa830ddc45e7d20e0fd06655adfdc5243fe5..f745f2f25120f7068de6634af56aa1f443c5b5d9 100644
--- a/en/application-dev/media/video-playback.md
+++ b/en/application-dev/media/video-playback.md
@@ -78,7 +78,9 @@ export class AVPlayerDemo {
private avPlayer;
private count: number = 0;
private surfaceID: string; // The surfaceID parameter specifies the window used to display the video. Its value is obtained through the XComponent.
-
+ private isSeek: boolean = true; // Specify whether the seek operation is supported.
+ private fileSize: number = -1;
+ private fd: number = 0;
// Set AVPlayer callback functions.
setAVPlayerCallback() {
// Callback function for the seek operation.
@@ -113,8 +115,13 @@ export class AVPlayerDemo {
case 'playing': // This state is reported upon a successful callback of play().
console.info('AVPlayer state playing called.');
if (this.count !== 0) {
- console.info('AVPlayer start to seek.');
- this.avPlayer.seek (this.avPlayer.duration); // Call seek() to seek to the end of the video clip.
+ if (this.isSeek) {
+ console.info('AVPlayer start to seek.');
+ this.avPlayer.seek (this.avPlayer.duration); // Call seek() to seek to the end of the video clip.
+ } else {
+ // When the seek operation is not supported, the playback continues until it reaches the end.
+ console.info('AVPlayer wait to play end.');
+ }
} else {
this.avPlayer.pause(); // Call pause() to pause the playback.
}
@@ -152,10 +159,11 @@ export class AVPlayerDemo {
let context = getContext(this) as common.UIAbilityContext;
// Obtain the sandbox address filesDir through UIAbilityContext. The stage model is used as an example.
let pathDir = context.filesDir;
- let path = pathDir + '/H264_AAC.mp4';
+ let path = pathDir + '/H264_AAC.mp4';
// Open the corresponding file address to obtain the file descriptor and assign a value to the URL to trigger the reporting of the initialized state.
let file = await fs.open(path);
fdPath = fdPath + '' + file.fd;
+ this.isSeek = true; // The seek operation is supported.
this.avPlayer.url = fdPath;
}
@@ -169,9 +177,86 @@ export class AVPlayerDemo {
// The return type is {fd,offset,length}, where fd indicates the file descriptor address of the HAP file, offset indicates the media asset offset, and length indicates the duration of the media asset to play.
let context = getContext(this) as common.UIAbilityContext;
let fileDescriptor = await context.resourceManager.getRawFd('H264_AAC.mp4');
+ this.isSeek = true; // The seek operation is supported.
// Assign a value to fdSrc to trigger the reporting of the initialized state.
this.avPlayer.fdSrc = fileDescriptor;
}
+
+ // The following demo shows how to use the file system to open the sandbox address, obtain the media file address, and play the media file with the seek operation using the dataSrc attribute.
+ async avPlayerDataSrcSeekDemo() {
+ // Create an AVPlayer instance.
+ this.avPlayer = await media.createAVPlayer();
+ // Set a callback function for state changes.
+ this.setAVPlayerCallback();
+ // dataSrc indicates the playback source address. When the seek operation is supported, fileSize indicates the size of the file to be played. The following describes how to assign a value to fileSize.
+ let src = {
+ fileSize: -1,
+ callback: (buf, length, pos) => {
+ let num = 0;
+ if (buf == undefined || length == undefined || pos == undefined) {
+ return -1;
+ }
+ num = fs.readSync(this.fd, buf, { offset: pos, length: length });
+ if (num > 0 && (this.fileSize >= pos)) {
+ return num;
+ }
+ return -1;
+ }
+ }
+ let context = getContext(this) as common.UIAbilityContext;
+ // Obtain the sandbox address filesDir through UIAbilityContext. The stage model is used as an example.
+ let pathDir = context.filesDir;
+ let path = pathDir + '/H264_AAC.mp4';
+ await fs.open(path).then((file) => {
+ this.fd = file.fd;
+ })
+ // Obtain the size of the file to be played.
+ this.fileSize = fs.statSync(path).size;
+ src.fileSize = this.fileSize;
+ this.isSeek = true; // The seek operation is supported.
+ this.avPlayer.dataSrc = src;
+ }
+
+ // The following demo shows how to use the file system to open the sandbox address, obtain the media file address, and play the media file without the seek operation using the dataSrc attribute.
+ async avPlayerDataSrcNoSeekDemo() {
+ // Create an AVPlayer instance.
+ this.avPlayer = await media.createAVPlayer();
+ // Set a callback function for state changes.
+ this.setAVPlayerCallback();
+ let context = getContext(this) as common.UIAbilityContext;
+ let src: object = {
+ fileSize: -1,
+ callback: (buf, length, pos) => {
+ let num = 0;
+ if (buf == undefined || length == undefined) {
+ return -1;
+ }
+ num = fs.readSync(this.fd, buf);
+ if (num > 0) {
+ return num;
+ }
+ return -1;
+ }
+ }
+ // Obtain the sandbox address filesDir through UIAbilityContext. The stage model is used as an example.
+ let pathDir = context.filesDir;
+ let path = pathDir + '/H264_AAC.mp4';
+ await fs.open(path).then((file) => {
+ this.fd = file.fd;
+ })
+ this.isSeek = false; // The seek operation is not supported.
+ this.avPlayer.dataSrc = src;
+ }
+
+ // The following demo shows how to play live streams by setting the network address through the URL.
+ async avPlayerLiveDemo() {
+ // Create an AVPlayer instance.
+ this.avPlayer = await media.createAVPlayer();
+ // Set a callback function for state changes.
+ this.setAVPlayerCallback();
+ this.isSeek = false; // The seek operation is not supported.
+ this.avPlayer.url = 'http://xxx.xxx.xxx.xxx:xx/xx/index.m3u8'; // Play live webcasting streams using HLS.
+ }
}
```
diff --git a/en/application-dev/quick-start/arkts-observed-and-objectlink.md b/en/application-dev/quick-start/arkts-observed-and-objectlink.md
index a84802480d1fbd3eb4b6942d5b8f1a2f5f642aa1..1282545cc1d65a1acdc90da3ac5a2828cf611ca9 100644
--- a/en/application-dev/quick-start/arkts-observed-and-objectlink.md
+++ b/en/application-dev/quick-start/arkts-observed-and-objectlink.md
@@ -316,7 +316,7 @@ class StringArray extends Array {
-Declare a class that extends from** Array**: **class StringArray extends Array\ {}** and create an instance of **StringArray**. The use of the **new** operator is required for the \@Observed class decorator to work properly.
+Declare a class that extends from **Array**: **class StringArray extends Array\ {}** and create an instance of **StringArray**. The use of the **new** operator is required for the \@Observed class decorator to work properly.
```ts
diff --git a/en/application-dev/quick-start/arkts-page-custom-components-lifecycle.md b/en/application-dev/quick-start/arkts-page-custom-components-lifecycle.md
index 2b8f2293918bef081b6f6377a99d6fdb2e35a03e..90a06cc468f5dc383ec3cf15a9f2d8a894f63239 100644
--- a/en/application-dev/quick-start/arkts-page-custom-components-lifecycle.md
+++ b/en/application-dev/quick-start/arkts-page-custom-components-lifecycle.md
@@ -19,7 +19,7 @@ The following lifecycle callbacks are provided for the lifecycle of a page, that
- [onBackPress](../reference/arkui-ts/ts-custom-component-lifecycle.md#onbackpress): Invoked when the user clicks the Back button.
-The following lifecycle callbacks are provided for the lifecycle of a custom component, which is one decorated with \@Component:
+The following lifecycle callbacks are provided for the lifecycle of a component, that is, the lifecycle of a custom component decorated with \@Component:
- [aboutToAppear](../reference/arkui-ts/ts-custom-component-lifecycle.md#abouttoappear): Invoked when the custom component is about to appear. Specifically, it is invoked after a new instance of the custom component is created and before its **build** function is executed.
@@ -134,7 +134,7 @@ struct MyComponent {
Child()
}
// When this.showChild is false, the Child child component is deleted, and Child aboutToDisappear is invoked.
- Button('create or delete Child').onClick(() => {
+ Button('delete Child').onClick(() => {
this.showChild = false;
})
// Because of the pushing from the current page to Page2, onPageHide is invoked.
diff --git a/en/application-dev/quick-start/arkts-rendering-control-lazyforeach.md b/en/application-dev/quick-start/arkts-rendering-control-lazyforeach.md
index 7086569f912a0c447228643958c38b3bd16e0045..95b6665c834a4bdf281b4712717e71f51659c112 100644
--- a/en/application-dev/quick-start/arkts-rendering-control-lazyforeach.md
+++ b/en/application-dev/quick-start/arkts-rendering-control-lazyforeach.md
@@ -75,15 +75,17 @@ interface DataChangeListener {
}
```
-| Declaration | Parameter Type | Description |
-| ---------------------------------------- | -------------------------------------- | ---------------------------------------- |
-| onDataReloaded(): void | - | Invoked when all data is reloaded. |
-| onDataAdded(index: number):void | number | Invoked when data is added to the position indicated by the specified index.
**index**: index of the position where data is added. |
-| onDataMoved(from: number, to: number): void | from: number,
to: number | Invoked when data is moved.
**from**: original position of data; **to**: target position of data.
**NOTE**
The ID must remain unchanged before and after data movement. If the ID changes, APIs for deleting and adding data must be called.|
-| onDataChanged(index: number): void | number | Invoked when data in the position indicated by the specified index is changed.
**index**: listener for data changes. |
-| onDataAdd(index: number): void | number | Invoked when data is added to the position indicated by the specified index.
**index**: index of the position where data is added. |
-| onDataMove(from: number, to: number): void | from: number,
to: number | Invoked when data is moved.
**from**: original position of data; **to**: target position of data.
**NOTE**
The ID must remain unchanged before and after data movement. If the ID changes, APIs for deleting and adding data must be called.|
-| onDataChanged(index: number): void | number | Invoked when data in the position indicated by the specified index is changed.
**index**: index of the position where data is changed.|
+| Declaration | Parameter Type | Description |
+| ------------------------------------------------------------ | -------------------------------------- | ------------------------------------------------------------ |
+| onDataReloaded(): void | - | Invoked when all data is reloaded. |
+| onDataAdded(index: number):void(deprecated) | number | Invoked when data is added to the position indicated by the specified index.
This API is deprecated since API version 8. You are advised to use **onDataAdd** instead.
**index**: index of the position where data is added.|
+| onDataMoved(from: number, to: number): void(deprecated) | from: number,
to: number | Invoked when data is moved.
This API is deprecated since API version 8. You are advised to use **onDataMove** instead.
**from**: original position of data; **to**: target position of data.
**NOTE**
The ID must remain unchanged before and after data movement. If the ID changes, APIs for deleting and adding data must be called.|
+| onDataDeleted(index: number):void(deprecated) | number | Invoked when data is deleted from the position indicated by the specified index. LazyForEach will update the displayed content accordingly.
This API is deprecated since API version 8. You are advised to use **onDataDelete** instead.
**index**: index of the position where data is deleted.|
+| onDataChanged(index: number): void(deprecated) | number | Invoked when data in the position indicated by the specified index is changed.
This API is deprecated since API version 8. You are advised to use **onDataChange** instead.
**index**: listener for data changes.|
+| onDataAdd(index: number): void8+ | number | Invoked when data is added to the position indicated by the specified index.
**index**: index of the position where data is added.|
+| onDataMove(from: number, to: number): void8+ | from: number,
to: number | Invoked when data is moved.
**from**: original position of data; **to**: target position of data.
**NOTE**
The ID must remain unchanged before and after data movement. If the ID changes, APIs for deleting and adding data must be called.|
+| onDataDelete(index: number):void8+ | number | Invoked when data is deleted from the position indicated by the specified index. LazyForEach will update the displayed content accordingly.
**index**: index of the position where data is deleted.
**NOTE**
Before **onDataDelete** is called, ensure that the corresponding data in **dataSource** has been deleted. Otherwise, undefined behavior will occur during page rendering.|
+| onDataChange(index: number): void8+ | number | Invoked when data in the position indicated by the specified index is changed.
**index**: index of the position where data is changed.|
## Restrictions
diff --git a/en/application-dev/quick-start/atomicService-aging.md b/en/application-dev/quick-start/atomicService-aging.md
index 6b393b5a9456e3cbf840dbf9cf5655c46d832658..75c4be084bc7e103f504924f936daea71b8fe5de 100644
--- a/en/application-dev/quick-start/atomicService-aging.md
+++ b/en/application-dev/quick-start/atomicService-aging.md
@@ -4,7 +4,7 @@ Space management for atomic services is necessary from two aspects. On the one h
## Managing Quota for Atomic Service Data Directories
-Set a storage quota for the data sandbox directory of an atomic service. This quota can be obtained through the system parameter **persist.sys.bms.aging.policy.atomicservice.datasize.threshold**. The default value is 1024 MB. When the quota is used up, writing data will return an error message.
+Set a storage quota for the data sandbox directory of an atomic service. This quota can be obtained through the system parameter **persist.sys.bms.aging.policy.atomicservice.datasize.threshold**. The default value is 50 MB. When the quota is used up, writing data will return an error message.
You can run the [param get/set](../../device-dev/subsystems/subsys-boot-init-plugin.md) command to view and set system parameters.
diff --git a/en/application-dev/quick-start/cross-app-hsp.md b/en/application-dev/quick-start/cross-app-hsp.md
index db971e348908dbc6f6ca87f5d84d162b6bac0997..4d4115490d7060843fe008cda7281fcc2a003ada 100644
--- a/en/application-dev/quick-start/cross-app-hsp.md
+++ b/en/application-dev/quick-start/cross-app-hsp.md
@@ -17,34 +17,29 @@ An inter-application HSP works by combining the following parts:
HSP: contains the actual implementation code, including the JS/TS code, C++ libraries, resources, and configuration files. It is either released to the application market or integrated into the system version.
### Integrating the HAR in an Inter-Application HSP
-Define the interfaces to be exported in the **index.d.ets** file in the HAR, which is the entry to the declaration file exported by the inter-application HSP. The path of the **index.d.ets** file is as follows:
+Define the interfaces to be exported in the **index.ets** file in the HAR, which is the entry to the declaration file exported by the inter-application HSP. The path to the **index.ets** file is as follows:
```
-src
-├── main
-| └── module.json5
-├── index.d.ets
+liba
+├── src
+│ └── main
+│ ├── ets
+│ │ ├── pages
+│ │ └── index.ets
+│ ├── resources
+│ └── module.json5
└── oh-package.json5
```
-Below is an example of the **index.d.ets** file content:
-```ts
-@Component
-export declare struct UIComponent {
- build():void;
-}
-
-export declare function hello(): string;
-
-export declare function foo1(): string;
+Below is an example of the **index.ets** file content:
-export declare function foo2(): string;
-
-export declare function nativeHello(): string;
+```ts
+// liba/src/main/ets/index.ets
+export { hello, foo1, foo2, nativeMulti, UIComponent } from './ui/MyUIComponent'
```
-In the example, **UIComponent** is an ArkUI component, **hello()**, **foo1()**, and **foo2()** are TS methods, and **nativeHello()** is a native method. Specific implementation is as follows:
+In the example, **UIComponent** is an ArkUI component, **hello()**, **foo1()**, and **foo2()** are TS methods, and **nativeMulti()** is a native method. Specific implementation is as follows:
#### ArkUI Components
The following is an implementation example of ArkUI components in the HSP:
```ts
-// lib/src/main/ets/ui/MyUIComponent.ets
+// liba/src/main/ets/ui/MyUIComponent.ets
@Component
export struct UIComponent {
@State message: string = 'Hello World'
@@ -63,6 +58,7 @@ export struct UIComponent {
#### **TS Methods**
The following is an implementation example of TS methods in the HSP:
```ts
+// liba/src/main/ets/ui/MyUIComponent.ets
export function hello(name: string): string {
return "hello + " + name;
}
@@ -74,50 +70,22 @@ export function foo1() {
export function foo2() {
return "foo2";
}
+
```
#### **Native Methods**
-The following is an implementation example of native methods in the HSP:
-```C++
-#include "napi/native_api.h"
-#include
-#include
-#include
-
-const std::string libname = "liba";
-const std::string version = "v10001";
-
-static napi_value Hello(napi_env env, napi_callback_info info) {
- napi_value ret;
- std::string msg = libname + ":native hello, " + version;
- napi_create_string_utf8(env, msg.c_str(), msg.length(), &ret);
- return ret;
-}
+The HSP can contain .so files compiled in C++. The HSP indirectly exports the native method in the .so file. In this example, the **multi** API in the **libnative.so** file is exported.
-EXTERN_C_START
-static napi_value Init(napi_env env, napi_value exports) {
- napi_property_descriptor desc[] = {
- {"nativeHello", nullptr, Hello, nullptr, nullptr, nullptr, napi_default, nullptr}};
- napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc);
- return exports;
-}
-EXTERN_C_END
-
-static napi_module demoModule = {
- .nm_version = 1,
- .nm_flags = 0,
- .nm_filename = nullptr,
- .nm_register_func = Init,
- .nm_modname = "liba",
- .nm_priv = ((void *)0),
- .reserved = {0},
-};
-
-extern "C" __attribute__((constructor)) void RegisterLibaModule(void) {
- napi_module_register(&demoModule);
+```ts
+// liba/src/main/ets/ui/MyUIComponent.ets
+import native from "libnative.so"
+
+export function nativeMulti(a: number, b: number) {
+ return native.multi(a, b);
}
```
+
### Using the Capabilities Exported from the HAR
-To start with, [configure dependency](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-development-npm-package-0000001222578434#section89674298391) on the HAR. The dependency information will then be generated in the **module.json5** file of the corresponding module, as shown in the following:
+To start with, [configure dependency](https://developer.harmonyos.com/cn/docs/documentation/doc-guides-V3/creating_har_api9-0000001518082393-V3#section611662614153) on the HAR. The dependency information will then be generated in the **module.json5** file of the corresponding module, as shown in the following:
```json
"dependencies": [
{
@@ -180,7 +148,7 @@ struct Index {
#### Referencing Native Methods in the HAR
To reference the native methods exported from the HAR, use **import** as follows:
``` ts
-import { nativeHello } from 'liba'
+import { nativeMulti } from 'liba'
@Component
struct Index {
@@ -190,7 +158,7 @@ struct Index {
Button('Button')
.onClick(()=>{
// Reference the native method in the HAR.
- nativeHello();
+ nativeMulti();
})
}
.width('100%')
@@ -207,11 +175,6 @@ Inter-application HSPs are not completely integrated into an application. They a
### Inter-Application HSP Debugging Mode
You can debug an inter-application HSP after it is distributed to a device. If the aforementioned distribution methods are not applicable, you can distribute the HSP by running **bm** commands. The procedure is as follows:
-
-> **NOTE**
->
-> Do not reverse steps 2 and 3. Otherwise, your application will fail to be installed due to a lack of the required inter-application HSP. For more information about the **bm** commands, see [Bundle Management](../../readme/bundle-management.md).
-
1. Obtain the inter-application HSP installation package.
2. Run the following **bm** command to install the inter-application HSP.
```
@@ -222,3 +185,7 @@ bm install -s sharebundle.hsp
bm install -p feature.hap
```
4. Start your application and start debugging.
+
+> **NOTE**
+>
+> Do not reverse steps 2 and 3. Otherwise, your application will fail to be installed due to a lack of the required inter-application HSP. For more information about the **bm** commands, see [bm Commands](../../readme/bundle-management.md#bm-commands).
\ No newline at end of file
diff --git a/en/application-dev/quick-start/har-package.md b/en/application-dev/quick-start/har-package.md
index 63b5fcfd10437ac2140a17bcc1daf690e780c791..587af49e108ed1cfedbd9a190ea7858bc470073c 100644
--- a/en/application-dev/quick-start/har-package.md
+++ b/en/application-dev/quick-start/har-package.md
@@ -2,7 +2,7 @@
A Harmony Archive (HAR) is a static shared package that can contain code, C++ libraries, resources, and configuration files. It enables modules and projects to share code related to ArkUI components, resources, and more. Unlike a Harmony Ability Package (HAP), a HAR cannot be independently installed on a device. Instead, it can be referenced only as the dependency of an application module.
## Creating a HAR Module
-You can kickstart your HAR module development with the module template of the **Library** type in DevEco Studio. By default, obfuscation is disabled for the HAR module. To enable this feature, set **artifactType** in the **build-profile.json5** file of the HAR module to **obfuscation** as follows:
+You can [create a HAR module in DevEco Studio](https://developer.harmonyos.com/cn/docs/documentation/doc-guides-V3/creating_har_api9-0000001518082393-V3#section143510369612). To better protect your source code, enable obfuscation for the HAR module so that DevEco Studio compiles, obfuscates, and compresses code during HAR building. To enable obfuscation, open the **build-profile.json5** file of the HAR module and set **artifactType** to **obfuscation** as follows:
```json
{
@@ -12,15 +12,13 @@ You can kickstart your HAR module development with the module template of the **
}
}
```
-The value options of **artifactType** are as follows, and the default value is **original**:
+The value options of **artifactType** are as follows, with the default value being **original**:
- **original**: Code is not obfuscated.
- **obfuscation**: Code is obfuscated using Uglify.
-When obfuscation is enabled, DevEco Studio compiles, obfuscates, and compresses code during HAR building, thereby protecting your code assets.
-
> **NOTE**
>
-> If **artifactType** is set to **obfuscation**, **apiType** must be set to **stageMode**, because obfuscation is available only in the stage model.
+> Obfuscation is available only in the stage model. Therefore, if **artifactType** is set to **obfuscation**, **apiType** must be set to **stageMode**.
## Precautions for HAR Development
- The HAR does not support the declaration of **abilities** and **extensionAbilities** in its configuration file.
@@ -88,12 +86,12 @@ export { func2 } from './src/main/ts/test'
```
### Resources
Resources are packed into the HAR when it is being compiled and packaged. During compilation and building of a HAP, DevEco Studio collects resource files from the HAP module and its dependent modules. If the resource files of different modules have the same name, DevEco Studio overwrites the resource files based on the following priorities (in descending order):
-- AppScope (supported only by the stage model of API version 9)
+- AppScope (only for the stage model of API version 9)
- Modules in the HAP file
- If resource conflicts occur between dependent HAR modules, they are overwritten based on the dependency sequence. (The module that is higher in the dependency sequence list has higher priority.)
## Referencing ArkUI Components, APIs, and Resources in the HAR
-To start with, [configure dependency](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-development-npm-package-0000001222578434#section89674298391) on the HAR.
+To start with, [configure dependency](https://developer.harmonyos.com/cn/docs/documentation/doc-guides-V3/creating_har_api9-0000001518082393-V3#section611662614153) on the HAR.
### Reference ArkUI Components in the HAR
@@ -170,3 +168,7 @@ struct Index {
}
}
```
+
+## Releasing a HAR
+
+Follow the [instructions](https://developer.harmonyos.com/cn/docs/documentation/doc-guides-V3/creating_har_api9-0000001518082393-V3#section1213451811512) to release a HAR.
diff --git a/en/application-dev/quick-start/in-app-hsp.md b/en/application-dev/quick-start/in-app-hsp.md
index 4c0cc3c7dffc1c41d0011dd644a94a84424808dc..cb31cbc5b703c3caec5c34b4e0702657b56d26f5 100644
--- a/en/application-dev/quick-start/in-app-hsp.md
+++ b/en/application-dev/quick-start/in-app-hsp.md
@@ -5,7 +5,7 @@ The in-application HSP is released with the Application Package (App Pack) of th
## Developing an In-Application HSP
-You can kickstart your HSP development with the HSP template in DevEco Studio. In this example, an HSP module named **library** is created. The basic project directory structure is as follows:
+[Create an HSP module in DevEco Studio](https://developer.harmonyos.com/cn/docs/documentation/doc-guides-V3/hsp-0000001521396322-V3#section7717162312546). In this example, an HSP module named **library** is created. The basic project directory structure is as follows:
```
library
├── src
@@ -88,7 +88,7 @@ if **Image("common/example.png")** is used in the HSP module, the **\** c
### Exporting Native Methods
The HSP can contain .so files compiled in C++. The HSP indirectly exports the native method in the .so file. In this example, the **multi** method in the **libnative.so** file is exported.
```ts
-// ibrary/src/main/ets/utils/nativeTest.ts
+// library/src/main/ets/utils/nativeTest.ts
import native from "libnative.so"
export function nativeMulti(a: number, b: number) {
@@ -103,15 +103,9 @@ export { nativeMulti } from './utils/nativeTest'
```
## Using the In-Application HSP
-To use APIs in the HSP, first configure the dependency on the HSP in the **oh-package.json5** file of the module that needs to call the APIs (called the invoking module). If the HSP and the invoking module are in the same project, the APIs can be referenced locally. The sample code is as follows:
-```json
-// entry/oh-package.json5
-"dependencies": {
- "library": "file:../library"
-}
-```
-You can now call the external APIs of the HSP in the same way as calling the APIs in the HAR.
-In this example, the external APIs are the following ones exported from **library**:
+To use APIs in the HSP, first [configure the dependency](https://developer.harmonyos.com/cn/docs/documentation/doc-guides-V3/hsp-0000001521396322-V3#section6161154819195) on the HSP in the **oh-package.json5** file of the module that needs to call the APIs (called the invoking module).
+You can then call the external APIs of the HSP in the same way as calling the APIs in the HAR. In this example, the external APIs are the following ones exported from **library**:
+
```ts
// library/src/main/ets/index.ets
export { Log, add, minus } from './utils/test'
diff --git a/en/application-dev/quick-start/module-configuration-file.md b/en/application-dev/quick-start/module-configuration-file.md
index 2d830a4b8318afdf61f4d9d7531e71a3a6420858..ac141ad75d108f68d25007491a15062ae958563e 100644
--- a/en/application-dev/quick-start/module-configuration-file.md
+++ b/en/application-dev/quick-start/module-configuration-file.md
@@ -309,7 +309,7 @@ Set **icon**, **label**, and **skills** under **abilities** in the **module.json
| [metadata](#metadata)| Metadata information of the UIAbility component.| Object array| Yes (initial value: left empty)|
| exported | Whether the UIAbility component can be called by other applications.
- **true**: The UIAbility component can be called by other applications.
- **false**: The UIAbility component cannot be called by other applications.| Boolean| Yes (initial value: **false**)|
| continuable | Whether the UIAbility component can be [migrated](../application-models/hop-cross-device-migration.md).
- **true**: The UIAbility component can be migrated.
- **false**: The UIAbility component cannot be migrated.| Boolean| Yes (initial value: **false**)|
-| [skills](#skills) | Feature set of [wants](../application-models/want-overview.md) that can be received by the current UIAbility or ExtensionAbility component.
Configuring rule:
- For HAPs of the entry type, you can configure multiple **skills** attributes with the entry capability for an OpenHarmony application. (A **skills** attribute with the entry capability is the one that has **ohos.want.action.home** and **entity.system.home** configured.)
- For HAPs of the feature type, you can configure **skills** attributes with the entry capability for an OpenHarmony application, but not for an OpenHarmony service.| Object array| Yes (initial value: left empty)|
+| [skills](#skills) | Feature set of [wants](../application-models/want-overview.md) that can be received by the current UIAbility or ExtensionAbility component.
Configuration rules:
- For HAPs of the entry type, you can configure multiple **skills** attributes with the entry capability for an OpenHarmony application. (A **skills** attribute with the entry capability is the one that has **ohos.want.action.home** and **entity.system.home** configured.)
- For HAPs of the feature type, you can configure **skills** attributes with the entry capability for an OpenHarmony application, but not for an OpenHarmony service.| Object array| Yes (initial value: left empty)|
| backgroundModes | Continuous tasks of the UIAbility component.
Continuous tasks are classified into the following types:
- **dataTransfer**: service for downloading, backing up, sharing, or transferring data from the network or peer devices.
- **audioPlayback**: audio playback service.
- **audioRecording**: audio recording service.
- **location**: location and navigation services.
- **bluetoothInteraction**: Bluetooth scanning, connection, and transmission services (wearables).
- **multiDeviceConnection**: multi-device interconnection service.
- **wifiInteraction**: Wi-Fi scanning, connection, and transmission services (as used in the Multi-screen Collaboration and clone features)
- **voip**: voice/video call and VoIP services.
- **taskKeeping**: computing service.| String array| Yes (initial value: left empty)|
| startWindowIcon | Index to the icon file of the UIAbility component startup page. Example: **$media:icon**.
The value is a string with a maximum of 255 bytes.| String| No|
| startWindowBackground | Index to the background color resource file of the UIAbility component startup page. Example: **$color:red**.
The value is a string with a maximum of 255 bytes.| String| No|
diff --git a/en/application-dev/quick-start/quickfix-principles.md b/en/application-dev/quick-start/quickfix-principles.md
index 4c0a1f684cfc1ff71c5ad9a2594ae8823e178e82..0431534f0f46bb7bb0988c538d84628767ce8bfb 100644
--- a/en/application-dev/quick-start/quickfix-principles.md
+++ b/en/application-dev/quick-start/quickfix-principles.md
@@ -10,7 +10,7 @@ Quick fix is a technical means provided by the OpenHarmony system for developers
* 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.
+* Installing an application update will delete the quick fix package.
## Structure of the Quick Fix Package
@@ -18,7 +18,7 @@ Quick fix is a technical means provided by the OpenHarmony system for developers
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).
+
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.md).
* 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).
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 aa5e53ae90c1794125f5b6ae8a8f7a5115128743..f87ae3594a44b17b34233adfd0d8127a2be34028 100644
--- a/en/application-dev/quick-start/resource-categories-and-access.md
+++ b/en/application-dev/quick-start/resource-categories-and-access.md
@@ -8,8 +8,6 @@ During application development, you may need to use different resources, such as
## Resource Categories
-### resources Directory
-
Resource files used during application development must be stored in specified directories for management. The **resources** directory consists of three types of subdirectories: the **base** subdirectory, qualifiers subdirectories, and the **rawfile** subdirectory. The common resource files used across projects in the stage model are stored in the **resources** directory under **AppScope**.
The **base** subdirectory is provided by default, and the qualifiers subdirectories are created on your own. When your application needs to use a resource, the system preferentially searches the qualifiers subdirectories that match the current device state. The system searches the **base** subdirectory for the target resource only when the **resources** directory does not contain any qualifiers subdirectories that match the current device state or the target resource is not found in the qualifiers subdirectories. The **rawfile** directory is not searched for resources.
@@ -18,24 +16,42 @@ Example of the **resources** directory:
```
resources
-|---base // Default directory
+|---base
+| |---element
+| | |---string.json
+| |---media
+| | |---icon.png
+| |---profile
+| | |---test_profile.json
+|---en_US // Default directory. When the device language is en-us, resources in this directory are preferentially matched.
+| |---element
+| | |---string.json
+| |---media
+| | |---icon.png
+| |---profile
+| | |---test_profile.json
+|---zh_CN // Default directory. When the device language is zh-cn, resources in this directory are preferentially matched.
| |---element
| | |---string.json
| |---media
| | |---icon.png
-|---en_GB-vertical-car-mdpi // Example of a qualifiers subdirectory, which needs to be created on your own
+| |---profile
+| | |---test_profile.json
+|---en_GB-vertical-car-mdpi // Example of a qualifiers subdirectory, which needs to be created on your own.
| |---element
| | |---string.json
| |---media
| | |---icon.png
-|---rawfile
+| |---profile
+| | |---test_profile.json
+|---rawfile // Other types of files are saved as raw files and will not be integrated into the resources.index file. You can customize the file name as needed.
```
**Table 1** Classification of the resources directory
| 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).| **en_US** and **zh_CN** are two default qualifiers subdirectories. You need to create other 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. |
@@ -77,14 +93,13 @@ The name of a qualifiers subdirectory consists of one or more qualifiers that re
You can create resource group subdirectories (including element, media, and profile) in the **base** and qualifiers subdirectories to store resource files of specific types.
-**Table 3** Resource group subdirectories
+ **Table 3** Resource group subdirectories
| Resource Group Subdirectory | Description | Resource File |
| ------- | ---------------------------------------- | ---------------------------------------- |
| 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**
@@ -231,7 +246,7 @@ When referencing resources in the **rawfile** subdirectory, use the **"$rawfile(
>
> 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):
+In the **.ets** file, you can use the resources defined in the **resources** directory. As described in [Resource Group Subdirectories](#resource-group-subdirectories), you can reference .json resource files, including **color.json**, **string.json**, and **plural.json**. The usage is as follows:
```ts
Text($r('app.string.string_hello'))
@@ -242,13 +257,14 @@ Text($r('app.string.string_world'))
.fontColor($r('app.color.color_world'))
.fontSize($r('app.float.font_world'))
-// Reference string resources. The second parameter of $r is used to replace %s, and value is "We will arrive at five'o clock".
-Text($r('app.string.message_arrive', "five'o clock"))
+// Reference string resources. The first parameter of $r indicates the string resource, and the second parameter is used to replace %s in the string.json file.
+// In this example, the resultant value is "We will arrive at five of the clock".
+Text($r('app.string.message_arrive', "five of the clock"))
.fontColor($r('app.color.color_hello'))
.fontSize($r('app.float.font_hello'))
-// Reference plural resources. The first parameter indicates the plural resource, the second parameter indicates the number of plural resources, and the third parameter indicates the substitute of %d.
-// The value is "5 apple" in singular form and "5 apples" in plural form.
+// Reference plural resources. The first parameter of $r indicates the plural resource, the second parameter indicates the number of plural resources (for English, **one** indicates singular and is represented by **1**, and **other** indicates plural and is represented by an integer greater than or equal to 1; for Chinese, **other** indicates both singular and plural), and the third parameter is used to replace %d.
+// In this example, the resultant value is "5 apples".
Text($r('app.plural.eat_apple', 5, 5))
.fontColor($r('app.color.color_world'))
.fontSize($r('app.float.font_world'))
diff --git a/en/application-dev/quick-start/start-with-ets-fa.md b/en/application-dev/quick-start/start-with-ets-fa.md
index 019490d354b8d7c6b6ff7771065aae1b7534b76c..36fe7adfb84fa9ea5a5e735a61d71ca44dbe6dab 100644
--- a/en/application-dev/quick-start/start-with-ets-fa.md
+++ b/en/application-dev/quick-start/start-with-ets-fa.md
@@ -10,7 +10,7 @@
## Creating an ArkTS Project
-1. If you are opening DevEco Studio for the first time, click **Create Project**. If a project is already open, choose **File** > **New** > **Create Project** from the menu bar. On the **Choose Your Ability Template** page, select **Application** (or **Atomic Service**, depending on your project), select **Empty Ability** as the template, and click Next.
+1. If you are opening DevEco Studio for the first time, click **Create Project**. If a project is already open, choose **File** > **New** > **Create Project** from the menu bar. On the **Choose Your Ability Template** page, select **Application** (or **Atomic Service**, depending on your project), select **Empty Ability** as the template, and click **Next**.
![createProject](figures/createProject.png)
diff --git a/en/application-dev/quick-start/start-with-ets-stage.md b/en/application-dev/quick-start/start-with-ets-stage.md
index d18a01875cf2e52abd45b493f8223c596912276d..978ffd47a206abc5f5b3e047a8d7f3dcc0e599e9 100644
--- a/en/application-dev/quick-start/start-with-ets-stage.md
+++ b/en/application-dev/quick-start/start-with-ets-stage.md
@@ -10,7 +10,7 @@
## Creating an ArkTS Project
-1. If you are opening DevEco Studio for the first time, click **Create Project**. If a project is already open, choose **File** > **New** > **Create Project** from the menu bar. On the **Choose Your Ability Template** page, select **Application** (or **Atomic Service**, depending on your project), select **Empty Ability** as the template, and click Next.
+1. If you are opening DevEco Studio for the first time, click **Create Project**. If a project is already open, choose **File** > **New** > **Create Project** from the menu bar. On the **Choose Your Ability Template** page, select **Application** (or **Atomic Service**, depending on your project), select **Empty Ability** as the template, and click **Next**.
![createProject](figures/createProject.png)
diff --git a/en/application-dev/quick-start/start-with-js-fa.md b/en/application-dev/quick-start/start-with-js-fa.md
index abb27d9fb942a406e22d98285626984bdc63d197..812be6247b4ed3aae55dd1f67b0ee5bb47f01065 100644
--- a/en/application-dev/quick-start/start-with-js-fa.md
+++ b/en/application-dev/quick-start/start-with-js-fa.md
@@ -8,7 +8,7 @@
## Creating a JavaScript Project
-1. If you are opening DevEco Studio for the first time, click **Create Project**. If a project is already open, choose **File** > **New** > **Create Project** from the menu bar. On the **Choose Your Ability Template** page, select **Application** (or **Atomic Service**, depending on your project), select **Empty Ability** as the template, and click Next.
+1. If you are opening DevEco Studio for the first time, click **Create Project**. If a project is already open, choose **File** > **New** > **Create Project** from the menu bar. On the **Choose Your Ability Template** page, select **Application** (or **Atomic Service**, depending on your project), select **Empty Ability** as the template, and click **Next**.
![createProject](figures/createProject.png)
diff --git a/en/application-dev/reference/apis/Readme-EN.md b/en/application-dev/reference/apis/Readme-EN.md
index b12b546360875f9bb0d71e8840c8d8716bf62907..b942d5aa2a56cfc90c0496074d2ca7dda6d96b6f 100644
--- a/en/application-dev/reference/apis/Readme-EN.md
+++ b/en/application-dev/reference/apis/Readme-EN.md
@@ -18,8 +18,6 @@
- [@ohos.app.form.FormExtensionAbility (FormExtensionAbility)](js-apis-app-form-formExtensionAbility.md)
- [@ohos.application.DataShareExtensionAbility (DataShare Extension Ability)](js-apis-application-dataShareExtensionAbility.md)
- [@ohos.application.StaticSubscriberExtensionAbility (StaticSubscriberExtensionAbility)](js-apis-application-staticSubscriberExtensionAbility.md)
- - Stage Model (To Be Deprecated Soon)
- - [@ohos.application.EnvironmentCallback (EnvironmentCallback)](js-apis-application-environmentCallback.md)
- FA Model
- [@ohos.ability.ability (Ability)](js-apis-ability-ability.md)
- [@ohos.ability.featureAbility (FeatureAbility)](js-apis-ability-featureAbility.md)
@@ -39,10 +37,12 @@
- [@ohos.app.ability.Want (Want)](js-apis-app-ability-want.md)
- [@ohos.app.ability.wantAgent (WantAgent)](js-apis-app-ability-wantAgent.md)
- [@ohos.app.ability.wantConstant (wantConstant)](js-apis-app-ability-wantConstant.md)
+ - [@ohos.app.businessAbilityRouter (Business Ability Router)](js-apis-businessAbilityRouter.md)
- [@ohos.app.form.formBindingData (formBindingData)](js-apis-app-form-formBindingData.md)
- [@ohos.app.form.formHost (FormHost)](js-apis-app-form-formHost.md)
- [@ohos.app.form.formInfo (FormInfo)](js-apis-app-form-formInfo.md)
- [@ohos.app.form.formProvider (FormProvider)](js-apis-app-form-formProvider.md)
+ - [@ohos.application.uriPermissionManager (URI Permission Management)](js-apis-uripermissionmanager.md)
- Both Models (To Be Deprecated Soon)
- [@ohos.ability.dataUriUtils (DataUriUtils)](js-apis-ability-dataUriUtils.md)
- [@ohos.ability.errorCode (ErrorCode)](js-apis-ability-errorCode.md)
@@ -139,7 +139,11 @@
- [NotificationSlot](js-apis-inner-notification-notificationSlot.md)
- [NotificationTemplate](js-apis-inner-notification-notificationTemplate.md)
- [NotificationUserInput](js-apis-inner-notification-notificationUserInput.md)
-- Bundle Management
+ - Common Events
+ - [Common Events of the Bundle Management Subsystem](common_event/commonEvent-bundleManager.md)
+ - [Common Events of the Notification Service](common_event/commonEvent-ans.md)
+ - [Common Events of the Telephony Subsystem](common_event/commonEvent-telephony.md)
+- Bundle Management
- [@ohos.bundle.appControl (appControl)](js-apis-appControl.md)
- [@ohos.bundle.bundleManager (bundleManager)](js-apis-bundleManager.md)
- [@ohos.bundle.bundleMonitor (bundleMonitor)](js-apis-bundleMonitor.md)
@@ -148,6 +152,7 @@
- [@ohos.bundle.freeInstall (freeInstall)](js-apis-freeInstall.md)
- [@ohos.bundle.installer (installer)](js-apis-installer.md)
- [@ohos.bundle.launcherBundleManager (launcherBundleManager)](js-apis-launcherBundleManager.md)
+ - [@ohos.bundle.overlay (overlay)](js-apis-overlay.md)
- [@ohos.zlib (Zip)](js-apis-zlib.md)
- bundleManager
- [abilityInfo](js-apis-bundleManager-abilityInfo.md)
@@ -155,18 +160,22 @@
- [AppProvisionInfo](js-apis-bundleManager-AppProvisionInfo.md)
- [bundleInfo](js-apis-bundleManager-bundleInfo.md)
- [BundlePackInfo](js-apis-bundleManager-BundlePackInfo.md)
+ - [BusinessAbilityInfo](js-apis-bundleManager-businessAbilityInfo.md)
- [dispatchInfo](js-apis-bundleManager-dispatchInfo.md)
- [elementName](js-apis-bundleManager-elementName.md)
- [extensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)
- [hapModuleInfo](js-apis-bundleManager-hapModuleInfo.md)
- [launcherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md)
- [metadata](js-apis-bundleManager-metadata.md)
+ - [OverlayModuleInfo](js-apis-bundleManager-overlayModuleInfo.md)
- [permissionDef](js-apis-bundleManager-permissionDef.md)
- [remoteAbilityInfo](js-apis-bundleManager-remoteAbilityInfo.md)
+ - [SharedBundleInfo](js-apis-bundleManager-sharedBundleInfo.md)
- [shortcutInfo](js-apis-bundleManager-shortcutInfo.md)
- UI Page
- [@ohos.animator (Animator)](js-apis-animator.md)
+ - [@ohos.arkui.componentSnapshot (Component Snapshot)](js-apis-arkui-componentSnapshot.md)
- [@ohos.arkui.drawableDescriptor (DrawableDescriptor)](js-apis-arkui-drawableDescriptor.md)
- [@ohos.curves (Interpolation Calculation)](js-apis-curve.md)
- [@ohos.matrix4 (Matrix Transformation)](js-apis-matrix4.md)
@@ -264,7 +273,7 @@
- [@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.mdns (mDNS Management)](js-apis-net-mdns.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)
@@ -449,4 +458,4 @@
- [remoteAbilityInfo](js-apis-bundle-remoteAbilityInfo.md)
- [shortcutInfo](js-apis-bundle-ShortcutInfo.md)
- data/rdb
- - [resultSet (Result Set)](js-apis-data-resultset.md)
\ No newline at end of file
+ - [resultSet](js-apis-data-resultset.md)
\ No newline at end of file
diff --git a/en/application-dev/reference/apis/js-apis-ability-ability.md b/en/application-dev/reference/apis/js-apis-ability-ability.md
index 80610df7f925ac5a5d29744b48179488e8efc7f6..04313f3dfe02920b468647e7e717065760da46cc 100644
--- a/en/application-dev/reference/apis/js-apis-ability-ability.md
+++ b/en/application-dev/reference/apis/js-apis-ability-ability.md
@@ -18,7 +18,7 @@ import ability from '@ohos.ability.ability';
| Name | Type | Description |
| ----------- | -------------------- | ------------------------------------------------------------ |
| DataAbilityHelper | [DataAbilityHelper](js-apis-inner-ability-dataAbilityHelper.md) | Level-2 module **DataAbilityHelper**. |
-| PacMap | [PacMap](js-apis-inner-application-pacMap.md) | Level-2 module **PacMap**.|
+| PacMap | [PacMap](js-apis-inner-ability-dataAbilityHelper.md#pacmap) | Level-2 module **PacMap**.|
| DataAbilityOperation | [DataAbilityOperation](js-apis-inner-ability-dataAbilityOperation.md) | Level-2 module **DataAbilityOperation**.|
| DataAbilityResult | [DataAbilityResult](js-apis-inner-ability-dataAbilityResult.md) | Level-2 module **DataAbilityResult**.|
| AbilityResult | [AbilityResult](js-apis-inner-ability-abilityResult.md) | Level-2 module **AbilityResult**.|
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 54785d5ddb6a24dba26fff11e436f7a222ae96f2..9f59a5506ce0d330fc8da3179bc03978f06353f2 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
@@ -1,6 +1,6 @@
# @ohos.app.ability.abilityDelegatorRegistry (AbilityDelegatorRegistry)
-**AbilityDelegatorRegistry**, a module of the [Test Framework](../../ability-deprecated/ability-delegator.md), is used to obtain [AbilityDelegator](js-apis-inner-application-abilityDelegator.md) and [AbilityDelegatorArgs](js-apis-inner-application-abilityDelegatorArgs.md) objects. **AbilityDelegator** provides APIs for creating **AbilityMonitor** objects, which can be used to listen for ability lifecycle changes. **AbilityDelegatorArgs** provides APIs for obtaining test parameters.
+**AbilityDelegatorRegistry**, a module of the [arkXtest User Guide](../../application-test/arkxtest-guidelines.md), is used to obtain [AbilityDelegator](js-apis-inner-application-abilityDelegator.md) and [AbilityDelegatorArgs](js-apis-inner-application-abilityDelegatorArgs.md) objects. **AbilityDelegator** provides APIs for creating **AbilityMonitor** objects, which can be used to listen for ability lifecycle changes. **AbilityDelegatorArgs** provides APIs for obtaining test parameters.
> **NOTE**
>
diff --git a/en/application-dev/reference/apis/js-apis-app-ability-common.md b/en/application-dev/reference/apis/js-apis-app-ability-common.md
index e18bc26fecc0695b771769df0abee199c4254ed9..dacf140793402f8d0512b7ac388fe7f7d65ee6b0 100644
--- a/en/application-dev/reference/apis/js-apis-app-ability-common.md
+++ b/en/application-dev/reference/apis/js-apis-app-ability-common.md
@@ -26,7 +26,7 @@ import common from '@ohos.app.ability.common';
| FormExtensionContext | [FormExtensionContext](js-apis-inner-application-formExtensionContext.md) | Level-2 module **FormExtensionContext**.|
| ServiceExtensionContext | [ServiceExtensionContext](js-apis-inner-application-serviceExtensionContext.md) | Level-2 module **ServiceExtensionContext**.|
| EventHub | [EventHub](js-apis-inner-application-eventHub.md) | Level-2 module **EventHub**.|
-| PacMap | [PacMap](js-apis-inner-application-pacMap.md) | Level-2 module **PacMap**.|
+| PacMap | [PacMap](js-apis-inner-ability-dataAbilityHelper.md#pacmap) | Level-2 module **PacMap**.|
| AbilityResult | [AbilityResult](js-apis-inner-ability-abilityResult.md) | Level-2 module **AbilityResult**.|
| ConnectOptions | [ConnectOptions](js-apis-inner-ability-connectOptions.md) | Level-2 module **ConnectOptions**.|
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 65f7fb03e38244ee92c9f94797fa3435072d2f60..1c61a91f7852898d4539ff7b8208d1bd9a9f63ac 100644
--- a/en/application-dev/reference/apis/js-apis-application-want.md
+++ b/en/application-dev/reference/apis/js-apis-application-want.md
@@ -130,6 +130,6 @@ import Want from '@ohos.application.Want';
});
```
-- For more details and examples, see [Want](../../application-models/want-overview.md).
+- For more details and examples, see [Application Model](../../application-models/application-model-composition.md).
diff --git a/en/application-dev/reference/apis/js-apis-audio.md b/en/application-dev/reference/apis/js-apis-audio.md
index 83c2d59e857f73cf3b6573cbc2b96f8200c14e18..4301f1019a2b6665a3ee039550146bee70e97be0 100644
--- a/en/application-dev/reference/apis/js-apis-audio.md
+++ b/en/application-dev/reference/apis/js-apis-audio.md
@@ -3553,6 +3553,7 @@ let inputAudioDeviceDescriptor = [{
networkId : audio.LOCAL_NETWORK_ID,
interruptGroupId : 1,
volumeGroupId : 1,
+ displayName : "",
}];
async function selectInputDevice(){
@@ -3602,6 +3603,7 @@ let inputAudioDeviceDescriptor = [{
networkId : audio.LOCAL_NETWORK_ID,
interruptGroupId : 1,
volumeGroupId : 1,
+ displayName : "",
}];
async function getRoutingManager(){
@@ -3756,6 +3758,7 @@ let outputAudioDeviceDescriptor = [{
networkId : audio.LOCAL_NETWORK_ID,
interruptGroupId : 1,
volumeGroupId : 1,
+ displayName : "",
}];
async function selectOutputDevice(){
@@ -3805,6 +3808,7 @@ let outputAudioDeviceDescriptor = [{
networkId : audio.LOCAL_NETWORK_ID,
interruptGroupId : 1,
volumeGroupId : 1,
+ displayName : "",
}];
async function selectOutputDevice(){
@@ -3856,6 +3860,7 @@ let outputAudioDeviceDescriptor = [{
networkId : audio.LOCAL_NETWORK_ID,
interruptGroupId : 1,
volumeGroupId : 1,
+ displayName : "",
}];
async function selectOutputDeviceByFilter(){
@@ -3914,6 +3919,7 @@ let outputAudioDeviceDescriptor = [{
networkId : audio.LOCAL_NETWORK_ID,
interruptGroupId : 1,
volumeGroupId : 1,
+ displayName : "",
}];
async function selectOutputDeviceByFilter(){
@@ -4082,17 +4088,18 @@ Describes the audio renderer change event.
**System capability**: SystemCapability.Multimedia.Audio.Renderer
-| Name | Type | Readable | Writable | Description |
-| ----------------- | ------------------------------------------------- | -------- | -------- | ---------------------------------------------------------- |
-| streamId | number | Yes | No | Unique ID of an audio stream. |
-| clientUid | number | Yes | No | UID of the audio renderer client.
This is a system API. |
-| rendererInfo | [AudioRendererInfo](#audiorendererinfo8) | Yes | No | Audio renderer information. |
-| rendererState | [AudioState](#audiostate) | Yes | No | Audio state.
This is a system API. |
-| deviceDescriptors | [AudioDeviceDescriptors](#audiodevicedescriptors) | Yes | No | Audio device description. |
+| Name | Type | Readable| Writable| Description |
+| -------------------| ----------------------------------------- | ---- | ---- | ---------------------------- |
+| streamId | number | Yes | No | Unique ID of an audio stream. |
+| clientUid | number | Yes | No | UID of the audio renderer client.
This is a system API.|
+| rendererInfo | [AudioRendererInfo](#audiorendererinfo8) | Yes | No | Audio renderer information. |
+| rendererState | [AudioState](#audiostate) | Yes | No | Audio state.
This is a system API.|
+| deviceDescriptors | [AudioDeviceDescriptors](#audiodevicedescriptors) | Yes | No | Audio device description.|
**Example**
```js
+
import audio from '@ohos.multimedia.audio';
const audioManager = audio.getAudioManager();
@@ -4140,13 +4147,13 @@ Describes the audio capturer change event.
**System capability**: SystemCapability.Multimedia.Audio.Capturer
-| Name | Type | Readable | Writable | Description |
-| ----------------- | ------------------------------------------------- | -------- | -------- | ---------------------------------------------------------- |
-| streamId | number | Yes | No | Unique ID of an audio stream. |
-| clientUid | number | Yes | No | UID of the audio capturer client.
This is a system API. |
-| capturerInfo | [AudioCapturerInfo](#audiocapturerinfo8) | Yes | No | Audio capturer information. |
-| capturerState | [AudioState](#audiostate) | Yes | No | Audio state.
This is a system API. |
-| deviceDescriptors | [AudioDeviceDescriptors](#audiodevicedescriptors) | Yes | No | Audio device description. |
+| Name | Type | Readable| Writable| Description |
+| -------------------| ----------------------------------------- | ---- | ---- | ---------------------------- |
+| streamId | number | Yes | No | Unique ID of an audio stream. |
+| clientUid | number | Yes | No | UID of the audio capturer client.
This is a system API.|
+| capturerInfo | [AudioCapturerInfo](#audiocapturerinfo8) | Yes | No | Audio capturer information. |
+| capturerState | [AudioState](#audiostate) | Yes | No | Audio state.
This is a system API.|
+| deviceDescriptors | [AudioDeviceDescriptors](#audiodevicedescriptors) | Yes | No | Audio device description.|
**Example**
@@ -4194,19 +4201,20 @@ Describes an audio device.
**System capability**: SystemCapability.Multimedia.Audio.Device
-| Name | Type | Readable | Writable | Description |
-| ----------------------------- | ------------------------- | -------- | -------- | ------------------------------------------------------------ |
-| deviceRole | [DeviceRole](#devicerole) | Yes | No | Device role. |
-| deviceType | [DeviceType](#devicetype) | Yes | No | Device type. |
-| id9+ | number | Yes | No | Device ID, which is unique. |
-| name9+ | string | Yes | No | Device name. |
-| address9+ | string | Yes | No | Device address. |
-| sampleRates9+ | Array<number> | Yes | No | Supported sampling rates. |
-| channelCounts9+ | Array<number> | Yes | No | Number of channels supported. |
-| channelMasks9+ | Array<number> | Yes | No | Supported channel masks. |
-| networkId9+ | string | Yes | No | ID of the device network.
This is a system API. |
-| interruptGroupId9+ | number | Yes | No | ID of the interruption group to which the device belongs.
This is a system API. |
-| volumeGroupId9+ | number | Yes | No | ID of the volume group to which the device belongs.
This is a system API. |
+| Name | Type | Readable| Writable| Description |
+| ----------------------------- | -------------------------- | ---- | ---- | ---------- |
+| deviceRole | [DeviceRole](#devicerole) | Yes | No | Device role.|
+| deviceType | [DeviceType](#devicetype) | Yes | No | Device type.|
+| id9+ | number | Yes | No | Device ID, which is unique. |
+| name9+ | string | Yes | No | Device name.|
+| address9+ | string | Yes | No | Device address.|
+| sampleRates9+ | Array<number> | Yes | No | Supported sampling rates.|
+| channelCounts9+ | Array<number> | Yes | No | Number of channels supported.|
+| channelMasks9+ | Array<number> | Yes | No | Supported channel masks.|
+| displayName10+ | string | Yes | No | Display name of the device.|
+| networkId9+ | string | Yes | No | ID of the device network.
This is a system API.|
+| interruptGroupId9+ | number | Yes | No | ID of the interruption group to which the device belongs.
This is a system API.|
+| volumeGroupId9+ | number | Yes | No | ID of the volume group to which the device belongs.
This is a system API.|
**Example**
@@ -4238,11 +4246,11 @@ Implements filter criteria. Before calling **selectOutputDeviceByFilter**, you m
**System API**: This is a system API.
-| Name | Type | Mandatory | Description |
-| ------------ | ---------------------------------------- | --------- | ------------------------------------------------------------ |
-| uid | number | No | Application ID.
**System capability**: SystemCapability.Multimedia.Audio.Core |
-| rendererInfo | [AudioRendererInfo](#audiorendererinfo8) | No | Audio renderer information.
**System capability**: SystemCapability.Multimedia.Audio.Renderer |
-| rendererId | number | No | Unique ID of an audio stream.
**System capability**: SystemCapability.Multimedia.Audio.Renderer |
+| Name | Type | Mandatory| Description |
+| -------------| ---------------------------------------- | ---- | -------------- |
+| uid | number | No | Application ID.
**System capability**: SystemCapability.Multimedia.Audio.Core|
+| rendererInfo | [AudioRendererInfo](#audiorendererinfo8) | No | Audio renderer information.
**System capability**: SystemCapability.Multimedia.Audio.Renderer|
+| rendererId | number | No | Unique ID of an audio stream.
**System capability**: SystemCapability.Multimedia.Audio.Renderer|
**Example**
@@ -4264,9 +4272,9 @@ Provides APIs for audio rendering. Before calling any API in **AudioRenderer**,
**System capability**: SystemCapability.Multimedia.Audio.Renderer
-| Name | Type | Readable | Writable | Description |
-| ------------------ | -------------------------- | -------- | -------- | --------------------- |
-| state8+ | [AudioState](#audiostate8) | Yes | No | Audio renderer state. |
+| Name | Type | Readable| Writable| Description |
+| ----- | -------------------------- | ---- | ---- | ------------------ |
+| state8+ | [AudioState](#audiostate8) | Yes | No | Audio renderer state.|
**Example**
@@ -4284,9 +4292,9 @@ Obtains the renderer information of this **AudioRenderer** instance. This API us
**Parameters**
-| Name | Type | Mandatory | Description |
-| :------- | :------------------------------------------------------- | :-------- | :------------------------------------------------ |
-| callback | AsyncCallback<[AudioRendererInfo](#audiorendererinfo8)\> | Yes | Callback used to return the renderer information. |
+| Name | Type | Mandatory| Description |
+| :------- | :------------------------------------------------------- | :--- | :--------------------- |
+| callback | AsyncCallback<[AudioRendererInfo](#audiorendererinfo8)\> | Yes | Callback used to return the renderer information.|
**Example**
@@ -4309,9 +4317,9 @@ Obtains the renderer information of this **AudioRenderer** instance. This API us
**Return value**
-| Type | Description |
-| -------------------------------------------------- | ------------------------------------------------ |
-| Promise<[AudioRendererInfo](#audiorendererinfo8)\> | Promise used to return the renderer information. |
+| Type | Description |
+| -------------------------------------------------- | ------------------------------- |
+| Promise<[AudioRendererInfo](#audiorendererinfo8)\> | Promise used to return the renderer information.|
**Example**
@@ -4336,9 +4344,9 @@ Obtains the stream information of this **AudioRenderer** instance. This API uses
**Parameters**
-| Name | Type | Mandatory | Description |
-| :------- | :--------------------------------------------------- | :-------- | :---------------------------------------------- |
-| callback | AsyncCallback<[AudioStreamInfo](#audiostreaminfo8)\> | Yes | Callback used to return the stream information. |
+| Name | Type | Mandatory| Description |
+| :------- | :--------------------------------------------------- | :--- | :------------------- |
+| callback | AsyncCallback<[AudioStreamInfo](#audiostreaminfo8)\> | Yes | Callback used to return the stream information.|
**Example**
@@ -4362,9 +4370,9 @@ Obtains the stream information of this **AudioRenderer** instance. This API uses
**Return value**
-| Type | Description |
-| :--------------------------------------------- | :--------------------------------------------- |
-| Promise<[AudioStreamInfo](#audiostreaminfo8)\> | Promise used to return the stream information. |
+| Type | Description |
+| :--------------------------------------------- | :--------------------- |
+| Promise<[AudioStreamInfo](#audiostreaminfo8)\> | Promise used to return the stream information.|
**Example**
@@ -4378,7 +4386,6 @@ audioRenderer.getStreamInfo().then((streamInfo) => {
}).catch((err) => {
console.error(`ERROR: ${err}`);
});
-
```
### getAudioStreamId9+
@@ -4391,9 +4398,9 @@ Obtains the stream ID of this **AudioRenderer** instance. This API uses an async
**Parameters**
-| Name | Type | Mandatory | Description |
-| :------- | :--------------------- | :-------- | :------------------------------------- |
-| callback | AsyncCallback | Yes | Callback used to return the stream ID. |
+| Name | Type | Mandatory| Description |
+| :------- | :--------------------------------------------------- | :--- | :------------------- |
+| callback | AsyncCallback | Yes | Callback used to return the stream ID.|
**Example**
@@ -4401,7 +4408,6 @@ Obtains the stream ID of this **AudioRenderer** instance. This API uses an async
audioRenderer.getAudioStreamId((err, streamid) => {
console.info(`Renderer GetStreamId: ${streamid}`);
});
-
```
### getAudioStreamId9+
@@ -4414,9 +4420,9 @@ Obtains the stream ID of this **AudioRenderer** instance. This API uses a promis
**Return value**
-| Type | Description |
-| :--------------- | :------------------------------------ |
-| Promise | Promise used to return the stream ID. |
+| Type | Description |
+| :--------------------------------------------- | :--------------------- |
+| Promise | Promise used to return the stream ID.|
**Example**
@@ -4426,7 +4432,6 @@ audioRenderer.getAudioStreamId().then((streamid) => {
}).catch((err) => {
console.error(`ERROR: ${err}`);
});
-
```
### start8+
@@ -4439,9 +4444,9 @@ Starts the renderer. This API uses an asynchronous callback to return the result
**Parameters**
-| Name | Type | Mandatory | Description |
-| -------- | -------------------- | --------- | ----------------------------------- |
-| callback | AsyncCallback\ | Yes | Callback used to return the result. |
+| Name | Type | Mandatory| Description |
+| -------- | -------------------- | ---- | ---------- |
+| callback | AsyncCallback\ | Yes | Callback used to return the result.|
**Example**
@@ -4453,7 +4458,6 @@ audioRenderer.start((err) => {
console.info('Renderer start success.');
}
});
-
```
### start8+
@@ -4466,9 +4470,9 @@ Starts the renderer. This API uses a promise to return the result.
**Return value**
-| Type | Description |
-| -------------- | ---------------------------------- |
-| Promise\ | Promise used to return the result. |
+| Type | Description |
+| -------------- | ------------------------- |
+| Promise\ | Promise used to return the result.|
**Example**
@@ -4478,7 +4482,6 @@ audioRenderer.start().then(() => {
}).catch((err) => {
console.error(`ERROR: ${err}`);
});
-
```
### pause8+
@@ -4491,9 +4494,9 @@ Pauses rendering. This API uses an asynchronous callback to return the result.
**Parameters**
-| Name | Type | Mandatory | Description |
-| -------- | -------------------- | --------- | ----------------------------------- |
-| callback | AsyncCallback\ | Yes | Callback used to return the result. |
+| Name | Type | Mandatory| Description |
+| -------- | -------------------- | ---- | ---------------- |
+| callback | AsyncCallback\ | Yes | Callback used to return the result.|
**Example**
@@ -4505,7 +4508,6 @@ audioRenderer.pause((err) => {
console.info('Renderer paused.');
}
});
-
```
### pause8+
@@ -4518,9 +4520,9 @@ Pauses rendering. This API uses a promise to return the result.
**Return value**
-| Type | Description |
-| -------------- | ---------------------------------- |
-| Promise\ | Promise used to return the result. |
+| Type | Description |
+| -------------- | ------------------------- |
+| Promise\ | Promise used to return the result.|
**Example**
@@ -4530,7 +4532,6 @@ audioRenderer.pause().then(() => {
}).catch((err) => {
console.error(`ERROR: ${err}`);
});
-
```
### drain8+
@@ -4543,9 +4544,9 @@ Drains the playback buffer. This API uses an asynchronous callback to return the
**Parameters**
-| Name | Type | Mandatory | Description |
-| -------- | -------------------- | --------- | ----------------------------------- |
-| callback | AsyncCallback\ | Yes | Callback used to return the result. |
+| Name | Type | Mandatory| Description |
+| -------- | -------------------- | ---- | ---------------- |
+| callback | AsyncCallback\ | Yes | Callback used to return the result.|
**Example**
@@ -4557,7 +4558,6 @@ audioRenderer.drain((err) => {
console.info('Renderer drained.');
}
});
-
```
### drain8+
@@ -4570,9 +4570,9 @@ Drains the playback buffer. This API uses a promise to return the result.
**Return value**
-| Type | Description |
-| -------------- | ---------------------------------- |
-| Promise\ | Promise used to return the result. |
+| Type | Description |
+| -------------- | ------------------------- |
+| Promise\ | Promise used to return the result.|
**Example**
@@ -4582,7 +4582,6 @@ audioRenderer.drain().then(() => {
}).catch((err) => {
console.error(`ERROR: ${err}`);
});
-
```
### stop8+
@@ -4595,9 +4594,9 @@ Stops rendering. This API uses an asynchronous callback to return the result.
**Parameters**
-| Name | Type | Mandatory | Description |
-| -------- | -------------------- | --------- | ----------------------------------- |
-| callback | AsyncCallback\ | Yes | Callback used to return the result. |
+| Name | Type | Mandatory| Description |
+| -------- | -------------------- | ---- | ---------------- |
+| callback | AsyncCallback\ | Yes | Callback used to return the result.|
**Example**
@@ -4609,7 +4608,6 @@ audioRenderer.stop((err) => {
console.info('Renderer stopped.');
}
});
-
```
### stop8+
@@ -4622,9 +4620,9 @@ Stops rendering. This API uses a promise to return the result.
**Return value**
-| Type | Description |
-| -------------- | ---------------------------------- |
-| Promise\ | Promise used to return the result. |
+| Type | Description |
+| -------------- | ------------------------- |
+| Promise\ | Promise used to return the result.|
**Example**
@@ -4634,7 +4632,6 @@ audioRenderer.stop().then(() => {
}).catch((err) => {
console.error(`ERROR: ${err}`);
});
-
```
### release8+
@@ -4647,9 +4644,9 @@ Releases the renderer. This API uses an asynchronous callback to return the resu
**Parameters**
-| Name | Type | Mandatory | Description |
-| -------- | -------------------- | --------- | ----------------------------------- |
-| callback | AsyncCallback\ | Yes | Callback used to return the result. |
+| Name | Type | Mandatory| Description |
+| -------- | -------------------- | ---- | ---------------- |
+| callback | AsyncCallback\ | Yes | Callback used to return the result.|
**Example**
@@ -4661,7 +4658,6 @@ audioRenderer.release((err) => {
console.info('Renderer released.');
}
});
-
```
### release8+
@@ -4674,9 +4670,9 @@ Releases the renderer. This API uses a promise to return the result.
**Return value**
-| Type | Description |
-| -------------- | ---------------------------------- |
-| Promise\ | Promise used to return the result. |
+| Type | Description |
+| -------------- | ------------------------- |
+| Promise\ | Promise used to return the result.|
**Example**
@@ -4686,7 +4682,6 @@ audioRenderer.release().then(() => {
}).catch((err) => {
console.error(`ERROR: ${err}`);
});
-
```
### write8+
@@ -4699,10 +4694,10 @@ Writes the buffer. This API uses an asynchronous callback to return the result.
**Parameters**
-| Name | Type | Mandatory | Description |
-| -------- | ---------------------- | --------- | ------------------------------------------------------------ |
-| buffer | ArrayBuffer | Yes | Buffer to be written. |
-| callback | AsyncCallback\ | Yes | Callback used to return the result. If the operation is successful, the number of bytes written is returned; otherwise, an error code is returned. |
+| Name | Type | Mandatory| Description |
+| -------- | ---------------------- | ---- | --------------------------------------------------- |
+| buffer | ArrayBuffer | Yes | Buffer to be written. |
+| callback | AsyncCallback\ | Yes | Callback used to return the result. If the operation is successful, the number of bytes written is returned; otherwise, an error code is returned.|
**Example**
@@ -4742,7 +4737,6 @@ for (let i = 0;i < len; i++) {
})
}
-
```
### write8+
@@ -4755,9 +4749,9 @@ Writes the buffer. This API uses a promise to return the result.
**Return value**
-| Type | Description |
+| Type | Description |
| ---------------- | ------------------------------------------------------------ |
-| Promise\ | Promise used to return the result. If the operation is successful, the number of bytes written is returned; otherwise, an error code is returned. |
+| Promise\ | Promise used to return the result. If the operation is successful, the number of bytes written is returned; otherwise, an error code is returned.|
**Example**
@@ -4792,7 +4786,6 @@ for (let i = 0;i < len; i++) {
console.error(`audioRenderer.write err: ${err}`);
}
}
-
```
### getAudioTime8+
@@ -4805,9 +4798,9 @@ Obtains the number of nanoseconds elapsed from the Unix epoch (January 1, 1970).
**Parameters**
-| Name | Type | Mandatory | Description |
-| -------- | ---------------------- | --------- | -------------------------------------- |
-| callback | AsyncCallback\ | Yes | Callback used to return the timestamp. |
+| Name | Type | Mandatory| Description |
+| -------- | ---------------------- | ---- | ---------------- |
+| callback | AsyncCallback\ | Yes | Callback used to return the timestamp.|
**Example**
@@ -4815,7 +4808,6 @@ Obtains the number of nanoseconds elapsed from the Unix epoch (January 1, 1970).
audioRenderer.getAudioTime((err, timestamp) => {
console.info(`Current timestamp: ${timestamp}`);
});
-
```
### getAudioTime8+
@@ -4828,9 +4820,9 @@ Obtains the number of nanoseconds elapsed from the Unix epoch (January 1, 1970).
**Return value**
-| Type | Description |
-| ---------------- | ------------------------------------- |
-| Promise\ | Promise used to return the timestamp. |
+| Type | Description |
+| ---------------- | ----------------------- |
+| Promise\ | Promise used to return the timestamp.|
**Example**
@@ -4840,7 +4832,6 @@ audioRenderer.getAudioTime().then((timestamp) => {
}).catch((err) => {
console.error(`ERROR: ${err}`);
});
-
```
### getBufferSize8+
@@ -4853,9 +4844,9 @@ Obtains a reasonable minimum buffer size in bytes for rendering. This API uses a
**Parameters**
-| Name | Type | Mandatory | Description |
-| -------- | ---------------------- | --------- | ---------------------------------------- |
-| callback | AsyncCallback\ | Yes | Callback used to return the buffer size. |
+| Name | Type | Mandatory| Description |
+| -------- | ---------------------- | ---- | -------------------- |
+| callback | AsyncCallback\ | Yes | Callback used to return the buffer size.|
**Example**
@@ -4865,7 +4856,6 @@ let bufferSize = audioRenderer.getBufferSize(async(err, bufferSize) => {
console.error('getBufferSize error');
}
});
-
```
### getBufferSize8+
@@ -4878,9 +4868,9 @@ Obtains a reasonable minimum buffer size in bytes for rendering. This API uses a
**Return value**
-| Type | Description |
-| ---------------- | --------------------------------------- |
-| Promise\ | Promise used to return the buffer size. |
+| Type | Description |
+| ---------------- | --------------------------- |
+| Promise\ | Promise used to return the buffer size.|
**Example**
@@ -4892,7 +4882,6 @@ audioRenderer.getBufferSize().then((data) => {
}).catch((err) => {
console.error(`AudioFrameworkRenderLog: getBufferSize: ERROR: ${err}`);
});
-
```
### setRenderRate8+
@@ -4905,10 +4894,10 @@ Sets the render rate. This API uses an asynchronous callback to return the resul
**Parameters**
-| Name | Type | Mandatory | Description |
-| -------- | ---------------------------------------- | --------- | ----------------------------------- |
-| rate | [AudioRendererRate](#audiorendererrate8) | Yes | Audio render rate. |
-| callback | AsyncCallback\ | Yes | Callback used to return the result. |
+| Name | Type | Mandatory| Description |
+| -------- | ---------------------------------------- | ---- | ------------------------ |
+| rate | [AudioRendererRate](#audiorendererrate8) | Yes | Audio render rate. |
+| callback | AsyncCallback\ | Yes | Callback used to return the result.|
**Example**
@@ -4920,7 +4909,6 @@ audioRenderer.setRenderRate(audio.AudioRendererRate.RENDER_RATE_NORMAL, (err) =>
console.info('Callback invoked to indicate a successful render rate setting.');
}
});
-
```
### setRenderRate8+
@@ -4933,15 +4921,15 @@ Sets the render rate. This API uses a promise to return the result.
**Parameters**
-| Name | Type | Mandatory | Description |
-| ---- | ---------------------------------------- | --------- | ------------------ |
-| rate | [AudioRendererRate](#audiorendererrate8) | Yes | Audio render rate. |
+| Name| Type | Mandatory| Description |
+| ------ | ---------------------------------------- | ---- | ------------ |
+| rate | [AudioRendererRate](#audiorendererrate8) | Yes | Audio render rate.|
**Return value**
-| Type | Description |
-| -------------- | ---------------------------------- |
-| Promise\ | Promise used to return the result. |
+| Type | Description |
+| -------------- | ------------------------- |
+| Promise\ | Promise used to return the result.|
**Example**
@@ -4951,7 +4939,6 @@ audioRenderer.setRenderRate(audio.AudioRendererRate.RENDER_RATE_NORMAL).then(()
}).catch((err) => {
console.error(`ERROR: ${err}`);
});
-
```
### getRenderRate8+
@@ -4964,9 +4951,9 @@ Obtains the current render rate. This API uses an asynchronous callback to retur
**Parameters**
-| Name | Type | Mandatory | Description |
-| -------- | ------------------------------------------------------- | --------- | ---------------------------------------------- |
-| callback | AsyncCallback<[AudioRendererRate](#audiorendererrate8)> | Yes | Callback used to return the audio render rate. |
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------------------------------------- | ---- | ------------------ |
+| callback | AsyncCallback<[AudioRendererRate](#audiorendererrate8)> | Yes | Callback used to return the audio render rate.|
**Example**
@@ -4974,7 +4961,6 @@ Obtains the current render rate. This API uses an asynchronous callback to retur
audioRenderer.getRenderRate((err, renderrate) => {
console.info(`getRenderRate: ${renderrate}`);
});
-
```
### getRenderRate8+
@@ -4987,9 +4973,9 @@ Obtains the current render rate. This API uses a promise to return the result.
**Return value**
-| Type | Description |
-| ------------------------------------------------- | --------------------------------------------- |
-| Promise<[AudioRendererRate](#audiorendererrate8)> | Promise used to return the audio render rate. |
+| Type | Description |
+| ------------------------------------------------- | ------------------------- |
+| Promise<[AudioRendererRate](#audiorendererrate8)> | Promise used to return the audio render rate.|
**Example**
@@ -4999,9 +4985,7 @@ audioRenderer.getRenderRate().then((renderRate) => {
}).catch((err) => {
console.error(`ERROR: ${err}`);
});
-
```
-
### setInterruptMode9+
setInterruptMode(mode: InterruptMode): Promise<void>
@@ -5012,15 +4996,15 @@ Sets the audio interruption mode for the application. This API uses a promise to
**Parameters**
-| Name | Type | Mandatory | Description |
-| ---- | -------------------------------- | --------- | ------------------------ |
-| mode | [InterruptMode](#interruptmode9) | Yes | Audio interruption mode. |
+| Name | Type | Mandatory | Description |
+| ---------- | ---------------------------------- | ------ | ---------- |
+| mode | [InterruptMode](#interruptmode9) | Yes | Audio interruption mode. |
**Return value**
-| Type | Description |
-| ------------------- | ------------------------------------------------------------ |
-| Promise<void> | Promise used to return the result. If the operation is successful, **undefined** is returned. Otherwise, **error** is returned. |
+| Type | Description |
+| ------------------- | ----------------------------- |
+| Promise<void> | Promise used to return the result. If the operation is successful, **undefined** is returned. Otherwise, **error** is returned.|
**Example**
@@ -5031,9 +5015,7 @@ audioRenderer.setInterruptMode(mode).then(data=>{
}).catch((err) => {
console.error(`setInterruptMode Fail: ${err}`);
});
-
```
-
### setInterruptMode9+
setInterruptMode(mode: InterruptMode, callback: AsyncCallback\): void
@@ -5044,10 +5026,10 @@ Sets the audio interruption mode for the application. This API uses an asynchron
**Parameters**
-| Name | Type | Mandatory | Description |
-| -------- | -------------------------------- | --------- | ----------------------------------- |
-| mode | [InterruptMode](#interruptmode9) | Yes | Audio interruption mode. |
-| callback | AsyncCallback\ | Yes | Callback used to return the result. |
+| Name | Type | Mandatory | Description |
+| ------- | ----------------------------------- | ------ | -------------- |
+|mode | [InterruptMode](#interruptmode9) | Yes | Audio interruption mode.|
+|callback | AsyncCallback\ | Yes |Callback used to return the result.|
**Example**
@@ -5059,7 +5041,6 @@ audioRenderer.setInterruptMode(mode, (err, data)=>{
}
console.info('setInterruptMode Success!');
});
-
```
### setVolume9+
@@ -5072,15 +5053,15 @@ Sets the volume for the application. This API uses a promise to return the resul
**Parameters**
-| Name | Type | Mandatory | Description |
-| ------ | ------ | --------- | ------------------------------------------------------------ |
-| volume | number | Yes | Volume to set, which can be within the range from 0.0 to 1.0. |
+| Name | Type | Mandatory | Description |
+| ---------- | ------- | ------ | ------------------- |
+| volume | number | Yes | Volume to set, which can be within the range from 0.0 to 1.0.|
**Return value**
-| Type | Description |
-| ------------------- | ------------------------------------------------------------ |
-| Promise<void> | Promise used to return the result. If the operation is successful, **undefined** is returned. Otherwise, **error** is returned. |
+| Type | Description |
+| ------------------- | ----------------------------- |
+| Promise<void> | Promise used to return the result. If the operation is successful, **undefined** is returned. Otherwise, **error** is returned.|
**Example**
@@ -5090,9 +5071,7 @@ audioRenderer.setVolume(0.5).then(data=>{
}).catch((err) => {
console.error(`setVolume Fail: ${err}`);
});
-
```
-
### setVolume9+
setVolume(volume: number, callback: AsyncCallback\): void
@@ -5103,10 +5082,10 @@ Sets the volume for the application. This API uses an asynchronous callback to r
**Parameters**
-| Name | Type | Mandatory | Description |
-| -------- | -------------------- | --------- | ------------------------------------------------------------ |
-| volume | number | Yes | Volume to set, which can be within the range from 0.0 to 1.0. |
-| callback | AsyncCallback\ | Yes | Callback used to return the result. |
+| Name | Type | Mandatory | Description |
+| ------- | -----------| ------ | ------------------- |
+|volume | number | Yes | Volume to set, which can be within the range from 0.0 to 1.0.|
+|callback | AsyncCallback\ | Yes |Callback used to return the result.|
**Example**
@@ -5117,7 +5096,6 @@ audioRenderer.setVolume(0.5, (err, data)=>{
}
console.info('setVolume Success!');
});
-
```
### on('audioInterrupt')9+
@@ -5132,18 +5110,18 @@ Same as [on('interrupt')](#oninterrupt), this API is used to listen for focus ch
**Parameters**
-| Name | Type | Mandatory | Description |
-| -------- | ---------------------------------------------- | --------- | ------------------------------------------------------------ |
-| type | string | Yes | Event type. The value **'audioInterrupt'** means the audio interruption event, which is triggered when audio rendering is interrupted. |
-| callback | Callback\<[InterruptEvent](#interruptevent9)\> | Yes | Callback used to return the audio interruption event. |
+| Name | Type | Mandatory| Description |
+| -------- | -------------------------------------------- | ---- | ------------------------------------------------------------ |
+| type | string | Yes | Event type. The value **'audioInterrupt'** means the audio interruption event, which is triggered when audio rendering is interrupted.|
+| callback | Callback\<[InterruptEvent](#interruptevent9)\> | Yes | Callback used to return the audio interruption event. |
**Error codes**
For details about the error codes, see [Audio Error Codes](../errorcodes/errorcode-audio.md).
-| ID | Error Message |
-| ------- | ------------------------------ |
-| 6800101 | if input parameter value error |
+| ID| Error Message|
+| ------- | --------------------------------------------|
+| 6800101 | if input parameter value error |
**Example**
@@ -5215,7 +5193,6 @@ async function onAudioInterrupt(){
}
});
}
-
```
### on('markReach')8+
@@ -5228,11 +5205,11 @@ Subscribes to mark reached events. When the number of frames rendered reaches th
**Parameters**
-| Name | Type | Mandatory | Description |
-| :------- | :---------------- | :-------- | :----------------------------------------------------------- |
-| type | string | Yes | Event type. The value is fixed at **'markReach'**. |
-| frame | number | Yes | Number of frames to trigger the event. The value must be greater than **0**. |
-| callback | Callback\ | Yes | Callback invoked when the event is triggered. |
+| Name | Type | Mandatory| Description |
+| :------- | :----------------------- | :--- | :---------------------------------------- |
+| type | string | Yes | Event type. The value is fixed at **'markReach'**.|
+| frame | number | Yes | Number of frames to trigger the event. The value must be greater than **0**. |
+| callback | Callback\ | Yes | Callback invoked when the event is triggered. |
**Example**
@@ -5242,7 +5219,6 @@ audioRenderer.on('markReach', 1000, (position) => {
console.info('ON Triggered successfully');
}
});
-
```
@@ -5256,15 +5232,14 @@ Unsubscribes from mark reached events.
**Parameters**
-| Name | Type | Mandatory | Description |
-| :--- | :----- | :-------- | :------------------------------------------------- |
-| type | string | Yes | Event type. The value is fixed at **'markReach'**. |
+| Name| Type | Mandatory| Description |
+| :----- | :----- | :--- | :------------------------------------------------ |
+| type | string | Yes | Event type. The value is fixed at **'markReach'**.|
**Example**
```js
audioRenderer.off('markReach');
-
```
### on('periodReach') 8+
@@ -5277,11 +5252,11 @@ Subscribes to period reached events. When the number of frames rendered reaches
**Parameters**
-| Name | Type | Mandatory | Description |
-| :------- | :---------------- | :-------- | :----------------------------------------------------------- |
-| type | string | Yes | Event type. The value is fixed at **'periodReach'**. |
-| frame | number | Yes | Number of frames to trigger the event. The value must be greater than **0**. |
-| callback | Callback\ | Yes | Callback invoked when the event is triggered. |
+| Name | Type | Mandatory| Description |
+| :------- | :----------------------- | :--- | :------------------------------------------ |
+| type | string | Yes | Event type. The value is fixed at **'periodReach'**.|
+| frame | number | Yes | Number of frames to trigger the event. The value must be greater than **0**. |
+| callback | Callback\ | Yes | Callback invoked when the event is triggered. |
**Example**
@@ -5291,7 +5266,6 @@ audioRenderer.on('periodReach', 1000, (position) => {
console.info('ON Triggered successfully');
}
});
-
```
### off('periodReach') 8+
@@ -5304,15 +5278,14 @@ Unsubscribes from period reached events.
**Parameters**
-| Name | Type | Mandatory | Description |
-| :--- | :----- | :-------- | :--------------------------------------------------- |
-| type | string | Yes | Event type. The value is fixed at **'periodReach'**. |
+| Name| Type | Mandatory| Description |
+| :----- | :----- | :--- | :-------------------------------------------------- |
+| type | string | Yes | Event type. The value is fixed at **'periodReach'**.|
**Example**
```js
audioRenderer.off('periodReach')
-
```
### on('stateChange')8+
@@ -5325,10 +5298,10 @@ Subscribes to state change events.
**Parameters**
-| Name | Type | Mandatory | Description |
-| :------- | :------------------------------------ | :-------- | :----------------------------------------------------------- |
-| type | string | Yes | Event type. The value **stateChange** means the state change event. |
-| callback | Callback\<[AudioState](#audiostate8)> | Yes | Callback used to return the state change. |
+| Name | Type | Mandatory| Description |
+| :------- | :------------------------- | :--- | :------------------------------------------ |
+| type | string | Yes | Event type. The value **stateChange** means the state change event.|
+| callback | Callback\<[AudioState](#audiostate8)> | Yes | Callback used to return the state change. |
**Example**
@@ -5341,7 +5314,6 @@ audioRenderer.on('stateChange', (state) => {
console.info('audio renderer state is: STATE_RUNNING');
}
});
-
```
## AudioCapturer8+
@@ -5352,15 +5324,14 @@ Provides APIs for audio capture. Before calling any API in **AudioCapturer**, yo
**System capability**: SystemCapability.Multimedia.Audio.Capturer
-| Name | Type | Readable | Writable | Description |
-| :----------------- | :------------------------- | :------- | :------- | :-------------------- |
-| state8+ | [AudioState](#audiostate8) | Yes | No | Audio capturer state. |
+| Name | Type | Readable| Writable| Description |
+| :---- | :------------------------- | :--- | :--- | :--------------- |
+| state8+ | [AudioState](#audiostate8) | Yes| No | Audio capturer state.|
**Example**
```js
let state = audioCapturer.state;
-
```
### getCapturerInfo8+
@@ -5373,9 +5344,9 @@ Obtains the capturer information of this **AudioCapturer** instance. This API us
**Parameters**
-| Name | Type | Mandatory | Description |
-| :------- | :-------------------------------- | :-------- | :------------------------------------------------ |
-| callback | AsyncCallback | Yes | Callback used to return the capturer information. |
+| Name | Type | Mandatory| Description |
+| :------- | :-------------------------------- | :--- | :----------------------------------- |
+| callback | AsyncCallback | Yes | Callback used to return the capturer information.|
**Example**
@@ -5389,7 +5360,6 @@ audioCapturer.getCapturerInfo((err, capturerInfo) => {
console.info(`Capturer flags: ${capturerInfo.capturerFlags}`);
}
});
-
```
@@ -5403,9 +5373,9 @@ Obtains the capturer information of this **AudioCapturer** instance. This API us
**Return value**
-| Type | Description |
-| :------------------------------------------------ | :----------------------------------------------- |
-| Promise<[AudioCapturerInfo](#audiocapturerinfo)\> | Promise used to return the capturer information. |
+| Type | Description |
+| :------------------------------------------------ | :---------------------------------- |
+| Promise<[AudioCapturerInfo](#audiocapturerinfo)\> | Promise used to return the capturer information.|
**Example**
@@ -5422,7 +5392,6 @@ audioCapturer.getCapturerInfo().then((audioParamsGet) => {
}).catch((err) => {
console.error(`AudioFrameworkRecLog: CapturerInfo :ERROR: ${err}`);
});
-
```
### getStreamInfo8+
@@ -5435,9 +5404,9 @@ Obtains the stream information of this **AudioCapturer** instance. This API uses
**Parameters**
-| Name | Type | Mandatory | Description |
-| :------- | :--------------------------------------------------- | :-------- | :---------------------------------------------- |
-| callback | AsyncCallback<[AudioStreamInfo](#audiostreaminfo8)\> | Yes | Callback used to return the stream information. |
+| Name | Type | Mandatory| Description |
+| :------- | :--------------------------------------------------- | :--- | :------------------------------- |
+| callback | AsyncCallback<[AudioStreamInfo](#audiostreaminfo8)\> | Yes | Callback used to return the stream information.|
**Example**
@@ -5453,7 +5422,6 @@ audioCapturer.getStreamInfo((err, streamInfo) => {
console.info(`Capturer encoding type: ${streamInfo.encodingType}`);
}
});
-
```
### getStreamInfo8+
@@ -5466,9 +5434,9 @@ Obtains the stream information of this **AudioCapturer** instance. This API uses
**Return value**
-| Type | Description |
-| :--------------------------------------------- | :--------------------------------------------- |
-| Promise<[AudioStreamInfo](#audiostreaminfo8)\> | Promise used to return the stream information. |
+| Type | Description |
+| :--------------------------------------------- | :------------------------------ |
+| Promise<[AudioStreamInfo](#audiostreaminfo8)\> | Promise used to return the stream information.|
**Example**
@@ -5482,7 +5450,6 @@ audioCapturer.getStreamInfo().then((audioParamsGet) => {
}).catch((err) => {
console.error(`getStreamInfo :ERROR: ${err}`);
});
-
```
### getAudioStreamId9+
@@ -5495,9 +5462,9 @@ Obtains the stream ID of this **AudioCapturer** instance. This API uses an async
**Parameters**
-| Name | Type | Mandatory | Description |
-| :------- | :--------------------- | :-------- | :------------------------------------- |
-| callback | AsyncCallback | Yes | Callback used to return the stream ID. |
+| Name | Type | Mandatory| Description |
+| :------- | :--------------------------------------------------- | :--- | :------------------- |
+| callback | AsyncCallback | Yes | Callback used to return the stream ID.|
**Example**
@@ -5505,7 +5472,6 @@ Obtains the stream ID of this **AudioCapturer** instance. This API uses an async
audioCapturer.getAudioStreamId((err, streamid) => {
console.info(`audioCapturer GetStreamId: ${streamid}`);
});
-
```
### getAudioStreamId9+
@@ -5518,9 +5484,9 @@ Obtains the stream ID of this **AudioCapturer** instance. This API uses a promis
**Return value**
-| Type | Description |
-| :--------------- | :------------------------------------ |
-| Promise | Promise used to return the stream ID. |
+| Type | Description |
+| :----------------| :--------------------- |
+| Promise | Promise used to return the stream ID.|
**Example**
@@ -5530,7 +5496,6 @@ audioCapturer.getAudioStreamId().then((streamid) => {
}).catch((err) => {
console.error(`ERROR: ${err}`);
});
-
```
### start8+
@@ -5543,9 +5508,9 @@ Starts capturing. This API uses an asynchronous callback to return the result.
**Parameters**
-| Name | Type | Mandatory | Description |
-| :------- | :------------------- | :-------- | :---------------------------------- |
-| callback | AsyncCallback | Yes | Callback used to return the result. |
+| Name | Type | Mandatory| Description |
+| :------- | :------------------- | :--- | :----------------------------- |
+| callback | AsyncCallback | Yes | Callback used to return the result.|
**Example**
@@ -5557,7 +5522,6 @@ audioCapturer.start((err) => {
console.info('Capturer start success.');
}
});
-
```
@@ -5571,9 +5535,9 @@ Starts capturing. This API uses a promise to return the result.
**Return value**
-| Type | Description |
-| :------------- | :--------------------------------- |
-| Promise | Promise used to return the result. |
+| Type | Description |
+| :------------- | :---------------------------- |
+| Promise | Promise used to return the result.|
**Example**
@@ -5589,7 +5553,6 @@ audioCapturer.start().then(() => {
}).catch((err) => {
console.info(`AudioFrameworkRecLog: Capturer start :ERROR : ${err}`);
});
-
```
### stop8+
@@ -5602,9 +5565,9 @@ Stops capturing. This API uses an asynchronous callback to return the result.
**Parameters**
-| Name | Type | Mandatory | Description |
-| :------- | :------------------- | :-------- | :---------------------------------- |
-| callback | AsyncCallback | Yes | Callback used to return the result. |
+| Name | Type | Mandatory| Description |
+| :------- | :------------------- | :--- | :----------------------------- |
+| callback | AsyncCallback | Yes | Callback used to return the result.|
**Example**
@@ -5616,7 +5579,6 @@ audioCapturer.stop((err) => {
console.info('Capturer stopped.');
}
});
-
```
@@ -5630,9 +5592,9 @@ Stops capturing. This API uses a promise to return the result.
**Return value**
-| Type | Description |
-| :------------- | :--------------------------------- |
-| Promise | Promise used to return the result. |
+| Type | Description |
+| :------------- | :---------------------------- |
+| Promise | Promise used to return the result.|
**Example**
@@ -5646,7 +5608,6 @@ audioCapturer.stop().then(() => {
}).catch((err) => {
console.info(`AudioFrameworkRecLog: Capturer stop: ERROR: ${err}`);
});
-
```
### release8+
@@ -5659,9 +5620,9 @@ Releases this **AudioCapturer** instance. This API uses an asynchronous callback
**Parameters**
-| Name | Type | Mandatory | Description |
-| :------- | :------------------- | :-------- | :---------------------------------- |
-| callback | AsyncCallback | Yes | Callback used to return the result. |
+| Name | Type | Mandatory| Description |
+| :------- | :------------------- | :--- | :---------------------------------- |
+| callback | AsyncCallback | Yes | Callback used to return the result.|
**Example**
@@ -5673,7 +5634,6 @@ audioCapturer.release((err) => {
console.info('capturer released.');
}
});
-
```
@@ -5687,9 +5647,9 @@ Releases this **AudioCapturer** instance. This API uses a promise to return the
**Return value**
-| Type | Description |
-| :------------- | :--------------------------------- |
-| Promise | Promise used to return the result. |
+| Type | Description |
+| :------------- | :---------------------------- |
+| Promise | Promise used to return the result.|
**Example**
@@ -5703,7 +5663,6 @@ audioCapturer.release().then(() => {
}).catch((err) => {
console.info(`AudioFrameworkRecLog: Capturer stop: ERROR: ${err}`);
});
-
```
### read8+
@@ -5716,11 +5675,11 @@ Reads the buffer. This API uses an asynchronous callback to return the result.
**Parameters**
-| Name | Type | Mandatory | Description |
-| :------------- | :-------------------------- | :-------- | :----------------------------------- |
-| size | number | Yes | Number of bytes to read. |
-| isBlockingRead | boolean | Yes | Whether to block the read operation. |
-| callback | AsyncCallback | Yes | Callback used to return the buffer. |
+| Name | Type | Mandatory| Description |
+| :------------- | :-------------------------- | :--- | :------------------------------- |
+| size | number | Yes | Number of bytes to read. |
+| isBlockingRead | boolean | Yes | Whether to block the read operation. |
+| callback | AsyncCallback | Yes | Callback used to return the buffer.|
**Example**
@@ -5737,7 +5696,6 @@ audioCapturer.read(bufferSize, true, async(err, buffer) => {
console.info('Success in reading the buffer data');
}
});
-
```
### read8+
@@ -5750,16 +5708,16 @@ Reads the buffer. This API uses a promise to return the result.
**Parameters**
-| Name | Type | Mandatory | Description |
-| :------------- | :------ | :-------- | :----------------------------------- |
-| size | number | Yes | Number of bytes to read. |
-| isBlockingRead | boolean | Yes | Whether to block the read operation. |
+| Name | Type | Mandatory| Description |
+| :------------- | :------ | :--- | :--------------- |
+| size | number | Yes | Number of bytes to read. |
+| isBlockingRead | boolean | Yes | Whether to block the read operation.|
**Return value**
-| Type | Description |
-| :-------------------- | :----------------------------------------------------------- |
-| Promise | Promise used to return the result. If the operation is successful, the buffer data read is returned; otherwise, an error code is returned. |
+| Type | Description |
+| :-------------------- | :----------------------------------------------------- |
+| Promise | Promise used to return the result. If the operation is successful, the buffer data read is returned; otherwise, an error code is returned.|
**Example**
@@ -5777,7 +5735,6 @@ audioCapturer.read(bufferSize, true).then((buffer) => {
}).catch((err) => {
console.info(`ERROR : ${err}`);
});
-
```
### getAudioTime8+
@@ -5790,9 +5747,9 @@ Obtains the number of nanoseconds elapsed from the Unix epoch (January 1, 1970).
**Parameters**
-| Name | Type | Mandatory | Description |
-| :------- | :--------------------- | :-------- | :---------------------------------- |
-| callback | AsyncCallback | Yes | Callback used to return the result. |
+| Name | Type | Mandatory| Description |
+| :------- | :--------------------- | :--- | :----------------------------- |
+| callback | AsyncCallback | Yes | Callback used to return the result.|
**Example**
@@ -5800,7 +5757,6 @@ Obtains the number of nanoseconds elapsed from the Unix epoch (January 1, 1970).
audioCapturer.getAudioTime((err, timestamp) => {
console.info(`Current timestamp: ${timestamp}`);
});
-
```
### getAudioTime8+
@@ -5813,9 +5769,9 @@ Obtains the number of nanoseconds elapsed from the Unix epoch (January 1, 1970).
**Return value**
-| Type | Description |
-| :--------------- | :------------------------------------ |
-| Promise | Promise used to return the timestamp. |
+| Type | Description |
+| :--------------- | :---------------------------- |
+| Promise | Promise used to return the timestamp.|
**Example**
@@ -5825,7 +5781,6 @@ audioCapturer.getAudioTime().then((audioTime) => {
}).catch((err) => {
console.info(`AudioFrameworkRecLog: AudioCapturer Created : ERROR : ${err}`);
});
-
```
### getBufferSize8+
@@ -5838,9 +5793,9 @@ Obtains a reasonable minimum buffer size in bytes for capturing. This API uses a
**Parameters**
-| Name | Type | Mandatory | Description |
-| :------- | :--------------------- | :-------- | :--------------------------------------- |
-| callback | AsyncCallback | Yes | Callback used to return the buffer size. |
+| Name | Type | Mandatory| Description |
+| :------- | :--------------------- | :--- | :----------------------------------- |
+| callback | AsyncCallback | Yes | Callback used to return the buffer size.|
**Example**
@@ -5855,7 +5810,6 @@ audioCapturer.getBufferSize((err, bufferSize) => {
});
}
});
-
```
### getBufferSize8+
@@ -5868,9 +5822,9 @@ Obtains a reasonable minimum buffer size in bytes for capturing. This API uses a
**Return value**
-| Type | Description |
-| :--------------- | :-------------------------------------- |
-| Promise | Promise used to return the buffer size. |
+| Type | Description |
+| :--------------- | :---------------------------------- |
+| Promise | Promise used to return the buffer size.|
**Example**
@@ -5882,14 +5836,13 @@ audioCapturer.getBufferSize().then((data) => {
}).catch((err) => {
console.info(`AudioFrameworkRecLog: getBufferSize :ERROR : ${err}`);
});
-
```
### on('audioInterrupt')10+
on(type: 'audioInterrupt', callback: Callback\): void
-Subscribes to audio interruption events. This API uses a callback to get interrupt events.
+Subscribes to audio interruption events. This API uses a callback to obtain interrupt events.
Same as [on('interrupt')](#oninterrupt), this API is used to listen for focus changes. The **AudioCapturer** instance proactively gains the focus when the **start** event occurs and releases the focus when the **pause** or **stop** event occurs. Therefore, you do not need to request to gain or release the focus.
@@ -5897,18 +5850,18 @@ Same as [on('interrupt')](#oninterrupt), this API is used to listen for focus ch
**Parameters**
-| Name | Type | Mandatory | Description |
-| -------- | ---------------------------------------------- | --------- | ------------------------------------------------------------ |
-| type | string | Yes | Event type. The value **'audioInterrupt'** means the audio interruption event, which is triggered when audio capturing is interrupted. |
-| callback | Callback\<[InterruptEvent](#interruptevent9)\> | Yes | Callback used to return the audio interruption event. |
+| Name | Type | Mandatory| Description |
+| -------- | -------------------------------------------- | ---- | ------------------------------------------------------------ |
+| type | string | Yes | Event type. The value **'audioInterrupt'** means the audio interruption event, which is triggered when audio capturing is interrupted.|
+| callback | Callback\<[InterruptEvent](#interruptevent9)\> | Yes | Callback used to return the audio interruption event. |
**Error codes**
For details about the error codes, see [Audio Error Codes](../errorcodes/errorcode-audio.md).
-| ID | Error Message |
-| ------- | ------------------------------ |
-| 6800101 | if input parameter value error |
+| ID| Error Message|
+| ------- | --------------------------------------------|
+| 6800101 | if input parameter value error |
**Example**
@@ -5959,7 +5912,6 @@ async function onAudioInterrupt(){
}
});
}
-
```
@@ -5973,11 +5925,11 @@ Subscribes to mark reached events. When the number of frames captured reaches th
**Parameters**
-| Name | Type | Mandatory | Description |
-| :------- | :---------------- | :-------- | :----------------------------------------------------------- |
-| type | string | Yes | Event type. The value is fixed at **'markReach'**. |
-| frame | number | Yes | Number of frames to trigger the event. The value must be greater than **0**. |
-| callback | Callback\ | Yes | Callback invoked when the event is triggered. |
+| Name | Type | Mandatory| Description |
+| :------- | :---------------------- | :--- | :----------------------------------------- |
+| type | string | Yes | Event type. The value is fixed at **'markReach'**. |
+| frame | number | Yes | Number of frames to trigger the event. The value must be greater than **0**. |
+| callback | Callback\ | Yes | Callback invoked when the event is triggered.|
**Example**
@@ -5987,7 +5939,6 @@ audioCapturer.on('markReach', 1000, (position) => {
console.info('ON Triggered successfully');
}
});
-
```
### off('markReach')8+
@@ -6000,15 +5951,14 @@ Unsubscribes from mark reached events.
**Parameters**
-| Name | Type | Mandatory | Description |
-| :--- | :----- | :-------- | :------------------------------------------------- |
-| type | string | Yes | Event type. The value is fixed at **'markReach'**. |
+| Name| Type | Mandatory| Description |
+| :----- | :----- | :--- | :-------------------------------------------- |
+| type | string | Yes | Event type. The value is fixed at **'markReach'**.|
**Example**
```js
audioCapturer.off('markReach');
-
```
### on('periodReach')8+
@@ -6021,11 +5971,11 @@ Subscribes to period reached events. When the number of frames captured reaches
**Parameters**
-| Name | Type | Mandatory | Description |
-| :------- | :---------------- | :-------- | :----------------------------------------------------------- |
-| type | string | Yes | Event type. The value is fixed at **'periodReach'**. |
-| frame | number | Yes | Number of frames to trigger the event. The value must be greater than **0**. |
-| callback | Callback\ | Yes | Callback invoked when the event is triggered. |
+| Name | Type | Mandatory| Description |
+| :------- | :----------------------- | :--- | :------------------------------------------ |
+| type | string | Yes | Event type. The value is fixed at **'periodReach'**.|
+| frame | number | Yes | Number of frames to trigger the event. The value must be greater than **0**. |
+| callback | Callback\ | Yes | Callback invoked when the event is triggered. |
**Example**
@@ -6035,7 +5985,6 @@ audioCapturer.on('periodReach', 1000, (position) => {
console.info('ON Triggered successfully');
}
});
-
```
### off('periodReach')8+
@@ -6048,15 +5997,14 @@ Unsubscribes from period reached events.
**Parameters**
-| Name | Type | Mandatory | Description |
-| :--- | :----- | :-------- | :--------------------------------------------------- |
-| type | string | Yes | Event type. The value is fixed at **'periodReach'**. |
+| Name| Type | Mandatory| Description |
+| :----- | :----- | :--- | :---------------------------------------------- |
+| type | string | Yes | Event type. The value is fixed at **'periodReach'**.|
**Example**
```js
audioCapturer.off('periodReach')
-
```
### on('stateChange')8+
@@ -6069,10 +6017,10 @@ Subscribes to state change events.
**Parameters**
-| Name | Type | Mandatory | Description |
-| :------- | :------------------------------------ | :-------- | :----------------------------------------------------------- |
-| type | string | Yes | Event type. The value **stateChange** means the state change event. |
-| callback | Callback\<[AudioState](#audiostate8)> | Yes | Callback used to return the state change. |
+| Name | Type | Mandatory| Description |
+| :------- | :------------------------- | :--- | :------------------------------------------ |
+| type | string | Yes | Event type. The value **stateChange** means the state change event.|
+| callback | Callback\<[AudioState](#audiostate8)> | Yes | Callback used to return the state change. |
**Example**
@@ -6085,7 +6033,6 @@ audioCapturer.on('stateChange', (state) => {
console.info('audio capturer state is: STATE_RUNNING');
}
});
-
```
## ToneType9+
@@ -6096,35 +6043,35 @@ Enumerates the tone types of the player.
**System capability**: SystemCapability.Multimedia.Audio.Tone
-| Name | Value | Description |
-| :----------------------------------------------- | :---- | :-------------------------------------------- |
-| TONE_TYPE_DIAL_0 | 0 | DTMF tone of key 0. |
-| TONE_TYPE_DIAL_1 | 1 | DTMF tone of key 1. |
-| TONE_TYPE_DIAL_2 | 2 | DTMF tone of key 2. |
-| TONE_TYPE_DIAL_3 | 3 | DTMF tone of key 3. |
-| TONE_TYPE_DIAL_4 | 4 | DTMF tone of key 4. |
-| TONE_TYPE_DIAL_5 | 5 | DTMF tone of key 5. |
-| TONE_TYPE_DIAL_6 | 6 | DTMF tone of key 6. |
-| TONE_TYPE_DIAL_7 | 7 | DTMF tone of key 7. |
-| TONE_TYPE_DIAL_8 | 8 | DTMF tone of key 8. |
-| TONE_TYPE_DIAL_9 | 9 | DTMF tone of key 9. |
-| TONE_TYPE_DIAL_S | 10 | DTMF tone of the star key (*). |
-| TONE_TYPE_DIAL_P | 11 | DTMF tone of the pound key (#). |
-| TONE_TYPE_DIAL_A | 12 | DTMF tone of key A. |
-| TONE_TYPE_DIAL_B | 13 | DTMF tone of key B. |
-| TONE_TYPE_DIAL_C | 14 | DTMF tone of key C. |
-| TONE_TYPE_DIAL_D | 15 | DTMF tone of key D. |
-| TONE_TYPE_COMMON_SUPERVISORY_DIAL | 100 | Supervisory tone - dial tone. |
-| TONE_TYPE_COMMON_SUPERVISORY_BUSY | 101 | Supervisory tone - busy. |
-| TONE_TYPE_COMMON_SUPERVISORY_CONGESTION | 102 | Supervisory tone - congestion. |
-| TONE_TYPE_COMMON_SUPERVISORY_RADIO_ACK | 103 | Supervisory tone - radio path acknowledgment. |
-| TONE_TYPE_COMMON_SUPERVISORY_RADIO_NOT_AVAILABLE | 104 | Supervisory tone - radio path not available. |
-| TONE_TYPE_COMMON_SUPERVISORY_CALL_WAITING | 106 | Supervisory tone - call waiting tone. |
-| TONE_TYPE_COMMON_SUPERVISORY_RINGTONE | 107 | Supervisory tone - ringing tone. |
-| TONE_TYPE_COMMON_PROPRIETARY_BEEP | 200 | Proprietary tone - beep tone. |
-| TONE_TYPE_COMMON_PROPRIETARY_ACK | 201 | Proprietary tone - ACK. |
-| TONE_TYPE_COMMON_PROPRIETARY_PROMPT | 203 | Proprietary tone - PROMPT. |
-| TONE_TYPE_COMMON_PROPRIETARY_DOUBLE_BEEP | 204 | Proprietary tone - double beep tone. |
+| Name | Value | Description |
+| :------------------------------------------------ | :----- | :----------------------------|
+| TONE_TYPE_DIAL_0 | 0 | DTMF tone of key 0. |
+| TONE_TYPE_DIAL_1 | 1 | DTMF tone of key 1. |
+| TONE_TYPE_DIAL_2 | 2 | DTMF tone of key 2. |
+| TONE_TYPE_DIAL_3 | 3 | DTMF tone of key 3. |
+| TONE_TYPE_DIAL_4 | 4 | DTMF tone of key 4. |
+| TONE_TYPE_DIAL_5 | 5 | DTMF tone of key 5. |
+| TONE_TYPE_DIAL_6 | 6 | DTMF tone of key 6. |
+| TONE_TYPE_DIAL_7 | 7 | DTMF tone of key 7. |
+| TONE_TYPE_DIAL_8 | 8 | DTMF tone of key 8. |
+| TONE_TYPE_DIAL_9 | 9 | DTMF tone of key 9. |
+| TONE_TYPE_DIAL_S | 10 | DTMF tone of the star key (*). |
+| TONE_TYPE_DIAL_P | 11 | DTMF tone of the pound key (#). |
+| TONE_TYPE_DIAL_A | 12 | DTMF tone of key A. |
+| TONE_TYPE_DIAL_B | 13 | DTMF tone of key B. |
+| TONE_TYPE_DIAL_C | 14 | DTMF tone of key C. |
+| TONE_TYPE_DIAL_D | 15 | DTMF tone of key D. |
+| TONE_TYPE_COMMON_SUPERVISORY_DIAL | 100 | Supervisory tone - dial tone. |
+| TONE_TYPE_COMMON_SUPERVISORY_BUSY | 101 | Supervisory tone - busy. |
+| TONE_TYPE_COMMON_SUPERVISORY_CONGESTION | 102 | Supervisory tone - congestion. |
+| TONE_TYPE_COMMON_SUPERVISORY_RADIO_ACK | 103 | Supervisory tone - radio path acknowledgment. |
+| TONE_TYPE_COMMON_SUPERVISORY_RADIO_NOT_AVAILABLE | 104 | Supervisory tone - radio path not available. |
+| TONE_TYPE_COMMON_SUPERVISORY_CALL_WAITING | 106 | Supervisory tone - call waiting tone. |
+| TONE_TYPE_COMMON_SUPERVISORY_RINGTONE | 107 | Supervisory tone - ringing tone. |
+| TONE_TYPE_COMMON_PROPRIETARY_BEEP | 200 | Proprietary tone - beep tone. |
+| TONE_TYPE_COMMON_PROPRIETARY_ACK | 201 | Proprietary tone - ACK. |
+| TONE_TYPE_COMMON_PROPRIETARY_PROMPT | 203 | Proprietary tone - PROMPT. |
+| TONE_TYPE_COMMON_PROPRIETARY_DOUBLE_BEEP | 204 | Proprietary tone - double beep tone. |
## TonePlayer9+
@@ -6144,10 +6091,10 @@ Loads the DTMF tone configuration. This API uses an asynchronous callback to ret
**Parameters**
-| Name | Type | Mandatory | Description |
-| :------- | :--------------------- | :-------- | :---------------------------------- |
-| type | [ToneType](#tonetype9) | Yes | Tone type. |
-| callback | AsyncCallback | Yes | Callback used to return the result. |
+| Name | Type | Mandatory | Description |
+| :--------------| :-------------------------- | :-----| :------------------------------ |
+| type | [ToneType](#tonetype9) | Yes | Tone type. |
+| callback | AsyncCallback | Yes | Callback used to return the result.|
**Example**
@@ -6160,7 +6107,6 @@ tonePlayer.load(audio.ToneType.TONE_TYPE_DIAL_5, (err) => {
console.info('callback call load success');
}
});
-
```
### load9+
@@ -6175,15 +6121,15 @@ Loads the DTMF tone configuration. This API uses a promise to return the result.
**Parameters**
-| Name | Type | Mandatory | Description |
-| :--- | :--------------------- | :-------- | ----------- |
-| type | [ToneType](#tonetype9) | Yes | Tone type. |
+| Name | Type | Mandatory | Description |
+| :------------- | :--------------------- | :--- | ---------------- |
+| type | [ToneType](#tonetype9) | Yes | Tone type. |
**Return value**
-| Type | Description |
-| :------------- | :--------------------------------- |
-| Promise | Promise used to return the result. |
+| Type | Description |
+| :--------------| :-------------------------- |
+| Promise | Promise used to return the result.|
**Example**
@@ -6193,7 +6139,6 @@ tonePlayer.load(audio.ToneType.TONE_TYPE_DIAL_1).then(() => {
}).catch(() => {
console.error('promise call load fail');
});
-
```
### start9+
@@ -6208,9 +6153,9 @@ Starts DTMF tone playing. This API uses an asynchronous callback to return the r
**Parameters**
-| Name | Type | Mandatory | Description |
-| :------- | :------------------- | :-------- | :---------------------------------- |
-| callback | AsyncCallback | Yes | Callback used to return the result. |
+| Name | Type | Mandatory| Description |
+| :------- | :------------------- | :--- | :----------------------------- |
+| callback | AsyncCallback | Yes | Callback used to return the result.|
**Example**
@@ -6223,7 +6168,6 @@ tonePlayer.start((err) => {
console.info('callback call start success');
}
});
-
```
### start9+
@@ -6238,9 +6182,9 @@ Starts DTMF tone playing. This API uses a promise to return the result.
**Return value**
-| Type | Description |
-| :------------- | :--------------------------------- |
-| Promise | Promise used to return the result. |
+| Type | Description |
+| :------------- | :---------------------------- |
+| Promise | Promise used to return the result.|
**Example**
@@ -6250,7 +6194,6 @@ tonePlayer.start().then(() => {
}).catch(() => {
console.error('promise call start fail');
});
-
```
### stop9+
@@ -6265,9 +6208,9 @@ Stops the tone that is being played. This API uses an asynchronous callback to r
**Parameters**
-| Name | Type | Mandatory | Description |
-| :------- | :------------------- | :-------- | :---------------------------------- |
-| callback | AsyncCallback | Yes | Callback used to return the result. |
+| Name | Type | Mandatory| Description |
+| :------- | :------------------- | :--- | :----------------------------- |
+| callback | AsyncCallback | Yes | Callback used to return the result.|
**Example**
@@ -6280,7 +6223,6 @@ tonePlayer.stop((err) => {
console.error('callback call stop success ');
}
});
-
```
### stop9+
@@ -6295,9 +6237,9 @@ Stops the tone that is being played. This API uses a promise to return the resul
**Return value**
-| Type | Description |
-| :------------- | :--------------------------------- |
-| Promise | Promise used to return the result. |
+| Type | Description |
+| :------------- | :---------------------------- |
+| Promise | Promise used to return the result.|
**Example**
@@ -6307,7 +6249,6 @@ tonePlayer.stop().then(() => {
}).catch(() => {
console.error('promise call stop fail');
});
-
```
### release9+
@@ -6322,9 +6263,9 @@ Releases the resources associated with the **TonePlayer** instance. This API use
**Parameters**
-| Name | Type | Mandatory | Description |
-| :------- | :------------------- | :-------- | :---------------------------------- |
-| callback | AsyncCallback | Yes | Callback used to return the result. |
+| Name | Type | Mandatory| Description |
+| :------- | :------------------- | :--- | :---------------------------- |
+| callback | AsyncCallback | Yes | Callback used to return the result. |
**Example**
@@ -6337,7 +6278,6 @@ tonePlayer.release((err) => {
console.info('callback call release success ');
}
});
-
```
### release9+
@@ -6352,9 +6292,9 @@ Releases the resources associated with the **TonePlayer** instance. This API use
**Return value**
-| Type | Description |
-| :------------- | :--------------------------------- |
-| Promise | Promise used to return the result. |
+| Type | Description |
+| :------------- | :---------------------------- |
+| Promise | Promise used to return the result.|
**Example**
@@ -6364,7 +6304,6 @@ tonePlayer.release().then(() => {
}).catch(() => {
console.error('promise call release fail');
});
-
```
## ActiveDeviceType(deprecated)
@@ -6377,10 +6316,10 @@ Enumerates the active device types.
**System capability**: SystemCapability.Multimedia.Audio.Device
-| Name | Value | Description |
-| ------------- | ----- | ------------------------------------------------------------ |
-| SPEAKER | 2 | Speaker. |
-| BLUETOOTH_SCO | 7 | Bluetooth device using Synchronous Connection Oriented (SCO) links. |
+| Name | Value | Description |
+| ------------- | ------ | ---------------------------------------------------- |
+| SPEAKER | 2 | Speaker. |
+| BLUETOOTH_SCO | 7 | Bluetooth device using Synchronous Connection Oriented (SCO) links.|
## InterruptActionType(deprecated)
@@ -6392,10 +6331,10 @@ Enumerates the returned event types for audio interruption events.
**System capability**: SystemCapability.Multimedia.Audio.Renderer
-| Name | Value | Description |
-| -------------- | ----- | ------------------------- |
-| TYPE_ACTIVATED | 0 | Focus gain event. |
-| TYPE_INTERRUPT | 1 | Audio interruption event. |
+| Name | Value | Description |
+| -------------- | ------ | ------------------ |
+| TYPE_ACTIVATED | 0 | Focus gain event.|
+| TYPE_INTERRUPT | 1 | Audio interruption event.|
## AudioInterrupt(deprecated)
@@ -6407,11 +6346,11 @@ Describes input parameters of audio interruption events.
**System capability**: SystemCapability.Multimedia.Audio.Renderer
-| Name | Type | Mandatory | Description |
-| --------------- | --------------------------- | --------- | ------------------------------------------------------------ |
-| streamUsage | [StreamUsage](#streamusage) | Yes | Audio stream usage. |
-| contentType | [ContentType](#contenttype) | Yes | Audio content type. |
-| pauseWhenDucked | boolean | Yes | Whether audio playback can be paused during audio interruption. The value **true** means that audio playback can be paused during audio interruption, and **false** means the opposite. |
+| Name | Type | Mandatory| Description |
+| --------------- | --------------------------- | ----| ------------------------------------------------------------ |
+| streamUsage | [StreamUsage](#streamusage) | Yes | Audio stream usage. |
+| contentType | [ContentType](#contenttype) | Yes | Audio content type. |
+| pauseWhenDucked | boolean | Yes | Whether audio playback can be paused during audio interruption. The value **true** means that audio playback can be paused during audio interruption, and **false** means the opposite.|
## InterruptAction(deprecated)
@@ -6423,9 +6362,9 @@ Describes the callback invoked for audio interruption or focus gain events.
**System capability**: SystemCapability.Multimedia.Audio.Renderer
-| Name | Type | Mandatory | Description |
-| ---------- | ----------------------------------------------------- | --------- | ------------------------------------------------------------ |
-| actionType | [InterruptActionType](#interruptactiontypedeprecated) | Yes | Returned event type. The value **TYPE_ACTIVATED** means the focus gain event, and **TYPE_INTERRUPT** means the audio interruption event. |
-| type | [InterruptType](#interrupttype) | No | Type of the audio interruption event. |
-| hint | [InterruptHint](#interrupthint) | No | Hint provided along with the audio interruption event. |
-| activated | boolean | No | Whether the focus is gained or released. The value **true** means that the focus is gained or released, and **false** means that the focus fails to be gained or released. |
\ No newline at end of file
+| Name | Type | Mandatory| Description |
+| ---------- | ------------------------------------------- | ---- | ------------------------------------------------------------ |
+| actionType | [InterruptActionType](#interruptactiontypedeprecated) | Yes | Returned event type. The value **TYPE_ACTIVATED** means the focus gain event, and **TYPE_INTERRUPT** means the audio interruption event.|
+| type | [InterruptType](#interrupttype) | No | Type of the audio interruption event. |
+| hint | [InterruptHint](#interrupthint) | No | Hint provided along with the audio interruption event. |
+| activated | boolean | No | Whether the focus is gained or released. The value **true** means that the focus is gained or released, and **false** means that the focus fails to be gained or released.|
diff --git a/en/application-dev/reference/apis/js-apis-avsession.md b/en/application-dev/reference/apis/js-apis-avsession.md
index 7efa6349694569c43954930e8fafdb8046a2446c..d9a98b7c17e79f588e60b199f8bf4530e781ce83 100644
--- a/en/application-dev/reference/apis/js-apis-avsession.md
+++ b/en/application-dev/reference/apis/js-apis-avsession.md
@@ -3,6 +3,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 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.
@@ -431,7 +432,7 @@ Before calling this API, import the **ohos.multimedia.audio** module to obtain t
| Type | Description |
| -------------- | ----------------------------- |
-| Promise | Promise used to return the result. If the casting 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**
@@ -453,13 +454,13 @@ let audioRoutingManager = audioManager.getRoutingManager();
let audioDevices;
await audioRoutingManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG).then((data) => {
audioDevices = data;
- console.info('Promise returned to indicate that the device list is obtained.');
+ console.info(`Promise returned to indicate that the device list is obtained.`);
}).catch((err) => {
console.info(`GetDevices BusinessError: code: ${err.code}, message: ${err.message}`);
});
avSession.castAudio('all', audioDevices).then(() => {
- console.info('CreateController : SUCCESS');
+ console.info(`CreateController : SUCCESS`);
}).catch((err) => {
console.info(`CreateController BusinessError: code: ${err.code}, message: ${err.message}`);
});
@@ -485,7 +486,7 @@ Before calling this API, import the **ohos.multimedia.audio** module to obtain t
| ------------ |--------------------------------------------| ---- | ------------------------------------------------------------ |
| session | [SessionToken](#sessiontoken) | 'all' | Yes | Session token. **SessionToken** indicates a specific token, and **'all'** indicates all tokens.|
| audioDevices | Array\<[audio.AudioDeviceDescriptor](js-apis-audio.md#audiodevicedescriptor)\> | Yes | Audio devices. |
-| callback | AsyncCallback | Yes | Callback used to return the result. If the casting is successful, **err** is **undefined**; otherwise, **err** is an error object. |
+| 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**
@@ -507,7 +508,7 @@ let audioRoutingManager = audioManager.getRoutingManager();
let audioDevices;
await audioRoutingManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG).then((data) => {
audioDevices = data;
- console.info('Promise returned to indicate that the device list is obtained.');
+ console.info(`Promise returned to indicate that the device list is obtained.`);
}).catch((err) => {
console.info(`GetDevices BusinessError: code: ${err.code}, message: ${err.message}`);
});
@@ -516,7 +517,7 @@ avSession.castAudio('all', audioDevices, function (err) {
if (err) {
console.info(`CastAudio BusinessError: code: ${err.code}, message: ${err.message}`);
} else {
- console.info('CastAudio : SUCCESS ');
+ console.info(`CastAudio : SUCCESS `);
}
});
```
@@ -634,7 +635,7 @@ For details about the error codes, see [AVSession Management Error Codes](../err
```js
avSession.on('sessionServiceDie', () => {
- console.info('on sessionServiceDie : session is Died ');
+ console.info(`on sessionServiceDie : session is Died `);
});
```
@@ -691,7 +692,7 @@ Sends a system key event to the top session. This API uses a promise to return t
| Type | Description |
| -------------- | ----------------------------- |
-| Promise | Promise used to return the result. If the event is sent, no value is returned; otherwise, an error object is returned.|
+| Promise\ | Promise used to return the result. If the event is sent, no value is returned; otherwise, an error object is returned.|
**Error codes**
@@ -710,7 +711,7 @@ let keyItem = {code:0x49, pressedTime:2, deviceId:0};
let event = {id:1, deviceId:0, actionTime:1, screenId:1, windowId:1, action:2, key:keyItem, unicodeChar:0, keys:[keyItem], ctrlKey:false, altKey:false, shiftKey:false, logoKey:false, fnKey:false, capsLock:false, numLock:false, scrollLock:false};
avSession.sendSystemAVKeyEvent(event).then(() => {
- console.info('SendSystemAVKeyEvent Successfully');
+ console.info(`SendSystemAVKeyEvent Successfully`);
}).catch((err) => {
console.info(`SendSystemAVKeyEvent BusinessError: code: ${err.code}, message: ${err.message}`);
});
@@ -734,7 +735,7 @@ Sends a system key event to the top session. This API uses an asynchronous callb
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------- |
| event | [KeyEvent](js-apis-keyevent.md) | Yes | Key event. |
-| callback | AsyncCallback | Yes | Callback used to return the result. If the event is sent, **err** is **undefined**; otherwise, **err** is an error object.|
+| 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**
@@ -755,7 +756,7 @@ avSession.sendSystemAVKeyEvent(event, function (err) {
if (err) {
console.info(`SendSystemAVKeyEvent BusinessError: code: ${err.code}, message: ${err.message}`);
} else {
- console.info('SendSystemAVKeyEvent : SUCCESS ');
+ console.info(`SendSystemAVKeyEvent : SUCCESS `);
}
});
```
@@ -782,7 +783,7 @@ Sends a system control command to the top session. This API uses a promise to re
| Type | Description |
| -------------- | ----------------------------- |
-| Promise | Promise used to return the result. If the command is sent, no value is returned; otherwise, an error object is returned.|
+| Promise\ | Promise used to return the result. If the command is sent, no value is returned; otherwise, an error object is returned.|
**Error codes**
@@ -814,7 +815,7 @@ let avcommand = {command:cmd};
// let cmd : avSession.AVControlCommandType = 'toggleFavorite';
// let avcommand = {command:cmd, parameter:"false"};
avSession.sendSystemControlCommand(avcommand).then(() => {
- console.info('SendSystemControlCommand successfully');
+ console.info(`SendSystemControlCommand successfully`);
}).catch((err) => {
console.info(`SendSystemControlCommand BusinessError: code: ${err.code}, message: ${err.message}`);
});
@@ -837,7 +838,7 @@ Sends a system control command to the top session. This API uses an asynchronous
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------- | ---- | ------------------------------------- |
| command | [AVControlCommand](#avcontrolcommand) | Yes | Command to send. |
-| callback | AsyncCallback | Yes | Callback used to return the result. If the command is sent, **err** is **undefined**; otherwise, **err** is an error object.|
+| 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**
@@ -872,7 +873,7 @@ avSession.sendSystemControlCommand(avcommand, function (err) {
if (err) {
console.info(`SendSystemControlCommand BusinessError: code: ${err.code}, message: ${err.message}`);
} else {
- console.info('sendSystemControlCommand successfully');
+ console.info(`sendSystemControlCommand successfully`);
}
});
```
@@ -918,7 +919,7 @@ Sets session metadata. This API uses a promise to return the result.
| Type | Description |
| -------------- | ----------------------------- |
-| Promise | Promise used to return the result. If the setting is successful, no value is returned; otherwise, an error object is returned.|
+| Promise\ | Promise used to return the result. If the setting is successful, no value is returned; otherwise, an error object is returned.|
**Error codes**
@@ -949,7 +950,7 @@ let metadata = {
nextAssetId: "121279",
};
session.setAVMetadata(metadata).then(() => {
- console.info('SetAVMetadata successfully');
+ console.info(`SetAVMetadata successfully`);
}).catch((err) => {
console.info(`SetAVMetadata BusinessError: code: ${err.code}, message: ${err.message}`);
});
@@ -970,7 +971,7 @@ Sets session metadata. This API uses an asynchronous callback to return the resu
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ------------------------------------- |
| data | [AVMetadata](#avmetadata) | Yes | Session metadata. |
-| callback | AsyncCallback | Yes | Callback used to return the result. If the setting is successful, **err** is **undefined**; otherwise, **err** is an error object.|
+| 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**
@@ -1004,7 +1005,7 @@ session.setAVMetadata(metadata, function (err) {
if (err) {
console.info(`SetAVMetadata BusinessError: code: ${err.code}, message: ${err.message}`);
} else {
- console.info('SetAVMetadata successfully');
+ console.info(`SetAVMetadata successfully`);
}
});
```
@@ -1029,10 +1030,9 @@ Sets information related to the session playback state. This API uses a promise
| Type | Description |
| -------------- | ----------------------------- |
-| Promise | Promise used to return the result. If the setting is successful, no value is returned; otherwise, an error object is returned.|
+| 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|
@@ -1052,7 +1052,7 @@ let playbackState = {
isFavorite:true,
};
session.setAVPlaybackState(playbackState).then(() => {
- console.info('SetAVPlaybackState successfully');
+ console.info(`SetAVPlaybackState successfully`);
}).catch((err) => {
console.info(`SetAVPlaybackState BusinessError: code: ${err.code}, message: ${err.message}`);
});
@@ -1073,7 +1073,7 @@ Sets information related to the session playback state. This API uses an asynchr
| Name | Type | Mandatory| Description |
| -------- | ----------------------------------- | ---- | ---------------------------------------------- |
| data | [AVPlaybackState](#avplaybackstate) | Yes | Information related to the session playback state.|
-| callback | AsyncCallback | Yes | Callback used to return the result. If the setting is successful, **err** is **undefined**; otherwise, **err** is an error object. |
+| 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**
@@ -1099,14 +1099,14 @@ session.setAVPlaybackState(PlaybackState, function (err) {
if (err) {
console.info(`SetAVPlaybackState BusinessError: code: ${err.code}, message: ${err.message}`);
} else {
- console.info('SetAVPlaybackState successfully');
+ console.info(`SetAVPlaybackState successfully`);
}
});
```
### setAVQueueItems10+
-setAVQueueItems(items: Array\): Promise
+setAVQueueItems(items: Array\): Promise\
Sets a playlist. This API uses a promise to return the result.
@@ -1124,7 +1124,7 @@ Sets a playlist. This API uses a promise to return the result.
| Type | Description |
| -------------- | ----------------------------- |
-| Promise | Promise used to return the result. If the setting is successful, no value is returned; otherwise, an error object is returned.|
+| Promise\ | Promise used to return the result. If the setting is successful, no value is returned; otherwise, an error object is returned.|
**Error codes**
@@ -1138,12 +1138,14 @@ For details about the error codes, see [AVSession Management Error Codes](../err
**Example**
```js
+let imageSource : imageImageSource = image.createImageSource(value.buffer);
+let imagePixel : image.PixelMap = await imageSource.createPixelMap({desiredSize:{width: 150, height: 150}});
let queueItemDescription_1 = {
mediaId: '001',
title: 'music_name',
subtitle: 'music_sub_name',
description: 'music_description',
- icon: PIXELMAP_OBJECT,
+ icon : imagePixel,
iconUri: 'http://www.icon.uri.com',
extras: {'extras':'any'}
};
@@ -1157,7 +1159,7 @@ let queueItemDescription_2 = {
subtitle: 'music_sub_name',
description: 'music_description',
icon: PIXELMAP_OBJECT,
- iconUri: 'http://www.icon.uri.com',
+ iconUri: 'http://www.xxx.com',
extras: {'extras':'any'}
};
let queueItem_2 = {
@@ -1166,7 +1168,7 @@ let queueItem_2 = {
};
let queueItemsArray = [queueItem_1, queueItem_2];
session.setAVQueueItems(queueItemsArray).then(() => {
- console.info('SetAVQueueItems successfully');
+ console.info(`SetAVQueueItems successfully`);
}).catch((err) => {
console.info(`SetAVQueueItems BusinessError: code: ${err.code}, message: ${err.message}`);
});
@@ -1174,7 +1176,7 @@ session.setAVQueueItems(queueItemsArray).then(() => {
### setAVQueueItems10+
-setAVQueueItems(items: Array\, callback: AsyncCallback): void
+setAVQueueItems(items: Array\, callback: AsyncCallback\): void
Sets a playlist. This API uses an asynchronous callback to return the result.
@@ -1187,7 +1189,7 @@ Sets a playlist. This API uses an asynchronous callback to return the result.
| 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.|
+| 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**
@@ -1201,12 +1203,14 @@ For details about the error codes, see [AVSession Management Error Codes](../err
**Example**
```js
+let imageSource : imageImageSource = image.createImageSource(value.buffer);
+let imagePixel : image.PixelMap = await imageSource.createPixelMap({desiredSize:{width: 150, height: 150}});
let queueItemDescription_1 = {
mediaId: '001',
title: 'music_name',
subtitle: 'music_sub_name',
description: 'music_description',
- icon: PIXELMAP_OBJECT,
+ icon: imagePixel,
iconUri: 'http://www.icon.uri.com',
extras: {'extras':'any'}
};
@@ -1232,7 +1236,7 @@ session.setAVQueueItems(queueItemsArray, function (err) {
if (err) {
console.info(`SetAVQueueItems BusinessError: code: ${err.code}, message: ${err.message}`);
} else {
- console.info('SetAVQueueItems successfully');
+ console.info(`SetAVQueueItems successfully`);
}
});
```
@@ -1257,7 +1261,7 @@ Sets a name for the playlist. This API uses a promise to return the result.
| Type | Description |
| -------------- | ----------------------------- |
-| Promise | Promise used to return the result. If the setting is successful, no value is returned; otherwise, an error object is returned.|
+| Promise\ | Promise used to return the result. If the setting is successful, no value is returned; otherwise, an error object is returned.|
**Error codes**
@@ -1273,7 +1277,7 @@ For details about the error codes, see [AVSession Management Error Codes](../err
```js
let queueTitle = 'QUEUE_TITLE';
session.setAVQueueTitle(queueTitle).then(() => {
- console.info('SetAVQueueTitle successfully');
+ console.info(`SetAVQueueTitle successfully`);
}).catch((err) => {
console.info(`SetAVQueueTitle BusinessError: code: ${err.code}, message: ${err.message}`);
});
@@ -1281,7 +1285,7 @@ session.setAVQueueTitle(queueTitle).then(() => {
### setAVQueueTitle10+
-setAVQueueTitle(title: string, callback: AsyncCallback\): void
+setAVQueueTitle(title: string, callback: AsyncCallback\): void
Sets a name for the playlist. This API uses an asynchronous callback to return the result.
@@ -1294,7 +1298,7 @@ Sets a name for the playlist. This API uses an asynchronous callback to return t
| 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.|
+| 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**
@@ -1313,7 +1317,7 @@ session.setAVQueueTitle(queueTitle, function (err) {
if (err) {
console.info(`SetAVQueueTitle BusinessError: code: ${err.code}, message: ${err.message}`);
} else {
- console.info('SetAVQueueTitle successfully');
+ console.info(`SetAVQueueTitle successfully`);
}
});
```
@@ -1338,7 +1342,7 @@ Sets a launcher ability. This API uses a promise to return the result.
| Type | Description |
| -------------- | ----------------------------- |
-| Promise | Promise used to return the result. If the setting is successful, no value is returned; otherwise, an error object is returned.|
+| Promise\ | Promise used to return the result. If the setting is successful, no value is returned; otherwise, an error object is returned.|
**Error codes**
@@ -1384,7 +1388,7 @@ let wantAgentInfo = {
wantAgent.getWantAgent(wantAgentInfo).then((agent) => {
session.setLaunchAbility(agent).then(() => {
- console.info('SetLaunchAbility successfully');
+ console.info(`SetLaunchAbility successfully`);
}).catch((err) => {
console.info(`SetLaunchAbility BusinessError: code: ${err.code}, message: ${err.message}`);
});
@@ -1406,7 +1410,7 @@ Sets a launcher ability. This API uses an asynchronous callback to return the re
| Name | Type | Mandatory| Description |
| -------- | --------------------------------------------- | ---- | ------------------------------------------------------------ |
| ability | [WantAgent](js-apis-app-ability-wantAgent.md) | Yes | Application attributes, such as the bundle name, ability name, and deviceID. |
-| callback | AsyncCallback | Yes | Callback used to return the result. If the setting is successful, **err** is **undefined**; otherwise, **err** is an error object.|
+| 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**
@@ -1455,7 +1459,7 @@ wantAgent.getWantAgent(wantAgentInfo).then((agent) => {
if (err) {
console.info(`SetLaunchAbility BusinessError: code: ${err.code}, message: ${err.message}`);
} else {
- console.info('SetLaunchAbility successfully');
+ console.info(`SetLaunchAbility successfully`);
}
});
});
@@ -1465,7 +1469,7 @@ wantAgent.getWantAgent(wantAgentInfo).then((agent) => {
dispatchSessionEvent(event: string, args: {[key: string]: Object}): Promise\
-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.
+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. It is called by the provider.
**System capability**: SystemCapability.Multimedia.AVSession.Core
@@ -1478,11 +1482,15 @@ Dispatches a custom event in the session, including the event name and event con
| event | string | Yes | Name of the session event.|
| args | {[key: string]: any} | Yes | Event content in key-value pair format.|
+> **NOTE**
+>
+> The **args** parameter supports the following data types: string, number, Boolean, object, array, and file descriptor. For details, see [@ohos.app.ability.Want(Want)](./js-apis-app-ability-want.md).
+
**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.|
+| Promise\ | Promise used to return the result. If the setting is successful, no value is returned; otherwise, an error object is returned.|
**Error codes**
@@ -1507,9 +1515,9 @@ await session.dispatchSessionEvent(eventName, args).catch((err) => {
### dispatchSessionEvent10+
-dispatchSessionEvent(event: string, args: {[key: string]: Object}, callback: AsyncCallback): void
+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.
+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. It is called by the provider.
**System capability**: SystemCapability.Multimedia.AVSession.Core
@@ -1521,7 +1529,11 @@ Dispatches a custom event in the session, including the event name and event con
| ------- | --------------------------------------------- | ---- | ----------------------------------------------------------- |
| 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.|
+| callback | AsyncCallback\ | Yes | Callback used to return the result. If the setting is successful, **err** is **undefined**; otherwise, **err** is an error object.|
+
+> **NOTE**
+>
+> The **args** parameter supports the following data types: string, number, Boolean, object, array, and file descriptor. For details, see [@ohos.app.ability.Want(Want)](./js-apis-app-ability-want.md).
**Error codes**
@@ -1546,6 +1558,93 @@ await session.dispatchSessionEvent(eventName, args, (err) => {
})
```
+### setExtras10+
+
+setExtras(extras: {[key: string]: Object}): Promise\
+
+Sets a custom media packet in the form of key-value pairs. This API uses a promise to return the result. It is called by the provider.
+
+**System capability**: SystemCapability.Multimedia.AVSession.Core
+
+**System API**: This is a system API.
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ------- | --------------------------------------------- | ---- | ----------------------------------------------------------- |
+| extras | {[key: string]: Object} | Yes | Key-value pairs of the custom media packet.|
+
+> **NOTE**
+>
+> The **extras** parameter supports the following data types: string, number, Boolean, object, array, and file descriptor. For details, see [@ohos.app.ability.Want(Want)](./js-apis-app-ability-want.md).
+
+**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 extras = {
+ extras : "This is custom media packet"
+}
+await session.setExtras(extras).catch((err) => {
+ console.info(`setExtras BusinessError: code: ${err.code}, message: ${err.message}`);
+})
+```
+
+### setExtras10+
+
+setExtras(extras: {[key: string]: Object}, callback: AsyncCallback\): void
+
+Sets a custom media packet in the form of key-value pairs. This API uses an asynchronous callback to return the result. It is called by the provider.
+
+**System capability**: SystemCapability.Multimedia.AVSession.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ------- | --------------------------------------------- | ---- | ----------------------------------------------------------- |
+| extras | {[key: string]: any} | Yes | Key-value pairs of the custom media packet.|
+| callback | AsyncCallback\ | Yes | Callback used to return the result. If the setting is successful, **err** is **undefined**; otherwise, **err** is an error object.|
+
+> **NOTE**
+>
+> The **extras** parameter supports the following data types: string, number, Boolean, object, array, and file descriptor. For details, see [@ohos.app.ability.Want(Want)](./js-apis-app-ability-want.md).
+
+**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 extras = {
+ extras : "This is custom media packet"
+}
+await session.setExtras(extras, (err) => {
+ if(err) {
+ console.info(`setExtras BusinessError: code: ${err.code}, message: ${err.message}`);
+ }
+})
+```
+
### getController
getController(): Promise\
@@ -1708,7 +1807,7 @@ Activates this session. A session can be used only after being activated. This A
| Type | Description |
| -------------- | ----------------------------- |
-| Promise | Promise used to return the result. If the session is activated, no value is returned; otherwise, an error object is returned.|
+| Promise\ | Promise used to return the result. If the session is activated, no value is returned; otherwise, an error object is returned.|
**Error codes**
@@ -1723,7 +1822,7 @@ For details about the error codes, see [AVSession Management Error Codes](../err
```js
session.activate().then(() => {
- console.info('Activate : SUCCESS ');
+ console.info(`Activate : SUCCESS `);
}).catch((err) => {
console.info(`Activate BusinessError: code: ${err.code}, message: ${err.message}`);
});
@@ -1743,7 +1842,7 @@ Activates this session. A session can be used only after being activated. This A
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ---------- |
-| callback | AsyncCallback | Yes | Callback used to return the result. If the session is activated, **err** is **undefined**; otherwise, **err** is an error object.|
+| 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**
@@ -1761,7 +1860,7 @@ session.activate(function (err) {
if (err) {
console.info(`Activate BusinessError: code: ${err.code}, message: ${err.message}`);
} else {
- console.info('Activate : SUCCESS ');
+ console.info(`Activate : SUCCESS `);
}
});
```
@@ -1780,7 +1879,7 @@ Deactivates this session. You can use [activate](#activate) to activate the sess
| Type | Description |
| -------------- | ----------------------------- |
-| Promise | Promise used to return the result. If the session is deactivated, no value is returned; otherwise, an error object is returned.|
+| Promise\ | Promise used to return the result. If the session is deactivated, no value is returned; otherwise, an error object is returned.|
**Error codes**
@@ -1795,7 +1894,7 @@ For details about the error codes, see [AVSession Management Error Codes](../err
```js
session.deactivate().then(() => {
- console.info('Deactivate : SUCCESS ');
+ console.info(`Deactivate : SUCCESS `);
}).catch((err) => {
console.info(`Deactivate BusinessError: code: ${err.code}, message: ${err.message}`);
});
@@ -1817,7 +1916,7 @@ Deactivates this session. You can use [activate](#activate) to activate the sess
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ---------- |
-| callback | AsyncCallback | Yes | Callback used to return the result. If the session is deactivated, **err** is **undefined**; otherwise, **err** is an error object.|
+| 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**
@@ -1835,7 +1934,7 @@ session.deactivate(function (err) {
if (err) {
console.info(`Deactivate BusinessError: code: ${err.code}, message: ${err.message}`);
} else {
- console.info('Deactivate : SUCCESS ');
+ console.info(`Deactivate : SUCCESS `);
}
});
```
@@ -1854,7 +1953,7 @@ Destroys this session. This API uses a promise to return the result.
| Type | Description |
| -------------- | ----------------------------- |
-| Promise | Promise used to return the result. If the session is destroyed, no value is returned; otherwise, an error object is returned.|
+| Promise\ | Promise used to return the result. If the session is destroyed, no value is returned; otherwise, an error object is returned.|
**Error codes**
@@ -1869,7 +1968,7 @@ For details about the error codes, see [AVSession Management Error Codes](../err
```js
session.destroy().then(() => {
- console.info('Destroy : SUCCESS ');
+ console.info(`Destroy : SUCCESS `);
}).catch((err) => {
console.info(`Destroy BusinessError: code: ${err.code}, message: ${err.message}`);
});
@@ -1889,7 +1988,7 @@ Destroys this session. This API uses an asynchronous callback to return the resu
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ---------- |
-| callback | AsyncCallback | Yes | Callback used to return the result. If the session is destroyed, **err** is **undefined**; otherwise, **err** is an error object.|
+| 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**
@@ -1907,7 +2006,7 @@ session.destroy(function (err) {
if (err) {
console.info(`Destroy BusinessError: code: ${err.code}, message: ${err.message}`);
} else {
- console.info('Destroy : SUCCESS ');
+ console.info(`Destroy : SUCCESS `);
}
});
```
@@ -1942,25 +2041,25 @@ For details about the error codes, see [AVSession Management Error Codes](../err
```js
session.on('play', () => {
- console.info('on play entry');
+ console.info(`on play entry`);
});
session.on('pause', () => {
- console.info('on pause entry');
+ console.info(`on pause entry`);
});
session.on('stop', () => {
- console.info('on stop entry');
+ console.info(`on stop entry`);
});
session.on('playNext', () => {
- console.info('on playNext entry');
+ console.info(`on playNext entry`);
});
session.on('playPrevious', () => {
- console.info('on playPrevious entry');
+ console.info(`on playPrevious entry`);
});
session.on('fastForward', () => {
- console.info('on fastForward entry');
+ console.info(`on fastForward entry`);
});
session.on('rewind', () => {
- console.info('on rewind entry');
+ console.info(`on rewind entry`);
});
```
@@ -2217,7 +2316,7 @@ Subscribes to custom control command changes.
| 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. |
+| 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. The parameters must be the same as those set in **sendCommand**. |
**Error codes**
@@ -2501,7 +2600,7 @@ session.off('outputDeviceChange');
### off('commonCommand')10+
-off(type: 'commonCommand', callback?: (commonCommand: string, args: {[key:string]: Object}) => void): void
+off(type: 'commonCommand', callback?: (command: string, args: {[key:string]: Object}) => void): void
Unsubscribes from custom control command changes.
@@ -2514,7 +2613,7 @@ Unsubscribes from custom control command changes.
| 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. |
+| callback | (command: string, args: {[key:string]: Object}) => void | No | Callback used for unsubscription. The **command** 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**
@@ -2540,6 +2639,8 @@ An AV session controller is created by calling [avSession.createController](#avs
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
| Name | Type | Readable| Writable| Description |
| :-------- | :----- | :--- | :--- | :-------------------------------------- |
@@ -2792,7 +2893,7 @@ Sends the ID of an item in the playlist to the session for processing. The sessi
| 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.|
+| 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**
@@ -2808,7 +2909,7 @@ For details about the error codes, see [AVSession Management Error Codes](../err
```js
let queueItemId = 0;
controller.skipToQueueItem(queueItemId).then(() => {
- console.info('SkipToQueueItem successfully');
+ console.info(`SkipToQueueItem successfully`);
}).catch((err) => {
console.info(`SkipToQueueItem BusinessError: code: ${err.code}, message: ${err.message}`);
});
@@ -2829,7 +2930,7 @@ Sends the ID of an item in the playlist to the session for processing. The sessi
| 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.|
+| 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**
@@ -2848,7 +2949,7 @@ controller.skipToQueueItem(queueItemId, function (err) {
if (err) {
console.info(`SkipToQueueItem BusinessError: code: ${err.code}, message: ${err.message}`);
} else {
- console.info('SkipToQueueItem successfully');
+ console.info(`SkipToQueueItem successfully`);
}
});
```
@@ -2996,6 +3097,92 @@ controller.getOutputDevice(function (err, deviceInfo) {
});
```
+### getExtras10+
+
+getExtras(): Promise\<{[key: string]: Object}>
+
+Obtains the custom media packet set by the provider. 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<{[key: string]: Object}\> | Promise used to return the custom media packet. The content of the packet is the same as that set in **setExtras**.|
+
+**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
+let extras = await controller.getExtras().catch((err) => {
+ console.info(`getExtras BusinessError: code: ${err.code}, message: ${err.message}`);
+});
+```
+
+### getExtras10+
+
+getExtras(callback: AsyncCallback\<{[key: string]: Object}>): void
+
+Obtains the custom media packet set by the provider. 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<{[key: string]: Object}\> | Yes | Callback used to return the custom media packet. The content of the packet is the same as that set in **setExtras**.|
+
+**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
+let metadata = {
+ assetId: "121278",
+ title: "lose yourself",
+ artist: "Eminem",
+ author: "ST",
+ album: "Slim shady",
+ writer: "ST",
+ composer: "ST",
+ duration: 2222,
+ mediaImage: "https://www.example.com/example.jpg",
+ subtitle: "8 Mile",
+ description: "Rap",
+ lyric: "https://www.example.com/example.lrc",
+ previousAssetId: "121277",
+ nextAssetId: "121279",
+};
+controller.getExtras(function (err, extras) {
+ if (err) {
+ console.info(`getExtras BusinessError: code: ${err.code}, message: ${err.message}`);
+ } else {
+ console.info(`getExtras : SUCCESS : assetId : ${metadata.assetId}`);
+ }
+});
+```
+
### sendAVKeyEvent
sendAVKeyEvent(event: KeyEvent): Promise\
@@ -3028,7 +3215,7 @@ For details about the error codes, see [AVSession Management Error Codes](../err
| Type | Description |
| -------------- | ----------------------------- |
-| Promise | Promise used to return the result. If the event is sent, no value is returned; otherwise, an error object is returned.|
+| Promise\ | Promise used to return the result. If the event is sent, no value is returned; otherwise, an error object is returned.|
**Example**
@@ -3037,7 +3224,7 @@ let keyItem = {code:0x49, pressedTime:2, deviceId:0};
let event = {action:2, key:keyItem, keys:[keyItem]};
controller.sendAVKeyEvent(event).then(() => {
- console.info('SendAVKeyEvent Successfully');
+ console.info(`SendAVKeyEvent Successfully`);
}).catch((err) => {
console.info(`SendAVKeyEvent BusinessError: code: ${err.code}, message: ${err.message}`);
});
@@ -3058,7 +3245,7 @@ Sends a key event to the session corresponding to this controller. This API uses
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ---------- |
| event | [KeyEvent](js-apis-keyevent.md) | Yes | Key event.|
-| callback | AsyncCallback | Yes | Callback used to return the result. If the event is sent, **err** is **undefined**; otherwise, **err** is an error object.|
+| 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**
@@ -3082,7 +3269,7 @@ controller.sendAVKeyEvent(event, function (err) {
if (err) {
console.info(`SendAVKeyEvent BusinessError: code: ${err.code}, message: ${err.message}`);
} else {
- console.info('SendAVKeyEvent Successfully');
+ console.info(`SendAVKeyEvent Successfully`);
}
});
```
@@ -3284,7 +3471,7 @@ Destroys this controller. A controller can no longer be used after being destroy
| Type | Description |
| -------------- | ----------------------------- |
-| Promise | Promise used to return the result. If the controller is destroyed, no value is returned; otherwise, an error object is returned.|
+| Promise\ | Promise used to return the result. If the controller is destroyed, no value is returned; otherwise, an error object is returned.|
**Error codes**
@@ -3299,7 +3486,7 @@ For details about the error codes, see [AVSession Management Error Codes](../err
```js
controller.destroy().then(() => {
- console.info('Destroy : SUCCESS ');
+ console.info(`Destroy : SUCCESS `);
}).catch((err) => {
console.info(`Destroy BusinessError: code: ${err.code}, message: ${err.message}`);
});
@@ -3319,7 +3506,7 @@ Destroys this controller. A controller can no longer be used after being destroy
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ---------- |
-| callback | AsyncCallback | Yes | Callback used to return the result. If the controller is destroyed, **err** is **undefined**; otherwise, **err** is an error object.|
+| 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**
@@ -3337,7 +3524,7 @@ controller.destroy(function (err) {
if (err) {
console.info(`Destroy BusinessError: code: ${err.code}, message: ${err.message}`);
} else {
- console.info('Destroy : SUCCESS ');
+ console.info(`Destroy : SUCCESS `);
}
});
```
@@ -3422,6 +3609,10 @@ sendControlCommand(command: AVControlCommand): Promise\
Sends a control command to the session through the controller. This API uses a promise to return the result.
+> **NOTE**
+>
+> Before using **sendControlCommand**, the controller must ensure that the AVSession has registered with the corresponding listener. For details about how to register the listener, see [Registering AVSession Listeners](#onplaypausestopplaynextplaypreviousfastforwardrewind).
+
**System capability**: SystemCapability.Multimedia.AVSession.Core
**System API**: This is a system API.
@@ -3436,7 +3627,7 @@ Sends a control command to the session through the controller. This API uses a p
| Type | Description |
| -------------- | ----------------------------- |
-| Promise | Promise used to return the result. If the command is sent, no value is returned; otherwise, an error object is returned.|
+| Promise\ | Promise used to return the result. If the command is sent, no value is returned; otherwise, an error object is returned.|
**Error codes**
@@ -3466,7 +3657,7 @@ let avCommand = {command:'play'};
// let avCommand = {command:'setLoopMode', parameter:avSession.LoopMode.LOOP_MODE_SINGLE};
// let avCommand = {command:'toggleFavorite', parameter:"false"};
controller.sendControlCommand(avCommand).then(() => {
- console.info('SendControlCommand successfully');
+ console.info(`SendControlCommand successfully`);
}).catch((err) => {
console.info(`SendControlCommand BusinessError: code: ${err.code}, message: ${err.message}`);
});
@@ -3478,6 +3669,10 @@ sendControlCommand(command: AVControlCommand, callback: AsyncCallback\): v
Sends a control command to the session through the controller. This API uses an asynchronous callback to return the result.
+> **NOTE**
+>
+> Before using **sendControlCommand**, the controller must ensure that the AVSession has registered with the corresponding listener. For details about how to register the listener, see [Registering AVSession Listeners](#onplaypausestopplaynextplaypreviousfastforwardrewind).
+
**System capability**: SystemCapability.Multimedia.AVSession.Core
**System API**: This is a system API.
@@ -3487,7 +3682,7 @@ Sends a control command to the session through the controller. This API uses an
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------- | ---- | ------------------------------ |
| command | [AVControlCommand](#avcontrolcommand) | Yes | Command to send.|
-| callback | AsyncCallback | Yes | Callback used to return the result. If the command is sent, **err** is **undefined**; otherwise, **err** is an error object. |
+| 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**
@@ -3520,7 +3715,7 @@ controller.sendControlCommand(avCommand, function (err) {
if (err) {
console.info(`SendControlCommand BusinessError: code: ${err.code}, message: ${err.message}`);
} else {
- console.info('SendControlCommand successfully');
+ console.info(`SendControlCommand successfully`);
}
});
```
@@ -3533,6 +3728,8 @@ Sends a custom control command to the session through the controller. This API u
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**Parameters**
| Name | Type | Mandatory| Description |
@@ -3540,11 +3737,15 @@ Sends a custom control command to the session through the controller. This API u
| 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.|
+> **NOTE**
+>
+> The **args** parameter supports the following data types: string, number, Boolean, object, array, and file descriptor. For details, see [@ohos.app.ability.Want(Want)](./js-apis-app-ability-want.md).
+
**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.|
+| Promise\ | Promise used to return the result. If the command is sent, no value is returned; otherwise, an error object is returned.|
**Error codes**
@@ -3579,16 +3780,21 @@ Sends a custom control command to the session through the controller. This API u
**System capability**: SystemCapability.Multimedia.AVSession.Core
+**System API**: This is a system API.
+
**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. |
+| 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**
+> **NOTE**
+>
+> The **args** parameter supports the following data types: string, number, Boolean, object, array, and file descriptor. For details, see [@ohos.app.ability.Want(Want)](./js-apis-app-ability-want.md).
+**Error codes**
For details about the error codes, see [AVSession Management Error Codes](../errorcodes/errorcode-avsession.md).
| ID| Error Message|
@@ -3698,7 +3904,7 @@ controller.on('playbackStateChange', playbackFilter, (playbackState) => {
on(type: 'sessionEvent', callback: (sessionEvent: string, args: {[key:string]: Object}) => void): void
-Subscribes to session event changes.
+Subscribes to session event changes. This API is called by the controller.
**System capability**: SystemCapability.Multimedia.AVSession.Core
@@ -3732,7 +3938,7 @@ controller.on('sessionEvent', (sessionEvent, args) => {
on(type: 'queueItemsChange', callback: (items: Array<[AVQueueItem](#avqueueitem10)\>) => void): void
-Subscribes to playlist item changes.
+Subscribes to playlist item changes. This API is called by the controller.
**System capability**: SystemCapability.Multimedia.AVSession.Core
@@ -3766,7 +3972,7 @@ controller.on('queueItemsChange', (items) => {
on(type: 'queueTitleChange', callback: (title: string) => void): void
-Subscribes to playlist name changes.
+Subscribes to playlist name changes. This API is called by the controller.
**System capability**: SystemCapability.Multimedia.AVSession.Core
@@ -3796,6 +4002,41 @@ controller.on('queueTitleChange', (title) => {
});
```
+### on('extrasChange')10+
+
+on(type: 'extrasChange', callback: (extras: {[key:string]: Object}) => void): void
+
+Subscribes to custom media packet changes. This API is called by the controller.
+
+**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 **'extrasChange'** is reported when the provider sets a custom media packet.|
+| callback | (extras: {[key:string]: object}) => void | Yes | Callback used for subscription. The **extras** parameter in the callback indicates the custom media packet set by the provider. This packet is the same as that set in **dispatchSessionEvent**. |
+
+**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. |
+| 401 | Parameter check failed |
+
+**Example**
+
+```js
+controller.on('extrasChange', (extras) => {
+ console.info(`Caught extrasChange event,the new extra is: ${JSON.stringify(extras)}`);
+});
+```
+
### on('sessionDestroy')
on(type: 'sessionDestroy', callback: () => void)
@@ -3826,7 +4067,7 @@ For details about the error codes, see [AVSession Management Error Codes](../err
```js
controller.on('sessionDestroy', () => {
- console.info('on sessionDestroy : SUCCESS ');
+ console.info(`on sessionDestroy : SUCCESS `);
});
```
@@ -3937,7 +4178,7 @@ controller.on('outputDeviceChange', (device) => {
off(type: 'metadataChange', callback?: (data: AVMetadata) => void)
-Unsubscribes from metadata changes.
+Unsubscribes from metadata changes. This API is called by the controller.
**System capability**: SystemCapability.Multimedia.AVSession.Core
@@ -3968,7 +4209,7 @@ controller.off('metadataChange');
off(type: 'playbackStateChange', callback?: (state: AVPlaybackState) => void)
-Unsubscribes from playback state changes.
+Unsubscribes from playback state changes. This API is called by the controller.
**System capability**: SystemCapability.Multimedia.AVSession.Core
@@ -3999,7 +4240,7 @@ controller.off('playbackStateChange');
off(type: 'sessionEvent', callback?: (sessionEvent: string, args: {[key:string]: Obejct}) => void): void
-Unsubscribes from session event changes.
+Unsubscribes from session event changes. This API is called by the controller.
**System capability**: SystemCapability.Multimedia.AVSession.Core
@@ -4030,7 +4271,7 @@ controller.off('sessionEvent');
off(type: 'queueItemsChange', callback?: (items: Array<[AVQueueItem](#avqueueitem10)\>) => void): void
-Unsubscribes from playback item changes.
+Unsubscribes from playback item changes. This API is called by the controller.
**System capability**: SystemCapability.Multimedia.AVSession.Core
@@ -4061,7 +4302,7 @@ controller.off('queueItemsChange');
off(type: 'queueTitleChange', callback?: (title: string) => void): void
-Unsubscribes from playlist name changes.
+Unsubscribes from playlist name changes. This API is called by the controller.
**System capability**: SystemCapability.Multimedia.AVSession.Core
@@ -4088,11 +4329,44 @@ For details about the error codes, see [AVSession Management Error Codes](../err
controller.off('queueTitleChange');
```
+### off('extrasChange')10+
+
+off(type: 'extrasChange', callback?: (extras: {[key:string]: Object}) => void): void
+
+Unsubscribes from custom media packet changes. This API is called by the controller.
+
+**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 **'extrasChange'**. |
+| callback | ({[key:string]: Object}) => void | No | Callback used for unsubscription.
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. |
+| 6600103 | The session controller does not exist. |
+| 401 | Parameter check failed |
+
+**Example**
+
+```js
+controller.off('extrasChange');
+```
+
### off('sessionDestroy')
off(type: 'sessionDestroy', callback?: () => void)
-Unsubscribes from the session destruction event.
+Unsubscribes from the session destruction event. This API is called by the controller.
**System capability**: SystemCapability.Multimedia.AVSession.Core
@@ -4123,7 +4397,7 @@ controller.off('sessionDestroy');
off(type: 'activeStateChange', callback?: (isActive: boolean) => void)
-Unsubscribes from session activation state changes.
+Unsubscribes from session activation state changes. This API is called by the controller.
**System capability**: SystemCapability.Multimedia.AVSession.Core
@@ -4154,7 +4428,7 @@ controller.off('activeStateChange');
off(type: 'validCommandChange', callback?: (commands: Array\) => void)
-Unsubscribes from valid command changes.
+Unsubscribes from valid command changes. This API is called by the controller.
**System capability**: SystemCapability.Multimedia.AVSession.Core
@@ -4185,7 +4459,7 @@ controller.off('validCommandChange');
off(type: 'outputDeviceChange', callback?: (device: OutputDeviceInfo) => void): void
-Unsubscribes from output device changes.
+Unsubscribes from output device changes. This API is called by the controller.
**System capability**: SystemCapability.Multimedia.AVSession.Core
@@ -4363,6 +4637,8 @@ Describes the information related to the media playback state.
| bufferedTime | number | No | Buffered time.|
| loopMode | [LoopMode](#loopmode) | No | Loop mode.|
| isFavorite | boolean | No | Whether the media asset is favorited.|
+| activeItemId10+ | number | No | ID of the item that is being played.|
+| extras10+ | {[key: string]: Object} | No | Custom media data.|
## PlaybackPosition
@@ -4442,3 +4718,5 @@ Enumerates the error codes used in the media session.
| ERR_CODE_COMMAND_INVALID | 6600105 | Invalid session command. |
| ERR_CODE_SESSION_INACTIVE | 6600106 | The session is not activated. |
| ERR_CODE_MESSAGE_OVERLOAD | 6600107 | Too many commands or events. |
+
+
\ No newline at end of file
diff --git a/en/application-dev/reference/apis/js-apis-batteryStatistics.md b/en/application-dev/reference/apis/js-apis-batteryStatistics.md
index 721a432caaf67116a6df882c0e8995e76b893a7e..8314dd92cfc15cdbc9ad8e1e232b3fab2b00380b 100644
--- a/en/application-dev/reference/apis/js-apis-batteryStatistics.md
+++ b/en/application-dev/reference/apis/js-apis-batteryStatistics.md
@@ -36,7 +36,7 @@ For details about the error codes, see [Thermal Manager Error Codes](../errorcod
| Code | Error Message |
|---------|---------|
-| 4600101 | Operation failed. Cannot connect to service.|
+| 4600101 | If connecting to the service failed. |
**Example**
@@ -72,7 +72,7 @@ For details about the error codes, see [Thermal Manager Error Codes](../errorcod
| Code | Error Message |
|---------|---------|
-| 4600101 | Operation failed. Cannot connect to service.|
+| 4600101 | If connecting to the service failed. |
**Example**
@@ -114,7 +114,7 @@ For details about the error codes, see [Thermal Manager Error Codes](../errorcod
| Code | Error Message |
|---------|---------|
-| 4600101 | Operation failed. Cannot connect to service.|
+| 4600101 | If connecting to the service failed. |
**Example**
@@ -155,7 +155,7 @@ For details about the error codes, see [Thermal Manager Error Codes](../errorcod
| Code | Error Message |
|---------|---------|
-| 4600101 | Operation failed. Cannot connect to service.|
+| 4600101 | If connecting to the service failed. |
**Example**
@@ -196,13 +196,13 @@ For details about the error codes, see [Thermal Manager Error Codes](../errorcod
| Code | Error Message |
|---------|---------|
-| 4600101 | Operation failed. Cannot connect to service.|
+| 4600101 | If connecting to the service failed. |
**Example**
```js
try {
- var value = batteryStats.getHardwareUnitPowerValue(ConsumptionType.CONSUMPTION_TYPE_SCREEN);
+ var value = batteryStats.getHardwareUnitPowerValue(batteryStats.ConsumptionType.CONSUMPTION_TYPE_SCREEN);
console.info('battery statistics value of hardware is: ' + value);
} catch(err) {
console.error('get battery statistics percent of hardware failed, err: ' + err);
@@ -237,13 +237,13 @@ For details about the error codes, see [Thermal Manager Error Codes](../errorcod
| Code | Error Message |
|---------|---------|
-| 4600101 | Operation failed. Cannot connect to service.|
+| 4600101 | If connecting to the service failed. |
**Example**
```js
try {
- var percent = batteryStats.getHardwareUnitPowerPercent(ConsumptionType.CONSUMPTION_TYPE_SCREEN);
+ var percent = batteryStats.getHardwareUnitPowerPercent(batteryStats.ConsumptionType.CONSUMPTION_TYPE_SCREEN);
console.info('battery statistics percent of hardware is: ' + percent);
} catch(err) {
console.error('get battery statistics percent of hardware failed, err: ' + err);
diff --git a/en/application-dev/reference/apis/js-apis-brightness.md b/en/application-dev/reference/apis/js-apis-brightness.md
index bd003733a485c1601ac251697461e78b863976a8..e6af63700029738f388f41edb5d980b51a9f9614 100644
--- a/en/application-dev/reference/apis/js-apis-brightness.md
+++ b/en/application-dev/reference/apis/js-apis-brightness.md
@@ -22,7 +22,7 @@ Sets the screen brightness.
**System API**: This is a system API.
-**System capability**: SystemCapability.PowerManager.DisplayPowerManager
+**System capability:** SystemCapability.PowerManager.DisplayPowerManager
**Parameters**
@@ -34,9 +34,9 @@ Sets the screen brightness.
For details about the error codes, see [Screen Brightness Error Codes](../errorcodes/errorcode-brightness.md).
-| Code | Error Message |
+| ID | Error Message |
|---------|---------|
-| 4700101 | Operation failed. Cannot connect to service.|
+| 4700101 | If connecting to the service failed. |
**Example**
diff --git a/en/application-dev/reference/apis/js-apis-buffer.md b/en/application-dev/reference/apis/js-apis-buffer.md
index 5a014e7cfe5618c7e31741b43d32ce743d86a0b2..737c9f1dbf05e30e2f84e185b89e804642b0c39f 100644
--- a/en/application-dev/reference/apis/js-apis-buffer.md
+++ b/en/application-dev/reference/apis/js-apis-buffer.md
@@ -726,7 +726,7 @@ Checks whether this **Buffer** instance contains the specified value.
| -------- | -------- | -------- | -------- |
| value | string \| number \| Buffer \| Uint8Array | Yes| Value to match.|
| byteOffset | number | No| Number of bytes to skip before starting to check data. If the offset is a negative number, data is checked from the end of the **Buffer** instance. The default value is **0**.|
-| encoding | [BufferEncoding](#bufferencoding) | No| Encoding format used if **value** is a string. The default value is **utf-8**.|
+| encoding | [BufferEncoding](#bufferencoding) | No| Encoding format (valid only when **value** is a string). The default value is **utf-8**.|
**Return value**
@@ -758,7 +758,7 @@ Obtains the index of the first occurrence of the specified value in this **Buffe
| -------- | -------- | -------- | -------- |
| value | string \| number \| Buffer \| Uint8Array | Yes| Value to match.|
| byteOffset | number | No| Number of bytes to skip before starting to check data. If the offset is a negative number, data is checked from the end of the **Buffer** instance. The default value is **0**.|
-| encoding | [BufferEncoding](#bufferencoding) | No| Encoding format used if **value** is a string. The default value is **utf-8**.|
+| encoding | [BufferEncoding](#bufferencoding) | No| Encoding format (valid only when **value** is a string). The default value is **utf-8**.|
**Return value**
@@ -815,7 +815,7 @@ Obtains the index of the last occurrence of the specified value in this **Buffer
| -------- | -------- | -------- | -------- |
| value | string \| number \| Buffer \| Uint8Array | Yes| Value to match.|
| byteOffset | number | No| Number of bytes to skip before starting to check data. If the offset is a negative number, data is checked from the end of the **Buffer** instance. The default value is **0**.|
-| encoding | [BufferEncoding](#bufferencoding) | No| Encoding format used if **value** is a string. The default value is **utf-8**.|
+| encoding | [BufferEncoding](#bufferencoding) | No| Encoding format (valid only when **value** is a string). The default value is **utf-8**.|
**Return value**
@@ -838,7 +838,7 @@ console.log(buf.lastIndexOf('buffer').toString()); // Print: 17
readBigInt64BE(offset?: number): bigint
-Reads a signed, big-endian 64-bit big integer from this **Buffer** instance at the specified offset.
+Reads a 64-bit, big-endian, signed big integer from this **Buffer** instance at the specified offset.
**System capability**: SystemCapability.Utils.Lang
@@ -872,14 +872,14 @@ let buf = buffer.from([0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x70,
console.log(buf.readBigInt64BE(0).toString());
let buf1 = buffer.allocUninitializedFromPool(8);
-let result = buf1.writeBigInt64BE(0x0102030405060708n, 0);
+let result = buf1.writeBigInt64BE(BigInt(0x0102030405060708), 0);
```
### readBigInt64LE
readBigInt64LE(offset?: number): bigint
-Reads a signed, little-endian 64-bit big integer from this **Buffer** instance at the specified offset.
+Reads a 64-bit, little-endian, signed big integer from this **Buffer** instance at the specified offset.
**System capability**: SystemCapability.Utils.Lang
@@ -913,14 +913,14 @@ let buf = buffer.from([0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x70,
console.log(buf.readBigInt64LE(0).toString());
let buf1 = buffer.allocUninitializedFromPool(8);
-let result = buf1.writeBigInt64BE(0x0102030405060708n, 0);
+let result = buf1.writeBigInt64BE(BigInt(0x0102030405060708), 0);
```
### readBigUInt64BE
readBigUInt64BE(offset?: number): bigint
-Reads an unsigned, big-endian 64-bit big integer from this **Buffer** instance at the specified offset.
+Reads a 64-bit, big-endian, unsigned big integer from this **Buffer** instance at the specified offset.
**System capability**: SystemCapability.Utils.Lang
@@ -954,14 +954,14 @@ let buf = buffer.from([0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x70,
console.log(buf.readBigUInt64BE(0).toString());
let buf1 = buffer.allocUninitializedFromPool(8);
-let result = buf1.writeBigUInt64BE(0xdecafafecacefaden, 0);
+let result = buf1.writeBigUInt64BE(BigInt(0xdecafafecacefade), 0);
```
### readBigUInt64LE
readBigUInt64LE(offset?: number): bigint
-Reads an unsigned, little-endian 64-bit big integer from this **Buffer** instance at the specified offset.
+Reads a 64-bit, little-endian, unsigned big integer from this **Buffer** instance at the specified offset.
**System capability**: SystemCapability.Utils.Lang
@@ -995,14 +995,14 @@ let buf = buffer.from([0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x70,
console.log(buf.readBigUInt64LE(0).toString());
let buf1 = buffer.allocUninitializedFromPool(8);
-let result = buf1.writeBigUInt64BE(0xdecafafecacefaden, 0);
+let result = buf1.writeBigUInt64BE(BigInt(0xdecafafecacefade), 0);
```
### readDoubleBE
readDoubleBE(offset?: number): number
-Reads a 64-bit, big-endian floating-point number from this **Buffer** instance at the specified offset.
+Reads a 64-bit, big-endian, double-precision floating-point number from this **Buffer** instance at the specified offset.
**System capability**: SystemCapability.Utils.Lang
@@ -1042,7 +1042,7 @@ let result = buf1.writeDoubleBE(123.456, 0);
readDoubleLE(offset?: number): number
-Reads a 64-bit, little-endian floating-point number from this **Buffer** instance at the specified offset.
+Reads a 64-bit, little-endian, double-precision floating-point number from this **Buffer** instance at the specified offset.
**System capability**: SystemCapability.Utils.Lang
@@ -1082,7 +1082,7 @@ let result = buf1.writeDoubleLE(123.456, 0);
readFloatBE(offset?: number): number
-Reads a 32-bit, big-endian floating-point number from this **Buffer** instance at the specified offset.
+Reads a 32-bit, big-endian, single-precision floating-point number from this **Buffer** instance at the specified offset.
**System capability**: SystemCapability.Utils.Lang
@@ -1122,7 +1122,7 @@ let result = buf1.writeFloatBE(0xcabcbcbc, 0);
readFloatLE(offset?: number): number
-Reads a 32-bit, little-endian floating-point number from this **Buffer** instance at the specified offset.
+Reads a 32-bit, little-endian, single-precision floating-point number from this **Buffer** instance at the specified offset.
**System capability**: SystemCapability.Utils.Lang
@@ -1162,7 +1162,7 @@ let result = buf1.writeFloatLE(0xcabcbcbc, 0);
readInt8(offset?: number): number
-Reads a signed 8-bit integer from this **Buffer** instance at the specified offset.
+Reads a 8-bit signed integer from this **Buffer** instance at the specified offset.
**System capability**: SystemCapability.Utils.Lang
@@ -1203,7 +1203,7 @@ let result = buf1.writeInt8(0x12);
readInt16BE(offset?: number): number
-Reads a signed, big-endian 16-bit integer from this **Buffer** instance at the specified offset.
+Reads a 16-bit, big-endian, signed integer from this **Buffer** instance at the specified offset.
**System capability**: SystemCapability.Utils.Lang
@@ -1243,7 +1243,7 @@ let result = buf1.writeInt16BE(0x1234, 0);
readInt16LE(offset?: number): number
-Reads a signed, little-endian 16-bit integer from this **Buffer** instance at the specified offset.
+Reads a 16-bit, little-endian, signed integer from this **Buffer** instance at the specified offset.
**System capability**: SystemCapability.Utils.Lang
@@ -1283,7 +1283,7 @@ let result = buf1.writeInt16BE(0x1234, 0);
readInt32BE(offset?: number): number
-Reads a signed, big-endian 32-bit integer from this **Buffer** instance at the specified offset.
+Reads a 32-bit, big-endian, signed integer from this **Buffer** instance at the specified offset.
**System capability**: SystemCapability.Utils.Lang
@@ -1323,7 +1323,7 @@ let result = buf1.writeInt32BE(0x12345678, 0);
readInt32LE(offset?: number): number
-Reads a signed, little-endian 32-bit integer from this **Buffer** instance at the specified offset.
+Reads a 32-bit, little-endian, signed integer from this **Buffer** instance at the specified offset.
**System capability**: SystemCapability.Utils.Lang
@@ -1449,7 +1449,7 @@ let result = buf1.writeIntLE(0x123456789011, 0, 6);
readUInt8(offset?: number): number
-Reads an unsigned 8-bit integer from this **Buffer** instance at the specified offset.
+Reads a 8-bit unsigned integer from this **Buffer** instance at the specified offset.
**System capability**: SystemCapability.Utils.Lang
@@ -1491,7 +1491,7 @@ let result = buf1.writeUInt8(0x42);
readUInt16BE(offset?: number): number
-Reads an unsigned, big-endian 16-bit integer from this **Buffer** instance at the specified offset.
+Reads a 16-bit, big-endian, unsigned integer from this **Buffer** instance at the specified offset.
**System capability**: SystemCapability.Utils.Lang
@@ -1533,7 +1533,7 @@ let result = buf1.writeUInt16BE(0x1234, 0);
readUInt16LE(offset?: number): number
-Reads an unsigned, little-endian 16-bit integer from this **Buffer** instance at the specified offset.
+Reads a 16-bit, little-endian, unsigned integer from this **Buffer** instance at the specified offset.
**System capability**: SystemCapability.Utils.Lang
@@ -1575,7 +1575,7 @@ let result = buf1.writeUInt16LE(0x1234, 0);
readUInt32BE(offset?: number): number
-Reads an unsigned, big-endian 32-bit integer from this **Buffer** instance at the specified offset.
+Reads a 32-bit, big-endian, unsigned integer from this **Buffer** instance at the specified offset.
**System capability**: SystemCapability.Utils.Lang
@@ -1616,7 +1616,7 @@ let result = buf1.writeUInt32BE(0x12345678, 0);
readUInt32LE(offset?: number): number
-Reads an unsigned, little-endian 32-bit integer from this **Buffer** instance at the specified offset.
+Reads a 32-bit, little-endian, unsigned integer from this **Buffer** instance at the specified offset.
**System capability**: SystemCapability.Utils.Lang
@@ -2013,7 +2013,7 @@ let length = buffer1.write('abcd', 8);
writeBigInt64BE(value: bigint, offset?: number): number
-Writes a signed, big-endian 64-bit Big integer to this **Buffer** instance at the specified offset.
+Writes a 64-bit, big-endian, signed big integer to this **Buffer** instance at the specified offset.
**System capability**: SystemCapability.Utils.Lang
@@ -2045,14 +2045,14 @@ For details about the error codes, see [Utils Error Codes](../errorcodes/errorco
import buffer from '@ohos.buffer';
let buf = buffer.allocUninitializedFromPool(8);
-let result = buf.writeBigInt64BE(0x0102030405060708n, 0);
+let result = buf.writeBigInt64BE(BigInt(0x0102030405060708), 0);
```
### writeBigInt64LE
writeBigInt64LE(value: bigint, offset?: number): number
-Writes a signed, little-endian 64-bit Big integer to this **Buffer** instance at the specified offset.
+Writes a 64-bit, little-endian, signed big integer to this **Buffer** instance at the specified offset.
**System capability**: SystemCapability.Utils.Lang
@@ -2084,14 +2084,14 @@ For details about the error codes, see [Utils Error Codes](../errorcodes/errorco
import buffer from '@ohos.buffer';
let buf = buffer.allocUninitializedFromPool(8);
-let result = buf.writeBigInt64LE(0x0102030405060708n, 0);
+let result = buf.writeBigInt64LE(BigInt(0x0102030405060708), 0);
```
### writeBigUInt64BE
writeBigUInt64BE(value: bigint, offset?: number): number
-Writes an unsigned, big-endian 64-bit Big integer to this **Buffer** instance at the specified offset.
+Writes a 64-bit, big-endian, unsigned big integer to this **Buffer** instance at the specified offset.
**System capability**: SystemCapability.Utils.Lang
@@ -2123,14 +2123,14 @@ For details about the error codes, see [Utils Error Codes](../errorcodes/errorco
import buffer from '@ohos.buffer';
let buf = buffer.allocUninitializedFromPool(8);
-let result = buf.writeBigUInt64BE(0xdecafafecacefaden, 0);
+let result = buf.writeBigUInt64BE(BigInt(0xdecafafecacefade), 0);
```
### writeBigUInt64LE
writeBigUInt64LE(value: bigint, offset?: number): number
-Writes an unsigned, little-endian 64-bit Big integer to this **Buffer** instance at the specified offset.
+Writes a 64-bit, little-endian, unsigned big integer to this **Buffer** instance at the specified offset.
**System capability**: SystemCapability.Utils.Lang
@@ -2162,14 +2162,14 @@ For details about the error codes, see [Utils Error Codes](../errorcodes/errorco
import buffer from '@ohos.buffer';
let buf = buffer.allocUninitializedFromPool(8);
-let result = buf.writeBigUInt64LE(0xdecafafecacefaden, 0);
+let result = buf.writeBigUInt64LE(BigInt(0xdecafafecacefade), 0);
```
### writeDoubleBE
writeDoubleBE(value: number, offset?: number): number
-Writes a big-endian double-precision floating-point number to this **Buffer** instance at the specified offset.
+Writes a 64-bit, big-endian, double-precision floating-point number to this **Buffer** instance at the specified offset.
**System capability**: SystemCapability.Utils.Lang
@@ -2208,7 +2208,7 @@ let result = buf.writeDoubleBE(123.456, 0);
writeDoubleLE(value: number, offset?: number): number
-Writes a little-endian double-precision floating-point number to this **Buffer** instance at the specified offset.
+Writes a 64-bit, little-endian, double-precision floating-point number to this **Buffer** instance at the specified offset.
**System capability**: SystemCapability.Utils.Lang
@@ -2247,7 +2247,7 @@ let result = buf.writeDoubleLE(123.456, 0);
writeFloatBE(value: number, offset?: number): number
-Writes a big-endian single-precision floating-point number to this **Buffer** instance at the specified offset.
+Writes a 32-bit, big-endian, single-precision floating-point number to this **Buffer** instance at the specified offset.
**System capability**: SystemCapability.Utils.Lang
@@ -2287,7 +2287,7 @@ let result = buf.writeFloatBE(0xcafebabe, 0);
writeFloatLE(value: number, offset?: number): number
-Writes a little-endian single-precision floating-point number to this **Buffer** instance at the specified offset.
+Writes a 32-bit, little-endian, single-precision floating-point number to this **Buffer** instance at the specified offset.
**System capability**: SystemCapability.Utils.Lang
@@ -2326,7 +2326,7 @@ let result = buf.writeFloatLE(0xcafebabe, 0);
writeInt8(value: number, offset?: number): number
-Writes a signed 8-bit integer to this **Buffer** instance at the specified offset.
+Writes a 8-bit signed integer to this **Buffer** instance at the specified offset.
**System capability**: SystemCapability.Utils.Lang
@@ -2367,7 +2367,7 @@ let result1 = buf.writeInt8(-2, 1);
writeInt16BE(value: number, offset?: number): number
-Writes a signed, big-endian 16-bit integer to this **Buffer** instance at the specified offset.
+Writes a 16-bit, big-endian, signed integer to this **Buffer** instance at the specified offset.
**System capability**: SystemCapability.Utils.Lang
@@ -2407,7 +2407,7 @@ let result = buf.writeInt16BE(0x0102, 0);
writeInt16LE(value: number, offset?: number): number
-Writes a signed, little-endian 16-bit integer to this **Buffer** instance at the specified offset.
+Writes a 16-bit, little-endian, signed integer to this **Buffer** instance at the specified offset.
**System capability**: SystemCapability.Utils.Lang
@@ -2446,7 +2446,7 @@ let result = buf.writeInt16LE(0x0304, 0);
writeInt32BE(value: number, offset?: number): number
-Writes a signed, big-endian 32-bit integer to this **Buffer** instance at the specified offset.
+Writes a 32-bit, big-endian, signed integer to this **Buffer** instance at the specified offset.
**System capability**: SystemCapability.Utils.Lang
@@ -2486,7 +2486,7 @@ let result = buf.writeInt32BE(0x01020304, 0);
writeInt32LE(value: number, offset?: number): number
-Writes a signed, little-endian 32-bit integer to this **Buffer** instance at the specified offset.
+Writes a 32-bit, little-endian, signed integer to this **Buffer** instance at the specified offset.
**System capability**: SystemCapability.Utils.Lang
@@ -2606,7 +2606,7 @@ let result = buf.writeIntLE(0x1234567890ab, 0, 6);
writeUInt8(value: number, offset?: number): number
-Writes an unsigned 8-bit integer to this **Buffer** instance at the specified offset.
+Writes a 8-bit unsigned integer to this **Buffer** instance at the specified offset.
**System capability**: SystemCapability.Utils.Lang
@@ -2648,7 +2648,7 @@ let result3 = buf.writeUInt8(0x42, 3);
writeUInt16BE(value: number, offset?: number): number
-Writes an unsigned, big-endian 16-bit integer to this **Buffer** instance at the specified offset.
+Writes a 16-bit, big-endian, unsigned integer to this **Buffer** instance at the specified offset.
**System capability**: SystemCapability.Utils.Lang
@@ -2688,7 +2688,7 @@ let result1 = buf.writeUInt16BE(0xbeef, 2);
writeUInt16LE(value: number, offset?: number): number
-Writes an unsigned, little-endian 16-bit integer to this **Buffer** instance at the specified offset.
+Writes a 16-bit, little-endian, unsigned integer to this **Buffer** instance at the specified offset.
**System capability**: SystemCapability.Utils.Lang
@@ -2728,7 +2728,7 @@ let result1 = buf.writeUInt16LE(0xbeef, 2);
writeUInt32BE(value: number, offset?: number): number
-Writes an unsigned, big-endian 32-bit integer to this **Buffer** instance at the specified offset.
+Writes a 32-bit, big-endian, unsigned integer to this **Buffer** instance at the specified offset.
**System capability**: SystemCapability.Utils.Lang
@@ -2767,7 +2767,7 @@ let result = buf.writeUInt32BE(0xfeedface, 0);
writeUInt32LE(value: number, offset?: number): number
-Writes an unsigned, little-endian 32-bit integer to this **Buffer** instance at the specified offset.
+Writes a 32-bit, little-endian, unsigned integer to this **Buffer** instance at the specified offset.
**System capability**: SystemCapability.Utils.Lang
diff --git a/en/application-dev/reference/apis/js-apis-bundleMonitor.md b/en/application-dev/reference/apis/js-apis-bundleMonitor.md
index cef362d3702423395594a8ae52326b99e5aee191..0cea1311feadeba8b3dc9f7dd250894e57267c67 100644
--- a/en/application-dev/reference/apis/js-apis-bundleMonitor.md
+++ b/en/application-dev/reference/apis/js-apis-bundleMonitor.md
@@ -81,7 +81,7 @@ Unsubscribes from bundle installation, uninstall, and update events.
| Name | Type | Mandatory| Description |
| ---------------------------- | -------- | ---- | ---------------------------------------------------------- |
| type| BundleChangedEvent| Yes | Type of the event to unsubscribe from. |
-| callback | callback\| No | Callback used for the unsubscription. If this parameter is left empty, all callbacks of the current event are unsubscribed from.|
+| callback | callback\| No | Callback used for the unsubscription. By default, no value is passed, and all callbacks of the current event are unsubscribed from.|
**Example**
diff --git a/en/application-dev/reference/apis/js-apis-call.md b/en/application-dev/reference/apis/js-apis-call.md
index 9ba1dfa2ca3ef6a55b0e2a662f4f413b91d1013f..1f90664de26360d3099d9f0870baabaad1063b23 100644
--- a/en/application-dev/reference/apis/js-apis-call.md
+++ b/en/application-dev/reference/apis/js-apis-call.md
@@ -16,7 +16,7 @@ import call from '@ohos.telephony.call';
## call.dialCall9+
-dialCall\(phoneNumber: string, callback: AsyncCallback\): void
+dialCall\(phoneNumber: string, callback: AsyncCallback\\): void
Initiates a call. This API uses an asynchronous callback to return the result.
@@ -40,6 +40,7 @@ For details about the following error codes, see [Telephony Error Codes](../../r
| ID| Error Message |
| -------- | -------------------------------------------- |
| 201 | Permission denied. |
+| 202 | Non-system applications use system APIs. |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
@@ -57,7 +58,7 @@ call.dialCall("138xxxxxxxx", (err) => {
## call.dialCall9+
-dialCall\(phoneNumber: string, options: DialCallOptions, callback: AsyncCallback\): void
+dialCall\(phoneNumber: string, options: DialCallOptions, callback: AsyncCallback\\): void
Initiates a call. You can set call options as needed. This API uses an asynchronous callback to return the result.
@@ -82,6 +83,7 @@ For details about the following error codes, see [Telephony Error Codes](../../r
| ID| Error Message |
| -------- | -------------------------------------------- |
| 201 | Permission denied. |
+| 202 | Non-system applications use system APIs. |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
@@ -104,7 +106,7 @@ call.dialCall("138xxxxxxxx", {
## call.dialCall9+
-dialCall\(phoneNumber: string, options?: DialCallOptions\): Promise
+dialCall\(phoneNumber: string, options?: DialCallOptions\): Promise\
Initiates a call. You can set call options as needed. This API uses a promise to return the result.
@@ -119,7 +121,7 @@ Initiates a call. You can set call options as needed. This API uses a promise to
| Name | Type | Mandatory| Description |
| ----------- | ----------------------------------- | ---- | -------------------------------------- |
| phoneNumber | string | Yes | Phone number. |
-| options | [DialCallOptions](#dialcalloptions9)| No | Call options, which carry other configuration information of the call.|
+| options | [DialCallOptions](#dialcalloptions9)| No | Call options, which carry other configuration information of the call.
If this parameter is not set, the following configuration is used by default. For details, see [DialCallOptions](#dialcalloptions9).
- **accountId**: 0 (card slot 1)
- **videoState**: voice call
- **dialScene**: common call
- **dialType**: carrier call |
**Return value**
@@ -134,6 +136,7 @@ For details about the following error codes, see [Telephony Error Codes](../../r
| ID| Error Message |
| -------- | -------------------------------------------- |
| 201 | Permission denied. |
+| 202 | Non-system applications use system APIs. |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
@@ -158,7 +161,7 @@ promise.then(() => {
## call.dial(deprecated)
-dial\(phoneNumber: string, callback: AsyncCallback\): void
+dial\(phoneNumber: string, callback: AsyncCallback\\): void
Initiates a call. This API uses an asynchronous callback to return the result.
@@ -188,7 +191,7 @@ call.dial("138xxxxxxxx", (err, data) => {
## call.dial(deprecated)
-dial\(phoneNumber: string, options: DialOptions, callback: AsyncCallback\): void
+dial\(phoneNumber: string, options: DialOptions, callback: AsyncCallback\\): void
Initiates a call. You can set call options as needed. This API uses an asynchronous callback to return the result.
@@ -220,7 +223,7 @@ call.dial("138xxxxxxxx", {
## call.dial(deprecated)
-dial\(phoneNumber: string, options?: DialOptions\): Promise
+dial\(phoneNumber: string, options?: DialOptions\): Promise\
Initiates a call. You can set call options as needed. This API uses a promise to return the result.
@@ -260,7 +263,7 @@ promise.then(data => {
## call.makeCall7+
-makeCall(phoneNumber: string, callback: AsyncCallback\): void
+makeCall\(phoneNumber: string, callback: AsyncCallback\\): void
Launches the call screen and displays the dialed number. This API uses an asynchronous callback to return the result.
@@ -296,7 +299,7 @@ call.makeCall("138xxxxxxxx", err => {
## call.makeCall7+
-makeCall(phoneNumber: string): Promise\
+makeCall\(phoneNumber: string\): Promise\
Launches the call screen and displays the dialed number. This API uses a promise to return the result.
@@ -339,7 +342,7 @@ promise.then(() => {
## call.hasCall
-hasCall\(callback: AsyncCallback\): void
+hasCall\(callback: AsyncCallback\\): void
Checks whether a call is in progress. This API uses an asynchronous callback to return the result.
@@ -362,7 +365,7 @@ call.hasCall((err, data) => {
## call.hasCall
-hasCall\(\): Promise
+hasCall\(\): Promise\
Checks whether a call is in progress. This API uses a promise to return the result.
@@ -388,7 +391,7 @@ promise.then(data => {
## call.getCallState
-getCallState\(callback: AsyncCallback\): void
+getCallState\(callback: AsyncCallback\\): void
Obtains the call status. This API uses an asynchronous callback to return the result.
@@ -411,7 +414,7 @@ call.getCallState((err, data) => {
## call.getCallState
-getCallState\(\): Promise
+getCallState\(\): Promise\
Obtains the call status. This API uses a promise to return the result.
@@ -436,7 +439,7 @@ promise.then(data => {
## call.hasVoiceCapability