提交 9b5141ca 编写于 作者: H HelloCrease

Merge branch 'OpenHarmony-3.2-Release' of https://gitee.com/HelloCrease/docs...

Merge branch 'OpenHarmony-3.2-Release' of https://gitee.com/HelloCrease/docs into OpenHarmony-3.2-Release
......@@ -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
......
......@@ -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
......
# 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.
......
......@@ -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)
......
......@@ -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 [\<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 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
# 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.
......
......@@ -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.
......
# 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
```
......@@ -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.<br>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.<br>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**
......
......@@ -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.
......
# 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.
......
......@@ -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**
......
......@@ -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.|
......
......@@ -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.
<br>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);
```
# 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.
<br>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.
<br>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.
<br>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.
<br>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.
<br>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);
```
......@@ -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)
......@@ -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<uint8_t*>(bitmapAddr));
// Destroy the canvas object.
OH_Drawing_CanvasDestroy(cCanvas);
// Destroy the bitmap object.
......
......@@ -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
......
......@@ -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 [\<Radio>](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 [\<Refresh>](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 [\<Radio>](../reference/arkui-ts/ts-basic-components-radio.md) component, and the **refreshing** parameter of the [\<Refresh>](../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
......
......@@ -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:<br>- **entry**: main module of the application.<br>- **feature**: dynamic feature module of the application.<br>- **har**: static shared module.<br>- **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.<br><br>
**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.<br>**NOTE**<br>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.<br>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.<br>**NOTE**<br>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. <br>- **true**: The ExtensionAbility component can be called by other applications.<br>- **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. <br>- **true**: The ExtensionAbility component can be called by other applications.<br>- **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
......
......@@ -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.
......
# 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.
......
......@@ -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.
......
......@@ -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)
......
......@@ -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();
......
......@@ -893,7 +893,7 @@ try {
on(type: "stateChange", callback: Callback&lt;BluetoothState&gt;): 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&lt;BluetoothState&gt;): 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&lt;[StateChangeParam](#StateChangeParam)&gt; | 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);
......
......@@ -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. |
......
......@@ -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. |
## CardType<sup>9+</sup>
......@@ -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.|
## hasHceCapability<sup>9+</sup>
......@@ -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.|
## isDefaultService<sup>9+</sup>
......@@ -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 = {
......
# @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.initialize<sup>9+</sup>
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.uninitialize<sup>9+</sup>
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&lt;string&gt;
......@@ -72,6 +106,41 @@ connectedTag.readNdefTag().then((data) => {
});
```
## connectedTag.read<sup>9+</sup>
read(): Promise&lt;number[]&gt;
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&lt;number[]&gt; | 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&lt;string&gt;): void
......@@ -102,6 +171,43 @@ connectedTag.readNdefTag((err, data)=> {
});
```
## connectedTag.read<sup>9+</sup>
read(callback: AsyncCallback&lt;number[]&gt;): 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&lt;number[]&gt; | 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&lt;void&gt;
......@@ -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.write<sup>9+</sup>
write(data: number[]): Promise&lt;void&gt;
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&lt;void&gt; | 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&lt;void&gt;): 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.write<sup>9+</sup>
write(data: number[], callback: AsyncCallback&lt;void&gt;): 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&lt;void&gt; | 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&lt;number&gt;): 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()
......
......@@ -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.
......
......@@ -23,10 +23,10 @@ Creates a distributed data object.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| context | Context | Yes| Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>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.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>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&lt;void&gt; | 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&lt;void&gt; | 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&lt;void&gt; | Yes| Asynchronous callback invoked when the distributed data object exits all joined sessions.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;void&gt; | 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&lt;string&gt; }> | Yes| Callback invoked to return the changes of the distributed data object.<br>**sessionId** indicates the session ID of the distributed data object.<br>**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&lt;string&gt; }> | Yes| Callback invoked to return the changes of the distributed data object.<br>**sessionId** indicates the session ID of the distributed data object.<br>**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&lt;string&gt; }> | No| Callback for data changes. If this parameter is not specified, all data change callbacks of this distributed data object will be unregistered.<br>**sessionId** indicates the session ID of the distributed data object.<br>**fields** indicates the changed attributes of the distributed data object.|
| callback | Callback<{ sessionId: string, fields: Array&lt;string&gt; }> | No| Callback for data changes. If this parameter is not specified, all data change callbacks of this distributed data object will be unregistered.<br>**sessionId** indicates the session ID of the distributed data object.<br>**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.<br>**sessionId** indicates the session ID of the distributed data object.<br>**networkId** indicates the object device ID, that is, **deviceId**.<br>**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.<br>**sessionId** indicates the session ID of the distributed data object.<br>**networkId** indicates the object device ID, that is, **deviceId**.<br>**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.<br>**sessionId** indicates the session ID of the distributed data object.<br>**deviceId** indicates the device ID of the distributed data object.<br>**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.<br>**sessionId** indicates the session ID of the distributed data object.<br>**deviceId** indicates the device ID of the distributed data object.<br>**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&lt;[SaveSuccessResponse](#savesuccessresponse9)&gt; | 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&lt;[SaveSuccessResponse](#savesuccessresponse9)&gt; | 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&lt;[SaveSuccessResponse](#savesuccessresponse9)&gt; | Promise used to return **SaveSuccessResponse**, which contains information such as session ID, version, and device ID.|
| Type| Description|
| -------- | -------- |
| Promise&lt;[SaveSuccessResponse](#savesuccessresponse9)&gt; | 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&lt;RevokeSaveSuccessResponse&gt;): 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&lt;[RevokeSaveSuccessResponse](#revokesavesuccessresponse9)&gt; | Yes| Callback invoked to return **RevokeSaveSuccessResponse**, which contains the session ID.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;[RevokeSaveSuccessResponse](#revokesavesuccessresponse9)&gt; | Yes| Callback invoked to return **RevokeSaveSuccessResponse**, which contains the session ID.|
**Example**
......@@ -468,7 +468,7 @@ g_object.revokeSave((err, result) => {
revokeSave(): Promise&lt;RevokeSaveSuccessResponse&gt;
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&lt;[RevokeSaveSuccessResponse](#revokesavesuccessresponse9)&gt; | Promise used to return **RevokeSaveSuccessResponse**, which contains the session ID.|
| Type| Description|
| -------- | -------- |
| Promise&lt;[RevokeSaveSuccessResponse](#revokesavesuccessresponse9)&gt; | 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;<br>returns **false** otherwise. |
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the session ID is set successfully;<br>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&lt;string&gt; }> | Yes| Callback invoked to return the changes of the distributed data object.<br>**sessionId** indicates the session ID of the distributed data object.<br>**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&lt;string&gt; }> | Yes| Callback invoked to return the changes of the distributed data object.<br>**sessionId** indicates the session ID of the distributed data object.<br>**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&lt;string&gt; }> | No| Callback for data changes. If this parameter is not specified, all data change callbacks of this distributed data object will be unregistered.<br>**sessionId** indicates the session ID of the distributed data object.<br>**fields** indicates the changed attributes of the distributed data object.|
| callback | Callback<{ sessionId: string, fields: Array&lt;string&gt; }> | No| Callback for data changes. If this parameter is not specified, all data change callbacks of this distributed data object will be unregistered.<br>**sessionId** indicates the session ID of the distributed data object.<br>**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.<br>**sessionId** indicates the session ID of the distributed data object.<br>**networkId** indicates the object device ID, that is, **deviceId**.<br>**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.<br>**sessionId** indicates the session ID of the distributed data object.<br>**networkId** indicates the object device ID, that is, **deviceId**.<br>**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.<br>**sessionId** indicates the session ID of the distributed data object.<br>**deviceId** indicates the device ID of the distributed data object.<br>**status** indicates the object status, which can be online or offline.|
......
......@@ -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;
......
......@@ -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**<br/>
> **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**<br/>
> **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&lt;Array&lt;string&gt;&gt; | Yes| Observer that listens for the data changes in the RDB store.|
| observer | Callback&lt;Array&lt;string&gt;&gt; | Yes| Observer that listens for the data changes in the RDB store. **Array<string>** 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&lt;Array&lt;string&gt;&gt; | Yes| Data change observer registered.|
| observer | Callback&lt;Array&lt;string&gt;&gt; | Yes| Data change observer to unregister. **Array<string>** indicates the IDs of the peer devices whose data in the database is changed.|
**Example**
......
# @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
......
......@@ -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.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core |
| encrypt | boolean | No|Whether to encrypt database files. By default, database files are not encrypted.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core |
| backup | boolean | No|Whether to back up database files. By default, database files are backed up. <br>**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.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core<br>**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.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core|
| securityLevel | [SecurityLevel](#securitylevel) | No|Security level of the KV store. By default, the security level is not set.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core |
| schema<sup>8+</sup> | [Schema](#schema8) | No| Schema used to define the values stored in a KV store.<br>**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.<br>**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.<br>**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.<br>**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.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core<br>**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.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core|
| securityLevel | [SecurityLevel](#securitylevel) | Yes|Security level (S1-S4) of the KV store.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core |
| schema<sup>8+</sup> | [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.<br>**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.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore |
| S0 | 1 | The KV store security level is public.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core |
| NO_LEVEL | 0 | No security level is set for the KV store (deprecated).<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore |
| S0 | 1 | The KV store security level is public (deprecated).<br>**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.<br>**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.<br>**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.<br>**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&lt;[ChangeNotification](#changenotification)&gt; |No |Callback for the data change event.|
| listener | Callback&lt;[ChangeNotification](#changenotification)&gt; | 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&lt;Array&lt;[string, number]&gt;&gt; | No |Callback for the synchronization complete event. |
| syncCallback | Callback&lt;Array&lt;[string, number]&gt;&gt; | 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&lt;[ChangeNotification](#changenotification)&gt; |No |Callback for the data change event.|
| listener | Callback&lt;[ChangeNotification](#changenotification)&gt; | 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&lt;Array&lt;[string, number]&gt;&gt; | No | Callback for the synchronization complete event. |
| syncCallback | Callback&lt;Array&lt;[string, number]&gt;&gt; | 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&lt;[ChangeNotification](#changenotification)&gt; |No |Callback for the data change event.|
| listener | Callback&lt;[ChangeNotification](#changenotification)&gt; | 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&lt;Array&lt;[string, number]&gt;&gt; | No | Callback for the synchronization complete event. |
| syncCallback | Callback&lt;Array&lt;[string, number]&gt;&gt; | No | Callback for the synchronization complete event. If the callback is not specified, all subscriptions to the synchronization complete event will be canceled. |
**Example**
......
......@@ -14,7 +14,7 @@ import fileShare from '@ohos.fileshare';
## fileShare.grantUriPermission
grantUriPermission(uri: string, bundleName: string, mode: number, callback: AsyncCallback&lt;void&gt;): void
grantUriPermission(uri: string, bundleName: string, flag: wantConstant.Flags, callback: AsyncCallback&lt;void&gt;): 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).<br>**wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION**: permission to read the file. <br>**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).<br>**wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION**: permission to read the file. <br>**wantConstant.Flags.FLAG_AUTH_WRITE_URI_PERMISSION**: permission to write the file.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. |
**Error codes**
......@@ -67,7 +67,7 @@ try {
## fileShare.grantUriPermission
grantUriPermission(uri: string, bundleName: string, mode: number): Promise&lt;void&gt;
grantUriPermission(uri: string, bundleName: string, flag: wantConstant.Flags): Promise&lt;void&gt;
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).<br>**wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION**: permission to read the file. <br>**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).<br>**wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION**: permission to read the file. <br>**wantConstant.Flags.FLAG_AUTH_WRITE_URI_PERMISSION**: permission to write the file.|
**Return value**
......
......@@ -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
......
# @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%')
}
}
```
......@@ -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 | string<sup>6+</sup> \| Object<sup>6+</sup> \| ArrayBuffer<sup>8+</sup> | No | Additional data for sending a request. This parameter is not used by default.<br>- 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.<sup>6+</sup><br>- 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.<sup>6+</sup> |
| extraData | string<sup>6+</sup> \| Object<sup>6+</sup> \| ArrayBuffer<sup>8+</sup> | No | Additional data for sending a request. This parameter is not used by default.<br>- 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.<br>- 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.|
| expectDataType<sup>9+</sup> | [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.|
| usingCache<sup>9+</sup> | boolean | No | Whether to use the cache. The default value is **true**. |
| priority<sup>9+</sup> | number | No | Priority. The value range is [1,1000]. The default value is **1**. |
......
......@@ -610,7 +610,7 @@ Defines the accessibilityelement. Before calling APIs of **AccessibilityElement*
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
## attributeNames
### attributeNames
attributeNames\<T extends keyof ElementAttributeValues>(): Promise\<Array\<T>>;
......@@ -636,7 +636,7 @@ rootElement.attributeNames().then((data) => {
console.log('failed to get attribute names, because ' + JSON.stringify(err));
});
```
## attributeNames
### attributeNames
attributeNames\<T extends keyof ElementAttributeValues>(callback: AsyncCallback\<Array\<T>>): void;
......@@ -664,7 +664,7 @@ rootElement.attributeNames((err, data) => {
console.info('get attribute names success');
});
```
## AccessibilityElement.attributeValue
### attributeValue
attributeValue\<T extends keyof ElementAttributeValues>(attributeName: T): Promise\<ElementAttributeValues[T]>;
......@@ -709,7 +709,7 @@ try {
console.log('failed to get attribute value, because ' + JSON.stringify(exception));
}
```
## AccessibilityElement.attributeValue
### attributeValue
attributeValue\<T extends keyof ElementAttributeValues>(attributeName: T,
callback: AsyncCallback\<ElementAttributeValues[T]>): void;
......@@ -752,7 +752,7 @@ try {
console.log('failed to get attribute value, because ' + JSON.stringify(exception));
}
```
## actionNames
### actionNames
actionNames(): Promise\<Array\<string>>;
......@@ -778,7 +778,7 @@ rootElement.actionNames().then((data) => {
console.log('failed to get action names because ' + JSON.stringify(err));
});
```
## actionNames
### actionNames
actionNames(callback: AsyncCallback\<Array\<string>>): void;
......@@ -806,7 +806,7 @@ rootElement.actionNames((err, data) => {
console.info('get action names success');
});
```
## performAction
### performAction
performAction(actionName: string, parameters?: object): Promise\<void>;
......@@ -849,7 +849,7 @@ try {
console.log('failed to perform action, because ' + JSON.stringify(exception));
}
```
## performAction
### performAction
performAction(actionName: string, callback: AsyncCallback\<void>): 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>): 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\<Array\<AccessibilityElement>>;
......@@ -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\<Array\<AccessibilityElement>>): 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\<AccessibilityElement>;
......@@ -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\<AccessibilityElement>): 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\<AccessibilityElement>;
......@@ -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\<AccessibilityElement>): void;
......
......@@ -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.|
......@@ -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')<sup>10+</sup>
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.<br>**iface**: NIC name.<br>**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')<sup>10+</sup>
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.<br>**iface**: NIC name.<br>**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.
......
......@@ -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&lt;[NfcState](#nfcstate)&gt; | No| Callback for the NFC state changes. This parameter can be left blank.|
| callback | Callback&lt;[NfcState](#nfcstate)&gt; | 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**
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册