diff --git a/en/application-dev/application-models/Readme-EN.md b/en/application-dev/application-models/Readme-EN.md
index 65d5dc91d92ae7622d7a5824759798230f3a4806..aca0bbb39f14d5110bf82d2a610eca7d8b05dd6c 100644
--- a/en/application-dev/application-models/Readme-EN.md
+++ b/en/application-dev/application-models/Readme-EN.md
@@ -20,7 +20,7 @@
- [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
@@ -36,9 +36,10 @@
- [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 UIAbility Through the router Event](arkts-ui-widget-event-router.md)
+ - [Launching a UIAbility in the Background Through the call Event](arkts-ui-widget-event-call.md)
+ - [Updating Widget Content Through the message Event](arkts-ui-widget-event-formextensionability.md)
+ - [Updating Widget Content Through the router or call Event](arkts-ui-widget-event-uiability.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)
@@ -52,7 +53,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)
@@ -71,7 +72,7 @@
- [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)
- Thread Model
- [Thread Model Overview](thread-model-stage.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/accessibilityextensionability.md b/en/application-dev/application-models/accessibilityextensionability.md
index 688eaefa4bc10723d23f880dfbb4c1502cb42053..c14b4b95921f8adef52c83b20253d26b774b16fa 100644
--- a/en/application-dev/application-models/accessibilityextensionability.md
+++ b/en/application-dev/application-models/accessibilityextensionability.md
@@ -12,17 +12,31 @@ The **AccessibilityExtensionAbility** module provides accessibility extension ca
This document is organized as follows:
-- [AccessibilityExtensionAbility Development](#accessibilityextensionability-development)
- - [Creating an Accessibility Extension Service](#creating-an-accessibility-extension-service)
- - [Creating a Project](#creating-a-project)
- - [Creating an AccessibilityExtAbility File](#creating-an-accessibilityextability-file)
- - [Processing an Accessibility Event](#processing-an-accessibility-event)
- - [Declaring Capabilities of Accessibility Extension Services](#declaring-capabilities-of-accessibility-extension-services)
- - [Enabling a Custom Accessibility Extension Service](#enabling-a-custom-accessibility-extension-service)
+- [AccessibilityExtensionAbility Overview](#accessibilityextensionability-overview)
+- [Creating an Accessibility Extension Service](#creating-an-accessibility-extension-service)
+- [Processing an Accessibility Event](#processing-an-accessibility-event)
+- [Declaring Capabilities of Accessibility Extension Services](#declaring-capabilities-of-accessibility-extension-services)
+- [Enabling a Custom Accessibility Extension Service](#enabling-a-custom-accessibility-extension-service)
+
+## AccessibilityExtensionAbility Overview
+
+Accessibility is about giving equal access to everyone so that they can access and use information equally and conveniently under any circumstances. It helps narrow the digital divide between people of different classes, regions, ages, and health status in terms of information understanding, information exchange, and information utilization, so that they can participate in social life more conveniently and enjoy the benefits of technological advances.
+
+AccessibilityExtensionAbility is an accessibility extension service framework. It allows you to develop your own extension services and provides a standard mechanism for exchanging information between applications and extension services. You can make use of the provided capabilities and APIs to develop accessibility features for users with disabilities or physical limitations. For example, you can develop a screen reader for users with vision impairments.
+
+Below shows the AccessibilityExtensionAbility framework.
+
+
+
+1. Accessibility app: extension service application developed based on the AccessibilityExtensionAbility framework, for example, a screen reader application.
+2. Target app: application assisted by the accessibility app.
+3. AccessibilityAbilityManagerService (AAMS): main service of the AccessibilityExtensionAbility framework, which is used to manage the lifecycle of accessibility apps and provide a bridge for information exchange between accessibility apps and target apps.
+4. AccessibilityAbility (AAkit): ability that is used by the accessibility app to build an extension service ability operating environment and that provides interfaces for the accessibility app to query and operate the target app, including performing click/long press operations.
+5. AccessibilitySystemAbilityClient (ASACkit): used by the target app to send accessibility events, such as content change events, to AAMS, and respond to the instructions (such as performing click/long press operations) sent by the accessibility app through AAMS.
## Creating an Accessibility Extension Service
-You can create an accessibility extension service by creating a project from scratch or adding the service to an existing project.
+You can create an accessibility extension service by creating a project from scratch or adding the service to an existing project. Only one accessibility extension service can be created for a project.
### Creating a Project
@@ -40,15 +54,15 @@ import AccessibilityExtensionAbility from '@ohos.application.AccessibilityExtens
class AccessibilityExtAbility extends AccessibilityExtensionAbility {
onConnect() {
- console.log('AccessibilityExtAbility onConnect');
+ console.info('AccessibilityExtAbility onConnect');
}
onDisconnect() {
- console.log('AccessibilityExtAbility onDisconnect');
+ console.info('AccessibilityExtAbility onDisconnect');
}
onAccessibilityEvent(accessibilityEvent) {
- console.log('AccessibilityExtAbility onAccessibilityEvent: ' + JSON.stringify(accessibilityEvent));
+ console.info('AccessibilityExtAbility onAccessibilityEvent: ' + JSON.stringify(accessibilityEvent));
}
}
@@ -69,9 +83,9 @@ You can process the service logic for accessibility events in the **onAccessibil
```typescript
onAccessibilityEvent(accessibilityEvent) {
- console.log('AccessibilityExtAbility onAccessibilityEvent: ' + JSON.stringify(accessibilityEvent));
+ console.info('AccessibilityExtAbility onAccessibilityEvent: ' + JSON.stringify(accessibilityEvent));
if (accessibilityEvent.eventType === 'pageStateUpdate') {
- console.log('AccessibilityExtAbility onAccessibilityEvent: pageStateUpdate');
+ console.info('AccessibilityExtAbility onAccessibilityEvent: pageStateUpdate');
// TODO: Develop custom logic.
}
}
@@ -119,3 +133,4 @@ To enable or disable an accessibility extension service, run the following comma
In the preceding commands, **AccessibilityExtAbility** indicates the name of the accessibility extension service, **com.example.demo** indicates the bundle name, and **rg** indicates the capabilities (**r** is short for retrieve).
If the service is enabled or disabled successfully, the message "enable ability successfully" or "disable ability successfully" is displayed.
+
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

@@ -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
+
+ 
+
- **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.
-

-
+
- The figure below illustrates the holding relationship of contexts.
-

-- 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

- 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

- 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

- 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

- 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/arkts-ui-widget-event-call.md b/en/application-dev/application-models/arkts-ui-widget-event-call.md
new file mode 100644
index 0000000000000000000000000000000000000000..073506706053e31402d7c69d645138ec7ab112cc
--- /dev/null
+++ b/en/application-dev/application-models/arkts-ui-widget-event-call.md
@@ -0,0 +1,89 @@
+# Launching a UIAbility in the Background Through the call Event
+
+
+There may be cases you want to provide in a widget access to features available in your application when it is running in the foreground, for example, the play, pause, and stop buttons in a music application widget. This is where the **call** capability of the **postCardAction** API comes in handy. This capability, when used in a widget, can start the specified UIAbility of the widget provider in the background. It also allows the widget to call the specified method of the application and transfer data so that the application, while in the background, can behave accordingly in response to touching of the buttons on the widget.
+
+
+Generally, buttons are used to trigger the **call** event. Below is an example.
+
+
+- In this example, two buttons are laid out on the widget page. When one button is clicked, the **postCardAction** API is called to send a **call** event to the target UIAbility. Note that the **method** parameter in the API indicates the method to call in the target UIAbility. It is mandatory and of the string type.
+
+ ```ts
+ @Entry
+ @Component
+ struct WidgetCard {
+ build() {
+ Column() {
+ Button ('Feature A')
+ .margin('20%')
+ .onClick(() => {
+ console.info('call EntryAbility funA');
+ postCardAction(this, {
+ 'action': 'call',
+ 'abilityName': 'EntryAbility', // Only the UIAbility of the current application is allowed.
+ 'params': {
+ 'method': 'funA' // Set the name of the method to call in the EntryAbility.
+ }
+ });
+ })
+
+ Button ('Feature B')
+ .margin('20%')
+ .onClick(() => {
+ console.info('call EntryAbility funB');
+ postCardAction(this, {
+ 'action': 'call',
+ 'abilityName': 'EntryAbility', // Only the UIAbility of the current application is allowed.
+ 'params': {
+ 'method': 'funB', // Set the name of the method to call in the EntryAbility.
+ 'num': 1 // Set other parameters to be transferred.
+ }
+ });
+ })
+ }
+ .width('100%')
+ .height('100%')
+ }
+ }
+ ```
+
+- The UIAbility receives the **call** event and obtains the transferred parameters. It then executes the target method specified by the **method** parameter. Other data can be obtained in readString mode. Listen for the method required by the **call** event in the **onCreate** callback of the UIAbility.
+
+ ```ts
+ import UIAbility from '@ohos.app.ability.UIAbility';
+
+ function FunACall(data) {
+ // Obtain all parameters transferred in the call event.
+ console.info('FunACall param:' + JSON.stringify(data.readString()));
+ return null;
+ }
+
+ function FunBCall(data) {
+ console.info('FunACall param:' + JSON.stringify(data.readString()));
+ return null;
+ }
+
+ export default class CameraAbility extends UIAbility {
+ // If the UIAbility is started for the first time, the onCreate lifecycle callback is triggered after the call event is received.
+ onCreate(want, launchParam) {
+ try {
+ // Listen for the method required by the call event.
+ this.callee.on('funA', FunACall);
+ this.callee.on('funB', FunBCall);
+ } catch (error) {
+ console.error(`Failed to register callee on. Cause: ${JSON.stringify(err)}`);
+ }
+ }
+
+ // Deregister the listener when the process exits.
+ onDestroy() {
+ try {
+ this.callee.off('funA');
+ this.callee.off('funB');
+ } catch (err) {
+ console.error(`Failed to register callee off. Cause: ${JSON.stringify(err)}`);
+ }
+ }
+ };
+ ```
diff --git a/en/application-dev/application-models/arkts-ui-widget-event-formextensionability.md b/en/application-dev/application-models/arkts-ui-widget-event-formextensionability.md
index 861f5ca66eea9a06ee50c7b1448e1f6ed040c01a..be7761d8d78da5102afadd2c37043c228dfcd53e 100644
--- a/en/application-dev/application-models/arkts-ui-widget-event-formextensionability.md
+++ b/en/application-dev/application-models/arkts-ui-widget-event-formextensionability.md
@@ -1,7 +1,7 @@
-# Updating Widget Content Through FormExtensionAbility
+# Updating Widget Content Through the message Event
-On the widget page, the **postCardAction** API can be used to trigger a message event to the FormExtensionAbility, which then updates the widget content. The following is an example of this widget update mode.
+On the widget page, the **postCardAction** API can be used to trigger a message event to start a FormExtensionAbility, which then updates the widget content. The following is an example of this widget update mode.
- On the widget page, register the **onClick** event callback of the button and call the **postCardAction** API in the callback to trigger the event to the FormExtensionAbility.
@@ -57,10 +57,10 @@ On the widget page, the **postCardAction** API can be used to trigger a message
})
}
- // ...
+ ...
}
```
The figure below shows the effect.
-
+

diff --git a/en/application-dev/application-models/arkts-ui-widget-event-overview.md b/en/application-dev/application-models/arkts-ui-widget-event-overview.md
index fbc77b97a27b52b0f7b2a3b0cebc5b5cb5940f72..ed029fc3017d00a7d4c2cf14e1b905139bd7eb49 100644
--- a/en/application-dev/application-models/arkts-ui-widget-event-overview.md
+++ b/en/application-dev/application-models/arkts-ui-widget-event-overview.md
@@ -1,40 +1,31 @@
# Widget Event Capability Overview
-
The ArkTS widget provides the **postCardAction()** API for interaction between the widget internal and the provider application. Currently, this API supports the router, message, and call events and can be called only in the widget.
-

+**Definition**: postCardAction(component: Object, action: Object): void
-Definition: postCardAction(component: Object, action: Object): void
-
-
-Parameters:
-
+**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| component | Object | Yes| Instance of the current custom component. Generally, **this** is transferred.|
| action | Object | Yes| Action description. For details, see the following table.|
+**Description of the action parameter**
-Description of the action parameter
-
-
-| **Key** | **Value** | Description|
+| Key | Value | Description|
| -------- | -------- | -------- |
-| "action" | string | Action type.
- **"router"**: application redirection. If this type of action is triggered, the corresponding UIAbility is displayed. Only the UIAbility of the current application can be displayed.
- **"message"**: custom message. If this type of action is triggered, the [onFormEvent()](../reference/apis/js-apis-app-form-formExtensionAbility.md#onformevent) lifecycle callback of the provider FormExtensionAbility is called.
- **"call"**: application startup in the background. If this type of action is triggered, the corresponding UIAbility is started but does not run in the foreground. The target application must have the permission to run in the background ([ohos.permission.KEEP_BACKGROUND_RUNNING](../security/permission-list.md#ohospermissionkeep_background_running)).|
+| "action" | string | Action type.
- **"router"**: redirection to the specified UIAbility of the widget provider.
- **"message"**: custom message. If this type of action is triggered, the [onFormEvent()](../reference/apis/js-apis-app-form-formExtensionAbility.md#onformevent) lifecycle callback of the provider FormExtensionAbility is called.
- **"call"**: launch of the widget provider in the background. If this type of action is triggered, the specified UIAbility of the widget provider is started in the background, but not displayed in the foreground. This action type requires that the widget provider should have the [ohos.permission.KEEP_BACKGROUND_RUNNING](../security/permission-list.md#ohospermissionkeep_background_running) permission.|
| "bundleName" | string | Name of the target bundle when **action** is **"router"** or **"call"**. This parameter is optional.|
| "moduleName" | string | Name of the target module when **action** is **"router"** or **"call"**. This parameter is optional.|
| "abilityName" | string | Name of the target UIAbility when **action** is **"router"** or **"call"**. This parameter is mandatory.|
-| "params" | Object | Additional parameters carried in the current action. The value is a key-value pair in JSON format.|
+| "params" | Object | Additional parameters carried in the current action. The value is a key-value pair in JSON format. For the **"call"** action type, the **method** parameter must be set and its value type must be string. This parameter is mandatory.|
Sample code of the **postCardAction()** API:
-
-
```typescript
Button ('Jump')
.width('40%')
@@ -45,18 +36,26 @@ Button ('Jump')
'bundleName': 'com.example.myapplication',
'abilityName': 'EntryAbility',
'params': {
- 'message': 'testForRouter' // Customize the message to be sent.
+ 'message': 'testForRouter' // Customize the message to send.
}
});
})
-```
-
-
-The following are typical widget development scenarios that can be implemented through widget events:
+Button ('Start in Background')
+ .width('40%')
+ .height('20%')
+ .onClick(() => {
+ postCardAction(this, {
+ 'action': 'call',
+ 'bundleName': 'com.example.myapplication',
+ 'abilityName': 'EntryAbility',
+ 'params': {
+ 'method': 'fun', // Set the name of the method to call. It is mandatory.
+ 'message': 'testForcall' // Customize the message to send.
+ }
+ });
+ })
+```
-- [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)
+Read on to learn the typical widget development scenarios that can be implemented through widget events.
diff --git a/en/application-dev/application-models/arkts-ui-widget-event-router.md b/en/application-dev/application-models/arkts-ui-widget-event-router.md
index 371cbc6b2729a7985ed2fd183297ed771fddb11d..733ff7f59b57ec4295fa21cb4d83ae8a5b2b8eb4 100644
--- a/en/application-dev/application-models/arkts-ui-widget-event-router.md
+++ b/en/application-dev/application-models/arkts-ui-widget-event-router.md
@@ -1,8 +1,6 @@
-# Redirecting to a Specified Page Through the Router Event
-
-
-The **router** capability of the **postCardAction** API can be used in a widget to quickly start the widget provider application. An application can provide different buttons through the widget so that users can jump to different pages at the touch of a button. For example, a camera widget provides the buttons that direct the user to respective pages, such as the page for taking a photo and the page for recording a video.
+# Redirecting to a UIAbility Through the router Event
+The **router** capability of the **postCardAction** API can be used in a widget to quickly start a specific UIAbility of the widget provider. By leveraging this capability, an application can provide in the widget multiple buttons, each of which targets a different target UIAbility. For example, a camera widget can provide the buttons that redirect the user to the UIAbility for taking a photo and the UIAbility for recording a video.

diff --git a/en/application-dev/application-models/arkts-ui-widget-event-uiability.md b/en/application-dev/application-models/arkts-ui-widget-event-uiability.md
index 0d6cb33a3749c81b6b41dd4904ba64c89a7942ae..ca66e20aa2d258a0e05002296dac39c19ac131c3 100644
--- a/en/application-dev/application-models/arkts-ui-widget-event-uiability.md
+++ b/en/application-dev/application-models/arkts-ui-widget-event-uiability.md
@@ -1,10 +1,11 @@
-# Updating Widget Content Through UIAbility
+# Updating Widget Content Through the router or call Event
-On the widget page, the **postCardAction** API can be used to trigger a router or call event to start the UIAbility, which then updates the widget content. The following is an example of this widget update mode.
+On the widget page, the **postCardAction** API can be used to trigger a router or call event to start a UIAbility, which then updates the widget content. The following is an example of this widget update mode.
+## Updating Widget Content Through the router Event
-- On the widget page, register the **onClick** event callback of the button and call the **postCardAction** API in the callback to trigger the event to the FormExtensionAbility.
+- On the widget page, register the **onClick** event callback of the button and call the **postCardAction** API in the callback to trigger the **router** event to the FormExtensionAbility.
```ts
let storage = new LocalStorage();
@@ -84,3 +85,104 @@ On the widget page, the **postCardAction** API can be used to trigger a router o
...
}
```
+
+## Updating Widget Content Through the call Event
+
+- When using the **call** event of the **postCardAction** API, the value of **formId** must be updated in the **onAddForm** callback of the FormExtensionAbility.
+
+ ```ts
+ import formBindingData from '@ohos.app.form.formBindingData';
+ import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
+
+ export default class EntryFormAbility extends FormExtensionAbility {
+ onAddForm(want) {
+ let formId = want.parameters["ohos.extra.param.key.form_identity"];
+ let dataObj1 = {
+ "formId": formId
+ };
+ let obj1 = formBindingData.createFormBindingData(dataObj1);
+ return obj1;
+ }
+
+ ...
+ };
+ ```
+
+- On the widget page, register the **onClick** event callback of the button and call the **postCardAction** API in the callback to trigger the event to the UIAbility.
+
+ ```ts
+ let storage = new LocalStorage();
+ @Entry(storage)
+ @Component
+ struct WidgetCard {
+ @LocalStorageProp('detail') detail: string = 'init';
+ @LocalStorageProp('formId') formId: string = '0';
+
+ build() {
+ Column() {
+ Button ('Start in Background')
+ .margin('20%')
+ .onClick(() => {
+ console.info('postCardAction to EntryAbility');
+ postCardAction(this, {
+ 'action': 'call',
+ 'abilityName': 'EntryAbility', // Only the UIAbility of the current application is allowed.
+ 'params': {
+ 'method': 'funA',
+ 'formId': this.formId,
+ 'detail': 'CallFromCard'
+ }
+ });
+ })
+ Text(`${this.detail}`).margin('20%')
+ }
+ .width('100%')
+ .height('100%')
+ }
+ }
+ ```
+
+- Listen for the method required by the **call** event in the **onCreate** callback of the UIAbility, and then call the [updateForm](../reference/apis/js-apis-app-form-formProvider.md#updateform) API in the corresponding method to update the widget.
+
+ ```ts
+ import UIAbility from '@ohos.app.ability.UIAbility';
+ import formBindingData from '@ohos.app.form.formBindingData';
+ import formProvider from '@ohos.app.form.formProvider';
+ import formInfo from '@ohos.app.form.formInfo';
+
+ const MSG_SEND_METHOD: string = 'funA';
+
+ // After the call event is received, the method listened for by the callee is triggered.
+ function FunACall(data) {
+ // Obtain all parameters transferred in the call event.
+ let params = JSON.parse(data.readString())
+ if (params.formId !== undefined) {
+ let curFormId = params.formId;
+ let message = params.detail;
+ console.info(`UpdateForm formId: ${curFormId}, message: ${message}`);
+ let formData = {
+ "detail": message
+ };
+ let formMsg = formBindingData.createFormBindingData(formData)
+ formProvider.updateForm(curFormId, formMsg).then((data) => {
+ console.info('updateForm success.' + JSON.stringify(data));
+ }).catch((error) => {
+ console.error('updateForm failed:' + JSON.stringify(error));
+ })
+ }
+ return null;
+ }
+ export default class EntryAbility extends UIAbility {
+ // If the UIAbility is started for the first time, the onCreate lifecycle callback is triggered after the call event is received.
+ onCreate(want, launchParam) {
+ console.info('Want:' + JSON.stringify(want));
+ try {
+ // Listen for the method required by the call event.
+ this.callee.on(MSG_SEND_METHOD, FunACall);
+ } catch (error) {
+ console.info(`${MSG_SEND_METHOD} register failed with error ${JSON.stringify(error)}`)
+ }
+ }
+ ...
+ }
+ ```
diff --git a/en/application-dev/application-models/arkts-ui-widget-image-update.md b/en/application-dev/application-models/arkts-ui-widget-image-update.md
index 4862fbf747c0275d179eb4a2f988280379f2d262..dfe6dbf0e9249c66c3fb1d0723f1c7b296443381 100644
--- a/en/application-dev/application-models/arkts-ui-widget-image-update.md
+++ b/en/application-dev/application-models/arkts-ui-widget-image-update.md
@@ -1,10 +1,10 @@
# Updating Local and Online Images in the Widget
-Generally, local images or online images downloaded from the network need to be displayed on a widget. To obtain local and online images, use the FormExtensionAbility. The following exemplifies how to show local and online images on a widget.
+Typically, a widget includes local images or online images downloaded from the network. To obtain local and online images, use the FormExtensionAbility. The following exemplifies how to show local and online images on a widget.
-1. Internet access is required for downloading online images. Therefore, you need to apply for the **ohos.permission.INTERNET** permission. For details, see [Declaring Permissions in the Configuration File](../security/accesstoken-guidelines.md).
+1. For the widget to download online images, declare the **ohos.permission.INTERNET** permission for the widget. For details, see [Declaring Permissions in the Configuration File](../security/accesstoken-guidelines.md).
2. Update local files in the **onAddForm** lifecycle callback of the EntryFormAbility.
@@ -44,7 +44,7 @@ Generally, local images or online images downloaded from the network need to be
}
```
-3. Update online files in the onFormEvent lifecycle callback of the EntryFormAbility.
+3. Update online images in the **onFormEvent** lifecycle callback of the EntryFormAbility.
```ts
import formBindingData from '@ohos.app.form.formBindingData';
@@ -60,8 +60,8 @@ Generally, local images or online images downloaded from the network need to be
'text': 'Updating...'
})
formProvider.updateForm(formId, formInfo)
- // Note: The FormExtensionAbility is started when the lifecycle callback is triggered. It can run in the background for only 5 seconds.
- // When possible, limit the size of the image to download. If an image cannot be downloaded within 5 seconds, it cannot be updated to the widget page.
+ // Note: After being started with the triggering of the lifecycle callback, the FormExtensionAbility can run in the background for only 5 seconds.
+ // When possible, limit the size of the image to download. If an image cannot be downloaded within 5 seconds, it will not be updated to the widget page.
let netFile = 'https://xxxx/xxxx.png'; // Specify the URL of the image to download.
let tempDir = this.context.getApplicationContext().tempDir;
let fileName = 'file' + Date.now();
@@ -161,6 +161,6 @@ Generally, local images or online images downloaded from the network need to be
```
> **NOTE**
-> - The **\** component displays images in the remote memory based on the **memory://** identifier in the input parameter (**memory://fileName**). The **fileName** value must be consistent with the key in the object (**'formImages': {key: fd}**) passed by the EntryFormAbility.
+> - The **\** component displays images in the remote memory based on the **memory://** identifier in the input parameter (**memory://fileName**). The value of **fileName** must be consistent with the key in the object (**'formImages': {key: fd}**) passed by the EntryFormAbility.
>
-> - The **\** component determines whether to update the image based on whether the input parameter is changed. Therefore, the value of **imgName** passed by the EntryFormAbility each time must be different. If the two values of **imgName** passed consecutively are identical, the image is not updated.
+> - The **\** component determines whether to update the image by comparing the values of **imgName** consecutively passed by the EntryFormAbility. It updates the image only when the values are different.
diff --git a/en/application-dev/application-models/arkts-ui-widget-lifecycle.md b/en/application-dev/application-models/arkts-ui-widget-lifecycle.md
index 4cb68536312e26e0f7c98546839134c0ab435a8c..fb25fd362f67646d65853b870a6a9cb518c4d760 100644
--- a/en/application-dev/application-models/arkts-ui-widget-lifecycle.md
+++ b/en/application-dev/application-models/arkts-ui-widget-lifecycle.md
@@ -92,4 +92,5 @@ When creating an ArkTS widget, you need to implement the [FormExtensionAbility](
> **NOTE**
-> The FormExtensionAbility cannot reside in the background. Therefore, continuous tasks cannot be processed in the widget lifecycle callbacks. The FormExtensionAbility persists for 5 seconds after the lifecycle callback is completed and will exit if no new lifecycle callback is invoked during this time frame. For the service logic that may take more than 5 seconds to complete, it is recommended that you [start the application](arkts-ui-widget-event-uiability.md). After the processing is complete, use the [updateForm](../reference/apis/js-apis-app-form-formProvider.md#updateform) to notify the widget of the update.
+>
+> The FormExtensionAbility cannot reside in the background. It persists for 5 seconds after the lifecycle callback is completed and exist if no new lifecycle callback is invoked during this time frame. This means that continuous tasks cannot be processed in the widget lifecycle callbacks. For the service logic that may take more than 5 seconds to complete, it is recommended that you [start the application](arkts-ui-widget-event-uiability.md) for processing. After the processing is complete, use [updateForm()](../reference/apis/js-apis-app-form-formProvider.md#updateform) to notify the widget of the update.
diff --git a/en/application-dev/application-models/arkts-ui-widget-modules.md b/en/application-dev/application-models/arkts-ui-widget-modules.md
index 5084b7ea5045002759ca57f10c055ef5623eb7d0..b9a411426db84a4c1af12e70eab956adc8f25806 100644
--- a/en/application-dev/application-models/arkts-ui-widget-modules.md
+++ b/en/application-dev/application-models/arkts-ui-widget-modules.md
@@ -1,7 +1,7 @@
# ArkTS Widget Related Modules
+**Figure 1** ArkTS widget related modules
- **Figure 1** ArkTS widget related modules

@@ -15,10 +15,10 @@
- [formBindingData](../reference/apis/js-apis-app-form-formBindingData.md): provides APIs for widget data binding. You can use the APIs to create a **FormBindingData** object and obtain related information.
-- [Page Layout (Card.ets)](arkts-ui-widget-page-overview.md): provides APIs for a declarative paradigm UI.
- - [ArkTS widget capabilities](arkts-ui-widget-event-overview.md): include the **postCardAction** API used for interaction between the widget internal and the provider application and can be called only in the widget.
- - [ArkTS widget capability list](arkts-ui-widget-page-overview.md#page-capabilities-supported-by-arkts-widgets): lists the APIs, components, events, attributes, and lifecycle callbacks that can be used in ArkTS widgets.
+- [Page layout (Card.ets)](arkts-ui-widget-page-overview.md): provides APIs for a declarative paradigm UI.
+ - [Capabilities exclusive to ArkTS widgets](arkts-ui-widget-event-overview.md): include the **postCardAction** API used for interaction between the widget internal and the provider application and can be called only in the widget.
+ - [ArkTS widget capability list](arkts-ui-widget-page-overview.md#page-capabilities-supported-by-arkts-widgets): contain the APIs, components, events, attributes, and lifecycle callbacks that can be used in ArkTS widgets.
- [Widget configuration](arkts-ui-widget-configuration.md): includes FormExtensionAbility configuration and widget configuration.
- - Configure FormExtensionAbility information under **extensionAbilities** in the [module.json5 file](../quick-start/module-configuration-file.md).
+ - Configure the FormExtensionAbility information under **extensionAbilities** in the [module.json5 file](../quick-start/module-configuration-file.md).
- Configure the widget configuration information (**WidgetCard.ets**) in the [form_config.json](arkts-ui-widget-configuration.md) file in **resources/base/profile**.
diff --git a/en/application-dev/application-models/arkts-ui-widget-page-animation.md b/en/application-dev/application-models/arkts-ui-widget-page-animation.md
index 9a940aeecb62682a185ba8c0529adc38017c8e2d..0cb8e356c61155d367e55c0f39bbf491d03e2e12 100644
--- a/en/application-dev/application-models/arkts-ui-widget-page-animation.md
+++ b/en/application-dev/application-models/arkts-ui-widget-page-animation.md
@@ -1,10 +1,10 @@
# Using Animations in the Widget
-To make your ArkTS widget more engaging, you can apply animations to it, including [explicit animation](../reference/arkui-ts/ts-explicit-animation.md), [attribute animation](../reference/arkui-ts/ts-animatorproperty.md), and [component transition](../reference/arkui-ts/ts-transition-animation-component.md). Note the following restrictions when using the animations in ArkTS widgets.
+To make your ArkTS widget more engaging, you can apply animations to it, including [explicit animation](../reference/arkui-ts/ts-explicit-animation.md), [attribute animation](../reference/arkui-ts/ts-animatorproperty.md), and [component transition](../reference/arkui-ts/ts-transition-animation-component.md). Just note the following restrictions when using the animations in ArkTS widgets.
- **Table 1** Restrictions on animation parameters
+**Table 1** Restrictions on animation parameters
| Name| Description| Description|
| -------- | -------- | -------- |
@@ -13,14 +13,10 @@ To make your ArkTS widget more engaging, you can apply animations to it, includi
| delay | Animation delay duration.| Do not set this parameter in the widget. Use the default value 0.|
| iterations | Number of times that the animation is played.| Do not set this parameter in the widget. Use the default value 1.|
-
The following sample code implements the animation effect of button rotation:
-

-
-
```ts
@Entry
@Component
diff --git a/en/application-dev/application-models/arkts-ui-widget-page-custom-drawing.md b/en/application-dev/application-models/arkts-ui-widget-page-custom-drawing.md
index 49523d60af886db40b55fc90d80c9bd5027cade8..a55cb9cd17cda67cc2989e5916db19c5cf36cc47 100644
--- a/en/application-dev/application-models/arkts-ui-widget-page-custom-drawing.md
+++ b/en/application-dev/application-models/arkts-ui-widget-page-custom-drawing.md
@@ -1,9 +1,9 @@
# Applying Custom Drawing in the Widget
- You can apply custom drawing in your ArkTS widget to create a more vibrant experience. Use the [Canvas](../reference/arkui-ts/ts-components-canvas-canvas.md) component to create a canvas on the widget, and then use the [CanvasRenderingContext2D](../reference/arkui-ts/ts-canvasrenderingcontext2d.md) object to draw custom graphics on the canvas. The following code shows how to draw a smiling face in the center of the canvas.
+You can apply custom drawing in your ArkTS widget to create a more vibrant experience. Use the [Canvas](../reference/arkui-ts/ts-components-canvas-canvas.md) component to create a canvas on the widget, and then use the [CanvasRenderingContext2D](../reference/arkui-ts/ts-canvasrenderingcontext2d.md) object to draw custom graphics on the canvas. The following code snippet draws a smiling face in the center of a canvas.
-```typescript
+```ts
@Entry
@Component
struct Card {
@@ -30,41 +30,41 @@ struct Card {
this.context.fillRect(0, 0, this.canvasWidth, this.canvasHeight);
// Draw a red circle in the center of the canvas.
this.context.beginPath();
- let radius = this.context.width / 3
- let circleX = this.context.width / 2
- let circleY = this.context.height / 2
+ let radius = this.context.width / 3;
+ let circleX = this.context.width / 2;
+ let circleY = this.context.height / 2;
this.context.moveTo(circleX - radius, circleY);
this.context.arc(circleX, circleY, radius, 2 * Math.PI, 0, true);
this.context.closePath();
this.context.fillStyle = 'red';
this.context.fill();
// Draw the left eye of the smiling face.
- let leftR = radius / 4
- let leftX = circleX - (radius / 2)
- let leftY = circleY - (radius / 3.5)
+ let leftR = radius / 4;
+ let leftX = circleX - (radius / 2);
+ let leftY = circleY - (radius / 3.5);
this.context.beginPath();
this.context.arc(leftX, leftY, leftR, 0, Math.PI, true);
- this.context.strokeStyle = '#ffff00'
- this.context.lineWidth = 10
- this.context.stroke()
+ this.context.strokeStyle = '#ffff00';
+ this.context.lineWidth = 10;
+ this.context.stroke();
// Draw the right eye of the smiling face.
- let rightR = radius / 4
- let rightX = circleX + (radius / 2)
- let rightY = circleY - (radius / 3.5)
+ let rightR = radius / 4;
+ let rightX = circleX + (radius / 2);
+ let rightY = circleY - (radius / 3.5);
this.context.beginPath();
this.context.arc(rightX, rightY, rightR, 0, Math.PI, true);
- this.context.strokeStyle = '#ffff00'
- this.context.lineWidth = 10
- this.context.stroke()
+ this.context.strokeStyle = '#ffff00';
+ this.context.lineWidth = 10;
+ this.context.stroke();
// Draw the mouth of the smiling face.
- let mouthR = radius / 2.5
- let mouthX = circleX
- let mouthY = circleY + (radius / 3)
+ let mouthR = radius / 2.5;
+ let mouthX = circleX;
+ let mouthY = circleY + (radius / 3);
this.context.beginPath();
this.context.arc(mouthX, mouthY, mouthR, Math.PI, 0, true);
- this.context.strokeStyle = '#ffff00'
- this.context.lineWidth = 10
- this.context.stroke()
+ this.context.strokeStyle = '#ffff00';
+ this.context.lineWidth = 10;
+ this.context.stroke();
})
}
}.height('100%').width('100%')
@@ -72,8 +72,6 @@ struct Card {
}
```
-
The figure below shows the effect.
-
-
+
\ No newline at end of file
diff --git a/en/application-dev/application-models/arkts-ui-widget-update-by-status.md b/en/application-dev/application-models/arkts-ui-widget-update-by-status.md
index 8952b8dff4ecdd3acad6b1a65513d8e529c4dc70..b27958c66d3e174a66c80c90e46cdd71f5ecf668 100644
--- a/en/application-dev/application-models/arkts-ui-widget-update-by-status.md
+++ b/en/application-dev/application-models/arkts-ui-widget-update-by-status.md
@@ -1,7 +1,7 @@
# Updating Widget Content by State
-Multiple widgets of the same application can be configured to implement different features. For example, two weather widgets can be added to the home screen: one for displaying the weather of London, and the other Beijing. The widget is set to be updated at 07:00 every morning. It needs to detect the configured city, and then updates the city-specific weather information. The following example describes how to dynamically update the widget content based on the state.
+There are cases where multiple copies of the same widget are added to the home screen to accommodate different needs. In these cases, the widget content needs to be dynamically updated based on the state. This topic exemplifies how this is implemented. In the following example, two weather widgets are added to the home screen: one for displaying the weather of London, and the other Beijing, both configured to be updated at 07:00 every morning. The widget provider detects the target city, and then displays the city-specific weather information on the widgets.
- Widget configuration file: Configure the widget to be updated at 07:00 every morning.
@@ -74,7 +74,7 @@ Multiple widgets of the same application can be configured to implement differen
}
Row() {// Content that is updated only in state A
- Text('State A: ')
+ Text ('State A:')
Text(this.textA)
}
@@ -167,4 +167,5 @@ Multiple widgets of the same application can be configured to implement differen
> **NOTE**
+>
> When the local database is used for widget information persistence, it is recommended that [TEMPORARY_KEY](../reference/apis/js-apis-app-form-formInfo.md#formparam) be used to determine whether the currently added widget is a normal one in the [onAddForm](../reference/apis/js-apis-app-form-formExtensionAbility.md#onaddform) lifecycle callback. If the widget is a normal one, the widget information is directly persisted. If the widget is a temporary one, the widget information is persisted when the widget is converted to a normal one ([onCastToNormalForm](../reference/apis/js-apis-app-form-formExtensionAbility.md#oncasttonormalform)). In addition, the persistent widget information needs to be deleted when the widget is destroyed ([onRemoveForm](../reference/apis/js-apis-app-form-formExtensionAbility.md#onremoveform)), preventing the database size from continuously increasing due to repeated widget addition and deletion.
diff --git a/en/application-dev/application-models/arkts-ui-widget-update-by-time.md b/en/application-dev/application-models/arkts-ui-widget-update-by-time.md
index 5b27a636f83f144110c5533a3d43baf0087c3716..2c2643c802aff436656f5855d67c00e1a3c38dcd 100644
--- a/en/application-dev/application-models/arkts-ui-widget-update-by-time.md
+++ b/en/application-dev/application-models/arkts-ui-widget-update-by-time.md
@@ -5,7 +5,7 @@ Before configuring a widget to update periodically, enable the periodic update f
The widget framework provides the following modes of updating widgets periodically:
-- Set the update interval: The widget will be updated at the specified interval. You can specify the interval by setting the [updateDuration](arkts-ui-widget-configuration.md) field in the **form_config.json** file. For example, you can configure the widget to update once an hour.
+- Set the update interval: The widget will be updated at the specified interval by calling [onUpdateForm](../reference/apis/js-apis-app-form-formExtensionAbility.md#onupdateform). You can specify the interval by setting the [updateDuration](arkts-ui-widget-configuration.md) field in the **form_config.json** file. For example, you can configure the widget to update once an hour.
> **NOTE**
>
diff --git a/en/application-dev/application-models/common-event-overview.md b/en/application-dev/application-models/common-event-overview.md
index e8be9abaa3015a5512c47af55d2f364be0de79ad..3f532865e686592282b9080f234c088ee24a64f8 100644
--- a/en/application-dev/application-models/common-event-overview.md
+++ b/en/application-dev/application-models/common-event-overview.md
@@ -7,8 +7,7 @@ OpenHarmony provides Common Event Service (CES) for applications to subscribe to
Common events are classified into system common events and custom common events.
-- System common events: defined in CES. Only system applications and system services can publish system common events, such as HAP installation, update, and uninstall. For details about the supported system common events, see [Support](../reference/apis/js-apis-commonEventManager.md#support).
-
+- System common events: defined in CES. Currently, only system applications and system services can publish system common events, such as HAP installation, update, and uninstall. For details about the supported system common events, see [System Common Events](../reference/apis/commonEventManager-definitions.md).
- Custom common events: customized by applications to implement cross-process event communication.
@@ -16,9 +15,7 @@ Common events are also classified into unordered, ordered, and sticky common eve
- Unordered common events: common events that CES forwards regardless of whether subscribers receive the events and when they subscribe to the events.
-
-- Ordered common events: common events that CES forwards based on the subscriber priority. CES forwards common events to the subscriber with lower priority only after receiving a reply from the previous subscriber with higher priority. Subscribers with the same priority receive common events in a random order.
-
+- Ordered common events: common events that CES forwards based on the subscriber priority. CES preferentially forwards an ordered common event to the subscriber with higher priority, waits until the subscriber receives the event, and then forwards the events to the subscriber with lower priority. Subscribers with the same priority receive common events in a random order.
- Sticky common events: common events that can be sent to a subscriber before or after they initiate a subscription. Only system applications and system services can send sticky common events, which remain in the system after being sent. The sends must first request the **ohos.permission.COMMONEVENT_STICKY** permission. For details about the configuration, see [Permission Application Guide](../security/accesstoken-guidelines.md#declaring-permissions-in-the-configuration-file).
diff --git a/en/application-dev/application-models/common-event-remove-sticky.md b/en/application-dev/application-models/common-event-remove-sticky.md
index 358cf8ccf912e0c329684ff904207b933713835b..2ad907a9c7962d496f0a791c88a25aaab54a9d25 100644
--- a/en/application-dev/application-models/common-event-remove-sticky.md
+++ b/en/application-dev/application-models/common-event-remove-sticky.md
@@ -1,4 +1,4 @@
-# Removing Sticky Common Events
+# Removing Sticky Common Events (for System Applications Only)
## When to Use
@@ -16,21 +16,26 @@ For details, see [Common Event](../reference/apis/js-apis-commonEventManager.md)
## How to Develop
-1. Import the module.
-
+1. Request the **ohos.permission.COMMONEVENT_STICKY** permission. For details, see [Declaring Permissions in the Configuration File](../security/accesstoken-guidelines.md#declaring-permissions-in-the-configuration-file).
+
+2. Import the module.
+
```ts
import commonEventManager from '@ohos.commonEventManager';
```
-2. The sticky common event to be removed must have been released by the application. For details about how to release sticky common events, see [Publishing Common Events](common-event-publish.md).
+3. Call the [removeStickyCommonEvent()](../reference/apis/js-apis-commonEventManager.md#commoneventmanagerremovestickycommonevent10) API to remove the target sticky common event.
+
+ > **NOTE**
+ >
+ > The sticky common event to be removed must have been released by the application. For details about how to release sticky common events, see [Publishing Common Events](common-event-publish.md).
```ts
- CommonEventManager.removeStickyCommonEvent("sticky_event", (err) => { // sticky_event indicates the name of the sticky common event to remove.
- if (err) {
- console.info(`Remove sticky event AsyncCallback failed, errCode: ${err.code}, errMes: ${err.message}`);
- return;
- }
- console.info(`Remove sticky event AsyncCallback success`);
- }
+ commonEventManager.removeStickyCommonEvent("sticky_event", (err) => { // sticky_event indicates the name of the target sticky common event.
+ if (err) {
+ console.error(`Failed to remove sticky common event. Code is ${err.code}, message is ${err.message}`);
+ return;
+ }
+ console.info(`Succeeded in removeing sticky event.`);
});
```
diff --git a/en/application-dev/application-models/common-event-static-subscription.md b/en/application-dev/application-models/common-event-static-subscription.md
index 53e014abe38ac3f8ec89fe8a21dc9280184a280b..7005c86ae2e29eb7c635f55b5da05f658ccd8360 100644
--- a/en/application-dev/application-models/common-event-static-subscription.md
+++ b/en/application-dev/application-models/common-event-static-subscription.md
@@ -2,38 +2,46 @@
## When to Use
-A static subscriber is started once it receives a target event published by the system or application. At the same time, the **onReceiveEvent** callback is triggered, in which you can implement the service logic. For example, if an application needs to execute some initialization tasks during device power-on, the application can subscribe to the power-on event in static mode. After receiving the power-on event, the application is started to execute the initialization tasks. Subscribing to a common event in static mode is achieved by configuring a declaration file and implementing a class that inherits from **StaticSubscriberExtensionAbility**. Note that this subscribing mode has negative impact on system power consumption. Therefore, exercise caution when using this mode.
+A static subscriber is started once it receives a target event published by the system or application. At the same time, the [onReceiveEvent()](../reference/apis/js-apis-application-staticSubscriberExtensionAbility.md#staticsubscriberextensionabilityonreceiveevent) callback is triggered.
+
+You can implement the service logic in the [onReceiveEvent()](../reference/apis/js-apis-application-staticSubscriberExtensionAbility.md#staticsubscriberextensionabilityonreceiveevent) callback. For example, if an application needs to execute some initialization tasks during device power-on, the application can subscribe to the power-on event in static mode. After receiving the power-on event, the application is started to execute the initialization tasks.
+
+Subscribing to a common event in static mode is achieved by configuring a declaration file and implementing a class that inherits from [StaticSubscriberExtensionAbility](../reference/apis/js-apis-application-staticSubscriberExtensionAbility.md).
+
+> **NOTE**
+>
+> The static subscription mode has negative impact on system power consumption. Therefore, exercise caution when using this mode.
## How to Develop
-1. Declaring a Static Subscriber
+1. Declaring a static subscriber.
- To declare a static subscriber, create an ExtensionAbility, which is derived from the **StaticSubscriberExtensionAbility** class, in the project. The sample code is as follows:
+ To declare a static subscriber, create an ExtensionAbility, which is derived from the **StaticSubscriberExtensionAbility** class, in the project.
+
+ You can implement service logic in the **onReceiveEvent()** callback.
```ts
import StaticSubscriberExtensionAbility from '@ohos.application.StaticSubscriberExtensionAbility'
export default class StaticSubscriber extends StaticSubscriberExtensionAbility {
- onReceiveEvent(event) {
- console.log('onReceiveEvent, event:' + event.event);
- }
+ onReceiveEvent(event) {
+ console.info('onReceiveEvent, event: ' + event.event);
+ }
}
```
- You can implement service logic in the **onReceiveEvent** callback.
-
-2. Project Configuration for a Static Subscriber
+2. Configure static subscriber settings.
- After writing the static subscriber code, configure the subscriber in the **module.json5** file. The configuration format is as follows:
+ After writing the static subscriber code, configure the subscriber in the [module.json5](../quick-start/module-configuration-file.md) file.
```ts
{
"module": {
- ......
+ ...
"extensionAbilities": [
{
"name": "StaticSubscriber",
- "srcEntry": "./ets/StaticSubscriber/StaticSubscriber.ts",
+ "srcEntry": "./ets/staticsubscriber/StaticSubscriber.ts",
"description": "$string:StaticSubscriber_desc",
"icon": "$media:icon",
"label": "$string:StaticSubscriber_label",
@@ -47,14 +55,14 @@ A static subscriber is started once it receives a target event published by the
]
}
]
- ......
+ ...
}
}
```
- Pay attention to the following fields in the JSON file:
+ Some fields in the file are described as follows:
- - **srcEntry**: entry file path of the ExtensionAbility, that is, the file path of the static subscriber declared in Step 2.
+ - **srcEntry **: entry file path of the ExtensionAbility, that is, the file path of the static subscriber declared in Step 2.
- **type**: ExtensionAbility type. For a static subscriber, set this field to **staticSubscriber**.
@@ -62,42 +70,46 @@ A static subscriber is started once it receives a target event published by the
- **name**: name of the ExtensionAbility. For a static subscriber, declare the name as **ohos.extension.staticSubscriber** for successful identification.
- **resource**: path that stores the ExtensionAbility configuration, which is customizable. In this example, the path is **resources/base/profile/subscribe.json**.
- A level-2 configuration file pointed to by **metadata** must be in the following format:
- ```ts
- {
- "commonEvents": [
- {
- "name": "xxx",
- "permission": "xxx",
- "events":[
- "xxx"
- ]
- }
- ]
- }
- ```
+3. Configure the level-2 configuration file to which the metadata points.
- If the level-2 configuration file is not declared in this format, the file cannot be identified. The fields are described as follows:
+ ```json
+ {
+ "commonEvents": [
+ {
+ "name": "xxx",
+ "permission": "xxx",
+ "events":[
+ "xxx"
+ ]
+ }
+ ]
+ }
+ ```
- - **name**: name of the ExtensionAbility, which must be the same as the name of **extensionAbility** declared in **module.json5**.
+ If the level-2 configuration file is not declared in this format, the file cannot be identified. Some fields in the file are described as follows:
- - **permission**: permission required for the publisher. If a publisher without the required permission attempts to publish an event, the event is regarded as invalid and will not be published.
+ - **name**: name of the ExtensionAbility, which must be the same as the name of **extensionAbility** declared in **module.json5**.
+ - **permission**: permission required for the publisher. If a publisher without the required permission attempts to publish an event, the event is regarded as invalid and will not be published.
+ - **events**: list of target events to subscribe to.
- - **events**: list of target events to subscribe to.
+4. Modify the [preset configuration file](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568/preinstall-config/install_list_permissions.json) of the device, that is, the **/system/etc/app/install_list_permission.json** file on the device. When the device is started, this file is read. During application installation, the common event type specified by **allowCommonEvent** in the file is authorized. The **install_list_permission.json** file contains the following fields:
-3. Device System Configuration
+ - **bundleName**: bundle name of the application.
+ - **app_signature**: fingerprint information of the application. For details, see [Application Privilege Configuration Guide](../../device-dev/subsystems/subsys-app-privilege-config-guide.md#configuration-in-install_list_capabilityjson).
+ - **allowCommonEvent**: type of common event that can be started by static broadcast.
- In the device system configuration file **/system/etc/app/install_list_capability.json**, add the bundle name of the static subscriber.
+ > **NOTE**
+ >
+ > The **install_list_permissions.json** file is available only for preinstalled applications.
- ```json
- {
- "install_list": [
- {
- "bundleName": "ohos.extension.staticSubscriber",
- "allowCommonEvent": ["usual.event.A", "usual.event.B"],
- }
- ]
- }
+ ```json
+ [
+ {
+ "bundleName": "com.example.myapplication",
+ "app_signature": ["****"],
+ "allowCommonEvent": ["usual.event.A", "usual.event.B"]
+ }
+ ]
```
diff --git a/en/application-dev/application-models/common-event-subscription-overview.md b/en/application-dev/application-models/common-event-subscription-overview.md
index 20064af92d3df2e6f7ab7d62c4f71f911848057a..262f30c87e6018fed4e417a196dcaeeb58e42ae2 100644
--- a/en/application-dev/application-models/common-event-subscription-overview.md
+++ b/en/application-dev/application-models/common-event-subscription-overview.md
@@ -1,7 +1,7 @@
# Common Event Subscription Overview
-The common event service provides two subscription modes: dynamic and static. The biggest difference between these two modes is that dynamic subscription requires the application to be running, while static subscription does not.
+The common event service provides two subscription modes: dynamic and static. The biggest difference between these two modes is that dynamic subscription requires the application to be running, while static subscription does not.
- In dynamic subscription mode, a subscriber subscribes to common events by calling an API during the running period. For details, see [Subscribing to Common Events in Dynamic Mode](common-event-subscription.md).
-- In static subscription mode, a subscriber subscribes to common events by configuring a declaration file and implementing a class that inherits from StaticSubscriberExtensionAbility. For details, see [Subscribing to Common Events in Static Mode](common-event-static-subscription.md).
+- In static subscription mode, a subscriber subscribes to common events by configuring a declaration file and implementing a class that inherits from **StaticSubscriberExtensionAbility**. For details, see [Subscribing to Common Events in Static Mode](common-event-static-subscription.md).
diff --git a/en/application-dev/application-models/common-event-subscription.md b/en/application-dev/application-models/common-event-subscription.md
index 6cdc52ef9b798e48a911892f965db8fbf2aaa67f..c3e3ebfa52415d5e0ebade26973f78a589fb348f 100644
--- a/en/application-dev/application-models/common-event-subscription.md
+++ b/en/application-dev/application-models/common-event-subscription.md
@@ -32,7 +32,7 @@ For details about the APIs, see [API Reference](../reference/apis/js-apis-common
let subscriber = null;
// Subscriber information.
let subscribeInfo = {
- events: ["usual.event.SCREEN_OFF"], // Subscribe to the common event screen-off.
+ events: ["usual.event.SCREEN_OFF"], // Subscribe to the common event screen-off.
}
```
@@ -41,13 +41,13 @@ For details about the APIs, see [API Reference](../reference/apis/js-apis-common
```ts
// Callback for subscriber creation.
commonEventManager.createSubscriber(subscribeInfo, (err, data) => {
- if (err) {
- console.error(`[CommonEvent] CreateSubscriberCallBack err=${JSON.stringify(err)}`);
- } else {
- console.info(`[CommonEvent] CreateSubscriber success`);
- subscriber = data;
- // Callback for common event subscription.
- }
+ if (err) {
+ console.error(`Failed to create subscriber. Code is ${err.code}, message is ${err.message}`);
+ return;
+ }
+ console.info('Succeeded in creating subscriber.');
+ subscriber = data;
+ // Callback for common event subscription.
})
```
@@ -56,14 +56,13 @@ For details about the APIs, see [API Reference](../reference/apis/js-apis-common
```ts
// Callback for common event subscription.
if (subscriber !== null) {
- commonEventManager.subscribe(subscriber, (err, data) => {
- if (err) {
- console.error(`[CommonEvent] SubscribeCallBack err=${JSON.stringify(err)}`);
- } else {
- console.info(`[CommonEvent] SubscribeCallBack data=${JSON.stringify(data)}`);
- }
- })
+ commonEventManager.subscribe(subscriber, (err, data) => {
+ if (err) {
+ console.error(`Failed to subscribe common event. Code is ${err.code}, message is ${err.message}`);
+ return;
+ }
+ })
} else {
- console.error(`[CommonEvent] Need create subscriber`);
+ console.error(`Need create subscriber`);
}
```
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.

## 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/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

### 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
- 
+
+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/AccessibilityFramework.png b/en/application-dev/application-models/figures/AccessibilityFramework.png
new file mode 100644
index 0000000000000000000000000000000000000000..786233e6ac160972f62b9786397eb077f7ee767c
Binary files /dev/null and b/en/application-dev/application-models/figures/AccessibilityFramework.png differ
diff --git a/en/application-dev/application-models/figures/WidgetCanvasDemo.jpeg b/en/application-dev/application-models/figures/WidgetCanvasDemo.jpeg
deleted file mode 100644
index 9c797ff4575ae0aaf9aad27ae5d4d701181faf97..0000000000000000000000000000000000000000
Binary files a/en/application-dev/application-models/figures/WidgetCanvasDemo.jpeg and /dev/null differ
diff --git a/en/application-dev/application-models/figures/WidgetCanvasDemo.png b/en/application-dev/application-models/figures/WidgetCanvasDemo.png
new file mode 100644
index 0000000000000000000000000000000000000000..c09c82dd88cf002020990b5b8327701c445eeaaf
Binary files /dev/null and b/en/application-dev/application-models/figures/WidgetCanvasDemo.png differ
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/inputmethodextentionability.md b/en/application-dev/application-models/inputmethodextentionability.md
index 2b3910707ecdb6f964822380a85b14857ec8fd29..b36cf2a050cd15c1d4047410406ed46343f604e5 100644
--- a/en/application-dev/application-models/inputmethodextentionability.md
+++ b/en/application-dev/application-models/inputmethodextentionability.md
@@ -1,11 +1,11 @@
# InputMethodExtensionAbility Development
-[InputMethodExtensionAbility](../reference/apis/js-apis-inputmethod-extension-ability.md) is an ExtensionAbility component of the inputMethod type that provides extension capabilities for the input method framework.
+## When to Use
+[InputMethodExtensionAbility](../reference/apis/js-apis-inputmethod-extension-ability.md), inherited from [ExtensionAbility](extensionability-overview.md), is used for developing input method applications.
-InputMethodExtensionAbility can be started or connected by other application components to process transactions in the background based on the request of the caller.
+The entire lifecycle of the [InputMethodExtensionAbility](../reference/apis/js-apis-inputmethod-extension-ability.md) instance and the owning ExtensionAbility process is scheduled and managed by the input method framework. The input method framework provides the [InputMethodExtensionAbility](../reference/apis/js-apis-inputmethod-extension-ability.md) base class. Derive this base class to implement initialization and resource clearing.
-
-InputMethodExtensionAbility provides related capabilities through the [InputMethodExtensionContext](../reference/apis/js-apis-inputmethod-extension-context.md).
+[InputMethodExtensionAbility](../reference/apis/js-apis-inputmethod-extension-ability.md) provides related capabilities through [InputMethodExtensionContext](../reference/apis/js-apis-inputmethod-extension-context.md).
## Implementing an Input Method Application
@@ -13,15 +13,13 @@ InputMethodExtensionAbility provides related capabilities through the [InputMeth
InputMethodExtensionAbility provides the **onCreate()** and **onDestory()** callbacks, as described below. Override them as required.
- **onCreate**
-
This callback is triggered when a service is created for the first time. You can perform initialization operations, for example, registering a common event listener.
-
+
> **NOTE**
>
> If a service has been created, starting it again does not trigger the **onCreate()** callback.
-
+
- **onDestroy**
-
This callback is triggered when the service is no longer used and the instance is ready for destruction. You can clear resources in this callback, for example, deregister the listener.
@@ -29,7 +27,7 @@ InputMethodExtensionAbility provides the **onCreate()** and **onDestory()** call
To implement an input method application, manually create an InputMethodExtensionAbility component in DevEco Studio. The procedure is as follows:
-In the **ets** directory of the target module, right-click and choose **New** > **Extention Ability** > **InputMethod** to a minimum template of InputMethodExtensionAbility.
+In the **ets** directory of the target module, right-click and choose **New** > **Extension Ability** > **InputMethod** to a minimum template of InputMethodExtensionAbility.
> **NOTE**
>
@@ -70,7 +68,7 @@ The minimum template contains four files: **KeyboardController.ts**, **InputMeth
onDestroy() {
console.log("onDestroy.");
- this.context.destroy();
+ this.keyboardController.onDestroy(); // Destroy the window and deregister the event listener.
}
}
```
@@ -109,7 +107,6 @@ The minimum template contains four files: **KeyboardController.ts**, **InputMeth
this.unRegisterListener(); // Deregister the event listener.
let win = windowManager.findWindow(this.windowName);
win.destroyWindow(); // Destroy the window.
- this.mContext.terminateSelf(); // Terminate the InputMethodExtensionAbility service.
}
private initWindow(): void // Initialize the window.
@@ -159,7 +156,7 @@ The minimum template contains four files: **KeyboardController.ts**, **InputMeth
})
globalThis.inputAbility.on('inputStop', (imeId) => {
if (imeId == "Bundle name/Ability name") {
- this.onDestroy();
+ this.mContext.destroy(); // Destroy the InputMethodExtensionAbility service.
}
});
}
@@ -233,7 +230,7 @@ The minimum template contains four files: **KeyboardController.ts**, **InputMeth
Add the path to this file to the **src** field in the **resources/base/profile/main_pages.json** file.
- ```ts
+ ```ets
import { numberSourceListData, sourceListType } from './keyboardKeyData'
@Component
@@ -342,12 +339,12 @@ The minimum template contains four files: **KeyboardController.ts**, **InputMeth
}
```
- Register the InputMethodExtensionAbility in the [module.json5 file](../quick-start/module-configuration-file.md) corresponding to the target module. Set **type** to **"inputMethod"** and **srcEntry** to the code path of the InputMethodExtensionAbility component.
+5. Register the InputMethodExtensionAbility in the [module.json5 file](../quick-start/module-configuration-file.md) corresponding to the **Module** project. Set **type** to **"inputMethod"** and **srcEntry** to the code path of the InputMethodExtensionAbility component.
```ts
{
"module": {
- // ...
+ ...
"extensionAbilities": [
{
"description": "inputMethod",
@@ -364,3 +361,47 @@ The minimum template contains four files: **KeyboardController.ts**, **InputMeth
+## Restrictions
+
+To reduce the risk of abuse of the InputMethodExtensionAbility by third-party applications, the invoking of APIs in the following modules is restricted in the InputMethodExtensionAbility:
+
+> **NOTE**
+>
+> - If a restricted module is imported, no error is reported during compilation, but an incorrect value (**undefined**) is returned during running. As a result, the module does not take effect.
+> - Currently, access to the [@ohos.multimedia.audio (Audio Management)](../reference/apis/js-apis-audio.md) module is allowed, with compliance with the following rules:
+> - Users who deny the recording permission should still be allowed to use the non-voice-input features of the input method application.
+> - Recording-related services are allowed only when the InputMethodExtensionAbility is in the foreground. For example, perform recording only when the soft keyboard is in the foreground and the user is proactively using the voice input method; stop recording when the application is switched to the background.
+> - Applications will see increasingly stringent measures against violations with the preceding rules, and any violation may result in function exceptions.
+
+**Restricted modules:**
+
+- [@ohos.ability.featureAbility (FeatureAbility)](../reference/apis/js-apis-ability-featureAbility.md)
+- [@ohos.ability.particleAbility (ParticleAbility)](../reference/apis/js-apis-ability-particleAbility.md)
+- [@ohos.account.distributedAccount (Distributed Account Management)](../reference/apis/js-apis-distributed-account.md)
+- [@ohos.backgroundTaskManager (Background Task Management)](../reference/apis/js-apis-backgroundTaskManager.md)
+- [@ohos.bluetooth (Bluetooth)](../reference/apis/js-apis-bluetooth.md)
+- [@ohos.bluetoothManager (Bluetooth)](../reference/apis/js-apis-bluetoothManager.md)
+- [@ohos.connectedTag (Active Tags)](../reference/apis/js-apis-connectedTag.md)
+- [@ohos.geolocation (Geolocation)](../reference/apis/js-apis-geolocation.md)
+- [@ohos.geoLocationManager (Geolocation Manager)](../reference/apis/js-apis-geoLocationManager.md)
+- [@ohos.nfc.cardEmulation (Standard NFC Card Emulation)](../reference/apis/js-apis-cardEmulation.md)
+- [@ohos.nfc.controller (Standard NFC)](../reference/apis/js-apis-nfcController.md)
+- [@ohos.nfc.tag (Standard NFC Tags)](../reference/apis/js-apis-nfcTag.md)
+- [@ohos.reminderAgent (Reminder Agent)](../reference/apis/js-apis-reminderAgent.md)
+- [@ohos.reminderAgentManager (reminderAgentManager)](../reference/apis/js-apis-reminderAgentManager.md)
+- [@ohos.sensor (Sensor)](../reference/apis/js-apis-sensor.md)
+- [@ohos.telephony.call (Call)](../reference/apis/js-apis-call.md)
+- [@ohos.telephony.data (Cellular Data)](../reference/apis/js-apis-telephony-data.md)
+- [@ohos.telephony.observer (observer)](../reference/apis/js-apis-observer.md)
+- [@ohos.telephony.radio (Network Search)](../reference/apis/js-apis-radio.md)
+- [@ohos.telephony.sim (SIM Management)](../reference/apis/js-apis-sim.md)
+- [@ohos.telephony.sms (SMS)](../reference/apis/js-apis-sms.md)
+- [@ohos.wallpaper (Wallpaper)](../reference/apis/js-apis-wallpaper.md)
+- [@ohos.wifiext (WLAN Extension)](../reference/apis/js-apis-wifiext.md)
+- [@ohos.wifiManager (WLAN)](../reference/apis/js-apis-wifiManager.md)
+- [@ohos.wifiManagerExt (WLAN Extension Interface)](../reference/apis/js-apis-wifiManagerExt.md)
+- [@system.geolocation (Geolocation)](../reference/apis/js-apis-system-location.md)
+- [nfctech (Standard NFC Technologies)](../reference/apis/js-apis-nfctech.md)
+- [tagSession (Standard NFC Tag Session)](../reference/apis/js-apis-tagSession.md)
+
+
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-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
+

- 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/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/service-widget-overview.md b/en/application-dev/application-models/service-widget-overview.md
index 3739129f2a07765b2ebe015910d1d6e3d8d721d0..528d9d4c134107c30de75f7f9e84ab42be514224 100644
--- a/en/application-dev/application-models/service-widget-overview.md
+++ b/en/application-dev/application-models/service-widget-overview.md
@@ -6,7 +6,7 @@ A service widget (also called widget) is a set of UI components that display imp
## Service Widget Architecture
- **Figure 1** Service widget architecture
+**Figure 1** Service widget architecture

@@ -24,7 +24,7 @@ Before you get started, it would be helpful if you have a basic understanding of
Below is the typical procedure of using the widget:
- **Figure 2** Typical procedure of using the widget
+**Figure 2** Typical procedure of using the widget

@@ -55,4 +55,4 @@ ArkTS widgets and JS widgets have different implementation principles and featur
| Custom drawing| Not supported| Supported|
| Logic code execution (excluding the import capability)| Not supported| Supported|
-As can be seen above, ArkTS widgets have more capabilities and use cases than JS widgets. Therefore, ArkTS widgets are always recommended, except for the case where the widget consists of only static pages.
+As can be seen above, ArkTS widgets provide more capabilities and use cases than JS widgets. Therefore, ArkTS widgets are always recommended, except for the case where the widget consists of only static pages.
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
+

- **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-stage.md b/en/application-dev/application-models/thread-model-stage.md
index 7343b9b619a5d68354e65e254a22a2b078ca44ee..2b1f855980a14eeba89a18184c69d46eebaea6ac 100644
--- a/en/application-dev/application-models/thread-model-stage.md
+++ b/en/application-dev/application-models/thread-model-stage.md
@@ -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
-
- 
+
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

- 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.

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.
+

## 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
- 
+
- 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
+

> **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
+

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
-
+
## 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
-
-
+**Figure 2** WindowStageCreate and WindowStageDestory
+
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
+

## 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

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/connectivity/Readme-EN.md b/en/application-dev/connectivity/Readme-EN.md
index 59df854e8a37289cc9dcf55ed2f7d8110a7c84d0..c09ca21b6d0814bd1cd2cecb95b0d2896fada8c4 100755
--- a/en/application-dev/connectivity/Readme-EN.md
+++ b/en/application-dev/connectivity/Readme-EN.md
@@ -5,7 +5,6 @@
- [HTTP Data Request](http-request.md)
- [WebSocket Connection](websocket-connection.md)
- [Socket Connection](socket-connection.md)
- - [Network Policy Management](net-policy-management.md)
- [Network Sharing](net-sharing.md)
- [Ethernet Connection](net-ethernet.md)
- [Network Connection Management](net-connection-manager.md)
diff --git a/en/application-dev/connectivity/net-connection-manager.md b/en/application-dev/connectivity/net-connection-manager.md
index 5ee75a717882c3344612e741b2e197fa6e57509d..c443c93759caddbc5203b65022426882c0bb960b 100644
--- a/en/application-dev/connectivity/net-connection-manager.md
+++ b/en/application-dev/connectivity/net-connection-manager.md
@@ -39,7 +39,7 @@ For the complete list of APIs and example code, see [Network Connection Manageme
| ---- | ---- | ---- |
| ohos.net.connection | function getDefaultNet(callback: AsyncCallback\): void; |Creates a **NetHandle** object that contains the **netId** of the default network. This API uses an asynchronous callback to return the result.|
| ohos.net.connection | function getGlobalHttpProxy10+(callback: AsyncCallback\): void;| Obtains the global HTTP proxy for the network. This API uses an asynchronous callback to return the result.|
-| ohos.net.connection | function setGlobalHttpProxy10+(httpProxy: HttpProxy, callback: AsyncCallback): void;| Sets the global HTTP proxy for the network. This API uses an asynchronous callback to return the result.|
+| ohos.net.connection | function setGlobalHttpProxy10+(httpProxy: HttpProxy, callback: AsyncCallback\): void;| Sets the global HTTP proxy for the network. This API uses an asynchronous callback to return the result.|
| ohos.net.connection | function getAppNet9+(callback: AsyncCallback\): void;| Obtains a **NetHandle** object that contains the **netId** of the network bound to the application. This API uses an asynchronous callback to return the result.|
| ohos.net.connection | function setAppNet9+(netHandle: NetHandle, callback: AsyncCallback\): void;| Binds an application to the specified network. The application can access the external network only through this network. This API uses an asynchronous callback to return the result.|
| ohos.net.connection | function getDefaultNetSync9+(): NetHandle; |Obtains the default active data network in synchronous mode. You can use **getNetCapabilities** to obtain information such as the network type and capabilities.|
@@ -47,7 +47,7 @@ For the complete list of APIs and example code, see [Network Connection Manageme
| ohos.net.connection | function getAllNets(callback: AsyncCallback\>): void;| Obtains the list of **NetHandle** objects of the connected network. This API uses an asynchronous callback to return the result.|
| ohos.net.connection | function getConnectionProperties(netHandle: NetHandle, callback: AsyncCallback\): void; |Obtains link information of the default network. This API uses an asynchronous callback to return the result.|
| ohos.net.connection | function getNetCapabilities(netHandle: NetHandle, callback: AsyncCallback\): void; |Obtains the capability set of the default network. This API uses an asynchronous callback to return the result.|
-| ohos.net.connection | function isDefaultNetMetered9+(callback: AsyncCallback): void; |Checks whether the data traffic usage on the current network is metered. This API uses an asynchronous callback to return the result.|
+| ohos.net.connection | function isDefaultNetMetered9+(callback: AsyncCallback\): void; |Checks whether the data traffic usage on the current network is metered. This API uses an asynchronous callback to return the result.|
| ohos.net.connection | function reportNetConnected(netHandle: NetHandle, callback: AsyncCallback\): void;| Reports a **netAavailable** event to NetManager. If this API is called, the application considers that its network status (ohos.net.connection.NetCap.NET_CAPABILITY_VAILDATED) is inconsistent with that of NetManager. This API uses an asynchronous callback to return the result.|
| ohos.net.connection | function reportNetDisconnected(netHandle: NetHandle, callback: AsyncCallback\): void;| Reports a **netAavailable** event to NetManager. If this API is called, the application considers that its network status (ohos.net.connection.NetCap.NET_CAPABILITY_VAILDATED) is inconsistent with that of NetManager. This API uses an asynchronous callback to return the result.|
| ohos.net.connection | function getAddressesByName(host: string, callback: AsyncCallback\>): void; |Obtains all IP addresses of the specified network by resolving the domain name. This API uses an asynchronous callback to return the result.|
diff --git a/en/application-dev/connectivity/net-mgmt-overview.md b/en/application-dev/connectivity/net-mgmt-overview.md
index 043d41768f89dd851839eae893b7ba4409395f5e..f03d7668edc9fc27ef22c4ef4d69b186f7b4c3d9 100644
--- a/en/application-dev/connectivity/net-mgmt-overview.md
+++ b/en/application-dev/connectivity/net-mgmt-overview.md
@@ -5,7 +5,6 @@ Network management functions include:
- [HTTP data request](http-request.md): initiates a data request through HTTP.
- [WebSocket connection](websocket-connection.md): establishes a bidirectional connection between the server and client through WebSocket.
- [Socket connection](socket-connection.md): transmits data through Socket.
-- [Network policy management](net-policy-management.md): restricts network capabilities by setting network policies, including cellular network policy, sleep/power-saving mode policy, and background network policy, and resets network policies as needed.
- [Network sharing](net-sharing.md): shares a device's Internet connection with other connected devices by means of Wi-Fi hotspot, Bluetooth, and USB sharing, and queries the network sharing state and shared mobile data volume.
- [Ethernet connection](net-ethernet.md): provides wired network capabilities, which allow you to set the IP address, subnet mask, gateway, and Domain Name System (DNS) server of a wired network.
- [Network connection management](net-connection-manager.md): provides basic network management capabilities, including management of Wi-Fi/cellular/Ethernet connection priorities, network quality evaluation, subscription to network connection status changes, query of network connection information, and DNS resolution.
diff --git a/en/application-dev/connectivity/net-policy-management.md b/en/application-dev/connectivity/net-policy-management.md
deleted file mode 100644
index 6450bd671e565fdffafb7eeed499e123893a45a3..0000000000000000000000000000000000000000
--- a/en/application-dev/connectivity/net-policy-management.md
+++ /dev/null
@@ -1,402 +0,0 @@
-# Network Policy Management
-
-## Introduction
-
-The Network Policy Management module allows you to restrict network capabilities by setting network policies, including cellular network policy, sleep/power-saving mode policy, and background network policy, and to reset network policies as needed.
-
-> **NOTE**
-> To maximize the application running efficiency, most API calls are called asynchronously in callback or promise mode. The following code examples use the callback mode. For details about the APIs, see [sms API Reference](../reference/apis/js-apis-net-policy.md).
-
-## Basic Concepts
-
-- Sleep mode: A mode in which the system shuts down some idle components and peripherals to enter the low-power mode and restricts some applications from accessing the network.
-- Power-saving mode: A mode in which the system disables certain functions and features to save power. When this mode is enabled, the system performance deteriorates and some applications are restricted from accessing the network.
-- Traffic-saving mode: A mode in which the system restricts background applications that use the metering network. It is equivalent to the background network policy.
-- Cellular network: A mobile communication network.
-- Metering network: A mobile network with preconfigured traffic quota, WLAN network, or Ethernet network.
-
-## **Constraints**
-
-- Programming language: C++ and JS
-- System: Linux kernel
-- The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
-
-## When to Use
-
-Typical application scenarios of network policy management are as follows:
-
-- Managing the metering network policy: Set the metering network quota and obtain the configured metering network policy.
-- Managing network access for an application in the background: Set and obtain the status of the background network restriction switch, and check whether the application indicated by the specified UID can access the network in the background.
-- Managing the metering network access policy: Set and obtain the policy for the application indicated by the specified UID to access the metering network, and obtain the UIDs of the applications for which the policy is configured.
-- Restoring network policies
-- Checking whether an application indicated by the specified UID can access a metering or non-metering network
-- Adding a UID to or removing a UID from the sleep mode allowlist, and obtaining the sleep mode allowlist
-- Adding a UID to or removing a UID from the power-saving mode allowlist, and obtaining the power-saving mode allowlist
-- Updating the network notification policy
-
-The following describes the development procedure specific to each application scenario.
-
-## Available APIs
-
-For the complete list of APIs and example code, see [Network Policy Management](../reference/apis/js-apis-net-policy.md).
-
-| Type| API| Description|
-| ---- | ---- | ---- |
-| ohos.net.policy | function setBackgroundPolicy(isAllowed: boolean, callback: AsyncCallback\): void |Sets a background network policy. This API uses an asynchronous callback to return the result.|
-| ohos.net.policy | function isBackgroundAllowed(callback: AsyncCallback\): void; |Obtains the background network policy. This API uses an asynchronous callback to return the result.|
-| ohos.net.policy | function setPolicyByUid(uid: number, policy: NetUidPolicy, callback: AsyncCallback\): void; |Sets an application-specific network policy by **uid**. This API uses an asynchronous callback to return the result.|
-| ohos.net.policy | function getPolicyByUid(uid: number, callback: AsyncCallback\): void;| Obtains an application-specific network policy by **uid**. This API uses an asynchronous callback to return the result.|
-| ohos.net.policy | function getUidsByPolicy(policy: NetUidPolicy, callback: AsyncCallback\>): void; | Obtains the UID array of applications configured with a certain application-specific network policy. This API uses an asynchronous callback to return the result.|
-| ohos.net.policy | function getNetQuotaPolicies(callback: AsyncCallback\>): void; |Obtains the network quota policies. This API uses an asynchronous callback to return the result.|
-| ohos.net.policy | function setNetQuotaPolicies(quotaPolicies: Array\, callback: AsyncCallback\): void; |Sets an array of network quota policies. This API uses an asynchronous callback to return the result.|
-| ohos.net.policy | function restoreAllPolicies(iccid: string, callback: AsyncCallback\): void; | Restores all the policies (cellular network, background network, firewall, and application-specific network policies) for the given SIM card. This API uses an asynchronous callback to return the result.|
-| ohos.net.policy | function isUidNetAllowed(uid: number, isMetered: boolean, callback: AsyncCallback\): void; | Checks whether an application is allowed to access metering or non-metering networks. This API uses an asynchronous callback to return the result.|
-| ohos.net.policy | function isUidNetAllowed(uid: number, iface: string, callback: AsyncCallback\): void; | Checks whether an application is allowed to access the given network. This API uses an asynchronous callback to return the result.|
-| ohos.net.policy | function setDeviceIdleAllowList(uid: number, isAllowed: boolean, callback: AsyncCallback\): void; | Sets whether to add an application to the device idle allowlist. This API uses an asynchronous callback to return the result.|
-| ohos.net.policy | function getDeviceIdleAllowList(callback: AsyncCallback\>): void; | Obtains the UID array of applications that are on the device idle allowlist. This API uses an asynchronous callback to return the result.|
-| ohos.net.policy | function getBackgroundPolicyByUid(uid: number, callback: AsyncCallback\): void; | Obtains the background network policies configured for the given application. This API uses an asynchronous callback to return the result.|
-| ohos.net.policy | function resetPolicies(iccid: string, callback: AsyncCallback\): void; | Restores all the policies (cellular network, background network, firewall, and application-specific network policies) for the given SIM card. This API uses an asynchronous callback to return the result.|
-| ohos.net.policy | function updateRemindPolicy(netType: NetBearType, iccid: string, remindType: RemindType, callback: AsyncCallback\): void; | Updates a reminder policy. This API uses an asynchronous callback to return the result.|
-| ohos.net.policy | function setPowerSaveAllowList(uid: number, isAllowed: boolean, callback: AsyncCallback\): void; | Sets whether to add an application to the power-saving allowlist. This API uses an asynchronous callback to return the result.|
-| ohos.net.policy | function getPowerSaveAllowList(callback: AsyncCallback\>): void; | Obtains the UID array of applications that are on the power-saving allowlist. This API uses an asynchronous callback to return the result.|
-| ohos.net.policy | function on(type: "netUidPolicyChange", callback: Callback\<{ uid: number, policy: NetUidPolicy }>): void; | Subscribes to policy changes. This API uses an asynchronous callback to return the result.|
-| ohos.net.policy | function off(type: "netUidPolicyChange", callback: Callback\<{ uid: number, policy: NetUidPolicy }>): void; | Unsubscribes from policy changes. This API uses an asynchronous callback to return the result.|
-| ohos.net.policy | function on(type: "netUidRuleChange", callback: Callback\<{ uid: number, rule: NetUidRule }>): void; | Subscribes to rule changes. This API uses an asynchronous callback to return the result.|
-| ohos.net.policy | function off(type: "netUidRuleChange", callback: Callback\<{ uid: number, rule: NetUidRule }>): void; | Unsubscribes from rule changes. This API uses an asynchronous callback to return the result.|
-| ohos.net.policy | function on(type: "netMeteredIfacesChange", callback: Callback\>): void; | Subscribes to metered **iface** changes. This API uses an asynchronous callback to return the result.|
-| ohos.net.policy | function off(type: "netMeteredIfacesChange", callback: Callback\>): void; | Unsubscribes from metered **iface** changes. This API uses an asynchronous callback to return the result.|
-| ohos.net.policy | function on(type: "netQuotaPolicyChange", callback: Callback\>): void; | Subscribes to network quota policy changes. This API uses an asynchronous callback to return the result.|
-| ohos.net.policy | function off(type: "netQuotaPolicyChange", callback: Callback\>): void; | Unsubscribes from network quota policy changes. This API uses an asynchronous callback to return the result.|
-| ohos.net.policy | function on(type: "netBackgroundPolicyChange", callback: Callback\): void; | Subscribes to background network policy changes. This API uses an asynchronous callback to return the result.|
-| ohos.net.policy | function off(type: "netBackgroundPolicyChange", callback: Callback\): void; | Unsubscribes from background network policy changes. This API uses an asynchronous callback to return the result.|
-
-## Managing the Metering Network Policy
-
-1. Import the **policy** namespace from **@ohos.net.policy.d.ts**.
-
-2. Call **setNetQuotaPolicies** to configure the metering network policy.
-
-3. Call **getNetQuotaPolicies** to obtain the configured metering network policy.
-
-```js
- // Import the policy namespace.
- import policy from '@ohos.net.policy';
-
- addNetQuotaPolicy(){
- let param = {
- // For details about the value of netType, see [NetBearType](../reference/apis/js-apis-net-connection.md#netbeartype).
- netType:Number.parseInt(this.netType),
-
- // Integrated circuit card identifier (ICCID) of the SIM card on the metering cellular network. It is not available for an Ethernet or Wi-Fi network.
- iccid:this.iccid,
-
- // Used together with ICCID on the metering cellular network. It is used independently on an Ethernet or Wi-Fi network.
- ident:this.ident,
-
- // Metering start time, for example, M1, D1, and Y1.
- periodDuration:this.periodDuration,
-
- // Set the traffic threshold for generating an alarm to an integer greater than 0.
- warningBytes:Number.parseInt(this.warningBytes),
-
- // Set the traffic quota to an integer greater than 0.
- limitBytes:Number.parseInt(this.limitBytes),
-
- // Specify whether the network is a metering network. The value true means a metering network and false means a non-metering network.
- metered:Boolean(Number.parseInt(this.metered)),https://gitee.com/openharmony/docs/pulls/14404
- // For details about the action triggered after the traffic limit is reached, see [LimitAction](../reference/apis/js-apis-net-policy.md#limitaction).
- limitAction:Number.parseInt(this.limitAction)
- };
- this.netQuotaPolicyList.push(param);
- },
-
- // Subscribe to metered iface changes.
- policy.on('netMeteredIfacesChange', (data) => {
- this.log('on netMeteredIfacesChange: ' + JSON.stringify(data));
- });
-
- // Subscribe to metering network policy changes.
- policy.on('netQuotaPolicyChange', (data) => {
- this.log('on netQuotaPolicyChange: ' + JSON.stringify(data));
- });
-
- // Call setNetQuotaPolicies to configure the metering network policy.
- setNetQuotaPolicies(){
- this.dialogType = DialogType.HIDE;
- policy.setNetQuotaPolicies(this.netQuotaPolicyList, (err, data) => {
- console.log(JSON.stringify(err));
- console.log(JSON.stringify(data));
- });
- },
-
- // Call getNetQuotaPolicies to obtain the configured metering network policy.
- getNetQuotaPolicies(){
- policy.getNetQuotaPolicies((err, data) => {
- this.callBack(err, data);
- if(data){
- this.netQuotaPolicyList = data;
- }
- });
- },
-
- // Unsubscribe from metered iface changes.
- policy.off('netMeteredIfacesChange', (data) => {
- this.log('off netMeteredIfacesChange: ' + JSON.stringify(data));
- });
-
- // Unsubscribe from metering network policy changes.
- policy.off('netQuotaPolicyChange', (data) => {
- this.log('off netQuotaPolicyChange: ' + JSON.stringify(data));
- });
-```
-
-## Managing Network Access for an Application in the Background
-
-### How to Develop
-
-1. Import the **policy** namespace from **@ohos.net.policy.d.ts**.
-
-2. Call **setBackgroundAllowed** to enable or disable the background network restriction switch.
-
-3. Call **isBackgroundAllowed** to check whether the background network restriction switch is enabled or disabled.
-
-4. Call **getBackgroundPolicyByUid** to check whether the application indicated b the specified UID can access the network in the background.
-
-```js
- // Import the policy namespace.
- import policy from '@ohos.net.policy'
-
- // Subscribe to background network policy changes.
- policy.on('netBackgroundPolicyChange', (data) => {
- this.log('on netBackgroundPolicyChange: ' + JSON.stringify(data));
- });
-
- // Call setBackgroundAllowed to enable or disable the background network restriction switch.
- setBackgroundAllowed() {
- policy.setBackgroundAllowed(Boolean(Number.parseInt(this.isBoolean)), (err, data) => {
- console.log(JSON.stringify(err));
- console.log(JSON.stringify(data))
- });
- },
-
- // Call isBackgroundAllowed to check whether the background network restriction switch is enabled or disabled.
- isBackgroundAllowed() {
- policy.isBackgroundAllowed((err, data) => {
- console.log(JSON.stringify(err));
- console.log(JSON.stringify(data))
- });
- },
-
- // Call getBackgroundPolicyByUid to check whether the application indicated b the specified UID can access the network in the background.
- getBackgroundPolicyByUid() {
- policy.getBackgroundPolicyByUid(Number.parseInt(this.firstParam), (err, data) => {
- console.log(JSON.stringify(err));
- console.log(JSON.stringify(data))
- });
- },
-
- // Unsubscribe from background network policy changes.
- policy.off('netBackgroundPolicyChange', (data) => {
- this.log('off netBackgroundPolicyChange: ' + JSON.stringify(data));
- });
-```
-
-## Managing the Metering Network Access Policy
-
-### How to Develop
-
-1. Import the **policy** namespace from **@ohos.net.policy.d.ts**.
-
-2. Call **setPolicyByUid** to set whether the application indicated by the specified UID can access the network in the background.
-
-3. Call **getPolicyByUid** to check whether the metering network access policy for the application indicated by the specified UID.
-
-4. Call **getUidsByPolicy** to obtain the UIDs of the applications for which the metering network access policy is configured.
-
-```js
- // Import the policy namespace.
- import policy from '@ohos.net.policy'
-
- // Subscribe to policy changes of the application indicated by the specified UID.
- policy.on('netUidPolicyChange', (data) => {
- this.log('on netUidPolicyChange: ' + JSON.stringify(data));
- });
-
- // Subscribe to rule changes of the application indicated by the specified UID.
- policy.on('netUidRuleChange', (data) => {
- this.log('on netUidRuleChange: ' + JSON.stringify(data));
- });
-
- // Call setPolicyByUid to set whether the application indicated by the specified UID can access the network in the background.
- setPolicyByUid() {
- let param = {
- uid: Number.parseInt(this.firstParam), policy: Number.parseInt(this.currentNetUidPolicy)
- }
- policy.setPolicyByUid(Number.parseInt(this.firstParam), Number.parseInt(this.currentNetUidPolicy), (err, data) => {
- console.log(JSON.stringify(err));
- console.log(JSON.stringify(data))
- });
- },
-
- // Call getPolicyByUid to check whether the metering network access policy for the application indicated by the specified UID.
- getPolicyByUid() {
- policy.getPolicyByUid(Number.parseInt(this.firstParam), (err, data) => {
- console.log(JSON.stringify(err));
- console.log(JSON.stringify(data))
- });
- },
-
- // Call getUidsByPolicy to obtain the UIDs of the applications for which the metering network access policy is configured.
- getUidsByPolicy(){
- policy.getUidsByPolicy(Number.parseInt(this.currentNetUidPolicy), (err, data) => {
- console.log(JSON.stringify(err));
- console.log(JSON.stringify(data))
- });
- },
-
- // Unsubscribe from policy changes of the application indicated by the specified UID.
- policy.off('netUidPolicyChange', (data) => {
- this.log('off netUidPolicyChange: ' + JSON.stringify(data));
- });
-
- // Unsubscribe from rule changes of the application indicated by the specified UID.
- policy.off('netUidRuleChange', (data) => {
- this.log('off netUidRuleChange: ' + JSON.stringify(data));
- });
-
-```
-
-## Restoring Network Policies
-
-### How to Develop
-
-1. Import the **policy** namespace from **@ohos.net.policy.d.ts**.
-
-2. Call **restoreAllPolicies** to restore all network policies.
-
-```js
- // Import the policy namespace.
- import policy from '@ohos.net.policy'
-
- // Call restoreAllPolicies to restore all network policies.
- restoreAllPolicies(){
- policy.restoreAllPolicies(this.firstParam, (err, data) => {
- console.log(JSON.stringify(err));
- console.log(JSON.stringify(data))
- });
- },
-```
-
-## Checking Access to a Metering or Non-metering Network
-
-### How to Develop
-
-1. Import the **policy** namespace from **@ohos.net.policy.d.ts**.
-
-2. Call **isUidNetAllowed** to check whether the UID can access the metering or non-metering network.
-
-```js
- // Import the policy namespace.
- import policy from '@ohos.net.policy'
-
- // Call isUidNetAllowed to check whether the application indicated by the specified UID can access the metering or non-metering network.
- isUidNetAllowedIsMetered(){
- let param = {
- uid: Number.parseInt(this.firstParam), isMetered: Boolean(Number.parseInt(this.isBoolean))
- }
- policy.isUidNetAllowed(Number.parseInt(this.firstParam), Boolean(Number.parseInt(this.isBoolean)), (err, data) => {
- console.log(JSON.stringify(err));
- console.log(JSON.stringify(data))
- });
- },
-```
-
-## Managing the Sleep Mode Allowlist
-
-### How to Develop
-
-1. Import the **policy** namespace from **@ohos.net.policy.d.ts**.
-
-2. Call **setDeviceIdleAllowList** to add a UID to or remove a UID from the sleep mode allowlist.
-
-3. Call **getDeviceIdleAllowList** to obtain the UIDs added to the sleep mode allowlist.
-
-```js
- // Import the policy namespace.
- import policy from '@ohos.net.policy'
-
- // Call setDeviceIdleAllowList to add a UID to or remove a UID from the sleep mode allowlist.
- setDeviceIdleAllowList(){
- let param = {
- uid: Number.parseInt(this.firstParam), isAllowed: Boolean(Number.parseInt(this.isBoolean))
- }
- policy.setDeviceIdleAllowList(Number.parseInt(this.firstParam), Boolean(Number.parseInt(this.isBoolean)), (err, data) => {
- console.log(JSON.stringify(err));
- console.log(JSON.stringify(data))
- });
- },
-
- // Call getDeviceIdleAllowList to obtain the UIDs added to the sleep mode allowlist.
- getDeviceIdleAllowList(){
- policy.getDeviceIdleAllowList((err, data) => {
- console.log(JSON.stringify(err));
- console.log(JSON.stringify(data))
- });
- },
-```
-
-## Managing the Power-saving Mode Allowlist
-
-### How to Develop
-
-1. Import the **policy** namespace from **@ohos.net.policy.d.ts**.
-2. Call **setPowerSaveAllowList** to add a UID to or remove a UID from the power-saving mode allowlist.
-3. Call **getPowerSaveAllowList** to obtain the UIDs added to the power-saving mode allowlist.
-
-```js
- // Import the policy namespace.
- import policy from '@ohos.net.policy'
-
- // Call setPowerSaveAllowList to add a UID to or remove a UID from the power-saving mode allowlist.
- setPowerSaveAllowList(){
- let param = {
- uid: Number.parseInt(this.firstParam), isAllowed: Boolean(Number.parseInt(this.isBoolean))
- }
- policy.setPowerSaveAllowList(Number.parseInt(this.firstParam), Boolean(Number.parseInt(this.isBoolean)), (err, data) => {
- console.log(JSON.stringify(err));
- console.log(JSON.stringify(data))
- });
- },
-
- // Call getPowerSaveAllowList to obtain the UIDs added to the power-saving mode allowlist.
- getPowerSaveAllowList(){
- policy.getPowerSaveAllowList((err, data) => {
- console.log(JSON.stringify(err));
- console.log(JSON.stringify(data))
- });
- },
-```
-
-## Updating the Network Notification Policy
-
-### How to Develop
-
-1. Import the **policy** namespace from **@ohos.net.policy.d.ts**.
-
-2. Call **updateRemindPolicy** to update the network notification policy.
-
-```js
- // Import the policy namespace.
- import policy from '@ohos.net.policy'
-
- // Call updateRemindPolicy to update the network notification policy.
- updateRemindPolicy() {
- let param = {
- netType: Number.parseInt(this.netType), iccid: this.firstParam, remindType: this.currentRemindType
- }
- policy.updateRemindPolicy(Number.parseInt(this.netType), this.firstParam, Number.parseInt(this.currentRemindType), (err, data) => {
- console.log(JSON.stringify(err));
- console.log(JSON.stringify(data))
- });
- },
-```
diff --git a/en/application-dev/device/usb-guidelines.md b/en/application-dev/device/usb-guidelines.md
index 68c8c3de013e75d56854bf0cf0e3a71aca9eb261..ef09e1ee89940220f8b9d1936362d34ebf8bf7a6 100644
--- a/en/application-dev/device/usb-guidelines.md
+++ b/en/application-dev/device/usb-guidelines.md
@@ -1,156 +1,161 @@
# USB Service Development
+
## When to Use
In Host mode, you can obtain the list of connected USB devices, enable or disable the devices, manage device access permissions, and perform data transfer or control transfer.
-## APIs
+
+## Available APIs
The USB service provides the following functions: query of USB device list, bulk data transfer, control transfer, and access permission management.
The following table lists the USB APIs currently available. For details, see the [API Reference](../reference/apis/js-apis-usbManager.md).
-**Table 1** Open USB APIs
+**Table 1** Open USB APIs
-| API | Description |
+| Name | Description |
| ------------------------------------------------------------ | ------------------------------------------------------------ |
-| hasRight(deviceName: string): boolean | Checks whether the user has the device access permissions. |
-| requestRight(deviceName: string): Promise\ | Requests the temporary permission for a given application to access the USB device. This API uses a promise to return the result. |
-| connectDevice(device: USBDevice): Readonly\ | Connects to the USB device based on the device list returned by `getDevices()`. |
-| getDevices(): Array> | Obtains the list of USB devices connected to the USB host. If no USB device is connected, an empty list is returned. |
-| setConfiguration(pipe: USBDevicePipe, config: USBConfiguration): number | Sets the USB device configuration. |
-| setInterface(pipe: USBDevicePipe, iface: USBInterface): number | Sets a USB interface. |
-| claimInterface(pipe: USBDevicePipe, iface: USBInterface, force ?: boolean): number | Claims a USB interface. |
-| bulkTransfer(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, timeout ?: number): Promise\ | Performs bulk transfer. |
-| closePipe(pipe: USBDevicePipe): number | Closes a USB device pipe. |
-| releaseInterface(pipe: USBDevicePipe, iface: USBInterface): number | Releases a USB interface. |
-| getFileDescriptor(pipe: USBDevicePipe): number | Obtains the file descriptor. |
-| getRawDescriptor(pipe: USBDevicePipe): Uint8Array | Obtains the raw USB descriptor. |
-| controlTransfer(pipe: USBDevicePipe, controlparam: USBControlParams, timeout ?: number): Promise<number> | Performs control transfer. |
+| hasRight(deviceName: string): boolean | Checks whether the user has the device access permissions.|
+| requestRight(deviceName: string): Promise<boolean> | Requests the device access permissions for the application. This API uses a promise to return the result. |
+| removeRight(deviceName: string): boolean | Revokes the device access permissions of the application.|
+| connectDevice(device: USBDevice): Readonly<USBDevicePipe> | Connects to the USB device based on the device information returned by `getDevices()`. |
+| getDevices(): Array<Readonly<USBDevice>> | Obtains the list of USB devices connected to the host. If no device is connected, an empty list is returned. |
+| setConfiguration(pipe: USBDevicePipe, config: USBConfiguration): number | Sets the USB device configuration. |
+| setInterface(pipe: USBDevicePipe, iface: USBInterface): number | Sets a USB interface. |
+| claimInterface(pipe: USBDevicePipe, iface: USBInterface, force ?: boolean): number | Claims a USB interface. |
+| bulkTransfer(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, timeout ?: number): Promise<number> | Performs bulk transfer. |
+| closePipe(pipe: USBDevicePipe): number | Closes a USB device pipe. |
+| releaseInterface(pipe: USBDevicePipe, iface: USBInterface): number | Releases a USB interface. |
+| getFileDescriptor(pipe: USBDevicePipe): number | Obtains the file descriptor. |
+| getRawDescriptor(pipe: USBDevicePipe): Uint8Array | Obtains the raw USB descriptor. |
+| controlTransfer(pipe: USBDevicePipe, controlparam: USBControlParams, timeout ?: number): Promise<number> | Performs control transfer. |
+
## How to Develop
-You can set a USB device as the USB host to connect to other USB devices for data transfer. The development procedure is as follows:
-
-1. Obtain the USB device list.
-
- ```js
- // Import the USB API package.
- import usb from '@ohos.usbManager';
- // Obtain the USB device list.
- let deviceList = usb.getDevices();
- /*
- Example deviceList structure
- [
- {
- name: "1-1",
- serial: "",
- manufacturerName: "",
- productName: "",
- version: "",
- vendorId: 7531,
- productId: 2,
- clazz: 9,
- subClass: 0,
- protocol: 1,
- devAddress: 1,
- busNum: 1,
- configs: [
- {
- id: 1,
- attributes: 224,
- isRemoteWakeup: true,
- isSelfPowered: true,
- maxPower: 0,
- name: "1-1",
- interfaces: [
- {
- id: 0,
- protocol: 0,
- clazz: 9,
- subClass: 0,
- alternateSetting: 0,
- name: "1-1",
- endpoints: [
- {
- address: 129,
- attributes: 3,
- interval: 12,
- maxPacketSize: 4,
- direction: 128,
- number: 1,
- type: 3,
- interfaceId: 0,
- }
- ]
- }
- ]
- }
- ]
- }
- ]
- */
- ```
-
+You can set a USB device as a host to connect to a device for data transfer. The development procedure is as follows:
+
+
+1. Obtain the USB device list.
+
+ ```js
+ // Import the USB API package.
+ import usb from '@ohos.usbManager';
+ // Obtain the USB device list.
+ let deviceList = usb.getDevices();
+ /*
+ Example deviceList structure:
+ [
+ {
+ name: "1-1",
+ serial: "",
+ manufacturerName: "",
+ productName: "",
+ version: "",
+ vendorId: 7531,
+ productId: 2,
+ clazz: 9,
+ subClass: 0,
+ protocol: 1,
+ devAddress: 1,
+ busNum: 1,
+ configs: [
+ {
+ id: 1,
+ attributes: 224,
+ isRemoteWakeup: true,
+ isSelfPowered: true,
+ maxPower: 0,
+ name: "1-1",
+ interfaces: [
+ {
+ id: 0,
+ protocol: 0,
+ clazz: 9,
+ subClass: 0,
+ alternateSetting: 0,
+ name: "1-1",
+ endpoints: [
+ {
+ address: 129,
+ attributes: 3,
+ interval: 12,
+ maxPacketSize: 4,
+ direction: 128,
+ number: 1,
+ type: 3,
+ interfaceId: 0,
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ */
+ ```
2. Obtain the device operation permissions.
- ```js
- let deviceName = deviceList[0].name;
- // Request the permissions to operate a specified device.
- usb.requestRight(deviceName).then(hasRight => {
- console.info("usb device request right result: " + hasRight);
- }).catch(error => {
- console.info("usb device request right failed : " + error);
- });
- ```
+ ```js
+ let deviceName = deviceList[0].name;
+ // Request the permissions to operate a specified device.
+ usb.requestRight(deviceName).then(hasRight => {
+ console.info("usb device request right result: " + hasRight);
+ }).catch(error => {
+ console.info("usb device request right failed : " + error);
+ });
+ ```
3. Open the device.
- ```js
- // Open the device, and obtain the USB device pipe for data transfer.
- let interface1 = deviceList[0].configs[0].interfaces[0];
- /*
- Claim the corresponding interface from deviceList.
- interface1 must be one present in the device configuration.
- */
- usb.claimInterface(pipe, interface1, true);
- ```
+ ```js
+ // Open the device, and obtain the USB device pipe for data transfer.
+ let pipe = usb.connectDevice(deviceList[0]);
+ let interface1 = deviceList[0].configs[0].interfaces[0];
+ /*
+ Claim the corresponding interface from **deviceList**.
+ interface1 must be one present in the device configuration.
+ */
+ usb.claimInterface(pipe, interface1, true);
+ ```
4. Perform data transfer.
- ```js
- /*
+ ```js
+ /*
Read data. Select the corresponding RX endpoint from deviceList for data transfer.
- (endpoint.direction == 0x80); dataUint8Array indicates the data to read. The data type is Uint8Array.
- */
- let inEndpoint = interface1.endpoints[2];
- let outEndpoint = interface1.endpoints[1];
- let dataUint8Array = new Uint8Array(1024);
- usb.bulkTransfer(pipe, inEndpoint, dataUint8Array, 15000).then(dataLength => {
- if (dataLength >= 0) {
- console.info("usb readData result Length : " + dataLength);
- } else {
- console.info("usb readData failed : " + dataLength);
- }
- }).catch(error => {
- console.info("usb readData error : " + JSON.stringify(error));
- });
- // Send data. Select the corresponding TX endpoint from deviceList for data transfer. (endpoint.direction == 0)
- usb.bulkTransfer(pipe, outEndpoint, dataUint8Array, 15000).then(dataLength => {
- if (dataLength >= 0) {
- console.info("usb writeData result write length : " + dataLength);
- } else {
- console.info("writeData failed");
- }
- }).catch(error => {
- console.info("usb writeData error : " + JSON.stringify(error));
- });
- ```
-
-5. Release the USB interface, and close the USB device.
-
- ```js
- usb.releaseInterface(pipe, interface);
- usb.closePipe(pipe);
- ```
\ No newline at end of file
+ (endpoint.direction == 0x80); dataUint8Array indicates the data to read. The data type is Uint8Array.
+ */
+ let inEndpoint = interface1.endpoints[2];
+ let outEndpoint = interface1.endpoints[1];
+ let dataUint8Array = new Uint8Array(1024);
+ usb.bulkTransfer(pipe, inEndpoint, dataUint8Array, 15000).then(dataLength => {
+ if (dataLength >= 0) {
+ console.info("usb readData result Length : " + dataLength);
+ } else {
+ console.info("usb readData failed : " + dataLength);
+ }
+ }).catch(error => {
+ console.info("usb readData error : " + JSON.stringify(error));
+ });
+ // Send data. Select the corresponding TX endpoint from deviceList for data transfer. (endpoint.direction == 0)
+ usb.bulkTransfer(pipe, outEndpoint, dataUint8Array, 15000).then(dataLength => {
+ if (dataLength >= 0) {
+ console.info("usb writeData result write length : " + dataLength);
+ } else {
+ console.info("writeData failed");
+ }
+ }).catch(error => {
+ console.info("usb writeData error : " + JSON.stringify(error));
+ });
+ ```
+
+5. Release the USB interface, and close the USB device.
+
+ ```js
+ usb.releaseInterface(pipe, interface1);
+ usb.closePipe(pipe);
+ ```
\ No newline at end of file
diff --git a/en/application-dev/internationalization/intl-guidelines.md b/en/application-dev/internationalization/intl-guidelines.md
index fcac5325292b27f349f6c3dcadb627dca2dd0c03..8c9deeaee3bd571a2db3e85a4c59266ed65eaad0 100644
--- a/en/application-dev/internationalization/intl-guidelines.md
+++ b/en/application-dev/internationalization/intl-guidelines.md
@@ -111,7 +111,7 @@ The [i18n](../reference/apis/js-apis-i18n.md) module provides enhanced I18N capa
let dateTimeFormat = new Intl.DateTimeFormat();
```
- Alternatively, use your own locale and formatting parameters to create a **DateTimeFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [DateTimeOptions](../reference/apis/js-apis-intl.md#datetimeoptions9).
+ Alternatively, use your own locale and formatting parameters to create a **DateTimeFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [DateTimeOptions](../reference/apis/js-apis-intl.md#datetimeoptions6).
```js
let options = {dateStyle: "full", timeStyle: "full"};
@@ -181,7 +181,7 @@ The [i18n](../reference/apis/js-apis-i18n.md) module provides enhanced I18N capa
let numberFormat = new Intl.NumberFormat();
```
- Alternatively, use your own locale and formatting parameters to create a **NumberFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [NumberOptions](../reference/apis/js-apis-intl.md#numberoptions9).
+ Alternatively, use your own locale and formatting parameters to create a **NumberFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [NumberOptions](../reference/apis/js-apis-intl.md#numberoptions6).
```js
let options = {compactDisplay: "short", notation: "compact"};
@@ -240,7 +240,7 @@ Users in different regions have different requirements for string sorting. [Coll
let collator = new Intl.Collator();
```
- Alternatively, use your own locale and formatting parameters to create a **Collator** object. For a full list of parameters, see [CollatorOptions](../reference/apis/js-apis-intl.md#collatoroptions9).
+ Alternatively, use your own locale and formatting parameters to create a **Collator** object. For a full list of parameters, see [CollatorOptions](../reference/apis/js-apis-intl.md#collatoroptions8).
The **sensitivity** parameter is used to specify the levels of differences that will be used for string comparison. The value **base** indicates that only characters are compared, but not the accent and capitalization. For example, 'a' != 'b', 'a' == '', 'a'=='A'. The value **accent** indicates that the accent is considered, but not the capitalization. For example, 'a' != 'b', 'a' == '', 'a'=='A'. The value **case** indicates that the capitalization is considered, but the accent. For example, 'a' != 'b', 'a' == '', 'a'=='A'. The value **variant** indicates that the accent and capitalization are considered. For example, 'a' != 'b', 'a' == '', 'a'=='A'.
```js
@@ -301,7 +301,7 @@ According to grammars in certain languages, the singular or plural form of a nou
let pluralRules = new Intl.PluralRules();
```
- Alternatively, use your own locale and formatting parameters to create a **PluralRules** object. For a full list of parameters, see [PluralRulesOptions](../reference/apis/js-apis-intl.md#pluralrulesoptions9).
+ Alternatively, use your own locale and formatting parameters to create a **PluralRules** object. For a full list of parameters, see [PluralRulesOptions](../reference/apis/js-apis-intl.md#pluralrulesoptions8).
```js
let pluralRules = new Intl.PluralRules("zh-CN", {localeMatcher: "best fit", type: "cardinal"});
@@ -349,7 +349,7 @@ According to grammars in certain languages, the singular or plural form of a nou
let relativeTimeFormat = new Intl.RelativeTimeFormat();
```
- Alternatively, use your own locale and formatting parameters to create a **RelativeTimeFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [RelativeTimeFormatInputOptions](../reference/apis/js-apis-intl.md#relativetimeformatinputoptions9).
+ Alternatively, use your own locale and formatting parameters to create a **RelativeTimeFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [RelativeTimeFormatInputOptions](../reference/apis/js-apis-intl.md#relativetimeformatinputoptions8).
```js
let relativeTimeFormat = new Intl.RelativeTimeFormat("zh-CN", {numeric: "always", style: "long"});
diff --git a/en/application-dev/notification/figures/en-us_image_0000001466462305.png b/en/application-dev/notification/figures/en-us_image_0000001466462305.png
index 740f4b79a9ee234008cad6cf3616a8f213569476..7db8892ea08d7bc75f87c1f90cc7bc7281a7e07e 100644
Binary files a/en/application-dev/notification/figures/en-us_image_0000001466462305.png and b/en/application-dev/notification/figures/en-us_image_0000001466462305.png differ
diff --git a/en/application-dev/notification/notification-enable.md b/en/application-dev/notification/notification-enable.md
index 4b0ecd303d8f13b3f7ba4f43364ddd53ffadc1d7..0ab05bec0d4ec44eee8f2c5c43151c2da6da51d3 100644
--- a/en/application-dev/notification/notification-enable.md
+++ b/en/application-dev/notification/notification-enable.md
@@ -1,17 +1,17 @@
# Enabling Notification
-To publish a notification, you must have notification enabled for your application. You can call the [requestEnableNotification()](../reference/apis/js-apis-notificationManager.md#notificationrequestenablenotification) API to display a dialog box prompting the user to enable notification for your application. Note that the dialog box is displayed only when the API is called for the first time.
+To publish a notification, you must have notification enabled for your application. You can call the [requestEnableNotification()](../reference/apis/js-apis-notificationManager.md#notificationmanagerrequestenablenotification) API to display a dialog box prompting the user to enable notification for your application. Note that the dialog box is displayed only when the API is called for the first time.
- **Figure 1** Dialog box prompting the user to enable notification
+**Figure 1** Dialog box prompting the user to enable notification

- Touching **allow** enables notification for the application, and touching **ban** keeps notification disabled.
-- The dialog box will not be displayed again when [requestEnableNotification()](../reference/apis/js-apis-notificationManager.md#notificationrequestenablenotification) is called later. The user can manually enable notification as follows.
-
+- The dialog box will not be displayed again when [requestEnableNotification()](../reference/apis/js-apis-notificationManager.md#notificationmanagerrequestenablenotification) is called later. The user can manually enable notification as follows.
+
| 1. Swipe down from the upper left corner of the device screen to access the notification panel. | 2. Touch the **Settings** icon in the upper right corner. On the notification screen, locate the target application.| 3. Toggle on **Allow notifications**. |
| ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
|  |  |  |
@@ -19,7 +19,7 @@ To publish a notification, you must have notification enabled for your applicati
## Available APIs
-For details about the APIs, see [@ohos.notificationManager](../reference/apis/js-apis-notificationManager.md#notificationrequestenablenotification).
+For details about the APIs, see [@ohos.notificationManager](../reference/apis/js-apis-notificationManager.md#notificationmanagerrequestenablenotification).
**Table 1** Notification APIs
diff --git a/en/application-dev/notification/notification-overview.md b/en/application-dev/notification/notification-overview.md
index 6bef8be8fd446e62b3e3da04582b467c9ddc5961..f3dd4149d7b9c77be498f6d02abed67d9e070ab8 100644
--- a/en/application-dev/notification/notification-overview.md
+++ b/en/application-dev/notification/notification-overview.md
@@ -24,4 +24,5 @@ A notification is generated by the notification sender and sent to the notificat
System applications also support notification-related configuration options, such as switches. The system configuration initiates a configuration request and sends the request to the notification subsystem for storage in the memory and database.
+**Figure 1** Notification service process

diff --git a/en/application-dev/notification/notification-subscription.md b/en/application-dev/notification/notification-subscription.md
index 95fe77de7feead97208082c12519523588cd6521..45e75f1f64606cfa89cae2cfae91b89a13faaa5c 100644
--- a/en/application-dev/notification/notification-subscription.md
+++ b/en/application-dev/notification/notification-subscription.md
@@ -16,19 +16,19 @@ The major APIs for notification subscription are described as follows. For detai
| Name | Description|
| -------- | -------- |
| subscribe(subscriber: NotificationSubscriber, info: NotificationSubscribeInfo, callback: AsyncCallback<void>): void | Subscribes to notifications from a specific application.|
-| subscribe(subscriber: NotificationSubscriber, callback: AsyncCallback<void>): void | Subscribes to notifications from all applications. |
+| subscribe(subscriber: NotificationSubscriber, callback: AsyncCallback<void>): void | Subscribes to notifications from all applications. |
**Table 2** Callbacks for notification subscription
| Name | Description|
| -------- | -------- |
-| onConsume?:(data: SubscribeCallbackData) => void | Callback for receiving notifications. |
-| onCancel?:(data: SubscribeCallbackData) => void | Callback for canceling notifications. |
-| onUpdate?:(data: NotificationSortingMap) => void | Callback for notification sorting updates. |
-| onConnect?:() => void; | Callback for subscription. |
-| onDisconnect?:() => void; | Callback for unsubscription. |
-| onDestroy?:() => void | Callback for disconnecting from the notification subsystem. |
-| onDoNotDisturbDateChange?:(mode: notification.DoNotDisturbDate) => void | Callback for the Do Not Disturb (DNT) time changes.|
+| onConsume?:(data: SubscribeCallbackData) => void | Callback for receiving notifications. |
+| onCancel?:(data: SubscribeCallbackData) => void | Callback for canceling notifications. |
+| onUpdate?:(data: NotificationSortingMap) => void | Callback for notification sorting updates. |
+| onConnect?:() => void; | Callback for subscription. |
+| onDisconnect?:() => void; | Callback for unsubscription. |
+| onDestroy?:() => void | Callback for disconnecting from the notification subsystem. |
+| onDoNotDisturbDateChange?:(mode: notification.DoNotDisturbDate) => void | Callback for the Do Not Disturb (DNT) time changes.|
| onEnabledNotificationChanged?:(callbackData: EnabledNotificationCallbackData) => void | Callback for notification switch changes. |
@@ -46,37 +46,38 @@ The major APIs for notification subscription are described as follows. For detai
```ts
let subscriber = {
- onConsume: function (data) {
- let req = data.request;
- console.info('[ANS] onConsume callback req.id: ' + req.id);
- },
- onCancel: function (data) {
- let req = data.request;
- console.info('[ANS] onCancel callback req.id: : ' + req.id);
- },
- onUpdate: function (data) {
- console.info('[ANS] onUpdate in test');
- },
- onConnect: function () {
- console.info('[ANS] onConnect in test');
- },
- onDisconnect: function () {
- console.info('[ANS] onDisConnect in test');
- },
- onDestroy: function () {
- console.info('[ANS] onDestroy in test');
- },
+ onConsume: function (data) {
+ let req = data.request;
+ console.info(`onConsume callback. req.id: ${req.id}`);
+ },
+ onCancel: function (data) {
+ let req = data.request;
+ console.info(`onCancel callback. req.id: ${req.id}`);
+ },
+ onUpdate: function (data) {
+ let req = data.request;
+ console.info(`onUpdate callback. req.id: ${req.id}`);
+ },
+ onConnect: function () {
+ console.info(`onConnect callback.}`);
+ },
+ onDisconnect: function () {
+ console.info(`onDisconnect callback.}`);
+ },
+ onDestroy: function () {
+ console.info(`onDestroy callback.}`);
+ },
};
```
-
+
4. Initiate notification subscription.
```ts
notificationSubscribe.subscribe(subscriber, (err, data) => { // This API uses an asynchronous callback to return the result.
if (err) {
- console.error(`[ANS] subscribe failed, code is ${err.code}, message is ${err.message}`);
+ console.error(`Failed to subscribe notification. Code is ${err.code}, message is ${err.message}`);
return;
}
- console.info(`[ANS] subscribeTest success : + ${data}`);
+ console.info(`Succeeded in subscribing to notification. Data: ${data}`);
});
```
diff --git a/en/application-dev/notification/notification-with-wantagent.md b/en/application-dev/notification/notification-with-wantagent.md
index 47275ecabeed338cfb67cff44cb39c325498e0ff..638f53ef2f6f6fce1637468ba4c900496727f23d 100644
--- a/en/application-dev/notification/notification-with-wantagent.md
+++ b/en/application-dev/notification/notification-with-wantagent.md
@@ -4,7 +4,7 @@ A [WantAgent](../reference/apis/js-apis-app-ability-wantAgent.md) object encapsu
Below you can see the process of adding a **WantAgent** object to a notification. The notification publisher requests a **WantAgent** object from the Ability Manager Service (AMS), and then sends a notification carrying the **WantAgent** object to the home screen. When the user touches the notification from the notification panel on the home screen, the **WantAgent** object is triggered.
- **Figure 1** Publishing a notification with a WantAgent object
+**Figure 1** Publishing a notification with a WantAgent object

@@ -15,11 +15,11 @@ For details about the APIs, see [@ohos.app.ability.wantAgent](../reference/apis/
| Name| Description|
| -------- | -------- |
-|getWantAgent(info: WantAgentInfo, callback: AsyncCallback<WantAgent>): void | Creates a **WantAgent** object.|
-|trigger(agent: WantAgent, triggerInfo: TriggerInfo, callback?: Callback<CompleteData>): void | Triggers a **WantAgent** object.|
-|cancel(agent: WantAgent, callback: AsyncCallback<void>): void | Cancels a **WantAgent** object.|
-|getWant(agent: WantAgent, callback: AsyncCallback<Want>): void | Obtains a **WantAgent** object.|
-|equal(agent: WantAgent, otherAgent: WantAgent, callback: AsyncCallback<boolean>): void | Checks whether two **WantAgent** objects are equal.|
+| getWantAgent(info: WantAgentInfo, callback: AsyncCallback<WantAgent>): void | Creates a **WantAgent** object.|
+| trigger(agent: WantAgent, triggerInfo: TriggerInfo, callback?: Callback<CompleteData>): void | Triggers a **WantAgent** object.|
+| cancel(agent: WantAgent, callback: AsyncCallback<void>): void | Cancels a **WantAgent** object.|
+| getWant(agent: WantAgent, callback: AsyncCallback<Want>): void | Obtains a **WantAgent** object.|
+| equal(agent: WantAgent, otherAgent: WantAgent, callback: AsyncCallback<boolean>): void | Checks whether two **WantAgent** objects are equal.|
## How to Develop
@@ -42,20 +42,20 @@ For details about the APIs, see [@ohos.app.ability.wantAgent](../reference/apis/
// Set the action type through operationType of WantAgentInfo.
let wantAgentInfo = {
- wants: [
- {
- deviceId: '',
- bundleName: 'com.example.myapplication',
- abilityName: 'EntryAbility',
- action: '',
- entities: [],
- uri: '',
- parameters: {}
- }
- ],
- operationType: wantAgent.OperationType.START_ABILITY,
- requestCode: 0,
- wantAgentFlags:[wantAgent.WantAgentFlags.CONSTANT_FLAG]
+ wants: [
+ {
+ deviceId: '',
+ bundleName: 'com.example.myapplication',
+ abilityName: 'EntryAbility',
+ action: '',
+ entities: [],
+ uri: '',
+ parameters: {}
+ }
+ ],
+ operationType: wantAgent.OperationType.START_ABILITY,
+ requestCode: 0,
+ wantAgentFlags:[wantAgent.WantAgentFlags.CONSTANT_FLAG]
};
```
@@ -66,16 +66,16 @@ For details about the APIs, see [@ohos.app.ability.wantAgent](../reference/apis/
// Set the action type through operationType of WantAgentInfo.
let wantAgentInfo = {
- wants: [
- {
- action: 'event_name', // Set the action name.
- parameters: {},
- }
- ],
- operationType: wantAgent.OperationType.SEND_COMMON_EVENT,
- requestCode: 0,
- wantAgentFlags: [wantAgent.WantAgentFlags.CONSTANT_FLAG],
- }
+ wants: [
+ {
+ action: 'event_name', // Set the action name.
+ parameters: {},
+ }
+ ],
+ operationType: wantAgent.OperationType.SEND_COMMON_EVENT,
+ requestCode: 0,
+ wantAgentFlags: [wantAgent.WantAgentFlags.CONSTANT_FLAG],
+ };
```
4. Invoke the [getWantAgent()](../reference/apis/js-apis-app-ability-wantAgent.md#wantagentgetwantagent) API to create a **WantAgent** object.
@@ -83,12 +83,12 @@ For details about the APIs, see [@ohos.app.ability.wantAgent](../reference/apis/
```typescript
// Create a WantAgent object.
wantAgent.getWantAgent(wantAgentInfo, (err, data) => {
- if (err) {
- console.error('[WantAgent]getWantAgent err=' + JSON.stringify(err));
- return;
- }
- console.info('[WantAgent]getWantAgent success');
- wantAgentObj = data;
+ if (err) {
+ console.error(`Failed to get want agent. Code is ${err.code}, message is ${err.message}`);
+ return;
+ }
+ console.info('Succeeded in geting want agent.');
+ wantAgentObj = data;
});
```
@@ -97,25 +97,25 @@ For details about the APIs, see [@ohos.app.ability.wantAgent](../reference/apis/
```typescript
// Create a NotificationRequest object.
let notificationRequest: notificationManager.NotificationRequest = {
- content: {
- contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
- normal: {
- title: 'Test_Title',
- text: 'Test_Text',
- additionalText: 'Test_AdditionalText',
- },
+ content: {
+ contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
+ normal: {
+ title: 'Test_Title',
+ text: 'Test_Text',
+ additionalText: 'Test_AdditionalText',
},
- id: 1,
- label: 'TEST',
- wantAgent: wantAgentObj,
+ },
+ id: 1,
+ label: 'TEST',
+ wantAgent: wantAgentObj,
}
notificationManager.publish(notificationRequest, (err) => {
- if (err) {
- console.error(`[ANS] publish failed, code is ${err.code}, message is ${err.message}`);
- return;
- }
- console.info(`[ANS] publish success`);
+ if (err) {
+ console.error(`Failed to publish notification. Code is ${err.code}, message is ${err.message}`);
+ return;
+ }
+ console.info('Succeeded in publishing notification.');
});
```
diff --git a/en/application-dev/notification/progress-bar-notification.md b/en/application-dev/notification/progress-bar-notification.md
index db7cae812218c2f7b6c363d204baa04dfeeb639f..4f016fefcbb6912fa9a0b998c7b5feb672503eee 100644
--- a/en/application-dev/notification/progress-bar-notification.md
+++ b/en/application-dev/notification/progress-bar-notification.md
@@ -27,13 +27,14 @@ In the [NotificationTemplate](../reference/apis/js-apis-inner-notification-notif
```ts
notificationManager.isSupportTemplate('downloadTemplate').then((data) => {
console.info(`[ANS] isSupportTemplate success`);
+ console.info('Succeeded in supporting download template notification.');
let isSupportTpl: boolean = data; // The value true means that the template of the downloadTemplate type is supported, and false means the opposite.
// ...
}).catch((err) => {
- console.error(`[ANS] isSupportTemplate failed, code is ${err.code}, message is ${err.message}`);
+ console.error(`Failed to support download template notification. Code is ${err.code}, message is ${err.message}`);
});
```
-
+
> **NOTE**
>
> Proceed with the step below only when the specified template is supported.
@@ -61,9 +62,9 @@ In the [NotificationTemplate](../reference/apis/js-apis-inner-notification-notif
// Publish the notification.
notificationManager.publish(notificationRequest, (err) => {
if (err) {
- console.error(`[ANS] publish failed, code is ${err.code}, message is ${err.message}`);
+ console.error(`Failed to publish notification. Code is ${err.code}, message is ${err.message}`);
return;
}
- console.info(`[ANS] publish success `);
+ console.info('Succeeded in publishing notification.');
});
```
diff --git a/en/application-dev/notification/text-notification.md b/en/application-dev/notification/text-notification.md
index 7901a78a4c547ca02caae191b551d27f6cae3e3a..fb1455e0dcdd791db6658935b48e90a6f14a3a14 100644
--- a/en/application-dev/notification/text-notification.md
+++ b/en/application-dev/notification/text-notification.md
@@ -3,8 +3,7 @@
You can publish basic notifications to send SMS messages, prompt messages, and advertisements. Available content types of basic notifications include normal text, long text, multi-line text, and picture-attached.
-
- **Table 1** Basic notification content types
+**Table 1** Basic notification content types
| Type| Description|
| -------- | -------- |
@@ -13,16 +12,16 @@ You can publish basic notifications to send SMS messages, prompt messages, and a
| NOTIFICATION_CONTENT_MULTILINE | Multi-line text notification.|
| NOTIFICATION_CONTENT_PICTURE | Picture-attached notification.|
+Notifications are displayed in the notification panel, which is the only supported subscriber to notifications. Below you can see two examples of the basic notification.
-Notifications are displayed in the notification panel, which is the only system subscriber to notifications. Below you can see two examples of the basic notification.
+**Figure 1** Examples of the basic notification
-**Figure 1** Examples of the basic notification

## Available APIs
-The following table describes the APIs for notification publishing. You specify the notification type by setting the [NotificationRequest](../reference/apis/js-apis-notificationManager.md#notificationrequest) parameter in the APIs.
+The following table describes the APIs for notification publishing. You specify the notification type by setting the [NotificationRequest](../reference/apis/js-apis-inner-notification-notificationRequest.md#notificationrequest) parameter in the APIs.
| Name| Description|
| -------- | -------- |
@@ -48,21 +47,21 @@ The following table describes the APIs for notification publishing. You specify
let notificationRequest: notificationManager.NotificationRequest = {
id: 1,
content: {
- contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, // Basic notification
- normal: {
- title: 'test_title',
- text: 'test_text',
- additionalText: 'test_additionalText',
- }
+ contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, // Basic notification
+ normal: {
+ title: 'test_title',
+ text: 'test_text',
+ additionalText: 'test_additionalText',
+ }
}
- }
+ };
notificationManager.publish(notificationRequest, (err) => {
- if (err) {
- console.error(`[ANS] publish failed, code is ${err.code}, message is ${err.message}`);
- return;
- }
- console.info(`[ANS] publish success.`);
+ if (err) {
+ console.error(`Failed to publish notification. Code is ${err.code}, message is ${err.message}`);
+ return;
+ }
+ console.info('Succeeded in publishing notification.');
});
```
@@ -74,25 +73,25 @@ The following table describes the APIs for notification publishing. You specify
let notificationRequest: notificationManager.NotificationRequest = {
id: 1,
content: {
- contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_LONG_TEXT, // Long-text notification
- longText: {
- title: 'test_title',
- text: 'test_text',
- additionalText: 'test_additionalText',
- longText: 'test_longText',
- briefText: 'test_briefText',
- expandedTitle: 'test_expandedTitle',
- }
+ contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_LONG_TEXT, // Long-text notification
+ longText: {
+ title: 'test_title',
+ text: 'test_text',
+ additionalText: 'test_additionalText',
+ longText: 'test_longText',
+ briefText: 'test_briefText',
+ expandedTitle: 'test_expandedTitle',
+ }
}
- }
+ };
// Publish the notification.
notificationManager.publish(notificationRequest, (err) => {
- if (err) {
- console.error(`[ANS] publish failed, code is ${err.code}, message is ${err.message}`);
- return;
- }
- console.info(`[ANS] publish success.`);
+ if (err) {
+ console.error(`Failed to publish notification. Code is ${err.code}, message is ${err.message}`);
+ return;
+ }
+ console.info('Succeeded in publishing notification.');
});
```
@@ -104,24 +103,24 @@ The following table describes the APIs for notification publishing. You specify
let notificationRequest: notificationManager.NotificationRequest = {
id: 1,
content: {
- contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_MULTILINE, // Multi-line text notification
- multiLine: {
- title: 'test_title',
- text: 'test_text',
- briefText: 'test_briefText',
- longTitle: 'test_longTitle',
- lines: ['line_01', 'line_02', 'line_03', 'line_04'],
- }
+ contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_MULTILINE, // Multi-line text notification
+ multiLine: {
+ title: 'test_title',
+ text: 'test_text',
+ briefText: 'test_briefText',
+ longTitle: 'test_longTitle',
+ lines: ['line_01', 'line_02', 'line_03', 'line_04'],
+ }
}
- }
+ };
// Publish the notification.
notificationManager.publish(notificationRequest, (err) => {
if (err) {
- console.error(`[ANS] publish failed, code is ${err.code}, message is ${err.message}`);
- return;
+ console.error(`Failed to publish notification. Code is ${err.code}, message is ${err.message}`);
+ return;
}
- console.info(`[ANS] publish success`);
+ console.info('Succeeded in publishing notification.');
});
```
@@ -132,27 +131,27 @@ The following table describes the APIs for notification publishing. You specify
```ts
let imagePixelMap: PixelMap = undefined; // Obtain the PixelMap information.
let notificationRequest: notificationManager.NotificationRequest = {
- id: 1,
- content: {
- contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_PICTURE,
- picture: {
- title: 'test_title',
- text: 'test_text',
- additionalText: 'test_additionalText',
- briefText: 'test_briefText',
- expandedTitle: 'test_expandedTitle',
- picture: imagePixelMap
- }
+ id: 1,
+ content: {
+ contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_PICTURE,
+ picture: {
+ title: 'test_title',
+ text: 'test_text',
+ additionalText: 'test_additionalText',
+ briefText: 'test_briefText',
+ expandedTitle: 'test_expandedTitle',
+ picture: imagePixelMap
}
- }
+ }
+ };
// Publish the notification.
notificationManager.publish(notificationRequest, (err) => {
- if (err) {
- console.error(`[ANS] publish failed, code is ${err.code}, message is ${err.message}`);
- return;
- }
- console.info(`[ANS] publish success.`);
+ if (err) {
+ console.error(`Failed to publish notification. Code is ${err.code}, message is ${err.message}`);
+ return;
+ }
+ console.info('Succeeded in publishing notification.');
});
```
diff --git a/en/application-dev/reference/apis/Readme-EN.md b/en/application-dev/reference/apis/Readme-EN.md
index b942d5aa2a56cfc90c0496074d2ca7dda6d96b6f..f9a6af9e1de4ac19c1623914fcd7e6a62c41a3fd 100644
--- a/en/application-dev/reference/apis/Readme-EN.md
+++ b/en/application-dev/reference/apis/Readme-EN.md
@@ -120,6 +120,7 @@
- [@ohos.events.emitter (Emitter)](js-apis-emitter.md)
- [@ohos.notificationManager (NotificationManager) (Recommended)](js-apis-notificationManager.md)
- [@ohos.notificationSubscribe (NotificationSubscribe) (Recommended)](js-apis-notificationSubscribe.md)
+ - [@ohos.application.StaticSubscriberExtensionContext (NotificationSubscribe) (Recommended)](js-apis-application-StaticSubscriberExtensionContext.md)
- [System Common Events (To Be Deprecated Soon)](commonEvent-definitions.md)
- [@ohos.commonEvent (Common Event) (To Be Deprecated Soon)](js-apis-commonEvent.md)
- [@ohos.notification (Notification) (To Be Deprecated Soon)](js-apis-notification.md)
@@ -137,6 +138,10 @@
- [NotificationFlags](js-apis-inner-notification-notificationFlags.md)
- [NotificationRequest](js-apis-inner-notification-notificationRequest.md)
- [NotificationSlot](js-apis-inner-notification-notificationSlot.md)
+ - [NotificationSorting](js-apis-inner-notification-notificationSorting.md)
+ - [NotificationSortingMap](js-apis-inner-notification-notificationSortingMap.md)
+ - [NotificationSubscribeInfo](js-apis-inner-notification-notificationSubscribeInfo.md)
+ - [NotificationSubscriber](js-apis-inner-notification-notificationSubscriber.md)
- [NotificationTemplate](js-apis-inner-notification-notificationTemplate.md)
- [NotificationUserInput](js-apis-inner-notification-notificationUserInput.md)
- Common Events
@@ -320,7 +325,7 @@
- [@ohos.systemTimer (System Timer)](js-apis-system-timer.md)
- [@ohos.wallpaper (Wallpaper)](js-apis-wallpaper.md)
- [@ohos.web.webview (Webview)](js-apis-webview.md)
- - [console (Log)](js-apis-logs.md)
+ - [Console](js-apis-logs.md)
- [Timer](js-apis-timer.md)
- application
- [AccessibilityExtensionContext (Accessibility Extension Context)](js-apis-inner-application-accessibilityExtensionContext.md)
@@ -330,6 +335,7 @@
- [@ohos.batteryStatistics (Battery Statistics)](js-apis-batteryStatistics.md)
- [@ohos.brightness (Screen Brightness)](js-apis-brightness.md)
- [@ohos.charger (Charging Type)](js-apis-charger.md)
+ - [@ohos.cooperate (Screen Hopping)](js-apis-devicestatus-cooperate.md)
- [@ohos.deviceInfo (Device Information)](js-apis-device-info.md)
- [@ohos.distributedHardware.deviceManager (Device Management)](js-apis-device-manager.md)
- [@ohos.geoLocationManager (Geolocation Manager)](js-apis-geoLocationManager.md)
@@ -344,6 +350,7 @@
- [@ohos.multimodalInput.mouseEvent (Mouse Event)](js-apis-mouseevent.md)
- [@ohos.multimodalInput.pointer (Mouse Pointer)](js-apis-pointer.md)
- [@ohos.multimodalInput.touchEvent (Touch Event)](js-apis-touchevent.md)
+ - [@ohos.multimodalInput.shortKey (Shortcut Key)](js-apis-shortKey.md)
- [@ohos.power (System Power Management)](js-apis-power.md)
- [@ohos.runningLock (Runninglock)](js-apis-runninglock.md)
- [@ohos.sensor (Sensor)](js-apis-sensor.md)
@@ -365,6 +372,7 @@
- [@ohos.configPolicy (Configuration Policy)](js-apis-configPolicy.md)
- [@ohos.enterprise.accountManager (Account Management)](js-apis-enterprise-accountManager.md)
- [@ohos.enterprise.adminManager (Enterprise Device Management)](js-apis-enterprise-adminManager.md)
+ - [@ohos.enterprise.applicationManager (Application Management)](js-apis-enterprise-applicationManager.md)
- [@ohos.enterprise.bundleManager (Bundle Management)](js-apis-enterprise-bundleManager.md)
- [@ohos.enterprise.dateTimeManager (System Time Management)](js-apis-enterprise-dateTimeManager.md)
- [@ohos.enterprise.deviceControl (Device Control Management)](js-apis-enterprise-deviceControl.md)
diff --git a/en/application-dev/reference/apis/js-apis-Bundle.md b/en/application-dev/reference/apis/js-apis-Bundle.md
index c116f901789c4a0fd1898d28bb7e8fd69a1b38fc..db930ccbe8cc14f368b9e16d29b556074e981482 100644
--- a/en/application-dev/reference/apis/js-apis-Bundle.md
+++ b/en/application-dev/reference/apis/js-apis-Bundle.md
@@ -904,7 +904,7 @@ bundle.getAllApplicationInfo(bundleFlags, userId, (err, data) => {
> This API is deprecated since API version 9. You are advised to use [bundleManager.getAllApplicationInfo](js-apis-bundleManager.md#bundlemanagergetallapplicationinfo) instead.
-getAllApplicationInfo(bundleFlags: number, callback: AsyncCallback>) : void;
+getAllApplicationInfo(bundleFlags: number, callback: AsyncCallback\\>): void;
Obtains the information about all applications of the current user. This API uses an asynchronous callback to return the result.
diff --git a/en/application-dev/reference/apis/js-apis-app-form-formExtensionAbility.md b/en/application-dev/reference/apis/js-apis-app-form-formExtensionAbility.md
index 7ea0a7024970cffde1434f76ce911cce28dbcd2e..95d4b1e408a255be8f9830ecc0594640211a26e1 100644
--- a/en/application-dev/reference/apis/js-apis-app-form-formExtensionAbility.md
+++ b/en/application-dev/reference/apis/js-apis-app-form-formExtensionAbility.md
@@ -25,7 +25,7 @@ import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
onAddForm(want: Want): formBindingData.FormBindingData
-Called to notify the widget provider that a **Form** instance (widget) has been created.
+Called to notify the widget provider that a **Form** instance (widget) is being created.
**System capability**: SystemCapability.Ability.Form
@@ -49,7 +49,7 @@ import formBindingData from '@ohos.app.form.formBindingData';
export default class MyFormExtensionAbility extends FormExtensionAbility {
onAddForm(want) {
- console.log('FormExtensionAbility onAddForm, want: ${want.abilityName}');
+ console.log(`FormExtensionAbility onAddForm, want: ${want.abilityName}`);
let dataObj1 = {
temperature: '11c',
'time': '11:00'
@@ -64,7 +64,7 @@ export default class MyFormExtensionAbility extends FormExtensionAbility {
onCastToNormalForm(formId: string): void
-Called to notify the widget provider that a temporary widget has been converted to a normal one.
+Called to notify the widget provider that a temporary widget is being converted to a normal one.
**System capability**: SystemCapability.Ability.Form
@@ -81,7 +81,7 @@ import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
export default class MyFormExtensionAbility extends FormExtensionAbility {
onCastToNormalForm(formId) {
- console.log('FormExtensionAbility onCastToNormalForm, formId: ${formId}');
+ console.log(`FormExtensionAbility onCastToNormalForm, formId: ${formId}`);
}
};
```
@@ -90,7 +90,7 @@ export default class MyFormExtensionAbility extends FormExtensionAbility {
onUpdateForm(formId: string): void
-Called to notify the widget provider that a widget has been updated. After obtaining the latest data, your application should call [updateForm](js-apis-app-form-formProvider.md#updateform) of **formProvider** to update the widget data.
+Called to notify the widget provider that a widget is being updated. After obtaining the latest data, your application should call [updateForm](js-apis-app-form-formProvider.md#updateform) of **formProvider** to update the widget data.
**System capability**: SystemCapability.Ability.Form
@@ -109,15 +109,15 @@ import formProvider from '@ohos.app.form.formProvider';
export default class MyFormExtensionAbility extends FormExtensionAbility {
onUpdateForm(formId) {
- console.log('FormExtensionAbility onUpdateForm, formId: ${formId}');
+ console.log(`FormExtensionAbility onUpdateForm, formId: ${formId}`);
let obj2 = formBindingData.createFormBindingData({
temperature: '22c',
time: '22:00'
});
formProvider.updateForm(formId, obj2).then((data) => {
- console.log('FormExtensionAbility context updateForm, data: ${data}');
+ console.log(`FormExtensionAbility context updateForm, data: ${data}`);
}).catch((error) => {
- console.error('Operation updateForm failed. Cause: ${error}');
+ console.error(`Operation updateForm failed. Cause: ${error}`);
});
}
};
@@ -127,7 +127,7 @@ export default class MyFormExtensionAbility extends FormExtensionAbility {
onChangeFormVisibility(newStatus: { [key: string]: number }): void
-Called to notify the widget provider of the change of visibility.
+Called to notify the widget provider that the widget visibility status is being changed.
**System capability**: SystemCapability.Ability.Form
@@ -146,18 +146,18 @@ import formProvider from '@ohos.app.form.formProvider';
export default class MyFormExtensionAbility extends FormExtensionAbility {
onChangeFormVisibility(newStatus) {
- console.log('FormExtensionAbility onChangeFormVisibility, newStatus: ${newStatus}');
+ console.log(`FormExtensionAbility onChangeFormVisibility, newStatus: ${newStatus}`);
let obj2 = formBindingData.createFormBindingData({
temperature: '22c',
time: '22:00'
});
for (let key in newStatus) {
- console.log('FormExtensionAbility onChangeFormVisibility, key: ${key}, value= ${newStatus[key]}');
+ console.log(`FormExtensionAbility onChangeFormVisibility, key: ${key}, value= ${newStatus[key]}`);
formProvider.updateForm(key, obj2).then((data) => {
- console.log('FormExtensionAbility context updateForm, data: ${data}');
+ console.log(`FormExtensionAbility context updateForm, data: ${data}`);
}).catch((error) => {
- console.error('Operation updateForm failed. Cause: ${error}');
+ console.error(`Operation updateForm failed. Cause: ${error}`);
});
}
}
@@ -168,7 +168,7 @@ export default class MyFormExtensionAbility extends FormExtensionAbility {
onFormEvent(formId: string, message: string): void
-Called to instruct the widget provider to receive and process the widget event.
+Called to instruct the widget provider to process the widget event.
**System capability**: SystemCapability.Ability.Form
@@ -186,7 +186,7 @@ import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
export default class MyFormExtensionAbility extends FormExtensionAbility {
onFormEvent(formId, message) {
- console.log('FormExtensionAbility onFormEvent, formId: ${formId}, message: ${message}');
+ console.log(`FormExtensionAbility onFormEvent, formId: ${formId}, message: ${message}`);
}
};
```
@@ -195,7 +195,7 @@ export default class MyFormExtensionAbility extends FormExtensionAbility {
onRemoveForm(formId: string): void
-Called to notify the widget provider that a **Form** instance (widget) has been destroyed.
+Called to notify the widget provider that a **Form** instance (widget) is being destroyed.
**System capability**: SystemCapability.Ability.Form
@@ -212,7 +212,7 @@ import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
export default class MyFormExtensionAbility extends FormExtensionAbility {
onRemoveForm(formId) {
- console.log('FormExtensionAbility onRemoveForm, formId: ${formId}');
+ console.log(`FormExtensionAbility onRemoveForm, formId: ${formId}`);
}
};
```
@@ -221,7 +221,7 @@ export default class MyFormExtensionAbility extends FormExtensionAbility {
onConfigurationUpdate(newConfig: Configuration): void;
-Called when the configuration of the environment where the ability is running is updated.
+Called when the configuration of the environment where the FormExtensionAbility is running is updated.
**System capability**: SystemCapability.Ability.Form
@@ -238,7 +238,7 @@ import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
export default class MyFormExtensionAbility extends FormExtensionAbility {
onConfigurationUpdate(config) {
- console.log('onConfigurationUpdate, config: ${JSON.stringify(config)}');
+ console.log(`onConfigurationUpdate, config: ${JSON.stringify(config)}`);
}
};
```
@@ -247,7 +247,7 @@ export default class MyFormExtensionAbility extends FormExtensionAbility {
onAcquireFormState?(want: Want): formInfo.FormState;
-Called when the widget provider receives the status query result of a widget. By default, the initial state is returned.
+Called to notify the widget provider that the widget host is requesting the widget state. By default, the initial state is returned.
**System capability**: SystemCapability.Ability.Form
@@ -265,7 +265,7 @@ import formInfo from '@ohos.app.form.formInfo';
export default class MyFormExtensionAbility extends FormExtensionAbility {
onAcquireFormState(want) {
- console.log('FormExtensionAbility onAcquireFormState, want: ${want}');
+ console.log(`FormExtensionAbility onAcquireFormState, want: ${want}`);
return formInfo.FormState.UNKNOWN;
}
};
@@ -275,7 +275,7 @@ export default class MyFormExtensionAbility extends FormExtensionAbility {
onShareForm?(formId: string): { [key: string]: Object }
-Called by the widget provider to receive shared widget data.
+Called to notify the widget provider that the widget host is sharing the widget data.
**System API**: This is a system API.
@@ -300,7 +300,46 @@ import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
export default class MyFormExtensionAbility extends FormExtensionAbility {
onShareForm(formId) {
- console.log('FormExtensionAbility onShareForm, formId: ${formId}');
+ console.log(`FormExtensionAbility onShareForm, formId: ${formId}`);
+ let wantParams = {
+ 'temperature': '20',
+ 'time': '2022-8-8 09:59',
+ };
+ return wantParams;
+ }
+};
+```
+
+## onAcquireFormData10+
+
+onAcquireFormData?(formId: string): { [key: string]: Object }
+
+Called to notify the widget provider that the widget host is requesting the custom data.
+
+**System API**: This is a system API.
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| formId | string | Yes | Widget ID.|
+
+**Return value**
+
+| Type | Description |
+| ------------------------------------------------------------ | ----------------------------------------------------------- |
+| {[key: string]: any} | Custom data of the widget, in the form of key-value pairs.|
+
+**Example**
+
+```ts
+import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
+
+export default class MyFormExtensionAbility extends FormExtensionAbility {
+ onAcquireFormData(formId) {
+ console.log('FormExtensionAbility onAcquireFormData, formId: ${formId}');
let wantParams = {
'temperature': '20',
'time': '2022-8-8 09:59',
diff --git a/en/application-dev/reference/apis/js-apis-app-form-formHost.md b/en/application-dev/reference/apis/js-apis-app-form-formHost.md
index 0afda1db43c8830ffbf9eeb63cceae0c07a62f2c..d81c78c439f21e0ce60ff3df6e33c3d949ee980a 100644
--- a/en/application-dev/reference/apis/js-apis-app-form-formHost.md
+++ b/en/application-dev/reference/apis/js-apis-app-form-formHost.md
@@ -2222,7 +2222,7 @@ try {
## getRunningFormInfosByFilter10+
-function getRunningFormInfosByFilter(formProviderFilter: formInfo.FormProviderFilter): Promise<Array<formInfo.RunningFormInfo>>
+getRunningFormInfosByFilter(formProviderFilter: formInfo.FormProviderFilter): Promise<Array<formInfo.RunningFormInfo>>
Obtains the information about widget hosts based on the widget provider information. This API uses a promise to return the result.
@@ -2273,7 +2273,7 @@ try {
## getRunningFormInfosByFilter10+
-function getRunningFormInfosByFilter(formProviderFilter: formInfo.FormProviderFilter, callback: AsyncCallback<Array<formInfo.FormInfo>>): void
+getRunningFormInfosByFilter(formProviderFilter: formInfo.FormProviderFilter, callback: AsyncCallback<Array<formInfo.FormInfo>>): void
Obtains the information about widget hosts based on the widget provider information. This API uses an asynchronous callback to return the result.
@@ -2321,7 +2321,7 @@ try {
## getRunningFormInfoById10+
-function getRunningFormInfoById(formId: string): Promise<Array<formInfo.RunningFormInfo>>
+getRunningFormInfoById(formId: string): Promise<Array<formInfo.RunningFormInfo>>
Obtains the information about widget hosts based on the widget ID. This API uses a promise to return the result.
@@ -2366,7 +2366,7 @@ try {
## getRunningFormInfoById10+
-function getRunningFormInfoById(formId: string, callback: AsyncCallback<Array<formInfo.FormInfo>>): void
+getRunningFormInfoById(formId: string, callback: AsyncCallback<Array<formInfo.FormInfo>>): void
Obtains the information about widget hosts based on the widget ID. This API uses an asynchronous callback to return the result.
diff --git a/en/application-dev/reference/apis/js-apis-application-StaticSubscriberExtensionContext.md b/en/application-dev/reference/apis/js-apis-application-StaticSubscriberExtensionContext.md
new file mode 100644
index 0000000000000000000000000000000000000000..f1c7c82e6af9bdeacc971596d47b217c72f1ddc9
--- /dev/null
+++ b/en/application-dev/reference/apis/js-apis-application-StaticSubscriberExtensionContext.md
@@ -0,0 +1,161 @@
+# @ohos.application.StaticSubscriberExtensionContext (StaticSubscriberExtensionContext)
+
+The **StaticSubscriberExtensionContext** module, inherited from **ExtensionContext**, provides context for StaticSubscriberExtensionAbilities.
+
+You can use the APIs of this module to start StaticSubscriberExtensionAbilities.
+
+> **NOTE**
+>
+> The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+> The APIs of this module can be used only in the stage model.
+
+## Usage
+
+Before using the **StaticSubscriberExtensionContext** module, you must first obtain a **StaticSubscriberExtensionAbility** instance.
+
+```ts
+import StaticSubscriberExtensionAbility from '@ohos.application.StaticSubscriberExtensionAbility'
+
+export default class MyStaticSubscriberExtensionAbility extends StaticSubscriberExtensionAbility {
+ context = this.context;
+};
+```
+
+## StaticSubscriberExtensionContext.startAbility
+
+startAbility(want: Want, callback: AsyncCallback<void>): void;
+
+Starts an ability that belongs to the same application as this StaticSubscriberExtensionAbility. This API uses an asynchronous callback to return the result.
+
+Observe the following when using this API:
+ - If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
+ - If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ----------------------------------- | ---- | -------------------------- |
+| want | [Want](js-apis-application-want.md) | Yes | Want information about the target ability. |
+| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
+
+**Error codes**
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
+
+| ID| Error Message |
+| -------- | ------------------------------------------------------------ |
+| 16000001 | The specified ability does not exist. |
+| 16000002 | Incorrect ability type. |
+| 16000004 | Can not start invisible component. |
+| 16000005 | The specified process does not have the permission. |
+| 16000006 | Cross-user operations are not allowed. |
+| 16000008 | The crowdtesting application expires. |
+| 16000009 | An ability cannot be started or stopped in Wukong mode. |
+| 16000011 | The context does not exist. |
+| 16000050 | Internal error. |
+| 16000053 | The ability is not on the top of the UI. |
+| 16000055 | Installation-free timed out. |
+| 16200001 | The caller has been released. |
+| 16300003 | The target application is not self application. |
+
+**Example**
+
+ ```ts
+ let want = {
+ bundleName: "com.example.myapp",
+ abilityName: "MyAbility"
+ };
+
+ try {
+ this.context.startAbility(want, (error) => {
+ if (error) {
+ // Process service logic errors.
+ console.log('startAbility failed, error.code: ' + JSON.stringify(error.code) +
+ ' error.message: ' + JSON.stringify(error.message));
+ return;
+ }
+ // Carry out normal service processing.
+ console.log('startAbility succeed');
+ });
+ } catch (paramError) {
+ // Process input parameter errors.
+ console.log('startAbility failed, error.code: ' + JSON.stringify(paramError.code) +
+ ' error.message: ' + JSON.stringify(paramError.message));
+ }
+ ```
+
+## StaticSubscriberExtensionContext.startAbility
+
+startAbility(want: Want): Promise<void>;
+
+Starts an ability that belongs to the same application as this StaticSubscriberExtensionAbility. This API uses a promise to return the result.
+
+Observe the following when using this API:
+ - If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
+ - If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ----------------------------------- | ---- | ----------------------- |
+| want | [Want](js-apis-application-want.md) | Yes | Want information about the target ability.|
+
+**Return value**
+
+| Type | Description |
+| ------------------- | ------------------------- |
+| Promise<void> | Promise used to return the result.|
+
+**Error codes**
+
+For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
+
+| ID| Error Message |
+| -------- | ------------------------------------------------------------ |
+| 16000001 | The specified ability does not exist. |
+| 16000002 | Incorrect ability type. |
+| 16000004 | Can not start invisible component. |
+| 16000005 | The specified process does not have the permission. |
+| 16000006 | Cross-user operations are not allowed. |
+| 16000008 | The crowdtesting application expires. |
+| 16000009 | An ability cannot be started or stopped in Wukong mode. |
+| 16000011 | The context does not exist. |
+| 16000050 | Internal error. |
+| 16000053 | The ability is not on the top of the UI. |
+| 16000055 | Installation-free timed out. |
+| 16200001 | The caller has been released. |
+| 16300003 | The target application is not self application. |
+
+**Example**
+
+ ```ts
+ let want = {
+ bundleName: "com.example.myapp",
+ abilityName: "MyAbility"
+ };
+
+ try {
+ this.context.startAbility(want)
+ .then(() => {
+ // Carry out normal service processing.
+ console.log('startAbility succeed');
+ })
+ .catch((error) => {
+ // Process service logic errors.
+ console.log('startAbility failed, error.code: ' + JSON.stringify(error.code) +
+ ' error.message: ' + JSON.stringify(error.message));
+ });
+ } catch (paramError) {
+ // Process input parameter errors.
+ console.log('startAbility failed, error.code: ' + JSON.stringify(paramError.code) +
+ ' error.message: ' + JSON.stringify(paramError.message));
+ }
+ ```
diff --git a/en/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md b/en/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md
index 096433a60c44904bbe9b2f25d09e9384e192c7fb..c28c4372ba1cf10ad9c67669913de1b4ac06ae17 100644
--- a/en/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md
+++ b/en/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md
@@ -13,6 +13,14 @@ The **StaticSubscriberExtensionAbility** module provides Extension abilities for
import StaticSubscriberExtensionAbility from '@ohos.application.StaticSubscriberExtensionAbility';
```
+## Attributes
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+| Name | Type | Readable| Writable| Description |
+| ------- | ------------------------------------------------------------ | ---- | ---- | -------- |
+| context | [StaticSubscriberExtensionContext](js-apis-application-StaticSubscriberExtensionContext.md) | Yes | No | Context.|
+
## StaticSubscriberExtensionAbility.onReceiveEvent
onReceiveEvent(event: CommonEventData): void;
@@ -30,7 +38,6 @@ Callback of the common event of a static subscriber.
| event | [CommonEventData](js-apis-commonEventManager.md#commoneventdata) | Yes| Common event of a static subscriber.|
**Example**
-
```ts
class MyStaticSubscriberExtensionAbility extends StaticSubscriberExtensionAbility {
onReceiveEvent(event) {
diff --git a/en/application-dev/reference/apis/js-apis-arkui-componentSnapshot.md b/en/application-dev/reference/apis/js-apis-arkui-componentSnapshot.md
index 340a54ba1b1e5950cdced1971050c42590208f74..f8bbe2212f0b6b9ae41183bfce2ae7c03a726d99 100644
--- a/en/application-dev/reference/apis/js-apis-arkui-componentSnapshot.md
+++ b/en/application-dev/reference/apis/js-apis-arkui-componentSnapshot.md
@@ -1,6 +1,6 @@
# @ohos.arkui.componentSnapshot (Component Snapshot)
-The **componentSnapshot** module provides APIs for obtaining component snapshots, including snapshots of components that have been loaded and snapshots of components that have not been loaded yet.
+The **componentSnapshot** module provides APIs for obtaining component snapshots, including snapshots of components that have been loaded and snapshots of components that have not been loaded yet. Note that a component snapshot does not contain content drawn outside of the area of the owning component or the parent component.
> **NOTE**
>
@@ -8,6 +8,7 @@ The **componentSnapshot** module provides APIs for obtaining component snapshots
>
> You can preview how this component looks on a real device. The preview is not yet available in the DevEco Studio Previewer.
+
## Modules to Import
```js
@@ -20,14 +21,18 @@ get(id: string, callback: AsyncCallback): void
Obtains the snapshot of a component that has been loaded. This API uses an asynchronous callback to return the result.
+> **NOTE**
+>
+> The snapshot captures content rendered in the last frame. If this API is called when the component triggers an update, the re-rendered content will not be included in the obtained snapshot.
+
**System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ----------------------------------- | ---- | ------------------------------------------------------------------------------ |
-| id | string | Yes | [ID](../arkui-ts/ts-universal-attributes-component-id.md) of the target component.|
-| callback | AsyncCallback<image.PixelMap> | Yes | Callback used to return the result. |
+| Name | Type | Mandatory | Description |
+| -------- | ----------------------------------- | ---- | ---------------------------------------- |
+| id | string | Yes | [ID](../arkui-ts/ts-universal-attributes-component-id.md) of the target component.|
+| callback | AsyncCallback<image.PixelMap> | Yes | Callback used to return the result. |
**Example**
@@ -45,8 +50,8 @@ struct SnapshotExample {
Image(this.pixmap)
.width(300).height(300)
// ...Component
- // ...Components
- // ...Components
+ // ...Component
+ // ...Component
Button("click to generate UI snapshot")
.onClick(() => {
componentSnapshot.get("root", (error: Error, pixmap: image.PixelMap) => {
@@ -71,25 +76,29 @@ get(id: string): Promise
Obtains the snapshot of a component that has been loaded. This API uses a promise to return the result.
+> **NOTE**
+>
+> The snapshot captures content rendered in the last frame. If this API is called when the component triggers an update, the re-rendered content will not be included in the obtained snapshot.
+
**System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters**
-| Name | Type | Mandatory| Description |
-| ------- | ------------------------------------------------------- | ---- | -------------------- |
-| id | string | Yes | [ID](../arkui-ts/ts-universal-attributes-component-id.md) of the target component.|
+| Name | Type | Mandatory | Description |
+| ---- | ------ | ---- | ---------------------------------------- |
+| id | string | Yes | [ID](../arkui-ts/ts-universal-attributes-component-id.md) of the target component.|
**Return value**
-| Type | Description |
-| ----------------------------- | -------------- |
+| Type | Description |
+| ----------------------------- | -------- |
| Promise<image.PixelMap> | Promise used to return the result.|
**Error codes**
-| ID| Error Message |
-| -------- | ------------------- |
-| 100001 | if id is not valid. |
+| ID | Error Message |
+| ------ | ------------------- |
+| 100001 | if id is not valid. |
**Example**
@@ -134,14 +143,21 @@ createFromBuilder(builder: CustomBuilder, callback: AsyncCallback **NOTE**
+>
+> To account for the time spent in awaiting component building and rendering, the callback of offscreen snapshots has a delay of less than 500 ms.
+>
+> If a component is on a time-consuming task, for example, an **\** or **\** component that is loading online images, its loading may be still in progress when this API is called. In this case, the output snapshot does not represent the component in the way it looks when the loading is successfully completed.
+
+
**System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ------------------------------------------------------- | ---- | -------------------- |
-| builder | [CustomBuilder](../arkui-ts/ts-types.md#custombuilder8) | Yes | Builder of the custom component.|
-| callback | AsyncCallback<image.PixelMap> | Yes | Callback used to return the result. |
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | ---------- |
+| builder | [CustomBuilder](../arkui-ts/ts-types.md#custombuilder8) | Yes | Builder of the custom component.|
+| callback | AsyncCallback<image.PixelMap> | Yes | Callback used to return the result.|
**Example**
@@ -194,25 +210,31 @@ createFromBuilder(builder: CustomBuilder): Promise
Renders a custom component in the application background and outputs its snapshot. This API uses a promise to return the result.
+> **NOTE**
+>
+> To account for the time spent in awaiting component building and rendering, the callback of offscreen snapshots has a delay of less than 500 ms.
+>
+> If a component is on a time-consuming task, for example, an **\** or **\** component that is loading online images, its loading may be still in progress when this API is called. In this case, the output snapshot does not represent the component in the way it looks when the loading is successfully completed.
+
**System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters**
-| Name | Type | Mandatory| Description |
-| ------- | ------------------------------------------------------- | ---- | -------------------- |
-| builder | [CustomBuilder](../arkui-ts/ts-types.md#custombuilder8) | Yes | Builder of the custom component.|
+| Name | Type | Mandatory | Description |
+| ------- | ---------------------------------------- | ---- | ---------- |
+| builder | [CustomBuilder](../arkui-ts/ts-types.md#custombuilder8) | Yes | Builder of the custom component.|
**Return value**
-| Type | Description |
-| ----------------------------- | -------------- |
+| Type | Description |
+| ----------------------------- | -------- |
| Promise<image.PixelMap> | Promise used to return the result.|
**Error codes**
-| ID| Error Message |
-| -------- | ----------------------------------------- |
-| 100001 | if builder is not a valid build function. |
+| ID | Error Message |
+| ------ | ---------------------------------------- |
+| 100001 | if builder is not a valid build function. |
**Example**
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-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-bundleManager.md b/en/application-dev/reference/apis/js-apis-bundleManager.md
index 7962d8ae77ab77dc1bba0d72b4418d3da2f867a2..a4d1dab714b0b5f632b020d0b57d6c788b48d8b7 100644
--- a/en/application-dev/reference/apis/js-apis-bundleManager.md
+++ b/en/application-dev/reference/apis/js-apis-bundleManager.md
@@ -113,6 +113,7 @@ Enumerates the types of Extension abilities.
| THUMBNAIL | 13 | ThumbnailExtensionAbility: provides thumbnails for files. This ability is reserved.|
| PREVIEW | 14 | PreviewExtensionAbility: provides APIs for file preview so that other applications can be embedded and displayed in the current application. This ability is reserved.|
| PRINT10+ | 15 | PrintExtensionAbility: provides APIs for printing images. Printing documents is not supported yet.|
+| PUSH10+ | 17 | **PushExtensionAbility**: provides APIs for pushing scenario-specific messages. This ability is reserved.|
| DRIVER10+ | 18 | DriverExtensionAbility: provides APIs for the peripheral driver. This type of ability is not supported yet.|
| UNSPECIFIED | 255 | No type is specified. It is used together with **queryExtensionAbilityInfo** to query all types of Extension abilities.|
diff --git a/en/application-dev/reference/apis/js-apis-call.md b/en/application-dev/reference/apis/js-apis-call.md
index 1f90664de26360d3099d9f0870baabaad1063b23..a488a313beff34555f589b57bdea17ddbdbcc752 100644
--- a/en/application-dev/reference/apis/js-apis-call.md
+++ b/en/application-dev/reference/apis/js-apis-call.md
@@ -2057,7 +2057,7 @@ promise.then(data => {
setCallWaiting\(slotId: number, activate: boolean, callback: AsyncCallback\\): void
-Sets the call waiting switch. This API uses an asynchronous callback to return the result.
+Specifies whether to enable the call waiting service. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
@@ -2099,7 +2099,7 @@ call.setCallWaiting(0, true, (err) => {
setCallWaiting\(slotId: number, activate: boolean\): Promise\
-Sets the call waiting switch. This API uses a promise to return the result.
+Specifies whether to enable the call waiting service. This API uses a promise to return the result.
**System API**: This is a system API.
@@ -2719,6 +2719,91 @@ call.off('mmiCodeResult', data => {
});
```
+
+## call.on('audioDeviceChange')10+
+
+on\(type: 'audioDeviceChange', callback: Callback\\): void
+
+Subscribes to audio device change events. This API uses an asynchronous callback to return the result.
+
+**System API**: This is a system API.
+
+**Required permission**: ohos.permission.SET_TELEPHONY_STATE
+
+**System capability**: SystemCapability.Telephony.CallManager
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ----------------------------------------------- | ---- | --------------------------------------------------- |
+| type | string | Yes | Audio device change. This field has a fixed value of **audioDeviceChange**.|
+| callback | Callback<[AudioDeviceInfo](#audiodeviceinfo10)> | Yes | Callback used to return the result. |
+
+**Error codes**
+
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 202 | Non-system applications use system APIs. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
+**Example**
+
+```js
+call.on('audioDeviceChange', data => {
+ console.log(`callback: data->${JSON.stringify(data)}`);
+});
+```
+
+
+## call.off('audioDeviceChange')10+
+
+off\(type: 'audioDeviceChange', callback?: Callback\\): void
+
+Unsubscribes from **audioDeviceChange** events. This API uses an asynchronous callback to return the result.
+
+**System API**: This is a system API.
+
+**Required permission**: ohos.permission.SET_TELEPHONY_STATE
+
+**System capability**: SystemCapability.Telephony.CallManager
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------------------------- | ---- | --------------------------------------------------- |
+| type | string | Yes | Audio device change. This field has a fixed value of **audioDeviceChange**.|
+| callback | Callback<[AudioDeviceInfo](#audiodeviceinfo10)> | No | Callback used to return the result. If this parameter is not set, no subscription cancellation result will be received. |
+
+**Error codes**
+
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| 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. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
+**Example**
+
+```js
+call.off('audioDeviceChange', data => {
+ console.log(`callback: data->${JSON.stringify(data)}`);
+});
+```
+
+
## call.isNewCallAllowed8+
isNewCallAllowed\(callback: AsyncCallback\\): void
@@ -3804,7 +3889,7 @@ call.updateImsCallMode(1, 1).then(() => {
enableImsSwitch\(slotId: number, callback: AsyncCallback\\): void
-Enables the IMS switch. This API uses an asynchronous callback to return the result.
+Enables the IMS service. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
@@ -3845,7 +3930,7 @@ call.enableImsSwitch(0, (err) => {
enableImsSwitch\(slotId: number\): Promise\
-Enables the IMS switch. This API uses a promise to return the result.
+Enables the IMS service. This API uses a promise to return the result.
**System API**: This is a system API.
@@ -3893,7 +3978,7 @@ call.enableImsSwitch(0).then(() => {
disableImsSwitch\(slotId: number, callback: AsyncCallback\\): void
-Disables the IMS switch. This API uses an asynchronous callback to return the result.
+Disables the IMS service. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
@@ -3934,7 +4019,7 @@ call.disableImsSwitch(0, (err) => {
disableImsSwitch\(slotId: number\): Promise\
-Disables the IMS switch. This API uses a promise to return the result.
+Disables the IMS service. This API uses a promise to return the result.
**System API**: This is a system API.
@@ -3982,7 +4067,7 @@ call.disableImsSwitch(0).then(() => {
isImsSwitchEnabled\(slotId: number, callback: AsyncCallback\\): void
-Checks whether the IMS switch is enabled. This API uses an asynchronous callback to return the result.
+Checks whether the IMS service is enabled. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
@@ -4020,7 +4105,7 @@ call.isImsSwitchEnabled(0, (err, data) => {
isImsSwitchEnabled\(slotId: number\): Promise\
-Checks whether the IMS switch is enabled. This API uses a promise to return the result.
+Checks whether the IMS service is enabled. This API uses a promise to return the result.
**System API**: This is a system API.
@@ -4062,6 +4147,472 @@ promise.then(data => {
});
```
+
+## call.closeUnfinishedUssd10+
+
+closeUnfinishedUssd\(slotId: number, callback: AsyncCallback\\): void
+
+Cancels the unfinished USSD services. This API uses an asynchronous callback to return the result.
+
+**System API**: This is a system API.
+
+**Required permission**: ohos.permission.SET_TELEPHONY_STATE
+
+**System capability**: SystemCapability.Telephony.CallManager
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------- | ---- | -------------------------------------- |
+| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2 |
+| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
+
+**Error codes**
+
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 202 | Non-system applications use system APIs. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
+**Example**
+
+```js
+let slotId = 0;
+call.closeUnfinishedUssd(slotId, (err) => {
+ console.log(`callback: err->${JSON.stringify(err)}`);
+});
+```
+
+## call.closeUnfinishedUssd10+
+
+closeUnfinishedUssd\(slotId: number\): Promise\
+
+Cancels the unfinished USSD services. This API uses a promise to return the result.
+
+**System API**: This is a system API.
+
+**Required permission**: ohos.permission.SET_TELEPHONY_STATE
+
+**System capability**: SystemCapability.Telephony.CallManager
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | -------------------------------------- |
+| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2 |
+
+**Return value**
+
+| Type | Description |
+| ------------------- | --------------------------- |
+| Promise<void> | Promise used to return the result. |
+
+**Error codes**
+
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 202 | Non-system applications use system APIs. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
+**Example**
+
+```js
+let slotId = 0;
+call.closeUnfinishedUssd(slotId).then(() => {
+ console.log(`closeUnfinishedUssd success.`);
+}).catch((err) => {
+ console.error(`closeUnfinishedUssd fail, promise: err->${JSON.stringify(err)}`);
+});
+```
+
+
+## call.setVoNRState10+
+
+setVoNRState\(slotId: number, state: VoNRState, callback: AsyncCallback\\): void
+
+Sets the status of the VoNR switch. This API uses an asynchronous callback to return the result.
+
+**System API**: This is a system API.
+
+**Required permission**: ohos.permission.SET_TELEPHONY_STATE
+
+**System capability**: SystemCapability.Telephony.CallManager
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ----------- | ----------------------------- | ---- | ---------------------------------------------------- |
+| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2 |
+| state | [VoNRState](#vonrstate10) | Yes | Status of the VoNR switch. |
+| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. Callback used to return the result. The value **true** indicates that the operation is successful, and value **false** indicates the opposite.|
+
+**Error codes**
+
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| 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. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
+**Example**
+
+```js
+let slotId = 0;
+let state = 1;
+call.setVoNRState(slotId, state, (err, data) => {
+ console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
+});
+```
+
+
+## call.setVoNRState10+
+
+setVoNRState\(slotId: number, state: VoNRState\): Promise\
+
+Sets the status of the VoNR switch. This API uses a promise to return the result.
+
+**System API**: This is a system API.
+
+**Required permission**: ohos.permission.SET_TELEPHONY_STATE
+
+**System capability**: SystemCapability.Telephony.CallManager
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ----------- | ----------------------------- | ---- | ------------------------------------------- |
+| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2 |
+| state | [VoNRState](#vonrstate10) | Yes | Status of the VoNR switch. |
+
+**Return value**
+
+| Type | Description |
+| ---------------------- | --------------------------------------------- |
+| Promise<boolean> | Promise used to return the result. |
+
+**Error codes**
+
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 202 | Non-system applications use system APIs. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
+**Example**
+
+```js
+let slotId = 0;
+let state = 1;
+call.setVoNRState(slotId, state).then(() => {
+ console.log(`setVoNRState success, promise: data->${JSON.stringify(data)}`);
+}).catch((err) => {
+ console.error(`setVoNRState fail, promise: err->${JSON.stringify(err)}`);
+});
+```
+
+
+## call.getVoNRState10+
+
+getVoNRState\(slotId: number, callback: AsyncCallback\\): void
+
+Obtains the status of the VoNR switch. This API uses an asynchronous callback to return the result.
+
+**System API**: This is a system API.
+
+**Required permission**: ohos.permission.GET_TELEPHONY_STATE
+
+**System capability**: SystemCapability.Telephony.CallManager
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ----------- | --------------------------------------------- | ---- | ------------------------------------------------------ |
+| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2 |
+| callback | AsyncCallback<[VoNRState](#vonrstate10)>| Yes | Callback used to return the result. |
+
+**Error codes**
+
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 202 | Non-system applications use system APIs. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
+**Example**
+
+```js
+let slotId = 0;
+call.getVoNRState(slotId, (err, data) => {
+ console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
+});
+```
+
+
+## call.getVoNRState10+
+
+getVoNRState\(slotId: number\): Promise\
+
+Obtains the status of the VoNR switch. This API uses a promise to return the result.
+
+**System API**: This is a system API.
+
+**Required permission**: ohos.permission.GET_TELEPHONY_STATE
+
+**System capability**: SystemCapability.Telephony.CallManager
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ----------- | ----------------------------- | ---- | ------------------------------------------- |
+| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2 |
+
+**Return value**
+
+| Type | Description |
+| ---------------------------------------- | ------------------------------------------- |
+| Promise<[VoNRState](#vonrstate10)> | Promise used to return the result. |
+
+**Error codes**
+
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 202 | Non-system applications use system APIs. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
+**Example**
+
+```js
+let slotId = 0;
+let promise = call.getVoNRState(slotId);
+promise.then(data => {
+ console.log(`getVoNRState success, promise: data->${JSON.stringify(data)}`);
+}).catch(err => {
+ console.error(`getVoNRState fail, promise: err->${JSON.stringify(err)}`);
+});
+```
+
+
+## call.canSetCallTransferTime10+
+
+canSetCallTransferTime\(slotId: number, callback: AsyncCallback\\): void
+
+Checks whether the call forwarding time can be set. This API uses an asynchronous callback to return the result.
+
+**System API**: This is a system API.
+
+**Required permission**: ohos.permission.GET_TELEPHONY_STATE
+
+**System capability**: SystemCapability.Telephony.CallManager
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ----------- | ----------------------------- | ---- | ----------------------------------------------------- |
+| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2 |
+| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. Callback used to return the result. The value **true** indicates that the call forwarding time can be set, and the value **false** indicates the opposite.|
+
+**Error codes**
+
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| 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. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
+**Example**
+
+```js
+let slotId = 0;
+call.canSetCallTransferTime(slotId, (err, data) => {
+ console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
+});
+```
+
+
+## call.canSetCallTransferTime10+
+
+canSetCallTransferTime\(slotId: number\): Promise\
+
+Checks whether the call forwarding time can be set. This API uses a promise to return the result.
+
+**System API**: This is a system API.
+
+**Required permission**: ohos.permission.GET_TELEPHONY_STATE
+
+**System capability**: SystemCapability.Telephony.CallManager
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ----------- | ----------------------------- | ---- | ------------------------------------------- |
+| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2 |
+
+**Return value**
+
+| Type | Description |
+| ---------------------- | --------------------------------------------- |
+| Promise<boolean> | Promise used to return the result.|
+
+**Error codes**
+
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 202 | Non-system applications use system APIs. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
+**Example**
+
+```js
+let slotId = 0;
+call.canSetCallTransferTime(slotId).then(() => {
+ console.log(`canSetCallTransferTime success, promise: data->${JSON.stringify(data)}`);
+}).catch((err) => {
+ console.error(`canSetCallTransferTime fail, promise: err->${JSON.stringify(err)}`);
+});
+```
+
+
+## call.inputDialerSpecialCode10+
+
+inputDialerSpecialCode\(inputCode: string, callback: AsyncCallback\\): void
+
+Performs a secret code broadcast. This API uses an asynchronous callback to return the result.
+
+**System API**: This is a system API.
+
+**Required Permissions**: ohos.permission.PLACE_CALL
+
+**System capability**: SystemCapability.Telephony.CallManager
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ----------- | ---------------------------- | ---- | ----------------------------------------- |
+| inputCode | string | Yes | Secret code, for example, **2846579** (project menu).|
+| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
+
+**Error codes**
+
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 202 | Non-system applications use system APIs. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+
+**Example**
+
+```js
+call.inputDialerSpecialCode('2846579', (err) => {
+ console.log(`callback: err->${JSON.stringify(err)}`);
+});
+```
+
+## call.inputDialerSpecialCode10+
+
+inputDialerSpecialCode\(inputCode: string\): Promise\
+
+Performs a secret code broadcast. This API uses a promise to return the result.
+
+**System API**: This is a system API.
+
+**Required Permissions**: ohos.permission.PLACE_CALL
+
+**System capability**: SystemCapability.Telephony.CallManager
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ----------- | ---------------------------- | ---- | ----------------------------------------- |
+| inputCode | string | Yes | Secret code, for example, **2846579** (project menu).|
+
+**Return value**
+
+| Type | Description |
+| ------------------- | --------------------------- |
+| Promise<void> | Promise used to return the result.|
+
+**Error codes**
+
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 202 | Non-system applications use system APIs. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+
+**Example**
+
+```js
+try {
+ call.inputDialerSpecialCode('2846579');
+ console.log(`inputDialerSpecialCode success`);
+} catch (error) {
+ console.log(`inputDialerSpecialCode fail, promise: err->${JSON.stringify(error)}`);
+}
+```
+
+
## DialOptions
Provides an option for determining whether a call is a video call.
@@ -4071,23 +4622,25 @@ Provides an option for determining whether a call is a video call.
| Name | Type | Mandatory| Description |
| ------------------------ | ---------------------------------- | ---- | ----------------------------------------------------------------------------------------------- |
| extras | boolean | No | Indication of a video call.
- **true**: video call
- **false** (default): voice call |
-| accountId 8+ | number | No | Account ID.
- **0**: card slot 1
- **1**: card slot 2
|
-| videoState 8+ | [VideoStateType](#videostatetype7) | No | Video state type. |
-| dialScene 8+ | [DialScene](#dialscene8) | No | Dialup scenario. |
-| dialType 8+ | [DialType](#dialtype8) | No | Dialup type. |
+| accountId 8+ | number | No | Account ID.
- **0**: card slot 1
- **1**: card slot 2
This is a system API. |
+| videoState 8+ | [VideoStateType](#videostatetype7) | No | Video state type. This is a system API. |
+| dialScene 8+ | [DialScene](#dialscene8) | No | Dialup scenario. This is a system API. |
+| dialType 8+ | [DialType](#dialtype8) | No | Dialup type. This is a system API. |
## DialCallOptions9+
Defines options for initiating a call.
+**System API**: This is a system API.
+
**System capability**: SystemCapability.Telephony.CallManager
-| Name | Type | Mandatory| Description |
-| ------------------------ | ---------------------------------- | ---- | ------------------------------------------------------------ |
-| accountId 9+ | number | No | Account ID.
- **0**: card slot 1
- **1**: card slot 2
This is a system API.|
-| videoState 9+ | [VideoStateType](#videostatetype7) | No | Video state type. This is a system API. |
-| dialScene 9+ | [DialScene](#dialscene8) | No | Dialup scenario. This is a system API. |
-| dialType 9+ | [DialType](#dialtype8) | No | Dialup type. This is a system API. |
+| Name | Type | Mandatory| Description |
+| ------------------------ | ---------------------------------- | ---- | ------------------------------------------- |
+| accountId 9+ | number | No | Account ID.
- **0**: card slot 1
- **1**: card slot 2
|
+| videoState 9+ | [VideoStateType](#videostatetype7) | No | Video state type. |
+| dialScene 9+ | [DialScene](#dialscene8) | No | Dialup scenario. |
+| dialType 9+ | [DialType](#dialtype8) | No | Dialup type. |
## CallState
@@ -4138,6 +4691,19 @@ Enumerates IMS call modes.
| CALL_MODE_SEND_RECEIVE | 3 | Sending and receiving calls.|
| CALL_MODE_VIDEO_PAUSED | 4 | Pausing video calls. |
+## VoNRState10+
+
+Enumerates VoNR switch states.
+
+**System API**: This is a system API.
+
+**System capability**: SystemCapability.Telephony.CallManager
+
+| Name | Value | Description |
+| ---------------------- | ---- | ----------------- |
+| VONR_STATE_OFF | 0 | Disabled. |
+| VONR_STATE_ON | 1 | Enabled. |
+
## AudioDevice8+
Enumerates audio devices.
@@ -4154,6 +4720,36 @@ Enumerates audio devices.
| DEVICE_BLUETOOTH_SCO | 3 | Bluetooth SCO device. |
| DEVICE_MIC | 4 | Microphone device|
+## AudioDeviceType10+
+
+Enumerates audio device types.
+
+**System API**: This is a system API.
+
+**System capability**: SystemCapability.Telephony.CallManager
+
+| Name | Value | Description |
+| -------------------- | ---- | ----------- |
+| DEVICE_EARPIECE | 0 | Headset device. |
+| DEVICE_SPEAKER | 1 | Speaker device. |
+| DEVICE_WIRED_HEADSET | 2 | Wired headset device.|
+| DEVICE_BLUETOOTH_SCO | 3 | Bluetooth SCO device. |
+
+## AudioDeviceInfo10+
+
+Defines the audio device information.
+
+**System API**: This is a system API.
+
+**System capability**: SystemCapability.Telephony.CallManager
+
+| Name | Type | Mandatory | Description |
+| --------------------------------- | ------------------------------------- | ---- | ---------------- |
+| audioDeviceList 10+ | [Array\](#audiodevice8) | Yes | Audio device list. |
+| currentAudioDevice 10+ | [AudioDevice](#audiodevice8) | Yes | Audio device type. |
+| isMuted 10+ | boolean | Yes | Whether the audio device is muted. |
+
+
## CallRestrictionType8+
Enumerates call restriction types.
@@ -4511,7 +5107,7 @@ Enumerates call disconnection causes.
| BEARER_SERVICE_NOT_IMPLEMENTED9+ | 65 | Bearer service not implemented. |
| ACM_EQUALTO_OR_GREATER_THAN_THE_MAXIMUM_VALUE9+ | 68 | ACM greater than or equal to the maximum value. |
| REQUESTED_FACILITY_NOT_IMPLEMENTED9+ | 69 | Requested facility not implemented. |
-| ONLY_RESTRICTED_DIGITAL_INFO_BEARER_CAPABILITY_IS_AVAILABLE9+ | 70 | Only restricted digital information capability available. |
+| ONLY_RESTRICTED_DIGITAL_INFO_BEARER_CAPABILITY_IS_AVAILABLE9+ | 70 | Only restricted digital information bearer capability available. |
| SERVICE_OR_OPTION_NOT_IMPLEMENTED_UNSPECIFIED9+ | 79 | Service or option not implemented, unspecified. |
| INVALID_TRANSACTION_IDENTIFIER_VALUE9+ | 81 | Invalid transaction identifier value. |
| USER_NOT_MEMBER_OF_CUG9+ | 87 | User not member of CUG. |
diff --git a/en/application-dev/reference/apis/js-apis-camera.md b/en/application-dev/reference/apis/js-apis-camera.md
index 106aa2ecdcea58b97966a46e1f4ea38bcb2432eb..b8d4e4b54a0d34826962b8d3d66b5e7f1b30be13 100644
--- a/en/application-dev/reference/apis/js-apis-camera.md
+++ b/en/application-dev/reference/apis/js-apis-camera.md
@@ -550,7 +550,7 @@ Listens for camera status changes. This API uses an asynchronous callback to ret
**Example**
```js
-cameraManager.on('cameraStatus', (cameraStatusInfo) => {
+cameraManager.on('cameraStatus', (err, cameraStatusInfo) => {
console.log(`camera : ${cameraStatusInfo.camera.cameraId}`);
console.log(`status: ${cameraStatusInfo.status}`);
})
@@ -1679,7 +1679,7 @@ The coordinate system is based on the horizontal device direction with the devic
| Name | Type | Mandatory| Description |
| ------------- | -------------------------------| ---- | ------------------- |
-| exposurePoint | [Point](#point) | Yes | Exposure point. |
+| exposurePoint | [Point](#point) | Yes | Metering point. The value range of x and y must be within [0,1]. If a value less than 0 is passed, the value **0** is used. If a value greater than **1** is passed, the value **1** is used. |
**Return value**
@@ -1754,7 +1754,7 @@ Before the setting, you are advised to use **[getExposureBiasRange](#getexposure
| Name | Type | Mandatory| Description |
| -------- | -------------------------------| ---- | ------------------- |
-| exposureBias | number | Yes | Exposure bias to set, which must be within the range obtained by running **getExposureBiasRange** interface. If the API call fails, an error code defined in [CameraErrorCode](#cameraerrorcode) is returned.|
+| exposureBias | number | Yes | EV. The supported EV range can be obtained by calling **getExposureBiasRange**. If calling the API fails, an error code defined in [CameraErrorCode](#cameraerrorcode) will be returned. If the value passed is not within the supported range, the nearest critical point is used.|
**Error codes**
@@ -1936,7 +1936,7 @@ The coordinate system is based on the horizontal device direction with the devic
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | ------------------- |
-| Point1 | [Point](#point) | Yes | Focal point. |
+| Point1 | [Point](#point) | Yes | Focal point. The value range of x and y must be within [0,1]. If a value less than 0 is passed, the value **0** is used. If a value greater than **1** is passed, the value **1** is used. |
**Return value**
@@ -2075,7 +2075,7 @@ Sets a zoom ratio, with a maximum precision of two decimal places.
| Name | Type | Mandatory| Description |
| --------- | -------------------- | ---- | ------------------- |
-| zoomRatio | number | Yes | Zoom ratio. You can use **getZoomRatioRange** to obtain the supported values.|
+| zoomRatio | number | Yes | Zoom ratio. The supported zoom ratio range can be obtained by calling **getZoomRatioRange**. If the value passed is not within the supported range, the nearest critical point is used.|
**Return value**
@@ -2735,7 +2735,7 @@ Captures a photo with the specified shooting parameters. This API uses a promise
| Name | Type | Mandatory| Description |
| ------- | ------------------------------------------- | ---- | -------- |
-| setting | [PhotoCaptureSetting](#photocapturesetting) | No | Shooting settings.|
+| setting | [PhotoCaptureSetting](#photocapturesetting) | No | Shooting parameters. The input of **undefined** is processed as if no parameters were passed.|
**Return value**
diff --git a/en/application-dev/reference/apis/js-apis-convertxml.md b/en/application-dev/reference/apis/js-apis-convertxml.md
index 4c66c928fb7ee6c5482d39db7b39acaa6793691e..8aad8fdf810b9f3246672b8c3d2e21df7733d94e 100644
--- a/en/application-dev/reference/apis/js-apis-convertxml.md
+++ b/en/application-dev/reference/apis/js-apis-convertxml.md
@@ -28,7 +28,7 @@ Converts an XML text into a JavaScript object.
| Name | Type | Mandatory| Description |
| ------- | --------------------------------- | ---- | --------------- |
| xml | string | Yes | XML text to convert.|
-| options | [ConvertOptions](#convertoptions) | No | Options for conversion. |
+| options | [ConvertOptions](#convertoptions) | No | Options for conversion. The default value is a **ConvertOptions** object, which consists of the default values of the attributes in the object. |
**Return value**
@@ -89,7 +89,7 @@ Converts an XML text into a JavaScript object.
| Name | Type | Mandatory| Description |
| ------- | --------------------------------- | ---- | --------------- |
| xml | string | Yes | XML text to convert.|
-| options | [ConvertOptions](#convertoptions) | No | Options for conversion. |
+| options | [ConvertOptions](#convertoptions) | No | Options for conversion. The default value is a **ConvertOptions** object, which consists of the default values of the attributes in the object. |
**Return value**
diff --git a/en/application-dev/reference/apis/js-apis-enterprise-applicationManager.md b/en/application-dev/reference/apis/js-apis-enterprise-applicationManager.md
new file mode 100644
index 0000000000000000000000000000000000000000..0f9d2852f88f7e6b729326e62fc3886422d63eb2
--- /dev/null
+++ b/en/application-dev/reference/apis/js-apis-enterprise-applicationManager.md
@@ -0,0 +1,434 @@
+# @ohos.enterprise.applicationManager (Application Management)
+
+The **applicationManager** module provides application management capabilities, including adding applications to or removing applications from an application blocklist, and obtaining the application blocklist. The application blocklist contains the applications that are forbidden to run. Only the enterprise device administrator applications can call the APIs provided by this module.
+
+> **NOTE**
+>
+> - The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+> - The APIs of this module can be called only after a [device administrator application](js-apis-enterprise-adminManager.md#adminmanagerenableadmin) is enabled.
+
+## Modules to Import
+
+```js
+import applicationManager from '@ohos.enterprise.applicationManager';
+```
+
+## applicationManager.addDisallowedRunningBundles
+
+addDisallowedRunningBundles(admin: Want, appIds: Array\, callback: AsyncCallback<void>): void;
+
+Adds applications to the application blocklist using the specified device administrator application. This API uses an asynchronous callback to return the result. The applications added to the blocklist cannot run under the administrator user.
+
+**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_POLICY
+
+**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
+
+**System API**: This is a system API.
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | ------------------------------- |
+| admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application. |
+| appIds | Array<string> | Yes | IDs of the applications to add. |
+| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
+
+**Error codes**
+
+For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
+
+| ID| Error Message |
+| ------- | ---------------------------------------------------------------------------- |
+| 9200001 | the application is not an administrator of the device. |
+| 9200002 | the administrator application does not have permission to manage the device. |
+
+
+**Example**
+
+```js
+let wantTemp = {
+ bundleName: "com.example.myapplication",
+ abilityName: "EntryAbility",
+};
+let appIds = ["com.example.myapplication"];
+
+applicationManager.addDisallowedRunningBundles(wantTemp, appIds, (error) => {
+ if (error != null) {
+ console.log("error code:" + error.code + " error message:" + error.message);
+ }
+});
+```
+
+## applicationManager.addDisallowedRunningBundles
+
+addDisallowedRunningBundles(admin: Want, appIds: Array\, userId: number, callback: AsyncCallback<void>): void;
+
+Adds applications to the application list for a user using the specified device administrator application. This API uses an asynchronous callback to return the result. The applications added to the blocklist cannot run under the user specified by **userId**.
+
+**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_POLICY
+
+**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
+
+**System API**: This is a system API.
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ----- | ----------------------------------- | ---- | ------- |
+| admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application. |
+| appIds | Array<string> | Yes | IDs of the applications to add. |
+| userId | number | Yes | User ID. The default value is the user ID of the caller. The user ID must be greater than or equal to **0**.|
+| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
+
+**Error codes**
+
+For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
+
+| ID| Error Message |
+| ------- | ---------------------------------------------------------------------------- |
+| 9200001 | the application is not an administrator of the device. |
+| 9200002 | the administrator application does not have permission to manage the device. |
+
+**Example**
+
+```js
+let wantTemp = {
+ bundleName: "com.example.myapplication",
+ abilityName: "EntryAbility",
+};
+let appIds = ["com.example.myapplication"];
+
+applicationManager.addDisallowedRunningBundles(wantTemp, appIds, 100, (error) => {
+ if (error != null) {
+ console.log("error code:" + error.code + " error message:" + error.message);
+ }
+});
+```
+
+## applicationManager.addDisallowedRunningBundles
+
+addDisallowedRunningBundles(admin: Want, appIds: Array\, userId?: number): Promise<void>;
+
+Adds applications to the application blocklist using the specified device administrator application. This API uses a promise to return the result. If **userId** is passed in when this API is called, the added applications cannot run under the specified user. If **userId** is not passed in, the added applications cannot run under the current user.
+
+**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_POLICY
+
+**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
+
+**System API**: This is a system API.
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ----- | ----------------------------------- | ---- | ------- |
+| admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application. |
+| appIds | Array<string> | Yes | IDs of the applications to add. |
+| userId | number | No | User ID. The default value is the user ID of the caller. The user ID must be greater than or equal to **0**.|
+
+**Return value**
+
+| Type | Description |
+| --------------------- | ------------------------- |
+| Promise<void> | Promise that returns no value. An error object is thrown when the applications fail to be added. |
+
+**Error codes**
+
+For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
+
+| ID| Error Message |
+| ------- | ---------------------------------------------------------------------------- |
+| 9200001 | the application is not an administrator of the device. |
+| 9200002 | the administrator application does not have permission to manage the device. |
+
+**Example**
+
+```js
+let wantTemp = {
+ bundleName: "com.example.myapplication",
+ abilityName: "EntryAbility",
+};
+let appIds = ["com.example.myapplication"];
+
+applicationManager.addDisallowedRunningBundles(wantTemp, appIds, 100).then(() => {
+ console.log("success");
+}).catch(error => {
+ console.log("error code:" + error.code + " error message:" + error.message);
+});
+```
+
+## applicationManager.removeDisallowedRunningBundles
+
+removeDisallowedRunningBundles(admin: Want, appIds: Array\, callback: AsyncCallback<void>): void;
+
+Removes applications from the application blocklist using the specified device administrator application. This API uses an asynchronous callback to return the result. If an application blocklist exists, the applications in the blocklist cannot run under the current user.
+
+**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_POLICY
+
+**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
+
+**System API**: This is a system API.
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | ------------------------------- |
+| admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application. |
+| appIds | Array<string> | Yes | IDs of the applications to remove. |
+| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
+
+**Error codes**
+
+For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
+
+| ID| Error Message |
+| ------- | ---------------------------------------------------------------------------- |
+| 9200001 | the application is not an administrator of the device. |
+| 9200002 | the administrator application does not have permission to manage the device. |
+
+**Example**
+
+```js
+let wantTemp = {
+ bundleName: "com.example.myapplication",
+ abilityName: "EntryAbility",
+};
+let appIds = ["com.example.myapplication"];
+
+applicationManager.removeDisallowedRunningBundles(wantTemp, appIds, (error) => {
+ if (error != null) {
+ console.log("error code:" + error.code + " error message:" + error.message);
+ }
+});
+```
+
+## applicationManager.removeDisallowedRunningBundles
+
+removeDisallowedRunningBundles(admin: Want, appIds: Array\, userId: number, callback: AsyncCallback<void>): void;
+
+Removes applications from the application blocklist of a user using the specified device administrator application. This API uses an asynchronous callback to return the result. If an application blocklist exists, the applications in the blocklist cannot run under the user specified by **userId**.
+
+**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_POLICY
+
+**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
+
+**System API**: This is a system API.
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ----- | ----------------------------------- | ---- | ------- |
+| admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application. |
+| appIds | Array<string> | Yes | IDs of the applications to remove. |
+| userId | number | Yes | User ID. The default value is the user ID of the caller. The user ID must be greater than or equal to **0**.|
+| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
+
+**Error codes**
+
+For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
+
+| ID| Error Message |
+| ------- | ---------------------------------------------------------------------------- |
+| 9200001 | the application is not an administrator of the device. |
+| 9200002 | the administrator application does not have permission to manage the device. |
+
+**Example**
+
+```js
+let wantTemp = {
+ bundleName: "com.example.myapplication",
+ abilityName: "EntryAbility",
+};
+let appIds = ["com.example.myapplication"];
+
+applicationManager.removeDisallowedRunningBundles(wantTemp, appIds, 100, (error) => {
+ if (error != null) {
+ console.log("error code:" + error.code + " error message:" + error.message);
+ }
+});
+```
+
+## applicationManager.removeDisallowedRunningBundles
+
+removeDisallowedRunningBundles(admin: Want, appIds: Array\, userId?: number): Promise<void>;
+
+Removes applications from the application blocklist using the specified device administrator application. This API uses a promise to return the result. If **userId** is passed in when this API is called to remove applications from the blocklist, the applications in the blocklist cannot run under the specified user. If **userId** is not passed in, the applications in the blocklist cannot run under the current user.
+
+**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_POLICY
+
+**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
+
+**System API**: This is a system API.
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ----- | ----------------------------------- | ---- | ------- |
+| admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application. |
+| appIds | Array<string> | Yes | IDs of the applications to remove. |
+| userId | number | No | User ID. The default value is the user ID of the caller. The user ID must be greater than or equal to **0**.|
+
+**Return value**
+
+| Type | Description |
+| --------------------- | ------------------------- |
+| Promise<void> | Promise that returns no value. An error object is thrown when the applications fail to be removed. |
+
+**Error codes**
+
+For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
+
+| ID| Error Message |
+| ------- | ---------------------------------------------------------------------------- |
+| 9200001 | the application is not an administrator of the device. |
+| 9200002 | the administrator application does not have permission to manage the device. |
+
+**Example**
+
+```js
+let wantTemp = {
+ bundleName: "com.example.myapplication",
+ abilityName: "EntryAbility",
+};
+let appIds = ["com.example.myapplication"];
+
+applicationManager.removeDisallowedRunningBundles(wantTemp, appIds, 100).then(() => {
+ console.log("success");
+}).catch(error => {
+ console.log("error code:" + error.code + " error message:" + error.message);
+});
+```
+
+## applicationManager.getDisallowedRunningBundles
+
+getDisallowedRunningBundles(admin: Want, callback: AsyncCallback<Array<string>>): void;
+
+Obtains the application blocklist of the administrator user using the specified device administrator application. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_POLICY
+
+**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
+
+**System API**: This is a system API.
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | ------------------------------- |
+| admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application. |
+| callback | AsyncCallback<Array<string>> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object. |
+
+**Error codes**
+
+For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
+
+| ID| Error Message |
+| ------- | ---------------------------------------------------------------------------- |
+| 9200001 | the application is not an administrator of the device. |
+| 9200002 | the administrator application does not have permission to manage the device. |
+
+**Example**
+
+```js
+let wantTemp = {
+ bundleName: "com.example.myapplication",
+ abilityName: "EntryAbility",
+};
+
+applicationManager.getDisallowedRunningBundles(wantTemp, (error) => {
+ if (error != null) {
+ console.log("error code:" + error.code + " error message:" + error.message);
+ }
+});
+```
+
+## applicationManager.getDisallowedRunningBundles
+
+getDisallowedRunningBundles(admin: Want, userId: number, callback: AsyncCallback<Array<string>>): void;
+
+Obtains the application blocklist of a user using the specified device administrator application. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_POLICY
+
+**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
+
+**System API**: This is a system API.
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | ------------------------------- |
+| admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application. |
+| userId | number | Yes | User ID. The default value is the user ID of the caller. The user ID must be greater than or equal to **0**.|
+| callback | AsyncCallback<Array<string>> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object. |
+
+**Error codes**
+
+For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
+
+| ID| Error Message |
+| ------- | ---------------------------------------------------------------------------- |
+| 9200001 | the application is not an administrator of the device. |
+| 9200002 | the administrator application does not have permission to manage the device. |
+
+**Example**
+
+```js
+let wantTemp = {
+ bundleName: "com.example.myapplication",
+ abilityName: "EntryAbility",
+};
+
+applicationManager.getDisallowedRunningBundles(wantTemp, 100, (error) => {
+ if (error != null) {
+ console.log("error code:" + error.code + " error message:" + error.message);
+ }
+});
+```
+
+## applicationManager.getDisallowedRunningBundles
+
+getDisallowedRunningBundles(admin: Want, userId?: number): Promise<Array<string>>;
+
+Obtains the application blocklist using the specified device administrator application. This API uses a promise to return the result. If **userId** is passed in when this API is called, the device administrator application obtains the application blocklist of the specified user. If **userId** is not passed in, the device administrator application obtains the application blocklist of the current user.
+
+**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_POLICY
+
+**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
+
+**System API**: This is a system API.
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ----- | ----------------------------------- | ---- | ------- |
+| admin | [Want](js-apis-app-ability-want.md) | Yes | Device administrator application.|
+| userId | number | No | User ID. The default value is the user ID of the caller. The user ID must be greater than or equal to **0**.|
+
+**Return value**
+
+| Type | Description |
+| --------------------- | ------------------------- |
+| Promise<Array<string>> | Promise used to return the application blocklist of the administrator user.|
+
+**Error codes**
+
+For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
+
+| ID| Error Message |
+| ------- | ---------------------------------------------------------------------------- |
+| 9200001 | the application is not an administrator of the device. |
+| 9200002 | the administrator application does not have permission to manage the device. |
+
+**Example**
+
+```js
+let wantTemp = {
+ bundleName: "com.example.myapplication",
+ abilityName: "EntryAbility",
+};
+applicationManager.getDisallowedRunningBundles(wantTemp, 100).then(() => {
+ console.log("success");
+}).catch(error => {
+ console.log("error code:" + error.code + " error message:" + error.message);
+});
+```
diff --git a/en/application-dev/reference/apis/js-apis-i18n.md b/en/application-dev/reference/apis/js-apis-i18n.md
index db85444d68f958ed8af462815a2865ddc02adc0f..fe9a116b82379a17518731accb378484eb71dfc2 100644
--- a/en/application-dev/reference/apis/js-apis-i18n.md
+++ b/en/application-dev/reference/apis/js-apis-i18n.md
@@ -46,7 +46,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
| ID | Error Message |
| ------ | ---------------------- |
-| 890001 | Unspported para value. |
+| 890001 | param value not valid |
**Example**
```js
@@ -85,7 +85,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
| ID | Error Message |
| ------ | ---------------------- |
-| 890001 | Unspported para value. |
+| 890001 | param value not valid |
**Example**
```js
@@ -116,7 +116,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
| ID | Error Message |
| ------ | ---------------------- |
-| 890001 | Unspported para value. |
+| 890001 | param value not valid |
**Example**
```js
@@ -153,7 +153,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
| ID | Error Message |
| ------ | ---------------------- |
-| 890001 | Unspported para value. |
+| 890001 | param value not valid |
**Example**
```js
@@ -191,7 +191,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
| ID | Error Message |
| ------ | ---------------------- |
-| 890001 | Unspported para value. |
+| 890001 | param value not valid |
**Example**
```js
@@ -222,7 +222,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
| ID | Error Message |
| ------ | ---------------------- |
-| 890001 | Unspported para value. |
+| 890001 | param value not valid |
**Example**
```js
@@ -257,7 +257,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
| ID | Error Message |
| ------ | ---------------------- |
-| 890001 | Unspported para value. |
+| 890001 | param value not valid |
**Example**
```js
@@ -288,7 +288,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
| ID | Error Message |
| ------ | ---------------------- |
-| 890001 | Unspported para value. |
+| 890001 | param value not valid |
**Example**
```js
@@ -323,7 +323,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
| ID | Error Message |
| ------ | ---------------------- |
-| 890001 | Unspported para value. |
+| 890001 | param value not valid |
**Example**
```js
@@ -354,7 +354,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
| ID | Error Message |
| ------ | ---------------------- |
-| 890001 | Unspported para value. |
+| 890001 | param value not valid |
**Example**
```js
@@ -389,7 +389,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
| ID | Error Message |
| ------ | ---------------------- |
-| 890001 | Unspported para value. |
+| 890001 | param value not valid |
**Example**
```js
@@ -420,7 +420,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
| ID | Error Message |
| ------ | ---------------------- |
-| 890001 | Unspported para value. |
+| 890001 | param value not valid |
**Example**
```js
@@ -455,7 +455,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
| ID | Error Message |
| ------ | ---------------------- |
-| 890001 | Unspported para value. |
+| 890001 | param value not valid |
**Example**
```js
@@ -492,7 +492,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
| ID | Error Message |
| ------ | ---------------------- |
-| 890001 | Unspported para value. |
+| 890001 | param value not valid |
**Example**
```js
@@ -530,7 +530,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
| ID | Error Message |
| ------ | ---------------------- |
-| 890001 | Unspported para value. |
+| 890001 | param value not valid |
**Example**
```js
@@ -563,7 +563,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
| ID | Error Message |
| ------ | ---------------------- |
-| 890001 | Unspported para value. |
+| 890001 | param value not valid |
**Example**
```js
@@ -594,7 +594,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
| ID | Error Message |
| ------ | ---------------------- |
-| 890001 | Unspported para value. |
+| 890001 | param value not valid |
**Example**
```js
@@ -625,7 +625,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
| ID | Error Message |
| ------ | ---------------------- |
-| 890001 | Unspported para value. |
+| 890001 | param value not valid |
**Example**
```js
@@ -660,7 +660,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
| ID | Error Message |
| ------ | ---------------------- |
-| 890001 | Unspported para value. |
+| 890001 | param value not valid |
**Example**
```ts
@@ -691,7 +691,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
| ID | Error Message |
| ------ | ---------------------- |
-| 890001 | Unspported para value. |
+| 890001 | param value not valid |
**Example**
```ts
@@ -1737,6 +1737,35 @@ Obtains the **TimeZone** object corresponding to the specified time zone city ID
let timezone = I18n.TimeZone.getTimezoneFromCity("Shanghai");
```
+### getTimezonesByLocation10+
+
+static getTimezonesByLocation(longitude: number, latitude: number): Array<TimeZone>
+
+Creates an array of **TimeZone** objects corresponding to the specified longitude and latitude.
+
+**System capability**: SystemCapability.Global.I18n
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| --------- | ------ | ---- | ------ |
+| longitude | number | Yes | Longitude. The value ranges from **-180** to **179.9**. A positive value is used for east longitude and a negative value is used for west longitude.|
+| latitude | number | Yes | Latitude. The value ranges from **-90** to **89.9**. A positive value is used for north latitude and a negative value is used for south latitude.|
+
+**Return value**
+
+| Type | Description |
+| -------- | ----------- |
+| Array<[TimeZone](#timezone)> | Array of **TimeZone** objects.|
+
+**Example**
+ ```js
+ let timezoneArray = I18n.TimeZone.getTimezonesByLocation(-118.1, 34.0);
+ for (var i = 0; i < timezoneArray.length; i++) {
+ let tzId = timezoneArray[i].getID();
+ }
+ ```
+
## Transliterator9+
diff --git a/en/application-dev/reference/apis/js-apis-image.md b/en/application-dev/reference/apis/js-apis-image.md
index 9c6037df7f907354d71a6eacb211855b579945a5..34337fa9198edeeeab9d437bc084538777834d31 100644
--- a/en/application-dev/reference/apis/js-apis-image.md
+++ b/en/application-dev/reference/apis/js-apis-image.md
@@ -879,6 +879,53 @@ async function Demo() {
}
```
+### getColorSpace10+
+
+getColorSpace(): colorSpaceManager.ColorSpaceManager
+
+Obtains the color space of this image
+
+**System capability**: SystemCapability.Multimedia.Image.Core
+
+**Return value**
+
+| Type | Description |
+| ----------------------------------- | ---------------- |
+| [colorSpaceManager.ColorSpaceManager](js-apis-colorSpaceManager.md#colorspacemanager) | Color space obtained.|
+
+**Example**
+
+```js
+import colorSpaceManager from '@ohos.graphics.colorSpaceManager';
+async function Demo() {
+ let csm = pixelmap.getColorSpace();
+}
+```
+
+### setColorSpace10+
+
+setColorSpace(colorSpace: colorSpaceManager.ColorSpaceManager): void
+
+Sets the color space for this image.
+
+**System capability**: SystemCapability.Multimedia.Image.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ---------- | ----------------------------------- | ---- | --------------- |
+| colorSpace | [colorSpaceManager.ColorSpaceManager](js-apis-colorSpaceManager.md#colorspacemanager) | Yes | Color space to set.|
+
+**Example**
+
+```js
+import colorSpaceManager from '@ohos.graphics.colorSpaceManager';
+async function Demo() {
+ var csm = colorSpaceManager.create(colorSpaceName);
+ pixelmap.setColorSpace(csm);
+}
+```
+
### release7+
release():Promise\
@@ -937,7 +984,7 @@ Creates an **ImageSource** instance based on the URI.
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ---------------------------------- |
-| uri | string | Yes | Image path. Currently, only the application sandbox path is supported.
Currently, the following formats are supported: JPG, PNG, GIF, BMP, Webp, and RAW.|
+| uri | string | Yes | Image path. Currently, only the application sandbox path is supported.
Currently, the following formats are supported: .jpg, .png, .gif, .bmp, .webp, and raw. For details, see [SVG Tags10+](#svg-tags). |
**Return value**
@@ -975,7 +1022,7 @@ Creates an **ImageSource** instance based on the URI.
| Name | Type | Mandatory| Description |
| ------- | ------------------------------- | ---- | ----------------------------------- |
-| uri | string | Yes | Image path. Currently, only the application sandbox path is supported.
Currently, the following formats are supported: JPG, PNG, GIF, BMP, Webp, and RAW.|
+| uri | string | Yes | Image path. Currently, only the application sandbox path is supported.
Currently, the following formats are supported: .jpg, .png, .gif, .bmp, .webp, and raw. For details, see [SVG Tags10+](#svg-tags). |
| options | [SourceOptions](#sourceoptions9) | Yes | Image properties, including the image index and default property value.|
**Return value**
@@ -1553,10 +1600,10 @@ let decodeOpts = {
editable: true,
desiredSize: { width: 198, height: 202 },
rotate: 0,
- desiredPixelFormat: RGBA_8888,
+ desiredPixelFormat: 3,
index: 0,
};
-let pixelmaplist = await imageSourceApi.createPixelMapList(decodeOpts);
+let pixelmaplist = imageSourceApi.createPixelMapList(decodeOpts);
```
### createPixelMapList10+
@@ -1604,7 +1651,7 @@ let decodeOpts = {
editable: true,
desiredSize: { width: 198, height: 202 },
rotate: 0,
- desiredPixelFormat: RGBA_8888,
+ desiredPixelFormat: 3,
index: 0,
};
imageSourceApi.createPixelMap(decodeOpts, pixelmaplist => {
@@ -1651,12 +1698,12 @@ Obtains an array of delay times. This API uses a promise to return the result.
**Example**
```js
-let delayTimes = await imageSourceApi.getDelayTime();
+let delayTimes = imageSourceApi.getDelayTime();
```
### getFrameCount10+
-getFrameCount(callback: AsyncCallback): void;
+getFrameCount(callback: AsyncCallback\): void;
Obtains the number of frames. This API uses an asynchronous callback to return the result.
@@ -1693,7 +1740,7 @@ Obtains the number of frames. This API uses a promise to return the result.
**Example**
```js
-let frameCount = await imageSourceApi.getFrameCount();
+let frameCount = imageSourceApi.getFrameCount();
```
### release
@@ -2787,7 +2834,50 @@ Describes the color components of an image.
| pixelStride | number | Yes | No | Pixel stride. |
| byteBuffer | ArrayBuffer | Yes | No | Component buffer.|
-## ResponseCode
+## Supplementary Information
+### SVG Tags
+
+The SVG tags are supported since API verison 10. The used version is (SVG) 1.1. Currently, the following tags are supported:
+- a
+- circla
+- clipPath
+- defs
+- ellipse
+- feBlend
+- feColorMatrix
+- feComposite
+- feDiffuseLighting
+- feDisplacementMap
+- feDistantLight
+- feFlood
+- feGaussianBlur
+- feImage
+- feMorphology
+- feOffset
+- fePointLight
+- feSpecularLighting
+- feSpotLight
+- feTurbulence
+- filter
+- g
+- image
+- line
+- linearGradient
+- mask
+- path
+- pattern
+- polygon
+- polyline
+- radialGradient
+- rect
+- stop
+- svg
+- text
+- textPath
+- tspan
+- use
+
+### ResponseCode
Enumerates the response codes returned upon build errors.
diff --git a/en/application-dev/reference/apis/js-apis-intl.md b/en/application-dev/reference/apis/js-apis-intl.md
index cec10d9eef5fbd50d9d81ca6a5358d57d78fdbf0..99131363c58faef8abe196d0e20e01b176a1258e 100644
--- a/en/application-dev/reference/apis/js-apis-intl.md
+++ b/en/application-dev/reference/apis/js-apis-intl.md
@@ -1,7 +1,6 @@
# @ohos.intl (Internationalization)
-The **intl** module provides basic i18n capabilities, such as time and date formatting, number formatting, and string sorting, through the standard i18n APIs defined in ECMA 402.
-
+ The **intl** module provides basic i18n capabilities, such as time and date formatting, number formatting, and string sorting, through the standard i18n APIs defined in ECMA 402.
The [i18n](js-apis-i18n.md) module provides enhanced i18n capabilities through supplementary interfaces that are not defined in ECMA 402. It works with the intl module to provide a complete suite of i18n capabilities.
> **NOTE**
@@ -68,7 +67,7 @@ Creates a **Locale** object.
| Name | Type | Mandatory | Description |
| -------------------- | -------------------------------- | ---- | ---------------------------- |
| locale | string | Yes | A string containing locale information, including the language, optional script, and region. For details about the international standards and combination modes for the language, script, and country or region, see [intl Development](../../internationalization/intl-guidelines.md#setting-locale-information).|
-| options9+ | [LocaleOptions](#localeoptions9) | No | Options for creating the **Locale** object. |
+| options | [LocaleOptions](#localeoptions6) | No | Options for creating the **Locale** object. |
**Example**
```js
@@ -160,9 +159,10 @@ Minimizes information of the **Locale** object. If the script and locale informa
```
-## LocaleOptions9+
+## LocaleOptions6+
Represents the locale options.
+In API version 9, the attributes in **LocaleOptions** are optional.
**System capability**: SystemCapability.Global.I18n
@@ -207,7 +207,7 @@ Creates a **DateTimeOptions** object for the specified locale.
| Name | Type | Mandatory | Description |
| -------------------- | ------------------------------------ | ---- | ---------------------------- |
| locale | string \| Array<string> | Yes | A string containing locale information, including the language, optional script, and region.|
-| options9+ | [DateTimeOptions](#datetimeoptions9) | No | Options for creating a **DateTimeFormat** object. |
+| options | [DateTimeOptions](#datetimeoptions6) | No | Options for creating a **DateTimeFormat** object. |
**Example**
```js
@@ -299,7 +299,7 @@ Obtains the formatting options for **DateTimeFormat** object.
| Type | Description |
| ------------------------------------ | ----------------------------- |
-| [DateTimeOptions](#datetimeoptions9) | Formatting options for **DateTimeFormat** objects.|
+| [DateTimeOptions](#datetimeoptions6) | Formatting options for **DateTimeFormat** objects.|
**Example**
```js
@@ -311,9 +311,10 @@ Obtains the formatting options for **DateTimeFormat** object.
```
-## DateTimeOptions9+
+## DateTimeOptions6+
Provides the options for the **DateTimeFormat** object.
+In API version 9, the attributes in **DateTimeOptions** are optional.
**System capability**: SystemCapability.Global.I18n
@@ -371,7 +372,7 @@ Creates a **NumberFormat** object for the specified locale.
| Name | Type | Mandatory | Description |
| -------------------- | -------------------------------- | ---- | ---------------------------- |
| locale | string \| Array<string> | Yes | A string containing locale information, including the language, optional script, and region.|
-| options9+ | [NumberOptions](#numberoptions9) | No | Options for creating a **NumberFormat** object. |
+| options | [NumberOptions](#numberoptions6) | No | Options for creating a **NumberFormat** object. |
**Example**
```js
@@ -421,7 +422,7 @@ Obtains the options of the **NumberFormat** object.
| Type | Description |
| -------------------------------- | --------------------------- |
-| [NumberOptions](#numberoptions9) | Formatting options for **NumberFormat** objects.|
+| [NumberOptions](#numberoptions6) | Formatting options for **NumberFormat** objects.|
**Example**
@@ -434,9 +435,10 @@ Obtains the options of the **NumberFormat** object.
```
-## NumberOptions9+
+## NumberOptions6+
Defines the device capability.
+In API version 9, the attributes in **NumberOptions** are optional.
**System capability**: SystemCapability.Global.I18n
@@ -448,7 +450,7 @@ Defines the device capability.
| currencyDisplay | string | Yes | Yes | Currency display mode. The value can be **symbol**, **narrowSymbol**, **code**, or **name**.|
| unit | string | Yes | Yes | Unit name, for example, **meter**, **inch**, or **hectare**. |
| unitDisplay | string | Yes | Yes | Unit display format. The value can be **long**, **short**, or **narrow**.|
-| unitUsage | string | Yes | Yes | Unit usage scenario. The value can be any of the following: **default**, **area-land-agricult**, **area-land-commercl**, **area-land-residntl**, **length-person**, **length-person-small**, **length-rainfall**, **length-road**, **length-road-small**, **length-snowfall**, **length-vehicle**, **length-visiblty**, **length-visiblty-small**, **length-person-informal**, **length-person-small-informal**, **length-road-informal**, **speed-road-travel**, **speed-wind**, **temperature-person**, **temperature-weather**, **volume-vehicle-fuel**.|
+| unitUsage8+ | string | Yes | Yes | Unit usage scenario. The value can be any of the following: **default**, **area-land-agricult**, **area-land-commercl**, **area-land-residntl**, **length-person**, **length-person-small**, **length-rainfall**, **length-road**, **length-road-small**, **length-snowfall**, **length-vehicle**, **length-visiblty**, **length-visiblty-small**, **length-person-informal**, **length-person-small-informal**, **length-road-informal**, **speed-road-travel**, **speed-wind**, **temperature-person**, **temperature-weather**, **volume-vehicle-fuel**.|
| signDisplay | string | Yes | Yes | Number sign display format. The value can be **auto**, **never**, **always**, or **expectZero**.|
| compactDisplay | string | Yes | Yes | Compact display format. The value can be **long** or **short**. |
| notation | string | Yes | Yes | Number formatting specification. The value can be **standard**, **scientific**, **engineering**, or **compact**.|
@@ -494,7 +496,7 @@ Creates a **Collator** object.
| Name | Type | Mandatory | Description |
| -------------------- | ------------------------------------ | ---- | ---------------------------- |
| locale | string \| Array<string> | Yes | A string containing locale information, including the language, optional script, and region.|
-| options9+ | [CollatorOptions](#collatoroptions9) | No | Options for creating a **Collator** object. |
+| options | [CollatorOptions](#collatoroptions8) | No | Options for creating a **Collator** object. |
**Example**
```js
@@ -545,7 +547,7 @@ Returns properties reflecting the locale and collation options of a **Collator**
| Type | Description |
| ------------------------------------ | ----------------- |
-| [CollatorOptions](#collatoroptions9) | Properties of the **Collator** object.|
+| [CollatorOptions](#collatoroptions8) | Properties of the **Collator** object.|
**Example**
```js
@@ -557,9 +559,10 @@ Returns properties reflecting the locale and collation options of a **Collator**
```
-## CollatorOptions9+
+## CollatorOptions8+
Represents the properties of a **Collator** object.
+In API version 9, the attributes in **CollatorOptions** are optional.
**System capability**: SystemCapability.Global.I18n
@@ -605,7 +608,7 @@ Creates a **PluralRules** object to obtain the singular-plural type of numbers.
| Name | Type | Mandatory | Description |
| -------------------- | ---------------------------------------- | ---- | ---------------------------- |
| locale | string \| Array<string> | Yes | A string containing locale information, including the language, optional script, and region.|
-| options9+ | [PluralRulesOptions](#pluralrulesoptions9) | No | Options for creating a **PluralRules** object. |
+| options | [PluralRulesOptions](#pluralrulesoptions8) | No | Options for creating a **PluralRules** object. |
**Example**
```js
@@ -648,9 +651,10 @@ Obtains a string that represents the singular-plural type of the specified numbe
```
-## PluralRulesOptions9+
+## PluralRulesOptions8+
Represents the properties of a **PluralRules** object.
+In API version 9, the attributes in **PluralRulesOptions** are optional.
**System capability**: SystemCapability.Global.I18n
@@ -696,7 +700,7 @@ Creates a **RelativeTimeFormat** object.
| Name | Type | Mandatory | Description |
| -------------------- | ---------------------------------------- | ---- | ---------------------------- |
| locale | string \| Array<string> | Yes | A string containing locale information, including the language, optional script, and region.|
-| options9+ | [RelativeTimeFormatInputOptions](#relativetimeformatinputoptions9) | No | Options for creating a **RelativeTimeFormat** object. |
+| options | [RelativeTimeFormatInputOptions](#relativetimeformatinputoptions8) | No | Options for creating a **RelativeTimeFormat** object. |
**Example**
```js
@@ -788,9 +792,10 @@ Obtains the formatting options for **RelativeTimeFormat** objects.
```
-## RelativeTimeFormatInputOptions9+
+## RelativeTimeFormatInputOptions8+
Represents the properties of a **RelativeTimeFormat** object.
+In API version 9, the attributes in **RelativeTimeFormatInputOptions** are optional.
**System capability**: SystemCapability.Global.I18n
diff --git a/en/application-dev/reference/apis/js-apis-loglibrary.md b/en/application-dev/reference/apis/js-apis-loglibrary.md
new file mode 100644
index 0000000000000000000000000000000000000000..cbb849eab6fca14001bdd9f648fb2ce60cd8e2f1
--- /dev/null
+++ b/en/application-dev/reference/apis/js-apis-loglibrary.md
@@ -0,0 +1,319 @@
+# @ohos.logLibrary (Log Library)
+
+The **logLibrary** module provides APIs for obtaining various system maintenance and test logs.
+
+> **NOTE**
+>
+> - The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+> - The APIs provided by this module are system APIs.
+
+## Modules to Import
+
+```js
+import logLibrary from '@ohos.logLibrary';
+```
+
+## LogEntry
+
+Defines a **LogEntry** object.
+
+**System capability**: SystemCapability.HiviewDFX.Hiview.LogLibrary
+
+| Name| Type| Readable| Writable| Description|
+| -------- | -------- | -------- | -------- | -------- |
+| name | string | Yes| No| Log file name. |
+| mtime | number | Yes| No | Time of the last modification to the file. The value is the number of seconds elapsed since 00:00:00 on January 1, 1970.|
+| size | number | Yes| No | File size, in bytes.|
+
+## logLibrary.list
+
+list(logType: string): LogEntry[]
+
+Obtains the list of log files of the specified type in synchronous mode. This API accepts objects of the string type as input parameters and returns a list log files of the specified type.
+
+**Required permission**: ohos.permission.READ_HIVIEW_SYSTEM
+
+**System capability**: SystemCapability.HiviewDFX.Hiview.LogLibrary
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| --------- | ------------------------- | ---- | ------------------------------------------------------------ |
+| logType | string | Yes| Log type, for example, **HILOG**, **FAULTLOG**, **BETACLUB**, or **REMOTELOG**.|
+
+**Return value**
+
+| Type | Description |
+| ------------------- | ------------------------------------------------------------ |
+| LogEntry[] | Array of log file objects.|
+
+**Error codes**
+
+For details about error codes, see [Log Library Error Codes](../errorcodes/errorcode-loglibrary.md).
+
+| ID| Error Message|
+| ------- | ----------------------------------------------------------------- |
+| 201 | Permission denied. |
+| 202 | Permission denied, non-system app called system api. |
+| 401 | Invalid argument.|
+
+**Example**
+
+```js
+import logLibrary from '@ohos.logLibrary';
+
+try {
+ let logObj = logLibrary.list('HILOG');
+ // do something here.
+} catch (error) {
+ console.error(`error code: ${error.code}, error msg: ${error.message}`);
+}
+```
+
+## logLibrary.copy
+
+copy(logType: string, logName: string, dest: string): Promise<void>
+
+Copies log files of the specified type to the target application directory. This API uses a promise to return the result.
+
+**Required permission**: ohos.permission.READ_HIVIEW_SYSTEM
+
+**System capability**: SystemCapability.HiviewDFX.Hiview.LogLibrary
+
+**Parameters**
+
+| Name | Type | Mandatory| Description|
+| --------- | ----------------------- | ---- | --------------- |
+| logType | string | Yes| Log type, for example, **HILOG**, **FAULTLOG**, **BETACLUB**, or **REMOTELOG**.|
+| logName | string | Yes | Log file name.|
+| dest | string | Yes | Target directory. Enter the relative path of the directory. If this parameter is specified, log files will be saved to the **hiview/dest** folder in the application cache path, that is, **../cache/hiview/dest**. You can enter a multi-level directory.
If you leave this parameter empty, log files will be saved to the root directory, that is, the **hiview** folder in the application cache path.|
+
+**Return value**
+
+| Type | Description |
+| ------------------- | ------------------------------------------------------------ |
+| Promise<void> | Promise used to return the result. Depending on whether the operation is successful, you can use the **then()** or **catch()** method to process the callback.|
+
+**Error codes**
+
+For details about error codes, see [Log Library Error Codes](../errorcodes/errorcode-loglibrary.md).
+
+| ID| Error Message|
+| -------- | ---------------------------------------------------------------- |
+| 201 | Permission denied. |
+| 202 | Permission denied, non-system app called system api. |
+| 401 | Invalid argument.|
+| 21300001 | Source file does not exists. |
+
+**Example**
+
+```js
+import logLibrary from '@ohos.logLibrary';
+
+try {
+ logLibrary.copy('HILOG', 'hiapplogcat-1.zip', ''
+ ).then(
+ (val) => {
+ // do something here.
+ }
+ ).catch(
+ (err) => {
+ // do something here.
+ }
+ )
+} catch (error) {
+ console.error(`error code: ${error.code}, error msg: ${error.message}`);
+}
+```
+
+## logLibrary.copy
+
+copy(logType: string, logName: string, dest: string, callback: AsyncCallback<void>): void
+
+Copies log files of the specified type to the target application directory. This API uses an asynchronous callback to return the result.
+
+**Required permission**: ohos.permission.READ_HIVIEW_SYSTEM
+
+**System capability**: SystemCapability.HiviewDFX.Hiview.LogLibrary
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| --------- | ------------------------- | ---- | ------------------------------------------------------------ |
+| logType | string | Yes| Log type, for example, **HILOG**, **FAULTLOG**, **BETACLUB**, or **REMOTELOG**.|
+| logName | string | Yes | Log file name.|
+| dest | string | Yes | Target directory. Enter the relative path of the directory. If this parameter is specified, log files will be saved to the **hiview/dest** folder in the application cache path, that is, **../cache/hiview/dest**. You can enter a multi-level directory.
If you leave this parameter empty, log files will be saved to the root directory, that is, the **hiview** folder in the application cache path.|
+| callback | AsyncCallback<void> | Yes| Callback used to process the received return value. The value **0** indicates that the operation is successful, and any other value indicates that the operation has failed.|
+
+**Error codes**
+
+For details about error codes, see [Log Library Error Codes](../errorcodes/errorcode-loglibrary.md).
+
+| ID| Error Message|
+| ------- | ----------------------------------------------------------------- |
+| 201 | Permission denied. |
+| 202 | Permission denied, non-system app called system api. |
+| 401 | Invalid argument.|
+| 21300001 | Source file does not exists. |
+
+**Example**
+
+```js
+import logLibrary from '@ohos.logLibrary';
+
+try {
+ logLibrary.copy('HILOG', 'hiapplogcat-1.zip', 'dir1', (error, val) => {
+ if (val === undefined) {
+ // copy failed.
+ } else {
+ // copy success.
+ }
+ });
+} catch (error) {
+ console.error(`error code: ${error.code}, error msg: ${error.message}`);
+}
+```
+
+## logLibrary.move
+
+move(logType: string, logName: string, dest: string): Promise<void>
+
+Moves log files of the specified type to the target application directory. This API uses a promise to return the result.
+
+**Required permission**: ohos.permission.WRITE_HIVIEW_SYSTEM
+
+**System capability**: SystemCapability.HiviewDFX.Hiview.LogLibrary
+
+**Parameters**
+
+| Name | Type | Mandatory| Description|
+| --------- | ----------------------- | ---- | --------------- |
+| logType | string | Yes| Log type, for example, **FAULTLOG**, **BETACLUB**, or **REMOTELOG**.|
+| logName | string | Yes | Log file name.|
+| dest | string | Yes | Target directory. Enter the relative path of the directory. If this parameter is specified, log files will be saved to the **hiview/dest** folder in the application cache path, that is, **../cache/hiview/dest**. You can enter a multi-level directory.
If you leave this parameter empty, log files will be saved to the root directory, that is, the **hiview** folder in the application cache path.|
+
+**Return value**
+
+| Type | Description |
+| ------------------- | ------------------------------------------------------------ |
+| Promise<void> | Promise used to return the result. Depending on whether the operation is successful, you can use the **then()** or **catch()** method to process the callback.|
+
+**Error codes**
+
+For details about error codes, see [Log Library Error Codes](../errorcodes/errorcode-loglibrary.md).
+
+| ID| Error Message|
+| -------- | ---------------------------------------------------------------- |
+| 201 | Permission denied. |
+| 202 | Permission denied, non-system app called system api. |
+| 401 | Invalid argument.|
+| 21300001 | Source file does not exists. |
+
+**Example**
+
+```js
+import logLibrary from '@ohos.logLibrary';
+
+try {
+ logLibrary.move('FAULTLOG', 'fault_log_test.zip', ''
+ ).then(
+ (val) => {
+ // do something here.
+ }
+ ).catch(
+ (err) => {
+ // do something here.
+ }
+ )
+} catch (error) {
+ console.error(`error code: ${error.code}, error msg: ${error.message}`);
+}
+```
+
+## logLibrary.move
+
+move(logType: string, logName: string, dest: string, callback: AsyncCallback<void>): void
+
+Moves log files of the specified type to the target application directory. This API uses an asynchronous callback to return the result.
+
+**Required permission**: ohos.permission.WRITE_HIVIEW_SYSTEM
+
+**System capability**: SystemCapability.HiviewDFX.Hiview.LogLibrary
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| --------- | ------------------------- | ---- | ------------------------------------------------------------ |
+| logType | string | Yes| Log type, for example, **HILOG**, **FAULTLOG**, **BETACLUB**, or **REMOTELOG**.|
+| logName | string | Yes | Log file name.|
+| dest | string | Yes | Target directory. Enter the relative path of the directory. If this parameter is specified, log files will be saved to the **hiview/dest** folder in the application cache path, that is, **../cache/hiview/dest**. You can enter a multi-level directory.
If you leave this parameter empty, log files will be saved to the root directory, that is, the **hiview** folder in the application cache path.|
+| callback | AsyncCallback<void> | Yes| Callback used to process the received return value. The value **0** indicates that the operation is successful, and any other value indicates that the operation has failed.|
+
+**Error codes**
+
+For details about error codes, see [Log Library Error Codes](../errorcodes/errorcode-loglibrary.md).
+
+| ID| Error Message|
+| ------- | ----------------------------------------------------------------- |
+| 201 | Permission denied. |
+| 202 | Permission denied, non-system app called system api. |
+| 401 | Invalid argument.|
+| 21300001 | Source file does not exists. |
+
+**Example**
+
+```js
+import logLibrary from '@ohos.logLibrary';
+
+try {
+ logLibrary.move('FAULTLOG', 'fault_log_test.zip', 'dir1/dir2', (error, val) => {
+ if (val === undefined) {
+ // move failed.
+ } else {
+ // move success.
+ }
+ });
+} catch (error) {
+ console.error(`error code: ${error.code}, error msg: ${error.message}`);
+}
+```
+
+## logLibrary.remove
+
+remove(logType: string, logName: string): void
+
+Deletes log files of the specified type in synchronous mode.
+
+**Required permission**: ohos.permission.WRITE_HIVIEW_SYSTEM
+
+**System capability**: SystemCapability.HiviewDFX.Hiview.LogLibrary
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| --------- | ------------------------- | ---- | ------------------------------------------------------------ |
+| logType | string | Yes| Log type, for example, **FAULTLOG**, **BETACLUB**, or **REMOTELOG**.|
+| logName | string | Yes | Log file name.|
+
+**Error codes**
+
+For details about error codes, see [Log Library Error Codes](../errorcodes/errorcode-loglibrary.md).
+
+| ID| Error Message|
+| ------- | ----------------------------------------------------------------- |
+| 201 | Permission denied. |
+| 202 | Permission denied, non-system app called system api. |
+| 401 | Invalid argument.|
+| 21300001 | Source file does not exists. |
+
+**Example**
+
+```js
+import logLibrary from '@ohos.logLibrary';
+
+try {
+ logLibrary.remove('FAULTLOG', 'fault_log_test.zip');
+} catch (error) {
+ console.error(`error code: ${error.code}, error msg: ${error.message}`);
+}
+```
diff --git a/en/application-dev/reference/apis/js-apis-logs.md b/en/application-dev/reference/apis/js-apis-logs.md
index b2d837bae04d378938b355d535971cf6d56e48c5..fa73f169b26bec6240b6205c2970af08f5def1f8 100644
--- a/en/application-dev/reference/apis/js-apis-logs.md
+++ b/en/application-dev/reference/apis/js-apis-logs.md
@@ -1,8 +1,6 @@
-# console (Log Printing)
+# Console
-The **console** module provides basic log printing capabilities and supports log printing by log level.
-
-If you want to use more advanced log printing services, for example, filtering logs by the specified ID, you are advised to use [`@ohos.hilog`](js-apis-hilog.md).
+The **console** module provides a simple debugging console, which is similar to the JavaScript console provided by the browser.
> **NOTE**
>
@@ -10,9 +8,9 @@ If you want to use more advanced log printing services, for example, filtering l
## console.debug
-debug(message: string): void
+debug(message: string, ...arguments: any[]): void
-Prints debug-level logs.
+Prints debugging information in formatted output mode.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
@@ -20,14 +18,25 @@ Prints debug-level logs.
| Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ----------- |
-| message | string | Yes | Text to print.|
+| message | string | Yes | Text to be printed.|
+| arguments | any | No | Arguments in the message or other information to be printed.|
+**Example**
+```js
+const number = 5;
+console.debug('count: %d', number); // Print the debugging information with arguments in the message replaced.
+// count: 5
+console.debug('count:', number); // Print the message and other information.
+// count: 5
+console.debug('count:'); // Print the message only.
+// count:
+```
## console.log
-log(message: string): void
+log(message: string, ...arguments: any[]): void
-Prints debug-level logs.
+Prints log information in formatted output mode.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
@@ -35,14 +44,25 @@ Prints debug-level logs.
| Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ----------- |
-| message | string | Yes | Text to print.|
+| message | string | Yes | Text to be printed.|
+| arguments | any | No |Arguments in the message or other information to be printed.|
+**Example**
+```js
+const number = 5;
+console.log('count: %d', number); // Print the log information with arguments in the message replaced.
+// count: 5
+console.log('count:', number); // Print the message and other information.
+// count: 5
+console.log('count:'); // Print the message only.
+// count:
+```
## console.info
-info(message: string): void
+info(message: string, ...arguments: any[]): void
-Prints info-level logs.
+Prints log information in formatted output mode. This API is the alias of **console.log ()**.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
@@ -50,14 +70,25 @@ Prints info-level logs.
| Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ----------- |
-| message | string | Yes | Text to print.|
+| message | string | Yes | Text to be printed.|
+| arguments | any | No | Arguments in the message or other information to be printed.|
+**Example**
+```js
+const number = 5;
+console.info('count: %d', number); // Print the log information with arguments in the message replaced.
+// count: 5
+console.info('count:', number); // Print the message and other information.
+// count: 5
+console.info('count:'); // Print the message only.
+// count:
+```
## console.warn
-warn(message: string): void
+warn(message: string, ...arguments: any[]): void
-Prints warn-level logs.
+Prints warning information in formatted output mode.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
@@ -65,14 +96,25 @@ Prints warn-level logs.
| Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ----------- |
-| message | string | Yes | Text to print.|
+| message | string | Yes | Warning information to be printed.|
+| arguments | any | No | Arguments in the message or other information to be printed.|
+**Example**
+```js
+const str = "name should be string";
+console.warn('warn: %d', str); // Print the warning information with arguments in the message replaced.
+// warn: name should be string
+console.warn('warn:', str); // Print the message and other information.
+// warn: name should be string
+console.warn('warn:'); // Print the message only.
+// warn:
+```
## console.error
-error(message: string): void
+error(message: string, ...arguments: any[]): void
-Prints error-level logs.
+Prints error information in formatted output mode.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
@@ -80,31 +122,26 @@ Prints error-level logs.
| Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ----------- |
-| message | string | Yes | Text to print.|
+| message | string | Yes | Error information to be printed.|
+| arguments | any | No | Arguments in the message or other information to be printed.|
**Example**
-
+```js
+const str = "value is not defined";
+console.error('error: %d', str); // Print the error information with arguments in the message replaced.
+// error: value is not defined
+console.error('error:', str); // Print the message and other information.
+// error: value is not defined
+console.error('error:'); // Print the message only.
+// error:
```
-export default {
- clickConsole(){
- var versionCode = 1;
- console.info('Hello World. The current version code is ' + versionCode);
- console.log(`versionCode: ${versionCode}`);
- / / The following is supported since API version 6: console.log('versionCode:%d.', versionCode);
- }
-}
-```
-
-Switch to the HiLog window at the bottom of HUAWEI DevEco Studio. Specifically, select the current device and process, set the log level to Info, and enter Hello World in the search box. Logs that meet the search criteria are displayed, as shown in the following figure.
-
-
## console.assert10+
assert(value?: Object, ...arguments: Object[]): void
-If **value** is false, the subsequent content will be printed.
+Prints assertion information.
**System capability**: SystemCapability.Utils.Lang
@@ -112,24 +149,26 @@ If **value** is false, the subsequent content will be printed.
| Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ----------- |
-| value | Object | No | Value|
-| arguments | Object | No | Prints error messages.|
+| value | Object | No | Result value. If **value** is **false** or left blank, the output starting with "Assertion failed" is printed. If **value** is **true**, no information is printed.|
+| arguments | Object | No | Other information to be printed when **value** is **false**. If this parameter is left blank, other information is not printed.|
**Example**
-```
-console.assert(true, 'does nothing');
+```js
+console.assert(true, 'does nothing'); // Do not print error information as value is true.
+console.assert(2% 1 == 0,'does nothing'); // Do not print error information as value is true.
console.assert(false, 'console %s work', 'didn\'t');
-// Assertion console:ohos didn't work
+// Assertion failed: console didn't work
console.assert();
// Assertion failed
```
+
## console.count10+
count(label?: string): void
-Adds a counter by the specified label name to count the number of times **console.count()** is called. The default value is **default**.
+Maintains an internal counter. When this counter is invoked, its label name and the corresponding call count are printed.
**System capability**: SystemCapability.Utils.Lang
@@ -137,10 +176,11 @@ Adds a counter by the specified label name to count the number of times **consol
| Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ----------- |
-| label | string | No | Counter label name.|
+| label | string | No | Counter label name. The default value is **default**.|
+
**Example**
-```
+```js
console.count()
// default: 1
console.count('default')
@@ -150,7 +190,7 @@ console.count('abc')
console.count('xyz')
// xyz: 1
console.count('abc')
-abc: 2
+// abc: 2
console.count()
// default: 3
```
@@ -159,7 +199,7 @@ console.count()
countReset(label?: string): void
-Resets a counter by the specified label name. The default value is **default**.
+Resets a counter based on the specified label name.
**System capability**: SystemCapability.Utils.Lang
@@ -167,10 +207,10 @@ Resets a counter by the specified label name. The default value is **default**.
| Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ----------- |
-| label | string | No | Counter label name.|
+| label | string | No | Counter label name. The default value is **default**.|
**Example**
-```
+```js
console.count('abc');
// abc: 1
console.countReset('abc');
@@ -190,13 +230,24 @@ Prints content of the specified object.
| Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ----------- |
-| dir | Object | No | Object whose content needs to be printed.|
+| dir | Object | No | Object whose content needs to be printed. If this parameter is left blank, no information is printed.|
+
+
+**Example**
+```js
+let a = { foo: { bar: { baz: true } }};
+console.dir(a);
+// Object: {"foo":{"bar":{"baz":true}}}
+
+console.dir(); // No information is printed.
+```
+
## console.dirxml10+
dirxml(...arguments: Object[]): void
-Calls **console.log()** and passes the received parameters to it. This API does not produce any content of the XML format.
+Displays an interactive tree of the descendant elements of the specified XML element. This API is implemented by calling **console.log()** internally. It does not produce any XML elements. The usage method is the same as that of **console.log()**.
**System capability**: SystemCapability.Utils.Lang
@@ -204,13 +255,24 @@ Calls **console.log()** and passes the received parameters to it. This API does
| Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ----------- |
-| arguments | Object | No | Information to be printed.|
+| arguments | Object | Yes | Information to be printed.|
+
+**Example**
+```js
+const number = 5;
+console.dirxml('count: %d', number);
+// count: 5
+console.dirxml('count:', number);
+// count: 5
+console.dirxml('count:');
+// count:
+```
## console.group10+
group(...arguments: Object[]): void
-Creates an inline group so that subsequent lines are indented by the value specified by **groupIndentation**.
+Increases the indentation of subsequent lines by two spaces.
If the information to be printed is provided, the information is printed without extra indentation.
**System capability**: SystemCapability.Utils.Lang
@@ -220,11 +282,26 @@ If the information to be printed is provided, the information is printed without
| Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ----------- |
| arguments | Object | No | Information to be printed.|
+
+**Example**
+```js
+console.log("outter");
+// outter
+console.group();
+console.log("level 1");
+// level 1
+console.group("in level1");
+// in level1
+console.log("level 2");
+// level 2
+```
+
+
## console.groupCollapsed10+
groupCollapsed(...arguments: Object[]): void
-Creates a collapsed inline group.
+Creates a new inline group in collapsed mode. The usage and function of this API are the same as those of **console.group()**.
**System capability**: SystemCapability.Utils.Lang
@@ -234,14 +311,42 @@ Creates a collapsed inline group.
| ------- | ------ | ---- | ----------- |
| arguments | Object | No | Information to be printed.|
+
+**Example**
+```js
+console.groupCollapsed("outter");
+// outter
+console.groupCollapsed();
+console.log("level 1");
+// level 1
+console.groupCollapsed("in level1");
+// in level1
+console.log("level 2");
+// level 2
+```
+
## console.groupEnd10+
groupEnd(): void
-Exits an inline group so that subsequent lines are not indented by the value specified by **groupIndentation** .
+Reduces the indentation of subsequent lines by two spaces.
**System capability**: SystemCapability.Utils.Lang
+
+**Example**
+```js
+console.log("outter");
+// outter
+console.group();
+console.log("level 1");
+// level 1
+console.groupEnd();
+console.log("outter");
+// outter
+```
+
+
## console.table10+
table(tableData?: Object): void
@@ -254,10 +359,10 @@ Prints data in a table.
| Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ----------- |
-| tableData | Object | No | Data to be printed in a table.|
+| tableData | Object | No | Data to be printed in a table. If this parameter is left blank, no information is printed.|
**Example**
-```
+```js
console.table([1, 2, 3]);
// ┌─────────┬────────┐
// │ (index) │ Values │
@@ -281,7 +386,7 @@ console.table({ a: [1, 2, 3, 4, 5], b: 5, c: { e: 5 } });
time(label?: string): void
-Starts a timer to track the duration of an operation. The default value is **default**. You can use **console.timeEnd()** to disable the timer and print the result.
+Starts a timer to track the duration of an operation. You can use **console.timeEnd()** to close the timer and print the elapsed time (in ms).
**System capability**: SystemCapability.Utils.Lang
@@ -289,13 +394,18 @@ Starts a timer to track the duration of an operation. The default value is **def
| Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ----------- |
-| label | string | No | Timer label.|
+| label | string | No | Timer label. The default value is **default**.|
+
+**Example**
+```js
+console.time('abc');
+```
## console.timeEnd10+
timeEnd(label?: string): void
-Stops the timer started by **console.time()** and prints the result. The default value is **default**.
+Stops the timer started by calling **console.time()** and prints the elapsed time (in ms).
**System capability**: SystemCapability.Utils.Lang
@@ -303,10 +413,10 @@ Stops the timer started by **console.time()** and prints the result. The default
| Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ----------- |
-| label | string | No | Timer label.|
+| label | string | No | Timer label. The default value is **default**.|
**Example**
-```
+```js
console.time('abc');
console.timeEnd('abc');
// abc: 225.438ms
@@ -316,7 +426,7 @@ console.timeEnd('abc');
timeLog(label?: string, ...arguments: Object[]): void
-Prints the elapsed time and other logs for the timer started by **console.time()**.
+Prints the elapsed time and other data parameters for the timer started by **console.time()**.
**System capability**: SystemCapability.Utils.Lang
@@ -324,14 +434,13 @@ Prints the elapsed time and other logs for the timer started by **console.time()
| Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ----------- |
-| label | string | No | Timer label.|
+| label | string | No | Timer label. The default value is **default**.|
| arguments | Object | No | Logs to be printed.|
**Example**
-```
+```js
console.time('timer1');
-const value = aaa (); // Return 17.
-console.timeLog('timer1', value);
+console.timeLog('timer1', 17);
// timer1: 365.227ms 17
console.timeEnd('timer1');
// timer1: 513.22ms
@@ -349,10 +458,14 @@ Creates a stack trace.
| Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ----------- |
-| arguments | Object | No | Logs to be printed.|
+| arguments | Object | No | Logs to be printed. If this parameter is left blank, only stack information is printed.|
**Example**
-```
+```js
console.trace();
+// Trace:
+// xxxxxxxxxx (current stack information)
console.trace("Show the trace");
+// Trace: Show the trace
+// xxxxxxxxxx (current stack information)
```
diff --git a/en/application-dev/reference/apis/js-apis-net-ethernet.md b/en/application-dev/reference/apis/js-apis-net-ethernet.md
index ec15531de49c13ab4b2c85b0da9eacf37400d195..eca9a04d0e42791e19a3620f6582f3d7284dc6d4 100644
--- a/en/application-dev/reference/apis/js-apis-net-ethernet.md
+++ b/en/application-dev/reference/apis/js-apis-net-ethernet.md
@@ -55,8 +55,7 @@ ethernet.setIfaceConfig("eth0", {
route: "192.168.xx.xxx",
gateway: "192.168.xx.xxx",
netMask: "255.255.255.0",
- dnsServers: "1.1.1.1",
- domain: "2.2.2.2"
+ dnsServers: "1.1.1.1"
}, (error) => {
if (error) {
console.log("setIfaceConfig callback error = " + JSON.stringify(error));
@@ -115,8 +114,7 @@ ethernet.setIfaceConfig("eth0", {
route: "192.168.xx.xxx",
gateway: "192.168.xx.xxx",
netMask: "255.255.255.0",
- dnsServers: "1.1.1.1",
- domain: "2.2.2.2"
+ dnsServers: "1.1.1.1"
}).then(() => {
console.log("setIfaceConfig promise ok ");
}).catch(error => {
@@ -168,7 +166,6 @@ ethernet.getIfaceConfig("eth0", (error, value) => {
console.log("getIfaceConfig callback gateway = " + JSON.stringify(value.gateway));
console.log("getIfaceConfig callback netMask = " + JSON.stringify(value.netMask));
console.log("getIfaceConfig callback dnsServers = " + JSON.stringify(value.dnsServers));
- console.log("getIfaceConfig callback domain = " + JSON.stringify(value.domain));
}
});
```
@@ -219,7 +216,6 @@ ethernet.getIfaceConfig("eth0").then((data) => {
console.log("getIfaceConfig promise gateway = " + JSON.stringify(data.gateway));
console.log("getIfaceConfig promise netMask = " + JSON.stringify(data.netMask));
console.log("getIfaceConfig promise dnsServers = " + JSON.stringify(data.dnsServers));
- console.log("getIfaceConfig promise domain = " + JSON.stringify(data.domain));
}).catch(error => {
console.log("getIfaceConfig promise error = " + JSON.stringify(error));
});
diff --git a/en/application-dev/reference/apis/js-apis-net-policy.md b/en/application-dev/reference/apis/js-apis-net-policy.md
deleted file mode 100644
index cb5f1624f6a3508d25ee1019525ebac8ea9c5475..0000000000000000000000000000000000000000
--- a/en/application-dev/reference/apis/js-apis-net-policy.md
+++ /dev/null
@@ -1,1555 +0,0 @@
-# @ohos.net.policy (Network Policy Management)
-
-The **policy** module provides APIs for managing network policies, through which you can control and manage the data volume used.
-
-> **NOTE**
->
-> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
-
-## Modules to Import
-
-```js
-import policy from '@ohos.net.policy'
-```
-
-## policy.setBackgroundAllowed
-
-setBackgroundAllowed(isAllowed: boolean, callback: AsyncCallback\): void
-
-Sets a background network policy. This API uses an asynchronous callback to return the result.
-
-**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL
-
-**System capability**: SystemCapability.Communication.NetManager.Core
-
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| -------- | --------------------------------------- | ---- | ---------- |
-| isAllowed | boolean | Yes | Whether applications running in the background are allowed to use mobile data.|
-| callback | AsyncCallback\ | Yes | Callback used to return the result. If the operation is successful, the operation result is returned. If the operation fails, an error message is returned.|
-
-**Error codes**
-
-| ID| Error Message |
-| ------- | -------------------------------------------- |
-| 201 | Permission denied. |
-| 401 | Parameter error. |
-| 2100001 | Invalid parameter value. |
-| 2100002 | Operation failed. Cannot connect to service.|
-| 2100003 | System internal error. |
-
-**Example**
-
-```js
-policy.setBackgroundAllowed(Boolean(Number.parseInt(this.isBoolean)), (error) => {
- console.log(JSON.stringify(error))
-})
-;
-```
-
-## policy.setBackgroundAllowed
-
-setBackgroundAllowed(isAllowed: boolean): Promise\
-
-Sets a background network policy. This API uses a promise to return the result.
-
-**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL
-
-**System capability**: SystemCapability.Communication.NetManager.Core
-
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| -------- | --------------------------------------- | ---- | ---------- |
-| isAllowed | boolean | Yes | Whether applications running in the background are allowed to use mobile data.|
-
-**Error codes**
-
-| ID| Error Message |
-| ------- | -------------------------------------------- |
-| 201 | Permission denied. |
-| 401 | Parameter error. |
-| 2100001 | Invalid parameter value. |
-| 2100002 | Operation failed. Cannot connect to service.|
-| 2100003 | System internal error. |
-
-**Return value**
-
-| Type | Description |
-| --------------------------------- | ------------------------------------- |
-| Promise\ | Promise used to return the result. If the operation is successful, the operation result is returned. If the operation fails, an error message is returned.|
-
-**Example**
-
-```js
-policy.setBackgroundAllowed(Boolean(Number.parseInt(this.isBoolean))).then(function (error) {
- console.log(JSON.stringify(error))
-})
-```
-
-## policy.isBackgroundAllowed
-
-isBackgroundAllowed(callback: AsyncCallback\): void
-
-Obtains the background network policy. This API uses an asynchronous callback to return the result.
-
-**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL
-
-**System capability**: SystemCapability.Communication.NetManager.Core
-
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| -------- | --------------------------------------- | ---- | ---------- |
-| callback | AsyncCallback\ | Yes | Callback used to return the result. If the operation is successful, **true** is returned, which means that applications running in the background are allowed to use mobile data. If the operation fails, an error message is returned.|
-
-**Error codes**
-
-| ID| Error Message |
-| ------- | -------------------------------------------- |
-| 201 | Permission denied. |
-| 2100002 | Operation failed. Cannot connect to service.|
-| 2100003 | System internal error. |
-
-**Example**
-
-```js
-policy.isBackgroundAllowed((error, data) => {
- this.callBack(error, data);
- console.log(JSON.stringify(error))
- console.log(JSON.stringify(data))
-});
-```
-
-## policy.isBackgroundAllowed
-
-isBackgroundAllowed(): Promise\;
-
-Obtains the background network policy. This API uses a promise to return the result.
-
-**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL
-
-**System capability**: SystemCapability.Communication.NetManager.Core
-
-**Return value**
-
-| Type | Description |
-| --------------------------------- | ------------------------------------- |
-| Promise\ | Promise used to return the result. If the operation is successful, **true** is returned, which means that applications running in the background are allowed to use mobile data. If the operation fails, an error message is returned.|
-
-**Error codes**
-
-| ID| Error Message |
-| ------- | -------------------------------------------- |
-| 201 | Permission denied. |
-| 2100002 | Operation failed. Cannot connect to service.|
-| 2100003 | System internal error. |
-
-**Example**
-
-```js
-policy.isBackgroundAllowed().then(function (error, data) {
- console.log(JSON.stringify(error))
- console.log(JSON.stringify(data))
-})
-```
-
-## policy.setPolicyByUid
-
-setPolicyByUid(uid: number, policy: NetUidPolicy, callback: AsyncCallback\): void
-
-Sets an application-specific network policy. This API uses an asynchronous callback to return the result.
-
-**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL
-
-**System capability**: SystemCapability.Communication.NetManager.Core
-
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| -------- | --------------------------------------- | ---- | ---------- |
-| uid | number | Yes | Unique ID of the application.|
-| policy | [NetUidPolicy](#netuidpolicy) | Yes| Application-specific network policy to set.|
-| callback | AsyncCallback\ | Yes | Callback used to return the result. If the operation is successful, the operation result is returned. If the operation fails, an error message is returned.|
-
-**Error codes**
-
-| ID| Error Message |
-| ------- | -------------------------------------------- |
-| 201 | Permission denied. |
-| 401 | Parameter error. |
-| 2100001 | Invalid parameter value. |
-| 2100002 | Operation failed. Cannot connect to service.|
-| 2100003 | System internal error. |
-
-**Example**
-
-```js
-let param = {
- uid: Number.parseInt(this.firstParam), policy: Number.parseInt(this.currentNetUidPolicy)
-}
-policy.setPolicyByUid(Number.parseInt(this.firstParam), Number.parseInt(this.currentNetUidPolicy), (error) => {
- this.callBack(error);
-});
-```
-
-## policy.setPolicyByUid
-
-setPolicyByUid(uid: number, policy: NetUidPolicy): Promise\;
-
-Sets an application-specific network policy. This API uses a promise to return the result.
-
-**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL
-
-**System capability**: SystemCapability.Communication.NetManager.Core
-
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| -------- | --------------------------------------- | ---- | ---------- |
-| uid | number | Yes | Unique ID of the application.|
-| policy | [NetUidPolicy](#netuidpolicy) | Yes| Application-specific network policy to set.|
-
-**Return value**
-
-| Type | Description |
-| --------------------------------- | ------------------------------------- |
-| Promise\ | Promise used to return the result. If the operation is successful, the operation result is returned. If the operation fails, an error message is returned.|
-
-**Error codes**
-
-| ID| Error Message |
-| ------- | -------------------------------------------- |
-| 201 | Permission denied. |
-| 401 | Parameter error. |
-| 2100001 | Invalid parameter value. |
-| 2100002 | Operation failed. Cannot connect to service.|
-| 2100003 | System internal error. |
-
-**Example**
-
-```js
-let param = {
- uid: Number.parseInt(this.firstParam), policy: Number.parseInt(this.currentNetUidPolicy)
-}
-policy.setPolicyByUid(Number.parseInt(this.firstParam), Number.parseInt(this.currentNetUidPolicy)).then(function (error) {
- console.log(JSON.stringify(error))
-})
-```
-
-## policy.getPolicyByUid
-
-getPolicyByUid(uid: number, callback: AsyncCallback\): void
-
-Obtains an application-specific network policy by **uid**. This API uses an asynchronous callback to return the result.
-
-**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL
-
-**System capability**: SystemCapability.Communication.NetManager.Core
-
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| -------- | --------------------------------------- | ---- | ---------- |
-| uid | number | Yes| Unique ID of the application.|
-| callback | AsyncCallback\<[NetUidPolicy](#netuidpolicy)> | Yes | Callback used to return the result. If the operation is successful, the operation result is returned. If the operation fails, an error message is returned.|
-
-**Error codes**
-
-| ID| Error Message |
-| ------- | -------------------------------------------- |
-| 201 | Permission denied. |
-| 401 | Parameter error. |
-| 2100001 | Invalid parameter value. |
-| 2100002 | Operation failed. Cannot connect to service.|
-| 2100003 | System internal error. |
-
-**Example**
-
-```js
-policy.getPolicyByUid(Number.parseInt(this.firstParam), (error, data) => {
- this.callBack(error, data);
-});
-```
-
-## policy.getPolicyByUid
-
-getPolicyByUid(uid: number): Promise\;
-
-Obtains an application-specific network policy by **uid**. This API uses a promise to return the result.
-
-**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL
-
-**System capability**: SystemCapability.Communication.NetManager.Core
-
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| -------- | --------------------------------------- | ---- | ---------- |
-| uid | number | Yes| Unique ID of the application.|
-
-**Return value**
-
-| Type | Description |
-| --------------------------------- | ------------------------------------- |
-| Promise\<[NetUidPolicy](#netuidpolicy)> | Promise used to return the result. If the operation is successful, the operation result is returned. If the operation fails, an error message is returned.|
-
-**Error codes**
-
-| ID| Error Message |
-| ------- | -------------------------------------------- |
-| 201 | Permission denied. |
-| 401 | Parameter error. |
-| 2100001 | Invalid parameter value. |
-| 2100002 | Operation failed. Cannot connect to service.|
-| 2100003 | System internal error. |
-
-**Example**
-
-```js
-policy.getPolicyByUid(Number.parseInt(this.firstParam)).then(function (error, data) {
- console.log(JSON.stringify(error))
- console.log(JSON.stringify(data))
-})
-```
-
-## policy.getUidsByPolicy
-
-getUidsByPolicy(policy: NetUidPolicy, callback: AsyncCallback\>): void
-
-Obtains the UID array of applications configured with a certain application-specific network policy. This API uses an asynchronous callback to return the result.
-
-**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL
-
-**System capability**: SystemCapability.Communication.NetManager.Core
-
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| -------- | --------------------------------------- | ---- | ---------- |
-| policy | [NetUidPolicy](#netuidpolicy) | Yes| Target application-specific network policy.|
-| callback | AsyncCallback\> | Yes | Callback used to return the result. If the operation is successful, the operation result is returned. If the operation fails, an error message is returned.|
-
-**Error codes**
-
-| ID| Error Message |
-| ------- | -------------------------------------------- |
-| 201 | Permission denied. |
-| 401 | Parameter error. |
-| 2100001 | Invalid parameter value. |
-| 2100002 | Operation failed. Cannot connect to service.|
-| 2100003 | System internal error. |
-
-**Example**
-
-```js
-policy.getUidsByPolicy(Number.parseInt(this.currentNetUidPolicy), (error, data) => {
- this.callBack(error, data);
-});
-```
-
-## policy.getUidsByPolicy
-
-function getUidsByPolicy(policy: NetUidPolicy): Promise\>;
-
-Obtains the UID array of applications configured with a certain application-specific network policy. This API uses a promise to return the result.
-
-**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL
-
-**System capability**: SystemCapability.Communication.NetManager.Core
-
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| -------- | --------------------------------------- | ---- | ---------- |
-| policy | [NetUidPolicy](#netuidpolicy) | Yes| Target application-specific network policy.|
-
-**Return value**
-
-| Type | Description |
-| --------------------------------- | ------------------------------------- |
-| Promise\> | Promise used to return the result. If the operation is successful, the operation result is returned. If the operation fails, an error message is returned.|
-
-**Error codes**
-
-| ID| Error Message |
-| ------- | -------------------------------------------- |
-| 201 | Permission denied. |
-| 401 | Parameter error. |
-| 2100001 | Invalid parameter value. |
-| 2100002 | Operation failed. Cannot connect to service.|
-| 2100003 | System internal error. |
-
-**Example**
-
-```js
-policy.getUidsByPolicy(Number.parseInt(this.firstParam)).then(function (error, data) {
- console.log(JSON.stringify(error))
- console.log(JSON.stringify(data))
-})
-```
-
-## policy.getNetQuotaPolicies
-
-getNetQuotaPolicies(callback: AsyncCallback\>): void
-
-Obtains the network quota policies. This API uses an asynchronous callback to return the result.
-
-**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL
-
-**System capability**: SystemCapability.Communication.NetManager.Core
-
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| -------- | --------------------------------------- | ---- | ---------- |
-| callback | AsyncCallback\> | Yes | Callback used to return the result.|
-
-**Error codes**
-
-| ID| Error Message |
-| ------- | -------------------------------------------- |
-| 201 | Permission denied. |
-| 2100002 | Operation failed. Cannot connect to service.|
-| 2100003 | System internal error. |
-
-**Example**
-
-```js
-policy.getNetQuotaPolicies((error, data) => {
- this.callBack(error, data);
-});
-```
-
-## policy.getNetQuotaPolicies
-
-getNetQuotaPolicies(): Promise\>;
-
-Obtains the network quota policies. This API uses a promise to return the result.
-
-**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL
-
-**System capability**: SystemCapability.Communication.NetManager.Core
-
-**Return value**
-
-| Type | Description |
-| --------------------------------- | ------------------------------------- |
-| Promise\> | Promise used to return the result.|
-
-**Error codes**
-
-| ID| Error Message |
-| ------- | -------------------------------------------- |
-| 201 | Permission denied. |
-| 2100002 | Operation failed. Cannot connect to service.|
-| 2100003 | System internal error. |
-
-**Example**
-
-```js
-policy.getNetQuotaPolicies().then(function (error, data) {
- console.log(JSON.stringify(error))
- console.log(JSON.stringify(data))
-})
-
-```
-
-## policy.setNetQuotaPolicies
-
-setNetQuotaPolicies(quotaPolicies: Array\, callback: AsyncCallback\): void
-
-Sets an array of network quota policies. This API uses an asynchronous callback to return the result.
-
-**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL
-
-**System capability**: SystemCapability.Communication.NetManager.Core
-
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| -------- | --------------------------------------- | ---- | ---------- |
-| quotaPolicies | Array\<[NetQuotaPolicy](#netquotapolicy)> | Yes| An array of network quota policies to set.|
-| callback | AsyncCallback\ | Yes | Callback used to return the result.|
-
-**Error codes**
-
-| ID| Error Message |
-| ------- | -------------------------------------------- |
-| 201 | Permission denied. |
-| 401 | Parameter error. |
-| 2100001 | Invalid parameter value. |
-| 2100002 | Operation failed. Cannot connect to service.|
-| 2100003 | System internal error. |
-
-**Example**
-
-```js
-let param = {
- netType: Number.parseInt(this.netType),
- iccid: this.iccid,
- ident: this.ident,
- periodDuration: this.periodDuration,
- warningBytes: Number.parseInt(this.warningBytes),
- limitBytes: Number.parseInt(this.limitBytes),
- lastWarningRemind: this.lastWarningRemind,
- lastLimitRemind: this.lastLimitRemind,
- metered: Boolean(Number.parseInt(this.metered)),
- limitAction: this.limitAction
-};
-this.netQuotaPolicyList.push(param);
-
-policy.setNetQuotaPolicies(this.netQuotaPolicyList, (error) => {
- console.log(JSON.stringify(error))
-});
-```
-
-## policy.setNetQuotaPolicies
-
-setNetQuotaPolicies(quotaPolicies: Array\): Promise\;
-
-Sets an array of network quota policies. This API uses a promise to return the result.
-
-**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL
-
-**System capability**: SystemCapability.Communication.NetManager.Core
-
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| -------- | --------------------------------------- | ---- | ---------- |
-| quotaPolicies | Array\<[NetQuotaPolicy](#netquotapolicy)> | Yes| An array of network quota policies to set.|
-
-**Error codes**
-
-| ID| Error Message |
-| ------- | -------------------------------------------- |
-| 201 | Permission denied. |
-| 401 | Parameter error. |
-| 2100001 | Invalid parameter value. |
-| 2100002 | Operation failed. Cannot connect to service.|
-| 2100003 | System internal error. |
-
-**Return value**
-
-| Type | Description |
-| --------------------------------- | ------------------------------------- |
-| Promise\ | Promise used to return the result.|
-
-**Example**
-
-```js
-let param = {
- netType: Number.parseInt(this.netType),
- iccid: this.iccid,
- ident: this.ident,
- periodDuration: this.periodDuration,
- warningBytes: Number.parseInt(this.warningBytes),
- limitBytes: Number.parseInt(this.limitBytes),
- lastWarningRemind: this.lastWarningRemind,
- lastLimitRemind: this.lastLimitRemind,
- metered: Boolean(Number.parseInt(this.metered)),
- limitAction: this.limitAction
-};
-this.netQuotaPolicyList.push(param);
-
-policy.setNetQuotaPolicies(this.netQuotaPolicyList).then(function (error) {
- console.log(JSON.stringify(error))
-})
-```
-
-## policy.restoreAllPolicies
-
-restoreAllPolicies(iccid: string, callback: AsyncCallback\): void
-
-Restores all the policies (cellular network, background network, firewall, and application-specific network policies) for the given SIM card. This API uses an asynchronous callback to return the result.
-
-**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL
-
-**System capability**: SystemCapability.Communication.NetManager.Core
-
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| -------- | --------------------------------------- | ---- | ---------- |
-| iccid | string | Yes| SIM card ID.|
-| callback | AsyncCallback\ | Yes | Callback used to return the result.|
-
-**Error codes**
-
-| ID| Error Message |
-| ------- | -------------------------------------------- |
-| 201 | Permission denied. |
-| 401 | Parameter error. |
-| 2100001 | Invalid parameter value. |
-| 2100002 | Operation failed. Cannot connect to service.|
-| 2100003 | System internal error. |
-
-**Example**
-
-```js
-this.firstParam = iccid;
-policy.restoreAllPolicies(this.firstParam, (error) => {
- console.log(JSON.stringify(error))
-});
-```
-
-## policy.restoreAllPolicies
-
-restoreAllPolicies(iccid: string): Promise\;
-
-Restores all the policies (cellular network, background network, firewall, and application-specific network policies) for the given SIM card. This API uses a promise to return the result.
-
-**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL
-
-**System capability**: SystemCapability.Communication.NetManager.Core
-
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| -------- | --------------------------------------- | ---- | ---------- |
-| iccid | string | Yes| SIM card ID.|
-
-**Return value**
-
-| Type | Description |
-| --------------------------------- | ------------------------------------- |
-| Promise\ | Promise used to return the result.|
-
-**Error codes**
-
-| ID| Error Message |
-| ------- | -------------------------------------------- |
-| 201 | Permission denied. |
-| 401 | Parameter error. |
-| 2100001 | Invalid parameter value. |
-| 2100002 | Operation failed. Cannot connect to service.|
-| 2100003 | System internal error. |
-
-**Example**
-
-```js
-this.firstParam = iccid;
-policy.restoreAllPolicies(this.firstParam).then(function (error) {
- console.log(JSON.stringify(error))
-})
-```
-
-## policy.isUidNetAllowed
-
-isUidNetAllowed(uid: number, isMetered: boolean, callback: AsyncCallback\): void
-
-Checks whether an application is allowed to access metered networks. This API uses an asynchronous callback to return the result.
-
-**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL
-
-**System capability**: SystemCapability.Communication.NetManager.Core
-
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| -------- | --------------------------------------- | ---- | ---------- |
-| uid | number | Yes| Unique ID of the application.|
-| isMetered | boolean | Yes| Whether the network is a metered network.|
-| callback | AsyncCallback\ | Yes | Callback used to return the result. The value **true** means that the application is allowed to access metered networks, and **false** means the opposite.|
-
-**Error codes**
-
-| ID| Error Message |
-| ------- | -------------------------------------------- |
-| 201 | Permission denied. |
-| 401 | Parameter error. |
-| 2100001 | Invalid parameter value. |
-| 2100002 | Operation failed. Cannot connect to service.|
-| 2100003 | System internal error. |
-
-**Example**
-
-```js
-let param = {
- uid: Number.parseInt(this.firstParam), isMetered: Boolean(Number.parseInt(this.isBoolean))
-}
-policy.isUidNetAllowed(Number.parseInt(this.firstParam), Boolean(Number.parseInt(this.isBoolean)), (error, data) => {
- this.callBack(error, data);
-});
-```
-
-## policy.isUidNetAllowed
-
-isUidNetAllowed(uid: number, isMetered: boolean): Promise\;
-
-Checks whether an application is allowed to access metered networks. This API uses a promise to return the result.
-
-**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL
-
-**System capability**: SystemCapability.Communication.NetManager.Core
-
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| -------- | --------------------------------------- | ---- | ---------- |
-| uid | number | Yes| Unique ID of the application.|
-| isMetered | boolean | Yes| Whether the network is a metered network.|
-
-**Return value**
-
-| Type | Description |
-| --------------------------------- | ------------------------------------- |
-| Promise\ | Promise used to return the result.|
-
-**Error codes**
-
-| ID| Error Message |
-| ------- | -------------------------------------------- |
-| 201 | Permission denied. |
-| 401 | Parameter error. |
-| 2100001 | Invalid parameter value. |
-| 2100002 | Operation failed. Cannot connect to service.|
-| 2100003 | System internal error. |
-
-**Example**
-
-```js
-let param = {
- uid: Number.parseInt(this.firstParam), isMetered: Boolean(Number.parseInt(this.isBoolean))
-}
-policy.isUidNetAllowed(Number.parseInt(this.firstParam), Boolean(Number.parseInt(this.isBoolean))).then(function (error, data) {
- console.log(JSON.stringify(error))
- console.log(JSON.stringify(data))
-})
-```
-
-## policy.isUidNetAllowed
-
-isUidNetAllowed(uid: number, iface: string, callback: AsyncCallback\): void
-
-Checks whether an application is allowed to access the given network. This API uses an asynchronous callback to return the result.
-
-**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL
-
-**System capability**: SystemCapability.Communication.NetManager.Core
-
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| -------- | --------------------------------------- | ---- | ---------- |
-| uid | number | Yes| Unique ID of the application.|
-| iface | string | Yes| Name of the target network.|
-| callback | AsyncCallback\ | Yes | Callback used to return the result. The value **true** means that the application is allowed to access the given network, and **false** means the opposite.|
-
-**Error codes**
-
-| ID| Error Message |
-| ------- | -------------------------------------------- |
-| 201 | Permission denied. |
-| 401 | Parameter error. |
-| 2100001 | Invalid parameter value. |
-| 2100002 | Operation failed. Cannot connect to service.|
-| 2100003 | System internal error. |
-
-**Example**
-
-```js
-let param = {
- uid: Number.parseInt(this.firstParam), iface: this.secondParam
-}
-policy.isUidNetAllowed(Number.parseInt(this.firstParam), this.secondParam, (error, data) => {
- this.callBack(error, data);
-});
-```
-
-## policy.isUidNetAllowed
-
-isUidNetAllowed(uid: number, iface: string): Promise\;
-
-Checks whether an application is allowed to access the given network. This API uses a promise to return the result.
-
-**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL
-
-**System capability**: SystemCapability.Communication.NetManager.Core
-
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| -------- | --------------------------------------- | ---- | ---------- |
-| uid | number | Yes| Unique ID of the application.|
-| iface | string | Yes| Name of the target network.|
-
-**Return value**
-
-| Type | Description |
-| --------------------------------- | ------------------------------------- |
-| Promise\ | Promise used to return the result.|
-
-**Error codes**
-
-| ID| Error Message |
-| ------- | -------------------------------------------- |
-| 201 | Permission denied. |
-| 401 | Parameter error. |
-| 2100001 | Invalid parameter value. |
-| 2100002 | Operation failed. Cannot connect to service.|
-| 2100003 | System internal error. |
-
-**Example**
-
-```js
-let param = {
- uid: Number.parseInt(this.firstParam), iface: this.secondParam
-}
-policy.isUidNetAllowed(Number.parseInt(this.firstParam), this.secondParam).then(function (error, data) {
- console.log(JSON.stringify(error))
- console.log(JSON.stringify(data))
-})
-```
-
-## policy.setDeviceIdleAllowList
-
-setDeviceIdleAllowList(uid: number, isAllowed: boolean, callback: AsyncCallback\): void
-
-Sets whether to add an application to the device idle allowlist. This API uses an asynchronous callback to return the result.
-
-**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL
-
-**System capability**: SystemCapability.Communication.NetManager.Core
-
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| -------- | --------------------------------------- | ---- | ---------- |
-| uid | number | Yes| Unique ID of the application.|
-| isAllowed | boolean | Yes| Whether to add the application to the allowlist.|
-| callback | callback: AsyncCallback\ | Yes | Callback used to return the result.|
-
-**Error codes**
-
-| ID| Error Message |
-| ------- | -------------------------------------------- |
-| 201 | Permission denied. |
-| 401 | Parameter error. |
-| 2100001 | Invalid parameter value. |
-| 2100002 | Operation failed. Cannot connect to service.|
-| 2100003 | System internal error. |
-
-**Example**
-
-```js
-let param = {
- uid: Number.parseInt(this.firstParam), isAllowed: Boolean(Number.parseInt(this.isBoolean))
-}
-policy.setDeviceIdleAllowList(Number.parseInt(this.firstParam), Boolean(Number.parseInt(this.isBoolean)), (error) => {
- console.log(JSON.stringify(error))
-});
-```
-
-## policy.setDeviceIdleAllowList
-
-setDeviceIdleAllowList(uid: number, isAllowed: boolean): Promise\;
-
-Sets whether to add an application to the device idle allowlist. This API uses a promise to return the result.
-
-**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL
-
-**System capability**: SystemCapability.Communication.NetManager.Core
-
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| -------- | --------------------------------------- | ---- | ---------- |
-| uid | number | Yes| Unique ID of the application.|
-| isAllowed | boolean | Yes| Whether to add the application to the allowlist.|
-
-**Return value**
-
-| Type | Description |
-| --------------------------------- | ------------------------------------- |
-| Promise\ | Promise used to return the result.|
-
-**Error codes**
-
-| ID| Error Message |
-| ------- | -------------------------------------------- |
-| 201 | Permission denied. |
-| 401 | Parameter error. |
-| 2100001 | Invalid parameter value. |
-| 2100002 | Operation failed. Cannot connect to service.|
-| 2100003 | System internal error. |
-
-**Example**
-
-```js
-let param = {
- uid: Number.parseInt(this.firstParam), isAllowed: Boolean(Number.parseInt(this.isBoolean))
-}
-policy.setDeviceIdleAllowList(Number.parseInt(this.firstParam), Boolean(Number.parseInt(this.isBoolean))).then(function (error) {
- console.log(JSON.stringify(error))
-})
-```
-
-## policy.getDeviceIdleAllowList
-
-getDeviceIdleAllowList(callback: AsyncCallback\>): void
-
-Obtains the UID array of applications that are on the device idle allowlist. This API uses an asynchronous callback to return the result.
-
-**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL
-
-**System capability**: SystemCapability.Communication.NetManager.Core
-
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| -------- | --------------------------------------- | ---- | ---------- |
-| callback | AsyncCallback\> | Yes | Callback used to return the result.|
-
-**Error codes**
-
-| ID| Error Message |
-| ------- | -------------------------------------------- |
-| 201 | Permission denied. |
-| 2100002 | Operation failed. Cannot connect to service.|
-| 2100003 | System internal error. |
-
-**Example**
-
-```js
-policy.getDeviceIdleAllowList((error, data) => {
- this.callBack(error, data);
-});
-```
-
-## policy.getDeviceIdleAllowList
-
-getDeviceIdleAllowList(): Promise\>;
-
-Obtains the UID array of applications that are on the device idle allowlist. This API uses a promise to return the result.
-
-**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL
-
-**System capability**: SystemCapability.Communication.NetManager.Core
-
-**Return value**
-
-| Type | Description |
-| --------------------------------- | ------------------------------------- |
-| Promise\> | Promise used to return the result.|
-
-**Error codes**
-
-| ID| Error Message |
-| ------- | -------------------------------------------- |
-| 201 | Permission denied. |
-| 2100002 | Operation failed. Cannot connect to service.|
-| 2100003 | System internal error. |
-
-**Example**
-
-```js
-policy.getDeviceIdleAllowList().then(function (error, data) {
- console.log(JSON.stringify(error))
- console.log(JSON.stringify(data))
-})
-```
-
-## policy.getBackgroundPolicyByUid
-
-getBackgroundPolicyByUid(uid: number, callback: AsyncCallback\): void
-
-Obtains the background network policies configured for the given application. This API uses an asynchronous callback to return the result.
-
-**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL
-
-**System capability**: SystemCapability.Communication.NetManager.Core
-
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| -------- | --------------------------------------- | ---- | ---------- |
-| uid | number | Yes| Unique ID of the application.|
-| callback | AsyncCallback\<[NetBackgroundPolicy](#netbackgroundpolicy)> | Yes | Callback used to return the result.|
-
-**Error codes**
-
-| ID| Error Message |
-| ------- | -------------------------------------------- |
-| 201 | Permission denied. |
-| 401 | Parameter error. |
-| 2100001 | Invalid parameter value. |
-| 2100002 | Operation failed. Cannot connect to service.|
-| 2100003 | System internal error. |
-
-**Example**
-
-```js
-this.firstParam = uid
-policy.getBackgroundPolicyByUid(Number.parseInt(this.firstParam), (error, data) => {
- this.callBack(error, data);
-});
-```
-
-## policy.getBackgroundPolicyByUid
-
-getBackgroundPolicyByUid(uid: number): Promise\;
-
-Obtains the background network policies configured for the given application. This API uses a promise to return the result.
-
-**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL
-
-**System capability**: SystemCapability.Communication.NetManager.Core
-
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| -------- | --------------------------------------- | ---- | ---------- |
-| uid | number | Yes| Unique ID of the application.|
-
-**Return value**
-
-| Type | Description |
-| --------------------------------- | ------------------------------------- |
-| Promise\<[NetBackgroundPolicy](#netbackgroundpolicy)> | Promise used to return the result.|
-
-**Error codes**
-
-| ID| Error Message |
-| ------- | -------------------------------------------- |
-| 201 | Permission denied. |
-| 401 | Parameter error. |
-| 2100001 | Invalid parameter value. |
-| 2100002 | Operation failed. Cannot connect to service.|
-| 2100003 | System internal error. |
-
-**Example**
-
-```js
-this.firstParam = uid
-policy.getBackgroundPolicyByUid(Number.parseInt(this.firstParam)).then(function (error, data) {
- console.log(JSON.stringify(error))
- console.log(JSON.stringify(data))
-})
-```
-
-## policy.resetPolicies
-
-resetPolicies(iccid: string, callback: AsyncCallback\): void
-
-Restores all the policies (cellular network, background network, firewall, and application-specific network policies) for the given SIM card. This API uses an asynchronous callback to return the result.
-
-**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL
-
-**System capability**: SystemCapability.Communication.NetManager.Core
-
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| -------- | --------------------------------------- | ---- | ---------- |
-| iccid | string | Yes| SIM card ID.|
-| callback | AsyncCallback\ | Yes | Callback used to return the result.|
-
-**Error codes**
-
-| ID| Error Message |
-| ------- | -------------------------------------------- |
-| 201 | Permission denied. |
-| 401 | Parameter error. |
-| 2100001 | Invalid parameter value. |
-| 2100002 | Operation failed. Cannot connect to service.|
-| 2100003 | System internal error. |
-
-**Example**
-
-```js
-this.firstParam = iccid
-policy.resetPolicies(this.firstParam, (error) => {
- console.log(JSON.stringify(error))
-});
-```
-
-## policy.resetPolicies
-
-resetPolicies(iccid: string): Promise\;
-
-Restores all the policies (cellular network, background network, firewall, and application-specific network policies) for the given SIM card. This API uses a promise to return the result.
-
-**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL
-
-**System capability**: SystemCapability.Communication.NetManager.Core
-
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| -------- | --------------------------------------- | ---- | ---------- |
-| iccid | string | Yes| SIM card ID.|
-
-**Return value**
-
-| Type | Description |
-| --------------------------------- | ------------------------------------- |
-| Promise\ | Promise used to return the result.|
-
-**Error codes**
-
-| ID| Error Message |
-| ------- | -------------------------------------------- |
-| 201 | Permission denied. |
-| 401 | Parameter error. |
-| 2100001 | Invalid parameter value. |
-| 2100002 | Operation failed. Cannot connect to service.|
-| 2100003 | System internal error. |
-
-**Example**
-
-```js
-policy.getUidsByPolicy(Number.parseInt(this.firstParam)).then(function (error, data) {
-
-})
-this.firstParam = iccid
-policy.resetPolicies(this.firstParam).then(function (error) {
- console.log(JSON.stringify(error))
-})
-```
-
-## policy.updateRemindPolicy
-
-updateRemindPolicy(netType: NetBearType, iccid: string, remindType: RemindType, callback: AsyncCallback\): void
-
-Updates a reminder policy. This API uses an asynchronous callback to return the result.
-
-**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL
-
-**System capability**: SystemCapability.Communication.NetManager.Core
-
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| -------- | --------------------------------------- | ---- | ---------- |
-| netType | [NetBearType](js-apis-net-connection.md#netbeartype) | Yes| Network type.|
-| iccid | string | Yes| SIM card ID.|
-| remindType | [RemindType](#remindtype) | Yes| Reminder type.|
-| callback | AsyncCallback\ | Yes | Callback used to return the result.|
-
-**Error codes**
-
-| ID| Error Message |
-| ------- | -------------------------------------------- |
-| 201 | Permission denied. |
-| 401 | Parameter error. |
-| 2100001 | Invalid parameter value. |
-| 2100002 | Operation failed. Cannot connect to service.|
-| 2100003 | System internal error. |
-
-**Example**
-
-```js
-let param = {
- netType: Number.parseInt(this.netType), iccid: this.firstParam, remindType: this.currentRemindType
-}
-policy.updateRemindPolicy(Number.parseInt(this.netType), this.firstParam, Number.parseInt(this.currentRemindType), (error) => {
- console.log(JSON.stringify(error))
-});
-```
-
-## policy.updateRemindPolicy
-
-updateRemindPolicy(netType: NetBearType, iccid: string, remindType: RemindType): Promise\;
-
-Updates a reminder policy. This API uses a promise to return the result.
-
-**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL
-
-**System capability**: SystemCapability.Communication.NetManager.Core
-
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| -------- | --------------------------------------- | ---- | ---------- |
-| netType | [NetBearType](js-apis-net-connection.md#netbeartype) | Yes| Network type.|
-| iccid | string | Yes| SIM card ID.|
-| remindType | [RemindType](#remindtype) | Yes| Reminder type.|
-
-**Return value**
-
-| Type | Description |
-| --------------------------------- | ------------------------------------- |
-| Promise\ | Promise used to return the result.|
-
-**Error codes**
-
-| ID| Error Message |
-| ------- | -------------------------------------------- |
-| 201 | Permission denied. |
-| 401 | Parameter error. |
-| 2100001 | Invalid parameter value. |
-| 2100002 | Operation failed. Cannot connect to service.|
-| 2100003 | System internal error. |
-
-**Example**
-
-```js
-let param = {
- netType: Number.parseInt(this.netType), iccid: this.firstParam, remindType: this.currentRemindType
-}
-policy.updateRemindPolicy(Number.parseInt(this.netType), this.firstParam, Number.parseInt(this.currentRemindType)).then(function (error) {
- console.log(JSON.stringify(error))
-})
-```
-
-## policy.setPowerSaveAllowList
-
-setPowerSaveAllowList(uid: number, isAllowed: boolean, callback: AsyncCallback\): void
-
-Sets whether to add an application to the power-saving allowlist. This API uses an asynchronous callback to return the result.
-
-**Required permissions**: ohos.permission.CONNECTIVITY_INTERNAL
-
-**System capability**: SystemCapability.Communication.NetManager.Core
-
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| -------- | --------------------------------------- | ---- | ---------- |
-| uid | number | Yes| Unique ID of the application.|
-| isAllowed | boolean | Yes| Whether to add the application to the allowlist.|
-| callback | callback: AsyncCallback\ | Yes | Callback used to return the result.|
-
-**Error codes**
-
-| ID| Error Message |
-| ------- | -------------------------------------------- |
-| 201 | Permission denied. |
-| 401 | Parameter error. |
-| 2100001 | Invalid parameter value. |
-| 2100002 | Operation failed. Cannot connect to service.|
-| 2100003 | System internal error. |
-
-**Example**
-
-```js
-let param = {
- uid: Number.parseInt(this.firstParam), isAllowed: Boolean(Number.parseInt(this.isBoolean))
-}
-policy.setPowerSaveAllowList(Number.parseInt(this.firstParam), Boolean(Number.parseInt(this.isBoolean)), (error) => {
- console.log(JSON.stringify(error))
-});
-```
-
-## policy.setPowerSaveAllowList
-
-setPowerSaveAllowList(uid: number, isAllowed: boolean): Promise\