diff --git a/.idea/.gitignore b/.idea/.gitignore
deleted file mode 100644
index 26d33521af10bcc7fd8cea344038eaaeb78d0ef5..0000000000000000000000000000000000000000
--- a/.idea/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-# Default ignored files
-/shelf/
-/workspace.xml
diff --git a/.idea/docs.iml b/.idea/docs.iml
deleted file mode 100644
index d6ebd4805981b8400db3e3291c74a743fef9a824..0000000000000000000000000000000000000000
--- a/.idea/docs.iml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
deleted file mode 100644
index 87ea532768b38bd5204c0ec5698088effb68bc8a..0000000000000000000000000000000000000000
--- a/.idea/gradle.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
deleted file mode 100644
index 6049cfe013e0d2ef3f5f29c1b34b880e9d498ef0..0000000000000000000000000000000000000000
--- a/.idea/modules.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
deleted file mode 100644
index 35eb1ddfbbc029bcab630581847471d7f238ec53..0000000000000000000000000000000000000000
--- a/.idea/vcs.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/CODEOWNERS b/CODEOWNERS
index 0505a2b82d072e49f5bd1fb94a19fc2287c09f61..9d7e915103f7fa3ba7dc3d9cc9845fec3fe6761c 100644
--- a/CODEOWNERS
+++ b/CODEOWNERS
@@ -218,6 +218,11 @@ zh-cn/application-dev/reference/apis/js-apis-huks.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-useriam-userauth.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-system-cipher.md @zengyawen
zh-cn/application-dev/reference/apis/js-apis-data-ability.md @ge-yafang
+zh-cn/application-dev/reference/apis/js-apis-data-DataShareResultSet.md @ge-yafang
+zh-cn/application-dev/reference/apis/js-apis-data-ValuesBucket.md @ge-yafang
+zh-cn/application-dev/reference/apis/js-apis-data-dataSharePredicates.md @ge-yafang
+zh-cn/application-dev/reference/apis/js-apis-data-dataShare.md @ge-yafang
+zh-cn/application-dev/reference/apis/js-apis-application-DataShareExtensionAbility.md @ge-yafang
zh-cn/application-dev/reference/apis/js-apis-distributed-data.md @ge-yafang
zh-cn/application-dev/reference/apis/js-apis-data-distributedobject.md @ge-yafang
zh-cn/application-dev/reference/apis/js-apis-data-preferences.md @ge-yafang
diff --git a/OAT.xml b/OAT.xml
index 414d2024d4d92853fb4a174aea6f19d54c3c770d..59b222c66c936f6d1284c6d1cded6f8cc95f1e25 100644
--- a/OAT.xml
+++ b/OAT.xml
@@ -38,12 +38,13 @@
-
+
+
@@ -65,7 +66,7 @@
-
+
diff --git a/README.md b/README.md
index e5ec091688e68b4d3632dac4d6cd079ed8f0f279..7e19add93fd8c1818e41387bfd4c8ad34efa2b71 100644
--- a/README.md
+++ b/README.md
@@ -6,6 +6,8 @@ This repository stores device and application development documents provided by
## Contents
+[OpenAtom OpenHarmony](https://www.openharmony.cn/docs?navId=3&navName=OpenHarmony%20Documentation%20Overview)
+
[Chinese Documentation](zh-cn/readme.md)
[English Documentation](en/readme.md)
@@ -15,7 +17,7 @@ This repository stores device and application development documents provided by
### Latest Versions
- master: the latest version.
-
+
- OpenHarmony 3.2 Beta1. [Learn more](en/release-notes/OpenHarmony-v3.2-beta1.md)
- OpenHarmony 3.1 Release. [Learn more](en/release-notes/OpenHarmony-v3.1-release.md)
diff --git a/docker/README_en.md b/docker/README_en.md
index 9853079a565ee82d2a752ec134b6c29acc7ab43b..d73216868ef9aebfcc3ebefdc60e9ee38f802071 100755
--- a/docker/README_en.md
+++ b/docker/README_en.md
@@ -4,7 +4,7 @@
This document provides guidance on building the Docker image for mini- and small-system devices.
-The Docker image of OpenHarmony is hosted on [HUAWEI Cloud SWR](https://auth.huaweicloud.com/authui/login.html?service=https%3A%2F%2Fconsole.huaweicloud.com%2Fswr%2F%3Fregion%3Dcn-south-1%26cloud_route_state%3D%2Fapp%2Fwarehouse%2FwarehouseMangeDetail%2Fgoldensir%2Fopenharmony-docker%2Fopenharmony-docker%3Ftype%3DownImage&locale=en-us#/login). Using the Docker image will help simplify environment configurations needed for the building. The following table lists container-based options needed for building in the standalone Docker environment.
+The Docker image of OpenHarmony is hosted on [HUAWEI Cloud SWR](https://auth.huaweicloud.com/authui/login.html?service=https%3A%2F%2Fconsole.huaweicloud.com%2Fswr%2F%3Fregion%3Dcn-south-1%26cloud_route_state%3D%2Fapp%2Fwarehouse%2FwarehouseMangeDetail%2Fgoldensir%2Fopenharmony-docker%2Fopenharmony-docker%3Ftype%3DownImage&locale=en-us#/login). Using the Docker image will help simplify environment configurations needed for the building. The following table lists container-based options needed for building in the standalone [Docker environment](https://gitee.com/openharmony/docs/blob/master/en/device-dev/get-code/gettools-acquire.md).
| Docker Image Repository | Tag | Description |
| :----------------------------------------------------------- | :------ | :-------------------------------------------------------- |
diff --git a/en/application-dev/IDL/idl-guidelines.md b/en/application-dev/IDL/idl-guidelines.md
index 66b45bd4c04860e882c9104aaf3c58164f5ec29b..cb075f42cf7ef08d02f78ec1d0377c84d5a0bbf6 100644
--- a/en/application-dev/IDL/idl-guidelines.md
+++ b/en/application-dev/IDL/idl-guidelines.md
@@ -3,7 +3,7 @@
## IDL Overview
To ensure successful communications between the client and server, interfaces recognized by both parties must be defined. The OpenHarmony Interface Definition Language (IDL) is a tool for defining such interfaces. OpenHarmony IDL decomposes objects to be transferred into primitives that can be understood by the operating system and encapsulates cross-boundary objects based on developers' requirements.
-**Figure 1** IDL interface description
+ **Figure 1** IDL interface description

@@ -29,16 +29,16 @@ IDL has the following advantages:
#### Primitive Type
| IDL Primitive Type| C++ Primitive Type| TS Primitive Type|
-| -------- | -------- | -------- |
-|void | void | void |
-|boolean | bool | boolean |
-|byte | int8_t | number |
-|short | int16_t | number |
-|int | int32_t | number |
-|long | int64_t | number |
-|float | float | number |
-|double | double | number |
-|String | std::string | string |
+| -------- | -------- | -------- |
+|void | void | void |
+|boolean | bool | boolean |
+|byte | int8_t | number |
+|short | int16_t | number |
+|int | int32_t | number |
+|long | int64_t | number |
+|float | float | number |
+|double | double | number |
+|String | std::string | string |
The preceding table lists the primitive types supported by IDL and the mappings to the C++ and TS primitive types.
@@ -47,29 +47,34 @@ The sequenceable type is declared using the keyword **sequenceable**. This type
In C++, the declaration is placed in the file header in the format of **sequenceable includedir..namespace.typename**. It can be in any of the following forms:
-```
+```cpp
sequenceable includedir..namespace.typename
sequenceable includedir...typename
sequenceable namespace.typename
```
+
In the preceding information, **includedir** indicates the directory where the header file of the type is located, and the dot (.) is used as the separator. **namespace** indicates the namespace where the type is located, and the dot (.) is used as the separator. **typename** indicates the data type, which can contain only English characters. **includedir** and **namespace** are separated by two dots (..). If the declaration statement does not contain two dots, all characters except the last typename will be parsed as a namespace. Example:
-```
+
+```cpp
sequenceable a.b..C.D
```
+
The preceding statement is parsed into the following code in the C++ header file:
-```
+
+```cpp
#include "a/b/d.h"
using C::D;
```
+
In TS, the declaration is placed in the file header in the format of **sequenceable namespace.typename;**. It can be in the following form:
-```
+```ts
sequenceable idl.MySequenceable
```
In the preceding information, **namespace** indicates the namespace to which the data type belongs, **typename** indicates the data type name, and **MySequenceable** indicates that data can be passed during IPC using **Parcel** objects. The sequenceable type is not defined in the IDL file, but in the .ts file. Therefore, IDL adds the following statement to the generated .ts file based on the declaration:
-```
+```ts
import MySequenceable from "./my_sequenceable"
```
@@ -80,19 +85,19 @@ The interface type refers to interfaces defined in IDL files. The interfaces def
The declaration form in C++ is similar to that of the sequenceable type. The declaration form is as follows:
-```
+```cpp
interface includedir..namespace.typename
```
In TS, the declaration form is as follows:
-```
+```ts
interface namespace.interfacename
```
In the preceding information, **namespace** indicates the namespace to which the interface belongs, and **interfacename** indicates the name of the interface. For example, **interface OHOS.IIdlTestObserver;** declares the **IIdlTestObserver** interface defined in another IDL file. This interface can be used as the parameter type or return value type of a method in the current file. IDL adds the following statement to the generated .ts file based on the statement:
-```
+```ts
import IIdlTestObserver from "./i_idl_test_observer"
```
@@ -100,9 +105,9 @@ import IIdlTestObserver from "./i_idl_test_observer"
The array type is represented by T[], where **T** can be the primitive, sequenceable, interface, or array type. In C++, this type is generated as **std::vector<T>**.
The table below lists the mappings between the IDL array type and TS and C++ data types.
-|IDL Data Type | C++ Data Type | TS Data Type |
-| -------- | -------- | -------- |
-|T[] | std::vector<T> | T[] |
+|IDL Data Type | C++ Data Type | TS Data Type |
+| ------- | -------- | -------- |
+|T[] | std::vector<T> | T[] |
#### Container Type
IDL supports two container types: List and Map. The List container is represented in the format of **List<T>**. The Map container is represented in the format of **Map**, where **T**, **KT**, and **VT** can be of the primitive, sequenceable, interface, array, or container type.
@@ -114,26 +119,32 @@ In TS, the List container type is not supported, and the Map container type is g
The table below lists the mappings between the IDL container type and TS and C++ data types.
|IDL Data Type | C++ Data Type | TS Data Type |
-| -------- | -------- | -------- |
-|List<T> | std::list | Not supported|
-|Map | std::map | Map |
+| -------- | -------- | ------- |
+|List<T> | std::list | Not supported |
+|Map | std::map | Map |
### Specifications for Compiling IDL Files
Only one interface type can be defined in an IDL file, and the interface name must be the same as the file name. The interface definition of the IDL file is described in Backus-Naur form (BNF). The basic definition format is as follows:
+
```
[<*interface_attr_declaration*>]interface<*interface_name_with_namespace*>{<*method_declaration*>}
```
+
In the preceding information, <*interface_attr_declaration*> declares interface attributes. Currently, only the **oneway** attribute is supported, indicating that all methods in the interface are unidirectional. Such a method returns value without waiting for the execution to complete. This attribute is optional. If this attribute is not set, synchronous call is used. The interface name must contain the complete interface header file directory, namespace, and method declaration. Empty interfaces are not allowed.
The method declaration format in the interface is as follows:
+
```
[<*method_attr_declaration*>]<*result_type*><*method_declaration*>
```
+
In the preceding information, <*method_attr_declaration*> describes the interface attributes. Currently, only the **oneway** attribute is supported, indicating that the method is unidirectional. Such a method returns value without waiting for the execution to complete. This attribute is optional. If this attribute is not set, synchronous call is used. <*result_type*> indicates the type of the return value, and <*method_declaration*> indicates the method name and parameter declaration.
The parameter declaration format is as follows:
+
```
[<*formal_param_attr*>]<*type*><*identifier*>
```
+
The value of <*formal_param_attr*> can be **in**, **out**, or **inout**, indicating that the parameter is an input parameter, an output parameter, or both an input and an output parameter, respectively. A **oneway** method does not allow **output** or **inout** parameters or return values.
## How to Develop
@@ -144,20 +155,20 @@ The value of <*formal_param_attr*> can be **in**, **out**, or **inout**, indicat
You can use C++ to create IDL files. An example IDL file is as follows:
-```
+```cpp
interface OHOS.IIdlTestService {
int TestIntTransaction([in] int data);
void TestStringTransaction([in] String data);
}
```
-You can run the **./idl -gen-cpp -d dir -c dir/iTest.idl** command (**-d** indicates the output directory) to generate the interface file, stub file, and proxy file in the **dir** directory in the execution environment. The names of the generated interface class files are the same as that of the IDL file, except that the file name extensions are **.h** and **.cpp**. For example, for **IIdlTestService.idl**, the generated files are **i_idl_test_service.h**, **idl_test_service_proxy.h**, **idl_test_service_stub.h**, **idl_test_service_proxy.cpp**, and **idl_test_service_stub.cpp**.
+You can run the **./idl -gen-cpp -d dir -c dir/iTest.idl** command (**-d** indicates the output directory) to generate the interface file, stub file, and proxy file in the **dir** directory in the execution environment. The names of the generated interface class files are the same as that of the IDL file, except that the file name extensions are **.h** and **.cpp**. For example, the files generated for **IIdlTestService.idl** are **i_idl_test_service.h**, **idl_test_service_proxy.h**, **idl_test_service_stub.h**, **idl_test_service_proxy.cpp**, and **idl_test_service_stub.cpp**.
#### Exposing Interfaces on the Server
The stub class generated by IDL is an abstract implementation of the interface class and declares all methods in the IDL file.
-```
+```cpp
#ifndef OHOS_IDLTESTSERVICESTUB_H
#define OHOS_IDLTESTSERVICESTUB_H
#include
@@ -182,7 +193,7 @@ private:
You need to inherit the interface class defined in the IDL file and implement the methods in the class. In addition, you need to register the defined services with SAMGR during service initialization. In the following code snippet, **TestService** inherits the **IdlTestServiceStub** interface class and implements the **TestIntTransaction** and **TestStringTransaction** methods.
-```
+```cpp
#ifndef OHOS_IPC_TEST_SERVICE_H
#define OHOS_IPC_TEST_SERVICE_H
@@ -207,7 +218,7 @@ private:
The sample code for registering a service is as follows:
-```
+```cpp
#include "test_service.h"
#include
@@ -259,12 +270,11 @@ ErrCode TestService::TestStringTransaction(const std::string &data)
} // namespace OHOS
```
-
#### Calling Methods from the Client for IPC
The C++ client obtains the service proxy defined in the system through SAMGR and then invokes the interface provided by the proxy. The sample code is as follows:
-```
+```cpp
#include "test_client.h"
#include "if_system_ability_manager.h"
@@ -316,16 +326,13 @@ void TestClient::StartStringTransaction()
} // namespace OHOS
```
-
-
-
### Development Using TS
#### Creating an IDL File
You can use TS to create IDL files. An example IDL file is as follows:
-```
+```ts
interface OHOS.IIdlTestService {
int TestIntTransaction([in] int data);
void TestStringTransaction([in] String data);
@@ -338,7 +345,7 @@ Run the **./idl -c IIdlTestService.idl -gen-ts -d /data/ts/** command (**-d** in
The stub class generated by IDL is an abstract implementation of the interface class and declares all methods in the IDL file.
-```
+```ts
import {testIntTransactionCallback} from "./i_idl_test_service";
import {testStringTransactionCallback} from "./i_idl_test_service";
import IIdlTestService from "./i_idl_test_service";
@@ -387,7 +394,7 @@ export default class IdlTestServiceStub extends rpc.RemoteObject implements IIdl
You need to inherit the interface class defined in the IDL file and implement the methods in the class. The following code snippet shows how to inherit the **IdlTestServiceStub** interface class and implement the **testIntTransaction** and **testStringTransaction** methods.
-```
+```ts
import {testIntTransactionCallback} from "./i_idl_test_service"
import {testStringTransactionCallback} from "./i_idl_test_service"
import IdlTestServiceStub from "./idl_test_service_stub"
@@ -408,7 +415,7 @@ class IdlTestImp extends IdlTestServiceStub {
After the service implements the interface, the interface needs to be exposed to the client for connection. If your service needs to expose this interface, extend **Ability** and implement **onConnect()** to return **IRemoteObject** so that the client can interact with the service process. The following code snippet shows how to expose the **IRemoteAbility** interface to the client:
-```
+```ts
export default {
onStart() {
console.info('ServiceAbility onStart');
@@ -442,7 +449,7 @@ export default {
When the client calls **connectAbility()** to connect to a Service ability, the **onConnect** callback in **onAbilityConnectDone** of the client receives the **IRemoteObject** instance returned by the **onConnect()** method of the Service ability. The client and Service ability are in different applications. Therefore, the directory of the client application must contain a copy of the .idl file (the SDK automatically generates the proxy class). The **onConnect** callback then uses the **IRemoteObject** instance to create the **testProxy** instance of the **IdlTestServiceProxy** class and calls the related IPC method. The sample code is as follows:
-```
+```ts
import IdlTestServiceProxy from './idl_test_service_proxy'
import featureAbility from '@ohos.ability.featureAbility';
@@ -495,7 +502,7 @@ To create a class that supports the sequenceable type, perform the following ope
The following is an example of the **MySequenceable** class code:
-```
+```ts
import rpc from '@ohos.rpc';
export default class MySequenceable {
constructor(num: number, str: string) {
@@ -523,8 +530,6 @@ export default class MySequenceable {
}
```
-
-
## How to Develop for Interworking Between C++ and TS
### TS Proxy and C++ Stub Development
@@ -535,7 +540,7 @@ export default class MySequenceable {
2. Create a service object, inherit the interface class defined in the C++ stub file, and implement the methods in the class. An example is as follows:
- ```
+ ```cpp
class IdlTestServiceImpl : public IdlTestServiceStub {
public:
IdlTestServiceImpl() = default;
@@ -558,7 +563,7 @@ export default class MySequenceable {
C++ provides C++ service objects to TS in the format of native APIs. For example, C++ provides a **GetNativeObject** method, which is used to create an **IdlTestServiceImpl** instance. Using the **NAPI_ohos_rpc_CreateJsRemoteObject** method, you can create a JS remote object for the TS application.
-```
+```cpp
NativeValue* GetNativeObject(NativeEngine& engine, NativeCallbackInfo& info)
{
sptr impl = new IdlTestServiceImpl();
@@ -572,8 +577,7 @@ NativeValue* GetNativeObject(NativeEngine& engine, NativeCallbackInfo& info)
Use TS to construct an IDL file and run commands to generate interfaces, stub files, and proxy files. An example proxy file is as follows:
-```
-
+```ts
import {testIntTransactionCallback} from "./i_idl_test_service";
import {testStringTransactionCallback} from "./i_idl_test_service";
import IIdlTestService from "./i_idl_test_service";
@@ -634,7 +638,7 @@ export default class IdlTestServiceProxy implements IIdlTestService {
2. Construct a TS proxy and transfers the remote C++ service object to it.
3. Use the TS proxy to call the method declared in the IDL file to implement the interworking between the TS proxy and C++ stub. The following is an example:
-```
+```ts
import IdlTestServiceProxy from './idl_test_service_proxy'
import nativeMgr from 'nativeManager';
diff --git a/en/application-dev/Readme-EN.md b/en/application-dev/Readme-EN.md
index a4d1f95a92f50783825b392d55aa089d121c84c4..fdc79edbcb58a00729b62b5e9f7d239b52cdbf59 100644
--- a/en/application-dev/Readme-EN.md
+++ b/en/application-dev/Readme-EN.md
@@ -20,24 +20,21 @@
- Development
- [Ability Development](ability/Readme-EN.md)
- [UI Development](ui/Readme-EN.md)
- - Basic Feature Development
- - [Common Event and Notification](notification/Readme-EN.md)
- - [Window Manager](windowmanager/Readme-EN.md)
- - [WebGL](webgl/Readme-EN.md)
- - [Media](media/Readme-EN.md)
- - [Security](security/Readme-EN.md)
- - [Connectivity](connectivity/Readme-EN.md)
- - [Data Management](database/Readme-EN.md)
- - [Telephony](telephony/Readme-EN.md)
- - [Agent-Powered Scheduled Reminders](background-agent-scheduled-reminder/Readme-EN.md)
- - [Background Task Management](background-task-management/Readme-EN.md)
- - [Work Scheduler](work-scheduler/Readme-EN.md)
- - [Device Management](device/Readme-EN.md)
- - [Device Usage Statistics](device-usage-statistics/Readme-EN.md)
- - [DFX](dfx/Readme-EN.md)
- - [Internationalization](internationalization/Readme-EN.md)
- - [OpenHarmony IDL Specifications and User Guide](IDL/idl-guidelines.md)
- - [Using Native APIs in Application Projects](napi/Readme-EN.md)
+ - [Common Event and Notification](notification/Readme-EN.md)
+ - [Window Manager](windowmanager/Readme-EN.md)
+ - [WebGL](webgl/Readme-EN.md)
+ - [Media](media/Readme-EN.md)
+ - [Security](security/Readme-EN.md)
+ - [Connectivity](connectivity/Readme-EN.md)
+ - [Data Management](database/Readme-EN.md)
+ - [Telephony](telephony/Readme-EN.md)
+ - [Task Management](task-management/Readme-EN.md)
+ - [Device Management](device/Readme-EN.md)
+ - [Device Usage Statistics](device-usage-statistics/Readme-EN.md)
+ - [DFX](dfx/Readme-EN.md)
+ - [Internationalization](internationalization/Readme-EN.md)
+ - [OpenHarmony IDL Specifications and User Guide](IDL/idl-guidelines.md)
+ - [Using Native APIs in Application Projects](napi/Readme-EN.md)
- Tools
- [DevEco Studio (OpenHarmony) User Guide](quick-start/deveco-studio-user-guide-for-openharmony.md)
- Hands-On Tutorials
diff --git a/en/application-dev/ability/ability-assistant-guidelines.md b/en/application-dev/ability/ability-assistant-guidelines.md
index 7af76245661a90090b4ba2533b5f24ea5e9a6b09..4d7b0edb2b91ca07123ad7495f4d64fc2f525e1d 100644
--- a/en/application-dev/ability/ability-assistant-guidelines.md
+++ b/en/application-dev/ability/ability-assistant-guidelines.md
@@ -2,11 +2,7 @@
The ability assistant enables you to start applications, atomic services, and test cases and debug applications. By using this tool, you can send commands in the hdc shell to perform various system operations, such as starting abilities, forcibly stopping processes, and printing ability information.
-## Development Guidelines
-
-The ability assistant is pre-installed in the device environment. You can directly invoke the tool using commands.
-
-### Query-related Commands
+## Query-related Commands
- **help**
@@ -22,7 +18,7 @@ The ability assistant is pre-installed in the device environment. You can direct
aa help
```
-### Ability-related Commands
+## Ability-related Commands
- **start**
@@ -77,10 +73,10 @@ The ability assistant is pre-installed in the device environment. You can direct
| -a/--all | - | Prints ability information in all missions. |
| -l/--mission-list | type (All logs are printed if this parameter is left unspecified.)| Prints mission stack information. The following values are available for **type**: - NORMAL - DEFAULT_STANDARD - DEFAULT_SINGLE - LAUNCHER |
| -e/--extension | elementName | Prints extended component information. |
- | -u/--userId | UserId | Prints stack information of a specified user ID. This parameter must be used together with other parameters. Example commands: aa **dump -a -u 100** and **aa dump -d -u 100**|
- | -d/--data | | Prints Data ability information. |
+ | -u/--userId | UserId | Prints stack information of a specified user ID. This parameter must be used together with other parameters. Example commands: aa **dump -a -u 100** and **aa dump -d -u 100**. |
+ | -d/--data | - | Prints Data ability information. |
| -i/--ability | AbilityRecord ID | Prints detailed information about a specified ability. |
- | -c/--client | | Prints detailed ability information. This parameter must be used together with other parameters. Example commands: **aa dump -a -c** and **aa dump -i 21 -c**|
+ | -c/--client | - | Prints detailed ability information. This parameter must be used together with other parameters. Example commands: **aa dump -a -c** and **aa dump -i 21 -c**. |
**Method**
diff --git a/en/application-dev/ability/ability-brief.md b/en/application-dev/ability/ability-brief.md
index be6473c975266e41fee1e850fe5206eb7a624f85..283037aedc8c219bee48511898dd300a0c05dc3b 100644
--- a/en/application-dev/ability/ability-brief.md
+++ b/en/application-dev/ability/ability-brief.md
@@ -1,20 +1,20 @@
# Ability Framework Overview
-An ability is the abstraction of a functionality that an application can provide. It is the minimum unit for the system to schedule applications. An application can contain one or more **Ability** instances.
+An ability is the abstraction of a functionality that an application can provide. It is the minimum unit for the system to schedule applications. An application can contain one or more `Ability` instances.
The ability framework model has two forms.
-- FA model, which applies to application development using API 8 and earlier versions. In the FA model, there are Feature Ability (FA) and Particle Ability (PA). The FA supports Page abilities, and the PA supports Service, Data, and Form abilities.
-- Stage model, which is introduced since API 9. In the stage model, there are Ability and ExtensionAbility. The ExtensionAbility is further extended to ServiceExtensionAbility, FormExtensionAbility, DataShareExtensionAbility, and more.
+- FA model, which applies to application development using API version 8 and earlier versions. In the FA model, there are Feature Ability (FA) and Particle Ability (PA). The FA supports Page abilities, and the PA supports Service, Data, and Form abilities.
+- Stage model, which is introduced since API version 9. In the stage model, there are Ability and ExtensionAbility. The ExtensionAbility is further extended to ServiceExtensionAbility, FormExtensionAbility, DataShareExtensionAbility, and more.
The stage model is designed to make it easier to develop complex applications in the distributed environment. The table below lists the design differences between the two models.
| Item | FA Model | Stage Model |
| -------------- | ------------------------------------------------------------ | -------------------------------------------------------- |
-| Development mode | Web-like APIs are provided. The UI development is the same as that of the stage model. | Object-oriented development mode is provided. The UI development is the same as that of the FA model. |
+| Development mode | Web-like APIs are provided. The UI development is the same as that of the stage model. | Object-oriented development mode is provided. The UI development is the same as that of the FA model. |
| Engine instance | Each ability in a process exclusively uses a JS VM engine instance. | Multiple abilities in a process share one JS VM engine instance. |
-| Intra-process object sharing| Not supported. | Supported. |
-| Bundle description file | The **config.json** file is used to describe the HAP and component information. The component must use a fixed file name.| The **module.json** file is used to describe the HAP and component information. The entry file name can be specified.|
+| Intra-process object sharing| Not supported. | Supported. |
+| Bundle description file | The `config.json` file is used to describe the HAP and component information. Each component must use a fixed file name.| The `module.json` file is used to describe the HAP and component information. The entry file name can be specified.|
| Component | Four types of components are provided: Page ability (used for UI page display), Service ability (used to provide services), Data ability (used for data sharing), and Form ability (used to provide widgets).| Two types of components are provided: Ability (used for UI page display) and Extension (scenario-based service extension). |
In addition, the following differences exist in the development process:
@@ -28,4 +28,7 @@ In addition, the following differences exist in the development process:

-For details about the two models, see [FA Model Overview](fa-brief.md) and [Stage Model Overview](stage-brief.md).
\ No newline at end of file
+For details about the two models, see [FA Model Overview](fa-brief.md) and [Stage Model Overview](stage-brief.md).
+## Samples
+The following sample is provided to help you better understand how to develop abilities:
+- [Intra- and Inter-page Navigation](https://gitee.com/openharmony/codelabs/tree/master/Ability/PageAbility)
diff --git a/en/application-dev/ability/ability-delegator.md b/en/application-dev/ability/ability-delegator.md
index 4e27041093bc2b9d1e3a2966f7a5f20b0f51b94c..5fd0293efde6d6d264be28b6c30123e7697bee6b 100644
--- a/en/application-dev/ability/ability-delegator.md
+++ b/en/application-dev/ability/ability-delegator.md
@@ -12,8 +12,8 @@ The APIs provided by the test framework can be used only in the test HAP. They t
The test framework can be started in either of the following ways:
-- Method 1: Run the aa test command.
-- Method 2: Use the IDE.
+- Method 1: Run the `aa test` command.
+- Method 2: Use DevEco Studio.
### Running aa test
@@ -37,16 +37,16 @@ aa test -b BundleName -m com.example.myapplicationfaets -s unittest OpenHarmonyT
| -s unittest | Yes | Name of the **TestRunner** to be used. The TestRunner name must be the same as the file name. |
| -w | No | Timeout interval of a test case, in seconds. If this parameter is not specified or is set to a value less than or equal to **0**, the test framework exits only after **finishTest** is invoked.|
| -s \\ | No | **-s** can be followed by any key-value pair obtained through **AbilityDelegatorArgs.parameters**. For example, in **-s classname myTest**, **-s classname** is the key and **myTest** is the value.|
-| -D | No | Debug mode for starting the tested application. |
-| -h | No | Help information. |
+| -D | No | Debug mode for starting the tested application.|
+| -h | No | Help information.|
-### Using the IDE
+### Using DevEco Studio
-For details about how to use the IDE to start the test framework, see [IDE Guide](https://developer.harmonyos.com/en/docs/documentation/doc-guides/ohos-openharmony-test-framework-0000001263160453#section1034420367508).
+For details about how to use DevEco Studio to start the test framework, see [OpenHarmony Test Framework](https://developer.harmonyos.com/en/docs/documentation/doc-guides/ohos-openharmony-test-framework-0000001263160453#section1034420367508).
## Introduction to TestRunner
-**TestRunner** is the entry class of the test framework test process. When the test process is started, the system calls related APIs in **TestRunner**. You need to inherit this class and override the **onPrepare** and **onRun** APIs. When creating an application template, the IDE initializes the default **TestRunner** and starts the default **TestAbility** in the **onRun** API. You can modify the test code of **TestAbility** or override **onPrepare** and **onRun** in **TestRunner** to implement your own test code. For details, see [TestRunner](../reference/apis/js-apis-testRunner.md).
+**TestRunner** is the entry class of the test framework test process. When the test process is started, the system calls related APIs in **TestRunner**. You need to inherit this class and override the **onPrepare** and **onRun** APIs. When creating an application template, DevEco Studio initializes the default **TestRunner** and starts the default **TestAbility** in the **onRun** API. You can modify the test code of **TestAbility** or override **onPrepare** and **onRun** in **TestRunner** to implement your own test code. For details, see [TestRunner](../reference/apis/js-apis-testRunner.md).
## Introduction to AbilityDelegatorRegistry
@@ -136,6 +136,7 @@ abilityDelegator.startAbility(want, (err, data) => {
### Running a Shell Command
**AbilityDelegator** provides APIs to run shell commands in the test environment.
+
**Example**
```javascript
@@ -150,6 +151,7 @@ abilityDelegator.executeShellCommand(cmd, (err, data) => {
### Printing Log Information
**AbilityDelegator** provides APIs for printing log information. You can call any API in the test code to print process logs to the unit test console.
+
**Example**
```javascript
@@ -165,6 +167,7 @@ abilityDelegator.print(msg, (err) => {
### Finishing the Test and Printing Log Information
**AbilityDelegator** provides the APIs for actively finishing the test. You can call any API in test code to finish the test and print logs to the unit test console.
+
**Example**
```javascript
diff --git a/en/application-dev/ability/context-userguide.md b/en/application-dev/ability/context-userguide.md
index b058e9942bc7126c0a4b04a91acbd8806e9afdc4..16a4a8c54b0798b0ba52a0328d40e47ec3283603 100644
--- a/en/application-dev/ability/context-userguide.md
+++ b/en/application-dev/ability/context-userguide.md
@@ -6,12 +6,13 @@
The OpenHarmony application framework has two models: Feature Ability (FA) model and stage model. Correspondingly, there are two sets of context mechanisms. **application/BaseContext** is a common context base class. It uses the **stageMode** attribute to specify whether the context is used for the stage model.
-- FA Model
-
- Only the methods in **app/Context** can be used for the context in the FA model. Both the application-level context and ability-level context are instances of this type. If an ability-level method is invoked in the application-level context, an error occurs. Therefore, you must pay attention to the actual meaning of the **Context** instance.
-
-- Stage Model
+- FA model
+
+ Only the methods in **app/Context** can be used for the context in the FA model. Both the application-level context and ability-level context are instances of this type. If an ability-level method is invoked in the application-level context, an error occurs. Therefore, you must pay attention to the actual meaning of the **Context** instance.
+
+- Stage model
+
The stage model has the following types of contexts: **application/Context**, **application/ApplicationContext**, **application/AbilityStageContext**, **application/ExtensionContext**, **application/AbilityContext**, and **application/FormExtensionContext**. For details about these contexts and how to use them, see [Context in the Stage Model](#context-in-the-stage-model).

@@ -45,6 +46,34 @@ export default {
}
```
+### Common Context-related Methods in the FA Model
+The following context-related methods are available in the FA model:
+```javascript
+setDisplayOrientation(orientation: bundle.DisplayOrientation, callback: AsyncCallback): void
+setDisplayOrientation(orientation: bundle.DisplayOrientation): Promise;
+```
+The methods are used to set the display orientation of the current ability.
+
+**Example**
+```javascript
+import featureAbility from '@ohos.ability.featureAbility'
+import bundle from '../@ohos.bundle';
+
+export default {
+ onCreate() {
+ // Obtain the context and call related APIs.
+ let context = featureAbility.getContext();
+ context.setDisplayOrientation(bundle.DisplayOrientation.LANDSCAPE).then(() => {
+ console.log("Set display orientation.")
+ })
+ console.info('Application onCreate')
+ },
+ onDestroy() {
+ console.info('Application onDestroy')
+ },
+}
+```
+
## Context in the Stage Model
The following describes the contexts provided by the stage model in detail.
diff --git a/en/application-dev/ability/fa-brief.md b/en/application-dev/ability/fa-brief.md
index 670c741d84218a261df7fa09d88e42c9b69a693f..e3374b85a5e16e76a4b13dc58b1950e442a1313b 100644
--- a/en/application-dev/ability/fa-brief.md
+++ b/en/application-dev/ability/fa-brief.md
@@ -3,22 +3,15 @@
## Overall Architecture
The development of an OpenHarmony application is essentially the development of one or more abilities. By scheduling abilities and managing their lifecycle, OpenHarmony implements application scheduling.
-The Feature Ability (FA) model applies to application development using API 8 and earlier versions. In this model, there are Page, Service, Data, and Form abilities.
+The Feature Ability (FA) model applies to application development using API version 8 and earlier versions. In this model, there are Page, Service, Data, and Form abilities.
- The Page ability implements the ArkUI and provides the capability of interacting with users.
- The Service ability does not have a UI. It runs in the background and provides custom services for other abilities to invoke.
-- The Data ability does not have a UI. It also runs in the background and enables other abilities to insert, delete, and query data.
+- The Data ability does not have a UI. It runs in the background and enables other abilities to insert, delete, and query data.
- The Form ability provides a widget, which is a UI display mode.
-## Application Package Structure
-**The following figure shows the application package structure.**
-
-
-
-For details about the application package structure, see [Description of the Application Package Structure Configuration File](../quick-start/package-structure.md).
-
## Lifecycle
-Among all abilities, the Page ability has the most complex lifecycle, because it has a UI and is the interaction entry of applications.
+Among all abilities, the Page ability has the most complex lifecycle, because it has a UI and acts as a touchpoint for interacting with users.
**The following figure shows the lifecycle of the Page ability.**

@@ -30,6 +23,20 @@ Currently, the **app.js** file provides only the **onCreate** and **onDestroy**
## Process and Thread Model
-An application exclusively uses an independent process, and an ability exclusively uses an independent thread. An application process is created when an ability is started for the first time, and a thread is created for this ability too. After the application is started, other abilities in the application are started, and a thread is created for every of these started abilities. Each ability is bound to an independent JSRuntime instance. Therefore, abilities are isolated from each other.
+An application exclusively uses an independent process, and an ability exclusively uses an independent thread. When an ability is started for the first time, an application process as well as a thread for this ability is created. After the application is started, other abilities in the application are started, and a thread is created for every of these started abilities. Each ability is bound to an independent JSRuntime instance. In this way, abilities are isolated from each other.

+## Samples
+The following sample is provided to help you better understand how to develop abilities:
+
+- [`DistributeCalc`: Distributed Calculator (eTS, API version 8)](https://gitee.com/openharmony/app_samples/tree/master/Preset/DistributeCalc)
+- [`DistributeGraffiti`: Distributed Graffiti (eTS, API version 8)](https://gitee.com/openharmony/app_samples/tree/master/ability/DistributedGraffiti)
+
+- [Remote FA Startup](https://gitee.com/openharmony/codelabs/tree/master/Distributed/RemoteStartFA)
+- [Distributed News App](https://gitee.com/openharmony/codelabs/tree/master/Distributed/NewsDemo)
+- [Synced Sketchpad (eTS)](https://gitee.com/openharmony/codelabs/tree/master/Distributed/DistributeDatabaseDrawEts)
+- [Distributed Authentication (JS)](https://gitee.com/openharmony/codelabs/tree/master/Distributed/GameAuthOpenH)
+- [Distributed Game Controller (eTS)](https://gitee.com/openharmony/codelabs/tree/master/Distributed/HandleGameApplication)
+- [Distributed Mail System (eTS)](https://gitee.com/openharmony/codelabs/tree/master/Distributed/OHMailETS)
+- [Distributed Jigsaw Puzzle (eTS)](https://gitee.com/openharmony/codelabs/tree/master/Distributed/OpenHarmonyPictureGame)
+- [Distributed Control (eTS)](https://gitee.com/openharmony/codelabs/tree/master/Distributed/RemoteControllerETS)
diff --git a/en/application-dev/ability/fa-dataability.md b/en/application-dev/ability/fa-dataability.md
index 4b098d095df7ca0bec73c485f1a83d70ae43fb3d..f7bcf858e15b2f7f16b0327b1b91097e2f28facd 100644
--- a/en/application-dev/ability/fa-dataability.md
+++ b/en/application-dev/ability/fa-dataability.md
@@ -6,32 +6,40 @@ Data ability providers can customize data access-related APIs such as data inser
## Available APIs
-**Table 1** Data ability lifecycle callbacks
+**Table 1** Data ability lifecycle APIs
|API|Description|
|:------|:------|
-|onInitialized|Called during ability initialization to initialize the relational database (RDB).|
-|update|Updates data in the database.|
-|query|Queries data in the database.|
-|delete|Deletes one or multiple data records from the database.|
-|normalizeUri|Normalizes the URI. A normalized URI applies to cross-device use, persistence, backup, and restore. When the context changes, it ensures that the same data item can be referenced.|
-|batchInsert|Inserts multiple data records into the database.|
-|denormalizeUri|Converts a normalized URI generated by **normalizeUri** into a denormalized URI.|
-|insert|Inserts a data record into the database.|
-|openFile|Opens a file.|
-|getFileTypes|Obtains the MIME type of a file.|
-|getType|Obtains the MIME type matching the data specified by the URI.|
-|executeBatch|Operates data in the database in batches.|
-|call|A customized API.|
+|onInitialized?(info: AbilityInfo): void|Called during ability initialization to initialize the relational database (RDB).|
+|update?(uri: string, valueBucket: rdb.ValuesBucket, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback\): void|Updates data in the database.|
+|query?(uri: string, columns: Array\, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback\): void|Queries data in the database.|
+|delete?(uri: string, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback\): void|Deletes one or more data records from the database.|
+|normalizeUri?(uri: string, callback: AsyncCallback\): void|Normalizes the URI. A normalized URI applies to cross-device use, persistence, backup, and restore. When the context changes, it ensures that the same data item can be referenced.|
+|batchInsert?(uri: string, valueBuckets: Array\, callback: AsyncCallback\): void|Inserts multiple data records into the database.|
+|denormalizeUri?(uri: string, callback: AsyncCallback\): void|Converts a normalized URI generated by **normalizeUri** into a denormalized URI.|
+|insert?(uri: string, valueBucket: rdb.ValuesBucket, callback: AsyncCallback\): void|Inserts a data record into the database.|
+|openFile?(uri: string, mode: string, callback: AsyncCallback\): void|Opens a file.|
+|getFileTypes?(uri: string, mimeTypeFilter: string, callback: AsyncCallback\>): void|Obtains the MIME type of a file.|
+|getType?(uri: string, callback: AsyncCallback\): void|Obtains the MIME type matching the data specified by the URI.|
+|executeBatch?(ops: Array\, callback: AsyncCallback\>): void|Operates data in the database in batches.|
+|call?(method: string, arg: string, extras: PacMap, callback: AsyncCallback\): void|Calls a custom API.|
## How to Develop
### Creating a Data Ability
-1. To meet the basic requirements of the database storage service, implement the **Insert**, **Query**, **Update**, and **Delete** APIs in the **Data** class to provide batch data processing. The traversal logic has been implemented by the **BatchInsert** and **ExecuteBatch** APIs.
+1. To meet the basic requirements of the database storage service, implement the **Insert**, **Query**, **Update**, and **Delete** APIs in the **Data** class. The **BatchInsert** and **ExecuteBatch** APIs have already implemented the traversal logic, but not batch data processing.
The following code snippet shows how to create a Data ability:
```javascript
+ import dataAbility from '@ohos.data.dataAbility'
+ import dataRdb from '@ohos.data.rdb'
+
+ const TABLE_NAME = 'book'
+ const STORE_CONFIG = { name: 'book.db' }
+ const SQL_CREATE_TABLE = 'CREATE TABLE IF NOT EXISTS book(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, introduction TEXT NOT NULL)'
+ let rdbStore: dataRdb.RdbStore = undefined
+
export default {
onInitialized(abilityInfo) {
console.info('DataAbility onInitialized, abilityInfo:' + abilityInfo.bundleName)
@@ -50,7 +58,7 @@ Data ability providers can customize data access-related APIs such as data inser
for (let i = 0;i < valueBuckets.length; i++) {
console.info('DataAbility batch insert i=' + i)
if (i < valueBuckets.length - 1) {
- rdbStore.insert(TABLE_NAME, valueBuckets[i], (num: number) => {
+ rdbStore.insert(TABLE_NAME, valueBuckets[i], (err: any, num: number) => {
console.info('DataAbility batch insert ret=' + num)
})
} else {
@@ -76,7 +84,7 @@ Data ability providers can customize data access-related APIs such as data inser
};
```
-2. Submodule Configuration
+2. Configure the submodule.
| JSON Field| Description |
| ------------ | ------------------------------------------------------------ |
@@ -89,15 +97,15 @@ Data ability providers can customize data access-related APIs such as data inser
```json
"abilities":[{
- "srcPath": "DataAbility",
- "name": ".DataAbility",
- "icon": "$media:icon",
- "srcLanguage": "ets",
- "description": "$string:description_dataability",
- "type": "data",
- "visible": true,
- "uri": "dataability://ohos.samples.etsdataability.DataAbility"
- }]
+ "srcPath": "DataAbility",
+ "name": ".DataAbility",
+ "icon": "$media:icon",
+ "srcLanguage": "ets",
+ "description": "$string:description_dataability",
+ "type": "data",
+ "visible": true,
+ "uri": "dataability://ohos.samples.etsdataability.DataAbility"
+ }]
```
### Accessing a Data ability
@@ -118,6 +126,10 @@ The basic dependency packages include:
For details about the APIs provided by **DataAbilityHelper**, see [DataAbilityHelper Module](../reference/apis/js-apis-dataAbilityHelper.md).
```js
// Different from the URI defined in the config.json file, the URI passed in the parameter has an extra slash (/), because there is a DeviceID parameter between the second and the third slash (/).
+ import featureAbility from '@ohos.ability.featureAbility'
+ import ohos_data_ability from '@ohos.data.dataAbility'
+ import ohos_data_rdb from '@ohos.data.rdb'
+
var urivar = "dataability:///com.ix.DataAbility"
var DAHelper = featureAbility.acquireDataAbilityHelper(
urivar
@@ -137,7 +149,7 @@ The basic dependency packages include:
urivar,
valuesBucket,
(error, data) => {
- expect(typeof(data)).assertEqual("number")
+ console.log("DAHelper insert result: " + data)
}
);
```
@@ -156,7 +168,7 @@ The basic dependency packages include:
urivar,
da,
(error, data) => {
- expect(typeof(data)).assertEqual("number")
+ console.log("DAHelper delete result: " + data)
}
);
```
@@ -176,7 +188,7 @@ The basic dependency packages include:
valuesBucket,
da,
(error, data) => {
- expect(typeof(data)).assertEqual("number")
+ console.log("DAHelper update result: " + data)
}
);
```
@@ -197,7 +209,7 @@ The basic dependency packages include:
valArray,
da,
(error, data) => {
- expect(typeof(data)).assertEqual("object")
+ console.log("DAHelper query result: " + data)
}
);
```
@@ -217,7 +229,7 @@ The basic dependency packages include:
urivar,
cars,
(error, data) => {
- expect(typeof(data)).assertEqual("number")
+ console.log("DAHelper batchInsert result: " + data)
}
);
```
@@ -241,12 +253,12 @@ The basic dependency packages include:
valuesBucket: {"executeBatch" : "value1",},
predicates: da,
expectedCount:0,
- PredicatesBackReferences: {},
+ predicatesBackReferences: null,
interrupted:true,
}
],
(error, data) => {
- expect(typeof(data)).assertEqual("object")
+ console.log("DAHelper executeBatch result: " + data)
}
);
```
@@ -265,21 +277,15 @@ The basic dependency packages include:
},
predicates: da,
expectedCount:0,
- PredicatesBackReferences: {},
+ predicatesBackReferences: null,
interrupted:true,
}
]
);
```
-## Development Example
-
-The following sample is provided to help you better understand how to develop a Data ability:
-
-- [DataAbility](https://gitee.com/openharmony/app_samples/tree/master/ability/DataAbility)
-
-This sample shows how to:
+## Samples
-Create a Data ability in the **data.ts** file in the **DataAbility** directory.
+The following sample is provided to help you better understand how to develop Data abilities:
-Encapsulate the process of accessing the Data ability in the **MainAbility** directory.
+- [`DataAbility`: Creation and Access of Data Abilities (eTS, API version 8)](https://gitee.com/openharmony/app_samples/tree/master/ability/DataAbility)
diff --git a/en/application-dev/ability/fa-formability.md b/en/application-dev/ability/fa-formability.md
index 8b447ba835d915e3d6ff1b7ed491342932048673..2cbf353e910af8ebb8dff02218331ae97f568e2c 100644
--- a/en/application-dev/ability/fa-formability.md
+++ b/en/application-dev/ability/fa-formability.md
@@ -3,40 +3,33 @@
## Widget Overview
A widget is a set of UI components used to display important information or operations for an application. It provides users with direct access to a desired application service, without requiring them to open the application.
-A widget displays brief information about an application on the UI of another application (host application, currently system applications only) and provides basic interactive features such as opening a UI page or sending a message. The widget host is responsible for displaying the widget.
+A widget displays brief information about an application on the UI of another application (host application, currently system applications only) and provides basic interactive functions such as opening a UI page or sending a message.
Basic concepts:
-- Widget provider
-
- The widget provider is an atomic service that provides the content to be displayed. It controls the display content, component layout, and component click events of a widget.
-
-- Widget host
-
- The widget host is an application that displays the widget content and controls the position where the widget is displayed in the host application.
-
-- Widget Manager
-
- The Widget Manager is a resident agent that manages widgets added to the system and provides functions such as periodic widget update.
+- Widget provider: an atomic service that controls what and how content is displayed in a widget and interacts with users.
+- Widget host: an application that displays the widget content and controls the position where the widget is displayed in the host application.
+- Widget Manager: a resident agent that manages widgets added to the system and provides functions such as periodic widget update.
->  **NOTE**
+> **NOTE**
+>
> The widget host and provider do not keep running all the time. The Widget Manager starts the widget provider to obtain widget information when a widget is added, deleted, or updated.
You only need to develop widget content as the widget provider. The system automatically handles the work done by the widget host and Widget Manager.
The widget provider controls the widget content to display, component layout, and click events bound to components.
-## Scenario
+## Development Overview
-Form ability development refers to the development conducted by the widget provider based on the [Feature Ability (FA) model](fa-brief.md). As a widget provider, you need to carry out the following operations:
+In FA widget development, you need to carry out the following operations as a widget provider based on the [Feature Ability (FA) model](fa-brief.md).
- Develop the lifecycle callbacks in **LifecycleForm**.
-- Create a **FormBindingData** object.
+- Create a **FormBindingData** instance.
- Update a widget through **FormProvider**.
-- Develop the widget UI page.
+- Develop the widget UI pages.
## Available APIs
-The table below describes the lifecycle callbacks provided **LifecycleForm**.
+The table below describes the lifecycle callbacks provided in **LifecycleForm**.
**Table 1** LifecycleForm APIs
@@ -45,10 +38,10 @@ The table below describes the lifecycle callbacks provided **LifecycleForm**.
| onCreate(want: Want): formBindingData.FormBindingData | Called to notify the widget provider that a **Form** instance (widget) has been created. |
| onCastToNormal(formId: string): void | Called to notify the widget provider that a temporary widget has been converted to a normal one.|
| onUpdate(formId: string): void | Called to notify the widget provider that a widget has been updated. |
-| onVisibilityChange(newStatus: { [key: string]: number }): void | Called to notify the widget provider of the change of widget visibility. |
-| onEvent(formId: string, message: string): void | Called to instruct the widget provider to receive and process the widget event. |
+| onVisibilityChange(newStatus: { [key: string]: number }): void | Called to notify the widget provider of the change in widget visibility. |
+| onEvent(formId: string, message: string): void | Called to instruct the widget provider to receive and process a widget event. |
| onDestroy(formId: string): void | Called to notify the widget provider that a **Form** instance (widget) has been destroyed. |
-| onAcquireFormState?(want: Want): formInfo.FormState | Called when the widget provider receives the status query result of a specified widget. |
+| onAcquireFormState?(want: Want): formInfo.FormState | Called when the widget provider receives the status query result of a widget. |
For details about the **FormProvider** APIs, see [FormProvider](../reference/apis/js-apis-formprovider.md).
@@ -81,7 +74,7 @@ To create a widget in the FA model, you need to implement the lifecycles of **Li
export default {
onCreate(want) {
console.log('FormAbility onCreate');
- // Persistently store widget information for subsequent use, such as widget instance retrieval and update.
+ // Persistently store widget information for subsequent use, such as widget instance retrieval or update.
let obj = {
"title": "titleOnCreate",
"detail": "detailOnCreate"
@@ -94,7 +87,7 @@ To create a widget in the FA model, you need to implement the lifecycles of **Li
console.log('FormAbility onCastToNormal');
},
onUpdate(formId) {
- // To support scheduled update, periodic update, or update requested by the widget host for a widget, override this method for data update.
+ // To support scheduled update, periodic update, or update requested by the widget host, override this method for widget data update.
console.log('FormAbility onUpdate');
let obj = {
"title": "titleOnUpdate",
@@ -124,11 +117,11 @@ To create a widget in the FA model, you need to implement the lifecycles of **Li
}
```
-### Configuring config.json for the Form Ability
+### Configuring the Widget Configuration File
-Configure the **config.json** file for the **Form** ability.
+Configure the **config.json** file for the widget.
-- The **js** module in the **config.json** file provides the JavaScript resources of the **Form** ability. The internal field structure is described as follows:
+- The **js** module in the **config.json** file provides the JavaScript resources of the widget. The internal structure is described as follows:
| Field| Description | Data Type| Default |
| -------- | ------------------------------------------------------------ | -------- | ------------------------ |
@@ -152,7 +145,7 @@ Configure the **config.json** file for the **Form** ability.
}]
```
-- The **abilities** module in the **config.json** file corresponds to the **LifecycleForm** of the widget. The internal field structure is described as follows:
+- The **abilities** module in the **config.json** file corresponds to the **LifecycleForm** of the widget. The internal structure is described as follows:
| Field | Description | Data Type | Default |
| ------------------- | ------------------------------------------------------------ | ---------- | ------------------------ |
@@ -161,12 +154,12 @@ Configure the **config.json** file for the **Form** ability.
| isDefault | Whether the widget is a default one. Each ability has only one default widget. **true**: The widget is the default one. **false**: The widget is not the default one.| Boolean | No |
| type | Type of the widget. Available values are as follows: **JS**: indicates a JavaScript-programmed widget. | String | No |
| colorMode | Color mode of the widget. Available values are as follows: **auto**: The widget adopts the auto-adaptive color mode. **dark**: The widget adopts the dark color mode. **light**: The widget adopts the light color mode.| String | Yes (initial value: **auto**)|
- | supportDimensions | Grid styles supported by the widget. Available values are as follows: 1 * 2: indicates a grid with one row and two columns. 2 * 2: indicates a grid with two rows and two columns. 2 * 4: indicates a grid with two rows and four columns. 4 * 4: indicates a grid with four rows and four columns.| String array| No |
+ | supportDimensions | Grid styles supported by the widget. Available values are as follows: **1 * 2**: indicates a grid with one row and two columns. **2 * 2**: indicates a grid with two rows and two columns. **2 * 4**: indicates a grid with two rows and four columns. **4 * 4**: indicates a grid with four rows and four columns.| String array| No |
| defaultDimension | Default grid style of the widget. The value must be available in the **supportDimensions** array of the widget.| String | No |
| updateEnabled | Whether the widget can be updated periodically. Available values are as follows: **true**: The widget can be updated periodically, depending on the update way you select, either at a specified interval (**updateDuration**) or at the scheduled time (**scheduledUpdateTime**). **updateDuration** is preferentially recommended. **false**: The widget cannot be updated periodically.| Boolean | No |
| scheduledUpdateTime | Scheduled time to update the widget. The value is in 24-hour format and accurate to minute. | String | Yes (initial value: **0:0**) |
| updateDuration | Interval to update the widget. The value is a natural number, in the unit of 30 minutes. If the value is **0**, this field does not take effect. If the value is a positive integer ***N***, the interval is calculated by multiplying ***N*** and 30 minutes.| Number | Yes (initial value: **0**) |
- | formConfigAbility | Indicates the link to a specific page of the application. The value is a URI. | String | Yes (initial value: left empty) |
+ | formConfigAbility | Link to a specific page of the application. The value is a URI. | String | Yes (initial value: left empty) |
| formVisibleNotify | Whether the widget is allowed to use the widget visibility notification. | String | Yes (initial value: left empty) |
| jsComponentName | Component name of the widget. The value is a string with a maximum of 127 bytes. | String | No |
| metaData | Metadata of the widget. This field contains the array of the **customizeData** field. | Object | Yes (initial value: left empty) |
@@ -203,7 +196,7 @@ Configure the **config.json** file for the **Form** ability.
```
-### Widget Data Persistence
+### Persistently Storing Widget Data
Mostly, the widget provider is started only when it needs to obtain information about a widget. The Widget Manager supports multi-instance management and uses the widget ID to identify an instance. If the widget provider supports widget data modification, it must persistently store the data based on the widget ID, so that it can access the data of the target widget when obtaining, updating, or starting a widget.
@@ -214,7 +207,8 @@ Mostly, the widget provider is started only when it needs to obtain information
let formId = want.parameters["ohos.extra.param.key.form_identity"];
let formName = want.parameters["ohos.extra.param.key.form_name"];
let tempFlag = want.parameters["ohos.extra.param.key.form_temporary"];
- // Persistently store widget information for subsequent use, such as widget instance retrieval and update.
+ // Persistently store widget information for subsequent use, such as widget instance retrieval or update.
+ // The storeFormInfo API is not implemented here. For details about the implementation, see "FA Model Widget" provided in "Samples".
storeFormInfo(formId, formName, tempFlag, want);
let obj = {
@@ -230,29 +224,53 @@ You should override **onDestroy** to delete widget data.
```javascript
onDestroy(formId) {
- // Delete widget data.
- deleteFormInfo(formId);
console.log('FormAbility onDestroy');
+
+ // You need to implement the code for deleting the persistent widget instance.
+ // The deleteFormInfo API is not implemented here. For details, see "Widget Host" provided in "Samples".
+ deleteFormInfo(formId);
}
```
For details about the persistence method, see [Lightweight Data Store Development](../database/database-preference-guidelines.md).
-Note that the **Want** passed by the widget host to the widget provider contains a temporary flag, indicating whether the requested widget is a temporary one.
+Note that the **Want** passed by the widget host to the widget provider contains a flag that indicates whether the requested widget is a temporary one.
-Normal widget: a widget that will be persistently used by the widget host
+- Normal widget: a widget that will be persistently used by the widget host
-Temporary widget: a widget that is temporarily used by the widget host
+- Temporary widget: a widget that is temporarily used by the widget host
Data of a temporary widget is not persistently stored. If the widget framework is killed and restarted, data of a temporary widget will be deleted. However, the widget provider is not notified of which widget is deleted, and still keeps the data. Therefore, the widget provider should implement data clearing. In addition, the widget host may convert a temporary widget into a normal one. If the conversion is successful, the widget provider should process the widget ID and store the data persistently. This prevents the widget provider from deleting persistent data when clearing temporary widgets.
-### Developing the Widget UI Page
+### Updating Widget Data
+
+When a widget application initiates a data update upon a scheduled or periodic update, the application obtains the latest data and calls **updateForm** to update the widget. The code snippet is as follows:
+
+```javascript
+onUpdate(formId) {
+ // To support scheduled update, periodic update, or update requested by the widget host, override this method for widget data update.
+ console.log('FormAbility onUpdate');
+ let obj = {
+ "title": "titleOnUpdate",
+ "detail": "detailOnUpdate"
+ };
+ let formData = formBindingData.createFormBindingData(obj);
+ // Call the updateForm method to update the widget. Only the data passed through the input parameter is updated. Other information remains unchanged.
+ formProvider.updateForm(formId, formData).catch((error) => {
+ console.log('FormAbility updateForm, error:' + JSON.stringify(error));
+ });
+}
+```
+
+### Developing Widget UI Pages
+
You can use HML, CSS, and JSON to develop the UI page for a JavaScript-programmed widget.
->  **NOTE**
+> **NOTE**
+>
> Currently, only the JavaScript-based web-like development paradigm can be used to develop the widget UI.
- - HML:
+ - In the HML file:
```html
@@ -267,7 +285,7 @@ You can use HML, CSS, and JSON to develop the UI page for a JavaScript-programme
```
- - CSS:
+ - In the CSS file:
```css
.container {
@@ -308,7 +326,7 @@ You can use HML, CSS, and JSON to develop the UI page for a JavaScript-programme
}
```
- - JSON:
+ - In the JSON file:
```json
{
"data": {
@@ -331,10 +349,8 @@ Now you've got a widget shown below.

-## Development Example
-
-The following sample is provided to help you better understand how to develop a widget on the FA model:
-
-[FormAbility](https://gitee.com/openharmony/app_samples/tree/master/ability/FormAbility)
+## Samples
-This sample provides a widget. Users can create, update, and delete widgets on the home screen of their devices or by using their own widget host. This sample also implements widget information persistence by using lightweight data storage.
+The following samples are provided to help you better understand how to develop a widget on the FA model:
+- [`FormAbility`: FA Model Widget (JS, API version 8)](https://gitee.com/openharmony/app_samples/tree/master/ability/FormAbility)
+- [`FormLauncher`: Widget Host (eTS, API version 8)](https://gitee.com/openharmony/app_samples/tree/master/ability/FormLauncher)
diff --git a/en/application-dev/ability/fa-pageability.md b/en/application-dev/ability/fa-pageability.md
index beaac42b2915507ef9ff58a4e40790c458d43f7f..7aa76452a3a17c7fd831044b345ffc6a8844e47a 100644
--- a/en/application-dev/ability/fa-pageability.md
+++ b/en/application-dev/ability/fa-pageability.md
@@ -37,6 +37,8 @@ You can override the lifecycle callbacks provided by the Page ability in the **a
The ability supports two launch types: singleton and multi-instance.
You can specify the launch type by setting **launchType** in the **config.json** file.
+**Table 1** Introduction to startup mode
+
| Launch Type | Description |Description |
| ----------- | ------- |---------------- |
| standard | Multi-instance | A new instance is started each time an ability starts.|
@@ -48,7 +50,7 @@ By default, **singleton** is used.
## Development Guidelines
### Available APIs
-**Table 1** APIs provided by featureAbility
+**Table 2** APIs provided by featureAbility
| API | Description |
| --------------------------------------------------- | --------------- |
@@ -86,8 +88,10 @@ By default, **singleton** is used.
);
```
-### Starting a Remote Page Ability (Applying only to System Applications)
->Note: The **getTrustedDeviceListSync** API of the **DeviceManager** class is open only to system applications. Therefore, remote Page ability startup applies only to system applications.
+### Starting a Remote Page Ability
+>Note
+>
+>This feature applies only to system applications, since the **getTrustedDeviceListSync** API of the **DeviceManager** class is open only to system applications.
**Modules to Import**
@@ -102,16 +106,16 @@ By default, **singleton** is used.
console.info('onStartRemoteAbility begin');
let params;
let wantValue = {
- bundleName: 'ohos.samples.etsDemo',
- abilityName: 'ohos.samples.etsDemo.RemoteAbility',
- deviceId: getRemoteDeviceId(),
- parameters: params
+ bundleName: 'ohos.samples.etsDemo',
+ abilityName: 'ohos.samples.etsDemo.RemoteAbility',
+ deviceId: getRemoteDeviceId(),
+ parameters: params
};
console.info('onStartRemoteAbility want=' + JSON.stringify(wantValue));
featureAbility.startAbility({
- want: wantValue
+ want: wantValue
}).then((data) => {
- console.info('onStartRemoteAbility finished, ' + JSON.stringify(data));
+ console.info('onStartRemoteAbility finished, ' + JSON.stringify(data));
});
console.info('onStartRemoteAbility end');
}
@@ -123,17 +127,17 @@ Obtain **deviceId** from **DeviceManager**. The sample code is as follows:
import deviceManager from '@ohos.distributedHardware.deviceManager';
let dmClass;
function getRemoteDeviceId() {
- if (typeof dmClass === 'object' && dmClass != null) {
- let list = dmClass.getTrustedDeviceListSync();
- if (typeof (list) == 'undefined' || typeof (list.length) == 'undefined') {
+ if (typeof dmClass === 'object' && dmClass != null) {
+ let list = dmClass.getTrustedDeviceListSync();
+ if (typeof (list) == 'undefined' || typeof (list.length) == 'undefined') {
console.log("MainAbility onButtonClick getRemoteDeviceId err: list is null");
return;
- }
- console.log("MainAbility onButtonClick getRemoteDeviceId success:" + list[0].deviceId);
- return list[0].deviceId;
- } else {
- console.log("MainAbility onButtonClick getRemoteDeviceId err: dmClass is null");
- }
+ }
+ console.log("MainAbility onButtonClick getRemoteDeviceId success:" + list[0].deviceId);
+ return list[0].deviceId;
+ } else {
+ console.log("MainAbility onButtonClick getRemoteDeviceId err: dmClass is null");
+ }
}
```
@@ -143,41 +147,40 @@ In the cross-device scenario, the application must also apply for the data synch
import abilityAccessCtrl from "@ohos.abilityAccessCtrl";
import bundle from '@ohos.bundle';
async function RequestPermission() {
- console.info('RequestPermission begin');
- let array: Array = ["ohos.permission.DISTRIBUTED_DATASYNC"];
- let bundleFlag = 0;
- let tokenID = undefined;
- let userID = 100;
- let appInfo = await bundle.getApplicationInfo('ohos.samples.etsDemo', bundleFlag, userID);
- tokenID = appInfo.accessTokenId;
- let atManager = abilityAccessCtrl.createAtManager();
- let requestPermissions: Array = [];
- for (let i = 0;i < array.length; i++) {
- let result = await atManager.verifyAccessToken(tokenID, array[i]);
- console.info("verifyAccessToken result:" + JSON.stringify(result));
- if (result == abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED) {
- } else {
- requestPermissions.push(array[i]);
- }
- }
- console.info("requestPermissions:" + JSON.stringify(requestPermissions));
- if (requestPermissions.length == 0 || requestPermissions == []) {
- return;
- }
- let context = featureAbility.getContext();
- context.requestPermissionsFromUser(requestPermissions, 1, (data)=>{
- console.info("data:" + JSON.stringify(data));
- console.info("data requestCode:" + data.requestCode);
- console.info("data permissions:" + data.permissions);
- console.info("data authResults:" + data.authResults);
- });
- console.info('RequestPermission end');
+ console.info('RequestPermission begin');
+ let array: Array = ["ohos.permission.DISTRIBUTED_DATASYNC"];
+ let bundleFlag = 0;
+ let tokenID = undefined;
+ let userID = 100;
+ let appInfo = await bundle.getApplicationInfo('ohos.samples.etsDemo', bundleFlag, userID);
+ tokenID = appInfo.accessTokenId;
+ let atManager = abilityAccessCtrl.createAtManager();
+ let requestPermissions: Array = [];
+ for (let i = 0;i < array.length; i++) {
+ let result = await atManager.verifyAccessToken(tokenID, array[i]);
+ console.info("verifyAccessToken result:" + JSON.stringify(result));
+ if (result != abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED) {
+ requestPermissions.push(array[i]);
+ }
+ }
+ console.info("requestPermissions:" + JSON.stringify(requestPermissions));
+ if (requestPermissions.length == 0 || requestPermissions == []) {
+ return;
+ }
+ let context = featureAbility.getContext();
+ context.requestPermissionsFromUser(requestPermissions, 1, (data)=>{
+ console.info("data:" + JSON.stringify(data));
+ console.info("data requestCode:" + data.requestCode);
+ console.info("data permissions:" + data.permissions);
+ console.info("data authResults:" + data.authResults);
+ });
+ console.info('RequestPermission end');
}
```
### Lifecycle APIs
-**Table 2** Lifecycle callbacks
+**Table 3** Lifecycle callbacks
| API | Description |
| ------------ | ------------------------------------------------------------ |
diff --git a/en/application-dev/ability/fa-serviceability.md b/en/application-dev/ability/fa-serviceability.md
index cf2609b22be6082751f415a6d85aac20e1a8ec9a..72b4542e19a675d3531948e07375d491fb001c63 100644
--- a/en/application-dev/ability/fa-serviceability.md
+++ b/en/application-dev/ability/fa-serviceability.md
@@ -5,22 +5,20 @@ A Service ability is used to run tasks in the background, such as playing music
## Available APIs
-**Table 1** Service ability lifecycle callbacks
+**Table 1** Service ability lifecycle APIs
|API|Description|
|:------|:------|
-|onStart|Called to initialize a Service ability when the Service ability is being created. This callback is invoked only once in the entire lifecycle of a Service ability. The **Want** object passed to this callback must be null.|
-|onCommand|Called every time a Service ability is created on a client. You can calculate calling statistics and perform initialization operations in this callback.|
-|onConnect|Called when another ability is connected to the Service ability.|
-|onDisconnect|Called when another ability is disconnected from the Service ability.|
-|onStop|Called when the Service ability is being destroyed. You should override this callback for your Service ability to clear its resources, such as threads and registered listeners.|
+|onStart?(): void|Called to initialize a Service ability being created. This callback is invoked only once in the entire lifecycle of a Service ability. The **Want** object passed to this callback must be null.|
+|onCommand?(want: Want, startId: number): void|Called every time a Service ability is created on a client. You can collect calling statistics and perform initialization operations in this callback.|
+|onConnect?(want: Want): rpc.RemoteObject|Called when another ability is connected to the Service ability.|
+|onDisconnect?(want: Want): void|Called when another ability is disconnected from the Service ability.|
+|onStop?(): void|Called when the Service ability is being destroyed. You should override this callback for your Service ability to clear its resources, such as threads and registered listeners.|
## How to Develop
-### Creating a Service Ability
+### Creating and Registering a Service Ability
-1. Create a child class of the **Ability** class and override the following Service ability-related lifecycle callbacks to implement your own logic for processing requests to interact with your Service ability:
-
- The following code snippet shows how to create a Service ability:
+1. Override the Service ability-related lifecycle callbacks to implement your own logic for processing interaction requests.
```javascript
export default {
@@ -32,6 +30,7 @@ A Service ability is used to run tasks in the background, such as playing music
},
onConnect(want) {
console.log('ServiceAbility OnConnect');
+ return null;
},
onDisconnect(want) {
console.log('ServiceAbility OnDisConnect');
@@ -41,10 +40,10 @@ A Service ability is used to run tasks in the background, such as playing music
},
}
```
-
+
2. Register a Service ability.
- You must declare your Service ability in the **config.json** file by setting its **type** attribute to **service**.
+ Declare the Service ability in the **config.json** file by setting its **type** attribute to **service**.
```javascript
{
@@ -78,12 +77,12 @@ The following code snippet shows how to start a Service ability running on the l
```javascript
import featureAbility from '@ohos.ability.featureAbility';
-let promise = await featureAbility.startAbility(
+let promise = featureAbility.startAbility(
{
want:
{
- bundleName: "com.jstest.serviceability",
- abilityName: "com.jstest.serviceability.MainAbility",
+ bundleName: "com.jstest.service",
+ abilityName: "com.jstest.service.ServiceAbility",
},
}
);
@@ -93,11 +92,26 @@ After the preceding code is executed, the **startAbility()** API is called to st
- If the Service ability is not running, the system calls **onStart()** to initialize the Service ability, and then calls **onCommand()** on the Service ability.
- If the Service ability is running, the system directly calls **onCommand()** on the Service ability.
+The following code snippet shows how to start a Service ability running on the remote device. For details about **getRemoteDeviceId()**, see [Connecting to a Remote Service Ability](#connecting-to-a-remote-service-ability-applying-only-to-system-applications).
+
+```javascript
+import featureAbility from '@ohos.ability.featureAbility';
+let promise = featureAbility.startAbility(
+ {
+ want:
+ {
+ deviceId: getRemoteDeviceId(), // Remote device ID
+ bundleName: "com.jstest.service",
+ abilityName: "com.jstest.service.ServiceAbility",
+ },
+ }
+);
+```
### Stopping a Service Ability
- Once created, the Service ability keeps running in the background. The system does not stop or destroy it unless memory resources must be reclaimed. You can call **terminateSelf()** on a Service ability to stop it.
+Once created, the Service ability keeps running in the background. The system does not stop or destroy it unless memory resources must be reclaimed.
@@ -105,124 +119,140 @@ After the preceding code is executed, the **startAbility()** API is called to st
If you need to connect a Service ability to a Page ability or to a Service ability in another application, you must first implement the **IAbilityConnection** API for the connection. A Service ability allows other abilities to connect to it through **connectAbility()**.
-When calling **connectAbility()**, you should pass a **Want** object containing information about the target Service ability and an **IAbilityConnection** object to the API. **IAbilityConnection** provides the following callbacks that you should implement: **onConnect()**, **onDisconnect()**, and **onFailed()**. The **onConnect()** callback is invoked when a Service ability is connected, **onDisconnect()** is invoked when a Service ability is unexpectedly disconnected, and **onFailed()** is invoked when a connection to a Service ability fails.
-The following code snippet shows how to implement the callbacks:
+You can use either of the following methods to connect to a Service ability:
-```javascript
-let mRemote;
-function onConnectCallback(element, remote){
- console.log('onConnectLocalService onConnectDone element: ' + element);
- console.log('onConnectLocalService onConnectDone remote: ' + remote);
- mRemote = remote;
- if (mRemote == null) {
- prompt.showToast({
- message: "onConnectLocalService not connected yet"
- });
- return;
- }
- let option = new rpc.MessageOption();
- let data = new rpc.MessageParcel();
- let reply = new rpc.MessageParcel();
- data.writeInt(1);
- data.writeInt(99);
- mRemote.sendRequest(1, data, reply, option).then((result) => {
- console.log('sendRequest success');
- let msg = reply.readInt();
+1. Using the IDL to automatically generate code
+
+ Use OpenHarmony Interface Definition Language (IDL) to automatically generate the corresponding client, server, and **IRemoteObject** code. For details, see [“Development Using TS” in OpenHarmony IDL Specifications and User Guide](https://gitee.com/openharmony/docs/blob/master/en/application-dev/IDL/idl-guidelines.md#development-using-ts).
+
+2. Writing code in the corresponding file
+
+ When calling **connectAbility()**, you should pass a **Want** object containing information about the target Service ability and an **IAbilityConnection** object to the API. **IAbilityConnection** provides the following callbacks that you should implement: **onConnect()**, **onDisconnect()**, and **onFailed()**. The **onConnect()** callback is invoked when a Service ability is connected, **onDisconnect()** is invoked when a Service ability is unexpectedly disconnected, and **onFailed()** is invoked when a connection to a Service ability fails.
+
+ The following code snippet shows how to implement the callbacks:
+
+ ```javascript
+ import prompt from '@system.prompt'
+
+ let mRemote;
+ function onConnectCallback(element, remote){
+ console.log('onConnectLocalService onConnectDone element: ' + element);
+ console.log('onConnectLocalService onConnectDone remote: ' + remote);
+ mRemote = remote;
+ if (mRemote == null) {
prompt.showToast({
- message: "onConnectLocalService connect result: " + msg,
- duration: 3000
+ message: "onConnectLocalService not connected yet"
+ });
+ return;
+ }
+ let option = new rpc.MessageOption();
+ let data = new rpc.MessageParcel();
+ let reply = new rpc.MessageParcel();
+ data.writeInt(1);
+ data.writeInt(99);
+ mRemote.sendRequest(1, data, reply, option).then((result) => {
+ console.log('sendRequest success');
+ let msg = reply.readInt();
+ prompt.showToast({
+ message: "onConnectLocalService connect result: " + msg,
+ duration: 3000
+ });
+ }).catch((e) => {
+ console.log('sendRequest error:' + e);
});
- }).catch((e) => {
- console.log('sendRequest error:' + e);
- });
-}
+ }
-function onDisconnectCallback(element){
- console.log('ConnectAbility onDisconnect Callback')
-}
+ function onDisconnectCallback(element){
+ console.log('ConnectAbility onDisconnect Callback')
+ }
-function onFailedCallback(code){
- console.log('ConnectAbility onFailed Callback')
-}
-```
+ function onFailedCallback(code){
+ console.log('ConnectAbility onFailed Callback')
+ }
+ ```
-The following code snippet shows how to connect to a local Service ability:
+ The following code snippet shows how to connect to a local Service ability:
-```javascript
-import featureAbility from '@ohos.ability.featureAbility';
-let connId = featureAbility.connectAbility(
- {
- bundleName: "com.jstest.serviceability",
- abilityName: "com.jstest.serviceability.MainAbility",
- },
- {
- onConnect: onConnectCallback,
- onDisconnect: onDisconnectCallback,
- onFailed: onFailedCallback,
- },
-);
-```
+ ```javascript
+ import featureAbility from '@ohos.ability.featureAbility';
+ let connId = featureAbility.connectAbility(
+ {
+ bundleName: "com.jstest.service",
+ abilityName: "com.jstest.service.ServiceAbility",
+ },
+ {
+ onConnect: onConnectCallback,
+ onDisconnect: onDisconnectCallback,
+ onFailed: onFailedCallback,
+ },
+ );
+ ```
-When a Service ability is connected, the **onConnect()** callback is invoked and returns an **IRemoteObject** defining the proxy used for communicating with the Service ability. OpenHarmony provides a default implementation of the **IRemoteObject** interface. You can inherit **rpc.RemoteObject** to implement your own class of **IRemoteObject**.
+ When a Service ability is connected, the **onConnect()** callback is invoked and returns an **IRemoteObject** defining the proxy used for communicating with the Service ability. OpenHarmony provides a default implementation of **IRemoteObject**. You can extend **rpc.RemoteObject** to implement your own class of **IRemoteObject**.
-The following code snippet shows how the Service ability instance returns itself to the calling ability:
+ The following code snippet shows how the Service ability instance returns itself to the calling ability:
-```javascript
-import rpc from "@ohos.rpc";
+ ```javascript
+ import rpc from "@ohos.rpc";
-let mMyStub;
-export default {
- onStart() {
- class MyStub extends rpc.RemoteObject{
- constructor(des) {
- if (typeof des === 'string') {
- super(des);
+ let mMyStub;
+ export default {
+ onStart() {
+ class MyStub extends rpc.RemoteObject{
+ constructor(des) {
+ if (typeof des === 'string') {
+ super(des);
+ }
+ return null;
}
- return null;
- }
- onRemoteRequest(code, data, reply, option) {
- console.log("ServiceAbility onRemoteRequest called");
- if (code === 1) {
- let op1 = data.readInt();
- let op2 = data.readInt();
- console.log("op1 = " + op1 + ", op2 = " + op2);
- reply.writeInt(op1 + op2);
- } else {
- console.log("ServiceAbility unknown request code");
+ onRemoteRequest(code, data, reply, option) {
+ console.log("ServiceAbility onRemoteRequest called");
+ if (code === 1) {
+ let op1 = data.readInt();
+ let op2 = data.readInt();
+ console.log("op1 = " + op1 + ", op2 = " + op2);
+ reply.writeInt(op1 + op2);
+ } else {
+ console.log("ServiceAbility unknown request code");
+ }
+ return true;
}
- return true;
}
- }
- mMyStub = new MyStub("ServiceAbility-test");
- },
- onCommand(want, startId) {
- console.log('ServiceAbility onCommand');
- },
- onConnect(want) {
- console.log('ServiceAbility OnConnect');
- return mMyStub;
- },
- onDisconnect(want) {
- console.log('ServiceAbility OnDisConnect');
- },
- onStop() {
- console.log('ServiceAbility onStop');
- },
-}
-```
+ mMyStub = new MyStub("ServiceAbility-test");
+ },
+ onCommand(want, startId) {
+ console.log('ServiceAbility onCommand');
+ },
+ onConnect(want) {
+ console.log('ServiceAbility OnConnect');
+ return mMyStub;
+ },
+ onDisconnect(want) {
+ console.log('ServiceAbility OnDisConnect');
+ },
+ onStop() {
+ console.log('ServiceAbility onStop');
+ },
+ }
+ ```
+
+### Connecting to a Remote Service Ability
-### Connecting to a Remote Service Ability (Applying only to System Applications)
->Note: The **getTrustedDeviceListSync** API of the **DeviceManager** class is open only to system applications. Therefore, remote Service ability startup applies only to system applications.
+>**NOTE**
+>
+>This feature applies only to system applications, since the **getTrustedDeviceListSync** API of the **DeviceManager** class is open only to system applications.
-If you need to connect a Service ability to a Page ability on another device or to a Service ability in another application on another device, you must first implement the **IAbilityConnection** interface for the connection. A Service ability allows other abilities on another device to connect to it through **connectAbility()**.
+If you need to connect a Service ability to a Page ability or another Service ability on a remote device, you must first implement the **IAbilityConnection** interface for the connection. A Service ability allows abilities on another device to connect to it through **connectAbility()**.
When calling **connectAbility()**, you should pass a **Want** object containing information about the target Service ability and an **IAbilityConnection** object to the API. **IAbilityConnection** provides the following callbacks that you should implement: **onConnect()**, **onDisconnect()**, and **onFailed()**. The **onConnect()** callback is invoked when a Service ability is connected, **onDisconnect()** is invoked when a Service ability is unexpectedly disconnected, and **onFailed()** is invoked when a connection to a Service ability fails.
The following code snippet shows how to implement the callbacks:
```ts
+import prompt from '@system.prompt'
+
let mRemote;
function onConnectCallback(element, remote){
console.log('onConnectRemoteService onConnectDone element: ' + element);
@@ -264,7 +294,10 @@ The **Want** of the target Service ability must contain the remote **deviceId**,
```ts
import deviceManager from '@ohos.distributedHardware.deviceManager';
+
+// For details about the implementation of dmClass, see the implementation in Distributed Demo in Samples.
let dmClass;
+
function getRemoteDeviceId() {
if (typeof dmClass === 'object' && dmClass != null) {
let list = dmClass.getTrustedDeviceListSync();
@@ -327,15 +360,12 @@ async function RequestPermission() {
let context = featureAbility.getContext();
context.requestPermissionsFromUser(requestPermissions, 1, (data)=>{
console.info("data:" + JSON.stringify(data));
- console.info("data requestCode:" + data.requestCode);
- console.info("data permissions:" + data.permissions);
- console.info("data authResults:" + data.authResults);
});
console.info('RequestPermission end');
}
```
-When a Service ability is connected, the **onConnect()** callback is invoked and returns an **IRemoteObject** defining the proxy used for communicating with the Service ability. OpenHarmony provides a default implementation of the **IRemoteObject** interface. You can inherit **rpc.RemoteObject** to implement your own class of **IRemoteObject**.
+When a Service ability is connected, the **onConnect()** callback is invoked and returns an **IRemoteObject** defining the proxy used for communicating with the Service ability. OpenHarmony provides a default implementation of **IRemoteObject**. You can extend **rpc.RemoteObject** to implement your own class of **IRemoteObject**.
The following code snippet shows how the Service ability instance returns itself to the calling ability:
@@ -398,5 +428,5 @@ export default {
## Samples
The following samples are provided to help you better understand how to develop a Service ability:
-- [`ServiceAbility`: Service Ability Creation and Use (eTS) (API8)](https://gitee.com/openharmony/app_samples/tree/master/ability/ServiceAbility)
-- [`DMS`: Distributed Demo (eTS) (API7)](https://gitee.com/openharmony/app_samples/tree/master/ability/DMS)
+- [`ServiceAbility`: Service Ability Creation and Use (eTS, API version 8)](https://gitee.com/openharmony/app_samples/tree/master/ability/ServiceAbility)
+- [`DMS`: Distributed Demo (eTS, API version 8)](https://gitee.com/openharmony/app_samples/tree/master/ability/DMS)
diff --git a/en/application-dev/ability/figures/fa-pageAbility-lifecycle.png b/en/application-dev/ability/figures/fa-pageAbility-lifecycle.png
index ab6e01af0cf96f852c37696fe0c23425219eca39..59a06741053c85cab6ea90b41bd16a6f2e1ff508 100644
Binary files a/en/application-dev/ability/figures/fa-pageAbility-lifecycle.png and b/en/application-dev/ability/figures/fa-pageAbility-lifecycle.png differ
diff --git a/en/application-dev/ability/stage-ability-continuation.md b/en/application-dev/ability/stage-ability-continuation.md
index 0e070f2fee46ba41aa1f7c342b202010a9b58d10..0695a3bd491785d414d75be6520d513229b0bcbc 100644
--- a/en/application-dev/ability/stage-ability-continuation.md
+++ b/en/application-dev/ability/stage-ability-continuation.md
@@ -2,19 +2,18 @@
## When to Use
-Ability continuation is to continue the current mission of an application, including the UI component status variables and distributed objects, on another device. The UI component status variables are used to synchronize page data, and the distributed objects are used to synchronize data in the memory.
+Ability continuation is to continue the current mission of an application, including the UI component state variables and distributed objects, on another device. The UI component state variables are used to synchronize UI data, and the distributed objects are used to synchronize memory data.
## Available APIs
-The following table lists the APIs used for ability continuation. For details about the APIs, see [Ability](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-application-ability.md).
+The following table lists the APIs used for ability continuation. For details about the APIs, see [Ability](../reference/apis/js-apis-application-ability.md).
**Table 1** Ability continuation APIs
|API| Description|
|:------ | :------|
-| onContinue(wantParam : {[key: string]: any}): OnContinueResult | Called by the **initiator** to save data during the ability continuation preparation process. The return value **0** means that the continuation request is accepted, and an error code means that the continuation request is denied.|
-| onCreate(want: Want, param: LaunchParam): void| Called by the **target** to restore the data and page.|
-| **enum** OnContinueResult | Enumerates the return values of **onContinue**. The options are as follows: **AGREE** (request accepted), **REJECT** (request denied), and **MISMATCH** (version mismatch).|
+| onContinue(wantParam : {[key: string]: any}): OnContinueResult | Called by the initiator to store the data required for continuation and request continuation. The value **AGREE** means that the continuation is accepted, and **REJECT** means the continuation is rejected, and **MISMATCH** means a version mismatch.|
+| onCreate(want: Want, param : LaunchParam): void | Called by the target to restore the data and UI page.|
@@ -22,6 +21,8 @@ The following table lists the APIs used for ability continuation. For details ab

+In effect, ability continuation is a cross-device ability startup that carries data. When the continuation is triggered, device A calls back **onContinue()** of the application. You must save the current data in this API. Then, device A initiates a cross-device ability startup on device B and transmits the data to device B. Device B calls back **onCreate()**. You must restore the transmitted data in this API.
+
## How to Develop
### Application Continuation
@@ -31,78 +32,84 @@ The following table lists the APIs used for ability continuation. For details ab
- Configure the application to support ability continuation.
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 another device.
-
- ```javascript
- "continuable": true
- ```
+
+ ```javascript
+ "continuable": true
+ ```
+
- * Configure the application startup type.
+ - Configure the application startup type.
- Set **launchType** in the **module.json5** to **standard**. Currently, only multi-instance applications can be continued on another device.
-
- ```javascript
- "launchType": "standard"
- ```
+ Set **launchType** in the **module.json5** file to **standard** to add multi-instance support to the application.
+
+ ```javascript
+ "launchType": "standard"
+ ```
+
- * Apply for the distributed permissions.
+ - Apply for the distributed permissions.
Declare the **DISTRIBUTED_DATASYNC** permission in the **module.json5** file for the application.
-
- ```javascript
- "requestPermissions": [
- {
- "name": "ohos.permission.DISTRIBUTED_DATASYNC"
- },
- ```
-
- This permission must be granted by the user in a dialog box when the application is started for the first time. To enable the application to display a dialog box to ask for the permission, add the following code to **onWindowStageCreate** of the **Ability** class:
-
- ```javascript
- requestPermissions = async () => {
- let permissions: Array = [
- "ohos.permission.DISTRIBUTED_DATASYNC"
- ];
- let needGrantPermission = false
- let accessManger = accessControl.createAtManager()
- Logger.info("app permission get bundle info")
- let bundleInfo = await bundle.getApplicationInfo(BUNDLE_NAME, 0, 100)
- Logger.info(`app permission query permission ${bundleInfo.accessTokenId.toString()}`)
- for (const permission of permissions) {
- Logger.info(`app permission query grant status ${permission}`)
- try {
- let grantStatus = await accessManger.verifyAccessToken(bundleInfo.accessTokenId, permission)
- if (grantStatus === PERMISSION_REJECT) {
- needGrantPermission = true
- break;
- }
- } catch (err) {
- Logger.error(`app permission query grant status error ${permission} ${JSON.stringify(err)}`)
- needGrantPermission = true
- break;
- }
- }
- if (needGrantPermission) {
- Logger.info("app permission needGrantPermission")
- try {
- await this.context.requestPermissionsFromUser(permissions)
- } catch (err) {
- Logger.error(`app permission ${JSON.stringify(err)}`)
- }
- } else {
- Logger.info("app permission already granted")
- }
- }
- ```
-
-
-
-2. Implement the **onContinue** API.
-
- The **onContinue** API is called by the **initiator** to save the UI component status variables and memory data and prepare for continuation. After the application completes the continuation preparation, the system must return **OnContinueResult.AGREE** to accept the continuation request. If an error code is returned, the request is denied. If this API is not implemented, the system rejects the continuation request by default.
+
+ ```javascript
+ "requestPermissions": [
+ {
+ "name": "ohos.permission.DISTRIBUTED_DATASYNC"
+ },
+ ```
+
+
+
+ This permission must be granted by the user in a dialog box when the application is started for the first time. To enable the application to display a dialog box to ask for the permission, add the following code to **onWindowStageCreate** of the **Ability** class:
+
+ ```javascript
+ requestPermissions = async () => {
+ let permissions: Array = [
+ "ohos.permission.DISTRIBUTED_DATASYNC"
+ ];
+ let needGrantPermission = false
+ let accessManger = accessControl.createAtManager()
+ Logger.info("app permission get bundle info")
+ let bundleInfo = await bundle.getApplicationInfo(BUNDLE_NAME, 0, 100)
+ Logger.info(`app permission query permission ${bundleInfo.accessTokenId.toString()}`)
+ for (const permission of permissions) {
+ Logger.info(`app permission query grant status ${permission}`)
+ try {
+ let grantStatus = await accessManger.verifyAccessToken(bundleInfo.accessTokenId, permission)
+ if (grantStatus === PERMISSION_REJECT) {
+ needGrantPermission = true
+ break;
+ }
+ } catch (err) {
+ Logger.error(`app permission query grant status error ${permission} ${JSON.stringify(err)}`)
+ needGrantPermission = true
+ break;
+ }
+ }
+ if (needGrantPermission) {
+ Logger.info("app permission needGrantPermission")
+ try {
+ await this.context.requestPermissionsFromUser(permissions)
+ } catch (err) {
+ Logger.error(`app permission ${JSON.stringify(err)}`)
+ }
+ } else {
+ Logger.info("app permission already granted")
+ }
+ }
+ ```
+
+
+
+
+
+2. Implement the **onContinue()** API.
+
+ The **onContinue()** API is called by the initiator to save the UI component state variables and memory data and prepare for continuation. After the application completes the continuation preparation, the system must return **OnContinueResult.AGREE(0)** to accept the continuation request. If an error code is returned, the request is rejected. If this API is not implemented, the system rejects the continuation request by default.
Modules to import:
@@ -111,41 +118,38 @@ The following table lists the APIs used for ability continuation. For details ab
import AbilityConstant from '@ohos.application.AbilityConstant';
```
- - To implement ability continuation, you must implement this API and have the value **AGREE** returned.
-
-
- - Example
-
+ To implement ability continuation, you must implement this API and have the value **AGREE** returned.
+
+ Example
+
```javascript
- onContinue(wantParam : {[key: string]: any}) {
- Logger.info("onContinue using distributedObject")
- // Set the user input data into the want parameter.
- wantParam["input"] = AppStorage.Get('ContinueInput');
- Logger.info(`onContinue input = ${wantParam["input"]}`);
- return AbilityConstant.OnContinueResult.AGREE
- }
+ onContinue(wantParam : {[key: string]: any}) {
+ Logger.info("onContinue using distributedObject")
+ // Set the user input data into want params.
+ wantParam["input"] = AppStorage.Get('ContinueInput');
+ Logger.info(`onContinue input = ${wantParam["input"]}`);
+ return AbilityConstant.OnContinueResult.AGREE
+ }
```
+
+
+3. Implement the continuation logic in the **onCreate()** API.
+ The **onCreate()** API is called by the target. When the ability is started on the target device, this API is called to instruct the application to synchronize the memory data and UI component state, and triggers page restoration after the synchronization is complete. If the continuation logic is not implemented, the ability will be started in common startup mode and the page cannot be restored.
-3. Implement the continuation logic in the **onCreate** API.
-
- The **onCreate** API is called by the **target**. When the ability is started on the target device, this API is called to instruct the application to synchronize the memory data and UI component status, and triggers page restoration after the synchronization is complete. If the continuation logic is not implemented, the ability will be started in common startup mode and the page cannot be restored.
-
- - The target device determines whether the startup is **LaunchReason.CONTINUATION** based on **launchReason** in **onCreate**.
-
-
- - After data restore is complete, call **restoreWindowStage** to trigger page restoration.
-
-
- * Example
+ The target device determines whether the startup is **LaunchReason.CONTINUATION** based on **launchReason** in **onCreate()**.
+
+ After data restore is complete, call **restoreWindowStage** to trigger page restoration.
+
+ Example
```javascript
onCreate(want, launchParam) {
Logger.info(`MainAbility onCreate ${AbilityConstant.LaunchReason.CONTINUATION}`)
globalThis.abilityWant = want;
if (launchParam.launchReason == AbilityConstant.LaunchReason.CONTINUATION) {
- let input = want.parameters.input // get user data from want params
+ let input = want.parameters.input // Obtain user data from want params.
AppStorage.SetOrCreate('ContinueInput', input)
Logger.info(`onCreate for continuation sessionId: ${this.sessionId}`)
@@ -159,71 +163,68 @@ The following table lists the APIs used for ability continuation. For details ab
### Data Continuation
-1. Use distributed objects.
-
- Distributed data objects allow cross-device data synchronization like local variables. For two devices that form a Super Device, when data in the distributed data object of an application is added, deleted, or modified on a device, the data for the same application is also updated on the other device. Both devices can listen for the data changes and online and offline states of the other. For details, see [Distributed Data Object Development](https://gitee.com/openharmony/docs/blob/master/en/application-dev/database/database-distributedobject-guidelines.md).
-
- In the ability continuation scenario, the distributed data object is used to synchronize the memory data from the local device to the target device.
-
- - In **onContinue**, the initiator saves the data to be continued to the distributed object, sets the session ID, and sends the session ID to the target device through **wantParam**.
-
- ```javascript
- import Ability from '@ohos.application.Ability';
- import distributedObject from '@ohos.data.distributedDataObject';
-
- var g_object = distributedObject.createDistributedObject({name:undefined});
-
- export default class MainAbility extends Ability {
- contentStorage : ContentStorage
- sessionId : string;
-
- onContinue(wantParam : {[key: string]: any}) {
- Logger.info("onContinue using distributedObject")
- this.sessionId = distributedObject.genSessionId();
- // Set the session ID for the distributed data object.
- g_object.setSessionId(this.sessionId);
- g_object.name = "Amy";
- // Set the session ID into the want parameter.
- wantParam["session"] = this.sessionId;
- return AbilityConstant.OnContinueResult.AGREE
- }
-
- ```
-
- - The target device obtains the session ID from **onCreate**, creates a distributed object, and associates the distributed object with the session ID. In this way, the distributed object can be synchronized. Before calling **restoreWindowStage**, ensure that all distributed objects required for continuation have been associated for correct data retrieval.
-
- ```javascript
- import Ability from '@ohos.application.Ability';
- import distributedObject from '@ohos.data.distributedDataObject';
-
- var g_object = distributedObject.createDistributedObject({name:undefined});
-
- export default class MainAbility extends Ability {
- contentStorage : ContentStorage
- sessionId : string;
-
- statusCallback(sessionId, networkid, status) {
- Logger.info(`continuation object status change, sessionId: ${sessionId}, status: ${status}, g_object.name: ${g_object.name}`)
- }
-
- onCreate(want, launchParam) {
- Logger.info(`MainAbility onCreate ${AbilityConstant.LaunchReason.CONTINUATION}`)
- if (launchParam.launchReason == AbilityConstant.LaunchReason.CONTINUATION) {
- // Obtain the session ID of the distributed data object from the want parameter.
- this.sessionId = want.parameters.session
- Logger.info(`onCreate for continuation sessionId: ${this.sessionId}`)
-
- g_object.on("status", this.statusCallback);
- // Set the session ID for data synchronization.
- g_object.setSessionId(this.sessionId);
-
- this.contentStorage = new ContentStorage();
- this.context.restoreWindowStage(this.contentStorage);
- }
- }
+Use distributed objects.
+
+Distributed objects allow cross-device data synchronization like local variables. For two devices that form a Super Device, when data in the distributed data object of an application is added, deleted, or modified on a device, the data for the same application is also updated on the other device. Both devices can listen for the data changes and online and offline states of the other. For details, see [Distributed Data Object Development](../database/database-distributedobject-guidelines.md).
+
+In the ability continuation scenario, the distributed data object is used to synchronize the memory data from the local device to the target device.
+
+- In **onContinue()**, the initiator saves the data to be continued to the distributed object, sets the session ID, and sends the session ID to the target device through **wantParam**.
+
+ ```javascript
+ import Ability from '@ohos.application.Ability';
+ import distributedObject from '@ohos.data.distributedDataObject';
+
+ var g_object = distributedObject.createDistributedObject({name:undefined});
+
+ export default class MainAbility extends Ability {
+ contentStorage : ContentStorage
+ sessionId : string;
+
+ onContinue(wantParam : {[key: string]: any}) {
+ Logger.info("onContinue using distributedObject")
+ this.sessionId = distributedObject.genSessionId();
+ // Set the session ID for the distributed data object.
+ g_object.setSessionId(this.sessionId);
+ g_object.name = "Amy";
+ // Set the session ID into the want parameter.
+ wantParam["session"] = this.sessionId;
+ return AbilityConstant.OnContinueResult.AGREE
}
- ```
-
-
-
-For details about the complete example, see the sample.
+ ```
+
+
+
+- The target device obtains the session ID from **onCreate()**, creates a distributed object, and associates the distributed object with the session ID. In this way, the distributed object can be synchronized. Before calling **restoreWindowStage**, ensure that all distributed objects required for continuation have been associated.
+
+ ```javascript
+ import Ability from '@ohos.application.Ability';
+ import distributedObject from '@ohos.data.distributedDataObject';
+
+ var g_object = distributedObject.createDistributedObject({name:undefined});
+
+ export default class MainAbility extends Ability {
+ contentStorage : ContentStorage
+ sessionId : string;
+
+ statusCallback(sessionId, networkid, status) {
+ Logger.info(`continuation object status change, sessionId: ${sessionId}, status: ${status}, g_object.name: ${g_object.name}`)
+ }
+
+ onCreate(want, launchParam) {
+ Logger.info(`MainAbility onCreate ${AbilityConstant.LaunchReason.CONTINUATION}`)
+ if (launchParam.launchReason == AbilityConstant.LaunchReason.CONTINUATION) {
+ // Obtain the session ID of the distributed data object from the want parameter.
+ this.sessionId = want.parameters.session
+ Logger.info(`onCreate for continuation sessionId: ${this.sessionId}`)
+
+ g_object.on("status", this.statusCallback);
+ // Set the session ID for data synchronization.
+ g_object.setSessionId(this.sessionId);
+
+ this.contentStorage = new ContentStorage();
+ this.context.restoreWindowStage(this.contentStorage);
+ }
+ }
+ }
+ ```
diff --git a/en/application-dev/ability/stage-ability.md b/en/application-dev/ability/stage-ability.md
index 8429b0ae59a9a28b2601855f90bd04f602e68226..011951ac5073aaec023c7c27aad3fe13dd1a7392 100644
--- a/en/application-dev/ability/stage-ability.md
+++ b/en/application-dev/ability/stage-ability.md
@@ -1,19 +1,19 @@
# Ability Development
## When to Use
-Unlike the FA model, the [stage model](stage-brief.md) requires you to declare the application package structure in the `module.json` and `app.json` files during application development. For details about the configuration file, see [Application Package Structure Configuration File](../quick-start/stage-structure.md). To develop abilities based on the stage model, implement the following logic:
-- Create abilities for an application that involves screen viewing and human-machine interaction. You must implement the following scenarios: ability lifecycle callbacks, obtaining ability configuration, requesting permissions, and notifying environment changes.
+Ability development in the [stage model](stage-brief.md) is significantly different from that in the FA model. The stage model requires you to declare the application package structure in the `module.json` and `app.json` files during application development. For details about the configuration file, see [Application Package Structure Configuration File](../quick-start/stage-structure.md). To develop an ability based on the stage model, implement the following logic:
+- Create an ability that supports screen viewing and human-machine interaction. You must implement the following scenarios: ability lifecycle callbacks, obtaining ability configuration, requesting permissions, and notifying environment changes.
- Start an ability. You need to implement ability startup on the same device, on a remote device, or with a specified UI page.
- Call abilities. For details, see [Call Development](stage-call.md).
- Connect to and disconnect from a Service Extension ability. For details, see [Service Extension Ability Development](stage-serviceextension.md).
- Continue the ability on another device. For details, see [Ability Continuation Development](stage-ability-continuation.md).
### Launch Type
-The ability supports three launch types: singleton, multi-instance, and instance-specific. Each launch type, specified by `launchType` in the `module.json` file, specifies the action that can be performed when the ability is started.
+An ability can be launched in the **standard**, **singleton**, or **specified** mode, as configured by `launchType` in the `module.json` file. Depending on the launch type, the action performed when the ability is started differs, as described below.
-| Launch Type | Description |Description |
+| Launch Type | Description |Action |
| ----------- | ------- |---------------- |
| standard | Multi-instance | A new instance is started each time an ability starts.|
-| singleton | Singleton | Only one instance exists in the system. If an instance already exists when an ability is started, that instance is reused.|
+| singleton | Singleton | The ability has only one instance in the system. If an instance already exists when an ability is started, that instance is reused.|
| specified | Instance-specific| The internal service of an ability determines whether to create multiple instances during running.|
By default, the singleton mode is used. The following is an example of the `module.json` file:
@@ -78,29 +78,29 @@ To create Page abilities for an application in the stage model, you must impleme
onCreate(want, launchParam) {
console.log("MainAbility onCreate")
}
-
+
onDestroy() {
console.log("MainAbility onDestroy")
}
-
+
onWindowStageCreate(windowStage) {
console.log("MainAbility onWindowStageCreate")
-
+
windowStage.loadContent("pages/index").then((data) => {
console.log("MainAbility load content succeed with data: " + JSON.stringify(data))
}).catch((error) => {
console.error("MainAbility load content failed with error: " + JSON.stringify(error))
})
}
-
+
onWindowStageDestroy() {
console.log("MainAbility onWindowStageDestroy")
}
-
+
onForeground() {
console.log("MainAbility onForeground")
}
-
+
onBackground() {
console.log("MainAbility onBackground")
}
@@ -145,9 +145,9 @@ export default class MainAbility extends Ability {
}
```
### Requesting Permissions
-If an application needs to obtain user privacy information or use system capabilities, for example, obtaining location information or using the camera to take photos or record videos, it must request the permission from consumers. During application development, you need to specify the involved sensitive permissions, declare the required permissions in `module.json`, and use the `requestPermissionsFromUser` API to request the permission from consumers in the form of a dialog box. The following uses the permissions for calendar access as an example.
+If an application needs to obtain user privacy information or use system capabilities, for example, obtaining location information or using the camera to take photos or record videos, it must request the respective permission from consumers. During application development, you need to specify the involved sensitive permissions, declare the required permissions in `module.json`, and use the `requestPermissionsFromUser` API to request the permission from consumers in the form of a dialog box. The following uses the permission for calendar access as an example.
-Declare the required permissions in the `module.json` file.
+Declare the required permission in the `module.json` file.
```json
"requestPermissions": [
{
@@ -155,7 +155,7 @@ Declare the required permissions in the `module.json` file.
}
]
```
-Request the permissions from consumers in the form of a dialog box:
+Request the permission from consumers in the form of a dialog box:
```ts
let context = this.context
let permissions: Array = ['ohos.permission.READ_CALENDAR']
@@ -166,11 +166,11 @@ context.requestPermissionsFromUser(permissions).then((data) => {
})
```
### Notifying of Environment Changes
-Environment changes include changes of global configurations and ability configurations. Currently, the global configurations include the system language and color mode. The change of global configurations is generally triggered by the configuration item in **Settings** or the icon in **Control Panel**. The ability configuration is specific to a single `Ability` instance, including the display ID, screen resolution, and screen orientation. The configuration is related to the display where the ability is located, and the change is generally triggered by the window. For details on the configuration, see [Configuration](../reference/apis/js-apis-configuration.md).
+Environment changes include changes of global configurations and ability configurations. Currently, the global configurations include the system language and color mode. The change of global configurations is generally triggered by configuration items in **Settings** or icons in **Control Panel**. The ability configuration is specific to a single `Ability` instance, including the display ID, screen resolution, and screen orientation. The configuration is related to the display where the ability is located, and the change is generally triggered by the window. For details on the configuration, see [Configuration](../reference/apis/js-apis-configuration.md).
For an application in the stage model, when the configuration changes, its abilities are not restarted, but the `onConfigurationUpdated(config: Configuration)` callback is triggered. If the application needs to perform processing based on the change, you can overwrite `onConfigurationUpdated`. Note that the `Configuration` object in the callback contains all the configurations of the current ability, not only the changed configurations.
-The following example shows the implement of the `onConfigurationUpdated` callback in the `AbilityStage` class. The callback is triggered when the system language and color mode are changed.
+The following example shows the implementation of the `onConfigurationUpdated` callback in the `AbilityStage` class. The callback is triggered when the system language and color mode are changed.
```ts
import Ability from '@ohos.application.Ability'
import ConfigurationConstant from '@ohos.application.ConfigurationConstant'
@@ -184,7 +184,7 @@ export default class MyAbilityStage extends AbilityStage {
}
```
-The following example shows the implement of the `onConfigurationUpdated` callback in the `Ability` class. The callback is triggered when the system language, color mode, or display parameters (such as the direction and density) change.
+The following example shows the implementation of the `onConfigurationUpdated` callback in the `Ability` class. The callback is triggered when the system language, color mode, or display parameters (such as the direction and density) change.
```ts
import Ability from '@ohos.application.Ability'
import ConfigurationConstant from '@ohos.application.ConfigurationConstant'
@@ -205,19 +205,19 @@ export default class MainAbility extends Ability {
```
## Starting an Ability
### Available APIs
-The `Ability` class has the `context` attribute, which belongs to the `AbilityContext` class. The `AbilityContext` class has the `abilityInfo`, `currentHapModuleInfo`, and other attributes and the APIs used for starting abilities. For details, see [AbilityContext](../reference/apis/js-apis-ability-context.md).
+The `Ability` class has the `context` attribute, which belongs to the `AbilityContext` class. The `AbilityContext` class has the `abilityInfo`, `currentHapModuleInfo`, and other attributes as well as the APIs used for starting abilities. For details, see [AbilityContext](../reference/apis/js-apis-ability-context.md).
**Table 3** AbilityContext APIs
|API|Description|
|:------|:------|
-|startAbility(want: Want, callback: AsyncCallback): void|Starts an ability.|
-|startAbility(want: Want, options?: StartOptions): Promise|Starts an ability.|
-|startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback): void|Starts an ability with the account ID.|
-|startAbilityWithAccount(want: Want, accountId: number, options?: StartOptions): Promise|Starts an ability with the account ID.|
-|startAbilityForResult(want: Want, callback: AsyncCallback): void|Starts an ability with the returned result.|
-|startAbilityForResult(want: Want, options?: StartOptions): Promise|Starts an ability with the returned result.|
-|startAbilityForResultWithAccount(want: Want, accountId: number, callback: AsyncCallback): void|Starts an ability with the execution result and account ID.|
-|startAbilityForResultWithAccount(want: Want, accountId: number, options?: StartOptions): Promise|Starts an ability with the execution result and account ID.|
+|startAbility(want: Want, callback: AsyncCallback\): void|Starts an ability.|
+|startAbility(want: Want, options?: StartOptions): Promise\|Starts an ability.|
+|startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\): void|Starts an ability with the account ID.|
+|startAbilityWithAccount(want: Want, accountId: number, options?: StartOptions): Promise\|Starts an ability with the account ID.|
+|startAbilityForResult(want: Want, callback: AsyncCallback\): void|Starts an ability with the returned result.|
+|startAbilityForResult(want: Want, options?: StartOptions): Promise\|Starts an ability with the returned result.|
+|startAbilityForResultWithAccount(want: Want, accountId: number, callback: AsyncCallback\): void|Starts an ability with the execution result and account ID.|
+|startAbilityForResultWithAccount(want: Want, accountId: number, options?: StartOptions): Promise\|Starts an ability with the execution result and account ID.|
### Starting an Ability on the Same Device
An application can obtain the context of an `Ability` instance through `this.context` and then use the `startAbility` API in the `AbilityContext` class to start the ability. The ability can be started by specifying `Want`, `StartOptions`, and `accountId`, and the operation result can be returned using a callback or `Promise` instance. The sample code is as follows:
```ts
@@ -235,9 +235,8 @@ context.startAbility(want).then((data) => {
```
### Starting an Ability on a Remote Device
-This feature applies only to system applications, since the `getTrustedDeviceListSync` API of the `DeviceManager` class is open only to system applications.
+>This feature applies only to system applications, since the `getTrustedDeviceListSync` API of the `DeviceManager` class is open only to system applications.
In the cross-device scenario, you must specify the ID of the remote device. The sample code is as follows:
-
```ts
let context = this.context
var want = {
@@ -268,7 +267,7 @@ function getRemoteDeviceId() {
}
}
```
-Request the permission `ohos.permission.DISTRIBUTED_DATASYNC ` from consumers. This permission is used for data synchronization. For details about the sample code for requesting the permission, see [Requesting Permissions](##requesting-permissions).
+Request the permission `ohos.permission.DISTRIBUTED_DATASYNC` from consumers. This permission is used for data synchronization. For details about the sample code for requesting the permission, see [Requesting Permissions](##requesting-permissions).
### Starting an Ability with the Specified Page
If the launch type of an ability is set to `singleton` and the ability has been started, the `onNewWant` callback is triggered when the ability is started again. You can pass start options through the `want`. For example, to start an ability with the specified page, use the `uri` or `parameters` parameter in the `want` to pass the page information. Currently, the ability in the stage model cannot directly use the `router` capability. You must pass the start options to the custom component and invoke the `router` method to display the specified page during the custom component lifecycle management. The sample code is as follows:
diff --git a/en/application-dev/ability/stage-brief.md b/en/application-dev/ability/stage-brief.md
index 8d4ab32e671a3364776317f724d7ce51c218bfcf..0b4bfe8e3ec2943528e3bd2e8b640dea4ffbd070 100644
--- a/en/application-dev/ability/stage-brief.md
+++ b/en/application-dev/ability/stage-brief.md
@@ -1,6 +1,6 @@
# Stage Model Overview
-### Design Ideas
+## Design Ideas
The stage model is designed to make it easier to develop complex applications in the distributed environment.
@@ -20,10 +20,10 @@ The stage model is designed based on the following considerations:
- **Support for multiple device types and window forms**
- To support multiple device types and facilitate the implementation of different window forms, the component manager and window manager must be decoupled at the architecture layer for easier tailoring. To achieve this goal, the stage model redefines the ability lifecycle and implements unidirectional dependency of the component manager and window manager.
+ To support multiple device types and facilitate the implementation of different window forms, the component manager and window manager must be decoupled at the architecture layer for easier tailoring. To achieve this goal, the stage model redefines the ability lifecycle and implements unidirectional dependency for the component manager and window manager.
-### Basic Concepts
+## Basic Concepts
The following figure shows the basic concepts in the stage model.
@@ -33,24 +33,24 @@ The following figure shows the basic concepts in the stage model.
- **Bundle**: an OpenHarmony application identified by **appid**. A bundle can contain multiple HAP files. Each application has a **bundleName**. However, **bundleName** must be used together with **appid** and other information to uniquely identify an application.
- **AbilityStage**: runtime class of an HAP. It is created when the HAP is loaded to the process for the first time and is visible to developers in the runtime.
- **Application**: runtime class of a bundle, which is invisible to developers in the runtime.
-- **Context**: provides various capabilities that can be invoked by developers during the runtime. The **Ability** and **ExtensionAbility** classes have their own context classes, which inherit the base class **Context**. The base class provides information such as the bundle name, module name, and path.
-- **Ability**: provides lifecycle callback, holds the **AbilityContext** class, and supports component continuation and collaboration.
+- **Context**: base class that the context classes of **Ability** and **ExtensionAbility** classes inherit. This class provides various capabilities that can be invoked by developers in the runtime, and various information such as the bundle name, module name, and path.
+- **Ability**: class that provides lifecycle callbacks, holds the **AbilityContext** class, and supports component continuation and collaboration.
- **ExtensionAbility**: general name of scenario-based service extension abilities. The system defines multiple scenario-based **ExtensionAbility** classes, each of which has its own **ExtensionContext**.
- **WindowStage**: local window manager.
- **Window**: basic unit managed by the window manager. It has an ArkUI engine instance.
-- **ArkUI Page**: displays declarative ArkUI.
+- **ArkUI Page**: ArkUI development framework page.
-### Lifecycle
+## Lifecycle
-The ability and ability stage lifecycles are the most important concepts in the basic process of an application. The comparison between the FA model lifecycle and stage model lifecycle is provided in [Ability Framework Overview](ability-brief.md). This section focuses on the ability lifecycle transition and the scheduling relationships between the ability, ability stage, and window stage.
+The ability and ability stage lifecycles are the rudiments of the basic process of an application. For details about how these lifecycles differ from those in the FA model, see [Ability Framework Overview](ability-brief.md). This section focuses on the ability lifecycle transition and the scheduling relationships between the ability, ability stage, and window stage.

-To implement multi-device-form tailoring and multi-window scalability, OpenHarmony decouples the component manager from the window manager. The ability lifecycle defined in the stage model includes only the creation, destruction, foreground, and background states. The gain focus and lose focus states that are closely related to UI content are defined in the window stage. This implements weak coupling between the abilities and windows. On the service side, the window manager notifies the component manager of the foreground and background changes, so the component manager only senses the foreground and background changes but not the focus changes.
+To implement device-specific tailoring and multi-window scalability, OpenHarmony decouples the component manager from the window manager. The ability lifecycle defined in the stage model includes only the creation, destruction, foreground, and background states. The gain focus and lose focus states that are closely related to UI content are defined in the window stage. This implements weak coupling between the abilities and windows. On the service side, the window manager notifies the component manager of the foreground and background changes, so the component manager only senses the foreground and background changes but not the focus changes.
-### Ability Instances and Missions
+## Ability Instances and Missions
Abilities can be started in any of the following modes:
@@ -62,11 +62,11 @@ Abilities can be started in any of the following modes:
Each ability instance corresponds to a mission in **Launcher Recent**.
-The mission corresponding to each ability instance has a snapshot of the ability instance. After the ability instance is destroyed, the ability class information and snapshot are retained in the mission until the user deletes the information or the storage space exceeds the upper limit.
+The mission corresponding to an ability instance has a snapshot of the ability instance. After the ability instance is destroyed, the ability class information and snapshot are retained in the mission until the user deletes the information or the storage space reaches the upper limit.

-### ExtensionAbility Mechanism
+## ExtensionAbility Mechanism
Different from the ability used for page display, the extension ability provides a restricted service running environment. It has the following features:
@@ -82,9 +82,9 @@ The following figure uses the widget scenario as an example. You can inherit fro

-### Process Model
+## Process Model
-All OpenHarmony applications are designed to meet the single-process model. In the single-process model, an application is not allowed to configure multiple processes, and all processes in the application are created and managed by the system. Each application supports a maximum of three types of processes:
+All OpenHarmony applications are designed to meet the single-process model. In the single-process model, all processes in the application are created and managed by the system. Each application supports a maximum of three types of processes:
- Main process: runs all ability components, pages, and service logic.
diff --git a/en/application-dev/ability/stage-call.md b/en/application-dev/ability/stage-call.md
index 36efd3076702ef26c37cd304794ea2caf36e053d..e402454ddf6afd1b1aab71601e52b19d8010b425 100644
--- a/en/application-dev/ability/stage-call.md
+++ b/en/application-dev/ability/stage-call.md
@@ -18,11 +18,11 @@ The table below describes the ability call APIs. For details, see [Ability](../r
**Table 1** Ability call APIs
|API|Description|
|:------|:------|
-|startAbilityByCall(want: Want): Promise|Obtains the caller interface of the specified ability and, if the specified ability is not running, starts the ability in the background.|
+|startAbilityByCall(want: Want): Promise\|Obtains the caller interface of the specified ability and, if the specified ability is not running, starts the ability in the background.|
|on(method: string, callback: CaleeCallBack): void|Callback invoked when the callee registers a method.|
|off(method: string): void|Callback invoked when the callee deregisters a method.|
-|call(method: string, data: rpc.Sequenceable): Promise|Sends agreed sequenceable data to the callee.|
-|callWithResult(method: string, data: rpc.Sequenceable): Promise|Sends agreed sequenceable data to the callee and returns the agreed sequenceable data.|
+|call(method: string, data: rpc.Sequenceable): Promise\|Sends agreed sequenceable data to the callee.|
+|callWithResult(method: string, data: rpc.Sequenceable): Promise\|Sends agreed sequenceable data to the callee and returns the agreed sequenceable data.|
|release(): void|Releases the caller interface.|
|onRelease(callback: OnReleaseCallBack): void|Registers a callback that is invoked when the caller is disconnected.|
@@ -83,7 +83,7 @@ export default class MySequenceable {
```
4. Implement **Callee.on** and **Callee.off**.
- The time to register a listener for the callee depends on your application. The data sent and received before the listener is registered and that after the listener is deregistered are not processed. In the following example, the **CalleeSortMethod** listener is registered in **onCreate** of the ability and deregistered in **onDestroy**. After receiving sequenceable data, the application processes the data and returns the data result. You need to implement processing based on service requirements. The sample code snippet is as follows:
+ The time to register a listener for the callee depends on your application. The data sent and received before the listener is registered and that after the listener is deregistered are not processed. In the following example, the **MSG_SEND_METHOD** listener is registered in **onCreate** of the ability and deregistered in **onDestroy**. After receiving sequenceable data, the application processes the data and returns the data result. You need to implement processing based on service requirements. The sample code snippet is as follows:
```ts
const TAG: string = '[CalleeAbility]'
const MSG_SEND_METHOD: string = 'CallSendMsg'
@@ -148,7 +148,7 @@ async onButtonGetCaller() {
console.error(TAG + 'get caller failed with ' + error)
})
```
-In the cross-device scenario, you need to specify the ID of the peer device. The sample code snippet is as follows:
+ In the cross-device scenario, you need to specify the ID of the peer device. The sample code snippet is as follows:
```ts
let TAG = '[MainAbility] '
var caller = undefined
@@ -172,7 +172,7 @@ context.startAbilityByCall({
console.error(TAG + 'get remote caller failed with ' + error)
})
```
-Obtain the ID of the peer device from **DeviceManager**. Note that the **getTrustedDeviceListSync** API is open only to system applications. The sample code snippet is as follows:
+ Obtain the ID of the peer device from **DeviceManager**. Note that the **getTrustedDeviceListSync** API is open only to system applications. The sample code snippet is as follows:
```ts
import deviceManager from '@ohos.distributedHardware.deviceManager';
var dmClass;
@@ -190,7 +190,7 @@ function getRemoteDeviceId() {
}
}
```
-In the cross-device scenario, the application must also apply for the data synchronization permission from end users. The sample code snippet is as follows:
+ In the cross-device scenario, the application must also apply for the data synchronization permission from end users. The sample code snippet is as follows:
```ts
let context = this.context
let permissions: Array = ['ohos.permission.DISTRIBUTED_DATASYNC']
@@ -215,7 +215,7 @@ async onButtonCall() {
}
```
-In the following, **CallWithResult** is used to send data **originMsg** to the callee and assign the data processed by the **CallSendMsg** method to **backMsg**. The sample code snippet is as follows:
+ In the following, **CallWithResult** is used to send data **originMsg** to the callee and assign the data processed by the **CallSendMsg** method to **backMsg**. The sample code snippet is as follows:
```ts
const MSG_SEND_METHOD: string = 'CallSendMsg'
originMsg: string = ''
diff --git a/en/application-dev/ability/stage-formextension.md b/en/application-dev/ability/stage-formextension.md
index 24d704fbc193e9743cbb59792c48b18cd3e601ca..0a1b17b91cf2be48405e4e9681146f1017ffa93b 100644
--- a/en/application-dev/ability/stage-formextension.md
+++ b/en/application-dev/ability/stage-formextension.md
@@ -4,18 +4,16 @@
A widget is a set of UI components used to display important information or operations for an application. It provides users with direct access to a desired application service, without requiring them to open the application.
-A widget displays brief information about an application on the UI of another application (host application, currently system applications only) and provides basic interactive features such as opening a UI page or sending a message. The widget host is responsible for displaying the service widget.
+A widget displays brief information about an application on the UI of another application (host application, currently system applications only) and provides basic interactive functions such as opening a UI page or sending a message.
Basic concepts:
-- Widget provider
- The widget provider is an atomic service that provides the content to be displayed. It controls the display content, component layout, and component click events of a widget.
-- Widget host
- The widget host is an application that displays the widget content and controls the position where the widget is displayed in the host application.
-- Widget Manager
- The Widget Manager is a resident agent that manages widgets added to the system and provides functions such as periodic widget update.
+- Widget provider: an atomic service that controls what and how content is displayed in a widget and interacts with users.
+- Widget host: an application that displays the widget content and controls the position where the widget is displayed in the host application.
+- Widget Manager: a resident agent that manages widgets added to the system and provides functions such as periodic widget update.
->  **NOTE**
+> **NOTE**
+>
> The widget host and provider do not keep running all the time. The Widget Manager starts the widget provider to obtain widget information when a widget is added, deleted, or updated.
You only need to develop widget content as the widget provider. The system automatically handles the work done by the widget host and Widget Manager.
@@ -24,16 +22,16 @@ The widget provider controls the widget content to display, component layout, an
## When to Use
-Stage ability development refers to the development conducted by the widget provider based on the [stage model](stage-brief.md). As a widget provider, you need to carry out the following operations:
+Stage widget development refers to the development conducted by the widget provider based on the [stage model](stage-brief.md). As a widget provider, you need to carry out the following operations:
-- Develop the lifecycle callback functions in **FormExtension**.
-- Create a **FormBindingData** object.
+- Develop the lifecycle callbacks in **FormExtension**.
+- Create a **FormBindingData** instance.
- Update a widget through **FormProvider**.
- Develop the widget UI page.
## Available APIs
-The **FormExtension** class has the **context** attribute. For details on the APIs provided by the **FormExtension** class, see [FormExtension](../reference/apis/js-apis-formextension.md).
+The **FormExtension** class has the following APIs. For details, see [FormExtension](../reference/apis/js-apis-formextension.md).
**Table 1** FormExtension APIs
@@ -42,19 +40,19 @@ The **FormExtension** class has the **context** attribute. For details on the AP
| onCreate(want: Want): formBindingData.FormBindingData | Called to notify the widget provider that a **Form** instance (widget) has been created. |
| onCastToNormal(formId: string): void | Called to notify the widget provider that a temporary widget has been converted to a normal one.|
| onUpdate(formId: string): void | Called to notify the widget provider that a widget has been updated. |
-| onVisibilityChange(newStatus: { [key: string]: number }): void | Called to notify the widget provider of the change of widget visibility. |
-| onEvent(formId: string, message: string): void | Called to instruct the widget provider to receive and process the widget event. |
+| onVisibilityChange(newStatus: { [key: string]: number }): void | Called to notify the widget provider of the change in widget visibility. |
+| onEvent(formId: string, message: string): void | Called to instruct the widget provider to receive and process a widget event. |
| onDestroy(formId: string): void | Called to notify the widget provider that a **Form** instance (widget) has been destroyed. |
-| onConfigurationUpdated(config: Configuration): void; | Called when the configuration of the environment where the ability is running is updated. |
+| onConfigurationUpdated(config: Configuration): void; | Called when the configuration of the environment where the widget is running is updated. |
-The **context** attribute of the **FormExtension** class inherits from the **FormExtensionContext** class. For details about the APIs provided by the **FormExtensionContext** class, see [FormExtensionContext](../reference/apis/js-apis-formextensioncontext.md).
+The **FormExtension** class also has a member context, that is, the **FormExtensionContext** class. For details, see [FormExtensionContext](../reference/apis/js-apis-formextensioncontext.md).
**Table 2** FormExtensionContext APIs
| API | Description |
| :----------------------------------------------------------- | :------------------------ |
-| updateForm(formId: string, formBindingData: formBindingData.FormBindingData, callback: AsyncCallback\): void | Updates a widget. This method uses a callback to return the result. |
-| updateForm(formId: string, formBindingData: formBindingData.FormBindingData): Promise\ | Updates a widget. This method uses a promise to return the result.|
+| updateForm(formId: string, formBindingData: formBindingData.FormBindingData, callback: AsyncCallback\): void | Updates a widget. This API uses an asynchronous callback to return the result. |
+| updateForm(formId: string, formBindingData: formBindingData.FormBindingData): Promise\ | Updates a widget. This API uses a promise to return the result.|
For details about the **FormProvider** APIs, see [FormProvider](../reference/apis/js-apis-formprovider.md).
@@ -69,9 +67,9 @@ For details about the **FormProvider** APIs, see [FormProvider](../reference/api
## How to Develop
-### Creating a Form Extension
+### Creating a FormExtension Instance
-To create a widget in the stage model, you need to implement the lifecycle callback functions of **FormExtension**. The sample code is as follows:
+To create a widget in the stage model, implement the lifecycle callbacks of **FormExtension**. The sample code is as follows:
1. Import the required modules.
@@ -82,13 +80,13 @@ To create a widget in the stage model, you need to implement the lifecycle callb
import formProvider from '@ohos.application.formProvider'
```
-2. Implement the lifecycle callback functions of **FormExtension**.
+2. Implement the lifecycle callbacks of **FormExtension**.
```javascript
export default class FormAbility extends FormExtension {
onCreate(want) {
console.log('FormAbility onCreate');
- // Persistently store widget information for subsequent use, such as widget instance retrieval and update.
+ // Persistently store widget information for subsequent use, such as during widget instance retrieval or update.
let obj = {
"title": "titleOnCreate",
"detail": "detailOnCreate"
@@ -101,7 +99,7 @@ To create a widget in the stage model, you need to implement the lifecycle callb
console.log('FormAbility onCastToNormal');
}
onUpdate(formId) {
- // To support scheduled update, periodic update, or update requested by the widget host for a widget, override this method for data update.
+ // To support scheduled update, periodic update, or update requested by the widget host, override this method for widget data update.
console.log('FormAbility onUpdate');
let obj = {
"title": "titleOnUpdate",
@@ -130,24 +128,22 @@ To create a widget in the stage model, you need to implement the lifecycle callb
}
```
-### Configuring config.json for the Form Ability
+### Configuring the Widget Configuration File
-Configure the **module.json** file for the **Form** ability.
-
-- The internal field structure of the **extensionAbility** module is described as follows:
+- Configure Extension ability information under **extensionAbilities** in the **module.json5** file. The internal field structure is described as follows:
| Field | Description | Data Type | Default |
| ----------- | ------------------------------------------------------------ | ---------- | -------------------- |
- | name | Name of an extension ability. | String | No |
- | srcEntrance | JS code path of the extension ability. | String | No |
- | description | Description of the extension ability. The value can be a string or a resource index to descriptions in multiple languages.| String | Yes (initial value: left empty)|
- | icon | Index of the extension ability icon file. | String | Yes (initial value: left empty)|
- | label | Descriptive information about the extension ability presented externally. The value can be a string or a resource index to the description.| String | Yes (initial value: left empty)|
- | type | Type of the extension ability. The value can be **form** or **service**. | String | No |
+ | name | Name of the Extension ability. This field must be specified. | String | No |
+ | srcEntrance | Path of the Extension ability lifecycle code. This field must be specified.| String | No |
+ | description | Description of the Extension ability. The value can be a string or a resource index to descriptions in multiple languages.| String | Yes (initial value: left empty)|
+ | icon | Index of the Extension ability icon file. | String | Yes (initial value: left empty)|
+ | label | Descriptive information about the Extension ability presented externally. The value can be a string or a resource index to the description.| String | Yes (initial value: left empty)|
+ | type | Type of the Extension ability. In the current development scenario, set this field to **form**.| String | No |
| permissions | Permissions required for abilities of another application to call the current ability. | String array| Yes (initial value: left empty)|
- | metadata | Metadata of the extension ability. It describes the configuration information of the extension ability.| Object | Yes (initial value: left empty) |
+ | metadata | Metadata (configuration information) of the Extension ability.| Object | Yes (initial value: left empty) |
- For a Form Extension ability, set **type** to **form** and **metadata** to the widget details.
+ For a Form Extension ability, you must specify **metadata**. Specifically, set **name** to **ohos.extension.form** (fixed), and set **resource** to the index of the widget configuration information.
A configuration example is as follows:
@@ -165,25 +161,25 @@ Configure the **module.json** file for the **Form** ability.
}]
```
-- Configure the widget profile module. In the metadata of the Form Extension ability, the resource file path specified by **ohos.extension.form** must be used. For example, **$profile:form_config** means that **form_config.json** in the **resources/base/profile/** directory of the development view is used as the widget profile.
+- Configure the widget configuration information. **resource** in **metadata** specifies the index of the widget configuration information. For example, **$profile:form_config** means that **form_config.json** in the **resources/base/profile/** directory of the development view is used as the widget profile configuration file.
The internal field structure is described as follows:
| Field | Description | Data Type | Default |
| ------------------- | ------------------------------------------------------------ | ---------- | ------------------------ |
- | name | Class name of the widget. The value is a string with a maximum of 127 bytes. | String | No |
+ | name | Class name of a widget. The value is a string with a maximum of 127 bytes. | String | No |
| description | Description of the widget. The value can be a string or a resource index to descriptions in multiple languages. The value is a string with a maximum of 255 bytes.| String | Yes (initial value: left empty) |
| src | Full path of the UI code corresponding to the widget. | String | No |
| window | Window-related configurations. | Object | Yes |
| isDefault | Whether the widget is a default one. Each ability has only one default widget. **true**: The widget is the default one. **false**: The widget is not the default one.| Boolean | No |
| colorMode | Color mode of the widget. Available values are as follows: **auto**: The widget adopts the auto-adaptive color mode. **dark**: The widget adopts the dark color mode. **light**: The widget adopts the light color mode.| String | Yes (initial value: **auto**)|
- | supportDimensions | Grid styles supported by the widget. Available values are as follows: 1 * 2: indicates a grid with one row and two columns. 2 * 2: indicates a grid with two rows and two columns. 2 * 4: indicates a grid with two rows and four columns. 4 * 4: indicates a grid with four rows and four columns.| String array| No |
+ | supportDimensions | Grid styles supported by the widget. Available values are as follows: **1 * 2**: indicates a grid with one row and two columns. **2 * 2**: indicates a grid with two rows and two columns. **2 * 4**: indicates a grid with two rows and four columns. **4 * 4**: indicates a grid with four rows and four columns.| String array| No |
| defaultDimension | Default grid style of the widget. The value must be available in the **supportDimensions** array of the widget.| String | No |
- | updateEnabled | Whether the widget can be updated periodically. Available values are as follows: **true**: The widget can be updated periodically, depending on the update way you select, either at a specified interval (**updateDuration**) or at the scheduled time (**scheduledUpdateTime**). **updateDuration** is preferentially recommended. **false**: The widget cannot be updated periodically.| Boolean | No |
+ | updateEnabled | Whether the widget can be updated periodically. Available values are as follows: **true**: The widget can be updated periodically, depending on the update way you select, either at a specified interval (**updateDuration**) or at the scheduled time (**scheduledUpdateTime**). **updateDuration** is recommended. **false**: The widget cannot be updated periodically.| Boolean | No |
| scheduledUpdateTime | Scheduled time to update the widget. The value is in 24-hour format and accurate to minute. | String | Yes (initial value: **0:0**) |
| updateDuration | Interval to update the widget. The value is a natural number, in the unit of 30 minutes. If the value is **0**, this field does not take effect. If the value is a positive integer ***N***, the interval is calculated by multiplying ***N*** and 30 minutes.| Number | Yes (initial value: **0**) |
| formConfigAbility | Link to a specific page of the application. The value is a URI. | String | Yes (initial value: left empty) |
- | formVisibleNotify | Whether the widget is allowed to use the widget visibility notification. | String | Yes (initial value: left empty) |
+ | formVisibleNotify | Whether the widget is allowed to use the widget visibility notification. | String | Yes (initial value: left empty) |
| metaData | Metadata of the widget. This field contains the array of the **customizeData** field. | Object | Yes (initial value: left empty) |
A configuration example is as follows:
@@ -192,7 +188,7 @@ Configure the **module.json** file for the **Form** ability.
{
"forms": [{
"name": "widget",
- "description": "This is a service widget.",
+ "description": "This is a widget.",
"src": "./js/widget/pages/index/index",
"window": {
"autoDesignWidth": true,
@@ -211,9 +207,9 @@ Configure the **module.json** file for the **Form** ability.
```
-### Widget Data Persistence
+### Persistently Storing Widget Data
-Mostly, the widget provider is started only when it needs to obtain information about a widget. The Widget Manager supports multi-instance management and uses the widget ID to identify an instance. If the widget provider supports widget data modification, it must persistently store the data based on the widget ID, so that it can access the data of the target widget when obtaining, updating, or starting a widget.
+Mostly, the widget provider is started only when it needs to obtain information about a widget. The Widget Manager supports multi-instance management and uses the widget ID to identify an instance. If the widget provider supports widget data modification, it must persistently store the data based on the widget ID, so that it can access the data of the target widget when obtaining, updating, or starting the widget.
```javascript
onCreate(want) {
@@ -222,7 +218,8 @@ Mostly, the widget provider is started only when it needs to obtain information
let formId = want.parameters["ohos.extra.param.key.form_identity"];
let formName = want.parameters["ohos.extra.param.key.form_name"];
let tempFlag = want.parameters["ohos.extra.param.key.form_temporary"];
- // Persistently store widget information for subsequent use, such as widget instance retrieval and update.
+ // Persistently store widget data for subsequent use, such as widget instance retrieval and update.
+ // The storeFormInfo API is not implemented here. For details about the implementation, see "Samples" below.
storeFormInfo(formId, formName, tempFlag, want);
let obj = {
@@ -238,9 +235,11 @@ You should override **onDestroy** to delete widget data.
```javascript
onDestroy(formId) {
- // Delete widget data.
- deleteFormInfo(formId);
console.log('FormAbility onDestroy');
+
+ // You need to implement the code for deleting the persistent widget data.
+ // The deleteFormInfo API is not implemented here. For details about the implementation, see "Samples" below.
+ deleteFormInfo(formId);
}
```
@@ -248,16 +247,37 @@ For details about the persistence method, see [Lightweight Data Store Developmen
Note that the **Want** passed by the widget host to the widget provider contains a temporary flag, indicating whether the requested widget is a temporary one.
-Normal widget: a widget that will be persistently used by the widget host
+- Normal widget: a widget that will be persistently used by the widget host
+
+- Temporary widget: a widget that is temporarily used by the widget host
+
+Data of a temporary widget is not persistently stored. If it is deleted from the Widget Manager due to exceptions, such as crash of the widget framework, the widget provider will not be notified of which widget is deleted, and still keeps the data. In light of this, the widget provider should implement data clearing. If the widget host successfully converts a temporary widget into a normal one, the widget provider should also process the widget ID and store the data persistently. This prevents the widget provider from deleting the widget data when clearing temporary widgets.
-Temporary widget: a widget that is temporarily used by the widget host
+### Updating Widget Data
-Data of a temporary widget is not persistently stored. If the widget framework is killed and restarted, data of a temporary widget will be deleted. However, the widget provider is not notified of which widget is deleted, and still keeps the data. Therefore, the widget provider should implement data clearing. In addition, the widget host may convert a temporary widget into a normal one. If the conversion is successful, the widget provider should process the widget ID and store the data persistently. This prevents the widget provider from deleting persistent data when clearing temporary widgets.
+When a widget application initiates a data update upon a scheduled or periodic update, the application obtains the latest data and calls **updateForm** to update the widget. The sample code is as follows:
+
+```javascript
+onUpdate(formId) {
+ // To support scheduled update, periodic update, or update requested by the widget host, override this method for widget data update.
+ console.log('FormAbility onUpdate');
+ let obj = {
+ "title": "titleOnUpdate",
+ "detail": "detailOnUpdate"
+ };
+ let formData = formBindingData.createFormBindingData(obj);
+ // Call the updateForm method to update the widget. Only the data passed through the input parameter is updated. Other information remains unchanged.
+ formProvider.updateForm(formId, formData).catch((error) => {
+ console.log('FormAbility updateForm, error:' + JSON.stringify(error));
+ });
+}
+```
### Developing the Widget UI Page
+
You can use HML, CSS, and JSON to develop the UI page for a JavaScript-programmed widget.
->  **NOTE**
+>  **NOTE**
> Currently, only the JavaScript-based web-like development paradigm can be used to develop the widget UI.
- hml:
@@ -339,10 +359,7 @@ Now you've got a widget shown below.

-## Development Example
+## Samples
The following sample is provided to help you better understand how to develop a widget on the stage model:
-
-[FormExtAbility](https://gitee.com/openharmony/app_samples/tree/master/ability/FormExtAbility)
-
-Users can create, update, and delete widgets on the home screen of their devices or by using their own widget host. This sample also implements widget information persistence by using lightweight data storage.
\ No newline at end of file
+- [`FormExtAbility`: Stage Model Widget (eTS, JS, API version 9)](https://gitee.com/openharmony/app_samples/tree/master/ability/FormExtAbility)
diff --git a/en/application-dev/ability/stage-serviceextension.md b/en/application-dev/ability/stage-serviceextension.md
index fd91ba285e8a54e58e519ef29c3a055b867a6745..c6f6362a727855189a398b6b305312c45e6135b1 100644
--- a/en/application-dev/ability/stage-serviceextension.md
+++ b/en/application-dev/ability/stage-serviceextension.md
@@ -1,85 +1,75 @@
# Service Extension Ability Development
## When to Use
-**ExtensionAbility** is the base class of new **Extension** components in the stage model. It is used to process jobs without UIs. The lifecycle of **ExtensionAbility** is simple and does not involve foreground or background. **ServiceExtensionAbility** is extended from **ExtensionAbility**.
+**ExtensionAbility** is the base class of the new Extension component in the stage model. It is used to process missions without UIs. The lifecycle of an Extension ability is simple and does not involve foreground or background states. **ServiceExtensionAbility** is extended from **ExtensionAbility**.
-You can customize a class that inherits from **ServiceExtensionAbility** and override the lifecycle callbacks of **ExtensionAbility** to perform service logic operations during the initialization, connection, and disconnection processes.
+You can customize a class that inherits from **ServiceExtensionAbility** and override the lifecycle callbacks in the base class to perform service logic operations during the initialization, connection, and disconnection processes.
## Available APIs
-**Table 1** ServiceExtensionAbility lifecycle callbacks
+**Table 1** ServiceExtensionAbility lifecycle APIs
|API|Description|
|:------|:------|
-|onCreate|Called for the initialization when **startAbility** or **connectAbility** is invoked for a given ability for the first time.|
-|onRequest|Called each time **startAbility** is invoked for a given ability. The initial value of **startId** is 1, and the value is incremented by one each time **startAbility** is invoked for that ability.|
-|onConnect|Called when **connectAbility** is invoked for a given ability. This callback is not invoked for repeated calling of **connectAbility** for a specific ability. However, it will be invoked when **disconnectAbility** is called to disconnect an ability and then **connectAbility** is called to connect the ability again. The returned result is a **RemoteObject**.|
-|onDisconnect|Called when **disconnectAbility** is called for a given ability. If the Extension ability is started by **connectAbility** and is not bound by other applications, the **onDestroy** callback will also be triggered to destroy the Extension ability.|
-|onDestroy|Called when **terminateSelf** is invoked to terminate the ability.|
+|onCreate(want: Want): void|Called for the initialization when **startAbility** or **connectAbility** is invoked for a given ability for the first time.|
+|onRequest(want: Want, startId: number): void|Called each time **startAbility** is invoked for a given ability. The initial value of **startId** is **1**, and the value is incremented by one each time **startAbility** is invoked for that ability.|
+|onConnect(want: Want): rpc.RemoteObject|Called when **connectAbility** is invoked for a given ability. This callback is not invoked for repeated calling of **connectAbility** for a specific ability. However, it will be invoked unless **connectAbility** is called after the ability has been disconnected using **disconnectAbility**. The returned result is a **RemoteObject**.|
+|onDisconnect(want: Want): void|Called when **disconnectAbility** is called for a given ability. If the Extension ability is started by **connectAbility** and is not bound to other applications, the **onDestroy** callback will also be triggered to destroy the Extension ability.|
+|onDestroy(): void|Called when **terminateSelf** is invoked to terminate the ability.|
## Constraints
-- Currently, OpenHarmony does not support creation of a **ServiceExtensionAbility** for third-party applications.
+OpenHarmony does not support creation of a Service Extension ability for third-party applications.
## How to Develop
-1. Create a Service Extension ability.
+1. Declare the Service Extension ability in the **module.json** file by setting its **type** attribute to **service**. The following is a configuration example of the **module.json** file:
-Customize a class that inherits from **ServiceExtensionAbility** in the .ts file and override the lifecycle callbacks of the base class. The code sample is as follows:
- ```js
- import rpc from '@ohos.rpc'
- class StubTest extends rpc.RemoteObject {
- constructor(des) {
- super(des);
- }
- onRemoteRequest(code, data, reply, option) {
- }
- }
-
- class ServiceExt extends ServiceExtensionAbility {
- onCreate(want) {
- console.log('onCreate, want:' + want.abilityName);
- }
- onRequest(want, startId) {
- console.log('onRequest, want:' + want.abilityName);
- }
- onConnect(want) {
- console.log('onConnect , want:' + want.abilityName);
- return new StubTest("test");
- }
- onDisconnect(want) {
- console.log('onDisconnect, want:' + want.abilityName);
- }
- onDestroy() {
- console.log('onDestroy');
- }
- }
- ```
-
-
-2. Register the Service Extension ability.
-
-Declare the Service Extension ability in the **module.json** file by setting its **type** attribute to **service**.
+ ```json
+ "extensionAbilities":[{
+ "name": "ServiceExtAbility",
+ "icon": "$media:icon",
+ "description": "service",
+ "type": "service",
+ "visible": true,
+ "srcEntrance": "./ets/ServiceExtAbility/ServiceExtAbility.ts"
+ }]
+ ```
-**module.json configuration example**
-```json
-"extensionAbilities":[{
- "name": "ServiceExtAbility",
- "icon": "$media:icon",
- "description": "service",
- "type": "service",
- "visible": true,
- "srcEntrance": "./ets/ServiceExtAbility/ServiceExtAbility.ts"
-}]
-```
+2. Customize a class that inherits from **ServiceExtensionAbility** in the .ts file in the directory where the Service Extension ability is defined and override the lifecycle callbacks of the base class. The code sample is as follows:
-## Development Example
-
-The following sample is provided to help you better understand how to develop a Service Extension ability:
+ ```js
+ import rpc from '@ohos.rpc'
+ class StubTest extends rpc.RemoteObject {
+ constructor(des) {
+ super(des);
+ }
+ onRemoteRequest(code, data, reply, option) {
+ }
+ }
-- [ServiceExtensionAbility](https://gitee.com/openharmony/app_samples/tree/master/ability/ServiceExtAbility)
+ class ServiceExt extends ServiceExtensionAbility {
+ console.log('onCreate, want:' + want.abilityName);
+ }
+ onRequest(want, startId) {
+ console.log('onRequest, want:' + want.abilityName);
+ }
+ onConnect(want) {
+ console.log('onConnect , want:' + want.abilityName);
+ return new StubTest("test");
+ }
+ onDisconnect(want) {
+ console.log('onDisconnect, want:' + want.abilityName);
+ }
+ onDestroy() {
+ console.log('onDestroy');
+ }
+ }
+ ```
+## Samples
-This sample will guide you through creating a Service Extension ability in the **ServiceExtAbility.ts** file in the **ServiceExtensionAbility** directory.
\ No newline at end of file
+The following sample is provided to help you better understand how to develop Service Extension abilities:
+- [`ServiceExtAbility`: Stage Extension Ability Creation and Usage (eTS, API version 9)](https://gitee.com/openharmony/app_samples/tree/master/ability/StageCallAbility)
diff --git a/en/application-dev/ability/wantagent.md b/en/application-dev/ability/wantagent.md
index 013c2010966a891debdc080bd6b1390a19f5537d..eacc92936960cca3bd022e6438a63c15a8f2688a 100644
--- a/en/application-dev/ability/wantagent.md
+++ b/en/application-dev/ability/wantagent.md
@@ -1,73 +1,86 @@
# WantAgent Development
+## When to Use
+The **WantAgent** class encapsulates want information that specifies a particular action, which can be starting an ability or publishing a common event. You can either call **wantAgent.trigger** to trigger a **WantAgent** directly or add a **WantAgent** to a notification so that it will be triggered when users tap the notification.
-### Introduction
-The **WantAgent** class encapsulates a **Want** object that specifies a particular action. You can trigger a **WantAgent** by calling **wantAgent.trigger** directly or by adding it to a notification so that it is triggered when a user taps the notification.
-
-You can use a **WantAgent** in a notification to start an ability or publish a common event.
-
-### When to Use
-Start another ability through a **WantAgent**.
-
-### Available APIs
+## Available APIs
| API | Description|
| ---------------------------------------------------------------------------------------------- | ----------- |
-| wantAgent.getWantAgentInfo(info: WantAgentInfo, callback: AsyncCallback\) | Creates a **WantAgent** object. This API uses an asynchronous callback to return the result.|
-| wantAgent.getWantAgent(info: WantAgentInfo): Promise\; | Creates a **WantAgent** object. This API uses a promise to return the result.|
-| commonEvent.trigger(agent: WantAgent, triggerInfo: TriggerInfo, callback?: Callback\) | Triggers a **WantAgent**.|
+| getWantAgentInfo(info: WantAgentInfo, callback: AsyncCallback\) | Creates a **WantAgent** object. This API uses an asynchronous callback to return the result.|
+| getWantAgent(info: WantAgentInfo): Promise\ | Creates a **WantAgent** object. This API uses a promise to return the result.|
+| trigger(agent: WantAgent, triggerInfo: TriggerInfo, callback?: Callback\) | Triggers a **WantAgent** object.|
-### How to Develop
+## How to Develop
1. Import the **WantAgent** module.
-```javascript
-import wantAgent from '@ohos.wantAgent';
-```
+ ```
+ import wantAgent from '@ohos.wantAgent';
+ ```
+
+2. Create a **WantAgentInfo** object that will be used for starting an ability. For details about the data types and parameters of **WantAgentInfo**, see [WantAgent](../reference/apis/js-apis-wantAgent.md#wantagentinfo).
-2. Create a **WantAgentInfo** object. For details about the data types and parameters of **WantAgentInfo**, see [WantAgent Module](../reference/apis/js-apis-wantAgent.md#wantagentinfo).
+ ```
+ private wantAgentObj = null // Save the WantAgent object created. It will be used to complete the trigger operations.
+
+ //wantAgentInfo
+ var wantAgentInfo = {
+ wants: [
+ {
+ deviceId: "",
+ bundleName: "com.example.test",
+ abilityName: "com.example.test.MainAbility",
+ action: "",
+ entities: [],
+ uri: "",
+ parameters: {}
+ }
+ ],
+ operationType: wantAgent.OperationType.START_ABILITY,
+ requestCode: 0,
+ wantAgentFlags:[wantAgent.WantAgentFlags.CONSTANT_FLAG]
+ }
+ ```
-```javascript
-private wantAgentObj = null // Save the WantAgent object created. It will be used to complete the trigger operations.
+3. Create a **WantAgentInfo** object for publishing a common event.
-//wantAgentInfo
-var wantAgentInfo = {
- wants: [
- {
- deviceId: "",
- bundleName: "com.example.test",
- abilityName: "com.example.test.MainAbility",
- action: "",
- entities: [],
- uri: "",
- parameters: {}
- }
- ],
- operationType: OperationType.START_ABILITY,
- requestCode: 0,
- wantAgentFlags:[WantAgentFlags.CONSTANT_FLAG]
-}
-```
+ ```
+ private wantAgentObj = null // Save the WantAgent object created. It will be used to complete the trigger operations.
+
+ //wantAgentInfo
+ var wantAgentInfo = {
+ wants: [
+ {
+ action: "event_name", // Set the action name.
+ parameters: {}
+ }
+ ],
+ operationType: wantAgent.OperationType.SEND_COMMON_EVENT,
+ requestCode: 0,
+ wantAgentFlags:[wantAgent.WantAgentFlags.CONSTANT_FLAG]
+ }
+ ```
-3. Create a **WantAgent** object and save the returned **wantAgentObj** for subsequent trigger operations.
+4. Create a **WantAgent** object and save the returned **wantAgentObj** for subsequent trigger operations.
-```javascript
-// Create a WantAgent object.
-wantAgent.getWantAgent(wantAgentInfo, (err, wantAgentObj) => {
- if (err.code) {
- console.error("[WantAgent]getWantAgent err=" + JSON.stringify(err))
- } else {
- console.log("[WantAgent]getWantAgent success")
- this.wantAgentObj = wantAgentObj
- }
-})
-```
+ ```
+ // Create a WantAgent object.
+ wantAgent.getWantAgent(wantAgentInfo, (err, wantAgentObj) => {
+ if (err.code) {
+ console.error("[WantAgent]getWantAgent err=" + JSON.stringify(err))
+ } else {
+ console.log("[WantAgent]getWantAgent success")
+ this.wantAgentObj = wantAgentObj
+ }
+ })
+ ```
-4. Trigger the **WantAgent**.
+5. Trigger the **WantAgent** object.
-```
-// Trigger the WantAgent.
-var triggerInfo = {
- code:0
-}
-wantAgent.trigger(wantAgentObj, triggerInfo, (completeData) => {
- console.log("[WantAgent]getWantAgent success, completeData: ", + JSON.stringify(completeData))
-})
-```
\ No newline at end of file
+ ```
+ // Trigger the WantAgent object.
+ var triggerInfo = {
+ code:0
+ }
+ wantAgent.trigger(wantAgentObj, triggerInfo, (completeData) => {
+ console.log("[WantAgent]getWantAgent success, completeData: ", + JSON.stringify(completeData))
+ })
+ ```
diff --git a/en/application-dev/application-dev-guide-for-gitee.md b/en/application-dev/application-dev-guide-for-gitee.md
index d626a1975edf7c74ab34a45016f1702f1db4226e..753b706605487dbe2cf5ebe0ce961b19d94e7ee0 100644
--- a/en/application-dev/application-dev-guide-for-gitee.md
+++ b/en/application-dev/application-dev-guide-for-gitee.md
@@ -24,18 +24,21 @@ First thing first, familiarize yourself with the two cornerstone frameworks in O
All applications should be developed on top of these frameworks.
Then, equip yourself for developing the key features, with the following guidelines:
+- [Common Event and Notification](notification/Readme-EN.md)
- [Window Manager](windowmanager/Readme-EN.md)
- [WebGL](webgl/Readme-EN.md)
- [Media](media/Readme-EN.md)
- [Security](security/Readme-EN.md)
- [Connectivity](connectivity/Readme-EN.md)
+- [Telephony](telephony/Readme-EN.md)
- [Data Management](database/Readme-EN.md)
-- [Agent-Powered Scheduled Reminders](background-agent-scheduled-reminder/Readme-EN.md)
-- [Background Task Management](background-task-management/Readme-EN.md)
+- [Task Management](task-management/Readme-EN.md)
- [Device Management](device/Readme-EN.md)
- [Device Usage Statistics](device-usage-statistics/Readme-EN.md)
- [DFX](dfx/Readme-EN.md)
- [Internationalization](internationalization/Readme-EN.md)
+- [IDL Specifications and User Guide](IDL/idl-guidelines.md)
+- [Using Native APIs in Application Projects](napi/Readme-EN.md)
### Tools
diff --git a/en/application-dev/application-dev-guide.md b/en/application-dev/application-dev-guide.md
index d79d1af7c2e0fd6a2fe6920b6e729957abe0ed4e..c07f787d38091637215907537e54812c397a417e 100644
--- a/en/application-dev/application-dev-guide.md
+++ b/en/application-dev/application-dev-guide.md
@@ -24,14 +24,15 @@ First thing first, familiarize yourself with the two cornerstone frameworks in O
All applications should be developed on top of these frameworks.
Then, equip yourself for developing the key features, with the following guidelines:
+- [Common Event and Notification](notification/notification-brief.md)
- [Window Manager](windowmanager/window-overview.md)
- [WebGL](webgl/webgl-overview.md)
- [Media](media/audio-overview.md)
- [Security](security/userauth-overview.md)
- [Connectivity](connectivity/ipc-rpc-overview.md)
+- [Telephony](telephony/telephony-overview.md)
- [Data Management](database/database-mdds-overview.md)
-- [Agent-Powered Scheduled Reminders](background-agent-scheduled-reminder/background-agent-scheduled-reminder-overview.md)
-- [Background Task Management](background-task-management/background-task-overview.md)
+- [Task Management](task-management/background-task-overview.md)
- [Device](device/usb-overview.md)
- [Device Usage Statistics](device-usage-statistics/device-usage-statistics-overview.md)
- [DFX](dfx/hiappevent-overview.md)
diff --git a/en/application-dev/background-agent-scheduled-reminder/Readme-EN.md b/en/application-dev/background-agent-scheduled-reminder/Readme-EN.md
deleted file mode 100644
index c7c039ce8a141b630356284bb32031b376b7a394..0000000000000000000000000000000000000000
--- a/en/application-dev/background-agent-scheduled-reminder/Readme-EN.md
+++ /dev/null
@@ -1,5 +0,0 @@
-# Agent-Powered Scheduled Reminder
-
-- [Agent-Powered Scheduled Reminder Overview](background-agent-scheduled-reminder-overview.md)
-- [Agent-Powered Scheduled Reminder Development](background-agent-scheduled-reminder-guide.md)
-
diff --git a/en/application-dev/background-task-management/Readme-EN.md b/en/application-dev/background-task-management/Readme-EN.md
deleted file mode 100644
index d645314bfff65a72f1c6ff7efdb678e1b11753b4..0000000000000000000000000000000000000000
--- a/en/application-dev/background-task-management/Readme-EN.md
+++ /dev/null
@@ -1,4 +0,0 @@
-# Background Task Management
-
-- [Background Task Management Overview](background-task-overview.md)
-- [Background Task Management Development](background-task-dev-guide.md)
\ No newline at end of file
diff --git a/en/application-dev/connectivity/ipc-rpc-development-guideline.md b/en/application-dev/connectivity/ipc-rpc-development-guideline.md
index 03019858805cff17ef97b4c7227ee5c86947536b..3d541e4832aa72a585972d327e2fb2f31a077fa6 100644
--- a/en/application-dev/connectivity/ipc-rpc-development-guideline.md
+++ b/en/application-dev/connectivity/ipc-rpc-development-guideline.md
@@ -133,13 +133,13 @@ IPC/RPC enables a proxy and a stub that run on different processes to communicat
```
// Register the TestAbilityStub instance with the SystemAbilityManager on the same device as the SA.
auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
- samgr->AddSystemAbility(said, new TestAbility());
+ samgr->AddSystemAbility(saId, new TestAbility());
// Register the TestAbilityStub instance with the SystemAbilityManager on a different device.
auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
ISystemAbilityManager::SAExtraProp saExtra;
saExtra.isDistributed = true; // Set a distributed SA.
- int result = samgr->AddSystemAbility(said, new TestAbility(), saExtra);
+ int result = samgr->AddSystemAbility(saId, new TestAbility(), saExtra);
```
6. Obtain the SA.
@@ -149,12 +149,12 @@ IPC/RPC enables a proxy and a stub that run on different processes to communicat
```
// Obtain the proxy of the SA registered on the local device.
sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
- sptr remoteObject = samgr->GetSystemAbility(said);
+ sptr remoteObject = samgr->GetSystemAbility(saId);
sptr testAbility = iface_cast(remoteObject); // Use the iface_cast macro to convert the proxy to a specific type.
// Obtain the proxies of the SAs registered with other devices.
sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
- sptr remoteObject = samgr->GetSystemAbility(sdid, deviceId); // deviceId identifies a device.
+ sptr remoteObject = samgr->GetSystemAbility(saId, deviceId); // deviceId identifies a device.
sptr proxy(new TestAbilityProxy(remoteObject)); // Construct a proxy.
```
diff --git a/en/application-dev/database/database-distributedobject-guidelines.md b/en/application-dev/database/database-distributedobject-guidelines.md
index 86392551501483b40e69ce3fdcad0e3c5f71e92c..baf12a5741e2186ab57aeb5feb1acb534fa4651a 100644
--- a/en/application-dev/database/database-distributedobject-guidelines.md
+++ b/en/application-dev/database/database-distributedobject-guidelines.md
@@ -13,62 +13,107 @@ Call **createDistributedObject()** to create a distributed data object instance.
**Table 1** API for creating a distributed data object instance
- | Package | API | Description |
- | -------- | -------- | -------- |
- | ohos.data.distributedDataObject | createDistributedObject(source: object): DistributedObject | Creates a distributed data object instance for data operations. - **source**: attributes of the **distributedObject** set. - **DistributedObject**: returns the distributed object created. |
+| Package| API| Description|
+| -------- | -------- | -------- |
+| ohos.data.distributedDataObject| createDistributedObject(source: object): DistributedObject | Creates a distributed data object instance for data operations. - **source**: attributes of the **distributedObject** set. - **DistributedObject**: returns the distributed object created.|
### Generating a Session ID
Call **genSessionId()** to generate a session ID randomly. The generated session ID can be used to set the session ID of a distributed data object.
**Table 2** API for generating a session ID randomly
- | Package | API | Description |
- | -------- | -------- | -------- |
- | ohos.data.distributedDataObject | genSessionId(): string | Generates a session ID, which can be used as the session ID of a distributed data object. |
+| Package| API| Description|
+| -------- | -------- | -------- |
+| ohos.data.distributedDataObject| genSessionId(): string | Generates a session ID, which can be used as the session ID of a distributed data object.|
### Setting a SessionID for Distributed Data Objects
Call **setSessionId()** to set a session ID for a distributed data object. The session ID is a unique identifier for one collaboration across devices. The distributed data objects to be synchronized must be associated with the same session ID.
**Table 3** API for setting a session ID
- | Class | API | Description |
- | -------- | -------- | -------- |
- | DistributedDataObject | setSessionId(sessionId?: string): boolean | Sets a session ID for distributed data objects. **sessionId**: session ID of a distributed object in a trusted network. To remove a distributed data object from the network, set this parameter to "" or leave it empty. |
+| Class| API| Description|
+| -------- | -------- | -------- |
+| DistributedDataObject | setSessionId(sessionId?: string): boolean | Sets a session ID for distributed data objects. **sessionId**: session ID of a distributed object in a trusted network. To remove a distributed data object from the network, set this parameter to "" or leave it empty.|
### Observing Data Changes
Call **on()** to subscribe to data changes of a distributed data object. When the data changes, a callback will be invoked to return the data changes. You can use **off()** to unsubscribe from the data changes.
**Table 4** APIs for observing data changes of a distributed data object
- | Class | API | Description |
- | -------- | -------- | -------- |
- | DistributedDataObject | on(type: 'change', callback: Callback<{ sessionId: string, fields: Array<string> }>): void | Subscribes to data changes. |
- | DistributedDataObject | off(type: 'change', callback?: Callback<{ sessionId: string, fields: Array<string> }>): void | Unsubscribes from data changes. **Callback**: specifies callback used to return changes of the distributed data object. If this parameter is not specified, all callbacks related to data changes will be unregistered. |
+| Class| API| Description|
+| -------- | -------- | -------- |
+| DistributedDataObject| on(type: 'change', callback: Callback<{ sessionId: string, fields: Array<string> }>): void | Subscribes to data changes.|
+| DistributedDataObject| off(type: 'change', callback?: Callback<{ sessionId: string, fields: Array<string> }>): void | Unsubscribes from data changes. **Callback**: specifies callback used to return changes of the distributed data object. If this parameter is not specified, all callbacks related to data changes will be unregistered.|
### Observing Online or Offline Status
Call **on()** to subscribe to status changes of a distributed data object. The status can be online or offline. When the status changes, a callback will be invoked to return the status. You can use **off()** to unsubscribe from the status changes.
**Table 5** APIs for observing status changes of a distributed data object
- | Class | API | Description |
- | -------- | -------- | -------- |
- | DistributedDataObject | on(type: 'status', callback: Callback<{ sessionId: string, networkId: string, status: 'online' \ | 'offline' }>): void | Subscribes to the status changes of a distributed data object. |
- | DistributedDataObject | off(type: 'status', callback?: Callback<{ sessionId: string, deviceId: string, status: 'online' \ | 'offline' }>): void | Unsubscribes from status changes of a distributed data object. |
+| Class| API| Description|
+| -------- | -------- | -------- |
+| DistributedDataObject| on(type: 'status', callback: Callback<{ sessionId: string, networkId: string, status: 'online' \| 'offline' }>): void | Subscribes to the status changes of a distributed data object.|
+| DistributedDataObject| off(type: 'status', callback?: Callback<{ sessionId: string, deviceId: string, status: 'online' \| 'offline' }>): void | Unsubscribes from status changes of a distributed data object.|
+### Saving a Distributed Data Object and Revoking the Data Saving Operation
+Call **save()** to save a distributed data object. When the application is active, the saved data will not be released. When the application exits and restarts, the data saved on the device will be restored.
+
+Call **revokeSave()** to revoke a distributed data object that is no longer required. If the distributed data object is saved on the local device, **revokeSave()** will delete the data from all trusted devices. If the distributed data object is not saved on the local device, **revokeSave()** will delete the data from the local device.
+
+The saved data will be released in the following cases:
+
+- The data is stored for more than 24 hours.
+- The application has been uninstalled.
+- Data is successfully restored.
+
+**Table 6** APIs for saving a distributed data object and revoking the saving
+| Class| API| Description|
+| -------- | -------- | -------- |
+| DistributedDataObject | save(deviceId: string): Promise<SaveSuccessResponse> | Saves a distributed data object. This API uses a promise to return the result.|
+| DistributedDataObject| save(deviceId: string, callback: AsyncCallback<SaveSuccessResponse>): void | Saves a distributed data object. This API uses an asynchronous callback to return the result.|
+| DistributedDataObject | revokeSave(callback: AsyncCallback<RevokeSaveSuccessResponse>): void | Revokes the data saving operation. This API uses an asynchronous callback to return the result. |
+| DistributedDataObject| revokeSave(): Promise<RevokeSaveSuccessResponse> | Revokes the data saving operation. This API uses a promise to return the result. |
## How to Develop
The following example shows how to implement a distributed data object synchronization.
1. Import the @ohos.data.distributedDataObject module to the development environment.
-
- ```js
- import distributedObject from '@ohos.data.distributedDataObject'
+ ```js
+ import distributedObject from '@ohos.data.distributedDataObject';
```
+2. Request the permission. Add the required permission in the **config.json** file. The sample code is as follows:
+ ```
+ {
+ "module": {
+ "reqPermissions": [
+ {
+ "name": "ohos.permission.DISTRIBUTED_DATASYNC"
+ }
+ ]
+ }
+ }
+ ```
+ This permission must also be authorized by the user through a dialog box when the application is started for the first time. The sample code is as follows:
+ ```js
+ import featureAbility from '@ohos.ability.featureAbility';
+
+ function grantPermission() {
+ console.info('grantPermission');
+ let context = featureAbility.getContext();
+ context.requestPermissionsFromUser(['ohos.permission.DISTRIBUTED_DATASYNC'], 666, function (result) {
+ console.info(`result.requestCode=${result.requestCode}`)
+
+ })
+ console.info('end grantPermission');
+ }
+ grantPermission();
+ ```
-2. Obtain a distributed data object instance.
+3. Obtain a distributed data object instance.
+ The sample code is as follows:
```js
var local_object = distributedObject.createDistributedObject({name:undefined, age:undefined, isVis:true,
parent:undefined, list:undefined});
@@ -76,7 +121,9 @@ The following example shows how to implement a distributed data object synchroni
```
-3. Add the synchronization network. The data objects in the synchronization network include the local and remote objects.
+4. Add the synchronization network. The data objects in the synchronization network include the local and remote objects.
+
+ The sample code is as follows:
```js
// Local object
@@ -91,8 +138,10 @@ The following example shows how to implement a distributed data object synchroni
// After learning that the device goes online, the remote object synchronizes data. That is, name changes to jack and age to 18.
```
-4. Observe the data changes of the distributed data object. You can subscribe to data changes of the remote object. When the data in the remote object changes, a callback will be called to return the data changes.
-
+5. Observe the data changes of the distributed data object. You can subscribe to data changes of the peer object. When the data in the peer object changes, a callback will be called to return the data changes.
+
+ The sample code is as follows:
+
```js
function changeCallback(sessionId, changeData) {
console.info("change" + sessionId);
@@ -103,13 +152,14 @@ The following example shows how to implement a distributed data object synchroni
});
}
}
-
+
// To refresh the page in changeCallback, correctly bind (this) to the changeCallback.
local_object.on("change", this.changeCallback.bind(this));
```
-5. Modify object attributes. The object attributes support basic data types (such as number, Boolean, and string) and complex data types (array and nested basic types).
-
+6. Modify object attributes. The object attributes support basic data types (such as number, Boolean, and string) and complex data types (array and nested basic types).
+
+ The sample code is as follows:
```js
local_object.name = "jack";
local_object.age = 19;
@@ -127,23 +177,23 @@ The following example shows how to implement a distributed data object synchroni
local_object.parent.mother = "mom";
```
-6. Access the distributed data object. Obtain the distributed data object attribute, which is the latest data on the network.
-
+7. Access the distributed data object. Obtain the distributed data object attribute, which is the latest data on the network.
+
+ The sample code is as follows:
```js
console.info("name " + local_object["name"]);
```
+8. Unsubscribe from data changes. You can specify the callback to unregister. If you do not specify the callback, all data change callbacks of the distributed data object will be unregistered.
-7. Unsubscribe from data changes. You can specify the callback to unsubscribe from. If you do not specify the callback, all data change callbacks of the distributed data object will be unsubscribed from.
-
+ The sample code is as follows:
```js
- // Unsubscribe from the specified data change callback.
+ // Unregister the specified data change callback.
local_object.off("change", changeCallback);
- // Unsubscribe from all data change callbacks.
+ // Unregister all data change callbacks.
local_object.off("change");
```
-
-8. Subscribe to the status (online/offline) changes of the distributed data object. A callback will be invoked to report the status change when the target distributed data object goes online or offline.
-
+9. Subscribe to the status (online/offline) changes of the distributed data object. A callback will be invoked to report the status change when the target distributed data object goes online or offline.
+ The sample code is as follows:
```js
function statusCallback(sessionId, networkId, status) {
this.response += "status changed " + sessionId + " " + status + " " + networkId;
@@ -152,17 +202,63 @@ The following example shows how to implement a distributed data object synchroni
local_object.on("status", this.statusCallback);
```
-9. Unsubscribe from the status changes of the distributed data object. You can specify the callback to unsubscribe from. If you do not specify the callback, this API unsubscribes from all callbacks of this distributed data object.
+10. Save a distributed data object and revoke the data saving operation.
+
+ - Callback
- ```js
- // Unsubscribe from the specified status change callback.
- local_object.off("status", statusCallback);
- // Unsubscribe from all status change callbacks.
- local_object.off("status");
- ```
-10. Remove a distributed data object from the synchronization network. Data changes on the local object will not be synchronized to the removed distributed data object.
+ ```js
+ // Save a distributed data object.
+ local_object.save("local", (result, data)=>{
+ console.log("save callback");
+ console.info("save sessionId " + data.sessionId);
+ console.info("save version " + data.version);
+ console.info("save deviceId " + data.deviceId);
+ });
+ // Revoke the data saving operation.
+ local_object.revokeSave((result, data) =>{
+ console.log("revokeSave callback");
+ console.info("revokeSave sessionId " + data.sessionId);
+ });
+ ```
+ - Promise
```js
- local_object.setSessionId("");
- ```
\ No newline at end of file
+ // Save a distributed data object.
+ g_object.save("local").then((result)=>{
+ console.info("save sessionId " + result.sessionId);
+ console.info("save version " + result.version);
+ console.info("save deviceId " + result.deviceId);
+ }, (result)=>{
+ console.info("save local failed.");
+ });
+ // Revoke the data saving operation.
+ g_object.revokeSave().then((result)=>{
+ console.info("revokeSave success.");
+ }, (result)=>{
+ console.info("revokeSave failed.");
+ });
+ ```
+11. Unsubscribe from the status changes of the distributed data object. You can specify the callback to unregister. If you do not specify the callback, this API unregister all callbacks of this distributed data object.
+
+ The sample code is as follows:
+ ```js
+ // Unregister the specified status change callback.
+ local_object.off("status", this.statusCallback);
+ // Unregister all status change callbacks.
+ local_object.off("status");
+ ```
+12. Remove a distributed data object from the synchronization network. Data changes on the local object will not be synchronized to the removed distributed data object.
+
+ The sample code is as follows:
+ ```js
+ local_object.setSessionId("");
+ ```
+## Development Example
+
+The following example is provided for you to better understand the development of distributed data objects:
+
+- [Distributed Notepad](https://gitee.com/openharmony/distributeddatamgr_objectstore/tree/master/samples/distributedNotepad)
+
+
+When an event of the Notepad app occurs on a device, such as a note is added, the tile or content of a note is changed, or the event list is cleared, the change will be synchronized to other devices in the trusted network.
diff --git a/en/application-dev/database/database-relational-guidelines.md b/en/application-dev/database/database-relational-guidelines.md
index 571442b3a561e9466fa72a664fcd5785a5bdddc0..7e465b1a13d86a4512a6d0ec693a8f8c248374d8 100644
--- a/en/application-dev/database/database-relational-guidelines.md
+++ b/en/application-dev/database/database-relational-guidelines.md
@@ -15,10 +15,10 @@ The following table describes the APIs available for creating and deleting an RD
| API| Description|
| -------- | -------- |
-|getRdbStore(config: StoreConfig, version: number, callback: AsyncCallback<RdbStore>): void | Obtains an RDB store. This method uses a callback to return the result. You can set parameters for the RDB store based on service requirements, and then call APIs to perform data operations. - **config**: configuration of the RDB store. - **version**: RDB version. - **callback**: callback invoked to return the RDB store obtained.|
-|getRdbStore(config: StoreConfig, version: number): Promise<RdbStore> | Obtains an RDB store. This method uses a promise to return the result. You can set parameters for the RDB store based on service requirements, and then call APIs to perform data operations. - **config**: configuration of the RDB store. - **version**: RDB version.|
-|deleteRdbStore(name: string, callback: AsyncCallback<void>): void | Deletes an RDB store. This method uses a callback to return the result. - **name**: RDB store to delete. - **callback**: callback invoked to return the result.|
-| deleteRdbStore(name: string): Promise<void> | Deletes an RDB store. This method uses a promise to return the result. - **name**: RDB store to delete.|
+|getRdbStore(config: StoreConfig, version: number, callback: AsyncCallback<RdbStore>): void | Obtains an RDB store. This method uses a callback to return the result. You can set parameters for the RDB store based on service requirements, and then call APIs to perform data operations. - **config**: configuration of the RDB store. - **version**: RDB version. - **callback**: callback invoked to return the RDB store obtained.|
+|getRdbStore(config: StoreConfig, version: number): Promise<RdbStore> | Obtains an RDB store. This method uses a promise to return the result. You can set parameters for the RDB store based on service requirements, and then call APIs to perform data operations. - **config**: configuration of the RDB store. - **version**: RDB version.|
+|deleteRdbStore(name: string, callback: AsyncCallback<void>): void | Deletes an RDB store. This method uses a callback to return the result. - **name**: RDB store to delete. - **callback**: callback invoked to return the result.|
+| deleteRdbStore(name: string): Promise<void> | Deletes an RDB store. This method uses a promise to return the result. - **name**: RDB store to delete.|
### Managing Data in an RDB Store
@@ -32,8 +32,8 @@ The RDB provides APIs for inserting, deleting, updating, and querying data in th
| Class| API| Description|
| -------- | -------- | -------- |
- | RdbStore | insert(name: string, values: ValuesBucket, callback: AsyncCallback<number>):void | Inserts a row of data into a table. This method uses a callback to return the result. - **name**: name of the target table. - **values**: data to be inserted into the table. - **callback**: callback invoked to return the result. If the operation is successful, the row ID will be returned. Otherwise, **-1** will be returned.|
- | RdbStore | insert(name: string, values: ValuesBucket): Promise<number> | Inserts a row of data into a table. This method uses a promise to return the result. - **name**: name of the target table. - **values**: data to be inserted into the table.|
+ | RdbStore | insert(name: string, values: ValuesBucket, callback: AsyncCallback<number>):void | Inserts a row of data into a table. This method uses a callback to return the result. - **name**: name of the target table. - **values**: data to be inserted into the table. - **callback**: callback invoked to return the result. If the operation is successful, the row ID will be returned. Otherwise, **-1** will be returned.|
+ | RdbStore | insert(name: string, values: ValuesBucket): Promise<number> | Inserts a row of data into a table. This method uses a promise to return the result. - **name**: name of the target table. - **values**: data to be inserted into the table.|
- **Updating data**
@@ -43,8 +43,8 @@ The RDB provides APIs for inserting, deleting, updating, and querying data in th
| Class| API| Description|
| -------- | -------- | -------- |
- | RdbStore | update(values: ValuesBucket, rdbPredicates: RdbPredicates, callback: AsyncCallback<number>):void | Updates data in the RDB store based on the specified **RdbPredicates** object. This method uses a callback to return the result. - **values**: data to update, which is stored in a **ValuesBucket**. - **rdbPredicates**: conditions for updating data. - **callback**: callback invoked to return the number of rows updated.|
- | RdbStore | update(values: ValuesBucket, rdbPredicates: RdbPredicates): Promise\ | Updates data in the RDB store based on the specified **RdbPredicates** object. This method uses a promise to return the result. - **values**: data to update, which is stored in a **ValuesBucket**. - **rdbPredicates**: conditions for updating data.|
+ | RdbStore | update(values: ValuesBucket, rdbPredicates: RdbPredicates, callback: AsyncCallback<number>):void | Updates data in the RDB store based on the specified **RdbPredicates** object. This method uses a callback to return the result. - **values**: data to update, which is stored in a **ValuesBucket**. - **rdbPredicates**: conditions for updating data. - **callback**: callback invoked to return the number of rows updated.|
+ | RdbStore | update(values: ValuesBucket, rdbPredicates: RdbPredicates): Promise\ | Updates data in the RDB store based on the specified **RdbPredicates** object. This method uses a promise to return the result. - **values**: data to update, which is stored in a **ValuesBucket**. - **rdbPredicates**: conditions for updating data.|
- **Deleting data**
@@ -54,8 +54,8 @@ The RDB provides APIs for inserting, deleting, updating, and querying data in th
| Class| API| Description|
| -------- | -------- | -------- |
- | RdbStore | delete(rdbPredicates: RdbPredicates, callback: AsyncCallback<number>):void | Deletes data from the RDB store based on the specified **RdbPredicates** object. This method uses a callback to return the result. - **rdbPredicates**: conditions for deleting data. - **callback**: callback invoked to return the number of rows deleted.|
- | RdbStore | delete(rdbPredicates: RdbPredicates): Promise\ | Deletes data from the RDB store based on the specified **RdbPredicates** object. This method uses a promise to return the result. - **rdbPredicates**: conditions for deleting data.|
+ | RdbStore | delete(rdbPredicates: RdbPredicates, callback: AsyncCallback<number>):void | Deletes data from the RDB store based on the specified **RdbPredicates** object. This method uses a callback to return the result. - **rdbPredicates**: conditions for deleting data. - **callback**: callback invoked to return the number of rows deleted.|
+ | RdbStore | delete(rdbPredicates: RdbPredicates): Promise\ | Deletes data from the RDB store based on the specified **RdbPredicates** object. This method uses a promise to return the result. - **rdbPredicates**: conditions for deleting data.|
- **Querying data**
@@ -68,10 +68,10 @@ The RDB provides APIs for inserting, deleting, updating, and querying data in th
| Class| API| Description|
| -------- | -------- | -------- |
- | RdbStore | query(rdbPredicates: RdbPredicates, columns: Array, callback: AsyncCallback<ResultSet>): void | Queries data in the RDB store based on the specified **RdbPredicates** object. This method uses a callback to return the result. - **rdbPredicates**: conditions for querying data. - **columns**: columns to query. If this parameter is not specified, the query applies to all columns. - **callback**: callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned.|
- | RdbStore | query(rdbPredicates: RdbPredicates, columns: Array): Promise<ResultSet> | Queries data in the RDB store based on the specified **RdbPredicates** object. This method uses a promise to return the result. - **rdbPredicates**: conditions for querying data. - **columns**: columns to query. If this parameter is not specified, the query applies to all columns.|
- | RdbStore | querySql(sql: string, bindArgs: Array<ValueType>, callback: AsyncCallback<ResultSet>):void | Queries data in the RDB store using the specified SQL statement. This method uses a callback to return the result. - **sql**: SQL statement. - **bindArgs**: arguments in the SQL statement. - **callback**: callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned.|
- | RdbStore | querySql(sql: string, bindArgs?: Array<ValueType>):Promise<ResultSet> | Queries data in the RDB store using the specified SQL statement. This method uses a promise to return the result. - **sql**: SQL statement. - **bindArgs**: arguments in the SQL statement.|
+ | RdbStore | query(rdbPredicates: RdbPredicates, columns: Array, callback: AsyncCallback<ResultSet>): void | Queries data in the RDB store based on the specified **RdbPredicates** object. This method uses a callback to return the result. - **rdbPredicates**: conditions for querying data. - **columns**: columns to query. If this parameter is not specified, the query applies to all columns. - **callback**: callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned.|
+ | RdbStore | query(rdbPredicates: RdbPredicates, columns: Array): Promise<ResultSet> | Queries data in the RDB store based on the specified **RdbPredicates** object. This method uses a promise to return the result. - **rdbPredicates**: conditions for querying data. - **columns**: columns to query. If this parameter is not specified, the query applies to all columns.|
+ | RdbStore | querySql(sql: string, bindArgs: Array<ValueType>, callback: AsyncCallback<ResultSet>):void | Queries data in the RDB store using the specified SQL statement. This method uses a callback to return the result. - **sql**: SQL statement. - **bindArgs**: arguments in the SQL statement. - **callback**: callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned.|
+ | RdbStore | querySql(sql: string, bindArgs?: Array<ValueType>):Promise<ResultSet> | Queries data in the RDB store using the specified SQL statement. This method uses a promise to return the result. - **sql**: SQL statement. - **bindArgs**: arguments in the SQL statement.|
### Using Predicates
@@ -81,36 +81,36 @@ The RDB provides **RdbPredicates** for you to set database operation conditions.
| Class| API| Description|
| -------- | -------- | -------- |
-| RdbPredicates |inDevices(devices: Array\): RdbPredicates | Specifies remote devices on the network with RDB stores to be synchronized. - **devices**: IDs of the remote devices on the network. - **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
-| RdbPredicates |inAllDevices(): RdbPredicates | Connects to all remote devices on the network with RDB stores to be synchronized. - **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
-| RdbPredicates | equalTo(field: string, value: ValueType): RdbPredicates | Sets the **RdbPredicates** to match the field with data type **ValueType** and value equal to the specified value. - **field**: column name in the database table. - **value**: value specified. - **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
-| RdbPredicates | notEqualTo(field: string, value: ValueType): RdbPredicates | Sets the **RdbPredicates** to match the field with data type **ValueType** and value not equal to the specified value. - **field**: column name in the database table. - **value**: value specified. - **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
-| RdbPredicates | beginWrap(): RdbPredicates | Adds a left parenthesis to the **RdbPredicates**. - **RdbPredicates**: returns a **RdbPredicates** with a left parenthesis.|
-| RdbPredicates | endWrap(): RdbPredicates | Adds a right parenthesis to the **RdbPredicates**. - **RdbPredicates**: returns a **RdbPredicates** with a right parenthesis.|
-| RdbPredicates | or(): RdbPredicates | Adds the OR condition to the **RdbPredicates**. - **RdbPredicates**: returns a **RdbPredicates** with the OR condition.|
-| RdbPredicates | and(): RdbPredicates | Adds the AND condition to the **RdbPredicates**. - **RdbPredicates**: returns a **RdbPredicates** with the AND condition.|
-| RdbPredicates | contains(field: string, value: string): RdbPredicats | Sets the **RdbPredicates** to match a string containing the specified value. - **field**: column name in the database table. - **value**: value specified. - **RdbPredicates**: returns a **RdbPredicates** object that matches the specified string.|
-| RdbPredicates | beginsWith(field: string, value: string): RdbPredicates | Sets the **RdbPredicates** to match a string that starts with the specified value. - **field**: column name in the database table. - **value**: value specified. - **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
-| RdbPredicates | endsWith(field: string, value: string): RdbPredicates | Sets the **RdbPredicates** to match a string that ends with the specified value. - **field**: column name in the database table. - **value**: value specified. - **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
-| RdbPredicates | isNull(field: string): RdbPredicates | Sets the **RdbPredicates** to match the field whose value is null. - **field**: column name in the database table. - **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
-| RdbPredicates | isNotNull(field: string): RdbPredicates | Sets the **RdbPredicates** to match the field whose value is not null. - **field**: column name in the database table. - **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
-| RdbPredicates | like(field: string, value: string): RdbPredicates | Sets the **RdbPredicates** to match a string that is similar to the specified value. - **field**: column name in the database table. - **value**: value specified. - **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
-| RdbPredicates | glob(field: string, value: string): RdbPredicates | Sets the **RdbPredicates** to match the specified string. - **field**: column name in the database table. - **value**: value specified. - **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
-| RdbPredicates | between(field: string, low: ValueType, high: ValueType): RdbPredicates | Sets the **RdbPredicates** to match the field with data type **ValueType** and value within the specified range. - **field**: column name in the database table. - **low**: minimum value that matches the **RdbPredicates**. - **high**: maximum value that matches the **RdbPredicates**. - **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
-| RdbPredicates | notBetween(field: string, low: ValueType, high: ValueType): RdbPredicates | Sets the **RdbPredicates** to match the field with data type **ValueType** and value out of the specified range. - **field**: column name in the database table. - **low**: minimum value that matches the **RdbPredicates**. - **high**: maximum value that matches the **RdbPredicates**. - **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
-| RdbPredicates | greaterThan(field: string, value: ValueType): RdbPredicatesgr | Sets the **RdbPredicates** to match the field with data type **ValueType** and value greater than the specified value. - **field**: column name in the database table. - **value**: value specified. - **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
-| RdbPredicates | lessThan(field: string, value: ValueType): RdbPredicates | Sets the **RdbPredicates** to match the field with data type **ValueType** and value less than the specified value. - **field**: column name in the database table. - **value**: value specified. - **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
-| RdbPredicates | greaterThanOrEqualTo(field: string, value: ValueType): RdbPredicates | Sets the **RdbPredicates** to match the field with data type **ValueType** and value greater than or equal to the specified value. - **field**: column name in the database table. - **value**: value specified. - **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
-| RdbPredicates | lessThanOrEqualTo(field: string, value: ValueType): RdbPredicates | Sets the **RdbPredicates** to match the field with data type **ValueType** and value less than or equal to the specified value. - **field**: column name in the database table. - **value**: value specified. - **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
-| RdbPredicates | orderByAsc(field: string): RdbPredicates | Sets the **RdbPredicates** to match the column with values sorted in ascending order. - **field**: column name in the database table. - **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
-| RdbPredicates | orderByDesc(field: string): RdbPredicates | Sets the **RdbPredicates** to match the column with values sorted in descending order. - **field**: column name in the database table. - **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
-| RdbPredicates | distinct(): RdbPredicates | Sets the **RdbPredicates** to filter out duplicate records. - **RdbPredicates**: returns a **RdbPredicates** object that can filter out duplicate records.|
-| RdbPredicates | limitAs(value: number): RdbPredicates | Sets the **RdbPredicates** to specify the maximum number of records. - **value**: maximum number of records. - **RdbPredicates**: returns a **RdbPredicates** object that can be used to set the maximum number of records.|
-| RdbPredicates | offsetAs(rowOffset: number): RdbPredicates | Sets the **RdbPredicates** to specify the start position of the returned result. - **rowOffset**: start position of the returned result. The value is a positive integer. - **RdbPredicates**: returns a **RdbPredicates** object that specifies the start position of the returned result.|
-| RdbPredicates | groupBy(fields: Array<string>): RdbPredicates | Sets the **RdbPredicates** to group rows that have the same value into summary rows. - **fields**: names of the columns grouped for querying data. - **RdbPredicates**: returns a **RdbPredicates** object that groups rows with the same value.|
-| RdbPredicates | indexedBy(indexName: string): RdbPredicates | Sets the **RdbPredicates** to specify the index column. - **indexName**: name of the index column. - **RdbPredicates**: returns a **RdbPredicates** object that specifies the index column.|
-| RdbPredicates | in(field: string, value: Array<ValueType>): RdbPredicates | Sets the **RdbPredicates** to match the field with data type **Array<ValueType>** and value within the specified range. - **field**: column name in the database table. - **value**: array of **ValueType** to match. - **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
-| RdbPredicates | notIn(field: string, value: Array<ValueType>): RdbPredicates | Sets the **RdbPredicates** to match the field with data type **Array<ValueType>** and value out of the specified range. - **field**: column name in the database table. - **value**: array of **ValueType** to match. - **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
+| RdbPredicates |inDevices(devices: Array\): RdbPredicates | Specifies remote devices on the network with RDB stores to be synchronized. - **devices**: IDs of the remote devices on the network. - **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
+| RdbPredicates |inAllDevices(): RdbPredicates | Connects to all remote devices on the network with RDB stores to be synchronized. - **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
+| RdbPredicates | equalTo(field: string, value: ValueType): RdbPredicates | Sets the **RdbPredicates** to match the field with data type **ValueType** and value equal to the specified value. - **field**: column name in the database table. - **value**: value specified. - **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
+| RdbPredicates | notEqualTo(field: string, value: ValueType): RdbPredicates | Sets the **RdbPredicates** to match the field with data type **ValueType** and value not equal to the specified value. - **field**: column name in the database table. - **value**: value specified. - **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
+| RdbPredicates | beginWrap(): RdbPredicates | Adds a left parenthesis to the **RdbPredicates**. - **RdbPredicates**: returns a **RdbPredicates** with a left parenthesis.|
+| RdbPredicates | endWrap(): RdbPredicates | Adds a right parenthesis to the **RdbPredicates**. - **RdbPredicates**: returns a **RdbPredicates** with a right parenthesis.|
+| RdbPredicates | or(): RdbPredicates | Adds the OR condition to the **RdbPredicates**. - **RdbPredicates**: returns a **RdbPredicates** with the OR condition.|
+| RdbPredicates | and(): RdbPredicates | Adds the AND condition to the **RdbPredicates**. - **RdbPredicates**: returns a **RdbPredicates** with the AND condition.|
+| RdbPredicates | contains(field: string, value: string): RdbPredicates | Sets the **RdbPredicates** to match a string containing the specified value. - **field**: column name in the database table. - **value**: value specified. - **RdbPredicates**: returns a **RdbPredicates** object that matches the specified string.|
+| RdbPredicates | beginsWith(field: string, value: string): RdbPredicates | Sets the **RdbPredicates** to match a string that starts with the specified value. - **field**: column name in the database table. - **value**: value specified. - **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
+| RdbPredicates | endsWith(field: string, value: string): RdbPredicates | Sets the **RdbPredicates** to match a string that ends with the specified value. - **field**: column name in the database table. - **value**: value specified. - **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
+| RdbPredicates | isNull(field: string): RdbPredicates | Sets the **RdbPredicates** to match the field whose value is null. - **field**: column name in the database table. - **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
+| RdbPredicates | isNotNull(field: string): RdbPredicates | Sets the **RdbPredicates** to match the field whose value is not null. - **field**: column name in the database table. - **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
+| RdbPredicates | like(field: string, value: string): RdbPredicates | Sets the **RdbPredicates** to match a string that is similar to the specified value. - **field**: column name in the database table. - **value**: value specified. - **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
+| RdbPredicates | glob(field: string, value: string): RdbPredicates | Sets the **RdbPredicates** to match the specified string. - **field**: column name in the database table. - **value**: value specified. - **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
+| RdbPredicates | between(field: string, low: ValueType, high: ValueType): RdbPredicates | Sets the **RdbPredicates** to match the field with data type **ValueType** and value within the specified range. - **field**: column name in the database table. - **low**: minimum value that matches the **RdbPredicates**. - **high**: maximum value that matches the **RdbPredicates**. - **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
+| RdbPredicates | notBetween(field: string, low: ValueType, high: ValueType): RdbPredicates | Sets the **RdbPredicates** to match the field with data type **ValueType** and value out of the specified range. - **field**: column name in the database table. - **low**: minimum value that matches the **RdbPredicates**. - **high**: maximum value that matches the **RdbPredicates**. - **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
+| RdbPredicates | greaterThan(field: string, value: ValueType): RdbPredicatesgr | Sets the **RdbPredicates** to match the field with data type **ValueType** and value greater than the specified value. - **field**: column name in the database table. - **value**: value specified. - **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
+| RdbPredicates | lessThan(field: string, value: ValueType): RdbPredicates | Sets the **RdbPredicates** to match the field with data type **ValueType** and value less than the specified value. - **field**: column name in the database table. - **value**: value specified. - **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
+| RdbPredicates | greaterThanOrEqualTo(field: string, value: ValueType): RdbPredicates | Sets the **RdbPredicates** to match the field with data type **ValueType** and value greater than or equal to the specified value. - **field**: column name in the database table. - **value**: value specified. - **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
+| RdbPredicates | lessThanOrEqualTo(field: string, value: ValueType): RdbPredicates | Sets the **RdbPredicates** to match the field with data type **ValueType** and value less than or equal to the specified value. - **field**: column name in the database table. - **value**: value specified. - **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
+| RdbPredicates | orderByAsc(field: string): RdbPredicates | Sets the **RdbPredicates** to match the column with values sorted in ascending order. - **field**: column name in the database table. - **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
+| RdbPredicates | orderByDesc(field: string): RdbPredicates | Sets the **RdbPredicates** to match the column with values sorted in descending order. - **field**: column name in the database table. - **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
+| RdbPredicates | distinct(): RdbPredicates | Sets the **RdbPredicates** to filter out duplicate records. - **RdbPredicates**: returns a **RdbPredicates** object that can filter out duplicate records.|
+| RdbPredicates | limitAs(value: number): RdbPredicates | Sets the **RdbPredicates** to specify the maximum number of records. - **value**: maximum number of records. - **RdbPredicates**: returns a **RdbPredicates** object that can be used to set the maximum number of records.|
+| RdbPredicates | offsetAs(rowOffset: number): RdbPredicates | Sets the **RdbPredicates** to specify the start position of the returned result. - **rowOffset**: start position of the returned result. The value is a positive integer. - **RdbPredicates**: returns a **RdbPredicates** object that specifies the start position of the returned result.|
+| RdbPredicates | groupBy(fields: Array<string>): RdbPredicates | Sets the **RdbPredicates** to group rows that have the same value into summary rows. - **fields**: names of the columns grouped for querying data. - **RdbPredicates**: returns a **RdbPredicates** object that groups rows with the same value.|
+| RdbPredicates | indexedBy(indexName: string): RdbPredicates | Sets the **RdbPredicates** to specify the index column. - **indexName**: name of the index column. - **RdbPredicates**: returns a **RdbPredicates** object that specifies the index column.|
+| RdbPredicates | in(field: string, value: Array<ValueType>): RdbPredicates | Sets the **RdbPredicates** to match the field with data type **Array<ValueType>** and value within the specified range. - **field**: column name in the database table. - **value**: array of **ValueType** to match. - **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
+| RdbPredicates | notIn(field: string, value: Array<ValueType>): RdbPredicates | Sets the **RdbPredicates** to match the field with data type **Array<ValueType>** and value out of the specified range. - **field**: column name in the database table. - **value**: array of **ValueType** to match. - **RdbPredicates**: returns a **RdbPredicates** object that matches the specified field.|
### Using the Result Set
@@ -123,32 +123,34 @@ A result set can be regarded as a row of data in the queried results. It allows
| Class| API| Description|
| -------- | -------- | -------- |
-| ResultSet | goTo(offset:number): boolean | Moves the result set forwards or backwards by the specified offset relative to its current position.|
-| ResultSet | goToRow(position: number): boolean | Moves the result set to the specified row.|
-| ResultSet | goToNextRow(): boolean | Moves the result set to the next row.|
-| ResultSet | goToPreviousRow(): boolean | Moves the result set to the previous row.|
-| ResultSet | getColumnIndex(columnName: string): number | Obtains the column index based on the specified column name.|
-| ResultSet | getColumnName(columnIndex: number): string | Obtains the column name based on the specified column index.|
-| ResultSet | goToFirstRow(): boolean | Checks whether the result set is located in the first row.|
-| ResultSet | goToLastRow(): boolean | Checks whether the result set is located in the last row.|
-| ResultSet | getString(columnIndex: number): string | Obtains the value in the specified column of the current row, in a string.|
-| ResultSet | getBlob(columnIndex: number): Uint8Array | Obtains the values in the specified column of the current row, in a byte array.|
-| ResultSet | getDouble(columnIndex: number): number | Obtains the values in the specified column of the current row, in double.|
-| ResultSet | isColumnNull(columnIndex: number): boolean | Checks whether the value in the specified column of the current row is null.|
-| ResultSet | close(): void | Closes the result set.|
+| ResultSet | goTo(offset:number): boolean | Moves the result set forwards or backwards by the specified offset relative to its current position.|
+| ResultSet | goToRow(position: number): boolean | Moves the result set to the specified row.|
+| ResultSet | goToNextRow(): boolean | Moves the result set to the next row.|
+| ResultSet | goToPreviousRow(): boolean | Moves the result set to the previous row.|
+| ResultSet | getColumnIndex(columnName: string): number | Obtains the column index based on the specified column name.|
+| ResultSet | getColumnName(columnIndex: number): string | Obtains the column name based on the specified column index.|
+| ResultSet | goToFirstRow(): boolean | Checks whether the result set is located in the first row.|
+| ResultSet | goToLastRow(): boolean | Checks whether the result set is located in the last row.|
+| ResultSet | getString(columnIndex: number): string | Obtains the value in the specified column of the current row, in a string.|
+| ResultSet | getBlob(columnIndex: number): Uint8Array | Obtains the values in the specified column of the current row, in a byte array.|
+| ResultSet | getDouble(columnIndex: number): number | Obtains the values in the specified column of the current row, in double.|
+| ResultSet | isColumnNull(columnIndex: number): boolean | Checks whether the value in the specified column of the current row is null.|
+| ResultSet | close(): void | Closes the result set.|
### Setting Distributed Tables
+>**CAUTION** ohos.permission.DISTRIBUTED_DATASYNC is requied for using the **setDistributedTables**, **obtainDistributedTableName**, **sync**, **on**, and **off** APIs of **RdbStore**.
+
**Setting Distributed Tables**
**Table 8** APIs for setting distributed tables
| Class| API| Description|
| -------- | -------- | -------- |
-| RdbStore | setDistributedTables(tables: Array\, callback: AsyncCallback\): void | Sets a list of distributed tables. This method uses a callback to return the result. - **tables**: names of the distributed tables to set. - **callback**: callback invoked to return the result.|
-| RdbStore | setDistributedTables(tables: Array\): Promise\ | Sets a list of distributed tables. This method uses a promise to return the result. - **tables**: names of the distributed tables to set.|
+| RdbStore | setDistributedTables(tables: Array\, callback: AsyncCallback\): void | Sets a list of distributed tables. This method uses a callback to return the result. - **tables**: names of the distributed tables to set. - **callback**: callback invoked to return the result.|
+| RdbStore | setDistributedTables(tables: Array\): Promise\ | Sets a list of distributed tables. This method uses a promise to return the result. - **tables**: names of the distributed tables to set.|
**Obtaining the Distributed Table Name for a Remote Device**
@@ -158,8 +160,8 @@ You can obtain the distributed table name for a remote device based on the local
| Class| API| Description|
| -------- | -------- | -------- |
-| RdbStore | obtainDistributedTableName(device: string, table: string, callback: AsyncCallback\): void | Obtains the distributed table name for a remote device based on the local table name. The distributed table name is used to query the RDB store of the remote device. This method uses a callback to return the result. - **device**: remote device. - **table**: local table name. - **callback**: callback used to return the result. If the operation is successful, the distributed table name of the remote device will be returned. |
-| RdbStore | obtainDistributedTableName(device: string, table: string): Promise\ | Obtains the distributed table name for a remote device based on the local table name. The distributed table name is used to query the RDB store of the remote device. This method uses a promise to return the result. - **device**: remote device. - **table**: local table name.|
+| RdbStore | obtainDistributedTableName(device: string, table: string, callback: AsyncCallback\): void | Obtains the distributed table name for a remote device based on the local table name. The distributed table name is used to query the RDB store of the remote device. This method uses a callback to return the result. - **device**: remote device. - **table**: local table name. - **callback**: callback used to return the result. If the operation is successful, the distributed table name of the remote device will be returned. |
+| RdbStore | obtainDistributedTableName(device: string, table: string): Promise\ | Obtains the distributed table name for a remote device based on the local table name. The distributed table name is used to query the RDB store of the remote device. This method uses a promise to return the result. - **device**: remote device. - **table**: local table name.|
**Synchronizing Data Between Devices**
@@ -167,8 +169,8 @@ You can obtain the distributed table name for a remote device based on the local
| Class| API| Description|
| -------- | -------- | -------- |
-| RdbStore | sync(mode: SyncMode, predicates: RdbPredicates, callback: AsyncCallback>): void | Synchronizes data between devices. This method uses a callback to return the result. - **mode**: data synchronization mode. **SYNC\_MODE\_PUSH** means to push data from the local device to a remote device. **SYNC\_MODE\_PULL** means to pull data from a remote device to the local device. - **predicates**: data and devices to be synchronized. - **callback**: callback invoked to return the result. In the result, **string** indicates the device ID, and **number** indicates the synchronization status of each device. The value **0** indicates a success, and other values indicate a failure.|
-| RdbStore | sync(mode: SyncMode, predicates: RdbPredicates): Promise> | Synchronizes data between devices. This method uses a promise to return the result. - **mode**: data synchronization mode. **SYNC\_MODE\_PUSH** means to push data from the local device to a remote device. **SYNC\_MODE\_PULL** means to pull data from a remote device to the local device. - **predicates**: data and devices to be synchronized. |
+| RdbStore | sync(mode: SyncMode, predicates: RdbPredicates, callback: AsyncCallback\>): void | Synchronizes data between devices. This method uses a callback to return the result. - **mode**: data synchronization mode. **SYNC\_MODE\_PUSH** means to push data from the local device to a remote device. **SYNC\_MODE\_PULL** means to pull data from a remote device to the local device. - **predicates**: data and devices to be synchronized. - **callback**: callback invoked to return the result. In the result, **string** indicates the device ID, and **number** indicates the synchronization status of each device. The value **0** indicates a success, and other values indicate a failure.|
+| RdbStore | sync(mode: SyncMode, predicates: RdbPredicates): Promise\> | Synchronizes data between devices. This method uses a promise to return the result. - **mode**: data synchronization mode. **SYNC\_MODE\_PUSH** means to push data from the local device to a remote device. **SYNC\_MODE\_PULL** means to pull data from a remote device to the local device. - **predicates**: data and devices to be synchronized. |
**Registering an RDB Store Observer**
@@ -176,7 +178,7 @@ You can obtain the distributed table name for a remote device based on the local
| Class| API| Description|
| -------- | -------- | -------- |
-| RdbStore |on(event: 'dataChange', type: SubscribeType, observer: Callback>): void| Registers an observer for this RDB store to subscribe to distributed data changes. When data in the RDB store changes, a callback will be invoked to return the data changes. - **type**: subscription type. **SUBSCRIBE\_TYPE\_REMOTE** means to subscribe to remote data changes. - **observer**: observer that listens for data changes in the RDB store.|
+| RdbStore |on(event: 'dataChange', type: SubscribeType, observer: Callback\>): void| Registers an observer for this RDB store to subscribe to distributed data changes. When data in the RDB store changes, a callback will be invoked to return the data changes. - **type**: subscription type. **SUBSCRIBE\_TYPE\_REMOTE** means to subscribe to remote data changes. - **observer**: observer that listens for data changes in the RDB store.|
**Unregistering an RDB Store Observer**
@@ -184,7 +186,7 @@ You can obtain the distributed table name for a remote device based on the local
| Class| API| Description|
| -------- | -------- | -------- |
-| RdbStore |off(event:'dataChange', type: SubscribeType, observer: Callback>): void| Unregisters the observer of the specified type for the RDB store. This method uses a callback to return the result. - **type**: subscription type. **SUBSCRIBE\_TYPE\_REMOTE** means to subscribe to remote data changes. - **observer**: observer to unregister.|
+| RdbStore |off(event:'dataChange', type: SubscribeType, observer: Callback\>): void;| Unregisters the observer of the specified type for the RDB store. This API uses a callback to return the result. - **type**: subscription type. **SUBSCRIBE\_TYPE\_REMOTE** means to subscribe to remote data changes. - **observer**: observer to unregister.|
## How to Develop
@@ -202,7 +204,7 @@ You can obtain the distributed table name for a remote device based on the local
const CREATE_TABLE_TEST = "CREATE TABLE IF NOT EXISTS test (" + "id INTEGER PRIMARY KEY AUTOINCREMENT, " + "name TEXT NOT NULL, " + "age INTEGER, " + "salary REAL, " + "blobType BLOB)";
const STORE_CONFIG = {name: "rdbstore.db",}
data_rdb.getRdbStore(STORE_CONFIG, 1, function (err, rdbStore) {
- rdbStore.executeSql(SQL_CREATE_TABLE)
+ rdbStore.executeSql(CREATE_TABLE_TEST)
console.info('create table done.')
})
```
@@ -242,24 +244,37 @@ You can obtain the distributed table name for a remote device based on the local
```
4. Set the distributed tables to be synchronized.
- 1. Set the distributed tables.
- 2. Check whether the setting is successful.
+
+ 1. Add the following permission to the permission configuration file:
+ ```js
+ "requestPermissions":
+ {
+ "name": "ohos.permission.DISTRIBUTED_DATASYNC"
+ }
+ ```
+ 2. Obtain the required permission.
+ 3. Set the distributed tables.
+ 4. Check whether the setting is successful.
The sample code is as follows:
- ```js
- let promise = rdbStore.setDistributedTables(["test"])
- promise.then(() => {
- console.info("setDistributedTables success.")
- }).catch((err) => {
- console.info("setDistributedTables failed.")
- })
- ```
+ ```js
+ let context = featureAbility.getContext();
+ context.requestPermissionsFromUser(['ohos.permission.DISTRIBUTED_DATASYNC'], 666, function (result) {
+ console.info(`result.requestCode=${result.requestCode}`)
+ })
+ let promise = rdbStore.setDistributedTables(["test"])
+ promise.then(() => {
+ console.info("setDistributedTables success.")
+ }).catch((err) => {
+ console.info("setDistributedTables failed.")
+ })
+ ```
- 5. Synchronize data across devices.
+5. Synchronize data across devices.
1. Constructs an **RdbPredicates** object to specify remote devices within the network to be synchronized.
2. Call the **sync()** method to synchronize data.
- 3. Check whether the data synchronization is successful.
+ 3. Check whether data synchronization is successful.
The sample code is as follows:
@@ -306,3 +321,8 @@ You can obtain the distributed table name for a remote device based on the local
let tableName = rdbStore.obtainDistributedTableName(deviceId, "test");
let resultSet = rdbStore.querySql("SELECT * FROM " + tableName)
```
+## Samples
+The following samples are provided for you to better understand the RDB development:
+- [`Rdb`: eTS RDB (API8)](https://gitee.com/openharmony/app_samples/tree/master/data/Rdb)
+- [`DistributedRdb`: eTS Distributed Relational Database (API8)](https://gitee.com/openharmony/app_samples/tree/master/data/DistributedRdb)
+- [Relational Database](https://gitee.com/openharmony/codelabs/tree/master/Data/JSRelationshipData)
diff --git a/en/application-dev/device-usage-statistics/device-usage-statistics-dev-guide.md b/en/application-dev/device-usage-statistics/device-usage-statistics-dev-guide.md
index 06edad460749ab7ef5cb00bb820489a8368c01f8..c4e4fdf3850f4bd3b1b8f6902133835764414cb3 100644
--- a/en/application-dev/device-usage-statistics/device-usage-statistics-dev-guide.md
+++ b/en/application-dev/device-usage-statistics/device-usage-statistics-dev-guide.md
@@ -3,6 +3,7 @@
## When to Use
With device usage statistics APIs, you can have a better understanding of the application, notification, and system usage. For example, in application usage statistics, you can query the application usage, event log, and bundle group.
+
The application records (usage history statistics and event records) cached by components are updated to the database for persistent storage within 30 minutes after an event is reported.
## Available APIs
@@ -19,9 +20,20 @@ import stats from '@ohos.bundleState';
| function queryBundleStateInfos(begin: number, end: number, callback: AsyncCallback<BundleActiveInfoResponse>): void | Queries the application usage duration statistics based on the specified start time and end time.|
| function queryCurrentBundleActiveStates(begin: number, end: number, callback: AsyncCallback<Array<BundleActiveState>>): void | Queries events of this application based on the specified start time and end time.|
| function queryBundleStateInfoByInterval(byInterval: IntervalType, begin: number, end: number, callback: AsyncCallback<Array<BundleStateInfo>>): void | Queries the application usage duration statistics in the specified time frame at the specified interval (daily, weekly, monthly, or annually).|
-| function queryAppUsagePriorityGroup(callback: AsyncCallback<number>): void | Queries the priority group of the current invoker application.|
+| function queryAppUsagePriorityGroup(callback: AsyncCallback<number>): void | Queries the priority group of this application. This API uses an asynchronous callback to return the result.|
+| function queryAppUsagePriorityGroup(): Promise<number>; | Queries the priority group of this application. This API uses a promise to return the result.|
| function isIdleState(bundleName: string, callback: AsyncCallback<boolean>): void | Checks whether the application specified by **bundleName** is in the idle state. |
| function getRecentlyUsedModules(maxNum: number, callback: AsyncCallback<BundleActiveModuleInfo>): void | Obtains the number of FA usage records specified by **maxNum**.|
+| function queryAppNotificationNumber(begin: number, end: number, callback: AsyncCallback<Array<BundleActiveEventState>>): void | Queries the number of notifications from all applications based on the specified start time and end time.|
+| function queryBundleActiveEventStates(begin: number, end: number, callback: AsyncCallback<Array<BundleActiveEventState>>): void | Queries statistics about system events (hibernation, wakeup, unlocking, and screen locking) that occur between the specified start time and end time.|
+| function queryAppUsagePriorityGroup(bundleName? : string, callback: AsyncCallback<number>): void | Queries the priority group of the application specified by **bundleName**. If **bundleName** is not specified, the priority group of the current application is queried. This API uses an asynchronous callback to return the result.|
+| function queryAppUsagePriorityGroup(bundleName? : string): Promise<number>; | Queries the priority group of the application specified by **bundleName**. If **bundleName** is not specified, the priority group of the current application is queried. This API uses a promise to return the result.|
+| function setBundleGroup(bundleName : string, newGroup: GroupType, callback: AsyncCallback>boolean>): void | Sets the group for the application specified by **bundleName**. This API uses an asynchronous callback to return the result.|
+| function setBundleGroup(bundleName : string, newGroup : GroupType): Promise>boolean>; | Sets the group for the application specified by **bundleName**. This API uses a promise to return the result.|
+| function registerGroupCallBack(callback: Callback>BundleActiveGroupCallbackInfo>, callback: AsyncCallback>boolean>): void | Registers a callback for application group changes. When an application group of the user changes, the change is returned to all applications that have registered the callback. This API uses an asynchronous callback to return the result.|
+| function registerGroupCallBack(callback: Callback>BundleActiveGroupCallbackInfo>): Promise>boolean>; | Registers a callback for application group changes. When an application group of the user changes, the change is returned to all applications that have registered the callback. This API uses a promise to return the result.|
+| function unRegisterGroupCallBack(callback: AsyncCallback>boolean>): void | Deregisters the callback for application group changes. This API uses an asynchronous callback to return the result.|
+| function unRegisterGroupCallBack(): Promise>boolean>; | Deregisters the callback for application group changes. This API uses a promise to return the result.|
## How to Develop
@@ -44,7 +56,7 @@ import stats from '@ohos.bundleState';
```js
import stats from '@ohos.bundleState'
- // Use a promise to return the result.
+ // Promise mode
stats.queryBundleActiveStates(0, 20000000000000).then( res => {
console.log('BUNDLE_ACTIVE queryBundleActiveStates promise success.');
for (let i = 0; i < res.length; i++) {
@@ -55,7 +67,7 @@ import stats from '@ohos.bundleState';
console.log('BUNDLE_ACTIVE queryBundleActiveStates promise failed, because: ' + err.code);
});
- // Use an asynchronous callback to return the result.
+ // Asynchronous callback mode
stats.queryBundleActiveStates(0, 20000000000000, (err, res) => {
if (err) {
console.log('BUNDLE_ACTIVE queryBundleActiveStates callback failed, because: ' + err.code);
@@ -74,7 +86,7 @@ import stats from '@ohos.bundleState';
```js
import stats from '@ohos.bundleState'
- // Use a promise to return the result.
+ // Promise mode
stats.queryBundleStateInfos(0, 20000000000000).then( res => {
console.log('BUNDLE_ACTIVE queryBundleStateInfos promise success.');
let i = 1;
@@ -87,7 +99,7 @@ import stats from '@ohos.bundleState';
console.log('BUNDLE_ACTIVE queryBundleStateInfos promise failed, because: ' + err.code);
});
- // Use an asynchronous callback to return the result.
+ // Asynchronous callback mode
stats.queryBundleStateInfos(0, 20000000000000, (err, res) => {
if (err) {
console.log('BUNDLE_ACTIVE queryBundleStateInfos callback failed, because: ' + err.code);
@@ -108,7 +120,7 @@ import stats from '@ohos.bundleState';
```js
import stats from '@ohos.bundleState'
- // Use a promise to return the result.
+ // Promise mode
stats.queryCurrentBundleActiveStates(0, 20000000000000).then( res => {
console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates promise success.');
for (let i = 0; i < res.length; i++) {
@@ -119,7 +131,7 @@ import stats from '@ohos.bundleState';
console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates promise failed, because: ' + err.code);
});
- // Use an asynchronous callback to return the result.
+ // Asynchronous callback mode
stats.queryCurrentBundleActiveStates(0, 20000000000000, (err, res) => {
if (err) {
console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback failed, because: ' + err.code);
@@ -138,7 +150,7 @@ import stats from '@ohos.bundleState';
```js
import stats from '@ohos.bundleState'
- // Use a promise to return the result.
+ // Promise mode
stats.queryBundleStateInfoByInterval(0, 0, 20000000000000).then( res => {
console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval promise success.');
for (let i = 0; i < res.length; i++) {
@@ -149,7 +161,7 @@ import stats from '@ohos.bundleState';
console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval promise failed, because: ' + err.code);
});
- // Use an asynchronous callback to return the result.
+ // Asynchronous callback mode
stats.queryBundleStateInfoByInterval(0, 0, 20000000000000, (err, res) => {
if (err) {
console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback failed, because: ' + err.code);
@@ -163,19 +175,19 @@ import stats from '@ohos.bundleState';
});
```
-6. Query the priority group of the current invoker application. This requires no permission to be configured in the **config.json** file.
+6. Query the priority group of the current application. This requires no permission to be configured in the **config.json** file.
```js
import stats from '@ohos.bundleState'
-
- // Use a promise to return the result.
+
+ // Promise mode
stats.queryAppUsagePriorityGroup().then( res => {
console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup promise succeeded. result: ' + JSON.stringify(res));
}).catch( err => {
console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup promise failed. because: ' + err.code);
});
-
- // Use an asynchronous callback to return the result.
+
+ // Callback mode
stats.queryAppUsagePriorityGroup((err, res) => {
if (err) {
console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup callback failed. because: ' + err.code);
@@ -184,20 +196,20 @@ import stats from '@ohos.bundleState';
}
});
```
-
-7. Check whether the application specified by **bundleName** is in the idle state. This requires no permission to be configured in the **config.json** file.
+
+7. Check whether the application specified by **bundleName** is in the idle state. This requires no permission to be configured in the **config.json** file. A third-party application can only check the idle status of itself.
```js
import stats from '@ohos.bundleState'
- // Use a promise to return the result.
+ // Promise mode
stats.isIdleState("com.ohos.camera").then( res => {
console.log('BUNDLE_ACTIVE isIdleState promise succeeded, result: ' + JSON.stringify(res));
}).catch( err => {
console.log('BUNDLE_ACTIVE isIdleState promise failed, because: ' + err.code);
});
- // Use an asynchronous callback to return the result.
+ // Asynchronous callback mode
stats.isIdleState("com.ohos.camera", (err, res) => {
if (err) {
console.log('BUNDLE_ACTIVE isIdleState callback failed, because: ' + err.code);
@@ -212,7 +224,7 @@ import stats from '@ohos.bundleState';
```js
import stats from '@ohos.bundleState'
- // Use a promise to return the result.
+ // Promise mode
stats.getRecentlyUsedModules(1000).then( res => {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise succeeded');
for (let i = 0; i < res.length; i++) {
@@ -223,7 +235,7 @@ import stats from '@ohos.bundleState';
console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise failed, because: ' + err.code);
});
- // Use a promise to return the result when maxNum is not specified.
+ // Promise mode when maxNum is not specified
stats.getRecentlyUsedModules().then( res => {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise succeeded');
for (let i = 0; i < res.length; i++) {
@@ -234,7 +246,7 @@ import stats from '@ohos.bundleState';
console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise failed, because: ' + err.code);
});
- // Use an asynchronous callback to return the result.
+ // Asynchronous callback mode
stats.getRecentlyUsedModules(1000,(err, res) => {
if(err) {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules callback failed, because: ' + err.code);
@@ -247,7 +259,7 @@ import stats from '@ohos.bundleState';
}
});
- // Use an asynchronous callback to return the result when maxNum is not specified.
+ // Asynchronous callback mode when maxNum is not specified
stats.getRecentlyUsedModules((err, res) => {
if(err) {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules callback failed, because: ' + err.code);
@@ -260,3 +272,168 @@ import stats from '@ohos.bundleState';
}
});
```
+
+9. Query the number of notifications from all applications based on the specified start time and end time. This requires the **ohos.permission.BUNDLE_ACTIVE_INFO** permission to be configured in the **config.json** file.
+
+ ```js
+ import stats from '@ohos.bundleState'
+
+ // Promise mode
+ stats.queryAppNotificationNumber(0, 20000000000000).then( res => {
+ console.log('BUNDLE_ACTIVE queryAppNotificationNumber promise success.');
+ console.log('BUNDLE_ACTIVE queryAppNotificationNumber promise result ' + JSON.stringify(res));
+ }).catch( err => {
+ console.log('BUNDLE_ACTIVE queryAppNotificationNumber promise failed, because: ' + err.code);
+ });
+
+ // Asynchronous callback mode
+ stats.queryAppNotificationNumber(0, 20000000000000, (err, res) => {
+ if (err) {
+ console.log('BUNDLE_ACTIVE queryAppNotificationNumber callback failed, because: ' + err.code);
+ } else {
+ console.log('BUNDLE_ACTIVE queryAppNotificationNumber callback success.');
+ console.log('BUNDLE_ACTIVE queryAppNotificationNumber callback result ' + JSON.stringify(res));
+ }
+ });
+ ```
+
+10. Query statistics about system events (hibernation, wakeup, unlocking, and screen locking) that occur between the specified start time and end time. This requires the **ohos.permission.BUNDLE_ACTIVE_INFO** permission to be configured in the **config.json** file.
+
+ ```js
+ import stats from '@ohos.bundleState'
+
+ // Promise mode
+ stats.queryBundleActiveEventStates(0, 20000000000000).then( res => {
+ console.log('BUNDLE_ACTIVE queryBundleActiveEventStates promise success.');
+ console.log('BUNDLE_ACTIVE queryBundleActiveEventStates promise result ' + JSON.stringify(res));
+ }).catch( err => {
+ console.log('BUNDLE_ACTIVE queryBundleActiveEventStates promise failed, because: ' + err.code);
+ });
+
+ // Asynchronous callback mode
+ stats.queryBundleActiveEventStates(0, 20000000000000, (err, res) => {
+ if (err) {
+ console.log('BUNDLE_ACTIVE queryBundleActiveEventStates callback failed, because: ' + err.code);
+ } else {
+ console.log('BUNDLE_ACTIVE queryBundleActiveEventStates callback success.');
+ console.log('BUNDLE_ACTIVE queryBundleActiveEventStates callback result ' + JSON.stringify(res));
+ }
+ });
+ ```
+
+11. Query the priority group of the current application. This requires no permission to be configured in the **config.json** file. Query the priority group of a specified application. This requires the **ohos.permission.BUNDLE_ACTIVE_INFO** permission to be configured in the **config.json** file.
+
+ ```js
+ import stats from '@ohos.bundleState'
+
+ // Promise mode without parameters
+ stats.queryAppUsagePriorityGroup().then( res => {
+ console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup promise succeeded. result: ' + JSON.stringify(res));
+ }).catch( err => {
+ console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup promise failed. because: ' + err.code);
+ });
+
+ // Asynchronous callback mode without parameters
+ stats.queryAppUsagePriorityGroup((err, res) => {
+ if (err) {
+ console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup callback failed. because: ' + err.code);
+ } else {
+ console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup callback succeeded. result: ' + JSON.stringify(res));
+ }
+ });
+
+ // Promise mode with parameters
+ stats.queryAppUsagePriorityGroup(this.bundleName).then( res => {
+ console.log('BUNDLE_ACTIVE QueryPackageGroup promise succeeded. result: ' + JSON.stringify(res));
+ }).catch( err => {
+ console.log('BUNDLE_ACTIVE QueryPackageGroup promise failed. because: ' + err.code);
+ });
+
+ // Asynchronous callback mode with parameters
+ stats.queryAppUsagePriorityGroup(this.bundleName, (err, res) => {
+ if(err) {
+ console.log('BUNDLE_ACTIVE QueryPackageGroup callback failed. because: ' + err.code);
+ } else {
+ console.log('BUNDLE_ACTIVE QueryPackageGroup callback succeeded. result: ' + JSON.stringify(res));
+ }
+ });
+ ```
+
+11. Set the group for the application specified by **bundleName**.
+
+ ```javascript
+ import stats from '@ohos.bundleState'
+
+ // Promise mode
+ stats.setBundleGroup(this.bundleName, this.newGroup).then( () => {
+ console.log('BUNDLE_ACTIVE SetBundleGroup promise succeeded.');
+ }).catch( err => {
+ console.log('BUNDLE_ACTIVE SetBundleGroup promise failed. because: ' + err.code);
+ });
+ // Asynchronous callback mode
+ stats.setBundleGroup(this.bundleName, this.newGroup, (err) => {
+ if(err) {
+ console.log('BUNDLE_ACTIVE SetBundleGroup callback failed. because: ' + err.code);
+ } else {
+ console.log('BUNDLE_ACTIVE SetBundleGroup callback succeeded.');
+ }
+ });
+ ```
+
+12. Register a callback for application group changes. When an application group of the user changes, the change is returned to all applications that have registered the callback.
+
+ ```javascript
+ import stats from '@ohos.bundleState'
+
+ // Promise mode
+ let onBundleGroupChanged = (err,res) =>{
+ console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack callback success.');
+ console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result oldGroup is : ' + res.oldGroup);
+ console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result newGroup is : ' + res.newGroup);
+ console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result changeReason is : ' + res.newGroup);
+ console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result userId is : ' + res.userId);
+ console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result bundleName is : ' + res.bundleName);
+ };
+ stats.registerGroupCallBack(onBundleGroupChanged).then( () => {
+ console.log('BUNDLE_ACTIVE RegisterGroupCallBack promise succeeded.');
+ }).catch( err => {
+ console.log('BUNDLE_ACTIVE RegisterGroupCallBack promise failed. because: ' + err.code);
+ });
+ // Asynchronous callback mode
+ let onBundleGroupChanged = (err,res) =>{
+ console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack callback success.');
+ console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result's oldGroup is : ' + res.oldGroup);
+ console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result's newGroup is : ' + res.newGroup);
+ console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result's changeReason is : ' + res.newGroup);
+ console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result's userId is : ' + res.userId);
+ console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result's bundleName is : ' + res.bundleName);
+ };
+ stats.registerGroupCallBack(onBundleGroupChanged, (err)=>{
+ if(err) {
+ console.log('BUNDLE_ACTIVE RegisterGroupCallBack callback failed, because: ' + err.code);
+ } else {
+ console.log('BUNDLE_ACTIVE RegisterGroupCallBack callback success.');
+ }
+ });
+ ```
+
+13. Deregister the callback for application group changes.
+
+ ```javascript
+ import stats from '@ohos.bundleState'
+
+ //promise
+ stats.unRegisterGroupCallBack().then( () => {
+ console.log('BUNDLE_ACTIVE UnRegisterGroupCallBack promise succeeded.');
+ }).catch( err => {
+ console.log('BUNDLE_ACTIVE UnRegisterGroupCallBack promise failed. because: ' + err.code);
+ });
+ //callback
+ stats.unRegisterGroupCallBack((err)=>{
+ if(err) {
+ console.log('BUNDLE_ACTIVE UnRegisterGroupCallBack callback failed, because: ' + err.code);
+ } else {
+ console.log('BUNDLE_ACTIVE UnRegisterGroupCallBack callback success.');
+ }
+ });
+ ```
diff --git a/en/application-dev/device-usage-statistics/device-usage-statistics-overview.md b/en/application-dev/device-usage-statistics/device-usage-statistics-overview.md
index 696a32c18ca974da852fa8600d126ca692d81f7d..e9d669f7973dce4360c617a6872fa3c86adf481f 100644
--- a/en/application-dev/device-usage-statistics/device-usage-statistics-overview.md
+++ b/en/application-dev/device-usage-statistics/device-usage-statistics-overview.md
@@ -12,22 +12,29 @@ Currently you can have access to statistics on the application usage, and notifi
3. Upon start of a new day
- **The application usage statistics can include the following**:
-1. Events of all applications based on the specified start time and end time
+1. Events of all applications based on the specified start time and end time
+2. Application usage duration statistics based on the specified start time and end time
+3. Events of the current application based on the specified start time and end time
+4. Application usage duration statistics in the specified time frame at the specified interval (daily, weekly, monthly, or annually)
+5. Priority group of the current invoker application
+6. Whether a specific application is in the idle state
+7. Number of FA usage records specified by **maxNum**, sorted by time (most recent first). If **maxNum** is not specified, the default value **1000** will be used.
+8. Number of notifications from applications based on the specified start time and end time
+9. Statistics about system events (hibernation, wakeup, unlocking, and screen locking) that occur between the specified start time and end time
+9. Priority group of the invoker application or a specified application
-2. Application usage duration statistics based on the specified start time and end time
+- **The setters can be used to:**
-3. Events of the current application based on the specified start time and end time
+ Set the group for the application specified by **bundleName**.
-4. Application usage duration statistics in the specified time frame at the specified interval (daily, weekly, monthly, or annually)
+- **The registration APIs can be used to:**
-5. Priority group of the current invoker application
+ Register a callback for application group changes. When an application group of the user changes, the change is returned to all applications that have registered the callback.
-6. Whether a specific application is in the idle state
+- **The deregistration APIs can be used to:**
-7. The number of FA usage records specified by **maxNum**, sorted by time (most recent first)
-
- If **maxNum** is not specified, the default value **1000** will be used.
+ Deregister the callback for application group changes.
### Required Permissions
-- The **queryBundleActiveStates**, **queryBundleStateInfos**, and **queryBundleStateInfoByInterval** APIs used for device usage statistics are system APIs. Before calling these APIs, you need to apply for the **ohos.permission.BUNDLE_ACTIVE_INFO** permission.
-- This permission is not required for calling **queryCurrentBundleActiveStates**, **queryAppUsagePriorityGroup**, and **isIdleState**, which are third-party APIs.
+- Before calling the following system APIs, you need to apply for the **ohos.permission.BUNDLE_ACTIVE_INFO** permission: **queryBundleActiveStates**, **queryBundleStateInfos**, **queryBundleStateInfoByInterval**, **queryBundleActiveEventStates**, **queryAppNotificationNumber**, **queryAppUsagePriorityGroup(bundleName?)**, **setBundleGroup**, **registerGroupCallBack**, and **unRegisterGroupCallBack**.
+- This permission is not required for calling third-party APIs: **queryCurrentBundleActiveStates**, **queryAppUsagePriorityGroup()**, and **isIdleState**.
diff --git a/en/application-dev/device/Readme-EN.md b/en/application-dev/device/Readme-EN.md
index 41f8cf0de280706eff7ae88c051d50d18630f173..c006438a34418139129e23f475d059e274ca914d 100644
--- a/en/application-dev/device/Readme-EN.md
+++ b/en/application-dev/device/Readme-EN.md
@@ -13,6 +13,6 @@
- Vibrator
- [Vibrator Overview](vibrator-overview.md)
- [Vibrator Development](vibrator-guidelines.md)
-- Update Servcie
+- Update Service
- [Sample Server Overview](sample-server-overview.md)
- [Sample Server Development](sample-server-guidelines.md)
diff --git a/en/application-dev/device/device-location-info.md b/en/application-dev/device/device-location-info.md
index 25d539a79c431159bd0e2816ace8f658d29c8ead..84f189d7f247bd9516204c7dd0d76aafb6438dbb 100644
--- a/en/application-dev/device/device-location-info.md
+++ b/en/application-dev/device/device-location-info.md
@@ -12,7 +12,7 @@ Real-time location of the device is recommended for location-sensitive services.
The following table describes APIs available for obtaining device location information.
- **Table1** APIs for obtaining device location information
+ **Table 1** APIs for obtaining device location information
| API | Description |
| -------- | -------- |
@@ -54,7 +54,9 @@ The following table describes APIs available for obtaining device location infor
## How to Develop
-1. Before using basic location capabilities, check whether your application has been granted the permission to access the device location information. If not, your application needs to obtain the permission from the user. For details, see .
+To learn more about the APIs for obtaining device location information, see [Geolocation](../reference/apis/js-apis-geolocation.md).
+
+1. Before using basic location capabilities, check whether your application has been granted the permission to access the device location information. If not, your application needs to obtain the permission from the user. For details, see the following section.
The system provides the following location permissions:
- ohos.permission.LOCATION
@@ -108,7 +110,7 @@ The following table describes APIs available for obtaining device location infor
```
- **Table2** Common use cases of the location function
+ **Table 2** Common use cases of the location function
| Use Case | Constant | Description |
| -------- | -------- | -------- |
@@ -139,7 +141,7 @@ The following table describes APIs available for obtaining device location infor
```
- **Table3** Location priority policies
+ **Table 3** Location priority policies
| Policy | Constant | Description |
| -------- | -------- | -------- |
@@ -174,7 +176,7 @@ The following table describes APIs available for obtaining device location infor
geolocation.off('locationChange', locationChange);
```
- If your application does not need the real-time device location, it can use the last known device location cached in the system instead.
+ If your application does not need the real-time device location, it can use the last known device location cached in the system instead.
```
geolocation.getLastLocation((data) => {
diff --git a/en/application-dev/device/usb-guidelines.md b/en/application-dev/device/usb-guidelines.md
index 8476e88dc8ea1bf774b70991545dbd1d5f3620fe..37b2ed13a6285096b0c6683851c39b85e519ad4d 100644
--- a/en/application-dev/device/usb-guidelines.md
+++ b/en/application-dev/device/usb-guidelines.md
@@ -8,7 +8,7 @@ In Host mode, you can obtain the list of connected devices, enable or disable th
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-usb.md).
+The following table lists the USB APIs currently available. For details, see the [API Reference](../reference/apis/js-apis-usb.md).
**Table 1** Open USB APIs
@@ -21,7 +21,7 @@ The following table lists the USB APIs currently available. For details, see the
| setConfiguration(pipe: USBDevicePipe, config: USBConfig): 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 |
-| function bulkTransfer(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, timeout?: number): Promise\ | Performs bulk transfer. |
+| 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. |
diff --git a/en/application-dev/device/vibrator-guidelines.md b/en/application-dev/device/vibrator-guidelines.md
index f0eb8c5f896ae881550aeae85759692fd052c2ce..b8d201c22ed514ca0047b73b50e9f2184cf0587c 100644
--- a/en/application-dev/device/vibrator-guidelines.md
+++ b/en/application-dev/device/vibrator-guidelines.md
@@ -8,20 +8,20 @@ You can set different vibration effects as needed, for example, customizing the
## Available APIs
- | Module| API| Description|
-| -------- | -------- | -------- |
-| ohos.vibrator | vibrate(duration: number): Promise<void> | Triggers vibration with the specified duration. This API uses a promise to return the result.|
-| ohos.vibrator | vibrate(duration: number, callback?: AsyncCallback<void>): void | Triggers vibration with the specified duration. This API uses a callback to return the result.|
-| ohos.vibrator | vibrate(effectId: EffectId): Promise<void> | Triggers vibration with the specified effect. This API uses a promise to return the result.|
-| ohos.vibrator | vibrate(effectId: EffectId, callback?: AsyncCallback<void>): void | Triggers vibration with the specified effect. This API uses a callback to return the result.|
-| ohos.vibrator | stop(stopMode: VibratorStopMode): Promise<void> | Stops vibration. This API uses a promise to return the result.|
-| ohos.vibrator | stop(stopMode: VibratorStopMode, callback?: AsyncCallback<void>): void | Stops vibration. This API uses a callback to return the result.|
+| Module | API | Description |
+| ------------- | ---------------------------------------- | ------------------------------- |
+| ohos.vibrator | vibrate(duration: number): Promise<void> | Triggers vibration with the specified duration. This API uses a promise to return the result. |
+| ohos.vibrator | vibrate(duration: number, callback?: AsyncCallback<void>): void | Triggers vibration with the specified duration. This API uses a callback to return the result. |
+| ohos.vibrator | vibrate(effectId: EffectId): Promise<void> | Triggers vibration with the specified effect. This API uses a promise to return the result. |
+| ohos.vibrator | vibrate(effectId: EffectId, callback?: AsyncCallback<void>): void | Triggers vibration with the specified effect. This API uses a callback to return the result.|
+| ohos.vibrator | stop(stopMode: VibratorStopMode): Promise<void> | Stops vibration. This API uses a promise to return the result. |
+| ohos.vibrator | stop(stopMode: VibratorStopMode, callback?: AsyncCallback<void>): void | Stops vibration. This API uses a callback to return the result. |
## How to Develop
1. Declare the permissions required for controlling vibrators on the hardware device in the `config.json` file.
-
+
```
"reqPermissions": [
{
@@ -58,7 +58,7 @@ You can set different vibration effects as needed, for example, customizing the
```
2. Trigger the device to vibrate.
-
+
```
import vibrator from "@ohos.vibrator"
vibrator.vibrate(1000).then((error)=>{
@@ -71,7 +71,7 @@ You can set different vibration effects as needed, for example, customizing the
```
3. Stop the vibration.
-
+
```
import vibrator from "@ohos.vibrator"
vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET).then((error)=>{
diff --git a/en/application-dev/internationalization/i18n-guidelines.md b/en/application-dev/internationalization/i18n-guidelines.md
index 4aa32c4ea6c69775867d86747b56e3ee17c8ec7b..244734770314757986733edc03b597894aa8e75e 100644
--- a/en/application-dev/internationalization/i18n-guidelines.md
+++ b/en/application-dev/internationalization/i18n-guidelines.md
@@ -4,7 +4,7 @@ This development guide describes how to use i18n APIs that are not defined in EC
## Obtaining System Language and Region Information
-APIs are provided to access the system language and region information.
+You can use APIs provided in the following table to obtain the system language and region information.
### Available APIs
@@ -17,7 +17,7 @@ APIs are provided to access the system language and region information.
| ohos.i18n | isRTL(locale: string): boolean7+ | Checks whether the locale uses a right-to-left (RTL) language. |
| ohos.i18n | is24HourClock(): boolean7+ | Checks whether the system uses a 24-hour clock. |
| ohos.i18n | getDisplayLanguage(language: string, locale: string, sentenceCase?: boolean): string | Obtains the localized display of a language. |
-| ohos.i18n | getDisplayCountry(country: string, locale: string, sentenceCase?: boolean): string | Obtains the localized display of a country. |
+| ohos.i18n | getDisplayCountry(country: string, locale: string, sentenceCase?: boolean): string | Obtains the localized display of a country name. |
### How to Develop
@@ -70,7 +70,7 @@ APIs are provided to access the system language and region information.
```
7. Obtain the localized display of a country.
- Call the **getDisplayCountry** method to obtain the localized display of a country. **country** indicates the country to be localized, **locale** indicates the locale, and **sentenceCase** indicates whether the first letter of the result must be capitalized.
+ Call the **getDisplayCountry** method to obtain the localized display of a country name. **country** indicates the country code (a two-letter code in compliance with ISO-3166, for example, CN), **locale** indicates the locale, and **sentenceCase** indicates whether the first letter of the result must be capitalized.
```
var country = "US";
@@ -344,14 +344,14 @@ When a text is displayed in more than one line, [BreakIterator](../reference/api
```
- var firstPos = breakIterator.first(); // Sets a BreakIterator object to the first break point, that is, the start position of the text.
- var lastPos = breakIterator.last(); // Sets a BreakIterator object to the last break point, that is, the position after the text end.
- // Moves a BreakIterator object forward or backward by a certain number of break points.
+ var firstPos = breakIterator.first(); // Set a BreakIterator object to the first break point, that is, the start position of the text.
+ var lastPos = breakIterator.last(); // Set a BreakIterator object to the last break point, that is, the position after the text end.
+ // Move a BreakIterator object forward or backward by a certain number of break points.
// If a positive number is input, move backward. If a negative number is input, move forward. If no value is input, move one position backward.
// When the object is moved out of the text length range, -1 is returned.
var nextPos = breakIterator.next(-2);
- var previousPos = breakIterator.previous(); // Moves a BreakIterator object to the previous break point. When the text length is out of the range, -1 is returned.
- // Moves a BreakIterator object to the break point following the position specified by offset. If the object is moved out of the text length range, -1 is returned.
+ var previousPos = breakIterator.previous(); // Move a BreakIterator object to the previous break point. When the text length is out of the range, -1 is returned.
+ // Move a BreakIterator object to the break point following the position specified by offset. If the object is moved out of the text length range, -1 is returned.
var followingPos = breakIterator.following(10);
```
diff --git a/en/application-dev/internationalization/intl-guidelines.md b/en/application-dev/internationalization/intl-guidelines.md
index a27df95ea9c9657c30401b1fd1ad9d9b21d77fca..9eceb50b876b05c960518ff554f65ec09963c0c9 100644
--- a/en/application-dev/internationalization/intl-guidelines.md
+++ b/en/application-dev/internationalization/intl-guidelines.md
@@ -26,6 +26,20 @@ Use [Locale](../reference/apis/js-apis-intl.md) APIs to maximize or minimize loc
1. Instantiate a **Locale** object.
Create a **Locale** object by using the **Locale** constructor. This method receives a string representing the locale and an optional [Attributes](../reference/apis/js-apis-intl.md) list.
+ A **Locale** object consists of four parts: language, script, region, and extension, which are separated by using a hyphen (-).
+ - Language: mandatory. It is represented by a two-letter or three-letter code as defined in ISO-639. For example, **en** indicates English and **zh** indicates Chinese.
+ - Script: optional. It is represented by a four-letter code as defined in ISO-15924. The first letter is in uppercase, and the remaining three letters are in lowercase. For example, **Hant** represents the traditional Chinese, and **Hans** represents the simplified Chinese.
+ - Country or region: optional. It is represented by two-letter code as defined in ISO-3166. Both letters are in uppercase. For example, **CN** represents China, and **US** represents the United States.
+ - Extensions: optional. Each extension consists of two parts, key and value. Currently, the extensions listed in the following table are supported (see BCP 47 Extensions). Extensions can be in any sequence and are written in the format of **-key-value**. They are appended to the language, script, and region by using **-u**. For example, **zh-u-nu-latn-ca-chinese** indicates that the Latin numbering system and Chinese calendar system are used. Extensions can also be passed via the second parameter.
+ | Extended Parameter ID| Description|
+ | -------- | -------- |
+ | ca | Calendar algorithm.|
+ | co | Collation type.|
+ | hc | Hour cycle.|
+ | nu | Numbering system.|
+ | kn | Whether numeric collation is used when sorting or comparing strings.|
+ | kf | Whether upper case or lower case is considered when sorting or comparing strings.|
+
```
var locale = "zh-CN";
@@ -89,7 +103,7 @@ Use [DateTimeFormat](../reference/apis/js-apis-intl.md) APIs to format the date
```
2. Format the date and time.
- Call the **format** method to format a **Date** object. This method returns a string representing the formatting result.
+ Call the **format** method to format the date and time in the **DateTimeFormat** object. This method returns a string representing the formatting result.
```
Date date = new Date();
@@ -97,7 +111,7 @@ Use [DateTimeFormat](../reference/apis/js-apis-intl.md) APIs to format the date
```
3. Format a period.
- Call the **formatRange** method to format a period. This method requires input of two **Date** objects, which respectively indicate the start date and end date of a period. This method returns a string representing the formatting result.
+ Call the **formatRange** method to format the period in the **DateTimeFormat** object. This method requires input of two **Date** objects, which respectively indicate the start date and end date of a period. This method returns a string representing the formatting result.
```
Date startDate = new Date();
@@ -113,9 +127,9 @@ Use [DateTimeFormat](../reference/apis/js-apis-intl.md) APIs to format the date
```
-## Number Formatting
+## Formatting Numbers
-Use [NumberFormat](../reference/apis/js-apis-intl.md) APIs to format a number for a specific locale.
+Use [NumberFormat](../reference/apis/js-apis-intl.md) APIs to format numbers for a specific locale.
### Available APIs
@@ -161,7 +175,7 @@ Use [NumberFormat](../reference/apis/js-apis-intl.md) APIs to format a number fo
```
-## String Sorting
+## Sorting Strings
Use [Collator](../reference/apis/js-apis-intl.md) APIs to sort strings based on a specific locale. Users in different regions have different preferences for string sorting.
@@ -248,7 +262,7 @@ Use [PluralRules](../reference/apis/js-apis-intl.md) APIs to determine the singu
```
-## Formatting Relative Time
+## Formatting the Relative Time
Use [RelativeTimeFormat](../reference/apis/js-apis-intl.md) APIs to format the relative time for a specific locale.
diff --git a/en/application-dev/media/audio-overview.md b/en/application-dev/media/audio-overview.md
index c313e9315eb46c440efb116e318148a666d44012..e1fd93eab8238b8ae55c9ce3dff2e807a1585a00 100755
--- a/en/application-dev/media/audio-overview.md
+++ b/en/application-dev/media/audio-overview.md
@@ -1,30 +1,20 @@
-# Audio Overview
+# Audio Overview
You can use APIs provided by the audio module to implement audio-related features, including audio playback and volume management.
-> **NOTE**
->Due to permission issues, the above features are temporarily unavailable for the standard system.
+## Basic Concepts
-## Basic Concepts
+- **Sampling**
+ Sampling is a process to obtain discrete-time signals by extracting samples from analog signals in a continuous time domain at a specific interval.
-- **Sampling**
+- **Sampling rate**
+ Sampling rate is the number of samples extracted from a continuous signal per second to form a discrete signal. It is measured in Hz. Generally, human hearing range is from 20 Hz to 20 kHz. Common audio sampling rates include 8 kHz, 11.025 kHz, 22.05 kHz, 16 kHz, 37.8 kHz, 44.1 kHz, 48 kHz, 96 kHz, and 192 kHz.
- Sampling is a process to obtain discrete-time signals by extracting samples from analog signals in a continuous time domain at a specific interval.
-
-- **Sampling rate**
-
- Sampling rate is the number of samples extracted from a continuous signal per second to form a discrete signal. It is measured in Hz. Generally, human hearing range is from 20 Hz to 20 kHz. Common audio sampling rates include 8 kHz, 11.025 kHz, 22.05 kHz, 16 kHz, 37.8 kHz, 44.1 kHz, 48 kHz, 96 kHz, and 192 kHz.
-
-- **Channel**
-
- Channels refer to different spatial positions where independent audio signals are recorded or played. The number of channels is the number of audio sources used during audio recording, or the number of speakers used for audio playback.
-
-- **Audio frame**
-
- Audio data is in stream form. For the convenience of audio algorithm processing and transmission, it is generally agreed that a data amount in a unit of 2.5 to 60 milliseconds is one audio frame. This unit is called sampling time, and its length is specific to codecs and the application requirements.
-
-- **PCM**
-
- Pulse code modulation \(PCM\) is a method used to digitally represent sampled analog signals. It converts continuous-time analog signals into discrete-time digital signal samples.
+- **Channel**
+ Channels refer to different spatial positions where independent audio signals are recorded or played. The number of channels is the number of audio sources used during audio recording, or the number of speakers used for audio playback.
+- **Audio frame**
+ Audio data is in stream form. For the convenience of audio algorithm processing and transmission, it is generally agreed that a data amount in a unit of 2.5 to 60 milliseconds is one audio frame. This unit is called sampling time, and its length is specific to codecs and the application requirements.
+- **PCM**
+ Pulse code modulation (PCM) is a method used to digitally represent sampled analog signals. It converts continuous-time analog signals into discrete-time digital signal samples.
diff --git a/en/application-dev/media/audio-playback.md b/en/application-dev/media/audio-playback.md
index c8dabdf0bea89476f3ff9d81392d2d0d1ee4dc28..cabf6a85c3638656585ff7e315701408c12467bc 100644
--- a/en/application-dev/media/audio-playback.md
+++ b/en/application-dev/media/audio-playback.md
@@ -256,7 +256,8 @@ export class AudioDemo {
The following samples are provided to help you better understand how to develop audio playback:
-- [JsDistributedMusicPlayer: Distributed Music Player (JS, API version 7)](https://gitee.com/openharmony/app_samples/tree/master/ability/JsDistributedMusicPlayer)
-- [JsAudioPlayer: Audio Playback and Management (JS, API version 7)](https://gitee.com/openharmony/app_samples/tree/master/media/JsAudioPlayer)
-- [eTsAudioPlayer: Audio Player (eTS)](https://gitee.com/openharmony/app_samples/blob/master/media/Recorder/entry/src/main/ets/MainAbility/pages/Play.ets)
+- [`JsDistributedMusicPlayer`: Distributed Music Player (JS, API version 7)](https://gitee.com/openharmony/app_samples/tree/master/ability/JsDistributedMusicPlayer)
+- [`JsAudioPlayer`: Audio Playback and Management (JS, API version 7)](https://gitee.com/openharmony/app_samples/tree/master/media/JsAudioPlayer)
+- [`eTsAudioPlayer`: Audio Player (eTS)](https://gitee.com/openharmony/app_samples/blob/master/media/Recorder/entry/src/main/ets/MainAbility/pages/Play.ets)
- [Audio Player](https://gitee.com/openharmony/codelabs/tree/master/Media/Audio_OH_ETS)
+
diff --git a/en/application-dev/media/audio-recorder.md b/en/application-dev/media/audio-recorder.md
index d24ee72f4a322e44734a0eb7a70ca04d11dc8994..fa43dff19c7488520dd459d53ae326739cdb0fef 100644
--- a/en/application-dev/media/audio-recorder.md
+++ b/en/application-dev/media/audio-recorder.md
@@ -190,7 +190,8 @@ export class AudioRecorderDemo {
The following samples are provided to help you better understand how to develop audio recording:
-- [Recorder: Recorder (eTS, API version 8)](https://gitee.com/openharmony/app_samples/tree/master/media/Recorder)
-- [JsRecorder: Recorder (JS, API version 8)](https://gitee.com/openharmony/app_samples/tree/master/media/JSRecorder)
-- [eTsAudioPlayer: Audio Player (eTS)](https://gitee.com/openharmony/app_samples/blob/master/media/Recorder/entry/src/main/ets/MainAbility/pages/Play.ets)
+- [`Recorder`: Recorder (eTS, API version 8)](https://gitee.com/openharmony/app_samples/tree/master/media/Recorder)
+- [`JsRecorder`: Recorder (JS, API version 8)](https://gitee.com/openharmony/app_samples/tree/master/media/JSRecorder)
+- [`eTsAudioPlayer`: Audio Player (eTS)](https://gitee.com/openharmony/app_samples/blob/master/media/Recorder/entry/src/main/ets/MainAbility/pages/Play.ets)
- [Audio Player](https://gitee.com/openharmony/codelabs/tree/master/Media/Audio_OH_ETS)
+
diff --git a/en/application-dev/media/audio-renderer.md b/en/application-dev/media/audio-renderer.md
index 8e2be849396373aaa68ee7c4eb5e36a4cad28c1c..82a0753b66384e6f1a991ba97f7d6c7580936e0e 100644
--- a/en/application-dev/media/audio-renderer.md
+++ b/en/application-dev/media/audio-renderer.md
@@ -20,8 +20,6 @@ During application development, you are advised to use **on('stateChange')** to
To ensure that the UI thread is not blocked, most **AudioRenderer** calls are asynchronous. Each API provides the callback and promise functions. The following examples use the promise functions. For more information, see [AudioRenderer in Audio Management](../reference/apis/js-apis-audio.md#audiorenderer8).
-
-
## How to Develop
1. Use **createAudioRenderer()** to create an **AudioRenderer** instance.
@@ -31,7 +29,7 @@ To ensure that the UI thread is not blocked, most **AudioRenderer** calls are as
var audioStreamInfo = {
samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100,
channels: audio.AudioChannel.CHANNEL_1,
- sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE,
+ sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE,
encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW
}
@@ -58,49 +56,49 @@ To ensure that the UI thread is not blocked, most **AudioRenderer** calls are as
In the case of audio interruption, the application may encounter write failures. To avoid such failures, interruption unaware applications can use **audioRenderer.state** to check the renderer state before writing audio data. The applications can obtain more details by subscribing to the audio interruption events. For details, see [InterruptEvent](../reference/apis/js-apis-audio.md#interruptevent9).
```js
- audioRenderer.on('interrupt', (interruptEvent) => {
- console.info('InterruptEvent Received');
- console.info('InterruptType: ' + interruptEvent.eventType);
- console.info('InterruptForceType: ' + interruptEvent.forceType);
- console.info('AInterruptHint: ' + interruptEvent.hintType);
-
- if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_FORCE) {
- switch (interruptEvent.hintType) {
- // Force Pause: Action was taken by framework.
- // Halt the write calls to avoid data loss.
- case audio.InterruptHint.INTERRUPT_HINT_PAUSE:
- isPlay = false;
- break;
- // Force Stop: Action was taken by framework.
- // Halt the write calls to avoid data loss.
- case audio.InterruptHint.INTERRUPT_HINT_STOP:
- isPlay = false;
- break;
- // Force Duck: Action was taken by framework,
- // just notifying the app that volume has been reduced.
- case audio.InterruptHint.INTERRUPT_HINT_DUCK:
- break;
- // Force Unduck: Action was taken by framework,
- // just notifying the app that volume has been restored.
- case audio.InterruptHint.INTERRUPT_HINT_UNDUCK:
- break;
- }
- } else if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_SHARE) {
- switch (interruptEvent.hintType) {
- // Share Resume: Action is to be taken by App.
- // Resume the force paused stream if required.
- case audio.InterruptHint.INTERRUPT_HINT_RESUME:
- startRenderer();
- break;
- // Share Pause: Stream has been interrupted,
- // It can choose to pause or play concurrently.
- case audio.InterruptHint.INTERRUPT_HINT_PAUSE:
- isPlay = false;
- pauseRenderer();
- break;
- }
- }
- });
+ audioRenderer.on('interrupt', (interruptEvent) => {
+ console.info('InterruptEvent Received');
+ console.info('InterruptType: ' + interruptEvent.eventType);
+ console.info('InterruptForceType: ' + interruptEvent.forceType);
+ console.info('AInterruptHint: ' + interruptEvent.hintType);
+
+ if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_FORCE) {
+ switch (interruptEvent.hintType) {
+ // Force Pause: Action was taken by framework.
+ // Halt the write calls to avoid data loss.
+ case audio.InterruptHint.INTERRUPT_HINT_PAUSE:
+ isPlay = false;
+ break;
+ // Force Stop: Action was taken by framework.
+ // Halt the write calls to avoid data loss.
+ case audio.InterruptHint.INTERRUPT_HINT_STOP:
+ isPlay = false;
+ break;
+ // Force Duck: Action was taken by framework,
+ // just notifying the app that volume has been reduced.
+ case audio.InterruptHint.INTERRUPT_HINT_DUCK:
+ break;
+ // Force Unduck: Action was taken by framework,
+ // just notifying the app that volume has been restored.
+ case audio.InterruptHint.INTERRUPT_HINT_UNDUCK:
+ break;
+ }
+ } else if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_SHARE) {
+ switch (interruptEvent.hintType) {
+ // Share Resume: Action is to be taken by App.
+ // Resume the force paused stream if required.
+ case audio.InterruptHint.INTERRUPT_HINT_RESUME:
+ startRenderer();
+ break;
+ // Share Pause: Stream has been interrupted,
+ // It can choose to pause or play concurrently.
+ case audio.InterruptHint.INTERRUPT_HINT_PAUSE:
+ isPlay = false;
+ pauseRenderer();
+ break;
+ }
+ }
+ });
```
3. Use **start()** to start audio rendering.
@@ -178,38 +176,38 @@ To ensure that the UI thread is not blocked, most **AudioRenderer** calls are as
5. (Optional) Call **pause()** or **stop()** to pause or stop rendering.
```js
- async function pauseRenderer() {
- var state = audioRenderer.state;
- if (state != audio.AudioState.STATE_RUNNING) {
- console.info('Renderer is not running');
- return;
- }
-
- await audioRenderer.pause();
-
- state = audioRenderer.state;
- if (state == audio.AudioState.STATE_PAUSED) {
- console.info('Renderer paused');
- } else {
- console.error('Renderer pause failed');
- }
- }
-
- async function stopRenderer() {
- var state = audioRenderer.state;
- if (state != audio.AudioState.STATE_RUNNING || state != audio.AudioState.STATE_PAUSED) {
- console.info('Renderer is not running or paused');
- return;
- }
-
- await audioRenderer.stop();
+ async function pauseRenderer() {
+ var state = audioRenderer.state;
+ if (state != audio.AudioState.STATE_RUNNING) {
+ console.info('Renderer is not running');
+ return;
+ }
+
+ await audioRenderer.pause();
+
+ state = audioRenderer.state;
+ if (state == audio.AudioState.STATE_PAUSED) {
+ console.info('Renderer paused');
+ } else {
+ console.error('Renderer pause failed');
+ }
+ }
- state = audioRenderer.state;
- if (state == audio.AudioState.STATE_STOPPED) {
- console.info('Renderer stopped');
- } else {
- console.error('Renderer stop failed');
- }
+ async function stopRenderer() {
+ var state = audioRenderer.state;
+ if (state != audio.AudioState.STATE_RUNNING || state != audio.AudioState.STATE_PAUSED) {
+ console.info('Renderer is not running or paused');
+ return;
+ }
+
+ await audioRenderer.stop();
+
+ state = audioRenderer.state;
+ if (state == audio.AudioState.STATE_STOPPED) {
+ console.info('Renderer stopped');
+ } else {
+ console.error('Renderer stop failed');
+ }
}
```
@@ -218,22 +216,20 @@ To ensure that the UI thread is not blocked, most **AudioRenderer** calls are as
**AudioRenderer** uses a large number of system resources. Therefore, ensure that the resources are released after the task is complete.
```js
- async function releaseRenderer() {
- if (state_ == RELEASED || state_ == NEW) {
- console.info('Resourced already released');
- return;
- }
-
- await audioRenderer.release();
-
- state = audioRenderer.state;
- if (state == STATE_RELEASED) {
- console.info('Renderer released');
- } else {
- console.info('Renderer release failed');
- }
-
- }
- ```
+ async function releaseRenderer() {
+ if (state_ == RELEASED || state_ == NEW) {
+ console.info('Resourced already released');
+ return;
+ }
-
+ await audioRenderer.release();
+
+ state = audioRenderer.state;
+ if (state == STATE_RELEASED) {
+ console.info('Renderer released');
+ } else {
+ console.info('Renderer release failed');
+ }
+
+ }
+ ```
diff --git a/en/application-dev/media/camera.md b/en/application-dev/media/camera.md
index ef72e05d5b7d5b83d827f129c28d8d0574dea74e..5af14112df2959acbcfc606c9cd2938860ad6f85 100644
--- a/en/application-dev/media/camera.md
+++ b/en/application-dev/media/camera.md
@@ -54,16 +54,16 @@ await cameraManager.getCameras((err, cameras) => {
cameraArray = cameras
})
- for(let cameraIndex = 0; cameraIndex < cameraArray.length; cameraIndex) {
- console.log('cameraId : ' + cameraArray[cameraIndex].cameraId) // Obtain the camera ID.
- console.log('cameraPosition : ' + cameraArray[cameraIndex].cameraPosition) // Obtain the camera position.
- console.log('cameraType : ' + cameraArray[cameraIndex].cameraType) // Obtain the camera type.
- console.log('connectionType : ' + cameraArray[cameraIndex].connectionType) // Obtain the camera connection type.
- }
-
- // Create a camera input stream.
- let cameraInput
- await cameraManager.createCameraInput(cameraArray[0].cameraId).then((input) => {
+for(let cameraIndex = 0; cameraIndex < cameraArray.length; cameraIndex) {
+ console.log('cameraId : ' + cameraArray[cameraIndex].cameraId) // Obtain the camera ID.
+ console.log('cameraPosition : ' + cameraArray[cameraIndex].cameraPosition) // Obtain the camera position.
+ console.log('cameraType : ' + cameraArray[cameraIndex].cameraType) // Obtain the camera type.
+ console.log('connectionType : ' + cameraArray[cameraIndex].connectionType) // Obtain the camera connection type.
+}
+
+// Create a camera input stream.
+let cameraInput
+await cameraManager.createCameraInput(cameraArray[0].cameraId).then((input) => {
console.log('Promise returned with the CameraInput instance');
cameraInput = input
})
diff --git a/en/application-dev/media/video-playback.md b/en/application-dev/media/video-playback.md
index 4317e0362769936b16844f22d592e5163dfbcdff..4045cc12c9f198184dce1fd531caa0d783c60ff7 100644
--- a/en/application-dev/media/video-playback.md
+++ b/en/application-dev/media/video-playback.md
@@ -8,13 +8,11 @@ You can use video playback APIs to convert video data into visible signals, play

-
-
**Figure 2** Layer 0 diagram of video playback

-Note: Video playback requires hardware capabilities such as display, audio, and codec.
+*Note: Video playback requires hardware capabilities such as display, audio, and codec.*
1. A third-party application obtains a surface ID from the XComponent.
2. The third-party application transfers the surface ID to the VideoPlayer JS.
@@ -43,9 +41,7 @@ The full video playback process includes creating an instance, setting the URL,
For details about the **url** types supported by **VideoPlayer**, see the [url attribute](../reference/apis/js-apis-media.md#videoplayer_attributes).
-For details about how to create an XComponent, see [XComponent](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/arkui-ts/ts-basic-components-xcomponent.md).
-
-*Note: **setSurface** must be called after the URL is set but before **prepare** is called.
+For details about how to create an XComponent, see [XComponent](../reference/arkui-ts/ts-basic-components-xcomponent.md).
```js
import media from '@ohos.multimedia.media'
@@ -120,7 +116,7 @@ export class VideoPlayerDemo {
console.info('pause success');
}, this.failureCallback).catch(this.catchCallback);
- // Use a promise to obtain the video track information.
+ // Use a promise to obtain the video track information communication_dsoftbus.
let arrayDescription;
await videoPlayer.getTrackDescription().then((arrlist) => {
if (typeof (arrlist) != 'undefined') {
diff --git a/en/application-dev/napi/Readme-EN.md b/en/application-dev/napi/Readme-EN.md
index ebcb811f7886a097c741198f0696b61327cefefb..d5297e9374fdf42b1b50fa2ac6e545fe9766971b 100644
--- a/en/application-dev/napi/Readme-EN.md
+++ b/en/application-dev/napi/Readme-EN.md
@@ -1,6 +1,7 @@
# Native APIs
- [Using Native APIs in Application Projects](napi-guidelines.md)
-
+- [Drawing Development](drawing-guidelines.md)
+- [Native Window Development](native-window-guidelines.md)
- [Raw File Development](rawfile-guidelines.md)
diff --git a/en/application-dev/napi/drawing-guidelines.md b/en/application-dev/napi/drawing-guidelines.md
new file mode 100644
index 0000000000000000000000000000000000000000..e813f84d92d4155e78c9ca651af6a3e3cd010232
--- /dev/null
+++ b/en/application-dev/napi/drawing-guidelines.md
@@ -0,0 +1,208 @@
+# Drawing Development
+
+## When to Use
+
+The Native Drawing module provides APIs for drawing 2D graphics and text. The following scenarios are common for drawing development:
+* Drawing 2D graphics
+* Drawing and painting text
+
+## Available APIs
+
+| API| Description|
+| -------- | -------- |
+| OH_Drawing_BitmapCreate (void) | Creates a bitmap object.|
+| OH_Drawing_BitmapBuild (OH_Drawing_Bitmap *, const uint32_t width, const uint32_t height, const OH_Drawing_BitmapFormat *) | Initializes the width and height of a bitmap object and sets the pixel format for the bitmap.|
+| OH_Drawing_CanvasCreate (void) | Creates a canvas object.|
+| OH_Drawing_CanvasBind (OH_Drawing_Canvas *, OH_Drawing_Bitmap *) | Binds a bitmap to a canvas so that the content drawn on the canvas is output to the bitmap (this process is called CPU rendering).|
+| OH_Drawing_CanvasAttachBrush (OH_Drawing_Canvas *, const OH_Drawing_Brush *) | Attaches a brush to a canvas so that the canvas will use the style and color of the brush to fill in a shape.|
+| OH_Drawing_CanvasAttachPen (OH_Drawing_Canvas *, const OH_Drawing_Pen *) | Attaches a pen to a canvas so that the canvas will use the style and color of the pen to outline a shape.|
+| OH_Drawing_CanvasDrawPath (OH_Drawing_Canvas *, const OH_Drawing_Path *) | Draws a path.|
+| OH_Drawing_PathCreate (void) | Creates a path object.|
+| OH_Drawing_PathMoveTo (OH_Drawing_Path *, float x, float y) | Sets the start point of a path.|
+| OH_Drawing_PathLineTo (OH_Drawing_Path *, float x, float y) | Draws a line segment from the last point of a path to the target point. |
+| OH_Drawing_PathClose (OH_Drawing_Path *) | Closes a path. A line segment from the start point to the last point of the path is added.|
+| OH_Drawing_PenCreate (void) | Creates a pen object.|
+| OH_Drawing_PenSetAntiAlias (OH_Drawing_Pen *, bool) | Checks whether anti-aliasing is enabled for a pen. If anti-aliasing is enabled, edges will be drawn with partial transparency.|
+| OH_Drawing_PenSetWidth (OH_Drawing_Pen *, float width) | Sets the thickness for a pen. This thickness determines the width of the outline of a shape.|
+| OH_Drawing_BrushCreate (void) | Creates a brush object.|
+| OH_Drawing_BrushSetColor (OH_Drawing_Brush *, uint32_t color) | Sets the color for a brush. The color will be used by the brush to fill in a shape.|
+| OH_Drawing_CreateTypographyStyle (void) | Creates a `TypographyStyle` object.|
+| OH_Drawing_CreateTextStyle (void) | Creates a `TextStyle` object.|
+| OH_Drawing_TypographyHandlerAddText (OH_Drawing_TypographyCreate *, const char *) | Sets the text content.|
+| OH_Drawing_TypographyPaint (OH_Drawing_Typography *, OH_Drawing_Canvas *, double, double) | Paints text on the canvas.|
+
+
+
+## Development Procedure for 2D Graphics Drawing
+
+The following steps describe how to use the canvas and brush of the Native Drawing module to draw a 2D graphics.
+
+1. **Create a bitmap object.** Use `OH_Drawing_BitmapCreate` in `drawing_bitmap.h` to create a bitmap object (named `cBitmap` in this example), and use `OH_Drawing_BitmapBuild` to specify its length, width, and pixel format.
+
+ ```c++
+ // Create a bitmap object.
+ OH_Drawing_Bitmap* cBitmap = OH_Drawing_BitmapCreate();
+ // Define the pixel format of the bitmap.
+ OH_Drawing_BitmapFormat cFormat {COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUYE};
+ // Set the pixel format for the bitmap.
+ OH_Drawing_BitmapBuild(cBitmap, width, height, &cFormat);
+ ```
+
+2. **Create a canvas object.** Use `OH_Drawing_CanvasCreate` in `drawing_canvas.h` to create a canvas object (named `cCanvas` in this example), and use `OH_Drawing_CanvasBind` to bind `cBitmap` to this canvas. The content drawn on the canvas will be output to the bound `cBitmap` object.
+
+ ```c++
+ // Create a canvas object.
+ OH_Drawing_Canvas* cCanvas = OH_Drawing_CanvasCreate();
+ // Bind the bitmap to the canvas. The content drawn on the canvas will be output to the bound bitmap memory.
+ OH_Drawing_CanvasBind(cCanvas, cBitmap);
+ // Use white to clear the canvas.
+ OH_Drawing_CanvasClear(cCanvas, OH_Drawing_ColorSetArgb(0xFF, 0xFF, 0xFF, 0xFF));
+ ```
+
+3. **Construct a shape.** Use the APIs provided in `drawing_path.h` to draw a pentagram `cPath`.
+
+ ```c++
+ int len = 300;
+
+ float aX = 500;
+ float aY = 500;
+
+ float dX = aX - len * std::sin(18.0f);
+ float dY = aY + len * std::cos(18.0f);
+
+ float cX = aX + len * std::sin(18.0f);
+ float cY = dY;
+
+ float bX = aX + (len / 2.0);
+ float bY = aY + std::sqrt((cX - dX) * (cX - dX) + (len / 2.0) * (len / 2.0));
+
+ float eX = aX - (len / 2.0);
+ float eY = bY;
+
+ // Create a path object and use the APIs to draw a pentagram.
+ OH_Drawing_Path* cPath = OH_Drawing_PathCreate();
+ // Specify the start point of the path.
+ OH_Drawing_PathMoveTo(cPath, aX, aY);
+ // Draw a line segment from the last point of a path to the target point.
+ OH_Drawing_PathLineTo(cPath, bX, bY);
+ OH_Drawing_PathLineTo(cPath, cX, cY);
+ OH_Drawing_PathLineTo(cPath, dX, dY);
+ OH_Drawing_PathLineTo(cPath, eX, eY);
+ // Close the path. Now the path is drawn.
+ OH_Drawing_PathClose(cPath);
+ ```
+
+4. **Set the brush and pen styles.** Use `OH_Drawing_PenCreate` in `drawing_pen.h` to create a pen (named `cPen` in this example), and set the attributes such as the anti-aliasing, color, and thickness. The pen is used to outline a shape. Use `OH_Drawing_BrushCreate` in `drawing_brush.h` to create a brush (named `cBrush` in this example), and set the brush color. The brush is used to fill in a shape. Use `OH_Drawing_CanvasAttachPen` and `OH_Drawing_CanvasAttachBrush` in `drawing_canvas.h` to attach the pen and brush to the canvas.
+
+ ```c++
+ // Create a pen object and set the anti-aliasing, color, and thickness.
+ OH_Drawing_Pen* cPen = OH_Drawing_PenCreate();
+ OH_Drawing_PenSetAntiAlias(cPen, true);
+ OH_Drawing_PenSetColor(cPen, OH_Drawing_ColorSetArgb(0xFF, 0xFF, 0x00, 0x00));
+ OH_Drawing_PenSetWidth(cPen, 10.0);
+ OH_Drawing_PenSetJoin(cPen, LINE_ROUND_JOIN);
+ // Attach the pen to the canvas.
+ OH_Drawing_CanvasAttachPen(cCanvas, cPen);
+
+ // Create a brush object and set the color.
+ OH_Drawing_Brush* cBrush = OH_Drawing_BrushCreate();
+ OH_Drawing_BrushSetColor(cBrush, OH_Drawing_ColorSetArgb(0xFF, 0x00, 0xFF, 0x00));
+
+ // Attach the brush to the canvas.
+ OH_Drawing_CanvasAttachBrush(cCanvas, cBrush);
+ ```
+
+5. **Draw a shape.** Use `OH_Drawing_CanvasDrawPath` in `drawing_canvas.h` to draw a pentagram on the canvas. Call the corresponding APIs to destroy the objects when they are no longer needed.
+
+ ```c++
+ // Draw a pentagram on the canvas. The outline of the pentagram is drawn by the pen, and the color is filled in by the brush.
+ OH_Drawing_CanvasDrawPath(cCanvas, cPath);
+ // Destroy the created objects when they are no longer needed.
+ OH_Drawing_BrushDestory(cBrush);
+ OH_Drawing_PenDestory(cPen);
+ OH_Drawing_PathDestory(cPath);
+ ```
+
+6. **Obtain pixel data.** Use `OH_Drawing_BitmapGetPixels` in `drawing_bitmap.h` to obtain the pixel address of the bitmap bound to the canvas. The memory to which the address points contains the pixel data of the drawing on the canvas.
+
+ ```c++
+ // Obtain the pixel address after drawing. The memory to which the address points contains the pixel data of the drawing on the canvas.
+ void* bitmapAddr = OH_Drawing_BitmapGetPixels(cBitmap);
+ auto ret = memcpy_s(addr, addrSize, bitmapAddr, addrSize);
+ if (ret != EOK) {
+ LOGI("memcpy_s failed");
+ }
+ // Destroy the canvas object.
+ OH_Drawing_CanvasDestory(cCanvas);
+ // Destroy the bitmap object.
+ OH_Drawing_BitmapDestory(cBitmap);
+ ```
+
+## Development Procedure for Text Drawing and Display
+
+The following steps describe how to use the text drawing and display feature of the Native Drawing module.
+1. **Create a canvas and a bitmap.**
+
+ ```c++
+ // Create a bitmap.
+ OH_Drawing_Bitmap* cBitmap = OH_Drawing_BitmapCreate();
+ OH_Drawing_BitmapFormat cFormat {COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE};
+ OH_Drawing_BitmapBuild(cBitmap, width, height, &cFormat);
+ // Create a canvas.
+ OH_Drawing_Canvas* cCanvas = OH_Drawing_CanvasCreate();
+ OH_Drawing_CanvasBind(cCanvas, cBitmap);
+ OH_Drawing_CanvasClear(cCanvas, OH_Drawing_ColorSetArgb(0xFF, 0xFF, 0xFF, 0xFF));
+ ```
+
+2. **Set the typography style.**
+
+ ```c++
+ // Set the typography attributes such as left to right (LTR) for the text direction and left-aligned for the text alignment mode.
+ OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle();
+ OH_Drawing_SetTypographyTextDirection(typoStyle, TEXT_DIRECTION_LTR);
+ OH_Drawing_SetTypographyTextAlign(typoStyle, TEXT_ALIGN_LEFT);
+ ```
+
+3. **Set the text style.**
+
+ ```c++
+ // Set the text color, for example, black.
+ OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle();
+ OH_Drawing_SetTextStyleColor(txtStyle, OH_Drawing_ColorSetArgb(0xFF, 0x00, 0x00, 0x00));
+ // Set text attributes such as the font size and weight.
+ double fontSize = 30;
+ OH_Drawing_SetTextStyleFontSize(txtStyle, fontSize);
+ OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_400);
+ OH_Drawing_SetTextStyleBaseLine(txtStyle, TEXT_BASELINE_ALPHABETIC);
+ OH_Drawing_SetTextStyleFontHeight(txtStyle, 1);
+ // Set the font families.
+ const char* fontFamilies[] = {"Roboto"};
+ OH_Drawing_SetTextStyleFontFamilies(txtStyle, 1, fontFamilies);
+ OH_Drawing_SetTextStyleFontStyle(txtStyle, FONT_STYLE_NORMAL);
+ OH_Drawing_SetTextStyleLocale(txtStyle, "en");
+ ```
+
+4. **Generate the final text display effect.**
+
+ ```c++
+ OH_Drawing_TypographyCreate* handler = OH_Drawing_CreateTypographyHandler(typoStyle,
+ OH_Drawing_CreateFontCollection());
+ OH_Drawing_TypographyHandlerPushTextStyle(handler, txtStyle);
+ // Set the text content.
+ const char* text = "OpenHarmony\n";
+ OH_Drawing_TypographyHandlerAddText(handler, text);
+ OH_Drawing_TypographyHandlerPopTextStyle(handler);
+ OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler);
+ // Set the maximum width.
+ double maxWidth = 800.0;
+ OH_Drawing_TypographyLayout(typography, maxWidth);
+ // Set the start position for text display.
+ double position[2] = {10.0, 15.0};
+ OH_Drawing_TypographyPaint(typography, cCanvas, position[0], position[1]);
+ ```
+
+## Samples
+
+The following samples are provided to help you better understand how to use the Native Drawing module:
+* [2D Graphics Drawing Using Native Drawing](https://gitee.com/openharmony/graphic_graphic_2d/blob/master/rosen/samples/2d_graphics/drawing_c_sample.cpp)
+* [Text Drawing and Painting Using Native Drawing](https://gitee.com/openharmony/graphic_graphic_2d/blob/master/rosen/samples/text/renderservice/drawing_text_c_sample.cpp)
diff --git a/en/application-dev/napi/native-window-guidelines.md b/en/application-dev/napi/native-window-guidelines.md
new file mode 100644
index 0000000000000000000000000000000000000000..b92ccc54234c9162dad4b35242dcf9d992e5eeec
--- /dev/null
+++ b/en/application-dev/napi/native-window-guidelines.md
@@ -0,0 +1,107 @@
+# NativeWindow Development
+
+## When to Use
+
+`NativeWindow` is a local platform window of OpenHarmony. It provides APIs for you to create a native window from `Surface`, create a native window buffer from `SurfaceBuffer`, and request and flush a buffer.
+The following scenarios are common for native window development:
+
+* Drawing content using native C++ code and displaying the content on the screen
+* Requesting and flushing a buffer when adapting to EGL `eglswapbuffer`
+
+## Available APIs
+
+| API| Description|
+| -------- | -------- |
+| OH_NativeWindow_CreateNativeWindowFromSurface (void \*pSurface) | Creates a `NativeWindow` instance. A new `NativeWindow` instance is created each time this function is called.|
+| OH_NativeWindow_DestroyNativeWindow (struct NativeWindow \*window) | Decreases the reference count of a `NativeWindow` instance by 1 and, when the reference count reaches 0, destroys the instance.|
+| OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer (void \*pSurfaceBuffer) | Creates a `NativeWindowBuffer` instance. A new `NativeWindowBuffer` instance is created each time this function is called.|
+| OH_NativeWindow_DestroyNativeWindowBuffer (struct NativeWindowBuffer \*buffer) | Decreases the reference count of a `NativeWindowBuffer` instance by 1 and, when the reference count reaches 0, destroys the instance.|
+| OH_NativeWindow_NativeWindowRequestBuffer (struct NativeWindow \*window struct NativeWindowBuffer \*\*buffer, int \*fenceFd) | Requests a `NativeWindowBuffer` through a `NativeWindow` instance for content production.|
+| OH_NativeWindow_NativeWindowFlushBuffer (struct NativeWindow \*window, struct NativeWindowBuffer \*buffer, int fenceFd, Region region) | Flushes the `NativeWindowBuffer` filled with the content to the buffer queue through a `NativeWindow` instance for content consumption.|
+| OH_NativeWindow_NativeWindowCancelBuffer (struct NativeWindow \*window, struct NativeWindowBuffer \*buffer) | Returns the `NativeWindowBuffer` to the buffer queue through a `NativeWindow` instance, without filling in any content. The `NativeWindowBuffer` can be used for another request.|
+| OH_NativeWindow_NativeWindowHandleOpt (struct NativeWindow \*window, int code,...) | Sets or obtains the attributes of a native window, including the width, height, and content format.|
+| OH_NativeWindow_GetBufferHandleFromNative (struct NativeWindowBuffer \*buffer) | Obtains the pointer to a `BufferHandle` of a `NativeWindowBuffer` instance.|
+| OH_NativeWindow_NativeObjectReference (void \*obj) | Adds the reference count of a native object.|
+| OH_NativeWindow_NativeObjectUnreference (void \*obj) | Decreases the reference count of a native object and, when the reference count reaches 0, destroys this object.|
+| OH_NativeWindow_GetNativeObjectMagic (void \*obj) | Obtains the magic ID of a native object.|
+
+
+
+## How to Develop
+
+The following steps describe how to use `OH_NativeXComponent` in OpenHarmony to draw content using native C++ code and display the content on the screen.
+
+1. Define an `XComponent` of the `texture` type in `index.ets` for content display.
+ ```js
+ XComponent({ id: 'xcomponentId', type: 'texture', libraryname: 'nativerender'})
+ .borderColor(Color.Red)
+ .borderWidth(5)
+ .onLoad(() => {})
+ .onDestroy(() => {})
+ ```
+
+2. Obtain an `OH_NativeXComponent` instance (named `nativeXComponent` in this example) by calling `napi_get_named_property`, and obtain a `NativeWindow` instance by registering the callback of the `OH_NativeXComponent` instance.
+
+ ```c++
+ // Define a NAPI instance.
+ napi_value exportInstance = nullptr;
+ // Define an OH_NativeXComponent instance.
+ OH_NativeXComponent *nativeXComponent = nullptr;
+ // Use the OH_NATIVE_XCOMPONENT_OBJ export instance.
+ napi_getname_property(env, exports, OH_NATIVE_XCOMPONENT_OBJ, &exportInstance);
+ // Convert the NAPI instance to the OH_NativeXComponent instance.
+ napi_unwarp(env, exportInstance, reinterpret_cast(&nativeXComponent));
+ ```
+
+3. Define the callback `OnSurfaceCreated`. During the creation of a `Surface`, the callback is used to initialize the rendering environment, for example, the `Skia` rendering environment, and write the content to be displayed to `NativeWindow`.
+
+ ```c++
+ void OnSurfaceCreatedCB(NativeXComponent* component, void* window) {
+ // Obtain the width and height of the native window.
+ uint64_t width_ = 0, height_ = 0;
+ OH_NativeXComponent_GetXComponentSize(nativeXComponent, window, &width_, &height_);
+ // Convert void* into a NativeWindow instance. NativeWindow is defined in native_window/external_window.h.
+ NativeWindow* nativeWindow_ = (NativeWindow*)(window);
+
+ // Set or obtain the NativeWindow attributes by calling OH_NativeWindow_NativeWindowHandleOpt.
+ // 1. Use SET_USAGE to set the usage attribute of the native window, for example, to HBM_USE_CPU_READ.
+ OH_NativeWindow_NativeWindowHandleOpt(nativeWindow_, SET_USAGE, HBM_USE_CPU_READ | HBM_USE_CPU_WRITE |HBM_USE_MEM_DMA);
+ // 2. Use SET_BUFFER_GEOMETRY to set the width and height attributes of the native window.
+ OH_NativeWindow_NativeWindowHandleOpt(nativeWindow_, SET_BUFFER_GEOMETRY, width_, height_);
+ // 3. Use SET_FORMAT to set the format attribute of the native window, for example, to PIXEL_FMT_RGBA_8888.
+ OH_NativeWindow_NativeWindowHandleOpt(nativeWindow_, SET_FORMAT, PIXEL_FMT_RGBA_8888);
+ // 4. Use SET_STRIDE to set the stride attribute of the native window.
+ OH_NativeWindow_NativeWindowHandleOpt(nativeWindow_, SET_STRIDE, 0x8);
+
+ // Obtain the NativeWindowBuffer instance by calling OH_NativeWindow_NativeWindowRequestBuffer.
+ struct NativeWindowBuffer* buffer = nullptr;
+ int fenceFd;
+ OH_NativeWindow_NativeWindowRequestBuffer(nativeWindow_, &buffer, &fenceFd);
+
+ // Obtain the buffer handle by calling OH_NativeWindow_GetNativeBufferHandleFromNative.
+ BufferHandle* bufferHandle = OH_NativeWindow_GetNativeBufferHandleFromNative(buffer);
+
+ // Create a Skia bitmap using BufferHandle.
+ SkBitmap bitmap;
+ SkImageInfo imageInfo = ...
+ bitmap.setInfo(imageInfo, bufferHandle->stride);
+ bitmap.setPixels(bufferHandle->virAddr);
+ // Create Skia Canvas and write the content to the native window.
+ ...
+
+ // After the write operation is complete, flush the buffer by using OH_NativeWindow_NativeWindowFlushBuffer so that the data is displayed on the screen.
+ Region region{nullptr, 0};
+ OH_NativeWindow_NativeWindowFlushBuffer(nativeWindow_, buffer, fenceFd, region)
+ }
+ ```
+
+4. Register the callback `OnSurfaceCreated` by using `OH_NativeXComponent_RegisterCallback`.
+
+ ```c++
+ OH_NativeXComponent_Callback &callback_;
+ callback_->OnSurfaceCreated = OnSurfaceCreatedCB;
+ callback_->OnSurfaceChanged = OnSurfaceChangedCB;
+ callback_->OnSurfaceDestoryed = OnSurfaceDestoryedCB;
+ callback_->DispatchTouchEvent = DispatchTouchEventCB;
+ OH_NativeXComponent_RegisterCallback(nativeXComponent, callback_)
+ ```
diff --git a/en/application-dev/napi/rawfile-guidelines.md b/en/application-dev/napi/rawfile-guidelines.md
index 29f66194bd40cd4f7a228213734db2ad65c81180..c585b162a2dc483ca72a5369170b2ee0f43a01a1 100644
--- a/en/application-dev/napi/rawfile-guidelines.md
+++ b/en/application-dev/napi/rawfile-guidelines.md
@@ -4,7 +4,7 @@
## When to Use
-This document describes how to use the native Rawfile APIs to manage raw file directories and files in OpenHarmony. The table below describes the APIs.
+This document describes how to use the native Rawfile APIs to manage raw file directories and files in OpenHarmony. You can use the APIs to traverse, open, search for, read, and close raw files.
## Available APIs
@@ -16,14 +16,14 @@ This document describes how to use the native Rawfile APIs to manage raw file di
| const char *OH_ResourceManager_GetRawFileName(RawDir *rawDir, int index) | Obtains the name of a raw file. |
| RawFile *OH_ResourceManager_OpenRawFile(const NativeResourceManager *mgr, const char *fileName) | Opens a raw file. |
| long OH_ResourceManager_GetRawFileSize(RawFile *rawFile) | Obtains the size of a raw file. |
-| int OH_ResourceManager_SeekRawFile(const RawFile *rawFile, long offset, int whence) | Seeks a data read/write position in a raw file based on the specified offset. |
+| int OH_ResourceManager_SeekRawFile(const RawFile *rawFile, long offset, int whence) | Seeks a read/write position in a raw file based on the specified offset. |
| long OH_ResourceManager_GetRawFileOffset(const RawFile *rawFile) | Obtains the offset. |
| int OH_ResourceManager_ReadRawFile(const RawFile *rawFile, void *buf, size_t length) | Reads a raw file. |
| void OH_ResourceManager_CloseRawFile(RawFile *rawFile) | Closes a raw file to release resources. |
| void OH_ResourceManager_CloseRawDir(RawDir *rawDir) | Closes a raw file directory to release resources. |
-| bool OH_ResourceManager_GetRawFileDescriptor(const RawFile *rawFile, RawFileDescriptor &descriptor) | Obtains the file description (FD) of a raw file. |
+| bool OH_ResourceManager_GetRawFileDescriptor(const RawFile *rawFile, RawFileDescriptor &descriptor) | Obtains the file descriptor (FD) of a raw file. |
| bool OH_ResourceManager_ReleaseRawFileDescriptor(const RawFileDescriptor &descriptor) | Releases the FD of a raw file. |
-| void OH_ResourceManager_ReleaseNativeResourceManager(NativeResourceManager *resMgr) | Releases native resource manager resources. |
+| void OH_ResourceManager_ReleaseNativeResourceManager(NativeResourceManager *resMgr) | Releases the native resource manager. |
## How to Develop
@@ -38,7 +38,7 @@ This document describes how to use the native Rawfile APIs to manage raw file di
2. Call **OH_ResourceManager_InitNativeResourceManager(napi_env env, napi_value jsResMgr)** to obtain a **NativeResourceManager** instance.
```js
- // Call the JS API to pass the JS resource manager.
+ // Import the JS resource manager from the JS head file and pass it to the C++ file.
import resManager from '@ohos.resourceManager'
import rawfileTest from 'librawFileTest.so'
resManager.getResourceManager().then(resmgr => {
@@ -49,7 +49,7 @@ This document describes how to use the native Rawfile APIs to manage raw file di
```
```c++
- // The C++ API obtains and parses the parameters passed by the JS API.
+ // Obtain and parse the parameters in the C++ file.
NativeResourceManager* nativeResourceManager = nullptr;
std::string path;
if (i == 0 && valueType == napi_string) {
@@ -57,7 +57,7 @@ This document describes how to use the native Rawfile APIs to manage raw file di
......
path = buf.data();
} else if (i == 1 && valueType == napi_object) {
- // Parse the second parameter, which is the resource manager.
+ // Parse the second parameter, which is the JS resource manager.
nativeResourceManager = OH_ResourceManager_InitNativeResourceManager(env, argv[i]);
}
```
@@ -80,7 +80,7 @@ This document describes how to use the native Rawfile APIs to manage raw file di
-5. Call **OH_ResourceManager_GetRawFileName** to obtain the name of the raw file based on the specified index.
+5. Call **OH_ResourceManager_GetRawFileName** to obtain the name of the raw file with the specified index.
```c++
for (int index = 0; index < count; index++) {
@@ -90,7 +90,7 @@ This document describes how to use the native Rawfile APIs to manage raw file di
-6. Call **OH_ResourceManager_OpenRawFile** to obtain a **RawFile** instance based on the specified file name.
+6. Call **OH_ResourceManager_OpenRawFile** to obtain a **RawFile** instance with the specified file name.
```c++
RawFile* rawFile = OH_ResourceManager_OpenRawFile(nativeResourceManager, fileName.c_str());
@@ -106,7 +106,7 @@ This document describes how to use the native Rawfile APIs to manage raw file di
-8. Call **OH_ResourceManager_SeekRawFile** to seek a data read/write position in the raw file based on the specified offset.
+8. Call **OH_ResourceManager_SeekRawFile** to seek a read/write position in the raw file based on the specified offset.
```c++
int position = OH_ResourceManager_SeekRawFile(rawFile, 10, 0);
@@ -124,7 +124,7 @@ This document describes how to use the native Rawfile APIs to manage raw file di
-10. Call **OH_ResourceManager_ReadRawFile** to read a raw file.
+10. Call **OH_ResourceManager_ReadRawFile** to read the raw file.
```c++
std::unique_ptr mediaData = std::make_unique(rawFileSize);
@@ -149,7 +149,7 @@ This document describes how to use the native Rawfile APIs to manage raw file di
-13. Call **OH_ResourceManager_GetRawFileDescriptor** to obtain **RawFileDescriptor** of the raw file.
+13. Call **OH_ResourceManager_GetRawFileDescriptor** to obtain the FD of the raw file.
```c++
RawFileDescriptor descriptor;
diff --git a/en/application-dev/notification/Readme-EN.md b/en/application-dev/notification/Readme-EN.md
index e92287b53eb737c851ddf1a5ff9c992368526dc5..dccfc8dbc4c59611db4aa53ff8a5a295cbba4d46 100644
--- a/en/application-dev/notification/Readme-EN.md
+++ b/en/application-dev/notification/Readme-EN.md
@@ -2,5 +2,8 @@
- [Common Event and Notification Overview](notification-brief.md)
- [Common Event Development](common-event.md)
-- [Notification Development](notification.md)
+- [Notification Development](notification-guidelines.md)
+- Agent-Powered Scheduled Reminder
+ - [Agent-Powered Scheduled Reminder Overview](background-agent-scheduled-reminder-overview.md)
+ - [Agent-Powered Scheduled Reminder Development](background-agent-scheduled-reminder-guide.md)
- [Debugging Assistant Usage](assistant-guidelines.md)
diff --git a/en/application-dev/notification/assistant-guidelines.md b/en/application-dev/notification/assistant-guidelines.md
index 35d3eaeaaddd023861056fe819fbe4016c59bb01..c6de99e3fee6919ef1ca1e1a0f87a7aa0a890a74 100644
--- a/en/application-dev/notification/assistant-guidelines.md
+++ b/en/application-dev/notification/assistant-guidelines.md
@@ -2,9 +2,9 @@
The common event and notification module provides debugging tools to facilitate your application development. With these tools, you can view common event and notification information, publish common events, and more. These tools have been integrated with the system. You can run related commands directly in the shell.
-### cem Debugging Assistant
+## cem Debugging Assistant
-##### publish
+### publish
* Functionality
@@ -41,7 +41,7 @@ The common event and notification module provides debugging tools to facilitate

-##### dump
+### dump
* Functionality
@@ -67,7 +67,7 @@ The common event and notification module provides debugging tools to facilitate

-##### help
+### help
* Functionality
@@ -83,9 +83,9 @@ The common event and notification module provides debugging tools to facilitate
-### anm Debugging Assistant
+## anm Debugging Assistant
-##### dump
+### dump
* Functionality
@@ -119,7 +119,7 @@ The common event and notification module provides debugging tools to facilitate
Set the number of the cached recent notifications to be displayed to 10.
-##### help
+### help
* Functionality
diff --git a/en/application-dev/background-agent-scheduled-reminder/background-agent-scheduled-reminder-guide.md b/en/application-dev/notification/background-agent-scheduled-reminder-guide.md
similarity index 100%
rename from en/application-dev/background-agent-scheduled-reminder/background-agent-scheduled-reminder-guide.md
rename to en/application-dev/notification/background-agent-scheduled-reminder-guide.md
diff --git a/en/application-dev/background-agent-scheduled-reminder/background-agent-scheduled-reminder-overview.md b/en/application-dev/notification/background-agent-scheduled-reminder-overview.md
similarity index 80%
rename from en/application-dev/background-agent-scheduled-reminder/background-agent-scheduled-reminder-overview.md
rename to en/application-dev/notification/background-agent-scheduled-reminder-overview.md
index b44656a23200393dc8ac0a2d21d2f5b4a7e06796..a9eccc77a9fecd9d1044eead091bfe9ffb097310 100644
--- a/en/application-dev/background-agent-scheduled-reminder/background-agent-scheduled-reminder-overview.md
+++ b/en/application-dev/notification/background-agent-scheduled-reminder-overview.md
@@ -1,4 +1,4 @@
-# Agent-Powered Scheduled Reminder Overview
+# Agent-Powered Scheduled Reminder Overview
Your application can call the **ReminderRequest** class to create scheduled reminders for countdown timers, calendar events, and alarm clocks. When the created reminders are published, the timing and pop-up notification functions of your application will be taken over by the reminder agent in the background, even when your application is frozen or exits.
diff --git a/en/application-dev/notification/common-event.md b/en/application-dev/notification/common-event.md
index 8ea3eaa2d6b2f450f28660ca9f50ad3b99947c8b..e48bcd802e2a1d16536c29193748b14193517e4c 100644
--- a/en/application-dev/notification/common-event.md
+++ b/en/application-dev/notification/common-event.md
@@ -1,5 +1,5 @@
# Common Event Development
-### Introduction
+## Introduction
OpenHarmony provides a Common Event Service (CES) for applications to subscribe to, publish, and unsubscribe from common events.
Common events are classified into system common events and custom common events.
@@ -25,13 +25,13 @@ You can create a subscriber object to subscribe to a common event to obtain the
### How to Develop
1. Import the **commonEvent** module.
-```javascript
+```js
import commonEvent from '@ohos.commonEvent';
```
2. Create a **subscribeInfo** object. For details about the data types and parameters of the object, see [CommonEventSubscribeInfo](../reference/apis/js-apis-commonEvent.md#commoneventsubscribeinfo).
-```javascript
+```js
private subscriber = null // Used to save the created subscriber object for subsequent subscription and unsubscription.
// Subscriber information
@@ -42,7 +42,7 @@ var subscribeInfo = {
3. Create a subscriber object and save the returned object for subsequent operations such as subscription and unsubscription.
-```javascript
+```js
// Callback for subscriber creation.
commonEvent.createSubscriber(subscribeInfo, (err, subscriber) => {
if (err.code) {
@@ -57,7 +57,7 @@ commonEvent.createSubscriber(subscribeInfo, (err, subscriber) => {
4. Create a subscription callback, which is triggered when an event is received. The data returned by the subscription callback contains information such as the common event name and data carried by the publisher. For details about the data types and parameters of the common event data, see [CommonEventData](../reference/apis/js-apis-commonEvent.md#commoneventdata).
-```javascript
+```js
// Callback for common event subscription.
if (this.subscriber != null) {
commonEvent.subscribe(this.subscriber, (err, data) => {
@@ -74,7 +74,7 @@ if (this.subscriber != null) {
}
```
-## Public Event Publishing Development
+## Common Event Publishing Development
### When to Use
You can use the **publish** APIs to publish a custom common event, which can carry data for subscribers to parse and process.
@@ -89,13 +89,13 @@ You can use the **publish** APIs to publish a custom common event, which can car
#### Development for Publishing a Common Event
1. Import the **commonEvent** module.
-```javascript
+```js
import commonEvent from '@ohos.commonEvent';
```
2. Pass in the common event name and callback, and publish the event.
-```javascript
+```js
// Publish a common event.
commonEvent.publish("event", (err) => {
if (err.code) {
@@ -109,13 +109,13 @@ commonEvent.publish("event", (err) => {
#### Development for Publishing a Common Event with Given Attributes
1. Import the **commonEvent** module.
-```javascript
+```js
import commonEvent from '@ohos.commonEvent'
```
2. Define attributes of the common event to publish. For details about the data types and parameters in the data to publish, see [CommonEventPublishData](../reference/apis/js-apis-commonEvent.md#commoneventpublishdata).
-```javascript
+```js
// Attributes of a common event.
var options = {
code: 1, // Result code of the common event
@@ -125,7 +125,7 @@ var options = {
3. Pass in the common event name, attributes of the common event, and callback, and publish the event.
-```javascript
+```js
// Publish a common event.
commonEvent.publish("event", options, (err) => {
if (err.code) {
@@ -149,14 +149,14 @@ You can use the **unsubscribe** API to unsubscribe from a common event.
### How to Develop
1. Import the **commonEvent** module.
-```javascript
+```js
import commonEvent from '@ohos.commonEvent';
```
2. Subscribe to a common event by following instructions in [Common Event Subscription Development](#Common-Event-Subscription-Development).
3. Invoke the **unsubscribe** API in **CommonEvent** to unsubscribe from the common event.
-```javascript
+```js
if (this.subscriber != null) {
commonEvent.unsubscribe(this.subscriber, (err) => {
if (err.code) {
diff --git a/en/application-dev/notification/figures/notification.png b/en/application-dev/notification/figures/notification.png
index 93029e29a91d6dd435a9a768cb79c5fc48184565..18dcb99b0c531a19698f749105d88db91043837a 100644
Binary files a/en/application-dev/notification/figures/notification.png and b/en/application-dev/notification/figures/notification.png differ
diff --git a/en/application-dev/notification/notification.md b/en/application-dev/notification/notification-guidelines.md
similarity index 100%
rename from en/application-dev/notification/notification.md
rename to en/application-dev/notification/notification-guidelines.md
diff --git a/en/application-dev/quick-start/Readme-EN.md b/en/application-dev/quick-start/Readme-EN.md
index 228d2f0442007f51177f074b6d2e70fcf7486395..f44905cb2c2d33a8efb52f80d01e199e674e2c5b 100644
--- a/en/application-dev/quick-start/Readme-EN.md
+++ b/en/application-dev/quick-start/Readme-EN.md
@@ -11,4 +11,4 @@
- [Application Package Structure Configuration File (Stage Model)](stage-structure.md)
- [Resource File Categories](basic-resource-file-categories.md)
- [SysCap](syscap.md)
-
+ - [HarmonyAppProvision Configuration File](app-provision-structure.md)
diff --git a/en/application-dev/quick-start/app-provision-structure.md b/en/application-dev/quick-start/app-provision-structure.md
new file mode 100644
index 0000000000000000000000000000000000000000..0ab67146829dc0d8bed1f6eaac6afb2b06f21854
--- /dev/null
+++ b/en/application-dev/quick-start/app-provision-structure.md
@@ -0,0 +1,99 @@
+# HarmonyAppProvision Configuration File
+The **HarmonyAppProvision** configuration file (also called profile) is the file where you declare permission and signature information for your application.
+
+## Configuration File Internal Structure
+The **HarmonyAppProvision** file consists of several parts, which are described in the table below.
+
+**Table 1** Configuration file internal structure
+| Name | Description | Data Type| Mandatory | Initial Value Allowed|
+| ----------- | ---------------------------------------------------------------------------------------- | -------- | -------- | -------- |
+| version-code | Version number of the **HarmonyAppProvision** file format. The value is a positive integer containing 32 or less digits.| Number | Yes | No |
+| version-name | Description of the version number. It is recommended that the value consist of three segments, for example, **A.B.C**. | String | Yes | No|
+| uuid | Unique ID of the **HarmonyAppProvision** file. | String | Yes | No|
+| type | Type of the **HarmonyAppProvision** file. The value can be **debug** (for application debugging) and **release** (for application release). The recommended value is **debug**.| String | Yes | No|
+| issuer | Issuer of the **HarmonyAppProvision** file. | String | Yes | No|
+| validity | Validity period of the **HarmonyAppProvision** file. For details, see [Internal Structure of the validity Object](#internal-structure-of-the-validity-object). | Object | Yes | No |
+| bundle-info | Information about the application bundle and developer. For details, see [Internal Structure of the bundle-info Object](#internal-structure-of-the-bundle-info-object). | Object | Yes | No |
+| acls | Information about the Access Control Lists (ACLs). For details, see [Internal Structure of the acls Object](#internal-structure-of-the-acls-object). | Object | No | No |
+| permissions | Permissions required for your application. For details, see [Internal Structure of the permissions Object](#internal-structure-of-the-permissions-object). | Object | No | No |
+| debug-info | Additional debug information. For details, see [Internal Structure of the debug-info Object](#internal-structure-of-the-debug-info-object). | Object | No | No |
+
+An example of the **HarmonyAppProvision** file is as follows:
+```json
+{
+ "version-code": 1,
+ "version-name": "1.0.0",
+ "uuid": "string",
+ "type": "debug",
+ "validity": {
+ "not-before": 1586422743,
+ "not-after": 1617958743
+ },
+ "bundle-info" : {
+ "developer-id": "OpenHarmony",
+ "development-certificate": "Base64 string",
+ "distribution-certificate": "Base64 string",
+ "bundle-name": "com.OpenHarmony.app.test",
+ "apl": "normal",
+ "app-feature": "hos_normal_app"
+ },
+ "acls": {
+ "allowed-acls": ["string"]
+ },
+ "permissions": {
+ "restricted-permissions": ["string"]
+ },
+ "debug-info" : {
+ "device-id-type": "udid",
+ "device-ids": ["string"]
+ },
+ "issuer": "OpenHarmony"
+}
+
+```
+
+
+### Internal Structure of the validity Object
+| Name | Description | Data Type| Mandatory | Initial Value Allowed|
+| ---------- | ------------------------------- | ------- | ------- | --------- |
+| not-before | Start time of the file validity period. The value is a Unix timestamp, which is a non-negative integer.| Number | Yes | No |
+| not-after | End time of the file validity period. The value is a Unix timestamp, which is a non-negative integer.| Number | Yes | No |
+
+### Internal Structure of the bundle-info Object
+| Name | Description | Data Type| Mandatory | Initial Value Allowed|
+| ------------------------ | ------------------------------- | ------- | -------- | --------- |
+| developer-id | Unique ID of the developer.| String | Yes | No |
+| development-certificate | Information about the [debug certificate](../security/hapsigntool-guidelines.md).| Number | Yes if **type** is set to **debug** and no otherwise | No |
+| distribution-certificate | Information about the [release certificate](../security/hapsigntool-guidelines.md).| Number | Yes if **type** is set to **release** and no otherwise | No |
+| bundle-name | Bundle name of the application.| String | Yes | No |
+| apl | [Ability privilege level (APL)](../security/accesstoken-overview.md) of your application. The value can be **normal**, **system_basic**, or **system_core**.| String | Yes | No |
+| app-feature | Type of your application. The value can be **hos_system_app** (system application) or **hos_normal_app** (non-system application).| String | Yes | No |
+
+
+### Internal structure of the acls Object
+The **acls** object contains the [ACLs](../security/accesstoken-overview.md) configured for your application. It should be noted that you still need to fill the ACL information in the **reqPermissions** attribute in the [config.json](package-structure.md) file.
+
+**Table 4** Internal structure of the acls object
+
+| Name | Description | Data Type| Mandatory | Initial Value Allowed|
+| ------------------------ | ------------------------------- | ------- | ------- | --------- |
+| allowed-acls | [ACLs](../security/accesstoken-overview.md) configured for your application.| String array | No | No |
+
+### Internal Structure of the permissions Object
+The **permissions** object contains restricted permissions required for your application. Different from the ACLs set in the **acls** object, these permissions need user authorization during the running of your application. It should be noted that you still need to fill the permission information in the **reqPermissions** attribute in the [config.json](package-structure.md) file.
+
+**Table 5** Internal structure of the permissions object
+
+| Name | Description | Data Type| Mandatory | Initial Value Allowed|
+| ------------------------ | ------------------------------- | ------- | ------- | --------- |
+| restricted-permissions | [Restricted permissions](../security/accesstoken-overview.md) required for your application.| String array | No | No |
+
+### Internal Structure of the debug-info Object
+The **debug-info** object contains debug information of your application, mainly device management and control information.
+
+**Table 6** Internal structure of the debug-info object
+
+| Name | Description | Data Type| Mandatory | Initial Value Allowed|
+| ------------------------ | ------------------------------- | ------- | ------- | --------- |
+| device-id-type | Type of the device ID. Currently, only the udid type is supported.| String | No | No |
+| device-ids | IDs of devices on which your application can be debugged.| String array | No | No |
diff --git a/en/application-dev/quick-start/figures/en-us_image_202206250937.png b/en/application-dev/quick-start/figures/en-us_image_202206250937.png
new file mode 100644
index 0000000000000000000000000000000000000000..c4aa65192d174763ee3b6c74e10274978868ac67
Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_202206250937.png differ
diff --git a/en/application-dev/quick-start/figures/image-20220326064841782.png b/en/application-dev/quick-start/figures/image-20220326064841782.png
index ce4450151f3dc0de82cd8f57cf6018eebbc46f58..a7811ffe339baceffbfff66f2173b2e5e29a6fc1 100644
Binary files a/en/application-dev/quick-start/figures/image-20220326064841782.png and b/en/application-dev/quick-start/figures/image-20220326064841782.png differ
diff --git a/en/application-dev/quick-start/figures/image-20220326064913834.png b/en/application-dev/quick-start/figures/image-20220326064913834.png
index c7fb0ea68933a659f81b1febb2ef946c2b274e42..9bb845a90c3b80db95c736cc84d2434537cf8522 100644
Binary files a/en/application-dev/quick-start/figures/image-20220326064913834.png and b/en/application-dev/quick-start/figures/image-20220326064913834.png differ
diff --git a/en/application-dev/quick-start/figures/image-20220326064955505.png b/en/application-dev/quick-start/figures/image-20220326064955505.png
index bf1180a41e86bbb39c48e7c132f0929e6c448aed..89a43655a064971b721a5aee4222d7c2d37c9523 100644
Binary files a/en/application-dev/quick-start/figures/image-20220326064955505.png and b/en/application-dev/quick-start/figures/image-20220326064955505.png differ
diff --git a/en/application-dev/quick-start/figures/image-20220326065043006.png b/en/application-dev/quick-start/figures/image-20220326065043006.png
index 2cf4b8a6503e6a7a3d7095d092144927384127f7..c8b11931993c83e507dbf7150a5be740430ae42f 100644
Binary files a/en/application-dev/quick-start/figures/image-20220326065043006.png and b/en/application-dev/quick-start/figures/image-20220326065043006.png differ
diff --git a/en/application-dev/quick-start/figures/image-20220326065124911.png b/en/application-dev/quick-start/figures/image-20220326065124911.png
index 872f36c3bf328dcb4ff58ac6f9106d5c4726dc56..858a8af31bc83367fc4c2f696d0f69e58b36b216 100644
Binary files a/en/application-dev/quick-start/figures/image-20220326065124911.png and b/en/application-dev/quick-start/figures/image-20220326065124911.png differ
diff --git a/en/application-dev/quick-start/figures/image-20220326065201867.png b/en/application-dev/quick-start/figures/image-20220326065201867.png
index 5c3b428823d5f044a2857e641ac2465beff39114..e447e34c0a80c472cb2dfd684e1822866b4134d8 100644
Binary files a/en/application-dev/quick-start/figures/image-20220326065201867.png and b/en/application-dev/quick-start/figures/image-20220326065201867.png differ
diff --git a/en/application-dev/quick-start/figures/image-20220326072448840.png b/en/application-dev/quick-start/figures/image-20220326072448840.png
index dac0f9dfe41d8f7667e21f2224563910e3aa9429..861ef6a871ce38d28a1144722ff4d0d327a8bc84 100644
Binary files a/en/application-dev/quick-start/figures/image-20220326072448840.png and b/en/application-dev/quick-start/figures/image-20220326072448840.png differ
diff --git a/en/application-dev/quick-start/start-with-ets-low-code.md b/en/application-dev/quick-start/start-with-ets-low-code.md
index fc897bead0d8009b0e913bbd37a18513fa8807bf..1dd03af96c2064b5b6b0baa89e7295decb4cf1fd 100644
--- a/en/application-dev/quick-start/start-with-ets-low-code.md
+++ b/en/application-dev/quick-start/start-with-ets-low-code.md
@@ -15,7 +15,7 @@ You can develop applications or services in the low-code approach using either o
- Create a project that supports low-code development. This method is used as an example in this topic.
-- In an existing project, create a .visual file for development.
+- In an existing project, create a .visual file for development. For details, see [Creating a .visual File That Supports Low-Code Development](#building-the-second-page).
## Creating a Project That Supports Low-Code Development
@@ -52,7 +52,7 @@ Add **Column**, **Text**, and **Button** components to the first page. A column
Open the **index.visual** file, right-click the existing template components on the canvas, and choose **Delete** from the shortcut menu to delete them. Below is an illustration of the operations.
-
+ 
2. Add a **Column** component and set its styles and attributes.
@@ -62,7 +62,7 @@ Add **Column**, **Text**, and **Button** components to the first page. A column
3. Add a **Text** component.
- Drag the **Text** component from the **UI Control** area to the canvas and then to the center area of the **Column** component. In the **Attributes & Styles** area, click **Feature**, set **Content** of the **Text** component to **this.message** (that is, **Hello World**), set **FontSize** to **30fp**, and set **TextAlign** to **Center**. Then, select the **Text** component on the canvas and drag its corners to fully display the text. Below is an illustration of the operations.
+ Drag the **Text** component from the **UI Control** area to the canvas and then to the center area of the **Column** component. In the **Attributes & Styles** area, click **Feature**, set **Content** of the **Text** component to **this.message** (that is, **Hello World**), set **FontSize** to **30fp**, and set **TextAlign** to **center**. Then, select the **Text** component on the canvas and drag its corners to fully display the text. Below is an illustration of the operations.

@@ -70,7 +70,7 @@ Add **Column**, **Text**, and **Button** components to the first page. A column
Drag the **Button** component from the **UI Control** area to the canvas and then to a position under the **Text** component. In the **Attributes & Styles** area on the right, click **General** and set **Height** of the **Button** component to **40vp**. Click **Feature** and set **Label** to **Next** and **FontSize** to **25fp**. Below is an illustration of the operations.
-
+ 
5. On the toolbar in the upper right corner of the editing window, click **Previewer** to open the Previewer.
@@ -85,7 +85,7 @@ Add **Column**, **Text**, and **Button** components to the first page. A column
In the **Project** window, choose **entry** > **src** > **main** > **ets** > **MainAbility**, right-click the **pages** folder, choose **New** > **Visual**, name the page **second**, and click **Finish**. Below, you can see the structure of the **pages** folder.
-
+ 
2. [Delete the existing template components from the canvas.](#delete_origin_content)
@@ -110,7 +110,7 @@ Add **Column**, **Text**, and **Button** components to the first page. A column
}
}
```
- - Drag the **Text** component to the canvas and then to the center area of the **Column** component. In the **Attributes & Styles** area, click **Feature**, set **Content** of the **Text** component to **this.message** (that is, **Hi there**), set **FontSize** to **30fp**, and set **TextAlign** to **Center**. Then, select the **Text** component on the canvas and drag its corners to fully display the text. Below is an illustration of the operations.
+ - Drag the **Text** component to the canvas and then to the center area of the **Column** component. In the **Attributes & Styles** area, click **Feature**, set **Content** of the **Text** component to **this.message** (that is, **Hi there**), set **FontSize** to **30fp**, and set **TextAlign** to **center**. Then, select the **Text** component on the canvas and drag its corners to fully display the text. Below is an illustration of the operations.

@@ -123,7 +123,7 @@ Add **Column**, **Text**, and **Button** components to the first page. A column
## Implementing Page Redirection
-You can implement page redirection through the page router, which finds the target page based on the page URI. Import the **router** module and then perform the steps below:
+You can implement page redirection through the page router, which finds the target page based on the page URL. Import the **router** module and then perform the steps below:
1. Implement redirection from the first page to the second page.
diff --git a/en/application-dev/quick-start/start-with-ets.md b/en/application-dev/quick-start/start-with-ets.md
index 2af755f6518228e6f972f380ae3acd0b130b98be..443c2b2ce1a6c632008e026b80ec22fb0f20cb79 100644
--- a/en/application-dev/quick-start/start-with-ets.md
+++ b/en/application-dev/quick-start/start-with-ets.md
@@ -28,7 +28,7 @@
- **src > main > ets > MainAbility > app.ets**: ability lifecycle file.
- **src > main > resources**: a collection of resource files used by your application/service, such as graphics, multimedia, character strings, and layout files.
- **src > main > config.json**: module configuration file. This file describes the global configuration information of the application/service, the device-specific configuration information, and the configuration information of the HAP file.
- - **build-profile.json5**: current module information and build configuration options, including **buildOption target**.
+ - **build-profile.json5**: current module information and build configuration options, including **buildOption** and **targets**.
- **hvigorfile.js**: module-level compilation and build task script. You can customize related tasks and code implementation.
- **build-profile.json5**: application-level configuration information, including the signature and product configuration.
- **hvigorfile.js**: application-level compilation and build task script.
@@ -157,7 +157,7 @@
## Implementing Page Redirection
-You can implement page redirection through the page router, which finds the target page based on the page URI. Import the **router** module and then perform the steps below:
+You can implement page redirection through the page router, which finds the target page based on the page URL. Import the **router** module and then perform the steps below:
1. Implement redirection from the first page to the second page.
diff --git a/en/application-dev/quick-start/start-with-js-low-code.md b/en/application-dev/quick-start/start-with-js-low-code.md
index 69e650671909a57d56c6486346938a4804de2fdf..ae92487ff92401b76b1f271ec760e18e713a51a6 100644
--- a/en/application-dev/quick-start/start-with-js-low-code.md
+++ b/en/application-dev/quick-start/start-with-js-low-code.md
@@ -13,7 +13,7 @@ You can develop applications or services in the low-code approach using either o
- Create a project that supports low-code development. This method is used as an example in this topic.
-- In an existing project, create a Visual file for development.
+- In an existing project, create a Visual file for development. For details, see [Creating a .visual File That Supports Low-Code Development](#building-the-second-page).
## Creating a Project That Supports Low-Code Development
@@ -53,15 +53,15 @@ Add **Div**, **Text**, and **Button** components to the first page.
1. Delete the existing template components from the canvas.
-Open the index.visual file, right-click the existing template components on the canvas, and choose **Delete** from the shortcut menu to delete them. Below is an illustration of the operations.
+ Open the index.visual file, right-click the existing template components on the canvas, and choose **Delete** from the shortcut menu to delete them. Below is an illustration of the operations.
-
+ 
2. Add a **Div** component and set its styles and attributes.
Drag the **Div** component from the **UI Control** area to the canvas. In the **Attributes & Styles** area on the right, click **General** and set **Height** to **100%** so that the component fills the entire screen. Click **Flex**, set **FlexDirection** to **column** so that the main axis of the component is vertical, and set both **JustifyContent** and **AlignItems** to **center** so that the child components of the **Div** component are centered along the main axis and cross axis. Below is an illustration of the operations.
-
+ 
3. Add a **Text** component.
@@ -86,10 +86,14 @@ Open the index.visual file, right-click the existing template components on the
1. Create the second page.
- In the **Project** window, choose **entry** > **src** > **main** > **js** > **MainAbility**, right-click the **pages** folder, choose **New** > **Visual**, name the page **second**, and click **Finish**. Below, you can see the structure of the **pages** folder.
+ In the **Project** window, choose **entry** > **src** > **main** > **js** > **MainAbility**, right-click the **pages** folder, choose **New** > **JS Visual**, as shown below, name the page **second**, and click **Finish**.
-
+
+ Below, you can see the structure of the **pages** folder.
+
+ 
+
2. [Delete the existing template components from the canvas.](#delete_origin_content)
3. [Add a Div component and set its styles and attributes.](#add_container)
@@ -109,7 +113,7 @@ Open the index.visual file, right-click the existing template components on the
## Implementing Page Redirection
-You can implement page redirection through the [page router](../ui/ui-js-building-ui-routes.md), which finds the target page based on the page URI. Import the **router** module and then perform the steps below:
+You can implement page redirection through the [page router](../ui/ui-js-building-ui-routes.md), which finds the target page based on the page URL. Import the **router** module and then perform the steps below:
1. Implement redirection from the first page to the second page.
diff --git a/en/application-dev/quick-start/start-with-js.md b/en/application-dev/quick-start/start-with-js.md
index 23b28e30abc18d3d27973df208ed41f703407a6c..7cfc53af2b98dc01d9b8f6cf240e7a712538a911 100644
--- a/en/application-dev/quick-start/start-with-js.md
+++ b/en/application-dev/quick-start/start-with-js.md
@@ -27,7 +27,7 @@
- **src > main > js > MainAbility > app.js**: ability lifecycle file.
- **src > main > resources**: a collection of resource files used by your application/service, such as graphics, multimedia, character strings, and layout files.
- **src > main > config.json**: module configuration file. This file describes the global configuration information of the application/service, the device-specific configuration information, and the configuration information of the HAP file.
- - **build-profile.json5**: current module information and build configuration options, including **buildOption target**.
+ - **build-profile.json5**: current module information and build configuration options, including **buildOption** and **targets**.
- **hvigorfile.js**: module-level compilation and build task script. You can customize related tasks and code implementation.
- **build-profile.json5**: application-level configuration information, including the signature and product configuration.
- **hvigorfile.js**: application-level compilation and build task script.
@@ -168,7 +168,7 @@
## Implementing Page Redirection
-You can implement page redirection through the [page router](../ui/ui-js-building-ui-routes.md), which finds the target page based on the page URI. Import the **router** module and then perform the steps below:
+You can implement page redirection through the [page router](../ui/ui-js-building-ui-routes.md), which finds the target page based on the page URL. Import the **router** module and then perform the steps below:
1. Implement redirection from the first page to the second page.
diff --git a/en/application-dev/quick-start/syscap.md b/en/application-dev/quick-start/syscap.md
index bd81ff6771735d0cb78be5321269460a7ebd0bd2..e74c958c4df493bd5084ad477b95f78c7893cd48 100644
--- a/en/application-dev/quick-start/syscap.md
+++ b/en/application-dev/quick-start/syscap.md
@@ -4,26 +4,26 @@
### System Capabilities and APIs
-SysCap is short for System Capability. It refers to a standalone feature in the operating system, for example, Bluetooth, Wi-Fi, NFC, or camera. Each system capability corresponds to a set of bound APIs, whose availability depends on the support of the target device. Such a set of APIs can be provided in the IDE for association.
+SysCap is short for System Capability. It refers to a standalone feature in the operating system, for example, Bluetooth, Wi-Fi, NFC, or camera. Each SysCap corresponds to a set of bound APIs, whose availability depends on the support of the target device. Such a set of APIs are provided in DevEco Studio for association.

-### Supported Capability Set, Associated Capability Set, and Required Capability Set
+### Supported SysCap Set, Associated SysCap Set, and Required SysCap Set
-The supported capability set, associated capability set, and required capability set are collections of system capabilities.
-The supported capability set covers the device capabilities, and the required capability set covers the application capabilities. If the capability set required by application A is a subset of the capability set supported by device N, application A can be distributed to device N for installation and running. Otherwise, application A cannot be distributed.
-The associated capability set covers the system capabilities of associated APIs that the IDE offers during application development.
+The supported SysCap set, associated SysCap set, and required SysCap set are collections of SysCaps.
+The supported SysCap set covers the device capabilities, and the required SysCap set covers the application capabilities. If the SysCap set required by application A is a subset of the SysCap set supported by device N, application A can be distributed to device N for installation and running. Otherwise, application A cannot be distributed.
+The associated SysCap set covers the system capabilities of associated APIs that the IDE offers during application development.

-### Devices and Supported Capability Sets
+### Devices and Supported SysCap Sets
-Each device provides a capability set that matches its hardware capability.
-The SDK classifies devices into general devices and custom devices. The general devices' supported capability set is defined by OpenHarmony, and the custom devices' is defined by device vendors.
+Each device provides a SysCap set that matches its hardware capability.
+The SDK classifies devices into general devices and custom devices. The general devices' supported SysCap set is defined by OpenHarmony, and the custom devices' is defined by device vendors.

@@ -31,7 +31,7 @@ The SDK classifies devices into general devices and custom devices. The general
### Mapping Between Devices and SDK Capabilities
-The SDK provides a full set of APIs for the IDE. The IDE identifies the supported capability set based on the devices supported by the project, filters the APIs contained in the capability set, and provides the supported APIs for association (to autocomplete input).
+The SDK provides a full set of APIs for the IDE. DevEco Studio identifies the supported SysCap set based on the devices supported by the project, filters the APIs contained in the SysCap set, and provides the supported APIs for association (to autocomplete input).

@@ -49,11 +49,11 @@ Right-click the project directory and choose **Import Product Compatibility ID**
-### Configuring the Associated Capability Set and Required Capability Set
+### Configuring the Associated SysCap Set and Required SysCap Set
-The IDE automatically configures the associated capability set and required capability set based on the settings supported by the created project. You can modify the capability sets when necessary.
-You can add APIs to the associated capability set in the IDE by adding system capabilities. However, note that these APIs may not be supported on the device. Therefore, check whether these APIs are supported before using them.
-Exercise caution when modifying the required capability set. Incorrect modifications may result in the application being unable to be distributed to the target device.
+DevEco Studio automatically configures the associated SysCap set and required SysCap set based on the settings supported by the created project. You can modify these SysCap sets when necessary.
+You can add APIs to the associated SysCap set in DevEco Studio by adding system capabilities. However, note that these APIs may not be supported on the device. Therefore, check whether these APIs are supported before using them.
+Exercise caution when modifying the required SysCap set. Incorrect modifications may result in the application being unable to be distributed to the target device.
```
/* syscap.json */
@@ -74,15 +74,15 @@ Exercise caution when modifying the required capability set. Incorrect modificat
...
]
},
- development: { /* The SysCap set in addedSysCaps and the SysCap set supported by each device configured in devices form the associated capability set. */
+ development: { /* The SysCap set in addedSysCaps and the SysCap set supported by each device configured in devices form the associated SysCap set. */
addedSysCaps: [
"SystemCapability.Location.Location.Lite",
...
]
},
production: { /* Used to generate the RPCID. Exercise caution when adding this parameter. Under incorrect settings, applications may fail to be distributed to target devices. */
- addedSysCaps: [], // Intersection of SysCap sets supported by devices configured in devices. It is the required capability set with addedSysCaps set and removedSysCaps set.
- removedSysCaps: [] // When the required capability set is a capability subset of a device, the application can be distributed to the device.
+ addedSysCaps: [], // Intersection of SysCap sets supported by devices configured in devices. It is the required SysCap set with addedSysCaps set and removedSysCaps set.
+ removedSysCaps: [] // When the required SysCap set is a capability subset of a device, the application can be distributed to the device.
}
}
```
@@ -91,7 +91,7 @@ Exercise caution when modifying the required capability set. Incorrect modificat
### Single-Device Application Development
-By default, the associated capability set and required system capability set of the application are the same as the supported system capability set of the device. Exercise caution when modifying the required capability set.
+By default, the associated SysCap set and required SysCap set of the application are the same as the supported SysCap set of the device. Exercise caution when modifying the required SysCap set.

@@ -99,7 +99,7 @@ By default, the associated capability set and required system capability set of
### Cross-Device Application Development
-By default, the associated capability set of an application is the union of multiple devices' supported capability sets, while the required capability set is the intersection of the devices' supported capability sets.
+By default, the associated SysCap set of an application is the union of multiple devices' supported SysCap sets, while the required SysCap set is the intersection of the devices' supported SysCap sets.

@@ -133,9 +133,9 @@ if (geolocation) {
-### Checking the Differences Between Devices with the Same Capability
+### Checking the Differences Between Devices with a Specific SysCap
-The performance of a system capability may vary by device type. For example, a tablet is superior to a smart wearable device in terms of the camera capability.
+The performance of a SysCap may vary by device type. For example, a tablet is superior to a smart wearable device in terms of the camera capability.
```
import userAuth from '@ohos.userIAM.userAuth';
@@ -162,7 +162,7 @@ The device SysCaps in product solutions vary according to the component combinat

-1. A set of OpenHarmony source code consists of optional and mandatory components. Different components have different system capabilities. In other words, different components represent different SysCaps.
+1. A set of OpenHarmony source code consists of optional and mandatory components. Different components represent different SysCaps.
2. In a normalized released SDK, APIs are mapped to SysCap sets.
@@ -170,10 +170,10 @@ The device SysCaps in product solutions vary according to the component combinat
4. The components configured for a product can be OpenHarmony components or proprietary components developed by a third party. Since there is mapping between components and SysCap, the SysCap set of the product can be obtained after all components are assembled.
-5. The SysCap set is encoded to generate the PCID. You can import the PCID to the IDE and decode it into SysCap. During development, compatibility processing is performed to mitigate the SysCap differences of devices.
+5. The SysCap set is encoded to generate the PCID. You can import the PCID to DevEco Studio and decode it into SysCaps. During development, compatibility processing is performed to mitigate the SysCap differences of devices.
6. System parameters deployed on devices contain the SysCap set. The system provides native interfaces and application interfaces for components and applications to check whether a specific SysCap is available.
-7. During application development, the SysCap required by the application is encoded into the Required Product Compatibility ID (RPCID) and written into the application installation package. During application installation, the package manager decodes the RPCID to obtain the SysCap required by the application and compares it with the SysCap of the device. If the SysCap required by the application is met, the application can be installed.
+7. During application development, the SysCap set required by the application is encoded into the Required Product Compatibility ID (RPCID) and written into the application installation package. During application installation, the package manager decodes the RPCID to obtain the SysCap set required by the application and compares it with the SysCap set supported by the device. If the SysCap set required by the application is met, the application can be installed on the device.
8. When an application is running on a device, the **canIUse** API can be used to query whether the device is compatible with a specific SysCap.
diff --git a/en/application-dev/reference/apis/js-apis-Bundle.md b/en/application-dev/reference/apis/js-apis-Bundle.md
index 8c6a8aebe0334692b2485e575884960d3e251ed7..9a037c0128fc29bd99577f44b755365396483a9b 100644
--- a/en/application-dev/reference/apis/js-apis-Bundle.md
+++ b/en/application-dev/reference/apis/js-apis-Bundle.md
@@ -143,7 +143,7 @@ bundle.getApplicationInfo(bundleName, bundleFlags, (err, data) => {
## bundle.getAllBundleInfo
-getAllBundleInfo(bundleFlag: BundleFlag, userId?: number): Promise>
+getAllBundleInfo(bundleFlag: BundleFlag, userId?: number): Promise\>
Obtains the information of all available bundles of a specified user in the system. This API uses a promise to return the result.
@@ -166,7 +166,7 @@ SystemCapability.BundleManager.BundleFramework
| Type | Description |
| --------------------------- | -------------------------- |
-| Promise> | Promise used to return the information of all available bundles.|
+| Promise\> | Promise used to return the information of all available bundles.|
**Example**
@@ -185,7 +185,7 @@ bundle.getAllBundleInfo(bundleFlag, userId)
## bundle.getAllBundleInfo
-getAllBundleInfo(bundleFlag: BundleFlag, callback: AsyncCallback>): void
+getAllBundleInfo(bundleFlag: BundleFlag, callback: AsyncCallback\>): void
Obtains the information of all available bundles in the system. This API uses an asynchronous callback to return the result.
@@ -220,7 +220,7 @@ bundle.getAllBundleInfo(bundleFlag, (err, data) => {
## bundle.getAllBundleInfo
-getAllBundleInfo(bundleFlag: BundleFlag, userId: number, callback: AsyncCallback>): void
+getAllBundleInfo(bundleFlag: BundleFlag, userId: number, callback: AsyncCallback\>): void
Obtains the information of all available bundles in the system. This API uses an asynchronous callback to return the result.
@@ -238,7 +238,7 @@ SystemCapability.BundleManager.BundleFramework
| ---------- | --------------------------------- | ---- | --------------------------------------- |
| bundleFlag | BundleFlag | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.|
| userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. |
-| callback | AsyncCallback> | Yes | Callback used to return the information of all available bundles. |
+| callback | AsyncCallback\> | Yes | Callback used to return the information of all available bundles. |
**Example**
@@ -495,7 +495,7 @@ bundle.getAllApplicationInfo(bundleFlags, (err, data) => {
## bundle.getBundleArchiveInfo
-getBundleArchiveInfo(hapFilePath: string, bundleFlags: number) : Promise
+getBundleArchiveInfo(hapFilePath: string, bundleFlags: number) : Promise\
Obtains information about the bundles contained in a HAP file. This API uses a promise to return the result.
@@ -530,7 +530,7 @@ bundle.getBundleArchiveInfo(hapFilePath, bundleFlags)
## bundle.getBundleArchiveInfo
-getBundleArchiveInfo(hapFilePath: string, bundleFlags: number, callback: AsyncCallback) : void
+getBundleArchiveInfo(hapFilePath: string, bundleFlags: number, callback: AsyncCallback\) : void
Obtains information about the bundles contained in a HAP file. This API uses an asynchronous callback to return the result.
diff --git a/en/application-dev/reference/apis/js-apis-Context.md b/en/application-dev/reference/apis/js-apis-Context.md
index 1a4861251195d5cfd17c4c0b2496583b29c212e7..8b2851b629aaa7ef7efaec1f2753bb655dbd1b2f 100644
--- a/en/application-dev/reference/apis/js-apis-Context.md
+++ b/en/application-dev/reference/apis/js-apis-Context.md
@@ -1,7 +1,9 @@
-# Context Module
+# Context
-> **NOTE**
-> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+> **NOTE**
+>
+> The initial APIs of this module are supported since API version 6. 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 FA model.
## Modules to Import
@@ -834,7 +836,7 @@ Obtains information of the current ability. This API uses an asynchronous callba
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ------------------------- |
-| callback | AsyncCallback\<[AbilityInfo](#abilityInfo)> | Yes |Callback used to return the ability information.|
+| callback | AsyncCallback\<[AbilityInfo](#abilityInfo)> | Yes | Callback used to return the ability information.|
**Example**
@@ -886,7 +888,7 @@ Obtains the context of the application.
| Type | Description |
| --------- |------ |
-| Context |Application context.|
+| Context | Application context.|
**Example**
@@ -928,14 +930,14 @@ Describes the HAP module information.
| labelId | number | Yes | No | Module label ID. |
| iconId | number | Yes | No | Module icon ID. |
| backgroundImg | string | Yes | No | Module background image. |
-| supportedModes | number | Yes | No | Modes supported by the module. |
-| reqCapabilities | Array | Yes | No | Capabilities required for module running.|
-| deviceTypes | Array | Yes | No | An array of supported device types.|
-| abilityInfo | Array | Yes | No | Ability information. |
+| supportedModes | number | Yes | No | Running modes supported by the module. |
+| reqCapabilities | Array\ | Yes | No | Capabilities required for module running.|
+| deviceTypes | Array\ | Yes | No | Device types supported by the module.|
+| abilityInfo | Array\ | Yes | No | Ability information. |
| moduleName | string | Yes | No | Module name. |
-| mainAbilityName | string | Yes | No | Name of the entrance ability. |
-| installationFree | boolean | Yes | No | When installation-free is supported. |
-| mainElementName | string | Yes| No| Information about the entry ability.|
+| mainAbilityName | string | Yes | No | Name of the main ability. |
+| installationFree | boolean | Yes | No | Whether installation-free is supported. |
+| mainElementName | string | Yes| No| Information about the main ability.|
## AppVersionInfo7+
diff --git a/en/application-dev/reference/apis/js-apis-DataUriUtils.md b/en/application-dev/reference/apis/js-apis-DataUriUtils.md
index 345eaa8b0960856001d4ce3e8395943e271bf155..584b7e1285c0087bc1109bd32d50eb1143360df1 100644
--- a/en/application-dev/reference/apis/js-apis-DataUriUtils.md
+++ b/en/application-dev/reference/apis/js-apis-DataUriUtils.md
@@ -1,6 +1,7 @@
# DataUriUtils Module
-> **NOTE**
+> **NOTE**
+>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
diff --git a/en/application-dev/reference/apis/js-apis-ability-context.md b/en/application-dev/reference/apis/js-apis-ability-context.md
index 5472f3dff854cb8e97499401954b850ec98e1fcd..b858d93cbd061d4f1df583ac9d4045e152105b7a 100644
--- a/en/application-dev/reference/apis/js-apis-ability-context.md
+++ b/en/application-dev/reference/apis/js-apis-ability-context.md
@@ -1,7 +1,9 @@
# AbilityContext
-> **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.
+> **NOTE**
+>
+> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+> The APIs of this module can be used only in the stage model.
Implements the ability context. This module is inherited from **Context**.
@@ -55,7 +57,7 @@ Starts an ability. This API uses a callback to return the result.
var want = {
"deviceId": "",
"bundleName": "com.extreme.test",
- "abilityName": "com.extreme.test.MainAbility"
+ "abilityName": "MainAbility"
};
this.context.startAbility(want, (error) => {
console.log("error.code = " + error.code)
@@ -76,7 +78,7 @@ Starts an ability. This API uses a callback to return the result.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
-| options | StartOptions | Yes| Parameters used for starting the ability.|
+| options | [StartOptions](js-apis-application-StartOptions.md) | Yes| Parameters used for starting the ability.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
**Example**
@@ -85,7 +87,7 @@ Starts an ability. This API uses a callback to return the result.
var want = {
"deviceId": "",
"bundleName": "com.extreme.test",
- "abilityName": "com.extreme.test.MainAbility"
+ "abilityName": "MainAbility"
};
var options = {
windowMode: 0,
@@ -109,7 +111,7 @@ Starts an ability. This API uses a promise to return the result.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
-| options | StartOptions | No| Parameters used for starting the ability.|
+| options | [StartOptions](js-apis-application-StartOptions.md) | No| Parameters used for starting the ability.|
**Return value**
@@ -123,7 +125,7 @@ Starts an ability. This API uses a promise to return the result.
var want = {
"deviceId": "",
"bundleName": "com.extreme.test",
- "abilityName": "com.extreme.test.MainAbility"
+ "abilityName": "MainAbility"
};
var options = {
windowMode: 0,
@@ -141,7 +143,7 @@ Starts an ability. This API uses a promise to return the result.
startAbilityForResult(want: Want, callback: AsyncCallback<AbilityResult>): void;
-Starts an ability. This API uses a callback to return the execution result when the ability is terminated.
+Starts an ability. This API uses a callback to return the result when the ability is terminated.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
@@ -169,7 +171,7 @@ Starts an ability. This API uses a callback to return the execution result when
startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback<AbilityResult>): void;
-Starts an ability. This API uses a callback to return the execution result when the ability is terminated.
+Starts an ability. This API uses a callback to return the result when the ability is terminated.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
@@ -178,7 +180,7 @@ Starts an ability. This API uses a callback to return the execution result when
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want |[Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
-| options | StartOptions | Yes| Parameters used for starting the ability.|
+| options | [StartOptions](js-apis-application-StartOptions.md) | Yes| Parameters used for starting the ability.|
| callback | AsyncCallback<[AbilityResult](js-apis-featureAbility.md#abilityresult)> | Yes| Callback used to return the result.|
@@ -202,7 +204,7 @@ Starts an ability. This API uses a callback to return the execution result when
startAbilityForResult(want: Want, options?: StartOptions): Promise<AbilityResult>;
-Starts an ability. This API uses a promise to return the execution result when the ability is terminated.
+Starts an ability. This API uses a promise to return the result when the ability is terminated.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
@@ -211,7 +213,7 @@ Starts an ability. This API uses a promise to return the execution result when t
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
-| options | StartOptions | No| Parameters used for starting the ability.|
+| options | [StartOptions](js-apis-application-StartOptions.md) | No| Parameters used for starting the ability.|
**Return value**
@@ -374,7 +376,7 @@ Obtains the caller interface of the specified ability, and if the specified abil
onWindowStageCreate(windowStage) {
this.context.startAbilityByCall({
bundleName: "com.example.myservice",
- abilityName: "com.example.myservice.MainAbility",
+ abilityName: "MainAbility",
deviceId: ""
}).then((obj) => {
caller = obj;
@@ -450,7 +452,7 @@ Requests permissions from the user by displaying a pop-up window. This API uses
setMissionLabel(label: string, callback:AsyncCallback<void>): void;
-Sets the label of the ability displayed in the task. This API uses a callback to return the result.
+Sets the label of the ability in the mission. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
@@ -474,7 +476,7 @@ Sets the label of the ability displayed in the task. This API uses a callback to
setMissionLabel(label: string): Promise<void>
-Sets the label of the ability displayed in the task. This API uses a promise to return the result.
+Sets the label of the ability in the mission. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
diff --git a/en/application-dev/reference/apis/js-apis-ability-errorCode.md b/en/application-dev/reference/apis/js-apis-ability-errorCode.md
index d882c9b5ce0870438d9372a8470efcf5c5dad5b8..cc0197f022957aadb0dd784c1d4ae8c6e0c50005 100644
--- a/en/application-dev/reference/apis/js-apis-ability-errorCode.md
+++ b/en/application-dev/reference/apis/js-apis-ability-errorCode.md
@@ -1,9 +1,8 @@
# ErrorCode
-
-> **NOTE**
-> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
-
+> **NOTE**
+>
+> The initial APIs of this module are supported since API 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
@@ -17,9 +16,9 @@ Defines the error code used when the ability is started.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-| Name | Value | Description |
+| Name | Value | Description |
| ------------------------------ | ---- | ---------------------------------------- |
-| NO_ERROR | 0 | No error occurs. |
-| INVALID_PARAMETER | -1 | Invalid parameter. |
-| ABILITY_NOT_FOUND | -2 | The ability is not found. |
-| PERMISSION_DENY | -3 | Permission denied. |
+| NO_ERROR | 0 | No error occurs. |
+| INVALID_PARAMETER | -1 | Invalid parameter.|
+| ABILITY_NOT_FOUND | -2 | The ability is not found.|
+| PERMISSION_DENY | -3 | Permission denied. |
diff --git a/en/application-dev/reference/apis/js-apis-ability-wantConstant.md b/en/application-dev/reference/apis/js-apis-ability-wantConstant.md
index 1190acad72e203ec1d42e7f2c4979938156bad50..e1d57d47b1b77f1695f8ec79ac49bfbb22422d05 100644
--- a/en/application-dev/reference/apis/js-apis-ability-wantConstant.md
+++ b/en/application-dev/reference/apis/js-apis-ability-wantConstant.md
@@ -1,17 +1,15 @@
# wantConstant
-
-> **NOTE**
+> **NOTE**
+>
> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
-
## Modules to Import
```
import wantConstant from '@ohos.ability.wantConstant'
```
-
## wantConstant.Action
**System capability**: SystemCapability.Ability.AbilityBase
@@ -20,32 +18,32 @@ Lists the permissions.
| Common Event Macro | Common Event Name | Subscriber Permission |
| ------------ | ------------------ | ---------------------- |
-| ACTION_HOME | ohos.want.action.home | None |
-| ACTION_DIAL | ohos.want.action.dial | None |
-| ACTION_SEARCH | ohos.want.action.search | None |
-| ACTION_WIRELESS_SETTINGS | ohos.settings.wireless | None |
-| ACTION_MANAGE_APPLICATIONS_SETTINGS | ohos.settings.manage.applications | None |
-| ACTION_APPLICATION_DETAILS_SETTINGS | ohos.settings.application.details | None |
-| ACTION_SET_ALARM | ohos.want.action.setAlarm | None |
-| ACTION_SHOW_ALARMS | ohos.want.action.showAlarms | None |
-| ACTION_SNOOZE_ALARM | ohos.want.action.snoozeAlarm | None |
-| ACTION_DISMISS_ALARM | ohos.want.action.dismissAlarm | None |
-| ACTION_DISMISS_TIMER | ohos.want.action.dismissTimer | None |
-| ACTION_SEND_SMS | ohos.want.action.sendSms | None |
-| ACTION_CHOOSE | ohos.want.action.choose | None |
-| ACTION_IMAGE_CAPTURE8+ | ohos.want.action.imageCapture | None |
-| ACTION_VIDEO_CAPTUR8+ | ohos.want.action.videoCapture | None |
-| ACTION_SELECT | ohos.want.action.select | None |
-| ACTION_SEND_DATA | ohos.want.action.sendData | None |
-| ACTION_SEND_MULTIPLE_DATA | ohos.want.action.sendMultipleData | None |
-| ACTION_SCAN_MEDIA_FILE | ohos.want.action.scanMediaFile | None |
-| ACTION_VIEW_DATA | ohos.want.action.viewData | None |
-| ACTION_EDIT_DATA | ohos.want.action.editData | None |
-| INTENT_PARAMS_INTENT | ability.want.params.INTENT | None |
-| INTENT_PARAMS_TITLE | ability.want.params.TITLE | None |
-| ACTION_FILE_SELECT7+ | ohos.action.fileSelect | None |
-| PARAMS_STREAM7+ | ability.params.stream | None |
-| ACTION_APP_ACCOUNT_OAUTH 8+ | ohos.account.appAccount.action.oauth | None |
+| ACTION_HOME | ohos.want.action.home | None |
+| ACTION_DIAL | ohos.want.action.dial | None |
+| ACTION_SEARCH | ohos.want.action.search | None |
+| ACTION_WIRELESS_SETTINGS | ohos.settings.wireless | None |
+| ACTION_MANAGE_APPLICATIONS_SETTINGS | ohos.settings.manage.applications | None |
+| ACTION_APPLICATION_DETAILS_SETTINGS | ohos.settings.application.details | None |
+| ACTION_SET_ALARM | ohos.want.action.setAlarm | None |
+| ACTION_SHOW_ALARMS | ohos.want.action.showAlarms | None |
+| ACTION_SNOOZE_ALARM | ohos.want.action.snoozeAlarm | None |
+| ACTION_DISMISS_ALARM | ohos.want.action.dismissAlarm | None |
+| ACTION_DISMISS_TIMER | ohos.want.action.dismissTimer | None |
+| ACTION_SEND_SMS | ohos.want.action.sendSms | None |
+| ACTION_CHOOSE | ohos.want.action.choose | None |
+| ACTION_IMAGE_CAPTURE8+ | ohos.want.action.imageCapture | None |
+| ACTION_VIDEO_CAPTUR8+ | ohos.want.action.videoCapture | None |
+| ACTION_SELECT | ohos.want.action.select | None |
+| ACTION_SEND_DATA | ohos.want.action.sendData | None |
+| ACTION_SEND_MULTIPLE_DATA | ohos.want.action.sendMultipleData | None |
+| ACTION_SCAN_MEDIA_FILE | ohos.want.action.scanMediaFile | None |
+| ACTION_VIEW_DATA | ohos.want.action.viewData | None |
+| ACTION_EDIT_DATA | ohos.want.action.editData | None |
+| INTENT_PARAMS_INTENT | ability.want.params.INTENT | None |
+| INTENT_PARAMS_TITLE | ability.want.params.TITLE | None |
+| ACTION_FILE_SELECT7+ | ohos.action.fileSelect | None |
+| PARAMS_STREAM7+ | ability.params.stream | None |
+| ACTION_APP_ACCOUNT_OAUTH 8+ | ohos.account.appAccount.action.oauth | None |
## wantConstant.Entity
@@ -56,12 +54,12 @@ Lists the permissions.
| Common Event Macro | Common Event Name | Subscriber Permission |
| ------------ | ------------------ | ---------------------- |
-| ENTITY_DEFAULT | entity.system.default | None |
-| ENTITY_HOME | entity.system.homel | None |
-| ENTITY_VOICE | ENTITY_VOICE | None |
-| ENTITY_BROWSABLE | entity.system.browsable | None |
-| ENTITY_VIDEO | entity.system.video | None |
-| ACTION_APPLICATION_DETAILS_SETTINGS | ohos.settings.application.details | None |
+| ENTITY_DEFAULT | entity.system.default | None |
+| ENTITY_HOME | entity.system.homel | None |
+| ENTITY_VOICE | ENTITY_VOICE | None |
+| ENTITY_BROWSABLE | entity.system.browsable | None |
+| ENTITY_VIDEO | entity.system.video | None |
+| ACTION_APPLICATION_DETAILS_SETTINGS | ohos.settings.application.details | None |
## flags
@@ -70,19 +68,19 @@ Lists the permissions.
| Name | Value | Description |
| ------------------------------------ | ---------- | ------------------------------------------------------------ |
-| FLAG_AUTH_READ_URI_PERMISSION | 0x00000001 | Indicates the permission to read the URI. |
-| FLAG_AUTH_WRITE_URI_PERMISSION | 0x00000002 | Indicates the permission to write the URI. |
-| FLAG_ABILITY_FORWARD_RESULT | 0x00000004 | Returns the result to the ability. |
-| FLAG_ABILITY_CONTINUATION | 0x00000008 | Indicates whether the ability on the local device can be continued on a remote device. |
-| FLAG_NOT_OHOS_COMPONENT | 0x00000010 | Indicates that a component does not belong to OHOS. |
-| FLAG_ABILITY_FORM_ENABLED | 0x00000020 | Indicates that an ability is enabled. |
-| FLAG_AUTH_PERSISTABLE_URI_PERMISSION | 0x00000040 | Indicates the permission to make the URI persistent. |
-| FLAG_AUTH_PREFIX_URI_PERMISSION | 0x00000080 | Indicates the permission to verify URIs by prefix matching. |
-| FLAG_ABILITYSLICE_MULTI_DEVICE | 0x00000100 | Supports cross-device startup in a distributed scheduler.|
-| FLAG_START_FOREGROUND_ABILITY | 0x00000200 | Indicates that the Service ability is started regardless of whether the host application has been started. |
-| FLAG_ABILITY_CONTINUATION_REVERSIBLE | 0x00000400 | Indicates that ability continuation is reversible. |
-| FLAG_INSTALL_ON_DEMAND | 0x00000800 | Indicates that the specific ability will be installed if it has not been installed. |
-| FLAG_INSTALL_WITH_BACKGROUND_MODE | 0x80000000 | Indicates that the specific ability will be installed in the background if it has not been installed. |
-| FLAG_ABILITY_CLEAR_MISSION | 0x00008000 | Clears other operation missions. This flag can be set for the **Want** object in the **startAbility** API passed to [ohos.app.Context](js-apis-ability-context.md) and must be used together with **flag_ABILITY_NEW_MISSION**. |
-| FLAG_ABILITY_NEW_MISSION | 0x10000000 | Indicates the operation of creating a mission on the history mission stack. |
-| FLAG_ABILITY_MISSION_TOP | 0x20000000 | Starts the mission on the top of the existing mission stack; creates an ability instance if no mission exists. |
+| FLAG_AUTH_READ_URI_PERMISSION | 0x00000001 | Indicates the permission to read the URI. |
+| FLAG_AUTH_WRITE_URI_PERMISSION | 0x00000002 | Indicates the permission to write the URI. |
+| FLAG_ABILITY_FORWARD_RESULT | 0x00000004 | Returns the result to the ability. |
+| FLAG_ABILITY_CONTINUATION | 0x00000008 | Indicates whether the ability on the local device can be continued on a remote device. |
+| FLAG_NOT_OHOS_COMPONENT | 0x00000010 | Indicates that a component does not belong to OHOS. |
+| FLAG_ABILITY_FORM_ENABLED | 0x00000020 | Indicates that an ability is enabled. |
+| FLAG_AUTH_PERSISTABLE_URI_PERMISSION | 0x00000040 | Indicates the permission to make the URI persistent. |
+| FLAG_AUTH_PREFIX_URI_PERMISSION | 0x00000080 | Indicates the permission to verify URIs by prefix matching. |
+| FLAG_ABILITYSLICE_MULTI_DEVICE | 0x00000100 | Supports cross-device startup in a distributed scheduler. |
+| FLAG_START_FOREGROUND_ABILITY | 0x00000200 | Indicates that the Service ability is started regardless of whether the host application has been started. |
+| FLAG_ABILITY_CONTINUATION_REVERSIBLE | 0x00000400 | Indicates that ability continuation is reversible. |
+| FLAG_INSTALL_ON_DEMAND | 0x00000800 | Indicates that the specific ability will be installed if it has not been installed. |
+| FLAG_INSTALL_WITH_BACKGROUND_MODE | 0x80000000 | Indicates that the specific ability will be installed in the background if it has not been installed. |
+| FLAG_ABILITY_CLEAR_MISSION | 0x00008000 | Clears other operation missions. This flag can be set for the **Want** object in the **startAbility** API passed to [ohos.app.Context](js-apis-ability-context.md) and must be used together with **flag_ABILITY_NEW_MISSION**.|
+| FLAG_ABILITY_NEW_MISSION | 0x10000000 | Indicates the operation of creating a mission on the history mission stack. |
+| FLAG_ABILITY_MISSION_TOP | 0x20000000 | Starts the mission on the top of the existing mission stack; creates an ability instance if no mission exists.|
diff --git a/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md b/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md
index dbe86ab6c071bda8d824b0dd79b417569cfda5ac..5a21d564110cdf922e344c52ded3bd8d44604b2f 100644
--- a/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md
+++ b/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md
@@ -1,6 +1,9 @@
-# Ability Access Control
+# Ability Access Control
-> **NOTE**
+Provides program permission management capabilities, including authentication, authorization, and revocation.
+
+> **NOTE**
+>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
@@ -72,6 +75,8 @@ grantUserGrantedPermission(tokenID: number, permissionName: string, permissionFl
Grants a user granted permission to an application. This API uses a promise to return the result.
+This is a system API and cannot be called by third-party applications.
+
**Required permissions**: ohos.permission.GRANT_SENSITIVE_PERMISSIONS
**System capability**: SystemCapability.Security.AccessToken
@@ -96,20 +101,20 @@ Grants a user granted permission to an application. This API uses a promise to r
var AtManager = abilityAccessCtrl.createAtManager();
let tokenID = 0;
let permissionFlag = 1;
-let promise = AtManager.grantUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS",permissionFlag);
+let promise = AtManager.grantUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", permissionFlag);
promise.then(data => {
console.log(`promise: data->${JSON.stringify(data)}`);
});
```
-
-
### grantUserGrantedPermission
grantUserGrantedPermission(tokenID: number, permissionName: string, permissionFlag: number, callback: AsyncCallback<number>): void
Grants a user granted permission to an application. This API uses an asynchronous callback to return the result.
+This is a system API and cannot be called by third-party applications.
+
**Required permissions**: ohos.permission.GRANT_SENSITIVE_PERMISSIONS
**System capability**: SystemCapability.Security.AccessToken
@@ -129,8 +134,12 @@ Grants a user granted permission to an application. This API uses an asynchronou
var AtManager = abilityAccessCtrl.createAtManager();
let tokenID = 0;
let permissionFlag = 1;
-AtManager.grantUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS",permissionFlag, data => {
- console.log(`callback: data->${JSON.stringify(data)}`);
+AtManager.grantUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", permissionFlag, (err, data) => {
+ if (err) {
+ console.log(`callback: err->${JSON.stringify(err)}`);
+ } else {
+ console.log(`callback: data->${JSON.stringify(data)}`);
+ }
});
```
@@ -140,6 +149,8 @@ revokeUserGrantedPermission(tokenID: number, permissionName: string, permissionF
Revokes a user granted permission given to an application. This API uses a promise to return the result.
+This is a system API and cannot be called by third-party applications.
+
**Required permissions**: ohos.permission.REVOKE_SENSITIVE_PERMISSIONS
**System capability**: SystemCapability.Security.AccessToken
@@ -176,6 +187,8 @@ revokeUserGrantedPermission(tokenID: number, permissionName: string, permissionF
Revokes a user granted permission given to an application. This API uses an asynchronous callback to return the result.
+This is a system API and cannot be called by third-party applications.
+
**Required permissions**: ohos.permission.REVOKE_SENSITIVE_PERMISSIONS
**System capability**: SystemCapability.Security.AccessToken
@@ -195,8 +208,12 @@ Revokes a user granted permission given to an application. This API uses an asyn
var AtManager = abilityAccessCtrl.createAtManager();
let tokenID = 0;
let permissionFlag = 1;
-AtManager.revokeUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS",permissionFlag, data => {
- console.log(`callback: data->${JSON.stringify(data)}`);
+AtManager.revokeUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", permissionFlag, (err, data) => {
+ if (err) {
+ console.log(`callback: err->${JSON.stringify(err)}`);
+ } else {
+ console.log(`callback: data->${JSON.stringify(data)}`);
+ }
});
```
@@ -206,7 +223,9 @@ getPermissionFlags(tokenID: number, permissionName: string): Promise<number&g
Obtains the flags of the specified permission of a given application. This API uses a promise to return the result.
-**Required permissions**: ohos.permission.GET_SENSITIVE_PERMISSIONS, GRANT_SENSITIVE_PERMISSIONS, or REVOKE_SENSITIVE_PERMISSIONS
+This is a system API and cannot be called by third-party applications.
+
+**Required permissions**: ohos.permission.GET_SENSITIVE_PERMISSIONS, ohos.permission.GRANT_SENSITIVE_PERMISSIONS, or ohos.permission.REVOKE_SENSITIVE_PERMISSIONS
**System capability**: SystemCapability.Security.AccessToken
diff --git a/en/application-dev/reference/apis/js-apis-abilityDelegatorRegistry.md b/en/application-dev/reference/apis/js-apis-abilityDelegatorRegistry.md
index 65769dc7a2fbe62443957c415ca5c095e9473d52..a609e0df688e7a9cc5b32ea25907eda95ab14c47 100644
--- a/en/application-dev/reference/apis/js-apis-abilityDelegatorRegistry.md
+++ b/en/application-dev/reference/apis/js-apis-abilityDelegatorRegistry.md
@@ -1,6 +1,7 @@
# AbilityDelegatorRegistry
-> **NOTE**
+> **NOTE**
+>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
@@ -9,21 +10,19 @@
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
```
-
-
## AbilityLifecycleState
Enumerates the ability lifecycle states.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
- | Name | Value | Description |
- | ------------- | ---- | --------------------------- |
- | UNINITIALIZED | 0 | The ability is in an invalid state. |
- | CREATE | 1 | The ability is created. |
- | FOREGROUND | 2 | The ability is running in the foreground. |
- | BACKGROUND | 3 | The ability is running in the background. |
- | DESTROY | 4 | The ability is destroyed. |
+| Name | Value | Description |
+| ------------- | ---- | --------------------------- |
+| UNINITIALIZED | 0 | The ability is in an invalid state. |
+| CREATE | 1 | The ability is created.|
+| FOREGROUND | 2 | The ability is running in the foreground. |
+| BACKGROUND | 3 | The ability is running in the background. |
+| DESTROY | 4 | The ability is destroyed.|
@@ -37,9 +36,9 @@ Obtains the **AbilityDelegator** object of the application.
**Return value**
- | Type | Description |
- | ------------------------------------------------------------ | ------------------------------------------------------------ |
- | [AbilityDelegator](js-apis-application-abilityDelegator.md#AbilityDelegator) | [AbilityDelegator](js-apis-application-abilityDelegator.md#AbilityDelegator) object, which can be used to schedule functions related to the test framework. |
+| Type | Description |
+| ------------------------------------------------------------ | ------------------------------------------------------------ |
+| [AbilityDelegator](js-apis-application-abilityDelegator.md#AbilityDelegator) | [AbilityDelegator](js-apis-application-abilityDelegator.md#AbilityDelegator) object, which can be used to schedule functions related to the test framework.|
**Example**
@@ -61,9 +60,9 @@ Obtains the **AbilityDelegatorArgs** object of the application.
**Return value**
- | Type | Description |
- | ------------------------------------------------------------ | ------------------------------------------------------------ |
- | [AbilityDelegatorArgs](js-apis-application-abilityDelegatorArgs.md#AbilityDelegatorArgs) | [AbilityDelegatorArgs](js-apis-application-abilityDelegatorArgs.md#AbilityDelegatorArgs) object, which can be used to obtain test parameters. |
+| Type | Description |
+| ------------------------------------------------------------ | ------------------------------------------------------------ |
+| [AbilityDelegatorArgs](js-apis-application-abilityDelegatorArgs.md#AbilityDelegatorArgs) | [AbilityDelegatorArgs](js-apis-application-abilityDelegatorArgs.md#AbilityDelegatorArgs) object, which can be used to obtain test parameters.|
**Example**
diff --git a/en/application-dev/reference/apis/js-apis-abilityrunninginfo.md b/en/application-dev/reference/apis/js-apis-abilityrunninginfo.md
index 9223a481fb8a9c6f3db8366d664958294e370704..508463e3a428fffe336de4ae2c986623fb54d3b1 100644
--- a/en/application-dev/reference/apis/js-apis-abilityrunninginfo.md
+++ b/en/application-dev/reference/apis/js-apis-abilityrunninginfo.md
@@ -1,9 +1,9 @@
# AbilityRunningInfo
-> **NOTE**
+> **NOTE**
+>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
-
Provides ability running information.
## Modules to Import
@@ -11,13 +11,11 @@ Provides ability running information.
```js
import abilitymanager from '@ohos.application.abilityManager';
```
-## Usage
+## Usage
The ability running information is obtained by using the **getAbilityRunningInfos** API in **abilityManager**.
-
-
```js
import abilitymanager from '@ohos.application.abilityManager';
abilitymanager.getAbilityRunningInfos((err,data) => {
diff --git a/en/application-dev/reference/apis/js-apis-abilitystagecontext.md b/en/application-dev/reference/apis/js-apis-abilitystagecontext.md
index c1552ef27358e1e5fd687b2003520105c82980eb..65705aae3936cc2c9e9643f6142be6de6564124b 100644
--- a/en/application-dev/reference/apis/js-apis-abilitystagecontext.md
+++ b/en/application-dev/reference/apis/js-apis-abilitystagecontext.md
@@ -1,8 +1,9 @@
# AbilityStageContext
-> **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.
-
+> **NOTE**
+>
+> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+> The APIs of this module can be used only in the stage model.
Implements the context of an ability stage. This module is inherited from [Context](js-apis-application-context.md).
@@ -14,11 +15,8 @@ import AbilityStage from '@ohos.application.AbilityStage';
## Usage
-
The ability stage context is obtained through an **AbilityStage** instance.
-
-
```js
import AbilityStage from '@ohos.application.AbilityStage';
class MyAbilityStage extends AbilityStage {
@@ -28,7 +26,6 @@ class MyAbilityStage extends AbilityStage {
}
```
-
## Attributes
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
diff --git a/en/application-dev/reference/apis/js-apis-animator.md b/en/application-dev/reference/apis/js-apis-animator.md
index 462e56f7d18c0df2661e1ce1944bce0d159fcffe..2a9c01095ebf3ccfac93d9d96774c103fa2f6e4f 100644
--- a/en/application-dev/reference/apis/js-apis-animator.md
+++ b/en/application-dev/reference/apis/js-apis-animator.md
@@ -1,248 +1,240 @@
-# Animation
+# Animator
+
+> **NOTE**
+> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
-> **NOTE:**
->The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
-**requestAnimationFrame**: none
+```
+import animator from '@ohos.animator';
+```
+
+
+## createAnimator
+
+createAnimator(options: AnimatorOptions): AnimatorResult
+
+Creates an **Animator** object.
+
+**System capability**: SystemCapability.ArkUI.ArkUI.Full
+
+**Parameters**
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| options | [AnimatorOptions](#animatoroptions) | Yes| Animator options. For details, see **AnimatorOptions**.|
+
+**Return value**
+| Type| Description|
+| -------- | -------- |
+| [AnimatorResult](#animatorresult) | Animator result.|
+
+**Example**
+
+ ```
+
+
+
+
+
+ ```
+
+ ```
+ // js
+ export default {
+ data : {
+ divWidth: 200,
+ divHeight: 200,
+ animator: null
+ },
+ onInit() {
+ var options = {
+ duration: 1500,
+ easing: 'friction',
+ fill: 'forwards',
+ iterations: 2,
+ begin: 200.0,
+ end: 400.0
+ };
+ this.animator = animator.createAnimator(options);
+ },
+ Show() {
+ var options1 = {
+ duration: 2000,
+ easing: 'friction',
+ fill: 'forwards',
+ iterations: 1,
+ begin: 200.0,
+ end: 400.0
+ };
+ this.animator.update(options1);
+ var _this = this;
+ this.animator.onframe = function(value) {
+ _this.divWidth = value;
+ _this.divHeight = value;
+ };
+ this.animator.play();
+ }
+ }
+ ```
+
+## AnimatorResult
+
+Defines the animator result.
+
+### update
+
+update(options: AnimatorOptions): void
+
+Updates this animator.
-**cancelAnimationFrame**: none
+**System capability**: SystemCapability.ArkUI.ArkUI.Full
-**createAnimator**:
+**Parameters**
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| options | [AnimatorOptions](#animatoroptions) | Yes| Animator options.|
+**Example**
```
-import animator from '@ohos.animator';
+animator.update(options);
```
-## Required Permissions
+### play
-None
+play(): void
-## requestAnimationFrame
+Plays this animation.
-requestAnimationFrame\(handler\[, \[ ...args\]\]\): number
+**System capability**: SystemCapability.ArkUI.ArkUI.Full
-Requests an animation frame.
+**Example**
+```
+animator.play();
+```
-- Parameters
+### finish
- | Name | Type | Mandatory | Description |
- | ------- | ----------- | --------- | ------------------------------------------------------------ |
- | handler | Function | Yes | Handler used to request a frame. When **requestAnimationFrame** calls the **handler**, the timestamp is passed to the first parameter to indicate the time when **requestAnimationFrame** starts to execute the callback. |
- | ...args | Array\ | No | Additional parameter, which is passed to the **handler** as a parameter during function callback. |
+finish(): void
-- Return values
+Ends this animation.
- | Type | Description |
- | ------ | ----------- |
- | number | Request ID. |
-
-- Example
+**System capability**: SystemCapability.ArkUI.ArkUI.Full
- ```
-
-
- ```
-
- ```
- /* xxx.css */
- .container {
- flex-direction: column;
- justify-content: center;
- align-items: center;
- width: 100%;
- height: 100%;
- }
- .btn{
- width: 300px;
- margin-top: 40px;
- }
- ```
-
- ```
- /* xxx.js */
- export default {
- data: {
- requestId: 0,
- startTime: 0,
- },
- beginAnimation() {
- cancelAnimationFrame(this.requestId);
- this.requestId = requestAnimationFrame(this.runAnimation);
- },
- runAnimation(timestamp) {
- if (this.startTime == 0) {
- this.startTime = timestamp;
- }
- var elapsed = timestamp - this.startTime;
- if (elapsed < 500) {
- console.log('callback handler timestamp: ' + timestamp);
- this.requestId = requestAnimationFrame(this.runAnimation);
- }
- },
- stopAnimation() {
- cancelAnimationFrame(this.requestId);
- }
- }
- ```
+cancel(): void
+Cancels this animation.
-## createAnimator
+**System capability**: SystemCapability.ArkUI.ArkUI.Full
-createAnimator\(options\[...\]\): void
-
-Creates an animation object.
-
-- Parameters
-
- | Name | Type | Mandatory | Description |
- | ------- | ------ | --------- | ------------------------------------------------------------ |
- | options | Object | Yes | Attributes of the **Animator** to be created. For details, see the options table. |
-
-- Description of options
-
- | Name | Type | Mandatory | Description |
- | ---------- | ------ | --------- | ------------------------------------------------------------ |
- | duration | number | No | Duration for playing an animation, in milliseconds. The default value is **0**. |
- | easing | string | No | Animation easing curve. The default value is **ease**. |
- | delay | number | No | Animation delay duration, in milliseconds. The default value is **0**, indicating that there is no delay. |
- | fill | string | No | Animation start/stop mode. The default value is **none**. |
- | direction | string | No | Animation playback mode. The default value is **normal**. |
- | iterations | number | No | Number of times that an animation is played. The default value is **1**. If this parameter is set to **0**, the animation is not played. If this parameter is set to **-1**, the animation is played for an unlimited number of times. |
- | begin | number | No | Start point of the animation easing. If this parameter is not set, the default value **0** is used. |
- | end | number | No | End point of the animation easing. If this parameter is not set, the default value **1** is used. |
-
-- animator interfaces
-
- | Name | Type | Description |
- | ------- | ------- | ------------------------------------------------------------ |
- | update | options | Updates the animation parameters. The input parameters are the same as those of **createAnimator**. |
- | play | - | Starts an animation. |
- | finish | - | Ends an animation. |
- | pause | - | Pauses an animation. |
- | cancel | - | Cancels an animation. |
- | reverse | - | Reverses an animation. |
-
-
-- **animator** supported events:
-
- | Name | Type | Description |
- | ------ | ------ | ----------------------------------- |
- | frame | number | The frame is requested. |
- | cancel | - | The animation is forcibly canceled. |
- | finish | - | The animation playback is complete. |
- | repeat | - | The animation replays. |
-
-- Example
-
- ```
-
-
-
-
-
- ```
-
- ```
- // js
- export default {
- data : {
- divWidth: 200,
- divHeight: 200,
- animator: null
- },
- onInit() {
- var options = {
- duration: 1500,
- easing: 'friction',
- fill: 'forwards',
- iterations: 2,
- begin: 200.0,
- end: 400.0
- };
- this.animator = animator.createAnimator(options);
- },
- Show() {
- var options1 = {
- duration: 2000,
- easing: 'friction',
- fill: 'forwards',
- iterations: 1,
- begin: 200.0,
- end: 400.0
- };
- this.animator.update(options1);
- var _this = this;
- this.animator.onframe = function(value) {
- _this.divWidth = value;
- _this.divHeight = value;
- };
- this.animator.play();
- }
- }
- ```
\ No newline at end of file
+**Example**
+```
+animator.cancel();
+```
+
+### reverse
+
+reverse(): void
+
+Plays this animation in reverse order.
+
+**System capability**: SystemCapability.ArkUI.ArkUI.Full
+
+**Example**
+```
+animator.reverse();
+```
+
+### onframe
+
+onframe: (progress: number) => void
+
+Called when a frame is received.
+
+**System capability**: SystemCapability.ArkUI.ArkUI.Full
+
+**Parameters**
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| progress | number | Yes| Current progress of the animation.|
+
+**Example**
+```
+animator.onframe();
+```
+
+### onfinish
+
+onfinish: () => void
+
+Called when this animation is finished.
+
+**System capability**: SystemCapability.ArkUI.ArkUI.Full
+
+**Example**
+```
+animator.onfinish();
+```
+
+### oncancel
+
+oncancel: () => void
+
+Called when this animation is canceled.
+
+**System capability**: SystemCapability.ArkUI.ArkUI.Full
+
+**Example**
+```
+animator.oncancel();
+```
+
+### onrepeat
+
+onrepeat: () => void
+
+**System capability**: SystemCapability.ArkUI.ArkUI.Full
+
+**Example**
+```
+animator.onrepeat();
+```
+
+Called when this animation repeats.
+
+## AnimatorOptions
+
+Defines animator options.
+
+**System capability**: SystemCapability.ArkUI.ArkUI.Full
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| duration | number | Yes| Duration for playing the animation, in milliseconds. The default value is **0**.|
+| easing | string | Yes| Animation interpolation curve. The default value is **ease**.|
+| delay | number | Yes| Animation delay duration, in milliseconds. The default value is **0**, indicating that there is no delay.|
+| fill | "none" \| "forwards" \| "backwards" \| "both" | Yes| State of the animated target after the animation is executed. The default value is **none**, which means that the target will retain its end state (defined by the last keyframe) after the animation is executed. |
+| direction | "normal" \| "reverse" \| "alternate" \| "alternate-reverse" | Yes| Animation playback mode. The default value is **normal**.|
+| iterations | number | Yes| Number of times that the animation is played. The default value is **1**. The value **0** means not to play the animation, and **-1** means to play the animation for an unlimited number of times.|
+| begin | number | Yes| Start point of the animation interpolation. If this parameter is not set, the default value **0** is used.|
+| end | number | Yes| End point of the animation interpolation. If this parameter is not set, the default value **1** is used.|
diff --git a/en/application-dev/reference/apis/js-apis-appAccount.md b/en/application-dev/reference/apis/js-apis-appAccount.md
index 3577652546daea30400c7eadafd7e6771a55db77..96766c334d7167b6c577e78f1294dec0b6e76d67 100644
--- a/en/application-dev/reference/apis/js-apis-appAccount.md
+++ b/en/application-dev/reference/apis/js-apis-appAccount.md
@@ -1,4 +1,6 @@
-# App Account Management
+# App Account Management
+
+Provides app account management, including adding, deleting, querying, modifying, and authorizing app accounts, writing data to disks, and synchronizing data.
> **NOTE**
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
@@ -20,13 +22,14 @@ Creates an **AppAccountManager** instance.
**System capability**: SystemCapability.Account.AppAccount
**Return Value**
- | Type | Description |
- | ----------------- | ------------ |
- | AppAccountManager | **AppAccountManager** instance created. |
+
+| Type | Description |
+| ----------------- | ------------ |
+| AppAccountManager | **AppAccountManager** instance created.|
**Example**
```js
- var appAccountManager = account.createAppAccountManager();
+ const appAccountManager = account_appAccount.createAppAccountManager();
```
## AppAccountManager
@@ -37,16 +40,16 @@ Provides methods to manage app accounts.
addAccount(name: string, callback: AsyncCallback<void>): void
-Adds an app account to the account management service. This method uses an asynchronous callback to return the result.
+Adds an app account to the **AppAccountManager** service. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
- | Name | Type | Mandatory | Description |
- | -------- | ------------------------- | ---- | --------------------- |
- | name | string | Yes | Name of the app account to add. |
- | callback | AsyncCallback<void> | Yes | Callback invoked when the app account is added. |
+| Name | Type | Mandatory | Description |
+| -------- | ------------------------- | ---- | -------------------- |
+| name | string | Yes | Name of the app account to add. |
+| callback | AsyncCallback<void> | Yes | Callback invoked when the app account is added.|
**Example**
@@ -61,17 +64,17 @@ Adds an app account to the account management service. This method uses an async
addAccount(name: string, extraInfo: string, callback: AsyncCallback<void>): void
-Adds an app account and its additional information to the account management service. This method uses an asynchronous callback to return the result.
+Adds the account name and additional information (information that can be converted into the string type, such as token) of this app to the **AppAccountManager** service. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
- | Name | Type | Mandatory | Description |
- | --------- | ------------------------- | ---- | ---------------------------------------- |
- | name | string | Yes | Name of the app account to add. |
- | extraInfo | string | Yes | Additional information (for example, token) of the app account to add. The additional information cannot contain sensitive information about the app account. |
- | callback | AsyncCallback<void> | Yes | Callback invoked when the app account and its additional information are added. |
+| Name | Type | Mandatory | Description |
+| --------- | ------------------------- | ---- | ---------------------------------------- |
+| name | string | Yes | Name of the app account to add. |
+| extraInfo | string | Yes | Additional information to add. The additional information cannot contain sensitive information, such as the app account password.|
+| callback | AsyncCallback<void> | Yes | Callback invoked when the app account name and additional information are added. |
**Example**
@@ -86,24 +89,24 @@ Adds an app account and its additional information to the account management ser
### addAccount
-addAccount(name: string, extraInfo?: string): Promise<void>
+addAccount(name: string, extraInfo: string): Promise<void>
-Adds an app account and its additional information to the account management service. This method uses a promise to return the result.
+Adds the account name and additional information (information that can be converted into the string type, such as token) of this app to the **AppAccountManager** service. This API uses a promise to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
- | Name | Type | Mandatory | Description |
- | --------- | ------ | ---- | -------------------------------- |
- | name | string | Yes | Name of the app account to add. |
- | extraInfo | string | Yes | Additional information of the app account to add. The additional information cannot contain sensitive information about the app account. |
+| Name | Type | Mandatory | Description |
+| --------- | ------ | ---- | ---------------------------------------- |
+| name | string | Yes | Name of the app account to add. |
+| extraInfo | string | Yes | Additional information to add. The additional information cannot contain sensitive information, such as the app account password.|
**Return Value**
- | Type | Description |
- | ------------------- | --------------------- |
- | Promise<void> | Promise used to return the result. |
+| Type | Description |
+| ------------------- | --------------------- |
+| Promise<void> | Promise used to return the result.|
**Example**
@@ -120,18 +123,18 @@ Adds an app account and its additional information to the account management ser
addAccountImplicitly(owner: string, authType: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void
-Implicitly adds an app account based on the specified account owner, authentication type, and options. This method uses an asynchronous callback to return the result.
+Implicitly adds an app account based on the specified account owner, authentication type, and options. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
- | Name | Type | Mandatory | Description |
- | -------- | --------------------- | ---- | --------------- |
- | owner | string | Yes | Bundle name of the app account to add. |
- | authType | string | Yes | Authentication type of the app account to add. |
- | options | {[key: string]: any} | Yes | Options for the authentication. |
- | callback | AuthenticatorCallback | Yes | Authenticator callback invoked to return the authentication result. |
+| Name | Type | Mandatory | Description |
+| -------- | --------------------- | ---- | ----------------------- |
+| owner | string | Yes | Owner of the app account to add. The value is the bundle name of the app. |
+| authType | string | Yes | Authentication type of the app account to add. The authentication type is customized. |
+| options | {[key: string]: any} | Yes | Authentication options, which can be set as required.|
+| callback | AuthenticatorCallback | Yes | Authenticator callback invoked to return the authentication result. |
**Example**
@@ -161,16 +164,16 @@ Implicitly adds an app account based on the specified account owner, authenticat
deleteAccount(name: string, callback: AsyncCallback<void>): void
-Deletes an app account from the account management service. This method uses an asynchronous callback to return the result.
+Deletes an app account from the **AppAccountManager** service. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
- | Name | Type | Mandatory | Description |
- | -------- | ------------------------- | ---- | ----------------- |
- | name | string | Yes | Name of the app account to delete. |
- | callback | AsyncCallback<void> | Yes | Callback invoked when the app account is deleted. |
+| Name | Type | Mandatory | Description |
+| -------- | ------------------------- | ---- | ---------------- |
+| name | string | Yes | Name of the app account to delete. |
+| callback | AsyncCallback<void> | Yes | Callback invoked when the app account is deleted.|
**Example**
@@ -185,21 +188,21 @@ Deletes an app account from the account management service. This method uses an
deleteAccount(name: string): Promise<void>
-Deletes an app account from the account management service. This method uses a promise to return the result.
+Deletes an app account from the **AppAccountManager** service. This API uses a promise to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
- | Name | Type | Mandatory | Description |
- | ---- | ------ | ---- | ------------ |
- | name | string | Yes | Name of the app account to delete. |
+| Name | Type | Mandatory | Description |
+| ---- | ------ | ---- | ----------- |
+| name | string | Yes | Name of the app account to delete.|
**Return Value**
- | Type | Description |
- | :------------------ | :-------------------- |
- | Promise<void> | Promise used to return the result. |
+| Type | Description |
+| :------------------ | :-------------------- |
+| Promise<void> | Promise used to return the result.|
**Example**
@@ -216,17 +219,17 @@ Deletes an app account from the account management service. This method uses a p
disableAppAccess(name: string, bundleName: string, callback: AsyncCallback<void>): void
-Disables an app account from accessing an application with the given bundle name. This method uses an asynchronous callback to return the result.
+Disables an app account from accessing an app with the given bundle name. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
- | Name | Type | Mandatory | Description |
- | ---------- | ------------------------- | ---- | ------------------------------- |
- | name | string | Yes | App account name. |
- | bundleName | string | Yes | Bundle name of an app. |
- | callback | AsyncCallback<void> | Yes | Callback invoked when the app account is disabled from accessing the application with the given bundle name. |
+| Name | Type | Mandatory | Description |
+| ---------- | ------------------------- | ---- | --------------------------------- |
+| name | string | Yes | Name of the target app account. |
+| bundleName | string | Yes | Bundle name of the app. |
+| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
**Example**
@@ -241,22 +244,22 @@ Disables an app account from accessing an application with the given bundle name
disableAppAccess(name: string, bundleName: string): Promise<void>
-Disables an app account from accessing an application with the given bundle name. This method uses a promise to return the result.
+Disables an app account from accessing an app with the given bundle name. This API uses a promise to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
- | Name | Type | Mandatory | Description |
- | ---------- | ------ | ---- | ----------------- |
- | name | string | Yes | App account name. |
- | bundleName | string | Yes | Bundle name of an app. |
+| Name | Type | Mandatory | Description |
+| ---------- | ------ | ---- | ---------------- |
+| name | string | Yes | Name of the target app account.|
+| bundleName | string | Yes | Bundle name of the app. |
**Return Value**
- | Type | Description |
- | :------------------ | :-------------------- |
- | Promise<void> | Promise used to return the result. |
+| Type | Description |
+| :------------------ | :-------------------- |
+| Promise<void> | Promise used to return the result.|
**Example**
@@ -273,17 +276,17 @@ Disables an app account from accessing an application with the given bundle name
enableAppAccess(name: string, bundleName: string, callback: AsyncCallback<void>): void
-Enables an app account to access an application with the given bundle name. This method uses an asynchronous callback to return the result.
+Enables an app account to access an app with the given bundle name. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
- | Name | Type | Mandatory | Description |
- | ---------- | ------------------------- | ---- | ------------------------------- |
- | name | string | Yes | App account name. |
- | bundleName | string | Yes | Bundle name of an app. |
- | callback | AsyncCallback<void> | Yes | Callback invoked when the app account is enabled to access the application with the given bundle name. |
+| Name | Type | Mandatory | Description |
+| ---------- | ------------------------- | ---- | --------------------------------- |
+| name | string | Yes | Name of the target app account. |
+| bundleName | string | Yes | Bundle name of an app. |
+| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
**Example**
@@ -298,22 +301,22 @@ Enables an app account to access an application with the given bundle name. This
enableAppAccess(name: string, bundleName: string): Promise<void>
-Enables an app account to access an application with the given bundle name. This method uses a promise to return the result.
+Enables an app account to access an app with the given bundle name. This API uses a promise to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
- | Name | Type | Mandatory | Description |
- | ---------- | ------ | ---- | --------- |
- | name | string | Yes | App account name. |
- | bundleName | string | Yes | Bundle name of an app. |
+| Name | Type | Mandatory | Description |
+| ---------- | ------ | ---- | --------- |
+| name | string | Yes | Name of the target app account. |
+| bundleName | string | Yes | Bundle name of an app.|
**Return Value**
- | Type | Description |
- | :------------------ | :-------------------- |
- | Promise<void> | Promise used to return the result. |
+| Type | Description |
+| :------------------ | :-------------------- |
+| Promise<void> | Promise used to return the result.|
**Example**
@@ -329,7 +332,7 @@ Enables an app account to access an application with the given bundle name. This
checkAppAccountSyncEnable(name: string, callback: AsyncCallback<boolean>): void
-Checks whether an app account allows application data synchronization. This method uses an asynchronous callback to return the result.
+Checks whether an app account allows app data synchronization. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC (available only to system applications)
@@ -337,10 +340,10 @@ Checks whether an app account allows application data synchronization. This meth
**Parameters**
- | Name | Type | Mandatory | Description |
- | -------- | ---------------------------- | ---- | ---------------------- |
- | name | string | Yes | App account name. |
- | callback | AsyncCallback<boolean> | Yes | Callback used to return whether the app account allows application data synchronization. |
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------- | ---- | --------------------- |
+| name | string | Yes | Name of the target app account. |
+| callback | AsyncCallback<boolean> | Yes | Callback used to return the result.|
**Example**
@@ -356,7 +359,7 @@ Checks whether an app account allows application data synchronization. This meth
checkAppAccountSyncEnable(name: string): Promise<boolean>
-Checks whether an app account allows application data synchronization. This method uses a promise to return the result.
+Checks whether an app account allows app data synchronization. This API uses a promise to return the result.
**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC (available only to system applications)
@@ -364,15 +367,15 @@ Checks whether an app account allows application data synchronization. This meth
**Parameters**
- | Name | Type | Mandatory | Description |
- | ---- | ------ | ---- | ------- |
- | name | string | Yes | App account name. |
+| Name | Type | Mandatory | Description |
+| ---- | ------ | ---- | ------- |
+| name | string | Yes | Name of the target app account.|
**Return Value**
- | Type | Description |
- | :--------------------- | :-------------------- |
- | Promise<boolean> | Promise used to return the result. |
+| Type | Description |
+| :--------------------- | :-------------------- |
+| Promise<boolean> | Promise used to return the result.|
**Example**
@@ -387,20 +390,20 @@ Checks whether an app account allows application data synchronization. This meth
### setAccountCredential
-setAccountCredential(name: string, credentialType: string, credential: string, callback: AsyncCallback<void>): void
+setAccountCredential(name: string, credentialType: string, credential: string,callback: AsyncCallback<void>): void
-Sets a credential for an app account. This method uses an asynchronous callback to return the result.
+Sets a credential for an app account. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
- | Name | Type | Mandatory | Description |
- | -------------- | ------------------------- | ---- | -------------- |
- | name | string | Yes | App account name. |
- | credentialType | string | Yes | Type of the credential to set. |
- | credential | string | Yes | Credential to set. |
- | callback | AsyncCallback<void> | Yes | Callback invoked when a credential is set for the specified app account. |
+| Name | Type | Mandatory | Description |
+| -------------- | ------------------------- | ---- | ------------- |
+| name | string | Yes | Name of the target app account. |
+| credentialType | string | Yes | Type of the credential to set. |
+| credential | string | Yes | Credential to set. |
+| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
**Example**
@@ -415,23 +418,23 @@ Sets a credential for an app account. This method uses an asynchronous callback
setAccountCredential(name: string, credentialType: string, credential: string): Promise<void>
-Sets a credential for an app account. This method uses a promise to return the result asynchronously.
+Sets a credential for an app account. This API uses a promise to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
- | Name | Type | Mandatory | Description |
- | -------------- | ------ | ---- | ---------- |
- | name | string | Yes | App account name. |
- | credentialType | string | Yes | Type of the credential to set. |
- | credential | string | Yes | Credential to set. |
+| Name | Type | Mandatory | Description |
+| -------------- | ------ | ---- | ---------- |
+| name | string | Yes | Name of the target app account. |
+| credentialType | string | Yes | Type of the credential to set.|
+| credential | string | Yes | Credential to set. |
**Return Value**
- | Type | Description |
- | :------------------ | :-------------------- |
- | Promise<void> | Promise used to return the result. |
+| Type | Description |
+| :------------------ | :-------------------- |
+| Promise<void> | Promise used to return the result.|
**Example**
@@ -448,17 +451,17 @@ Sets a credential for an app account. This method uses a promise to return the r
setAccountExtraInfo(name: string, extraInfo: string, callback: AsyncCallback<void>): void
-Sets additional information for an app account. This method uses an asynchronous callback to return the result.
+Sets additional information for an app account. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
- | Name | Type | Mandatory | Description |
- | --------- | ------------------------- | ---- | ---------------- |
- | name | string | Yes | App account name. |
- | extraInfo | string | Yes | Additional information to set. |
- | callback | AsyncCallback<void> | Yes | Callback invoked when additional information is set for the specified app account. |
+| Name | Type | Mandatory | Description |
+| --------- | ------------------------- | ---- | --------------- |
+| name | string | Yes | Name of the target app account. |
+| extraInfo | string | Yes | Additional information to set. |
+| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
**Example**
@@ -473,22 +476,22 @@ Sets additional information for an app account. This method uses an asynchronous
setAccountExtraInfo(name: string, extraInfo: string): Promise<void>
-Sets additional information for an app account. This method uses a promise to return the result asynchronously.
+Sets additional information for an app account. This API uses a promise to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
- | Name | Type | Mandatory | Description |
- | --------- | ------ | ---- | --------- |
- | name | string | Yes | App account name. |
- | extraInfo | string | Yes | Additional information to set. |
+| Name | Type | Mandatory | Description |
+| --------- | ------ | ---- | --------- |
+| name | string | Yes | Name of the target app account. |
+| extraInfo | string | Yes | Additional information to set.|
**Return Value**
- | Type | Description |
- | :------------------ | :-------------------- |
- | Promise<void> | Promise used to return the result. |
+| Type | Description |
+| :------------------ | :-------------------- |
+| Promise<void> | Promise used to return the result.|
**Example**
@@ -505,7 +508,7 @@ Sets additional information for an app account. This method uses a promise to re
setAppAccountSyncEnable(name: string, isEnable: boolean, callback: AsyncCallback<void>): void
-Sets whether to enable application data synchronization for an app account. This method uses an asynchronous callback to return the result.
+Sets whether to enable app data synchronization for an app account. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC (available only to system applications)
@@ -513,11 +516,11 @@ Sets whether to enable application data synchronization for an app account. This
**Parameters**
- | Name | Type | Mandatory | Description |
- | -------- | ------------------------- | ---- | ------------------------- |
- | name | string | Yes | App account name. |
- | isEnable | boolean | Yes | Whether to enable app data synchronization. |
- | callback | AsyncCallback<void> | Yes | Callback invoked when application data synchronization is enabled or disabled for the app account. |
+| Name | Type | Mandatory | Description |
+| -------- | ------------------------- | ---- | ------------------------- |
+| name | string | Yes | Name of the target app account. |
+| isEnable | boolean | Yes | Whether to enable app data synchronization. |
+| callback | AsyncCallback<void> | Yes | Callback invoked when app data synchronization is enabled or disabled for the app account.|
**Example**
@@ -532,7 +535,7 @@ Sets whether to enable application data synchronization for an app account. This
setAppAccountSyncEnable(name: string, isEnable: boolean): Promise<void>
-Sets whether to enable application data synchronization for an app account. This method uses a promise to return the result asynchronously.
+Sets whether to enable app data synchronization for an app account. This API uses a promise to return the result.
**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC (available only to system applications)
@@ -540,16 +543,16 @@ Sets whether to enable application data synchronization for an app account. This
**Parameters**
- | Name | Type | Mandatory | Description |
- | -------- | ------- | ---- | ----------- |
- | name | string | Yes | App account name. |
- | isEnable | boolean | Yes | Whether to enable app data synchronization. |
+| Name | Type | Mandatory | Description |
+| -------- | ------- | ---- | ----------- |
+| name | string | Yes | Name of the target app account. |
+| isEnable | boolean | Yes | Whether to enable app data synchronization.|
**Return Value**
- | Type | Description |
- | :------------------ | :-------------------- |
- | Promise<void> | Promise used to return the result. |
+| Type | Description |
+| :------------------ | :-------------------- |
+| Promise<void> | Promise used to return the result.|
**Example**
@@ -566,18 +569,18 @@ Sets whether to enable application data synchronization for an app account. This
setAssociatedData(name: string, key: string, value: string, callback: AsyncCallback<void>): void
-Sets data to be associated with an app account. This method uses an asynchronous callback to return the result.
+Sets data to be associated with an app account. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
- | Name | Type | Mandatory | Description |
- | -------- | ------------------------- | ---- | ----------------- |
- | name | string | Yes | App account name. |
- | key | string | Yes | Key of the data to set. The private key can be customized. |
- | value | string | Yes | Value of the data to be set. |
- | callback | AsyncCallback<void> | Yes | Callback invoked when the data associated with the specified app account is set. |
+| Name | Type | Mandatory | Description |
+| -------- | ------------------------- | ---- | ----------------- |
+| name | string | Yes | Name of the target app account. |
+| key | string | Yes | Key of the data to set. The private key can be customized.|
+| value | string | Yes | Value of the data to be set. |
+| callback | AsyncCallback<void> | Yes | Callback invoked when the data associated with the specified app account is set.|
**Example**
@@ -591,23 +594,23 @@ Sets data to be associated with an app account. This method uses an asynchronous
setAssociatedData(name: string, key: string, value: string): Promise<void>
-Sets data to be associated with an app account. This method uses a promise to return the result asynchronously.
+Sets data to be associated with an app account. This API uses a promise to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
- | Name | Type | Mandatory | Description |
- | ----- | ------ | ---- | ----------------- |
- | name | string | Yes | App account name. |
- | key | string | Yes | Key of the data to set. The private key can be customized. |
- | value | string | Yes | Value of the data to be set. |
+| Name | Type | Mandatory | Description |
+| ----- | ------ | ---- | ----------------- |
+| name | string | Yes | Name of the target app account. |
+| key | string | Yes | Key of the data to set. The private key can be customized.|
+| value | string | Yes | Value of the data to be set. |
**Return Value**
- | Type | Description |
- | :------------------ | :-------------------- |
- | Promise<void> | Promise used to return the result. |
+| Type | Description |
+| :------------------ | :-------------------- |
+| Promise<void> | Promise used to return the result.|
**Example**
@@ -624,17 +627,17 @@ Sets data to be associated with an app account. This method uses a promise to re
getAccountCredential(name: string, credentialType: string, callback: AsyncCallback<string>): void
-Obtains the credential of an app account. This method uses an asynchronous callback to return the result.
+Obtains the credentials (such as the digital password, face image, and PIN) of an app account. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
- | Name | Type | Mandatory | Description |
- | -------------- | --------------------------- | ---- | -------------- |
- | name | string | Yes | App account name. |
- | credentialType | string | Yes | Type of the credential to obtain. |
- | callback | AsyncCallback<string> | Yes | Callback invoked to return the credential of the specified app account. |
+| Name | Type | Mandatory | Description |
+| -------------- | --------------------------- | ---- | -------------- |
+| name | string | Yes | Name of the target app account. |
+| credentialType | string | Yes | Type of the credential to obtain.|
+| callback | AsyncCallback<string> | Yes | Callback invoked to return the credential obtained.|
**Example**
@@ -650,22 +653,22 @@ Obtains the credential of an app account. This method uses an asynchronous callb
getAccountCredential(name: string, credentialType: string): Promise<string>
-Obtains the credential of an app account. This method uses a promise to return the result asynchronously.
+Obtains the credential of an app account. This API uses a promise to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
- | Name | Type | Mandatory | Description |
- | -------------- | ------ | ---- | ---------- |
- | name | string | Yes | App account name. |
- | credentialType | string | Yes | Type of the credential to obtain. |
+| Name | Type | Mandatory | Description |
+| -------------- | ------ | ---- | ---------- |
+| name | string | Yes | Name of the target app account. |
+| credentialType | string | Yes | Type of the credential to obtain.|
**Return Value**
- | Type | Description |
- | :-------------------- | :-------------------- |
- | Promise<string> | Promise used to return the result. |
+| Type | Description |
+| :-------------------- | :-------------------- |
+| Promise<string> | Promise used to return the result.|
**Example**
@@ -682,16 +685,16 @@ Obtains the credential of an app account. This method uses a promise to return t
getAccountExtraInfo(name: string, callback: AsyncCallback<string>): void
-Obtains additional information of an app account. This method uses an asynchronous callback to return the result.
+Obtains additional information (information that can be converted into the string type) about an app account. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
- | Name | Type | Mandatory | Description |
- | -------- | --------------------------- | ---- | ---------------- |
- | name | string | Yes | App account name. |
- | callback | AsyncCallback<string> | Yes | Callback invoked to return the additional information of the specified app account. |
+| Name | Type | Mandatory | Description |
+| -------- | --------------------------- | ---- | --------------- |
+| name | string | Yes | Name of the target app account. |
+| callback | AsyncCallback<string> | Yes | Callback invoked to return the additional information of the specified app account.|
**Example**
@@ -707,21 +710,21 @@ Obtains additional information of an app account. This method uses an asynchrono
getAccountExtraInfo(name: string): Promise<string>
-Obtains additional information of an app account. This method uses a promise to return the result asynchronously.
+Obtains additional information of an app account. This API uses a promise to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
- | Name | Type | Mandatory | Description |
- | ---- | ------ | ---- | ------- |
- | name | string | Yes | App account name. |
+| Name | Type | Mandatory | Description |
+| ---- | ------ | ---- | ------- |
+| name | string | Yes | Name of the target app account.|
**Return Value**
- | Type | Description |
- | :-------------------- | :-------------------- |
- | Promise<string> | Promise used to return the result. |
+| Type | Description |
+| :-------------------- | :-------------------- |
+| Promise<string> | Promise used to return the result.|
**Example**
@@ -738,17 +741,17 @@ Obtains additional information of an app account. This method uses a promise to
getAssociatedData(name: string, key: string, callback: AsyncCallback<string>): void
-Obtains data associated with an app account. This method uses an asynchronous callback to return the result.
+Obtains data associated with an app account. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
- | Name | Type | Mandatory | Description |
- | -------- | --------------------------- | ---- | ----------------- |
- | name | string | Yes | App account name. |
- | key | string | Yes | Key of the data to obtain. |
- | callback | AsyncCallback<string> | Yes | Callback invoked to return the data associated with the specified app account. |
+| Name | Type | Mandatory | Description |
+| -------- | --------------------------- | ---- | ----------------- |
+| name | string | Yes | Name of the target app account. |
+| key | string | Yes | Key of the data to obtain. |
+| callback | AsyncCallback<string> | Yes | Callback invoked to return the data associated with the specified app account.|
**Example**
@@ -764,22 +767,22 @@ Obtains data associated with an app account. This method uses an asynchronous ca
getAssociatedData(name: string, key: string): Promise<string>
-Obtains data associated with an app account. This method uses a promise to return the result asynchronously.
+Obtains data associated with an app account. This API uses a promise to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
- | Name | Type | Mandatory | Description |
- | ---- | ------ | ---- | ----------- |
- | name | string | Yes | App account name. |
- | key | string | Yes | Key of the data to obtain. |
+| Name | Type | Mandatory | Description |
+| ---- | ------ | ---- | --------- |
+| name | string | Yes | Name of the target app account. |
+| key | string | Yes | Key of the data to obtain.|
**Return Value**
- | Type | Description |
- | :-------------------- | :-------------------- |
- | Promise<string> | Promise used to return the result. |
+| Type | Description |
+| :-------------------- | :-------------------- |
+| Promise<string> | Promise used to return the result.|
**Example**
@@ -796,7 +799,7 @@ Obtains data associated with an app account. This method uses a promise to retur
getAllAccessibleAccounts(callback: AsyncCallback<Array<AppAccountInfo>>): void
-Obtains information about all accessible app accounts. This method uses an asynchronous callback to return the result.
+Obtains information about all accessible app accounts. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.GET_ALL_APP_ACCOUNTS (available only to system applications)
@@ -804,9 +807,9 @@ Obtains information about all accessible app accounts. This method uses an async
**Parameters**
- | Name | Type | Mandatory | Description |
- | -------- | ---------------------------------------- | ---- | -------- |
- | callback | AsyncCallback<Array<AppAccountInfo>> | Yes | Callback invoked to return information about all accessible app accounts. |
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | --------- |
+| callback | AsyncCallback<Array<AppAccountInfo>> | Yes | Callback invoked to return information about all accessible app accounts.|
**Example**
@@ -822,7 +825,7 @@ Obtains information about all accessible app accounts. This method uses an async
getAllAccessibleAccounts(): Promise<Array<AppAccountInfo>>
-Obtains information about all accessible app accounts. This method uses an asynchronous callback to return the result.
+Obtains information about all accessible app accounts. This API uses a promise to return the result.
**Required permissions**: ohos.permission.GET_ALL_APP_ACCOUNTS (available only to system applications)
@@ -830,9 +833,9 @@ Obtains information about all accessible app accounts. This method uses an async
**Parameters**
- | Type | Description |
- | ---------------------------------------- | --------------------- |
- | Promise<Array<AppAccountInfo>> | Promise used to return the result. |
+| Type | Description |
+| ---------------------------------------- | --------------------- |
+| Promise<Array<AppAccountInfo>> | Promise used to return the result.|
**Example**
@@ -849,7 +852,7 @@ Obtains information about all accessible app accounts. This method uses an async
getAllAccounts(owner: string, callback: AsyncCallback<Array<AppAccountInfo>>): void
-Obtains information about all app accounts of the specified app. This method uses an asynchronous callback to return the result.
+Obtains information about all app accounts of the specified app. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.GET_ALL_APP_ACCOUNTS (available only to system applications)
@@ -857,10 +860,10 @@ Obtains information about all app accounts of the specified app. This method use
**Parameters**
- | Name | Type | Mandatory | Description |
- | -------- | ---------------------------------------- | ---- | -------- |
- | owner | string | Yes | Bundle name of the app. |
- | callback | AsyncCallback<Array<AppAccountInfo>> | Yes | Callback invoked to return information about all accessible app accounts. |
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | --------- |
+| owner | string | Yes | Owner of the app account. The value is the bundle name of the app. |
+| callback | AsyncCallback<Array<AppAccountInfo>> | Yes | Callback invoked to return the app account information obtained.|
**Example**
@@ -877,7 +880,7 @@ Obtains information about all app accounts of the specified app. This method use
getAllAccounts(owner: string): Promise<Array<AppAccountInfo>>
-Obtains information about all app accounts of the specified app. This method uses an asynchronous callback to return the result.
+Obtains information about all app accounts of the specified app. This API uses a promise to return the result.
**Required permissions**: ohos.permission.GET_ALL_APP_ACCOUNTS (available only to system applications)
@@ -885,15 +888,15 @@ Obtains information about all app accounts of the specified app. This method use
**Parameters**
- | Name | Type | Mandatory | Description |
- | ----- | ------ | ---- | ----- |
- | owner | string | Yes | Bundle name of the app. |
+| Name | Type | Mandatory | Description |
+| ----- | ------ | ---- | ------ |
+| owner | string | Yes | Owner of the app account. The value is the bundle name of the app.|
**Parameters**
- | Type | Description |
- | ---------------------------------------- | --------------------- |
- | Promise<Array<AppAccountInfo>> | Promise used to return the result. |
+| Type | Description |
+| ---------------------------------------- | --------------------- |
+| Promise<Array<AppAccountInfo>> | Promise used to return the result.|
**Example**
@@ -911,17 +914,17 @@ Obtains information about all app accounts of the specified app. This method use
on(type: 'change', owners: Array<string>, callback: Callback<Array<AppAccountInfo>>): void
-Subscribes to the account change event of the specified account owners. This method uses an asynchronous callback to return the result.
+Subscribes to the account change events of the specified account owners. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
- | Name | Type | Mandatory | Description |
- | -------- | ---------------------------------------- | ---- | ------------------------------ |
- | type | 'change' | Yes | Type of the event to subscribe to. The subscriber will receive a notification when the account owners update their accounts. |
- | owners | Array<string> | Yes | Owners of the accounts. |
- | callback | Callback<Array<AppAccountInfo>> | Yes | Callback invoked to return the account change. |
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | ------------------------------ |
+| type | 'change' | Yes | Account change events to subscribe to. The subscriber will receive a notification when the account owners update their accounts.|
+| owners | Array<string> | Yes | Account owners. |
+| callback | Callback<Array<AppAccountInfo>> | Yes | Callback invoked to return the account changes. |
**Example**
@@ -942,16 +945,16 @@ Subscribes to the account change event of the specified account owners. This met
off(type: 'change', callback?: Callback>): void
-Unsubscribes from the account change event. This method uses an asynchronous callback to return the result.
+Unsubscribes from the account change events. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
- | Name | Type | Mandatory | Description |
- | -------- | -------------------------------- | ---- | ------------ |
- | type | 'change' | Yes | Account change event to unsubscribe from. |
- | callback | Callback> | No | Callback used to report the account change. |
+| Name | Type | Mandatory | Description |
+| -------- | -------------------------------- | ---- | ------------ |
+| type | 'change' | Yes | Account change events to unsubscribe from. |
+| callback | Callback> | No | Callback used to report the account changes.|
**Example**
@@ -975,19 +978,19 @@ Unsubscribes from the account change event. This method uses an asynchronous cal
authenticate(name: string, owner: string, authType: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void
-Authenticates an app account to obtain the Open Authorization (OAuth) access token. This method uses an asynchronous callback to return the result.
+Authenticates an app account to obtain the Open Authorization (OAuth) token. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
- | Name | Type | Mandatory | Description |
- | -------- | --------------------- | ---- | --------------- |
- | name | string | Yes | Name of the app account to authenticate. |
- | owner | string | Yes | Bundle name of the app. |
- | authType | string | Yes | Authentication type. |
- | options | {[key: string]: any} | Yes | Options for the authentication. |
- | callback | AuthenticatorCallback | Yes | Authenticator callback invoked to return the authentication result. |
+| Name | Type | Mandatory | Description |
+| -------- | --------------------- | ---- | --------------- |
+| name | string | Yes | Name of the app account to authenticate. |
+| owner | string | Yes | Owner of the app account. The value is the bundle name of the app. |
+| authType | string | Yes | Authentication type. |
+| options | {[key: string]: any} | Yes | Options for the authentication. |
+| callback | AuthenticatorCallback | Yes | Authenticator callback invoked to return the authentication result.|
**Example**
@@ -1017,18 +1020,18 @@ Authenticates an app account to obtain the Open Authorization (OAuth) access tok
getOAuthToken(name: string, owner: string, authType: string, callback: AsyncCallback<string>): void
-Obtains the OAuth access token of an app account based on the specified authentication type. This method uses an asynchronous callback to return the result.
+Obtains the OAuth token of an app account based on the specified authentication type. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
- | Name | Type | Mandatory | Description |
- | -------- | --------------------------- | ---- | ----------- |
- | name | string | Yes | App account name. |
- | owner | string | Yes | Bundle name of the app. |
- | authType | string | Yes | Authentication type. |
- | callback | AsyncCallback<string> | Yes | Callback invoked to return the result. |
+| Name | Type | Mandatory | Description |
+| -------- | --------------------------- | ---- | ----------- |
+| name | string | Yes | Name of the target app account. |
+| owner | string | Yes | Owner of the app account. The value is the bundle name of the app.|
+| authType | string | Yes | Authentication type. |
+| callback | AsyncCallback<string> | Yes | Callback invoked to return the result. |
**Example**
@@ -1044,23 +1047,23 @@ Obtains the OAuth access token of an app account based on the specified authenti
getOAuthToken(name: string, owner: string, authType: string): Promise<string>
-Obtains the OAuth access token of an app account based on the specified authentication type. This method uses a promise to return the result.
+Obtains the OAuth token of an app account based on the specified authentication type. This API uses a promise to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
- | Name | Type | Mandatory | Description |
- | -------- | ------ | ---- | ----------- |
- | name | string | Yes | App account name. |
- | owner | string | Yes | Bundle name of the app. |
- | authType | string | Yes | Authentication type. |
+| Name | Type | Mandatory | Description |
+| -------- | ------ | ---- | ----------- |
+| name | string | Yes | Name of the target app account. |
+| owner | string | Yes | Owner of the app account. The value is the bundle name of the app.|
+| authType | string | Yes | Authentication type. |
**Parameters**
- | Type | Description |
- | --------------------- | --------------------- |
- | Promise<string> | Promise used to return the result. |
+| Type | Description |
+| --------------------- | --------------------- |
+| Promise<string> | Promise used to return the result.|
**Example**
@@ -1077,18 +1080,18 @@ Obtains the OAuth access token of an app account based on the specified authenti
setOAuthToken(name: string, authType: string, token: string, callback: AsyncCallback<void>): void
-Sets an OAuth access token for an app account. This method uses an asynchronous callback to return the result.
+Sets an OAuth token for an app account. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
- | Name | Type | Mandatory | Description |
- | -------- | ------------------------- | ---- | -------- |
- | name | string | Yes | App account name. |
- | authType | string | Yes | Authentication type. |
- | token | string | Yes | OAuth access token to set. |
- | callback | AsyncCallback<void> | Yes | Callback invoked to return the result. |
+| Name | Type | Mandatory | Description |
+| -------- | ------------------------- | ---- | -------- |
+| name | string | Yes | Name of the target app account.|
+| authType | string | Yes | Authentication type. |
+| token | string | Yes | OAuth token to set.|
+| callback | AsyncCallback<void> | Yes | Callback invoked to return the result.|
**Example**
@@ -1103,23 +1106,23 @@ Sets an OAuth access token for an app account. This method uses an asynchronous
setOAuthToken(name: string, authType: string, token: string): Promise<void>
-Sets an OAuth access token for an app account. This method uses a promise to return the result.
+Sets an OAuth token for an app account. This API uses a promise to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
- | Name | Type | Mandatory | Description |
- | -------- | ------ | ---- | -------- |
- | name | string | Yes | App account name. |
- | authType | string | Yes | Authentication type. |
- | token | string | Yes | OAuth access token to set. |
+| Name | Type | Mandatory | Description |
+| -------- | ------ | ---- | -------- |
+| name | string | Yes | Name of the target app account.|
+| authType | string | Yes | Authentication type. |
+| token | string | Yes | OAuth token to set.|
**Parameters**
- | Type | Description |
- | ------------------- | --------------------- |
- | Promise<void> | Promise used to return the result. |
+| Type | Description |
+| ------------------- | --------------------- |
+| Promise<void> | Promise used to return the result.|
**Example**
@@ -1136,19 +1139,19 @@ Sets an OAuth access token for an app account. This method uses a promise to ret
deleteOAuthToken(name: string, owner: string, authType: string, token: string, callback: AsyncCallback<void>): void
-Deletes the specified OAuth access token for an app account. This method uses an asynchronous callback to return the result.
+Deletes the specified OAuth token for an app account. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
- | Name | Type | Mandatory | Description |
- | -------- | ------------------------- | ---- | ------------ |
- | name | string | Yes | App account name. |
- | owner | string | Yes | Bundle name of the app. |
- | authType | string | Yes | Authentication type. |
- | token | string | Yes | OAuth access token to delete. |
- | callback | AsyncCallback<void> | Yes | Callback invoked to return the result. |
+| Name | Type | Mandatory | Description |
+| -------- | ------------------------- | ---- | ------------ |
+| name | string | Yes | Name of the target app account. |
+| owner | string | Yes | Owner of the app account. The value is the bundle name of the app. |
+| authType | string | Yes | Authentication type. |
+| token | string | Yes | OAuth token to delete.|
+| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. |
**Example**
@@ -1163,24 +1166,24 @@ Deletes the specified OAuth access token for an app account. This method uses an
deleteOAuthToken(name: string, owner: string, authType: string, token: string): Promise<void>
-Deletes the specified OAuth access token for an app account. This method uses a promise to return the result.
+Deletes the specified OAuth token for an app account. This API uses a promise to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
- | Name | Type | Mandatory | Description |
- | -------- | ------ | ---- | ------------ |
- | name | string | Yes | App account name. |
- | owner | string | Yes | Bundle name of the app. |
- | authType | string | Yes | Authentication type. |
- | token | string | Yes | OAuth access token to delete. |
+| Name | Type | Mandatory | Description |
+| -------- | ------ | ---- | ------------ |
+| name | string | Yes | Name of the target app account. |
+| owner | string | Yes | Owner of the app account. The value is the bundle name of the app. |
+| authType | string | Yes | Authentication type. |
+| token | string | Yes | OAuth token to delete.|
**Parameters**
- | Type | Description |
- | ------------------- | --------------------- |
- | Promise<void> | Promise used to return the result. |
+| Type | Description |
+| ------------------- | --------------------- |
+| Promise<void> | Promise used to return the result.|
**Example**
@@ -1197,19 +1200,19 @@ Deletes the specified OAuth access token for an app account. This method uses a
setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVisible: boolean, callback: AsyncCallback<void>): void
-Sets the visibility of an OAuth access token to the specified app. This method uses an asynchronous callback to return the result.
+Sets the visibility of an OAuth token to an app. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
- | Name | Type | Mandatory | Description |
- | ---------- | ------------------------- | ---- | ------------ |
- | name | string | Yes | App account name. |
- | authType | string | Yes | Authentication type. |
- | bundleName | string | Yes | Bundle name of the app. |
- | isVisible | boolean | Yes | Whether the OAuth access token is visible to the app. |
- | callback | AsyncCallback<void> | Yes | Callback invoked to return the result. |
+| Name | Type | Mandatory | Description |
+| ---------- | ------------------------- | ---- | ------------------------- |
+| name | string | Yes | Name of the target app account. |
+| authType | string | Yes | Authentication type. |
+| bundleName | string | Yes | Bundle name of the app. |
+| isVisible | boolean | Yes | Whether the OAuth token is visible to the app. The value **true** means visible, and the value **false** means the opposite.|
+| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. |
**Example**
@@ -1224,24 +1227,24 @@ Sets the visibility of an OAuth access token to the specified app. This method u
setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVisible: boolean): Promise<void>
-Sets the visibility of an OAuth access token to the specified app. This method uses a promise to return the result.
+Sets the visibility of an OAuth token to an app. This API uses a promise to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
- | Name | Type | Mandatory | Description |
- | ---------- | ------- | ---- | ------------ |
- | name | string | Yes | App account name. |
- | authType | string | Yes | Authentication type. |
- | bundleName | string | Yes | Bundle name of the app. |
- | isVisible | boolean | Yes | Whether the OAuth access token is visible to the app. |
+| Name | Type | Mandatory | Description |
+| ---------- | ------- | ---- | ------------ |
+| name | string | Yes | Name of the target app account. |
+| authType | string | Yes | Authentication type. |
+| bundleName | string | Yes | Bundle name of the app.|
+| isVisible | boolean | Yes | Whether the OAuth token is visible to the app. |
**Parameters**
- | Type | Description |
- | ------------------- | --------------------- |
- | Promise<void> | Promise used to return the result. |
+| Type | Description |
+| ------------------- | --------------------- |
+| Promise<void> | Promise used to return the result.|
**Example**
@@ -1258,18 +1261,18 @@ Sets the visibility of an OAuth access token to the specified app. This method u
checkOAuthTokenVisibility(name: string, authType: string, bundleName: string, callback: AsyncCallback<boolean>): void
-Checks whether an OAuth token is visible to the specified app. This method uses an asynchronous callback to return the result.
+Checks whether an OAuth token is visible to an app. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
- | Name | Type | Mandatory | Description |
- | ---------- | ---------------------------- | ---- | ------------- |
- | name | string | Yes | App account name. |
- | authType | string | Yes | Authentication type. |
- | bundleName | string | Yes | Bundle name of the app. |
- | callback | AsyncCallback<boolean> | Yes | Callback invoked to return the result. |
+| Name | Type | Mandatory | Description |
+| ---------- | ---------------------------- | ---- | ----------- |
+| name | string | Yes | Name of the target app account. |
+| authType | string | Yes | Authentication type. |
+| bundleName | string | Yes | Bundle name of the app.|
+| callback | AsyncCallback<boolean> | Yes | Callback invoked to return the result. |
**Example**
@@ -1285,23 +1288,23 @@ Checks whether an OAuth token is visible to the specified app. This method uses
checkOAuthTokenVisibility(name: string, authType: string, bundleName: string): Promise<boolean>
-Checks whether an OAuth token is visible to the specified app. This method uses a promise to return the result.
+Checks whether an OAuth token is visible to an app. This API uses a promise to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
- | Name | Type | Mandatory | Description |
- | ---------- | ------ | ---- | ------------- |
- | name | string | Yes | App account name. |
- | authType | string | Yes | Authentication type. |
- | bundleName | string | Yes | Bundle name of the app. |
+| Name | Type | Mandatory | Description |
+| ---------- | ------ | ---- | ------------- |
+| name | string | Yes | Name of the target app account. |
+| authType | string | Yes | Authentication type. |
+| bundleName | string | Yes | Bundle name of the app.|
**Parameters**
- | Type | Description |
- | ---------------------- | --------------------- |
- | Promise<boolean> | Promise used to return the result. |
+| Type | Description |
+| ---------------------- | --------------------- |
+| Promise<boolean> | Promise used to return the result.|
**Example**
@@ -1318,17 +1321,17 @@ Checks whether an OAuth token is visible to the specified app. This method uses
getAllOAuthTokens(name: string, owner: string, callback: AsyncCallback<Array<OAuthTokenInfo>>): void
-Obtains information about all OAuth access tokens of an app account visible to the specified app. This method uses an asynchronous callback to return the result.
+Obtains all OAuth tokens visible to the caller for an app account. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
- | Name | Type | Mandatory | Description |
- | -------- | ---------------------------------------- | ---- | ----------- |
- | name | string | Yes | App account name. |
- | owner | string | Yes | Bundle name of the app. |
- | callback | AsyncCallback<Array<OAuthTokenInfo>> | Yes | Callback invoked to return the result. |
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | ----------- |
+| name | string | Yes | Name of the target app account. |
+| owner | string | Yes | Owner of the app account. The value is the bundle name of the app.|
+| callback | AsyncCallback<Array< [OAuthTokenInfo](#oauthtokeninfo8)>> | Yes | Callback invoked to return the result. |
**Example**
@@ -1344,22 +1347,22 @@ Obtains information about all OAuth access tokens of an app account visible to t
getAllOAuthTokens(name: string, owner: string): Promise<Array<OAuthTokenInfo>>
-Obtains information about all OAuth access tokens of an app account visible to the specified app. This method uses a promise to return the result.
+Obtains all OAuth tokens visible to the caller for an app account. This API uses a promise to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
- | Name | Type | Mandatory | Description |
- | ----- | ------ | ---- | ----------- |
- | name | string | Yes | App account name. |
- | owner | string | Yes | Bundle name of the app. |
+| Name | Type | Mandatory | Description |
+| ----- | ------ | ---- | ----------- |
+| name | string | Yes | Name of the target app account. |
+| owner | string | Yes | Owner of the app account. The value is the bundle name of the app.|
**Parameters**
- | Type | Description |
- | ---------------------------------------- | --------------------- |
- | Promise<Array<OAuthTokenInfo>> | Promise used to return the result. |
+| Type | Description |
+| ---------------------------------------- | --------------------- |
+| Promise<Array< [OAuthTokenInfo](#oauthtokeninfo8)>> | Promise used to return the result.|
**Example**
@@ -1376,17 +1379,17 @@ Obtains information about all OAuth access tokens of an app account visible to t
getOAuthList(name: string, authType: string, callback: AsyncCallback<Array<string>>): void
-Obtains the authorization list of OAuth access tokens of an app account. This method uses an asynchronous callback to return the result.
+Obtains a list of authorized OAuth tokens of an app account. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
- | Name | Type | Mandatory | Description |
- | -------- | ---------------------------------------- | ---- | ----------- |
- | name | string | Yes | App account name. |
- | owner | string | Yes | Bundle name of the app. |
- | callback | AsyncCallback<Array<string>> | Yes | Callback invoked to return the result. |
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | ----------------------- |
+| name | string | Yes | Name of the target app account. |
+| authType | string | Yes | Authorization type.|
+| callback | AsyncCallback<Array<string>> | Yes | Callback invoked to return the result. |
**Example**
@@ -1402,22 +1405,22 @@ Obtains the authorization list of OAuth access tokens of an app account. This me
getOAuthList(name: string, authType: string): Promise<Array<string>>
-Obtains the authorization list of OAuth access tokens of an app account. This method uses a promise to return the result.
+Obtains a list of authorized OAuth tokens of an app account. This API uses a promise to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
- | Name | Type | Mandatory | Description |
- | ----- | ------ | ---- | ----------- |
- | name | string | Yes | App account name. |
- | owner | string | Yes | Bundle name of the app. |
+| Name | Type | Mandatory | Description |
+| -------- | ------ | ---- | ----------------------- |
+| name | string | Yes | Name of the target app account. |
+| authType | string | Yes | Authorization type.|
**Parameters**
- | Type | Description |
- | ---------------------------------- | --------------------- |
- | Promise<Array<string>> | Promise used to return the result. |
+| Type | Description |
+| ---------------------------------- | --------------------- |
+| Promise<Array<string>> | Promise used to return the result.|
**Example**
@@ -1434,20 +1437,21 @@ Obtains the authorization list of OAuth access tokens of an app account. This me
getAuthenticatorCallback(sessionId: string, callback: AsyncCallback<AuthenticatorCallback>): void
-Obtains the authenticator callback for a session. This method uses an asynchronous callback to return the result.
+Obtains the authenticator callback for an authentication session. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
- | Name | Type | Mandatory | Description |
- | --------- | ---------------------------------------- | ---- | -------- |
- | sessionId | string | Yes | ID of the session to authenticate. |
- | callback | AsyncCallback<AuthenticatorCallback> | Yes | Callback invoked to return the result. |
+| Name | Type | Mandatory | Description |
+| --------- | ---------------------------------------- | ---- | -------- |
+| sessionId | string | Yes | ID of the authentication session.|
+| callback | AsyncCallback<AuthenticatorCallback> | Yes | Callback invoked to return the result.|
**Example**
```js
+ import featureAbility from '@ohos.ability.featureAbility';
const appAccountManager = account_appAccount.createAppAccountManager();
featureAbility.getWant((err, want) => {
var sessionId = want.parameters[account_appAccount.Constants.KEY_SESSION_ID];
@@ -1469,21 +1473,21 @@ Obtains the authenticator callback for a session. This method uses an asynchrono
getAuthenticatorCallback(sessionId: string): Promise<AuthenticatorCallback>
-Obtains the authenticator callback for a session. This method uses a promise to return the result.
+Obtains the authenticator callback for an authentication session. This API uses a promise to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
- | Name | Type | Mandatory | Description |
- | --------- | ------ | ---- | -------- |
- | sessionId | string | Yes | ID of the session to authenticate. |
+| Name | Type | Mandatory | Description |
+| --------- | ------ | ---- | -------- |
+| sessionId | string | Yes | ID of the authentication session.|
**Parameters**
- | Type | Description |
- | ------------------------------------ | --------------------- |
- | Promise<AuthenticatorCallback> | Promise used to return the result. |
+| Type | Description |
+| ------------------------------------ | --------------------- |
+| Promise<AuthenticatorCallback> | Promise used to return the result.|
**Example**
@@ -1509,16 +1513,16 @@ Obtains the authenticator callback for a session. This method uses a promise to
getAuthenticatorInfo(owner: string, callback: AsyncCallback<AuthenticatorInfo>): void
-Obtains authenticator information of an app account. This method uses an asynchronous callback to return the result.
+Obtains authenticator information of an app account. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
- | Name | Type | Mandatory | Description |
- | -------- | -------------------------------------- | ---- | ----------- |
- | owner | string | Yes | Bundle name of the app. |
- | callback | AsyncCallback<AuthenticatorInfo> | Yes | Callback invoked to return the result. |
+| Name | Type | Mandatory | Description |
+| -------- | -------------------------------------- | ---- | ----------- |
+| owner | string | Yes | Owner of the app account. The value is the bundle name of the app.|
+| callback | AsyncCallback<AuthenticatorInfo> | Yes | Callback invoked to return the result. |
**Example**
@@ -1534,21 +1538,21 @@ Obtains authenticator information of an app account. This method uses an asynchr
getAuthenticatorInfo(owner: string): Promise<AuthenticatorInfo>
-Obtains authenticator information of an app account. This method uses a promise to return the result.
+Obtains authenticator information of an app account. This API uses a promise to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
- | Name | Type | Mandatory | Description |
- | ----- | ------ | ---- | ----------- |
- | owner | string | Yes | Bundle name of the app. |
+| Name | Type | Mandatory | Description |
+| ----- | ------ | ---- | ----------- |
+| owner | string | Yes | Owner of the app account. The value is the bundle name of the app.|
**Parameters**
- | Type | Description |
- | -------------------------------- | --------------------- |
- | Promise<AuthenticatorInfo> | Promise used to return the result. |
+| Type | Description |
+| -------------------------------- | --------------------- |
+| Promise<AuthenticatorInfo> | Promise used to return the result.|
**Example**
@@ -1561,27 +1565,397 @@ Obtains authenticator information of an app account. This method uses a promise
});
```
+### checkAppAccess9+
+
+checkAppAccess(name: string, bundleName: string, callback: AsyncCallback<boolean>): void
+
+Checks whether an app account is authorized to access an app. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ---------- | ---------------------------- | ----- | ---------------- |
+| name | string | Yes | Name of the target app account. |
+| bundleName | string | Yes | Bundle name of the app to check. |
+| callback | AsyncCallback<boolean> | Yes | Callback invoked to return the result. |
+
+**Example**
+
+ ```js
+ const appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.checkAppAccess("zhangsan", "com.example.ohos.accountjsdemo", (err, data) => {
+ console.log('checkAppAccess: ' + JSON.stringify(data));
+ console.log("checkAppAccess err: " + JSON.stringify(err));
+ });
+ ```
+
+### checkAppAccess9+
+
+checkAppAccess(name: string, bundleName: string): Promise<boolean>
+
+Checks whether an app account is authorized to access an app. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ---------- | ------ | ----- | ---------------- |
+| name | string | Yes | Name of the target app account. |
+| bundleName | string | Yes | Bundle name of the app to check. |
+
+**Parameters**
+
+| Type | Description |
+| ---------------------- | --------------------------------- |
+| Promise<boolean> | Promise used to return the result.|
+
+**Example**
+
+ ```js
+ const appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.checkAppAccess("zhangsan", "com.example.ohos.accountjsdemo").then((data) => {
+ console.log('checkAppAccess: ' + JSON.stringify(data));
+ }).catch((err) => {
+ console.log("checkAppAccess err: " + JSON.stringify(err));
+ });
+ ```
+
+### deleteAccountCredential9+
+
+deleteAccountCredential(name: string, credentialType: string, callback: AsyncCallback<void>): void
+
+Deletes the credential of an app account. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------------- | ------------------------- | ----- | -------------- |
+| name | string | Yes | Name of the target app account.|
+| credentialType | string | Yes | Type of the credential to delete. |
+| callback | AsyncCallback<void> | Yes | Callback invoked to return the result.|
+
+**Example**
+
+ ```js
+ const appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.deleteAccountCredential("zhangsan", "pin", (err, data) => {
+ console.log('deleteAccountCredential: ' + JSON.stringify(data));
+ console.log("deleteAccountCredential err: " + JSON.stringify(err));
+ });
+ ```
+
+### deleteAccountCredential9+
+
+deleteAccountCredential(name: string, credentialType: string): Promise<void>
+
+Deletes the credential of an app account. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------------- | ------ | ----- | --------------- |
+| name | string | Yes | Name of the target app account.|
+| credentialType | string | Yes | Type of the credential to delete. |
+
+**Parameters**
+
+| Type | Description |
+| ------------------- | -------------------------------- |
+| Promise<void> | Promise used to return the result.|
+
+**Example**
+
+ ```js
+ const appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.deleteAccountCredential("zhangsan", "pin").then((data) => {
+ console.log('deleteAccountCredential: ' + JSON.stringify(data));
+ }).catch((err) => {
+ console.log("deleteAccountCredential err: " + JSON.stringify(err));
+ });
+ ```
+
+### checkAccountLabels9+
+
+checkAccountLabels(name: string, owner: string, labels: Array<string>, callback: AsyncCallback<boolean>): void;
+
+Checks whether an app account has specific labels. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------------- | ------------------------- | ----- | --------------- |
+| name | string | Yes | Name of the target app account. |
+| owner | string | Yes | Owner of the app account. The value is the bundle name of the app.|
+| labels | Array<string< | Yes | Labels to check. |
+| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. |
+
+**Example**
+
+ ```js
+ const appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.checkAccountLabels("zhangsan", "com.example.ohos.accountjsdemo", (err, data) => {
+ console.log('checkAccountLabels: ' + JSON.stringify(data));
+ console.log("checkAccountLabels err: " + JSON.stringify(err));
+ });
+ ```
+
+### checkAccountLabels9+
+
+checkAccountLabels(name: string, owner: string, labels: Array<string>): Promise<void>
+
+Checks whether an app account has specific labels. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------------- | ------------------------- | ----- | --------------- |
+| name | string | Yes | Name of the target app account. |
+| owner | string | Yes | Owner of the app account. The value is the bundle name of the app.|
+| labels | Array<string< | Yes | Labels to check. |
+
+**Parameters**
+
+| Type | Description |
+| ------------------- | -------------------------------- |
+| Promise<boolean> | Promise used to return the result.|
+
+**Example**
+
+ ```js
+ const appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.checkAccountLabels("zhangsan", "com.example.ohos.accountjsdemo").then((data) => {
+ console.log('checkAccountLabels: ' + JSON.stringify(data));
+ }).catch((err) => {
+ console.log("checkAccountLabels err: " + JSON.stringify(err));
+ });
+ ```
+
+### selectAccountsByOptions9+
+
+selectAccountsByOptions(options: SelectAccountsOptions, callback: AsyncCallback<Array<AppAccountInfo>>);
+
+Selects the accounts accessible to the requester based on the options. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------------- | ----------------------------------- | ----- | --------------- |
+| options | SelectAccountsOptions | Yes | Options for selecting accounts. |
+| callback | AsyncCallback<AppAccountInfo> | Yes | Callback invoked to return the result. |
+
+**Example**
+
+ ```js
+ const appAccountManager = account_appAccount.createAppAccountManager();
+ var options = {
+ allowedOwners: ["com.example.ohos.accountjsdemo"]
+ };
+ appAccountManager.selectAccountsByOptions(options, (err, data) => {
+ console.log('selectAccountsByOptions: ' + JSON.stringify(data));
+ console.log("selectAccountsByOptions err: " + JSON.stringify(err));
+ });
+ ```
+
+### selectAccountsByOptions9+
+
+selectAccountsByOptions(options: SelectAccountsOptions): Promise<void>
+
+Selects the accounts accessible to the requester based on the options. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------------- | ------------------------- | ----- | --------------- |
+| options | SelectAccountsOptions | Yes | Options for selecting accounts. |
+
+**Parameters**
+
+| Type | Description |
+| ------------------- | -------------------------------- |
+| Promise<AppAccountInfo> | Promise used to return the result.|
+
+**Example**
+
+ ```js
+ const appAccountManager = account_appAccount.createAppAccountManager();
+ var options = {
+ allowedOwners: ["com.example.ohos.accountjsdemo"]
+ };
+ appAccountManager.selectAccountsByOptions(options).then((data) => {
+ console.log('selectAccountsByOptions: ' + JSON.stringify(data));
+ }).catch((err) => {
+ console.log("selectAccountsByOptions err: " + JSON.stringify(err));
+ });
+ ```
+
+### verifyCredential9+
+
+verifyCredential(name: string, owner: string, callback: AuthenticatorCallback): void;
+
+Verifies the user credential. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | --------------------- | ----- | ----------------------- |
+| name | string | Yes | Name of the target app account. |
+| owner | string | Yes | Owner of the app account. The value is the bundle name of the app. |
+| callback | AuthenticatorCallback | Yes | Authenticator callback invoked to return the verification result.|
+
+**Example**
+
+ ```js
+ const appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.verifyCredential("zhangsan", "com.example.ohos.accountjsdemo", {
+ onResult: (resultCode, result) => {
+ console.log("verifyCredential onResult, resultCode:" + JSON.stringify(resultCode));
+ console.log("verifyCredential onResult, result:" + JSON.stringify(result));
+ },
+ onRequestRedirected: (request) => {
+ console.log("verifyCredential onRequestRedirected, request:" + JSON.stringify(request));
+ }
+ });
+ ```
+
+### verifyCredential9+
+
+verifyCredential(name: string, owner: string, options, callback: AuthenticatorCallback): void;
+
+Verifies the user credential. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ----------------------- | ----- | ----------------------- |
+| name | string | Yes | Name of the target app account. |
+| owner | string | Yes | Owner of the app account. The value is the bundle name of the app. |
+| options | VerifyCredentialOptions | Yes | Options for verifying the user credential. |
+| callback | AuthenticatorCallback | Yes | Authenticator callback invoked to return the verification result.|
+
+**Example**
+
+ ```js
+ const appAccountManager = account_appAccount.createAppAccountManager();
+ var options = {
+ credentialType: "pin",
+ credential: "123456"
+ };
+ appAccountManager.verifyCredential("zhangsan", "com.example.ohos.accountjsdemo", options, {
+ onResult: (resultCode, result) => {
+ console.log("verifyCredential onResult, resultCode:" + JSON.stringify(resultCode));
+ console.log("verifyCredential onResult, result:" + JSON.stringify(result));
+ },
+ onRequestRedirected: (request) => {
+ console.log("verifyCredential onRequestRedirected, request:" + JSON.stringify(request));
+ }
+ });
+ ```
+
+### setAuthenticatorProperties9+
+
+setAuthenticatorProperties(owner: string, callback: AuthenticatorCallback): void;
+
+Sets authenticator properties. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | --------------------- | ----- | ----------------------- |
+| owner | string | Yes | Owner of the authenticator. |
+| options | SetPropertiesOptions | Yes | Authenticator properties to set. |
+| callback | AuthenticatorCallback | Yes | Authenticator callback invoked to return the result.|
+
+**Example**
+
+ ```js
+ const appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.setAuthenticatorProperties("com.example.ohos.accountjsdemo", {
+ onResult: (resultCode, result) => {
+ console.log("setAuthenticatorProperties onResult, resultCode:" + JSON.stringify(resultCode));
+ console.log("setAuthenticatorProperties onResult, result:" + JSON.stringify(result));
+ },
+ onRequestRedirected: (request) => {
+ console.log("setAuthenticatorProperties onRequestRedirected, request:" + JSON.stringify(request));
+ }
+ });
+ ```
+
+### setAuthenticatorProperties9+
+
+setAuthenticatorProperties(owner: string, options: SetPropertiesOptions, callback: AuthenticatorCallback): void;
+
+Sets authenticator properties. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | --------------------- | ----- | ----------------------- |
+| owner | string | Yes | Owner of the authenticator. |
+| options | SetPropertiesOptions | Yes | Authenticator properties to set. |
+| callback | AuthenticatorCallback | Yes | Authenticator callback invoked to return the result.|
+
+**Example**
+
+ ```js
+ const appAccountManager = account_appAccount.createAppAccountManager();
+ var options = {
+ properties: {"prop1": "value1"}
+ };
+ appAccountManager.setAuthenticatorProperties("com.example.ohos.accountjsdemo", options, {
+ onResult: (resultCode, result) => {
+ console.log("setAuthenticatorProperties onResult, resultCode:" + JSON.stringify(resultCode));
+ console.log("setAuthenticatorProperties onResult, result:" + JSON.stringify(result));
+ },
+ onRequestRedirected: (request) => {
+ console.log("setAuthenticatorProperties onRequestRedirected, request:" + JSON.stringify(request));
+ }
+ });
+ ```
+
## AppAccountInfo
Defines app account information.
**System capability**: SystemCapability.Account.AppAccount
- | Name | Type | Mandatory | Description |
- | ----- | ------ | ---- | ----------- |
- | owner | string | Yes | Bundle name of the app. |
- | name | string | Yes | App account name. |
+| Name | Type | Mandatory | Description |
+| ----- | ------ | ---- | ----------- |
+| owner | string | Yes | Owner of the app account. The value is the bundle name of the app.|
+| name | string | Yes | Name of the target app account. |
## OAuthTokenInfo8+
-Defines OAuth access token information.
+Defines OAuth token information.
**System capability**: SystemCapability.Account.AppAccount
- | Name | Type | Mandatory | Description |
- | -------- | ------ | ---- | -------- |
- | authType | string | Yes | Authentication type. |
- | token | string | Yes | Value of the access token. |
+| Name | Type | Mandatory | Description |
+| -------- | ------ | ---- | -------- |
+| authType | string | Yes | Authentication type.|
+| token | string | Yes | Value of the token. |
## AuthenticatorInfo8+
@@ -1589,11 +1963,47 @@ Defines OAuth authenticator information.
**System capability**: SystemCapability.Account.AppAccount
- | Name | Type | Mandatory | Description |
- | ------- | ------ | ---- | ---------- |
- | owner | string | Yes | Bundle name of the authenticator owner. |
- | iconId | string | Yes | ID of the authenticator icon. |
- | labelId | string | Yes | ID of the authenticator label. |
+| Name | Type | Mandatory | Description |
+| ------- | ------ | ---- | ---------- |
+| owner | string | Yes | Owner of the authenticator. The value is the bundle name of the app.|
+| iconId | string | Yes | ID of the authenticator icon. |
+| labelId | string | Yes | ID of the authenticator label. |
+
+## SelectAccountsOptions9+
+
+Represents the options for selecting accounts.
+
+**System capability**: SystemCapability.Account.AppAccount
+
+| Name | Type | Mandatory | Description |
+| --------------- | --------------------------- | ----- | ------------------- |
+| allowedAccounts | Array<AppAccountInfo> | No | Allowed accounts. |
+| allowedOwners | Array<string> | No | Allowed account owners.|
+| requiredLabels | Array<string> | No | Labels required for the authenticator. |
+
+## VerifyCredentialOptions9+
+
+Represents the options for verifying the user credential.
+
+**System capability**: SystemCapability.Account.AppAccount
+
+| Name | Type | Mandatory | Description |
+| -------------- | ---------------------- | ----- | -------------- |
+| credentialType | string | No | Type of the credential to verify. |
+| credential | string | No | Credential value. |
+| parameters | {[key:string]: Object} | No | Customized parameters.|
+
+
+## SetPropertiesOptions9+
+
+Represents the options for setting authenticator properties.
+
+**System capability**: SystemCapability.Account.AppAccount
+
+| Name | Type | Mandatory | Description |
+| ---------- | ---------------------- | ----- | -------------- |
+| properties | {[key:string]: Object} | No | Authenticator properties to set. |
+| parameters | {[key:string]: Object} | No | Customized parameters.|
## Constants8+
@@ -1601,19 +2011,21 @@ Enumerates the constants.
**System capability**: SystemCapability.Account.AppAccount
- | Name | Default Value | Description |
- | ----------------------------- | ---------------------- | ------------- |
- | ACTION_ADD_ACCOUNT_IMPLICITLY | "addAccountImplicitly" | Operation for implicitly adding an account. |
- | ACTION_AUTHENTICATE | "authenticate" | Authentication operation. |
- | KEY_NAME | "name" | App account name. |
- | KEY_OWNER | "owner" | App account owner. |
- | KEY_TOKEN | "token" | OAuth access token. |
- | KEY_ACTION | "action" | Action. |
- | KEY_AUTH_TYPE | "authType" | Authentication type. |
- | KEY_SESSION_ID | "sessionId" | Session ID. |
- | KEY_CALLER_PID | "callerPid" | Caller process ID (PID). |
- | KEY_CALLER_UID | "callerUid" | Caller user ID (UID). |
- | KEY_CALLER_BUNDLE_NAME | "callerBundleName" | Caller bundle name. |
+| Name | Default Value | Description |
+| ----------------------------- | ---------------------- | ------------- |
+| ACTION_ADD_ACCOUNT_IMPLICITLY | "addAccountImplicitly" | Operation of adding an account implicitly. |
+| ACTION_AUTHENTICATE | "authenticate" | Authentication operation. |
+| KEY_NAME | "name" | App account name. |
+| KEY_OWNER | "owner" | Owner of an app account.|
+| KEY_TOKEN | "token" | Token. |
+| KEY_ACTION | "action" | Operation. |
+| KEY_AUTH_TYPE | "authType" | Authentication type. |
+| KEY_SESSION_ID | "sessionId" | Session ID. |
+| KEY_CALLER_PID | "callerPid" | PID of the caller. |
+| KEY_CALLER_UID | "callerUid" | UID of the caller. |
+| KEY_CALLER_BUNDLE_NAME | "callerBundleName" | Bundle name of the caller. |
+| KEY_REQUIRED_LABELS | "requiredLabels" | Required labels. |
+| KEY_BOOLEAN_RESULT | "booleanResult" | Return value of the Boolean type. |
## ResultCode8+
@@ -1621,45 +2033,45 @@ Enumerates the result codes.
**System capability**: SystemCapability.Account.AppAccount
- | Name | Default Value | Description |
- | ----------------------------------- | ----- | ------------ |
- | SUCCESS | 0 | The operation is successful. |
- | ERROR_ACCOUNT_NOT_EXIST | 10001 | The app account does not exist. |
- | ERROR_APP_ACCOUNT_SERVICE_EXCEPTION | 10002 | The app account service is abnormal. |
- | ERROR_INVALID_PASSWORD | 10003 | The password is invalid. |
- | ERROR_INVALID_REQUEST | 10004 | The request is invalid. |
- | ERROR_INVALID_RESPONSE | 10005 | The response is invalid. |
- | ERROR_NETWORK_EXCEPTION | 10006 | The network is abnormal. |
- | ERROR_OAUTH_AUTHENTICATOR_NOT_EXIST | 10007 | The authenticator does not exist. |
- | ERROR_OAUTH_CANCELED | 10008 | The authentication is canceled. |
- | ERROR_OAUTH_LIST_TOO_LARGE | 10009 | The size of the OAuth list exceeds the limit. |
- | ERROR_OAUTH_SERVICE_BUSY | 10010 | The OAuth service is busy. |
- | ERROR_OAUTH_SERVICE_EXCEPTION | 10011 | The OAuth service is abnormal. |
- | ERROR_OAUTH_SESSION_NOT_EXIST | 10012 | The session to be authenticated does not exist. |
- | ERROR_OAUTH_TIMEOUT | 10013 | The authentication timed out. |
- | ERROR_OAUTH_TOKEN_NOT_EXIST | 10014 | The OAuth access token does not exist. |
- | ERROR_OAUTH_TOKEN_TOO_MANY | 10015 | The number of OAuth access tokens reaches the limit. |
- | ERROR_OAUTH_UNSUPPORT_ACTION | 10016 | The authentication operation is not supported. |
- | ERROR_OAUTH_UNSUPPORT_AUTH_TYPE | 10017 | The authentication type is not supported. |
- | ERROR_PERMISSION_DENIED | 10018 | The required permission is missing. |
+| Name | Default Value | Description |
+| ----------------------------------- | ----- | ------------ |
+| SUCCESS | 0 | The operation is successful. |
+| ERROR_ACCOUNT_NOT_EXIST | 10001 | The app account does not exist. |
+| ERROR_APP_ACCOUNT_SERVICE_EXCEPTION | 10002 | The app account service is abnormal. |
+| ERROR_INVALID_PASSWORD | 10003 | The password is invalid. |
+| ERROR_INVALID_REQUEST | 10004 | The request is invalid. |
+| ERROR_INVALID_RESPONSE | 10005 | The response is invalid. |
+| ERROR_NETWORK_EXCEPTION | 10006 | The network is abnormal. |
+| ERROR_OAUTH_AUTHENTICATOR_NOT_EXIST | 10007 | The authenticator does not exist. |
+| ERROR_OAUTH_CANCELED | 10008 | The authentication is canceled. |
+| ERROR_OAUTH_LIST_TOO_LARGE | 10009 | The size of the OAuth list exceeds the limit. |
+| ERROR_OAUTH_SERVICE_BUSY | 10010 | The OAuth service is busy. |
+| ERROR_OAUTH_SERVICE_EXCEPTION | 10011 | The OAuth service is abnormal. |
+| ERROR_OAUTH_SESSION_NOT_EXIST | 10012 | The session to be authenticated does not exist. |
+| ERROR_OAUTH_TIMEOUT | 10013 | The authentication timed out. |
+| ERROR_OAUTH_TOKEN_NOT_EXIST | 10014 | The OAuth token does not exist.|
+| ERROR_OAUTH_TOKEN_TOO_MANY | 10015 | The number of OAuth tokens reaches the limit. |
+| ERROR_OAUTH_UNSUPPORT_ACTION | 10016 | The authentication operation is not supported. |
+| ERROR_OAUTH_UNSUPPORT_AUTH_TYPE | 10017 | The authentication type is not supported. |
+| ERROR_PERMISSION_DENIED | 10018 | The required permission is missing. |
## AuthenticatorCallback8+
-Provides methods for managing the OAuth authenticator callback.
+Provides OAuth authenticator callbacks.
### onResult8+
onResult: (code: number, result: {[key: string]: any}) => void
-Called back to send the authentication result.
+Returns the result of an authentication request.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
- | Name | Type | Mandatory | Description |
- | ------ | -------------------- | ---- | ------ |
- | code | number | Yes | Authentication result code. |
- | result | {[key: string]: any} | Yes | Authentication result. |
+| Name | Type | Mandatory | Description |
+| ------ | -------------------- | ---- | ------ |
+| code | number | Yes | Authentication result code.|
+| result | {[key: string]: any} | Yes | Authentication result. |
**Example**
@@ -1681,14 +2093,14 @@ Called back to send the authentication result.
onRequestRedirected: (request: Want) => void
-Called back to redirect an authentication request.
+Redirects a request.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
- | Name | Type | Mandatory | Description |
- | ------- | ---- | ---- | ---------- |
- | request | Want | Yes | Request to be redirected. |
+| Name | Type | Mandatory | Description |
+| ------- | ---- | ---- | ---------- |
+| request | Want | Yes | Request to be redirected.|
**Example**
@@ -1710,42 +2122,128 @@ Called back to redirect an authentication request.
}
```
+### onRequestContinued9+
+
+onRequestContinued: () => void
+
+Continues to process the request.
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Example**
+
+ ```js
+ const appAccountManager = account_appAccount.createAppAccountManager();
+ var sessionId = "1234";
+ appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => {
+ callback.OnRequestContinued();
+ }).catch((err) => {
+ console.log("getAuthenticatorCallback err: " + JSON.stringify(err));
+ });
+ ```
+
## Authenticator8+
-Defines the OAuth authenticator base class.
+Provides APIs to operate the authenticator.
### addAccountImplicitly8+
addAccountImplicitly(authType: string, callerBundleName: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void
-Implicitly adds an app account based on the specified authentication type and options. This method uses an asynchronous callback to return the result.
+Implicitly adds an app account based on the specified authentication type and options. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
- | Name | Type | Mandatory | Description |
- | ---------------- | --------------------- | ---- | --------------- |
- | authType | string | Yes | Authentication type. |
- | callerBundleName | string | Yes | Bundle name of the authentication requester. |
- | options | {[key: string]: any} | Yes | Options for the authentication. |
- | callback | AuthenticatorCallback | Yes | Authenticator callback invoked to return the authentication result. |
+| Name | Type | Mandatory | Description |
+| ---------------- | --------------------- | ---- | --------------- |
+| authType | string | Yes | Authentication type. |
+| callerBundleName | string | Yes | Bundle name of the authentication requester. |
+| options | {[key: string]: any} | Yes | Options for the authentication. |
+| callback | AuthenticatorCallback | Yes | Authenticator callback invoked to return the authentication result.|
### authenticate8+
authenticate(name: string, authType: string, callerBundleName: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void
-Authenticates an app account to obtain the OAuth access token. This method uses an asynchronous callback to return the result.
+Authenticates an app account to obtain the OAuth access token. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
- | Name | Type | Mandatory | Description |
- | ---------------- | --------------------- | ---- | --------------- |
- | name | string | Yes | App account name. |
- | authType | string | Yes | Authentication type. |
- | callerBundleName | string | Yes | Bundle name of the authentication requester. |
- | options | {[key: string]: any} | Yes | Options for the authentication. |
- | callback | AuthenticatorCallback | Yes | Authenticator callback invoked to return the authentication result. |
+| Name | Type | Mandatory | Description |
+| ---------------- | --------------------- | ---- | --------------- |
+| name | string | Yes | Name of the target app account. |
+| authType | string | Yes | Authentication type. |
+| callerBundleName | string | Yes | Bundle name of the authentication requester. |
+| options | {[key: string]: any} | Yes | Options for the authentication. |
+| callback | AuthenticatorCallback | Yes | Authenticator callback invoked to return the authentication result.|
+
+### verifyCredential9+
+
+verifyCredential(name: string, options: VerifyCredentialOptions, callback: AuthenticatorCallback): void;
+
+Verifies the app account credential. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+| Name | Type | Mandatory | Description |
+| --------- | ------------------------ | -- -- | --------------------------- |
+| name | string | Yes | Name of the target app account. |
+| options | VerifyCredentialOptions | Yes | Optional for credential verification. |
+| callback | AuthenticatorCallback | Yes | Authenticator callback invoked to return the verification result.|
+
+### setProperties9+
+
+setProperties(options: SetPropertiesOptions, callback: AuthenticatorCallback): void;
+
+Sets authenticator properties. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+| Name | Type | Mandatory | Description |
+| --------- | --------------------- | -- -- | --------------------------- |
+| options | SetPropertiesOptions | Yes | Authenticator properties to set. |
+| callback | AuthenticatorCallback | Yes | Authenticator callback invoked to return the result.|
+
+### checkAccountLabels9+
+
+checkAccountLabels(name: string, labels: Array<string>, callback: AuthenticatorCallback): void;
+
+Checks the account labels. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+| Name | Type | Mandatory | Description |
+| --------- | --------------------- | -- -- | --------------------------- |
+| name | string | Yes | Name of the target app account. |
+| labels | Array | Yes | Labels to check. |
+| callback | AuthenticatorCallback | Yes | Authenticator callback invoked to return the check result.|
+
+### isAccountRemovable9+
+
+isAccountRemovable(name: string, callback: AuthenticatorCallback): void;
+
+Checks whether an app account can be deleted. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Account.AppAccount
+
+**Parameters**
+| Name | Type | Mandatory | Description |
+| --------- | --------------------- | -- -- | --------------------------- |
+| name | string | Yes | Name of the target app account. |
+| callback | AuthenticatorCallback | Yes | Authenticator callback invoked to return the result.|
+
+### getRemoteObject9+
+
+getRemoteObject(): rpc.RemoteObject;
+
+Obtains the remote object of an authenticator. This API cannot be overloaded.
+
+**System capability**: SystemCapability.Account.AppAccount
**Example**
@@ -1764,6 +2262,30 @@ Authenticates an app account to obtain the OAuth access token. This method uses
[account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"};
callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
}
+
+ verifyCredential(name: string, options: VerifyCredentialOptions, callback: AuthenticatorCallback) {
+ callback.onRequestRedirected({
+ bundleName: "com.example.ohos.accountjsdemo",
+ abilityName: "com.example.ohos.accountjsdemo.VerifyAbility",
+ parameters: {
+ name: name
+ }
+ });
+ }
+
+ setProperties(options: SetPropertiesOptions, callback: AuthenticatorCallback) {
+ callback.onResult(account_appAccount.ResultCode.SUCCESS, {});
+ }
+
+ checkAccountLabels(name: string, labels: Array<string>, callback: AuthenticatorCallback) {
+ var result = {[account_appAccount.Constants.KEY_BOOLEAN_RESULT]: false};
+ callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
+ }
+
+ isAccountRemovable(name, callback) {
+ var result = {[account_appAccount.Constants.KEY_BOOLEAN_RESULT]: true};
+ callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
+ }
}
export default {
@@ -1771,4 +2293,4 @@ Authenticates an app account to obtain the OAuth access token. This method uses
return new MyAuthenticator();
}
}
- ```
\ No newline at end of file
+ ```
diff --git a/en/application-dev/reference/apis/js-apis-application-MissionSnapshot.md b/en/application-dev/reference/apis/js-apis-application-MissionSnapshot.md
index 4521fcd2b0158e67b20d36ac059cea5642a28179..c850915c4d2743d7ee8f03ce0b96d6a4f7739525 100644
--- a/en/application-dev/reference/apis/js-apis-application-MissionSnapshot.md
+++ b/en/application-dev/reference/apis/js-apis-application-MissionSnapshot.md
@@ -1,6 +1,5 @@
# MissionSnapshot
-
> **NOTE**
>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
@@ -10,7 +9,7 @@ Provides the snapshot of a mission.
## Modules to Import
```
-import abilitymanager from '@ohos.application.abilityManager';
+import missionManager from '@ohos.application.missionManager'
import ElementName from '@ohos.bundle';
import image from '@ohos.multimedia.image';
```
diff --git a/en/application-dev/reference/apis/js-apis-application-StartOptions.md b/en/application-dev/reference/apis/js-apis-application-StartOptions.md
index b2a29f392acdac4b4e9bdfbdd1b31c7809671ce5..e221f4506244b56ea43e24ef916085ef1f3fac63 100644
--- a/en/application-dev/reference/apis/js-apis-application-StartOptions.md
+++ b/en/application-dev/reference/apis/js-apis-application-StartOptions.md
@@ -1,15 +1,14 @@
# StartOptions
-> **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.
-
+> **NOTE**
+>
+> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+> The APIs of this module can be used only in the stage model.
**StartOptions** is the basic communication component of the system.
-
## Modules to Import
-
```
import StartOptions from '@ohos.application.StartOptions';
```
@@ -18,8 +17,8 @@ import StartOptions from '@ohos.application.StartOptions';
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
-| Name | Readable | Writable | Type | Mandatory | Description |
+| Name| Readable| Writable| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | -------- | -------- |
-| [windowMode](js-apis-window.md#windowmode) | Yes| No | number | No | Window mode. |
-| displayId | Yes| No | number | No | Display ID. |
+| [windowMode](js-apis-window.md#windowmode) | Yes| No| number | No| Window mode.|
+| displayId | Yes| No| number | No| Display ID.|
diff --git a/en/application-dev/reference/apis/js-apis-application-Want.md b/en/application-dev/reference/apis/js-apis-application-Want.md
index 19509a5e771ce744b16a8f231faf6f75bccb772b..26c0cd030bcdf36cee488cba5066b2beba38a3d3 100644
--- a/en/application-dev/reference/apis/js-apis-application-Want.md
+++ b/en/application-dev/reference/apis/js-apis-application-Want.md
@@ -1,14 +1,13 @@
# Want
-> **NOTE**
+> **NOTE**
+>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
**Want** is the basic communication component of the system.
-
## Modules to Import
-
```
import Want from '@ohos.application.Want';
```
@@ -17,14 +16,15 @@ import Want from '@ohos.application.Want';
**System capability**: SystemCapability.Ability.AbilityBase
- | Name | Readable/Writable | Type | Mandatory | Description |
- | ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ |
- | deviceId | Read only | string | No | ID of the device running the ability. |
- | bundleName | Read only | string | No | Bundle name of the ability. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can directly match the specified ability. |
- | abilityName | Read only | string | No | Name of the ability. If both **package** and **AbilityName** are specified in this field in a **Want** object, the **Want** object can directly match the specified ability. |
- | uri | Read only | string | No | URI information to match. If **uri** is specified in a **Want** object, the **Want** object will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path**. |
- | type | Read only | string | No | MIME type, for example, **text/plain** or **image/***. |
- | flags | Read only | number | No | How the **Want** object will be handled. By default, numbers are passed in. For details, see [flags](js-apis-featureAbility.md#flags). |
- | action | Read only | string | No | Action option. |
- | parameters | Read only | {[key: string]: any} | No | List of parameters in the **Want** object. |
- | entities | Read only | Array\ | No | List of entities. |
+| Name | Readable/Writable| Type | Mandatory| Description |
+| ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ |
+| deviceId | Read only | string | No | ID of the device running the ability. |
+| bundleName | Read only | string | No | Bundle name of the ability. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can match a specific ability.|
+| abilityName | Read only | string | No | Name of the ability. If both **package** and **abilityName** are specified in a **Want** object, the **Want** object can match a specific ability.|
+| uri | Read only | string | No | URI information to match. If **uri** is specified in a **Want** object, the **Want** object will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path**.|
+| type | Read only | string | No | MIME type, for example, **text/plain** or **image/***. |
+| flags | Read only | number | No | How the **Want** object will be handled. By default, numbers are passed in. For details, see [flags](js-apis-featureAbility.md#flags).|
+| action | Read only | string | No | Action option. |
+| parameters | Read only | {[key: string]: any} | No | List of parameters in the **Want** object. |
+| entities | Read only | Array\ | No | List of entities. |
+| moduleName9+ | Read only | string | No | Module to which the ability belongs. Different abilities among HAP files in an application may use the same name. If the abilities cannot be distinguished by the combination of **bundleName** and **abilityName**, you can set **moduleName** for better distinguishing.| |
diff --git a/en/application-dev/reference/apis/js-apis-application-ability.md b/en/application-dev/reference/apis/js-apis-application-ability.md
index 136ec10fb630431a12d0455ca5e941249265267e..bdf719b34ed6e7ba0dcc227ff5866c8ae7b87a87 100644
--- a/en/application-dev/reference/apis/js-apis-application-ability.md
+++ b/en/application-dev/reference/apis/js-apis-application-ability.md
@@ -1,15 +1,14 @@
# Ability
->  **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.
-
+> **NOTE**
+>
+> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+> The APIs of this module can be used only in the stage model.
Manages the ability lifecycle and context.
-
## Modules to Import
-
```
import Ability from '@ohos.application.Ability';
```
@@ -23,6 +22,8 @@ import Ability from '@ohos.application.Ability';
| context | [AbilityContext](js-apis-ability-context.md) | Yes| No| Context of an ability.|
| launchWant | [Want](js-apis-application-Want.md) | Yes| No| Parameters for starting the ability.|
| lastRequestWant | [Want](js-apis-application-Want.md) | Yes| No| Parameters used when the ability was started last time.|
+| callee | [Callee](#callee) | Yes| No| Object that invokes the stub service.|
+
## Ability.onCreate
@@ -200,11 +201,12 @@ Called to save data during the ability migration preparation process.
**Example**
```js
+ import AbilityConstant from "@ohos.application.AbilityConstant"
class myAbility extends Ability {
onContinue(wantParams) {
console.log('onContinue');
wantParams["myData"] = "my1234567";
- return true;
+ return AbilityConstant.OnContinueResult.AGREE;
}
}
```
@@ -212,7 +214,7 @@ Called to save data during the ability migration preparation process.
## Ability.onNewWant
-onNewWant(want: Want): void;
+onNewWant(want: Want, launchParams: AbilityConstant.LaunchParam): void;
Called when the ability startup mode is set to singleton.
@@ -223,13 +225,17 @@ Called when the ability startup mode is set to singleton.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Want parameters, such as the ability name and bundle name.|
+ | launchParams | AbilityConstant.LaunchParam | Yes| Reason for the ability startup and the last abnormal exit.|
**Example**
```js
class myAbility extends Ability {
- onNewWant(want) {
+ onNewWant(want, launchParams) {
console.log('onNewWant, want:' + want.abilityName);
+ if (launchParams.launchReason === AbilityConstant.LaunchReason.CONTINUATION) {
+ console.log('onNewWant, launchReason is continuation');
+ }
}
}
```
@@ -259,6 +265,32 @@ Called when the configuration of the environment where the ability is running is
}
```
+## Ability.dump
+
+dump(params: Array\): Array\;
+
+Called when the client information is dumped.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+**Parameters**
+
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | params | Array\ | Yes| Parameters in the form of a command.|
+
+**Example**
+
+ ```js
+ class myAbility extends Ability {
+ dump(params) {
+ console.log('dump, params:' + JSON.stringify(params));
+ return ["params"]
+ }
+ }
+ ```
+
+
## Caller
@@ -291,6 +323,9 @@ Sends sequenceable data to the target ability.
```js
import Ability from '@ohos.application.Ability';
class MyMessageAble{ // Custom sequenceable data structure
+ name:""
+ str:""
+ num: 1
constructor(name, str) {
this.name = name;
this.str = str;
@@ -314,7 +349,7 @@ Sends sequenceable data to the target ability.
onWindowStageCreate(windowStage) {
this.context.startAbilityByCall({
bundleName: "com.example.myservice",
- abilityName: "com.example.myservice.MainAbility",
+ abilityName: "MainAbility",
deviceId: ""
}).then((obj) => {
caller = obj;
@@ -361,6 +396,9 @@ Sends sequenceable data to the target ability and obtains the sequenceable data
```js
import Ability from '@ohos.application.Ability';
class MyMessageAble{
+ name:""
+ str:""
+ num: 1
constructor(name, str) {
this.name = name;
this.str = str;
@@ -384,7 +422,7 @@ Sends sequenceable data to the target ability and obtains the sequenceable data
onWindowStageCreate(windowStage) {
this.context.startAbilityByCall({
bundleName: "com.example.myservice",
- abilityName: "com.example.myservice.MainAbility",
+ abilityName: "MainAbility",
deviceId: ""
}).then((obj) => {
caller = obj;
@@ -423,7 +461,7 @@ Releases the caller interface of the target ability.
onWindowStageCreate(windowStage) {
this.context.startAbilityByCall({
bundleName: "com.example.myservice",
- abilityName: "com.example.myservice.MainAbility",
+ abilityName: "MainAbility",
deviceId: ""
}).then((obj) => {
caller = obj;
@@ -445,7 +483,7 @@ Releases the caller interface of the target ability.
onRelease(callback: OnReleaseCallBack): void;
-Registers a callback that is invoked when the Stub on the target ability is disconnected.
+Registers a callback that is invoked when the stub on the target ability is disconnected.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
@@ -464,7 +502,7 @@ Registers a callback that is invoked when the Stub on the target ability is disc
onWindowStageCreate(windowStage) {
this.context.startAbilityByCall({
bundleName: "com.example.myservice",
- abilityName: "com.example.myservice.MainAbility",
+ abilityName: "MainAbility",
deviceId: ""
}).then((obj) => {
caller = obj;
@@ -509,6 +547,9 @@ Registers a caller notification callback, which is invoked when the target abili
```js
import Ability from '@ohos.application.Ability';
class MyMessageAble{
+ name:""
+ str:""
+ num: 1
constructor(name, str) {
this.name = name;
this.str = str;
diff --git a/en/application-dev/reference/apis/js-apis-application-abilityConstant.md b/en/application-dev/reference/apis/js-apis-application-abilityConstant.md
index 1db280b4b8c111250cd1cb4230c5e665184cb0df..3b2a958f7f403cade73487d61ff3695e5935d1bb 100644
--- a/en/application-dev/reference/apis/js-apis-application-abilityConstant.md
+++ b/en/application-dev/reference/apis/js-apis-application-abilityConstant.md
@@ -1,28 +1,26 @@
# AbilityConstant
-> **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.
-
+> **NOTE**
+>
+> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+> The APIs of this module can be used only in the stage model.
Provides parameters related to ability launch.
-
## Modules to Import
-
```js
import AbilityConstant from '@ohos.application.AbilityConstant';
```
-
## Attributes
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
- | Name | Type | Readable | Writable | Description |
- | -------- | -------- | -------- | -------- | -------- |
- | launchReason | LaunchReason | Yes | Yes | Ability launch reason. |
- | lastExitReason | LastExitReason | Yes | Yes | Reason for the last exit. |
+| Name| Type| Readable| Writable| Description|
+| -------- | -------- | -------- | -------- | -------- |
+| launchReason | LaunchReason| Yes| Yes| Ability launch reason.|
+| lastExitReason | LastExitReason | Yes| Yes| Reason for the last exit.|
## AbilityConstant.LaunchReason
@@ -30,12 +28,12 @@ Enumerates ability launch reasons.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
- | Name | Value | Description |
- | ----------------------------- | ---- | ------------------------------------------------------------ |
- | UNKNOWN | 0 | Unknown reason. |
- | START_ABILITY | 1 | Ability startup. |
- | CALL | 2 | Call. |
- | CONTINUATION | 3 | Ability continuation. |
+| Name | Value | Description |
+| ----------------------------- | ---- | ------------------------------------------------------------ |
+| UNKNOWN | 0 | Unknown reason.|
+| START_ABILITY | 1 | Ability startup.|
+| CALL | 2 | Call.|
+| CONTINUATION | 3 | Ability continuation.|
## AbilityConstant.LastExitReason
@@ -44,11 +42,11 @@ Enumerates reasons for the last exit.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
- | Name | Value | Description |
- | ----------------------------- | ---- | ------------------------------------------------------------ |
- | UNKNOWN | 0 | Unknown reason. |
- | ABILITY_NOT_RESPONDING | 1 | The ability does not respond. |
- | NORMAL | 2 | Normal status. |
+| Name | Value | Description |
+| ----------------------------- | ---- | ------------------------------------------------------------ |
+| UNKNOWN | 0 | Unknown reason.|
+| ABILITY_NOT_RESPONDING | 1 | The ability does not respond.|
+| NORMAL | 2 | Normal status.|
## AbilityConstant.OnContinueResult
@@ -57,8 +55,8 @@ Enumerates ability continuation results.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
- | Name | Value | Description |
- | ----------------------------- | ---- | ------------------------------------------------------------ |
- | AGREE | 0 | Continuation agreed. |
- | REJECT | 1 | Continuation denied. |
- | MISMATCH | 2 | Mismatch. |
+| Name | Value | Description |
+| ----------------------------- | ---- | ------------------------------------------------------------ |
+| AGREE | 0 | Continuation agreed.|
+| REJECT | 1 | Continuation denied.|
+| MISMATCH | 2 | Mismatch.|
diff --git a/en/application-dev/reference/apis/js-apis-application-abilityDelegator.md b/en/application-dev/reference/apis/js-apis-application-abilityDelegator.md
index e781aa0db5f13e434d049101ea35b8b1cf38aff0..ec8655be70c9037622328066aa63d2cc643421d1 100644
--- a/en/application-dev/reference/apis/js-apis-application-abilityDelegator.md
+++ b/en/application-dev/reference/apis/js-apis-application-abilityDelegator.md
@@ -1,7 +1,7 @@
# AbilityDelegator
-> **NOTE**
->
+> **NOTE**
+>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
@@ -10,8 +10,6 @@
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
```
-
-
## AbilityDelegator
### addAbilityMonitor9+
diff --git a/en/application-dev/reference/apis/js-apis-application-abilityDelegatorArgs.md b/en/application-dev/reference/apis/js-apis-application-abilityDelegatorArgs.md
index 72a1eefa41398259ea56e28e7745b975859432c5..ad43acc77bd9e7ff82b9d5bb7e01467e6b36c656 100644
--- a/en/application-dev/reference/apis/js-apis-application-abilityDelegatorArgs.md
+++ b/en/application-dev/reference/apis/js-apis-application-abilityDelegatorArgs.md
@@ -1,7 +1,7 @@
# AbilityDelegatorArgs
-> **NOTE**
->
+> **NOTE**
+>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
@@ -10,8 +10,6 @@
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
```
-
-
## AbilityDelegatorArgs
Describes the test parameters.
diff --git a/en/application-dev/reference/apis/js-apis-application-abilityLifecycleCallback.md b/en/application-dev/reference/apis/js-apis-application-abilityLifecycleCallback.md
index 9ac9b6868ec31a1b7e9f8b164491a6fec2e61997..02803ad07bcde72288958a9be4981a15b8b4b555 100644
--- a/en/application-dev/reference/apis/js-apis-application-abilityLifecycleCallback.md
+++ b/en/application-dev/reference/apis/js-apis-application-abilityLifecycleCallback.md
@@ -1,11 +1,19 @@
# AbilityLifecycleCallback
-> **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.
+> **NOTE**
+>
+> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+> The APIs of this module can be used only in the stage model.
A callback class that provides APIs, such as **onAbilityCreate**, **onAbilityWindowStageCreate**, and **onAbilityWindowStageDestroy**, to listen for the lifecycle of the application context.
+## Modules to Import
+
+```js
+import AbilityLifecycleCallback from "@ohos.application.abilityLifecycleCallback";
+```
+
## AbilityLifecycleCallback.onAbilityCreate
diff --git a/en/application-dev/reference/apis/js-apis-application-abilityMonitor.md b/en/application-dev/reference/apis/js-apis-application-abilityMonitor.md
index b31687b7edc2b3f6059d4f45fbf305c357d5a71b..e7f017b48ebb0f440b021386e7a427e2d0a59852 100644
--- a/en/application-dev/reference/apis/js-apis-application-abilityMonitor.md
+++ b/en/application-dev/reference/apis/js-apis-application-abilityMonitor.md
@@ -1,8 +1,8 @@
# AbilityMonitor
> **NOTE**
->
-> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+>
+> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
@@ -10,8 +10,6 @@
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
```
-
-
## AbilityMonitor
Describes an ability monitor.
diff --git a/en/application-dev/reference/apis/js-apis-application-abilitystage.md b/en/application-dev/reference/apis/js-apis-application-abilitystage.md
index bb9c758f36dc8456d817cb655303591f7dfa09a7..731d21305f151cd0318b14813e270bc14a27a3d2 100644
--- a/en/application-dev/reference/apis/js-apis-application-abilitystage.md
+++ b/en/application-dev/reference/apis/js-apis-application-abilitystage.md
@@ -1,15 +1,14 @@
# AbilityStage
-> **NOTE**
-> The initial APIs of this module are supported since API 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
-
+> **NOTE**
+>
+> The initial APIs of this module are supported since API 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+> The APIs of this module can be used only in the stage model.
Runtime class for HAP files. It provides APIs to notify you when a HAP file starts loading. You can then initialize the HAP file, for example, pre-load resources and create threads.
-
## Modules to Import
-
```js
import AbilityStage from '@ohos.application.AbilityStage';
```
@@ -22,8 +21,6 @@ Called when the application is created.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-
**Example**
```js
diff --git a/en/application-dev/reference/apis/js-apis-application-applicationContext.md b/en/application-dev/reference/apis/js-apis-application-applicationContext.md
index b34cb68eac4b252d24d3644c82e98f395f45c38a..517d9fb529fce872c5972a1aada50ce9f9b54ec9 100644
--- a/en/application-dev/reference/apis/js-apis-application-applicationContext.md
+++ b/en/application-dev/reference/apis/js-apis-application-applicationContext.md
@@ -1,8 +1,9 @@
# ApplicationContext
-> **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.
-
+> **NOTE**
+>
+> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+> The APIs of this module can be used only in the stage model.
Provides application-level context and APIs for registering and deregistering the ability lifecycle listener in an application.
@@ -41,14 +42,6 @@ Registers a listener to monitor the ability lifecycle of the application.
| ------ | ------------------------------ |
| number | ID of the registered listener. The ID is incremented by 1 each time the listener is registered. When the ID exceeds 2^63-1, **-1** is returned.|
-**Example**
-
- ```js
- let applicationContext = this.context.getApplicationContext();
- console.log("stage applicationContext: " + JSON.stringify(applicationContext));
- let lifecycleid = applicationContext.registerAbilityLifecycleCallback(AbilityLifecycleCallback);
- console.log("registerAbilityLifecycleCallback number: " + JSON.stringify(lifecycleid));
- ```
## ApplicationContext.unregisterAbilityLifecycleCallback
@@ -68,9 +61,47 @@ Deregisters the listener that monitors the ability lifecycle of the application.
**Example**
```js
- let applicationContext = this.context.getApplicationContext();
- console.log("stage applicationContext: " + JSON.stringify(applicationContext));
- applicationContext.unregisterAbilityLifecycleCallback(lifecycleid, (error, data) => {
- console.log("unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error));
- });
+ import AbilityStage from "@ohos.application.AbilityStage";
+
+ var lifecycleid;
+
+ export default class MyAbilityStage extends AbilityStage {
+ onCreate() {
+ console.log("MyAbilityStage onCreate")
+ let AbilityLifecycleCallback = {
+ onAbilityCreate(ability){
+ console.log("AbilityLifecycleCallback onAbilityCreate ability:" + JSON.stringify(ability));
+ },
+ onAbilityWindowStageCreate(ability){
+ console.log("AbilityLifecycleCallback onAbilityWindowStageCreate ability:" + JSON.stringify(ability));
+ },
+ onAbilityWindowStageDestroy(ability){
+ console.log("AbilityLifecycleCallback onAbilityWindowStageDestroy ability:" + JSON.stringify(ability));
+ },
+ onAbilityDestroy(ability){
+ console.log("AbilityLifecycleCallback onAbilityDestroy ability:" + JSON.stringify(ability));
+ },
+ onAbilityForeground(ability){
+ console.log("AbilityLifecycleCallback onAbilityForeground ability:" + JSON.stringify(ability));
+ },
+ onAbilityBackground(ability){
+ console.log("AbilityLifecycleCallback onAbilityBackground ability:" + JSON.stringify(ability));
+ },
+ onAbilityContinue(ability){
+ console.log("AbilityLifecycleCallback onAbilityContinue ability:" + JSON.stringify(ability));
+ }
+ }
+ // 1. Obtain applicationContext through the context attribute.
+ let applicationContext = this.context.getApplicationContext();
+ // 2. Use applicationContext to register a listener for the ability lifecycle in the application.
+ lifecycleid = applicationContext.registerAbilityLifecycleCallback(AbilityLifecycleCallback);
+ console.log("registerAbilityLifecycleCallback number: " + JSON.stringify(lifecycleid));
+ }
+ onDestroy() {
+ let applicationContext = this.context.getApplicationContext();
+ applicationContext.unregisterAbilityLifecycleCallback(lifecycleid, (error, data) => {
+ console.log("unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error));
+ });
+ }
+ }
```
diff --git a/en/application-dev/reference/apis/js-apis-application-context.md b/en/application-dev/reference/apis/js-apis-application-context.md
index 38ceb059efc27760cefb03b1c04fdd66a4f614e3..66cd6b7150041bdbf45d4d0e0adf105e0ade044b 100644
--- a/en/application-dev/reference/apis/js-apis-application-context.md
+++ b/en/application-dev/reference/apis/js-apis-application-context.md
@@ -1,8 +1,9 @@
# Context
->  **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.
-
+> **NOTE**
+>
+> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+> The APIs of this module can be used only in the stage model.
Provides the context for running code, including **applicationInfo** and **resourceManager**.
@@ -19,43 +20,43 @@ You must extend **AbilityContext** to implement this module.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
- | Name| Type| Readable| Writable| Description|
+ | Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| resourceManager | ResourceManager | Yes| No| **ResourceManager** object.|
-| applicationInfo | ApplicationInfo | Yes| No| Information about the application.|
-| cacheDir | string | Yes| No| Cache directory of the application on the internal storage.|
-| tempDir | string | Yes| No| Temporary file directory of the application.|
-| filesDir | string | Yes| No| File directory of the application on the internal storage.|
-| databaseDir | string | Yes| No| Storage directory of local data.|
-| storageDir | string | Yes| No| Storage directory of lightweight data.|
-| bundleCodeDir | string | Yes| No| Application installation path.|
-| distributedFilesDir | string | Yes| No| Storage directory of distributed application data files.|
-| eventHub | [EventHub](js-apis-eventhub.md) | Yes| No| Event hub information.|
-| area | [AreaMode](#areamode) | Yes| Yes| Area in which the file to be access is located.|
+| resourceManager | ResourceManager | Yes| No| **ResourceManager** object.|
+| applicationInfo | ApplicationInfo | Yes| No| Information about the application.|
+| cacheDir | string | Yes| No| Cache directory of the application on the internal storage.|
+| tempDir | string | Yes| No| Temporary file directory of the application.|
+| filesDir | string | Yes| No| File directory of the application on the internal storage.|
+| databaseDir | string | Yes| No| Storage directory of local data.|
+| storageDir | string | Yes| No| Storage directory of lightweight data.|
+| bundleCodeDir | string | Yes| No| Application installation path.|
+| distributedFilesDir | string | Yes| No| Storage directory of distributed application data files.|
+| eventHub | [EventHub](js-apis-eventhub.md) | Yes| No| Event hub information.|
+| area | [AreaMode](#areamode) | Yes| Yes| Area in which the file to be access is located.|
## Context.createBundleContext
createBundleContext(bundleName: string): Context;
-Creates an application context.
+Creates a context for a given application.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
- | Name| Type| Mandatory| Description|
+ | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
- | bundleName | string | Yes| Application bundle name.|
+ | bundleName | string | Yes| Application bundle name.|
**Return value**
- | Type| Description|
+ | Type| Description|
| -------- | -------- |
- | Context | Context of the application created.|
+ | Context | Context created.|
**Example**
-
+
```js
import AbilityContext from '@ohos.application.Ability'
class MainAbility extends AbilityContext {
@@ -68,6 +69,76 @@ Creates an application context.
```
+## Context.createModuleContext
+
+createModuleContext(moduleName: string): Context;
+
+Creates a context for a given HAP.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Parameters**
+
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | moduleName | string | Yes| HAP name in the application.|
+
+**Return value**
+
+ | Type| Description|
+ | -------- | -------- |
+ | Context | Context created.|
+
+**Example**
+
+ ```js
+ import AbilityContext from '@ohos.application.Ability'
+ class MainAbility extends AbilityContext {
+ onWindowStageCreate(windowStage) {
+ let moduleName = "module";
+ let context = this.context.createModuleContext(moduleName);
+ }
+}
+
+ ```
+
+
+## Context.createModuleContext
+
+createModuleContext(bundleName: string, moduleName: string): Context;
+
+Creates a context for a given HAP in an application.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Parameters**
+
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | bundleName | string | Yes| Application bundle name.|
+ | moduleName | string | Yes| HAP name in the application.|
+
+**Return value**
+
+ | Type| Description|
+ | -------- | -------- |
+ | Context | Context created.|
+
+**Example**
+
+ ```js
+ import AbilityContext from '@ohos.application.Ability'
+ class MainAbility extends AbilityContext {
+ onWindowStageCreate(windowStage) {
+ let bundleName = "com.example.bundle";
+ let moduleName = "module";
+ let context = this.context.createModuleContext(bundleName, moduleName);
+ }
+}
+
+ ```
+
+
## Context.getApplicationContext
getApplicationContext(): ApplicationContext;
@@ -83,7 +154,7 @@ Obtains the context of this application.
| ApplicationContext | Current application context.|
**Example**
-
+
```js
// This part is mandatory.
let applicationContext = this.context.getApplicationContext();
diff --git a/en/application-dev/reference/apis/js-apis-application-missionInfo.md b/en/application-dev/reference/apis/js-apis-application-missionInfo.md
index 8371830fe05b7b9ab89973f5a9390160734547ef..05938521e10970192409f856e68b816c18d3f3f0 100644
--- a/en/application-dev/reference/apis/js-apis-application-missionInfo.md
+++ b/en/application-dev/reference/apis/js-apis-application-missionInfo.md
@@ -1,6 +1,7 @@
# MissionInfo
-> **NOTE**
+> **NOTE**
+>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
@@ -9,7 +10,6 @@
import MissionInfo from '@ohos.application.missionInfo'
```
-
## MissionInfo
Provides the mission information.
diff --git a/en/application-dev/reference/apis/js-apis-application-shellCmdResult.md b/en/application-dev/reference/apis/js-apis-application-shellCmdResult.md
index d96a1d1bec16e7c05b7e802fe13ca8a895c6eac3..e0cddeee652418cdd714507cee826971fce73e28 100644
--- a/en/application-dev/reference/apis/js-apis-application-shellCmdResult.md
+++ b/en/application-dev/reference/apis/js-apis-application-shellCmdResult.md
@@ -1,7 +1,7 @@
# ShellCmdResult
-> **NOTE**
->
+> **NOTE**
+>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
@@ -10,8 +10,6 @@
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
```
-
-
## ShellCmdResult
Describes the shell command execution result.
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 0a0a18ae37b50456db8c5e9d81ebceaaf675f18f..abd004e82d684fc3b038aebf8fb1153602137476 100644
--- a/en/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md
+++ b/en/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md
@@ -1,9 +1,9 @@
# StaticSubscriberExtensionAbility
-
-> **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.
-
+> **NOTE**
+>
+> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+> The APIs of this module can be used only in the stage model.
## Modules to Import
```
@@ -20,9 +20,9 @@ Callback of the common event of a static subscriber.
**Parameters**
- | Name | Type | Mandatory | Description |
+ | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
- | event | CommonEventData | Yes | Callback of the common event of a static subscriber. |
+ | event | CommonEventData | Yes| Callback of the common event of a static subscriber.|
**Example**
diff --git a/en/application-dev/reference/apis/js-apis-appmanager.md b/en/application-dev/reference/apis/js-apis-appmanager.md
index 96c9bd009552016f88cc361103b15eb725828195..236ed9c1af1231ebb1ddc8c63356a20f57cb3010 100644
--- a/en/application-dev/reference/apis/js-apis-appmanager.md
+++ b/en/application-dev/reference/apis/js-apis-appmanager.md
@@ -1,6 +1,7 @@
# appManager
-> **NOTE**
+> **NOTE**
+>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
@@ -25,9 +26,9 @@ Checks whether this application is undergoing a stability test. This API uses an
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| callback | AsyncCallback<boolean> | No| Callback used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.|
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | callback | AsyncCallback<boolean> | No| Callback used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.|
**Example**
@@ -49,9 +50,9 @@ Checks whether this application is undergoing a stability test. This API uses a
**Return value**
-| Type| Description|
-| -------- | -------- |
-| Promise<boolean> | Promise used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.|
+ | Type| Description|
+ | -------- | -------- |
+ | Promise<boolean> | Promise used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.|
**Example**
@@ -75,9 +76,9 @@ Checks whether this application is running on a RAM constrained device. This API
**Return value**
-| Type| Description|
-| -------- | -------- |
-| Promise<boolean> | Promise used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.|
+ | Type| Description|
+ | -------- | -------- |
+ | Promise<boolean> | Promise used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.|
**Example**
@@ -99,9 +100,9 @@ Checks whether this application is running on a RAM constrained device. This API
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| callback | AsyncCallback<boolean> | No| Callback used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.|
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | callback | AsyncCallback<boolean> | No| Callback used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.|
**Example**
@@ -122,9 +123,9 @@ Obtains the memory size of this application. This API uses a promise to return t
**Return value**
-| Type| Description|
-| -------- | -------- |
-| Promise<number> | Size of the application memory.|
+ | Type| Description|
+ | -------- | -------- |
+ | Promise<number> | Size of the application memory.|
**Example**
@@ -146,9 +147,9 @@ Obtains the memory size of this application. This API uses an asynchronous callb
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| callback | AsyncCallback<number> | No| Size of the application memory.|
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | callback | AsyncCallback<number> | No| Size of the application memory.|
**Example**
diff --git a/en/application-dev/reference/apis/js-apis-arraylist.md b/en/application-dev/reference/apis/js-apis-arraylist.md
index 2290f5d295d182f700248afc45d131bb51aea79a..341295a167878f6c3696efe01f15a29415f91cd8 100644
--- a/en/application-dev/reference/apis/js-apis-arraylist.md
+++ b/en/application-dev/reference/apis/js-apis-arraylist.md
@@ -1,25 +1,32 @@
# Linear Container ArrayList
->  **NOTE**
+> **NOTE**
+>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+**ArrayList** is a linear data structure that is implemented based on arrays. **ArrayList** can dynamically adjust the capacity based on project requirements. It increases the capacity by 50% each time.
+
+Similar to **ArrayList**, **[Vector](js-apis-vector.md)** is also implemented based on arrays and can dynamically adjust the capacity. It increases the capability by 100% each time.
+
+When compared with **[LinkedList](js-apis-linkedlist.md)**, **ArrayList** is more efficient in random access but less efficient in the addition or removal operation, because its addition or removal operation affects the position of other elements in the container.
+
+**Recommended use case**: Use **ArrayList** when elements in a container need to be frequently read.
+
## Modules to Import
```ts
-import ArrayList from '@ohos.util.ArrayList'
+import ArrayList from '@ohos.util.ArrayList';
```
-## System Capabilities
-
-SystemCapability.Utils.Lang
-
## ArrayList
### Attributes
+**System capability**: SystemCapability.Utils.Lang
+
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| length | number | Yes| No| Number of entries in an array list (called container later).|
+| length | number | Yes| No| Number of elements in an array list (called container later).|
### constructor
@@ -28,6 +35,8 @@ constructor()
A constructor used to create an **ArrayList** instance.
+**System capability**: SystemCapability.Utils.Lang
+
**Example**
```ts
@@ -39,19 +48,21 @@ let arrayList = new ArrayList();
add(element: T): boolean
-Adds an entry at the end of this container.
+Adds an element at the end of this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| element | T | Yes| Entry to add.|
+| element | T | Yes| Target element.|
**Return value**
| Type| Description|
| -------- | -------- |
-| boolean | Returns **true** if the entry is added successfully; returns **false** otherwise.|
+| boolean | Returns **true** if the element is added successfully; returns **false** otherwise.|
**Example**
@@ -69,14 +80,16 @@ Adds an entry at the end of this container.
insert(element: T, index: number): void
-Inserts an entry at the specified position in this container.
+Inserts an element at the specified position in this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| element | T | Yes| Entry to insert.|
-| index | number | Yes| Index of the position where the entry is to be inserted.|
+| element | T | Yes| Target element.|
+| index | number | Yes| Index of the position where the element is to be inserted.|
**Example**
@@ -91,19 +104,21 @@ arrayList.insert(true, 2);
has(element: T): boolean
-Checks whether this container has the specified entry.
+Checks whether this container has the specified element.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| element | T | Yes| Entry to check.|
+| element | T | Yes| Target element.|
**Return value**
| Type| Description|
| -------- | -------- |
-| boolean | Returns **true** if the specified entry is contained; returns **false** otherwise.|
+| boolean | Returns **true** if the specified element is contained; returns **false** otherwise.|
**Example**
@@ -118,19 +133,21 @@ let result1 = arrayList.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
getIndexOf(element: T): number
-Obtains the index of the first occurrence of the specified entry in this container.
+Obtains the index of the first occurrence of the specified element in this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| element | T | Yes| Entry to query.|
+| element | T | Yes| Target element.|
**Return value**
| Type| Description|
| -------- | -------- |
-| number | Returns the position index if obtained; returns **-1** if the specified entry is not found.|
+| number | Returns the position index if obtained; returns **-1** if the specified element is not found.|
**Example**
@@ -150,19 +167,21 @@ let result = arrayList.getIndexOf(2);
getLastIndexOf(element: T): number
-Obtains the index of the last occurrence of the specified entry in this container.
+Obtains the index of the last occurrence of the specified element in this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| element | T | Yes| Entry to query.|
+| element | T | Yes| Target element.|
**Return value**
| Type| Description|
| -------- | -------- |
-| number | Returns the position index if obtained; returns **-1** if the specified entry is not found.|
+| number | Returns the position index if obtained; returns **-1** if the specified element is not found.|
**Example**
@@ -182,19 +201,21 @@ let result = arrayList.getLastIndexOf(2);
removeByIndex(index: number): T
-Removes an entry with the specified position from this container.
+Removes an element with the specified position from this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| index | number | Yes| Position index of the entry to remove.|
+| index | number | Yes| Position index of the target element.|
**Return value**
| Type| Description|
| -------- | -------- |
-| T | Entry removed.|
+| T | Element removed.|
**Example**
@@ -212,19 +233,21 @@ let result = arrayList.removeByIndex(2);
remove(element: T): boolean
-Removes the first occurrence of the specified entry from this container.
+Removes the first occurrence of the specified element from this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| element | T | Yes| Entry to remove.|
+| element | T | Yes| Target element.|
**Return value**
| Type| Description|
| -------- | -------- |
-| boolean | Returns **true** if the entry is removed successfully; returns **false** otherwise.|
+| boolean | Returns **true** if the element is removed successfully; returns **false** otherwise.|
**Example**
@@ -241,7 +264,9 @@ let result = arrayList.remove(2);
removeByRange(fromIndex: number, toIndex: number): void
-Removes from this container all of the entries within a range, including the entry at the start position but not that at the end position.
+Removes from this container all of the elements within a range, including the element at the start position but not that at the end position.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
@@ -268,7 +293,9 @@ arrayList.removeByRange(2, 6);
replaceAllElements(callbackfn: (value: T, index?: number, arrlist?: ArrayList<T>) => T,
thisArg?: Object): void
-Replaces all entries in this container with new entries, and returns the new ones.
+Replaces all elements in this container with new elements, and returns the new ones.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
@@ -281,8 +308,8 @@ callbackfn
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| value | T | Yes| Value of the entry that is currently traversed.|
-| index | number | No| Position index of the entry that is currently traversed.|
+| value | T | Yes| Value of the element that is currently traversed.|
+| index | number | No| Position index of the element that is currently traversed.|
| arrlist | ArrayList<T> | No| Instance that invokes the **replaceAllElements** method.|
**Example**
@@ -293,10 +320,10 @@ arrayList.add(2);
arrayList.add(4);
arrayList.add(5);
arrayList.add(4);
-arrayList.replaceAllElements((value, index) => {
+arrayList.replaceAllElements((value: number, index: number)=> {
return value = 2 * value;
});
-arrayList.replaceAllElements((value, index) => {
+arrayList.replaceAllElements((value: number, index: number) => {
return value = value - 2;
});
```
@@ -306,21 +333,23 @@ arrayList.replaceAllElements((value, index) => {
forEach(callbackfn: (value: T, index?: number, arrlist?: ArrayList<T>) => void,
thisArg?: Object): void
-Uses a callback to traverse the entries in this container and obtain their position indexes.
+Uses a callback to traverse the elements in this container and obtain their position indexes.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| callbackfn | function | Yes| Callback invoked to traverse the entries in the container.|
+| callbackfn | function | Yes| Callback invoked to traverse the elements in the container.|
| thisArg | Object | No| Value to use when the callback is invoked.|
callbackfn
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| value | T | Yes| Value of the entry that is currently traversed.|
-| index | number | No| Position index of the entry that is currently traversed.|
+| value | T | Yes| Value of the element that is currently traversed.|
+| index | number | No| Position index of the element that is currently traversed.|
| arrlist | ArrayList<T> | No| Instance that invokes the **forEach** method.|
**Example**
@@ -332,7 +361,7 @@ arrayList.add(4);
arrayList.add(5);
arrayList.add(4);
arrayList.forEach((value, index) => {
- console.log(value, index);
+ console.log("value:" + value, index);
});
```
@@ -340,7 +369,9 @@ arrayList.forEach((value, index) => {
sort(comparator?: (firstValue: T, secondValue: T) => number): void
-Sorts entries in this container.
+Sorts elements in this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
@@ -352,8 +383,8 @@ comparator
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| firstValue | T | Yes| Previous entry.|
-| secondValue | T | Yes| Next entry.|
+| firstValue | T | Yes| Previous element.|
+| secondValue | T | Yes| Next element.|
**Example**
@@ -363,8 +394,8 @@ arrayList.add(2);
arrayList.add(4);
arrayList.add(5);
arrayList.add(4);
-arrayList.sort(a, (b => a - b));
-arrayList.sort(a, (b => b - a));
+arrayList.sort((a: number, b: number) => a - b);
+arrayList.sort((a: number, b: number) => b - a);
arrayList.sort();
```
@@ -372,7 +403,9 @@ arrayList.sort();
subArrayList(fromIndex: number, toIndex: number): ArrayList<T>
-Obtains entries within a range in this container, including the entry at the start position but not that at the end position, and returns these entries as a new **ArrayList** instance.
+Obtains elements within a range in this container, including the element at the start position but not that at the end position, and returns these elements as a new **ArrayList** instance.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
@@ -406,6 +439,8 @@ clear(): void
Clears this container and sets its length to **0**.
+**System capability**: SystemCapability.Utils.Lang
+
**Example**
```ts
@@ -423,6 +458,8 @@ clone(): ArrayList<T>
Clones this container and returns a copy. The modification to the copy does not affect the original instance.
+**System capability**: SystemCapability.Utils.Lang
+
**Return value**
@@ -447,6 +484,8 @@ getCapacity(): number
Obtains the capacity of this container.
+**System capability**: SystemCapability.Utils.Lang
+
**Return value**
| Type| Description|
@@ -470,6 +509,8 @@ convertToArray(): Array<T>
Converts this container into an array.
+**System capability**: SystemCapability.Utils.Lang
+
**Return value**
| Type| Description|
@@ -491,7 +532,9 @@ let result = arrayList.convertToArray();
isEmpty(): boolean
-Checks whether this container is empty (contains no entry).
+Checks whether this container is empty (contains no element).
+
+**System capability**: SystemCapability.Utils.Lang
**Return value**
@@ -516,6 +559,8 @@ increaseCapacityTo(newCapacity: number): void
Increases the capacity of this container.
+**System capability**: SystemCapability.Utils.Lang
+
**Parameters**
| Name| Type| Mandatory| Description|
@@ -540,6 +585,8 @@ trimToCurrentLength(): void
Trims the capacity of this container to its current length.
+**System capability**: SystemCapability.Utils.Lang
+
**Example**
```ts
@@ -557,6 +604,8 @@ arrayList.trimToCurrentLength();
Obtains an iterator, each item of which is a JavaScript object.
+**System capability**: SystemCapability.Utils.Lang
+
**Return value**
| Type| Description|
@@ -574,14 +623,14 @@ arrayList.add(4);
// Method 1:
for (let item of arrayList) {
- console.log(item);
+ console.log("value:" + item);
}
// Method 2:
let iter = arrayList[Symbol.iterator]();
let temp = iter.next().value;
while(temp != undefined) {
- console.log(temp);
+ console.log("value:" + temp);
temp = iter.next().value;
}
```
diff --git a/en/application-dev/reference/apis/js-apis-audio.md b/en/application-dev/reference/apis/js-apis-audio.md
index eb07b107edd27aca0cd0bc3e389ae7eeabbb4374..87e2238b4c208c14833f7fe00baefd93820209f4 100644
--- a/en/application-dev/reference/apis/js-apis-audio.md
+++ b/en/application-dev/reference/apis/js-apis-audio.md
@@ -246,6 +246,17 @@ Enumerates the audio stream types.
| VOICE_ASSISTANT8+ | 9 | Audio stream for voice assistant.|
+## InterruptMode9+
+
+Enumerates the audio interruption modes.
+
+**System capability**: SystemCapability.Multimedia.Audio.InterruptMode
+
+| Name | Default Value| Description |
+| ---------------------------- | ------ | ---------- |
+| SHARE_MODE | 0 | Share mode.|
+| INDEPENDENT_MODE| 1 | Independent mode. |
+
## DeviceFlag
Enumerates the audio device flags.
@@ -542,7 +553,7 @@ Describes the callback invoked for audio interruption or focus gain events.
| ---------- | ------------------------------------------- | ---- | ------------------------------------------------------------ |
| actionType | [InterruptActionType](#interruptactiontype) | 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. |
+| 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.|
## VolumeEvent8+
@@ -646,7 +657,7 @@ Sets the volume for a stream. This API uses an asynchronous callback to return t
| ---------- | ----------------------------------- | ---- | -------------------------------------------------------- |
| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. |
| volume | number | Yes | Volume to set. The value range can be obtained by calling **getMinVolume** and **getMaxVolume**.|
-| callback | AsyncCallback<void\> | Yes | Callback used to return the result. |
+| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
**Example**
@@ -1135,6 +1146,8 @@ setAudioParameter(key: string, value: string, callback: AsyncCallback<void>
Sets an audio parameter. This API uses an asynchronous callback to return the result.
+This API is used to extend the audio configuration based on the hardware capability. The supported audio parameters vary according to the device and can be obtained from the device manual. The example below is for reference only.
+
**System capability**: SystemCapability.Multimedia.Audio.Core
**Parameters**
@@ -1148,7 +1161,7 @@ Sets an audio parameter. This API uses an asynchronous callback to return the re
**Example**
```
-audioManager.setAudioParameter('PBits per sample', '8 bit', (err) => {
+audioManager.setAudioParameter('key_example', 'value_example', (err) => {
if (err) {
console.error('Failed to set the audio parameter. ${err.message}');
return;
@@ -1163,6 +1176,8 @@ setAudioParameter(key: string, value: string): Promise<void>
Sets an audio parameter. This API uses a promise to return the result.
+This API is used to extend the audio configuration based on the hardware capability. The supported audio parameters vary according to the device and can be obtained from the device manual. The example below is for reference only.
+
**System capability**: SystemCapability.Multimedia.Audio.Core
**Parameters**
@@ -1181,7 +1196,7 @@ Sets an audio parameter. This API uses a promise to return the result.
**Example**
```
-audioManager.setAudioParameter('PBits per sample', '8 bit').then(() => {
+audioManager.setAudioParameter('key_example', 'value_example').then(() => {
console.log('Promise returned to indicate a successful setting of the audio parameter.');
});
```
@@ -1192,6 +1207,8 @@ getAudioParameter(key: string, callback: AsyncCallback<string>): void
Obtains the value of an audio parameter. This API uses an asynchronous callback to return the result.
+This API is used to extend the audio configuration based on the hardware capability. The supported audio parameters vary according to the device and can be obtained from the device manual. The example below is for reference only.
+
**System capability**: SystemCapability.Multimedia.Audio.Core
**Parameters**
@@ -1204,7 +1221,7 @@ Obtains the value of an audio parameter. This API uses an asynchronous callback
**Example**
```
-audioManager.getAudioParameter('PBits per sample', (err, value) => {
+audioManager.getAudioParameter('key_example', (err, value) => {
if (err) {
console.error('Failed to obtain the value of the audio parameter. ${err.message}');
return;
@@ -1219,6 +1236,8 @@ getAudioParameter(key: string): Promise<string>
Obtains the value of an audio parameter. This API uses a promise to return the result.
+This API is used to extend the audio configuration based on the hardware capability. The supported audio parameters vary according to the device and can be obtained from the device manual. The example below is for reference only.
+
**System capability**: SystemCapability.Multimedia.Audio.Core
**Parameters**
@@ -1236,7 +1255,7 @@ Obtains the value of an audio parameter. This API uses a promise to return the r
**Example**
```
-audioManager.getAudioParameter('PBits per sample').then((value) => {
+audioManager.getAudioParameter('key_example').then((value) => {
console.log('Promise returned to indicate that the value of the audio parameter is obtained.' + value);
});
```
@@ -2477,7 +2496,55 @@ audioRenderer.getRenderRate().then((renderRate) => {
console.log('ERROR: '+err.message);
});
```
+### setInterruptMode9+
+
+setInterruptMode(interruptMode: InterruptMode): Promise<void>
+
+Sets the audio interruption mode for the application. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Multimedia.Audio.Renderer
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ---------- | ----------------------------------- | ---- | -------------------------------------------------------- |
+| interruptMode | [InterruptMode](#InterruptMode) | 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.|
+
+**Example**
+
+```
+audioManager.setInterruptMode(audio.InterruptType.SHARE_MODE).then(() => {
+ console.log('Promise returned to indicate a successful volume setting.');
+});
+```
+### setInterruptMode9+
+
+setInterruptMode(interruptMode: InterruptMode, callback: Callback\): void
+
+Sets the audio interruption mode for the application. This API uses a callback to return the result.
+
+**System capability**: SystemCapability.Multimedia.Audio.Renderer
+**Parameters**
+
+| Name| Type| Mandatory| Description |
+| ---------- | ----------------------------------- | ---- | -------------------------------------------------------- |
+|interruptMode | [InterruptMode](#InterruptMode) | Yes | Audio interruption mode.|
+|callback | Callback\ | Yes |Callback used to return the result.|
+
+**Example**
+
+```
+audioManager.setInterruptMode(audio.InterruptType.SHARE_MODE,()=>{
+ console.log('Callback returned to indicate a successful volume setting.');
+});
+```
### on('interrupt')9+
on(type: 'interrupt', callback: Callback\): void
@@ -2996,7 +3063,7 @@ audioCapturer.read(bufferSize, true, async(err, buffer) => {
if (!err) {
console.log("Success in reading the buffer data");
}
-};
+});
```
diff --git a/en/application-dev/reference/apis/js-apis-backgroundTaskManager.md b/en/application-dev/reference/apis/js-apis-backgroundTaskManager.md
index 68b16ef535f1e5da679dce4baf903ef10cd4a5de..cbb0ff47c767fd26e499913f44ba88d7e6187f17 100644
--- a/en/application-dev/reference/apis/js-apis-backgroundTaskManager.md
+++ b/en/application-dev/reference/apis/js-apis-backgroundTaskManager.md
@@ -1,6 +1,15 @@
-# Background Task Management
+# BackgroundTaskManager
+
+This module provides background task management.
+
+If a service needs to be continued when the application or service module is running in the background (not visible to users), the application or service module can request a transient task or continuous task for delayed suspension based on the service type.
+
+If an application has a task that needs to be continued when the application is switched to the background and can be completed within a short period of time, the application can request a transient task. For example, if a user chooses to clear junk files in the **Files** application and exits the application, the application can request a transient task to complete the cleanup.
+
+If an application has a service that can be intuitively perceived by users and needs to run in the background for a long period of time (for example, music playback in the background), the application can request a continuous task.
> **NOTE**
+>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
@@ -119,6 +128,7 @@ Cancels the suspension delay.
**Example**
```js
+ let id = 1;
backgroundTaskManager.cancelSuspendDelay(id);
```
@@ -304,14 +314,14 @@ Provides the information about the suspension delay.
**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
-| Name | Value| Description |
-| ----------------------- | ------ | ---------------------------- |
-| DATA_TRANSFER | 1 | Data transfer. |
-| AUDIO_PLAYBACK | 2 | Audio playback. |
-| AUDIO_RECORDING | 3 | Audio recording. |
-| LOCATION | 4 | Positioning and navigation. |
-| BLUETOOTH_INTERACTION | 5 | Bluetooth-related task. |
-| MULTI_DEVICE_CONNECTION | 6 | Multi-device connection. |
-| WIFI_INTERACTION | 7 | WLAN-related (reserved). |
-| VOIP | 8 | Voice and video call (reserved). |
-| TASK_KEEPING | 9 | Computing task (effective only for specific devices).|
+| Name | Value| Description |
+| ----------------------- | ------ | ------------------------------------------------------------ |
+| DATA_TRANSFER | 1 | Data transfer. |
+| AUDIO_PLAYBACK | 2 | Audio playback. |
+| AUDIO_RECORDING | 3 | Audio recording. |
+| LOCATION | 4 | Positioning and navigation. |
+| BLUETOOTH_INTERACTION | 5 | Bluetooth-related task. |
+| MULTI_DEVICE_CONNECTION | 6 | Multi-device connection. |
+| WIFI_INTERACTION | 7 | WLAN-related. This is a system API and cannot be called by third-party applications.|
+| VOIP | 8 | Audio and video calls. This is a system API and cannot be called by third-party applications.|
+| TASK_KEEPING | 9 | Computing task (effective only for specific devices). |
diff --git a/en/application-dev/reference/apis/js-apis-bluetooth.md b/en/application-dev/reference/apis/js-apis-bluetooth.md
index 8c2e4f41606e44f93d872427c2c81b1ecf70cb4f..1e280124850de1ccfa9658365d97c3219b1d5b2b 100644
--- a/en/application-dev/reference/apis/js-apis-bluetooth.md
+++ b/en/application-dev/reference/apis/js-apis-bluetooth.md
@@ -1,9 +1,9 @@
# Bluetooth
->  **NOTE**
+> **NOTE**
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
->
-> The Bluetooth module provides Classic Bluetooth capabilities and Bluetooth Low Energy (BLE) scan and advertising.
+
+Provides classic Bluetooth capabilities and Bluetooth Low Energy (BLE) scan and advertising.
## Modules to Import
@@ -201,7 +201,7 @@ Obtains the connection state of a profile.
| Name | Type | Mandatory | Description |
| --------- | --------- | ---- | ------------------------------------- |
-| ProfileId | profileId | Yes | ID of the target profile, for example, **PROFILE_A2DP_SOURCE**.|
+| ProfileId | profileId | Yes | ID of the profile to obtain, for example, **PROFILE_A2DP_SOURCE**.|
**Return value**
@@ -212,7 +212,7 @@ Obtains the connection state of a profile.
**Example**
```js
-let result = bluetooth.getProfileConnState(PROFILE_A2DP_SOURCE);
+let result = bluetooth.getProfileConnState(bluetooth.ProfileId.PROFILE_A2DP_SOURCE);
```
@@ -355,7 +355,7 @@ Sets the Bluetooth scan mode so that the device can be discovered by a remote de
```js
// The device can be discovered and connected only when the discoverable and connectable mode is used.
-let result = bluetooth.setBluetoothScanMode(ScanMode.SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE, 100);
+let result = bluetooth.setBluetoothScanMode(bluetooth.ScanMode.SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE, 100);
```
@@ -720,7 +720,7 @@ bluetooth.off('stateChange', onReceiveEvent);
```
-## bluetooth.sppListen8+
+## bluetooth.sppListen8+
sppListen(name: string, option: SppOption, callback: AsyncCallback<number>): void
@@ -773,6 +773,14 @@ Listens for a connection to be made to this socket from the client and accepts i
**Example**
```js
+let serverNumber = -1;
+function serverSocket(code, number) {
+ console.log('bluetooth error code: ' + code.code);
+ if (code.code == 0) {
+ console.log('bluetooth serverSocket Number: ' + number);
+ serverNumber = number;
+ }
+}
let clientNumber = -1;
function acceptClientSocket(code, number) {
console.log('bluetooth error code: ' + code.code);
@@ -807,6 +815,7 @@ Initiates an SPP connection to a remote device from the client.
**Example**
```js
+
let clientNumber = -1;
function clientSocket(code, number) {
if (code.code != 0) {
@@ -838,6 +847,14 @@ Closes the listening socket of the server.
**Example**
```js
+let serverNumber = -1;
+function serverSocket(code, number) {
+ console.log('bluetooth error code: ' + code.code);
+ if (code.code == 0) {
+ console.log('bluetooth serverSocket Number: ' + number);
+ serverNumber = number;
+ }
+}
bluetooth.sppCloseServerSocket(serverNumber);
```
@@ -860,6 +877,15 @@ Closes the client socket.
**Example**
```js
+let clientNumber = -1;
+function clientSocket(code, number) {
+ if (code.code != 0) {
+ return;
+ }
+ console.log('bluetooth serverSocket Number: ' + number);
+ // The obtained clientNumber is used as the socket ID for subsequent read/write operations on the client.
+ clientNumber = number;
+}
bluetooth.sppCloseClientSocket(clientNumber);
```
@@ -888,6 +914,15 @@ Writes data to the remote device through the socket.
**Example**
```js
+let clientNumber = -1;
+function clientSocket(code, number) {
+ if (code.code != 0) {
+ return;
+ }
+ console.log('bluetooth serverSocket Number: ' + number);
+ // The obtained clientNumber is used as the socket ID for subsequent read/write operations on the client.
+ clientNumber = number;
+}
let arrayBuffer = new ArrayBuffer(8);
let data = new Uint8Array(arrayBuffer);
data[0] = 123;
@@ -923,6 +958,15 @@ No value is returned.
**Example**
```js
+let clientNumber = -1;
+function clientSocket(code, number) {
+ if (code.code != 0) {
+ return;
+ }
+ console.log('bluetooth serverSocket Number: ' + number);
+ // The obtained clientNumber is used as the socket ID for subsequent read/write operations on the client.
+ clientNumber = number;
+}
function dataRead(dataBuffer) {
let data = new Uint8Array(dataBuffer);
console.log('bluetooth data is: ' + data[0]);
@@ -954,6 +998,15 @@ No value is returned.
**Example**
```js
+let clientNumber = -1;
+function clientSocket(code, number) {
+ if (code.code != 0) {
+ return;
+ }
+ console.log('bluetooth serverSocket Number: ' + number);
+ // The obtained clientNumber is used as the socket ID for subsequent read/write operations on the client.
+ clientNumber = number;
+}
bluetooth.off('sppRead', clientNumber);
```
@@ -981,14 +1034,14 @@ Obtains a profile object.
**Example**
```js
-let a2dpSrc = bluetooth.getProfile(PROFILE_A2DP_SOURCE);
+let a2dpSrc = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE);
```
## bluetooth.getProfile9+
getProfile(profileId: ProfileId): A2dpSourceProfile | HandsFreeAudioGatewayProfile | HidHostProfile
-Obtains the profile object instance based on **ProfileId**. API version 9 is added with **HidHostProfile**.
+Obtains a profile instance. **HidHostProfile** is added in API version 9.
**System capability**: SystemCapability.Communication.Bluetooth.Core
@@ -996,7 +1049,7 @@ Obtains the profile object instance based on **ProfileId**. API version 9 is add
| Name | Type | Mandatory | Description |
| --------- | --------- | ---- | ------------------------------------- |
-| profileId | [ProfileId](#ProfileId) | Yes | ID of the target profile, for example, **PROFILE_A2DP_SOURCE**.|
+| profileId | [ProfileId](#ProfileId) | Yes | ID of the profile to obtain, for example, **PROFILE_A2DP_SOURCE**.|
**Return value**
@@ -1007,7 +1060,7 @@ Obtains the profile object instance based on **ProfileId**. API version 9 is add
**Example**
```js
-let hidHost = bluetooth.getProfile(PROFILE_HID_HOST);
+let hidHost = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_HID_HOST);
```
@@ -1239,7 +1292,7 @@ No value is returned.
**Example**
```js
-let a2dpSrc = bluetooth.getProfile(PROFILE_A2DP_SOURCE)
+let a2dpSrc = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE)
let retArray = a2dpSrc.getConnectionDevices();
```
@@ -1257,7 +1310,7 @@ Obtains the connection state of the profile.
| Name | Type | Mandatory | Description |
| ------ | ------ | ---- | ------- |
-| device | string | Yes | Address of the remote device.|
+| device | string | Yes | Address of the target device.|
**Return value**
@@ -1268,7 +1321,7 @@ Obtains the connection state of the profile.
**Example**
```js
-let a2dpSrc = bluetooth.getProfile(PROFILE_A2DP_SOURCE)
+let a2dpSrc = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE)
let ret = a2dpSrc.getDeviceState('XX:XX:XX:XX:XX:XX');
```
@@ -1277,7 +1330,7 @@ let ret = a2dpSrc.getDeviceState('XX:XX:XX:XX:XX:XX');
Before using a method of **A2dpSourceProfile**, you need to create an instance of this class by using the **getProfile()** method.
-### connect8+
+### connect8+
connect(device: string): boolean
@@ -1302,12 +1355,12 @@ Sets up an Advanced Audio Distribution Profile (A2DP) connection.
**Example**
```js
-let a2dpSrc = bluetooth.getProfile(PROFILE_A2DP_SOURCE)
+let a2dpSrc = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE)
let ret = a2dpSrc.connect('XX:XX:XX:XX:XX:XX');
```
-### disconnect8+
+### disconnect8+
disconnect(device: string): boolean
@@ -1332,7 +1385,7 @@ Disconnects an A2DP connection.
**Example**
```js
-let a2dpSrc = bluetooth.getProfile(PROFILE_A2DP_SOURCE);
+let a2dpSrc = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE);
let ret = a2dpSrc.disconnect('XX:XX:XX:XX:XX:XX');
```
@@ -1362,7 +1415,7 @@ No value is returned.
function onReceiveEvent(data) {
console.info('a2dp state = '+ JSON.stringify(data));
}
-let a2dpSrc = bluetooth.getProfile(PROFILE_A2DP_SOURCE);
+let a2dpSrc = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE);
a2dpSrc.on('connectionStateChange', onReceiveEvent);
```
@@ -1392,7 +1445,7 @@ No value is returned.
function onReceiveEvent(data) {
console.info('a2dp state = '+ JSON.stringify(data));
}
-let a2dpSrc = bluetooth.getProfile(PROFILE_A2DP_SOURCE);
+let a2dpSrc = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE);
a2dpSrc.on('connectionStateChange', onReceiveEvent);
a2dpSrc.off('connectionStateChange', onReceiveEvent);
```
@@ -1410,7 +1463,7 @@ Obtains the playing state of a device.
| Name | Type | Mandatory | Description |
| ------ | ------ | ---- | ------- |
-| device | string | Yes | Address of the remote device.|
+| device | string | Yes | Address of the target device.|
**Return value**
@@ -1421,7 +1474,7 @@ Obtains the playing state of a device.
**Example**
```js
-let a2dpSrc = bluetooth.getProfile(PROFILE_A2DP_SOURCE);
+let a2dpSrc = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE);
let state = a2dpSrc.getPlayingState('XX:XX:XX:XX:XX:XX');
```
@@ -1431,7 +1484,7 @@ let state = a2dpSrc.getPlayingState('XX:XX:XX:XX:XX:XX');
Before using a method of **HandsFreeAudioGatewayProfile**, you need to create an instance of this class by using the **getProfile()** method.
-### connect8+
+### connect8+
connect(device: string): boolean
@@ -1445,7 +1498,7 @@ Sets up a Hands-free Profile (HFP) connection of a device.
| Name | Type | Mandatory | Description |
| ------ | ------ | ---- | ------- |
-| device | string | Yes | Address of the remote device.|
+| device | string | Yes | Address of the target device.|
**Return value**
@@ -1456,12 +1509,12 @@ Sets up a Hands-free Profile (HFP) connection of a device.
**Example**
```js
-let hfpAg = bluetooth.getProfile(PROFILE_HANDS_FREE_AUDIO_GATEWAY);
+let hfpAg = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_HANDS_FREE_AUDIO_GATEWAY);
let ret = hfpAg.connect('XX:XX:XX:XX:XX:XX');
```
-### disconnect8+
+### disconnect8+
disconnect(device: string): boolean
@@ -1475,7 +1528,7 @@ Disconnects the HFP connection of a device.
| Name | Type | Mandatory | Description |
| ------ | ------ | ---- | ------- |
-| device | string | Yes | Address of the remote device.|
+| device | string | Yes | Address of the target device.|
**Return value**
@@ -1486,7 +1539,7 @@ Disconnects the HFP connection of a device.
**Example**
```js
-let hfpAg = bluetooth.getProfile(PROFILE_HANDS_FREE_AUDIO_GATEWAY);
+let hfpAg = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_HANDS_FREE_AUDIO_GATEWAY);
let ret = hfpAg.disconnect('XX:XX:XX:XX:XX:XX');
```
@@ -1516,7 +1569,7 @@ No value is returned.
function onReceiveEvent(data) {
console.info('hfp state = '+ JSON.stringify(data));
}
-let hfpAg = bluetooth.getProfile(PROFILE_HANDS_FREE_AUDIO_GATEWAY);
+let hfpAg = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_HANDS_FREE_AUDIO_GATEWAY);
hfpAg.on('connectionStateChange', onReceiveEvent);
```
@@ -1546,7 +1599,7 @@ No value is returned.
function onReceiveEvent(data) {
console.info('hfp state = '+ JSON.stringify(data));
}
-let hfpAg = bluetooth.getProfile(PROFILE_HANDS_FREE_AUDIO_GATEWAY);
+let hfpAg = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_HANDS_FREE_AUDIO_GATEWAY);
hfpAg.on('connectionStateChange', onReceiveEvent);
hfpAg.off('connectionStateChange', onReceiveEvent);
```
@@ -1573,7 +1626,7 @@ Connects to the HidHost service of a device.
| Name | Type | Mandatory | Description |
| ------ | ------ | ---- | ------- |
-| device | string | Yes | Address of the remote device.|
+| device | string | Yes | Address of the target device.|
**Return value**
@@ -1584,7 +1637,7 @@ Connects to the HidHost service of a device.
**Example**
```js
-let hidHostProfile = bluetooth.getProfile(PROFILE_HID_HOST);
+let hidHostProfile = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_HID_HOST);
let ret = hidHostProfile.connect('XX:XX:XX:XX:XX:XX');
```
@@ -1605,7 +1658,7 @@ Disconnects from the HidHost service of a device.
| Name | Type | Mandatory | Description |
| ------ | ------ | ---- | ------- |
-| device | string | Yes | Address of the remote device.|
+| device | string | Yes | Address of the target device.|
**Return value**
@@ -1616,7 +1669,7 @@ Disconnects from the HidHost service of a device.
**Example**
```js
-let hidHostProfile = bluetooth.getProfile(PROFILE_HID_HOST);
+let hidHostProfile = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_HID_HOST);
let ret = hidHostProfile.disconnect('XX:XX:XX:XX:XX:XX');
```
@@ -1646,7 +1699,7 @@ No value is returned.
function onReceiveEvent(data) {
console.info('hidHost state = '+ JSON.stringify(data));
}
-let hidHost = bluetooth.getProfile(PROFILE_HID_HOST);
+let hidHost = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_HID_HOST);
hidHost.on('connectionStateChange', onReceiveEvent);
```
@@ -1676,7 +1729,7 @@ No value is returned.
function onReceiveEvent(data) {
console.info('hidHost state = '+ JSON.stringify(data));
}
-let hidHost = bluetooth.getProfile(PROFILE_HID_HOST);
+let hidHost = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_HID_HOST);
hidHost.on('connectionStateChange', onReceiveEvent);
hidHost.off('connectionStateChange', onReceiveEvent);
```
@@ -1819,7 +1872,7 @@ cccV[0] = 1;
let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB', characteristicValue: arrayBufferC, descriptors:descriptors};
let characteristicN = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
- characteristicUuid: '00001821-0000-1000-8000-00805F9B34FB', characteristicValue: arrayBufferC, descriptors:descriptorsN};
+ characteristicUuid: '00001821-0000-1000-8000-00805F9B34FB', characteristicValue: arrayBufferC, descriptors:descriptors};
characteristics[0] = characteristic;
// Create a gattService instance.
@@ -1911,8 +1964,11 @@ Notifies the connected client device when a characteristic value changes.
**Example**
```js
+let arrayBufferC = new ArrayBuffer(8);
+let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB', characteristicValue: arrayBufferC, descriptors:descriptors};
let notifyCharacteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
- characteristicUuid: '00001821-0000-1000-8000-00805F9B34FB', characteristicValue: notifyCcc.characteristicValue, confirm: false};
+ characteristicUuid: '00001821-0000-1000-8000-00805F9B34FB', characteristicValue: characteristic.characteristicValue, confirm: false};
let server = bluetooth.BLE.createGattServer();
server.notifyCharacteristicChanged('XX:XX:XX:XX:XX:XX', notifyCharacteristic);
```
@@ -2138,7 +2194,7 @@ Subscribes to the descriptor read request events.
| Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | --------------------------------- |
| type | string | Yes | Event type. The value **descriptorRead** indicates a descriptor read request event.|
-| callback | Callback<[DescriptorReadReq](#descriptorreadreq)> | Yes | Callback invoked to return a descriptor read request from the GATT client. |
+| callback | Callback<[DescriptorReadReq](#descriptorreadreq)> | Yes | Callback invoked to return a descriptor read request event from the GATT client. |
**Return value**
@@ -2279,7 +2335,6 @@ let gattServer = bluetooth.BLE.createGattServer();
gattServer.off("descriptorWrite");
```
-
### on('connectStateChange')
on(type: "connectStateChange", callback: Callback<BLEConnectChangedState>): void
@@ -2488,7 +2543,7 @@ Obtains all services of the remote BLE device. This API uses a promise to return
// Promise
let device = bluetooth.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
device.connect();
-let services = device.getServices();
+var services = device.getServices();
console.log("bluetooth services size is ", services.length);
for (let i = 0; i < services.length; i++) {
@@ -2826,8 +2881,11 @@ Sets the function of notifying the GATT client when the characteristic value of
**Example**
```js
+let arrayBufferC = new ArrayBuffer(8);
+let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
+ characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB', characteristicValue: arrayBufferC, descriptors:descriptors};
let device = bluetooth.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
-device.setNotifyCharacteristicChanged(notifyCcc, false);
+device.setNotifyCharacteristicChanged(characteristic, false);
```
@@ -3296,11 +3354,19 @@ Defines the scan filter parameters.
**System capability**: SystemCapability.Communication.Bluetooth.Core
-| Name | Type | Readable | Writable | Description |
-| ----------- | ------ | ---- | ---- | ---------------------------------------- |
-| deviceId | string | Yes | Yes | Address of the BLE device to filter, for example, XX:XX:XX:XX:XX:XX. |
-| name | string | Yes | Yes | Name of the BLE device to filter. |
-| serviceUuid | string | Yes | Yes | UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**.|
+| Name | Type | Readable| Writable| Description |
+| ---------------------------------------- | ----------- | ---- | ---- | ------------------------------------------------------------ |
+| deviceId | string | Yes | Yes | Address of the BLE device to filter, for example, XX:XX:XX:XX:XX:XX. |
+| name | string | Yes | Yes | Name of the BLE device to filter. |
+| serviceUuid | string | Yes | Yes | Service UUID of the device to filter, for example, **00001888-0000-1000-8000-00805f9b34fb**.|
+| serviceUuidMask9+ | string | Yes | Yes | Service UUID mask of the device to filter, for example, **FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF**.|
+| serviceSolicitationUuid9+ | string | Yes | Yes | Service solicitation UUID of the device to filter, for example, **00001888-0000-1000-8000-00805F9B34FB**.|
+| serviceSolicitationUuidMask9+ | string | Yes | Yes | Service solicitation UUID mask of the device to filter, for example, **FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF**.|
+| serviceData9+ | ArrayBuffer | Yes | Yes | Service data of the device to filter, for example, **[0x90, 0x00, 0xF1, 0xF2]**.|
+| serviceDataMask9+ | ArrayBuffer | Yes | Yes | Service data mask of the device to filter, for example, **[0xFF,0xFF,0xFF,0xFF]**.|
+| manufacturerId9+ | number | Yes | Yes | Manufacturer ID of the device to filter, for example, **0x0006**. |
+| manufactureData9+ | ArrayBuffer | Yes | Yes | Manufacturer data of the device to filter, for example, **[0x1F,0x2F,0x3F]**.|
+| manufactureDataMask9+ | ArrayBuffer | Yes | Yes | Manufacturer data mask of the device to filter, for example, **[0xFF, 0xFF, 0xFF]**.|
## ScanOptions
diff --git a/en/application-dev/reference/apis/js-apis-bundle-BundleInfo.md b/en/application-dev/reference/apis/js-apis-bundle-BundleInfo.md
index 4b5437ad37fe5abe16948b4b88fd86567966c6a6..38a93fd67cb7cd086f4e2f317dfd9a966ddc1f6d 100644
--- a/en/application-dev/reference/apis/js-apis-bundle-BundleInfo.md
+++ b/en/application-dev/reference/apis/js-apis-bundle-BundleInfo.md
@@ -53,7 +53,7 @@ Provides the detailed information of the permissions to request from the system.
| name | string | Yes | Yes | Name of the permission to request. |
| reason | string | Yes | Yes | Reason for requesting the permission. |
| reasonId9+ | number | Yes | Yes | ID of the reason for requesting the permission.|
-| usedScene | [UsedScene](#UsedScene) | Yes | Yes | Application scenario and timing for using the permission.|
+| usedScene | [UsedScene](#usedscene) | Yes | Yes | Application scenario and timing for using the permission.|
diff --git a/en/application-dev/reference/apis/js-apis-camera.md b/en/application-dev/reference/apis/js-apis-camera.md
index 7229bf0f4c6b812c6ec52d26c0d6f289858725e9..34b0ab6878da8b7a36848c5f7d7181022009a34b 100644
--- a/en/application-dev/reference/apis/js-apis-camera.md
+++ b/en/application-dev/reference/apis/js-apis-camera.md
@@ -175,6 +175,17 @@ cameraManager.getCameras().then((cameraArray) => {
})
```
+### Size
+
+Size parameters. This interface used to get supported size for Preview + Photo + Video.
+
+**System capability**: SystemCapability.Multimedia.Camera.Core
+
+| Name | Default Value | Mandatory| Description |
+| -------- | ------------------------------------------- | ---- | ----------------------------------- |
+| height | number | Yes | Desired height of the Preview + Photo + Video. |
+| width | number | Yes | Desired width of the Preview + Photo + Video.|
+
### createCameraInput
createCameraInput(cameraId: string, callback: AsyncCallback): void
@@ -249,7 +260,7 @@ Creates a **CameraInput** instance with the specified camera position and camera
**Example**
```
-cameraManager.createCameraInput(cameraPosition, cameraType, (err, cameraInput) => {
+cameraManager.createCameraInput(camera.CameraPosition.CAMERA_POSITION_BACK, camera.CameraType.CAMERA_TYPE_UNSPECIFIED, (err, cameraInput) => {
if (err) {
console.error('Failed to create the CameraInput instance. ${err.message}');
return;
@@ -282,7 +293,7 @@ Creates a **CameraInput** instance with the specified camera position and camera
**Example**
```
-cameraManager.createCameraInput(cameraPosition, cameraType).then((cameraInput) => {
+cameraManager.createCameraInput(camera.CameraPosition.CAMERA_POSITION_BACK, camera.CameraType.CAMERA_TYPE_UNSPECIFIED).then((cameraInput) => {
console.log('Promise returned with the CameraInput instance.');
})
```
@@ -305,7 +316,11 @@ Listens for camera status changes. This API uses a callback to return the camera
**Example**
```
-cameraManager.on('cameraStatus', (cameraStatusInfo) => {
+cameraManager.on('cameraStatus', (err, cameraStatusInfo) => {
+ if (err) {
+ console.error('Failed to get cameraStatus callback. ${err.message}');
+ return;
+ }
console.log('camera : ' + cameraStatusInfo.camera.cameraId);
console.log('status: ' + cameraStatusInfo.status);
})
@@ -327,14 +342,14 @@ After **[camera.getCameraManager](#cameragetcameramanager)** is called, a camera
**Example**
```
-async function getCameraInfo() {
+async function getCameraInfo("cameraId") {
var cameraManager = await camera.getCameraManager();
var cameras = await cameraManager.getCameras();
var cameraObj = cameras[0];
var cameraId = cameraObj.cameraId;
var cameraPosition = cameraObj.cameraPosition;
var cameraType = cameraObj.cameraType;
- var cameraId = cameraObj.connectionType;
+ var connectionType = cameraObj.connectionType;
}
```
@@ -470,7 +485,7 @@ Checks whether a specified flash mode is supported. This API uses an asynchronou
**Example**
```
-cameraInput.isFlashModeSupported(flashMode, (err, status) => {
+cameraInput.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO, (err, status) => {
if (err) {
console.error('Failed to check whether the flash mode is supported. ${err.message}');
return;
@@ -502,7 +517,7 @@ Checks whether a specified flash mode is supported. This API uses a promise to r
**Example**
```
-cameraInput.isFlashModeSupported(flashMode).then((status) => {
+cameraInput.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO).then((status) => {
console.log('Promise returned with flash mode support status.' + status);
})
```
@@ -530,7 +545,7 @@ Before setting the parameters, do the following checks:
**Example**
```
-cameraInput.setFlashMode(flashMode, (err) => {
+cameraInput.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO, (err) => {
if (err) {
console.error('Failed to set the flash mode ${err.message}');
return;
@@ -567,7 +582,7 @@ Before setting the parameters, do the following checks:
**Example**
```
-cameraInput.setFlashMode(flashMode).then(() => {
+cameraInput.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO).then(() => {
console.log('Promise returned with the successful execution of setFlashMode.');
})
```
@@ -638,7 +653,7 @@ Checks whether a specified focus mode is supported. This API uses an asynchronou
**Example**
```
-cameraInput.isFocusModeSupported(afMode, (err, status) => {
+cameraInput.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_AUTO, (err, status) => {
if (err) {
console.error('Failed to check whether the focus mode is supported. ${err.message}');
return;
@@ -670,7 +685,7 @@ Checks whether a specified focus mode is supported. This API uses a promise to r
**Example**
```
-cameraInput.isFocusModeSupported(afMode).then((status) => {
+cameraInput.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_AUTO).then((status) => {
console.log('Promise returned with focus mode support status.' + status);
})
```
@@ -695,7 +710,7 @@ Before setting the focus mode, use **[isFocusModeSupported](#isfocusmodesupporte
**Example**
```
-cameraInput.setFocusMode(afMode, (err) => {
+cameraInput.setFocusMode(camera.FocusMode.FOCUS_MODE_AUTO, (err) => {
if (err) {
console.error('Failed to set the focus mode ${err.message}');
return;
@@ -729,7 +744,7 @@ Before setting the focus mode, use **[isFocusModeSupported](#isfocusmodesupporte
**Example**
```
-cameraInput.setFocusMode(afMode).then(() => {
+cameraInput.setFocusMode(camera.FocusMode.FOCUS_MODE_AUTO).then(() => {
console.log('Promise returned with the successful execution of setFocusMode.');
})
```
@@ -848,7 +863,7 @@ Sets a zoom ratio. This API uses an asynchronous callback to return the result.
**Example**
```
-cameraInput.setZoomRatio(zoomRatio, (err) => {
+cameraInput.setZoomRatio(1, (err) => {
if (err) {
console.error('Failed to set the zoom ratio value ${err.message}');
return;
@@ -880,7 +895,7 @@ Sets a zoom ratio. This API uses a promise to return the result.
**Example**
```
-cameraInput.setZoomRatio(zoomRatio).then(() => {
+cameraInput.setZoomRatio(1).then(() => {
console.log('Promise returned with the successful execution of setZoomRatio.');
})
```
@@ -950,7 +965,7 @@ Releases this **CameraInput** instance. This API uses an asynchronous callback t
**Example**
```
-camera.release((err) => {
+cameraInput.release((err) => {
if (err) {
console.error('Failed to release the CameraInput instance ${err.message}');
return;
@@ -1027,6 +1042,27 @@ cameraInput.on('error', (cameraInputError) => {
})
```
+## CameraInputErrorCode
+
+Enumerates the CameraInput error code.
+
+**System capability**: SystemCapability.Multimedia.Camera.Core
+
+| Name | Default Value| Description |
+| ---------------------- | ------ | ------------ |
+| ERROR_UNKNOWN | -1 | Unknown error.|
+
+## CameraInputError
+
+Camera input error object which extends **Error** interface.
+
+**System capability**: SystemCapability.Multimedia.Camera.Core
+
+**Parameters**
+
+| Name | Default Value| Description |
+| ---------------------- | ------ | ------------ |
+| code | [CameraInputErrorCode](#camerainputerrorcode) | Used to get error code in CameraInput on('error') callback|
## FlashMode
@@ -1836,6 +1872,28 @@ captureSession.on('error', (captureSessionError) => {
})
```
+## CaptureSessionErrorCode
+
+Enumerates the CaptureSession error code.
+
+**System capability**: SystemCapability.Multimedia.Camera.Core
+
+| Name | Default Value| Description |
+| ---------------------- | ------ | ------------ |
+| ERROR_UNKNOWN | -1 | Unknown error.|
+
+## CaptureSessionError
+
+Capture session error object which extends **Error** interface.
+
+**System capability**: SystemCapability.Multimedia.Camera.Core
+
+**Parameters**
+
+| Name | Default Value| Description |
+| ---------------------- | ------ | ------------ |
+| code | [CaptureSessionErrorCode](#capturesessionerrorcode) | Used to get error code in CaptureSession on('error') callback.|
+
## camera.createPreviewOutput
createPreviewOutput(surfaceId: string, callback: AsyncCallback): void
@@ -1854,7 +1912,7 @@ Creates a **PreviewOutput** instance. This API uses an asynchronous callback to
**Example**
```
-camera.createPreviewOutput((surfaceId), (err, previewOutput) => {
+camera.createPreviewOutput(("surfaceId"), (err, previewOutput) => {
if (err) {
console.error('Failed to create the PreviewOutput instance. ${err.message}');
return;
@@ -1886,7 +1944,7 @@ Creates a **PreviewOutput** instance. This API uses a promise to return the inst
**Example**
```
-camera.createPreviewOutput(surfaceId).then((previewOutput) => {
+camera.createPreviewOutput("surfaceId").then((previewOutput) => {
console.log('Promise returned with the PreviewOutput instance');
})
```
@@ -2013,6 +2071,28 @@ previewOutput.on('error', (previewOutputError) => {
})
```
+## PreviewOutputErrorCode
+
+Enumerates the PreviewOutput error code.
+
+**System capability**: SystemCapability.Multimedia.Camera.Core
+
+| Name | Default Value| Description |
+| ---------------------- | ------ | ------------ |
+| ERROR_UNKNOWN | -1 | Unknown error.|
+
+## PreviewOutputError
+
+Preview output error object which extends **Error** interface.
+
+**System capability**: SystemCapability.Multimedia.Camera.Core
+
+**Parameters**
+
+| Name | Default Value| Description |
+| ---------------------- | ------ | ------------ |
+| code | [PreviewOutputErrorCode](#previewoutputerrorcode) | Used to get error code in PreviewOutput on('error') callback.|
+
## camera.createPhotoOutput
createPhotoOutput(surfaceId: string, callback: AsyncCallback): void
@@ -2031,7 +2111,7 @@ Creates a **PhotoOutput** instance. This API uses an asynchronous callback to re
**Example**
```
-camera.createPhotoOutput((surfaceId), (err, photoOutput) => {
+camera.createPhotoOutput(("surfaceId"), (err, photoOutput) => {
if (err) {
console.error('Failed to create the PhotoOutput instance. ${err.message}');
return;
@@ -2063,7 +2143,7 @@ Creates a **PhotoOutput** instance. This API uses a promise to return the instan
**Example**
```
-camera.createPhotoOutput(surfaceId).then((photoOutput) => {
+camera.createPhotoOutput("surfaceId").then((photoOutput) => {
console.log('Promise returned with PhotoOutput instance');
})
```
@@ -2260,7 +2340,7 @@ Listens for photo capture start events. This API uses a callback to return the e
**Example**
```
-photoOutput.on('captureStart', (captureId) => {
+photoOutput.on('captureStart', (err, captureId) => {
console.log('photo capture stated, captureId : ' + captureId);
})
```
@@ -2336,6 +2416,50 @@ photoOutput.on('error', (photoOutputError) => {
})
```
+### FrameShutterInfo
+
+Frame shutter callback info which provides **captureId** & **timestamp** parameteres & indicates the frame shutter event.
+
+**Parameteres**
+
+| Name | Type | Mandatory| Description |
+| :------- | :------------------------------- | :--- | :---------------------------------------- |
+| captureId | number | Yes | Capture id.|
+| timestamp | number | Yes | Timestamp for frame.
+
+### CaptureEndInfo
+
+Capture end info which provides **captureId** & **frameCount** parameteres & indicates the photo capture end event.
+
+**Parameteres**
+
+| Name | Type | Mandatory| Description |
+| :------- | :------------------------------- | :--- | :---------------------------------------- |
+| captureId | number | Yes | Capture id.|
+| frameCount | number | Yes | Frame count.
+
+## PhotoOutputErrorCode
+
+Enumerates the PhotoOutput error code.
+
+**System capability**: SystemCapability.Multimedia.Camera.Core
+
+| Name | Default Value| Description |
+| ---------------------- | ------ | ------------ |
+| ERROR_UNKNOWN | -1 | Unknown error.|
+
+## PhotoOutputError
+
+Photo output error object which extends **Error** interface.
+
+**System capability**: SystemCapability.Multimedia.Camera.Core
+
+**Parameters**
+
+| Name | Default Value| Description |
+| ---------------------- | ------ | ------------ |
+| code | [PhotoOutputErrorCode](#photooutputerrorcode) | Used to get error code in PhotoOutput on('error') callback.|
+
## camera.createVideoOutput
createVideoOutput(surfaceId: string, callback: AsyncCallback): void
@@ -2354,7 +2478,7 @@ Creates a **VideoOutput** instance. This API uses an asynchronous callback to re
**Example**
```
-camera.createVideoOutput((surfaceId), (err, videoOutput) => {
+camera.createVideoOutput(("surfaceId"), (err, videoOutput) => {
if (err) {
console.error('Failed to create the VideoOutput instance. ${err.message}');
return;
@@ -2386,7 +2510,8 @@ Creates a **VideoOutput** instance. This API uses a promise to return the instan
**Example**
```
-camera.createVideoOutput(surfaceId).then((videoOutput) => {
+camera.createVideoOutput("surfaceId"
+).then((videoOutput) => {
console.log('Promise returned with the VideoOutput instance');
})
```
@@ -2609,3 +2734,25 @@ videoOutput.on('error', (VideoOutputError) => {
console.log('Video output error code: ' + VideoOutputError.code);
})
```
+
+## VideoOutputErrorCode
+
+Enumerates the VideoOutput error code.
+
+**System capability**: SystemCapability.Multimedia.Camera.Core
+
+| Name | Default Value| Description |
+| ---------------------- | ------ | ------------ |
+| ERROR_UNKNOWN | -1 | Unknown error.|
+
+## VideoOutputError
+
+Photo output error object which extends **Error** interface.
+
+**System capability**: SystemCapability.Multimedia.Camera.Core
+
+**Parameters**
+
+| Name | Default Value| Description |
+| ---------------------- | ------ | ------------ |
+| code | [VideoOutputErrorCode](#videooutputerrorcode) | Used to get error code in VideoOutput on('error') callback.|
\ No newline at end of file
diff --git a/en/application-dev/reference/apis/js-apis-cardEmulation.md b/en/application-dev/reference/apis/js-apis-cardEmulation.md
index 8a02d10ed21fa79dce8f21e557d4564c76321451..3f0d063a7e435b2f777f79bb6934aaf8d233e13a 100644
--- a/en/application-dev/reference/apis/js-apis-cardEmulation.md
+++ b/en/application-dev/reference/apis/js-apis-cardEmulation.md
@@ -1,6 +1,6 @@
# Standard NFC Card Emulation
-This module is used to implement Near-Field Communication (NFC) card emulation.
+Implements Near-Field Communication (NFC) card emulation.
> **NOTE**
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
@@ -45,7 +45,7 @@ Starts HCE.
| Name | Type | Mandatory| Description |
| ------- | -------- | ---- | ----------------------- |
-| aidList | string[] | Yes | Aid list to be registered for card emulation.|
+| aidList | string[] | Yes | Application ID (AID) list to be registered for card emulation.|
### stopHCE
@@ -78,7 +78,7 @@ Subscribes to messages from the peer device after **startHCE()**.
sendResponse(responseApdu: number[]): void;
-Sends data to the peer device.
+Sends a response to the peer device.
**Required permissions**: ohos.permission.NFC_CARD_EMULATION
diff --git a/en/application-dev/reference/apis/js-apis-commonEvent.md b/en/application-dev/reference/apis/js-apis-commonEvent.md
index 0c9b2e2352cea78bbfa4b98b6a329af95133cf68..50c4228a23727b230a2ffab82dcf077be5f6682b 100644
--- a/en/application-dev/reference/apis/js-apis-commonEvent.md
+++ b/en/application-dev/reference/apis/js-apis-commonEvent.md
@@ -1,6 +1,6 @@
# CommonEvent
->  **NOTE**
+> **NOTE**
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Required Permissions
@@ -181,7 +181,7 @@ Publishes a common event. This API uses a callback to return the result.
**Example**
```js
-// Callback for common event publication
+// Callback for common event publication.
function PublishCallBack(err) {
if (err.code) {
console.error("publish failed " + JSON.stringify(err));
@@ -219,7 +219,7 @@ Publishes a common event with given attributes. This API uses a callback to retu
// Attributes of a common event.
var options = {
code: 0, // Result code of the common event
- data: "initial data";// Result data of the common event
+ data: "initial data",// Result data of the common event
isOrdered: true // The common event is an ordered one.
}
@@ -257,7 +257,7 @@ Publishes a common event to a specific user. This API uses a callback to return
**Example**
```js
-// Callback for common event publication
+// Callback for common event publication.
function PublishAsUserCallBack(err) {
if (err.code) {
console.error("publishAsUser failed " + JSON.stringify(err));
@@ -299,7 +299,7 @@ Publishes a common event with given attributes to a specific user. This API uses
// Attributes of a common event.
var options = {
code: 0, // Result code of the common event
- data: "initial data";// Result data of the common event
+ data: "initial data",// Result data of the common event
}
// Callback for common event publication
@@ -1177,12 +1177,12 @@ Finishes this ordered common event. This API uses a callback to return the resul
var subscriber; // Subscriber object successfully created.
// Callback for ordered common event finishing.
-function finishCommonEventCallback() {
+function finishCommonEventCallback(err) {
if (err.code) {
- console.error("finishCommonEvent failed " + JSON.stringify(err));
- } else {
- console.info("FinishCommonEvent");
- }
+ console.error("finishCommonEvent failed " + JSON.stringify(err));
+} else {
+ console.info("FinishCommonEvent");
+}
}
subscriber.finishCommonEvent(finishCommonEventCallback);
```
diff --git a/en/application-dev/reference/apis/js-apis-config-policy.md b/en/application-dev/reference/apis/js-apis-config-policy.md
index 3991e4ab9dff7911220c98d4aa89b2c896cbb1fe..3c8f4d0050107f7e0b50e0d8f6c2a44d0a87e664 100644
--- a/en/application-dev/reference/apis/js-apis-config-policy.md
+++ b/en/application-dev/reference/apis/js-apis-config-policy.md
@@ -1,39 +1,41 @@
# Configuration Policy
->  **NOTE**
-> - The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
-> - The APIs of this module are system APIs and cannot be called by third-party applications.
-
The configuration policy provides the capability of obtaining the custom configuration directory and file path based on the predefined custom configuration level.
+> **NOTE**
+>
+> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+>
+> The APIs of this module are system APIs and cannot be called by third-party applications.
+
## Modules to Import
-```
+```js
import configPolicy from '@ohos.configPolicy';
```
## getOneCfgFile
-getOneCfgFile(relPath: string, callback: AsyncCallback<string>): void
+getOneCfgFile(relPath: string, callback: AsyncCallback<string>)
Obtains the path of a configuration file with the specified name and highest priority. This API uses an asynchronous callback to return the result.
-For example, if the **config.xml** file is stored in **/system/etc/config.xml** and **/sys-pod/etc/config.xml** (in ascending order of priority), then **/sys-pod/etc/config.xml** is returned.
+For example, if the **config.xml** file is stored in **/system/etc/config.xml** and **/sys_pod/etc/config.xml** (in ascending order of priority), then **/sys_pod/etc/config.xml** is returned.
**System capability**: SystemCapability.Customization.ConfigPolicy
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | relPath | string | Yes| Name of the configuration file.|
- | callback | AsyncCallback<string> | Yes| Callback used to return the path of the configuration file.|
+| Name | Type | Mandatory | Description |
+| -------- | --------------------------- | ---- | --------------------- |
+| relPath | string | Yes | Name of the configuration file. |
+| callback | AsyncCallback<string> | Yes | Callback used to return the path of the configuration file.|
**Example**
- ```
- configPolicy.getOneCfgFile('config.xml', (error, value) => {
+ ```js
+ configPolicy.getOneCfgFile('etc/config.xml', (error, value) => {
if (error == undefined) {
- console.log(value);
+ console.log("value is " + value);
} else {
- console.log(error);
+ console.log("error occurs "+ error);
}
});
```
@@ -48,19 +50,19 @@ Obtains the path of a configuration file with the specified name and highest pri
**System capability**: SystemCapability.Customization.ConfigPolicy
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | relPath | string | Yes| Name of the configuration file.|
+| Name | Type | Mandatory | Description |
+| ------- | ------ | ---- | ----- |
+| relPath | string | Yes | Name of the configuration file.|
**Return value**
- | Type| Description|
- | -------- | -------- |
- | Promise<string> | Promise used to return the path of the configuration file.|
+| Type | Description |
+| --------------------- | ------------ |
+| Promise<string> | Promise used to return the path of the configuration file.|
**Example**
- ```
- configPolicy.getOneCfgFile('config.xml').then(value => {
- console.log(value);
+ ```js
+ configPolicy.getOneCfgFile('etc/config.xml').then(value => {
+ console.log("value is " + value);
}).catch(error => {
console.log("getOneCfgFile promise " + error);
});
@@ -69,26 +71,25 @@ Obtains the path of a configuration file with the specified name and highest pri
## getCfgFiles
-getCfgFiles(relPath: string, callback: AsyncCallback<Array<string>>): void
+getCfgFiles(relPath: string, callback: AsyncCallback<Array<string>>)
-Obtains all configuration files with the specified name and lists them in ascending order of priority. This API uses an asynchronous callback to return the result. For example, if the **config.xml** file is stored in **/system/etc/config.xml**
-and **/sys-pod/etc/config.xml**, then **/system/etc/config.xml, /sys-pod/etc/config.xml** is returned.
+Obtains all configuration files with the specified name and lists them in ascending order of priority. This API uses an asynchronous callback to return the result. For example, if the **config.xml** file is stored in **/system/etc/config.xml** and **/sys_pod/etc/config.xml**, then **/system/etc/config.xml, /sys_pod/etc/config.xml** is returned.
**System capability**: SystemCapability.Customization.ConfigPolicy
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | relPath | string | Yes| Name of the configuration file.|
- | callback | AsyncCallback<Array<string>> | Yes| Callback used to return the file list.|
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | ------------- |
+| relPath | string | Yes | Name of the configuration file. |
+| callback | AsyncCallback<Array<string>> | Yes | Callback used to return the file list.|
**Example**
- ```
- configPolicy.getCfgFiles('config.xml', (error, value) => {
+ ```js
+ configPolicy.getCfgFiles('etc/config.xml', (error, value) => {
if (error == undefined) {
- console.log(value);
+ console.log("value is " + value);
} else {
- console.log(error);
+ console.log("error occurs "+ error);
}
});
```
@@ -103,19 +104,19 @@ Obtains all configuration files with the specified name and lists them in ascend
**System capability**: SystemCapability.Customization.ConfigPolicy
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | relPath | string | Yes| Name of the configuration file.|
+| Name | Type | Mandatory | Description |
+| ------- | ------ | ---- | ----- |
+| relPath | string | Yes | Name of the configuration file.|
**Return value**
- | Type| Description|
- | -------- | -------- |
- | Promise<Array<string>> | Promise used to return the file list.|
+| Type | Description |
+| ---------------------------------- | ---- |
+| Promise<Array<string>> | Promise used to return the file list.|
**Example**
- ```
- configPolicy.getCfgFiles('config.xml').then(value => {
- console.log(value);
+ ```js
+ configPolicy.getCfgFiles('etc/config.xml').then(value => {
+ console.log("value is " + value);
}).catch(error => {
console.log("getCfgFiles promise " + error);
});
@@ -124,24 +125,24 @@ Obtains all configuration files with the specified name and lists them in ascend
## getCfgDirList
-getCfgDirList(callback: AsyncCallback<Array<string>>): void
+getCfgDirList(callback: AsyncCallback<Array<string>>)
Obtains the configuration level directory list. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Customization.ConfigPolicy
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | callback | AsyncCallback<Array<string>> | Yes| Callback used to return the configuration level directory list.|
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | ----------------- |
+| callback | AsyncCallback<Array<string>> | Yes | Callback used to return the configuration level directory list.|
**Example**
- ```
+ ```js
configPolicy.getCfgDirList((error, value) => {
if (error == undefined) {
- console.log(value);
+ console.log("value is " + value);
} else {
- console.log(error);
+ console.log("error occurs "+ error);
}
});
```
@@ -156,14 +157,14 @@ Obtains the configuration level directory list. This API uses a promise to retur
**System capability**: SystemCapability.Customization.ConfigPolicy
**Return value**
- | Type| Description|
- | -------- | -------- |
- | Promise<Array<string>> | Promise used to return the configuration level directory list.|
+| Type | Description |
+| ---------------------------------- | -------- |
+| Promise<Array<string>> | Promise used to return the configuration level directory list.|
**Example**
- ```
+ ```js
configPolicy.getCfgDirList().then(value => {
- console.log(value);
+ console.log("value is " + value);
}).catch(error => {
console.log("getCfgDirList promise " + error);
});
diff --git a/en/application-dev/reference/apis/js-apis-configuration.md b/en/application-dev/reference/apis/js-apis-configuration.md
index 0cad135c638c6663301c5a4edea7a1a436ced8f3..507b8a42448dd4ae892424feaae061c47d814138 100644
--- a/en/application-dev/reference/apis/js-apis-configuration.md
+++ b/en/application-dev/reference/apis/js-apis-configuration.md
@@ -1,28 +1,25 @@
# Configuration
-> **NOTE**
+> **NOTE**
+>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
-
Provides the configuration for the environment where the ability is running.
-
## Modules to Import
-
```js
import Configuration from '@ohos.application.Configuration';
```
-
## Attributes
**System capability**: SystemCapability.Ability.AbilityBase
-| Name| Type | Readable | Writable | Description |
+ | Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| language | string | Yes | Yes| Language of the application. |
-| colorMode | [ColorMode](js-apis-configurationconstant.md) | Yes | Yes | Color mode, which can be **COLOR_MODE_LIGHT** or **COLOR_MODE_DARK**. The default value is **COLOR_MODE_LIGHT**.|
-| direction9+ | Direction | Yes| No| Screen orientation, which can be **DIRECTION_HORIZONTAL** or **DIRECTION_VERTICAL**. |
-| screenDensity9+ | ScreenDensity | Yes| No | Screen resolution, which can be **SCREEN_DENSITY_SDPI** (120), **SCREEN_DENSITY_MDPI** (160), **SCREEN_DENSITY_LDPI** (240), **SCREEN_DENSITY_XLDPI** (320), **SCREEN_DENSITY_XXLDPI** (480), or **SCREEN_DENSITY_XXXLDPI** (640). |
-| displayId9+ | number | Yes| No| ID of the display where the application is located. |
+| language | string | Yes| Yes| Language of the application.|
+| colorMode | [ColorMode](js-apis-configurationconstant.md) | Yes| Yes| Color mode, which can be **COLOR_MODE_LIGHT** or **COLOR_MODE_DARK**. The default value is **COLOR_MODE_LIGHT**.|
+| direction9+ | Direction | Yes| No| Screen orientation, which can be **DIRECTION_HORIZONTAL** or **DIRECTION_VERTICAL**.|
+| screenDensity9+ | ScreenDensity | Yes| No| Screen resolution, which can be **SCREEN_DENSITY_SDPI** (120), **SCREEN_DENSITY_MDPI** (160), **SCREEN_DENSITY_LDPI** (240), **SCREEN_DENSITY_XLDPI** (320), **SCREEN_DENSITY_XXLDPI** (480), or **SCREEN_DENSITY_XXXLDPI** (640).|
+| displayId9+ | number | Yes| No| ID of the display where the application is located.|
diff --git a/en/application-dev/reference/apis/js-apis-configurationconstant.md b/en/application-dev/reference/apis/js-apis-configurationconstant.md
index a61eeea271c180fe92f22a8be5691daf70b45da6..ebb78bc00e5ece7a6e04e64db6135f9d2f7ed7fd 100644
--- a/en/application-dev/reference/apis/js-apis-configurationconstant.md
+++ b/en/application-dev/reference/apis/js-apis-configurationconstant.md
@@ -1,6 +1,7 @@
# ConfigurationConstant
-> **NOTE**
+> **NOTE**
+>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
@@ -27,11 +28,11 @@ ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT
**System capability**: SystemCapability.Ability.AbilityBase
-| Name | Value | Description |
+| Name| Value| Description|
| -------- | -------- | -------- |
-| COLOR_MODE_NOT_SET | -1 | Unspecified color mode. |
-| COLOR_MODE_DARK | 0 | Dark mode. |
-| COLOR_MODE_LIGHT | 1 | Light mode. |
+| COLOR_MODE_NOT_SET | -1 | Unspecified color mode.|
+| COLOR_MODE_DARK | 0 | Dark mode.|
+| COLOR_MODE_LIGHT | 1 | Light mode.|
## ConfigurationConstant.Direction9+
@@ -46,11 +47,11 @@ ConfigurationConstant.Direction.DIRECTION_VERTICAL
**System capability**: SystemCapability.Ability.AbilityBase
-| Name | Value | Description |
+| Name| Value| Description|
| -------- | -------- | -------- |
-| DIRECTION_NOT_SET | -1 | Unspecified direction. |
-| DIRECTION_VERTICAL | 0 | Vertical direction. |
-| DIRECTION_HORIZONTAL | 1 | Horizontal direction. |
+| DIRECTION_NOT_SET | -1 | Unspecified direction.|
+| DIRECTION_VERTICAL | 0 | Vertical direction.|
+| DIRECTION_HORIZONTAL | 1 | Horizontal direction.|
## ConfigurationConstant.ScreenDensity9+
@@ -65,12 +66,12 @@ ConfigurationConstant.ScreenDensity.SCREEN_DENSITY_NOT_SET
**System capability**: SystemCapability.Ability.AbilityBase
-| Name | Value | Description |
+| Name| Value| Description|
| -------- | -------- | -------- |
-| SCREEN_DENSITY_NOT_SET | 0 | Unspecified screen resolution. |
-| SCREEN_DENSITY_SDPI | 120 | The screen resolution is sdpi. |
-| SCREEN_DENSITY_MDPI | 160 | The screen resolution is mdpi. |
-| SCREEN_DENSITY_LDPI | 240 | The screen resolution is ldpi. |
-| SCREEN_DENSITY_XLDPI | 320 | The screen resolution is xldpi. |
-| SCREEN_DENSITY_XXLDPI | 480 | The screen resolution is xxldpi. |
-| SCREEN_DENSITY_XXXLDPI | 640 | The screen resolution is xxxldpi. |
+| SCREEN_DENSITY_NOT_SET | 0 | Unspecified screen resolution.|
+| SCREEN_DENSITY_SDPI | 120 | The screen resolution is sdpi.|
+| SCREEN_DENSITY_MDPI | 160 | The screen resolution is mdpi.|
+| SCREEN_DENSITY_LDPI | 240 | The screen resolution is ldpi.|
+| SCREEN_DENSITY_XLDPI | 320 | The screen resolution is xldpi.|
+| SCREEN_DENSITY_XXLDPI | 480 | The screen resolution is xxldpi.|
+| SCREEN_DENSITY_XXXLDPI | 640 | The screen resolution is xxxldpi.|
diff --git a/en/application-dev/reference/apis/js-apis-contact.md b/en/application-dev/reference/apis/js-apis-contact.md
index e9ac02205ed355fb1a0933f449ebd9b304277adc..ee5cf3137c7aa5d1ef6cb8ef1c1ef47ef8b35236 100644
--- a/en/application-dev/reference/apis/js-apis-contact.md
+++ b/en/application-dev/reference/apis/js-apis-contact.md
@@ -195,7 +195,7 @@ Updates a contact based on the specified contact information and attributes. Thi
fullName: {fullName: 'xxx'},
phoneNumbers: [{phoneNumber: '138xxxxxxxx'}]
},{
- attributes:['ATTR_EMAIL', 'ATTR_NAME']
+ attributes:[contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME]
}, (err) => {
if (err) {
console.log('updateContact callback: err->${JSON.stringify(err)}');
@@ -234,7 +234,7 @@ Updates a contact based on the specified contact information and attributes. Thi
fullName: {fullName: 'xxx'},
phoneNumbers: [{phoneNumber: '138xxxxxxxx'}]
}, {
- attributes: ["ATTR_EMAIL", "ATTR_NAME"]
+ attributes: [contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME]
});
promise.then(() => {
console.log('updateContact success');
@@ -564,7 +564,9 @@ Queries contacts based on the specified key and application. This API uses an as
```js
contact.queryContact('xxx', {
- holderId: 0
+ holderId: 0,
+ bundleName: "",
+ displayName: ""
}, (err, data) => {
if (err) {
console.log(`queryContact callback: err->${JSON.stringify(err)}`);
@@ -596,7 +598,7 @@ Queries contacts based on the specified key and attributes. This API uses an asy
```js
contact.queryContact('xxx', {
- attributes: ["ATTR_EMAIL", "ATTR_NAME"]
+ attributes: [contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME]
}, (err, data) => {
if (err) {
console.log(`queryContact callback: err->${JSON.stringify(err)}`);
@@ -630,8 +632,11 @@ Queries contacts based on the specified key, application, and attributes. This A
```js
contact.queryContact('xxx', {
holderId: 0
+ holderId: 0,
+ bundleName: "",
+ displayName: ""
}, {
- attributes: ["ATTR_EMAIL", "ATTR_NAME"]
+ attributes: [contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME]
}, (err, data) => {
if (err) {
console.log(`queryContact callback: err->${JSON.stringify(err)}`);
@@ -669,8 +674,11 @@ Queries contacts based on the specified key, application, and attributes. This A
```js
let promise = contact.queryContact('xxx', {
holderId: 0
+ holderId: 0,
+ bundleName: "",
+ displayName: ""
}, {
- attributes: ["ATTR_EMAIL", "ATTR_NAME"]
+ attributes: [contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME]
});
promise.then((data) => {
console.log(`queryContact success: data->${JSON.stringify(data)}`);
@@ -728,7 +736,9 @@ Queries all contacts based on the specified application. This API uses an asynch
```js
contact.queryContacts({
- holderId: 0
+ holderId: 0,
+ bundleName: "",
+ displayName: ""
}, (err, data) => {
if (err) {
console.log(`queryContacts callback: err->${JSON.stringify(err)}`);
@@ -759,7 +769,7 @@ Queries all contacts based on the specified attributes. This API uses an asynchr
```js
contact.queryContacts({
- attributes: ["ATTR_EMAIL", "ATTR_NAME"]
+ attributes: [contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME]
}, (err, data) => {
if (err) {
console.log(`queryContacts callback: err->${JSON.stringify(err)}`);
@@ -791,9 +801,11 @@ Queries all contacts based on the specified application and attributes. This API
```js
contact.queryContacts({
- holderId: 0
+ holderId: 0,
+ bundleName: "",
+ displayName: ""
}, {
- attributes: ["ATTR_EMAIL", "ATTR_NAME"]
+ attributes: [contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME]
}, (err, data) => {
if (err) {
console.log(`queryContacts callback: err->${JSON.stringify(err)}`);
@@ -829,9 +841,11 @@ Queries all contacts based on the specified application and attributes. This API
```js
let promise = contact.queryContacts({
- holderId: 0
+ holderId: 0,
+ bundleName: "",
+ displayName: ""
}, {
- attributes: ["ATTR_EMAIL", "ATTR_NAME"]
+ attributes: [contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME]
});
promise.then((data) => {
console.log(`queryContacts success: data->${JSON.stringify(data)}`);
@@ -891,7 +905,9 @@ Queries contacts based on the specified phone number and application. This API u
```js
contact.queryContactsByPhoneNumber('138xxxxxxxx', {
- holderId: 0
+ holderId: 0,
+ bundleName: "",
+ displayName: ""
}, (err, data) => {
if (err) {
console.log(`queryContactsByPhoneNumber callback: err->${JSON.stringify(err)}`);
@@ -923,7 +939,7 @@ Queries contacts based on the specified phone number and attributes. This API us
```js
contact.queryContactsByPhoneNumber('138xxxxxxxx', {
- attributes: ["ATTR_EMAIL", "ATTR_NAME"]
+ attributes: [contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME]
}, (err, data) => {
if (err) {
console.log(`queryContactsByPhoneNumber callback: err->${JSON.stringify(err)}`);
@@ -956,9 +972,11 @@ Queries contacts based on the specified phone number, application, and attribute
```js
contact.queryContactsByPhoneNumber('138xxxxxxxx', {
- holderId: 0
+ holderId: 0,
+ bundleName: "",
+ displayName: ""
}, {
- attributes: ["ATTR_EMAIL", "ATTR_NAME"]
+ attributes: [contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME]
}, (err, data) => {
if (err) {
console.log(`queryContactsByPhoneNumber callback: err->${JSON.stringify(err)}`);
@@ -995,9 +1013,11 @@ Queries contacts based on the specified phone number, application, and attribute
```js
let promise = contact.queryContactsByPhoneNumber('138xxxxxxxx', {
- holderId: 0
+ holderId: 0,
+ bundleName: "",
+ displayName: ""
}, {
- attributes: ["ATTR_EMAIL", "ATTR_NAME"]
+ attributes: [contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME]
});
promise.then((data) => {
console.log(`queryContactsByPhoneNumber success: data->${JSON.stringify(data)}`);
@@ -1057,7 +1077,9 @@ Queries contacts based on the specified email address and application. This API
```js
contact.queryContactsByEmail('xxx@email.com', {
- holderId: 0
+ holderId: 0,
+ bundleName: "",
+ displayName: ""
}, (err, data) => {
if (err) {
console.log(`queryContactsByEmail callback: err->${JSON.stringify(err)}`);
@@ -1089,7 +1111,7 @@ Queries contacts based on the specified email address and attributes. This API u
```js
contact.queryContactsByEmail('xxx@email.com', {
- attributes: ["ATTR_EMAIL", "ATTR_NAME"]
+ attributes: [contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME]
}, (err, data) => {
if (err) {
console.log(`queryContactsByEmail callback: err->${JSON.stringify(err)}`);
@@ -1122,9 +1144,11 @@ Queries contacts based on the specified email address, application, and attribut
```js
contact.queryContactsByEmail('xxx@email.com', {
- holderId: 0
+ holderId: 0,
+ bundleName: "",
+ displayName: ""
}, {
- attributes: ["ATTR_EMAIL", "ATTR_NAME"]
+ attributes: [contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME]
}, (err, data) => {
if (err) {
console.log(`queryContactsByEmail callback: err->${JSON.stringify(err)}`);
@@ -1161,9 +1185,11 @@ Queries contacts based on the specified email address, application, and attribut
```js
let promise = contact.queryContactsByEmail('xxx@email.com', {
- holderId: 0
+ holderId: 0,
+ bundleName: "",
+ displayName: ""
}, {
- attributes: ["ATTR_EMAIL", "ATTR_NAME"]
+ attributes: [contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME]
});
promise.then((data) => {
console.log(`queryContactsByEmail success: data->${JSON.stringify(data)}`);
@@ -1221,7 +1247,9 @@ Queries all groups of this contact based on the specified application. This API
```js
contact.queryGroups({
- holderId: 0
+ holderId: 0,
+ bundleName: "",
+ displayName: ""
}, (err, data) => {
if (err) {
console.log(`queryGroups callback: err->${JSON.stringify(err)}`);
@@ -1256,7 +1284,9 @@ Queries all groups of this contact based on the specified application. This API
```js
let promise = contact.queryGroups({
- holderId: 0
+ holderId: 0,
+ bundleName: "",
+ displayName: ""
});
promise.then((data) => {
console.log(`queryGroups success: data->${JSON.stringify(data)}`);
@@ -1371,7 +1401,9 @@ Queries the key of a contact based on the specified contact ID and application.
```js
contact.queryKey(id, {
- holderId:1
+ holderId: 0,
+ bundleName: "",
+ displayName: ""
}, (err, data) => {
if (err) {
console.log(`queryKey callback: err->${JSON.stringify(err)}`);
@@ -1407,7 +1439,9 @@ Queries the key of a contact based on the specified contact ID and application.
```js
let promise = contact.queryKey(id, {
- holderId: 0
+ holderId: 0,
+ bundleName: "",
+ displayName: ""
});
promise.then((data) => {
console.log(`queryKey success: data->${JSON.stringify(data)}`);
diff --git a/en/application-dev/reference/apis/js-apis-convertxml.md b/en/application-dev/reference/apis/js-apis-convertxml.md
index 1b41a320c35d1c9295bdc3f830c731ccf83e0f27..3fd4e4e52ca7a82b33dd6a13aa7f425ab2aea9be 100644
--- a/en/application-dev/reference/apis/js-apis-convertxml.md
+++ b/en/application-dev/reference/apis/js-apis-convertxml.md
@@ -27,7 +27,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 coversion. |
+| options | [ConvertOptions](#convertoptions) | No | Options for conversion. |
**Return value**
@@ -57,7 +57,7 @@ console.log(result)
## ConvertOptions
-Options for coversion.
+Options for conversion.
**System capability**: SystemCapability.Utils.Lang
diff --git a/en/application-dev/reference/apis/js-apis-data-ability.md b/en/application-dev/reference/apis/js-apis-data-ability.md
index bd14fac4882d454ba2f299ea811b89ed1d30167d..b801f7038e84713dd3096a7c7c63f3a03314e2a5 100644
--- a/en/application-dev/reference/apis/js-apis-data-ability.md
+++ b/en/application-dev/reference/apis/js-apis-data-ability.md
@@ -1,6 +1,7 @@
# DataAbilityPredicates
-> **NOTE**
+> **NOTE**
+>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
@@ -17,21 +18,21 @@ import dataAbility from '@ohos.data.dataAbility';
createRdbPredicates(name: string, dataAbilityPredicates: DataAbilityPredicates): rdb.RdbPredicates
-Creates an **RdbPredicates** object based on a **DataAbilityPredicates** object.
+Creates an **RdbPredicates** object from a **DataAbilityPredicates** object.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | name | string | Yes| Table name in the RDB store.|
- | dataAbilityPredicates | [DataAbilityPredicates](#dataabilitypredicates) | Yes| **DataAbilityPredicates** object. |
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| name | string | Yes| Table name in the RDB store.|
+| dataAbilityPredicates | [DataAbilityPredicates](#dataabilitypredicates) | Yes| **DataAbilityPredicates** object. |
**Return value**
- | Type| Description|
- | -------- | -------- |
- | rdb.[RdbPredicates](js-apis-data-rdb.md#rdbpredicates) | **RdbPredicates** object created.|
+| Type| Description|
+| -------- | -------- |
+| rdb.[RdbPredicates](js-apis-data-rdb.md#rdbpredicates) | **RdbPredicates** object created.|
**Example**
```js
@@ -57,20 +58,19 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | field | string | Yes| Column name in the table.|
- | value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| field | string | Yes| Column name in the table.|
+| value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.|
**Return value**
- | Type| Description|
- | -------- | -------- |
- | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
+| Type| Description|
+| -------- | -------- |
+| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
**Example**
```js
- let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
- predicates.equalTo("NAME", "lisi")
+ dataAbilityPredicates.equalTo("NAME", "lisi")
```
@@ -85,20 +85,19 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | field | string | Yes| Column name in the table.|
- | value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| field | string | Yes| Column name in the table.|
+| value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.|
**Return value**
- | Type| Description|
- | -------- | -------- |
- | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
+| Type| Description|
+| -------- | -------- |
+| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
**Example**
```js
- let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
- predicates.notEqualTo("NAME", "lisi")
+ dataAbilityPredicates.notEqualTo("NAME", "lisi")
```
@@ -113,14 +112,13 @@ Adds a left parenthesis to this **DataAbilityPredicates**.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Return value**
- | Type| Description|
- | -------- | -------- |
- | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object with a left parenthesis.|
+| Type| Description|
+| -------- | -------- |
+| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object with a left parenthesis.|
**Example**
```js
- let predicates = new dataAbilitylity.DataAbilityPredicates("EMPLOYEE")
- predicates.equalTo("NAME", "lisi")
+ dataAbilityPredicates.equalTo("NAME", "lisi")
.beginWrap()
.equalTo("AGE", 18)
.or()
@@ -140,14 +138,13 @@ Adds a right parenthesis to this **DataAbilityPredicates**.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Return value**
- | Type| Description|
- | -------- | -------- |
- | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object with a right parenthesis.|
+| Type| Description|
+| -------- | -------- |
+| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object with a right parenthesis.|
**Example**
```js
- let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
- predicates.equalTo("NAME", "lisi")
+ dataAbilityPredicates.equalTo("NAME", "lisi")
.beginWrap()
.equalTo("AGE", 18)
.or()
@@ -167,14 +164,13 @@ Adds the OR condition to this **DataAbilityPredicates**.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Return value**
- | Type| Description|
- | -------- | -------- |
- | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object with the OR condition.|
+| Type| Description|
+| -------- | -------- |
+| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object with the OR condition.|
**Example**
```js
- let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
- predicates.equalTo("NAME", "Lisa")
+ dataAbilityPredicates.equalTo("NAME", "Lisa")
.or()
.equalTo("NAME", "Rose")
```
@@ -191,14 +187,13 @@ Adds the AND condition to this **DataAbilityPredicates**.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Return value**
- | Type| Description|
- | -------- | -------- |
- | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object with the AND condition.|
+| Type| Description|
+| -------- | -------- |
+| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object with the AND condition.|
**Example**
```js
- let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
- predicates.equalTo("NAME", "Lisa")
+ dataAbilityPredicates.equalTo("NAME", "Lisa")
.and()
.equalTo("SALARY", 200.5)
```
@@ -215,20 +210,19 @@ Sets a **DataAbilityPredicates** object to match a string containing the specifi
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | field | string | Yes| Column name in the table.|
- | value | string | Yes| Value to match the **DataAbilityPredicates**.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| field | string | Yes| Column name in the table.|
+| value | string | Yes| Value to match the **DataAbilityPredicates**.|
**Return value**
- | Type| Description|
- | -------- | -------- |
- | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
+| Type| Description|
+| -------- | -------- |
+| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
**Example**
```js
- let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
- predicates.contains("NAME", "os")
+ dataAbilityPredicates.contains("NAME", "os")
```
@@ -243,20 +237,19 @@ Sets a **DataAbilityPredicates** object to match a string that starts with the s
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | field | string | Yes| Column name in the table.|
- | value | string | Yes| Value to match the **DataAbilityPredicates**.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| field | string | Yes| Column name in the table.|
+| value | string | Yes| Value to match the **DataAbilityPredicates**.|
**Return value**
- | Type| Description|
- | -------- | -------- |
- | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
+| Type| Description|
+| -------- | -------- |
+| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
**Example**
```js
- let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
- predicates.beginsWith("NAME", "os")
+ dataAbilityPredicates.beginsWith("NAME", "os")
```
@@ -271,20 +264,19 @@ Sets a **DataAbilityPredicates** object to match a string that ends with the spe
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | field | string | Yes| Column name in the table.|
- | value | string | Yes| Value to match the **DataAbilityPredicates**.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| field | string | Yes| Column name in the table.|
+| value | string | Yes| Value to match the **DataAbilityPredicates**.|
**Return value**
- | Type| Description|
- | -------- | -------- |
- | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
+| Type| Description|
+| -------- | -------- |
+| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
**Example**
```
- let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
- predicates.endsWith("NAME", "se")
+ dataAbilityPredicates.endsWith("NAME", "se")
```
@@ -299,19 +291,18 @@ Sets a **DataAbilityPredicates** object to match the field whose value is null.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | field | string | Yes| Column name in the table.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| field | string | Yes| Column name in the table.|
**Return value**
- | Type| Description|
- | -------- | -------- |
- | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
+| Type| Description|
+| -------- | -------- |
+| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
**Example**
```js
- let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
- predicates.isNull("NAME")
+ dataAbilityPredicates.isNull("NAME")
```
@@ -326,19 +317,18 @@ Sets a **DataAbilityPredicates** object to match the field whose value is not nu
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | field | string | Yes| Column name in the table.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| field | string | Yes| Column name in the table.|
**Return value**
- | Type| Description|
- | -------- | -------- |
- | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
+| Type| Description|
+| -------- | -------- |
+| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
**Example**
```js
- let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
- predicates.isNotNull("NAME")
+ dataAbilityPredicates.isNotNull("NAME")
```
@@ -353,20 +343,19 @@ Sets a **DataAbilityPredicates** object to match a string that is similar to the
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | field | string | Yes| Column name in the table.|
- | value | string | Yes| Value to match the **DataAbilityPredicates**.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| field | string | Yes| Column name in the table.|
+| value | string | Yes| Value to match the **DataAbilityPredicates**.|
**Return value**
- | Type| Description|
- | -------- | -------- |
- | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
+| Type| Description|
+| -------- | -------- |
+| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
**Example**
```js
- let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
- predicates.like("NAME", "%os%")
+ dataAbilityPredicates.like("NAME", "%os%")
```
@@ -381,20 +370,19 @@ Sets a **DataAbilityPredicates** object to match the specified string.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | field | string | Yes| Column name in the table.|
- | value | string | Yes| Value to match the **DataAbilityPredicates**.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| field | string | Yes| Column name in the table.|
+| value | string | Yes| Value to match the **DataAbilityPredicates**.|
**Return value**
- | Type| Description|
- | -------- | -------- |
- | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
+| Type| Description|
+| -------- | -------- |
+| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
**Example**
```js
- let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
- predicates.glob("NAME", "?h*g")
+ dataAbilityPredicates.glob("NAME", "?h*g")
```
@@ -409,21 +397,20 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | field | string | Yes| Column name in the table.|
- | low | [ValueType](#valuetype) | Yes| Minimum value to match the **DataAbilityPredicates**.|
- | high | [ValueType](#valuetype) | Yes| Maximum value to match the **DataAbilityPredicates**.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| field | string | Yes| Column name in the table.|
+| low | [ValueType](#valuetype) | Yes| Minimum value to match the **DataAbilityPredicates**.|
+| high | [ValueType](#valuetype) | Yes| Maximum value to match the **DataAbilityPredicates**.|
**Return value**
- | Type| Description|
- | -------- | -------- |
- | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
+| Type| Description|
+| -------- | -------- |
+| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
**Example**
```js
- let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
- predicates.between("AGE", 10, 50)
+ dataAbilityPredicates.between("AGE", 10, 50)
```
@@ -438,21 +425,20 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | field | string | Yes| Column name in the table.|
- | low | [ValueType](#valuetype) | Yes| Minimum value to match the **DataAbilityPredicates**.|
- | high | [ValueType](#valuetype) | Yes| Maximum value to match the **DataAbilityPredicates**.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| field | string | Yes| Column name in the table.|
+| low | [ValueType](#valuetype) | Yes| Minimum value to match the **DataAbilityPredicates**.|
+| high | [ValueType](#valuetype) | Yes| Maximum value to match the **DataAbilityPredicates**.|
**Return value**
- | Type| Description|
- | -------- | -------- |
- | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
+| Type| Description|
+| -------- | -------- |
+| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
**Example**
```js
- let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
- predicates.notBetween("AGE", 10, 50)
+ dataAbilityPredicates.notBetween("AGE", 10, 50)
```
@@ -467,20 +453,19 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | field | string | Yes| Column name in the table.|
- | value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| field | string | Yes| Column name in the table.|
+| value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.|
**Return value**
- | Type| Description|
- | -------- | -------- |
- | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
+| Type| Description|
+| -------- | -------- |
+| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
**Example**
```js
- let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
- predicates.greaterThan("AGE", 18)
+ dataAbilityPredicates.greaterThan("AGE", 18)
```
@@ -495,20 +480,19 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | field | string | Yes| Column name in the table.|
- | value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| field | string | Yes| Column name in the table.|
+| value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.|
**Return value**
- | Type| Description|
- | -------- | -------- |
- | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
+| Type| Description|
+| -------- | -------- |
+| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
**Example**
```js
- let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
- predicates.lessThan("AGE", 20)
+ dataAbilityPredicates.lessThan("AGE", 20)
```
@@ -523,20 +507,19 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | field | string | Yes| Column name in the table.|
- | value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| field | string | Yes| Column name in the table.|
+| value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.|
**Return value**
- | Type| Description|
- | -------- | -------- |
- | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
+| Type| Description|
+| -------- | -------- |
+| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
**Example**
```js
- let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
- predicates.greaterThanOrEqualTo("AGE", 18)
+ dataAbilityPredicates.greaterThanOrEqualTo("AGE", 18)
```
@@ -551,20 +534,19 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | field | string | Yes| Column name in the table.|
- | value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| field | string | Yes| Column name in the table.|
+| value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.|
**Return value**
- | Type| Description|
- | -------- | -------- |
- | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
+| Type| Description|
+| -------- | -------- |
+| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
**Example**
```js
- let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
- predicates.lessThanOrEqualTo("AGE", 20)
+ dataAbilityPredicates.lessThanOrEqualTo("AGE", 20)
```
@@ -579,19 +561,18 @@ Sets a **DataAbilityPredicates** object to match the column with values sorted i
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | field | string | Yes| Column name in the table.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| field | string | Yes| Column name in the table.|
**Return value**
- | Type| Description|
- | -------- | -------- |
- | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
+| Type| Description|
+| -------- | -------- |
+| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
**Example**
```js
- let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
- predicates.orderByAsc("NAME")
+ dataAbilityPredicates.orderByAsc("NAME")
```
@@ -606,19 +587,18 @@ Sets a **DataAbilityPredicates** object to match the column with values sorted i
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | field | string | Yes| Column name in the table.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| field | string | Yes| Column name in the table.|
**Return value**
- | Type| Description|
- | -------- | -------- |
- | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
+| Type| Description|
+| -------- | -------- |
+| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
**Example**
```js
- let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
- predicates.orderByDesc("AGE")
+ dataAbilityPredicates.orderByDesc("AGE")
```
@@ -633,20 +613,13 @@ Sets a **DataAbilityPredicates** object to filter out duplicate records.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Return value**
- | Type| Description|
- | -------- | -------- |
- | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that can filter out duplicate records.|
+| Type| Description|
+| -------- | -------- |
+| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that can filter out duplicate records.|
**Example**
```js
- let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
- predicates.equalTo("NAME", "Rose").distinct("NAME")
- let promiseDistinct = rdbStore.query(predicates, ["NAME"])
- promiseDistinct.then((resultSet) => {
- console.log("distinct")
- }).catch((err) => {
- expect(null).assertFail();
- })
+ dataAbilityPredicates.equalTo("NAME", "Rose").distinct()
```
@@ -661,19 +634,18 @@ Set a **DataAbilityPredicates** object to specify the maximum number of records.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | value | number | Yes| Maximum number of records.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| value | number | Yes| Maximum number of records.|
**Return value**
- | Type| Description|
- | -------- | -------- |
- | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that specifies the maximum number of records.|
+| Type| Description|
+| -------- | -------- |
+| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that specifies the maximum number of records.|
**Example**
```js
- let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
- predicates.equalTo("NAME", "Rose").limitAs(3)
+ dataAbilityPredicates.equalTo("NAME", "Rose").limitAs(3)
```
@@ -688,19 +660,18 @@ Sets a **DataAbilityPredicates** object to specify the start position of the ret
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | rowOffset | number | Yes| Number of rows to offset from the beginning. The value is a positive integer.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| rowOffset | number | Yes| Number of rows to offset from the beginning. The value is a positive integer.|
**Return value**
- | Type| Description|
- | -------- | -------- |
- | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that specifies the start position of the returned result.|
+| Type| Description|
+| -------- | -------- |
+| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that specifies the start position of the returned result.|
**Example**
```js
- let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
- predicates.equalTo("NAME", "Rose").offsetAs(3)
+ dataAbilityPredicates.equalTo("NAME", "Rose").offsetAs(3)
```
@@ -715,19 +686,18 @@ Sets a **DataAbilityPredicates** object to group rows that have the same value i
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | fields | Array<string> | Yes| Names of columns to group.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| fields | Array<string> | Yes| Names of columns to group.|
**Return value**
- | Type| Description|
- | -------- | -------- |
- | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that groups rows with the same value.|
+| Type| Description|
+| -------- | -------- |
+| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that groups rows with the same value.|
**Example**
```js
- let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
- predicates.groupBy(["AGE", "NAME"])
+ dataAbilityPredicates.groupBy(["AGE", "NAME"])
```
### indexedBy
@@ -735,24 +705,24 @@ Sets a **DataAbilityPredicates** object to group rows that have the same value i
indexedBy(field: string): DataAbilityPredicates
-
Sets a **DataAbilityPredicates** object to specify the index column.
+**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
+
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | indexName | string | Yes| Name of the index column.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| indexName | string | Yes| Name of the index column.|
**Return value**
- | Type| Description|
- | -------- | -------- |
- | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that specifies the index column.|
+| Type| Description|
+| -------- | -------- |
+| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that specifies the index column.|
**Example**
```js
- let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
- predicates.indexedBy("SALARY_INDEX")
+ dataAbilityPredicates.indexedBy("SALARY_INDEX")
```
@@ -767,21 +737,20 @@ Sets a **DataAbilityPredicates** object to match the field with data type Array<
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | field | string | Yes| Column name in the table.|
- | value | Array<[ValueType](#valuetype)> | Yes| Array of **ValueType**s to match.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| field | string | Yes| Column name in the table.|
+| value | Array<[ValueType](#valuetype)> | Yes| Array of **ValueType**s to match.|
**Return value**
- | Type| Description|
- | -------- | -------- |
- | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
+| Type| Description|
+| -------- | -------- |
+| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
**Example**
```js
- let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
- predicates.in("AGE", [18, 20])
+ dataAbilityPredicates.in("AGE", [18, 20])
```
@@ -796,21 +765,20 @@ Sets a **DataAbilityPredicates** object to match the field with data type Array<
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | field | string | Yes| Column name in the table.|
- | value | Array<[ValueType](#valuetype)> | Yes| Array of **ValueType**s to match.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| field | string | Yes| Column name in the table.|
+| value | Array<[ValueType](#valuetype)> | Yes| Array of **ValueType**s to match.|
**Return value**
- | Type| Description|
- | -------- | -------- |
- | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
+| Type| Description|
+| -------- | -------- |
+| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
**Example**
```js
- let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
- predicates.notIn("NAME", ["Lisa", "Rose"])
+ dataAbilityPredicates.notIn("NAME", ["Lisa", "Rose"])
```
## ValueType
diff --git a/en/application-dev/reference/apis/js-apis-data-distributedobject.md b/en/application-dev/reference/apis/js-apis-data-distributedobject.md
index 36761408ca6fe04d507711a0664f0903fa48be90..a58a4583a1db69548342f0c63b8a13aec0dfb623 100644
--- a/en/application-dev/reference/apis/js-apis-data-distributedobject.md
+++ b/en/application-dev/reference/apis/js-apis-data-distributedobject.md
@@ -1,6 +1,9 @@
# Distributed Data Object
+Provides basic data object management, including creating, querying, deleting, modifying, and subscribing to data objects, and distributed data object collaboration for the same application among multiple devices.
+
> **NOTE**
+>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
@@ -20,9 +23,9 @@ Creates a distributed data object.
**System capability**: SystemCapability.DistributedDataManager.DataObject.DistributedObject
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | source | object | Yes| Attribute of the distributed data object to create.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| source | object | Yes| Attribute of the distributed data object to create.|
**Return value**
| Type| Description|
@@ -31,14 +34,14 @@ Creates a distributed data object.
**Example**
```js
- import distributedObject from '@ohos.data.distributedDataObject'
+ import distributedObject from '@ohos.data.distributedDataObject';
// Create a distributed data object, which contains attributes of four types, namely, string, number, boolean, and object.
var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false,
parent:{mother:"jack mom",father:"jack Dad"}});
```
-## distributedObject.genSessionId()
+## distributedObject.genSessionId
genSessionId(): string
@@ -47,16 +50,37 @@ Creates a random session ID.
**System capability**: SystemCapability.DistributedDataManager.DataObject.DistributedObject
**Return value**
- | Type| Description|
- | -------- | -------- |
- | string | Session ID created.|
+| Type| Description|
+| -------- | -------- |
+| string | Session ID created.|
**Example**
```js
- import distributedObject from '@ohos.data.distributedDataObject'
+ import distributedObject from '@ohos.data.distributedDataObject';
var sessionId = distributedObject.genSessionId();
```
+## SaveSuccessResponse9+
+
+Called when the **Save()** API is successfully called.
+
+**System capability**: SystemCapability.DistributedDataManager.DataObject.DistributedObject
+
+| Name| Type| Description|
+| -------- | -------- | -------- |
+| sessionId | string | Unique ID for multi-device collaboration.|
+| version | number |Version of the distributed data object saved.|
+| deviceId | string | ID of the device where the distributed data object is stored. The default value is **local**, which identifies a local device. You can set it as required.|
+
+## RevokeSaveSuccessResponse9+
+
+Called when the **revokeSave()** API is successfully called.
+
+**System capability**: SystemCapability.DistributedDataManager.DataObject.DistributedObject
+
+| Name| Type| Description|
+| -------- | -------- | -------- |
+| sessionId | string | Unique ID for multi-device collaboration.|
## DistributedObject
@@ -68,24 +92,26 @@ setSessionId(sessionId?: string): boolean
Sets a session ID for synchronization. Automatic synchronization is performed for multiple devices with the same session ID on a trusted network.
+**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
+
**System capability**: SystemCapability.DistributedDataManager.DataObject.DistributedObject
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | sessionId | string | No| ID of a distributed data object on a trusted network. To remove a distributed data object from the network, set this parameter to "" or leave it empty.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| sessionId | string | No| ID of a distributed data object on a trusted network. To remove a distributed data object from the network, set this parameter to "" or leave it empty.|
**Return value**
- | Type| Description|
- | -------- | -------- |
- | boolean | Returns **true** if the session ID is set successfully; returns **false** otherwise. |
+| Type| Description|
+| -------- | -------- |
+| boolean | Returns **true** if the session ID is set successfully; returns **false** otherwise. |
**Example**
```js
- import distributedObject from '@ohos.data.distributedDataObject'
+ import distributedObject from '@ohos.data.distributedDataObject';
var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false,
parent:{mother:"jack mom",father:"jack Dad"}});
// Add g_object to the distributed network.
@@ -104,25 +130,25 @@ Subscribes to the changes of this distributed data object.
**System capability**: SystemCapability.DistributedDataManager.DataObject.DistributedObject
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | type | string | Yes| Event type to subscribe to. The value is **change**, which indicates data changes.|
- | callback | Callback<{ sessionId: string, fields: Array<string> }> | Yes| Callback used to return the changes of the distributed data object. **sessionId** indicates the session ID of the distributed data object. **fields** indicates the changed attributes of the distributed data object.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| type | string | Yes| Event type to subscribe to. The value is **change**, which indicates data changes.|
+| callback | Callback<{ sessionId: string, fields: Array<string> }> | Yes| Callback used to return the changes of the distributed data object. **sessionId** indicates the session ID of the distributed data object. **fields** indicates the changed attributes of the distributed data object.|
**Example**
- ```js
- import distributedObject from '@ohos.data.distributedDataObject'
- var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false,
- parent:{mother:"jack mom",father:"jack Dad"}});
- g_object.on("change", function (sessionId, changeData) {
- console.info("change" + sessionId);
- if (changeData != null && changeData != undefined) {
- changeData.forEach(element => {
- console.info("changed !" + element + " " + g_object[element]);
- });
- }
- });
- ```
+```js
+import distributedObject from '@ohos.data.distributedDataObject';
+var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false,parent:{mother:"jack mom",father:"jack Dad"}});
+globalThis.changeCallback = (sessionId, changeData) => {
+ console.info("change" + sessionId);
+ if (changeData != null && changeData != undefined) {
+ changeData.forEach(element => {
+ console.info("changed !" + element + " " + g_object[element]);
+ });
+ }
+}
+g_object.on("change", globalThis.changeCallback);
+```
### off('change')
@@ -133,27 +159,21 @@ Unsubscribes from the changes of this distributed data object.
**System capability**: SystemCapability.DistributedDataManager.DataObject.DistributedObject
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | type | string | Yes| Event type to unsubscribe from. The value is **change**, which indicates data changes.|
- | callback | Callback<{ sessionId: string, fields: Array<string> }> | No| Callback used to return the changes of the distributed data object. If this parameter is not specified, this API unsubscribes from all callbacks for data changes of this distributed data object. **sessionId** indicates the session ID of the distributed data object. **fields** indicates the changed attributes of the distributed data object.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| type | string | Yes| Event type to unsubscribe from. The value is **change**, which indicates data changes.|
+| callback | Callback<{ sessionId: string, fields: Array<string> }> | No| Callback to be unregistered. If this parameter is not set, all data change callbacks of the object will be unregistered. **sessionId** indicates the session ID of the distributed data object. **fields** indicates the changed attributes of the distributed data object.|
**Example**
- ```js
- import distributedObject from '@ohos.data.distributedDataObject'
- var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false,
- parent:{mother:"jack mom",father:"jack Dad"}});
- g_object.on("change", function (sessionId, changeData) {
- console.info("change" + sessionId);
- });
- // Unsubscribe from the specified data change callback for the distributed data object.
- g_object.off("change", function (sessionId, changeData) {
- console.info("change" + sessionId);
- });
- // Unsubscribe from all data change callbacks for the distributed data object.
- g_object.off("change");
- ```
+```js
+import distributedObject from '@ohos.data.distributedDataObject';
+var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false,parent:{mother:"jack mom",father:"jack Dad"}});
+// Unregister the specified data change callback.
+g_object.off("change", globalThis.changeCallback);
+// Unregister all data change callbacks.
+g_object.off("change");
+```
### on('status')
@@ -164,20 +184,20 @@ Subscribes to the status change (online or offline) of this distributed data obj
**System capability**: SystemCapability.DistributedDataManager.DataObject.DistributedObject
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | type | string | Yes| Event type to subscribe to. The value is **status**, which indicates the change in the status (online or offline) of the distributed data object.|
- | callback | Callback<{ sessionId: string, networkId: string, status: 'online' \| 'offline' }> | Yes| Callback used to return the status change. **sessionId** indicates the session ID of the distributed data object. **networkId** indicates the network ID of the device. **status** indicates the status, which can be online or offline.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| type | string | Yes| Event type to subscribe to. The value is **status**, which indicates the status change (online or offline) of the distributed data object.|
+| callback | Callback<{ sessionId: string, networkId: string, status: 'online' \| 'offline' }> | Yes| Callback used to return the status change. **sessionId**: session ID of the distributed data object. **networkId**: object device ID, that is, **deviceId**. **status** indicates the object status, which can be online or offline. |
**Example**
- ```js
- import distributedObject from '@ohos.data.distributedDataObject'
- var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false,
- parent:{mother:"jack mom",father:"jack Dad"}});
- g_object.on("status", function (sessionId, networkid, status) {
- this.response += "status changed " + sessionId + " " + status + " " + networkId;
- });
- ```
+```js
+import distributedObject from '@ohos.data.distributedDataObject';
+globalThis.statusCallback = (sessionId, networkId, status) => {
+ globalThis.response += "status changed " + sessionId + " " + status + " " + networkId;
+}
+var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false,parent:{mother:"jack mom",father:"jack Dad"}});
+g_object.on("status", globalThis.statusCallback);
+```
### off('status')
@@ -189,22 +209,158 @@ Unsubscribes from the status change (online or offline) of this distributed data
**System capability**: SystemCapability.DistributedDataManager.DataObject.DistributedObject
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | type | string | Yes| Event type to unsubscribe from. The value is **status**, which indicates the change in the status (online or offline) of the distributed data object.|
- | callback | Callback<{ sessionId: string, deviceId: string, status: 'online' \| 'offline' }> | No| Callback used to return the status change. If this parameter is not specified, this API unsubscribes from all callbacks of this distributed data object. **sessionId** indicates the session ID of the distributed data object. **deviceId** indicates the device ID of the distributed data object. **status** indicates the status, which can be online or offline.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| type | string | Yes| Event type to unsubscribe from. The value is **status**, which indicates the status change (online or offline) of the distributed data object.|
+| callback | Callback<{ sessionId: string, deviceId: string, status: 'online' \| 'offline' }> | No| Callback used to return the status change. If this parameter is not specified, this API unsubscribes from all callbacks of this distributed data object. **sessionId**: session ID of the distributed data object. **deviceId** indicates the device ID of the distributed data object. **status** indicates the status, which can be online or offline.|
**Example**
- ```js
- import distributedObject from '@ohos.data.distributedDataObject'
- g_object.on("status", function (sessionId, networkId, status) {
- this.response += "status changed " + sessionId + " " + status + " " + networkId;
+```js
+import distributedObject from '@ohos.data.distributedDataObject';
+var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false,parent:{mother:"jack mom",father:"jack Dad"}});
+globalThis.statusCallback = (sessionId, networkId, status) => {
+ globalThis.response += "status changed " + sessionId + " " + status + " " + networkId;
+}
+// Unsubscribe from the specified status change callback for the distributed data object.
+g_object.off("status",globalThis.statusCallback);
+// Unsubscribe from all status change callbacks for the distributed data object.
+g_object.off("status");
+```
+
+### save9+
+
+save(deviceId: string, callback: AsyncCallback<SaveSuccessResponse>): void
+
+Saves a distributed data object. This API uses an asynchronous callback to return the result.
+
+If the application is active, the saved data will not be released. When the application exits and restarts, the data saved on the device will be restored.
+
+The saved data will be released in the following cases:
+
+- The data is stored for more than 24 hours.
+- The application has been uninstalled.
+- Data is successfully restored.
+
+**System capability**: SystemCapability.DistributedDataManager.DataObject.DistributedObject
+
+**Parameters**
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| deviceId | string | Yes| ID of the device where data is stored. The value **local** indicates the local device.|
+| callback | AsyncCallback<[SaveSuccessResponse](#savesuccessresponse)> | Yes| Callback used to return **SaveSuccessResponse**, which contains information such as session ID, version, and device ID.|
+
+**Example**
+
+ ```ts
+ import distributedObject from '@ohos.data.distributedDataObject';
+ var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false});
+ g_object.setSessionId("123456");
+ g_object.save("local", (result)=>{
+ console.log("save callback");
+ console.info("save sessionId " + result.sessionId);
+ console.info("save version " + result.version);
+ console.info("save deviceId " + result.deviceId);
+ });
+ ```
+
+### save9+
+
+save(deviceId: string): Promise<SaveSuccessResponse>
+
+Saves a distributed data object. This API uses a promise to return the result.
+
+If the application is active, the saved data will not be released. When the application exits and restarts, the data saved on the device will be restored.
+
+The saved data will be released in the following cases:
+
+- The data is stored for more than 24 hours.
+- The application has been uninstalled.
+- Data is successfully restored.
+
+**System capability**: SystemCapability.DistributedDataManager.DataObject.DistributedObject
+
+**Parameters**
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| deviceId | string | Yes| ID of the device where the data is saved. The default value is **local**, which indicates the local device. |
+
+ **Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Promise<[SaveSuccessResponse](#savesuccessresponse)> | Promise used to return **SaveSuccessResponse**, which contains information such as session ID, version, and device ID.|
+
+**Example**
+
+ ```ts
+ import distributedObject from '@ohos.data.distributedDataObject';
+ var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false});
+ g_object.setSessionId("123456");
+ g_object.save("local").then((result)=>{
+ console.log("save callback");
+ console.info("save sessionId " + result.sessionId);
+ console.info("save version " + result.version);
+ console.info("save deviceId " + result.deviceId);
+ }, ()=>{
+ console.error("save failed");
+ });
+ ```
+
+### revokeSave9+
+
+revokeSave(callback: AsyncCallback<SaveSuccessResponse>): void
+
+Revokes the saving operation of a distributed data object. This API uses an asynchronous callback to return the result.
+
+If the object is saved on the local device, the data saved on all trusted devices will be deleted.
+If the object is stored on another device, the data on the local device will be deleted.
+
+**System capability**: SystemCapability.DistributedDataManager.DataObject.DistributedObject
+
+**Parameters**
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| callback | AsyncCallback<[RevokeSaveSuccessResponse](#revokesavesuccessresponse)> | No| Callback used to return **RevokeSaveSuccessResponse**, which contains the session ID.|
+
+**Example**
+
+ ```ts
+ import distributedObject from '@ohos.data.distributedDataObject';
+ var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false});
+ g_object.setSessionId("123456");
+ g_object.revokeSave((result, data) =>{
+ console.log("revokeSave callback");
});
- // Unsubscribe from the specified status change callback for the distributed data object.
- g_object.off("status", function (sessionId, networkId, status) {
- this.response += "status changed " + sessionId + " " + status + " " + networkId;
+ ```
+
+### revokeSave9+
+
+revokeSave(): Promise<SaveSuccessResponse>
+
+Revokes the saving operation of a distributed data object. This API uses a promise to return the result.
+
+If the object is saved on the local device, the data saved on all trusted devices will be deleted.
+If the object is stored on another device, the data on the local device will be deleted.
+
+**System capability**: SystemCapability.DistributedDataManager.DataObject.DistributedObject
+
+ **Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Promise<[RevokeSaveSuccessResponse](#revokesavesuccessresponse)> | Promise used to return **RevokeSaveSuccessResponse**, which contains the session ID.|
+
+**Example**
+
+ ```ts
+ import distributedObject from '@ohos.data.distributedDataObject';
+ var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false});
+ g_object.setSessionId("123456");
+ g_object.revokeSave("local").then((result)=>{
+ console.log("revokeSave callback");
+ console.log("sessionId" + result.sessionId);
+ }, ()=>{
+ console.error("revokeSave failed");
});
- // Unsubscribe from all status change callbacks for the distributed data object.
- g_object.off("status");
```
diff --git a/en/application-dev/reference/apis/js-apis-data-preferences.md b/en/application-dev/reference/apis/js-apis-data-preferences.md
index 1010a20849fb9da41e445bc5212e88427b3f28c5..73d27f9f20009d0674b4cf07e017139988d09fbe 100644
--- a/en/application-dev/reference/apis/js-apis-data-preferences.md
+++ b/en/application-dev/reference/apis/js-apis-data-preferences.md
@@ -1,6 +1,6 @@
# Preferences
-Preferences provide capabilities for processing data in the form of key-value (KV) pairs and supports lightweight data persistence, modification, and query. In KV pairs, keys are of the string type, and values can be of the number, string, or Boolean type.
+Preferences provide capabilities for processing data in the form of key-value (KV) pairs and support lightweight data persistence, modification, and query. In KV pairs, keys are of the string type, and values can be of the number, string, or Boolean type.
> **NOTE**
@@ -19,8 +19,8 @@ import data_preferences from '@ohos.data.preferences';
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| MAX_KEY_LENGTH | string | Yes| No| Maximum length of a key. It is 80 bytes.|
-| MAX_VALUE_LENGTH | string | Yes| No| Maximum length of a value. It is 8192 bytes.|
+| MAX_KEY_LENGTH | string | Yes| No| Maximum length of a key. It must be less than 80 bytes.|
+| MAX_VALUE_LENGTH | string | Yes| No| Maximum length of a value. It must be less than 8192 bytes.|
## data_preferences.getPreferences
@@ -33,11 +33,11 @@ Reads a **Preferences** persistence file and loads data to the **Preferences** i
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | context | [Context](js-apis-ability-context.md) | Yes| Context of the application or functionality.|
- | name | string | Yes| Name of the **Preferences** instance persistence file.|
- | callback | AsyncCallback<[Preferences](#preferences)> | Yes| Callback used to return the result.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| context | [Context](js-apis-ability-context.md) | Yes| Context of the application or functionality.|
+| name | string | Yes| Name of the **Preferences** instance persistence file.|
+| callback | AsyncCallback<[Preferences](#preferences)> | Yes| Callback used to return the result.|
**Example**
```ts
@@ -60,15 +60,15 @@ Reads a **Preferences** persistence file and loads data to the **Preferences** i
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | context | [Context](js-apis-ability-context.md) | Yes| Context of the application or functionality.|
- | name | string | Yes| Name of the **Preferences** instance persistence file.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| context | [Context](js-apis-ability-context.md) | Yes| Context of the application or functionality.|
+| name | string | Yes| Name of the **Preferences** instance persistence file.|
**Return value**
- | Type| Description|
- | -------- | -------- |
- | Promise<[Preferences](#preferences)> | Promise used to return the result.|
+| Type| Description|
+| -------- | -------- |
+| Promise<[Preferences](#preferences)> | Promise used to return the result.|
**Example**
```ts
@@ -76,7 +76,7 @@ let promise = data_preferences.getPreferences(this.context, 'mystore')
promise.then((preferences) => {
console.info("Got preferences successfully.")
}).catch((err) => {
- console.info("Failed to get the preferences")
+ console.info("Failed to get the preferences")
})
```
@@ -91,11 +91,11 @@ Once a **Preferences** persistence file is deleted, the **Preferences** instance
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | context | [Context](js-apis-ability-context.md) | Yes| Context of the application or functionality.|
- | name | string | Yes| Name of the **Preferences** instance persistence file.|
- | callback | AsyncCallback<void> | Yes| Callback used to return the result.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| context | [Context](js-apis-ability-context.md) | Yes| Context of the application or functionality.|
+| name | string | Yes| Name of the **Preferences** instance persistence file.|
+| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
**Example**
```ts
@@ -119,15 +119,15 @@ Once a **Preferences** persistence file is deleted, the **Preferences** instance
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | context | [Context](js-apis-ability-context.md) | Yes| Context of the application or functionality.|
- | name | string | Yes| Name of the **Preferences** instance persistence file.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| context | [Context](js-apis-ability-context.md) | Yes| Context of the application or functionality.|
+| name | string | Yes| Name of the **Preferences** instance persistence file.|
**Return value**
- | Type| Description|
- | -------- | -------- |
- | Promise<void> | Promise used to return the result.|
+| Type| Description|
+| -------- | -------- |
+| Promise<void> | Promise used to return the result.|
**Example**
```ts
@@ -151,11 +151,11 @@ When a **Preferences** singleton instance is removed, this instance cannot be us
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | context | [Context](js-apis-ability-context.md) | Yes| Context of the application or functionality.|
- | name | string | Yes| Name of the **Preferences** instance persistence file.|
- | callback | AsyncCallback<void> | Yes| Callback used to return the result.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| context | [Context](js-apis-ability-context.md) | Yes| Context of the application or functionality.|
+| name | string | Yes| Name of the **Preferences** instance persistence file.|
+| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
**Example**
```ts
@@ -179,16 +179,16 @@ When a **Preferences** singleton instance is removed, this instance cannot be us
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
-Parameters
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | context | [Context](js-apis-ability-context.md) | Yes| Context of the application or functionality.|
- | name | string | Yes| Name of the **Preferences** instance persistence file.|
+**Parameters**
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| context | [Context](js-apis-ability-context.md) | Yes| Context of the application or functionality.|
+| name | string | Yes| Name of the **Preferences** instance persistence file.|
**Return value**
- | Type| Description|
- | -------- | -------- |
- | Promise<void> | Promise used to return the result.|
+| Type| Description|
+| -------- | -------- |
+| Promise<void> | Promise used to return the result.|
**Example**
```ts
@@ -215,15 +215,15 @@ Obtains the value of a key. If the value is null or a non-default value, the def
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | key | string | Yes| Key of the data to obtain. It cannot be empty.|
- | defValue | [ValueType](#valuetype) | Yes| Default value to be returned. It can be a number, string, or Boolean value.|
- | callback | AsyncCallback<ValueType> | Yes| Callback used to return the result.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| key | string | Yes| Key of the data to obtain. It cannot be empty.|
+| defValue | [ValueType](#valuetype) | Yes| Default value to be returned. It can be a number, string, or Boolean value.|
+| callback | AsyncCallback<ValueType> | Yes| Callback used to return the result.|
**Example**
```ts
- preferences.get('startup', 'default', function(err, value) {
+preferences.get('startup', 'default', function(err, value) {
if (err) {
console.info("Failed to get the value of startup, err: " + err)
return
@@ -242,15 +242,15 @@ Obtains the value of a key. If the value is null or a non-default value, the def
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | key | string | Yes| Key of the data to obtain. It cannot be empty.|
- | defValue | [ValueType](#valuetype) | Yes| Default value to be returned. It can be a number, string, or Boolean value.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| key | string | Yes| Key of the data to obtain. It cannot be empty.|
+| defValue | [ValueType](#valuetype) | Yes| Default value to be returned. It can be a number, string, or Boolean value.|
**Return value**
- | Type| Description|
- | -------- | -------- |
- | Promise<ValueType> | Promise used to return the result.|
+| Type| Description|
+| -------- | -------- |
+| Promise<ValueType> | Promise used to return the result.|
**Example**
```ts
@@ -262,6 +262,57 @@ promise.then((value) => {
})
```
+### getAll
+
+getAll(callback: AsyncCallback<Object>): void;
+
+Obtains the **Object** instance that contains all KV pairs.
+
+**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
+
+**Parameters**
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| callback | AsyncCallback<Object> | Yes| Callback used to return the **Object** instance obtained.|
+
+**Example**
+```ts
+preferences.get.getAll(function (err, value) {
+ if (err) {
+ console.info("getAll failed, err: " + err)
+ return
+ }
+ let keys = Object.keys(value)
+ console.info('getAll keys = ' + keys)
+ console.info("getAll object = " + JSON.stringify(value))
+});
+```
+
+
+### getAll
+
+getAll(): Promise<Object>
+
+Obtains the **Object** instance that contains all KV pairs.
+
+**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
+
+**Return value**
+| Type| Description|
+| -------- | -------- |
+| Promise<Object> | Promise used to return the **Object** instance obtained.|
+
+**Example**
+```ts
+let promise = preferences.getAll()
+promise.then((value) => {
+ let keys = Object.keys(value)
+ console.info('getAll keys = ' + keys)
+ console.info("getAll object = " + JSON.stringify(value))
+}).catch((err) => {
+ console.info("getAll failed, err: " + err)
+})
+```
### put
@@ -272,11 +323,11 @@ Puts a new value to this **Preferences** instance and its persistence file. This
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | key | string | Yes| Key of the data. It cannot be empty.|
- | value | [ValueType](#valuetype) | Yes| New value to store. It can be a number, string, or Boolean value.|
- | callback | AsyncCallback<void> | Yes| Callback used to return the result.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| key | string | Yes| Key of the data. It cannot be empty.|
+| value | [ValueType](#valuetype) | Yes| New value to store. It can be a number, string, or Boolean value.|
+| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
**Example**
```ts
@@ -299,15 +350,15 @@ Puts a new value to this **Preferences** instance and its persistence file. This
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | key | string | Yes| Key of the data. It cannot be empty.|
- | value | [ValueType](#valuetype) | Yes| New value to store. It can be a number, string, or Boolean value.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| key | string | Yes| Key of the data. It cannot be empty.|
+| value | [ValueType](#valuetype) | Yes| New value to store. It can be a number, string, or Boolean value.|
**Return value**
- | Type| Description|
- | -------- | -------- |
- | Promise<void> | Promise used to return the result.|
+| Type| Description|
+| -------- | -------- |
+| Promise<void> | Promise used to return the result.|
**Example**
```ts
@@ -322,22 +373,17 @@ promise.then(() => {
### has
-has(key: string, callback: AsyncCallback<boolean>): boolean
+has(key: string, callback: AsyncCallback<boolean>): void
Checks whether this **Preferences** instance contains data with a given key. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | key | string | Yes| Key of the data to check. It cannot be empty.|
- | callback | AsyncCallback<boolean> | Yes| Callback used to return the result.|
-
-**Return value**
- | Type| Description|
- | -------- | -------- |
- | boolean | Returns **true** if the **Preferences** instance contains data with the specified key; returns **false** otherwise.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| key | string | Yes| Key of the data to check. It cannot be empty.|
+| callback | AsyncCallback<boolean> | Yes| Callback used to return the result. It returns **true** if the **Preferences** instance contains data with the given key and returns **false** otherwise.|
**Example**
```ts
@@ -364,14 +410,14 @@ Checks whether this **Preferences** instance contains data with a given key. Thi
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | key | string | Yes| Key of the data to check. It cannot be empty.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| key | string | Yes| Key of the data to check. It cannot be empty.|
**Return value**
- | Type| Description|
- | -------- | -------- |
- | Promise<boolean> | Promise used to return the result.|
+| Type| Description|
+| -------- | -------- |
+| Promise<boolean> | Promise used to return the result. It returns **true** if the **Preferences** instance contains data with the given key and returns **false** otherwise.|
**Example**
```ts
@@ -383,7 +429,7 @@ promise.then((isExist) => {
console.info("The key of startup is not contained.")
}
}).catch((err) => {
- console.info("Check the key of startup failed, err: " + err)
+ console.info("Failed to check the key of startup, err: " + err)
})
```
@@ -397,10 +443,10 @@ Deletes a KV pair of the specified key from this **Preferences** instance. This
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | key | string | Yes| Key of the KV pair to delete. It cannot be empty.|
- | callback | AsyncCallback<void> | Yes| Callback used to return the result.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| key | string | Yes| Key of the KV pair to delete. It cannot be empty.|
+| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
**Example**
```ts
@@ -423,14 +469,14 @@ Deletes a KV pair of the specified key from this **Preferences** instance. This
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | key | string | Yes| Key of the KV pair to delete. It cannot be empty.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| key | string | Yes| Key of the KV pair to delete. It cannot be empty.|
**Return value**
- | Type| Description|
- | -------- | -------- |
- | Promise<void> | Promise used to return the result.|
+| Type| Description|
+| -------- | -------- |
+| Promise<void> | Promise used to return the result.|
**Example**
```ts
@@ -452,9 +498,9 @@ Saves the modification to this **Preferences** instance and synchronizes the mod
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | callback | AsyncCallback<void> | Yes| Callback used to return the result.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
**Example**
```ts
@@ -477,9 +523,9 @@ Saves the modification to this **Preferences** instance and synchronizes the mod
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Return value**
- | Type| Description|
- | -------- | -------- |
- | Promise<void> | Promise used to return the result.|
+| Type| Description|
+| -------- | -------- |
+| Promise<void> | Promise used to return the result.|
**Example**
```ts
@@ -500,10 +546,10 @@ Clears data of this **Preferences** instance. This API uses an asynchronous call
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
-Parameters
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | callback | AsyncCallback<void> | Yes| Callback used to return the result.|
+**Parameters**
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
**Example**
```ts
@@ -526,9 +572,9 @@ Clears data of this **Preferences** instance. This API uses a promise to return
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Return value**
- | Type| Description|
- | -------- | -------- |
- | Promise<void> | Promise used to return the result.|
+| Type| Description|
+| -------- | -------- |
+| Promise<void> | Promise used to return the result.|
**Example**
```ts
@@ -550,10 +596,10 @@ Subscribes to data changes. When the value of the subscribed key changes, a call
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters**
- | Name| Type| Description|
- | -------- | -------- | -------- |
- | type | string | Event type. The value **change** indicates data change events.|
- | callback | Callback<{ key : string }> | Callback used to return data changes.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| type | string | Yes| Event type. The value **change** indicates data change events.|
+| callback | Callback<{ key : string }> | Yes| Callback used to return data changes.|
**Example**
```ts
@@ -584,17 +630,17 @@ preferences.put('startup', 'auto', function (err) {
### off('change')
-off(type: 'change', callback: Callback<{ key : string }>): void
+off(type: 'change', callback?: Callback<{ key : string }>): void
Unsubscribes from data changes.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters**
- | Name| Type| Description|
- | -------- | -------- | -------- |
- | type | string | Event type. The value **change** indicates data change events.|
- | callback | Callback<{ key : string }> | Callback used to return data changes.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| type | string | Yes| Event type. The value **change** indicates data change events.|
+| callback | Callback<{ key : string }> | No| Callback used to return data changes. If this parameter is left empty, all callbacks for data changes will be canceled.|
**Example**
```ts
diff --git a/en/application-dev/reference/apis/js-apis-data-rdb.md b/en/application-dev/reference/apis/js-apis-data-rdb.md
index f1211dc922a699081aeab7a5b145771923d8f7fe..ac26222e5da8c26216901b3de93bec9b4f22133b 100644
--- a/en/application-dev/reference/apis/js-apis-data-rdb.md
+++ b/en/application-dev/reference/apis/js-apis-data-rdb.md
@@ -1,6 +1,14 @@
# Relational Database
+The relational database (RDB) manages data based on relational models. With the underlying SQLite database, the RDB provides a complete mechanism for managing local databases. To satisfy different needs in complicated scenarios, the RDB offers a series of methods for performing operations such as adding, deleting, modifying, and querying data, and supports direct execution of SQL statements.
+
+This module provides the following RDB-related functions:
+
+- [RdbPredicates](#rdbpredicates): predicates indicating the nature, feature, or relationship of a data entity in an RDB store. It is used to define the operation conditions for an RDB store.
+- [RdbStore](#rdbstore): provides APIs for managing an RDB store.
+
> **NOTE**
+>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
@@ -11,71 +19,9 @@ import data_rdb from '@ohos.data.rdb';
## data_rdb.getRdbStore
-getRdbStore(config: StoreConfig, version: number, callback: AsyncCallback<RdbStore>): void
-
-Obtains a relational database (RDB) store. This API uses an asynchronous callback to return the result. You can set parameters for the RDB store based on service requirements and call APIs to perform data operations.
-
-**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
-
-**Parameters**
-
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| config | [StoreConfig](#storeconfig) | Yes| Configuration of the RDB store.|
-| version | number | Yes| RDB store version.|
-| callback | AsyncCallback<[RdbStore](#rdbstore)> | Yes| Callback invoked to return the RDB store obtained.|
-
-**Example**
-
-```js
-const STORE_CONFIG = { name: "RdbTest.db"}
-data_rdb.getRdbStore(STORE_CONFIG, 1, function (err, rdbStore) {
- if (err) {
- console.info("Failed to get RdbStore, err: " + err)
- return
- }
- console.log("Got RdbStore successfully.")
-})
-```
-## data_rdb.getRdbStore
-
-getRdbStore(config: StoreConfig, version: number): Promise<RdbStore>
-
-Obtains an RDB store. This API uses a promise to return the result. You can set parameters for the RDB store based on service requirements and call APIs to perform data operations.
-
-**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
-
-**Parameters**
-
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| config | [StoreConfig](#storeconfig) | Yes| Configuration of the RDB store.|
-| version | number | Yes| RDB store version.|
-
-**Return value**
-
-| Type| Description|
-| -------- | -------- |
-| Promise<[RdbStore](#rdbstore)> | Promise used to return the RDB store obtained.|
-
-**Example**
-
-```js
-const STORE_CONFIG = { name: "RdbTest.db" }
-let promise = data_rdb.getRdbStore(STORE_CONFIG, 1);
-promise.then(async (rdbStore) => {
- console.log("Got RdbStore successfully.")
-}).catch((err) => {
- console.log("Failed to get RdbStore, err: " + err)
-})
-```
-
-
-## data_rdb.getRdbStore8+
-
getRdbStore(context: Context, config: StoreConfig, version: number, callback: AsyncCallback<RdbStore>): void
-Obtains a relational database (RDB) store. This API uses an asynchronous callback to return the result. You can set parameters for the RDB store based on service requirements and call APIs to perform data operations.
+Obtains an RDB store. This API uses an asynchronous callback to return the result. You can set parameters for the RDB store based on service requirements and call APIs to perform data operations.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
@@ -83,7 +29,7 @@ Obtains a relational database (RDB) store. This API uses an asynchronous callbac
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| context8+ | Context | Yes| Context of the app or functionality. For the definition of **Context** of API version 8, see [Context](js-apis-Context.md). For the definition of **Context** of API version 9, see [Context](js-apis-ability-context.md).|
+| context | Context | Yes| Context of the application or functionality. See [Context](js-apis-Context.md) for versions earlier than API version 9. See [Context](js-apis-ability-context.md) for API version 9 or later.|
| config | [StoreConfig](#storeconfig) | Yes| Configuration of the RDB store.|
| version | number | Yes| RDB store version.|
| callback | AsyncCallback<[RdbStore](#rdbstore)> | Yes| Callback invoked to return the RDB store obtained.|
@@ -101,7 +47,7 @@ data_rdb.getRdbStore(this.context, STORE_CONFIG, 1, function (err, rdbStore) {
})
```
-## data_rdb.getRdbStore8+
+## data_rdb.getRdbStore
getRdbStore(context: Context, config: StoreConfig, version: number): Promise<RdbStore>
@@ -113,7 +59,7 @@ Obtains an RDB store. This API uses a promise to return the result. You can set
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| context8+ | Context | Yes| Context of the app or functionality. For the definition of **Context** of API version 8, see [Context](js-apis-Context.md). For the definition of **Context** of API version 9, see [Context](js-apis-ability-context.md).|
+| context | Context | Yes| Context of the application or functionality. See [Context](js-apis-Context.md) for versions earlier than API version 9. See [Context](js-apis-ability-context.md) for API version 9 or later.|
| config | [StoreConfig](#storeconfig) | Yes| Configuration of the RDB store.|
| version | number | Yes| RDB store version.|
@@ -137,68 +83,16 @@ promise.then(async (rdbStore) => {
## data_rdb.deleteRdbStore
-deleteRdbStore(name: string, callback: AsyncCallback<void>): void
-
-Deletes an RDB store. This API uses a callback to return the result.
-
-**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
-
-**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| name | string | Yes| Name of the RDB store to delete.|
-| callback | AsyncCallback<void> | Yes| Callback invoked to return the result.|
-
-**Example**
-```js
-data_rdb.deleteRdbStore("RdbTest.db", function (err, rdbStore) {
- if (err) {
- console.info("Failed to delete RdbStore, err: " + err)
- return
- }
- console.log("Deleted RdbStore successfully.")
-})
-```
- ## data_rdb.deleteRdbStore
-
-deleteRdbStore(name: string): Promise<void>
-
-Deletes an RDB store. This API uses a promise to return the result.
-
-**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
-
-**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| name | string | Yes| Name of the RDB store to delete.|
-
-**Return value**
-| Type| Description|
-| -------- | -------- |
-| Promise<void> | Promise used to return the result.|
-
-**Example**
-```js
-let promise = data_rdb.deleteRdbStore("RdbTest.db")
-promise.then(()=>{
- console.log("Deleted RdbStore successfully.")
-}).catch((err) => {
- console.info("Failed to delete RdbStore, err: " + err)
-})
-```
-
-## data_rdb.deleteRdbStore8+
-
deleteRdbStore(context: Context, name: string, callback: AsyncCallback<void>): void
-Deletes an RDB store. This API uses a callback to return the result.
+Deletes an RDB store. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| context8+ | Context | Yes| Context of the app or functionality. For the definition of **Context** of API version 8, see [Context](js-apis-Context.md). For the definition of **Context** of API version 9, see [Context](js-apis-ability-context.md).|
+| context | Context | Yes| Context of the application or functionality. See [Context](js-apis-Context.md) for versions earlier than API version 9. See [Context](js-apis-ability-context.md) for API version 9 or later.|
| name | string | Yes| Name of the RDB store to delete.|
| callback | AsyncCallback<void> | Yes| Callback invoked to return the result.|
@@ -213,7 +107,7 @@ data_rdb.deleteRdbStore(this.context, "RdbTest.db", function (err, rdbStore) {
})
```
-## data_rdb.deleteRdbStore8+
+## data_rdb.deleteRdbStore
deleteRdbStore(context: Context, name: string): Promise<void>
@@ -224,7 +118,7 @@ Deletes an RDB store. This API uses a promise to return the result.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| context8+ | Context | Yes| Context of the app or functionality. For the definition of **Context** of API version 8, see [Context](js-apis-Context.md). For the definition of **Context** of API version 9, see [Context](js-apis-ability-context.md).|
+| context | Context | Yes| Context of the application or functionality. See [Context](js-apis-Context.md) for versions earlier than API version 9. See [Context](js-apis-ability-context.md) for API version 9 or later.|
| name | string | Yes| Name of the RDB store to delete.|
**Return value**
@@ -234,7 +128,7 @@ Deletes an RDB store. This API uses a promise to return the result.
**Example**
```js
-let promise = data_rdb.deleteRdbStore("RdbTest.db")
+let promise = data_rdb.deleteRdbStore(this.context, "RdbTest.db")
promise.then(()=>{
console.log("Deleted RdbStore successfully.")
}).catch((err) => {
@@ -636,7 +530,7 @@ Sets the **RdbPredicates** to match the specified string.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the database table.|
-| value | string | Yes| Value to match the **RdbPredicates**.
Wildcards are supported. ***** indicates zero, one, or multiple digits or characters. **?** indicates a single digit or character.|
+| value | string | Yes| Value to match the **RdbPredicates**.
Wildcards are supported. * indicates zero, one, or multiple digits or characters. **?** indicates a single digit or character.|
**Return value**
| Type| Description|
@@ -889,10 +783,10 @@ let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.equalTo("NAME", "Rose").distinct("NAME")
let promise = rdbStore.query(predicates, ["NAME"])
promise.then((resultSet) => {
- console.log("resultSet column names:" + resultSet.columnNames)
- console.log("resultSet column count:" + resultSet.columnCount)
+ console.log("ResultSet column names: " + resultSet.columnNames)
+ console.log("ResultSet column count: " + resultSet.columnCount)
}).catch((err) => {
- console.log("query err.")
+ console.log("Query err.")
})
```
@@ -1064,16 +958,16 @@ Provides methods to manage an RDB store.
### insert
-insert(name: string, values: ValuesBucket, callback: AsyncCallback<number>):void
+insert(table: string, values: ValuesBucket, callback: AsyncCallback<number>):void
-Inserts a row of data into a table. This API uses a callback to return the result.
+Inserts a row of data into a table. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| name | string | Yes| Name of the target table.|
+| table | string | Yes| Name of the target table.|
| values | [ValuesBucket](#valuesbucket) | Yes| Row of data to insert.|
| callback | AsyncCallback<number> | Yes| Callback invoked to return the result. If the operation is successful, the row ID will be returned. Otherwise, **-1** will be returned.|
@@ -1090,14 +984,14 @@ rdbStore.insert("EMPLOYEE", valueBucket, function (err, ret) {
console.info("Failed to insert data, err: " + err)
return
}
- console.log("Insert first done: " + ret)
+ console.log("Inserted first row: " + ret)
})
```
### insert
-insert(name: string, values: ValuesBucket):Promise<number>
+insert(table: string, values: ValuesBucket):Promise<number>
Inserts a row of data into a table. This API uses a promise to return the result.
@@ -1106,7 +1000,7 @@ Inserts a row of data into a table. This API uses a promise to return the result
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| name | string | Yes| Name of the target table.|
+| table | string | Yes| Name of the target table.|
| values | [ValuesBucket](#valuesbucket) | Yes| Row of data to insert.|
**Return value**
@@ -1133,17 +1027,17 @@ promise.then(async (ret) => {
### update
-update(values: ValuesBucket, rdbPredicates: RdbPredicates, callback: AsyncCallback<number>):void
+update(values: ValuesBucket, predicates: RdbPredicates, callback: AsyncCallback<number>):void
-Updates data in the database based on the specified RdbPredicates object. This API uses a callback to return the result.
+Updates data in the database based on the specified RdbPredicates object. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| values | [ValuesBucket](#valuesbucket) | Yes| Data to update. The value specifies the row of data to be updated in the database. The key-value pair is associated with the column name in the target table.|
-| rdbPredicates | [RdbPredicates](#rdbpredicates) | Yes| Row of data to insert.|
+| values | [ValuesBucket](#valuesbucket) | Yes| Rows of data to be updated in the database. The key-value pair is associated with the column name in the target table.|
+| predicates | [RdbPredicates](#rdbpredicates) | Yes| Update conditions specified by the **RdbPredicates** object.|
| callback | AsyncCallback<number> | Yes| Callback used to return the number of rows updated.|
**Example**
@@ -1168,7 +1062,7 @@ rdbStore.update(valueBucket, predicates, function (err, ret) {
### update
-update(values: ValuesBucket, rdbPredicates: RdbPredicates):Promise<number>
+update(values: ValuesBucket, predicates: RdbPredicates):Promise<number>
Updates data in the database based on the specified RdbPredicates object. This API uses a promise to return the result.
@@ -1177,8 +1071,8 @@ Updates data in the database based on the specified RdbPredicates object. This A
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| values | [ValuesBucket](#valuesbucket) | Yes| Data to update. The value specifies the row of data to be updated in the database. The key-value pair is associated with the column name in the target table.|
-| rdbPredicates | [RdbPredicates](#rdbpredicates) | Yes| Row of data to insert.|
+| values | [ValuesBucket](#valuesbucket) | Yes| Rows of data to be updated in the database. The key-value pair is associated with the column name in the target table.|
+| predicates | [RdbPredicates](#rdbpredicates) | Yes| Update conditions specified by the **RdbPredicates** object.|
**Return value**
| Type| Description|
@@ -1203,20 +1097,92 @@ promise.then(async (ret) => {
})
```
+### update9+
+update(table: string, values: ValuesBucket, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback<number>):void
+
+Updates data in the database based on the specified **DataSharePredicates** object. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
+
+**Parameters**
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| table | string | Yes| Name of the target table.|
+| values | [ValuesBucket](#valuesbucket) | Yes| Rows of data to be updated in the database. The key-value pair is associated with the column name in the target table.|
+| predicates | [DataSharePredicates](js-apis-data-DataSharePredicates.md#datasharepredicates)| Yes| Update conditions specified by the **DataSharePredicates** object.|
+| callback | AsyncCallback<number> | Yes| Callback used to return the number of rows updated.|
+
+**Example**
+```js
+import dataSharePredicates from '@ohos.data.dataSharePredicates'
+const valueBucket = {
+ "NAME": "Rose",
+ "AGE": 22,
+ "SALARY": 200.5,
+ "CODES": new Uint8Array([1, 2, 3, 4, 5]),
+}
+let predicates = new dataSharePredicates.DataSharePredicates()
+predicates.equalTo("NAME", "Lisa")
+rdbStore.update("EMPLOYEE", valueBucket, predicates, function (err, ret) {
+ if (err) {
+ console.info("Failed to update data, err: " + err)
+ return
+ }
+ console.log("Updated row count: " + ret)
+})
+```
+### update9+
+
+update(table: string, values: ValuesBucket, predicates: DataSharePredicates):Promise<number>
+
+Updates data in the database based on the specified **DataSharePredicates** object. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
+
+**Parameters**
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| table | string | Yes| Name of the target table.|
+| values | [ValuesBucket](#valuesbucket) | Yes| Rows of data to be updated in the database. The key-value pair is associated with the column name in the target table.|
+| predicates | [DataSharePredicates](js-apis-data-DataSharePredicates.md#datasharepredicates) | Yes| Update conditions specified by the **DataSharePredicates** object.|
+
+**Return value**
+| Type| Description|
+| -------- | -------- |
+| Promise<number> | Promise used to return the number of rows updated.|
+
+**Example**
+```js
+import dataSharePredicates from '@ohos.data.dataSharePredicates'
+const valueBucket = {
+ "NAME": "Rose",
+ "AGE": 22,
+ "SALARY": 200.5,
+ "CODES": new Uint8Array([1, 2, 3, 4, 5]),
+}
+let predicates = new dataSharePredicates.DataSharePredicates()
+predicates.equalTo("NAME", "Lisa")
+let promise = rdbStore.update("EMPLOYEE", valueBucket, predicates)
+promise.then(async (ret) => {
+ console.log("Updated row count: " + ret)
+}).catch((err) => {
+ console.info("Failed to update data, err: " + err)
+})
+```
### delete
-delete(rdbPredicates: RdbPredicates, callback: AsyncCallback<number>):void
+delete(predicates: RdbPredicates, callback: AsyncCallback<number>):void
-Deletes data from the database based on the specified RdbPredicates object. This API uses a callback to return the result.
+Deletes data from the database based on the specified **RdbPredicates** object. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| rdbPredicates | [RdbPredicates](#rdbpredicates) | Yes| Conditions specified for deleting data.|
+| predicates | [RdbPredicates](#rdbpredicates) | Yes| Conditions specified by the **RdbPredicates** object for deleting data.|
| callback | AsyncCallback<number> | Yes| Callback invoked to return the number of rows updated.|
**Example**
@@ -1228,23 +1194,23 @@ rdbStore.delete(predicates, function (err, rows) {
console.info("Failed to delete data, err: " + err)
return
}
- console.log("Delete rows: " + rows)
+ console.log("Deleted rows: " + rows)
})
```
### delete
-delete(rdbPredicates: RdbPredicates):Promise<number>
+delete(predicates: RdbPredicates):Promise<number>
-Deletes data from the database based on the specified RdbPredicates object. This API uses a promise to return the result.
+Deletes data from the database based on the specified **RdbPredicates** object. This API uses a promise to return the result.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| rdbPredicates | [RdbPredicates](#rdbpredicates) | Yes| Conditions specified for deleting data.|
+| predicates | [RdbPredicates](#rdbpredicates) | Yes| Conditions specified by the **RdbPredicates** object for deleting data.|
**Return value**
| Type| Description|
@@ -1257,25 +1223,85 @@ let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.equalTo("NAME", "Lisa")
let promise = rdbStore.delete(predicates)
promise.then((rows) => {
- console.log("Delete rows: " + rows)
+ console.log("Deleted rows: " + rows)
}).catch((err) => {
console.info("Failed to delete data, err: " + err)
})
```
+### delete9+
+
+delete(table: string, predicates: DataSharePredicates, callback: AsyncCallback<number>):void
+
+
+Deletes data from the database based on the specified **DataSharePredicates** object. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
+
+**Parameters**
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| table | string | Yes| Name of the target table.|
+| predicates | [DataSharePredicates](js-apis-data-DataSharePredicates.md#datasharepredicates) | Yes| Conditions specified by the **DataSharePredicates** object for deleting data.|
+| callback | AsyncCallback<number> | Yes| Callback invoked to return the number of rows updated.|
+
+**Example**
+```js
+import dataSharePredicates from '@ohos.data.dataSharePredicates'
+let predicates = new dataSharePredicates.DataSharePredicates()
+predicates.equalTo("NAME", "Lisa")
+rdbStore.delete("EMPLOYEE", predicates, function (err, rows) {
+ if (err) {
+ console.info("Failed to delete data, err: " + err)
+ return
+ }
+ console.log("Deleted rows: " + rows)
+})
+```
+### delete9+
+
+delete(table: string, predicates: dataSharePredicates.DataSharePredicates):Promise<number>
+
+Deletes data from the database based on the specified **DataSharePredicates** object. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
+
+**Parameters**
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| table | string | Yes| Name of the target table.|
+| predicates | [DataSharePredicates](js-apis-data-DataSharePredicates.md#datasharepredicates) | Yes| Conditions specified by the **DataSharePredicates** object for deleting data.|
+
+**Return value**
+| Type| Description|
+| -------- | -------- |
+| Promise<number> | Promise used to return the number of rows updated.|
+
+**Example**
+```js
+import dataSharePredicates from '@ohos.data.dataSharePredicates'
+let predicates = new dataSharePredicates.DataSharePredicates()
+predicates.equalTo("NAME", "Lisa")
+let promise = rdbStore.delete("EMPLOYEE", predicates)
+promise.then((rows) => {
+ console.log("Deleted rows: " + rows)
+}).catch((err) => {
+ console.info("Failed to delete data, err: " + err)
+})
+```
### query
-query(rdbPredicates: RdbPredicates, columns: Array<string>, callback: AsyncCallback<ResultSet>):void
+query(predicates: RdbPredicates, columns: Array<string>, callback: AsyncCallback<ResultSet>):void
-Queries data in the database based on specified conditions. This API uses a callback to return the result.
+Queries data in the database based on specified conditions. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| rdbPredicates | [RdbPredicates](#rdbpredicates) | Yes| Query conditions specified by the **RdbPredicates** object.|
+| predicates | [RdbPredicates](#rdbpredicates) | Yes| Query conditions specified by the **RdbPredicates** object.|
| columns | Array<string> | Yes| Columns to query. If this parameter is not specified, the query applies to all columns.|
| callback | AsyncCallback<[ResultSet](js-apis-data-resultset.md)> | Yes| Callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned.|
@@ -1285,18 +1311,18 @@ let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.equalTo("NAME", "Rose")
rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"], function (err, resultSet) {
if (err) {
- console.info("Query failed, err: " + err)
+ console.info("Failed to query data, err: " + err)
return
}
- console.log("resultSet column names:" + resultSet.columnNames)
- console.log("resultSet column count:" + resultSet.columnCount)
+ console.log("ResultSet column names: " + resultSet.columnNames)
+ console.log("ResultSet column count: " + resultSet.columnCount)
})
```
### query
-query(rdbPredicates: RdbPredicates, columns?: Array<string>):Promise<ResultSet>
+query(predicates: RdbPredicates, columns?: Array<string>):Promise<ResultSet>
Queries data in the database based on specified conditions. This API uses a promise to return the result.
@@ -1305,7 +1331,7 @@ Queries data in the database based on specified conditions. This API uses a prom
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| rdbPredicates | [RdbPredicates](#rdbpredicates) | Yes| Query conditions specified by the **RdbPredicates** object.|
+| predicates | [RdbPredicates](#rdbpredicates) | Yes| Query conditions specified by the **RdbPredicates** object.|
| columns | Array<string> | No| Columns to query. If this parameter is not specified, the query applies to all columns.|
**Return value**
@@ -1319,19 +1345,81 @@ Queries data in the database based on specified conditions. This API uses a prom
predicates.equalTo("NAME", "Rose")
let promise = rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"])
promise.then((resultSet) => {
- console.log("resultSet column names:" + resultSet.columnNames)
- console.log("resultSet column count:" + resultSet.columnCount)
+ console.log("ResultSet column names: " + resultSet.columnNames)
+ console.log("ResultSet column count: " + resultSet.columnCount)
}).catch((err) => {
- console.info("Query failed, err: " + err)
+ console.info("Failed to query data, err: " + err)
})
```
+### query9+
+
+query(predicates: DataSharePredicates, columns: Array<string>, callback: AsyncCallback<ResultSet>):void
+
+Queries data in the database based on specified conditions. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
+
+**Parameters**
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| predicates | [DataSharePredicates](js-apis-data-DataSharePredicates.md#datasharepredicates) | Yes| Query conditions specified by the **DataSharePredicates** object.|
+| columns | Array<string> | Yes| Columns to query. If this parameter is not specified, the query applies to all columns.|
+| callback | AsyncCallback<[ResultSet](js-apis-data-resultset.md)> | Yes| Callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned.|
+
+**Example**
+```js
+import dataSharePredicates from '@ohos.data.dataSharePredicates'
+let predicates = new dataSharePredicates.DataSharePredicates()
+predicates.equalTo("NAME", "Rose")
+rdbStore.query("EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"], function (err, resultSet) {
+ if (err) {
+ console.info("Failed to query data, err: " + err)
+ return
+ }
+ console.log("ResultSet column names: " + resultSet.columnNames)
+ console.log("ResultSet column count: " + resultSet.columnCount)
+})
+```
+
+### query9+
+
+query(predicates: DataSharePredicates, columns?: Array<string>):Promise<ResultSet>
+
+Queries data in the database based on specified conditions. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
+
+**Parameters**
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| predicates | [DataSharePredicates](js-apis-data-DataSharePredicates.md#datasharepredicates) | Yes| Query conditions specified by the **DataSharePredicates** object.|
+| columns | Array<string> | No| Columns to query. If this parameter is not specified, the query applies to all columns.|
+
+**Return value**
+| Type| Description|
+| -------- | -------- |
+| Promise<[ResultSet](js-apis-data-resultset.md)> | Promise used to return the result. If the operation is successful, a **ResultSet** object will be returned.|
+
+**Example**
+```js
+import dataSharePredicates from '@ohos.data.dataSharePredicates'
+let predicates = new dataSharePredicates.DataSharePredicates()
+predicates.equalTo("NAME", "Rose")
+let promise = rdbStore.query("EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"])
+promise.then((resultSet) => {
+ console.log("ResultSet column names: " + resultSet.columnNames)
+ console.log("ResultSet column count: " + resultSet.columnCount)
+}).catch((err) => {
+ console.info("Failed to query data, err: " + err)
+})
+```
### querySql8+
querySql(sql: string, bindArgs: Array<ValueType>, callback: AsyncCallback<ResultSet>):void
-Queries data in the RDB store using the specified SQL statement. This API uses a callback to return the result.
+Queries data in the RDB store using the specified SQL statement. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
@@ -1346,11 +1434,11 @@ Queries data in the RDB store using the specified SQL statement. This API uses a
```js
rdbStore.querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = ?", ['sanguo'], function (err, resultSet) {
if (err) {
- console.info("Query failed, err: " + err)
+ console.info("Failed to query data, err: " + err)
return
}
- console.log("resultSet column names:" + resultSet.columnNames)
- console.log("resultSet column count:" + resultSet.columnCount)
+ console.log("ResultSet column names: " + resultSet.columnNames)
+ console.log("ResultSet column count: " + resultSet.columnCount)
})
```
@@ -1378,10 +1466,10 @@ Queries data in the RDB store using the specified SQL statement. This API uses a
```js
let promise = rdbStore.querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = ?", ['sanguo'])
promise.then((resultSet) => {
- console.log("resultSet column names:" + resultSet.columnNames)
- console.log("resultSet column count:" + resultSet.columnCount)
+ console.log("ResultSet column names: " + resultSet.columnNames)
+ console.log("ResultSet column count: " + resultSet.columnCount)
}).catch((err) => {
- console.info("Query failed, err: " + err)
+ console.info("Failed to query data, err: " + err)
})
```
@@ -1390,7 +1478,7 @@ promise.then((resultSet) => {
executeSql(sql: string, bindArgs: Array<ValueType>, callback: AsyncCallback<void>):void
-Runs the SQL statement that contains the specified parameters but does not return a value. This API uses a callback to return the execution result.
+Runs the SQL statement that contains the specified parameters but does not return a value. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
@@ -1406,10 +1494,10 @@ Runs the SQL statement that contains the specified parameters but does not retur
const SQL_CREATE_TABLE = "CREATE TABLE IF NOT EXISTS EMPLOYEE (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL, AGE INTEGER, SALARY REAL, CODES BLOB)"
rdbStore.executeSql(SQL_CREATE_TABLE, null, function(err) {
if (err) {
- console.info("executeSql failed, err: " + err)
+ console.info("Failed to execute SQL, err: " + err)
return
}
- console.info('create table done.')
+ console.info('Create table done.')
})
```
@@ -1438,9 +1526,9 @@ Runs the SQL statement that contains the specified parameters but does not retur
const SQL_CREATE_TABLE = "CREATE TABLE IF NOT EXISTS EMPLOYEE (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL, AGE INTEGER, SALARY REAL, CODES BLOB)"
let promise = rdbStore.executeSql(SQL_CREATE_TABLE)
promise.then(() => {
- console.info('create table done.')
+ console.info('Create table done.')
}).catch((err) => {
- console.info("ExecuteSql failed, err: " + err)
+ console.info("Failed to execute SQL, err: " + err)
})
```
@@ -1533,12 +1621,119 @@ try {
}
```
+### backup9+
+
+backup(destName:string, callback: AsyncCallback<void>):void
+
+Backs up the database with the specified name. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
+
+**Parameters**
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| destName | string | Yes| Name of the database backup file.|
+| callback | AsyncCallback<void> | Yes| Callback invoked to return the result.|
+
+**Example**
+```js
+rdbStore.backup("dbBackup.db", function(err) {
+ if (err) {
+ console.info('Failed to back up data, err: ' + err)
+ return
+ }
+ console.info('Backup successful.')
+})
+```
+
+### backup9+
+
+backup(destName:string): Promise<void>
+
+Backs up the database with the specified name. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
+
+**Parameters**
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| destName | string | Yes| Name of the database backup file.|
+
+**Return value**
+| Type| Description|
+| -------- | -------- |
+| Promise<void> | Promise used to return the result.|
+
+**Example**
+```js
+let promiseBackup = rdbStore.backup("dbBackup.db")
+promiseBackup.then(()=>{
+ console.info('Backup successful.')
+}).catch((err)=>{
+ console.info('Failed to back up data, err: ' + err)
+})
+```
+
+### restore9+
+
+restore(srcName:string, callback: AsyncCallback<void>):void
+
+Restores a database from a specified database backup file. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
+
+**Parameters**
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| srcName | string | Yes| Name of the database backup file.|
+| callback | AsyncCallback<void> | Yes| Callback invoked to return the result.|
+
+**Example**
+```js
+rdbStore.restore("dbBackup.db", function(err) {
+ if (err) {
+ console.info('Failed to restore data, err: ' + err)
+ return
+ }
+ console.info('Restore successful.')
+})
+```
+
+### restore9+
+
+restore(srcName:string): Promise<void>
+
+Restores a database from a specified database backup file. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
+
+**Parameters**
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| srcName | string | Yes| Name of the database backup file.|
+
+**Return value**
+| Type| Description|
+| -------- | -------- |
+| Promise<void> | Promise used to return the result.|
+
+**Example**
+```js
+let promiseRestore = rdbStore.restore("dbBackup.db")
+promiseRestore.then(()=>{
+ console.info('Restore successful.')
+}).catch((err)=>{
+ console.info('Failed to restore data, err: ' + err)
+})
+```
### setDistributedTables8+
setDistributedTables(tables: Array<string>, callback: AsyncCallback<void>): void
-Sets a list of distributed tables. This API uses a callback to return the result.
+Sets a list of distributed tables. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
@@ -1552,10 +1747,10 @@ Sets a list of distributed tables. This API uses a callback to return the result
```js
rdbStore.setDistributedTables(["EMPLOYEE"], function (err) {
if (err) {
- console.info('setDistributedTables failed, err: ' + err)
+ console.info('Failed to set distributed tables, err: ' + err)
return
}
- console.info('setDistributedTables successful.')
+ console.info('Set distributed tables successfully.')
})
```
@@ -1566,6 +1761,8 @@ rdbStore.setDistributedTables(["EMPLOYEE"], function (err) {
Sets a list of distributed tables. This API uses a promise to return the result.
+**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
+
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters**
@@ -1582,9 +1779,9 @@ Sets a list of distributed tables. This API uses a promise to return the result.
```js
let promise = rdbStore.setDistributedTables(["EMPLOYEE"])
promise.then(() => {
- console.info("setDistributedTables successful.")
+ console.info("Set distributed tables successfully.")
}).catch((err) => {
- console.info("setDistributedTables failed, err: " + err)
+ console.info("Failed to set distributed tables, err: " + err)
})
```
@@ -1592,7 +1789,9 @@ promise.then(() => {
obtainDistributedTableName(device: string, table: string, callback: AsyncCallback<string>): void
-Obtains the distributed table name for a remote device based on the local table name. The distributed table name is required when the database of a remote device is queried. This API uses a callback to return the result.
+Obtains the distributed table name for a remote device based on the local table name. The distributed table name is required when the database of a remote device is queried. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
@@ -1605,12 +1804,12 @@ Obtains the distributed table name for a remote device based on the local table
**Example**
```js
-rdbStore.obtainDistributedTableName(deviceId, "EMPLOYEE", function (err, tableName) {
+rdbStore.obtainDistributedTableName("12345678abcde", "EMPLOYEE", function (err, tableName) {
if (err) {
- console.info('obtainDistributedTableName failed, err: ' + err)
+ console.info('Failed to obtain DistributedTableName, err: ' + err)
return
}
- console.info('obtainDistributedTableName successful, tableName=.' + tableName)
+ console.info('Obtained DistributedTableName successfully, tableName=.' + tableName)
})
```
@@ -1621,6 +1820,8 @@ rdbStore.obtainDistributedTableName(deviceId, "EMPLOYEE", function (err, tableNa
Obtains the distributed table name for a remote device based on the local table name. The distributed table name is required when the database of a remote device is queried. This API uses a promise to return the result.
+**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
+
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters**
@@ -1636,11 +1837,11 @@ Obtains the distributed table name for a remote device based on the local table
**Example**
```js
-let promise = rdbStore.obtainDistributedTableName(deviceId, "EMPLOYEE")
+let promise = rdbStore.obtainDistributedTableName("12345678abcde", "EMPLOYEE")
promise.then((tableName) => {
- console.info('obtainDistributedTableName successful, tableName=' + tableName)
+ console.info('Obtained DistributedTableName successfully, tableName= ' + tableName)
}).catch((err) => {
- console.info('obtainDistributedTableName failed, err: ' + err)
+ console.info('Failed to obtain DistributedTableName, err: ' + err)
})
```
@@ -1648,7 +1849,9 @@ promise.then((tableName) => {
sync(mode: SyncMode, predicates: RdbPredicates, callback: AsyncCallback<Array<[string, number]>>): void
-Synchronizes data between devices. This API uses a callback to return the result.
+Synchronizes data between devices. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
@@ -1661,14 +1864,14 @@ Synchronizes data between devices. This API uses a callback to return the result
**Example**
```js
-let predicates = new rdb.RdbPredicates('EMPLOYEE')
+let predicates = new data_rdb.RdbPredicates('EMPLOYEE')
predicates.inDevices(['12345678abcde'])
-rdbStore.sync(rdb.SyncMode.SYNC_MODE_PUSH, predicates, function (err, result) {
+rdbStore.sync(data_rdb.SyncMode.SYNC_MODE_PUSH, predicates, function (err, result) {
if (err) {
- console.log('sync failed, err: ' + err)
+ console.log('Sync failed, err: ' + err)
return
}
- console.log('sync done.')
+ console.log('Sync done.')
for (let i = 0; i < result.length; i++) {
console.log('device=' + result[i][0] + ' status=' + result[i][1])
}
@@ -1682,6 +1885,8 @@ rdbStore.sync(rdb.SyncMode.SYNC_MODE_PUSH, predicates, function (err, result) {
Synchronizes data between devices. This API uses a promise to return the result.
+**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
+
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters**
@@ -1702,12 +1907,12 @@ let predicates = new data_rdb.RdbPredicates('EMPLOYEE')
predicates.inDevices(['12345678abcde'])
let promise = rdbStore.sync(data_rdb.SyncMode.SYNC_MODE_PUSH, predicates)
promise.then((result) =>{
- console.log('sync done.')
+ console.log('Sync done.')
for (let i = 0; i < result.length; i++) {
console.log('device=' + result[i][0] + ' status=' + result[i][1])
}
}).catch((err) => {
- console.log('sync failed')
+ console.log('Sync failed')
})
```
@@ -1717,6 +1922,8 @@ on(event: 'dataChange', type: SubscribeType, observer: Callback<Array<stri
Registers an observer for this RDB store. When the data in the RDB store changes, a callback is invoked to return the data changes.
+**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
+
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters**
@@ -1747,6 +1954,8 @@ off(event:'dataChange', type: SubscribeType, observer: Callback<Array<stri
Deletes the specified observer of the RDB store. This API uses a callback to return the result.
+**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
+
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
**Parameters**
@@ -1821,6 +2030,8 @@ Defines the database synchronization mode.
Defines the subscription type.
+**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
+
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
| Name | Default Value| Description|
diff --git a/en/application-dev/reference/apis/js-apis-data-storage.md b/en/application-dev/reference/apis/js-apis-data-storage.md
index 63ae9d95bc7da1a827030de4e644d44d68c7235c..6cdfcf94fdf36dd3f9d4adb4e44420394120fd10 100644
--- a/en/application-dev/reference/apis/js-apis-data-storage.md
+++ b/en/application-dev/reference/apis/js-apis-data-storage.md
@@ -22,15 +22,15 @@ import dataStorage from '@ohos.data.storage';
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| MAX_KEY_LENGTH | string | Yes| No| Maximum length of a key. It is 80 bytes.|
-| MAX_VALUE_LENGTH | string | Yes| No| Maximum length of a value. It is 8192 bytes.|
+| MAX_KEY_LENGTH | string | Yes| No| Maximum length of a key. It must be less than 80 bytes.|
+| MAX_VALUE_LENGTH | string | Yes| No| Maximum length of a value. It must be less than 8192 bytes.|
## dataStorage.getStorageSync
getStorageSync(path: string): Storage
-Reads the specified file and load its data to the **Storage** instance for data operations.
+Reads the specified file and loads its data to the **Storage** instance for data operations.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
diff --git a/en/application-dev/reference/apis/js-apis-dataAbilityHelper.md b/en/application-dev/reference/apis/js-apis-dataAbilityHelper.md
index 1ce0a05d1ef3c97b9c0dd6d53c6abf22c2ec670c..df69b38be754f255ce637249c18a9d2fca5e13fd 100644
--- a/en/application-dev/reference/apis/js-apis-dataAbilityHelper.md
+++ b/en/application-dev/reference/apis/js-apis-dataAbilityHelper.md
@@ -1,7 +1,9 @@
-# DataAbilityHelper Module (JavaScript SDK APIs)
+# DataAbilityHelper
-> **NOTE**
-> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+> **NOTE**
+>
+> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+> The APIs of this module can be used only in the FA model.
## Modules to Import
@@ -571,7 +573,7 @@ Inserts multiple data records into the database. This API uses an asynchronous c
| Name | Type | Mandatory| Description |
| ------------ | ----------------------- | ---- | -------------------------------- |
| uri | string | Yes | URI of the data to insert. |
-| valuesBucket | Array | Yes | Data records to insert. |
+| valuesBucket | Array\ | Yes | Data records to insert. |
| callback | AsyncCallback\ | Yes | Callback used to return the number of inserted data records.|
**Example**
@@ -870,7 +872,7 @@ DAHelper.query(
## DataAbilityHelper.call
-call(uri: string, method: string, arg: string, extras: PacMap): Promise
+call(uri: string, method: string, arg: string, extras: PacMap): Promise\
Calls the extended API of the Data ability. This API uses a promise to return the result.
@@ -889,7 +891,7 @@ Calls the extended API of the Data ability. This API uses a promise to return th
| Type| Description|
|------ | ------- |
-|Promise<[PacMap](#pacmap)> | Promise used to return the result.|
+|Promise\<[PacMap](#pacmap)> | Promise used to return the result.|
**Example**
@@ -906,7 +908,7 @@ dataAbilityHelper.call("dataability:///com.example.jsapidemo.UserDataAbility", "
## DataAbilityHelper.call
-call(uri: string, method: string, arg: string, extras: PacMap, callback: AsyncCallback): void
+call(uri: string, method: string, arg: string, extras: PacMap, callback: AsyncCallback\): void
Calls the extended API of the Data ability. This API uses an asynchronous callback to return the result.
@@ -920,7 +922,7 @@ Calls the extended API of the Data ability. This API uses an asynchronous callba
| method | string | Yes | Name of the API to call. |
| arg | string | Yes |Parameter to pass. |
| extras | [PacMap](#pacmap) | Yes | Key-value pair parameter. |
-| callback | AsyncCallback<[PacMap](#pacmap)> | Yes| Callback used to return the result. |
+| callback | AsyncCallback\<[PacMap](#pacmap)> | Yes| Callback used to return the result. |
**Example**
diff --git a/en/application-dev/reference/apis/js-apis-deque.md b/en/application-dev/reference/apis/js-apis-deque.md
index b16ecfe75ea6ea083c5ff3bed796ebada1e06c58..8d9a9c1b42bef6ce74fdfb21a8033b80e68c1868 100644
--- a/en/application-dev/reference/apis/js-apis-deque.md
+++ b/en/application-dev/reference/apis/js-apis-deque.md
@@ -1,26 +1,32 @@
# Linear Container Deque
->  **NOTE**
+> **NOTE**
+>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+Double-ended queue (deque) is a sequence container implemented based on the queue data structure that follows the principles of First In First Out (FIFO) and Last In First Out (LIFO). It allows insertion and removal of elements at both the ends. **Deque** can dynamically adjust the capacity based on project requirements. It doubles the capacity each time. **Deque** differs from **[Queue](js-apis-queue.md)** and **[Vector](js-apis-vector.md)** mainly in the following aspects:
+
+**Queue** follows the principle of FIFO only and allows element removal at the front and insertion at the rear.
+
+**Vector** supports insertion and deletion of elements in between, as well asat both the ends. When compared with **Vector**, **Deque** is more efficient in inserting and removing header elements, but less efficient in accessing elements.
+
+**Recommended use case**: Use **Deque** when you need to frequently insert or remove elements at both the ends of a container.
## Modules to Import
```ts
-import Deque from '@ohos.util.Deque'
+import Deque from '@ohos.util.Deque';
```
-## System Capabilities
-
-SystemCapability.Utils.Lang
-
## Deque
### Attributes
+**System capability**: SystemCapability.Utils.Lang
+
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| length | number | Yes| No| Number of entries in a double-ended queue (deque, called container later).|
+| length | number | Yes| No| Number of elements in a deque (called container later).|
### constructor
@@ -28,6 +34,8 @@ constructor()
A constructor used to create a **Deque** instance.
+**System capability**: SystemCapability.Utils.Lang
+
**Example**
```ts
@@ -38,13 +46,15 @@ let deque = new Deque();
insertFront(element: T): void
-Inserts an entry at the front of this container.
+Inserts an element at the front of this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| element | T | Yes| Entry to insert.|
+| element | T | Yes| Target element.|
**Example**
@@ -62,13 +72,15 @@ deque.insertFront(false);
insertEnd(element: T): void
-Inserts an entry at the end of this container.
+Inserts an element at the end of this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| element | T | Yes| Entry to insert.|
+| element | T | Yes| Target element.|
**Example**
@@ -86,19 +98,21 @@ deque.insertEnd(false);
has(element: T): boolean
-Checks whether this container has the specified entry.
+Checks whether this container has the specified element.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| element | T | Yes| Entry to check.|
+| element | T | Yes| Target element.|
**Return value**
| Type| Description|
| -------- | -------- |
-| boolean | Returns **true** if the specified entry is contained; returns **false** otherwise.|
+| boolean | Returns **true** if the specified element is contained; returns **false** otherwise.|
**Example**
@@ -113,13 +127,15 @@ let result1 = deque.has("Ahfbrgrbgnutfodgorrogorg");
popFirst(): T
-Removes the first entry of this container.
+Removes the first element of this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Return value**
| Type| Description|
| -------- | -------- |
-| T | Entry removed.|
+| T | Element removed.|
**Example**
@@ -137,13 +153,15 @@ let result = deque.popFirst();
popLast(): T
-Removes the last entry of this container.
+Removes the last element of this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Return value**
| Type| Description|
| -------- | -------- |
-| T | Entry removed.|
+| T | Element removed.|
**Example**
@@ -162,13 +180,15 @@ let result = deque.popLast();
forEach(callbackfn: (value: T, index?: number, deque?: Deque<T>) => void,
thisArg?: Object): void
-Uses a callback to traverse the entries in this container and obtain their position indexes.
+Uses a callback to traverse the elements in this container and obtain their position indexes.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| callbackfn | function | Yes| Callback invoked to traverse the entries in the container.|
+| callbackfn | function | Yes| Callback invoked to traverse the elements in the container.|
| thisArg | Object | No| Value to use when the callback is invoked.|
callbackfn
@@ -176,7 +196,7 @@ callbackfn
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | T | Yes| Value of the element that is currently traversed.|
-| index | number | No| Position index of the entry that is currently traversed.|
+| index | number | No| Position index of the element that is currently traversed.|
| deque | Deque<T> | No| Instance that invokes the **forEach** method.|
**Example**
@@ -188,7 +208,7 @@ deque.insertEnd(4);
deque.insertFront(5);
deque.insertEnd(4);
deque.forEach((value, index) => {
- console.log(value, index);
+ console.log("value:" + value, index);
});
```
@@ -196,13 +216,15 @@ deque.forEach((value, index) => {
getFirst(): T
-Obtains the first entry of this container.
+Obtains the first element of this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Return value**
| Type| Description|
| -------- | -------- |
-| T | Entry obtained.|
+| T | Element obtained.|
**Example**
@@ -219,13 +241,15 @@ let result = deque.getFirst();
getLast(): T
-Obtains the last entry of this container.
+Obtains the last element of this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Return value**
| Type| Description|
| -------- | -------- |
-| T | Entry obtained.|
+| T | Element obtained.|
**Example**
@@ -242,9 +266,10 @@ let result = deque.getLast();
[Symbol.iterator]\(): IterableIterator<T>
-
Obtains an iterator, each item of which is a JavaScript object.
+**System capability**: SystemCapability.Utils.Lang
+
**Return value**
| Type| Description|
@@ -261,14 +286,14 @@ deque.insertFront(4);
// Method 1:
for (let item of deque) {
- console.log(item);
+ console.log("value:" + item);
}
// Method 2:
let iter = deque[Symbol.iterator]();
let temp = iter.next().value;
while(temp != undefined) {
- console.log(temp);
+ console.log("value:" + temp);
temp = iter.next().value;
}
```
diff --git a/en/application-dev/reference/apis/js-apis-device-info.md b/en/application-dev/reference/apis/js-apis-device-info.md
index 0f5dd2a794e92690820f12d6ab8e82e9f6b3b340..c23ee9f6eaccd02c06f9723a6544c61b2d821acb 100644
--- a/en/application-dev/reference/apis/js-apis-device-info.md
+++ b/en/application-dev/reference/apis/js-apis-device-info.md
@@ -1,6 +1,6 @@
# Device Information
->  **NOTE**
+> **NOTE**
> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
@@ -24,7 +24,7 @@ import deviceInfo from '@ohos.deviceInfo'
| softwareModel | string | Yes| No| Software model.|
| hardwareModel | string | Yes| No| Hardware model.|
| hardwareProfile | string | Yes| No| Hardware profile.|
-| serial | string | Yes| No| Device serial number.|
+| serial | string | Yes| No| Device serial number. **Required permissions**: ohos.permission.sec.ACCESS_UDID (a system permission)|
| bootloaderVersion | string | Yes| No| Bootloader version.|
| abiList | string | Yes| No| Application binary interface (Abi) list.|
| securityPatchTag | string | Yes| No| Security patch tag.|
@@ -44,4 +44,4 @@ import deviceInfo from '@ohos.deviceInfo'
| buildHost | string | Yes| No| Build host.|
| buildTime | string | Yes| No| Build time.|
| buildRootHash | string | Yes| No| Build root hash.|
-| udid7+ | string | Yes| No| Device UDID.|
+| udid7+ | string | Yes| No| Device UDID. **Required permissions**: ohos.permission.sec.ACCESS_UDID (a system permission)|
diff --git a/en/application-dev/reference/apis/js-apis-deviceUsageStatistics.md b/en/application-dev/reference/apis/js-apis-deviceUsageStatistics.md
index 11739fc75ed2e39a24f55c50a46a02bab94cd7d5..2ae6d7b5a18696850e13d8d088f9a1300561742c 100644
--- a/en/application-dev/reference/apis/js-apis-deviceUsageStatistics.md
+++ b/en/application-dev/reference/apis/js-apis-deviceUsageStatistics.md
@@ -1,7 +1,7 @@
# Device Usage Statistics
->  **NOTE** The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
->
+> **NOTE**
+> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
@@ -14,16 +14,16 @@ import bundleState from '@ohos.bundleState'
isIdleState(bundleName: string, callback: AsyncCallback<boolean>): void
-Checks whether the application specified by **bundleName** is in the idle state. This API uses an asynchronous callback to return the result.
+Checks whether the application specified by **bundleName** is in the idle state. This API uses an asynchronous callback to return the result. A third-party application can only check the idle status of itself.
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| bundleName | string | Yes| Bundle name of an application.|
-| callback | AsyncCallback<boolean> | Yes| Callback used to return the result. Returns whether the application specified by **bundleName** is in the idle state if the value of **bundleName** is valid; returns **null** otherwise.|
+| Name | Type | Mandatory | Description |
+| ---------- | ---------------------------- | ---- | ---------------------------------------- |
+| bundleName | string | Yes | Bundle name of an application. |
+| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. If the value of **bundleName** is valid, **null** will be returned.|
**Example**
@@ -41,21 +41,21 @@ Checks whether the application specified by **bundleName** is in the idle state.
isIdleState(bundleName: string): Promise<boolean>
-Checks whether the application specified by **bundleName** is in the idle state. This API uses a promise to return the result.
+Checks whether the application specified by **bundleName** is in the idle state. This API uses a promise to return the result. A third-party application can only check the idle status of itself.
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| bundleName | string | Yes| Bundle name of an application.|
+| Name | Type | Mandatory | Description |
+| ---------- | ------ | ---- | -------------- |
+| bundleName | string | Yes | Bundle name of an application.|
**Return value**
-| Type| Description|
-| -------- | -------- |
-| Promise<boolean> | Promise used to return the result. Returns whether the application specified by **bundleName** is in the idle state if the value of **bundleName** is valid; returns **null** otherwise.|
+| Type | Description |
+| ---------------------- | ---------------------------------------- |
+| Promise<boolean> | Promise used to return the result. If the value of **bundleName** is valid, **null** will be returned.|
**Example**
@@ -69,53 +69,62 @@ Checks whether the application specified by **bundleName** is in the idle state.
## bundleState.queryAppUsagePriorityGroup
-queryAppUsagePriorityGroup(callback: AsyncCallback<number>): void
+queryAppUsagePriorityGroup(): Promise\
-Queries the priority group of the current invoker application. This API uses an asynchronous callback to return the result.
+Queries the priority group of this application. This API uses a promise to return the result.
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
-**Parameters**
+**Return value**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| callback | AsyncCallback<number> | Yes| Callback used to return the result.|
+| Type | Description |
+| --------------- | --------------------------- |
+| Promise\ | Promise used to return the result.|
**Example**
- ```js
- bundleState.queryAppUsagePriorityGroup((err, res) => {
- if (err) {
- console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup callback failed. because: ' + err.code);
- } else {
- console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup callback succeeded. result: ' + JSON.stringify(res));
- }
- });
- ```
+```javascript
+bundleState.queryAppUsagePriorityGroup().then( res => {
+ console.log('BUNDLE_ACTIVE QueryPackageGroup promise succeeded. result: ' + JSON.stringify(res));
+}).catch( err => {
+ console.log('BUNDLE_ACTIVE QueryPackageGroup promise failed. because: ' + err.code);
+});
+```
## bundleState.queryAppUsagePriorityGroup
-queryAppUsagePriorityGroup(): Promise<number>
+queryAppUsagePriorityGroup(callback: AsyncCallback\): void
-Queries the priority group of the current invoker application. This API uses a promise to return the result.
+Queries the priority group of this application. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
-**Return value**
+**Parameters**
-| Type| Description|
-| -------- | -------- |
-| Promise<number> | Promise used to return the result.|
+| Name | Type | Mandatory | Description |
+| -------- | --------------------- | ---- | -------------------------- |
+| callback | AsyncCallback\ | Yes | Callback used to return the result.|
**Example**
- ```js
- bundleState.queryAppUsagePriorityGroup().then( res => {
- console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup promise succeeded. result: ' + JSON.stringify(res));
- }).catch( err => {
- console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup promise failed. because: ' + err.code);
- });
- ```
+```javascript
+// Callback with bundleName
+bundleState.queryAppUsagePriorityGroup(this.bundleName, (err, res) => {
+ if(err) {
+ console.log('BUNDLE_ACTIVE QueryPackageGroup callback failed. because: ' + err.code);
+ } else {
+ console.log('BUNDLE_ACTIVE QueryPackageGroup callback succeeded. result: ' + JSON.stringify(res));
+ }
+});
+// Callback without bundleName
+bundleState.queryAppUsagePriorityGroup((err, res) => {
+ if(err) {
+ console.log('BUNDLE_ACTIVE QueryPackageGroup callback failed. because: ' + err.code);
+ } else {
+ console.log('BUNDLE_ACTIVE QueryPackageGroup callback succeeded. result: ' + JSON.stringify(res));
+ }
+});
+```
## bundleState.queryBundleStateInfos
@@ -127,13 +136,15 @@ Queries the application usage duration statistics based on the specified start t
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| begin | number | Yes| Start time.|
-| end | number | Yes| End time.|
-| callback | AsyncCallback<[BundleActiveInfoResponse](#bundleactiveinforesponse)> | Yes| Callback used to return the result.|
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | --------------------------------------- |
+| begin | number | Yes | Start time. |
+| end | number | Yes | End time. |
+| callback | AsyncCallback<[BundleActiveInfoResponse](#bundleactiveinforesponse)> | Yes | Callback used to return the result.|
**Example**
@@ -163,17 +174,19 @@ Queries the application usage duration statistics based on the specified start t
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| begin | number | Yes| Start time.|
-| end | number | Yes| End time.|
+| Name | Type | Mandatory | Description |
+| ----- | ------ | ---- | ----- |
+| begin | number | Yes | Start time.|
+| end | number | Yes | End time.|
**Return value**
-| Type| Description|
-| -------- | -------- |
+| Type | Description |
+| ---------------------------------------- | -------------------------------------- |
| Promise<[BundleActiveInfoResponse](#bundleactiveinforesponse)> | Promise used to return the result.|
**Example**
@@ -202,14 +215,16 @@ Queries the application usage duration statistics in the specified time frame at
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| byInterval | [IntervalType](#intervaltype) | Yes| Interval type.|
-| begin | number | Yes| Start time.|
-| end | number | Yes| End time.|
-| callback | AsyncCallback<Array<[BundleStateInfo](#bundlestateinfo)>> | Yes| Callback used to return the result.|
+| Name | Type | Mandatory | Description |
+| ---------- | ---------------------------------------- | ---- | ---------------------------------------- |
+| byInterval | [IntervalType](#intervaltype) | Yes | Type of information to be queried. |
+| begin | number | Yes | Start time. |
+| end | number | Yes | End time. |
+| callback | AsyncCallback<Array<[BundleStateInfo](#bundlestateinfo)>> | Yes | Callback used to return the result.|
**Example**
@@ -237,18 +252,20 @@ Queries the application usage duration statistics in the specified time frame at
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| byInterval | [IntervalType](#intervaltype) | Yes| Interval type.|
-| begin | number | Yes| Start time.|
-| end | number | Yes| End time.|
+| Name | Type | Mandatory | Description |
+| ---------- | ----------------------------- | ---- | ----- |
+| byInterval | [IntervalType](#intervaltype) | Yes | Type of information to be queried.|
+| begin | number | Yes | Start time.|
+| end | number | Yes | End time.|
**Return value**
-| Type| Description|
-| -------- | -------- |
+| Type | Description |
+| ---------------------------------------- | ---------------------------------------- |
| Promise<Array<[BundleStateInfo](#bundlestateinfo)>> | Promise used to return the result.|
**Example**
@@ -275,13 +292,15 @@ Queries events of all applications based on the specified start time and end tim
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| begin | number | Yes| Start time.|
-| end | number | Yes| End time.|
-| callback | AsyncCallback<Array<[BundleActiveState](#bundleactivestate)>> | Yes| Callback used to return the result.|
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | --------------------------------------- |
+| begin | number | Yes | Start time. |
+| end | number | Yes | End time. |
+| callback | AsyncCallback<Array<[BundleActiveState](#bundleactivestate)>> | Yes | Callback used to return the result.|
**Example**
@@ -309,17 +328,19 @@ Queries events of all applications based on the specified start time and end tim
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| begin | number | Yes| Start time.|
-| end | number | Yes| End time.|
+| Name | Type | Mandatory | Description |
+| ----- | ------ | ---- | ----- |
+| begin | number | Yes | Start time.|
+| end | number | Yes | End time.|
**Return value**
-| Type| Description|
-| -------- | -------- |
+| Type | Description |
+| ---------------------------------------- | -------------------------------------- |
| Promise<Array<[BundleActiveState](#bundleactivestate)>> | Promise used to return the result.|
**Example**
@@ -346,11 +367,11 @@ Queries events of this application based on the specified start time and end tim
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| begin | number | Yes| Start time.|
-| end | number | Yes| End time.|
-| callback | AsyncCallback<Array<[BundleActiveState](#bundleactivestate)>> | Yes| Callback used to return the result.|
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | --------------------------------------- |
+| begin | number | Yes | Start time. |
+| end | number | Yes | End time. |
+| callback | AsyncCallback<Array<[BundleActiveState](#bundleactivestate)>> | Yes | Callback used to return the result.|
**Example**
@@ -378,15 +399,15 @@ Queries events of this application based on the specified start time and end tim
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| begin | number | Yes| Start time.|
-| end | number | Yes| End time.|
+| Name | Type | Mandatory | Description |
+| ----- | ------ | ---- | ----- |
+| begin | number | Yes | Start time.|
+| end | number | Yes | End time.|
**Return value**
-| Type| Description|
-| -------- | -------- |
+| Type | Description |
+| ---------------------------------------- | -------------------------------------- |
| Promise<Array<[BundleActiveState](#bundleactivestate)>> | Promise used to return the result.|
**Example**
@@ -413,22 +434,24 @@ Obtains the number of FA usage records specified by **maxNum**. This API uses a
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| maxNum | number | No| Maximum number of returned records. The maximum and default value is **1000**. If this parameter is not specified, **1000** is used.|
+| Name | Type | Mandatory | Description |
+| ------ | ------ | ---- | ---------------------------------- |
+| maxNum | number | No | Maximum number of returned records. The maximum and default value is **1000**. If this parameter is not specified, **1000** is used.|
**Return value**
-| Type| Description|
-| -------- | -------- |
+| Type | Description |
+| ---------------------------------------- | ---------------------------------- |
| Promise<Array<[BundleActiveModuleInfo](#bundleactivemoduleinfo9)>> | Promise used to return the result.|
**Example**
```js
- bundleState.getRecentlyUsedModules(this.maxNum).then( res => {
+ bundleState.getRecentlyUsedModules(1000).then( res => {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise succeeded');
for (let i = 0; i < res.length; i++) {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise number : ' + (i + 1));
@@ -460,17 +483,19 @@ Obtains the number of FA usage records specified by **maxNum**. This API uses an
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| maxNum | number | No| Maximum number of returned records. The maximum and default value is **1000**. If this parameter is not specified, **1000** is used.|
-| callback | AsyncCallback<Array<[BundleActiveModuleInfo](#bundleactivemoduleinfo9)>> | Yes| Callback used to return the result.|
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | ----------------------------------- |
+| maxNum | number | No | Maximum number of returned records. The maximum and default value is **1000**. If this parameter is not specified, **1000** is used. |
+| callback | AsyncCallback<Array<[BundleActiveModuleInfo](#bundleactivemoduleinfo9)>> | Yes | Callback used to return the result.|
**Example**
```js
- bundleState.getRecentlyUsedModules(this.maxNum,(err, res) => {
+ bundleState.getRecentlyUsedModules(1000,(err, res) => {
if(err) {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules callback failed, because: ' + err.code);
} else {
@@ -483,7 +508,7 @@ Obtains the number of FA usage records specified by **maxNum**. This API uses an
});
// Invocation when maxNum is not passed
- stats.getRecentlyUsedModules((err, res) => {
+ bundleState.getRecentlyUsedModules((err, res) => {
if(err) {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules callback failed, because: ' + err.code);
} else {
@@ -496,59 +521,507 @@ Obtains the number of FA usage records specified by **maxNum**. This API uses an
});
```
+## bundleState.queryAppUsagePriorityGroup9+
+
+queryAppUsagePriorityGroup(bundleName? : string): Promise
+
+Queries the priority group of the application specified by **bundleName**. If **bundleName** is not specified, the priority group of the current application is queried. This API uses a promise to return the result.
+
+**Required permissions**: ohos.permission.BUNDLE_ACTIVE_INFO
+
+**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ---------- | ------ | ---- | ---------------------------------------- |
+| bundleName | string | No | Bundle name of the target application. If this parameter is not specified, the priority group of the current application is queried.|
+
+**Return value**
+
+| Type | Description |
+| --------------- | --------------------------- |
+| Promise\ | Promise used to return the result.|
+
+**Example**
+
+```javascript
+// Promise with bundleName
+bundleState.queryAppUsagePriorityGroup(this.bundleName).then( res => {
+ console.log('BUNDLE_ACTIVE QueryPackageGroup promise succeeded. result: ' + JSON.stringify(res));
+}).catch( err => {
+ console.log('BUNDLE_ACTIVE QueryPackageGroup promise failed. because: ' + err.code);
+});
+// Promise without bundleName
+bundleState.queryAppUsagePriorityGroup().then( res => {
+ console.log('BUNDLE_ACTIVE QueryPackageGroup promise succeeded. result: ' + JSON.stringify(res));
+}).catch( err => {
+ console.log('BUNDLE_ACTIVE QueryPackageGroup promise failed. because: ' + err.code);
+});
+```
+
+## bundleState.queryAppUsagePriorityGroup9+
+
+queryAppUsagePriorityGroup(bundleName? : string, callback: AsyncCallback\): void
+
+Queries the priority group of the application specified by **bundleName**. If **bundleName** is not specified, the priority group of the current application is queried. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.BUNDLE_ACTIVE_INFO
+
+**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ---------- | --------------------- | ---- | ---------------------------------------- |
+| bundleName | string | No | Bundle name of the target application. If this parameter is not specified, the priority group of the current application is queried.|
+| callback | AsyncCallback\ | Yes | Callback used to return the result. |
+
+**Example**
+
+```javascript
+// Callback with bundleName
+bundleState.queryAppUsagePriorityGroup(this.bundleName, (err, res) => {
+ if(err) {
+ console.log('BUNDLE_ACTIVE QueryPackageGroup callback failed. because: ' + err.code);
+ } else {
+ console.log('BUNDLE_ACTIVE QueryPackageGroup callback succeeded. result: ' + JSON.stringify(res));
+ }
+});
+// Callback without bundleName
+bundleState.queryAppUsagePriorityGroup((err, res) => {
+ if(err) {
+ console.log('BUNDLE_ACTIVE QueryPackageGroup callback failed. because: ' + err.code);
+ } else {
+ console.log('BUNDLE_ACTIVE QueryPackageGroup callback succeeded. result: ' + JSON.stringify(res));
+ }
+});
+```
+
+## bundleState.setBundleGroup9+
+
+setBundleGroup(bundleName: string, newGroup: GroupType): Promise\
+
+Sets the group for the application specified by **bundleName**. This API uses a promise to return the result.
+
+**Required permissions**: ohos.permission.BUNDLE_ACTIVE_INFO
+
+**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ---------- | --------- | ---- | ---- |
+| bundleName | string | Yes | Bundle name of the target application.|
+| newGroup | GroupType | Yes | Application group.|
+
+**Return value**
+
+| Type | Description |
+| ------------- | ------------------------- |
+| Promise\ | Promise used to return the result.|
+
+**Example**
+
+```javascript
+this.bundleName = "com.example.deviceUsageStatistics";
+this.newGroup = stats.GroupType.ACTIVE_GROUP_DAILY;
+
+bundleState.setBundleGroup(this.bundleName, this.newGroup).then( () => {
+ console.log('BUNDLE_ACTIVE SetBundleGroup promise succeeded.');
+}).catch( err => {
+ console.log('BUNDLE_ACTIVE SetBundleGroup promise failed. because: ' + err.code);
+});
+```
+
+## bundleState.setBundleGroup9+
+
+setBundleGroup(bundleName: string, newGroup: GroupType, callback: AsyncCallback\): void
+
+Sets the group for the application specified by **bundleName**. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.BUNDLE_ACTIVE_INFO
+
+**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ---------- | ------------------- | ---- | ------------------------- |
+| bundleName | string | Yes | Bundle name of the target application. |
+| newGroup | GroupType | Yes | Application group. |
+| callback | AsyncCallback\ | Yes | Callback used to return the result.|
+
+**Example**
+
+```javascript
+this.bundleName = "com.example.deviceUsageStatistics";
+this.newGroup = stats.GroupType.ACTIVE_GROUP_DAILY;
+
+bundleState.setBundleGroup(this.bundleName, this.newGroup, (err) => {
+ if(err) {
+ console.log('BUNDLE_ACTIVE SetBundleGroup callback failed. because: ' + err.code);
+ } else {
+ console.log('BUNDLE_ACTIVE SetBundleGroup callback succeeded.');
+ }
+});
+```
+
+## bundleState.registerGroupCallBack9+
+
+registerGroupCallBack(callback: Callback\): Promise\
+
+Registers a callback for application group changes. When an application group of the user changes, **BundleActiveGroupCallbackInfo** is returned to all applications that have registered the callback. This API uses a promise to return the result.
+
+**Required permissions**: ohos.permission.BUNDLE_ACTIVE_INFO
+
+**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | --------------------------------------- | ---- | ----------- |
+| callback | Callback\ | Yes | Callback for application group changes.|
+
+**Return value**
+
+| Type | Description |
+| ------------- | ----------------------- |
+| Promise\ | Promise used to return the result.|
+
+**Example**
+
+```javascript
+let onBundleGroupChanged = (err,res) =>{
+ console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack callback success.');
+ console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result oldGroup is : ' + res.oldGroup);
+ console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result newGroup is : ' + res.newGroup);
+ console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result changeReason is : ' + res.newGroup);
+ console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result userId is : ' + res.userId);
+ console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result bundleName is : ' + res.bundleName);
+};
+bundleState.registerGroupCallBack(onBundleGroupChanged).then( () => {
+ console.log('BUNDLE_ACTIVE RegisterGroupCallBack promise succeeded.');
+}).catch( err => {
+ console.log('BUNDLE_ACTIVE RegisterGroupCallBack promise failed. because: ' + err.code);
+});
+```
+
+## bundleState.registerGroupCallBack9+
+
+registerGroupCallBack(callback: Callback\, callback: AsyncCallback\): void
+
+Registers a callback for application group changes. When an application group of the user changes, **BundleActiveGroupCallbackInfo** is returned to all applications that have registered the callback. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.BUNDLE_ACTIVE_INFO
+
+**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | --------------------------------------- | ---- | ------------- |
+| callback | Callback\ | Yes | Callback for application group changes. |
+| callback | AsyncCallback\ | Yes | Callback used to return the result.|
+
+**Example**
+
+```javascript
+let onBundleGroupChanged = (err,res) =>{
+ console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack callback success.');
+ console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result's oldGroup is : ' + res.oldGroup);
+ console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result's newGroup is : ' + res.newGroup);
+ console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result's changeReason is : ' + res.newGroup);
+ console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result's userId is : ' + res.userId);
+ console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result's bundleName is : ' + res.bundleName);
+};
+bundleState.registerGroupCallBack(onBundleGroupChanged, (err)=>{
+ if(err) {
+ console.log('BUNDLE_ACTIVE RegisterGroupCallBack callback failed, because: ' + err.code);
+ } else {
+ console.log('BUNDLE_ACTIVE RegisterGroupCallBack callback success.');
+ }
+});
+```
+
+## bundleState.unRegisterGroupCallBack9+
+
+unRegisterGroupCallBack(): Promise\
+
+Deregisters the callback for application group changes. This API uses a promise to return the result.
+
+**Required permissions**: ohos.permission.BUNDLE_ACTIVE_INFO
+
+**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**: none
+
+**Return value**
+
+| Type | Description |
+| ------------- | ------------------------ |
+| Promise\ | Promise used to return the result.|
+
+**Example**
+
+```javascript
+bundleState.unRegisterGroupCallBack().then( () => {
+ console.log('BUNDLE_ACTIVE UnRegisterGroupCallBack promise succeeded.');
+}).catch( err => {
+ console.log('BUNDLE_ACTIVE UnRegisterGroupCallBack promise failed. because: ' + err.code);
+});
+```
+
+## bundleState.unRegisterGroupCallBack9+
+
+unRegisterGroupCallBack(callback: AsyncCallback\): void;
+
+Deregisters the callback for application group changes. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.BUNDLE_ACTIVE_INFO
+
+**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ------------------- | ---- | -------------- |
+| callback | AsyncCallback\ | Yes | Callback used to return the result.|
+
+**Example**
+
+```javascript
+bundleState.unRegisterGroupCallBack((err)=>{
+ if(err) {
+ console.log('BUNDLE_ACTIVE UnRegisterGroupCallBack callback failed, because: ' + err.code);
+ } else {
+ console.log('BUNDLE_ACTIVE UnRegisterGroupCallBack callback success.');
+ }
+});
+```
+
+## bundleState.queryBundleActiveEventStates9+
+
+queryBundleActiveEventStates(begin: number, end: number): Promise<Array<BundleActiveEventState>>
+
+Queries statistics about system events (hibernation, wakeup, unlocking, and screen locking) that occur between the specified start time and end time. This API uses a promise to return the result.
+
+**Required permissions**: ohos.permission.BUNDLE_ACTIVE_INFO
+
+**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ----- | ------ | ---- | ----- |
+| begin | number | Yes | Start time.|
+| end | number | Yes | End time.|
+
+**Return value**
+
+| Type | Description |
+| ---------------------------------------- | ---------------------------------------- |
+| Promise<Array<[BundleActiveEventState](#bundleactiveeventstate9)>> | Promise used to return the result.|
+
+**Example**
+
+ ```js
+ bundleState.queryBundleActiveEventStates(0, 20000000000000).then( res => {
+ console.log('BUNDLE_ACTIVE queryBundleActiveEventStates promise success.');
+ console.log('BUNDLE_ACTIVE queryBundleActiveEventStates promise result ' + JSON.stringify(res));
+ }).catch( err=> {
+ console.log('BUNDLE_ACTIVE queryBundleActiveEventStates promise failed, because: ' + err.code);
+ });
+ ```
+
+## bundleState.queryBundleActiveEventStates9+
+
+queryBundleActiveEventStates(begin: number, end: number, callback: AsyncCallback<Array<BundleActiveEventState>>): void
+
+Queries statistics about system events (hibernation, wakeup, unlocking, and screen locking) that occur between the specified start time and end time. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.BUNDLE_ACTIVE_INFO
+
+**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
+| begin | number | Yes | Start time. |
+| end | number | Yes | End time. |
+| callback | AsyncCallback<Array<[BundleActiveEventState](#bundleactiveeventstate9)>> | Yes | Promise used to return the result.|
+
+**Example**
+
+ ```js
+ bundleState.queryBundleActiveEventStates(0, 20000000000000, (err, res) => {
+ if(err) {
+ console.log('BUNDLE_ACTIVE queryBundleActiveEventStates callback failed, because: ' + err.code);
+ } else {
+ console.log('BUNDLE_ACTIVE queryBundleActiveEventStates callback success.');
+ console.log('BUNDLE_ACTIVE queryBundleActiveEventStates callback result ' + JSON.stringify(res));
+ }
+ });
+ ```
+
+## bundleState.queryAppNotificationNumber9+
+
+queryAppNotificationNumber(begin: number, end: number): Promise<Array<BundleActiveEventState>>
+
+Queries the number of notifications from all applications based on the specified start time and end time. This API uses a promise to return the result.
+
+**Required permissions**: ohos.permission.BUNDLE_ACTIVE_INFO
+
+**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ----- | ------ | ---- | ----- |
+| begin | number | Yes | Start time.|
+| end | number | Yes | End time.|
+
+**Return value**
+
+| Type | Description |
+| ---------------------------------------- | ---------------------------------------- |
+| Promise<Array<[BundleActiveEventState](#bundleactiveeventstate9)>> | Promise used to return the result.|
+
+**Example**
+
+ ```js
+ bundleState.queryAppNotificationNumber(0, 20000000000000).then( res => {
+ console.log('BUNDLE_ACTIVE queryAppNotificationNumber promise success.');
+ console.log('BUNDLE_ACTIVE queryAppNotificationNumber promise result ' + JSON.stringify(res));
+ }).catch( err=> {
+ console.log('BUNDLE_ACTIVE queryAppNotificationNumber promise failed, because: ' + err.code);
+ });
+ ```
+
+## bundleState.queryAppNotificationNumber9+
+
+queryAppNotificationNumber(begin: number, end: number, callback: AsyncCallback<Array<BundleActiveEventState>>): void
+
+Queries the number of notifications from all applications based on the specified start time and end time. This API uses an asynchronous callback to return the result.
+
+**Required permissions**: ohos.permission.BUNDLE_ACTIVE_INFO
+
+**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
+| begin | number | Yes | Start time. |
+| end | number | Yes | End time. |
+| callback | AsyncCallback<Array<[BundleActiveEventState](#bundleactiveeventstate9)>> | Yes | Callback used to return the result.|
+
+**Example**
+
+ ```js
+ bundleState.queryAppNotificationNumber(0, 20000000000000, (err, res) => {
+ if(err) {
+ console.log('BUNDLE_ACTIVE queryAppNotificationNumberCallBack callback failed, because: ' + err.code);
+ } else {
+ console.log('BUNDLE_ACTIVE queryAppNotificationNumberCallBack callback success.');
+ console.log('BUNDLE_ACTIVE queryAppNotificationNumberCallBack callback result ' + JSON.stringify(res));
+ }
+ });
+ ```
+
## BundleActiveModuleInfo9+
Provides the information about the FA usage.
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| deviceId | string | No| ID of the device to which the FA belongs.|
-| bundleName | string | Yes| Name of the application bundle to which the FA belongs.|
-| moduleName | string | Yes| Name of the module to which the FA belongs.|
-| abilityName | string | No| **MainAbility** name of the FA.|
-| appLabelId | number | No| Application label ID of the FA.|
-| labelId | number | No| Label ID of the module to which the FA belongs.|
-| descriptionId | number | No| Description ID of the application to which the FA belongs.|
-| abilityLableId | number | No| **MainAbility** label ID of the FA.|
-| abilityDescriptionId | number | No| **MainAbility** description ID of the FA.|
-| abilityIconId | number | No| **MainAbility** icon ID of the FA.|
-| launchedCount | number | Yes| Number of FA startup times.|
-| lastModuleUsedTime | number | Yes| Last time when the FA is used.|
-| formRecords | Array<[BundleActiveFormInfo](#bundleactiveforminfo9)> | Yes| Array of widget usage records in the FA.|
+| Name | Type | Mandatory | Description |
+| -------------------- | ---------------------------------------- | ---- | ----------------------------- |
+| deviceId | string | No | ID of the device to which the FA belongs. |
+| bundleName | string | Yes | Name of the application bundle to which the FA belongs. |
+| moduleName | string | Yes | Name of the module to which the FA belongs. |
+| abilityName | string | No | **MainAbility** name of the FA. |
+| appLabelId | number | No | Application label ID of the FA. |
+| labelId | number | No | Label ID of the module to which the FA belongs. |
+| descriptionId | number | No | Description ID of the application to which the FA belongs. |
+| abilityLableId | number | No | **MainAbility** label ID of the FA. |
+| abilityDescriptionId | number | No | **MainAbility** description ID of the FA.|
+| abilityIconId | number | No | **MainAbility** icon ID of the FA. |
+| launchedCount | number | Yes | Number of FA startup times. |
+| lastModuleUsedTime | number | Yes | Last time when the FA was used. |
+| formRecords | Array<[BundleActiveFormInfo](#bundleactiveforminfo9)> | Yes | Array of widget usage records in the FA. |
## BundleActiveFormInfo9+
Provides the FA widget usage information.
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| formName | number | Yes| Widget name.|
-| formDimension | number | Yes| Widget dimensions.|
-| formId | number | Yes| Widget ID.|
-| formLastUsedTime | number | Yes| Last time when the widget was clicked.|
-| count | number | Yes| Number of clicks on the widget.|
+| Name | Type | Mandatory | Description |
+| ---------------- | ------ | ---- | ----------- |
+| formName | number | Yes | Widget name. |
+| formDimension | number | Yes | Widget dimensions. |
+| formId | number | Yes | Widget ID. |
+| formLastUsedTime | number | Yes | Last time when the widget was clicked.|
+| count | number | Yes | Number of clicks on the widget. |
+
+## BundleActiveGroupCallbackInfo9+
+
+Provides the application group changes returned through a callback.
+
+**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
+
+| Name | Type | Mandatory | Description |
+| ---------------- | ------ | ---- | -------- |
+| appUsageOldGroup | number | Yes | Application group before the change.|
+| appUsageNewGroup | number | Yes | Application group after the change.|
+| useId | number | Yes | User ID. |
+| changeReason | number | Yes | Reason for the group change. |
+| bundleName | string | Yes | Bundle name of an application. |
## BundleStateInfo
-Provides the usage duration information of an application.
+
+Provides the usage duration information of applications.
### Attributes
-**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
+**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| bundleName | string | Yes| Application bundle name.|
-| abilityPrevAccessTime | number | Yes| Last time when the application was used.|
-| abilityInFgTotalTime | number | Yes| Total time that the application runs in the foreground.|
-| id | number | No| User ID. This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
-| abilityPrevSeenTime | number | No| Last time when the application was visible in the foreground. This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
-| abilitySeenTotalTime | number | No| Total time when the application is visible in the foreground. This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
-| fgAbilityAccessTotalTime | number | No| Total time that the application accesses the foreground. This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
-| fgAbilityPrevAccessTime | number | No| Last time when the application accessed the foreground. This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
-| infosBeginTime | number | No| Time logged in the first application usage record in the **BundleActiveInfo** object. This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
-| infosEndTime | number | No| Time logged in the last application usage record in the **BundleActiveInfo** object. This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
+| Name | Type | Mandatory | Description |
+| ------------------------ | ------ | ---- | ---------------------------------------- |
+| bundleName | string | Yes | Bundle name of the application. |
+| abilityPrevAccessTime | number | Yes | Last time when the application was used. |
+| abilityInFgTotalTime | number | Yes | Total time that the application runs in the foreground. |
+| id | number | No | User ID. This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
+| abilityPrevSeenTime | number | No | Last time when the application was visible in the foreground. This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
+| abilitySeenTotalTime | number | No | Total time that the application is visible in the foreground. This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
+| fgAbilityAccessTotalTime | number | No | Total time that the application accesses the foreground. This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
+| fgAbilityPrevAccessTime | number | No | Last time when the application accessed the foreground. This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
+| infosBeginTime | number | No | Time logged in the first application usage record in the **BundleActiveInfo** object. This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
+| infosEndTime | number | No | Time logged in the last application usage record in the **BundleActiveInfo** object. This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
### merge
@@ -562,9 +1035,9 @@ This API is defined but not implemented in OpenHarmony 3.1 Release. It will be a
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| toMerge | [BundleStateInfo](#bundlestateinfo) | Yes| Application usage information to merge.|
+| Name | Type | Mandatory | Description |
+| ------- | ----------------------------------- | ---- | -------------- |
+| toMerge | [BundleStateInfo](#bundlestateinfo) | Yes | Application usage information to merge.|
## BundleActiveState
@@ -572,14 +1045,14 @@ Provides information about an application event.
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| bundleName | string | Yes| Application bundle name.|
-| stateType | number | Yes| Application event type.|
-| stateOccurredTime | number | Yes| Timestamp when the application event occurs.|
-| appUsagePriorityGroup | number | No| Usage priority group of the application. This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
-| indexOfLink | string | No| Shortcut ID. This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
-| nameOfClass | string | No| Class name. This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
+| Name | Type | Mandatory | Description |
+| --------------------- | ------ | ---- | ---------------------------------------- |
+| bundleName | string | Yes | Bundle name of the application. |
+| stateType | number | Yes | Application event type. |
+| stateOccurredTime | number | Yes | Timestamp when the application event occurs. |
+| appUsagePriorityGroup | number | No | Usage priority group of the application. This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
+| indexOfLink | string | No | Shortcut ID. This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
+| nameOfClass | string | No | Class name. This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
## BundleActiveInfoResponse
@@ -587,9 +1060,23 @@ Provides the usage duration information of applications.
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| [key: string]: BundleStateInfo | [key: string]: [BundleStateInfo](#bundlestateinfo) | Yes| Usage duration information by application.|
+| Name | Type | Mandatory | Description |
+| ------------------------------ | ---------------------------------------- | ---- | -------------- |
+| [key: string]: BundleStateInfo | [key: string]: [BundleStateInfo](#bundlestateinfo) | Yes | Usage duration information by application.|
+
+## BundleActiveEventState9+
+
+Provides statistics about notifications and system events.
+
+**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+| Name | Type | Mandatory | Description |
+| ------- | ------ | ---- | ----------------- |
+| name | string | Yes | Bundle name of the notification sending application or system event name. |
+| eventId | number | Yes | Type of the notification or system event. |
+| count | number | Yes | Number of application notifications or system event triggering times.|
## IntervalType
@@ -597,10 +1084,25 @@ Enumerates the interval types for querying the application usage duration.
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
-|Name |Default Value |Description|
-| -------- | -------- | -------- |
-| BY_OPTIMIZED | 0 | The system obtains the application usage duration statistics in the specified time frame at the interval the system deems appropriate.|
-| BY_DAILY | 1 | The system obtains the application usage duration statistics in the specified time frame on a daily basis.|
-| BY_WEEKLY | 2 | The system obtains the application usage duration statistics in the specified time frame on a weekly basis.|
-| BY_MONTHLY | 3 | The system obtains the application usage duration statistics in the specified time frame on a monthly basis.|
-| BY_ANNUALLY | 4 | The system obtains the application usage duration statistics in the specified time frame on an annual basis.|
+| Name | Default Value | Description |
+| ------------ | ---- | ---------------------------------------- |
+| BY_OPTIMIZED | 0 | The system obtains the application usage duration statistics in the specified time frame at the interval the system deems appropriate.|
+| BY_DAILY | 1 | The system obtains the application usage duration statistics in the specified time frame on a daily basis. |
+| BY_WEEKLY | 2 | The system obtains the application usage duration statistics in the specified time frame on a weekly basis. |
+| BY_MONTHLY | 3 | The system obtains the application usage duration statistics in the specified time frame on a monthly basis. |
+| BY_ANNUALLY | 4 | The system obtains the application usage duration statistics in the specified time frame on an annual basis. |
+
+## GroupType
+
+Enumerates the application group types.
+
+**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
+
+| Name | Default Value | Description |
+| ------------------ | ---- | ----------------- |
+| ACTIVE_GROUP_ALIVE | 10 | Group of active applications. |
+| ACTIVE_GROUP_DAILY | 20 | Group of frequently used applications that are not in the active state. |
+| ACTIVE_GROUP_FIXED | 30 | Group of applications that are used periodically but not every day.|
+| ACTIVE_GROUP_RARE | 40 | Group of rarely used applications. |
+| ACTIVE_GROUP_LIMIT | 50 | Group of restricted applications. |
+| ACTIVE_GROUP_NEVER | 60 | Group of applications that have been installed but never run. |
diff --git a/en/application-dev/reference/apis/js-apis-display.md b/en/application-dev/reference/apis/js-apis-display.md
index 994fe3a673ca9d505c0a6f96df6f007fe6d027d4..ffbc73ff530a4d8f9ec39fd6e824760df9448644 100644
--- a/en/application-dev/reference/apis/js-apis-display.md
+++ b/en/application-dev/reference/apis/js-apis-display.md
@@ -1,6 +1,8 @@
# Display
+Provides APIs for managing displays, such as obtaining information about the default display, obtaining information about all displays, and listening for the addition and removal of displays.
-> **NOTE**
+> **NOTE**
+>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
@@ -139,7 +141,7 @@ Obtains all the display objects.
| Type | Description |
| ----------------------------------------------- | ------------------------------------------------------- |
- | Promise<Array<[Display](#display)>> | Promise used to return an array containing all the display objects.|
+ | Promise<Array<[Display](#display)>> | Promise used to return all the display objects.|
**Example**
@@ -163,7 +165,7 @@ Enables listening.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
- | type | string | Yes| Listening type. The available values are as follows: - **add**: listening for whether a display is added - **remove**: listening for whether a display is removed - **change**: listening for whether a display is changed|
+ | type | string | Yes| Listening type. The available values are as follows: - **add**: listening for whether a display is added - **remove**: listening for whether a display is removed - **change**: listening for whether a display is changed|
| callback | Callback<number> | Yes| Callback used to return the ID of the display.|
**Example**
@@ -186,7 +188,7 @@ Disables listening.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
- | type | string | Yes| Listening type. The available values are as follows: - **add**: listening for whether a display is added - **remove**: listening for whether a display is removed - **change**: listening for whether a display is changed|
+ | type | string | Yes| Listening type. The available values are as follows: - **add**: listening for whether a display is added - **remove**: listening for whether a display is removed - **change**: listening for whether a display is changed|
| callback | Callback<number> | No| Callback used to return the ID of the display.|
**Example**
diff --git a/en/application-dev/reference/apis/js-apis-distributed-data.md b/en/application-dev/reference/apis/js-apis-distributed-data.md
index 6c4d1b471f53748d89fb576f6584b8290903d2fa..d44ba34a8a05de6dea75b8d94965376e668d6bd1 100644
--- a/en/application-dev/reference/apis/js-apis-distributed-data.md
+++ b/en/application-dev/reference/apis/js-apis-distributed-data.md
@@ -576,13 +576,12 @@ Provides KV store configuration.
Defines the KV store types.
-**System capability**: SystemCapability.DistributedDataManager.KVStore.Core
| Name | Default Value| Description |
| --- | ---- | ----------------------- |
-| DEVICE_COLLABORATION | 0 | Device KV store. |
-| SINGLE_VERSION | 1 | Single KV store. |
-| MULTI_VERSION | 2 | Multi-version KV store. This type is not supported currently. |
+| DEVICE_COLLABORATION | 0 | Device KV store. **System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore |
+| SINGLE_VERSION | 1 | Single KV store. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core |
+| MULTI_VERSION | 2 | Multi-version KV store. This type is not supported currently. **System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore|
## SecurityLevel
@@ -1239,7 +1238,7 @@ try {
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
- console.log("dumplicated calls should be ok :" + e);
+ console.log("duplicated calls should be ok :" + e);
}
```
@@ -1274,7 +1273,7 @@ try {
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
- console.log("dumplicated calls should be ok :" + e);
+ console.log("duplicated calls should be ok :" + e);
}
```
@@ -1309,7 +1308,7 @@ try {
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
- console.log("dumplicated calls should be ok :" + e);
+ console.log("duplicated calls should be ok :" + e);
}
```
@@ -1344,7 +1343,7 @@ try {
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
- console.log("dumplicated calls should be ok :" + e);
+ console.log("duplicated calls should be ok :" + e);
}
```
@@ -1379,7 +1378,7 @@ try {
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
- console.log("dumplicated calls should be ok :" + e);
+ console.log("duplicated calls should be ok :" + e);
}
```
@@ -1414,7 +1413,7 @@ try {
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
- console.log("dumplicated calls should be ok :" + e);
+ console.log("duplicated calls should be ok :" + e);
}
```
@@ -1449,7 +1448,7 @@ try {
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
- console.log("dumplicated calls should be ok :" + e);
+ console.log("duplicated calls should be ok :" + e);
}
```
@@ -1485,7 +1484,7 @@ try {
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
- console.log("dumplicated calls should be ok :" + e);
+ console.log("duplicated calls should be ok :" + e);
}
```
@@ -1520,7 +1519,7 @@ try {
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
- console.log("dumplicated calls should be ok :" + e);
+ console.log("duplicated calls should be ok :" + e);
}
```
@@ -1555,7 +1554,7 @@ try {
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
- console.log("dumplicated calls should be ok :" + e);
+ console.log("duplicated calls should be ok :" + e);
}
```
@@ -1590,7 +1589,7 @@ try {
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
- console.log("dumplicated calls should be ok :" + e);
+ console.log("duplicated calls should be ok :" + e);
}
```
@@ -1625,7 +1624,7 @@ try {
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
- console.log("dumplicated calls should be ok :" + e);
+ console.log("duplicated calls should be ok :" + e);
}
```
@@ -1660,7 +1659,7 @@ try {
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
- console.log("dumplicated calls should be ok :" + e);
+ console.log("duplicated calls should be ok :" + e);
}
```
@@ -1690,7 +1689,7 @@ try {
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
- console.log("dumplicated calls should be ok :" + e);
+ console.log("duplicated calls should be ok :" + e);
}
```
@@ -1720,7 +1719,7 @@ try {
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
- console.log("dumplicated calls should be ok :" + e);
+ console.log("duplicated calls should be ok :" + e);
}
```
@@ -1755,7 +1754,7 @@ try {
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
- console.log("dumplicated calls should be ok :" + e);
+ console.log("duplicated calls should be ok :" + e);
}
```
@@ -1790,7 +1789,7 @@ try {
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
- console.log("dumplicated calls should be ok :" + e);
+ console.log("duplicated calls should be ok :" + e);
}
```
@@ -1826,7 +1825,7 @@ try {
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
- console.log("dumplicated calls should be ok :" + e);
+ console.log("duplicated calls should be ok :" + e);
}
```
@@ -1860,7 +1859,7 @@ try {
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
- console.log("dumplicated calls should be ok :" + e);
+ console.log("duplicated calls should be ok :" + e);
}
```
@@ -1890,7 +1889,7 @@ try {
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
- console.log("dumplicated calls should be ok :" + e);
+ console.log("duplicated calls should be ok :" + e);
}
```
@@ -1920,7 +1919,7 @@ try {
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
- console.log("dumplicated calls should be ok :" + e);
+ console.log("duplicated calls should be ok :" + e);
}
```
@@ -1955,7 +1954,7 @@ try {
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
- console.log("dumplicated calls should be ok :" + e);
+ console.log("duplicated calls should be ok :" + e);
}
```
@@ -1990,7 +1989,7 @@ try {
console.log("query is " + query.getSqlLike());
query = null;
} catch (e) {
- console.log("dumplicated calls should be ok :" + e);
+ console.log("duplicated calls should be ok :" + e);
}
```
@@ -2051,7 +2050,7 @@ try {
let sql1 = query.getSqlLike();
console.log("GetSqlLike sql=" + sql1);
} catch (e) {
- console.log("dumplicated calls should be ok : " + e);
+ console.log("duplicated calls should be ok : " + e);
}
```
diff --git a/en/application-dev/reference/apis/js-apis-eventhub.md b/en/application-dev/reference/apis/js-apis-eventhub.md
index f2d605b94821c591812c73bbb10defa04a6a40e1..a5a25efdbab5c977e92b85a5fcc656f5c3ae3ef7 100644
--- a/en/application-dev/reference/apis/js-apis-eventhub.md
+++ b/en/application-dev/reference/apis/js-apis-eventhub.md
@@ -1,8 +1,9 @@
# EventHub
-> **NOTE**
-> The initial APIs of this module are supported since API 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
-
+> **NOTE**
+>
+> The initial APIs of this module are supported since API 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+> The APIs of this module can be used only in the stage model.
Implements event subscription, unsubscription, and triggering.
@@ -14,11 +15,8 @@ import Ability from '@ohos.application.Ability'
## Usage
-
Before using any APIs in the **EventHub**, you must obtain an **EventHub** instance through the member variable **context** of the **Ability** instance.
-
-
```js
import Ability from '@ohos.application.Ability'
export default class MainAbility extends Ability {
diff --git a/en/application-dev/reference/apis/js-apis-extension-context.md b/en/application-dev/reference/apis/js-apis-extension-context.md
index afd1cec9cd5df1eaaedfc8679e1dc478e8e09766..24ca2bb2e99bd5b308aea4683a9242c998417e78 100644
--- a/en/application-dev/reference/apis/js-apis-extension-context.md
+++ b/en/application-dev/reference/apis/js-apis-extension-context.md
@@ -1,7 +1,9 @@
# ExtensionContext
-> **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.
+> **NOTE**
+>
+> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+> The APIs of this module can be used only in the stage model.
Implements the extension context. This module is inherited from **Context**.
diff --git a/en/application-dev/reference/apis/js-apis-extensionrunninginfo.md b/en/application-dev/reference/apis/js-apis-extensionrunninginfo.md
index 05a2fb5bdfda8d4f86e0283b7d9abdeeee2e2f22..62f6d9b631aa687e61fc6a1b4fe26fb72f16f105 100644
--- a/en/application-dev/reference/apis/js-apis-extensionrunninginfo.md
+++ b/en/application-dev/reference/apis/js-apis-extensionrunninginfo.md
@@ -1,9 +1,9 @@
# ExtensionRunningInfo
-> **NOTE**
+> **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.
-
Provides extension running information.
## Modules to Import
@@ -14,11 +14,8 @@ import abilitymanager from '@ohos.application.abilityManager';
## Usage
-
The extension running information is obtained through an **abilityManager** instance.
-
-
```js
import abilitymanager from '@ohos.application.abilityManager';
let upperLimit=1
diff --git a/en/application-dev/reference/apis/js-apis-featureAbility.md b/en/application-dev/reference/apis/js-apis-featureAbility.md
index 578fb21ef40144ad14616abd58e9219dc57e3cbd..4c15fefc458a174ee0477d23b77aa9796f2bb051 100644
--- a/en/application-dev/reference/apis/js-apis-featureAbility.md
+++ b/en/application-dev/reference/apis/js-apis-featureAbility.md
@@ -1,7 +1,9 @@
-# FeatureAbility Module (JavaScript)
+# FeatureAbility
-> **NOTE**
-> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+> **NOTE**
+>
+> The initial APIs of this module are supported since API version 6. 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 FA model.
## Constraints
@@ -923,7 +925,7 @@ Enumerates operation types of the Data ability.
**System capability**: SystemCapability.Ability.AbilityBase
-| Name | Name | Description |
+| Name | Value | Description |
| ------------------------------------ | ---------- | ---------------------------------------- |
| FLAG_AUTH_READ_URI_PERMISSION | 0x00000001 | Indicates the permission to read the URI. |
| FLAG_AUTH_WRITE_URI_PERMISSION | 0x00000002 | Indicates the permission to write the URI. |
diff --git a/en/application-dev/reference/apis/js-apis-formInfo.md b/en/application-dev/reference/apis/js-apis-formInfo.md
index 1091770862af33647f271be1d0097859c7440ad1..502a8212f54e8cdefa381a8b862f1148e2f73b11 100644
--- a/en/application-dev/reference/apis/js-apis-formInfo.md
+++ b/en/application-dev/reference/apis/js-apis-formInfo.md
@@ -1,6 +1,7 @@
# FormInfo
->  **NOTE**
+> **NOTE**
+>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Provides widget information.
diff --git a/en/application-dev/reference/apis/js-apis-formbindingdata.md b/en/application-dev/reference/apis/js-apis-formbindingdata.md
index 5f92677ec4a9856d96bc78b8787059ad5fb180ac..622f78b73e55afbe4fdcf8b342597b3ba44edeeb 100644
--- a/en/application-dev/reference/apis/js-apis-formbindingdata.md
+++ b/en/application-dev/reference/apis/js-apis-formbindingdata.md
@@ -1,6 +1,7 @@
# FormBindingData
->  **NOTE**
+> **NOTE**
+>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
@@ -38,12 +39,20 @@ Creates a **FormBindingData** object.
**Example**
```js
- let fd = fileio.openSync(path);
- let obj = {
- "temperature": "21°",
- "formImages": {"image": fd}
- };
- let formBindingDataObj = formBindingData.createFormBindingData(obj);
+ import featureAbility from '@ohos.ability.featureAbility';
+ import fileio from '@ohos.fileio';
+ let context=featureAbility.getContext();
+ context.getOrCreateLocalDir((err,data)=>{
+ let path=data+"/xxx.jpg";
+ let fd = fileio.openSync(path);
+ let obj = {
+ "temperature": "21°",
+ "formImages": {"image": fd}
+ };
+ let formBindingDataObj = formBindingData.createFormBindingData(obj);
+ })
+
+
```
## Attributes
diff --git a/en/application-dev/reference/apis/js-apis-formerror.md b/en/application-dev/reference/apis/js-apis-formerror.md
index 37eecd85304700c21d92e6f07d3cd11229a32c64..62e062c25eab28cfa018f4971da3e5317db7d448 100644
--- a/en/application-dev/reference/apis/js-apis-formerror.md
+++ b/en/application-dev/reference/apis/js-apis-formerror.md
@@ -1,6 +1,7 @@
# FormError
->  **NOTE**
+> **NOTE**
+>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Provides widget-related error codes.
diff --git a/en/application-dev/reference/apis/js-apis-formextension.md b/en/application-dev/reference/apis/js-apis-formextension.md
index 0329e0cf3595887133d17c9af400df4b916d7845..b758b2f8e46d2bc4df93d94546f36c0caff4c960 100644
--- a/en/application-dev/reference/apis/js-apis-formextension.md
+++ b/en/application-dev/reference/apis/js-apis-formextension.md
@@ -1,7 +1,9 @@
# FormExtension
-> **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.
+> **NOTE**
+>
+> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+> The APIs of this module can be used only in the stage model.
Provides **FormExtension** APIs.
@@ -21,7 +23,7 @@ None
| Name | Type | Readable| Writable| Description |
| ------- | ------------------------------------------------------- | ---- | ---- | --------------------------------------------------- |
-| context | [FormExtensionContext](js-apis-formextensioncontext.md) | Yes | No | Context of the **FormExtension**. This class is inherited from **ExtensionContext**.|
+| context | [FormExtensionContext](js-apis-formextensioncontext.md) | Yes | No | Context of the **FormExtension**. This context is inherited from **ExtensionContext**.|
## onCreate
@@ -227,7 +229,7 @@ Called when the configuration of the environment where the ability is running is
onAcquireFormState?(want: Want): formInfo.FormState;
-Used by the widget provider to receive the widget state query request. By default, the initial widget state is returned.
+Called when the widget provider receives the status query result of a specified service widget. By default, the initial state is returned.
**System capability**: SystemCapability.Ability.Form
diff --git a/en/application-dev/reference/apis/js-apis-formextensioncontext.md b/en/application-dev/reference/apis/js-apis-formextensioncontext.md
index ac5149428ef10806dbc67e9a17c4b108ad3cf174..4e877102c65aaf630ee5d5e12eff7d3c9e611b42 100644
--- a/en/application-dev/reference/apis/js-apis-formextensioncontext.md
+++ b/en/application-dev/reference/apis/js-apis-formextensioncontext.md
@@ -1,7 +1,9 @@
# FormExtensionContext
-> **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.
+> **NOTE**
+>
+> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+> The APIs of this module can be used only in the stage model.
Implements the context that provides the capabilities and APIs of **FormExtension**. This class is inherited from **ExtensionContext**.
@@ -21,11 +23,11 @@ Updates a widget. This method uses a callback to return the result.
**Parameters**
-| Name | Type | Mandatory| Description |
-| --------------- | ------------------------------------------------------------ | ---- | -------------------------------------- |
-| formId | string | Yes | ID of the widget that requests to be updated. |
-| formBindingData | [formBindingData.FormBindingData](js-apis-formbindingdata.md#formbindingdata) | Yes | New data of the widget. |
-| callback | AsyncCallback\ | Yes | Callback used to return the result indicating whether the method is successfully called.|
+ | Name | Type | Mandatory| Description |
+ | --------------- | ------------------------------------------------------------ | ---- | -------------------------------------- |
+ | formId | string | Yes | ID of the widget that requests to be updated. |
+ | formBindingData | [formBindingData.FormBindingData](js-apis-formbindingdata.md#formbindingdata) | Yes | New data of the widget. |
+ | callback | AsyncCallback\ | Yes | Callback used to return the result indicating whether the method is successfully called.|
**Example**
@@ -54,16 +56,16 @@ Updates a widget. This method uses a promise to return the result.
**Parameters**
-| Name | Type | Mandatory| Description |
-| --------------- | ------------------------------------------------------------ | ---- | ------------------ |
-| formId | string | Yes | ID of the widget that requests to be updated.|
-| formBindingData | [formBindingData.FormBindingData](js-apis-formbindingdata.md#formbindingdata) | Yes | New data of the widget. |
+ | Name | Type | Mandatory| Description |
+ | --------------- | ------------------------------------------------------------ | ---- | ------------------ |
+ | formId | string | Yes | ID of the widget that requests to be updated.|
+ | formBindingData | [formBindingData.FormBindingData](js-apis-formbindingdata.md#formbindingdata) | Yes | New data of the widget. |
**Return value**
-| Type | Description |
-| -------------- | --------------------------------- |
-| Promise\ | Promise returned with the result indicating whether the method is successfully called.|
+ | Type | Description |
+ | -------------- | --------------------------------- |
+ | Promise\ | Promise returned with the result indicating whether the method is successfully called.|
**Example**
diff --git a/en/application-dev/reference/apis/js-apis-formhost.md b/en/application-dev/reference/apis/js-apis-formhost.md
index 5c012bf525f59b08454fd7aa0886a5a0ed419d0e..91ea521d2bcdece8aa8b3f7b4fc7c278db4c2ba1 100644
--- a/en/application-dev/reference/apis/js-apis-formhost.md
+++ b/en/application-dev/reference/apis/js-apis-formhost.md
@@ -1,6 +1,7 @@
# FormHost
-> **NOTE**
+> **NOTE**
+>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Provides APIs related to the widget host.
diff --git a/en/application-dev/reference/apis/js-apis-formprovider.md b/en/application-dev/reference/apis/js-apis-formprovider.md
index 7ff3e5f3d80fcfb93b057bf5e67def7d1f197e92..0637af7ceb3c1368f242d91d9f4b59566b7f08df 100644
--- a/en/application-dev/reference/apis/js-apis-formprovider.md
+++ b/en/application-dev/reference/apis/js-apis-formprovider.md
@@ -1,9 +1,10 @@
# FormProvider
-> **NOTE**
-> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+The **FormProvider** module provides APIs related to the widget provider. You can use the APIs to update a widget, set the next refresh time for a widget, obtain widget information, and release a widget release.
-Provides APIs related to the widget provider.
+> **NOTE**
+>
+> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
@@ -27,11 +28,11 @@ SystemCapability.Ability.Form
**Parameters**
- | Name| Type | Mandatory| Description |
- | ------ | ------ | ---- | ------------------------------------- |
- | formId | string | Yes | ID of a widget. |
- | minute | number | Yes | Refresh interval, in minutes. The value must be greater than or equal to 5. |
- | callback | AsyncCallback<void> | Yes| Callback used to return the result.|
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ------------------------------------- |
+| formId | string | Yes | ID of a widget. |
+| minute | number | Yes | Refresh interval, in minutes. The value must be greater than or equal to 5. |
+| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
**Example**
@@ -56,16 +57,16 @@ SystemCapability.Ability.Form
**Parameters**
- | Name| Type | Mandatory| Description |
- | ------ | ------ | ---- | ------------------------------------- |
- | formId | string | Yes | ID of a widget. |
- | minute | number | Yes | Refresh interval, in minutes. The value must be greater than or equal to 5. |
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ------------------------------------- |
+| formId | string | Yes | ID of a widget. |
+| minute | number | Yes | Refresh interval, in minutes. The value must be greater than or equal to 5. |
**Return value**
- | Type | Description |
- | ------------- | ---------------------------------- |
- | Promise\ |Promise used to return the result. |
+| Type | Description |
+| ------------- | ---------------------------------- |
+| Promise\ |Promise used to return the result. |
**Example**
@@ -90,11 +91,11 @@ SystemCapability.Ability.Form
**Parameters**
- | Name| Type | Mandatory| Description |
- | ------ | ---------------------------------------------------------------------- | ---- | ---------------- |
- | formId | string | Yes | ID of the widget to update.|
- | formBindingData | [FormBindingData](js-apis-formbindingdata.md#formbindingdata) | Yes | Data to be used for the update. |
- | callback | AsyncCallback<void> | Yes| Callback used to return the result.|
+| Name| Type | Mandatory| Description |
+| ------ | ---------------------------------------------------------------------- | ---- | ---------------- |
+| formId | string | Yes | ID of the widget to update.|
+| formBindingData | [FormBindingData](js-apis-formbindingdata.md#formbindingdata) | Yes | Data to be used for the update. |
+| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
**Example**
@@ -121,10 +122,10 @@ SystemCapability.Ability.Form
**Parameters**
- | Name| Type | Mandatory| Description |
- | ------ | ---------------------------------------------------------------------- | ---- | ---------------- |
- | formId | string | Yes | ID of the widget to update.|
- | formBindingData | [FormBindingData](js-apis-formbindingdata.md#formbindingdata) | Yes | Data to be used for the update. |
+| Name| Type | Mandatory| Description |
+| ------ | ---------------------------------------------------------------------- | ---- | ---------------- |
+| formId | string | Yes | ID of the widget to update.|
+| formBindingData | [FormBindingData](js-apis-formbindingdata.md#formbindingdata) | Yes | Data to be used for the update. |
**Return value**
@@ -144,3 +145,289 @@ SystemCapability.Ability.Form
console.log('formProvider updateForm, error:' + JSON.stringify(error));
});
```
+
+## getFormsInfo9+
+
+getFormsInfo(callback: AsyncCallback<Array<formInfo.FormInfo>>): void;
+
+Obtains the application's widget information on the device. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ------- |
+| callback | AsyncCallback<Array<[FormInfo](./js-apis-formInfo.md#forminfo-1)>> | Yes| Callback used to return the widget information.|
+
+**Example**
+
+```js
+formProvider.getFormsInfo((error, data) => {
+ if (error.code) {
+ console.log('formProvider getFormsInfo, error:' + JSON.stringify(error));
+ } else {
+ console.log('formProvider getFormsInfo, data:' + JSON.stringify(data));
+ }
+});
+```
+## getFormsInfo9+
+
+getFormsInfo(filter: formInfo.FormInfoFilter, callback: AsyncCallback<Array<formInfo.FormInfo>>): void;
+
+Obtains the application's widget information that meets a filter criterion on the device. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ------- |
+| filter | formInfo.FormInfoFilter | Yes| Filter criterion.|
+| callback | AsyncCallback<Array<[FormInfo](./js-apis-formInfo.md#forminfo-1)>> | Yes| Callback used to return the widget information.|
+
+**Example**
+
+```js
+const filter : formInfo.FormInfoFilter = {
+ moduleName : "entry"
+};
+formProvider.getFormsInfo(filter, (error, data) => {
+ if (error.code) {
+ console.log('formProvider getFormsInfo, error:' + JSON.stringify(error));
+ } else {
+ console.log('formProvider getFormsInfo, data:' + JSON.stringify(data));
+ }
+});
+```
+
+## getFormsInfo9+
+
+getFormsInfo(filter?: formInfo.FormInfoFilter): Promise<Array<formInfo.FormInfo>>;
+
+Obtains the application's widget information on the device. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ------- |
+| filter | formInfo.FormInfoFilter | No| Filter criterion.|
+
+**Return value**
+
+| Type | Description |
+| :------------ | :---------------------------------- |
+| Promise<Array<[FormInfo](./js-apis-formInfo.md#forminfo-1)>> | Promise used to return the widget information.|
+
+**Example**
+
+```js
+const filter : formInfo.FormInfoFilter = {
+ moduleName : "entry"
+};
+formProvider.getFormsInfo(filter).then((data) => {
+ console.log('formProvider getFormsInfo, data:' + JSON.stringify(data));
+}).catch((error) => {
+ console.log('formProvider getFormsInfo, error:' + JSON.stringify(error));
+});
+```
+
+## requestPublishForm9+
+
+requestPublishForm(want: Want, formBindingData: formBindingData.FormBindingData, callback: AsyncCallback<string>): <void>;
+
+Requests to publish a widget carrying data to the widget host. This API uses an asynchronous callback to return the result.
+
+**System capability**
+
+SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ---------------------------------------------------------------------- | ---- | ---------------- |
+| want | [Want](js-apis-application-Want.md) | Yes | Information about the target widget. **abilityName**: ability of the target widget. **parameters**: "ohos.extra.param.key.form_dimension" "ohos.extra.param.key.form_name" "ohos.extra.param.key.module_name" |
+| formBindingData | [FormBindingData](js-apis-formbindingdata.md#formbindingdata) | Yes | Data used for creating the widget.|
+| callback | AsyncCallback<string> | Yes| Callback used to return the widget ID.|
+
+**Example**
+
+ ```js
+ import formBindingData from '@ohos.application.formBindingData';
+ var want = {
+ abilityName: "FormAbility",
+ parameters: {
+ "ohos.extra.param.key.form_dimension": 2,
+ "ohos.extra.param.key.form_name": "widget",
+ "ohos.extra.param.key.module_name": "entry"
+ }
+ };
+ let obj = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"});
+ formProvider.requestPublishForm(want, obj, (error, data) => {
+ if (error.code) {
+ console.log('formProvider requestPublishForm, error: ' + JSON.stringify(error));
+ } else {
+ console.log('formProvider requestPublishForm, form ID is: ' + JSON.stringify(data));
+ }
+ });
+ ```
+
+## requestPublishForm9+
+
+requestPublishForm(want: Want, callback: AsyncCallback<string>): <void>;
+
+Requests to publish a widget to the widget host. This API uses an asynchronous callback to return the result.
+
+**System capability**
+
+SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ----------------------------------- | ---- | ------------------------------------------------------------ |
+| want | [Want](js-apis-application-Want.md) | Yes | Information about the target widget. **abilityName**: ability of the target widget. **parameters**: "ohos.extra.param.key.form_dimension" "ohos.extra.param.key.form_name" "ohos.extra.param.key.module_name" |
+| callback | AsyncCallback<string> | Yes | Callback used to return the widget ID. |
+
+**Example**
+
+ ```js
+ var want = {
+ abilityName: "FormAbility",
+ parameters: {
+ "ohos.extra.param.key.form_dimension": 2,
+ "ohos.extra.param.key.form_name": "widget",
+ "ohos.extra.param.key.module_name": "entry"
+ }
+ };
+ formProvider.requestPublishForm(want, (error, data) => {
+ if (error.code) {
+ console.log('formProvider requestPublishForm, error: ' + JSON.stringify(error));
+ } else {
+ console.log('formProvider requestPublishForm, form ID is: ' + JSON.stringify(data));
+ }
+ });
+ ```
+
+## requestPublishForm9+
+
+requestPublishForm(want: Want, formBindingData?: formBindingData.FormBindingData): Promise<string>;
+
+Requests to publish a widget to the widget host. This API uses a promise to return the result.
+
+**System capability**
+
+SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| --------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
+| want | [Want](js-apis-application-Want.md) | Yes | Information about the target widget. **abilityName**: ability of the target widget. **parameters**: "ohos.extra.param.key.form_dimension" "ohos.extra.param.key.form_name" "ohos.extra.param.key.module_name" |
+| formBindingData | [FormBindingData](js-apis-formbindingdata.md#formbindingdata) | No | Data used for creating the widget. |
+
+**Return value**
+
+| Type | Description |
+| :------------ | :---------------------------------- |
+| Promise<string> | Promise used to return the widget ID.|
+
+**Example**
+
+ ```js
+ var want = {
+ abilityName: "FormAbility",
+ parameters: {
+ "ohos.extra.param.key.form_dimension": 2,
+ "ohos.extra.param.key.form_name": "widget",
+ "ohos.extra.param.key.module_name": "entry"
+ }
+ };
+ formProvider.requestPublishForm(want).then((data) => {
+ console.log('formProvider requestPublishForm success, form ID is :' + JSON.stringify(data));
+ }).catch((error) => {
+ console.log('formProvider requestPublishForm, error: ' + JSON.stringify(error));
+ });
+ ```
+
+## isRequestPublishFormSupported9+
+
+isRequestPublishFormSupported(callback: AsyncCallback<boolean>): void;
+
+Checks whether a widget can be published to the widget host. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Ability.Form
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ------- |
+| callback | AsyncCallback<boolean> | Yes| Callback used to return the result.|
+
+**Example**
+
+```js
+formProvider.isRequestPublishFormSupported((error, isSupported) => {
+ if (error.code) {
+ console.log('formProvider isRequestPublishFormSupported, error:' + JSON.stringify(error));
+ } else {
+ if (isSupported) {
+ var want = {
+ abilityName: "FormAbility",
+ parameters: {
+ "ohos.extra.param.key.form_dimension": 2,
+ "ohos.extra.param.key.form_name": "widget",
+ "ohos.extra.param.key.module_name": "entry"
+ }
+ };
+ formProvider.requestPublishForm(want, (error, data) => {
+ if (error.code) {
+ console.log('formProvider requestPublishForm, error: ' + JSON.stringify(error));
+ } else {
+ console.log('formProvider requestPublishForm, form ID is: ' + JSON.stringify(data));
+ }
+ });
+ }
+ }
+});
+```
+
+## isRequestPublishFormSupported9+
+
+isRequestPublishFormSupported(): Promise<boolean>;
+
+Checks whether a widget can be published to the widget host. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Ability.Form
+
+**Return value**
+
+| Type | Description |
+| :------------ | :---------------------------------- |
+| Promise<boolean> | Promise used to return the result.|
+
+**Example**
+
+```js
+formProvider.isRequestPublishFormSupported().then((isSupported) => {
+ if (isSupported) {
+ var want = {
+ abilityName: "FormAbility",
+ parameters: {
+ "ohos.extra.param.key.form_dimension": 2,
+ "ohos.extra.param.key.form_name": "widget",
+ "ohos.extra.param.key.module_name": "entry"
+ }
+ };
+ formProvider.requestPublishForm(want).then((data) => {
+ console.log('formProvider requestPublishForm success, form ID is :' + JSON.stringify(data));
+ }).catch((error) => {
+ console.log('formProvider requestPublishForm, error: ' + JSON.stringify(error));
+ });
+ }
+}).catch((error) => {
+ console.log('formProvider isRequestPublishFormSupported, error:' + JSON.stringify(error));
+});
+```
diff --git a/en/application-dev/reference/apis/js-apis-geolocation.md b/en/application-dev/reference/apis/js-apis-geolocation.md
index 7d4694bfa7cac837438ecd4f38a9f414316e92e0..01a012065ab52ac2e7a1dc781b608ec865394c31 100644
--- a/en/application-dev/reference/apis/js-apis-geolocation.md
+++ b/en/application-dev/reference/apis/js-apis-geolocation.md
@@ -1,5 +1,6 @@
# Geolocation
+Location services provide basic functions such as GNSS positioning, network positioning, geocoding, reverse geocoding, country code and geofencing.
>  **NOTE**
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
@@ -695,7 +696,7 @@ This is a system API and cannot be called by third-party applications.
disableLocation(callback: AsyncCallback<boolean>) : void;
-Enables the location service. This API uses an asynchronous callback to return the result.
+Disables the location service. This API uses an asynchronous callback to return the result.
This is a system API and cannot be called by third-party applications.
@@ -722,7 +723,7 @@ This is a system API and cannot be called by third-party applications.
disableLocation() : Promise<boolean>
-Enables the location service. This API uses a promise to return the result.
+Disables the location service. This API uses a promise to return the result.
This is a system API and cannot be called by third-party applications.
diff --git a/en/application-dev/reference/apis/js-apis-hashmap.md b/en/application-dev/reference/apis/js-apis-hashmap.md
index 434f68b4b0324fe381961d64a00babcbba7d1d98..d1ac45e3bd10590be109ded2095405e4dee962de 100644
--- a/en/application-dev/reference/apis/js-apis-hashmap.md
+++ b/en/application-dev/reference/apis/js-apis-hashmap.md
@@ -1,27 +1,32 @@
# Nonlinear Container HashMap
->  **NOTE**
+> **NOTE**
+>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+**HashMap** is a map implemented based on the array, linked list, and red-black tree. It provides efficient data query, insertion, and removal. The elements in a **HashMap** instance are mappings of key-value pairs. Each key must be unique and have only one value.
+
+**HashMap** is faster in accessing data than **[TreeMap](js-apis-treemap.md)**, because the former accesses the keys based on the hash codes, whereas the latter stores and accesses the keys in sorted order.
+
+**[HashSet](js-apis-hashset.md)** is implemented based on **HashMap**. The input parameter of **HashMap** consists of **key** and **value**. In **HashSet**, only the **value** object is processed.
+
+**Recommended use case**: Use **HashMap** when you need to quickly access, remove, and insert key-value pairs.
## Modules to Import
```ts
-import HashMap from '@ohos.util.HashMap'
+import HashMap from '@ohos.util.HashMap';
```
-## System Capabilities
-
-SystemCapability.Utils.Lang
-
## HashMap
-
### Attributes
+**System capability**: SystemCapability.Utils.Lang
+
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| length | number | Yes| No| Number of entries in a hash map (called container later).|
+| length | number | Yes| No| Number of elements in a hash map (called container later).|
### constructor
@@ -30,6 +35,8 @@ constructor()
A constructor used to create a **HashMap** instance.
+**System capability**: SystemCapability.Utils.Lang
+
**Example**
```ts
@@ -41,7 +48,9 @@ let hashMap = new HashMap();
isEmpty(): boolean
-Checks whether this container is empty (contains no entry).
+Checks whether this container is empty (contains no element).
+
+**System capability**: SystemCapability.Utils.Lang
**Return value**
@@ -63,11 +72,13 @@ hasKey(key: K): boolean
Checks whether this container contains the specified key.
+**System capability**: SystemCapability.Utils.Lang
+
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| key | K | Yes| Key to check.|
+| key | K | Yes| Target key.|
**Return value**
@@ -91,11 +102,13 @@ hasValue(value: V): boolean
Checks whether this container contains the specified value.
+**System capability**: SystemCapability.Utils.Lang
+
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| value | V | Yes| Value to check.|
+| value | V | Yes| Target value.|
**Return value**
@@ -119,11 +132,13 @@ get(key: K): V
Obtains the value of the specified key in this container.
+**System capability**: SystemCapability.Utils.Lang
+
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| key | K | Yes| Key to query.|
+| key | K | Yes| Target key.|
**Return value**
@@ -145,13 +160,15 @@ let result = hashMap.get("sdfs");
setAll(map: HashMap): void
-Adds all entries in a **HashMap** instance to this container.
+Adds all elements in a **HashMap** instance to this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| map | HashMap | Yes| **HashMap** instance whose entries are to be added to the current container.|
+| map | HashMap | Yes| **HashMap** instance whose elements are to be added to the current container.|
**Example**
@@ -168,20 +185,22 @@ hashMap.setAll(newHashMap);
set(key: K, value: V): Object
-Adds an entry to this container.
+Adds an element to this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| key | K | Yes| Key of the entry to add.|
-| value | V | Yes| Value of the entry to add.|
+| key | K | Yes| Key of the target element.|
+| value | V | Yes| Value of the element.|
**Return value**
| Type| Description|
| -------- | -------- |
-| Object | Container that contains the new entry.|
+| Object | Container that contains the new element.|
**Example**
@@ -195,19 +214,21 @@ let result = hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
remove(key: K): V
-Removes an entry with the specified key from this container.
+Removes an element with the specified key from this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| key | K | Yes| Key of the entry to remove.|
+| key | K | Yes| Key of the target element.|
**Return value**
| Type| Description|
| -------- | -------- |
-| V | Value of the entry removed.|
+| V | Value of the element.|
**Example**
@@ -225,6 +246,8 @@ clear(): void
Clears this container and sets its length to **0**.
+**System capability**: SystemCapability.Utils.Lang
+
**Example**
```ts
@@ -239,7 +262,9 @@ hashMap.clear();
keys(): IterableIterator<K>
-Obtains an iterator that contains all the entries in this container.
+Obtains an iterator that contains all the elements in this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Return value**
@@ -256,7 +281,7 @@ hashMap.set("sdfs", 356);
let iter = hashMap.keys();
let temp = iter.next().value;
while(temp != undefined) {
- console.log(temp);
+ console.log("value:" + temp);
temp = iter.next().value;
}
```
@@ -268,6 +293,8 @@ values(): IterableIterator<V>
Obtains an iterator that contains all the values in this container.
+**System capability**: SystemCapability.Utils.Lang
+
**Return value**
| Type| Description|
@@ -283,7 +310,7 @@ hashMap.set("sdfs", 356);
let iter = hashMap.values();
let temp = iter.next().value;
while(temp != undefined) {
- console.log(temp);
+ console.log("value:" + temp);
temp = iter.next().value;
}
```
@@ -293,20 +320,22 @@ while(temp != undefined) {
replace(key: K, newValue: V): boolean
-Replaces an entry in this container.
+Replaces an element in this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| key | K | Yes| Key of the entry to replace.|
-| newValue | V | Yes| New value of the entry.|
+| key | K | Yes| Key of the target element.|
+| newValue | V | Yes| New value of the element.|
**Return value**
| Type| Description|
| -------- | -------- |
-| boolean | Returns **true** if the entry is replaced successfully; returns **false** otherwise.|
+| boolean | Returns **true** if the element is replaced successfully; returns **false** otherwise.|
**Example**
@@ -321,20 +350,22 @@ let result = hashMap.replace("sdfs", 357);
forEach(callbackfn: (value?: V, key?: K, map?: HashMap) => void, thisArg?: Object): void
-Uses a callback to traverse the entries in this container and obtain their position indexes.
+Uses a callback to traverse the elements in this container and obtain their position indexes.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| callbackfn | function | Yes| Callback invoked to traverse the entries in the container.|
+| callbackfn | function | Yes| Callback invoked to traverse the elements in the container.|
| thisArg | Object | No| Value to use when the callback is invoked.|
callbackfn
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| value | V | No| Value of the entry that is currently traversed.|
-| key | K | No| Key of the entry that is currently traversed.|
+| value | V | No| Value of the element that is currently traversed.|
+| key | K | No| Key of the element that is currently traversed.|
| map | HashMap | No| Instance that invokes the **forEach** method.|
**Example**
@@ -344,7 +375,7 @@ let hashMap = new HashMap();
hashMap.set("sdfs", 123);
hashMap.set("dfsghsf", 357);
hashMap.forEach((value, key) => {
- console.log(value, key);
+ console.log("value:" + value, key);
});
```
@@ -353,7 +384,9 @@ hashMap.forEach((value, key) => {
entries(): IterableIterator<[K, V]>
-Obtains an iterator that contains all the entries in this container.
+Obtains an iterator that contains all the elements in this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Return value**
@@ -370,8 +403,8 @@ hashMap.set("sdfs", 356);
let iter = hashMap.entries();
let temp = iter.next().value;
while(temp != undefined) {
- console.log(temp[0]);
- console.log(temp[1]);
+ console.log("key:" + temp[0]);
+ console.log("value:" + temp[1]);
temp = iter.next().value;
}
```
@@ -383,6 +416,8 @@ while(temp != undefined) {
Obtains an iterator, each item of which is a JavaScript object.
+**System capability**: SystemCapability.Utils.Lang
+
**Return value**
| Type| Description|
@@ -397,16 +432,16 @@ hashMap.set("sdfs", 356);
// Method 1:
for (let item of hashMap) {
- console.log("key: " + item[0]);
- console.log("value: " + item[1]);
+ console.log("key:" + item[0]);
+ console.log("value:" + item[1]);
}
// Method 2:
let iter = hashMap[Symbol.iterator]();
let temp = iter.next().value;
while(temp != undefined) {
- console.log(temp[0]);
- console.log(temp[1]);
+ console.log("key:" + temp[0]);
+ console.log("value:" + temp[1]);
temp = iter.next().value;
}
```
diff --git a/en/application-dev/reference/apis/js-apis-hashset.md b/en/application-dev/reference/apis/js-apis-hashset.md
index 605aa184364b76c5695390db18d63bcf6cbff689..85bbfa2719412099c1d051de61b3c39363872b27 100644
--- a/en/application-dev/reference/apis/js-apis-hashset.md
+++ b/en/application-dev/reference/apis/js-apis-hashset.md
@@ -1,8 +1,14 @@
# Nonlinear Container HashSet
->  **NOTE**
+> **NOTE**
+>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+**HashSet** is implemented based on [HashMap](js-apis-hashmap.md). In **HashSet**, only the **value** object is processed.
+
+Unlike [TreeSet](js-apis-treeset.md), which stores and accesses data in sorted order, **HashSet** stores data in a random order. This means that **HashSet** may use a different order when storing and accessing elements. Both of them allows only unique elements. However, null values are allowed in **HashSet**, but not allowed in **TreeSet**.
+
+**Recommended use case**: Use **HashSet** when you need a set that has only unique elements or need to deduplicate a set.
## Modules to Import
@@ -10,18 +16,15 @@
import HashSet from '@ohos.util.HashSet';
```
-## System Capabilities
-
-SystemCapability.Utils.Lang
-
## HashSet
-
### Attributes
+**System capability**: SystemCapability.Utils.Lang
+
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| length | number | Yes| No| Number of entries in a hash set (called container later).|
+| length | number | Yes| No| Number of elements in a hash set (called container later).|
### constructor
@@ -30,6 +33,8 @@ constructor()
A constructor used to create a **HashSet** instance.
+**System capability**: SystemCapability.Utils.Lang
+
**Example**
```ts
@@ -41,7 +46,9 @@ let hashSet = new HashSet();
isEmpty(): boolean
-Checks whether this container is empty (contains no entry).
+Checks whether this container is empty (contains no element).
+
+**System capability**: SystemCapability.Utils.Lang
**Return value**
@@ -61,19 +68,21 @@ let result = hashSet.isEmpty();
has(value: T): boolean
-Checks whether this container contains the specified entry.
+Checks whether this container contains the specified element.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| value | T | Yes| Entry to check.|
+| value | T | Yes| Target element.|
**Return value**
| Type| Description|
| -------- | -------- |
-| boolean | Returns **true** if the specified entry is contained; returns **false** otherwise.|
+| boolean | Returns **true** if the specified element is contained; returns **false** otherwise.|
**Example**
@@ -89,19 +98,21 @@ let result1 = hashSet.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
add(value: T): boolean
-Adds an entry to this container.
+Adds an element to this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| value | T | Yes| Entry to add.|
+| value | T | Yes| Target element.|
**Return value**
| Type| Description|
| -------- | -------- |
-| boolean | Returns **true** if the entry is added successfully; returns **false** otherwise.|
+| boolean | Returns **true** if the element is added successfully; returns **false** otherwise.|
**Example**
@@ -115,19 +126,21 @@ let result = hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
remove(value: T): boolean
-Removes an entry from this container.
+Removes an element from this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| value | T | Yes| Entry to remove.|
+| value | T | Yes| Target element.|
**Return value**
| Type| Description|
| -------- | -------- |
-| boolean | Returns **true** if the entry is removed successfully; returns **false** otherwise.|
+| boolean | Returns **true** if the element is removed successfully; returns **false** otherwise.|
**Example**
@@ -145,6 +158,8 @@ clear(): void
Clears this container and sets its length to **0**.
+**System capability**: SystemCapability.Utils.Lang
+
**Example**
```ts
@@ -161,6 +176,8 @@ values(): IterableIterator<T>
Obtains an iterator that contains all the values in this container.
+**System capability**: SystemCapability.Utils.Lang
+
**Return value**
| Type| Description|
@@ -176,7 +193,7 @@ hashSet.add("sdfs");
let iter = hashSet.values();
let temp = iter.next().value;
while(temp != undefined) {
- console.log(temp);
+ console.log("value:" + temp);
temp = iter.next().value;
}
```
@@ -186,20 +203,22 @@ while(temp != undefined) {
forEach(callbackfn: (value?: T, key?: T, set?: HashSet<T>) => void, thisArg?: Object): void
-Uses a callback to traverse the entries in this container and obtain their position indexes.
+Uses a callback to traverse the elements in this container and obtain their position indexes.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| callbackfn | function | Yes| Callback invoked to traverse the entries in the container.|
+| callbackfn | function | Yes| Callback invoked to traverse the elements in the container.|
| thisArg | Object | No| Value to use when the callback is invoked.|
callbackfn
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| value | T | No| Value of the entry that is currently traversed.|
-| key | T | No| Key of the entry that is currently traversed (same as **value**).|
+| value | T | No| Value of the element that is currently traversed.|
+| key | T | No| Key of the element that is currently traversed (same as **value**).|
| set | HashSet<T> | No| Instance that invokes the **forEach** method.|
**Example**
@@ -209,7 +228,7 @@ let hashSet = new HashSet();
hashSet.add("sdfs");
hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
hashSet.forEach((value, key) => {
- console.log(value, key);
+ console.log("value:" + value, key);
});
```
@@ -217,7 +236,9 @@ hashSet.forEach((value, key) => {
### entries
entries(): IterableIterator<[T, T]>
-Obtains an iterator that contains all the entries in this container.
+Obtains an iterator that contains all the elements in this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Return value**
@@ -234,8 +255,8 @@ hashSet.add("sdfs");
let iter = hashSet.entries();
let temp = iter.next().value;
while(temp != undefined) {
- console.log(temp[0]);
- console.log(temp[1]);
+ console.log("key:" + temp[0]);
+ console.log("value:" + temp[1]);
temp = iter.next().value;
}
```
@@ -247,6 +268,8 @@ while(temp != undefined) {
Obtains an iterator, each item of which is a JavaScript object.
+**System capability**: SystemCapability.Utils.Lang
+
**Return value**
| Type| Description|
@@ -269,7 +292,7 @@ for (let item of hashSet) {
let iter = hashSet[Symbol.iterator]();
let temp = iter.next().value;
while(temp != undefined) {
- console.log(temp);
+ console.log("value: " + temp);
temp = iter.next().value;
}
```
diff --git a/en/application-dev/reference/apis/js-apis-hiappevent.md b/en/application-dev/reference/apis/js-apis-hiappevent.md
index f75b45946a8f5aa6541ce502c7ff58673ecd4e8a..c684f0ea4f3c4cdd77de4e189b00e15f41a82855 100644
--- a/en/application-dev/reference/apis/js-apis-hiappevent.md
+++ b/en/application-dev/reference/apis/js-apis-hiappevent.md
@@ -1,5 +1,7 @@
# HiAppEvent
+This module provides the application event logging functions, such as writing application events to the event file and managing the event logging configuration.
+
>  **NOTE**
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
diff --git a/en/application-dev/reference/apis/js-apis-hilog.md b/en/application-dev/reference/apis/js-apis-hilog.md
index 107d3419b8a8b2840d54b90c5e239ea2fea85ac3..c01d3ce2f21c64cca00b453a3d3a6448b84fc22f 100644
--- a/en/application-dev/reference/apis/js-apis-hilog.md
+++ b/en/application-dev/reference/apis/js-apis-hilog.md
@@ -1,7 +1,6 @@
# HiLog
The HiLog subsystem allows your applications or services to output logs based on the specified type, level, and format string. Such logs help you learn the running status of applications and better debug programs.
-This document describes only API functions. For details about log printing requirements, see [Logging Guide](../../../contribute/OpenHarmony-Log-guide.md).
> **NOTE**
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
@@ -24,7 +23,7 @@ Checks whether logs are printable based on the specified service domain, log tag
| Name| Type | Mandatory| Description |
| ------ | --------------------- | ---- | ------------------------------------------------------------ |
-| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**. You can define the value as required.|
+| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**. You can define the value within your application as required.|
| tag | string | Yes | Log tag in the string format. You are advised to use this parameter to identify a particular service behavior or the class holding the ongoing method.|
| level | [LogLevel](#loglevel) | Yes | Log level. |
@@ -68,7 +67,7 @@ DEBUG logs are not recorded in official versions by default. They are available
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------------------------------ |
-| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**. You can define the value as required.|
+| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**. You can define the value within your application as required.|
| tag | string | Yes | Log tag in the string format. You are advised to use this parameter to identify a particular service behavior or the class holding the ongoing method.|
| format | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory. Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by ****.|
| args | any[] | Yes | Variable-length parameter list corresponding to the format string. The number and type of parameters must map to the identifier in the format string.|
@@ -99,7 +98,7 @@ Prints INFO logs.
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------------------------------ |
-| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**. You can define the value as required.|
+| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**. You can define the value within your application as required.|
| tag | string | Yes | Log tag in the string format. You are advised to use this parameter to identify a particular service behavior or the class holding the ongoing method.|
| format | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory. Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by ****.|
| args | any[] | Yes | Variable-length parameter list corresponding to the format string. The number and type of parameters must map to the identifier in the format string.|
@@ -130,7 +129,7 @@ Prints WARN logs.
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------------------------------ |
-| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**. You can define the value as required.|
+| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**. You can define the value within your application as required.|
| tag | string | Yes | Log tag in the string format. You are advised to use this parameter to identify a particular service behavior or the class holding the ongoing method.|
| format | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory. Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by ****.|
| args | any[] | Yes | Variable-length parameter list corresponding to the format string. The number and type of parameters must map to the identifier in the format string.|
@@ -161,7 +160,7 @@ Prints ERROR logs.
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------------------------------ |
-| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**. You can define the value as required.|
+| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**. You can define the value within your application as required.|
| tag | string | Yes | Log tag in the string format. You are advised to use this parameter to identify a particular service behavior or the class holding the ongoing method.|
| format | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory. Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by ****.|
| args | any[] | Yes | Variable-length parameter list corresponding to the format string. The number and type of parameters must map to the identifier in the format string.|
@@ -192,7 +191,7 @@ Prints FATAL logs.
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------------------------------ |
-| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**. You can define the value as required.|
+| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**. You can define the value within your application as required.|
| tag | string | Yes | Log tag in the string format. You are advised to use this parameter to identify a particular service behavior or the class holding the ongoing method.|
| format | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory. Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by ****.|
| args | any[] | Yes | Variable-length parameter list corresponding to the format string. The number and type of parameters must map to the identifier in the format string.|
diff --git a/en/application-dev/reference/apis/js-apis-hisysevent.md b/en/application-dev/reference/apis/js-apis-hisysevent.md
new file mode 100644
index 0000000000000000000000000000000000000000..5564b1a7fc8024284fabf6ada9efaa08f8d0cb73
--- /dev/null
+++ b/en/application-dev/reference/apis/js-apis-hisysevent.md
@@ -0,0 +1,345 @@
+# System Event Logging
+
+Provides system event logging APIs for system HAP applications.
+
+> **NOTE**
+> - The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+> - The APIs of this module are system APIs and cannot be called by third-party applications.
+
+
+## Modules to Import
+
+```js
+import hiSysEvent from '@ohos.hiSysEvent';
+```
+
+## EventType
+
+Enumerates event types.
+
+**System capability**: SystemCapability.HiviewDFX.HiSysEvent
+
+| Name| Default Value| Description|
+| -------- | -------- | -------- |
+| FAULT | 1 | Error event.|
+| STATISTIC | 2 | Statistic event.|
+| SECURITY | 3 | Security event.|
+| BEHAVIOR | 4 | User behavior event.|
+
+## SysEventInfo
+
+Defines a system event.
+
+**System capability**: SystemCapability.HiviewDFX.HiSysEvent
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| domain | string | Yes| Event domain.|
+| name | string | Yes| Event name.|
+| eventType | [EventType](#eventtype) | Yes| Event type.|
+| params | object | No| Event parameters.|
+
+
+## hiSysEvent.write
+
+write(info: SysEventInfo, callback: AsyncCallback<void>): void
+
+Writes event information to the event file. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.HiviewDFX.HiSysEvent
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| --------- | ------------------------- | ---- | ------------------------------------------------------------ |
+| info | [SysEventInfo](#syseventinfo) | Yes| System event information.|
+| callback | AsyncCallback<void> | Yes| Callback used to process the received return value. - Value **0**: The event verification is successful, and the event will be written to the event file asynchronously. - A value greater than **0**: Invalid parameters are present in the event, and the event will be written to the event file asynchronously after the invalid parameters are ignored. - A value smaller than **0**: The event parameter verification fails, and the event will not be written to the event file.|
+
+**Example**
+
+```js
+import hiSysEvent from '@ohos.hiSysEvent';
+
+hiSysEvent.write({
+ domain: "RELIABILITY",
+ name: "STACK",
+ eventType: hiSysEvent.EventType.FAULT,
+ params: {
+ PID: 487,
+ UID: 103,
+ PACKAGE_NAME: "com.ohos.hisysevent.test",
+ PROCESS_NAME: "syseventservice",
+ MSG: "no msg."
+ }
+}, (err, val) => {
+ // do something here.
+})
+```
+
+
+## hiSysEvent.write
+
+write(info: SysEventInfo): Promise<void>
+
+Writes event information to the event file. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.HiviewDFX.HiSysEvent
+
+**Parameters**
+
+| Name | Type | Mandatory| Description|
+| --------- | ----------------------- | ---- | --------------- |
+| eventType | [EventType](#eventtype) | Yes | Application event type.|
+
+**Return value**
+
+| Type | Description |
+| ------------------- | ------------------------------------------------------------ |
+| Promise<void> | Promise used to return the result. Depending on whether event writing is successful, you can use the **then()** or **catch()** method to process the callback.|
+
+**Example**
+
+```js
+import hiSysEvent from '@ohos.hiSysEvent';
+
+hiSysEvent.write({
+ domain: "RELIABILITY",
+ name: "STACK",
+ eventType: hiSysEvent.EventType.FAULT,
+ params: {
+ PID: 487,
+ UID: 103,
+ PACKAGE_NAME: "com.ohos.hisysevent.test",
+ PROCESS_NAME: "syseventservice",
+ MSG: "no msg."
+ }
+}).then(
+ (val) => {
+ // do something here.
+ }
+).catch(
+ (err) => {
+ // do something here.
+ }
+)
+```
+
+## RuleType
+
+Enumerates matching rule types.
+
+**System capability**: SystemCapability.HiviewDFX.HiSysEvent
+
+| Name| Default Value| Description|
+| -------- | -------- | -------- |
+| WHOLE_WORD | 1 | Whole word matching.|
+| PREFIX | 2 | Prefix matching.|
+| REGULAR | 3 | Regular expression matching.|
+
+## WatchRule
+
+Defines rules for event subscription.
+
+**System capability**: SystemCapability.HiviewDFX.HiSysEvent
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| domain | string | Yes| Event domain.|
+| name | string | Yes| Event name.|
+| tag | string | No| Event tag.|
+| ruleType | [RuleType](#ruletype) | Yes| Matching rule type.|
+
+## Watcher
+
+Defines a watcher for event subscription.
+
+**System capability**: SystemCapability.HiviewDFX.HiSysEvent
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| rules | [WatchRule](#watchrule)[] | Yes| Array of matching rules for event subscription.|
+| onEvent | function | Yes| Callback for event subscription: (info: [SysEventInfo](#syseventinfo)) => void|
+| onServiceDied | function | Yes| Callback for disabling of event subscription: () => void|
+
+## hiSysEvent.addWatcher
+
+addWatcher(watcher: Watcher): number
+
+Adds a watcher for event subscription.
+
+**Required permission**: ohos.permission.READ_DFX_SYSEVENT
+
+**System capability**: SystemCapability.HiviewDFX.HiSysEvent
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| ------ | ----------------------------- | ---- | ------------------------ |
+| watcher | [Watcher](#watcher) | Yes| Watcher for event subscription.|
+
+**Return value**
+
+| Type | Description|
+| ------- | -------------------------------------------------- |
+| number | Event subscription result. - **0**: Event subscription is successful. - A value smaller than **0**: Event subscription has failed.|
+
+**Example**
+
+```js
+import hiSysEvent from '@ohos.hiSysEvent';
+
+let watcher = {
+ rules: [{
+ domain: "RELIABILITY",
+ name: "STACK",
+ tag: "STABILITY",
+ ruleType: hiSysEvent.RuleType.WHOLE_WORD,
+ }],
+ onEvent: (info) => {
+ // do something here.
+ },
+ onServiceDied: () => {
+ // do something here.
+ }
+}
+let ret = hiSysEvent.addWatcher(watcher)
+```
+
+## hiSysEvent.removeWatcher
+
+removeWatcher(wathcer: Watcher): number
+
+Removes a watcher used for event subscription.
+
+**Required permission**: ohos.permission.READ_DFX_SYSEVENT
+
+**System capability**: SystemCapability.HiviewDFX.HiSysEvent
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------------- | ---- | ------------------------ |
+| watcher | [Watcher](#watcher) | Yes| Watcher for event subscription.|
+
+**Return value**
+
+| Type | Description|
+| ------- | ----------------------------------------------------------- |
+| number | Result of removing the watcher. - **0**: Removing the watcher is successful. - A value smaller than **0**: Removing the watcher has failed.|
+
+**Example**
+
+```js
+import hiSysEvent from '@ohos.hiSysEvent';
+
+let watcher = {
+ rules: [{
+ domain: "RELIABILITY",
+ name: "STACK",
+ tag: "STABILITY",
+ ruleType: hiSysEvent.RuleType.WHOLE_WORD,
+ }],
+ onEvent: (info) => {
+ // do something here.
+ },
+ onServiceDied: () => {
+ // do something here.
+ }
+}
+let ret = hiSysEvent.addWatcher(watcher)
+hiSysEvent.removeWatcher(watcher)
+```
+
+## QueryArg
+
+Defines arguments for event query.
+
+**System capability**: SystemCapability.HiviewDFX.HiSysEvent
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| beginTime | number | Yes| Start time (13-digit timestamp) for event query.|
+| endTime | number | Yes| End time (13-digit timestamp) for event query.|
+| maxEvents | number | Yes| Maximum number of events that can be queried.|
+
+## QueryRule
+
+Defines rules for event query.
+
+**System capability**: SystemCapability.HiviewDFX.HiSysEvent
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| domain | string | Yes| Event domain.|
+| names | string[] | Yes| Array of event names.|
+
+## Querier
+
+Defines an event query instance.
+
+**System capability**: SystemCapability.HiviewDFX.HiSysEvent
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| onQuery | function | Yes| Callback of queried events: (infos: [SysEventInfo](#syseventinfo)[], seqs: number[]) => void|
+| onComplete | function | Yes| Callback of query result statistics: (reason: number, total: number) => void|
+
+## hiSysEvent.query
+
+query(queryArg: QueryArg, rules: QueryRule[], querier: Querier): number
+
+Queries system events.
+
+**Required permission**: ohos.permission.READ_DFX_SYSEVENT
+
+**System capability**: SystemCapability.HiviewDFX.HiSysEvent
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| ------ | ----------------------------- | ---- | ------------------------ |
+| queryArg | [QueryArg](#queryarg) | Yes | Arguments for event query.|
+| rules | [QueryRule](#queryrule)[] | Yes | Array of event query rules.|
+| querier | [Querier](#querier) | Yes | Event query instance.|
+
+**Return value**
+
+| Type | Description |
+| ------- | ----------------------------------------------------------- |
+| number | Event query result. - **0**: Event query is successful. - A value smaller than **0**: Event query has failed.|
+
+**Example**
+
+```js
+import hiSysEvent from '@ohos.hiSysEvent';
+
+hiSysEvent.write({
+ domain: "RELIABILITY",
+ name: "STACK",
+ eventType: hiSysEvent.EventType.FAULT,
+ params: {
+ PID: 487,
+ UID: 103,
+ PACKAGE_NAME: "com.ohos.hisysevent.test",
+ PROCESS_NAME: "syseventservice",
+ MSG: "no msg."
+ }
+}, (err, val) => {
+ // do something here.
+})
+hiSysEvent.query({
+ beginTime: -1,
+ endTime: -1,
+ maxEvents: 5,
+}, [{
+ domain: "RELIABILITY",
+ names: ["STACK"],
+}], {
+ onQuery: function (infos, seqs) {
+ // do something here.
+ },
+ onComplete: function(reason, total) {
+ // do something here.
+ }
+})
+```
diff --git a/en/application-dev/reference/apis/js-apis-hitracechain.md b/en/application-dev/reference/apis/js-apis-hitracechain.md
index 485eddc0fbfb59946228e859760885ad0ce1b633..cbaf898f75c37ba8921fe3d8ffd11e5484ec28e8 100644
--- a/en/application-dev/reference/apis/js-apis-hitracechain.md
+++ b/en/application-dev/reference/apis/js-apis-hitracechain.md
@@ -1,5 +1,7 @@
# Distributed Call Chain Tracing
+This module implements call chain tracing throughout a service process. It provides functions such as starting and stopping call chain tracing and configuring trace points.
+
>  **NOTE**
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
diff --git a/en/application-dev/reference/apis/js-apis-hitracemeter.md b/en/application-dev/reference/apis/js-apis-hitracemeter.md
index 656063edf90a71a74e8f7b5e90375acfccfdae9c..e856ee20a4c8956ff0f05707b596935b68ca9e7a 100644
--- a/en/application-dev/reference/apis/js-apis-hitracemeter.md
+++ b/en/application-dev/reference/apis/js-apis-hitracemeter.md
@@ -1,5 +1,7 @@
# Performance Tracing
+This module provides the functions of tracing service processes and monitoring the system performance. It provides the data needed for hiTraceMeter to carry out performance analysis.
+
>  **NOTE**
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
diff --git a/en/application-dev/reference/apis/js-apis-huks.md b/en/application-dev/reference/apis/js-apis-huks.md
index fee69291fd7aac23115a01f4d3f59e5f53311120..35a2a3e6a1067c9a9dd26bb8d2ae0e9d39ffcc2e 100644
--- a/en/application-dev/reference/apis/js-apis-huks.md
+++ b/en/application-dev/reference/apis/js-apis-huks.md
@@ -1,11 +1,11 @@
# HUKS
->  **NOTE**
+>  **NOTE**
>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
-OpenHarmony Universal KeyStore (HUKS) provides KeyStore (KS) capabilities for applications, including key management and key cryptography operations.
-HUKS also provides APIs for applications to import or generate keys.
+Provides KeyStore (KS) capabilities for applications, including key management and key cryptography operations.
+The keys managed by OpenHarmony Universal KeyStore (HUKS) can be imported by applications or generated by calling the HUKS APIs.
## Modules to Import
@@ -20,73 +20,75 @@ Enumerates the error codes.
| Name | Value | Description|
| -------------------------- | ----- | ---- |
-| HUKS_SUCCESS | 0 |Success. |
-| HUKS_FAILURE | -1 |Failure. |
-| HUKS_ERROR_BAD_STATE | -2 |Incorrect state. |
-| HUKS_ERROR_INVALID_ARGUMENT | -3 |Invalid argument. |
-| HUKS_ERROR_NOT_SUPPORTED | -4 |Not supported. |
-| HUKS_ERROR_NO_PERMISSION | -5 |No permission. |
-| HUKS_ERROR_INSUFFICIENT_DATA | -6 |Insufficient data. |
-| HUKS_ERROR_BUFFER_TOO_SMALL | -7 |Insufficient buffer. |
-| HUKS_ERROR_INSUFFICIENT_MEMORY | -8 |Insufficient memory. |
-| HUKS_ERROR_COMMUNICATION_FAILURE | -9 |Communication failure. |
-| HUKS_ERROR_STORAGE_FAILURE | -10 |Storage failure. |
-| HUKS_ERROR_HARDWARE_FAILURE | -11 |Hardware fault. |
-| HUKS_ERROR_ALREADY_EXISTS | -12 |The object already exists. |
-| HUKS_ERROR_NOT_EXIST | -13 |The object does not exist. |
-| HUKS_ERROR_NULL_POINTER | -14 |Null pointer. |
-| HUKS_ERROR_FILE_SIZE_FAIL | -15 |Incorrect file size. |
-| HUKS_ERROR_READ_FILE_FAIL | -16 |Failed to read the file. |
-| HUKS_ERROR_INVALID_PUBLIC_KEY | -17 |Invalid public key. |
-| HUKS_ERROR_INVALID_PRIVATE_KEY | -18 |Invalid private key. |
-| HUKS_ERROR_INVALID_KEY_INFO | -19 |Invalid key information. |
-| HUKS_ERROR_HASH_NOT_EQUAL | -20 |The hash values are not equal. |
-| HUKS_ERROR_MALLOC_FAIL | -21 |MALLOC failed. |
-| HUKS_ERROR_WRITE_FILE_FAIL | -22 |Failed to write the file. |
-| HUKS_ERROR_REMOVE_FILE_FAIL | -23 |Failed to delete the file. |
-| HUKS_ERROR_OPEN_FILE_FAIL | -24 |Failed to open the file. |
-| HUKS_ERROR_CLOSE_FILE_FAIL | -25 |Failed to close the file. |
-| HUKS_ERROR_MAKE_DIR_FAIL | -26 |Failed to create the directory. |
-| HUKS_ERROR_INVALID_KEY_FILE | -27 |Invalid key file. |
-| HUKS_ERROR_IPC_MSG_FAIL | -28 |Incorrect IPC information. |
-| HUKS_ERROR_REQUEST_OVERFLOWS | -29 |Request overflows. |
-| HUKS_ERROR_PARAM_NOT_EXIST | -30 |The parameter does not exist. |
-| HUKS_ERROR_CRYPTO_ENGINE_ERROR | -31 |CRYPTO ENGINE error. |
-| HUKS_ERROR_COMMUNICATION_TIMEOUT | -32 |Communication timed out. |
-| HUKS_ERROR_IPC_INIT_FAIL | -33 |IPC initialization failed. |
-| HUKS_ERROR_IPC_DLOPEN_FAIL | -34 |IPC DLOPEN failed. |
-| HUKS_ERROR_EFUSE_READ_FAIL | -35 |Failed to read eFUSE. |
-| HUKS_ERROR_NEW_ROOT_KEY_MATERIAL_EXIST | -36 |New root key material exists. |
-| HUKS_ERROR_UPDATE_ROOT_KEY_MATERIAL_FAIL | -37 |Failed to update the root key material. |
-| HUKS_ERROR_VERIFICATION_FAILED | -38 |Failed to verify the certificate chain. |
+| HUKS_SUCCESS | 0 |Success.|
+| HUKS_FAILURE | -1 |Failure.|
+| HUKS_ERROR_BAD_STATE | -2 |Incorrect state.|
+| HUKS_ERROR_INVALID_ARGUMENT | -3 |Invalid argument.|
+| HUKS_ERROR_NOT_SUPPORTED | -4 |Not supported.|
+| HUKS_ERROR_NO_PERMISSION | -5 |No permission.|
+| HUKS_ERROR_INSUFFICIENT_DATA | -6 |Insufficient data.|
+| HUKS_ERROR_BUFFER_TOO_SMALL | -7 |Insufficient buffer.|
+| HUKS_ERROR_INSUFFICIENT_MEMORY | -8 |Insufficient memory.|
+| HUKS_ERROR_COMMUNICATION_FAILURE | -9 |Communication failure.|
+| HUKS_ERROR_STORAGE_FAILURE | -10 |Storage failure.|
+| HUKS_ERROR_HARDWARE_FAILURE | -11 |Hardware fault.|
+| HUKS_ERROR_ALREADY_EXISTS | -12 |The object already exists.|
+| HUKS_ERROR_NOT_EXIST | -13 |The object does not exist.|
+| HUKS_ERROR_NULL_POINTER | -14 |Null pointer.|
+| HUKS_ERROR_FILE_SIZE_FAIL | -15 |Incorrect file size.|
+| HUKS_ERROR_READ_FILE_FAIL | -16 |Failed to read the file.|
+| HUKS_ERROR_INVALID_PUBLIC_KEY | -17 |Invalid public key.|
+| HUKS_ERROR_INVALID_PRIVATE_KEY | -18 |Invalid private key.|
+| HUKS_ERROR_INVALID_KEY_INFO | -19 |Invalid key information.|
+| HUKS_ERROR_HASH_NOT_EQUAL | -20 |The hash values are not equal.|
+| HUKS_ERROR_MALLOC_FAIL | -21 |MALLOC failed.|
+| HUKS_ERROR_WRITE_FILE_FAIL | -22 |Failed to write the file.|
+| HUKS_ERROR_REMOVE_FILE_FAIL | -23 |Failed to delete the file.|
+| HUKS_ERROR_OPEN_FILE_FAIL | -24 |Failed to open the file.|
+| HUKS_ERROR_CLOSE_FILE_FAIL | -25 |Failed to close the file.|
+| HUKS_ERROR_MAKE_DIR_FAIL | -26 |Failed to create the directory.|
+| HUKS_ERROR_INVALID_KEY_FILE | -27 |Invalid key file.|
+| HUKS_ERROR_IPC_MSG_FAIL | -28 |Incorrect IPC information.|
+| HUKS_ERROR_REQUEST_OVERFLOWS | -29 |Request overflows.|
+| HUKS_ERROR_PARAM_NOT_EXIST | -30 |The parameter does not exist.|
+| HUKS_ERROR_CRYPTO_ENGINE_ERROR | -31 |CRYPTO ENGINE error.|
+| HUKS_ERROR_COMMUNICATION_TIMEOUT | -32 |Communication timed out.|
+| HUKS_ERROR_IPC_INIT_FAIL | -33 |IPC initialization failed.|
+| HUKS_ERROR_IPC_DLOPEN_FAIL | -34 |IPC DLOPEN failed.|
+| HUKS_ERROR_EFUSE_READ_FAIL | -35 |Failed to read eFUSE.|
+| HUKS_ERROR_NEW_ROOT_KEY_MATERIAL_EXIST | -36 |New root key material exists.|
+| HUKS_ERROR_UPDATE_ROOT_KEY_MATERIAL_FAIL | -37 |Failed to update the root key material.|
+| HUKS_ERROR_VERIFICATION_FAILED | -38 |Failed to verify the certificate chain.|
| HUKS_ERROR_CHECK_GET_ALG_FAIL | -100 |Failed to check whether the ALG is obtained. |
-| HUKS_ERROR_CHECK_GET_KEY_SIZE_FAIL | -101 |Failed to check whether the key size is obtained. |
-| HUKS_ERROR_CHECK_GET_PADDING_FAIL | -102 |Failed to check whether padding is obtained. |
-| HUKS_ERROR_CHECK_GET_PURPOSE_FAIL | -103 |Failed to check whether the purpose is obtained. |
-| HUKS_ERROR_CHECK_GET_DIGEST_FAIL | -104 |Failed to check whether digest is obtained. |
-| HUKS_ERROR_CHECK_GET_MODE_FAIL | -105 |Failed to check whether the mode is obtained. |
-| HUKS_ERROR_CHECK_GET_NONCE_FAIL | -106 |Failed to check whether the nonce is obtained. |
-| HUKS_ERROR_CHECK_GET_AAD_FAIL | -107 |Failed to check whether the AAD is obtained. |
-| HUKS_ERROR_CHECK_GET_IV_FAIL | -108 |Failed to check whether the initialization vector (IV) is obtained. |
-| HUKS_ERROR_CHECK_GET_AE_TAG_FAIL | -109 |Failed to check whether the AE flag is obtained. |
-| HUKS_ERROR_CHECK_GET_SALT_FAIL | -110 |Failed to check whether the SALT is obtained. |
-| HUKS_ERROR_CHECK_GET_ITERATION_FAIL | -111 |Failed to check whether the iteration is obtained. |
-| HUKS_ERROR_INVALID_ALGORITHM | -112 |Invalid algorithm. |
-| HUKS_ERROR_INVALID_KEY_SIZE | -113 |Invalid key size. |
-| HUKS_ERROR_INVALID_PADDING | -114 |Invalid padding. |
-| HUKS_ERROR_INVALID_PURPOSE | -115 |Invalid purpose. |
-| HUKS_ERROR_INVALID_MODE | -116 |Invalid mode. |
-| HUKS_ERROR_INVALID_DIGEST | -117 |Invalid digest. |
-| HUKS_ERROR_INVALID_SIGNATURE_SIZE | -118 |Invalid signature size. |
-| HUKS_ERROR_INVALID_IV | -119 |Invalid IV. |
-| HUKS_ERROR_INVALID_AAD | -120 |Invalid AAD. |
-| HUKS_ERROR_INVALID_NONCE | -121 |Invalid nonce. |
-| HUKS_ERROR_INVALID_AE_TAG | -122 |Invalid AE tag. |
-| HUKS_ERROR_INVALID_SALT | -123 |Invalid SALT. |
-| HUKS_ERROR_INVALID_ITERATION | -124 |Invalid iteration. |
-| HUKS_ERROR_INVALID_OPERATION | -125 |Invalid operation. |
-| HUKS_ERROR_INTERNAL_ERROR | -999 |Internal error. |
-| HUKS_ERROR_UNKNOWN_ERROR | -1000 |Unknown error. |
+| HUKS_ERROR_CHECK_GET_KEY_SIZE_FAIL | -101 |Failed to check whether the key size is obtained.|
+| HUKS_ERROR_CHECK_GET_PADDING_FAIL | -102 |Failed to check whether padding is obtained.|
+| HUKS_ERROR_CHECK_GET_PURPOSE_FAIL | -103 |Failed to check whether the purpose is obtained.|
+| HUKS_ERROR_CHECK_GET_DIGEST_FAIL | -104 |Failed to check whether digest is obtained.|
+| HUKS_ERROR_CHECK_GET_MODE_FAIL | -105 |Failed to check whether the mode is obtained.|
+| HUKS_ERROR_CHECK_GET_NONCE_FAIL | -106 |Failed to check whether the nonce is obtained.|
+| HUKS_ERROR_CHECK_GET_AAD_FAIL | -107 |Failed to check whether the AAD is obtained.|
+| HUKS_ERROR_CHECK_GET_IV_FAIL | -108 |Failed to check whether the initialization vector (IV) is obtained.|
+| HUKS_ERROR_CHECK_GET_AE_TAG_FAIL | -109 |Failed to check whether the AE flag is obtained.|
+| HUKS_ERROR_CHECK_GET_SALT_FAIL | -110 |Failed to check whether the SALT is obtained.|
+| HUKS_ERROR_CHECK_GET_ITERATION_FAIL | -111 |Failed to check whether the iteration is obtained.|
+| HUKS_ERROR_INVALID_ALGORITHM | -112 |Invalid algorithm.|
+| HUKS_ERROR_INVALID_KEY_SIZE | -113 |Invalid key size.|
+| HUKS_ERROR_INVALID_PADDING | -114 |Invalid padding.|
+| HUKS_ERROR_INVALID_PURPOSE | -115 |Invalid purpose.|
+| HUKS_ERROR_INVALID_MODE | -116 |Invalid mode.|
+| HUKS_ERROR_INVALID_DIGEST | -117 |Invalid digest.|
+| HUKS_ERROR_INVALID_SIGNATURE_SIZE | -118 |Invalid signature size.|
+| HUKS_ERROR_INVALID_IV | -119 |Invalid IV.|
+| HUKS_ERROR_INVALID_AAD | -120 |Invalid AAD.|
+| HUKS_ERROR_INVALID_NONCE | -121 |Invalid nonce.|
+| HUKS_ERROR_INVALID_AE_TAG | -122 |Invalid AE tag.|
+| HUKS_ERROR_INVALID_SALT | -123 |Invalid SALT.|
+| HUKS_ERROR_INVALID_ITERATION | -124 |Invalid iteration.|
+| HUKS_ERROR_INVALID_OPERATION | -125 |Invalid operation.|
+| HUKS_ERROR_INVALID_WRAPPED_FORMAT9+ | -126 |Incorrect format of the wrapped key being imported.|
+| HUKS_ERROR_INVALID_USAGE_OF_KEY9+ | -127 |Incorrect purpose of the wrapped key being imported.|
+| HUKS_ERROR_INTERNAL_ERROR | -999 |Internal error.|
+| HUKS_ERROR_UNKNOWN_ERROR | -1000 |Unknown error.|
## HuksKeyPurpose
@@ -97,13 +99,13 @@ Enumerates the key purposes.
| Name | Value | Description |
| ------------------------ | ---- | -------------------------------- |
-| HUKS_KEY_PURPOSE_ENCRYPT | 1 | Used to encrypt plain text. |
+| HUKS_KEY_PURPOSE_ENCRYPT | 1 | Used to encrypt plaintext. |
| HUKS_KEY_PURPOSE_DECRYPT | 2 | Used to decrypt cipher text. |
-| HUKS_KEY_PURPOSE_SIGN | 4 | Usedd to sign data. |
+| HUKS_KEY_PURPOSE_SIGN | 4 | Used to sign data. |
| HUKS_KEY_PURPOSE_VERIFY | 8 | Used to verify the signed data. |
| HUKS_KEY_PURPOSE_DERIVE | 16 | Used to derive a key. |
-| HUKS_KEY_PURPOSE_WRAP | 32 | Used for encrypted import. |
-| HUKS_KEY_PURPOSE_UNWRAP | 64 | Used for encrypted export. |
+| HUKS_KEY_PURPOSE_WRAP | 32 | Used to wrap data. |
+| HUKS_KEY_PURPOSE_UNWRAP | 64 | Used for unwrap data. |
| HUKS_KEY_PURPOSE_MAC | 128 | Used to generate a message authentication code (MAC). |
| HUKS_KEY_PURPOSE_AGREE | 256 | Used for key agreement. |
@@ -115,13 +117,14 @@ Enumerates the digest algorithms.
| Name | Value | Description |
| ---------------------- | ---- | ---------------------------------------- |
-| HUKS_DIGEST_NONE | 0 | No digest algorithm. |
-| HUKS_DIGEST_MD5 | 1 | MD5. |
-| HUKS_DIGEST_SHA1 | 10 | SHA1. |
-| HUKS_DIGEST_SHA224 | 11 | SHA-224. |
-| HUKS_DIGEST_SHA256 | 12 | SHA-256. |
-| HUKS_DIGEST_SHA384 | 13 | SHA-384. |
-| HUKS_DIGEST_SHA512 | 14 | SHA-512. |
+| HUKS_DIGEST_NONE | 0 | No digest algorithm |
+| HUKS_DIGEST_MD5 | 1 | MD5 |
+| HUKS_DIGEST_SM39+ | 2 | SM3 |
+| HUKS_DIGEST_SHA1 | 10 | SHA1 |
+| HUKS_DIGEST_SHA224 | 11 | SHA-224 |
+| HUKS_DIGEST_SHA256 | 12 | SHA-256 |
+| HUKS_DIGEST_SHA384 | 13 | SHA-384 |
+| HUKS_DIGEST_SHA512 | 14 | SHA-512 |
## HuksKeyPadding
@@ -131,11 +134,11 @@ Enumerates the padding algorithms.
| Name | Value | Description |
| ---------------------- | ---- | ---------------------------------------- |
-| HUKS_PADDING_NONE | 0 | No padding algorithm. |
-| HUKS_PADDING_OAEP | 1 | Optimal Asymmetric Encryption Padding (OAEP). |
-| HUKS_PADDING_PSS | 2 | Probabilistic Signature Scheme (PSS). |
-| HUKS_PADDING_PKCS1_V1_5 | 3 | PKCS1_V1_5. |
-| HUKS_PADDING_PKCS5 | 4 | Public Key Cryptography Standards (PKCS) #5. |
+| HUKS_PADDING_NONE | 0 | No padding algorithm |
+| HUKS_PADDING_OAEP | 1 | Optimal Asymmetric Encryption Padding (OAEP) |
+| HUKS_PADDING_PSS | 2 | Probabilistic Signature Scheme (PSS) |
+| HUKS_PADDING_PKCS1_V1_5 | 3 | PKCS1_V1_5 |
+| HUKS_PADDING_PKCS5 | 4 | Public Key Cryptography Standards (PKCS) #5 |
| HUKS_PADDING_PKCS7 | 5 | PKCS #7|
## HuksCipherMode
@@ -146,12 +149,12 @@ Enumerates the cipher modes.
| Name | Value | Description |
| ------------- | ---- | --------------------- |
-| HUKS_MODE_ECB | 1 | Electronic Code BLock (ECB) mode. |
-| HUKS_MODE_CBC | 2 | Cipher Block Chaining (CBC) mode. |
-| HUKS_MODE_CTR | 3 | Counter (CTR) mode. |
-| HUKS_MODE_OFB | 4 | Output Feedback (OFB) mode. |
-| HUKS_MODE_CCM | 31 | Counter with CBC-MAC (CCM) mode. |
-| HUKS_MODE_GCM | 32 | Galois/Counter (GCM) mode. |
+| HUKS_MODE_ECB | 1 | Electronic Code Block (ECB) mode |
+| HUKS_MODE_CBC | 2 | Cipher Block Chaining (CBC) mode |
+| HUKS_MODE_CTR | 3 | Counter (CTR) mode |
+| HUKS_MODE_OFB | 4 | Output Feedback (OFB) mode |
+| HUKS_MODE_CCM | 31 | Counter with CBC-MAC (CCM) mode |
+| HUKS_MODE_GCM | 32 | Galois/Counter (GCM) mode |
## HuksKeySize
@@ -159,26 +162,28 @@ Enumerates the key sizes.
**System capability**: SystemCapability.Security.Huks
-| Name | Value | Description |
-| ---------------------------- | ---- | ------------------------------------------ |
-| HUKS_RSA_KEY_SIZE_512 | 512 | Rivest-Shamir-Adleman (RSA) key of 512 bits. |
-| HUKS_RSA_KEY_SIZE_768 | 768 | RSA key of 768 bits. |
-| HUKS_RSA_KEY_SIZE_1024 | 1024 | RSA key of 1024 bits. |
-| HUKS_RSA_KEY_SIZE_2048 | 2048 | RSA key of 2048 bits. |
-| HUKS_RSA_KEY_SIZE_3072 | 3072 | RSA key of 3072 bits. |
-| HUKS_RSA_KEY_SIZE_4096 | 4096 | RSA key of 4096 bits. |
-| HUKS_ECC_KEY_SIZE_224 | 224 | ECC key of 224 bits. |
-| HUKS_ECC_KEY_SIZE_256 | 256 | ECC key of 256 bits. |
-| HUKS_ECC_KEY_SIZE_384 | 384 | ECC key of 384 bits. |
-| HUKS_ECC_KEY_SIZE_521 | 521 | ECC key of 521 bits. |
-| HUKS_AES_KEY_SIZE_128 | 128 | AES key of 128 bits. |
-| HUKS_AES_KEY_SIZE_192 | 196 | AES key of 196 bits. |
-| HUKS_AES_KEY_SIZE_256 | 256 | AES key of 256 bits. |
-| HUKS_AES_KEY_SIZE_512 | 512 | AES key of 512 bits. |
-| HUKS_CURVE25519_KEY_SIZE_256 | 256 | Curve25519 key of 256 bits. |
-| HUKS_DH_KEY_SIZE_2048 | 2048 | DH key of 2048 bits. |
-| HUKS_DH_KEY_SIZE_3072 | 3072 | DH key of 3072 bits. |
-| HUKS_DH_KEY_SIZE_4096 | 4096 | DH key of 4096 bits. |
+| Name | Value | Description |
+| ---------------------------------- | ---- | ------------------------------------------ |
+| HUKS_RSA_KEY_SIZE_512 | 512 | Rivest-Shamir-Adleman (RSA) key of 512 bits |
+| HUKS_RSA_KEY_SIZE_768 | 768 | RSA key of 768 bits |
+| HUKS_RSA_KEY_SIZE_1024 | 1024 | RSA key of 1024 bits |
+| HUKS_RSA_KEY_SIZE_2048 | 2048 | RSA key of 2048 bits |
+| HUKS_RSA_KEY_SIZE_3072 | 3072 | RSA key of 3072 bits |
+| HUKS_RSA_KEY_SIZE_4096 | 4096 | RSA key of 4096 bits |
+| HUKS_ECC_KEY_SIZE_224 | 224 | ECC key of 224 bits |
+| HUKS_ECC_KEY_SIZE_256 | 256 | ECC key of 256 bits |
+| HUKS_ECC_KEY_SIZE_384 | 384 | ECC key of 384 bits |
+| HUKS_ECC_KEY_SIZE_521 | 521 | ECC key of 521 bits |
+| HUKS_AES_KEY_SIZE_128 | 128 | AES key of 128 bits |
+| HUKS_AES_KEY_SIZE_192 | 196 | AES key of 196 bits |
+| HUKS_AES_KEY_SIZE_256 | 256 | AES key of 256 bits |
+| HUKS_AES_KEY_SIZE_512 | 512 | AES key of 512 bits |
+| HUKS_CURVE25519_KEY_SIZE_256 | 256 | Curve25519 key of 256 bits |
+| HUKS_DH_KEY_SIZE_2048 | 2048 | DH key of 2048 bits |
+| HUKS_DH_KEY_SIZE_3072 | 3072 | DH key of 3072 bits |
+| HUKS_DH_KEY_SIZE_4096 | 4096 | DH key of 4096 bits |
+| HUKS_SM2_KEY_SIZE_2569+ | 256 | SM2 key of 256 bits |
+| HUKS_SM4_KEY_SIZE_1289+ | 128 | SM4 key of 128 bits |
## HuksKeyAlg
@@ -186,19 +191,22 @@ Enumerates the key algorithms.
**System capability**: SystemCapability.Security.Huks
-| Name | Value | Description |
-| ---------------- | ---- | --------------------- |
-| HUKS_ALG_RSA | 1 | RSA. |
-| HUKS_ALG_ECC | 2 | ECC. |
-| HUKS_ALG_DSA | 3 | DSA. |
-| HUKS_ALG_AES | 20 | AES. |
-| HUKS_ALG_HMAC | 50 | HMAC. |
-| HUKS_ALG_HKDF | 51 | HKDF. |
-| HUKS_ALG_PBKDF2 | 52 | PBKDF2. |
-| HUKS_ALG_ECDH | 100 | ECDH. |
-| HUKS_ALG_X25519 | 101 | X25519 algorithm. |
-| HUKS_ALG_ED25519 | 102 | ED25519 algorithm. |
-| HUKS_ALG_DH | 103 | DH. |
+| Name | Value | Description |
+| ------------------------- | ---- | --------------------- |
+| HUKS_ALG_RSA | 1 | RSA |
+| HUKS_ALG_ECC | 2 | ECC |
+| HUKS_ALG_DSA | 3 | DSA |
+| HUKS_ALG_AES | 20 | AES |
+| HUKS_ALG_HMAC | 50 | HMAC |
+| HUKS_ALG_HKDF | 51 | HKDF |
+| HUKS_ALG_PBKDF2 | 52 | PBKDF2 |
+| HUKS_ALG_ECDH | 100 | ECDH |
+| HUKS_ALG_X25519 | 101 | X25519 |
+| HUKS_ALG_ED25519 | 102 | ED25519 |
+| HUKS_ALG_DH | 103 | DH |
+| HUKS_ALG_SM29+ | 150 | SM2 |
+| HUKS_ALG_SM39+ | 151 | SM3 |
+| HUKS_ALG_SM49+ | 152 | SM4 |
## HuksKeyGenerateType
@@ -208,9 +216,9 @@ Enumerates the key generation types.
| Name | Value | Description |
| ------------------------------ | ---- | ---------------- |
-| HUKS_KEY_GENERATE_TYPE_DEFAULT | 0 | Key generated by default. |
-| HUKS_KEY_GENERATE_TYPE_DERIVE | 1 | Derived key. |
-| HUKS_KEY_GENERATE_TYPE_AGREE | 2 | Key generated by agreement. |
+| HUKS_KEY_GENERATE_TYPE_DEFAULT | 0 | Key generated by default.|
+| HUKS_KEY_GENERATE_TYPE_DERIVE | 1 | Derived key.|
+| HUKS_KEY_GENERATE_TYPE_AGREE | 2 | Key generated by agreement.|
## HuksKeyFlag
@@ -220,10 +228,10 @@ Enumerates the key generation modes.
| Name | Value | Description |
| -------------------------- | ---- | ------------------------------------ |
-| HUKS_KEY_FLAG_IMPORT_KEY | 1 | The key is imported by using the public key import API. |
-| HUKS_KEY_FLAG_GENERATE_KEY | 2 | The key is generated by using the private key generation API. |
-| HUKS_KEY_FLAG_AGREE_KEY | 3 | The key is generated by using the key agreement API. |
-| HUKS_KEY_FLAG_DERIVE_KEY | 4 | The key is generated by using the key derivation API. |
+| HUKS_KEY_FLAG_IMPORT_KEY | 1 | The key is imported by using an API. |
+| HUKS_KEY_FLAG_GENERATE_KEY | 2 | The key is generated by using an API. |
+| HUKS_KEY_FLAG_AGREE_KEY | 3 | The key is generated by using a key agreement API. |
+| HUKS_KEY_FLAG_DERIVE_KEY | 4 | The key is derived by using an API. |
## HuksKeyStorageType
@@ -234,7 +242,7 @@ Enumerates the key storage modes.
| Name | Value | Description |
| ----------------------- | ---- | ------------------------------ |
| HUKS_STORAGE_TEMP | 0 | The key is managed locally. |
-| HUKS_STORAGE_PERSISTENT | 1 | The key is managed by the HUKS service. |
+| HUKS_STORAGE_PERSISTENT | 1 | The key is managed by the HUKS service.|
## HuksSendType
@@ -244,8 +252,31 @@ Enumerates the tag transfer modes.
| Name | Value | Description |
| -------------------- | ---- | ----------------- |
-| HUKS_SEND_TYPE_ASYNC | 0 | The tag is sent asynchronously. |
-| HUKS_SEND_TYPE_SYNC | 1 | The tag is sent synchronously. |
+| HUKS_SEND_TYPE_ASYNC | 0 | The tag is sent asynchronously.|
+| HUKS_SEND_TYPE_SYNC | 1 | The tag is sent synchronously.|
+
+## HuksUnwrapSuite9+
+
+Enumerates the algorithm suites used when a wrapped key is imported.
+
+**System capability**: SystemCapability.Security.Huks
+
+| Name | Value | Description |
+| ---------------------------------------------- | ---- | ----------------------------------------------------- |
+| HUKS_UNWRAP_SUITE_X25519_AES_256_GCM_NOPADDING | 1 | Use X25519 for key agreement and then use AES-256 GCM to encrypt the key.|
+| HUKS_UNWRAP_SUITE_ECDH_AES_256_GCM_NOPADDING | 2 | Use ECDH for key agreement and then use AES-256 GCM to encrypt the key. |
+
+## HuksImportKeyType9+
+
+Enumerates the types of the key to import. By default, a public key is imported. This field is not required when a symmetric key is imported.
+
+**System capability**: SystemCapability.Security.Huks
+
+| Name | Value | Description |
+| ------------------------- | ---- | ------------------------------ |
+| HUKS_KEY_TYPE_PUBLIC_KEY | 0 | Public key |
+| HUKS_KEY_TYPE_PRIVATE_KEY | 1 | Private key |
+| HUKS_KEY_TYPE_KEY_PAIR | 2 | Public and private key pair |
## HuksTagType
@@ -256,12 +287,12 @@ Enumerates the tag data types.
| Name | Value | Description |
| --------------------- | ------- | --------------------------------------- |
-| HUKS_TAG_TYPE_INVALID | 0 << 28 | Invalid tag type. |
-| HUKS_TAG_TYPE_INT | 1 << 28 | Number of the int type. |
-| HUKS_TAG_TYPE_UINT | 2 << 28 | Number of the uint type. |
-| HUKS_TAG_TYPE_ULONG | 3 << 28 | bigint. |
-| HUKS_TAG_TYPE_BOOL | 4 << 28 | Boolean. |
-| HUKS_TAG_TYPE_BYTES | 5 << 28 | Uint8Array. |
+| HUKS_TAG_TYPE_INVALID | 0 << 28 | Invalid tag type |
+| HUKS_TAG_TYPE_INT | 1 << 28 | Number of the int type |
+| HUKS_TAG_TYPE_UINT | 2 << 28 | Number of the uint type |
+| HUKS_TAG_TYPE_ULONG | 3 << 28 | bigint |
+| HUKS_TAG_TYPE_BOOL | 4 << 28 | Boolean |
+| HUKS_TAG_TYPE_BYTES | 5 << 28 | Uint8Array |
## HuksTag
@@ -269,84 +300,86 @@ Enumerates the tags used to invoke parameters.
**System capability**: SystemCapability.Security.Huks
-| Name | Value | Description |
-| -------------------------------------- | ---------------------------------------- | -------------------------------------- |
-| HUKS_TAG_INVALID | HuksTagType.HUKS_TAG_TYPE_INVALID \| 0 | Invalid tag. |
-| HUKS_TAG_ALGORITHM | HUKS_TAG_TYPE_UINT \| 1 | Algorithm. |
-| HUKS_TAG_PURPOSE | HuksTagType.HUKS_TAG_TYPE_UINT \| 2 | Purpose of a key. |
-| HUKS_TAG_KEY_SIZE | HuksTagType.HUKS_TAG_TYPE_UINT \| 3 | Key size. |
-| HUKS_TAG_DIGEST | HuksTagType.HUKS_TAG_TYPE_UINT \| 4 | Digest algorithm. |
-| HUKS_TAG_PADDING | HuksTagType.HUKS_TAG_TYPE_UINT \| 5 | Padding algorithm. |
-| HUKS_TAG_BLOCK_MODE | HuksTagType.HUKS_TAG_TYPE_UINT \| 6 | Cipher mode. |
-| HUKS_TAG_KEY_TYPE | HuksTagType.HUKS_TAG_TYPE_UINT \| 7 | Key type. |
-| HUKS_TAG_ASSOCIATED_DATA | HuksTagType.HUKS_TAG_TYPE_BYTES \| 8 | Associated authentication data. |
-| HUKS_TAG_NONCE | HuksTagType.HUKS_TAG_TYPE_BYTES \| 9 | Field for key encryption and decryption. |
-| HUKS_TAG_IV | HuksTagType.HUKS_TAG_TYPE_BYTES \| 10 | IV. |
-| HUKS_TAG_INFO | HuksTagType.HUKS_TAG_TYPE_BYTES \| 11 | Information generated during key derivation. |
-| HUKS_TAG_SALT | HuksTagType.HUKS_TAG_TYPE_BYTES \| 12 | Salt value used for key derivation. |
-| HUKS_TAG_PWD | HuksTagType.HUKS_TAG_TYPE_BYTES \| 13 | Password used for key derivation. |
-| HUKS_TAG_ITERATION | HuksTagType.HUKS_TAG_TYPE_UINT \| 14 | Number of iterations for key derivation. |
-| HUKS_TAG_KEY_GENERATE_TYPE | HuksTagType.HUKS_TAG_TYPE_UINT \| 15 | Key generation type. |
-| HUKS_TAG_DERIVE_MAIN_KEY | HuksTagType.HUKS_TAG_TYPE_BYTES \| 16 | Main key for key derivation. |
-| HUKS_TAG_DERIVE_FACTOR | HuksTagType.HUKS_TAG_TYPE_BYTES \| 17 | Factor for key derivation. |
-| HUKS_TAG_DERIVE_ALG | HuksTagType.HUKS_TAG_TYPE_UINT \| 18 | Type of the algorithm used for key derivation. |
-| HUKS_TAG_AGREE_ALG | HuksTagType.HUKS_TAG_TYPE_UINT \| 19 | Type of the algorithm used in key agreement. |
-| HUKS_TAG_AGREE_PUBLIC_KEY_IS_KEY_ALIAS | HuksTagType.HUKS_TAG_TYPE_BOOL \| 20 | Alias of the public key during key agreement. |
-| HUKS_TAG_AGREE_PRIVATE_KEY_ALIAS | HuksTagType.HUKS_TAG_TYPE_BYTES \| 21 | Private key alias used in key agreement. |
-| HUKS_TAG_AGREE_PUBLIC_KEY | HuksTagType.HUKS_TAG_TYPE_BYTES \| 22 | Public key used in key agreement. |
-| HUKS_TAG_KEY_ALIAS | HuksTagType.HUKS_TAG_TYPE_BYTES \| 23 | Key alias. |
-| HUKS_TAG_DERIVE_KEY_SIZE | HuksTagType.HUKS_TAG_TYPE_UINT \| 24 | Size of the derived key. |
-| HUKS_TAG_ACTIVE_DATETIME | HuksTagType.HUKS_TAG_TYPE_ULONG \| 201 | Reserved. |
-| HUKS_TAG_ORIGINATION_EXPIRE_DATETIME | HuksTagType.HUKS_TAG_TYPE_ULONG \| 202 | Reserved. |
-| HUKS_TAG_USAGE_EXPIRE_DATETIME | HuksTagType.HUKS_TAG_TYPE_ULONG \| 203 | Reserved. |
-| HUKS_TAG_CREATION_DATETIME | HuksTagType.HUKS_TAG_TYPE_ULONG \| 204 | Reserved. |
-| HUKS_TAG_ALL_USERS | ksTagType.HUKS_TAG_TYPE_BOOL \| 301 | Reserved. |
-| HUKS_TAG_USER_ID | HuksTagType.HUKS_TAG_TYPE_UINT \| 302 | Reserved. |
-| HUKS_TAG_NO_AUTH_REQUIRED | HuksTagType.HUKS_TAG_TYPE_BOOL \| 303 | Reserved. |
-| HUKS_TAG_USER_AUTH_TYPE | HuksTagType.HUKS_TAG_TYPE_UINT \| 304 | Reserved. |
-| HUKS_TAG_AUTH_TIMEOUT | HuksTagType.HUKS_TAG_TYPE_UINT \| 305 | Reserved. |
-| HUKS_TAG_AUTH_TOKEN | HuksTagType.HUKS_TAG_TYPE_BYTES \| 306 | Reserved. |
-| HUKS_TAG_ATTESTATION_CHALLENGE | HuksTagType.HUKS_TAG_TYPE_BYTES \| 501 | Challenge value used in the attestation. |
-| HUKS_TAG_ATTESTATION_APPLICATION_ID | HuksTagType.HUKS_TAG_TYPE_BYTES \| 502 | Application ID used in the attestation. |
-| HUKS_TAG_ATTESTATION_ID_BRAND | HuksTagType.HUKS_TAG_TYPE_BYTES \| 503 | Device brand. |
-| HUKS_TAG_ATTESTATION_ID_DEVICE | HuksTagType.HUKS_TAG_TYPE_BYTES \| 504 | Device. |
-| HUKS_TAG_ATTESTATION_ID_PRODUCT | HuksTagType.HUKS_TAG_TYPE_BYTES \| 505 | Product. |
-| HUKS_TAG_ATTESTATION_ID_SERIAL | HuksTagType.HUKS_TAG_TYPE_BYTES \| 506 | Device SN. |
-| HUKS_TAG_ATTESTATION_ID_IMEI | HuksTagType.HUKS_TAG_TYPE_BYTES \| 507 | Device IMEI. |
-| HUKS_TAG_ATTESTATION_ID_MEID | HuksTagType.HUKS_TAG_TYPE_BYTES \| 508 | Device MEID. |
-| HUKS_TAG_ATTESTATION_ID_MANUFACTURER | HuksTagType.HUKS_TAG_TYPE_BYTES \| 509 | Device manufacturer. |
-| HUKS_TAG_ATTESTATION_ID_MODEL | HuksTagType.HUKS_TAG_TYPE_BYTES \| 510 | Device model. |
-| HUKS_TAG_ATTESTATION_ID_ALIAS | HuksTagType.HUKS_TAG_TYPE_BYTES \| 511 | Key alias used in the attestation. |
-| HUKS_TAG_ATTESTATION_ID_SOCID | HuksTagType.HUKS_TAG_TYPE_BYTES \| 512 | Device SOCID. |
-| HUKS_TAG_ATTESTATION_ID_UDID | HuksTagType.HUKS_TAG_TYPE_BYTES \| 513 | Device UDID. |
-| HUKS_TAG_ATTESTATION_ID_SEC_LEVEL_INFO | HuksTagType.HUKS_TAG_TYPE_BYTES \| 514 | Security credential used for the attestation. |
-| HUKS_TAG_ATTESTATION_ID_VERSION_INFO | HuksTagType.HUKS_TAG_TYPE_BYTES \| 515 | Version information used in the attestation. |
-| HUKS_TAG_IS_KEY_ALIAS | HuksTagType.HUKS_TAG_TYPE_BOOL \| 1001 | Whether to use the alias passed in during key generation. |
-| HUKS_TAG_KEY_STORAGE_FLAG | HuksTagType.HUKS_TAG_TYPE_UINT \| 1002 | Key storage mode. |
-| HUKS_TAG_IS_ALLOWED_WRAP | HuksTagType.HUKS_TAG_TYPE_BOOL \| 1003 | Reserved. |
-| HUKS_TAG_KEY_WRAP_TYPE | HuksTagType.HUKS_TAG_TYPE_UINT \| 1004 | Reserved. |
-| HUKS_TAG_KEY_AUTH_ID | HuksTagType.HUKS_TAG_TYPE_BYTES \| 1005 | Reserved. |
-| HUKS_TAG_KEY_ROLE | HuksTagType.HUKS_TAG_TYPE_UINT \| 1006 | Reserved. |
-| HUKS_TAG_KEY_FLAG | HuksTagType.HUKS_TAG_TYPE_UINT \| 1007 | Flag of the key. |
-| HUKS_TAG_IS_ASYNCHRONIZED | HuksTagType.HUKS_TAG_TYPE_UINT \| 1008 | Reserved. |
-| HUKS_TAG_SECURE_KEY_ALIAS | HuksTagType.HUKS_TAG_TYPE_BOOL \| 1009 | Reserved. |
-| HUKS_TAG_SECURE_KEY_UUID | HuksTagType.HUKS_TAG_TYPE_BYTES \| 1010 | Reserved. |
-| HUKS_TAG_KEY_DOMAIN | HuksTagType.HUKS_TAG_TYPE_UINT \| 1011 | Reserved. |
-| HUKS_TAG_PROCESS_NAME | HuksTagType.HUKS_TAG_TYPE_BYTES \| 10001 | Process name. |
-| HUKS_TAG_PACKAGE_NAME | HuksTagType.HUKS_TAG_TYPE_BYTES \| 10002 | Reserved. |
-| HUKS_TAG_ACCESS_TIME | HuksTagType.HUKS_TAG_TYPE_UINT \| 10003 | Reserved. |
-| HUKS_TAG_USES_TIME | HuksTagType.HUKS_TAG_TYPE_UINT \| 10004 | Reserved. |
-| HUKS_TAG_CRYPTO_CTX | HuksTagType.HUKS_TAG_TYPE_ULONG \| 10005 | Reserved. |
-| HUKS_TAG_KEY | HuksTagType.HUKS_TAG_TYPE_BYTES \| 10006 | Reserved. |
-| HUKS_TAG_KEY_VERSION | HuksTagType.HUKS_TAG_TYPE_UINT \| 10007 | Key version. |
-| HUKS_TAG_PAYLOAD_LEN | HuksTagType.HUKS_TAG_TYPE_UINT \| 10008 | Reserved. |
-| HUKS_TAG_AE_TAG | HuksTagType.HUKS_TAG_TYPE_BYTES \| 10009 | Reserved. |
-| HUKS_TAG_IS_KEY_HANDLE | HuksTagType.HUKS_TAG_TYPE_ULONG \| 10010 | Reserved. |
-| HUKS_TAG_OS_VERSION | HuksTagType.HUKS_TAG_TYPE_UINT \| 10101 | OS version. |
-| HUKS_TAG_OS_PATCHLEVEL | HuksTagType.HUKS_TAG_TYPE_UINT \| 10102 | OS patch level. |
-| HUKS_TAG_SYMMETRIC_KEY_DATA | HuksTagType.HUKS_TAG_TYPE_BYTES \| 20001 | Reserved. |
-| HUKS_TAG_ASYMMETRIC_PUBLIC_KEY_DATA | HuksTagType.HUKS_TAG_TYPE_BYTES \| 20002 | Reserved. |
-| HUKS_TAG_ASYMMETRIC_PRIVATE_KEY_DATA | HuksTagType.HUKS_TAG_TYPE_BYTES \| 20003 | Reserved. |
+| Name | Value | Description |
+| -------------------------------------------- | ---------------------------------------- | -------------------------------------- |
+| HUKS_TAG_INVALID | HuksTagType.HUKS_TAG_TYPE_INVALID \| 0 | Invalid tag. |
+| HUKS_TAG_ALGORITHM | HUKS_TAG_TYPE_UINT \| 1 | Algorithm. |
+| HUKS_TAG_PURPOSE | HuksTagType.HUKS_TAG_TYPE_UINT \| 2 | Purpose of a key. |
+| HUKS_TAG_KEY_SIZE | HuksTagType.HUKS_TAG_TYPE_UINT \| 3 | Key size. |
+| HUKS_TAG_DIGEST | HuksTagType.HUKS_TAG_TYPE_UINT \| 4 | Digest algorithm. |
+| HUKS_TAG_PADDING | HuksTagType.HUKS_TAG_TYPE_UINT \| 5 | Padding algorithm. |
+| HUKS_TAG_BLOCK_MODE | HuksTagType.HUKS_TAG_TYPE_UINT \| 6 | Cipher mode. |
+| HUKS_TAG_KEY_TYPE | HuksTagType.HUKS_TAG_TYPE_UINT \| 7 | Key type. |
+| HUKS_TAG_ASSOCIATED_DATA | HuksTagType.HUKS_TAG_TYPE_BYTES \| 8 | Associated authentication data. |
+| HUKS_TAG_NONCE | HuksTagType.HUKS_TAG_TYPE_BYTES \| 9 | Field for key encryption and decryption. |
+| HUKS_TAG_IV | HuksTagType.HUKS_TAG_TYPE_BYTES \| 10 | IV. |
+| HUKS_TAG_INFO | HuksTagType.HUKS_TAG_TYPE_BYTES \| 11 | Information generated during key derivation. |
+| HUKS_TAG_SALT | HuksTagType.HUKS_TAG_TYPE_BYTES \| 12 | Salt value used for key derivation. |
+| HUKS_TAG_PWD | HuksTagType.HUKS_TAG_TYPE_BYTES \| 13 | Password used for key derivation. |
+| HUKS_TAG_ITERATION | HuksTagType.HUKS_TAG_TYPE_UINT \| 14 | Number of iterations for key derivation. |
+| HUKS_TAG_KEY_GENERATE_TYPE | HuksTagType.HUKS_TAG_TYPE_UINT \| 15 | Key generation type. |
+| HUKS_TAG_DERIVE_MAIN_KEY | HuksTagType.HUKS_TAG_TYPE_BYTES \| 16 | Main key for key derivation. |
+| HUKS_TAG_DERIVE_FACTOR | HuksTagType.HUKS_TAG_TYPE_BYTES \| 17 | Factor for key derivation. |
+| HUKS_TAG_DERIVE_ALG | HuksTagType.HUKS_TAG_TYPE_UINT \| 18 | Type of the algorithm used for key derivation. |
+| HUKS_TAG_AGREE_ALG | HuksTagType.HUKS_TAG_TYPE_UINT \| 19 | Type of the algorithm used in key agreement. |
+| HUKS_TAG_AGREE_PUBLIC_KEY_IS_KEY_ALIAS | HuksTagType.HUKS_TAG_TYPE_BOOL \| 20 | Alias of the public key during key agreement. |
+| HUKS_TAG_AGREE_PRIVATE_KEY_ALIAS | HuksTagType.HUKS_TAG_TYPE_BYTES \| 21 | Private key alias used in key agreement. |
+| HUKS_TAG_AGREE_PUBLIC_KEY | HuksTagType.HUKS_TAG_TYPE_BYTES \| 22 | Public key used in key agreement. |
+| HUKS_TAG_KEY_ALIAS | HuksTagType.HUKS_TAG_TYPE_BYTES \| 23 | Key alias. |
+| HUKS_TAG_DERIVE_KEY_SIZE | HuksTagType.HUKS_TAG_TYPE_UINT \| 24 | Size of the derived key. |
+| HUKS_TAG_IMPORT_KEY_TYPE9+ | HuksTagType.HUKS_TAG_TYPE_UINT \| 25 | Type of the imported key. |
+| HUKS_TAG_UNWRAP_ALGORITHM_SUITE9+ | HuksTagType.HUKS_TAG_TYPE_UINT \| 26 | Algorithm suite used when a wrapped key is imported. |
+| HUKS_TAG_ACTIVE_DATETIME | HuksTagType.HUKS_TAG_TYPE_ULONG \| 201 | Reserved. |
+| HUKS_TAG_ORIGINATION_EXPIRE_DATETIME | HuksTagType.HUKS_TAG_TYPE_ULONG \| 202 | Reserved. |
+| HUKS_TAG_USAGE_EXPIRE_DATETIME | HuksTagType.HUKS_TAG_TYPE_ULONG \| 203 | Reserved. |
+| HUKS_TAG_CREATION_DATETIME | HuksTagType.HUKS_TAG_TYPE_ULONG \| 204 | Reserved. |
+| HUKS_TAG_ALL_USERS | ksTagType.HUKS_TAG_TYPE_BOOL \| 301 | Reserved. |
+| HUKS_TAG_USER_ID | HuksTagType.HUKS_TAG_TYPE_UINT \| 302 | Reserved. |
+| HUKS_TAG_NO_AUTH_REQUIRED | HuksTagType.HUKS_TAG_TYPE_BOOL \| 303 | Reserved. |
+| HUKS_TAG_USER_AUTH_TYPE | HuksTagType.HUKS_TAG_TYPE_UINT \| 304 | Reserved. |
+| HUKS_TAG_AUTH_TIMEOUT | HuksTagType.HUKS_TAG_TYPE_UINT \| 305 | Reserved. |
+| HUKS_TAG_AUTH_TOKEN | HuksTagType.HUKS_TAG_TYPE_BYTES \| 306 | Reserved. |
+| HUKS_TAG_ATTESTATION_CHALLENGE | HuksTagType.HUKS_TAG_TYPE_BYTES \| 501 | Challenge value used in the attestation. |
+| HUKS_TAG_ATTESTATION_APPLICATION_ID | HuksTagType.HUKS_TAG_TYPE_BYTES \| 502 | Application ID used in the attestation. |
+| HUKS_TAG_ATTESTATION_ID_BRAND | HuksTagType.HUKS_TAG_TYPE_BYTES \| 503 | Device brand. |
+| HUKS_TAG_ATTESTATION_ID_DEVICE | HuksTagType.HUKS_TAG_TYPE_BYTES \| 504 | Device. |
+| HUKS_TAG_ATTESTATION_ID_PRODUCT | HuksTagType.HUKS_TAG_TYPE_BYTES \| 505 | Product. |
+| HUKS_TAG_ATTESTATION_ID_SERIAL | HuksTagType.HUKS_TAG_TYPE_BYTES \| 506 | Device SN. |
+| HUKS_TAG_ATTESTATION_ID_IMEI | HuksTagType.HUKS_TAG_TYPE_BYTES \| 507 | Device IMEI. |
+| HUKS_TAG_ATTESTATION_ID_MEID | HuksTagType.HUKS_TAG_TYPE_BYTES \| 508 | Device MEID. |
+| HUKS_TAG_ATTESTATION_ID_MANUFACTURER | HuksTagType.HUKS_TAG_TYPE_BYTES \| 509 | Device manufacturer. |
+| HUKS_TAG_ATTESTATION_ID_MODEL | HuksTagType.HUKS_TAG_TYPE_BYTES \| 510 | Device model. |
+| HUKS_TAG_ATTESTATION_ID_ALIAS | HuksTagType.HUKS_TAG_TYPE_BYTES \| 511 | Key alias used in the attestation. |
+| HUKS_TAG_ATTESTATION_ID_SOCID | HuksTagType.HUKS_TAG_TYPE_BYTES \| 512 | Device SOCID. |
+| HUKS_TAG_ATTESTATION_ID_UDID | HuksTagType.HUKS_TAG_TYPE_BYTES \| 513 | Device UDID. |
+| HUKS_TAG_ATTESTATION_ID_SEC_LEVEL_INFO | HuksTagType.HUKS_TAG_TYPE_BYTES \| 514 | Security credential used for the attestation. |
+| HUKS_TAG_ATTESTATION_ID_VERSION_INFO | HuksTagType.HUKS_TAG_TYPE_BYTES \| 515 | Version information used in the attestation. |
+| HUKS_TAG_IS_KEY_ALIAS | HuksTagType.HUKS_TAG_TYPE_BOOL \| 1001 | Whether to use the alias passed in during key generation.|
+| HUKS_TAG_KEY_STORAGE_FLAG | HuksTagType.HUKS_TAG_TYPE_UINT \| 1002 | Key storage mode. |
+| HUKS_TAG_IS_ALLOWED_WRAP | HuksTagType.HUKS_TAG_TYPE_BOOL \| 1003 | Reserved. |
+| HUKS_TAG_KEY_WRAP_TYPE | HuksTagType.HUKS_TAG_TYPE_UINT \| 1004 | Reserved. |
+| HUKS_TAG_KEY_AUTH_ID | HuksTagType.HUKS_TAG_TYPE_BYTES \| 1005 | Reserved. |
+| HUKS_TAG_KEY_ROLE | HuksTagType.HUKS_TAG_TYPE_UINT \| 1006 | Reserved. |
+| HUKS_TAG_KEY_FLAG | HuksTagType.HUKS_TAG_TYPE_UINT \| 1007 | Flag of the key. |
+| HUKS_TAG_IS_ASYNCHRONIZED | HuksTagType.HUKS_TAG_TYPE_UINT \| 1008 | Reserved. |
+| HUKS_TAG_SECURE_KEY_ALIAS | HuksTagType.HUKS_TAG_TYPE_BOOL \| 1009 | Reserved. |
+| HUKS_TAG_SECURE_KEY_UUID | HuksTagType.HUKS_TAG_TYPE_BYTES \| 1010 | Reserved. |
+| HUKS_TAG_KEY_DOMAIN | HuksTagType.HUKS_TAG_TYPE_UINT \| 1011 | Reserved. |
+| HUKS_TAG_PROCESS_NAME | HuksTagType.HUKS_TAG_TYPE_BYTES \| 10001 | Process name. |
+| HUKS_TAG_PACKAGE_NAME | HuksTagType.HUKS_TAG_TYPE_BYTES \| 10002 | Reserved. |
+| HUKS_TAG_ACCESS_TIME | HuksTagType.HUKS_TAG_TYPE_UINT \| 10003 | Reserved. |
+| HUKS_TAG_USES_TIME | HuksTagType.HUKS_TAG_TYPE_UINT \| 10004 | Reserved. |
+| HUKS_TAG_CRYPTO_CTX | HuksTagType.HUKS_TAG_TYPE_ULONG \| 10005 | Reserved. |
+| HUKS_TAG_KEY | HuksTagType.HUKS_TAG_TYPE_BYTES \| 10006 | Reserved. |
+| HUKS_TAG_KEY_VERSION | HuksTagType.HUKS_TAG_TYPE_UINT \| 10007 | Key version. |
+| HUKS_TAG_PAYLOAD_LEN | HuksTagType.HUKS_TAG_TYPE_UINT \| 10008 | Reserved. |
+| HUKS_TAG_AE_TAG | HuksTagType.HUKS_TAG_TYPE_BYTES \| 10009 | Reserved. |
+| HUKS_TAG_IS_KEY_HANDLE | HuksTagType.HUKS_TAG_TYPE_ULONG \| 10010 | Reserved. |
+| HUKS_TAG_OS_VERSION | HuksTagType.HUKS_TAG_TYPE_UINT \| 10101 | OS version. |
+| HUKS_TAG_OS_PATCHLEVEL | HuksTagType.HUKS_TAG_TYPE_UINT \| 10102 | OS patch level. |
+| HUKS_TAG_SYMMETRIC_KEY_DATA | HuksTagType.HUKS_TAG_TYPE_BYTES \| 20001 | Reserved. |
+| HUKS_TAG_ASYMMETRIC_PUBLIC_KEY_DATA | HuksTagType.HUKS_TAG_TYPE_BYTES \| 20002 | Reserved. |
+| HUKS_TAG_ASYMMETRIC_PRIVATE_KEY_DATA | HuksTagType.HUKS_TAG_TYPE_BYTES \| 20003 | Reserved. |
## huks.generateKey
@@ -362,7 +395,7 @@ Generates a key. This API uses an asynchronous callback to return the result.
| -------- | ----------------------------------------- | ---- | ------------------------------------------------------------ |
| keyAlias | string | Yes | Alias of the key. |
| options | [HuksOptions](#huksoptions) | Yes | Tags required for generating the key. |
-| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes | Callback used to return the result. If the operation is successful, **HUKS_SUCCESS** will be returned. If the operation fails, an error code defined in **HuksResult** will be returned. |
+| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes | Callback used to return the result. If the operation is successful, **HUKS_SUCCESS** will be returned. If the operation fails, an error code defined in **HuksResult** will be returned.|
**Example**
@@ -402,7 +435,7 @@ huks.generateKey(keyAlias, options, function (err, data){});
generateKey(keyAlias: string, options: HuksOptions) : Promise\
-Generates a key. This API uses a promise to return the result.
+Generates a key. This API uses a promise to return the result asynchronously.
**System capability**: SystemCapability.Security.Huks
@@ -411,13 +444,13 @@ Generates a key. This API uses a promise to return the result.
| Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | ------------------------ |
| keyAlias | string | Yes | Alias of the key. |
-| options | [HuksOptions](#huksoptions) | Yes | Tags required for generating the key. |
+| options | [HuksOptions](#huksoptions) | Yes | Tags required for generating the key.|
**Return value**
| Type | Description |
| ----------------------------------- | -------------------------------------------------- |
-| Promise\<[HuksResult](#huksresult)> | Promise used to return the result. If the operation is successful, **HUKS_SUCCESS** will be returned. If the operation fails, an error code will be returned. |
+| Promise\<[HuksResult](#huksresult)> | Promise used to return the result. If the operation is successful, **HUKS_SUCCESS** will be returned. If the operation fails, an error code will be returned.|
**Example**
@@ -463,7 +496,7 @@ Deletes a key. This API uses an asynchronous callback to return the result.
| -------- | ----------------------------------------- | ---- | -------------------------------------------------- |
| keyAlias | string | Yes | Key alias passed in when the key was generated. |
| options | [HuksOptions](#huksoptions) | Yes | Empty object (leave this parameter empty). |
-| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes | Callback used to return the result. If the operation is successful, **HUKS_SUCCESS** will be returned. If the operation fails, an error code will be returned. |
+| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes | Callback used to return the result. If the operation is successful, **HUKS_SUCCESS** will be returned. If the operation fails, an error code will be returned.|
**Example**
@@ -480,7 +513,7 @@ huks.deleteKey(keyAlias, emptyOptions, function (err, data) {});
deleteKey(keyAlias: string, options: HuksOptions) : Promise\
-Deletes a key. This API uses a promise to return the result.
+Deletes a key. This API uses a promise to return the result asynchronously.
**System capability**: SystemCapability.Security.Huks
@@ -488,14 +521,14 @@ Deletes a key. This API uses a promise to return the result.
| Name | Type | Mandatory| Description |
| -------- | ----------- | ---- | ----------------------------------------------------- |
-| keyAlias | string | Yes | Key alias passed in when the key was generated. |
-| options | [HuksOptions](#huksoptions) | Yes | Empty object (leave this parameter empty). |
+| keyAlias | string | Yes | Key alias passed in when the key was generated.|
+| options | [HuksOptions](#huksoptions) | Yes | Empty object (leave this parameter empty).|
**Return value**
| Type | Description |
| ----------------------------------- | -------------------------------------------------- |
-| Promise\<[HuksResult](#huksresult)> | Promise used to return the result. If the operation is successful, **HUKS_SUCCESS** will be returned. If the operation fails, an error code will be returned. |
+| Promise\<[HuksResult](#huksresult)> | Promise used to return the result. If the operation is successful, **HUKS_SUCCESS** will be returned. If the operation fails, an error code will be returned.|
**Example**
@@ -520,13 +553,13 @@ Obtains the SDK version of the current system.
| Name | Type | Mandatory| Description |
| ------- | ---------- | ---- | ------------------------- |
-| options | [HuksOptions](#huksoptions) | Yes | Empty object, which is used to hold the SDK version. |
+| options | [HuksOptions](#huksoptions) | Yes | Empty object, which is used to hold the SDK version.|
**Return value**
| Type | Description |
| ------ | ------------- |
-| string | SDK version obtained. |
+| string | SDK version obtained.|
**Example**
@@ -542,7 +575,7 @@ var result = huks.getSdkVersion(emptyOptions);
importKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback\) : void
-Imports a key. This API uses an asynchronous callback to return the result.
+Imports a key in plaintext. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Security.Huks
@@ -550,9 +583,9 @@ Imports a key. This API uses an asynchronous callback to return the result.
| Name | Type | Mandatory| Description |
| -------- | ------------------------ | ---- | ------------------------------------------------- |
-| keyAlias | string | Yes | Key alias, which is used to hold the key pair. |
-| options | [HuksOptions](#huksoptions) | Yes | Tags required for the import and key pair to import. |
-| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes | Callback used to return the result. If the operation is successful, **HUKS_SUCCESS** will be returned. If the operation fails, an error code will be returned. |
+| keyAlias | string | Yes | Alias of the key to import.|
+| options | [HuksOptions](#huksoptions) | Yes | Tags required for the import and key to import.|
+| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes | Callback used to return the result. If the operation is successful, **HUKS_SUCCESS** will be returned. If the operation fails, an error code will be returned.|
**Example**
@@ -600,7 +633,7 @@ huks.importKey(keyAlias, options, function (err, data){});
importKey(keyAlias: string, options: HuksOptions) : Promise\
-Imports a key. This API uses a promise to return the result.
+Imports a key in plaintext. This API uses a promise to return the result asynchronously.
**System capability**: SystemCapability.Security.Huks
@@ -608,14 +641,14 @@ Imports a key. This API uses a promise to return the result.
| Name | Type | Mandatory| Description |
| -------- | ----------- | ---- | ------------------------------------ |
-| keyAlias | string | Yes | Key alias, which is used to hold the key pair. |
-| options | [HuksOptions](#huksoptions) | Yes | Tags required for the import and key pair to import. |
+| keyAlias | string | Yes | Alias of the key to import.|
+| options | [HuksOptions](#huksoptions) | Yes | Tags required for the import and key to import.|
**Return value**
| Type | Description |
| ----------------------------------- | -------------------------------------------------- |
-| Promise\<[HuksResult](#huksresult)> | Promise used to return the result. If the operation is successful, **HUKS_SUCCESS** will be returned. If the operation fails, an error code will be returned. |
+| Promise\<[HuksResult](#huksresult)> | Promise used to return the result. If the operation is successful, **HUKS_SUCCESS** will be returned. If the operation fails, an error code will be returned.|
**Example**
@@ -661,6 +694,230 @@ var huksoptions = {
var result = huks.importKey(keyAlias, huksoptions);
```
+## huks.importWrappedKey9+
+
+importWrappedKey(keyAlias: string, wrappingKeyAlias: string, options: HuksOptions, callback: AsyncCallback\) : void
+
+Imports a wrapped key. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Security.Huks
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ---------------- | ----------------------------------------- | ---- | -------------------------------------------------- |
+| keyAlias | string | Yes | Alias of the wrapped key to import. |
+| wrappingKeyAlias | string | Yes | Alias of the data used to unwrap the key imported. |
+| options | [HuksOptions](#huksoptions) | Yes | Tags required for the import and the wrapped key to import. |
+| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes | Callback used to return the result. If the operation is successful, **HUKS_SUCCESS** will be returned. If the operation fails, an error code will be returned.|
+
+**Example**
+
+```js
+var exportWrappingKey;
+var alias1 = "importAlias";
+var alias2 = "wrappingKeyAlias";
+
+async function TestGenFunc(alias, options) {
+ await genKey(alias, options)
+ .then((data) => {
+ console.log(`test genKey data: ${JSON.stringify(data)}`);
+ })
+ .catch((err) => {
+ console.log('test genKey err information: ' + JSON.stringify(err));
+ });
+}
+
+function genKey(alias, options) {
+ return new Promise((resolve, reject) => {
+ huks.generateKey(alias, options, function (err, data) {
+ console.log(`test genKey data: ${JSON.stringify(data)}`);
+ if (err.code !== 0) {
+ console.log('test genKey err information: ' + JSON.stringify(err));
+ reject(err);
+ } else {
+ resolve(data);
+ }
+ });
+ });
+}
+
+async function TestExportFunc(alias, options) {
+ await exportKey(alias, options)
+ .then((data) => {
+ console.log(`test exportKey data: ${JSON.stringify(data)}`);
+ })
+ .catch((err) => {
+ console.log('test exportKey err information: ' + JSON.stringify(err));
+ });
+}
+
+function exportKey(alias, options) {
+ return new Promise((resolve, reject) => {
+ huks.exportKey(alias, options, function (err, data) {
+ console.log(`test exportKey data: ${JSON.stringify(data)}`);
+ if (err.code !== 0) {
+ console.log('test exportKey err information: ' + JSON.stringify(err));
+ reject(err);
+ } else {
+ exportWrappingKey = data.outData;
+ resolve(data);
+ }
+ });
+ });
+}
+
+async function TestImportWrappedFunc(alias, wrappingAlias, options) {
+ await importWrappedKey(alias, wrappingAlias, options)
+ .then((data) => {
+ console.log(`TestImportWrappedFunc data: ${JSON.stringify(data)}`);
+ })
+ .catch((err) => {
+ console.log('test importWrappedKey err information: ' + JSON.stringify(err));
+ });
+}
+
+function importWrappedKey(alias, wrappingAlias, options) {
+ return new Promise((resolve, reject) => {
+ huks.importWrappedKey(alias, wrappingAlias, options, function (err, data) {
+ console.log(`importWrappedKey data: ${JSON.stringify(data)}`);
+ if (err.code !== 0) {
+ console.log('importWrappedKey err information: ' + JSON.stringify(err));
+ reject(err);
+ } else {
+ resolve(data);
+ }
+ });
+ });
+}
+
+async function TestImportWrappedKeyFunc(
+ alias,
+ wrappingAlias,
+ genOptions,
+ importOptions
+) {
+ await TestGenFunc(wrappingAlias, genOptions);
+ await TestExportFunc(wrappingAlias, genOptions);
+
+ /*The following operations do not invoke the HUKS APIs, and the specific implementation is not provided here.
+ * For example, import keyA.
+ * 1. Use ECC to generate a public and private key pair keyB. The public key is keyB_pub, and the private key is keyB_pri.
+ * 2. Use keyB_pri and the public key obtained from wrappingAlias to negotiate the shared key share_key.
+ * 3. Randomly generate a key kek for encrypting keyA using AES-GCM. During the encryption, record nonce1/aad1/ciphertext keyA_enc/encrypted tag1.
+ * 4. Use the share_key to encrypt kek using AES-GCM. During the encryption, record nonce2/aad2/ciphertext kek_enc/encrypted tag2.
+ * 5. Generate the importOptions.inData field in the following format:
+ * keyB_pub length (4 bytes) + keyB_pub + aad2 length (4 bytes) + aad2 +
+ * nonce2 length (4 bytes) + nonce2 + tag2 length (4 bytes) + tag2 +
+ * kek_enc length (4 bytes) + kek_enc + aad1 length (4 bytes) + aad1 +
+ * nonce1 length (4 bytes) + nonce1 + tag1 length (4 bytes) + tag1 +
+ * Memory occupied by the keyA length (4 bytes) + keyA length + keyA_enc length (4 bytes) + keyA_enc
+ */
+ var inputKey = new Uint8Array([0x02, 0x00, 0x00, 0x00]);
+ importOptions.inData = inputKey;
+ await TestImportWrappedFunc(alias, wrappingAlias, importOptions);
+}
+
+function makeGenerateOptions() {
+ var properties = new Array();
+ properties[0] = {
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_ECC
+ };
+ properties[1] = {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_ECC_KEY_SIZE_256
+ };
+ properties[2] = {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_UNWRAP
+ };
+ properties[3] = {
+ tag: huks.HuksTag.HUKS_TAG_DIGEST,
+ value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256
+ };
+ var options = {
+ properties: properties
+ };
+ return options;
+};
+
+function makeImportOptions() {
+ var properties = new Array();
+ properties[0] = {
+ tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
+ value: huks.HuksKeyAlg.HUKS_ALG_AES
+ };
+ properties[1] = {
+ tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
+ value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256
+ };
+ properties[2] = {
+ tag: huks.HuksTag.HUKS_TAG_PURPOSE,
+ value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT
+ };
+ properties[3] = {
+ tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE,
+ value: huks.HuksCipherMode.HUKS_MODE_CBC
+ };
+ properties[4] = {
+ tag: huks.HuksTag.HUKS_TAG_UNWRAP_ALGORITHM_SUITE,
+ value: huks.HuksUnwrapSuite.HUKS_UNWRAP_SUITE_ECDH_AES_256_GCM_NOPADDING
+ };
+ var options = {
+ properties: properties
+ };
+ return options;
+};
+
+function huksImportWrappedKey() {
+ var genOptions = makeGenerateOptions();
+ var importOptions = makeImportOptions();
+ TestImportWrappedKeyFunc(
+ alias1,
+ alias2,
+ genOptions,
+ importOptions
+ );
+}
+```
+
+## huks.importWrappedKey9+
+
+importWrappedKey(keyAlias: string, wrappingKeyAlias: string, options: HuksOptions) : Promise\
+
+Imports a wrapped key. This API uses a promise to return the result asynchronously.
+
+**System capability**: SystemCapability.Security.Huks
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ---------------- | --------------------------- | ---- | --------------------------------------------- |
+| keyAlias | string | Yes | Alias of the wrapped key to import. |
+| wrappingKeyAlias | string | Yes | Alias of the data used to unwrap the key imported. |
+| options | [HuksOptions](#huksoptions) | Yes | Tags required for the import and the wrapped key to import.|
+
+**Return value**
+
+| Type | Description |
+| ----------------------------------- | -------------------------------------------------- |
+| Promise\<[HuksResult](#huksresult)> | Promise used to return the result. If the operation is successful, **HUKS_SUCCESS** will be returned. If the operation fails, an error code will be returned.|
+
+**Example**
+
+```js
+/* The process is similar as if a callback is used, except the following:*/
+async function TestImportWrappedFunc(alias, wrappingAlias, options) {
+ var result = await huks.importWrappedKey(alias, wrappingAlias, options);
+ if (result.errorCode === 0) {
+ console.log('test importWrappedKey success');
+ } else {
+ console.log('test importWrappedKey fail');
+ }
+}
+```
+
## huks.exportKey
exportKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback\) : void
@@ -675,7 +932,7 @@ Exports a key. This API uses an asynchronous callback to return the result.
| -------- | ----------------------------------------- | ---- | ------------------------------------------------------------ |
| keyAlias | string | Yes | Key alias, which must be the same as the alias used when the key was generated. |
| options | [HuksOptions](#huksoptions) | Yes | Empty object (leave this parameter empty). |
-| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes | Callback used to return the result. If the operation is successful, **HUKS_SUCCESS** will be returned. If the operation fails, an error code will be returned. **outData** contains the public key exported. |
+| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes | Callback used to return the result. If the operation is successful, **HUKS_SUCCESS** will be returned. If the operation fails, an error code will be returned. **outData** contains the public key exported.|
**Example**
@@ -692,7 +949,7 @@ huks.exportKey(keyAlias, emptyOptions, function (err, data){});
exportKey(keyAlias: string, options: HuksOptions) : Promise\
-Exports a key. This API uses a promise to return the result.
+Exports a key. This API uses a promise to return the result asynchronously.
**System capability**: SystemCapability.Security.Huks
@@ -700,14 +957,14 @@ Exports a key. This API uses a promise to return the result.
| Name | Type | Mandatory| Description |
| -------- | ----------- | ---- | ------------------------------------------------------------ |
-| keyAlias | string | Yes | Key alias, which must be the same as the alias used when the key was generated. |
-| options | [HuksOptions](#huksoptions) | Yes | Empty object (leave this parameter empty). |
+| keyAlias | string | Yes | Key alias, which must be the same as the alias used when the key was generated.|
+| options | [HuksOptions](#huksoptions) | Yes | Empty object (leave this parameter empty).|
**Return value**
| Type | Description |
| ----------------------------------- | ------------------------------------------------------------ |
-| Promise\<[HuksResult](#huksresult)> | Promise used to return the result. If the operation is successful, **HUKS_SUCCESS** will be returned. If the operation fails, an error code will be returned. **outData** contains the public key exported. |
+| Promise\<[HuksResult](#huksresult)> | Promise used to return the result. If the operation is successful, **HUKS_SUCCESS** will be returned. If the operation fails, an error code will be returned. **outData** contains the public key exported.|
**Example**
@@ -734,7 +991,7 @@ Obtains key properties. This API uses an asynchronous callback to return the res
| -------- | ----------------------------------------- | ---- | ------------------------------------------------------------ |
| keyAlias | string | Yes | Key alias, which must be the same as the alias used when the key was generated. |
| options | [HuksOptions](#huksoptions) | Yes | Empty object (leave this parameter empty). |
-| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes | Callback used to return the result. **HUKS_SUCCESS** will be returned if the operation is successful; an error code will be returned otherwise. |
+| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes | Callback used to return the result. If the operation is successful, **errorCode** is **HUKS_SUCCESS**; otherwise, an error code will be returned.|
**Example**
@@ -751,7 +1008,7 @@ huks.getKeyProperties(keyAlias, emptyOptions, function (err, data){});
getKeyProperties(keyAlias: string, options: HuksOptions) : Promise\
-Obtains key properties. This API uses a promise to return the result.
+Obtains key properties. This API uses a promise to return the result asynchronously.
**System capability**: SystemCapability.Security.Huks
@@ -759,14 +1016,14 @@ Obtains key properties. This API uses a promise to return the result.
| Name | Type | Mandatory| Description |
| -------- | ----------- | ---- | ------------------------------------------------------------ |
-| keyAlias | string | Yes | Key alias, which must be the same as the alias used when the key was generated. |
-| options | [HuksOptions](#huksoptions) | Yes | Empty object (leave this parameter empty). |
+| keyAlias | string | Yes | Key alias, which must be the same as the alias used when the key was generated.|
+| options | [HuksOptions](#huksoptions) | Yes | Empty object (leave this parameter empty).|
**Return value**
| Type | Description |
| ------------------ | ------------------------------------------------------------ |
-| Promise\<[HuksResult](#huksoptions)> | Promise used to return the result. In the return result, **HUKS_SUCCESS** will be returned for **errorCode** if the operation is successful; an error code will be returned otherwise. **properties** returns the parameters required for generating the key. |
+| Promise\<[HuksResult](#huksoptions)> | Promise used to return the result. If the operation is successful, **errorCode** is **HUKS_SUCCESS**; otherwise, an error code will be returned. **properties** returns the parameters required for generating the key.|
**Example**
@@ -791,9 +1048,9 @@ Checks whether a key exists. This API uses an asynchronous callback to return th
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ------------------------------------- |
-| keyAlias | string | Yes | Alias of the key to check. |
-| options | [HuksOptions](#huksoptions) | Yes | Empty object (leave this parameter empty). |
-| callback | AsyncCallback\ | Yes | Callback used to return the result. **TRUE** means that the key exists; **FALSE** means the opposite. |
+| keyAlias | string | Yes | Alias of the key to check.|
+| options | [HuksOptions](#huksoptions) | Yes | Empty object (leave this parameter empty).|
+| callback | AsyncCallback\ | Yes | Callback used to return the result. **TRUE** means that the key exists; **FALSE** means the opposite.|
**Example**
@@ -810,7 +1067,7 @@ huks.isKeyExist(keyAlias, emptyOptions, function (err, data){});
isKeyExist(keyAlias: string, options: HuksOptions) : Promise\
-Checks whether a key exists. This API uses a promise to return the result.
+Checks whether a key exists. This API uses a promise to return the result asynchronously.
**System capability**: SystemCapability.Security.Huks
@@ -818,14 +1075,14 @@ Checks whether a key exists. This API uses a promise to return the result.
| Name | Type | Mandatory| Description |
| -------- | ----------- | ---- | -------------------------------- |
-| keyAlias | string | Yes | Alias of the key to check. |
-| options | [HuksOptions](#huksoptions) | Yes | Empty object (leave this parameter empty). |
+| keyAlias | string | Yes | Alias of the key to check.|
+| options | [HuksOptions](#huksoptions) | Yes | Empty object (leave this parameter empty).|
**Return value**
| Type | Description |
| ----------------- | --------------------------------------- |
-| Promise\ | Promise used to return the result. **TRUE** means that the key exists; **FALSE** means the opposite. |
+| Promise\ | Promise used to return the result. **TRUE** means that the key exists; **FALSE** means the opposite.|
**Example**
@@ -852,16 +1109,16 @@ Initializes a key. This API uses an asynchronous callback to return the result.
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ------------------------------------- |
-| keyAlias | string | Yes | Alias of the target key. |
-| options | [HuksOptions](#huksoptions) | Yes | Parameters used for initialization. |
-| callback | AsyncCallback\<[HuksHandle](#hukshandle)> | Yes | Callback used to return the handle of the initialization operation. |
+| keyAlias | string | Yes | Alias of the target key.|
+| options | [HuksOptions](#huksoptions) | Yes | Parameters used for initialization.|
+| callback | AsyncCallback\<[HuksHandle](#hukshandle)> | Yes | Callback used to return the handle of the initialization operation.|
## huks.init
init(keyAlias: string, options: HuksOptions) : Promise\
-Initializes a key. This API uses a promise to return the result.
+Initializes a key. This API uses a promise to return the result asynchronously.
**System capability**: SystemCapability.Security.Huks
@@ -869,9 +1126,9 @@ Initializes a key. This API uses a promise to return the result.
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ------------------------------------- |
-| keyAlias | string | Yes | Alias of the target key. |
-| options | [HuksOptions](#huksoptions) | Yes | Parameters used for initialization. |
-| promise | Promise\<[HuksHandle](#hukshandle)> | Yes | Promise used to return the handle of the initialization operation. |
+| keyAlias | string | Yes | Alias of the target key.|
+| options | [HuksOptions](#huksoptions) | Yes | Parameters used for initialization.|
+| promise | Promise\<[HuksHandle](#hukshandle)> | Yes | Promise used to return the handle of the initialization operation.|
## huks.update
@@ -886,17 +1143,17 @@ Updates a key. This API uses an asynchronous callback to return the result.
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ------------------------------------- |
-| handle | number | Yes | Handle of the **Update** operation. |
-| token | Uint8Array | No| Token of the **Update** operation. |
-| options | [HuksOptions](#huksoptions) | Yes | Parameters of the **Update** operation. |
-| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes| Callback used to return the operation result. |
+| handle | number | Yes | Handle of the **Update** operation.|
+| token | Uint8Array | No| Token of the **Update** operation.|
+| options | [HuksOptions](#huksoptions) | Yes | Parameters of the **Update** operation.|
+| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes| Callback used to return the operation result.|
## huks.update
update(handle: number, token?: Uint8Array, options: HuksOptions) : Promise\
-Updates a key. This API uses a promise to return the result.
+Updates a key. This API uses a promise to return the result asynchronously.
**System capability**: SystemCapability.Security.Huks
@@ -904,10 +1161,10 @@ Updates a key. This API uses a promise to return the result.
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ------------------------------------- |
-| handle | number | Yes | Handle of the **Update** operation. |
-| token | Uint8Array | No| Token of the **Update** operation. |
-| options | [HuksOptions](#huksoptions) | Yes | Parameters of the **Update** operation. |
-| promise | Promise\<[HuksResult](#huksresult)> | Yes| Promise used to return the operation result. |
+| handle | number | Yes | Handle of the **Update** operation.|
+| token | Uint8Array | No| Token of the **Update** operation.|
+| options | [HuksOptions](#huksoptions) | Yes | Parameters of the **Update** operation.|
+| promise | Promise\<[HuksResult](#huksresult)> | Yes| Promise used to return the operation result.|
## huks.finish
@@ -922,16 +1179,16 @@ Completes the key operation and releases resources. This API uses an asynchronou
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ------------------------------------- |
-| handle | number | Yes | Handle of the **Finish** operation. |
-| options | [HuksOptions](#huksoptions) | Yes | Parameters of the **Finish** operation. |
-| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes| Callback used to return the operation result. |
+| handle | number | Yes | Handle of the **Finish** operation.|
+| options | [HuksOptions](#huksoptions) | Yes | Parameters of the **Finish** operation.|
+| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes| Callback used to return the operation result.|
## huks.finish
finish(handle: number, options: HuksOptions) : Promise\
-Completes the key operation and releases resources. This API uses a promise to return the result.
+Completes the key operation and releases resources. This API uses a promise to return the result asynchronously.
**System capability**: SystemCapability.Security.Huks
@@ -939,9 +1196,9 @@ Completes the key operation and releases resources. This API uses a promise to r
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ------------------------------------- |
-| handle | number | Yes | Handle of the **Finish** operation. |
-| options | [HuksOptions](#huksoptions) | Yes | Parameters of the **Finish** operation. |
-| promise | Promise\<[HuksResult](#HuksResult)> | Yes| Promise used to return the operation result. |
+| handle | number | Yes | Handle of the **Finish** operation.|
+| options | [HuksOptions](#huksoptions) | Yes | Parameters of the **Finish** operation.|
+| promise | Promise\<[HuksResult](#HuksResult)> | Yes| Promise used to return the operation result.|
## huks.abort
@@ -956,9 +1213,9 @@ Aborts the use of the key. This API uses an asynchronous callback to return the
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ------------------------------------- |
-| handle | number | Yes | Handle of the **Abort** operation. |
-| options | [HuksOptions](#huksoptions) | Yes | Parameters of the **Abort** operation. |
-| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes| Callback used to return the operation result. |
+| handle | number | Yes | Handle of the **Abort** operation.|
+| options | [HuksOptions](#huksoptions) | Yes | Parameters of the **Abort** operation.|
+| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes| Callback used to return the operation result.|
**Example**
@@ -1168,7 +1425,7 @@ struct Index {
abort(handle: number, options: HuksOptions) : Promise\;
-Aborts the use of the key. This API uses a promise to return the result.
+Aborts the use of the key. This API uses a promise to return the result asynchronously.
**System capability**: SystemCapability.Security.Huks
@@ -1176,9 +1433,9 @@ Aborts the use of the key. This API uses a promise to return the result.
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ------------------------------------- |
-| handle | number | Yes | Handle of the **Abort** operation. |
-| options | [HuksOptions](#huksoptions) | Yes | Parameters of the **Abort** operation. |
-| promise | Promise\<[HuksResult](#huksresult)> | Yes| Promise used to return the operation result. |
+| handle | number | Yes | Handle of the **Abort** operation.|
+| options | [HuksOptions](#huksoptions) | Yes | Parameters of the **Abort** operation.|
+| promise | Promise\<[HuksResult](#huksresult)> | Yes| Promise used to return the operation result.|
**Example**
@@ -1399,7 +1656,7 @@ Defines the **param** in the **properties** array of **options** used in the API
| Name| Type | Mandatory| Description |
| ------ | ----------------------------------- | ---- | ---------- |
| tag | HuksTag | Yes | Tag. |
-| value | boolean\|number\|bigint\|Uint8Array | Yes | Value of the tag. |
+| value | boolean\|number\|bigint\|Uint8Array | Yes | Value of the tag.|
## HuksOptions
@@ -1409,7 +1666,7 @@ Defines the **options** used in the APIs.
| Name | Type | Mandatory| Description |
| ---------- | ----------------- | ---- | ------------------------ |
-| properties | Array\ | No | Array used to hold **HuksParam**. |
+| properties | Array\ | No | Array used to hold **HuksParam**.|
| inData | Uint8Array | No | Input data. |
## HuksHandle
@@ -1418,11 +1675,11 @@ Defines the HUKS handle structure.
**System capability**: SystemCapability.Security.Huks
-| Name | Type | Mandatory | Description |
+| Name | Type | Mandatory| Description |
| ---------- | ---------------- | ---- | -------- |
-| errorCode | number | Yes | Error code. |
-| handle | number | Yes| Value of the handle. |
-| token | Uint8Array | No| Reserved. |
+| errorCode | number | Yes | Error code.|
+| handle | number | Yes| Value of the handle.|
+| token | Uint8Array | No| Reserved.|
## HuksResult
@@ -1433,9 +1690,9 @@ Defines the **HuksResult** structure.
-| Name | Type | Mandatory | Description |
+| Name | Type | Mandatory| Description |
| ---------- | ----------------- | ---- | -------- |
| errorCode | number | Yes | Error code. |
-| outData | Uint8Array | No | Output data. |
+| outData | Uint8Array | No | Output data.|
| properties | Array\ | No | Properties. |
| certChains | Array\ | No | Certificate chain. |
diff --git a/en/application-dev/reference/apis/js-apis-i18n.md b/en/application-dev/reference/apis/js-apis-i18n.md
index d06667da7dc1cd4efce41464968cd975309418d7..dc9f7442dab9fd1b39f12cf3fff71bfd83c13551 100644
--- a/en/application-dev/reference/apis/js-apis-i18n.md
+++ b/en/application-dev/reference/apis/js-apis-i18n.md
@@ -1461,7 +1461,7 @@ Obtains the **TimeZone** object corresponding to the specified time zone ID.
```
-## RelativeTimeFormat8+
+## TimeZone8+
### getID8+
diff --git a/en/application-dev/reference/apis/js-apis-image.md b/en/application-dev/reference/apis/js-apis-image.md
index 5b564c7addd10b39e5873bf50faa84efc9ff1ad6..ff9c8b14b4aba73b734f9fb61f4e6f2d1d2755aa 100644
--- a/en/application-dev/reference/apis/js-apis-image.md
+++ b/en/application-dev/reference/apis/js-apis-image.md
@@ -1,6 +1,7 @@
# Image Processing
-> **NOTE**
+> **NOTE**
+>
> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
@@ -20,7 +21,7 @@ Creates a **PixelMap** object. This API uses a promise to return the result.
| Name | Type | Mandatory| Description |
| ------- | ------------------------------------------------ | ---- | ------------------------------------------------------------ |
-| colors | ArrayBuffer | Yes | Color array. |
+| colors | ArrayBuffer | Yes | Color array in BGRA_8888 format. |
| options | [InitializationOptions](#initializationoptions8) | Yes | Pixel properties, including the alpha type, size, scale mode, pixel format, and editable.|
**Return value**
@@ -32,9 +33,11 @@ Creates a **PixelMap** object. This API uses a promise to return the result.
**Example**
```js
-image.createPixelMap(Color, opts)
- .then((pixelmap) => {
- })
+const color = new ArrayBuffer(96);
+let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
+image.createPixelMap(color, opts)
+ .then((pixelmap) => {
+ })
```
## image.createPixelMap8+
@@ -49,15 +52,17 @@ Creates a **PixelMap** object. This API uses an asynchronous callback to return
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------ | ---- | -------------------------- |
-| colors | ArrayBuffer | Yes | Color array. |
+| colors | ArrayBuffer | Yes | Color array in BGRA_8888 format. |
| options | [InitializationOptions](#initializationoptions8) | Yes | Pixel properties. |
| callback | AsyncCallback\<[PixelMap](#pixelmap7)> | Yes | Callback used to return the **PixelMap** object.|
**Example**
```js
-image.createPixelMap(Color, opts, (pixelmap) => {
- })
+const color = new ArrayBuffer(96);
+let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
+image.createPixelMap(color, opts, (pixelmap) => {
+ })
```
## PixelMap7+
@@ -95,11 +100,11 @@ Reads image pixel map data and writes the data to an **ArrayBuffer**. This API u
**Example**
```js
-pixelmap.readPixelsToBuffer(readBuffer).then(() => {
- // Called if the condition is met.
- }).catch(error => {
- // Called if no condition is met.
- })
+pixelmap.readPixelsToBuffer(ReadBuffer).then(() => {
+ console.log('readPixelsToBuffer succeeded.'); // Called if the condition is met.
+}).catch(error => {
+ console.log('readPixelsToBuffer failed.'); // Called if no condition is met.
+})
```
### readPixelsToBuffer7+
@@ -120,8 +125,13 @@ Reads image pixel map data and writes the data to an **ArrayBuffer**. This API u
**Example**
```js
-pixelmap.readPixelsToBuffer(readBuffer, () => {
- })
+pixelmap.readPixelsToBuffer(ReadBuffer, (err, res) => {
+ if(err) {
+ console.log('readPixelsToBuffer failed.'); // Called if the condition is met.
+ } else {
+ console.log('readPixelsToBuffer succeeded.'); // Called if the condition is met.
+ }
+})
```
### readPixels7+
@@ -147,11 +157,11 @@ Reads image pixel map data in an area. This API uses a promise to return the dat
**Example**
```js
-pixelmap.readPixels(area).then((data) => {
- // Called if the condition is met.
- }).catch(error => {
- // Called if no condition is met.
- })
+pixelmap.readPixels(Area).then((data) => {
+ console.log('readPixels succeeded.'); // Called if the condition is met.
+}).catch(error => {
+ console.log('readPixels failed.'); // Called if no condition is met.
+})
```
### readPixels7+
@@ -174,19 +184,17 @@ Reads image pixel map data in an area. This API uses an asynchronous callback to
```js
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts, (err, pixelmap) => {
- if(pixelmap == undefined){
- console.info('createPixelMap failed');
- expect(false).assertTrue();
- done();
- }else{
- const area = { pixels: new ArrayBuffer(8),
- offset: 0,
- stride: 8,
- region: { size: { height: 1, width: 2 }, x: 0, y: 0 }}
- pixelmap.readPixels(area, () => {
- console.info('readPixels success');
- })
- }
+ if(pixelmap == undefined){
+ console.info('createPixelMap failed.');
+ } else {
+ const area = { pixels: new ArrayBuffer(8),
+ offset: 0,
+ stride: 8,
+ region: { size: { height: 1, width: 2 }, x: 0, y: 0 }};
+ pixelmap.readPixels(area, () => {
+ console.info('readPixels success');
+ })
+ }
})
```
@@ -218,9 +226,7 @@ let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts)
.then( pixelmap => {
if (pixelmap == undefined) {
- console.info('createPixelMap failed');
- expect(false).assertTrue()
- done();
+ console.info('createPixelMap failed.');
}
const area = { pixels: new ArrayBuffer(8),
offset: 0,
@@ -240,11 +246,8 @@ image.createPixelMap(color, opts)
region: { size: { height: 1, width: 2 }, x: 0, y: 0 }
}
})
- })
- .catch(error => {
+ }).catch(error => {
console.log('error: ' + error);
- expect().assertFail();
- done();
})
```
@@ -266,14 +269,14 @@ Writes image pixel map data to an area. This API uses an asynchronous callback t
**Example**
```js
-pixelmap.writePixels(area, () => {
- const readArea = {
- pixels: new ArrayBuffer(20),
- offset: 0,
- stride: 8,
- region: { size: { height: 1, width: 2 }, x: 0, y: 0 },
- }
- })
+pixelmap.writePixels(Area, () => {
+ const readArea = {
+ pixels: new ArrayBuffer(20),
+ offset: 0,
+ stride: 8,
+ region: { size: { height: 1, width: 2 }, x: 0, y: 0 },
+ }
+})
```
### writeBufferToPixels7+
@@ -299,11 +302,11 @@ Reads image data in an **ArrayBuffer** and writes the data to a **PixelMap** obj
**Example**
```js
-pixelMap.writeBufferToPixels(colorBuffer).then(() => {
+PixelMap.writeBufferToPixels(color).then(() => {
console.log("Succeeded in writing data from a buffer to a PixelMap.");
}).catch((err) => {
console.error("Failed to write data from a buffer to a PixelMap.");
-});
+})
```
### writeBufferToPixels7+
@@ -324,12 +327,13 @@ Reads image data in an **ArrayBuffer** and writes the data to a **PixelMap** obj
**Example**
```js
-pixelMap.writeBufferToPixels(colorBuffer, function(err) {
+PixelMap.writeBufferToPixels(color, function(err) {
if (err) {
console.error("Failed to write data from a buffer to a PixelMap.");
return;
- }
- console.log("Succeeded in writing data from a buffer to a PixelMap.");
+ } else {
+ console.log("Succeeded in writing data from a buffer to a PixelMap.");
+ }
});
```
@@ -350,7 +354,7 @@ Obtains pixel map information of this image. This API uses a promise to return t
**Example**
```js
-pixelMap.getImageInfo().then(function(info) {
+PixelMap.getImageInfo().then(function(info) {
console.log("Succeeded in obtaining the image pixel map information.");
}).catch((err) => {
console.error("Failed to obtain the image pixel map information.");
@@ -374,7 +378,11 @@ Obtains pixel map information of this image. This API uses an asynchronous callb
**Example**
```js
-pixelmap.getImageInfo((imageInfo) => {})
+pixelmap.getImageInfo((imageInfo) => {
+ console.log("getImageInfo succeeded.");
+}).catch((err) => {
+ console.error("getImageInfo failed.");
+})
```
### getBytesNumberPerRow7+
@@ -394,7 +402,9 @@ Obtains the number of bytes per line of the image pixel map.
**Example**
```js
-rowCount = pixelmap.getBytesNumberPerRow()
+image.createPixelMap(clolr, opts, (err,pixelmap) => {
+ let rowCount = pixelmap.getBytesNumberPerRow();
+})
```
### getPixelBytesNumber7+
@@ -414,7 +424,7 @@ Obtains the total number of bytes of the image pixel map.
**Example**
```js
-pixelBytesNumber = pixelmap.getPixelBytesNumber()
+let pixelBytesNumber = pixelmap.getPixelBytesNumber();
```
### release7+
@@ -434,8 +444,13 @@ Releases this **PixelMap** object. This API uses a promise to return the result.
**Example**
```js
- pixelmap.release().then(() => { })
- .catch(error => {})
+image.createPixelMap(color, opts, (pixelmap) => {
+ pixelmap.release().then(() => {
+ console.log('release succeeded.');
+ }).catch(error => {
+ console.log('release failed.');
+ })
+})
```
### release7+
@@ -455,7 +470,13 @@ Releases this **PixelMap** object. This API uses an asynchronous callback to ret
**Example**
```js
-pixelmap.release(()=>{ })
+image.createPixelMap(color, opts, (pixelmap) => {
+ pixelmap.release().then(() => {
+ console.log('release succeeded.');
+ }).catch(error => {
+ console.log('release failed.');
+ })
+})
```
## image.createImageSource
@@ -508,7 +529,7 @@ Creates an **ImageSource** instance based on the file descriptor.
**Example**
```js
-const imageSourceApi = image.createImageSource(0)
+const imageSourceApi = image.createImageSource(0);
```
## ImageSource
@@ -541,7 +562,13 @@ Obtains information about an image with the specified index. This API uses an as
**Example**
```js
-imageSourceApi.getImageInfo(0,(error, imageInfo) => {})
+imageSourceApi.getImageInfo(0,(error, imageInfo) => {
+ if(error) {
+ console.log('getImageInfo failed.');
+ } else {
+ console.log('getImageInfo succeeded.');
+ }
+})
```
### getImageInfo
@@ -561,7 +588,11 @@ Obtains information about this image. This API uses an asynchronous callback to
**Example**
```js
-imageSourceApi.getImageInfo(imageInfo => {})
+imageSourceApi.getImageInfo(imageInfo => {
+ console.log('getImageInfo succeeded.');
+}).catch(error => {
+ console.log('getImageInfo failed.');
+})
```
### getImageInfo
@@ -588,8 +619,11 @@ Obtains information about an image with the specified index. This API uses a pro
```js
imageSourceApi.getImageInfo(0)
- .then(imageInfo => {})
- .catch(error => {})
+ .then(imageInfo => {
+ console.log('getImageInfo succeeded.');
+ }).catch(error => {
+ console.log('getImageInfo failed.');
+ })
```
### getImageProperty7+
@@ -617,8 +651,11 @@ Obtains the value of a property with the specified index in this image. This API
```js
imageSourceApi.getImageProperty("BitsPerSample")
- .then(data => {})
- .catch(error => {})
+ .then(data => {
+ console.log('getImageProperty succeeded.');
+ }).catch(error => {
+ console.log('getImageProperty failed.');
+ })
```
### getImageProperty7+
@@ -639,7 +676,13 @@ Obtains the value of a property with the specified index in this image. This API
**Example**
```js
-imageSourceApi.getImageProperty("BitsPerSample",(error,data) => {})
+imageSourceApi.getImageProperty("BitsPerSample",(error,data) => {
+ if(error) {
+ console.log('getImageProperty failed.');
+ } else {
+ console.log('getImageProperty succeeded.');
+ }
+})
```
### getImageProperty7+
@@ -661,7 +704,13 @@ Obtains the value of a property in this image. This API uses an asynchronous cal
**Example**
```js
-imageSourceApi.getImageProperty("BitsPerSample",property,(error,data) => {})
+imageSourceApi.getImageProperty("BitsPerSample",Property,(error,data) => {
+ if(error) {
+ console.log('getImageProperty failed.');
+ } else {
+ console.log('getImageProperty succeeded.');
+ }
+})
```
### createPixelMap7+
@@ -687,8 +736,11 @@ Creates a **PixelMap** object based on image decoding parameters. This API uses
**Example**
```js
-imageSourceApi.createPixelMap().then(pixelmap => {})
- .catch(error => {})
+imageSourceApi.createPixelMap().then(pixelmap => {
+ console.log('createPixelMap succeeded.');
+}).catch(error => {
+ console.log('createPixelMap failed.');
+})
```
### createPixelMap7+
@@ -708,7 +760,11 @@ Creates a **PixelMap** object based on the default parameters. This API uses an
**Example**
```js
-imageSourceApi.createPixelMap(pixelmap => {})
+imageSourceApi.createPixelMap(pixelmap => {
+ console.log('createPixelMap succeeded.');
+}).catch(error => {
+ console.log('createPixelMap failed.');
+})
```
### createPixelMap7+
@@ -729,7 +785,11 @@ Creates a **PixelMap** object based on image decoding parameters. This API uses
**Example**
```js
-imageSourceApi.createPixelMap(decodingOptions, pixelmap => {})
+imageSourceApi.createPixelMap(decodingOptions, pixelmap => {
+ console.log('createPixelMap succeeded.');
+}).catch(error => {
+ console.log('createPixelMap failed.');
+})
```
### release
@@ -749,7 +809,11 @@ Releases this **ImageSource** instance. This API uses an asynchronous callback t
**Example**
```js
-imageSourceApi.release(() => {})
+imageSourceApi.release(() => {
+ console.log('release succeeded.');
+}).catch(error => {
+ console.log('release failed.');
+})
```
### release
@@ -769,7 +833,11 @@ Releases this **ImageSource** instance. This API uses a promise to return the re
**Example**
```js
-imageSourceApi.release().then(()=>{ }).catch(error => {})
+imageSourceApi.release().then(()=>{
+ console.log('release succeeded.');
+}).catch(error => {
+ console.log('release failed.');
+})
```
## image.createImagePacker
@@ -823,8 +891,8 @@ Packs an image. This API uses an asynchronous callback to return the result.
**Example**
```js
-let packOpts = { format:["image/jpeg"], quality:98 }
-imagePackerApi.packing(imageSourceApi, packOpts, data => {})
+let packOpts = { format:["image/jpeg"], quality:98 };
+imagePackerApi.packing(ImageSourceApi, packOpts, data => {})
```
### packing
@@ -852,9 +920,12 @@ Packs an image. This API uses a promise to return the result.
```js
let packOpts = { format:["image/jpeg"], quality:98 }
-imagePackerApi.packing(imageSourceApi, packOpts)
- .then( data => { })
- .catch(error => {})
+imagePackerApi.packing(ImageSourceApi, packOpts)
+ .then( data => {
+ console.log('packing succeeded.');
+ }).catch(error => {
+ console.log('packing failed.');
+ })
```
### packing8+
@@ -877,7 +948,11 @@ Packs an image. This API uses an asynchronous callback to return the result.
```js
let packOpts = { format:["image/jpeg"], quality:98 }
-imagePackerApi.packing(pixelMapApi, packOpts, data => {})
+imagePackerApi.packing(PixelMapApi, packOpts, data => {
+ console.log('packing succeeded.');
+}).catch(error => {
+ console.log('packing failed.');
+})
```
### packing8+
@@ -905,9 +980,12 @@ Packs an image. This API uses a promise to return the result.
```js
let packOpts = { format:["image/jpeg"], quality:98 }
-imagePackerApi.packing(pixelMapApi, packOpts)
- .then( data => { })
- .catch(error => {})
+imagePackerApi.packing(PixelMapApi, packOpts)
+ .then( data => {
+ console.log('packing succeeded.');
+ }).catch(error => {
+ console.log('packing failed.');
+ })
```
### release
@@ -927,7 +1005,11 @@ Releases this **ImagePacker** instance. This API uses an asynchronous callback t
**Example**
```js
-imagePackerApi.release(()=>{})
+imagePackerApi.release(()=>{
+ console.log('release succeeded.');
+}).catch(error => {
+ console.log('release failed.');
+})
```
### release
@@ -947,8 +1029,11 @@ Releases this **ImagePacker** instance. This API uses a promise to return the re
**Example**
```js
- imagePackerApi.release().then(()=>{
- }).catch((error)=>{})
+imagePackerApi.release().then(()=>{
+ console.log('release succeeded.');
+}).catch((error)=>{
+ console.log('release failed.');
+})
```
## image.createImageReceiver9+
@@ -977,7 +1062,7 @@ Create an **ImageReceiver** instance by specifying the image width, height, form
**Example**
```js
-var receiver = image.createImageReceiver(8192, 8, 4, 8)
+var receiver = image.createImageReceiver(8192, 8, 4, 8);
```
## ImageReceiver9+
@@ -1013,7 +1098,13 @@ Obtains a surface ID for the camera or other components. This API uses an asynch
**Example**
```js
- receiver.getReceivingSurfaceId((err, id) => {});
+ receiver.getReceivingSurfaceId((err, id) => {
+ if(err) {
+ console.log('getReceivingSurfaceId failed.');
+ } else {
+ console.log('getReceivingSurfaceId succeeded.');
+ }
+});
```
### getReceivingSurfaceId9+
@@ -1034,8 +1125,10 @@ Obtains a surface ID for the camera or other components. This API uses a promise
```js
receiver.getReceivingSurfaceId().then( id => {
- }).catch(error => {
- })
+ console.log('getReceivingSurfaceId succeeded.');
+}).catch(error => {
+ console.log('getReceivingSurfaceId failed.');
+})
```
### readLatestImage9+
@@ -1055,7 +1148,13 @@ Reads the latest image from the **ImageReceiver** instance. This API uses an asy
**Example**
```js
- receiver.readLatestImage((err, img) => { });
+receiver.readLatestImage((err, img) => {
+ if(err) {
+ console.log('readLatestImage failed.');
+ } else {
+ console.log('readLatestImage succeeded.');
+ }
+});
```
### readLatestImage9+
@@ -1075,8 +1174,11 @@ Reads the latest image from the **ImageReceiver** instance. This API uses a prom
**Example**
```js
-receiver.readLatestImage().then(img => {})
- .catch(error => {})
+receiver.readLatestImage().then(img => {
+ console.log('readLatestImage succeeded.');
+}).catch(error => {
+ console.log('readLatestImage failed.');
+})
```
### readNextImage9+
@@ -1096,7 +1198,13 @@ Reads the next image from the **ImageReceiver** instance. This API uses an async
**Example**
```js
-receiver.readNextImage((err, img) => {});
+receiver.readNextImage((err, img) => {
+ if(err) {
+ console.log('readNextImage failed.');
+ } else {
+ console.log('readNextImage succeeded.');
+ }
+});
```
### readNextImage9+
@@ -1116,9 +1224,11 @@ Reads the next image from the **ImageReceiver** instance. This API uses a promis
**Example**
```js
- receiver.readNextImage().then(img => {
- }).catch(error => {
- })
+receiver.readNextImage().then(img => {
+ console.log('readNextImage succeeded.');
+}).catch(error => {
+ console.log('readNextImage failed.');
+})
```
### on('imageArrival')9+
@@ -1139,7 +1249,7 @@ Listens for image arrival events.
**Example**
```js
- receiver.on('imageArrival', () => {})
+receiver.on('imageArrival', () => {})
```
### release9+
@@ -1159,7 +1269,7 @@ Releases this **ImageReceiver** instance. This API uses an asynchronous callback
**Example**
```js
- receiver.release(() => {})
+receiver.release(() => {})
```
### release9+
@@ -1179,8 +1289,11 @@ Releases this **ImageReceiver** instance. This API uses a promise to return the
**Example**
```js
- receiver.release().then(() => {})
- .catch(error => {})
+receiver.release().then(() => {
+ console.log('release succeeded.');
+}).catch(error => {
+ console.log('release failed.');
+})
```
## Image9+
@@ -1215,7 +1328,13 @@ Obtains the component buffer from the **Image** instance based on the color comp
**Example**
```js
- img.getComponent(4, (err, component) => {})
+img.getComponent(4, (err, component) => {
+ if(err) {
+ console.log('getComponent failed.');
+ } else {
+ console.log('getComponent succeeded.');
+ }
+})
```
### getComponent9+
@@ -1263,7 +1382,11 @@ The corresponding resources must be released before another image arrives.
**Example**
```js
-img.release(() =>{ })
+img.release(() =>{
+ console.log('release succeeded.');
+}).catch(error => {
+ console.log('release failed.');
+})
```
### release9+
@@ -1286,8 +1409,10 @@ The corresponding resources must be released before another image arrives.
```js
img.release().then(() =>{
- }).catch(error => {
- })
+ console.log('release succeeded.');
+}).catch(error => {
+ console.log('release failed.');
+})
```
## PositionArea7+
@@ -1388,7 +1513,7 @@ Defines image decoding options.
| desiredSize | [Size](#size) | Yes | Yes | Expected output size. |
| desiredRegion | [Region](#region7) | Yes | Yes | Region to decode. |
| desiredPixelFormat | [PixelMapFormat](#pixelmapformat7) | Yes | Yes | Pixel map format for decoding.|
-| index | numer | Yes | Yes | Index of the image to decode. |
+| index | number | Yes | Yes | Index of the image to decode. |
## Region7+
diff --git a/en/application-dev/reference/apis/js-apis-inputdevice.md b/en/application-dev/reference/apis/js-apis-inputdevice.md
index b7dc7ccd495f9ea74eb31f17af6bee58036703ad..c47a977b1f2b1559488b6f6602a6ed116ad88197 100644
--- a/en/application-dev/reference/apis/js-apis-inputdevice.md
+++ b/en/application-dev/reference/apis/js-apis-inputdevice.md
@@ -36,7 +36,7 @@ Enables listening for hot swap events of an input device.
let isPhysicalKeyboardExist = true;
inputDevice.on("change", (data) => {
console.log("type: " + data.type + ", deviceId: " + data.deviceId);
- inputDevice.getKeyboardType(data.deviceId, (ret) => {
+ inputDevice.getKeyboardType(data.deviceId, (err, ret) => {
console.log("The keyboard type of the device is: " + ret);
if (ret == inputDevice.KeyboardType.ALPHABETIC_KEYBOARD && data.type == 'add') {
// The physical keyboard is connected.
@@ -68,12 +68,12 @@ Disables listening for hot swap events of an input device.
**Example**
```js
-listener: function(data) {
+function listener(data) {
console.log("type: " + data.type + ", deviceId: " + data.deviceId);
}
// Disable this listener.
-inputDevice.off("change", this.listener);
+inputDevice.off("change", listener);
// Disable all listeners.
inputDevice.off("change");
@@ -104,7 +104,7 @@ inputDevice.getDeviceIds((ids)=>{
## inputDevice.getDeviceIds
-function getDeviceIds(): Promise<<Array<number>>
+getDeviceIds(): Promise<Array<number>>
Obtains the IDs of all input devices. This API uses a promise to return the result.
@@ -150,7 +150,7 @@ inputDevice.getDevice(1, (inputDevice)=>{
## inputDevice.getDevice
-function getDevice(deviceId: number): Promise<InputDeviceData>
+getDevice(deviceId: number): Promise<InputDeviceData>
Obtains information about an input device. This API uses a promise to return the result.
@@ -336,7 +336,7 @@ Defines the axis range of an input device.
| Name | Type | Description |
| ----------------------- | ------------------------- | -------- |
| source | [SourceType](#sourcetype) | Input source type of the axis.|
-| axis | [AxisType](axistype) | Axis type. |
+| axis | [AxisType](#axistype) | Axis type. |
| max | number | Maximum value of the axis. |
| min | number | Minimum value of the axis. |
| fuzz9+ | number | Fuzzy value of the axis. |
diff --git a/en/application-dev/reference/apis/js-apis-inputmethod.md b/en/application-dev/reference/apis/js-apis-inputmethod.md
index a89590f552dd1a55408fd2743bffc9cde1f73e14..0b7fc7a4e6e20b0cbd760c85d4ac3ee120b6a6cf 100644
--- a/en/application-dev/reference/apis/js-apis-inputmethod.md
+++ b/en/application-dev/reference/apis/js-apis-inputmethod.md
@@ -1,7 +1,8 @@
# Input Method Framework
->  **NOTE** The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+> **NOTE**
>
+> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
@@ -21,7 +22,7 @@ Provides the constants.
| MAX_TYPE_NUM | number | Yes| No| Maximum number of supported input methods.|
-## InputMethodProperty8+
+## InputMethodProperty8+
Describes the input method application attributes.
@@ -32,7 +33,7 @@ Describes the input method application attributes.
| packageName | string | Yes| No| Package name.|
| methodId | string | Yes| No| Ability name.|
-## inputMethod.getInputMethodController
+## inputMethod.getInputMethodController
getInputMethodController(): InputMethodController
@@ -48,11 +49,11 @@ Obtains an [InputMethodController](#InputMethodController) instance.
**Example**
-```
-var InputMethodController = inputMethod.getInputMethodController();
+```js
+ var InputMethodController = inputMethod.getInputMethodController();
```
-## inputMethod.getInputMethodSetting8+
+## inputMethod.getInputMethodSetting8+
getInputMethodSetting(): InputMethodSetting
@@ -69,10 +70,10 @@ Obtains an [InputMethodSetting](#InputMethodSetting) instance.
**Example**
```js
-var InputMethodSetting = inputMethod.getInputMethodSetting();
+ var InputMethodSetting = inputMethod.getInputMethodSetting();
```
-## InputMethodController
+## InputMethodController
In the following API examples, you must first use [getInputMethodController](#getInputMethodController) to obtain an **InputMethodController** instance, and then call the APIs using the obtained instance.
@@ -93,7 +94,7 @@ Hides the keyboard. This API uses an asynchronous callback to return the result.
**Example**
```js
- InputMethodController.stopInput((error)=>{
+ InputMethodController.stopInput((error)=>{
console.info('stopInput');
});
```
@@ -116,11 +117,11 @@ Hides the keyboard. This API uses an asynchronous callback to return the result.
```js
- var isSuccess = InputMethodController.stopInput();
- console.info('stopInput isSuccess = ' + isSuccess);
+ var isSuccess = InputMethodController.stopInput();
+ console.info('stopInput isSuccess = ' + isSuccess);
```
-## InputMethodSetting8+
+## InputMethodSetting8+
In the following API examples, you must first use [getInputMethodSetting](#getInputMethodSetting) to obtain an **InputMethodSetting** instance, and then call the APIs using the obtained instance.
@@ -141,12 +142,12 @@ Obtains the list of installed input methods. This API uses an asynchronous callb
**Example**
```js
- InputMethodSetting.listInputMethod((properties)=>{
- for (var i = 0;i < properties.length; i++) {
- var property = properties[i];
- console.info(property.packageName + "/" + property.methodId);
- }
-});
+ InputMethodSetting.listInputMethod((properties)=>{
+ for (var i = 0;i < properties.length; i++) {
+ var property = properties[i];
+ console.info(property.packageName + "/" + property.methodId);
+ }
+ });
```
### listInputMethod
@@ -166,11 +167,11 @@ Obtains the list of installed input methods. This API uses an asynchronous callb
**Example**
```js
- var properties = InputMethodSetting.listInputMethod();
- for (var i = 0;i < properties.length; i++) {
- var property = properties[i];
- console.info(property.packageName + "/" + property.methodId);
- }
+ var properties = InputMethodSetting.listInputMethod();
+ for (var i = 0;i < properties.length; i++) {
+ var property = properties[i];
+ console.info(property.packageName + "/" + property.methodId);
+ }
```
### displayOptionalInputMethod
@@ -189,14 +190,14 @@ Displays a dialog box for selecting an input method. This API uses an asynchrono
**Example**
```js
- InputMethodSetting.displayOptionalInputMethod(()=>{
- console.info('displayOptionalInputMethod is called');
- });
+ InputMethodSetting.displayOptionalInputMethod(()=>{
+ console.info('displayOptionalInputMethod is called');
+ });
```
### displayOptionalInputMethod
-displayOptionalInputMethod(): Promise<void>
+ displayOptionalInputMethod(): Promise<void>
Displays a dialog box for selecting an input method. This API uses an asynchronous callback to return the result.
@@ -211,5 +212,5 @@ Displays a dialog box for selecting an input method. This API uses an asynchrono
**Example**
```js
- InputMethodSetting.displayOptionalInputMethod();
+ InputMethodSetting.displayOptionalInputMethod();
```
\ No newline at end of file
diff --git a/en/application-dev/reference/apis/js-apis-intl.md b/en/application-dev/reference/apis/js-apis-intl.md
index ef18b367bd83082946103da35aba0cf6684e8e87..2ae9a62bcd2d4a436cfdef61c31383ed929b09b6 100644
--- a/en/application-dev/reference/apis/js-apis-intl.md
+++ b/en/application-dev/reference/apis/js-apis-intl.md
@@ -136,7 +136,7 @@ Represents the locale options.
| Name | Type | Readable | Writable | Description |
| --------------- | ------- | ---- | ---- | ---------------------------------------- |
-| calendar | string | Yes | Yes | Calendar for the locale. The calue can be any of the following: **buddhist**, **chinese**, **coptic**, **dangi**, **ethioaa**, **ethiopic**, **gregory**, **hebrew**, **indian**, **islamic**, **islamic-umalqura**, **islamic-tbla**, **islamic-civil**, **islamic-rgsa**, **iso8601**, **japanese**, **persian**, **roc**, **islamicc**.|
+| calendar | string | Yes | Yes | Calendar for the locale. The value can be any of the following: **buddhist**, **chinese**, **coptic**, **dangi**, **ethioaa**, **ethiopic**, **gregory**, **hebrew**, **indian**, **islamic**, **islamic-umalqura**, **islamic-tbla**, **islamic-civil**, **islamic-rgsa**, **iso8601**, **japanese**, **persian**, **roc**, **islamicc**.|
| collation | string | Yes | Yes | Collation rule. The value can be any of the following: **big5han**, **compat**, **dict**, **direct**, **ducet**, **emoji**, **eor**, **gb2312**, **phonebk**, **phonetic**, **pinyin**, **reformed**,**search**, **searchjl**, **standard**, **stroke**, **trad**, **unihan**, **zhuyin**.|
| hourCycle | string | Yes | Yes | Time system for the locale. The value can be any of the following: **h11**, **h12**, **h23**, **h24**.|
| numberingSystem | string | Yes | Yes | Numbering system for the locale. The value can be any of the following: **adlm**, **ahom**, **arab**, **arabext**, **bali**, **beng**, **bhks**, **brah**, **cakm**, **cham**, **deva**, **diak**, **fullwide**, **gong**, **gonm**, **gujr**, **guru**, **hanidec**, **hmng**, **hmnp**, **java**, **kali**, **khmr**, **knda**, **lana**, **lanatham**, **laoo**, **latn**, **lepc**, **limb**, **mathbold**, **mathdbl**, **mathmono**, **mathsanb**, **mathsans**, **mlym**, **modi**, **mong**, **mroo**, **mtei**, **mymr**, **mymrshan**, **mymrtlng**, **newa**, **nkoo**, **olck**, **orya**, **osma**, **rohg**, **saur**, **segment**, **shrd**, **sind**, **sinh**, **sora**, **sund**, **takr**, **talu**, **tamldec**, **telu**, **thai**, **tibt**, **tirh**, **vaii**, **wara**, **wcho**.|
diff --git a/en/application-dev/reference/apis/js-apis-lightweightmap.md b/en/application-dev/reference/apis/js-apis-lightweightmap.md
index 5273e9290e9be72ee4c4ed9e7aefc412c6805e2a..5ac480761ba58f22e2f120aeaa0aca58faed366d 100644
--- a/en/application-dev/reference/apis/js-apis-lightweightmap.md
+++ b/en/application-dev/reference/apis/js-apis-lightweightmap.md
@@ -1,27 +1,34 @@
# Nonlinear Container LightWeightMap
->  **NOTE**
+> **NOTE**
+>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+**LightWeightMap** stores key-value (KV) pairs. Each key must be unique and have only one value.
+
+**LightWeightMap** is based on generics and uses a lightweight structure. Keys in the map are searched using hash values, which are stored in an array.
+
+Compared with **[HashMap](js-apis-hashmap.md)**, which can also store KV pairs, **LightWeightMap** occupies less memory.
+
+**Recommended use case**: Use LightWeightMap when you need to store and access **KV pairs**.
## Modules to Import
```ts
-import LightWeightMap from '@ohos.util.LightWeightMap'
+import LightWeightMap from '@ohos.util.LightWeightMap';
```
-## System Capabilities
-SystemCapability.Utils.Lang
## LightWeightMap
-
### Attributes
+**System capability**: SystemCapability.Utils.Lang
+
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| length | number | Yes| No| Number of entries in a lightweight map (called container later).|
+| length | number | Yes| No| Number of elements in a lightweight map (called container later).|
### constructor
@@ -30,6 +37,8 @@ constructor()
A constructor used to create a **LightWeightMap** instance.
+**System capability**: SystemCapability.Utils.Lang
+
**Example**
```ts
@@ -41,7 +50,9 @@ let lightWeightMap = new LightWeightMap();
isEmpty(): boolean
-Checks whether this container is empty (contains no entry).
+Checks whether this container is empty (contains no element).
+
+**System capability**: SystemCapability.Utils.Lang
**Return value**
@@ -61,7 +72,9 @@ let result = lightWeightMap.isEmpty();
hasAll(map: LightWeightMap): boolean
-Checks whether this container contains all entries of the specified **LightWeightMap** instance.
+Checks whether this container contains all elements of the specified **LightWeightMap** instance.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
@@ -73,7 +86,7 @@ Checks whether this container contains all entries of the specified **LightWeigh
| Type| Description|
| -------- | -------- |
-| boolean | Returns **true** if all the entries in the specified **LightWeightMap** instance are contained; returns **false** otherwise.|
+| boolean | Returns **true** if all the elements in the specified **LightWeightMap** instance are contained; returns **false** otherwise.|
**Example**
@@ -93,11 +106,13 @@ hasKey(key: K): boolean;
Checks whether this container contains the specified key.
+**System capability**: SystemCapability.Utils.Lang
+
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| key | K | Yes| Key to check.|
+| key | K | Yes| Target key.|
**Return value**
@@ -122,11 +137,13 @@ hasValue(value: V): boolean
Checks whether this container contains the specified value.
+**System capability**: SystemCapability.Utils.Lang
+
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| value | V | Yes| Value to check.|
+| value | V | Yes| Target value.|
**Return value**
@@ -150,11 +167,13 @@ increaseCapacityTo(minimumCapacity: number): void
Increases the capacity of this container.
+**System capability**: SystemCapability.Utils.Lang
+
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| minimumCapacity | number | Yes| Minimum number of entries to accommodate in this container.|
+| minimumCapacity | number | Yes| Minimum number of elements to accommodate in this container.|
**Example**
@@ -170,11 +189,13 @@ get(key: K): V
Obtains the value of the specified key in this container.
+**System capability**: SystemCapability.Utils.Lang
+
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| key | K | Yes| Key to query.|
+| key | K | Yes| Target key.|
**Return value**
@@ -196,19 +217,21 @@ let result = lightWeightMap.get("sdfs");
getIndexOfKey(key: K): number
-Obtains the index of the first occurrence of an entry with the specified key in this container.
+Obtains the index of the first occurrence of an element with the specified key in this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| key | K | Yes| Key of the entry.|
+| key | K | Yes| Key of the element.|
**Return value**
| Type| Description|
| -------- | -------- |
-| number | Returns the position index if obtained; returns **-1** if the specified entry is not found.|
+| number | Returns the position index if obtained; returns **-1** otherwise.|
**Example**
@@ -224,19 +247,21 @@ let result = lightWeightMap.getIndexOfKey("sdfs");
getIndexOfValue(value: V): number
-Obtains the index of the first occurrence of an entry with the specified value in this container.
+Obtains the index of the first occurrence of an element with the specified value in this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| value | V | Yes| Value of the entry.|
+| value | V | Yes| Key of the element.|
**Return value**
| Type| Description|
| -------- | -------- |
-| number | Returns the position index if obtained; returns **-1** if the specified entry is not found.|
+| number | Returns the position index if obtained; returns **-1** otherwise.|
**Example**
@@ -252,13 +277,15 @@ let result = lightWeightMap.getIndexOfValue(123);
getKeyAt(index: number): K
-Obtains the key of an entry at the specified position in this container.
+Obtains the key of an element at the specified position in this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| index | number | Yes| Position index of the entry.|
+| index | number | Yes| Position index of the element.|
**Return value**
@@ -280,13 +307,15 @@ let result = lightWeightMap.getKeyAt(1);
setAll(map: LightWeightMap): void
-Adds all entries in a **LightWeightMap** instance to this container.
+Adds all elements in a **LightWeightMap** instance to this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| map | LightWeightMap | Yes| **LightWeightMap** instance whose entries are to be added to the current container.|
+| map | LightWeightMap | Yes| **LightWeightMap** instance whose elements are to be added to the current container.|
**Example**
@@ -302,20 +331,22 @@ lightWeightMap.setAll(map);
### set
set(key: K, value: V): Object
-Adds an entry to this container.
+Adds an element to this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| key | K | Yes| Key of the entry to add.|
-| value | V | Yes| Value of the entry to add.|
+| key | K | Yes| Key of the target element.|
+| value | V | Yes| Value of the target element.|
**Return value**
| Type| Description|
| -------- | -------- |
-| Object | Container that contains the new entry.|
+| Object | Container that contains the new element.|
**Example**
@@ -329,19 +360,21 @@ let result = lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
remove(key: K): V
-Removes an entry with the specified key from this container.
+Removes an element with the specified key from this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| key | K | Yes| Key of the entry to remove.|
+| key | K | Yes| Target key.|
**Return value**
| Type| Description|
| -------- | -------- |
-| V | Value of the entry removed.|
+| V | Value of the element removed.|
**Example**
@@ -357,19 +390,21 @@ lightWeightMap.remove("sdfs");
removeAt(index: number): boolean
-Removes an entry at the specified position from this container.
+Removes an element at the specified position from this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| index | number | Yes| Position index of the entry.|
+| index | number | Yes| Position index of the element.|
**Return value**
| Type| Description|
| -------- | -------- |
-| boolean | Returns **true** if the entry is removed successfully; returns **false** otherwise.|
+| boolean | Returns **true** if the element is removed successfully; returns **false** otherwise.|
**Example**
@@ -385,14 +420,16 @@ let result = lightWeightMap.removeAt(1);
setValueAt(index: number, newValue: V): boolean
-Sets a value for an entry at the specified position in this container.
+Sets a value for an element at the specified position in this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| index | number | Yes| Position index of the entry.|
-| newValue | V | Yes| Value of the entry to set.|
+| index | number | Yes| Position index of the target element.|
+| newValue | V | Yes| Value of the target element to set.|
**Return value**
@@ -414,13 +451,15 @@ lightWeightMap.setValueAt(1, 3546);
getValueAt(index: number): V
-Obtains the value of an entry at the specified position in this container.
+Obtains the value of an element at the specified position in this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| index | number | Yes| Position index of the entry.|
+| index | number | Yes| Position index of the element.|
**Return value**
@@ -444,6 +483,8 @@ clear(): void
Clears this container and sets its length to **0**.
+**System capability**: SystemCapability.Utils.Lang
+
**Example**
```ts
@@ -460,6 +501,8 @@ keys(): IterableIterator<K>
Obtains an iterator that contains all the keys in this container.
+**System capability**: SystemCapability.Utils.Lang
+
**Return value**
| Type| Description|
@@ -475,7 +518,7 @@ lightWeightMap.set("sdfs", 356);
let iter = lightWeightMap.keys();
let temp = iter.next().value;
while(temp != undefined) {
- console.log(temp);
+ console.log("value:" + temp);
temp = iter.next().value;
}
```
@@ -487,6 +530,8 @@ values(): IterableIterator<V>
Obtains an iterator that contains all the values in this container.
+**System capability**: SystemCapability.Utils.Lang
+
**Return value**
| Type| Description|
@@ -502,7 +547,7 @@ lightWeightMap.set("sdfs", 356);
let iter = lightWeightMap.values();
let temp = iter.next().value;
while(temp != undefined) {
- console.log(temp);
+ console.log("value:" + temp);
temp = iter.next().value;
}
```
@@ -512,20 +557,22 @@ while(temp != undefined) {
forEach(callbackfn: (value?: V, key?: K, map?: LightWeightMap) => void, thisArg?: Object): void
-Uses a callback to traverse the entries in this container and obtain their position indexes.
+Uses a callback to traverse the elements in this container and obtain their position indexes.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| callbackfn | function | Yes| Callback invoked to traverse the entries in the container.|
+| callbackfn | function | Yes| Callback invoked to traverse the elements in the container.|
| thisArg | Object | No| Value to use when the callback is invoked.|
callbackfn
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| value | V | No| Value of the entry that is currently traversed.|
-| key | K | No| Key of the entry that is currently traversed.|
+| value | V | No| Value of the element that is currently traversed.|
+| key | K | No| Key of the element that is currently traversed.|
| map | LightWeightMap | No| Instance that invokes the **forEach** method.|
**Example**
@@ -535,7 +582,7 @@ let lightWeightMap = new LightWeightMap();
lightWeightMap.set("sdfs", 123);
lightWeightMap.set("dfsghsf", 357);
lightWeightMap.forEach((value, key) => {
- console.log(value, key);
+ console.log("value:" + value, key);
});
```
@@ -544,7 +591,9 @@ lightWeightMap.forEach((value, key) => {
entries(): IterableIterator<[K, V]>
-Obtains an iterator that contains all the entries in this container.
+Obtains an iterator that contains all the elements in this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Return value**
@@ -561,8 +610,8 @@ lightWeightMap.set("sdfs", 356);
let iter = lightWeightMap.entries();
let temp = iter.next().value;
while(temp != undefined) {
- console.log(temp[0]);
- console.log(temp[1]);
+ console.log("key:" + temp[0]);
+ console.log("value:" + temp[1]);
temp = iter.next().value;
}
```
@@ -571,13 +620,15 @@ while(temp != undefined) {
toString(): String
-Concatenates the entries in this container into a string and returns the string.
+Concatenates the elements in this container into a string and returns the string.
+
+**System capability**: SystemCapability.Utils.Lang
**Return value**
- | Type| Description|
- | -------- | -------- |
- | String | Returns a string.|
+| Type| Description|
+| -------- | -------- |
+| String | String obtained.|
**Example**
@@ -594,6 +645,8 @@ Concatenates the entries in this container into a string and returns the string.
Obtains an iterator, each item of which is a JavaScript object.
+**System capability**: SystemCapability.Utils.Lang
+
**Return value**
| Type| Description|
@@ -609,16 +662,16 @@ lightWeightMap.set("sdfs", 356);
// Method 1:
for (let item of lightWeightMap) {
- console.log("key: " + item[0]);
- console.log("value: " + item[1]);
+ console.log("key:" + item[0]);
+ console.log("value:" + item[1]);
}
// Method 2:
let iter = lightWeightMap[Symbol.iterator]();
let temp = iter.next().value;
while(temp != undefined) {
- console.log(temp[0]);
- console.log(temp[1]);
+ console.log("key:" + temp[0]);
+ console.log("value:" + temp[1]);
temp = iter.next().value;
}
```
diff --git a/en/application-dev/reference/apis/js-apis-lightweightset.md b/en/application-dev/reference/apis/js-apis-lightweightset.md
index a024852f8c94b4df3d6a81727cffae004cbbd67c..4a900d9f5476216ae7e98a0df9d762119753ad36 100644
--- a/en/application-dev/reference/apis/js-apis-lightweightset.md
+++ b/en/application-dev/reference/apis/js-apis-lightweightset.md
@@ -1,27 +1,36 @@
# Nonlinear Container LightWeightSet
->  **NOTE**
+> **NOTE**
+>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+**LightWeightSet** stores a set of values, each of which must be unique.
+
+**LightWeightSet** is based on generics and uses a lightweight structure. Its default initial capacity is 8, and it has the capacity doubled in each expansion.
+
+The values in such a set are searched using hash values, which are stored in an array.
+
+Compared with **[HashSet](js-apis-hashset.md)**, which can also store values, **LightWeightSet** occupies less memory.
+
+**Recommended use case**: Use **LightWeightSet** when you need a set that has only unique elements or need to deduplicate a set.
## Modules to Import
```ts
-import LightWeightSet from '@ohos.util.LightWeightSet'
+import LightWeightSet from '@ohos.util.LightWeightSet';
```
-## System Capabilities
-SystemCapability.Utils.Lang
## LightWeightSet
-
### Attributes
+**System capability**: SystemCapability.Utils.Lang
+
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| length | number | Yes| No| Number of entries in a lightweight set (called container later).|
+| length | number | Yes| No| Number of elements in a lightweight set (called container later).|
### constructor
@@ -30,6 +39,8 @@ constructor()
A constructor used to create a **LightWeightSet** instance.
+**System capability**: SystemCapability.Utils.Lang
+
**Example**
```ts
@@ -41,7 +52,9 @@ let lightWeightSet = new LightWeightSet();
isEmpty(): boolean
-Checks whether this container is empty.
+Checks whether this container is empty (contains no element).
+
+**System capability**: SystemCapability.Utils.Lang
**Return value**
@@ -60,19 +73,21 @@ let result = lightWeightSet.isEmpty();
add(obj: T): boolean
-Adds an entry to this container.
+Adds an element to this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| obj | T | Yes| Entry to add.|
+| obj | T | Yes| Target element.|
**Return value**
| Type| Description|
| -------- | -------- |
-| boolean | Returns **true** if the entry is added successfully; returns **false** otherwise.|
+| boolean | Returns **true** if the element is added successfully; returns **false** otherwise.|
**Example**
@@ -86,13 +101,15 @@ let result = lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
addAll(set: LightWeightSet<T>): boolean
-Adds all entries in a **LightWeightSet** instance to this container.
+Adds all elements in a **LightWeightSet** instance to this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| set | LightWeightSet<T> | Yes| **LightWeightSet** instance whose entries are to be added to the current container.|
+| set | LightWeightSet<T> | Yes| **LightWeightSet** instance whose elements are to be added to the current container.|
**Example**
@@ -110,7 +127,9 @@ let result = lightWeightSet.addAll(set);
hasAll(set: LightWeightSet<T>): boolean
-Checks whether this container contains all entries of the specified **LightWeightSet** instance.
+Checks whether this container contains all elements of the specified **LightWeightSet** instance.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
@@ -122,7 +141,7 @@ Checks whether this container contains all entries of the specified **LightWeigh
| Type| Description|
| -------- | -------- |
-| boolean | Returns **true** if all the entries in the specified **LightWeightSet** instance are contained; returns **false** otherwise.|
+| boolean | Returns **true** if all the elements in the specified **LightWeightSet** instance are contained; returns **false** otherwise.|
**Example**
@@ -142,11 +161,13 @@ has(key: T): boolean
Checks whether this container has the specified key.
+**System capability**: SystemCapability.Utils.Lang
+
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| key| T | Yes| Key to query.|
+| key| T | Yes| Target key.|
**Return value**
@@ -170,6 +191,8 @@ equal(obj: Object): boolean
Checks whether this container contains objects of the same type as the specified **obj**.
+**System capability**: SystemCapability.Utils.Lang
+
**Parameters**
| Name| Type| Mandatory| Description|
@@ -199,11 +222,13 @@ increaseCapacityTo(minimumCapacity: number): void
Increases the capacity of this container.
+**System capability**: SystemCapability.Utils.Lang
+
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| minimumCapacity | number | Yes| Minimum number of entries to accommodate in the container.|
+| minimumCapacity | number | Yes| Minimum number of elements to accommodate in the container.|
**Example**
@@ -217,19 +242,21 @@ lightWeightSet.increaseCapacityTo(10);
getIndexOf(key: T): number
-Obtains the position index of the entry with the specified key in this container.
+Obtains the position index of the element with the specified key in this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| key| T | Yes| Key of the entry to query.|
+| key| T | Yes| Key of the target element.|
**Return value**
| Type| Description|
| -------- | -------- |
-| number | Position index of the entry.|
+| number | Position index of the element.|
**Example**
@@ -245,19 +272,21 @@ let result = lightWeightSet.getIndexOf("sdfs");
remove(key: T): T
-Removes an entry of the specified key from this container.
+Removes an element of the specified key from this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| key| T | Yes| Key of the entry to remove.|
+| key| T | Yes| Key of the target element.|
**Return value**
| Type| Description|
| -------- | -------- |
-| T | Value of the entry removed.|
+| T | Value of the element removed.|
**Example**
@@ -273,19 +302,21 @@ let result = lightWeightSet.remove("sdfs");
removeAt(index: number): boolean
-Removes the entry at the specified position from this container.
+Removes the element at the specified position from this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| index | number | Yes| Position index of the entry.|
+| index | number | Yes| Position index of the element.|
**Return value**
| Type| Description|
| -------- | -------- |
-| boolean | Returns **true** if the entry is removed successfully; returns **false** otherwise.|
+| boolean | Returns **true** if the element is removed successfully; returns **false** otherwise.|
**Example**
@@ -301,13 +332,15 @@ let result = lightWeightSet.removeAt(1);
getValueAt(index: number): T
-Obtains the value of the entry at the specified position in this container.
+Obtains the value of the element at the specified position in this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| index | number | Yes| Position index of the entry.|
+| index | number | Yes| Position index of the element.|
**Return value**
@@ -331,6 +364,8 @@ clear(): void
Clears this container and sets its length to **0**.
+**System capability**: SystemCapability.Utils.Lang
+
**Example**
```ts
@@ -345,7 +380,9 @@ lightWeightSet.clear();
toString(): String
-Obtains a string that contains all entries in this container.
+Obtains a string that contains all elements in this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Return value**
@@ -369,6 +406,8 @@ toArray(): Array<T>
Obtains an array that contains all objects in this container.
+**System capability**: SystemCapability.Utils.Lang
+
**Return value**
| Type| Description|
@@ -391,6 +430,8 @@ values(): IterableIterator<T>
Obtains an iterator that contains all the values in this container.
+**System capability**: SystemCapability.Utils.Lang
+
**Return value**
| Type| Description|
@@ -416,20 +457,22 @@ while(index < lightWeightSet.length) {
forEach(callbackfn: (value?: T, key?: T, set?: LightWeightSet<T>) => void, thisArg?: Object): void
-Uses a callback to traverse the entries in this container and obtain their position indexes.
+Uses a callback to traverse the elements in this container and obtain their position indexes.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| callbackfn | function | Yes| Callback invoked to traverse the entries in the container.|
+| callbackfn | function | Yes| Callback invoked to traverse the elements in the container.|
| thisArg | Object | No| Value to use when the callback is invoked.|
callbackfn
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| value | T | No| Value of the entry that is currently traversed.|
-| key| T | No| Key of the entry that is currently traversed (same as **value**).|
+| value | T | No| Value of the element that is currently traversed.|
+| key| T | No| Key of the element that is currently traversed (same as **value**).|
| set | LightWeightSet<T> | No| Instance that invokes the **forEach** method.|
**Example**
@@ -439,7 +482,7 @@ let lightWeightSet = new LightWeightSet();
lightWeightSet.add("sdfs");
lightWeightSet.add("dfsghsf");
lightWeightSet.forEach((value, key) => {
- console.log(value, key);
+ console.log("value:" + value, key);
});
```
@@ -448,7 +491,9 @@ lightWeightSet.forEach((value, key) => {
entries(): IterableIterator<[T, T]>
-Obtains an iterator that contains all the entries in this container.
+Obtains an iterator that contains all the elements in this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Return value**
@@ -477,6 +522,8 @@ while(index < lightWeightSet.length) {
Obtains an iterator, each item of which is a JavaScript object.
+**System capability**: SystemCapability.Utils.Lang
+
**Return value**
| Type| Description|
@@ -492,14 +539,14 @@ lightWeightSet.add("sdfs");
// Method 1:
for (let item of lightWeightSet) {
- console.log("value: " + item);
+ console.log("value:" + item);
}
// Method 2:
let iter = lightWeightSet[Symbol.iterator]();
let temp = iter.next().value;
while(temp != undefined) {
- console.log(temp);
+ console.log("value:" + temp);
temp = iter.next().value;
}
```
diff --git a/en/application-dev/reference/apis/js-apis-linkedlist.md b/en/application-dev/reference/apis/js-apis-linkedlist.md
index 2827999afc78fe6e9c026ce976a9821e1ce35350..73737f14b6078445e1f67762ca43a86a22804dbe 100644
--- a/en/application-dev/reference/apis/js-apis-linkedlist.md
+++ b/en/application-dev/reference/apis/js-apis-linkedlist.md
@@ -1,28 +1,35 @@
# Linear Container LinkedList
->  **NOTE**
+> **NOTE**
+>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+**LinkedList** is implemented based on the doubly linked list. Each node of the doubly linked list has references pointing to the previous element and the next element. When querying an element, the system traverses the list from the beginning or end. **LinkedList** offers efficient insertion and removal operations but supports low query efficiency. **LinkedList** allows null elements.
+
+Unlike **[List](js-apis-list.md)**, which is a singly linked list, **LinkedList** is a doubly linked list that supports insertion and removal at both ends.
+
+**LinkedList** is less efficient in data access than **[ArrayList](js-apis-arraylist.md)**.
+
+**Recommended use case**: Use **LinkedList** for frequent insertion and removal operations.
## Modules to Import
```ts
-import LinkedList from '@ohos.util.LinkedList'
+import LinkedList from '@ohos.util.LinkedList';
```
-## System Capability
-SystemCapability.Utils.Lang
## LinkedList
-
### Attributes
+**System capability**: SystemCapability.Utils.Lang
+
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| length | number | Yes| No| Number of entries in a linked list (called container later).|
+| length | number | Yes| No| Number of elements in a linked list (called container later).|
### constructor
@@ -31,6 +38,8 @@ constructor()
A constructor used to create a **LinkedList** instance.
+**System capability**: SystemCapability.Utils.Lang
+
**Example**
@@ -43,19 +52,21 @@ let linkedList = new LinkedList();
add(element: T): boolean
-Adds an entry at the end of this container.
+Adds an element at the end of this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| element | T | Yes| Entry to add.|
+| element | T | Yes| Target element.|
**Return value**
| Type| Description|
| -------- | -------- |
-| boolean | Returns **true** if the entry is added successfully; returns **false** otherwise.|
+| boolean | Returns **true** if the element is added successfully; returns **false** otherwise.|
**Example**
@@ -73,13 +84,15 @@ let result3 = linkedList.add(false);
addFirst(element: T): void
-Adds an entry at the top of this container.
+Adds an element at the top of this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| element | T | Yes| Entry to add.|
+| element | T | Yes| Target element.|
**Example**
@@ -97,14 +110,16 @@ linkedList.addFirst(false);
insert(index: number, element: T): void
-Inserts an entry at the specified position in this container.
+Inserts an element at the specified position in this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| element | T | Yes| Entry to insert.|
-| index | number | Yes| Index of the position where the entry is to be inserted.|
+| element | T | Yes| Target element.|
+| index | number | Yes| Index of the position where the element is to be inserted.|
**Example**
@@ -119,19 +134,21 @@ linkedList.insert(2, true);
has(element: T): boolean
-Checks whether this container has the specified entry.
+Checks whether this container has the specified element.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| element | T | Yes| Entry to check.|
+| element | T | Yes| Target element.|
**Return value**
| Type| Description|
| -------- | -------- |
-| boolean | Returns **true** if the specified entry is contained; returns **false** otherwise.|
+| boolean | Returns **true** if the specified element is contained; returns **false** otherwise.|
**Example**
@@ -146,19 +163,21 @@ let result = linkedList.has("Ahfbrgrbgnutfodgorrogorg");
get(index: number): T
-Obtains an entry at the specified position in this container.
+Obtains an element at the specified position in this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| index | number | Yes| Position index of the entry to query.|
+| index | number | Yes| Position index of the target element.|
**Return value**
| Type| Description|
| -------- | -------- |
-| T | Entry obtained.|
+| T | Element obtained.|
**Example**
@@ -178,19 +197,21 @@ let result = linkedList.get(2);
getLastIndexOf(element: T): number
-Obtains the index of the last occurrence of the specified entry in this container.
+Obtains the index of the last occurrence of the specified element in this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| element | T | Yes| Entry to check.|
+| element | T | Yes| Target element.|
**Return value**
| Type| Description|
| -------- | -------- |
-| number | Returns the position index if obtained; returns **-1** if the specified entry is not found.|
+| number | Returns the position index if obtained; returns **-1** otherwise.|
**Example**
@@ -210,19 +231,21 @@ let result = linkedList.getLastIndexOf(2);
getIndexOf(element: T): number
-Obtains the index of the first occurrence of the specified entry in this container.
+Obtains the index of the first occurrence of the specified element in this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| element | T | Yes| Entry to check.|
+| element | T | Yes| Target element.|
**Return value**
| Type| Description|
| -------- | -------- |
-| number | Returns the position index if obtained; returns **-1** if the specified entry is not found.|
+| number | Returns the position index if obtained; returns **-1** otherwise.|
**Example**
@@ -242,19 +265,21 @@ let result = linkedList.getIndexOf(2);
removeByIndex(index: number): T
-Removes an entry at the specified position from this container.
+Removes an element at the specified position from this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| index | number | Yes| Position index of the entry to remove.|
+| index | number | Yes| Position index of the target element.|
**Return value**
| Type| Description|
| -------- | -------- |
-| T | Entry removed.|
+| T | Element removed.|
**Example**
@@ -272,13 +297,15 @@ let result = linkedList.removeByIndex(2);
removeFirst(): T
-Removes the first entry from this container.
+Removes the first element from this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Return value**
| Type| Description|
| -------- | -------- |
-| T | Entry removed.|
+| T | Element removed.|
**Example**
@@ -296,13 +323,15 @@ let result = linkedList.removeFirst();
removeLast(): T
-Removes the last entry from this container.
+Removes the last element from this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Return value**
| Type| Description|
| -------- | -------- |
-| T | Entry removed.|
+| T | Element removed.|
**Example**
@@ -320,19 +349,21 @@ let result = linkedList.removeLast();
remove(element: T): boolean
-Removes the first occurrence of the specified entry from this container.
+Removes the first occurrence of the specified element from this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| element | T | Yes| Entry to check.|
+| element | T | Yes| Target element.|
**Return value**
| Type| Description|
| -------- | -------- |
-| boolean | Returns **true** if the entry is removed successfully; returns **false** otherwise.|
+| boolean | Returns **true** if the element is removed successfully; returns **false** otherwise.|
**Example**
@@ -349,19 +380,21 @@ let result = linkedList.remove(2);
removeFirstFound(element: T): boolean
-Removes the first occurrence of the specified entry from this container.
+Removes the first occurrence of the specified element from this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| element | T | Yes| Entry to check.|
+| element | T | Yes| Target element.|
**Return value**
| Type| Description|
| -------- | -------- |
-| boolean | Returns **true** if the entry is removed successfully; returns **false** otherwise.|
+| boolean | Returns **true** if the element is removed successfully; returns **false** otherwise.|
**Example**
@@ -378,19 +411,21 @@ let result = linkedList.removeFirstFound(4);
removeLastFound(element: T): boolean
-Removes the last occurrence of the specified entry from this container.
+Removes the last occurrence of the specified element from this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| element | T | Yes| Entry to check.|
+| element | T | Yes| Target element.|
**Return value**
| Type| Description|
| -------- | -------- |
-| boolean | Returns **true** if the entry is removed successfully; returns **false** otherwise.|
+| boolean | Returns **true** if the element is removed successfully; returns **false** otherwise.|
**Example**
@@ -409,6 +444,8 @@ clone(): LinkedList<T>
Clones this container and returns a copy. The modification to the copy does not affect the original instance.
+**System capability**: SystemCapability.Utils.Lang
+
**Return value**
| Type| Description|
@@ -431,21 +468,23 @@ let result = linkedList.clone();
forEach(callbackfn: (value: T, index?: number, LinkedList?: LinkedList<T>) => void,
thisArg?: Object): void
-Uses a callback to traverse the entries in this container and obtain their position indexes.
+Uses a callback to traverse the elements in this container and obtain their position indexes.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| callbackfn | function | Yes| Callback invoked to traverse the entries in the container.|
+| callbackfn | function | Yes| Callback invoked to traverse the elements in the container.|
| thisArg | Object | No| Value to use when the callback is invoked.|
callbackfn
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| value | T | Yes| Value of the entry that is currently traversed.|
-| index | number | No| Position index of the entry that is currently traversed.|
+| value | T | Yes| Value of the element that is currently traversed.|
+| index | number | No| Position index of the element that is currently traversed.|
| LinkedList | LinkedList<T> | No| Instance that invokes the **forEach** API.|
**Example**
@@ -457,7 +496,7 @@ linkedList.add(4);
linkedList.add(5);
linkedList.add(4);
linkedList.forEach((value, index) => {
- console.log(value, index);
+ console.log("value:" + value, index);
});
```
@@ -467,6 +506,8 @@ clear(): void
Clears this container and sets its length to **0**.
+**System capability**: SystemCapability.Utils.Lang
+
**Example**
```ts
@@ -482,20 +523,22 @@ linkedList.clear();
set(index: number, element: T): T
-Replaces an entry at the specified position in this container with a given entry.
+Replaces an element at the specified position in this container with a given element.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| index | number | Yes| Position index of the entry to replace.|
-| element | T | Yes| Entry to be used for replacement.|
+| index | number | Yes| Position index of the target element.|
+| element | T | Yes| Element to be used for replacement.|
**Return value**
| Type| Description|
| -------- | -------- |
-| T | New entry.|
+| T | New element.|
**Example**
@@ -514,6 +557,8 @@ convertToArray(): Array<T>
Converts this container into an array.
+**System capability**: SystemCapability.Utils.Lang
+
**Return value**
| Type| Description|
@@ -534,13 +579,15 @@ let result = linkedList.convertToArray();
getFirst(): T
-Obtains the first entry in this container.
+Obtains the first element in this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Return value**
| Type| Description|
| -------- | -------- |
-| T | Returns the entry if obtained; returns **undefined** otherwise.|
+| T | Returns the element if obtained; returns **undefined** otherwise.|
**Example**
@@ -557,13 +604,15 @@ let result = linkedList.getFirst();
getLast(): T
-Obtains the last entry in this container.
+Obtains the last element in this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Return value**
| Type| Description|
| -------- | -------- |
-| T | Returns the entry if obtained; returns **undefined** otherwise.|
+| T | Returns the element if obtained; returns **undefined** otherwise.|
**Example**
@@ -580,9 +629,10 @@ linkedList.getLast();
[Symbol.iterator]\(): IterableIterator<T>
-
Obtains an iterator, each item of which is a JavaScript object.
+**System capability**: SystemCapability.Utils.Lang
+
**Return value**
| Type| Description|
@@ -600,14 +650,14 @@ linkedList.add(4);
// Method 1:
for (let item of linkedList) {
- console.log(item);
+ console.log("value:" + item);
}
// Method 2:
let iter = linkedList[Symbol.iterator]();
let temp = iter.next().value;
while(temp != undefined) {
- console.log(temp);
+ console.log("value:" + temp);
temp = iter.next().value;
}
```
diff --git a/en/application-dev/reference/apis/js-apis-list.md b/en/application-dev/reference/apis/js-apis-list.md
index 661d0726ebe52f5e5fc97d68cca866938bc2660a..0b839a5a0baae3fa58e4592485c3b9e959183530 100644
--- a/en/application-dev/reference/apis/js-apis-list.md
+++ b/en/application-dev/reference/apis/js-apis-list.md
@@ -1,28 +1,31 @@
# Linear Container List
->  **NOTE**
+> **NOTE**
+>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+**List** is implemented based on the singly linked list. Each node has a reference pointing to the next element. When querying an element, the system traverses the list from the beginning. **List** offers efficient insertion and removal operations but supports low query efficiency. **List** allows null elements.
+
+Unlike [LinkedList](js-apis-linkedlist.md), which is a doubly linked list, **List** is a singly linked list that does not support insertion or removal at both ends.
+
+**Recommended use case**: Use **List** for frequent insertion and removal operations.
## Modules to Import
```ts
-import List from '@ohos.util.List'
+import List from '@ohos.util.List';
```
-## System Capabilities
-
-SystemCapability.Utils.Lang
-
## List
-
### Attributes
+**System capability**: SystemCapability.Utils.Lang
+
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| length | number | Yes| No| Number of entries in a list (called container later).|
+| length | number | Yes| No| Number of elements in a list (called container later).|
### constructor
@@ -31,6 +34,8 @@ constructor()
A constructor used to create a **List** instance.
+**System capability**: SystemCapability.Utils.Lang
+
**Example**
@@ -43,19 +48,21 @@ let list = new List();
add(element: T): boolean
-Adds an entry at the end of this container.
+Adds an element at the end of this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Value Type | Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| element | T | Yes| Element to add.|
+| element | T | Yes| Target element.|
**Return value**
| Value Type | Description|
| -------- | -------- |
-| boolean | Returns **true** if the entry is added successfully; returns **false** otherwise.|
+| boolean | Returns **true** if the element is added successfully; returns **false** otherwise.|
**Example**
@@ -73,14 +80,16 @@ let result3 = list.add(false);
insert(element: T, index: number): void
-Inserts an entry at the specified position in this container.
+Inserts an element at the specified position in this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Value Type | Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| element | T | Yes| Element to insert.|
-| index | number | Yes| Index of the position where the entry is to be inserted.|
+| element | T | Yes| Target element.|
+| index | number | Yes| Index of the position where the element is to be inserted.|
**Example**
@@ -95,19 +104,21 @@ list.insert(true, 2);
has(element: T): boolean
-Checks whether this container has the specified entry.
+Checks whether this container has the specified element.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Value Type | Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| element | T | Yes| Entry to check.|
+| element | T | Yes| Target element.|
**Return value**
| Value Type | Description|
| -------- | -------- |
-| boolean | Returns **true** if the specified entry is contained; returns **false** otherwise.|
+| boolean | Returns **true** if the specified element is contained; returns **false** otherwise.|
**Example**
@@ -122,19 +133,21 @@ let result1 = list.has("Ahfbrgrbgnutfodgorrogorg");
get(index: number): T
-Obtains the entry at the specified position in this container.
+Obtains the element at the specified position in this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Value Type | Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| index | number | Yes| Position index of the entry to obtain.|
+| index | number | Yes| Position index of the target element.|
**Return value**
| Value Type | Description|
| -------- | -------- |
-| T | Entry obtained.|
+| T | Element obtained.|
**Example**
@@ -154,19 +167,21 @@ let result = list.get(2);
getLastIndexOf(element: T): number
-Obtains the index of the last occurrence of the specified entry in this container.
+Obtains the index of the last occurrence of the specified element in this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Value Type | Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| element | T | Yes| Entry to obtain.|
+| element | T | Yes| Target element.|
**Return value**
| Value Type | Description|
| -------- | -------- |
-| number | Returns the position index if obtained; returns **-1** if the specified entry is not found.|
+| number | Returns the position index if obtained; returns **-1** otherwise.|
**Example**
@@ -186,19 +201,21 @@ let result = list.getLastIndexOf(2);
getIndexOf(element: T): number
-Obtains the index of the first occurrence of the specified entry in this container.
+Obtains the index of the first occurrence of the specified element in this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Value Type | Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| element | T | Yes| Entry to obtain.|
+| element | T | Yes| Target element.|
**Return value**
| Value Type | Description|
| -------- | -------- |
-| number | Returns the position index if obtained; returns **-1** if the specified entry is not found.|
+| number | Returns the position index if obtained; returns **-1** otherwise.|
**Example**
@@ -221,6 +238,8 @@ equal(obj: Object): boolean
Compares whether a specified object is equal to this container.
+**System capability**: SystemCapability.Utils.Lang
+
**Parameters**
| Name| Value Type | Mandatory| Description|
@@ -254,19 +273,21 @@ let result = list.equal(obj2);
removeByIndex(index: number): T
-Removes an entry at the specified position from this container.
+Removes an element at the specified position from this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Value Type | Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| index | number | Yes| Position index of the entry to remove.|
+| index | number | Yes| Position index of the target element.|
**Return value**
| Value Type | Description|
| -------- | -------- |
-| T | Entry removed.|
+| T | Element removed.|
**Example**
@@ -284,19 +305,21 @@ let result = list.removeByIndex(2);
remove(element: T): boolean
-Removes the first occurrence of the specified entry from this container.
+Removes the first occurrence of the specified element from this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Value Type | Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| element | T | Yes| Entry to remove.|
+| element | T | Yes| Target element.|
**Return value**
| Value Type | Description|
| -------- | -------- |
-| boolean | Returns **true** if the entry is removed successfully; returns **false** otherwise.|
+| boolean | Returns **true** if the element is removed successfully; returns **false** otherwise.|
**Example**
@@ -314,7 +337,9 @@ let result = list.remove(2);
replaceAllElements(callbackfn: (value: T, index?: number, list?: List<T>) => T,
thisArg?: Object): void
-Replaces all entries in this container with new entries, and returns the new ones.
+Replaces all elements in this container with new elements, and returns the new ones.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
@@ -327,8 +352,8 @@ callbackfn
| Name| Value Type | Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| value | T | Yes| Value of the entry that is currently traversed.|
-| index | number | No| Position index of the entry that is currently traversed.|
+| value | T | Yes| Value of the element that is currently traversed.|
+| index | number | No| Position index of the element that is currently traversed.|
| list | List<T> | No| Instance that invokes the **replaceAllElements** method.|
**Example**
@@ -339,10 +364,10 @@ list.add(2);
list.add(4);
list.add(5);
list.add(4);
-list.replaceAllElements((value, index) => {
+list.replaceAllElements((value: number, index: number) => {
return value = 2 * value;
});
-list.replaceAllElements((value, index) => {
+list.replaceAllElements((value: number, index: number) => {
return value = value - 2;
});
```
@@ -352,21 +377,23 @@ list.replaceAllElements((value, index) => {
forEach(callbackfn: (value: T, index?: number, List?: List<T>) => void,
thisArg?: Object): void
-Uses a callback to traverse the entries in this container and obtain their position indexes.
+Uses a callback to traverse the elements in this container and obtain their position indexes.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Value Type | Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| callbackfn | function | Yes| Callback invoked to traverse the entries in the container.|
+| callbackfn | function | Yes| Callback invoked to traverse the elements in the container.|
| thisArg | Object | No| Value to use when the callback is invoked.|
callbackfn
| Name| Value Type | Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| value | T | Yes| Value of the entry that is currently traversed.|
-| index | number | No| Position index of the entry that is currently traversed.|
+| value | T | Yes| Value of the element that is currently traversed.|
+| index | number | No| Position index of the element that is currently traversed.|
| List | List<T> | No| Instance that invokes the **forEach** method.|
**Example**
@@ -378,7 +405,7 @@ list.add(4);
list.add(5);
list.add(4);
list.forEach((value, index) => {
- console.log(value, index);
+ console.log("value: " + value, index);
});
```
@@ -387,20 +414,22 @@ list.forEach((value, index) => {
sort(comparator: (firstValue: T, secondValue: T) => number): void
-Sorts entries in this container.
+Sorts elements in this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
-| Name | Type | Mandatory | Description |
+| Name| Value Type | Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| comparator | function | Yes | Callback invoked for sorting. |
+| comparator | function | Yes| Callback invoked for sorting.|
comparator
-| Name | Type | Mandatory | Description |
+| Name| Value Type | Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| firstValue | T | Yes | Previous entry. |
-| secondValue | T | Yes | Next entry. |
+| firstValue | T | Yes| Previous element.|
+| secondValue | T | Yes| Next element.|
**Example**
@@ -410,15 +439,17 @@ list.add(2);
list.add(4);
list.add(5);
list.add(4);
-list.sort(a, (b => a - b));
-list.sort(a, (b => b - a));
+list.sort((a: number, b: number) => a - b);
+list.sort((a: number, b: number) => b - a);
```
### getSubList
getSubList(fromIndex: number, toIndex: number): List<T>
-Obtains entries within a range in this container, including the entry at the start position but not that at the end position, and returns these entries as a new **List** instance.
+Obtains elements within a range in this container, including the element at the start position but not that at the end position, and returns these elements as a new **List** instance.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
@@ -441,9 +472,9 @@ list.add(2);
list.add(4);
list.add(5);
list.add(4);
-let result = list.subList(2, 4);
-let result1 = list.subList(4, 3);
-let result2 = list.subList(2, 6);
+let result = list.getSubList(2, 4);
+let result1 = list.getSubList(4, 3);
+let result2 = list.getSubList(2, 6);
```
### clear
@@ -452,6 +483,8 @@ clear(): void
Clears this container and sets its length to **0**.
+**System capability**: SystemCapability.Utils.Lang
+
**Example**
```ts
@@ -467,20 +500,22 @@ list.clear();
set(index: number, element: T): T
-Replaces an entry at the specified position in this container with a given entry.
+Replaces an element at the specified position in this container with a given element.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Value Type | Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| index | number | Yes| Position index of the entry to replace.|
-| element | T | Yes| Entry to be used for replacement.|
+| index | number | Yes| Position index of the target element.|
+| element | T | Yes| Element to be used for replacement.|
**Return value**
| Value Type | Description|
| -------- | -------- |
-| T | New entry.|
+| T | New element.|
**Example**
@@ -500,11 +535,13 @@ convertToArray(): Array<T>
Converts this container into an array.
+**System capability**: SystemCapability.Utils.Lang
+
**Return value**
-| Type | Description |
+| Value Type | Description|
| -------- | -------- |
-| Array<T> | Array obtained. |
+| Array<T> | Array obtained.|
**Example**
@@ -521,7 +558,9 @@ let result = list.convertToArray();
isEmpty(): boolean
-Checks whether this container is empty (contains no entry).
+Checks whether this container is empty (contains no element).
+
+**System capability**: SystemCapability.Utils.Lang
**Return value**
@@ -544,13 +583,15 @@ let result = list.isEmpty();
getFirst(): T
-Obtains the first entry in this container.
+Obtains the first element in this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Return value**
| Value Type | Description|
| -------- | -------- |
-| T | The first entry obtained.|
+| T | The first element obtained.|
**Example**
@@ -567,13 +608,15 @@ let result = list.getFirst();
getLast(): T
-Obtains the last entry in this container.
+Obtains the last element in this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Return value**
| Value Type | Description|
| -------- | -------- |
-| T | The last entry obtained.|
+| T | The last element obtained.|
**Example**
@@ -590,9 +633,10 @@ let result = list.getLast();
[Symbol.iterator]\(): IterableIterator<T>
-
Obtains an iterator, each item of which is a JavaScript object.
+**System capability**: SystemCapability.Utils.Lang
+
**Return value**
| Value Type | Description|
@@ -610,14 +654,14 @@ list.add(4);
// Method 1:
for (let item of list) {
- console.log(item);
+ console.log("value: " + item);
}
// Method 2:
let iter = list[Symbol.iterator]();
let temp = iter.next().value;
while(temp != undefined) {
- console.log(temp);
+ console.log("value: " + temp);
temp = iter.next().value;
}
```
diff --git a/en/application-dev/reference/apis/js-apis-media.md b/en/application-dev/reference/apis/js-apis-media.md
index 90041e190287f35f80ed0913690a8cdc3b11ae45..49f6e8f5ab16a3f6f28980204181f54a4e22c992 100644
--- a/en/application-dev/reference/apis/js-apis-media.md
+++ b/en/application-dev/reference/apis/js-apis-media.md
@@ -1,6 +1,7 @@
# Media
> **NOTE**
+>
> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
The multimedia subsystem provides a set of simple and easy-to-use APIs for you to access the system and use media resources.
@@ -117,7 +118,7 @@ Creates an **AudioRecorder** instance to control audio recording.
**Example**
```js
-let audiorecorder = media.createAudioRecorder();
+let audioRecorder = media.createAudioRecorder();
```
## media.createVideoRecorder9+
@@ -679,6 +680,8 @@ setDisplaySurface(surfaceId: string, callback: AsyncCallback\): void
Sets **SurfaceId**. This API uses a callback to return the result.
+*Note: **SetDisplaySurface** must be called between the URL setting and the calling of **prepare**. A surface must be set for video streams without audio. Otherwise, the calling of **prepare** fails.
+
**System capability**: SystemCapability.Multimedia.Media.VideoPlayer
**Parameters**
@@ -706,6 +709,8 @@ setDisplaySurface(surfaceId: string): Promise\
Sets **SurfaceId**. This API uses a promise to return the result.
+*Note: **SetDisplaySurface** must be called between the URL setting and the calling of **prepare**. A surface must be set for video streams without audio. Otherwise, the calling of **prepare** fails.
+
**System capability**: SystemCapability.Multimedia.Media.VideoPlayer
**Parameters**
@@ -716,9 +721,9 @@ Sets **SurfaceId**. 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**
@@ -1679,34 +1684,34 @@ let audioRecorderConfig = {
uri : 'fd://xx', // The file must be created by the caller and granted with proper permissions.
location : { latitude : 30, longitude : 130},
}
-audioRecorder.on('error', (error) => { // Set the 'error' event callback.
+audioRecorder.on('error', (error) => { // Set the error event callback.
console.info(`audio error called, errName is ${error.name}`);
console.info(`audio error called, errCode is ${error.code}`);
console.info(`audio error called, errMessage is ${error.message}`);
});
-audioRecorder.on('prepare', () => { // Set the 'prepare' event callback.
+audioRecorder.on('prepare', () => { // Set the prepare event callback.
console.log('prepare success');
- audioRecorder.start(); // Start recording and trigger the 'start' event callback.
+ audioRecorder.start(); // Start recording and trigger the start event callback.
});
-audioRecorder.on('start', () => { // Set the 'start' event callback.
+audioRecorder.on('start', () => { // Set the start event callback.
console.log('audio recorder start success');
});
-audioRecorder.on('pause', () => { // Set the 'pause' event callback.
+audioRecorder.on('pause', () => { // Set the pause event callback.
console.log('audio recorder pause success');
});
-audioRecorder.on('resume', () => { // Set the 'resume' event callback.
+audioRecorder.on('resume', () => { // Set the resume event callback.
console.log('audio recorder resume success');
});
-audioRecorder.on('stop', () => { // Set the 'stop' event callback.
+audioRecorder.on('stop', () => { // Set the stop event callback.
console.log('audio recorder stop success');
});
-audioRecorder.on('release', () => { // Set the 'release' event callback.
+audioRecorder.on('release', () => { // Set the release event callback.
console.log('audio recorder release success');
});
-audioRecorder.on('reset', () => { // Set the 'reset' event callback.
+audioRecorder.on('reset', () => { // Set the reset event callback.
console.log('audio recorder reset success');
});
-audioRecorder.prepare(audioRecorderConfig) // Set recording parameters and trigger the 'prepare' event callback.
+audioRecorder.prepare(audioRecorderConfig) // Set recording parameters and trigger the prepare event callback.
```
### on('error')
@@ -1727,12 +1732,12 @@ Subscribes to the audio recording error event.
**Example**
```js
-audioRecorder.on('error', (error) => { // Set the 'error' event callback.
+audioRecorder.on('error', (error) => { // Set the error event callback.
console.info(`audio error called, errName is ${error.name}`); // Print the error name.
console.info(`audio error called, errCode is ${error.code}`); // Print the error code.
console.info(`audio error called, errMessage is ${error.message}`); // Print the detailed description of the error type.
});
-audioRecorder.prepare(); // Do no set any parameter in prepare and trigger the 'error' event callback.
+audioRecorder.prepare(); // Do no set any parameter in prepare and trigger the error event callback.
```
## AudioRecorderConfig
@@ -1749,7 +1754,7 @@ Describes audio recording configurations.
| numberOfChannels | number | No | Number of audio channels. The default value is **2**. |
| format | [AudioOutputFormat](#audiooutputformat) | No | Audio output format. The default value is **MPEG_4**. |
| location | [Location](#location) | No | Geographical location of the recorded audio. |
-| uri | string | Yes | Audio output URI. Supported: fd://xx (fd number)  The file must be created by the caller and granted with proper permissions.|
+| uri | string | Yes | Audio output URI. Supported: fd://xx (fd number)  The file must be created by the caller and granted with proper permissions.|
| audioEncoderMime | [CodecMimeType](#codecmimetype8) | No | Audio encoding format. |
@@ -2347,7 +2352,7 @@ Subscribes to the video recording error event.
**Example**
```js
-videoRecorder.on('error', (error) => { // Set the 'error' event callback.
+videoRecorder.on('error', (error) => { // Set the error event callback.
console.info(`audio error called, errName is ${error.name}`); // Print the error name.
console.info(`audio error called, errCode is ${error.code}`); // Print the error code.
console.info(`audio error called, errMessage is ${error.message}`); // Print the detailed description of the error type.
@@ -2383,7 +2388,7 @@ Describes the video recording parameters.
| profile | [VideoRecorderProfile](#videorecorderprofile9) | Yes | Video recording profile. |
| rotation | number | No | Rotation angle of the recorded video. |
| location | [Location](#location) | No | Geographical location of the recorded video. |
-| url | string | Yes | Video output URL. Supported: fd://xx (fd number)  The file must be created by the caller and granted with proper permissions.|
+| url | string | Yes | Video output URL. Supported: fd://xx (fd number)  The file must be created by the caller and granted with proper permissions.|
## AudioSourceType9+
@@ -2434,7 +2439,7 @@ Enumerates the container format types (CFTs).
| Name | Value | Description |
| ----------- | ----- | --------------------- |
-| CFT_MPEG_4 | "mp4" | Video container format MPEG-4 .|
+| CFT_MPEG_4 | "mp4" | Video container format MPEG-4.|
| CFT_MPEG_4A | "m4a" | Audio container format M4A.|
## Location
diff --git a/en/application-dev/reference/apis/js-apis-medialibrary.md b/en/application-dev/reference/apis/js-apis-medialibrary.md
index 46ad60a5fe4baee84f673dee354d688e1be4b2a2..3d2f6f3e9703e606847e92822c62aa20c2811e8f 100644
--- a/en/application-dev/reference/apis/js-apis-medialibrary.md
+++ b/en/application-dev/reference/apis/js-apis-medialibrary.md
@@ -1,6 +1,7 @@
-# Media Library Management
+# MediaLibrary
-> **NOTE**
+> **NOTE**
+>
> This component is supported since API version 6. Updates will be marked with a superscript to indicate their earliest API version.
## Modules to Import
@@ -93,7 +94,7 @@ let imagesfetchOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()],
};
-mediaLibrary.getFileAssets(imagesfetchOp, (error, fetchFileResult) => {
+media.getFileAssets(imagesfetchOp, (error, fetchFileResult) => {
if (fetchFileResult != undefined) {
console.info('mediaLibraryTest : ASSET_CALLBACK fetchFileResult success');
fetchFileResult.getAllObject((err, fileAssetList) => {
@@ -135,7 +136,7 @@ let imagesfetchOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()],
};
-mediaLibrary.getFileAssets(imagesfetchOp).then(function(fetchFileResult){
+media.getFileAssets(imagesfetchOp).then(function(fetchFileResult){
console.info("getFileAssets successfully:"+ JSON.stringify(dir));
}).catch(function(err){
console.info("getFileAssets failed with error:"+ err);
@@ -182,7 +183,7 @@ Unsubscribes from the media library changes. This API uses an asynchronous callb
**Example**
```
-mediaLibrary.off('imageChange', () => {
+media.off('imageChange', () => {
// stop listening success
})
```
@@ -350,7 +351,7 @@ let AlbumNoArgsfetchOp = {
selections: '',
selectionArgs: [],
};
-mediaLibrary.getAlbums(AlbumNoArgsfetchOp, (err, albumList) => {
+media.getAlbums(AlbumNoArgsfetchOp, (err, albumList) => {
if (albumList != undefined) {
const album = albumList[0];
console.info('album.albumName = ' + album.albumName);
@@ -390,7 +391,7 @@ let AlbumNoArgsfetchOp = {
selections: '',
selectionArgs: [],
};
-mediaLibrary.getAlbums(AlbumNoArgsfetchOp).then(function(albumList){
+media.getAlbums(AlbumNoArgsfetchOp).then(function(albumList){
console.info("getAlbums successfully:"+ JSON.stringify(albumList));
}).catch(function(err){
console.info("getAlbums failed with error:"+ err);
@@ -439,7 +440,6 @@ Call this API when you no longer need to use the APIs in the **MediaLibrary** in
**Example**
```
-var media = mediaLibrary.getMediaLibrary(context);
media.release()
```
@@ -1957,7 +1957,7 @@ async function example() {
Provides APIs to implement a physical album.
-### **Attributes**
+### Attributes
**System capability**: SystemCapability.Multimedia.MediaLibrary.Core
diff --git a/en/application-dev/reference/apis/js-apis-mediaquery.md b/en/application-dev/reference/apis/js-apis-mediaquery.md
index 7cb3263efc4800810a185bf908ae98fef33808ec..bb6de45ab300f0e8fe1d5143849e656869decd3f 100644
--- a/en/application-dev/reference/apis/js-apis-mediaquery.md
+++ b/en/application-dev/reference/apis/js-apis-mediaquery.md
@@ -1,12 +1,13 @@
# Media Query
-> **NOTE**
+> **NOTE**
+>
> The APIs of this module are supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
## Modules to Import
-```
+```js
import mediaquery from '@ohos.mediaquery'
```
@@ -22,19 +23,22 @@ matchMediaSync(condition: string): MediaQueryListener
Sets the media query criteria and returns the corresponding listening handle.
-- Parameters
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | condition | string | Yes| Matching condition of a media event.|
+**System capability**: SystemCapability.ArkUI.ArkUI.Full
-- Return value
- | Type| Description|
- | -------- | -------- |
- | MediaQueryListener | Listening handle to a media event, which is used to register or unregister the listening callback.|
+**Parameters**
+| Name | Type | Mandatory | Description |
+| --------- | ------ | ---- | ---------------------------------------- |
+| condition | string | Yes | Matching condition of a media event. For details, see "Syntax of Media Query Conditions" in [Media Query](../../ui/ui-ts-layout-mediaquery.md). |
-- Example
- ```
- listener = mediaquery.matchMediaSync('(orientation: landscape)'); // Listen for landscape events.
+**Return value**
+| Type | Description |
+| ------------------ | ---------------------- |
+| MediaQueryListener | Listening handle to a media event, which is used to register or deregister the listening callback.|
+
+**Example**
+
+ ```js
+listener = mediaquery.matchMediaSync('(orientation: landscape)'); // Listen for landscape events.
```
@@ -42,13 +46,14 @@ Sets the media query criteria and returns the corresponding listening handle.
Media query handle, including the first query result when the handle is applied for.
+**System capability**: SystemCapability.ArkUI.ArkUI.Full
### Attributes
-| Name| Type| Readable| Writable| Description|
-| -------- | -------- | -------- | -------- | -------- |
-| matches | boolean | Yes| No| Whether the match condition is met.|
-| media | string | Yes| No| Matching condition of a media event.|
+| Name | Type | Readable | Writable | Description |
+| ------- | ------- | ---- | ---- | ---------- |
+| matches | boolean | Yes | No | Whether the match condition is met. |
+| media | string | Yes | No | Matching condition of a media event.|
### on
@@ -57,13 +62,15 @@ on(type: 'change', callback: Callback<MediaQueryResult>): void
Registers a callback with the corresponding query condition by using the handle. This callback is triggered when the media attributes change.
-- Parameters
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | type | string | Yes| Must enter the string **change**.|
- | callback | Callback<MediaQueryResult> | Yes| Callback registered with media query.|
+**System capability**: SystemCapability.ArkUI.ArkUI.Full
+
+**Parameters**
+| Name | Type | Mandatory | Description |
+| -------- | -------------------------------- | ---- | ---------------- |
+| type | string | Yes | Must enter the string **change**.|
+| callback | Callback<MediaQueryResult> | Yes | Callback registered with media query. |
-- Example
+**Example**
For details, see [off Example](#off).
@@ -71,15 +78,18 @@ Registers a callback with the corresponding query condition by using the handle.
off(type: 'change', callback?: Callback<MediaQueryResult>): void
-Unregisters a callback with the corresponding query condition by using the handle, so that no callback is triggered when the media attributes change.
-- Parameters
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | type | boolean | Yes| Must enter the string **change**.|
- | callback | Callback<MediaQueryResult> | No| Callback to be unregistered. If the default value is used, all callbacks of the handle are unregistered.|
+Deregisters a callback with the corresponding query condition by using the handle, so that no callback is triggered when the media attributes change.
-- Example
- ```
+**System capability**: SystemCapability.ArkUI.ArkUI.Full
+
+**Parameters**
+| Name | Type | Mandatory | Description |
+| -------- | -------------------------------- | ---- | ----------------------------- |
+| type | boolean | Yes | Must enter the string **change**. |
+| callback | Callback<MediaQueryResult> | No | Callback to be deregistered. If the default value is used, all callbacks of the handle are deregistered.|
+
+**Example**
+ ```js
import mediaquery from '@ohos.mediaquery'
listener = mediaquery.matchMediaSync('(orientation: landscape)'); // Listen for landscape events.
@@ -90,8 +100,8 @@ Unregisters a callback with the corresponding query condition by using the handl
// do something here
}
}
- this.listener.on('change', this.onPortrait) // Registration callback.
- this.listener.off('change', this.onPortrait) // Deregistration callback.
+ listener.on('change', onPortrait) // Register a callback.
+ listener.off('change', onPortrait) // Deregister a callback.
```
@@ -100,15 +110,15 @@ Unregisters a callback with the corresponding query condition by using the handl
### Attributes
-| Name| Type| Readable| Writable| Description|
-| -------- | -------- | -------- | -------- | -------- |
-| matches | boolean | Yes| No| Whether the match condition is met.|
-| media | string | Yes| No| Matching condition of a media event.|
+| Name | Type | Readable | Writable | Description |
+| ------- | ------- | ---- | ---- | ---------- |
+| matches | boolean | Yes | No | Whether the match condition is met. |
+| media | string | Yes | No | Matching condition of a media event.|
### Example
-```
+```js
import mediaquery from '@ohos.mediaquery'
let portraitFunc = null
@@ -131,7 +141,7 @@ struct MediaQueryExample {
}
aboutToAppear() {
- portraitFunc = this.onPortrait.bind(this) //bind current js instance
+ portraitFunc = this.onPortrait.bind(this) // Bind the current JS instance.
this.listener.on('change', portraitFunc)
}
diff --git a/en/application-dev/reference/apis/js-apis-missionManager.md b/en/application-dev/reference/apis/js-apis-missionManager.md
index 75c79e3af3da6181c1a81f374cdd3730e95a4191..94fb115434d6860cb2096586d48f0c981ea9a30a 100644
--- a/en/application-dev/reference/apis/js-apis-missionManager.md
+++ b/en/application-dev/reference/apis/js-apis-missionManager.md
@@ -1,7 +1,8 @@
# missionManager
-> **NOTE**
+> **NOTE**
+>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
missionManager provides APIs to lock, unlock, and clear missions, and switch a mission to the foreground.
@@ -26,15 +27,15 @@ Registers a listener to observe the mission status.
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| listener | MissionListener | Yes| Listener to register.|
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | listener | MissionListener | Yes| Listener to register.|
**Return value**
-| Type| Description|
-| -------- | -------- |
-| number | Returns the unique index of the mission status listener, which is created by the system and allocated when the listener is registered.|
+ | Type| Description|
+ | -------- | -------- |
+ | number | Returns the unique index of the mission status listener, which is created by the system and allocated when the listener is registered.|
**Example**
@@ -62,10 +63,10 @@ Deregisters a mission status listener. This API uses an asynchronous callback to
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| listenerId | number | Yes| Unique index of the mission status listener to unregister. It is returned by **registerMissionListener**.|
-| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | listenerId | number | Yes| Unique index of the mission status listener to unregister. It is returned by **registerMissionListener**.|
+ | callback | AsyncCallback<void> | Yes| Callback used to return the result.|
**Example**
@@ -96,15 +97,15 @@ Deregisters a mission status listener. This API uses a promise to return the res
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| listenerId | number | Yes| Unique index of the mission status listener to unregister. It is returned by **registerMissionListener**.|
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | listenerId | number | Yes| Unique index of the mission status listener to unregister. It is returned by **registerMissionListener**.|
**Return value**
-| Type| Description|
-| -------- | -------- |
-| Promise<void> | Promise used to return the result.|
+ | Type| Description|
+ | -------- | -------- |
+ | Promise<void> | Promise used to return the result.|
**Example**
@@ -135,11 +136,11 @@ Obtains the information about a given mission. This API uses an asynchronous cal
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
-| missionId | number | Yes| Mission ID.|
-| callback | AsyncCallback<[MissionInfo](#missioninfo)> | Yes| Callback used to return the mission information obtained.|
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
+ | missionId | number | Yes| Mission ID.|
+ | callback | AsyncCallback<[MissionInfo](#missioninfo)> | Yes| Callback used to return the mission information obtained.|
**Example**
@@ -169,16 +170,16 @@ Obtains the information about a given mission. This API uses a promise to return
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
-| missionId | number | Yes| Mission ID.|
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
+ | missionId | number | Yes| Mission ID.|
**Return value**
-| Type| Description|
-| -------- | -------- |
-| Promise<[MissionInfo](#missioninfo)> | Promise used to return the mission information obtained.|
+ | Type| Description|
+ | -------- | -------- |
+ | Promise<[MissionInfo](#missioninfo)> | Promise used to return the mission information obtained.|
**Example**
@@ -201,11 +202,11 @@ Obtains information about all missions. This API uses an asynchronous callback t
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
-| numMax | number | Yes| Maximum number of missions whose information can be obtained.|
-| callback | AsyncCallback<Array<[MissionInfo](#missioninfo)>> | Yes| Callback used to return the array of mission information obtained.|
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
+ | numMax | number | Yes| Maximum number of missions whose information can be obtained.|
+ | callback | AsyncCallback<Array<[MissionInfo](#missioninfo)>> | Yes| Callback used to return the array of mission information obtained.|
**Example**
@@ -230,16 +231,16 @@ Obtains information about all missions. This API uses a promise to return the re
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
-| numMax | number | Yes| Maximum number of missions whose information can be obtained.|
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
+ | numMax | number | Yes| Maximum number of missions whose information can be obtained.|
**Return value**
-| Type| Description|
-| -------- | -------- |
-| Promise<Array<[MissionInfo](#missioninfo)>> | Promise used to return the array of mission information obtained.|
+ | Type| Description|
+ | -------- | -------- |
+ | Promise<Array<[MissionInfo](#missioninfo)>> | Promise used to return the array of mission information obtained.|
**Example**
@@ -262,11 +263,11 @@ Obtains the snapshot of a given mission. This API uses an asynchronous callback
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
-| missionId | number | Yes| Mission ID.|
-| callback | AsyncCallback<[MissionSnapshot](js-apis-application-MissionSnapshot.md)> | Yes| Callback used to return the snapshot information obtained.|
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
+ | missionId | number | Yes| Mission ID.|
+ | callback | AsyncCallback<[MissionSnapshot](js-apis-application-MissionSnapshot.md)> | Yes| Callback used to return the snapshot information obtained.|
**Example**
@@ -297,16 +298,16 @@ Obtains the snapshot of a given mission. This API uses a promise to return the r
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
-| missionId | number | Yes| Mission ID.|
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
+ | missionId | number | Yes| Mission ID.|
**Return value**
-| Type| Description|
-| -------- | -------- |
-| Promise<[MissionSnapshot](js-apis-application-MissionSnapshot.md)> | Promise used to return the snapshot information obtained.|
+ | Type| Description|
+ | -------- | -------- |
+ | Promise<[MissionSnapshot](js-apis-application-MissionSnapshot.md)> | Promise used to return the snapshot information obtained.|
**Example**
@@ -337,10 +338,10 @@ Locks a given mission. This API uses an asynchronous callback to return the resu
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| missionId | number | Yes| Mission ID.|
-| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | missionId | number | Yes| Mission ID.|
+ | callback | AsyncCallback<void> | Yes| Callback used to return the result.|
**Example**
@@ -370,15 +371,15 @@ Locks a given mission. This API uses a promise to return the result.
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| missionId | number | Yes| Mission ID.|
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | missionId | number | Yes| Mission ID.|
**Return value**
-| Type| Description|
-| -------- | -------- |
-| Promise<void> | Promise used to return the result.|
+ | Type| Description|
+ | -------- | -------- |
+ | Promise<void> | Promise used to return the result.|
**Example**
@@ -441,15 +442,15 @@ Unlocks a given mission. This API uses a promise to return the result.
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| missionId | number | Yes| Mission ID.|
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | missionId | number | Yes| Mission ID.|
**Return value**
-| Type| Description|
-| -------- | -------- |
-| Promise<void> | Promise used to return the result.|
+ | Type| Description|
+ | -------- | -------- |
+ | Promise<void> | Promise used to return the result.|
**Example**
@@ -483,10 +484,10 @@ Clears a given mission, regardless of whether it is locked. This API uses an asy
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| missionId | number | Yes| Mission ID.|
-| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | missionId | number | Yes| Mission ID.|
+ | callback | AsyncCallback<void> | Yes| Callback used to return the result.|
**Example**
@@ -516,15 +517,15 @@ Clears a given mission, regardless of whether it is locked. This API uses a prom
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| missionId | number | Yes| Mission ID.|
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | missionId | number | Yes| Mission ID.|
**Return value**
-| Type| Description|
-| -------- | -------- |
-| Promise<void> | Promise used to return the result.|
+ | Type| Description|
+ | -------- | -------- |
+ | Promise<void> | Promise used to return the result.|
**Example**
@@ -574,9 +575,9 @@ Clears all unlocked missions. This API uses a promise to return the result.
**Return value**
-| Type| Description|
-| -------- | -------- |
-| Promise<void> | Promise used to return the result.|
+ | Type| Description|
+ | -------- | -------- |
+ | Promise<void> | Promise used to return the result.|
**Example**
@@ -598,10 +599,10 @@ Switches a given mission to the foreground. This API uses an asynchronous callba
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| missionId | number | Yes| Mission ID.|
-| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | missionId | number | Yes| Mission ID.|
+ | callback | AsyncCallback<void> | Yes| Callback used to return the result.|
**Example**
@@ -631,11 +632,11 @@ Switches a given mission to the foreground, with the startup parameters for the
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| missionId | number | Yes| Mission ID.|
-| options | StartOptions | Yes| Startup parameters, which are used to specify the window mode and device ID for switching the mission to the foreground.|
-| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | missionId | number | Yes| Mission ID.|
+ | options | [StartOptions](js-apis-application-StartOptions.md) | Yes| Startup parameters, which are used to specify the window mode and device ID for switching the mission to the foreground.|
+ | callback | AsyncCallback<void> | Yes| Callback used to return the result.|
**Example**
@@ -665,16 +666,16 @@ Switches a given mission to the foreground, with the startup parameters for the
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| missionId | number | Yes| Mission ID.|
-| options | StartOptions | No| Startup parameters, which are used to specify the window mode and device ID for switching the mission to the foreground.|
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | missionId | number | Yes| Mission ID.|
+ | options | [StartOptions](js-apis-application-StartOptions.md) | No| Startup parameters, which are used to specify the window mode and device ID for switching the mission to the foreground.|
**Return value**
-| Type| Description|
-| -------- | -------- |
-| Promise<void> | Promise used to return the result.|
+ | Type| Description|
+ | -------- | -------- |
+ | Promise<void> | Promise used to return the result.|
**Example**
@@ -700,13 +701,13 @@ Describes the mission information.
**System capability**: SystemCapability.Ability.AbilityBase
-| Name| Type| Readable| Writable| Description|
+| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| missionId | number | Yes| Yes| Mission ID.|
-| runningState | number | Yes| Yes| Running state of the mission.|
-| lockedState | boolean | Yes| Yes| Locked state of the mission.|
-| timestamp | string | Yes| Yes| Latest time when the mission was created or updated.|
-| want | [Want](js-apis-application-Want.md) | Yes| Yes| **Want** information of the mission.|
-| label | string | Yes| Yes| Label of the mission.|
-| iconPath | string | Yes| Yes| Path of the mission icon.|
-| continuable | boolean | Yes| Yes| Whether the mission can be continued on another device. |
+| missionId | number | Yes| Yes| Mission ID.|
+| runningState | number | Yes| Yes| Running state of the mission.|
+| lockedState | boolean | Yes| Yes| Locked state of the mission.|
+| timestamp | string | Yes| Yes| Latest time when the mission was created or updated.|
+| want | [Want](js-apis-application-Want.md) | Yes| Yes| **Want** information of the mission.|
+| label | string | Yes| Yes| Label of the mission.|
+| iconPath | string | Yes| Yes| Path of the mission icon.|
+| continuable | boolean | Yes| Yes| Whether the mission can be continued on another device. |
diff --git a/en/application-dev/reference/apis/js-apis-nfcController.md b/en/application-dev/reference/apis/js-apis-nfcController.md
index 3f5bc3c0db412c3837e6a8259c3bd2365d27553c..d4c99452483b63a9893905329d4fd1aae0be4505 100644
--- a/en/application-dev/reference/apis/js-apis-nfcController.md
+++ b/en/application-dev/reference/apis/js-apis-nfcController.md
@@ -1,6 +1,6 @@
# Standard NFC
-This module is used to implement Near-Field Communication (NFC).
+Implements Near-Field Communication (NFC).
> **NOTE**
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
@@ -90,7 +90,7 @@ Obtains the NFC state.
on(type: "nfcStateChange", callback: Callback<NfcState>): void
-Registers NFC state changes.
+Subscribes to NFC state changes.
**System capability**: SystemCapability.Communication.NFC
@@ -107,7 +107,7 @@ Registers NFC state changes.
off(type: "nfcStateChange", callback?: Callback<NfcState>): void
-Unregisters the NFC state changes.
+Unsubscribes from the NFC state changes.
**System capability**: SystemCapability.Communication.NFC
@@ -129,10 +129,10 @@ Unregisters the NFC state changes.
console.info("nfc state receive state: " + result);
}
- // Register the NFC state changes.
+ // Subscribe to the NFC state changes.
nfcController.on(NFC_STATE_NOTIFY, recvNfcStateNotifyFunc);
- // Unregister the NFC state changes.
+ // Unsubscribe from the NFC state changes.
nfcController.off(NFC_STATE_NOTIFY, recvNfcStateNotifyFunc);
```
diff --git a/en/application-dev/reference/apis/js-apis-nfcTag.md b/en/application-dev/reference/apis/js-apis-nfcTag.md
index 160bac7842cbdb4a289361eb00de1ba12892d64e..51731e95e192713e71add3304331475c11dd6629 100644
--- a/en/application-dev/reference/apis/js-apis-nfcTag.md
+++ b/en/application-dev/reference/apis/js-apis-nfcTag.md
@@ -1,6 +1,6 @@
# Standard NFC Tag
-This module is used to manage Near-Field Communication (NFC) tags.
+Manages Near-Field Communication (NFC) tags.
> **NOTE**
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
@@ -17,7 +17,7 @@ import tag from '@ohos.nfc.tag';
getNfcATag(tagInfo: TagInfo): NfcATag
-Obtains the **NfcATag** object, which allows access to the tags that use the NfcA technology.
+Obtains an **NfcATag** object, which allows access to the tags that use the NFC-A technology.
**Required permissions**: ohos.permission.NFC_TAG
@@ -33,7 +33,7 @@ Obtains the **NfcATag** object, which allows access to the tags that use the Nfc
getNfcBTag(tagInfo: TagInfo): NfcBTag
-Obtains the **NfcBTag** object, which allows access to the tags that use the NfcB technology.
+Obtains an **NfcBTag** object, which allows access to the tags that use the NFC-B technology.
**Required permissions**: ohos.permission.NFC_TAG
@@ -49,7 +49,7 @@ Obtains the **NfcBTag** object, which allows access to the tags that use the Nfc
getNfcFTag(tagInfo: TagInfo): NfcFTag
-Obtains the **NfcFTag** object, which allows access to the tags that use the NfcF technology.
+Obtains an **NfcFTag** object, which allows access to the tags that use the NFC-F technology.
**Required permissions**: ohos.permission.NFC_TAG
@@ -65,7 +65,7 @@ Obtains the **NfcFTag** object, which allows access to the tags that use the Nfc
getNfcVTag(tagInfo: TagInfo): NfcVTag
-Obtains the **NfcVTag** object, which allows access to the tags that use the NfcV technology.
+Obtains an **NfcVTag** object, which allows access to the tags that use the NFC-V technology.
**Required permissions**: ohos.permission.NFC_TAG
diff --git a/en/application-dev/reference/apis/js-apis-notification.md b/en/application-dev/reference/apis/js-apis-notification.md
index 1bd8702edac6a361335c69520bb54e8571224ebb..7912809087579d64ca726be1b9ada1c8ea0129fb 100644
--- a/en/application-dev/reference/apis/js-apis-notification.md
+++ b/en/application-dev/reference/apis/js-apis-notification.md
@@ -1,6 +1,6 @@
# Notification
->  **NOTE**
+> **NOTE**
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
@@ -85,6 +85,8 @@ Publishes a notification. This API uses an asynchronous callback to return the r
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name | Readable| Writable| Type | Mandatory| Description |
@@ -100,7 +102,7 @@ Publishes a notification. This API uses an asynchronous callback to return the r
function publishCallback(err) {
console.info("==========================>publishCallback=======================>");
}
-// ID of the user who receives the notification.
+// ID of the user who receives the notification
var userId = 1
// NotificationRequest object
var notificationRequest = {
@@ -125,6 +127,8 @@ Publishes a notification. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name | Readable| Writable| Type | Mandatory| Description |
@@ -287,6 +291,8 @@ Adds a notification slot. This API uses an asynchronous callback to return the r
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name | Readable| Writable| Type | Mandatory| Description |
@@ -318,6 +324,8 @@ Adds a notification slot. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name| Readable| Writable| Type | Mandatory| Description |
@@ -397,6 +405,8 @@ Adds multiple notification slots. This API uses an asynchronous callback to retu
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name | Readable| Writable| Type | Mandatory| Description |
@@ -432,6 +442,8 @@ Adds multiple notification slots. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name | Readable| Writable| Type | Mandatory| Description |
@@ -669,6 +681,8 @@ Subscribes to a notification with the subscription information specified. This A
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name | Readable| Writable| Type | Mandatory| Description |
@@ -684,7 +698,7 @@ Subscribes to a notification with the subscription information specified. This A
function subscribeCallback(err) {
console.info("==========================>subscribeCallback=======================>");
}
-function onConsumeCallback(err, data) {
+function onConsumeCallback(data) {
console.info("==========================>onConsumeCallback=======================>");
}
var subscriber = {
@@ -706,6 +720,8 @@ Subscribes to a notification with the subscription information specified. This A
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name | Readable| Writable| Type | Mandatory| Description |
@@ -719,7 +735,7 @@ Subscribes to a notification with the subscription information specified. This A
function subscribeCallback(err) {
console.info("==========================>subscribeCallback=======================>");
}
-function onConsumeCallback(err, data) {
+function onConsumeCallback(data) {
console.info("==========================>onConsumeCallback=======================>");
}
var subscriber = {
@@ -738,6 +754,8 @@ Subscribes to a notification with the subscription information specified. This A
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name | Readable| Writable| Type | Mandatory| Description |
@@ -748,7 +766,7 @@ Subscribes to a notification with the subscription information specified. This A
**Example**
```js
-function onConsumeCallback(err, data) {
+function onConsumeCallback(data) {
console.info("==========================>onConsumeCallback=======================>");
}
var subscriber = {
@@ -769,6 +787,8 @@ Unsubscribes from a notification. This API uses an asynchronous callback to retu
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name | Readable| Writable| Type | Mandatory| Description |
@@ -782,7 +802,7 @@ Unsubscribes from a notification. This API uses an asynchronous callback to retu
function unsubscribeCallback(err) {
console.info("==========================>unsubscribeCallback=======================>");
}
-function onConsumeCallback(err, data) {
+function onConsumeCallback(data) {
console.info("==========================>onConsumeCallback=======================>");
}
var subscriber = {
@@ -801,6 +821,8 @@ Unsubscribes from a notification. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name | Readable| Writable| Type | Mandatory| Description |
@@ -810,7 +832,7 @@ Unsubscribes from a notification. This API uses a promise to return the result.
**Example**
```js
-function onConsumeCallback(err, data) {
+function onConsumeCallback(data) {
console.info("==========================>onConsumeCallback=======================>");
}
var subscriber = {
@@ -831,6 +853,8 @@ Sets whether to enable notification for a specified bundle. This API uses an asy
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name | Readable| Writable| Type | Mandatory| Description |
@@ -861,6 +885,8 @@ Sets whether to enable notification for a specified bundle. This API uses a prom
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name | Readable| Writable| Type | Mandatory| Description |
@@ -889,6 +915,8 @@ Checks whether notification is enabled for a specified bundle. This API uses an
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name | Readable| Writable| Type | Mandatory| Description |
@@ -918,6 +946,8 @@ Checks whether notification is enabled for a specified bundle. This API uses a p
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name | Readable| Writable| Type | Mandatory| Description |
@@ -951,6 +981,8 @@ Checks whether notification is enabled for this application. This API uses an as
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name | Readable| Writable| Type | Mandatory| Description |
@@ -977,6 +1009,8 @@ Checks whether notification is enabled for this application. This API uses a pro
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name | Readable| Writable| Type | Mandatory| Description |
@@ -1007,6 +1041,8 @@ Sets whether to enable the notification badge for a specified bundle. This API u
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name | Readable| Writable| Type | Mandatory| Description |
@@ -1037,6 +1073,8 @@ Sets the notification slot for a specified bundle. This API uses a promise to re
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name | Readable| Writable| Type | Mandatory| Description |
@@ -1065,6 +1103,8 @@ Checks whether the notification badge is enabled for a specified bundle. This AP
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name | Readable| Writable| Type | Mandatory| Description |
@@ -1094,6 +1134,8 @@ Checks whether the notification badge is enabled for a specified bundle. This AP
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name | Readable| Writable| Type | Mandatory| Description |
@@ -1127,6 +1169,8 @@ Sets the notification slot for a specified bundle. This API uses an asynchronous
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name | Readable| Writable| Type | Mandatory| Description |
@@ -1160,6 +1204,8 @@ Sets the notification slot for a specified bundle. This API uses a promise to re
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name | Readable| Writable| Type | Mandatory| Description |
@@ -1176,7 +1222,7 @@ var bundle = {
var notificationSlot = {
type: Notification.SlotType.SOCIAL_COMMUNICATION
}
-Notification.displayBadge(bundle, notificationSlot).then(() => {
+Notification.setSlotByBundle(bundle, notificationSlot).then(() => {
console.info("==========================>setSlotByBundleCallback=======================>");
});
```
@@ -1191,6 +1237,8 @@ Obtains the notification slots of a specified bundle. This API uses an asynchron
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name | Readable| Writable| Type | Mandatory| Description |
@@ -1220,6 +1268,8 @@ Obtains the notification slots of a specified bundle. This API uses a promise to
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name | Readable| Writable| Type | Mandatory| Description |
@@ -1253,6 +1303,8 @@ Obtains the number of notification slots of a specified bundle. This API uses an
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name | Readable| Writable| Type | Mandatory| Description |
@@ -1263,7 +1315,7 @@ Obtains the number of notification slots of a specified bundle. This API uses an
**Example**
```js
-function getSlotNumByBundle(err, data) {
+function getSlotNumByBundleCallback(err, data) {
console.info("==========================>getSlotNumByBundleCallback=======================>");
}
var bundle = {
@@ -1282,6 +1334,8 @@ Obtains the number of notification slots of a specified bundle. This API uses a
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name | Readable| Writable| Type | Mandatory| Description |
@@ -1315,6 +1369,8 @@ Removes a notification for a specified bundle. This API uses an asynchronous cal
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name | Readable| Writable| Type | Mandatory| Description |
@@ -1349,6 +1405,8 @@ Removes a notification for a specified bundle. This API uses a promise to return
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name | Readable| Writable| Type | Mandatory| Description |
@@ -1381,6 +1439,8 @@ Removes a notification for a specified bundle. This API uses an asynchronous cal
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name | Readable| Writable| Type | Mandatory| Description |
@@ -1391,6 +1451,8 @@ Removes a notification for a specified bundle. This API uses an asynchronous cal
**Example**
```js
+var hashCode = 'hashCode'
+
function removeCallback(err) {
console.info("==========================>removeCallback=======================>");
}
@@ -1408,6 +1470,8 @@ Removes a notification for a specified bundle. This API uses a promise to return
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name | Readable| Writable| Type | Mandatory| Description |
@@ -1417,6 +1481,8 @@ Removes a notification for a specified bundle. This API uses a promise to return
**Example**
```js
+var hashCode = 'hashCode'
+
Notification.remove(hashCode).then(() => {
console.info("==========================>removeCallback=======================>");
});
@@ -1432,6 +1498,8 @@ Removes all notifications for a specified bundle. This API uses an asynchronous
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name | Readable| Writable| Type | Mandatory| Description |
@@ -1461,6 +1529,8 @@ Removes all notifications. This API uses an asynchronous callback to return the
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name | Readable| Writable| Type | Mandatory| Description |
@@ -1487,6 +1557,8 @@ Removes all notifications for a specified user. This API uses a promise to retur
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name | Readable| Writable| Type | Mandatory| Description |
@@ -1509,6 +1581,8 @@ Removes all notifications for a specified user. This API uses an asynchronous ca
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name | Readable| Writable| Type | Mandatory| Description |
@@ -1536,6 +1610,8 @@ Removes all notifications for a specified user. This API uses a promise to retur
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name | Readable| Writable| Type | Mandatory| Description |
@@ -1563,6 +1639,8 @@ Obtains all active notifications. This API uses an asynchronous callback to retu
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name | Readable| Writable| Type | Mandatory| Description |
@@ -1589,6 +1667,8 @@ Obtains all active notifications. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Return value**
| Type | Description |
@@ -1767,6 +1847,8 @@ Removes a notification group for a specified bundle. This API uses an asynchrono
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name | Readable| Writable| Type | Mandatory| Description |
@@ -1798,6 +1880,8 @@ Removes a notification group for a specified bundle. This API uses a promise to
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name | Readable| Writable| Type | Mandatory| Description |
@@ -1825,6 +1909,8 @@ Sets the DND time. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name | Readable| Writable| Type | Mandatory| Description |
@@ -1858,6 +1944,8 @@ Sets the DND time. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name| Readable| Writable| Type | Mandatory| Description |
@@ -1886,6 +1974,8 @@ Sets the DND time for a specified user. This API uses an asynchronous callback t
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name | Readable| Writable| Type | Mandatory| Description |
@@ -1922,6 +2012,8 @@ Sets the DND time for a specified user. This API uses a promise to return the re
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name | Readable| Writable| Type | Mandatory| Description |
@@ -1954,6 +2046,8 @@ Obtains the DND time. This API uses an asynchronous callback to return the resul
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name | Readable| Writable| Type | Mandatory| Description |
@@ -1980,6 +2074,8 @@ Obtains the DND time. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Return value**
| Type | Description |
@@ -2063,6 +2159,8 @@ Checks whether the DND mode is supported. This API uses an asynchronous callback
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name | Readable| Writable| Type | Mandatory| Description |
@@ -2089,6 +2187,8 @@ Checks whether the DND mode is supported. This API uses a promise to return the
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Return value**
| Type | Description |
@@ -2182,11 +2282,11 @@ Requests notification to be enabled for this application. This API uses an async
**Example**
```javascript
-function requestEnabledNotificationCallback() {
+function requestEnableNotificationCallback() {
console.log('------------- requestEnabledNotification --------------');
};
-Notification.requestEnabledNotification(requestEnabledNotificationCallback);
+Notification.requestEnableNotification(requestEnableNotificationCallback);
```
@@ -2217,6 +2317,8 @@ Sets whether this device supports distributed notifications. This API uses an as
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name | Type | Mandatory| Description |
@@ -2246,6 +2348,8 @@ Sets whether this device supports distributed notifications. This API uses a pro
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name | Type | Mandatory| Description |
@@ -2285,7 +2389,7 @@ function isDistributedEnabledCallback() {
console.log('----------- isDistributedEnabled ------------');
};
-Notification.enableDistributed(isDistributedEnabledCallback);
+Notification.isDistributedEnabled(isDistributedEnabledCallback);
```
@@ -2322,6 +2426,8 @@ Sets whether an application supports distributed notifications based on the bund
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name | Type | Mandatory| Description |
@@ -2350,12 +2456,14 @@ Notification.enableDistributedByBundle(bundle, enable, enableDistributedByBundle
## Notification.enableDistributedByBundle8+
-bundleenableDistributedByBundle(bundle: BundleOption, enable: boolean): Promise
+bundleenableDistributedByBundle(bundle: BundleOption, enable: boolean): Promise\
Sets whether an application supports distributed notifications based on the bundle. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name | Type | Mandatory| Description |
@@ -2386,6 +2494,8 @@ Obtains whether an application supports distributed notifications based on the b
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name | Type | Mandatory| Description |
@@ -2404,7 +2514,7 @@ var bundle = {
bundle: "bundleName1",
}
-Notification.enableDistributedByBundle(bundle, isDistributedEnabledByBundleCallback);
+Notification.isDistributedEnabledByBundle(bundle, isDistributedEnabledByBundleCallback);
```
@@ -2417,6 +2527,8 @@ Obtains whether an application supports distributed notifications based on the b
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name | Type | Mandatory| Description |
@@ -2451,6 +2563,8 @@ Obtains the notification reminder type. This API uses an asynchronous callback t
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Parameters**
| Name | Type | Mandatory| Description |
@@ -2477,6 +2591,8 @@ Obtains the notification reminder type. This API uses a promise to return the re
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
**Return value**
| Type | Description |
@@ -2492,8 +2608,289 @@ Notification.getDeviceRemindType()
});
```
+## Notification.publishAsBundle9+
+
+publishAsBundle(request: NotificationRequest, representativeBundle: string, userId: number, callback: AsyncCallback\): void
+
+Publishes an agent-powered notification. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Notification.Notification
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+
+| Name | Type | Mandatory| Description |
+| -------------------- | ------------------------------------------- | ---- | --------------------------------------------- |
+| request | [NotificationRequest](#notificationrequest) | Yes | Notification to publish.|
+| representativeBundle | string | Yes | Bundle name of the application whose notification function is taken over by the reminder agent. |
+| userId | number | Yes | ID of the user who receives the notification. |
+| callback | AsyncCallback | Yes | Callback used to return the result. |
+
+**Example**
+
+```js
+// Callback for publishAsBundle
+function publishAsBundleCallback(err) {
+ console.info("==========================>publishAsBundleCallback=======================>");
+}
+// Bundle name of the application whose notification function is taken over by the reminder agent
+let representativeBundle = "com.example.demo"
+// ID of the user who receives the notification
+let userId = 100
+// NotificationRequest object
+let notificationRequest = {
+ id: 1,
+ content: {
+ contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
+ normal: {
+ title: "test_title",
+ text: "test_text",
+ additionalText: "test_additionalText"
+ }
+ }
+}
+
+Notification.publishAsBundle(notificationRequest, representativeBundle, userId, publishAsBundleCallback);
+```
+
+## Notification.publishAsBundle9+
+
+publishAsBundle(request: NotificationRequest, representativeBundle: string, userId: number): Promise\
+
+Publishes a notification through the reminder agent. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Notification.Notification
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+
+| Name | Type | Mandatory| Description |
+| -------------------- | ------------------------------------------- | ---- | --------------------------------------------- |
+| request | [NotificationRequest](#notificationrequest) | Yes | Notification to publish.|
+| representativeBundle | string | Yes | Bundle name of the application whose notification function is taken over by the reminder agent. |
+| userId | number | Yes | ID of the user who receives the notification. |
+
+**Example**
+
+```js
+// Bundle name of the application whose notification function is taken over by the reminder agent
+let representativeBundle = "com.example.demo"
+// ID of the user who receives the notification
+let userId = 100
+// NotificationRequest object
+var notificationRequest = {
+ id: 1,
+ content: {
+ contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
+ normal: {
+ title: "test_title",
+ text: "test_text",
+ additionalText: "test_additionalText"
+ }
+ }
+}
+
+Notification.publishAsBundle(notificationRequest, representativeBundle, userId).then(() => {
+ console.info("==========================>publishAsBundleCallback=======================>");
+});
+```
+
+## Notification.cancelAsBundle9+
+
+cancelAsBundle(id: number, representativeBundle: string, userId: number, callback: AsyncCallback\): void
+
+Cancels a notification published by the reminder agent. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Notification.Notification
+
+**Parameters**
+
+
+| Name | Type | Mandatory| Description |
+| -------------------- | ------------- | ---- | ------------------------ |
+| id | number | Yes | Notification ID. |
+| representativeBundle | string | Yes | Bundle name of the application whose notification function is taken over by the reminder agent. |
+| userId | number | Yes | ID of the user who receives the notification. |
+| callback | AsyncCallback | Yes | Callback used to return the result.|
+
+**Example**
+
+```js
+//cancelAsBundle
+function cancelAsBundleCallback(err) {
+ console.info("==========================>cancelAsBundleCallback=======================>");
+}
+// Bundle name of the application whose notification function is taken over by the reminder agent
+let representativeBundle = "com.example.demo"
+// ID of the user who receives the notification
+let userId = 100
+
+Notification.cancelAsBundle(0, representativeBundle, userId, cancelAsBundleCallback);
+```
+
+## Notification.cancelAsBundle9+
+
+cancelAsBundle(id: number, representativeBundle: string, userId: number): Promise\
+
+Publishes a notification through the reminder agent. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Notification.Notification
+
+**Parameters**
+
+
+| Name | Type | Mandatory| Description |
+| -------------------- | ------ | ---- | ------------------ |
+| id | number | Yes | Notification ID. |
+| representativeBundle | string | Yes | Bundle name of the application whose notification function is taken over by the reminder agent.|
+| userId | number | Yes | ID of the user who receives the notification.|
+
+**Example**
+
+```js
+// Bundle name of the application whose notification function is taken over by the reminder agent
+let representativeBundle = "com.example.demo"
+// ID of the user who receives the notification
+let userId = 100
+
+Notification.cancelAsBundle(0, representativeBundle, userId).then(() => {
+ console.info("==========================>cancelAsBundleCallback=======================>");
+});
+```
+
+## Notification.enableNotificationSlot9+
+
+enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean, callback: AsyncCallback): void
+
+Sets the enabled status for a notification slot of a specified type. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Notification.Notification
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ----------------------------- | ---- | ---------------------- |
+| bundle | [BundleOption](#bundleoption) | Yes | Bundle information. |
+| type | [SlotType](#slottype) | Yes | Notification slot type. |
+| enable | boolean | Yes | Whether to enable notification. |
+| callback | AsyncCallback\ | Yes | Callback used to return the result.|
+
+**Example**
+
+```js
+//enableNotificationSlot
+function enableSlotCallback(err) {
+ console.log('===================>enableSlotCallback==================>');
+};
+
+Notification.enableNotificationSlot(
+ { bundle: "ohos.samples.notification", },
+ notify.SlotType.SOCIAL_COMMUNICATION,
+ true,
+ enableSlotCallback);
+```
+
+## Notification.enableNotificationSlot9+
+
+enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean): Promise
+
+Sets the enabled status for a notification slot of a specified type. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Notification.Notification
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ----------------------------- | ---- | -------------- |
+| bundle | [BundleOption](#bundleoption) | Yes | Bundle information. |
+| type | [SlotType](#slottype) | Yes | Notification slot type.|
+| enable | boolean | Yes | Whether to enable notification. |
+
+**Example**
+
+```js
+//enableNotificationSlot
+Notification.enableNotificationSlot(
+ { bundle: "ohos.samples.notification", },
+ notify.SlotType.SOCIAL_COMMUNICATION,
+ true).then(() => {
+ console.log('====================>enableNotificationSlot====================>');
+ });
+```
+
+## Notification.isNotificationSlotEnabled9+
+
+isNotificationSlotEnabled(bundle: BundleOption, type: SlotType, callback: AsyncCallback): void
+
+Obtains the enabled status of a notification slot of a specified type. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Notification.Notification
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ----------------------------- | ---- | ---------------------- |
+| bundle | [BundleOption](#bundleoption) | Yes | Bundle information. |
+| type | [SlotType](#slottype) | Yes | Notification slot type. |
+| callback | AsyncCallback\ | Yes | Callback used to return the result.|
+
+**Example**
+
+```js
+//isNotificationSlotEnabled
+function getEnableSlotCallback(err, data) {
+ console.log('===================>getEnableSlotCallback==================');
+};
+
+Notification.isNotificationSlotEnabled(
+ { bundle: "ohos.samples.notification", },
+ notify.SlotType.SOCIAL_COMMUNICATION,
+ getEnableSlotCallback);
+```
+
+## Notification.isNotificationSlotEnabled9+
+
+isNotificationSlotEnabled(bundle: BundleOption, type: SlotType): Promise
+
+Obtains the enabled status of a notification slot of a specified type. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Notification.Notification
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ----------------------------- | ---- | -------------- |
+| bundle | [BundleOption](#bundleoption) | Yes | Bundle information. |
+| type | [SlotType](#slottype) | Yes | Notification slot type.|
+
+**Example**
+
+```js
+//isNotificationSlotEnabled
+Notification.isNotificationSlotEnabled(
+ { bundle: "ohos.samples.notification", },
+ notify.SlotType.SOCIAL_COMMUNICATION,
+ true).then((data) => {
+ console.log('====================>isNotificationSlotEnabled====================>');
+ });
+```
+
## NotificationSubscriber
+**System API**: This is a system API and cannot be called by third-party applications.
+
### onConsume
onConsume?:(data: [SubscribeCallbackData](#subscribecallbackdata))
@@ -2526,12 +2923,12 @@ function onConsumeCallback(data) {
let wantAgent = data.wantAgent;
wantAgent .getWant(wantAgent)
.then((data1) => {
- console.log('===> getWant success want:' + JSON.stringfy(data1));
+ console.log('===> getWant success want:' + JSON.stringify(data1));
})
.catch((err) => {
- console.error('===> getWant failed because' + JSON.stringfy(err));
+ console.error('===> getWant failed because' + JSON.stringify(err));
});
- console.info('===> onConsume callback req.wantAgent:' + JSON.stringfy(req.wantAgent));
+ console.info('===> onConsume callback req.wantAgent:' + JSON.stringify(req.wantAgent));
};
var subscriber = {
@@ -2766,14 +3163,10 @@ function subscribeCallback(err) {
}
};
-function onEnabledNotificationChangedCallback(err, callbackData) {
- if (err.code) {
- console.info("subscribe failed " + JSON.stringify(err));
- } else {
- console.info("bundle: ", callbackData.bundle);
- console.info("uid: ", callbackData.uid);
- console.info("enable: ", callbackData.enable);
- }
+function onEnabledNotificationChangedCallback(callbackData) {
+ console.info("bundle: ", callbackData.bundle);
+ console.info("uid: ", callbackData.uid);
+ console.info("enable: ", callbackData.enable);
};
var subscriber = {
@@ -2787,6 +3180,8 @@ Notification.subscribe(subscriber, subscribeCallback);
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
| Name | Readable| Writable| Type | Mandatory| Description |
| --------------- | ---- | --- | ------------------------------------------------- | ---- | -------- |
| request | Yes | No | [NotificationRequest](#notificationrequest) | Yes | Notification content.|
@@ -2800,6 +3195,8 @@ Notification.subscribe(subscriber, subscribeCallback);
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
| Name | Readable| Writable| Type | Mandatory| Description |
| ------ | ---- | --- | ------- | ---- | ---------------- |
| bundle | Yes | No | string | Yes | Bundle name of the application. |
@@ -2811,6 +3208,8 @@ Notification.subscribe(subscriber, subscribeCallback);
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
| Name | Readable| Writable| Type | Description |
| ----- | ---- | --- | ------------------------------------- | ------------------------ |
| type | Yes | No | [DoNotDisturbType](#donotdisturbtype8) | DND time type.|
@@ -2823,13 +3222,14 @@ Notification.subscribe(subscriber, subscribeCallback);
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
| Name | Value | Description |
| ------------ | ---------------- | ------------------------------------------ |
-| TYPE_NONE | DoNotDisturbType | Non-DND. |
-| TYPE_ONCE | DoNotDisturbType | One-shot DND at the specified time segment (only considering the hour and minute).|
-| TYPE_DAILY | DoNotDisturbType | Daily DND at the specified time segment (only considering the hour and minute).|
-| TYPE_CLEARLY | DoNotDisturbType | DND at the specified time segment (considering the year, month, day, hour, and minute). |
+| TYPE_NONE | 0 | Non-DND. |
+| TYPE_ONCE | 1 | One-shot DND at the specified time segment (only considering the hour and minute).|
+| TYPE_DAILY | 2 | Daily DND at the specified time segment (only considering the hour and minute).|
+| TYPE_CLEARLY | 3 | DND at the specified time segment (considering the year, month, day, hour, and minute). |
## ContentType
@@ -2838,11 +3238,11 @@ Notification.subscribe(subscriber, subscribeCallback);
| Name | Value | Description |
| --------------------------------- | ----------- | ------------------ |
-| NOTIFICATION_CONTENT_BASIC_TEXT | ContentType | Normal text notification. |
-| NOTIFICATION_CONTENT_LONG_TEXT | ContentType | Long text notification. |
-| NOTIFICATION_CONTENT_PICTURE | ContentType | Picture-attached notification. |
-| NOTIFICATION_CONTENT_CONVERSATION | ContentType | Conversation notification. |
-| NOTIFICATION_CONTENT_MULTILINE | ContentType | Multi-line text notification.|
+| NOTIFICATION_CONTENT_BASIC_TEXT | NOTIFICATION_CONTENT_BASIC_TEXT | Normal text notification. |
+| NOTIFICATION_CONTENT_LONG_TEXT | NOTIFICATION_CONTENT_LONG_TEXT | Long text notification. |
+| NOTIFICATION_CONTENT_PICTURE | NOTIFICATION_CONTENT_PICTURE | Picture-attached notification. |
+| NOTIFICATION_CONTENT_CONVERSATION | NOTIFICATION_CONTENT_CONVERSATION | Conversation notification. |
+| NOTIFICATION_CONTENT_MULTILINE | NOTIFICATION_CONTENT_MULTILINE | Multi-line text notification.|
## SlotLevel
@@ -2850,9 +3250,9 @@ Notification.subscribe(subscriber, subscribeCallback);
| Name | Value | Description |
| --------------------------------- | ----------- | ------------------ |
-| LEVEL_NONE | 0 | The notification feature is disabled. |
-| LEVEL_MIN | 1 | The notification feature is enabled, but the notification icon is not displayed in the status bar, with no banner or alert tone.|
-| LEVEL_LOW | 2 | The notification feature is enabled, and the notification icon is displayed in the status bar, with no banner or alert tone.|
+| LEVEL_NONE | 0 | The notification function is disabled. |
+| LEVEL_MIN | 1 | The notification function is enabled, but the notification icon is not displayed in the status bar, with no banner or alert tone.|
+| LEVEL_LOW | 2 | The notification function is enabled, and the notification icon is displayed in the status bar, with no banner or alert tone.|
| LEVEL_DEFAULT | 3 | The notification feature is enabled, and the notification icon is displayed in the status bar, with an alert tone but no banner.|
| LEVEL_HIGH | 4 | The notification feature is enabled, and the notification icon is displayed in the status bar, with an alert tone and banner.|
@@ -2884,11 +3284,11 @@ Notification.subscribe(subscriber, subscribeCallback);
| Name | Value | Description |
| -------------------- | -------- | ---------- |
-| UNKNOWN_TYPE | SlotType | Unknown type.|
-| SOCIAL_COMMUNICATION | SlotType | Notification slot for social communication.|
-| SERVICE_INFORMATION | SlotType | Notification slot for service information.|
-| CONTENT_INFORMATION | SlotType | Notification slot for content consultation.|
-| OTHER_TYPES | SlotType | Notification slot for other purposes.|
+| UNKNOWN_TYPE | 0 | Unknown type.|
+| SOCIAL_COMMUNICATION | 1 | Notification slot for social communication.|
+| SERVICE_INFORMATION | 2 | Notification slot for service information.|
+| CONTENT_INFORMATION | 3 | Notification slot for content consultation.|
+| OTHER_TYPES | 0xFFFF | Notification slot for other purposes.|
## NotificationActionButton
@@ -2973,6 +3373,8 @@ Notification.subscribe(subscriber, subscribeCallback);
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
| Name | Value | Description |
| -------------- | --- | --------------------------------- |
| TYPE_NONE | 0 | The default flag is used. |
@@ -3021,7 +3423,7 @@ Notification.subscribe(subscriber, subscribeCallback);
| creatorBundleName | Yes | No | string | No | Name of the bundle that creates the notification. |
| creatorUid | Yes | No | number | No | UID used for creating the notification. |
| creatorPid | Yes | No | number | No | PID used for creating the notification. |
-| creatorUserId8+| Yes | No | number | No | ID of the user who creates a notification. |
+| creatorUserId8+| Yes | No | number | No | ID of the user who creates the notification. |
| hashCode | Yes | No | string | No | Unique ID of the notification. |
| classification | Yes | Yes | string | No | Notification category. |
| groupName8+| Yes | Yes | string | No | Group notification name. |
@@ -3062,12 +3464,15 @@ Notification.subscribe(subscriber, subscribeCallback);
| lightEnabled | Yes | Yes | boolean | No | Whether the indicator blinks for the notification. |
| lightColor | Yes | Yes | number | No | Indicator color of the notification. |
| vibrationValues | Yes | Yes | Array\ | No | Vibration mode of the notification. |
+| enabled9+ | Yes | No | boolean | No | Enabled status of the notification slot. |
## NotificationSorting
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
| Name | Readable| Writable| Type | Mandatory| Description |
| -------- | ---- | --- | ------------------------------------- | ---- | ------------ |
| slot | Yes | No | [NotificationSlot](#notificationslot) | Yes | Notification slot content.|
@@ -3079,6 +3484,8 @@ Notification.subscribe(subscriber, subscribeCallback);
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
| Name | Readable| Writable| Type | Mandatory| Description |
| -------------- | ---- | --- | ------------------------------------------------------------ | ---- | ---------------- |
| sortings | Yes | No | {[key: string]: [NotificationSorting](#notificationsorting)} | Yes | Array of notification sorting information.|
@@ -3089,6 +3496,8 @@ Notification.subscribe(subscriber, subscribeCallback);
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
| Name | Readable| Writable| Type | Mandatory| Description |
| ----------- | --- | ---- | --------------- | ---- | ------------------------------- |
| bundleNames | Yes | Yes | Array\ | No | Bundle names of the applications whose notifications are to be subscribed to.|
@@ -3118,6 +3527,8 @@ Notification.subscribe(subscriber, subscribeCallback);
**System capability**: SystemCapability.Notification.Notification
+**System API**: This is a system API and cannot be called by third-party applications.
+
| Name | Value | Description |
| -------------------- | --- | --------------------------------- |
| IDLE_DONOT_REMIND | 0 | The device is not in use. No notification is required. |
diff --git a/en/application-dev/reference/apis/js-apis-osAccount.md b/en/application-dev/reference/apis/js-apis-osAccount.md
index f0e93479b923928923f27bcda147a7c8d23f0d59..bb62764d00730e1abb51a3b302915cd6bee264ca 100644
--- a/en/application-dev/reference/apis/js-apis-osAccount.md
+++ b/en/application-dev/reference/apis/js-apis-osAccount.md
@@ -1,6 +1,6 @@
# OS Account Management
->  **NOTE**
+>  **NOTE**
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
@@ -48,7 +48,7 @@ Provides methods to manage OS accounts.
activateOsAccount(localId: number, callback: AsyncCallback<void>): void
-Activates an OS account. This method uses an asynchronous callback to return the result.
+Activates an OS account. This API uses an asynchronous callback to return the result.
This is a system API and cannot be called by third-party applications.
@@ -76,7 +76,7 @@ This is a system API and cannot be called by third-party applications.
activateOsAccount(localId: number): Promise<void>
-Activates an OS account. This method uses a promise to return the result.
+Activates an OS account. This API uses a promise to return the result asynchronously.
This is a system API and cannot be called by third-party applications.
@@ -111,7 +111,7 @@ This is a system API and cannot be called by third-party applications.
isMultiOsAccountEnable(callback: AsyncCallback<boolean>): void
-Checks whether multiple OS accounts are supported. This method uses an asynchronous callback to return the result.
+Checks whether multiple OS accounts are supported. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.OsAccount
@@ -135,7 +135,7 @@ Checks whether multiple OS accounts are supported. This method uses an asynchron
isMultiOsAccountEnable(): Promise<boolean>
-Checks whether multiple OS accounts are supported. This method uses a promise to return the result.
+Checks whether multiple OS accounts are supported. This API uses a promise to return the result asynchronously.
**System capability**: SystemCapability.Account.OsAccount
@@ -160,7 +160,7 @@ Checks whether multiple OS accounts are supported. This method uses a promise to
isOsAccountActived(localId: number, callback: AsyncCallback<boolean>): void
-Checks whether an OS account is activated. This method uses an asynchronous callback to return the result.
+Checks whether an OS account is activated. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
@@ -188,7 +188,7 @@ Checks whether an OS account is activated. This method uses an asynchronous call
isOsAccountActived(localId: number): Promise<boolean>
-Checks whether an OS account is activated. This method uses a promise to return the result.
+Checks whether an OS account is activated. This API uses a promise to return the result asynchronously.
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
@@ -222,7 +222,7 @@ Checks whether an OS account is activated. This method uses a promise to return
isOsAccountConstraintEnable(localId: number, constraint: string, callback: AsyncCallback<boolean>): void
-Checks whether the specified constraint is enabled for an OS account. This method uses an asynchronous callback to return the result.
+Checks whether the specified constraint is enabled for an OS account. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
@@ -251,7 +251,7 @@ Checks whether the specified constraint is enabled for an OS account. This metho
isOsAccountConstraintEnable(localId: number, constraint: string): Promise<boolean>
-Checks whether the specified constraint is enabled for an OS account. This method uses a promise to return the result.
+Checks whether the specified constraint is enabled for an OS account. This API uses a promise to return the result asynchronously.
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
@@ -286,7 +286,7 @@ Checks whether the specified constraint is enabled for an OS account. This metho
isTestOsAccount(callback: AsyncCallback<boolean>): void
-Checks whether this OS account is a test account. This method uses an asynchronous callback to return the result.
+Checks whether this OS account is a test account. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.OsAccount
@@ -310,7 +310,7 @@ Checks whether this OS account is a test account. This method uses an asynchrono
isTestOsAccount(): Promise<boolean>
-Checks whether this OS account is a test account. This method uses a promise to return the result.
+Checks whether this OS account is a test account. This API uses a promise to return the result asynchronously.
**System capability**: SystemCapability.Account.OsAccount
@@ -335,7 +335,7 @@ Checks whether this OS account is a test account. This method uses a promise to
isOsAccountVerified(callback: AsyncCallback<boolean>): void
-Checks whether this OS account has been verified. This method uses an asynchronous callback to return the result.
+Checks whether this OS account has been verified. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.OsAccount
@@ -359,7 +359,7 @@ Checks whether this OS account has been verified. This method uses an asynchrono
isOsAccountVerified(localId: number, callback: AsyncCallback<boolean>): void
-Checks whether an OS account has been verified. This method uses an asynchronous callback to return the result.
+Checks whether an OS account has been verified. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
@@ -386,7 +386,7 @@ Checks whether an OS account has been verified. This method uses an asynchronous
isOsAccountVerified(localId?: number): Promise<boolean>
-Checks whether an OS account has been verified. This method uses a promise to return the result.
+Checks whether an OS account has been verified. This API uses a promise to return the result asynchronously.
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
@@ -419,7 +419,7 @@ Checks whether an OS account has been verified. This method uses a promise to re
removeOsAccount(localId: number, callback: AsyncCallback<void>): void
-Removes an OS account. This method uses an asynchronous callback to return the result.
+Removes an OS account. This API uses an asynchronous callback to return the result.
This is a system API and cannot be called by third-party applications.
@@ -451,7 +451,7 @@ This is a system API and cannot be called by third-party applications.
removeOsAccount(localId: number): Promise<void>
-Removes an OS account. This method uses a promise to return the result.
+Removes an OS account. This API uses a promise to return the result asynchronously.
This is a system API and cannot be called by third-party applications.
@@ -491,7 +491,7 @@ This is a system API and cannot be called by third-party applications.
setOsAccountConstraints(localId: number, constraints: Array<string>, enable: boolean,callback: AsyncCallback<void>): void
-Sets or removes constraints for an OS account. This method uses an asynchronous callback to return the result.
+Sets or removes constraints for an OS account. This API uses an asynchronous callback to return the result.
This is a system API and cannot be called by third-party applications.
@@ -522,7 +522,7 @@ This is a system API and cannot be called by third-party applications.
setOsAccountConstraints(localId: number, constraints: Array<string>, enable: boolean): Promise<void>
-Sets or removes constraints for an OS account. This method uses a promise to return the result.
+Sets or removes constraints for an OS account. This API uses a promise to return the result asynchronously.
This is a system API and cannot be called by third-party applications.
@@ -560,7 +560,7 @@ This is a system API and cannot be called by third-party applications.
setOsAccountName(localId: number, localName: string, callback: AsyncCallback<void>): void
-Sets a name for an OS account. This method uses an asynchronous callback to return the result.
+Sets a name for an OS account. This API uses an asynchronous callback to return the result.
This is a system API and cannot be called by third-party applications.
@@ -591,7 +591,7 @@ This is a system API and cannot be called by third-party applications.
setOsAccountName(localId: number, localName: string): Promise<void>
-Sets a name for an OS account. This method uses a promise to return the result.
+Sets a name for an OS account. This API uses a promise to return the result asynchronously.
This is a system API and cannot be called by third-party applications.
@@ -629,7 +629,7 @@ This is a system API and cannot be called by third-party applications.
getCreatedOsAccountsCount(callback: AsyncCallback<number>): void
-Obtains the number of OS accounts created. This method uses an asynchronous callback to return the result.
+Obtains the number of OS accounts created. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
@@ -655,7 +655,7 @@ Obtains the number of OS accounts created. This method uses an asynchronous call
getCreatedOsAccountsCount(): Promise<number>
-Obtains the number of OS accounts created. This method uses a promise to return the result.
+Obtains the number of OS accounts created. This API uses a promise to return the result asynchronously.
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
@@ -682,7 +682,7 @@ Obtains the number of OS accounts created. This method uses a promise to return
getOsAccountLocalIdFromProcess(callback: AsyncCallback<number>): void
-Obtains the ID of the OS account to which the current process belongs. This method uses an asynchronous callback to return the result.
+Obtains the ID of the OS account to which the current process belongs. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.OsAccount
@@ -706,7 +706,7 @@ Obtains the ID of the OS account to which the current process belongs. This meth
getOsAccountLocalIdFromProcess(): Promise<number>
-Obtains the ID of the OS account to which the current process belongs. This method uses a promise to return the result.
+Obtains the ID of the OS account to which the current process belongs. This API uses a promise to return the result asynchronously.
**System capability**: SystemCapability.Account.OsAccount
@@ -731,7 +731,7 @@ Obtains the ID of the OS account to which the current process belongs. This meth
getOsAccountLocalIdFromUid(uid: number, callback: AsyncCallback<number>): void
-Obtains the OS account ID based on the process UID. This method uses an asynchronous callback to return the result.
+Obtains the OS account ID based on the process UID. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.OsAccount
@@ -757,7 +757,7 @@ Obtains the OS account ID based on the process UID. This method uses an asynchro
getOsAccountLocalIdFromUid(uid: number): Promise<number>
-Obtains the OS account ID based on the process UID. This method uses a promise to return the result.
+Obtains the OS account ID based on the process UID. This API uses a promise to return the result asynchronously.
**System capability**: SystemCapability.Account.OsAccount
@@ -789,7 +789,7 @@ Obtains the OS account ID based on the process UID. This method uses a promise t
getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo, callback: AsyncCallback<number>): void
-Obtains the OS account ID based on domain account information. This method uses an asynchronous callback to return the result.
+Obtains the OS account ID based on domain account information. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
@@ -817,7 +817,7 @@ Obtains the OS account ID based on domain account information. This method uses
getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo): Promise<number>
-Obtains the OS account ID based on domain account information. This method uses a promise to return the result.
+Obtains the OS account ID based on domain account information. This API uses a promise to return the result asynchronously.
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
@@ -851,7 +851,7 @@ Obtains the OS account ID based on domain account information. This method uses
queryMaxOsAccountNumber(callback: AsyncCallback<number>): void
-Obtains the maximum number of OS accounts that can be created. This method uses an asynchronous callback to return the result.
+Obtains the maximum number of OS accounts that can be created. This API uses an asynchronous callback to return the result.
This is a system API and cannot be called by third-party applications.
@@ -877,7 +877,7 @@ This is a system API and cannot be called by third-party applications.
queryMaxOsAccountNumber(): Promise<number>
-Obtains the maximum number of OS accounts that can be created. This method uses a promise to return the result.
+Obtains the maximum number of OS accounts that can be created. This API uses a promise to return the result asynchronously.
This is a system API and cannot be called by third-party applications.
@@ -904,7 +904,7 @@ This is a system API and cannot be called by third-party applications.
getOsAccountAllConstraints(localId: number, callback: AsyncCallback<Array<string>>): void
-Obtains all constraints enabled for an OS account. This method uses an asynchronous callback to return the result.
+Obtains all constraints enabled for an OS account. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
@@ -932,7 +932,7 @@ Obtains all constraints enabled for an OS account. This method uses an asynchron
getOsAccountAllConstraints(localId: number): Promise<Array<string>>
-Obtains all constraints enabled for an OS account. This method uses a promise to return the result.
+Obtains all constraints enabled for an OS account. This API uses a promise to return the result asynchronously.
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
@@ -966,7 +966,7 @@ Obtains all constraints enabled for an OS account. This method uses a promise to
queryAllCreatedOsAccounts(callback: AsyncCallback<Array<OsAccountInfo>>): void
-Obtains information about all the OS accounts created. This method uses an asynchronous callback to return the result.
+Obtains information about all the OS accounts created. This API uses an asynchronous callback to return the result.
This is a system API and cannot be called by third-party applications.
@@ -992,7 +992,7 @@ This is a system API and cannot be called by third-party applications.
queryAllCreatedOsAccounts(): Promise<Array<OsAccountInfo>>
-Obtains information about all the OS accounts created. This method uses a promise to return the result.
+Obtains information about all the OS accounts created. This API uses a promise to return the result asynchronously.
This is a system API and cannot be called by third-party applications.
@@ -1019,7 +1019,7 @@ This is a system API and cannot be called by third-party applications.
queryActivatedOsAccountIds(callback: AsyncCallback<Array<number>>): void
-Obtains information about all activated OS accounts. This method uses an asynchronous callback to return the result.
+Obtains information about all activated OS accounts. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.OsAccount
@@ -1046,7 +1046,7 @@ Obtains information about all activated OS accounts. This method uses an asynchr
queryActivatedOsAccountIds(): Promise<Array<number>>
-Obtains information about all activated OS accounts. This method uses a promise to return the result.
+Obtains information about all activated OS accounts. This API uses a promise to return the result asynchronously.
**System capability**: SystemCapability.Account.OsAccount
@@ -1071,7 +1071,7 @@ Obtains information about all activated OS accounts. This method uses a promise
createOsAccount(localName: string, type: OsAccountType, callback: AsyncCallback<OsAccountInfo>): void
-Creates an OS account. This method uses an asynchronous callback to return the result.
+Creates an OS account. This API uses an asynchronous callback to return the result.
This is a system API and cannot be called by third-party applications.
@@ -1101,7 +1101,7 @@ This is a system API and cannot be called by third-party applications.
createOsAccount(localName: string, type: OsAccountType): Promise<OsAccountInfo>
-Creates an OS account. This method uses a promise to return the result.
+Creates an OS account. This API uses a promise to return the result asynchronously.
This is a system API and cannot be called by third-party applications.
@@ -1137,7 +1137,7 @@ This is a system API and cannot be called by third-party applications.
createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo, callback: AsyncCallback<OsAccountInfo>): void
-Creates an OS account and associates it with the specified domain account. This method uses an asynchronous callback to return the result.
+Creates an OS account and associates it with the specified domain account. This API uses an asynchronous callback to return the result.
This is a system API and cannot be called by third-party applications.
@@ -1168,7 +1168,7 @@ This is a system API and cannot be called by third-party applications.
createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo): Promise<OsAccountInfo>
-Creates an OS account and associates it with the specified domain account. This method uses a promise to return the result.
+Creates an OS account and associates it with the specified domain account. This API uses a promise to return the result asynchronously.
This is a system API and cannot be called by third-party applications.
@@ -1205,7 +1205,7 @@ This is a system API and cannot be called by third-party applications.
queryCurrentOsAccount(callback: AsyncCallback<OsAccountInfo>): void
-Obtains information about the OS account to which the current process belongs. This method uses an asynchronous callback to return the result.
+Obtains information about the OS account to which the current process belongs. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
@@ -1231,7 +1231,7 @@ Obtains information about the OS account to which the current process belongs. T
queryCurrentOsAccount(): Promise<OsAccountInfo>
-Obtains information about the OS account to which the current process belongs. This method uses a promise to return the result.
+Obtains information about the OS account to which the current process belongs. This API uses a promise to return the result asynchronously.
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
@@ -1258,7 +1258,7 @@ Obtains information about the OS account to which the current process belongs. T
queryOsAccountById(localId: number, callback: AsyncCallback<OsAccountInfo>): void
-Obtains information about an OS account. This method uses an asynchronous callback to return the result.
+Obtains information about an OS account. This API uses an asynchronous callback to return the result.
This is a system API and cannot be called by third-party applications.
@@ -1288,7 +1288,7 @@ This is a system API and cannot be called by third-party applications.
queryOsAccountById(localId: number): Promise<OsAccountInfo>
-Obtains information about an OS account. This method uses a promise to return the result.
+Obtains information about an OS account. This API uses a promise to return the result asynchronously.
This is a system API and cannot be called by third-party applications.
@@ -1324,7 +1324,7 @@ This is a system API and cannot be called by third-party applications.
getOsAccountTypeFromProcess(callback: AsyncCallback<OsAccountType>): void
-Obtains the type of the OS account to which the current process belongs. This method uses an asynchronous callback to return the result.
+Obtains the type of the OS account to which the current process belongs. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.OsAccount
@@ -1348,7 +1348,7 @@ Obtains the type of the OS account to which the current process belongs. This me
getOsAccountTypeFromProcess(): Promise<OsAccountType>
-Obtains the type of the OS account to which the current process belongs. This method uses a promise to return the result.
+Obtains the type of the OS account to which the current process belongs. This API uses a promise to return the result asynchronously.
**System capability**: SystemCapability.Account.OsAccount
@@ -1373,7 +1373,7 @@ Obtains the type of the OS account to which the current process belongs. This me
getDistributedVirtualDeviceId(callback: AsyncCallback<string>): void
-Obtains the ID of this distributed virtual device. This method uses an asynchronous callback to return the result.
+Obtains the ID of this distributed virtual device. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC or ohos.permission.MANAGE_LOCAL_ACCOUNTS
@@ -1399,7 +1399,7 @@ Obtains the ID of this distributed virtual device. This method uses an asynchron
getDistributedVirtualDeviceId(): Promise<string>
-Obtains the ID of this distributed virtual device. This method uses a promise to return the result.
+Obtains the ID of this distributed virtual device. This API uses a promise to return the result asynchronously.
**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC or ohos.permission.MANAGE_LOCAL_ACCOUNTS
@@ -1426,7 +1426,7 @@ Obtains the ID of this distributed virtual device. This method uses a promise to
getOsAccountProfilePhoto(localId: number, callback: AsyncCallback<string>): void
-Obtains the profile photo of an OS account. This method uses an asynchronous callback to return the result.
+Obtains the profile photo of an OS account. This API uses an asynchronous callback to return the result.
This is a system API and cannot be called by third-party applications.
@@ -1456,7 +1456,7 @@ This is a system API and cannot be called by third-party applications.
getOsAccountProfilePhoto(localId: number): Promise<string>
-Obtains the profile photo of an OS account. This method uses a promise to return the result.
+Obtains the profile photo of an OS account. This API uses a promise to return the result asynchronously.
This is a system API and cannot be called by third-party applications.
@@ -1492,7 +1492,7 @@ This is a system API and cannot be called by third-party applications.
setOsAccountProfilePhoto(localId: number, photo: string, callback: AsyncCallback<void>): void
-Sets a profile photo for an OS account. This method uses an asynchronous callback to return the result.
+Sets a profile photo for an OS account. This API uses an asynchronous callback to return the result.
This is a system API and cannot be called by third-party applications.
@@ -1526,7 +1526,7 @@ This is a system API and cannot be called by third-party applications.
setOsAccountProfilePhoto(localId: number, photo: string): Promise<void>
-Sets a profile photo for an OS account. This method uses a promise to return the result.
+Sets a profile photo for an OS account. This API uses a promise to return the result asynchronously.
This is a system API and cannot be called by third-party applications.
@@ -1567,7 +1567,7 @@ This is a system API and cannot be called by third-party applications.
getOsAccountLocalIdBySerialNumber(serialNumber: number, callback: AsyncCallback<number>): void
-Obtains the OS account ID based on the SN. This method uses an asynchronous callback to return the result.
+Obtains the OS account ID based on the SN. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.OsAccount
@@ -1593,7 +1593,7 @@ Obtains the OS account ID based on the SN. This method uses an asynchronous call
getOsAccountLocalIdBySerialNumber(serialNumber: number): Promise<number>
-Obtains the OS account ID based on the SN. This method uses a promise to return the result.
+Obtains the OS account ID based on the SN. This API uses a promise to return the result asynchronously.
**System capability**: SystemCapability.Account.OsAccount
@@ -1625,7 +1625,7 @@ Obtains the OS account ID based on the SN. This method uses a promise to return
getSerialNumberByOsAccountLocalId(localId: number, callback: AsyncCallback<number>): void
-Obtains the SN of an OS account based on the account ID. This method uses an asynchronous callback to return the result.
+Obtains the SN of an OS account based on the account ID. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.OsAccount
@@ -1651,7 +1651,7 @@ Obtains the SN of an OS account based on the account ID. This method uses an asy
getSerialNumberByOsAccountLocalId(localId: number): Promise<number>
-Obtains the SN of an OS account based on the account ID. This method uses a promise to return the result.
+Obtains the SN of an OS account based on the account ID. This API uses a promise to return the result asynchronously.
**System capability**: SystemCapability.Account.OsAccount
@@ -1683,7 +1683,7 @@ Obtains the SN of an OS account based on the account ID. This method uses a prom
on(type: 'activate' | 'activating', name: string, callback: Callback<number>): void
-Subscribes to OS account changes. This method uses an asynchronous callback to return the result.
+Subscribes to OS account changes. This API uses an asynchronous callback to return the result.
This is a system API and cannot be called by third-party applications.
@@ -1713,7 +1713,7 @@ This is a system API and cannot be called by third-party applications.
off(type: 'activate' | 'activating', name: string, callback?: Callback<number>): void
-Unsubscribes from the OS account changes. This method uses an asynchronous callback to return the result.
+Unsubscribes from the OS account changes. This API uses an asynchronous callback to return the result.
This is a system API and cannot be called by third-party applications.
@@ -1739,6 +1739,173 @@ This is a system API and cannot be called by third-party applications.
accountManager.off("activating", "osAccountOnOffNameA", offCallback);
```
+### getBundleIdFromUid9+
+
+getBundleIdFromUid(uid: number, callback: AsyncCallback<number>): void;
+
+Obtains the bundle ID based on the UID. This API uses an asynchronous callback to return the result.
+
+This is a system API and cannot be called by third-party applications.
+
+**System capability**: SystemCapability.Account.OsAccount
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | -------------------------- | ---- | ------------------------------------------------------------ |
+| uid | number | Yes | Process UID.|
+| callback | AsyncCallback<number> | Yes | Callback used to return the bundle ID obtained. |
+
+**Example**
+
+ ```js
+ var testUid = 1000000;
+ osAccountManager.getBundleIdFromUid(testUid,(err,bundleId)=>{
+ console.info("getBundleIdFromUid errInfo:" + JSON.stringify(err));
+ console.info("getBundleIdFromUid bundleId:" + JSON.stringify(bundleId));
+ });
+ ```
+### getBundleIdFromUid9+
+
+getBundleIdFromUid(uid: number): Promise<number>;
+
+Obtains the bundle ID based on the UID. This API uses a promise to return the result asynchronously.
+
+This is a system API and cannot be called by third-party applications.
+
+**System capability**: SystemCapability.Account.OsAccount
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ------- | ------ | ---- | ------------ |
+| uid | number | Yes | Process UID.|
+
+**Return Value**
+
+| Type | Description |
+| :-------------------- | :----------------------------------------------------------- |
+| Promise<number> | Promise used to return the bundle ID obtained.|
+
+**Example**
+
+ ```js
+ var testUid = 1000000;
+ var bundleIdInfo = await osAccountManager.getBundleIdFromUid(testUid).catch((err)=>{
+ console.info("getBundleIdFromUid errInfo:" + JSON.stringify(err));})
+ console.info("getBundleIdFromUid bundleId:" + JSON.stringify(bundleIdInfo));
+ ```
+
+### isMainOsAccount9+
+
+isMainOsAccount(callback: AsyncCallback<boolean>): void;
+
+Checks whether the current process belongs to the main OS account. This API uses an asynchronous callback to return the result.
+
+This is a system API and cannot be called by third-party applications.
+
+**System capability**: SystemCapability.Account.OsAccount
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | -------------------------- | ---- | ------------------------------------------------------------ |
+| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. If the current process belongs to the main OS account, **true** will be returned. Otherwise, **false** will be returned. |
+
+**Example**
+
+ ```js
+ osAccountManager.isMainOsAccount((err,result)=>{
+ console.info("isMainOsAccount errInfo:" + JSON.stringify(err));
+ console.info("isMainOsAccount result:" + JSON.stringify(result));
+ });
+ ```
+### isMainOsAccount9+
+
+isMainOsAccount(): Promise<boolean>;
+
+Checks whether the current process belongs to the main OS account. This API uses a promise to return the result asynchronously.
+
+This is a system API and cannot be called by third-party applications.
+
+**System capability**: SystemCapability.Account.OsAccount
+
+**Return Value**
+
+| Type | Description |
+| :-------------------- | :----------------------------------------------------------- |
+| Promise<boolean> | Promise used to return the result. If the current process belongs to the main OS account, **true** will be returned. Otherwise, **false** will be returned.|
+
+**Example**
+
+ ```js
+ var result = await osAccountManager.isMainOsAccount().catch((err)=>{
+ console.info("isMainOsAccount errInfo:" + JSON.stringify(err));
+ });
+ console.info("isMainOsAccount result:" + JSON.stringify(result));
+ ```
+### queryOsAccountConstraintSourceTypes9+
+
+queryOsAccountConstraintSourceTypes(localId: number, constraint: string, callback: AsyncCallback<Array<ConstraintSourceTypeInfo>>): void;
+
+Obtains the constraint source information of an OS account.
+
+This is a system API and cannot be called by third-party applications.
+
+**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
+
+**System capability**: SystemCapability.Account.OsAccount
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | -------------------------- | ---- | ------------------------------------------------------------ |
+| localId | number | Yes | ID of the target OS account.|
+| constraint | string | Yes | Name of the [constraint](#constraints) to query.|
+| callback | AsyncCallback<Array<[ConstraintSourceTypeInfo](#constraintsourcetypeinfo)>> | Yes | Callback used to return the source information about the specified [constraint] (#constraints). |
+
+**Example**
+
+ ```js
+ osAccountManager.queryOsAccountConstraintSourceTypes(100, "constraint.wifi",(err,sourceTypeInfos)=>{
+ console.info("queryOsAccountConstraintSourceType errInfo:" + JSON.stringify(err));
+ console.info("queryOsAccountConstraintSourceType sourceTypeInfos:" + JSON.stringify(sourceTypeInfos));
+ });
+ ```
+
+### queryOsAccountConstraintSourceTypes9+
+
+queryOsAccountConstraintSourceTypes(localId: number, constraint: string): Promise<Array<ConstraintSourceTypeInfo>>;
+
+Obtains the constraint source information of an OS account. This API uses a promise to return the result asynchronously.
+
+This is a system API and cannot be called by third-party applications.
+
+**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
+
+**System capability**: SystemCapability.Account.OsAccount
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ------- | ------ | ---- | ------------ |
+| localId | number | Yes | ID of the target OS account.|
+| constraint | string | Yes | Name of the [constraint](#constraints) to query.|
+
+**Return Value**
+
+| Type | Description |
+| :-------------------- | :----------------------------------------------------------- |
+| Promise<Array<[ConstraintSourceTypeInfo](#constraintsourcetypeinfo)>> | Promise used to return the source information about the specified [constraint] (#constraints).|
+
+**Example**
+
+ ```js
+ var sourceTypeInfos = await osAccountManager.queryOsAccountConstraintSourceTypes(100, "constraint.wifi").catch((err)=>{
+ console.info("queryOsAccountConstraintSourceType errInfo:" + JSON.stringify(err));})
+ console.info("queryOsAccountConstraintSourceType sourceTypeInfos:" + JSON.stringify(sourceTypeInfos));
+ ```
+
## OsAccountInfo
Defines information about an OS account.
@@ -1839,3 +2006,27 @@ Domain account information.
| constraint.screen.timeout.set | A user is not allowed to configure the screen off timeout.|
| constraint.print | A user is not allowed to print.|
| constraint.private.dns.set | A user is not allowed to configure a private domain name server (DNS).|
+
+## ConstraintSourceTypeInfo9+
+
+Defines information about the source of a constraint.
+
+**System capability**: SystemCapability.Account.OsAccount
+
+| Name | Type | Mandatory| Description |
+| ----------- | ------ | ---- | ---------- |
+| localId | number | Yes | ID of the OS account. |
+| type | [ConstraintSourceType](#constraintsourcetype) | Yes | Type of the constrain source.|
+
+## ConstraintSourceType9+
+
+Enumerates the constraint sources.
+
+**System capability**: SystemCapability.Account.OsAccount
+
+| Name | Default Value| Description |
+| ------ | ------ | ------------ |
+| CONSTRAINT_NOT_EXIST | 0 | The constraint does not exist.|
+| CONSTRAINT_TYPE_BASE | 1 | Constraint from system settings. |
+| CONSTRAINT_TYPE_DEVICE_OWNER | 2 | Constraint from the device owners' settings. |
+| CONSTRAINT_TYPE_PROFILE_OWNER | 3 | Constraint from the profile owners' settings. |
diff --git a/en/application-dev/reference/apis/js-apis-particleAbility.md b/en/application-dev/reference/apis/js-apis-particleAbility.md
index 2dd21c5d94a61e84c510f453457a9ef0ace89435..12f2fd80bdd78b13c59b1684f080ac2798a9c436 100644
--- a/en/application-dev/reference/apis/js-apis-particleAbility.md
+++ b/en/application-dev/reference/apis/js-apis-particleAbility.md
@@ -1,7 +1,9 @@
-# ParticleAbility Module
+# ParticleAbility
-> **NOTE**
-> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+> **NOTE**
+>
+> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+> The APIs of this module can be used only in the FA model.
## Constraints
diff --git a/en/application-dev/reference/apis/js-apis-pasteboard.md b/en/application-dev/reference/apis/js-apis-pasteboard.md
index c5ca90fd33c1de4b2eb4f4fff33eee5e2d899a79..cf7fbb1caa02a7c9c8f6b434a227a3275574fa6c 100644
--- a/en/application-dev/reference/apis/js-apis-pasteboard.md
+++ b/en/application-dev/reference/apis/js-apis-pasteboard.md
@@ -1,7 +1,7 @@
# Pasteboard
->  **NOTE** The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+> **NOTE** The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
@@ -48,9 +48,9 @@ Creates a **PasteData** object for plain text.
**Example**
-```js
-var pasteData = pasteboard.createPlainTextData("content");
-```
+ ```js
+ var pasteData = pasteboard.createPlainTextData("content");
+ ```
## pasteboard.createHtmlData7+
@@ -75,10 +75,10 @@ Creates a **PasteData** object for HTML text.
**Example**
-```js
-var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "
\n" + " \n" + "\n" + "";
+ var htmlRecord = pasteboard.createHtmlTextRecord(html);
+ pasteData.addRecord(textRecord);
+ pasteData.addRecord(htmlRecord);
+ ```
### getMimeTypes7+
@@ -588,10 +588,10 @@ Obtains **mimeTypes** in [PasteDataProperty](#pastedataproperty7) from this past
**Example**
-```js
-var pasteData = pasteboard.createPlainTextData("hello");
-var types = pasteData.getMimeTypes();
-```
+ ```js
+ var pasteData = pasteboard.createPlainTextData("hello");
+ var types = pasteData.getMimeTypes();
+ ```
### getPrimaryMimeType7+
@@ -610,10 +610,10 @@ Obtains the data type of the primary record.
**Example**
-```js
-var pasteData = pasteboard.createPlainTextData("hello");
-var type = pasteData.getPrimaryMimeType();
-```
+ ```js
+ var pasteData = pasteboard.createPlainTextData("hello");
+ var type = pasteData.getPrimaryMimeType();
+ ```
### getProperty7+
@@ -632,10 +632,10 @@ Obtains the property description object.
**Example**
-```js
-var pasteData = pasteboard.createPlainTextData("hello");
-var property = pasteData.getProperty();
-```
+ ```js
+ var pasteData = pasteboard.createPlainTextData("hello");
+ var property = pasteData.getProperty();
+ ```
### getRecordAt7+
@@ -660,10 +660,10 @@ Obtains the record with the specified index.
**Example**
-```js
-var pasteData = pasteboard.createPlainTextData("hello");
-var record = pasteData.getRecordAt(0);
-```
+ ```js
+ var pasteData = pasteboard.createPlainTextData("hello");
+ var record = pasteData.getRecordAt(0);
+ ```
### getRecordCount7+
@@ -682,10 +682,10 @@ Obtains the number of data records in this pasteboard.
**Example**
-```js
-var pasteData = pasteboard.createPlainTextData("hello");
-var count = pasteData.getRecordCount();
-```
+ ```js
+ var pasteData = pasteboard.createPlainTextData("hello");
+ var count = pasteData.getRecordCount();
+ ```
### getTag7+
@@ -704,10 +704,10 @@ Obtains the user-defined tag content. If the tag content is not set, null is ret
**Example**
-```js
-var pasteData = pasteboard.createPlainTextData("hello");
-var tag = pasteData.getTag();
-```
+ ```js
+ var pasteData = pasteboard.createPlainTextData("hello");
+ var tag = pasteData.getTag();
+ ```
### hasMimeType7+
@@ -732,10 +732,10 @@ Checks whether the content of this pasteboard contains the specified data type.
**Example**
-```js
-var pasteData = pasteboard.createPlainTextData("hello");
-var hasType = pasteData.hasMimeType(pasteboard.MIMETYPE_TEXT_PLAIN);
-```
+ ```js
+ var pasteData = pasteboard.createPlainTextData("hello");
+ var hasType = pasteData.hasMimeType(pasteboard.MIMETYPE_TEXT_PLAIN);
+ ```
### removeRecordAt7+
@@ -760,10 +760,10 @@ Removes the data record with a specified index from this pasteboard.
**Example**
-```js
-var pasteData = pasteboard.createPlainTextData("hello");
-var isRemove = pasteData.removeRecordAt(0);
-```
+ ```js
+ var pasteData = pasteboard.createPlainTextData("hello");
+ var isRemove = pasteData.removeRecordAt(0);
+ ```
### replaceRecordAt7+
@@ -789,11 +789,11 @@ Replaces the data record with a specified index in this pasteboard.
**Example**
-```js
-var pasteData = pasteboard.createPlainTextData("hello");
-var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt");
-var isReplace = pasteData.replaceRecordAt(0, record);
-```
+ ```js
+ var pasteData = pasteboard.createPlainTextData("hello");
+ var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt");
+ var isReplace = pasteData.replaceRecordAt(0, record);
+ ```
## pasteboard.getSystemPasteboard
@@ -812,9 +812,9 @@ Obtains the system pasteboard.
**Example**
-```js
-var systemPasteboard = pasteboard.getSystemPasteboard();
-```
+ ```js
+ var systemPasteboard = pasteboard.getSystemPasteboard();
+ ```
## SystemPasteboard
@@ -843,17 +843,17 @@ Writes data to a pasteboard. This API uses an asynchronous callback to return th
**Example**
-```js
-var pasteData = pasteboard.createPlainTextData("content");
-var systemPasteboard = pasteboard.getSystemPasteboard();
-systemPasteboard.setPasteData(pasteData, (error, data) => {
- if (error) {
- console.error('Failed to setPasteData. Cause: ' + error.message);
- return;
- }
- console.info('setPasteData successfully.');
-});
-```
+ ```js
+ var pasteData = pasteboard.createPlainTextData("content");
+ var systemPasteboard = pasteboard.getSystemPasteboard();
+ systemPasteboard.setPasteData(pasteData, (error, data) => {
+ if (error) {
+ console.error('Failed to setPasteData. Cause: ' + error.message);
+ return;
+ }
+ console.info('setPasteData successfully.');
+ });
+ ```
### setPasteData
@@ -878,15 +878,15 @@ Writes data to a pasteboard. This API uses a promise to return the result.
**Example**
-```js
-var pasteData = pasteboard.createPlainTextData("content");
-var systemPasteboard = pasteboard.getSystemPasteboard();
-systemPasteboard.setPasteData(pasteData).then((data) => {
- console.info('setPasteData success.');
-}).catch((error) => {
- console.error('Failed to setPasteData. Cause: ' + error.message);
-});
-```
+ ```js
+ var pasteData = pasteboard.createPlainTextData("content");
+ var systemPasteboard = pasteboard.getSystemPasteboard();
+ systemPasteboard.setPasteData(pasteData).then((data) => {
+ console.info('setPasteData success.');
+ }).catch((error) => {
+ console.error('Failed to setPasteData. Cause: ' + error.message);
+ });
+ ```
### getPasteData
@@ -905,16 +905,16 @@ Reads the system pasteboard content. This API uses an asynchronous callback to r
**Example**
-```js
-var systemPasteboard = pasteboard.getSystemPasteboard();
-systemPasteboard.getPasteData((error, pasteData) => {
- if (error) {
- console.error('Failed to getPasteData. Cause: ' + error.message);
- return;
- }
- var text = pasteData.getPrimaryText();
-});
-```
+ ```js
+ var systemPasteboard = pasteboard.getSystemPasteboard();
+ systemPasteboard.getPasteData((error, pasteData) => {
+ if (error) {
+ console.error('Failed to getPasteData. Cause: ' + error.message);
+ return;
+ }
+ var text = pasteData.getPrimaryText();
+ });
+ ```
### getPasteData
@@ -933,14 +933,14 @@ Reads the system pasteboard content. This API uses a promise to return the resul
**Example**
-```js
-var systemPasteboard = pasteboard.getSystemPasteboard();
-systemPasteboard.getPasteData().then((pasteData) => {
- var text = pasteData.getPrimaryText();
-}).catch((error) => {
- console.error('Failed to getPasteData. Cause: ' + error.message);
-})
-```
+ ```js
+ var systemPasteboard = pasteboard.getSystemPasteboard();
+ systemPasteboard.getPasteData().then((pasteData) => {
+ var text = pasteData.getPrimaryText();
+ }).catch((error) => {
+ console.error('Failed to getPasteData. Cause: ' + error.message);
+ })
+ ```
### on('update')7+
@@ -960,18 +960,18 @@ Subscribes to the content change event of the system pasteboard. If the pasteboa
**Example**
-```js
-var systemPasteboard = pasteboard.getSystemPasteboard();
-var listener = ()=>{
- console.info('The system pasteboard has changed');
-};
-systemPasteboard.on('update', listener);
-```
+ ```js
+ var systemPasteboard = pasteboard.getSystemPasteboard();
+ var listener = () => {
+ console.info('The system pasteboard has changed');
+ };
+ systemPasteboard.on('update', listener);
+ ```
### off('update')7+
-off(type: 'update', callback? : () =>void ): void
+off(type: 'update', callback?: () =>void ): void
Unsubscribes from the system pasteboard content change event.
@@ -986,9 +986,12 @@ Unsubscribes from the system pasteboard content change event.
**Example**
-```js
-systemPasteboard.off('update', listener);
-```
+ ```js
+ let listener = () => {
+ console.info('The system pasteboard has changed');
+ };
+ systemPasteboard.off('update', listener);
+ ```
### hasPasteData7+
@@ -1007,15 +1010,15 @@ Checks whether the system pasteboard contains content. This API uses an asynchro
**Example**
-```js
-systemPasteboard.hasPasteData((err, data) => {
- if (err) {
- console.error('failed to hasPasteData because ' + JSON.stringify(err));
- return;
- }
- console.info('success hasPasteData : ' + JSON.stringify(data));
-});
-```
+ ```js
+ systemPasteboard.hasPasteData((err, data) => {
+ if (err) {
+ console.error('failed to hasPasteData because ' + JSON.stringify(err));
+ return;
+ }
+ console.info('success hasPasteData : ' + JSON.stringify(data));
+ });
+ ```
### hasPasteData7+
@@ -1059,15 +1062,15 @@ Clears the system pasteboard content. This API uses an asynchronous callback to
**Example**
-```js
-systemPasteboard.clear((err, data) => {
- if (err) {
- console.error('failed to clear because ' + JSON.stringify(err));
- return;
- }
- console.info('success clear');
-});
-```
+ ```js
+ systemPasteboard.clear((err, data) => {
+ if (err) {
+ console.error('failed to clear because ' + JSON.stringify(err));
+ return;
+ }
+ console.info('success clear');
+ });
+ ```
### clear7+
@@ -1086,10 +1089,10 @@ Clears the system pasteboard content. This API uses a promise to return the resu
**Example**
-```js
-systemPasteboard.clear().then((data) => {
- console.info('success clear');
-}).catch((error) => {
- console.error('failed to clear because ' + JSON.stringify(error));
-});
-```
\ No newline at end of file
+ ```js
+ systemPasteboard.clear().then((data) => {
+ console.info('success clear');
+ }).catch((error) => {
+ console.error('failed to clear because ' + JSON.stringify(error));
+ });
+ ```
diff --git a/en/application-dev/reference/apis/js-apis-permissionrequestresult.md b/en/application-dev/reference/apis/js-apis-permissionrequestresult.md
index de7be38f0c910c202f90c0eb76396e18f4f5fd7e..f0d3ed2f0ce6e5e84883f38b7d9441b74dae5ae4 100644
--- a/en/application-dev/reference/apis/js-apis-permissionrequestresult.md
+++ b/en/application-dev/reference/apis/js-apis-permissionrequestresult.md
@@ -1,7 +1,9 @@
# PermissionRequestResult
-> **NOTE**
+> **NOTE**
+>
> The initial APIs of this module are supported since API 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+> The APIs of this module can be used only in the stage model.
Provides the permission request result.
diff --git a/en/application-dev/reference/apis/js-apis-plainarray.md b/en/application-dev/reference/apis/js-apis-plainarray.md
index 3f0475a9dccbf4efb61836c7fa735174bb060d1e..237dfe4234e2eb9049e419bfe94d051c2aab893e 100644
--- a/en/application-dev/reference/apis/js-apis-plainarray.md
+++ b/en/application-dev/reference/apis/js-apis-plainarray.md
@@ -1,27 +1,34 @@
# Nonlinear Container PlainArray
->  **NOTE**
+> **NOTE**
+>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+**PlainArray** stores key-value (KV) pairs. Each key must be unique, be of the number type, and have only one value.
+
+**PlainArray** is based on generics and uses a lightweight structure. Keys in the array are searched using binary search, which map to values in other arrays.
+
+Both **PlainArray** and **[LightWeightMap](js-apis-lightweightmap.md)** are used to store KV pairs in the lightweight structure. However, the key type of **PlainArray** can only be **number**.
+
+**Recommended use case**: Use **PlainArray** when you need to store KV pairs whose keys are of the **number** type.
## Modules to Import
```ts
-import PlainArray from '@ohos.util.PlainArray'
+import PlainArray from '@ohos.util.PlainArray';
```
-## System Capability
-SystemCapability.Utils.Lang
## PlainArray
-
### Attributes
+**System capability**: SystemCapability.Utils.Lang
+
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| length | number | Yes| No| Number of entries in a plain array (called container later).|
+| length | number | Yes| No| Number of elements in a plain array (called container later).|
### constructor
@@ -30,6 +37,8 @@ constructor()
A constructor used to create a **PlainArray** instance.
+**System capability**: SystemCapability.Utils.Lang
+
**Example**
```ts
@@ -43,6 +52,8 @@ isEmpty(): boolean
Checks whether this container is empty.
+**System capability**: SystemCapability.Utils.Lang
+
**Return value**
| Type| Description|
@@ -63,11 +74,13 @@ has(key: number): boolean
Checks whether this container contains the specified key.
+**System capability**: SystemCapability.Utils.Lang
+
**Parameters**
| Name| Type | Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| key | number | Yes| Key to check.|
+| key | number | Yes| Target key.|
**Return value**
@@ -91,11 +104,13 @@ get(key: number): T
Obtains the value of the specified key in this container.
+**System capability**: SystemCapability.Utils.Lang
+
**Parameters**
| Name| Type | Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| key | number | Yes| Key to query.|
+| key | number | Yes| Target key.|
**Return value**
@@ -117,19 +132,21 @@ let result = plainArray.get(1);
getIndexOfKey(key: number): number
-Obtains the index of the first occurrence of an entry with the specified key in this container.
+Obtains the index of the first occurrence of an element with the specified key in this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type | Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| key | number | Yes| Key of the entry to obtain.|
+| key | number | Yes| Target key.|
**Return value**
| Type| Description|
| -------- | -------- |
-| number | Returns the position index if obtained; returns **-1** if the specified entry is not found.|
+| number | Returns the position index if obtained; returns **-1** otherwise.|
**Example**
@@ -137,7 +154,7 @@ Obtains the index of the first occurrence of an entry with the specified key in
let plainArray = new PlainArray();
plainArray.add(1, "sddfhf");
plainArray.add(2, "sffdfhf");
-let result = plainArray.getIndexOfKey("sdfs");
+let result = plainArray.getIndexOfKey(2);
```
@@ -145,19 +162,21 @@ let result = plainArray.getIndexOfKey("sdfs");
getIndexOfValue(value: T): number
-Obtains the index of the first occurrence of an entry with the specified value in this container.
+Obtains the index of the first occurrence of an element with the specified value in this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type | Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| value | T | Yes| Value of the entry to obtain.|
+| value | T | Yes| Value of the target element.|
**Return value**
| Type| Description|
| -------- | -------- |
-| number | Returns the position index if obtained; returns **-1** if the specified entry is not found.|
+| number | Returns the position index if obtained; returns **-1** otherwise.|
**Example**
@@ -173,19 +192,21 @@ let result = plainArray.getIndexOfValue("sddfhf");
getKeyAt(index: number): number
-Obtains the key of the entry at the specified position in this container.
+Obtains the key of the element at the specified position in this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type | Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| index | number | Yes| Position index of the entry to obtain.|
+| index | number | Yes| Position index of the target element.|
**Return value**
| Type| Description|
| -------- | -------- |
-| number | Returns the key of the entry if obtained; returns **-1** otherwise.|
+| number | Returns the key of the element if obtained; returns **-1** otherwise.|
**Example**
@@ -200,19 +221,21 @@ let result = plainArray.getKeyAt(1);
getValueAt(index: number): T
-Obtains the value of an entry at the specified position in this container.
+Obtains the value of an element at the specified position in this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
- | Name| Type | Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | index | number | Yes| Position index of the entry to obtain.|
+| Name| Type | Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| index | number | Yes| Position index of the target element.|
**Return value**
- | Type| Description|
- | -------- | -------- |
- | T | Returns the value of the entry if obtained; returns **undefined** otherwise.|
+| Type| Description|
+| -------- | -------- |
+| T | Returns the value of the element if obtained; returns **undefined** otherwise.|
**Example**
@@ -229,6 +252,8 @@ clone(): PlainArray<T>
Clones this container and returns a copy. The modification to the copy does not affect the original instance.
+**System capability**: SystemCapability.Utils.Lang
+
**Return value**
| Type| Description|
@@ -249,14 +274,16 @@ let newPlainArray = plainArray.clone();
add(key: number, value: T): void
-Adds an entry to this container.
+Adds an element to this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type | Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| key | number | Yes| Key of the entry to add.|
-| value | T | Yes| Value of the entry to add.|
+| key | number | Yes| Key of the target element.|
+| value | T | Yes| Value of the target element.|
**Example**
@@ -270,19 +297,21 @@ plainArray.add(1, "sddfhf");
remove(key: number): T
-Removes an entry with the specified key from this container.
+Removes an element with the specified key from this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type | Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| key | number | Yes| Key of the entry to remove.|
+| key | number | Yes| Target key.|
**Return value**
| Type| Description|
| -------- | -------- |
-| T | Value of the entry removed.|
+| T | Value of the element removed.|
**Example**
@@ -299,19 +328,21 @@ let result = plainArray.remove(2);
removeAt(index: number): T
-Removes an entry at the specified position from this container.
+Removes an element at the specified position from this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type | Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| index | number | Yes| Position index of the entry to remove.|
+| index | number | Yes| Position index of the target element.|
**Return value**
| Type| Description|
| -------- | -------- |
-| T | Entry removed.|
+| T | Element removed.|
**Example**
@@ -328,20 +359,22 @@ let result = plainArray.removeAt(1);
removeRangeFrom(index: number, size: number): number
-Removes entries in a specified range from this container.
+Removes elements in a specified range from this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type | Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| index | number | Yes| Start position of the entries to remove.|
-| size | number | Yes| Number of entries to remove.|
+| index | number | Yes| Start position of the elements to remove.|
+| size | number | Yes| Number of elements to remove.|
**Return value**
| Type| Description|
| -------- | -------- |
-| number | Number of entries removed.|
+| number | Number of elements removed.|
**Example**
@@ -357,14 +390,16 @@ let result = plainArray.removeRangeFrom(1, 3);
setValueAt(index: number, value: T): void
-Sets a value for an entry at the specified position in this container.
+Sets a value for an element at the specified position in this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type | Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| index | number | Yes| Position index of the entry.|
-| value | T | Yes| Value of the entry to set.|
+| index | number | Yes| Position index of the target element.|
+| value | T | Yes| Value of the target element.|
**Example**
@@ -380,7 +415,9 @@ plainArray.setValueAt(1, 3546);
toString(): String
-Obtains a string that contains all entries in this container.
+Obtains a string that contains all elements in this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Return value**
@@ -404,6 +441,8 @@ clear(): void
Clears this container and sets its length to **0**.
+**System capability**: SystemCapability.Utils.Lang
+
**Example**
```ts
@@ -418,20 +457,22 @@ plainArray.clear();
forEach(callbackfn: (value: T, index?: number, PlainArray?: PlainArray<T>) => void, thisArg?: Object): void
-Uses a callback to traverse the entries in this container and obtain their position indexes.
+Uses a callback to traverse the elements in this container and obtain their position indexes.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type | Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| callbackfn | function | Yes| Callback invoked to traverse the entries in the container.|
+| callbackfn | function | Yes| Callback invoked to traverse the elements in the container.|
| thisArg | Object | No| Value to use when the callback is invoked.|
callbackfn
| Name| Type | Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| value | T | Yes| Value of the entry that is currently traversed.|
-| index | number | No| Key of the entry that is currently traversed.|
+| value | T | Yes| Value of the element that is currently traversed.|
+| index | number | No| Key of the element that is currently traversed.|
| PlainArray | PlainArray<T>| No| Instance that invokes the **forEach** API.|
**Example**
@@ -440,8 +481,8 @@ callbackfn
let plainArray = new PlainArray();
plainArray.add(1, "sddfhf");
plainArray.add(2, "sffdfhf");
-plainArray.forEach((value, key) => {
- console.log(value, key);
+plainArray.forEach((value, index) => {
+ console.log("value:" + value, index);
});
```
@@ -452,6 +493,8 @@ plainArray.forEach((value, key) => {
Obtains an iterator, each item of which is a JavaScript object.
+**System capability**: SystemCapability.Utils.Lang
+
**Return value**
| Type| Description|
@@ -467,16 +510,16 @@ plainArray.add(2, "sffdfhf");
// Method 1:
for (let item of plainArray) {
- console.log("index: " + item[0]);
- console.log("value: " + item[1]);
+ console.log("index:" + item[0]);
+ console.log("value:" + item[1]);
}
// Method 2:
let iter = plainArray[Symbol.iterator]();
let temp = iter.next().value;
while(temp != undefined) {
- console.log(temp[0]);
- console.log(temp[1]);
+ console.log("index:" + temp[0]);
+ console.log("value:" + temp[1]);
temp = iter.next().value;
}
```
diff --git a/en/application-dev/reference/apis/js-apis-process.md b/en/application-dev/reference/apis/js-apis-process.md
index e8f5549c0edbefd8d5a5b3645a57e7955753bf20..e73c4fe303ebeaac19274d5214085fb8646fa651 100755
--- a/en/application-dev/reference/apis/js-apis-process.md
+++ b/en/application-dev/reference/apis/js-apis-process.md
@@ -232,7 +232,7 @@ Checks whether this process is running in a 64-bit environment.
**Example**
```js
-var ressult = process.is64Bit();
+var result = process.is64Bit();
```
diff --git a/en/application-dev/reference/apis/js-apis-processrunninginfo.md b/en/application-dev/reference/apis/js-apis-processrunninginfo.md
index 63f61d7472be78055c0c4612aa154b2f9eb4c922..24fb9f15a5427a450ea907bb296c43f3d3f55a91 100644
--- a/en/application-dev/reference/apis/js-apis-processrunninginfo.md
+++ b/en/application-dev/reference/apis/js-apis-processrunninginfo.md
@@ -1,9 +1,9 @@
# ProcessRunningInfo
-> **NOTE**
+> **NOTE**
+>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
-
Provides process running information.
## Modules to Import
@@ -14,11 +14,8 @@ import appManager from '@ohos.application.appManager'
## Usage
-
The process running information is obtained through an **appManager** instance.
-
-
```js
import appManager from '@ohos.application.appManager';
appManager.getProcessRunningInfos((error,data) => {
diff --git a/en/application-dev/reference/apis/js-apis-prompt.md b/en/application-dev/reference/apis/js-apis-prompt.md
index 3b4523f4f2e3d85ba3f53cf41ce4aa719d777526..3facc0146ebe2484672cffb3c9a45d0ac7d9f164 100644
--- a/en/application-dev/reference/apis/js-apis-prompt.md
+++ b/en/application-dev/reference/apis/js-apis-prompt.md
@@ -1,6 +1,6 @@
# Prompt
->  **NOTE**
+> **NOTE**
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
@@ -208,7 +208,7 @@ Shows an action menu. This API uses a callback to return the result asynchronous
## prompt.showActionMenu
-showActionMenu(options: ActionMenuOptions): Promise
+showActionMenu(options: ActionMenuOptions): Promise\
Shows an action menu. This API uses a promise to return the result synchronously.
diff --git a/en/application-dev/reference/apis/js-apis-queue.md b/en/application-dev/reference/apis/js-apis-queue.md
index ff80fc9e5e8dc3acfe5dbe12c3041a44f5d8e57b..a31a72649d0e0ede56771f3fa6c9bf4d25bbefe7 100644
--- a/en/application-dev/reference/apis/js-apis-queue.md
+++ b/en/application-dev/reference/apis/js-apis-queue.md
@@ -1,28 +1,31 @@
# Linear Container Queue
->  **NOTE**
+> **NOTE**
+>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+**Queue** follows the principle of First In First Out (FIFO). It supports insertion of elements at the end and removal from the front of the queue. **Queue** is implemented based on the queue data structure.
+
+Unlike **[Deque](js-apis-deque.md)**, which supports insertion and removal at both the ends, **Queue** supports insertion at one end and removal at the other end.
+
+**Recommended use case**: Use **Queue** in FIFO scenarios.
## Modules to Import
```ts
-import Queue from '@ohos.util.Queue'
+import Queue from '@ohos.util.Queue';
```
-## System Capabilities
-
-SystemCapability.Utils.Lang
-
## Queue
-
### Attributes
+**System capability**: SystemCapability.Utils.Lang
+
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| length | number | Yes| No| Number of entries in a queue (called container later).|
+| length | number | Yes| No| Number of elements in a queue (called container later).|
### constructor
@@ -31,6 +34,8 @@ constructor()
A constructor used to create a **Queue** instance.
+**System capability**: SystemCapability.Utils.Lang
+
**Example**
```ts
@@ -42,19 +47,21 @@ let queue = new Queue();
add(element: T): boolean
-Adds an entry at the end of this container.
+Adds an element at the end of this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| element | T | Yes| Entry to add.|
+| element | T | Yes| Target element.|
**Return value**
| Type| Description|
| -------- | -------- |
-| boolean | Returns **true** if the entry is added successfully; returns **false** otherwise.|
+| boolean | Returns **true** if the element is added successfully; returns **false** otherwise.|
**Example**
@@ -73,13 +80,15 @@ let result3 = queue.add(c);
pop(): T
-Removes the first entry from this container.
+Removes the first element from this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Return value**
| Type| Description|
| -------- | -------- |
-| T | Entry removed.|
+| T | Element removed.|
**Example**
@@ -97,13 +106,15 @@ let result = queue.pop();
getFirst(): T
-Obtains the first entry of this container.
+Obtains the first element of this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Type| Description|
| -------- | -------- |
-| T | The first entry obtained.|
+| T | The first element obtained.|
**Example**
@@ -121,21 +132,23 @@ let result = queue.getFirst();
forEach(callbackfn: (value: T, index?: number, Queue?: Queue<T>) => void,
thisArg?: Object): void
-Uses a callback to traverse the entries in this container and obtain their position indexes.
+Uses a callback to traverse the elements in this container and obtain their position indexes.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| callbackfn | function | Yes| Callback invoked to traverse the entries in the container.|
+| callbackfn | function | Yes| Callback invoked to traverse the elements in the container.|
| thisArg | Object | No| Value to use when the callback is invoked.|
callbackfn
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| value | T | Yes| Value of the entry that is currently traversed.|
-| index | number | No| Position index of the entry that is currently traversed.|
+| value | T | Yes| Value of the element that is currently traversed.|
+| index | number | No| Position index of the element that is currently traversed.|
| Queue | Queue<T> | No| Instance that invokes the **forEach** method.|
**Example**
@@ -147,7 +160,7 @@ queue.add(4);
queue.add(5);
queue.add(4);
queue.forEach((value, index) => {
- console.log(value, index);
+ console.log("value:" + value, index);
});
```
@@ -156,14 +169,15 @@ queue.forEach((value, index) => {
[Symbol.iterator]\(): IterableIterator<T>
-
Obtains an iterator, each item of which is a JavaScript object.
+**System capability**: SystemCapability.Utils.Lang
+
**Return value**
-| Type | Description |
+| Type| Description|
| -------- | -------- |
-| IterableIterator<T> | Iterator obtained. |
+| IterableIterator<T> | Iterator obtained.|
**Example**
```ts
@@ -175,14 +189,14 @@ queue.add(4);
// Method 1:
for (let item of queue) {
- console.log(item);
+ console.log("value:" + item);
}
// Method 2:
let iter = queue[Symbol.iterator]();
let temp = iter.next().value;
while(temp != undefined) {
- console.log(temp);
+ console.log("value:" + temp);
temp = iter.next().value;
}
```
diff --git a/en/application-dev/reference/apis/js-apis-radio.md b/en/application-dev/reference/apis/js-apis-radio.md
index 4df1f4e33d37e28fc1ea83d7fde57d32c21df143..86d29eebedf8fb206589a7770a92362a79873c69 100644
--- a/en/application-dev/reference/apis/js-apis-radio.md
+++ b/en/application-dev/reference/apis/js-apis-radio.md
@@ -408,7 +408,7 @@ Checks whether the current device supports 5G \(NR\).
```js
let slotId = 0;
let result = radio.isNrSupported(slotId);
-console.log(result);
+console.log("Result: "+ result);
```
diff --git a/en/application-dev/reference/apis/js-apis-request.md b/en/application-dev/reference/apis/js-apis-request.md
index fec9be3f8e6b9e7cf42f741f357710c99650c2c3..98ff862ea6932d76bed8ba8a8de4a9b452e54a11 100644
--- a/en/application-dev/reference/apis/js-apis-request.md
+++ b/en/application-dev/reference/apis/js-apis-request.md
@@ -7,7 +7,7 @@
## Modules to Import
-```
+```js
import request from '@ohos.request';
```
@@ -84,8 +84,10 @@ Uploads files. This API uses a promise to return the result.
```js
let file1 = { filename: "test", name: "test", uri: "internal://cache/test.jpg", type: "jpg" };
+ let data = { name: "name123", value: "123" };
+ let header = { key1: "value1", key2: "value2" };
let uploadTask;
- request.upload({ url: 'https://patch', files: [file1] }).then((data) => {
+ request.upload({ url: 'https://patch', header: header, method: "POST", files: [file1], data: [data] }).then((data) => {
uploadTask = data;
}).catch((err) => {
console.error('Failed to request the upload. Cause: ' + JSON.stringify(err));
@@ -114,8 +116,10 @@ Uploads files. This API uses an asynchronous callback to return the result.
```js
let file1 = { filename: "test", name: "test", uri: "internal://cache/test.jpg", type: "jpg" };
+ let data = { name: "name123", value: "123" };
+ let header = { key1: "value1", key2: "value2" };
let uploadTask;
- request.upload({ url: 'https://patch', files: [file1] }, (err, data) => {
+ request.upload({ url: 'https://patch', header: header, method: "POST", files: [file1], data: [data] }, (err, data) => {
if (err) {
console.error('Failed to request the upload. Cause: ' + JSON.stringify(err));
return;
@@ -335,10 +339,10 @@ Removes this upload task. This API uses an asynchronous callback to return the r
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| url | string | Yes | Resource URL. |
-| header | object | No | HTTP or HTTPS header added to an upload request. |
-| method | string | No | Request methods available: **POST** and **PUT**. The default value is **POST**. |
+| header | object | Yes | HTTP or HTTPS header added to an upload request. |
+| method | string | Yes | Request methods available: **POST** and **PUT**. The default value is **POST**. |
| files | Array<[File](#file)> | Yes | List of files to upload, which is submitted through **multipart/form-data**. |
-| data | Array<[RequestData](#requestdata)> | No | Form data in the request body. |
+| data | Array<[RequestData](#requestdata)> | Yes | Form data in the request body. |
## File
@@ -349,7 +353,7 @@ Removes this upload task. This API uses an asynchronous callback to return the r
| -------- | -------- | -------- | -------- |
| filename | string | No | File name in the header when **multipart** is used. |
| name | string | No | Name of a form item when **multipart** is used. The default value is **file**. |
-| uri | string | Yes | Local path for storing files. The **dataability** and **internal** protocol types are supported. However, the **internal** protocol type supports only temporary directories. The following is an example: dataability:///com.domainname.dataability.persondata/person/10/file.txt internal://cache/path/to/file.txt |
+| uri | string | Yes | Local path for storing files. The **dataability** and **internal** protocol types are supported. However, the **internal** protocol type supports only temporary directories. Below are examples: dataability:///com.domainname.dataability.persondata/person/10/file.txt internal://cache/path/to/file.txt |
| type | string | No | Type of the file content. By default, the type is obtained based on the extension of the file name or URI. |
diff --git a/en/application-dev/reference/apis/js-apis-resource-manager.md b/en/application-dev/reference/apis/js-apis-resource-manager.md
index 2effb8b20a713c2c1f9a27baa8c12cabdcd37cda..335e31cdb21bacd975db26b726f503c0a44e431d 100644
--- a/en/application-dev/reference/apis/js-apis-resource-manager.md
+++ b/en/application-dev/reference/apis/js-apis-resource-manager.md
@@ -2,7 +2,7 @@
The resource management module provides APIs to obtain information about the current device configuration (including the language, region, screen direction, and MCC/MNC) and device capability (including the device type and resolution).
->  **NOTE**
+> **NOTE**
> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
@@ -12,31 +12,41 @@ The resource management module provides APIs to obtain information about the cur
import resourceManager from '@ohos.resourceManager';
```
+## Usage
+
+Since API version 9, the stage model allows an application to obtain a **ResourceManager** object based on **context** and call its APIs without first importing the required bundle. This method, however, is not applicable to the FA model.
+
+```
+this.context.resourceManager;
+```
+
## resourceManager.getResourceManager
getResourceManager(callback: AsyncCallback<ResourceManager>): void
-Obtains the **ResourceManager** object of this application. This API uses a callback to return the result.
+Obtains the **ResourceManager** object of this application. This API uses an asynchronous callback to return the result.
+
+This API is used only in the FA model.
**System capability**: SystemCapability.Global.ResourceManager
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ----------------------------- |
-| callback | AsyncCallback<[ResourceManager](#resourcemanager)> | Yes | Asynchronous callback used to return the **ResourceManager** object obtained.|
+| callback | AsyncCallback<[ResourceManager](#resourcemanager)> | Yes | Asynchronous callback used to return the result.|
**Example**
```
resourceManager.getResourceManager((error, mgr) => {
if (error != null) {
- console.log("error occurs" + error);
+ console.log("error is " + error);
return;
}
mgr.getString(0x1000000, (error, value) => {
if (error != null) {
- console.log(value);
+ console.log("error is " + error);
} else {
- console.log(value);
+ let str = value;
}
});
});
@@ -47,7 +57,9 @@ Obtains the **ResourceManager** object of this application. This API uses a call
getResourceManager(bundleName: string, callback: AsyncCallback<ResourceManager>): void
-Obtains the **ResourceManager** object of an application. This API uses an asynchronous callback to return the result.
+Obtains the **ResourceManager** object of an application based on the specified bundle name. This API uses an asynchronous callback to return the result.
+
+This API is used only in the FA model.
**System capability**: SystemCapability.Global.ResourceManager
@@ -55,7 +67,7 @@ Obtains the **ResourceManager** object of an application. This API uses an async
| Name | Type | Mandatory | Description |
| ---------- | ---------------------------------------- | ---- | ----------------------------- |
| bundleName | string | Yes | Bundle name of the target application. |
-| callback | AsyncCallback<[ResourceManager](#resourcemanager)> | Yes | Asynchronous callback used to return the **ResourceManager** object obtained.|
+| callback | AsyncCallback<[ResourceManager](#resourcemanager)> | Yes | Asynchronous callback used to return the result.|
**Example**
```
@@ -70,25 +82,27 @@ getResourceManager(): Promise<ResourceManager>
Obtains the **ResourceManager** object of this application. This API uses a promise to return the result.
+This API is used only in the FA model.
+
**System capability**: SystemCapability.Global.ResourceManager
**Return value**
| Type | Description |
| ---------------------------------------- | ----------------- |
-| Promise<[ResourceManager](#resourcemanager)> | Promise used to return the **ResourceManager** object obtained.|
+| Promise<[ResourceManager](#resourcemanager)> | Promise used to return the result.|
**Example**
```
resourceManager.getResourceManager().then(mgr => {
mgr.getString(0x1000000, (error, value) => {
if (error != null) {
- console.log(value);
+ console.log("error is " + error);
} else {
- console.log(value);
+ let str = value;
}
});
}).catch(error => {
- console.log(error);
+ console.log("error is " + error);
});
```
@@ -97,7 +111,9 @@ Obtains the **ResourceManager** object of this application. This API uses a prom
getResourceManager(bundleName: string): Promise<ResourceManager>
-Obtains the **ResourceManager** object of an application. This API uses a promise to return the result.
+Obtains the **ResourceManager** object of an application based on the specified bundle name. This API uses a promise to return the result.
+
+This API is used only in the FA model.
**System capability**: SystemCapability.Global.ResourceManager
@@ -109,7 +125,7 @@ Obtains the **ResourceManager** object of an application. This API uses a promis
**Return value**
| Type | Description |
| ---------------------------------------- | ------------------ |
-| Promise<[ResourceManager](#resourcemanager)> | Promise used to return the **ResourceManager** object obtained.|
+| Promise<[ResourceManager](#resourcemanager)> | Promise used to return the result.|
**Example**
```
@@ -129,8 +145,8 @@ Enumerates the screen directions.
| Name | Default Value | Description |
| -------------------- | ---- | ---- |
-| DIRECTION_VERTICAL | 0 | Portrait |
-| DIRECTION_HORIZONTAL | 1 | Landscape |
+| DIRECTION_VERTICAL | 0 | Portrait. |
+| DIRECTION_HORIZONTAL | 1 | Landscape. |
## DeviceType
@@ -141,12 +157,12 @@ Enumerates the device types.
| Name | Default Value | Description |
| -------------------- | ---- | ---- |
-| DEVICE_TYPE_PHONE | 0x00 | Phone |
-| DEVICE_TYPE_TABLET | 0x01 | Tablet |
-| DEVICE_TYPE_CAR | 0x02 | Head unit |
-| DEVICE_TYPE_PC | 0x03 | PC |
-| DEVICE_TYPE_TV | 0x04 | TV |
-| DEVICE_TYPE_WEARABLE | 0x06 | Wearable |
+| DEVICE_TYPE_PHONE | 0x00 | Phone. |
+| DEVICE_TYPE_TABLET | 0x01 | Tablet. |
+| DEVICE_TYPE_CAR | 0x02 | Head unit. |
+| DEVICE_TYPE_PC | 0x03 | PC. |
+| DEVICE_TYPE_TV | 0x04 | TV. |
+| DEVICE_TYPE_WEARABLE | 0x06 | Wearable. |
## ScreenDensity
@@ -182,8 +198,8 @@ Defines the device configuration.
```
resourceManager.getResourceManager((error, mgr) => {
mgr.getConfiguration((error, value) => {
- console.log(value.direction);
- console.log(value.locale);
+ let direction = value.direction;
+ let locale = value.locale;
});
});
```
@@ -205,8 +221,8 @@ Defines the device capability.
```
resourceManager.getResourceManager((error, mgr) => {
mgr.getDeviceCapability((error, value) => {
- console.log(value.screenDensity);
- console.log(value.deviceType);
+ let screenDensity = value.screenDensity;
+ let deviceType = value.deviceType;
});
});
```
@@ -227,7 +243,7 @@ Defines the descriptor information of the raw file.
Defines the capability of accessing application resources.
->  **NOTE**
+> **NOTE**
> - The methods involved in **ResourceManager** are applicable only to the TypeScript-based declarative development paradigm.
>
> - Resource files are defined in the **resources** directory of the project. You can obtain the resource ID using **$r(resource address).id**, for example, **$r('app.string.test').id**.
@@ -245,16 +261,16 @@ Obtains the string corresponding to the specified resource ID. This API uses an
| Name | Type | Mandatory | Description |
| -------- | --------------------------- | ---- | --------------- |
| resId | number | Yes | Resource ID. |
-| callback | AsyncCallback<string> | Yes | Asynchronous callback used to return the obtained string.|
+| callback | AsyncCallback<string> | Yes | Asynchronous callback used to return the result.|
**Example**
```
resourceManager.getResourceManager((error, mgr) => {
mgr.getString($r('app.string.test').id, (error, value) => {
if (error != null) {
- console.log(value);
+ console.log("error is " + error);
} else {
- console.log(value);
+ let str = value;
}
});
});
@@ -277,15 +293,15 @@ Obtains the string corresponding to the specified resource ID. This API uses a p
**Return value**
| Type | Description |
| --------------------- | ----------- |
-| Promise<string> | Promise used to return the string obtained.|
+| Promise<string> | Promise used to return the result.|
**Example**
```
resourceManager.getResourceManager((error, mgr) => {
mgr.getString($r('app.string.test').id).then(value => {
- console.log(value);
+ let str = value;
}).catch(error => {
- console.log("getstring promise " + error);
+ console.log("getstring promise error is " + error);
});
});
```
@@ -295,7 +311,7 @@ Obtains the string corresponding to the specified resource ID. This API uses a p
getStringArray(resId: number, callback: AsyncCallback<Array<string>>): void
-Obtains the array of strings corresponding to the specified resource ID. This API uses an asynchronous callback to return the result.
+Obtains the string array corresponding to the specified resource ID. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Global.ResourceManager
@@ -303,16 +319,16 @@ Obtains the array of strings corresponding to the specified resource ID. This AP
| Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ----------------- |
| resId | number | Yes | Resource ID. |
-| callback | AsyncCallback<Array<string>> | Yes | Asynchronous callback used to return the obtained array of strings.|
+| callback | AsyncCallback<Array<string>> | Yes | Asynchronous callback used to return the result.|
**Example**
```
resourceManager.getResourceManager((error, mgr) => {
mgr.getStringArray($r('app.strarray.test').id, (error, value) => {
if (error != null) {
- console.log(value);
+ console.log("error is " + error);
} else {
- console.log(value);
+ let strArray = value;
}
});
});
@@ -323,7 +339,7 @@ Obtains the array of strings corresponding to the specified resource ID. This AP
getStringArray(resId: number): Promise<Array<string>>
-Obtains the array of strings corresponding to the specified resource ID. This API uses a promise to return the result.
+Obtains the string array corresponding to the specified resource ID. This API uses a promise to return the result.
**System capability**: SystemCapability.Global.ResourceManager
@@ -335,15 +351,15 @@ Obtains the array of strings corresponding to the specified resource ID. This AP
**Return value**
| Type | Description |
| ---------------------------------- | ------------- |
-| Promise<Array<string>> | Promise used to return the array of strings obtained.|
+| Promise<Array<string>> | Promise used to return the result.|
**Example**
```
resourceManager.getResourceManager((error, mgr) => {
mgr.getStringArray($r('app.strarray.test').id).then(value => {
- console.log(value);
+ let strArray = value;
}).catch(error => {
- console.log("getstring promise " + error);
+ console.log("getStringArray promise error is " + error);
});
});
```
@@ -361,16 +377,16 @@ Obtains the content of the media file corresponding to the specified resource ID
| Name | Type | Mandatory | Description |
| -------- | ------------------------------- | ---- | ------------------ |
| resId | number | Yes | Resource ID. |
-| callback | AsyncCallback<Uint8Array> | Yes | Asynchronous callback used to return the content of the media file obtained.|
+| callback | AsyncCallback<Uint8Array> | Yes | Asynchronous callback used to return the result.|
**Example**
```
resourceManager.getResourceManager((error, mgr) => {
mgr.getMedia($r('app.media.test').id, (error, value) => {
if (error != null) {
- console.log(value);
+ console.log("error is " + error);
} else {
- console.log(value);
+ let media = value;
}
});
});
@@ -393,15 +409,15 @@ Obtains the content of the media file corresponding to the specified resource ID
**Return value**
| Type | Description |
| ------------------------- | -------------- |
-| Promise<Uint8Array> | Promise used to return the content of the media file obtained.|
+| Promise<Uint8Array> | Promise used to return the result.|
**Example**
```
resourceManager.getResourceManager((error, mgr) => {
mgr.getMedia($r('app.media.test').id).then(value => {
- console.log(value);
+ let media = value;
}).catch(error => {
- console.log("getstring promise " + error);
+ console.log("getMedia promise error is " + error);
});
});
```
@@ -419,16 +435,16 @@ Obtains the Base64 code of the image corresponding to the specified resource ID.
| Name | Type | Mandatory | Description |
| -------- | --------------------------- | ---- | ------------------------ |
| resId | number | Yes | Resource ID. |
-| callback | AsyncCallback<string> | Yes | Asynchronous callback used to return the Base64 code of the image obtained.|
+| callback | AsyncCallback<string> | Yes | Asynchronous callback used to return the result.|
**Example**
```
resourceManager.getResourceManager((error, mgr) => {
mgr.getMediaBase64($r('app.media.test').id, (error, value) => {
if (error != null) {
- console.log(value);
+ console.log("error is " + error);
} else {
- console.log(value);
+ let media = value;
}
});
});
@@ -451,15 +467,15 @@ Obtains the Base64 code of the image corresponding to the specified resource ID.
**Return value**
| Type | Description |
| --------------------- | -------------------- |
-| Promise<string> | Promise used to return the Base64 code of the image obtained.|
+| Promise<string> | Promise used to return the result.|
**Example**
```
resourceManager.getResourceManager((error, mgr) => {
mgr.getMediaBase64($r('app.media.test').id).then(value => {
- console.log(value);
+ let media = value;
}).catch(error => {
- console.log("getstring promise " + error);
+ console.log("getMediaBase64 promise error is " + error);
});
});
```
@@ -476,16 +492,17 @@ Obtains the device configuration. This API uses an asynchronous callback to retu
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ------------------------- |
-| callback | AsyncCallback<[Configuration](#configuration)> | Yes | Asynchronous callback used to return the obtained device configuration.|
+| callback | AsyncCallback<[Configuration](#configuration)> | Yes | Asynchronous callback used to return the result.|
**Example**
```
resourceManager.getResourceManager((error, mgr) => {
mgr.getConfiguration((error, value) => {
if (error != null) {
- console.log(value);
+ console.log("error is " + error);
} else {
- console.log(value);
+ let direction = value.direction;
+ let locale = value.locale;
}
});
});
@@ -503,15 +520,16 @@ Obtains the device configuration. This API uses a promise to return the result.
**Return value**
| Type | Description |
| ---------------------------------------- | ---------------- |
-| Promise<[Configuration](#configuration)> | Promise used to return the device configuration.|
+| Promise<[Configuration](#configuration)> | Promise used to return the result.|
**Example**
```
resourceManager.getResourceManager((error, mgr) => {
mgr.getConfiguration().then(value => {
- console.log(value);
+ let direction = value.direction;
+ let locale = value.locale;
}).catch(error => {
- console.log("getstring promise " + error);
+ console.log("getConfiguration promise error is " + error);
});
});
```
@@ -528,16 +546,17 @@ Obtains the device capability. This API uses an asynchronous callback to return
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ---------------------------- |
-| callback | AsyncCallback<[DeviceCapability](#devicecapability)> | Yes | Asynchronous callback used to return the obtained device capability.|
+| callback | AsyncCallback<[DeviceCapability](#devicecapability)> | Yes | Asynchronous callback used to return the result.|
**Example**
```
resourceManager.getResourceManager((error, mgr) => {
mgr.getDeviceCapability((error, value) => {
if (error != null) {
- console.log(value);
+ console.log("error is " + error);
} else {
- console.log(value);
+ let screenDensity = value.screenDensity;
+ let deviceType = value.deviceType;
}
});
});
@@ -555,15 +574,16 @@ Obtains the device capability. This API uses a promise to return the result.
**Return value**
| Type | Description |
| ---------------------------------------- | ------------------- |
-| Promise<[DeviceCapability](#devicecapability)> | Promise used to return the obtained device capability.|
+| Promise<[DeviceCapability](#devicecapability)> | Promise used to return the result.|
**Example**
```
resourceManager.getResourceManager((error, mgr) => {
mgr.getDeviceCapability().then(value => {
- console.log(value);
+ let screenDensity = value.screenDensity;
+ let deviceType = value.deviceType;
}).catch(error => {
- console.log("getstring promise " + error);
+ console.log("getDeviceCapability promise error is " + error);
});
});
```
@@ -582,16 +602,16 @@ Obtains the specified number of singular-plural strings corresponding to the spe
| -------- | --------------------------- | ---- | ------------------------------- |
| resId | number | Yes | Resource ID. |
| num | number | Yes | Number that determines the plural or singular form. |
-| callback | AsyncCallback<string> | Yes | Asynchronous callback used to return the singular-plural string obtained.|
+| callback | AsyncCallback<string> | Yes | Asynchronous callback used to return the result.|
**Example**
```
resourceManager.getResourceManager((error, mgr) => {
mgr.getPluralString($r("app.plural.test").id, 1, (error, value) => {
if (error != null) {
- console.log(value);
+ console.log("error is " + error);
} else {
- console.log(value);
+ let str = value;
}
});
});
@@ -615,15 +635,15 @@ Obtains the specified number of singular-plural strings corresponding to the spe
**Return value**
| Type | Description |
| --------------------- | ------------------------- |
-| Promise<string> | Promise used to return the singular-plural string obtained.|
+| Promise<string> | Promise used to return the result.|
**Example**
```
resourceManager.getResourceManager((error, mgr) => {
mgr.getPluralString($r("app.plural.test").id, 1).then(value => {
- console.log(value);
+ let str = value;
}).catch(error => {
- console.log("getstring promise " + error);
+ console.log("getPluralString promise error is " + error);
});
});
```
@@ -632,7 +652,7 @@ Obtains the specified number of singular-plural strings corresponding to the spe
getRawFile(path: string, callback: AsyncCallback<Uint8Array>): void
-Obtains the content of rawfile in the specified path. This API uses an asynchronous callback to return the result.
+Obtains the content of the raw file in the **resources/rawfile** directory. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Global.ResourceManager
@@ -640,16 +660,16 @@ Obtains the content of rawfile in the specified path. This API uses an asynchron
| Name | Type | Mandatory | Description |
| -------- | ------------------------------- | ---- | ----------------------- |
| path | string | Yes | Path of the raw file. |
-| callback | AsyncCallback<Uint8Array> | Yes | Asynchronous callback used to return the raw file content, in byte arrays.|
+| callback | AsyncCallback<Uint8Array> | Yes | Asynchronous callback used to return the result.|
**Example**
```
resourceManager.getResourceManager((error, mgr) => {
mgr.getRawFile("test.xml", (error, value) => {
if (error != null) {
- console.log(value);
+ console.log("error is " + error);
} else {
- console.log(value);
+ let rawFile = value;
}
});
});
@@ -659,7 +679,7 @@ Obtains the content of rawfile in the specified path. This API uses an asynchron
getRawFile(path: string): Promise<Uint8Array>
-Obtains the content of the raw file in the specified path. This API uses a promise to return the result.
+Obtains the content of the raw file in the **resources/rawfile** directory. This API uses a promise to return the result.
**System capability**: SystemCapability.Global.ResourceManager
@@ -671,15 +691,15 @@ Obtains the content of the raw file in the specified path. This API uses a promi
**Return value**
| Type | Description |
| ------------------------- | ----------- |
-| Promise<Uint8Array> | Promise used to return the raw file content, in byte arrays.|
+| Promise<Uint8Array> | Promise used to return the result.|
**Example**
```
resourceManager.getResourceManager((error, mgr) => {
mgr.getRawFile("test.xml").then(value => {
- console.log(value);
+ let rawFile = value;
}).catch(error => {
- console.log("getrawfile promise " + error);
+ console.log("getRawFile promise error is " + error);
});
});
```
@@ -688,7 +708,7 @@ Obtains the content of the raw file in the specified path. This API uses a promi
getRawFileDescriptor(path: string, callback: AsyncCallback<RawFileDescriptor>): void
-Obtains the descriptor of the raw file in the specified path. This API uses an asynchronous callback to return the result.
+Obtains the descriptor of the raw file in the **resources/rawfile** directory. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Global.ResourceManager
@@ -696,14 +716,14 @@ Obtains the descriptor of the raw file in the specified path. This API uses an a
| Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | -------------------------------- |
| path | string | Yes | Path of the raw file. |
-| callback | AsyncCallback<[RawFileDescriptor](#rawfiledescriptor8)> | Yes | Asynchronous callback used to return the raw file descriptor.|
+| callback | AsyncCallback<[RawFileDescriptor](#rawfiledescriptor8)> | Yes | Asynchronous callback used to return the result.|
**Example**
```
resourceManager.getResourceManager((error, mgr) => {
mgr.getRawFileDescriptor("test.xml", (error, value) => {
if (error != null) {
- console.log(value);
+ console.log("error is " + error);
} else {
let fd = value.fd;
let offset = value.offset;
@@ -717,7 +737,7 @@ Obtains the descriptor of the raw file in the specified path. This API uses an a
getRawFileDescriptor(path: string): Promise<RawFileDescriptor>
-Obtains the descriptor of the raw file in the specified path. This API uses a promise to return the result.
+Obtains the descriptor of the raw file in the **resources/rawfile** directory. This API uses a promise to return the result.
**System capability**: SystemCapability.Global.ResourceManager
@@ -729,7 +749,7 @@ Obtains the descriptor of the raw file in the specified path. This API uses a pr
**Return value**
| Type | Description |
| ---------------------------------------- | ------------------- |
-| Promise<[RawFileDescriptor](#rawfiledescriptor8)> | Promise used to return the raw file descriptor.|
+| Promise<[RawFileDescriptor](#rawfiledescriptor8)> | Promise used to return the result.|
**Example**
```
@@ -739,7 +759,7 @@ Obtains the descriptor of the raw file in the specified path. This API uses a pr
let offset = value.offset;
let length = value.length;
}).catch(error => {
- console.log("getRawFileDescriptor promise " + error);
+ console.log("getRawFileDescriptor promise error is " + error);
});
});
```
@@ -748,7 +768,7 @@ Obtains the descriptor of the raw file in the specified path. This API uses a pr
closeRawFileDescriptor(path: string, callback: AsyncCallback<void>): void
-Closes the descriptor of the raw file in the specified path. This API uses an asynchronous callback to return the result.
+Closes the descriptor of the raw file in the **resources/rawfile** directory. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Global.ResourceManager
@@ -763,7 +783,7 @@ Closes the descriptor of the raw file in the specified path. This API uses an as
resourceManager.getResourceManager((error, mgr) => {
mgr.closeRawFileDescriptor("test.xml", (error, value) => {
if (error != null) {
- console.log(value);
+ console.log("error is " + error);
}
});
});
@@ -773,7 +793,7 @@ Closes the descriptor of the raw file in the specified path. This API uses an as
closeRawFileDescriptor(path: string): Promise<void>
-Closes the descriptor of the raw file in the specified path. This API uses a promise to return the result.
+Closes the descriptor of the raw file in the **resources/rawfile** directory. This API uses a promise to return the result.
**System capability**: SystemCapability.Global.ResourceManager
@@ -791,9 +811,9 @@ Closes the descriptor of the raw file in the specified path. This API uses a pro
```
resourceManager.getResourceManager((error, mgr) => {
mgr.closeRawFileDescriptor("test.xml").then(value => {
- console.log(value);
+ let result = value;
}).catch(error => {
- console.log("closeRawFileDescriptor promise " + error);
+ console.log("closeRawFileDescriptor promise error is " + error);
});
});
```
@@ -809,10 +829,408 @@ Releases the created **resourceManager**.
**Example**
```
resourceManager.getResourceManager((error, mgr) => {
- mgr.release((error, value) => {
- if (error != null) {
- console.log(value);
- }
- });
+ mgr.release();
+ });
+ ```
+
+### getStringByName9+
+
+getStringByName(resName: string, callback: AsyncCallback<string>): void
+
+Obtains the string corresponding to the specified resource name. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Global.ResourceManager
+
+**Parameters**
+| Name | Type | Mandatory | Description |
+| -------- | --------------------------- | ---- | --------------- |
+| resName | string | Yes | Resource name. |
+| callback | AsyncCallback<string> | Yes | Asynchronous callback used to return the result.|
+
+**Example**
+ ```
+ resourceManager.getStringByName("test", (error, value) => {
+ if (error != null) {
+ console.log("error is " + error);
+ } else {
+ let string = value;
+ }
+ });
+ ```
+
+### getStringByName9+
+
+getStringByName(resName: string): Promise<string>
+
+Obtains the string corresponding to the specified resource name. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Global.ResourceManager
+
+**Parameters**
+| Name | Type | Mandatory | Description |
+| ------- | ------ | ---- | ---- |
+| resName | string | Yes | Resource name.|
+
+**Return value**
+| Type | Description |
+| --------------------- | ----------- |
+| Promise<string> | String corresponding to the resource name.|
+
+**Example**
+ ```
+ resourceManager.getStringByName("test").then(value => {
+ let string = value;
+ }).catch(error => {
+ console.log("getStringByName promise error is " + error);
+ });
+ ```
+
+### getStringArrayByName9+
+
+getStringArrayByName(resName: string, callback: AsyncCallback<Array<string>>): void
+
+Obtains the string array corresponding to the specified resource name. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Global.ResourceManager
+
+**Parameters**
+| Name | Type | Mandatory | Description |
+| -------- | ---------------------------------------- | ---- | ----------------- |
+| resName | string | Yes | Resource name. |
+| callback | AsyncCallback<Array<string>> | Yes | Asynchronous callback used to return the result.|
+
+**Example**
+ ```
+ resourceManager.getStringArrayByName("test", (error, value) => {
+ if (error != null) {
+ console.log("error is " + error);
+ } else {
+ let strArray = value;
+ }
+ });
+ ```
+
+### getStringArrayByName9+
+
+getStringArrayByName(resName: string): Promise<Array<string>>
+
+Obtains the string array corresponding to the specified resource name. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Global.ResourceManager
+
+**Parameters**
+| Name | Type | Mandatory | Description |
+| ------- | ------ | ---- | ----- |
+| resName | string | Yes | Resource name.|
+
+**Return value**
+| Type | Description |
+| ---------------------------------- | ------------- |
+| Promise<Array<string>> | Promise used to return the result.|
+
+**Example**
+ ```
+ resourceManager.getStringArrayByName("test").then(value => {
+ let strArray = value;
+ }).catch(error => {
+ console.log("getStringArrayByName promise error is " + error);
+ });
+ ```
+
+### getMediaByName9+
+
+getMediaByName(resName: string, callback: AsyncCallback<Uint8Array>): void
+
+Obtains the content of the media file corresponding to the specified resource name. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Global.ResourceManager
+
+**Parameters**
+| Name | Type | Mandatory | Description |
+| -------- | ------------------------------- | ---- | ------------------ |
+| resName | string | Yes | Resource name. |
+| callback | AsyncCallback<Uint8Array> | Yes | Asynchronous callback used to return the result.|
+
+**Example**
+ ```
+ resourceManager.getMediaByName("test", (error, value) => {
+ if (error != null) {
+ console.log("error is " + error);
+ } else {
+ let media = value;
+ }
+ });
+ ```
+
+### getMediaByName9+
+
+getMediaByName(resName: string): Promise<Uint8Array>
+
+Obtains the content of the media file corresponding to the specified resource name. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Global.ResourceManager
+
+**Parameters**
+| Name | Type | Mandatory | Description |
+| ----- | ------ | ---- | ----- |
+| resName | string | Yes | Resource name.|
+
+**Return value**
+| Type | Description |
+| ------------------------- | -------------- |
+| Promise<Uint8Array> | Promise used to return the result.|
+
+**Example**
+ ```
+ resourceManager.getMediaByName("test").then(value => {
+ let media = value;
+ }).catch(error => {
+ console.log("getMediaByName promise error is " + error);
+ });
+ ```
+
+### getMediaBase64ByName9+
+
+getMediaBase64ByName(resName: string, callback: AsyncCallback<string>): void
+
+Obtains the Base64 code of the image corresponding to the specified resource name. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Global.ResourceManager
+
+**Parameters**
+| Name | Type | Mandatory | Description |
+| -------- | --------------------------- | ---- | ------------------------ |
+| resName | string | Yes | Resource name. |
+| callback | AsyncCallback<string> | Yes | Asynchronous callback used to return the result.|
+
+**Example**
+ ```
+ resourceManager.getMediaBase64ByName("test", (error, value) => {
+ if (error != null) {
+ console.log("error is " + error);
+ } else {
+ let media = value;
+ }
});
```
+
+### getMediaBase64ByName9+
+
+getMediaBase64ByName(resName: string): Promise<string>
+
+Obtains the Base64 code of the image corresponding to the specified resource name. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Global.ResourceManager
+
+**Parameters**
+| Name | Type | Mandatory | Description |
+| ------- | ------ | ---- | ----- |
+| resName | string | Yes | Resource name.|
+
+**Return value**
+| Type | Description |
+| --------------------- | -------------------- |
+| Promise<string> | Promise used to return the result.|
+
+**Example**
+ ```
+ resourceManager.getMediaByName("test").then(value => {
+ let media = value;
+ }).catch(error => {
+ console.log("getMediaBase64ByName promise error is " + error);
+ });
+ ```
+
+### getPluralStringByName9+
+
+getPluralStringByName(resName: string, num: number, callback: AsyncCallback<string>): void
+
+Obtains the plural string corresponding to the specified resource name. This API uses an asynchronous callback to return the result.
+
+**System capability**: SystemCapability.Global.ResourceManager
+
+**Parameters**
+| Name | Type | Mandatory | Description |
+| -------- | --------------------------- | ---- | ------------------------------- |
+| resName | string | Yes | Resource name. |
+| num | number | Yes | Number that determines the plural or singular form. |
+| callback | AsyncCallback<string> | Yes | Asynchronous callback used to return the result.|
+
+**Example**
+ ```
+ resourceManager.getPluralStringByName("test", 1, (error, value) => {
+ if (error != null) {
+ console.log("error is " + error);
+ } else {
+ let str = value;
+ }
+ });
+ ```
+
+### getPluralStringByName9+
+
+getPluralStringByName(resName: string, num: number): Promise<string>
+
+Obtains the plural string corresponding to the specified resource name. This API uses a promise to return the result.
+
+**System capability**: SystemCapability.Global.ResourceManager
+
+**Parameters**
+| Name | Type | Mandatory | Description |
+| ------- | ------ | ---- | ----- |
+| resName | string | Yes | Resource name.|
+| num | number | Yes | Number that determines the plural or singular form. |
+
+**Return value**
+| Type | Description |
+| --------------------- | ------------------------- |
+| Promise<string> | Promise used to return the result.|
+
+**Example**
+ ```
+ resourceManager.getPluralStringByName("test", 1).then(value => {
+ let str = value;
+ }).catch(error => {
+ console.log("getPluralStringByName promise error is " + error);
+ });
+ ```
+
+### getStringSync9+
+
+getStringSync(resId: number): string
+
+Obtains the string corresponding to the specified resource ID. This API returns the result synchronously.
+
+**System capability**: SystemCapability.Global.ResourceManager
+
+**Parameters**
+| Name | Type | Mandatory | Description |
+| ----- | ------ | ---- | ----- |
+| resId | number | Yes | Resource ID.|
+
+**Return value**
+| Type | Description |
+| --------------------- | ----------- |
+| string | String corresponding to the specified resource ID.|
+
+**Example**
+ ```
+ resourceManager.getStringSync($r('app.string.test').id);
+ ```
+
+### getStringByNameSync9+
+
+getStringByNameSync(resName: string): string
+
+Obtains the string corresponding to the specified resource name. This API returns the result synchronously.
+
+**System capability**: SystemCapability.Global.ResourceManager
+
+**Parameters**
+| Name | Type | Mandatory | Description |
+| ----- | ------ | ---- | ----- |
+| resName | string | Yes | Resource name.|
+
+**Return value**
+| Type | Description |
+| --------------------- | ----------- |
+| string | String corresponding to the resource name.|
+
+**Example**
+ ```
+ resourceManager.getStringByNameSync("test");
+ ```
+
+ ### getBoolean9+
+
+getBoolean(resId: number): boolean
+
+Obtains the Boolean result corresponding to the specified resource ID. This API returns the result synchronously.
+
+**System capability**: SystemCapability.Global.ResourceManager
+
+**Parameters**
+| Name | Type | Mandatory | Description |
+| ----- | ------ | ---- | ----- |
+| resId | number | Yes | Resource ID.|
+
+**Return value**
+| Type | Description |
+| --------------------- | ----------- |
+| boolean | Boolean result corresponding to the specified resource ID.|
+
+**Example**
+ ```
+ resourceManager.getBoolean($r('app.boolean.boolean_test').id);
+ ```
+
+### getBooleanByName9+
+
+getBooleanByName(resName: string): boolean
+
+Obtains the Boolean result corresponding to the specified resource name. This API returns the result synchronously.
+
+**System capability**: SystemCapability.Global.ResourceManager
+
+**Parameters**
+| Name | Type | Mandatory | Description |
+| ------- | ------ | ---- | ----- |
+| resName | string | Yes | Resource name.|
+
+**Return value**
+| Type | Description |
+| --------------------- | ----------- |
+| boolean | Boolean result corresponding to the specified resource name.|
+
+**Example**
+ ```
+ resourceManager.getBooleanByName("boolean_test");
+ ```
+
+ ### getNumber9+
+
+getNumber(resId: number): number
+
+Obtains the integer or float value corresponding to the specified resource ID. This API returns the result synchronously.
+
+**System capability**: SystemCapability.Global.ResourceManager
+
+**Parameters**
+| Name | Type | Mandatory | Description |
+| ----- | ------ | ---- | ----- |
+| resId | number | Yes | Resource ID.|
+
+**Return value**
+| Type | Description |
+| --------------------- | ----------- |
+| number | Integer or float value corresponding to the specified resource ID.|
+
+**Example**
+ ```
+ resourceManager.getNumber($r('app.integer.integer_test').id);
+ resourceManager.getNumber($r('app.float.float_test').id);
+ ```
+
+### getNumberByName9+
+
+getNumberByName(resName: string): number
+
+Obtains the integer or float value corresponding to the specified resource name. This API returns the result synchronously.
+
+**System capability**: SystemCapability.Global.ResourceManager
+
+**Parameters**
+| Name | Type | Mandatory | Description |
+| ----- | ------ | ---- | ----- |
+| resName | string | Yes | Resource name.|
+
+**Return value**
+| Type | Description |
+| --------------------- | ----------- |
+| number | Integer or float value corresponding to the specified resource name.|
+
+**Example**
+ ```
+ resourceManager.getNumberByName("integer_test");
+ resourceManager.getNumberByName("float_test");
+ ```
diff --git a/en/application-dev/reference/apis/js-apis-router.md b/en/application-dev/reference/apis/js-apis-router.md
index b17d29151d7c1c9a9ee53de976cd4c0f77ea838a..40076077bd258dab549dbcb46e16a7137961c107 100644
--- a/en/application-dev/reference/apis/js-apis-router.md
+++ b/en/application-dev/reference/apis/js-apis-router.md
@@ -1,6 +1,6 @@
# Page Routing
->  **NOTE**
+> **NOTE**
>
> - The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - Page routing APIs can be invoked only after page rendering is complete. Do not call the APIs in **onInit** and **onReady** when the page is still in the rendering phase.
@@ -190,6 +190,8 @@ getLength(): string
Obtains the number of pages in the current stack.
+**System capability**: SystemCapability.ArkUI.ArkUI.Full
+
**Return value**
| Type| Description|
| -------- | -------- |
@@ -275,7 +277,7 @@ Enables the display of a confirm dialog box before returning to the previous pag
Describes the confirm dialog box.
-**System capability**: SystemCapability.ArkUI.ArkUI.Lite
+**System capability**: SystemCapability.ArkUI.ArkUI.Full
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
diff --git a/en/application-dev/reference/apis/js-apis-screenshot.md b/en/application-dev/reference/apis/js-apis-screenshot.md
index 690a77e0d9563a066d7f1da9352aca640b6fbea3..5e2d47e03ba31ab4bae9118e3dc373359d56da11 100644
--- a/en/application-dev/reference/apis/js-apis-screenshot.md
+++ b/en/application-dev/reference/apis/js-apis-screenshot.md
@@ -1,7 +1,11 @@
# Screenshot
+Provides APIs for you to set information such as the region to capture and the size of the screen region when capturing a screen.
-> **NOTE**
+> **NOTE**
+>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+>
+> The APIs provided by this module are system APIs.
## Modules to Import
@@ -16,11 +20,12 @@ Describes screenshot options.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
-| Name | Type | Mandatory| Description |
-| ---------- | ------------- | ---- | ------------------------------------------------------------ |
-| screenRect | [Rect](#rect) | No | Region of the screen to capture. If this parameter is null, the full screen will be captured.|
-| imageSize | [Size](#size) | No | Size of the screen region to capture. If this parameter is null, the full screen will be captured.|
-| rotation | number | No | Rotation angle of the screenshot. Currently, the value can be **0** only. The default value is **0**.|
+| Name | Type | Mandatory| Description |
+| ---------------------- | ------------- | ---- | ------------------------------------------------------------ |
+| screenRect | [Rect](#rect) | No | Region of the screen to capture. If this parameter is null, the full screen will be captured. |
+| imageSize | [Size](#size) | No | Size of the screen region to capture. If this parameter is null, the full screen will be captured. |
+| rotation | number | No | Rotation angle of the screenshot. Currently, the value can be **0** only. The default value is **0**. |
+| displayId8+ | number | No | ID of the [display](js-apis-display.md#display) device on which the screen region is to be captured.|
## Rect
@@ -56,14 +61,14 @@ Takes a screenshot and saves it as a **PixelMap** object. This method uses a cal
**System capability**: SystemCapability.WindowManager.WindowManager.Core
-**Required permissions**: ohos.permission.CAPTURE_SCREEN
+**Required permissions**: ohos.permission.CAPTURE_SCREEN (available only to system applications)
**Parameters**
- | Name | Type | Mandatory| Description |
- | -------- | --------------------------------------- | ---- | ------------------------------------------------------------ |
- | options | [ScreenshotOptions](#screenshotoptions) | No | Screenshot options, which consist of **screenRect**, **imageSize**, and **rotation**. You need to set these parameters.|
- | callback | AsyncCallback<image.PixelMap> | Yes | Callback used to return a **PixelMap** object. |
+| Name | Type | Mandatory| Description |
+| -------- | --------------------------------------- | ---- | ------------------------------------------------------------ |
+| options | [ScreenshotOptions](#screenshotoptions) | No | Consists of **screenRect**, **imageSize**, **rotation**, and **displayId**. You can set them separately.|
+| callback | AsyncCallback<image.PixelMap> | Yes | Callback used to return a **PixelMap** object. |
**Example**
@@ -77,7 +82,8 @@ Takes a screenshot and saves it as a **PixelMap** object. This method uses a cal
"imageSize": {
"width": 300,
"height": 300},
- "rotation": 0
+ "rotation": 0,
+ "displayId": 0
};
screenshot.save(ScreenshotOptions, (err, data) => {
if (err) {
@@ -96,19 +102,19 @@ Takes a screenshot and saves it as a **PixelMap** object. This method uses a pro
**System capability**: SystemCapability.WindowManager.WindowManager.Core
-**Required permissions**: ohos.permission.CAPTURE_SCREEN
+**Required permissions**: ohos.permission.CAPTURE_SCREEN (available only to system applications)
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | --------------------------------------- | ---- | ------------------------------------------------------------ |
-| options | [ScreenshotOptions](#screenshotoptions) | No | Screenshot options, which consist of **screenRect**, **imageSize**, and **rotation**. You need to set these parameters.|
+| options | [ScreenshotOptions](#screenshotoptions) | No | Consists of **screenRect**, **imageSize**, **rotation**, and **displayId**. You can set them separately.|
**Return value**
- | Type | Description |
- | ----------------------------- | ----------------------------------------------- |
- | Promise<image.PixelMap> | Promise used to return an **image.PixelMap** object.|
+| Type | Description |
+| ----------------------------- | ----------------------------------------------- |
+| Promise<image.PixelMap> | Promise used to return a **PixelMap** object.|
**Example**
@@ -122,7 +128,8 @@ Takes a screenshot and saves it as a **PixelMap** object. This method uses a pro
"imageSize": {
"width": 300,
"height": 300},
- "rotation": 0
+ "rotation": 0,
+ "displayId": 0
};
let promise = screenshot.save(ScreenshotOptions);
promise.then(() => {
diff --git a/en/application-dev/reference/apis/js-apis-sensor.md b/en/application-dev/reference/apis/js-apis-sensor.md
index c04e503414020d5c0b6107ef2313df58d91b52f5..aab544f7f78bd2b755ab24443aa1d0acd5d683c1 100644
--- a/en/application-dev/reference/apis/js-apis-sensor.md
+++ b/en/application-dev/reference/apis/js-apis-sensor.md
@@ -1,17 +1,19 @@
# Sensor
-> **NOTE**
+> **NOTE**
+>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
-```
+```js
import sensor from '@ohos.sensor';
```
+## sensor.on
-## sensor.on(SensorType.SENSOR_TYPE_ID_ACCELEROMETER)
+### ACCELEROMETER
on(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: Callback<AccelerometerResponse>,options?: Options): void
@@ -30,7 +32,7 @@ Subscribes to data changes of the acceleration sensor. If this API is called mul
| options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
**Example**
- ```
+ ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER,function(data){
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
@@ -40,8 +42,7 @@ Subscribes to data changes of the acceleration sensor. If this API is called mul
);
```
-
-## sensor.on(SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION)
+### LINEAR_ACCELERATION
on(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback:Callback<LinearAccelerometerResponse>, options?: Options): void
@@ -59,7 +60,7 @@ Subscribes to data changes of the linear acceleration sensor. If this API is cal
| options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
**Example**
- ```
+ ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,function(data){
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
@@ -69,8 +70,7 @@ Subscribes to data changes of the linear acceleration sensor. If this API is cal
);
```
-
-## sensor.on(SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED)
+### ACCELEROMETER_UNCALIBRATED
on(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,callback: Callback<AccelerometerUncalibratedResponse>, options?: Options): void
@@ -88,7 +88,7 @@ Subscribes to data changes of the uncalibrated acceleration sensor. If this API
| options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
**Example**
- ```
+ ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,function(data){
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
@@ -101,8 +101,7 @@ Subscribes to data changes of the uncalibrated acceleration sensor. If this API
);
```
-
-## sensor.on(SensorType.SENSOR_TYPE_ID_GRAVITY)
+### GRAVITY
on(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: Callback<GravityResponse>,options?: Options): void
@@ -118,7 +117,7 @@ Subscribes to data changes of the gravity sensor. If this API is called multiple
| options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
**Example**
- ```
+ ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY,function(data){
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
@@ -128,8 +127,7 @@ Subscribes to data changes of the gravity sensor. If this API is called multiple
);
```
-
-## sensor.on(SensorType.SENSOR_TYPE_ID_GYROSCOPE)
+### GYROSCOPE
on(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: Callback<GyroscopeResponse>, options?: Options): void
@@ -147,7 +145,7 @@ Subscribes to data changes of the gyroscope sensor. If this API is called multip
| options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
**Example**
- ```
+ ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE,function(data){
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
@@ -157,8 +155,7 @@ Subscribes to data changes of the gyroscope sensor. If this API is called multip
);
```
-
-## sensor.on(SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED)
+### GYROSCOPE_UNCALIBRATED
on(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,callback:Callback<GyroscopeUncalibratedResponse>, options?: Options): void
@@ -176,7 +173,7 @@ Subscribes to data changes of the uncalibrated gyroscope sensor. If this API is
| options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. |
**Example**
- ```
+ ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,function(data){
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
@@ -189,8 +186,7 @@ Subscribes to data changes of the uncalibrated gyroscope sensor. If this API is
);
```
-
-## sensor.on(SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION)
+### SIGNIFICANT_MOTION
on(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback: Callback<SignificantMotionResponse>, options?: Options): void
@@ -206,7 +202,7 @@ Subscribes to data changes of the significant motion sensor. If this API is call
| options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
**Example**
- ```
+ ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION,function(data){
console.info('Scalar data: ' + data.scalar);
},
@@ -214,8 +210,7 @@ Subscribes to data changes of the significant motion sensor. If this API is call
);
```
-
-## sensor.on(SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION)
+### PEDOMETER_DETECTION
on(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback: Callback<PedometerDetectionResponse>, options?: Options): void
@@ -233,7 +228,7 @@ Subscribes to data changes of the pedometer detection sensor. If this API is cal
| options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
**Example**
- ```
+ ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION,function(data){
console.info('Scalar data: ' + data.scalar);
},
@@ -241,8 +236,7 @@ Subscribes to data changes of the pedometer detection sensor. If this API is cal
);
```
-
-## sensor.on(SensorType.SENSOR_TYPE_ID_PEDOMETER)
+### PEDOMETER
on(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: Callback<PedometerResponse>, options?: Options): void
@@ -260,7 +254,7 @@ Subscribes to data changes of the pedometer sensor. If this API is called multip
| options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
**Example**
- ```
+ ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER,function(data){
console.info('Steps: ' + data.steps);
},
@@ -268,8 +262,7 @@ Subscribes to data changes of the pedometer sensor. If this API is called multip
);
```
-
-## sensor.on(SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE)
+### AMBIENT_TEMPERATURE
on(type:SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,callback:Callback<AmbientTemperatureResponse>, options?: Options): void
@@ -285,7 +278,7 @@ Subscribes to data changes of the ambient temperature sensor. If this API is cal
| options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
**Example**
- ```
+ ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,function(data){
console.info('Temperature: ' + data.temperature);
},
@@ -293,8 +286,7 @@ Subscribes to data changes of the ambient temperature sensor. If this API is cal
);
```
-
-## sensor.on(SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD)
+### MAGNETIC_FIELD
on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: Callback<MagneticFieldResponse>,options?: Options): void
@@ -310,7 +302,7 @@ Subscribes to data changes of the magnetic field sensor. If this API is called m
| options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
**Example**
- ```
+ ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD,function(data){
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
@@ -320,8 +312,7 @@ Subscribes to data changes of the magnetic field sensor. If this API is called m
);
```
-
-## sensor.on(SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED)
+### MAGNETIC_FIELD_UNCALIBRATED
on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,callback: Callback<MagneticFieldUncalibratedResponse>, options?: Options): void
@@ -337,7 +328,7 @@ Subscribes to data changes of the uncalibrated magnetic field sensor. If this AP
| options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
**Example**
- ```
+ ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,function(data){
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
@@ -350,8 +341,7 @@ Subscribes to data changes of the uncalibrated magnetic field sensor. If this AP
);
```
-
-## sensor.on(SensorType.SENSOR_TYPE_ID_PROXIMITY)
+### PROXIMITY
on(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: Callback<ProximityResponse>,options?: Options): void
@@ -367,7 +357,7 @@ Subscribes to data changes of the proximity sensor. If this API is called multip
| options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
**Example**
- ```
+ ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY,function(data){
console.info('Distance: ' + data.distance);
},
@@ -375,8 +365,7 @@ Subscribes to data changes of the proximity sensor. If this API is called multip
);
```
-
-## sensor.on(SensorType.SENSOR_TYPE_ID_HUMIDITY)
+### HUMIDITY
on(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: Callback<HumidityResponse>,options?: Options): void
@@ -392,7 +381,7 @@ Subscribes to data changes of the humidity sensor. If this API is called multipl
| options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
**Example**
- ```
+ ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY,function(data){
console.info('Humidity: ' + data.humidity);
},
@@ -400,8 +389,7 @@ Subscribes to data changes of the humidity sensor. If this API is called multipl
);
```
-
-## sensor.on(SensorType.SENSOR_TYPE_ID_BAROMETER)
+### BAROMETER
on(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback: Callback<BarometerResponse>,options?: Options): void
@@ -417,7 +405,7 @@ Subscribes to data changes of the barometer sensor. If this API is called multip
| options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
**Example**
- ```
+ ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER,function(data){
console.info('Atmospheric pressure: ' + data.pressure);
},
@@ -425,8 +413,7 @@ Subscribes to data changes of the barometer sensor. If this API is called multip
);
```
-
-## sensor.on(SensorType.SENSOR_TYPE_ID_HALL)
+### HALL
on(type: SensorType.SENSOR_TYPE_ID_HALL, callback: Callback<HallResponse>, options?: Options): void
@@ -442,7 +429,7 @@ Subscribes to data changes of the Hall effect sensor. If this API is called mult
| options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
**Example**
- ```
+ ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HALL,function(data){
console.info('Status: ' + data.status);
},
@@ -450,8 +437,7 @@ Subscribes to data changes of the Hall effect sensor. If this API is called mult
);
```
-
-## sensor.on(SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT)
+### AMBIENT_LIGHT
on(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: Callback<LightResponse>, options?: Options): void
@@ -467,7 +453,7 @@ Subscribes to data changes of the ambient light sensor. If this API is called mu
| options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
**Example**
- ```
+ ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT,function(data){
console.info(' Illumination: ' + data.intensity);
},
@@ -475,8 +461,7 @@ Subscribes to data changes of the ambient light sensor. If this API is called mu
);
```
-
-## sensor.on(SensorType.SENSOR_TYPE_ID_ORIENTATION)
+### ORIENTATION
on(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: Callback<OrientationResponse>, options?: Options): void
@@ -492,7 +477,7 @@ Subscribes to data changes of the orientation sensor. If this API is called mult
| options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
**Example**
- ```
+ ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION,function(data){
console.info('The device rotates at an angle around the X axis: ' + data.beta);
console.info('The device rotates at an angle around the Y axis: ' + data.gamma);
@@ -502,7 +487,7 @@ Subscribes to data changes of the orientation sensor. If this API is called mult
);
```
-## sensor.on(SensorType.SENSOR_TYPE_ID_HEART_RATE)
+### HEART_RATE
on(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: Callback<HeartRateResponse>, options?: Options): void
@@ -521,7 +506,7 @@ Subscribes to only one data change of the heart rate sensor.
**Example**
-```
+```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HEART_RATE,function(data){
console.info("Heart rate: " + data.heartRate);
},
@@ -529,7 +514,7 @@ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HEART_RATE,function(data){
);
```
-## sensor.on(SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR)
+### ROTATION_VECTOR
on(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR,callback: Callback<RotationVectorResponse>,options?: Options): void
@@ -545,7 +530,7 @@ Subscribes to data changes of the rotation vector sensor. If this API is called
| options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
**Example**
- ```
+ ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR,function(data){
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
@@ -556,8 +541,7 @@ Subscribes to data changes of the rotation vector sensor. If this API is called
);
```
-
-## sensor.on(SensorType.SENSOR_TYPE_ID_WEAR_DETECTION)
+### WEAR_DETECTION
on(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: Callback<WearDetectionResponse>,options?: Options): void
@@ -573,7 +557,7 @@ Subscribes to data changes of the wear detection sensor. If this API is called m
| options | [Options](#options) | No | Interval at which the callback is invoked to return the sensor data. The default value is 200,000,000 ns. |
**Example**
- ```
+ ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_WEAR_DETECTION,function(data){
console.info('Wear status: ' + data.value);
},
@@ -581,8 +565,9 @@ Subscribes to data changes of the wear detection sensor. If this API is called m
);
```
+## sensor.once
-## sensor.once(SensorType.SENSOR_TYPE_ID_ACCELEROMETER)
+### ACCELEROMETER
once(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: Callback<AccelerometerResponse>): void
@@ -599,7 +584,7 @@ Subscribes to only one data change of the acceleration sensor.
| callback | Callback<[AccelerometerResponse](#accelerometerresponse)> | Yes | One-shot callback used to return the acceleration sensor data. The reported data type in the callback is **AccelerometerResponse**.|
**Example**
- ```
+ ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER,function(data){
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
@@ -608,8 +593,7 @@ Subscribes to only one data change of the acceleration sensor.
);
```
-
-## sensor.once(SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION)
+### LINEAR_ACCELERATION
once(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback:Callback<LinearAccelerometerResponse>): void
@@ -626,7 +610,7 @@ Subscribes to only one data change of the linear acceleration sensor.
| callback | Callback<[LinearAccelerometerResponse](#linearaccelerometerresponse)> | Yes | One-shot callback used to return the linear acceleration sensor data. The reported data type in the callback is **LinearAccelerometerResponse**.|
**Example**
- ```
+ ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, function(data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
@@ -635,8 +619,7 @@ Subscribes to only one data change of the linear acceleration sensor.
);
```
-
-## sensor.once(SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED)
+### ACCELEROMETER_UNCALIBRATED
once(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,callback: Callback<AccelerometerUncalibratedResponse>): void
@@ -665,8 +648,7 @@ Subscribes to only one data change of the uncalibrated acceleration sensor.
);
```
-
-## sensor.once(SensorType.SENSOR_TYPE_ID_GRAVITY)
+### GRAVITY
once(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: Callback<GravityResponse>): void
@@ -681,7 +663,7 @@ Subscribes to only one data change of the gravity sensor.
| callback | Callback<[GravityResponse](#gravityresponse)> | Yes | One-shot callback used to return the gravity sensor data. The reported data type in the callback is **GravityResponse**.|
**Example**
- ```
+ ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, function(data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
@@ -690,8 +672,7 @@ Subscribes to only one data change of the gravity sensor.
);
```
-
-## sensor.once(SensorType.SENSOR_TYPE_ID_GYROSCOPE)
+### GYROSCOPE
once(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: Callback<GyroscopeResponse>): void
@@ -708,7 +689,7 @@ Subscribes to only one data change of the gyroscope sensor.
| callback | Callback<[GyroscopeResponse](#gyroscoperesponse)> | Yes | One-shot callback used to return the gyroscope sensor data. The reported data type in the callback is **GyroscopeResponse**.|
**Example**
- ```
+ ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, function(data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
@@ -717,8 +698,7 @@ Subscribes to only one data change of the gyroscope sensor.
);
```
-
-## sensor.once(SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED)
+### GYROSCOPE_UNCALIBRATED
once(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,callback: Callback<GyroscopeUncalibratedResponse>): void
@@ -735,7 +715,7 @@ Subscribes to only one data change of the uncalibrated gyroscope sensor.
| callback | Callback<[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)> | Yes | One-shot callback used to return the uncalibrated gyroscope sensor data. The reported data type in the callback is **GyroscopeUncalibratedResponse**.|
**Example**
- ```
+ ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, function(data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
@@ -747,8 +727,7 @@ Subscribes to only one data change of the uncalibrated gyroscope sensor.
);
```
-
-## sensor.once(SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION)
+### SIGNIFICANT_MOTION
once(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION,callback: Callback<SignificantMotionResponse>): void
@@ -763,15 +742,14 @@ Subscribes to only one data change of the significant motion sensor.
| callback | Callback<[SignificantMotionResponse](#significantmotionresponse)> | Yes | One-shot callback used to return the significant motion sensor data. The reported data type in the callback is **SignificantMotionResponse**.|
**Example**
- ```
+ ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, function(data) {
console.info('Scalar data: ' + data.scalar);
}
);
```
-
-## sensor.once(SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION)
+### PEDOMETER_DETECTION
once(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION,callback: Callback<PedometerDetectionResponse>): void
@@ -788,15 +766,14 @@ Subscribes to only one data change of the pedometer detection sensor.
| callback | Callback<[PedometerDetectionResponse](#pedometerdetectionresponse)> | Yes | One-shot callback used to return the pedometer detection sensor data. The reported data type in the callback is **PedometerDetectionResponse**.|
**Example**
- ```
+ ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, function(data) {
console.info('Scalar data: ' + data.scalar);
}
);
```
-
-## sensor.once(SensorType.SENSOR_TYPE_ID_PEDOMETER)
+### PEDOMETER
once(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: Callback<PedometerResponse>): void
@@ -813,15 +790,14 @@ Subscribes to only one data change of the pedometer sensor.
| callback | Callback<[PedometerResponse](#pedometerresponse)> | Yes | One-shot callback used to return the pedometer sensor data. The reported data type in the callback is **PedometerResponse**.|
**Example**
- ```
+ ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, function(data) {
console.info('Steps: ' + data.steps);
}
);
```
-
-## sensor.once(SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE)
+### AMBIENT_TEMPERATURE
once(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,callback: Callback<AmbientTemperatureResponse>): void
@@ -836,15 +812,14 @@ Subscribes to only one data change of the ambient temperature sensor.
| callback | Callback<[AmbientTemperatureResponse](#ambienttemperatureresponse)> | Yes | One-shot callback used to return the ambient temperature sensor data. The reported data type in the callback is **AmbientTemperatureResponse**.|
**Example**
- ```
+ ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, function(data) {
console.info('Temperature: ' + data.temperature);
}
);
```
-
-## sensor.once(SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD)
+### MAGNETIC_FIELD
once(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: Callback<MagneticFieldResponse>): void
@@ -859,7 +834,7 @@ Subscribes to only one data change of the magnetic field sensor.
| callback | Callback<[MagneticFieldResponse](#magneticfieldresponse)> | Yes | One-shot callback used to return the magnetic field sensor data. The reported data type in the callback is **MagneticFieldResponse**.|
**Example**
- ```
+ ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, function(data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
@@ -868,8 +843,7 @@ Subscribes to only one data change of the magnetic field sensor.
);
```
-
-## sensor.once(SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED)
+### MAGNETIC_FIELD_UNCALIBRATED
once(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,callback: Callback<MagneticFieldUncalibratedResponse>): void
@@ -884,7 +858,7 @@ Subscribes to only one data change of the uncalibrated magnetic field sensor.
| callback | Callback<[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)> | Yes | One-shot callback used to return the uncalibrated magnetic field sensor data. The reported data type in the callback is **MagneticFieldUncalibratedResponse**.|
**Example**
- ```
+ ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, function(data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
@@ -896,8 +870,7 @@ Subscribes to only one data change of the uncalibrated magnetic field sensor.
);
```
-
-## sensor.once(SensorType.SENSOR_TYPE_ID_PROXIMITY)
+### PROXIMITY
once(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: Callback<ProximityResponse>): void
@@ -912,7 +885,7 @@ Subscribes to only one data change of the proximity sensor.
| callback | Callback<[ProximityResponse](#proximityresponse)> | Yes | One-shot callback used to return the proximity sensor data. The reported data type in the callback is **ProximityResponse**.|
**Example**
- ```
+ ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY, function(error, data) {
if (error) {
console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message);
@@ -923,8 +896,7 @@ Subscribes to only one data change of the proximity sensor.
);
```
-
-## sensor.once(SensorType.SENSOR_TYPE_ID_HUMIDITY)
+### HUMIDITY
once(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: Callback<HumidityResponse>): void
@@ -939,15 +911,14 @@ Subscribes to only one data change of the humidity sensor.
| callback | Callback<[HumidityResponse](#humidityresponse)> | Yes | One-shot callback used to return the humidity sensor data. The reported data type in the callback is **HumidityResponse**.|
**Example**
- ```
+ ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY, function(data) {
console.info('Humidity: ' + data.humidity);
}
);
```
-
-## sensor.once(SensorType.SENSOR_TYPE_ID_BAROMETER)
+### BAROMETER
once(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback: Callback<BarometerResponse>): void
@@ -962,15 +933,14 @@ Subscribes to only one data change of the barometer sensor.
| callback | Callback<[BarometerResponse](#barometerresponse)> | Yes | One-shot callback used to return the barometer sensor data. The reported data type in the callback is **BarometerResponse**.|
**Example**
- ```
+ ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, function(data) {
console.info('Atmospheric pressure: ' + data.pressure);
}
);
```
-
-## sensor.once(SensorType.SENSOR_TYPE_ID_HALL)
+### HALL
once(type: SensorType.SENSOR_TYPE_ID_HALL, callback: Callback<HallResponse>): void
@@ -985,15 +955,14 @@ Subscribes to only one data change of the Hall effect sensor.
| callback | Callback<[HallResponse](#hallresponse)> | Yes | One-shot callback used to return the Hall effect sensor data. The reported data type in the callback is **HallResponse**.|
**Example**
- ```
+ ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HALL, function(data) {
console.info('Status: ' + data.status);
}
);
```
-
-## sensor.once(SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT)
+### AMBIENT_LIGHT
once(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: Callback<LightResponse>): void
@@ -1008,15 +977,14 @@ Subscribes to only one data change of the ambient light sensor.
| callback | Callback<[LightResponse](#lightresponse)> | Yes | One-shot callback used to return the ambient light sensor data. The reported data type in the callback is **LightResponse**.|
**Example**
- ```
+ ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, function(data) {
console.info(' Illumination: ' + data.intensity);
}
);
```
-
-## sensor.once(SensorType.SENSOR_TYPE_ID_ORIENTATION)
+### ORIENTATION
once(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: Callback<OrientationResponse>): void
@@ -1031,7 +999,7 @@ Subscribes to only one data change of the orientation sensor.
| callback | Callback<[OrientationResponse](#orientationresponse)> | Yes | One-shot callback used to return the orientation sensor data. The reported data type in the callback is **OrientationResponse**.|
**Example**
- ```
+ ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, function(data) {
console.info('The device rotates at an angle around the X axis: ' + data.beta);
console.info('The device rotates at an angle around the Y axis: ' + data.gamma);
@@ -1040,8 +1008,7 @@ Subscribes to only one data change of the orientation sensor.
);
```
-
-## sensor.once(SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR)
+### ROTATION_VECTOR
once(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback: Callback<RotationVectorResponse>): void
@@ -1056,7 +1023,7 @@ Subscribes to only one data change of the rotation vector sensor.
| callback | Callback<[RotationVectorResponse](#rotationvectorresponse)> | Yes | One-shot callback used to return the rotation vector sensor data. The reported data type in the callback is **RotationVectorResponse**.|
**Example**
- ```
+ ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, function(data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
@@ -1066,8 +1033,7 @@ Subscribes to only one data change of the rotation vector sensor.
);
```
-
-## sensor.once(SensorType.SENSOR_TYPE_ID_HEART_RATE)
+### HEART_RATE
once(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: Callback<HeartRateResponse>): void
@@ -1084,15 +1050,14 @@ Subscribes to only one data change of the heart rate sensor.
| callback | Callback<[HeartRateResponse](#heartrateresponse)> | Yes | One-shot callback used to return the heart rate sensor data. The reported data type in the callback is **HeartRateResponse**.|
**Example**
- ```
+ ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HEART_RATE, function(data) {
console.info("Heart rate: " + data.heartRate);
}
);
```
-
-## sensor.once(SensorType.SENSOR_TYPE_ID_WEAR_DETECTION)
+### WEAR_DETECTION
once(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: Callback<WearDetectionResponse>): void
@@ -1107,14 +1072,16 @@ Subscribes to only one data change of the wear detection sensor.
| callback | Callback<[WearDetectionResponse](#weardetectionresponse)> | Yes | One-shot callback used to return the wear detection sensor data. The reported data type in the callback is **WearDetectionResponse**.|
**Example**
- ```
+ ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, function(data) {
console.info("Wear status: "+ data.value);
}
);
```
-## sensor.off(SensorType.SENSOR_TYPE_ID_ACCELEROMETER)
+## sensor.off
+
+### ACCELEROMETER
off(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback?: Callback<AccelerometerResponse>): void
@@ -1133,7 +1100,7 @@ Unsubscribes from sensor data changes.
**Example**
-```
+```js
function callback(data) {
console.info('x-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
@@ -1142,7 +1109,7 @@ function callback(data) {
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback);
```
-## sensor.off(SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED)
+### ACCELEROMETER_UNCALIBRATED
off(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, callback?: Callback<AccelerometerUncalibratedResponse>): void
@@ -1161,7 +1128,7 @@ Unsubscribes from sensor data changes.
**Example**
-```
+```js
function callback(data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
@@ -1173,7 +1140,7 @@ function callback(data) {
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, callback);
```
-## sensor.off(SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT)
+### AMBIENT_LIGHT
off(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback?: Callback<LightResponse>): void
@@ -1190,14 +1157,14 @@ Unsubscribes from sensor data changes.
**Example**
-```
+```js
function callback(data) {
console.info(' Illumination: ' + data.intensity);
}
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback);
```
-## sensor.off(SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE)
+### AMBIENT_TEMPERATURE
off(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, callback?: Callback<AmbientTemperatureResponse>): void
@@ -1214,14 +1181,14 @@ Unsubscribes from sensor data changes.
**Example**
-```
+```js
function callback(data) {
console.info('Temperature: ' + data.temperature);
}
sensor.off( sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, callback);
```
-## sensor.off(SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE)
+### AMBIENT_TEMPERATURE
off(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback?: Callback<BarometerResponse>): void
@@ -1238,14 +1205,14 @@ Unsubscribes from sensor data changes.
**Example**
-```
+```js
function callback(data) {
console.info('Atmospheric pressure: ' + data.pressure);
}
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, callback);
```
-## sensor.off(SensorType.SENSOR_TYPE_ID_GRAVITY)
+### GRAVITY
off(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback?: Callback<GravityResponse>): void
@@ -1262,7 +1229,7 @@ Unsubscribes from sensor data changes.
**Example**
-```
+```js
function callback(data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
@@ -1271,7 +1238,7 @@ function callback(data) {
sensor.off( sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback);
```
-## sensor.off(SensorType.SENSOR_TYPE_ID_GYROSCOPE)
+### GYROSCOPE
off(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback?: Callback<GyroscopeResponse>): void
@@ -1290,7 +1257,7 @@ Unsubscribes from sensor data changes.
**Example**
-```
+```js
function callback(data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
@@ -1299,7 +1266,7 @@ function callback(data) {
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback);
```
-## sensor.off(SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED)
+### GYROSCOPE_UNCALIBRATED
off(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, callback?: Callback<GyroscopeUncalibratedResponse>): void
@@ -1318,7 +1285,7 @@ Unsubscribes from sensor data changes.
**Example**
-```
+```js
function callback(data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
@@ -1327,7 +1294,7 @@ function callback(data) {
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, callback);
```
-## sensor.off(SensorType.SENSOR_TYPE_ID_HALL)
+### HALL
off(type: SensorType.SENSOR_TYPE_ID_HALL, callback?: Callback<HallResponse>): void
@@ -1344,14 +1311,14 @@ Unsubscribes from sensor data changes.
**Example**
-```
+```js
function callback(data) {
console.info('Status: ' + data.status);
}
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_HALL, callback);
```
-## sensor.off(SensorType.SENSOR_TYPE_ID_HEART_RATE)
+### HEART_RATE
off(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback?: Callback<HeartRateResponse>): void
@@ -1370,14 +1337,14 @@ Unsubscribes from sensor data changes.
**Example**
-```
+```js
function callback(data) {
console.info("Heart rate: " + data.heartRate);
}
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_HEART_RATE, callback);
```
-## sensor.off(SensorType.SENSOR_TYPE_ID_HUMIDITY)
+### HUMIDITY
off(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback?: Callback<HumidityResponse>): void
@@ -1396,14 +1363,14 @@ Unsubscribes from sensor data changes.
**Example**
-```
+```js
function callback(data) {
console.info('Humidity: ' + data.humidity);
}
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY, callback);
```
-## sensor.off(SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION)
+### LINEAR_ACCELERATION
off(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, callback?: Callback<LinearAccelerometerResponse>): void
@@ -1422,7 +1389,7 @@ Unsubscribes from sensor data changes.
**Example**
-```
+```js
function callback(data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
@@ -1431,7 +1398,7 @@ function callback(data) {
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, callback);
```
-## sensor.off(SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD)
+### MAGNETIC_FIELD
off(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback?: Callback<MagneticFieldResponse>): void
@@ -1450,7 +1417,7 @@ Unsubscribes from sensor data changes.
**Example**
-```
+```js
function callback(data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
@@ -1459,7 +1426,7 @@ function callback(data) {
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback);
```
-## sensor.off(SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED)
+### MAGNETIC_FIELD_UNCALIBRATED
off(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, callback?: Callback<MagneticFieldUncalibratedResponse>): void
@@ -1476,7 +1443,7 @@ Unsubscribes from sensor data changes.
**Example**
-```
+```js
function callback(data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
@@ -1488,7 +1455,7 @@ function callback(data) {
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, callback);
```
-## sensor.off(SensorType.SENSOR_TYPE_ID_ORIENTATION)
+### ORIENTATION
off(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback?: Callback<OrientationResponse>): void
@@ -1505,7 +1472,7 @@ Unsubscribes from sensor data changes.
**Example**
-```
+```js
function callback(data) {
console.info('The device rotates at an angle around the X axis: ' + data.beta);
console.info('The device rotates at an angle around the Y axis: ' + data.gamma);
@@ -1514,7 +1481,7 @@ function callback(data) {
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback);
```
-## sensor.off(SensorType.SENSOR_TYPE_ID_PEDOMETER)
+### PEDOMETER
off(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback?: Callback<PedometerResponse>): void
@@ -1529,16 +1496,16 @@ Unsubscribes from sensor data changes.
| type | [SensorType](#sensortype) | Yes | Type of the sensor to unsubscribe from, which is **SENSOR_TYPE_ID_PEDOMETER**. |
| callback | Callback<[PedometerResponse](#pedometerresponse)> | Yes | Callback used to return the pedometer sensor data. The reported data type in the callback is **PedometerResponse**.|
-**Return value**
+**Example**
-```
+```js
function callback(data) {
console.info('Steps: ' + data.steps);
}
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback);
```
-## sensor.off(SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION)
+### PEDOMETER_DETECTION
off(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback?: Callback<PedometerDetectionResponse>): void
@@ -1557,14 +1524,14 @@ Unsubscribes from sensor data changes.
**Example**
-```
+```js
function callback(data) {
console.info('Scalar data: ' + data.scalar);
}
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback);
```
-## sensor.off(SensorType.SENSOR_TYPE_ID_PROXIMITY)
+### PROXIMITY
off(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback?: Callback<ProximityResponse>): void
@@ -1581,14 +1548,14 @@ Unsubscribes from sensor data changes.
**Example**
-```
+```js
function callback(data) {
console.info('Distance: ' + data.distance);
}
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY, callback);
```
-## sensor.off(SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR)
+### ROTATION_VECTOR
off(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback?: Callback<RotationVectorResponse>): void
@@ -1605,7 +1572,7 @@ Unsubscribes from sensor data changes.
**Example**
-```
+```js
function callback(data) {
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
@@ -1615,7 +1582,7 @@ function callback(data) {
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback);
```
-## sensor.off(SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION)
+### SIGNIFICANT_MOTION
off(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback?: Callback<SignificantMotionResponse>): void
@@ -1632,14 +1599,14 @@ Unsubscribes from sensor data changes.
**Example**
-```
+```js
function callback(data) {
console.info('Scalar data: ' + data.scalar);
}
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback);
```
-## sensor.off(SensorType.SENSOR_TYPE_ID_WEAR_DETECTION)
+### WEAR_DETECTION
off(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback?: Callback<WearDetectionResponse>): void
@@ -1656,7 +1623,7 @@ Unsubscribes from sensor data changes.
**Example**
-```
+```js
function accCallback(data) {
console.info('Wear status: ' + data.value);
}
@@ -1681,13 +1648,13 @@ Rotates a rotation vector so that it can represent the coordinate system in diff
**Example**
-```
-sensor.transformCoordinateSystem([1, 0, 0, 0, 1, 0, 0, 0, 1], {'axisX':2, 'axisY':3}, function(err, data) {
+```js
+sensor.transformCoordinateSystem([1, 0, 0, 0, 1, 0, 0, 0, 1], {x:2, y:3}, function(err, data) {
if (err) {
console.error("Operation failed. Error code: " + err.code + ", message: " + err.message);
return;
}
- console.info("Operation successed. Data obtained: " + data.x);
+ console.info("Operation successed. Data obtained: " + data);
for (var i=0; i < data.length; i++) {
console.info("transformCoordinateSystem data[ " + i + "] = " + data[i]);
}
@@ -1716,8 +1683,8 @@ Rotates a rotation vector so that it can represent the coordinate system in diff
**Example**
-```
-const promise = sensor.transformCoordinateSystem([1, 0, 0, 0, 1, 0, 0, 0, 1], {'axisX':2, 'axisY':3});
+```js
+const promise = sensor.transformCoordinateSystem([1, 0, 0, 0, 1, 0, 0, 0, 1], {x:2, y:3});
promise.then((data) => {
console.info("Operation successed.");
for (var i=0; i < data.length; i++) {
@@ -1744,8 +1711,8 @@ Obtains the geomagnetic field of a geographic location. This API uses a callback
| callback | AsyncCallback<[GeomagneticResponse](#geomagneticresponse)> | Yes | Callback used to return the geomagnetic field. |
**Example**
-```
-sensor.getGeomagneticField([80, 0, 0], 1580486400000, function(err, data) {
+```js
+sensor.getGeomagneticField({latitude:80, longitude:0, altitude:0}, 1580486400000, function(err, data) {
if (err) {
console.error('Operation failed. Error code: ' + err.code + '; message: ' + err.message);
return;
@@ -1772,11 +1739,11 @@ Obtains the geomagnetic field of a geographic location. This API uses a promise
**Return value**
| Type | Description |
| ---------------------------------------- | ------- |
-| Promise<[GeomagneticResponse](#geomagneticresponse)> | Promise used to return the geomagnetic field.|
+| Promise<[GeomagneticResponse](#geomagneticresponse)> | Promise used to return the geomagnetic field. |
-**Return value**
- ```
- const promise = sensor.getGeomagneticField([80, 0, 0], 1580486400000);
+**Example**
+ ```js
+ const promise = sensor.getGeomagneticField({latitude:80, longitude:0, altitude:0}, 1580486400000);
promise.then((data) => {
console.info('sensor_getGeomagneticField_promise x: ' + data.x + ',y: ' + data.y + ',z: ' +
data.z + ',geomagneticDip: ' + data.geomagneticDip + ',deflectionAngle: ' + data.deflectionAngle +
@@ -1802,9 +1769,9 @@ Obtains the altitude at which the device is located based on the sea-level atmos
| currentPressure | number | Yes | Atmospheric pressure at the altitude where the device is located, in hPa.|
| callback | AsyncCallback<number> | Yes | Callback used to return the altitude, in meters. |
-**Return value**
+**Example**
- ```
+ ```js
sensor.getAltitude(0, 200, function(err, data) {
if (err) {
console.error(
@@ -1836,9 +1803,9 @@ Obtains the altitude at which the device is located based on the sea-level atmos
| --------------------- | ------------------ |
| Promise<number> | Promise used to return the altitude, in meters.|
-**Return value**
+**Example**
- ```
+ ```js
const promise = sensor.getAltitude(0, 200);
promise.then((data) => {
console.info(' sensor_getAltitude_Promise success', data);
@@ -1863,12 +1830,12 @@ Obtains the magnetic dip based on the inclination matrix. This API uses a callba
| inclinationMatrix | Array<number> | Yes | Inclination matrix. |
| callback | AsyncCallback<number> | Yes | Callback used to return the magnetic dip, in radians.|
-**Return value**
+**Example**
- ```
+ ```js
sensor.getGeomagneticDip([1, 0, 0, 0, 1, 0, 0, 0, 1], function(err, data) {
if (err) {
- console.error(LABEL + 'SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' +
+ console.error('SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' +
err.message);
return;
}
@@ -1896,9 +1863,9 @@ Obtains the magnetic dip based on the inclination matrix. This API uses a promis
| --------------------- | -------------- |
| Promise<number> | Promise used to return the magnetic dip, in radians.|
-**Return value**
+**Example**
- ```
+ ```js
const promise = sensor.getGeomagneticDip([1, 0, 0, 0, 1, 0, 0, 0, 1]);
promise.then((data) => {
console.info(' getGeomagneticDip_promise successed', data);
@@ -1923,18 +1890,18 @@ Obtains the angle change between two rotation matrices. This API uses a callback
| preRotationMatrix | Array<number> | Yes | The other rotation matrix. |
| callback | AsyncCallback<Array<number>> | Yes | Callback used to return the angle change around the z, x, and y axes.|
-**Return value**
+**Example**
- ```
+ ```js
sensor. getAngleModify([1,0,0,0,1,0,0,0,1], [1, 0, 0, 0, 0.87, -0.50, 0, 0.50, 0.87], function(err, data) {
if (err) {
- console.error(LABEL + 'Failed to register data, error code is: ' + err.code + ', message: ' +
+ console.error('Failed to register data, error code is: ' + err.code + ', message: ' +
err.message);
return;
}
console.info("SensorJsAPI--->Successed to get getAngleModifiy interface get data: " + data.x);
for (var i=0; i < data.length; i++) {
- console.info(LABEL + "data[" + i + "]: " + data[i]);
+ console.info("data[" + i + "]: " + data[i]);
}
})
```
@@ -1961,17 +1928,17 @@ Obtains the angle change between two rotation matrices. This API uses a promise
| ---------------------------------- | ------------------ |
| Promise<Array<number>> | Promise used to return the angle change around the z, x, and y axes.|
-**Return value**
+**Example**
- ```
+ ```js
const promise = sensor.getAngleModify([1,0,0,0,1,0,0,0,1], [1,0,0,0,0.87,-0.50,0,0.50,0.87]);
promise.then((data) => {
- console.info(LABEL + 'getAngleModifiy_promise success');
+ console.info('getAngleModifiy_promise success');
for (var i=0; i < data.length; i++) {
- console.info(LABEL + "data[" + i + "]: " + data[i]);
+ console.info("data[" + i + "]: " + data[i]);
}
}).catch((reason) => {
- console.info(LABEL + "promise::catch", reason);
+ console.info("promise::catch", reason);
})
```
@@ -1991,18 +1958,18 @@ Converts a rotation vector into a rotation matrix. This API uses a callback to r
| rotationVector | Array<number> | Yes | Rotation vector to convert.|
| callback | AsyncCallback<Array<number>> | Yes | Callback used to return the rotation matrix.|
-**Return value**
+**Example**
- ```
+ ```js
sensor.createRotationMatrix([0.20046076, 0.21907, 0.73978853, 0.60376877], function(err, data) {
if (err) {
- console.error(LABEL + 'SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' +
+ console.error('SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' +
err.message);
return;
}
console.info("SensorJsAPI--->Successed to get createRotationMatrix interface get data: " + data.x);
for (var i=0; i < data.length; i++) {
- console.info(LABEL + "data[" + i + "]: " + data[i]);
+ console.info("data[" + i + "]: " + data[i]);
}
})
```
@@ -2028,17 +1995,17 @@ Converts a rotation vector into a rotation matrix. This API uses a promise to re
| ---------------------------------- | ------- |
| Promise<Array<number>> | Promise used to return the rotation matrix.|
-**Return value**
+**Example**
- ```
+ ```js
const promise = sensor.createRotationMatrix([0.20046076, 0.21907, 0.73978853, 0.60376877]);
promise.then((data) => {
- console.info(LABEL + 'createRotationMatrix_promise success');
+ console.info('createRotationMatrix_promise success');
for (var i=0; i < data.length; i++) {
- console.info(LABEL + "data[" + i + "]: " + data[i]);
+ console.info("data[" + i + "]: " + data[i]);
}
}).catch((reason) => {
- console.info(LABEL + "promise::catch", reason);
+ console.info("promise::catch", reason);
})
```
@@ -2058,18 +2025,18 @@ Converts a rotation vector into a quaternion. This API uses a callback to return
| rotationVector | Array<number> | Yes | Rotation vector to convert.|
| callback | AsyncCallback<Array<number>> | Yes | Callback used to return the quaternion. |
-**Return value**
+**Example**
- ```
+ ```js
sensor.createQuaternion([0.20046076, 0.21907, 0.73978853, 0.60376877], function(err, data) {
if (err) {
- console.error(LABEL + 'SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' +
+ console.error('SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' +
err.message);
return;
}
console.info("SensorJsAPI--->Successed to get createQuaternion interface get data: " + data.x);
for (var i=0; i < data.length; i++) {
- console.info(LABEL + "data[" + i + "]: " + data[i]);
+ console.info("data[" + i + "]: " + data[i]);
}
})
```
@@ -2095,14 +2062,14 @@ Converts a rotation vector into a quaternion. This API uses a promise to return
| ---------------------------------- | ------ |
| Promise<Array<number>> | Promise used to return the quaternion.|
-**Return value**
+**Example**
- ```
+ ```js
const promise = sensor.createQuaternion([0.20046076, 0.21907, 0.73978853, 0.60376877]);
promise.then((data) => {
console.info('createQuaternion_promise successed');
for (var i=0; i < data.length; i++) {
- console.info(LABEL + "data[" + i + "]: " + data[i]);
+ console.info("data[" + i + "]: " + data[i]);
}
}).catch((err) => {
console.info('promise failed');
@@ -2125,18 +2092,18 @@ Obtains the device direction based on the rotation matrix. This API uses a callb
| rotationMatrix | Array<number> | Yes | Rotation matrix. |
| callback | AsyncCallback<Array<number>> | Yes | Callback used to return the rotation angle around the z, x, and y axes.|
-**Return value**
+**Example**
- ```
+ ```js
sensor.getDirection([1, 0, 0, 0, 1, 0, 0, 0, 1], function(err, data) {
if (err) {
- console.error(LABEL + 'SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' +
+ console.error('SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' +
err.message);
return;
}
- console.info(LABEL + "SensorJsAPI--->Successed to get getDirection interface get data: " + data.x);
+ console.info("SensorJsAPI--->Successed to get getDirection interface get data: " + data);
for (var i = 1; i < data.length; i++) {
- console.info(TAG +"sensor_getDirection_callback" + data[i]);
+ console.info("sensor_getDirection_callback" + data[i]);
}
})
```
@@ -2162,14 +2129,14 @@ Obtains the device direction based on the rotation matrix. This API uses a promi
| ---------------------------------- | ------------------ |
| Promise<Array<number>> | Promise used to return the rotation angle around the z, x, and y axes.|
-**Return value**
+**Example**
- ```
+ ```js
const promise = sensor.getDirection([1, 0, 0, 0, 1, 0, 0, 0, 1]);
promise.then((data) => {
- console.info(' sensor_getAltitude_Promise success', data.x);
+ console.info('sensor_getAltitude_Promise success', data);
for (var i = 1; i < data.length; i++) {
- console.info(TAG +"sensor_getDirection_promise" + data[i]);
+ console.info("sensor_getDirection_promise" + data[i]);
}
}).catch((err) => {
console.info('promise failed');
@@ -2193,18 +2160,18 @@ Creates a rotation matrix based on the gravity vector and geomagnetic vector. Th
| geomagnetic | Array<number> | Yes | Geomagnetic vector.|
| callback | AsyncCallback<[RotationMatrixResponse](#rotationmatrixresponse)> | Yes | Callback used to return the rotation matrix.|
-**Return value**
+**Example**
- ```
+ ```js
sensor.createRotationMatrix([-0.27775216, 0.5351276, 9.788099], [210.87253, -78.6096, -111.44444], function(err, data) {
if (err) {
- console.error(LABEL + 'SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' +
+ console.error('SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' +
err.message);
return;
}
console.info("SensorJsAPI--->Successed to get createRotationMatrix interface get data: " + data.x);
for (var i=0; i < data.length; i++) {
- console.info(LABEL + "data[" + i + "]: " + data[i])
+ console.info("data[" + i + "]: " + data[i])
}
})
```
@@ -2231,17 +2198,17 @@ Creates a rotation matrix based on the gravity vector and geomagnetic vector. Th
| ---------------------------------------- | ------- |
| Promise<[RotationMatrixResponse](#rotationmatrixresponse)> | Promise used to return the rotation matrix.|
-**Return value**
+**Example**
- ```
+ ```js
const promise = sensor.createRotationMatrix([-0.27775216, 0.5351276, 9.788099], [210.87253, -78.6096, -111.44444]);
promise.then((data) => {
- console.info(LABEL + 'createRotationMatrix_promise successed');
+ console.info('createRotationMatrix_promise successed');
for (var i=0; i < data.length; i++) {
- console.info(LABEL + "data[" + i + "]: " + data[i]);
+ console.info("data[" + i + "]: " + data[i]);
}
}).catch((err) => {
- console.info(LABEL + 'promise failed');
+ console.info('promise failed');
})
```
@@ -2355,11 +2322,11 @@ Describes the orientation sensor data. It extends from [Response](#response).
**System capability**: SystemCapability.Sensors.Sensor
-| Name | Type | Readable | Writable | Description |
-| ----- | ------ | ---- | ---- | ------------------------ |
+| Name | Type | Readable | Writable | Description |
+| ----- | ------ | ---- | ---- | ----------------- |
| alpha | number | Yes | Yes | Rotation angle of the device around the z-axis, in degrees.|
-| beta | number | Yes | Yes | Rotation angle of the device around the x-axis, in degrees. |
-| gamma | number | Yes | Yes | Rotation angle of the device around the y-axis, in degrees. |
+| beta | number | Yes | Yes | Rotation angle of the device around the x-axis, in degrees.|
+| gamma | number | Yes | Yes | Rotation angle of the device around the y-axis, in degrees.|
## RotationVectorResponse
diff --git a/en/application-dev/reference/apis/js-apis-service-extension-ability.md b/en/application-dev/reference/apis/js-apis-service-extension-ability.md
index 55e18ad1fa75577fb8e711e15dffac4e339b98eb..b66c29fe1834b589ee9ffd32eb598e5c53dc2e0a 100644
--- a/en/application-dev/reference/apis/js-apis-service-extension-ability.md
+++ b/en/application-dev/reference/apis/js-apis-service-extension-ability.md
@@ -1,31 +1,29 @@
# ServiceExtensionAbility
-> **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.
-
+> **NOTE**
+>
+> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+> The APIs of this module can be used only in the stage model.
Provides APIs related to **ServiceExtension**.
-
## Modules to Import
```
import ServiceExtension from '@ohos.application.ServiceExtensionAbility';
```
-
## Required Permissions
None.
-
## Attributes
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-| Name| Type| Readable| Writable| Description|
+| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| context | [ServiceExtensionContext](js-apis-service-extension-context.md) | Yes| No| Service extension context, which is inherited from **ExtensionContext**.|
+| context | [ServiceExtensionContext](js-apis-service-extension-context.md) | Yes| No| Service extension context, which is inherited from **ExtensionContext**.|
## ServiceExtensionAbility.onCreate
@@ -38,9 +36,9 @@ Called when an extension is created to initialize the service logic.
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| want | [Want](js-apis-application-Want.md) | Yes| Information related to this extension, including the ability name and bundle name.|
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | want | [Want](js-apis-application-Want.md) | Yes| Information related to this extension, including the ability name and bundle name.|
**Example**
@@ -82,10 +80,10 @@ Called after **onCreate** is invoked when an ability is started by calling **sta
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| want | [Want](js-apis-application-Want.md) | Yes| Information related to this extension, including the ability name and bundle name.|
-| startId | number | Yes| Number of ability start times. The initial value is **1**, and the value is automatically incremented for each ability started.|
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | want | [Want](js-apis-application-Want.md) | Yes| Information related to this extension, including the ability name and bundle name.|
+ | startId | number | Yes| Number of ability start times. The initial value is **1**, and the value is automatically incremented for each ability started.|
**Example**
@@ -108,15 +106,15 @@ Called after **onCreate** is invoked when an ability is started by calling **con
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| want | [Want](js-apis-application-Want.md)| Yes| Information related to this extension, including the ability name and bundle name.|
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | want | [Want](js-apis-application-Want.md)| Yes| Information related to this extension, including the ability name and bundle name.|
**Return value**
-| Type| Description|
-| -------- | -------- |
-| rpc.RemoteObject | A **RemoteObject** object used for communication with the client.|
+ | Type| Description|
+ | -------- | -------- |
+ | rpc.RemoteObject | A **RemoteObject** object used for communication with the client.|
**Example**
@@ -148,9 +146,9 @@ Called when the ability is disconnected.
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| want |[Want](js-apis-application-Want.md)| Yes| Information related to this extension, including the ability name and bundle name.|
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | want |[Want](js-apis-application-Want.md)| Yes| Information related to this extension, including the ability name and bundle name.|
**Example**
diff --git a/en/application-dev/reference/apis/js-apis-service-extension-context.md b/en/application-dev/reference/apis/js-apis-service-extension-context.md
index a11942cf16b785967a8491e46a06d8ad820359aa..518167d562ba8801223e206ad5b35ea07ea94936 100644
--- a/en/application-dev/reference/apis/js-apis-service-extension-context.md
+++ b/en/application-dev/reference/apis/js-apis-service-extension-context.md
@@ -1,11 +1,17 @@
# ServiceExtensionContext
->  **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.
-
+> **NOTE**
+>
+> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+> The APIs of this module can be used only in the stage model.
Implements the context that provides the capabilities and APIs of **ServiceExtension**. This class is inherited from **ExtensionContext**.
+## Modules to Import
+
+```
+import ExtensionContext from '@ohos.application.ServiceExtensionAbility';
+```
## startAbility
@@ -25,13 +31,18 @@ Starts an ability. This API uses a callback to return the result.
**Example**
```js
- let want = {
- "bundleName": "com.example.myapp",
- "abilityName": "com.example.myapp.MyAbility"
- };
- this.context.startAbility(want, (err) => {
- console.log('startAbility result:' + JSON.stringfy(err));
- });
+ import ExtensionContext from '@ohos.application.ServiceExtensionAbility';
+ class MainAbility extends ExtensionContext {
+ onWindowStageCreate(windowStage) {
+ let want = {
+ "bundleName": "com.example.myapp",
+ "abilityName": "MyAbility"};
+ this.context.startAbility(want, (err) => {
+ console.log('startAbility result:' + JSON.stringify(err));
+ });
+ }
+ }
+
```
@@ -58,15 +69,22 @@ Starts an ability. This API uses a promise to return the result.
**Example**
```js
- let want = {
- "bundleName": "com.example.myapp",
- "abilityName": "com.example.myapp.MyAbility"
- };
- this.context.startAbility(want).then((data) => {
- console.log('success:' + JSON.stringfy(data));
- }).catch((error) => {
- console.log('failed:' + JSON.stringfy(error));
- });
+ import ExtensionContext from '@ohos.application.ServiceExtensionAbility';
+ class MainAbility extends ExtensionContext {
+ onWindowStageCreate(windowStage) {
+ let want = {
+ "bundleName": "com.example.myapp",
+ "abilityName": "MyAbility"
+ };
+ this.context.startAbility(want).then((data) => {
+ console.log('success:' + JSON.stringify(data));
+ }).catch((error) => {
+ console.log('failed:' + JSON.stringify(error));
+ });
+ }
+ }
+
+
```
@@ -87,9 +105,16 @@ Terminates this ability. This API uses a callback to return the result.
**Example**
```js
- this.context.terminateSelf((err) => {
- console.log('terminateSelf result:' + JSON.stringfy(err));
- });
+ import ExtensionContext from '@ohos.application.ServiceExtensionAbility';
+ class MainAbility extends ExtensionContext {
+ onWindowStageCreate(windowStage) {
+ this.context.terminateSelf((err) => {
+ console.log('terminateSelf result:' + JSON.stringify(err));
+ });
+ }
+ }
+
+
```
@@ -110,11 +135,17 @@ Terminates this ability. This API uses a promise to return the result.
**Example**
```js
- this.context.terminateSelf(want).then((data) => {
- console.log('success:' + JSON.stringfy(data));
- }).catch((error) => {
- console.log('failed:' + JSON.stringfy(error));
- });
+ import ExtensionContext from '@ohos.application.ServiceExtensionAbility';
+ class MainAbility extends ExtensionContext {
+ onWindowStageCreate(windowStage) {
+ this.context.terminateSelf().then((data) => {
+ console.log('success:' + JSON.stringify(data));
+ }).catch((error) => {
+ console.log('failed:' + JSON.stringify(error));
+ });
+ }
+}
+
```
@@ -144,7 +175,7 @@ Connects this ability to a Service ability.
```js
let want = {
"bundleName": "com.example.myapp",
- "abilityName": "com.example.myapp.MyAbility"
+ "abilityName": "MyAbility"
};
let options = {
onConnect: function(elementName, proxy) {},
@@ -173,9 +204,18 @@ Disconnects this ability from the Service ability. This API uses a callback to r
**Example**
```js
- this.context.disconnectAbility(connection, (err) => { // connection is the return value of connectAbility.
- console.log('terminateSelf result:' + JSON.stringfy(err));
- });
+ import ExtensionContext from '@ohos.application.ServiceExtensionAbility';
+ class MainAbility extends ExtensionContext {
+ onWindowStageCreate(windowStage) {
+ let connection=1
+ this.context.disconnectAbility(connection, (err) => {
+ // connection is the return value of connectAbility.
+ console.log('terminateSelf result:' + JSON.stringify(err));
+ });
+ }
+ }
+
+
```
@@ -202,11 +242,18 @@ Disconnects this ability from the Service ability. This API uses a promise to re
**Example**
```js
- this.context.disconnectAbility(connection).then((data) => { // connection is the return value of connectAbility.
- console.log('success:' + JSON.stringfy(data));
- }).catch((error) => {
- console.log('failed:' + JSON.stringfy(error));
- });
+ import ExtensionContext from '@ohos.application.ServiceExtensionAbility';
+ class MainAbility extends ExtensionContext {
+ onWindowStageCreate(windowStage) {
+ let connection=1
+ this.context.disconnectAbility(connection).then((data) => { // connection is the return value of connectAbility.
+ console.log('success:' + JSON.stringify(data));
+ }).catch((error) => {
+ console.log('failed:' + JSON.stringify(error));
+ });
+ }
+ }
+
```
diff --git a/en/application-dev/reference/apis/js-apis-settings.md b/en/application-dev/reference/apis/js-apis-settings.md
index 83b3ac3920ac5fe6bca78974f664174157da86b0..73be3dd9605235802e6bcd78992ff47d6cd1c469 100644
--- a/en/application-dev/reference/apis/js-apis-settings.md
+++ b/en/application-dev/reference/apis/js-apis-settings.md
@@ -1,6 +1,7 @@
# Settings
-> **NOTE**
+> **NOTE**
+>
> The initial APIs of this module are supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version.
@@ -27,7 +28,7 @@ Obtains the URI of a data item.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| name | string | Yes| Name of the target data item. Data items can be classified as follows:
Existing data items in the database, for example:
Brightness: 'settings.screen.brightness'
Time format: 'settings.time.format'
Custom data items
|
+| name | string | Yes| Name of the target data item. Data items can be classified as follows:
|
**Return value**
@@ -39,7 +40,7 @@ Obtains the URI of a data item.
```typescript
// Obtain the URI of a data item.
- let urivar = settings.getUriSync('settings.screen.brightness');
+ let urivar = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS);
```
@@ -55,7 +56,7 @@ Obtains the value of a data item.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| dataAbilityHelper | [DataAbilityHelper](js-apis-dataAbilityHelper.md) | Yes| **DataAbilityHelper** class.|
-| name | string | Yes| Name of the target data item. Data items can be classified as follows:
Existing data items in the database, for example:
Brightness: 'settings.screen.brightness'
Time format: 'settings.time.format'
Custom data items
|
+| name | string | Yes| Name of the target data item. Data items can be classified as follows:
|
| defValue | string | Yes| Default value This parameter is user-defined. If it is not found in the database, the default value is returned.|
**Return value**
@@ -69,11 +70,10 @@ Obtains the value of a data item.
```typescript
import featureAbility from '@ohos.ability.featureAbility';
-// Obtain the value of 'settings.screen.brightness' (this data item already exists in the database).
-let brightness = 'settings.screen.brightness';
-let uri = settings.getUriSync(brightness);
+// Obtain the value of settings.display.SCREEN_BRIGHTNESS_STATUS (this data item already exists in the database).
+let uri = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS);
let helper = featureAbility.acquireDataAbilityHelper(uri);
-let value = settings.getValueSync(helper, brightness, '10');
+let value = settings.getValueSync(helper, settings.display.SCREEN_BRIGHTNESS_STATUS, '10');
```
@@ -85,7 +85,7 @@ Sets the value of a data item.
If the specified data item exists in the database, the **setValueSync** method updates the value of the data item. If the data item does not exist in the database, the **setValueSync** method inserts the data item into the database.
-**Required permissions**: ohos.permission.WRITE_SYSTEM_SETTING
+**Required permissions**: ohos.permission.MODIFY_SETTINGS
**System capability**: SystemCapability.Applictaions.settings.Core
@@ -94,7 +94,7 @@ If the specified data item exists in the database, the **setValueSync** method u
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| dataAbilityHelper | [DataAbilityHelper](js-apis-dataAbilityHelper.md) | Yes| **DataAbilityHelper** class.|
-| name | string | Yes| Name of the target data item. Data items can be classified as follows:
Existing data items in the database, for example:
Brightness: 'settings.screen.brightness'
Time format: 'settings.time.format'
Custom data items
|
+| name | string | Yes| Name of the target data item. Data items can be classified as follows:
|
| value | string | Yes| Value of the data item.|
**Return value**
@@ -108,10 +108,9 @@ If the specified data item exists in the database, the **setValueSync** method u
```typescript
import featureAbility from '@ohos.ability.featureAbility';
-// Update the value of 'settings.screen.brightness'. (As this data item exists in the database, the setValueSync
+// Update the value of settings.display.SCREEN_BRIGHTNESS_STATUS. (As this data item exists in the database, the setValueSync
method will update the value of the data item.)
-let brightness = 'settings.screen.brightness';
-let uri = settings.getUriSync(brightness);
+let uri = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS);
let helper = featureAbility.acquireDataAbilityHelper(uri);
-let ret = settings.setValueSync(helper, brightness, '100');
+let ret = settings.setValueSync(helper, settings.display.SCREEN_BRIGHTNESS_STATUS, '100');
```
\ No newline at end of file
diff --git a/en/application-dev/reference/apis/js-apis-sim.md b/en/application-dev/reference/apis/js-apis-sim.md
index f1f20e8d810c3f3fa648e680d494199e30bc1dfe..3344e47d14f8d615b1f81e75f92251dc4e8c8287 100644
--- a/en/application-dev/reference/apis/js-apis-sim.md
+++ b/en/application-dev/reference/apis/js-apis-sim.md
@@ -521,7 +521,7 @@ Obtains the number of card slots.
**Example**
```js
-console.log(sim.getMaxSimCount())
+console.log("Result: "+ sim.getMaxSimCount())
```
diff --git a/en/application-dev/reference/apis/js-apis-stack.md b/en/application-dev/reference/apis/js-apis-stack.md
index 245f4f88fd48e8b3b3ba2263e67fe0a33e95959b..b1e10e9478bc3335b30cd85498f9feb81b07bfd1 100644
--- a/en/application-dev/reference/apis/js-apis-stack.md
+++ b/en/application-dev/reference/apis/js-apis-stack.md
@@ -1,28 +1,33 @@
# Linear Container Stack
->  **NOTE**
+> **NOTE**
+>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+**Stack** is implemented based on the array data structure. It follows the principle Last Out First In (LOFI) and supports data insertion and removal at one end.
+
+Unlike **[Queue](js-apis-queue.md)**, which is implemented based on the queue data structure and supports insertion at one end and removal at the other end, **Stack** supports insertion and removal at the same end.
+
+**Recommended use case**: Use **Stack** in LOFI scenarios.
## Modules to Import
```ts
-import Stack from '@ohos.util.Stack'
+import Stack from '@ohos.util.Stack';
```
-## System Capabilities
-SystemCapability.Utils.Lang
## Stack
-
### Attributes
+**System capability**: SystemCapability.Utils.Lang
+
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| length | number | Yes| No| Number of entries in a stack (called container later).|
+| length | number | Yes| No| Number of elements in a stack (called container later).|
### constructor
@@ -31,6 +36,8 @@ constructor()
A constructor used to create a **Stack** instance.
+**System capability**: SystemCapability.Utils.Lang
+
**Example**
```ts
@@ -42,13 +49,15 @@ let stack = new Stack();
push(item: T): T
-Adds an entry at the top of this container.
+Adds an element at the top of this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| item | T | Yes| Element to add.|
+| item | T | Yes| Target element.|
**Return value**
@@ -72,13 +81,15 @@ let result3 = stack.push(c);
pop(): T
-Removes the top entry from this container.
+Removes the top element from this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Return value**
| Type| Description|
| -------- | -------- |
-| T | Entry removed.|
+| T | Element removed.|
**Example**
@@ -96,13 +107,15 @@ let result = stack.pop();
peek(): T
-Obtains the top entry of this container.
+Obtains the top element of this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Return value**
| Type| Description|
| -------- | -------- |
-| T | Entry obtained.|
+| T | Element obtained.|
**Example**
@@ -119,19 +132,21 @@ let result = stack.peek();
locate(element: T): number
-Obtains the index of the first occurrence of the specified entry in this container.
+Obtains the index of the first occurrence of the specified element in this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| element | T | Yes| Entry to query.|
+| element | T | Yes| Target element.|
**Return value**
| Type| Description|
| -------- | -------- |
-| number | Returns the position index if obtained; returns **-1** if the specified entry is not found.|
+| number | Returns the position index if obtained; returns **-1** otherwise.|
**Example**
@@ -149,21 +164,23 @@ let result = stack.locate(2);
forEach(callbackfn: (value: T, index?: number, stack?: Stack<T>) => void,
thisArg?: Object): void
-Uses a callback to traverse the entries in this container and obtain their position indexes.
+Uses a callback to traverse the elements in this container and obtain their position indexes.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| callbackfn | function | Yes| Callback invoked to traverse the entries in the container.|
+| callbackfn | function | Yes| Callback invoked to traverse the elements in the container.|
| thisArg | Object | No| Value to use when the callback is invoked.|
callbackfn
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| value | T | Yes| Value of the entry that is currently traversed.|
-| index | number | No| Position index of the entry that is currently traversed.|
+| value | T | Yes| Value of the element that is currently traversed.|
+| index | number | No| Position index of the element that is currently traversed.|
| stack | Stack<T> | No| Instance that invokes the **forEach** method.|
**Example**
@@ -175,7 +192,7 @@ stack.push(4);
stack.push(5);
stack.push(4);
stack.forEach((value, index) => {
- console.log(value, index);
+ console.log("value:" + value, index);
});
```
@@ -183,7 +200,9 @@ stack.forEach((value, index) => {
isEmpty(): boolean
-Checks whether this container is empty (contains no entries).
+Checks whether this container is empty (contains no elements).
+
+**System capability**: SystemCapability.Utils.Lang
**Return value**
@@ -206,9 +225,10 @@ let result = stack.isEmpty();
[Symbol.iterator]\(): IterableIterator<T>
-
Obtains an iterator, each item of which is a JavaScript object.
+**System capability**: SystemCapability.Utils.Lang
+
**Return value**
| Type| Description|
@@ -225,14 +245,14 @@ stack.push(4);
// Method 1:
for (let item of stack) {
- console.log(item);
+ console.log("value:" + item);
}
// Method 2:
let iter = stack[Symbol.iterator]();
let temp = iter.next().value;
while(temp != undefined) {
- console.log(temp);
+ console.log("value:" + temp);
temp = iter.next().value;
}
```
diff --git a/en/application-dev/reference/apis/js-apis-storage-statistics.md b/en/application-dev/reference/apis/js-apis-storage-statistics.md
index 3cb85add7ff167a0366e7944d5731b70425d6904..a0b973cb896a595e5361d5a441ab184bf0339b3d 100644
--- a/en/application-dev/reference/apis/js-apis-storage-statistics.md
+++ b/en/application-dev/reference/apis/js-apis-storage-statistics.md
@@ -5,7 +5,7 @@
> - The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - API version 9 is a canary version for trial use. The APIs of this version may be unstable.
-The APIs of this module can be used to obtain storage space information, including the space of built-in and plug-in memory cards, space occupied by different types of data, and space of application data.
+Obtains storage space information, including the space of built-in and plug-in memory cards, space occupied by different types of data, and space of application data.
## Modules to Import
@@ -148,7 +148,7 @@ Asynchronously obtains the available space of the specified volume. This API use
getBundleStats(packageName: string): Promise<BundleStats>
-Asynchronously obtains information about an application. This API uses a promise to return the result.
+Asynchronously obtains space information of an application. This API uses a promise to return the result.
**Required permissions**: ohos.permission.STORAGE_MANAGER
@@ -166,7 +166,7 @@ Asynchronously obtains information about an application. This API uses a promise
| Type | Description |
| ------------------------------------------ | -------------------------- |
- | Promise<[Bundlestats](#bundlestats)> | Promise used to return the application information obtained.|
+ | Promise<[Bundlestats](#bundlestats)> | Promise used to return the space information obtained.|
- Example
@@ -183,7 +183,7 @@ Asynchronously obtains information about an application. This API uses a promise
getBundleStats(packageName: string, callback: AsyncCallback<BundleStats>): void
-Asynchronously obtains information about an application. This API uses a callback to return the result.
+Asynchronously obtains space information of an application. This API uses a callback to return the result.
**Required permissions**: ohos.permission.STORAGE_MANAGER
@@ -196,7 +196,7 @@ Asynchronously obtains information about an application. This API uses a callbac
| Name | Type | Mandatory| Description |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------ |
| packageName | string | Yes | Bundle name of the application.|
- | callback | callback:AsyncCallback<[Bundlestats](#bundlestats)> | Yes | Callback invoked to return the application information obtained.|
+ | callback | callback:AsyncCallback<[Bundlestats](#bundlestats)> | Yes | Callback invoked to return the space information obtained.|
- Example
@@ -214,7 +214,7 @@ Asynchronously obtains information about an application. This API uses a callbac
getCurrentBundleStats(): Promise
-Asynchronously obtains information about the current third-party application. This API uses a promise to return the result.
+Asynchronously obtains space information of the current third-party application. This API uses a promise to return the result.
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
@@ -222,7 +222,7 @@ Asynchronously obtains information about the current third-party application. Th
| Type | Description |
| ------------------------------------------ | -------------------------- |
- | Promise<[Bundlestats](#bundlestats)> | Promise used to return the application information obtained. |
+ | Promise<[Bundlestats](#bundlestats)> | Promise used to return the space information obtained. |
- Example
@@ -235,15 +235,15 @@ Asynchronously obtains information about the current third-party application. Th
getCurrentBundleStats(callback: AsyncCallback): void
-Asynchronously obtains information about the current third-party application. This API uses a callback to return the result.
-
+Asynchronously obtains space information of the current third-party application. This API uses a callback to return the result.
+
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
- Parameters
| Name | Type | Mandatory | Description |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------ |
- | callback | callback:AsyncCallback<[BundleStats](#bundlestats)> | Yes | Callback invoked to return the application information obtained. |
+ | callback | callback:AsyncCallback<[BundleStats](#bundlestats)> | Yes | Callback invoked to return the space information obtained. |
- Example
@@ -260,7 +260,7 @@ Asynchronously obtains information about the current third-party application. Th
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
-- Attribute
+- Attributes
| Name | Type | Description |
| --------- | ------ | -------------- |
@@ -452,7 +452,7 @@ Asynchronously obtains the space occupied by each type of user data. This API us
| Name | Type | Mandatory| Description|
| ---------- | ------ | ---- | ---- |
- | userId | string | No | User ID. Value: - Set this parameter to the ID of the user to be queried. - If no value is specified, information about the current user is queried.|
+ | userId | string | No | User ID. - Set this parameter to the ID of the user to be queried. - If no value is specified, information about the current user is queried.|
- Return value
@@ -487,7 +487,7 @@ Asynchronously obtains the space occupied by each type of user data. This API us
| Name | Type | Mandatory| Description |
| ---------- | ------------------------------------ | ---- | -------------------------- |
- | userId | string | No | User ID. Value: - Set this parameter to the ID of the user to be queried. - If no value is specified, information about the current user is queried. |
+ | userId | string | No | User ID. - Set this parameter to the ID of the user to be queried. - If no value is specified, information about the current user is queried. |
| callback | callback:AsyncCallback<[StorageStats](#StorageStats)> | Yes | Callback invoked to return the information obtained.|
- Example
@@ -505,13 +505,13 @@ Asynchronously obtains the space occupied by each type of user data. This API us
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
-- Attribute
+- Attributes
| Name | Type | Description |
| --------- | ------ | -------------- |
| total | number | Total space of the built-in memory card. |
-| audio | number | Space occupied by the audio data. |
-| video | number | Space occupied by the video data.|
-| image | number | Space occupied by the image data. |
+| audio | number | Space occupied by audio data. |
+| video | number | Space occupied by video data.|
+| image | number | Space occupied by image data. |
| file | number | Space occupied by files. |
-| app | number | Space occupied by the application data.|
+| app | number | Space occupied by application data.|
diff --git a/en/application-dev/reference/apis/js-apis-system-bluetooth.md b/en/application-dev/reference/apis/js-apis-system-bluetooth.md
index 27223da59dd798215ff27a2a6bad0f49282097c9..9f2ef61d8465f220a97884f3097c43b203e07b80 100644
--- a/en/application-dev/reference/apis/js-apis-system-bluetooth.md
+++ b/en/application-dev/reference/apis/js-apis-system-bluetooth.md
@@ -1,7 +1,7 @@
# Bluetooth
->  **NOTE**
+> **NOTE**
>
> - The APIs of this module are no longer maintained since API version 7. You are advised to use [`@ohos.bluetooth`](js-apis-bluetooth.md).
>
@@ -15,7 +15,6 @@
import bluetooth from '@system.bluetooth';
```
-
## bluetooth.startBLEScan(OBJECT)
Scans for Bluetooth Low Energy (BLE) devices nearby. This operation consumes system resources. Call [bluetooth.stopBLEScan](#bluetoothstopblescanobject) to stop the scan after a BLE device is detected and connected.
@@ -25,7 +24,6 @@ Scans for Bluetooth Low Energy (BLE) devices nearby. This operation consumes sys
**System capability**: SystemCapability.Communication.Bluetooth.Lite
**Parameters**
-
**Table 1** StartBLEScanOptions
| Name| Type| Mandatory| Description|
@@ -61,7 +59,6 @@ Stops scanning for BLE devices nearby. This API is used with [bluetooth.startBLE
**System capability**: SystemCapability.Communication.Bluetooth.Lite
**Parameters**
-
**Table 2** StopBLEScanOptions
| Name| Type| Mandatory| Description|
@@ -74,6 +71,7 @@ Stops scanning for BLE devices nearby. This API is used with [bluetooth.startBLE
```
bluetooth.stopBLEScan({
+ interval:0,
success() {
console.log('call bluetooth.stopBLEScan success.');
},
@@ -96,7 +94,6 @@ Subscribes to the newly detected BLE device. If this API is called multiple time
**System capability**: SystemCapability.Communication.Bluetooth.Lite
**Parameters**
-
**Table 3** SubscribeBLEFoundOptions
| Name| Type| Mandatory| Description|
@@ -123,7 +120,7 @@ Subscribes to the newly detected BLE device. If this API is called multiple time
**Example**
```
- bluetooth.startaBLEScan({
+ bluetooth.startBLEScan({
success() {
bluetooth.subscribeBLEFound({
success(data) {
diff --git a/en/application-dev/reference/apis/js-apis-system-cipher.md b/en/application-dev/reference/apis/js-apis-system-cipher.md
index b0dc3c5b117f5256020aa0cc5073e662c62cb6c9..c4f862b0e3cbf448631be452f826ac395a44435c 100644
--- a/en/application-dev/reference/apis/js-apis-system-cipher.md
+++ b/en/application-dev/reference/apis/js-apis-system-cipher.md
@@ -1,15 +1,14 @@
# Encryption Algorithm
->  **Note:**
+> **NOTE**
>
-> - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version.
-> - This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.
+> The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
-```
+```js
import cipher from '@system.cipher'
```
@@ -24,69 +23,74 @@ Encrypts or decrypts data using RSA.
**Parameters**
-| Name | Type | Mandatory | Description |
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| action | string | Yes | Action type. The options are as follows: 1. **encrypt**: Encrypts data. 2. **decrypt**: Decrypts data. |
-| text | string | Yes | Text content to be encrypted or decrypted. The text to be encrypted must be a common text and cannot exceed the length calculated based on the formula (keySize/8 - 66). **keySize** indicates the key length. For example, if the key length is 1024 bytes, the text cannot exceed 62 bytes (1024/8 - 66 = 62). The text content to be decrypted must be a binary value encoded using Base64. The default format is used for Base64 encoding. |
-| key | string | Yes | Keys encrypted using RSA. During encryption, this parameter is a public key. During decryption, it is a private key. |
-| transformation | string | No | RSA algorithm padding. The default value is **RSA/None/OAEPWithSHA256AndMGF1Padding**. |
-| success | Function | No | Called when data is encrypted or decrypted successfully. |
-| fail | Function | No | Called when data fails to be encrypted or decrypted. |
-| complete | Function | No | Called when the execution is complete. |
+| action | string | Yes| Action to perform. The options are as follows: - encrypt - decrypt|
+| text | string | Yes| Text to be encrypted or decrypted. The text to be encrypted must be common text that meets the following requirement: Maximum text length = Key length/8 - 66 For example, if the key is of 1024 bytes, the text to be encrypted cannot exceed 62 bytes (1024/8 -66 = 62). The text to be decrypted must be binary text encoded in Base64. The default format is used for Base64 encoding.|
+| key | string | Yes| RSA key. The key is used as a public key in encryption and a private key in decryption.|
+| transformation | string | No| RSA padding. The default value is **RSA/None/OAEPWithSHA256AndMGF1Padding**.|
+| success | Function | No| Called when data is encrypted or decrypted successfully.|
+| fail | Function | No| Called when data fails to be encrypted or decrypted.|
+| complete | Function | No| Called when the execution is complete.|
**Example**
-```
+```js
export default {
rsa() {
cipher.rsa({
- // Encrypt data.
+ // Encrypt data.
action: 'encrypt',
- // Text content to be encrypted
+ // Text to be encrypted.
text: 'hello',
- // Base64-encoded public key used for encryption
- key:
- 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDc7GR2MrfAoefES+wrs1ns2afT\n' +
- 'eJXSfIkEHfPXG9fVFjaws1ho4KcZfsxlA0+SXvc83f2SVGCuzULmM2lxxRCtcUN/\n' +
- 'h7SoaYEeluhqFimL2AEjfSwINHCLqObJkcjCfoZpE1JCehPiDOJsyT50Auc08h/4\n' +
- 'jHQfanyC1nc62LqUCQIDAQAB',
- success: function(data) {
- console.log('handling success: ${data.text}');
- },
- fail: function(data, code) {
- console.log(`### cipher.rsa encrypt fail ### ${code}: ${data}`);
- }
+ // Base64-encoded public key used for encryption.
+ key:
+ 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCx414QSP3RsYWYzf9mkBMiBAXo\n' +
+ '6S7Lpva1fKlcuVxjoFC1iMnzD4mC0uiL4k5MNi43J64c7dbqi3qAJjdAtuwQ6NZJ\n' +
+ '+Enz0RzmVFh/4yk6lmqRzuEFQqhQqSZzaLq6sq2N2G0Sv2Xl3sLvqAfe2HNm2oBw\n' +
+ 'jBpApTJ3TeneOo6Z5QIDAQAB',
+ success: function(data) {
+ console.log(`handling successful:${data.text}`);
+ },
+ fail: function(data, code) {
+ console.log(`### Failed to encrypt cipher.rsa ### ${code}:${data}`);
+ },
+ complete: function() {
+ console.log(`operation complete!`);
+ }
});
cipher.rsa({
- // Decrypt data.
+ // Decrypt data.
action: 'decrypt',
- // The text to be decrypted is a Base64-encoded binary value, and the decrypted text is "hello".
+ // Text to be decrypted, which is binary text encoded in Base64. The decrypted text is "hello".
text:
- 'CUg3tTxTIdpCfreIxIBdws3uhd5qXLwcrVl3XDnQzZFVHyjVVCDHS16rjopaZ4C5xU2Tc8mSDzt7\n' +
- 'gp9vBfSwi7bMtSUvXG18DlncsKJFDkJpS5t0PkpS9YrJXrY80Gpe+ME6+6dN9bjgqMljbitDdBRf\n' +
- 'S/ZWNI4Q8Q0suNjNkGU=',
- // Base64-encoded public key used for encryption
+ 'EPeCFPib6ayKbA0M6oSywARvFZ8dFYfjQv3nY8ikZGtS9UHq2sLPvAfpeIzggSiCxqbWeCftP1XQ\n' +
+ 'Sa+jEpzFlT1qoSTunBbrYzugPTajIJDTg6R1IRsF/J+mmakn0POVPvi4jCo9wqavB324Bx0Wipnc\n' +
+ 'EU5WO0oBHo5l4x6dTpU=',
+ // Base64-encoded private key used for decryption.
key:
- 'MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBANzsZHYyt8Ch58RL\n' +
- '7CuzWezZp9N4ldJ8iQQd89cb19UWNrCzWGjgpxl+zGUDT5Je9zzd/ZJUYK7NQuYz\n' +
- 'aXHFEK1xQ3+HtKhpgR6W6GoWKYvYASN9LAg0cIuo5smRyMJ+hmkTUkJ6E+IM4mzJ\n' +
- 'PnQC5zTyH/iMdB9qfILWdzrYupQJAgMBAAECgYEAkibhH0DWR13U0gvYJeD08Lfd\n' +
- 'Sw1PMHyquEqIcho9Yv7bF3LOXjOg2EEGPx09mvuwXFgP1Kp1e67XPytr6pQQPzK7\n' +
- 'XAPcLPx80R/ZjZs8vNFndDOd1HgD3vSVmYQarNzmKi72tOUWMPevsaFXPHo6Xx3X\n' +
- '8x0wYb7XuBsQguRctTECQQD7GWX3JUiyo562iVrpTDPOXsrUxmzCrgz2OZildxMd\n' +
- 'Pp/PkyDrx7mEXTpk4K/XnQJ3GpJNi2iDSxDuPSAeJ/aPAkEA4Tw4+1Z43S/xH3C3\n' +
- 'nfulYBNyB4si6KEUuC0krcC1pDJ21Gd12efKo5VF8SaJI1ZUQOzguV+dqNsB/JUY\n' +
- 'OFfX5wJAB1dKv9r7MR3Peg6x9bggm5vx2h6i914XSuuMJupASM6X5X2rrLj+F3yS\n' +
- 'RHi9K1SPyeOg+1tkBtKfABgRZFBOyQJAbuTivUSe73AqTKuHjB4ZF0ubqgEkJ9sf\n' +
- 'Q2rekzm9dOFvxjZGPQo1qALX09qATMi1ZN376ukby8ZAnSafLSZ64wJBAM2V37go\n' +
- 'Sj44HF76ksRow8gecuQm48NCTGAGTicXg8riKog2GC9y8pMNHAezoR9wXJF7kk+k\n' +
- 'lz5cHyoMZ9mcd30=',
- success: function(data) {
- console.log('handling success: ${data.text}');
- },
- fail: function(data, code) {
- console.log(`### cipher.rsa decrypt fail ### ${code}: ${data}`);
- },
+ 'MIICXgIBAAKBgQCx414QSP3RsYWYzf9mkBMiBAXo6S7Lpva1fKlcuVxjoFC1iMnz\n' +
+ 'D4mC0uiL4k5MNi43J64c7dbqi3qAJjdAtuwQ6NZJ+Enz0RzmVFh/4yk6lmqRzuEF\n' +
+ 'QqhQqSZzaLq6sq2N2G0Sv2Xl3sLvqAfe2HNm2oBwjBpApTJ3TeneOo6Z5QIDAQAB\n' +
+ 'AoGBAKPNtoRQcklxqo+2wQP0j2m3Qqnib1DggjVEgb/8f/LNYQSI3U2QdROemryU\n' +
+ 'u3y6N3xacZ359PktTrRKfH5+8ohmHGhIuPAnefp6bLvAFUcl4t1xm74Cow62Kyw3\n' +
+ 'aSbmuTG98dxPA1sXD0jiprdtsq2wQ9CoKNyY7/d/pKoqxNuBAkEA4GytZ60NCTj9\n' +
+ 'w24jACFeko5YqCFY/TTLoc4SQvWtFMnimRPclLZhtUIK0P8dib71UFedx+AxklgL\n' +
+ 'A5gjcfo+2QJBAMrqiwyCh3OQ5DhyRPDwt87x1/jg5fy4hhete2ufSf2FoQCVqO+w\n' +
+ 'PKoljdXmJeS6rGgzGibstuHLrP3tcIho4+0CQD3ZFWzF/xq0jxKlrpWhnJuNCRfE\n' +
+ 'oO6e9yNvVA8J/5oEDSOcmqSNIp4+RhbUx8InUxnCG6Ryv5aSFu71pYcKrPkCQQCL\n' +
+ 'RUGcm3ZGTnslduB0knNF+V2ndwzDUQ7P74UXT+PjurTPhujFYiuxCEd6ORVnEOzG\n' +
+ 'M9TORIgdH8MjIbWsGnndAkEAw9yURDaorE8IYPLF2IEn09g1uzvWPs3phDb6smVx\n' +
+ '8GfqIdUNf+aCG5TZK/kXBF1sqcsi7jXMAf4jBlejVbSVZg==',
+ success: function(data) {
+ console.log(`handling successful:${data.text}`);
+ },
+ fail: function(data, code) {
+ console.log(`### Failed to encrypt cipher.rsa ### ${code}:${data}`);
+ },
+ complete: function() {
+ console.log(`operation complete!`);
+ }
});
}
}
@@ -103,63 +107,66 @@ Encrypts or decrypts data using AES.
**Parameters**
-| Name | Type | Mandatory | Description |
+| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| action | string | Yes | Action type. The options are as follows: 1. **encrypt**: Encrypts data. 2. **decrypt**: Decrypts data. |
-| text | string | Yes | Text content to be encrypted or decrypted. The text to be encrypted must be a common text. The text content to be decrypted must be a binary value encoded using Base64. The default format is used for Base64 encoding. |
-| key | string | Yes | Key used for encryption or decryption, which is a character string encrypted using Base64. |
-| transformation | string | No | Encryption mode and padding of the AES algorithm. The default value is **AES/CBC/PKCS5Padding**. |
-| iv | string | No | Initial vector for AES-based encryption and decryption. The value is a character string encoded using Base64. The default value is the key value. |
-| ivOffset | string | No | Offset of the initial vector for AES-based encryption and decryption. The default value is **0**. |
-| ivLen | string | No | Length of the initial vector for AES-based encryption and decryption. The default value is **16**. |
-| success | Function | No | Called when data is encrypted or decrypted successfully. |
-| fail | Function | No | Called when data fails to be encrypted or decrypted. |
-| complete | Function | No | Called when the execution is complete. |
+| action | string | Yes| Action to perform. The options are as follows: - encrypt - decrypt|
+| text | string | Yes| Text to be encrypted or decrypted. The text to be encrypted must be common text. The text to be decrypted must be binary text encoded in Base64. The default format is used for Base64 encoding.|
+| key | string | Yes| Key used for encryption or decryption. It is a string encoded in Base64.|
+| transformation | string | No| Encryption mode and padding of the AES algorithm. The default value is **AES/CBC/PKCS5Padding**.|
+| iv | string | No| Initialization vector (IV) for AES-based encryption and decryption. The value is a string encoded in Base64. The default value is the key value.|
+| ivOffset | string | No| Offset of the IV for AES-based encryption and decryption. The default value is **0**, which is the only value supported.|
+| ivLen | string | No| Length of the IV, in bytes. This field is reserved. The default value is **16**, which is the only value supported.|
+| success | Function | No| Called when data is encrypted or decrypted successfully.|
+| fail | Function | No| Called when data fails to be encrypted or decrypted.|
+| complete | Function | No| Called when the execution is complete.|
**Example**
-```
+```js
export default {
aes() {
cipher.aes({
- // Encrypt data.
+ // Encrypt data.
action: 'encrypt',
- // Text content to be encrypted
+ // Text to be encrypted.
text: 'hello',
- // Base64-encoded key used for encryption
+ // Base64-encoded key used for encryption.
key: 'NDM5Qjk2UjAzMEE0NzVCRjlFMkQwQkVGOFc1NkM1QkQ=',
transformation: 'AES/CBC/PKCS5Padding',
- ivOffset: 0,
- ivLen: 16,
- success: (data) => {
- console.log('handling success: ${data.text}');
- },
- fail: (data, code) => {
- console.log(`### cipher.aes encrypt fail ### ${code}: ${data}`);
- }
+ ivOffset: '0',
+ ivLen: '16',
+ success: function(data) {
+ console.log(`handling successful:${data.text}`);
+ },
+ fail: function(data, code) {
+ console.log(`### Failed to encrypt cipher.rsa ### ${code}:${data}`);
+ },
+ complete: function() {
+ console.log(`operation complete!`);
+ }
});
cipher.aes({
- // Decrypt data.
+ // Decrypt data.
action: 'decrypt',
- // Text to be decrypted, which is a Base64-encoded binary value
- text: 'CUg3tTxTIdpCfreIxIBdws3uhd5qXLwcrVl3XDnQzZFVHyjVVCDHS16rjopaZ4C5xU2Tc8mSDzt7\n' +
- 'gp9vBfSwi7bMtSUvXG18DlncsKJFDkJpS5t0PkpS9YrJXrY80Gpe+ME6+6dN9bjgqMljbitDdBRf\n' +
- 'S/ZWNI4Q8Q0suNjNkGU=',
- // Base64-encoded key used for decryption
+ // Text to be decrypted, which is binary text encoded in Base64.
+ text: '1o0kf2HXwLxHkSh5W5NhzA==',
+ // Base64-encoded key used for decryption.
key: 'NDM5Qjk2UjAzMEE0NzVCRjlFMkQwQkVGOFc1NkM1QkQ=',
transformation: 'AES/CBC/PKCS5Padding',
- ivOffset: 0,
- ivLen: 16,
- success: (data) => {
- this.dealTxt = data.text;
- },
- fail: (data, code) => {
- prompt.showToast({
- message: (`### cipher.aes decrypt fail ### code = ${code}: ${data}`)
- })
- },
+ ivOffset: '0',
+ ivLen: '16',
+ success: function(data) {
+ console.log(`handling success:${data.text}`);
+ },
+ fail: function(data, code) {
+ console.log(`### Failed to decrypt cipher.rsa ### ${code}:${data}`);
+ },
+ complete: function() {
+ console.log(`operation complete!`);
+ }
+ });
});
}
}
-```
\ No newline at end of file
+```
diff --git a/en/application-dev/reference/apis/js-apis-system-prompt.md b/en/application-dev/reference/apis/js-apis-system-prompt.md
index f894715391f015cbd67ecf913a7923c00d4e78e1..e37601dbfa3ec72d13a7722fb4dc56a8b3fe6fef 100644
--- a/en/application-dev/reference/apis/js-apis-system-prompt.md
+++ b/en/application-dev/reference/apis/js-apis-system-prompt.md
@@ -1,8 +1,8 @@
# Prompt
->  **NOTE**
+> **NOTE**
>
-> - The APIs of this module are no longer maintained since API version 8. You are advised to use ['@ohos.prompt](js-apis-prompt.md)' instead.
+> - The APIs of this module are no longer maintained since API version 8. You are advised to use [`@ohos.prompt`](js-apis-prompt.md) instead.
>
>
> - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version.
@@ -11,7 +11,7 @@
## Modules to Import
-```
+```js
import prompt from '@system.prompt';
```
@@ -31,7 +31,7 @@ Shows the toast.
**Example**
-```
+```js
export default {
showToast() {
prompt.showToast({
@@ -60,7 +60,7 @@ Shows the dialog box.
**Example**
-```
+```js
export default {
showDialog() {
prompt.showDialog({
@@ -100,7 +100,7 @@ Shows the action menu.
**Example**
-```
+```js
export default {
showActionMenu() {
prompt.showActionMenu({
@@ -115,11 +115,11 @@ export default {
color: '#000000',
},
],
- success: function(data) {
+ success: function(tapIndex) {
console.log('dialog success callback, click button : ' + data.tapIndex);
},
- fail: function(data) {
- console.log('dialog fail callback' + data.errMsg);
+ fail: function(errMsg) {
+ console.log('dialog fail callback' + errMsg);
},
});
}
@@ -135,7 +135,7 @@ Describes the options for showing the toast.
| ------------------- | -------------- | ---- | ---------------------------------------- |
| message | string | Yes | Text to display. |
| duration | number | No | Duration that the toast will remain on the screen. The default value is 1500 ms. The recommended value range is 1500 ms to 10000 ms. If a value less than 1500 ms is set, the default value is used.|
-| bottom5+ | string\|number | No | Distance between the toast frame and the bottom of the screen. This parameter is available only on phones and tablets. |
+| bottom5+ | string\|number | No | Distance between the toast border and the bottom of the screen. |
## Button
diff --git a/en/application-dev/reference/apis/js-apis-system-router.md b/en/application-dev/reference/apis/js-apis-system-router.md
index a93ffdfa68f6406c6290221d4c5fe757fd7c906b..0f1f932efe54af1337ce19354d19343b6f637687 100644
--- a/en/application-dev/reference/apis/js-apis-system-router.md
+++ b/en/application-dev/reference/apis/js-apis-system-router.md
@@ -1,6 +1,6 @@
# Page Routing
->  **NOTE**
+> **NOTE**
>
> - The APIs of this module are no longer maintained since API version 8. You are advised to use [`@ohos.router`](js-apis-router.md) instead.
>
@@ -11,7 +11,7 @@
## Modules to Import
-```
+```js
import router from '@system.router';
```
@@ -31,7 +31,7 @@ Navigates to a specified page in the application.
**Example**
-```
+```js
// Current page
export default {
pushPage() {
@@ -49,7 +49,7 @@ export default {
```
-```
+```js
// routerpage2 page
export default {
data: {
@@ -85,7 +85,7 @@ Replaces the current page with another one in the application and destroys the c
**Example**
-```
+```js
// Current page
export default {
replacePage() {
@@ -100,7 +100,7 @@ export default {
```
-```
+```js
// detail page
export default {
data: {
@@ -128,7 +128,7 @@ Returns to the previous page or a specified page.
**Example**
-```
+```js
// index page
export default {
indexPushPage() {
@@ -140,7 +140,7 @@ export default {
```
-```
+```js
// detail page
export default {
detailPushPage() {
@@ -152,7 +152,7 @@ export default {
```
-```
+```js
// Navigate from the mall page to the detail page through router.back().
export default {
mallBackPage() {
@@ -162,7 +162,7 @@ export default {
```
-```
+```js
// Navigate from the detail page to the index page through router.back().
export default {
defaultBack() {
@@ -172,7 +172,7 @@ export default {
```
-```
+```js
// Return to the detail page through router.back().
export default {
backToDetail() {
@@ -208,7 +208,7 @@ Clears all historical pages in the stack and retains only the current page at th
**Example**
-```
+```js
export default {
clearPage() {
router.clear();
@@ -232,7 +232,7 @@ Obtains the number of pages in the current stack.
**Example**
-```
+```js
export default {
getLength() {
var size = router.getLength();
@@ -257,7 +257,7 @@ Obtains state information about the current page.
**Example**
-```
+```js
export default {
getState() {
var page = router.getState();
@@ -284,7 +284,7 @@ Enables the display of a confirm dialog box before returning to the previous pag
**Example**
-```
+```js
export default {
enableAlertBeforeBackPage() {
router.enableAlertBeforeBackPage({
@@ -292,8 +292,8 @@ export default {
success: function() {
console.log('success');
},
- fail: function() {
- console.log('fail');
+ cancel: function() {
+ console.log('cancel');
},
});
}
@@ -316,15 +316,15 @@ Disables the display of a confirm dialog box before returning to the previous pa
**Example**
-```
+```js
export default {
disableAlertBeforeBackPage() {
router.disableAlertBeforeBackPage({
success: function() {
console.log('success');
},
- fail: function() {
- console.log('fail');
+ cancel: function() {
+ console.log('cancel');
},
});
}
diff --git a/en/application-dev/reference/apis/js-apis-system-storage.md b/en/application-dev/reference/apis/js-apis-system-storage.md
index 37e8dc5de76e930a81a337c9afd3fe0adcd459c4..ffa96a8e8e6f569c7cc2b9413736aff7048d7713 100644
--- a/en/application-dev/reference/apis/js-apis-system-storage.md
+++ b/en/application-dev/reference/apis/js-apis-system-storage.md
@@ -68,7 +68,7 @@ Sets the value in the cache based on the specified key.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the data to set.|
-| value | string | Yes| New value to set. The maximum length is 128 bytes.|
+| value | string | Yes| New value to set. The length must be less than 128 bytes.|
| success | Function | No| Called when **storage.set()** is successful.|
| fail | Function | No| Called when **storage.set()** fails. In the callback, **data** indicates the error information, and **code** indicates the error code.|
| complete | Function | No| Called when **storage.set()** is complete.|
diff --git a/en/application-dev/reference/apis/js-apis-system-time.md b/en/application-dev/reference/apis/js-apis-system-time.md
index 74beca3c0aacbabd628f99f7987b96caf5988f61..a89640acc11ba359dfdf6011bbd4766cdd42b5ec 100644
--- a/en/application-dev/reference/apis/js-apis-system-time.md
+++ b/en/application-dev/reference/apis/js-apis-system-time.md
@@ -1,7 +1,8 @@
# Setting the System Time
->  **NOTE** The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
->
+This module provides the time, time zone, and timing services. Use the time and time zone services to set and obtain the system time and time zone, and use the timing service to manage and use the system time and time zone to implement alarms or other timing functions.
+
+> **NOTE** The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
@@ -189,7 +190,7 @@ Obtains the time elapsed since system start, excluding the deep sleep time. This
**Example**
```js
- systemTime.getCurrentTime().then((data) => {
+ systemTime.getRealActiveTime().then((data) => {
console.log(`systemTime.getRealActiveTime success data : ` + JSON.stringify(data));
}).catch((error) => {
console.error(`failed to systemTime.getRealActiveTime because ` + JSON.stringify(error));
@@ -199,7 +200,7 @@ Obtains the time elapsed since system start, excluding the deep sleep time. This
## systemTime.getRealTime8+
-getRealTime(callback: AsyncCallback<number>): void
+getRealTime(isNano?: boolean, callback: AsyncCallback<number>): void
Obtains the time elapsed since system start, including the deep sleep time. This API uses an asynchronous callback to return the result.
@@ -227,7 +228,7 @@ Obtains the time elapsed since system start, including the deep sleep time. This
## systemTime.getRealTime8+
-getRealTime(): Promise<number>
+getRealTime(isNano?: boolean): Promise<number>
Obtains the time elapsed since system start, including the deep sleep time. This API uses a promise to return the result.
diff --git a/en/application-dev/reference/apis/js-apis-testRunner.md b/en/application-dev/reference/apis/js-apis-testRunner.md
index 47f1dc8dad5189495c3ca2a74d6b72ea96fc6de1..717c8448a00518b777b882fa7a49d7aca4509e11 100644
--- a/en/application-dev/reference/apis/js-apis-testRunner.md
+++ b/en/application-dev/reference/apis/js-apis-testRunner.md
@@ -1,8 +1,8 @@
# TestRunner
-> **Note**
->
-> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+> **NOTE**
+>
+> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
diff --git a/en/application-dev/reference/apis/js-apis-timer.md b/en/application-dev/reference/apis/js-apis-timer.md
index e85037469d3dd0d931ea7de0a37df77d35880bae..d144a95db8f59ca0605fd228b351380afe6feac8 100644
--- a/en/application-dev/reference/apis/js-apis-timer.md
+++ b/en/application-dev/reference/apis/js-apis-timer.md
@@ -1,50 +1,45 @@
# Timer
-> **NOTE:** The initial APIs of this module are supported since API version 4. Newly added APIs will be marked with a superscript to indicate their earliest API version.
-## Module to Import
-
-None
+## setTimeout
-## Required Permissions
+## Modules to Import
-None
-## setTimeout
+```
+import Time from '@ohos.Time';
+```
-setTimeout(handler[,delay[, ...args]]): number
+setTimeout(handler[,delay[,…args]]): number
Sets a timer for the system to call a function after the timer goes off.
-- Parameters
+**Parameters**
-
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| handler | Function | Yes| Function to be called after the timer goes off.|
+| delay | number | No| Number of milliseconds delayed before the execution. If this parameter is left empty, the default value **0** is used, which means that the execution starts immediately or as soon as possible.|
+| ...args | Array<any> | No| Additional parameters to pass to the handler after the timer goes off.|
- | Name | Type | Mandatory | Description |
- | ------- | ----------- | --------- | ------------------------------------------------------------ |
- | handler | Function | Yes | Function to be called after the timer goes off. |
- | delay | number | No | Number of milliseconds delayed before the execution. If this parameter is left empty, the default value **0** is used, which means that the execution starts immediately or as soon as possible. |
- | ...args | Array\ | No | Additional parameter to pass to the handler after the timer goes off. |
+**Return value**
-- Return Value
+| Type| Description|
+| -------- | -------- |
+| number | Timer ID.|
-
+**Example**
- | Type | Description |
- | ------ | ----------- |
- | number | Timer ID. |
-
-- Example
-
- ```
- export default {
- setTimeOut() {
- var timeoutID = setTimeout(function() {
- console.log('delay 1s');
- }, 1000);
- }
+```js
+export default {
+ setTimeOut() {
+ var timeoutID = setTimeout(function() {
+ console.log('delay 1s');
+ }, 1000);
}
- ```
+}
+```
+
## clearTimeout
@@ -52,26 +47,25 @@ clearTimeout(timeoutID: number): void
Cancels the timer created via **setTimeout()**.
-- Parameter
+**Parameters**
-
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| timeoutID | number | Yes| ID of the timer to cancel, which is returned by **setTimeout()**|
- | Name | Type | Mandatory | Description |
- | --------- | ------ | --------- | ------------------------------------------------------------ |
- | timeoutID | number | Yes | ID of the timer to cancel, which is returned by **setTimeout()** |
+**Example**
-- Example
-
- ```
- export default {
- clearTimeOut() {
- var timeoutID = setTimeout(function() {
- console.log('do after 1s delay.');
- }, 1000);
- clearTimeout(timeoutID);
- }
+```js
+export default {
+ clearTimeOut() {
+ var timeoutID = setTimeout(function() {
+ console.log('do after 1s delay.');
+ }, 1000);
+ clearTimeout(timeoutID);
}
- ```
+}
+```
+
## setInterval
@@ -79,35 +73,32 @@ setInterval(handler[, delay[, ...args]]): number
Sets a repeating timer for the system to repeatedly call a function at a fixed interval.
-- Parameters
-
-
+**Parameters**
- | Name | Type | Mandatory | Description |
- | ------- | ----------- | --------- | ------------------------------------------------------------ |
- | handler | Function | Yes | Function to be called repeatedly |
- | delay | number | No | Number of milliseconds delayed before the execution |
- | ...args | Array\ | No | Additional parameter to pass to the handler after the timer goes off |
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| handler | Function | Yes| Function to be called repeatedly.|
+| delay | number | No| Number of milliseconds delayed before the execution.|
+| ...args | Array<any> | No| Additional parameters to pass to the handler after the timer goes off.|
-- Return Value
+**Return value**
-
+| Type| Description|
+| -------- | -------- |
+| number | ID of the repeating timer.|
- | Type | Description |
- | ------ | ------------------------- |
- | number | ID of the repeated timer. |
+**Example**
-- Example
-
- ```
- export default {
- setInterval() {
- var intervalID = setInterval(function() {
- console.log('do very 1s.');
- }, 1000);
- }
+```js
+export default {
+ setInterval() {
+ var intervalID = setInterval(function() {
+ console.log('do very 1s.');
+ }, 1000);
}
- ```
+}
+```
+
## clearInterval
@@ -115,23 +106,21 @@ clearInterval(intervalID: number): void
Cancels the repeating timer set via **setInterval()**.
-- Parameter
-
-
+**Parameters**
- | Name | Type | Mandatory | Description |
- | ---------- | ------ | --------- | ------------------------------------------------------------ |
- | intervalID | number | Yes | ID of the repeating timer to cancel, which is returned by **setInterval()**. |
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| intervalID | number | Yes| ID of the repeating timer to cancel, which is returned by **setInterval()**.|
-- Example
+**Example**
- ```
- export default {
- clearInterval() {
- var intervalID = setInterval(function() {
- console.log('do very 1s.');
- }, 1000);
- clearInterval(intervalID);
- }
+```js
+export default {
+ clearInterval() {
+ var intervalID = setInterval(function() {
+ console.log('do very 1s.');
+ }, 1000);
+ clearInterval(intervalID);
}
- ```
\ No newline at end of file
+}
+```
\ No newline at end of file
diff --git a/en/application-dev/reference/apis/js-apis-treemap.md b/en/application-dev/reference/apis/js-apis-treemap.md
index c3d62b882dbb74012ba561135f5934dae3b3e22e..7914e5bd409d29b3bcae14653aaa6bd8dd5f6f9c 100644
--- a/en/application-dev/reference/apis/js-apis-treemap.md
+++ b/en/application-dev/reference/apis/js-apis-treemap.md
@@ -1,27 +1,32 @@
# Nonlinear Container TreeMap
->  **NOTE**
+> **NOTE**
+>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+**TreeMap** stores key-value (KV) pairs. Each key must be unique and have only one value.
+
+**TreeMap** is implemented using a red-black tree, which is a binary search tree where keys are stored in sorted order for efficient insertion and removal.
+
+**[HashMap](js-apis-treemap.md)** is faster in accessing data than **TreeMap**, because the former accesses data based on the hash code of the key, whereas the latter stores and accesses the keys in sorted order.
+
+Recommended use case: Use **TreeMap** when you need to store KV pairs in sorted order.
## Modules to Import
```ts
-import TreeMap from '@ohos.util.TreeMap'
+import TreeMap from '@ohos.util.TreeMap';
```
-## System Capabilities
-
-SystemCapability.Utils.Lang
-
## TreeMap
-
### Attributes
+**System capability**: SystemCapability.Utils.Lang
+
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| length | number | Yes| No| Number of entries in a tree map (called container later).|
+| length | number | Yes| No| Number of elements in a tree map (called container later).|
### constructor
@@ -30,6 +35,8 @@ constructor(comparator?:(firstValue: K, secondValue: K) => boolean)
A constructor used to create a **TreeMap** instance.
+**System capability**: SystemCapability.Utils.Lang
+
**Parameters**
| Name| Type| Mandatory| Description|
@@ -47,7 +54,9 @@ let treeMap = new TreeMap();
isEmpty(): boolean
-Checks whether this container is empty (contains no entry).
+Checks whether this container is empty (contains no element).
+
+**System capability**: SystemCapability.Utils.Lang
**Return value**
@@ -69,11 +78,13 @@ hasKey(key: K): boolean
Checks whether this container has the specified key.
+**System capability**: SystemCapability.Utils.Lang
+
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| key | K | Yes| Key to check.|
+| key | K | Yes| Target key.|
**Return value**
@@ -97,11 +108,13 @@ hasValue(value: V): boolean
Checks whether this container has the specified value.
+**System capability**: SystemCapability.Utils.Lang
+
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| value | V | Yes| Value to check.|
+| value | V | Yes| Target value.|
**Return value**
@@ -125,11 +138,13 @@ get(key: K): V
Obtains the value of the specified key in this container.
+**System capability**: SystemCapability.Utils.Lang
+
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| key | K | Yes| Key to query.|
+| key | K | Yes| Target key.|
**Return value**
@@ -153,6 +168,8 @@ getFirstKey(): K
Obtains the first key in this container.
+**System capability**: SystemCapability.Utils.Lang
+
**Return value**
| Type| Description|
@@ -175,6 +192,8 @@ getLastKey(): K
Obtains the last key in this container.
+**System capability**: SystemCapability.Utils.Lang
+
**Return value**
| Type| Description|
@@ -195,13 +214,15 @@ let result = treeMap.getLastKey();
setAll(map: TreeMap): void
-Adds all entries in a **TreeMap** instance to this container.
+Adds all elements in a **TreeMap** instance to this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| map | TreeMap | Yes| **TreeMap** instance whose entries are to be added to the current container.|
+| map | TreeMap | Yes| **TreeMap** instance whose elements are to be added to the current container.|
**Example**
@@ -218,20 +239,22 @@ treeMap.setAll(map);
set(key: K, value: V): Object
-Adds an entry to this container.
+Adds an element to this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| key | K | Yes| Key of the entry to add.|
-| value | V | Yes| Value of the entry to add.|
+| key | K | Yes| Key of the target element.|
+| value | V | Yes| Value of the target element.|
**Return value**
| Type| Description|
| -------- | -------- |
-| Object | Container that contains the new entry.|
+| Object | Container that contains the new element.|
**Example**
@@ -245,19 +268,21 @@ treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
remove(key: K): V
-Removes the entry with the specified key from this container.
+Removes the element with the specified key from this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| key | K | Yes| Key of the entry to remove.|
+| key | K | Yes| Target key.|
**Return value**
| Type| Description|
| -------- | -------- |
-| V | Value of the entry removed.|
+| V | Value of the element removed.|
**Example**
@@ -275,6 +300,8 @@ getLowerKey(key: K): K
Obtains the key that is placed in front of the input key in this container.
+**System capability**: SystemCapability.Utils.Lang
+
**Parameters**
| Name| Type| Mandatory| Description|
@@ -304,6 +331,8 @@ getHigherKey(key: K): K
Obtains the key that is placed next to the input key in this container.
+**System capability**: SystemCapability.Utils.Lang
+
**Parameters**
| Name| Type| Mandatory| Description|
@@ -330,20 +359,22 @@ let result = treeMap.getHigherKey("sdfs");
replace(key: K, newValue: V): boolean
-Replaces an entry in this container.
+Replaces an element in this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| key | K | Yes| Key of the entry to replace.|
-| newValue | V | Yes| New value of the entry.|
+| key | K | Yes| Key of the target element.|
+| newValue | V | Yes| New value of the element.|
**Return value**
| Type| Description|
| -------- | -------- |
-| boolean | Returns **true** if the entry is replaced successfully; returns **false** otherwise.|
+| boolean | Returns **true** if the element is replaced successfully; returns **false** otherwise.|
**Example**
@@ -360,6 +391,8 @@ clear(): void
Clears this container and sets its length to **0**.
+**System capability**: SystemCapability.Utils.Lang
+
**Example**
```ts
@@ -376,6 +409,8 @@ keys(): IterableIterator<K>
Obtains an iterator that contains all the keys in this container.
+**System capability**: SystemCapability.Utils.Lang
+
**Return value**
| Type| Description|
@@ -391,7 +426,7 @@ treeMap.set("sdfs", 356);
let iter = treeMap.keys();
let temp = iter.next().value;
while(temp != undefined) {
- console.log(temp);
+ console.log("value:" + temp);
temp = iter.next().value;
}
```
@@ -403,6 +438,8 @@ values(): IterableIterator<V>
Obtains an iterator that contains all the values in this container.
+**System capability**: SystemCapability.Utils.Lang
+
**Return value**
| Type| Description|
@@ -418,7 +455,7 @@ treeMap.set("sdfs", 356);
let iter = treeMap.values();
let temp = iter.next().value;
while(temp != undefined) {
- console.log(temp);
+ console.log("value:" + temp);
temp = iter.next().value;
}
```
@@ -428,20 +465,22 @@ while(temp != undefined) {
forEach(callbackfn: (value?: V, key?: K, map?: TreeMap) => void, thisArg?: Object): void
-Uses a callback to traverse the entries in this container and obtain their position indexes.
+Uses a callback to traverse the elements in this container and obtain their position indexes.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| callbackfn | function | Yes| Callback invoked to traverse the entries in the container.|
+| callbackfn | function | Yes| Callback invoked to traverse the elements in the container.|
| thisArg | Object | No| Value to use when the callback is invoked.|
callbackfn
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| value | V | No| Value of the entry that is currently traversed.|
-| key | K | No| Key of the entry that is currently traversed.|
+| value | V | No| Value of the element that is currently traversed.|
+| key | K | No| Key of the element that is currently traversed.|
| map | TreeMap | No| Instance that invokes the **forEach** method.|
**Example**
@@ -451,7 +490,7 @@ let treeMap = new TreeMap();
treeMap.set("sdfs", 123);
treeMap.set("dfsghsf", 357);
treeMap.forEach((value, key) => {
- console.log(value, key);
+ console.log("value:" + value, key);
});
```
@@ -460,7 +499,9 @@ treeMap.forEach((value, key) => {
entries(): IterableIterator<[K, V]>
-Obtains an iterator that contains all the entries in this container.
+Obtains an iterator that contains all the elements in this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Return value**
@@ -477,8 +518,8 @@ treeMap.set("sdfs", 356);
let iter = treeMap.entries();
let temp = iter.next().value;
while(temp != undefined) {
- console.log(temp[0]);
- console.log(temp[1]);
+ console.log("key:" + temp[0]);
+ console.log("value:" + temp[1]);
temp = iter.next().value;
}
```
@@ -488,9 +529,10 @@ while(temp != undefined) {
[Symbol.iterator]\(): IterableIterator<[K, V]>
-
Obtains an iterator, each item of which is a JavaScript object.
+**System capability**: SystemCapability.Utils.Lang
+
**Return value**
| Type| Description|
| -------- | -------- |
@@ -505,16 +547,16 @@ treeMap.set("sdfs", 356);
// Method 1:
for (let item of treeMap) {
- console.log("key: " + item[0]);
- console.log("value: " + item[1]);
+ console.log("key:" + item[0]);
+ console.log("value:" + item[1]);
}
// Method 2:
let iter = treeMap[Symbol.iterator]();
let temp = iter.next().value;
while(temp != undefined) {
- console.log(temp[0]);
- console.log(temp[1]);
+ console.log("key:" + temp[0]);
+ console.log("value:" + temp[1]);
temp = iter.next().value;
}
```
diff --git a/en/application-dev/reference/apis/js-apis-treeset.md b/en/application-dev/reference/apis/js-apis-treeset.md
index 305af6a8d694f0e37e63aa736031a070267c3934..6e50abcf23c7cf2c3a77e6029244a0078edd1562 100644
--- a/en/application-dev/reference/apis/js-apis-treeset.md
+++ b/en/application-dev/reference/apis/js-apis-treeset.md
@@ -1,27 +1,30 @@
# Nonlinear Container TreeSet
->  **NOTE**
+> **NOTE**
+>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+**TreeSet** is implemented based on **[TreeMap](js-apis-treemap.md)**. In **TreeSet**, only **value** objects are processed. **TreeSet** can be used to store values, each of which must be unique.
+
+**[HashSet](js-apis-hashset.md)** stores data in a random order, whereas **TreeSet** stores data in sorted order. Both of them allows only unique elements. However, null values are allowed in **HashSet**, but not allowed in **TreeSet**.
+
+Recommended use case: Use **TreeSet** when you need to store data in sorted order.
## Modules to Import
```ts
-import TreeSet from '@ohos.util.TreeSet'
+import TreeSet from '@ohos.util.TreeSet';
```
-## System Capabilities
-
-SystemCapability.Utils.Lang
-
## TreeSet
-
### Attributes
+**System capability**: SystemCapability.Utils.Lang
+
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| length | number | Yes| No| Number of entries in a tree set (called container later).|
+| length | number | Yes| No| Number of elements in a tree set (called container later).|
### constructor
@@ -30,6 +33,8 @@ constructor(comparator?:(firstValue: T, secondValue: T) => boolean)
A constructor used to create a **TreeSet** instance.
+**System capability**: SystemCapability.Utils.Lang
+
**Parameters**
| Name| Type| Mandatory| Description|
@@ -47,7 +52,9 @@ let treeSet = new TreeSet();
isEmpty(): boolean
-Checks whether this container is empty (contains no entry).
+Checks whether this container is empty (contains no element).
+
+**System capability**: SystemCapability.Utils.Lang
**Return value**
@@ -69,11 +76,13 @@ has(value: T): boolean
Checks whether this container has the specified value.
+**System capability**: SystemCapability.Utils.Lang
+
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| value | T | Yes| Value to query.|
+| value | T | Yes| Target value.|
**Return value**
@@ -95,7 +104,9 @@ let result1 = treeSet.has(123);
getFirstValue(): T
-Obtains the value of the first entry in this container.
+Obtains the value of the first element in this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Return value**
@@ -117,7 +128,9 @@ let result = treeSet.getFirstValue();
getLastValue(): T
-Obtains the value of the last entry in this container.
+Obtains the value of the last element in this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Return value**
@@ -139,19 +152,21 @@ let result = treeSet.getLastValue();
add(value: T): boolean
-Adds an entry to this container.
+Adds an element to this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| value | T | Yes| Entry to add.|
+| value | T | Yes| Target element.|
**Return value**
| Type| Description|
| -------- | -------- |
-| boolean | Returns **true** if the entry is added successfully; returns **false** otherwise.|
+| boolean | Returns **true** if the element is added successfully; returns **false** otherwise.|
**Example**
@@ -165,19 +180,21 @@ let result = treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
remove(value: T): boolean
-Removes the entry with the specified key from this container.
+Removes the element with the specified key from this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| value | T | Yes| Key of the entry to remove.|
+| value | T | Yes| Key of the target element.|
**Return value**
| Type| Description|
| -------- | -------- |
-| boolean | Returns **true** if the entry is removed successfully; returns **false** otherwise.|
+| boolean | Returns **true** if the element is removed successfully; returns **false** otherwise.|
**Example**
@@ -195,6 +212,8 @@ getLowerValue(key: T): T
Obtains the value that is placed in front of the input key in this container.
+**System capability**: SystemCapability.Utils.Lang
+
**Parameters**
| Name| Type| Mandatory| Description|
@@ -224,6 +243,8 @@ getHigherValue(key: T): T
Obtains the value that is placed next to the input key in this container.
+**System capability**: SystemCapability.Utils.Lang
+
**Parameters**
| Name| Type| Mandatory| Description|
@@ -251,13 +272,15 @@ let result = treeSet.getHigherValue("sdfs");
popFirst(): T
-Removes the first entry in this container.
+Removes the first element in this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Return value**
| Type| Description|
| -------- | -------- |
-| T | Entry removed.|
+| T | Element removed.|
**Example**
@@ -273,13 +296,15 @@ let result = treeSet.popFirst();
popLast(): T
-Removes the last entry in this container.
+Removes the last element in this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Return value**
| Type| Description|
| -------- | -------- |
-| T | Entry removed.|
+| T | Element removed.|
**Example**
@@ -297,6 +322,8 @@ clear(): void
Clears this container and sets its length to **0**.
+**System capability**: SystemCapability.Utils.Lang
+
**Example**
```ts
@@ -313,6 +340,8 @@ values(): IterableIterator<T>
Obtains an iterator that contains all the values in this container.
+**System capability**: SystemCapability.Utils.Lang
+
**Return value**
| Type| Description|
@@ -328,7 +357,7 @@ treeSet.add("sdfs");
let iter = treeSet.values();
let temp = iter.next().value;
while(temp != undefined) {
- console.log(temp);
+ console.log("value:" + temp);
temp = iter.next().value;
}
```
@@ -338,20 +367,22 @@ while(temp != undefined) {
forEach(callbackfn: (value?: T, key?: T, set?: TreeSet<T>) => void, thisArg?: Object): void
-Uses a callback to traverse the entries in this container and obtain their position indexes.
+Uses a callback to traverse the elements in this container and obtain their position indexes.
+
+**System capability**: SystemCapability.Utils.Lang
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| callbackfn | function | Yes| Callback invoked to traverse the entries in the container.|
+| callbackfn | function | Yes| Callback invoked to traverse the elements in the container.|
| thisArg | Object | No| Value to use when the callback is invoked.|
callbackfn
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| value | T | No| Value of the entry that is currently traversed.|
-| key | T | No| Key of the entry that is currently traversed (same as **value**).|
+| value | T | No| Value of the element that is currently traversed.|
+| key | T | No| Key of the element that is currently traversed (same as **value**).|
| set | TreeSet<T> | No| Instance that invokes the **forEach** method.|
**Example**
@@ -361,7 +392,7 @@ let treeSet = new TreeSet();
treeSet.add("sdfs");
treeSet.add("dfsghsf");
treeSet.forEach((value, key) => {
- console.log(value, key)
+ console.log("value:" + value, key)
});
```
@@ -370,7 +401,9 @@ treeSet.forEach((value, key) => {
entries(): IterableIterator<[T, T]>
-Obtains an iterator that contains all the entries in this container.
+Obtains an iterator that contains all the elements in this container.
+
+**System capability**: SystemCapability.Utils.Lang
**Return value**
@@ -387,8 +420,8 @@ treeSet.add("sdfs");
let iter = treeSet.entries();
let temp = iter.next().value;
while(temp != undefined) {
- console.log(temp[0]);
- console.log(temp[1]);
+ console.log("key:" + temp[0]);
+ console.log("value:" + temp[1]);
temp = iter.next().value;
}
```
@@ -398,9 +431,10 @@ while(temp != undefined) {
[Symbol.iterator]\(): IterableIterator<T>
-
Obtains an iterator, each item of which is a JavaScript object.
+**System capability**: SystemCapability.Utils.Lang
+
**Return value**
| Type| Description|
@@ -416,14 +450,14 @@ treeSet.add("sdfs");
// Method 1:
for (let item of treeSet) {
- console.log("value: " + item);
+ console.log("value:" + item);
}
// Method 2:
let iter = treeSet[Symbol.iterator]();
let temp = iter.next().value;
while(temp != undefined) {
- console.log(temp);
+ console.log("value:" + temp);
temp = iter.next().value;
}
```
diff --git a/en/application-dev/reference/apis/js-apis-uitest.md b/en/application-dev/reference/apis/js-apis-uitest.md
index b554e47f481696c48dea31a47315e454a01b9efa..6586d6f0a2c7fc5641a5b49411f67390859e3bfe 100644
--- a/en/application-dev/reference/apis/js-apis-uitest.md
+++ b/en/application-dev/reference/apis/js-apis-uitest.md
@@ -1,8 +1,7 @@
# UiTest
->**NOTE**
+>**NOTE** The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
->The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
@@ -13,46 +12,27 @@ import {UiDriver,BY,MatchPattern} from '@ohos.uitest'
## By
-The UiTest framework provides a wide range of UI component feature description APIs in the **By** class to filter and match components.
-The API capabilities provided by the **By** class exhibit the following features:
+The UiTest framework provides a wide range of UI component feature description APIs in the **By** class to filter and match components.
+The API capabilities provided by the **By** class exhibit the following features: 1. Allow one or more attributes as the match conditions. For example, you can specify both the **text** and **id** attributes to find the target component. 2. Provide multiple match patterns for component attributes. 3. Support absolute positioning and relative positioning for components. APIs such as [By.isBefore](#byisbefore) and [By.isAfter](#byisafter) can be used to specify the features of adjacent components to assist positioning. All APIs provided in the **By** class are synchronous. You are advised to use the static constructor **BY** to create a **By** object in chain mode.
-- Allows one or more attributes as the match conditions. For example, you can specify both the **text** and **id** attributes to find the target component.
-
-- Provides multiple match patterns for component attributes.
-
-- Supports absolute positioning and relative positioning for components. APIs such as **isBefore** and **isAfter** can be used to specify the features of adjacent components to assist positioning.
-
-All APIs provided in the **By** class are synchronous. You are advised to use the static constructor **BY** to create a **By** object in chain mode, for example, **BY.text('123').type('button')**.
-
-### enum MatchPattern
-
-Enumerates the match patterns supported for component attributes.
-
-**System capability**: SystemCapability.Test.UiTest
-
-| Name | Value | Description |
-| ----------- | ---- | ------------ |
-| EQUALS | 0 | Equal to the given value. |
-| CONTAINS | 1 | Contain the given value. |
-| STARTS_WITH | 2 | Start with the given value.|
-| ENDS_WITH | 3 | End with the given value.|
+```js
+BY.text('123').type('button')
+```
### By.text
-text(txt:string,pattern?:MatchPattern):By
+text(txt: string, pattern?: MatchPattern): By
Specifies the text attribute of the target component. Multiple match patterns are supported.
-**Required permissions**: none
-
**System capability**: SystemCapability.Test.UiTest
**Parameters**
-| Name | Type | Mandatory| Description |
-| ------- | ------------ | ---- | ---------------------------------- |
-| txt | string | Yes | Component text, used to match the target component.|
-| pattern | MatchPattern | No | Match pattern. The default value is **EQUALS**. |
+| Name | Type | Mandatory| Description |
+| ------- | ------------ | ---- | ------------------------------------------------- |
+| txt | string | Yes | Component text, used to match the target component. |
+| pattern | MatchPattern | No | Match pattern. The default value is [EQUALS](#matchpattern).|
**Return value**
@@ -62,324 +42,382 @@ Specifies the text attribute of the target component. Multiple match patterns ar
**Example**
-```
-let by = BY.text('123') // Use the static constructor BY to create a By object and specify the text attribute
- of the target component.
+```js
+let by = BY.text('123') // Use the static constructor BY to create a By object and specify the text attribute of the target component.
```
### By.key
-key(key:string):By;
+key(key: string): By
Specifies the key attribute of the target component.
-**Required permissions**: none
-
**System capability**: SystemCapability.Test.UiTest
**Parameters**
-| Name| Type | Mandatory| Description |
-| ------ | ------ | ---- | --------------- |
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ----------------- |
| key | string | Yes | Component key.|
**Return value**
-| Type| Description |
-| ---- | -------------- |
+| Type| Description |
+| ---- | ---------------- |
| By | Returns the **By** object itself.|
**Example**
-```
-let by = BY.key('123') // Use the static constructor BY to create a By object and specify the key attribute
- of the target component.
+```js
+let by = BY.key('123') // Use the static constructor BY to create a By object and specify the key attribute of the target component.
```
### By.id
-id(id:number):By;
-
-Specifies the ID property of the target component.
+id(id: number): By
-**Required permissions**: none
+Specifies the ID attribute of the target component.
**System capability**: SystemCapability.Test.UiTest
**Parameters**
-| Name| Type | Mandatory| Description |
-| ------ | ------ | ---- | ------------ |
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ---------------- |
| id | number | Yes | Component ID.|
**Return value**
-| Type| Description |
-| ---- | -------------- |
+| Type| Description |
+| ---- | ---------------- |
| By | Returns the **By** object itself.|
**Example**
-```
-let by = BY.id(123) // Use the static constructor BY to create a By object and specify the ID attribute
- of the target component.
+```js
+let by = BY.id(123) // Use the static constructor BY to create a By object and specify the id attribute of the target component.
```
### By.type
-type(tp:string):By;
+type(tp: string): By
-Specifies the type property of the target component.
-
-**Required permissions**: none
+Specifies the type attribute of the target component.
**System capability**: SystemCapability.Test.UiTest
**Parameters**
-| Name| Type | Mandatory| Description |
-| ------ | ------ | ---- | ------------ |
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | -------------- |
| tp | string | Yes | Component type.|
**Return value**
-| Type| Description |
-| ---- | -------------- |
+| Type| Description |
+| ---- | ---------------- |
| By | Returns the **By** object itself.|
**Example**
-```
-let by = BY.type('button') // Use the static constructor BY to create a By object and specify the type attribute
- of the target component.
+```js
+let by = BY.type('button') // Use the static constructor BY to create a By object and specify the type attribute of the target component.
```
### By.clickable
-clickable(b?:bool):By;
+clickable(b?: bool): By
Specifies the clickable attribute of the target component.
-**Required permissions**: none
-
**System capability**: SystemCapability.Test.UiTest
**Parameters**
-| Name| Type| Mandatory| Description |
-| ------ | ---- | ---- | ------------------------------ |
+| Name| Type| Mandatory| Description |
+| ------ | ---- | ---- | -------------------------------- |
| b | bool | No | Clickable status of the target component. The default value is **true**.|
**Return value**
-| Type| Description |
-| ---- | -------------- |
+| Type| Description |
+| ---- | ---------------- |
| By | Returns the **By** object itself.|
**Example**
+```js
+let by = BY.clickable(true) // Use the static constructor BY to create a By object and specify the clickable status attribute of the target component.
```
-let by = BY.clickable(true) // Use the static constructor BY to create a By object and specify the clickable attribute
- of the target component.
+
+### By.longClickable9+
+
+longClickable(b?: bool): By
+
+Specifies the long-clickable status attribute of the target component.
+
+**System capability**: SystemCapability.Test.UiTest
+
+**Parameters**
+
+| Name| Type| Mandatory| Description |
+| ------ | ---- | ---- | ------------------------------------ |
+| b | bool | No | Long-clickable status of the target component. The default value is **true**.|
+
+**Return value**
+
+| Type| Description |
+| ---- | ---------------- |
+| By | Returns the **By** object itself.|
+
+**Example**
+
+```js
+let by = BY.longClickable(true) // Use the static constructor BY to create a By object and specify the long-clickable status attribute of the target component.
```
### By.scrollable
-scrollable(b?:bool):By;
+scrollable(b?: bool): By
-Specifies the scrollable attribute of the target component.
-
-**Required permissions**: none
+Specifies the scrollable status attribute of the target component.
**System capability**: SystemCapability.Test.UiTest
**Parameters**
-| Name| Type| Mandatory| Description |
-| ------ | ---- | ---- | -------------------------- |
+| Name| Type| Mandatory| Description |
+| ------ | ---- | ---- | ---------------------------- |
| b | bool | No | Scrollable status of the target component. The default value is **true**.|
**Return value**
-| Type| Description |
-| ---- | -------------- |
+| Type| Description |
+| ---- | ---------------- |
| By | Returns the **By** object itself.|
**Example**
-```
-let by = BY.scrollable(true) // Use the static constructor BY to create a By object and specify the scrollable attribute
- of the target component.
+```js
+let by = BY.scrollable(true) // Use the static constructor BY to create a By object and specify the scrollable status attribute of the target component.
```
### By.enabled
-enabled(b?:bool):By;
-
-Specifies the enable attribute of the target component.
+enabled(b?: bool): By
-**Required permissions**: none
+Specifies the enabled status attribute of the target component.
**System capability**: SystemCapability.Test.UiTest
**Parameters**
-| Name| Type| Mandatory| Description |
-| ------ | ---- | ---- | ---------------------------- |
-| b | bool | No | Enable status of the target component. The default value is **true**.|
+| Name| Type| Mandatory| Description |
+| ------ | ---- | ---- | ------------------------------ |
+| b | bool | No | Enabled status of the target component. The default value is **true**.|
**Return value**
-| Type| Description |
-| ---- | -------------- |
+| Type| Description |
+| ---- | ---------------- |
| By | Returns the **By** object itself.|
**Example**
-```
-let by = BY.enabled(true) // Use the static constructor BY to create a By object and specify the enable attribute
- of the target component.
+```js
+let by = BY.enabled(true) // Use the static constructor BY to create a By object and specify the enabled status attribute of the target component.
```
### By.focused
-focused(b?:bool):By;
-
-Specifies the focused attribute of the target component.
+focused(b?: bool): By
-**Required permissions**: none
+Specifies the focused status attribute of the target component.
**System capability**: SystemCapability.Test.UiTest
**Parameters**
-| Name| Type| Mandatory| Description |
-| ------ | ---- | ---- | ------------------------ |
+| Name| Type| Mandatory| Description |
+| ------ | ---- | ---- | -------------------------- |
| b | bool | No | Focused status of the target component. The default value is **true**.|
**Return value**
-| Type| Description |
-| ---- | -------------- |
+| Type| Description |
+| ---- | ---------------- |
| By | Returns the **By** object itself.|
**Example**
-```
-let by = BY.enabled(true) // Use the static constructor BY to create a By object and specify the focused attribute
- of the target component.
+```js
+let by = BY.focused(true) // Use the static constructor BY to create a By object and specify the focused status attribute of the target component.
```
### By.selected
-selected(b?:bool):By;
-
-Specifies the selected attribute of the target component.
+selected(b?: bool): By
-**Required permissions**: none
+Specifies the selected status attribute of the target component.
**System capability**: SystemCapability.Test.UiTest
**Parameters**
-| Name| Type| Mandatory| Description |
-| ------ | ---- | ---- | ------------------------------ |
+| Name| Type| Mandatory| Description |
+| ------ | ---- | ---- | -------------------------------- |
| b | bool | No | Selected status of the target component. The default value is **true**.|
**Return value**
+| Type| Description |
+| ---- | ---------------- |
+| By | Returns the **By** object itself.|
+
+**Example**
+
+```js
+let by = BY.selected(true) // Use the static constructor BY to create a By object and specify the selected status attribute of the target component.
+```
+
+### By.checked9+
+
+checked(b?: bool): By
+
+Specifies the checked status attribute of the target component.
+
+**System capability**: SystemCapability.Test.UiTest
+
+**Parameters**
+
+| Name| Type| Mandatory| Description |
+| ------ | ---- | ---- | --------------------------------- |
+| b | bool | No | Checked status of the target component. The default value is **false**.|
+
+**Return value**
+
| Type| Description |
| ---- | -------------- |
| By | Returns the **By** object itself.|
**Example**
+```js
+let by = BY.checked(true) // Use the static constructor BY to create a By object and specify the checked status attribute of the target component.
```
-let by = BY.selected(true) // Use the static constructor BY to create a By object and specify the selected attribute
- of the target component.
+
+### By.checkable9+
+
+checkable(b?: bool): By
+
+Specifies the checkable status attribute of the target component.
+
+**System capability**: SystemCapability.Test.UiTest
+
+**Parameters**
+
+| Name| Type| Mandatory| Description |
+| ------ | ---- | ---- | ------------------------------------- |
+| b | bool | No | Checkable status of the target component. The default value is **false**.|
+
+**Return value**
+
+| Type| Description |
+| ---- | ---------------- |
+| By | Returns the **By** object itself.|
+
+**Example**
+
+```js
+let by = BY.checkable(true) // Use the static constructor BY to create a By object and specify the checkable status attribute of the target component.
```
### By.isBefore
-isBefore(by:By):By;
+isBefore(by: By): By
Specifies the attributes of the component before which the target component is located.
-**Required permissions**: none
-
**System capability**: SystemCapability.Test.UiTest
**Parameters**
-| Name| Type| Mandatory| Description |
-| ------ | ---- | ---- | -------------- |
+| Name| Type| Mandatory| Description |
+| ------ | ---- | ---- | ---------------- |
| by | By | Yes | Attributes of the component before which the target component is located.|
**Return value**
-| Type| Description |
-| ---- | -------------- |
+| Type| Description |
+| ---- | ---------------- |
| By | Returns the **By** object itself.|
**Example**
-```
-let by = BY.isBefore(BY.text('123')) // Use the static constructor BY to create a By object and specify the attributes
- of the component before which the target component is located.
+```js
+let by = BY.isBefore(BY.text('123')) // Use the static constructor BY to create a By object and specify the attributes of the component before which the target component is located.
```
### By.isAfter
-isAfter(by:By):By;
+isAfter(by: By): By
Specifies the attributes of the component after which the target component is located.
-**Required permissions**: none
-
**System capability**: SystemCapability.Test.UiTest
**Parameters**
-| Name| Type| Mandatory| Description |
-| ------ | ---- | ---- | -------------- |
+| Name| Type| Mandatory| Description |
+| ------ | ---- | ---- | ---------------- |
| by | By | Yes | Attributes of the component before which the target component is located.|
**Return value**
-| Type| Description |
-| ---- | -------------- |
+| Type| Description |
+| ---- | ---------------- |
| By | Returns the **By** object itself.|
**Example**
-```
-let by = BY.isAfter(BY.text('123')) // Use the static constructor BY to create a By object and specify the attributes
- of the component after which the target component is located.
+```js
+let by = BY.isAfter(BY.text('123')) // Use the static constructor BY to create a By object and specify the attributes of the component after which the target component is located.
```
## UiComponent
In **UiTest**, the **UiComponent** class represents a component on the UI and provides APIs for obtaining component attributes, clicking a component, scrolling to search for a component, and text injection.
-All APIs provided by this class use a promise to return the result and must be invoked using **await**.
+All APIs provided in this class use a promise to return the result and must be invoked using **await**.
+
+### Rect9+
+
+Provides border information of a component.
+
+**System capability**: SystemCapability.Test.UiTest
+
+| Name | Type| Readable| Writable| Description |
+| ------- | -------- | ---- | ---- | ------------------------- |
+| leftX | number | Yes | No | X coordinate of the upper left corner of the component borders.|
+| topY | number | Yes | No | Y coordinate of the upper left corner of the component borders.|
+| rightX | number | Yes | No | X coordinate of the lower right corner of the component borders.|
+| bottomY | number | Yes | No | Y coordinate of the lower right corner of the component borders.|
### UiComponent.click
-click():Promise;
+click(): Promise\
Clicks this component.
-**Required permissions**: none
-
**System capability**: SystemCapability.Test.UiTest
**Example**
-```
+```js
async function demo() {
let driver = UiDriver.create()
let button = await driver.findComponent(BY.type('button'))
@@ -389,37 +427,33 @@ async function demo() {
### UiComponent.doubleClick
-doubleClick():Promise;
+doubleClick(): Promise\