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/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 ![IDL-interface-description](./figures/IDL-interface-description.png) @@ -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/ability/ability-assistant-guidelines.md b/en/application-dev/ability/ability-assistant-guidelines.md index af99d83038589c063817b92084e89c808863155f..4d7b0edb2b91ca07123ad7495f4d64fc2f525e1d 100644 --- a/en/application-dev/ability/ability-assistant-guidelines.md +++ b/en/application-dev/ability/ability-assistant-guidelines.md @@ -65,18 +65,18 @@ The ability assistant enables you to start applications, atomic services, and te - **dump** - Prints ability related information. + Prints ability-related information. | Name | Level-2 Parameter | Description | | ----------------- | -------------------- | ------------------------------------------------------------ | | -h/--help | - | Prints help information. | | -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 | + | -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 dee25352d7df1e828eada909bde107554a168bd9..283037aedc8c219bee48511898dd300a0c05dc3b 100644 --- a/en/application-dev/ability/ability-brief.md +++ b/en/application-dev/ability/ability-brief.md @@ -13,7 +13,7 @@ The stage model is designed to make it easier to develop complex applications in | -------------- | ------------------------------------------------------------ | -------------------------------------------------------- | | 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 | +| 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). | 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). ![contextIntroduction](figures/contextIntroduction.png) @@ -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-formability.md b/en/application-dev/ability/fa-formability.md index dac8d5ee66e4441021a91f1967815d364227228c..2cbf353e910af8ebb8dff02218331ae97f568e2c 100644 --- a/en/application-dev/ability/fa-formability.md +++ b/en/application-dev/ability/fa-formability.md @@ -10,25 +10,26 @@ Basic concepts: - 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. -> ![icon-note.gif](public_sys-resources/icon-note.gif) **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** 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 @@ -37,7 +38,7 @@ 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. | +| 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 widget. | @@ -73,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 during widget instance retrieval or update. + // Persistently store widget information for subsequent use, such as widget instance retrieval or update. let obj = { "title": "titleOnCreate", "detail": "detailOnCreate" @@ -120,7 +121,7 @@ To create a widget in the FA model, you need to implement the lifecycles of **Li Configure the **config.json** file for the widget. -- The **js** module in the **config.json** file provides the JavaScript resources of the widget. 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 | | -------- | ------------------------------------------------------------ | -------- | ------------------------ | @@ -144,7 +145,7 @@ Configure the **config.json** file for the widget. }] ``` -- 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 | | ------------------- | ------------------------------------------------------------ | ---------- | ------------------------ | @@ -195,7 +196,7 @@ Configure the **config.json** file for the widget. ``` -### Persistently Store Widget Data +### 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. @@ -206,7 +207,7 @@ 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); @@ -233,21 +234,43 @@ You should override **onDestroy** to delete widget data. 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 - 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. -> ![icon-note.gif](public_sys-resources/icon-note.gif) **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
@@ -262,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 { @@ -303,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": { diff --git a/en/application-dev/ability/fa-pageability.md b/en/application-dev/ability/fa-pageability.md index 3c9fd320425f7b5fa961665aa104645d1dcbcebf..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** @@ -176,7 +180,7 @@ In the cross-device scenario, the application must also apply for the data synch ### 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 ef62358595f235aeae23d1f4b0bb63cb77936537..72b4542e19a675d3531948e07375d491fb001c63 100644 --- a/en/application-dev/ability/fa-serviceability.md +++ b/en/application-dev/ability/fa-serviceability.md @@ -238,7 +238,7 @@ You can use either of the following methods to connect to a Service ability: } ``` -### Connecting to a Remote Service Ability (Applying only to System Applications) +### Connecting to a Remote Service Ability >**NOTE** > diff --git a/en/application-dev/ability/stage-ability.md b/en/application-dev/ability/stage-ability.md index 91e7d1132a048a74ab168208d5f2212683350b78..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,7 +205,7 @@ 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| @@ -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 eb6b66c5507d0aab80d9d22576519f70aba351a2..0b4bfe8e3ec2943528e3bd2e8b640dea4ffbd070 100644 --- a/en/application-dev/ability/stage-brief.md +++ b/en/application-dev/ability/stage-brief.md @@ -8,7 +8,7 @@ The following figure shows the design ideas of the stage model. ![stagedesign](figures/stagedesign.png) -​ The stage model is designed based on the following considerations: +The stage model is designed based on the following considerations: - **Balance between application capabilities and overall system power consumption** diff --git a/en/application-dev/ability/stage-formextension.md b/en/application-dev/ability/stage-formextension.md index e1d3604c566b217a7b4f9f2c880faf5d4c71cf47..0a1b17b91cf2be48405e4e9681146f1017ffa93b 100644 --- a/en/application-dev/ability/stage-formextension.md +++ b/en/application-dev/ability/stage-formextension.md @@ -4,7 +4,7 @@ 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 functions such as opening a UI page or sending a message. +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: @@ -12,7 +12,8 @@ Basic concepts: - 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. -> ![icon-note.gif](public_sys-resources/icon-note.gif) **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. @@ -187,7 +188,7 @@ To create a widget in the stage model, implement the lifecycle callbacks of **Fo { "forms": [{ "name": "widget", - "description": "This is a service widget.", + "description": "This is a widget.", "src": "./js/widget/pages/index/index", "window": { "autoDesignWidth": true, @@ -252,7 +253,28 @@ Note that the **Want** passed by the widget host to the widget provider contains 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. +### 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 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. > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** diff --git a/en/application-dev/ability/stage-serviceextension.md b/en/application-dev/ability/stage-serviceextension.md index 90448c52428af38b8128477c24eec4911b88b827..c6f6362a727855189a398b6b305312c45e6135b1 100644 --- a/en/application-dev/ability/stage-serviceextension.md +++ b/en/application-dev/ability/stage-serviceextension.md @@ -1,86 +1,75 @@ # Service Extension Ability Development ## When to Use -**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 it 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 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 Service Extension ability 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'); - } - } - ``` + ```json + "extensionAbilities":[{ + "name": "ServiceExtAbility", + "icon": "$media:icon", + "description": "service", + "type": "service", + "visible": true, + "srcEntrance": "./ets/ServiceExtAbility/ServiceExtAbility.ts" + }] + ``` -2. Register the Service Extension ability. +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: -Declare the Service Extension ability in the **module.json** file by setting its **type** attribute to **service**. - -**module.json configuration example** - -```json -"extensionAbilities":[{ - "name": "ServiceExtAbility", - "icon": "$media:icon", - "description": "service", - "type": "service", - "visible": true, - "srcEntrance": "./ets/ServiceExtAbility/ServiceExtAbility.ts" -}] -``` - -## Development Example - -The following sample is provided to help you better understand how to develop a Service Extension ability: - -- [ServiceExtensionAbility](https://gitee.com/openharmony/app_samples/tree/master/ability/ServiceExtAbility) + ```js + import rpc from '@ohos.rpc' + class StubTest extends rpc.RemoteObject { + constructor(des) { + super(des); + } + onRemoteRequest(code, data, reply, option) { + } + } -This sample shows how to create a Service Extension ability in the **ServiceExtAbility.ts** file in the **ServiceExtensionAbility** directory. + 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 +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/database/database-relational-guidelines.md b/en/application-dev/database/database-relational-guidelines.md index cdcbf0b033288458f2d0ae4192476d86bc9f38b5..7e465b1a13d86a4512a6d0ec693a8f8c248374d8 100644 --- a/en/application-dev/database/database-relational-guidelines.md +++ b/en/application-dev/database/database-relational-guidelines.md @@ -89,7 +89,7 @@ The RDB provides **RdbPredicates** for you to set database operation conditions. | 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 | 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.| @@ -204,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.') }) ``` 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/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/napi/native-window-guidelines.md b/en/application-dev/napi/native-window-guidelines.md index f86fdb78ed8d0c111c1c2a1eb8b80ca2de5409bf..b92ccc54234c9162dad4b35242dcf9d992e5eeec 100644 --- a/en/application-dev/napi/native-window-guidelines.md +++ b/en/application-dev/napi/native-window-guidelines.md @@ -56,7 +56,7 @@ The following steps describe how to use `OH_NativeXComponent` in OpenHarmony to 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 OnSufaceCreatedCB(NativeXComponent* component, void* window) { + 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_); @@ -89,8 +89,8 @@ The following steps describe how to use `OH_NativeXComponent` in OpenHarmony to // Create Skia Canvas and write the content to the native window. ... - // After the write operation is complete, flush the buffer by using OH_NativeWindwo_NativeWindowFlushBuffer so that the data is displayed on the screen. - Regoin region{nullptr, 0}; + // 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) } ``` @@ -99,9 +99,9 @@ The following steps describe how to use `OH_NativeXComponent` in OpenHarmony to ```c++ OH_NativeXComponent_Callback &callback_; - callback_->OnSurfaceCreated = OnSufaceCreatedCB; - callback_->OnSurfaceChanged = OnSufaceChangedCB; - callback_->OnSurfaceDestoryed = OnSufaceDestoryedCB; + callback_->OnSurfaceCreated = OnSurfaceCreatedCB; + callback_->OnSurfaceChanged = OnSurfaceChangedCB; + callback_->OnSurfaceDestoryed = OnSurfaceDestoryedCB; callback_->DispatchTouchEvent = DispatchTouchEventCB; OH_NativeXComponent_RegisterCallback(nativeXComponent, callback_) ``` 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/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/start-with-ets-low-code.md b/en/application-dev/quick-start/start-with-ets-low-code.md index ca50b149038b8b5e573039f45bacabfbcaec1ec2..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. -![en-us_image_0000001233208980](figures/en-us_image_0000001233208980.gif) + ![en-us_image_0000001233208980](figures/en-us_image_0000001233208980.gif) 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 ![en-us_image_0000001277608813](figures/en-us_image_0000001277608813.png)**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 ![en-us_image_0000001277608813](figures/en-us_image_0000001277608813.png)**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. ![en-us_image_0000001235731706](figures/en-us_image_0000001235731706.gif) @@ -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 ![en-us_image_0000001277728577](figures/en-us_image_0000001277728577.png)**General** and set **Height** of the **Button** component to **40vp**. Click ![en-us_image_0000001277809337](figures/en-us_image_0000001277809337.png)**Feature** and set **Label** to **Next** and **FontSize** to **25fp**. Below is an illustration of the operations. -![en-us_image_0000001235732402](figures/en-us_image_0000001235732402.gif) + ![en-us_image_0000001235732402](figures/en-us_image_0000001235732402.gif) 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. -![en-us_image_0000001233368868](figures/en-us_image_0000001233368868.png) + ![en-us_image_0000001233368868](figures/en-us_image_0000001233368868.png) 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 ![en-us_image_0000001277488985](figures/en-us_image_0000001277488985.png)**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 ![en-us_image_0000001277488985](figures/en-us_image_0000001277488985.png)**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. ![en-us_image_0000001280255513](figures/en-us_image_0000001280255513.gif) 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 865f2b69847412f626c47d8228d1a3dc344a3b7a..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. -![en-us_image_0000001216600980](figures/en-us_image_0000001216600980.gif) + ![en-us_image_0000001216600980](figures/en-us_image_0000001216600980.gif) 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 ![en-us_image_0000001260226691](figures/en-us_image_0000001260226691.png)**General** and set **Height** to **100%** so that the component fills the entire screen. Click ![en-us_image_0000001215226858](figures/en-us_image_0000001215226858.png)**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. -![en-us_image_0000001216448880](figures/en-us_image_0000001216448880.gif) + ![en-us_image_0000001216448880](figures/en-us_image_0000001216448880.gif) 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**. -![en-us_image_0000001223882030](figures/en-us_image_0000001223882030.png) + create-newVisual + Below, you can see the structure of the **pages** folder. + + ![en-us_image_0000001223882030](figures/en-us_image_0000001223882030.png) + 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) diff --git a/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md b/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md index 6c8d70d16381f7b6875728d0045c2d32e400c757..5a21d564110cdf922e344c52ded3bd8d44604b2f 100644 --- a/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md +++ b/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md @@ -75,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 @@ -111,6 +113,8 @@ grantUserGrantedPermission(tokenID: number, permissionName: string, permissionFl 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 @@ -145,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 @@ -181,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 @@ -215,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-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-arraylist.md b/en/application-dev/reference/apis/js-apis-arraylist.md index a887e9a02b24275e2574ea5fac7ecee0ac49f723..341295a167878f6c3696efe01f15a29415f91cd8 100644 --- a/en/application-dev/reference/apis/js-apis-arraylist.md +++ b/en/application-dev/reference/apis/js-apis-arraylist.md @@ -320,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; }); ``` @@ -394,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(); ``` diff --git a/en/application-dev/reference/apis/js-apis-audio.md b/en/application-dev/reference/apis/js-apis-audio.md index 3a449fb0426baae2532bd3ad2f748d5af49263ec..87e2238b4c208c14833f7fe00baefd93820209f4 100644 --- a/en/application-dev/reference/apis/js-apis-audio.md +++ b/en/application-dev/reference/apis/js-apis-audio.md @@ -3063,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 7ffa13920f46c4e9fb71a46ddf85025d0385dcad..cbb0ff47c767fd26e499913f44ba88d7e6187f17 100644 --- a/en/application-dev/reference/apis/js-apis-backgroundTaskManager.md +++ b/en/application-dev/reference/apis/js-apis-backgroundTaskManager.md @@ -128,6 +128,7 @@ Cancels the suspension delay. **Example** ```js + let id = 1; backgroundTaskManager.cancelSuspendDelay(id); ``` @@ -313,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 -> ![icon-note.gif](public_sys-resources/icon-note.gif) **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-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 -> ![icon-note.gif](public_sys-resources/icon-note.gif) **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-data-ability.md b/en/application-dev/reference/apis/js-apis-data-ability.md index 5e13507952dec34e32f7a4e49a75669ccc16fd82..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,6 @@ # 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. @@ -24,15 +24,15 @@ Creates an **RdbPredicates** object from a **DataAbilityPredicates** object. **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 @@ -58,15 +58,15 @@ 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 @@ -85,15 +85,15 @@ 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 @@ -112,9 +112,9 @@ 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 @@ -138,9 +138,9 @@ 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 @@ -164,9 +164,9 @@ 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 @@ -187,9 +187,9 @@ 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 @@ -210,15 +210,15 @@ 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 @@ -237,15 +237,15 @@ 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 @@ -264,15 +264,15 @@ 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** ``` @@ -291,14 +291,14 @@ 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 @@ -317,14 +317,14 @@ 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 @@ -343,15 +343,15 @@ 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 @@ -370,15 +370,15 @@ 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 @@ -397,16 +397,16 @@ 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 @@ -425,16 +425,16 @@ 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 @@ -453,15 +453,15 @@ 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 @@ -480,15 +480,15 @@ 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 @@ -507,15 +507,15 @@ 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 @@ -534,15 +534,15 @@ 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 @@ -561,14 +561,14 @@ 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 @@ -587,14 +587,14 @@ 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 @@ -613,9 +613,9 @@ 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 @@ -634,14 +634,14 @@ 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 @@ -660,14 +660,14 @@ 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 @@ -686,14 +686,14 @@ 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 @@ -705,19 +705,20 @@ 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 @@ -736,16 +737,16 @@ 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 @@ -764,16 +765,16 @@ 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 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 86b5c39b48db3bbdd15de93bd3411e915c351135..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 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 RDB store. This API uses an asynchronous callback to return the result | 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 an asynchronous 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) => { @@ -1090,7 +984,7 @@ 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) }) ``` @@ -1204,7 +1098,7 @@ promise.then(async (ret) => { ``` ### update9+ -update(table: string, values: ValuesBucket, predicates: DataSharePredicates, callback: AsyncCallback<number>):void +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. @@ -1215,19 +1109,19 @@ Updates data in the database based on the specified **DataSharePredicates** obje | -------- | -------- | -------- | -------- | | 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 | Yes| Update conditions specified by the **DataSharePredicates** object.| +| 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 dataShare from '@ohos.data.dataShare' +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 dataShare.DataSharePredicates() +let predicates = new dataSharePredicates.DataSharePredicates() predicates.equalTo("NAME", "Lisa") rdbStore.update("EMPLOYEE", valueBucket, predicates, function (err, ret) { if (err) { @@ -1250,7 +1144,7 @@ Updates data in the database based on the specified **DataSharePredicates** obje | -------- | -------- | -------- | -------- | | 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 | Yes| Update conditions specified by the **DataSharePredicates** object.| +| predicates | [DataSharePredicates](js-apis-data-DataSharePredicates.md#datasharepredicates) | Yes| Update conditions specified by the **DataSharePredicates** object.| **Return value** | Type| Description| @@ -1259,14 +1153,14 @@ Updates data in the database based on the specified **DataSharePredicates** obje **Example** ```js -import dataShare from '@ohos.data.dataShare' +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 dataShare.DataSharePredicates() +let predicates = new dataSharePredicates.DataSharePredicates() predicates.equalTo("NAME", "Lisa") let promise = rdbStore.update("EMPLOYEE", valueBucket, predicates) promise.then(async (ret) => { @@ -1300,7 +1194,7 @@ 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) }) ``` @@ -1329,7 +1223,7 @@ 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) }) @@ -1348,25 +1242,25 @@ Deletes data from the database based on the specified **DataSharePredicates** ob | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | table | string | Yes| Name of the target table.| -| predicates | DataSharePredicates | Yes| Conditions specified by the **DataSharePredicates** object for deleting data.| +| 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 dataShare from '@ohos.data.dataShare' -let predicates = new dataShare.DataSharePredicates() +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("Delete rows: " + rows) + console.log("Deleted rows: " + rows) }) ``` ### delete9+ -delete(table: string, predicates: DataSharePredicates):Promise<number> +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. @@ -1376,7 +1270,7 @@ Deletes data from the database based on the specified **DataSharePredicates** ob | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | table | string | Yes| Name of the target table.| -| predicates | DataSharePredicates | Yes| Conditions specified by the **DataSharePredicates** object for deleting data.| +| predicates | [DataSharePredicates](js-apis-data-DataSharePredicates.md#datasharepredicates) | Yes| Conditions specified by the **DataSharePredicates** object for deleting data.| **Return value** | Type| Description| @@ -1385,12 +1279,12 @@ Deletes data from the database based on the specified **DataSharePredicates** ob **Example** ```js -import dataShare from '@ohos.data.dataShare' -let predicates = new dataShare.DataSharePredicates() +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("Delete rows: " + rows) + console.log("Deleted rows: " + rows) }).catch((err) => { console.info("Failed to delete data, err: " + err) }) @@ -1417,7 +1311,7 @@ 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) @@ -1454,7 +1348,7 @@ Queries data in the database based on specified conditions. This API uses a prom 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) }) ``` @@ -1469,18 +1363,18 @@ Queries data in the database based on specified conditions. This API uses an asy **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| predicates | DataSharePredicates | Yes| Query conditions specified by the **DataSharePredicates** object.| +| 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 dataShare from '@ohos.data.dataShare' -let predicates = new dataShare.DataSharePredicates() +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("Query failed, err: " + err) + console.info("Failed to query data, err: " + err) return } console.log("ResultSet column names: " + resultSet.columnNames) @@ -1499,7 +1393,7 @@ Queries data in the database based on specified conditions. This API uses a prom **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| predicates | DataSharePredicates | Yes| Query conditions specified by the **DataSharePredicates** object.| +| 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** @@ -1509,15 +1403,15 @@ Queries data in the database based on specified conditions. This API uses a prom **Example** ```js -import dataShare from '@ohos.data.dataShare' -let predicates = new dataShare.DataSharePredicates() +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("Query failed, err: " + err) + console.info("Failed to query data, err: " + err) }) ``` @@ -1540,7 +1434,7 @@ 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) @@ -1575,7 +1469,7 @@ promise.then((resultSet) => { 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) }) ``` @@ -1600,7 +1494,7 @@ 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.') @@ -1634,7 +1528,7 @@ let promise = rdbStore.executeSql(SQL_CREATE_TABLE) promise.then(() => { console.info('Create table done.') }).catch((err) => { - console.info("ExecuteSql failed, err: " + err) + console.info("Failed to execute SQL, err: " + err) }) ``` @@ -1745,10 +1639,10 @@ Backs up the database with the specified name. This API uses an asynchronous cal ```js rdbStore.backup("dbBackup.db", function(err) { if (err) { - console.info('Backup failed, err: ' + err) + console.info('Failed to back up data, err: ' + err) return } - console.info('Backup success.') + console.info('Backup successful.') }) ``` @@ -1774,9 +1668,9 @@ Backs up the database with the specified name. This API uses a promise to return ```js let promiseBackup = rdbStore.backup("dbBackup.db") promiseBackup.then(()=>{ - console.info('Backup success.') + console.info('Backup successful.') }).catch((err)=>{ - console.info('Backup failed, err: ' + err) + console.info('Failed to back up data, err: ' + err) }) ``` @@ -1798,10 +1692,10 @@ Restores a database from a specified database backup file. This API uses an asyn ```js rdbStore.restore("dbBackup.db", function(err) { if (err) { - console.info('Restore failed, err: ' + err) + console.info('Failed to restore data, err: ' + err) return } - console.info('Restore success.') + console.info('Restore successful.') }) ``` @@ -1827,9 +1721,9 @@ Restores a database from a specified database backup file. This API uses a promi ```js let promiseRestore = rdbStore.restore("dbBackup.db") promiseRestore.then(()=>{ - console.info('Restore success.') + console.info('Restore successful.') }).catch((err)=>{ - console.info('Restore failed, err: ' + err) + console.info('Failed to restore data, err: ' + err) }) ``` @@ -1910,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('Failed to obtain distributed table name, err: ' + err) + console.info('Failed to obtain DistributedTableName, err: ' + err) return } - console.info('Obtained distributed table name successfully, tableName=.' + tableName) + console.info('Obtained DistributedTableName successfully, tableName=.' + tableName) }) ``` @@ -1943,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('Obtained distributed table name successfully, tableName= ' + tableName) + console.info('Obtained DistributedTableName successfully, tableName= ' + tableName) }).catch((err) => { - console.info('Failed to obtain distributed table name, err: ' + err) + console.info('Failed to obtain DistributedTableName, err: ' + err) }) ``` @@ -1970,9 +1864,9 @@ Synchronizes data between devices. This API uses an asynchronous callback to ret **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) return 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 2fdd9e1b06f1bfd40c30e941068e821a916204ae..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 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-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. + > ![icon-note.gif](public_sys-resources/icon-note.gif) **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 4d45271a8791a8370ed4950c75ac96c0fb408b8c..c01d3ce2f21c64cca00b453a3d3a6448b84fc22f 100644 --- a/en/application-dev/reference/apis/js-apis-hilog.md +++ b/en/application-dev/reference/apis/js-apis-hilog.md @@ -23,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. | @@ -67,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.| @@ -98,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.| @@ -129,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.| @@ -160,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.| @@ -191,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-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. + > ![icon-note.gif](public_sys-resources/icon-note.gif) **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. + > ![icon-note.gif](public_sys-resources/icon-note.gif) **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-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 7369fcdb2e2415913fb3b197aaa8d209a9fee4ef..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+ diff --git a/en/application-dev/reference/apis/js-apis-inputmethod.md b/en/application-dev/reference/apis/js-apis-inputmethod.md index c61ca55fd32ff103763e4271392c0e23c83deda7..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** - ```js +```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. @@ -140,18 +141,18 @@ 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); - } +```js + InputMethodSetting.listInputMethod((properties)=>{ + for (var i = 0;i < properties.length; i++) { + var property = properties[i]; + console.info(property.packageName + "/" + property.methodId); + } }); - ``` +``` ### listInputMethod -listInputMethod(): Promise<Array<InputMethodProperty>> +listInputMethod(): Array<InputMethodProperty> Obtains the list of installed input methods. This API uses an asynchronous callback to return the result. @@ -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-list.md b/en/application-dev/reference/apis/js-apis-list.md index dfd940b660fe213cf114a7a2b3391c75eb608c5e..0b839a5a0baae3fa58e4592485c3b9e959183530 100644 --- a/en/application-dev/reference/apis/js-apis-list.md +++ b/en/application-dev/reference/apis/js-apis-list.md @@ -364,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; }); ``` @@ -439,8 +439,8 @@ 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 @@ -472,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 diff --git a/en/application-dev/reference/apis/js-apis-mediaquery.md b/en/application-dev/reference/apis/js-apis-mediaquery.md index 1f754aa69bee3f93a3420df473d06e915a673c4f..bb6de45ab300f0e8fe1d5143849e656869decd3f 100644 --- a/en/application-dev/reference/apis/js-apis-mediaquery.md +++ b/en/application-dev/reference/apis/js-apis-mediaquery.md @@ -23,17 +23,20 @@ matchMediaSync(condition: string): MediaQueryListener Sets the media query criteria and returns the corresponding listening handle. +**System capability**: SystemCapability.ArkUI.ArkUI.Full + **Parameters** -| Name | Type | Mandatory | Description | -| --------- | ------ | ---- | ---------- | -| condition | string | Yes | Matching condition of a media event.| +| 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). | **Return value** | Type | Description | | ------------------ | ---------------------- | -| MediaQueryListener | Listening handle to a media event, which is used to register or unregister the listening callback.| +| 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. ``` @@ -43,6 +46,7 @@ listener = mediaquery.matchMediaSync('(orientation: landscape)'); // Listen for Media query handle, including the first query result when the handle is applied for. +**System capability**: SystemCapability.ArkUI.ArkUI.Full ### Attributes @@ -58,6 +62,8 @@ 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. +**System capability**: SystemCapability.ArkUI.ArkUI.Full + **Parameters** | Name | Type | Mandatory | Description | | -------- | -------------------------------- | ---- | ---------------- | @@ -72,12 +78,15 @@ 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. +Deregisters a callback with the corresponding query condition by using the handle, so that no callback is triggered when the media attributes change. + +**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 unregistered. If the default value is used, all callbacks of the handle are unregistered.| +| callback | Callback<MediaQueryResult> | No | Callback to be deregistered. If the default value is used, all callbacks of the handle are deregistered.| **Example** ```js @@ -92,7 +101,7 @@ Unregisters a callback with the corresponding query condition by using the handl } } listener.on('change', onPortrait) // Register a callback. - listener.off('change', onPortrait) // Unregister a callback. + listener.off('change', onPortrait) // Deregister a callback. ``` @@ -132,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-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 -> ![icon-note.gif](public_sys-resources/icon-note.gif) **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 573909893ea8c182e91b739d753a2f36bf244d16..5e2d47e03ba31ab4bae9118e3dc373359d56da11 100644 --- a/en/application-dev/reference/apis/js-apis-screenshot.md +++ b/en/application-dev/reference/apis/js-apis-screenshot.md @@ -1,8 +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** > > 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 @@ -17,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 @@ -63,7 +67,7 @@ Takes a screenshot and saves it as a **PixelMap** object. This method uses a cal | 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.| | callback | AsyncCallback<image.PixelMap> | Yes | Callback used to return a **PixelMap** object. | **Example** @@ -78,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) { @@ -103,13 +108,13 @@ Takes a screenshot and saves it as a **PixelMap** object. This method uses a pro | 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.| +| Promise<image.PixelMap> | Promise used to return a **PixelMap** object.| **Example** @@ -123,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-settings.md b/en/application-dev/reference/apis/js-apis-settings.md index 81444a400e5dc33c2a2b53c489488fea4fe1be58..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. @@ -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.display.SCREEN_BRIGHTNESS_STATUS
    • Time format: settings.date.TIME_FORMAT
  • Custom data items
| +| 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.display.SCREEN_BRIGHTNESS_STATUS**
    • Time format: **settings.date.TIME_FORMAT**
  • Custom data items
| | 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** @@ -93,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.display.SCREEN_BRIGHTNESS_STATUS
    • Time format: settings.date.TIME_FORMAT
  • Custom data items
| +| 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.display.SCREEN_BRIGHTNESS_STATUS**
    • Time format: **settings.date.TIME_FORMAT**
  • Custom data items
| | value | string | Yes| Value of the data item.| **Return value** 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 -> ![icon-note.gif](public_sys-resources/icon-note.gif) **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 2cc2fa8e75d563784bfc31efcb919619b5738994..c4f862b0e3cbf448631be452f826ac395a44435c 100644 --- a/en/application-dev/reference/apis/js-apis-system-cipher.md +++ b/en/application-dev/reference/apis/js-apis-system-cipher.md @@ -29,7 +29,7 @@ Encrypts or decrypts data using RSA. | 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 successful.| +| 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.| @@ -44,48 +44,53 @@ export default { // 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}`); - } + 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. action: 'decrypt', // 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=', + '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!`); + } }); } } @@ -109,9 +114,9 @@ Encrypts or decrypts data using AES. | 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**.| -| ivLen | string | No| Length of the IV for AES-based encryption and decryption, in bytes. The default value is **16**.| -| success | Function | No| Called when data is encrypted or decrypted successful.| +| 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.| @@ -128,35 +133,38 @@ export default { // 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. action: 'decrypt', // Text to be decrypted, which is binary text encoded in Base64. - text: 'CUg3tTxTIdpCfreIxIBdws3uhd5qXLwcrVl3XDnQzZFVHyjVVCDHS16rjopaZ4C5xU2Tc8mSDzt7\n' + - 'gp9vBfSwi7bMtSUvXG18DlncsKJFDkJpS5t0PkpS9YrJXrY80Gpe+ME6+6dN9bjgqMljbitDdBRf\n' + - 'S/ZWNI4Q8Q0suNjNkGU=', + 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!`); + } + }); }); } } 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 9d8abc5a6a73f95e4a1c674fc1c1a716154f56d8..a89640acc11ba359dfdf6011bbd4766cdd42b5ec 100644 --- a/en/application-dev/reference/apis/js-apis-system-time.md +++ b/en/application-dev/reference/apis/js-apis-system-time.md @@ -190,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)); diff --git a/en/application-dev/reference/apis/js-apis-util.md b/en/application-dev/reference/apis/js-apis-util.md index f427cfe5749110480fd4d7400fc3e3cb1de2c6e7..2ac8daeb3799908d57a5b7a2c5fd456dcfee8f59 100755 --- a/en/application-dev/reference/apis/js-apis-util.md +++ b/en/application-dev/reference/apis/js-apis-util.md @@ -1,11 +1,12 @@ # util -> **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. -This module provides common utility functions, such as **TextEncoder** and **TextDecoder** for string encoding and decoding, **RationalNumber** for rational number operations, **LruBuffer** for buffer management, **Scope** for range determination, **Base64** for Base64 encoding and decoding, and **types** for checks of built-in object types. +This module provides common utility functions, such as **TextEncoder** and **TextDecoder** for string encoding and decoding, **RationalNumber** for rational number operations, **LruBuffer** for buffer management, **Scope** for range determination, **Base64** for Base64 encoding and decoding, and **Types** for checks of built-in object types. ## Modules to Import @@ -23,15 +24,15 @@ Prints the input content in a formatted string. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | format | string | Yes | Format of the string to print. | - | ...args | Object[] | No | Data to format. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| format | string | Yes| Format of the string to print.| +| ...args | Object[] | No| Data to format.| **Return value** - | Type | Description | - | -------- | -------- | - | string | String in the specified format. | +| Type| Description| +| -------- | -------- | +| string | String in the specified format.| **Example** ```js @@ -49,14 +50,14 @@ Obtains detailed information about a system error code. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | errno | number | Yes | Error code generated. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| errno | number | Yes| Error code generated.| **Return value** - | Type | Description | - | -------- | -------- | - | string | Detailed information about the error code. | +| Type| Description| +| -------- | -------- | +| string | Detailed information about the error code.| **Example** ```js @@ -76,14 +77,14 @@ Calls back an asynchronous function. In the callback, the first parameter indica **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | original | Function | Yes | Asynchronous function. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| original | Function | Yes| Asynchronous function.| **Return value** - | Type | Description | - | -------- | -------- | - | Function | Callback, in which the first parameter indicates the cause of the rejection (the value is **null** if the promise has been resolved) and the second parameter indicates the resolved value. | +| Type| Description| +| -------- | -------- | +| Function | Callback, in which the first parameter indicates the cause of the rejection (the value is **null** if the promise has been resolved) and the second parameter indicates the resolved value.| **Example** ```js @@ -107,14 +108,14 @@ Processes an asynchronous function and returns a promise version. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | original | Function | Yes | Asynchronous function. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| original | Function | Yes| Asynchronous function.| **Return value** - | Type | Description | - | -------- | -------- | - | Function | Function in the error-first style (that is, **(err, value) =>...** is called as the last parameter) and the promise version. | +| Type| Description| +| -------- | -------- | +| Function | Function in the error-first style (that is, **(err, value) =>...** is called as the last parameter) and the promise version.| **Example** ```js @@ -138,11 +139,11 @@ Processes an asynchronous function and returns a promise version. **System capability**: SystemCapability.Utils.Lang - | Name | Type | Readable | Writable | Description | - | -------- | -------- | -------- | -------- | -------- | - | encoding | string | Yes | No | Encoding format.
- Supported formats: utf-8, ibm866, iso-8859-2, iso-8859-3, iso-8859-4, iso-8859-5, iso-8859-6, iso-8859-7, iso-8859-8, iso-8859-8-i, iso-8859-10, iso-8859-13, iso-8859-14, iso-8859-15, koi8-r, koi8-u, macintosh, windows-874, windows-1250, windows-1251, windows-1252, windows-1253, windows-1254, windows-1255, windows-1256, windows-1257, windows-1258, x-mac-cyrilli, gbk, gb18030, big5, euc-jp, iso-2022-jp, shift_jis, euc-kr, utf-16be, utf-16le | - | fatal | boolean | Yes | No | Whether to display fatal errors. | - | ignoreBOM | boolean | Yes | No | Whether to ignore the byte order marker (BOM). The default value is **false**, which indicates that the result contains the BOM. | +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| encoding | string | Yes| No| Encoding format.
- Supported formats: utf-8, ibm866, iso-8859-2, iso-8859-3, iso-8859-4, iso-8859-5, iso-8859-6, iso-8859-7, iso-8859-8, iso-8859-8-i, iso-8859-10, iso-8859-13, iso-8859-14, iso-8859-15, koi8-r, koi8-u, macintosh, windows-874, windows-1250, windows-1251, windows-1252, windows-1253, windows-1254, windows-1255, windows-1256, windows-1257, windows-1258, x-mac-cyrilli, gbk, gb18030, big5, euc-jp, iso-2022-jp, shift_jis, euc-kr, utf-16be, utf-16le| +| fatal | boolean | Yes| No| Whether to display fatal errors.| +| ignoreBOM | boolean | Yes| No| Whether to ignore the byte order marker (BOM). The default value is **false**, which indicates that the result contains the BOM.| ### constructor @@ -154,17 +155,17 @@ A constructor used to create a **TextDecoder** object. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | encoding | string | No | Encoding format. | - | options | Object | No | Encoding-related options, which include **fatal** and **ignoreBOM**. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| encoding | string | No| Encoding format.| +| options | Object | No| Encoding-related options, which include **fatal** and **ignoreBOM**.| **Table 1** options - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | fatal | boolean | No | Whether to display fatal errors. | - | ignoreBOM | boolean | No | Whether to ignore the BOM. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| fatal | boolean | No| Whether to display fatal errors.| +| ignoreBOM | boolean | No| Whether to ignore the BOM.| **Example** ```js @@ -181,21 +182,21 @@ Decodes the input content. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | input | Unit8Array | Yes | Uint8Array to decode. | - | options | Object | No | Options related to decoding. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| input | Unit8Array | Yes| Uint8Array to decode.| +| options | Object | No| Options related to decoding.| **Table 2** options - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | stream | boolean | No | Whether to allow data blocks in subsequent **decode()**. If data is processed in blocks, set this parameter to **true**. If this is the last data block to process or data is not divided into blocks, set this parameter to **false**. The default value is **false**. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| stream | boolean | No| Whether to allow data blocks in subsequent **decode()**. If data is processed in blocks, set this parameter to **true**. If this is the last data block to process or data is not divided into blocks, set this parameter to **false**. The default value is **false**.| **Return value** - | Type | Description | - | -------- | -------- | - | string | Data decoded. | +| Type| Description| +| -------- | -------- | +| string | Data decoded.| **Example** ```js @@ -219,9 +220,9 @@ Decodes the input content. **System capability**: SystemCapability.Utils.Lang - | Name | Type | Readable | Writable | Description | - | -------- | -------- | -------- | -------- | -------- | - | encoding | string | Yes | No | Encoding format. The default format is **utf-8**. | +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| encoding | string | Yes| No| Encoding format. The default format is **utf-8**.| ### constructor @@ -247,14 +248,14 @@ Encodes the input content. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | input | string | Yes | String to encode. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| input | string | Yes| String to encode.| **Return value** - | Type | Description | - | -------- | -------- | - | Uint8Array | Encoded text. | +| Type| Description| +| -------- | -------- | +| Uint8Array | Encoded text.| **Example** ```js @@ -274,15 +275,15 @@ Stores the UTF-8 encoded text. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | input | string | Yes | String to encode. | - | dest | Uint8Array | Yes | **Uint8Array** instance used to store the UTF-8 encoded text. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| input | string | Yes| String to encode.| +| dest | Uint8Array | Yes| **Uint8Array** instance used to store the UTF-8 encoded text.| **Return value** - | Type | Description | - | -------- | -------- | - | Uint8Array | Encoded text. | +| Type| Description| +| -------- | -------- | +| Uint8Array | Encoded text.| **Example** ```js @@ -304,10 +305,10 @@ A constructor used to create a **RationalNumber** object. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | numerator | number | Yes | Numerator, which is an integer. | - | denominator | number | Yes | Denominator, which is an integer. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| numerator | number | Yes| Numerator, which is an integer.| +| denominator | number | Yes| Denominator, which is an integer.| **Example** ```js @@ -324,14 +325,14 @@ Creates a **RationalNumber** object based on the given string. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | rationalString | string | Yes | String used to create the **RationalNumber** object. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| rationalString | string | Yes| String used to create the **RationalNumber** object.| **Return value** - | Type | Description | - | -------- | -------- | - | object | **RationalNumber** object created. | +| Type| Description| +| -------- | -------- | +| object | **RationalNumber** object created.| **Example** ```js @@ -349,17 +350,16 @@ Compares this **RationalNumber** object with a given object. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | another | RationalNumber | Yes | Object used to compare with this **RationalNumber** object. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| another | RationalNumber | Yes| Object used to compare with this **RationalNumber** object.| **Return value** - | Type | Description | - | -------- | -------- | - | number | Returns **0** if the two objects are equal; returns **1** if the given object is less than this object; return **-1** if the given object is greater than this object. | +| Type| Description| +| -------- | -------- | +| number | Returns **0** if the two objects are equal; returns **1** if the given object is less than this object; return **-1** if the given object is greater than this object.| **Example** - ```js var rationalNumber = new util.RationalNumber(1,2); var rational = rationalNumer.creatRationalFromString("3/4"); @@ -376,9 +376,9 @@ Obtains the value of this **RationalNumber** object as an integer or a floating- **System capability**: SystemCapability.Utils.Lang **Return value** - | Type | Description | - | -------- | -------- | - | number | An integer or a floating-point number. | +| Type| Description| +| -------- | -------- | +| number | An integer or a floating-point number.| **Example** ```js @@ -396,14 +396,14 @@ Checks whether this **RationalNumber** object equals the given object. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | object | Object | Yes | Object used to compare with this **RationalNumber** object. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| object | Object | Yes| Object used to compare with this **RationalNumber** object.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the two objects are equal; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the two objects are equal; returns **false** otherwise.| **Example** ```js @@ -422,15 +422,15 @@ Obtains the greatest common divisor of two specified integers. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | number1 | number | Yes | The first integer used to get the greatest common divisor. | - | number2 | number | Yes | The second integer used to get the greatest common divisor. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| number1 | number | Yes| The first integer used to get the greatest common divisor.| +| number2 | number | Yes| The second integer used to get the greatest common divisor.| **Return value** - | Type | Description | - | -------- | -------- | - | number | Greatest common divisor obtained. | +| Type| Description| +| -------- | -------- | +| number | Greatest common divisor obtained.| **Example** ```js @@ -449,9 +449,9 @@ Obtains the numerator of this **RationalNumber** object. **Return value** - | Type | Description | - | -------- | -------- | - | number | Numerator of this **RationalNumber** object. | +| Type| Description| +| -------- | -------- | +| number | Numerator of this **RationalNumber** object.| **Example** ```js @@ -469,9 +469,9 @@ Obtains the denominator of this **RationalNumber** object. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type | Description | - | -------- | -------- | - | number | Denominator of this **RationalNumber** object. | +| Type| Description| +| -------- | -------- | +| number | Denominator of this **RationalNumber** object.| **Example** ```js @@ -482,16 +482,16 @@ Obtains the denominator of this **RationalNumber** object. ### isZero8+ -isZero​(): boolean +isZero​():boolean Checks whether this **RationalNumber** object is **0**. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the value of this **RationalNumber** object is **0**; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the value of this **RationalNumber** object is **0**; returns **false** otherwise.| **Example** ```js @@ -509,9 +509,9 @@ Checks whether this **RationalNumber** object is a Not a Number (NaN). **System capability**: SystemCapability.Utils.Lang **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if this **RationalNumber** object is a NaN (the denominator and numerator are both **0**); returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if this **RationalNumber** object is a NaN (the denominator and numerator are both **0**); returns **false** otherwise.| **Example** ```js @@ -522,16 +522,16 @@ Checks whether this **RationalNumber** object is a Not a Number (NaN). ### isFinite8+ -isFinite​(): boolean +isFinite​():boolean Checks whether this **RationalNumber** object represents a finite value. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if this **RationalNumber** object represents a finite value (the denominator is not **0**); returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if this **RationalNumber** object represents a finite value (the denominator is not **0**); returns **false** otherwise.| **Example** ```js @@ -549,9 +549,9 @@ Obtains the string representation of this **RationalNumber** object. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type | Description | - | -------- | -------- | - | string | Returns **NaN** if the numerator and denominator of this object are both **0**; returns a string in Numerator/Denominator format otherwise, for example, **3/5**. | +| Type| Description| +| -------- | -------- | +| string | Returns **NaN** if the numerator and denominator of this object are both **0**; returns a string in Numerator/Denominator format otherwise, for example, **3/5**.| **Example** ```js @@ -565,9 +565,9 @@ Obtains the string representation of this **RationalNumber** object. **System capability**: SystemCapability.Utils.Lang - | Name | Type | Readable | Writable | Description | - | -------- | -------- | -------- | -------- | -------- | - | length | number | Yes | No | Total number of values in this buffer. | +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| length | number | Yes| No| Total number of values in this buffer.| **Example** ```js @@ -587,9 +587,9 @@ A constructor used to create an **LruBuffer** instance. The default capacity of **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | capacity | number | No | Capacity of the **LruBuffer** to create. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| capacity | number | No| Capacity of the **LruBuffer** to create.| **Example** ```js @@ -606,9 +606,9 @@ Changes the **LruBuffer** capacity. If the new capacity is less than or equal to **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | newCapacity | number | Yes | New capacity of the **LruBuffer**. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| newCapacity | number | Yes| New capacity of the **LruBuffer**.| **Example** ```js @@ -626,9 +626,9 @@ Obtains the string representation of this **LruBuffer** object. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type | Description | - | -------- | -------- | - | string | String representation of this **LruBuffer** object. | +| Type| Description| +| -------- | -------- | +| string | String representation of this **LruBuffer** object.| **Example** ```js @@ -649,9 +649,9 @@ Obtains the capacity of this buffer. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type | Description | - | -------- | -------- | - | number | Capacity of this buffer. | +| Type| Description| +| -------- | -------- | +| number | Capacity of this buffer.| **Example** ```js @@ -686,9 +686,9 @@ Obtains the number of return values for **createDefault()**. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type | Description | - | -------- | -------- | - | number | Number of return values for **createDefault()**. | +| Type| Description| +| -------- | -------- | +| number | Number of return values for **createDefault()**.| **Example** ```js @@ -707,9 +707,9 @@ Obtains the number of times that the queried values are mismatched. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type | Description | - | -------- | -------- | - | number | Number of times that the queried values are mismatched. | +| Type| Description| +| -------- | -------- | +| number | Number of times that the queried values are mismatched.| **Example** ```js @@ -729,9 +729,9 @@ Obtains the number of removals from this buffer. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type | Description | - | -------- | -------- | - | number | Number of removals from the buffer. | +| Type| Description| +| -------- | -------- | +| number | Number of removals from the buffer.| **Example** ```js @@ -752,9 +752,9 @@ Obtains the number of times that the queried values are matched. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type | Description | - | -------- | -------- | - | number | Number of times that the queried values are matched. | +| Type| Description| +| -------- | -------- | +| number | Number of times that the queried values are matched.| **Example** ```js @@ -774,9 +774,9 @@ Obtains the number of additions to this buffer. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type | Description | - | -------- | -------- | - | number | Number of additions to the buffer. | +| Type| Description| +| -------- | -------- | +| number | Number of additions to the buffer.| **Example** ```js @@ -795,9 +795,9 @@ Checks whether this buffer is empty. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the buffer does not contain any value. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the buffer does not contain any value.| **Example** ```js @@ -809,21 +809,21 @@ Checks whether this buffer is empty. ### get8+ -get(key: K): V | undefined +get(key: K): V | undefined Obtains the value of the specified key. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | key | K | Yes | Key based on which the value is queried. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| key | K | Yes| Key based on which the value is queried.| **Return value** - | Type | Description | - | -------- | -------- | - | V \ | undefind | Returns the value of the key if a match is found in the buffer; returns **undefined** otherwise. | +| Type| Description| +| -------- | -------- | +| V \| undefind | Returns the value of the key if a match is found in the buffer; returns **undefined** otherwise.| **Example** ```js @@ -842,15 +842,15 @@ Adds a key-value pair to this buffer. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | key | K | Yes | Key of the key-value pair to add. | - | value | V | Yes | Value of the key-value pair to add. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| key | K | Yes| Key of the key-value pair to add.| +| value | V | Yes| Value of the key-value pair to add.| **Return value** - | Type | Description | - | -------- | -------- | - | V | Returns the existing value if the key already exists; returns the value added otherwise. If the key or value is null, an exception will be thrown. | +| Type| Description| +| -------- | -------- | +| V | Returns the existing value if the key already exists; returns the value added otherwise. If the key or value is null, an exception will be thrown. | **Example** ```js @@ -868,9 +868,9 @@ Obtains all values in this buffer, listed from the most to the least recently ac **System capability**: SystemCapability.Utils.Lang **Return value** - | Type | Description | - | -------- | -------- | - | V [] | All values in the buffer, listed from the most to the least recently accessed. | +| Type| Description| +| -------- | -------- | +| V [] | All values in the buffer, listed from the most to the least recently accessed.| **Example** ```js @@ -891,9 +891,9 @@ Obtains all keys in this buffer, listed from the most to the least recently acce **System capability**: SystemCapability.Utils.Lang **Return value** - | Type | Description | - | -------- | -------- | - | K [] | All keys in the buffer, listed from the most to the least recently accessed. | +| Type| Description| +| -------- | -------- | +| K [] | All keys in the buffer, listed from the most to the least recently accessed.| **Example** ```js @@ -905,21 +905,21 @@ Obtains all keys in this buffer, listed from the most to the least recently acce ### remove8+ -remove(key: K): V | undefined +remove(key: K): V | undefined Removes the specified key and its value from this buffer. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | key | K | Yes | Key to remove. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| key | K | Yes| Key to remove.| **Return value** - | Type | Description | - | -------- | -------- | - | V \ | undefind | Returns an **Optional** object containing the removed key-value pair if the key exists in the buffer; returns an empty **Optional** object otherwise. If the key is null, an exception will be thrown. | +| Type| Description| +| -------- | -------- | +| V \| undefind | Returns an **Optional** object containing the removed key-value pair if the key exists in the buffer; returns an empty **Optional** object otherwise. If the key is null, an exception will be thrown.| **Example** ```js @@ -938,12 +938,12 @@ Performs subsequent operations after a value is removed. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | isEvict | boolean | No | Whether the buffer capacity is insufficient. If the value is **true**, this method is called due to insufficient capacity. | - | key | K | Yes | Key removed. | - | value | V | Yes | Value removed. | - | newValue | V | No | New value for the key if the **put()** method is called and the key to be added already exists. In other cases, this parameter is left blank. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| isEvict | boolean | No| Whether the buffer capacity is insufficient. If the value is **true**, this method is called due to insufficient capacity.| +| key | K | Yes| Key removed.| +| value | V | Yes| Value removed.| +| newValue | V | No| New value for the key if the **put()** method is called and the key to be added already exists. In other cases, this parameter is left blank.| **Example** ```js @@ -983,14 +983,14 @@ Checks whether this buffer contains the specified key. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | key | K | Yes | Key to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| key | K | Yes| Key to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the buffer contains the specified key; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the buffer contains the specified key; returns **false** otherwise.| **Example** ```js @@ -1009,14 +1009,14 @@ Creates a value if the value of the specified key is not available. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | key | K | Yes | Key of which the value is missing. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| key | K | Yes| Key of which the value is missing.| **Return value** - | Type | Description | - | -------- | -------- | - | V | Value of the key. | +| Type| Description| +| -------- | -------- | +| V | Value of the key.| **Example** ```js @@ -1034,9 +1034,9 @@ Obtains a new iterator object that contains all key-value pairs in this object. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type | Description | - | -------- | -------- | - | [K, V] | Iterable array. | +| Type| Description| +| -------- | -------- | +| [K, V] | Iterable array.| **Example** ```js @@ -1055,9 +1055,9 @@ Obtains a two-dimensional array in key-value pairs. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type | Description | - | -------- | -------- | - | [K, V] | Two-dimensional array in key-value pairs. | +| Type| Description| +| -------- | -------- | +| [K, V] | Two-dimensional array in key-value pairs.| **Example** ```js @@ -1079,7 +1079,7 @@ The values of the **ScopeComparable** type are used to implement the **compareTo interface ScopeComparable{ compareTo(other: ScopeComparable): boolean; } -type ScopeType = ScopeComparable | number; +type ScopeType = ScopeComparable | number; ``` @@ -1090,6 +1090,8 @@ Example ```js class Temperature{ constructor(value){ + // If TS is used for development, add the following code: + // private readonly _temp: Temperature; this._temp = value; } comapreTo(value){ @@ -1114,10 +1116,10 @@ A constructor used to create a **Scope** object with the specified upper and low **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | lowerObj | [ScopeType](#scopetype8) | Yes | Lower limit of the **Scope** object. | - | upperObj | [ScopeType](#scopetype8) | Yes | Upper limit of the **Scope** object. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| lowerObj | [ScopeType](#scopetype8) | Yes| Lower limit of the **Scope** object.| +| upperObj | [ScopeType](#scopetype8) | Yes| Upper limit of the **Scope** object.| **Example** ```js @@ -1136,9 +1138,9 @@ Obtains a string representation that contains this **Scope**. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type | Description | - | -------- | -------- | - | string | String representation containing the **Scope**. | +| Type| Description| +| -------- | -------- | +| string | String representation containing the **Scope**.| **Example** ```js @@ -1158,14 +1160,14 @@ Obtains the intersection of this **Scope** and the given **Scope**. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | range | [Scope](#scope8) | Yes | **Scope** specified. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| range | [Scope](#scope8) | Yes| **Scope** specified.| **Return value** - | Type | Description | - | -------- | -------- | - | [Scope](#scope8) | Intersection of this **Scope** and the given **Scope**. | +| Type| Description| +| -------- | -------- | +| [Scope](#scope8) | Intersection of this **Scope** and the given **Scope**.| **Example** ```js @@ -1181,22 +1183,22 @@ Obtains the intersection of this **Scope** and the given **Scope**. ### intersect8+ -intersect(lowerObj: ScopeType,upperObj: ScopeType): Scope +intersect(lowerObj:ScopeType,upperObj:ScopeType):Scope Obtains the intersection of this **Scope** and the given lower and upper limits. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | lowerObj | [ScopeType](#scopetype8) | Yes | Lower limit. | - | upperObj | [ScopeType](#scopetype8) | Yes | Upper limit. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| lowerObj | [ScopeType](#scopetype8) | Yes| Lower limit.| +| upperObj | [ScopeType](#scopetype8) | Yes| Upper limit.| **Return value** - | Type | Description | - | -------- | -------- | - | [Scope](#scope8) | Intersection of this **Scope** and the given lower and upper limits. | +| Type| Description| +| -------- | -------- | +| [Scope](#scope8) | Intersection of this **Scope** and the given lower and upper limits.| **Example** ```js @@ -1219,9 +1221,9 @@ Obtains the upper limit of this **Scope**. **Return value** - | Type | Description | - | -------- | -------- | - | [ScopeType](#scopetype8) | Upper limit of this **Scope**. | +| Type| Description| +| -------- | -------- | +| [ScopeType](#scopetype8) | Upper limit of this **Scope**.| **Example** ```js @@ -1241,9 +1243,9 @@ Obtains the lower limit of this **Scope**. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type | Description | - | -------- | -------- | - | [ScopeType](#scopetype8) | Lower limit of this **Scope**. | +| Type| Description| +| -------- | -------- | +| [ScopeType](#scopetype8) | Lower limit of this **Scope**.| **Example** ```js @@ -1263,17 +1265,18 @@ Obtains the union set of this **Scope** and the given lower and upper limits. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | lowerObj | [ScopeType](#scopetype8) | Yes | Lower limit. | - | upperObj | [ScopeType](#scopetype8) | Yes | Upper limit. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| lowerObj | [ScopeType](#scopetype8) | Yes| Lower limit.| +| upperObj | [ScopeType](#scopetype8) | Yes| Upper limit.| **Return value** - | Type | Description | - | -------- | -------- | - | [Scope](#scope8) | Union set of this **Scope** and the given lower and upper limits. | +| Type| Description| +| -------- | -------- | +| [Scope](#scope8) | Union set of this **Scope** and the given lower and upper limits.| **Example** + ```js var tempLower = new Temperature(30); var tempUpper = new Temperature(40); @@ -1286,21 +1289,21 @@ Obtains the union set of this **Scope** and the given lower and upper limits. ### expand8+ -expand(range:Scope):Scope +expand(range: Scope): Scope Obtains the union set of this **Scope** and the given **Scope**. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | range | [Scope](#scope8) | Yes | **Scope** specified. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| range | [Scope](#scope8) | Yes| **Scope** specified.| **Return value** - | Type | Description | - | -------- | -------- | - | [Scope](#scope8) | Union set of this **Scope** and the given **Scope**. | +| Type| Description| +| -------- | -------- | +| [Scope](#scope8) | Union set of this **Scope** and the given **Scope**.| **Example** ```js @@ -1323,14 +1326,14 @@ Obtains the union set of this **Scope** and the given value. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | [ScopeType](#scopetype8) | Yes | Value specified. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | [ScopeType](#scopetype8) | Yes| Value specified.| **Return value** - | Type | Description | - | -------- | -------- | - | [Scope](#scope8) | Union set of this **Scope** and the given value. | +| Type| Description| +| -------- | -------- | +| [Scope](#scope8) | Union set of this **Scope** and the given value.| **Example** ```js @@ -1351,14 +1354,14 @@ Checks whether a value is within this **Scope**. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | [ScopeType](#scopetype8) | Yes | Value specified. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | [ScopeType](#scopetype8) | Yes| Value specified.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the value is within this **Scope**; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the value is within this **Scope**; returns **false** otherwise.| **Example** ```js @@ -1379,14 +1382,14 @@ Checks whether a range is within this **Scope**. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | range | [Scope](#scope8) | Yes | **Scope** specified. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| range | [Scope](#scope8) | Yes| **Scope** specified.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the range is within this **Scope**; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the range is within this **Scope**; returns **false** otherwise.| **Example** ```js @@ -1409,14 +1412,14 @@ Limits a value to this **Scope**. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | [ScopeType](#scopetype8) | Yes | Value specified. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | [ScopeType](#scopetype8) | Yes| Value specified.| **Return value** - | Type | Description | - | -------- | -------- | - | [ScopeType](#scopetype8) | Returns **lowerObj** if the specified value is less than the lower limit; returns **upperObj** if the specified value is greater than the upper limit; returns the specified value if it is within this **Scope**. | +| Type| Description| +| -------- | -------- | +| [ScopeType](#scopetype8) | Returns **lowerObj** if the specified value is less than the lower limit; returns **upperObj** if the specified value is greater than the upper limit; returns the specified value if it is within this **Scope**.| **Example** ```js @@ -1454,14 +1457,14 @@ Encodes the input content. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | src | Uint8Array | Yes | Uint8Array to encode. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| src | Uint8Array | Yes| Uint8Array to encode.| **Return value** - | Type | Description | - | -------- | -------- | - | Uint8Array | Uint8Array encoded. | +| Type| Description| +| -------- | -------- | +| Uint8Array | Uint8Array encoded.| **Example** ```js @@ -1480,14 +1483,14 @@ Encodes the input content. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | src | Uint8Array | Yes | Uint8Array to encode. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| src | Uint8Array | Yes| Uint8Array to encode.| **Return value** - | Type | Description | - | -------- | -------- | - | string | String encoded from the Uint8Array. | +| Type| Description| +| -------- | -------- | +| string | String encoded from the Uint8Array.| **Example** ```js @@ -1499,21 +1502,21 @@ Encodes the input content. ### decodeSync8+ -decodeSync(src: Uint8Array | string): Uint8Array +decodeSync(src: Uint8Array | string): Uint8Array Decodes the input content. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | src | Uint8Array \ | string | Yes | Uint8Array or string to decode. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| src | Uint8Array \| string | Yes| Uint8Array or string to decode.| **Return value** - | Type | Description | - | -------- | -------- | - | Uint8Array | Uint8Array decoded. | +| Type| Description| +| -------- | -------- | +| Uint8Array | Uint8Array decoded.| **Example** ```js @@ -1532,14 +1535,14 @@ Encodes the input content asynchronously. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | src | Uint8Array | Yes | Uint8Array to encode asynchronously. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| src | Uint8Array | Yes| Uint8Array to encode asynchronously.| **Return value** - | Type | Description | - | -------- | -------- | - | Promise<Uint8Array> | Uint8Array obtained after asynchronous encoding. | +| Type| Description| +| -------- | -------- | +| Promise<Uint8Array> | Uint8Array obtained after asynchronous encoding.| **Example** ```js @@ -1563,14 +1566,14 @@ Encodes the input content asynchronously. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | src | Uint8Array | Yes | Uint8Array to encode asynchronously. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| src | Uint8Array | Yes| Uint8Array to encode asynchronously.| **Return value** - | Type | Description | - | -------- | -------- | - | Promise<string> | String obtained after asynchronous encoding. | +| Type| Description| +| -------- | -------- | +| Promise<string> | String obtained after asynchronous encoding.| **Example** ```js @@ -1584,21 +1587,21 @@ Encodes the input content asynchronously. ### decode8+ -decode(src: Uint8Array | string): Promise<Uint8Array> +decode(src: Uint8Array | string): Promise<Uint8Array> Decodes the input content asynchronously. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | src | Uint8Array \ | string | Yes | Uint8Array or string to decode asynchronously. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| src | Uint8Array \| string | Yes| Uint8Array or string to decode asynchronously.| **Return value** - | Type | Description | - | -------- | -------- | - | Promise<Uint8Array> | Uint8Array obtained after asynchronous decoding. | +| Type| Description| +| -------- | -------- | +| Promise<Uint8Array> | Uint8Array obtained after asynchronous decoding.| **Example** ```js @@ -1620,7 +1623,7 @@ Decodes the input content asynchronously. constructor() -A constructor used to create a **types** object. +A constructor used to create a **Types** object. **System capability**: SystemCapability.Utils.Lang @@ -1639,14 +1642,14 @@ Checks whether the input value is of the **ArrayBuffer** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **ArrayBuffer** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **ArrayBuffer** type; returns **false** otherwise.| **Example** ```js @@ -1666,14 +1669,14 @@ Checks whether the input value is of the **ArrayBufferView** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **ArrayBufferView** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **ArrayBufferView** type; returns **false** otherwise.| **Example** ```js @@ -1691,14 +1694,14 @@ Checks whether the input value is of the **arguments** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **arguments** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **arguments** type; returns **false** otherwise.| **Example** ```js @@ -1719,14 +1722,14 @@ Checks whether the input value is of the **ArrayBuffer** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **ArrayBuffer** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **ArrayBuffer** type; returns **false** otherwise.| **Example** ```js @@ -1744,14 +1747,14 @@ Checks whether the input value is an asynchronous function. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is an asynchronous function; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is an asynchronous function; returns **false** otherwise.| **Example** ```js @@ -1769,14 +1772,14 @@ Checks whether the input value is of the **Boolean** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Boolean** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Boolean** type; returns **false** otherwise.| **Example** ```js @@ -1794,14 +1797,14 @@ Checks whether the input value is of the **Boolean**, **Number**, **String**, or **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Boolean**, **Number**, **String**, or **Symbol** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Boolean**, **Number**, **String**, or **Symbol** type; returns **false** otherwise.| **Example** ```js @@ -1819,14 +1822,14 @@ Checks whether the input value is of the **DataView** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **DataView** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **DataView** type; returns **false** otherwise.| **Example** ```js @@ -1845,14 +1848,14 @@ Checks whether the input value is of the **Date** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Date** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Date** type; returns **false** otherwise.| **Example** ```js @@ -1870,14 +1873,14 @@ Checks whether the input value is of the **native external** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **native external** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **native external** type; returns **false** otherwise.| **Example** ```js @@ -1896,14 +1899,14 @@ Checks whether the input value is of the **Float32Array** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Float32Array** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Float32Array** type; returns **false** otherwise.| **Example** ```js @@ -1921,14 +1924,14 @@ Checks whether the input value is of the **Float64Array** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Float64Array** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Float64Array** type; returns **false** otherwise.| **Example** ```js @@ -1946,14 +1949,14 @@ Checks whether the input value is a generator function. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is a generator function; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is a generator function; returns **false** otherwise.| **Example** ```js @@ -1971,14 +1974,14 @@ Checks whether the input value is a generator object. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is a generator object; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is a generator object; returns **false** otherwise.| **Example** ```js @@ -1998,14 +2001,14 @@ Checks whether the input value is of the **Int8Array** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Int8Array** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Int8Array** type; returns **false** otherwise.| **Example** ```js @@ -2023,14 +2026,14 @@ Checks whether the input value is of the **Int16Array** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Int16Array** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Int16Array** type; returns **false** otherwise.| **Example** ```js @@ -2048,14 +2051,14 @@ Checks whether the input value is of the **Int32Array** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Int32Array** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Int32Array** type; returns **false** otherwise.| **Example** ```js @@ -2073,14 +2076,14 @@ Checks whether the input value is of the **Map** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Map** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Map** type; returns **false** otherwise.| **Example** ```js @@ -2098,14 +2101,14 @@ Checks whether the input value is of the **MapIterator** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **MapIterator** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **MapIterator** type; returns **false** otherwise.| **Example** ```js @@ -2124,14 +2127,14 @@ Checks whether the input value is of the **Error** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Error** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Error** type; returns **false** otherwise.| **Example** ```js @@ -2149,14 +2152,14 @@ Checks whether the input value is a number object. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is a number object; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is a number object; returns **false** otherwise.| **Example** ```js @@ -2174,14 +2177,14 @@ Checks whether the input value is a promise. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is a promise; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is a promise; returns **false** otherwise.| **Example** ```js @@ -2199,14 +2202,14 @@ Checks whether the input value is a proxy. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is a proxy; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is a proxy; returns **false** otherwise.| **Example** ```js @@ -2226,14 +2229,14 @@ Checks whether the input value is of the **RegExp** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **RegExp** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **RegExp** type; returns **false** otherwise.| **Example** ```js @@ -2251,14 +2254,14 @@ Checks whether the input value is of the **Set** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Set** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Set** type; returns **false** otherwise.| **Example** ```js @@ -2276,14 +2279,14 @@ Checks whether the input value is of the **SetIterator** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **SetIterator** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **SetIterator** type; returns **false** otherwise.| **Example** ```js @@ -2302,14 +2305,14 @@ Checks whether the input value is a string object. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is a string object; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is a string object; returns **false** otherwise.| **Example** ```js @@ -2327,14 +2330,14 @@ Checks whether the input value is a symbol object. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is a symbol object; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is a symbol object; returns **false** otherwise.| **Example** ```js @@ -2355,14 +2358,14 @@ Checks whether the input value is of the **TypedArray** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **TypedArray** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **TypedArray** type; returns **false** otherwise.| **Example** ```js @@ -2380,14 +2383,14 @@ Checks whether the input value is of the **Uint8Array** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Uint8Array** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Uint8Array** type; returns **false** otherwise.| **Example** ```js @@ -2405,14 +2408,14 @@ Checks whether the input value is of the **Uint8ClampedArray** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Uint8ClampedArray** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Uint8ClampedArray** type; returns **false** otherwise.| **Example** ```js @@ -2430,14 +2433,14 @@ Checks whether the input value is of the **Uint16Array** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Uint16Array** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Uint16Array** type; returns **false** otherwise.| **Example** ```js @@ -2455,14 +2458,14 @@ Checks whether the input value is of the **Uint32Array** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Uint32Array** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Uint32Array** type; returns **false** otherwise.| **Example** ```js @@ -2480,14 +2483,14 @@ Checks whether the input value is of the **WeakMap** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **WeakMap** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **WeakMap** type; returns **false** otherwise.| **Example** ```js @@ -2505,17 +2508,17 @@ Checks whether the input value is of the **WeakSet** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **WeakSet** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **WeakSet** type; returns **false** otherwise.| **Example** ```js var that = new util.types(); var result = that.isWeakSet(new WeakSet()); - ``` \ No newline at end of file + ``` diff --git a/en/application-dev/reference/apis/js-apis-vector.md b/en/application-dev/reference/apis/js-apis-vector.md index 9288f871d45e7a08a542221ddf561e6a4e4fe81b..5dd8e49bb0c2467b2885784b9c1281f61e46a003 100644 --- a/en/application-dev/reference/apis/js-apis-vector.md +++ b/en/application-dev/reference/apis/js-apis-vector.md @@ -319,10 +319,10 @@ vector.add(2); vector.add(4); vector.add(5); vector.add(4); -vector.replaceAllElements((value, index) => { +vector.replaceAllElements((value: number, index: number) => { return value = 2 * value; }); -vector.replaceAllElements((value, index) => { +vector.replaceAllElements((value: number, index: number) => { return value = value - 2; }); ``` @@ -394,8 +394,8 @@ vector.add(2); vector.add(4); vector.add(5); vector.add(4); -vector.sort((a, b) => a - b); -vector.sort((a, b) => b - a); +vector.sort((a: number, b: number) => a - b); +vector.sort((a: number, b: number) => b - a); vector.sort(); ``` @@ -620,7 +620,7 @@ vector.add(2); vector.add(4); vector.add(5); vector.add(4); -let result = vector.toSting(); +let result = vector.toString(); ``` ### copyToArray diff --git a/en/application-dev/reference/apis/js-apis-wifi.md b/en/application-dev/reference/apis/js-apis-wifi.md index 503ee06a8f8546cb1386b67b863fe3e6bd16f7aa..875607d4fd022e5a9e91359bde83ee4d1d70a69b 100644 --- a/en/application-dev/reference/apis/js-apis-wifi.md +++ b/en/application-dev/reference/apis/js-apis-wifi.md @@ -1,6 +1,6 @@ # WLAN -> ![icon-note.gif](public_sys-resources/icon-note.gif) **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. @@ -16,13 +16,11 @@ isWifiActive(): boolean Checks whether the WLAN is activated. -- Required permissions: - ohos.permission.GET_WIFI_INFO +**Required permissions**: ohos.permission.GET_WIFI_INFO -- System capability: - SystemCapability.Communication.WiFi.STA +**System capability**: SystemCapability.Communication.WiFi.STA -- Return value +**Return value** | **Type**| **Description**| | -------- | -------- | | boolean | Returns **true** if the WLAN is activated; returns **false** otherwise.| @@ -34,13 +32,11 @@ scan(): boolean Starts a scan for WLAN. -- Required permissions: - ohos.permission.SET_WIFI_INFO and ohos.permission.LOCATION +**Required permissions**: ohos.permission.SET_WIFI_INFO and ohos.permission.LOCATION -- System capability: - SystemCapability.Communication.WiFi.STA +**System capability**: SystemCapability.Communication.WiFi.STA -- Return value +**Return value** | **Type**| **Description**| | -------- | -------- | | boolean | Returns **true** if the scan is successful; returns **false** otherwise.| @@ -52,13 +48,11 @@ getScanInfos(): Promise<Array<WifiScanInfo>> Obtains the scan result. This method uses a promise to return the result. -- Required permissions: - ohos.permission.GET_WIFI_INFO, ohos.permission.GET_WIFI_PEERS_MAC, or ohos.permission.LOCATION +**Required permissions**: ohos.permission.GET_WIFI_INFO, ohos.permission.GET_WIFI_PEERS_MAC, or ohos.permission.LOCATION -- System capability: - SystemCapability.Communication.WiFi.STA +**System capability**: SystemCapability.Communication.WiFi.STA -- Return value +**Return value** | **Type**| **Description**| | -------- | -------- | | Promise< Array<[WifiScanInfo](#wifiscaninfo)> > | Promise used to return the scan result, which is a list of hotspots detected.| @@ -70,18 +64,16 @@ getScanInfos(callback: AsyncCallback<Array<WifiScanInfo>>): void Obtains the scan result. This method uses an asynchronous callback to return the result. -- Required permissions: - ohos.permission.GET_WIFI_INFO, ohos.permission.GET_WIFI_PEERS_MAC, or ohos.permission.LOCATION +**Required permissions**: at least one of ohos.permission.GET_WIFI_INFO, ohos.permission.GET_WIFI_PEERS_MAC, and ohos.permission.LOCATION -- System capability: - SystemCapability.Communication.WiFi.STA +**System capability**: SystemCapability.Communication.WiFi.STA -- Parameters +**Parameters** | **Name**| **Type**| **Mandatory**| **Description**| | -------- | -------- | -------- | -------- | | callback | AsyncCallback< Array<[WifiScanInfo](#wifiscaninfo)>> | Yes| Callback invoked to return the result, which is a list of hotspots detected.| -- Example +**Example** ```js import wifi from '@ohos.wifi'; @@ -160,18 +152,18 @@ addUntrustedConfig(config: WifiDeviceConfig): Promise<boolean> Adds untrusted WLAN configuration. This method uses a promise to return the result. -- Required permissions: +**Required permissions**: ohos.permission.SET_WIFI_INFO -- System capability: +**System capability**: SystemCapability.Communication.WiFi.STA -- Parameters +**Parameters** | **Name**| **Type**| **Mandatory**| **Description**| | -------- | -------- | -------- | -------- | | config | [WifiDeviceConfig](#WifiDeviceConfig) | Yes| WLAN configuration to add.| -- Return value +**Return value** | **Type**| **Description**| | -------- | -------- | | Promise<boolean> | Promise used to return the operation result. The value **true** indicates that the operation is successful; **false** indicates the opposite.| @@ -182,7 +174,7 @@ Represents the WLAN configuration. | **Name**| **Type**| **Readable/Writable**| **Description**| | -------- | -------- | -------- | -------- | -| ssid | string | Read only| Hotspot service set identifier (SSID), in UTF-8 format.| +| ssid | string | Read only| Hotspot SSID, in UTF-8 format.| | bssid | string | Read only| BSSID of the hotspot.| | preSharedKey | string | Read only| Private key of the hotspot.| | isHiddenSsid | boolean | Read only| Whether to hide the network.| @@ -195,13 +187,11 @@ addUntrustedConfig(config: WifiDeviceConfig, callback: AsyncCallback<boolean& Adds untrusted WLAN configuration. This method uses an asynchronous callback to return the result. -- Required permissions: - ohos.permission.SET_WIFI_INFO +**Required permissions**: ohos.permission.SET_WIFI_INFO -- System capability: - SystemCapability.Communication.WiFi.STA +**System capability**: SystemCapability.Communication.WiFi.STA -- Parameters +**Parameters** | **Name**| **Type**| **Mandatory**| **Description**| | -------- | -------- | -------- | -------- | | config | [WifiDeviceConfig](#WifiDeviceConfig) | Yes| WLAN configuration to add.| @@ -214,18 +204,16 @@ removeUntrustedConfig(config: WifiDeviceConfig): Promise<boolean> Removes untrusted WLAN configuration. This method uses a promise to return the result. -- Required permissions: - ohos.permission.SET_WIFI_INFO +**Required permissions**: ohos.permission.SET_WIFI_INFO -- System capability: - SystemCapability.Communication.WiFi.STA +**System capability**: SystemCapability.Communication.WiFi.STA -- Parameters +**Parameters** | **Name**| **Type**| **Mandatory**| **Description**| | -------- | -------- | -------- | -------- | | config | [WifiDeviceConfig](#WifiDeviceConfig) | Yes| WLAN configuration to remove.| -- Return value +**Return value** | **Type**| **Description**| | -------- | -------- | | Promise<boolean> | Promise used to return the operation result. The value **true** indicates that the operation is successful; **false** indicates the opposite.| @@ -237,13 +225,11 @@ removeUntrustedConfig(config: WifiDeviceConfig, callback: AsyncCallback<boole Removes untrusted WLAN configuration. This method uses an asynchronous callback to return the result. -- Required permissions: - ohos.permission.SET_WIFI_INFO +**Required permissions**: ohos.permission.SET_WIFI_INFO -- System capability: - SystemCapability.Communication.WiFi.STA +**System capability**: SystemCapability.Communication.WiFi.STA -- Parameters +**Parameters** | **Name**| **Type**| **Mandatory**| **Description**| | -------- | -------- | -------- | -------- | | config | [WifiDeviceConfig](#WifiDeviceConfig) | Yes| WLAN configuration to remove.| @@ -256,19 +242,17 @@ getSignalLevel(rssi: number, band: number): number Obtains the WLAN signal strength. -- Required permissions: - ohos.permission.GET_WIFI_INFO +**Required permissions**: ohos.permission.GET_WIFI_INFO -- System capability: - SystemCapability.Communication.WiFi.STA +**System capability**: SystemCapability.Communication.WiFi.STA -- **Parameters** +**Parameters** | **Name**| **Type**| **Mandatory**| **Description**| | -------- | -------- | -------- | -------- | | rssi | number | Yes| Signal strength of the hotspot, in dBm.| | band | number | Yes| Frequency band of the WLAN AP.| -- Return value +**Return value** | **Type**| **Description**| | -------- | -------- | | number | Signal strength obtained. The value range is [0, 4].| @@ -280,13 +264,11 @@ getLinkedInfo(): Promise<WifiLinkedInfo> Obtains WLAN connection information. This method uses a promise to return the result. -- Required permissions: - ohos.permission.GET_WIFI_INFO +**Required permissions**: ohos.permission.GET_WIFI_INFO -- System capability: - SystemCapability.Communication.WiFi.STA +**System capability**: SystemCapability.Communication.WiFi.STA -- Return value +**Return value** | Type| Description| | -------- | -------- | | Promise<[WifiLinkedInfo](#WifiLinkedInfo)> | Promise used to return the WLAN connection information obtained.| @@ -298,18 +280,16 @@ getLinkedInfo(callback: AsyncCallback<WifiLinkedInfo>): void Obtains WLAN connection information. This method uses a callback to return the result. -- Required permissions: - ohos.permission.GET_WIFI_INFO +**Required permissions**: ohos.permission.GET_WIFI_INFO -- System capability: - SystemCapability.Communication.WiFi.STA +**System capability**: SystemCapability.Communication.WiFi.STA -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | callback | AsyncCallback<[WifiLinkedInfo](#WifiLinkedInfo)> | Yes| Callback invoked to return the WLAN connection information obtained.| -- Example +**Example** ```js import wifi from '@ohos.wifi'; @@ -342,7 +322,7 @@ Represents the WLAN connection information. | linkSpeed | number | Read only| Speed of the WLAN AP.| | frequency | number | Read only| Frequency of the WLAN AP.| | isHidden | boolean | Read only| Whether the WLAN AP is hidden.| -| isRestricted | boolean | Read only| Whether data volume is restricted at the WLAN AP.| +| isRestricted | boolean | Read only| Whether to restrict data volume at the WLAN AP.| | macAddress | string | Read only| MAC address of the device.| | ipAddress | number | Read only| IP address of the device that sets up the WLAN connection.| | connState | [ConnState](#ConnState) | Read only| WLAN connection state.| @@ -370,13 +350,11 @@ isConnected(): boolean Checks whether the WLAN is connected. -- Required permissions: - ohos.permission.GET_WIFI_INFO +**Required permissions**: ohos.permission.GET_WIFI_INFO -- System capability: - SystemCapability.Communication.WiFi.STA +**System capability**: SystemCapability.Communication.WiFi.STA -- Return value +**Return value** | **Type**| **Description**| | -------- | -------- | | boolean | Returns **true** if the WLAN is connected; returns **false** otherwise.| @@ -388,35 +366,35 @@ isFeatureSupported(featureId: number): boolean Checks whether the device supports the specified WLAN feature. -- Required permissions: - ohos.permission.GET_WIFI_INFO +**Required permissions**: ohos.permission.GET_WIFI_INFO -- System capability: - SystemCapability.Communication.WiFi.Core +**System capability**: SystemCapability.Communication.WiFi.Core + +**Parameters** -- **Parameters** | **Name**| **Type**| Mandatory| **Description**| | -------- | -------- | -------- | -------- | | featureId | number | Yes| Feature ID.| -- Return value +**Return value** | **Type**| **Description**| | -------- | -------- | | boolean | Returns **true** if the feature is supported; returns **false** otherwise.| -- Enumerates the WLAN features. - | Value| Description| - | -------- | -------- | - | 0x0001 | WLAN infrastructure mode| - | 0x0002 | 5 GHz bandwidth| - | 0x0004 | Generic Advertisement Service (GAS)/Access Network Query Protocol (ANQP) feature| - | 0x0008 | Wi-Fi Direct| - | 0x0010 | SoftAP| - | 0x0040 | Wi-Fi AWare| - | 0x8000 | WLAN AP/STA concurrency| - | 0x8000000 | WPA3 Personal (WPA-3 SAE)| - | 0x10000000 | WPA3-Enterprise Suite-B | - | 0x20000000 | Enhanced open feature| +**Feature IDs** + +| Value| Description| +| -------- | -------- | +| 0x0001 | WLAN infrastructure mode| +| 0x0002 | 5 GHz bandwidth| +| 0x0004 | Generic Advertisement Service (GAS)/Access Network Query Protocol (ANQP) feature| +| 0x0008 | Wi-Fi Direct| +| 0x0010 | SoftAP| +| 0x0040 | Wi-Fi AWare| +| 0x8000 | WLAN AP/STA concurrency| +| 0x8000000 | WPA3 Personal (WPA-3 SAE)| +| 0x10000000 | WPA3-Enterprise Suite-B | +| 0x20000000 | Enhanced open feature| ## wifi.getIpInfo7+ @@ -425,13 +403,11 @@ getIpInfo(): IpInfo Obtains IP information. -- Required permissions: - ohos.permission.GET_WIFI_INFO +**Required permissions**: ohos.permission.GET_WIFI_INFO -- System capability: - SystemCapability.Communication.WiFi.STA +**System capability**: SystemCapability.Communication.WiFi.STA -- Return value +**Return value** | **Type**| **Description**| | -------- | -------- | | [IpInfo](#IpInfo) | IP information obtained.| @@ -458,13 +434,11 @@ getCountryCode(): string Obtains the country code. -- Required permissions: - ohos.permission.GET_WIFI_INFO +**Required permissions**: ohos.permission.GET_WIFI_INFO -- System capability: - SystemCapability.Communication.WiFi.Core +**System capability**: SystemCapability.Communication.WiFi.Core -- Return value +**Return value** | **Type**| **Description**| | -------- | -------- | | string | Country code obtained.| @@ -476,13 +450,11 @@ getP2pLinkedInfo(): Promise<WifiP2pLinkedInfo> Obtains peer-to-peer (P2P) connection information. This method uses a promise to return the result. -- Required permissions: - ohos.permission.GET_WIFI_INFO +**Required permissions**: ohos.permission.GET_WIFI_INFO -- System capability: - SystemCapability.Communication.WiFi.P2P +**System capability**: SystemCapability.Communication.WiFi.P2P -- Return value +**Return value** | Type| Description| | -------- | -------- | | Promise<[WifiP2pLinkedInfo](#WifiP2pLinkedInfo)> | Promise used to return the P2P connection information obtained.| @@ -494,13 +466,11 @@ getP2pLinkedInfo(callback: AsyncCallback<WifiP2pLinkedInfo>): void Obtains P2P connection information. This method uses a callback to return the result. -- Required permissions: - ohos.permission.GET_WIFI_INFO +**Required permissions**: ohos.permission.GET_WIFI_INFO -- System capability: - SystemCapability.Communication.WiFi.P2P +**System capability**: SystemCapability.Communication.WiFi.P2P -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | callback | AsyncCallback<[WifiP2pLinkedInfo](#WifiP2pLinkedInfo)> | Yes| Callback used to return the P2P connection information obtained.| @@ -533,13 +503,11 @@ getCurrentGroup(): Promise<WifiP2pGroupInfo> Obtains the current P2P group information. This method uses a promise to return the result. -- Required permissions: - ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION +**Required permissions**: ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION -- System capability: - SystemCapability.Communication.WiFi.P2P +**System capability**: SystemCapability.Communication.WiFi.P2P -- Return value +**Return value** | Type| Description| | -------- | -------- | | Promise<[WifiP2pGroupInfo](#WifiP2pGroupInfo)> | Promise used to return the P2P group information obtained.| @@ -551,13 +519,11 @@ getCurrentGroup(callback: AsyncCallback<WifiP2pGroupInfo>): void Obtains the P2P group information. This method uses an asynchronous callback to return the result. -- Required permissions: - ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION +**Required permissions**: ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION -- System capability: - SystemCapability.Communication.WiFi.P2P +**System capability**: SystemCapability.Communication.WiFi.P2P -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | callback | AsyncCallback<[WifiP2pGroupInfo](#WifiP2pGroupInfo)> | Yes| Callback used to return the P2P group information obtained.| @@ -610,13 +576,11 @@ getP2pPeerDevices(): Promise<WifiP2pDevice[]> Obtains the list of peer devices in a P2P connection. This method uses a promise to return the result. -- Required permissions: - ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION +**Required permissions**: ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION -- System capability: - SystemCapability.Communication.WiFi.P2P +**System capability**: SystemCapability.Communication.WiFi.P2P -- Return value +**Return value** | Type| Description| | -------- | -------- | | Promise<[WifiP2pDevice[]](#WifiP2pDevice)> | Promise used to return the peer device list obtained.| @@ -628,13 +592,11 @@ getP2pPeerDevices(callback: AsyncCallback<WifiP2pDevice[]>): void Obtains the list of peer devices in a P2P connection. This method uses an asynchronous callback to return the result. -- Required permissions: - ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION +**Required permissions**: ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION -- System capability: - SystemCapability.Communication.WiFi.P2P +**System capability**: SystemCapability.Communication.WiFi.P2P -- Parameters +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | callback | AsyncCallback<[WifiP2pDevice[]](#WifiP2pDevice)> | Yes| Callback used to return the peer device list obtained.| @@ -646,18 +608,17 @@ createGroup(config: WifiP2PConfig): boolean; Creates a P2P group. -- Required permissions: - ohos.permission.GET_WIFI_INFO +**Required permissions**: ohos.permission.GET_WIFI_INFO + +**System capability**: SystemCapability.Communication.WiFi.P2P -- System capability: - SystemCapability.Communication.WiFi.P2P +**Parameters** -- **Parameters** | **Name**| **Type**| Mandatory| **Description**| | -------- | -------- | -------- | -------- | | config | [WifiP2PConfig](#WifiP2PConfig) | Yes| Group configuration.| -- Return value +**Return value** | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -691,13 +652,11 @@ removeGroup(): boolean; Removes a P2P group. -- Required permissions: - ohos.permission.GET_WIFI_INFO +**Required permissions**: ohos.permission.GET_WIFI_INFO -- System capability: - SystemCapability.Communication.WiFi.P2P +**System capability**: SystemCapability.Communication.WiFi.P2P -- Return value +**Return value** | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -709,24 +668,23 @@ p2pConnect(config: WifiP2PConfig): boolean; Sets up a P2P connection. -- Required permissions: - ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION +**Required permissions**: ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION -- System capability: - SystemCapability.Communication.WiFi.P2P +**System capability**: SystemCapability.Communication.WiFi.P2P + +**Parameters** -- **Parameters** | **Name**| **Type**| Mandatory| **Description**| | -------- | -------- | -------- | -------- | | config | [WifiP2PConfig](#WifiP2PConfig) | Yes| Connection configuration.| -- Return value +**Return value** | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| -- Example +**Example** ```js import wifi from '@ohos.wifi'; @@ -799,13 +757,11 @@ p2pCancelConnect(): boolean; Cancels this P2P connection. -- Required permissions: - ohos.permission.GET_WIFI_INFO +**Required permissions**: ohos.permission.GET_WIFI_INFO -- System capability: - SystemCapability.Communication.WiFi.P2P +**System capability**: SystemCapability.Communication.WiFi.P2P -- Return value +**Return value** | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -817,13 +773,11 @@ startDiscoverDevices(): boolean; Starts to discover devices. -- Required permissions: - ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION +**Required permissions**: ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION -- System capability: - SystemCapability.Communication.WiFi.P2P +**System capability**: SystemCapability.Communication.WiFi.P2P -- Return value +**Return value** | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -835,13 +789,11 @@ stopDiscoverDevices(): boolean; Stops discovering devices. -- Required permissions: - ohos.permission.GET_WIFI_INFO +**Required permissions**: ohos.permission.GET_WIFI_INFO -- System capability: - SystemCapability.Communication.WiFi.P2P +**System capability**: SystemCapability.Communication.WiFi.P2P -- Return value +**Return value** | Type| Description| | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| @@ -853,25 +805,24 @@ on(type: "wifiStateChange", callback: Callback<number>): void Registers the WLAN state change events. -- Required permissions: - ohos.permission.GET_WIFI_INFO +**Required permissions**: ohos.permission.GET_WIFI_INFO -- System capability: - SystemCapability.Communication.WiFi.STA +**System capability**: SystemCapability.Communication.WiFi.STA -- Parameters +**Parameters** | **Name**| **Type**| **Mandatory**| **Description**| | -------- | -------- | -------- | -------- | | type | string | Yes| Event type. The value is **wifiStateChange**.| | callback | Callback<number> | Yes| Callback invoked to return the WLAN state.| -- Enumerates the WLAN states. - | **Value**| **Description**| - | -------- | -------- | - | 0 | Deactivated| - | 1 | Activated| - | 2 | Activating| - | 3 | Deactivating| +**WLAN states** + +| **Value**| **Description**| +| -------- | -------- | +| 0 | Deactivated| +| 1 | Activated| +| 2 | Activating| +| 3 | Deactivating| ## wifi.off('wifiStateChange')7+ @@ -880,19 +831,17 @@ off(type: "wifiStateChange", callback?: Callback<number>): void Unregisters the WLAN state change events. -- Required permissions: - ohos.permission.GET_WIFI_INFO +**Required permissions**: ohos.permission.GET_WIFI_INFO -- System capability: - SystemCapability.Communication.WiFi.STA +**System capability**: SystemCapability.Communication.WiFi.STA -- Parameters +**Parameters** | **Name**| **Type**| **Mandatory**| **Description**| | -------- | -------- | -------- | -------- | | type | string | Yes| Event type. The value is **wifiStateChange**.| | callback | Callback<number> | No| Callback used to return the WLAN state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| -- Example +**Example** ```js import wifi from '@ohos.wifi'; @@ -915,23 +864,22 @@ on(type: "wifiConnectionChange", callback: Callback<number>): void Registers the WLAN connection state change events. -- Required permissions: - ohos.permission.GET_WIFI_INFO +**Required permissions**: ohos.permission.GET_WIFI_INFO -- System capability: - SystemCapability.Communication.WiFi.STA +**System capability**: SystemCapability.Communication.WiFi.STA -- Parameters +**Parameters** | **Name**| **Type**| **Mandatory**| **Description**| | -------- | -------- | -------- | -------- | | type | string | Yes| Event type. The value is **wifiConnectionChange**.| | callback | Callback<number> | Yes| Callback invoked to return the WLAN connection state.| -- Enumerates the WLAN connection states. - | **Value**| **Description**| - | -------- | -------- | - | 0 | Disconnected| - | 1 | Connected| +**WLAN connection states** + +| **Value**| **Description**| +| -------- | -------- | +| 0 | Disconnected| +| 1 | Connected| ## wifi.off('wifiConnectionChange')7+ @@ -940,17 +888,15 @@ off(type: "wifiConnectionChange", callback?: Callback<number>): void Unregisters the WLAN connection state change events. -- Required permissions: - ohos.permission.GET_WIFI_INFO +**Required permissions**: ohos.permission.GET_WIFI_INFO -- System capability: - SystemCapability.Communication.WiFi.STA +**System capability**: SystemCapability.Communication.WiFi.STA -- Parameters +**Parameters** | **Name**| **Type**| **Mandatory**| **Description**| | -------- | -------- | -------- | -------- | | type | string | Yes| Event type. The value is **wifiConnectionChange**.| - | callback | Callback<number> | No| Callback used to report the WLAN connection state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| + | callback | Callback<number> | No| Callback used to return the WLAN connection state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| ## wifi.on('wifiScanStateChange')7+ @@ -959,23 +905,22 @@ on(type: "wifiScanStateChange", callback: Callback<number>): void Registers the WLAN scan state change events. -- Required permissions: - ohos.permission.GET_WIFI_INFO +**Required permissions**: ohos.permission.GET_WIFI_INFO -- System capability: - SystemCapability.Communication.WiFi.STA +**System capability**: SystemCapability.Communication.WiFi.STA -- Parameters +**Parameters** | **Name**| **Type**| **Mandatory**| **Description**| | -------- | -------- | -------- | -------- | | type | string | Yes| Event type. The value is **wifiScanStateChange**.| | callback | Callback<number> | Yes| Callback invoked to return the WLAN scan state.| -- Enumerates the WLAN scan states. - | **Value**| **Description**| - | -------- | -------- | - | 0 | Scan failed| - | 1 | Scan successful| +**WLAN scan states** + +| **Value**| **Description**| +| -------- | -------- | +| 0 | Scan failed| +| 1 | Scan successful| ## wifi.off('wifiScanStateChange')7+ @@ -984,13 +929,11 @@ off(type: "wifiScanStateChange", callback?: Callback<number>): void Unregisters the WLAN scan state change events. -- Required permissions: - ohos.permission.GET_WIFI_INFO +**Required permissions**: ohos.permission.GET_WIFI_INFO -- System capability: - SystemCapability.Communication.WiFi.STA +**System capability**: SystemCapability.Communication.WiFi.STA -- Parameters +**Parameters** | **Name**| **Type**| **Mandatory**| **Description**| | -------- | -------- | -------- | -------- | @@ -1002,15 +945,13 @@ Unregisters the WLAN scan state change events. on(type: "wifiRssiChange", callback: Callback<number>): void -Registers the RSSI state change events. +Registers the RSSI change events. -- Required permissions: - ohos.permission.GET_WIFI_INFO +**Required permissions**: ohos.permission.GET_WIFI_INFO -- System capability: - SystemCapability.Communication.WiFi.STA +**System capability**: SystemCapability.Communication.WiFi.STA -- Parameters +**Parameters** | **Name**| **Type**| **Mandatory**| **Description**| | -------- | -------- | -------- | -------- | | type | string | Yes| Event type. The value is **wifiRssiChange**.| @@ -1021,15 +962,13 @@ Registers the RSSI state change events. off(type: "wifiRssiChange", callback?: Callback<number>): void -Unregisters the RSSI state change events. +Unregisters the RSSI change events. -- Required permissions: - ohos.permission.GET_WIFI_INFO +**Required permissions**: ohos.permission.GET_WIFI_INFO -- System capability: - SystemCapability.Communication.WiFi.STA +**System capability**: SystemCapability.Communication.WiFi.STA -- Parameters +**Parameters** | **Name**| **Type**| **Mandatory**| **Description**| | -------- | -------- | -------- | -------- | | type | string | Yes| Event type. The value is **wifiRssiChange**.| @@ -1042,25 +981,24 @@ on(type: "hotspotStateChange", callback: Callback<number>): void Registers the hotspot state change events. -- Required permissions: - ohos.permission.GET_WIFI_INFO +**Required permissions**: ohos.permission.GET_WIFI_INFO -- System capability: - SystemCapability.Communication.WiFi.AP.Core +**System capability**: SystemCapability.Communication.WiFi.AP.Core -- Parameters +**Parameters** | **Name**| **Type**| **Mandatory**| **Description**| | -------- | -------- | -------- | -------- | | type | string | Yes| Event type. The value is **hotspotStateChange**.| | callback | Callback<number> | Yes| Callback invoked to return the hotspot state.| -- Enumerates the hotspot states. - | **Value**| **Description**| - | -------- | -------- | - | 0 | Deactivated| - | 1 | Activated| - | 2 | Activating| - | 3 | Deactivating| +**Hotspot states** + +| **Value**| **Description**| +| -------- | -------- | +| 0 | Deactivated| +| 1 | Activated| +| 2 | Activating| +| 3 | Deactivating| ## wifi.off('hotspotStateChange')7+ @@ -1069,13 +1007,11 @@ off(type: "hotspotStateChange", callback?: Callback<number>): void Unregisters the hotspot state change events. -- Required permissions: - ohos.permission.GET_WIFI_INFO +**Required permissions**: ohos.permission.GET_WIFI_INFO -- System capability: - SystemCapability.Communication.WiFi.AP.Core +**System capability**: SystemCapability.Communication.WiFi.AP.Core -- Parameters +**Parameters** | **Name**| **Type**| **Mandatory**| **Description**| | -------- | -------- | -------- | -------- | | type | string | Yes| Event type. The value is **hotspotStateChange**.| @@ -1086,28 +1022,27 @@ Unregisters the hotspot state change events. on(type: "p2pStateChange", callback: Callback<number>): void -Registers the P2P status change events. +Registers the P2P state change events. -- Required permissions: - ohos.permission.GET_WIFI_INFO +**Required permissions**: ohos.permission.GET_WIFI_INFO -- System capability: - SystemCapability.Communication.WiFi.P2P +**System capability**: SystemCapability.Communication.WiFi.P2P -- Parameters +**Parameters** | **Name**| **Type**| **Mandatory**| **Description**| | -------- | -------- | -------- | -------- | | type | string | Yes| Event type. The value is **p2pStateChange**.| | callback | Callback<number> | Yes| Callback invoked to return the P2P state.| -- Enumerates the P2P states. - | **Value**| **Description**| - | -------- | -------- | - | 1 | Available| - | 2 | Opening| - | 3 | Opened| - | 4 | Closing| - | 5 | Closed| +**P2P states** + +| **Value**| **Description**| +| -------- | -------- | +| 1 | Available| +| 2 | Opening| +| 3 | Opened| +| 4 | Closing| +| 5 | Closed| ## wifi.off('p2pStateChange')8+ @@ -1115,13 +1050,11 @@ off(type: "p2pStateChange", callback?: Callback<number>): void Unregisters the P2P state change events. -- Required permissions: - ohos.permission.GET_WIFI_INFO +**Required permissions**: ohos.permission.GET_WIFI_INFO -- System capability: - SystemCapability.Communication.WiFi.P2P +**System capability**: SystemCapability.Communication.WiFi.P2P -- Parameters +**Parameters** | **Name**| **Type**| **Mandatory**| **Description**| | -------- | -------- | -------- | -------- | | type | string | Yes| Event type. The value is **p2pStateChange**.| @@ -1134,13 +1067,11 @@ on(type: "p2pConnectionChange", callback: Callback<WifiP2pLinkedInfo>): vo Registers the P2P connection state change events. -- Required permissions: - ohos.permission.GET_WIFI_INFO +**Required permissions**: ohos.permission.GET_WIFI_INFO -- System capability: - SystemCapability.Communication.WiFi.P2P +**System capability**: SystemCapability.Communication.WiFi.P2P -- Parameters +**Parameters** | **Name**| **Type**| **Mandatory**| **Description**| | -------- | -------- | -------- | -------- | | type | string | Yes| Event type. The value is **p2pConnectionChange**.| @@ -1153,13 +1084,11 @@ off(type: "p2pConnectionChange", callback?: Callback<WifiP2pLinkedInfo>): Unregisters the P2P connection state change events. -- Required permissions: - ohos.permission.GET_WIFI_INFO +**Required permissions**: ohos.permission.GET_WIFI_INFO -- System capability: - SystemCapability.Communication.WiFi.P2P +**System capability**: SystemCapability.Communication.WiFi.P2P -- Parameters +**Parameters** | **Name**| **Type**| **Mandatory**| **Description**| | -------- | -------- | -------- | -------- | | type | string | Yes| Event type. The value is **p2pConnectionChange**.| @@ -1172,13 +1101,11 @@ on(type: "p2pDeviceChange", callback: Callback<WifiP2pDevice>): void Registers the P2P device state change events. -- Required permissions: - ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION +**Required permissions**: ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION -- System capability: - SystemCapability.Communication.WiFi.P2P +**System capability**: SystemCapability.Communication.WiFi.P2P -- Parameters +**Parameters** | **Name**| **Type**| **Mandatory**| **Description**| | -------- | -------- | -------- | -------- | | type | string | Yes| Event type. The value is **p2pDeviceChange**.| @@ -1191,13 +1118,11 @@ off(type: "p2pDeviceChange", callback?: Callback<WifiP2pDevice>): void Unregisters the P2P device state change events. -- Required permissions: - ohos.permission.LOCATION +**Required permissions**: ohos.permission.LOCATION -- System capability: - SystemCapability.Communication.WiFi.P2P +**System capability**: SystemCapability.Communication.WiFi.P2P -- Parameters +**Parameters** | **Name**| **Type**| **Mandatory**| **Description**| | -------- | -------- | -------- | -------- | | type | string | Yes| Event type. The value is **p2pDeviceChange**.| @@ -1210,13 +1135,11 @@ on(type: "p2pPeerDeviceChange", callback: Callback<WifiP2pDevice[]>): void Registers the P2P peer device state change events. -- Required permissions: - ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION +**Required permissions**: ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION -- System capability: - SystemCapability.Communication.WiFi.P2P +**System capability**: SystemCapability.Communication.WiFi.P2P -- Parameters +**Parameters** | **Name**| **Type**| **Mandatory**| **Description**| | -------- | -------- | -------- | -------- | | type | string | Yes| Event type. The value is **p2pPeerDeviceChange**.| @@ -1229,13 +1152,11 @@ off(type: "p2pPeerDeviceChange", callback?: Callback<WifiP2pDevice[]>): vo Unregisters the P2P peer device state change events. -- Required permissions: - ohos.permission.LOCATION +**Required permissions**: ohos.permission.LOCATION -- System capability: - SystemCapability.Communication.WiFi.P2P +**System capability**: SystemCapability.Communication.WiFi.P2P -- Parameters +**Parameters** | **Name**| **Type**| **Mandatory**| **Description**| | -------- | -------- | -------- | -------- | | type | string | Yes| Event type. The value is **p2pPeerDeviceChange**.| @@ -1248,13 +1169,11 @@ on(type: "p2pPersistentGroupChange", callback: Callback<void>): void Registers the P2P persistent group state change events. -- Required permissions: - ohos.permission.GET_WIFI_INFO +**Required permissions**: ohos.permission.GET_WIFI_INFO -- System capability: - SystemCapability.Communication.WiFi.P2P +**System capability**: SystemCapability.Communication.WiFi.P2P -- Parameters +**Parameters** | **Name**| **Type**| **Mandatory**| **Description**| | -------- | -------- | -------- | -------- | | type | string | Yes| Event type. The value is **p2pPersistentGroupChange**.| @@ -1267,13 +1186,11 @@ off(type: "p2pPersistentGroupChange", callback?: Callback<void>): void Unregisters the P2P persistent group state change events. -- Required permissions: - ohos.permission.GET_WIFI_INFO +**Required permissions**: ohos.permission.GET_WIFI_INFO -- System capability: - SystemCapability.Communication.WiFi.P2P +**System capability**: SystemCapability.Communication.WiFi.P2P -- Parameters +**Parameters** | **Name**| **Type**| **Mandatory**| **Description**| | -------- | -------- | -------- | -------- | | type | string | Yes| Event type. The value is **p2pPersistentGroupChange**.| @@ -1286,23 +1203,22 @@ on(type: "p2pDiscoveryChange", callback: Callback<number>): void Registers the P2P discovered device state change events. -- Required permissions: - ohos.permission.GET_WIFI_INFO +**Required permissions**: ohos.permission.GET_WIFI_INFO -- System capability: - SystemCapability.Communication.WiFi.P2P +**System capability**: SystemCapability.Communication.WiFi.P2P -- Parameters +**Parameters** | **Name**| **Type**| **Mandatory**| **Description**| | -------- | -------- | -------- | -------- | | type | string | Yes| Event type. The value is **p2pDiscoveryChange**.| | callback | Callback<number> | Yes| Callback invoked to return the state of the P2P discovered device.| -- Enumerates the states of P2P discovered devices. - | **Value**| **Description**| - | -------- | -------- | - | 0 | Initial state| - | 1 | Discovered| +**P2P discovered device states** + +| **Value**| **Description**| +| -------- | -------- | +| 0 | Initial state| +| 1 | Discovered| ## wifi.off('p2pDiscoveryChange')8+ @@ -1311,13 +1227,11 @@ off(type: "p2pDiscoveryChange", callback?: Callback<number>): void Unregisters the P2P discovered device state change events. -- Required permissions: - ohos.permission.GET_WIFI_INFO +**Required permissions**: ohos.permission.GET_WIFI_INFO -- System capability: - SystemCapability.Communication.WiFi.P2P +**System capability**: SystemCapability.Communication.WiFi.P2P -- Parameters +**Parameters** | **Name**| **Type**| **Mandatory**| **Description**| | -------- | -------- | -------- | -------- | | type | string | Yes| Event type. The value is **p2pDiscoveryChange**.| diff --git a/en/application-dev/reference/arkui-js/js-components-common-events.md b/en/application-dev/reference/arkui-js/js-components-common-events.md index 28bceb4b82d812406de1fef949c8d6478b47c6e4..572360f56518f2a6da4df7366528a5c7a0d01c45 100644 --- a/en/application-dev/reference/arkui-js/js-components-common-events.md +++ b/en/application-dev/reference/arkui-js/js-components-common-events.md @@ -223,14 +223,14 @@ Sets a custom drag image. | Name | Type | Mandatory | Name | | -------- | -------- | ---- | ---------------------------------------- | -| pixelmap | PixelMap | Yes | Image transferred from the frontend. For details, see [PixelMap](../apis/js-apis-image.md#pixelmap7).| +| pixelmap | [PixelMap](../apis/js-apis-image.md#pixelmap7) | Yes | Image transferred from the frontend. | | offsetX | number | Yes | Horizontal offset relative to the image. | | offsetY | number | Yes | Vertical offset relative to the image. | **Return value** | Type | Description | | ---- | ------------------------ | -| bool | Operation result. The value **true** means that the operation is successful, and **false** means otherwise.| +| boolean | Operation result. The value **true** means that the operation is successful, and **false** means otherwise.| **Example** diff --git a/en/application-dev/reference/arkui-js/js-components-media-video.md b/en/application-dev/reference/arkui-js/js-components-media-video.md index b957ee6d968a2a4b038c4d600d7ea6adef966b40..18c3fbef3bff790dfea6359d7a5d7c5516d0ecd5 100644 --- a/en/application-dev/reference/arkui-js/js-components-media-video.md +++ b/en/application-dev/reference/arkui-js/js-components-media-video.md @@ -1,7 +1,7 @@ # video -> **NOTE**
+> **NOTE** > > - This component is supported since API version 4. Updates will be marked with a superscript to indicate their earliest API version. > @@ -15,7 +15,7 @@ > ] > ``` -The **\