diff --git a/CODEOWNERS b/CODEOWNERS index 6d0f4060fc392e7644ff7462b3889c9b90824723..827a13005c46f79db59e5379ddf23269b690f7c8 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -187,7 +187,8 @@ zh-cn/application-dev/dfx/errormanager-guidelines.md @RayShih zh-cn/application-dev/key-features/multi-device-app-dev/ @lingminghw zh-cn/application-dev/database/ @ge-yafang zh-cn/application-dev/napi/native-window-guidelines.md @ge-yafang -zh-cn/application-dev/napi/mindspore-lite-guidelines.md @ge-yafang +zh-cn/application-dev/napi/mindspore-lite-guidelines.md @ge-yafang +zh-cn/application-dev/napi/neural-network-runtime-guidelines.md @ge-yafang zh-cn/application-dev/napi/rawfile_guidelines.md @ningningW zh-cn/application-dev/background-agent-scheduled-reminder/ @RayShih zh-cn/application-dev/background-task-management/ @ningningW diff --git a/en/application-dev/application-dev-guide.md b/en/application-dev/application-dev-guide.md index a6b12502918a7c3adfa37378241ffceda3e4f015..ad34cdd099a470dd7731cc0c3c086125044261b7 100644 --- a/en/application-dev/application-dev-guide.md +++ b/en/application-dev/application-dev-guide.md @@ -64,7 +64,8 @@ API references encompass all components and APIs available in OpenHarmony, helpi They are organized as follows: - [Component Reference (TypeScript-based Declarative Development Paradigm)](reference/arkui-ts/ts-components-summary.md) -- [Component Reference (JavaScript-compatible Web-like Development Paradigm)](reference/arkui-js/js-components-common-attributes.md) +- [Component Reference (JavaScript-compatible Web-like Development Paradigm- ArkUI.Full)](reference/arkui-js/Readme-EN.md) +- [Component Reference (JavaScript-compatible Web-like Development Paradigm- ArkUI.Lite)](reference/arkui-js-lite/Readme-EN.md) - [JS Service Widget UI Components](reference/js-service-widget-ui/js-service-widget-file.md) - [JS and TS APIs](reference/apis/development-intro.md) - Native APIs diff --git a/en/application-dev/application-models/accessibilityextensionability.md b/en/application-dev/application-models/accessibilityextensionability.md index 5e88bb69d8fec4fc1abd5488a5998930a6a894ad..62f0bd981504d1249e04dcf62c0041e8091496bf 100644 --- a/en/application-dev/application-models/accessibilityextensionability.md +++ b/en/application-dev/application-models/accessibilityextensionability.md @@ -1,4 +1,4 @@ -# AccessibilityExtensionAbility Development +# AccessibilityExtensionAbility The **AccessibilityExtensionAbility** module provides accessibility extension capabilities based on the **ExtensionAbility** framework. You can develop your accessibility applications by applying the **AccessibilityExtensionAbility** template to enhance usability. diff --git a/en/application-dev/application-models/application-component-configuration-stage.md b/en/application-dev/application-models/application-component-configuration-stage.md index b50d40b4a694ecdf55338d249a20ff458d36ba20..db1f4b9f8205993e30c1d4de1000fae72c6d5b08 100644 --- a/en/application-dev/application-models/application-component-configuration-stage.md +++ b/en/application-dev/application-models/application-component-configuration-stage.md @@ -6,7 +6,7 @@ Icons and labels are usually configured together. There is the application icon, The application icon and label are used in **Settings**. For example, they are displayed in the application list in **Settings**. The entry icon is displayed on the device's home screen after the application is installed. The entry icon maps to a [UIAbility](uiability-overview.md) component. Therefore, an application can have multiple entry icons and entry labels. When you touch one of them, the corresponding UIAbility page is displayed. -**Figure 1** Icons and labels +**Figure 1** Icons and labels ![application-component-configuration-stage](figures/application-component-configuration-stage.png) diff --git a/en/application-dev/application-models/arkts-ui-widget-working-principles.md b/en/application-dev/application-models/arkts-ui-widget-working-principles.md index a0edb6c6c68d9ada32cd3ff34f5117d5cc012ed6..b1b09dc409380da8e530f571b2e5711ec63edd10 100644 --- a/en/application-dev/application-models/arkts-ui-widget-working-principles.md +++ b/en/application-dev/application-models/arkts-ui-widget-working-principles.md @@ -3,42 +3,45 @@ ## Implementation Principles - **Figure 1** ArkTS widget implementation principles +**Figure 1** ArkTS widget implementation principles + ![WidgetPrinciple](figures/WidgetPrinciple.png) - Widget host: an application that displays the widget content and controls the widget location. Only the system application can function as a widget host. - Widget provider: an application that provides the widget content to display and controls how widget components are laid out and how they interact with users. -- Widget Manager: a resident agent that manages widgets in the system. It provides the [formProvider](../reference/apis/js-apis-app-form-formProvider.md) and [formHost](../reference/apis/js-apis-app-form-formHost.md) APIs as well as widget management, usage, and periodic updates. +- Widget Manager: a resident agent that manages widgets in the system. It provides the [formProvider](../reference/apis/js-apis-app-form-formProvider.md) and [formHost](../reference/apis/js-apis-app-form-formHost.md) APIs as well as the APIs for widget management, usage, and periodic updates. - Widget rendering service: a service that manages widget rendering instances. Widget rendering instances are bound to the [widget components](../reference/arkui-ts/ts-basic-components-formcomponent.md) on the widget host on a one-to-one basis. The widget rendering service runs the widget page code **widgets.abc** for rendering, and sends the rendered data to the corresponding widget component on the widget host. **Figure 2** Working principles of the ArkTS widget rendering service ![WidgetRender](figures/WidgetRender.png) -Unlike JS widgets, ArkTS widgets support logic code running. To avoid potential ArkTS widget issues from affecting the use of applications, the widget page code **widgets.abc** is executed by the widget rendering service, which is managed by the Widget Manager. Each widget component of a widget host corresponds to a rendering instance in the widget rendering service. Rendering instances of an application provider run in the same virtual machine operating environment, and rendering instances of different application providers run in different virtual machine operating environments. In this way, the resources and state data are isolated between widgets of different application providers. During development, pay attention to the use of the [globalThis](uiability-data-sync-with-ui.md#using-globalthis-between-uiability-and-page) object. Use one **globalThis** object for widgets by the same application provider, and different **globalThis** objects for widgets by different application providers. +Unlike JS widgets, ArkTS widgets support logic code running. The widget page code **widgets.abc** is executed by the widget rendering service, which is managed by the Widget Manager. Each widget component of a widget host corresponds to a rendering instance in the widget rendering service. Rendering instances of a widget provider run in the same virtual machine operating environment, and rendering instances of different widget providers run in different virtual machine operating environments. In this way, the resources and state data are isolated between widgets of different widget providers. During development, pay attention to the use of the [globalThis](uiability-data-sync-with-ui.md#using-globalthis-between-uiability-and-page) object. Use one **globalThis** object for widgets from the same widget provider, and different **globalThis** objects for widgets from different widget providers. ## Advantages of ArkTS Widgets -As a quick entry to applications, ArkTS widgets have the following advantages over JS widgets: +As a quick entry to applications, ArkTS widgets outperform JS widgets in the following aspects: - Improved development experience and efficiency, thanks to the unified development paradigm + ArkTS widgets share the same declarative UI development framework as application pages. This means that the page layouts can be directly reused in widgets, improving development experience and efficiency. - - **Figure 3** Comparison of widget project structures + + **Figure 3** Comparison of widget project structures + ![WidgetProject](figures/WidgetProject.png) - + - More widget features - - Animation: The ArkTS widget supports the [attribute animation](../reference/arkui-ts/ts-animatorproperty.md) and [explicit animation](../reference/arkui-ts/ts-explicit-animation.md) capabilities, which can be leveraged to deliver a more engaging experience. - - Custom drawing: The ArkTS widget allows you to draw graphics with the [Canvas](../reference/arkui-ts/ts-components-canvas-canvas.md) component to present information more vividly. - - Logic code execution: The capability to run logic code in widgets means that service logic can be self-closed in widgets, expanding the service application scenarios of widgets. + - Animation: ArkTS widgets support the [attribute animation](../reference/arkui-ts/ts-animatorproperty.md) and [explicit animation](../reference/arkui-ts/ts-explicit-animation.md) capabilities, which can be leveraged to deliver a more engaging experience. + - Custom drawing: ArkTS widgets allow you to draw graphics with the [\](../reference/arkui-ts/ts-components-canvas-canvas.md) component to present information more vividly. + - Logic code execution: The capability to run logic code in widgets means that service logic can be self-closed in widgets, expanding the use cases of widgets. ## Constraints on ArkTS Widgets -Compared with JS widgets, ArkTS widgets provide more capabilities, but they are also more prone to malicious behavior. The ArkTS widget is displayed in the widget host, which is usually the home screen. To ensure user experience and power consumption, the ArkTS widget capability is restricted as follows: +Compared with JS widgets, ArkTS widgets provide more capabilities, but they are also more prone to malicious behavior. To account for the impact on the widget host – typically the home screen, ArkTS widgets are subject to the following restrictions: - The .so file cannot be loaded. @@ -46,12 +49,14 @@ Compared with JS widgets, ArkTS widgets provide more capabilities, but they are - Only [partial](arkts-ui-widget-page-overview.md) components, events, animations, data management, state management, and API capabilities of the declarative paradigm are supported. -- The event processing of the widget is independent of that of the widget host. It is recommended that you do not use the left and right sliding components when the widget host supports left and right swipes to prevent gesture conflicts. +- The event processing of the widget is independent of that of the widget host. To prevent gesture conflicts, avoid using swipers in the widget when the widget host supports left and right swipes. -The following features are coming to ArkTS widgets in later versions: +In addition, ArkTS widgets do not support the following features: -- Breakpoint debugging - -- import statements +- Importing modules - Instant preview + +- Breakpoint debugging. + +- Hot reload diff --git a/en/application-dev/application-models/figures/WidgetPrinciple.png b/en/application-dev/application-models/figures/WidgetPrinciple.png index 588975d0095de58d0d220809ba77aec541a64984..68ca315394fe2cb5bd2580ca6df38b9940ac1349 100644 Binary files a/en/application-dev/application-models/figures/WidgetPrinciple.png and b/en/application-dev/application-models/figures/WidgetPrinciple.png differ diff --git a/en/application-dev/application-models/figures/WidgetProject.png b/en/application-dev/application-models/figures/WidgetProject.png index 788bb3ac63ca5727527bd104f76689f762b7b33d..299eed75fc1edfd9557e0fe743facb0e9c8d94b2 100644 Binary files a/en/application-dev/application-models/figures/WidgetProject.png and b/en/application-dev/application-models/figures/WidgetProject.png differ diff --git a/en/application-dev/application-models/figures/WidgetRender.png b/en/application-dev/application-models/figures/WidgetRender.png index 228128b143995fec75c71c4172e3d90ca15177f6..0f46bd74b0e48ac0c9f947d96d5e147786f547c0 100644 Binary files a/en/application-dev/application-models/figures/WidgetRender.png and b/en/application-dev/application-models/figures/WidgetRender.png differ diff --git a/en/application-dev/application-models/inputmethodextentionability.md b/en/application-dev/application-models/inputmethodextentionability.md index 2e8371d7e7b9514003295ad4f57b1b8fd678ad3b..eea85014d86310fffd2d22119f3ae68cb3a29493 100644 --- a/en/application-dev/application-models/inputmethodextentionability.md +++ b/en/application-dev/application-models/inputmethodextentionability.md @@ -1,4 +1,4 @@ -# InputMethodExtensionAbility Development +# InputMethodExtensionAbility ## When to Use [InputMethodExtensionAbility](../reference/apis/js-apis-inputmethod-extension-ability.md), inherited from [ExtensionAbility](extensionability-overview.md), is used for developing input method applications. diff --git a/en/application-dev/application-models/serviceextensionability.md b/en/application-dev/application-models/serviceextensionability.md index 555a288f4726a2bfbb9db9cf0c26b1cb8e799b04..f2546aed3e2436b574690ef281347a5715b79dad 100644 --- a/en/application-dev/application-models/serviceextensionability.md +++ b/en/application-dev/application-models/serviceextensionability.md @@ -401,7 +401,7 @@ When ServiceExtensionAbility is used to provide sensitive services, the client i console.info(TAG, 'getBundleNameByUid: ' + callerBundleName); // Identify the bundle name of the client. if (callerBundleName != 'com.example.connectextapp') { // The verification fails. - console.info(TAG, 'The caller bundle is not in whitelist, reject'); + console.info(TAG, 'The caller bundle is not in trustlist, reject'); return; } // The verification is successful, and service logic is executed normally. diff --git a/en/application-dev/application-models/windowextensionability.md b/en/application-dev/application-models/windowextensionability.md index 975b350a47966341bd9c60046f9b69ee011f9ae3..3f07cb8e46f1289c70144981e5250b165d84cf7d 100644 --- a/en/application-dev/application-models/windowextensionability.md +++ b/en/application-dev/application-models/windowextensionability.md @@ -1,4 +1,4 @@ -# WindowExtensionAbility +# WindowExtensionAbility (for System Applications Only) [WindowExtensionAbility](../reference/apis/js-apis-application-windowExtensionAbility.md) is a type of ExtensionAbility component that allows a system application to be embedded in and displayed over another application. @@ -7,15 +7,14 @@ The WindowExtensionAbility component must be used together with the [AbilityComponent](../reference/arkui-ts/ts-container-ability-component.md) to process services of the started application. WindowExtensionAbility is run in connection mode. A system application must use the AbilityComponent to start the WindowExtensionAbility component. Each ExtensionAbility has its own context. For WindowExtensionAbility, -the context is [WindowExtensionContext](../reference/apis/js-apis-inner-application-windowExtensionContext.md). +the context is [WindowExtensionContext](../reference/apis/js-apis-inner-application-windowExtensionContext.md). > **NOTE** > > **WindowExtensionAbility** is a system API. To embed a third-party application in another application and display it over the application, switch to the full SDK by following the instructions provided in [Guide to Switching to Full SDK](../../application-dev/quick-start/full-sdk-switch-guide.md). -> -## Setting an Embedded UIAbility (for System Applications Only) +## Setting an Embedded UIAbility The **WindowExtensionAbility** class provides **onConnect()**, **onDisconnect()**, and **onWindowReady()** lifecycle callbacks, which can be overridden. @@ -79,7 +78,7 @@ To implement an embedded application, manually create a WindowExtensionAbility i ``` -## Starting an Embedded UIAbility (for System Applications Only) +## Starting an Embedded UIAbility System applications can load the created WindowExtensionAbility through the AbilityComponent. @@ -110,4 +109,5 @@ System applications can load the created WindowExtensionAbility through the Abil .backgroundColor(0x64BB5c) } } - ``` \ No newline at end of file + ``` + diff --git a/en/application-dev/application-test/arkxtest-guidelines.md b/en/application-dev/application-test/arkxtest-guidelines.md index 5f4f36e78850272bc5101fa1b86e76f6e91d5f37..cccf0b6049941195a787cba716946299c0d3f4ae 100644 --- a/en/application-dev/application-test/arkxtest-guidelines.md +++ b/en/application-dev/application-test/arkxtest-guidelines.md @@ -13,7 +13,7 @@ In this document you will learn about the key functions of arkXtest and how to u arkXtest is part of the OpenHarmony toolkit and provides basic capabilities of writing and running OpenHarmony automated test scripts. In terms of test script writing, arkXtest offers a wide range of APIs, including basic process APIs, assertion APIs, and APIs related to UI operations. In terms of test script running, arkXtest offers such features as identifying, scheduling, and executing test scripts, as well as summarizing test script execution results. -### Principles +### Implementation arkXtest is divided into two parts: unit test framework and UI test framework. @@ -27,28 +27,28 @@ arkXtest is divided into two parts: unit test framework and UI test framework. ![](figures/TestFlow.PNG) -- UI Testing Framework +- UI Test Framework - The UI test framework provides [UiTest APIs](../reference/apis/js-apis-uitest.md) for you to call in different test scenarios. The test scripts are executed on top of the unit test framework mentioned above. + The UI test framework provides [UiTest APIs](../reference/apis/js-apis-uitest.md) for you to call in different test scenarios. The UI test scripts are executed on top of the aformentioned unit test framework. The figure below shows the main functions of the UI test framework. ![](figures/Uitest.PNG) -### Limitations and Constraints +### Constraints - The features of the UI test framework are available only in OpenHarmony 3.1 and later versions. - The feature availability of the unit test framework varies by version. For details about the mappings between the features and versions, see [arkXtest](https://gitee.com/openharmony/testfwk_arkxtest/blob/master/README_en.md). -## Environment preparations +## Preparing the Environment ### Environment Requirements -Software for writing test scripts: DevEco Studio 3.0 or later +Software: DevEco Studio 3.0 or later -Hardware for running test scripts: PC connected to a OpenHarmony device, such as the RK3568 development board +Hardware: PC connected to an OpenHarmony device, such as the RK3568 development board ### Setting Up the Environment @@ -57,7 +57,7 @@ Hardware for running test scripts: PC connected to a OpenHarmony device, such as ## Creating a Test Script -1. Open DevEco Studio and create a project, where the **ohos** directory is where the test script is located. +1. Open DevEco Studio and create a project, in which the **ohos** directory is where the test script is located. 2. Open the .ets file of the module to be tested in the project directory. Move the cursor to any position in the code, and then right-click and choose **Show Context Actions** > **Create Ohos Test** or press **Alt+Enter** and choose **Create Ohos Test** to create a test class. ## Writing a Unit Test Script @@ -95,7 +95,7 @@ export default function abilityTest() { The unit test script must contain the following basic elements: -1. Import of the dependency package so that the dependent test APIs can be used. +1. Import of the dependencies so that the dependent test APIs can be used. 2. Test code, mainly about the related logic, such as API invoking. @@ -105,7 +105,7 @@ The unit test script must contain the following basic elements: You write a UI test script based on the unit test framework, adding the invoking of APIs provided by the UI test framework to implement the corresponding test logic. -In this example, the UI test script is written based on the preceding unit test script. First, add the dependency package, as shown below: +In this example, the UI test script is written based on the preceding unit test script. First, import the dependency, as shown below: ```js import {Driver,ON,Component,MatchPattern} from '@ohos.uitest' @@ -180,11 +180,11 @@ The logs added to the test case are displayed after the test case execution, rat **Possible Causes** -More than one asynchronous interface is called in the test case.
In principle, logs in the test case are printed before the test case execution is complete. +More than one asynchronous API is called in the test case.
In principle, logs in the test case are printed before the test case execution is complete. - **Solution** +**Solution** -If more than one asynchronous interface is called, you are advised to encapsulate the interface invoking into the promise mode +If more than one asynchronous API is called, you are advised to encapsulate the API invoking into the promise mode. #### Error "fail to start ability" is reported during test case execution @@ -227,7 +227,7 @@ The UI test case fails to be executed. The HiLog file contains the error message **Possible Causes** -The ArkUI feature is disabled. As a result, the control tree information on the test page is not generated. +The ArkUI feature is disabled. As a result, the component tree information is not generated on the test page. **Solution** @@ -237,33 +237,33 @@ Run the following command, restart the device, and execute the test case again: hdc shell param set persist.ace.testmode.enabled 1 ``` -#### The failure log contains "uitest-api dose not allow calling concurrently" +#### The failure log contains "uitest-api does not allow calling concurrently" **Problem** -The UI test case fails to be executed. The HiLog file contains the error message "uitest-api dose not allow calling concurrently". +The UI test case fails to be executed. The HiLog file contains the error message "uitest-api does not allow calling concurrently". **Possible Causes** -1. In the test case, the **await** operator is not added to the asynchronous interface provided by the UI test framework. +1. In the test case, the **await** operator is not added to the asynchronous API provided by the UI test framework. 2. The UI test case is executed in multiple processes. As a result, multiple UI test processes are started. The framework does not support multi-process invoking. **Solution** -1. Check the case implementation and add the **await** operator to the asynchronous interface invoking. +1. Check the case implementation and add the **await** operator to the asynchronous API. 2. Do not execute UI test cases in multiple processes. -#### The failure log contains "dose not exist on current UI! Check if the UI has changed after you got the widget object" +#### The failure log contains "does not exist on current UI! Check if the UI has changed after you got the widget object" **Problem** -The UI test case fails to be executed. The HiLog file contains the error message "dose not exist on current UI! Check if the UI has changed after you got the widget object". +The UI test case fails to be executed. The HiLog file contains the error message "does not exist on current UI! Check if the UI has changed after you got the widget object." **Possible Causes** -After the target component is found in the code of the test case, the device UI changes. As a result, the found component is lost and the emulation operation cannot be performed. +After the target component is found in the code of the test case, the device UI changes, resulting in loss of the found component and inability to perform emulation. **Solution** diff --git a/en/application-dev/connectivity/http-request.md b/en/application-dev/connectivity/http-request.md index 996720a573aefd71e5be9766cba90df423e730b7..39ed52f818f0d904099bf13a581b58a84d61adae 100644 --- a/en/application-dev/connectivity/http-request.md +++ b/en/application-dev/connectivity/http-request.md @@ -70,6 +70,8 @@ httpRequest.request( // data.header carries the HTTP response header. Parse the content based on service requirements. console.info('header:' + JSON.stringify(data.header)); console.info('cookies:' + JSON.stringify(data.cookies)); // 8+ + // Call the destroy() method to release resources after the HttpRequest is complete. + httpRequest.destroy(); } else { console.info('error:' + JSON.stringify(err)); // Unsubscribe from HTTP Response Header events. diff --git a/en/application-dev/database/share-device-data-across-apps-overview.md b/en/application-dev/database/share-device-data-across-apps-overview.md index 6392e579a8e078e4ff41751aa2ebcc1481ac58a0..0d8fb24ae88a3a5ea0d9f9f8b386afbce5d8f1a1 100644 --- a/en/application-dev/database/share-device-data-across-apps-overview.md +++ b/en/application-dev/database/share-device-data-across-apps-overview.md @@ -1,5 +1,6 @@ # Cross-Application Data Sharing Overview + ## Function The application data on a device, such as the Contacts, short message service (SMS), and Gallery data, always needs to be shared with other applications. However, certain data, such as the accounts and passwords, cannot be shared. Certain data, such as SMS messages, can be accessed but not modified by other applications. The **DataShare** module provides a secure and easy-to-use mechanism for sharing data of an application with other applications on the same device. @@ -18,7 +19,6 @@ Before developing cross-application data sharing on a device, understand the fol - **Predicates**: an object that specifies the conditions for updating, deleting, or querying data in a database. - ## Implementation The data provider can directly use **DataShare** to share data with other applications without complex encapsulation. The data consumer only needs to use a set of APIs to access the data, because the **DataShare** access mode does not vary with the data provisioning mode. This greatly reduces the learning time and development difficulty. @@ -37,7 +37,6 @@ The cross-application data sharing can be implemented in either of the following This method is recommended when the cross-application data access involves only the operations for adding, deleting, modifying, and querying data in databases. - ## Constraints - **DataShare** is subject to the limitations on the database used by the data provider. The supported data models, length of the keys and values, and maximum number of databases that can be accessed at a time by each application vary with the database in use. diff --git a/en/application-dev/dfx/hitracemeter-guidelines.md b/en/application-dev/dfx/hitracemeter-guidelines.md index 3adf91286aaf410d7862c60320878e57acb359e8..3244aa9356bbcd3748594061a3752fad8aa3d3f3 100644 --- a/en/application-dev/dfx/hitracemeter-guidelines.md +++ b/en/application-dev/dfx/hitracemeter-guidelines.md @@ -21,7 +21,7 @@ Due to the asynchronous I/O feature of JS, the hiTraceMeter module provides only ## Available APIs -The performance tracing APIs are provided by the **hiTraceMeter** module. For details, see [API Reference]( ../reference/apis/js-apis-hitracemeter.md). +The performance tracing APIs are provided by the **hiTraceMeter** module. For details, see [API Reference](../reference/apis/js-apis-hitracemeter.md). **APIs for performance tracing** diff --git a/en/application-dev/file-management/app-fs-space-statistics.md b/en/application-dev/file-management/app-fs-space-statistics.md index 6854af8c857173db01bcaf730722630c4bffba1b..9596834a5b5bda14e810061817dcdf55da3aaf3a 100644 --- a/en/application-dev/file-management/app-fs-space-statistics.md +++ b/en/application-dev/file-management/app-fs-space-statistics.md @@ -10,7 +10,7 @@ For details about the APIs, see [ohos.file.statvfs](../reference/apis/js-apis-fi | Module| API| Description| | -------- | -------- | -------- | -| \@ohos.file.storageStatistic | getCurrentBundleStats | Obtains the storage space of the current application, in bytes.| +| \@ohos.file.storageStatistics | getCurrentBundleStats | Obtains the storage space of the current application, in bytes.| | \@ohos.file.statvfs | getFreeSize | Obtains the free space of a file system, in bytes.| | \@ohos.file.statvfs | getTotalSize | Obtains the total space of a file system, in bytes.| diff --git a/en/application-dev/file-management/save-user-file.md b/en/application-dev/file-management/save-user-file.md index d1ca80444deffa2bad38f01442e0135e20ac67c3..db6ad37908be0a1fe1dd00e36c4553830bf03c72 100644 --- a/en/application-dev/file-management/save-user-file.md +++ b/en/application-dev/file-management/save-user-file.md @@ -7,10 +7,11 @@ The operations for saving images, audio or video clips, and documents are simila ## Saving Images or Video Files -1. Import the **FilePicker** module. +1. Import the **picker** module and **fs** module. ```ts import picker from '@ohos.file.picker'; + import fs from '@ohos.file.fs'; ``` 2. Create a **photoSaveOptions** instance. @@ -20,27 +21,43 @@ The operations for saving images, audio or video clips, and documents are simila photoSaveOptions.newFileNames = ["PhotoViewPicker01.jpg"]; // (Optional) Set the names of the files to save. ``` -3. Create a **photoViewPicker** instance and call [save()](../reference/apis/js-apis-file-picker.md#save) to open the **FilePicker** page to save the files. - After the user selects the target folder, the file saving operation is complete. After the files are saved successfully, the URIs of the files saved are returned. +3. Create a **photoViewPicker** instance and call [save()](../reference/apis/js-apis-file-picker.md#save) to open the **FilePicker** page to save the files. After the user selects the target folder, the file saving operation is complete. After the files are saved successfully, the URIs of the files saved are returned. + +
The permission on the URIs returned by **save()** is read/write. Further file operations can be performed based on the URIs in the result set. Note that the URI cannot be directly used in the **picker** callback to open a file. You need to define a global variable to save the URI and use a button to trigger file opening. ```ts + let URI = null; const photoViewPicker = new picker.PhotoViewPicker(); - photoViewPicker.save(photoSaveOptions) - .then(async (photoSaveResult) => { - let uri = photoSaveResult[0]; - // Perform operations on the files based on the file URIs obtained. - }) - .catch((err) => { - console.error(`Invoke documentPicker.select failed, code is ${err.code}, message is ${err.message}`); - }) + photoViewPicker.save(photoSaveOptions).then((photoSaveResult) => { + URI = photoSaveResult[0]; + console.info('photoViewPicker.save to file succeed and URI is:' + URI); + }).catch((err) => { + console.error(`Invoke photoViewPicker.save failed, code is ${err.code}, message is ${err.message}`); + }) + ``` + +4. Use a button to trigger invocation of other functions. Use [fs.openSync()](../reference/apis/js-apis-file-fs.md#fsopensync) to open the file based on the URI and obtain the FD. Note that the **mode** parameter of **fs.openSync()** must be **fs.OpenMode.READ_WRITE**. + + ```ts + let file = fs.openSync(URI, fs.OpenMode.READ_WRITE); + console.info('file fd: ' + file.fd); + ``` + +5. Use [fs.writeSync()](../reference/apis/js-apis-file-fs.md#writesync) to edit the file based on the FD, and then close the FD. + + ```ts + let writeLen = fs.writeSync(file.fd, 'hello, world'); + console.info('write data to file succeed and size is:' + writeLen); + fs.closeSync(file); ``` ## Saving Documents -1. Import the **FilePicker** module. +1. Import the **picker** module and **fs** module. ```ts import picker from '@ohos.file.picker'; + import fs from '@ohos.file.fs'; ``` 2. Create a **documentSaveOptions** instance. @@ -50,31 +67,43 @@ The operations for saving images, audio or video clips, and documents are simila documentSaveOptions.newFileNames = ["DocumentViewPicker01.txt"]; // (Optional) Set the names of the documents to save. ``` -3. Create a **documentViewPicker** instance, and call [save()](../reference/apis/js-apis-file-picker.md#save-3) to open the **FilePicker** page to save the documents. - After the user selects the target folder, the file saving operation is complete. After the files are saved successfully, the URIs of the files saved are returned. - - > **NOTE** - > - > Currently, **DocumentSelectOptions** is not configurable. By default, all types of user files are selected. +3. Create a **documentViewPicker** instance, and call [save()](../reference/apis/js-apis-file-picker.md#save-3) to open the **FilePicker** page to save the documents. After the user selects the target folder, the file saving operation is complete. After the files are saved successfully, the URIs of the files saved are returned. + + The permission on the URIs returned by **save()** is read/write. Further file operations can be performed based on the URIs in the result set. Note that the URI cannot be directly used in the **picker** callback to open a file. You need to define a global variable to save the URI and use a button to trigger file opening. ```ts + let URI = null; const documentViewPicker = new picker.DocumentViewPicker(); // Create a documentViewPicker instance. - documentViewPicker.save(documentSaveOptions) - .then(async (documentSaveResult) => { - let uri = documentSaveResult[0]; - // For example, write data to the documents based on the obtained URIs. - }) - .catch((err) => { - console.error(`Invoke documentPicker.save failed, code is ${err.code}, message is ${err.message}`); - }) + documentViewPicker.save(documentSaveOptions).then((documentSaveResult) => { + URI = documentSaveResult[0]; + console.info('documentViewPicker.save to file succeed and URI is:' + URI); + }).catch((err) => { + console.error(`Invoke documentViewPicker.save failed, code is ${err.code}, message is ${err.message}`); + }) + ``` + +4. Use a button to trigger invocation of other functions. Use [fs.openSync()](../reference/apis/js-apis-file-fs.md#fsopensync) to open the file based on the URI and obtain the FD. Note that the **mode** parameter of **fs.openSync()** must be **fs.OpenMode.READ_WRITE**. + + ```ts + let file = fs.openSync(URI, fs.OpenMode.READ_WRITE); + console.info('file fd: ' + file.fd); + ``` + +5. Use [fs.writeSync()](../reference/apis/js-apis-file-fs.md#writesync) to edit the file based on the FD, and then close the FD. + + ```ts + let writeLen = fs.writeSync(file.fd, 'hello, world'); + console.info('write data to file succeed and size is:' + writeLen); + fs.closeSync(file); ``` ## Saving Audio Files -1. Import the **FilePicker** module. +1. Import the **picker** module and **fs** module. ```ts import picker from '@ohos.file.picker'; + import fs from '@ohos.file.fs'; ``` 2. Create an **audioSaveOptions** instance. @@ -84,20 +113,33 @@ The operations for saving images, audio or video clips, and documents are simila audioSaveOptions.newFileNames = ['AudioViewPicker01.mp3']; // (Optional) Set the names of the files to save. ``` -3. Create an **audioViewPicker** instance, and call [save()](../reference/apis/js-apis-file-picker.md#save-6) to open the **FilePicker** page to save the files. - After the user selects the target folder, the file saving operation is complete. After the files are saved successfully, the URIs of the files saved are returned. - > **NOTE** - > - > Currently, **AudioSelectOptions** is not configurable. By default, all types of user files are selected. - +3. Create an **audioViewPicker** instance, and call [save()](../reference/apis/js-apis-file-picker.md#save-6) to open the **FilePicker** page to save the files. After the user selects the target folder, the file saving operation is complete. After the files are saved successfully, the URIs of the files saved are returned. + + The permission on the URIs returned by **save()** is read/write. Further file operations can be performed based on the URIs in the result set. Note that the URI cannot be directly used in the **picker** callback to open a file. You need to define a global variable to save the URI and use a button to trigger file opening. + ```ts + let URI = null; const audioViewPicker = new picker.AudioViewPicker(); - audioViewPicker.save(audioSaveOptions) - .then((audioSelectResult) => { - let uri = audioSelectResult[0]; - // Perform operations on the audio files based on the file URIs. - }) - .catch((err) => { - console.error(`Invoke audioPicker.select failed, code is ${err.code}, message is ${err.message}`); - }) + audioViewPicker.save(audioSaveOptions).then((audioSelectResult) => { + URI = audioSelectResult[0]; + console.info('audioViewPicker.save to file succeed and URI is:' + URI); + }).catch((err) => { + console.error(`Invoke audioViewPicker.save failed, code is ${err.code}, message is ${err.message}`); + }) + ``` + +4. Use a button to trigger invocation of other functions. Use [fs.openSync()](../reference/apis/js-apis-file-fs.md#fsopensync) to open the file based on the URI and obtain the FD. Note that the **mode** parameter of **fs.openSync()** must be **fs.OpenMode.READ_WRITE**. + + ```ts + let file = fs.openSync(URI, fs.OpenMode.READ_WRITE); + console.info('file fd: ' + file.fd); + ``` + +5. Use [fs.writeSync](../reference/apis/js-apis-file-fs.md#writesync) to edit the file based on the FD, and then close the FD. + + ```ts + let writeLen = fs.writeSync(file.fd, 'hello, world'); + console.info('write data to file succeed and size is:' + writeLen); + fs.closeSync(file); ``` + diff --git a/en/application-dev/file-management/select-user-file.md b/en/application-dev/file-management/select-user-file.md index c87015b50235ff9c54721668c019caea9119a5ae..853aae60d7e73fa4238e388eefb19ded0ca59b1d 100644 --- a/en/application-dev/file-management/select-user-file.md +++ b/en/application-dev/file-management/select-user-file.md @@ -1,6 +1,6 @@ # Selecting User Files -If your application needs to support share and saving of user files (such as images and videos) by users, you can use the [FilePicker](../reference/apis/js-apis-file-picker.md) prebuilt in OpenHarmony to implement selecting and saving of user files. +If your application needs to support share and saving of user files (such as images and videos), you can use OpenHarmony [FilePicker](../reference/apis/js-apis-file-picker.md) to implement selection and saving of user files. The **FilePicker** provides the following interfaces by file type: @@ -12,10 +12,11 @@ The **FilePicker** provides the following interfaces by file type: ## Selecting Images or Video Files -1. Import the **FilePicker** module. +1. Import the **picker** module and **fs** module. ```ts import picker from '@ohos.file.picker'; + import fs from '@ohos.file.fs'; ``` 2. Create a **photoSelectOptions** instance. @@ -32,28 +33,44 @@ The **FilePicker** provides the following interfaces by file type: photoSelectOptions.maxSelectNumber = 5; // Set the maximum number of images to select. ``` -4. Create a **photoPicker** instance and call [select()](../reference/apis/js-apis-file-picker.md#select) to open the **FilePicker** page for the user to select files. +4. Create a **photoPicker** instance and call [select()](../reference/apis/js-apis-file-picker.md#select) to open the **FilePicker** page for the user to select files. After the files are selected, [PhotoSelectResult](../reference/apis/js-apis-file-picker.md#photoselectresult) is returned. + +
The permission on the URIs returned by **select()** is read-only. Further file operations can be performed based on the URIs in the **PhotoSelectResult**. Note that the URI cannot be directly used in the **picker** callback to open a file. You need to define a global variable to save the URI and use a button to trigger file opening. - Use [PhotoSelectResult](../reference/apis/js-apis-file-picker.md#photoselectresult) to return a result set. Further operations on the selected files can be performed based on the file URIs in the result set. + ```ts + let URI = null; + const photoViewPicker = new picker.PhotoViewPicker(); + photoViewPicker.select(photoSelectOptions).then((photoSelectResult) => { + URI = photoSelectResult.photoUris[0]; + console.info('photoViewPicker.select to file succeed and URI is:' + URI); + }).catch((err) => { + console.error(`Invoke photoViewPicker.select failed, code is ${err.code}, message is ${err.message}`); + }) + ``` + +5. Use a button to trigger invocation of other functions. Use [fs.openSync()](../reference/apis/js-apis-file-fs.md#fsopensync) to open the file based on the URI and obtain the FD. Note that the **mode** parameter of **fs.openSync()** must be **fs.OpenMode.READ_ONLY**. + + ```ts + let file = fs.openSync(URI, fs.OpenMode.READ_ONLY); + console.info('file fd: ' + file.fd); + ``` + +6. Use [fs.readSync()](../reference/apis/js-apis-file-fs.md#readsync) to read the file data based on the FD. After the data is read, close the FD. ```ts - const photoPicker = new picker.PhotoViewPicker(); - photoPicker.select(photoSelectOptions) - .then(async (photoSelectResult) => { - let uri = photoSelectResult.photoUris[0]; - // Perform operations on the files based on the file URIs obtained. - }) - .catch((err) => { - console.error(`Invoke documentPicker.select failed, code is ${err.code}, message is ${err.message}`); - }) + let buffer = new ArrayBuffer(4096); + let readLen = fs.readSync(file.fd, buffer); + console.info('readSync data to file succeed and buffer size is:' + readLen); + fs.closeSync(file); ``` ## Selecting Documents -1. Import the **FilePicker** module. +1. Import the **picker** module and **fs** module. ```ts import picker from '@ohos.file.picker'; + import fs from '@ohos.file.fs'; ``` 2. Create a **documentSelectOptions** instance. @@ -62,26 +79,25 @@ The **FilePicker** provides the following interfaces by file type: const documentSelectOptions = new picker.DocumentSelectOptions(); ``` -3. Create a **documentViewPicker** instance, and call [**select()**](../reference/apis/js-apis-file-picker.md#select-3) to open the **FilePicker** page for the user to select documents. - - After the documents are selected successfully, a result set containing the file URIs is returned. Further operations can be performed on the documents based on the file URIs. - - For example, you can use [file management APIs](../reference/apis/js-apis-file-fs.md) to obtain file attribute information, such as the file size, access time, and last modification time, based on the URI. If you need to obtain the file name, use [startAbilityForResult](../../application-dev/application-models/uiability-intra-device-interaction.md). +3. Create a **documentViewPicker** instance, and call [**select()**](../reference/apis/js-apis-file-picker.md#select-3) to open the **FilePicker** page for the user to select documents. After the documents are selected, a result set containing the file URIs is returned. + +
The permission on the URIs returned by **select()** is read-only. Further file operations can be performed based on the URIs in the result set. Note that the URI cannot be directly used in the **picker** callback to open a file. You need to define a global variable to save the URI and use a button to trigger file opening. + +
For example, you can use [file management APIs](../reference/apis/js-apis-file-fs.md) to obtain file attribute information, such as the file size, access time, and last modification time, based on the URI. If you need to obtain the file name, use [startAbilityForResult](../../application-dev/application-models/uiability-intra-device-interaction.md). > **NOTE** > > Currently, **DocumentSelectOptions** is not configurable. By default, all types of user files are selected. ```ts + let URI = null; const documentViewPicker = new picker.DocumentViewPicker(); // Create a documentViewPicker instance. - documentViewPicker.select(documentSelectOptions) - .then((documentSelectResult) => { - let uri = documentSelectResult[0]; - // Perform operations on the documents based on the file URIs. - }) - .catch((err) => { - console.error(`Invoke documentPicker.select failed, code is ${err.code}, message is ${err.message}`); - }) + documentViewPicker.select(documentSelectOptions).then((documentSelectResult) => { + URI = documentSelectResult[0]; + console.info('documentViewPicker.select to file succeed and URI is:' + URI); + }).catch((err) => { + console.error(`Invoke documentViewPicker.select failed, code is ${err.code}, message is ${err.message}`); + }) ``` > **NOTE** @@ -98,7 +114,7 @@ The **FilePicker** provides the following interfaces by file type: try { let result = await context.startAbilityForResult(config, {windowMode: 1}); if (result.resultCode !== 0) { - console.error(`DocumentPicker.select failed, code is ${result.resultCode}, message is ${result.want.parameters.message}`); + console.error(`documentViewPicker.select failed, code is ${result.resultCode}, message is ${result.want.parameters.message}`); return; } // Obtain the URI of the document. @@ -106,16 +122,34 @@ The **FilePicker** provides the following interfaces by file type: // Obtain the name of the document. let file_name_list = result.want.parameters.file_name_list; } catch (err) { - console.error(`Invoke documentPicker.select failed, code is ${err.code}, message is ${err.message}`); + console.error(`Invoke documentViewPicker.select failed, code is ${err.code}, message is ${err.message}`); } ``` +4. Use a button to trigger invocation of other functions. Use [fs.openSync()](../reference/apis/js-apis-file-fs.md#fsopensync) to open the file based on the URI and obtain the FD. Note that the **mode** parameter of **fs.openSync()** must be **fs.OpenMode.READ_ONLY**. + + ```ts + let file = fs.openSync(URI, fs.OpenMode.READ_ONLY); + console.info('file fd: ' + file.fd); + ``` + +5. Use [fs.readSync()](../reference/apis/js-apis-file-fs.md#readsync) to read the file data based on the FD. After the data is read, close the FD. + + ```ts + let buffer = new ArrayBuffer(4096); + let readLen = fs.readSync(file.fd, buffer); + console.info('readSync data to file succeed and buffer size is:' + readLen); + fs.closeSync(file); + ``` + + ## Selecting an Audio File -1. Import the **FilePicker** module. +1. Import the **picker** module and **fs** module. ```ts import picker from '@ohos.file.picker'; + import fs from '@ohos.file.fs'; ``` 2. Create an **audioSelectOptions** instance. @@ -124,24 +158,39 @@ The **FilePicker** provides the following interfaces by file type: const audioSelectOptions = new picker.AudioSelectOptions(); ``` -3. Create an **audioViewPicker** instance, and call [**select()**](../reference/apis/js-apis-file-picker.md#select-6) to open the **FilePicker** page for the user to select audio files. - - After the files are selected successfully, a result set containing the URIs of the audio files selected is returned. Further operations can be performed on the documents based on the file URIs. - - For example, use the [file management interface](../reference/apis/js-apis-file-fs.md) to obtain the file handle (FD) of the audio clip based on the URI, and then develop the audio playback function based on the media service. For details, see [Audio Playback Development](../media/audio-playback-overview.md). +3. Create an **audioViewPicker** instance, and call [**select()**](../reference/apis/js-apis-file-picker.md#select-6) to open the **FilePicker** page for the user to select audio files. After the files are selected, a result set containing the URIs of the audio files selected is returned. + +
The permission on the URIs returned by **select()** is read-only. Further file operations can be performed based on the URIs in the result set. Note that the URI cannot be directly used in the **picker** callback to open a file. You need to define a global variable to save the URI and use a button to trigger file opening. + +
For example, use the [file management interface](../reference/apis/js-apis-file-fs.md) to obtain the file handle (FD) of the audio clip based on the URI, and then develop the audio playback function based on the media service. For details, see [Audio Playback Development](../media/audio-playback-overview.md). > **NOTE** > > Currently, **AudioSelectOptions** is not configurable. By default, all types of user files are selected. ```ts + let URI = null; const audioViewPicker = new picker.AudioViewPicker(); - audioViewPicker.select(audioSelectOptions) - .then(audioSelectResult => { - let uri = audioSelectOptions[0]; - // Perform operations on the audio files based on the file URIs. - }) - .catch((err) => { - console.error(`Invoke audioPicker.select failed, code is ${err.code}, message is ${err.message}`); - }) + audioViewPicker.select(audioSelectOptions).then(audioSelectResult => { + URI = audioSelectOptions[0]; + console.info('audioViewPicker.select to file succeed and URI is:' + URI); + }).catch((err) => { + console.error(`Invoke audioViewPicker.select failed, code is ${err.code}, message is ${err.message}`); + }) + ``` + +4. Use a button to trigger invocation of other functions. Use [fs.openSync()](../reference/apis/js-apis-file-fs.md#fsopensync) to open the file based on the URI and obtain the FD. Note that the **mode** parameter of **fs.openSync()** must be **fs.OpenMode.READ_ONLY**. + + ```ts + let file = fs.openSync(URI, fs.OpenMode.READ_ONLY); + console.info('file fd: ' + file.fd); + ``` + +5. Use [fs.readSync()](../reference/apis/js-apis-file-fs.md#readsync) to read the file data based on the FD. After the data is read, close the FD. + + ```ts + let buffer = new ArrayBuffer(4096); + let readLen = fs.readSync(file.fd, buffer); + console.info('readSync data to file succeed and buffer size is:' + readLen); + fs.closeSync(file); ``` diff --git a/en/application-dev/internationalization/intl-guidelines.md b/en/application-dev/internationalization/intl-guidelines.md index 5731421555d083f90464a0257a21c119ebd8ee3a..087b5fb6a837c764aea1888ea5a5bbe3b913bdb1 100644 --- a/en/application-dev/internationalization/intl-guidelines.md +++ b/en/application-dev/internationalization/intl-guidelines.md @@ -349,7 +349,7 @@ According to grammars in certain languages, the singular or plural form of a nou let relativeTimeFormat = new Intl.RelativeTimeFormat(); ``` - Alternatively, use your own locale and formatting parameters to create a **RelativeTimeFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [RelativeTimeFormatInputOptions](../reference/apis/js-apis-intl.md#relativetimeformatinputoptions9). + Alternatively, use your own locale and formatting parameters to create a **RelativeTimeFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [ RelativeTimeFormatInputOptions](../reference/apis/js-apis-intl.md#relativetimeformatinputoptions9). ```js let relativeTimeFormat = new Intl.RelativeTimeFormat("zh-CN", {numeric: "always", style: "long"}); @@ -384,4 +384,10 @@ According to grammars in certain languages, the singular or plural form of a nou ```js let relativeTimeFormat = new Intl.RelativeTimeFormat("zh-CN", {numeric: "always", style: "long"}); let options = relativeTimeFormat.resolvedOptions(); // options = {"locale": "zh-CN", "style": "long", "numeric": "always", "numberingSystem": "latn"} - ``` \ No newline at end of file + ``` + +## Samples + +The following sample is provided to help you better understand how to develop internationalization capabilities: + +- [`International`: Internationalization (ArkTS) (API9) (Full SDK)] (https://gitee.com/openharmony/applications_app_samples/tree/OpenHarmony-3.2-Release/code/SystemFeature/Internationalnation/International) diff --git a/en/application-dev/napi/drawing-guidelines.md b/en/application-dev/napi/drawing-guidelines.md index 22d85aec0fe405e47cd92abeafa94ba5e7b7ed5f..c341703ff86d6d0e3c6a34e8270e934b33a15d3a 100644 --- a/en/application-dev/napi/drawing-guidelines.md +++ b/en/application-dev/napi/drawing-guidelines.md @@ -128,10 +128,7 @@ The following steps describe how to use the canvas and brush of the Native Drawi ```c++ // Obtain the pixel address after drawing. The memory to which the address points contains the pixel data of the drawing on the canvas. void* bitmapAddr = OH_Drawing_BitmapGetPixels(cBitmap); - auto ret = memcpy_s(addr, addrSize, bitmapAddr, addrSize); - if (ret != EOK) { - LOGI("memcpy_s failed"); - } + std::copy(addr, addr + addrSize, static_cast(bitmapAddr)); // Destroy the canvas object. OH_Drawing_CanvasDestroy(cCanvas); // Destroy the bitmap object. diff --git a/en/application-dev/quick-start/application-package-structure-stage.md b/en/application-dev/quick-start/application-package-structure-stage.md index 0736157fd42b4b6b6a2549e9262a7d25313aa452..2962c70242ad3bd558619fbbbbe755a86dae35c9 100644 --- a/en/application-dev/quick-start/application-package-structure-stage.md +++ b/en/application-dev/quick-start/application-package-structure-stage.md @@ -4,7 +4,7 @@ To develop an application based on the [stage model](application-configuration-file-overview-stage.md), it will be helpful if you have a basic understanding of the structure of the application package created after the application is built and packaged, as well as the related basic concepts. -- In development, an application contains one or more modules. You can [create modules](https://developer.harmonyos.com/en/docs/documentation/doc-guides-V3/ohos-adding-deleting-module-0000001218760594-V3) in the application project in [DevEco Studio](https://developer.harmonyos.com/en/develop/deveco-studio/). As a basic functional unit of an OpenHarmony application/service, a module contains source code, resource files, third-party libraries, and application/service configuration files, and can be built and run independently. Modules can be classified as Ability or Library. A module of the Ability type is built into a Harmony Ability Package (HAP) file, and a module of the Library type is built into a [Harmony Archive (HAR)](har-package.md) file or a [Harmony Shared Package (HSP)](shared-guide.md). +- In development, an application contains one or more modules. You can [create modules](https://developer.harmonyos.com/en/docs/documentation/doc-guides-V3/add_new_module-0000001053223741-V3) in the application project in [DevEco Studio](https://developer.harmonyos.com/en/develop/deveco-studio/). As a basic functional unit of an OpenHarmony application/service, a module contains source code, resource files, third-party libraries, and application/service configuration files, and can be built and run independently. Modules can be classified as Ability or Library. A module of the Ability type is built into a Harmony Ability Package (HAP) file, and a module of the Library type is built into a [Harmony Archive (HAR)](har-package.md) file or a [Harmony Shared Package (HSP)](shared-guide.md). A module can contain one or more [UIAbility](../application-models/uiability-overview.md) components, as shown in the figure below. **Figure 1** Relationship between modules and UIAbility components diff --git a/en/application-dev/quick-start/arkts-two-way-sync.md b/en/application-dev/quick-start/arkts-two-way-sync.md index 91be73c3f3ffea335784d26b34f5ab3464743294..25acb5741b55ed121950726455f9b3bfce183d29 100644 --- a/en/application-dev/quick-start/arkts-two-way-sync.md +++ b/en/application-dev/quick-start/arkts-two-way-sync.md @@ -4,21 +4,21 @@ The $$ operator provides a TS variable by-reference to a built-in component so that the variable value and the internal state of that component are kept in sync. -What the internal state is depends on the component. For example, for the [bindPopup](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md) attribute method, it is the **show** parameter. +What the internal state is depends on the component. For example, for the [bindPopup](../reference/arkui-ts/ts-universal-attributes-popup.md) attribute method, it is the **show** parameter. ## Rules of Use - $$ supports variables of simple types and variables decorated by **\@State**, **\@Link**, or **\@Prop**. -- Currently, $$ supports only the **show** parameter of the [bindPopup](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md) attribute method, the **checked** attribute of the [\](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/arkui-ts/ts-basic-components-radio.md) component, and the **refreshing** parameter of the [\](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/arkui-ts/ts-container-refresh.md) component. +- Currently, $$ supports only the **show** parameter of the [bindPopup](../reference/arkui-ts/ts-universal-attributes-popup.md) attribute method, the **checked** attribute of the [\](../reference/arkui-ts/ts-basic-components-radio.md) component, and the **refreshing** parameter of the [\](../reference/arkui-ts/ts-container-refresh.md) component. - When the variable bound to $$ changes, the UI is re-rendered synchronously. ## Example -This example uses the **show** parameter of the [bindPopup](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md) attribute method. +This example uses the **show** parameter of the [bindPopup](../reference/arkui-ts/ts-universal-attributes-popup.md) attribute method. ```ts diff --git a/en/application-dev/quick-start/figures/application_details.jpg b/en/application-dev/quick-start/figures/application_details.jpg index 02524b549eaf636e2a8a0f2ec869513d99f1a161..311f1f6b17263622d514caa6deac9905df8aa6c3 100644 Binary files a/en/application-dev/quick-start/figures/application_details.jpg and b/en/application-dev/quick-start/figures/application_details.jpg differ diff --git a/en/application-dev/quick-start/module-configuration-file.md b/en/application-dev/quick-start/module-configuration-file.md index 65907daeaa07d2ce42ff7d4bedb17e199928f1c0..017ea8d1237702b5b959069dff14b363dc1cdf53 100644 --- a/en/application-dev/quick-start/module-configuration-file.md +++ b/en/application-dev/quick-start/module-configuration-file.md @@ -71,7 +71,7 @@ As shown above, the **module.json5** file contains several tags. | Name| Description| Data Type| Initial Value Allowed| | -------- | -------- | -------- | -------- | -| name | Name of the module. The value is a string with a maximum of 31 bytes and must be unique in the entire application. Chinese characters are not allowed.| String| No| +| name | Name of the module. The value is a string with a maximum of 31 bytes and must be unique in the entire application. | String| No| | type | Type of the module. The options are as follows:
- **entry**: main module of the application.
- **feature**: dynamic feature module of the application.
- **har**: static shared module.
- **shared**: dynamic shared module.| String| No| | srcEntry | Code path corresponding to the module. The value is a string with a maximum of 127 bytes.| String| Yes (initial value: left empty)| | description | Description of the module. The value is a string with a maximum of 255 bytes or a string resource index.| String| Yes (initial value: left empty)| @@ -221,73 +221,6 @@ The **metadata** tag represents the custom metadata of the HAP file. The tag val UIAbility configuration of the module, which is valid only for the current UIAbility component. -**By default, application icons cannot be hidden from the home screen in OpenHarmony.** - -The OpenHarmony system imposes a strict rule on the presence of application icons. If no icon is configured in the HAP file of an application, the system uses the icon specified in the **app.json** file as the application icon and displays it on the home screen. - -Touching this icon will direct the user to the application details screen in **Settings**, as shown in Figure 1. - -To hide an application icon from the home screen, you must configure the **AllowAppDesktopIconHide** privilege. For details, see [Application Privilege Configuration Guide](../../device-dev/subsystems/subsys-app-privilege-config-guide.md). - -**Objectives**: - -This requirement on application icons is intended to prevent malicious applications from deliberately configuring no icon to block uninstallation attempts. - -**Setting the application icon to be displayed on the home screen**: - -Set **icon**, **label**, and **skills** under **abilities** in the **module.json5** file. In addition, make sure the **skills** configuration contains **ohos.want.action.home** and **entity.system.home**. - -``` -{ - "module":{ - - ... - - "abilities": [{ - "icon": "$media:icon", - "label": "Login", - "skills": [{ - "actions": ["ohos.want.action.home"], - "entities": ["entity.system.home"], - "uris": [] - }] - }], - ... - - } -} -``` - -**Display rules of application icons and labels on the home screen:** -* The HAP file contains UIAbility configuration. - * The application icon on the home screen is set under **abilities** in the **module.json5** file. - * The application does not have the privilege to hide its icon from the home screen. - * The application icon displayed on the home screen is the icon configured for the UIAbility. - * The application label displayed on the home screen is the label configured for the UIAbility. If no label is configured, the bundle name is returned. - * The name of the UIAbility is displayed. - * When the user touches the home screen icon, the home screen of the UIAbility is displayed. - * The application has the privilege to hide its icon from the home screen. - * The information about the application is not returned during home screen information query, and the icon of the application is not displayed on the home screen. - * The application icon on the home screen is not set under **abilities** in the **module.json5** file. - * The application does not have the privilege to hide its icon from the home screen. - * The application icon displayed on the home screen is the icon specified under **app**. (The **icon** field in the **app.json** file is mandatory.) - * The application label displayed on the home screen is the label specified under **app**. (The **label** field in the **app.json** file is mandatory.) - * Touching the application icon on the home screen will direct the user to the application details screen shown in Figure 1. - * The application has the privilege to hide its icon from the home screen. - * The information about the application is not returned during home screen information query, and the icon of the application is not displayed on the home screen. -* The HAP file does not contain UIAbility configuration. - * The application does not have the privilege to hide its icon from the home screen. - * The application icon displayed on the home screen is the icon specified under **app**. (The **icon** field in the **app.json** file is mandatory.) - * The application label displayed on the home screen is the label specified under **app**. (The **label** field in the **app.json** file is mandatory.) - * Touching the application icon on the home screen will direct the user to the application details screen shown in Figure 1. - * The application has the privilege to hide its icon from the home screen. - * The information about the application is not returned during home screen information query, and the icon of the application is not displayed on the home screen.

- -**Figure 1** Application details screen - -![Application details screen](figures/application_details.jpg) - - **Table 6** abilities | Name| Description| Data Type| Initial Value Allowed| @@ -438,7 +371,7 @@ The **extensionAbilities** tag represents the configuration of extensionAbilitie | uri | Data URI provided by the ExtensionAbility component. The value is a string with a maximum of 255 bytes, in the reverse domain name notation.
**NOTE**
This attribute is mandatory when the type of the ExtensionAbility component is set to **dataShare**.| String| Yes (initial value: left empty)| |skills | Feature set of [wants](../application-models/want-overview.md) that can be received by the ExtensionAbility component.
Configuration rule: In an entry package, you can configure multiple **skills** attributes with the entry capability. (A **skills** attribute with the entry capability is the one that has **ohos.want.action.home** and **entity.system.home** configured.) The **label** and **icon** in the first ExtensionAbility that has **skills** configured are used as the **label** and **icon** of the entire OpenHarmony service/application.
**NOTE**
The **skills** attribute with the entry capability can be configured for the feature package of an OpenHarmony application, but not for an OpenHarmony service.| Array| Yes (initial value: left empty)| | [metadata](#metadata)| Metadata of the ExtensionAbility component.| Object| Yes (initial value: left empty)| -| exported | Whether the ExtensionAbility component can be called by other applications.
- **true**: The ExtensionAbility component can be called by other applications.
- **false**: The UIAbility component cannot be called by other applications.| Boolean| Yes (initial value: **false**)| +| exported | Whether the ExtensionAbility component can be called by other applications.
- **true**: The ExtensionAbility component can be called by other applications.
- **false**: The ExtensionAbility component cannot be called by other applications.| Boolean| Yes (initial value: **false**)| Example of the **extensionAbilities** structure: @@ -591,7 +524,7 @@ The **shortcut** information is identified in **metadata**, where: ## distributionFilter -The **distributionFilter** tag defines the rules for distributing HAP files based on different device specifications, so that precise matching can be performed when the application market distributes applications. Distribution rules cover the following factors: screen shape, screen size, screen resolution, and country/region code. During distribution, a unique HAP is determined based on the mapping between **deviceType** and these five factors. This tag must be configured in the **/resource/profile resource** directory. Its sub-tags are optional. +The **distributionFilter** tag defines the rules for distributing HAP files based on different device specifications, so that precise matching can be performed when the application market distributes applications. Distribution rules cover the following factors: API version, screen shape, screen size, screen resolution, and country/region code. During distribution, a unique HAP is determined based on the mapping between **deviceType** and these five factors. This tag must be configured in the **/resource/profile resource** directory. Its sub-tags are optional. **Table 12** distributionFilter diff --git a/en/application-dev/quick-start/module-structure.md b/en/application-dev/quick-start/module-structure.md index a18a1eae33ac116e9bb829b2d30dc34e344b935f..9888faac93bbd619ac13c5f901e6219225115cf6 100644 --- a/en/application-dev/quick-start/module-structure.md +++ b/en/application-dev/quick-start/module-structure.md @@ -7,23 +7,23 @@ The **module** tag contains the HAP configuration. | Name| Description| Data Type| Initial Value Allowed| | -------- | -------- | -------- | -------- | -| mainAbility | Ability whose icon is displayed in the Service Center. When the resident process is started, the **mainAbility** is started.| String| Yes (initial value: left empty)| -| package | Package name of the HAP file, which must be unique in the application. The value is a string with a maximum of 127 bytes, in the reverse domain name notation. It is recommended that the value be the same as the project directory of the HAP file. | String| No| -| name | Class name of the HAP file. The value is a string with a maximum of 255 bytes, in the reverse domain name notation. The prefix must be the same as the **package** value specified for this module. Alternatively, the value can start with a period (.) followed by the class name.| String| Yes (initial value: left empty)| -| description | Description of the HAP file. The value is a string with a maximum of 255 bytes. If the value exceeds the limit or needs to support multiple languages, you can use a resource index to the description.| String| Yes (initial value: left empty)| -| supportedModes | Modes supported by the application. Currently, only the **drive** mode is defined. This attribute applies only to head units.| String array| Yes (initial value: left empty)| -|deviceType | Type of device on which the ability can run. The device types predefined in the system include **tablet**, **tv**, **car**, and **wearable**.| String array| No| -|distro | Distribution description of the HAP file.| Object| No| -|metaData | Metadata of the HAP file.| Object| Yes (initial value: left empty)| -| abilities | All abilities in the current module. The value is an array of objects, each of which represents an ability.| Object array| Yes (initial value: left empty)| -| js | A set of JS modules developed using ArkUI. The value is an array of objects, each of which represents a JS module.| Object array| Yes (initial value: left empty)| -| shortcuts | Shortcuts of the application. The value is an array of objects, each of which represents a shortcut object.| Object array| Yes (initial value: left empty)| -| reqPermissions | Permissions that the application requests from the system when it is running.| Object array| Yes (initial value: left empty)| -| colorMode | Color mode of the application. The options are as follows:
- **dark**: Resources applicable for the dark mode are used.
- **light**: Resources applicable for the light mode are used.
- **auto**: Resources are used based on the color mode of the system.| String| Yes (initial value: **auto**)| +| mainAbility | Ability whose icon is displayed in the Service Center. When the resident process is started, the **mainAbility** is started.| String| Yes (initial value: left empty)| +| package | Package name of the HAP file, which must be unique in the application. The value is a string with a maximum of 127 bytes, in the reverse domain name notation. It is recommended that the value be the same as the project directory of the HAP file. | String| No| +| name | Class name of the HAP file. The value is a string with a maximum of 255 bytes, in the reverse domain name notation. The prefix must be the same as the **package** value specified for this module. Alternatively, the value can start with a period (.) followed by the class name.| String| Yes (initial value: left empty)| +| description | Description of the HAP file. The value is a string with a maximum of 255 bytes. If the value exceeds the limit or needs to support multiple languages, you can use a resource index to the description.| String| Yes (initial value: left empty)| +| supportedModes | Modes supported by the application. Currently, only the **drive** mode is defined. This attribute applies only to head units.| String array| Yes (initial value: left empty)| +|deviceType | Type of device on which the ability can run. The device types predefined in the system include **tablet**, **tv**, **car**, and **wearable**.| String array| No| +|distro | Distribution description of the HAP file.| Object| No| +|metaData | Metadata of the HAP file.| Object| Yes (initial value: left empty)| +| abilities | All abilities in the current module. The value is an array of objects, each of which represents an ability.| Object array| Yes (initial value: left empty)| +| js | A set of JS modules developed using ArkUI. The value is an array of objects, each of which represents a JS module.| Object array| Yes (initial value: left empty)| +| shortcuts | Shortcuts of the application. The value is an array of objects, each of which represents a shortcut object.| Object array| Yes (initial value: left empty)| +| reqPermissions | Permissions that the application requests from the system when it is running.| Object array| Yes (initial value: left empty)| +| colorMode | Color mode of the application. The options are as follows:
- **dark**: Resources applicable for the dark mode are used.
- **light**: Resources applicable for the light mode are used.
- **auto**: Resources are used based on the color mode of the system.| String| Yes (initial value: **auto**)| | distributionFilter | Distribution rules of the application. This attribute defines the rules for distributing HAP files based on different device specifications, so that precise matching can be performed when the application market distributes applications. Distribution rules cover three factors: API version, screen shape, and screen resolution. During distribution, a unique HAP is determined based on the mapping between **deviceType** and these three factors.| Object| Yes (initial value: left empty) Set this attribute when an application has multiple entry modules.| -|commonEvents | Information about the common event static subscriber, which must contain the subscriber name, required permissions, and list of the common events subscribed to. When a subscribed event is sent, the static subscriber is started. Unlike the dynamic subscriber, the static subscriber does not need to proactively call the common event subscription API in the service code, and may not be running when the common event is published.| Object array| Yes (initial value: left empty)| -| entryTheme | Keyword of an OpenHarmony internal theme. Set it to the resource index of the name.| String| Yes (initial value: left empty)| -|testRunner | Test runner configuration.| Object| Yes (initial value: left empty)| +|commonEvents | Information about the common event static subscriber, which must contain the subscriber name, required permissions, and list of the common events subscribed to. When a subscribed event is sent, the static subscriber is started. Unlike the dynamic subscriber, the static subscriber does not need to proactively call the common event subscription API in the service code, and may not be running when the common event is published.| Object array| Yes (initial value: left empty)| +| entryTheme | Keyword of an OpenHarmony internal theme. Set it to the resource index of the name.| String| Yes (initial value: left empty)| +|testRunner | Test runner configuration.| Object| Yes (initial value: left empty)| Example of the **module** tag structure: @@ -128,7 +128,7 @@ Example of the **distro** attribute structure: | Name| Description| Data Type| Initial Value Allowed| | -------- | -------- | -------- | -------- | -| description | Description of the parameter. The value can be a string or a resource index to descriptions in multiple languages. The value can contain a maximum of 255 characters.| String| Yes (initial value: left empty)| +| description | Description of the parameter. The value can be a string or a resource index to descriptions in multiple languages. The value can contain a maximum of 255 bytes.| String| Yes (initial value: left empty)| | name | Name of the parameter passed for calling the ability. The value can contain a maximum of 255 bytes.| String| No| | type | Type of the parameter passed for calling the ability, for example, **Integer**.| String| No| @@ -138,8 +138,8 @@ Example of the **distro** attribute structure: | Name| Description| Data Type| Initial Value Allowed| | -------- | -------- | -------- | -------- | -| description | Description of the return value. The value can be a string or a resource index to descriptions in multiple languages. The value can contain a maximum of 255 characters.| String| Yes (initial value: left empty)| -| name | Name of the return value. The value can contain a maximum of 255 characters.| String| Yes (initial value: left empty)| +| description | Description of the return value. The value can be a string or a resource index to descriptions in multiple languages. The value can contain a maximum of 255 bytes.| String| Yes (initial value: left empty)| +| name | Name of the return value. The value can contain a maximum of 255 bytes.| String| Yes (initial value: left empty)| | type | Type of the return value, for example, **Integer**.| String| No| ## Internal Structure of the customizeData Attribute @@ -190,21 +190,48 @@ Example of the metadata attribute: ## Internal Structure of the abilities Attribute -**By default, application icons cannot be hidden from the home screen in OpenHarmony.** - -The OpenHarmony system imposes a strict rule on the presence of application icons. If no icon is configured in the HAP file of an application, the system creates a default icon for the application and displays it on the home screen. +**Table 8** Internal structure of the abilities attribute -Touching this icon will direct the user to the application details screen in **Settings**, as shown in Figure 1. +| Name| Description| Data Type| Initial Value Allowed| +| -------- | -------- | -------- | -------- | +| process | Name of the process running the application or ability. If the **process** attribute is configured in the **deviceConfig** tag, all abilities of the application run in this process. You can set the **process** attribute for a specific ability in the **abilities** attribute, so that the ability can run in the particular process. If this attribute is set to the name of the process running other applications, all these applications can run in the same process, provided they have the same unified user ID and the same signature. The value can contain a maximum of 31 bytes.| String| Yes (initial value: left empty)| +| name | Ability name. The value can be a reverse domain name, in the format of "*bundleName*.*className*", for example, **"com.example.myapplication.EntryAbility"**. Alternatively, the value can start with a period (.) followed by the class name, for example, **".EntryAbility"**.
The ability name must be unique in an application.
**NOTE**
If you use DevEco Studio to create the project, an ability named **EntryAbility** will be created by default, and its configuration will be saved to the **config.json** file. If you use other IDEs, the value of this attribute can be customized. The value can contain a maximum of 127 bytes. | String| No| +| description | Description of the ability. The value can be a string or a resource index to descriptions in multiple languages. The value can contain a maximum of 255 bytes.| String| Yes (initial value: left empty)| +| icon | Index to the ability icon file. Example value: **$media:ability_icon**. In the **skills** attribute of the ability, if the **actions** value contains **action.system.home** and the **entities** value contains **entity.system.home**, the icon of the ability is also used as the icon of the application. If multiple abilities address this condition, the icon of the first candidate ability is used as the application icon.
**NOTE**
The **icon** and **label** values of an application are visible to users. Ensure that at least one of them is different from any existing icons or labels. | String| Yes (initial value: left empty)| +| label | Ability name displayed to users. The value can be a name string or a resource index to names in multiple languages, for example, **$string:ability_label**. In the **skills** attribute of the ability, if the **actions** value contains **action.system.home** and the **entities** value contains **entity.system.home**, the label of the ability is also used as the label of the application. If multiple abilities address this condition, the label of the first candidate ability is used as the application label.
**NOTE**
The **icon** and **label** values of an application are visible to users. Ensure that at least one of them is different from any existing icons or labels. The value can be a reference to a string defined in a resource file or a string enclosed in brackets ({}). The value can contain a maximum of 255 bytes. | String| Yes (initial value: left empty)| +| uri | Uniform Resource Identifier (URI) of the ability. The value can contain a maximum of 255 bytes.| String| Yes (No for abilities using the Data template)| +| launchType | Launch type of the ability. The value can be **standard** or **singleton**.
**standard**: Multiple **Ability** instances can be created during startup. Most abilities can use this type.
**singleton**: Only a single **Ability** instance can be created across all task stacks during startup. For example, a globally unique incoming call screen uses the singleton launch type. This attribute applies only to the default, tablet, smart TV, head unit, and wearable device types.| String| Yes (initial value: **"singleton"**)| +| visible | Whether the ability can be called by other applications.
**true**: The ability can be called by other applications.
**false**: The ability cannot be called by other applications.| Boolean| Yes (initial value: **false**)| +| permissions | Permissions required for abilities of another application to call the current ability. The value is an array of permission names predefined by the system, generally in the reverse domain name notation. It contains a maximum of 255 bytes.| String array| Yes (initial value: left empty)| +|skills | Types of the **want** that can be accepted by the ability.| Object array| Yes (initial value: left empty)| +| deviceCapability | Device capabilities required to run the ability. The value is an array of up to 512 elements, each of which contains a maximum of 64 bytes.| String array| Yes (initial value: left empty)| +| metaData | Metadata.| Object| Yes (initial value: left empty)| +| type | Ability type. The options are as follows:
**page**: FA developed using the Page template to provide the capability of interacting with users.
**service**: PA developed using the Service template to provide the capability of running tasks in the background.
**data**: PA developed using the Data template to provide unified data access for external systems.
**CA**: ability that can be started by other applications as a window.| String| No| +| orientation | Display orientations of the ability. This attribute applies only to the ability using the Page template. The options are as follows:
**unspecified**: indicates that the system automatically determines the display orientation of the ability.
**landscape**: indicates the landscape orientation.
**portrait**: indicates the portrait orientation.
**followRecent**: indicates that the orientation follows the most recent application in the stack.| String| Yes (initial value: **"unspecified"**)| +| backgroundModes | Background service type of the ability. You can assign multiple background service types to a specific ability. This field applies only to the ability using the Service template. The options are as follows:
**dataTransfer**: service for downloading, backing up, sharing, or transferring data from the network or peer devices.
**audioPlayback**: audio playback service.
**audioRecording**: audio recording service.
**pictureInPicture**: picture in picture (PiP) and small-window video playback services.
**voip**: voice/video call and VoIP services.
**location**: location and navigation services.
**bluetoothInteraction**: Bluetooth scanning, connection, and transmission services.
**wifiInteraction**: WLAN scanning, connection, and transmission services.
**screenFetch**: screen recording and screenshot services.
**multiDeviceConnection**: multi-device interconnection service.| String array| Yes (initial value: left empty)| +| grantPermission | Whether permissions can be granted for any data in the ability.| Boolean| Yes (initial value: left empty)| +| readPermission | Permission required for reading data in the ability. This attribute applies only to the ability using the Data template. The value is a string with a maximum of 255 bytes. This attribute applies only to the default, tablet, smart TV, head unit, and wearable device types.| String| Yes (initial value: left empty)| +| writePermission | Permission required for writing data to the ability. This attribute applies only to the ability using the Data template. The value is a string with a maximum of 255 bytes.| String| Yes (initial value: left empty)| +| configChanges | System configurations that the ability concerns. Upon any changes on the concerned configurations, the **onConfigurationUpdated** callback will be invoked to notify the ability. The options are as follows:
**mcc**: indicates that the mobile country code (MCC) of the IMSI is changed. Typical scenario: A SIM card is detected, and the MCC is updated.
**mnc**: indicates that the mobile network code (MNC) of the IMSI is changed. Typical scenario: A SIM card is detected, and the MNC is updated.
**locale**: indicates that the locale is changed. Typical scenario: The user selects a new language for the text display of the device.
**layout**: indicates that the screen layout is changed. Typical scenario: Currently, different display forms are all in the active state.
**fontSize**: indicates that font size is changed. Typical scenario: A new global font size is set.
**orientation**: indicates that the screen orientation is changed. Typical scenario: The user rotates the device.
**density**: indicates that the display density is changed. Typical scenario: The user may specify different display ratios, or different display forms are active at the same time.
**size**: indicates that the size of the display window is changed.
**smallestSize**: indicates that the length of the shorter side of the display window is changed.
**colorMode**: indicates that the color mode is changed.| String array| Yes (initial value: left empty)| +| mission | Task stack of the ability. This attribute applies only to the ability using the Page template. By default, all abilities in an application belong to the same task stack.| String| Yes (initial value: bundle name of the application)| +| targetAbility | Target ability that this ability alias points to. This attribute applies only to the ability using the Page template. If the **targetAbility** attribute is set, only **name**, **icon**, **label**, **visible**, **permissions**, and **skills** take effect in the current ability (ability alias). Other attributes use the values of the **targetAbility** attribute. The target ability must belong to the same application as the alias and must be declared in **config.json** ahead of the alias.| String| Yes (initial value: left empty, indicating that the current ability is not an alias)| +| formsEnabled | Whether the ability can provide widgets. This attribute applies only to the ability using the Page template.
**true**: This ability can provide widgets.
**false**: This ability cannot provide widgets.| Boolean| Yes (initial value: **false**)| +| forms | Information about the widgets used by the ability. This attribute is valid only when **formsEnabled** is set to **true**.| Object array| Yes (initial value: left empty)| +| srcLanguage | Programming language of the ability, which you can specify when creating the project.| String| Yes (initial value: **"js"**)| +| srcPath | JS code path corresponding to the ability. The value can contain a maximum of 127 bytes.| String| No| +| uriPermission | Application data that the ability can access. This attribute consists of the **mode** and **path** sub-attributes. This attribute is valid only for the capability of the type provider.| Object| Yes (initial value: left empty)| +| startWindowIcon | Index to the icon file of the ability startup page. This attribute applies only to the ability using the Page template. Example: **$media:icon**.| String| Yes (initial value: left empty)| +| startWindowBackground | Index to the background color resource file of the ability startup page. This attribute applies only to the ability using the Page template. Example: **$color:red**.| String| Yes (initial value: left empty)| +| removeMissionAfterTerminate | Whether to remove the relevant task from the task list after the ability is destroyed. This attribute applies only to the ability using the Page template. The value **true** means to remove the relevant task from the task list after the ability is destroyed, and **false** means the opposite.| Boolean| Yes (initial value: **false**)| -To hide an application icon from the home screen, you must configure the **AllowAppDesktopIconHide** privilege. For details, see [Application Privilege Configuration Guide](../../device-dev/subsystems/subsys-app-privilege-config-guide.md). -**Objectives**: +**By default, application icons cannot be hidden from the home screen in OpenHarmony.** -This requirement on application icons is intended to prevent malicious applications from deliberately configuring no icon to block uninstallation attempts. +OpenHarmony strictly controls applications without icons to prevent malicious applications from deliberately configuring no icon to block uninstall attempts. **Setting the application icon to be displayed on the home screen**: -Set **icon**, **label**, and **skills** under **abilities** in the **config.json** file. In addition, make sure the **skills** configuration contains **ohos.want.action.home** and **entity.system.home**. +Set **icon**, **label**, and **skills** under **abilities** in the **config.json** file. Make sure the **skills** configuration contains **ohos.want.action.home** and **entity.system.home**. ``` { @@ -228,71 +255,34 @@ Set **icon**, **label**, and **skills** under **abilities** in the **config.json } ``` -**Display rules of application icons and labels on the home screen:** +To hide an application icon from the home screen, you must configure the **AllowAppDesktopIconHide** privilege. For details, see [Application Privilege Configuration Guide](../../device-dev/subsystems/subsys-app-privilege-config-guide.md). The rules for displaying the entry icon and entry label are as follows: * The HAP file contains Page ability configuration. * The application icon on the home screen is set under **abilities** in the **config.json** file. * The application does not have the privilege to hide its icon from the home screen. - * The application icon displayed on the home screen is the icon configured for the Page ability. - * The application label displayed on the home screen is the label configured for the Page ability. If no label is configured, the bundle name is returned. - * The name of the Page ability is displayed. - * When the user touches the home screen icon, the home screen of the Page ability is displayed. + * The system uses the icon configured for the Page ability as the entry icon and displays it on the home screen. Touching this icon will direct the user to the home page of the Page ability. + * The system uses the label configured for the PageAbility as the entry label and displays it on the home screen. If no label is configured, the bundle name is returned. * The application has the privilege to hide its icon from the home screen. - * The information about the application is not returned during home screen information query, and the icon of the application is not displayed on the home screen. + * The application information is not returned when the home screen queries the information, and the entry icon and label of the application are not displayed on the home screen. * The application icon on the home screen is not set under **abilities** in the **config.json** file. * The application does not have the privilege to hide its icon from the home screen. - * The application icon displayed on the home screen is the default icon. - * The application label displayed on the home screen is the bundle name of the application. - * Touching the application icon on the home screen will direct the user to the application details screen shown in Figure 1. + * The system uses the default icon as the entry icon and displays it on the home screen. Touching this icon will direct the user to the application details screen under application management, as shown in Figure 1. + * The system uses the bundle name of the application as the entry label and displays it on the home screen. * The application has the privilege to hide its icon from the home screen. - * The information about the application is not returned during home screen information query, and the icon of the application is not displayed on the home screen. + * The application information is not returned when the home screen queries the information, and the entry icon and label of the application are not displayed on the home screen. * The HAP file does not contain Page ability configuration. * The application does not have the privilege to hide its icon from the home screen. - * The application icon displayed on the home screen is the default icon. - * The application label displayed on the home screen is the bundle name of the application. - * Touching the application icon on the home screen will direct the user to the application details screen shown in Figure 1. + * The system uses the default icon as the entry icon and displays it on the home screen. Touching this icon will direct the user to the application details screen under application management, as shown in Figure 1. + * The system uses the bundle name of the application as the entry label and displays it on the home screen. * The application has the privilege to hide its icon from the home screen. - * The information about the application is not returned during home screen information query, and the icon of the application is not displayed on the home screen. - -Note: The label displayed on the application details screen may be different from that displayed on the home screen. For non-Page abilities, it is the entry label set (if any).

+ * The application information is not returned when the home screen queries the information, and the entry icon and label of the application are not displayed on the home screen. **Figure 1** Application details screen ![Application details screen](figures/application_details.jpg) - -**Table 8** Internal structure of the abilities attribute - -| Name| Description| Data Type| Initial Value Allowed| -| -------- | -------- | -------- | -------- | -| process | Name of the process running the application or ability. If the **process** attribute is configured in the **deviceConfig** tag, all abilities of the application run in this process. You can set the **process** attribute for a specific ability in the **abilities** attribute, so that the ability can run in the particular process. If this attribute is set to the name of the process running other applications, all these applications can run in the same process, provided they have the same unified user ID and the same signature. The value can contain a maximum of 31 bytes.| String| Yes (initial value: left empty)| -| name | Ability name. The value can be a reverse domain name, in the format of "*bundleName*.*className*", for example, **"com.example.myapplication.EntryAbility"**. Alternatively, the value can start with a period (.) followed by the class name, for example, **".EntryAbility"**.
The ability name must be unique in an application. Note: If you use DevEco Studio to create the project, an ability named **EntryAbility** will be created by default, and its configuration will be saved to the **config.json** file. If you use other IDEs, the value of this attribute can be customized. The value can contain a maximum of 127 bytes.| String| No| -| description | Description of the ability. The value can be a string or a resource index to descriptions in multiple languages. The value can contain a maximum of 255 bytes.| String| Yes (initial value: left empty)| -| icon | Index to the ability icon file. Example value: **$media:ability_icon**. In the **skills** attribute of the ability, if the **actions** value contains **action.system.home** and the **entities** value contains **entity.system.home**, the icon of the ability is also used as the icon of the application. If multiple abilities address this condition, the icon of the first candidate ability is used as the application icon.
Note: The **icon** and **label** values of an application are visible to users. Ensure that at least one of them is different from any existing icons or labels.| String| Yes (initial value: left empty)| -| label | Ability name displayed to users. The value can be a name string or a resource index to names in multiple languages, for example, **$string:ability_label**. In the **skills** attribute of the ability, if the **actions** value contains **action.system.home** and the **entities** value contains **entity.system.home**, the label of the ability is also used as the label of the application. If multiple abilities address this condition, the label of the first candidate ability is used as the application label.
Note: The **icon** and **label** values of an application are visible to users. Ensure that at least one of them is different from any existing icons or labels. The value can be a reference to a string defined in a resource file or a string enclosed in brackets ({}). The value can contain a maximum of 255 characters.| String| Yes (initial value: left empty)| -| uri | Uniform Resource Identifier (URI) of the ability. The value can contain a maximum of 255 bytes.| String| Yes (No for abilities using the Data template)| -| launchType | Launch type of the ability. The value can be **standard** or **singleton**.
**standard**: Multiple **Ability** instances can be created during startup. Most abilities can use this type.
**singleton**: Only a single **Ability** instance can be created across all task stacks during startup. For example, a globally unique incoming call screen uses the singleton launch type. This attribute applies only to the default, tablet, smart TV, head unit, and wearable device types.| String| Yes (initial value: **"singleton"**)| -| visible | Whether the ability can be called by other applications.
**true**: The ability can be called by other applications.
**false**: The ability cannot be called by other applications.| Boolean| Yes (initial value: **false**)| -| permissions | Permissions required for abilities of another application to call the current ability. The value is an array of permission names predefined by the system, generally in the reverse domain name notation. It contains a maximum of 255 bytes.| String array| Yes (initial value: left empty)| -|skills | Types of the **want** that can be accepted by the ability.| Object array| Yes (initial value: left empty)| -| deviceCapability | Device capabilities required to run the ability. The value is an array of up to 512 elements, each of which contains a maximum of 64 bytes.| String array| Yes (initial value: left empty)| -| metaData | Metadata.| Object| Yes (initial value: left empty)| -| type | Ability type. The options are as follows:
**page**: FA developed using the Page template to provide the capability of interacting with users.
**service**: PA developed using the Service template to provide the capability of running tasks in the background.
**data**: PA developed using the Data template to provide unified data access for external systems.
**CA**: ability that can be started by other applications as a window.| String| No| -| orientation | Display orientations of the ability. This attribute applies only to the ability using the Page template. The options are as follows:
**unspecified**: indicates that the system automatically determines the display orientation of the ability.
**landscape**: indicates the landscape orientation.
**portrait**: indicates the portrait orientation.
**followRecent**: indicates that the orientation follows the most recent application in the stack.| String| Yes (initial value: **"unspecified"**)| -| backgroundModes | Background service type of the ability. You can assign multiple background service types to a specific ability. This field applies only to the ability using the Service template. The options are as follows:
**dataTransfer**: service for downloading, backing up, sharing, or transferring data from the network or peer devices.
**audioPlayback**: audio playback service.
**audioRecording**: audio recording service.
**pictureInPicture**: picture in picture (PiP) and small-window video playback services.
**voip**: voice/video call and VoIP services.
**location**: location and navigation services.
**bluetoothInteraction**: Bluetooth scanning, connection, and transmission services.
**wifiInteraction**: WLAN scanning, connection, and transmission services.
**screenFetch**: screen recording and screenshot services.
**multiDeviceConnection**: multi-device interconnection service.| String array| Yes (initial value: left empty)| -| grantPermission | Whether permissions can be granted for any data in the ability.| Boolean| Yes (initial value: left empty)| -| readPermission | Permission required for reading data in the ability. This attribute applies only to the ability using the Data template. The value is a string with a maximum of 255 bytes. This attribute applies only to the default, tablet, smart TV, head unit, and wearable device types.| String| Yes (initial value: left empty)| -| writePermission | Permission required for writing data to the ability. This attribute applies only to the ability using the Data template. The value is a string with a maximum of 255 bytes.| String| Yes (initial value: left empty)| -| configChanges | System configurations that the ability concerns. Upon any changes on the concerned configurations, the **onConfigurationUpdated** callback will be invoked to notify the ability. The options are as follows:
**mcc**: indicates that the mobile country code (MCC) of the IMSI is changed. Typical scenario: A SIM card is detected, and the MCC is updated.
**mnc**: indicates that the mobile network code (MNC) of the IMSI is changed. Typical scenario: A SIM card is detected, and the MNC is updated.
**locale**: indicates that the locale is changed. Typical scenario: The user selects a new language for the text display of the device.
**layout**: indicates that the screen layout is changed. Typical scenario: Currently, different display forms are all in the active state.
**fontSize**: indicates that font size is changed. Typical scenario: A new global font size is set.
**orientation**: indicates that the screen orientation is changed. Typical scenario: The user rotates the device.
**density**: indicates that the display density is changed. Typical scenario: The user may specify different display ratios, or different display forms are active at the same time.
**size**: indicates that the size of the display window is changed.
**smallestSize**: indicates that the length of the shorter side of the display window is changed.
**colorMode**: indicates that the color mode is changed.| String array| Yes (initial value: left empty)| -| mission | Task stack of the ability. This attribute applies only to the ability using the Page template. By default, all abilities in an application belong to the same task stack.| String| Yes (initial value: bundle name of the application)| -| targetAbility | Target ability that this ability alias points to. This attribute applies only to the ability using the Page template. If the **targetAbility** attribute is set, only **name**, **icon**, **label**, **visible**, **permissions**, and **skills** take effect in the current ability (ability alias). Other attributes use the values of the **targetAbility** attribute. The target ability must belong to the same application as the alias and must be declared in **config.json** ahead of the alias.| String| Yes (initial value: left empty, indicating that the current ability is not an alias)| -| formsEnabled | Whether the ability can provide widgets. This attribute applies only to the ability using the Page template.
**true**: This ability can provide widgets.
**false**: This ability cannot provide widgets.| Boolean| Yes (initial value: **false**)| -| forms | Information about the widgets used by the ability. This attribute is valid only when **formsEnabled** is set to **true**.| Object array| Yes (initial value: left empty)| -| srcLanguage | Programming language of the ability, which you can specify when creating the project.| String| Yes (initial value: **"js"**)| -| srcPath | JS code path corresponding to the ability. The value can contain a maximum of 127 bytes.| String| No| -| uriPermission | Application data that the ability can access. This attribute consists of the **mode** and **path** sub-attributes. This attribute is valid only for the capability of the type provider.| Object| Yes (initial value: left empty)| -| startWindowIcon | Index to the icon file of the ability startup page. This attribute applies only to the ability using the Page template. Example: **$media:icon**.| String| Yes (initial value: left empty)| -| startWindowBackground | Index to the background color resource file of the ability startup page. This attribute applies only to the ability using the Page template. Example: **$color:red**.| String| Yes (initial value: left empty)| -| removeMissionAfterTerminate | Whether to remove the relevant task from the task list after the ability is destroyed. This attribute applies only to the ability using the Page template. The value **true** means to remove the relevant task from the task list after the ability is destroyed, and **false** means the opposite.| Boolean| Yes (initial value: **false**)| +> **NOTE** +> +> The label displayed on the application details screen may be different from the one displayed on the home screen. These two are the same if the entry icon and label are configured for the non-Page ability. ## Internal Structure of the uriPermission Attribute diff --git a/en/application-dev/quick-start/multi-hap-release-deployment.md b/en/application-dev/quick-start/multi-hap-release-deployment.md index b4587f2c2125c526b86bfa0646af4b1fcbc9e9d3..4d3d1167e7765e25f3e07942a0ce703e7e2b2355 100644 --- a/en/application-dev/quick-start/multi-hap-release-deployment.md +++ b/en/application-dev/quick-start/multi-hap-release-deployment.md @@ -9,7 +9,9 @@ Below is the process of developing, debugging, releasing, and deploying multiple You can use [DevEco Studio](https://developer.harmonyos.com/en/develop/deveco-studio) to create multiple modules as needed and develop services in respective modules. ## Debugging -After building code into one or more HAP files and installing or updating these HAP files, you can debug them by using the methods: +After building code into one or more HAP files and installing or updating these HAP files, you can debug them. You can leverage a single set of code and files to build multiple target editions for different audiences, deployment environments, operating environments, and more. For details, see [Customizing Multi-Target and Multi-Product Builds](https://developer.harmonyos.com/cn/docs/documentation/doc-guides-V3/customized-multi-targets-and-products-0000001430013853-V3?catalogVersion=V3). + +You can debug HAP files using the methods: * Using DevEco Studio for debugging Follow the instructions in [Debugging Configuration](https://developer.harmonyos.com/en/docs/documentation/doc-guides/ohos-debugging-and-running-0000001263040487#section10491183521520). @@ -49,7 +51,7 @@ After building code into one or more HAP files and installing or updating these // The execution result is as follows: uninstall bundle successfully. ``` - After the HAP files are installed or updated, you can debug them by following the instructions in [Ability Assistant](https://docs.openharmony.cn/pages/v3.2Beta/en/application-dev/tools/aa-tool.md/). + After the HAP files are installed or updated, you can debug them by following the instructions in [Ability Assistant](../tools/aa-tool.md). ## Release When your application package meets the release requirements, you can package and build it into an App Pack and release it to the application market on the cloud. The application market verifies the signature of the App Pack. If the signature verification is successful, the application market obtains the HAP files from the App Pack, signs them, and distributes the signed HAP files. diff --git a/en/application-dev/quick-start/shared-guide.md b/en/application-dev/quick-start/shared-guide.md index 2a7ed0b4b5fafa4e1afcebca5c6799239b6f814c..1cac8ec4910a7b9d7aa76c5717cee2c8dc260bbb 100644 --- a/en/application-dev/quick-start/shared-guide.md +++ b/en/application-dev/quick-start/shared-guide.md @@ -1,6 +1,6 @@ # Shared Package Overview -OpenHarmony provides two types of shared packages: [Harmony Achive (HAR)](har-package.md) static shared package and Harmony Shared Package (HSP) dynamic shared package. +OpenHarmony provides two types of shared packages: [Harmony Archive (HAR)](har-package.md) static shared package and Harmony Shared Package (HSP) dynamic shared package. Both the HAR and HSP are used to share code and resources and can contain code, C++ libraries, resources, and configuration files. The biggest differences between them are as follows: The code and resources in the HAR are compiled with the invoking module, and if there are multiple invoking modules, the build product contains multiple copies of the same code and resources; the code and resources in the HSP can be compiled independently, and the build product contains only one copy of the code and resources. diff --git a/en/application-dev/quick-start/start-with-ets-stage.md b/en/application-dev/quick-start/start-with-ets-stage.md index 978ffd47a206abc5f5b3e047a8d7f3dcc0e599e9..fb8593d555aec31c44e7a6658f6a68f2ab99dccb 100644 --- a/en/application-dev/quick-start/start-with-ets-stage.md +++ b/en/application-dev/quick-start/start-with-ets-stage.md @@ -37,14 +37,14 @@ - **AppScope** > **app.json5**: global configuration of your application. - **entry**: OpenHarmony project module, which can be built into an OpenHarmony Ability Package ([HAP](../../glossary.md#hap)). -- **oh_modules**: third-party library dependency information. For details about how to adapt a historical npm project to ohpm, see [Manually Migrating Historical Projects](https://developer.harmonyos.com/cn/docs/documentation/doc-guides-V3/project_overview-0000001053822398-V3#section108143331212). - **src > main > ets**: a collection of ArkTS source code. - **src > main > ets > entryability**: entry to your application/service. - **src > main > ets > pages**: pages included in your application/service. - **src > main > resources**: a collection of resource files used by your application/service, such as graphics, multimedia, character strings, and layout files. For details about resource files, see [Resource Categories and Access](resource-categories-and-access.md#resource-categories). - **src > main > module.json5**: module configuration file. This file describes the global configuration information of the application/service, the device-specific configuration information, and the configuration information of the HAP file. For details, see [module.json5 Configuration File](module-configuration-file.md). - **build-profile.json5**: current module information and build configuration options, including **buildOption** and **targets**. Under **targets**, you can set **runtimeOS** to **HarmonyOS** (default) or **OpenHarmony**, depending on the OS of your application. -- **hvigorfile.ts**: module-level build script. You can customize related tasks and code implementation. + - **hvigorfile.ts**: module-level build script. You can customize related tasks and code implementation. +- **oh_modules**: third-party library dependency information. For details about how to adapt a historical npm project to ohpm, see [Manually Migrating Historical Projects](https://developer.harmonyos.com/cn/docs/documentation/doc-guides-V3/project_overview-0000001053822398-V3#section108143331212). - **build-profile.json5**: application-level configuration information, including the signature and product configuration. - **hvigorfile.ts**: application-level build script. diff --git a/en/application-dev/reference/apis/Readme-EN.md b/en/application-dev/reference/apis/Readme-EN.md index 08402ed7456c35fd4f1c47d74f0ddb381822a638..057c1f8b9b5d8b6a8033c52e4e83044c33a2c20c 100644 --- a/en/application-dev/reference/apis/Readme-EN.md +++ b/en/application-dev/reference/apis/Readme-EN.md @@ -301,7 +301,7 @@ - [@ohos.systemTimer (System Timer)](js-apis-system-timer.md) - [@ohos.wallpaper (Wallpaper)](js-apis-wallpaper.md) - [@ohos.web.webview (Webview)](js-apis-webview.md) - - [console (Log)](js-apis-logs.md) + - [Console](js-apis-logs.md) - [Timer](js-apis-timer.md) - application - [AccessibilityExtensionContext (Accessibility Extension Context)](js-apis-inner-application-accessibilityExtensionContext.md) diff --git a/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md b/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md index 52750e0743704b2cfd897e3b4fa4d8560ae30080..af859fbd34391edbca7779d79aafa23b9029cc7c 100644 --- a/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md +++ b/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md @@ -461,7 +461,7 @@ For details about the error codes, see [Application Access Control Error Codes]( **Example** ```js -import abilityAccessCtrl, {Permissions} from '@ohos.abilityAccessCtrl'; +import {Permissions} from '@ohos.abilityAccessCtrl'; import bundleManager from '@ohos.bundle.bundleManager'; let atManager = abilityAccessCtrl.createAtManager(); @@ -512,7 +512,7 @@ For details about the error codes, see [Application Access Control Error Codes]( **Example** ```js -import abilityAccessCtrl, {Permissions} from '@ohos.abilityAccessCtrl'; +import {Permissions} from '@ohos.abilityAccessCtrl'; import bundleManager from '@ohos.bundle.bundleManager'; let atManager = abilityAccessCtrl.createAtManager(); diff --git a/en/application-dev/reference/apis/js-apis-bluetoothManager.md b/en/application-dev/reference/apis/js-apis-bluetoothManager.md index 761cc2d9949952e3797d71271e97190ec4f71854..ac6105538d4ec026924963c5ba54ca2fd430e5e4 100644 --- a/en/application-dev/reference/apis/js-apis-bluetoothManager.md +++ b/en/application-dev/reference/apis/js-apis-bluetoothManager.md @@ -893,7 +893,7 @@ try { on(type: "stateChange", callback: Callback<BluetoothState>): void -Subscribes to the Bluetooth connection state change events. +Subscribes to Bluetooth state events. **Required permissions**: ohos.permission.USE_BLUETOOTH @@ -932,7 +932,7 @@ try { off(type: "stateChange", callback?: Callback<BluetoothState>): void -Unsubscribes from the Bluetooth connection state change events. +Unsubscribes from Bluetooth state events. **Required permissions**: ohos.permission.USE_BLUETOOTH @@ -1994,7 +1994,7 @@ Subscribes to the HFP connection state change events. | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | string | Yes | Event type. The value **connectionStateChange** indicates an HFP connection state change event. | +| type | string | Yes | Event type. The value **connectionStateChange** indicates an HFP connection state change event.| | callback | Callback<[StateChangeParam](#StateChangeParam)> | Yes | Callback invoked to return the HFP connection state change event. | **Example** @@ -2075,7 +2075,7 @@ For details about the error codes, see [Bluetooth Error Codes](../errorcodes/err ```js try { - let hidHostProfile = bluetoothManager.getProfileInst(bluetoothManager.ProfileId.PROFILE_HID_HOST) as bluetoothManager.HidHostProfile; + let hidHostProfile = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_HID_HOST) as bluetoothManager.HidHostProfile; hidHostProfile.connect('XX:XX:XX:XX:XX:XX'); } catch (err) { console.error("errCode:" + err.code + ",errMessage:" + err.message); @@ -2116,7 +2116,7 @@ For details about the error codes, see [Bluetooth Error Codes](../errorcodes/err ```js try { - let hidHostProfile = bluetoothManager.getProfileInst(bluetoothManager.ProfileId.PROFILE_HID_HOST) as bluetoothManager.HidHostProfile; + let hidHostProfile = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_HID_HOST) as bluetoothManager.HidHostProfile; hidHostProfile.disconnect('XX:XX:XX:XX:XX:XX'); } catch (err) { console.error("errCode:" + err.code + ",errMessage:" + err.message); @@ -2145,7 +2145,7 @@ Subscribes to the HidHost connection state change events. function onReceiveEvent(data) { console.info('hidHost state = '+ JSON.stringify(data)); } -let hidHost = bluetoothManager.getProfileInst(bluetoothManager.ProfileId.PROFILE_HID_HOST) as bluetoothManager.HidHostProfile; +let hidHost = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_HID_HOST) as bluetoothManager.HidHostProfile; hidHost.on('connectionStateChange', onReceiveEvent); ``` @@ -2171,7 +2171,7 @@ Unsubscribes from the HidHost connection state change events. function onReceiveEvent(data) { console.info('hidHost state = '+ JSON.stringify(data)); } -let hidHost = bluetoothManager.getProfileInst(bluetoothManager.ProfileId.PROFILE_HID_HOST) as bluetoothManager.HidHostProfile; +let hidHost = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_HID_HOST) as bluetoothManager.HidHostProfile; hidHost.on('connectionStateChange', onReceiveEvent); hidHost.off('connectionStateChange', onReceiveEvent); ``` @@ -2215,7 +2215,7 @@ For details about the error codes, see [Bluetooth Error Codes](../errorcodes/err ```js try { - let panProfile = bluetoothManager.getProfileInst(bluetoothManager.ProfileId.PROFILE_PAN_NETWORK) as bluetoothManager.PanProfile; + let panProfile = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_PAN_NETWORK) as bluetoothManager.PanProfile; panProfile.disconnect('XX:XX:XX:XX:XX:XX'); } catch (err) { console.error("errCode:" + err.code + ",errMessage:" + err.message); @@ -2244,7 +2244,7 @@ Subscribes to the PAN connection state change events. function onReceiveEvent(data) { console.info('pan state = '+ JSON.stringify(data)); } -let panProfile = bluetoothManager.getProfileInst(bluetoothManager.ProfileId.PROFILE_PAN_NETWORK) as bluetoothManager.PanProfile; +let panProfile = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_PAN_NETWORK) as bluetoothManager.PanProfile; panProfile.on('connectionStateChange', onReceiveEvent); ``` @@ -2270,7 +2270,7 @@ Unsubscribes from the PAN connection state change events. function onReceiveEvent(data) { console.info('pan state = '+ JSON.stringify(data)); } -let panProfile = bluetoothManager.getProfileInst(bluetoothManager.ProfileId.PROFILE_PAN_NETWORK) as bluetoothManager.PanProfile; +let panProfile = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_PAN_NETWORK) as bluetoothManager.PanProfile; panProfile.on('connectionStateChange', onReceiveEvent); panProfile.off('connectionStateChange', onReceiveEvent); ``` @@ -2309,7 +2309,7 @@ For details about the error codes, see [Bluetooth Error Codes](../errorcodes/err ```js try { - let panProfile = bluetoothManager.getProfileInst(bluetoothManager.ProfileId.PROFILE_PAN_NETWORK) as bluetoothManager.PanProfile; + let panProfile = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_PAN_NETWORK) as bluetoothManager.PanProfile; panProfile.setTethering(true); } catch (err) { console.error("errCode:" + err.code + ",errMessage:" + err.message); @@ -2337,7 +2337,7 @@ Obtains the network sharing status. ```js try { - let panProfile = bluetoothManager.getProfileInst(bluetoothManager.ProfileId.PROFILE_PAN_NETWORK) as bluetoothManager.PanProfile; + let panProfile = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_PAN_NETWORK) as bluetoothManager.PanProfile; let ret = panProfile.isTetheringOn(); } catch (err) { console.error("errCode:" + err.code + ",errMessage:" + err.message); diff --git a/en/application-dev/reference/apis/js-apis-bundleManager-applicationInfo.md b/en/application-dev/reference/apis/js-apis-bundleManager-applicationInfo.md index 3447ba9b6dacd6a5606902caa24269931ff0d09e..f087d6292802e7a1e8f253be041e99081c36bab8 100644 --- a/en/application-dev/reference/apis/js-apis-bundleManager-applicationInfo.md +++ b/en/application-dev/reference/apis/js-apis-bundleManager-applicationInfo.md @@ -26,9 +26,9 @@ The **ApplicationInfo** module defines the application information. A system app | removable | boolean | Yes | No | Whether the application is removable. | | accessTokenId | number | Yes | No | Access token ID of the application. | | uid | number | Yes | No | UID of the application. | -| iconResource | [Resource](js-apis-resource-manager.md#resource9) | Yes| No| Resource information of the application icon. The resource information obtained contains the bundle name, module name, and ID of the resource. You can call **getMediaContent** in [@ohos.resourceManager.d.ts](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.resourceManager.d.ts) to obtain the resource details. | -| labelResource | [Resource](js-apis-resource-manager.md#resource9) | Yes| No| Resource information of the application label. The resource information obtained contains the bundle name, module name, and ID of the resource. You can call **getMediaContent** in [@ohos.resourceManager.d.ts](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.resourceManager.d.ts) to obtain the resource details. | -| descriptionResource | [Resource](js-apis-resource-manager.md#resource9) | Yes| No| Resource information of the application description. The resource information obtained contains the bundle name, module name, and ID of the resource. You can call **getMediaContent** in [@ohos.resourceManager.d.ts](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.resourceManager.d.ts) to obtain the resource details.| +| iconResource | [Resource](js-apis-resource-manager.md#resource9) | Yes| No| Resource information of the application icon. The resource information obtained contains the bundle name, module name, and ID of the resource. You can call **getMediaContent** in [@ohos.resourceManager.d.ts](js-apis-resource-manager.md#getmediacontent9) to obtain the resource details. | +| labelResource | [Resource](js-apis-resource-manager.md#resource9) | Yes| No| Resource information of the application label. The resource information obtained contains the bundle name, module name, and ID of the resource. You can call **getMediaContent** in [@ohos.resourceManager.d.ts](js-apis-resource-manager.md#getmediacontent9) to obtain the resource details. | +| descriptionResource | [Resource](js-apis-resource-manager.md#resource9) | Yes| No| Resource information of the application description. The resource information obtained contains the bundle name, module name, and ID of the resource. You can call **getMediaContent** in [@ohos.resourceManager.d.ts](js-apis-resource-manager.md#getmediacontent9) to obtain the resource details.| | appDistributionType | string | Yes | No | Distribution type of the application signing certificate. The options are **app_gallery**, **enterprise**, **os_integration**, and **crowdtesting**. | | appProvisionType | string | Yes | No | Type of the application signing certificate file. The options are **debug** and **release**. | | systemApp | boolean | Yes | No | Whether the application is a system application. | diff --git a/en/application-dev/reference/apis/js-apis-call.md b/en/application-dev/reference/apis/js-apis-call.md index 3e25735a64c0d71c6bf07fa4f21eeee901afb2f6..5ebf816e58265d6ea40df37d32481fd4e992b036 100644 --- a/en/application-dev/reference/apis/js-apis-call.md +++ b/en/application-dev/reference/apis/js-apis-call.md @@ -35,7 +35,7 @@ Initiates a call. This API uses an asynchronous callback to return the result. **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -76,7 +76,7 @@ Initiates a call. You can set call options as needed. This API uses an asynchron **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -117,7 +117,7 @@ Initiates a call. You can set call options as needed. This API uses a promise to | Name | Type | Mandatory| Description | | ----------- | ----------------------------------- | ---- | -------------------------------------- | | phoneNumber | string | Yes | Phone number. | -| options | [DialCallOptions](#dialcalloptions9)| No | Call options, which carry other configuration information of the call.| +| options | [DialCallOptions](#dialcalloptions9)| No | Call options, which carry other configuration information of the call.
If this parameter is not set, the following configuration is used by default. For details, see [DialCallOptions](#dialcalloptions9).
- **accountId**: 0 (card slot 1)
- **videoState**: voice call
- **dialScene**: common call
- **dialType**: carrier call | **Return value** @@ -127,7 +127,7 @@ Initiates a call. You can set call options as needed. This API uses a promise to **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -274,7 +274,7 @@ Launches the call screen and displays the dialed number. This API uses an asynch **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -315,7 +315,7 @@ Launches the call screen and displays the dialed number. This API uses a promise **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -469,7 +469,7 @@ Checks whether the called number is an emergency number. This API uses an asynch **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -506,7 +506,7 @@ Checks whether the called number is an emergency number based on the phone numbe **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -548,7 +548,7 @@ Checks whether the called number is an emergency number based on the phone numbe **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -588,7 +588,7 @@ A formatted phone number is a standard numeric string, for example, 555 0100. **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -626,7 +626,7 @@ A formatted phone number is a standard numeric string, for example, 555 0100. **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -672,7 +672,7 @@ A formatted phone number is a standard numeric string, for example, 555 0100. **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -715,7 +715,7 @@ The phone number must match the specified country code. For example, for a China **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -761,7 +761,7 @@ All country codes are supported. **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -802,7 +802,7 @@ Mutes the ringtone while it is playing. It does not work if the ringtone has bee **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -842,7 +842,7 @@ Mutes the ringtone while it is playing. It does not work if the ringtone has bee **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -883,7 +883,7 @@ Answers a call. This API uses an asynchronous callback to return the result. **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -919,7 +919,7 @@ Answers a call. This API uses a promise to return the result. | Name| Type | Mandatory| Description | | ------ | ------ | ---- | ------------------------------------------------------------ | -| callId | number | No | Call ID. You can obtain the value by subscribing to **callDetailsChange** events. This parameter is optional from API version 9.| +| callId | number | No | Call ID. You can obtain the value by subscribing to **callDetailsChange** events. This parameter is optional from API version 9.
If this parameter is not set, the latest ringing call will be connected.| **Return value** @@ -929,7 +929,7 @@ Answers a call. This API uses a promise to return the result. **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -971,7 +971,7 @@ Answers a call. This API uses an asynchronous callback to return the result. **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -1012,7 +1012,7 @@ Ends a call. This API uses an asynchronous callback to return the result. **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -1048,7 +1048,7 @@ Ends a call. This API uses a promise to return the result. | Name| Type | Mandatory| Description | | ------ | ------ | ---- | ------------------------------------------------------------ | -| callId | number | No | Call ID. You can obtain the value by subscribing to **callDetailsChange** events. This parameter is optional from API version 9.| +| callId | number | No | Call ID. You can obtain the value by subscribing to **callDetailsChange** events. This parameter is optional from API version 9.
If this parameter is not set, the latest ongoing, dialed, or connected call will be ended.| **Return value** @@ -1058,7 +1058,7 @@ Ends a call. This API uses a promise to return the result. **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -1100,7 +1100,7 @@ Ends a call. This API uses an asynchronous callback to return the result. **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -1142,7 +1142,7 @@ Rejects a call. This API uses an asynchronous callback to return the result. **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -1185,7 +1185,7 @@ Rejects a call. This API uses an asynchronous callback to return the result. **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -1224,8 +1224,8 @@ Rejects a call. This API uses a promise to return the result. | Name | Type | Mandatory| Description | | ------- | ---------------------------------------------- | ---- | ------------------------------------------------------------ | -| callId | number | No | Call ID. You can obtain the value by subscribing to **callDetailsChange** events. This parameter is optional from API version 9.| -| options | [RejectMessageOptions](#rejectmessageoptions7) | No | Options for the call rejection message. | +| callId | number | No | Call ID. You can obtain the value by subscribing to **callDetailsChange** events. This parameter is optional from API version 9.
If this parameter is not set, the latest ringing call will be rejected.| +| options | [RejectMessageOptions](#rejectmessageoptions7) | No | Options for the call rejection message. If this parameter is not set, no call rejection message will be sent.| **Return value** @@ -1235,7 +1235,7 @@ Rejects a call. This API uses a promise to return the result. **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -1280,7 +1280,7 @@ Rejects a call. This API uses an asynchronous callback to return the result. **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -1321,7 +1321,7 @@ Rejects a call. This API uses an asynchronous callback to return the result. **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -1365,7 +1365,7 @@ Holds a call based on the specified call ID. This API uses an asynchronous callb **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -1411,7 +1411,7 @@ Holds a call based on the specified call ID. This API uses a promise to return t **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -1453,7 +1453,7 @@ Unholds a call based on the specified call ID. This API uses an asynchronous cal **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -1499,7 +1499,7 @@ Unholds a call based on the specified call ID. This API uses a promise to return **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -1541,7 +1541,7 @@ Switches a call. This API uses an asynchronous callback to return the result. **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -1587,7 +1587,7 @@ Switches a call. This API uses a promise to return the result. **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -1627,7 +1627,7 @@ Combines two calls into a conference call. This API uses an asynchronous callbac **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -1670,7 +1670,7 @@ Combines two calls into a conference call. This API uses a promise to return the **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -1709,7 +1709,7 @@ Obtains the main call ID. This API uses an asynchronous callback to return the r **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -1753,7 +1753,7 @@ Obtains the main call ID. This API uses a promise to return the result. **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -1793,7 +1793,7 @@ Obtains the list of subcall IDs. This API uses an asynchronous callback to retur **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -1836,7 +1836,7 @@ Obtains the list of subcall IDs. This API uses a promise to return the result. **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -1876,7 +1876,7 @@ Obtains the list of call IDs in a conference. This API uses an asynchronous call **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -1919,7 +1919,7 @@ Obtains the list of call IDs in a conference. This API uses a promise to return **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -1961,7 +1961,7 @@ Obtains the call waiting status. This API uses an asynchronous callback to retur **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -2007,7 +2007,7 @@ Obtains the call waiting status. This API uses a promise to return the result. **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -2033,7 +2033,7 @@ promise.then(data => { setCallWaiting\(slotId: number, activate: boolean, callback: AsyncCallback\): void -Sets the call waiting switch. This API uses an asynchronous callback to return the result. +Specifies whether to enable the call waiting service. This API uses an asynchronous callback to return the result. **System API**: This is a system API. @@ -2051,7 +2051,7 @@ Sets the call waiting switch. This API uses an asynchronous callback to return t **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -2075,7 +2075,7 @@ call.setCallWaiting(0, true, (err) => { setCallWaiting\(slotId: number, activate: boolean\): Promise -Sets the call waiting switch. This API uses a promise to return the result. +Specifies whether to enable the call waiting service. This API uses a promise to return the result. **System API**: This is a system API. @@ -2098,7 +2098,7 @@ Sets the call waiting switch. This API uses a promise to return the result. **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -2139,7 +2139,7 @@ Enables DTMF. This API uses an asynchronous callback to return the result. **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -2183,7 +2183,7 @@ Enables DTMF. This API uses a promise to return the result. **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -2222,7 +2222,7 @@ Stops DTMF. This API uses an asynchronous callback to return the result. **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -2265,7 +2265,7 @@ Stops DTMF. This API uses a promise to return the result. **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -2305,7 +2305,7 @@ Checks whether a call is an emergency call. This API uses an asynchronous callba **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -2345,7 +2345,7 @@ Checks whether a call is an emergency call. This API uses a promise to return th **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -2388,7 +2388,7 @@ Subscribes to **callDetailsChange** events. This API uses an asynchronous callba **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -2428,7 +2428,7 @@ Subscribes to **callEventChange** events. This API uses an asynchronous callback **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -2468,7 +2468,7 @@ Subscribes to **callDisconnectedCause** events. This API uses an asynchronous ca **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -2508,7 +2508,7 @@ Subscribes to **mmiCodeResult** events. This API uses an asynchronous callback t **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -2544,11 +2544,11 @@ Unsubscribes from **callDetailsChange** events. This API uses an asynchronous ca | Name | Type | Mandatory| Description | | -------- | -------------------------------------------------------- | ---- | ---------------------------------- | | type | string | Yes | Call details change. This field has a fixed value of **callDetailsChange**.| -| callback | Callback<[CallAttributeOptions](#callattributeoptions7)> | No | Callback used to return the result. | +| callback | Callback<[CallAttributeOptions](#callattributeoptions7)> | No | Callback used to return the result. If this parameter is not set, no subscription cancellation result will be received.| **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -2584,11 +2584,11 @@ Unsubscribes from **callEventChange** events. This API uses an asynchronous call | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------ | ---- | ---------------------------------- | | type | string | Yes | Call event change. This field has a fixed value of **callEventChange**.| -| callback | Callback<[CallEventOptions](#calleventoptions8)> | No | Callback used to return the result. | +| callback | Callback<[CallEventOptions](#calleventoptions8)> | No | Callback used to return the result. If this parameter is not set, no subscription cancellation result will be received.| **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -2624,11 +2624,11 @@ Unsubscribes from **callDisconnectedCause** events. This API uses an asynchronou | Name | Type | Mandatory| Description | | -------- | ---------------------------------------------------------- | ---- | ------------------- | | type | string | Yes | Call disconnection cause. This field has a fixed value of **callDisconnectedCause**.| -| callback | Callback<[DisconnectedDetails](#disconnecteddetails9)> | No | Callback used to return the result. | +| callback | Callback<[DisconnectedDetails](#disconnecteddetails9)> | No | Callback used to return the result. If this parameter is not set, no subscription cancellation result will be received.| **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -2664,11 +2664,11 @@ Unsubscribes from **mmiCodeResult** events. This API uses an asynchronous callba | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------ | ---- | ----------- | | type | string | Yes | MMI code result. This field has a fixed value of **mmiCodeResult**.| -| callback | Callback<[MmiCodeResults](#mmicoderesults9)> | No | Callback used to return the result. | +| callback | Callback<[MmiCodeResults](#mmicoderesults9)> | No | Callback used to return the result. If this parameter is not set, no subscription cancellation result will be received.| **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -2705,7 +2705,7 @@ Checks whether a new call is allowed. This API uses an asynchronous callback to **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -2742,7 +2742,7 @@ Checks whether a new call is allowed. This API uses a promise to return the resu **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -2782,7 +2782,7 @@ Separates calls from a conference call. This API uses an asynchronous callback t **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -2825,7 +2825,7 @@ Separates calls from a conference call. This API uses a promise to return the re **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -2867,7 +2867,7 @@ Obtains the call restriction status. This API uses an asynchronous callback to r **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -2914,7 +2914,7 @@ Obtains the call restriction status. This API uses a promise to return the resul **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -2958,7 +2958,7 @@ Sets the call restriction status. This API uses an asynchronous callback to retu **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -3010,7 +3010,7 @@ Sets the call restriction status. This API uses a promise to return the result. **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -3058,7 +3058,7 @@ Obtains call transfer information. This API uses an asynchronous callback to ret **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -3105,7 +3105,7 @@ Obtains call transfer information. This API uses a promise to return the result. **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -3149,7 +3149,7 @@ Sets call transfer information. This API uses an asynchronous callback to return **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -3201,7 +3201,7 @@ Sets call transfer information. This API uses a promise to return the result. **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -3247,7 +3247,7 @@ Checks whether the ringtone is playing. This API uses an asynchronous callback t **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -3287,7 +3287,7 @@ Checks whether the ringtone is playing. This API uses a promise to return the re **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -3327,7 +3327,7 @@ Sets call muting. This API uses an asynchronous callback to return the result. **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -3364,7 +3364,7 @@ Sets call muting. This API uses a promise to return the result. **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -3402,7 +3402,7 @@ Cancels call muting. This API uses an asynchronous callback to return the result **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -3439,7 +3439,7 @@ Cancels call muting. This API uses a promise to return the result. **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -3478,7 +3478,7 @@ Sets the audio device for a call. This API uses an asynchronous callback to retu **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -3501,7 +3501,7 @@ call.setAudioDevice(1, (err) => { setAudioDevice\(device: AudioDevice, options: AudioDeviceOptions, callback: AsyncCallback\): void -Sets the audio device for a call based on the specified options. This API uses an asynchronous callback to return the result. +Sets the audio device for a call. This API uses an asynchronous callback to return the result. **System API**: This is a system API. @@ -3517,7 +3517,7 @@ Sets the audio device for a call based on the specified options. This API uses a **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -3564,7 +3564,7 @@ Sets the audio device for a call based on the specified options. This API uses a **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -3607,7 +3607,7 @@ Joins a conference call. This API uses an asynchronous callback to return the re **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -3653,7 +3653,7 @@ Joins a conference call. This API uses a promise to return the result. **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -3696,7 +3696,7 @@ Updates the IMS call mode. This API uses an asynchronous callback to return the **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -3739,7 +3739,7 @@ Updates the IMS call mode. This API uses a promise to return the result. **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -3763,7 +3763,7 @@ call.updateImsCallMode(1, 1).then(() => { enableImsSwitch(slotId: number, callback: AsyncCallback): void -Enables the IMS switch. This API uses an asynchronous callback to return the result. +Enables the IMS service. This API uses an asynchronous callback to return the result. **System API**: This is a system API. @@ -3780,7 +3780,7 @@ Enables the IMS switch. This API uses an asynchronous callback to return the res **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -3803,7 +3803,7 @@ call.enableImsSwitch(0, (err) => { enableImsSwitch(slotId: number): Promise -Enables the IMS switch. This API uses a promise to return the result. +Enables the IMS service. This API uses a promise to return the result. **System API**: This is a system API. @@ -3825,7 +3825,7 @@ Enables the IMS switch. This API uses a promise to return the result. **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -3850,7 +3850,7 @@ call.enableImsSwitch(0).then(() => { disableImsSwitch(slotId: number, callback: AsyncCallback): void -Disables the IMS switch. This API uses an asynchronous callback to return the result. +Disables the IMS service. This API uses an asynchronous callback to return the result. **System API**: This is a system API. @@ -3867,7 +3867,7 @@ Disables the IMS switch. This API uses an asynchronous callback to return the re **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -3890,7 +3890,7 @@ call.disableImsSwitch(0, (err) => { disableImsSwitch(slotId: number): Promise -Disables the IMS switch. This API uses a promise to return the result. +Disables the IMS service. This API uses a promise to return the result. **System API**: This is a system API. @@ -3912,7 +3912,7 @@ Disables the IMS switch. This API uses a promise to return the result. **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -3937,7 +3937,7 @@ call.disableImsSwitch(0).then(() => { isImsSwitchEnabled(slotId: number, callback: AsyncCallback): void -Checks whether the IMS switch is enabled. This API uses an asynchronous callback to return the result. +Checks whether the IMS service is enabled. This API uses an asynchronous callback to return the result. **System API**: This is a system API. @@ -3952,7 +3952,7 @@ Checks whether the IMS switch is enabled. This API uses an asynchronous callback **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -3974,7 +3974,7 @@ call.isImsSwitchEnabled(0, (err, data) => { isImsSwitchEnabled(slotId: number): Promise -Checks whether the IMS switch is enabled. This API uses a promise to return the result. +Checks whether the IMS service is enabled. This API uses a promise to return the result. **System API**: This is a system API. @@ -3994,7 +3994,7 @@ Checks whether the IMS switch is enabled. This API uses a promise to return the **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -4031,7 +4031,7 @@ Provides an option for determining whether a call is a video call. ## DialCallOptions9+ -Defines options for initiating a call. +Provides an option for determining whether a call is a video call. **System capability**: SystemCapability.Telephony.CallManager @@ -4408,7 +4408,7 @@ Enumerates call transfer states. ## DisconnectedDetails9+ -Defines the cause of a call disconnection. +Defines the call disconnection cause. **System API**: This is a system API. @@ -4416,12 +4416,12 @@ Defines the cause of a call disconnection. | Name | Type | Mandatory| Description | | ------- | ------------------------------------------ | ---- | --------------- | -| reason | [DisconnectedReason](#disconnectedreason8) | Yes | Cause of the call disconnection. | -| message | string | Yes | Message indicating the call disconnection.| +| reason | [DisconnectedReason](#disconnectedreason8) | Yes | Call disconnection cause. | +| message | string | Yes | Call ending message.| ## DisconnectedReason8+ -Enumerates causes of call disconnection. +Enumerates call disconnection causes. **System API**: This is a system API. @@ -4464,7 +4464,7 @@ Enumerates causes of call disconnection. | BEARER_SERVICE_NOT_IMPLEMENTED9+ | 65 | Bearer service not implemented. | | ACM_EQUALTO_OR_GREATER_THAN_THE_MAXIMUM_VALUE9+ | 68 | ACM greater than or equal to the maximum value. | | REQUESTED_FACILITY_NOT_IMPLEMENTED9+ | 69 | Requested facility not implemented. | -| ONLY_RESTRICTED_DIGITAL_INFO_BEARER_CAPABILITY_IS_AVAILABLE9+ | 70 | Only restricted digital information capability available. | +| ONLY_RESTRICTED_DIGITAL_INFO_BEARER_CAPABILITY_IS_AVAILABLE9+ | 70 | Only restricted digital information bearer capability available. | | SERVICE_OR_OPTION_NOT_IMPLEMENTED_UNSPECIFIED9+ | 79 | Service or option not implemented, unspecified. | | INVALID_TRANSACTION_IDENTIFIER_VALUE9+ | 81 | Invalid transaction identifier value. | | USER_NOT_MEMBER_OF_CUG9+ | 87 | User not member of CUG. | diff --git a/en/application-dev/reference/apis/js-apis-cardEmulation.md b/en/application-dev/reference/apis/js-apis-cardEmulation.md index 599ec851697326c6329d1d080fe611a3161a9514..946ebd2f881fe66a7ec6b0afc8e308d254a6f68c 100644 --- a/en/application-dev/reference/apis/js-apis-cardEmulation.md +++ b/en/application-dev/reference/apis/js-apis-cardEmulation.md @@ -21,11 +21,11 @@ Enumerates the NFC card emulation types. **System capability**: SystemCapability.Communication.NFC.CardEmulation -| Name| Value| Description| -| -------- | -------- | -------- | -| HCE | 0 | HCE.| -| UICC | 1 | Subscriber identity module (SIM) card emulation.| -| ESE | 2 | embedded Secure Element (eSE) emulation.| +| Name | Value | Description | +| ---- | ---- | -------- | +| HCE | 0 | HCE.| +| UICC | 1 | Subscriber identity module (SIM) card emulation.| +| ESE | 2 | embedded Secure Element (eSE) emulation. | ## CardType9+ @@ -33,10 +33,10 @@ Enumerates the types of services used by the card emulation application. **System capability**: SystemCapability.Communication.NFC.CardEmulation -| Name| Value| Description| -| -------- | -------- | -------- | +| Name | Value | Description | +| ------- | --------- | ----------------- | | PAYMENT | "payment" | Payment type.| -| OTHER | "other" | Other types.| +| OTHER | "other" | Other types.| ## isSupported @@ -51,14 +51,14 @@ Checks whether a certain type of card emulation is supported. **Parameters** -| Name | Type | Mandatory| Description | -| ------- | -------- | ---- | ----------------------- | -| feature | number | Yes | Card emulation type. For details, see [FeatureType](#featuretype).| +| Name | Type | Mandatory | Description | +| ------- | ------ | ---- | ---------------------------------------- | +| feature | number | Yes | Card emulation type. For details, see [FeatureType](#featuretype).| **Return value** -| **Type**| **Description**| -| -------- | -------- | +| **Type** | **Description** | +| ------- | -------------------------------------- | | boolean | Returns **true** if the card emulation type is supported; returns **false** otherwise.| ## hasHceCapability9+ @@ -73,8 +73,8 @@ Checks whether HCE is supported. **Return value** -| **Type**| **Description**| -| -------- | -------- | +| **Type** | **Description** | +| ------- | -------------------------------- | | boolean | Returns **true** if HCE is supported; returns **false** otherwise.| ## isDefaultService9+ @@ -89,15 +89,15 @@ Checks whether an application is the default application of the specified servic **Parameters** -| Name | Type | Mandatory| Description | -| ------- | -------- | ---- | ----------------------- | -| elementName | [ElementName](js-apis-bundleManager-elementName.md#elementname) | Yes| Application description, which consists of the bundle name and component name.| -| type | [CardType](#cardtype9) | Yes| Card emulation service type.| +| Name | Type | Mandatory | Description | +| ----------- | ---------------------------------------- | ---- | ----------------------- | +| elementName | [ElementName](js-apis-bundleManager-elementName.md#elementname) | Yes | Application description, which consists of the bundle name and component name.| +| type | [CardType](#cardtype9) | Yes | Card emulation service type. | **Return value** -| **Type**| **Description**| -| -------- | -------- | +| **Type** | **Description** | +| ------- | ------------------------------------ | | boolean | Returns **true** if the application is the default payment application; returns **false** otherwise.| **Example** @@ -108,13 +108,11 @@ import cardEmulation from '@ohos.nfc.cardEmulation'; var isHceSupported = cardEmulation.isSupported(cardEmulation.FeatureType.HCE); if (!isHceSupported) { console.log('this device is not supported for HCE, ignore it.'); - return; } var hasHceCap = cardEmulation.hasHceCapability(); if (!hasHceCap) { console.log('this device hasHceCapability false, ignore it.'); - return; } var elementName = { diff --git a/en/application-dev/reference/apis/js-apis-connectedTag.md b/en/application-dev/reference/apis/js-apis-connectedTag.md index 1bfb1231c3c4584fe4d608891bdf2be54458e425..9f8ea1bd9dcf8b2586865648732db2dd367bf20a 100644 --- a/en/application-dev/reference/apis/js-apis-connectedTag.md +++ b/en/application-dev/reference/apis/js-apis-connectedTag.md @@ -1,4 +1,4 @@ -# @ohos.connectedTag +# @ohos.connectedTag (Active Tags) The **connectedTag** module provides APIs for using active tags. You can use the APIs to initialize the active tag chip and read and write active tags. @@ -28,6 +28,23 @@ Initializes the active tag chip. | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| +## connectedTag.initialize9+ + +initialize(): void + +Initializes the active tag chip. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.ConnectedTag + +**Error codes** +For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode-nfc.md). + +| ID| Error Message| +| -------- | -------- | +| 3200101 | Connected NFC tag running state is abnormal in service. | + ## connectedTag.uninit uninit(): boolean @@ -44,6 +61,23 @@ Uninitializes the active tag resources. | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| +## connectedTag.uninitialize9+ + +uninitialize(): void + +Uninitializes the active tag resources. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.ConnectedTag + +**Error codes** +For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode-nfc.md). + +| ID| Error Message| +| -------- | -------- | +| 3200101 | Connected NFC tag running state is abnormal in service. | + ## connectedTag.readNdefTag readNdefTag(): Promise<string> @@ -72,6 +106,41 @@ connectedTag.readNdefTag().then((data) => { }); ``` +## connectedTag.read9+ + +read(): Promise<number[]> + +Reads the content of this active tag. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.ConnectedTag + +**Return value** + +| **Type**| **Description**| +| -------- | -------- | +| Promise<number[]> | Promise used to return the content of the active tag.| + +**Error codes** +For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode-nfc.md). + +| ID| Error Message| +| -------- | -------- | +| 3200101 | Connected NFC tag running state is abnormal in service. | + +**Example** + +```js +import connectedTag from '@ohos.connectedTag'; + +connectedTag.read().then((data) => { + console.log("connectedTag read Promise data = " + data); +}).catch((err)=> { + console.log("connectedTag read Promise err: " + err); +}); +``` + ## connectedTag.readNdefTag readNdefTag(callback: AsyncCallback<string>): void @@ -102,6 +171,43 @@ connectedTag.readNdefTag((err, data)=> { }); ``` +## connectedTag.read9+ + +read(callback: AsyncCallback<number[]>): void + +Reads the content of this active tag. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.ConnectedTag + +**Parameters** + +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<number[]> | Yes| Callback invoked to return the active tag content obtained.| + +**Error codes** +For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode-nfc.md). + +| ID| Error Message| +| -------- | -------- | +| 3200101 | Connected NFC tag running state is abnormal in service. | + +**Example** + +```js +import connectedTag from '@ohos.connectedTag'; + +connectedTag.read((err, data)=> { + if (err) { + console.log("connectedTag read AsyncCallback err: " + err); + } else { + console.log("connectedTag read AsyncCallback data: " + data); + } +}); +``` + ## connectedTag.writeNdefTag writeNdefTag(data: string): Promise<void> @@ -129,7 +235,7 @@ Writes data to this active tag. This API uses a promise to return the result. ```js import connectedTag from '@ohos.connectedTag'; -var rawData = "010203"; // change it tobe correct. +var rawData = "010203"; // Set it as required. connectedTag.writeNdefTag(rawData).then(() => { console.log("connectedTag writeNdefTag Promise success."); }).catch((err)=> { @@ -137,6 +243,48 @@ connectedTag.writeNdefTag(rawData).then(() => { }); ``` +## connectedTag.write9+ + +write(data: number[]): Promise<void> + +Writes data to this active tag. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.ConnectedTag + +**Parameters** + +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| data | number[] | Yes| Data to be written to the active tag. The value is a hexadecimal number ranging from 0x00 to 0xFF.| + +**Return value** + +| **Type**| **Description**| +| -------- | -------- | +| Promise<void> | Promise that returns no value.| + +**Error codes** +For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode-nfc.md). + +| ID| Error Message| +| -------- | -------- | +| 3200101 | Connected NFC tag running state is abnormal in service. | + +**Example** + +```js +import connectedTag from '@ohos.connectedTag'; + +var rawData = [0x01, 0x02, 0x03]; // change it tobe correct. +connectedTag.write(rawData).then(() => { + console.log("connectedTag write NdefTag Promise success."); +}).catch((err)=> { + console.log("connectedTag write NdefTag Promise err: " + err); +}); +``` + ## connectedTag.writeNdefTag writeNdefTag(data: string, callback: AsyncCallback<void>): void @@ -159,7 +307,7 @@ Writes data to this active tag. This API uses an asynchronous callback to return ```js import connectedTag from '@ohos.connectedTag'; -var rawData = "010203"; // change it tobe correct. +var rawData = "010203"; // Set it as required. connectedTag.writeNdefTag(rawData, (err)=> { if (err) { console.log("connectedTag writeNdefTag AsyncCallback err: " + err); @@ -169,6 +317,45 @@ connectedTag.writeNdefTag(rawData, (err)=> { }); ``` +## connectedTag.write9+ + +write(data: number[], callback: AsyncCallback<void>): void + +Writes data to this active tag. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.NFC_TAG + +**System capability**: SystemCapability.Communication.ConnectedTag + +**Parameters** + +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| data | number[] | Yes| Data to be written to the active tag. The value is a hexadecimal number ranging from 0x00 to 0xFF.| +| callback | AsyncCallback<void> | Yes| Callback invoked to return the active tag content obtained.| + +**Error codes** +For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode-nfc.md). + +| ID| Error Message| +| -------- | -------- | +| 3200101 | Connected NFC tag running state is abnormal in service. | + +**Example** + +```js +import connectedTag from '@ohos.connectedTag'; + +var rawData = [0x01, 0x02, 0x03]; // change it tobe correct. +connectedTag.write(rawData, (err)=> { + if (err) { + console.log("connectedTag write NdefTag AsyncCallback err: " + err); + } else { + console.log("connectedTag write NdefTag AsyncCallback success."); + } +}); +``` + ## connectedTag.on('notify') on(type: "notify", callback: Callback<number>): void @@ -220,7 +407,7 @@ connectedTag.on("notify", (err, rfState)=> { var initStatus = connectedTag.init(); console.log("connectedTag init status: " + initStatus); -// Add nfc connecected tag business oprations here... +// Add NFC connected tag business operations here. // connectedTag.writeNdefTag(rawData) // connectedTag.readNdefTag() diff --git a/en/application-dev/reference/apis/js-apis-data-dataSharePredicates.md b/en/application-dev/reference/apis/js-apis-data-dataSharePredicates.md index 78d896c54a2f1c1674825ddaff66088634129596..6fe449189c068aa7d73745feb4482c60835772c3 100644 --- a/en/application-dev/reference/apis/js-apis-data-dataSharePredicates.md +++ b/en/application-dev/reference/apis/js-apis-data-dataSharePredicates.md @@ -6,9 +6,8 @@ The APIs provided by **DataSharePredicates** correspond to the filter criteria > **NOTE** > -> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. -> -> The APIs provided by this module are system APIs. +> - The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. +>- The APIs provided by this module are system APIs. ## Modules to Import @@ -18,7 +17,7 @@ import dataSharePredicates from '@ohos.data.dataSharePredicates'; ``` ## DataSharePredicates -Provides methods for setting different **DataSharePredicates** objects. +Provides methods for setting different **DataSharePredicates** objects. This type is not multi-thread safe. If a **DataSharePredicates** instance is operated by multiple threads at the same time in an application, use a lock for the instance. ### equalTo @@ -428,7 +427,7 @@ predicates.glob("NAME", "?h*g") between(field: string, low: ValueType, high: ValueType): DataSharePredicates -Sets a **DataSharePredicates** object to search for the data that is within the specified range, including the start and end values. +Sets a **DataSharePredicates** object to match the data that is within the specified range, including the start and end values. Currently, only the RDB supports this **DataSharePredicates** object. @@ -459,7 +458,7 @@ predicates.between("AGE", 10, 50) notBetween(field: string, low: ValueType, high: ValueType): DataSharePredicates -Sets a **DataSharePredicates** object to search for the data that is out of the specified range, excluding the start and end values. +Sets a **DataSharePredicates** object to match the data that is out of the specified range, excluding the start and end values. Currently, only the RDB supports this **DataSharePredicates** object. diff --git a/en/application-dev/reference/apis/js-apis-data-distributedobject.md b/en/application-dev/reference/apis/js-apis-data-distributedobject.md index 978cbffcf74444d9c902a91d72017d316f5ae5e8..8892f9ff2538ad00cebda30ba7b80fa3abf31641 100644 --- a/en/application-dev/reference/apis/js-apis-data-distributedobject.md +++ b/en/application-dev/reference/apis/js-apis-data-distributedobject.md @@ -23,10 +23,10 @@ Creates a distributed data object. **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| context | Context | Yes| Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-inner-application-uiAbilityContext.md).| -| source | object | Yes| Attributes of the distributed data object.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | context | Context | Yes| Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-inner-application-uiAbilityContext.md).| + | source | object | Yes| Attributes of the distributed data object.| **Return value** @@ -75,9 +75,9 @@ Creates a random session ID. **Return value** -| Type| Description| -| -------- | -------- | -| string | Session ID created.| + | Type| Description| + | -------- | -------- | + | string | Session ID created.| **Example** @@ -124,18 +124,18 @@ Sets a session ID for synchronization. Automatic synchronization is performed fo **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| sessionId | string | Yes| ID of a distributed data object on a trusted network.| -| callback | AsyncCallback<void> | Yes| Asynchronous callback invoked when the session ID is successfully set.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | sessionId | string | Yes| ID of a distributed data object on a trusted network.| + | callback | AsyncCallback<void> | Yes| Asynchronous callback invoked when the session ID is successfully set.| **Error codes** For details about the error codes, see [Distributed Data Object Error Codes](../errorcodes/errorcode-distributed-dataObject.md). -| ID| Error Message| -| -------- | -------- | -| 15400001 | Failed to create the in-memory database.| + | ID| Error Message| + | -------- | -------- | + | 15400001 | Create table failed.| **Example** @@ -158,17 +158,17 @@ Exits all joined sessions. **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| callback | AsyncCallback<void> | Yes| Asynchronous callback invoked when the distributed data object exits all joined sessions.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<void> | Yes| Asynchronous callback invoked when the distributed data object exits all joined sessions.| **Error codes** For details about the error codes, see [Distributed Data Object Error Codes](../errorcodes/errorcode-distributed-dataObject.md). -| ID| Error Message| -| -------- | -------- | -| 15400001 | Failed to create the in-memory database.| + | ID| Error Message| + | -------- | -------- | + | 15400001 | Create table failed.| **Example** @@ -195,9 +195,9 @@ Sets a session ID for synchronization. Automatic synchronization is performed fo **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| sessionId | string | No| ID of a distributed data object on a trusted network. To remove a distributed data object from the network, set this parameter to "" or leave it empty.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | sessionId | string | No| ID of a distributed data object on a trusted network. To remove a distributed data object from the network, set this parameter to "" or leave it empty.| **Return value** @@ -209,9 +209,9 @@ Sets a session ID for synchronization. Automatic synchronization is performed fo For details about the error codes, see [Distributed Data Object Error Codes](../errorcodes/errorcode-distributed-dataObject.md). -| ID| Error Message| -| -------- | -------- | -| 15400001 | Failed to create the in-memory database.| + | ID| Error Message| + | -------- | -------- | + | 15400001 | Create table failed.| **Example** @@ -240,10 +240,10 @@ Subscribes to data changes of this distributed data object. **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| type | string | Yes| Event type to subscribe to. The value is **change**, which indicates data changes.| -| callback | Callback<{ sessionId: string, fields: Array<string> }> | Yes| Callback invoked to return the changes of the distributed data object.
**sessionId** indicates the session ID of the distributed data object.
**fields** indicates the changed attributes of the distributed data object.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | type | string | Yes| Event type to subscribe to. The value is **change**, which indicates data changes.| + | callback | Callback<{ sessionId: string, fields: Array<string> }> | Yes| Callback invoked to return the changes of the distributed data object.
**sessionId** indicates the session ID of the distributed data object.
**fields** indicates the changed attributes of the distributed data object.| **Example** @@ -269,10 +269,10 @@ Unsubscribes from the data changes of this distributed data object. **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | | type | string | Yes| Event type to unsubscribe from. The value is **change**, which indicates data changes.| -| callback | Callback<{ sessionId: string, fields: Array<string> }> | No| Callback for data changes. If this parameter is not specified, all data change callbacks of this distributed data object will be unregistered.
**sessionId** indicates the session ID of the distributed data object.
**fields** indicates the changed attributes of the distributed data object.| + | callback | Callback<{ sessionId: string, fields: Array<string> }> | No| Callback for data changes. If this parameter is not specified, all data change callbacks of this distributed data object will be unregistered.
**sessionId** indicates the session ID of the distributed data object.
**fields** indicates the changed attributes of the distributed data object.| **Example** @@ -294,10 +294,10 @@ Subscribes to status changes of this distributed data object. **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| type | string | Yes| Event type to subscribe to. The value is **status**, which indicates the status change (online or offline) of the distributed data object.| -| callback | Callback<{ sessionId: string, networkId: string, status: 'online' \| 'offline' }> | Yes| Callback invoked to return the status change.
**sessionId** indicates the session ID of the distributed data object.
**networkId** indicates the object device ID, that is, **deviceId**.
**status** indicates the object status, which can be online or offline.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | type | string | Yes| Event type to subscribe to. The value is **status**, which indicates the status change (online or offline) of the distributed data object.| + | callback | Callback<{ sessionId: string, networkId: string, status: 'online' \| 'offline' }> | Yes| Callback invoked to return the status change.
**sessionId** indicates the session ID of the distributed data object.
**networkId** indicates the object device ID, that is, **deviceId**.
**status** indicates the object status, which can be online or offline.| **Example** @@ -318,10 +318,10 @@ Unsubscribes from the status change of this distributed data object. **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | | type | string | Yes| Event type to unsubscribe from. The value is **status**, which indicates the status change (online or offline) of the distributed data object.| -| callback | Callback<{ sessionId: string, deviceId: string, status: 'online' \| 'offline' }> | No| Callback for status changes. If this parameter is not specified, all status change callbacks of this distributed data object will be unsubscribed from.
**sessionId** indicates the session ID of the distributed data object.
**deviceId** indicates the device ID of the distributed data object.
**status** indicates the object status, which can be online or offline.| + | callback | Callback<{ sessionId: string, deviceId: string, status: 'online' \| 'offline' }> | No| Callback for status changes. If this parameter is not specified, all status change callbacks of this distributed data object will be unsubscribed from.
**sessionId** indicates the session ID of the distributed data object.
**deviceId** indicates the device ID of the distributed data object.
**status** indicates the object status, which can be online or offline.| **Example** @@ -354,10 +354,10 @@ The saved data will be released in the following cases: **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| deviceId | string | Yes| ID of the device where data is stored. The value **local** indicates the local device.| -| callback | AsyncCallback<[SaveSuccessResponse](#savesuccessresponse9)> | Yes| Callback invoked to return **SaveSuccessResponse**, which contains information such as session ID, version, and device ID.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | deviceId | string | Yes| ID of the device where data is stored. The value **local** indicates the local device.| + | callback | AsyncCallback<[SaveSuccessResponse](#savesuccessresponse9)> | Yes| Callback invoked to return **SaveSuccessResponse**, which contains information such as session ID, version, and device ID.| **Example** @@ -394,15 +394,15 @@ The saved data will be released in the following cases: **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| deviceId | string | Yes| ID of the device where the data is saved. The default value is **local**, which indicates the local device. | + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | deviceId | string | Yes| ID of the device where the data is saved. The default value is **local**, which indicates the local device. | **Return value** -| Type| Description| -| -------- | -------- | -| Promise<[SaveSuccessResponse](#savesuccessresponse9)> | Promise used to return **SaveSuccessResponse**, which contains information such as session ID, version, and device ID.| + | Type| Description| + | -------- | -------- | + | Promise<[SaveSuccessResponse](#savesuccessresponse9)> | Promise used to return **SaveSuccessResponse**, which contains information such as session ID, version, and device ID.| **Example** @@ -423,7 +423,7 @@ g_object.save("local").then((result) => { revokeSave(callback: AsyncCallback<RevokeSaveSuccessResponse>): void -Revokes the saving operation of this distributed data object. This API uses an asynchronous callback to return the result. +Revokes the data of this distributed data object saved. This API uses an asynchronous callback to return the result. If the object is saved on the local device, the data saved on all trusted devices will be deleted. If the object is stored on another device, the data on the local device will be deleted. @@ -432,9 +432,9 @@ If the object is stored on another device, the data on the local device will be **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| callback | AsyncCallback<[RevokeSaveSuccessResponse](#revokesavesuccessresponse9)> | Yes| Callback invoked to return **RevokeSaveSuccessResponse**, which contains the session ID.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<[RevokeSaveSuccessResponse](#revokesavesuccessresponse9)> | Yes| Callback invoked to return **RevokeSaveSuccessResponse**, which contains the session ID.| **Example** @@ -468,7 +468,7 @@ g_object.revokeSave((err, result) => { revokeSave(): Promise<RevokeSaveSuccessResponse> -Revokes the saving operation of this distributed data object. This API uses a promise to return the result. +Revokes the data of this distributed data object saved. This API uses a promise to return the result. If the object is saved on the local device, the data saved on all trusted devices will be deleted. If the object is stored on another device, the data on the local device will be deleted. @@ -477,9 +477,9 @@ If the object is stored on another device, the data on the local device will be **Return value** -| Type| Description| -| -------- | -------- | -| Promise<[RevokeSaveSuccessResponse](#revokesavesuccessresponse9)> | Promise used to return **RevokeSaveSuccessResponse**, which contains the session ID.| + | Type| Description| + | -------- | -------- | + | Promise<[RevokeSaveSuccessResponse](#revokesavesuccessresponse9)> | Promise used to return **RevokeSaveSuccessResponse**, which contains the session ID.| **Example** @@ -520,9 +520,9 @@ Creates a distributed data object. **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| source | object | Yes| Attributes of the distributed data object.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | source | object | Yes| Attributes of the distributed data object.| **Return value** @@ -558,15 +558,15 @@ Sets a session ID for synchronization. Automatic synchronization is performed fo **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| sessionId | string | No| ID of a distributed data object on a trusted network. To remove a distributed data object from the network, set this parameter to "" or leave it empty.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | sessionId | string | No| ID of a distributed data object on a trusted network. To remove a distributed data object from the network, set this parameter to "" or leave it empty.| **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the session ID is set successfully;
returns **false** otherwise. | + | Type| Description| + | -------- | -------- | + | boolean | Returns **true** if the session ID is set successfully;
returns **false** otherwise. | **Example** @@ -593,10 +593,10 @@ Subscribes to data changes of this distributed data object. **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| type | string | Yes| Event type to subscribe to. The value is **change**, which indicates data changes.| -| callback | Callback<{ sessionId: string, fields: Array<string> }> | Yes| Callback invoked to return the changes of the distributed data object.
**sessionId** indicates the session ID of the distributed data object.
**fields** indicates the changed attributes of the distributed data object.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | type | string | Yes| Event type to subscribe to. The value is **change**, which indicates data changes.| + | callback | Callback<{ sessionId: string, fields: Array<string> }> | Yes| Callback invoked to return the changes of the distributed data object.
**sessionId** indicates the session ID of the distributed data object.
**fields** indicates the changed attributes of the distributed data object.| **Example** @@ -628,10 +628,10 @@ Unsubscribes from the data changes of this distributed data object. **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | | type | string | Yes| Event type to unsubscribe from. The value is **change**, which indicates data changes.| -| callback | Callback<{ sessionId: string, fields: Array<string> }> | No| Callback for data changes. If this parameter is not specified, all data change callbacks of this distributed data object will be unregistered.
**sessionId** indicates the session ID of the distributed data object.
**fields** indicates the changed attributes of the distributed data object.| + | callback | Callback<{ sessionId: string, fields: Array<string> }> | No| Callback for data changes. If this parameter is not specified, all data change callbacks of this distributed data object will be unregistered.
**sessionId** indicates the session ID of the distributed data object.
**fields** indicates the changed attributes of the distributed data object.| **Example** @@ -659,10 +659,10 @@ Subscribes to status changes of this distributed data object. **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| type | string | Yes| Event type to subscribe to. The value is **status**, which indicates the status change (online or offline) of the distributed data object.| -| callback | Callback<{ sessionId: string, networkId: string, status: 'online' \| 'offline' }> | Yes| Callback invoked to return the status change.
**sessionId** indicates the session ID of the distributed data object.
**networkId** indicates the object device ID, that is, **deviceId**.
**status** indicates the object status, which can be online or offline.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | type | string | Yes| Event type to subscribe to. The value is **status**, which indicates the status change (online or offline) of the distributed data object.| + | callback | Callback<{ sessionId: string, networkId: string, status: 'online' \| 'offline' }> | Yes| Callback invoked to return the status change.
**sessionId** indicates the session ID of the distributed data object.
**networkId** indicates the object device ID, that is, **deviceId**.
**status** indicates the object status, which can be online or offline.| **Example** @@ -689,8 +689,8 @@ Unsubscribes from the status change of this distributed data object. **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | | type | string | Yes| Event type to unsubscribe from. The value is **status**, which indicates the status change (online or offline) of the distributed data object.| | callback | Callback<{ sessionId: string, deviceId: string, status: 'online' \| 'offline' }> | No| Callback for status changes. If this parameter is not specified, all status change callbacks of this distributed data object will be unregistered.
**sessionId** indicates the session ID of the distributed data object.
**deviceId** indicates the device ID of the distributed data object.
**status** indicates the object status, which can be online or offline.| diff --git a/en/application-dev/reference/apis/js-apis-data-preferences.md b/en/application-dev/reference/apis/js-apis-data-preferences.md index 156078c63ad8f33a7747e493948f59d511a1c791..e2a87d1165961d5c5107e18d5500b7f1ae70567c 100644 --- a/en/application-dev/reference/apis/js-apis-data-preferences.md +++ b/en/application-dev/reference/apis/js-apis-data-preferences.md @@ -185,7 +185,7 @@ For details about the error codes, see [User Preference Error Codes](../errorcod | ID| Error Message | | -------- | ------------------------------| -| 15500010 | Failed to delete the preferences. | +| 15500010 | Failed to delete preferences. | **Example** @@ -197,7 +197,7 @@ import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); try { - data_preferences.deletePreferences(context, 'mystore', function (err, val) { + data_preferences.deletePreferences(context, 'mystore', function (err) { if (err) { console.info("Failed to delete the preferences. code =" + err.code + ", message =" + err.message); return; @@ -217,7 +217,7 @@ import UIAbility from '@ohos.app.ability.UIAbility'; class EntryAbility extends UIAbility { onWindowStageCreate(windowStage) { try { - data_preferences.deletePreferences(this.context, 'mystore', function (err, val) { + data_preferences.deletePreferences(this.context, 'mystore', function (err) { if (err) { console.info("Failed to delete the preferences. code =" + err.code + ", message =" + err.message); return; @@ -262,7 +262,7 @@ For details about the error codes, see [User Preference Error Codes](../errorcod | ID| Error Message | | -------- | ------------------------------| -| 15500010 | Failed to delete the preferences. | +| 15500010 | Failed to delete preferences. | **Example** @@ -334,7 +334,7 @@ import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); try { - data_preferences.removePreferencesFromCache(context, 'mystore', function (err, val) { + data_preferences.removePreferencesFromCache(context, 'mystore', function (err) { if (err) { console.info("Failed to remove the preferences. code =" + err.code + ", message =" + err.message); return; @@ -354,7 +354,7 @@ import UIAbility from '@ohos.app.ability.UIAbility'; class EntryAbility extends UIAbility { onWindowStageCreate(windowStage) { try { - data_preferences.removePreferencesFromCache(this.context, 'mystore', function (err, val) { + data_preferences.removePreferencesFromCache(this.context, 'mystore', function (err) { if (err) { console.info("Failed to remove the preferences. code =" + err.code + ", message =" + err.message); return; 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 2833579427f07e06bb793914864eba79322eb07a..8288efbbb55e7c308d5dd418b022521e97d08a5f 100644 --- a/en/application-dev/reference/apis/js-apis-data-rdb.md +++ b/en/application-dev/reference/apis/js-apis-data-rdb.md @@ -9,9 +9,8 @@ This module provides the following RDB-related functions: > **NOTE** > -> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. -> -> The APIs of this module are no longer maintained since API version 9. You are advised to use [@ohos.data.relationalStore](js-apis-data-relationalStore.md). +> - The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> - The APIs of this module are no longer maintained since API version 9. You are advised to use [@ohos.data.relationalStore](js-apis-data-relationalStore.md). ## Modules to Import @@ -1174,7 +1173,7 @@ predicates.notIn("NAME", ["Lisa", "Rose"]) Provides methods to manage an RDB store. -Before using the APIs of this class, use [executeSql](#executesql8) to initialize the database table structure and related data. +Before using the APIs of this class, use [executeSql](#executesql) to initialize the database table structure and related data. ### insert @@ -1830,7 +1829,7 @@ obtainDistributedTableName(device: string, table: string, callback: AsyncCallbac Obtains the distributed table name of a remote device based on the local table name of the device. The distributed table name is required when the RDB store of a remote device is queried. -> **NOTE**
+> **NOTE** > > The value of **device** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications. @@ -1879,7 +1878,7 @@ rdbStore.obtainDistributedTableName(deviceId, "EMPLOYEE", function (err, tableNa Obtains the distributed table name of a remote device based on the local table name of the device. The distributed table name is required when the RDB store of a remote device is queried. -> **NOTE**
+> **NOTE** > > The value of **device** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications. @@ -2045,7 +2044,7 @@ Registers an observer for this RDB store. When the data in the RDB store changes | -------- | -------- | -------- | -------- | | event | string | Yes| The value is'dataChange', which indicates a data change event.| | type | [SubscribeType](#subscribetype8) | Yes| Subscription type to register.| -| observer | Callback<Array<string>> | Yes| Observer that listens for the data changes in the RDB store.| +| observer | Callback<Array<string>> | Yes| Observer that listens for the data changes in the RDB store. **Array** indicates the IDs of the peer devices whose data in the database is changed.| **Example** @@ -2076,7 +2075,7 @@ Unregisters the observer of the specified type from the RDB store. This API uses | -------- | -------- | -------- | -------- | | event | string | Yes| The value is'dataChange', which indicates a data change event.| | type | [SubscribeType](#subscribetype8) | Yes| Subscription type to unregister.| -| observer | Callback<Array<string>> | Yes| Data change observer registered.| +| observer | Callback<Array<string>> | Yes| Data change observer to unregister. **Array** indicates the IDs of the peer devices whose data in the database is changed.| **Example** diff --git a/en/application-dev/reference/apis/js-apis-data-relationalStore.md b/en/application-dev/reference/apis/js-apis-data-relationalStore.md index 36383b8856f6903b1399d2a10446ef7b5bd15960..218572271420e03a9ff960879087a818751e4360 100644 --- a/en/application-dev/reference/apis/js-apis-data-relationalStore.md +++ b/en/application-dev/reference/apis/js-apis-data-relationalStore.md @@ -6,7 +6,7 @@ The **relationalStore** module provides the following functions: - [RdbPredicates](#rdbpredicates): provides predicates indicating the nature, feature, or relationship of a data entity in an RDB store. It is used to define the operation conditions for an RDB store. - [RdbStore](#rdbstore): provides APIs for managing data in an RDB store. -- [ResultSet](#resultset): provides APIs for accessing the result set obtained from the RDB store. +- [Resultset](#resultset): provides APIs for accessing the result set obtained from the RDB store. > **NOTE** > @@ -38,10 +38,11 @@ Obtains an RDB store. This API uses an asynchronous callback to return the resul For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). -| **ID**| **Error Message** | -| ------------ | ----------------------- | -| 14800010 | If failed delete database by invalid database name. | -| 14800011 | If failed open database by database corrupted. | +| **ID**| **Error Message** | +| ------------ | ----------------------------------------------------------- | +| 14800010 | Failed to open or delete database by invalid database path. | +| 14800011 | Failed to open database by database corrupted. | +| 14800000 | Inner error. | **Example** @@ -64,7 +65,7 @@ const STORE_CONFIG = { relationalStore.getRdbStore(context, STORE_CONFIG, function (err, rdbStore) { store = rdbStore; if (err) { - console.error(`Get RdbStore failed, err: ${err}`); + console.error(`Get RdbStore failed, code is ${err.code},message is ${err.message}`); return; } console.info(`Get RdbStore successfully.`); @@ -87,7 +88,7 @@ class EntryAbility extends UIAbility { relationalStore.getRdbStore(this.context, STORE_CONFIG, function (err, rdbStore) { store = rdbStore; if (err) { - console.error(`Get RdbStore failed, err: ${err}`); + console.error(`Get RdbStore failed, code is ${err.code},message is ${err.message}`); return; } console.info(`Get RdbStore successfully.`); @@ -121,10 +122,11 @@ Obtains an RDB store. This API uses a promise to return the result. You can set For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). -| **ID**| **Error Message** | -| ------------ | ----------------------- | -| 14800010 | If failed delete database by invalid database name. | -| 14800011 | If failed open database by database corrupted. | +| **ID**| **Error Message** | +| ------------ | ----------------------------------------------------------- | +| 14800010 | Failed to open or delete database by invalid database path. | +| 14800011 | Failed to open database by database corrupted. | +| 14800000 | Inner error. | **Example** @@ -148,7 +150,7 @@ promise.then(async (rdbStore) => { store = rdbStore; console.info(`Get RdbStore successfully.`); }).catch((err) => { - console.error(`Get RdbStore failed, err: ${err}`); + console.error(`Get RdbStore failed, code is ${err.code},message is ${err.message}`); }) ``` @@ -170,7 +172,7 @@ class EntryAbility extends UIAbility { store = rdbStore; console.info(`Get RdbStore successfully.`) }).catch((err) => { - console.error(`Get RdbStore failed, err: ${err}`); + console.error(`Get RdbStore failed, code is ${err.code},message is ${err.message}`); }) } } @@ -196,9 +198,10 @@ Deletes an RDB store. This API uses an asynchronous callback to return the resul For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). -| **ID**| **Error Message** | -| ------------ | ----------------------- | -| 14800010 | If failed delete database by invalid database name. | +| **ID**| **Error Message** | +| ------------ | ----------------------------------------------------------- | +| 14800010 | Failed to open or delete database by invalid database path. | +| 14800000 | Inner error. | **Example** @@ -212,7 +215,7 @@ let context = featureAbility.getContext() relationalStore.deleteRdbStore(context, "RdbTest.db", function (err) { if (err) { - console.error(`Delete RdbStore failed, err: ${err}`); + console.error(`Delete RdbStore failed, code is ${err.code},message is ${err.message}`); return; } console.info(`Delete RdbStore successfully.`); @@ -228,7 +231,7 @@ class EntryAbility extends UIAbility { onWindowStageCreate(windowStage){ relationalStore.deleteRdbStore(this.context, "RdbTest.db", function (err) { if (err) { - console.error(`Delete RdbStore failed, err: ${err}`); + console.error(`Delete RdbStore failed, code is ${err.code},message is ${err.message}`); return; } console.info(`Delete RdbStore successfully.`); @@ -262,9 +265,10 @@ Deletes an RDB store. This API uses a promise to return the result. For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). -| **ID**| **Error Message** | -| ------------ | ----------------------- | -| 14800010 | If failed delete database by invalid database name. | +| **ID**| **Error Message** | +| ------------ | ----------------------------------------------------------- | +| 14800010 | Failed to open or delete database by invalid database path. | +| 14800000 | Inner error. | **Example** @@ -280,7 +284,7 @@ let promise = relationalStore.deleteRdbStore(context, "RdbTest.db"); promise.then(()=>{ console.info(`Delete RdbStore successfully.`); }).catch((err) => { - console.error(`Delete RdbStore failed, err: ${err}`); + console.error(`Delete RdbStore failed, code is ${err.code},message is ${err.message}`); }) ``` @@ -295,7 +299,7 @@ class EntryAbility extends UIAbility { promise.then(()=>{ console.info(`Delete RdbStore successfully.`); }).catch((err) => { - console.error(`Delete RdbStore failed, err: ${err}`); + console.error(`Delete RdbStore failed, code is ${err.code},message is ${err.message}`); }) } } @@ -311,7 +315,7 @@ Defines the RDB store configuration. | ------------- | ------------- | ---- | --------------------------------------------------------- | | name | string | Yes | Database file name. | | securityLevel | [SecurityLevel](#securitylevel) | Yes | Security level of the RDB store. | -| encrypt | boolean | No | Whether to encrypt the RDB store.
The value **true** means to encrypt the RDB store;
the value **false** means the opposite.| +| encrypt | boolean | No | Whether to encrypt the RDB store.
The value **true** means to encrypt the RDB store;
the value **false** (default) means the opposite.| ## SecurityLevel @@ -319,7 +323,7 @@ Enumerates the RDB store security levels. > **NOTE** > -> To perform data synchronization operations, the RDB store security level must be lower than or equal to that of the peer device. For details, see the [Cross-Device Data Synchronization Mechanism](../../database/sync-app-data-across-devices-overview.md#cross-device-data-synchronization-mechanism). +> To perform data synchronization operations, the RDB store security level must be lower than or equal to that of the peer device. For details, see the [Cross-Device Data Synchronization Mechanism]( ../../database/sync-app-data-across-devices-overview.md#cross-device-data-synchronization-mechanism). **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core @@ -344,7 +348,7 @@ Defines the data types allowed. ## ValuesBucket -Defines the types of the key and value in a KV pair. +Defines the types of the key and value in a KV pair. This type is not multi-thread safe. If a **ValuesBucket** instance is operated by multiple threads at the same time in an application, use a lock for the instance. **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core @@ -374,10 +378,26 @@ Defines the subscription type. | Name | Value | Description | | --------------------- | ---- | ------------------ | | SUBSCRIBE_TYPE_REMOTE | 0 | Subscribe to remote data changes.| +| SUBSCRIBE_TYPE_CLOUD10+ | 1 | Subscribe to cloud data changes.| + +## ConflictResolution10+ + +Defines the resolution to use when **insert()** and **update()** conflict. + +**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core + +| Name | Value | Description | +| -------------------- | ---- | ------------------------------------------------------------ | +| ON_CONFLICT_NONE | 0 | No operation is performed.| +| ON_CONFLICT_ROLLBACK | 1 | Abort the SQL statement and roll back the current transaction. | +| ON_CONFLICT_ABORT | 2 | Abort the current SQL statement and revert any changes made by the current SQL statement. However, the changes made by the previous SQL statement in the same transaction are retained and the transaction remains active.| +| ON_CONFLICT_FAIL | 3 | Abort the current SQL statement. The **FAIL** resolution does not revert previous changes made by the failed SQL statement or end the transaction.| +| ON_CONFLICT_IGNORE | 4 | Skip the rows that contain constraint violations and continue to process the subsequent rows of the SQL statement.| +| ON_CONFLICT_REPLACE | 5 | Delete pre-existing rows that cause the constraint violation before inserting or updating the current row, and continue to execute the command normally.| ## RdbPredicates -Defines the predicates for an RDB store. This class determines whether the conditional expression for the RDB store is true or false. +Defines the predicates for an RDB store. This class determines whether the conditional expression for the RDB store is true or false. This type is not multi-thread safe. If an **RdbPredicates** instance is operated by multiple threads at the same time in an application, use a lock for the instance. ### constructor @@ -1233,10 +1253,27 @@ predicates.notIn("NAME", ["Lisa", "Rose"]); ## RdbStore -Provides methods to manage an RDB store. +Provides APIs to manage an RDB store. Before using the APIs of this class, use [executeSql](#executesql) to initialize the database table structure and related data. +### Attributes10+ + +**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core + +| Name | Type | Mandatory| Description | +| ------------ | ----------- | ---- | -------------------------------- | +| version10+ | number | Yes | RDB store version, which is an integer greater than 0. | + +**Example** + +```js +// Set the RDB store version. +store.version = 3; +// Obtain the RDB store version. +console.info(`RdbStore version is ${store.version}`); +``` + ### insert insert(table: string, values: ValuesBucket, callback: AsyncCallback<number>):void @@ -1253,6 +1290,15 @@ Inserts a row of data into a table. This API uses an asynchronous callback to re | values | [ValuesBucket](#valuesbucket) | Yes | Row of data to insert. | | callback | AsyncCallback<number> | Yes | Callback invoked to return the result. If the operation is successful, the row ID will be returned. Otherwise, **-1** will be returned.| +**Error codes** + +For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). + +| **ID**| **Error Message** | +| ------------ | -------------------------------------------- | +| 14800047 | The WAL file size exceeds the default limit. | +| 14800000 | Inner error. | + **Example** ```js @@ -1264,13 +1310,56 @@ const valueBucket = { }; store.insert("EMPLOYEE", valueBucket, function (err, rowId) { if (err) { - console.error(`Insert is failed, err: ${err}`); + console.error(`Insert is failed, code is ${err.code},message is ${err.message}`); return; } console.info(`Insert is successful, rowId = ${rowId}`); }) ``` +### insert10+ + +insert(table: string, values: ValuesBucket, conflict: ConflictResolution, callback: AsyncCallback<number>):void + +Inserts a row of data into a table. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------- | ---- | ---------------------------------------------------------- | +| table | string | Yes | Name of the target table. | +| values | [ValuesBucket](#valuesbucket) | Yes | Row of data to insert. | +| conflict | [ConflictResolution](#conflictresolution10) | Yes | Resolution used to resolve the conflict. | +| callback | AsyncCallback<number> | Yes | Callback invoked to return the result. If the operation is successful, the row ID will be returned. Otherwise, **-1** will be returned.| + +**Error codes** + +For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). + +| **ID**| **Error Message** | +| ------------ | -------------------------------------------- | +| 14800047 | The WAL file size exceeds the default limit. | +| 14800000 | Inner error. | + +**Example** + +```js +const valueBucket = { + "NAME": "Lisa", + "AGE": 18, + "SALARY": 100.5, + "CODES": new Uint8Array([1, 2, 3, 4, 5]), +}; +store.insert("EMPLOYEE", valueBucket, relationalStore.ConflictResolution.ON_CONFLICT_REPLACE, function (err, rowId) { + if (err) { + console.error(`Insert is failed, code is ${err.code},message is ${err.message}`); + return; + } + console.info(`Insert is successful, rowId = ${rowId}`); +}) +``` ### insert @@ -1293,6 +1382,15 @@ Inserts a row of data into a table. This API uses a promise to return the result | --------------------- | ------------------------------------------------- | | Promise<number> | Promise used to return the result. If the operation is successful, the row ID will be returned. Otherwise, **-1** will be returned.| +**Error codes** + +For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). + +| **ID**| **Error Message** | +| ------------ | -------------------------------------------- | +| 14800047 | The WAL file size exceeds the default limit. | +| 14800000 | Inner error. | + **Example** ```js @@ -1306,10 +1404,57 @@ let promise = store.insert("EMPLOYEE", valueBucket); promise.then((rowId) => { console.info(`Insert is successful, rowId = ${rowId}`); }).catch((err) => { - console.error(`Insert is failed, err: ${err}`); + console.error(`Insert is failed, code is ${err.code},message is ${err.message}`); }) ``` +### insert10+ + +insert(table: string, values: ValuesBucket, conflict: ConflictResolution):Promise<number> + +Inserts a row of data into a table. This API uses a promise to return the result. + +**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------- | ---- | -------------------------- | +| table | string | Yes | Name of the target table. | +| values | [ValuesBucket](#valuesbucket) | Yes | Row of data to insert.| +| conflict | [ConflictResolution](#conflictresolution10) | Yes | Resolution used to resolve the conflict. | + +**Return value** + +| Type | Description | +| --------------------- | ------------------------------------------------- | +| Promise<number> | Promise used to return the result. If the operation is successful, the row ID will be returned. Otherwise, **-1** will be returned.| + +**Error codes** + +For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). + +| **ID**| **Error Message** | +| ------------ | -------------------------------------------- | +| 14800047 | The WAL file size exceeds the default limit. | +| 14800000 | Inner error. | + +**Example** + +```js +const valueBucket = { + "NAME": "Lisa", + "AGE": 18, + "SALARY": 100.5, + "CODES": new Uint8Array([1, 2, 3, 4, 5]), +}; +let promise = store.insert("EMPLOYEE", valueBucket, relationalStore.ConflictResolution.ON_CONFLICT_REPLACE); +promise.then((rowId) => { + console.info(`Insert is successful, rowId = ${rowId}`); +}).catch((err) => { + console.error(`Insert is failed, code is ${err.code},message is ${err.message}`); +}) +``` ### batchInsert @@ -1327,6 +1472,15 @@ Batch inserts data into a table. This API uses an asynchronous callback to retur | values | Array<[ValuesBucket](#valuesbucket)> | Yes | An array of data to insert. | | callback | AsyncCallback<number> | Yes | Callback invoked to return the result. If the operation is successful, the number of inserted data records is returned. Otherwise, **-1** is returned.| +**Error codes** + +For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). + +| **ID**| **Error Message** | +| ------------ | -------------------------------------------- | +| 14800047 | The WAL file size exceeds the default limit. | +| 14800000 | Inner error. | + **Example** ```js @@ -1352,7 +1506,7 @@ const valueBucket3 = { let valueBuckets = new Array(valueBucket1, valueBucket2, valueBucket3); store.batchInsert("EMPLOYEE", valueBuckets, function(err, insertNum) { if (err) { - console.error(`batchInsert is failed, err: ${err}`); + console.error(`batchInsert is failed, code is ${err.code},message is ${err.message}`); return; } console.info(`batchInsert is successful, the number of values that were inserted = ${insertNum}`); @@ -1380,6 +1534,15 @@ Batch inserts data into a table. This API uses a promise to return the result. | --------------------- | ----------------------------------------------------------- | | Promise<number> | Promise used to return the result. If the operation is successful, the number of inserted data records is returned. Otherwise, **-1** is returned.| +**Error codes** + +For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). + +| **ID**| **Error Message** | +| ------------ | -------------------------------------------- | +| 14800047 | The WAL file size exceeds the default limit. | +| 14800000 | Inner error. | + **Example** ```js @@ -1407,7 +1570,7 @@ let promise = store.batchInsert("EMPLOYEE", valueBuckets); promise.then((insertNum) => { console.info(`batchInsert is successful, the number of values that were inserted = ${insertNum}`); }).catch((err) => { - console.error(`batchInsert is failed, err: ${err}`); + console.error(`batchInsert is failed, code is ${err.code},message is ${err.message}`); }) ``` @@ -1427,6 +1590,15 @@ Updates data in the RDB store based on the specified **RdbPredicates** object. T | predicates | [RdbPredicates](#rdbpredicates) | Yes | Update conditions specified by the **RdbPredicates** object. | | callback | AsyncCallback<number> | Yes | Callback invoked to return the number of rows updated. | +**Error codes** + +For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). + +| **ID**| **Error Message** | +| ------------ | -------------------------------------------- | +| 14800047 | The WAL file size exceeds the default limit. | +| 14800000 | Inner error. | + **Example** ```js @@ -1440,13 +1612,58 @@ let predicates = new relationalStore.RdbPredicates("EMPLOYEE"); predicates.equalTo("NAME", "Lisa"); store.update(valueBucket, predicates, function (err, rows) { if (err) { - console.error(`Updated failed, err: ${err}`); + console.error(`Updated failed, code is ${err.code},message is ${err.message}`); return; } console.info(`Updated row count: ${rows}`); }) ``` +### update10+ + +update(values: ValuesBucket, predicates: RdbPredicates, conflict: ConflictResolution, callback: AsyncCallback<number>):void + +Updates data in the RDB store based on the specified **RdbPredicates** object. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ------------------------------------------- | ---- | ------------------------------------------------------------ | +| values | [ValuesBucket](#valuesbucket) | Yes | Rows of data to update in the RDB store. The key-value pair is associated with the column name in the target table.| +| predicates | [RdbPredicates](#rdbpredicates) | Yes | Update conditions specified by the **RdbPredicates** object. | +| conflict | [ConflictResolution](#conflictresolution10) | Yes | Resolution used to resolve the conflict. | +| callback | AsyncCallback<number> | Yes | Callback invoked to return the number of rows updated. | + +**Error codes** + +For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). + +| **ID**| **Error Message** | +| ------------ | -------------------------------------------- | +| 14800047 | The WAL file size exceeds the default limit. | +| 14800000 | Inner error. | + +**Example** + +```js +const valueBucket = { + "NAME": "Rose", + "AGE": 22, + "SALARY": 200.5, + "CODES": new Uint8Array([1, 2, 3, 4, 5]), +}; +let predicates = new relationalStore.RdbPredicates("EMPLOYEE"); +predicates.equalTo("NAME", "Lisa"); +store.update(valueBucket, predicates, relationalStore.ConflictResolution.ON_CONFLICT_REPLACE, function (err, rows) { + if (err) { + console.error(`Updated failed, code is ${err.code},message is ${err.message}`); + return; + } + console.info(`Updated row count: ${rows}`); +}) +``` ### update @@ -1469,6 +1686,15 @@ Updates data based on the specified **RdbPredicates** object. This API uses a pr | --------------------- | ----------------------------------------- | | Promise<number> | Promise used to return the number of rows updated.| +**Error codes** + +For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). + +| **ID**| **Error Message** | +| ------------ | -------------------------------------------- | +| 14800047 | The WAL file size exceeds the default limit. | +| 14800000 | Inner error. | + **Example** ```js @@ -1484,10 +1710,59 @@ let promise = store.update(valueBucket, predicates); promise.then(async (rows) => { console.info(`Updated row count: ${rows}`); }).catch((err) => { - console.error(`Updated failed, err: ${err}`); + console.error(`Updated failed, code is ${err.code},message is ${err.message}`); }) ``` +### update10+ + +update(values: ValuesBucket, predicates: RdbPredicates, conflict: ConflictResolution):Promise<number> + +Updates data based on the specified **RdbPredicates** object. This API uses a promise to return the result. + +**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ------------------------------------------- | ---- | ------------------------------------------------------------ | +| values | [ValuesBucket](#valuesbucket) | Yes | Rows of data to update in the RDB store. The key-value pair is associated with the column name in the target table.| +| predicates | [RdbPredicates](#rdbpredicates) | Yes | Update conditions specified by the **RdbPredicates** object. | +| conflict | [ConflictResolution](#conflictresolution10) | Yes | Resolution used to resolve the conflict. | + +**Return value** + +| Type | Description | +| --------------------- | ----------------------------------------- | +| Promise<number> | Promise used to return the number of rows updated.| + +**Error codes** + +For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). + +| **ID**| **Error Message** | +| ------------ | -------------------------------------------- | +| 14800047 | The WAL file size exceeds the default limit. | +| 14800000 | Inner error. | + +**Example** + +```js +const valueBucket = { + "NAME": "Rose", + "AGE": 22, + "SALARY": 200.5, + "CODES": new Uint8Array([1, 2, 3, 4, 5]), +}; +let predicates = new relationalStore.RdbPredicates("EMPLOYEE"); +predicates.equalTo("NAME", "Lisa"); +let promise = store.update(valueBucket, predicates, relationalStore.ConflictResolution.ON_CONFLICT_REPLACE); +promise.then(async (rows) => { + console.info(`Updated row count: ${rows}`); +}).catch((err) => { + console.error(`Updated failed, code is ${err.code},message is ${err.message}`); +}) +``` ### update @@ -1497,6 +1772,8 @@ Updates data based on the specified **DataSharePredicates** object. This API use **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core +**Model restriction**: This API can be used only in the stage model. + **System API**: This is a system API. **Parameters** @@ -1508,6 +1785,15 @@ Updates data based on the specified **DataSharePredicates** object. This API use | predicates | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes | Update conditions specified by the **DataSharePredicates** object. | | callback | AsyncCallback<number> | Yes | Callback invoked to return the number of rows updated. | +**Error codes** + +For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). + +| **ID**| **Error Message** | +| ------------ | -------------------------------------------- | +| 14800047 | The WAL file size exceeds the default limit. | +| 14800000 | Inner error. | + **Example** ```js @@ -1522,7 +1808,7 @@ let predicates = new dataSharePredicates.DataSharePredicates(); predicates.equalTo("NAME", "Lisa"); store.update("EMPLOYEE", valueBucket, predicates, function (err, rows) { if (err) { - console.error(`Updated failed, err: ${err}`); + console.error(`Updated failed, code is ${err.code},message is ${err.message}`); return; } console.info(`Updated row count: ${rows}`); @@ -1537,6 +1823,8 @@ Updates data based on the specified **DataSharePredicates** object. This API use **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core +**Model restriction**: This API can be used only in the stage model. + **System API**: This is a system API. **Parameters** @@ -1553,6 +1841,15 @@ Updates data based on the specified **DataSharePredicates** object. This API use | --------------------- | ----------------------------------------- | | Promise<number> | Promise used to return the number of rows updated.| +**Error codes** + +For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). + +| **ID**| **Error Message** | +| ------------ | -------------------------------------------- | +| 14800047 | The WAL file size exceeds the default limit. | +| 14800000 | Inner error. | + **Example** ```js @@ -1569,7 +1866,7 @@ let promise = store.update("EMPLOYEE", valueBucket, predicates); promise.then(async (rows) => { console.info(`Updated row count: ${rows}`); }).catch((err) => { - console.error(`Updated failed, err: ${err}`); + console.error(`Updated failed, code is ${err.code},message is ${err.message}`); }) ``` @@ -1588,6 +1885,15 @@ Deletes data from the RDB store based on the specified **RdbPredicates** object. | predicates | [RdbPredicates](#rdbpredicates) | Yes | Conditions specified by the **RdbPredicates** object for deleting data.| | callback | AsyncCallback<number> | Yes | Callback invoked to return the number of rows deleted. | +**Error codes** + +For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). + +| **ID**| **Error Message** | +| ------------ | -------------------------------------------- | +| 14800047 | The WAL file size exceeds the default limit. | +| 14800000 | Inner error. | + **Example** ```js @@ -1595,7 +1901,7 @@ let predicates = new relationalStore.RdbPredicates("EMPLOYEE"); predicates.equalTo("NAME", "Lisa"); store.delete(predicates, function (err, rows) { if (err) { - console.error(`Delete failed, err: ${err}`); + console.error(`Delete failed, code is ${err.code},message is ${err.message}`); return; } console.info(`Delete rows: ${rows}`); @@ -1620,7 +1926,16 @@ Deletes data from the RDB store based on the specified **RdbPredicates** object. | Type | Description | | --------------------- | ------------------------------- | -| Promise<number> | Promise used to return the number of rows deleted. | +| Promise<number> | Promise used to return the number of rows deleted.| + +**Error codes** + +For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). + +| **ID**| **Error Message** | +| ------------ | -------------------------------------------- | +| 14800047 | The WAL file size exceeds the default limit. | +| 14800000 | Inner error. | **Example** @@ -1631,7 +1946,7 @@ let promise = store.delete(predicates); promise.then((rows) => { console.info(`Delete rows: ${rows}`); }).catch((err) => { - console.error(`Delete failed, err: ${err}`); + console.error(`Delete failed, code is ${err.code},message is ${err.message}`); }) ``` @@ -1643,6 +1958,8 @@ Deletes data from the RDB store based on the specified **DataSharePredicates** o **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core +**Model restriction**: This API can be used only in the stage model. + **System API**: This is a system API. **Parameters** @@ -1651,7 +1968,16 @@ Deletes data from the RDB store based on the specified **DataSharePredicates** o | ---------- | ------------------------------------------------------------ | ---- | --------------------------------------------- | | table | string | Yes | Name of the target table. | | predicates | [dataSharePredicates.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 deleted. | +| callback | AsyncCallback<number> | Yes | Callback invoked to return the number of rows deleted. | + +**Error codes** + +For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). + +| **ID**| **Error Message** | +| ------------ | -------------------------------------------- | +| 14800047 | The WAL file size exceeds the default limit. | +| 14800000 | Inner error. | **Example** @@ -1661,7 +1987,7 @@ let predicates = new dataSharePredicates.DataSharePredicates(); predicates.equalTo("NAME", "Lisa"); store.delete("EMPLOYEE", predicates, function (err, rows) { if (err) { - console.error(`Delete failed, err: ${err}`); + console.error(`Delete failed, code is ${err.code},message is ${err.message}`); return; } console.info(`Delete rows: ${rows}`); @@ -1676,6 +2002,8 @@ Deletes data from the RDB store based on the specified **DataSharePredicates** o **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core +**Model restriction**: This API can be used only in the stage model. + **System API**: This is a system API. **Parameters** @@ -1691,6 +2019,15 @@ Deletes data from the RDB store based on the specified **DataSharePredicates** o | --------------------- | ------------------------------- | | Promise<number> | Promise used to return the number of rows deleted.| +**Error codes** + +For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). + +| **ID**| **Error Message** | +| ------------ | -------------------------------------------- | +| 14800047 | The WAL file size exceeds the default limit. | +| 14800000 | Inner error. | + **Example** ```js @@ -1701,7 +2038,7 @@ let promise = store.delete("EMPLOYEE", predicates); promise.then((rows) => { console.info(`Delete rows: ${rows}`); }).catch((err) => { - console.error(`Delete failed, err: ${err}`); + console.error(`Delete failed, code is ${err.code},message is ${err.message}`); }) ``` @@ -1721,6 +2058,14 @@ Queries data from the RDB store based on specified conditions. This API uses an | columns | Array<string> | Yes | Columns to query. If this parameter is not specified, the query applies to all columns. | | callback | AsyncCallback<[ResultSet](#resultset)> | Yes | Callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned.| +**Error codes** + +For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). + +| **ID**| **Error Message** | +| ------------ | ---------------------------- | +| 14800000 | Inner error. | + **Example** ```js @@ -1728,11 +2073,20 @@ let predicates = new relationalStore.RdbPredicates("EMPLOYEE"); predicates.equalTo("NAME", "Rose"); store.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"], function (err, resultSet) { if (err) { - console.error(`Query failed, err: ${err}`); + console.error(`Query failed, code is ${err.code},message is ${err.message}`); return; } - console.info(`ResultSet column names: ${resultSet.columnNames}`); - console.info(`ResultSet column count: ${resultSet.columnCount}`); + console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`); + // resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0. + while(resultSet.goToNextRow()) { + const id = resultSet.getLong(resultSet.getColumnIndex("ID")); + const name = resultSet.getString(resultSet.getColumnIndex("NAME")); + const age = resultSet.getLong(resultSet.getColumnIndex("AGE")); + const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY")); + console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`); + } + // Release the dataset memory. + resultSet.close(); }) ``` @@ -1751,6 +2105,14 @@ Queries data from the RDB store based on specified conditions. This API uses a p | predicates | [RdbPredicates](#rdbpredicates) | Yes | Query conditions specified by the **RdbPredicates** object. | | columns | Array<string> | No | Columns to query. If this parameter is not specified, the query applies to all columns.| +**Error codes** + +For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). + +| **ID**| **Error Message** | +| ------------ | ---------------------------- | +| 14800000 | Inner error. | + **Return value** | Type | Description | @@ -1764,10 +2126,19 @@ let predicates = new relationalStore.RdbPredicates("EMPLOYEE"); predicates.equalTo("NAME", "Rose"); let promise = store.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]); promise.then((resultSet) => { - console.info(`ResultSet column names: ${resultSet.columnNames}`); - console.info(`ResultSet column count: ${resultSet.columnCount}`); + console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`); + // resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0. + while(resultSet.goToNextRow()) { + const id = resultSet.getLong(resultSet.getColumnIndex("ID")); + const name = resultSet.getString(resultSet.getColumnIndex("NAME")); + const age = resultSet.getLong(resultSet.getColumnIndex("AGE")); + const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY")); + console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`); + } + // Release the dataset memory. + resultSet.close(); }).catch((err) => { - console.error(`Query failed, err: ${err}`); + console.error(`Query failed, code is ${err.code},message is ${err.message}`); }) ``` @@ -1779,6 +2150,8 @@ Queries data from the RDB store based on specified conditions. This API uses an **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core +**Model restriction**: This API can be used only in the stage model. + **System API**: This is a system API. **Parameters** @@ -1790,6 +2163,14 @@ Queries data from the RDB store based on specified conditions. This API uses an | columns | Array<string> | Yes | Columns to query. If this parameter is not specified, the query applies to all columns. | | callback | AsyncCallback<[ResultSet](#resultset)> | Yes | Callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned.| +**Error codes** + +For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). + +| **ID**| **Error Message** | +| ------------ | ---------------------------- | +| 14800000 | Inner error. | + **Example** ```js @@ -1798,11 +2179,20 @@ let predicates = new dataSharePredicates.DataSharePredicates(); predicates.equalTo("NAME", "Rose"); store.query("EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"], function (err, resultSet) { if (err) { - console.error(`Query failed, err: ${err}`); + console.error(`Query failed, code is ${err.code},message is ${err.message}`); return; } - console.info(`ResultSet column names: ${resultSet.columnNames}`); - console.info(`ResultSet column count: ${resultSet.columnCount}`); + console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`); + // resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0. + while(resultSet.goToNextRow()) { + const id = resultSet.getLong(resultSet.getColumnIndex("ID")); + const name = resultSet.getString(resultSet.getColumnIndex("NAME")); + const age = resultSet.getLong(resultSet.getColumnIndex("AGE")); + const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY")); + console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`); + } + // Release the dataset memory. + resultSet.close(); }) ``` @@ -1814,6 +2204,8 @@ Queries data from the RDB store based on specified conditions. This API uses a p **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core +**Model restriction**: This API can be used only in the stage model. + **System API**: This is a system API. **Parameters** @@ -1830,6 +2222,14 @@ Queries data from the RDB store based on specified conditions. This API uses a p | ------------------------------------------------------- | -------------------------------------------------- | | Promise<[ResultSet](#resultset)> | Promise used to return the result. If the operation is successful, a **ResultSet** object will be returned.| +**Error codes** + +For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). + +| **ID**| **Error Message** | +| ------------ | ---------------------------- | +| 14800000 | Inner error. | + **Example** ```js @@ -1838,10 +2238,19 @@ let predicates = new dataSharePredicates.DataSharePredicates(); predicates.equalTo("NAME", "Rose"); let promise = store.query("EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]); promise.then((resultSet) => { - console.info(`ResultSet column names: ${resultSet.columnNames}`); - console.info(`ResultSet column count: ${resultSet.columnCount}`); + console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`); + // resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0. + while(resultSet.goToNextRow()) { + const id = resultSet.getLong(resultSet.getColumnIndex("ID")); + const name = resultSet.getString(resultSet.getColumnIndex("NAME")); + const age = resultSet.getLong(resultSet.getColumnIndex("AGE")); + const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY")); + console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`); + } + // Release the dataset memory. + resultSet.close(); }).catch((err) => { - console.error(`Query failed, err: ${err}`); + console.error(`Query failed, code is ${err.code},message is ${err.message}`); }) ``` @@ -1851,7 +2260,7 @@ remoteQuery(device: string, table: string, predicates: RdbPredicates, columns: A Queries data from the RDB store of a remote device based on specified conditions. This API uses an asynchronous callback to return the result. -> **NOTE** +> **NOTE**
> > The value of **device** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications. @@ -1867,6 +2276,14 @@ Queries data from the RDB store of a remote device based on specified conditions | columns | Array<string> | Yes | Columns to query. If this parameter is not specified, the query applies to all columns. | | callback | AsyncCallback<[ResultSet](#resultset)> | Yes | Callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned.| +**Error codes** + +For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). + +| **ID**| **Error Message** | +| ------------ | ---------------------------- | +| 14800000 | Inner error. | + **Example** ```js @@ -1889,11 +2306,20 @@ predicates.greaterThan("id", 0); store.remoteQuery(deviceId, "EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"], function(err, resultSet) { if (err) { - console.error(`Failed to remoteQuery, err: ${err}`); + console.error(`Failed to remoteQuery, code is ${err.code},message is ${err.message}`); return; } - console.info(`ResultSet column names: ${resultSet.columnNames}`); - console.info(`ResultSet column count: ${resultSet.columnCount}`); + console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`); + // resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0. + while(resultSet.goToNextRow()) { + const id = resultSet.getLong(resultSet.getColumnIndex("ID")); + const name = resultSet.getString(resultSet.getColumnIndex("NAME")); + const age = resultSet.getLong(resultSet.getColumnIndex("AGE")); + const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY")); + console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`); + } + // Release the dataset memory. + resultSet.close(); } ) ``` @@ -1904,7 +2330,7 @@ remoteQuery(device: string, table: string, predicates: RdbPredicates, columns: A Queries data from the RDB store of a remote device based on specified conditions. This API uses a promise to return the result. -> **NOTE** +> **NOTE**
> > The value of **device** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications. @@ -1925,6 +2351,14 @@ Queries data from the RDB store of a remote device based on specified conditions | ------------------------------------------------------------ | -------------------------------------------------- | | Promise<[ResultSet](#resultset)> | Promise used to return the result. If the operation is successful, a **ResultSet** object will be returned.| +**Error codes** + +For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). + +| **ID**| **Error Message** | +| ------------ | ---------------------------- | +| 14800000 | Inner error. | + **Example** ```js @@ -1946,10 +2380,19 @@ let predicates = new relationalStore.RdbPredicates('EMPLOYEE'); predicates.greaterThan("id", 0); let promise = store.remoteQuery(deviceId, "EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]); promise.then((resultSet) => { - console.info(`ResultSet column names: ${resultSet.columnNames}`); - console.info(`ResultSet column count: ${resultSet.columnCount}`); + console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`); + // resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0. + while(resultSet.goToNextRow()) { + const id = resultSet.getLong(resultSet.getColumnIndex("ID")); + const name = resultSet.getString(resultSet.getColumnIndex("NAME")); + const age = resultSet.getLong(resultSet.getColumnIndex("AGE")); + const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY")); + console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`); + } + // Release the dataset memory. + resultSet.close(); }).catch((err) => { - console.error(`Failed to remoteQuery, err: ${err}`); + console.error(`Failed to remoteQuery, code is ${err.code},message is ${err.message}`); }) ``` @@ -1969,16 +2412,33 @@ Queries data using the specified SQL statement. This API uses an asynchronous ca | bindArgs | Array<[ValueType](#valuetype)> | Yes | Arguments in the SQL statement. The value corresponds to the placeholders in the SQL parameter statement. If the SQL parameter statement is complete, the value of this parameter must be an empty array.| | callback | AsyncCallback<[ResultSet](#resultset)> | Yes | Callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned. | +**Error codes** + +For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). + +| **ID**| **Error Message** | +| ------------ | ---------------------------- | +| 14800000 | Inner error. | + **Example** ```js store.querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = ?", ['sanguo'], function (err, resultSet) { if (err) { - console.error(`Query failed, err: ${err}`); + console.error(`Query failed, code is ${err.code},message is ${err.message}`); return; } - console.info(`ResultSet column names: ${resultSet.columnNames}`); - console.info(`ResultSet column count: ${resultSet.columnCount}`); + console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`); + // resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0. + while(resultSet.goToNextRow()) { + const id = resultSet.getLong(resultSet.getColumnIndex("ID")); + const name = resultSet.getString(resultSet.getColumnIndex("NAME")); + const age = resultSet.getLong(resultSet.getColumnIndex("AGE")); + const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY")); + console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`); + } + // Release the dataset memory. + resultSet.close(); }) ``` @@ -2003,15 +2463,32 @@ Queries data using the specified SQL statement. This API uses a promise to retur | ------------------------------------------------------- | -------------------------------------------------- | | Promise<[ResultSet](#resultset)> | Promise used to return the result. If the operation is successful, a **ResultSet** object will be returned.| +**Error codes** + +For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). + +| **ID**| **Error Message** | +| ------------ | ---------------------------- | +| 14800000 | Inner error. | + **Example** ```js let promise = store.querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = 'sanguo'"); promise.then((resultSet) => { - console.info(`ResultSet column names: ${resultSet.columnNames}`); - console.info(`ResultSet column count: ${resultSet.columnCount}`); + console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`); + // resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0. + while(resultSet.goToNextRow()) { + const id = resultSet.getLong(resultSet.getColumnIndex("ID")); + const name = resultSet.getString(resultSet.getColumnIndex("NAME")); + const age = resultSet.getLong(resultSet.getColumnIndex("AGE")); + const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY")); + console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`); + } + // Release the dataset memory. + resultSet.close(); }).catch((err) => { - console.error(`Query failed, err: ${err}`); + console.error(`Query failed, code is ${err.code},message is ${err.message}`); }) ``` @@ -2031,13 +2508,22 @@ Executes an SQL statement that contains specified arguments but returns no value | bindArgs | Array<[ValueType](#valuetype)> | Yes | Arguments in the SQL statement. The value corresponds to the placeholders in the SQL parameter statement. If the SQL parameter statement is complete, the value of this parameter must be an empty array.| | callback | AsyncCallback<void> | Yes | Callback invoked to return the result. | +**Error codes** + +For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). + +| **ID**| **Error Message** | +| ------------ | -------------------------------------------- | +| 14800047 | The WAL file size exceeds the default limit. | +| 14800000 | Inner error. | + **Example** ```js const SQL_DELETE_TABLE = "DELETE FROM test WHERE name = ?" store.executeSql(SQL_DELETE_TABLE, ['zhangsan'], function(err) { if (err) { - console.error(`ExecuteSql failed, err: ${err}`); + console.error(`ExecuteSql failed, code is ${err.code},message is ${err.message}`); return; } console.info(`Delete table done.`); @@ -2065,6 +2551,15 @@ Executes an SQL statement that contains specified arguments but returns no value | ------------------- | ------------------------- | | Promise<void> | Promise that returns no value.| +**Error codes** + +For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). + +| **ID**| **Error Message** | +| ------------ | -------------------------------------------- | +| 14800047 | The WAL file size exceeds the default limit. | +| 14800000 | Inner error. | + **Example** ```js @@ -2073,7 +2568,7 @@ let promise = store.executeSql(SQL_DELETE_TABLE); promise.then(() => { console.info(`Delete table done.`); }).catch((err) => { - console.error(`ExecuteSql failed, err: ${err}`); + console.error(`ExecuteSql failed, code is ${err.code},message is ${err.message}`); }) ``` @@ -2085,6 +2580,15 @@ Starts the transaction before executing an SQL statement. **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core +**Error codes** + +For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). + +| **ID**| **Error Message** | +| ------------ | -------------------------------------------- | +| 14800047 | The WAL file size exceeds the default limit. | +| 14800000 | Inner error. | + **Example** ```js @@ -2096,7 +2600,7 @@ const STORE_CONFIG = { }; relationalStore.getRdbStore(context, STORE_CONFIG, async function (err, store) { if (err) { - console.error(`GetRdbStore failed, err: ${err}`); + console.error(`GetRdbStore failed, code is ${err.code},message is ${err.message}`); return; } store.beginTransaction(); @@ -2130,7 +2634,7 @@ const STORE_CONFIG = { }; relationalStore.getRdbStore(context, STORE_CONFIG, async function (err, store) { if (err) { - console.error(`GetRdbStore failed, err: ${err}`); + console.error(`GetRdbStore failed, code is ${err.code},message is ${err.message}`); return; } store.beginTransaction(); @@ -2164,7 +2668,7 @@ const STORE_CONFIG = { }; relationalStore.getRdbStore(context, STORE_CONFIG, async function (err, store) { if (err) { - console.error(`GetRdbStore failed, err: ${err}`); + console.error(`GetRdbStore failed, code is ${err.code},message is ${err.message}`); return; } try { @@ -2179,7 +2683,7 @@ relationalStore.getRdbStore(context, STORE_CONFIG, async function (err, store) { await store.insert("test", valueBucket); store.commit(); } catch (err) { - console.error(`Transaction failed, err: ${err}`); + console.error(`Transaction failed, code is ${err.code},message is ${err.message}`); store.rollBack(); } }) @@ -2200,12 +2704,20 @@ Backs up an RDB store. This API uses an asynchronous callback to return the resu | destName | string | Yes | Name of the RDB store backup file.| | callback | AsyncCallback<void> | Yes | Callback invoked to return the result. | +**Error codes** + +For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). + +| **ID**| **Error Message** | +| ------------ | ---------------------------- | +| 14800000 | Inner error. | + **Example** ```js store.backup("dbBackup.db", function(err) { if (err) { - console.error(`Backup failed, err: ${err}`); + console.error(`Backup failed, code is ${err.code},message is ${err.message}`); return; } console.info(`Backup success.`); @@ -2232,6 +2744,14 @@ Backs up an RDB store. This API uses a promise to return the result. | ------------------- | ------------------------- | | Promise<void> | Promise that returns no value.| +**Error codes** + +For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). + +| **ID**| **Error Message** | +| ------------ | ---------------------------- | +| 14800000 | Inner error. | + **Example** ```js @@ -2239,7 +2759,7 @@ let promiseBackup = store.backup("dbBackup.db"); promiseBackup.then(()=>{ console.info(`Backup success.`); }).catch((err)=>{ - console.error(`Backup failed, err: ${err}`); + console.error(`Backup failed, code is ${err.code},message is ${err.message}`); }) ``` @@ -2258,12 +2778,20 @@ Restores an RDB store from a backup file. This API uses an asynchronous callback | srcName | string | Yes | Name of the RDB store backup file.| | callback | AsyncCallback<void> | Yes | Callback invoked to return the result. | +**Error codes** + +For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). + +| **ID**| **Error Message** | +| ------------ | ---------------------------- | +| 14800000 | Inner error. | + **Example** ```js store.restore("dbBackup.db", function(err) { if (err) { - console.error(`Restore failed, err: ${err}`); + console.error(`Restore failed, code is ${err.code},message is ${err.message}`); return; } console.info(`Restore success.`); @@ -2290,6 +2818,14 @@ Restores an RDB store from a backup file. This API uses a promise to return the | ------------------- | ------------------------- | | Promise<void> | Promise that returns no value.| +**Error codes** + +For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). + +| **ID**| **Error Message** | +| ------------ | ---------------------------- | +| 14800000 | Inner error. | + **Example** ```js @@ -2297,7 +2833,7 @@ let promiseRestore = store.restore("dbBackup.db"); promiseRestore.then(()=>{ console.info(`Restore success.`); }).catch((err)=>{ - console.error(`Restore failed, err: ${err}`); + console.error(`Restore failed, code is ${err.code},message is ${err.message}`); }) ``` @@ -2318,12 +2854,20 @@ Sets distributed tables. This API uses an asynchronous callback to return the re | tables | Array<string> | Yes | Names of the distributed tables to set.| | callback | AsyncCallback<void> | Yes | Callback invoked to return the result.| +**Error codes** + +For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). + +| **ID**| **Error Message** | +| ------------ | ---------------------------- | +| 14800000 | Inner error. | + **Example** ```js store.setDistributedTables(["EMPLOYEE"], function (err) { if (err) { - console.error(`SetDistributedTables failed, err: ${err}`); + console.error(`SetDistributedTables failed, code is ${err.code},message is ${err.message}`); return; } console.info(`SetDistributedTables successfully.`); @@ -2352,6 +2896,14 @@ Sets distributed tables. This API uses a promise to return the result. | ------------------- | ------------------------- | | Promise<void> | Promise that returns no value.| +**Error codes** + +For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). + +| **ID**| **Error Message** | +| ------------ | ---------------------------- | +| 14800000 | Inner error. | + **Example** ```js @@ -2359,7 +2911,7 @@ let promise = store.setDistributedTables(["EMPLOYEE"]); promise.then(() => { console.info(`SetDistributedTables successfully.`); }).catch((err) => { - console.error(`SetDistributedTables failed, err: ${err}`); + console.error(`SetDistributedTables failed, code is ${err.code},message is ${err.message}`); }) ``` @@ -2385,6 +2937,14 @@ Obtains the distributed table name of a remote device based on the local table n | table | string | Yes | Local table name of the remote device. | | callback | AsyncCallback<string> | Yes | Callback invoked to return the result. If the operation succeeds, the distributed table name of the remote device is returned.| +**Error codes** + +For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). + +| **ID**| **Error Message** | +| ------------ | ---------------------------- | +| 14800000 | Inner error. | + **Example** ```js @@ -2404,7 +2964,7 @@ deviceManager.createDeviceManager("com.example.appdatamgrverify", (err, manager) store.obtainDistributedTableName(deviceId, "EMPLOYEE", function (err, tableName) { if (err) { - console.error(`ObtainDistributedTableName failed, err: ${err}`); + console.error(`ObtainDistributedTableName failed, code is ${err.code},message is ${err.message}`); return; } console.info(`ObtainDistributedTableName successfully, tableName= ${tableName}`); @@ -2438,6 +2998,14 @@ Obtains the distributed table name of a remote device based on the local table n | --------------------- | ----------------------------------------------------- | | Promise<string> | Promise used to return the result. If the operation succeeds, the distributed table name of the remote device is returned.| +**Error codes** + +For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). + +| **ID**| **Error Message** | +| ------------ | ---------------------------- | +| 14800000 | Inner error. | + **Example** ```js @@ -2459,7 +3027,7 @@ let promise = store.obtainDistributedTableName(deviceId, "EMPLOYEE"); promise.then((tableName) => { console.info(`ObtainDistributedTableName successfully, tableName= ${tableName}`); }).catch((err) => { - console.error(`ObtainDistributedTableName failed, err: ${err}`); + console.error(`ObtainDistributedTableName failed, code is ${err.code},message is ${err.message}`); }) ``` @@ -2481,6 +3049,14 @@ Synchronizes data between devices. This API uses an asynchronous callback to ret | predicates | [RdbPredicates](#rdbpredicates) | Yes | **RdbPredicates** object that specifies the data and devices to synchronize. | | callback | AsyncCallback<Array<[string, number]>> | Yes | Callback invoked to send the synchronization result to the caller.
**string** indicates the device ID.
**number** indicates the synchronization status of that device. The value **0** indicates a successful synchronization. Other values indicate a synchronization failure. | +**Error codes** + +For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). + +| **ID**| **Error Message** | +| ------------ | ---------------------------- | +| 14800000 | Inner error. | + **Example** ```js @@ -2504,7 +3080,7 @@ let predicates = new relationalStore.RdbPredicates('EMPLOYEE'); predicates.inDevices(deviceIds); store.sync(relationalStore.SyncMode.SYNC_MODE_PUSH, predicates, function (err, result) { if (err) { - console.error(`Sync failed, err: ${err}`); + console.error(`Sync failed, code is ${err.code},message is ${err.message}`); return; } console.info(`Sync done.`); @@ -2537,6 +3113,14 @@ Synchronizes data between devices. This API uses a promise to return the result. | -------------------------------------------- | ------------------------------------------------------------ | | Promise<Array<[string, number]>> | Promise used to send the synchronization result.
**string** indicates the device ID.
**number** indicates the synchronization status of that device. The value **0** indicates a successful synchronization. Other values indicate a synchronization failure. | +**Error codes** + +For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md). + +| **ID**| **Error Message** | +| ------------ | ---------------------------- | +| 14800000 | Inner error. | + **Example** ```js @@ -2565,7 +3149,7 @@ promise.then((result) =>{ console.info(`device= ${result[i][0]}, status= ${result[i][1]}`); } }).catch((err) => { - console.error(`Sync failed, err: ${err}`); + console.error(`Sync failed, code is ${err.code},message is ${err.message}`); }) ``` @@ -2581,9 +3165,9 @@ Registers an observer for this RDB store. When the data in the RDB store changes | Name | Type | Mandatory| Description | | -------- | ----------------------------------- | ---- | ------------------------------------------- | -| event | string | Yes | Event to observe. The value is **dataChange**, which indicates a data change event. | +| event | string | Yes | Event to observe. The value is **dataChange**, which indicates a data change event. | | type | [SubscribeType](#subscribetype) | Yes | Subscription type to register.| -| observer | Callback<Array<string>> | Yes | Callback invoked to return the data change. | +| observer | Callback<Array<string>> | Yes | Callback invoked to return the data change event. **Array** indicates the IDs of the peer devices whose data in the database is changed.| **Example** @@ -2596,7 +3180,7 @@ function storeObserver(devices) { try { store.on('dataChange', relationalStore.SubscribeType.SUBSCRIBE_TYPE_REMOTE, storeObserver); } catch (err) { - console.error(`Register observer failed, err: ${err}`); + console.error(`Register observer failed, code is ${err.code},message is ${err.message}`); } ``` @@ -2612,9 +3196,9 @@ Unregisters the observer of the specified type from the RDB store. This API uses | Name | Type | Mandatory| Description | | -------- | ---------------------------------- | ---- | ------------------------------------------ | -| event | string | Yes | Event to observe. The value is **dataChange**, which indicates a data change event. | -| type | [SubscribeType](#subscribetype) | Yes | Subscription type to unregister. | -| observer | Callback<Array<string>> | Yes | Callback for the data change. | +| event | string | Yes | Event type. The value is **dataChange**, which indicates a data change event. | +| type | [SubscribeType](#subscribetype) | Yes | Subscription type to unregister. | +| observer | Callback<Array<string>> | Yes | Callback for the data change event. **Array** indicates the IDs of the peer devices whose data in the database is changed.| **Example** @@ -2627,7 +3211,7 @@ function storeObserver(devices) { try { store.off('dataChange', relationalStore.SubscribeType.SUBSCRIBE_TYPE_REMOTE, storeObserver); } catch (err) { - console.error(`Unregister observer failed, err: ${err}`); + console.error(`Unregister observer failed, code is ${err.code},message is ${err.message}`); } ``` @@ -2767,7 +3351,7 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode | **ID**| **Error Message** | | ------------ | ------------------------------------------------------------ | -| 14800012 | The result set is empty or the specified location is invalid. | +| 14800012 | The result set is empty or the specified location is invalid. | **Example** @@ -2778,7 +3362,7 @@ promise.then((resultSet) => { resultSet.goTo(1); resultSet.close(); }).catch((err) => { - console.error(`query failed, err: ${err}`); + console.error(`query failed, code is ${err.code},message is ${err.message}`); }); ``` @@ -2808,7 +3392,7 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode | **ID**| **Error Message** | | ------------ | ------------------------------------------------------------ | -| 14800012 | The result set is empty or the specified location is invalid. | +| 14800012 | The result set is empty or the specified location is invalid. | **Example** @@ -2819,7 +3403,7 @@ promise.then((resultSet) => { resultSet.goToRow(5); resultSet.close(); }).catch((err) => { - console.error(`query failed, err: ${err}`); + console.error(`query failed, code is ${err.code},message is ${err.message}`); }); ``` @@ -2844,7 +3428,7 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode | **ID**| **Error Message** | | ------------ | ------------------------------------------------------------ | -| 14800012 | The result set is empty or the specified location is invalid. | +| 14800012 | The result set is empty or the specified location is invalid. | **Example** @@ -2855,7 +3439,7 @@ promise.then((resultSet) => { resultSet.goToFirstRow(); resultSet.close(); }).catch((err) => { - console.error(`query failed, err: ${err}`); + console.error(`query failed, code is ${err.code},message is ${err.message}`); }); ``` @@ -2879,7 +3463,7 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode | **ID**| **Error Message** | | ------------ | ------------------------------------------------------------ | -| 14800012 | The result set is empty or the specified location is invalid. | +| 14800012 | The result set is empty or the specified location is invalid. | **Example** @@ -2890,7 +3474,7 @@ promise.then((resultSet) => { resultSet.goToLastRow(); resultSet.close(); }).catch((err) => { - console.error(`query failed, err: ${err}`); + console.error(`query failed, code is ${err.code},message is ${err.message}`); }); ``` @@ -2914,7 +3498,7 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode | **ID**| **Error Message** | | ------------ | ------------------------------------------------------------ | -| 14800012 | The result set is empty or the specified location is invalid. | +| 14800012 | The result set is empty or the specified location is invalid. | **Example** @@ -2925,7 +3509,7 @@ promise.then((resultSet) => { resultSet.goToNextRow(); resultSet.close(); }).catch((err) => { - console.error(`query failed, err: ${err}`); + console.error(`query failed, code is ${err.code},message is ${err.message}`); }); ``` @@ -2949,7 +3533,7 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode | **ID**| **Error Message** | | ------------ | ------------------------------------------------------------ | -| 14800012 | The result set is empty or the specified location is invalid. | +| 14800012 | The result set is empty or the specified location is invalid. | **Example** @@ -2960,7 +3544,7 @@ promise.then((resultSet) => { resultSet.goToPreviousRow(); resultSet.close(); }).catch((err) => { - console.error(`query failed, err: ${err}`); + console.error(`query failed, code is ${err.code},message is ${err.message}`); }); ``` @@ -3050,7 +3634,7 @@ Obtains the value of the Long type based on the specified column and the current | Type | Description | | ------ | ------------------------------------------------------------ | -| number | Value obtained.
The value range supported by this API is **Number.MIN_SAFE_INTEGER** to **Number.MAX_SAFE_INTEGER**. If the value is out of this range, use [getDouble](#getdouble).| +| number | Value obtained.
The value range supported by API is **Number.MIN_SAFE_INTEGER** to **Number.MAX_SAFE_INTEGER**. If the value is out of this range, use [getDouble](#getdouble).| **Error codes** @@ -3150,7 +3734,7 @@ let promiseClose = store.query(predicatesClose, ["ID", "NAME", "AGE", "SALARY", promiseClose.then((resultSet) => { resultSet.close(); }).catch((err) => { - console.error(`resultset close failed, err: ${err}`); + console.error(`resultset close failed, code is ${err.code},message is ${err.message}`); }); ``` @@ -3160,4 +3744,4 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode | **ID**| **Error Message** | | ------------ | ------------------------------------------------------------ | -| 14800012 | The result set is empty or the specified location is invalid. | +| 14800012 | The result set is empty or the specified location is invalid. | diff --git a/en/application-dev/reference/apis/js-apis-data-valuesBucket.md b/en/application-dev/reference/apis/js-apis-data-valuesBucket.md index 009ff71b091c7d91a92d92364450316e3aeecfa2..ee21647ac71dacf7afa8240d2aa93e2ea65967f4 100644 --- a/en/application-dev/reference/apis/js-apis-data-valuesBucket.md +++ b/en/application-dev/reference/apis/js-apis-data-valuesBucket.md @@ -1,4 +1,4 @@ -# @ohos.data.ValuesBucket (Value Bucket) +# @ohos.data.ValuesBucket (Data Set) The **ValueBucket** module holds data in key-value (KV) pairs. You can use it to insert data into a database. @@ -6,7 +6,6 @@ The **ValueBucket** module holds data in key-value (KV) pairs. You can use it to > > The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > -> The APIs provided by this module are system APIs. ## Modules to Import @@ -30,7 +29,7 @@ Enumerates the value types allowed by the database. ## ValuesBucket -Defines the types of the key and value in a KV pair. +Defines the types of the key and value in a KV pair. This type is not multi-thread safe. If a **ValuesBucket** instance is operated by multiple threads at the same time in an application, use a lock for the instance. **System capability**: SystemCapability.DistributedDataManager.DataShare.Core 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 05532a37fa647366abbc6dfa640eba798a07d178..428e37263769770d2f3861ad95db770db62db08b 100644 --- a/en/application-dev/reference/apis/js-apis-distributed-data.md +++ b/en/application-dev/reference/apis/js-apis-distributed-data.md @@ -129,8 +129,8 @@ Defines user information. | Name| Type| Mandatory| Description| | ----- | ------ |------ | ------ | -| userId | string | No | User ID.| -| userType | [UserType](#usertype) | No | User type.| +| userId | string | No | User ID. The default value is **0**.| +| userType | [UserType](#usertype) | No | User type. The default value is **0**.| ## UserType @@ -268,7 +268,7 @@ const options = { backup: false, autoSync: true, kvStoreType: distributedData.KVStoreType.SINGLE_VERSION, - schema: '', + schema: undefined, securityLevel: distributedData.SecurityLevel.S2, } try { @@ -318,7 +318,7 @@ const options = { backup: false, autoSync: true, kvStoreType: distributedData.KVStoreType.SINGLE_VERSION, - schema: '', + schema: undefined, securityLevel: distributedData.SecurityLevel.S2, } try { @@ -366,7 +366,7 @@ const options = { backup : false, autoSync : true, kvStoreType : distributedData.KVStoreType.SINGLE_VERSION, - schema : '', + schema : undefined, securityLevel : distributedData.SecurityLevel.S2, } try { @@ -415,7 +415,7 @@ const options = { backup : false, autoSync : true, kvStoreType : distributedData.KVStoreType.SINGLE_VERSION, - schema : '', + schema : undefined, securityLevel : distributedData.SecurityLevel.S2, } try { @@ -575,13 +575,13 @@ Provides KV store configuration. | Name | Type| Mandatory | Description | | ----- | ------ | ------ | -------------------| -| createIfMissing | boolean | No| Whether to create a KV store if no database file exists. By default, a KV store is created.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core | -| encrypt | boolean | No|Whether to encrypt database files. By default, database files are not encrypted.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core | -| backup | boolean | No|Whether to back up database files. By default, database files are backed up.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core | -| autoSync | boolean | No|Whether to automatically synchronize database files. The value **false** (default) means to manually synchronize database files; the value **true** means to automatically synchronize database files.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core
**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC | -| kvStoreType | [KVStoreType](#kvstoretype) | No|Type of the KV store to create. By default, a device KV store is created. The device KV store stores data for multiple devices that collaborate with each other.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core| -| securityLevel | [SecurityLevel](#securitylevel) | No|Security level of the KV store. By default, the security level is not set.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core | -| schema8+ | [Schema](#schema8) | No| Schema used to define the values stored in a KV store.
**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore| +| createIfMissing | boolean | No| Whether to create a KV store if no database file exists. The default value is **true**, which means to create a KV store.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core | +| encrypt | boolean | No|Whether to encrypt the KV store. The default value is **false**, which means the KV store is not encrypted.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core | +| backup | boolean | No|Whether to back up the KV store. The default value is **true**, which means to back up the KV store.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core | +| autoSync | boolean | No|Whether to automatically synchronize database files. The value **false** (default) means to manually synchronize database files; the value **true** means to automatically synchronize database files.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core
**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC | +| kvStoreType | [KVStoreType](#kvstoretype) | No|Type of the KV store to create. The default value is **DEVICE_COLLABORATION**, which indicates a device KV store.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core| +| securityLevel | [SecurityLevel](#securitylevel) | Yes|Security level (S1-S4) of the KV store.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core | +| schema8+ | [Schema](#schema8) | No| Schema used to define the values stored in the KV store. The default value is **undefined**, which means the schema is not set.
**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore| ## KVStoreType @@ -602,8 +602,8 @@ Enumerates the KV store security levels. | Name | Value| Description | | --- | ---- | ----------------------- | -| NO_LEVEL | 0 | No security level is set for the KV store.
**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore | -| S0 | 1 | The KV store security level is public.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core | +| NO_LEVEL | 0 | No security level is set for the KV store (deprecated).
**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore | +| S0 | 1 | The KV store security level is public (deprecated).
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core | | S1 | 2 | The KV store security level is low. If data leakage occurs, minor impact will be caused on the database. For example, a KV store that contains system data such as wallpapers.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core | | S2 | 3 | The KV store security level is medium. If data leakage occurs, moderate impact will be caused on the database. For example, a KV store that contains information created by users or call records, such as audio or video clips.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core | | S3 | 5 | The KV store security level is high. If data leakage occurs, major impact will be caused on the database. For example, a KV store that contains information such as user fitness, health, and location data.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core | @@ -2292,7 +2292,7 @@ Unsubscribes from data changes. | Name | Type | Mandatory| Description | | -------- | --------------------------------------------------------- | ---- | -------------------------------------------------------- | | event | string | Yes | Event to unsubscribe from. The value is **dataChange**, which indicates a data change event.| -| listener |Callback<[ChangeNotification](#changenotification)> |No |Callback for the data change event.| +| listener | Callback<[ChangeNotification](#changenotification)> | No | Callback for the data change event. If the callback is not specified, all subscriptions to the data change event will be canceled.| @@ -2330,7 +2330,7 @@ Unsubscribes from synchronization complete events. | Name | Type | Mandatory| Description | | ------------ | --------------------------------------------- | ---- | ---------------------------------------------------------- | | event | string | Yes | Event to unsubscribe from. The value is **syncComplete**, which indicates a synchronization complete event.| -| syncCallback |Callback<Array<[string, number]>> | No |Callback for the synchronization complete event. | +| syncCallback | Callback<Array<[string, number]>> | No | Callback for the synchronization complete event. If the callback is not specified, all subscriptions to the synchronization complete event will be canceled. | **Example** @@ -3769,7 +3769,7 @@ Synchronizes the KV store manually. | --------- | --------------------- | ---- | ---------------------------------------------- | | deviceIds | string[] | Yes | List of IDs of the devices in the same networking environment to be synchronized.| | mode | [SyncMode](#syncmode) | Yes | Synchronization mode. | -| delayMs | number | No | Allowed synchronization delay time, in ms. | +| delayMs | number | No | Allowed synchronization delay time, in ms. The default value is **0**. | **Example** @@ -3884,7 +3884,7 @@ Unsubscribes from data changes. | Name | Type | Mandatory| Description | | -------- | --------------------------------------------------------- | ---- | -------------------------------------------------------- | | event | string | Yes | Event to unsubscribe from. The value is **dataChange**, which indicates a data change event.| -| listener |Callback<[ChangeNotification](#changenotification)> |No |Callback for the data change event.| +| listener | Callback<[ChangeNotification](#changenotification)> | No | Callback for the data change event. If the callback is not specified, all subscriptions to the data change event will be canceled. | **Example** @@ -3920,7 +3920,7 @@ Unsubscribes from synchronization complete events. | Name | Type | Mandatory| Description | | ------------ | --------------------------------------------- | ---- | ---------------------------------------------------------- | | event | string | Yes | Event to unsubscribe from. The value is **syncComplete**, which indicates a synchronization complete event.| -| syncCallback | Callback<Array<[string, number]>> | No | Callback for the synchronization complete event. | +| syncCallback | Callback<Array<[string, number]>> | No | Callback for the synchronization complete event. If the callback is not specified, all subscriptions to the synchronization complete event will be canceled. | **Example** @@ -5191,7 +5191,7 @@ Synchronizes the KV store manually. | ----- | ------ | ---- | ----------------------- | | deviceIds |string[] | Yes |IDs of the devices to be synchronized.| | mode |[SyncMode](#syncmode) | Yes |Synchronization mode. | -| delayMs |number | No |Allowed synchronization delay time, in ms. | +| delayMs |number | No |Allowed synchronization delay time, in ms. The default value is **0**. | **Example** @@ -5306,7 +5306,7 @@ Unsubscribes from data changes. | Name | Type | Mandatory| Description | | -------- | --------------------------------------------------------- | ---- | -------------------------------------------------------- | | event | string | Yes | Event to unsubscribe from. The value is **dataChange**, which indicates a data change event.| -| listener |Callback<[ChangeNotification](#changenotification)> |No |Callback for the data change event.| +| listener | Callback<[ChangeNotification](#changenotification)> | No | Callback for the data change event. If the callback is not specified, all subscriptions to the data change event will be canceled.| **Example** @@ -5342,7 +5342,7 @@ Unsubscribes from synchronization complete events. | Name | Type | Mandatory| Description | | ------------ | --------------------------------------------- | ---- | ---------------------------------------------------------- | | event | string | Yes | Event to unsubscribe from. The value is **syncComplete**, which indicates a synchronization complete event.| -| syncCallback | Callback<Array<[string, number]>> | No | Callback for the synchronization complete event. | +| syncCallback | Callback<Array<[string, number]>> | No | Callback for the synchronization complete event. If the callback is not specified, all subscriptions to the synchronization complete event will be canceled. | **Example** diff --git a/en/application-dev/reference/apis/js-apis-distributedKVStore.md b/en/application-dev/reference/apis/js-apis-distributedKVStore.md index fc93034ec3b0dbda991821ee80c66ae9162d264c..bc59b6d77719160ca63ea4901e399a0666801619 100644 --- a/en/application-dev/reference/apis/js-apis-distributedKVStore.md +++ b/en/application-dev/reference/apis/js-apis-distributedKVStore.md @@ -12,7 +12,8 @@ The **distributedKVStore** module provides the following functions: > **NOTE** > -> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> - The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> - All the APIs that need to obtain **deviceId** in this module are available only to system applications. ## Modules to Import @@ -148,13 +149,13 @@ Provides KV store configuration. | Name | Type | Mandatory| Description | | --------------- | -------------- | ---- | -------------------------| -| createIfMissing | boolean | No | Whether to create a KV store if no database file exists. By default, a KV store is created.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core| -| encrypt | boolean | No | Whether to encrypt database files. By default, database files are not encrypted.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core| -| backup | boolean | No | Whether to back up database files. By default, database files are backed up.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core| -| autoSync | boolean | No | Whether to automatically synchronize database files. The value **false** (default) means to manually synchronize database files; the value **true** means to automatically synchronize database files.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core
**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC| -| kvStoreType | [KVStoreType](#kvstoretype) | No | Type of the KV store to create. By default, a device KV store is created. The device KV store stores data for multiple devices that collaborate with each other.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core| -| securityLevel | [SecurityLevel](#securitylevel) | Yes |Security level of the KV store.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core| -| schema | [Schema](#schema) | No | Schema used to define the values stored in the KV store. By default, **schema** is not used.
**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore| +| createIfMissing | boolean | No | Whether to create a KV store if no database file exists. The default value is **true**, which means to create a KV store.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core| +| encrypt | boolean | No | Whether to encrypt the KV store. The default value is **false**, which means the KV store is not encrypted.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core| +| backup | boolean | No | Whether to back up the KV store. The default value is **true**, which means to back up the KV store.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core| +| autoSync | boolean | No | Whether to automatically synchronize database files. The default value is **false**, which means the database files are manually synchronized.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core
**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC| +| kvStoreType | [KVStoreType](#kvstoretype) | No | Type of the KV store to create. The default value is **DEVICE_COLLABORATION**, which indicates a device KV store.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core| +| securityLevel | [SecurityLevel](#securitylevel) | Yes | Security level of the KV store.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core| +| schema | [Schema](#schema) | No | Schema used to define the values stored in the KV store. The default value is **undefined**, which means no schema is set.
**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore| ## Schema @@ -226,23 +227,23 @@ Appends a child node to this **FieldNode**. **Example** ```js -import ddm from '@ohos.data.distributedKVStore'; +import distributedKVStore from '@ohos.data.distributedKVStore'; try { - let node = new ddm.FieldNode("root"); - let child1 = new ddm.FieldNode("child1"); - let child2 = new ddm.FieldNode("child2"); - let child3 = new ddm.FieldNode("child3"); + let node = new distributedKVStore.FieldNode("root"); + let child1 = new distributedKVStore.FieldNode("child1"); + let child2 = new distributedKVStore.FieldNode("child2"); + let child3 = new distributedKVStore.FieldNode("child3"); node.appendChild(child1); node.appendChild(child2); node.appendChild(child3); - console.log("appendNode " + JSON.stringify(node)); + console.info("appendNode " + JSON.stringify(node)); child1 = null; child2 = null; child3 = null; node = null; } catch (e) { - console.log("AppendChild " + e); + console.error("AppendChild " + e); } ``` @@ -250,7 +251,7 @@ try { createKVManager(config: KVManagerConfig): KVManager -Creates a **KVManager** instance to manage KV stores. +Creates a **KVManager** instance for KV store management. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -276,7 +277,7 @@ import UIAbility from '@ohos.app.ability.UIAbility'; let kvManager; export default class EntryAbility extends UIAbility { onCreate() { - console.log("MyAbilityStage onCreate") + console.info("MyAbilityStage onCreate") let context = this.context const kvManagerConfig = { context: context, @@ -284,7 +285,7 @@ export default class EntryAbility extends UIAbility { } try { kvManager = distributedKVStore.createKVManager(kvManagerConfig); - console.log("Created KVManager successfully"); + console.info("Succeeded in creating KVManager"); } catch (e) { console.error(`Failed to create KVManager.code is ${e.code},message is ${e.message}`); } @@ -304,7 +305,7 @@ const kvManagerConfig = { } try { kvManager = distributedKVStore.createKVManager(kvManagerConfig); - console.log("Created KVManager successfully"); + console.info("Succeeded in creating KVManager"); } catch (e) { console.error(`Failed to create KVManager.code is ${e.code},message is ${e.message}`); } @@ -316,7 +317,7 @@ Provides an instance to obtain information about a distributed KV store. Before ### getKVStore -getKVStore<T >(storeId: string, options: Options, callback: AsyncCallback<T>): void +getKVStore<T>(storeId: string, options: Options, callback: AsyncCallback<T>): void Creates and obtains a distributed KV store. This API uses an asynchronous callback to return the result. @@ -358,17 +359,17 @@ try { console.error(`Failed to get KVStore.code is ${err.code},message is ${err.message}`); return; } - console.log("Succeeded in getting KVStore"); + console.info("Succeeded in getting KVStore"); kvStore = store; }); } catch (e) { - console.log(`An unexpected error occurred.code is ${e.code},message is ${e.message}`); + console.error(`An unexpected error occurred.code is ${e.code},message is ${e.message}`); } ``` ### getKVStore -getKVStore<T >(storeId: string, options: Options): Promise<T> +getKVStore<T>(storeId: string, options: Options): Promise<T> Creates and obtains a distributed KV store. This API uses a promise to return the result. @@ -411,13 +412,13 @@ try { securityLevel: distributedKVStore.SecurityLevel.S2, }; kvManager.getKVStore('storeId', options).then((store) => { - console.log("Succeeded in getting KVStore"); + console.info("Succeeded in getting KVStore"); kvStore = store; }).catch((err) => { console.error(`Failed to get KVStore.code is ${err.code},message is ${err.message}`); }); } catch (e) { - console.log(`An unexpected error occurred.code is ${e.code},message is ${e.message}`); + console.error(`An unexpected error occurred.code is ${e.code},message is ${e.message}`); } ``` @@ -448,19 +449,25 @@ const options = { backup: false, autoSync: true, kvStoreType: distributedKVStore.KVStoreType.SINGLE_VERSION, - schema: '', + schema: undefined, securityLevel: distributedKVStore.SecurityLevel.S2, } try { kvManager.getKVStore('storeId', options, async function (err, store) { - console.log('Succeeded in getting KVStore'); + if (err != undefined) { + console.error(`Failed to get KVStore.code is ${err.code},message is ${err.message}`); + return; + } + console.info('Succeeded in getting KVStore'); kvStore = store; - kvManager.closeKVStore('appId', 'storeId', function (err, data) { + kvStore = null; + store = null; + kvManager.closeKVStore('appId', 'storeId', function (err) { if (err != undefined) { console.error(`Failed to close KVStore.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in closing KVStore'); + console.info('Succeeded in closing KVStore'); }); }); } catch (e) { @@ -500,15 +507,17 @@ const options = { backup: false, autoSync: true, kvStoreType: distributedKVStore.KVStoreType.SINGLE_VERSION, - schema: '', + schema: undefined, securityLevel: distributedKVStore.SecurityLevel.S2, } try { kvManager.getKVStore('storeId', options).then(async (store) => { - console.log('Succeeded in getting KVStore'); + console.info('Succeeded in getting KVStore'); kvStore = store; + kvStore = null; + store = null; kvManager.closeKVStore('appId', 'storeId').then(() => { - console.log('Succeeded in closing KVStore'); + console.info('Succeeded in closing KVStore'); }).catch((err) => { console.error(`Failed to close KVStore.code is ${err.code},message is ${err.message}`); }); @@ -555,7 +564,7 @@ const options = { backup: false, autoSync: true, kvStoreType: distributedKVStore.KVStoreType.SINGLE_VERSION, - schema: '', + schema: undefined, securityLevel: distributedKVStore.SecurityLevel.S2, } try { @@ -564,14 +573,16 @@ try { console.error(`Failed to get KVStore.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in getting KVStore'); + console.info('Succeeded in getting KVStore'); kvStore = store; - kvManager.deleteKVStore('appId', 'storeId', function (err, data) { + kvStore = null; + store = null; + kvManager.deleteKVStore('appId', 'storeId', function (err) { if (err != undefined) { console.error(`Failed to delete KVStore.code is ${err.code},message is ${err.message}`); return; } - console.log(`Succeeded in deleting KVStore`); + console.info(`Succeeded in deleting KVStore`); }); }); } catch (e) { @@ -619,15 +630,17 @@ const options = { backup: false, autoSync: true, kvStoreType: distributedKVStore.KVStoreType.SINGLE_VERSION, - schema: '', + schema: undefined, securityLevel: distributedKVStore.SecurityLevel.S2, } try { kvManager.getKVStore('storeId', options).then(async (store) => { - console.log('Succeeded in getting KVStore'); + console.info('Succeeded in getting KVStore'); kvStore = store; + kvStore = null; + store = null; kvManager.deleteKVStore('appId', 'storeId').then(() => { - console.log('Succeeded in deleting KVStore'); + console.info('Succeeded in deleting KVStore'); }).catch((err) => { console.error(`Failed to delete KVStore.code is ${err.code},message is ${err.message}`); }); @@ -664,8 +677,8 @@ try { console.error(`Failed to get AllKVStoreId.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in getting AllKVStoreId'); - console.log(`GetAllKVStoreId size = ${data.length}`); + console.info('Succeeded in getting AllKVStoreId'); + console.info(`GetAllKVStoreId size = ${data.length}`); }); } catch (e) { console.error(`Failed to get AllKVStoreId.code is ${e.code},message is ${e.message}`); @@ -697,10 +710,10 @@ Obtains the IDs of all distributed KV stores that are created by [getKVStore](#g ```js let kvManager; try { - console.log('GetAllKVStoreId'); + console.info('GetAllKVStoreId'); kvManager.getAllKVStoreId('appId').then((data) => { - console.log('Succeeded in getting AllKVStoreId'); - console.log(`GetAllKVStoreId size = ${data.length}`); + console.info('Succeeded in getting AllKVStoreId'); + console.info(`GetAllKVStoreId size = ${data.length}`); }).catch((err) => { console.error(`Failed to get AllKVStoreId.code is ${err.code},message is ${err.message}`); }); @@ -713,7 +726,7 @@ try { on(event: 'distributedDataServiceDie', deathCallback: Callback<void>): void -Subscribes to service status changes. +Subscribes to service status changes. If the service is terminated, you need to register the callbacks for data change notifications and synchronization complete notifications again. In addition, an error will be returned for a synchronization operation. **System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore @@ -729,13 +742,13 @@ Subscribes to service status changes. ```js let kvManager; try { - console.log('KVManagerOn'); + console.info('KVManagerOn'); const deathCallback = function () { - console.log('death callback call'); + console.info('death callback call'); } kvManager.on('distributedDataServiceDie', deathCallback); } catch (e) { - console.log(`An unexpected error occurred.code is ${e.code},message is ${e.message}`); + console.error(`An unexpected error occurred.code is ${e.code},message is ${e.message}`); } ``` @@ -743,7 +756,7 @@ try { off(event: 'distributedDataServiceDie', deathCallback?: Callback<void>): void -Unsubscribes from service status changes. +Unsubscribes from service status changes. The **deathCallback** parameter must be a callback registered for subscribing to service status changes. Otherwise, the unsubscription will fail. **System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore @@ -752,26 +765,26 @@ Unsubscribes from service status changes. | Name | Type | Mandatory| Description | | ------------- | -------------------- | ---- | ------------------------------------------------------------ | | event | string | Yes | Event to unsubscribe from. The value is **distributedDataServiceDie**, which indicates a service status change event.| -| deathCallback | Callback<void> | No | Callback for the service status change event. | +| deathCallback | Callback<void> | No | Callback for the service status change event. If this parameter is not specified, all subscriptions to the service status change event will be canceled. | **Example** ```js let kvManager; try { - console.log('KVManagerOff'); + console.info('KVManagerOff'); const deathCallback = function () { - console.log('death callback call'); + console.info('death callback call'); } kvManager.off('distributedDataServiceDie', deathCallback); } catch (e) { - console.log(`An unexpected error occurred.code is ${e.code},message is ${e.message}`); + console.error(`An unexpected error occurred.code is ${e.code},message is ${e.message}`); } ``` ## KVStoreResultSet -Provides APIs for obtaining the distributed KV store result sets. +Provides APIs for obtaining the distributed KV store result sets. A maximum of eight result sets can be opened at a time. Before calling any API in **KVStoreResultSet**, you must use **[getKVStore](#getkvstore)** to construct a **SingleKVStore** or **DeviceKVStore** instance. @@ -795,16 +808,17 @@ Obtains the total number of rows in the result set. let kvStore; try { let resultSet; + let count; kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('getResultSet succeed.'); + console.info('getResultSet succeed.'); resultSet = result; + count = resultSet.getCount(); + console.info("getCount succeed:" + count); }).catch((err) => { - console.log('getResultSet failed: ' + err); + console.error('getResultSet failed: ' + err); }); - const count = resultSet.getCount(); - console.log("getCount succeed:" + count); } catch (e) { - console.log("getCount failed: " + e); + console.error("getCount failed: " + e); } ``` @@ -812,7 +826,7 @@ try { getPosition(): number -Obtains the current data read position (position from which data is read) in the result set. +Obtains the current data read position (position from which data is read) in the result set. The read position changes with the operations, such as [moveToFirst](#movetofirst) and [moveToLast](#movetolast). **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -820,7 +834,7 @@ Obtains the current data read position (position from which data is read) in the | Type | Description | | ------ | ------------------ | -| number | Current data read position obtained.| +| number | Current data read position obtained. The value must be greater than or equal to **-1**. The value **-1** means no data is read; the value **0** indicates the first row.| **Example** @@ -828,16 +842,17 @@ Obtains the current data read position (position from which data is read) in the let kvStore; try { let resultSet; + let position; kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('getResultSet succeeded.'); + console.info('getResultSet succeeded.'); resultSet = result; + position = resultSet.getPosition(); + console.info("getPosition succeed:" + position); }).catch((err) => { - console.log('getResultSet failed: ' + err); + console.error('getResultSet failed: ' + err); }); - const position = resultSet.getPosition(); - console.log("getPosition succeed:" + position); } catch (e) { - console.log("getPosition failed: " + e); + console.error("getPosition failed: " + e); } ``` @@ -861,16 +876,17 @@ Moves the data read position to the first row. If the result set is empty, **fal let kvStore; try { let resultSet; + let moved; kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('getResultSet succeed.'); + console.info('getResultSet succeed.'); resultSet = result; + moved = resultSet.moveToFirst(); + console.info("moveToFirst succeed: " + moved); }).catch((err) => { - console.log('getResultSet failed: ' + err); + console.error('getResultSet failed: ' + err); }); - const moved1 = resultSet.moveToFirst(); - console.log("moveToFirst succeed: " + moved1); } catch (e) { - console.log("moveToFirst failed " + e); + console.error("moveToFirst failed " + e); } ``` @@ -894,16 +910,17 @@ Moves the data read position to the last row. If the result set is empty, **fals let kvStore; try { let resultSet; + let moved; kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('getResultSet succeed.'); + console.info('getResultSet succeed.'); resultSet = result; + moved = resultSet.moveToLast(); + console.info("moveToLast succeed:" + moved); }).catch((err) => { - console.log('getResultSet failed: ' + err); + console.error('getResultSet failed: ' + err); }); - const moved2 = resultSet.moveToLast(); - console.log("moveToLast succeed:" + moved2); } catch (e) { - console.log("moveToLast failed: " + e); + console.error("moveToLast failed: " + e); } ``` @@ -911,7 +928,7 @@ try { moveToNext(): boolean -Moves the data read position to the next row. If the result set is empty, **false** will be returned. +Moves the data read position to the next row. If the result set is empty, **false** will be returned. This API applies when the whole result set is obtained. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -927,16 +944,20 @@ Moves the data read position to the next row. If the result set is empty, **fals let kvStore; try { let resultSet; + let moved; kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('getResultSet succeed.'); + console.info('getResultSet succeed.'); resultSet = result; + do { + moved = resultSet.moveToNext(); + const entry = resultSet.getEntry(); + console.info("moveToNext succeed: " + moved); + } while (moved) }).catch((err) => { - console.log('getResultSet failed: ' + err); + console.error('getResultSet failed: ' + err); }); - const moved3 = resultSet.moveToNext(); - console.log("moveToNext succeed: " + moved3); } catch (e) { - console.log("moveToNext failed: " + e); + console.error("moveToNext failed: " + e); } ``` @@ -944,7 +965,7 @@ try { moveToPrevious(): boolean -Moves the data read position to the previous row. If the result set is empty, **false** will be returned. +Moves the data read position to the previous row. If the result set is empty, **false** will be returned. This API applies when the whole result set is obtained. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -960,16 +981,18 @@ Moves the data read position to the previous row. If the result set is empty, ** let kvStore; try { let resultSet; + let moved; kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('getResultSet succeed.'); + console.info('getResultSet succeed.'); resultSet = result; + moved = resultSet.moveToLast(); + moved = resultSet.moveToPrevious(); + console.info("moveToPrevious succeed:" + moved); }).catch((err) => { - console.log('getResultSet failed: ' + err); + console.error('getResultSet failed: ' + err); }); - const moved4 = resultSet.moveToPrevious(); - console.log("moveToPrevious succeed:" + moved4); } catch (e) { - console.log("moveToPrevious failed: " + e); + console.error("moveToPrevious failed: " + e); } ``` @@ -977,7 +1000,7 @@ try { move(offset: number): boolean -Moves the data read position with the specified offset from the current position. +Moves the data read position with the specified offset from the current position. That is, moves the number of rows specified by **offset** from the current position. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -999,16 +1022,17 @@ Moves the data read position with the specified offset from the current position let kvStore; try { let resultSet; + let moved; kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('Succeeded in getting resultSet'); + console.info('Succeeded in getting resultSet'); resultSet = result; + moved = resultSet.move(2); // If the current position is 0, move the read position forward by two rows, that is, move to row 3. + console.info(`Succeeded in moving.moved = ${moved}`); }).catch((err) => { console.error(`Failed to get resultSet.code is ${err.code},message is ${err.message}`); }); - const moved5 = resultSet.move(1); - console.log(`Succeeded in moving.moved5 = ${moved5}`); } catch (e) { - console.log(`Failed to move.code is ${e.code},message is ${e.message}`); + console.error(`Failed to move.code is ${e.code},message is ${e.message}`); } ``` @@ -1038,14 +1062,15 @@ Moves the data read position from 0 to an absolute position. let kvStore; try { let resultSet; + let moved; kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('Succeeded in getting resultSet'); + console.info('Succeeded in getting resultSet'); resultSet = result; + moved = resultSet.moveToPosition(1); + console.info(`Succeeded in moving to position.moved=${moved}`); }).catch((err) => { console.error(`Failed to get resultSet.code is ${err.code},message is ${err.message}`); }); - const moved6 = resultSet.moveToPosition(1); - console.log(`Succeeded in moving to position.moved6=${moved6}`); } catch (e) { console.error(`Failed to move to position.code is ${e.code},message is ${e.message}`); } @@ -1071,16 +1096,17 @@ Checks whether the data read position is the first row. let kvStore; try { let resultSet; + let isfirst; kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('getResultSet succeed.'); + console.info('getResultSet succeed.'); resultSet = result; + isfirst = resultSet.isFirst(); + console.info("Check isFirst succeed:" + isfirst); }).catch((err) => { - console.log('getResultSet failed: ' + err); + console.error('getResultSet failed: ' + err); }); - const isfirst = resultSet.isFirst(); - console.log("Check isFirst succeed:" + isfirst); } catch (e) { - console.log("Check isFirst failed: " + e); + console.error("Check isFirst failed: " + e); } ``` @@ -1104,16 +1130,17 @@ Checks whether the data read position is the last row. let kvStore; try { let resultSet; + let islast; kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('getResultSet succeed.'); + console.info('getResultSet succeed.'); resultSet = result; + islast = resultSet.isLast(); + console.info("Check isLast succeed: " + islast); }).catch((err) => { - console.log('getResultSet failed: ' + err); + console.error('getResultSet failed: ' + err); }); - const islast = resultSet.isLast(); - console.log("Check isLast succeed: " + islast); } catch (e) { - console.log("Check isLast failed: " + e); + console.error("Check isLast failed: " + e); } ``` @@ -1138,15 +1165,15 @@ let kvStore; try { let resultSet; kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('getResultSet succeed.'); + console.info('getResultSet succeed.'); resultSet = result; + const isbeforefirst = resultSet.isBeforeFirst(); + console.info("Check isBeforeFirst succeed: " + isbeforefirst); }).catch((err) => { - console.log('getResultSet failed: ' + err); + console.error('getResultSet failed: ' + err); }); - const isbeforefirst = resultSet.isBeforeFirst(); - console.log("Check isBeforeFirst succeed: " + isbeforefirst); } catch (e) { - console.log("Check isBeforeFirst failed: " + e); + console.error("Check isBeforeFirst failed: " + e); } ``` @@ -1171,13 +1198,13 @@ let kvStore; try { let resultSet; kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('getResultSet succeed.'); + console.info('getResultSet succeed.'); resultSet = result; + const isafterlast = resultSet.isAfterLast(); + console.info("Check isAfterLast succeed:" + isafterlast); }).catch((err) => { - console.log('getResultSet failed: ' + err); + console.error('getResultSet failed: ' + err); }); - const isafterlast = resultSet.isAfterLast(); - console.log("Check isAfterLast succeed:" + isafterlast); } catch (e) { console.log("Check isAfterLast failed: " + e); } @@ -1204,21 +1231,21 @@ let kvStore; try { let resultSet; kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('getResultSet succeed.'); + console.info('getResultSet succeed.'); resultSet = result; + const entry = resultSet.getEntry(); + console.info("getEntry succeed:" + JSON.stringify(entry)); }).catch((err) => { - console.log('getResultSet failed: ' + err); + console.error('getResultSet failed: ' + err); }); - const entry = resultSet.getEntry(); - console.log("getEntry succeed:" + JSON.stringify(entry)); } catch (e) { - console.log("getEntry failed: " + e); + console.error("getEntry failed: " + e); } ``` ## Query -Provides methods to create a **Query** object, which defines different data query criteria. +Provides methods to create a **Query** object, which defines different data query criteria. A **Query** object supports a maximum of 256 predicates. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -1250,12 +1277,12 @@ Resets the **Query** object. try { let query = new distributedKVStore.Query(); query.equalTo("key", "value"); - console.log("query is " + query.getSqlLike()); + console.info("query is " + query.getSqlLike()); query.reset(); - console.log("query is " + query.getSqlLike()); + console.info("query is " + query.getSqlLike()); query = null; } catch (e) { - console.log("simply calls should be ok :" + e); + console.error("simply calls should be ok :" + e); } ``` @@ -1286,7 +1313,7 @@ Creates a **Query** object to match the specified field whose value is equal to try { let query = new distributedKVStore.Query(); query.equalTo("field", "value"); - console.log(`query is ${query.getSqlLike()}`); + console.info(`query is ${query.getSqlLike()}`); query = null; } catch (e) { console.error(`duplicated calls should be ok.ode is ${e.code},message is ${e.message}`); @@ -1320,7 +1347,7 @@ Creates a **Query** object to match the specified field whose value is not equal try { let query = new distributedKVStore.Query(); query.notEqualTo("field", "value"); - console.log(`query is ${query.getSqlLike()}`); + console.info(`query is ${query.getSqlLike()}`); query = null; } catch (e) { console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`); @@ -1353,7 +1380,7 @@ Creates a **Query** object to match the specified field whose value is greater t try { let query = new distributedKVStore.Query(); query.greaterThan("field", "value"); - console.log(`query is ${query.getSqlLike()}`); + console.info(`query is ${query.getSqlLike()}`); query = null; } catch (e) { console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`); @@ -1388,7 +1415,7 @@ Creates a **Query** object to match the specified field whose value is less than try { let query = new distributedKVStore.Query(); query.lessThan("field", "value"); - console.log(`query is ${query.getSqlLike()}`); + console.info(`query is ${query.getSqlLike()}`); query = null; } catch (e) { console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`); @@ -1423,7 +1450,7 @@ Creates a **Query** object to match the specified field whose value is greater t try { let query = new distributedKVStore.Query(); query.greaterThanOrEqualTo("field", "value"); - console.log(`query is ${query.getSqlLike()}`); + console.info(`query is ${query.getSqlLike()}`); query = null; } catch (e) { console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`); @@ -1458,7 +1485,7 @@ Creates a **Query** object to match the specified field whose value is less than try { let query = new distributedKVStore.Query(); query.lessThanOrEqualTo("field", "value"); - console.log(`query is ${query.getSqlLike()}`); + console.info(`query is ${query.getSqlLike()}`); query = null; } catch (e) { console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`); @@ -1491,7 +1518,7 @@ Creates a **Query** object to match the specified field whose value is **null**. try { let query = new distributedKVStore.Query(); query.isNull("field"); - console.log(`query is ${query.getSqlLike()}`); + console.info(`query is ${query.getSqlLike()}`); query = null; } catch (e) { console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`); @@ -1525,7 +1552,7 @@ Creates a **Query** object to match the specified field whose value is within th try { let query = new distributedKVStore.Query(); query.inNumber("field", [0, 1]); - console.log(`query is ${query.getSqlLike()}`); + console.info(`query is ${query.getSqlLike()}`); query = null; } catch (e) { console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`); @@ -1559,7 +1586,7 @@ Creates a **Query** object to match the specified field whose value is within th try { let query = new distributedKVStore.Query(); query.inString("field", ['test1', 'test2']); - console.log(`query is ${query.getSqlLike()}`); + console.info(`query is ${query.getSqlLike()}`); query = null; } catch (e) { console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`); @@ -1593,7 +1620,7 @@ Creates a **Query** object to match the specified field whose value is not withi try { let query = new distributedKVStore.Query(); query.notInNumber("field", [0, 1]); - console.log(`query is ${query.getSqlLike()}`); + console.info(`query is ${query.getSqlLike()}`); query = null; } catch (e) { console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`); @@ -1627,7 +1654,7 @@ Creates a **Query** object to match the specified field whose value is not withi try { let query = new distributedKVStore.Query(); query.notInString("field", ['test1', 'test2']); - console.log(`query is ${query.getSqlLike()}`); + console.info(`query is ${query.getSqlLike()}`); query = null; } catch (e) { console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`); @@ -1661,7 +1688,7 @@ Creates a **Query** object to match the specified field whose value is similar t try { let query = new distributedKVStore.Query(); query.like("field", "value"); - console.log(`query is ${query.getSqlLike()}`); + console.info(`query is ${query.getSqlLike()}`); query = null; } catch (e) { console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`); @@ -1695,7 +1722,7 @@ Creates a **Query** object to match the specified field whose value is not simil try { let query = new distributedKVStore.Query(); query.unlike("field", "value"); - console.log(`query is ${query.getSqlLike()}`); + console.info(`query is ${query.getSqlLike()}`); query = null; } catch (e) { console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`); @@ -1724,10 +1751,10 @@ try { query.notEqualTo("field", "value1"); query.and(); query.notEqualTo("field", "value2"); - console.log("query is " + query.getSqlLike()); + console.info("query is " + query.getSqlLike()); query = null; } catch (e) { - console.log("duplicated calls should be ok :" + e); + console.error("duplicated calls should be ok :" + e); } ``` @@ -1753,10 +1780,10 @@ try { query.notEqualTo("field", "value1"); query.or(); query.notEqualTo("field", "value2"); - console.log("query is " + query.getSqlLike()); + console.info("query is " + query.getSqlLike()); query = null; } catch (e) { - console.log("duplicated calls should be ok :" + e); + console.error("duplicated calls should be ok :" + e); } ``` @@ -1787,7 +1814,7 @@ try { let query = new distributedKVStore.Query(); query.notEqualTo("field", "value"); query.orderByAsc("field"); - console.log(`query is ${query.getSqlLike()}`); + console.info(`query is ${query.getSqlLike()}`); query = null; } catch (e) { console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`); @@ -1821,7 +1848,7 @@ try { let query = new distributedKVStore.Query(); query.notEqualTo("field", "value"); query.orderByDesc("field"); - console.log(`query is ${query.getSqlLike()}`); + console.info(`query is ${query.getSqlLike()}`); query = null; } catch (e) { console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`); @@ -1832,7 +1859,7 @@ try { limit(total: number, offset: number): Query -Creates a **Query** object to specify the number of records of the query result and where to start. +Creates a **Query** object to specify the number of records of the query result and where to start. This API must be called after the invocation of the **orderByAsc()**, **orderByDesc()**, and the query APIs of the **Query** object. **System capability**: SystemCapability.DistributedDataManager.KVStore.Core @@ -1858,7 +1885,7 @@ try { let query = new distributedKVStore.Query(); query.notEqualTo("field", "value"); query.limit(total, offset); - console.log(`query is ${query.getSqlLike()}`); + console.info(`query is ${query.getSqlLike()}`); query = null; } catch (e) { console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`); @@ -1891,7 +1918,7 @@ Creates a **Query** object to match the specified field whose value is not **nul try { let query = new distributedKVStore.Query(); query.isNotNull("field"); - console.log(`query is ${query.getSqlLike()}`); + console.info(`query is ${query.getSqlLike()}`); query = null; } catch (e) { console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`); @@ -1920,10 +1947,10 @@ try { query.beginGroup(); query.isNotNull("field"); query.endGroup(); - console.log("query is " + query.getSqlLike()); + console.info("query is " + query.getSqlLike()); query = null; } catch (e) { - console.log("duplicated calls should be ok :" + e); + console.error("duplicated calls should be ok :" + e); } ``` @@ -1949,10 +1976,10 @@ try { query.beginGroup(); query.isNotNull("field"); query.endGroup(); - console.log("query is " + query.getSqlLike()); + console.info("query is " + query.getSqlLike()); query = null; } catch (e) { - console.log("duplicated calls should be ok :" + e); + console.error("duplicated calls should be ok :" + e); } ``` @@ -1983,7 +2010,7 @@ try { let query = new distributedKVStore.Query(); query.prefixKey("$.name"); query.prefixKey("0"); - console.log(`query is ${query.getSqlLike()}`); + console.info(`query is ${query.getSqlLike()}`); query = null; } catch (e) { console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`); @@ -2017,7 +2044,7 @@ try { let query = new distributedKVStore.Query(); query.setSuggestIndex("$.name"); query.setSuggestIndex("0"); - console.log(`query is ${query.getSqlLike()}`); + console.info(`query is ${query.getSqlLike()}`); query = null; } catch (e) { console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`); @@ -2050,7 +2077,7 @@ Creates a **Query** object with the device ID as the key prefix. try { let query = new distributedKVStore.Query(); query.deviceId("deviceId"); - console.log(`query is ${query.getSqlLike()}`); + console.info(`query is ${query.getSqlLike()}`); } catch (e) { console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`); } @@ -2076,9 +2103,9 @@ Obtains the query statement of the **Query** object. try { let query = new distributedKVStore.Query(); let sql1 = query.getSqlLike(); - console.log(`GetSqlLike sql= ${sql1}`); + console.info(`GetSqlLike sql= ${sql1}`); } catch (e) { - console.log("duplicated calls should be ok : " + e); + console.error("duplicated calls should be ok : " + e); } ``` @@ -2120,12 +2147,12 @@ let kvStore; const KEY_TEST_STRING_ELEMENT = 'key_test_string'; const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; try { - kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err, data) { + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err) { if (err != undefined) { console.error(`Failed to put.code is ${err.code},message is ${err.message}`); return; } - console.log("Succeeded in putting"); + console.info("Succeeded in putting"); }); } catch (e) { console.error(`An unexpected error occurred.code is ${e.code},message is ${e.message}`); @@ -2169,8 +2196,8 @@ let kvStore; const KEY_TEST_STRING_ELEMENT = 'key_test_string'; const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; try { - kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((data) => { - console.log(`Succeeded in putting.data=${data}`); + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then(() => { + console.info(`Succeeded in putting data`); }).catch((err) => { console.error(`Failed to put.code is ${err.code},message is ${err.message}`); }); @@ -2191,7 +2218,7 @@ Batch inserts KV pairs to this single KV store. This API uses an asynchronous ca | Name | Type | Mandatory| Description | | -------- | ------------------------ | ---- | ------------------------ | -| entries | [Entry](#entry)[] | Yes | KV pairs to insert in batches.| +| entries | [Entry](#entry)[] | Yes | KV pairs to insert in batches. An **entries** object allows a maximum of 128 entries.| | callback | AsyncCallback<void> | Yes | Callback invoked to return the result. | **Error codes** @@ -2220,20 +2247,20 @@ try { } entries.push(entry); } - console.log(`entries: ${entries}`); - kvStore.putBatch(entries, async function (err, data) { + console.info(`entries: ${entries}`); + kvStore.putBatch(entries, async function (err) { if (err != undefined) { console.error(`Failed to put Batch.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in putting Batch'); + console.info('Succeeded in putting Batch'); kvStore.getEntries('batch_test_string_key', function (err, entries) { if (err != undefined) { console.error(`Failed to get Entries.code is ${err.code},message is ${err.message}`); } - console.log('Succeeded in getting Entries'); - console.log(`entries.length: ${entries.length}`); - console.log(`entries[0]: ${entries[0]}`); + console.info('Succeeded in getting Entries'); + console.info(`entries.length: ${entries.length}`); + console.info(`entries[0]: ${entries[0]}`); }); }); } catch (e) { @@ -2253,7 +2280,7 @@ Batch inserts KV pairs to this single KV store. This API uses a promise to retur | Name | Type | Mandatory| Description | | ------- | ----------------- | ---- | ------------------------ | -| entries | [Entry](#entry)[] | Yes | KV pairs to insert in batches.| +| entries | [Entry](#entry)[] | Yes | KV pairs to insert in batches. An **entries** object allows a maximum of 128 entries.| **Return value** @@ -2287,12 +2314,12 @@ try { } entries.push(entry); } - console.log(`entries: ${entries}`); - kvStore.putBatch(entries).then(async (entries) => { - console.log('Succeeded in putting Batch'); + console.info(`entries: ${entries}`); + kvStore.putBatch(entries).then(async () => { + console.info('Succeeded in putting Batch'); kvStore.getEntries('batch_test_string_key').then((entries) => { - console.log('Succeeded in getting Entries'); - console.log(`PutBatch ${entries}`); + console.info('Succeeded in getting Entries'); + console.info(`PutBatch ${entries}`); }).catch((err) => { console.error(`Failed to get Entries.code is ${err.code},message is ${err.message}`); }); @@ -2344,12 +2371,12 @@ try { v8Arr.push(vb1); v8Arr.push(vb2); v8Arr.push(vb3); - kvStore.putBatch(v8Arr, async function (err, data) { + kvStore.putBatch(v8Arr, async function (err) { if (err != undefined) { console.error(`Failed to put batch.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in putting batch'); + console.info('Succeeded in putting batch'); }) } catch (e) { console.error(`Failed to put batch.code is ${e.code},message is ${e.message}`); @@ -2401,8 +2428,8 @@ try { v8Arr.push(vb1); v8Arr.push(vb2); v8Arr.push(vb3); - kvStore.putBatch(v8Arr).then(async (data) => { - console.log(`Succeeded in putting patch`); + kvStore.putBatch(v8Arr).then(async () => { + console.info(`Succeeded in putting patch`); }).catch((err) => { console.error(`putBatch fail.code is ${err.code},message is ${err.message}`); }); @@ -2442,18 +2469,18 @@ let kvStore; const KEY_TEST_STRING_ELEMENT = 'key_test_string'; const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; try { - kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err, data) { + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err) { if (err != undefined) { console.error(`Failed to put.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in putting'); - kvStore.delete(KEY_TEST_STRING_ELEMENT, function (err, data) { + console.info('Succeeded in putting'); + kvStore.delete(KEY_TEST_STRING_ELEMENT, function (err) { if (err != undefined) { console.error(`Failed to delete.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in deleting'); + console.info('Succeeded in deleting'); }); }); } catch (e) { @@ -2497,10 +2524,10 @@ let kvStore; const KEY_TEST_STRING_ELEMENT = 'key_test_string'; const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; try { - kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((data) => { - console.log(`Succeeded in putting: ${data}`); - kvStore.delete(KEY_TEST_STRING_ELEMENT).then((data) => { - console.log('Succeeded in deleting'); + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then(() => { + console.info(`Succeeded in putting data`); + kvStore.delete(KEY_TEST_STRING_ELEMENT).then(() => { + console.info('Succeeded in deleting'); }).catch((err) => { console.error(`Failed to delete.code is ${err.code},message is ${err.message}`); }); @@ -2545,9 +2572,9 @@ import dataSharePredicates from '@ohos.data.dataSharePredicates'; let kvStore; try { let predicates = new dataSharePredicates.DataSharePredicates(); - kvStore.delete(predicates, function (err, data) { + kvStore.delete(predicates, function (err) { if (err == undefined) { - console.log('Succeeded in deleting'); + console.info('Succeeded in deleting'); } else { console.error(`Failed to delete.code is ${err.code},message is ${err.message}`); } @@ -2598,10 +2625,10 @@ try { let predicates = new dataSharePredicates.DataSharePredicates(); let arr = ["name"]; predicates.inKeys(arr); - kvStore.put("name", "bob").then((data) => { - console.log(`Succeeded in putting: ${data}`); - kvStore.delete(predicates).then((data) => { - console.log('Succeeded in deleting'); + kvStore.put("name", "bob").then(() => { + console.info(`Succeeded in putting data`); + kvStore.delete(predicates).then(() => { + console.info('Succeeded in deleting'); }).catch((err) => { console.error(`Failed to delete.code is ${err.code},message is ${err.message}`); }); @@ -2656,19 +2683,19 @@ try { entries.push(entry); keys.push(key + i); } - console.log(`entries: ${entries}`); - kvStore.putBatch(entries, async function (err, data) { + console.info(`entries: ${entries}`); + kvStore.putBatch(entries, async function (err) { if (err != undefined) { console.error(`Failed to put Batch.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in putting Batch'); - kvStore.deleteBatch(keys, async function (err, data) { + console.info('Succeeded in putting Batch'); + kvStore.deleteBatch(keys, async function (err) { if (err != undefined) { console.error(`Failed to delete Batch.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in deleting Batch'); + console.info('Succeeded in deleting Batch'); }); }); } catch (e) { @@ -2724,11 +2751,11 @@ try { entries.push(entry); keys.push(key + i); } - console.log(`entries: ${entries}`); - kvStore.putBatch(entries).then(async (data) => { - console.log('Succeeded in putting Batch'); - kvStore.deleteBatch(keys).then((err) => { - console.log('Succeeded in deleting Batch'); + console.info(`entries: ${entries}`); + kvStore.putBatch(entries).then(async () => { + console.info('Succeeded in putting Batch'); + kvStore.deleteBatch(keys).then(() => { + console.info('Succeeded in deleting Batch'); }).catch((err) => { console.error(`Failed to delete Batch.code is ${err.code},message is ${err.message}`); }); @@ -2770,16 +2797,16 @@ let kvStore; const KEY_TEST_STRING_ELEMENT = 'key_test_string_2'; const VALUE_TEST_STRING_ELEMENT = 'value-string-002'; try { - kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, async function (err, data) { - console.log('Succeeded in putting data'); + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, async function (err) { + console.info('Succeeded in putting data'); const deviceid = 'no_exist_device_id'; - kvStore.removeDeviceData(deviceid, async function (err, data) { + kvStore.removeDeviceData(deviceid, async function (err) { if (err == undefined) { - console.log('succeeded in removing device data'); + console.info('succeeded in removing device data'); } else { console.error(`Failed to remove device data.code is ${err.code},message is ${err.message} `); kvStore.get(KEY_TEST_STRING_ELEMENT, async function (err, data) { - console.log('Succeeded in getting data'); + console.info('Succeeded in getting data'); }); } }); @@ -2824,19 +2851,19 @@ let kvStore; const KEY_TEST_STRING_ELEMENT = 'key_test_string_2'; const VALUE_TEST_STRING_ELEMENT = 'value-string-001'; try { - kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((err) => { - console.log('Succeeded in putting data'); + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then(() => { + console.info('Succeeded in putting data'); }).catch((err) => { console.error(`Failed to put data.code is ${err.code},message is ${err.message} `); }); const deviceid = 'no_exist_device_id'; - kvStore.removeDeviceData(deviceid).then((err) => { - console.log('succeeded in removing device data'); + kvStore.removeDeviceData(deviceid).then(() => { + console.info('succeeded in removing device data'); }).catch((err) => { console.error(`Failed to remove device data.code is ${err.code},message is ${err.message} `); }); kvStore.get(KEY_TEST_STRING_ELEMENT).then((data) => { - console.log('Succeeded in getting data'); + console.info('Succeeded in getting data'); }).catch((err) => { console.error(`Failed to get data.code is ${err.code},message is ${err.message} `); }); @@ -2877,18 +2904,18 @@ let kvStore; const KEY_TEST_STRING_ELEMENT = 'key_test_string'; const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; try { - kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err, data) { + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err) { if (err != undefined) { console.error(`Failed to put.code is ${err.code},message is ${err.message}`); return; } - console.log("Succeeded in putting"); + console.info("Succeeded in putting"); kvStore.get(KEY_TEST_STRING_ELEMENT, function (err, data) { if (err != undefined) { console.error(`Failed to get.code is ${err.code},message is ${err.message}`); return; } - console.log(`Succeeded in getting data.data=${data}`); + console.info(`Succeeded in getting data.data=${data}`); }); }); } catch (e) { @@ -2933,10 +2960,10 @@ let kvStore; const KEY_TEST_STRING_ELEMENT = 'key_test_string'; const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; try { - kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((data) => { - console.log(`Succeeded in putting data.data=${data}`); + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then(() => { + console.info(`Succeeded in putting data`); kvStore.get(KEY_TEST_STRING_ELEMENT).then((data) => { - console.log(`Succeeded in getting data.data=${data}`); + console.info(`Succeeded in getting data.data=${data}`); }).catch((err) => { console.error(`Failed to get.code is ${err.code},message is ${err.message}`); }); @@ -2989,21 +3016,21 @@ try { } entries.push(entry); } - console.log(`entries: ${entries}`); - kvStore.putBatch(entries, async function (err, data) { + console.info(`entries: ${entries}`); + kvStore.putBatch(entries, async function (err) { if (err != undefined) { console.error(`Failed to put Batch.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in putting Batch'); + console.info('Succeeded in putting Batch'); kvStore.getEntries('batch_test_string_key', function (err, entries) { if (err != undefined) { console.error(`Failed to get Entries.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in getting Entries'); - console.log(`entries.length: ${entries.length}`); - console.log(`entries[0]: ${entries[0]}`); + console.info('Succeeded in getting Entries'); + console.info(`entries.length: ${entries.length}`); + console.info(`entries[0]: ${entries[0]}`); }); }); } catch (e) { @@ -3057,12 +3084,12 @@ try { } entries.push(entry); } - console.log(`entries: ${entries}`); - kvStore.putBatch(entries).then(async (entries) => { - console.log('Succeeded in putting Batch'); + console.info(`entries: ${entries}`); + kvStore.putBatch(entries).then(async () => { + console.info('Succeeded in putting Batch'); kvStore.getEntries('batch_test_string_key').then((entries) => { - console.log('Succeeded in getting Entries'); - console.log(`PutBatch ${entries}`); + console.info('Succeeded in getting Entries'); + console.info(`PutBatch ${entries}`); }).catch((err) => { console.error(`Failed to get Entries.code is ${err.code},message is ${err.message}`); }); @@ -3116,9 +3143,9 @@ try { } entries.push(entry); } - console.log(`entries: {entries}`); - kvStore.putBatch(entries, async function (err, data) { - console.log('Succeeded in putting Batch'); + console.info(`entries: {entries}`); + kvStore.putBatch(entries, async function (err) { + console.info('Succeeded in putting Batch'); const query = new distributedKVStore.Query(); query.prefixKey("batch_test"); kvStore.getEntries(query, function (err, entries) { @@ -3126,9 +3153,9 @@ try { console.error(`Failed to get Entries.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in getting Entries'); - console.log(`entries.length: ${entries.length}`); - console.log(`entries[0]: ${entries[0]}`); + console.info('Succeeded in getting Entries'); + console.info(`entries.length: ${entries.length}`); + console.info(`entries[0]: ${entries[0]}`); }); }); } catch (e) { @@ -3183,20 +3210,20 @@ try { } entries.push(entry); } - console.log(`entries: {entries}`); - kvStore.putBatch(entries).then(async (err) => { - console.log('Succeeded in putting Batch'); + console.info(`entries: {entries}`); + kvStore.putBatch(entries).then(async () => { + console.info('Succeeded in putting Batch'); const query = new distributedKVStore.Query(); query.prefixKey("batch_test"); kvStore.getEntries(query).then((entries) => { - console.log('Succeeded in getting Entries'); + console.info('Succeeded in getting Entries'); }).catch((err) => { console.error(`Failed to get Entries.code is ${err.code},message is ${err.message}`); }); }).catch((err) => { console.error(`Failed to get Entries.code is ${err.code},message is ${err.message}`) }); - console.log('Succeeded in getting Entries'); + console.info('Succeeded in getting Entries'); } catch (e) { console.error(`Failed to get Entries.code is ${e.code},message is ${e.message}`); } @@ -3244,25 +3271,25 @@ try { } entries.push(entry); } - kvStore.putBatch(entries, async function (err, data) { + kvStore.putBatch(entries, async function (err) { if (err != undefined) { console.error(`Failed to put batch.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in putting batch'); + console.info('Succeeded in putting batch'); kvStore.getResultSet('batch_test_string_key', async function (err, result) { if (err != undefined) { console.error(`Failed to get resultset.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in getting result set'); + console.info('Succeeded in getting result set'); resultSet = result; - kvStore.closeResultSet(resultSet, function (err, data) { + kvStore.closeResultSet(resultSet, function (err) { if (err != undefined) { console.error(`Failed to close resultset.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in closing result set'); + console.info('Succeeded in closing result set'); }) }); }); @@ -3318,19 +3345,19 @@ try { } entries.push(entry); } - kvStore.putBatch(entries).then(async (err) => { - console.log('Succeeded in putting batch'); + kvStore.putBatch(entries).then(async () => { + console.info('Succeeded in putting batch'); }).catch((err) => { console.error(`Failed to put batch.code is ${err.code},message is ${err.message}`); }); kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('Succeeded in getting result set'); + console.info('Succeeded in getting result set'); resultSet = result; }).catch((err) => { console.error(`Failed to get resultset.code is ${err.code},message is ${err.message}`); }); - kvStore.closeResultSet(resultSet).then((err) => { - console.log('Succeeded in closing result set'); + kvStore.closeResultSet(resultSet).then(() => { + console.info('Succeeded in closing result set'); }).catch((err) => { console.error(`Failed to close resultset.code is ${err.code},message is ${err.message}`); }); @@ -3381,12 +3408,12 @@ try { } entries.push(entry); } - kvStore.putBatch(entries, async function (err, data) { + kvStore.putBatch(entries, async function (err) { if (err != undefined) { console.error(`Failed to put batch.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in putting batch'); + console.info('Succeeded in putting batch'); const query = new distributedKVStore.Query(); query.prefixKey("batch_test"); kvStore.getResultSet(query, async function (err, result) { @@ -3394,7 +3421,7 @@ try { console.error(`Failed to get resultset.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in getting result set'); + console.info('Succeeded in getting result set'); }); }); } catch (e) { @@ -3449,15 +3476,15 @@ try { } entries.push(entry); } - kvStore.putBatch(entries).then(async (err) => { - console.log('Succeeded in putting batch'); + kvStore.putBatch(entries).then(async () => { + console.info('Succeeded in putting batch'); }).catch((err) => { console.error(`Failed to put batch.code is ${err.code},message is ${err.message}`); }); const query = new distributedKVStore.Query(); query.prefixKey("batch_test"); kvStore.getResultSet(query).then((result) => { - console.log('Succeeded in getting result set'); + console.info('Succeeded in getting result set'); resultSet = result; }).catch((err) => { console.error(`Failed to get resultset.code is ${err.code},message is ${err.message}`); @@ -3508,14 +3535,14 @@ try { console.error(`Failed to get resultset.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in getting result set'); + console.info('Succeeded in getting result set'); resultSet = result; - kvStore.closeResultSet(resultSet, function (err, data) { + kvStore.closeResultSet(resultSet, function (err) { if (err != undefined) { console.error(`Failed to close resultset.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in closing result set'); + console.info('Succeeded in closing result set'); }) }); } catch (e) { @@ -3565,13 +3592,13 @@ try { let predicates = new dataSharePredicates.DataSharePredicates(); predicates.prefixKey("batch_test_string_key"); kvStore.getResultSet(predicates).then((result) => { - console.log('Succeeded in getting result set'); + console.info('Succeeded in getting result set'); resultSet = result; }).catch((err) => { console.error(`Failed to get resultset.code is ${err.code},message is ${err.message}`); }); - kvStore.closeResultSet(resultSet).then((err) => { - console.log('Succeeded in closing result set'); + kvStore.closeResultSet(resultSet).then(() => { + console.info('Succeeded in closing result set'); }).catch((err) => { console.error(`Failed to close resultset.code is ${err.code},message is ${err.message}`); }); @@ -3601,9 +3628,9 @@ Closes the **KVStoreResultSet** object returned by [SingleKvStore.getResultSet]( let kvStore; try { let resultSet = null; - kvStore.closeResultSet(resultSet, function (err, data) { + kvStore.closeResultSet(resultSet, function (err) { if (err == undefined) { - console.log('Succeeded in closing result set'); + console.info('Succeeded in closing result set'); } else { console.error(`Failed to close resultset.code is ${err.code},message is ${err.message}`); } @@ -3640,7 +3667,7 @@ let kvStore; try { let resultSet = null; kvStore.closeResultSet(resultSet).then(() => { - console.log('Succeeded in closing result set'); + console.info('Succeeded in closing result set'); }).catch((err) => { console.error(`Failed to close resultset.code is ${err.code},message is ${err.message}`); }); @@ -3690,8 +3717,8 @@ try { } entries.push(entry); } - kvStore.putBatch(entries, async function (err, data) { - console.log('Succeeded in putting batch'); + kvStore.putBatch(entries, async function (err) { + console.info('Succeeded in putting batch'); const query = new distributedKVStore.Query(); query.prefixKey("batch_test"); kvStore.getResultSize(query, async function (err, resultSize) { @@ -3699,7 +3726,7 @@ try { console.error(`Failed to get result size.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in getting result set size'); + console.info('Succeeded in getting result set size'); }); }); } catch (e) { @@ -3753,15 +3780,15 @@ try { } entries.push(entry); } - kvStore.putBatch(entries).then(async (err) => { - console.log('Succeeded in putting batch'); + kvStore.putBatch(entries).then(async () => { + console.info('Succeeded in putting batch'); }).catch((err) => { console.error(`Failed to put batch.code is ${err.code},message is ${err.message}`); }); const query = new distributedKVStore.Query(); query.prefixKey("batch_test"); kvStore.getResultSize(query).then((resultSize) => { - console.log('Succeeded in getting result set size'); + console.info('Succeeded in getting result set size'); }).catch((err) => { console.error(`Failed to get result size.code is ${err.code},message is ${err.message}`); }); @@ -3799,11 +3826,11 @@ For details about the error codes, see [Distributed KV Store Error Codes](../err let kvStore; let file = "BK001"; try { - kvStore.backup(file, (err, data) => { + kvStore.backup(file, (err) => { if (err) { console.error(`Failed to backup.code is ${err.code},message is ${err.message} `); } else { - console.info(`Succeeded in backupping data.data=${data}`); + console.info(`Succeeded in backupping data`); } }); } catch (e) { @@ -3845,8 +3872,8 @@ For details about the error codes, see [Distributed KV Store Error Codes](../err let kvStore; let file = "BK001"; try { - kvStore.backup(file).then((data) => { - console.info(`Succeeded in backupping data.data=${data}`); + kvStore.backup(file).then(() => { + console.info(`Succeeded in backupping data`); }).catch((err) => { console.error(`Failed to backup.code is ${err.code},message is ${err.message}`); }); @@ -3884,11 +3911,11 @@ For details about the error codes, see [Distributed KV Store Error Codes](../err let kvStore; let file = "BK001"; try { - kvStore.restore(file, (err, data) => { + kvStore.restore(file, (err) => { if (err) { console.error(`Failed to restore.code is ${err.code},message is ${err.message}`); } else { - console.info(`Succeeded in restoring data.data=${data}`); + console.info(`Succeeded in restoring data`); } }); } catch (e) { @@ -3930,8 +3957,8 @@ For details about the error codes, see [Distributed KV Store Error Codes](../err let kvStore; let file = "BK001"; try { - kvStore.restore(file).then((data) => { - console.info(`Succeeded in restoring data.data=${data}`); + kvStore.restore(file).then(() => { + console.info(`Succeeded in restoring data`); }).catch((err) => { console.error(`Failed to restore.code is ${err.code},message is ${err.message}`); }); @@ -4005,7 +4032,7 @@ try { console.error(`Failed to delete Backup.code is ${err.code},message is ${err.message}`); }) } catch (e) { - console.log(`An unexpected error occurred.code is ${e.code},message is ${e.message}`); + console.error(`An unexpected error occurred.code is ${e.code},message is ${e.message}`); } ``` @@ -4053,23 +4080,23 @@ function putBatchString(len, prefix) { try { var count = 0; kvStore.on('dataChange', 0, function (data) { - console.log(`startTransaction 0 ${data}`); + console.info(`startTransaction 0 ${data}`); count++; }); - kvStore.startTransaction(async function (err, data) { + kvStore.startTransaction(async function (err) { if (err != undefined) { console.error(`Failed to start Transaction.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in starting Transaction'); + console.info('Succeeded in starting Transaction'); let entries = putBatchString(10, 'batch_test_string_key'); - console.log(`entries: ${entries}`); - kvStore.putBatch(entries, async function (err, data) { + console.info(`entries: ${entries}`); + kvStore.putBatch(entries, async function (err) { if (err != undefined) { console.error(`Failed to put batch.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in putting Batch'); + console.info('Succeeded in putting Batch'); }); }); } catch (e) { @@ -4106,11 +4133,11 @@ let kvStore; try { var count = 0; kvStore.on('dataChange', distributedKVStore.SubscribeType.SUBSCRIBE_TYPE_ALL, function (data) { - console.log(`startTransaction 0 ${data}`); + console.info(`startTransaction 0 ${data}`); count++; }); - kvStore.startTransaction().then(async (err) => { - console.log('Succeeded in starting Transaction'); + kvStore.startTransaction().then(async () => { + console.info('Succeeded in starting Transaction'); }).catch((err) => { console.error(`Failed to start Transaction.code is ${err.code},message is ${err.message}`); }); @@ -4146,9 +4173,9 @@ For details about the error codes, see [Distributed KV Store Error Codes](../err ```js let kvStore; try { - kvStore.commit(function (err, data) { + kvStore.commit(function (err) { if (err == undefined) { - console.log('Succeeded in committing'); + console.info('Succeeded in committing'); } else { console.error(`Failed to commit.code is ${err.code},message is ${err.message}`); } @@ -4185,13 +4212,13 @@ For details about the error codes, see [Distributed KV Store Error Codes](../err ```js let kvStore; try { - kvStore.commit().then(async (err) => { - console.log('Succeeded in committing'); + kvStore.commit().then(async () => { + console.info('Succeeded in committing'); }).catch((err) => { console.error(`Failed to commit.code is ${err.code},message is ${err.message}`); }); } catch (e) { - console.error(`An unexpected error occurred.ode is ${e.code},message is ${e.message}`); + console.error(`An unexpected error occurred.code is ${e.code},message is ${e.message}`); } ``` @@ -4222,9 +4249,9 @@ For details about the error codes, see [Distributed KV Store Error Codes](../err ```js let kvStore; try { - kvStore.rollback(function (err,data) { + kvStore.rollback(function (err) { if (err == undefined) { - console.log('Succeeded in rolling back'); + console.info('Succeeded in rolling back'); } else { console.error(`Failed to rollback.code is ${err.code},message is ${err.message}`); } @@ -4261,8 +4288,8 @@ For details about the error codes, see [Distributed KV Store Error Codes](../err ```js let kvStore; try { - kvStore.rollback().then(async (err) => { - console.log('Succeeded in rolling back'); + kvStore.rollback().then(async () => { + console.info('Succeeded in rolling back'); }).catch((err) => { console.error(`Failed to rollback.code is ${err.code},message is ${err.message}`); }); @@ -4291,9 +4318,9 @@ Sets data synchronization, which can be enabled or disabled. This API uses an as ```js let kvStore; try { - kvStore.enableSync(true, function (err, data) { + kvStore.enableSync(true, function (err) { if (err == undefined) { - console.log('Succeeded in enabling sync'); + console.info('Succeeded in enabling sync'); } else { console.error(`Failed to enable sync.code is ${err.code},message is ${err.message}`); } @@ -4328,8 +4355,8 @@ Sets data synchronization, which can be enabled or disabled. This API uses a pro ```js let kvStore; try { - kvStore.enableSync(true).then((err) => { - console.log('Succeeded in enabling sync'); + kvStore.enableSync(true).then(() => { + console.info('Succeeded in enabling sync'); }).catch((err) => { console.error(`Failed to enable sync.code is ${err.code},message is ${err.message}`); }); @@ -4361,12 +4388,12 @@ let kvStore; try { const localLabels = ['A', 'B']; const remoteSupportLabels = ['C', 'D']; - kvStore.setSyncRange(localLabels, remoteSupportLabels, function (err, data) { + kvStore.setSyncRange(localLabels, remoteSupportLabels, function (err) { if (err != undefined) { console.error(`Failed to set syncRange.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in setting syncRange'); + console.info('Succeeded in setting syncRange'); }); } catch (e) { console.error(`An unexpected error occurred.code is ${e.code},message is ${e.message}`); @@ -4401,8 +4428,8 @@ let kvStore; try { const localLabels = ['A', 'B']; const remoteSupportLabels = ['C', 'D']; - kvStore.setSyncRange(localLabels, remoteSupportLabels).then((err) => { - console.log('Succeeded in setting syncRange'); + kvStore.setSyncRange(localLabels, remoteSupportLabels).then(() => { + console.info('Succeeded in setting syncRange'); }).catch((err) => { console.error(`Failed to set syncRange.code is ${err.code},message is ${err.message}`); }); @@ -4432,12 +4459,12 @@ Sets the default delay allowed for KV store synchronization. This API uses an as let kvStore; try { const defaultAllowedDelayMs = 500; - kvStore.setSyncParam(defaultAllowedDelayMs, function (err, data) { + kvStore.setSyncParam(defaultAllowedDelayMs, function (err) { if (err != undefined) { console.error(`Failed to set syncParam.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in setting syncParam'); + console.info('Succeeded in setting syncParam'); }); } catch (e) { console.error(`An unexpected error occurred.code is ${e.code},message is ${e.message}`); @@ -4470,8 +4497,8 @@ Sets the default delay allowed for KV store synchronization. This API uses a pro let kvStore; try { const defaultAllowedDelayMs = 500; - kvStore.setSyncParam(defaultAllowedDelayMs).then((err) => { - console.log('Succeeded in setting syncParam'); + kvStore.setSyncParam(defaultAllowedDelayMs).then(() => { + console.info('Succeeded in setting syncParam'); }).catch((err) => { console.error(`Failed to set syncParam.code is ${err.code},message is ${err.message}`); }); @@ -4499,7 +4526,7 @@ Synchronizes the KV store manually. For details about the synchronization modes | --------- | --------------------- | ---- | ---------------------------------------------- | | deviceIds | string[] | Yes | List of IDs of the devices in the same networking environment to be synchronized.| | mode | [SyncMode](#syncmode) | Yes | Synchronization mode. | -| delayMs | number | No | Allowed synchronization delay time, in ms. | +| delayMs | number | No | Allowed synchronization delay time, in ms. The default value is **0**. | **Error codes** @@ -4532,14 +4559,14 @@ deviceManager.createDeviceManager('bundleName', (err, value) => { } try { kvStore.on('syncComplete', function (data) { - console.log('Sync dataChange'); + console.info('Sync dataChange'); }); - kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync101', VALUE_TEST_SYNC_ELEMENT, function (err, data) { + kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync101', VALUE_TEST_SYNC_ELEMENT, function (err) { if (err != undefined) { console.error(`Failed to sync.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in putting data'); + console.info('Succeeded in putting data'); const mode = distributedKVStore.SyncMode.PULL_ONLY; kvStore.sync(deviceIds, mode, 1000); }); @@ -4570,7 +4597,7 @@ Synchronizes the KV store manually. This API returns the result synchronously. F | deviceIds | string[] | Yes | List of IDs of the devices in the same networking environment to be synchronized.| | mode | [SyncMode](#syncmode) | Yes | Synchronization mode. | | query | [Query](#query) | Yes | **Query** object to match. | -| delayMs | number | No | Allowed synchronization delay time, in ms. | +| delayMs | number | No | Allowed synchronization delay time, in ms. The default value is **0**. | **Error codes** @@ -4603,14 +4630,14 @@ deviceManager.createDeviceManager('bundleName', (err, value) => { } try { kvStore.on('syncComplete', function (data) { - console.log('Sync dataChange'); + console.info('Sync dataChange'); }); - kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync101', VALUE_TEST_SYNC_ELEMENT, function (err, data) { + kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync101', VALUE_TEST_SYNC_ELEMENT, function (err) { if (err != undefined) { console.error(`Failed to sync.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in putting data'); + console.info('Succeeded in putting data'); const mode = distributedKVStore.SyncMode.PULL_ONLY; const query = new distributedKVStore.Query(); query.prefixKey("batch_test"); @@ -4655,7 +4682,7 @@ For details about the error codes, see [Distributed KV Store Error Codes](../err let kvStore; try { kvStore.on('dataChange', distributedKVStore.SubscribeType.SUBSCRIBE_TYPE_LOCAL, function (data) { - console.log(`dataChange callback call data: ${data}`); + console.info(`dataChange callback call data: ${data}`); }); } catch (e) { console.error(`An unexpected error occurred.code is ${e.code},message is ${e.message}`); @@ -4685,10 +4712,10 @@ const KEY_TEST_FLOAT_ELEMENT = 'key_test_float'; const VALUE_TEST_FLOAT_ELEMENT = 321.12; try { kvStore.on('syncComplete', function (data) { - console.log(`syncComplete ${data}`); + console.info(`syncComplete ${data}`); }); - kvStore.put(KEY_TEST_FLOAT_ELEMENT, VALUE_TEST_FLOAT_ELEMENT).then((data) => { - console.log('succeeded in putting'); + kvStore.put(KEY_TEST_FLOAT_ELEMENT, VALUE_TEST_FLOAT_ELEMENT).then(() => { + console.info('succeeded in putting'); }).catch((err) => { console.error(`Failed to put.code is ${err.code},message is ${err.message}`); }); @@ -4710,7 +4737,7 @@ Unsubscribes from data changes. | Name | Type | Mandatory| Description | | -------- | --------------------------------------------------------- | ---- | -------------------------------------------------------- | | event | string | Yes | Event to unsubscribe from. The value is **dataChange**, which indicates a data change event.| -| listener | Callback<[ChangeNotification](#changenotification)> | No | Callback for data changes. | +| listener | Callback<[ChangeNotification](#changenotification)> | No | Callback for data changes. If the callback is not specified, all subscriptions to the data change event will be canceled. | **Error codes** @@ -4726,7 +4753,7 @@ For details about the error codes, see [Distributed KV Store Error Codes](../err let kvStore; class KvstoreModel { call(data) { - console.log(`dataChange : ${data}`); + console.info(`dataChange : ${data}`); } subscribeDataChange() { @@ -4764,7 +4791,7 @@ Unsubscribes from synchronization complete events. | Name | Type | Mandatory| Description | | ------------ | --------------------------------------------- | ---- | ---------------------------------------------------------- | | event | string | Yes | Event to unsubscribe from. The value is **syncComplete**, which indicates a synchronization complete event.| -| syncCallback | Callback<Array<[string, number]>> | No | Callback for the synchronization complete event. | +| syncCallback | Callback<Array<[string, number]>> | No | Callback for the synchronization complete event. If the callback is not specified, all subscriptions to the synchronization complete event will be canceled. | **Example** @@ -4772,7 +4799,7 @@ Unsubscribes from synchronization complete events. let kvStore; class KvstoreModel { call(data) { - console.log(`syncComplete : ${data}`); + console.info(`syncComplete : ${data}`); } subscribeDataChange() { @@ -4829,7 +4856,7 @@ try { console.error(`Failed to get SecurityLevel.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in getting securityLevel'); + console.info('Succeeded in getting securityLevel'); }); } catch (e) { console.error(`An unexpected error occurred.code is ${e.code},message is ${e.message}`); @@ -4864,7 +4891,7 @@ For details about the error codes, see [Distributed KV Store Error Codes](../err let kvStore; try { kvStore.getSecurityLevel().then((data) => { - console.log('Succeeded in getting securityLevel'); + console.info('Succeeded in getting securityLevel'); }).catch((err) => { console.error(`Failed to get SecurityLevel.code is ${err.code},message is ${err.message}`); }); @@ -4915,18 +4942,18 @@ let kvStore; const KEY_TEST_STRING_ELEMENT = 'key_test_string'; const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; try { - kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err, data) { + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err) { if (err != undefined) { console.error(`Failed to put.code is ${err.code},message is ${err.message}`); return; } - console.log("Succeeded in putting"); + console.info("Succeeded in putting"); kvStore.get(KEY_TEST_STRING_ELEMENT, function (err, data) { if (err != undefined) { console.error(`Failed to get.code is ${err.code},message is ${err.message}`); return; } - console.log(`Succeeded in getting data.data=${data}`); + console.info(`Succeeded in getting data.data=${data}`); }); }); } catch (e) { @@ -4971,10 +4998,10 @@ let kvStore; const KEY_TEST_STRING_ELEMENT = 'key_test_string'; const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; try { - kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((data) => { - console.log(`Succeeded in putting data.data=${data}`); + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then(() => { + console.info(`Succeeded in putting data`); kvStore.get(KEY_TEST_STRING_ELEMENT).then((data) => { - console.log(`Succeeded in getting data.data=${data}`); + console.info(`Succeeded in getting data.data=${data}`); }).catch((err) => { console.error(`Failed to get.code is ${err.code},message is ${err.message}`); }); @@ -5019,18 +5046,18 @@ let kvStore; const KEY_TEST_STRING_ELEMENT = 'key_test_string_2'; const VALUE_TEST_STRING_ELEMENT = 'value-string-002'; try { - kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, async function (err, data) { + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, async function (err) { if (err != undefined) { console.error(`Failed to put.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in putting'); + console.info('Succeeded in putting'); kvStore.get('localDeviceId', KEY_TEST_STRING_ELEMENT, function (err, data) { if (err != undefined) { console.error(`Failed to get.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in getting'); + console.info('Succeeded in getting'); }); }) } catch (e) { @@ -5076,10 +5103,10 @@ let kvStore; const KEY_TEST_STRING_ELEMENT = 'key_test_string_2'; const VALUE_TEST_STRING_ELEMENT = 'value-string-002'; try { - kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then(async (data) => { - console.log('Succeeded in putting'); + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then(async () => { + console.info('Succeeded in putting'); kvStore.get('localDeviceId', KEY_TEST_STRING_ELEMENT).then((data) => { - console.log('Succeeded in getting'); + console.info('Succeeded in getting'); }).catch((err) => { console.error(`Failed to get.code is ${err.code},message is ${err.message}`); }); @@ -5132,21 +5159,21 @@ try { } entries.push(entry); } - console.log(`entries: ${entries}`); - kvStore.putBatch(entries, async function (err, data) { + console.info(`entries: ${entries}`); + kvStore.putBatch(entries, async function (err) { if (err != undefined) { console.error(`Failed to put Batch.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in putting Batch'); + console.info('Succeeded in putting Batch'); kvStore.getEntries('batch_test_string_key', function (err, entries) { if (err != undefined) { console.error(`Failed to get Entries.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in getting Entries'); - console.log(`entries.length: ${entries.length}`); - console.log(`entries[0]: ${entries[0]}`); + console.info('Succeeded in getting Entries'); + console.info(`entries.length: ${entries.length}`); + console.info(`entries[0]: ${entries[0]}`); }); }); } catch (e) { @@ -5200,12 +5227,12 @@ try { } entries.push(entry); } - console.log(`entries: ${entries}`); - kvStore.putBatch(entries).then(async (entries) => { - console.log('Succeeded in putting Batch'); + console.info(`entries: ${entries}`); + kvStore.putBatch(entries).then(async () => { + console.info('Succeeded in putting Batch'); kvStore.getEntries('batch_test_string_key').then((entries) => { - console.log('Succeeded in getting Entries'); - console.log(`PutBatch ${entries}`); + console.info('Succeeded in getting Entries'); + console.info(`PutBatch ${entries}`); }).catch((err) => { console.error(`Failed to get Entries.code is ${err.code},message is ${err.message}`); }); @@ -5259,21 +5286,21 @@ try { } entries.push(entry); } - console.log(`entries : ${entries}`); - kvStore.putBatch(entries, async function (err, data) { + console.info(`entries : ${entries}`); + kvStore.putBatch(entries, async function (err) { if (err != undefined) { console.error(`Failed to put batch.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in putting batch'); + console.info('Succeeded in putting batch'); kvStore.getEntries('localDeviceId', 'batch_test_string_key', function (err, entries) { if (err != undefined) { console.error(`Failed to get entries.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in getting entries'); - console.log(`entries.length: ${entries.length}`); - console.log(`entries[0]: ${entries[0]}`); + console.info('Succeeded in getting entries'); + console.info(`entries.length: ${entries.length}`); + console.info(`entries[0]: ${entries[0]}`); }); }); } catch (e) { @@ -5328,15 +5355,15 @@ try { } entries.push(entry); } - console.log(`entries: ${entries}`); - kvStore.putBatch(entries).then(async (err) => { - console.log('Succeeded in putting batch'); + console.info(`entries: ${entries}`); + kvStore.putBatch(entries).then(async () => { + console.info('Succeeded in putting batch'); kvStore.getEntries('localDeviceId', 'batch_test_string_key').then((entries) => { - console.log('Succeeded in getting entries'); - console.log(`entries.length: ${entries.length}`); - console.log(`entries[0]: ${entries[0]}`); - console.log(`entries[0].value: ${entries[0].value}`); - console.log(`entries[0].value.value: ${entries[0].value.value}`); + console.info('Succeeded in getting entries'); + console.info(`entries.length: ${entries.length}`); + console.info(`entries[0]: ${entries[0]}`); + console.info(`entries[0].value: ${entries[0].value}`); + console.info(`entries[0].value.value: ${entries[0].value.value}`); }).catch((err) => { console.error(`Failed to get entries.code is ${err.code},message is ${err.message}`); }); @@ -5390,9 +5417,9 @@ try { } entries.push(entry); } - console.log(`entries: {entries}`); - kvStore.putBatch(entries, async function (err, data) { - console.log('Succeeded in putting Batch'); + console.info(`entries: {entries}`); + kvStore.putBatch(entries, async function (err) { + console.info('Succeeded in putting Batch'); const query = new distributedKVStore.Query(); query.prefixKey("batch_test"); kvStore.getEntries(query, function (err, entries) { @@ -5400,9 +5427,9 @@ try { console.error(`Failed to get Entries.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in getting Entries'); - console.log(`entries.length: ${entries.length}`); - console.log(`entries[0]: ${entries[0]}`); + console.info('Succeeded in getting Entries'); + console.info(`entries.length: ${entries.length}`); + console.info(`entries[0]: ${entries[0]}`); }); }); } catch (e) { @@ -5457,20 +5484,20 @@ try { } entries.push(entry); } - console.log(`entries: {entries}`); - kvStore.putBatch(entries).then(async (err) => { - console.log('Succeeded in putting Batch'); + console.info(`entries: {entries}`); + kvStore.putBatch(entries).then(async () => { + console.info('Succeeded in putting Batch'); const query = new distributedKVStore.Query(); query.prefixKey("batch_test"); kvStore.getEntries(query).then((entries) => { - console.log('Succeeded in getting Entries'); + console.info('Succeeded in getting Entries'); }).catch((err) => { console.error(`Failed to get Entries.code is ${err.code},message is ${err.message}`); }); }).catch((err) => { console.error(`Failed to get Entries.code is ${err.code},message is ${err.message}`) }); - console.log('Succeeded in getting Entries'); + console.info('Succeeded in getting Entries'); } catch (e) { console.error(`Failed to get Entries.code is ${e.code},message is ${e.message}`); } @@ -5519,13 +5546,13 @@ try { } entries.push(entry); } - console.log(`entries: ${entries}`); - kvStore.putBatch(entries, async function (err, data) { + console.info(`entries: ${entries}`); + kvStore.putBatch(entries, async function (err) { if (err != undefined) { console.error(`Failed to put batch.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in putting batch'); + console.info('Succeeded in putting batch'); var query = new distributedKVStore.Query(); query.deviceId('localDeviceId'); query.prefixKey("batch_test"); @@ -5534,12 +5561,12 @@ try { console.error(`Failed to get entries.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in getting entries'); - console.log(`entries.length: ${entries.length}`); - console.log(`entries[0]: ${entries[0]}`); + console.info('Succeeded in getting entries'); + console.info(`entries.length: ${entries.length}`); + console.info(`entries[0]: ${entries[0]}`); }) }); - console.log('Succeeded in getting entries'); + console.info('Succeeded in getting entries'); } catch (e) { console.error(`Failed to get entries.code is ${e.code},message is ${e.message}`); } @@ -5593,21 +5620,21 @@ try { } entries.push(entry); } - console.log(`entries: ${entries}`); - kvStore.putBatch(entries).then(async (err) => { - console.log('Succeeded in putting batch'); + console.info(`entries: ${entries}`); + kvStore.putBatch(entries).then(async () => { + console.info('Succeeded in putting batch'); var query = new distributedKVStore.Query(); query.deviceId('localDeviceId'); query.prefixKey("batch_test"); kvStore.getEntries('localDeviceId', query).then((entries) => { - console.log('Succeeded in getting entries'); + console.info('Succeeded in getting entries'); }).catch((err) => { console.error(`Failed to get entries.code is ${err.code},message is ${err.message}`); }); }).catch((err) => { console.error(`Failed to put batch.code is ${err.code},message is ${err.message}`); }); - console.log('Succeeded in getting entries'); + console.info('Succeeded in getting entries'); } catch (e) { console.error(`Failed to get entries.code is ${e.code},message is ${e.message}`); } @@ -5655,25 +5682,25 @@ try { } entries.push(entry); } - kvStore.putBatch(entries, async function (err, data) { + kvStore.putBatch(entries, async function (err) { if (err != undefined) { console.error(`Failed to put batch.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in putting batch'); + console.info('Succeeded in putting batch'); kvStore.getResultSet('batch_test_string_key', async function (err, result) { if (err != undefined) { console.error(`Failed to get resultset.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in getting result set'); + console.info('Succeeded in getting result set'); resultSet = result; - kvStore.closeResultSet(resultSet, function (err, data) { + kvStore.closeResultSet(resultSet, function (err) { if (err != undefined) { console.error(`Failed to close resultset.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in closing result set'); + console.info('Succeeded in closing result set'); }) }); }); @@ -5729,19 +5756,19 @@ try { } entries.push(entry); } - kvStore.putBatch(entries).then(async (err) => { - console.log('Succeeded in putting batch'); + kvStore.putBatch(entries).then(async () => { + console.info('Succeeded in putting batch'); }).catch((err) => { console.error(`Failed to put batch.code is ${err.code},message is ${err.message}`); }); kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('Succeeded in getting result set'); + console.info('Succeeded in getting result set'); resultSet = result; }).catch((err) => { console.error(`Failed to get resultset.code is ${err.code},message is ${err.message}`); }); - kvStore.closeResultSet(resultSet).then((err) => { - console.log('Succeeded in closing result set'); + kvStore.closeResultSet(resultSet).then(() => { + console.info('Succeeded in closing result set'); }).catch((err) => { console.error(`Failed to close resultset.code is ${err.code},message is ${err.message}`); }); @@ -5786,14 +5813,14 @@ try { console.error(`Failed to get resultSet.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in getting resultSet'); + console.info('Succeeded in getting resultSet'); resultSet = result; - kvStore.closeResultSet(resultSet, function (err, data) { + kvStore.closeResultSet(resultSet, function (err) { if (err != undefined) { console.error(`Failed to close resultSet.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in closing resultSet'); + console.info('Succeeded in closing resultSet'); }) }); } catch (e) { @@ -5838,13 +5865,13 @@ let kvStore; try { let resultSet; kvStore.getResultSet('localDeviceId', 'batch_test_string_key').then((result) => { - console.log('Succeeded in getting resultSet'); + console.info('Succeeded in getting resultSet'); resultSet = result; }).catch((err) => { console.error(`Failed to get resultSet.code is ${err.code},message is ${err.message}`); }); - kvStore.closeResultSet(resultSet).then((err) => { - console.log('Succeeded in closing resultSet'); + kvStore.closeResultSet(resultSet).then(() => { + console.info('Succeeded in closing resultSet'); }).catch((err) => { console.error(`Failed to close resultSet.code is ${err.code},message is ${err.message}`); }); @@ -5896,12 +5923,12 @@ try { } entries.push(entry); } - kvStore.putBatch(entries, async function (err, data) { + kvStore.putBatch(entries, async function (err) { if (err != undefined) { console.error(`Failed to put batch.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in putting batch'); + console.info('Succeeded in putting batch'); const query = new distributedKVStore.Query(); query.prefixKey("batch_test"); kvStore.getResultSet('localDeviceId', query, async function (err, result) { @@ -5909,14 +5936,14 @@ try { console.error(`Failed to get resultSet.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in getting resultSet'); + console.info('Succeeded in getting resultSet'); resultSet = result; - kvStore.closeResultSet(resultSet, function (err, data) { + kvStore.closeResultSet(resultSet, function (err) { if (err != undefined) { console.error(`Failed to close resultSet.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in closing resultSet'); + console.info('Succeeded in closing resultSet'); }) }); }); @@ -5973,23 +6000,23 @@ try { } entries.push(entry); } - kvStore.putBatch(entries).then(async (err) => { - console.log('Succeeded in putting batch'); + kvStore.putBatch(entries).then(async () => { + console.info('Succeeded in putting batch'); }).catch((err) => { console.error(`Failed to put batch.code is ${err.code},message is ${err.message}`); }); const query = new distributedKVStore.Query(); query.prefixKey("batch_test"); kvStore.getResultSet('localDeviceId', query).then((result) => { - console.log('Succeeded in getting resultSet'); + console.info('Succeeded in getting resultSet'); resultSet = result; }).catch((err) => { console.error(`Failed to get resultSet.code is ${err.code},message is ${err.message}`); }); query.deviceId('localDeviceId'); - console.log("GetResultSet " + query.getSqlLike()); - kvStore.closeResultSet(resultSet).then((err) => { - console.log('Succeeded in closing resultSet'); + console.info("GetResultSet " + query.getSqlLike()); + kvStore.closeResultSet(resultSet).then(() => { + console.info('Succeeded in closing resultSet'); }).catch((err) => { console.error(`Failed to close resultSet.code is ${err.code},message is ${err.message}`); }); @@ -6046,18 +6073,18 @@ try { } entries.push(entry); } - kvStore.putBatch(entries).then(async (err) => { - console.log('Succeeded in putting batch'); + kvStore.putBatch(entries).then(async () => { + console.info('Succeeded in putting batch'); }).catch((err) => { console.error(`Failed to put batch.code is ${err.code},message is ${err.message}`); }); const query = new distributedKVStore.Query(); query.prefixKey("batch_test"); kvStore.getResultSet(query).then((result) => { - console.log('Succeeded in getting result set'); + console.info('Succeeded in getting result set'); resultSet = result; }).catch((err) => { - console.error(`Failed to get resultset.code is ${err.code},message is ${err.message}`); + console.error(`Fail to get resultset.code is ${err.code},message is ${err.message}`); }); } catch (e) { console.error(`An unexpected error occurred.code is ${e.code},message is ${e.code}`); @@ -6066,24 +6093,18 @@ try { ### getResultSet -getResultSet(deviceId: string, query: Query): Promise<KVStoreResultSet> +getResultSet(query: Query, callback:AsyncCallback<KVStoreResultSet>): void Obtains a **KVStoreResultSet** object that matches the specified device ID and **Query** object. This API uses a promise to return the result. -**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core **Parameters** | Name | Type | Mandatory| Description | | -------- | -------------- | ---- | ---------------------------------- | -| deviceId | string | Yes | ID of the device to which the **KVStoreResultSet** object belongs.| | query | [Query](#query) | Yes | **Query** object to match. | - -**Return value** - -| Type | Description | -| ---------------------------------------------------- | ------------------------------------------------------------ | -| Promise<[KVStoreResultSet](#kvstoreresultset)> | Promise used to return the **KVStoreResultSet** object obtained.| +| callback | AsyncCallback<[KVStoreResultSet](#kvstoreresultset)> | Yes | Callback invoked to return the **KVStoreResultSet** object obtained. | **Error codes** @@ -6112,27 +6133,30 @@ try { } entries.push(entry); } - kvStore.putBatch(entries).then(async (err) => { - console.log('Succeeded in putting batch'); - }).catch((err) => { - console.error(`Failed to put batch.code is ${err.code},message is ${err.message}`); - }); - const query = new distributedKVStore.Query(); - query.prefixKey("batch_test"); - kvStore.getResultSet('localDeviceId', query).then((result) => { - console.log('Succeeded in getting resultSet'); - resultSet = result; - }).catch((err) => { - console.error(`Failed to get resultSet.code is ${err.code},message is ${err.message}`); - }); - query.deviceId('localDeviceId'); - console.log("GetResultSet " + query.getSqlLike()); - kvStore.closeResultSet(resultSet).then((err) => { - console.log('Succeeded in closing resultSet'); - }).catch((err) => { - console.error(`Failed to close resultSet.code is ${err.code},message is ${err.message}`); + kvStore.putBatch(entries, async function (err) { + if (err != undefined) { + console.error(`Failed to put batch.code is ${err.code},message is ${err.message}`); + return; + } + console.info('Succeeded in putting batch'); + const query = new distributedKVStore.Query(); + query.prefixKey("batch_test"); + kvStore.getResultSet(query, async function (err, result) { + if (err != undefined) { + console.error(`Failed to get resultSet.code is ${err.code},message is ${err.message}`); + return; + } + console.info('Succeeded in getting resultSet'); + resultSet = result; + kvStore.closeResultSet(resultSet, function (err) { + if (err != undefined) { + console.error(`Failed to close resultSet.code is ${err.code},message is ${err.message}`); + return; + } + console.info('Succeeded in closing resultSet'); + }) + }); }); - } catch (e) { console.error(`Failed to get resultSet.code is ${e.code},message is ${e.message}`); } @@ -6179,14 +6203,14 @@ try { console.error(`Failed to get resultset.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in getting result set'); + console.info('Succeeded in getting result set'); resultSet = result; - kvStore.closeResultSet(resultSet, function (err, data) { + kvStore.closeResultSet(resultSet, function (err) { if (err != undefined) { console.error(`Failed to close resultset.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in closing result set'); + console.info('Succeeded in closing result set'); }) }); } catch (e) { @@ -6236,13 +6260,13 @@ try { let predicates = new dataSharePredicates.DataSharePredicates(); predicates.prefixKey("batch_test_string_key"); kvStore.getResultSet(predicates).then((result) => { - console.log('Succeeded in getting result set'); + console.info('Succeeded in getting result set'); resultSet = result; }).catch((err) => { console.error(`Failed to get resultset.code is ${err.code},message is ${err.message}`); }); - kvStore.closeResultSet(resultSet).then((err) => { - console.log('Succeeded in closing result set'); + kvStore.closeResultSet(resultSet).then(() => { + console.info('Succeeded in closing result set'); }).catch((err) => { console.error(`Failed to close resultset.code is ${err.code},message is ${err.message}`); }); @@ -6293,14 +6317,14 @@ try { console.error(`Failed to get resultset.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in getting result set'); + console.info('Succeeded in getting result set'); resultSet = result; - kvStore.closeResultSet(resultSet, function (err, data) { + kvStore.closeResultSet(resultSet, function (err) { if (err != undefined) { console.error(`Failed to close resultset.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in closing result set'); + console.info('Succeeded in closing result set'); }) }); } catch (e) { @@ -6350,13 +6374,13 @@ try { let predicates = new dataSharePredicates.DataSharePredicates(); predicates.prefixKey("batch_test_string_key"); kvStore.getResultSet('localDeviceId', predicates).then((result) => { - console.log('Succeeded in getting result set'); + console.info('Succeeded in getting result set'); resultSet = result; }).catch((err) => { console.error(`Failed to get resultset.code is ${err.code},message is ${err.message}`); }); - kvStore.closeResultSet(resultSet).then((err) => { - console.log('Succeeded in closing result set'); + kvStore.closeResultSet(resultSet).then(() => { + console.info('Succeeded in closing result set'); }).catch((err) => { console.error(`Failed to close resultset.code is ${err.code},message is ${err.message}`); }); @@ -6406,8 +6430,8 @@ try { } entries.push(entry); } - kvStore.putBatch(entries, async function (err, data) { - console.log('Succeeded in putting batch'); + kvStore.putBatch(entries, async function (err) { + console.info('Succeeded in putting batch'); const query = new distributedKVStore.Query(); query.prefixKey("batch_test"); kvStore.getResultSize(query, async function (err, resultSize) { @@ -6415,7 +6439,7 @@ try { console.error(`Failed to get result size.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in getting result set size'); + console.info('Succeeded in getting result set size'); }); }); } catch (e) { @@ -6469,15 +6493,15 @@ try { } entries.push(entry); } - kvStore.putBatch(entries).then(async (err) => { - console.log('Succeeded in putting batch'); + kvStore.putBatch(entries).then(async () => { + console.info('Succeeded in putting batch'); }).catch((err) => { console.error(`Failed to put batch.code is ${err.code},message is ${err.message}`); }); const query = new distributedKVStore.Query(); query.prefixKey("batch_test"); kvStore.getResultSize(query).then((resultSize) => { - console.log('Succeeded in getting result set size'); + console.info('Succeeded in getting result set size'); }).catch((err) => { console.error(`Failed to get result size.code is ${err.code},message is ${err.message}`); }); @@ -6528,12 +6552,12 @@ try { } entries.push(entry); } - kvStore.putBatch(entries, async function (err, data) { + kvStore.putBatch(entries, async function (err) { if (err != undefined) { console.error(`Failed to put batch.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in putting batch'); + console.info('Succeeded in putting batch'); const query = new distributedKVStore.Query(); query.prefixKey("batch_test"); kvStore.getResultSize('localDeviceId', query, async function (err, resultSize) { @@ -6541,8 +6565,7 @@ try { console.error(`Failed to get resultSize.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in getting resultSize'); - ; + console.info('Succeeded in getting resultSize'); }); }); } catch (e) { @@ -6597,16 +6620,15 @@ try { } entries.push(entry); } - kvStore.putBatch(entries).then(async (err) => { - console.log('Succeeded in putting batch'); + kvStore.putBatch(entries).then(async () => { + console.info('Succeeded in putting batch'); }).catch((err) => { console.error(`Failed to put batch.code is ${err.code},message is ${err.message}`); }); var query = new distributedKVStore.Query(); query.prefixKey("batch_test"); kvStore.getResultSize('localDeviceId', query).then((resultSize) => { - console.log('Succeeded in getting resultSize'); - ; + console.info('Succeeded in getting resultSize'); }).catch((err) => { console.error(`Failed to get resultSize.code is ${err.code},message is ${err.message}`); }); diff --git a/en/application-dev/reference/apis/js-apis-fileShare.md b/en/application-dev/reference/apis/js-apis-fileShare.md index 2d0d66de9f6e9860e16820d40d13908767359127..5293993000d0ff6015053875e5093b47f48ef127 100644 --- a/en/application-dev/reference/apis/js-apis-fileShare.md +++ b/en/application-dev/reference/apis/js-apis-fileShare.md @@ -14,7 +14,7 @@ import fileShare from '@ohos.fileshare'; ## fileShare.grantUriPermission -grantUriPermission(uri: string, bundleName: string, mode: number, callback: AsyncCallback<void>): void +grantUriPermission(uri: string, bundleName: string, flag: wantConstant.Flags, callback: AsyncCallback<void>): void Grants permissions on a user file by the URI to an application. This API uses an asynchronous callback to return the result. @@ -30,7 +30,7 @@ Grants permissions on a user file by the URI to an application. This API uses an | ------ | ------ | ---- | -------------------------- | | uri | string | Yes | URI of a user file.| | bundleName | string | Yes | Bundle name of the application to be grated with the permissions.| -| mode | number | Yes | Permissions to grant. For details, see [wantConstant.Flags](js-apis-app-ability-wantConstant.md#wantconstantflags).
**wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION**: permission to read the file.
**wantConstant.Flags.FLAG_AUTH_WRITE_URI_PERMISSION**: permission to write the file.| +| flag | wantConstant.Flags | Yes | Permissions to grant. For details, see [wantConstant.Flags](js-apis-app-ability-wantConstant.md#wantconstantflags).
**wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION**: permission to read the file.
**wantConstant.Flags.FLAG_AUTH_WRITE_URI_PERMISSION**: permission to write the file.| | callback | AsyncCallback<void> | Yes | Callback invoked to return the result. | **Error codes** @@ -67,7 +67,7 @@ try { ## fileShare.grantUriPermission -grantUriPermission(uri: string, bundleName: string, mode: number): Promise<void> +grantUriPermission(uri: string, bundleName: string, flag: wantConstant.Flags): Promise<void> Grants permissions on a user file by the URI to an application. This API uses a promise to return the result. @@ -83,7 +83,7 @@ Grants permissions on a user file by the URI to an application. This API uses a | ------ | ------ | ---- | -------------------------- | | uri | string | Yes | URI of a user file.| | bundleName | string | Yes | Bundle name of the application to be grated with the permissions.| -| mode | number | Yes | Permissions to grant. For details, see [wantConstant.Flags](js-apis-app-ability-wantConstant.md#wantconstantflags).
**wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION**: permission to read the file.
**wantConstant.Flags.FLAG_AUTH_WRITE_URI_PERMISSION**: permission to write the file.| +| flag | wantConstant.Flags | Yes | Permissions to grant. For details, see [wantConstant.Flags](js-apis-app-ability-wantConstant.md#wantconstantflags).
**wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION**: permission to read the file.
**wantConstant.Flags.FLAG_AUTH_WRITE_URI_PERMISSION**: permission to write the file.| **Return value** diff --git a/en/application-dev/reference/apis/js-apis-fileio.md b/en/application-dev/reference/apis/js-apis-fileio.md index 1d326862153ed88bbc7bc1c53ffedbdce5d90e80..d0e243b5347338ff8fcef509777281d45f2f215f 100644 --- a/en/application-dev/reference/apis/js-apis-fileio.md +++ b/en/application-dev/reference/apis/js-apis-fileio.md @@ -21,8 +21,9 @@ Before using the APIs provided by this module to perform operations on files or **Stage Model** ```js -import Ability from '@ohos.application.Ability'; -class MainAbility extends Ability { +import UIAbility from '@ohos.app.ability.UIAbility'; + +export default class EntryAbility extends UIAbility { onWindowStageCreate(windowStage) { let context = this.context; let pathDir = context.filesDir; @@ -30,19 +31,18 @@ class MainAbility extends Ability { } ``` - For details about how to obtain the stage model context, see [UIAbilityContext](js-apis-inner-application-uiAbilityContext.md). - **FA Model** ```js import featureAbility from '@ohos.ability.featureAbility'; + let context = featureAbility.getContext(); context.getFilesDir().then((data) => { let pathDir = data; }) ``` - For details about how to obtain the FA model context, see [Contex](js-apis-inner-app-context.md#context). +For details about how to obtain the FA model context, see [Contex](js-apis-inner-app-context.md#context). ## fileio.stat diff --git a/en/application-dev/reference/apis/js-apis-font.md b/en/application-dev/reference/apis/js-apis-font.md new file mode 100644 index 0000000000000000000000000000000000000000..0b7d7fb3abcb1353d022e70ea785f6454cd422b4 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-font.md @@ -0,0 +1,64 @@ +# @ohos.font (Custom Font Registration) + +The **font** module provides APIs for registering custom fonts. + +> **NOTE** +> +> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. + +## Modules to Import + +```ts +import font from '@ohos.font' +``` + +## font.registerFont + +registerFont(options: FontOptions): void + +Registers a custom font with the font manager. + +**System capability**: SystemCapability.ArkUI.ArkUI.Full + +**Parameters** + +| Name | Type | Mandatory | Description | +| ------- | --------------------------- | ---- | ----------- | +| options | [FontOptions](#fontoptions) | Yes | Information about the custom font to register.| + +## FontOptions + +| Name | Type | Mandatory | Description | +| ---------- | ------ | ---- | ------------ | +| familyName | string | Yes | Name of the custom font to register. | +| familySrc | string | Yes | Path of the custom font to register.| + +## Example + +```ts +// xxx.ets +import font from '@ohos.font'; + +@Entry +@Component +struct FontExample { + @State message: string =' Hello, World' + + aboutToAppear() { + font.registerFont({ + familyName: 'medium', + familySrc: '/font/medium.ttf' + }) + } + + build() { + Column() { + Text(this.message) + .align(Alignment.Center) + .fontSize(20) + .fontFamily('medium') // medium: name of the custom font to register. + .height('100%') + }.width('100%') + } +} +``` diff --git a/en/application-dev/reference/apis/js-apis-http.md b/en/application-dev/reference/apis/js-apis-http.md index 8b6e6495c919bba52e0d3ce05c0e1675b493fa8f..2b15b9bb2a98bea710f49e5aaa7a6ca2843d9427 100644 --- a/en/application-dev/reference/apis/js-apis-http.md +++ b/en/application-dev/reference/apis/js-apis-http.md @@ -53,11 +53,13 @@ httpRequest.request( // data.header carries the HTTP response header. Parse the content based on service requirements. console.info('header:' + JSON.stringify(data.header)); console.info('cookies:' + JSON.stringify(data.cookies)); // 8+ + // Call the destroy() method to release resources after the HttpRequest is complete. + httpRequest.destroy(); } else { console.info('error:' + JSON.stringify(err)); // Unsubscribe from HTTP Response Header events. httpRequest.off('headersReceive'); - // Call the destroy() method to release resources after HttpRequest is complete. + // Call the destroy() method to release resources after the HttpRequest is complete. httpRequest.destroy(); } } @@ -73,6 +75,9 @@ createHttp(): HttpRequest Creates an HTTP request. You can use this API to initiate or destroy an HTTP request, or enable or disable listening for HTTP Response Header events. An **HttpRequest** object corresponds to an HTTP request. To initiate multiple HTTP requests, you must create an **HttpRequest** object for each HTTP request. +> **NOTE** +> Call the **destroy()** method to release resources after the HttpRequest is complete. + **System capability**: SystemCapability.Communication.NetStack **Return value** @@ -115,7 +120,7 @@ Initiates an HTTP request to a given URL. This API uses an asynchronous callback **Error codes** -| Code | Error Message | +| ID | Error Message | |---------|-------------------------------------------------------| | 401 | Parameter error. | | 201 | Permission denied. | @@ -167,7 +172,7 @@ Initiates an HTTP request containing specified options to a given URL. This API **Error codes** -| Code | Error Message | +| ID | Error Message | |---------|-------------------------------------------------------| | 401 | Parameter error. | | 201 | Permission denied. | @@ -258,7 +263,7 @@ Initiates an HTTP request containing specified options to a given URL. This API **Error codes** -| Code | Error Message | +| ID | Error Message | |---------|-------------------------------------------------------| | 401 | Parameter error. | | 201 | Permission denied. | @@ -465,7 +470,7 @@ Specifies the type and value range of the optional parameters in the HTTP reques | Name | Type | Mandatory| Description | | -------------- | --------------------------------------------- | ---- | ------------------------------------------------------------ | | method | [RequestMethod](#requestmethod) | No | Request method. The default value is **GET**. | -| extraData | string6+ \| Object6+ \| ArrayBuffer8+ | No | Additional data for sending a request. This parameter is not used by default.
- If the HTTP request uses a POST or PUT method, this parameter serves as the content of the HTTP request and is encoded in UTF-8 format. If **'Content-Type'** is **'application/x-www-form-urlencoded'**, the data in the request body must be encoded in the format of **key1=value1&key2=value2&key3=value3** after URL transcoding.6+
- If the HTTP request uses the GET, OPTIONS, DELETE, TRACE, or CONNECT method, this parameter serves as a supplement to HTTP request parameters. Parameters of the string type need to be encoded before being passed to the HTTP request. Parameters of the object type do not need to be precoded and will be directly concatenated to the URL. Parameters of the ArrayBuffer type will not be concatenated to the URL.6+ | +| extraData | string6+ \| Object6+ \| ArrayBuffer8+ | No | Additional data for sending a request. This parameter is not used by default.
- If the HTTP request uses a POST or PUT method, this parameter serves as the content of the HTTP request and is encoded in UTF-8 format. If **'Content-Type'** is **'application/x-www-form-urlencoded'**, the data in the request body must be encoded in the format of **key1=value1&key2=value2&key3=value3** after URL transcoding.
- If the HTTP request uses the GET, OPTIONS, DELETE, TRACE, or CONNECT method, this parameter serves as a supplement to HTTP request parameters. Parameters of the string type need to be encoded before being passed to the HTTP request. Parameters of the object type do not need to be precoded and will be directly concatenated to the URL. Parameters of the ArrayBuffer type will not be concatenated to the URL.| | expectDataType9+ | [HttpDataType](#httpdatatype9) | No | Type of the returned data. This parameter is not used by default. If this parameter is set, the system returns the specified type of data preferentially.| | usingCache9+ | boolean | No | Whether to use the cache. The default value is **true**. | | priority9+ | number | No | Priority. The value range is [1,1000]. The default value is **1**. | diff --git a/en/application-dev/reference/apis/js-apis-inner-application-accessibilityExtensionContext.md b/en/application-dev/reference/apis/js-apis-inner-application-accessibilityExtensionContext.md index d147c049b2a9aa006b83bef9ed28b266340347db..002ea7b6728a93e26429934f95b04d74c8ab332c 100644 --- a/en/application-dev/reference/apis/js-apis-inner-application-accessibilityExtensionContext.md +++ b/en/application-dev/reference/apis/js-apis-inner-application-accessibilityExtensionContext.md @@ -610,7 +610,7 @@ Defines the accessibilityelement. Before calling APIs of **AccessibilityElement* **System capability**: SystemCapability.BarrierFree.Accessibility.Core -## attributeNames +### attributeNames attributeNames\(): Promise\>; @@ -636,7 +636,7 @@ rootElement.attributeNames().then((data) => { console.log('failed to get attribute names, because ' + JSON.stringify(err)); }); ``` -## attributeNames +### attributeNames attributeNames\(callback: AsyncCallback\>): void; @@ -664,7 +664,7 @@ rootElement.attributeNames((err, data) => { console.info('get attribute names success'); }); ``` -## AccessibilityElement.attributeValue +### attributeValue attributeValue\(attributeName: T): Promise\; @@ -709,7 +709,7 @@ try { console.log('failed to get attribute value, because ' + JSON.stringify(exception)); } ``` -## AccessibilityElement.attributeValue +### attributeValue attributeValue\(attributeName: T, callback: AsyncCallback\): void; @@ -752,7 +752,7 @@ try { console.log('failed to get attribute value, because ' + JSON.stringify(exception)); } ``` -## actionNames +### actionNames actionNames(): Promise\>; @@ -778,7 +778,7 @@ rootElement.actionNames().then((data) => { console.log('failed to get action names because ' + JSON.stringify(err)); }); ``` -## actionNames +### actionNames actionNames(callback: AsyncCallback\>): void; @@ -806,7 +806,7 @@ rootElement.actionNames((err, data) => { console.info('get action names success'); }); ``` -## performAction +### performAction performAction(actionName: string, parameters?: object): Promise\; @@ -849,7 +849,7 @@ try { console.log('failed to perform action, because ' + JSON.stringify(exception)); } ``` -## performAction +### performAction performAction(actionName: string, callback: AsyncCallback\): void; @@ -888,7 +888,7 @@ try { console.log('failed to perform action, because ' + JSON.stringify(exception)); } ``` -## performAction +### performAction performAction(actionName: string, parameters: object, callback: AsyncCallback\): void; @@ -932,7 +932,7 @@ try { console.log('failed to perform action, because ' + JSON.stringify(exception)); } ``` -## findElement('content') +### findElement('content') findElement(type: 'content', condition: string): Promise\>; @@ -971,7 +971,7 @@ try { console.log('failed to find element, because ' + JSON.stringify(exception)); } ``` -## findElement('content') +### findElement('content') findElement(type: 'content', condition: string, callback: AsyncCallback\>): void; @@ -1007,7 +1007,7 @@ try { console.log('failed to find element, because ' + JSON.stringify(exception)); } ``` -## findElement('focusType') +### findElement('focusType') findElement(type: 'focusType', condition: FocusType): Promise\; @@ -1046,7 +1046,7 @@ try { console.log('failed to find element, because ' + JSON.stringify(exception)); } ``` -## findElement('focusType') +### findElement('focusType') findElement(type: 'focusType', condition: FocusType, callback: AsyncCallback\): void; @@ -1082,7 +1082,7 @@ try { console.log('failed to find element, because ' + JSON.stringify(exception)); } ``` -## findElement('focusDirection') +### findElement('focusDirection') findElement(type: 'focusDirection', condition: FocusDirection): Promise\; @@ -1121,7 +1121,7 @@ try { console.log('failed to find element, because ' + JSON.stringify(exception)); } ``` -## findElement('focusDirection') +### findElement('focusDirection') findElement(type: 'focusDirection', condition: FocusDirection, callback: AsyncCallback\): void; diff --git a/en/application-dev/reference/apis/js-apis-installer.md b/en/application-dev/reference/apis/js-apis-installer.md index 3b1d21de1f372bfffab3890dec3860e74ff37877..ceff24181b2d2506fbcfb77567f4e01cb1d18bee 100644 --- a/en/application-dev/reference/apis/js-apis-installer.md +++ b/en/application-dev/reference/apis/js-apis-installer.md @@ -474,4 +474,4 @@ Defines the parameters that need to be specified for bundle installation, uninst | installFlag | number | No | Installation flag. The value **0** means initial installation and **1** means overwrite installation.| | isKeepData | boolean | No | Whether to retain the data directory during bundle uninstall.| | hashParams | Array<[HashParam](#hashparam)> | No| Hash parameters. | -| crowdtestDeadline| number | No |End date of crowdtesting.| +| crowdtestDeadline| number | No | End date of crowdtesting. The default value is **-1**, indicating that no end date is specified for crowdtesting.| diff --git a/en/application-dev/reference/apis/js-apis-logs.md b/en/application-dev/reference/apis/js-apis-logs.md index 48cc7954e1b4315f0e12d9571395decf9592b90d..673a24f3340de67ad98a86a8b2648e0e9af1693c 100644 --- a/en/application-dev/reference/apis/js-apis-logs.md +++ b/en/application-dev/reference/apis/js-apis-logs.md @@ -1,81 +1,143 @@ -# console (Log) +# Console -> **NOTE**
-> The APIs of this module are no longer maintained since API version 7. You are advised to use ['@ohos.hilog](js-apis-hilog.md)' instead. +The **console** module provides a simple debugging console, which is similar to the JavaScript console provided by the browser. + +> **NOTE** +> +> The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version. ## console.debug -debug(message: string): void +debug(message: string, ...arguments: any[]): void + +Prints debugging information in formatted output mode. + +**System capability**: SystemCapability.ArkUI.ArkUI.Full -Prints debug logs. +**Parameters** -- Parameters - | Name | Type | Mandatory | Description | - | ------- | ------ | ---- | ----------- | - | message | string | Yes | Text to print.| +| Name | Type | Mandatory | Description | +| ------- | ------ | ---- | ----------- | +| message | string | Yes | Text to be printed.| +| arguments | any[] | No | Arguments in the message or other information to be printed.| +**Example** + +```js +const number = 5; +console.debug('count: %d', number); // Print the debugging information with arguments in the message replaced. +// count: 5 +console.debug('count:', number); // Print the message and other information. +// count: 5 +console.debug('count:'); // Print the message only. +// count: +``` ## console.log -log(message: string): void +log(message: string, ...arguments: any[]): void -Prints debug logs. +Prints log information in formatted output mode. -- Parameters - | Name | Type | Mandatory | Description | - | ------- | ------ | ---- | ----------- | - | message | string | Yes | Text to print.| +**System capability**: SystemCapability.ArkUI.ArkUI.Full +**Parameters** + +| Name | Type | Mandatory | Description | +| ------- | ------ | ---- | ----------- | +| message | string | Yes | Text to be printed.| +| arguments | any[] | No |Arguments in the message or other information to be printed.| + +**Example** + +```js +const number = 5; +console.log('count: %d', number); // Print the log information with arguments in the message replaced. +// count: 5 +console.log('count:', number); // Print the message and other information. +// count: 5 +console.log('count:'); // Print the message only. +// count: +``` ## console.info -info(message: string): void +info(message: string, ...arguments: any[]): void + +Prints log information in formatted output mode. This API is the alias of **console.log ()**. -Prints info-level logs. +**System capability**: SystemCapability.ArkUI.ArkUI.Full -- Parameters - | Name | Type | Mandatory | Description | - | ------- | ------ | ---- | ----------- | - | message | string | Yes | Text to print.| +**Parameters** +| Name | Type | Mandatory | Description | +| ------- | ------ | ---- | ----------- | +| message | string | Yes | Text to be printed.| +| arguments | any[] | No | Arguments in the message or other information to be printed.| + +**Example** + +```js +const number = 5; +console.info('count: %d', number); // Print the log information with arguments in the message replaced. +// count: 5 +console.info('count:', number); // Print the message and other information. +// count: 5 +console.info('count:'); // Print the message only. +// count: +``` ## console.warn -warn(message: string): void +warn(message: string, ...arguments: any[]): void + +Prints warning information in formatted output mode. + +**System capability**: SystemCapability.ArkUI.ArkUI.Full -Prints warn-level logs. +**Parameters** -- Parameters - | Name | Type | Mandatory | Description | - | ------- | ------ | ---- | ----------- | - | message | string | Yes | Text to print.| +| Name | Type | Mandatory | Description | +| ------- | ------ | ---- | ----------- | +| message | string | Yes | Warning information to be printed.| +| arguments | any[] | No | Arguments in the message or other information to be printed.| +**Example** + +```js +const str = "name should be string"; +console.warn('warn: %d', str); // Print the warning information with arguments in the message replaced. +// warn: name should be string +console.warn('warn:', str); // Print the message and other information. +// warn: name should be string +console.warn('warn:'); // Print the message only. +// warn: +``` ## console.error -error(message: string): void +error(message: string, ...arguments: any[]): void -Prints error-level logs. +Prints error information in formatted output mode. -- Parameters - | Name | Type | Mandatory | Description | - | ------- | ------ | ---- | ----------- | - | message | string | Yes | Text to print.| +**System capability**: SystemCapability.ArkUI.ArkUI.Full +**Parameters** -## Example +| Name | Type | Mandatory | Description | +| ------- | ------ | ---- | ----------- | +| message | string | Yes | Error information to be printed.| +| arguments | any[] | No | Arguments in the message or other information to be printed.| -``` -export default { - clickConsole(){ - var versionCode = 1; - console.info('Hello World. The current version code is ' + versionCode); - console.log(`versionCode: ${versionCode}`); - / / The following is supported since API version 6: console.log('versionCode:%d.', versionCode); - } -} -``` -Switch to the HiLog window at the bottom of HUAWEI DevEco Studio. Specifically, select the current device and process, set the log level to Info, and enter Hello World in the search box. Logs that meet the search criteria are displayed, as shown in the following figure. +**Example** -![en-us_image_0000001200913929](figures/en-us_image_0000001200913929.png) +```js +const str = "value is not defined"; +console.error('error: %d', str); // Print the error information with arguments in the message replaced. +// error: value is not defined +console.error('error:', str); // Print the message and other information. +// error: value is not defined +console.error('error:'); // Print the message only. +// error: +``` diff --git a/en/application-dev/reference/apis/js-apis-net-ethernet.md b/en/application-dev/reference/apis/js-apis-net-ethernet.md index 0b7697b6d8dfcdb6a01bf7d3a44d0a64115c0855..b80bfcd7bc76eee01f3607fd79c066ae052dada1 100644 --- a/en/application-dev/reference/apis/js-apis-net-ethernet.md +++ b/en/application-dev/reference/apis/js-apis-net-ethernet.md @@ -53,8 +53,7 @@ ethernet.setIfaceConfig("eth0", { route: "192.168.xx.xxx", gateway: "192.168.xx.xxx", netMask: "255.255.255.0", - dnsServers: "1.1.1.1", - domain: "2.2.2.2" + dnsServers: "1.1.1.1" }, (error) => { if (error) { console.log("setIfaceConfig callback error = " + JSON.stringify(error)); @@ -111,8 +110,7 @@ ethernet.setIfaceConfig("eth0", { route: "192.168.xx.xxx", gateway: "192.168.xx.xxx", netMask: "255.255.255.0", - dnsServers: "1.1.1.1", - domain: "2.2.2.2" + dnsServers: "1.1.1.1" }).then(() => { console.log("setIfaceConfig promise ok "); }).catch(error => { @@ -163,7 +161,6 @@ ethernet.getIfaceConfig("eth0", (error, value) => { console.log("getIfaceConfig callback gateway = " + JSON.stringify(value.gateway)); console.log("getIfaceConfig callback netMask = " + JSON.stringify(value.netMask)); console.log("getIfaceConfig callback dnsServers = " + JSON.stringify(value.dnsServers)); - console.log("getIfaceConfig callback domain = " + JSON.stringify(value.domain)); } }); ``` @@ -213,7 +210,6 @@ ethernet.getIfaceConfig("eth0").then((data) => { console.log("getIfaceConfig promise gateway = " + JSON.stringify(data.gateway)); console.log("getIfaceConfig promise netMask = " + JSON.stringify(data.netMask)); console.log("getIfaceConfig promise dnsServers = " + JSON.stringify(data.dnsServers)); - console.log("getIfaceConfig promise domain = " + JSON.stringify(data.domain)); }).catch(error => { console.log("getIfaceConfig promise error = " + JSON.stringify(error)); }); @@ -386,74 +382,6 @@ ethernet.getAllActiveIfaces().then((data) => { }); ``` -## ethernet.on('interfaceStateChange')10+ - -on(type: 'interfaceStateChange', callback: Callback\<{ iface: string, active: boolean }\>): void - -Registers an observer for NIC hot swap events. This API uses an asynchronous callback to return the result. - -**System API**: This is a system API. - -**Required permission**: ohos.permission.GET_NETWORK_INFO - -**System capability**: SystemCapability.Communication.NetManager.Ethernet - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| type | string | Yes | Event type. The value is **interfaceStateChange**.| -| callback | AsyncCallback\<{ iface: string, active: boolean }\> | Yes | Callback used to return the result.
**iface**: NIC name.
**active**: whether the NIC is active. The value **true** indicates that the NIC is active, and the value **false** indicates the opposite.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Applicable only to system applications. | -| 401 | Parameter error. | - -**Example** - -```js -ethernet.on('interfaceStateChange', (data) => { - console.log('on interfaceSharingStateChange: ' + JSON.stringify(data)); -}); -``` - -## ethernet.off('interfaceStateChange')10+ - -off(type: 'interfaceStateChange', callback?: Callback\<{ iface: string, active: boolean }\>): void - -Unregisters the observer for NIC hot swap events. This API uses an asynchronous callback to return the result. - -**System API**: This is a system API. - -**Required permission**: ohos.permission.GET_NETWORK_INFO - -**System capability**: SystemCapability.Communication.NetManager.Ethernet - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------- | -| type | string | Yes | Event type. The value is **interfaceStateChange**.| -| callback | AsyncCallback\<{ iface: string, active: boolean }> | No | Callback used to return the result.
**iface**: NIC name.
**active**: whether the NIC is active. The value **true** indicates that the NIC is active, and the value **false** indicates the opposite.| - -**Error codes** - -| ID| Error Message | -| ------- | -------------------------------------------- | -| 201 | Permission denied. | -| 202 | Applicable only to system applications. | -| 401 | Parameter error. | - -**Example** - -```js -ethernet.off('interfaceStateChange'); -``` - ## InterfaceConfiguration Defines the network configuration for the Ethernet connection. diff --git a/en/application-dev/reference/apis/js-apis-nfcController.md b/en/application-dev/reference/apis/js-apis-nfcController.md index 4c55691b61cd60cb59543ae0881a719d5bb8fc1b..c9c909b93e7b345a99fd934078b76af6873d639a 100644 --- a/en/application-dev/reference/apis/js-apis-nfcController.md +++ b/en/application-dev/reference/apis/js-apis-nfcController.md @@ -176,7 +176,7 @@ Unsubscribes from the NFC state changes. The subscriber will not receive NFC sta | **Name**| **Type**| **Mandatory**| **Description**| | -------- | -------- | -------- | -------- | | type | string | Yes| Event type to unsubscribe from. The value is **nfcStateChange**.| -| callback | Callback<[NfcState](#nfcstate)> | No| Callback for the NFC state changes. This parameter can be left blank.| +| callback | Callback<[NfcState](#nfcstate)> | No| Callback for the NFC state changes. This parameter can be left blank. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| **Example** diff --git a/en/application-dev/reference/apis/js-apis-nfcTag.md b/en/application-dev/reference/apis/js-apis-nfcTag.md index 6b1bd68289e090aaa4ee73ce459437a51db5bff1..61bd849804434dfd16db488c933c7b62bb47456d 100644 --- a/en/application-dev/reference/apis/js-apis-nfcTag.md +++ b/en/application-dev/reference/apis/js-apis-nfcTag.md @@ -48,10 +48,11 @@ Before developing applications related to tag read and write, you must declare N } ``` > **CAUTION**
-1. The **actions** field is mandatory. It must be **ohos.nfc.tag.action.TAG_FOUND** and cannot be changed. -2. The **name** field under **metadata** is mandatory. It must be **tag-tech** and cannot be changed. -3. The **value** field under **metadata** is mandatory. It can be **NfcA**, **NfcB**, **NfcF**, **NfcV**, **IsoDep**, **Ndef**, **MifareClassic**, **MifareUL**, **NdefFormatable** or any of their combinations. Incorrect settings of this field will cause a parsing failure. -4. The **name** field under **requestPermissions** is mandatory. It must be **ohos.permission.NFC_TAG** and cannot be changed. +> +> - The **actions** field is mandatory. It must be **ohos.nfc.tag.action.TAG_FOUND** and cannot be changed. +> - The **name** field under **metadata** is mandatory. It must be **tag-tech** and cannot be changed. +> - The **value** field under **metadata** is mandatory. It can be **NfcA**, **NfcB**, **NfcF**, **NfcV**, **IsoDep**, **Ndef**, **MifareClassic**, **MifareUL**, **NdefFormatable** or any of their combinations. Incorrect settings of this field will cause a parsing failure. +> - The **name** field under **requestPermissions** is mandatory. It must be **ohos.permission.NFC_TAG** and cannot be changed. ## **Modules to Import** @@ -98,7 +99,7 @@ onCreate(want, launchParam) { if (isNfcATag) { var nfcA; try { - nfcA = tag.getNfcATag(taginfo); + nfcA = tag.getNfcATag(tagInfo); } catch (error) { console.log("tag.getNfcATag caught error: " + error); } @@ -109,7 +110,7 @@ onCreate(want, launchParam) { if (isIsoDepTag) { var isoDep; try { - isoDep = tag.getIsoDep(taginfo); + isoDep = tag.getIsoDep(tagInfo); } catch (error) { console.log("tag.getIsoDep caught error: " + error); } @@ -139,8 +140,8 @@ Obtains an **NfcATag** object, which allows access to the tags that use the NFC- **Return value** -| **Type**| **Description**| -| -------- | -------- | +| **Type** | **Description** | +| ------------------------------------- | ------------- | | [NfcATag](js-apis-nfctech.md#nfcatag) | **NfcATag** object obtained.| ## tag.getNfcA9+ @@ -159,16 +160,16 @@ Obtains an **NfcATag** object, which allows access to the tags that use the NFC- **Return value** -| **Type**| **Description**| -| -------- | -------- | +| **Type** | **Description** | +| ------------------------------------- | ------------- | | [NfcATag](js-apis-nfctech.md#nfcatag) | **NfcATag** object obtained.| **Error codes** For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode-nfc.md). -| ID| Error Message| -| ------- | -------| +| ID | Error Message | +| ------- | ---------------------------------------- | | 3100201 | Tag running state is abnormal in service. | ## tag.getNfcBTag @@ -190,9 +191,9 @@ Obtains an **NfcBTag** object, which allows access to the tags that use the NFC- **Return value** -| **Type**| **Description** | -| -------- | ---------------- | -| [NfcBTag](js-apis-nfctech.md#nfcbtag) | **NfcBTag** object obtained.| +| **Type** | **Description** | +| ------------------------------------- | ------------- | +| [NfcBTag](js-apis-nfctech.md#nfcbtag) | **NfcBTag** object obtained.| ## tag.getNfcB9+ @@ -210,16 +211,16 @@ Obtains an **NfcBTag** object, which allows access to the tags that use the NFC- **Return value** -| **Type**| **Description** | -| -------- | ---------------- | -| [NfcBTag](js-apis-nfctech.md#nfcbtag) | **NfcBTag** object obtained.| +| **Type** | **Description** | +| ------------------------------------- | ------------- | +| [NfcBTag](js-apis-nfctech.md#nfcbtag) | **NfcBTag** object obtained.| **Error codes** For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode-nfc.md). -| ID| Error Message| -| ------- | -------| +| ID | Error Message | +| ------- | ---------------------------------------- | | 3100201 | Tag running state is abnormal in service. | ## tag.getNfcFTag @@ -241,9 +242,9 @@ Obtains an **NfcFTag** object, which allows access to the tags that use the NFC- **Return value** -| **Type**| **Description** | -| -------- | ---------------- | -| [NfcFTag](js-apis-nfctech.md#nfcftag) | **NfcFTag** object obtained.| +| **Type** | **Description** | +| ------------------------------------- | ------------- | +| [NfcFTag](js-apis-nfctech.md#nfcftag) | **NfcFTag** object obtained.| ## tag.getNfcF9+ @@ -261,16 +262,16 @@ Obtains an **NfcFTag** object, which allows access to the tags that use the NFC- **Return value** -| **Type**| **Description** | -| -------- | ---------------- | -| [NfcFTag](js-apis-nfctech.md#nfcftag) | **NfcFTag** object obtained.| +| **Type** | **Description** | +| ------------------------------------- | ------------- | +| [NfcFTag](js-apis-nfctech.md#nfcftag) | **NfcFTag** object obtained.| **Error codes** For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode-nfc.md). -| ID| Error Message| -| ------- | -------| +| ID | Error Message | +| ------- | ---------------------------------------- | | 3100201 | Tag running state is abnormal in service. | ## tag.getNfcVTag @@ -292,9 +293,9 @@ Obtains an **NfcVTag** object, which allows access to the tags that use the NFC- **Return value** -| **Type**| **Description** | -| -------- | ---------------- | -| [NfcVTag](js-apis-nfctech.md#nfcvtag) | **NfcVTag** object obtained.| +| **Type** | **Description** | +| ------------------------------------- | ------------- | +| [NfcVTag](js-apis-nfctech.md#nfcvtag) | **NfcVTag** object obtained.| ## tag.getNfcV9+ @@ -312,16 +313,16 @@ Obtains an **NfcVTag** object, which allows access to the tags that use the NFC- **Return value** -| **Type**| **Description** | -| -------- | ---------------- | -| [NfcVTag](js-apis-nfctech.md#nfcvtag) | **NfcVTag** object obtained.| +| **Type** | **Description** | +| ------------------------------------- | ------------- | +| [NfcVTag](js-apis-nfctech.md#nfcvtag) | **NfcVTag** object obtained.| **Error codes** For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode-nfc.md). -| ID| Error Message| -| ------- | -------| +| ID | Error Message | +| ------- | ---------------------------------------- | | 3100201 | Tag running state is abnormal in service. | ## tag.getIsoDep9+ @@ -334,22 +335,22 @@ Obtains an **IsoDepTag** object, which allows access to the tags that use the IS **Parameters** -| Name | Type | Mandatory | Description | -| --------- | ------------------------- | ---- | ---------------------------------------- | -| taginfo | [TagInfo](#taginfo) | Yes| Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**. | +| Name | Type | Mandatory | Description | +| ------- | ------------------- | ---- | ---------------------------------------- | +| taginfo | [TagInfo](#taginfo) | Yes | Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**.| **Return value** -| **Type**| **Description** | -| ---------- | ------------------| -| [IsoDepTag](js-apis-nfctech.md#isodeptag9) | **IsoDepTag** object obtained.| +| **Type** | **Description** | +| ---------------------------------------- | ----------------------------------- | +| [IsoDepTag](js-apis-nfctech.md#isodeptag9) | **IsoDepTag** object obtained.| **Error codes** For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode-nfc.md). -| ID| Error Message| -| ------- | -------| +| ID | Error Message | +| ------- | ---------------------------------------- | | 3100201 | Tag running state is abnormal in service. | ## tag.getNdef9+ @@ -362,22 +363,22 @@ Obtains an **NdefTag** object, which allows access to the tags in the NFC Data E **Parameters** -| Name | Type | Mandatory | Description | -| --------- | ------------------------- | ---- | ---------------------------------------- | -| taginfo | [TagInfo](#taginfo) | Yes | Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**. | +| Name | Type | Mandatory | Description | +| ------- | ------------------- | ---- | ---------------------------------------- | +| taginfo | [TagInfo](#taginfo) | Yes | Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**.| **Return value** -| **Type**| **Description** | -| ---------| -------------- | -| [NdefTag](js-apis-nfctech.md#ndeftag9) | **NdefTag** object obtained.| +| **Type** | **Description** | +| -------------------------------------- | ------------------------------- | +| [NdefTag](js-apis-nfctech.md#ndeftag9) | **NdefTag** object obtained.| **Error codes** For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode-nfc.md). -| ID| Error Message| -| ------- | -------| +| ID | Error Message | +| ------- | ---------------------------------------- | | 3100201 | Tag running state is abnormal in service. | ## tag.getMifareClassic9+ @@ -390,22 +391,22 @@ Obtains a **MifareClassicTag** object, which allows access to the tags that use **Parameters** -| Name | Type | Mandatory | Description | -| --------- | ------------------------- | ---- | ---------------------------------------- | -| taginfo | [TagInfo](#taginfo) | Yes | Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**. | +| Name | Type | Mandatory | Description | +| ------- | ------------------- | ---- | ---------------------------------------- | +| taginfo | [TagInfo](#taginfo) | Yes | Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**.| **Return value** -| **Type**| **Description** | -| ----------------- | ------------------------| -| [MifareClassicTag](js-apis-nfctech.md#mifareclassictag-9) | **MifareClassicTag** object obtained.| +| **Type** | **Description** | +| ---------------------------------------- | ---------------------------------------- | +| [MifareClassicTag](js-apis-nfctech.md#mifareclassictag-9) | **MifareClassicTag** object obtained.| **Error codes** For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode-nfc.md). -| ID| Error Message| -| ------- | -------| +| ID | Error Message | +| ------- | ---------------------------------------- | | 3100201 | Tag running state is abnormal in service. | ## tag.getMifareUltralight9+ @@ -417,22 +418,22 @@ Obtains a **MifareUltralightTag** object, which allows access to the tags that u **System capability**: SystemCapability.Communication.NFC.Tag **Parameters** -| Name | Type | Mandatory | Description | -| --------- | ------------------------- | ---- | ---------------------------------------- | -| taginfo | [TagInfo](#taginfo) | Yes | Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**. | +| Name | Type | Mandatory | Description | +| ------- | ------------------- | ---- | ---------------------------------------- | +| taginfo | [TagInfo](#taginfo) | Yes | Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**.| **Return value** -| **Type**| **Description** | -| -------------------- | ---------------------------| -| [MifareUltralightTag](js-apis-nfctech.md#mifareultralighttag9) | **MifareUltralightTag** object obtained.| +| **Type** | **Description** | +| ---------------------------------------- | ---------------------------------------- | +| [MifareUltralightTag](js-apis-nfctech.md#mifareultralighttag9) | **MifareUltralightTag** object obtained.| **Error codes** For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode-nfc.md). -| ID| Error Message| -| ------- | -------| +| ID | Error Message | +| ------- | ---------------------------------------- | | 3100201 | Tag running state is abnormal in service. | ## tag.getNdefFormatable9+ @@ -445,16 +446,16 @@ Obtains an **NdefFormatableTag** object, which allows access to the tags that ar **Return value** -| **Type**| **Description** | -| ------------------ | --------------------------| -| [NdefFormatableTag](js-apis-nfctech.md#ndefformatabletag) | **NdefFormatableTag** object obtained.| +| **Type** | **Description** | +| ---------------------------------------- | ---------------------------------------- | +| [NdefFormatableTag](js-apis-nfctech.md#ndefformatabletag) | **NdefFormatableTag** object obtained.| **Error codes** For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode-nfc.md). -| ID| Error Message| -| ------- | -------| +| ID | Error Message | +| ------- | ---------------------------------------- | | 3100201 | Tag running state is abnormal in service. | ## tag.getTagInfo9+ @@ -467,14 +468,14 @@ Obtains **TagInfo** from **Want**, which is initialized by the NFC service and c **Parameters** -| Name | Type | Mandatory | Description | -| --------- | ------------------------- | ---- | ---------------------------------------- | -| want | [Want](js-apis-app-ability-want.md#Want) | Yes | Data obtained from the parameters of the **onCreate** entry function when an ability is dispatched. | +| Name | Type | Mandatory | Description | +| ---- | ---------------------------------------- | ---- | --------------------------------- | +| want | [Want](js-apis-app-ability-want.md#Want) | Yes | Data obtained from the parameters of the **onCreate** entry function when an ability is dispatched.| **Return value** -| **Type**| **Description** | -| ------------------ | --------------------------| +| **Type** | **Description** | +| ------------------- | --------------------------- | | [TagInfo](#taginfo) | **TagInfo** object obtained.| @@ -488,14 +489,14 @@ Creates an NDEF record based on the specified URI. **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ----------------------- | ---- | -------------------------------------- | -| uri | string | Yes| Data to write to the NDEF record.| +| Name | Type | Mandatory | Description | +| ---- | ------ | ---- | ---------------------- | +| uri | string | Yes | Data to write to the NDEF record.| **Return value** -| **Type**| **Description** | -| ------------------ | --------------------------| +| **Type** | **Description** | +| -------------------------- | ---------------------------------------- | | [NdefRecord](#ndefrecord9) | NDEF record created. For details, see *NFCForum-TS-NDEF_1.0*.| **Example** @@ -527,15 +528,15 @@ Creates an NDEF record based on the specified text data and encoding type. **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ----------------------- | ---- | -------------------------------------- | -| text | string | Yes | Text to write to the NDEF record.| -| locale | string | Yes | Encoding mode of the text.| +| Name | Type | Mandatory | Description | +| ------ | ------ | ---- | ------------------------ | +| text | string | Yes | Text to write to the NDEF record.| +| locale | string | Yes | Encoding mode of the text. | **Return value** -| **Type**| **Description** | -| ------------------ | --------------------------| +| **Type** | **Description** | +| -------------------------- | ---------------------------------------- | | [NdefRecord](#ndefrecord9) | NDEF record created. For details, see *NFCForum-TS-NDEF_1.0*.| **Example** @@ -569,15 +570,15 @@ Creates an NDEF record based on the specified MIME data and type. **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ----------------------- | ---- | -------------------------------------- | -| mimeType | string | Yes | MIME type that complies with RFC rules, for example, **text/plain** or **image/jpeg**.| -| mimeData | number[] | Yes | MIME data, which consists of hexadecimal numbers ranging from **0x00** to **0xFF**.| +| Name | Type | Mandatory | Description | +| -------- | -------- | ---- | ---------------------------------------- | +| mimeType | string | Yes | MIME type that complies with RFC rules, for example, **text/plain** or **image/jpeg**.| +| mimeData | number[] | Yes | MIME data, which consists of hexadecimal numbers ranging from **0x00** to **0xFF**. | **Return value** -| **Type**| **Description** | -| ------------------ | --------------------------| +| **Type** | **Description** | +| -------------------------- | ---------------------------------------- | | [NdefRecord](#ndefrecord9) | NDEF record created. For details, see *NFCForum-TS-NDEF_1.0*.| **Example** @@ -609,16 +610,16 @@ Creates an NDEF record based on application-specific data. **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ----------------------- | ---- | -------------------------------------- | -| domainName | string | Yes | Bundle name of the application or domain name of the organization that releases the applications.| -| type | string | Yes | Type of the application data.| -| externalData | number[] | Yes | Application data, which consists of hexadecimal numbers ranging from **0x00** to **0xFF**.| +| Name | Type | Mandatory | Description | +| ------------ | -------- | ---- | ----------------------------------- | +| domainName | string | Yes | Bundle name of the application or domain name of the organization that releases the applications. | +| type | string | Yes | Type of the application data. | +| externalData | number[] | Yes | Application data, which consists of hexadecimal numbers ranging from **0x00** to **0xFF**.| **Return value** -| **Type**| **Description** | -| ------------------ | --------------------------| +| **Type** | **Description** | +| -------------------------- | ---------------------------------------- | | [NdefRecord](#ndefrecord9) | NDEF record created. For details, see *NFCForum-TS-NDEF_1.0*.| **Example** @@ -652,14 +653,14 @@ Converts an NDEF message to bytes. **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ----------------------- | ---- | -------------------------------------- | -| ndefMessage | [NdefMessage](js-apis-nfctech.md#ndefmessage9) | Yes | NDEF message to convert.| +| Name | Type | Mandatory | Description | +| ----------- | ---------------------------------------- | ---- | ----------- | +| ndefMessage | [NdefMessage](js-apis-nfctech.md#ndefmessage9) | Yes | NDEF message to convert.| **Return value** -| **Type**| **Description** | -| ------------------ | --------------------------| +| **Type** | **Description** | +| -------- | ---------------------------------------- | | number[] | NDEF message in bytes, which consists of hexadecimal numbers ranging from **0x00** to **0xFF**.| **Example** @@ -693,14 +694,14 @@ Creates an NDEF message from raw byte data. The data must comply with the NDEF r **Parameters** -| **Name**| **Type**| **Mandatory**| **Description**| -| -------- | -------- | -------- | -------- | -| data | number[] | Yes| Raw byte data, which consists of hexadecimal numbers ranging from **0x00** to **0xFF**. The data must comply with the NDEF record format.| +| **Name**| **Type** | **Mandatory**| **Description** | +| ------- | -------- | ------ | ---------------------------------------- | +| data | number[] | Yes | Raw byte data, which consists of hexadecimal numbers ranging from **0x00** to **0xFF**. The data must comply with the NDEF record format.| **Return value** -| **Type**| **Description** | -| ------------------ | --------------------------| +| **Type** | **Description** | +| ---------------------------------------- | ---------------------------------------- | | [NdefMessage](js-apis-nfctech.md#ndefmessage9) | NDEF message created. For details, see *NFCForum-TS-NDEF_1.0*.| **Example** @@ -727,14 +728,14 @@ Creates an NDEF message from the NDEF records list. **Parameters** -| **Name**| **Type**| **Mandatory**| **Description**| -| -------- | -------- | -------- | -------- | -| ndefRecords | [NdefRecord](js-apis-nfcTag.md#ndefrecord9)[] | Yes| NDEF record list used to create the NDEF message. For details, see *NFCForum-TS-NDEF_1.0*.| +| **Name** | **Type** | **Mandatory**| **Description** | +| ----------- | ---------------------------------------- | ------ | ---------------------------------------- | +| ndefRecords | [NdefRecord](js-apis-nfcTag.md#ndefrecord9)[] | Yes | NDEF record list used to create the NDEF message. For details, see *NFCForum-TS-NDEF_1.0*.| **Return value** -| **Type**| **Description** | -| ------------------ | --------------------------| +| **Type** | **Description** | +| ---------------------------------------- | ---------------------------------------- | | [NdefMessage](js-apis-nfctech.md#ndefmessage9) | NDEF message created. For details, see *NFCForum-TS-NDEF_1.0*.| **Example** @@ -762,66 +763,66 @@ Defines the **TagInfo** object, which provides information about the tag technol **Required permissions**: ohos.permission.NFC_TAG -| **Name**| **Type**| **Readable**| **Writable**| **Description**| -| -------- | -------- | -------- | -------- | -------- | -| uid9+ | number[] | Yes| No| Tag unique identifier (UID), which consists of hexadecimal numbers ranging from **0x00** to **0xFF**.| -| technology9+ | number[] | Yes| No| Supported technologies. Each number is a constant indicating the supported technology.| -| supportedProfiles | number[] | Yes| No| Supported profiles. This parameter is not supported since API version 9. Use [tag.TagInfo#technology](#tagtaginfo) instead.| -| extrasData9+ | [PacMap](js-apis-inner-ability-dataAbilityHelper.md#pacmap)[] | Yes| No| Extended attribute value of the tag technology.
**System API**: This is a system API.| -| tagRfDiscId9+ | number | Yes| No| ID allocated when the tag is discovered.
**System API**: This is a system API.| -| remoteTagService9+ | [rpc.RemoteObject](js-apis-rpc.md#remoteobject) | Yes| No| Remote object of the NFC service process used for interface communication between the client and the service.
**System API**: This is a system API.| +| **Name** | **Type** | **Readable**| **Writable**| **Description** | +| ----------------------------- | ---------------------------------------- | ------ | ------ | ---------------------------------------- | +| uid9+ | number[] | Yes | No | Tag unique identifier (UID), which consists of hexadecimal numbers ranging from **0x00** to **0xFF**. | +| technology9+ | number[] | Yes | No | Supported technologies. Each number is a constant indicating the supported technology. | +| supportedProfiles | number[] | Yes | No | Supported profiles. This parameter is not supported since API version 9. Use [tag.TagInfo#technology](#tagtaginfo) instead.| +| extrasData9+ | [PacMap](js-apis-inner-ability-dataAbilityHelper.md#pacmap)[] | Yes | No | Extended attribute value of the tag technology.
**System API**: This is a system API. | +| tagRfDiscId9+ | number | Yes | No | ID allocated when the tag is discovered.
**System API**: This is a system API. | +| remoteTagService9+ | [rpc.RemoteObject](js-apis-rpc.md#remoteobject) | Yes | No | Remote object of the NFC service process used for interface communication between the client and the service.
**System API**: This is a system API.| ## NdefRecord9+ Defines an NDEF record. For details, see *NFCForum-TS-NDEF_1.0*. **System capability**: SystemCapability.Communication.NFC.Tag -| **Name**| **Type**| **Readable**| **Writable**| **Description**| -| -------- | -------- | -------- | -------- | -------- | -| tnf | number | Yes| No| Type name field (TNF) of the NDEF record.| -| rtdType| number[] | Yes| No| Record type definition (RTD) of the NDEF record. It consists of hexadecimal numbers ranging from **0x00** to **0xFF**.| -| id | number[] | Yes| No| NDEF record ID, which consists of hexadecimal numbers ranging from **0x00** to **0xFF**.| -| payload | number[] | Yes| No| NDEF payload, which consists of hexadecimal numbers ranging from **0x00** to **0xFF**.| +| **Name** | **Type** | **Readable**| **Writable**| **Description** | +| ------- | -------- | ------ | ------ | ---------------------------------------- | +| tnf | number | Yes | No | Type name field (TNF) of the NDEF record. | +| rtdType | number[] | Yes | No | Record type definition (RTD) of the NDEF record. It consists of hexadecimal numbers ranging from **0x00** to **0xFF**.| +| id | number[] | Yes | No | NDEF record ID, which consists of hexadecimal numbers ranging from **0x00** to **0xFF**.| +| payload | number[] | Yes | No | NDEF payload, which consists of hexadecimal numbers ranging from **0x00** to **0xFF**.| ## Technology Type Definition Enumerates the tag technology types. **System capability**: SystemCapability.Communication.NFC.Tag -| **Name**| **Value**| **Description**| -| -------- | -------- | -------- | -| NFC_A | 1 | NFC-A (ISO 14443-3A).| +| **Name** | **Value**| **Description** | +| ---------------------------- | ----- | ------------------------ | +| NFC_A | 1 | NFC-A (ISO 14443-3A). | | NFC_B | 2 | NFC-B (ISO 14443-3B).| -| ISO_DEP | 3 | ISO-DEP (ISO 14443-4).| -| NFC_F | 4 | NFC-F (JIS 6319-4).| -| NFC_V | 5 | NFC-V (ISO 15693).| -| NDEF | 6 | NDEF.| -| NDEF_FORMATABLE9+ | 7 | NDEF formattable.| -| MIFARE_CLASSIC | 8 | MIFARE Classic.| -| MIFARE_ULTRALIGHT | 9 | MIFARE Ultralight.| +| ISO_DEP | 3 | ISO-DEP (ISO 14443-4).| +| NFC_F | 4 | NFC-F (JIS 6319-4). | +| NFC_V | 5 | NFC-V (ISO 15693). | +| NDEF | 6 | NDEF. | +| NDEF_FORMATABLE9+ | 7 | NDEF formattable. | +| MIFARE_CLASSIC | 8 | MIFARE Classic. | +| MIFARE_ULTRALIGHT | 9 | MIFARE Ultralight. | ## TnfType9+ Enumerates the TNF types. For details, see *NFCForum-TS-NDEF_1.0*. **System capability**: SystemCapability.Communication.NFC.Tag -| **Name**| **Value**| **Description**| -| -------- | -------- | -------- | -| TNF_EMPTY | 0x0 | Empty.| -| TNF_WELL_KNOWN | 0x1 | NFC Forum Well Known Type [NFC RTD].| -| TNF_MEDIA | 0x2 | Media-type as defined in RFC 2046 [RFC 2046].| -| TNF_ABSOLUTE_URI | 0x3 | Absolute URI as defined in RFC 3986 [RFC 3986].| -| TNF_EXT_APP | 0x4 | NFC Forum external type [NFC RTD].| -| TNF_UNKNOWN | 0x5 | Unknown.| -| TNF_UNCHANGED | 0x6 | Unchanged (see section 2.3.3 in *NFCForum-TS-NDEF_1.0*).| +| **Name** | **Value**| **Description** | +| ---------------- | ----- | ---------------------------------------- | +| TNF_EMPTY | 0x0 | Empty. | +| TNF_WELL_KNOWN | 0x1 | NFC Forum Well Known Type [NFC RTD]. | +| TNF_MEDIA | 0x2 | Media-type as defined in RFC 2046 [RFC 2046].| +| TNF_ABSOLUTE_URI | 0x3 | Absolute URI as defined in RFC 3986 [RFC 3986].| +| TNF_EXT_APP | 0x4 | NFC Forum external type [NFC RTD]. | +| TNF_UNKNOWN | 0x5 | Unknown. | +| TNF_UNCHANGED | 0x6 | Unchanged (see section 2.3.3 in *NFCForum-TS-NDEF_1.0*). | ## NDEF Record RTD Enumerates the NDEF record types. For details about the RTD, see *NFCForum-TS-NDEF_1.0*. **System capability**: SystemCapability.Communication.NFC.Tag -| **Name**| **Value**| **Description**| -| -------- | -------- | -------- | -| RTD_TEXT9+ | [0x54] | NDEF record of the text type.| +| **Name** | **Value** | **Description** | +| --------------------- | ------ | ------------------ | +| RTD_TEXT9+ | [0x54] | NDEF record of the text type. | | RTD_URI9+ | [0x55] | NDEF record of the URI type.| ## NfcForumType9+ @@ -829,46 +830,47 @@ Enumerates the NFC Forum tag types. **System capability**: SystemCapability.Communication.NFC.Tag -| **Name**| **Value**| **Description**| -| -------- | -------- | -------- | -| NFC_FORUM_TYPE_1 | 1 | NFC Forum tag type 1.| -| NFC_FORUM_TYPE_2 | 2 | NFC Forum tag type 2.| -| NFC_FORUM_TYPE_3 | 3 | NFC Forum tag type 3.| -| NFC_FORUM_TYPE_4 | 4 | NFC Forum tag type 4.| -| MIFARE_CLASSIC | 101 | MIFARE Classic.| +| **Name** | **Value**| **Description** | +| ---------------- | ----- | ----------------- | +| NFC_FORUM_TYPE_1 | 1 | NFC Forum tag type 1. | +| NFC_FORUM_TYPE_2 | 2 | NFC Forum tag type 2. | +| NFC_FORUM_TYPE_3 | 3 | NFC Forum tag type 3. | +| NFC_FORUM_TYPE_4 | 4 | NFC Forum tag type 4. | +| MIFARE_CLASSIC | 101 | MIFARE Classic.| ## MifareClassicType9+ Enumerates the MIFARE Classic tag types. **System capability**: SystemCapability.Communication.NFC.Tag -| **Name**| **Value**| **Description**| -| -------- | -------- | -------- | -| TYPE_UNKNOWN | 0 | Unknown type.| -| TYPE_CLASSIC | 1 | MIFARE Classic.| -| TYPE_PLUS | 2 | MIFARE Plus.| -| TYPE_PRO | 3 | MIFARE Pro.| +| **Name** | **Value**| **Description** | +| ------------ | ----- | ----------------- | +| TYPE_UNKNOWN | 0 | Unknown type. | +| TYPE_CLASSIC | 1 | MIFARE Classic.| +| TYPE_PLUS | 2 | MIFARE Plus. | +| TYPE_PRO | 3 | MIFARE Pro. | ## MifareClassicSize9+ Enumerates the sizes of a MIFARE Classic tag. **System capability**: SystemCapability.Communication.NFC.Tag -| **Name**| **Value**| **Description**| -| -------- | -------- | -------- | -| MC_SIZE_MINI | 320 | Each tag has 5 sectors, and each sector has 4 blocks.| -| MC_SIZE_1K | 1024 | Each tag has 16 sectors, and each sector has 4 blocks.| -| MC_SIZE_2K | 2048 | Each tag has 32 sectors, and each sector has 4 blocks.| -| MC_SIZE_4K | 4096 | Each tag has 40 sectors, and each sector has 4 blocks.| +| **Name** | **Value**| **Description** | +| ------------ | ----- | ------------------ | +| MC_SIZE_MINI | 320 | Each tag has 5 sectors, and each sector has 4 blocks. | +| MC_SIZE_1K | 1024 | Each tag has 16 sectors, and each sector has 4 blocks.| +| MC_SIZE_2K | 2048 | Each tag has 32 sectors, and each sector has 4 blocks.| +| MC_SIZE_4K | 4096 | Each tag has 40 sectors, and each sector has 4 blocks.| ## MifareUltralightType9+ Enumerates the MIFARE Ultralight tag types. **System capability**: SystemCapability.Communication.NFC.Tag -| **Name**| **Value**| **Description**| -| -------- | -------- | -------- | -| TYPE_UNKNOWN | 0 | Unknown type.| -| TYPE_ULTRALIGHT | 1 | MIFARE Ultralight.| -| TYPE_ULTRALIGHT_C | 2 | MIFARE Ultralight C.| +| **Name** | **Value**| **Description** | +| ----------------- | ----- | ---------------------- | +| TYPE_UNKNOWN | 0 | Unknown type. | +| TYPE_ULTRALIGHT | 1 | MIFARE Ultralight. | +| TYPE_ULTRALIGHT_C | 2 | MIFARE Ultralight C.| + \ No newline at end of file diff --git a/en/application-dev/reference/apis/js-apis-pasteboard.md b/en/application-dev/reference/apis/js-apis-pasteboard.md index 6f893aa8ff0d17a0f7e57c09dd3590592dadef6c..062eac82845175e658dac6fa2891a3a034b71a81 100644 --- a/en/application-dev/reference/apis/js-apis-pasteboard.md +++ b/en/application-dev/reference/apis/js-apis-pasteboard.md @@ -483,9 +483,9 @@ record.convertToText().then((data) => { ## PasteData -Provides **PasteData** APIs. +Implements a **PasteData** object. Paste data contains one or more data records ([PasteDataRecord](#pastedatarecord7)) and property description objects ([PasteDataProperty](#pastedataproperty7)). -Before calling any **PasteData** API, you must obtain a **PasteData** object. +Before calling any API in **PasteData**, you must use **[createData()](#pasteboardcreatedata9)** or **[getData()](#getdata9)** to create a **PasteData** object. **System capability**: SystemCapability.MiscServices.Pasteboard @@ -666,8 +666,8 @@ For details about the error codes, see [Pasteboard Error Codes](../errorcodes/er ```js let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_URI, 'dataability:///com.example.myapplication1/user.txt'); -let dataXml = new ArrayBuffer(256); -pasteData.addRecord('app/xml', dataXml); + let dataXml = new ArrayBuffer(256); + pasteData.addRecord('app/xml', dataXml); ``` ### getMimeTypes7+ diff --git a/en/application-dev/reference/apis/js-apis-plugincomponent.md b/en/application-dev/reference/apis/js-apis-plugincomponent.md index 7becd3c7eed30158ec0054285e2a2903eaa5ff6b..365893915779d1d414b163434a8902fe9ff55363 100644 --- a/en/application-dev/reference/apis/js-apis-plugincomponent.md +++ b/en/application-dev/reference/apis/js-apis-plugincomponent.md @@ -155,11 +155,11 @@ Registers the listener for the push event. ```js function onPushListener(source, template, data, extraData) { - console.log("onPushListener template.source=" + template.source) - console.log("onPushListener source=" + JSON.stringify(source)) - console.log("onPushListener template=" + JSON.stringify(template)) - console.log("onPushListener data=" + JSON.stringify(data)) - console.log("onPushListener extraData=" + JSON.stringify(extraData)) + console.log("onPushListener template.source=" + template.source) + console.log("onPushListener source=" + JSON.stringify(source)) + console.log("onPushListener template=" + JSON.stringify(template)) + console.log("onPushListener data=" + JSON.stringify(data)) + console.log("onPushListener extraData=" + JSON.stringify(extraData)) } ``` @@ -181,14 +181,13 @@ Registers the listener for the request event. **Example** ```js -function onRequestListener(source, name, data) -{ - console.error("onRequestListener"); - console.log("onRequestListener source=" + JSON.stringify(source)); - console.log("onRequestListener name=" + name); - console.log("onRequestListener data=" + JSON.stringify(data)); +function onRequestListener(source, name, data) { + console.error("onRequestListener"); + console.log("onRequestListener source=" + JSON.stringify(source)); + console.log("onRequestListener name=" + name); + console.log("onRequestListener data=" + JSON.stringify(data)); - return {template:"ets/pages/plugin.js", data:data}; + return { template: "ets/pages/plugin.js", data: data }; } ``` @@ -210,24 +209,24 @@ Pushes the component and data to the component user. ```js pluginComponentManager.push( -{ + { want: { - bundleName: "com.example.provider", - abilityName: "com.example.provider.MainAbility", + bundleName: "com.example.provider", + abilityName: "com.example.provider.MainAbility", }, name: "plugintemplate", data: { - "key_1": "plugin component test", - "key_2": 34234 + "key_1": "plugin component test", + "key_2": 34234 }, extraData: { - "extra_str": "this is push event" + "extra_str": "this is push event" }, jsonPath: "", - }, - (err, data) => { - console.log("push_callback: push ok!"); - } + }, + (err, data) => { + console.log("push_callback: push ok!"); + } ) ``` @@ -251,30 +250,30 @@ Pushes the component and data to the component user. ```js pluginComponentManager.push( - { - owner:{ - bundleName:"com.example.provider", - abilityName:"com.example.provider.MainAbility" - }, - target: { - bundleName: "com.example.provider", - abilityName: "com.example.provider.MainAbility", - }, - name: "ets/pages/plugin2.js", - data: { - "js": "ets/pages/plugin.js", - "key_1": 1111, , - }, - extraData: { - "extra_str": "this is push event" - }, - jsonPath: "", + { + owner: { + bundleName: "com.example.provider", + abilityName: "com.example.provider.MainAbility" + }, + target: { + bundleName: "com.example.provider", + abilityName: "com.example.provider.MainAbility", + }, + name: "ets/pages/plugin2.js", + data: { + "js": "ets/pages/plugin.js", + "key_1": 1111, , + }, + extraData: { + "extra_str": "this is push event" }, - (err, data) => { - console.log("push_callback:err: " ,JSON.stringify(err)); - console.log("push_callback:data: " , JSON.stringify(data)); - console.log("push_callback: push ok!"); - } + jsonPath: "", + }, + (err, data) => { + console.log("push_callback:err: ", JSON.stringify(err)); + console.log("push_callback:data: ", JSON.stringify(data)); + console.log("push_callback: push ok!"); + } ) ``` @@ -299,24 +298,24 @@ Requests the component from the component provider. ```js pluginComponentManager.request( - { - want: { - bundleName: "com.example.provider", - abilityName: "com.example.provider.MainAbility", - }, - name: "plugintemplate", - data: { - "key_1": "plugin component test", - "key_2": 1111111 - }, - jsonPath: "", + { + want: { + bundleName: "com.example.provider", + abilityName: "com.example.provider.MainAbility", }, - (err, data) => { - console.log("request_callback: componentTemplate.ability=" + data.componentTemplate.ability) - console.log("request_callback: componentTemplate.source=" + data.componentTemplate.source) - console.log("request_callback: data=" + JSON.stringify(data.data)) - console.log("request_callback: extraData=" + JSON.stringify(data.extraData)) - } + name: "plugintemplate", + data: { + "key_1": "plugin component test", + "key_2": 1111111 + }, + jsonPath: "", + }, + (err, data) => { + console.log("request_callback: componentTemplate.ability=" + data.componentTemplate.ability) + console.log("request_callback: componentTemplate.source=" + data.componentTemplate.source) + console.log("request_callback: data=" + JSON.stringify(data.data)) + console.log("request_callback: extraData=" + JSON.stringify(data.extraData)) + } ) ``` @@ -342,25 +341,25 @@ Requests the component from the component provider. ```js pluginComponentManager.request( - { - owner:{ - bundleName:"com.example.provider", - abilityName:"com.example.provider.MainAbility" - }, - target: { - bundleName: "com.example.provider", - abilityName: "ets/pages/plugin2.js", - }, - name: "plugintemplate", - data: { - "key_1": " myapplication plugin component test", - }, - jsonPath: "", + { + owner: { + bundleName: "com.example.provider", + abilityName: "com.example.provider.MainAbility" + }, + target: { + bundleName: "com.example.provider", + abilityName: "ets/pages/plugin2.js", }, - (err, data) => { - console.log("request_callback: componentTemplate.ability=" + data.componentTemplate.ability) - console.log("request_callback: componentTemplate.source=" + data.componentTemplate.source) - } + name: "plugintemplate", + data: { + "key_1": " myapplication plugin component test", + }, + jsonPath: "", + }, + (err, data) => { + console.log("request_callback: componentTemplate.ability=" + data.componentTemplate.ability) + console.log("request_callback: componentTemplate.source=" + data.componentTemplate.source) + } ) ``` @@ -381,8 +380,8 @@ Listens for events of the request type and returns the requested data, or listen **Example** ```js - pluginComponentManager.on("push", onPushListener) - pluginComponentManager.on("request", onRequestListener) +pluginComponentManager.on("push", onPushListener) +pluginComponentManager.on("request", onRequestListener) ``` ## About the external.json File diff --git a/en/application-dev/reference/apis/js-apis-radio.md b/en/application-dev/reference/apis/js-apis-radio.md index 15c1fc484dd8987dd26c9229beeb200ba8a711e9..07ad0145ba522105dfab765316452a3bb518cb70 100644 --- a/en/application-dev/reference/apis/js-apis-radio.md +++ b/en/application-dev/reference/apis/js-apis-radio.md @@ -32,7 +32,7 @@ Obtains the RAT used in the CS and PS domains for the SIM card in the specified **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -77,7 +77,7 @@ Obtains the RAT used in the CS and PS domains for the SIM card in the specified **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -119,7 +119,7 @@ Obtains the network status. This API uses an asynchronous callback to return the **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -158,7 +158,7 @@ Obtains the network status. This API uses an asynchronous callback to return the **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -203,7 +203,7 @@ Obtains the network status. This API uses a promise to return the result. **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -244,7 +244,7 @@ Obtains the network selection mode of the SIM card in the specified slot. This A **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -286,7 +286,7 @@ Obtains the network selection mode of the SIM card in the specified slot. This A **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -326,7 +326,7 @@ Obtains the ISO country code of the network with which the SIM card in the speci **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -368,7 +368,7 @@ Obtains the ISO country code of the network with which the SIM card in the speci **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -403,11 +403,11 @@ Obtains the ID of the slot in which the primary card is located. This API uses a | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| callback | AsyncCallback\ | Yes | Callback invoked to return the result.| +| callback | AsyncCallback\ | Yes | Callback used to return the result.| **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -441,7 +441,7 @@ Obtains the ID of the slot in which the primary card is located. This API uses a **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -479,7 +479,7 @@ Obtains a list of signal strengths of the network with which the SIM card in the **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -521,7 +521,7 @@ Obtains a list of signal strengths of the network with which the SIM card in the **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -670,7 +670,7 @@ Checks whether the radio service is enabled on the primary SIM card. This API us **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -709,7 +709,7 @@ Checks whether the radio service is enabled on the SIM card in the specified slo **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -754,7 +754,7 @@ Checks whether the radio service is enabled on the SIM card in the specified slo **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -795,7 +795,7 @@ Obtains the carrier name for the SIM card in the specified slot. This API uses a **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -837,7 +837,7 @@ Obtains the carrier name for the SIM card in the specified slot. This API uses a **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -880,7 +880,7 @@ Sets the ID of the slot in which the primary card is located. This API uses an a **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -928,7 +928,7 @@ Sets the ID of the slot in which the primary card is located. This API uses a pr **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -972,7 +972,7 @@ Obtains the IMEI of the SIM card in a card slot. This API uses an asynchronous c **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -996,7 +996,7 @@ radio.getIMEI((err, data) => { getIMEI(slotId: number, callback: AsyncCallback): void -Obtains the IMEI of the SIM card in the specified card slot. This API uses an asynchronous callback to return the result. +Obtains the IMEI of the SIM card in a card slot. This API uses an asynchronous callback to return the result. **System API**: This is a system API. @@ -1013,7 +1013,7 @@ Obtains the IMEI of the SIM card in the specified card slot. This API uses an as **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -1060,7 +1060,7 @@ Obtains the IMEI of the SIM card in the specified card slot. This API uses a pro **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -1103,7 +1103,7 @@ Obtains the MEID of the SIM card in a card slot. This API uses an asynchronous c **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -1127,7 +1127,7 @@ radio.getMEID((err, data) => { getMEID(slotId: number, callback: AsyncCallback): void -Obtains the MEID of the SIM card in the specified card slot. This API uses an asynchronous callback to return the result. +Obtains the MEID of the SIM card in a card slot. This API uses an asynchronous callback to return the result. **System API**: This is a system API. @@ -1144,7 +1144,7 @@ Obtains the MEID of the SIM card in the specified card slot. This API uses an as **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -1191,7 +1191,7 @@ Obtains the MEID of the SIM card in the specified card slot. This API uses a pro **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -1234,7 +1234,7 @@ Obtains the unique device ID of the SIM card in a card slot. This API uses an as **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -1258,7 +1258,7 @@ radio.getUniqueDeviceId((err, data) => { getUniqueDeviceId(slotId: number, callback: AsyncCallback): void -Obtains the unique device ID of the SIM card in the specified card slot. This API uses an asynchronous callback to return the result. +Obtains the unique device ID of the SIM card in a card slot. This API uses an asynchronous callback to return the result. **System API**: This is a system API. @@ -1275,7 +1275,7 @@ Obtains the unique device ID of the SIM card in the specified card slot. This AP **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -1322,7 +1322,7 @@ Obtains the unique device ID of the SIM card in the specified card slot. This AP **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -1365,7 +1365,7 @@ Sends a cell location update request. This API uses an asynchronous callback to **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -1388,7 +1388,7 @@ radio.sendUpdateCellLocationRequest((err) => { sendUpdateCellLocationRequest\(slotId: number, callback: AsyncCallback\): void -Sends a cell location update request for the SIM card in the specified slot. This API uses an asynchronous callback to return the result. +Sends a cell location update request. This API uses an asynchronous callback to return the result. **System API**: This is a system API. @@ -1405,7 +1405,7 @@ Sends a cell location update request for the SIM card in the specified slot. Thi **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -1451,7 +1451,7 @@ Sends a cell location update request for the SIM card in the specified slot. Thi **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -1493,7 +1493,7 @@ Obtains cell information. This API uses an asynchronous callback to return the r **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -1517,7 +1517,7 @@ radio.getCellInformation((err, data) => { getCellInformation(slotId: number, callback: AsyncCallback\>): void -Obtains cell information for the SIM card in the specified slot. This API uses an asynchronous callback to return the result. +Obtains cell information. This API uses an asynchronous callback to return the result. **System API**: This is a system API. @@ -1534,7 +1534,7 @@ Obtains cell information for the SIM card in the specified slot. This API uses a **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -1581,7 +1581,7 @@ Obtains cell information for the SIM card in the specified slot. This API uses a **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -1625,7 +1625,7 @@ Sets the network selection mode. This API uses an asynchronous callback to retur **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -1682,7 +1682,7 @@ Sets the network selection mode. This API uses a promise to return the result. **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -1737,7 +1737,7 @@ Obtains network search information for the SIM card in the specified slot. This **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -1782,7 +1782,7 @@ Obtains network search information for the SIM card in the specified slot. This **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -1822,7 +1822,7 @@ Obtains the NR option mode. This API uses an asynchronous callback to return the **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -1845,7 +1845,7 @@ radio.getNrOptionMode((err, data) => { getNrOptionMode(slotId: number, callback: AsyncCallback): void -Obtains the NR option mode for the SIM card in the specified slot. This API uses an asynchronous callback to return the result. +Obtains the NR option mode. This API uses an asynchronous callback to return the result. **System API**: This is a system API. @@ -1860,7 +1860,7 @@ Obtains the NR option mode for the SIM card in the specified slot. This API uses **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -1904,7 +1904,7 @@ Obtains the NR option mode for the SIM card in the specified slot. This API uses **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -1946,7 +1946,7 @@ Turns on the radio function. This API uses an asynchronous callback to return th **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -1970,7 +1970,7 @@ radio.turnOnRadio((err) => { turnOnRadio(slotId: number, callback: AsyncCallback): void -Turns on the radio function for the SIM card in the specified slot. This API uses an asynchronous callback to return the result. +Turns on the radio function. This API uses an asynchronous callback to return the result. **System API**: This is a system API. @@ -1987,7 +1987,7 @@ Turns on the radio function for the SIM card in the specified slot. This API use **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -2034,7 +2034,7 @@ Turns on the radio function for the SIM card in the specified slot. This API use **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -2076,7 +2076,7 @@ Turns off the radio function. This API uses an asynchronous callback to return t **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -2100,7 +2100,7 @@ radio.turnOffRadio((err) => { turnOffRadio(slotId: number, callback: AsyncCallback): void -Turns off the radio function for the SIM card in the specified slot. This API uses an asynchronous callback to return the result. +Turns off the radio function. This API uses an asynchronous callback to return the result. **System API**: This is a system API. @@ -2117,7 +2117,7 @@ Turns off the radio function for the SIM card in the specified slot. This API us **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -2164,7 +2164,7 @@ Turns off the radio function for the SIM card in the specified slot. This API us **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -2208,7 +2208,7 @@ Sets the preferred network for the SIM card in the specified slot. This API uses **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -2255,7 +2255,7 @@ Sets the preferred network for the SIM card in the specified slot. This API uses **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -2298,7 +2298,7 @@ Obtains the preferred network for the SIM card in the specified slot. This API u **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -2343,7 +2343,7 @@ Obtains the preferred network for the SIM card in the specified slot. This API u **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -2387,7 +2387,7 @@ Obtains the IMS registration status of the specified IMS service type for the SI **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -2433,7 +2433,7 @@ Obtains the IMS registration status of the specified IMS service type for the SI **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -2478,7 +2478,7 @@ Enables listening for **imsRegStateChange** events. This API uses an asynchronou **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | @@ -2516,11 +2516,11 @@ Disables listening for **imsRegStateChange** events. This API uses an asynchrono | type | string | Yes | IMS registration status changes. | | slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| | imsType | [ImsServiceType](#imsservicetype9) | Yes | IMS service type. | -| callback | Callback<[ImsRegInfo](#imsreginfo9)> | No | Callback used to return the result. | +| callback | Callback<[ImsRegInfo](#imsreginfo9)> | No | Callback used to return the result. If this parameter is not set, the API unsubscribes from all callbacks.| **Error codes** -For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). +For details about the error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | | -------- | -------------------------------------------- | diff --git a/en/application-dev/reference/apis/js-apis-rpc.md b/en/application-dev/reference/apis/js-apis-rpc.md index c4688c804e2ea21de453a25cf2ad543193f9d2ed..4e2f4ed96e608f1f91cca03faea5188893be128f 100644 --- a/en/application-dev/reference/apis/js-apis-rpc.md +++ b/en/application-dev/reference/apis/js-apis-rpc.md @@ -2397,7 +2397,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ```ts // Import @ohos.ability.featureAbility only for the application developed based on the FA model. // import FA from "@ohos.ability.featureAbility"; - + let proxy; let connect = { onConnect: function(elementName, remoteProxy) { @@ -2415,10 +2415,10 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode "bundleName": "com.ohos.server", "abilityName": "com.ohos.server.EntryAbility", }; - + // Use this method to connect to the ability for the FA model. // FA.connectAbility(want,connect); - + globalThis.context.connectServiceExtensionAbility(want, connect); ``` @@ -4860,7 +4860,7 @@ Reads the exception information from this **MessageParcel** object. ```ts // Import @ohos.ability.featureAbility only for the application developed based on the FA model. // import FA from "@ohos.ability.featureAbility"; - + let proxy; let connect = { onConnect: function(elementName, remoteProxy) { @@ -4878,10 +4878,10 @@ Reads the exception information from this **MessageParcel** object. "bundleName": "com.ohos.server", "abilityName": "com.ohos.server.EntryAbility", }; - + // Use this method to connect to the ability for the FA model. // FA.connectAbility(want,connect); - + globalThis.context.connectServiceExtensionAbility(want, connect); ``` @@ -5452,6 +5452,7 @@ Marshals this **Parcelable** object into a **MessageSequence** object. | Type | Description | | ------- | -------------------------------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| + **Example** ```ts @@ -5557,6 +5558,7 @@ Marshals the sequenceable object into a **MessageParcel** object. | Type | Description | | ------- | -------------------------------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| + **Example** ```ts @@ -5673,7 +5675,7 @@ Obtains a proxy or remote object. This API must be implemented by its derived cl ```ts // Import @ohos.ability.featureAbility only for the application developed based on the FA model. // import FA from "@ohos.ability.featureAbility"; - + let proxy; let connect = { onConnect: function(elementName, remoteProxy) { @@ -5691,10 +5693,10 @@ Obtains a proxy or remote object. This API must be implemented by its derived cl "bundleName": "com.ohos.server", "abilityName": "com.ohos.server.EntryAbility", }; - + // Use this method to connect to the ability for the FA model. // FA.connectAbility(want,connect); - + globalThis.context.connectServiceExtensionAbility(want, connect); ``` @@ -6117,7 +6119,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch ```ts // Import @ohos.ability.featureAbility only for the application developed based on the FA model. // import FA from "@ohos.ability.featureAbility"; - + let proxy; let connect = { onConnect: function(elementName, remoteProxy) { @@ -6135,10 +6137,10 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch "bundleName": "com.ohos.server", "abilityName": "com.ohos.server.EntryAbility", }; - + // Use this method to connect to the ability for the FA model. // FA.connectAbility(want,connect); - + globalThis.context.connectServiceExtensionAbility(want, connect); ``` @@ -6193,7 +6195,7 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn ```ts // Import @ohos.ability.featureAbility only for the application developed based on the FA model. // import FA from "@ohos.ability.featureAbility"; - + let proxy; let connect = { onConnect: function(elementName, remoteProxy) { @@ -6211,10 +6213,10 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn "bundleName": "com.ohos.server", "abilityName": "com.ohos.server.EntryAbility", }; - + // Use this method to connect to the ability for the FA model. // FA.connectAbility(want,connect); - + globalThis.context.connectServiceExtensionAbility(want, connect); ``` @@ -6277,7 +6279,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch ```ts // Import @ohos.ability.featureAbility only for the application developed based on the FA model. // import FA from "@ohos.ability.featureAbility"; - + let proxy; let connect = { onConnect: function(elementName, remoteProxy) { @@ -6295,10 +6297,10 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch "bundleName": "com.ohos.server", "abilityName": "com.ohos.server.EntryAbility", }; - + // Use this method to connect to the ability for the FA model. // FA.connectAbility(want,connect); - + globalThis.context.connectServiceExtensionAbility(want, connect); ``` @@ -6354,7 +6356,7 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn ```ts // Import @ohos.ability.featureAbility only for the application developed based on the FA model. // import FA from "@ohos.ability.featureAbility"; - + let proxy; let connect = { onConnect: function(elementName, remoteProxy) { @@ -6385,10 +6387,10 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn result.data.reclaim(); result.reply.reclaim(); } - + // Use this method to connect to the ability for the FA model. // FA.connectAbility(want,connect); - + globalThis.context.connectServiceExtensionAbility(want, connect); ``` @@ -6435,7 +6437,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch ```ts // Import @ohos.ability.featureAbility only for the application developed based on the FA model. // import FA from "@ohos.ability.featureAbility"; - + let proxy; let connect = { onConnect: function(elementName, remoteProxy) { @@ -6466,10 +6468,10 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch result.data.reclaim(); result.reply.reclaim(); } - + // Use this method to connect to the ability for the FA model. // FA.connectAbility(want,connect); - + globalThis.context.connectServiceExtensionAbility(want, connect); ``` @@ -6519,7 +6521,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ```ts // Import @ohos.ability.featureAbility only for the application developed based on the FA model. // import FA from "@ohos.ability.featureAbility"; - + let proxy; let connect = { onConnect: function(elementName, remoteProxy) { @@ -6537,10 +6539,10 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode "bundleName": "com.ohos.server", "abilityName": "com.ohos.server.EntryAbility", }; - + // Use this method to connect to the ability for the FA model. // FA.connectAbility(want,connect); - + globalThis.context.connectServiceExtensionAbility(want, connect); ``` @@ -6585,7 +6587,7 @@ Obtains the **LocalInterface** object of an interface token. ```ts // Import @ohos.ability.featureAbility only for the application developed based on the FA model. // import FA from "@ohos.ability.featureAbility"; - + let proxy; let connect = { onConnect: function(elementName, remoteProxy) { @@ -6603,10 +6605,10 @@ Obtains the **LocalInterface** object of an interface token. "bundleName": "com.ohos.server", "abilityName": "com.ohos.server.EntryAbility", }; - + // Use this method to connect to the ability for the FA model. // FA.connectAbility(want,connect); - + globalThis.context.connectServiceExtensionAbility(want, connect); ``` @@ -6647,7 +6649,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ```ts // Import @ohos.ability.featureAbility only for the application developed based on the FA model. // import FA from "@ohos.ability.featureAbility"; - + let proxy; let connect = { onConnect: function(elementName, remoteProxy) { @@ -6665,10 +6667,10 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode "bundleName": "com.ohos.server", "abilityName": "com.ohos.server.EntryAbility", }; - + // Use this method to connect to the ability for the FA model. // FA.connectAbility(want,connect); - + globalThis.context.connectServiceExtensionAbility(want, connect); ``` @@ -6689,7 +6691,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode } ``` -### addDeathRecippient(deprecated) +### addDeathRecipient(deprecated) >This API is no longer maintained since API version 9. You are advised to use [registerDeathRecipient](#registerdeathrecipient9). @@ -6719,7 +6721,7 @@ Adds a callback for receiving the death notifications of the remote object, incl ```ts // Import @ohos.ability.featureAbility only for the application developed based on the FA model. // import FA from "@ohos.ability.featureAbility"; - + let proxy; let connect = { onConnect: function(elementName, remoteProxy) { @@ -6737,14 +6739,14 @@ Adds a callback for receiving the death notifications of the remote object, incl "bundleName": "com.ohos.server", "abilityName": "com.ohos.server.EntryAbility", }; - + // Use this method to connect to the ability for the FA model. // FA.connectAbility(want,connect); - + globalThis.context.connectServiceExtensionAbility(want, connect); ``` - The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **addDeathRecippient()** of the proxy object is called to add a callback for receiving the death notification of the remove object. + The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **addDeathRecipient()** of the proxy object is called to add a callback for receiving the death notification of the remove object. ```ts class MyDeathRecipient { @@ -6786,7 +6788,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ```ts // Import @ohos.ability.featureAbility only for the application developed based on the FA model. // import FA from "@ohos.ability.featureAbility"; - + let proxy; let connect = { onConnect: function(elementName, remoteProxy) { @@ -6804,10 +6806,10 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode "bundleName": "com.ohos.server", "abilityName": "com.ohos.server.EntryAbility", }; - + // Use this method to connect to the ability for the FA model. // FA.connectAbility(want,connect); - + globalThis.context.connectServiceExtensionAbility(want, connect); ``` @@ -6821,8 +6823,8 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode } let deathRecipient = new MyDeathRecipient(); try { - proxy.registerDeathRecippient(deathRecipient, 0); - proxy.unregisterDeathRecippient(deathRecipient, 0); + proxy.registerDeathRecipient(deathRecipient, 0); + proxy.unregisterDeathRecipient(deathRecipient, 0); } catch(error) { console.info("proxy register deathRecipient fail, errorCode " + error.code); console.info("proxy register deathRecipient fail, errorMessage " + error.message); @@ -6859,7 +6861,7 @@ Removes the callback used to receive death notifications of the remote object. ```ts // Import @ohos.ability.featureAbility only for the application developed based on the FA model. // import FA from "@ohos.ability.featureAbility"; - + let proxy; let connect = { onConnect: function(elementName, remoteProxy) { @@ -6877,10 +6879,10 @@ Removes the callback used to receive death notifications of the remote object. "bundleName": "com.ohos.server", "abilityName": "com.ohos.server.EntryAbility", }; - + // Use this method to connect to the ability for the FA model. // FA.connectAbility(want,connect); - + globalThis.context.connectServiceExtensionAbility(want, connect); ``` @@ -6893,7 +6895,7 @@ Removes the callback used to receive death notifications of the remote object. } } let deathRecipient = new MyDeathRecipient(); - proxy.addDeathRecippient(deathRecipient, 0); + proxy.addDeathRecipient(deathRecipient, 0); proxy.removeDeathRecipient(deathRecipient, 0); ``` @@ -6927,7 +6929,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ```ts // Import @ohos.ability.featureAbility only for the application developed based on the FA model. // import FA from "@ohos.ability.featureAbility"; - + let proxy; let connect = { onConnect: function(elementName, remoteProxy) { @@ -6945,10 +6947,10 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode "bundleName": "com.ohos.server", "abilityName": "com.ohos.server.EntryAbility", }; - + // Use this method to connect to the ability for the FA model. // FA.connectAbility(want,connect); - + globalThis.context.connectServiceExtensionAbility(want, connect); ``` The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **getDescriptor()** of the proxy object is called to obtain the interface descriptor of the object. @@ -6986,7 +6988,7 @@ Obtains the interface descriptor of this proxy object. ```ts // Import @ohos.ability.featureAbility only for the application developed based on the FA model. // import FA from "@ohos.ability.featureAbility"; - + let proxy; let connect = { onConnect: function(elementName, remoteProxy) { @@ -7004,10 +7006,10 @@ Obtains the interface descriptor of this proxy object. "bundleName": "com.ohos.server", "abilityName": "com.ohos.server.EntryAbility", }; - + // Use this method to connect to the ability for the FA model. // FA.connectAbility(want,connect); - + globalThis.context.connectServiceExtensionAbility(want, connect); ``` @@ -7039,7 +7041,7 @@ Checks whether the **RemoteObject** is dead. ```ts // Import @ohos.ability.featureAbility only for the application developed based on the FA model. // import FA from "@ohos.ability.featureAbility"; - + let proxy; let connect = { onConnect: function(elementName, remoteProxy) { @@ -7057,10 +7059,10 @@ Checks whether the **RemoteObject** is dead. "bundleName": "com.ohos.server", "abilityName": "com.ohos.server.EntryAbility", }; - + // Use this method to connect to the ability for the FA model. // FA.connectAbility(want,connect); - + globalThis.context.connectServiceExtensionAbility(want, connect); ``` @@ -7095,9 +7097,9 @@ A constructor used to create a **MessageOption** object. **Parameters** - | Name | Type | Mandatory| Description | - | --------- | ------ | ---- | -------------------------------------- | - | syncFlags | number | No | Call flag, which can be synchronous or asynchronous. The default value is **synchronous**.| +| Name| Type | Mandatory| Description | +| ------ | ------- | ---- | -------------------------------------- | +| async | boolean | No | Call flag, which can be synchronous or asynchronous. The default value is **synchronous**.| **Example** @@ -7146,7 +7148,7 @@ Checks whether **SendMessageRequest** is called synchronously or asynchronously. | Type | Description | | ------- | ---------------------------------------- | - | boolean | Returns **true** if **SendMessageRequest** is called synchronously; returns **false** if **SendMessageRequest** is called asynchronously.| + | boolean | Returns **true** if **SendMessageRequest** is called asynchronously; returns **false** if it is called synchronously.| **Example** @@ -7825,7 +7827,7 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn | Type | Description | | ---------------------------- | --------------------------------------------- | - | Promise<RequestResult> | Promise used to return the **sendRequestResult** object.| + | Promise<RequestResult> | Promise used to return the **RequestResult** instance. | **Example** @@ -9101,29 +9103,30 @@ Reads data from the shared file associated with this **Ashmem** object. ```ts import Ability from '@ohos.app.ability.UIAbility'; + export default class MainAbility extends Ability { - onCreate(want, launchParam) { - console.log("[Demo] MainAbility onCreate"); - globalThis.context = this.context; - } - onDestroy() { - console.log("[Demo] MainAbility onDestroy"); - } - onWindowStageCreate(windowStage) { - // Main window is created, set main page for this ability - console.log("[Demo] MainAbility onWindowStageCreate"); - } - onWindowStageDestroy() { - // Main window is destroyed, release UI related resources - console.log("[Demo] MainAbility onWindowStageDestroy"); - } - onForeground() { - // Ability has brought to foreground - console.log("[Demo] MainAbility onForeground"); - } - onBackground() { - // Ability has back to background - console.log("[Demo] MainAbility onBackground"); - } + onCreate(want, launchParam) { + console.log("[Demo] MainAbility onCreate"); + globalThis.context = this.context; + } + onDestroy() { + console.log("[Demo] MainAbility onDestroy"); + } + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("[Demo] MainAbility onWindowStageCreate"); + } + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("[Demo] MainAbility onWindowStageDestroy"); + } + onForeground() { + // Ability has brought to foreground + console.log("[Demo] MainAbility onForeground"); + } + onBackground() { + // Ability has back to background + console.log("[Demo] MainAbility onBackground"); + } }; ``` diff --git a/en/application-dev/reference/apis/js-apis-socket.md b/en/application-dev/reference/apis/js-apis-socket.md index c34bb01c8780edc3c579bd40468382baa8fb6310..454e9ffc48c13ccd071b25326043ad20f91e1aa2 100644 --- a/en/application-dev/reference/apis/js-apis-socket.md +++ b/en/application-dev/reference/apis/js-apis-socket.md @@ -32,11 +32,11 @@ Creates a **UDPSocket** object. let udp = socket.constructUDPSocketInstance(); ``` -## UDPSocket +## UDPSocket7+ Defines a **UDPSocket** connection. Before invoking UDPSocket APIs, you need to call [socket.constructUDPSocketInstance](#socketconstructudpsocketinstance) to create a **UDPSocket** object. -### bind +### bind7+ bind(address: NetAddress, callback: AsyncCallback\): void @@ -76,7 +76,7 @@ udp.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}, err => { }) ``` -### bind +### bind7+ bind(address: NetAddress): Promise\ @@ -120,7 +120,7 @@ promise.then(() => { }); ``` -### send +### send7+ send(options: UDPSendOptions, callback: AsyncCallback\): void @@ -166,7 +166,7 @@ udp.send({ }) ``` -### send +### send7+ send(options: UDPSendOptions): Promise\ @@ -216,7 +216,7 @@ promise.then(() => { }); ``` -### close +### close7+ close(callback: AsyncCallback\): void @@ -245,7 +245,7 @@ udp.close(err => { }) ``` -### close +### close7+ close(): Promise\ @@ -273,7 +273,7 @@ promise.then(() => { }); ``` -### getState +### getState7+ getState(callback: AsyncCallback\): void @@ -318,7 +318,7 @@ udp.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}, err => { }) ``` -### getState +### getState7+ getState(): Promise\ @@ -357,7 +357,7 @@ promise.then(err => { }); ``` -### setExtraOptions +### setExtraOptions7+ setExtraOptions(options: UDPExtraOptions, callback: AsyncCallback\): void @@ -410,7 +410,7 @@ udp.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}, err => { }) ``` -### setExtraOptions +### setExtraOptions7+ setExtraOptions(options: UDPExtraOptions): Promise\ @@ -466,7 +466,7 @@ promise.then(() => { }); ``` -### on('message') +### on('message')7+ on(type: 'message', callback: Callback\<{message: ArrayBuffer, remoteInfo: SocketRemoteInfo}\>): void @@ -490,7 +490,7 @@ udp.on('message', value => { }); ``` -### off('message') +### off('message')7+ off(type: 'message', callback?: Callback\<{message: ArrayBuffer, remoteInfo: SocketRemoteInfo}\>): void @@ -521,7 +521,7 @@ udp.off('message', callback); udp.off('message'); ``` -### on('listening' | 'close') +### on('listening' | 'close')7+ on(type: 'listening' | 'close', callback: Callback\): void @@ -548,7 +548,7 @@ udp.on('close', () => { }); ``` -### off('listening' | 'close') +### off('listening' | 'close')7+ off(type: 'listening' | 'close', callback?: Callback\): void @@ -586,7 +586,7 @@ udp.off('close', callback2); udp.off('close'); ``` -### on('error') +### on('error')7+ on(type: 'error', callback: ErrorCallback): void @@ -610,7 +610,7 @@ udp.on('error', err => { }); ``` -### off('error') +### off('error')7+ off(type: 'error', callback?: ErrorCallback): void @@ -641,7 +641,7 @@ udp.off('error', callback); udp.off('error'); ``` -## NetAddress +## NetAddress7+ Defines the destination address. @@ -653,7 +653,7 @@ Defines the destination address. | port | number | No | Port number. The value ranges from **0** to **65535**. If this parameter is not specified, the system randomly allocates a port. | | family | number | No | Network protocol type.
- **1**: IPv4
- **2**: IPv6
The default value is **1**.| -## UDPSendOptions +## UDPSendOptions7+ Defines the parameters for sending data over the UDPSocket connection. @@ -664,7 +664,7 @@ Defines the parameters for sending data over the UDPSocket connection. | data | string \| ArrayBuffer7+ | Yes | Data to send. | | address | [NetAddress](#netaddress) | Yes | Destination address.| -## UDPExtraOptions +## UDPExtraOptions7+ Defines other properties of the UDPSocket connection. @@ -673,12 +673,12 @@ Defines other properties of the UDPSocket connection. | Name | Type | Mandatory| Description | | ----------------- | ------- | ---- | -------------------------------- | | broadcast | boolean | No | Whether to send broadcast messages. The default value is **false**. | -| receiveBufferSize | number | No | Size of the receive buffer, in bytes. | -| sendBufferSize | number | No | Size of the send buffer, in bytes. | +| receiveBufferSize | number | No | Size of the receive buffer, in bytes. The default value is **0**. | +| sendBufferSize | number | No | Size of the send buffer, in bytes. The default value is **0**. | | reuseAddress | boolean | No | Whether to reuse addresses. The default value is **false**. | -| socketTimeout | number | No | Timeout duration of the UDPSocket connection, in ms.| +| socketTimeout | number | No | Timeout duration of the UDPSocket connection, in ms. The default value is **0**.| -## SocketStateBase +## SocketStateBase7+ Defines the status of the socket connection. @@ -690,7 +690,7 @@ Defines the status of the socket connection. | isClose | boolean | Yes | Whether the connection is in the closed state.| | isConnected | boolean | Yes | Whether the connection is in the connected state.| -## SocketRemoteInfo +## SocketRemoteInfo7+ Defines information about the socket connection. @@ -709,7 +709,7 @@ The UDP error code mapping is in the format of 2301000 + Linux kernel error code For details about error codes, see [Socket Error Codes](../errorcodes/errorcode-net-socket.md). -## socket.constructTCPSocketInstance +## socket.constructTCPSocketInstance7+ constructTCPSocketInstance(): TCPSocket @@ -729,11 +729,11 @@ Creates a **TCPSocket** object. let tcp = socket.constructTCPSocketInstance(); ``` -## TCPSocket +## TCPSocket7+ Defines a TCPSocket connection. Before invoking TCPSocket APIs, you need to call [socket.constructTCPSocketInstance](#socketconstructtcpsocketinstance) to create a **TCPSocket** object. -### bind +### bind7+ bind(address: NetAddress, callback: AsyncCallback\): void @@ -773,7 +773,7 @@ tcp.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}, err => { }) ``` -### bind +### bind7+ bind(address: NetAddress): Promise\ @@ -817,7 +817,7 @@ promise.then(() => { }); ``` -### connect +### connect7+ connect(options: TCPConnectOptions, callback: AsyncCallback\): void @@ -857,7 +857,7 @@ tcp.connect({address: {address: '192.168.xx.xxx', port: xxxx, family: 1}, timeou }) ``` -### connect +### connect7+ connect(options: TCPConnectOptions): Promise\ @@ -898,7 +898,7 @@ promise.then(() => { }); ``` -### send +### send7+ send(options: TCPSendOptions, callback: AsyncCallback\): void @@ -944,7 +944,7 @@ tcp.connect({address: {address: '192.168.xx.xxx', port: xxxx, family: 1}, timeou }) ``` -### send +### send7+ send(options: TCPSendOptions): Promise\ @@ -996,7 +996,7 @@ promise1.then(() => { }); ``` -### close +### close7+ close(callback: AsyncCallback\): void @@ -1031,7 +1031,7 @@ tcp.close(err => { }) ``` -### close +### close7+ close(): Promise\ @@ -1065,7 +1065,7 @@ promise.then(() => { }); ``` -### getRemoteAddress +### getRemoteAddress7+ getRemoteAddress(callback: AsyncCallback\): void @@ -1106,7 +1106,7 @@ tcp.connect({address: {address: '192.168.xx.xxx', port: xxxx, family: 1}, timeou }); ``` -### getRemoteAddress +### getRemoteAddress7+ getRemoteAddress(): Promise\ @@ -1149,7 +1149,7 @@ promise1.then(() => { }); ``` -### getState +### getState7+ getState(callback: AsyncCallback\): void @@ -1190,7 +1190,7 @@ let promise = tcp.connect({address: {address: '192.168.xx.xxx', port: xxxx, fami }); ``` -### getState +### getState7+ getState(): Promise\ @@ -1233,7 +1233,7 @@ promise.then(() => { }); ``` -### setExtraOptions +### setExtraOptions7+ setExtraOptions(options: TCPExtraOptions, callback: AsyncCallback\): void @@ -1285,7 +1285,7 @@ let promise = tcp.connect({address: {address: '192.168.xx.xxx', port: xxxx, fami }); ``` -### setExtraOptions +### setExtraOptions7+ setExtraOptions(options: TCPExtraOptions): Promise\ @@ -1344,7 +1344,7 @@ promise.then(() => { }); ``` -### on('message') +### on('message')7+ on(type: 'message', callback: Callback<{message: ArrayBuffer, remoteInfo: SocketRemoteInfo}\>): void @@ -1368,7 +1368,7 @@ tcp.on('message', value => { }); ``` -### off('message') +### off('message')7+ off(type: 'message', callback?: Callback<{message: ArrayBuffer, remoteInfo: SocketRemoteInfo}\>): void @@ -1399,7 +1399,7 @@ tcp.off('message', callback); tcp.off('message'); ``` -### on('connect' | 'close') +### on('connect' | 'close')7+ on(type: 'connect' | 'close', callback: Callback\): void @@ -1426,7 +1426,7 @@ tcp.on('close', data => { }); ``` -### off('connect' | 'close') +### off('connect' | 'close')7+ off(type: 'connect' | 'close', callback?: Callback\): void @@ -1464,7 +1464,7 @@ tcp.off('close', callback2); tcp.off('close'); ``` -### on('error') +### on('error')7+ on(type: 'error', callback: ErrorCallback): void @@ -1488,7 +1488,7 @@ tcp.on('error', err => { }); ``` -### off('error') +### off('error')7+ off(type: 'error', callback?: ErrorCallback): void @@ -1519,7 +1519,7 @@ tcp.off('error', callback); tcp.off('error'); ``` -## TCPConnectOptions +## TCPConnectOptions7+ Defines TCPSocket connection parameters. @@ -1530,7 +1530,7 @@ Defines TCPSocket connection parameters. | address | [NetAddress](#netaddress) | Yes | Bound IP address and port number. | | timeout | number | No | Timeout duration of the TCPSocket connection, in ms.| -## TCPSendOptions +## TCPSendOptions7+ Defines the parameters for sending data over the TCPSocket connection. @@ -1541,7 +1541,7 @@ Defines the parameters for sending data over the TCPSocket connection. | data | string\| ArrayBuffer7+ | Yes | Data to send. | | encoding | string | No | Character encoding format. The options are as follows: **UTF-8**, **UTF-16BE**, **UTF-16LE**, **UTF-16**, **US-AECII**, and **ISO-8859-1**. The default value is **UTF-8**.| -## TCPExtraOptions +## TCPExtraOptions7+ Defines other properties of the TCPSocket connection. @@ -1553,10 +1553,10 @@ Defines other properties of the TCPSocket connection. | OOBInline | boolean | No | Whether to enable OOBInline. The default value is **false**. | | TCPNoDelay | boolean | No | Whether to enable no-delay on the TCPSocket connection. The default value is **false**. | | socketLinger | Object | Yes | Socket linger.
- **on**: whether to enable socket linger. The value true means to enable socket linger and false means the opposite.
- **linger**: linger time, in ms. The value ranges from **0** to **65535**.
Specify this parameter only when **on** is set to **true**.| -| receiveBufferSize | number | No | Size of the receive buffer, in bytes. | -| sendBufferSize | number | No | Size of the send buffer, in bytes. | +| receiveBufferSize | number | No | Size of the receive buffer, in bytes. The default value is **0**. | +| sendBufferSize | number | No | Size of the send buffer, in bytes. The default value is **0**. | | reuseAddress | boolean | No | Whether to reuse addresses. The default value is **false**. | -| socketTimeout | number | No | Timeout duration of the UDPSocket connection, in ms. | +| socketTimeout | number | No | Timeout duration of the TCPSocket connection, in ms. The default value is **0**. | ## Description of TCP Error Codes @@ -1853,7 +1853,7 @@ promise.then(() => { }); ``` -### on('message') +### on('message')9+ on(type: 'message', callback: Callback<{message: ArrayBuffer, remoteInfo: SocketRemoteInfo}>): void; @@ -1884,7 +1884,7 @@ tls.on('message', value => { }); ``` -### off('message') +### off('message')9+ off(type: 'message', callback?: Callback\<{message: ArrayBuffer, remoteInfo: SocketRemoteInfo}\>): void @@ -1920,7 +1920,7 @@ tls.on('message', callback); // You can pass the callback of the on method to cancel listening for a certain type of callback. If you do not pass the callback, you will cancel listening for all callbacks. tls.off('message', callback); ``` -### on('connect' | 'close') +### on('connect' | 'close')9+ on(type: 'connect' | 'close', callback: Callback\): void @@ -1947,7 +1947,7 @@ tls.on('close', () => { }); ``` -### off('connect' | 'close') +### off('connect' | 'close')9+ off(type: 'connect' | 'close', callback?: Callback\): void @@ -1984,7 +1984,7 @@ tls.on('close', callback2); tls.off('close', callback2); ``` -### on('error') +### on('error')9+ on(type: 'error', callback: ErrorCallback): void @@ -2008,7 +2008,7 @@ tls.on('error', err => { }); ``` -### off('error') +### off('error')9+ off(type: 'error', callback?: ErrorCallback): void @@ -2783,7 +2783,7 @@ Defines TLS connection options. | -------------- | ------------------------------------- | --- |-------------- | | address | [NetAddress](#netaddress) | Yes | Gateway address. | | secureOptions | [TLSSecureOptions](#tlssecureoptions9) | Yes| TLS security options.| -| ALPNProtocols | Array\ | No| Application Layer Protocol Negotiation (ALPN) protocols. | +| ALPNProtocols | Array\ | No| ALPN protocol. The value range is ["spdy/1", "http/1.1"]. The default value is **[]**. | ## TLSSecureOptions9+ @@ -2797,10 +2797,10 @@ Defines TLS security options. The CA certificate is mandatory, and other paramet | cert | string | No| Digital certificate of the local client. | | key | string | No| Private key of the local digital certificate. | | password | string | No| Password for reading the private key. | -| protocols | [Protocol](#protocol9) \|Array\<[Protocol](#protocol9)\> | No| TLS protocol version. | +| protocols | [Protocol](#protocol9) \|Array\<[Protocol](#protocol9)\> | No| TLS protocol version. The default value is **TLSv1.2**. | | useRemoteCipherPrefer | boolean | No| Whether to use the remote cipher suite preferentially. | -| signatureAlgorithms | string | No| Signing algorithm used during communication. | -| cipherSuite | string | No| Cipher suite used during communication. | +| signatureAlgorithms | string | No| Signing algorithm used during communication. The default value is **""**. | +| cipherSuite | string | No| Cipher suite used during communication. The default value is **""**. | ## Protocol9+ diff --git a/en/application-dev/reference/apis/js-apis-system-battery.md b/en/application-dev/reference/apis/js-apis-system-battery.md index 25af13c0c39825138fe490b36abd7ad00157f1d9..8eef0562cdedb91214d4eb9e688445eb6d8ff9b8 100644 --- a/en/application-dev/reference/apis/js-apis-system-battery.md +++ b/en/application-dev/reference/apis/js-apis-system-battery.md @@ -27,7 +27,7 @@ Obtains the current charging state and battery level. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| options | [GetStatusOptions](#getstatusoptions) | No| Object that contains the API calling result.| +| options | [GetStatusOptions](#getstatusoptions) | No| Object that contains the API calling result. This parameter is optional and is left blank by default.| **Example** @@ -44,15 +44,15 @@ battery.getStatus({ ## GetStatusOptions -Obtains the object that contains the API calling result. +Object that contains the API calling result. **System capability**: SystemCapability.PowerManager.BatteryManager.Core | Name | Type | Mandatory| Description | | -------- | --------------------------------------------------- | ---- | ------------------------------------------------------------ | -| success | (data: [BatteryResponse](#batteryresponse)) => void | No | Called when API call is successful. **data** is a return value of the [BatteryResponse](#batteryresponse) type.| -| fail | (data: string, code: number) => void | No | Called when API call has failed. **data** indicates the error information, and **code** indicates the error code. | -| complete | () => void | No | Called when API call is complete. | +| success | (data: [BatteryResponse](#batteryresponse)) => void | No | Called when an API call is successful. **data** is a return value of the [BatteryResponse](#batteryresponse) type.| +| fail | (data: string, code: number) => void | No | Called when an API call has failed. **data** indicates the error information, and **code** indicates the error code. | +| complete | () => void | No | Called when an API call is complete. | ## BatteryResponse @@ -60,7 +60,7 @@ Defines a response that returns the charging status and remaining power of the d **System capability**: SystemCapability.PowerManager.BatteryManager.Core -| Name| Type| Readable | Writable | Description| +| Name| Type| Readable| Writable| Description| | -------- | -------- | -------- | -------- | -------- | -| charging | boolean | Yes | No | Whether the battery is being charged.| -| level | number | Yes | No | Current battery level, which ranges from **0.00** to **1.00**.| +| charging | boolean | Yes| No| Whether the battery is being charged.| +| level | number | Yes| No| Current battery level, which ranges from **0.00** to **1.00**.| diff --git a/en/application-dev/reference/apis/js-apis-system-brightness.md b/en/application-dev/reference/apis/js-apis-system-brightness.md index 8053c8f0c73d190d33e547ff9f0227df5c6db06a..01a1defec2d87411735e0ffcf30b08beb93faccf 100644 --- a/en/application-dev/reference/apis/js-apis-system-brightness.md +++ b/en/application-dev/reference/apis/js-apis-system-brightness.md @@ -28,7 +28,7 @@ Obtains the current screen brightness. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| options | [GetBrightnessOptions](#getbrightnessoptions) | No | Options for obtaining the screen brightness.| +| options | [GetBrightnessOptions](#getbrightnessoptions) | No | Options for obtaining the screen brightness. This parameter is optional and is left blank by default.| **Example** @@ -56,7 +56,7 @@ Sets the screen brightness. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| options | [SetBrightnessOptions](#setbrightnessoptions) | No | Options for setting the screen brightness.| +| options | [SetBrightnessOptions](#setbrightnessoptions) | No | Options for setting the screen brightness. This parameter is optional and is left blank by default.| **Example** @@ -85,7 +85,7 @@ Obtains the screen brightness adjustment mode. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| options | [GetBrightnessModeOptions](#getbrightnessmodeoptions) | No| Options for obtaining the screen brightness mode.| +| options | [GetBrightnessModeOptions](#getbrightnessmodeoptions) | No| Options for obtaining the screen brightness mode. This parameter is optional and is left blank by default.| **Example** @@ -112,7 +112,7 @@ Sets the screen brightness adjustment mode. **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| options | [SetBrightnessModeOptions](#setbrightnessmodeoptions) | No | Options for setting the screen brightness mode.| +| options | [SetBrightnessModeOptions](#setbrightnessmodeoptions) | No | Options for setting the screen brightness mode. This parameter is optional and is left blank by default.| **Example** @@ -143,7 +143,7 @@ Sets whether to always keep the screen on. Call this API in **onShow()**. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| options | [SetKeepScreenOnOptions](#setkeepscreenonoptions) | No| Options for setting the screen to be steady on.| +| options | [SetKeepScreenOnOptions](#setkeepscreenonoptions) | No| Options for setting the screen to be steady on. This parameter is optional and is left blank by default.| **Example** @@ -166,9 +166,9 @@ Defines the options for obtaining the screen brightness. | Name | Type | Mandatory| Description | | -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | -| success | (data: [BrightnessResponse](#brightnessresponse)) => void | No | Called when API call is successful. **data** is a return value of the [BrightnessResponse](#brightnessresponse) type.| -| fail | (data: string, code: number) => void | No | Called when API call has failed. **data** indicates the error information, and **code** indicates the error code. | -| complete | () => void | No | Called when the API call is complete. | +| success | (data: [BrightnessResponse](#brightnessresponse)) => void | No | Called when an API call is successful. **data** is a return value of the [BrightnessResponse](#brightnessresponse) type.| +| fail | (data: string, code: number) => void | No | Called when an API call has failed. **data** indicates the error information, and **code** indicates the error code. | +| complete | () => void | No | Called when an API call is complete. | ## SetBrightnessOptions @@ -178,10 +178,10 @@ Defines the options for setting the screen brightness. | Name | Type | Mandatory| Description | | -------- | ------------------------------------ | ---- | ------------------------------------------------------------ | -| value | number | Yes | Screen brightness. The value is an integer ranging from **1** to **255**.
- If the value is less than or equal to **0**, value **1** will be used.
- If the value is greater than **255**, value **255** will be used.
- If the value contains decimals, the integral part of the value will be used. For example, if value **8.1** is set, value **8** will be used.| -| success | () => void | No | Callback upon a successful API call. | -| fail | (data: string, code: number) => void | No | Called when API call has failed. **data** indicates the error information, and **code** indicates the error code. | -| complete | () => void | No | Called when the API call is complete. | +| value | number | Yes | Screen brightness. The value is an integer ranging from **1** to **255**.
- If the value is less than or equal to **0**, value **1** will be used.
- If the value is greater than **255**, value **255** will be used.
- If the value contains decimals, the integral part of the value will be used. For example, if value **8.1** is set, value **8** will be used.| +| success | () => void | No | Called when an API call is successful. | +| fail | (data: string, code: number) => void | No | Called when an API call has failed. **data** indicates the error information, and **code** indicates the error code. | +| complete | () => void | No | Called when an API call is complete. | ## BrightnessResponse @@ -201,9 +201,9 @@ Defines the options for obtaining the screen brightness mode. | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| success | (data: [BrightnessModeResponse](#brightnessmoderesponse)) => void | No | Called when API call is successful. **data** is a return value of the [BrightnessModeResponse](#brightnessmoderesponse) type.| -| fail | (data: string, code: number) => void | No | Called when API call has failed. **data** indicates the error information, and **code** indicates the error code. | -| complete | () => void | No | Called when the API call is complete. | +| success | (data: [BrightnessModeResponse](#brightnessmoderesponse)) => void | No | Called when an API call is successful. **data** is a return value of the [BrightnessModeResponse](#brightnessmoderesponse) type.| +| fail | (data: string, code: number) => void | No | Called when an API call has failed. **data** indicates the error information, and **code** indicates the error code. | +| complete | () => void | No | Called when an API call is complete. | ## SetBrightnessModeOptions @@ -214,9 +214,9 @@ Defines the options for setting the screen brightness mode. | Name | Type | Mandatory| Description | | -------- | ------------------------------------ | ---- | ------------------------------------------------------ | | mode | number | Yes | The value **0** indicates the manual adjustment mode, and the value **1** indicates the automatic adjustment mode.| -| success | () => void | No | Callback upon a successful API call. | -| fail | (data: string, code: number) => void | No | Called when API call has failed. **data** indicates the error information, and **code** indicates the error code.| -| complete | () => void | No | Called when the API call is complete. | +| success | () => void | No | Called when an API call is successful. | +| fail | (data: string, code: number) => void | No | Called when an API call has failed. **data** indicates the error information, and **code** indicates the error code.| +| complete | () => void | No | Called when an API call is complete. | ## BrightnessModeResponse @@ -237,6 +237,6 @@ Defines the options for setting the screen to be steady on. | Name | Type | Mandatory| Description | | ------------ | ------------------------------------ | ---- | ------------------------------------------------------ | | keepScreenOn | boolean | Yes | The value **true** means to keep the screen steady on, and the value **false** indicates the opposite. | -| success | () => void | No | Callback upon a successful API call. | -| fail | (data: string, code: number) => void | No | Called when API call has failed. **data** indicates the error information, and **code** indicates the error code.| -| complete | () => void | No | Called when the API call is complete. | +| success | () => void | No | Called when an API call is successful. | +| fail | (data: string, code: number) => void | No | Called when an API call has failed. **data** indicates the error information, and **code** indicates the error code.| +| complete | () => void | No | Called when an API call is complete. | diff --git a/en/application-dev/reference/apis/js-apis-system-date-time.md b/en/application-dev/reference/apis/js-apis-system-date-time.md index 38d90b668894a52dde1a4ae05578d290182bc6ef..de45c25f8a7ab2ac317bc0a212ba3aef0576febc 100644 --- a/en/application-dev/reference/apis/js-apis-system-date-time.md +++ b/en/application-dev/reference/apis/js-apis-system-date-time.md @@ -97,7 +97,7 @@ Obtains the time elapsed since the Unix epoch. This API uses an asynchronous cal | Name | Type | Mandatory| Description | | -------- | -------------- | ---- | ------------------ | -| isNano | boolean | Yes | Whether the time to return is in nanoseconds.
- **true**: The time to return is in nanoseconds.
- **false**: The time to return is in milliseconds.| +| isNano | boolean | Yes | Whether the time to return is in nanoseconds.
- **true**: The time to return is in nanoseconds.
- **false**: The time to return is in milliseconds. | | callback | AsyncCallback<number> | Yes | Callback used to return the time elapsed since the Unix epoch. | **Example** @@ -128,7 +128,7 @@ Obtains the time elapsed since the Unix epoch. This API uses an asynchronous cal | Name | Type | Mandatory| Description | | -------- | ----------- | ---- | ---------------------------------- | -| callback | AsyncCallback<number> | Yes | Callback used to return the time elapsed since the Unix epoch. | +| callback | AsyncCallback<number> | Yes | Callback used to return the time elapsed since the Unix epoch, in milliseconds. | **Example** @@ -158,7 +158,7 @@ Obtains the time elapsed since the Unix epoch. This API uses a promise to return | Name| Type | Mandatory| Description | | ------ | ------- | ---- | ------------------------- | -| isNano | boolean | No | Whether the time to return is in nanoseconds.
- **true**: The time to return is in nanoseconds.
- **false**: The time to return is in milliseconds.| +| isNano | boolean | No | Whether the time to return is in nanoseconds.
- **true**: The time to return is in nanoseconds.
- **false**: The time to return is in milliseconds.
Default value: **false** | **Return value** @@ -192,7 +192,7 @@ Obtains the time elapsed since system startup, excluding the deep sleep time. Th | Name | Type | Mandatory| Description | | -------- | ---------- | ---- | -------------------------- | -| isNano | boolean | Yes | Whether the time to return is in nanoseconds.
- **true**: The time to return is in nanoseconds.
- **false**: The time to return is in milliseconds.| +| isNano | boolean | Yes | Whether the time to return is in nanoseconds.
- **true**: The time to return is in nanoseconds.
- **false**: The time to return is in milliseconds. | | callback | AsyncCallback<number> | Yes | Callback used to return the time.| **Example** @@ -253,7 +253,7 @@ Obtains the time elapsed since system startup, excluding the deep sleep time. Th | Name| Type | Mandatory| Description | | ------ | ------- | ---- | ----------------------------------- | -| isNano | boolean | No | Whether the time to return is in nanoseconds.
- **true**: The time to return is in nanoseconds.
- **false**: The time to return is in milliseconds.| +| isNano | boolean | No | Whether the time to return is in nanoseconds.
- **true**: The time to return is in nanoseconds.
- **false**: The time to return is in milliseconds.
Default value: **false** | **Return value** @@ -287,7 +287,7 @@ Obtains the time elapsed since system startup, including the deep sleep time. Th | Name | Type | Mandatory| Description | | -------- | --------------- | ---- | ------------------------------- | -| isNano | boolean | Yes | Whether the time to return is in nanoseconds.
- **true**: The time to return is in nanoseconds.
- **false**: The time to return is in milliseconds.| +| isNano | boolean | Yes | Whether the time to return is in nanoseconds.
- **true**: The time to return is in nanoseconds.
- **false**: The time to return is in milliseconds. | | callback | AsyncCallback<number> | Yes | Callback used to return the time. | **Example** @@ -348,7 +348,7 @@ Obtains the time elapsed since system startup, including the deep sleep time. Th | Name| Type | Mandatory| Description | | ------ | ------- | ---- | ------------------------------- | -| isNano | boolean | No | Whether the time to return is in nanoseconds.
- **true**: The time to return is in nanoseconds.
- **false**: The time to return is in milliseconds.| +| isNano | boolean | No | Whether the time to return is in nanoseconds.
- **true**: The time to return is in nanoseconds.
- **false**: The time to return is in milliseconds.
Default value: **false** | **Return value** diff --git a/en/application-dev/reference/apis/js-apis-system-device.md b/en/application-dev/reference/apis/js-apis-system-device.md index d1809eb7b9772ce25bf67e1a44e04c5c1febf7a2..ee8dd583a241d2ee8c2a3bbb6ed5d52cc2a30ef7 100644 --- a/en/application-dev/reference/apis/js-apis-system-device.md +++ b/en/application-dev/reference/apis/js-apis-system-device.md @@ -63,7 +63,6 @@ Provides the device information. | screenDensity4+ | number | Screen density.| | screenShape4+ | string | Screen shape. The options are as follows:
- **rect**: rectangular screen
- **circle**: round screen| | apiVersion4+ | number | API version.| -| releaseType4+ | string | Release type. The value includes both the release type and the API version, for example, Beta1.
Available release types are as follows:
- **Canary**: Releases of this type are compatible with each other under the same API version, but not with those of the **beta** and **release** type.
- **Beta**: Releases of this type are compatible with each other under the same API version, but not with those of the **release** type.
- **Release**: Releases of this type are compatible with the latest five API versions. | | deviceType4+ | string | Device type.| diff --git a/en/application-dev/reference/apis/js-apis-system-router.md b/en/application-dev/reference/apis/js-apis-system-router.md index cb6ae5245d9b11ddc267ee326a34a3ab38164f04..1a09b8feed18014569ab8a61f75de2beffe2e55b 100644 --- a/en/application-dev/reference/apis/js-apis-system-router.md +++ b/en/application-dev/reference/apis/js-apis-system-router.md @@ -343,8 +343,8 @@ Defines the page routing parameters. | Name | Type| Mandatory| Description | | ------ | -------- | ---- | ------------------------------------------------------------ | -| uri | string | Yes | URI of the target page, in either of the following formats:
1. Absolute path, which is provided by the **pages** list in the **config.json** file. Example:
- pages/index/index
- pages/detail/detail
2. Specific path. If the URI is a slash (/), the home page is displayed.| -| params | object | No | Data that needs to be passed to the target page during redirection. The target page can use **router.getParams()** to obtain the passed parameters, for example, **this.keyValue** (**keyValue** is the value of a key in **params**). In the web-like paradigm, these parameters can be directly used on the target page. If the field specified by **key** already exists on the target page, the passed value of the key will be displayed.| +| uri7+ | string | Yes | URI of the target page, in either of the following formats:
1. Absolute path, which is provided by the **pages** list in the **config.json** file. Example:
- pages/index/index
- pages/detail/detail
2. Specific path. If the URI is a slash (/), the home page is displayed.| +| params7+ | object | No | Data that needs to be passed to the target page during redirection. The target page can use **router.getParams()** to obtain the passed parameters, for example, **this.keyValue** (**keyValue** is the value of a key in **params**). In the web-like paradigm, these parameters can be directly used on the target page. If the field specified by **key** already exists on the target page, the passed value of the key will be displayed.| ## BackRouterOptions @@ -355,8 +355,8 @@ Defines the parameters for routing back. | Name | Type| Mandatory| Description | | ------ | -------- | ---- | ------------------------------------------------------------ | -| uri | string | No | URI of the page to return to. If the specified page does not exist in the page stack, the application does not respond. If this parameter is not set, the application returns to the previous page.
**System capability**: SystemCapability.ArkUI.ArkUI.Full| -| params | object | No | Data that needs to be passed to the target page during redirection.
**System capability**: SystemCapability.ArkUI.ArkUI.Lite| +| uri7+ | string | No | URI of the page to return to. If the specified page does not exist in the page stack, the application does not respond. If this parameter is not set, the application returns to the previous page.
**System capability**: SystemCapability.ArkUI.ArkUI.Full| +| params7+ | object | No | Data that needs to be passed to the target page during redirection.
**System capability**: SystemCapability.ArkUI.ArkUI.Lite| ## RouterState diff --git a/en/application-dev/reference/apis/js-apis-system-time.md b/en/application-dev/reference/apis/js-apis-system-time.md index b1f745e7085764b193567866dc6e6a74e7cb04d4..d1cdd26246f3408d3c930fa061be7ddc972d8bfc 100644 --- a/en/application-dev/reference/apis/js-apis-system-time.md +++ b/en/application-dev/reference/apis/js-apis-system-time.md @@ -13,7 +13,7 @@ The **systemTime** module provides system time and time zone features. You can u import systemTime from '@ohos.systemTime'; ``` -## systemTime.setTime(deprecated) +## systemTime.setTime setTime(time : number, callback : AsyncCallback<void>) : void @@ -191,7 +191,7 @@ Obtains the time elapsed since the Unix epoch. This API uses a promise to return | Name| Type | Mandatory| Description | | ------ | ------- | ---- | ------------------------- | -| isNano | boolean | No | Whether the time to return is in nanoseconds.
- **true**: in nanoseconds.
- **false**: in milliseconds.| +| isNano | boolean | No | Whether the time to return is in nanoseconds.
- **true**: in nanoseconds.
- **false**: in milliseconds.
Default value: **false** | **Return value** @@ -310,7 +310,7 @@ Obtains the time elapsed since system startup, excluding the deep sleep time. Th | Name| Type | Mandatory| Description | | ------ | ------- | ---- | ----------------------------------- | -| isNano | boolean | No | Whether the time to return is in nanoseconds.
- **true**: in nanoseconds.
- **false**: in milliseconds.| +| isNano | boolean | No | Whether the time to return is in nanoseconds.
- **true**: in nanoseconds.
- **false**: in milliseconds.
Default value: **false** | **Return value** @@ -429,7 +429,7 @@ Obtains the time elapsed since system startup, including the deep sleep time. Th | Name| Type | Mandatory| Description | | ------ | ------- | ---- | ------------------------------- | -| isNano | boolean | No | Whether the time to return is in nanoseconds.
- **true**: in nanoseconds.
- **false**: in milliseconds.| +| isNano | boolean | No | Whether the time to return is in nanoseconds.
- **true**: in nanoseconds.
- **false**: in milliseconds.
Default value: **false** | **Return value** diff --git a/en/application-dev/reference/apis/js-apis-timer.md b/en/application-dev/reference/apis/js-apis-timer.md index f1fabcf335ead87b35304549ac60efd765f9ff42..eb501dd5dcac48ca8fb5ea17c2c69226b36ef424 100644 --- a/en/application-dev/reference/apis/js-apis-timer.md +++ b/en/application-dev/reference/apis/js-apis-timer.md @@ -18,9 +18,9 @@ Sets a timer for the system to call a function after the timer goes off. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| handler | Function \| string | Yes| Function to be called after the timer goes off.| +| handler | Function \| string | Yes| Function to be called after the timer goes off. If the type is string, error information is printed and no other processing is performed.| | delay | number | No| Number of milliseconds delayed before the execution. If this parameter is left empty, the default value **0** is used, which means that the execution starts immediately or as soon as possible.| -| ...arguments | Array<any> | No| Additional parameters to pass to the handler after the timer goes off.| +| ...arguments | any[] | No| Additional parameters to pass to the handler after the timer goes off.| **Return value** @@ -31,19 +31,15 @@ Sets a timer for the system to call a function after the timer goes off. **Example** ```js - export default { - setTimeOut() { - var timeoutID = setTimeout(function() { - console.log('delay 1s'); - }, 1000); - } - } + setTimeout(function() { + console.log('delay 1s'); + }, 1000); ``` ## clearTimeout -clearTimeout(timeoutID: number): void +clearTimeout(timeoutID?: number): void Cancels the timer created via **setTimeout()**. @@ -53,19 +49,15 @@ Cancels the timer created via **setTimeout()**. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| timeoutID | number | Yes| ID of the timer to cancel, which is returned by **setTimeout()**| +| timeoutID | number | No| ID of the timer to cancel, which is returned by **setTimeout()** If this parameter is omitted, no timer is canceled.| **Example** - ```js - export default { - clearTimeOut() { - var timeoutID = setTimeout(function() { - console.log('do after 1s delay.'); - }, 1000); - clearTimeout(timeoutID); - } - } + ```js + let timeoutID = setTimeout(function() { + console.log('do after 1s delay.'); + }, 1000); + clearTimeout(timeoutID); ``` @@ -81,32 +73,28 @@ Sets a repeating timer for the system to repeatedly call a function at a fixed i | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| handler | Function \| string | Yes| Function to be called repeatedly.| +| handler | Function \| string | Yes| Function to be called repeatedly. If the type is string, error information is printed and no other processing is performed.| | delay | number | Yes| Number of milliseconds delayed before the execution.| -| ...arguments | Array<any> | No| Additional parameters to pass to the handler after the timer goes off.| +| ...arguments | any[] | No| Additional parameters to pass to the handler after the timer goes off.| **Return value** | Type| Description| | -------- | -------- | -| number | ID of the repeating timer.| +| number | Timer ID.| **Example** ```js - export default { - setInterval() { - var intervalID = setInterval(function() { - console.log('do very 1s.'); - }, 1000); - } - } + setInterval(function() { + console.log('do every 1s.'); + }, 1000); ``` ## clearInterval -clearInterval(intervalID: number): void +clearInterval(intervalID?: number): void Cancels the repeating timer set via **setInterval()**. @@ -116,17 +104,13 @@ Cancels the repeating timer set via **setInterval()**. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| intervalID | number | Yes| ID of the repeating timer to cancel, which is returned by **setInterval()**.| +| intervalID | number | No| ID of the repeating timer to cancel, which is returned by **setInterval()**. If this parameter is omitted, no timer is canceled.| **Example** - ```js - export default { - clearInterval() { - var intervalID = setInterval(function() { - console.log('do very 1s.'); - }, 1000); - clearInterval(intervalID); - } - } + ```js + let intervalID = setInterval(function() { + console.log('do every 1s.'); + }, 1000); + clearInterval(intervalID); ``` diff --git a/en/application-dev/reference/apis/js-apis-uitest.md b/en/application-dev/reference/apis/js-apis-uitest.md index 03eb460589a3c0790873388128ad7bdc250850eb..3b0ee56a7bef48b0bee0bcdae5c6a781d0ba2b86 100644 --- a/en/application-dev/reference/apis/js-apis-uitest.md +++ b/en/application-dev/reference/apis/js-apis-uitest.md @@ -119,7 +119,16 @@ Provides the flag attributes of this window. ## On9+ Since API version 9, the UiTest framework provides a wide range of UI component feature description APIs in the **On** class to filter and match components. -The API capabilities provided by the **On** class exhibit the following features: 1. Allow one or more attributes as the match conditions. For example, you can specify both the **text** and **id** attributes to find the target component.
2. Provide multiple match patterns for component attributes.
3. Support absolute positioning and relative positioning for components. APIs such as [ON.isBefore](#isbefore) and [ON.isAfter](#isafter) can be used to specify the features of adjacent components to assist positioning.
All APIs provided in the **On** class are synchronous. You are advised to use the static constructor **ON** to create an **On** object in chain mode. + +The API capabilities provided by the **On** class exhibit the following features: + +- Allow one or more attributes as the match conditions. For example, you can specify both the **text** and **id** attributes to find the target component. + +- Provide multiple match patterns for component attributes. + +- Support absolute positioning and relative positioning for components. APIs such as [ON.isBefore](#isbefore9) and [ON.isAfter](#isafter9) can be used to specify the features of adjacent components to assist positioning. + +All APIs provided in the **On** class are synchronous. You are advised to use the static constructor **ON** to create an **On** object in chain mode. ```js ON.text('123').type('button'); @@ -420,7 +429,7 @@ let on = ON.checkable(true); // Use the static constructor ON to create an On ob isBefore(on: On): On -Specifies the attributes of the component before which the target component is located. +Specifies that the target component is located before the given attribute component. **System capability**: SystemCapability.Test.UiTest @@ -439,14 +448,14 @@ Specifies the attributes of the component before which the target component is l **Example** ```js -let on = ON.isBefore(ON.text('123')); // Use the static constructor ON to create an On object and specify the attributes of the component before which the target component is located. +let on = ON.isBefore(ON.text('123')); // Create an On object using the static constructor ON, specifying that the target component is located before the given attribute component. ``` ### isAfter9+ isAfter(on: On): On -Specifies the attributes of the component after which the target component is located. +Specifies that the target component is located after the given attribute component. **System capability**: SystemCapability.Test.UiTest @@ -465,12 +474,13 @@ Specifies the attributes of the component after which the target component is lo **Example** ```js -let on = ON.isAfter(ON.text('123')); // Use the static constructor ON to create an On object and specify the attributes of the component after which the target component is located. +let on = ON.isAfter(ON.text('123')); // Create an On object using the static constructor ON, specifying that the target component is located after the given attribute component. ``` ## Component9+ -In **UiTest** of API version 9, the **Component** class represents a component on the UI and provides APIs for obtaining component attributes, clicking a component, scrolling to search for a component, and text injection. +Represents a component on the UI and provides APIs for obtaining component attributes, clicking a component, scrolling to search for a component, and text injection. + All APIs provided in this class use a promise to return the result and must be invoked using **await**. ### click9+ @@ -1476,7 +1486,7 @@ Searches this **Driver** object for the target component that matches the given | Type | Description | | --------------------------------- | --------------------------------- | -| Promise\<[Component](#component)> | Promise used to return the found component.| +| Promise\<[Component](#component9)> | Promise used to return the found component.| **Error codes** @@ -2078,7 +2088,7 @@ Simulates a fling operation on the screen. | from | [Point](#point9) | Yes | Coordinates of the point where the finger touches the screen. | | to | [Point](#point9) | Yes | Coordinates of the point where the finger leaves the screen. | | stepLen | number | Yes | Fling step length, in pixels. | -| speed | number | Yes | Scroll speed, in pixel/s. The value ranges from 200 to 15000. If the set value is not in the range, the default value 600 is used.| +| speed | number | Yes | Fling speed, in pixel/s. The value ranges from 200 to 15000. If the set value is not in the range, the default value 600 is used.| **Error codes** @@ -2093,7 +2103,7 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ```js async function demo() { let driver = Driver.create(); - await driver.fling({x: 500, Y: 480},{x: 450, Y: 480},5,600); + await driver.fling({x: 500, y: 480},{x: 450, y: 480},5,600); } ``` @@ -2649,7 +2659,13 @@ async function demo() { ## By(deprecated) The UiTest framework provides a wide range of UI component feature description APIs in the **By** class to filter and match components. -The API capabilities provided by the **By** class exhibit the following features:
1. Allow one or more attributes as the match conditions. For example, you can specify both the **text** and **id** attributes to find the target component.
2. Provide multiple match patterns for component attributes.
3. Support absolute positioning and relative positioning for components. APIs such as [By.isBefore(deprecated)](#isbeforedeprecated) and [By.isAfter(deprecated)](#isafterdeprecated) can be used to specify the features of adjacent components to assist positioning.
All APIs provided in the **By** class are synchronous. You are advised to use the static constructor **BY** to create a **By** object in chain mode. +The API capabilities provided by the **By** class exhibit the following features: + +- Allow one or more attributes as the match conditions. For example, you can specify both the **text** and **id** attributes to find the target component. +- Provide multiple match patterns for component attributes. +- Support absolute positioning and relative positioning for components. APIs such as [By.isBefore(deprecated)](#isbeforedeprecated) and [By.isAfter(deprecated)](#isafterdeprecated) can be used to specify the features of adjacent components to assist positioning. + +All APIs provided in the **By** class are synchronous. You are advised to use the static constructor **BY** to create a **By** object in chain mode. This API is deprecated since API version 9. You are advised to use [On9+](#on9) instead. @@ -2663,7 +2679,7 @@ text(txt: string, pattern?: MatchPattern): By Specifies the text attribute of the target component. Multiple match patterns are supported. -This API is deprecated since API version 9. You are advised to use [text9+](#text9). +This API is deprecated since API version 9. You are advised to use [text9+](#text9) instead. **System capability**: SystemCapability.Test.UiTest @@ -2693,7 +2709,7 @@ key(key: string): By Specifies the key attribute of the target component. -This API is deprecated since API version 9. You are advised to use [id9+](#id9). +This API is deprecated since API version 9. You are advised to use [id9+](#id9) instead. **System capability**: SystemCapability.Test.UiTest @@ -2751,7 +2767,7 @@ type(tp: string): By Specifies the type attribute of the target component. -This API is deprecated since API version 9. You are advised to use [type9+](#type9). +This API is deprecated since API version 9. You are advised to use [type9+](#type9) instead. **System capability**: SystemCapability.Test.UiTest @@ -2780,7 +2796,7 @@ clickable(b?: boolean): By Specifies the clickable status attribute of the target component. -This API is deprecated since API version 9. You are advised to use [clickable9+](#clickable9). +This API is deprecated since API version 9. You are advised to use [clickable9+](#clickable9) instead. **System capability**: SystemCapability.Test.UiTest @@ -2809,7 +2825,7 @@ scrollable(b?: boolean): By Specifies the scrollable status attribute of the target component. -This API is deprecated since API version 9. You are advised to use [scrollable9+](#scrollable9). +This API is deprecated since API version 9. You are advised to use [scrollable9+](#scrollable9) instead. **System capability**: SystemCapability.Test.UiTest @@ -2837,7 +2853,7 @@ enabled(b?: boolean): By Specifies the enabled status attribute of the target component. -This API is deprecated since API version 9. You are advised to use [enabled9+](#enabled9). +This API is deprecated since API version 9. You are advised to use [enabled9+](#enabled9) instead. **System capability**: SystemCapability.Test.UiTest @@ -2865,7 +2881,7 @@ focused(b?: boolean): By Specifies the focused status attribute of the target component. -This API is deprecated since API version 9. You are advised to use [focused9+](#focused9). +This API is deprecated since API version 9. You are advised to use [focused9+](#focused9) instead. **System capability**: SystemCapability.Test.UiTest @@ -2919,7 +2935,7 @@ let by = BY.selected(true); // Use the static constructor BY to create a By obje isBefore(by: By): By -Specifies the attributes of the component before which the target component is located. +Specifies that the target component is located before the given attribute component. This API is deprecated since API version 9. You are advised to use [isBefore9+](#isbefore9). @@ -2947,9 +2963,9 @@ let by = BY.isBefore(BY.text('123')); // Use the static constructor BY to create isAfter(by: By): By -Specifies the attributes of the component after which the target component is located. +Specifies that the target component is located after the given attribute component. -This API is deprecated since API version 9. You are advised to use [isAfter9+](#isafter9). +This API is deprecated since API version 9. You are advised to use [isAfter9+](#isafter9) instead. **System capability**: SystemCapability.Test.UiTest @@ -2968,7 +2984,7 @@ This API is deprecated since API version 9. You are advised to use [isAfter **Example** ```js -let by = BY.isAfter(BY.text('123')); // Use the static constructor BY to create a By object and specify the attributes of the component after which the target component is located. +let by = BY.isAfter(BY.text('123')); // Use the static constructor BY to create a By object, specifying that the target component is located after the given attribute component. ``` ## UiComponent(deprecated) @@ -2984,7 +3000,7 @@ click(): Promise\ Clicks this component. -This API is deprecated since API version 9. You are advised to use [click9+](#click9). +This API is deprecated since API version 9. You are advised to use [click9+](#click9) instead. **System capability**: SystemCapability.Test.UiTest @@ -3004,7 +3020,7 @@ doubleClick(): Promise\ Double-clicks this component. -This API is deprecated since API version 9. You are advised to use [doubleClick9+](#doubleclick9). +This API is deprecated since API version 9. You are advised to use [doubleClick9+](#doubleclick9) instead. **System capability**: SystemCapability.Test.UiTest @@ -3024,7 +3040,7 @@ longClick(): Promise\ Long-clicks this component. -This API is deprecated since API version 9. You are advised to use [longClick9+](#longclick9). +This API is deprecated since API version 9. You are advised to use [longClick9+](#longclick9) instead. **System capability**: SystemCapability.Test.UiTest @@ -3070,7 +3086,7 @@ getKey(): Promise\ Obtains the key of this component. -This API is deprecated since API version 9. You are advised to use [getId9+](#getid9). +This API is deprecated since API version 9. You are advised to use [getId9+](#getid9) instead. **System capability**: SystemCapability.Test.UiTest @@ -3096,7 +3112,7 @@ getText(): Promise\ Obtains the text information of this component. -This API is deprecated since API version 9. You are advised to use [getText9+](#gettext9). +This API is deprecated since API version 9. You are advised to use [getText9+](#gettext9) instead. **System capability**: SystemCapability.Test.UiTest @@ -3122,7 +3138,7 @@ getType(): Promise\ Obtains the type of this component. -This API is deprecated since API version 9. You are advised to use [getType9+](#gettype9). +This API is deprecated since API version 9. You are advised to use [getType9+](#gettype9) instead. **System capability**: SystemCapability.Test.UiTest @@ -3148,7 +3164,7 @@ isClickable(): Promise\ Obtains the clickable status of this component. -This API is deprecated since API version 9. You are advised to use [isClickable9+](#isclickable9). +This API is deprecated since API version 9. You are advised to use [isClickable9+](#isclickable9) instead. **System capability**: SystemCapability.Test.UiTest @@ -3178,7 +3194,7 @@ isScrollable(): Promise\ Obtains the scrollable status of this component. -This API is deprecated since API version 9. You are advised to use [isScrollable9+](#isscrollable9). +This API is deprecated since API version 9. You are advised to use [isScrollable9+](#isscrollable9) instead. **System capability**: SystemCapability.Test.UiTest @@ -3209,7 +3225,7 @@ isEnabled(): Promise\ Obtains the enabled status of this component. -This API is deprecated since API version 9. You are advised to use [isEnabled9+](#isenabled9). +This API is deprecated since API version 9. You are advised to use [isEnabled9+](#isenabled9) instead. **System capability**: SystemCapability.Test.UiTest @@ -3240,7 +3256,7 @@ isFocused(): Promise\ Obtains the focused status of this component. -This API is deprecated since API version 9. You are advised to use [isFocused9+](#isfocused9). +This API is deprecated since API version 9. You are advised to use [isFocused9+](#isfocused9) instead. **System capability**: SystemCapability.Test.UiTest @@ -3270,7 +3286,7 @@ isSelected(): Promise\ Obtains the selected status of this component. -This API is deprecated since API version 9. You are advised to use [isSelected9+](#isselected9). +This API is deprecated since API version 9. You are advised to use [isSelected9+](#isselected9) instead. **System capability**: SystemCapability.Test.UiTest @@ -3300,7 +3316,7 @@ inputText(text: string): Promise\ Enters text into this component (available for text boxes). -This API is deprecated since API version 9. You are advised to use [inputText9+](#inputtext9). +This API is deprecated since API version 9. You are advised to use [inputText9+](#inputtext9) instead. **System capability**: SystemCapability.Test.UiTest @@ -3326,7 +3342,7 @@ scrollSearch(by: By): Promise\ Scrolls on this component to search for the target component (applicable to components that support scrolling, such as **\**). -This API is deprecated since API version 9. You are advised to use [scrollSearch9+](#scrollsearch9). +This API is deprecated since API version 9. You are advised to use [scrollSearch9+](#scrollsearch9) instead. **System capability**: SystemCapability.Test.UiTest @@ -3365,7 +3381,7 @@ static create(): UiDriver Creates a **UiDriver** object and returns the object created. This API is a static API. -This API is deprecated since API version 9. You are advised to use [create9+](#create9). +This API is deprecated since API version 9. You are advised to use [create9+](#create9) instead. **System capability**: SystemCapability.Test.UiTest @@ -3389,7 +3405,7 @@ delayMs(duration: number): Promise\ Delays this **UiDriver** object within the specified duration. -This API is deprecated since API version 9. You are advised to use [delayMs9+](#delayms9). +This API is deprecated since API version 9. You are advised to use [delayMs9+](#delayms9) instead. **System capability**: SystemCapability.Test.UiTest @@ -3414,7 +3430,7 @@ findComponent(by: By): Promise\ Searches this **UiDriver** object for the target component that matches the given attributes. -This API is deprecated since API version 9. You are advised to use [findComponent9+](#findcomponent9). +This API is deprecated since API version 9. You are advised to use [findComponent9+](#findcomponent9) instead. **System capability**: SystemCapability.Test.UiTest @@ -3445,7 +3461,7 @@ findComponents(by: By): Promise\> Searches this **UiDriver** object for all components that match the given attributes. -This API is deprecated since API version 9. You are advised to use [findComponents9+](#findcomponents9). +This API is deprecated since API version 9. You are advised to use [findComponents9+](#findcomponents9) instead. **System capability**: SystemCapability.Test.UiTest @@ -3476,7 +3492,7 @@ assertComponentExist(by: By): Promise\ Asserts that a component that matches the given attributes exists on the current page. If the component does not exist, the API throws a JS exception, causing the current test case to fail. -This API is deprecated since API version 9. You are advised to use [assertComponentExist9+](#assertcomponentexist9). +This API is deprecated since API version 9. You are advised to use [assertComponentExist9+](#assertcomponentexist9) instead. **System capability**: SystemCapability.Test.UiTest @@ -3501,7 +3517,7 @@ pressBack(): Promise\ Presses the Back button on this **UiDriver** object. -This API is deprecated since API version 9. You are advised to use [pressBack9+](#pressback9). +This API is deprecated since API version 9. You are advised to use [pressBack9+](#pressback9) instead. **System capability**: SystemCapability.Test.UiTest @@ -3520,7 +3536,7 @@ triggerKey(keyCode: number): Promise\ Triggers the key of this **UiDriver** object that matches the given key code. -This API is deprecated since API version 9. You are advised to use [triggerKey9+](#triggerkey9). +This API is deprecated since API version 9. You are advised to use [triggerKey9+](#triggerkey9) instead. **System capability**: SystemCapability.Test.UiTest @@ -3546,7 +3562,7 @@ click(x: number, y: number): Promise\ Clicks a specific point of this **UiDriver** object based on the given coordinates. -This API is deprecated since API version 9. You are advised to use [click9+](#click9). +This API is deprecated since API version 9. You are advised to use [click9+](#click9) instead. **System capability**: SystemCapability.Test.UiTest @@ -3572,7 +3588,7 @@ doubleClick(x: number, y: number): Promise\ Double-clicks a specific point of this **UiDriver** object based on the given coordinates. -This API is deprecated since API version 9. You are advised to use [doubleClick9+](#doubleclick9). +This API is deprecated since API version 9. You are advised to use [doubleClick9+](#doubleclick9) instead. **System capability**: SystemCapability.Test.UiTest @@ -3598,7 +3614,7 @@ longClick(x: number, y: number): Promise\ Long-clicks a specific point of this **UiDriver** object based on the given coordinates. -This API is deprecated since API version 9. You are advised to use [longClick9+](#longclick9). +This API is deprecated since API version 9. You are advised to use [longClick9+](#longclick9) instead. **System capability**: SystemCapability.Test.UiTest @@ -3624,7 +3640,7 @@ swipe(startx: number, starty: number, endx: number, endy: number): Promise\9+](#swipe9). +This API is deprecated since API version 9. You are advised to use [swipe9+](#swipe9) instead. **System capability**: SystemCapability.Test.UiTest @@ -3652,7 +3668,7 @@ screenCap(savePath: string): Promise\ Captures the current screen of this **UiDriver** object and saves it as a PNG image to the given save path. -This API is deprecated since API version 9. You are advised to use [screenCap9+](#screencap9). +This API is deprecated since API version 9. You are advised to use [screenCap9+](#screencap9) instead. **System capability**: SystemCapability.Test.UiTest diff --git a/en/application-dev/reference/apis/js-apis-zlib.md b/en/application-dev/reference/apis/js-apis-zlib.md index 454cca88f82548b86ba2a9b4209c1782cc0eaa8f..6515eea99d43d68018a46c56b79bd38754d7864a 100644 --- a/en/application-dev/reference/apis/js-apis-zlib.md +++ b/en/application-dev/reference/apis/js-apis-zlib.md @@ -231,7 +231,7 @@ Decompresses a file. This API uses an asynchronous callback to return the result | Name | Type | Mandatory| Description | | ----------------------- | ------------------- | ---- | ------------------------------------------------------------ | -| inFile | string | Yes | Path of the file to decompress. For details about the path, see [FA Model](js-apis-inner-app-context.md) and [Stage Model](js-apis-inner-application-context.md).| +| inFile | string | Yes | Path of the file to decompress. The file name extension must be .zip. For details about the path, see [FA Model](js-apis-inner-app-context.md) and [Stage Model](js-apis-inner-application-context.md).| | outFile | string | Yes | Path of the decompressed file. The path must exist in the system. Otherwise, the decompression fails. The path must be an application sandbox path, which can be obtained from the context. For details about the context, see [FA Model](js-apis-inner-app-context.md) and [Stage Model](js-apis-inner-application-context.md).| | options | [Options](#options) | Yes | Decompression parameters. | | AsyncCallback<**void**> | callback | No | Callback used to return the result. If the operation is successful, **null** is returned; otherwise, a specific error code is returned. | @@ -282,7 +282,7 @@ Decompresses a file. This API uses a promise to return the result. | Name | Type | Mandatory| Description | | ------- | ------------------- | ---- | ------------------------------------------------------------ | -| inFile | string | Yes | Path of the file to decompress. For details about the path, see [FA Model](js-apis-inner-app-context.md) and [Stage Model](js-apis-inner-application-context.md).| +| inFile | string | Yes | Path of the file to decompress. The file name extension must be .zip. For details about the path, see [FA Model](js-apis-inner-app-context.md) and [Stage Model](js-apis-inner-application-context.md).| | outFile | string | Yes | Path of the decompressed file. The path must exist in the system. Otherwise, the decompression fails. The path must be an application sandbox path, which can be obtained from the context. For details about the context, see [FA Model](js-apis-inner-app-context.md) and [Stage Model](js-apis-inner-application-context.md).| | options | [Options](#options) | Yes | Decompression parameters. | diff --git a/en/application-dev/reference/arkui-js-lite/Readme-EN.md b/en/application-dev/reference/arkui-js-lite/Readme-EN.md new file mode 100644 index 0000000000000000000000000000000000000000..4dbc7b08dbed8356f7cb907c3dbebff5c5b09bf5 --- /dev/null +++ b/en/application-dev/reference/arkui-js-lite/Readme-EN.md @@ -0,0 +1,37 @@ +# JavaScript-compatible Web-like Development Paradigm (ArkUI.Lite) + +- Framework Overview + - [File Organization](js-framework-file.md) + - ["js" Tag](js-framework-js-tag.md) + - [app.js](js-framework-js-file.md) + - Syntax + - [HML](js-framework-syntax-hml.md) + - [CSS](js-framework-syntax-css.md) + - [JavaScript](js-framework-syntax-js.md) +- Universal Component Information + - [Universal Events](js-common-events.md) + - [Universal Attributes](js-common-attributes.md) + - [Universal Styles](js-common-styles.md) + - [Animation Styles](js-components-common-animation.md) + - [Media Query](js-components-common-mediaquery.md) +- Container Components + - [div](js-components-container-div.md) + - [list](js-components-container-list.md) + - [list-item](js-components-container-list-item.md) + - [stack](js-components-container-stack.md) + - [swiper](js-components-container-swiper.md) +- Basic Components + - [chart](js-components-basic-chart.md) + - [image](js-components-basic-image.md) + - [image-animator](js-components-basic-image-animator.md) + - [input](js-components-basic-input.md) + - [marquee](js-components-basic-marquee.md) + - [picker-view](js-components-basic-picker-view.md) + - [progress](js-components-basic-progress.md) + - [qrcode](js-components-basic-qrcode.md) + - [slider](js-components-basic-slider.md) + - [switch](js-components-basic-switch.md) + - [text](js-components-basic-text.md) +- Canvas Components + - [canvas](js-components-canvas-canvas.md) + - [CanvasRenderingContext2D](js-components-canvas-canvasrenderingcontext2d.md) diff --git a/en/application-dev/reference/arkui-js-lite/figures/000000.png b/en/application-dev/reference/arkui-js-lite/figures/000000.png new file mode 100644 index 0000000000000000000000000000000000000000..58293d5e874f2aa36ecaf7282ca9e4736318092f Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/000000.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/GIF.gif b/en/application-dev/reference/arkui-js-lite/figures/GIF.gif new file mode 100644 index 0000000000000000000000000000000000000000..fa77bb91654623c2de68a19e7f9f95bbd1d029bc Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/GIF.gif differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/aliceblue.png b/en/application-dev/reference/arkui-js-lite/figures/aliceblue.png new file mode 100644 index 0000000000000000000000000000000000000000..378000d344e90ab4db41869a4612daf6b60d66ab Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/aliceblue.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/animation-demo1.gif b/en/application-dev/reference/arkui-js-lite/figures/animation-demo1.gif new file mode 100644 index 0000000000000000000000000000000000000000..fc1eadbb05520daa6d79779683db96d0afe7cbdd Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/animation-demo1.gif differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/animation-demo2.gif b/en/application-dev/reference/arkui-js-lite/figures/animation-demo2.gif new file mode 100644 index 0000000000000000000000000000000000000000..c3d337edf8e35352dcc9d9b9919019e1f7ec4d96 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/animation-demo2.gif differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/antiquewhite.png b/en/application-dev/reference/arkui-js-lite/figures/antiquewhite.png new file mode 100644 index 0000000000000000000000000000000000000000..8e195633945b3387c46a7d295862351d4ff1fc64 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/antiquewhite.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/aqua.png b/en/application-dev/reference/arkui-js-lite/figures/aqua.png new file mode 100644 index 0000000000000000000000000000000000000000..3e6aaacfe1c26157294e6dedfeaa1488aeed12a3 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/aqua.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/aquamarine.png b/en/application-dev/reference/arkui-js-lite/figures/aquamarine.png new file mode 100644 index 0000000000000000000000000000000000000000..c25a692065d473ccf9f5b6d36254787e2497fad6 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/aquamarine.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/azure.png b/en/application-dev/reference/arkui-js-lite/figures/azure.png new file mode 100644 index 0000000000000000000000000000000000000000..2e7cec00f9d186d76ff5cb12d47811084217cc1c Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/azure.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/barchart.PNG b/en/application-dev/reference/arkui-js-lite/figures/barchart.PNG new file mode 100644 index 0000000000000000000000000000000000000000..aa4ba3f9fa64250b1b86bd6d39b6a8071d3de1c3 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/barchart.PNG differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/beige.png b/en/application-dev/reference/arkui-js-lite/figures/beige.png new file mode 100644 index 0000000000000000000000000000000000000000..21f20a4220aabf9449c707291633e7b3723fe378 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/beige.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/bisque.png b/en/application-dev/reference/arkui-js-lite/figures/bisque.png new file mode 100644 index 0000000000000000000000000000000000000000..7983d590a2c617c6cad68c90af6b12aa17518810 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/bisque.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/blanchedalmond.png b/en/application-dev/reference/arkui-js-lite/figures/blanchedalmond.png new file mode 100644 index 0000000000000000000000000000000000000000..04bcf099edface801be6074a33ff33a980c9b606 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/blanchedalmond.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/blue.png b/en/application-dev/reference/arkui-js-lite/figures/blue.png new file mode 100644 index 0000000000000000000000000000000000000000..e370a44cf043fc34bd8891f57faad2cd2ca05707 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/blue.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/blueviolet.png b/en/application-dev/reference/arkui-js-lite/figures/blueviolet.png new file mode 100644 index 0000000000000000000000000000000000000000..ca1edf2219980ab9c8533b9fda3219521c50533d Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/blueviolet.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/brown.png b/en/application-dev/reference/arkui-js-lite/figures/brown.png new file mode 100644 index 0000000000000000000000000000000000000000..0d22570503febc7a7dcba0d1e870f49f32fe489a Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/brown.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/burlywood.png b/en/application-dev/reference/arkui-js-lite/figures/burlywood.png new file mode 100644 index 0000000000000000000000000000000000000000..0d53a47b7eace81d5c7da88c59fee61e30c89681 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/burlywood.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/cadetblue.png b/en/application-dev/reference/arkui-js-lite/figures/cadetblue.png new file mode 100644 index 0000000000000000000000000000000000000000..a59bc9cdb0f75ad79e4714d3593216021369c862 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/cadetblue.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/chartreuse.png b/en/application-dev/reference/arkui-js-lite/figures/chartreuse.png new file mode 100644 index 0000000000000000000000000000000000000000..3026d3c195598159232b4b1f08e9f198f4b4fa2c Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/chartreuse.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/chocolate.png b/en/application-dev/reference/arkui-js-lite/figures/chocolate.png new file mode 100644 index 0000000000000000000000000000000000000000..02d5f4e31b020ea9f64e36a7b7cd50299cf3d7f2 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/chocolate.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/coral.png b/en/application-dev/reference/arkui-js-lite/figures/coral.png new file mode 100644 index 0000000000000000000000000000000000000000..8442c9b2258c79ee6b6a3d5963df5b792bbb1a16 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/coral.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/cornflowerblue.png b/en/application-dev/reference/arkui-js-lite/figures/cornflowerblue.png new file mode 100644 index 0000000000000000000000000000000000000000..3621ef6876dbd1103487aed8ff190e6a0204ffde Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/cornflowerblue.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/cornsilk.png b/en/application-dev/reference/arkui-js-lite/figures/cornsilk.png new file mode 100644 index 0000000000000000000000000000000000000000..bf38fe45eaf254939b88b9d2a66635408060acf7 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/cornsilk.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/crimson.png b/en/application-dev/reference/arkui-js-lite/figures/crimson.png new file mode 100644 index 0000000000000000000000000000000000000000..bca655617699ef8dc1265bf692a3170c7effe15b Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/crimson.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/cyan.png b/en/application-dev/reference/arkui-js-lite/figures/cyan.png new file mode 100644 index 0000000000000000000000000000000000000000..3e6aaacfe1c26157294e6dedfeaa1488aeed12a3 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/cyan.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/darkblue.png b/en/application-dev/reference/arkui-js-lite/figures/darkblue.png new file mode 100644 index 0000000000000000000000000000000000000000..b234a769d1a9f1f30c4d2127160cf067e9f71ad6 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/darkblue.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/darkcyan.png b/en/application-dev/reference/arkui-js-lite/figures/darkcyan.png new file mode 100644 index 0000000000000000000000000000000000000000..b780eb08852e8916ec6ff1a401ea6946c8d727cf Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/darkcyan.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/darkgoldenrod.png b/en/application-dev/reference/arkui-js-lite/figures/darkgoldenrod.png new file mode 100644 index 0000000000000000000000000000000000000000..26f2f228b47b8acb8adcddc3abf9156d6c29364e Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/darkgoldenrod.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/darkgray.png b/en/application-dev/reference/arkui-js-lite/figures/darkgray.png new file mode 100644 index 0000000000000000000000000000000000000000..f1abe2afcb7902557ac3c4f58abfdf333af03121 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/darkgray.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/darkgreen.png b/en/application-dev/reference/arkui-js-lite/figures/darkgreen.png new file mode 100644 index 0000000000000000000000000000000000000000..4c4c304b67c398f32c5fff516cdde377ca39c73d Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/darkgreen.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/darkgrey.png b/en/application-dev/reference/arkui-js-lite/figures/darkgrey.png new file mode 100644 index 0000000000000000000000000000000000000000..f1abe2afcb7902557ac3c4f58abfdf333af03121 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/darkgrey.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/darkkhaki.png b/en/application-dev/reference/arkui-js-lite/figures/darkkhaki.png new file mode 100644 index 0000000000000000000000000000000000000000..12085848c0f6472d53f7e6504c1924ea6f5a44c1 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/darkkhaki.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/darkmagenta.png b/en/application-dev/reference/arkui-js-lite/figures/darkmagenta.png new file mode 100644 index 0000000000000000000000000000000000000000..9ed54c6c5c5186fb43f24dab24f7689ae0d14a12 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/darkmagenta.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/darkolivegreen.png b/en/application-dev/reference/arkui-js-lite/figures/darkolivegreen.png new file mode 100644 index 0000000000000000000000000000000000000000..53081e06f458cfc1772de30f669180333b8d783d Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/darkolivegreen.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/darkorange.png b/en/application-dev/reference/arkui-js-lite/figures/darkorange.png new file mode 100644 index 0000000000000000000000000000000000000000..6064f64867e3aca621244e1e6fdb16d3ab2ed748 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/darkorange.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/darkorchid.png b/en/application-dev/reference/arkui-js-lite/figures/darkorchid.png new file mode 100644 index 0000000000000000000000000000000000000000..6315d4654d04dd6b9b295fa1f8b37e8c550b17cf Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/darkorchid.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/darkred.png b/en/application-dev/reference/arkui-js-lite/figures/darkred.png new file mode 100644 index 0000000000000000000000000000000000000000..c33d763d18f5108bf0eedba19c662d05af397ee9 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/darkred.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/darksalmon.png b/en/application-dev/reference/arkui-js-lite/figures/darksalmon.png new file mode 100644 index 0000000000000000000000000000000000000000..57594c6855d4cdf1b37cc3e5354374c9dae0823b Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/darksalmon.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/darkseagreen.png b/en/application-dev/reference/arkui-js-lite/figures/darkseagreen.png new file mode 100644 index 0000000000000000000000000000000000000000..454b1796715794d51e2a1a4649bfafa1bfde80f0 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/darkseagreen.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/darkslateblue.png b/en/application-dev/reference/arkui-js-lite/figures/darkslateblue.png new file mode 100644 index 0000000000000000000000000000000000000000..7dfc7ee8793298d19c939369ba980abd547982ff Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/darkslateblue.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/darkslategray.png b/en/application-dev/reference/arkui-js-lite/figures/darkslategray.png new file mode 100644 index 0000000000000000000000000000000000000000..5e23c304c4911dc0ef487dfeb8d7820aea5fb44b Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/darkslategray.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/darkslategrey.png b/en/application-dev/reference/arkui-js-lite/figures/darkslategrey.png new file mode 100644 index 0000000000000000000000000000000000000000..5e23c304c4911dc0ef487dfeb8d7820aea5fb44b Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/darkslategrey.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/darkturquoise.png b/en/application-dev/reference/arkui-js-lite/figures/darkturquoise.png new file mode 100644 index 0000000000000000000000000000000000000000..4e41450db5d70f6d10d6d7bf59daba33085c177e Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/darkturquoise.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/darkviolet.png b/en/application-dev/reference/arkui-js-lite/figures/darkviolet.png new file mode 100644 index 0000000000000000000000000000000000000000..6f085565bd8c64d44bf58ce0969557515ec7ab97 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/darkviolet.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/deeppink.png b/en/application-dev/reference/arkui-js-lite/figures/deeppink.png new file mode 100644 index 0000000000000000000000000000000000000000..6348bb2b6ee281976f7d58159e4c33db29f542ad Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/deeppink.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/deepskyblue.png b/en/application-dev/reference/arkui-js-lite/figures/deepskyblue.png new file mode 100644 index 0000000000000000000000000000000000000000..0ac129028e67b43fcae8e3d5c1a539cc45ba6d21 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/deepskyblue.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/default.PNG b/en/application-dev/reference/arkui-js-lite/figures/default.PNG new file mode 100644 index 0000000000000000000000000000000000000000..5e4322d20ad887573ad85958bc181a1be0f85f1c Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/default.PNG differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/dimgray.png b/en/application-dev/reference/arkui-js-lite/figures/dimgray.png new file mode 100644 index 0000000000000000000000000000000000000000..1072a50f468dda3c90c889c31424b7c290eb1a13 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/dimgray.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/dimgrey.png b/en/application-dev/reference/arkui-js-lite/figures/dimgrey.png new file mode 100644 index 0000000000000000000000000000000000000000..1072a50f468dda3c90c889c31424b7c290eb1a13 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/dimgrey.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/dodgerblue.png b/en/application-dev/reference/arkui-js-lite/figures/dodgerblue.png new file mode 100644 index 0000000000000000000000000000000000000000..fe422eecde9ec9f1fcac762bd81a23b3fa3abde7 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/dodgerblue.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/ellipse.PNG b/en/application-dev/reference/arkui-js-lite/figures/ellipse.PNG new file mode 100644 index 0000000000000000000000000000000000000000..d0379dfc66b4d2151dae49beeb8af38c774381aa Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/ellipse.PNG differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001380789168.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001380789168.png new file mode 100644 index 0000000000000000000000000000000000000000..4481b08ab897619b408425f9bfe0fd5b1fcb6ef0 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001380789168.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001380789172.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001380789172.png new file mode 100644 index 0000000000000000000000000000000000000000..9a73bd33782f06a704ed9b288226dfa381d1d57c Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001380789172.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001380789180.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001380789180.png new file mode 100644 index 0000000000000000000000000000000000000000..6e58c669a2976297f71d35c304e988c2884e7dc0 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001380789180.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001380789184.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001380789184.png new file mode 100644 index 0000000000000000000000000000000000000000..5113bc6bad4f88bc2558aae304394e00e107ce88 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001380789184.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001380789188.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001380789188.png new file mode 100644 index 0000000000000000000000000000000000000000..4d0696a9ade017acbbdfb8812dafdec5d715cac5 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001380789188.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001380789296.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001380789296.png new file mode 100644 index 0000000000000000000000000000000000000000..f627659cef03f443e01fb28b44ceb9363369b8d8 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001380789296.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001380948700.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001380948700.png new file mode 100644 index 0000000000000000000000000000000000000000..8f6b4abcc27039c624bd21aad775db7c47a22dea Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001380948700.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001380948704.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001380948704.png new file mode 100644 index 0000000000000000000000000000000000000000..151ef990edbb33e1f54632609990f6c540149a5e Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001380948704.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001380948708.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001380948708.png new file mode 100644 index 0000000000000000000000000000000000000000..e061801d6eeb27d7fee0b287414e512559a87ea9 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001380948708.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001380948712.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001380948712.png new file mode 100644 index 0000000000000000000000000000000000000000..56c65edbcd66a2ebe9d8ef35c55eba90652bca0f Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001380948712.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001380948716.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001380948716.png new file mode 100644 index 0000000000000000000000000000000000000000..db54e678d8c42daca3e56dd85567c9978a9657c8 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001380948716.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001380948720.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001380948720.png new file mode 100644 index 0000000000000000000000000000000000000000..f59a10b44b9e9793bc3a9134f6c4633c8cfb49ce Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001380948720.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001380948828.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001380948828.png new file mode 100644 index 0000000000000000000000000000000000000000..f304daf1f80c86ca6f415e4f7a49b17ca20dae04 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001380948828.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001381108312.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001381108312.png new file mode 100644 index 0000000000000000000000000000000000000000..3917378fdcb47448e7daf8ae197e6d033fd345e9 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001381108312.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001381108316.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001381108316.png new file mode 100644 index 0000000000000000000000000000000000000000..4c8300af3bdf43e4d2192699b5ed4065fef451c0 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001381108316.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001381108320.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001381108320.png new file mode 100644 index 0000000000000000000000000000000000000000..3404b29dff12b910ae1be71ebf762252895468a8 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001381108320.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001381108324.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001381108324.png new file mode 100644 index 0000000000000000000000000000000000000000..dfee4f8cddcddd2ada89cb6d7e812fd0739d9cb8 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001381108324.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001381108328.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001381108328.png new file mode 100644 index 0000000000000000000000000000000000000000..33787429dd3205f9faac254950e95c097bd63b21 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001381108328.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001381108332.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001381108332.png new file mode 100644 index 0000000000000000000000000000000000000000..67959174e9b810b9278a7940bc097ac0c0738c7e Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001381108332.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001381108420.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001381108420.png new file mode 100644 index 0000000000000000000000000000000000000000..3ecdf0c714fa633f03db339626f51e62318cbf82 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001381108420.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001381108436.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001381108436.png new file mode 100644 index 0000000000000000000000000000000000000000..f6288a0361793fbbce554fd293831fae4bcefc9d Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001381108436.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001381268264.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001381268264.png new file mode 100644 index 0000000000000000000000000000000000000000..0c8973bcb7d55910c6702fe6b9b54506ad3b3727 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001381268264.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001381268268.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001381268268.png new file mode 100644 index 0000000000000000000000000000000000000000..3cc02a6196604a6a3d64b9961c04aaaa51dc829e Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001381268268.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001381268272.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001381268272.png new file mode 100644 index 0000000000000000000000000000000000000000..658dca4b52032016c15f77a94b3ef76c093b1d2c Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001381268272.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001381268276.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001381268276.png new file mode 100644 index 0000000000000000000000000000000000000000..8192453ec25d486b3923da4a25b0a6fe5034d869 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001381268276.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001381268280.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001381268280.png new file mode 100644 index 0000000000000000000000000000000000000000..2f786e33181995c2b5bf5f835df4557ff3f7e9b4 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001381268280.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001381268284.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001381268284.png new file mode 100644 index 0000000000000000000000000000000000000000..9ac4a39e925322831752617b71a77d040626d251 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001381268284.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001381268388.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001381268388.png new file mode 100644 index 0000000000000000000000000000000000000000..366ab30f3e3f9f4b7e8b579b06cd84a76b2bfabc Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001381268388.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431148353.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431148353.png new file mode 100644 index 0000000000000000000000000000000000000000..e89a1b24da145cf480cceb28ed7249b717e614bf Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431148353.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431148357.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431148357.png new file mode 100644 index 0000000000000000000000000000000000000000..68562c1006ec7c61c49c24aec99ecfd173ca055a Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431148357.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431148361.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431148361.png new file mode 100644 index 0000000000000000000000000000000000000000..bd4f47314f89fa4bbbd2d14527dd250b5e3e141b Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431148361.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431148365.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431148365.png new file mode 100644 index 0000000000000000000000000000000000000000..42efd9018bc05408596a768cbbe309f1e46273d7 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431148365.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431148369.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431148369.png new file mode 100644 index 0000000000000000000000000000000000000000..3108e0436219c1c3a7335679cdfea962c49f454d Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431148369.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431148457.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431148457.png new file mode 100644 index 0000000000000000000000000000000000000000..91c55d3677922b76ac78c4e56c87ef90b5b31fc2 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431148457.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431308057.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431308057.png new file mode 100644 index 0000000000000000000000000000000000000000..cc1dc87c79f827c8bb5be3f3771c37f4cb8b214e Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431308057.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431308061.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431308061.png new file mode 100644 index 0000000000000000000000000000000000000000..1362b8a3d98f4edf36420d3799f01476817e43d4 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431308061.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431308065.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431308065.png new file mode 100644 index 0000000000000000000000000000000000000000..2f9a8bacc0f78cb141820e8188d4ae5ef03dc7c1 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431308065.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431308073.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431308073.png new file mode 100644 index 0000000000000000000000000000000000000000..44ae627d6e40dd4b297eccdcf1c5dceef5a08d82 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431308073.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431308077.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431308077.png new file mode 100644 index 0000000000000000000000000000000000000000..f4e18dbe51e815ccdfc6f594e3424850c3b93a12 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431308077.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431308169.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431308169.png new file mode 100644 index 0000000000000000000000000000000000000000..612bc55f4aa5e832133801edf61cef01ffd1bc64 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431308169.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431308185.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431308185.png new file mode 100644 index 0000000000000000000000000000000000000000..3dccd46b21e76a7bbbaabc1ab77a29bd72ae850d Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431308185.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431388505.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431388505.png new file mode 100644 index 0000000000000000000000000000000000000000..47f90714bcb37e4df1b698503db6893d6c2a98c4 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431388505.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431388513.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431388513.png new file mode 100644 index 0000000000000000000000000000000000000000..072d846a3cd629316cd0dcf25d5e9e1e1d3e0dc4 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431388513.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431388517.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431388517.png new file mode 100644 index 0000000000000000000000000000000000000000..5b526bdf7cd539297715bbcddbbd505b7c683695 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431388517.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431388521.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431388521.png new file mode 100644 index 0000000000000000000000000000000000000000..1d5aedb22cb51d00b176f44c5ac5f3ad29d843f2 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431388521.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431388525.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431388525.png new file mode 100644 index 0000000000000000000000000000000000000000..1d71cee4618f1f2822cea1031c9b0e5d602e0a9b Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431388525.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431388529.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431388529.png new file mode 100644 index 0000000000000000000000000000000000000000..8253c65764c8d74e0a25404aa62fdd69d43f3c26 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431388529.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431388581.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431388581.png new file mode 100644 index 0000000000000000000000000000000000000000..bf5ef1c99e764de0e3a0fb0d5e68dc7722f1c0aa Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431388581.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431388637.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431388637.png new file mode 100644 index 0000000000000000000000000000000000000000..f9db5c31c8eae66244cd3f6e11336f72284bb2a6 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431388637.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431548105.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431548105.png new file mode 100644 index 0000000000000000000000000000000000000000..5da42e3e14d601745274cb62d914c6600620bb25 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431548105.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431548109.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431548109.png new file mode 100644 index 0000000000000000000000000000000000000000..63b480df9e9700601da85abef015c8326095851f Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431548109.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431548113.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431548113.png new file mode 100644 index 0000000000000000000000000000000000000000..63f343e89f62b15c117e0148c87ac049308c3117 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431548113.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431548117.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431548117.png new file mode 100644 index 0000000000000000000000000000000000000000..6afdd1b39e4bcb3664c7664a55b47b8537f4aeaa Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431548117.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431548121.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431548121.png new file mode 100644 index 0000000000000000000000000000000000000000..d6bbab16659f4b34b38a714510665ea7fd309055 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431548121.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431548125.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431548125.png new file mode 100644 index 0000000000000000000000000000000000000000..fea0122d3ef81899a02199c6cb265a099ad6c44f Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431548125.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431548233.png b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431548233.png new file mode 100644 index 0000000000000000000000000000000000000000..4cef59797fd8b9650c398562ac0b473485a9274b Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/en-us_image_0000001431548233.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/firebrick.png b/en/application-dev/reference/arkui-js-lite/figures/firebrick.png new file mode 100644 index 0000000000000000000000000000000000000000..af32ecea68c1cef693bcfa379af5ac28f66c1e14 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/firebrick.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/floralwhite.png b/en/application-dev/reference/arkui-js-lite/figures/floralwhite.png new file mode 100644 index 0000000000000000000000000000000000000000..5ee9f7e893611dce988b8aa7ccfe3fab4b9d912f Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/floralwhite.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/forestgreen.png b/en/application-dev/reference/arkui-js-lite/figures/forestgreen.png new file mode 100644 index 0000000000000000000000000000000000000000..7cfd4846ca697424582edbfed23ed93ef9e98138 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/forestgreen.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/fuchsia.png b/en/application-dev/reference/arkui-js-lite/figures/fuchsia.png new file mode 100644 index 0000000000000000000000000000000000000000..6823cbc9203b07abae455b4ee5c7692878c4be72 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/fuchsia.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/gainsboro.png b/en/application-dev/reference/arkui-js-lite/figures/gainsboro.png new file mode 100644 index 0000000000000000000000000000000000000000..d1d37504e15eb6fccd6b1c8e985d37fcc8ba9875 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/gainsboro.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/gauge.PNG b/en/application-dev/reference/arkui-js-lite/figures/gauge.PNG new file mode 100644 index 0000000000000000000000000000000000000000..31c0141d716059519377e1f39b9b8305370f239a Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/gauge.PNG differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/ghostwhite.png b/en/application-dev/reference/arkui-js-lite/figures/ghostwhite.png new file mode 100644 index 0000000000000000000000000000000000000000..45467f3e6fc0866b6da0521911bdb5e7d740df29 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/ghostwhite.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/gold.png b/en/application-dev/reference/arkui-js-lite/figures/gold.png new file mode 100644 index 0000000000000000000000000000000000000000..91a276a7dffb4d98c507e9af6afa1912cca1fed2 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/gold.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/goldenrod.png b/en/application-dev/reference/arkui-js-lite/figures/goldenrod.png new file mode 100644 index 0000000000000000000000000000000000000000..04ab7decab16cb7341665c2a67e8d5655a7eed6a Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/goldenrod.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/gray.png b/en/application-dev/reference/arkui-js-lite/figures/gray.png new file mode 100644 index 0000000000000000000000000000000000000000..dfcb0c5e259b3f8d7375c21712249c1e847edd67 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/gray.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/green.png b/en/application-dev/reference/arkui-js-lite/figures/green.png new file mode 100644 index 0000000000000000000000000000000000000000..bc28f5056c679e189543c8ad6fba67fb56db7655 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/green.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/greenyellow.png b/en/application-dev/reference/arkui-js-lite/figures/greenyellow.png new file mode 100644 index 0000000000000000000000000000000000000000..c89f746719790333bce2bde8c5b8d86102fdfc33 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/greenyellow.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/grey.png b/en/application-dev/reference/arkui-js-lite/figures/grey.png new file mode 100644 index 0000000000000000000000000000000000000000..dfcb0c5e259b3f8d7375c21712249c1e847edd67 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/grey.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/honeydew.png b/en/application-dev/reference/arkui-js-lite/figures/honeydew.png new file mode 100644 index 0000000000000000000000000000000000000000..51fb00e10bb5c167506ddfae1689b58e368df340 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/honeydew.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/hotpink.png b/en/application-dev/reference/arkui-js-lite/figures/hotpink.png new file mode 100644 index 0000000000000000000000000000000000000000..cbc1d312680f479e8c443476ea39eaf1e8a16e55 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/hotpink.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/image-animator.gif b/en/application-dev/reference/arkui-js-lite/figures/image-animator.gif new file mode 100644 index 0000000000000000000000000000000000000000..8321366bdb79b9e6530d53b0f45a6465ae7b967d Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/image-animator.gif differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/image.png b/en/application-dev/reference/arkui-js-lite/figures/image.png new file mode 100644 index 0000000000000000000000000000000000000000..79db22cd94523a8854562e4c8b45ee22d8b45e90 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/image.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/indianred.png b/en/application-dev/reference/arkui-js-lite/figures/indianred.png new file mode 100644 index 0000000000000000000000000000000000000000..069f570291be858a1768b75719a4a6adbd1bdef8 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/indianred.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/indigo.png b/en/application-dev/reference/arkui-js-lite/figures/indigo.png new file mode 100644 index 0000000000000000000000000000000000000000..db83d39f98583ee653ee39b0237eb55961e539c7 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/indigo.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/input-type-button.png b/en/application-dev/reference/arkui-js-lite/figures/input-type-button.png new file mode 100644 index 0000000000000000000000000000000000000000..247fed609d862aa73184f3428486ab62e82bf897 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/input-type-button.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/input-type-checkbox.gif b/en/application-dev/reference/arkui-js-lite/figures/input-type-checkbox.gif new file mode 100644 index 0000000000000000000000000000000000000000..2215e5cfa56f533c6b4d1318b2fa1fb07093dfaa Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/input-type-checkbox.gif differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/input-type-radio.gif b/en/application-dev/reference/arkui-js-lite/figures/input-type-radio.gif new file mode 100644 index 0000000000000000000000000000000000000000..bd5fea51c64deb1268793f3a3f70a2c379aebfda Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/input-type-radio.gif differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/ivory.png b/en/application-dev/reference/arkui-js-lite/figures/ivory.png new file mode 100644 index 0000000000000000000000000000000000000000..ff0aa71de78cb461a6602398ee915c677efdf3d4 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/ivory.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/khaki.png b/en/application-dev/reference/arkui-js-lite/figures/khaki.png new file mode 100644 index 0000000000000000000000000000000000000000..3fca22c329e9dc9ef73eee20757eac4ce7386842 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/khaki.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/lavender.png b/en/application-dev/reference/arkui-js-lite/figures/lavender.png new file mode 100644 index 0000000000000000000000000000000000000000..44e4d991524bd0ef88a0dd10f204e022dd9d0621 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/lavender.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/lavenderblush.png b/en/application-dev/reference/arkui-js-lite/figures/lavenderblush.png new file mode 100644 index 0000000000000000000000000000000000000000..5b22707e37ec772dc08a961e557a937862210167 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/lavenderblush.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/lawngreen.png b/en/application-dev/reference/arkui-js-lite/figures/lawngreen.png new file mode 100644 index 0000000000000000000000000000000000000000..41be1a646e14511b5d177d11a7bce10deaee5bc9 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/lawngreen.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/lemonchiffon.png b/en/application-dev/reference/arkui-js-lite/figures/lemonchiffon.png new file mode 100644 index 0000000000000000000000000000000000000000..d77ed21418dc3035feb9f9c8e15815e577d71a90 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/lemonchiffon.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/lightblue.png b/en/application-dev/reference/arkui-js-lite/figures/lightblue.png new file mode 100644 index 0000000000000000000000000000000000000000..7cc96f8f6364b93923f0a88b895fe6b151080932 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/lightblue.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/lightcoral.png b/en/application-dev/reference/arkui-js-lite/figures/lightcoral.png new file mode 100644 index 0000000000000000000000000000000000000000..515185ab1b3cf9aaba1204760dae19ab3c112b42 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/lightcoral.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/lightcyan.png b/en/application-dev/reference/arkui-js-lite/figures/lightcyan.png new file mode 100644 index 0000000000000000000000000000000000000000..6f929d8ab35b708978d8053047cb56bec4fa83bc Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/lightcyan.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/lightgoldenrodyellow.png b/en/application-dev/reference/arkui-js-lite/figures/lightgoldenrodyellow.png new file mode 100644 index 0000000000000000000000000000000000000000..1b0ed50716d897398c1e9a741e08ff5f1b9fd9de Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/lightgoldenrodyellow.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/lightgray.png b/en/application-dev/reference/arkui-js-lite/figures/lightgray.png new file mode 100644 index 0000000000000000000000000000000000000000..0a5eb251a8d731dc6a9d8b1f31f904c42fd372c3 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/lightgray.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/lightgreen.png b/en/application-dev/reference/arkui-js-lite/figures/lightgreen.png new file mode 100644 index 0000000000000000000000000000000000000000..f89943fc98661a6d2b78b5659c41483308a0c54b Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/lightgreen.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/lightpink.png b/en/application-dev/reference/arkui-js-lite/figures/lightpink.png new file mode 100644 index 0000000000000000000000000000000000000000..6eb2d41877c85cccfb918b042bc13c81c58ec191 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/lightpink.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/lightsalmon.png b/en/application-dev/reference/arkui-js-lite/figures/lightsalmon.png new file mode 100644 index 0000000000000000000000000000000000000000..d87462d1cdc9410e91ee050a53d58e71d1c5f312 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/lightsalmon.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/lightseagreen.png b/en/application-dev/reference/arkui-js-lite/figures/lightseagreen.png new file mode 100644 index 0000000000000000000000000000000000000000..e863d7a1c3b9c1ca08bd182dce43c55a4866d59b Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/lightseagreen.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/lightskyblue.png b/en/application-dev/reference/arkui-js-lite/figures/lightskyblue.png new file mode 100644 index 0000000000000000000000000000000000000000..daa035cea33b810571c18de67e4ac887eeb11850 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/lightskyblue.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/lightslategray.png b/en/application-dev/reference/arkui-js-lite/figures/lightslategray.png new file mode 100644 index 0000000000000000000000000000000000000000..2dadb92ce56793e2dd693bfa7d99b0c1168130dc Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/lightslategray.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/lightslategrey.png b/en/application-dev/reference/arkui-js-lite/figures/lightslategrey.png new file mode 100644 index 0000000000000000000000000000000000000000..2dadb92ce56793e2dd693bfa7d99b0c1168130dc Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/lightslategrey.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/lightsteelblue.png b/en/application-dev/reference/arkui-js-lite/figures/lightsteelblue.png new file mode 100644 index 0000000000000000000000000000000000000000..ac0521001d2513fd69e48ce61e1d1128b9d3a6dd Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/lightsteelblue.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/lightyellow.png b/en/application-dev/reference/arkui-js-lite/figures/lightyellow.png new file mode 100644 index 0000000000000000000000000000000000000000..d1ca7dd07fe7812ec1f87bf748595174569a5672 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/lightyellow.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/lime.png b/en/application-dev/reference/arkui-js-lite/figures/lime.png new file mode 100644 index 0000000000000000000000000000000000000000..481c833482d38c5f564127c8f412fe3c0275fd24 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/lime.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/limegreen.png b/en/application-dev/reference/arkui-js-lite/figures/limegreen.png new file mode 100644 index 0000000000000000000000000000000000000000..63a8c6adc29d340634ed06a1006a0fb56c991a9d Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/limegreen.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/linen.png b/en/application-dev/reference/arkui-js-lite/figures/linen.png new file mode 100644 index 0000000000000000000000000000000000000000..486baf6be50982404fd1c68a5bc51db45c62046a Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/linen.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/list.png b/en/application-dev/reference/arkui-js-lite/figures/list.png new file mode 100644 index 0000000000000000000000000000000000000000..969473b2307ce6b0528459d5e2b71b0baef4f733 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/list.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/lite_bar.PNG b/en/application-dev/reference/arkui-js-lite/figures/lite_bar.PNG new file mode 100644 index 0000000000000000000000000000000000000000..a180cd74fb6455adb495cf0d8471b34c93a9415e Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/lite_bar.PNG differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/lite_line.PNG b/en/application-dev/reference/arkui-js-lite/figures/lite_line.PNG new file mode 100644 index 0000000000000000000000000000000000000000..664ade98b38a3b6ac2b3e96dc4af8b75b6749a72 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/lite_line.PNG differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/magenta.png b/en/application-dev/reference/arkui-js-lite/figures/magenta.png new file mode 100644 index 0000000000000000000000000000000000000000..6823cbc9203b07abae455b4ee5c7692878c4be72 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/magenta.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/maroon.png b/en/application-dev/reference/arkui-js-lite/figures/maroon.png new file mode 100644 index 0000000000000000000000000000000000000000..1324b43b3f5b8dd0548cf2069c4c532c5284c445 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/maroon.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/marquee.gif b/en/application-dev/reference/arkui-js-lite/figures/marquee.gif new file mode 100644 index 0000000000000000000000000000000000000000..3b6df4b26274fdf5c3e6e1fab2423400455b7050 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/marquee.gif differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/mediumaquamarine.png b/en/application-dev/reference/arkui-js-lite/figures/mediumaquamarine.png new file mode 100644 index 0000000000000000000000000000000000000000..800bf296338fd01962f16a8863c37bfe515ce3be Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/mediumaquamarine.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/mediumblue.png b/en/application-dev/reference/arkui-js-lite/figures/mediumblue.png new file mode 100644 index 0000000000000000000000000000000000000000..c0df3f4f7d99f0b8c39995133c71d944bc07ea4b Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/mediumblue.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/mediumorchid.png b/en/application-dev/reference/arkui-js-lite/figures/mediumorchid.png new file mode 100644 index 0000000000000000000000000000000000000000..664d13c38389361e61a45870899e2a6f0bfc835f Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/mediumorchid.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/mediumpurple.png b/en/application-dev/reference/arkui-js-lite/figures/mediumpurple.png new file mode 100644 index 0000000000000000000000000000000000000000..848454297b67eb73ab641424badc438433e24479 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/mediumpurple.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/mediumseagreen.png b/en/application-dev/reference/arkui-js-lite/figures/mediumseagreen.png new file mode 100644 index 0000000000000000000000000000000000000000..984e7a561e661ecefca8b60d5ac239b67f96c98c Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/mediumseagreen.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/mediumslateblue.png b/en/application-dev/reference/arkui-js-lite/figures/mediumslateblue.png new file mode 100644 index 0000000000000000000000000000000000000000..39cf9d01563cf63bee003a47cd88258e860a0757 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/mediumslateblue.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/mediumspringgreen.png b/en/application-dev/reference/arkui-js-lite/figures/mediumspringgreen.png new file mode 100644 index 0000000000000000000000000000000000000000..56db1024a714f821528656c64e12520311bae8f5 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/mediumspringgreen.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/mediumturquoise.png b/en/application-dev/reference/arkui-js-lite/figures/mediumturquoise.png new file mode 100644 index 0000000000000000000000000000000000000000..b3c353b6a872d3597b767f4c216b2d16bfc2139b Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/mediumturquoise.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/mediumvioletred.png b/en/application-dev/reference/arkui-js-lite/figures/mediumvioletred.png new file mode 100644 index 0000000000000000000000000000000000000000..00767e63c899eec52c2c732e834bca8d26d348ce Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/mediumvioletred.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/midnightblue.png b/en/application-dev/reference/arkui-js-lite/figures/midnightblue.png new file mode 100644 index 0000000000000000000000000000000000000000..ac66614c0f277cd722b3d090cb10efb973152b0f Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/midnightblue.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/mintcream.png b/en/application-dev/reference/arkui-js-lite/figures/mintcream.png new file mode 100644 index 0000000000000000000000000000000000000000..64fdda07447707816e8a6238939169f58a4ce58f Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/mintcream.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/mistyrose.png b/en/application-dev/reference/arkui-js-lite/figures/mistyrose.png new file mode 100644 index 0000000000000000000000000000000000000000..6f5fe69b5a5a62b2d2b719b2be0a17a501363918 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/mistyrose.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/moccasin.png b/en/application-dev/reference/arkui-js-lite/figures/moccasin.png new file mode 100644 index 0000000000000000000000000000000000000000..115cb4c96382681743381aeba099549dc24c2ae5 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/moccasin.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/navajowhite.png b/en/application-dev/reference/arkui-js-lite/figures/navajowhite.png new file mode 100644 index 0000000000000000000000000000000000000000..a68e61ab120651294310c5e3632ce22d71917a52 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/navajowhite.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/navy.png b/en/application-dev/reference/arkui-js-lite/figures/navy.png new file mode 100644 index 0000000000000000000000000000000000000000..4e41c2cd90ba17798448d70b493ccceb3ac960f0 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/navy.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/oldlace.png b/en/application-dev/reference/arkui-js-lite/figures/oldlace.png new file mode 100644 index 0000000000000000000000000000000000000000..ecf361e4c749446160da1e8a07169b21d99f362a Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/oldlace.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/olive.png b/en/application-dev/reference/arkui-js-lite/figures/olive.png new file mode 100644 index 0000000000000000000000000000000000000000..0d386fef5c4fa9faf1b29c7667c7392db250f2eb Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/olive.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/olivedrab.png b/en/application-dev/reference/arkui-js-lite/figures/olivedrab.png new file mode 100644 index 0000000000000000000000000000000000000000..639f16f8aaf261176b3bc760c2eb616ad2f4aa28 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/olivedrab.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/orange.png b/en/application-dev/reference/arkui-js-lite/figures/orange.png new file mode 100644 index 0000000000000000000000000000000000000000..9c43caf5fdfd466eafc37b793f509a6bde2b885d Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/orange.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/orangered.png b/en/application-dev/reference/arkui-js-lite/figures/orangered.png new file mode 100644 index 0000000000000000000000000000000000000000..e72165fdf1b24d80f0abde742ad3d848497c6ea7 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/orangered.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/orchid.png b/en/application-dev/reference/arkui-js-lite/figures/orchid.png new file mode 100644 index 0000000000000000000000000000000000000000..9114031e04fc28be59e8c9567c0fcfe81a9cc5cb Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/orchid.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/palegoldenrod.png b/en/application-dev/reference/arkui-js-lite/figures/palegoldenrod.png new file mode 100644 index 0000000000000000000000000000000000000000..131584c72c082f40e2b466e2706c86a05df375e0 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/palegoldenrod.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/palegreen.png b/en/application-dev/reference/arkui-js-lite/figures/palegreen.png new file mode 100644 index 0000000000000000000000000000000000000000..891d52276622fd51893634ce26e08bd56f62b782 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/palegreen.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/paleturquoise.png b/en/application-dev/reference/arkui-js-lite/figures/paleturquoise.png new file mode 100644 index 0000000000000000000000000000000000000000..a618da21cf6c6d32066286e594921c0fc75b5dba Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/paleturquoise.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/palevioletred.png b/en/application-dev/reference/arkui-js-lite/figures/palevioletred.png new file mode 100644 index 0000000000000000000000000000000000000000..c88212b6818d6d18c77ee497cfcafaf661a70d52 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/palevioletred.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/papayawhip.png b/en/application-dev/reference/arkui-js-lite/figures/papayawhip.png new file mode 100644 index 0000000000000000000000000000000000000000..4b1948de8581602c6c5879c03d68c14f06eccd00 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/papayawhip.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/peachpuff.png b/en/application-dev/reference/arkui-js-lite/figures/peachpuff.png new file mode 100644 index 0000000000000000000000000000000000000000..1821f9c40ad9d24dc10dc662ecbe7936c9e10633 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/peachpuff.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/peru.png b/en/application-dev/reference/arkui-js-lite/figures/peru.png new file mode 100644 index 0000000000000000000000000000000000000000..3ca3e045717379bb09fa8d13ea0d42019bf546f2 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/peru.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/picker-view.png b/en/application-dev/reference/arkui-js-lite/figures/picker-view.png new file mode 100644 index 0000000000000000000000000000000000000000..3e5375876c6c7403b254df56c75d08031ad9801d Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/picker-view.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/pink.png b/en/application-dev/reference/arkui-js-lite/figures/pink.png new file mode 100644 index 0000000000000000000000000000000000000000..5c5e360f249a2002ba68ad9b94bd7f66f5d6aab1 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/pink.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/plum.png b/en/application-dev/reference/arkui-js-lite/figures/plum.png new file mode 100644 index 0000000000000000000000000000000000000000..1e0bad2b2bfed2559e53a8bc21162e6163ec8434 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/plum.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/powderblue.png b/en/application-dev/reference/arkui-js-lite/figures/powderblue.png new file mode 100644 index 0000000000000000000000000000000000000000..8b3eec4e46f6a29dc47694940ceaef1cfa1314af Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/powderblue.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/progress.png b/en/application-dev/reference/arkui-js-lite/figures/progress.png new file mode 100644 index 0000000000000000000000000000000000000000..fb9170121d950b8d8b5a4a5a209c25b452791d25 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/progress.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/purple.png b/en/application-dev/reference/arkui-js-lite/figures/purple.png new file mode 100644 index 0000000000000000000000000000000000000000..8bc3583f82d21c8bec0c70b2da36ed05723fd9a7 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/purple.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/qrcode.gif b/en/application-dev/reference/arkui-js-lite/figures/qrcode.gif new file mode 100644 index 0000000000000000000000000000000000000000..53e718c2879554c82d4a3d9800507a00e37613dc Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/qrcode.gif differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/rebeccapurple.png b/en/application-dev/reference/arkui-js-lite/figures/rebeccapurple.png new file mode 100644 index 0000000000000000000000000000000000000000..6a64534a0a867d44cf81c8a34c9981b5fbaf5faf Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/rebeccapurple.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/red.png b/en/application-dev/reference/arkui-js-lite/figures/red.png new file mode 100644 index 0000000000000000000000000000000000000000..309d1c46f8bc396df5eaed381a5ffa2f0389d602 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/red.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/rosybrown.png b/en/application-dev/reference/arkui-js-lite/figures/rosybrown.png new file mode 100644 index 0000000000000000000000000000000000000000..adca00e684afb79ff4f21313d0586025576a8be1 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/rosybrown.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/royalblue.png b/en/application-dev/reference/arkui-js-lite/figures/royalblue.png new file mode 100644 index 0000000000000000000000000000000000000000..69cb300d4bc8decee06c7fb64b03a24287865a8f Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/royalblue.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/saddlebrown.png b/en/application-dev/reference/arkui-js-lite/figures/saddlebrown.png new file mode 100644 index 0000000000000000000000000000000000000000..5d0ae86ad14ff863511a10ecc1a85b273e826dfc Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/saddlebrown.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/salmon.png b/en/application-dev/reference/arkui-js-lite/figures/salmon.png new file mode 100644 index 0000000000000000000000000000000000000000..b80a6c31cdb287c35965c7841aa97711d79b371c Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/salmon.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/sample1.gif b/en/application-dev/reference/arkui-js-lite/figures/sample1.gif new file mode 100644 index 0000000000000000000000000000000000000000..6168a14aa67c866abf6185ba3a3c2ae9f595153c Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/sample1.gif differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/sandybrown.png b/en/application-dev/reference/arkui-js-lite/figures/sandybrown.png new file mode 100644 index 0000000000000000000000000000000000000000..c952585d8032733700b57ce1a919d71ce9a4b58b Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/sandybrown.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/seagreen.png b/en/application-dev/reference/arkui-js-lite/figures/seagreen.png new file mode 100644 index 0000000000000000000000000000000000000000..858c4187d3a2874f651adc09dcae9a32f8407d86 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/seagreen.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/seashell.png b/en/application-dev/reference/arkui-js-lite/figures/seashell.png new file mode 100644 index 0000000000000000000000000000000000000000..c0b21ed6b44c2f756458137f931873f540c16e5f Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/seashell.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/sienna.png b/en/application-dev/reference/arkui-js-lite/figures/sienna.png new file mode 100644 index 0000000000000000000000000000000000000000..bdb02fdda28a155e2f622eeea2ff820144780e50 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/sienna.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/silver.png b/en/application-dev/reference/arkui-js-lite/figures/silver.png new file mode 100644 index 0000000000000000000000000000000000000000..0491d350277cd67d7774e3761164b9dd7038a117 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/silver.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/skyblue.png b/en/application-dev/reference/arkui-js-lite/figures/skyblue.png new file mode 100644 index 0000000000000000000000000000000000000000..1c4f9ae52153198f8690a1066fe66ba8c7bd1ee1 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/skyblue.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/slateblue.png b/en/application-dev/reference/arkui-js-lite/figures/slateblue.png new file mode 100644 index 0000000000000000000000000000000000000000..87915df37741dacfe9448bfebccf5a88d3ca2a76 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/slateblue.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/slategray.png b/en/application-dev/reference/arkui-js-lite/figures/slategray.png new file mode 100644 index 0000000000000000000000000000000000000000..6e4476c4791e37d4681f8e12313ae1cad0887c1b Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/slategray.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/slider.png b/en/application-dev/reference/arkui-js-lite/figures/slider.png new file mode 100644 index 0000000000000000000000000000000000000000..b72ed8404c613ec9283d7be1f56071d70fcbbc1f Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/slider.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/smoothOff.PNG b/en/application-dev/reference/arkui-js-lite/figures/smoothOff.PNG new file mode 100644 index 0000000000000000000000000000000000000000..c699e78774fadbd8da8c0cc290e88294d445aa6f Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/smoothOff.PNG differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/smoothOn.PNG b/en/application-dev/reference/arkui-js-lite/figures/smoothOn.PNG new file mode 100644 index 0000000000000000000000000000000000000000..b7a5a2a819eeafeb000c00bd7009a02e5fe1bbe5 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/smoothOn.PNG differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/snow.png b/en/application-dev/reference/arkui-js-lite/figures/snow.png new file mode 100644 index 0000000000000000000000000000000000000000..283cf90b3828b36af6fb3a746e806f6715053310 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/snow.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/springgreen.png b/en/application-dev/reference/arkui-js-lite/figures/springgreen.png new file mode 100644 index 0000000000000000000000000000000000000000..93825b7fe53a0794751ee4aa3ca46300c404835e Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/springgreen.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/steelblue.png b/en/application-dev/reference/arkui-js-lite/figures/steelblue.png new file mode 100644 index 0000000000000000000000000000000000000000..a9aba5f67b94427168fade014542532431e28a2e Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/steelblue.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/swiper.gif b/en/application-dev/reference/arkui-js-lite/figures/swiper.gif new file mode 100644 index 0000000000000000000000000000000000000000..2ec52b162dcfdd39c2d2f5a7be4106321935b010 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/swiper.gif differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/switch.gif b/en/application-dev/reference/arkui-js-lite/figures/switch.gif new file mode 100644 index 0000000000000000000000000000000000000000..64f8c8eb0c1ecf13e8b91f291782d825ce9f0076 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/switch.gif differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/tan.png b/en/application-dev/reference/arkui-js-lite/figures/tan.png new file mode 100644 index 0000000000000000000000000000000000000000..b162dbf0a6c890a03ea1aa0b28bdb454651b697c Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/tan.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/teal.png b/en/application-dev/reference/arkui-js-lite/figures/teal.png new file mode 100644 index 0000000000000000000000000000000000000000..93299fc38d761e5251673210c364f6825e319153 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/teal.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/text.png b/en/application-dev/reference/arkui-js-lite/figures/text.png new file mode 100644 index 0000000000000000000000000000000000000000..d3a79bc7ae959d16d1eb4b915fa9040f00996b16 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/text.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/thistle.png b/en/application-dev/reference/arkui-js-lite/figures/thistle.png new file mode 100644 index 0000000000000000000000000000000000000000..d62fc7767f7b2e0e8d0d7fed57e30bdf6a6a332f Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/thistle.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/tomato.png b/en/application-dev/reference/arkui-js-lite/figures/tomato.png new file mode 100644 index 0000000000000000000000000000000000000000..6d795f1618b1546c94266548069eccf9e9af2e01 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/tomato.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/turquoise.png b/en/application-dev/reference/arkui-js-lite/figures/turquoise.png new file mode 100644 index 0000000000000000000000000000000000000000..a33c4fce8448e2127b21e277437195ce0002766b Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/turquoise.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/violet.png b/en/application-dev/reference/arkui-js-lite/figures/violet.png new file mode 100644 index 0000000000000000000000000000000000000000..e9a0799a203fdd7bd41fa5175585dc170a20156e Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/violet.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/wheat.png b/en/application-dev/reference/arkui-js-lite/figures/wheat.png new file mode 100644 index 0000000000000000000000000000000000000000..8a5c7039b580128e75299672dc5438151dcf3572 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/wheat.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/white.png b/en/application-dev/reference/arkui-js-lite/figures/white.png new file mode 100644 index 0000000000000000000000000000000000000000..56d32d4cd371c5374b133cb81c9c077aaf7b110d Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/white.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/whitesmoke.png b/en/application-dev/reference/arkui-js-lite/figures/whitesmoke.png new file mode 100644 index 0000000000000000000000000000000000000000..6dc88e656c293c2e65939e4a793684488dfc81be Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/whitesmoke.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/yellow.png b/en/application-dev/reference/arkui-js-lite/figures/yellow.png new file mode 100644 index 0000000000000000000000000000000000000000..b54dbc2391d1a8f16312dd02dc3d65a35ea2626f Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/yellow.png differ diff --git a/en/application-dev/reference/arkui-js-lite/figures/yellowgreen.png b/en/application-dev/reference/arkui-js-lite/figures/yellowgreen.png new file mode 100644 index 0000000000000000000000000000000000000000..f89e20a55ba1e81f2cbda2bd0241edefadbe7149 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/figures/yellowgreen.png differ diff --git a/en/application-dev/reference/arkui-js-lite/js-common-attributes.md b/en/application-dev/reference/arkui-js-lite/js-common-attributes.md new file mode 100644 index 0000000000000000000000000000000000000000..d91f720d4e8d718abae2a45f4d99d245d46f4815 --- /dev/null +++ b/en/application-dev/reference/arkui-js-lite/js-common-attributes.md @@ -0,0 +1,28 @@ +# Universal Attributes + + +## Common Attributes + +Common attributes are used to set component identities and appearance. + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| id | string | No| Unique ID of the component.| +| style | string | No| Style declaration of the component.| +| class | string | No| Style class of the component, which is used to refer to a style table.| +| ref | string | No| Reference information of child elements, which is registered with the parent component on **$refs**.| + + +## Rendering Attributes + +Rendering attributes are used to set whether a component is rendered. + +| Name| Type| Description| +| -------- | -------- | -------- | +| for | Array | Expands the current element based on the configured data list.| +| if | boolean | Whether the element is added or removed.| +| show | boolean | Whether the element is displayed or hidden.| + +> **NOTE** +> +> Do not set styles in attribute fields. diff --git a/en/application-dev/reference/arkui-js-lite/js-common-events.md b/en/application-dev/reference/arkui-js-lite/js-common-events.md new file mode 100644 index 0000000000000000000000000000000000000000..93022870c037ef7424eb4a752d4b0e8ee87cda41 --- /dev/null +++ b/en/application-dev/reference/arkui-js-lite/js-common-events.md @@ -0,0 +1,19 @@ +# Universal Events + + +Different from private events, universal events can be bound to most components. + + +| Name| Parameter| Description| +| -------- | -------- | -------- | +| click | - | Triggered when the component is clicked. | +| longpress | - | Triggered when the component is long pressed. | +| swipe5+ | SwipeEvent | Triggered when a user quickly swipes on the component. | + + + **Table 1** SwipeEvent (inherited from BaseEvent) + +| Attribute| Type| Description | +| -------- | -------- | -------- | +| direction | string | Swiping direction. The value can be one of the following:
- **left**: Swipe left.
- **right**: Swipe right.
- **up**: Swipe up.
- **down**: Swipe down. | + diff --git a/en/application-dev/reference/arkui-js-lite/js-common-styles.md b/en/application-dev/reference/arkui-js-lite/js-common-styles.md new file mode 100644 index 0000000000000000000000000000000000000000..52b7e4c81ed17f40e65b8dcfcc0a359729453429 --- /dev/null +++ b/en/application-dev/reference/arkui-js-lite/js-common-styles.md @@ -0,0 +1,188 @@ +# Universal Styles + + +You can set universal styles for components in the **style** attribute or **.css** files. + + +| Name | Type | Default Value | Mandatory | Description | +| ---------------------------------- | ---------------------------------------- | ----- | ---- | ---------------------------------------- | +| width | <length> \| <percentage>5+ | - | No | Component width.

If this attribute is not set, the default value **0** is used. | +| height | <length> \| <percentage>5+ | - | No | Component height.

If this attribute is not set, the default value **0** is used. | +| padding | <length> | 0 | No | Shorthand attribute to set the padding for all sides in a declaration.
The attribute can have one to four values:
- If you set only one value, it specifies the padding for all the four sides.
- If you set two values, the first value specifies the top and bottom padding, and the second value specifies the left and right padding.
- If you set three values, the first value specifies the top padding, the second value specifies the left and right padding, and the third value specifies the bottom padding.
- If you set four values, they respectively specify the padding for top, right, bottom, and left sides (in clockwise order).| +| padding-[left\|top\|right\|bottom] | <length> | 0 | No | Left, top, right, and bottom padding. | +| margin | <length> \| <percentage>5+ | 0 | No | Shorthand attribute to set the margin for all sides in a declaration. The attribute can have one to four values:
- If you set only one value, it specifies the margin for all the four sides.
- If you set two values, the first value specifies the top and bottom margins, and the second value specifies the left and right margins.
- If you set three values, the first value specifies the top margin, the second value specifies the left and right margins, and the third value specifies the bottom margin.
- If you set four values, they respectively specify the margin for top, right, bottom, and left sides (in clockwise order).| +| margin-[left\|top\|right\|bottom] | <length> \| <percentage>5+ | 0 | No | Left, top, right, and bottom margins. | +| border-width | <length> | 0 | No | Shorthand attribute to set the margin for all sides. | +| border-color | <color> | black | No | Shorthand attribute to set the color for all borders. | +| border-radius | <length> | - | No | Radius of round-corner borders. | +| background-color | <color> | - | No | Background color. | +| opacity5+ | number | 1 | No | Opacity of an element. The value ranges from **0** to **1**. The value **1** means opaque, and **0** means completely transparent. | +| display | string | flex | No | Type of the box containing an element. Available values are as follows:
- **flex**: flexible layout
- **none**: not rendered| +| [left\|top] | <length> \| <percentage>6+ | - | No | Edge of the element.
- **left**: left edge position of the element. This attribute defines the offset between the left edge of the margin area of a positioned element and left edge of its containing block.
- **top**: top edge position of the element. This attribute defines the offset between the top edge of a positioned element and that of a block included in the element.| + + +> **NOTE** +> +> The aforementioned universal styles are not mandatory. +> +> Currently, the following color formats are supported: +> - rgb(255, 255, 255) +> +> - rgba(255, 255, 255, 1.0) +> +> - HEX formats: \#rrggbb and \#aarrggbb +> +> - Enumeration format: as listed in Table 1. The enumeration format is not supported in the script. + + + **Table 1** Color enums + +| Name | Hexadecimal Code | Color | +| -------------------- | -------- | ---------------------------------------- | +| aliceblue | \#f0f8ff | ![aliceblue](figures/aliceblue.png) | +| antiquewhite | \#faebd7 | ![antiquewhite](figures/antiquewhite.png) | +| aqua | \#00ffff | ![aqua](figures/aqua.png) | +| aquamarine | \#7fffd4 | ![aquamarine](figures/aquamarine.png) | +| azure | \#f0ffff | ![azure](figures/azure.png) | +| beige | \#f5f5dc | ![beige](figures/beige.png) | +| bisque | \#ffe4c4 | ![bisque](figures/bisque.png) | +| black | \#000000 | ![000000](figures/000000.png) | +| blanchedalmond | \#ffebcd | ![blanchedalmond](figures/blanchedalmond.png) | +| blue | \#0000ff | ![blue](figures/blue.png) | +| blueviolet | \#8a2be2 | ![blueviolet](figures/blueviolet.png) | +| brown | \#a52a2a | ![brown](figures/brown.png) | +| burlywood | \#deB887 | ![burlywood](figures/burlywood.png) | +| cadetblue | \#5f9ea0 | ![cadetblue](figures/cadetblue.png) | +| chartreuse | \#7fff00 | ![chartreuse](figures/chartreuse.png) | +| chocolate | \#d2691e | ![chocolate](figures/chocolate.png) | +| coral | \#ff7f50 | ![coral](figures/coral.png) | +| cornflowerblue | \#6495ed | ![cornflowerblue](figures/cornflowerblue.png) | +| cornsilk | \#fff8dc | ![cornsilk](figures/cornsilk.png) | +| crimson | \#dc143c | ![crimson](figures/crimson.png) | +| cyan | \#00ffff | ![cyan](figures/cyan.png) | +| darkblue | \#00008b | ![darkblue](figures/darkblue.png) | +| darkcyan | \#008b8b | ![darkcyan](figures/darkcyan.png) | +| darkgoldenrod | \#b8860b | ![darkgoldenrod](figures/darkgoldenrod.png) | +| darkgray | \#a9a9a9 | ![darkgray](figures/darkgray.png) | +| darkgreen | \#006400 | ![darkgreen](figures/darkgreen.png) | +| darkgrey | \#a9a9a9 | ![darkgrey](figures/darkgrey.png) | +| darkkhaki | \#bdb76b | ![darkkhaki](figures/darkkhaki.png) | +| darkmagenta | \#8b008b | ![darkmagenta](figures/darkmagenta.png) | +| darkolivegreen | \#556b2f | ![darkolivegreen](figures/darkolivegreen.png) | +| darkorange | \#ff8c00 | ![darkorange](figures/darkorange.png) | +| darkorchid | \#9932cc | ![darkorchid](figures/darkorchid.png) | +| darkred | \#8b0000 | ![darkred](figures/darkred.png) | +| darksalmon | \#e9967a | ![darksalmon](figures/darksalmon.png) | +| darkseagreen | \#8fbc8f | ![darkseagreen](figures/darkseagreen.png) | +| darkslateblue | \#483d8b | ![darkslateblue](figures/darkslateblue.png) | +| darkslategray | \#2f4f4f | ![darkslategray](figures/darkslategray.png) | +| darkslategrey | \#2f4f4f | ![darkslategrey](figures/darkslategrey.png) | +| darkturquoise | \#00ced1 | ![darkturquoise](figures/darkturquoise.png) | +| darkviolet | \#9400d3 | ![darkviolet](figures/darkviolet.png) | +| deeppink | \#ff1493 | ![deeppink](figures/deeppink.png) | +| deepskyblue | \#00bfff | ![deepskyblue](figures/deepskyblue.png) | +| dimgray | \#696969 | ![dimgray](figures/dimgray.png) | +| dimgrey | \#696969 | ![dimgrey](figures/dimgrey.png) | +| dodgerblue | \#1e90ff | ![dodgerblue](figures/dodgerblue.png) | +| firebrick | \#b22222 | ![firebrick](figures/firebrick.png) | +| floralwhite | \#fffaf0 | ![floralwhite](figures/floralwhite.png) | +| forestgreen | \#228b22 | ![forestgreen](figures/forestgreen.png) | +| fuchsia | \#ff00ff | ![fuchsia](figures/fuchsia.png) | +| gainsboro | \#dcdcdc | ![gainsboro](figures/gainsboro.png) | +| ghostwhite | \#f8f8ff | ![ghostwhite](figures/ghostwhite.png) | +| gold | \#ffd700 | ![gold](figures/gold.png) | +| goldenrod | \#daa520 | ![goldenrod](figures/goldenrod.png) | +| gray | \#808080 | ![gray](figures/gray.png) | +| green | \#008000 | ![green](figures/green.png) | +| greenyellow | \#adff2f | ![greenyellow](figures/greenyellow.png) | +| grey | \#808080 | ![grey](figures/grey.png) | +| honeydew | \#f0fff0 | ![honeydew](figures/honeydew.png) | +| hotpink | \#ff69b4 | ![hotpink](figures/hotpink.png) | +| indianred | \#cd5c5c | ![indianred](figures/indianred.png) | +| indigo | \#4b0082 | ![indigo](figures/indigo.png) | +| ivory | \#fffff0 | ![ivory](figures/ivory.png) | +| khaki | \#f0e68c | ![khaki](figures/khaki.png) | +| lavender | \#e6e6fa | ![lavender](figures/lavender.png) | +| lavenderblush | \#fff0f5 | ![lavenderblush](figures/lavenderblush.png) | +| lawngreen | \#7cfc00 | ![lawngreen](figures/lawngreen.png) | +| lemonchiffon | \#fffacd | ![lemonchiffon](figures/lemonchiffon.png) | +| lightblue | \#add8e6 | ![lightblue](figures/lightblue.png) | +| lightcoral | \#f08080 | ![lightcoral](figures/lightcoral.png) | +| lightcyan | \#e0ffff | ![lightcyan](figures/lightcyan.png) | +| lightgoldenrodyellow | \#fafad2 | ![lightgoldenrodyellow](figures/lightgoldenrodyellow.png) | +| lightgray | \#d3d3d3 | ![lightgray](figures/lightgray.png) | +| lightgreen | \#90ee90 | ![lightgreen](figures/lightgreen.png) | +| lightpink | \#ffb6c1 | ![lightpink](figures/lightpink.png) | +| lightsalmon | \#ffa07a | ![lightsalmon](figures/lightsalmon.png) | +| lightseagreen | \#20b2aa | ![lightseagreen](figures/lightseagreen.png) | +| lightskyblue | \#87cefa | ![lightskyblue](figures/lightskyblue.png) | +| lightslategray | \#778899 | ![lightslategray](figures/lightslategray.png) | +| lightslategrey | \#778899 | ![lightslategrey](figures/lightslategrey.png) | +| lightsteelblue | \#b0c4de | ![lightsteelblue](figures/lightsteelblue.png) | +| lightyellow | \#ffffe0 | ![lightyellow](figures/lightyellow.png) | +| lime | \#00ff00 | ![lime](figures/lime.png) | +| limegreen | \#32cd32 | ![limegreen](figures/limegreen.png) | +| linen | \#faf0e6 | ![linen](figures/linen.png) | +| magenta | \#ff00ff | ![magenta](figures/magenta.png) | +| maroon | \#800000 | ![maroon](figures/maroon.png) | +| mediumaquamarine | \#66cdaa | ![mediumaquamarine](figures/mediumaquamarine.png) | +| mediumblue | \#0000cd | ![mediumblue](figures/mediumblue.png) | +| mediumorchid | \#ba55d3 | ![mediumorchid](figures/mediumorchid.png) | +| mediumpurple | \#9370db | ![mediumpurple](figures/mediumpurple.png) | +| mediumseagreen | \#3cb371 | ![mediumseagreen](figures/mediumseagreen.png) | +| mediumslateblue | \#7b68ee | ![mediumslateblue](figures/mediumslateblue.png) | +| mediumspringgreen | \#00fa9a | ![mediumspringgreen](figures/mediumspringgreen.png) | +| mediumturquoise | \#48d1cc | ![mediumturquoise](figures/mediumturquoise.png) | +| mediumvioletred | \#c71585 | ![mediumvioletred](figures/mediumvioletred.png) | +| midnightblue | \#191970 | ![midnightblue](figures/midnightblue.png) | +| mintcream | \#f5fffa | ![mintcream](figures/mintcream.png) | +| mistyrose | \#ffe4e1 | ![mistyrose](figures/mistyrose.png) | +| moccasin | \#ffe4b5 | ![moccasin](figures/moccasin.png) | +| navajowhite | \#ffdead | ![navajowhite](figures/navajowhite.png) | +| navy | \#000080 | ![navy](figures/navy.png) | +| oldlace | \#fdf5e6 | ![oldlace](figures/oldlace.png) | +| olive | \#808000 | ![olive](figures/olive.png) | +| olivedrab | \#6b8e23 | ![olivedrab](figures/olivedrab.png) | +| orange | \#ffa500 | ![orange](figures/orange.png) | +| orangered | \#ff4500 | ![orangered](figures/orangered.png) | +| orchid | \#da70d6 | ![orchid](figures/orchid.png) | +| palegoldenrod | \#eee8aa | ![palegoldenrod](figures/palegoldenrod.png) | +| palegreen | \#98fb98 | ![palegreen](figures/palegreen.png) | +| paleturquoise | \#afeeee | ![paleturquoise](figures/paleturquoise.png) | +| palevioletred | \#db7093 | ![palevioletred](figures/palevioletred.png) | +| papayawhip | \#ffefd5 | ![papayawhip](figures/papayawhip.png) | +| peachpuff | \#ffdab9 | ![peachpuff](figures/peachpuff.png) | +| peru | \#cd853f | ![peru](figures/peru.png) | +| pink | \#ffc0cb | ![pink](figures/pink.png) | +| plum | \#dda0dd | ![plum](figures/plum.png) | +| powderblue | \#b0e0e6 | ![powderblue](figures/powderblue.png) | +| purple | \#800080 | ![purple](figures/purple.png) | +| rebeccapurple | \#663399 | ![rebeccapurple](figures/rebeccapurple.png) | +| red | \#ff0000 | ![red](figures/red.png) | +| rosybrown | \#bc8f8f | ![rosybrown](figures/rosybrown.png) | +| royalblue | \#4169e1 | ![royalblue](figures/royalblue.png) | +| saddlebrown | \#8b4513 | ![saddlebrown](figures/saddlebrown.png) | +| salmon | \#fa8072 | ![salmon](figures/salmon.png) | +| sandybrown | \#f4a460 | ![sandybrown](figures/sandybrown.png) | +| seagreen | \#2e8b57 | ![seagreen](figures/seagreen.png) | +| seashell | \#fff5ee | ![seashell](figures/seashell.png) | +| sienna | \#a0522d | ![sienna](figures/sienna.png) | +| silver | \#c0c0c0 | ![silver](figures/silver.png) | +| skyblue | \#87ceeb | ![skyblue](figures/skyblue.png) | +| slateblue | \#6a5acd | ![slateblue](figures/slateblue.png) | +| slategray | \#708090 | ![slategray](figures/slategray.png) | +| slategrey | \#708090 | ![slategray](figures/slategray.png) | +| snow | \#fffafa | ![snow](figures/snow.png) | +| springgreen | \#00ff7f | ![springgreen](figures/springgreen.png) | +| steelblue | \#4682b4 | ![steelblue](figures/steelblue.png) | +| tan | \#d2b48c | ![tan](figures/tan.png) | +| teal | \#008080 | ![teal](figures/teal.png) | +| thistle | \#d8Bfd8 | ![thistle](figures/thistle.png) | +| tomato | \#ff6347 | ![tomato](figures/tomato.png) | +| turquoise | \#40e0d0 | ![turquoise](figures/turquoise.png) | +| violet | \#ee82ee | ![violet](figures/violet.png) | +| wheat | \#f5deb3 | ![wheat](figures/wheat.png) | +| white | \#ffffff | ![white](figures/white.png) | +| whitesmoke | \#f5f5f5 | ![whitesmoke](figures/whitesmoke.png) | +| yellow | \#ffff00 | ![yellow](figures/yellow.png) | +| yellowgreen | \#9acd32 | ![yellowgreen](figures/yellowgreen.png) | diff --git a/en/application-dev/reference/arkui-js-lite/js-components-basic-chart.md b/en/application-dev/reference/arkui-js-lite/js-components-basic-chart.md new file mode 100644 index 0000000000000000000000000000000000000000..2c8f4c0550f7794d975eb7014e30506c034e9a1d --- /dev/null +++ b/en/application-dev/reference/arkui-js-lite/js-components-basic-chart.md @@ -0,0 +1,275 @@ +# chart + +The **\** component displays line charts and bar charts. + +> **NOTE** +> +> This component is supported since API version 4. Updates will be marked with a superscript to indicate their earliest API version. + + +## Child Components + +Not supported + + +## Attributes + +| Name | Type | Mandatory | Description | +| -------- | ------------------------- | ---- | ---------------------------------------- | +| type | string | No | Chart type. Dynamic modification is not supported. Available values include:
- **bar**: bar chart
- **line**: line chart
Default value: **line**| +| options | ChartOptions | Yes | Chart parameters. You can set the minimum value, maximum value, scale, and line width of the x-axis or y-axis, whether to display the x-axis and y-axis, and whether the line is smooth. Dynamic modification is not supported.| +| datasets | Array<ChartDataset> | Yes | Data sets. You can set multiple datasets and their background colors. | +| id | string | No | Unique ID of the component. | +| style | string | No | Style declaration of the component. | +| class | string | No | Style class of the component, which is used to refer to a style table. | +| ref | string | No | Reference information of child elements, which is registered with the parent component on **$refs**.| + + **Table 1** ChartOptions + +| Name | Type | Mandatory | Description | +| ------ | ----------- | ---- | ---------------------------------------- | +| xAxis | ChartAxis | Yes | X-axis parameters. You can set the minimum value, maximum value, and scale of the x-axis, and whether to display the x-axis. | +| yAxis | ChartAxis | Yes | Y-axis parameters. You can set the minimum value, maximum value, and scale of the y-axis, and whether to display the y-axis. | +| series | ChartSeries | No | Data series parameters which cover the following:
- Line style, such as the line width and whether the line is smooth.
- Style and size of the white point at the start of the line.
**NOTE**
Only line charts support this attribute.| + + **Table 2** ChartDataset + +| Name | Type | Default Value | Mandatory | Description | +| --------------------------- | ------------------- | -------- | ---- | -------------------- | +| backgroundColor(deprecated) | <color> | \#ff6384 | No | Color of a line or bar. This attribute is not recommended. | +| strokeColor | <color> | \#ff6384 | No | Line color. Only line charts support this attribute. | +| fillColor | <color> | \#ff6384 | No | Fill color. For line charts, the value indicates the gradient color to fill. | +| data | Array<number> | - | Yes | Data of the drawn line or bar. | +| gradient | boolean | false | No | Whether to display the gradient color. Only line charts support this attribute.| + + **Table 3** ChartAxis + +| Name | Type | Default Value | Mandatory | Description | +| -------- | ------------- | -------- | ---- | ---------------------------------------- | +| min | number | 0 | No | Minimum value of the axis.
Negative numbers are not supported. Only line charts support this attribute. | +| max | number | 100 | No | Maximum value of the axis.
Negative numbers are not supported. Only line charts support this attribute. | +| axisTick | number | 10 | No | Number of scales displayed on the axis.
**NOTE**
The value ranges from 1 to 20. The display effect depends on the calculation result of Number of pixels occupied by the image width/(**max**-**min**).
Lite wearables support integer calculation, and an error may occur in the case of inexhaustible division. Specifically, a segment of space may be left at the end of the x-axis.
In the bar chart, the number of bars in each group of data is the same as the number of scales, and the bars are displayed at the scales.| +| display | boolean | false | No | Whether to display the axis. | +| color | <color> | \#c0c0c0 | No | Axis color. | + + **Table 4** ChartSeries + +| Name | Type | Mandatory | Description | +| ----------- | -------------- | ---- | -------------------- | +| lineStyle | ChartLineStyle | No | Line style, such as the line width and whether the line is smooth. | +| headPoint | PointStyle | No | Style and size of the white point at the start of the line. | +| topPoint | PointStyle | No | Style and size of the top point. | +| bottomPoint | PointStyle | No | Style and size of the bottom point. | +| loop | ChartLoop | No | Whether to start drawing again when the screen is looped.| + + **Table 5** ChartLineStyle + +| Name | Type | Default Value | Mandatory | Description | +| ------ | -------------- | ----- | ---- | ----- | +| width | <length> | 1px | No | Line width.| +| smooth | boolean | false | No | Whether the line is smooth.| + + **Table 6** PointStyle + +| Name | Type | Default Value | Mandatory | Description | +| ----------- | -------------- | -------- | ---- | ---------------------------------- | +| shape | string | circle | No | Shape of the highlight point. Available values are as follows:
- circle| +| size | <length> | 5px | No | Size of the highlight point. | +| strokeWidth | <length> | 1px | No | Stroke width. | +| strokeColor | <color> | \#ff0000 | No | Stroke color. | +| fillColor | <color> | \#ff0000 | No | Fill color. | +| display | boolean | true | No | Whether to display the highlight spot. | + + **Table 7** ChartLoop + +| Name | Type | Default Value | Mandatory | Description | +| ------ | -------------- | ---- | ---- | ---------------------------------------- | +| margin | <length> | 1 | No | Number of erased points (horizontal distance between the latest drawn point and the earliest point). You are not advised to use **margin** together with **topPoint**, **bottomPoint**, or **headPoint** for mini-, small- and standard-system devices. If you do so, there is a possibility that the point is in the erase area and invisible.| + + + + +## Methods + +| Methods | Parameter | Description | +| ------ | ---------------------------------------- | ---------------------------------------- | +| append | {
serial: number, // Set the data subscript of the line chart to be updated.
data: Array<number>, // Set the new data.
} | Dynamically add data to an existing data series. The target series is specified based on **serial**, which is the subscript of the datasets array and starts from 0. **datasets[index].data** is not updated. Only line charts support this attribute. The value is incremented by 1 based on the horizontal coordinate and is related to the **xAxis min/max** setting.| + + +## Events + +| Name | Parameter | Description | +| ------------------ | --------------------------------- | ----------- | +| click | - | Triggered when the component is clicked. | +| longpress | - | Triggered when the component is long pressed. | +| swipe5+ | [SwipeEvent](js-common-events.md) | Triggered when a user quickly swipes on the component.| + + +## Styles + +| Name | Type | Default Value | Mandatory | Description | +| ---------------------------------- | ---------------------------------------- | ----- | ---- | ---------------------------------------- | +| width | <length> \| <percentage>5+ | - | No | Component width.

If this attribute is not set, the default value **0** is used. | +| height | <length> \| <percentage>5+ | - | No | Component height.

If this attribute is not set, the default value **0** is used. | +| padding | <length> | 0 | No | Shorthand attribute to set the padding for all sides.
The attribute can have one to four values:
- If you set only one value, it specifies the padding for all the four sides.
- If you set two values, the first value specifies the top and bottom padding, and the second value specifies the left and right padding.
- If you set three values, the first value specifies the top padding, the second value specifies the left and right padding, and the third value specifies the bottom padding.
- If you set four values, they respectively specify the padding for top, right, bottom, and left sides (in clockwise order).| +| padding-[left\|top\|right\|bottom] | <length> | 0 | No | Left, top, right, and bottom padding. | +| margin | <length> \| <percentage>5+ | 0 | No | Shorthand attribute to set the margin for all sides. The attribute can have one to four values:
- If you set only one value, it specifies the margin for all the four sides.
- If you set two values, the first value specifies the top and bottom margins, and the second value specifies the left and right margins.
- If you set three values, the first value specifies the top margin, the second value specifies the left and right margins, and the third value specifies the bottom margin.
- If you set four values, they respectively specify the margin for top, right, bottom, and left sides (in clockwise order).| +| margin-[left\|top\|right\|bottom] | <length> \| <percentage>5+ | 0 | No | Left, top, right, and bottom margins. | +| border-width | <length> | 0 | No | Shorthand attribute to set the margin for all sides. | +| border-color | <color> | black | No | Shorthand attribute to set the color for all borders. | +| border-radius | <length> | - | No | Radius of round-corner borders. | +| background-color | <color> | - | No | Background color. | +| display | string | flex | No | How and whether to display the box containing an element. Available values are as follows:
- **flex**: flexible layout
- **none**: not rendered| +| [left\|top] | <length> \| <percentage>6+ | - | No | Edge of the element.
- **left**: left edge position of the element. This attribute defines the offset between the left edge of the margin area of a positioned element and left edge of its containing block.
- **top**: top edge position of the element. This attribute defines the offset between the top edge of a positioned element and that of a block included in the element.| + +## Example + +1. Line chart + + ```html + +
+ + +
+ ``` + + + ```css + /* xxx.css */ + .container { + flex-direction: column; + justify-content: center; + align-items: center; + width: 454px; + height: 454px; + background-color: white; + } + .chart { + width: 300px; + height: 300px; + } + .button { + width: 280px; + border-radius: 0px; + } + ``` + + + ```js + // xxx.js + export default { + data: { + lineData: [ + { + strokeColor: '#0081ff', + fillColor: '#cce5ff', + data: [763, 550, 551, 554, 731, 654, 525, 696, 595, 628, 791, 505, 613, 575, 475, 553, 491, 680, 657, 716], + gradient: true, + } + ], + lineOps: { + xAxis: { + min: 0, + max: 20, + display: false, + }, + yAxis: { + min: 0, + max: 1000, + display: false, + }, + series: { + lineStyle: { + width: "5px", + smooth: true, + }, + headPoint: { + shape: "circle", + size: 10, + strokeWidth: 5, + fillColor: '#ffffff', + strokeColor: '#007aff', + display: true, + }, + loop: { + margin: 2, + gradient: true, + } + } + }, + }, + addData() { + this.$refs.linechart.append({ + serial: 0, + data: [Math.floor(Math.random() * 400) + 400] + }) + } + } + ``` + + ![lite_line](figures/lite_line.PNG) + +2. Bar chart + + ```html + +
+ +
+ ``` + + + ```css + /* xxx.css */ + .container { + flex-direction: column; + justify-content: center; + align-items: center; + width: 454px; + height: 454px; + background-color: white; + } + .chart { + width: 300px; + height: 300px; + } + ``` + + + ```js + // xxx.js + export default { + data: { + barData: [ + { + fillColor: '#f07826', + data: [763, 550, 551, 554, 731, 654, 525, 696, 595, 628], + }, + { + fillColor: '#cce5ff', + data: [535, 776, 615, 444, 694, 785, 677, 609, 562, 410], + }, + { + fillColor: '#ff88bb', + data: [673, 500, 574, 483, 702, 583, 437, 506, 693, 657], + }, + ], + barOps: { + xAxis: { + min: 0, + max: 20, + display: false, + axisTick: 10 + }, + yAxis: { + min: 0, + max: 1000, + display: false, + }, + }, + } + } + ``` + + ![lite_bar](figures/lite_bar.PNG) diff --git a/en/application-dev/reference/arkui-js-lite/js-components-basic-image-animator.md b/en/application-dev/reference/arkui-js-lite/js-components-basic-image-animator.md new file mode 100644 index 0000000000000000000000000000000000000000..226eff9f6c284140b5c671d2135dbe212b609590 --- /dev/null +++ b/en/application-dev/reference/arkui-js-lite/js-components-basic-image-animator.md @@ -0,0 +1,207 @@ +# image-animator + +The **\** component is used to provide an image frame animator. + +> **NOTE** +> +> This component is supported since API version 4. Updates will be marked with a superscript to indicate their earliest API version. + + +## Child Components + +Not supported + + +## Attributes + +| Name | Type | Default Value | Mandatory | Description | +| --------------------- | -------------------------- | -------- | ---- | ---------------------------------------- | +| images | Array<ImageFrame> | - | Yes | Image frame information. The frame information includes the image path, size, and location. The supported image formats include PNG, JPG, and BMP. For details about **ImageFrame**, see Table 1.
**NOTE**
Use data binding, for example, **images = {{images}}**, to specify the image. Declare the corresponding variable in the JavaScript: **images: [{src: "/common/heart-rate01.png"}, {src: "/common/heart-rate02.png"}]**.| +| iteration | number \| string | infinite | No | Number of times that the frame animation is played. **number** indicates a fixed number of playback operations, and **infinite** indicates an unlimited number of playback operations.| +| reverse | boolean | false | No | Playback sequence.
- **true**: Images are played from the last one to the first one.
- **false**: Images are played from the first one to the last one.| +| fixedsize | boolean | true | No | Whether the image size is the same as the component size.
- **true**: The image size is the same as the component size. In this case, the width, height, top, and left attributes of the image are invalid.
- **false**: The image size is different from the component size. In this case, the width, height, top, and left attributes of each image must be set separately.| +| duration | string | - | Yes | Single video playback duration, in seconds (s) or milliseconds (ms). The default unit is ms. If the value is **0**, no image is played. The value change takes effect only at the start of the next cycle.| +| fillmode5+ | string | forwards | No | Status of the frame animation after its playback is complete. Available values are as follows:
- **none**: restores to the initial status.
- **forwards**: retains the ending status defined for the last key frame.| +| id | string | - | No | Unique ID of the component. | +| style | string | - | No | Style declaration of the component. | +| class | string | - | No | Style class of the component, which is used to refer to a style table. | +| ref | string | - | No | Reference information of child elements, which is registered with the parent component on **$refs**.| + + **Table 1** ImageFrame + +| Name | Type | Default Value | Mandatory | Description | +| ------ | -------------- | ---- | ---- | ---------------- | +| src | <uri> | - | Yes | Image path. | +| width | <length> | 0 | No | Image width. | +| height | <length> | 0 | No | Image height. | +| top | <length> | 0 | No | Vertical coordinate of the image relative to the upper left corner of the component.| +| left | <length> | 0 | No | Horizontal coordinate of the image relative to the upper left corner of the component.| + + +## Events + +| Name | Parameter | Description | +| ------------------ | --------------------------------- | ----------- | +| stop | - | Triggered when the frame animation stops | +| click | - | Triggered when the component is clicked. | +| longpress | - | Triggered when the component is long pressed. | +| swipe5+ | [SwipeEvent](js-common-events.md) | Triggered when a user quickly swipes on the component.| + + +## Styles + +| Name | Type | Default Value | Mandatory | Description | +| ---------------------------------- | ---------------------------------------- | ----- | ---- | ---------------------------------------- | +| width | <length> \| <percentage>5+ | - | No | Component width.

If this attribute is not set, the default value **0** is used. | +| height | <length> \| <percentage>5+ | - | No | Component height.

If this attribute is not set, the default value **0** is used. | +| padding | <length> | 0 | No | Shorthand attribute to set the padding for all sides.
The attribute can have one to four values:
- If you set only one value, it specifies the padding for all the four sides.
- If you set two values, the first value specifies the top and bottom padding, and the second value specifies the left and right padding.
- If you set three values, the first value specifies the top padding, the second value specifies the left and right padding, and the third value specifies the bottom padding.
- If you set four values, they respectively specify the padding for top, right, bottom, and left sides (in clockwise order).| +| padding-[left\|top\|right\|bottom] | <length> | 0 | No | Left, top, right, and bottom padding. | +| margin | <length> \| <percentage>5+ | 0 | No | Shorthand attribute to set the margin for all sides. The attribute can have one to four values:
- If you set only one value, it specifies the margin for all the four sides.
- If you set two values, the first value specifies the top and bottom margins, and the second value specifies the left and right margins.
- If you set three values, the first value specifies the top margin, the second value specifies the left and right margins, and the third value specifies the bottom margin.
- If you set four values, they respectively specify the margin for top, right, bottom, and left sides (in clockwise order).| +| margin-[left\|top\|right\|bottom] | <length> \| <percentage>5+ | 0 | No | Left, top, right, and bottom margins. | +| border-width | <length> | 0 | No | Shorthand attribute to set the margin for all sides. | +| border-color | <color> | black | No | Shorthand attribute to set the color for all borders. | +| border-radius | <length> | - | No | Radius of round-corner borders. | +| background-color | <color> | - | No | Background color. | +| opacity5+ | number | 1 | No | Opacity of an element. The value ranges from **0** to **1**. The value **1** means opaque, and **0** means completely transparent. | +| display | string | flex | No | How and whether to display the box containing an element. Available values are as follows:
- **flex**: flexible layout
- **none**: not rendered| +| [left\|top] | <length> \| <percentage>6+ | - | No | left\|Edge of the element.
- **left**: left edge position of the element. This attribute defines the offset between the left edge of the margin area of a positioned element and left edge of its containing block.
- **top**: top edge position of the element. This attribute defines the offset between the top edge of a positioned element and that of a block included in the element.| + + +## Methods + +| Name | Parameter | Description | +| -------- | ---- | ---------------------------------------- | +| start | - | Starts to play the frame animation of an image. If this method is called again, the playback starts from the first frame. | +| pause | - | Pauses the frame animation playback of an image. | +| stop | - | Stops the frame animation playback of an image. | +| resume | - | Resumes the frame animation playback of an image. | +| getState | - | Obtains the playback state. Available values are as follows:
- playing
- paused
- stopped| + + +## Example + + +```html + +
+ +
+ + + + +
+
+``` + + +```css +/* xxx.css */ +.container { + flex-direction: column; + justify-content: center; + align-items: center; + left: 0px; + top: 0px; + width: 454px; + height: 454px; +} +.animator { + width: 70px; + height: 70px; +} +.btn-box { + width: 264px; + height: 120px; + flex-wrap: wrap; + justify-content: space-around; + align-items: center; +} +.btn { + border-radius: 8px; + width: 120px; + margin-top: 8px; +} +``` + + +```js +//xxx.js +export default { + data: { + frames: [ + { + src: "/common/asserts/heart78.png", + }, + { + src: "/common/asserts/heart79.png", + }, + { + src: "/common/asserts/heart80.png", + }, + { + src: "/common/asserts/heart81.png", + }, + { + src: "/common/asserts/heart82.png", + }, + { + src: "/common/asserts/heart83.png", + }, + { + src: "/common/asserts/heart84.png", + }, + { + src: "/common/asserts/heart85.png", + }, + { + src: "/common/asserts/heart86.png", + }, + { + src: "/common/asserts/heart87.png", + }, + { + src: "/common/asserts/heart88.png", + }, + { + src: "/common/asserts/heart89.png", + }, + { + src: "/common/asserts/heart90.png", + }, + { + src: "/common/asserts/heart91.png", + }, + { + src: "/common/asserts/heart92.png", + }, + { + src: "/common/asserts/heart93.png", + }, + { + src: "/common/asserts/heart94.png", + }, + { + src: "/common/asserts/heart95.png", + }, + { + src: "/common/asserts/heart96.png", + }, + ], + }, + handleStart() { + this.$refs.animator.start(); + }, + handlePause() { + this.$refs.animator.pause(); + }, + handleResume() { + this.$refs.animator.resume(); + }, + handleStop() { + this.$refs.animator.stop(); + }, +}; +``` + +![image-animator](figures/image-animator.gif) diff --git a/en/application-dev/reference/arkui-js-lite/js-components-basic-image.md b/en/application-dev/reference/arkui-js-lite/js-components-basic-image.md new file mode 100644 index 0000000000000000000000000000000000000000..9dd520dcdeed71f6de216e8d5337d54aec33668d --- /dev/null +++ b/en/application-dev/reference/arkui-js-lite/js-components-basic-image.md @@ -0,0 +1,74 @@ +# image + +The **\** component is used to render and display images. + +> **NOTE** +> +> This component is supported since API version 4. Updates will be marked with a superscript to indicate their earliest API version. + + +## Child Components + +Not supported + + +## Attributes + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| src | string | No|
Image path. The supported image formats include PNG and JPG.| +| id | string | No| Unique ID of the component.| +| style | string | No| Style declaration of the component.| +| class | string | No| Style class of the component, which is used to refer to a style table.| +| ref | string | No| Reference information of child elements, which is registered with the parent component on **$refs**.| + + +## Events + +| Name| Parameter| Description| +| -------- | -------- | -------- | +| click | - | Triggered when the component is clicked. | +| longpress | - | Triggered when the component is long pressed. | +| swipe5+ | [SwipeEvent](js-common-events.md) | Triggered when a user quickly swipes on the component. | + + +## Styles + +| Name| Type| Default Value| Mandatory| Description| +| -------- | -------- | -------- | -------- | -------- | +| width | <length> \| <percentage>5+ | - | No| Component width.

If this attribute is not set, the default value **0** is used.| +| height | <length> \| <percentage>5+ | - | No| Component height.

If this attribute is not set, the default value **0** is used.| +| padding | <length> | 0 | No| Shorthand attribute to set the padding for all sides.
The attribute can have one to four values:
- If you set only one value, it specifies the padding for all the four sides.
- If you set two values, the first value specifies the top and bottom padding, and the second value specifies the left and right padding.
- If you set three values, the first value specifies the top padding, the second value specifies the left and right padding, and the third value specifies the bottom padding.
- If you set four values, they respectively specify the padding for top, right, bottom, and left sides (in clockwise order).| +| padding-[left\|top\|right\|bottom] | <length> | 0 | No| Left, top, right, and bottom padding.| +| margin | <length> \| <percentage>5+ | 0 | No| Shorthand attribute to set the margin for all sides. The attribute can have one to four values:
- If you set only one value, it specifies the margin for all the four sides.
- If you set two values, the first value specifies the top and bottom margins, and the second value specifies the left and right margins.
- If you set three values, the first value specifies the top margin, the second value specifies the left and right margins, and the third value specifies the bottom margin.
- If you set four values, they respectively specify the margin for top, right, bottom, and left sides (in clockwise order).| +| margin-[left\|top\|right\|bottom] | <length> \| <percentage>5+ | 0 | No| Left, top, right, and bottom margins.| +| border-width | <length> | 0 | No| Shorthand attribute to set the margin for all sides.| +| border-color | <color> | black | No| Shorthand attribute to set the color for all borders.| +| border-radius | <length> | - | No| Radius of round-corner borders. | +| background-color | <color> | - | No| Background color.| +| opacity | number | 1 | No| Opacity of an element. The value ranges from **0** to **1**. The value **1** means opaque, and **0** means completely transparent.| +| display | string | flex | No| How and whether to display the box containing an element. Available values are as follows:
- **flex**: flexible layout
- **none**: not rendered| +| [left\|top] | <length> \| <percentage>6+ | - | No| left\|Edge of the element.
- **left**: left edge position of the element. This attribute defines the offset between the left edge of the margin area of a positioned element and left edge of its containing block.
- **top**: top edge position of the element. This attribute defines the offset between the top edge of a positioned element and that of a block included in the element.| + +## Example + +```html + +
+ + +
+``` + +```css +/* xxx.css */ +.container { + justify-content: center; + align-items: center; + flex-direction: column; + width: 100%; + height: 100%; +} +``` + +![image](figures/image.png) diff --git a/en/application-dev/reference/arkui-js-lite/js-components-basic-input.md b/en/application-dev/reference/arkui-js-lite/js-components-basic-input.md new file mode 100644 index 0000000000000000000000000000000000000000..a5770bcd59af1727f250b53ac6f1fe1570b4ff14 --- /dev/null +++ b/en/application-dev/reference/arkui-js-lite/js-components-basic-input.md @@ -0,0 +1,181 @@ +# input + +The **\** component provides an interactive interface to receive user input. It can be a radio button, check box, or button. + +> **NOTE** +> +> This component is supported since API version 4. Updates will be marked with a superscript to indicate their earliest API version. + + +## Child Components + +Not supported + + +## Attributes + +| Name| Type| Default Value| Mandatory| Description| +| -------- | -------- | -------- | -------- | -------- | +| type | string |
button | No| Type of the component, which cannot be dynamically modified. The options are as follows:
- **button**: a button that can be clicked.
- **checkbox**: a check box.
- **radio**: a radio button that allows users to select one from multiple others with the same name. | +| checked | boolean | false | No| Whether the component is selected. This attribute is valid only when **type** is set to **checkbox** or **radio**.| +| name | string | - | No| Name of the component.| +| value | string | - | No| Value of the component. When **type** is **radio**, this attribute is mandatory and the value must be unique for radio buttons with the same name.| +| id | string | - | No| Unique ID of the component.| +| style | string | - | No| Style declaration of the component.| +| class | string | - | No| Style class of the component, which is used to refer to a style table.| +| ref | string | - | No| Reference information of child elements, which is registered with the parent component on **$refs**.| + + +## Events + +- When **type** is set to **checkbox** or **radio**, the following events are supported. + | Name| Parameter| Description| + | -------- | -------- | -------- | + | change | { checked:true \| false } | Triggered when the checked status of the **checkbox** or **radio** button changes.| + | click | - | Triggered when the component is clicked. | + | longpress | - | Triggered when the component is long pressed. | + | swipe5+ | [SwipeEvent](js-common-events.md) | Triggered when a user quickly swipes on the component. | + +- When **type** is set to **button**, the following events are supported. + | Name| Parameter| Description| + | -------- | -------- | -------- | + | click | - | Triggered when the component is clicked. | + | longpress | - | Triggered when the component is long pressed. | + | swipe5+ | [SwipeEvent](js-common-events.md) | Triggered when a user quickly swipes on the component. | + + +## Styles + +| Name| Type| Default Value| Mandatory| Description| +| -------- | -------- | -------- | -------- | -------- | +| color | <color> | \#ffffff | No| Text color of the component.| +| font-size | <length> | 30px | No| Font size of the component.| +| width | <length> | - | No| Width of the component. The default value for a button is **100px**.| +| height | <length> | - | No| Height of the component. The default value for a button is **50px**.| +| font-family | string | SourceHanSansSC-Regular | No| Font. Only the **SourceHanSansSC-Regular** font is supported.| +| padding | <length> | 0 | No| Shorthand attribute to set the padding for all sides.
The attribute can have one to four values:
- If you set only one value, it specifies the padding for all the four sides.
- If you set two values, the first value specifies the top and bottom padding, and the second value specifies the left and right padding.
- If you set three values, the first value specifies the top padding, the second value specifies the left and right padding, and the third value specifies the bottom padding.
- If you set four values, they respectively specify the padding for top, right, bottom, and left sides (in clockwise order).| +| padding-[left\|top\|right\|bottom] | <length> | 0 | No| Left, top, right, and bottom padding.| +| margin | <length> \| <percentage>5+ | 0 | No| Shorthand attribute to set the margin for all sides. The attribute can have one to four values:
- If you set only one value, it specifies the margin for all the four sides.
- If you set two values, the first value specifies the top and bottom margins, and the second value specifies the left and right margins.
- If you set three values, the first value specifies the top margin, the second value specifies the left and right margins, and the third value specifies the bottom margin.
- If you set four values, they respectively specify the margin for top, right, bottom, and left sides (in clockwise order).| +| margin-[left\|top\|right\|bottom] | <length> \| <percentage>5+ | 0 | No| Left, top, right, and bottom margins.| +| border-width | <length> | 0 | No| Shorthand attribute to set the margin for all sides.| +| border-color | <color> | black | No| Shorthand attribute to set the color for all borders.| +| border-radius | <length> | - | No| Radius of round-corner borders. | +| background-color | <color> | - | No| Background color.| +| display | string | flex | No| How and whether to display the box containing an element. Available values are as follows:
- **flex**: flexible layout
- **none**: not rendered| +| [left\|top] | <length> \| <percentage>6+ | - | No| Edge of the element.
- **left**: left edge position of the element. This attribute defines the offset between the left edge of the margin area of a positioned element and left edge of its containing block.
- **top**: top edge position of the element. This attribute defines the offset between the top edge of a positioned element and that of a block included in the element. | + +## Example + +1. Common button + + ```html + +
+ +
+ ``` + + ```css + /* xxx.css */ + .div-button { + flex-direction: column; + align-items: center; + width: 100%; + height: 100%; + } + .button { + margin-top: 30px; + width: 280px; + } + ``` + + ![input-type-button](figures/input-type-button.png) + + + +2. Check box + + ```html + +
+ + {{text}} +
+ ``` + + ```css + /* xxx.css */ + .content{ + width: 100%; + height: 100%; + flex-direction: column; + align-items: center; + justify-content: center; + } + .text{ + font-size: 30px; + text-align: center; + width: 200px; + margin-top: 20px; + height: 100px; + } + ``` + + ```javascript + // xxx.js + export default { + data: { + text: "text" + }, + checkboxOnChange(e) { + this.text = e.checked; + } + } + ``` + + ![input-type-checkbox](figures/input-type-checkbox.gif) + +3. Radio button + + ```html + +
+
+ + radio1 +
+
+ + radio2 +
+
+ + radio3 +
+
+ ``` + + ```css + /* xxx.css */ + .container { + width: 100%; + height: 100%; + justify-content: center; + align-items: center; + flex-direction: column; + } + .item { + width: 50%; + height: 30%; + justify-content: center; + } + .text { + margin-top: 25%; + font-size: 30px; + text-align: center; + width: 200px; + height: 100px; + } + ``` + + ![input-type-radio](figures/input-type-radio.gif) diff --git a/en/application-dev/reference/arkui-js-lite/js-components-basic-marquee.md b/en/application-dev/reference/arkui-js-lite/js-components-basic-marquee.md new file mode 100644 index 0000000000000000000000000000000000000000..8ecc7a2e41d301f03540320244425beacc39a884 --- /dev/null +++ b/en/application-dev/reference/arkui-js-lite/js-components-basic-marquee.md @@ -0,0 +1,118 @@ +# marquee + +The **\** component is used to display a scrolling piece of text. + +> **NOTE** +> +> This component is supported since API version 4. Updates will be marked with a superscript to indicate their earliest API version. + + +## Child Components + +Not supported + + +## Attributes + +| Name| Type| Default Value| Mandatory| Description| +| -------- | -------- | -------- | -------- | -------- | +| scrollamount | number | 6 | No| Maximum length of each scroll.| +| id | string | - | No| Unique ID of the component.| +| style | string | - | No| Style declaration of the component.| +| class | string | - | No| Style class of the component, which is used to refer to a style table.| +| ref | string | - | No| Reference information of child elements, which is registered with the parent component on **$refs**.| + + +## Events + +| Name| Parameter| Description| +| -------- | -------- | -------- | +| click | - | Triggered when the component is clicked. | +| longpress | - | Triggered when the component is long pressed. | +| swipe5+ | [SwipeEvent](js-common-events.md) | Triggered when a user quickly swipes on the component. | + + +## Styles + +| Name| Type| Default Value| Mandatory| Description| +| -------- | -------- | -------- | -------- | -------- | +| color | <color> | \#ffffff


| No| Font color of the scrolling text.| +| font-size | <length> |
30 | No| Font size of the scrolling text.| +| font-family | string |

SourceHanSansSC-Regular | No|

Font. Only the **SourceHanSansSC-Regular** font is supported.| +| width | <length> \| <percentage>5+ | - | No| Component width.

If this attribute is not set, the default value **0** is used.| +| height | <length> \| <percentage>5+ | - | No| Component height.

If this attribute is not set, the default value **0** is used.| +| padding | <length> | 0 | No| Shorthand attribute to set the padding for all sides.
The attribute can have one to four values:
- If you set only one value, it specifies the padding for all the four sides.
- If you set two values, the first value specifies the top and bottom padding, and the second value specifies the left and right padding.
- If you set three values, the first value specifies the top padding, the second value specifies the left and right padding, and the third value specifies the bottom padding.
- If you set four values, they respectively specify the padding for top, right, bottom, and left sides (in clockwise order).| +| padding-[left\|top\|right\|bottom] | <length> | 0 | No| Left, top, right, and bottom padding.| +| margin | <length> \| <percentage>5+ | 0 | No| Shorthand attribute to set the margin for all sides. The attribute can have one to four values:
- If you set only one value, it specifies the margin for all the four sides.
- If you set two values, the first value specifies the top and bottom margins, and the second value specifies the left and right margins.
- If you set three values, the first value specifies the top margin, the second value specifies the left and right margins, and the third value specifies the bottom margin.
- If you set four values, they respectively specify the margin for top, right, bottom, and left sides (in clockwise order).| +| margin-[left\|top\|right\|bottom] | <length> \| <percentage>5+ | 0 | No| Left, top, right, and bottom margins.| +| border-width | <length> | 0 | No| Shorthand attribute to set the margin for all sides.| +| border-color | <color> | black | No| Shorthand attribute to set the color for all borders.| +| border-radius | <length> | - | No| Radius of round-corner borders.| +| background-color | <color> | - | No| Background color.| +| opacity5+ | number | 1 | No| Opacity of an element. The value ranges from **0** to **1**. The value **1** means opaque, and **0** means completely transparent.| +| display | string | flex | No| How and whether to display the box containing an element. Available values are as follows:
- **flex**: flexible layout
- **none**: not rendered| +| [left\|top] | <length> \| <percentage>6+ | - | No| left\|Edge of the element.
- **left**: left edge position of the element. This attribute defines the offset between the left edge of the margin area of a positioned element and left edge of its containing block.
- **top**: top edge position of the element. This attribute defines the offset between the top edge of a positioned element and that of a block included in the element.| + +## Example + +```html + +
+ {{marqueeCustomData}} + speed+ + speed- + changeData +
+``` + +```css +/* xxx.css */ +.container { + flex-direction: column; + width: 100%; + height: 100%; + flex-direction: column; + align-items: center; +} +.customMarquee { + width: 50%; + height: 80px; + padding: 10px; + margin: 20px; + border-width: 4px; + border-color: #ffffff; + border-radius: 20px; + font-size: 38px; +} +.text { + font-size: 30px; + text-align: center; + width: 30%; + height: 10%; + margin-top: 5%; + background-color: #f2f2f2; + border-radius: 40px; + color: #0d81f2; +} +``` + +```javascript +// xxx.js +export default { + data: { + scrollAmount: 30, + marqueeCustomData: 'Custom marquee Custom marquee Custom marquee' + }, + addSpeed() { + this.scrollAmount++; + }, + downSpeed() { + this.scrollAmount--; + }, + changeData() { + this.marqueeCustomData = 'Change Data Change Data Change Data'; + } +} +``` + +![marquee](figures/marquee.gif) diff --git a/en/application-dev/reference/arkui-js-lite/js-components-basic-picker-view.md b/en/application-dev/reference/arkui-js-lite/js-components-basic-picker-view.md new file mode 100644 index 0000000000000000000000000000000000000000..e9dacebc6c419bfaeca6c8aac9c1001e0725bd1f --- /dev/null +++ b/en/application-dev/reference/arkui-js-lite/js-components-basic-picker-view.md @@ -0,0 +1,145 @@ +# picker-view + +The **\** component provides the view that shows an embedded scrollable selector on the screen. + +> **NOTE** +> +> This component is supported since API version 4. Updates will be marked with a superscript to indicate their earliest API version. + + +## Child Components + +Not supported + + +## Attributes + +| Name| Type| Default Value| Mandatory| Description| +| -------- | -------- | -------- | -------- | -------- | +| type | string | text | No| Type of the scrollable selector, which cannot be changed dynamically. Available values are as follows:
- **text**: text selector.
- **time**: time selector.| +| id | string | - | No| Unique ID of the component.| +| style | string | - | No| Style declaration of the component.| +| class | string | - | No| Style class of the component, which is used to refer to a style table.| +| ref | string | - | No| Reference information of child elements, which is registered with the parent component on **$refs**.| + +Text selector (**type** is **text**) + +| Name| Type| Default Value| Mandatory| Description| +| -------- | -------- | -------- | -------- | -------- | +| range | Array | - | No| Value range of the text selector.
Use data binding, for example, **range = {{data}}**, to specify the range. Declare the corresponding variable in the JavaScript: **data: ["15", "20", "25"]**.| +| selected | string | 0 | No| Default value of the text selector. The value is the index of **range**.| + +Time selector (**type** is **time**) + +| Name| Type| Default Value| Mandatory| Description| +| -------- | -------- | -------- | -------- | -------- | +| selected | string | 00:00 | No| Default value of the time selector, in the format of HH:mm.
| + + +## Events + +Text selector (**type** is **text**) + +| Name| Parameter| Description| +| -------- | -------- | -------- | +| change | { newValue: newValue, newSelected: newSelected } | Triggered when a value is specified for the text selector.| + +Time selector (**type** is **time**) + +| Name| Parameter| Description| +| -------- | -------- | -------- | +| change | { hour: hour, minute: minute} | Triggered when a value is specified for the time selector. | + + +## Styles + +| Name| Type| Default Value| Mandatory| Description| +| -------- | -------- | -------- | -------- | -------- | +| color | <color> | \#808080 | No| Font color of a candidate item.| +| font-size | <length> | 30px | No| Font size of a candidate item. The value is of the length type, in pixels.| +| selected-color | <color> | \#ffffff | No| Font color of the selected item.| +| selected-font-size | <length> | 38px | No| Font size of the selected item. The value is of the length type, in pixels.| +| selected-font-family | string | HYQiHei-65S | No| Font type of the selected item.| +| font-family | string | HYQiHei-65S | No| Font type of an item.| +| width | <length> \| <percentage>5+ | - | No| Component width.
If this attribute is not set, the default value **0** is used. | +| height | <length> \| <percentage>5+ | - | No| Component height.
If this attribute is not set, the default value **0** is used. | +| padding | <length> | 0 | No| Shorthand attribute to set the padding for all sides.
The attribute can have one to four values:
- If you set only one value, it specifies the padding for all the four sides.
- If you set two values, the first value specifies the top and bottom padding, and the second value specifies the left and right padding.
- If you set three values, the first value specifies the top padding, the second value specifies the left and right padding, and the third value specifies the bottom padding.
- If you set four values, they respectively specify the padding for top, right, bottom, and left sides (in clockwise order).| +| padding-[left\|top\|right\|bottom] | <length> | 0 | No| Left, top, right, and bottom padding.| +| margin | <length> \| <percentage>5+ | 0 | No| Shorthand attribute to set the margin for all sides. The attribute can have one to four values:
- If you set only one value, it specifies the margin for all the four sides.
- If you set two values, the first value specifies the top and bottom margins, and the second value specifies the left and right margins.
- If you set three values, the first value specifies the top margin, the second value specifies the left and right margins, and the third value specifies the bottom margin.
- If you set four values, they respectively specify the margin for top, right, bottom, and left sides (in clockwise order).| +| margin-[left\|top\|right\|bottom] | <length> \| <percentage>5+ | 0 | No| Left, top, right, and bottom margins.| +| border-width | <length> | 0 | No| Shorthand attribute to set the margin for all sides.| +| border-color | <color> | black | No| Shorthand attribute to set the color for all borders.| +| border-radius | <length> | - | No| Radius of round-corner borders.| +| background-color | <color> | - | No| Background color.| +| display | string | flex | No| How and whether to display the box containing an element. Available values are as follows:
- **flex**: flexible layout
- **none**: not rendered| +| [left\|top] | <length> \| <percentage>6+ | - | No| Edge of the element.
- **left**: left edge position of the element. This attribute defines the offset between the left edge of the margin area of a positioned element and left edge of its containing block.
- **top**: top edge position of the element. This attribute defines the offset between the top edge of a positioned element and that of a block included in the element. | + + +## Example + + +```html + +
+ + Selected: {{time}} + + +
+``` + + +```css +/* xxx.css */ +.container { + flex-direction: column; + justify-content: center; + align-items: center; + left: 0px; + top: 0px; + width: 454px; + height: 454px; +} +.title { + font-size: 30px; + text-align: center; +} +.time-picker { + width: 500px; + height: 400px; + margin-top: 20px; +} +``` + + +```js +/* xxx.js */ +export default { + data: { + defaultTime: "", + time: "", + }, + onInit() { + this.defaultTime = this.now(); + }, + handleChange(data) { + this.time = this.concat(data.hour, data.minute); + }, + now() { + const date = new Date(); + const hours = date.getHours(); + const minutes = date.getMinutes(); + return this.concat(hours, minutes); + }, + + fill(value) { + return (value > 9 ? "" : "0") + value; + }, + + concat(hours, minutes) { + return `${this.fill(hours)}:${this.fill(minutes)}`; + }, +} +``` + +![picker-view](figures/picker-view.png) diff --git a/en/application-dev/reference/arkui-js-lite/js-components-basic-progress.md b/en/application-dev/reference/arkui-js-lite/js-components-basic-progress.md new file mode 100644 index 0000000000000000000000000000000000000000..740bc136bc0a506cc6f28f883424fb2a62b15504 --- /dev/null +++ b/en/application-dev/reference/arkui-js-lite/js-components-basic-progress.md @@ -0,0 +1,125 @@ +# progress + +The **\** component is used to provide a progress bar that displays the progress of content loading or an operation. + +> **NOTE** +> +> This component is supported since API version 4. Updates will be marked with a superscript to indicate their earliest API version. + + +## Child Components + +Not supported + + +## Attributes + +| Name| Type| Default Value| Mandatory| Description| +| -------- | -------- | -------- | -------- | -------- | +| type | string | horizontal | No| Type of the progress bar, which cannot be changed dynamically. Available values are as follows:
- **horizontal**: linear progress bar.
- **arc**: arc progress bar.| +| id | string | - | No| Unique ID of the component.| +| style | string | - | No| Style declaration of the component.| +| class | string | - | No| Style class of the component, which is used to refer to a style table.| +| ref | string | - | No| Reference information of child elements, which is registered with the parent component on **$refs**.| + +Different types of progress bars support different attributes. + +- When **type** is set to **horizontal**, the following attributes are supported. + | Name| Type| Default Value| Mandatory| Description| + | -------- | -------- | -------- | -------- | -------- | + | percent | number | 0 | No| Current progress. The value ranges from 0 to 100.| + +- When **type** is set to **arc**, the following attributes are supported. + | Name| Type| Default Value| Mandatory| Description| + | -------- | -------- | -------- | -------- | -------- | + | percent | number | 0 | No| Current progress. The value ranges from 0 to 100.| + + +## Events + +| Name| Parameter| Description| +| -------- | -------- | -------- | +| click | - | Triggered when the component is clicked. | +| longpress | - | Triggered when the component is long pressed. | +| swipe5+ | [SwipeEvent](js-common-events.md) | Triggered when a user quickly swipes on the component. | + + +## Styles + +- When **type** is set to **horizontal**, the following styles are supported. + + | Name | Type | Default Value | Mandatory| Description | + | ------------ | -------------- | ---------------------------------------------- | ---- | ------------------ | + | color | <color> | \#6b9ac7 | No | Color of the progress bar.| + | stroke-width | <length> | 321-4 \| 45+px | No | Stroke width of the progress bar.| + +- When **type** is set to **arc**, the following styles are supported. + + | Name | Type | Default Value| Mandatory| Description | + | ---------------- | -------------- | ------ | ---- | ------------------------------------------------------------ | + | color | <color> | - | No | Color of the arc progress bar. | + | background-color | <color> | - | No | Background color of the arc progress bar. | + | stroke-width | <length> | - | No | Width of the arc progress bar.
A larger width value means that the progress bar is closer to the center of the circle. The width is always within the radius range.| + | start-angle | <deg> | 240 | No | Start angle of the arc progress bar, which starts from the direction of zero o'clock. The value ranges from 0 to 360 degrees (clockwise).| + | total-angle | <deg> | 240 | No | Total length of the arc progress bar. The value ranges from –360 to 360. A negative number indicates anticlockwise.| + | center-x | <length> | - | No | Center of the arc progress bar (with the upper left corner of this widget as the coordinate origin). This style must be used together with **center-y** and **radius**.| + | center-y | <length> | - | No | Center of the arc progress bar (with the upper left corner of this widget as the coordinate origin). This style must be used together with **center-x** and **radius**.| + | radius | <length> | - | No | Radius of the arc progress bar. This style must be used together with **center-x** and **center-y**. | + +In addition to the preceding styles, the following styles are supported. + +| Name| Type| Default Value| Mandatory| Description| +| -------- | -------- | -------- | -------- | -------- | +| width | <length> \| <percentage>5+ | - | No| Component width.
If this attribute is not set, the default value **0** is used.| +| height | <length> \| <percentage>5+ | - | No| Component height.
If this attribute is not set, the default value **0** is used.| +| padding | <length> | 0 | No| Shorthand attribute to set the padding for all sides.
The attribute can have one to four values:
- If you set only one value, it specifies the padding for all the four sides.
- If you set two values, the first value specifies the top and bottom padding, and the second value specifies the left and right padding.
- If you set three values, the first value specifies the top padding, the second value specifies the left and right padding, and the third value specifies the bottom padding.
- If you set four values, they respectively specify the padding for top, right, bottom, and left sides (in clockwise order).| +| padding-[left\|top\|right\|bottom] | <length> | 0 | No| Left, top, right, and bottom padding.| +| margin | <length> \| <percentage>5+ | 0 | No| Shorthand attribute to set the margin for all sides. The attribute can have one to four values:
- If you set only one value, it specifies the margin for all the four sides.
- If you set two values, the first value specifies the top and bottom margins, and the second value specifies the left and right margins.
- If you set three values, the first value specifies the top margin, the second value specifies the left and right margins, and the third value specifies the bottom margin.
- If you set four values, they respectively specify the margin for top, right, bottom, and left sides (in clockwise order).| +| margin-[left\|top\|right\|bottom] | <length> \| <percentage>5+ | 0 | No| Left, top, right, and bottom margins.| +| border-width | <length> | 0 | No| Shorthand attribute to set the margin for all sides.| +| border-color | <color> | black | No| Shorthand attribute to set the color for all borders.| +| border-radius | <length> | - | No| Radius of round-corner borders.| +| display | string | flex | No| How and whether to display the box containing an element. Available values are as follows:
- **flex**: flexible layout
- **none**: not rendered| +| [left\|top] | <length> \| <percentage>6+ | - | No| Edge of the element.
- **left**: left edge position of the element. This attribute defines the offset between the left edge of the margin area of a positioned element and left edge of its containing block.
- **top**: top edge position of the element. This attribute defines the offset between the top edge of a positioned element and that of a block included in the element. | + +## Example + +```html + +
+ + +
+``` + +```css +/* xxx.css */ +.container { + flex-direction: column; + height: 100%; + width: 100%; + align-items: center; +} +.min-progress { + width: 300px; + height: 300px; +} +``` + +```javascript +// xxx.js +export default { + data: { + arcVal: 0, + horizontalVal: 0 + }, + changeArc() { + this.arcVal+= 10; + }, + changeHorizontal() { + this.horizontalVal+= 10; + } +} +``` + +![progress](figures/progress.png) diff --git a/en/application-dev/reference/arkui-js-lite/js-components-basic-qrcode.md b/en/application-dev/reference/arkui-js-lite/js-components-basic-qrcode.md new file mode 100644 index 0000000000000000000000000000000000000000..16ef26d1b4263b0217c9fedfc8f04016fe7175db --- /dev/null +++ b/en/application-dev/reference/arkui-js-lite/js-components-basic-qrcode.md @@ -0,0 +1,125 @@ +# qrcode + + +The **\** component is used to generate and display a QR code. + +> **NOTE** +> +> This component is supported since API version 5. Updates will be marked with a superscript to indicate their earliest API version. + + +## Child Components + +Not supported + + +## Attributes + +| Name| Type| Default Value| Mandatory| Description| +| -------- | -------- | -------- | -------- | -------- | +| value | string | - | Yes| Content used to generate the QR code. The maximum length is 256.| +| id | string | - | No| Unique ID of the component.| +| style | string | - | No| Style declaration of the component.| +| class | string | - | No| Style class of the component, which is used to refer to a style table.| +| ref | string | - | No| Reference information of child elements, which is registered with the parent component on **$refs**.| + + +## Events + +| Name| Parameter| Description| +| -------- | -------- | -------- | +| click | - | Triggered when the component is clicked. | +| longpress | - | Triggered when the component is long pressed. | +| swipe5+ | [SwipeEvent](js-common-events.md) | Triggered when a user quickly swipes on the component. | + + +## Styles + +| Name| Type| Default Value| Mandatory| Description| +| -------- | -------- | -------- | -------- | -------- | +| color | <color> | \#000000 | No| Color of the QR code.| +| background-color | <color> | \#ffffff | No| Background color of the QR code.| +| width | <length> \| <percentage>5+ | - | No| Component width.
If this attribute is not set, the default value **0** is used. | +| height | <length> \| <percentage>5+ | - | No| Component height.
If this attribute is not set, the default value **0** is used. | +| padding | <length> | 0 | No| Shorthand attribute to set the padding for all sides.
The attribute can have one to four values:
- If you set only one value, it specifies the padding for all the four sides.
- If you set two values, the first value specifies the top and bottom padding, and the second value specifies the left and right padding.
- If you set three values, the first value specifies the top padding, the second value specifies the left and right padding, and the third value specifies the bottom padding.
- If you set four values, they respectively specify the padding for top, right, bottom, and left sides (in clockwise order).| +| padding-[left\|top\|right\|bottom] | <length> | 0 | No| Left, top, right, and bottom padding.| +| margin | <length> \| <percentage>5+ | 0 | No| Shorthand attribute to set the margin for all sides. The attribute can have one to four values:
- If you set only one value, it specifies the margin for all the four sides.
- If you set two values, the first value specifies the top and bottom margins, and the second value specifies the left and right margins.
- If you set three values, the first value specifies the top margin, the second value specifies the left and right margins, and the third value specifies the bottom margin.
- If you set four values, they respectively specify the margin for top, right, bottom, and left sides (in clockwise order).| +| margin-[left\|top\|right\|bottom] | <length> \| <percentage>5+ | 0 | No| Left, top, right, and bottom margins.| +| border-width | <length> | 0 | No| Shorthand attribute to set the margin for all sides.| +| border-color | <color> | black | No| Shorthand attribute to set the color for all borders.| +| border-radius | <length> | - | No| Radius of round-corner borders.| +| display | string | flex | No| How and whether to display the box containing an element. Available values are as follows:
- **flex**: flexible layout
- **none**: not rendered| +| [left\|top] | <length> \| <percentage>6+ | - | No| Edge of the element.
- **left**: left edge position of the element. This attribute defines the offset between the left edge of the margin area of a positioned element and left edge of its containing block.
- **top**: top edge position of the element. This attribute defines the offset between the top edge of a positioned element and that of a block included in the element. | + +> **NOTE** +> - If the values of **width** and **height** are different, the smaller value is used as the length of the QR code. The generated QR code is center displayed. +> +>- The minimum values of **width** and **height** are 200 px. + + +## Example + + +```html + +
+ + Color + BackgroundColor + Value +
+``` + +```css +/* xxx.css */ +.container { + width: 100%; + height: 100%; + flex-direction: column; + justify-content: center; + align-items: center; +} +.qrCode { + width: 200px; + height: 200px; +} +.button { + width: 30%; + height: 10%; + margin-top: 5%; +} +``` + +```javascript +// xxx.js +export default { + data: { + qr_col: '#87ceeb', + qr_bcol: '#f0ffff', + qr_value: 'value' + }, + changeColor() { + if (this.qr_col == '#87ceeb') { + this.qr_col = '#fa8072'; + } else { + this.qr_col = '#87ceeb'; + } + }, + changeBackgroundColor() { + if (this.qr_bcol == '#f0ffff') { + this.qr_bcol = '#ffffe0'; + } else { + this.qr_bcol = '#f0ffff'; + } + }, + changeValue() { + if (this.qr_value == 'value') { + this.qr_value = 'change'; + } else { + this.qr_value = 'value'; + } + } +} +``` + +![qrcode](figures/qrcode.gif) diff --git a/en/application-dev/reference/arkui-js-lite/js-components-basic-slider.md b/en/application-dev/reference/arkui-js-lite/js-components-basic-slider.md new file mode 100644 index 0000000000000000000000000000000000000000..14a1804c4b47d769b5020fb820ac768a3f434316 --- /dev/null +++ b/en/application-dev/reference/arkui-js-lite/js-components-basic-slider.md @@ -0,0 +1,102 @@ +# slider + +The **\** component is used to quickly adjust settings, such as the volume and brightness. + +> **NOTE** +> +> This component is supported since API version 4. Updates will be marked with a superscript to indicate their earliest API version. + + +## Child Components + +Not supported + + +## Attributes + +| Name | Type | Default Value | Mandatory | Description | +| ----- | ------ | ---- | ---- | ---------------------------------------- | +| min | number | 0 | No | Minimum value of the slider. | +| max | number | 100 | No | Maximum value of the slider. | +| value | number | 0 | No | Initial value of the slider. | +| id | string | - | No | Unique ID of the component. | +| style | string | - | No | Style declaration of the component. | +| class | string | - | No | Style class of the component, which is used to refer to a style table. | +| ref | string | - | No | Reference information of child elements, which is registered with the parent component on **$refs**.| + + +## Events + +| Name | Parameter | Description | +| ------------------ | --------------------------------- | -------------- | +| change | ChangeEvent | Triggered when the value changes.| +| click | - | Triggered when the component is clicked. | +| longpress | - | Triggered when the component is long pressed. | +| swipe5+ | [SwipeEvent](js-common-events.md) | Triggered when a user quickly swipes on the component. | + + **Table 1** ChangeEvent + +| Attribute | Type | Description | +| ---------------------------------------- | ------ | ------------- | +| progress(deprecated5+) | string | Current value of the slider.| +| value5+ | number | Current value of the slider.| + + +## Styles + +| Name | Type | Default Value | Mandatory | Description | +| ---------------------------------- | ---------------------------------------- | -------- | ---- | ---------------------------------------- | +| color | <color> | \#000000 | No | Background color of the slider. | +| selected-color | <color> | \#ffffff | No | Selected color of the slider. | +| width | <length> \| <percentage>5+ | - | No | Component width.
If this attribute is not set, the default value **0** is used. | +| height | <length> \| <percentage>5+ | - | No | Component height.
If this attribute is not set, the default value **0** is used. | +| padding | <length> | 0 | No | Shorthand attribute to set the padding for all sides.
The attribute can have one to four values:
- If you set only one value, it specifies the padding for all the four sides.
- If you set two values, the first value specifies the top and bottom padding, and the second value specifies the left and right padding.
- If you set three values, the first value specifies the top padding, the second value specifies the left and right padding, and the third value specifies the bottom padding.
- If you set four values, they respectively specify the padding for top, right, bottom, and left sides (in clockwise order).| +| padding-[left\|top\|right\|bottom] | <length> | 0 | No | Left, top, right, and bottom padding. | +| margin | <length> \| <percentage>5+ | 0 | No | Shorthand attribute to set the margin for all sides. The attribute can have one to four values:
- If you set only one value, it specifies the margin for all the four sides.
- If you set two values, the first value specifies the top and bottom margins, and the second value specifies the left and right margins.
- If you set three values, the first value specifies the top margin, the second value specifies the left and right margins, and the third value specifies the bottom margin.
- If you set four values, they respectively specify the margin for top, right, bottom, and left sides (in clockwise order).| +| margin-[left\|top\|right\|bottom] | <length> \| <percentage>5+ | 0 | No | Left, top, right, and bottom margins. | +| border-width | <length> | 0 | No | Shorthand attribute to set the margin for all sides. | +| border-color | <color> | black | No | Shorthand attribute to set the color for all borders. | +| border-radius | <length> | - | No | Radius of round-corner borders. | +| background-color | <color> | - | No | Background color. | +| display | string | flex | No | How and whether to display the box containing an element. Available values are as follows:
- **flex**: flexible layout
- **none**: not rendered| +| [left\|top] | <length> \| <percentage>6+ | - | No | Edge of the element.
- **left**: left edge position of the element. This attribute defines the offset between the left edge of the margin area of a positioned element and left edge of its containing block.
- **top**: top edge position of the element. This attribute defines the offset between the top edge of a positioned element and that of a block included in the element.| + +## Example + +```html + +
+ slider start value is {{startValue}} + slider current value is {{currentValue}} + slider end value is {{endValue}} + +
+``` + +```css +/* xxx.css */ +.container { + flex-direction: column; + justify-content: center; + align-items: center; + width: 100%; + height: 100%; +} +``` + +```javascript +// xxx.js +export default { + data: { + value: 0, + startValue: 0, + currentValue: 0, + endValue: 100, + }, + setvalue(e) { + this.currentValue = e.value; + } +} +``` + +![slider](figures/slider.png) diff --git a/en/application-dev/reference/arkui-js-lite/js-components-basic-switch.md b/en/application-dev/reference/arkui-js-lite/js-components-basic-switch.md new file mode 100644 index 0000000000000000000000000000000000000000..42b4bddc549dcda654c2925d164e2eada3190910 --- /dev/null +++ b/en/application-dev/reference/arkui-js-lite/js-components-basic-switch.md @@ -0,0 +1,99 @@ +# switch + +The **\** component is used to enable or disable a function. + +> **NOTE** +> +> This component is supported since API version 4. Updates will be marked with a superscript to indicate their earliest API version. + + +## Child Components + +Not supported + + +## Attributes + +| Name| Type| Default Value| Mandatory| Description| +| -------- | -------- | -------- | -------- | -------- | +| checked | boolean | false | No| Whether the component is checked or not.| +| id | string | - | No| Unique ID of the component.| +| style | string | - | No| Style declaration of the component.| +| class | string | - | No| Style class of the component, which is used to refer to a style table.| +| ref | string | - | No| Reference information of child elements, which is registered with the parent component on **$refs**.| + + +## Events + +| Name| Parameter| Description| +| -------- | -------- | -------- | +| change | { checked: checkedValue } | Triggered when the **checked** state changes.| +| click | - | Triggered when the component is clicked. | +| longpress | - | Triggered when the component is long pressed. | +| swipe5+ | [SwipeEvent](js-common-events.md) | Triggered when a user quickly swipes on the component. | + + +## Styles + +| Name| Type| Default Value| Mandatory| Description| +| -------- | -------- | -------- | -------- | -------- | +| width | <length> \| <percentage>5+ | - | No| Component width.

If this attribute is not set, the default value **0** is used.| +| height | <length> \| <percentage>5+ | - | No| Component height.

If this attribute is not set, the default value **0** is used.| +| padding | <length> | 0 | No| Shorthand attribute to set the padding for all sides.
The attribute can have one to four values:
- If you set only one value, it specifies the padding for all the four sides.
- If you set two values, the first value specifies the top and bottom padding, and the second value specifies the left and right padding.
- If you set three values, the first value specifies the top padding, the second value specifies the left and right padding, and the third value specifies the bottom padding.
- If you set four values, they respectively specify the padding for top, right, bottom, and left sides (in clockwise order).| +| padding-[left\|top\|right\|bottom] | <length> | 0 | No| Left, top, right, and bottom padding.| +| margin | <length> \| <percentage>5+ | 0 | No| Shorthand attribute to set the margin for all sides. The attribute can have one to four values:
- If you set only one value, it specifies the margin for all the four sides.
- If you set two values, the first value specifies the top and bottom margins, and the second value specifies the left and right margins.
- If you set three values, the first value specifies the top margin, the second value specifies the left and right margins, and the third value specifies the bottom margin.
- If you set four values, they respectively specify the margin for top, right, bottom, and left sides (in clockwise order).| +| margin-[left\|top\|right\|bottom] | <length> \| <percentage>5+ | 0 | No| Left, top, right, and bottom margins.| +| border-width | <length> | 0 | No| Shorthand attribute to set the margin for all sides.| +| border-color | <color> | black | No| Shorthand attribute to set the color for all borders.| +| border-radius | <length> | - | No| Radius of round-corner borders.| +| background-color | <color> | - | No| Background color.| +| display | string | flex | No| How and whether to display the box containing an element. Available values are as follows:
- **flex**: flexible layout
- **none**: not rendered| +| [left\|top] | <length> \| <percentage>6+ | - | No| left\|Edge of the element.
- **left**: left edge position of the element. This attribute defines the offset between the left edge of the margin area of a positioned element and left edge of its containing block.
- **top**: top edge position of the element. This attribute defines the offset between the top edge of a positioned element and that of a block included in the element.| + +## Example + +```html + +
+
+ + {{title}} +
+
+``` + +```css +/* xxx.css */ +.container { + width: 100%; + height: 100%; + justify-content: center; + align-items: center; +} +.box{ + width: 18%; + height: 25%; + flex-direction:column; + justify-content: center; + align-items: center; +} +``` + +```javascript +// xxx.js +export default { + data: { + title: 'on' + }, + switchChange(e){ + console.log(e.checked); + if(e.checked){ + this.title="on" + }else{ + this.title="off" + } + } +} +``` + +![switch](figures/switch.gif) diff --git a/en/application-dev/reference/arkui-js-lite/js-components-basic-text.md b/en/application-dev/reference/arkui-js-lite/js-components-basic-text.md new file mode 100644 index 0000000000000000000000000000000000000000..bfb0c1fb8349b5e43c0aabea1b78c62adad8816d --- /dev/null +++ b/en/application-dev/reference/arkui-js-lite/js-components-basic-text.md @@ -0,0 +1,98 @@ +# text + +The **\** component is used to display a piece of textual information. + +> **NOTE** +> +> This component is supported since API version 4. Updates will be marked with a superscript to indicate their earliest API version. + + +## Child Components + +Not supported + + +## Attributes + +| Name| Type| Default Value| Mandatory| Description| +| -------- | -------- | -------- | -------- | -------- | +| id | string | - | No| Unique ID of the component.| +| style | string | - | No| Style declaration of the component.| +| class | string | - | No| Style class of the component, which is used to refer to a style table.| +| ref | string | - | No| Reference information of child elements, which is registered with the parent component on **$refs**.| + + +## Events + +| Name| Parameter| Description| +| -------- | -------- | -------- | +| click | - | Triggered when the component is clicked.| +| longpress | - | Triggered when the component is long pressed.| +| swipe5+ | [SwipeEvent](js-common-events.md) | Triggered when a user quickly swipes on the component.| + + +## Styles + +| Name| Type| Default Value| Mandatory| Description| +| -------- | -------- | -------- | -------- | -------- | +| color | <color> | \#ffffff | No| Font color.| +| font-size | <length> | 30px | No| Font size. | +| letter-spacing | <length> | 2px | No| Character spacing (px).| +| text-align | string | left | No| Text alignment mode. Available values are as follows:
- **left**: The text is left-aligned.
- **center**: The text is center-aligned.
- **right**: The text is right-aligned.| +| text-overflow | string | clip | No| Available values are as follows:
- **clip**: The text is clipped and displayed based on the size of the parent container.
- **ellipsis**: The text is displayed based on the size of the parent container. The text that cannot be displayed is replaced with ellipsis.| +| font-family | string | SourceHanSansSC-Regular | No| Font. Only the **SourceHanSansSC-Regular** font is supported.| +| width | <length> \| <percentage>5+ | 0px | No| Component width.
Unit: pixel
If this attribute is not set, the default value **0** is used.| +| height | <length> \| <percentage>5+ | 0px | No| Component height.
Unit: pixel
If this attribute is not set, the default value **0** is used.| +| padding | <length> | 0 | No| Shorthand attribute to set the padding for all sides.
The attribute can have one to four values:
- If you set only one value, it specifies the padding for all the four sides.
- If you set two values, the first value specifies the top and bottom padding, and the second value specifies the left and right padding.
- If you set three values, the first value specifies the top padding, the second value specifies the left and right padding, and the third value specifies the bottom padding.
- If you set four values, they respectively specify the padding for top, right, bottom, and left sides (in clockwise order).| +| padding-[left\|top\|right\|bottom] | <length> | 0 | No| Left, top, right, and bottom padding.| +| margin | <length> \| <percentage>5+ | 0 | No| Shorthand attribute to set the margin for all sides. The attribute can have one to four values:
- If you set only one value, it specifies the margin for all the four sides.
- If you set two values, the first value specifies the top and bottom margins, and the second value specifies the left and right margins.
- If you set three values, the first value specifies the top margin, the second value specifies the left and right margins, and the third value specifies the bottom margin.
- If you set four values, they respectively specify the margin for top, right, bottom, and left sides (in clockwise order).| +| margin-[left\|top\|right\|bottom] | <length> \| <percentage>5+ | 0 | No| Left, top, right, and bottom margins.| +| border-width | <length> | 0 | No| Shorthand attribute to set the margin for all sides.| +| border-color | <color> | black | No| Shorthand attribute to set the color for all borders.| +| border-radius | <length> | - | No| Radius of round-corner borders.| +| background-color | <color> | - | No| Background color.| +| opacity5+ | number | 1 | No| Opacity of an element. The value ranges from **0** to **1**. The value **1** means opaque, and **0** means completely transparent.| +| display | string | flex | No| How and whether to display the box containing an element. Available values are as follows:
- **flex**: flexible layout
- **none**: not rendered| +| [left\|top] | <length> \| <percentage>6+ | - | No| Edge of the element.
- **left**: left edge position of the element. This attribute defines the offset between the left edge of the margin area of a positioned element and left edge of its containing block.
- **top**: top edge position of the element. This attribute defines the offset between the top edge of a positioned element and that of a block included in the element. | + +## Example + +```html + +
+ + Hello {{ title }} + +
+``` + +```CSS +/* xxx.css */ +.container { + width: 100%; + height: 100%; + justify-content: center; + align-items: center; +} + +.title { + width: 100px; + font-size: 30px; + text-align: center; + color: red; +} +``` + +```javascript +// xxx.js +export default { + data: { + title: "" + }, + onInit() { + this.title = "World"; + } +} +``` + +![text](figures/text.png) diff --git a/en/application-dev/reference/arkui-js-lite/js-components-canvas-canvas.md b/en/application-dev/reference/arkui-js-lite/js-components-canvas-canvas.md new file mode 100644 index 0000000000000000000000000000000000000000..58b8642f8acb1adafb2a10242c8eee6ef850523b --- /dev/null +++ b/en/application-dev/reference/arkui-js-lite/js-components-canvas-canvas.md @@ -0,0 +1,55 @@ +# canvas + +The **\** component is used for customizing drawings. + +> **NOTE** +> +> This component is supported since API version 5. Updates will be marked with a superscript to indicate their earliest API version. + + +## Child Components + +Not supported + + +## Attributes + +| Name| Type| Default Value| Mandatory| Description| +| -------- | -------- | -------- | -------- | -------- | +| id | string | - | No| Unique ID of the component.| +| style | string | - | No| Style declaration of the component.| +| class | string | - | No| Style class of the component, which is used to refer to a style table.| +| ref | string | - | No| Reference information of child elements, which is registered with the parent component on **$refs**.| + + +## Events + +| Name| Parameter| Description| +| -------- | -------- | -------- | +| click | - | Triggered when the component is clicked.| +| longpress | - | Triggered when the component is long pressed.| +| swipe5+ | [SwipeEvent](js-common-events.md) | Triggered when a user quickly swipes on the component.| + + +## Styles + +| Name| Type| Default Value| Mandatory| Description| +| -------- | -------- | -------- | -------- | -------- | +| width | <length> \| <percentage>5+ | - | No| Component width.
If this attribute is not set, the default value **0** is used. | +| height | <length> \| <percentage>5+ | - | No| Component height.
If this attribute is not set, the default value **0** is used. | +| padding | <length> | 0 | No| Shorthand attribute to set the padding for all sides.
The attribute can have one to four values:
- If you set only one value, it specifies the padding for all the four sides.
- If you set two values, the first value specifies the top and bottom padding, and the second value specifies the left and right padding.
- If you set three values, the first value specifies the top padding, the second value specifies the left and right padding, and the third value specifies the bottom padding.
- If you set four values, they respectively specify the padding for top, right, bottom, and left sides (in clockwise order).| +| margin | <length> \| <percentage>5+ | 0 | No| Shorthand attribute to set the margin for all sides. The attribute can have one to four values:
- If you set only one value, it specifies the margin for all the four sides.
- If you set two values, the first value specifies the top and bottom margins, and the second value specifies the left and right margins.
- If you set three values, the first value specifies the top margin, the second value specifies the left and right margins, and the third value specifies the bottom margin.
- If you set four values, they respectively specify the margin for top, right, bottom, and left sides (in clockwise order).| +| margin-[left\|top\|right\|bottom] | <length> \| <percentage>5+ | 0 | No| Left, top, right, and bottom margins.| +| border-width | <length> | 0 | No| Shorthand attribute to set the margin for all sides.| +| border-color | <color> | black | No| Shorthand attribute to set the color for all borders.| +| border-radius | <length> | - | No| Radius of round-corner borders.| +| background-color | <color> | - | No| Background color.| +| display | string | flex | No| How and whether to display the box containing an element. Available values are as follows:
- **flex**: flexible layout
- **none**: not rendered| +| [left\|top] | <length> \| <percentage>6+ | - | No| Edge of the element.
- **left**: left edge position of the element. This attribute defines the offset between the left edge of the margin area of a positioned element and left edge of its containing block.
- **top**: top edge position of the element. This attribute defines the offset between the top edge of a positioned element and that of a block included in the element. | + + +## Methods + +| Name| Parameter| Description| +| -------- | -------- | -------- | +| getContext | string | Obtains the context of the drawing on a canvas. The parameter can be set only to **2d**. The return value is a 2D drawing object that provides specific 2D drawing operations. For details, see [CanvasRenderingContext2D](js-components-canvas-canvasrenderingcontext2d.md).| diff --git a/en/application-dev/reference/arkui-js-lite/js-components-canvas-canvasrenderingcontext2d.md b/en/application-dev/reference/arkui-js-lite/js-components-canvas-canvasrenderingcontext2d.md new file mode 100644 index 0000000000000000000000000000000000000000..1e5a349bff3f2fa7bf97fcefd67601a36bb3bb8a --- /dev/null +++ b/en/application-dev/reference/arkui-js-lite/js-components-canvas-canvasrenderingcontext2d.md @@ -0,0 +1,365 @@ +# CanvasRenderingContext2D + + +**CanvasRenderingContext2D** allows you to draw rectangles and text on a canvas. + +**Example** + +```html + + + + +``` + + +```javascript +// xxx.js +export default { + handleClick() { + const el = this.$refs.canvas1; + const ctx = el.getContext('2d'); + ctx.beginPath(); + ctx.arc(100, 75, 50, 0, 6.28); + ctx.stroke(); + }, +} +``` + + ![en-us_image_0000001431548113](figures/en-us_image_0000001431548113.png) + + +## fillRect() + +Fills a rectangle on the canvas. + +**Parameters** + +| Parameter| Type| Description| +| -------- | -------- | -------- | +| x | number | X-coordinate of the upper left corner of the rectangle.| +| y | number | Y-coordinate of the upper left corner of the rectangle.| +| width | number | Width of the rectangle.| +| height | number | Height of the rectangle.| + +**Example** + + ![en-us_image_0000001431388525](figures/en-us_image_0000001431388525.png) + + + ```javascript + ctx.fillRect(20, 20, 200, 150); + ``` + + +## fillStyle + +Sets the style to fill an area. + +**Parameters** + +| Parameter| Type| Description| +| -------- | -------- | -------- | +| color | <color> | Color used to fill the area| + +**Example** + + ![en-us_image_0000001431388505](figures/en-us_image_0000001431388505.png) + + + ```javascript + ctx.fillStyle = '#0000ff'; + ctx.fillRect(20, 20, 150, 100); + ``` + + +## strokeRect() + +Draws a rectangle stroke on the canvas. + +**Parameters** + +| Parameter| Type| Description| +| -------- | -------- | -------- | +| x | number | X-coordinate of the upper left corner of the rectangle.| +| y | number | Y-coordinate of the upper left corner of the rectangle.| +| width | number | Width of the rectangle.| +| height | number | Height of the rectangle.| + +**Example** + + ![en-us_image_0000001381268264](figures/en-us_image_0000001381268264.png) + + + ```javascript + ctx.strokeRect(30, 30, 200, 150); + ``` + + +## fillText() + +Draws filled text on the canvas. + +**Parameters** + +| Parameter| Type| Description| +| -------- | -------- | -------- | +| text | string | Text to draw.| +| x | number | X-coordinate of the lower left corner of the text.| +| y | number | Y-coordinate of the lower left corner of the text.| + +**Example** + + ![en-us_image_0000001431548109](figures/en-us_image_0000001431548109.png) + + + ```javascript + ctx.font = '35px sans-serif'; + ctx.fillText("Hello World!", 20, 60); + ``` + + +## lineWidth + +Sets the width of a line. + +**Parameters** + +| Parameter| Type| Description| +| -------- | -------- | -------- | +| lineWidth | number | Line width.| + +**Example** + + ![en-us_image_0000001431548121](figures/en-us_image_0000001431548121.png) + + + ```javascript + ctx.lineWidth = 5; + ctx.strokeRect(25, 25, 85, 105); + ``` + + +## strokeStyle + +Sets the stroke style. + +**Parameters** + +| Parameter| Type| Description| +| -------- | -------- | -------- | +| color | <color> | Color of the stroke.| + +**Example** + + ![en-us_image_0000001380789172](figures/en-us_image_0000001380789172.png) + + + ```javascript + ctx.lineWidth = 10; + ctx.strokeStyle = '#0000ff'; + ctx.strokeRect(25, 25, 155, 105); + ``` + + +### stroke()5+ + +Draws a stroke. + +**Example** + +![en-us_image_0000001431388513](figures/en-us_image_0000001431388513.png) + + ```javascript + ctx.moveTo(25, 25); + ctx.lineTo(25, 105); + ctx.strokeStyle = 'rgb(0,0,255)'; + ctx.stroke(); + ``` + + +### beginPath()5+ + +Creates a drawing path. + +**Example** + + ![en-us_image_0000001431548125](figures/en-us_image_0000001431548125.png) + + + ```javascript + ctx.beginPath(); + ctx.lineWidth = '6'; + ctx.strokeStyle = '#0000ff'; + ctx.moveTo(15, 80); + ctx.lineTo(280, 160); + ctx.stroke(); + ``` + + +### moveTo()5+ + +Moves a drawing path to a target position on the canvas. + +**Parameters** + +| Parameter| Type| Description| +| -------- | -------- | -------- | +| x | number | X-coordinate of the target position.| +| y | number | Y-coordinate of the target position.| + +**Example** + + ![en-us_image_0000001431388529](figures/en-us_image_0000001431388529.png) + + ```javascript + ctx.beginPath(); + ctx.moveTo(10, 10); + ctx.lineTo(280, 160); + ctx.stroke(); + ``` + + +### lineTo()5+ + +Connects the current point to a target position using a straight line. + +**Parameters** + +| Parameter| Type| Description| +| -------- | -------- | -------- | +| x | number | X-coordinate of the target position.| +| y | number | Y-coordinate of the target position.| + +**Example** + +![en-us_image_0000001431148365](figures/en-us_image_0000001431148365.png) + + ```javascript + ctx.beginPath(); + ctx.moveTo(10, 10); + ctx.lineTo(280, 160); + ctx.stroke(); + ``` + + +### closePath()5+ + +Draws a closed path. + +**Example** + + ![en-us_image_0000001381268284](figures/en-us_image_0000001381268284.png) + + + ```javascript + ctx.beginPath(); + ctx.moveTo(30, 30); + ctx.lineTo(110, 30); + ctx.lineTo(70, 90); + ctx.closePath(); + ctx.stroke(); + ``` + + +## font + +Sets the font style. + +**Parameters** + +| Parameter| Type| Description| +| -------- | -------- | -------- | +| value | string | Font style. **sans-serif**, **serif**, and **monospace** are supported. The default value is **30px HYQiHei-65S**.| + +**Example** + + ![en-us_image_0000001381108328](figures/en-us_image_0000001381108328.png) + + + ```javascript + ctx.font = '30px sans-serif'; + ctx.fillText("Hello World", 20, 60); + ``` + + +## textAlign + +Sets the text alignment mode. + +**Parameters** + +| Parameter| Type| Description| +| -------- | -------- | -------- | +| align | string | Available values are as follows:
- **left** (default): The text is left-aligned.
- **right**: The text is right-aligned.
- **center**: The text is center-aligned.| + +**Example** + + ![en-us_image_0000001431388517](figures/en-us_image_0000001431388517.png) + + + ```javascript + ctx.strokeStyle = '#0000ff'; + ctx.moveTo(140, 10); + ctx.lineTo(140, 160); + ctx.stroke(); + + ctx.font = '18px sans-serif'; + + // Show the different textAlign values + ctx.textAlign = 'left'; + ctx.fillText('textAlign=left', 140, 100); + ctx.textAlign = 'center'; + ctx.fillText('textAlign=center',140, 120); + ctx.textAlign = 'right'; + ctx.fillText('textAlign=right',140, 140); + ``` + + +## arc()5+ + +Draws an arc on the canvas. + +**Parameters** + +| Parameter| Type| Description| +| -------- | -------- | -------- | +| x | number | X-coordinate of the center point of the arc.| +| y | number | Y-coordinate of the center point of the arc.| +| radius | number | Radius of the arc.| +| startAngle | number | Start radian of the arc.| +| endAngle | number | End radian of the arc.| +| anticlockwise | boolean | Whether to draw the arc counterclockwise.| + +**Example** + +![en-us_image_0000001381108320](figures/en-us_image_0000001381108320.png) + + ```javascript + ctx.beginPath(); + ctx.arc(100, 75, 50, 0, 6.28); + ctx.stroke(); + ``` + + +### rect()5+ + +Creates a rectangle on the canvas. + +**Parameters** + +| Parameter| Type| Description| +| -------- | -------- | -------- | +| x | number | X-coordinate of the upper left corner of the rectangle.| +| y | number | Y-coordinate of the upper left corner of the rectangle.| +| width | number | Width of the rectangle.| +| height | number | Height of the rectangle.| + +**Example** + +![en-us_image_0000001381108312](figures/en-us_image_0000001381108312.png) + + ```javascript + ctx.rect(20, 20, 100, 100); // Create a 100*100 rectangle at (20, 20) + ctx.stroke(); // Draw it + ``` diff --git a/en/application-dev/reference/arkui-js-lite/js-components-common-animation.md b/en/application-dev/reference/arkui-js-lite/js-components-common-animation.md new file mode 100644 index 0000000000000000000000000000000000000000..ef2c39dc69ef2779e3e70c8ca61ff713f726e3d9 --- /dev/null +++ b/en/application-dev/reference/arkui-js-lite/js-components-common-animation.md @@ -0,0 +1,65 @@ +# Animation Styles + + +Components support dynamic rotation, translation, and scaling effects. These effects can be set in the **style** attribute or **.css** files. + + +| Name | Type | Default Value | Description | +| ------------------------- | ---------------------------------- | ----------- | ---------------------------------------- | +| transform | string | - | Translation, rotation, and scaling attributes. For details, see Table 1. | +| animation-name | string | - | \@keyframes rule. For details, see Table 2. | +| animation-delay | <time> | 0 | Delay for playing the animation, in ms or s, for example, **1000 ms** or **1s**. \|The default unit is ms.| +| animation-duration | <time> | 0 | Animation duration, in ms or s, for example, **1000 ms** or **1s**. \|The default unit is ms.
**NOTE**
**animation-duration** must be specified. Otherwise, the duration is **0**, which means the animation will not be played.| +| animation-iteration-count | number \| infinite | 1 | Number of times that an animation is played. The animation is played once by default. You can set the value to **infinite** to play the animation infinitely. | +| animation-timing-function | string |
linear | Speed curve of an animation, which makes the animation more fluent.
Available values are as follows:
- **linear**: The animation speed keeps unchanged.
- **ease-in**: The animation starts at a low speed. The cubic-bezier curve (0.42, 0.0, 1.0, 1.0) is used
- **ease-out**: The animation ends at a low speed. The cubic-bezier curve (0.0, 0.0, 0.58, 1.0) is used.
- **ease-in-out**: The animation starts and ends at a low speed. The cubic-bezier curve (0.42, 0.0, 0.58, 1.0) is used.| +| animation-fill-mode | string | none | Start and end styles of the animation.
- **none**: No style is applied to the target before or after the animation is executed.
- **forwards**: The target keeps the state at the end of the animation (defined in the last key frame) after the animation is executed.| + + + **Table 1** transform + +| Name | Type | Description | +| ---------- | ------------------------------------ | ---------- | +| translateX | <length> | Moves an element along the x-axis.| +| translateY | <length> | Moves an element along the y-axis.| +| rotate | <deg> \| <rad> | Rotates an element. | + +> **NOTE** +> +> Only images of the original size can be rotated on lite wearables. + + + **Table 2** \@keyframes + +| Name | Type | Default Value | Description | +| ---------------- | -------------- | ---- | ------------------ | +| background-color | <color> | - | Background color applied to the component after the animation is played. | +| width | <length> | - | Width value applied to the component after the animation is played. | +| height | <length> | - | Height value applied to the component after the animation is played. | +| transform | string | - | Transformation type applied to a component. For details, see Table 1.| + + +If there is no default value for when an animation will start or end, use **from** and **to** to specify the start and end of the display. The following is an example: + + +```css +@keyframes Go +{ + from { + background-color: #f76160; + } + to { + background-color: #09ba07; + } +} +``` + + +![animation-demo1](figures/animation-demo1.gif) + + + + + +> **NOTE** +> +> The \@keyframes rule with **from** and **to** defined cannot be dynamically bound to an element. diff --git a/en/application-dev/reference/arkui-js-lite/js-components-common-mediaquery.md b/en/application-dev/reference/arkui-js-lite/js-components-common-mediaquery.md new file mode 100644 index 0000000000000000000000000000000000000000..43a11aa1f7a691186eb436a19383913f0471ffa5 --- /dev/null +++ b/en/application-dev/reference/arkui-js-lite/js-components-common-mediaquery.md @@ -0,0 +1,110 @@ +# Media Query + +> **NOTE** +> +> - This API is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. +> +> - The **media** attribute uses the actual size, physical pixel, and screen resolution of the device by default. + + +Media queries are widely used. You can use them to modify the application style based on the device type or specific features and device parameters (such as the screen resolution). Specifically, media queries allow you to design a layout style based on the device and application attributes. + + +## CSS Syntax Rules + +Use **@media** to import query statements. The rule is as follows: + +``` +@media [media-type] [and|or] [(media-feature)] { + CSS-Code; +} +``` + +**@media screen and (round-screen: true) { … }**: The condition is met when the device screen is round. + +**@media (max-height: 454) { … }**: Range query. CSS level 3 is used. + +> **NOTE** +> +> - The following operators are not supported: <=, >=, <, and >. +> - Nested parentheses are supported since API version 9. +> - A media query statement can contain a maximum of 512 characters. +> - A media query condition can contain a maximum of 32 characters. + + +## Media Type + +| Type | Description | +| ------ | -------------- | +| screen | Media query based on screen-related parameters.| + + +## Media Logical Operation + +You can use media logical operators to implement complex media query. The following table describes the available operators. + +**Table 1** Media logical operators + +| Type | Description | +| --------------- | ---------------------------------------- | +| and | The **and** operator is used to combine multiple media features into one media query, in a logical AND operation. The query is valid only when all media features are true. It can also combine media types and media functions.
For example, **screen and (device-type: liteWearable) and (max-height: 454)** evaluates to **true** when the device type is wearable and the maximum height of the application is 454 pixel units.| +| or9+ | The **or** operator is used to combine multiple media features into one media query, in a logical OR operation. The query is valid if a media feature is true.
For example, **screen and (max-height: 454) or (round-screen: true)** evaluates to **true** when the maximum height of the application is 454 pixel units or the device screen is round.| + + + + +## Media Features + +| Type | Description | +| ---------------- | ---------------------------------------- | +| height | Height of the display area on the application page. | +| min-height | Minimum height of the display area on the application page. | +| max-height | Maximum height of the display area on the application page. | +| width | Width of the display area on the application page. | +| min-width | Minimum width of the display area on the application page. | +| max-width | Maximum width of the display area on the application page. | +| aspect-ratio | Ratio of the width to the height of the display area on the application page.
Example: **aspect-ratio: 1/2**| +| min-aspect-ratio | Minimum ratio of the width to the height of the display area on the application page. | +| max-aspect-ratio | Maximum ratio of the width to the height of the display area on the application page. | +| round-screen | Screen type. The value **true** means that the screen is round, and **false** means the opposite.| + + +## Sample Code for the Common Media Feature + +The number and type of attributes must be the same among **.container** blocks. Otherwise, display errors will occur. + +```html + +
+
+ Hello World +
+
+``` + +```css +/* xxx.css */ +.container { + width: 300px; + height: 600px; + background-color: #008000; +} +.title { + font-size: 30px; + text-align: center; +} +@media (device-type: samrtVision) { + .container { + width: 500px; + height: 500px; + background-color: #fa8072; + } +} +@media (device-type: liteWearable) { + .container { + width: 300px; + height: 300px; + background-color: #008b8b; + } +} +``` diff --git a/en/application-dev/reference/arkui-js-lite/js-components-container-div.md b/en/application-dev/reference/arkui-js-lite/js-components-container-div.md new file mode 100644 index 0000000000000000000000000000000000000000..7f9321e0194dd7a6fbc81d476be45188d12cafbb --- /dev/null +++ b/en/application-dev/reference/arkui-js-lite/js-components-container-div.md @@ -0,0 +1,154 @@ +# div + +The **\
** component is a basic container that is used as the root node of the page structure or is used to group the content. + +> **NOTE** +> +> This component is supported since API version 4. Updates will be marked with a superscript to indicate their earliest API version. + + +## Child Components + +Supported + + +## Attributes + +| Name| Type| Default Value| Mandatory| Description| +| -------- | -------- | -------- | -------- | -------- | +| id | string | - | No| Unique ID of the component.| +| style | string | - | No| Style declaration of the component.| +| class | string | - | No| Style class of the component, which is used to refer to a style table.| +| ref | string | - | No| Reference information of child elements, which is registered with the parent component on **$refs**.| + + +## Events + +| Name| Parameter| Description| +| -------- | -------- | -------- | +| click | - | Triggered when the component is clicked.| +| longpress | - | Triggered when the component is long pressed.| +| swipe5+ | [SwipeEvent](js-common-events.md) | Triggered when a user quickly swipes on the component.| + + +## Styles + +| Name| Type| Default Value| Mandatory| Description| +| -------- | -------- | -------- | -------- | -------- | +| flex-direction | string | row | No| Main axis direction of the flex container, which defines how items are placed in the container. Available values are as follows:
- **column**: Items are placed vertically from top to bottom.
- **row**: Items are placed horizontally from left to right.| +| flex-wrap | string | nowrap | No| Whether items in the flex container are displayed in a single line or multiple lines. The value cannot be dynamically updated. Available values are as follows:
- **nowrap**: Flex items are displayed in a single line.
- **wrap**: Flex items are displayed in multiple lines.| +| justify-content | string | flex-start | No| How items are aligned along the main axis of the flex container. Available values are as follows:
- **flex-start**: Items are packed toward the start edge of the container along the main axis.
- **flex-end**: Items are packed toward the end edge of the container along the main axis.
- **center**: Items are packed toward the center of the container along the main axis.
- **space-between**: Items are positioned with space between the rows.
- **space-around**: Items are positioned with space before, between, and after the rows.| +| align-items | string | stretch5+
flex-start1-4 | No| How items are aligned along the cross axis in a flex container. Available values are as follows:
- **stretch**: Items are stretched to the same height or width as the container along the cross axis.5+
- **flex-start**: Items are packed toward the start edge of the cross axis.
- **flex-end**: Items are packed toward the end edge of the cross axis.
- **center**: Items are packed toward the center of the cross axis.| +| display | string | flex | No| Type of the view box of the item. The value cannot be dynamically updated. Available values are as follows:
- **flex**: flexible layout
- **none**: not rendered| +| width | <length> \| <percentage>5+ | - | No| Component width.

If this attribute is not set, the default value **0** is used.| +| height | <length> \| <percentage>5+ | - | No| Component height.
If this attribute is not set, the default value **0** is used. | +| padding | <length> | 0 | No| Shorthand attribute to set the padding for all sides.
The attribute can have one to four values:
- If you set only one value, it specifies the padding for all the four sides.
- If you set two values, the first value specifies the top and bottom padding, and the second value specifies the left and right padding.
- If you set three values, the first value specifies the top padding, the second value specifies the left and right padding, and the third value specifies the bottom padding.
- If you set four values, they respectively specify the padding for top, right, bottom, and left sides (in clockwise order).| +| padding-[left\|top\|right\|bottom] | <length> | 0 | No| Left, top, right, and bottom padding.| +| margin | <length> \| <percentage>5+ | 0 | No| Shorthand attribute to set the margin for all sides. The attribute can have one to four values:
- If you set only one value, it specifies the margin for all the four sides.
- If you set two values, the first value specifies the top and bottom margins, and the second value specifies the left and right margins.
- If you set three values, the first value specifies the top margin, the second value specifies the left and right margins, and the third value specifies the bottom margin.
- If you set four values, they respectively specify the margin for top, right, bottom, and left sides (in clockwise order).| +| margin-[left\|top\|right\|bottom] | <length> \| <percentage>5+ | 0 | No| Left, top, right, and bottom margins.| +| border-width | <length> | 0 | No| Shorthand attribute to set the margin for all sides.| +| border-color | <color> | black | No| Shorthand attribute to set the color for all borders.| +| border-radius | <length> | - | No| Radius of round-corner borders.| +| background-color | <color> | - | No| Background color.| +| opacity5+ | number | 1 | No| Opacity of an element. The value ranges from **0** to **1**. The value **1** means opaque, and **0** means completely transparent.| +| [left\|top] | <length> \| <percentage>6+ | - | No| Edge of the element.
- **left**: left edge position of the element. This attribute defines the offset between the left edge of the margin area of a positioned element and left edge of its containing block.
- **top**: top edge position of the element. This attribute defines the offset between the top edge of a positioned element and that of a block included in the element. | + + +## Example + +1. Flex style + + ```html + +
+
+
+
+
+
+
+ ``` + + + ```css + /* xxx.css */ + .container { + flex-direction: column; + justify-content: center; + align-items: center; + width: 454px; + height: 454px; + } + .flex-box { + justify-content: space-around; + align-items: center; + width: 400px; + height: 140px; + background-color: #ffffff; + } + .flex-item { + width: 120px; + height: 120px; + border-radius: 16px; + } + .color-primary { + background-color: #007dff; + } + .color-warning { + background-color: #ff7500; + } + .color-success { + background-color: #41ba41; + } + ``` + + ![en-us_image_0000001381108420](figures/en-us_image_0000001381108420.png) + +2. Flex wrap style + + ```html + +
+
+
+
+
+
+
+ ``` + + + ```css + /* xxx.css */ + .container { + flex-direction: column; + justify-content: center; + align-items: center; + width: 454px; + height: 454px; + } + .flex-box { + justify-content: space-around; + align-items: center; + flex-wrap: wrap; + width: 300px; + height: 250px; + background-color: #ffffff; + } + .flex-item { + width: 120px; + height: 120px; + border-radius: 16px; + } + .color-primary { + background-color: #007dff; + } + .color-warning { + background-color: #ff7500; + } + .color-success { + background-color: #41ba41; + } + ``` + + ![en-us_image_0000001431148457](figures/en-us_image_0000001431148457.png) diff --git a/en/application-dev/reference/arkui-js-lite/js-components-container-list-item.md b/en/application-dev/reference/arkui-js-lite/js-components-container-list-item.md new file mode 100644 index 0000000000000000000000000000000000000000..32855f3c9a0b62169e81fd2643c97afce58c5d3f --- /dev/null +++ b/en/application-dev/reference/arkui-js-lite/js-components-container-list-item.md @@ -0,0 +1,53 @@ +# list-item + +**\** is a child component of the **[\](js-components-container-list.md)** component and is used to display items in a list. + +> **NOTE** +> +> This component is supported since API version 4. Updates will be marked with a superscript to indicate their earliest API version. + + +## Child Components + +Supported + + +## Attributes + +| Name| Type| Default Value| Mandatory| Description| +| -------- | -------- | -------- | -------- | -------- | +| id | string | - | No| Unique ID of the component.| +| style | string | - | No| Style declaration of the component.| +| class | string | - | No| Style class of the component, which is used to refer to a style table.| +| ref | string | - | No| Reference information of child elements, which is registered with the parent component on **$refs**.| + + +## Events + +| Name| Parameter| Description| +| -------- | -------- | -------- | +| click | - | Triggered when the component is clicked.| +| longpress | - | Triggered when the component is long pressed.| +| swipe5+ | [SwipeEvent](js-common-events.md) | Triggered when a user quickly swipes on the component.| + + +## Styles + +| Name| Type| Default Value| Mandatory| Description| +| -------- | -------- | -------- | -------- | -------- | +| width | <length> \| <percentage>5+ | - | No| Component width.
If this attribute is not set, the default value **0** is used.| +| height | <length> \| <percentage>5+ | - | No| Component height.
If this attribute is not set, the default value **0** is used.| +| padding | <length> | 0 | No| Shorthand attribute to set the padding for all sides.
The attribute can have one to four values:
- If you set only one value, it specifies the padding for all the four sides.
- If you set two values, the first value specifies the top and bottom padding, and the second value specifies the left and right padding. - If you set three values, the first value specifies the top padding, the second value specifies the left and right padding, and the third value specifies the bottom padding. - If you set four values, they respectively specify the padding for top, right, bottom, and left sides (in clockwise order).| +| padding-[left\|top\|right\|bottom] | <length> | 0 | No| Left, top, right, and bottom padding.| +| border-width | <length> | 0 | No| Shorthand attribute to set the margin for all sides.| +| border-color | <color> | black | No| Shorthand attribute to set the color for all borders.| +| border-radius | <length> | - | No| Radius of round-corner borders.| +| background-color | <color> | - | No| Background color.| +| opacity5+ | number | 1 | No| Opacity of an element. The value ranges from **0** to **1**. The value **1** means opaque, and **0** means completely transparent.| +| display | string | flex | No| How and whether to display the box containing an element. Available values are as follows:
- **flex**: flexible layout
- **none**: not rendered| + + + +## Example + +See **Example** in [list](js-components-container-list.md). diff --git a/en/application-dev/reference/arkui-js-lite/js-components-container-list.md b/en/application-dev/reference/arkui-js-lite/js-components-container-list.md new file mode 100644 index 0000000000000000000000000000000000000000..6c256285ccf9894184218e179efd96089289d61d --- /dev/null +++ b/en/application-dev/reference/arkui-js-lite/js-components-container-list.md @@ -0,0 +1,123 @@ +# list + +The **\** component provides a list container that presents a series of list items arranged in a column with the same width. It supports presentations of the same type of data in a multiple and coherent row style, for example, images or text. + +> **NOTE** +> +> This component is supported since API version 4. Updates will be marked with a superscript to indicate their earliest API version. + + +## Child Components + +Only [\](js-components-container-list-item.md) is supported. + + +## Attributes + +| Name| Type| Default Value| Mandatory| Description| +| -------- | -------- | -------- | -------- | -------- | +| id | string | - | No| Unique ID of the component.| +| style | string | - | No| Style declaration of the component.| +| class | string | - | No| Style class of the component, which is used to refer to a style table.| +| ref | string | - | No| Reference information of child elements, which is registered with the parent component on **$refs**.| + + +## Events + +| Name| Parameter| Description| +| -------- | -------- | -------- | +| scrollend | - | Triggered when the list stops scrolling.| +| click | - | Triggered when the list is clicked. | +| longpress | - | Triggered when the list is long pressed. | +| swipe5+ | [SwipeEvent](js-common-events.md) | Triggered when a user quickly swipes on the list. | +| scrolltop8+ | - | Triggered when the list is scrolled to the top.| +| scrollbottom8+ | - | Triggered when the list is scrolled to the bottom.| + + +## Styles + +| Name| Type| Default Value| Mandatory| Description| +| -------- | -------- | -------- | -------- | -------- | +| flex-direction | string | column | No| Main axis direction of the flex container. It specifies how items are placed in the flex container.
- **column**: Items are placed vertically from top to bottom.
- **row**: Items are placed horizontally from left to right.
For the **\** component, the default value is **column**. For other components, the default value is **row**. Dynamic modification is not supported.| +| width | <length> \| <percentage>5+ | - | No| Component width.
If this attribute is not set, the default value **0** is used. | +| height | <length> \| <percentage>5+ | - | No| Component height.
If this attribute is not set, the default value **0** is used. | +| padding | <length> | 0 | No| Shorthand attribute to set the padding for all sides.
The attribute can have one to four values:
- If you set only one value, it specifies the padding for all the four sides.
- If you set two values, the first value specifies the top and bottom padding, and the second value specifies the left and right padding.
- If you set three values, the first value specifies the top padding, the second value specifies the left and right padding, and the third value specifies the bottom padding.
- If you set four values, they respectively specify the padding for top, right, bottom, and left sides (in clockwise order).| +| padding-[left\|top\|right\|bottom] | <length> | 0 | No| Left, top, right, and bottom padding.| +| margin | <length> \| <percentage>5+ | 0 | No| Shorthand attribute to set the margin for all sides. The attribute can have one to four values:
- If you set only one value, it specifies the margin for all the four sides.
- If you set two values, the first value specifies the top and bottom margins, and the second value specifies the left and right margins.
- If you set three values, the first value specifies the top margin, the second value specifies the left and right margins, and the third value specifies the bottom margin.
- If you set four values, they respectively specify the margin for top, right, bottom, and left sides (in clockwise order).| +| margin-[left\|top\|right\|bottom] | <length> \| <percentage>5+ | 0 | No| Left, top, right, and bottom margins.| +| border-width | <length> | 0 | No| Shorthand attribute to set the margin for all sides.| +| border-color | <color> | black | No| Shorthand attribute to set the color for all borders.| +| border-radius | <length> | - | No| Radius of round-corner borders.| +| background-color | <color> | - | No| Background color.| +| opacity5+ | number | 1 | No| Opacity of an element. The value ranges from **0** to **1**. The value **1** means opaque, and **0** means completely transparent.| +| display | string | flex | No| How and whether to display the box containing an element. Available values are as follows:
- **flex**: flexible layout
- **none**: not rendered| +| [left\|top] | <length> \| <percentage>6+ | - | No| Edge of the element.
- **left**: left edge position of the element. This attribute defines the offset between the left edge of the margin area of a positioned element and left edge of its containing block.
- **top**: top edge position of the element. This attribute defines the offset between the top edge of a positioned element and that of a block included in the element. | + + +## Methods + +| Name| Parameter| Description| +| -------- | -------- | -------- | +| scrollTo | { index: number(position) } | Scrolls the list to the position of the item at the specified index.| + + +## Example + + +```html + +
+ + + {{$item.title}} + {{$item.date}} + + +
+``` + + +```js +// index.js +export default { + data: { + todolist: [{ + title: 'Prepare for the interview', + date: '2021-12-31 10:00:00', + }, { + title: 'Watch the movie', + date: '2021-12-31 20:00:00', + }], + }, +} +``` + + +```css +/* index.css */ +.container { + display: flex; + justify-content: center; + align-items: center; + left: 0px; + top: 0px; + width: 454px; + height: 454px; +} +.todo-wraper { + width: 454px; + height: 300px; +} +.todo-item { + width: 454px; + height: 80px; + flex-direction: column; +} +.todo-title { + width: 454px; + height: 40px; + text-align: center; +} +``` + +![list](figures/list.png) diff --git a/en/application-dev/reference/arkui-js-lite/js-components-container-stack.md b/en/application-dev/reference/arkui-js-lite/js-components-container-stack.md new file mode 100644 index 0000000000000000000000000000000000000000..c099a46be788de55f5832bc94614c569ba2b0bad --- /dev/null +++ b/en/application-dev/reference/arkui-js-lite/js-components-container-stack.md @@ -0,0 +1,101 @@ +# stack + +The **\** component provides a stack container where child components are successively stacked and the latter one overwrites the previous one. + +> **NOTE** +> +> This component is supported since API version 4. Updates will be marked with a superscript to indicate their earliest API version. + + +## Child Components + +Supported. + + +## Attributes + +| Name | Type | Default Value | Mandatory | Description | +| ----- | ------ | ---- | ---- | ---------------------------------------- | +| id | string | - | No | Unique ID of the component. | +| style | string | - | No | Style declaration of the component. | +| class | string | - | No | Style class of the component, which is used to refer to a style table. | +| ref | string | - | No | Reference information of child elements, which is registered with the parent component on **$refs**.| + + +## Events + +| Name | Parameter | Description | +| ------------------ | --------------------------------- | ----------- | +| click | - | Triggered when the component is clicked. | +| longpress | - | Triggered when the component is long pressed. | +| swipe5+ | [SwipeEvent](js-common-events.md) | Triggered when a user quickly swipes on the component.| + + +## Styles + +| Name | Type | Default Value | Mandatory | Description | +| ---------------------------------- | ---------------------------------------- | ----- | ---- | ---------------------------------------- | +| width | <length> \| <percentage>5+ | - | No | Component width.

If this attribute is not set, the default value **0** is used. | +| height | <length> \| <percentage>5+ | - | No | Component height.

If this attribute is not set, the default value **0** is used. | +| padding | <length> | 0 | No | Shorthand attribute to set the padding for all sides.
The attribute can have one to four values:
- If you set only one value, it specifies the padding for all the four sides.
- If you set two values, the first value specifies the top and bottom padding, and the second value specifies the left and right padding.
- If you set three values, the first value specifies the top padding, the second value specifies the left and right padding, and the third value specifies the bottom padding.
- If you set four values, they respectively specify the padding for top, right, bottom, and left sides (in clockwise order).| +| padding-[left\|top\|right\|bottom] | <length> | 0 | No | Left, top, right, and bottom padding. | +| margin | <length> \| <percentage>5+ | 0 | No | Shorthand attribute to set the margin for all sides. The attribute can have one to four values:
- If you set only one value, it specifies the margin for all the four sides.
- If you set two values, the first value specifies the top and bottom margins, and the second value specifies the left and right margins.
- If you set three values, the first value specifies the top margin, the second value specifies the left and right margins, and the third value specifies the bottom margin.
- If you set four values, they respectively specify the margin for top, right, bottom, and left sides (in clockwise order).| +| margin-[left\|top\|right\|bottom] | <length> \| <percentage>5+ | 0 | No | Left, top, right, and bottom margins. | +| border-width | <length> | 0 | No | Shorthand attribute to set the margin for all sides. | +| border-color | <color> | black | No | Shorthand attribute to set the color for all borders. | +| border-radius | <length> | - | No | Radius of round-corner borders. | +| background-color | <color> | - | No | Background color. | +| opacity5+ | number | 1 | No | Opacity of an element. The value ranges from **0** to **1**. The value **1** means opaque, and **0** means completely transparent. | +| display | string | flex | No | How and whether to display the box containing an element. Available values are as follows:
- **flex**: flexible layout
- **none**: not rendered| +| [left\|top] | <length> \| <percentage>6+ | - | No | Edge of the element.
- **left**: left edge position of the element. This attribute defines the offset between the left edge of the margin area of a positioned element and left edge of its containing block.
- **top**: top edge position of the element. This attribute defines the offset between the top edge of a positioned element and that of a block included in the element.| + +> **NOTE** +> +> The absolute positioning does not support a percentage. Therefore, **margin** cannot be set for the child components of the **\** component. + + +## Example + + +```html + + +
+
+
+
+``` + + +```css +/* xxx.css */ +.stack-parent { + width: 400px; + height: 400px; + background-color: #ffffff; + border-width: 1px; + border-style: solid; +} +.back-child { + width: 300px; + height: 300px; + background-color: #3f56ea; +} +.front-child { + width: 100px; + height: 100px; + background-color: #00bfc9; +} +.positioned-child { + width: 100px; + height: 100px; + left: 50px; + top: 50px; + background-color: #47cc47; +} +.bd-radius { + border-radius: 16px; +} +``` + +![en-us_image_0000001380789188](figures/en-us_image_0000001380789188.png) diff --git a/en/application-dev/reference/arkui-js-lite/js-components-container-swiper.md b/en/application-dev/reference/arkui-js-lite/js-components-container-swiper.md new file mode 100644 index 0000000000000000000000000000000000000000..34ad83a37b8d907b886427b183e99f4666e28327 --- /dev/null +++ b/en/application-dev/reference/arkui-js-lite/js-components-container-swiper.md @@ -0,0 +1,112 @@ +# swiper + +The **\** component provides a container that allows users to switch among child components using swipe gestures. + +> **NOTE** +> +> This component is supported since API version 4. Updates will be marked with a superscript to indicate their earliest API version. + + +## Child Components + +All child components except **\** are supported. + + +## Attributes + +| Name| Type| Default Value| Mandatory| Description| +| -------- | -------- | -------- | -------- | -------- | +| index | number | 0 | No| Index of the child component currently displayed in the container.| +| loop | boolean | true | No| Whether to enable looping. | +| duration | number | - | No| Duration of the autoplay for child component switching.| +| vertical | boolean | false | No| Whether the swipe gesture is performed vertically. A vertical swipe uses the vertical indicator.
The value cannot be dynamically updated.| +| id | string | - | No| Unique ID of the component.| +| style | string | - | No| Style declaration of the component.| +| class | string | - | No| Style class of the component, which is used to refer to a style table.| +| ref | string | - | No| Reference information of child elements, which is registered with the parent component on **$refs**.| + + +## Events + +| Name| Parameter| Description| +| -------- | -------- | -------- | +| change | { index: currentIndex } | Triggered when the index of the currently displayed component changes.| +| click | - | Triggered when the component is clicked.| +| longpress | - | Triggered when the component is long pressed.| +| swipe5+ | [SwipeEvent](js-common-events.md) | Triggered when a user quickly swipes on the component.| + + +## Styles + +| Name| Type| Default Value| Mandatory| Description| +| -------- | -------- | -------- | -------- | -------- | +| width | <length> \| <percentage>5+ | - | No| Component width.
If this attribute is not set, the default value **0** is used. | +| height | <length> \| <percentage>5+ | - | No| Component height.
If this attribute is not set, the default value **0** is used. | +| padding | <length> | 0 | No| Shorthand attribute to set the padding for all sides.
The attribute can have one to four values:
- If you set only one value, it specifies the padding for all the four sides.
- If you set two values, the first value specifies the top and bottom padding, and the second value specifies the left and right padding.
- If you set three values, the first value specifies the top padding, the second value specifies the left and right padding, and the third value specifies the bottom padding.
- If you set four values, they respectively specify the padding for top, right, bottom, and left sides (in clockwise order).| +| padding-[left\|top\|right\|bottom] | <length> | 0 | No| Left, top, right, and bottom padding.| +| margin | <length> \| <percentage>5+ | 0 | No| Shorthand attribute to set the margin for all sides. The attribute can have one to four values:
- If you set only one value, it specifies the margin for all the four sides.
- If you set two values, the first value specifies the top and bottom margins, and the second value specifies the left and right margins.
- If you set three values, the first value specifies the top margin, the second value specifies the left and right margins, and the third value specifies the bottom margin.
- If you set four values, they respectively specify the margin for top, right, bottom, and left sides (in clockwise order).| +| margin-[left\|top\|right\|bottom] | <length> \| <percentage>5+ | 0 | No| Left, top, right, and bottom margins.| +| border-width | <length> | 0 | No| Shorthand attribute to set the margin for all sides.| +| border-color | <color> | black | No| Shorthand attribute to set the color for all borders.| +| border-radius | <length> | - | No| Radius of round-corner borders.| +| background-color | <color> | - | No| Background color.| +| opacity5+ | number | 1 | No| Opacity of an element. The value ranges from **0** to **1**. The value **1** means opaque, and **0** means completely transparent.| +| display | string | flex | No| How and whether to display the box containing an element. Available values are as follows:
- **flex**: flexible layout
- **none**: not rendered| +| [left\|top] | <length> \| <percentage>6+ | - | No| Edge of the element.
- **left**: left edge position of the element. This attribute defines the offset between the left edge of the margin area of a positioned element and left edge of its containing block.
- **top**: top edge position of the element. This attribute defines the offset between the top edge of a positioned element and that of a block included in the element. | + + +## Example + + +```html + + +
+ 1 +
+
+ 2 +
+
+ 3 +
+
+``` + + +```css +/* xxx.css */ +.container { + left: 0px; + top: 0px; + width: 454px; + height: 454px; +} +.swiper-item { + width: 454px; + height: 454px; + justify-content: center; + align-items: center; +} +.primary-item { + background-color: #007dff; +} +.warning-item { + background-color: #ff7500; +} +.success-item { + background-color: #41ba41; +} +``` + + +```js +/* xxx.js */ +export default { + data: { + index: 1 + } +} +``` + +![swiper](figures/swiper.gif) diff --git a/en/application-dev/reference/arkui-js-lite/js-framework-file.md b/en/application-dev/reference/arkui-js-lite/js-framework-file.md new file mode 100644 index 0000000000000000000000000000000000000000..e03caae24cb2ddfd8c20c7517baef2420160bedc --- /dev/null +++ b/en/application-dev/reference/arkui-js-lite/js-framework-file.md @@ -0,0 +1,73 @@ +# File Organization + + +## Directory structure + +The following figure shows the typical directory structure of the JavaScript module (**entry/src/main/js/module**) for an application with feature abilities (FA) using JavaScript APIs. + + **Figure 1** Directory structure + +![en-us_image_0000001431388581](figures/en-us_image_0000001431388581.png) + +Functions of the files are as follows: + +- **.hml** files describe the page layout. + +- **.css** files describe the page style. + +- **.js** files process the interactions between pages and users. + +Functions of the folders are as follows: + +- The **app.js** file manages global JS logics and application lifecycle. +- The **pages** directory stores all component pages. +- The **common** directory stores public resource files, such as media resources and **.js** files. +- The **i18n** folder stores resources in different languages, for example, UI strings and image paths. + +> **NOTE** +> +> - The **i18n** folder is a reserved one and cannot be renamed. +> +> +> - The folders marked as optional in the directory structure can be created as needed after you create the project in DevEco Studio. + + +## File Access Rules + +Application resources can be accessed via an absolute or relative path. In this development framework, an absolute path starts with a slash (/), and a relative path starts with **./** or **../**. The rules are as follows: + +- To reference a code file, use a relative path, for example, **../common/utils.js**. + +- To reference a resource file, use an absolute path, for example: **/common/xxx.png**. + +- Store code files and resource files in the **common** directory and access the files in a required fashion. + +- In a **.css** file, use the **url()** function to create a URL, for example, **url(/common/xxx.png)**. + +> **NOTE** +> +> When code file A needs to reference code file B: +> +> - If code files A and B are in the same directory, you can use either a relative or absolute path in code file B to reference resource files. +> +> - If code files A and B are in different directories, you must use an absolute path in code file B to reference resource files, because the directory of code file B changes during Webpack packaging. +> + + +## Media File Formats + + **Table 1** Supported image formats + +| Format | Supported Version | File Name Extension| +| ---- | ------------------------ | ------- | +| BMP | API version 4+ | .bmp | +| JPEG | API version 4+ | .jpg | +| PNG | API version 4+ | .png | + +## Storage Directory + +Since API version 5, the [\](js-components-basic-image.md) component supports access to images in the private directory of an application. + +| Directory Type | Prefix | Access Visibility | Description | +| ------ | --------------- | ------ | --------------------------- | +| Private directory of the application| internal://app/ | Current application only| The directory is deleted when the application is uninstalled. Access to the parent directory using **../** is prohibited.| diff --git a/en/application-dev/reference/arkui-js-lite/js-framework-js-file.md b/en/application-dev/reference/arkui-js-lite/js-framework-js-file.md new file mode 100644 index 0000000000000000000000000000000000000000..ed245837baa9f181f5683d61602d8728aaaa1317 --- /dev/null +++ b/en/application-dev/reference/arkui-js-lite/js-framework-js-file.md @@ -0,0 +1,27 @@ +# app.js + +## Application Lifecycle4+ + +You can implement lifecycle logic specific to your application in the **app.js** file. Available application lifecycle functions are as follows: + + +- **onCreate()**: called when an application is created + +- **onDestory()**: called when an application is destroyed + + +In the following example, logs are printed only in the lifecycle functions. + + + +```js +// app.js +export default { + onCreate() { + console.info('Application onCreate'); + }, + onDestroy() { + console.info('Application onDestroy'); + }, +} +``` diff --git a/en/application-dev/reference/arkui-js-lite/js-framework-js-tag.md b/en/application-dev/reference/arkui-js-lite/js-framework-js-tag.md new file mode 100644 index 0000000000000000000000000000000000000000..868e668195e277d512bd98c99b0404261b198eab --- /dev/null +++ b/en/application-dev/reference/arkui-js-lite/js-framework-js-tag.md @@ -0,0 +1,74 @@ +# "js" Tag + + +The "js" tag contains the instance name and page route information. + + +| Tag | Type | Default Value | Mandatory | Description | +| ----- | ------ | ------- | ---- | ----------------------------- | +| name | string | default | Yes | Name of the JavaScript instance. | +| pages | Array | - | Yes | Route information. For details, see ["pages"](#pages).| + + +> **NOTE** +> +> The "name" and "pages" tags are configured in the "js" tag of the **config.json** file. + + +## pages + +The **"pages"** defines the route information of each page. Each page consists of the page path and page name. The following is an example: + + +``` +{ + ... + "pages": [ + "pages/index/index", + "pages/detail/detail" + ] + ... +} +``` + + +> **NOTE** +> +> +> - The application home page is fixed to **pages/index/index**. +> +> - The page name should not be a component name, for example, **text.hml** or **button.hml**. + + +## Example + + +``` +{ + "app": { + "bundleName": "com.example.player", + "version": { + "code": 1, + "name": "1.0" + }, + "vendor": "example" + } + "module": { + ... + "js": [ + { + "name": "default", + "pages": [ + "pages/index/index", + "pages/detail/detail" + ] + } + ], + "abilities": [ + { + ... + } + ] + } +} +``` diff --git a/en/application-dev/reference/arkui-js-lite/js-framework-syntax-css.md b/en/application-dev/reference/arkui-js-lite/js-framework-syntax-css.md new file mode 100644 index 0000000000000000000000000000000000000000..7e3bf96dde9606c86a70d75f1c89fe62a47d155d --- /dev/null +++ b/en/application-dev/reference/arkui-js-lite/js-framework-syntax-css.md @@ -0,0 +1,162 @@ +# CSS + + +Cascading Style Sheets (CSS) is a language used to describe the HML page structure. All HML components have default styles. You can customize styles for these components using CSS to design various pages. + + +## Style Import + +CSS files can be imported using the **\@import** statement. This facilitates module management and code reuse. + + +## Style Declaration + +The **.css** file with the same name as the **.hml** file in each page directory describes the styles of components on the HML page, determining how the components will be displayed. + +1. Internal style: The **style** and **class** attributes can be used to specify the component style. Sample code: + + ```html + +
+ Hello World +
+ ``` + + + ```css + /* index.css */ + .container { + justify-content: center; + } + ``` + +2. External style files: You need to import the files. For example, create a **style.css** file in the **common** directory and import the file at the beginning of **index.css**. + + ```css + /* style.css */ + .title { + font-size: 50px; + } + ``` + + + ```css + /* index.css */ + @import '../../common/style.css'; + .container { + justify-content: center; + } + ``` + + +## Selectors + +A CSS selector is used to select elements for which styles need to be added to. The following table lists the supported selectors. + +| Selector | Example | Description | +| ------ | --------------------- | ------------------------------------- | +| .class | .container | Selects all components whose **class** is **container**. | +| \#id | \#titleId | Selects all components whose **id** is **titleId**. | +| , | .title, .content | Selects all components whose **class** is **title** or **content**.| + +Example: + + +```html + +
+ Title +
+ Content +
+
+``` + + +```css +/* Page style xxx.css */ +/* Set the style for the components whose class is title. */ +.title { + font-size: 30px; +} +/* Set the style for the components whose id is contentId. */ +#contentId { + font-size: 20px; +} +/* Set padding for all components of the title or content class to 5 px. */ +.title, .content { + padding: 5px; +} + +``` + + +## Pseudo-classes + +A CSS pseudo-class is a keyword added to a selector that specifies a special state of the selected elements. + + + +| Name | Available Components | Description | +| -------- | ----------------------------------- | ---------------------------------------- | +| :active |
input[type="button"] | Selects the element activated by a user, for example, a pressed button. Only the **background-color** and **background-image** attributes can be set for the pseudo-class selector on lite wearables.| +| :checked | input[type="checkbox", type="radio"]| Selects the element whose **checked** attribute is **true**. Only the **background-color** and **background-image** attributes can be set for the pseudo-class selector on lite wearables.| + +The following is an example for you to use the **:active** pseudo-class to control the style when a user presses the button. + + +```html + +
+ +
+``` + + +```css +/* index.css */ +.button:active { + background-color: #888888;/* After the button is activated, the background color is changed to #888888. */ +} +``` + + +## Precompiled Styles + +Precompilation is a program that uses specific syntax to generate CSS files. It provides variables and calculation, helping you define component styles more conveniently. Currently, Less, Sass, and Scss are supported. To use precompiled styles, change the suffix of the original **.css** file. For example, change **index.css** to **index.less**, **index.sass**, or **index.scss**. + +- The following **index.less** file is changed from **index.css**. + + ```css + /* index.less */ + /* Define a variable. */ + @colorBackground: #000000; + .container { + background-color: @colorBackground; /* Use the variable defined in the .less file. */ + } + ``` + +- Reference a precompiled style file. For example, if the **style.scss** file is located in the **common** directory, change the original **index.css** file to **index.scss** and import **style.scss**. + + ```css + /* style.scss */ + /* Define a variable. */ + $colorBackground: #000000; + ``` + + Reference the precompiled style file in **index.scss**: + + + ```css + /* index.scss */ + /* Import style.scss. */ + @import '../../common/style.scss'; + .container { + background-color: $colorBackground; /* Use the variable defined in style.scss. */ + } + ``` + + + > **NOTE** + > + > Place precompiled style files in the **common** directory. diff --git a/en/application-dev/reference/arkui-js-lite/js-framework-syntax-hml.md b/en/application-dev/reference/arkui-js-lite/js-framework-syntax-hml.md new file mode 100644 index 0000000000000000000000000000000000000000..b111895cb5421d3b5d4310c56f85929c216615ec --- /dev/null +++ b/en/application-dev/reference/arkui-js-lite/js-framework-syntax-hml.md @@ -0,0 +1,310 @@ +# HML + + +The OpenHarmony Markup Language (HML) is an HTML-like language that allows you to build pages based on components and events. Pages built using HML have advanced capabilities such as data binding, event binding, loop rendering, and conditional rendering. + + +## HML Page Structure + + +```html + +
+ Image Show +
+ +
+
+``` + + +## Data Binding + + +```html + +
+ {{content[1]}} +
+``` + + +```js +// xxx.js +export default { + data: { + content: ['Hello World!', 'Welcome to my world!'] + }, + changeText: function() { + this.content.splice(1, 1, this.content[0]); + } +} +``` + +> **NOTE** +> - To make the array data modification take effect, use the **splice** method to change array items. +> +> - ECMAScript 6.0 syntax is not supported in HML. + + +## Event Binding + +The callback bound to an event receives an event object parameter, which can be used to obtain the event information. + + +```html + +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+
+``` + + +```js +// xxx.js +export default { + data: { + obj: '', + }, + clickfunc: function(e) { + this.obj = 'Hello World'; + console.log(e); + }, +} +``` + +> **NOTE** +> +> Event bubbling is supported since API version 5. After you upgrade the SDK and run an existing JavaScript application, events bound using a traditional statement (such as **onclick**) will not bubble. However, if you use the new SDK to repack the JavaScript application, such events will bubble. To avoid service logic errors, replace the traditional statement with one supported by the new SDK. For example, replace **onclick** with **grab:click**. + +**Example:** + +```html + +
+ {{count}} +
+ + + + + + +
+
+``` + + +```js +// xxx.js +export default { + data: { + count: 0 + }, + increase() { + this.count++; + }, + decrease() { + this.count--; + }, + multiply(multiplier) { + this.count = multiplier * this.count; + } +}; +``` + + +```css +/* xxx.css */ +.container { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + left: 0px; + top: 0px; + width: 454px; + height: 454px; +} +.title { + font-size: 30px; + text-align: center; + width: 200px; + height: 100px; +} +.box { + width: 454px; + height: 200px; + justify-content: center; + align-items: center; + flex-wrap: wrap; +} +.btn { + width: 200px; + border-radius: 0; + margin-top: 10px; + margin-left: 10px; +} +``` + + +## Loop Rendering + + +```html + +
+ + +
+ {{$idx}}.{{$item.name}} +
+ +
+ {{$idx}}.{{value.name}} +
+ +
+ {{index}}.{{value.name}} +
+
+``` + + +```js +// xxx.js +export default { + data: { + array: [ + {id: 1, name: 'jack', age: 18}, + {id: 2, name: 'tony', age: 18}, + ], + }, + changeText: function() { + if (this.array[1].name === "tony"){ + this.array.splice(1, 1, {id:2, name: 'Isabella', age: 18}); + } else { + this.array.splice(2, 1, {id:3, name: 'Bary', age: 18}); + } + }, +} +``` + +The **tid** attribute accelerates the **for** loop and improves the re-rendering efficiency when data in a loop changes. The **tid** attribute specifies the unique ID of each element in the array. If it is not specified, the index of each element in the array is used as the ID. For example, **tid="id"** indicates that the **id** attribute of each element is its unique ID. The **for** loop supports the following statements: + +- for="array": **array** is an array object, whose element variable is **$item** by default. + +- for="v in array": **v** is a custom element variable, whose index is **$idx** by default. + +- for="(i, v) in array": **i** indicates the element index, and **v** indicates the element variable. All elements of the array object will be looped through. + +> **NOTE** +> +> - Each element in the array must have the data attribute specified by **tid**. Otherwise, an exception may occur. +> +> - The attribute specified by **tid** in the array must be unique. Otherwise, performance loss occurs. In the above example, only **id** and **name** can be used as **tid** because they are unique fields. +> +> - The **tid** field does not support expressions. + + +## Conditional Rendering + +There are two ways to implement conditional rendering: **if-elif-else** or **show**. In **if-elif-else**, when the **if** statement evaluates to **false**, the component is not built in the VDOM and is not rendered. For **show**, when show is **false**, the component is not rendered but is built in the VDOM. In addition, the **if-elif-else** statements must be used in sibling nodes. Otherwise, the compilation fails. The following example uses both ways to implement conditional rendering: + + +```html + +
+ + + Hello-One + Hello-Two + Hello-World +
+``` + + +```css +/* xxx.css */ +.container{ + flex-direction: column; + align-items: center; +} +.btn{ + width: 280px; + font-size: 26px; + margin: 10px 0; +} +``` + + +```js +// xxx.js +export default { + data: { + show: false, + display: true, + }, + toggleShow: function() { + this.show = !this.show; + }, + toggleDisplay: function() { + this.display = !this.display; + } +} +``` + +In the optimized rendering (**show**), if **show** is **true**, the node is rendered properly; if it is **false**, the display style will be **none**. + + +```html + +
+ + Hello World +
+``` + + +```css +/* xxx.css */ +.container{ + flex-direction: column; + align-items: center; +} +.btn{ + width: 280px; + font-size: 26px; + margin: 10px 0; +} +``` + + +```js +// xxx.js +export default { + data: { + visible: false, + }, + toggle: function() { + this.visible = !this.visible; + }, +} +``` + +> **NOTE** +> +> Do not use **for** and **if** attributes at the same time in an element. diff --git a/en/application-dev/reference/arkui-js-lite/js-framework-syntax-js.md b/en/application-dev/reference/arkui-js-lite/js-framework-syntax-js.md new file mode 100644 index 0000000000000000000000000000000000000000..e9d71fc2ff680dfba5b95e7bae676854a1e68a28 --- /dev/null +++ b/en/application-dev/reference/arkui-js-lite/js-framework-syntax-js.md @@ -0,0 +1,122 @@ +# JavaScript + + +You can use a **.js** file in the ECMAScript compliant JavaScript language to define the service logic of an HML page. With dynamic typing, JavaScript can make your application more expressive with a flexible design. The following describes the JavaScript compilation and running. + + +## Syntax + +The ECMAScript 6.0 syntax is supported. Lite wearables only support the following ECMAScript 6.0 syntax: + +1. let/const + +2. arrow functions + +3. class + +4. default value + +5. destructuring assignment + +6. destructuring binding pattern + +7. enhanced object initializer + +8. for-of + +9. rest parameter + +10. template strings + +- Module declaration + Import functionality modules. + + + ``` + import router from '@system.router'; + ``` + +- Code reference + Import JavaScript code. + + + ``` + import utils from '../../common/utils.js'; + ``` + + +## Objects + +- Page objects + | Attribute | Type | Description | + | ----- | --------------- | ---------------------------------------- | + | data | Object/Function | Data model of the page. If the attribute is of the function type, the return value must be of the object type. The name cannot start with a dollar sign ($) or underscore (_). Do not use reserved words (**for**, **if**, **show**, and **tid**).
| + | $refs | Object | DOM elements or child component instances that have registered the **ref** attribute. For an example, see [Obtaining a DOM Element](#obtaining-a-dom-element). | + + +## Obtaining a DOM Element + +Use **$refs** to obtain a DOM element. + +```html + +
+ +
+``` + + + ```js + // index.js + export default { + data: { + images: [ + { src: '/common/frame1.png' }, + { src: '/common/frame2.png' }, + { src: '/common/frame3.png' }, + ], + }, + handleClick() { + const animator = this.$refs.animator; // Obtain the DOM element whose $refs attribute is animator. + const state = animator.getState(); + if (state === 'paused') { + animator.resume(); + } else if (state === 'stopped') { + animator.start(); + } else { + animator.pause(); + } + }, + }; + ``` + + +## Lifecycle APIs + +- Page lifecycle APIs + | Name | Type | Parameter | Return Value | Description | Triggered When | + | --------- | -------- | ---- | ---- | ------ | ------------------- | + | onInit | Function | N/A | N/A | Listens for page initialization. | Page initialization is complete. This API is called only once in the page lifecycle.| + | onReady | Function | N/A | N/A | Listens for page creation.| A page is created. This API is called only once in the page lifecycle. | + | onShow | Function | N/A | N/A | Listens for page display. | The page is displayed. | + | onHide | Function | N/A | N/A | Listens for page disappearance. | The page disappears. | + | onDestroy | Function | N/A | N/A | Listens for page destruction. | The page is destroyed. | + + The lifecycle APIs of page A are called in the following sequence: + - Open page A: onInit() -> onReady() -> onShow() + + - Open page B on page A: onHide() -> onDestroy() + + - Go back to page A from page B: onInit() -> onReady() -> onShow() + + - Exit page A: onHide() -> onDestroy() + + - Hide page A: onHide() + + - Show background page A on the foreground: onShow() + +- Application lifecycle APIs + | Name | Type | Parameter | Return Value | Description | Triggered When | + | --------- | -------- | ---- | ---- | ---- | --------- | + | onCreate | Function | N/A | N/A | Listens for application creation.| The application is created.| + | onDestroy | Function | N/A | N/A | Listens for application exit.| The application exits.| diff --git a/en/application-dev/reference/arkui-js-lite/public_sys-resources/icon-caution.gif b/en/application-dev/reference/arkui-js-lite/public_sys-resources/icon-caution.gif new file mode 100644 index 0000000000000000000000000000000000000000..6e90d7cfc2193e39e10bb58c38d01a23f045d571 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/public_sys-resources/icon-caution.gif differ diff --git a/en/application-dev/reference/arkui-js-lite/public_sys-resources/icon-danger.gif b/en/application-dev/reference/arkui-js-lite/public_sys-resources/icon-danger.gif new file mode 100644 index 0000000000000000000000000000000000000000..6e90d7cfc2193e39e10bb58c38d01a23f045d571 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/public_sys-resources/icon-danger.gif differ diff --git a/en/application-dev/reference/arkui-js-lite/public_sys-resources/icon-note.gif b/en/application-dev/reference/arkui-js-lite/public_sys-resources/icon-note.gif new file mode 100644 index 0000000000000000000000000000000000000000..6314297e45c1de184204098efd4814d6dc8b1cda Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/public_sys-resources/icon-note.gif differ diff --git a/en/application-dev/reference/arkui-js-lite/public_sys-resources/icon-notice.gif b/en/application-dev/reference/arkui-js-lite/public_sys-resources/icon-notice.gif new file mode 100644 index 0000000000000000000000000000000000000000..86024f61b691400bea99e5b1f506d9d9aef36e27 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/public_sys-resources/icon-notice.gif differ diff --git a/en/application-dev/reference/arkui-js-lite/public_sys-resources/icon-tip.gif b/en/application-dev/reference/arkui-js-lite/public_sys-resources/icon-tip.gif new file mode 100644 index 0000000000000000000000000000000000000000..93aa72053b510e456b149f36a0972703ea9999b7 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/public_sys-resources/icon-tip.gif differ diff --git a/en/application-dev/reference/arkui-js-lite/public_sys-resources/icon-warning.gif b/en/application-dev/reference/arkui-js-lite/public_sys-resources/icon-warning.gif new file mode 100644 index 0000000000000000000000000000000000000000..6e90d7cfc2193e39e10bb58c38d01a23f045d571 Binary files /dev/null and b/en/application-dev/reference/arkui-js-lite/public_sys-resources/icon-warning.gif differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_canvas_height.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_canvas_height.png new file mode 100644 index 0000000000000000000000000000000000000000..589059ee8bf53b736cdadfc79ee44bbfd9d3db02 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_canvas_height.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_canvas_width.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_canvas_width.png new file mode 100644 index 0000000000000000000000000000000000000000..c9d63dc6b6ff97b2b0ff3ae4599b787db8dd096f Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_canvas_width.png differ diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-gauge.md b/en/application-dev/reference/arkui-ts/ts-basic-components-gauge.md index 2fe773177813164169dc35eddeba176a95fa4f89..6cf611c47dfd4d3d08b3124ec50e38b0ca1a4da7 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-gauge.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-gauge.md @@ -23,9 +23,9 @@ Since API version 9, this API is supported in ArkTS widgets. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| value | number | Yes| Current value of the chart, that is, the position to which the pointer points in the chart. It is used as the initial value of the chart when the component is created.| +| value | number | Yes| Current value of the chart, that is, the position to which the pointer points in the chart. It is used as the initial value of the chart when the component is created.
**NOTE**
If the value is not within the range defined by the **min** and **max** parameters, the value of **min** is used.| | min | number | No| Minimum value of the current data segment.
Default value: **0**| -| max | number | No| Maximum value of the current data segment.
Default value: **100**| +| max | number | No| Maximum value of the current data segment.
Default value: **100**
**NOTE**
If the value of **max** is less than that of **min**, the default values **0** and **100** are used.
The values of **max** and **min** can be negative numbers.| ## Attributes @@ -36,8 +36,8 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the | value | number | Value of the chart. It can be dynamically changed.
Default value: **0**
Since API version 9, this API is supported in ArkTS widgets.| | startAngle | number | Start angle of the chart. The value **0** indicates 0 degrees, and a positive value indicates the clockwise direction.
Default value: **0**
Since API version 9, this API is supported in ArkTS widgets.| | endAngle | number | End angle of the chart. The value **0** indicates 0 degrees, and a positive value indicates the clockwise direction.
Default value: **360**
Since API version 9, this API is supported in ArkTS widgets.| -| colors | Array<[ColorStop](#colorstop)> | Colors of the chart. Colors can be set for individual segments.
Since API version 9, this API is supported in ArkTS widgets.| -| strokeWidth | Length | Stroke width of the chart.
Since API version 9, this API is supported in ArkTS widgets.| +| colors | Array<[ColorStop](#colorstop)> | Colors of the chart. Colors can be set for individual segments.
Default value: **Color.Black**
Since API version 9, this API is supported in ArkTS widgets.| +| strokeWidth | Length | Stroke width of the chart.
Default value: **4**
Unit: vp
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
A value less than 0 evaluates to the default value.
The value cannot be in percentage.| ## ColorStop @@ -47,7 +47,7 @@ Since API version 9, this API is supported in ArkTS widgets. | Name | Type | Description | | --------- | -------------------- | ------------------------------------------------------------ | -| ColorStop | [[ResourceColor](ts-types.md#resourcecolor), number] | Type of the gradient stop. The first parameter indicates the color value. If it is set to a non-color value, the black color is used. The second parameter indicates the color weight. If it is set to a negative number or a non-numeric value, the color weight is 0, which means that the color is not displayed.| +| ColorStop | [[ResourceColor](ts-types.md#resourcecolor), number] | Type of the gradient stop. The first parameter indicates the color value. If it is set to a non-color value, the black color is used. The second parameter indicates the color weight. If it is set to a negative number or a non-numeric value, the color weight is 0.| ## Example diff --git a/en/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md b/en/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md index 575b24c6ae39a82fdc9793301ffd581da96d1c59..d23a8649fc8a002b051036012570632cab47c6ad 100644 --- a/en/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md +++ b/en/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md @@ -10,7 +10,7 @@ Use **RenderingContext** to draw rectangles, text, images, and other objects on ## APIs -CanvasRenderingContext2D(setting: RenderingContextSetting) +CanvasRenderingContext2D(settings?: RenderingContextSettings) Since API version 9, this API is supported in ArkTS widgets. @@ -18,7 +18,7 @@ Since API version 9, this API is supported in ArkTS widgets. | Name | Type | Mandatory | Description | | ------- | ---------------------------------------- | ---- | ---------------------------------------- | -| setting | [RenderingContextSettings](#renderingcontextsettings) | Yes | See [RenderingContextSettings](#renderingcontextsettings).| +| settings | [RenderingContextSettings](#renderingcontextsettings) | No | See [RenderingContextSettings](#renderingcontextsettings).| ### RenderingContextSettings @@ -57,6 +57,8 @@ Since API version 9, this API is supported in ArkTS widgets. | [shadowOffsetX](#shadowoffsetx) | number | X-axis shadow offset relative to the original object.
Since API version 9, this API is supported in ArkTS widgets. | | [shadowOffsetY](#shadowoffsety) | number | Y-axis shadow offset relative to the original object.
Since API version 9, this API is supported in ArkTS widgets. | | [imageSmoothingEnabled](#imagesmoothingenabled) | boolean | Whether to adjust the image smoothness during image drawing. The value **true** means to enable this feature, and **false** means the opposite.
Default value: **true**
Since API version 9, this API is supported in ArkTS widgets. | +| [height](#height) | number | Component height.
Unit: vp
Since API version 9, this API is supported in ArkTS widgets.| +| [width](#width) | number | Component width.
Unit: vp
Since API version 9, this API is supported in ArkTS widgets.| > **NOTE** > @@ -652,6 +654,68 @@ struct ImageSmoothingEnabled { ![en-us_image_0000001211898472](figures/en-us_image_0000001211898472.png) +### height + +```ts +// xxx.ets +@Entry +@Component +struct HeightExample { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width(300) + .height(300) + .backgroundColor('#ffff00') + .onReady(() => { + let h = this.context.height + let w = this.context.width + this.context.fillRect(0, 0, 300, h/2) + }) + } + .width('100%') + .height('100%') + } +} +``` + +![en-us_image_canvas_height](figures/en-us_image_canvas_height.png) + + +### width + +```ts +// xxx.ets +@Entry +@Component +struct WidthExample { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width(300) + .height(300) + .backgroundColor('#ffff00') + .onReady(() => { + let h = this.context.height + let w = this.context.width + this.context.fillRect(0, 0, w/2, 300) + }) + } + .width('100%') + .height('100%') + } +} +``` + +![en-us_image_canvas_width](figures/en-us_image_canvas_width.png) + + ## Methods diff --git a/en/application-dev/reference/arkui-ts/ts-container-sidebarcontainer.md b/en/application-dev/reference/arkui-ts/ts-container-sidebarcontainer.md index 3a1ef0bfa62a2081886367baef187b963490d8bb..b01457d9d6e564b7998492d88cd18bf5d8bcd293 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-sidebarcontainer.md +++ b/en/application-dev/reference/arkui-ts/ts-container-sidebarcontainer.md @@ -44,7 +44,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the | showSideBar | boolean | Whether to display the sidebar.
Default value: **true** | | controlButton | [ButtonStyle](#buttonstyle) | Attributes of the sidebar control button.| | showControlButton | boolean | Whether to display the sidebar control button.
Default value: **true**| -| sideBarWidth | number \| Length9+ | Width of the sidebar.
Default value: **200**
Unit: vp
**NOTE**
A value less than 0 evaluates to the default value.
The value must comply with the width constraints. If it is not within the valid range, the value closest to the set one is used.
When set, the width of the sidebar takes precedence over that of the sidebar child components. If it is not set, however, the width of the sidebar child component takes precedence.| +| sideBarWidth | number \| Length9+ | Width of the sidebar.
Default value: **200**
Unit: vp
**NOTE**
A value less than 0 evaluates to the default value.
The value must comply with the width constraints. If it is not within the valid range, the value closest to the set one is used.
The width of the sidebar, whether it is specified or kept at the default, takes precedence over that of the sidebar child components.| | minSideBarWidth | number \| Length9+ | Minimum width of the sidebar.
Default value: **200**, in vp
**NOTE**
A value less than 0 evaluates to the default value.
The value cannot exceed the width of the sidebar container itself. Otherwise, the width of the sidebar container itself is used.
When set, the minimum width of the sidebar takes precedence over that of the sidebar child components. If it is not set, however, the minimum width of the sidebar child component takes precedence.| | maxSideBarWidth | number \| Length9+ | Maximum width of the sidebar.
Default value: **280**, in vp
**NOTE**
A value less than 0 evaluates to the default value.
The value cannot exceed the width of the sidebar container itself. Otherwise, the width of the sidebar container itself is used.
When set, the maximum width of the sidebar takes precedence over that of the sidebar child components. If it is not set, however, the maximum width of the sidebar child component takes precedence.| | autoHide9+ | boolean | Whether to automatically hide the sidebar when it is dragged to be smaller than the minimum width.
Default value: **true**
**NOTE**
The value is subject to the **minSideBarWidth** attribute method. If it is not set in **minSideBarWidth**, the default value is used.
Whether the sidebar should be hidden is determined when it is being dragged. When its width is less than the minimum width, the damping effect is required to trigger hiding (a distance out of range).| diff --git a/en/application-dev/reference/arkui-ts/ts-container-swiper.md b/en/application-dev/reference/arkui-ts/ts-container-swiper.md index 6819991d4c66ba1a96ca51dc4d56e7d900d24c0f..d5df61c6316ba122bb8d4bcb05032828310b0e7a 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-swiper.md +++ b/en/application-dev/reference/arkui-ts/ts-container-swiper.md @@ -45,7 +45,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the | cachedCount8+ | number | Number of child components to be cached.
Default value: **1**
**NOTE**
**cachedCount** has caching optimized. You are advised not to use it together with [LazyForEach](../../quick-start/arkts-rendering-control-lazyforeach.md).| | disableSwipe8+ | boolean | Whether to disable the swipe feature.
Default value: **false** | | curve8+ | [Curve](ts-appendix-enums.md#curve) \| string | Animation curve. The ease-in/ease-out curve is used by default. For details about common curves, see [Curve](ts-appendix-enums.md#curve). You can also create custom curves (interpolation curve objects) by using the API provided by the [interpolation calculation](../apis/js-apis-curve.md) module.
Default value: **Curve.Linear**| -| indicatorStyle8+ | {
left?: [Length](ts-types.md#length),
top?: [Length](ts-types.md#length),
right?: [Length](ts-types.md#length),
bottom?: [Length](ts-types.md#length),
size?: [Length](ts-types.md#length),
mask?: boolean,
color?: [ResourceColor](ts-types.md),
selectedColor?: [ResourceColor](ts-types.md)
} | Style of the navigation point indicator.
\- **left**: distance between the navigation point indicator and the left edge of the **\** component.
\- **top**: distance between the navigation point indicator and the top edge of the **\** component.
\- **right**: distance between the navigation point indicator and the right edge of the **\** component.
\- **bottom**: distance between the navigation point indicator and the bottom edge of the **\** component.
\- **size**: diameter of the navigation point indicator.
\- **mask**: whether to enable the mask for the navigation point indicator.
\- **color**: color of the navigation point indicator.
\- **selectedColor**: color of the selected navigation dot.| +| indicatorStyle8+ | {
left?: [Length](ts-types.md#length),
top?: [Length](ts-types.md#length),
right?: [Length](ts-types.md#length),
bottom?: [Length](ts-types.md#length),
size?: [Length](ts-types.md#length),
mask?: boolean,
color?: [ResourceColor](ts-types.md),
selectedColor?: [ResourceColor](ts-types.md)
} | Style of the navigation point indicator.
\- **left**: distance between the navigation point indicator and the left edge of the **\** component.
\- **top**: distance between the navigation point indicator and the top edge of the **\** component.
\- **right**: distance between the navigation point indicator and the right edge of the **\** component.
\- **bottom**: distance between the navigation point indicator and the bottom edge of the **\** component.
\- **size**: diameter of the navigation point indicator. The value cannot be in percentage. Default value: **6vp**
\- **mask**: whether to enable the mask for the navigation point indicator.
\- **color**: color of the navigation point indicator.
\- **selectedColor**: color of the selected navigation dot.| | displayCount8+ | number \| string | Number of elements to display per page.
Default value: **1**
**NOTE**
If the value is of the string type, it can only be **'auto'**, whose display effect is the same as that of **SwiperDisplayMode.AutoLinear**.
If the value is of the number type, child components stretch (shrink) on the main axis after the swiper width [deducting the result of itemSpace x (displayCount - 1)] is evenly distributed among them on the main axis.| | effectMode8+ | [EdgeEffect](ts-appendix-enums.md#edgeeffect) | Swipe effect. For details, see **EdgeEffect**.
Default value: **EdgeEffect.Spring**
**NOTE**
The spring effect does not take effect when the controller API is called.| diff --git a/en/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md b/en/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md index 4c164070999d363b634dc618fa6660b33fbfe1ba..6b28fef85c3e3ea991aa9c99881513cd3d88061a 100644 --- a/en/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md +++ b/en/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md @@ -10,7 +10,7 @@ Use **OffscreenCanvasRenderingContext2D** to draw rectangles, images, and text o ## APIs -OffscreenCanvasRenderingContext2D(width: number, height: number, setting: RenderingContextSettings) +OffscreenCanvasRenderingContext2D(width: number, height: number, settings?: RenderingContextSettings) Since API version 9, this API is supported in ArkTS widgets. @@ -20,7 +20,7 @@ Since API version 9, this API is supported in ArkTS widgets. | ------- | ------------------------------------------------------------ | ---- | ------------------------------------ | | width | number | Yes | Width of the offscreen canvas. | | height | number | Yes | Height of the offscreen canvas. | -| setting | [RenderingContextSettings](ts-canvasrenderingcontext2d.md#renderingcontextsettings) | Yes | See RenderingContextSettings.| +| settings | [RenderingContextSettings](ts-canvasrenderingcontext2d.md#renderingcontextsettings) | No | See RenderingContextSettings.| ## Attributes diff --git a/en/application-dev/reference/arkui-ts/ts-types.md b/en/application-dev/reference/arkui-ts/ts-types.md index 4fe6dd3ceaaf9bdcdc06b5b5a1fc1b92c7f1a1fb..83ca533b355809a9e3550975116ce55d4844ef3c 100644 --- a/en/application-dev/reference/arkui-ts/ts-types.md +++ b/en/application-dev/reference/arkui-ts/ts-types.md @@ -146,7 +146,7 @@ The **Font** type is used to set the text style. | ------ | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | size | [Length](#length) | No | Font size. If the value is of the number type, the unit fp is used. The value cannot be a percentage.| | weight | [FontWeight](ts-appendix-enums.md#fontweight) \| number \| string | No | Font weight. For the number type, the value ranges from 100 to 900, at an interval of 100. The default value is **400**. A larger value indicates a larger font weight.| -| family | string \| [Resource](#resource) | No | Font family of the text. Use commas (,) to separate multiple fonts. The priority of the fonts is the sequence in which they are placed. An example value is **'Arial, sans-serif'**. Currently, only the **'sans-serif'** font is supported.| +| family | string \| [Resource](#resource) | No | Font family of the text. Use commas (,) to separate multiple fonts. The priority of the fonts is the sequence in which they are placed. An example value is **'Arial, HarmonyOS Sans'**. Currently, only the **'HarmonyOS Sans'** font is supported.| | style | [FontStyle](ts-appendix-enums.md#fontstyle) | No | Font style. | ## Area8+ diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-flex-layout.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-flex-layout.md index 4d907d32c2d3545fb6b0afb10addabbf2053eb90..f0858c17f6f7d95d1d96757c3cadb3ad1fdc140b 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-flex-layout.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-flex-layout.md @@ -14,6 +14,7 @@ | flexGrow | number | Percentage of the parent container's remaining space that is allocated to the component.
Default value: **0**
Since API version 9, this API is supported in ArkTS widgets.| | flexShrink | number | Percentage of the parent container's shrink size that is allocated to the component.
When the parent container is **\** or **\**, the default value is **0**.
When the parent container is **\**, the default value is **1**.
Since API version 9, this API is supported in ArkTS widgets.| | alignSelf | [ItemAlign](ts-appendix-enums.md#itemalign) | Alignment mode of the child components along the cross axis of the parent container. The setting overwrites the **alignItems** setting of the parent container.
Default value: **ItemAlign.Auto**
Since API version 9, this API is supported in ArkTS widgets.| +| layoutWeight | number \| string | Weight of the component during layout. When the container size is determined, the container space is allocated along the main axis among the component and sibling components based on the layout weight, and the component size setting is ignored.
Default value: **0**
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
This attribute is valid only for the **\**, **\**, and **\** layouts.
The value can be a number greater than or equal to 0 or a string that can be converted to a number.| ## Example diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md index 614faeb3055349f54006933512feb2c4bd54f520..208a439b20a26388f719f00fc0690cd292071098 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md @@ -30,7 +30,7 @@ You can bind a popup to a component, specifying its content, interaction logic, | Name | Type | Mandatory | Description | | ---------------------------- | ---------------------------------------- | ---- | ---------------------------------------- | -| builder | [CustomBuilder](ts-types.md#custombuilder8) | Yes | Popup builder. | +| builder | [CustomBuilder](ts-types.md#custombuilder8) | Yes | Popup builder.
**NOTE**
The **popup** attribute is a universal attribute. A custom popup does not support display of another popup. The **position** attribute cannot be used for the first-layer container under the builder. If the **position** attribute is used, the popup will not be displayed. | | placement | [Placement](ts-appendix-enums.md#placement8) | No | Preferred position of the popup. If the set position is insufficient for holding the popup, it will be automatically adjusted.
Default value: **Placement.Bottom**| | popupColor | [ResourceColor](ts-types.md#resourcecolor) | No | Color of the popup. | | enableArrow | boolean | No | Whether to display an arrow.
Since API version 9, if the position set for the popup is not large enough, the arrow will not be displayed. For example, if **placement** is set to **Left**, but the popup height (80 vp) is less than the sum of the arrow width (32 vp) and diameter of popup rounded corner (48 vp), the arrow will not be displayed.
Default value: **true**| @@ -100,7 +100,7 @@ struct PopupExample { .bindPopup(this.customPopup, { builder: this.popupBuilder, placement: Placement.Top, - maskColor: '0x33000000', + mask: {color:'0x33000000'}, popupColor: Color.Yellow, enableArrow: true, showInSubWindow: false, diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-size.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-size.md index ef361829897dcbf29396cb14d654051bea2f41c6..8d42dea9981ac068c5559df80c225e21794b750a 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-size.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-size.md @@ -18,7 +18,6 @@ The size attributes set the width, height, and margin of a component. | padding | [Padding](ts-types.md#padding) \| [Length](ts-types.md#length) | Padding of the component.
When the parameter is of the **Length** type, the four paddings take effect.
Default value: **0**
When **padding** is set to a percentage, the width of the parent container is used as the basic value.
Since API version 9, this API is supported in ArkTS widgets.| | margin | [Margin](ts-types.md#margin) \| [Length](ts-types.md#length) | Margin of the component.
When the parameter is of the **Length** type, the four margins take effect.
Default value: **0**
When **margin** is set to a percentage, the width of the parent container is used as the basic value.
Since API version 9, this API is supported in ArkTS widgets.| | constraintSize | {
minWidth?: [Length](ts-types.md#length),
maxWidth?: [Length](ts-types.md#length),
minHeight?: [Length](ts-types.md#length),
maxHeight?: [Length](ts-types.md#length)
} | Constraint size of the component, which is used to limit the size range during component layout. **constraintSize** takes precedence over **width** and **height**. If the value of **minWidth** is greater than that of **maxWidth**, only the value of **minWidth** takes effect. The same rule applies to **minHeight** and **maxHeight**.
Default value:
{
minWidth: 0,
maxWidth: Infinity,
minHeight: 0,
maxHeight: Infinity
}
Since API version 9, this API is supported in ArkTS widgets.| -| layoutWeight | number \| string | Weight of the component during layout. When the container size is determined, the container space is allocated along the main axis among the component and sibling components based on the layout weight, and the component size setting is ignored.
Default value: **0**
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
This attribute is valid only for the **\**, **\**, and **\** layouts.
The value can be a number greater than or equal to 0 or a string that can be converted to a number.| ## Example diff --git a/en/application-dev/reference/errorcodes/errorcode-data-rdb.md b/en/application-dev/reference/errorcodes/errorcode-data-rdb.md index 7da8eb85ea4d4c94d68f8057900a204743afbf5b..6488b3551ac06f3aa12af58445912e1128651fee 100644 --- a/en/application-dev/reference/errorcodes/errorcode-data-rdb.md +++ b/en/application-dev/reference/errorcodes/errorcode-data-rdb.md @@ -4,11 +4,29 @@ > > This topic describes only module-specific error codes. For details about universal error codes, see [Universal Error Codes](errorcode-universal.md). +## 14800000 Internal Error + +**Error Message** + +Inner error. + +**Description** + +An error occurs at the underlying database. + +**Possible Causes** + +Invalid SQL statement is passed in. + +**Solution** + +Determine the cause of the error based on the log information. + ## 14800010 Invalid RDB Name **Error Message** -Invalid database name. +Failed to open or delete database by invalid database path. **Description** @@ -16,17 +34,17 @@ The RDB store name is invalid. **Possible Causes** -The RDB store name is empty or exceeds 1024 bytes. +The RDB store path is invalid. **Solution** -Check that the RDB store name is not empty and does not exceed 1024 bytes. +Check the RDB store path. ## 14800011 Database File Corrupted **Error Message** -Database corrupted. +Failed to open database by database corrupted. **Description** diff --git a/en/application-dev/reference/errorcodes/errorcode-nfc.md b/en/application-dev/reference/errorcodes/errorcode-nfc.md index 07e1648fe3256d63c9a74a0a580041ebd4b869d9..a8af05666cd02995cda09fd28d9823944fd1699c 100644 --- a/en/application-dev/reference/errorcodes/errorcode-nfc.md +++ b/en/application-dev/reference/errorcodes/errorcode-nfc.md @@ -47,3 +47,21 @@ An error occurs when the NFC service executes the tag service logic. 3. Connect to the tag and then perform the read and write operations. 4. Touch and read the card again. 5. Exit the app and read the card again. + +## 3200101 + +**Error Message** + +Connected NFC tag running state is abnormal in service. + +**Description** + +An error occurs when the service logic of the active NFC tag is executed. + +**Possible Causes** +1. The parameter values of the active NFC tag does not match the API called. +2. The active NFC tag chip does not respond within the specified time or returns an error state. + +**Solution** +1. Check that the active NFC tag parameters match the API called. +2. Touch and read the card again. diff --git a/en/application-dev/reference/errorcodes/errorcode-zlib.md b/en/application-dev/reference/errorcodes/errorcode-zlib.md index 47d5b3c6604b7bc2361d4355e829527dc5a15b9c..9e82ed0167d9868d1d5b7b5a7fdd39171733e703 100644 --- a/en/application-dev/reference/errorcodes/errorcode-zlib.md +++ b/en/application-dev/reference/errorcodes/errorcode-zlib.md @@ -21,7 +21,8 @@ When the **compress** API is called, the file to compress does not exist. When t **Solution** 1. Make sure the source file exists. -2. Make sure the path of the source file exists and the path is the correct sandbox path. +2. Ensure that the source file is in ZIP format. +3. Make sure the path of the source file exists and the path is the correct sandbox path. ## 900002 Invalid Destination File diff --git a/en/application-dev/reference/js-service-widget-ui/Readme-EN.md b/en/application-dev/reference/js-service-widget-ui/Readme-EN.md index 58b90a13761930910434b5d4bc95252119a3fced..9a487432df38c92f05714374d52eea2228ea8d9d 100644 --- a/en/application-dev/reference/js-service-widget-ui/Readme-EN.md +++ b/en/application-dev/reference/js-service-widget-ui/Readme-EN.md @@ -8,33 +8,32 @@ - [Multi-Language Capability](js-service-widget-multiple-languages.md) - [Version Compatibility Adaptation](js-service-widget-version-compatibility.md) - [Theme Configuration](js-service-widget-theme.md) -- Components - - Universal - - [Universal Attributes](js-service-widget-common-attributes.md) - - [Universal Styles](js-service-widget-common-styles.md) - - [Universal Events](js-service-widget-common-events.md) - - [Gradient Styles](js-service-widget-common-gradient.md) - - [Media Query](js-service-widget-common-mediaquery.md) - - [Custom Font Styles](js-service-widget-common-customizing-font.md) - - [Accessibility](js-service-widget-common-accessibility.md) - - [Atomic Layout](js-service-widget-common-atomic-layout.md) - - Container Components - - [badge](js-service-widget-container-badge.md) - - [div](js-service-widget-container-div.md) - - [list](js-service-widget-container-list.md) - - [list-item](js-service-widget-container-list-item.md) - - [stack](js-service-widget-container-stack.md) - - [swiper](js-service-widget-container-swiper.md) - - Basic Components - - [button](js-service-widget-basic-button.md) - - [calendar](js-service-widget-basic-calendar.md) - - [chart](js-service-widget-basic-chart.md) - - [clock](js-service-widget-basic-clock.md) - - [divider](js-service-widget-basic-divider.md) - - [image](js-service-widget-basic-image.md) - - [input](js-service-widget-basic-input.md) - - [progress](js-service-widget-basic-progress.md) - - [span](js-service-widget-basic-span.md) - - [text](js-service-widget-basic-text.md) +- Universal Component Information + - [Universal Attributes](js-service-widget-common-attributes.md) + - [Universal Styles](js-service-widget-common-styles.md) + - [Universal Events](js-service-widget-common-events.md) + - [Gradient Styles](js-service-widget-common-gradient.md) + - [Media Query](js-service-widget-common-mediaquery.md) + - [Custom Font Styles](js-service-widget-common-customizing-font.md) + - [Accessibility](js-service-widget-common-accessibility.md) + - [Atomic Layout](js-service-widget-common-atomic-layout.md) +- Container Components + - [badge](js-service-widget-container-badge.md) + - [div](js-service-widget-container-div.md) + - [list](js-service-widget-container-list.md) + - [list-item](js-service-widget-container-list-item.md) + - [stack](js-service-widget-container-stack.md) + - [swiper](js-service-widget-container-swiper.md) +- Basic Components + - [button](js-service-widget-basic-button.md) + - [calendar](js-service-widget-basic-calendar.md) + - [chart](js-service-widget-basic-chart.md) + - [clock](js-service-widget-basic-clock.md) + - [divider](js-service-widget-basic-divider.md) + - [image](js-service-widget-basic-image.md) + - [input](js-service-widget-basic-input.md) + - [progress](js-service-widget-basic-progress.md) + - [span](js-service-widget-basic-span.md) + - [text](js-service-widget-basic-text.md) - [Custom Component Basic Usage](js-service-widget-custom-basic-usage.md) - [Data Types](js-service-widget-appendix-types.md) diff --git a/en/application-dev/reference/native-apis/_audio_decoder.md b/en/application-dev/reference/native-apis/_audio_decoder.md index 2e9139ac64dd9cdc27f2099b43be1d680551be0a..73487fa40d3fb0eb8490b71bda87d3dde1986497 100644 --- a/en/application-dev/reference/native-apis/_audio_decoder.md +++ b/en/application-dev/reference/native-apis/_audio_decoder.md @@ -3,42 +3,41 @@ ## Overview -Provides the functions for audio decoding. +Provides the functions for audio decoding. This module may not be supported on some devices. You can call [CanIUse](../syscap.md) to check whether this module is supported on your device. -\@syscap SystemCapability.Multimedia.Media.AudioDecoder +@syscap SystemCapability.Multimedia.Media.AudioDecoder -**Since:** +**Since** 9 - ## Summary ### Files -| Name | Description | + | Name| Description| | -------- | -------- | -| [native_avcodec_audiodecoder.h](native__avcodec__audiodecoder_8h.md) | Declares the native APIs used for audio decoding.
File to Include: | +| [native_avcodec_audiodecoder.h](native__avcodec__audiodecoder_8h.md) | Declares the native APIs used for audio decoding.
File to include: | ### Functions -| Name | Description | + | Name| Description| | -------- | -------- | -| [OH_AudioDecoder_CreateByMime](#oh_audiodecoder_createbymime) (const char \*mime) | Creates an audio decoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This API is recommended in most cases. | -| [OH_AudioDecoder_CreateByName](#oh_audiodecoder_createbyname) (const char \*name) | Creates an audio decoder instance based on an audio decoder name. To use this API, you must know the exact name of the audio decoder. | -| [OH_AudioDecoder_Destroy](#oh_audiodecoder_destroy) (OH_AVCodec \*codec) | Clears the internal resources of an audio decoder and destroys the audio decoder instance. | -| [OH_AudioDecoder_SetCallback](#oh_audiodecoder_setcallback) (OH_AVCodec \*codec, [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md) callback, void \*userData) | Sets an asynchronous callback so that your application can respond to events generated by an audio decoder. This API must be called prior to **Prepare**. | -| [OH_AudioDecoder_Configure](#oh_audiodecoder_configure) (OH_AVCodec \*codec, OH_AVFormat \*format) | Configures an audio decoder. Typically, you need to configure the attributes, which can be extracted from the container, of the audio track that can be decoded. This API must be called prior to **Prepare**. | -| [OH_AudioDecoder_Prepare](#oh_audiodecoder_prepare) (OH_AVCodec \*codec) | Prepares internal resources for an audio decoder. This API must be called after **Configure**. | -| [OH_AudioDecoder_Start](#oh_audiodecoder_start) (OH_AVCodec \*codec) | Starts an audio decoder. This API can be called only after the decoder is prepared successfully. After being started, the decoder starts to report the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) event. | -| [OH_AudioDecoder_Stop](#oh_audiodecoder_stop) (OH_AVCodec \*codec) | Stops an audio decoder. After the decoder is stopped, you can call **Start** to start it again. If you have passed codec-specific data in the previous **Start** for the decoder, you must pass it again. | -| [OH_AudioDecoder_Flush](#oh_audiodecoder_flush) (OH_AVCodec \*codec) | Clears the input and output data in the internal buffer of an audio decoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required. | -| [OH_AudioDecoder_Reset](#oh_audiodecoder_reset) (OH_AVCodec \*codec) | Resets an audio decoder. To continue decoding, you must call **Configure** and **Start** to configure and start the decoder again. | -| [OH_AudioDecoder_GetOutputDescription](#oh_audiodecoder_getoutputdescription) (OH_AVCodec \*codec) | Obtains the attributes of the output data of an audio decoder. The caller must manually release the **OH_AVFormat** instance in the return value. | -| [OH_AudioDecoder_SetParameter](#oh_audiodecoder_setparameter) (OH_AVCodec \*codec, OH_AVFormat \*format) | Sets dynamic parameters for an audio decoder. This API can be called only after the decoder is started. Incorrect parameter settings may cause decoding failure. | -| [OH_AudioDecoder_PushInputData](#oh_audiodecoder_pushinputdata) (OH_AVCodec \*codec, uint32_t index, [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) attr) | Pushes the input buffer filled with data to an audio decoder. The [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback reports available input buffers and their indexes. After being pushed to the decoder, a buffer is not accessible until the buffer with the same index is reported again through the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback. In addition, some decoders require the input of codec-specific data to initialize the decoding process. | -| [OH_AudioDecoder_FreeOutputData](#oh_audiodecoder_freeoutputdata) (OH_AVCodec \*codec, uint32_t index) | Frees an output buffer of an audio decoder. | +| [OH_AudioDecoder_CreateByMime](#oh_audiodecoder_createbymime) (const char \*mime) | Creates an audio decoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This API is recommended in most cases. | +| [OH_AudioDecoder_CreateByName](#oh_audiodecoder_createbyname) (const char \*name) | Creates an audio decoder instance based on an audio decoder name. To use this API, you must know the exact name of the audio decoder. | +| [OH_AudioDecoder_Destroy](#oh_audiodecoder_destroy) (OH_AVCodec \*codec) | Clears the internal resources of an audio decoder and destroys the audio decoder instance. | +| [OH_AudioDecoder_SetCallback](#oh_audiodecoder_setcallback) (OH_AVCodec \*codec, [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md) callback, void \*userData) | Sets an asynchronous callback so that your application can respond to events generated by an audio decoder. This API must be called prior to **Prepare**. | +| [OH_AudioDecoder_Configure](#oh_audiodecoder_configure) (OH_AVCodec \*codec, OH_AVFormat \*format) | Configures an audio decoder. Typically, you need to configure the attributes, which can be extracted from the container, of the audio track that can be decoded. This API must be called prior to **Prepare**. | +| [OH_AudioDecoder_Prepare](#oh_audiodecoder_prepare) (OH_AVCodec \*codec) | Prepares internal resources for an audio decoder. This API must be called after **Configure**. | +| [OH_AudioDecoder_Start](#oh_audiodecoder_start) (OH_AVCodec \*codec) | Starts an audio decoder. This API can be called only after the decoder is prepared successfully. After being started, the decoder starts to report the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) event. | +| [OH_AudioDecoder_Stop](#oh_audiodecoder_stop) (OH_AVCodec \*codec) | Stops an audio decoder. After the decoder is stopped, you can call **Start** to start it again. If you have passed codec-specific data in the previous **Start** for the decoder, you must pass it again. | +| [OH_AudioDecoder_Flush](#oh_audiodecoder_flush) (OH_AVCodec \*codec) | Clears the input and output data in the internal buffer of an audio decoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required. | +| [OH_AudioDecoder_Reset](#oh_audiodecoder_reset) (OH_AVCodec \*codec) | Resets an audio decoder. To continue decoding, you must call **Configure** and **Start** to configure and start the decoder again. | +| [OH_AudioDecoder_GetOutputDescription](#oh_audiodecoder_getoutputdescription) (OH_AVCodec \*codec) | Obtains the attributes of the output data of an audio decoder. The caller must manually release the **OH_AVFormat** instance in the return value. | +| [OH_AudioDecoder_SetParameter](#oh_audiodecoder_setparameter) (OH_AVCodec \*codec, OH_AVFormat \*format) | Sets dynamic parameters for an audio decoder. This API can be called only after the decoder is started. Incorrect parameter settings may cause decoding failure. | +| [OH_AudioDecoder_PushInputData](#oh_audiodecoder_pushinputdata) (OH_AVCodec \*codec, uint32_t index, [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) attr) | Pushes the input buffer filled with data to an audio decoder. The [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback reports available input buffers and their indexes. After being pushed to the decoder, a buffer is not accessible until the buffer with the same index is reported again through the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback. In addition, some decoders require the input of codec-specific data to initialize the decoding process. | +| [OH_AudioDecoder_FreeOutputData](#oh_audiodecoder_freeoutputdata) (OH_AVCodec \*codec, uint32_t index) | Frees an output buffer of an audio decoder. | ## Function Description @@ -53,14 +52,14 @@ OH_AVErrCode OH_AudioDecoder_Configure (OH_AVCodec * codec, OH_AVFormat * format **Description**
Configures an audio decoder. Typically, you need to configure the attributes, which can be extracted from the container, of the audio track that can be decoded. This API must be called prior to **Prepare**. -\@syscap SystemCapability.Multimedia.Media.AudioDecoder +@syscap SystemCapability.Multimedia.Media.AudioDecoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | -| format | Indicates the handle to an **OH_AVFormat** instance, which provides the attributes of the audio track to be decoded. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| format | Indicates the handle to an **OH_AVFormat** instance, which provides the attributes of the audio track to be decoded. | **Returns** @@ -76,15 +75,15 @@ Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the op OH_AVCodec* OH_AudioDecoder_CreateByMime (const char * mime) ``` **Description**
-Creates an audio decoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This API is recommended in most cases. +Creates an audio decoder instance based on a MIME type. This API is recommended in most cases. -\@syscap SystemCapability.Multimedia.Media.AudioDecoder +@syscap SystemCapability.Multimedia.Media.AudioDecoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| mime | Indicates the pointer to a MIME type. For details, see [OH_AVCODEC_MIMETYPE_AUDIO_AAC](_codec_base.md#oh_avcodec_mimetype_audio_aac). | +| mime | Indicates the pointer to a MIME type. For details, see [OH_AVCODEC_MIMETYPE_AUDIO_AAC](_codec_base.md#oh_avcodec_mimetype_audio_aac).| **Returns** @@ -100,13 +99,13 @@ OH_AVCodec* OH_AudioDecoder_CreateByName (const char * name) **Description**
Creates an audio decoder instance based on an audio decoder name. To use this API, you must know the exact name of the audio decoder. -\@syscap SystemCapability.Multimedia.Media.AudioDecoder +@syscap SystemCapability.Multimedia.Media.AudioDecoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| name | Indicates the pointer to an audio decoder name. | +| name | Indicates the pointer to an audio decoder name. | **Returns** @@ -122,13 +121,13 @@ OH_AVErrCode OH_AudioDecoder_Destroy (OH_AVCodec * codec) **Description**
Clears the internal resources of an audio decoder and destroys the audio decoder instance. -\@syscap SystemCapability.Multimedia.Media.AudioDecoder +@syscap SystemCapability.Multimedia.Media.AudioDecoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | **Returns** @@ -146,13 +145,13 @@ OH_AVErrCode OH_AudioDecoder_Flush (OH_AVCodec * codec) **Description**
Clears the input and output data in the internal buffer of an audio decoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required. -\@syscap SystemCapability.Multimedia.Media.AudioDecoder +@syscap SystemCapability.Multimedia.Media.AudioDecoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | **Returns** @@ -170,14 +169,14 @@ OH_AVErrCode OH_AudioDecoder_FreeOutputData (OH_AVCodec * codec, uint32_t index **Description**
Frees an output buffer of an audio decoder. -\@syscap SystemCapability.Multimedia.Media.AudioDecoder +@syscap SystemCapability.Multimedia.Media.AudioDecoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | -| index | Indicates the index of an output buffer. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| index | Indicates the index of an output buffer. | **Returns** @@ -195,13 +194,13 @@ OH_AVFormat* OH_AudioDecoder_GetOutputDescription (OH_AVCodec * codec) **Description**
Obtains the attributes of the output data of an audio decoder. The caller must manually release the **OH_AVFormat** instance in the return value. -\@syscap SystemCapability.Multimedia.Media.AudioDecoder +@syscap SystemCapability.Multimedia.Media.AudioDecoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | **Returns** @@ -217,13 +216,13 @@ OH_AVErrCode OH_AudioDecoder_Prepare (OH_AVCodec * codec) **Description**
Prepares internal resources for an audio decoder. This API must be called after **Configure**. -\@syscap SystemCapability.Multimedia.Media.AudioDecoder +@syscap SystemCapability.Multimedia.Media.AudioDecoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | **Returns** @@ -241,15 +240,15 @@ OH_AVErrCode OH_AudioDecoder_PushInputData (OH_AVCodec * codec, uint32_t index, **Description**
Pushes the input buffer filled with data to an audio decoder. The [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback reports available input buffers and their indexes. After being pushed to the decoder, a buffer is not accessible until the buffer with the same index is reported again through the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback. In addition, some decoders require the input of codec-specific data to initialize the decoding process. -\@syscap SystemCapability.Multimedia.Media.AudioDecoder +@syscap SystemCapability.Multimedia.Media.AudioDecoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | -| index | Indicates the index of an input buffer. | -| attr | Indicates the attributes of the data contained in the buffer. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| index | Indicates the index of an input buffer. | +| attr | Indicates the attributes of the data contained in the buffer. | **Returns** @@ -267,13 +266,13 @@ OH_AVErrCode OH_AudioDecoder_Reset (OH_AVCodec * codec) **Description**
Resets an audio decoder. To continue decoding, you must call **Configure** and **Start** to configure and start the decoder again. -\@syscap SystemCapability.Multimedia.Media.AudioDecoder +@syscap SystemCapability.Multimedia.Media.AudioDecoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | **Returns** @@ -291,15 +290,15 @@ OH_AVErrCode OH_AudioDecoder_SetCallback (OH_AVCodec * codec, OH_AVCodecAsyncCal **Description**
Sets an asynchronous callback so that your application can respond to events generated by an audio decoder. This API must be called prior to **Prepare**. -\@syscap SystemCapability.Multimedia.Media.AudioDecoder +@syscap SystemCapability.Multimedia.Media.AudioDecoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | -| callback | Indicates a collection of all callback functions. For details, see [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md). | -| userData | Indicates the pointer to user-specific data. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| callback | Indicates a collection of all callback functions. For details, see [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md).| +| userData | Indicates the pointer to user-specific data. | **Returns** @@ -317,14 +316,14 @@ OH_AVErrCode OH_AudioDecoder_SetParameter (OH_AVCodec * codec, OH_AVFormat * for **Description**
Sets dynamic parameters for an audio decoder. This API can be called only after the decoder is started. Incorrect parameter settings may cause decoding failure. -\@syscap SystemCapability.Multimedia.Media.AudioDecoder +@syscap SystemCapability.Multimedia.Media.AudioDecoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | -| format | Indicates the handle to an **OH_AVFormat** instance. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| format | Indicates the handle to an **OH_AVFormat** instance. | **Returns** @@ -342,13 +341,13 @@ OH_AVErrCode OH_AudioDecoder_Start (OH_AVCodec * codec) **Description**
Starts an audio decoder. This API can be called only after the decoder is prepared successfully. After being started, the decoder starts to report the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) event. -\@syscap SystemCapability.Multimedia.Media.AudioDecoder +@syscap SystemCapability.Multimedia.Media.AudioDecoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | **Returns** @@ -366,13 +365,13 @@ OH_AVErrCode OH_AudioDecoder_Stop (OH_AVCodec * codec) **Description**
Stops an audio decoder. After the decoder is stopped, you can call **Start** to start it again. If you have passed codec-specific data in the previous **Start** for the decoder, you must pass it again. -\@syscap SystemCapability.Multimedia.Media.AudioDecoder +@syscap SystemCapability.Multimedia.Media.AudioDecoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | **Returns** diff --git a/en/application-dev/reference/native-apis/_audio_encoder.md b/en/application-dev/reference/native-apis/_audio_encoder.md index 07a727f5b55f808004864c7212b6fd6768da30ea..cf621c755cd5b145b8661a5c78d3297142f883a0 100644 --- a/en/application-dev/reference/native-apis/_audio_encoder.md +++ b/en/application-dev/reference/native-apis/_audio_encoder.md @@ -3,42 +3,41 @@ ## Overview -Provides the functions for audio encoding. +Provides the functions for audio encoding. This module may not be supported on some devices. You can call [CanIUse](../syscap.md) to check whether this module is supported on your device. -\@syscap SystemCapability.Multimedia.Media.AudioEncoder +@syscap SystemCapability.Multimedia.Media.AudioEncoder -**Since:** +**Since** 9 - ## Summary ### Files -| Name | Description | + | Name| Description| | -------- | -------- | -| [native_avcodec_audioencoder.h](native__avcodec__audioencoder_8h.md) | Declares the native APIs used for audio encoding.
File to Include: | +| [native_avcodec_audioencoder.h](native__avcodec__audioencoder_8h.md) | Declares the native APIs used for audio encoding.
File to include: | ### Functions -| Name | Description | + | Name| Description| | -------- | -------- | -| [OH_AudioEncoder_CreateByMime](#oh_audioencoder_createbymime) (const char \*mime) | Creates an audio encoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This API is recommended in most cases. | -| [OH_AudioEncoder_CreateByName](#oh_audioencoder_createbyname) (const char \*name) | Creates an audio encoder instance based on an audio encoder name. To use this API, you must know the exact name of the audio encoder. | -| [OH_AudioEncoder_Destroy](#oh_audioencoder_destroy) (OH_AVCodec \*codec) | Clears the internal resources of an audio encoder and destroys the audio encoder instance. | -| [OH_AudioEncoder_SetCallback](#oh_audioencoder_setcallback) (OH_AVCodec \*codec, [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md) callback, void \*userData) | Sets an asynchronous callback so that your application can respond to events generated by an audio encoder. This API must be called prior to **Prepare**. | -| [OH_AudioEncoder_Configure](#oh_audioencoder_configure) (OH_AVCodec \*codec, OH_AVFormat \*format) | Configures an audio encoder. Typically, you need to configure the attributes of the audio track that can be encoded. This API must be called prior to **Prepare**. | -| [OH_AudioEncoder_Prepare](#oh_audioencoder_prepare) (OH_AVCodec \*codec) | Prepares internal resources for an audio encoder. This API must be called after **Configure**. | -| [OH_AudioEncoder_Start](#oh_audioencoder_start) (OH_AVCodec \*codec) | Starts an audio encoder. This API can be called only after the encoder is prepared successfully. After being started, the encoder starts to report the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) event. | -| [OH_AudioEncoder_Stop](#oh_audioencoder_stop) (OH_AVCodec \*codec) | Stops an audio encoder. After the encoder is stopped, you can call **Start** to start it again. | -| [OH_AudioEncoder_Flush](#oh_audioencoder_flush) (OH_AVCodec \*codec) | Clears the input and output data in the internal buffer of an audio encoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required. | -| [OH_AudioEncoder_Reset](#oh_audioencoder_reset) (OH_AVCodec \*codec) | Resets an audio encoder. To continue encoding, you must call **Configure** and **Start** to configure and start the encoder again. | -| [OH_AudioEncoder_GetOutputDescription](#oh_audioencoder_getoutputdescription) (OH_AVCodec \*codec) | Obtains the attributes of the output data of an audio encoder. The caller must manually release the **OH_AVFormat** instance in the return value. | -| [OH_AudioEncoder_SetParameter](#oh_audioencoder_setparameter) (OH_AVCodec \*codec, OH_AVFormat \*format) | Sets dynamic parameters for an audio encoder. This API can be called only after the encoder is started. Incorrect parameter settings may cause encoding failure. | -| [OH_AudioEncoder_PushInputData](#oh_audioencoder_pushinputdata) (OH_AVCodec \*codec, uint32_t index, [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) attr) | Pushes the input buffer filled with data to an audio encoder. The [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback reports available input buffers and their indexes. After being pushed to the decoder, a buffer is not accessible until the buffer with the same index is reported again through the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback. | -| [OH_AudioEncoder_FreeOutputData](#oh_audioencoder_freeoutputdata) (OH_AVCodec \*codec, uint32_t index) | Frees an output buffer of an audio encoder. | +| [OH_AudioEncoder_CreateByMime](#oh_audioencoder_createbymime) (const char \*mime) | Creates an audio encoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This API is recommended in most cases. | +| [OH_AudioEncoder_CreateByName](#oh_audioencoder_createbyname) (const char \*name) | Creates an audio encoder instance based on an audio encoder name. To use this API, you must know the exact name of the audio encoder. | +| [OH_AudioEncoder_Destroy](#oh_audioencoder_destroy) (OH_AVCodec \*codec) | Clears the internal resources of an audio encoder and destroys the audio encoder instance. | +| [OH_AudioEncoder_SetCallback](#oh_audioencoder_setcallback) (OH_AVCodec \*codec, [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md) callback, void \*userData) | Sets an asynchronous callback so that your application can respond to events generated by an audio encoder. This API must be called prior to **Prepare**. | +| [OH_AudioEncoder_Configure](#oh_audioencoder_configure) (OH_AVCodec \*codec, OH_AVFormat \*format) | Configures an audio encoder. Typically, you need to configure the attributes of the audio track that can be encoded. This API must be called prior to **Prepare**. | +| [OH_AudioEncoder_Prepare](#oh_audioencoder_prepare) (OH_AVCodec \*codec) | Prepares internal resources for an audio encoder. This API must be called after **Configure**. | +| [OH_AudioEncoder_Start](#oh_audioencoder_start) (OH_AVCodec \*codec) | Starts an audio encoder. This API can be called only after the encoder is prepared successfully. After being started, the encoder starts to report the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) event. | +| [OH_AudioEncoder_Stop](#oh_audioencoder_stop) (OH_AVCodec \*codec) | Stops an audio encoder. After the encoder is stopped, you can call **Start** to start it again. | +| [OH_AudioEncoder_Flush](#oh_audioencoder_flush) (OH_AVCodec \*codec) | Clears the input and output data in the internal buffer of an audio encoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required. | +| [OH_AudioEncoder_Reset](#oh_audioencoder_reset) (OH_AVCodec \*codec) | Resets an audio encoder. To continue encoding, you must call **Configure** and **Start** to configure and start the encoder again. | +| [OH_AudioEncoder_GetOutputDescription](#oh_audioencoder_getoutputdescription) (OH_AVCodec \*codec) | Obtains the attributes of the output data of an audio encoder. The caller must manually release the **OH_AVFormat** instance in the return value. | +| [OH_AudioEncoder_SetParameter](#oh_audioencoder_setparameter) (OH_AVCodec \*codec, OH_AVFormat \*format) | Sets dynamic parameters for an audio encoder. This API can be called only after the encoder is started. Incorrect parameter settings may cause encoding failure. | +| [OH_AudioEncoder_PushInputData](#oh_audioencoder_pushinputdata) (OH_AVCodec \*codec, uint32_t index, [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) attr) | Pushes the input buffer filled with data to an audio encoder. The [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback reports available input buffers and their indexes. After being pushed to the encoder, a buffer is not accessible until the buffer with the same index is reported again through the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback. | +| [OH_AudioEncoder_FreeOutputData](#oh_audioencoder_freeoutputdata) (OH_AVCodec \*codec, uint32_t index) | Frees an output buffer of an audio encoder. | ## Function Description @@ -53,14 +52,14 @@ OH_AVErrCode OH_AudioEncoder_Configure (OH_AVCodec * codec, OH_AVFormat * format **Description**
Configures an audio encoder. Typically, you need to configure the attributes of the audio track that can be encoded. This API must be called prior to **Prepare**. -\@syscap SystemCapability.Multimedia.Media.AudioEncoder +@syscap SystemCapability.Multimedia.Media.AudioEncoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | -| format | Indicates the handle to an **OH_AVFormat** instance. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| format | Indicates the handle to an **OH_AVFormat** instance. | **Returns** @@ -76,15 +75,15 @@ Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the op OH_AVCodec* OH_AudioEncoder_CreateByMime (const char * mime) ``` **Description**
-Creates an audio encoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This API is recommended in most cases. +Creates an audio encoder instance based on a MIME type. This API is recommended in most cases. -\@syscap SystemCapability.Multimedia.Media.AudioEncoder +@syscap SystemCapability.Multimedia.Media.AudioEncoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| mime | Indicates the pointer to a MIME type. For details, see [OH_AVCODEC_MIMETYPE_AUDIO_AAC](_codec_base.md#oh_avcodec_mimetype_audio_aac). | +| mime | Indicates the pointer to a MIME type. For details, see [OH_AVCODEC_MIMETYPE_AUDIO_AAC](_codec_base.md#oh_avcodec_mimetype_audio_aac).| **Returns** @@ -100,13 +99,13 @@ OH_AVCodec* OH_AudioEncoder_CreateByName (const char * name) **Description**
Creates an audio encoder instance based on an audio encoder name. To use this API, you must know the exact name of the audio encoder. -\@syscap SystemCapability.Multimedia.Media.AudioEncoder +@syscap SystemCapability.Multimedia.Media.AudioEncoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| name | Indicates the pointer to an audio encoder name. | +| name | Indicates the pointer to an audio encoder name. | **Returns** @@ -122,13 +121,13 @@ OH_AVErrCode OH_AudioEncoder_Destroy (OH_AVCodec * codec) **Description**
Clears the internal resources of an audio encoder and destroys the audio encoder instance. -\@syscap SystemCapability.Multimedia.Media.AudioEncoder +@syscap SystemCapability.Multimedia.Media.AudioEncoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | **Returns** @@ -146,13 +145,13 @@ OH_AVErrCode OH_AudioEncoder_Flush (OH_AVCodec * codec) **Description**
Clears the input and output data in the internal buffer of an audio encoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required. -\@syscap SystemCapability.Multimedia.Media.AudioEncoder +@syscap SystemCapability.Multimedia.Media.AudioEncoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | **Returns** @@ -170,14 +169,14 @@ OH_AVErrCode OH_AudioEncoder_FreeOutputData (OH_AVCodec * codec, uint32_t index **Description**
Frees an output buffer of an audio encoder. -\@syscap SystemCapability.Multimedia.Media.AudioEncoder +@syscap SystemCapability.Multimedia.Media.AudioEncoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | -| index | Indicates the index of an output buffer. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| index | Indicates the index of an output buffer. | **Returns** @@ -195,13 +194,13 @@ OH_AVFormat* OH_AudioEncoder_GetOutputDescription (OH_AVCodec * codec) **Description**
Obtains the attributes of the output data of an audio encoder. The caller must manually release the **OH_AVFormat** instance in the return value. -\@syscap SystemCapability.Multimedia.Media.AudioEncoder +@syscap SystemCapability.Multimedia.Media.AudioEncoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | **Returns** @@ -217,13 +216,13 @@ OH_AVErrCode OH_AudioEncoder_Prepare (OH_AVCodec * codec) **Description**
Prepares internal resources for an audio encoder. This API must be called after **Configure**. -\@syscap SystemCapability.Multimedia.Media.AudioEncoder +@syscap SystemCapability.Multimedia.Media.AudioEncoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | **Returns** @@ -239,17 +238,17 @@ Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the op OH_AVErrCode OH_AudioEncoder_PushInputData (OH_AVCodec * codec, uint32_t index, OH_AVCodecBufferAttr attr ) ``` **Description**
-Pushes the input buffer filled with data to an audio encoder. The [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback reports available input buffers and their indexes. After being pushed to the decoder, a buffer is not accessible until the buffer with the same index is reported again through the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback. +Pushes the input buffer filled with data to an audio encoder. The [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback reports available input buffers and their indexes. After being pushed to the encoder, a buffer is not accessible until the buffer with the same index is reported again through the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback. -\@syscap SystemCapability.Multimedia.Media.AudioEncoder +@syscap SystemCapability.Multimedia.Media.AudioEncoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | -| index | Indicates the index of an input buffer. | -| attr | Indicates the attributes of the data contained in the buffer. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| index | Indicates the index of an input buffer. | +| attr | Indicates the attributes of the data contained in the buffer. | **Returns** @@ -267,13 +266,13 @@ OH_AVErrCode OH_AudioEncoder_Reset (OH_AVCodec * codec) **Description**
Resets an audio encoder. To continue encoding, you must call **Configure** and **Start** to configure and start the encoder again. -\@syscap SystemCapability.Multimedia.Media.AudioEncoder +@syscap SystemCapability.Multimedia.Media.AudioEncoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | **Returns** @@ -291,15 +290,15 @@ OH_AVErrCode OH_AudioEncoder_SetCallback (OH_AVCodec * codec, OH_AVCodecAsyncCal **Description**
Sets an asynchronous callback so that your application can respond to events generated by an audio encoder. This API must be called prior to **Prepare**. -\@syscap SystemCapability.Multimedia.Media.AudioEncoder +@syscap SystemCapability.Multimedia.Media.AudioEncoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | -| callback | Indicates a collection of all callback functions. For details, see [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md). | -| userData | Indicates the pointer to user-specific data. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| callback | Indicates a collection of all callback functions. For details, see [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md).| +| userData | Indicates the pointer to user-specific data. | **Returns** @@ -317,14 +316,14 @@ OH_AVErrCode OH_AudioEncoder_SetParameter (OH_AVCodec * codec, OH_AVFormat * for **Description**
Sets dynamic parameters for an audio encoder. This API can be called only after the encoder is started. Incorrect parameter settings may cause encoding failure. -\@syscap SystemCapability.Multimedia.Media.AudioEncoder +@syscap SystemCapability.Multimedia.Media.AudioEncoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | -| format | Indicates the handle to an **OH_AVFormat** instance. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| format | Indicates the handle to an **OH_AVFormat** instance. | **Returns** @@ -342,13 +341,13 @@ OH_AVErrCode OH_AudioEncoder_Start (OH_AVCodec * codec) **Description**
Starts an audio encoder. This API can be called only after the encoder is prepared successfully. After being started, the encoder starts to report the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) event. -\@syscap SystemCapability.Multimedia.Media.AudioEncoder +@syscap SystemCapability.Multimedia.Media.AudioEncoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | **Returns** @@ -366,13 +365,13 @@ OH_AVErrCode OH_AudioEncoder_Stop (OH_AVCodec * codec) **Description**
Stops an audio encoder. After the encoder is stopped, you can call **Start** to start it again. -\@syscap SystemCapability.Multimedia.Media.AudioEncoder +@syscap SystemCapability.Multimedia.Media.AudioEncoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | **Returns** diff --git a/en/application-dev/reference/native-apis/_codec_base.md b/en/application-dev/reference/native-apis/_codec_base.md index c908c604e4cb448ddf2bef4f071c5d588a0cbb89..a1f4f21a702369a61492f8e7a8e25b69f0718dec 100644 --- a/en/application-dev/reference/native-apis/_codec_base.md +++ b/en/application-dev/reference/native-apis/_codec_base.md @@ -3,86 +3,85 @@ ## Overview -Provides the common structs, character constants, and enums for running **OH_AVCodec** instances. +Provides the common structs, character constants, and enums for running **OH_AVCodec** instances. This module may not be supported on some devices. You can call [CanIUse](../syscap.md) to check whether this module is supported on your device. -\@syscap SystemCapability.Multimedia.Media.CodecBase +@syscap SystemCapability.Multimedia.Media.CodecBase -**Since:** +**Since** 9 - ## Summary ### Files -| Name | Description | + | Name| Description| | -------- | -------- | -| [native_avcodec_base.h](native__avcodec__base_8h.md) | Declares the common structs, character constants, and enums for running **OH_AVCodec** instances.
File to Include: | +| [native_avcodec_base.h](native__avcodec__base_8h.md) | Declares the common structs, character constants, and enums for running OH_AVCodec instances.
File to include: | ### Structs -| Name | Description | + | Name| Description| | -------- | -------- | -| [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) | Defines the buffer attributes of an **OH_AVCodec** instance. | -| [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md) | Defines a collection of asynchronous callback functions for an **OH_AVCodec** instance. You must register this struct instance for an **OH_AVCodec** instance and process the information reported through these callbacks to ensure the normal running of the instance. | +| [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) | Defines the buffer attributes of an **OH_AVCodec** instance. | +| [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md) | Defines a collection of asynchronous callback functions for an **OH_AVCodec** instance. You must register this struct instance for an **OH_AVCodec** instance and process the information reported through these callbacks to ensure the normal running of the instance. | ### Types -| Name | Description | + | Name| Description| | -------- | -------- | -| [OH_AVCodecBufferFlags](#oh_avcodecbufferflags) | Enumerates the buffer flags of an **OH_AVCodec** instance. | -| [OH_AVCodecBufferAttr](#oh_avcodecbufferattr) | Defines the buffer attributes of an **OH_AVCodec** instance. | -| [OH_AVCodecOnError](#oh_avcodeconerror)) (OH_AVCodec \*codec, int32_t errorCode, void \*userData) | Defines the function pointer that is called to report error information when an error occurs during the running of an **OH_AVCodec** instance. | -| [OH_AVCodecOnStreamChanged](#oh_avcodeconstreamchanged)) (OH_AVCodec \*codec, OH_AVFormat \*format, void \*userData) | Defines the function pointer that is called to report the attributes of the new stream when the output stream changes. Note that the lifecycle of the pointer to the **OH_AVFormat** instance is valid only when the function pointer is being called. Do not access the pointer to the instance after the function pointer is called. | -| [OH_AVCodecOnNeedInputData](#oh_avcodeconneedinputdata)) (OH_AVCodec \*codec, uint32_t index, OH_AVMemory \*data, void \*userData) | Defines the function pointer that is called, with a new buffer to fill in new input data, when new input data is required during the running of an **OH_AVCodec** instance. | -| [OH_AVCodecOnNewOutputData](#oh_avcodeconnewoutputdata)) (OH_AVCodec \*codec, uint32_t index, OH_AVMemory \*data, [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) \*attr, void \*userData) | Defines the function pointer that is called, with a buffer containing new output data, when the new output data is generated during the running of an **OH_AVCodec** instance. Note that the lifecycle of the pointer to the **[OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md)** instance is valid only when the function pointer is being called. Do not access the pointer to the instance after the function pointer is called. | -| [OH_AVCodecAsyncCallback](#oh_avcodecasynccallback) | Defines a collection of asynchronous callback functions for an **OH_AVCodec** instance. You must register this struct instance for an **OH_AVCodec** instance and process the information reported through these callbacks to ensure the normal running of the instance. | -| [OH_MediaType](#oh_mediatype) | Enumerates the media types. | -| [OH_AVCProfile](#oh_avcprofile) | Enumerates the AVC profiles. | -| [OH_AACProfile](#oh_aacprofile) | Enumerates the AAC profiles. | +| [OH_AVCodecBufferFlags](#oh_avcodecbufferflags) | Enumerates the buffer flags of an **OH_AVCodec** instance. | +| [OH_AVCodecBufferAttr](#oh_avcodecbufferattr) | Defines the buffer attributes of an **OH_AVCodec** instance. | +| (\*[OH_AVCodecOnError](#oh_avcodeconerror)) (OH_AVCodec \*codec, int32_t errorCode, void \*userData) | Defines the function pointer that is called to report error information when an error occurs during the running of an **OH_AVCodec** instance. | +| (\*[OH_AVCodecOnStreamChanged](#oh_avcodeconstreamchanged)) (OH_AVCodec \*codec, OH_AVFormat \*format, void \*userData) | Defines the function pointer that is called to report the attributes of the new stream when the output stream changes. Note that the lifecycle of the pointer to the **OH_AVFormat** instance is valid only when the function pointer is being called. Do not access the pointer to the instance after the function pointer is called. | +| (\*[OH_AVCodecOnNeedInputData](#oh_avcodeconneedinputdata)) (OH_AVCodec \*codec, uint32_t index, OH_AVMemory \*data, void \*userData) | Defines the function pointer that is called, with a new buffer to fill in new input data, when new input data is required during the running of an **OH_AVCodec** instance. | +| (\*[OH_AVCodecOnNewOutputData](#oh_avcodeconnewoutputdata)) (OH_AVCodec \*codec, uint32_t index, OH_AVMemory \*data, [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) \*attr, void \*userData) | Defines the function pointer that is called, with a buffer containing new output data, when the new output data is generated during the running of an **OH_AVCodec** instance. Note that the lifecycle of the pointer to the **OH_AVCodecBufferAttr** instance is valid only when the function pointer is being called. Do not access the pointer to the instance after the function pointer is called. | +| [OH_AVCodecAsyncCallback](#oh_avcodecasynccallback) | Defines a collection of asynchronous callback functions for an **OH_AVCodec** instance. You must register this struct instance for an **OH_AVCodec** instance and process the information reported through these callbacks to ensure the normal running of the instance. | +| [OH_MediaType](#oh_mediatype) | Enumerates the media types. | +| [OH_AVCProfile](#oh_avcprofile) | Enumerates the AVC profiles. | +| [OH_AACProfile](#oh_aacprofile) | Enumerates the AAC profiles. | ### Enums -| Name | Description | + | Name| Description| | -------- | -------- | -| [OH_AVCodecBufferFlags](#oh_avcodecbufferflags) {
**AVCODEC_BUFFER_FLAGS_NONE** = 0, AVCODEC_BUFFER_FLAGS_EOS = 1 << 0, AVCODEC_BUFFER_FLAGS_SYNC_FRAME = 1 << 1, AVCODEC_BUFFER_FLAGS_INCOMPLETE_FRAME = 1 << 2,
AVCODEC_BUFFER_FLAGS_CODEC_DATA = 1 << 3
} | Enumerates the buffer flags of an **OH_AVCodec** instance. | -| [OH_MediaType](#oh_mediatype) { MEDIA_TYPE_AUD = 0, MEDIA_TYPE_VID = 1 } | Enumerates the media types. | -| [OH_AVCProfile](#oh_avcprofile) { **AVC_PROFILE_BASELINE** = 0, **AVC_PROFILE_HIGH** = 4, **AVC_PROFILE_MAIN** = 8 } | Enumerates the AVC profiles. | -| [OH_AACProfile](#oh_aacprofile) { **AAC_PROFILE_LC** = 0 } | Enumerates the AAC profiles. | +| [OH_AVCodecBufferFlags](#oh_avcodecbufferflags) {
**AVCODEC_BUFFER_FLAGS_NONE** = 0, **AVCODEC_BUFFER_FLAGS_EOS** = 1 << 0, **AVCODEC_BUFFER_FLAGS_SYNC_FRAME** = 1 << 1, **AVCODEC_BUFFER_FLAGS_INCOMPLETE_FRAME** = 1 << 2, **AVCODEC_BUFFER_FLAGS_CODEC_DATA**= 1 << 3
} | Enumerates the buffer flags of an **OH_AVCodec** instance. | +| [OH_MediaType](#oh_mediatype) { **MEDIA_TYPE_AUD** = 0, **MEDIA_TYPE_VID** = 1 } | Enumerates the media types. | +| [OH_AVCProfile](#oh_avcprofile) { **AVC_PROFILE_BASELINE** = 0, **AVC_PROFILE_HIGH** = 4, **AVC_PROFILE_MAIN** = 8 } | Enumerates the Advanced Video Coding (AVC) profiles. | +| [OH_AACProfile](#oh_aacprofile) { **AAC_PROFILE_LC** = 0 } | Enumerates the Advanced Audio Coding (AAC) profiles. | ### Variables -| Name | Description | + | Name| Description| | -------- | -------- | -| [OH_AVCodecBufferAttr::pts](#pts) | Presentation timestamp of the buffer, in microseconds. | -| [OH_AVCodecBufferAttr::size](#size) | Size of the data contained in the buffer, in bytes. | -| [OH_AVCodecBufferAttr::offset](#offset) | Start offset of valid data in the buffer. | -| [OH_AVCodecBufferAttr::flags](#flags) | Buffer flag, which is a combination of multiple [OH_AVCodecBufferFlags](#oh_avcodecbufferflags). | -| [OH_AVCODEC_MIMETYPE_VIDEO_AVC](#oh_avcodec_mimetype_video_avc) | Defines the Multipurpose Internet Mail Extension (MIME) type for Advanced Video Coding (AVC). | -| [OH_AVCODEC_MIMETYPE_AUDIO_AAC](#oh_avcodec_mimetype_audio_aac) | Defines the MIME type for Advanced Audio Coding (AAC). | -| [OH_ED_KEY_TIME_STAMP](#oh_ed_key_time_stamp) | Provides unified character descriptors for the auxiliary data of the surface buffer. | -| [OH_ED_KEY_EOS](#oh_ed_key_eos) | Character descriptor of the end-of-stream in the surface auxiliary data. The value type is bool. | -| [OH_MD_KEY_TRACK_TYPE](#oh_md_key_track_type) | Provides unified character descriptors for the media playback framework. | -| [OH_MD_KEY_CODEC_MIME](#oh_md_key_codec_mime) | Character descriptor of the MIME type. The value type is string. | -| [OH_MD_KEY_DURATION](#oh_md_key_duration) | Character descriptor of duration. The value type is int64_t. | -| [OH_MD_KEY_BITRATE](#oh_md_key_bitrate) | Character descriptor of the bit rate. The value type is uint32_t. | -| [OH_MD_KEY_MAX_INPUT_SIZE](#oh_md_key_max_input_size) | Character descriptor of the maximum input size. The value type is uint32_t. | -| [OH_MD_KEY_WIDTH](#oh_md_key_width) | Character descriptor of the video width. The value type is uint32_t. | -| [OH_MD_KEY_HEIGHT](#oh_md_key_height) | Character descriptor of the video height. The value type is uint32_t. | -| [OH_MD_KEY_PIXEL_FORMAT](#oh_md_key_pixel_format) | Character descriptor of the video pixel format. The value type is int32_t. For details, see [OH_AVPixelFormat](_core.md#oh_avpixelformat). | -| [OH_MD_KEY_AUDIO_SAMPLE_FORMAT](#oh_md_key_audio_sample_format) | Character descriptor of the audio sample format. The value type is uint32_t. | -| [OH_MD_KEY_FRAME_RATE](#oh_md_key_frame_rate) | Character descriptor of the video frame rate. The value type is double. | -| [OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE](#oh_md_key_video_encode_bitrate_mode) | Character descriptor of the video encoding bit rate mode. The value type is int32_t. For details, see [OH_VideoEncodeBitrateMode](_video_encoder.md#oh_videoencodebitratemode). | -| [OH_MD_KEY_PROFILE](#oh_md_key_profile) | Character descriptor of the audio/video encoding capability. The value type is int32_t. For details, see [OH_AVCProfile](#oh_avcprofile) or [OH_AACProfile](#oh_aacprofile). | -| [OH_MD_KEY_AUD_CHANNEL_COUNT](#oh_md_key_aud_channel_count) | Character descriptor of the number of audio channels. The value type is uint32_t. | -| [OH_MD_KEY_AUD_SAMPLE_RATE](#oh_md_key_aud_sample_rate) | Character descriptor of the audio sampling rate. The value type is uint32_t. | -| [OH_MD_KEY_I_FRAME_INTERVAL](#oh_md_key_i_frame_interval) | Character descriptor of the I-frame interval. The value type is int32_t, and the unit is ms. | -| [OH_MD_KEY_ROTATION](#oh_md_key_rotation) | Character descriptor of the surface rotation angle. The value type is int32_t. The value range is {0, 90, 180, 270}. The default value is 0. | +| [OH_AVCodecBufferAttr::pts](#pts) | Defines the presentation timestamp of the buffer, in microseconds. | +| [OH_AVCodecBufferAttr::size](#size) | Defines the size of the data contained in the buffer, in bytes. | +| [OH_AVCodecBufferAttr::offset](#offset) | Defines the start offset of valid data in the buffer. | +| [OH_AVCodecBufferAttr::flags](#flags) | Defines a buffer flag, which is a combination of multiple [OH_AVCodecBufferFlags](#oh_avcodecbufferflags). | +| [OH_AVCODEC_MIMETYPE_VIDEO_AVC](#oh_avcodec_mimetype_video_avc) | Defines the Multipurpose Internet Mail Extension (MIME) type for AVC. | +| [OH_AVCODEC_MIMETYPE_AUDIO_AAC](#oh_avcodec_mimetype_audio_aac) | Defines the MIME type for AAC. | +| [OH_ED_KEY_TIME_STAMP](#oh_ed_key_time_stamp) | Defines the unified character descriptors for the auxiliary data of the surface buffer. | +| [OH_ED_KEY_EOS](#oh_ed_key_eos) | Defines the character descriptor of the end-of-stream in the surface auxiliary data. The value type is bool. | +| [OH_MD_KEY_TRACK_TYPE](#oh_md_key_track_type) | Defines the unified character descriptors for the media playback framework. | +| [OH_MD_KEY_CODEC_MIME](#oh_md_key_codec_mime) | Defines the character descriptor of the MIME type. The value type is string. | +| [OH_MD_KEY_DURATION](#oh_md_key_duration) | Defines the character descriptor of duration. The value type is int64_t. | +| [OH_MD_KEY_BITRATE](#oh_md_key_bitrate) | Defines the character descriptor of the bit rate. The value type is uint32_t. | +| [OH_MD_KEY_MAX_INPUT_SIZE](#oh_md_key_max_input_size) | Defines the character descriptor of the maximum input size. The value type is uint32_t. | +| [OH_MD_KEY_WIDTH](#oh_md_key_width) | Defines the character descriptor of the video width. The value type is uint32_t. | +| [OH_MD_KEY_HEIGHT](#oh_md_key_height) | Defines the character descriptor of the video height. The value type is uint32_t. | +| [OH_MD_KEY_PIXEL_FORMAT](#oh_md_key_pixel_format) | Defines the character descriptor of the video pixel format. The value type is int32_t. For details, see [OH_AVPixelFormat](_core.md#oh_avpixelformat).| +| [OH_MD_KEY_AUDIO_SAMPLE_FORMAT](#oh_md_key_audio_sample_format) | Defines the character descriptor of the audio sample format. The value type is uint32_t. | +| [OH_MD_KEY_FRAME_RATE](#oh_md_key_frame_rate) | Defines the character descriptor of the video frame rate. The value type is double. | +| [OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE](#oh_md_key_video_encode_bitrate_mode) | Defines the character descriptor of the video encoding bit rate mode. The value type is int32_t. For details, see [OH_VideoEncodeBitrateMode](_video_encoder.md#oh_videoencodebitratemode).| +| [OH_MD_KEY_PROFILE](#oh_md_key_profile) | Defines the character descriptor of the audio/video encoding capability. The value type is int32_t. For details, see [OH_AVCProfile](#oh_avcprofile) or [OH_AACProfile](#oh_aacprofile).| +| [OH_MD_KEY_AUD_CHANNEL_COUNT](#oh_md_key_aud_channel_count) | Defines the character descriptor of the number of audio channels. The value type is uint32_t. | +| [OH_MD_KEY_AUD_SAMPLE_RATE](#oh_md_key_aud_sample_rate) | Defines the character descriptor of the audio sampling rate. The value type is uint32_t. | +| [OH_MD_KEY_I_FRAME_INTERVAL](#oh_md_key_i_frame_interval) | Defines the character descriptor of the I-frame interval. The value type is int32_t, and the unit is ms. | +| [OH_MD_KEY_ROTATION](#oh_md_key_rotation) | Defines the character descriptor of the surface rotation angle. The value type is int32_t. The value range is {0, 90, 180, 270}. The default value is 0. | ## Type Description @@ -97,7 +96,7 @@ typedef enum OH_AACProfileOH_AACProfile **Description**
Enumerates the AAC profiles. -\@syscap SystemCapability.Multimedia.Media.CodecBase +@syscap SystemCapability.Multimedia.Media.CodecBase ### OH_AVCodecAsyncCallback @@ -109,16 +108,16 @@ typedef struct OH_AVCodecAsyncCallbackOH_AVCodecAsyncCallback **Description**
Defines a collection of asynchronous callback functions for an **OH_AVCodec** instance. You must register this struct instance for an **OH_AVCodec** instance and process the information reported through these callbacks to ensure the normal running of the instance. -\@syscap SystemCapability.Multimedia.Media.CodecBase +@syscap SystemCapability.Multimedia.Media.CodecBase - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| onError | Indicates the callback used to report errors occurred during the running of the instance. For details, see [OH_AVCodecOnError](#oh_avcodeconerror). | -| onStreamChanged | Indicates the callback used to report stream information. For details, see [OH_AVCodecOnStreamChanged](#oh_avcodeconstreamchanged). | -| onNeedInputData | Indicates the callback used to report input data needed. For details, see [OH_AVCodecOnNeedInputData](#oh_avcodeconneedinputdata). | -| onNeedInputData | Indicates the callback used to report output data needed. For details, see [OH_AVCodecOnNewOutputData](#oh_avcodeconnewoutputdata). | +| onError | Indicates the callback used to report errors occurred during the running of the instance. For details, see [OH_AVCodecOnError](#oh_avcodeconerror).| +| onStreamChanged | Indicates the callback used to report stream information. For details, see [OH_AVCodecOnStreamChanged](#oh_avcodeconstreamchanged).| +| onNeedInputData | Indicates the callback used to report input data needed. For details, see [OH_AVCodecOnNeedInputData](#oh_avcodeconneedinputdata).| +| onNeedInputData | Indicates the callback used to report output data needed. For details, see [OH_AVCodecOnNewOutputData](#oh_avcodeconnewoutputdata).| ### OH_AVCodecBufferAttr @@ -130,7 +129,7 @@ typedef struct OH_AVCodecBufferAttrOH_AVCodecBufferAttr **Description**
Defines the buffer attributes of an **OH_AVCodec** instance. -\@syscap SystemCapability.Multimedia.Media.CodecBase +@syscap SystemCapability.Multimedia.Media.CodecBase ### OH_AVCodecBufferFlags @@ -142,7 +141,7 @@ typedef enum OH_AVCodecBufferFlagsOH_AVCodecBufferFlags **Description**
Enumerates the buffer flags of an **OH_AVCodec** instance. -\@syscap SystemCapability.Multimedia.Media.CodecBase +@syscap SystemCapability.Multimedia.Media.CodecBase ### OH_AVCodecOnError @@ -154,15 +153,15 @@ typedef void(* OH_AVCodecOnError) (OH_AVCodec *codec, int32_t errorCode, void *u **Description**
Defines the function pointer that is called to report error information when an error occurs during the running of an **OH_AVCodec** instance. -\@syscap SystemCapability.Multimedia.Media.CodecBase +@syscap SystemCapability.Multimedia.Media.CodecBase - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | -| errorCode | Indicates an error code. | -| userData | Indicates the pointer to user-specific data. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| errorCode | Indicates an error code. | +| userData | Indicates the pointer to user-specific data. | ### OH_AVCodecOnNeedInputData @@ -174,16 +173,16 @@ typedef void(* OH_AVCodecOnNeedInputData) (OH_AVCodec *codec, uint32_t index, OH **Description**
Defines the function pointer that is called, with a new buffer to fill in new input data, when new input data is required during the running of an **OH_AVCodec** instance. -\@syscap SystemCapability.Multimedia.Media.CodecBase +@syscap SystemCapability.Multimedia.Media.CodecBase - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | -| index | Indicates the index of an input buffer. | -| data | Indicates the pointer to the new input data. | -| userData | Indicates the pointer to user-specific data. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| index | Indicates the index of an input buffer. | +| data | Indicates the pointer to the new input data. | +| userData | Indicates the pointer to user-specific data. | ### OH_AVCodecOnNewOutputData @@ -193,20 +192,19 @@ Defines the function pointer that is called, with a new buffer to fill in new in typedef void(* OH_AVCodecOnNewOutputData) (OH_AVCodec *codec, uint32_t index, OH_AVMemory *data, OH_AVCodecBufferAttr *attr, void *userData) ``` **Description**
-Defines the function pointer that is called, with a buffer containing new output data, when the new output data is generated during the running of an **OH_AVCodec** instance. Note that the lifecycle of the pointer to the **[OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md)** instance is valid only when the function pointer is being called. Do not access the pointer to the instance after the function pointer is called. +Defines the function pointer that is called, with a buffer containing new output data, when the new output data is generated during the running of an **OH_AVCodec** instance. Note that the lifecycle of the pointer to the **OH_AVCodecBufferAttr** instance is valid only when the function pointer is being called. Do not access the pointer to the instance after the function pointer is called. -\@syscap SystemCapability.Multimedia.Media.CodecBase +@syscap SystemCapability.Multimedia.Media.CodecBase - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | -| index | Indicates the index of a new output buffer. | -| data | Indicates the pointer to the new output data. | -| attr | Indicates the pointer to the attributes of the new output buffer. For details, see [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md). | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| index | Indicates the index of a new output buffer. | +| data | Indicates the pointer to the new output data. | +| attr | Indicates the pointer to the attributes of the new output buffer. For details, see [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md).| | userData | Indicates the pointer to user-specific data. | -| userData | specified data | ### OH_AVCodecOnStreamChanged @@ -218,15 +216,15 @@ typedef void(* OH_AVCodecOnStreamChanged) (OH_AVCodec *codec, OH_AVFormat *forma **Description**
Defines the function pointer that is called to report the attributes of the new stream when the output stream changes. Note that the lifecycle of the pointer to the **OH_AVFormat** instance is valid only when the function pointer is being called. Do not access the pointer to the instance after the function pointer is called. -\@syscap SystemCapability.Multimedia.Media.CodecBase +@syscap SystemCapability.Multimedia.Media.CodecBase - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | -| format | Indicates the handle to the attributes of the new output stream. | -| userData | Indicates the pointer to user-specific data. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| format | Indicates the handle to the attributes of the new output stream. | +| userData | Indicates the pointer to user-specific data. | ### OH_AVCProfile @@ -238,7 +236,7 @@ typedef enum OH_AVCProfileOH_AVCProfile **Description**
Enumerates the AVC profiles. -\@syscap SystemCapability.Multimedia.Media.CodecBase +@syscap SystemCapability.Multimedia.Media.CodecBase ### OH_MediaType @@ -250,7 +248,7 @@ typedef enum OH_MediaTypeOH_MediaType **Description**
Enumerates the media types. -\@syscap SystemCapability.Multimedia.Media.CodecBase +@syscap SystemCapability.Multimedia.Media.CodecBase ## Enum Description @@ -265,7 +263,7 @@ enum OH_AACProfile **Description**
Enumerates the AAC profiles. -\@syscap SystemCapability.Multimedia.Media.CodecBase +@syscap SystemCapability.Multimedia.Media.CodecBase ### OH_AVCodecBufferFlags @@ -277,14 +275,14 @@ enum OH_AVCodecBufferFlags **Description**
Enumerates the buffer flags of an **OH_AVCodec** instance. -\@syscap SystemCapability.Multimedia.Media.CodecBase +@syscap SystemCapability.Multimedia.Media.CodecBase -| Name | Description | + | Value| Description| | -------- | -------- | -| AVCODEC_BUFFER_FLAGS_EOS | The buffer contains an end-of-stream frame. | -| AVCODEC_BUFFER_FLAGS_SYNC_FRAME | The buffer contains a sync frame. | -| AVCODEC_BUFFER_FLAGS_INCOMPLETE_FRAME | The buffer contains part of a frame. | -| AVCODEC_BUFFER_FLAGS_CODEC_DATA | The buffer contains codec-specific data. | +| AVCODEC_BUFFER_FLAGS_EOS | The buffer contains an end-of-stream frame.| +| AVCODEC_BUFFER_FLAGS_SYNC_FRAME | The buffer contains a sync frame.| +| AVCODEC_BUFFER_FLAGS_INCOMPLETE_FRAME | The buffer contains part of a frame.| +| AVCODEC_BUFFER_FLAGS_CODEC_DATA | The buffer contains codec-specific data.| ### OH_AVCProfile @@ -296,7 +294,7 @@ enum OH_AVCProfile **Description**
Enumerates the AVC profiles. -\@syscap SystemCapability.Multimedia.Media.CodecBase +@syscap SystemCapability.Multimedia.Media.CodecBase ### OH_MediaType @@ -308,12 +306,12 @@ enum OH_MediaType **Description**
Enumerates the media types. -\@syscap SystemCapability.Multimedia.Media.CodecBase +@syscap SystemCapability.Multimedia.Media.CodecBase -| Name | Description | + | Value| Description| | -------- | -------- | -| MEDIA_TYPE_AUD | Audio track. | -| MEDIA_TYPE_VID | Video track. | +| MEDIA_TYPE_AUD | Audio track.| +| MEDIA_TYPE_VID | Video track.| ## Variable Description @@ -326,7 +324,7 @@ Enumerates the media types. uint32_t OH_AVCodecBufferAttr::flags ``` **Description**
-Buffer flag, which is a combination of multiple [OH_AVCodecBufferFlags](#oh_avcodecbufferflags). +Defines a buffer flag, which is a combination of multiple [OH_AVCodecBufferFlags](#oh_avcodecbufferflags). ### offset @@ -346,9 +344,9 @@ Start offset of valid data in the buffer. const char* OH_AVCODEC_MIMETYPE_AUDIO_AAC ``` **Description**
-Defines the MIME type for Advanced Audio Coding (AAC). +Defines the MIME type for AAC. -\@syscap SystemCapability.Multimedia.Media.CodecBase +@syscap SystemCapability.Multimedia.Media.CodecBase ### OH_AVCODEC_MIMETYPE_VIDEO_AVC @@ -358,9 +356,9 @@ Defines the MIME type for Advanced Audio Coding (AAC). const char* OH_AVCODEC_MIMETYPE_VIDEO_AVC ``` **Description**
-Defines the Multipurpose Internet Mail Extension (MIME) type for Advanced Video Coding (AVC). +Defines the MIME type for AVC. -\@syscap SystemCapability.Multimedia.Media.CodecBase +@syscap SystemCapability.Multimedia.Media.CodecBase ### OH_ED_KEY_EOS @@ -370,7 +368,7 @@ Defines the Multipurpose Internet Mail Extension (MIME) type for Advanced Video const char* OH_ED_KEY_EOS ``` **Description**
-Character descriptor of the end-of-stream in the surface auxiliary data. The value type is bool. +Defines the character descriptor of the end-of-stream in the surface auxiliary data. The value type is bool. ### OH_ED_KEY_TIME_STAMP @@ -380,9 +378,9 @@ Character descriptor of the end-of-stream in the surface auxiliary data. The val const char* OH_ED_KEY_TIME_STAMP ``` **Description**
-Provides unified character descriptors for the auxiliary data of the surface buffer. +Defines the unified character descriptors for the auxiliary data of the surface buffer. -\@syscap SystemCapability.Multimedia.Media.CodecBase +@syscap SystemCapability.Multimedia.Media.CodecBase ### OH_MD_KEY_AUD_CHANNEL_COUNT @@ -392,7 +390,7 @@ Provides unified character descriptors for the auxiliary data of the surface buf const char* OH_MD_KEY_AUD_CHANNEL_COUNT ``` **Description**
-Character descriptor of the number of audio channels. The value type is uint32_t. +Defines the character descriptor of the number of audio channels. The value type is uint32_t. ### OH_MD_KEY_AUD_SAMPLE_RATE @@ -402,7 +400,7 @@ Character descriptor of the number of audio channels. The value type is uint32_t const char* OH_MD_KEY_AUD_SAMPLE_RATE ``` **Description**
-Character descriptor of the audio sampling rate. The value type is uint32_t. +Defines the character descriptor of the audio sampling rate. The value type is uint32_t. ### OH_MD_KEY_AUDIO_SAMPLE_FORMAT @@ -412,7 +410,7 @@ Character descriptor of the audio sampling rate. The value type is uint32_t. const char* OH_MD_KEY_AUDIO_SAMPLE_FORMAT ``` **Description**
-Character descriptor of the audio sample format. The value type is uint32_t. +Defines the character descriptor of the audio sample format. The value type is uint32_t. ### OH_MD_KEY_BITRATE @@ -422,7 +420,7 @@ Character descriptor of the audio sample format. The value type is uint32_t. const char* OH_MD_KEY_BITRATE ``` **Description**
-Character descriptor of the bit rate. The value type is uint32_t. +Defines the character descriptor of the bit rate. The value type is uint32_t. ### OH_MD_KEY_CODEC_MIME @@ -432,7 +430,7 @@ Character descriptor of the bit rate. The value type is uint32_t. const char* OH_MD_KEY_CODEC_MIME ``` **Description**
-Character descriptor of the MIME type. The value type is string. +Defines the character descriptor of the MIME type. The value type is string. ### OH_MD_KEY_DURATION @@ -442,7 +440,7 @@ Character descriptor of the MIME type. The value type is string. const char* OH_MD_KEY_DURATION ``` **Description**
-Character descriptor of duration. The value type is int64_t. +Defines the character descriptor of duration. The value type is int64_t. ### OH_MD_KEY_FRAME_RATE @@ -452,7 +450,7 @@ Character descriptor of duration. The value type is int64_t. const char* OH_MD_KEY_FRAME_RATE ``` **Description**
-Character descriptor of the video frame rate. The value type is double. +Defines the character descriptor of the video frame rate. The value type is double. ### OH_MD_KEY_HEIGHT @@ -462,7 +460,7 @@ Character descriptor of the video frame rate. The value type is double. const char* OH_MD_KEY_HEIGHT ``` **Description**
-Character descriptor of the video height. The value type is uint32_t. +Defines the character descriptor of the video height. The value type is uint32_t. ### OH_MD_KEY_I_FRAME_INTERVAL @@ -472,7 +470,7 @@ Character descriptor of the video height. The value type is uint32_t. const char* OH_MD_KEY_I_FRAME_INTERVAL ``` **Description**
-Character descriptor of the I-frame interval. The value type is int32_t, and the unit is ms. +Defines the character descriptor of the I-frame interval. The value type is int32_t, and the unit is ms. ### OH_MD_KEY_MAX_INPUT_SIZE @@ -482,7 +480,7 @@ Character descriptor of the I-frame interval. The value type is int32_t, and the const char* OH_MD_KEY_MAX_INPUT_SIZE ``` **Description**
-Character descriptor of the maximum input size. The value type is uint32_t. +Defines the character descriptor of the maximum input size. The value type is uint32_t. ### OH_MD_KEY_PIXEL_FORMAT @@ -492,7 +490,7 @@ Character descriptor of the maximum input size. The value type is uint32_t. const char* OH_MD_KEY_PIXEL_FORMAT ``` **Description**
-Character descriptor of the video pixel format. The value type is int32_t. For details, see [OH_AVPixelFormat](_core.md#oh_avpixelformat). +Defines the character descriptor of the video pixel format. The value type is int32_t. For details, see [OH_AVPixelFormat](_core.md#oh_avpixelformat). ### OH_MD_KEY_PROFILE @@ -502,7 +500,7 @@ Character descriptor of the video pixel format. The value type is int32_t. For d const char* OH_MD_KEY_PROFILE ``` **Description**
-Character descriptor of the audio/video encoding capability. The value type is int32_t. For details, see [OH_AVCProfile](#oh_avcprofile) or [OH_AACProfile](#oh_aacprofile). +Defines the character descriptor of the audio/video encoding capability. The value type is int32_t. For details, see [OH_AVCProfile](#oh_avcprofile) or [OH_AACProfile](#oh_aacprofile). ### OH_MD_KEY_ROTATION @@ -512,7 +510,7 @@ Character descriptor of the audio/video encoding capability. The value type is i const char* OH_MD_KEY_ROTATION ``` **Description**
-Character descriptor of the surface rotation angle. The value type is int32_t. The value range is {0, 90, 180, 270}. The default value is 0. +Defines the character descriptor of the surface rotation angle. The value type is int32_t. The value range is {0, 90, 180, 270}. The default value is 0. ### OH_MD_KEY_TRACK_TYPE @@ -522,9 +520,9 @@ Character descriptor of the surface rotation angle. The value type is int32_t. T const char* OH_MD_KEY_TRACK_TYPE ``` **Description**
-Provides unified character descriptors for the media playback framework. +Defines the unified character descriptors for the media playback framework. -\@syscap SystemCapability.Multimedia.Media.CodecBase +@syscap SystemCapability.Multimedia.Media.CodecBase ### OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE @@ -534,7 +532,7 @@ Provides unified character descriptors for the media playback framework. const char* OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE ``` **Description**
-Character descriptor of the video encoding bit rate mode. The value type is int32_t. For details, see [OH_VideoEncodeBitrateMode](_video_encoder.md#oh_videoencodebitratemode). +Defines the character descriptor of the video encoding bit rate mode. The value type is int32_t. For details, see [OH_VideoEncodeBitrateMode](_video_encoder.md#oh_videoencodebitratemode). ### OH_MD_KEY_WIDTH @@ -544,7 +542,7 @@ Character descriptor of the video encoding bit rate mode. The value type is int3 const char* OH_MD_KEY_WIDTH ``` **Description**
-Character descriptor of the video width. The value type is uint32_t. +Defines the character descriptor of the video width. The value type is uint32_t. ### pts @@ -554,7 +552,7 @@ Character descriptor of the video width. The value type is uint32_t. int64_t OH_AVCodecBufferAttr::pts ``` **Description**
-Presentation timestamp of the buffer, in microseconds. +Defines the presentation timestamp of the buffer, in microseconds. ### size @@ -564,4 +562,4 @@ Presentation timestamp of the buffer, in microseconds. int32_t OH_AVCodecBufferAttr::size ``` **Description**
-Size of the data contained in the buffer, in bytes. +Defines the size of the data contained in the buffer, in bytes. diff --git a/en/application-dev/reference/native-apis/_video_decoder.md b/en/application-dev/reference/native-apis/_video_decoder.md index 23fcefb0c633bbe7682b6b5ceb4a835e2b5b6f32..c56dd9bfcbb30ce7b42d4b76cb96ed71e1bd7238 100644 --- a/en/application-dev/reference/native-apis/_video_decoder.md +++ b/en/application-dev/reference/native-apis/_video_decoder.md @@ -3,11 +3,11 @@ ## Overview -Provides the functions for video decoding. +Provides the functions for video decoding. This module may not be supported on some devices. You can call [CanIUse](../syscap.md) to check whether this module is supported on your device. -\@syscap SystemCapability.Multimedia.Media.VideoDecoder +@syscap SystemCapability.Multimedia.Media.VideoDecoder -**Since:** +**Since** 9 @@ -16,31 +16,31 @@ Provides the functions for video decoding. ### Files -| Name | Description | + | Name| Description| | -------- | -------- | -| [native_avcodec_videodecoder.h](native__avcodec__videodecoder_8h.md) | Declares the native APIs used for video decoding.
File to Include: | +| [native_avcodec_videodecoder.h](native__avcodec__videodecoder_8h.md) | Declares the native APIs used for video decoding.
File to include: | ### Functions -| Name | Description | + | Name| Description| | -------- | -------- | -| [OH_VideoDecoder_CreateByMime](#oh_videodecoder_createbymime) (const char \*mime) | Creates a video decoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This API is recommended in most cases. | -| [OH_VideoDecoder_CreateByName](#oh_videodecoder_createbyname) (const char \*name) | Creates a video decoder instance based on a video decoder name. To use this API, you must know the exact name of the video decoder. | -| [OH_VideoDecoder_Destroy](#oh_videodecoder_destroy) (OH_AVCodec \*codec) | Clears the internal resources of a video decoder and destroys the video decoder instance. | -| [OH_VideoDecoder_SetCallback](#oh_videodecoder_setcallback) (OH_AVCodec \*codec, [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md) callback, void \*userData) | Sets an asynchronous callback so that your application can respond to events generated by a video decoder. This API must be called prior to **Prepare**. | -| [OH_VideoDecoder_SetSurface](#oh_videodecoder_setsurface) (OH_AVCodec \*codec, [OHNativeWindow](_native_window.md) \*window) | Sets an output surface for a video decoder. This API must be called prior to **Prepare**. | -| [OH_VideoDecoder_Configure](#oh_videodecoder_configure) (OH_AVCodec \*codec, OH_AVFormat \*format) | Configures a video decoder. Typically, you need to configure the attributes, which can be extracted from the container, of the video track that can be decoded. This API must be called prior to **Prepare**. | -| [OH_VideoDecoder_Prepare](#oh_videodecoder_prepare) (OH_AVCodec \*codec) | Prepares internal resources for a video decoder. This API must be called after **Configure**. | -| [OH_VideoDecoder_Start](#oh_videodecoder_start) (OH_AVCodec \*codec) | Starts a video decoder. This API can be called only after the decoder is prepared successfully. After being started, the decoder starts to report the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) event. | -| [OH_VideoDecoder_Stop](#oh_videodecoder_stop) (OH_AVCodec \*codec) | Stops a video decoder. After the decoder is stopped, you can call **Start** to start it again. If you have passed codec-specific data in the previous **Start** for the decoder, you must pass it again. | -| [OH_VideoDecoder_Flush](#oh_videodecoder_flush) (OH_AVCodec \*codec) | Clears the input and output data in the internal buffer of a video decoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required. | -| [OH_VideoDecoder_Reset](#oh_videodecoder_reset) (OH_AVCodec \*codec) | Resets a video decoder. To continue decoding, you must call **Configure** and **Start** to configure and start the decoder again. | -| [OH_VideoDecoder_GetOutputDescription](#oh_videodecoder_getoutputdescription) (OH_AVCodec \*codec) | Obtains the attributes of the output data of a video decoder. The **OH_AVFormat** instance in the return value will become invalid when this API is called again or when the **OH_AVCodec** instance is destroyed. | -| [OH_VideoDecoder_SetParameter](#oh_videodecoder_setparameter) (OH_AVCodec \*codec, OH_AVFormat \*format) | Sets dynamic parameters for a video decoder. This API can be called only after the decoder is started. Incorrect parameter settings may cause decoding failure. | -| [OH_VideoDecoder_PushInputData](#oh_videodecoder_pushinputdata) (OH_AVCodec \*codec, uint32_t index, [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) attr) | Pushes the input buffer filled with data to a video decoder. The [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback reports available input buffers and their indexes. After being pushed to the decoder, a buffer is not accessible until the buffer with the same index is reported again through the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback. In addition, some decoders require the input of codec-specific data, such as PPS/SPS data in H.264 format, to initialize the decoding process. | -| [OH_VideoDecoder_RenderOutputData](#oh_videodecoder_renderoutputdata) (OH_AVCodec \*codec, uint32_t index) | Frees an output buffer of a video decoder and instructs the decoder to render the decoded data in the buffer on the output surface. If no output surface is configured, calling this API only frees the output buffer. | -| [OH_VideoDecoder_FreeOutputData](#oh_videodecoder_freeoutputdata) (OH_AVCodec \*codec, uint32_t index) | Frees an output buffer of a video decoder. | +| [OH_VideoDecoder_CreateByMime](#oh_videodecoder_createbymime) (const char \*mime) | Creates a video decoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This API is recommended in most cases. | +| [OH_VideoDecoder_CreateByName](#oh_videodecoder_createbyname) (const char \*name) | Creates a video decoder instance based on a video decoder name. To use this API, you must know the exact name of the video decoder. | +| [OH_VideoDecoder_Destroy](#oh_videodecoder_destroy) (OH_AVCodec \*codec) | Clears the internal resources of a video decoder and destroys the video decoder instance. | +| [OH_VideoDecoder_SetCallback](#oh_videodecoder_setcallback) (OH_AVCodec \*codec, [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md) callback, void \*userData) | Sets an asynchronous callback so that your application can respond to events generated by a video decoder. This API must be called prior to **Prepare**. | +| [OH_VideoDecoder_SetSurface](#oh_videodecoder_setsurface) (OH_AVCodec \*codec, OHNativeWindow \*window) | Sets an output surface for a video decoder. This API must be called prior to **Prepare**. | +| [OH_VideoDecoder_Configure](#oh_videodecoder_configure) (OH_AVCodec \*codec, OH_AVFormat \*format) | Configures a video decoder. Typically, you need to configure the attributes, which can be extracted from the container, of the video track that can be decoded. This API must be called prior to **Prepare**. | +| [OH_VideoDecoder_Prepare](#oh_videodecoder_prepare) (OH_AVCodec \*codec) | Prepares internal resources for a video decoder. This API must be called after **Configure**. | +| [OH_VideoDecoder_Start](#oh_videodecoder_start) (OH_AVCodec \*codec) | Starts a video decoder. This API can be called only after the decoder is prepared successfully. After being started, the decoder starts to report the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) event. | +| [OH_VideoDecoder_Stop](#oh_videodecoder_stop) (OH_AVCodec \*codec) | Stops a video decoder. After the decoder is stopped, you can call **Start** to start it again. If you have passed codec-specific data in the previous **Start** for the decoder, you must pass it again. | +| [OH_VideoDecoder_Flush](#oh_videodecoder_flush) (OH_AVCodec \*codec) | Clears the input and output data in the internal buffer of a video decoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required. | +| [OH_VideoDecoder_Reset](#oh_videodecoder_reset) (OH_AVCodec \*codec) | Resets a video decoder. To continue decoding, you must call **Configure** and **Start** to configure and start the decoder again. | +| [OH_VideoDecoder_GetOutputDescription](#oh_videodecoder_getoutputdescription) (OH_AVCodec \*codec) | Obtains the attributes of the output data of a video decoder. The **OH_AVFormat** instance in the return value will become invalid when this API is called again or when the **OH_AVCodec** instance is destroyed. | +| [OH_VideoDecoder_SetParameter](#oh_videodecoder_setparameter) (OH_AVCodec \*codec, OH_AVFormat \*format) | Sets dynamic parameters for a video decoder. This API can be called only after the decoder is started. Incorrect parameter settings may cause decoding failure. | +| [OH_VideoDecoder_PushInputData](#oh_videodecoder_pushinputdata) (OH_AVCodec \*codec, uint32_t index, [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) attr) | Pushes the input buffer filled with data to a video decoder. The [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback reports available input buffers and their indexes. After being pushed to the decoder, a buffer is not accessible until the buffer with the same index is reported again through the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback. In addition, some decoders require the input of codec-specific data, such as PPS/SPS data in H.264 format, to initialize the decoding process. | +| [OH_VideoDecoder_RenderOutputData](#oh_videodecoder_renderoutputdata) (OH_AVCodec \*codec, uint32_t index) | Frees an output buffer of a video decoder and instructs the decoder to render the decoded data in the buffer on the output surface. If no output surface is configured, calling this API only frees the output buffer. | +| [OH_VideoDecoder_FreeOutputData](#oh_videodecoder_freeoutputdata) (OH_AVCodec \*codec, uint32_t index) | Frees an output buffer of a video decoder. | ## Function Description @@ -55,14 +55,14 @@ OH_AVErrCode OH_VideoDecoder_Configure (OH_AVCodec * codec, OH_AVFormat * format **Description**
Configures a video decoder. Typically, you need to configure the attributes, which can be extracted from the container, of the video track that can be decoded. This API must be called prior to **Prepare**. -\@syscap SystemCapability.Multimedia.Media.VideoDecoder +@syscap SystemCapability.Multimedia.Media.VideoDecoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | -| format | Indicates the handle to an **OH_AVFormat** instance, which provides the attributes of the video track to be decoded. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| format | Indicates the handle to an **OH_AVFormat** instance, which provides the attributes of the video track to be decoded. | **Returns** @@ -80,13 +80,13 @@ OH_AVCodec* OH_VideoDecoder_CreateByMime (const char * mime) **Description**
Creates a video decoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This API is recommended in most cases. -\@syscap SystemCapability.Multimedia.Media.VideoDecoder +@syscap SystemCapability.Multimedia.Media.VideoDecoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| mime | Indicates the pointer to a MIME type. For details, see [OH_AVCODEC_MIMETYPE_VIDEO_AVC](_codec_base.md#oh_avcodec_mimetype_video_avc). | +| mime | Indicates the pointer to a MIME type. For details, see [OH_AVCODEC_MIMETYPE_VIDEO_AVC](_codec_base.md#oh_avcodec_mimetype_video_avc).| **Returns** @@ -102,13 +102,13 @@ OH_AVCodec* OH_VideoDecoder_CreateByName (const char * name) **Description**
Creates a video decoder instance based on a video decoder name. To use this API, you must know the exact name of the video decoder. -\@syscap SystemCapability.Multimedia.Media.VideoDecoder +@syscap SystemCapability.Multimedia.Media.VideoDecoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| name | Indicates the pointer to a video decoder name. | +| name | Indicates the pointer to a video decoder name. | **Returns** @@ -124,13 +124,13 @@ OH_AVErrCode OH_VideoDecoder_Destroy (OH_AVCodec * codec) **Description**
Clears the internal resources of a video decoder and destroys the video decoder instance. -\@syscap SystemCapability.Multimedia.Media.VideoDecoder +@syscap SystemCapability.Multimedia.Media.VideoDecoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | **Returns** @@ -148,13 +148,13 @@ OH_AVErrCode OH_VideoDecoder_Flush (OH_AVCodec * codec) **Description**
Clears the input and output data in the internal buffer of a video decoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required. -\@syscap SystemCapability.Multimedia.Media.VideoDecoder +@syscap SystemCapability.Multimedia.Media.VideoDecoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | **Returns** @@ -172,14 +172,14 @@ OH_AVErrCode OH_VideoDecoder_FreeOutputData (OH_AVCodec * codec, uint32_t index **Description**
Frees an output buffer of a video decoder. -\@syscap SystemCapability.Multimedia.Media.VideoDecoder +@syscap SystemCapability.Multimedia.Media.VideoDecoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | -| index | Indicates the index of an output buffer. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| index | Indicates the index of an output buffer. | **Returns** @@ -197,13 +197,13 @@ OH_AVFormat* OH_VideoDecoder_GetOutputDescription (OH_AVCodec * codec) **Description**
Obtains the attributes of the output data of a video decoder. The **OH_AVFormat** instance in the return value will become invalid when this API is called again or when the **OH_AVCodec** instance is destroyed. -\@syscap SystemCapability.Multimedia.Media.VideoDecoder +@syscap SystemCapability.Multimedia.Media.VideoDecoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | **Returns** @@ -219,13 +219,13 @@ OH_AVErrCode OH_VideoDecoder_Prepare (OH_AVCodec * codec) **Description**
Prepares internal resources for a video decoder. This API must be called after **Configure**. -\@syscap SystemCapability.Multimedia.Media.VideoDecoder +@syscap SystemCapability.Multimedia.Media.VideoDecoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | **Returns** @@ -243,15 +243,15 @@ OH_AVErrCode OH_VideoDecoder_PushInputData (OH_AVCodec * codec, uint32_t index, **Description**
Pushes the input buffer filled with data to a video decoder. The [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback reports available input buffers and their indexes. After being pushed to the decoder, a buffer is not accessible until the buffer with the same index is reported again through the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback. In addition, some decoders require the input of codec-specific data, such as PPS/SPS data in H.264 format, to initialize the decoding process. -\@syscap SystemCapability.Multimedia.Media.VideoDecoder +@syscap SystemCapability.Multimedia.Media.VideoDecoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | -| index | Indicates the index of an input buffer. | -| attr | Indicates the attributes of the data contained in the buffer. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| index | Indicates the index of an input buffer. | +| attr | Indicates the attributes of the data contained in the buffer. | **Returns** @@ -269,14 +269,14 @@ OH_AVErrCode OH_VideoDecoder_RenderOutputData (OH_AVCodec * codec, uint32_t inde **Description**
Frees an output buffer of a video decoder and instructs the decoder to render the decoded data in the buffer on the output surface. If no output surface is configured, calling this API only frees the output buffer. -\@syscap SystemCapability.Multimedia.Media.VideoDecoder +@syscap SystemCapability.Multimedia.Media.VideoDecoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | -| index | Indicates the index of an output buffer. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| index | Indicates the index of an output buffer. | **Returns** @@ -294,13 +294,13 @@ OH_AVErrCode OH_VideoDecoder_Reset (OH_AVCodec * codec) **Description**
Resets a video decoder. To continue decoding, you must call **Configure** and **Start** to configure and start the decoder again. -\@syscap SystemCapability.Multimedia.Media.VideoDecoder +@syscap SystemCapability.Multimedia.Media.VideoDecoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | **Returns** @@ -318,15 +318,15 @@ OH_AVErrCode OH_VideoDecoder_SetCallback (OH_AVCodec * codec, OH_AVCodecAsyncCal **Description**
Sets an asynchronous callback so that your application can respond to events generated by a video decoder. This API must be called prior to **Prepare**. -\@syscap SystemCapability.Multimedia.Media.VideoDecoder +@syscap SystemCapability.Multimedia.Media.VideoDecoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | -| callback | Indicates a collection of all callback functions. For details, see [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md). | -| userData | Indicates the pointer to user-specific data. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| callback | Indicates a collection of all callback functions. For details, see [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md).| +| userData | Indicates the pointer to user-specific data. | **Returns** @@ -344,14 +344,14 @@ OH_AVErrCode OH_VideoDecoder_SetParameter (OH_AVCodec * codec, OH_AVFormat * for **Description**
Sets dynamic parameters for a video decoder. This API can be called only after the decoder is started. Incorrect parameter settings may cause decoding failure. -\@syscap SystemCapability.Multimedia.Media.VideoDecoder +@syscap SystemCapability.Multimedia.Media.VideoDecoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | -| format | Indicates the handle to an **OH_AVFormat** instance. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| format | Indicates the pointer to an **OH_AVFormat** instance. | **Returns** @@ -369,14 +369,14 @@ OH_AVErrCode OH_VideoDecoder_SetSurface (OH_AVCodec * codec, OHNativeWindow * wi **Description**
Sets an output surface for a video decoder. This API must be called prior to **Prepare**. -\@syscap SystemCapability.Multimedia.Media.VideoDecoder +@syscap SystemCapability.Multimedia.Media.VideoDecoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | -| window | Indicates the pointer to an **OHNativeWindow** instance. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| window | Indicates the pointer to an **OHNativeWindow** instance. | **Returns** @@ -394,13 +394,13 @@ OH_AVErrCode OH_VideoDecoder_Start (OH_AVCodec * codec) **Description**
Starts a video decoder. This API can be called only after the decoder is prepared successfully. After being started, the decoder starts to report the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) event. -\@syscap SystemCapability.Multimedia.Media.VideoDecoder +@syscap SystemCapability.Multimedia.Media.VideoDecoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | **Returns** @@ -418,13 +418,13 @@ OH_AVErrCode OH_VideoDecoder_Stop (OH_AVCodec * codec) **Description**
Stops a video decoder. After the decoder is stopped, you can call **Start** to start it again. If you have passed codec-specific data in the previous **Start** for the decoder, you must pass it again. -\@syscap SystemCapability.Multimedia.Media.VideoDecoder +@syscap SystemCapability.Multimedia.Media.VideoDecoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | **Returns** diff --git a/en/application-dev/reference/native-apis/_video_encoder.md b/en/application-dev/reference/native-apis/_video_encoder.md index c28d758c417106607997feec3f8d5f75a0ea6099..736adcdf7e73b40beb4d35250fec0e19cd794d57 100644 --- a/en/application-dev/reference/native-apis/_video_encoder.md +++ b/en/application-dev/reference/native-apis/_video_encoder.md @@ -3,57 +3,56 @@ ## Overview -Provides the functions and enums for video encoding. +Provides the functions and enums for video encoding. This module may not be supported on some devices. You can call [CanIUse](../syscap.md) to check whether this module is supported on your device. -\@syscap SystemCapability.Multimedia.Media.VideoEncoder +@syscap SystemCapability.Multimedia.Media.VideoEncoder -**Since:** +**Since** 9 - ## Summary ### Files -| Name | Description | + | Name| Description| | -------- | -------- | -| [native_avcodec_videoencoder.h](native__avcodec__videoencoder_8h.md) | Declares the native APIs used for video encoding.
File to Include: | +| [native_avcodec_videoencoder.h](native__avcodec__videoencoder_8h.md) | Declares the native APIs used for video encoding.
File to include: | ### Types -| Name | Description | + | Name| Description| | -------- | -------- | -| [OH_VideoEncodeBitrateMode](#oh_videoencodebitratemode) | Enumerates the bit rate modes of video encoding. | +| [OH_VideoEncodeBitrateMode](#oh_videoencodebitratemode) | Enumerates the bit rate modes of video encoding. | ### Enums -| Name | Description | + | Name| Description| | -------- | -------- | -| [OH_VideoEncodeBitrateMode](#oh_videoencodebitratemode) { CBR = 0, VBR = 1, CQ = 2 } | Enumerates the bit rate modes of video encoding. | +| [OH_VideoEncodeBitrateMode](#oh_videoencodebitratemode) { **CBR** = 0, **VBR** = 1, **CQ** = 2 } | Enumerates the bit rate modes of video encoding. | ### Functions -| Name | Description | + | Name| Description| | -------- | -------- | -| [OH_VideoEncoder_CreateByMime](#oh_videoencoder_createbymime) (const char \*mime) | Creates a video encoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This API is recommended in most cases. | -| [OH_VideoEncoder_CreateByName](#oh_videoencoder_createbyname) (const char \*name) | Creates a video encoder instance based on a video encoder name. To use this API, you must know the exact name of the video encoder. | -| [OH_VideoEncoder_Destroy](#oh_videoencoder_destroy) (OH_AVCodec \*codec) | Clears the internal resources of a video encoder and destroys the video encoder instance. | -| [OH_VideoEncoder_SetCallback](#oh_videoencoder_setcallback) (OH_AVCodec \*codec, [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md) callback, void \*userData) | Sets an asynchronous callback so that your application can respond to events generated by a video encoder. This API must be called prior to **Prepare**. | -| [OH_VideoEncoder_Configure](#oh_videoencoder_configure) (OH_AVCodec \*codec, OH_AVFormat \*format) | Configures a video encoder. Typically, you need to configure the attributes of the video track that can be encoded. This API must be called prior to **Prepare**. | -| [OH_VideoEncoder_Prepare](#oh_videoencoder_prepare) (OH_AVCodec \*codec) | Prepares internal resources for a video encoder. This API must be called after **Configure**. | -| [OH_VideoEncoder_Start](#oh_videoencoder_start) (OH_AVCodec \*codec) | Starts a video encoder. This API can be called only after the encoder is prepared successfully. After being started, the encoder starts to report the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) event. | -| [OH_VideoEncoder_Stop](#oh_videoencoder_stop) (OH_AVCodec \*codec) | Stops a video encoder. After the encoder is stopped, you can call **Start** to start it again. | -| [OH_VideoEncoder_Flush](#oh_videoencoder_flush) (OH_AVCodec \*codec) | Clears the input and output data in the internal buffer of a video encoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required. | -| [OH_VideoEncoder_Reset](#oh_videoencoder_reset) (OH_AVCodec \*codec) | Resets a video encoder. To continue encoding, you must call **Configure** and **Start** to configure and start the encoder again. | -| [OH_VideoEncoder_GetOutputDescription](#oh_videoencoder_getoutputdescription) (OH_AVCodec \*codec) | Obtains the attributes of the output data of a video encoder. The **OH_AVFormat** instance in the return value will become invalid when this API is called again or when the **OH_AVCodec** instance is destroyed. | -| [OH_VideoEncoder_SetParameter](#oh_videoencoder_setparameter) (OH_AVCodec \*codec, OH_AVFormat \*format) | Sets dynamic parameters for a video encoder. This API can be called only after the encoder is started. Incorrect parameter settings may cause encoding failure. | -| [OH_VideoEncoder_GetSurface](#oh_videoencoder_getsurface) (OH_AVCodec \*codec, [OHNativeWindow](_native_window.md) \*\*window) | Obtains an input surface from a video encoder. This API must be called prior to **Prepare**. | -| [OH_VideoEncoder_FreeOutputData](#oh_videoencoder_freeoutputdata) (OH_AVCodec \*codec, uint32_t index) | Frees an output buffer of a video encoder. | -| [OH_VideoEncoder_NotifyEndOfStream](#oh_videoencoder_notifyendofstream) (OH_AVCodec \*codec) | Notifies a video encoder that input streams end. This API is recommended in surface mode. | +| [OH_VideoEncoder_CreateByMime](#oh_videoencoder_createbymime) (const char \*mime) | Creates a video encoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This API is recommended in most cases. | +| [OH_VideoEncoder_CreateByName](#oh_videoencoder_createbyname) (const char \*name) | Creates a video encoder instance based on a video encoder name. To use this API, you must know the exact name of the video encoder. | +| [OH_VideoEncoder_Destroy](#oh_videoencoder_destroy) (OH_AVCodec \*codec) | Clears the internal resources of a video encoder and destroys the video encoder instance. | +| [OH_VideoEncoder_SetCallback](#oh_videoencoder_setcallback) (OH_AVCodec \*codec, [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md) callback, void \*userData) | Sets an asynchronous callback so that your application can respond to events generated by a video encoder. This API must be called prior to **Prepare**. | +| [OH_VideoEncoder_Configure](#oh_videoencoder_configure) (OH_AVCodec \*codec, OH_AVFormat \*format) | Configures a video encoder. Typically, you need to configure the attributes of the video track that can be encoded. This API must be called prior to **Prepare**. | +| [OH_VideoEncoder_Prepare](#oh_videoencoder_prepare) (OH_AVCodec \*codec) | Prepares internal resources for a video encoder. This API must be called after **Configure**. | +| [OH_VideoEncoder_Start](#oh_videoencoder_start) (OH_AVCodec \*codec) | Starts a video encoder. This API can be called only after the encoder is prepared successfully. After being started, the encoder starts to report the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) event. | +| [OH_VideoEncoder_Stop](#oh_videoencoder_stop) (OH_AVCodec \*codec) | Stops a video encoder. After the encoder is stopped, you can call **Start** to start it again. | +| [OH_VideoEncoder_Flush](#oh_videoencoder_flush) (OH_AVCodec \*codec) | Clears the input and output data in the internal buffer of a video encoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required. | +| [OH_VideoEncoder_Reset](#oh_videoencoder_reset) (OH_AVCodec \*codec) | Resets a video encoder. To continue encoding, you must call **Configure** and **Start** to configure and start the encoder again. | +| [OH_VideoEncoder_GetOutputDescription](#oh_videoencoder_getoutputdescription) (OH_AVCodec \*codec) | Obtains the attributes of the output data of a video encoder. The **OH_AVFormat** instance in the return value will become invalid when this API is called again or when the **OH_AVCodec** instance is destroyed. | +| [OH_VideoEncoder_SetParameter](#oh_videoencoder_setparameter) (OH_AVCodec \*codec, OH_AVFormat \*format) | Sets dynamic parameters for a video encoder. This API can be called only after the encoder is started. Incorrect parameter settings may cause encoding failure. | +| [OH_VideoEncoder_GetSurface](#oh_videoencoder_getsurface) (OH_AVCodec \*codec, OHNativeWindow \*\*window) | Obtains an input surface from a video encoder. This API must be called prior to **Prepare**. | +| [OH_VideoEncoder_FreeOutputData](#oh_videoencoder_freeoutputdata) (OH_AVCodec \*codec, uint32_t index) | Frees an output buffer of a video encoder. | +| [OH_VideoEncoder_NotifyEndOfStream](#oh_videoencoder_notifyendofstream) (OH_AVCodec \*codec) | Notifies a video encoder that input streams end. This API is recommended in surface mode. | ## Type Description @@ -68,7 +67,7 @@ typedef enum OH_VideoEncodeBitrateModeOH_VideoEncodeBitrateMode **Description**
Enumerates the bit rate modes of video encoding. -\@syscap SystemCapability.Multimedia.Media.VideoEncoder +@syscap SystemCapability.Multimedia.Media.VideoEncoder ## Enum Description @@ -83,13 +82,13 @@ enum OH_VideoEncodeBitrateMode **Description**
Enumerates the bit rate modes of video encoding. -\@syscap SystemCapability.Multimedia.Media.VideoEncoder +@syscap SystemCapability.Multimedia.Media.VideoEncoder -| Name | Description | + | Value| Description| | -------- | -------- | -| CBR | Constant bit rate. | -| VBR | Variable bit rate. | -| CQ | Constant quality. | +| CBR | Constant bit rate.| +| VBR | Variable bit rate.| +| CQ | Constant quality.| ## Function Description @@ -104,14 +103,14 @@ OH_AVErrCode OH_VideoEncoder_Configure (OH_AVCodec * codec, OH_AVFormat * format **Description**
Configures a video encoder. Typically, you need to configure the attributes of the video track that can be encoded. This API must be called prior to **Prepare**. -\@syscap SystemCapability.Multimedia.Media.VideoEncoder +@syscap SystemCapability.Multimedia.Media.VideoEncoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | -| format | Indicates the handle to an **OH_AVFormat** instance, which provides the attributes of the video track to be encoded. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| format | Indicates the handle to an **OH_AVFormat** instance, which provides the attributes of the video track to be encoded. | **Returns** @@ -127,15 +126,15 @@ Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the op OH_AVCodec* OH_VideoEncoder_CreateByMime (const char * mime) ``` **Description**
-Creates a video encoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This API is recommended in most cases. +Creates a video encoder instance based on a MIME type. This API is recommended in most cases. -\@syscap SystemCapability.Multimedia.Media.VideoEncoder +@syscap SystemCapability.Multimedia.Media.VideoEncoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| mime | Indicates the pointer to a MIME type. For details, see [OH_AVCODEC_MIMETYPE_VIDEO_AVC](_codec_base.md#oh_avcodec_mimetype_video_avc). | +| mime | Indicates the pointer to a MIME type. For details, see [OH_AVCODEC_MIMETYPE_VIDEO_AVC](_codec_base.md#oh_avcodec_mimetype_video_avc).| **Returns** @@ -151,13 +150,13 @@ OH_AVCodec* OH_VideoEncoder_CreateByName (const char * name) **Description**
Creates a video encoder instance based on a video encoder name. To use this API, you must know the exact name of the video encoder. -\@syscap SystemCapability.Multimedia.Media.VideoEncoder +@syscap SystemCapability.Multimedia.Media.VideoEncoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| name | Indicates the pointer to a video encoder name. | +| name | Indicates the pointer to a video encoder name. | **Returns** @@ -173,13 +172,13 @@ OH_AVErrCode OH_VideoEncoder_Destroy (OH_AVCodec * codec) **Description**
Clears the internal resources of a video encoder and destroys the video encoder instance. -\@syscap SystemCapability.Multimedia.Media.VideoEncoder +@syscap SystemCapability.Multimedia.Media.VideoEncoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | **Returns** @@ -197,13 +196,13 @@ OH_AVErrCode OH_VideoEncoder_Flush (OH_AVCodec * codec) **Description**
Clears the input and output data in the internal buffer of a video encoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required. -\@syscap SystemCapability.Multimedia.Media.VideoEncoder +@syscap SystemCapability.Multimedia.Media.VideoEncoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | **Returns** @@ -221,14 +220,14 @@ OH_AVErrCode OH_VideoEncoder_FreeOutputData (OH_AVCodec * codec, uint32_t index **Description**
Frees an output buffer of a video encoder. -\@syscap SystemCapability.Multimedia.Media.VideoEncoder +@syscap SystemCapability.Multimedia.Media.VideoEncoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | -| index | Indicates the index of an output buffer. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| index | Indicates the index of an output buffer. | **Returns** @@ -246,13 +245,13 @@ OH_AVFormat* OH_VideoEncoder_GetOutputDescription (OH_AVCodec * codec) **Description**
Obtains the attributes of the output data of a video encoder. The **OH_AVFormat** instance in the return value will become invalid when this API is called again or when the **OH_AVCodec** instance is destroyed. -\@syscap SystemCapability.Multimedia.Media.VideoEncoder +@syscap SystemCapability.Multimedia.Media.VideoEncoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | **Returns** @@ -268,14 +267,14 @@ OH_AVErrCode OH_VideoEncoder_GetSurface (OH_AVCodec * codec, OHNativeWindow ** w **Description**
Obtains an input surface from a video encoder. This API must be called prior to **Prepare**. -\@syscap SystemCapability.Multimedia.Media.VideoEncoder +@syscap SystemCapability.Multimedia.Media.VideoEncoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | -| window | Indicates the double pointer to an **OHNativeWindow** instance. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| window | Indicates the double pointer to an **OHNativeWindow** instance. | **Returns** @@ -293,13 +292,13 @@ OH_AVErrCode OH_VideoEncoder_NotifyEndOfStream (OH_AVCodec * codec) **Description**
Notifies a video encoder that input streams end. This API is recommended in surface mode. -\@syscap SystemCapability.Multimedia.Media.VideoEncoder +@syscap SystemCapability.Multimedia.Media.VideoEncoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | **Returns** @@ -317,13 +316,13 @@ OH_AVErrCode OH_VideoEncoder_Prepare (OH_AVCodec * codec) **Description**
Prepares internal resources for a video encoder. This API must be called after **Configure**. -\@syscap SystemCapability.Multimedia.Media.VideoEncoder +@syscap SystemCapability.Multimedia.Media.VideoEncoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | **Returns** @@ -341,13 +340,13 @@ OH_AVErrCode OH_VideoEncoder_Reset (OH_AVCodec * codec) **Description**
Resets a video encoder. To continue encoding, you must call **Configure** and **Start** to configure and start the encoder again. -\@syscap SystemCapability.Multimedia.Media.VideoEncoder +@syscap SystemCapability.Multimedia.Media.VideoEncoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | **Returns** @@ -365,15 +364,15 @@ OH_AVErrCode OH_VideoEncoder_SetCallback (OH_AVCodec * codec, OH_AVCodecAsyncCal **Description**
Sets an asynchronous callback so that your application can respond to events generated by a video encoder. This API must be called prior to **Prepare**. -\@syscap SystemCapability.Multimedia.Media.VideoEncoder +@syscap SystemCapability.Multimedia.Media.VideoEncoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | -| callback | Indicates a collection of all callback functions. For details, see [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md). | -| userData | Indicates the pointer to user-specific data. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| callback | Indicates a collection of all callback functions. For details, see [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md).| +| userData | Indicates the pointer to user-specific data. | **Returns** @@ -391,14 +390,14 @@ OH_AVErrCode OH_VideoEncoder_SetParameter (OH_AVCodec * codec, OH_AVFormat * for **Description**
Sets dynamic parameters for a video encoder. This API can be called only after the encoder is started. Incorrect parameter settings may cause encoding failure. -\@syscap SystemCapability.Multimedia.Media.VideoEncoder +@syscap SystemCapability.Multimedia.Media.VideoEncoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | -| format | Indicates the handle to an **OH_AVFormat** instance. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| format | Indicates the handle to an **OH_AVFormat** instance. | **Returns** @@ -416,13 +415,13 @@ OH_AVErrCode OH_VideoEncoder_Start (OH_AVCodec * codec) **Description**
Starts a video encoder. This API can be called only after the encoder is prepared successfully. After being started, the encoder starts to report the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) event. -\@syscap SystemCapability.Multimedia.Media.VideoEncoder +@syscap SystemCapability.Multimedia.Media.VideoEncoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | **Returns** @@ -440,13 +439,13 @@ OH_AVErrCode OH_VideoEncoder_Stop (OH_AVCodec * codec) **Description**
Stops a video encoder. After the encoder is stopped, you can call **Start** to start it again. -\@syscap SystemCapability.Multimedia.Media.VideoEncoder +@syscap SystemCapability.Multimedia.Media.VideoEncoder - **Parameters** +**Parameters** -| Name | Description | + | Name| Description| | -------- | -------- | -| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | **Returns** diff --git a/en/application-dev/reference/native-lib/third_party_napi/napi.md b/en/application-dev/reference/native-lib/third_party_napi/napi.md index d555b935351b675e35777f01b58789650a54de57..8b07cf33cbd8c9a2e82eeb7668ab782330105ce1 100644 --- a/en/application-dev/reference/native-lib/third_party_napi/napi.md +++ b/en/application-dev/reference/native-lib/third_party_napi/napi.md @@ -2,124 +2,134 @@ ## Introduction -Node-API provides APIs to encapsulate JavaScript capabilities as a native plug-in. It is independent of the underlying JavaScript and is maintained as part of Node.js. +Node-API (NAPI) provides APIs to encapsulate JavaScript (JS) capabilities as a native plug-in. It is independent of the underlying JS and is maintained as part of Node.js. ## Supported Capabilities -Node-API eliminates the differences between underlying JavaScript engines and provides a set of stable interfaces. +NAPI eliminates the differences between underlying JS engines and provides a set of stable interfaces. -The OpenHarmony Native API (NAPI) component optimizes the Node-API interface implementation and provides connection to underlying engines such as ArkJS. Currently, some APIs in the [Node-API](https://nodejs.org/docs/v14.9.0/api/n-api.html) standard library are supported. +The OpenHarmony N-API component optimizes the Node-API interface implementation and provides connection to underlying engines such as ArkJS. Currently, some APIs in the [Node-API](https://nodejs.org/docs/v14.9.0/api/n-api.html) standard library are supported. -## Extended Symbols of NAPI +## Extended Symbols of the N-API Component -|Type|Symbol|Remarks| -| --- | --- | --- | -|FUNC|napi_run_script_path|Runs a JavaScript file.| - -**Symbols Exported from the Standard Library** +**Symbols Exported from the NAPI Library** -|Type|Symbol|Remarks| +|Type|Symbol|Description| | --- | --- | --- | -|FUNC|napi_module_register|| -|FUNC|napi_get_last_error_info|| -|FUNC|napi_throw|| -|FUNC|napi_throw_error|| -|FUNC|napi_throw_type_error|| -|FUNC|napi_throw_range_error|| -|FUNC|napi_is_error|| -|FUNC|napi_create_error|| -|FUNC|napi_create_type_error|| -|FUNC|napi_create_range_error|| -|FUNC|napi_get_and_clear_last_exception|| -|FUNC|napi_is_exception_pending|| -|FUNC|napi_fatal_error|| -|FUNC|napi_open_handle_scope|| -|FUNC|napi_close_handle_scope|| -|FUNC|napi_open_escapable_handle_scope|| -|FUNC|napi_close_escapable_handle_scope|| -|FUNC|napi_escape_handle|| -|FUNC|napi_create_reference|| -|FUNC|napi_delete_reference|| -|FUNC|napi_reference_ref|| -|FUNC|napi_reference_unref|| -|FUNC|napi_get_reference_value|| -|FUNC|napi_create_array|| -|FUNC|napi_create_array_with_length|| -|FUNC|napi_create_arraybuffer|| -|FUNC|napi_create_external|| -|FUNC|napi_create_external_arraybuffer|| -|FUNC|napi_create_object|| -|FUNC|napi_create_symbol|| -|FUNC|napi_create_typedarray|| -|FUNC|napi_create_dataview|| -|FUNC|napi_create_int32|| -|FUNC|napi_create_uint32|| -|FUNC|napi_create_int64|| -|FUNC|napi_create_double|| -|FUNC|napi_create_string_latin1|| -|FUNC|napi_create_string_utf8|| -|FUNC|napi_get_array_length|| -|FUNC|napi_get_arraybuffer_info|| -|FUNC|napi_get_prototype|| -|FUNC|napi_get_typedarray_info|| -|FUNC|napi_get_dataview_info|| -|FUNC|napi_get_value_bool|| -|FUNC|napi_get_value_double|| -|FUNC|napi_get_value_external|| -|FUNC|napi_get_value_int32|| -|FUNC|napi_get_value_int64|| -|FUNC|napi_get_value_string_latin1|| -|FUNC|napi_get_value_string_utf8|| -|FUNC|napi_get_value_uint32|| -|FUNC|napi_get_boolean|| -|FUNC|napi_get_global|| -|FUNC|napi_get_null|| -|FUNC|napi_get_undefined|| -|FUNC|napi_coerce_to_bool|| -|FUNC|napi_coerce_to_number|| -|FUNC|napi_coerce_to_object|| -|FUNC|napi_coerce_to_string|| -|FUNC|napi_typeof|| -|FUNC|napi_instanceof|| -|FUNC|napi_is_array|| -|FUNC|napi_is_arraybuffer|| -|FUNC|napi_is_typedarray|| -|FUNC|napi_is_dataview|| -|FUNC|napi_is_date|| -|FUNC|napi_strict_equals|| -|FUNC|napi_get_property_names|| -|FUNC|napi_set_property|| -|FUNC|napi_get_property|| -|FUNC|napi_has_property|| -|FUNC|napi_delete_property|| -|FUNC|napi_has_own_property|| -|FUNC|napi_set_named_property|| -|FUNC|napi_get_named_property|| -|FUNC|napi_has_named_property|| -|FUNC|napi_set_element|| -|FUNC|napi_get_element|| -|FUNC|napi_has_element|| -|FUNC|napi_delete_element|| -|FUNC|napi_define_properties|| -|FUNC|napi_call_function|| -|FUNC|napi_create_function|| -|FUNC|napi_get_cb_info|| -|FUNC|napi_get_new_target|| -|FUNC|napi_new_instance|| -|FUNC|napi_define_class|| -|FUNC|napi_wrap|| -|FUNC|napi_unwrap|| -|FUNC|napi_remove_wrap|| -|FUNC|napi_create_async_work|| -|FUNC|napi_delete_async_work|| -|FUNC|napi_queue_async_work|| -|FUNC|napi_cancel_async_work|| -|FUNC|napi_get_node_version|| -|FUNC|napi_get_version|| -|FUNC|napi_create_promise|| -|FUNC|napi_resolve_deferred|| -|FUNC|napi_reject_deferred|| -|FUNC|napi_is_promise|| -|FUNC|napi_run_script|| -|FUNC|napi_get_uv_event_loop|| \ No newline at end of file +|FUNC|napi_module_register|Registers the NAPI native module.| +|FUNC|napi_get_last_error_info|Obtains the **napi_extended_error_info** structure, which contains the latest error information.| +|FUNC|napi_throw|Throws a JS value.| +|FUNC|napi_throw_error|Throws a JS **Error** with text information.| +|FUNC|napi_throw_type_error|Throws a JS **TypeError** with text information.| +|FUNC|napi_throw_range_error|Throws a JS **RangeError** with text information.| +|FUNC|napi_is_error|Checks whether **napi_value** indicates an error object.| +|FUNC|napi_create_error|Creates and obtains a JS **Error** with text information.| +|FUNC|napi_create_type_error|Creates and obtains a JS **TypeError** with text information.| +|FUNC|napi_create_range_error|Creates and obtains a JS **RangeError** with text information.| +|FUNC|napi_get_and_clear_last_exception|Obtains and clears the latest exception.| +|FUNC|napi_is_exception_pending|Checks whether an exception occurs.| +|FUNC|napi_fatal_error|Raises a fatal error to terminate the process immediately.| +|FUNC|napi_open_handle_scope|Creates a context environment.| +|FUNC|napi_close_handle_scope|Closes the context environment. After the context environment is closed, all references declared in it are closed.| +|FUNC|napi_open_escapable_handle_scope|Creates an escapable handle scope from which the declared values can be returned to the parent scope.| +|FUNC|napi_close_escapable_handle_scope|Closes the escapable handle scope passed in.| +|FUNC|napi_escape_handle|Promotes the handle to the input JS object so that it is valid for the lifespan of its parent scope.| +|FUNC|napi_create_reference|Creates a reference for an **Object** to extend its lifespan. The caller needs to manage the reference lifespan.| +|FUNC|napi_delete_reference|Deletes the reference passed in.| +|FUNC|napi_reference_ref|Increments the reference count for the reference passed in and returns the count.| +|FUNC|napi_reference_unref|Decrements the reference count for the reference passed in and returns the count.| +|FUNC|napi_get_reference_value|Obtains the JS **Object** associated with the reference.| +|FUNC|napi_create_array|Creates and obtains a JS **Array**.| +|FUNC|napi_create_array_with_length|Creates and obtains a JS **Array** of the specified length.| +|FUNC|napi_create_arraybuffer|Creates and obtains a JS **ArrayBuffer** of the specified size.| +|FUNC|napi_create_external|Allocates a JS value with external data.| +|FUNC|napi_create_external_arraybuffer|Allocates a JS **ArrayBuffer** with external data.| +|FUNC|napi_create_object|Creates a default JS **Object**.| +|FUNC|napi_create_symbol|Create a JS **Symbol**.| +|FUNC|napi_create_typedarray|Creates a JS **TypeArray** from an existing **ArrayBuffer**.| +|FUNC|napi_create_dataview|Creates a JS **DataView** from an existing **ArrayBuffer**.| +|FUNC|napi_create_int32|Creates a JS **Number** from C **int32_t** data.| +|FUNC|napi_create_uint32|Creates a JS **Number** from C **uint32_t** data.| +|FUNC|napi_create_int64|Creates a JS **Number** from C **int64_t** data.| +|FUNC|napi_create_double|Creates a JS **Number** from C **double** data.| +|FUNC|napi_create_string_latin1|Creates a JS **String** from an ISO-8859-1-encoded C string.| +|FUNC|napi_create_string_utf8|Creates a JS **String** from a UTF8-encoded C string.| +|FUNC|napi_get_array_length|Obtains the length of an array.| +|FUNC|napi_get_arraybuffer_info|Obtains the underlying data buffer of the **ArrayBuffer** and its length.| +|FUNC|napi_get_prototype|Obtains the prototype of the specified JS **Object**.| +|FUNC|napi_get_typedarray_info|Obtains properties of the specified **TypedArray**.| +|FUNC|napi_get_dataview_info|Obtains properties of the specified **DataView**.| +|FUNC|napi_get_value_bool|Obtains the C Boolean equivalent of the given JS **Boolean**.| +|FUNC|napi_get_value_double|Obtains the C double equivalent of the given JS **Number**.| +|FUNC|napi_get_value_external|Obtains the external data pointer previously passed through **napi_create_external()**.| +|FUNC|napi_get_value_int32|Obtains the C int32 equivalent of the given JS **Number**.| +|FUNC|napi_get_value_int64|Obtains the C int64 equivalent of the given JS **Number**.| +|FUNC|napi_get_value_string_latin1|Obtains the ISO-8859-1-encoded string corresponding to the given JS value.| +|FUNC|napi_get_value_string_utf8|Obtains the UTF8-encoded string corresponding to the given JS value.| +|FUNC|napi_get_value_uint32|Obtains the C uint32 equivalent of the given JS **Number**.| +|FUNC|napi_get_boolean|Obtains the JS Boolean object based on the given C Boolean value.| +|FUNC|napi_get_global|Obtains the **global** object.| +|FUNC|napi_get_null|Obtains the **null** object.| +|FUNC|napi_get_undefined|Obtains the **undefined** object.| +|FUNC|napi_coerce_to_bool|Forcibly converts the given JS value to a JS Boolean value.| +|FUNC|napi_coerce_to_number|Forcibly converts the given JS value to a JS number.| +|FUNC|napi_coerce_to_object|Forcibly converts the given JS value to a JS object.| +|FUNC|napi_coerce_to_string|Forcibly converts the given JS value to a JS string.| +|FUNC|napi_typeof|Obtains the JS type of the given JS value.| +|FUNC|napi_instanceof|Checks whether the given object is an instance of the specified constructor.| +|FUNC|napi_is_array|Checks whether the given JS value is an array.| +|FUNC|napi_is_arraybuffer|Checks whether the given JS value is a **ArrayBuffer**.| +|FUNC|napi_is_typedarray|Checks whether the given JS value is a **TypedArray**.| +|FUNC|napi_is_dataview|Checks whether the given JS value is a **DataView**.| +|FUNC|napi_is_date|Checks whether the given JS value is a JS **Date** object.| +|FUNC|napi_strict_equals|Checks whether two JS values are strictly equal.| +|FUNC|napi_get_property_names|Obtains the names of the enumerable properties of **Object** in an array of strings.| +|FUNC|napi_set_property|Sets a property for the given **Object**.| +|FUNC|napi_get_property|Obtains the requested property of the given **Object**.| +|FUNC|napi_has_property|Checks whether the given **Object** has the specified property.| +|FUNC|napi_delete_property|Deletes the **key** property from the given **Object**.| +|FUNC|napi_has_own_property|Checks whether the given **Object** has the own property named **key**.| +|FUNC|napi_set_named_property|Sets a property with the specified name for the given **Object**.| +|FUNC|napi_get_named_property|Obtains the property with the specified name in the given **Object**.| +|FUNC|napi_has_named_property|Checks whether the given **Object** has the property with the specified name.| +|FUNC|napi_set_element|Sets an element at the specified index of the given **Object**.| +|FUNC|napi_get_element|Obtains the element at the specified index of the given **Object**.| +|FUNC|napi_has_element|Obtains the element if the given **Object** has an element at the specified index.| +|FUNC|napi_delete_element|Deletes the element at the specified index of the given **Object**.| +|FUNC|napi_define_properties|Defines multiple properties for the given **Object**.| +|FUNC|napi_call_function|Calls a JS function in a native method, that is, native call JS.| +|FUNC|napi_create_function|Creates a native method for JS to call.| +|FUNC|napi_get_cb_info|Obtains detailed information about the call, such as the parameters and **this** pointer, from the given callback info.| +|FUNC|napi_get_new_target|Obtains the **new.target** of the constructor call.| +|FUNC|napi_new_instance|Creates an instance based on the given constructor.| +|FUNC|napi_define_class|Defines a JS class corresponding to the C++ class.| +|FUNC|napi_wrap|Wraps a native instance in a JS object.| +|FUNC|napi_unwrap|Obtains the native instance that was previously wrapped in a JS object.| +|FUNC|napi_remove_wrap|Obtains the native instance that was previously wrapped in a JS object and removes the wrapping.| +|FUNC|napi_create_async_work|Creates a work object that executes logic asynchronously.| +|FUNC|napi_delete_async_work|Releases an asynchronous work object.| +|FUNC|napi_queue_async_work|Adds an asynchronous work object to the queue so that it can be scheduled for execution.| +|FUNC|napi_cancel_async_work|Cancels the queued asynchronous work if it has not been started.| +|FUNC|napi_get_node_version|Obtains the current Node-API version.| +|FUNC|napi_get_version|Obtains the latest Node-API version supported when the Node.js runtime.| +|FUNC|napi_create_promise|Creates a deferred object and a JS promise.| +|FUNC|napi_resolve_deferred|Resolves a deferred object that is associated with a JS promise.| +|FUNC|napi_reject_deferred|Rejects a deferred object that is associated with a JS promise.| +|FUNC|napi_is_promise|Checks whether the given JS value is a promise object.| +|FUNC|napi_get_uv_event_loop|Obtains the current libuv loop instance.| +|FUNC|napi_create_threadsafe_function|Creates a thread-safe function.| +|FUNC|napi_get_threadsafe_function_context|Obtains the context of a thread-safe function.| +|FUNC|napi_call_threadsafe_function|Calls a thread-safe function.| +|FUNC|napi_acquire_threadsafe_function|Indicates that a thread starts to use a thread-safe function.| +|FUNC|napi_release_threadsafe_function|Indicates that a thread releases a thread-safe function.| +|FUNC|napi_ref_threadsafe_function|Indicates that the event loop running on the main thread should not exit until the thread-safe function is destroyed.| +|FUNC|napi_unref_threadsafe_function|Indicates that the event loop running on the main thread may exit before the thread-safe function is destroyed.| +|FUNC|napi_create_date|Creates a JS **Date** from C **double** data.| +|FUNC|napi_get_date_value|Obtains the C double equivalent of the given JS **Date**.| +|FUNC|napi_create_bigint_int64|Creates a JS **BigInt** from C **int64** data.| +|FUNC|napi_create_bigint_uint64|Creates a JS **BigInt** from C **uint64** data.| +|FUNC|napi_create_bigint_words|Creates a single JS **BigInt** from a C **uint64** array.| +|FUNC|napi_get_value_bigint_int64|Obtains the C **int64** equivalent of the given JS **BigInt**.| +|FUNC|napi_get_value_bigint_uint64|Obtains the C **uint64** equivalent of the given JS **BigInt**.| +|FUNC|napi_get_value_bigint_words|Obtains information from the given JS **BigInt**, including the sign bit, 64-bit little-endian array, and number of elements in the array.| diff --git a/en/application-dev/reference/syscap-list.md b/en/application-dev/reference/syscap-list.md index 11c2a9d952abc1782ecab5a3ecad8d100e4a7a17..8b14b845fe60bf03adb3fca35c9138a012e99660 100644 --- a/en/application-dev/reference/syscap-list.md +++ b/en/application-dev/reference/syscap-list.md @@ -1349,7 +1349,7 @@ Webview component | Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router | | ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | -| Yes | No | Yes | Yes | Yes | Yes | No | No | +| Yes | No | No | Yes | Yes | No | No | No | ## SystemCapability.Cloud.AAID diff --git a/en/application-dev/security/accesstoken-guidelines.md b/en/application-dev/security/accesstoken-guidelines.md index a006a6ff28fb6d31bc236c11b56505621695930b..93e6b808074f476ab103ee1b43db856d7ab472d6 100644 --- a/en/application-dev/security/accesstoken-guidelines.md +++ b/en/application-dev/security/accesstoken-guidelines.md @@ -2,22 +2,22 @@ ## When to Use -The [Ability Privilege Level (APL)](accesstoken-overview.md#application-apls) of an application can be **normal**, **system_basic**, or **system_core**. The default APL is **normal**. The [permission types](accesstoken-overview.md#permission-types) include **system_grant** and **user_grant**. For details about the permissions for applications, see the [Application Permission List](permission-list.md). +Application permissions are used to prevent unauthorized access to sensitive data or critical functions. The [Ability Privilege Level (APL)](accesstoken-overview.md#application-apls) of an application can be **normal** (default), **system_basic**, or **system_core**. The [permission types](accesstoken-overview.md#permission-types) include **system_grant** and **user_grant**. For details about the permissions for applications, see the [Application Permission List](permission-list.md). This document describes the following operations: - [Declaring Permissions in the Configuration File](#declaring-permissions-in-the-configuration-file) - [Declaring the ACL](#declaring-the-acl) - [Requesting User Authorization](#requesting-user-authorization) -- [Pre-Authorizing user_grant Permissions](#pre-authorizing-user_grant-permissions) +- [Pre-authorizing user_grant Permissions](#pre-authorizing-user_grant-permissions) ## Declaring Permissions in the Configuration File -During the development, you need to declare the permissions required by your application one by one in the project configuration file. The application cannot obtain the permissions that are not declared in the configuration file. OpenHarmony provides two application models: FA model and stage model. For more information, see [Application Models](../application-models/application-model-description.md). The application bundle and configuration file vary with the application model. +The permissions required by an application must be declared one by one in the configuration file of the project. Otherwise, the application cannot obtain the permissions. > **NOTE** > -> The default APL of an application is **normal**. When an application of the **normal** APL needs a permission of the **system_basic** or **system_core** level, you must declare the permission in the configuration file and the [Access Control List (ACL)](#declaring-the-acl). +> If an application of the **normal** APL requires a permission of the **system_basic** or **system_core** level, you must also declare the permission in the [ACL](#declaring-the-acl). The following table describes the fields in the configuration file. @@ -28,7 +28,7 @@ The following table describes the fields in the configuration file. | usedScene | No | Application scenario of the permission.
This parameter is mandatory when a user_grant permission is required.| | abilities | No | Abilities that require the permission. The value is an array.
**Applicable model**: stage| | ability | No | Abilities that require the permission. The value is an array.
**Applicable model**: FA| -| when | No | Time when the permission is used.
Value:
- **inuse**: The permission applies only to a foreground application.
- **always**: The permission applies to both the foreground and background applications.| +| when | No | Time when the permission is required.
Value:
- **inuse**: The permission is required only when the application is in use.
- **always**: The permission is required no matter whether the application is in use.| ### Stage Model @@ -110,7 +110,7 @@ For example, if an application needs to access audio clips of a user and capture "acls":{ "allowed-acls":[ "ohos.permission.WRITE_AUDIO", - "ohos.permission.CAPTURE_SCREEN" + "ohos.permission.CAPTURE_SCREEN" ] } } @@ -118,24 +118,24 @@ For example, if an application needs to access audio clips of a user and capture ## Requesting User Authorization -The permissions for accessing user privacy information or using system abilities (for example, accessing Location or Calendar information or using the camera to take photos or record videos) request user authorization. Before an application that requires a **user_grant** permission is called, a verification is performed to check whether the user has granted the permission to the application. If the user has not granted the permission, a dialog box will be displayed to request user authorization. The following figure shows an example. +User authorization is required when an application needs to access user privacy information (such as Location or Calendar information) or using system abilities (such as the camera ability to take photos or record videos). In this case, the application requires a **user_grant** permission. Before the application accesses the data or using the system ability, a verification is performed to check whether the user has granted the permission to the application. If the user has not granted the permission, a dialog box will be displayed to request user authorization. The following figure shows an example. -**Figure 1** Requesting authorization from a user +**Figure 1** Requesting user authorization ![](figures/permission-read_calendar.png) > **NOTE** > -> Each time before an API protected by a **user_grant** permission is called, **requestPermissionsFromUser()** will be called to request user authorization. After the permission is granted, the user may revoke the authorization in **Settings**. Therefore, the previously granted authorization status cannot be persistent. +> Each time before an API protected by a **user_grant** permission is called, **requestPermissionsFromUser()** will be called to request user authorization. After the permission is granted, the user may revoke the authorization in **Settings**. Therefore, the previous authorization status cannot be persistent. ### Stage Model Example: Apply for the permission for an application to access the Calendar. -1. Declare the **ohos.permission.READ_CALENDAR** permission in the configuration file.
For details, see [Declaring Permissions in the Configuration File](#declaring-permissions-in-the-configuration-file). +1. Declare the **ohos.permission.READ_CALENDAR** permission in the configuration file. For details, see [Declaring Permissions in the Configuration File](#declaring-permissions-in-the-configuration-file). 2. Check whether the user has granted the permission. - Use [checkAccessToken()](../reference/apis/js-apis-abilityAccessCtrl.md#checkaccesstoken9) to check whether the user has granted the permission. If yes, the application can access the Calendar. Otherwise, request authorization from the user. + Use [checkAccessToken()](../reference/apis/js-apis-abilityAccessCtrl.md#checkaccesstoken9) to check whether the user has granted the permission. If yes, the application can access the Calendar. Otherwise, user authorization is required. ```ts import bundleManager from '@ohos.bundle.bundleManager'; @@ -152,14 +152,14 @@ Example: Apply for the permission for an application to access the Calendar. let appInfo: bundleManager.ApplicationInfo = bundleInfo.appInfo; tokenId = appInfo.accessTokenId; } catch (err) { - console.error(`getBundleInfoForSelf failed, code is ${err.code}, message is ${err.message}`); + console.error(`Failed to get bundle info for self. Code is ${err.code}, message is ${err.message}`); } // Check whether the user has granted the permission. try { grantStatus = await atManager.checkAccessToken(tokenId, permission); } catch (err) { - console.error(`checkAccessToken failed, code is ${err.code}, message is ${err.message}`); + console.error(`Failed to check access token. Code is ${err.code}, message is ${err.message}`); } return grantStatus; @@ -214,8 +214,7 @@ Example: Apply for the permission for an application to access the Calendar. } // The authorization is successful. }).catch((err) => { - console.error(`requestPermissionsFromUser failed, code is ${err.code}, message is ${err.message}`); - }) + console.error(`Failed to request permissions from user. Code is ${err.code}, message is ${err.message}`); // ... } @@ -249,7 +248,7 @@ Example: Apply for the permission for an application to access the Calendar. } // The authorization is successful. }).catch((err) => { - console.error(`requestPermissionsFromUser failed, code is ${err.code}, message is ${err.message}`); + console.error(`Failed to request permissions from user. Code is ${err.code}, message is ${err.message}`); }) } @@ -301,14 +300,18 @@ reqPermissions() { }); } ``` -## Pre-Authorizing user_grant Permissions -By default, the **user_grant** permissions must be dynamically authorized by the user through a dialog box. However, if you do not want the user authorization dialog box to display for pre-installed applications, you can pre-authorize the permissions, for example, the **ohos.permission.MICROPHONE** permission, in the [**install_list_permission.json**](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568/preinstall-config/install_list_permissions.json) file. The **install_list_permissions.json** file is in the **/system/etc/app/** directory on a device, and is loaded when the device starts. When the application is installed, the **user_grant** permissions in the file are granted.
The **install_list_permissions.json** file contains the following fields: +## Pre-authorizing user_grant Permissions +By default, the **user_grant** permissions must be dynamically authorized by the user through a dialog box. However, some pre-installed applications may require **user_grant** permissions, for example, the system camera application requires the **ohos.permission.MICROPHONE** permission. In this case, you can pre-authorize **user_grant** permissions for pre-installed applications in the [**install_list_permission.json**](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568/preinstall-config/install_list_permissions.json) file. The **install_list_permissions.json** file is in the **/system/etc/app/** directory on a device, and is loaded when the device starts. When the application is installed, the **user_grant** permissions in the file are granted. + +The **install_list_permissions.json** file contains the following fields: - **bundleName**: bundle name of the application. - **app_signature**: fingerprint information of the application. For details, see **Configuration in install_list_capability.json** in the [Application Privilege Configuration Guide](../../device-dev/subsystems/subsys-app-privilege-config-guide.md). -- **permissions**: **name** specifies the name of the **user_grant** permission to pre-authorize. **userCancellable** specifies whether the user can revoke the pre-authorization. The value **true** means the user can revoke the pre-authorization; the value **false** means the opposite. +- **permissions**: The **name** field specifies the name of the **user_grant** permission to pre-authorize. The **userCancellable** field specifies whether the user can revoke the pre-authorization. The value **true** means the user can revoke the pre-authorization; the value **false** means the opposite. -> **NOTE**
This file is available only for preinstalled applications. +> **NOTE** +> +> The **install_list_permissions.json** file is available only for preinstalled applications. ```json [ diff --git a/en/application-dev/ui/arkui-overview.md b/en/application-dev/ui/arkui-overview.md index 42214f4a140f8aa3d6e0f5de8cd44e58d949f3c8..d89564480f73b4b640d44d7b5d212a8e9f56f85e 100644 --- a/en/application-dev/ui/arkui-overview.md +++ b/en/application-dev/ui/arkui-overview.md @@ -1,58 +1,46 @@ # ArkUI Overview -ArkUI is a UI development framework for building OpenHarmony applications. It provides effortlessly natural UI syntax and UI development infrastructure including UI components, animation mechanisms, and event interaction, to meet the visualized GUI development requirements of application developers. -## Basic Concepts +ArkUI provides a comprehensive infrastructure for UI development of OpenHarmony applications, including simple UI syntax, a diverse array of UI features (components, layouts, animations, and interaction events), and a powerful previewer. -- **Component**: the smallest unit for UI building and display. You build a UI that meets your needs through flexible combinations of components. -- **Page**: the smallest unit for ArkUI application scheduling. You can design multiple pages for your application, manage their files on a per-page basis, and schedule page redirection through [page routing](../reference/apis/js-apis-router.md) APIs, so as to implement decoupling of application functions. +## Basic Concepts -## Key Features +- **UI**: user interface. You can design multiple pages for your application, manage their files on a per-page basis, and schedule page redirection through [routing](arkts-routing.md) APIs, so as to implement decoupling of application functions. -- **UI components**: ArkUI comes with a diverse array of built-in polymorphic components, including basic components (such as text, image, and button), container components with one or more child components, drawing components allowing for customization, and media components that provide video playback capabilities. By being polymorphic, a component provides variant forms to adapt to different types of devices and platforms. +- **Component**: the smallest unit for UI building and display, for example, a list, grid, button, radio button, progress indicator, and text. You build a UI that meets your needs through flexible combinations of components. -- **Flexible layouts**: Creating a responsive UI in ArkUI is easy, with the carefully-designed layout approaches: Besides the basic linear and flexible layouts, you also have access to the advanced list, grid, and column grid layouts as well as the atomic layouts that auto-adapt to screen resolutions. -- **Animation**: Apart from animations embedded in components, ArkUI offers additional animation features: attribute animation, transition animation, and custom animation. +## Two Development Paradigms -- **Drawing**: ArkUI offers advanced drawing capabilities that allow you to draw custom shapes with a range of editors, from images to fill colors and texts. +ArkUI comes with two development paradigms: [ArkTS-based declarative development paradigm](arkts-ui-development-overview.md) (declarative development paradigm for short) and [JS-compatible web-like development paradigm](../ui/ui-js-overview.md) (web-like development paradigm for short). You can choose whichever development paradigm that aligns with your practice. -- **Interaction**: ArkUI allows users to interact with your application UI properly, regardless of the system platform and input device. By default, the UI accepts input from touch gestures, remote controls, keyboards, and mouse devices, with support for event callbacks where you can define interaction logic of your own. +- **Declarative development paradigm**: uses [ArkTS](../quick-start/arkts-get-started.md) – a superset of TypeScript with declarative UI syntax, providing UI drawing capabilities from three dimensions: component, animation, and state management. -- **Platform API channel**: ArkUI provides an API extension mechanism through which platform capabilities are encapsulated to produce JavaScript (JS) APIs in a unified style. +- **Web-like development paradigm**: uses the classical three-stage programming model, in which OpenHarmony Markup Language (HML) is used for building layouts, CSS for defining styles, and JS for adding processing logic. This development paradigm has a low learning curve for frontend web developers, allowing them to quickly transform existing web applications into ArkUI applications. -- **Two development paradigms**: ArkUI comes with two development paradigms: [ArkTS-based declarative development paradigm](./ui-ts-overview.md) (declarative development paradigm for short) and [JS-compatible web-like development paradigm](./ui-js-overview.md) (web-like development paradigm for short). You can choose whichever development paradigm that aligns with your practice. +The declarative development paradigm is a better choice for building new application UIs for the following reasons: - | Development Paradigm | Description | Applicable To | Target Audience | - | -------- | ---------------------------------------- | ---------------- | ------------------- | - | Declarative development paradigm | Uses [ArkTS](../quick-start/arkts-get-started.md) – a superset of TypeScript with declarative UI syntax, providing UI drawing capabilities from three dimensions: component, animation, and status management. The programming mode used is closer to natural semantics. You can intuitively describe the UI without caring about how the framework implements UI drawing and rendering, leading to simplified and efficient development.| Applications involving technological sophistication and teamwork| Mobile application and system application developers| - | Web-like development paradigm| Uses the classical three-stage programming model, in which OpenHarmony Markup Language (HML) is used for building layouts, CSS for defining styles, and JS for adding processing logic. UI components are associated with data through one-way data-binding. This means that when data changes, the UI automatically refreshes with the new data. This development paradigm has a low learning curve for frontend web developers, allowing them to quickly transform existing web applications into ArkUI applications.| Small- and medium-sized applications and service widgets with simple UIs | Frontend web developers | +- **Higher development efficiency**: In the declarative development paradigm, the programming mode used is closer to natural semantics. You can intuitively describe the UI without caring about how the framework implements UI drawing and rendering, leading to simplified and efficient development. -## Framework Structure +- **Higher application performance**: As shown below, the two development paradigms share the UI backend engine and language runtime. However, the declarative development paradigm does not require the JS framework for managing the page DOM. As such, it has more streamlined rendering and update links and less memory usage. -![en-us_image_0000001267647869](figures/en-us_image_0000001267647869.png) +- **Future proof**: The declarative development paradigm will continue to develop as the preferred development paradigm in OpenHarmony, providing increasingly more diverse and powerful capabilities. -As shown above, the two development paradigms share the UI backend engine and language runtime. The UI backend engine implements the six basic capabilities of ArkUI. The declarative development paradigm does not require the JS Framework for managing the page DOM. As such, it has more streamlined rendering and update links and less memory usage. This makes the declarative development paradigm a better choice for building application UIs. + **Figure 1** ArkUI framework -## Relationship Between UI and Ability Framework + ![arkui-framework](figures/arkui-framework.png) -OpenHarmony provides two application models: FA model and stage model. The table below describes the relationship between these two models and the two development paradigms of ArkUI. - **FA Model** +## Development Paradigm Support by Application Type -| Type | UI Development Paradigm | Description | -| ---- | -------- | ---------------------------------------- | -| Application | Web-like development paradigm| UI development: HML, CSS, and JS
Service entries: files with fixed file names, which are **app.ets** (Page ability), **service.ts** (Service ability), and **data.ts** (Data ability)
Service logic: JS and TS| -| | Declarative development paradigm | UI development: ArkTS
Service entries: files with fixed file names, which are **app.ets** (Page ability), **service.ts** (Service ability), and **data.ts** (Data ability)
Service logic: JS and TS| -| Service widget| Web-like development paradigm| UI development: HML, CSS, and JSON (action)
Service entry: **form.ts**
Service logic: JS and TS| -| | Declarative development paradigm | Not supported currently | +The support for development paradigms varies according to the OpenHarmony [application model](../application-models/application-model-composition.md) and page form. For details, see the following table. - **Stage Model** + **Table 1** Supported development paradigms -| Type | UI Development Paradigm | Description | -| ---- | -------- | ---------------------------------------- | -| Application | Web-like development paradigm| Not supported currently | -| | Declarative development paradigm | UI development: ArkTS
Service entries: derived from **ohos.application.Ability**/**ExtensionAbility**
Service logic: TS| -| Service widget| Web-like development paradigm| UI development: HML, CSS, and JSON (action)
Service entries: derived from **FormExtensionAbility**
Service logic: TS| -| | Declarative development paradigm | Not supported currently | +| Application Model | Page Form | Supported Development Paradigm | +| ----------- | -------- | ------------------------ | +| Stage model (recommended)| Application or service page| Declarative development paradigm (recommended) | +| | Widget | Declarative development paradigm (recommended)
Web-like development paradigm| +| FA model | Application or service page| Declarative development paradigm
Web-like development paradigm | +| | Widget | Web-like development paradigm | diff --git a/en/application-dev/ui/figures/arkui-framework.png b/en/application-dev/ui/figures/arkui-framework.png new file mode 100644 index 0000000000000000000000000000000000000000..f49cdd8727a88945e1b5082d0ae81001bee3a2ce Binary files /dev/null and b/en/application-dev/ui/figures/arkui-framework.png differ diff --git a/en/application-dev/ui/figures/en-us_image_0000001267647869.png b/en/application-dev/ui/figures/en-us_image_0000001267647869.png deleted file mode 100644 index 91179e770c418c02c3751111b14bbea637b48b1c..0000000000000000000000000000000000000000 Binary files a/en/application-dev/ui/figures/en-us_image_0000001267647869.png and /dev/null differ diff --git a/en/application-dev/ui/figures/layout-element-omposition.png b/en/application-dev/ui/figures/layout-element-omposition.png index 03b69e006b2b8c9509056a8de65b4e2b0b37d834..b4bc30b110f51e8ceea3e47bbf279a007d96a5b3 100644 Binary files a/en/application-dev/ui/figures/layout-element-omposition.png and b/en/application-dev/ui/figures/layout-element-omposition.png differ diff --git a/en/application-dev/website.md b/en/application-dev/website.md index f1cde6dfbf47e5e4f681b37b18bb75b9868a598b..c6274ffeb0a2f423c5dee149ef1fbe27750c2888 100644 --- a/en/application-dev/website.md +++ b/en/application-dev/website.md @@ -1211,7 +1211,7 @@ - [@ohos.systemTimer (System Timer)](reference/apis/js-apis-system-timer.md) - [@ohos.wallpaper (Wallpaper)](reference/apis/js-apis-wallpaper.md) - [@ohos.web.webview (Webview)](reference/apis/js-apis-webview.md) - - [console (Log)](reference/apis/js-apis-logs.md) + - [Console](reference/apis/js-apis-logs.md) - [Timer](reference/apis/js-apis-timer.md) - application - [AccessibilityExtensionContext](reference/apis/js-apis-inner-application-accessibilityExtensionContext.md) diff --git a/en/device-dev/subsystems/subsys-app-privilege-config-guide.md b/en/device-dev/subsystems/subsys-app-privilege-config-guide.md index 665652b23e1832716680e14d5552c66aec744062..124e0e884e9b0436a936e7930911cae16e98dcd0 100644 --- a/en/device-dev/subsystems/subsys-app-privilege-config-guide.md +++ b/en/device-dev/subsystems/subsys-app-privilege-config-guide.md @@ -4,7 +4,9 @@ Application privileges are high-level capabilities of an application, for exampl OpenHarmony provides both general and device-specific application privileges. The latter can be configured by device vendors for applications on different devices. -Note: To avoid user dissatisfaction or even infringement, do not abuse application privileges. +> **NOTE** +> - To avoid user dissatisfaction or even infringement, do not abuse application privileges. +> - The method of changing the application's APL in its profile applies only to the applications or services in debug mode. For a commercial application, apply for a release certificate and profile in the corresponding application market. ## General Application Privileges @@ -15,18 +17,18 @@ General application privileges are privileges available to applications on all t | Privilege| Description | | ---------------- | ------------------------------------------------------------ | | AllowAppDataNotCleared | Allows application data not to be deleted.| -| AllowAppMultiProcess | Allows the application to run on multiple processes.| +| AllowAppMultiProcess | Allows an application to run on multiple processes.| | AllowAppDesktopIconHide | Allows the application icon to be hidden from the home screen.| | AllowAbilityPriorityQueried | Allows an ability to configure and query the priority. | | AllowAbilityExcludeFromMissions | Allows an ability to be hidden in the mission stack.| -| AllowAppUsePrivilegeExtension | Allows the application to use Service Extension and Data Extension abilities.| +| AllowAppUsePrivilegeExtension | Allows an application to use ServiceExtensionAbilities and DataExtensionAbilities.| | AllowFormVisibleNotify | Allows a widget to be visible on the home screen.| -### Configuration +### How to Configure -1. In the [HarmonyAppProvision file](../../application-dev/security/app-provision-structure.md), configure the general privileges in the **app-privilege-capabilities** field. -2. Use the signing tool hapsigner to sign the HarmonyAppProvision file and generate a **.p7b** file. -3. Use the **.p7b** file to sign the HAP. +1. Add the **app-privilege-capabilities** field to the [**HarmonyAppProvision** file](../../application-dev/security/app-provision-structure.md) to configure general privilege capabilities as required. +2. Use the hapsigner tool to sign the **HarmonyAppProvision** file and generate a .p7b file. +3. Use the .p7b file to sign the HAP. Reference: [hapsigner](https://gitee.com/openharmony/developtools_hapsigner#README.md) @@ -41,7 +43,7 @@ Reference: [hapsigner](https://gitee.com/openharmony/developtools_hapsigner#READ ... }, "issuer": "pki_internal", - "app-privilege-capabilities": ["AllowAppDataNotCleared", "AllowAppDesktopIconHide"] // The application data cannot be deleted, and icons can be hidden on the home screen. + "app-privilege-capabilities": ["AllowAppDataNotCleared", "AllowAppDesktopIconHide"] // The application data cannot be deleted, and the application icon can be hidden on the home screen. } ``` @@ -55,20 +57,20 @@ In addition to general application privileges, device vendors can define device- | Privilege | Type | Default Value| Description | | --------------------- | -------- | ------ | ------------------------------------------------- | -| removable | bool | true | Allows the application to be uninstalled. This privilege takes effect only for preset applications. | -| keepAlive | bool | false | Allows the application to keep running in the background. | -| singleton | bool | false | Allows the application to be installed for a single user (U0). | -| allowCommonEvent | string[] | - | Allows the application to be started by a static broadcast. | -| associatedWakeUp | bool | false | Allows the application in the FA model to be woken up by an associated application. | -| runningResourcesApply | bool | false | Allows the application to request running resources, such as the CPU, event notifications, and Bluetooth.| +| removable | bool | true | Allows an application to be uninstalled. This privilege takes effect only for preset applications. | +| keepAlive | bool | false | Allows an application to keep running in the background. | +| singleton | bool | false | Allows an application to be installed for a single user (User 0). | +| allowCommonEvent | string[] | - | Allows an application to be started by a static broadcast. | +| associatedWakeUp | bool | false | Allows an application in the FA model to be woken up by an associated application. | +| runningResourcesApply | bool | false | Allows an application to request running resources, such as the CPU, event notifications, and Bluetooth.| -### Configuration +### How to Configure -Configure the required privileges in [configuration files](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568/preinstall-config). +Configure the required privileges in the [configuration file](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568/preinstall-config). ### Example -#### Configuration in **install_list_capability.json** +#### Configuration in install_list_capability.json ``` { @@ -79,7 +81,7 @@ Configure the required privileges in [configuration files](https://gitee.com/ope "keepAlive": true, // The application is running in the background. "runningResourcesApply": true, // The application can apply for running resources such as the CPU, event notifications, and Bluetooth. "associatedWakeUp": true, // The application in the FA model can be woken up by an associated application. - "app_signature": ["8E93863FC32EE238060BF69A9B37E2608FFFB21F93C862DD511CBAC"], // The settings take effect only when the configured certificate fingerprint is the same as the HAP certificate fingerprint. + "app_signature": ["8E93863FC32EE238060BF69A9B37E2608FFFB21F93C862DD511CBAC"], // The setting takes effect only when the configured certificate fingerprint is the same as the HAP certificate fingerprint. "allowCommonEvent": ["usual.event.SCREEN_ON", "usual.event.THERMAL_LEVEL_CHANGED"] }, } @@ -87,66 +89,62 @@ Configure the required privileges in [configuration files](https://gitee.com/ope **Obtaining the Certificate Fingerprint** -1. Create the **profile.cer** file, and copy the certificate content under the **distribution-certificate** field of the HarmonyAppProvision file to the **profile.cer** file. +1. Create the **profile.cer** file, and copy the certificate content under the **distribution-certificate** field of the **HarmonyAppProvision** file to the **profile.cer** file. Example: - ``` - { - ... - "bundle-info": { - "distribution-certificate": "-----BEGIN CERTIFICATE----\nMIICMzCCAbegAwIBAgIEaOC/zDAMBggqhkjOPQQDAwUAMk..." / Certificate content. - ... - } - ... - } - ``` - - +``` +{ + ... + "bundle-info": { + "distribution-certificate": "-----BEGIN CERTIFICATE----\nMIICMzCCAbegAwIBAgIEaOC/zDAMBggqhkjOPQQDAwUAMk..." / Certificate content. + ... + } + ... +} +``` 2. Apply line breaks in the **profile.cer** content and remove the newline characters. Example: - ``` - -----BEGIN CERTIFICATE----- - MIICMzCCAbegAwIBAgIEaOC/zDAMBggqhkjOPQQDAwUAMGMxCzAJBgNVBAYTAkNO - MRQwEgYDVQQKEwtPcGVuSGFybW9ueTEZMBcGA1UECxMQT3Blbkhhcm1vbnkgVGVh - bTEjMCEGA1UEAxMaT3Blbkhhcm1vbnkgQXBwbGljYXRpb24gQ0EwHhcNMjEwMjAy - MTIxOTMxWhcNNDkxMjMxMTIxOTMxWjBoMQswCQYDVQQGEwJDTjEUMBIGA1UEChML - T3Blbkhhcm1vbnkxGTAXBgNVBAsTEE9wZW5IYXJtb255IFRlYW0xKDAmBgNVBAMT - H09wZW5IYXJtb255IEFwcGxpY2F0aW9uIFJlbGVhc2UwWTATBgcqhkjOPQIBBggq - hkjOPQMBBwNCAATbYOCQQpW5fdkYHN45v0X3AHax12jPBdEDosFRIZ1eXmxOYzSG - JwMfsHhUU90E8lI0TXYZnNmgM1sovubeQqATo1IwUDAfBgNVHSMEGDAWgBTbhrci - FtULoUu33SV7ufEFfaItRzAOBgNVHQ8BAf8EBAMCB4AwHQYDVR0OBBYEFPtxruhl - cRBQsJdwcZqLu9oNUVgaMAwGCCqGSM49BAMDBQADaAAwZQIxAJta0PQ2p4DIu/ps - LMdLCDgQ5UH1l0B4PGhBlMgdi2zf8nk9spazEQI/0XNwpft8QAIwHSuA2WelVi/o - zAlF08DnbJrOOtOnQq5wHOPlDYB4OtUzOYJk9scotrEnJxJzGsh/ - -----END CERTIFICATE----- - ``` - - - -3. Use keytool to print the certificate fingerprint. +``` +-----BEGIN CERTIFICATE----- +MIICMzCCAbegAwIBAgIEaOC/zDAMBggqhkjOPQQDAwUAMGMxCzAJBgNVBAYTAkNO +MRQwEgYDVQQKEwtPcGVuSGFybW9ueTEZMBcGA1UECxMQT3Blbkhhcm1vbnkgVGVh +bTEjMCEGA1UEAxMaT3Blbkhhcm1vbnkgQXBwbGljYXRpb24gQ0EwHhcNMjEwMjAy +MTIxOTMxWhcNNDkxMjMxMTIxOTMxWjBoMQswCQYDVQQGEwJDTjEUMBIGA1UEChML +T3Blbkhhcm1vbnkxGTAXBgNVBAsTEE9wZW5IYXJtb255IFRlYW0xKDAmBgNVBAMT +H09wZW5IYXJtb255IEFwcGxpY2F0aW9uIFJlbGVhc2UwWTATBgcqhkjOPQIBBggq +hkjOPQMBBwNCAATbYOCQQpW5fdkYHN45v0X3AHax12jPBdEDosFRIZ1eXmxOYzSG +JwMfsHhUU90E8lI0TXYZnNmgM1sovubeQqATo1IwUDAfBgNVHSMEGDAWgBTbhrci +FtULoUu33SV7ufEFfaItRzAOBgNVHQ8BAf8EBAMCB4AwHQYDVR0OBBYEFPtxruhl +cRBQsJdwcZqLu9oNUVgaMAwGCCqGSM49BAMDBQADaAAwZQIxAJta0PQ2p4DIu/ps +LMdLCDgQ5UH1l0B4PGhBlMgdi2zf8nk9spazEQI/0XNwpft8QAIwHSuA2WelVi/o +zAlF08DnbJrOOtOnQq5wHOPlDYB4OtUzOYJk9scotrEnJxJzGsh/ +-----END CERTIFICATE----- +``` + +3. Use keytool to obtain the certificate fingerprint. Example: - ``` - keytool -printcert -file profile.cer - result: - Issued To: CN=OpenHarmony Application Release, OU=OpenHarmony Team, O=OpenHarmony, C=CN - Issued By: CN=OpenHarmony Application CA, OU=OpenHarmony Team, O=OpenHarmony, C=CN - SN: 68e0bfcc - Valid From: Tue Feb 02 20:19:31 CST 2021, Valid To: Fri Dec 31 20:19:31 CST 2049 - Fingerprints: - SHA1 fingerprint: E3:E8:7C:65:B8:1D:02:52:24:6A:06:A4:3C:4A:02:39:19:92:D1:F5 - SHA256 fingerprint: 8E:93:86:3F:C3:2E:E2:38:06:0B:F6:9A:9B:37:E2:60:8F:FF:B2:1F:93:C8:62:DD:51:1C:BA:C9:F3:00:24:B5 // After the colons are removed, the fingerprint is 8E93863FC32EE238060BF69A9B37E2608FFFB21F93C862DD511CBAC9F30024B5. - ... - ``` - - - -#### Configuration in **install_list.json** +``` +keytool -printcert -file profile.cer +result: +Issued To: CN=OpenHarmony Application Release, OU=OpenHarmony Team, O=OpenHarmony, C=CN +Issued By: CN=OpenHarmony Application CA, OU=OpenHarmony Team, O=OpenHarmony, C=CN +SN: 68e0bfcc +Valid From: Tue Feb 02 20:19:31 CST 2021, **Valid To**: Fri Dec 31 20:19:31 CST 2049 +Fingerprints: + SHA1 fingerprint: E3:E8:7C:65:B8:1D:02:52:24:6A:06:A4:3C:4A:02:39:19:92:D1:F5 + SHA256 fingerprint: 8E:93:86:3F:C3:2E:E2:38:06:0B:F6:9A:9B:37:E2:60:8F:FF:B2:1F:93:C8:62:DD:51:1C:BA:C9:F3:00:24:B5 // After the colons are removed, the fingerprint is 8E93863FC32EE238060BF69A9B37E2608FFFB21F93C862DD511CBAC9F30024B5. +... +``` + + + +#### Configuration in install_list.json ``` { diff --git a/en/readme/arkui.md b/en/readme/arkui.md index b4c8f0ef37ae2c3d86d30eb68284f53f73ca1472..9959f7510e5ba437d0e084e887c26d5d38b6fb36 100644 --- a/en/readme/arkui.md +++ b/en/readme/arkui.md @@ -2,11 +2,11 @@ ## Introduction -ArkUI is a UI development framework that provides what you'll need to develop application UIs in OpenHarmony, including UI components, animations, drawing, interaction events, and JavaScript API extension mechanisms. ArkUI comes with two development paradigms: eTS-based declarative development paradigm (declarative development paradigm for short) and JavaScript-compatible web-like development paradigm (web-like development paradigm for short). +ArkUI is a UI development framework that provides what you'll need to develop application UIs in OpenHarmony, including UI components, animations, drawing, interaction events, and JavaScript API extension mechanisms. ArkUI comes with two development paradigms: ArkTS-based declarative development paradigm (declarative development paradigm for short) and JavaScript-compatible web-like development paradigm (web-like development paradigm for short). **Framework Structure** -![en-us_image_0000001267647869](../application-dev/ui/figures/en-us_image_0000001267647869.png) +![en-us_image_0000001183709904](../application-dev/ui/figures/arkui-framework.png) As shown above, the two development paradigms share the UI backend engine and language runtime. The UI backend engine implements the six basic capabilities of ArkUI. The declarative development paradigm does not require the JS Framework for managing the page DOM. As such, it has more streamlined rendering and update links and less memory usage. This makes the declarative development paradigm a better choice for building application UIs. diff --git a/en/readme/programming-language-runtime.md b/en/readme/programming-language-runtime.md index e9dc742bcc67be347e516b61837bf94bf67172e9..fcdf06b45a43ea8f72db2af92b15b5d6463893e6 100644 --- a/en/readme/programming-language-runtime.md +++ b/en/readme/programming-language-runtime.md @@ -36,10 +36,6 @@ Basic language capabilities are supported through library files. Some capabiliti The following list shows the repositories of third-party software and precompilation toolchains that are referenced: -[/third\_party/boost](https://gitee.com/openharmony/third_party_boost) - -[/third\_party/quickjs](https://gitee.com/openharmony/third_party_quickjs) - [/third\_party/jerryscript](https://gitee.com/openharmony/third_party_jerryscript) [/third\_party/mingw-w64](https://gitee.com/openharmony/third_party_mingw-w64) \ No newline at end of file diff --git a/en/release-notes/OpenHarmony-v3.1-beta.md b/en/release-notes/OpenHarmony-v3.1-beta.md index d31a28f05ea1b7017f59457573d77cc27fbe4482..cf7bdfe10854ac9c05850f934e9526b110f11d11 100644 --- a/en/release-notes/OpenHarmony-v3.1-beta.md +++ b/en/release-notes/OpenHarmony-v3.1-beta.md @@ -181,12 +181,9 @@ For details about the adaptation status, see [SIG_DevBoard](https://gitee.com/op | [Synced Sketchpad (ArkTS)](https://gitee.com/openharmony/codelabs/tree/master/Distributed/DistributeDatabaseDrawEts)| This codelab shows how to implement synchronous writing and interaction between multiple devices based on the distributed feature.| ArkTS | | [Distributed Database](https://gitee.com/openharmony/codelabs/tree/master/Data/JsDistributedData)| This codelab shows how to use the Distributed Data Service APIs to facilitate consistent data access between devices.| JS | | [Relational Database](https://gitee.com/openharmony/codelabs/tree/master/Data/JSRelationshipData)| This codelab shows how to quickly develop database-related application services based on the relational database and data management capability.| JS | -| [Simplified Declarative UI Paradigm (ArkTS)](https://gitee.com/openharmony/codelabs/tree/master/ETSUI/SimpleGalleryEts) | This codelab shows how to implement a gallery app based on OpenHarmony ArkUI components. | ArkTS | -| [One-Time Development for Multi-device Deployment (ArkTS)](https://gitee.com/openharmony/codelabs/tree/master/ETSUI/Multi_device) | This codelab shows how to implement one-time layout development for multi-device deployment based on OpenHarmony ArkTS UI components. | ArkTS | | [Shopping (ArkTS)](https://gitee.com/openharmony/codelabs/tree/master/ETSUI/ShoppingEts) | This codelab shows how to implement a shopping app based on OpenHarmony ArkTS UI components. | ArkTS | | [Transition Animation (ArkTS)](https://gitee.com/openharmony/codelabs/tree/master/ETSUI/TransitionAnimation) | This codelab shows how to implement page transition, component transition, and transition of shared elements based on OpenHarmony ArkUI components. | ArkTS | | [slider Usage (ArkTS)](https://gitee.com/openharmony/codelabs/tree/master/ETSUI/SliderExample) | This codelab shows how to use the OpenHarmony ArkUI component **\** to implement the animation effect when users adjust the size and speed of the windmill. | ArkTS | -| [Liquid Layout (ArkTS)](https://gitee.com/openharmony/codelabs/tree/master/ETSUI/FlowLayoutEts) | This codelab shows how to implement the liquid layout based on the OpenHarmony ArkTS UI components. | ArkTS | | [Dialog Box (ArkTS)](https://gitee.com/openharmony/codelabs/tree/master/ETSUI/CustomDialogEts) | This codelab shows how to implement an alert dialog box and custom dialog box based on OpenHarmony ArkTS UI components. | ArkTS | diff --git a/en/release-notes/OpenHarmony-v3.1-release.md b/en/release-notes/OpenHarmony-v3.1-release.md index bba0edfaf38f2a6a90e35e5d4a0dc96cd0fe5785..3499f018f7c3b4b996aa3775288ac2460c20ab9c 100644 --- a/en/release-notes/OpenHarmony-v3.1-release.md +++ b/en/release-notes/OpenHarmony-v3.1-release.md @@ -189,7 +189,7 @@ This version has the following updates to OpenHarmony 3.1 Beta. For details, see the following: -*[API Differences](api-diff/v3.1-Release/Readme-EN.md)* +*[API Differences](api-change/v3.1-Release/Readme-EN.md)* ### Chip and Development Board Adaptation @@ -237,7 +237,6 @@ For more information, visit [Samples](https://gitee.com/openharmony/app_samples) | [Audio Recording](https://gitee.com/openharmony/codelabs/tree/master/Media/Audio_OH_ETS)| This codelab shows how to use **AudioRecorder** to record an audio file and use **AudioPlayer** to play the recorded audio.| ArkTS | | [Notepad](https://gitee.com/openharmony/codelabs/tree/master/Data/NotePad_OH_ETS)| This codelab shows how to develop a notepad in ArkTS. You can create, delete, and favorite notes, and use the lightweight database to store data persistently. | ArkTS | | [Distributed Mail Editing](https://gitee.com/openharmony/codelabs/tree/master/Distributed/OHMailETS)| This codelab shows how to develop the distributed email editing function. By leveraging the distributed capabilities, a remote device in the same LAN and with the same login account can be started, and email editing can be continued on the remote device.| ArkTS | -| [Third-party Library](https://gitee.com/openharmony/codelabs/tree/master/ThirdPartyComponents/VCardDemo)| This codelab shows how to use vcard, a third-party library used in OpenHarmony to write and read contact data in a specified format (file with the extension name **vcard**).| ArkTS | ## Resolved Issues diff --git a/en/release-notes/changelogs/v3.2-release/Readme-EN.md b/en/release-notes/changelogs/v3.2-release/Readme-EN.md index 340e3f1e7826670138645e5e658b8aa387ac270e..5f58f851ac1b397530a0b4fc96256232eb22d8e7 100644 --- a/en/release-notes/changelogs/v3.2-release/Readme-EN.md +++ b/en/release-notes/changelogs/v3.2-release/Readme-EN.md @@ -1,8 +1,13 @@ # Readme -- [Ability framework](changelogs-ability.md) -- [Bundle manager subsystem](changelogs-bundlemanager.md) -- [Resource scheduler subsystem](changelogs-resourceschedule.md) -- [Telephony subsystem](changelogs-telephony.md) -- [Util subsystem](changelogs-util.md) +- [Ability Framework](changelogs-ability.md) +- [ArkUI](changelogs-arkui.md) +- [Bundle Manager Subsystem](changelogs-bundlemanager.md) +- [Input Method Framework](changelogs-imf.md) +- [Resource Scheduler Subsystem](changelogs-resourceschedule.md) +- [Theme Framework Subsystem - Screenlock](changelogs-screenlock.md) +- [Telephony Subsystem](changelogs-telephony.md) +- [Util Subsystem](changelogs-util.md) +- [Theme Framework Subsystem - Wallpaper](changelogs-wallpaper.md) +- [Web Subsystem](changelogs-web.md) diff --git a/en/release-notes/changelogs/v3.2-release/changelogs-arkui.md b/en/release-notes/changelogs/v3.2-release/changelogs-arkui.md new file mode 100644 index 0000000000000000000000000000000000000000..0a2bf8673fefe00b6736d5cd299e24e5f5acddf2 --- /dev/null +++ b/en/release-notes/changelogs/v3.2-release/changelogs-arkui.md @@ -0,0 +1,308 @@ +# ArkUI Subsystem Changelog + +## cl.arkui.1 Return Value Type Change of getInspectorTree + +**Change Impact** + +The code that uses the **getInspectorTree** API in versions earlier than OpenHarmony 3.2.10.7 must be adapted. + +**Key API/Component Changes** + +The return value of the **getInspectorTree** API is changed from the string type to the Object type. + +**Adaptation Guide** + +Adapt the code that takes the return value of **getInspectorTree** as a string.The sample code is as follows: + +- Before change: + +```typescript +console.info(getInspectorTree()) +``` + +- After change: + +```typescript +console.info(JSON.stringify(getInspectorTree())) +``` + +## cl.arkui.2 Deprecation the forceRebuild Attribute of \ + +**Change Impact** + +None. The attribute has no effect. + +**Key API/Component Changes** + +Deprecate the **forceRebuild** attribute of the **\** component. + +**Adaptation Guide** + +Delete the code that uses the **forceRebuild** attribute. This will not affect the functionality of the **\** component. + +## cl.arkui.3 Plugin Module API Changes + + +### 1. API Change in the **PluginComponentTemplate** Module + +Renamed the **ability** parameter **bundleName** to more clearly indicate the intended meaning. + +You need to adapt your application. + + + +**Change Impact** + +The application developed based on earlier versions must be adapted to the change. Otherwise, build errors will occur. + + + +**Key API/Component Changes** + +- Involved APIs: + + interface PluginComponentTemplate { + source: string; + bundleName: string; + } + + interface PluginComponentInterface { + (value: { template: PluginComponentTemplate; data: any }): PluginComponentAttribute; +} + +- Before change: + +```js + interface PluginComponentTemplate { source: string; ability: string; } + interface PluginComponentInterface { + (value: { template: PluginComponentTemplate; data: any }): PluginComponentAttribute; + } +``` + +- After change: + +```js + interface PluginComponentTemplate { source: string; bundleName: string; } + interface PluginComponentInterface { + (value: { template: PluginComponentTemplate; data: any }): PluginComponentAttribute; + } +``` + +**Adaptation Guide** + +Use the new API. The sample code is as follows: + +- Before change: +```js +PluginComponent({ + template: { source: 'plugincomponent1', ability: 'com.example.plugin' }, + data: { 'countDownStartValue': 'new countDownStartValue' } +}).size({ width: 500, height: 100 }) +``` + +- After change: +```js +PluginComponent({ + template: { source: 'plugincomponent1', bundleName: 'com.example.plugin' }, + data: { 'countDownStartValue': 'new countDownStartValue' } +}).size({ width: 500, height: 100 }) +``` + +### 2. API Change in the **pluginComponentManager** Module + +Renamed the **want** parameter **target** to more clearly indicate the intended meaning. + +You need to adapt your application. + + + +**Change Impact** + +The application developed based on earlier versions must be adapted to the change. Otherwise, alarms will arise. Though the build may be successful, the API will not work as intended. + + + +**Key API/Component Changes** + +- Involved APIs: + + interface PushParameterForStage { + owner: Want; + target: Want; + name: string; + data: KVObject; + extraData: KVObject; + jsonPath?: string; + } + + function push(param: PushParameterForStage, callback: AsyncCallback\): void; + + interface RequestParameterForStage { + owner: Want; + target: Want; + name: string; + data: KVObject; + jsonPath?: string; + } + + function request(param: RequestParameterForStage, callback: AsyncCallback\): void; + +- Before change: + +```js + interface PushParameterForStage { + owner: Want; + want: Want; + name: string; + data: KVObject; + extraData: KVObject; + jsonPath?: string; + } + + function push(param: PushParameterForStage, callback: AsyncCallback): void; + + interface RequestParameterForStage { + owner: Want; + want: Want; + name: string; + data: KVObject; + jsonPath?: string; + } + + function request(param: RequestParameterForStage, callback: AsyncCallback): void; +``` + +- After change: + +```js + interface PushParameterForStage { + owner: Want; + target: Want; + name: string; + data: KVObject; + extraData: KVObject; + jsonPath?: string; + } + + function push(param: PushParameterForStage, callback: AsyncCallback): void; + + interface RequestParameterForStage { + owner: Want; + target: Want; + name: string; + data: KVObject; + jsonPath?: string; + } + + function request(param: RequestParameterForStage, callback: AsyncCallback): void; +``` + +**Adaptation Guide** + +Use the new API. The sample code is as follows: + +- Before change: +```js +import pluginComponentManager from '@ohos.pluginComponent' + +pluginComponentManager.push({ + owner:{ + bundleName:"com.example.provider", + abilityName:"com.example.provider.MainAbility" + }, + want: { + bundleName: "com.example.provider", + abilityName: "com.example.provider.MainAbility", + }, + name: "ets/pages/plugin2.js", + data: { + "js": "ets/pages/plugin.js", + "key_1": 1111, + }, + extraData: { + "extra_str": "this is push event" + }, + jsonPath: "", + }, + (err, data) => { + console.log("push_callback:err: " ,JSON.stringify(err)); + console.log("push_callback:data: " , JSON.stringify(data)); + console.log("push_callback: push ok!"); + } +) + +pluginComponentManager.request({ + owner:{ + bundleName:"com.example.provider", + abilityName:"com.example.provider.MainAbility" + }, + want: { + bundleName: "com.example.provider", + abilityName: "ets/pages/plugin2.js", + }, + name: "plugintemplate", + data: { + "key_1": " myapplication plugin component test", + "key_2": 123456 + }, + jsonPath: "", +}, + (err, data) => { + console.log("request_callback: componentTemplate.ability=" + data.componentTemplate.ability) + console.log("request_callback: componentTemplate.source=" + data.componentTemplate.source) + } +) +``` + +- After change: +```js +import pluginComponentManager from '@ohos.pluginComponent' + +pluginComponentManager.push({ + owner:{ + bundleName:"com.example.provider", + abilityName:"com.example.provider.MainAbility" + }, + target: { + bundleName: "com.example.provider", + abilityName: "com.example.provider.MainAbility", + }, + name: "ets/pages/plugin2.js", + data: { + "js": "ets/pages/plugin.js", + "key_1": 1111, + }, + extraData: { + "extra_str": "this is push event" + }, + jsonPath: "", + }, + (err, data) => { + console.log("push_callback:err: " ,JSON.stringify(err)); + console.log("push_callback:data: " , JSON.stringify(data)); + console.log("push_callback: push ok!"); + } +) + +pluginComponentManager.request({ + owner:{ + bundleName:"com.example.provider", + abilityName:"com.example.provider.MainAbility" + }, + target: { + bundleName: "com.example.provider", + abilityName: "ets/pages/plugin2.js", + }, + name: "plugintemplate", + data: { + "key_1": " myapplication plugin component test", + "key_2": 123456 + }, + jsonPath: "", +}, + (err, data) => { + console.log("request_callback: componentTemplate.ability=" + data.componentTemplate.ability) + console.log("request_callback: componentTemplate.source=" + data.componentTemplate.source) + } +) +``` diff --git a/en/release-notes/changelogs/v3.2-release/changelogs-imf.md b/en/release-notes/changelogs/v3.2-release/changelogs-imf.md new file mode 100644 index 0000000000000000000000000000000000000000..f158d99d9a0023c67ad982fc6b687563121f4dac --- /dev/null +++ b/en/release-notes/changelogs/v3.2-release/changelogs-imf.md @@ -0,0 +1,19 @@ +# Input Method Framework Subsystem – Input Method Framework Service Changelog + + +## @ohos.InputMethodSubtype Change of name, label, and id +Changed the **name**, **label**, and **id** attributes since API version 9. + +**Change Impact** + +Applications must be adapted to the following changes. + +| Name| Before Change| After Change| +| -------- | -------- | -------- | +| label | (1) Value: ID of the input method subtype.| (1) Value: Label of the input method subtype.| +| name | (1) Description: Name of the input method subtype. (2) Value: Label of the input method subtype.| (1) Description: Bundle name of the input method; (2) Value: Bundle name of the input method.| +| id | (1) Value: Bundle name of the input method.| (1) Value: ID of the input method subtype.| + +**Adaptation Guide** + +Update the code to adapt to the preceding changes. diff --git a/en/release-notes/changelogs/v3.2-release/changelogs-screenlock.md b/en/release-notes/changelogs/v3.2-release/changelogs-screenlock.md new file mode 100644 index 0000000000000000000000000000000000000000..deeaac319aecfd4ba2824b8f23370d6fe2601adc --- /dev/null +++ b/en/release-notes/changelogs/v3.2-release/changelogs-screenlock.md @@ -0,0 +1,157 @@ +# Theme Framework Subsystem – Screenlock Management Service Changelog + + +## cl.screenlock.1 Permission Change of isLocked and unlock +Changed the **isLocked** and **unlock** APIs to system APIs since API version 9. + +You need to adapt your application based on the following information. + +**Change Impact** + +The JS API needs to be adapted for applications developed based on earlier versions. Otherwise, relevant functions will be affected. + +- Involved APIs: + +```js + function isLocked(): boolean; + function unlock(callback: AsyncCallback): void; + function unlock():Promise; +``` + +- Before change: + +```js + * Checks whether the screen is currently locked. + * + * @returns Returns {@code true} if the screen is currently locked; returns {@code false} otherwise. + * @syscap SystemCapability.MiscServices.ScreenLock + * @since 9 + */ + function isLocked(): boolean; + + /** + * Unlock the screen. + * + * @returns Returns {@code true} if the screen is unlocked successfully; returns {@code false} otherwise. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 202 - permission verification failed, application which is not a system application uses system API. + * @throws {BusinessError} 13200002 - the screenlock management service is abnormal. + * @syscap SystemCapability.MiscServices.ScreenLock + * @systemapi Hide this for inner system use. + * @since 9 + */ + function unlock(callback: AsyncCallback): void; + + /** + * Unlock the screen. + * + * @returns Returns {@code true} if the screen is unlocked successfully; returns {@code false} otherwise. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 202 - permission verification failed, application which is not a system application uses system API. + * @throws {BusinessError} 13200002 - the screenlock management service is abnormal. + * @syscap SystemCapability.MiscServices.ScreenLock + * @systemapi Hide this for inner system use. + * @since 9 + */ + function unlock():Promise; +``` + +- After change: + +```js + * Checks whether the screen is currently locked. + * + * @returns Returns {@code true} if the screen is currently locked; returns {@code false} otherwise. + * @throws {BusinessError} 202 - permission verification failed, application which is not a system application uses system API. + * @syscap SystemCapability.MiscServices.ScreenLock + * @systemapi Hide this for inner system use. + * @since 9 + */ + function isLocked(): boolean; + + /** + * Unlock the screen. + * + * @returns Returns {@code true} if the screen is unlocked successfully; returns {@code false} otherwise. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 13200002 - the screenlock management service is abnormal. + * @syscap SystemCapability.MiscServices.ScreenLock + * @since 9 + */ + function unlock(callback: AsyncCallback): void; + + /** + * Unlock the screen. + * + * @returns Returns {@code true} if the screen is unlocked successfully; returns {@code false} otherwise. + * @throws {BusinessError} 13200002 - the screenlock management service is abnormal. + * @syscap SystemCapability.MiscServices.ScreenLock + * @since 9 + */ + function unlock():Promise; +``` + + +**Adaptation Guide** + +Make sure the APIs are only invoked by system applications. + +The code snippet is as follows: + +```js + try { + let ret = screenLock.isLocked(); + console.error(`Obtain whether the screen is locked successfully , ret is: ${ret}`); + } catch (error) { + console.error(`Failed to obtain whether the screen is locked, error is : ${error.code}, ${error.message}`); + } +``` + +```js + screenlock.unlock((err, data) => { + if (err) { + console.error(`Failed to unlock the screen, because: ${err.message}`); + return; + } + console.info(`unlock the screen successfully. result: ${data}`); + }); +``` + +```js + screenlock.unlock().then((data) => { + console.info(`unlock the screen successfully. result: ${data}`); + }).catch((err) => { + console.error(`Failed to unlock the screen, because: ${err.message}`); + }); +``` + + +## cl.screenlock.2 Deprecation of isSecure +Deprecated the **isSecure** API since API version 9. + +You need to adapt your application based on the following information. + +**Change Impact** + +The API can no longer be used after being deleted. + +- Involved APIs: + +```js + function isSecure(): boolean; +``` + +- Before change: + +```js + function isSecure(): boolean; +``` + +- After change: + + The API is deleted. + + +**Adaptation Guide** + +Update the code so that the deprecated API is not used. diff --git a/en/release-notes/changelogs/v3.2-release/changelogs-wallpaper.md b/en/release-notes/changelogs/v3.2-release/changelogs-wallpaper.md new file mode 100644 index 0000000000000000000000000000000000000000..18fff418c0723c7508f6c7eacdb318b95758402b --- /dev/null +++ b/en/release-notes/changelogs/v3.2-release/changelogs-wallpaper.md @@ -0,0 +1,306 @@ +# Theme Framework Subsystem – Wallpaper Management Service Changelog + + +## cl.wallpaper.1 Permission Change of getColorsSync, getMinHeightSync, getMinWidthSync, restore, and setImage +Changed the **getColorsSync**, **getMinHeightSync**, **getMinWidthSync**, restore, and **setImage** APIs to system APIs since API version 9. + +You need to adapt your application based on the following information. + +**Change Impact** + +The JS API needs to be adapted for applications developed based on earlier versions. Otherwise, relevant functions will be affected. + +- Involved APIs: + +```js + function getColorsSync(wallpaperType: WallpaperType): Array; + function getMinHeightSync(): number; + function getMinWidthSync(): number; + function restore(wallpaperType: WallpaperType, callback: AsyncCallback): void; + function restore(wallpaperType: WallpaperType): Promise; + function setImage(source: string | image.PixelMap, wallpaperType: WallpaperType, callback: AsyncCallback): void; + function setImage(source: string | image.PixelMap, wallpaperType: WallpaperType): Promise; +``` + +- Before change: + +```js + /** + * Obtains the wallpaper colors for the wallpaper of the specified type. Returns rgbaColor type of array callback function. + * @param wallpaperType Indicates the wallpaper type. + * @returns { Array } the Array returned by the function. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 202 - permission verification failed, application which is not a system application uses system API. + * @syscap SystemCapability.MiscServices.Wallpaper + * @systemapi Hide this for inner system use. + * @since 9 + */ + function getColorsSync(wallpaperType: WallpaperType): Array; + + /** + * Obtains the minimum height of the wallpaper. in pixels. returns 0 if no wallpaper has been set. + * @returns { number } the number returned by the function. + * @throws {BusinessError} 202 - permission verification failed, application which is not a system application uses system API. + * @syscap SystemCapability.MiscServices.Wallpaper + * @systemapi Hide this for inner system use. + * @since 9 + */ + function getMinHeightSync(): number; + + /** + * Obtains the minimum width of the wallpaper. in pixels. returns 0 if no wallpaper has been set. + * @returns { number } the number returned by the function. + * @throws {BusinessError} 202 - permission verification failed, application which is not a system application uses system API. + * @syscap SystemCapability.MiscServices.Wallpaper + * @systemapi Hide this for inner system use. + * @since 9 + */ + function getMinWidthSync(): number; + + /** + * Removes a wallpaper of the specified type and restores the default one. + * @param wallpaperType Indicates the wallpaper type. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 202 - permission verification failed, application which is not a system application uses system API. + * @permission ohos.permission.SET_WALLPAPER + * @syscap SystemCapability.MiscServices.Wallpaper + * @systemapi Hide this for inner system use. + * @since 9 + */ + function restore(wallpaperType: WallpaperType, callback: AsyncCallback): void; + + /** + * Removes a wallpaper of the specified type and restores the default one. + * @param wallpaperType Indicates the wallpaper type. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 202 - permission verification failed, application which is not a system application uses system API. + * @permission ohos.permission.SET_WALLPAPER + * @syscap SystemCapability.MiscServices.Wallpaper + * @systemapi Hide this for inner system use. + * @since 9 + */ + function restore(wallpaperType: WallpaperType): Promise; + + /** + * Sets a wallpaper of the specified type based on the uri path from a JPEG or PNG file or the pixel map of a PNG file. + * @param source Indicates the uri path from a JPEG or PNG file or the pixel map of the PNG file. + * @param wallpaperType Indicates the wallpaper type. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 202 - permission verification failed, application which is not a system application uses system API. + * @permission ohos.permission.SET_WALLPAPER + * @syscap SystemCapability.MiscServices.Wallpaper + * @systemapi Hide this for inner system use. + * @since 9 + */ + function setImage(source: string | image.PixelMap, wallpaperType: WallpaperType, callback: AsyncCallback): void; + + /** + * Sets a wallpaper of the specified type based on the uri path from a JPEG or PNG file or the pixel map of a PNG file. + * @param source Indicates the uri path from a JPEG or PNG file or the pixel map of the PNG file. + * @param wallpaperType Indicates the wallpaper type. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 201 - permission denied. + * @throws {BusinessError} 202 - permission verification failed, application which is not a system application uses system API. + * @permission ohos.permission.SET_WALLPAPER + * @syscap SystemCapability.MiscServices.Wallpaper + * @systemapi Hide this for inner system use. + * @since 9 + */ + function setImage(source: string | image.PixelMap, wallpaperType: WallpaperType): Promise; +``` + +- After change: + +```js + /** + * Obtains the wallpaper colors for the wallpaper of the specified type. Returns rgbaColor type of array callback function. + * @param wallpaperType Indicates the wallpaper type. + * @returns { Array } the Array returned by the function. + * @throws {BusinessError} 401 - parameter error. + * @syscap SystemCapability.MiscServices.Wallpaper + * @since 9 + */ + function getColorsSync(wallpaperType: WallpaperType): Array; + + /** + * Obtains the minimum height of the wallpaper. in pixels. returns 0 if no wallpaper has been set. + * @returns { number } the number returned by the function. + * @syscap SystemCapability.MiscServices.Wallpaper + * @since 9 + */ + function getMinHeightSync(): number; + + /** + * Obtains the minimum width of the wallpaper. in pixels. returns 0 if no wallpaper has been set. + * @returns { number } the number returned by the function. + * @syscap SystemCapability.MiscServices.Wallpaper + * @since 9 + */ + function getMinWidthSync(): number; + + /** + * Removes a wallpaper of the specified type and restores the default one. + * @param wallpaperType Indicates the wallpaper type. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 201 - permission denied. + * @permission ohos.permission.SET_WALLPAPER + * @syscap SystemCapability.MiscServices.Wallpaper + * @since 9 + */ + function restore(wallpaperType: WallpaperType, callback: AsyncCallback): void; + + /** + * Removes a wallpaper of the specified type and restores the default one. + * @param wallpaperType Indicates the wallpaper type. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 201 - permission denied. + * @permission ohos.permission.SET_WALLPAPER + * @syscap SystemCapability.MiscServices.Wallpaper + * @since 9 + */ + function restore(wallpaperType: WallpaperType): Promise; + + /** + * Sets a wallpaper of the specified type based on the uri path from a JPEG or PNG file or the pixel map of a PNG file. + * @param source Indicates the uri path from a JPEG or PNG file or the pixel map of the PNG file. + * @param wallpaperType Indicates the wallpaper type. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 201 - permission denied. + * @permission ohos.permission.SET_WALLPAPER + * @syscap SystemCapability.MiscServices.Wallpaper + * @since 9 + */ + function setImage(source: string | image.PixelMap, wallpaperType: WallpaperType, callback: AsyncCallback): void; + + /** + * Sets a wallpaper of the specified type based on the uri path from a JPEG or PNG file or the pixel map of a PNG file. + * @param source Indicates the uri path from a JPEG or PNG file or the pixel map of the PNG file. + * @param wallpaperType Indicates the wallpaper type. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 201 - permission denied. + * @permission ohos.permission.SET_WALLPAPER + * @syscap SystemCapability.MiscServices.Wallpaper + * @since 9 + */ + function setImage(source: string | image.PixelMap, wallpaperType: WallpaperType): Promise; +``` + + +**Adaptation Guide** + +Make sure the APIs are only invoked by system applications. + +The code snippet is as follows: + +```js + try { + let colors = wallpaper.getColorsSync(wallpaper.WallpaperType.WALLPAPER_SYSTEM); + console.log(`success to getColorsSync: ${JSON.stringify(colors)}`); + } catch (error) { + console.error(`failed to getColorsSync because: ${JSON.stringify(error)}`); + } +``` + +```js + let minHeight = wallpaper.getMinHeightSync(); +``` + +```js + let minWidth = wallpaper.getMinWidthSync(); +``` + +```js + wallpaper.restore(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error) => { + if (error) { + console.error(`failed to restore because: ${JSON.stringify(error)}`); + return; + } + console.log(`success to restore.`); + }); +``` + +```js + wallpaper.restore(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then(() => { + console.log(`success to restore.`); + }).catch((error) => { + console.error(`failed to restore because: ${JSON.stringify(error)}`); + }); +``` + +```js + // The source type is string. + let wallpaperPath = "/data/data/ohos.acts.aafwk.plrdtest.form/files/Cup_ic.jpg"; + wallpaper.setImage(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error) => { + if (error) { + console.error(`failed to setImage because: ${JSON.stringify(error)}`); + return; + } + console.log(`success to setImage.`); + }); +``` + +```js + // The source type is string. + let wallpaperPath = "/data/data/ohos.acts.aafwk.plrdtest.form/files/Cup_ic.jpg"; + wallpaper.setImage(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then(() => { + console.log(`success to setImage.`); + }).catch((error) => { + console.error(`failed to setImage because: ${JSON.stringify(error)}`); + }); +``` + + +## cl.wallpaper.2 Deprecation of getIdSync, getFileSync, isChangeAllowed, isUserChangeAllowed, on, off, and RgbaColor +Deprecated the **getIdSync**, **getFileSync**, **isChangeAllowed**, **isUserChangeAllowed**, **on**, **off**, and **RgbaColor** APIs since API version 9. + +You need to adapt your application based on the following information. + +**Change Impact** + +The APIs can no longer be used after being deleted. + +- Involved APIs: + +```js + function getIdSync(wallpaperType: WallpaperType): number; + function getFileSync(wallpaperType: WallpaperType): number; + function isChangeAllowed(): boolean; + function isUserChangeAllowed(): boolean; + function on(type: 'colorChange', callback: (colors: Array, wallpaperType: WallpaperType) => void): void; + function off(type: 'colorChange', callback?: (colors: Array, wallpaperType: WallpaperType) => void): void; + interface RgbaColor { + red: number; + green: number; + blue: number; + alpha: number; + } +``` + +- Before change: + +```js + function getIdSync(wallpaperType: WallpaperType): number; + function getFileSync(wallpaperType: WallpaperType): number; + function isChangeAllowed(): boolean; + function isUserChangeAllowed(): boolean; + function on(type: 'colorChange', callback: (colors: Array, wallpaperType: WallpaperType) => void): void; + function off(type: 'colorChange', callback?: (colors: Array, wallpaperType: WallpaperType) => void): void; + interface RgbaColor { + red: number; + green: number; + blue: number; + alpha: number; + } +``` + +- After change: + + The APIs are deleted. + + +**Adaptation Guide** + +Update the code so that the deprecated APIs are not used. diff --git a/en/release-notes/changelogs/v3.2-release/changelogs-web.md b/en/release-notes/changelogs/v3.2-release/changelogs-web.md new file mode 100644 index 0000000000000000000000000000000000000000..806f1270619d8aec7e7efcf95f41b7a45cc602e8 --- /dev/null +++ b/en/release-notes/changelogs/v3.2-release/changelogs-web.md @@ -0,0 +1,467 @@ +# Web Subsystem Changelog + +Compared with earlier versions, OpenHarmony 3.2.10.7 has the following API changes in its web subsystem: + +## cl.web.1 HitTestTypeV9 Name Change + +Renamed the enum class **HitTestTypeV9** **WebHitTestType** to meet the naming conventions. + +**Change Impact** + +The enum class **HitTestTypeV9** and APIs that use **HitTestTypeV9** as a parameter or return value cannot be used in OpenHarmony 3.2.10.7 and later versions. + +**Key API/Component Changes** + +- Involved APIs: + + enum HitTestTypeV9 + +- Before change: + + ```ts + enum HitTestTypeV9 + ``` + +- After change: + + ```ts + enum WebHitTestType + ``` + +**Adaptation Guide** + +Replace **HitTestTypeV9** with **WebHitTestType**. + +## cl.web.2 HeaderV9 Name Change + +Renamed the struct **HeaderV9** **WebHeader** to meet the naming conventions. + +**Change Impact** + +The struct **HeaderV9** and APIs that use **HeaderV9** as a parameter or return value cannot be used in OpenHarmony 3.2.10.7 and later versions. + +**Key API/Component Changes** + +- Involved APIs: + + interface HeaderV9 + +- Before change: + + ```ts + interface HeaderV9 + ``` + +- After change: + + ```ts + interface WebHeader + ``` + +**Adaptation Guide** + +Replace **HeaderV9** with **WebHeader**. + +## cl.web.3 Member Change of HitTestValue + +Rename the member variable **HitTestTypeV9** in the **HitTestValue** struct **WebHitTestType** to meet the naming conventions. + +**Change Impact** + +The struct **HitTestValue** and APIs that use **HitTestValue** as a parameter or return value cannot be used in OpenHarmony 3.2.10.7 and later versions. + +**Key API/Component Changes** + +- Involved APIs: + + interface HitTestValue + +- Before change: + + ```ts + interface HitTestValue { + + /** + * Get the hit test type. + * + * @since 9 + */ + type: HitTestTypeV9; + + /** + * Get the hit test extra data. + * + * @since 9 + */ + extra: string; + } + ``` + +- After change: + + ```ts + interface HitTestValue { + + /** + * Get the hit test type. + * + * @since 9 + */ + type: WebHitTestType; + + /** + * Get the hit test extra data. + * + * @since 9 + */ + extra: string; + } + ``` + +**Adaptation Guide** + +Replace **HitTestTypeV9** with **WebHitTestType**. + +## cl.web.4 Parameter Type Change of loadUrl + +Changed the type of the **headers** parameter in **loadUrl** to **WebHeader** to meet the naming conventions. + +**Change Impact** + +The **loadUrl** API that uses the **headers** parameter cannot be used in OpenHarmony 3.2.10.7 and later versions. + +**Key API/Component Changes** + +- Involved APIs: + + loadUrl(url: string | Resource, headers?: Array\): void + +- Before change: + + ```ts + loadUrl(url: string | Resource, headers?: Array): void + ``` + +- After change: + + ```ts + loadUrl(url: string | Resource, headers?: Array): void + ``` + +**Adaptation Guide** + +Change the type of the **headers** parameter in **loadUrl** from **HeaderV9** to **WebHeader**. + +## cl.web.5 Return Value Type Change of getHitTest + +Changed the return value type of the **getHitTest** API to **WebHitTest** to meet the naming conventions. + +**Change Impact** + +The **getHitTest** API cannot be used in OpenHarmony 3.2.10.7 and later versions. + +**Key API/Component Changes** + +- Involved APIs: + + getHitTest(): HitTestTypeV9 + +- Before change: + + ```ts + getHitTest(): HitTestTypeV9 + ``` + +- After change: + + ```ts + getHitTest(): WebHitTestType + ``` + +**Adaptation Guide** + +Change the return value type of the **getHitTest** API from **HitTestTypeV9** to **WebHitTestType**. + +## cl.web.6 Moving of the WebMessagePort Class + +Moved the **WebMessagePort** class to **@ohos.web.webview.d.ts** and added error throwing. + +**Change Impact** + +If your application is developed based on earlier versions, note that the **d.ts** file storage location and the name of the module to be imported are changed. In addition, be mindful of the error codes now that the APIs in the class support error code processing. + +**Key API/Component Changes** + +- Involved APIs: + + postMessageEvent(message: WebMessageEvent): void; + onMessageEvent(callback: (result: string) => void): void; + +- Before change: + + ```ts + postMessageEvent(message: WebMessageEvent): void; + onMessageEvent(callback: (result: string) => void): void; + ``` + +- After change: + + ```ts + postMessageEvent(message: WebMessage): void; + onMessageEvent(callback: (result: WebMessage) => void): void; + ``` + +**Adaptation Guide** + +Instead of importing APIs from the original **WebMessagePort** class, import APIs from **@ohos.web.webview** as follows: + + ```ts + import web_webview from '@ohos.web.webview'; + ``` + +## cl.web.7 Moving of the HitTestValue Class + +Moved the **HitTestValue** class to **@ohos.web.webview.d.ts**; changed **HitTestValue** from a class to an API; changed the **getType** and **getExtra** from APIs to attributes. + +**Change Impact** + +If your application is developed based on earlier versions, note that the **d.ts** file storage location and the name of the module to be imported are changed. + +**Key API/Component Changes** + +- Involved APIs: + + getType(): HitTestType; + getExtra(): string; + +- Before change: + + ```ts + getType(): HitTestType; + getExtra(): string; + ``` + +- After change: + + ```ts + type: WebHitTestType; + extra: string; + ``` + +**Adaptation Guide** + +Instead of importing APIs from the original **HitTestValue** class, import APIs from **@ohos.web.webview** as follows: + + ```ts + import web_webview from '@ohos.web.webview'; + ``` + +## cl.web.8 Moving of API Version 9 APIs Under WebCookie + +Moved APIs of API version 9 in the **WebCookie** class to **web.webview.webview.WebCookieManager** +and added error throwing. + +**Change Impact** + +If your application is developed based on earlier versions, note that the **d.ts** file storage location and the name of the module to be imported are changed. In addition, be mindful of the error codes now that the APIs in the class support error code processing. +The APIs in the class are static. + +**Key API/Component Changes** + +- Involved APIs: + + isCookieAllowed(): boolean; + isThirdPartyCookieAllowed(): boolean; + putAcceptCookieEnabled(accept: boolean): void; + putAcceptThirdPartyCookieEnabled(accept: boolean): void; + setCookie(url: string, value: string): boolean; + saveCookieSync(): boolean; + getCookie(url: string): string; + existCookie(): boolean; + deleteEntireCookie(): void; + deleteSessionCookie(): void; + +- Before change: + + ```ts + isCookieAllowed(): boolean; + isThirdPartyCookieAllowed(): boolean; + putAcceptCookieEnabled(accept: boolean): void; + putAcceptThirdPartyCookieEnabled(accept: boolean): void; + setCookie(url: string, value: string): boolean; + saveCookieSync(): boolean; + getCookie(url: string): string; + existCookie(): boolean; + deleteEntireCookie(): void; + deleteSessionCookie(): void; + ``` + +- After change: + + ```ts + static isCookieAllowed(): boolean; + static isThirdPartyCookieAllowed(): boolean; + static putAcceptCookieEnabled(accept: boolean): void; + static putAcceptThirdPartyCookieEnabled(accept: boolean): void; + static setCookie(url: string, value: string): void; + static saveCookieAsync(): Promise; + static saveCookieAsync(callback: AsyncCallback): void; + static getCookie(url: string): string; + static existCookie(): boolean; + static deleteEntireCookie(): void; + static deleteSessionCookie(): void; + ``` + +**Adaptation Guide** + +Instead of importing APIs from the original **WebCookie** class, import APIs from **@ohos.web.webview** as follows: + + ```ts + import web_webview from '@ohos.web.webview'; + ``` + +## cl.web.9 Moving of API Version 9 APIs Under WebController + +Moved APIs of API version 9 in the **WebController** class to **web.webview.webview.WebviewController** and added error throwing. + +**Change Impact** + +If your application is developed based on earlier versions, note that the **d.ts** file storage location and the name of the module to be imported are changed. In addition, be mindful of the error codes now that the APIs in the class support error code processing. +The **getDefaultUserAgent** API is renamed **getUserAgent**. + +**Key API/Component Changes** + +- Involved APIs: + + zoomIn(): boolean; + zoomOut(): boolean; + createWebMessagePorts(): Array\; + postMessage(options: { message: WebMessageEvent, uri: string}): void; + getHitTestValue(): HitTestValue; + getWebId(): number; + getDefaultUserAgent(): string; + getTitle(): string; + getPageHeight(): number; + backOrForward(step: number): void; + searchAllAsync(searchString: string): void; + clearMatches(): void; + searchNext(forward: boolean): void; + clearSslCache(): void; + clearClientAuthenticationCache(): void; + getUrl(): string; + +- Before change: + + ```ts + zoomIn(): boolean; + zoomOut(): boolean; + createWebMessagePorts(): Array; + postMessage(options: { message: WebMessageEvent, uri: string}): void; + getHitTestValue(): HitTestValue; + getWebId(): number; + getDefaultUserAgent(): string; + getTitle(): string; + getPageHeight(): number; + backOrForward(step: number): void; + searchAllAsync(searchString: string): void; + clearMatches(): void; + searchNext(forward: boolean): void; + clearSslCache(): void; + clearClientAuthenticationCache(): void; + getUrl(): string; + ``` + +- After change: + + ```ts + zoomIn(): void; + zoomOut(): void; + createWebMessagePorts(): Array; + postMessage(name: string, ports: Array, uri: string): void; + getHitTestValue(): HitTestValue; + getWebId(): number; + getUserAgent(): string; + getTitle(): string; + getPageHeight(): number; + backOrForward(step: number): void; + searchAllAsync(searchString: string): void; + clearMatches(): void; + searchNext(forward: boolean): void; + clearSslCache(): void; + clearClientAuthenticationCache(): void; + getUrl(): string; + ``` + +**Adaptation Guide** + +Instead of importing APIs from the original **WebController** class, import APIs from **@ohos.web.webview** as follows: + + ```ts + import web_webview from '@ohos.web.webview'; + ``` + +## cl.web.10 Moving of the WebAsyncController Class + +Moved the APIs in the **WebAsyncController** class to the **web.webview.webview.WebviewController** class and added error throwing. + +**Change Impact** + +If your application is developed based on earlier versions, pay attention to error code processing. + +**Key API/Component Changes** + +- Involved APIs: + + storeWebArchive(baseName: string, autoName: boolean): Promise\; + storeWebArchive(baseName: string, autoName: boolean, callback : AsyncCallback\): void; + +- Before change: + + ```ts + storeWebArchive(baseName: string, autoName: boolean): Promise; + storeWebArchive(baseName: string, autoName: boolean, callback : AsyncCallback): void; + ``` + +- After change: + + ```ts + storeWebArchive(baseName: string, autoName: boolean): Promise; + storeWebArchive(baseName: string, autoName: boolean, callback : AsyncCallback): void; + ``` + +**Adaptation Guide** + +Example: + + ```ts + // xxx.ets + import web_webview from '@ohos.web.webview' + + @Entry + @Component + struct WebComponent { + controller: web_webview.WebviewController = new web_webview.WebviewController(); + + build() { + Column() { + Button('saveWebArchive') + .onClick(() => { + try { + this.controller.storeWebArchive("/data/storage/el2/base/", true, (error, filename) => { + if (error) { + console.info(`save web archive error: ` + JSON.stringify(error)) + return; + } + if (filename != null) { + console.info(`save web archive success: ${filename}`) + } + }); + } catch (error) { + console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); + } + }) + Web({ src: 'www.example.com', controller: this.controller }) + } + } + } + ``` diff --git a/zh-cn/application-dev/application-models/application-context-stage.md b/zh-cn/application-dev/application-models/application-context-stage.md index f30583f28421975cdf393f5378b65e959f7a9644..6e64c5a4a5bdc1044021706bfc49a1cdbe1f23bb 100644 --- a/zh-cn/application-dev/application-models/application-context-stage.md +++ b/zh-cn/application-dev/application-models/application-context-stage.md @@ -3,7 +3,7 @@ ## 概述 -[Context](../reference/apis/js-apis-inner-application-context.md)是应用中对象的上下文,其提供了应用的一些基础信息,例如resourceManager(资源管理)、applicationInfo(当前应用信息)、dir(应用开发路径)、area(文件分区)等,以及应用的一些基本方法,例如createBundleContext()、getApplicationContext()等。UIAbility组件和各种ExtensionAbility派生类组件都有各自不同的Context类。分别有基类Context、ApplicationContext、AbilityStageContext、UIAbilityContext、ExtensionContext、ServiceExtensionContext等Context。 +[Context](../reference/apis/js-apis-inner-application-context.md)是应用中对象的上下文,其提供了应用的一些基础信息,例如resourceManager(资源管理)、applicationInfo(当前应用信息)、dir(应用文件路径)、area(文件分区)等,以及应用的一些基本方法,例如createBundleContext()、getApplicationContext()等。UIAbility组件和各种ExtensionAbility派生类组件都有各自不同的Context类。分别有基类Context、ApplicationContext、AbilityStageContext、UIAbilityContext、ExtensionContext、ServiceExtensionContext等Context。 - 各类Context的继承关系 ![context-inheritance](figures/context-inheritance.png) @@ -68,78 +68,81 @@ 本章节通过如下典型场景来介绍Context的用法: -- [获取应用开发路径](#获取应用开发路径) +- [获取应用文件路径](#获取应用文件路径) - [获取和修改加密分区](#获取和修改加密分区) - [创建其他应用或其他Module的Context](#创建其他应用或其他module的context) - [订阅进程内UIAbility生命周期变化](#订阅进程内uiability生命周期变化) -### 获取应用开发路径 +### 获取应用文件路径 -从Context中获取的应用开发路径如下表所示。 +[基类Context](../reference/apis/js-apis-inner-application-context.md)提供了获取应用文件路径的能力,ApplicationContext、AbilityStageContext、UIAbilityContext和ExtensionContext均继承该能力。应用文件路径属于应用沙箱路径,具体请参见[应用沙箱目录](../file-management/app-sandbox-directory.md)。 -**表1** 应用开发路径说明 +上述各类Context获取的应用文件路径有所不同。 -| 属性名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| bundleCodeDir | string | 是 | 否 | 安装文件路径。应用在内部存储上的安装路径。 | -| cacheDir | string | 是 | 否 | 缓存文件路径。应用在内部存储上的缓存路径。
对应于“设置 > 应用管理”,找到对应应用的“存储”中的缓存内容。 | -| filesDir | string | 是 | 否 | 通用文件路径。应用在内部存储上的文件路径。
本目录下存放的文件可能会被应用迁移或者备份的时候同步到其他目录中。 | -| preferencesDir | string | 是 | 是 | 首选项文件路径。指示应用程序首选项目录。 | -| tempDir | string | 是 | 否 | 临时文件路径。
在应用卸载后,系统会删除存储在此目录中的文件。 | -| databaseDir | string | 是 | 否 | 数据库路径。获取本地数据库存储路径。 | -| distributedFilesDir | string | 是 | 否 | 分布式文件路径。 | +- 通过ApplicationContext获取应用级别的应用文件路径,此路径是应用全局信息推荐的存放路径,这些文件会跟随应用的卸载而删除。 -获取路径的能力是基类Context中提供的能力,因此在ApplicationContext、AbilityStageContext、UIAbilityContext和ExtensionContext中均可以获取,在各类Context中获取到的路径会有一些差别,具体差别如下图所示。 - -**图1** Context中获取的应用开发路径 -![context-dir](figures/context-dir.png) - -- 通过ApplicationContext获取的应用级别路径。应用全局信息建议存放的路径,存放在此路径的文件内容仅在应用卸载时会被删除。 - | 属性 | 路径 | + | 属性 | 路径 | | -------- | -------- | - | bundleCodeDir | {路径前缀}/el1/bundle/ | - | cacheDir | {路径前缀}/{加密等级}/base/cache/ | - | filesDir | {路径前缀}/{加密等级}/base/files/ | - | preferencesDir | {路径前缀}/{加密等级}/base/preferences/ | - | tempDir | {路径前缀}/{加密等级}/base/temp/ | - | databaseDir | {路径前缀}/{加密等级}/database/ | - | distributedFilesDir | {路径前缀}/el2/distributedFiles/ | - -- 通过AbilityStageContext、UIAbilityContext、ExtensionContext获取的HAP级别路径。HAP对应的信息建议存放的路径,存放在此路径的文件内容会跟随HAP的卸载而删除,不会影响应用级别路径的文件内容,除非该应用的HAP已全部卸载。 - | 属性 | 路径 | - | -------- | -------- | - | bundleCodeDir | {路径前缀}/el1/bundle/ | - | cacheDir | {路径前缀}/{加密等级}/base/**haps/{moduleName}**/cache/ | - | filesDir | {路径前缀}/{加密等级}/base/**haps/{moduleName}**/files/ | - | preferencesDir | {路径前缀}/{加密等级}/base/**haps/{moduleName}**/preferences/ | - | tempDir | {路径前缀}/{加密等级}/base/**haps/{moduleName}**/temp/ | - | databaseDir | {路径前缀}/{加密等级}/database/**{moduleName}**/ | - | distributedFilesDir | {路径前缀}/el2/distributedFiles/**{moduleName}**/ | + | bundleCodeDir | <路径前缀>/el1/bundle/ | + | cacheDir | <路径前缀>/<加密等级>/base/cache/ | + | filesDir | <路径前缀>/<加密等级>/base/files/ | + | preferencesDir | <路径前缀>/<加密等级>/base/preferences/ | + | tempDir | <路径前缀>/<加密等级>/base/temp/ | + | databaseDir | <路径前缀>/<加密等级>/database/ | + | distributedFilesDir | <路径前缀>/el2/distributedFiles/ | + + 示例代码如下所示。 + + ```ts + import UIAbility from '@ohos.app.ability.UIAbility'; + + export default class EntryAbility extends UIAbility { + onCreate(want, launchParam) { + let applicationContext = this.context.getApplicationContext(); + let cacheDir = applicationContext.cacheDir; + let tempDir = applicationContext.tempDir; + let filesDir = applicationContext.filesDir; + let databaseDir = applicationContext.databaseDir; + let bundleCodeDir = applicationContext.bundleCodeDir; + let distributedFilesDir = applicationContext.distributedFilesDir; + let preferencesDir = applicationContext.preferencesDir; + ... + } + } + ``` -获取应用开发路径的示例代码如下所示。 +- 通过AbilityStageContext、UIAbilityContext、ExtensionContext获取HAP级别的应用文件路径。此路径是HAP相关信息推荐的存放路径,这些文件会跟随HAP的卸载而删除,但不会影响应用级别路径的文件,除非该应用的HAP已全部卸载。 + | 属性 | 路径 | + | -------- | -------- | + | bundleCodeDir | <路径前缀>/el1/bundle/ | + | cacheDir | <路径前缀>/<加密等级>/base/**haps/\**/cache/ | + | filesDir | <路径前缀>/<加密等级>/base/**haps/\**/files/ | + | preferencesDir | <路径前缀>/<加密等级>/base/**haps/\**/preferences/ | + | tempDir | <路径前缀>/<加密等级>/base/**haps/\**/temp/ | + | databaseDir | <路径前缀>/<加密等级>/database/**\**/ | + | distributedFilesDir | <路径前缀>/el2/distributedFiles/**\**/ | -```ts -import UIAbility from '@ohos.app.ability.UIAbility'; + 示例代码如下所示。 -export default class EntryAbility extends UIAbility { - onCreate(want, launchParam) { - let cacheDir = this.context.cacheDir; - let tempDir = this.context.tempDir; - let filesDir = this.context.filesDir; - let databaseDir = this.context.databaseDir; - let bundleCodeDir = this.context.bundleCodeDir; - let distributedFilesDir = this.context.distributedFilesDir; - let preferencesDir = this.context.preferencesDir; - ... + ```ts + import UIAbility from '@ohos.app.ability.UIAbility'; + + export default class EntryAbility extends UIAbility { + onCreate(want, launchParam) { + let cacheDir = this.context.cacheDir; + let tempDir = this.context.tempDir; + let filesDir = this.context.filesDir; + let databaseDir = this.context.databaseDir; + let bundleCodeDir = this.context.bundleCodeDir; + let distributedFilesDir = this.context.distributedFilesDir; + let preferencesDir = this.context.preferencesDir; + ... + } } -} -``` + ``` -> **说明:** -> -> 示例代码获取到的是应用开发路径的沙箱路径。其对应的绝对路径,在创建或者修改文件之后,可以在`hdc shell`中,通过`find / -name <文件名称>`命令查找获取。 ### 获取和修改加密分区 @@ -153,22 +156,23 @@ export default class EntryAbility extends UIAbility { > > - AreaMode.EL2:用户级加密区,设备开机,首次输入密码后才能够访问的数据区。 -要实现获取和设置当前加密分区,可以通过读写[Context的area属性](../reference/apis/js-apis-inner-application-context.md)来实现。 +要实现获取和设置当前加密分区,可以通过读写[Context](../reference/apis/js-apis-inner-application-context.md)的`area`属性来实现。 ```ts import UIAbility from '@ohos.app.ability.UIAbility'; +import contextConstant from '@ohos.app.ability.contextConstant'; export default class EntryAbility extends UIAbility { onCreate(want, launchParam) { - // 存储普通信息前,切换到EL1设备机加密 - if (this.context.area === 1) { // 获取area - this.context.area = 0; // 修改area + // 存储普通信息前,切换到EL1设备级加密 + if (this.context.area === contextConstant.AreaMode.EL2) { // 获取area + this.context.area = contextConstant.AreaMode.EL1; // 修改area } // 存储普通信息 // 存储敏感信息前,切换到EL2用户级加密 - if (this.context.area === 0) { // 获取area - this.context.area = 1; // 修改area + if (this.context.area === contextConstant.AreaMode.EL1) { // 获取area + this.context.area = contextConstant.AreaMode.EL2; // 修改area } // 存储敏感信息 } @@ -178,16 +182,17 @@ export default class EntryAbility extends UIAbility { ### 创建其他应用或其他Module的Context -基类Context提供创建其他应用或其他Module的Context的方法有[createBundleContext(bundleName: string)](../reference/apis/js-apis-inner-application-context.md#contextcreatebundlecontext)、[createModuleContext(moduleName: string)](../reference/apis/js-apis-inner-application-context.md#contextcreatemodulecontext)和[createModuleContext(bundleName: string, moduleName: string)](../reference/apis/js-apis-inner-application-context.md#contextcreatemodulecontext-1)接口,创建其他应用或者其他Module的Context,从而通过该Context获取相应的资源信息(例如获取其他Module的[获取应用开发路径](#获取应用开发路径)信息)。 +基类Context提供创建其他应用或其他Module的Context的方法有[createBundleContext(bundleName: string)](../reference/apis/js-apis-inner-application-context.md#contextcreatebundlecontext)、[createModuleContext(moduleName: string)](../reference/apis/js-apis-inner-application-context.md#contextcreatemodulecontext)和[createModuleContext(bundleName: string, moduleName: string)](../reference/apis/js-apis-inner-application-context.md#contextcreatemodulecontext-1)接口,创建其他应用或者其他Module的Context,从而通过该Context获取相应的资源信息(例如获取其他Module的[获取应用文件路径](#获取应用文件路径)信息)。 -- 调用createBundleContext(bundleName:string)方法,创建其他应用的Context信息。 +- 调用`createBundleContext(bundleName:string)`方法,创建其他应用的Context信息。 > **说明:** + > > 当获取的是其他应用的Context时: - > - > - 申请`ohos.permission.GET_BUNDLE_INFO_PRIVILEGED`权限,配置方式请参见[访问控制授权申请](../security/accesstoken-guidelines.md#配置文件权限声明)。 - > + > + > - 申请`ohos.permission.GET_BUNDLE_INFO_PRIVILEGED`权限,配置方式请参见[配置文件权限声明](../security/accesstoken-guidelines.md#配置文件权限声明)。 + > > - 接口为系统接口,三方应用不支持调用。 - + 例如在桌面上显示的应用信息,包括应用名称和应用图标等,桌面应用可以通过调用上述的方法获取相应应用的Context信息从而获取到相应的应用名称、图标等资源信息。 ```ts @@ -202,8 +207,8 @@ export default class EntryAbility extends UIAbility { } } ``` - -- 调用createModuleContext(bundleName:string, moduleName:string)方法,获取指定应用指定Module的上下文信息。获取到指定应用指定Module的Context之后,即可获取到相应应用Module的资源信息。 + +- 调用`createModuleContext(bundleName:string, moduleName:string)`方法,获取指定应用指定Module的上下文信息。获取到指定应用指定Module的Context之后,即可获取到相应应用Module的资源信息。 > **说明:** > > 当获取的是其他应用的指定Module的Context时: @@ -225,7 +230,7 @@ export default class EntryAbility extends UIAbility { } ``` -- 调用createModuleContext(moduleName:string)方法,获取本应用中其他Module的Context。获取到其他Module的Context之后,即可获取到相应Module的资源信息。 +- 调用`createModuleContext(moduleName:string)`方法,获取本应用中其他Module的Context。获取到其他Module的Context之后,即可获取到相应Module的资源信息。 ```ts import UIAbility from '@ohos.app.ability.UIAbility'; diff --git a/zh-cn/application-dev/application-models/arkts-ui-widget-event-call.md b/zh-cn/application-dev/application-models/arkts-ui-widget-event-call.md index 50e43ab959093891ccb81408864faf66ce4957fd..c9d9942e43e24945bbf9d83c8ed96e2910aeb101 100644 --- a/zh-cn/application-dev/application-models/arkts-ui-widget-event-call.md +++ b/zh-cn/application-dev/application-models/arkts-ui-widget-event-call.md @@ -60,7 +60,7 @@ } function FunBCall(data) { - console.log('FunACall param:' + JSON.stringify(data.readString())); + console.log('FunBCall param:' + JSON.stringify(data.readString())); return null; } @@ -76,6 +76,8 @@ } } + ... + // 进程退出时,解除监听 onDestroy() { try { diff --git a/zh-cn/application-dev/application-models/arkts-ui-widget-event-overview.md b/zh-cn/application-dev/application-models/arkts-ui-widget-event-overview.md index b2a99b1618af9db2a2ae983c36267425c8223ab3..05e21771a5f452ac15c8676b34fdc264415dd07d 100644 --- a/zh-cn/application-dev/application-models/arkts-ui-widget-event-overview.md +++ b/zh-cn/application-dev/application-models/arkts-ui-widget-event-overview.md @@ -55,7 +55,7 @@ Button('拉至后台') 'abilityName': 'EntryAbility', 'params': { 'method': 'fun', // 自定义调用的方法名,必填 - 'message': 'testForcall' // 自定义要发送的message + 'message': 'testForCall' // 自定义要发送的message } }); }) diff --git a/zh-cn/application-dev/application-models/arkts-ui-widget-event-uiability.md b/zh-cn/application-dev/application-models/arkts-ui-widget-event-uiability.md index b80050596bd791dd69743819aabeb87955b627e5..7e4e7447e42601dba378c0348537aa75ee9bb96f 100644 --- a/zh-cn/application-dev/application-models/arkts-ui-widget-event-uiability.md +++ b/zh-cn/application-dev/application-models/arkts-ui-widget-event-uiability.md @@ -89,7 +89,7 @@ ## 通过call事件刷新卡片内容 - 在使用**postCardAction**接口的call事件时,需要在FormExtensionAbility中的onAddForm生命周期回调中更新formId。 - + ```ts import formBindingData from '@ohos.app.form.formBindingData'; import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility'; @@ -148,10 +148,9 @@ import UIAbility from '@ohos.app.ability.UIAbility'; import formBindingData from '@ohos.app.form.formBindingData'; import formProvider from '@ohos.app.form.formProvider'; - import formInfo from '@ohos.app.form.formInfo'; const MSG_SEND_METHOD: string = 'funA' - + // 在收到call事件后会触发callee监听的方法 function FunACall(data) { // 获取call事件中传递的所有参数 diff --git a/zh-cn/application-dev/application-models/common-event-static-subscription.md b/zh-cn/application-dev/application-models/common-event-static-subscription.md index 3c77b9fd6e6846773bab03f4616a5592278598e0..9f903c9ae3f004b0b2f6892254a44fdd0dbba748 100644 --- a/zh-cn/application-dev/application-models/common-event-static-subscription.md +++ b/zh-cn/application-dev/application-models/common-event-static-subscription.md @@ -93,27 +93,28 @@ - permission:订阅者要求的发布者需要具备的权限,对于发布了目标事件但不具备permission中声明的权限的发布者将被视为非法事件不予发布。 - events:订阅的目标事件列表。 -4. 修改设备的[预置配置文件](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568/preinstall-config/install_list_permissions.json)。[预置配置文件](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568/preinstall-config/install_list_permissions.json)在设备上的路径为`/system/etc/app/install_list_permission.json`,设备开机启动时会读取该配置文件,在应用安装会对在文件中配置的`allowCommonEvent`公共事件类型进行授权。预授权配置文件字段内容包括`bundleName`、`app_signature`和`allowCommonEvent`。 +4. 修改设备的[预置配置文件](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568/preinstall-config/install_list_capability.json)。[预置配置文件](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568/preinstall-config/install_list_capability.json)在设备上的路径为`/system/etc/app/install_list_capability.json`,设备开机启动时会读取该配置文件,在应用安装会对在文件中配置的`allowCommonEvent`公共事件类型进行授权。预授权配置文件字段内容包括`bundleName`、`app_signature`和`allowCommonEvent`。 - `bundleName`字段配置为应用的Bundle名称。 - - `app_signature`字段配置为应用的指纹信息。指纹信息的配置参见[应用特权配置指南](../../device-dev/subsystems/subsys-app-privilege-config-guide.md#install_list_capabilityjson中配置)。 + - `app_signature`字段配置为应用的指纹信息。指纹信息的配置请参见[应用特权配置指南](../../device-dev/subsystems/subsys-app-privilege-config-guide.md#install_list_capabilityjson中配置)。 - `allowCommonEvent`字段配置为允许静态广播拉起的公共事件项。 - > **说明**:当前仅支持预置应用配置该文件。 - ```json [ ... { "bundleName": "com.example.myapplication", // Bundle名称 "app_signature": ["****"], // 指纹信息 - "allowCommonEvent": ["usual.event.A", "usual.event.B"], // 允许静态广播拉起的公共事件项 - ] + "allowCommonEvent": ["usual.event.A", "usual.event.B"] // 允许静态广播拉起的公共事件项 } ] ``` + + > **说明**: + > + > 当前仅支持预置应用配置该文件。 -## 相关示例 +## 相关实例 针对StaticSubscriberExtensionAbility开发,可参考如下实例: diff --git a/zh-cn/application-dev/application-models/serviceextensionability.md b/zh-cn/application-dev/application-models/serviceextensionability.md index 7affeef41c4c19947fd69e93711125022a8cbbb3..3a9cf6faa1e55e54dc4891b7f4dd5f50b06a37f0 100644 --- a/zh-cn/application-dev/application-models/serviceextensionability.md +++ b/zh-cn/application-dev/application-models/serviceextensionability.md @@ -449,9 +449,9 @@ ServiceExtensionAbility服务组件在[onConnect()](../reference/apis/js-apis-ap } ``` -## 相关示例 +## 相关实例 -针对ServiceExtensionAbility开发,有以下相关示例可供参考: +针对ServiceExtensionAbility开发,有以下相关实例可供参考: - [`AbilityConnectServiceExtension`:Ability与ServiceExtensionAbility通信(ArkTS)(API9)(Full SDK)](https://gitee.com/openharmony/applications_app_samples/tree/master/code/BasicFeature/IDL/AbilityConnectServiceExtension) - [`StageModel`:Stage模型(ArkTS)(API9)(Full SDK)](https://gitee.com/openharmony/applications_app_samples/tree/master/code/BasicFeature/ApplicationModels/StageModel) diff --git a/zh-cn/application-dev/application-models/uiability-launch-type.md b/zh-cn/application-dev/application-models/uiability-launch-type.md index 263dc70696a7ab8e0058516203d76b5692d18b34..724e5b5ee637d20b912c7fba6daf9229f01c1440 100644 --- a/zh-cn/application-dev/application-models/uiability-launch-type.md +++ b/zh-cn/application-dev/application-models/uiability-launch-type.md @@ -90,7 +90,7 @@ specified启动模式为指定实例模式,针对一些特殊场景使用( } ``` -2. 在创建UIAbility实例之前,开发者可以为该实例指定一个唯一的字符串Key,这样在调用[`startAbility()`](.../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability)方法时,应用就可以根据指定的Key来识别响应请求的UIAbility实例。在EntryAbility中,调用[`startAbility()`](.../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability)方法时,可以在`want`参数中增加一个自定义参数,例如`instanceKey`,以此来区分不同的UIAbility实例。 +2. 在创建UIAbility实例之前,开发者可以为该实例指定一个唯一的字符串Key,这样在调用[`startAbility()`](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability)方法时,应用就可以根据指定的Key来识别响应请求的UIAbility实例。在EntryAbility中,调用[`startAbility()`](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability)方法时,可以在`want`参数中增加一个自定义参数,例如`instanceKey`,以此来区分不同的UIAbility实例。 ```ts // 在启动指定实例模式的UIAbility时,给每一个UIAbility实例配置一个独立的Key标识 diff --git a/zh-cn/application-dev/file-management/app-file-upload-download.md b/zh-cn/application-dev/file-management/app-file-upload-download.md index 6e04ff93d8700c4357172d72db1720eaa315cab8..a4c8e623bfaa943a9043fcc1b9bbc458dfe42243 100644 --- a/zh-cn/application-dev/file-management/app-file-upload-download.md +++ b/zh-cn/application-dev/file-management/app-file-upload-download.md @@ -48,7 +48,7 @@ try { .then((uploadTask) => { uploadTask.on('complete', (taskStates) => { for (let i = 0; i < taskStates.length; i++) { - console.info(`upload complete taskState: ${JSON.stringify(taskStates[i])}'); + console.info(`upload complete taskState: ${JSON.stringify(taskStates[i])}`); } }); }) diff --git a/zh-cn/application-dev/file-management/app-sandbox-directory.md b/zh-cn/application-dev/file-management/app-sandbox-directory.md index a521f924235ce3ae63c46af35d5ae11b178efab1..0340f8a7bc692a44018b4609780168da63b5b38b 100644 --- a/zh-cn/application-dev/file-management/app-sandbox-directory.md +++ b/zh-cn/application-dev/file-management/app-sandbox-directory.md @@ -10,8 +10,7 @@ 下图展示了应用沙箱下,应用可访问的文件范围和方式。 -**图1** 应用沙箱文件访问关系图 - +**图1** 应用沙箱文件访问关系图 ![Application sandbox file access relationship](figures/application-sandbox-file-access-relationship.png) ## 应用沙箱目录与应用沙箱路径 @@ -24,8 +23,7 @@ - 从实际物理路径推导物理路径与沙箱路径并不是1:1的映射关系,沙箱路径总是少于系统进程视角可见的物理路径。有些调试进程视角下的物理路径在对应的应用沙箱目录是无法找到的,而沙箱路径总是能够找到其对应的物理路径。 -**图2** 应用沙箱路径(不同权限与角色的进程下可见的文件路径不同) -   +**图2** 应用沙箱路径(不同权限与角色的进程下可见的文件路径不同) ![Application sandbox path](figures/application-sandbox-path.png) ## 应用文件目录与应用文件路径 @@ -36,8 +34,7 @@ 在此主要介绍应用文件目录,如下图所示。应用文件目录下某个文件或某个具体目录的路径称为应用文件路径。应用文件目录下的各个文件路径,具备不同的属性和特征。 -**图3** 应用文件目录结构图 - +**图3** 应用文件目录结构图 ![Application file directory structure](figures/application-file-directory-structure.png) 1. 一级目录data/:代表应用文件目录。 @@ -52,7 +49,7 @@ 4. 四级、五级目录: 通过ApplicationContext可以获取base下的files、cache、preferences、temp、distributedfiles等目录的应用文件路径,应用全局信息可以存放在这些目录下。 - 通过UIAbilityContext、AbilityStageContext、ExtensionContext可以获取hap级别应用文件路径。HAP信息可以存放在这些目录下,存放在此目录的文件会跟随HAP的卸载而删除,不会影响app级别目录下的文件。在开发态,一个应用包含一个或者多个HAP,详见[Stage模型应用程序包结构](../quick-start/application-package-structure-stage.md)。 + 通过UIAbilityContext、AbilityStageContext、ExtensionContext可以获取HAP级别应用文件路径。HAP信息可以存放在这些目录下,存放在此目录的文件会跟随HAP的卸载而删除,不会影响App级别目录下的文件。在开发态,一个应用包含一个或者多个HAP,详见[Stage模型应用程序包结构](../quick-start/application-package-structure-stage.md)。 Context上下文获取及上述应用文件路径的获取,详见[应用上下文Context](../application-models/application-context-stage.md)。 @@ -65,16 +62,16 @@ **表1** 应用文件路径详细说明 - | 目录名 | Context属性名称 | 类型 | 说明 | + | 目录名 | Context属性名称 | 类型 | 说明 | | -------- | -------- | -------- | -------- | - | bundle | bundleCodeDir | 安装文件路径 | 应用安装后的app的hap资源包所在目录;随应用卸载而清理。 | - | base | NA | 本设备文件路径 | 应用在本设备上存放持久化数据的目录,子目录包含files/、cache/、temp/和haps/;随应用卸载而清理。 | - | database | databaseDir | 数据库路径 | 应用在el1加密条件下存放通过分布式数据库服务操作的文件目录;随应用卸载而清理。 | - | distributedfiles | distributedFilesDir | 分布式文件路径 | 应用在el2加密条件下存放分布式文件的目录,应用将文件放入该目录可分布式跨设备直接访问;随应用卸载而清理。 | - | files | filesDir | 应用通用文件路径 | 应用在本设备内部存储上通用的存放默认长期保存的文件路径;随应用卸载而清理。 | - | cache | cacheDir | 应用缓存文件路径 | 应用在本设备内部存储上用于缓存下载的文件或可重新生成的缓存文件的路径,应用cache目录大小超过配额或者系统空间达到一定条件,自动触发清理该目录下文件;用户通过系统空间管理类应用也可能触发清理该目录。应用需判断文件是否仍存在,决策是否需重新缓存该文件。 | - | preferences | preferencesDir | 应用首选项文件路径 | 应用在本设备内部存储上通过数据库API存储配置类或首选项的目录;随应用卸载而清理。详见[通过用户首选项实现数据持久化](../database/data-persistence-by-preferences.md)。 | - | temp | tempDir | 应用临时文件路径 | 应用在本设备内部存储上仅在应用运行期间产生和需要的文件,应用退出后即清理。 | + | bundle | bundleCodeDir | 安装文件路径 | 应用安装后的App的HAP资源包所在目录;随应用卸载而清理。不能拼接路径访问资源文件,请使用[资源管理接口](../reference/apis/js-apis-resource-manager.md)访问资源。 | + | base | NA | 本设备文件路径 | 应用在本设备上存放持久化数据的目录,子目录包含files/、cache/、temp/和haps/;随应用卸载而清理。 | + | database | databaseDir | 数据库路径 | 应用在el1加密条件下存放通过分布式数据库服务操作的文件目录;随应用卸载而清理。 | + | distributedfiles | distributedFilesDir | 分布式文件路径 | 应用在el2加密条件下存放分布式文件的目录,应用将文件放入该目录可分布式跨设备直接访问;随应用卸载而清理。 | + | files | filesDir | 应用通用文件路径 | 应用在本设备内部存储上通用的存放默认长期保存的文件路径;随应用卸载而清理。 | + | cache | cacheDir | 应用缓存文件路径 | 应用在本设备内部存储上用于缓存下载的文件或可重新生成的缓存文件的路径,应用cache目录大小超过配额或者系统空间达到一定条件,自动触发清理该目录下文件;用户通过系统空间管理类应用也可能触发清理该目录。应用需判断文件是否仍存在,决策是否需重新缓存该文件。 | + | preferences | preferencesDir | 应用首选项文件路径 | 应用在本设备内部存储上通过数据库API存储配置类或首选项的目录;应用在本设备内部存储上通过数据库API存储配置类或首选项的目录;随应用卸载而清理。详见[通过用户首选项实现数据持久化](../database/data-persistence-by-preferences.md)。 | + | temp | tempDir | 应用临时文件路径 | 应用在本设备内部存储上仅在应用运行期间产生和需要的文件,应用退出后即清理。 | 对于上述各类应用文件路径,常见使用场景如下: diff --git a/zh-cn/application-dev/file-management/figures/application-file-directory-structure.png b/zh-cn/application-dev/file-management/figures/application-file-directory-structure.png index 9a4b622dbcd94afaaf13a4fc8bf22e9636d1337b..986260d28e8bcde7058f40ba3f9b7a8b7a5b8d17 100644 Binary files a/zh-cn/application-dev/file-management/figures/application-file-directory-structure.png and b/zh-cn/application-dev/file-management/figures/application-file-directory-structure.png differ diff --git a/zh-cn/application-dev/key-features/multi-device-app-dev/adaptive-layout.md b/zh-cn/application-dev/key-features/multi-device-app-dev/adaptive-layout.md index 29b7027125fbcfa7bb930a7190c5a7b15b179a4c..4cf432bd0d02aef68cbd378e24ae5e42af2ec515 100644 --- a/zh-cn/application-dev/key-features/multi-device-app-dev/adaptive-layout.md +++ b/zh-cn/application-dev/key-features/multi-device-app-dev/adaptive-layout.md @@ -190,7 +190,7 @@ struct FlexibleCapabilitySample2 { @Entry @Component struct EquipartitionCapabilitySample { - const list: number [] = [0, 1, 2, 3] + readonly list: number [] = [0, 1, 2, 3] @State rate: number = 0.6 // 底部滑块,可以通过拖拽滑块改变容器尺寸 @@ -424,8 +424,8 @@ struct ScaleCapabilitySample { .border({ width: 2, color: "#66F1CCB8"}) // 边框,仅用于展示效果 } .backgroundColor("#FFFFFF") - .height(this.sliderWidth) - .width(this.sliderHeight) + .height(this.sliderHeight) + .width(this.sliderWidth) this.slider() }.width('100%') @@ -709,7 +709,7 @@ struct HiddenCapabilitySample { @Component struct WrapCapabilitySample { @State rate: number = 0.7 - const imageList: Resource [] = [ + readonly imageList: Resource [] = [ $r('app.media.flexWrap1'), $r('app.media.flexWrap2'), $r('app.media.flexWrap3'), diff --git a/zh-cn/application-dev/key-features/multi-device-app-dev/responsive-layout.md b/zh-cn/application-dev/key-features/multi-device-app-dev/responsive-layout.md index a68af3880b62d79e6323b9a30588d2351cce6ee3..9d6cb5358ac7dc9bfe1d4616d1db9783e9d3644c 100644 --- a/zh-cn/application-dev/key-features/multi-device-app-dev/responsive-layout.md +++ b/zh-cn/application-dev/key-features/multi-device-app-dev/responsive-layout.md @@ -427,7 +427,7 @@ struct GridRowSample3 { gutter: {x: {sm: 8, md: 16, lg: 24}, y: {sm: 8, md: 16, lg: 24}}}) { ForEach(this.bgColors, (bgColor)=>{ GridCol({span: {sm: 2, md: 2, lg: 2}}) { - Row().backgroundColor(bgColor).height(30) + Row().backgroundColor(bgColor).height(30).width('100%') } }) } @@ -460,7 +460,7 @@ struct GridRowSample4 { GridCol({span:{xs: 12, sm: 12, md: 12, lg:12}}) { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Text("padding").fontSize(24).fontWeight(FontWeight.Medium) - }.backgroundColor('#19000000') + }.backgroundColor('#19000000').width('100%') } } .height(50) @@ -483,7 +483,7 @@ struct GridRowSample4 { GridCol({span:{xs: 12, sm: 12, md: 12, lg:12}}) { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Text("margin").fontSize(24).fontWeight(FontWeight.Medium) - }.backgroundColor('#19000000') + }.backgroundColor('#19000000').width('100%') } } .height(50) @@ -542,7 +542,7 @@ struct GridRowSample5 { Text('' + item.index).fontSize(24) } .justifyContent(FlexAlign.Center) - .backgroundColor(item.color).height(30) + .backgroundColor(item.color).height(30).width('100%') } }) } @@ -584,7 +584,7 @@ struct GridRowSample6 { Text('' + item.index).fontSize(24) } .justifyContent(FlexAlign.Center) - .backgroundColor(item.color).height(30) + .backgroundColor(item.color).height(30).width('100%') } }) } @@ -626,7 +626,7 @@ struct GridRowSample7 { Text('' + item.index).fontSize(24) } .justifyContent(FlexAlign.Center) - .backgroundColor(item.color).height(30) + .backgroundColor(item.color).height(30).width('100%') } }) } @@ -670,7 +670,7 @@ struct GridRowSample8 { Text('' + item.index).fontSize(24) } .justifyContent(FlexAlign.Center) - .backgroundColor(item.color).height(30) + .backgroundColor(item.color).height(30).width('100%') } }) } @@ -713,7 +713,7 @@ struct GridRowSample9 { Text('' + item.index).fontSize(24) } .justifyContent(FlexAlign.Center) - .backgroundColor(item.color).height(30) + .backgroundColor(item.color).height(30).width('100%') } }) } diff --git a/zh-cn/application-dev/napi/drawing-guidelines.md b/zh-cn/application-dev/napi/drawing-guidelines.md index 4de946c8a781f1e3f5b16cc929b7cce5bd585ce9..76b2d84b93a5ab76ed0d390f7517fcd9862bc01b 100644 --- a/zh-cn/application-dev/napi/drawing-guidelines.md +++ b/zh-cn/application-dev/napi/drawing-guidelines.md @@ -128,10 +128,7 @@ Native Drawing模块提供了一系列的接口用于基本图形和字体的绘 ```c++ // 画完后获取像素地址,地址指向的内存包含画布画的像素数据 void* bitmapAddr = OH_Drawing_BitmapGetPixels(cBitmap); - auto ret = memcpy_s(addr, addrSize, bitmapAddr, addrSize); - if (ret != EOK) { - LOGI("memcpy_s failed"); - } + std::copy(addr, addr + addrSize, static_cast(bitmapAddr)); // 销毁canvas对象 OH_Drawing_CanvasDestroy(cCanvas); // 销毁bitmap对象 diff --git a/zh-cn/application-dev/quick-start/app-configuration-file.md b/zh-cn/application-dev/quick-start/app-configuration-file.md index 6c67e7b79a7320406e736d393db068d7282ceb1f..2ed9c0766da654a416a5f4d137467b7f8201e200 100644 --- a/zh-cn/application-dev/quick-start/app-configuration-file.md +++ b/zh-cn/application-dev/quick-start/app-configuration-file.md @@ -34,7 +34,7 @@ app.json5配置文件包含以下标签。 | -------- | -------- | -------- | -------- | | bundleName | 标识应用的Bundle名称,用于标识应用的唯一性。该标签不可缺省。标签的值命名规则 :
- 字符串以字母、数字、下划线和符号“.”组成。
- 以字母开头。
- 最小长度7个字节,最大长度127个字节。
推荐采用反域名形式命名(如com.example.demo,建议第一级为域名后缀com,第二级为厂商/个人名,第三级为应用名,也可以多级)。
其中,随系统源码编译的应用建议命名为“com.ohos.demo”形式, ohos标识OpenHarmony系统应用。 | 字符串 | 该标签不可缺省。 | | bundleType| 标识应用的Bundle类型,用于区分应用或者原子化服务。该标签可选值为app和atomicService :
- app:当前Bundle为普通应用。
- atomicService:当前Bundle为原子化服务。| 字符串| 该标签可以缺省,缺省为app。 | -| debug | 标识应用是否可调试,该标签由IDE编译构建时生成。
- true:可调试。
- false:不可调式。 | 布尔值 | 该标签可以缺省,缺省为false。 | +| debug | 标识应用是否可调试,该标签由IDE编译构建时生成。
- true:可调试。
- false:不可调试。 | 布尔值 | 该标签可以缺省,缺省为false。 | | icon | 标识[应用的图标](../application-models/application-component-configuration-stage.md),标签值为图标资源文件的索引。 | 字符串 | 该标签不可缺省。 | | label | 标识[应用的名称](../application-models/application-component-configuration-stage.md),标签值为字符串资源的索引。 | 字符串 | 该标签不可缺省。 | | description | 标识应用的描述信息,标签值是字符串类型(最大255个字节)或对描述内容的字符串资源索引。 | 字符串 | 该标签可缺省,缺省值为空。 | diff --git a/zh-cn/application-dev/quick-start/arkts-style.md b/zh-cn/application-dev/quick-start/arkts-style.md index f50b027cdc5bbc338208a17d2acd2c2d4445ef47..8b69bb2bceb3642c0196e612104cec193503bfee 100644 --- a/zh-cn/application-dev/quick-start/arkts-style.md +++ b/zh-cn/application-dev/quick-start/arkts-style.md @@ -94,7 +94,7 @@ struct FancyUse { Text('FancyA') .globalFancy () .fontSize(30) - // 使用全局的@Styles封装的样式 + // 使用组件内的@Styles封装的样式 Text('FancyB') .fancy() .fontSize(30) diff --git a/zh-cn/application-dev/quick-start/deviceconfig-structure.md b/zh-cn/application-dev/quick-start/deviceconfig-structure.md index b6e981883ba5452c972efbccbd82fe24c5b1b733..d9fc4d0533c3769a16c547886ae1ff0ddab7cf0b 100644 --- a/zh-cn/application-dev/quick-start/deviceconfig-structure.md +++ b/zh-cn/application-dev/quick-start/deviceconfig-structure.md @@ -27,7 +27,7 @@ deviceConfig包含设备上的应用配置信息,可以包含default,tv,ca | process | 标识应用或者Ability的进程名。如果在deviceConfig标签下配置了process标签,则该应用的所有Ability都运行在这个进程中。如果在abilities标签下也为某个Ability配置了process标签,则该Ability就运行在这个进程中。该标签最大长度为31。 | 字符串 | 可缺省,缺省值为空。 | | keepAlive | 标识应用是否始终保持运行状态,仅支持系统应用配置,三方应用配置不生效。该标签为布尔类型,可缺省,缺省值为false,如果配置为true,应用将始终保持为运行状态,并在系统启动的时候被系统驱动起来,应用进程退出后,系统也会重新启动应用进程。 | 布尔值 | 可缺省,缺省值为false。 | | supportBackup | 标识应用是否支持备份和恢复。如果配置为"false",则不支持为该应用执行备份或恢复操作。 | 布尔值 | 可缺省,缺省值为false。 | -| compressNativeLibs | 标识libs库是否以压缩存储的方式打包到HAP。如果配置为"false",则libs库以不压缩的方式存储,HAP在安装时无需解压libs,运行时会直接从HAP内加载libs库。 | 布尔值 | 可缺省,缺省值为false。 | +| compressNativeLibs | 标识libs库是否以压缩存储的方式打包到HAP。如果配置为"false",则libs库以不压缩的方式存储,HAP在安装时无需解压libs,运行时会直接从HAP内加载libs库。 | 布尔值 | 可缺省,缺省值为true。 | | network | 标识网络安全性配置。该标签允许应用通过配置文件的安全声明来自定义其网络安全,无需修改应用代码。 | 对象 | 可缺省,缺省值为空。 | ## network对象的内部结构 diff --git a/zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md b/zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md index 41c1868ee8ddae1131ba0e2e7a511bfd3c3c9dfb..ad2ebafdbf256481a7592ed1e8526d9492d38043 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md +++ b/zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md @@ -197,7 +197,7 @@ grantUserGrantedPermission(tokenID: number, permissionName: Permissions, permiss | tokenID | number | 是 | 目标应用的身份标识。可通过应用的[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)获得。| | permissionName | Permissions | 是 | 被授予的权限名称,合法的权限名取值可在[系统权限定义列表](../../security/permission-list.md)中查询。 | | permissionFlags | number | 是 | 授权选项
- 0表示权限未经过用户主动设置。
- 1表示当次用户若选择禁止该权限,下次权限弹窗仍可以弹出申请用户授权。
- 2表示当次用户若选择禁止该权限,下次不会再弹出权限弹窗,需要用户在setting的权限管理中进行授权。
- 4表示当次权限设置为系统授权,用户不可更改这个权限授权状态。 | -| callback | AsyncCallback<void> | 是 | 授予应用user grant权限。当授予权限成功时,err为undefine;否则为错误对象。 | +| callback | AsyncCallback<void> | 是 | 授予应用user grant权限。当授予权限成功时,err为undefined;否则为错误对象。 | **错误码:** @@ -308,7 +308,7 @@ revokeUserGrantedPermission(tokenID: number, permissionName: Permissions, permis | tokenID | number | 是 | 目标应用的身份标识。可通过应用的[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)获得。 | | permissionName | Permissions | 是 | 被撤销的权限名称,合法的权限名取值可在[系统权限定义列表](../../security/permission-list.md)中查询。 | | permissionFlags | number | 是 | 授权选项
- 0表示权限未经过用户主动设置。
- 1表示当次用户若选择禁止该权限,下次权限弹窗仍可以弹出申请用户授权。
- 2表示当次用户若选择禁止该权限,下次不会再弹出权限弹窗,需要用户在setting的权限管理中进行授权。
- 4表示当次权限设置为系统授权,用户不可更改这个权限授权状态。 | -| callback | AsyncCallback<void> | 是 | 撤销应用user grant权限。当撤销权限成功时,err为undefine;否则为错误对象。 | +| callback | AsyncCallback<void> | 是 | 撤销应用user grant权限。当撤销权限成功时,err为undefined;否则为错误对象。 | **错误码:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-animator.md b/zh-cn/application-dev/reference/apis/js-apis-animator.md index 60f48b95676728d8e43f7c15edf5fbc7d374232d..f68d1303b3f40b41f77d6bb73c8fc30f84a360f3 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-animator.md +++ b/zh-cn/application-dev/reference/apis/js-apis-animator.md @@ -6,7 +6,7 @@ > > 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > -> 该模块不支持在[UIAbility](./js-apis-app-ability-uiAbility.md)中使用。 +> 该模块不支持在[UIAbility](./js-apis-app-ability-uiAbility.md)中使用,需要在创建组件实例后使用。 ## 导入模块 diff --git a/zh-cn/application-dev/reference/apis/js-apis-app-ability-wantAgent.md b/zh-cn/application-dev/reference/apis/js-apis-app-ability-wantAgent.md index 73551d324aa13221207c1e8148e634cf24d9791b..d25a277566bffa819c0e2f144f9c74eb9f7dab7f 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-app-ability-wantAgent.md +++ b/zh-cn/application-dev/reference/apis/js-apis-app-ability-wantAgent.md @@ -24,7 +24,7 @@ getWantAgent(info: WantAgentInfo, callback: AsyncCallback\): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------------- | ---- | ----------------------- | -| info | WantAgentInfo | 是 | WantAgent信息。 | +| info | [WantAgentInfo](js-apis-inner-wantAgent-wantAgentInfo.md) | 是 | WantAgent信息。 | | callback | AsyncCallback\ | 是 | 创建WantAgent的回调方法。 | **错误码:** @@ -596,7 +596,7 @@ getWant(agent: WantAgent): Promise\ | 类型 | 说明 | | ----------------------------------------------------------- | ------------------------------------------------------------ | -| Promise\ | 以Promise形式返回获取WantAgent对象的want。 | +| Promise\<[Want](js-apis-app-ability-want.md)\> | 以Promise形式返回获取WantAgent对象的want。 | **错误码:** @@ -841,7 +841,7 @@ trigger(agent: WantAgent, triggerInfo: TriggerInfo, callback?: AsyncCallback\ | 否 | 主动激发WantAgent实例的回调方法。 | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-dataShareExtensionAbility.md b/zh-cn/application-dev/reference/apis/js-apis-application-dataShareExtensionAbility.md index b13589178ab4ff55a44a90cf1fd65ac20ae44cdf..b1e7cfbc5c95d77bad979f3379bbed8c66f7a922 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-dataShareExtensionAbility.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-dataShareExtensionAbility.md @@ -78,10 +78,10 @@ export default class DataShareExtAbility extends DataShareExtensionAbility { name: DB_NAME, securityLevel: rdb.SecurityLevel.S1 }, function (err, data) { - console.log('getRdbStore done, data : ' + data); + console.info(`getRdbStore done, data : ${data}`); rdbStore = data; rdbStore.executeSql(DDL_TBL_CREATE, [], function (err) { - console.log('executeSql done, error message : ' + err); + console.error(`executeSql done, error message : ${err}`); }); if (callback) { callback(); @@ -122,11 +122,11 @@ let rdbStore; export default class DataShareExtAbility extends DataShareExtensionAbility { insert(uri, valueBucket, callback) { if (valueBucket === null) { - console.info('invalid valueBuckets'); + console.error('invalid valueBuckets'); return; } rdbStore.insert(TBL_NAME, valueBucket, function (err, ret) { - console.info('callback ret:' + ret); + console.info(`callback ret: ${ret}`); if (callback !== undefined) { callback(err, ret); } @@ -256,7 +256,7 @@ export default class DataShareExtAbility extends DataShareExtensionAbility { } rdbStore.query(TBL_NAME, predicates, columns, function (err, resultSet) { if (resultSet !== undefined) { - console.info('resultSet.rowCount: ' + resultSet.rowCount); + console.info(`resultSet.rowCount: ${resultSet.rowCount}`); } if (callback !== undefined) { callback(err, resultSet); @@ -297,14 +297,12 @@ let rdbStore; export default class DataShareExtAbility extends DataShareExtensionAbility { batchInsert(uri, valueBuckets, callback) { if (valueBuckets === null || valueBuckets.length === undefined) { - console.info('invalid valueBuckets'); + console.error('invalid valueBuckets'); return; } - let resultNum = valueBuckets.length; - valueBuckets.forEach(vb => { - rdbStore.insert(TBL_NAME, vb, function (err, ret) { + rdbStore.batchInsert(TBL_NAME, valueBuckets, function (err, ret) { if (callback !== undefined) { - callback(err, resultNum); + callback(err, ret); } }); }); @@ -333,7 +331,7 @@ normalizeUri?(uri: string, callback: AsyncCallback<string>): void export default class DataShareExtAbility extends DataShareExtensionAbility { normalizeUri(uri, callback) { let err = {'code':0}; - let ret = 'normalize+' + uri; + let ret = `normalize: ${uri}`; callback(err, ret); } }; @@ -360,7 +358,7 @@ denormalizeUri?(uri: string, callback: AsyncCallback<string>): void export default class DataShareExtAbility extends DataShareExtensionAbility { denormalizeUri(uri, callback) { let err = {'code':0}; - let ret = 'denormalize+' + uri; + let ret = `denormalize ${uri}`; callback(err, ret); } }; diff --git a/zh-cn/application-dev/reference/apis/js-apis-curve.md b/zh-cn/application-dev/reference/apis/js-apis-curve.md index 95946c8f4d90cf4607bd88ac978e9ace14ff77b7..b47d1db562e35cb2e39c6fde53cd41b09e1ec249 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-curve.md +++ b/zh-cn/application-dev/reference/apis/js-apis-curve.md @@ -16,7 +16,7 @@ import Curves from '@ohos.curves' ## Curves.initCurve9+ -initCurve(curve?: Curve):ICurve +initCurve(curve?: Curve): ICurve 插值曲线的初始化函数,可以根据入参创建一个插值曲线对象。 @@ -25,9 +25,9 @@ initCurve(curve?: Curve):ICurve **参数:** -| 参数名 | 类型 | 必填 | 默认值 | 说明 | -| ------ | ------------------------------------------------------------ | ---- | ------------ | ---------- | -| curve | [Curve](../arkui-ts/ts-appendix-enums.md#curve) | 否 | Curve.Linear | 曲线类型。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ----------------------------------------------- | ---- | ----------------------------------- | +| curve | [Curve](../arkui-ts/ts-appendix-enums.md#curve) | 否 | 曲线类型。
默认值:Curve.Linear | **返回值:** @@ -46,7 +46,7 @@ Curves.initCurve(Curve.EaseIn) // 创建一个默认先慢后快插值曲线 ##  Curves.stepsCurve9+ -stepsCurve(count: number, end: boolean):ICurve +stepsCurve(count: number, end: boolean): ICurve 构造阶梯曲线对象。 @@ -77,7 +77,7 @@ Curves.stepsCurve(9, true) //创建一个阶梯曲线 ## Curves.cubicBezierCurve9+ -cubicBezierCurve(x1: number, y1: number, x2: number, y2: number):ICurve +cubicBezierCurve(x1: number, y1: number, x2: number, y2: number): ICurve 构造三阶贝塞尔曲线对象,曲线的值必须处于0-1之间。 @@ -109,7 +109,7 @@ Curves.cubicBezierCurve(0.1, 0.0, 0.1, 1.0) // 创建一个三阶贝塞尔曲线 ##  Curves.springCurve9+ -springCurve(velocity: number, mass: number, stiffness: number, damping: number):ICurve +springCurve(velocity: number, mass: number, stiffness: number, damping: number): ICurve 构造弹簧曲线对象。 @@ -159,7 +159,7 @@ springMotion(response?: number, dampingFraction?: number, overlapDuration?: numb | 类型 | 说明 | | ---------------------------------- | ---------------- | -| [ICurve](#icurve)| 曲线对象。
**说明:** 弹性动画曲线为物理曲线,[animation](../arkui-ts/ts-animatorproperty.md)、[animateTo](../arkui-ts/ts-explicit-animation.md)中的duration参数不生效,动画持续时间取决于springMotion动画曲线参数和之前的速度。时间不能归一,故不能通过该曲线的[interpolate](#interpolate)函数获得插值。 | +| [ICurve](#icurve)| 曲线对象。
**说明:** 弹性动画曲线为物理曲线,[animation](../arkui-ts/ts-animatorproperty.md)、[animateTo](../arkui-ts/ts-explicit-animation.md)中的duration参数不生效,动画持续时间取决于springMotion动画曲线参数和之前的速度。时间不能归一,故不能通过该曲线的[interpolate](#interpolate9)函数获得插值。 | **示例:** @@ -204,7 +204,7 @@ Curves.responsiveSpringMotion() // 创建一个默认弹性跟手动画曲线 ## ICurve -### interpolate +### interpolate9+ interpolate(fraction: number): number @@ -246,9 +246,9 @@ init(curve?: Curve): string **参数:** -| 参数名 | 类型 | 必填 | 默认值 | 说明 | -| ------ | ------------------------------------------------------------ | ---- | ------------ | ---------- | -| curve |[Curve](../arkui-ts/ts-appendix-enums.md#curve) | 否 | Curve.Linear | 曲线类型。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ----------------------------------------------- | ---- | ----------------------------------- | +| curve | [Curve](../arkui-ts/ts-appendix-enums.md#curve) | 否 | 曲线类型。
默认值:Curve.Linear | ## Curves.steps(deprecated) diff --git a/zh-cn/application-dev/reference/apis/js-apis-data-DataShareResultSet.md b/zh-cn/application-dev/reference/apis/js-apis-data-DataShareResultSet.md index 3dcb1aae961c2031b4e0481e2b13c560bbb226c0..bbf4408ef4aa8b7484da6a233886af3b7253a3fb 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-data-DataShareResultSet.md +++ b/zh-cn/application-dev/reference/apis/js-apis-data-DataShareResultSet.md @@ -27,7 +27,7 @@ let dataShareHelper; let uri = ("datashare:///com.samples.datasharetest.DataShare"); await dataShare.createDataShareHelper(this.context, uri, (err, data) => { if (err != undefined) { - console.info("createDataShareHelper fail, error message : " + err); + console.error("createDataShareHelper fail, error message : " + err); } else { console.info("createDataShareHelper end, data : " + data); dataShareHelper = data; @@ -39,10 +39,10 @@ let da = new dataSharePredicates.DataSharePredicates(); let resultSet; da.equalTo("name", "ZhangSan"); dataShareHelper.query(uri, da, columns).then((data) => { - console.log("query end, data : " + data); + console.info("query end, data : " + data); resultSet = data; }).catch((err) => { - console.log("query fail, error message : " + err); + console.error("query fail, error message : " + err); }); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-data-dataShare.md b/zh-cn/application-dev/reference/apis/js-apis-data-dataShare.md index c020071d71df7945d50f2365d8de48b4c5176e05..d48b258739c33e07f602939d36afedf869b60797 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-data-dataShare.md +++ b/zh-cn/application-dev/reference/apis/js-apis-data-dataShare.md @@ -70,7 +70,7 @@ let uri = ("datashare:///com.samples.datasharetest.DataShare"); let dataShareHelper; try { dataShare.createDataShareHelper(this.context, uri, (err, data) => { - if (err != undefined) { + if (err !== undefined) { console.error(`createDataShareHelper error: code: ${err.code}, message: ${err.message} `); return; } @@ -260,7 +260,7 @@ const valueBucket = { } try { dataShareHelper.insert(uri, valueBucket).then((data) => { - console.log("insert succeed, data : " + data); + console.info("insert succeed, data : " + data); }). catch((err) => { console.error(`insert error: code: ${err.code}, message: ${err.message} `); }); @@ -296,7 +296,7 @@ let da = new dataSharePredicates.DataSharePredicates(); da.equalTo("name", "ZhangSan"); try { dataShareHelper.delete(uri, da, (err, data) => { - if (err != undefined) { + if (err !== undefined) { console.error(`delete error: code: ${err.code}, message: ${err.message} `); return; } @@ -339,7 +339,7 @@ let da = new dataSharePredicates.DataSharePredicates(); da.equalTo("name", "ZhangSan"); try { dataShareHelper.delete(uri, da).then((data) => { - console.log("delete succeed, data : " + data); + console.info("delete succeed, data : " + data); }). catch((err) => { console.error(`delete error: code: ${err.code}, message: ${err.message} `); }); @@ -377,11 +377,11 @@ let da = new dataSharePredicates.DataSharePredicates(); da.equalTo("name", "ZhangSan"); try { dataShareHelper.query(uri, da, columns, (err, data) => { - if (err != undefined) { + if (err !== undefined) { console.error(`query error: code: ${err.code}, message: ${err.message} `); return; } - console.log("query succeed, rowCount : " + data.rowCount); + console.info("query succeed, rowCount : " + data.rowCount); }); } catch (err) { console.error(`query error: code: ${err.code}, message: ${err.message} `); @@ -422,7 +422,7 @@ let da = new dataSharePredicates.DataSharePredicates(); da.equalTo("name", "ZhangSan"); try { dataShareHelper.query(uri, da, columns).then((data) => { - console.log("query succeed, rowCount : " + data.rowCount); + console.info("query succeed, rowCount : " + data.rowCount); }). catch((err) => { console.error(`query error: code: ${err.code}, message: ${err.message} `); }); @@ -465,11 +465,11 @@ const va = { } try { dataShareHelper.update(uri, da, va, (err, data) => { - if (err != undefined) { + if (err !== undefined) { console.error(`update error: code: ${err.code}, message: ${err.message} `); return; } - console.log("update succeed, data : " + data); + console.info("update succeed, data : " + data); }); } catch (err) { console.error(`update error: code: ${err.code}, message: ${err.message} `); @@ -515,7 +515,7 @@ const va = { } try { dataShareHelper.update(uri, da, va).then((data) => { - console.log("update succeed, data : " + data); + console.info("update succeed, data : " + data); }). catch((err) => { console.error(`update error: code: ${err.code}, message: ${err.message} `); }); @@ -550,11 +550,11 @@ let vbs = new Array({"name": "roe11", "age": 21, "salary": 20.5,}, {"name": "roe13", "age": 21, "salary": 20.5,}) try { dataShareHelper.batchInsert(uri, vbs, (err, data) => { - if (err != undefined) { + if (err !== undefined) { console.error(`batchInsert error: code: ${err.code}, message: ${err.message} `); return; } - console.log("batchInsert succeed, data : " + data); + console.info("batchInsert succeed, data : " + data); }); } catch (err) { console.error(`batchInsert error: code: ${err.code}, message: ${err.message} `); @@ -592,7 +592,7 @@ let vbs = new Array({"name": "roe11", "age": 21, "salary": 20.5,}, {"name": "roe13", "age": 21, "salary": 20.5,}) try { dataShareHelper.batchInsert(uri, vbs).then((data) => { - console.log("batchInsert succeed, data : " + data); + console.info("batchInsert succeed, data : " + data); }). catch((err) => { console.error(`batchInsert error: code: ${err.code}, message: ${err.message} `); }); @@ -622,10 +622,10 @@ normalizeUri(uri: string, callback: AsyncCallback<string>): void import UIAbility from '@ohos.app.ability.UIAbility' let uri = ("datashare:///com.samples.datasharetest.DataShare"); dataShareHelper.normalizeUri(uri, (err, data) => { - if (err != undefined) { - console.log("normalizeUri failed, error message : " + err); + if (err !== undefined) { + console.error("normalizeUri failed, error message : " + err); }else{ - console.log("normalizeUri = " + data); + console.info("normalizeUri = " + data); } }); ``` @@ -656,9 +656,9 @@ normalizeUri(uri: string): Promise<string> import UIAbility from '@ohos.app.ability.UIAbility' let uri = ("datashare:///com.samples.datasharetest.DataShare"); dataShareHelper.normalizeUri(uri).then((data) => { - console.log("normalizeUri = " + data); + console.info("normalizeUri = " + data); }).catch((err) => { - console.log("normalizeUri failed, error message : " + err); + console.error("normalizeUri failed, error message : " + err); }); ``` @@ -683,10 +683,10 @@ denormalizeUri(uri: string, callback: AsyncCallback<string>): void import UIAbility from '@ohos.app.ability.UIAbility' let uri = ("datashare:///com.samples.datasharetest.DataShare"); dataShareHelper.denormalizeUri(uri, (err, data) => { - if (err != undefined) { - console.log("denormalizeUri failed, error message : " + err); + if (err !== undefined) { + console.error("denormalizeUri failed, error message : " + err); }else{ - console.log("denormalizeUri = " + data); + console.info("denormalizeUri = " + data); } }); ``` @@ -717,9 +717,9 @@ denormalizeUri(uri: string): Promise<string> import UIAbility from '@ohos.app.ability.UIAbility' let uri = ("datashare:///com.samples.datasharetest.DataShare"); dataShareHelper.denormalizeUri(uri).then((data) => { - console.log("denormalizeUri = " + data); + console.info("denormalizeUri = " + data); }).catch((err) => { - console.log("denormalizeUri failed, error message : " + err); + console.error("denormalizeUri failed, error message : " + err); }); ``` @@ -744,7 +744,7 @@ notifyChange(uri: string, callback: AsyncCallback<void>): void import UIAbility from '@ohos.app.ability.UIAbility' let uri = ("datashare:///com.samples.datasharetest.DataShare"); dataShareHelper.notifyChange(uri, () => { - console.log("***** notifyChange *****"); + console.info("***** notifyChange *****"); }); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-display.md b/zh-cn/application-dev/reference/apis/js-apis-display.md index 971af855e30f098cc3baa450bf883e1d4bf201bd..7859c21d684b29f021619b5206e2174bcaf888d3 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-display.md +++ b/zh-cn/application-dev/reference/apis/js-apis-display.md @@ -436,7 +436,7 @@ getCutoutInfo(callback: AsyncCallback<CutoutInfo>): void | 参数名 | 类型 | 必填 | 说明 | | ----------- | --------------------------- | ---- | ------------------------------------------------------------ | -| callback | AsyncCallback<[CutoutInfo](#cutoutinfo9)> | 是 | 回调函数。返回描述不可用屏幕区域的CutoutInfo对象。。 | +| callback | AsyncCallback<[CutoutInfo](#cutoutinfo9)> | 是 | 回调函数。返回描述不可用屏幕区域的CutoutInfo对象。 | **错误码:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-distributedKVStore.md b/zh-cn/application-dev/reference/apis/js-apis-distributedKVStore.md index 11ef749fc6613fa46e80864e16e6dafee4b9a5ed..cc13105feb6a465663924218f3ffc5c143f5a703 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-distributedKVStore.md +++ b/zh-cn/application-dev/reference/apis/js-apis-distributedKVStore.md @@ -13,6 +13,7 @@ > **说明:** > > 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +>
本模块中所有需要获取deviceId的接口,都仅系统应用可用。 ## 导入模块 @@ -41,7 +42,7 @@ import distributedKVStore from '@ohos.data.distributedKVStore'; | --------------------- | ------- | --------------------------------------- | | MAX_KEY_LENGTH | 1024 | 数据库中Key允许的最大长度,单位字节。 | | MAX_VALUE_LENGTH | 4194303 | 数据库中Value允许的最大长度,单位字节。 | -| MAX_KEY_LENGTH_DEVICE | 896 | 最大设备密钥长度,单位字节。 | +| MAX_KEY_LENGTH_DEVICE | 896 | 设备协同数据库中key允许的最大长度,单位字节。 | | MAX_STORE_ID_LENGTH | 128 | 数据库标识符允许的最大长度,单位字节。 | | MAX_QUERY_LENGTH | 512000 | 最大查询长度,单位字节。 | | MAX_BATCH_SIZE | 128 | 最大批处理操作数量。 | @@ -137,10 +138,10 @@ import distributedKVStore from '@ohos.data.distributedKVStore'; | 名称 | 说明 | | -------: | ------------------------------------------------------------ | -| S1 | 表示数据库的安全级别为低级别,当数据泄露时会产生较低影响。例如,包含壁纸等系统数据的数据库。 | -| S2 | 表示数据库的安全级别为中级别,当数据泄露时会产生较大影响。例如,包含录音、视频等用户生成数据或通话记录等信息的数据库。 | -| S3 | 表示数据库的安全级别为高级别,当数据泄露时会产生重大影响。例如,包含用户运动、健康、位置等信息的数据库。 | -| S4 | 表示数据库的安全级别为关键级别,当数据泄露时会产生严重影响。例如,包含认证凭据、财务数据等信息的数据库。 | +| S1 | 表示数据库的安全级别为低级别,数据的泄露、篡改、破坏、销毁可能会给个人或组织导致有限的不利影响。
例如,性别、国籍,用户申请记录等。 | +| S2 | 表示数据库的安全级别为中级别,数据的泄露、篡改、破坏、销毁可能会给个人或组织导致严重的不利影响。
例如,个人详细通信地址,姓名昵称等。 | +| S3 | 表示数据库的安全级别为高级别,数据的泄露、篡改、破坏、销毁可能会给个人或组织导致严峻的不利影响。
例如,个人实时精确定位信息、运动轨迹等。 | +| S4 | 表示数据库的安全级别为关键级别,业界法律法规中定义的特殊数据类型,涉及个人的最私密领域的信息或者一旦泄露、篡改、破坏、销毁可能会给个人或组织造成重大的不利影响数据。
例如,政治观点、宗教、和哲学信仰、工会成员资格、基因数据、生物信息、健康和性生活状况、性取向等或设备认证鉴权、个人的信用卡等财务信息。 | ## Options @@ -151,10 +152,10 @@ import distributedKVStore from '@ohos.data.distributedKVStore'; | createIfMissing | boolean | 否 | 当数据库文件不存在时是否创建数据库,默认为true,即创建。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core | | encrypt | boolean | 否 | 设置数据库文件是否加密,默认为false,即不加密。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core | | backup | boolean | 否 | 设置数据库文件是否备份,默认为true,即备份。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core | -| autoSync | boolean | 否 | 设置数据库文件是否自动同步。默认为false,即手动同步;设置为true时,表示自动同步。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core
**需要权限**: ohos.permission.DISTRIBUTED_DATASYNC | +| autoSync | boolean | 否 | 设置数据库文件是否自动同步。默认为false,即手动同步。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core
**需要权限**: ohos.permission.DISTRIBUTED_DATASYNC | | kvStoreType | [KVStoreType](#kvstoretype) | 否 | 设置要创建的数据库类型,默认为DEVICE_COLLABORATION,即多设备协同数据库。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core | -| securityLevel | [SecurityLevel](#securitylevel) | 是 |设置数据库安全级别。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core | -| schema | [Schema](#schema) | 否 | 设置定义存储在数据库中的值,默认为undefined, 即不使用Schema。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore | +| securityLevel | [SecurityLevel](#securitylevel) | 是 | 设置数据库安全级别。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core | +| schema | [Schema](#schema) | 否 | 设置定义存储在数据库中的值,默认为undefined,即不使用Schema。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore | ## Schema @@ -226,23 +227,23 @@ appendChild(child: FieldNode): boolean **示例:** ```js -import ddm from '@ohos.data.distributedKVStore'; +import distributedKVStore from '@ohos.data.distributedKVStore'; try { - let node = new ddm.FieldNode("root"); - let child1 = new ddm.FieldNode("child1"); - let child2 = new ddm.FieldNode("child2"); - let child3 = new ddm.FieldNode("child3"); + let node = new distributedKVStore.FieldNode("root"); + let child1 = new distributedKVStore.FieldNode("child1"); + let child2 = new distributedKVStore.FieldNode("child2"); + let child3 = new distributedKVStore.FieldNode("child3"); node.appendChild(child1); node.appendChild(child2); node.appendChild(child3); - console.log("appendNode " + JSON.stringify(node)); + console.info("appendNode " + JSON.stringify(node)); child1 = null; child2 = null; child3 = null; node = null; } catch (e) { - console.log("AppendChild " + e); + console.error("AppendChild " + e); } ``` @@ -276,7 +277,7 @@ import UIAbility from '@ohos.app.ability.UIAbility'; let kvManager; export default class EntryAbility extends UIAbility { onCreate() { - console.log("MyAbilityStage onCreate") + console.info("MyAbilityStage onCreate") let context = this.context const kvManagerConfig = { context: context, @@ -284,7 +285,7 @@ export default class EntryAbility extends UIAbility { } try { kvManager = distributedKVStore.createKVManager(kvManagerConfig); - console.log("Succeeded in creating KVManager"); + console.info("Succeeded in creating KVManager"); } catch (e) { console.error(`Failed to create KVManager.code is ${e.code},message is ${e.message}`); } @@ -304,7 +305,7 @@ const kvManagerConfig = { } try { kvManager = distributedKVStore.createKVManager(kvManagerConfig); - console.log("Succeeded in creating KVManager"); + console.info("Succeeded in creating KVManager"); } catch (e) { console.error(`Failed to create KVManager.code is ${e.code},message is ${e.message}`); } @@ -316,7 +317,7 @@ try { ### getKVStore -getKVStore<T >(storeId: string, options: Options, callback: AsyncCallback<T>): void +getKVStore<T>(storeId: string, options: Options, callback: AsyncCallback<T>): void 通过指定Options和storeId,创建并获取分布式键值数据库,使用callback异步回调。 @@ -355,20 +356,20 @@ try { }; kvManager.getKVStore('storeId', options, function (err, store) { if (err) { - console.error(`Fail to get KVStore.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get KVStore.code is ${err.code},message is ${err.message}`); return; } - console.log("Succeeded in getting KVStore"); + console.info("Succeeded in getting KVStore"); kvStore = store; }); } catch (e) { - console.log(`An unexpected error occurred.code is ${e.code},message is ${e.message}`); + console.error(`An unexpected error occurred.code is ${e.code},message is ${e.message}`); } ``` ### getKVStore -getKVStore<T >(storeId: string, options: Options): Promise<T> +getKVStore<T>(storeId: string, options: Options): Promise<T> 通过指定Options和storeId,创建并获取分布式键值数据库,使用Promise异步回调。 @@ -411,13 +412,13 @@ try { securityLevel: distributedKVStore.SecurityLevel.S2, }; kvManager.getKVStore('storeId', options).then((store) => { - console.log("Succeeded in getting KVStore"); + console.info("Succeeded in getting KVStore"); kvStore = store; }).catch((err) => { - console.error(`Fail to get KVStore.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get KVStore.code is ${err.code},message is ${err.message}`); }); } catch (e) { - console.log(`An unexpected error occurred.code is ${e.code},message is ${e.message}`); + console.error(`An unexpected error occurred.code is ${e.code},message is ${e.message}`); } ``` @@ -453,14 +454,20 @@ const options = { } try { kvManager.getKVStore('storeId', options, async function (err, store) { - console.log('Succeeded in getting KVStore'); + if (err != undefined) { + console.error(`Failed to get KVStore.code is ${err.code},message is ${err.message}`); + return; + } + console.info('Succeeded in getting KVStore'); kvStore = store; - kvManager.closeKVStore('appId', 'storeId', function (err, data) { + kvStore = null; + store = null; + kvManager.closeKVStore('appId', 'storeId', function (err) { if (err != undefined) { - console.error(`Fail to close KVStore.code is ${err.code},message is ${err.message}`); + console.error(`Failed to close KVStore.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in closing KVStore'); + console.info('Succeeded in closing KVStore'); }); }); } catch (e) { @@ -505,18 +512,20 @@ const options = { } try { kvManager.getKVStore('storeId', options).then(async (store) => { - console.log('Succeeded in getting KVStore'); + console.info('Succeeded in getting KVStore'); kvStore = store; + kvStore = null; + store = null; kvManager.closeKVStore('appId', 'storeId').then(() => { - console.log('Succeeded in closing KVStore'); + console.info('Succeeded in closing KVStore'); }).catch((err) => { - console.error(`Fail to close KVStore.code is ${err.code},message is ${err.message}`); + console.error(`Failed to close KVStore.code is ${err.code},message is ${err.message}`); }); }).catch((err) => { - console.error(`Fail to get KVStore.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get KVStore.code is ${err.code},message is ${err.message}`); }); } catch (e) { - console.error(`Fail to close KVStore.code is ${e.code},message is ${e.message}`); + console.error(`Failed to close KVStore.code is ${e.code},message is ${e.message}`); } ``` @@ -561,21 +570,23 @@ const options = { try { kvManager.getKVStore('store', options, async function (err, store) { if (err != undefined) { - console.error(`Fail to get KVStore.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get KVStore.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in getting KVStore'); + console.info('Succeeded in getting KVStore'); kvStore = store; - kvManager.deleteKVStore('appId', 'storeId', function (err, data) { + kvStore = null; + store = null; + kvManager.deleteKVStore('appId', 'storeId', function (err) { if (err != undefined) { - console.error(`Fail to delete KVStore.code is ${err.code},message is ${err.message}`); + console.error(`Failed to delete KVStore.code is ${err.code},message is ${err.message}`); return; } - console.log(`Succeeded in deleting KVStore`); + console.info(`Succeeded in deleting KVStore`); }); }); } catch (e) { - console.error(`Fail to delete KVStore.code is ${e.code},message is ${e.message}`); + console.error(`Failed to delete KVStore.code is ${e.code},message is ${e.message}`); } ``` @@ -624,18 +635,20 @@ const options = { } try { kvManager.getKVStore('storeId', options).then(async (store) => { - console.log('Succeeded in getting KVStore'); + console.info('Succeeded in getting KVStore'); kvStore = store; + kvStore = null; + store = null; kvManager.deleteKVStore('appId', 'storeId').then(() => { - console.log('Succeeded in deleting KVStore'); + console.info('Succeeded in deleting KVStore'); }).catch((err) => { - console.error(`Fail to delete KVStore.code is ${err.code},message is ${err.message}`); + console.error(`Failed to delete KVStore.code is ${err.code},message is ${err.message}`); }); }).catch((err) => { - console.error(`Fail to get KVStore.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get KVStore.code is ${err.code},message is ${err.message}`); }); } catch (e) { - console.error(`Fail to delete KVStore.code is ${e.code},message is ${e.message}`); + console.error(`Failed to delete KVStore.code is ${e.code},message is ${e.message}`); } ``` @@ -661,14 +674,14 @@ let kvManager; try { kvManager.getAllKVStoreId('appId', function (err, data) { if (err != undefined) { - console.error(`Fail to get AllKVStoreId.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get AllKVStoreId.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in getting AllKVStoreId'); - console.log(`GetAllKVStoreId size = ${data.length}`); + console.info('Succeeded in getting AllKVStoreId'); + console.info(`GetAllKVStoreId size = ${data.length}`); }); } catch (e) { - console.error(`Fail to get AllKVStoreId.code is ${e.code},message is ${e.message}`); + console.error(`Failed to get AllKVStoreId.code is ${e.code},message is ${e.message}`); } ``` @@ -697,15 +710,15 @@ getAllKVStoreId(appId: string): Promise<string[]> ```js let kvManager; try { - console.log('GetAllKVStoreId'); + console.info('GetAllKVStoreId'); kvManager.getAllKVStoreId('appId').then((data) => { - console.log('Succeeded in getting AllKVStoreId'); - console.log(`GetAllKVStoreId size = ${data.length}`); + console.info('Succeeded in getting AllKVStoreId'); + console.info(`GetAllKVStoreId size = ${data.length}`); }).catch((err) => { - console.error(`Fail to get AllKVStoreId.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get AllKVStoreId.code is ${err.code},message is ${err.message}`); }); } catch (e) { - console.error(`Fail to get AllKVStoreId.code is ${e.code},message is ${e.message}`); + console.error(`Failed to get AllKVStoreId.code is ${e.code},message is ${e.message}`); } ``` @@ -713,7 +726,7 @@ try { on(event: 'distributedDataServiceDie', deathCallback: Callback<void>): void -订阅服务状态变更通知。 +订阅服务状态变更通知。如果服务终止,需要重新注册数据变更通知和同步完成事件回调通知,并且同步操作会返回失败。 **系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore @@ -729,13 +742,13 @@ on(event: 'distributedDataServiceDie', deathCallback: Callback<void>): voi ```js let kvManager; try { - console.log('KVManagerOn'); + console.info('KVManagerOn'); const deathCallback = function () { - console.log('death callback call'); + console.info('death callback call'); } kvManager.on('distributedDataServiceDie', deathCallback); } catch (e) { - console.log(`An unexpected error occurred.code is ${e.code},message is ${e.message}`); + console.error(`An unexpected error occurred.code is ${e.code},message is ${e.message}`); } ``` @@ -743,7 +756,7 @@ try { off(event: 'distributedDataServiceDie', deathCallback?: Callback<void>): void -取消订阅服务状态变更通知。 +取消订阅服务状态变更通知。参数中的deathCallback必须是已经订阅过的deathCallback,否则会取消订阅失败。 **系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore @@ -752,26 +765,26 @@ off(event: 'distributedDataServiceDie', deathCallback?: Callback<void>): v | 参数名 | 类型 | 必填 | 说明 | | ------------- | -------------------- | ---- | ------------------------------------------------------------ | | event | string | 是 | 取消订阅的事件名,固定为'distributedDataServiceDie',即服务状态变更事件。 | -| deathCallback | Callback<void> | 否 | 回调函数。 | +| deathCallback | Callback<void> | 否 | 回调函数。如果该参数不填,那么会将之前订阅过的所有的deathCallback取消订阅。 | **示例:** ```js let kvManager; try { - console.log('KVManagerOff'); + console.info('KVManagerOff'); const deathCallback = function () { - console.log('death callback call'); + console.info('death callback call'); } kvManager.off('distributedDataServiceDie', deathCallback); } catch (e) { - console.log(`An unexpected error occurred.code is ${e.code},message is ${e.message}`); + console.error(`An unexpected error occurred.code is ${e.code},message is ${e.message}`); } ``` ## KVStoreResultSet -提供获取数据库结果集的相关方法,包括查询和移动数据读取位置等。 +提供获取数据库结果集的相关方法,包括查询和移动数据读取位置等。同时允许打开的结果集的最大数量为8个。 在调用KVStoreResultSet的方法前,需要先通过[getKVStore](#getkvstore)构建一个SingleKVStore或者DeviceKVStore实例。 @@ -795,16 +808,17 @@ getCount(): number let kvStore; try { let resultSet; + let count; kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('getResultSet succeed.'); + console.info('getResultSet succeed.'); resultSet = result; + count = resultSet.getCount(); + console.info("getCount succeed:" + count); }).catch((err) => { - console.log('getResultSet failed: ' + err); + console.error('getResultSet failed: ' + err); }); - const count = resultSet.getCount(); - console.log("getCount succeed:" + count); } catch (e) { - console.log("getCount failed: " + e); + console.error("getCount failed: " + e); } ``` @@ -812,7 +826,7 @@ try { getPosition(): number -获取结果集中当前的读取位置。 +获取结果集中当前的读取位置。读取位置会因[moveToFirst](#movetofirst)、[moveToLast](#movetolast)等操作而发生变化。 **系统能力:** SystemCapability.DistributedDataManager.KVStore.Core @@ -820,7 +834,7 @@ getPosition(): number | 类型 | 说明 | | ------ | ------------------ | -| number | 返回当前读取位置。 | +| number | 返回当前读取位置。取值范围>= -1,值为 -1 时表示还未开始读取,值为 0 时表示第一行。 | **示例:** @@ -828,16 +842,17 @@ getPosition(): number let kvStore; try { let resultSet; + let position; kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('getResultSet succeeded.'); + console.info('getResultSet succeeded.'); resultSet = result; + position = resultSet.getPosition(); + console.info("getPosition succeed:" + position); }).catch((err) => { - console.log('getResultSet failed: ' + err); + console.error('getResultSet failed: ' + err); }); - const position = resultSet.getPosition(); - console.log("getPosition succeed:" + position); } catch (e) { - console.log("getPosition failed: " + e); + console.error("getPosition failed: " + e); } ``` @@ -861,16 +876,17 @@ moveToFirst(): boolean let kvStore; try { let resultSet; + let moved; kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('getResultSet succeed.'); + console.info('getResultSet succeed.'); resultSet = result; + moved = resultSet.moveToFirst(); + console.info("moveToFirst succeed: " + moved); }).catch((err) => { - console.log('getResultSet failed: ' + err); + console.error('getResultSet failed: ' + err); }); - const moved1 = resultSet.moveToFirst(); - console.log("moveToFirst succeed: " + moved1); } catch (e) { - console.log("moveToFirst failed " + e); + console.error("moveToFirst failed " + e); } ``` @@ -894,16 +910,17 @@ moveToLast(): boolean let kvStore; try { let resultSet; + let moved; kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('getResultSet succeed.'); + console.info('getResultSet succeed.'); resultSet = result; + moved = resultSet.moveToLast(); + console.info("moveToLast succeed:" + moved); }).catch((err) => { - console.log('getResultSet failed: ' + err); + console.error('getResultSet failed: ' + err); }); - const moved2 = resultSet.moveToLast(); - console.log("moveToLast succeed:" + moved2); } catch (e) { - console.log("moveToLast failed: " + e); + console.error("moveToLast failed: " + e); } ``` @@ -911,7 +928,7 @@ try { moveToNext(): boolean -将读取位置移动到下一行。如果结果集为空,则返回false。 +将读取位置移动到下一行。如果结果集为空,则返回false。适用于全量获取数据库结果集的场景。 **系统能力:** SystemCapability.DistributedDataManager.KVStore.Core @@ -927,16 +944,20 @@ moveToNext(): boolean let kvStore; try { let resultSet; + let moved; kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('getResultSet succeed.'); + console.info('getResultSet succeed.'); resultSet = result; + do { + moved = resultSet.moveToNext(); + const entry = resultSet.getEntry(); + console.info("moveToNext succeed: " + moved); + } while (moved) }).catch((err) => { - console.log('getResultSet failed: ' + err); + console.error('getResultSet failed: ' + err); }); - const moved3 = resultSet.moveToNext(); - console.log("moveToNext succeed: " + moved3); } catch (e) { - console.log("moveToNext failed: " + e); + console.error("moveToNext failed: " + e); } ``` @@ -944,7 +965,7 @@ try { moveToPrevious(): boolean -将读取位置移动到上一行。如果结果集为空,则返回false。 +将读取位置移动到上一行。如果结果集为空,则返回false。适用于全量获取数据库结果集的场景。 **系统能力:** SystemCapability.DistributedDataManager.KVStore.Core @@ -960,16 +981,18 @@ moveToPrevious(): boolean let kvStore; try { let resultSet; + let moved; kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('getResultSet succeed.'); + console.info('getResultSet succeed.'); resultSet = result; + moved = resultSet.moveToLast(); + moved = resultSet.moveToPrevious(); + console.info("moveToPrevious succeed:" + moved); }).catch((err) => { - console.log('getResultSet failed: ' + err); + console.error('getResultSet failed: ' + err); }); - const moved4 = resultSet.moveToPrevious(); - console.log("moveToPrevious succeed:" + moved4); } catch (e) { - console.log("moveToPrevious failed: " + e); + console.error("moveToPrevious failed: " + e); } ``` @@ -977,7 +1000,7 @@ try { move(offset: number): boolean -将读取位置移动到当前位置的相对偏移量。 +将读取位置移动到当前位置的相对偏移量。即当前游标位置向下偏移 offset 行。 **系统能力:** SystemCapability.DistributedDataManager.KVStore.Core @@ -999,16 +1022,17 @@ move(offset: number): boolean let kvStore; try { let resultSet; + let moved; kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('Succeeded in getting resultSet'); + console.info('Succeeded in getting resultSet'); resultSet = result; + moved = resultSet.move(2); //若当前位置为0,将读取位置从绝对位置为0的位置移动2行,即移动到绝对位置为2,行数为3的位置 + console.info(`Succeeded in moving.moved = ${moved}`); }).catch((err) => { - console.error(`Fail to get resultSet.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get resultSet.code is ${err.code},message is ${err.message}`); }); - const moved5 = resultSet.move(1); - console.log(`Succeeded in moving.moved5 = ${moved5}`); } catch (e) { - console.log(`Fail to move.code is ${e.code},message is ${e.message}`); + console.error(`Failed to move.code is ${e.code},message is ${e.message}`); } ``` @@ -1038,16 +1062,17 @@ moveToPosition(position: number): boolean let kvStore; try { let resultSet; + let moved; kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('Succeeded in getting resultSet'); + console.info('Succeeded in getting resultSet'); resultSet = result; + moved = resultSet.moveToPosition(1); + console.info(`Succeeded in moving to position.moved=${moved}`); }).catch((err) => { - console.error(`Fail to get resultSet.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get resultSet.code is ${err.code},message is ${err.message}`); }); - const moved6 = resultSet.moveToPosition(1); - console.log(`Succeeded in moving to position.moved6=${moved6}`); } catch (e) { - console.error(`Fail to move to position.code is ${e.code},message is ${e.message}`); + console.error(`Failed to move to position.code is ${e.code},message is ${e.message}`); } ``` @@ -1071,16 +1096,17 @@ isFirst(): boolean let kvStore; try { let resultSet; + let isfirst; kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('getResultSet succeed.'); + console.info('getResultSet succeed.'); resultSet = result; + isfirst = resultSet.isFirst(); + console.info("Check isFirst succeed:" + isfirst); }).catch((err) => { - console.log('getResultSet failed: ' + err); + console.error('getResultSet failed: ' + err); }); - const isfirst = resultSet.isFirst(); - console.log("Check isFirst succeed:" + isfirst); } catch (e) { - console.log("Check isFirst failed: " + e); + console.error("Check isFirst failed: " + e); } ``` @@ -1104,16 +1130,17 @@ isLast(): boolean let kvStore; try { let resultSet; + let islast; kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('getResultSet succeed.'); + console.info('getResultSet succeed.'); resultSet = result; + islast = resultSet.isLast(); + console.info("Check isLast succeed: " + islast); }).catch((err) => { - console.log('getResultSet failed: ' + err); + console.error('getResultSet failed: ' + err); }); - const islast = resultSet.isLast(); - console.log("Check isLast succeed: " + islast); } catch (e) { - console.log("Check isLast failed: " + e); + console.error("Check isLast failed: " + e); } ``` @@ -1138,15 +1165,15 @@ let kvStore; try { let resultSet; kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('getResultSet succeed.'); + console.info('getResultSet succeed.'); resultSet = result; + const isbeforefirst = resultSet.isBeforeFirst(); + console.info("Check isBeforeFirst succeed: " + isbeforefirst); }).catch((err) => { - console.log('getResultSet failed: ' + err); + console.error('getResultSet failed: ' + err); }); - const isbeforefirst = resultSet.isBeforeFirst(); - console.log("Check isBeforeFirst succeed: " + isbeforefirst); } catch (e) { - console.log("Check isBeforeFirst failed: " + e); + console.error("Check isBeforeFirst failed: " + e); } ``` @@ -1171,13 +1198,13 @@ let kvStore; try { let resultSet; kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('getResultSet succeed.'); + console.info('getResultSet succeed.'); resultSet = result; + const isafterlast = resultSet.isAfterLast(); + console.info("Check isAfterLast succeed:" + isafterlast); }).catch((err) => { - console.log('getResultSet failed: ' + err); + console.error('getResultSet failed: ' + err); }); - const isafterlast = resultSet.isAfterLast(); - console.log("Check isAfterLast succeed:" + isafterlast); } catch (e) { console.log("Check isAfterLast failed: " + e); } @@ -1204,21 +1231,21 @@ let kvStore; try { let resultSet; kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('getResultSet succeed.'); + console.info('getResultSet succeed.'); resultSet = result; + const entry = resultSet.getEntry(); + console.info("getEntry succeed:" + JSON.stringify(entry)); }).catch((err) => { - console.log('getResultSet failed: ' + err); + console.error('getResultSet failed: ' + err); }); - const entry = resultSet.getEntry(); - console.log("getEntry succeed:" + JSON.stringify(entry)); } catch (e) { - console.log("getEntry failed: " + e); + console.error("getEntry failed: " + e); } ``` ## Query -使用谓词表示数据库查询,提供创建Query实例、查询数据库中的数据和添加谓词的方法。 +使用谓词表示数据库查询,提供创建Query实例、查询数据库中的数据和添加谓词的方法。一个Query对象中谓词数量上限为256个。 **系统能力:** SystemCapability.DistributedDataManager.KVStore.Core @@ -1250,12 +1277,12 @@ reset(): Query try { let query = new distributedKVStore.Query(); query.equalTo("key", "value"); - console.log("query is " + query.getSqlLike()); + console.info("query is " + query.getSqlLike()); query.reset(); - console.log("query is " + query.getSqlLike()); + console.info("query is " + query.getSqlLike()); query = null; } catch (e) { - console.log("simply calls should be ok :" + e); + console.error("simply calls should be ok :" + e); } ``` @@ -1286,10 +1313,10 @@ equalTo(field: string, value: number|string|boolean): Query try { let query = new distributedKVStore.Query(); query.equalTo("field", "value"); - console.log(`query is ${query.getSqlLike()}`); + console.info(`query is ${query.getSqlLike()}`); query = null; } catch (e) { - console.error(`duplicated calls should be ok.ode is ${e.code},message is ${e.message}`); + console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`); } ``` @@ -1320,7 +1347,7 @@ notEqualTo(field: string, value: number|string|boolean): Query try { let query = new distributedKVStore.Query(); query.notEqualTo("field", "value"); - console.log(`query is ${query.getSqlLike()}`); + console.info(`query is ${query.getSqlLike()}`); query = null; } catch (e) { console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`); @@ -1353,7 +1380,7 @@ greaterThan(field: string, value: number|string|boolean): Query try { let query = new distributedKVStore.Query(); query.greaterThan("field", "value"); - console.log(`query is ${query.getSqlLike()}`); + console.info(`query is ${query.getSqlLike()}`); query = null; } catch (e) { console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`); @@ -1388,7 +1415,7 @@ lessThan(field: string, value: number|string): Query try { let query = new distributedKVStore.Query(); query.lessThan("field", "value"); - console.log(`query is ${query.getSqlLike()}`); + console.info(`query is ${query.getSqlLike()}`); query = null; } catch (e) { console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`); @@ -1423,7 +1450,7 @@ greaterThanOrEqualTo(field: string, value: number|string): Query try { let query = new distributedKVStore.Query(); query.greaterThanOrEqualTo("field", "value"); - console.log(`query is ${query.getSqlLike()}`); + console.info(`query is ${query.getSqlLike()}`); query = null; } catch (e) { console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`); @@ -1458,7 +1485,7 @@ lessThanOrEqualTo(field: string, value: number|string): Query try { let query = new distributedKVStore.Query(); query.lessThanOrEqualTo("field", "value"); - console.log(`query is ${query.getSqlLike()}`); + console.info(`query is ${query.getSqlLike()}`); query = null; } catch (e) { console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`); @@ -1491,7 +1518,7 @@ isNull(field: string): Query try { let query = new distributedKVStore.Query(); query.isNull("field"); - console.log(`query is ${query.getSqlLike()}`); + console.info(`query is ${query.getSqlLike()}`); query = null; } catch (e) { console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`); @@ -1525,7 +1552,7 @@ inNumber(field: string, valueList: number[]): Query try { let query = new distributedKVStore.Query(); query.inNumber("field", [0, 1]); - console.log(`query is ${query.getSqlLike()}`); + console.info(`query is ${query.getSqlLike()}`); query = null; } catch (e) { console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`); @@ -1559,7 +1586,7 @@ inString(field: string, valueList: string[]): Query try { let query = new distributedKVStore.Query(); query.inString("field", ['test1', 'test2']); - console.log(`query is ${query.getSqlLike()}`); + console.info(`query is ${query.getSqlLike()}`); query = null; } catch (e) { console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`); @@ -1593,7 +1620,7 @@ notInNumber(field: string, valueList: number[]): Query try { let query = new distributedKVStore.Query(); query.notInNumber("field", [0, 1]); - console.log(`query is ${query.getSqlLike()}`); + console.info(`query is ${query.getSqlLike()}`); query = null; } catch (e) { console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`); @@ -1627,7 +1654,7 @@ notInString(field: string, valueList: string[]): Query try { let query = new distributedKVStore.Query(); query.notInString("field", ['test1', 'test2']); - console.log(`query is ${query.getSqlLike()}`); + console.info(`query is ${query.getSqlLike()}`); query = null; } catch (e) { console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`); @@ -1661,7 +1688,7 @@ like(field: string, value: string): Query try { let query = new distributedKVStore.Query(); query.like("field", "value"); - console.log(`query is ${query.getSqlLike()}`); + console.info(`query is ${query.getSqlLike()}`); query = null; } catch (e) { console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`); @@ -1695,7 +1722,7 @@ unlike(field: string, value: string): Query try { let query = new distributedKVStore.Query(); query.unlike("field", "value"); - console.log(`query is ${query.getSqlLike()}`); + console.info(`query is ${query.getSqlLike()}`); query = null; } catch (e) { console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`); @@ -1724,10 +1751,10 @@ try { query.notEqualTo("field", "value1"); query.and(); query.notEqualTo("field", "value2"); - console.log("query is " + query.getSqlLike()); + console.info("query is " + query.getSqlLike()); query = null; } catch (e) { - console.log("duplicated calls should be ok :" + e); + console.error("duplicated calls should be ok :" + e); } ``` @@ -1753,10 +1780,10 @@ try { query.notEqualTo("field", "value1"); query.or(); query.notEqualTo("field", "value2"); - console.log("query is " + query.getSqlLike()); + console.info("query is " + query.getSqlLike()); query = null; } catch (e) { - console.log("duplicated calls should be ok :" + e); + console.error("duplicated calls should be ok :" + e); } ``` @@ -1787,7 +1814,7 @@ try { let query = new distributedKVStore.Query(); query.notEqualTo("field", "value"); query.orderByAsc("field"); - console.log(`query is ${query.getSqlLike()}`); + console.info(`query is ${query.getSqlLike()}`); query = null; } catch (e) { console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`); @@ -1821,7 +1848,7 @@ try { let query = new distributedKVStore.Query(); query.notEqualTo("field", "value"); query.orderByDesc("field"); - console.log(`query is ${query.getSqlLike()}`); + console.info(`query is ${query.getSqlLike()}`); query = null; } catch (e) { console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`); @@ -1832,7 +1859,7 @@ try { limit(total: number, offset: number): Query -构造一个Query对象来指定结果的数量和开始位置。 +构造一个Query对象来指定结果的数量和开始位置。该接口必须要在Query对象查询和升降序等操作之后调用,调用limit接口后,不可再对Query对象进行查询和升降序等操作。 **系统能力:** SystemCapability.DistributedDataManager.KVStore.Core @@ -1858,7 +1885,7 @@ try { let query = new distributedKVStore.Query(); query.notEqualTo("field", "value"); query.limit(total, offset); - console.log(`query is ${query.getSqlLike()}`); + console.info(`query is ${query.getSqlLike()}`); query = null; } catch (e) { console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`); @@ -1891,7 +1918,7 @@ isNotNull(field: string): Query try { let query = new distributedKVStore.Query(); query.isNotNull("field"); - console.log(`query is ${query.getSqlLike()}`); + console.info(`query is ${query.getSqlLike()}`); query = null; } catch (e) { console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`); @@ -1920,10 +1947,10 @@ try { query.beginGroup(); query.isNotNull("field"); query.endGroup(); - console.log("query is " + query.getSqlLike()); + console.info("query is " + query.getSqlLike()); query = null; } catch (e) { - console.log("duplicated calls should be ok :" + e); + console.error("duplicated calls should be ok :" + e); } ``` @@ -1949,10 +1976,10 @@ try { query.beginGroup(); query.isNotNull("field"); query.endGroup(); - console.log("query is " + query.getSqlLike()); + console.info("query is " + query.getSqlLike()); query = null; } catch (e) { - console.log("duplicated calls should be ok :" + e); + console.error("duplicated calls should be ok :" + e); } ``` @@ -1983,7 +2010,7 @@ try { let query = new distributedKVStore.Query(); query.prefixKey("$.name"); query.prefixKey("0"); - console.log(`query is ${query.getSqlLike()}`); + console.info(`query is ${query.getSqlLike()}`); query = null; } catch (e) { console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`); @@ -2017,7 +2044,7 @@ try { let query = new distributedKVStore.Query(); query.setSuggestIndex("$.name"); query.setSuggestIndex("0"); - console.log(`query is ${query.getSqlLike()}`); + console.info(`query is ${query.getSqlLike()}`); query = null; } catch (e) { console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`); @@ -2050,7 +2077,7 @@ deviceId(deviceId:string):Query try { let query = new distributedKVStore.Query(); query.deviceId("deviceId"); - console.log(`query is ${query.getSqlLike()}`); + console.info(`query is ${query.getSqlLike()}`); } catch (e) { console.error(`duplicated calls should be ok.code is ${e.code},message is ${e.message}`); } @@ -2076,9 +2103,9 @@ getSqlLike():string try { let query = new distributedKVStore.Query(); let sql1 = query.getSqlLike(); - console.log(`GetSqlLike sql= ${sql1}`); + console.info(`GetSqlLike sql= ${sql1}`); } catch (e) { - console.log("duplicated calls should be ok : " + e); + console.error("duplicated calls should be ok : " + e); } ``` @@ -2120,12 +2147,12 @@ let kvStore; const KEY_TEST_STRING_ELEMENT = 'key_test_string'; const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; try { - kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err, data) { + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err) { if (err != undefined) { - console.error(`Fail to put.code is ${err.code},message is ${err.message}`); + console.error(`Failed to put.code is ${err.code},message is ${err.message}`); return; } - console.log("Succeeded in putting"); + console.info("Succeeded in putting"); }); } catch (e) { console.error(`An unexpected error occurred.code is ${e.code},message is ${e.message}`); @@ -2169,10 +2196,10 @@ let kvStore; const KEY_TEST_STRING_ELEMENT = 'key_test_string'; const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; try { - kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((data) => { - console.log(`Succeeded in putting.data=${data}`); + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then(() => { + console.info(`Succeeded in putting data`); }).catch((err) => { - console.error(`Fail to put.code is ${err.code},message is ${err.message}`); + console.error(`Failed to put.code is ${err.code},message is ${err.message}`); }); } catch (e) { console.error(`An unexpected error occurred.code is ${e.code},message is ${e.message}`); @@ -2191,7 +2218,7 @@ putBatch(entries: Entry[], callback: AsyncCallback<void>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------ | ---- | ------------------------ | -| entries | [Entry](#entry)[] | 是 | 表示要批量插入的键值对。 | +| entries | [Entry](#entry)[] | 是 | 表示要批量插入的键值对。一个entries对象中允许的最大条目个数为128个。 | | callback | AsyncCallback<void> | 是 | 回调函数。 | **错误码:** @@ -2220,20 +2247,20 @@ try { } entries.push(entry); } - console.log(`entries: ${entries}`); - kvStore.putBatch(entries, async function (err, data) { + console.info(`entries: ${entries}`); + kvStore.putBatch(entries, async function (err) { if (err != undefined) { - console.error(`Fail to put Batch.code is ${err.code},message is ${err.message}`); + console.error(`Failed to put Batch.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in putting Batch'); + console.info('Succeeded in putting Batch'); kvStore.getEntries('batch_test_string_key', function (err, entries) { if (err != undefined) { - console.error(`Fail to get Entries.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get Entries.code is ${err.code},message is ${err.message}`); } - console.log('Succeeded in getting Entries'); - console.log(`entries.length: ${entries.length}`); - console.log(`entries[0]: ${entries[0]}`); + console.info('Succeeded in getting Entries'); + console.info(`entries.length: ${entries.length}`); + console.info(`entries[0]: ${entries[0]}`); }); }); } catch (e) { @@ -2253,7 +2280,7 @@ putBatch(entries: Entry[]): Promise<void> | 参数名 | 类型 | 必填 | 说明 | | ------- | ----------------- | ---- | ------------------------ | -| entries | [Entry](#entry)[] | 是 | 表示要批量插入的键值对。 | +| entries | [Entry](#entry)[] | 是 | 表示要批量插入的键值对。一个entries对象中允许的最大条目个数为128个。 | **返回值:** @@ -2287,17 +2314,17 @@ try { } entries.push(entry); } - console.log(`entries: ${entries}`); - kvStore.putBatch(entries).then(async (entries) => { - console.log('Succeeded in putting Batch'); + console.info(`entries: ${entries}`); + kvStore.putBatch(entries).then(async () => { + console.info('Succeeded in putting Batch'); kvStore.getEntries('batch_test_string_key').then((entries) => { - console.log('Succeeded in getting Entries'); - console.log(`PutBatch ${entries}`); + console.info('Succeeded in getting Entries'); + console.info(`PutBatch ${entries}`); }).catch((err) => { - console.error(`Fail to get Entries.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get Entries.code is ${err.code},message is ${err.message}`); }); }).catch((err) => { - console.error(`Fail to put Batch.code is ${err.code},message is ${err.message}`); + console.error(`Failed to put Batch.code is ${err.code},message is ${err.message}`); }); } catch (e) { console.error(`An unexpected error occurred.code is ${e.code},message is ${e.message} `); @@ -2344,15 +2371,15 @@ try { v8Arr.push(vb1); v8Arr.push(vb2); v8Arr.push(vb3); - kvStore.putBatch(v8Arr, async function (err, data) { + kvStore.putBatch(v8Arr, async function (err) { if (err != undefined) { - console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); + console.error(`Failed to put batch.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in putting batch'); + console.info('Succeeded in putting batch'); }) } catch (e) { - console.error(`Fail to put batch.code is ${e.code},message is ${e.message}`); + console.error(`Failed to put batch.code is ${e.code},message is ${e.message}`); } ``` @@ -2401,8 +2428,8 @@ try { v8Arr.push(vb1); v8Arr.push(vb2); v8Arr.push(vb3); - kvStore.putBatch(v8Arr).then(async (data) => { - console.log(`Succeeded in putting patch`); + kvStore.putBatch(v8Arr).then(async () => { + console.info(`Succeeded in putting patch`); }).catch((err) => { console.error(`putBatch fail.code is ${err.code},message is ${err.message}`); }); @@ -2442,18 +2469,18 @@ let kvStore; const KEY_TEST_STRING_ELEMENT = 'key_test_string'; const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; try { - kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err, data) { + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err) { if (err != undefined) { - console.error(`Fail to put.code is ${err.code},message is ${err.message}`); + console.error(`Failed to put.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in putting'); - kvStore.delete(KEY_TEST_STRING_ELEMENT, function (err, data) { + console.info('Succeeded in putting'); + kvStore.delete(KEY_TEST_STRING_ELEMENT, function (err) { if (err != undefined) { - console.error(`Fail to delete.code is ${err.code},message is ${err.message}`); + console.error(`Failed to delete.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in deleting'); + console.info('Succeeded in deleting'); }); }); } catch (e) { @@ -2497,15 +2524,15 @@ let kvStore; const KEY_TEST_STRING_ELEMENT = 'key_test_string'; const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; try { - kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((data) => { - console.log(`Succeeded in putting: ${data}`); - kvStore.delete(KEY_TEST_STRING_ELEMENT).then((data) => { - console.log('Succeeded in deleting'); + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then(() => { + console.info(`Succeeded in putting data`); + kvStore.delete(KEY_TEST_STRING_ELEMENT).then(() => { + console.info('Succeeded in deleting'); }).catch((err) => { - console.error(`Fail to delete.code is ${err.code},message is ${err.message}`); + console.error(`Failed to delete.code is ${err.code},message is ${err.message}`); }); }).catch((err) => { - console.error(`Fail to put.code is ${err.code},message is ${err.message}`); + console.error(`Failed to put.code is ${err.code},message is ${err.message}`); }); } catch (e) { console.error(`An unexpected error occurred.code is ${e.code},message is ${e.message}`); @@ -2545,11 +2572,11 @@ import dataSharePredicates from '@ohos.data.dataSharePredicates'; let kvStore; try { let predicates = new dataSharePredicates.DataSharePredicates(); - kvStore.delete(predicates, function (err, data) { + kvStore.delete(predicates, function (err) { if (err == undefined) { - console.log('Succeeded in deleting'); + console.info('Succeeded in deleting'); } else { - console.error(`Fail to delete.code is ${err.code},message is ${err.message}`); + console.error(`Failed to delete.code is ${err.code},message is ${err.message}`); } }); } catch (e) { @@ -2598,15 +2625,15 @@ try { let predicates = new dataSharePredicates.DataSharePredicates(); let arr = ["name"]; predicates.inKeys(arr); - kvStore.put("name", "bob").then((data) => { - console.log(`Succeeded in putting: ${data}`); - kvStore.delete(predicates).then((data) => { - console.log('Succeeded in deleting'); + kvStore.put("name", "bob").then(() => { + console.info(`Succeeded in putting data`); + kvStore.delete(predicates).then(() => { + console.info('Succeeded in deleting'); }).catch((err) => { - console.error(`Fail to delete.code is ${err.code},message is ${err.message}`); + console.error(`Failed to delete.code is ${err.code},message is ${err.message}`); }); }).catch((err) => { - console.error(`Fail to put.code is ${err.code},message is ${err.message}`); + console.error(`Failed to put.code is ${err.code},message is ${err.message}`); }); } catch (e) { console.error(`An unexpected error occurred.code is ${e.code},message is ${e.message}`); @@ -2656,19 +2683,19 @@ try { entries.push(entry); keys.push(key + i); } - console.log(`entries: ${entries}`); - kvStore.putBatch(entries, async function (err, data) { + console.info(`entries: ${entries}`); + kvStore.putBatch(entries, async function (err) { if (err != undefined) { - console.error(`Fail to put Batch.code is ${err.code},message is ${err.message}`); + console.error(`Failed to put Batch.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in putting Batch'); - kvStore.deleteBatch(keys, async function (err, data) { + console.info('Succeeded in putting Batch'); + kvStore.deleteBatch(keys, async function (err) { if (err != undefined) { - console.error(`Fail to delete Batch.code is ${err.code},message is ${err.message}`); + console.error(`Failed to delete Batch.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in deleting Batch'); + console.info('Succeeded in deleting Batch'); }); }); } catch (e) { @@ -2724,16 +2751,16 @@ try { entries.push(entry); keys.push(key + i); } - console.log(`entries: ${entries}`); - kvStore.putBatch(entries).then(async (data) => { - console.log('Succeeded in putting Batch'); - kvStore.deleteBatch(keys).then((err) => { - console.log('Succeeded in deleting Batch'); + console.info(`entries: ${entries}`); + kvStore.putBatch(entries).then(async () => { + console.info('Succeeded in putting Batch'); + kvStore.deleteBatch(keys).then(() => { + console.info('Succeeded in deleting Batch'); }).catch((err) => { - console.error(`Fail to delete Batch.code is ${err.code},message is ${err.message}`); + console.error(`Failed to delete Batch.code is ${err.code},message is ${err.message}`); }); }).catch((err) => { - console.error(`Fail to put Batch.code is ${err.code},message is ${err.message}`); + console.error(`Failed to put Batch.code is ${err.code},message is ${err.message}`); }); } catch (e) { console.error(`An unexpected error occurred.code is ${e.code},message is ${e.message}`); @@ -2770,16 +2797,16 @@ let kvStore; const KEY_TEST_STRING_ELEMENT = 'key_test_string_2'; const VALUE_TEST_STRING_ELEMENT = 'value-string-002'; try { - kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, async function (err, data) { - console.log('Succeeded in putting data'); + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, async function (err) { + console.info('Succeeded in putting data'); const deviceid = 'no_exist_device_id'; - kvStore.removeDeviceData(deviceid, async function (err, data) { + kvStore.removeDeviceData(deviceid, async function (err) { if (err == undefined) { - console.log('succeeded in removing device data'); + console.info('succeeded in removing device data'); } else { - console.error(`Fail to remove device data.code is ${err.code},message is ${err.message} `); + console.error(`Failed to remove device data.code is ${err.code},message is ${err.message} `); kvStore.get(KEY_TEST_STRING_ELEMENT, async function (err, data) { - console.log('Succeeded in getting data'); + console.info('Succeeded in getting data'); }); } }); @@ -2824,21 +2851,21 @@ let kvStore; const KEY_TEST_STRING_ELEMENT = 'key_test_string_2'; const VALUE_TEST_STRING_ELEMENT = 'value-string-001'; try { - kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((err) => { - console.log('Succeeded in putting data'); + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then(() => { + console.info('Succeeded in putting data'); }).catch((err) => { - console.error(`Fail to put data.code is ${err.code},message is ${err.message} `); + console.error(`Failed to put data.code is ${err.code},message is ${err.message} `); }); const deviceid = 'no_exist_device_id'; - kvStore.removeDeviceData(deviceid).then((err) => { - console.log('succeeded in removing device data'); + kvStore.removeDeviceData(deviceid).then(() => { + console.info('succeeded in removing device data'); }).catch((err) => { - console.error(`Fail to remove device data.code is ${err.code},message is ${err.message} `); + console.error(`Failed to remove device data.code is ${err.code},message is ${err.message} `); }); kvStore.get(KEY_TEST_STRING_ELEMENT).then((data) => { - console.log('Succeeded in getting data'); + console.info('Succeeded in getting data'); }).catch((err) => { - console.error(`Fail to get data.code is ${err.code},message is ${err.message} `); + console.error(`Failed to get data.code is ${err.code},message is ${err.message} `); }); } catch (e) { console.error(`An unexpected error occurred.code is ${e.code},message is ${e.message}`) @@ -2877,22 +2904,22 @@ let kvStore; const KEY_TEST_STRING_ELEMENT = 'key_test_string'; const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; try { - kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err, data) { + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err) { if (err != undefined) { - console.error(`Fail to put.code is ${err.code},message is ${err.message}`); + console.error(`Failed to put.code is ${err.code},message is ${err.message}`); return; } - console.log("Succeeded in putting"); + console.info("Succeeded in putting"); kvStore.get(KEY_TEST_STRING_ELEMENT, function (err, data) { if (err != undefined) { - console.error(`Fail to get.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get.code is ${err.code},message is ${err.message}`); return; } - console.log(`Succeeded in getting data.data=${data}`); + console.info(`Succeeded in getting data.data=${data}`); }); }); } catch (e) { - console.error(`Fail to get.code is ${e.code},message is ${e.message}`); + console.error(`Failed to get.code is ${e.code},message is ${e.message}`); } ``` @@ -2933,18 +2960,18 @@ let kvStore; const KEY_TEST_STRING_ELEMENT = 'key_test_string'; const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; try { - kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((data) => { - console.log(`Succeeded in putting data.data=${data}`); + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then(() => { + console.info(`Succeeded in putting data`); kvStore.get(KEY_TEST_STRING_ELEMENT).then((data) => { - console.log(`Succeeded in getting data.data=${data}`); + console.info(`Succeeded in getting data.data=${data}`); }).catch((err) => { - console.error(`Fail to get.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get.code is ${err.code},message is ${err.message}`); }); }).catch((err) => { - console.error(`Fail to put.code is ${err.code},message is ${err.message}`); + console.error(`Failed to put.code is ${err.code},message is ${err.message}`); }); } catch (e) { - console.error(`Fail to get.code is ${e.code},message is ${e.message}`); + console.error(`Failed to get.code is ${e.code},message is ${e.message}`); } ``` @@ -2989,21 +3016,21 @@ try { } entries.push(entry); } - console.log(`entries: ${entries}`); - kvStore.putBatch(entries, async function (err, data) { + console.info(`entries: ${entries}`); + kvStore.putBatch(entries, async function (err) { if (err != undefined) { - console.error(`Fail to put Batch.code is ${err.code},message is ${err.message}`); + console.error(`Failed to put Batch.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in putting Batch'); + console.info('Succeeded in putting Batch'); kvStore.getEntries('batch_test_string_key', function (err, entries) { if (err != undefined) { - console.error(`Fail to get Entries.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get Entries.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in getting Entries'); - console.log(`entries.length: ${entries.length}`); - console.log(`entries[0]: ${entries[0]}`); + console.info('Succeeded in getting Entries'); + console.info(`entries.length: ${entries.length}`); + console.info(`entries[0]: ${entries[0]}`); }); }); } catch (e) { @@ -3057,17 +3084,17 @@ try { } entries.push(entry); } - console.log(`entries: ${entries}`); - kvStore.putBatch(entries).then(async (entries) => { - console.log('Succeeded in putting Batch'); + console.info(`entries: ${entries}`); + kvStore.putBatch(entries).then(async () => { + console.info('Succeeded in putting Batch'); kvStore.getEntries('batch_test_string_key').then((entries) => { - console.log('Succeeded in getting Entries'); - console.log(`PutBatch ${entries}`); + console.info('Succeeded in getting Entries'); + console.info(`PutBatch ${entries}`); }).catch((err) => { - console.error(`Fail to get Entries.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get Entries.code is ${err.code},message is ${err.message}`); }); }).catch((err) => { - console.error(`Fail to put Batch.code is ${err.code},message is ${err.message}`); + console.error(`Failed to put Batch.code is ${err.code},message is ${err.message}`); }); } catch (e) { console.error(`An unexpected error occurred.code is ${e.code},message is ${e.message} `); @@ -3116,23 +3143,23 @@ try { } entries.push(entry); } - console.log(`entries: {entries}`); - kvStore.putBatch(entries, async function (err, data) { - console.log('Succeeded in putting Batch'); + console.info(`entries: {entries}`); + kvStore.putBatch(entries, async function (err) { + console.info('Succeeded in putting Batch'); const query = new distributedKVStore.Query(); query.prefixKey("batch_test"); kvStore.getEntries(query, function (err, entries) { if (err != undefined) { - console.error(`Fail to get Entries.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get Entries.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in getting Entries'); - console.log(`entries.length: ${entries.length}`); - console.log(`entries[0]: ${entries[0]}`); + console.info('Succeeded in getting Entries'); + console.info(`entries.length: ${entries.length}`); + console.info(`entries[0]: ${entries[0]}`); }); }); } catch (e) { - console.error(`Fail to get Entries.code is ${e.code},message is ${e.message}`); + console.error(`Failed to get Entries.code is ${e.code},message is ${e.message}`); } ``` @@ -3183,22 +3210,22 @@ try { } entries.push(entry); } - console.log(`entries: {entries}`); - kvStore.putBatch(entries).then(async (err) => { - console.log('Succeeded in putting Batch'); + console.info(`entries: {entries}`); + kvStore.putBatch(entries).then(async () => { + console.info('Succeeded in putting Batch'); const query = new distributedKVStore.Query(); query.prefixKey("batch_test"); kvStore.getEntries(query).then((entries) => { - console.log('Succeeded in getting Entries'); + console.info('Succeeded in getting Entries'); }).catch((err) => { - console.error(`Fail to get Entries.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get Entries.code is ${err.code},message is ${err.message}`); }); }).catch((err) => { - console.error(`Fail to get Entries.code is ${err.code},message is ${err.message}`) + console.error(`Failed to get Entries.code is ${err.code},message is ${err.message}`) }); - console.log('Succeeded in getting Entries'); + console.info('Succeeded in getting Entries'); } catch (e) { - console.error(`Fail to get Entries.code is ${e.code},message is ${e.message}`); + console.error(`Failed to get Entries.code is ${e.code},message is ${e.message}`); } ``` @@ -3244,25 +3271,25 @@ try { } entries.push(entry); } - kvStore.putBatch(entries, async function (err, data) { + kvStore.putBatch(entries, async function (err) { if (err != undefined) { - console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); + console.error(`Failed to put batch.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in putting batch'); + console.info('Succeeded in putting batch'); kvStore.getResultSet('batch_test_string_key', async function (err, result) { if (err != undefined) { - console.error(`Fail to get resultset.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get resultset.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in getting result set'); + console.info('Succeeded in getting result set'); resultSet = result; - kvStore.closeResultSet(resultSet, function (err, data) { + kvStore.closeResultSet(resultSet, function (err) { if (err != undefined) { - console.error(`Fail to close resultset.code is ${err.code},message is ${err.message}`); + console.error(`Failed to close resultset.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in closing result set'); + console.info('Succeeded in closing result set'); }) }); }); @@ -3318,21 +3345,21 @@ try { } entries.push(entry); } - kvStore.putBatch(entries).then(async (err) => { - console.log('Succeeded in putting batch'); + kvStore.putBatch(entries).then(async () => { + console.info('Succeeded in putting batch'); }).catch((err) => { - console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); + console.error(`Failed to put batch.code is ${err.code},message is ${err.message}`); }); kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('Succeeded in getting result set'); + console.info('Succeeded in getting result set'); resultSet = result; }).catch((err) => { - console.error(`Fail to get resultset.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get resultset.code is ${err.code},message is ${err.message}`); }); - kvStore.closeResultSet(resultSet).then((err) => { - console.log('Succeeded in closing result set'); + kvStore.closeResultSet(resultSet).then(() => { + console.info('Succeeded in closing result set'); }).catch((err) => { - console.error(`Fail to close resultset.code is ${err.code},message is ${err.message}`); + console.error(`Failed to close resultset.code is ${err.code},message is ${err.message}`); }); } catch (e) { console.error(`An unexpected error occurred.code is ${e.code},message is ${e.code}`); @@ -3381,20 +3408,20 @@ try { } entries.push(entry); } - kvStore.putBatch(entries, async function (err, data) { + kvStore.putBatch(entries, async function (err) { if (err != undefined) { - console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); + console.error(`Failed to put batch.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in putting batch'); + console.info('Succeeded in putting batch'); const query = new distributedKVStore.Query(); query.prefixKey("batch_test"); kvStore.getResultSet(query, async function (err, result) { if (err != undefined) { - console.error(`Fail to get resultset.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get resultset.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in getting result set'); + console.info('Succeeded in getting result set'); }); }); } catch (e) { @@ -3449,18 +3476,18 @@ try { } entries.push(entry); } - kvStore.putBatch(entries).then(async (err) => { - console.log('Succeeded in putting batch'); + kvStore.putBatch(entries).then(async () => { + console.info('Succeeded in putting batch'); }).catch((err) => { - console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); + console.error(`Failed to put batch.code is ${err.code},message is ${err.message}`); }); const query = new distributedKVStore.Query(); query.prefixKey("batch_test"); kvStore.getResultSet(query).then((result) => { - console.log('Succeeded in getting result set'); + console.info('Succeeded in getting result set'); resultSet = result; }).catch((err) => { - console.error(`Fail to get resultset.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get resultset.code is ${err.code},message is ${err.message}`); }); } catch (e) { console.error(`An unexpected error occurred.code is ${e.code},message is ${e.code}`); @@ -3505,17 +3532,17 @@ try { predicates.prefixKey("batch_test_string_key"); kvStore.getResultSet(predicates, async function (err, result) { if (err != undefined) { - console.error(`Fail to get resultset.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get resultset.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in getting result set'); + console.info('Succeeded in getting result set'); resultSet = result; - kvStore.closeResultSet(resultSet, function (err, data) { + kvStore.closeResultSet(resultSet, function (err) { if (err != undefined) { - console.error(`Fail to close resultset.code is ${err.code},message is ${err.message}`); + console.error(`Failed to close resultset.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in closing result set'); + console.info('Succeeded in closing result set'); }) }); } catch (e) { @@ -3565,15 +3592,15 @@ try { let predicates = new dataSharePredicates.DataSharePredicates(); predicates.prefixKey("batch_test_string_key"); kvStore.getResultSet(predicates).then((result) => { - console.log('Succeeded in getting result set'); + console.info('Succeeded in getting result set'); resultSet = result; }).catch((err) => { - console.error(`Fail to get resultset.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get resultset.code is ${err.code},message is ${err.message}`); }); - kvStore.closeResultSet(resultSet).then((err) => { - console.log('Succeeded in closing result set'); + kvStore.closeResultSet(resultSet).then(() => { + console.info('Succeeded in closing result set'); }).catch((err) => { - console.error(`Fail to close resultset.code is ${err.code},message is ${err.message}`); + console.error(`Failed to close resultset.code is ${err.code},message is ${err.message}`); }); } catch (e) { console.error(`An unexpected error occurred.code is ${e.code},message is ${e.code}`); @@ -3601,11 +3628,11 @@ closeResultSet(resultSet: KVStoreResultSet, callback: AsyncCallback<void>) let kvStore; try { let resultSet = null; - kvStore.closeResultSet(resultSet, function (err, data) { + kvStore.closeResultSet(resultSet, function (err) { if (err == undefined) { - console.log('Succeeded in closing result set'); + console.info('Succeeded in closing result set'); } else { - console.error(`Fail to close resultset.code is ${err.code},message is ${err.message}`); + console.error(`Failed to close resultset.code is ${err.code},message is ${err.message}`); } }); } catch (e) { @@ -3640,9 +3667,9 @@ let kvStore; try { let resultSet = null; kvStore.closeResultSet(resultSet).then(() => { - console.log('Succeeded in closing result set'); + console.info('Succeeded in closing result set'); }).catch((err) => { - console.error(`Fail to close resultset.code is ${err.code},message is ${err.message}`); + console.error(`Failed to close resultset.code is ${err.code},message is ${err.message}`); }); } catch (e) { console.error(`An unexpected error occurred.code is ${e.code},message is ${e.code}`); @@ -3690,16 +3717,16 @@ try { } entries.push(entry); } - kvStore.putBatch(entries, async function (err, data) { - console.log('Succeeded in putting batch'); + kvStore.putBatch(entries, async function (err) { + console.info('Succeeded in putting batch'); const query = new distributedKVStore.Query(); query.prefixKey("batch_test"); kvStore.getResultSize(query, async function (err, resultSize) { if (err != undefined) { - console.error(`Fail to get result size.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get result size.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in getting result set size'); + console.info('Succeeded in getting result set size'); }); }); } catch (e) { @@ -3753,17 +3780,17 @@ try { } entries.push(entry); } - kvStore.putBatch(entries).then(async (err) => { - console.log('Succeeded in putting batch'); + kvStore.putBatch(entries).then(async () => { + console.info('Succeeded in putting batch'); }).catch((err) => { - console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); + console.error(`Failed to put batch.code is ${err.code},message is ${err.message}`); }); const query = new distributedKVStore.Query(); query.prefixKey("batch_test"); kvStore.getResultSize(query).then((resultSize) => { - console.log('Succeeded in getting result set size'); + console.info('Succeeded in getting result set size'); }).catch((err) => { - console.error(`Fail to get result size.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get result size.code is ${err.code},message is ${err.message}`); }); } catch (e) { console.error(`An unexpected error occurred.code is ${e.code},message is ${e.code}`); @@ -3799,11 +3826,11 @@ backup(file:string, callback: AsyncCallback<void>):void let kvStore; let file = "BK001"; try { - kvStore.backup(file, (err, data) => { + kvStore.backup(file, (err) => { if (err) { - console.error(`Fail to backup.code is ${err.code},message is ${err.message} `); + console.error(`Failed to backup.code is ${err.code},message is ${err.message} `); } else { - console.info(`Succeeded in backupping data.data=${data}`); + console.info(`Succeeded in backupping data`); } }); } catch (e) { @@ -3845,10 +3872,10 @@ backup(file:string): Promise<void> let kvStore; let file = "BK001"; try { - kvStore.backup(file).then((data) => { - console.info(`Succeeded in backupping data.data=${data}`); + kvStore.backup(file).then(() => { + console.info(`Succeeded in backupping data`); }).catch((err) => { - console.error(`Fail to backup.code is ${err.code},message is ${err.message}`); + console.error(`Failed to backup.code is ${err.code},message is ${err.message}`); }); } catch (e) { console.error(`An unexpected error occurred.code is ${e.code},message is ${e.message}`); @@ -3884,11 +3911,11 @@ restore(file:string, callback: AsyncCallback<void>):void let kvStore; let file = "BK001"; try { - kvStore.restore(file, (err, data) => { + kvStore.restore(file, (err) => { if (err) { - console.error(`Fail to restore.code is ${err.code},message is ${err.message}`); + console.error(`Failed to restore.code is ${err.code},message is ${err.message}`); } else { - console.info(`Succeeded in restoring data.data=${data}`); + console.info(`Succeeded in restoring data`); } }); } catch (e) { @@ -3930,10 +3957,10 @@ restore(file:string): Promise<void> let kvStore; let file = "BK001"; try { - kvStore.restore(file).then((data) => { - console.info(`Succeeded in restoring data.data=${data}`); + kvStore.restore(file).then(() => { + console.info(`Succeeded in restoring data`); }).catch((err) => { - console.error(`Fail to restore.code is ${err.code},message is ${err.message}`); + console.error(`Failed to restore.code is ${err.code},message is ${err.message}`); }); } catch (e) { console.error(`An unexpected error occurred.code is ${e.code},message is ${e.message}`); @@ -3963,7 +3990,7 @@ let files = ["BK001", "BK002"]; try { kvStore.deleteBackup(files, (err, data) => { if (err) { - console.error(`Fail to delete Backup.code is ${err.code},message is ${err.message}`); + console.error(`Failed to delete Backup.code is ${err.code},message is ${err.message}`); } else { console.info(`Succeed in deleting Backup.data=${data}`); } @@ -4002,10 +4029,10 @@ try { kvStore.deleteBackup(files).then((data) => { console.info(`Succeed in deleting Backup.data=${data}`); }).catch((err) => { - console.error(`Fail to delete Backup.code is ${err.code},message is ${err.message}`); + console.error(`Failed to delete Backup.code is ${err.code},message is ${err.message}`); }) } catch (e) { - console.log(`An unexpected error occurred.code is ${e.code},message is ${e.message}`); + console.error(`An unexpected error occurred.code is ${e.code},message is ${e.message}`); } ``` @@ -4053,27 +4080,27 @@ function putBatchString(len, prefix) { try { var count = 0; kvStore.on('dataChange', 0, function (data) { - console.log(`startTransaction 0 ${data}`); + console.info(`startTransaction 0 ${data}`); count++; }); - kvStore.startTransaction(async function (err, data) { + kvStore.startTransaction(async function (err) { if (err != undefined) { - console.error(`Fail to start Transaction.code is ${err.code},message is ${err.message}`); + console.error(`Failed to start Transaction.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in starting Transaction'); + console.info('Succeeded in starting Transaction'); let entries = putBatchString(10, 'batch_test_string_key'); - console.log(`entries: ${entries}`); - kvStore.putBatch(entries, async function (err, data) { + console.info(`entries: ${entries}`); + kvStore.putBatch(entries, async function (err) { if (err != undefined) { - console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); + console.error(`Failed to put batch.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in putting Batch'); + console.info('Succeeded in putting Batch'); }); }); } catch (e) { - console.error(`Fail to start Transaction.code is ${e.code},message is ${e.message}`); + console.error(`Failed to start Transaction.code is ${e.code},message is ${e.message}`); } ``` @@ -4106,16 +4133,16 @@ let kvStore; try { var count = 0; kvStore.on('dataChange', distributedKVStore.SubscribeType.SUBSCRIBE_TYPE_ALL, function (data) { - console.log(`startTransaction 0 ${data}`); + console.info(`startTransaction 0 ${data}`); count++; }); - kvStore.startTransaction().then(async (err) => { - console.log('Succeeded in starting Transaction'); + kvStore.startTransaction().then(async () => { + console.info('Succeeded in starting Transaction'); }).catch((err) => { - console.error(`Fail to start Transaction.code is ${err.code},message is ${err.message}`); + console.error(`Failed to start Transaction.code is ${err.code},message is ${err.message}`); }); } catch (e) { - console.error(`Fail to start Transaction.code is ${e.code},message is ${e.message}`); + console.error(`Failed to start Transaction.code is ${e.code},message is ${e.message}`); } ``` @@ -4146,11 +4173,11 @@ commit(callback: AsyncCallback<void>): void ```js let kvStore; try { - kvStore.commit(function (err, data) { + kvStore.commit(function (err) { if (err == undefined) { - console.log('Succeeded in committing'); + console.info('Succeeded in committing'); } else { - console.error(`Fail to commit.code is ${err.code},message is ${err.message}`); + console.error(`Failed to commit.code is ${err.code},message is ${err.message}`); } }); } catch (e) { @@ -4185,13 +4212,13 @@ commit(): Promise<void> ```js let kvStore; try { - kvStore.commit().then(async (err) => { - console.log('Succeeded in committing'); + kvStore.commit().then(async () => { + console.info('Succeeded in committing'); }).catch((err) => { - console.error(`Fail to commit.code is ${err.code},message is ${err.message}`); + console.error(`Failed to commit.code is ${err.code},message is ${err.message}`); }); } catch (e) { - console.error(`An unexpected error occurred.ode is ${e.code},message is ${e.message}`); + console.error(`An unexpected error occurred.code is ${e.code},message is ${e.message}`); } ``` @@ -4222,11 +4249,11 @@ rollback(callback: AsyncCallback<void>): void ```js let kvStore; try { - kvStore.rollback(function (err,data) { + kvStore.rollback(function (err) { if (err == undefined) { - console.log('Succeeded in rolling back'); + console.info('Succeeded in rolling back'); } else { - console.error(`Fail to rollback.code is ${err.code},message is ${err.message}`); + console.error(`Failed to rollback.code is ${err.code},message is ${err.message}`); } }); }catch(e) { @@ -4261,10 +4288,10 @@ rollback(): Promise<void> ```js let kvStore; try { - kvStore.rollback().then(async (err) => { - console.log('Succeeded in rolling back'); + kvStore.rollback().then(async () => { + console.info('Succeeded in rolling back'); }).catch((err) => { - console.error(`Fail to rollback.code is ${err.code},message is ${err.message}`); + console.error(`Failed to rollback.code is ${err.code},message is ${err.message}`); }); } catch (e) { console.error(`An unexpected error occurred.code is ${e.code},message is ${e.message}`); @@ -4291,11 +4318,11 @@ enableSync(enabled: boolean, callback: AsyncCallback<void>): void ```js let kvStore; try { - kvStore.enableSync(true, function (err, data) { + kvStore.enableSync(true, function (err) { if (err == undefined) { - console.log('Succeeded in enabling sync'); + console.info('Succeeded in enabling sync'); } else { - console.error(`Fail to enable sync.code is ${err.code},message is ${err.message}`); + console.error(`Failed to enable sync.code is ${err.code},message is ${err.message}`); } }); } catch (e) { @@ -4328,10 +4355,10 @@ enableSync(enabled: boolean): Promise<void> ```js let kvStore; try { - kvStore.enableSync(true).then((err) => { - console.log('Succeeded in enabling sync'); + kvStore.enableSync(true).then(() => { + console.info('Succeeded in enabling sync'); }).catch((err) => { - console.error(`Fail to enable sync.code is ${err.code},message is ${err.message}`); + console.error(`Failed to enable sync.code is ${err.code},message is ${err.message}`); }); } catch (e) { console.error(`An unexpected error occurred.code is ${e.code},message is ${e.message}`); @@ -4361,12 +4388,12 @@ let kvStore; try { const localLabels = ['A', 'B']; const remoteSupportLabels = ['C', 'D']; - kvStore.setSyncRange(localLabels, remoteSupportLabels, function (err, data) { + kvStore.setSyncRange(localLabels, remoteSupportLabels, function (err) { if (err != undefined) { - console.error(`Fail to set syncRange.code is ${err.code},message is ${err.message}`); + console.error(`Failed to set syncRange.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in setting syncRange'); + console.info('Succeeded in setting syncRange'); }); } catch (e) { console.error(`An unexpected error occurred.code is ${e.code},message is ${e.message}`); @@ -4401,10 +4428,10 @@ let kvStore; try { const localLabels = ['A', 'B']; const remoteSupportLabels = ['C', 'D']; - kvStore.setSyncRange(localLabels, remoteSupportLabels).then((err) => { - console.log('Succeeded in setting syncRange'); + kvStore.setSyncRange(localLabels, remoteSupportLabels).then(() => { + console.info('Succeeded in setting syncRange'); }).catch((err) => { - console.error(`Fail to set syncRange.code is ${err.code},message is ${err.message}`); + console.error(`Failed to set syncRange.code is ${err.code},message is ${err.message}`); }); } catch (e) { console.error(`An unexpected error occurred.code is ${e.code},message is ${e.message}`); @@ -4432,12 +4459,12 @@ setSyncParam(defaultAllowedDelayMs: number, callback: AsyncCallback<void>) let kvStore; try { const defaultAllowedDelayMs = 500; - kvStore.setSyncParam(defaultAllowedDelayMs, function (err, data) { + kvStore.setSyncParam(defaultAllowedDelayMs, function (err) { if (err != undefined) { - console.error(`Fail to set syncParam.code is ${err.code},message is ${err.message}`); + console.error(`Failed to set syncParam.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in setting syncParam'); + console.info('Succeeded in setting syncParam'); }); } catch (e) { console.error(`An unexpected error occurred.code is ${e.code},message is ${e.message}`); @@ -4470,10 +4497,10 @@ setSyncParam(defaultAllowedDelayMs: number): Promise<void> let kvStore; try { const defaultAllowedDelayMs = 500; - kvStore.setSyncParam(defaultAllowedDelayMs).then((err) => { - console.log('Succeeded in setting syncParam'); + kvStore.setSyncParam(defaultAllowedDelayMs).then(() => { + console.info('Succeeded in setting syncParam'); }).catch((err) => { - console.error(`Fail to set syncParam.code is ${err.code},message is ${err.message}`); + console.error(`Failed to set syncParam.code is ${err.code},message is ${err.message}`); }); } catch (e) { console.error(`An unexpected error occurred.code is ${e.code},message is ${e.message}`); @@ -4532,19 +4559,19 @@ deviceManager.createDeviceManager('bundleName', (err, value) => { } try { kvStore.on('syncComplete', function (data) { - console.log('Sync dataChange'); + console.info('Sync dataChange'); }); - kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync101', VALUE_TEST_SYNC_ELEMENT, function (err, data) { + kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync101', VALUE_TEST_SYNC_ELEMENT, function (err) { if (err != undefined) { - console.error(`Fail to sync.code is ${err.code},message is ${err.message}`); + console.error(`Failed to sync.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in putting data'); + console.info('Succeeded in putting data'); const mode = distributedKVStore.SyncMode.PULL_ONLY; kvStore.sync(deviceIds, mode, 1000); }); } catch (e) { - console.error(`Fail to sync.code is ${e.code},message is ${e.message}`); + console.error(`Failed to sync.code is ${e.code},message is ${e.message}`); } } }); @@ -4603,14 +4630,14 @@ deviceManager.createDeviceManager('bundleName', (err, value) => { } try { kvStore.on('syncComplete', function (data) { - console.log('Sync dataChange'); + console.info('Sync dataChange'); }); - kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync101', VALUE_TEST_SYNC_ELEMENT, function (err, data) { + kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync101', VALUE_TEST_SYNC_ELEMENT, function (err) { if (err != undefined) { - console.error(`Fail to sync.code is ${err.code},message is ${err.message}`); + console.error(`Failed to sync.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in putting data'); + console.info('Succeeded in putting data'); const mode = distributedKVStore.SyncMode.PULL_ONLY; const query = new distributedKVStore.Query(); query.prefixKey("batch_test"); @@ -4618,7 +4645,7 @@ deviceManager.createDeviceManager('bundleName', (err, value) => { kvStore.sync(deviceIds, query, mode, 1000); }); } catch (e) { - console.error(`Fail to sync.code is ${e.code},message is ${e.message}`); + console.error(`Failed to sync.code is ${e.code},message is ${e.message}`); } } }); @@ -4655,7 +4682,7 @@ on(event: 'dataChange', type: SubscribeType, listener: Callback<ChangeNotific let kvStore; try { kvStore.on('dataChange', distributedKVStore.SubscribeType.SUBSCRIBE_TYPE_LOCAL, function (data) { - console.log(`dataChange callback call data: ${data}`); + console.info(`dataChange callback call data: ${data}`); }); } catch (e) { console.error(`An unexpected error occurred.code is ${e.code},message is ${e.message}`); @@ -4685,15 +4712,15 @@ const KEY_TEST_FLOAT_ELEMENT = 'key_test_float'; const VALUE_TEST_FLOAT_ELEMENT = 321.12; try { kvStore.on('syncComplete', function (data) { - console.log(`syncComplete ${data}`); + console.info(`syncComplete ${data}`); }); - kvStore.put(KEY_TEST_FLOAT_ELEMENT, VALUE_TEST_FLOAT_ELEMENT).then((data) => { - console.log('succeeded in putting'); + kvStore.put(KEY_TEST_FLOAT_ELEMENT, VALUE_TEST_FLOAT_ELEMENT).then(() => { + console.info('succeeded in putting'); }).catch((err) => { - console.error(`Fail to put.code is ${err.code},message is ${err.message}`); + console.error(`Failed to put.code is ${err.code},message is ${err.message}`); }); } catch (e) { - console.error(`Fail to subscribe syncComplete.code is ${e.code},message is ${e.message}`); + console.error(`Failed to subscribe syncComplete.code is ${e.code},message is ${e.message}`); } ``` @@ -4726,7 +4753,7 @@ off(event:'dataChange', listener?: Callback<ChangeNotification>): void let kvStore; class KvstoreModel { call(data) { - console.log(`dataChange : ${data}`); + console.info(`dataChange : ${data}`); } subscribeDataChange() { @@ -4735,7 +4762,7 @@ class KvstoreModel { kvStore.on('dataChange', distributedKVStore.SubscribeType.SUBSCRIBE_TYPE_REMOTE, this.call); } } catch (err) { - console.error(`Fail to subscribeDataChange.code is ${err.code},message is ${err.message}`); + console.error(`Failed to subscribeDataChange.code is ${err.code},message is ${err.message}`); } } @@ -4745,7 +4772,7 @@ class KvstoreModel { kvStore.off('dataChange', this.call); } } catch (err) { - console.error(`Fail to unsubscribeDataChange.code is ${err.code},message is ${err.message}`); + console.error(`Failed to unsubscribeDataChange.code is ${err.code},message is ${err.message}`); } } } @@ -4772,7 +4799,7 @@ off(event: 'syncComplete', syncCallback?: Callback<Array<[string, number]& let kvStore; class KvstoreModel { call(data) { - console.log(`syncComplete : ${data}`); + console.info(`syncComplete : ${data}`); } subscribeDataChange() { @@ -4781,7 +4808,7 @@ class KvstoreModel { kvStore.on('syncComplete', distributedKVStore.SubscribeType.SUBSCRIBE_TYPE_REMOTE, this.call); } } catch (err) { - console.error(`Fail to subscribeDataChange.code is ${err.code},message is ${err.message}`); + console.error(`Failed to subscribeDataChange.code is ${err.code},message is ${err.message}`); } } @@ -4791,7 +4818,7 @@ class KvstoreModel { kvStore.off('dsyncComplete', this.call); } } catch (err) { - console.error(`Fail to unsubscribeDataChange.code is ${err.code},message is ${err.message}`); + console.error(`Failed to unsubscribeDataChange.code is ${err.code},message is ${err.message}`); } } } @@ -4826,10 +4853,10 @@ let kvStore; try { kvStore.getSecurityLevel(function (err, data) { if (err != undefined) { - console.error(`Fail to get SecurityLevel.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get SecurityLevel.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in getting securityLevel'); + console.info('Succeeded in getting securityLevel'); }); } catch (e) { console.error(`An unexpected error occurred.code is ${e.code},message is ${e.message}`); @@ -4864,9 +4891,9 @@ getSecurityLevel(): Promise<SecurityLevel> let kvStore; try { kvStore.getSecurityLevel().then((data) => { - console.log('Succeeded in getting securityLevel'); + console.info('Succeeded in getting securityLevel'); }).catch((err) => { - console.error(`Fail to get SecurityLevel.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get SecurityLevel.code is ${err.code},message is ${err.message}`); }); } catch (e) { console.error(`An unexpected error occurred.code is ${e.code},message is ${e.message}`); @@ -4915,22 +4942,22 @@ let kvStore; const KEY_TEST_STRING_ELEMENT = 'key_test_string'; const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; try { - kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err, data) { + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err) { if (err != undefined) { - console.error(`Fail to put.code is ${err.code},message is ${err.message}`); + console.error(`Failed to put.code is ${err.code},message is ${err.message}`); return; } - console.log("Succeeded in putting"); + console.info("Succeeded in putting"); kvStore.get(KEY_TEST_STRING_ELEMENT, function (err, data) { if (err != undefined) { - console.error(`Fail to get.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get.code is ${err.code},message is ${err.message}`); return; } - console.log(`Succeeded in getting data.data=${data}`); + console.info(`Succeeded in getting data.data=${data}`); }); }); } catch (e) { - console.error(`Fail to get.code is ${e.code},message is ${e.message}`); + console.error(`Failed to get.code is ${e.code},message is ${e.message}`); } ``` @@ -4971,18 +4998,18 @@ let kvStore; const KEY_TEST_STRING_ELEMENT = 'key_test_string'; const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; try { - kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((data) => { - console.log(`Succeeded in putting data.data=${data}`); + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then(() => { + console.info(`Succeeded in putting data`); kvStore.get(KEY_TEST_STRING_ELEMENT).then((data) => { - console.log(`Succeeded in getting data.data=${data}`); + console.info(`Succeeded in getting data.data=${data}`); }).catch((err) => { - console.error(`Fail to get.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get.code is ${err.code},message is ${err.message}`); }); }).catch((err) => { - console.error(`Fail to put.code is ${err.code},message is ${err.message}`); + console.error(`Failed to put.code is ${err.code},message is ${err.message}`); }); } catch (e) { - console.error(`Fail to get.code is ${e.code},message is ${e.message}`); + console.error(`Failed to get.code is ${e.code},message is ${e.message}`); } ``` @@ -5019,22 +5046,22 @@ let kvStore; const KEY_TEST_STRING_ELEMENT = 'key_test_string_2'; const VALUE_TEST_STRING_ELEMENT = 'value-string-002'; try { - kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, async function (err, data) { + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, async function (err) { if (err != undefined) { - console.error(`Fail to put.code is ${err.code},message is ${err.message}`); + console.error(`Failed to put.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in putting'); + console.info('Succeeded in putting'); kvStore.get('localDeviceId', KEY_TEST_STRING_ELEMENT, function (err, data) { if (err != undefined) { - console.error(`Fail to get.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in getting'); + console.info('Succeeded in getting'); }); }) } catch (e) { - console.error(`Fail to get.code is ${e.code},message is ${e.message}`); + console.error(`Failed to get.code is ${e.code},message is ${e.message}`); } ``` @@ -5076,18 +5103,18 @@ let kvStore; const KEY_TEST_STRING_ELEMENT = 'key_test_string_2'; const VALUE_TEST_STRING_ELEMENT = 'value-string-002'; try { - kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then(async (data) => { - console.log('Succeeded in putting'); + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then(async () => { + console.info('Succeeded in putting'); kvStore.get('localDeviceId', KEY_TEST_STRING_ELEMENT).then((data) => { - console.log('Succeeded in getting'); + console.info('Succeeded in getting'); }).catch((err) => { - console.error(`Fail to get.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get.code is ${err.code},message is ${err.message}`); }); }).catch((error) => { - console.error(`Fail to put.code is ${error.code},message is ${error.message}`); + console.error(`Failed to put.code is ${error.code},message is ${error.message}`); }); } catch (e) { - console.error(`Fail to get.code is ${e.code},message is ${e.message}`); + console.error(`Failed to get.code is ${e.code},message is ${e.message}`); } ``` @@ -5132,21 +5159,21 @@ try { } entries.push(entry); } - console.log(`entries: ${entries}`); - kvStore.putBatch(entries, async function (err, data) { + console.info(`entries: ${entries}`); + kvStore.putBatch(entries, async function (err) { if (err != undefined) { - console.error(`Fail to put Batch.code is ${err.code},message is ${err.message}`); + console.error(`Failed to put Batch.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in putting Batch'); + console.info('Succeeded in putting Batch'); kvStore.getEntries('batch_test_string_key', function (err, entries) { if (err != undefined) { - console.error(`Fail to get Entries.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get Entries.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in getting Entries'); - console.log(`entries.length: ${entries.length}`); - console.log(`entries[0]: ${entries[0]}`); + console.info('Succeeded in getting Entries'); + console.info(`entries.length: ${entries.length}`); + console.info(`entries[0]: ${entries[0]}`); }); }); } catch (e) { @@ -5200,17 +5227,17 @@ try { } entries.push(entry); } - console.log(`entries: ${entries}`); - kvStore.putBatch(entries).then(async (entries) => { - console.log('Succeeded in putting Batch'); + console.info(`entries: ${entries}`); + kvStore.putBatch(entries).then(async () => { + console.info('Succeeded in putting Batch'); kvStore.getEntries('batch_test_string_key').then((entries) => { - console.log('Succeeded in getting Entries'); - console.log(`PutBatch ${entries}`); + console.info('Succeeded in getting Entries'); + console.info(`PutBatch ${entries}`); }).catch((err) => { - console.error(`Fail to get Entries.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get Entries.code is ${err.code},message is ${err.message}`); }); }).catch((err) => { - console.error(`Fail to put Batch.code is ${err.code},message is ${err.message}`); + console.error(`Failed to put Batch.code is ${err.code},message is ${err.message}`); }); } catch (e) { console.error(`An unexpected error occurred.code is ${e.code},message is ${e.message} `); @@ -5259,25 +5286,25 @@ try { } entries.push(entry); } - console.log(`entries : ${entries}`); - kvStore.putBatch(entries, async function (err, data) { + console.info(`entries : ${entries}`); + kvStore.putBatch(entries, async function (err) { if (err != undefined) { - console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); + console.error(`Failed to put batch.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in putting batch'); + console.info('Succeeded in putting batch'); kvStore.getEntries('localDeviceId', 'batch_test_string_key', function (err, entries) { if (err != undefined) { - console.error(`Fail to get entries.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get entries.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in getting entries'); - console.log(`entries.length: ${entries.length}`); - console.log(`entries[0]: ${entries[0]}`); + console.info('Succeeded in getting entries'); + console.info(`entries.length: ${entries.length}`); + console.info(`entries[0]: ${entries[0]}`); }); }); } catch (e) { - console.error(`Fail to put batch.code is ${e.code},message is ${e.message}`); + console.error(`Failed to put batch.code is ${e.code},message is ${e.message}`); } ``` @@ -5328,23 +5355,23 @@ try { } entries.push(entry); } - console.log(`entries: ${entries}`); - kvStore.putBatch(entries).then(async (err) => { - console.log('Succeeded in putting batch'); + console.info(`entries: ${entries}`); + kvStore.putBatch(entries).then(async () => { + console.info('Succeeded in putting batch'); kvStore.getEntries('localDeviceId', 'batch_test_string_key').then((entries) => { - console.log('Succeeded in getting entries'); - console.log(`entries.length: ${entries.length}`); - console.log(`entries[0]: ${entries[0]}`); - console.log(`entries[0].value: ${entries[0].value}`); - console.log(`entries[0].value.value: ${entries[0].value.value}`); + console.info('Succeeded in getting entries'); + console.info(`entries.length: ${entries.length}`); + console.info(`entries[0]: ${entries[0]}`); + console.info(`entries[0].value: ${entries[0].value}`); + console.info(`entries[0].value.value: ${entries[0].value.value}`); }).catch((err) => { - console.error(`Fail to get entries.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get entries.code is ${err.code},message is ${err.message}`); }); }).catch((err) => { - console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); + console.error(`Failed to put batch.code is ${err.code},message is ${err.message}`); }); } catch (e) { - console.error(`Fail to put batch.code is ${e.code},message is ${e.message}`); + console.error(`Failed to put batch.code is ${e.code},message is ${e.message}`); } ``` @@ -5390,23 +5417,23 @@ try { } entries.push(entry); } - console.log(`entries: {entries}`); - kvStore.putBatch(entries, async function (err, data) { - console.log('Succeeded in putting Batch'); + console.info(`entries: {entries}`); + kvStore.putBatch(entries, async function (err) { + console.info('Succeeded in putting Batch'); const query = new distributedKVStore.Query(); query.prefixKey("batch_test"); kvStore.getEntries(query, function (err, entries) { if (err != undefined) { - console.error(`Fail to get Entries.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get Entries.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in getting Entries'); - console.log(`entries.length: ${entries.length}`); - console.log(`entries[0]: ${entries[0]}`); + console.info('Succeeded in getting Entries'); + console.info(`entries.length: ${entries.length}`); + console.info(`entries[0]: ${entries[0]}`); }); }); } catch (e) { - console.error(`Fail to get Entries.code is ${e.code},message is ${e.message}`); + console.error(`Failed to get Entries.code is ${e.code},message is ${e.message}`); } ``` @@ -5457,22 +5484,22 @@ try { } entries.push(entry); } - console.log(`entries: {entries}`); - kvStore.putBatch(entries).then(async (err) => { - console.log('Succeeded in putting Batch'); + console.info(`entries: {entries}`); + kvStore.putBatch(entries).then(async () => { + console.info('Succeeded in putting Batch'); const query = new distributedKVStore.Query(); query.prefixKey("batch_test"); kvStore.getEntries(query).then((entries) => { - console.log('Succeeded in getting Entries'); + console.info('Succeeded in getting Entries'); }).catch((err) => { - console.error(`Fail to get Entries.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get Entries.code is ${err.code},message is ${err.message}`); }); }).catch((err) => { - console.error(`Fail to get Entries.code is ${err.code},message is ${err.message}`) + console.error(`Failed to get Entries.code is ${err.code},message is ${err.message}`) }); - console.log('Succeeded in getting Entries'); + console.info('Succeeded in getting Entries'); } catch (e) { - console.error(`Fail to get Entries.code is ${e.code},message is ${e.message}`); + console.error(`Failed to get Entries.code is ${e.code},message is ${e.message}`); } ``` @@ -5519,29 +5546,29 @@ try { } entries.push(entry); } - console.log(`entries: ${entries}`); - kvStore.putBatch(entries, async function (err, data) { + console.info(`entries: ${entries}`); + kvStore.putBatch(entries, async function (err) { if (err != undefined) { - console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); + console.error(`Failed to put batch.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in putting batch'); + console.info('Succeeded in putting batch'); var query = new distributedKVStore.Query(); query.deviceId('localDeviceId'); query.prefixKey("batch_test"); kvStore.getEntries('localDeviceId', query, function (err, entries) { if (err != undefined) { - console.error(`Fail to get entries.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get entries.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in getting entries'); - console.log(`entries.length: ${entries.length}`); - console.log(`entries[0]: ${entries[0]}`); + console.info('Succeeded in getting entries'); + console.info(`entries.length: ${entries.length}`); + console.info(`entries[0]: ${entries[0]}`); }) }); - console.log('Succeeded in getting entries'); + console.info('Succeeded in getting entries'); } catch (e) { - console.error(`Fail to get entries.code is ${e.code},message is ${e.message}`); + console.error(`Failed to get entries.code is ${e.code},message is ${e.message}`); } ``` @@ -5593,23 +5620,23 @@ try { } entries.push(entry); } - console.log(`entries: ${entries}`); - kvStore.putBatch(entries).then(async (err) => { - console.log('Succeeded in putting batch'); + console.info(`entries: ${entries}`); + kvStore.putBatch(entries).then(async () => { + console.info('Succeeded in putting batch'); var query = new distributedKVStore.Query(); query.deviceId('localDeviceId'); query.prefixKey("batch_test"); kvStore.getEntries('localDeviceId', query).then((entries) => { - console.log('Succeeded in getting entries'); + console.info('Succeeded in getting entries'); }).catch((err) => { - console.error(`Fail to get entries.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get entries.code is ${err.code},message is ${err.message}`); }); }).catch((err) => { - console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); + console.error(`Failed to put batch.code is ${err.code},message is ${err.message}`); }); - console.log('Succeeded in getting entries'); + console.info('Succeeded in getting entries'); } catch (e) { - console.error(`Fail to get entries.code is ${e.code},message is ${e.message}`); + console.error(`Failed to get entries.code is ${e.code},message is ${e.message}`); } ``` @@ -5655,25 +5682,25 @@ try { } entries.push(entry); } - kvStore.putBatch(entries, async function (err, data) { + kvStore.putBatch(entries, async function (err) { if (err != undefined) { - console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); + console.error(`Failed to put batch.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in putting batch'); + console.info('Succeeded in putting batch'); kvStore.getResultSet('batch_test_string_key', async function (err, result) { if (err != undefined) { - console.error(`Fail to get resultset.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get resultset.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in getting result set'); + console.info('Succeeded in getting result set'); resultSet = result; - kvStore.closeResultSet(resultSet, function (err, data) { + kvStore.closeResultSet(resultSet, function (err) { if (err != undefined) { - console.error(`Fail to close resultset.code is ${err.code},message is ${err.message}`); + console.error(`Failed to close resultset.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in closing result set'); + console.info('Succeeded in closing result set'); }) }); }); @@ -5729,21 +5756,21 @@ try { } entries.push(entry); } - kvStore.putBatch(entries).then(async (err) => { - console.log('Succeeded in putting batch'); + kvStore.putBatch(entries).then(async () => { + console.info('Succeeded in putting batch'); }).catch((err) => { - console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); + console.error(`Failed to put batch.code is ${err.code},message is ${err.message}`); }); kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('Succeeded in getting result set'); + console.info('Succeeded in getting result set'); resultSet = result; }).catch((err) => { - console.error(`Fail to get resultset.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get resultset.code is ${err.code},message is ${err.message}`); }); - kvStore.closeResultSet(resultSet).then((err) => { - console.log('Succeeded in closing result set'); + kvStore.closeResultSet(resultSet).then(() => { + console.info('Succeeded in closing result set'); }).catch((err) => { - console.error(`Fail to close resultset.code is ${err.code},message is ${err.message}`); + console.error(`Failed to close resultset.code is ${err.code},message is ${err.message}`); }); } catch (e) { console.error(`An unexpected error occurred.code is ${e.code},message is ${e.code}`); @@ -5783,21 +5810,21 @@ try { let resultSet; kvStore.getResultSet('localDeviceId', 'batch_test_string_key', async function (err, result) { if (err != undefined) { - console.error(`Fail to get resultSet.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get resultSet.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in getting resultSet'); + console.info('Succeeded in getting resultSet'); resultSet = result; - kvStore.closeResultSet(resultSet, function (err, data) { + kvStore.closeResultSet(resultSet, function (err) { if (err != undefined) { - console.error(`Fail to close resultSet.code is ${err.code},message is ${err.message}`); + console.error(`Failed to close resultSet.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in closing resultSet'); + console.info('Succeeded in closing resultSet'); }) }); } catch (e) { - console.error(`Fail to get resultSet.code is ${e.code},message is ${e.message}`); + console.error(`Failed to get resultSet.code is ${e.code},message is ${e.message}`); } ``` @@ -5838,18 +5865,18 @@ let kvStore; try { let resultSet; kvStore.getResultSet('localDeviceId', 'batch_test_string_key').then((result) => { - console.log('Succeeded in getting resultSet'); + console.info('Succeeded in getting resultSet'); resultSet = result; }).catch((err) => { - console.error(`Fail to get resultSet.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get resultSet.code is ${err.code},message is ${err.message}`); }); - kvStore.closeResultSet(resultSet).then((err) => { - console.log('Succeeded in closing resultSet'); + kvStore.closeResultSet(resultSet).then(() => { + console.info('Succeeded in closing resultSet'); }).catch((err) => { - console.error(`Fail to close resultSet.code is ${err.code},message is ${err.message}`); + console.error(`Failed to close resultSet.code is ${err.code},message is ${err.message}`); }); } catch (e) { - console.error(`Fail to get resultSet.code is ${e.code},message is ${e.message}`); + console.error(`Failed to get resultSet.code is ${e.code},message is ${e.message}`); } ``` @@ -5896,32 +5923,32 @@ try { } entries.push(entry); } - kvStore.putBatch(entries, async function (err, data) { + kvStore.putBatch(entries, async function (err) { if (err != undefined) { - console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); + console.error(`Failed to put batch.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in putting batch'); + console.info('Succeeded in putting batch'); const query = new distributedKVStore.Query(); query.prefixKey("batch_test"); kvStore.getResultSet('localDeviceId', query, async function (err, result) { if (err != undefined) { - console.error(`Fail to get resultSet.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get resultSet.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in getting resultSet'); + console.info('Succeeded in getting resultSet'); resultSet = result; - kvStore.closeResultSet(resultSet, function (err, data) { + kvStore.closeResultSet(resultSet, function (err) { if (err != undefined) { - console.error(`Fail to close resultSet.code is ${err.code},message is ${err.message}`); + console.error(`Failed to close resultSet.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in closing resultSet'); + console.info('Succeeded in closing resultSet'); }) }); }); } catch (e) { - console.error(`Fail to get resultSet.code is ${e.code},message is ${e.message}`); + console.error(`Failed to get resultSet.code is ${e.code},message is ${e.message}`); } ``` @@ -5973,29 +6000,29 @@ try { } entries.push(entry); } - kvStore.putBatch(entries).then(async (err) => { - console.log('Succeeded in putting batch'); + kvStore.putBatch(entries).then(async () => { + console.info('Succeeded in putting batch'); }).catch((err) => { - console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); + console.error(`Failed to put batch.code is ${err.code},message is ${err.message}`); }); const query = new distributedKVStore.Query(); query.prefixKey("batch_test"); kvStore.getResultSet('localDeviceId', query).then((result) => { - console.log('Succeeded in getting resultSet'); + console.info('Succeeded in getting resultSet'); resultSet = result; }).catch((err) => { - console.error(`Fail to get resultSet.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get resultSet.code is ${err.code},message is ${err.message}`); }); query.deviceId('localDeviceId'); - console.log("GetResultSet " + query.getSqlLike()); - kvStore.closeResultSet(resultSet).then((err) => { - console.log('Succeeded in closing resultSet'); + console.info("GetResultSet " + query.getSqlLike()); + kvStore.closeResultSet(resultSet).then(() => { + console.info('Succeeded in closing resultSet'); }).catch((err) => { - console.error(`Fail to close resultSet.code is ${err.code},message is ${err.message}`); + console.error(`Failed to close resultSet.code is ${err.code},message is ${err.message}`); }); } catch (e) { - console.error(`Fail to get resultSet.code is ${e.code},message is ${e.message}`); + console.error(`Failed to get resultSet.code is ${e.code},message is ${e.message}`); } ``` @@ -6046,15 +6073,15 @@ try { } entries.push(entry); } - kvStore.putBatch(entries).then(async (err) => { - console.log('Succeeded in putting batch'); + kvStore.putBatch(entries).then(async () => { + console.info('Succeeded in putting batch'); }).catch((err) => { - console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); + console.error(`Failed to put batch.code is ${err.code},message is ${err.message}`); }); const query = new distributedKVStore.Query(); query.prefixKey("batch_test"); kvStore.getResultSet(query).then((result) => { - console.log('Succeeded in getting result set'); + console.info('Succeeded in getting result set'); resultSet = result; }).catch((err) => { console.error(`Fail to get resultset.code is ${err.code},message is ${err.message}`); @@ -6066,24 +6093,18 @@ try { ### getResultSet -getResultSet(deviceId: string, query: Query): Promise<KVStoreResultSet> +getResultSet(query: Query, callback:AsyncCallback<KVStoreResultSet>): void -获取与指定设备ID和Query对象匹配的KVStoreResultSet对象,使用Promise异步回调。 +获取与本设备指定Query对象匹配的KVStoreResultSet对象,使用callback异步回调。 -**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore +**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------- | ---- | ---------------------------------- | -| deviceId | string | 是 | KVStoreResultSet对象所属的设备ID。 | | query | [Query](#query) | 是 | 表示查询对象。 | - -**返回值:** - -| 类型 | 说明 | -| ---------------------------------------------------- | ------------------------------------------------------------ | -| Promise<[KVStoreResultSet](#kvstoreresultset)> | Promise对象。返回与指定设备ID和Query对象匹配的KVStoreResultSet对象。 | +| callback | AsyncCallback<[KVStoreResultSet](#kvstoreresultset)> | 是 | 回调函数,获取与指定Predicates对象匹配的KVStoreResultSet对象。 | **错误码:** @@ -6112,29 +6133,32 @@ try { } entries.push(entry); } - kvStore.putBatch(entries).then(async (err) => { - console.log('Succeeded in putting batch'); - }).catch((err) => { - console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); - }); - const query = new distributedKVStore.Query(); - query.prefixKey("batch_test"); - kvStore.getResultSet('localDeviceId', query).then((result) => { - console.log('Succeeded in getting resultSet'); - resultSet = result; - }).catch((err) => { - console.error(`Fail to get resultSet.code is ${err.code},message is ${err.message}`); - }); - query.deviceId('localDeviceId'); - console.log("GetResultSet " + query.getSqlLike()); - kvStore.closeResultSet(resultSet).then((err) => { - console.log('Succeeded in closing resultSet'); - }).catch((err) => { - console.error(`Fail to close resultSet.code is ${err.code},message is ${err.message}`); + kvStore.putBatch(entries, async function (err) { + if (err != undefined) { + console.error(`Failed to put batch.code is ${err.code},message is ${err.message}`); + return; + } + console.info('Succeeded in putting batch'); + const query = new distributedKVStore.Query(); + query.prefixKey("batch_test"); + kvStore.getResultSet(query, async function (err, result) { + if (err != undefined) { + console.error(`Failed to get resultSet.code is ${err.code},message is ${err.message}`); + return; + } + console.info('Succeeded in getting resultSet'); + resultSet = result; + kvStore.closeResultSet(resultSet, function (err) { + if (err != undefined) { + console.error(`Failed to close resultSet.code is ${err.code},message is ${err.message}`); + return; + } + console.info('Succeeded in closing resultSet'); + }) + }); }); - } catch (e) { - console.error(`Fail to get resultSet.code is ${e.code},message is ${e.message}`); + console.error(`Failed to get resultSet.code is ${e.code},message is ${e.message}`); } ``` @@ -6176,17 +6200,17 @@ try { predicates.prefixKey("batch_test_string_key"); kvStore.getResultSet(predicates, async function (err, result) { if (err != undefined) { - console.error(`Fail to get resultset.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get resultset.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in getting result set'); + console.info('Succeeded in getting result set'); resultSet = result; - kvStore.closeResultSet(resultSet, function (err, data) { + kvStore.closeResultSet(resultSet, function (err) { if (err != undefined) { - console.error(`Fail to close resultset.code is ${err.code},message is ${err.message}`); + console.error(`Failed to close resultset.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in closing result set'); + console.info('Succeeded in closing result set'); }) }); } catch (e) { @@ -6236,15 +6260,15 @@ try { let predicates = new dataSharePredicates.DataSharePredicates(); predicates.prefixKey("batch_test_string_key"); kvStore.getResultSet(predicates).then((result) => { - console.log('Succeeded in getting result set'); + console.info('Succeeded in getting result set'); resultSet = result; }).catch((err) => { - console.error(`Fail to get resultset.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get resultset.code is ${err.code},message is ${err.message}`); }); - kvStore.closeResultSet(resultSet).then((err) => { - console.log('Succeeded in closing result set'); + kvStore.closeResultSet(resultSet).then(() => { + console.info('Succeeded in closing result set'); }).catch((err) => { - console.error(`Fail to close resultset.code is ${err.code},message is ${err.message}`); + console.error(`Failed to close resultset.code is ${err.code},message is ${err.message}`); }); } catch (e) { console.error(`An unexpected error occurred.code is ${e.code},message is ${e.code}`); @@ -6290,17 +6314,17 @@ try { predicates.prefixKey("batch_test_string_key"); kvStore.getResultSet('localDeviceId', predicates, async function (err, result) { if (err != undefined) { - console.error(`Fail to get resultset.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get resultset.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in getting result set'); + console.info('Succeeded in getting result set'); resultSet = result; - kvStore.closeResultSet(resultSet, function (err, data) { + kvStore.closeResultSet(resultSet, function (err) { if (err != undefined) { - console.error(`Fail to close resultset.code is ${err.code},message is ${err.message}`); + console.error(`Failed to close resultset.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in closing result set'); + console.info('Succeeded in closing result set'); }) }); } catch (e) { @@ -6350,15 +6374,15 @@ try { let predicates = new dataSharePredicates.DataSharePredicates(); predicates.prefixKey("batch_test_string_key"); kvStore.getResultSet('localDeviceId', predicates).then((result) => { - console.log('Succeeded in getting result set'); + console.info('Succeeded in getting result set'); resultSet = result; }).catch((err) => { - console.error(`Fail to get resultset.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get resultset.code is ${err.code},message is ${err.message}`); }); - kvStore.closeResultSet(resultSet).then((err) => { - console.log('Succeeded in closing result set'); + kvStore.closeResultSet(resultSet).then(() => { + console.info('Succeeded in closing result set'); }).catch((err) => { - console.error(`Fail to close resultset.code is ${err.code},message is ${err.message}`); + console.error(`Failed to close resultset.code is ${err.code},message is ${err.message}`); }); } catch (e) { console.error(`An unexpected error occurred.code is ${e.code},message is ${e.code}`); @@ -6406,16 +6430,16 @@ try { } entries.push(entry); } - kvStore.putBatch(entries, async function (err, data) { - console.log('Succeeded in putting batch'); + kvStore.putBatch(entries, async function (err) { + console.info('Succeeded in putting batch'); const query = new distributedKVStore.Query(); query.prefixKey("batch_test"); kvStore.getResultSize(query, async function (err, resultSize) { if (err != undefined) { - console.error(`Fail to get result size.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get result size.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in getting result set size'); + console.info('Succeeded in getting result set size'); }); }); } catch (e) { @@ -6469,17 +6493,17 @@ try { } entries.push(entry); } - kvStore.putBatch(entries).then(async (err) => { - console.log('Succeeded in putting batch'); + kvStore.putBatch(entries).then(async () => { + console.info('Succeeded in putting batch'); }).catch((err) => { - console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); + console.error(`Failed to put batch.code is ${err.code},message is ${err.message}`); }); const query = new distributedKVStore.Query(); query.prefixKey("batch_test"); kvStore.getResultSize(query).then((resultSize) => { - console.log('Succeeded in getting result set size'); + console.info('Succeeded in getting result set size'); }).catch((err) => { - console.error(`Fail to get result size.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get result size.code is ${err.code},message is ${err.message}`); }); } catch (e) { console.error(`An unexpected error occurred.code is ${e.code},message is ${e.code}`); @@ -6528,25 +6552,24 @@ try { } entries.push(entry); } - kvStore.putBatch(entries, async function (err, data) { + kvStore.putBatch(entries, async function (err) { if (err != undefined) { - console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); + console.error(`Failed to put batch.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in putting batch'); + console.info('Succeeded in putting batch'); const query = new distributedKVStore.Query(); query.prefixKey("batch_test"); kvStore.getResultSize('localDeviceId', query, async function (err, resultSize) { if (err != undefined) { - console.error(`Fail to get resultSize.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get resultSize.code is ${err.code},message is ${err.message}`); return; } - console.log('Succeeded in getting resultSize'); - ; + console.info('Succeeded in getting resultSize'); }); }); } catch (e) { - console.error(`Fail to get resultSize.code is ${e.code},message is ${e.message}`); + console.error(`Failed to get resultSize.code is ${e.code},message is ${e.message}`); } ``` @@ -6597,20 +6620,19 @@ try { } entries.push(entry); } - kvStore.putBatch(entries).then(async (err) => { - console.log('Succeeded in putting batch'); + kvStore.putBatch(entries).then(async () => { + console.info('Succeeded in putting batch'); }).catch((err) => { - console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); + console.error(`Failed to put batch.code is ${err.code},message is ${err.message}`); }); var query = new distributedKVStore.Query(); query.prefixKey("batch_test"); kvStore.getResultSize('localDeviceId', query).then((resultSize) => { - console.log('Succeeded in getting resultSize'); - ; + console.info('Succeeded in getting resultSize'); }).catch((err) => { - console.error(`Fail to get resultSize.code is ${err.code},message is ${err.message}`); + console.error(`Failed to get resultSize.code is ${err.code},message is ${err.message}`); }); } catch (e) { - console.error(`Fail to get resultSize.code is ${e.code},message is ${e.message}`); + console.error(`Failed to get resultSize.code is ${e.code},message is ${e.message}`); } ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-file-fs.md b/zh-cn/application-dev/reference/apis/js-apis-file-fs.md index c307849df40e84c09340334b44a3ff6f120e1409..d539c580bf88445039be55b3f5fe981e465c65f1 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-file-fs.md +++ b/zh-cn/application-dev/reference/apis/js-apis-file-fs.md @@ -251,7 +251,7 @@ accessSync(path: string): boolean ## fs.close -close(file: File|number): Promise<void> +close(file: number|File): Promise<void> 关闭文件,使用Promise异步回调。 @@ -261,7 +261,7 @@ close(file: File|number): Promise<void> | 参数名 | 类型 | 必填 | 说明 | | ---- | ------ | ---- | ------------ | - | file | [File](#file)\|number | 是 | 已打开的File对象或已打开的文件描述符fd。 | + | file | number\|[File](#file) | 是 | 已打开的File对象或已打开的文件描述符fd。 | **返回值:** @@ -288,7 +288,7 @@ close(file: File|number): Promise<void> ## fs.close -close(file: File|number, callback: AsyncCallback<void>): void +close(file: number|File, callback: AsyncCallback<void>): void 关闭文件,使用callback异步回调。 @@ -298,7 +298,7 @@ close(file: File|number, callback: AsyncCallback<void>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------- | ---- | ------------ | - | file | [File](#file)\|number | 是 | 已打开的File对象或已打开的文件描述符fd。 | + | file | number\|[File](#file) | 是 | 已打开的File对象或已打开的文件描述符fd。 | | callback | AsyncCallback<void> | 是 | 异步关闭文件之后的回调。 | **错误码:** @@ -321,7 +321,7 @@ close(file: File|number, callback: AsyncCallback<void>): void ## fs.closeSync -closeSync(file: File|number): void +closeSync(file: number|File): void 以同步方法关闭文件。 @@ -331,7 +331,7 @@ closeSync(file: File|number): void | 参数名 | 类型 | 必填 | 说明 | | ---- | ------ | ---- | ------------ | - | file | [File](#file)\|number | 是 | 已打开的File对象或已打开的文件描述符fd。 | + | file | number\|[File](#file) | 是 | 已打开的File对象或已打开的文件描述符fd。 | **错误码:** @@ -1811,6 +1811,8 @@ listFile(path: string, options?: { 列出文件夹下所有文件名,支持递归列出所有文件名(包含子目录下),支持文件过滤,使用Callback异步回调。 +**系统能力**:SystemCapability.FileManagement.File.FileIO + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1866,6 +1868,8 @@ listFileSync(path: string, options?: { 以同步方式列出文件夹下所有文件名,支持递归列出所有文件名(包含子目录下),支持文件过滤。 +**系统能力**:SystemCapability.FileManagement.File.FileIO + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1986,7 +1990,7 @@ moveFile(src: string, dest: string, mode?: number, callback: AsyncCallback\ **示例:** ```js - let file = fs.openSync(path, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); + let file = fs.openSync(pathDir + "/test.txt", fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); file.lock(true).then(() => { console.log("lock file successful"); }).catch((err) => { @@ -2963,7 +2967,7 @@ lock(exclusive?: boolean, callback: AsyncCallback\): void **示例:** ```js - let file = fs.openSync(path, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); + let file = fs.openSync(pathDir + "/test.txt", fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); file.lock(true, (err) => { if (err) { console.info("lock file failed with error message: " + err.message + ", error code: " + err.code); @@ -2994,7 +2998,7 @@ tryLock(exclusive?: boolean): void **示例:** ```js - let file = fs.openSync(path, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); + let file = fs.openSync(pathDir + "/test.txt", fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); file.tryLock(true); console.log("lock file successful"); ``` @@ -3014,7 +3018,7 @@ unlock(): void **示例:** ```js - let file = fs.openSync(path, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); + let file = fs.openSync(pathDir + "/test.txt", fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); file.tryLock(true); file.unlock(); console.log("unlock file successful"); diff --git a/zh-cn/application-dev/reference/apis/js-apis-fileShare.md b/zh-cn/application-dev/reference/apis/js-apis-fileShare.md index fb37ed4dc22dd0c26ff619e228e2f3cf658d5d96..bc8100dd776a50089715f6b84515db09d87b250b 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-fileShare.md +++ b/zh-cn/application-dev/reference/apis/js-apis-fileShare.md @@ -14,7 +14,7 @@ import fileShare from '@ohos.fileshare'; ## fileShare.grantUriPermission -grantUriPermission(uri: string, bundleName: string, mode: number, callback: AsyncCallback<void>): void +grantUriPermission(uri: string, bundleName: string, flag: wantConstant.Flags, callback: AsyncCallback<void>): void 对公共目录文件URI进行授权操作,使用callback异步回调。 @@ -30,7 +30,7 @@ grantUriPermission(uri: string, bundleName: string, mode: number, callback: Asyn | ------ | ------ | ---- | -------------------------- | | uri | string | 是 | 公共目录文件URI | | bundleName | string | 是 | 分享目标的包名 | -| mode | number | 是 | 授权的权限,参考[wantConstant.Flags](js-apis-app-ability-wantConstant.md#wantconstantflags)
wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION:读授权
wantConstant.Flags.FLAG_AUTH_WRITE_URI_PERMISSION:写授权| +| flag | wantConstant.Flags | 是 | 授权的权限,参考[wantConstant.Flags](js-apis-app-ability-wantConstant.md#wantconstantflags)
wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION:读授权
wantConstant.Flags.FLAG_AUTH_WRITE_URI_PERMISSION:写授权| | callback | AsyncCallback<void> | 是 | 异步授权之后的回调 | **错误码:** @@ -67,7 +67,7 @@ try { ## fileShare.grantUriPermission -grantUriPermission(uri: string, bundleName: string, mode: number): Promise<void> +grantUriPermission(uri: string, bundleName: string, flag: wantConstant.Flags): Promise<void> 将公共目录文件URI进行授权操作,使用Promise异步回调。 @@ -83,7 +83,7 @@ grantUriPermission(uri: string, bundleName: string, mode: number): Promise<vo | ------ | ------ | ---- | -------------------------- | | uri | string | 是 | 公共目录文件URI | | bundleName | string | 是 | 分享目标的包名 | -| mode | number | 是 | 授权的权限,参考[wantConstant.Flags](js-apis-app-ability-wantConstant.md#wantconstantflags)
wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION:读授权
wantConstant.Flags.FLAG_AUTH_WRITE_URI_PERMISSION:写授权| +| flag | wantConstant.Flags | 是 | 授权的权限,参考[wantConstant.Flags](js-apis-app-ability-wantConstant.md#wantconstantflags)
wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION:读授权
wantConstant.Flags.FLAG_AUTH_WRITE_URI_PERMISSION:写授权| **返回值:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-font.md b/zh-cn/application-dev/reference/apis/js-apis-font.md index f6ae982eb13e4261083ea2210256057db4e8d354..953916867dc975e7d958e3543d1454995f52a21c 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-font.md +++ b/zh-cn/application-dev/reference/apis/js-apis-font.md @@ -5,6 +5,8 @@ > **说明** > > 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> +> 本模块接口为系统接口。 ## 导入模块 diff --git a/zh-cn/application-dev/reference/apis/js-apis-hidebug.md b/zh-cn/application-dev/reference/apis/js-apis-hidebug.md index 882c616f0a128652201a64364e72230d71ccd63a..d508065063643f56d97115af46d73869b64e8ca9 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-hidebug.md +++ b/zh-cn/application-dev/reference/apis/js-apis-hidebug.md @@ -184,18 +184,18 @@ import featureAbility from '@ohos.ability.featureAbility' let context = featureAbility.getContext(); context.getFilesDir().then((data) => { - var path = data + "/serviceInfo.txt" - console.info("output path: " + path) - let fd = fs.openSync(path, 0o102, 0o666) - var serviceId = 10 - var args = new Array("allInfo") + var path = data + "/serviceInfo.txt"; + console.info("output path: " + path); + let file = fs.openSync(path, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); + var serviceId = 10; + var args = new Array("allInfo"); try { - hidebug.getServiceDump(serviceId, fd, args) + hidebug.getServiceDump(serviceId, file.fd, args); } catch (error) { - console.info(error.code) - console.info(error.message) + console.info(error.code); + console.info(error.message); } - fs.closeSync(fd); + fs.closeSync(file); }) ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-wantAgent-wantAgentInfo.md b/zh-cn/application-dev/reference/apis/js-apis-inner-wantAgent-wantAgentInfo.md index 6adfe0d53e74a2b569efa6ecf6c42fa82a575bd2..08ac26b32b68f326c64dbafda89a80d1fd53b702 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inner-wantAgent-wantAgentInfo.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-wantAgent-wantAgentInfo.md @@ -16,7 +16,7 @@ import wantAgent from '@ohos.app.ability.wantAgent'; | 名称 | 类型 | 必填 | 说明 | | -------------- | ------------------------------- | ---- | ---------------------- | -| wants | Array\ | 是 | 将被执行的动作列表。 | +| wants | Array\<[Want](js-apis-inner-ability-want.md)\> | 是 | 将被执行的动作列表。 | | operationType | [wantAgent.OperationType](js-apis-app-ability-wantAgent.md#operationtype) | 是 | 动作类型。 | | requestCode | number | 是 | 使用者定义的一个私有值。 | | wantAgentFlags | Array<[wantAgent.WantAgentFlags](js-apis-app-ability-wantAgent.md#wantagentflags)> | 否 | 动作执行属性。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputdevice.md b/zh-cn/application-dev/reference/apis/js-apis-inputdevice.md index e9c181f466f4dbfe8f26268ce74f9482ba7514bd..af57632414bc66445c738de3e22a8b3f68c6115e 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-inputdevice.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputdevice.md @@ -176,7 +176,7 @@ try { off(type: "change", listener?: Callback<DeviceListener>): void -取消监听输入设备的热插拔事件。 +取消监听输入设备的热插拔事件。在应用退出前调用,取消监听。 **系统能力**:SystemCapability.MultimodalInput.Input.InputDevice diff --git a/zh-cn/application-dev/reference/apis/js-apis-logs.md b/zh-cn/application-dev/reference/apis/js-apis-logs.md index c13358efccef3e1223f511b38d6c458deedcc2d4..abcc3b79992632a6817223591d78b04947bb61cf 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-logs.md +++ b/zh-cn/application-dev/reference/apis/js-apis-logs.md @@ -12,6 +12,8 @@ debug(message: string, ...arguments: any[]): void 以格式化输出方式打印调试信息。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **系统能力:** SystemCapability.ArkUI.ArkUI.Full **参数:** @@ -39,6 +41,8 @@ log(message: string, ...arguments: any[]): void 以格式化输出方式打印日志信息。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **系统能力:** SystemCapability.ArkUI.ArkUI.Full **参数:** @@ -66,6 +70,8 @@ info(message: string, ...arguments: any[]): void 以格式化输出方式打印日志信息。(console.log()的别名)。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **系统能力:** SystemCapability.ArkUI.ArkUI.Full **参数:** @@ -93,6 +99,8 @@ warn(message: string, ...arguments: any[]): void 以格式化输出方式打印警告信息。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **系统能力:** SystemCapability.ArkUI.ArkUI.Full **参数:** @@ -120,6 +128,8 @@ error(message: string, ...arguments: any[]): void 以格式化输出方式打印错误信息。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **系统能力:** SystemCapability.ArkUI.ArkUI.Full **参数:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-matrix4.md b/zh-cn/application-dev/reference/apis/js-apis-matrix4.md index 761096da0211c2658e8a14f49ac3d8fa7e733801..5832fd6efc06147e0b25d403f702ef4cb10bfcc3 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-matrix4.md +++ b/zh-cn/application-dev/reference/apis/js-apis-matrix4.md @@ -16,7 +16,7 @@ import matrix4 from '@ohos.matrix4' ## matrix4.init -init(array: Array<number>): Matrix4Transit +init(option: [number,number,number,number,number,number,number,number,number,number,number,number,number,number,number,number]): Matrix4Transit Matrix的构造函数,可以通过传入的参数创建一个四阶矩阵,矩阵为列优先。 @@ -25,17 +25,17 @@ Matrix的构造函数,可以通过传入的参数创建一个四阶矩阵, **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ------------------- | ---- | ------------------------------------------------------------ | -| array | Array<number> | 是 | 参数为长度为16(4\*4)的number数组, 详情见参数描述。
默认值:
[1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1] | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| option | [number,number,number,number,number,number,number,number,number,number,number,number,number,number,number,number] | 是 | 参数为长度为16(4\*4)的number数组, 详情见四阶矩阵说明。
默认值:
[1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1] | **返回值:** -| 类型 | 说明 | -| -------------- | ---------------------------- | -| Matrix4Transit | 根据入参创建的四阶矩阵对象。 | +| 类型 | 说明 | +| --------------------------------- | ---------------------------- | +| [Matrix4Transit](#matrix4transit) | 根据入参创建的四阶矩阵对象。 | -**array参数说明:** +**四阶矩阵说明:** | 参数名 | 类型 | 必填 | 说明 | | ---- | ------ | ---- | -------------------- | @@ -91,9 +91,9 @@ Matrix的初始化函数,可以返回一个单位矩阵对象。 **返回值:** -| 类型 | 说明 | -| -------------- | -------------- | -| Matrix4Transit | 单位矩阵对象。 | +| 类型 | 说明 | +| --------------------------------- | -------------- | +| [Matrix4Transit](#matrix4transit) | 单位矩阵对象。 | **示例:** @@ -136,9 +136,9 @@ Matrix的拷贝函数,可以拷贝一份当前的矩阵对象。 **返回值:** -| 类型 | 说明 | -| -------------- | -------------------- | -| Matrix4Transit | 当前矩阵的拷贝对象。 | +| 类型 | 说明 | +| --------------------------------- | -------------------- | +| [Matrix4Transit](#matrix4transit) | 当前矩阵的拷贝对象。 | **示例:** @@ -170,12 +170,12 @@ struct Test { ![zh-cn_image_0000001219744181](figures/zh-cn_image_0000001219744181.png) -## Matrix4 +## Matrix4Transit ### combine -combine(matrix: Matrix4): Matrix4Transit +combine(option: Matrix4Transit): Matrix4Transit Matrix的叠加函数,可以将两个矩阵的效果叠加起来生成一个新的矩阵对象。 @@ -184,15 +184,15 @@ Matrix的叠加函数,可以将两个矩阵的效果叠加起来生成一个 **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ------- | ---- | ------------------ | -| matrix | Matrix4 | 是 | 待叠加的矩阵对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | --------------------------------- | ---- | ------------------ | +| option | [Matrix4Transit](#matrix4transit) | 是 | 待叠加的矩阵对象。 | **返回值:** -| 类型 | 说明 | -| -------------- | ------------------ | -| Matrix4Transit | 矩阵叠加后的对象。 | +| 类型 | 说明 | +| --------------------------------- | ------------------ | +| [Matrix4Transit](#matrix4transit) | 矩阵叠加后的对象。 | **示例:** @@ -236,9 +236,9 @@ Matrix的逆函数,可以返回一个当前矩阵对象的逆矩阵,即效 **返回值:** -| 类型 | 说明 | -| -------------- | ---------------------- | -| Matrix4Transit | 当前矩阵的逆矩阵对象。 | +| 类型 | 说明 | +| --------------------------------- | ---------------------- | +| [Matrix4Transit](#matrix4transit) | 当前矩阵的逆矩阵对象。 | **示例:** @@ -270,25 +270,23 @@ struct Tests { ### translate -translate({x?: number, y?: number, z?: number}): Matrix4Transit +translate(option: TranslateOption): Matrix4Transit -Matrix的平移函数,可以为当前矩阵增加x轴/Y轴/Z轴平移效果。 +Matrix的平移函数,可以为当前矩阵增加x轴/y轴/z轴平移效果。 **系统能力:** SystemCapability.ArkUI.ArkUI.Full **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ------ | ---- | ------------------------------------------------------------ | -| x | number | 否 | x轴的平移距离。
默认值:0
单位px
取值范围 (-∞, +∞) | -| y | number | 否 | y轴的平移距离,单位px。
默认值:0
单位px
取值范围 (-∞, +∞) | -| z | number | 否 | z轴的平移距离,单位px。
默认值:0
单位px
取值范围 (-∞, +∞) | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ----------------------------------- | ---- | -------------- | +| option | [TranslateOption](#translateoption) | 是 | 设置平移参数。 | **返回值:** -| 类型 | 说明 | -| -------------- | ---------------------------- | -| Matrix4Transit | 增加好平移效果后的矩阵对象。 | +| 类型 | 说明 | +| --------------------------------- | ---------------------------- | +| [Matrix4Transit](#matrix4transit) | 增加好平移效果后的矩阵对象。 | **示例:** @@ -315,28 +313,30 @@ struct Test { ### scale -scale({x?: number, y?: number, z?: number, centerX?: number, centerY?: number}): Matrix4Transit +scale(option: ScaleOption): Matrix4Transit -Matrix的缩放函数,可以为当前矩阵增加x轴/Y轴/Z轴缩放效果。 +Matrix的缩放函数,可以为当前矩阵增加x轴/y轴/z轴缩放效果。 **系统能力:** SystemCapability.ArkUI.ArkUI.Full **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------- | ------ | ---- | ------------------------------------------------------------ | -| x | number | 否 | x轴的缩放倍数。x>1时以x轴方向放大,x<1时以x轴方向缩小。
默认值:1
取值范围 [0, +∞)
**说明:**
设置小于0的值时,按照默认值处理。 | -| y | number | 否 | y轴的缩放倍数。y>1时以y轴方向放大,y<1时以y轴方向缩小。
默认值:1
取值范围 [0, +∞)
**说明:**
设置小于0的值时,按照默认值处理。 | -| z | number | 否 | z轴的缩放倍数。z>1时以z轴方向放大,z<1时以z轴方向缩小。
默认值:1
取值范围 [0, +∞)
**说明:**
设置小于0的值时,按照默认值处理。 | -| centerX | number | 否 | 变换中心点x轴坐标。
默认值:0
取值范围 (-∞, +∞) | -| centerY | number | 否 | 变换中心点y轴坐标。
默认值:0
取值范围 (-∞, +∞) | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | --------------------------- | ---- | -------------- | +| option | [ScaleOption](#scaleoption) | 是 | 设置缩放参数。 | **返回值:** -| 类型 | 说明 | -| -------------- | ---------------------------- | -| Matrix4Transit | 增加好缩放效果后的矩阵对象。 | +| 类型 | 说明 | +| --------------------------------- | ---------------------------- | +| [Matrix4Transit](#matrix4transit) | 增加好平移效果后的矩阵对象。 | + +**返回值:** + +| 类型 | 说明 | +| --------------------------------- | ---------------------------- | +| [Matrix4Transit](#matrix4transit) | 增加好缩放效果后的矩阵对象。 | **示例:** @@ -363,29 +363,30 @@ struct Test { ### rotate -rotate({x?: number, y?: number, z?: number, angle?: number, centerX?: Length, centerY?: Length}): Matrix4Transit +rotate(option: RotateOption): Matrix4Transit -Matrix的旋转函数,可以为当前矩阵增加x轴/Y轴/Z轴旋转效果。 +Matrix的旋转函数,可以为当前矩阵增加x轴/y轴/z轴旋转效果。 **系统能力:** SystemCapability.ArkUI.ArkUI.Full **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------- | ------ | ---- | ----------------------------------------------------- | -| x | number | 否 | 旋转轴向量x坐标。
默认值:1
取值范围 (-∞, +∞) | -| y | number | 否 | 旋转轴向量y坐标。
默认值:1
取值范围 (-∞, +∞) | -| z | number | 否 | 旋转轴向量z坐标。
默认值:1
取值范围 (-∞, +∞) | -| angle | number | 否 | 旋转角度。
默认值:0 | -| centerX | number | 否 | 变换中心点x轴坐标。
默认值:0 | -| centerY | number | 否 | 变换中心点y轴坐标。
默认值:0 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ----------------------------- | ---- | -------------- | +| option | [RotateOption](#rotateoption) | 是 | 设置旋转参数。 | **返回值:** -| 类型 | 说明 | -| -------------- | ---------------------------- | -| Matrix4Transit | 增加好旋转效果后的矩阵对象。 | +| 类型 | 说明 | +| --------------------------------- | ---------------------------- | +| [Matrix4Transit](#matrix4transit) | 增加好平移效果后的矩阵对象。 | + +**返回值:** + +| 类型 | 说明 | +| --------------------------------- | ---------------------------- | +| [Matrix4Transit](#matrix4transit) | 增加好旋转效果后的矩阵对象。 | **示例:** @@ -412,7 +413,7 @@ struct Test { ### transformPoint -transformPoint(point: Point): Point +transformPoint(option: [number, number]): [number, number] Matrix的坐标点转换函数,可以将当前的变换效果作用到一个坐标点上。 @@ -421,15 +422,15 @@ Matrix的坐标点转换函数,可以将当前的变换效果作用到一个 **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------ | ----- | ---- | ------------------ | -| point | Point | 是 | 需要转换的坐标点。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ---------------- | ---- | ------------------ | +| option | [number, number] | 是 | 需要转换的坐标点。 | **返回值:** -| 类型 | 说明 | -| ----- | ---------------- | -| Point | 返回矩阵变换后的Point对象。 | +| 类型 | 说明 | +| ---------------- | --------------------------- | +| [number, number] | 返回矩阵变换后的Point对象。 | **示例:** @@ -468,3 +469,31 @@ struct Test { ![zh-cn_image_0000001219864133](figures/zh-cn_image_0000001219864133.PNG) +## TranslateOption + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ----------------------------------------------------------- | +| x | number | 否 | x轴的平移距离,单位px。
默认值:0
取值范围 (-∞, +∞) | +| y | number | 否 | y轴的平移距离,单位px。
默认值:0
取值范围 (-∞, +∞) | +| z | number | 否 | z轴的平移距离,单位px。
默认值:0
取值范围 (-∞, +∞) | + +## ScaleOption + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------ | ---- | ------------------------------------------------------------ | +| x | number | 否 | x轴的缩放倍数。x>1时以x轴方向放大,x<1时以x轴方向缩小。
默认值:1
取值范围 [0, +∞)
**说明:**
设置小于0的值时,按照默认值处理。 | +| y | number | 否 | y轴的缩放倍数。y>1时以y轴方向放大,y<1时以y轴方向缩小。
默认值:1
取值范围 [0, +∞)
**说明:**
设置小于0的值时,按照默认值处理。 | +| z | number | 否 | z轴的缩放倍数。z>1时以z轴方向放大,z<1时以z轴方向缩小。
默认值:1
取值范围 [0, +∞)
**说明:**
设置小于0的值时,按照默认值处理。 | +| centerX | number | 否 | 变换中心点x轴坐标。
默认值:0。
取值范围 (-∞, +∞) | +| centerY | number | 否 | 变换中心点y轴坐标。
默认值:0。
取值范围 (-∞, +∞) | + +## RotateOption + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------ | ---- | ------------------------------------------------------- | +| x | number | 否 | 旋转轴向量x坐标。
默认值:1。
取值范围 (-∞, +∞) | +| y | number | 否 | 旋转轴向量y坐标。
默认值:1。
取值范围 (-∞, +∞) | +| z | number | 否 | 旋转轴向量z坐标。
默认值:1。
取值范围 (-∞, +∞) | +| angle | number | 否 | 旋转角度。
默认值:0 | +| centerX | number | 否 | 变换中心点x轴坐标。
默认值:0 | +| centerY | number | 否 | 变换中心点y轴坐标。
默认值:0 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-mediaquery.md b/zh-cn/application-dev/reference/apis/js-apis-mediaquery.md index 44a24be4f6bed086ce2a089b45b752f3b537035d..3f78f1ce07e9331ed1a7d2c8bfbb5930b1061071 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-mediaquery.md +++ b/zh-cn/application-dev/reference/apis/js-apis-mediaquery.md @@ -6,7 +6,7 @@ > > 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 > -> 该模块不支持在[UIAbility](./js-apis-app-ability-uiAbility.md)中使用。 +> 该模块不支持在[UIAbility](./js-apis-app-ability-uiAbility.md)中使用,需要在创建组件实例后使用。 ## 导入模块 diff --git a/zh-cn/application-dev/reference/apis/js-apis-privacyManager.md b/zh-cn/application-dev/reference/apis/js-apis-privacyManager.md index a9a1d0a4eee23811c76319c366265d571c1444c1..215562c589bf7149e3c64cef7c2968245bdea5b1 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-privacyManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-privacyManager.md @@ -87,7 +87,7 @@ addPermissionUsedRecord(tokenID: number, permissionName: Permissions, successCou | permissionName | Permissions | 是 | 应用权限名称。 | | successCount | number | 是 | 访问成功的次数。 | | failCount | number | 是 | 访问失败的次数。 | -| callback | AsyncCallback<void> | 是 | 回调函数。当添加使用记录成功时,err为undefine;否则为错误对象。 | +| callback | AsyncCallback<void> | 是 | 回调函数。当添加使用记录成功时,err为undefined;否则为错误对象。 | **错误码:** @@ -195,7 +195,7 @@ getPermissionUsedRecord(request: PermissionUsedRequest, callback: AsyncCallback& | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------- | ---- | ------------------------------------------ | | request | [PermissionUsedRequest](#permissionusedrequest) | 是 | 查询权限使用记录的请求。 | -| callback | AsyncCallback<[PermissionUsedResponse](#permissionusedresponse)> | 是 | 回调函数。当查询记录成功时,err为undefine,data为查询到的权限使用记录;否则为错误对象。 | +| callback | AsyncCallback<[PermissionUsedResponse](#permissionusedresponse)> | 是 | 回调函数。当查询记录成功时,err为undefined,data为查询到的权限使用记录;否则为错误对象。 | **错误码:** @@ -306,7 +306,7 @@ startUsingPermission(tokenID: number, permissionName: Permissions, callback: Asy | -------------- | --------------------- | ---- | ------------------------------------ | | tokenID | number | 是 | 调用方的应用身份标识。可通过应用的[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)获得。 | | permissionName | Permissions | 是 | 需要使用的权限名。 | -| callback | AsyncCallback<void> | 是 | 回调函数。当开始使用权限成功时,err为undefine;否则为错误对象。 | +| callback | AsyncCallback<void> | 是 | 回调函数。当开始使用权限成功时,err为undefined;否则为错误对象。 | **错误码:** @@ -409,7 +409,7 @@ stopUsingPermission(tokenID: number, permissionName: Permissions, callback: Asyn | -------------- | --------------------- | ---- | ------------------------------------ | | tokenID | number | 是 | 调用方的应用身份标识。可通过应用的[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)获得。 | | permissionName | Permissions | 是 | 需要使用的权限名。 | -| callback | AsyncCallback<void> | 是 | 回调函数。当停止使用权限成功时,err为undefine;否则为错误对象。 | +| callback | AsyncCallback<void> | 是 | 回调函数。当停止使用权限成功时,err为undefined;否则为错误对象。 | **错误码:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-promptAction.md b/zh-cn/application-dev/reference/apis/js-apis-promptAction.md index 833d6b3c6d1540dec036521f4589d5577c9be541..6fee965c333b38bfda2c911af22903a9f63dd03b 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-promptAction.md +++ b/zh-cn/application-dev/reference/apis/js-apis-promptAction.md @@ -6,7 +6,7 @@ > > 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > -> 该模块不支持在[UIAbility](./js-apis-app-ability-uiAbility.md)中使用。 +> 该模块不支持在[UIAbility](./js-apis-app-ability-uiAbility.md)中使用,需要在创建组件实例后使用。 ## 导入模块 diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-battery.md b/zh-cn/application-dev/reference/apis/js-apis-system-battery.md index 0c102a55bb2e4b90ed8caeed8866f44fc86a5f6f..6949824c67c14b7e97e354390f9e7fa3e5eb91a6 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-battery.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-battery.md @@ -25,7 +25,7 @@ getStatus(options?: GetStatusOptions): void; **参数:** -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | options | [GetStatusOptions](#getstatusoptions) | 否 | 包含接口调用结果的对象。可选,默认为空。 | @@ -48,7 +48,7 @@ battery.getStatus({ **系统能力:** SystemCapability.PowerManager.BatteryManager.Core -| 名称 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------------------------------- | ---- | ------------------------------------------------------------ | | success | (data: [BatteryResponse](#batteryresponse)) => void | 否 | 接口调用成功的回调函数,data为[BatteryResponse](#batteryresponse)类型的返回值。 | | fail | (data: string, code: number) => void | 否 | 接口调用失败的回调函数。data为错误信息,code为错误码。 | @@ -60,7 +60,7 @@ battery.getStatus({ **系统能力:** SystemCapability.PowerManager.BatteryManager.Core -| 名称 | 类型 | 可读 | 可写 | 说明 | +| 参数名 | 类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | | charging | boolean | 是 | 否 | 当前电池是否在充电中。 | | level | number | 是 | 否 | 当前电池的电量,取值范围:0.00 - 1.00 。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-router.md b/zh-cn/application-dev/reference/apis/js-apis-system-router.md index 4d22c6d63cb4a3e66c13a22cf2a2fa93fa1220c6..2a1e365ed85cd8ffac6df0244a285d47ecd237d6 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-router.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-router.md @@ -341,8 +341,8 @@ export default { | 名称 | 类型 | 必填 | 说明 | | ------ | -------- | ---- | ------------------------------------------------------------ | -| uri7+ | string | 是 | 目标页面的uri,可以是以下的两种格式:
1. 页面的绝对路径,由config.json文件中的页面列表提供。例如:
- pages/index/index
-pages/detail/detail
2. 特定路径。如果URI为斜杠(/),则显示主页。 | -| params7+ | object | 否 | 表示路由跳转时要同时传递到目标页面的数据。跳转到目标页面后,使用router.getParams()获取传递的参数,此外,在类web范式中,参数也可以在页面中直接使用,如this.keyValue(keyValue为跳转时params参数中的key值),如果目标页面中已有该字段,则其值会被传入的字段值覆盖。 | +| uri | string | 是 | 目标页面的uri,可以是以下的两种格式:
1. 页面的绝对路径,由config.json文件中的页面列表提供。例如:
- pages/index/index
-pages/detail/detail
2. 特定路径。如果URI为斜杠(/),则显示主页。 | +| params | object | 否 | 表示路由跳转时要同时传递到目标页面的数据。跳转到目标页面后,使用router.getParams()获取传递的参数,此外,在类web范式中,参数也可以在页面中直接使用,如this.keyValue(keyValue为跳转时params参数中的key值),如果目标页面中已有该字段,则其值会被传入的字段值覆盖。 | ## BackRouterOptions diff --git a/zh-cn/application-dev/reference/apis/js-apis-usbManager.md b/zh-cn/application-dev/reference/apis/js-apis-usbManager.md index 4d4b694f7ded0314d274209755474931d66fa8a8..f9a884db278e3706ceb42e17f9426e2ff2391429 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-usbManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-usbManager.md @@ -152,7 +152,7 @@ hasRight(deviceName: string): boolean **示例:** ```js -let devicesName="1-1"; +let devicesName = "1-1"; let bool = usb.hasRight(devicesName); console.log(`${bool}`); ``` @@ -180,7 +180,7 @@ requestRight(deviceName: string): Promise<boolean> **示例:** ```js -let devicesName="1-1"; +let devicesName = "1-1"; usb.requestRight(devicesName).then((ret) => { console.log(`requestRight = ${ret}`); }); @@ -209,7 +209,7 @@ removeRight(deviceName: string): boolean **示例:** ```js -let devicesName= "1-1"; +let devicesName = "1-1"; if (usb.removeRight(devicesName)) { console.log(`Succeed in removing right`); } @@ -277,6 +277,16 @@ claimInterface(pipe: USBDevicePipe, iface: USBInterface, force ?: boolean): numb **示例:** ```js +let devicesList = usb.getDevices(); +if (devicesList.length == 0) { + console.log(`device list is empty`); + return; +} + +let device = devicesList[0]; +usb.requestRight(device.name); +let devicepipe = usb.connectDevice(device); +let interfaces = device.configs[0].interfaces[0]; let ret = usb.claimInterface(devicepipe, interfaces); console.log(`claimInterface = ${ret}`); ``` @@ -307,7 +317,18 @@ releaseInterface(pipe: USBDevicePipe, iface: USBInterface): number **示例:** ```js -let ret = usb.releaseInterface(devicepipe, interfaces); +let devicesList = usb.getDevices(); +if (devicesList.length == 0) { + console.log(`device list is empty`); + return; +} + +let device = devicesList[0]; +usb.requestRight(device.name); +let devicepipe = usb.connectDevice(device); +let interfaces = device.configs[0].interfaces[0]; +let ret = usb.claimInterface(devicepipe, interfaces); +ret = usb.releaseInterface(devicepipe, interfaces); console.log(`releaseInterface = ${ret}`); ``` @@ -337,6 +358,16 @@ setConfiguration(pipe: USBDevicePipe, config: USBConfiguration): number **示例:** ```js +let devicesList = usb.getDevices(); +if (devicesList.length == 0) { + console.log(`device list is empty`); + return; +} + +let device = devicesList[0]; +usb.requestRight(device.name); +let devicepipe = usb.connectDevice(device); +let config = device.configs[0]; let ret = usb.setConfiguration(devicepipe, config); console.log(`setConfiguration = ${ret}`); ``` @@ -367,7 +398,18 @@ setInterface(pipe: USBDevicePipe, iface: USBInterface): number **示例:** ```js -let ret = usb.setInterface(devicepipe, interfaces); +let devicesList = usb.getDevices(); +if (devicesList.length == 0) { + console.log(`device list is empty`); + return; +} + +let device = devicesList[0]; +usb.requestRight(device.name); +let devicepipe = usb.connectDevice(device); +let interfaces = device.configs[0].interfaces[0]; +let ret = usb.claimInterface(devicepipe, interfaces); +ret = usb.setInterface(devicepipe, interfaces); console.log(`setInterface = ${ret}`); ``` @@ -396,6 +438,14 @@ getRawDescriptor(pipe: USBDevicePipe): Uint8Array **示例:** ```js +let devicesList = usb.getDevices(); +if (devicesList.length == 0) { + console.log(`device list is empty`); + return; +} + +usb.requestRight(devicesList[0].name); +let devicepipe = usb.connectDevice(devicesList[0]); let ret = usb.getRawDescriptor(devicepipe); ``` @@ -424,6 +474,14 @@ getFileDescriptor(pipe: USBDevicePipe): number **示例:** ```js +let devicesList = usb.getDevices(); +if (devicesList.length == 0) { + console.log(`device list is empty`); + return; +} + +usb.requestRight(devicesList[0].name); +let devicepipe = usb.connectDevice(devicesList[0]); let ret = usb.getFileDescriptor(devicepipe); ``` @@ -462,6 +520,15 @@ let param = { index: 0, data: null }; + +let devicesList = usb.getDevices(); +if (devicesList.length == 0) { + console.log(`device list is empty`); + return; +} + +usb.requestRight(devicesList[0].name); +let devicepipe = usb.connectDevice(devicesList[0]); usb.controlTransfer(devicepipe, param).then((ret) => { console.log(`controlTransfer = ${ret}`); }) @@ -498,8 +565,22 @@ bulkTransfer(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, tim //usb.getDevices 接口返回数据集合,取其中一个设备对象,并获取权限 。 //把获取到的设备对象作为参数传入usb.connectDevice;当usb.connectDevice接口成功返回之后; //才可以调用第三个接口usb.claimInterface.当usb.claimInterface 调用成功以后,再调用该接口。 +let devicesList = usb.getDevices(); +if (devicesList.length == 0) { + console.log(`device list is empty`); + return; +} + +let device = devicesList[0]; +usb.requestRight(device.name); + +let devicepipe = usb.connectDevice(device); +let interfaces = device.configs[0].interfaces[0]; +let endpoint = device.configs[0].interfaces[0].endpoints[0]; +let ret = usb.claimInterface(devicepipe, interfaces); +let buffer = new Uint8Array(128); usb.bulkTransfer(devicepipe, endpoint, buffer).then((ret) => { - console.log(`bulkTransfer = ${ret}`); + console.log(`bulkTransfer = ${ret}`); }); ``` @@ -528,6 +609,14 @@ closePipe(pipe: USBDevicePipe): number **示例:** ```js +let devicesList = usb.getDevices(); +if (devicesList.length == 0) { + console.log(`device list is empty`); + return; +} + +usb.requestRight(devicesList[0].name); +let devicepipe = usb.connectDevice(devicesList[0]); let ret = usb.closePipe(devicepipe); console.log(`closePipe = ${ret}`); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-webview.md b/zh-cn/application-dev/reference/apis/js-apis-webview.md index 1a6de8f8e5f0363326c994a00d009e990d577fe7..bd2949328712caae3c0785c742b71cc5b2b425a4 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-webview.md +++ b/zh-cn/application-dev/reference/apis/js-apis-webview.md @@ -213,7 +213,7 @@ struct WebComponent { Button('close') .onClick(() => { try { - if (this.msgPort && this.msgPort[1]) { + if (this.msgPort && this.msgPort.length == 2) { this.msgPort[1].close(); } else { console.error("msgPort is null, Please initialize first"); @@ -394,7 +394,7 @@ struct WebComponent { .onClick(() => { try { // 需要加载的URL是Resource类型。 - this.controller.loadUrl($rawfile('xxx.html')); + this.controller.loadUrl($rawfile('index.html')); } catch (error) { console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); } @@ -407,8 +407,9 @@ struct WebComponent { 2.加载沙箱路径下的本地资源文件,可以参考[web](../arkui-ts/ts-basic-components-web.md#web)加载沙箱路径的示例代码。 +加载的html文件。 ```html - + @@ -1034,6 +1035,24 @@ struct Index { } ``` +加载的html文件。 +```html + + + + + + Hello world! + + + +``` + ### runJavaScript runJavaScript(script: string, callback : AsyncCallback\): void @@ -1097,6 +1116,24 @@ struct WebComponent { } ``` +加载的html文件。 +```html + + + + + + Hello world! + + + +``` + ### runJavaScript runJavaScript(script: string): Promise\ @@ -1135,11 +1172,9 @@ import web_webview from '@ohos.web.webview' @Component struct WebComponent { controller: web_webview.WebviewController = new web_webview.WebviewController(); - @State webResult: string = ''; build() { Column() { - Text(this.webResult).fontSize(20) Web({ src: $rawfile('index.html'), controller: this.controller }) .javaScriptAccess(true) .onPageEnd(e => { @@ -1161,6 +1196,24 @@ struct WebComponent { } ``` +加载的html文件。 +```html + + + + + + Hello world! + + + +``` + ### deleteJavaScriptRegister deleteJavaScriptRegister(name: string): void @@ -1637,14 +1690,15 @@ struct WebComponent { console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); } }) - Web({ src: $rawfile('xxx.html'), controller: this.controller }) + Web({ src: $rawfile('index.html'), controller: this.controller }) } } } ``` +加载的html文件。 ```html - + @@ -2432,14 +2486,15 @@ struct WebComponent { console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); } }) - Web({ src: 'www.example.com', controller: this.controller }) + Web({ src: $rawfile('index.html'), controller: this.controller }) } } } ``` +加载的html文件。 ```html - + @@ -2504,14 +2559,15 @@ struct WebComponent { console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); } }) - Web({ src: 'www.example.com', controller: this.controller }) + Web({ src: $rawfile('index.html'), controller: this.controller }) } } } ``` +加载的html文件。 ```html - + @@ -2576,14 +2632,15 @@ struct WebComponent { console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); } }) - Web({ src: 'www.example.com', controller: this.controller }) + Web({ src: $rawfile('index.html'), controller: this.controller }) } } } ``` +加载的html文件。 ```html - + diff --git a/zh-cn/application-dev/reference/apis/js-apis-zlib.md b/zh-cn/application-dev/reference/apis/js-apis-zlib.md index d2f2a50645c1291a1766eadfb96903d25a129426..f102d9d65874ba5475a8415c13605c6543867f8f 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-zlib.md +++ b/zh-cn/application-dev/reference/apis/js-apis-zlib.md @@ -231,7 +231,7 @@ decompressFile(inFile: string, outFile: string, options: Options, callback: Asyn | 参数名 | 类型 | 必填 | 说明 | | ----------------------- | ------------------- | ---- | ------------------------------------------------------------ | -| inFile | string | 是 | 指定的待解压缩文件的文件路径,对应的路径参考[FA模型](js-apis-inner-app-context.md),[stage模型](js-apis-inner-application-context.md)。 | +| inFile | string | 是 | 指定的待解压缩文件的文件路径,文件后缀需要以.zip结尾。对应的路径参考[FA模型](js-apis-inner-app-context.md),[stage模型](js-apis-inner-application-context.md)。 | | outFile | string | 是 | 指定的解压后的文件夹路径,文件夹目录路径需要在系统中存在,不存在则会解压失败。路径必须为沙箱路径,沙箱路径可以通过context获取,具体方法可参考[application/context(Stage模型)](js-apis-inner-application-context.md)或 [app/context(FA模型)](js-apis-inner-app-context.md)。 | | options | [Options](#options) | 是 | 解压的配置参数。 | | AsyncCallback<**void**> | callback | 否 | 解压的回调函数。 | @@ -282,7 +282,7 @@ decompressFile(inFile: string, outFile: string, options: Options): Promise\8+ | boolean | 设置是否同步加载图片,默认是异步加载。同步加载时阻塞UI线程,不会显示占位图。
默认值:false
从API version 9开始,该接口支持在ArkTS卡片中使用。 | | copyOption9+ | [CopyOptions](ts-appendix-enums.md#copyoptions9) | 设置图片是否可复制(SVG图片不支持复制)。
当copyOption设置为非CopyOptions.None时,支持使用长按、鼠标右击、快捷组合键'CTRL+C'等方式进行复制。
默认值:CopyOptions.None
该接口支持在ArkTS卡片中使用。 | | colorFilter9+ | [ColorFilter](ts-types.md#colorfilter9) | 给图像设置颜色滤镜效果。
该接口支持在ArkTS卡片中使用。 | +| draggable9+ | boolean | 设置默认拖拽效果。(不能和[onDragStart](ts-universal-events-drag-drop.md)事件同时使用。)
默认值:false | > **说明:** > diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-slider.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-slider.md index 6461f7f00eb609d7202a71cf6216558b7cd3bde3..be0ff7329d00accef55d215c602c8df49e0bf948 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-slider.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-slider.md @@ -22,7 +22,7 @@ Slider(options?: {value?: number, min?: number, max?: number, step?: number, sty | 参数名 | 参数类型 | 必填 | 参数描述 | | -------- | -------- | -------- | -------- | -| value | number | 否 | 当前进度值。
默认值:min | +| value | number | 否 | 当前进度值。
默认值:参数min | | min | number | 否 | 设置最小值。
默认值:0 | | max | number | 否 | 设置最大值。
默认值:100
**说明:**
min >= max异常情况,min取默认值0,max取默认值100。
value不在[min, max]范围之内,取min/max,靠近min取min,靠近max取max。 | | step | number | 否 | 设置Slider滑动步长。
默认值:1
取值范围:[0.01, max]
**说明:**
设置小于0或百分比的值时,按默认值显示。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-web.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-web.md index 464589fd9810c45b7e4098192eb46099707fda7d..e769d76979fab7ef3d4dad1aa10b06c14bad6576 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-web.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-web.md @@ -72,7 +72,7 @@ Web(options: { src: ResourceStr, controller: WebviewController | WebController}) ```ts // xxx.ets import web_webview from '@ohos.web.webview' - let url = 'file://' + globalThis.filesDir + '/xxx.html' + let url = 'file://' + globalThis.filesDir + '/index.html' @Entry @Component @@ -103,6 +103,7 @@ Web(options: { src: ResourceStr, controller: WebviewController | WebController}) } ``` + 加载的html文件。 ```html @@ -567,15 +568,16 @@ horizontalScrollBarAccess(horizontalScrollBar: boolean) controller: web_webview.WebviewController = new web_webview.WebviewController() build() { Column() { - Web({ src: 'www.example.com', controller: this.controller }) + Web({ src: $rawfile('index.html'), controller: this.controller }) .horizontalScrollBarAccess(true) } } } ``` + 加载的html文件。 ```html - + @@ -620,15 +622,16 @@ verticalScrollBarAccess(verticalScrollBar: boolean) controller: web_webview.WebviewController = new web_webview.WebviewController() build() { Column() { - Web({ src: 'www.example.com', controller: this.controller }) + Web({ src: $rawfile('index.html'), controller: this.controller }) .verticalScrollBarAccess(true) } } } ``` + 加载的html文件。 ```html - + @@ -649,6 +652,12 @@ verticalScrollBarAccess(verticalScrollBar: boolean) ``` +### password + +password(password: boolean) + +设置是否应保存密码。该接口为空接口。 + ### cacheMode cacheMode(cacheMode: CacheMode) @@ -1215,6 +1224,18 @@ forceDarkAccess(access: boolean) } ``` +### tableData + +tableData(tableData: boolean) + +设置是否应保存表单数据。该接口为空接口。 + +### wideViewModeAccess + +wideViewModeAccess(wideViewModeAccess: boolean) + +设置web是否支持html中meta标签的viewport属性。该接口为空接口。 + ### pinchSmooth9+ pinchSmooth(isEnabled: boolean) @@ -1281,7 +1302,7 @@ onAlert(callback: (event?: { url: string; message: string; result: JsResult }) = controller: web_webview.WebviewController = new web_webview.WebviewController() build() { Column() { - Web({ src: $rawfile("xxx.html"), controller: this.controller }) + Web({ src: $rawfile("index.html"), controller: this.controller }) .onAlert((event) => { console.log("event.url:" + event.url) console.log("event.message:" + event.message) @@ -1311,8 +1332,9 @@ onAlert(callback: (event?: { url: string; message: string; result: JsResult }) = } ``` - ``` - + 加载的html文件。 + ```html + @@ -1363,7 +1385,7 @@ onBeforeUnload(callback: (event?: { url: string; message: string; result: JsResu build() { Column() { - Web({ src: $rawfile("xxx.html"), controller: this.controller }) + Web({ src: $rawfile("index.html"), controller: this.controller }) .onBeforeUnload((event) => { console.log("event.url:" + event.url) console.log("event.message:" + event.message) @@ -1393,8 +1415,9 @@ onBeforeUnload(callback: (event?: { url: string; message: string; result: JsResu } ``` - ``` - + 加载的html文件。 + ```html + @@ -1445,7 +1468,7 @@ onConfirm(callback: (event?: { url: string; message: string; result: JsResult }) build() { Column() { - Web({ src: $rawfile("xxx.html"), controller: this.controller }) + Web({ src: $rawfile("index.html"), controller: this.controller }) .onConfirm((event) => { console.log("event.url:" + event.url) console.log("event.message:" + event.message) @@ -1475,8 +1498,9 @@ onConfirm(callback: (event?: { url: string; message: string; result: JsResult }) } ``` - ``` - + 加载的html文件。 + ```html + @@ -1534,7 +1558,7 @@ onPrompt(callback: (event?: { url: string; message: string; value: string; resul build() { Column() { - Web({ src: $rawfile("xxx.html"), controller: this.controller }) + Web({ src: $rawfile("index.html"), controller: this.controller }) .onPrompt((event) => { console.log("url:" + event.url) console.log("message:" + event.message) @@ -1565,8 +1589,9 @@ onPrompt(callback: (event?: { url: string; message: string; value: string; resul } ``` - ``` - + 加载的html文件。 + ```html + @@ -1947,6 +1972,26 @@ onRefreshAccessedHistory(callback: (event?: { url: string, isRefreshed: boolean } ``` +### onSslErrorReceive(deprecated) + +onSslErrorReceive(callback: (event?: { handler: Function, error: object }) => void) + +通知用户加载资源时发生SSL错误。 + +> **说明:** +> +> 从API version 8开始支持,从API version 9开始废弃。建议使用[onSslErrorEventReceive9+](#onsslerroreventreceive9)替代。 + +### onFileSelectorShow(deprecated) + +onFileSelectorShow(callback: (event?: { callback: Function, fileSelector: object }) => void) + +调用此函数以处理具有“文件”输入类型的HTML表单,以响应用户按下的“选择文件”按钮。 + +> **说明:** +> +> 从API version 8开始支持,从API version 9开始废弃。建议使用[onShowFileSelector9+](#onshowfileselector9)替代。 + ### onRenderExited9+ onRenderExited(callback: (event?: { renderExitReason: RenderExitReason }) => void) @@ -4559,6 +4604,7 @@ registerJavaScriptProxy(options: { object: object, name: string, methodList: Arr } ``` + 加载的html文件。 ```html @@ -4620,6 +4666,7 @@ runJavaScript(options: { script: string, callback?: (result: string) => void }) } ``` + 加载的html文件。 ```html @@ -4635,7 +4682,6 @@ runJavaScript(options: { script: string, callback?: (result: string) => void }) } - ``` ### stop(deprecated) @@ -4701,17 +4747,12 @@ clearHistory(): void 通过WebCookie可以控制Web组件中的cookie的各种行为,其中每个应用中的所有web组件共享一个WebCookie。通过controller方法中的getCookieManager方法可以获取WebCookie对象,进行后续的cookie管理操作。 ### setCookie(deprecated) -setCookie(url: string, value: string): boolean -设置cookie,该方法为同步方法。设置成功返回true,否则返回false。 -从API version 9开始不再维护,建议使用[setCookie9+](../apis/js-apis-webview.md#setcookie)代替。 +setCookie(): boolean -**参数:** +设置cookie,该方法为同步方法。设置成功返回true,否则返回false。 -| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | -| ----- | ------ | ---- | ---- | ----------------- | -| url | string | 是 | - | 要设置的cookie所属的url,建议使用完整的url。 | -| value | string | 是 | - | cookie的值。 | +从API version 9开始不再维护,建议使用[setCookie9+](../apis/js-apis-webview.md#setcookie)代替。 **返回值:** @@ -4719,57 +4760,16 @@ setCookie(url: string, value: string): boolean | ------- | ------------- | | boolean | 设置cookie是否成功。 | -**示例:** - - ```ts - // xxx.ets - @Entry - @Component - struct WebComponent { - controller: WebController = new WebController() - - build() { - Column() { - Button('setCookie') - .onClick(() => { - let result = this.controller.getCookieManager().setCookie("https://www.example.com", "a=b") - console.log("result: " + result) - }) - Web({ src: 'www.example.com', controller: this.controller }) - } - } - } - ``` ### saveCookie(deprecated) + saveCookie(): boolean 将当前存在内存中的cookie同步到磁盘中,该方法为同步方法。 + 从API version 9开始不再维护,建议使用[saveCookieAsync9+](../apis/js-apis-webview.md#savecookieasync)代替。 **返回值:** | 类型 | 说明 | | ------- | -------------------- | -| boolean | 同步内存cookie到磁盘操作是否成功。 | - -**示例:** - - ```ts - // xxx.ets - @Entry - @Component - struct WebComponent { - controller: WebController = new WebController() - - build() { - Column() { - Button('saveCookie') - .onClick(() => { - let result = this.controller.getCookieManager().saveCookie() - console.log("result: " + result) - }) - Web({ src: 'www.example.com', controller: this.controller }) - } - } - } - ``` +| boolean | 同步内存cookie到磁盘操作是否成功。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-badge.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-badge.md index d95736a0d6aeb68f82eba23c2410196fbf492eb5..66ccadc2c62326e52190bb04fc06e40414a48cfe 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-badge.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-badge.md @@ -25,12 +25,13 @@ 从API version 9开始,该接口支持在ArkTS卡片中使用。 **参数:** -| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | -| -------- | -------- | -------- | -------- | -------- | -| count | number | 是 | - | 设置提醒消息数。
**说明:**
小于等于0时不显示信息标记。 | -| position | [BadgePosition](#badgeposition枚举说明) | 否 | BadgePosition.RightTop | 设置提示点显示位置。
默认值:BadgePosition.RightTop | -| maxCount | number | 否 | 99 | 最大消息数,超过最大消息时仅显示maxCount+。 | -| style | [BadgeStyle](#badgestyle对象说明) | 是 | - | Badge组件可设置样式,支持设置文本颜色、尺寸、圆点颜色和尺寸。 | + +| 参数名 | 参数类型 | 必填 | 参数描述 | +| -------- | -------- | -------- | -------- | +| count | number | 是 | 设置提醒消息数。
**说明:**
小于等于0时不显示信息标记。
取值范围:[-2147483648,2147483647],非整数时会舍去小数部分取整数部分,如5.5取5。 | +| position | [BadgePosition](#badgeposition枚举说明) | 否 | 设置提示点显示位置。
默认值:BadgePosition.RightTop | +| maxCount | number | 否 | 最大消息数,超过最大消息时仅显示maxCount+。
默认值:99
取值范围:[-2147483648,2147483647],非整数时会舍去小数部分取整数部分,如5.5取5。 | +| style | [BadgeStyle](#badgestyle对象说明) | 是 | Badge组件可设置样式,支持设置文本颜色、尺寸、圆点颜色和尺寸。 | **方法2:** Badge(value: {value: string, position?: BadgePosition, style: BadgeStyle}) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-sidebarcontainer.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-sidebarcontainer.md index 6de91287fa67f28087b7ae1311093bc6c6b33aea..94655ff5430bceb62743369ba2e70a8d5c30b172 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-sidebarcontainer.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-sidebarcontainer.md @@ -44,7 +44,7 @@ SideBarContainer( type?: SideBarContainerType ) | showSideBar | boolean | 设置是否显示侧边栏。
默认值:true | | controlButton | [ButtonStyle](#buttonstyle对象说明) | 设置侧边栏控制按钮的属性。 | | showControlButton | boolean | 设置是否显示控制按钮。
默认值:true | -| sideBarWidth | number \| Length9+ | 设置侧边栏的宽度。
默认值:200
单位:vp
**说明:**
设置为小于0的值时按默认值显示。
受最小宽度和最大宽度限制,不在限制区域内取最近的点。
sideBarWidth优先于侧边栏子组件width,sideBarWidth未设置时默认值优先级低于侧边栏子组件width。 | +| sideBarWidth | number \| Length9+ | 设置侧边栏的宽度。
默认值:200
单位:vp
**说明:**
设置为小于0的值时按默认值显示。
受最小宽度和最大宽度限制,不在限制区域内取最近的点。
sideBarWidth优先于侧边栏子组件width,sideBarWidth未设置时默认值优先级高于侧边栏子组件width。 | | minSideBarWidth | number \| Length9+ | 设置侧边栏最小宽度。
默认值:200,单位vp
**说明:**
设置为小于0的值时按默认值显示。
值不能超过侧边栏容器本身宽度,超过使用侧边栏容器本身宽度。
minSideBarWidth优先于侧边栏子组件minWidth,minSideBarWidth未设置时默认值优先级低于侧边栏子组件minWidth。 | | maxSideBarWidth | number \| Length9+ | 设置侧边栏最大宽度。
默认值:280,单位vp
**说明:**
设置为小于0的值时按默认值显示。
值不能超过侧边栏容器本身宽度,超过使用侧边栏容器本身宽度。
maxSideBarWidth优先于侧边栏子组件maxWidth,maxSideBarWidth未设置时默认值优先级低于侧边栏子组件maxWidth。 | | autoHide9+ | boolean | 设置当侧边栏拖拽到小于最小宽度后,是否自动隐藏。
默认值:true
**说明:**
受minSideBarWidth属性方法影响,minSideBarWidth属性方法未设置值使用默认值。
拖拽过程中判断是否要自动隐藏。小于最小宽度时需要阻尼效果触发隐藏(越界一段距离) | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-methods-datepicker-dialog.md b/zh-cn/application-dev/reference/arkui-ts/ts-methods-datepicker-dialog.md index 50d072a9a221958dc2a7b21aa4608c913bc004fd..12e7e1cd23c5c05347cd5d21d966504824c753dc 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-methods-datepicker-dialog.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-methods-datepicker-dialog.md @@ -81,3 +81,5 @@ struct DatePickerDialogExample { } } ``` + +![DataPickerDialog](figures\DataPickerDialog.gif) \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-methods-textpicker-dialog.md b/zh-cn/application-dev/reference/arkui-ts/ts-methods-textpicker-dialog.md index 7bb99f5f46e8bcd2992b36025ca6e3c74a6465fc..1f4654c10228c24e46db767554e59141a1f6e5f6 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-methods-textpicker-dialog.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-methods-textpicker-dialog.md @@ -43,27 +43,31 @@ struct TextPickerDialogExample { private fruits: string[] = ['apple1', 'orange2', 'peach3', 'grape4', 'banana5'] build() { - Column() { - Button("TextPickerDialog") - .margin(20) - .onClick(() => { - TextPickerDialog.show({ - range: this.fruits, - selected: this.select, - onAccept: (value: TextPickerResult) => { - // 设置select为按下确定按钮时候的选中项index,这样当弹窗再次弹出时显示选中的是上一次确定的选项 - this.select = value.index - console.info("TextPickerDialog:onAccept()" + JSON.stringify(value)) - }, - onCancel: () => { - console.info("TextPickerDialog:onCancel()") - }, - onChange: (value: TextPickerResult) => { - console.info("TextPickerDialog:onChange()" + JSON.stringify(value)) - } + Row() { + Column() { + Button("TextPickerDialog") + .margin(20) + .onClick(() => { + TextPickerDialog.show({ + range: this.fruits, + selected: this.select, + onAccept: (value: TextPickerResult) => { + // 设置select为按下确定按钮时候的选中项index,这样当弹窗再次弹出时显示选中的是上一次确定的选项 + this.select = value.index + console.info("TextPickerDialog:onAccept()" + JSON.stringify(value)) + }, + onCancel: () => { + console.info("TextPickerDialog:onCancel()") + }, + onChange: (value: TextPickerResult) => { + console.info("TextPickerDialog:onChange()" + JSON.stringify(value)) + } + }) }) - }) - }.width('100%') + }.width('100%') + }.height('100%') } } ``` + +![TextPickerDialog](figures\TextPickerDialog.gif) \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-methods-timepicker-dialog.md b/zh-cn/application-dev/reference/arkui-ts/ts-methods-timepicker-dialog.md index 97229576c98b61f2d7fb69cf0512adc03e00f8c6..ede21f2c19aecf6ae97fee2a99bb5d951a8f72dd 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-methods-timepicker-dialog.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-methods-timepicker-dialog.md @@ -73,4 +73,6 @@ struct TimePickerDialogExample { }.width('100%') } } -``` \ No newline at end of file +``` + +![TimetPickerDialog](figures\TimePickerDialog.gif) \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-types.md b/zh-cn/application-dev/reference/arkui-ts/ts-types.md index e322a4992d1959b5e5662e8861712b2c0f522be9..279b99516bcb00697e378bccff4982619bbebf93 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-types.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-types.md @@ -144,7 +144,7 @@ | ------ | ---------------------------------------- | ---- | ---------------------------------------- | | size | [Length](#length) | 否 | 设置文本尺寸,Length为number类型时,使用fp单位。不支持设置百分比字符串。 | | weight | [FontWeight](ts-appendix-enums.md#fontweight) \| number \| string | 否 | 设置文本的字体粗细,number类型取值[100, 900],取值间隔为100,默认为400,取值越大,字体越粗。 | -| family | string \| [Resource](#resource) | 否 | 设置文本的字体列表。使用多个字体,使用','进行分割,优先级按顺序生效。例如:'Arial, sans-serif'。当前只支持'sans-serif'字体。 | +| family | string \| [Resource](#resource) | 否 | 设置文本的字体列表。使用多个字体,使用','进行分割,优先级按顺序生效。'Arial, HarmonyOS Sans'。当前只支持'HarmonyOS Sans'字体。 | | style | [FontStyle](ts-appendix-enums.md#fontstyle) | 否 | 设置文本的字体样式。 | ## Area8+ diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-zlib.md b/zh-cn/application-dev/reference/errorcodes/errorcode-zlib.md index d9c8d6a2dcf1719e07266c195b85a1f642cdb97e..23b4757bb35ab56dac394336066a2e90889df74d 100755 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-zlib.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-zlib.md @@ -21,7 +21,8 @@ The input source file is invalid. **处理步骤** 1. 检查源文件是否存在。 -2. 检查待压缩的文件路径是否存在,并且路径是否在正确的沙箱路径下。 +2. 检查源文件的后缀是否为.zip。 +3. 检查待压缩的文件路径是否存在,并且路径是否在正确的沙箱路径下。 ## 900002 传入的目标文件错误 diff --git a/zh-cn/application-dev/security/accesstoken-overview.md b/zh-cn/application-dev/security/accesstoken-overview.md index aad84e46328813bf8c93ec6eeed26ece60f2123f..ef7e1d20113d7c0f6402578ff37f469d00f59396 100644 --- a/zh-cn/application-dev/security/accesstoken-overview.md +++ b/zh-cn/application-dev/security/accesstoken-overview.md @@ -39,10 +39,14 @@ ATM (AccessTokenManager) 是OpenHarmony上基于AccessToken构建的统一的应 ![](figures/permission-workflow.jpg) +上图的数字标注,请参考以下说明: + 1:开发者可以参考下图,判断应用能否申请目标权限。 ![](figures/permission-application-process.png) +上图的数字标注,请参考以下说明: + 1:应用APL等级与权限等级的匹配关系请参考[权限等级说明](#权限等级说明)。 2:权限的授权方式分为user_grant(用户授权)和system_grant(系统授权),具体请参考[权限类型说明](#权限类型说明)。 @@ -58,6 +62,8 @@ ATM (AccessTokenManager) 是OpenHarmony上基于AccessToken构建的统一的应 ![](figures/permission-verify-process.png) +上图的数字标注,请参考以下说明: + 1:根据应用当前提供的接口是否涉及敏感的数据或者功能,使用应用权限对当前接口进行访问控制。 2:应用可以在系统已经存在的权限中[访问控制列表(ACL)说明](#访问控制列表acl说明)选择适合的权限。比如应用提供的接口会涉及到联系人信息的话,推荐使用联系人相关的权限对接口进行保护。 diff --git a/zh-cn/application-dev/security/cryptoFramework-guidelines.md b/zh-cn/application-dev/security/cryptoFramework-guidelines.md index cbfd2ba12b1b336730567bc1aafd45f98c3a45a7..c8cdd4b357c4d28dbc7f3000d634964a55409a80 100644 --- a/zh-cn/application-dev/security/cryptoFramework-guidelines.md +++ b/zh-cn/application-dev/security/cryptoFramework-guidelines.md @@ -1130,83 +1130,70 @@ function signLongMessagePromise() { ```javascript import cryptoFramework from "@ohos.security.cryptoFramework" -// turn string into uint8Arr +// 可理解的字符串转成字节流 function stringToUint8Array(str) { - var arr = []; - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)); - } - var tmpUint8Array = new Uint8Array(arr); - return tmpUint8Array; -} - -// generate dataBlob with given length -function GenDataBlob(dataBlobLen) { - var dataBlob; - if (dataBlobLen == 12) { - dataBlob = {data: stringToUint8Array("my test data")}; - } else { - console.error("GenDataBlob: dataBlobLen is invalid"); - dataBlob = {data: stringToUint8Array("my test data")}; + let arr = []; + for (let i = 0, j = str.length; i < j; ++i) { + arr.push(str.charCodeAt(i)); } - return dataBlob; + return new Uint8Array(arr); } -// md with promise async -function doMdByPromise(algName) { - var md; +// 以Promise方式完成摘要 +function doMdByPromise() { + let mdAlgName = "SHA256"; // 摘要算法名 + let message = "mdTestMessgae"; // 待摘要数据 + let md; + let mdOutput; try { - md = cryptoFramework.createMd(algName); + md = cryptoFramework.createMd(mdAlgName); } catch (error) { console.error("[Promise]: error code: " + error.code + ", message is: " + error.message); + return; } - console.error("[Promise]: Md algName is: " + md.algName); - // 初次update - var promiseMdUpdate = md.update(GenDataBlob(12)); + console.info("[Promise]: Md algName is: " + md.algName); + // 数据量较少时,可以只做一次update,将数据全部传入,接口未对入参长度做限制 + let promiseMdUpdate = md.update({ data: stringToUint8Array(message) }); promiseMdUpdate.then(() => { - // 可根据情况进行多次update - promiseMdUpdate = md.update(GenDataBlob(12)); - return promiseMdUpdate; - }).then(mdOutput => { - var PromiseMdDigest = md.digest(); + // 通过digest,返回摘要结果 + let PromiseMdDigest = md.digest(); return PromiseMdDigest; - }).then(mdOutput => { - console.error("[Promise]: MD result: " + mdOutput.data); - var mdLen = md.getMdLength(); - console.error("[Promise]: MD len: " + mdLen); + }).then(digestOutput => { + mdOutput = digestOutput; + console.info("[Promise]: MD result: " + mdOutput.data); + let mdLen = md.getMdLength(); + console.info("[Promise]: MD len: " + mdLen); }).catch(error => { console.error("[Promise]: error: " + error.message); }); } -// md with callback async -function doMdByCallback(algName) { - var md; +// 以Callback方式完成摘要 +function doMdByCallback() { + let mdAlgName = "SHA256"; // 摘要算法名 + let message = "mdTestMessgae"; // 待摘要数据 + let md; + let mdOutput; try { - md = cryptoFramework.createMd(algName); + md = cryptoFramework.createMd(mdAlgName); } catch (error) { console.error("[Callback]: error code: " + error.code + ", message is: " + error.message); } - console.error("[Callback]: Md algName is: " + md.algName); - // 初次update - md.update(GenDataBlob(12), (err,) => { + console.info("[Callback]: Md algName is: " + md.algName); + // 数据量较少时,可以只做一次update,将数据全部传入,接口未对入参长度做限制 + md.update({ data: stringToUint8Array(message) }, (err,) => { if (err) { console.error("[Callback]: err: " + err.code); } - // 可根据情况进行多次update - md.update(GenDataBlob(12), (err1,) => { + md.digest((err1, digestOutput) => { if (err1) { console.error("[Callback]: err: " + err1.code); + } else { + mdOutput = digestOutput; + console.info("[Callback]: MD result: " + mdOutput.data); + let mdLen = md.getMdLength(); + console.info("[Callback]: MD len: " + mdLen); } - md.digest((err2, mdOutput) => { - if (err2) { - console.error("[Callback]: err: " + err2.code); - } else { - console.error("[Callback]: MD result: " + mdOutput.data); - var mdLen = md.getMdLength(); - console.error("[Callback]: MD len: " + mdLen); - } - }); }); }); } @@ -1215,54 +1202,56 @@ function doMdByCallback(algName) { ```javascript import cryptoFramework from "@ohos.security.cryptoFramework" -async function updateData(index, obj, data) { - console.error("update " + (index + 1) + " MB data..."); - return obj.update(data); -} - +// 可理解的字符串转成字节流 function stringToUint8Array(str) { - var arr = []; - for (var i = 0, j = str.length; i < j; ++i) { + let arr = []; + for (let i = 0, j = str.length; i < j; ++i) { arr.push(str.charCodeAt(i)); } - var tmpUint8Array = new Uint8Array(arr); - return tmpUint8Array; + return new Uint8Array(arr); } -function GenDataBlob(dataBlobLen) { - var dataBlob; - if (dataBlobLen == 12) { - dataBlob = {data: stringToUint8Array("my test data")}; - } else { - console.error("GenDataBlob: dataBlobLen is invalid"); - dataBlob = {data: stringToUint8Array("my test data")}; - } - return dataBlob; -} -function LoopMdPromise(algName, loopSize) { - var md; +// 使用Promise方式,完成分段摘要 +async function doLoopMdPromise() { + let mdAlgName = "SHA256"; // 摘要算法名 + let md; + let mdOutput; try { - md = cryptoFramework.createMd(algName); + md = cryptoFramework.createMd(mdAlgName); } catch (error) { console.error("[Promise]: error code: " + error.code + ", message is: " + error.message); return; } - console.error("[Promise]: Md algName is: " + md.algName); - var promiseMdUpdate = md.update(GenDataBlob(12)); - promiseMdUpdate.then(() => { - var PromiseMdDigest = md.digest(); - return PromiseMdDigest; - }).then(async () => { - for (var i = 0; i < loopSize; i++) { - await updateData(i, md, GenDataBlob(12)); + console.info("[Promise]: Md algName is: " + md.algName); + let messageText = "aaaaa.....bbbbb.....ccccc.....ddddd.....eee"; // 假设信息总共43字节 + let messageArr = []; + let updateLength = 20; // 假设每20字节分段update一次,实际并无要求 + + for (let i = 0; i <= messageText.length; i++) { + if ((i % updateLength == 0 || i == messageText.length) && messageArr.length != 0) { + let message = new Uint8Array(messageArr); + let messageBlob = { data : message }; + // 使用await处理for循环里的update + try { + await md.update(messageBlob); // 分段update + } catch (error) { + console.error("await update error code: " + error.code + ", message is: " + error.message); + return; + } + messageArr = []; } - var PromiseMdDigest = md.digest(); - return PromiseMdDigest; - }).then(mdOutput => { - console.error("[Promise]: MD result: " + mdOutput.data); - var mdLen = md.getMdLength(); - console.error("[Promise]: MD len: " + mdLen); + // 按分割长度,填充messageArr + if (i < messageText.length) { + messageArr.push(messageText.charCodeAt(i)); + } + } + let PromiseMdDigest = md.digest(); + PromiseMdDigest.then(digestOutput => { + mdOutput = digestOutput; + console.info("[Promise]: MD result: " + mdOutput.data); + let mdLen = md.getMdLength(); + console.info("[Promise]: MD len: " + mdLen); }).catch(error => { console.error("[Promise]: error: " + error.message); }); @@ -1374,77 +1363,72 @@ Mac(message authentication code)可以对消息进行完整性校验,通过使 ```javascript import cryptoFramework from "@ohos.security.cryptoFramework" -// turn string into uint8Arr +// 可理解的字符串转成字节流 function stringToUint8Array(str) { - var arr = []; - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)); - } - var tmpUint8Array = new Uint8Array(arr); - return tmpUint8Array; -} - -// generate blob with this func -function GenDataBlob(dataBlobLen) { - var dataBlob; - if (dataBlobLen == 12) { - dataBlob = {data: stringToUint8Array("my test data")}; - } else { - console.error("GenDataBlob: dataBlobLen is invalid"); - dataBlob = {data: stringToUint8Array("my test data")}; + let arr = []; + for (let i = 0, j = str.length; i < j; ++i) { + arr.push(str.charCodeAt(i)); } - return dataBlob; + return new Uint8Array(arr); } -function doHmacByPromise(algName) { - var mac; +// 以Promise方式完成HMAC +function doHmacByPromise() { + let macAlgName = "SHA256"; // 摘要算法名 + let message = "hmacTestMessgae"; // 待hmac数据 + let macOutput; + let mac; try { - mac = cryptoFramework.createMac(algName); + mac = cryptoFramework.createMac(macAlgName); } catch (error) { console.error("[Promise]: error code: " + error.code + ", message is: " + error.message); } - console.error("[Promise]: Mac algName is: " + mac.algName); - var KeyBlob = { + console.info("[Promise]: Mac algName is: " + mac.algName); + let KeyBlob = { + // 128位密钥 data : stringToUint8Array("12345678abcdefgh") } - var symKeyGenerator = cryptoFramework.createSymKeyGenerator("AES128"); - var promiseConvertKey = symKeyGenerator.convertKey(KeyBlob); + let symKeyGenerator = cryptoFramework.createSymKeyGenerator("AES128"); + // 将二进制密钥转换为算法库密钥 + let promiseConvertKey = symKeyGenerator.convertKey(KeyBlob); promiseConvertKey.then(symKey => { - var promiseMacInit = mac.init(symKey); + let promiseMacInit = mac.init(symKey); return promiseMacInit; }).then(() => { - // 初次update - var promiseMacUpdate = mac.update(GenDataBlob(12)); - return promiseMacUpdate; - }).then(() => { - // 可根据情况进行多次update - var promiseMacUpdate = mac.update(GenDataBlob(12)); + // 数据量较少时,可以只做一次update,将数据全部传入,接口未对入参长度做限制 + let promiseMacUpdate = mac.update({ data: stringToUint8Array(message) }); return promiseMacUpdate; }).then(() => { - var PromiseMacDoFinal = mac.doFinal(); + let PromiseMacDoFinal = mac.doFinal(); return PromiseMacDoFinal; - }).then(macOutput => { - console.error("[Promise]: HMAC result: " + macOutput.data); - var macLen = mac.getMacLength(); - console.error("[Promise]: MAC len: " + macLen); + }).then(output => { + macOutput = output; + console.info("[Promise]: HMAC result: " + macOutput.data); + let macLen = mac.getMacLength(); + console.info("[Promise]: MAC len: " + macLen); }).catch(error => { console.error("[Promise]: error: " + error.message); }); } -// process by callback -function doHmacByCallback(algName) { - var mac; +// 以Callback方式完成HMAC +function doHmacByCallback() { + let macAlgName = "SHA256"; // 摘要算法名 + let message = "hmacTestMessgae"; // 待hmac数据 + let macOutput; + let mac; try { - mac = cryptoFramework.createMac(algName); + mac = cryptoFramework.createMac(macAlgName); } catch (error) { - AlertDialog.show({message: "[Callback]: error code: " + error.code + ", message is: " + error.message}); console.error("[Callback]: error code: " + error.code + ", message is: " + error.message); } - var KeyBlob = { + console.info("[Promise]: Mac algName is: " + mac.algName); + let KeyBlob = { + // 128位密钥 data : stringToUint8Array("12345678abcdefgh") } - var symKeyGenerator = cryptoFramework.createSymKeyGenerator("AES128"); + let symKeyGenerator = cryptoFramework.createSymKeyGenerator("AES128"); + // 将二进制密钥转换为算法库密钥 symKeyGenerator.convertKey(KeyBlob, (err, symKey) => { if (err) { console.error("[Callback]: err: " + err.code); @@ -1453,25 +1437,20 @@ function doHmacByCallback(algName) { if (err1) { console.error("[Callback]: err: " + err1.code); } - // 初次update - mac.update(GenDataBlob(12), (err2, ) => { + // 数据量较少时,可以只做一次update,将数据全部传入,接口未对入参长度做限制 + mac.update({ data: stringToUint8Array(message) }, (err2, ) => { if (err2) { console.error("[Callback]: err: " + err2.code); } - // 可根据情况进行多次update - mac.update(GenDataBlob(12), (err3, ) => { + mac.doFinal((err3, output) => { if (err3) { console.error("[Callback]: err: " + err3.code); + } else { + macOutput = output; + console.info("[Callback]: HMAC result: " + macOutput.data); + let macLen = mac.getMacLength(); + console.info("[Callback]: MAC len: " + macLen); } - mac.doFinal((err4, macOutput) => { - if (err4) { - console.error("[Callback]: err: " + err4.code); - } else { - console.error("[Callback]: HMAC result: " + macOutput.data); - var macLen = mac.getMacLength(); - console.error("[Callback]: MAC len: " + macLen); - } - }); }); }); }); @@ -1482,61 +1461,67 @@ function doHmacByCallback(algName) { ```javascript import cryptoFramework from "@ohos.security.cryptoFramework" -async function updateData(index, obj, data) { - console.error("update " + (index + 1) + " MB data..."); - return obj.update(data); -} - function stringToUint8Array(str) { - var arr = []; - for (var i = 0, j = str.length; i < j; ++i) { + let arr = []; + for (let i = 0, j = str.length; i < j; ++i) { arr.push(str.charCodeAt(i)); } - var tmpUint8Array = new Uint8Array(arr); - return tmpUint8Array; -} - -function GenDataBlob(dataBlobLen) { - var dataBlob; - if (dataBlobLen == 12) { - dataBlob = {data: stringToUint8Array("my test data")}; - } else { - console.error("GenDataBlob: dataBlobLen is invalid"); - dataBlob = {data: stringToUint8Array("my test data")}; - } - return dataBlob; + return new Uint8Array(arr); } -function LoopHmacPromise(algName, loopSize) { - var mac; +function doLoopHmacPromise() { + let macAlgName = "SHA256"; // 摘要算法名 + let macOutput; + let mac; try { - mac = cryptoFramework.createMac(algName); + mac = cryptoFramework.createMac(macAlgName); } catch (error) { console.error("[Promise]: error code: " + error.code + ", message is: " + error.message); return; } - console.error("[Promise]: Mac algName is: " + mac.algName); - var KeyBlob = { + console.info("[Promise]: Mac algName is: " + mac.algName); + let KeyBlob = { + // 128位密钥 data : stringToUint8Array("12345678abcdefgh") } - var symKeyGenerator = cryptoFramework.createSymKeyGenerator("AES128"); - var promiseConvertKey = symKeyGenerator.convertKey(KeyBlob); + let messageText = "aaaaa.....bbbbb.....ccccc.....ddddd.....eee"; // 假设信息总共43字节 + let updateLength = 20; // 假设每20字节分段update一次,实际并无要求 + let symKeyGenerator = cryptoFramework.createSymKeyGenerator("AES128"); + // 将二进制密钥转换为算法库密钥 + let promiseConvertKey = symKeyGenerator.convertKey(KeyBlob); promiseConvertKey.then(symKey => { - var promiseMacInit = mac.init(symKey); + let promiseMacInit = mac.init(symKey); return promiseMacInit; }).then(async () => { - for (var i = 0; i < loopSize; i++) { - await updateData(i, mac, GenDataBlob(12)); + let promiseMacUpdate; + let messageArr = []; + for (let i = 0; i <= messageText.length; i++) { + if ((i % updateLength == 0 || i == messageText.length) && messageArr.length != 0) { + let message = new Uint8Array(messageArr); + let messageBlob = { data : message }; + // 使用await处理for循环里的update + try { + promiseMacUpdate = await mac.update(messageBlob); // 分段update + } catch (error) { + console.error("await update error code: " + error.code + ", message is: " + error.message); + return; + } + messageArr = []; + } + // 按分割长度,填充messageArr + if (i < messageText.length) { + messageArr.push(messageText.charCodeAt(i)); + } } - var promiseMacUpdate = mac.update(GenDataBlob(12)); return promiseMacUpdate; }).then(() => { - var PromiseMacDoFinal = mac.doFinal(); + let PromiseMacDoFinal = mac.doFinal(); return PromiseMacDoFinal; - }).then(macOutput => { - console.error("[Promise]: HMAC result: " + macOutput.data); - var macLen = mac.getMacLength(); - console.error("[Promise]: MAC len: " + macLen); + }).then(output => { + macOutput = output; + console.log("[Promise]: HMAC result: " + macOutput.data); + let macLen = mac.getMacLength(); + console.log("[Promise]: MAC len: " + macLen); }).catch(error => { console.error("[Promise]: error: " + error.message); }); diff --git a/zh-cn/application-dev/windowmanager/application-window-stage.md b/zh-cn/application-dev/windowmanager/application-window-stage.md index dd68ca50595bec0158f4f38f6aafd290f1d30ad8..8d54a68cbc43d6e2f6b34e048b20ff2ca43000a1 100644 --- a/zh-cn/application-dev/windowmanager/application-window-stage.md +++ b/zh-cn/application-dev/windowmanager/application-window-stage.md @@ -53,16 +53,18 @@ 在`Stage`模型下,应用主窗口由`UIAbility`创建并维护生命周期。在`UIAbility`的`onWindowStageCreate`回调中,通过`WindowStage`获取应用主窗口,即可对其进行属性设置等操作。还可以在应用配置文件中设置应用主窗口的属性,如最大窗口宽度maxWindowWidth等,详见[module.json5配置文件](../quick-start/module-configuration-file.md#abilities标签)。 - ### 开发步骤 1. 获取应用主窗口。 + 通过`getMainWindow`接口获取应用主窗口。 2. 设置主窗口属性。 + 可设置主窗口的背景色、亮度值、是否可触等多个属性,开发者可根据需要选择对应的接口。本示例以设置“是否可触”属性为例。 3. 为主窗口加载对应的目标页面。 + 通过`loadContent`接口加载主窗口的目标页面。 ```ts @@ -101,99 +103,101 @@ export default class EntryAbility extends UIAbility { }; ``` - ## 设置应用子窗口 开发者可以按需创建应用子窗口,如弹窗等,并对其进行属性设置等操作。 - ### 开发步骤 1. 创建应用子窗口。 + 通过`createSubWindow`接口创建应用子窗口。 2. 设置子窗口属性。 + 子窗口创建成功后,可以改变其大小、位置等,还可以根据应用需要设置窗口背景色、亮度等属性。 3. 加载显示子窗口的具体内容。 + 通过`setUIContent`和`showWindow`接口加载显示子窗口的具体内容。 4. 销毁子窗口。 + 当不再需要某些子窗口时,可根据具体实现逻辑,使用`destroyWindow`接口销毁子窗口。 - - ```ts - import UIAbility from '@ohos.app.ability.UIAbility'; - - let windowStage_ = null; - let sub_windowClass = null; - export default class EntryAbility extends UIAbility { - showSubWindow() { - // 1.创建应用子窗口。 - windowStage_.createSubWindow("mySubWindow", (err, data) => { - if (err.code) { - console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(err)); - return; - } - sub_windowClass = data; - console.info('Succeeded in creating the subwindow. Data: ' + JSON.stringify(data)); - // 2.子窗口创建成功后,设置子窗口的位置、大小及相关属性等。 - sub_windowClass.moveWindowTo(300, 300, (err) => { - if (err.code) { - console.error('Failed to move the window. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in moving the window.'); - }); - sub_windowClass.resize(500, 500, (err) => { - if (err.code) { - console.error('Failed to change the window size. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in changing the window size.'); - }); - // 3.为子窗口加载对应的目标页面。 - sub_windowClass.setUIContent("pages/page3", (err) => { - if (err.code) { - console.error('Failed to load the content. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in loading the content.'); - // 3.显示子窗口。 - sub_windowClass.showWindow((err) => { - if (err.code) { - console.error('Failed to show the window. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in showing the window.'); - }); - }); - }) - } - - destroySubWindow() { - // 4.销毁子窗口。当不再需要子窗口时,可根据具体实现逻辑,使用destroy对其进行销毁。 - sub_windowClass.destroyWindow((err) => { - if (err.code) { - console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in destroying the window.'); - }); - } - - onWindowStageCreate(windowStage) { - windowStage_ = windowStage; - // 开发者可以在适当的时机,如主窗口上按钮点击事件等,创建子窗口。并不一定需要在onWindowStageCreate调用,这里仅作展示 - this.showSubWindow(); - } - - onWindowStageDestroy() { - // 开发者可以在适当的时机,如子窗口上点击关闭按钮等,销毁子窗口。并不一定需要在onWindowStageDestroy调用,这里仅作展示 - this.destroySubWindow(); - } - }; - ``` +```ts +import UIAbility from '@ohos.app.ability.UIAbility'; + +let windowStage_ = null; +let sub_windowClass = null; + +export default class EntryAbility extends UIAbility { + showSubWindow() { + // 1.创建应用子窗口。 + windowStage_.createSubWindow("mySubWindow", (err, data) => { + if (err.code) { + console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(err)); + return; + } + sub_windowClass = data; + console.info('Succeeded in creating the subwindow. Data: ' + JSON.stringify(data)); + // 2.子窗口创建成功后,设置子窗口的位置、大小及相关属性等。 + sub_windowClass.moveWindowTo(300, 300, (err) => { + if (err.code) { + console.error('Failed to move the window. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in moving the window.'); + }); + sub_windowClass.resize(500, 500, (err) => { + if (err.code) { + console.error('Failed to change the window size. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in changing the window size.'); + }); + // 3.为子窗口加载对应的目标页面。 + sub_windowClass.setUIContent("pages/page3", (err) => { + if (err.code) { + console.error('Failed to load the content. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in loading the content.'); + // 3.显示子窗口。 + sub_windowClass.showWindow((err) => { + if (err.code) { + console.error('Failed to show the window. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in showing the window.'); + }); + }); + }) + } + + destroySubWindow() { + // 4.销毁子窗口。当不再需要子窗口时,可根据具体实现逻辑,使用destroy对其进行销毁。 + sub_windowClass.destroyWindow((err) => { + if (err.code) { + console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in destroying the window.'); + }); + } + + onWindowStageCreate(windowStage) { + windowStage_ = windowStage; + // 开发者可以在适当的时机,如主窗口上按钮点击事件等,创建子窗口。并不一定需要在onWindowStageCreate调用,这里仅作展示 + this.showSubWindow(); + } + + onWindowStageDestroy() { + // 开发者可以在适当的时机,如子窗口上点击关闭按钮等,销毁子窗口。并不一定需要在onWindowStageDestroy调用,这里仅作展示 + this.destroySubWindow(); + } +}; +``` ## 体验窗口沉浸式能力 @@ -203,75 +207,78 @@ export default class EntryAbility extends UIAbility { ### 开发步骤 1. 获取应用主窗口。 + 通过`getMainWindow`接口获取应用主窗口。 2. 实现沉浸式效果。有以下两种方式: + - 方式一:调用`setWindowSystemBarEnable`接口,设置导航栏、状态栏不显示,从而达到沉浸式效果。 - - 方式二:调用`setWindowLayoutFullScreen`接口,设置应用主窗口为全屏布局;然后调用`setWindowSystemBarProperties`接口,设置导航栏、状态栏的透明度、背景/文字颜色以及高亮图标等属性,使之保持与主窗口显示协调一致,从而达到沉浸式效果。 + - 方式二:调用`setWindowLayoutFullScreen`接口,设置应用主窗口为全屏布局;然后调用`setWindowSystemBarProperties`接口,设置导航栏、状态栏的透明度、背景/文字颜色以及高亮图标等属性,使之保持与主窗口显示协调一致,从而达到沉浸式效果。 + 3. 加载显示沉浸式窗口的具体内容。 + 通过`loadContent`接口加载沉浸式窗口的具体内容。 - - ```ts - import UIAbility from '@ohos.app.ability.UIAbility'; - - export default class EntryAbility extends UIAbility { - onWindowStageCreate(windowStage) { - // 1.获取应用主窗口。 - let windowClass = null; - windowStage.getMainWindow((err, data) => { - if (err.code) { - console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err)); - return; - } - windowClass = data; - console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data)); - - // 2.实现沉浸式效果。方式一:设置导航栏、状态栏不显示。 - let names = []; - windowClass.setWindowSystemBarEnable(names, (err) => { - if (err.code) { - console.error('Failed to set the system bar to be visible. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in setting the system bar to be visible.'); - }); - // 2.实现沉浸式效果。方式二:设置窗口为全屏布局,配合设置导航栏、状态栏的透明度、背景/文字颜色及高亮图标等属性,与主窗口显示保持协调一致。 - let isLayoutFullScreen = true; - windowClass.setWindowLayoutFullScreen(isLayoutFullScreen, (err) => { - if (err.code) { - console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in setting the window layout to full-screen mode.'); - }); - let sysBarProps = { - statusBarColor: '#ff00ff', - navigationBarColor: '#00ff00', - // 以下两个属性从API Version 8开始支持 - statusBarContentColor: '#ffffff', - navigationBarContentColor: '#ffffff' - }; - windowClass.setWindowSystemBarProperties(sysBarProps, (err) => { - if (err.code) { - console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in setting the system bar properties.'); - }); - }) - // 3.为沉浸式窗口加载对应的目标页面。 - windowStage.loadContent("pages/page2", (err) => { - if (err.code) { - console.error('Failed to load the content. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in loading the content.'); - }); - } - }; - ``` +```ts +import UIAbility from '@ohos.app.ability.UIAbility'; + +export default class EntryAbility extends UIAbility { + onWindowStageCreate(windowStage) { + // 1.获取应用主窗口。 + let windowClass = null; + windowStage.getMainWindow((err, data) => { + if (err.code) { + console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err)); + return; + } + windowClass = data; + console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data)); + + // 2.实现沉浸式效果。方式一:设置导航栏、状态栏不显示。 + let names = []; + windowClass.setWindowSystemBarEnable(names, (err) => { + if (err.code) { + console.error('Failed to set the system bar to be visible. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the system bar to be visible.'); + }); + // 2.实现沉浸式效果。方式二:设置窗口为全屏布局,配合设置导航栏、状态栏的透明度、背景/文字颜色及高亮图标等属性,与主窗口显示保持协调一致。 + let isLayoutFullScreen = true; + windowClass.setWindowLayoutFullScreen(isLayoutFullScreen, (err) => { + if (err.code) { + console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the window layout to full-screen mode.'); + }); + let sysBarProps = { + statusBarColor: '#ff00ff', + navigationBarColor: '#00ff00', + // 以下两个属性从API Version 8开始支持 + statusBarContentColor: '#ffffff', + navigationBarContentColor: '#ffffff' + }; + windowClass.setWindowSystemBarProperties(sysBarProps, (err) => { + if (err.code) { + console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the system bar properties.'); + }); + }) + // 3.为沉浸式窗口加载对应的目标页面。 + windowStage.loadContent("pages/page2", (err) => { + if (err.code) { + console.error('Failed to load the content. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in loading the content.'); + }); + } +}; +``` ## 设置悬浮窗 @@ -281,6 +288,7 @@ export default class EntryAbility extends UIAbility { ### 开发步骤 1. 申请权限。 + 创建`WindowType.TYPE_FLOAT`即悬浮窗类型的窗口,需要在`module.json5`文件的`requestPermissions`对象中配置`ohos.permission.SYSTEM_FLOAT_WINDOW`权限。更多配置信息详见[module.json5配置文件](../quick-start/module-configuration-file.md)。 > **说明:** @@ -306,77 +314,81 @@ export default class EntryAbility extends UIAbility { ``` 2. 创建悬浮窗。 + 通过`window.createWindow`接口创建悬浮窗类型的窗口。 3. 对悬浮窗进行属性设置等操作。 + 悬浮窗窗口创建成功后,可以改变其大小、位置等,还可以根据应用需要设置悬浮窗背景色、亮度等属性。 4. 加载显示悬浮窗的具体内容。 + 通过`setUIContent`和`showWindow`接口加载显示悬浮窗的具体内容。 5. 销毁悬浮窗。 当不再需要悬浮窗时,可根据具体实现逻辑,使用`destroyWindow`接口销毁悬浮窗。 - ```ts - import UIAbility from '@ohos.app.ability.UIAbility'; - import window from '@ohos.window'; - - export default class EntryAbility extends UIAbility { - onWindowStageCreate(windowStage) { - // 2. 创建悬浮窗。 - let windowClass = null; - let config = {name: "floatWindow", windowType: window.WindowType.TYPE_FLOAT, ctx: this.context}; - window.createWindow(config, (err, data) => { - if (err.code) { - console.error('Failed to create the floatWindow. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in creating the floatWindow. Data: ' + JSON.stringify(data)); - windowClass = data; - // 3.悬浮窗窗口创建成功后,设置悬浮窗的位置、大小及相关属性等。 - windowClass.moveWindowTo(300, 300, (err) => { - if (err.code) { - console.error('Failed to move the window. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in moving the window.'); - }); - windowClass.resize(500, 500, (err) => { - if (err.code) { - console.error('Failed to change the window size. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in changing the window size.'); - }); - // 4.为悬浮窗加载对应的目标页面。 - windowClass.setUIContent("pages/page4", (err) => { - if (err.code) { - console.error('Failed to load the content. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in loading the content.'); - // 4.显示悬浮窗。 - windowClass.showWindow((err) => { - if (err.code) { - console.error('Failed to show the window. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in showing the window.'); - }); - }); - //5.销毁悬浮窗。当不再需要悬浮窗时,可根据具体实现逻辑,使用destroy对其进行销毁。 - windowClass.destroyWindow((err) => { - if (err.code) { - console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in destroying the window.'); - }); - }); - } - }; - ``` +```ts +import UIAbility from '@ohos.app.ability.UIAbility'; +import window from '@ohos.window'; + +export default class EntryAbility extends UIAbility { + onWindowStageCreate(windowStage) { + // 2. 创建悬浮窗。 + let windowClass = null; + let config = {name: "floatWindow", windowType: window.WindowType.TYPE_FLOAT, ctx: this.context}; + window.createWindow(config, (err, data) => { + if (err.code) { + console.error('Failed to create the floatWindow. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in creating the floatWindow. Data: ' + JSON.stringify(data)); + windowClass = data; + // 3.悬浮窗窗口创建成功后,设置悬浮窗的位置、大小及相关属性等。 + windowClass.moveWindowTo(300, 300, (err) => { + if (err.code) { + console.error('Failed to move the window. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in moving the window.'); + }); + windowClass.resize(500, 500, (err) => { + if (err.code) { + console.error('Failed to change the window size. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in changing the window size.'); + }); + // 4.为悬浮窗加载对应的目标页面。 + windowClass.setUIContent("pages/page4", (err) => { + if (err.code) { + console.error('Failed to load the content. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in loading the content.'); + // 4.显示悬浮窗。 + windowClass.showWindow((err) => { + if (err.code) { + console.error('Failed to show the window. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in showing the window.'); + }); + }); + //5.销毁悬浮窗。当不再需要悬浮窗时,可根据具体实现逻辑,使用destroy对其进行销毁。 + windowClass.destroyWindow((err) => { + if (err.code) { + console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in destroying the window.'); + }); + }); + } +}; +``` + ## 相关实例 针对window开发(Stage模型),有以下相关实例可供参考: diff --git a/zh-cn/device-dev/device-test/figures/smartperf_frame.png b/zh-cn/device-dev/device-test/figures/smartperf_frame.png new file mode 100644 index 0000000000000000000000000000000000000000..ec6d22ff82fcfcb4750a27a00322161bb6693e6f Binary files /dev/null and b/zh-cn/device-dev/device-test/figures/smartperf_frame.png differ diff --git a/zh-cn/device-dev/device-test/smartperf-host.md b/zh-cn/device-dev/device-test/smartperf-host.md new file mode 100644 index 0000000000000000000000000000000000000000..817dda1da14b9912620da32a04168505de8f4647 --- /dev/null +++ b/zh-cn/device-dev/device-test/smartperf-host.md @@ -0,0 +1,82 @@ +# Smartperf-Host +## 简介 +Smartperf-Host是一款深入挖掘数据、细粒度地展示数据的性能功耗调优工具,旨在为开发者提供一套性能调优平台,支持对CPU调度、频点、进程线程时间片、堆内存、帧率等数据进行采集和展示,展示方式为泳道图,支持GUI(图形用户界面)操作进行详细数据分析。 +## 架构图 +![系统架构图](figures/smartperf_frame.png) +该组件整体分为设备端和PC端两部分,设备端和PC端基于gRPC(Remote Procedure Call)通信框架进行数据交互。 + +设备端内部分为应用程序内嵌组件、命令行工具、性能调优服务、性能调优插件集合、部分系统工具及部分系统内核等模块。设备端提供了插件扩展能力,对外提供了插件接口,基于该扩展能力可以按需定义自己的能力,并集成到框架中来,目前基于插件能力已经完成了native内存插件、trace插件等,详细介绍见[性能调优组件](https://gitee.com/openharmony/developtools_profiler)。 + +PC端以Smartperf-Host网站的形式进行发布,内部分为Trace Streamer数据解析、SQLite数据存储、hdc设备管理、数据导入、UI绘制、数据分析等模块。下文会重点对Smartperf-Host提供的各项能力进行介绍。 +## 项目目录 +``` +/smartperf_host +├── host # Smartperf-Host 相关代码 +│ ├── doc # Smartperf-Host 相关使用文档 +│ ├── ide # Smartperf-Host IDE 模块目录 +│ │ └── src # 主机测调优模块代码 +│ │ │ ├── base-ui # 基础组件目录 +│ │ │ └── Trace # 业务逻辑目录 +│ ├── trace_streamer # 解析模块代码目录 +│ │ ├── base # 基础功能 +│ │ ├── cfg # 配置目录 +│ │ ├── filter # Filter 功能 +│ │ ├── include # Include 头文件 +│ │ ├── multi_platform # 平台适配 +│ │ ├── parser # 解析业务逻辑 +│ │ │ ├── bytrace_parser # byTrace 解析业务逻辑 +│ │ │ └── htrace_parser # hTrace 解析业务逻辑 +│ │ ├── table # 表结构 +│ │ ├── trace_data # trace 结构 +│ │ ├── trace_streamer # traceStreamer 结构 +│ │ │ └── kits # js/napi 接口存放目录 +``` +## 功能介绍 +- 网页加载trace + + 使用Smartperf-Host加载保存在本地的trace文件(htrace、ftrace等)并显示数据到泳道图中,trace数据分析详见《[网页加载trace说明](https://gitee.com/openharmony-sig/developtools_smartperf_host/blob/master/ide/src/doc/md/quickstart_systemtrace.md)》。 +- 网页抓取trace + + 使用Smartperf-Host在线抓取trace,可以自定义抓取内容、抓取时长、trace保存路径,详见《[网页抓取trace说明](https://gitee.com/openharmony-sig/developtools_smartperf_host/blob/master/ide/src/doc/md/quickstart_web_record.md)》。 +- 设备抓取trace + + 在设备端抓取trace,可以自定义抓取内容、抓取时长、trace保存路径,详见《[设备端抓取trace说明](https://gitee.com/openharmony-sig/developtools_smartperf_host/blob/master/ide/src/doc/md/quickstart_device_record.md)》。 +- Ability Monitor抓取 + + 使用Smartperf-Host抓取应用的CPU、内存、磁盘IO和网络的使用情况,详见《[Ability Monitor抓取和展示说明](https://gitee.com/openharmony-sig/developtools_smartperf_host/blob/master/ide/src/doc/md/quickstart_ability_monitor.md)》。 +- Native Memory抓取 + + 使用Smartperf-Host抓取应用的Native Memory(C和C++部分)的分配和释放情况,详见《[Native Memory抓取和展示说明](https://gitee.com/openharmony-sig/developtools_smartperf_host/blob/master/ide/src/doc/md/quickstart_native_memory.md)》。 +- Hiperf抓取 + + 使用Smartperf-Host抓取应用的cpu使用量、方法的调用栈等,详见《[HiPerf的抓取和展示说明](https://gitee.com/openharmony-sig/developtools_smartperf_host/blob/master/ide/src/doc/md/quickstart_hiperf.md)》。 +- HiSystemEvent抓取 + + 使用Smartperf-Host抓取应用的各个子类别功耗占比(CPU、网络、定位等)、应用的资源申请使用记录(WorkScheduler、Runninglock、Alarm、Location Request)、应用功耗异常事件显示、功耗关联系统状态显示(电池电量、屏幕状态),详见《[HiSystemEvent的抓取和展示说明](https://gitee.com/openharmony-sig/developtools_smartperf_host/blob/master/ide/src/doc/md/quickstart_hisystemevent.md)》。 +- FileSystem抓取 + + 使用Smartperf-Host抓取所有文件系统系统调用信息、读写调用次数等,详见《[FileSystem的抓取和展示说明](https://gitee.com/openharmony-sig/developtools_smartperf_host/blob/master/ide/src/doc/md/quickstart_filesystem.md)》。 +- 页内存抓取 + + 使用Smartperf-Host抓取页内存相关事件的开始时间、持续时间、触发进程、触发线程、事件类型、内存地址、内存大小等,详见《[页内存的抓取和展示说明](https://gitee.com/openharmony-sig/developtools_smartperf_host/blob/master/ide/src/doc/md/quickstart_page_fault.md)》。 +- Bio抓取 + + 使用Smartperf-Host抓取每次IO访问的起始时间、总延迟、进程、每4k数据的平均延迟、线程、操作(写数据、页面换入、Metadata)、访问量、路径等、Block number、优先级、Backtrace调用栈,详见《[Bio的抓取和展示说明](https://gitee.com/openharmony-sig/developtools_smartperf_host/blob/master/ide/src/doc/md/quickstart_bio.md)》。 +- 进程Smaps抓取 + + 使用Smartperf-Host抓取单个进程的smaps数据(类别、Pss、Rss、Vss等),数据源为/proc/$pid/smaps,详见《[进程smaps的抓取和展示说明](https://gitee.com/openharmony-sig/developtools_smartperf_host/blob/master/ide/src/doc/md/quickstart_smaps.md)》。 +- Sql分析和Metrics说明 + + Smartperf-Host网站trace解析完成后在线数据库使用说明,详见《[Sql分析和Metrics说明](https://gitee.com/openharmony-sig/developtools_smartperf_host/blob/master/ide/src/doc/md/quickstart_sql_metrics.md)》。 +## 编译指南 +项目编译主要包括两部分,Trace Streamer编译和Smartperf-Host编译部署。 +### 构建约束 +- C++ 11版本或以上 +- node 16.15.1版本或以上 +- npm 8.13.2版本或以上 +- TypeScript 4.2.3版本或以上 +- golang 1.13.8版本或以上 +### Trace Streamer编译 +搭建Smartperf-Host网站需要编译出trace_streamer的wasm版本供网页端进行原始trace数据解析工作,具体的编译过程参考《[如何独立编译Trace Streamer](https://gitee.com/openharmony-sig/smartperf/blob/master/host/trace_streamer/doc/compile_trace_streamer.md)》。 +### Smartperf-Host编译部署 +具体的编译部署过程参考《[SmartPerf 编译部署指导](https://gitee.com/openharmony-sig/developtools_smartperf_host/blob/master/ide/README_zh.md)》,部署成功后通过浏览器访问页面 https://[部署机器ip地址]:9000/application/ 即可使用Smartperf-Host的全部功能。 diff --git a/zh-cn/release-notes/OpenHarmony-v3.1-beta.md b/zh-cn/release-notes/OpenHarmony-v3.1-beta.md index 19e4e1de15c466662983cf8c841b6582b676ecf5..c79534d0b49046f533d57fa36ea31aaa2e39c3e3 100644 --- a/zh-cn/release-notes/OpenHarmony-v3.1-beta.md +++ b/zh-cn/release-notes/OpenHarmony-v3.1-beta.md @@ -183,12 +183,9 @@ _[Changelog](api-change/v3.1-beta/changelog-v3.1-beta.md)_ | [分布式手写板(ArkTS)](https://gitee.com/openharmony/codelabs/tree/master/Distributed/DistributeDatabaseDrawEts) | 基于分布式能力,实现多设备同步书写互动。 | ArkTS | | [分布式数据库](https://gitee.com/openharmony/codelabs/tree/master/Data/JsDistributedData) | 基于分布式数据接口,实现多种设备上一致的数据访问体验。 | JS | | [关系型数据库](https://gitee.com/openharmony/codelabs/tree/master/Data/JSRelationshipData) | 基于关系型数据库和数据管理能力,实现数据库相关应用服务的快速开发。 | JS | -| [极简声明式UI范式(ArkTS)](https://gitee.com/openharmony/codelabs/tree/master/ETSUI/SimpleGalleryEts) | 基于OpenHarmony ArkUI,实现一个图库应用。 | ArkTS | -| [一次开发多端部署(ArkTS)](https://gitee.com/openharmony/codelabs/tree/master/ETSUI/Multi_device) | 基于OpenHarmony ArkUI,实现一次布局,多端部署。 | ArkTS | | [购物应用(ArkTS)](https://gitee.com/openharmony/codelabs/tree/master/ETSUI/ShoppingEts) | 基于OpenHarmony ArkTS UI丰富的组件实现购物商城应用。 | ArkTS | | [转场动画的使用(ArkTS)](https://gitee.com/openharmony/codelabs/tree/master/ETSUI/TransitionAnimation) | 基于OpenHarmony ArkUI转场动画,实现了页面间转场、组件内转场以及共享元素转场。 | ArkTS | | [基础组件Slider的使用(ArkTS)](https://gitee.com/openharmony/codelabs/tree/master/ETSUI/SliderExample) | 基于OpenHarmony ArkUI,使用slider组件,实现可调节风车大小和转速的动画效果。 | ArkTS | -| [流式布局(ArkTS)](https://gitee.com/openharmony/codelabs/tree/master/ETSUI/FlowLayoutEts) | 基于OpenHarmony ArkUI,实现流式布局效果。 | ArkTS | | [弹窗(ArkTS)](https://gitee.com/openharmony/codelabs/tree/master/ETSUI/CustomDialogEts) | 基于OpenHarmony ArkUI,实现警告弹窗和自定义弹窗。 | ArkTS | diff --git a/zh-cn/release-notes/OpenHarmony-v3.1-release.md b/zh-cn/release-notes/OpenHarmony-v3.1-release.md index 8330a3c33ea3096b285492faa6e8fcff7946ad4f..877a527a61e931971c06ab95ce8696384168a824 100755 --- a/zh-cn/release-notes/OpenHarmony-v3.1-release.md +++ b/zh-cn/release-notes/OpenHarmony-v3.1-release.md @@ -238,7 +238,6 @@ _[API差异报告](api-change/v3.1-Release/Readme-CN.md)_ | [音频录制应用](https://gitee.com/openharmony/codelabs/tree/master/Media/Audio_OH_ETS) | 使用媒体组件AudioRecorder收录当前音频、使用AudioPlayer播放录音的方法。 | eTS | | [备忘录](https://gitee.com/openharmony/codelabs/tree/master/Data/NotePad_OH_ETS) | 使用eTS开发一个简易备忘录,支持新建、删除和收藏笔记功能,轻量级数据库持久化存储数据。 | eTS | | [分布式邮件编辑](https://gitee.com/openharmony/codelabs/tree/master/Distributed/OHMailETS) | 使用eTS开发分布式邮件,利用分布式的能力,在相同局域网及帐号下,拉起另一个设备,实现邮件在不同设备下的编辑流转。 | eTS | -| [三方库](https://gitee.com/openharmony/codelabs/tree/master/ThirdPartyComponents/VCardDemo) | 介绍openHarmony中三方库vcard库使用:一款写入和读取特定格式的联系人数据(后缀名为vcard的文件)的OpenHarmony组件。 | eTS | ## 修复缺陷列表