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..09fd374061b2288f851360259bacbec7b54ffaf7 100644 --- a/en/application-dev/ability/ability-assistant-guidelines.md +++ b/en/application-dev/ability/ability-assistant-guidelines.md @@ -74,9 +74,9 @@ The ability assistant enables you to start applications, atomic services, and te | -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. | + | -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/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/stage-formextension.md b/en/application-dev/ability/stage-formextension.md index e1d3604c566b217a7b4f9f2c880faf5d4c71cf47..3e19e5c756b9db4fc7d657fc4c1d9445d5835329 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: @@ -252,7 +252,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..21640122c2a0ffbf63c072e5880707b31e895fd5 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 overwrite 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 6c16c1700c9c12737fd3be84504a8342215047f6..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.| 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..ab30a5bdbd54630e9f94e7f31bc00de5ca9cc984 100644 --- a/en/application-dev/internationalization/i18n-guidelines.md +++ b/en/application-dev/internationalization/i18n-guidelines.md @@ -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"; diff --git a/en/application-dev/internationalization/intl-guidelines.md b/en/application-dev/internationalization/intl-guidelines.md index a27df95ea9c9657c30401b1fd1ad9d9b21d77fca..1332d196cec8c565a13bb77c3fdbcf263b35cf2c 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"; 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-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-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-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..de6f685f0559aab651ccd14d14386d3e77e2663a 100644 --- a/en/application-dev/reference/apis/js-apis-data-rdb.md +++ b/en/application-dev/reference/apis/js-apis-data-rdb.md @@ -1204,7 +1204,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 +1215,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) { @@ -1239,7 +1239,7 @@ rdbStore.update("EMPLOYEE", valueBucket, predicates, function (err, ret) { ``` ### update9+ -update(table: string, values: ValuesBucket, predicates: DataSharePredicates):Promise<number> +update(table: string, values: ValuesBucket, predicates: dataSharePredicates.DataSharePredicates):Promise<number> Updates data in the database based on the specified **DataSharePredicates** object. This API uses a promise to return the result. @@ -1250,7 +1250,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 +1259,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) => { @@ -1337,7 +1337,7 @@ promise.then((rows) => { ### delete9+ -delete(table: string, predicates: DataSharePredicates, callback: AsyncCallback<number>):void +delete(table: string, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback<number>):void Deletes data from the database based on the specified **DataSharePredicates** object. This API uses an asynchronous callback to return the result. @@ -1348,13 +1348,13 @@ 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) { @@ -1376,7 +1376,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,8 +1385,8 @@ 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) => { @@ -1460,7 +1460,7 @@ Queries data in the database based on specified conditions. This API uses a prom ### query9+ -query(predicates: DataSharePredicates, columns: Array<string>, callback: AsyncCallback<ResultSet>):void +query(predicates: dataSharePredicates.DataSharePredicates, columns: Array<string>, callback: AsyncCallback<ResultSet>):void Queries data in the database based on specified conditions. This API uses an asynchronous callback to return the result. @@ -1469,14 +1469,14 @@ 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) { @@ -1490,7 +1490,7 @@ rdbStore.query("EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"], ### query9+ -query(predicates: DataSharePredicates, columns?: Array<string>):Promise<ResultSet> +query(predicates: dataSharePredicates.DataSharePredicates, columns?: Array<string>):Promise<ResultSet> Queries data in the database based on specified conditions. This API uses a promise to return the result. @@ -1499,7 +1499,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,8 +1509,8 @@ 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) => { 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-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-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-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-ts/ts-offscreencanvasrenderingcontext2d.md b/en/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md index 074b3853761d1569bcf5ffc29e046afef1dfef9a..6e120cd42deb2de2e7388b56aaa0b5eef5ec799a 100644 --- a/en/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md +++ b/en/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md @@ -1,8 +1,7 @@ # OffscreenCanvasRenderingContext2D -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** -> The APIs of this module are supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. +> **NOTE**
The APIs of this module are supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. Use **OffscreenCanvasRenderingContext2D** to draw rectangles, images, and text offscreen onto a canvas. Drawing offscreen onto a canvas is a process where content to draw onto the canvas is first drawn in the buffer, and then converted into a picture, and finally the picture is drawn on the canvas. This process increases the drawing efficiency. @@ -43,14 +42,15 @@ OffscreenCanvasRenderingContext2D(width: number, height: number, setting: Render | [imageSmoothingEnabled](#imagesmoothingenabled) | boolean | true | Whether to adjust the image smoothness during image drawing. The value **true** means to enable this feature, and **false** means the opposite. | | imageSmoothingQuality | string | 'low' | Image smoothness. The value can be **'low'**, **'medium'**, or **'high'**. | -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> **NOTE** > The value of the **<color>** type can be in 'rgb(255, 255, 255)', 'rgba(255, 255, 255, 1.0)', or '\#FFFFFF' format. ### fillStyle -``` +```ts +// xxx.ets @Entry @Component struct FillStyleExample { @@ -83,7 +83,8 @@ struct FillStyleExample { ### lineWidth -``` +```ts +// xxx.ets @Entry @Component struct LineWidthExample { @@ -116,7 +117,8 @@ struct LineWidthExample { ### strokeStyle -``` +```ts +// xxx.ets @Entry @Component struct StrokeStyleExample { @@ -151,7 +153,8 @@ struct StrokeStyleExample { ### lineCap -``` +```ts +// xxx.ets @Entry @Component struct LineCapExample { @@ -188,7 +191,8 @@ struct LineCapExample { ### lineJoin -``` +```ts +// xxx.ets @Entry @Component struct LineJoinExample { @@ -226,7 +230,8 @@ struct LineJoinExample { ### miterLimit -``` +```ts +// xxx.ets @Entry @Component struct MiterLimit { @@ -264,7 +269,8 @@ struct MiterLimit { ### font -``` +```ts +// xxx.ets @Entry @Component struct Font { @@ -297,7 +303,8 @@ struct Font { ### textAlign -``` +```ts +// xxx.ets @Entry @Component struct CanvasExample { @@ -345,7 +352,8 @@ struct CanvasExample { ### textBaseline -``` +```ts +// xxx.ets @Entry @Component struct TextBaseline { @@ -393,7 +401,8 @@ struct TextBaseline { ### globalAlpha -``` +```ts +// xxx.ets @Entry @Component struct GlobalAlpha { @@ -429,7 +438,8 @@ struct GlobalAlpha { ### lineDashOffset -``` +```ts +// xxx.ets @Entry @Component struct LineDashOffset { @@ -477,7 +487,8 @@ struct LineDashOffset { | xor | Combines the new drawing and existing drawing using the XOR operation. | -``` +```ts +// xxx.ets @Entry @Component struct GlobalCompositeOperation { @@ -518,7 +529,8 @@ struct GlobalCompositeOperation { ### shadowBlur -``` +```ts +// xxx.ets @Entry @Component struct ShadowBlur { @@ -553,7 +565,8 @@ struct ShadowBlur { ### shadowColor -``` +```ts +// xxx.ets @Entry @Component struct ShadowColor { @@ -589,7 +602,8 @@ struct ShadowColor { ### shadowOffsetX -``` +```ts +// xxx.ets @Entry @Component struct ShadowOffsetX { @@ -625,7 +639,8 @@ struct ShadowOffsetX { ### shadowOffsetY -``` +```ts +// xxx.ets @Entry @Component struct ShadowOffsetY { @@ -661,7 +676,8 @@ struct ShadowOffsetY { ### imageSmoothingEnabled -``` +```ts +// xxx.ets @Entry @Component struct ImageSmoothingEnabled { @@ -711,7 +727,8 @@ Fills a rectangle on the canvas. - Example - ``` + ```ts +// xxx.ets @Entry @Component struct FillRect { @@ -800,7 +817,8 @@ Clears the content in a rectangle on the canvas. - Example - ``` + ```ts +// xxx.ets @Entry @Component struct ClearRect { @@ -845,7 +863,8 @@ Draws filled text on the canvas. - Example - ``` + ```ts +// xxx.ets @Entry @Component struct FillText { @@ -941,7 +960,8 @@ Returns a **TextMetrics** object used to obtain the width of specified text. - Example - ``` + ```ts +// xxx.ets @Entry @Component struct MeasureText { @@ -1023,7 +1043,8 @@ Creates a drawing path. - Example - ``` + ```ts +// xxx.ets @Entry @Component struct BeginPath { @@ -1070,7 +1091,8 @@ Moves a drawing path to a target position on the canvas. - Example - ``` + ```ts +// xxx.ets @Entry @Component struct MoveTo { @@ -1115,7 +1137,8 @@ Connects the current point to a target position using a straight line. - Example - ``` + ```ts +// xxx.ets @Entry @Component struct LineTo { @@ -1154,7 +1177,8 @@ Draws a closed path. - Example - ``` + ```ts +// xxx.ets @Entry @Component struct ClosePath { @@ -1201,7 +1225,8 @@ Creates a pattern for image filling based on a specified source image and repeti - Example - ``` + ```ts +// xxx.ets @Entry @Component struct CreatePattern { @@ -1250,7 +1275,8 @@ Draws a cubic bezier curve on the canvas. - Example - ``` + ```ts +// xxx.ets @Entry @Component struct BezierCurveTo { @@ -1297,7 +1323,8 @@ Draws a quadratic curve on the canvas. - Example - ``` + ```ts +// xxx.ets @Entry @Component struct QuadraticCurveTo { @@ -1346,7 +1373,8 @@ Draws an arc on the canvas. - Example - ``` + ```ts +// xxx.ets @Entry @Component struct Arc { @@ -1393,7 +1421,8 @@ Draws an arc based on the radius and points on the arc. - Example - ``` + ```ts +// xxx.ets @Entry @Component struct ArcTo { @@ -1444,7 +1473,8 @@ Draws an ellipse in the specified rectangular region. - Example - ``` + ```ts +// xxx.ets @Entry @Component struct CanvasExample { @@ -1490,7 +1520,8 @@ Creates a rectangle. - Example - ``` + ```ts +// xxx.ets @Entry @Component struct CanvasExample { @@ -1527,7 +1558,8 @@ Fills the area inside a closed path. - Example - ``` + ```ts +// xxx.ets @Entry @Component struct Fill { @@ -1564,7 +1596,8 @@ Sets the current path to a clipping path. - Example - ``` + ```ts +// xxx.ets @Entry @Component struct Clip { @@ -1609,7 +1642,8 @@ Rotates a canvas clockwise around its coordinate axes. - Example - ``` + ```ts +// xxx.ets @Entry @Component struct Rotate { @@ -1652,7 +1686,8 @@ Scales a canvas based on scale factors. - Example - ``` + ```ts +// xxx.ets @Entry @Component struct Scale { @@ -1688,7 +1723,7 @@ transform(scaleX: number, skewX: number, skewY: number, scaleY: number, translat Defines a transformation matrix. To transform a graph, you only need to set parameters of the matrix. The coordinates of the graph are multiplied by the matrix values to obtain new coordinates of the transformed graph. You can use the matrix to implement multiple transform effects. -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> **NOTE** > The following formulas calculate coordinates of the transformed graph. **x** and **y** represent coordinates before transformation, and **x'** and **y'** represent coordinates after transformation. > > - x' = scaleX \* x + skewY \* y + translateX @@ -1707,7 +1742,8 @@ Defines a transformation matrix. To transform a graph, you only need to set para - Example - ``` + ```ts +// xxx.ets @Entry @Component struct Transform { @@ -1760,7 +1796,8 @@ Resets the existing transformation matrix and creates a new transformation matri - Example - ``` + ```ts +// xxx.ets @Entry @Component struct SetTransform { @@ -1806,7 +1843,8 @@ Moves the origin of the coordinate system. - Example - ``` + ```ts +// xxx.ets @Entry @Component struct Translate { @@ -1838,18 +1876,18 @@ Moves the origin of the coordinate system. ### drawImage -drawImage(image: ImageBitmap, dx: number, dy: number): void +drawImage(image: ImageBitmap | PixelMap, dx: number, dy: number): void -drawImage(image: ImageBitmap, dx: number, dy: number, dWidth: number, dHeight: number): void +drawImage(image: ImageBitmap | PixelMap, dx: number, dy: number, dWidth: number, dHeight: number): void -drawImage(image: ImageBitmap, sx: number, sy: number, sWidth: number, sHeight: number, dx: number, dy: number, dWidth: number, dHeight: number):void +drawImage(image: ImageBitmap | PixelMap, sx: number, sy: number, sWidth: number, sHeight: number, dx: number, dy: number, dWidth: number, dHeight: number):void Draws an image. - Parameters | Name | Type | Mandatory | Default Value | Description | | ------- | ---------------------------------------- | --------- | ------------- | ---------------------------------------- | - | image | [ImageBitmap](ts-components-canvas-imagebitmap.md) | Yes | null | Image resource. For details, see ImageBitmap. | + | image | [ImageBitmap](ts-components-canvas-imagebitmap.md) or [PixelMap](../apis/js-apis-image.md#pixelmap7) | Yes | null | Image resource. For details, see ImageBitmap. | | sx | number | No | 0 | X-coordinate of the upper left corner of the rectangle used to crop the source image. | | sy | number | No | 0 | Y-coordinate of the upper left corner of the rectangle used to crop the source image. | | sWidth | number | No | 0 | Target width to crop the source image. | @@ -1862,7 +1900,8 @@ Draws an image. - Example - ``` + ```ts +// xxx.ets @Entry @Component struct Index { @@ -1915,12 +1954,24 @@ Creates an **ImageData** object by copying an existing **ImageData** object. For | --------- | ---------------------------------------- | --------- | ------------- | ----------------------------- | | imagedata | [ImageData](ts-components-canvas-imagebitmap.md) | Yes | null | **ImageData** object to copy. | +### getPixelMap + +getPixelMap(sx: number, sy: number, sw: number, sh: number): PixelMap + +Obtains the **[PixelMap](../apis/js-apis-image.md#pixelmap7)** object created with the pixels within the specified area on the canvas. +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | sx | number | Yes | 0 | X-coordinate of the upper left corner of the output area. | + | sy | number | Yes | 0 | Y-coordinate of the upper left corner of the output area. | + | sw | number | Yes | 0 | Width of the output area. | + | sh | number | Yes | 0 | Height of the output area. | ### getImageData getImageData(sx: number, sy: number, sw: number, sh: number): Object -Creates an [ImageData](ts-components-canvas-imagebitmap.md) object with pixels in the specified area on the canvas. +Obtains the **[ImageData](ts-components-canvas-imagebitmap.md)** object created with the pixels within the specified area on the canvas. - Parameters | Name | Type | Mandatory | Default Value | Description | @@ -1950,7 +2001,8 @@ Puts the [ImageData](ts-components-canvas-imagebitmap.md) onto a rectangular are - Example - ``` + ```ts +// xxx.ets @Entry @Component struct PutImageData { @@ -1993,7 +2045,8 @@ Restores the saved drawing context. - Example - ``` + ```ts +// xxx.ets @Entry @Component struct CanvasExample { @@ -2027,7 +2080,8 @@ Saves the current drawing context. - Example - ``` + ```ts +// xxx.ets @Entry @Component struct CanvasExample { @@ -2069,7 +2123,8 @@ Creates a linear gradient. - Example - ``` + ```ts +// xxx.ets @Entry @Component struct CreateLinearGradient { @@ -2121,7 +2176,8 @@ Creates a linear gradient. - Example - ``` + ```ts +// xxx.ets @Entry @Component struct CreateRadialGradient { diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-focus.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-focus.md index 6af105effec7f96f654d2a3acbb31cbb3017eead..e57cee1aef97a0c7c6c9f72b8740b30e599c4497 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-focus.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-focus.md @@ -1,8 +1,7 @@ # Focus Control - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** -> This attribute is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. +> **NOTE**
+> The APIs of this module are supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. ## Required Permissions @@ -12,66 +11,57 @@ None ## Attributes - | **Name** | **Type** | **Default Value** | **Description** | +| Name| Type| Default Value| Description| | -------- | -------- | -------- | -------- | -| focusable | boolean | false | Whether the current component is focusable. | +| focusable | boolean | false | Whether the current component is focusable.| +| tabIndex9+ | number | 0 | How the current component participates in sequential keyboard navigation.
- **tabIndex** >= 0: The component is focusable in sequential keyboard navigation, with its order defined by the value. A component with a larger value is focused after one with a smaller value. If multiple components share the same **tabIndex** value, their focus order follows their position in the component tree.
- **tabIndex** < 0 (usually **tabIndex** = -1): The component is focusable, but cannot be reached through sequential keyboard navigation. | -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** -> The following components support focus control: **<Button>**, **<Text>**, **<Image>**, **<List>**, and **<Grid>**. +> **NOTE**
+> The following components support focus control: **\