提交 a3afdff4 编写于 作者: H hui1975

Merge branch 'master' of gitee.com:openharmony/docs into zmh_0531

Change-Id: I33d15b4ce00aa110c61773b7a22f32a1b4c98153
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
- [HTTP Data Request](http-request.md) - [HTTP Data Request](http-request.md)
- [WebSocket Connection](websocket-connection.md) - [WebSocket Connection](websocket-connection.md)
- [Socket Connection](socket-connection.md) - [Socket Connection](socket-connection.md)
- [Network Policy Management](net-policy-management.md)
- [Network Sharing](net-sharing.md) - [Network Sharing](net-sharing.md)
- [Ethernet Connection](net-ethernet.md) - [Ethernet Connection](net-ethernet.md)
- [Network Connection Management](net-connection-manager.md) - [Network Connection Management](net-connection-manager.md)
......
...@@ -39,7 +39,7 @@ For the complete list of APIs and example code, see [Network Connection Manageme ...@@ -39,7 +39,7 @@ For the complete list of APIs and example code, see [Network Connection Manageme
| ---- | ---- | ---- | | ---- | ---- | ---- |
| ohos.net.connection | function getDefaultNet(callback: AsyncCallback\<NetHandle>): void; |Creates a **NetHandle** object that contains the **netId** of the default network. This API uses an asynchronous callback to return the result.| | ohos.net.connection | function getDefaultNet(callback: AsyncCallback\<NetHandle>): void; |Creates a **NetHandle** object that contains the **netId** of the default network. This API uses an asynchronous callback to return the result.|
| ohos.net.connection | function getGlobalHttpProxy<sup>10+</sup>(callback: AsyncCallback\<HttpProxy>): void;| Obtains the global HTTP proxy for the network. This API uses an asynchronous callback to return the result.| | ohos.net.connection | function getGlobalHttpProxy<sup>10+</sup>(callback: AsyncCallback\<HttpProxy>): void;| Obtains the global HTTP proxy for the network. This API uses an asynchronous callback to return the result.|
| ohos.net.connection | function setGlobalHttpProxy<sup>10+</sup>(httpProxy: HttpProxy, callback: AsyncCallback<void>): void;| Sets the global HTTP proxy for the network. This API uses an asynchronous callback to return the result.| | ohos.net.connection | function setGlobalHttpProxy<sup>10+</sup>(httpProxy: HttpProxy, callback: AsyncCallback\<void>): void;| Sets the global HTTP proxy for the network. This API uses an asynchronous callback to return the result.|
| ohos.net.connection | function getAppNet<sup>9+</sup>(callback: AsyncCallback\<NetHandle>): void;| Obtains a **NetHandle** object that contains the **netId** of the network bound to the application. This API uses an asynchronous callback to return the result.| | ohos.net.connection | function getAppNet<sup>9+</sup>(callback: AsyncCallback\<NetHandle>): void;| Obtains a **NetHandle** object that contains the **netId** of the network bound to the application. This API uses an asynchronous callback to return the result.|
| ohos.net.connection | function setAppNet<sup>9+</sup>(netHandle: NetHandle, callback: AsyncCallback\<void>): void;| Binds an application to the specified network. The application can access the external network only through this network. This API uses an asynchronous callback to return the result.| | ohos.net.connection | function setAppNet<sup>9+</sup>(netHandle: NetHandle, callback: AsyncCallback\<void>): void;| Binds an application to the specified network. The application can access the external network only through this network. This API uses an asynchronous callback to return the result.|
| ohos.net.connection | function getDefaultNetSync<sup>9+</sup>(): NetHandle; |Obtains the default active data network in synchronous mode. You can use **getNetCapabilities** to obtain information such as the network type and capabilities.| | ohos.net.connection | function getDefaultNetSync<sup>9+</sup>(): NetHandle; |Obtains the default active data network in synchronous mode. You can use **getNetCapabilities** to obtain information such as the network type and capabilities.|
...@@ -47,7 +47,7 @@ For the complete list of APIs and example code, see [Network Connection Manageme ...@@ -47,7 +47,7 @@ For the complete list of APIs and example code, see [Network Connection Manageme
| ohos.net.connection | function getAllNets(callback: AsyncCallback\<Array\<NetHandle>>): void;| Obtains the list of **NetHandle** objects of the connected network. This API uses an asynchronous callback to return the result.| | ohos.net.connection | function getAllNets(callback: AsyncCallback\<Array\<NetHandle>>): void;| Obtains the list of **NetHandle** objects of the connected network. This API uses an asynchronous callback to return the result.|
| ohos.net.connection | function getConnectionProperties(netHandle: NetHandle, callback: AsyncCallback\<ConnectionProperties>): void; |Obtains link information of the default network. This API uses an asynchronous callback to return the result.| | ohos.net.connection | function getConnectionProperties(netHandle: NetHandle, callback: AsyncCallback\<ConnectionProperties>): void; |Obtains link information of the default network. This API uses an asynchronous callback to return the result.|
| ohos.net.connection | function getNetCapabilities(netHandle: NetHandle, callback: AsyncCallback\<NetCapabilities>): void; |Obtains the capability set of the default network. This API uses an asynchronous callback to return the result.| | ohos.net.connection | function getNetCapabilities(netHandle: NetHandle, callback: AsyncCallback\<NetCapabilities>): void; |Obtains the capability set of the default network. This API uses an asynchronous callback to return the result.|
| ohos.net.connection | function isDefaultNetMetered<sup>9+</sup>(callback: AsyncCallback<boolean>): void; |Checks whether the data traffic usage on the current network is metered. This API uses an asynchronous callback to return the result.| | ohos.net.connection | function isDefaultNetMetered<sup>9+</sup>(callback: AsyncCallback\<boolean>): void; |Checks whether the data traffic usage on the current network is metered. This API uses an asynchronous callback to return the result.|
| ohos.net.connection | function reportNetConnected(netHandle: NetHandle, callback: AsyncCallback\<void>): void;| Reports a **netAavailable** event to NetManager. If this API is called, the application considers that its network status (ohos.net.connection.NetCap.NET_CAPABILITY_VAILDATED) is inconsistent with that of NetManager. This API uses an asynchronous callback to return the result.| | ohos.net.connection | function reportNetConnected(netHandle: NetHandle, callback: AsyncCallback\<void>): void;| Reports a **netAavailable** event to NetManager. If this API is called, the application considers that its network status (ohos.net.connection.NetCap.NET_CAPABILITY_VAILDATED) is inconsistent with that of NetManager. This API uses an asynchronous callback to return the result.|
| ohos.net.connection | function reportNetDisconnected(netHandle: NetHandle, callback: AsyncCallback\<void>): void;| Reports a **netAavailable** event to NetManager. If this API is called, the application considers that its network status (ohos.net.connection.NetCap.NET_CAPABILITY_VAILDATED) is inconsistent with that of NetManager. This API uses an asynchronous callback to return the result.| | ohos.net.connection | function reportNetDisconnected(netHandle: NetHandle, callback: AsyncCallback\<void>): void;| Reports a **netAavailable** event to NetManager. If this API is called, the application considers that its network status (ohos.net.connection.NetCap.NET_CAPABILITY_VAILDATED) is inconsistent with that of NetManager. This API uses an asynchronous callback to return the result.|
| ohos.net.connection | function getAddressesByName(host: string, callback: AsyncCallback\<Array\<NetAddress>>): void; |Obtains all IP addresses of the specified network by resolving the domain name. This API uses an asynchronous callback to return the result.| | ohos.net.connection | function getAddressesByName(host: string, callback: AsyncCallback\<Array\<NetAddress>>): void; |Obtains all IP addresses of the specified network by resolving the domain name. This API uses an asynchronous callback to return the result.|
......
...@@ -5,7 +5,6 @@ Network management functions include: ...@@ -5,7 +5,6 @@ Network management functions include:
- [HTTP data request](http-request.md): initiates a data request through HTTP. - [HTTP data request](http-request.md): initiates a data request through HTTP.
- [WebSocket connection](websocket-connection.md): establishes a bidirectional connection between the server and client through WebSocket. - [WebSocket connection](websocket-connection.md): establishes a bidirectional connection between the server and client through WebSocket.
- [Socket connection](socket-connection.md): transmits data through Socket. - [Socket connection](socket-connection.md): transmits data through Socket.
- [Network policy management](net-policy-management.md): restricts network capabilities by setting network policies, including cellular network policy, sleep/power-saving mode policy, and background network policy, and resets network policies as needed.
- [Network sharing](net-sharing.md): shares a device's Internet connection with other connected devices by means of Wi-Fi hotspot, Bluetooth, and USB sharing, and queries the network sharing state and shared mobile data volume. - [Network sharing](net-sharing.md): shares a device's Internet connection with other connected devices by means of Wi-Fi hotspot, Bluetooth, and USB sharing, and queries the network sharing state and shared mobile data volume.
- [Ethernet connection](net-ethernet.md): provides wired network capabilities, which allow you to set the IP address, subnet mask, gateway, and Domain Name System (DNS) server of a wired network. - [Ethernet connection](net-ethernet.md): provides wired network capabilities, which allow you to set the IP address, subnet mask, gateway, and Domain Name System (DNS) server of a wired network.
- [Network connection management](net-connection-manager.md): provides basic network management capabilities, including management of Wi-Fi/cellular/Ethernet connection priorities, network quality evaluation, subscription to network connection status changes, query of network connection information, and DNS resolution. - [Network connection management](net-connection-manager.md): provides basic network management capabilities, including management of Wi-Fi/cellular/Ethernet connection priorities, network quality evaluation, subscription to network connection status changes, query of network connection information, and DNS resolution.
......
# USB Service Development # USB Service Development
## When to Use ## When to Use
In Host mode, you can obtain the list of connected USB devices, enable or disable the devices, manage device access permissions, and perform data transfer or control transfer. In Host mode, you can obtain the list of connected USB devices, enable or disable the devices, manage device access permissions, and perform data transfer or control transfer.
## APIs
## Available APIs
The USB service provides the following functions: query of USB device list, bulk data transfer, control transfer, and access permission management. The USB service provides the following functions: query of USB device list, bulk data transfer, control transfer, and access permission management.
The following table lists the USB APIs currently available. For details, see the [API Reference](../reference/apis/js-apis-usbManager.md). The following table lists the USB APIs currently available. For details, see the [API Reference](../reference/apis/js-apis-usbManager.md).
**Table 1** Open USB APIs **Table 1** Open USB APIs
| API | Description | | Name | Description |
| ------------------------------------------------------------ | ------------------------------------------------------------ | | ------------------------------------------------------------ | ------------------------------------------------------------ |
| hasRight(deviceName: string): boolean | Checks whether the user has the device access permissions. | | hasRight(deviceName: string): boolean | Checks whether the user has the device access permissions.|
| requestRight(deviceName: string): Promise\<boolean> | Requests the temporary permission for a given application to access the USB device. This API uses a promise to return the result. | | requestRight(deviceName: string): Promise&lt;boolean&gt; | Requests the device access permissions for the application. This API uses a promise to return the result. |
| connectDevice(device: USBDevice): Readonly\<USBDevicePipe> | Connects to the USB device based on the device list returned by `getDevices()`. | | removeRight(deviceName: string): boolean | Revokes the device access permissions of the application.|
| getDevices(): Array<Readonly\<USBDevice>> | Obtains the list of USB devices connected to the USB host. If no USB device is connected, an empty list is returned. | | connectDevice(device: USBDevice): Readonly&lt;USBDevicePipe&gt; | Connects to the USB device based on the device information returned by `getDevices()`. |
| setConfiguration(pipe: USBDevicePipe, config: USBConfiguration): number | Sets the USB device configuration. | | getDevices(): Array&lt;Readonly&lt;USBDevice&gt;&gt; | Obtains the list of USB devices connected to the host. If no device is connected, an empty list is returned. |
| setInterface(pipe: USBDevicePipe, iface: USBInterface): number | Sets a USB interface. | | setConfiguration(pipe: USBDevicePipe, config: USBConfiguration): number | Sets the USB device configuration. |
| claimInterface(pipe: USBDevicePipe, iface: USBInterface, force ?: boolean): number | Claims a USB interface. | | setInterface(pipe: USBDevicePipe, iface: USBInterface): number | Sets a USB interface. |
| bulkTransfer(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, timeout ?: number): Promise\<number> | Performs bulk transfer. | | claimInterface(pipe: USBDevicePipe, iface: USBInterface, force ?: boolean): number | Claims a USB interface. |
| closePipe(pipe: USBDevicePipe): number | Closes a USB device pipe. | | bulkTransfer(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, timeout ?: number): Promise&lt;number&gt; | Performs bulk transfer. |
| releaseInterface(pipe: USBDevicePipe, iface: USBInterface): number | Releases a USB interface. | | closePipe(pipe: USBDevicePipe): number | Closes a USB device pipe. |
| getFileDescriptor(pipe: USBDevicePipe): number | Obtains the file descriptor. | | releaseInterface(pipe: USBDevicePipe, iface: USBInterface): number | Releases a USB interface. |
| getRawDescriptor(pipe: USBDevicePipe): Uint8Array | Obtains the raw USB descriptor. | | getFileDescriptor(pipe: USBDevicePipe): number | Obtains the file descriptor. |
| controlTransfer(pipe: USBDevicePipe, controlparam: USBControlParams, timeout ?: number): Promise&lt;number&gt; | Performs control transfer. | | getRawDescriptor(pipe: USBDevicePipe): Uint8Array | Obtains the raw USB descriptor. |
| controlTransfer(pipe: USBDevicePipe, controlparam: USBControlParams, timeout ?: number): Promise&lt;number&gt; | Performs control transfer. |
## How to Develop ## How to Develop
You can set a USB device as the USB host to connect to other USB devices for data transfer. The development procedure is as follows: You can set a USB device as a host to connect to a device for data transfer. The development procedure is as follows:
1. Obtain the USB device list.
1. Obtain the USB device list.
```js
// Import the USB API package. ```js
import usb from '@ohos.usbManager'; // Import the USB API package.
// Obtain the USB device list. import usb from '@ohos.usbManager';
let deviceList = usb.getDevices(); // Obtain the USB device list.
/* let deviceList = usb.getDevices();
Example deviceList structure /*
[ Example deviceList structure:
{ [
name: "1-1", {
serial: "", name: "1-1",
manufacturerName: "", serial: "",
productName: "", manufacturerName: "",
version: "", productName: "",
vendorId: 7531, version: "",
productId: 2, vendorId: 7531,
clazz: 9, productId: 2,
subClass: 0, clazz: 9,
protocol: 1, subClass: 0,
devAddress: 1, protocol: 1,
busNum: 1, devAddress: 1,
configs: [ busNum: 1,
{ configs: [
id: 1, {
attributes: 224, id: 1,
isRemoteWakeup: true, attributes: 224,
isSelfPowered: true, isRemoteWakeup: true,
maxPower: 0, isSelfPowered: true,
name: "1-1", maxPower: 0,
interfaces: [ name: "1-1",
{ interfaces: [
id: 0, {
protocol: 0, id: 0,
clazz: 9, protocol: 0,
subClass: 0, clazz: 9,
alternateSetting: 0, subClass: 0,
name: "1-1", alternateSetting: 0,
endpoints: [ name: "1-1",
{ endpoints: [
address: 129, {
attributes: 3, address: 129,
interval: 12, attributes: 3,
maxPacketSize: 4, interval: 12,
direction: 128, maxPacketSize: 4,
number: 1, direction: 128,
type: 3, number: 1,
interfaceId: 0, type: 3,
} interfaceId: 0,
] }
} ]
] }
} ]
] }
} ]
] }
*/ ]
``` */
```
2. Obtain the device operation permissions. 2. Obtain the device operation permissions.
```js ```js
let deviceName = deviceList[0].name; let deviceName = deviceList[0].name;
// Request the permissions to operate a specified device. // Request the permissions to operate a specified device.
usb.requestRight(deviceName).then(hasRight => { usb.requestRight(deviceName).then(hasRight => {
console.info("usb device request right result: " + hasRight); console.info("usb device request right result: " + hasRight);
}).catch(error => { }).catch(error => {
console.info("usb device request right failed : " + error); console.info("usb device request right failed : " + error);
}); });
``` ```
3. Open the device. 3. Open the device.
```js ```js
// Open the device, and obtain the USB device pipe for data transfer. // Open the device, and obtain the USB device pipe for data transfer.
let interface1 = deviceList[0].configs[0].interfaces[0]; let pipe = usb.connectDevice(deviceList[0]);
/* let interface1 = deviceList[0].configs[0].interfaces[0];
Claim the corresponding interface from deviceList. /*
interface1 must be one present in the device configuration. Claim the corresponding interface from **deviceList**.
*/ interface1 must be one present in the device configuration.
usb.claimInterface(pipe, interface1, true); */
``` usb.claimInterface(pipe, interface1, true);
```
4. Perform data transfer. 4. Perform data transfer.
```js ```js
/* /*
Read data. Select the corresponding RX endpoint from deviceList for data transfer. Read data. Select the corresponding RX endpoint from deviceList for data transfer.
(endpoint.direction == 0x80); dataUint8Array indicates the data to read. The data type is Uint8Array. (endpoint.direction == 0x80); dataUint8Array indicates the data to read. The data type is Uint8Array.
*/ */
let inEndpoint = interface1.endpoints[2]; let inEndpoint = interface1.endpoints[2];
let outEndpoint = interface1.endpoints[1]; let outEndpoint = interface1.endpoints[1];
let dataUint8Array = new Uint8Array(1024); let dataUint8Array = new Uint8Array(1024);
usb.bulkTransfer(pipe, inEndpoint, dataUint8Array, 15000).then(dataLength => { usb.bulkTransfer(pipe, inEndpoint, dataUint8Array, 15000).then(dataLength => {
if (dataLength >= 0) { if (dataLength >= 0) {
console.info("usb readData result Length : " + dataLength); console.info("usb readData result Length : " + dataLength);
} else { } else {
console.info("usb readData failed : " + dataLength); console.info("usb readData failed : " + dataLength);
} }
}).catch(error => { }).catch(error => {
console.info("usb readData error : " + JSON.stringify(error)); console.info("usb readData error : " + JSON.stringify(error));
}); });
// Send data. Select the corresponding TX endpoint from deviceList for data transfer. (endpoint.direction == 0) // Send data. Select the corresponding TX endpoint from deviceList for data transfer. (endpoint.direction == 0)
usb.bulkTransfer(pipe, outEndpoint, dataUint8Array, 15000).then(dataLength => { usb.bulkTransfer(pipe, outEndpoint, dataUint8Array, 15000).then(dataLength => {
if (dataLength >= 0) { if (dataLength >= 0) {
console.info("usb writeData result write length : " + dataLength); console.info("usb writeData result write length : " + dataLength);
} else { } else {
console.info("writeData failed"); console.info("writeData failed");
} }
}).catch(error => { }).catch(error => {
console.info("usb writeData error : " + JSON.stringify(error)); console.info("usb writeData error : " + JSON.stringify(error));
}); });
``` ```
5. Release the USB interface, and close the USB device. 5. Release the USB interface, and close the USB device.
```js ```js
usb.releaseInterface(pipe, interface); usb.releaseInterface(pipe, interface1);
usb.closePipe(pipe); usb.closePipe(pipe);
``` ```
\ No newline at end of file \ No newline at end of file
...@@ -111,7 +111,7 @@ The [i18n](../reference/apis/js-apis-i18n.md) module provides enhanced I18N capa ...@@ -111,7 +111,7 @@ The [i18n](../reference/apis/js-apis-i18n.md) module provides enhanced I18N capa
let dateTimeFormat = new Intl.DateTimeFormat(); let dateTimeFormat = new Intl.DateTimeFormat();
``` ```
Alternatively, use your own locale and formatting parameters to create a **DateTimeFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [DateTimeOptions](../reference/apis/js-apis-intl.md#datetimeoptions9). Alternatively, use your own locale and formatting parameters to create a **DateTimeFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [DateTimeOptions](../reference/apis/js-apis-intl.md#datetimeoptions6).
```js ```js
let options = {dateStyle: "full", timeStyle: "full"}; let options = {dateStyle: "full", timeStyle: "full"};
...@@ -181,7 +181,7 @@ The [i18n](../reference/apis/js-apis-i18n.md) module provides enhanced I18N capa ...@@ -181,7 +181,7 @@ The [i18n](../reference/apis/js-apis-i18n.md) module provides enhanced I18N capa
let numberFormat = new Intl.NumberFormat(); let numberFormat = new Intl.NumberFormat();
``` ```
Alternatively, use your own locale and formatting parameters to create a **NumberFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [NumberOptions](../reference/apis/js-apis-intl.md#numberoptions9). Alternatively, use your own locale and formatting parameters to create a **NumberFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [NumberOptions](../reference/apis/js-apis-intl.md#numberoptions6).
```js ```js
let options = {compactDisplay: "short", notation: "compact"}; let options = {compactDisplay: "short", notation: "compact"};
...@@ -240,7 +240,7 @@ Users in different regions have different requirements for string sorting. [Coll ...@@ -240,7 +240,7 @@ Users in different regions have different requirements for string sorting. [Coll
let collator = new Intl.Collator(); let collator = new Intl.Collator();
``` ```
Alternatively, use your own locale and formatting parameters to create a **Collator** object. For a full list of parameters, see [CollatorOptions](../reference/apis/js-apis-intl.md#collatoroptions9). Alternatively, use your own locale and formatting parameters to create a **Collator** object. For a full list of parameters, see [CollatorOptions](../reference/apis/js-apis-intl.md#collatoroptions8).
The **sensitivity** parameter is used to specify the levels of differences that will be used for string comparison. The value **base** indicates that only characters are compared, but not the accent and capitalization. For example, 'a' != 'b', 'a' == '', 'a'=='A'. The value **accent** indicates that the accent is considered, but not the capitalization. For example, 'a' != 'b', 'a' == '', 'a'=='A'. The value **case** indicates that the capitalization is considered, but the accent. For example, 'a' != 'b', 'a' == '', 'a'=='A'. The value **variant** indicates that the accent and capitalization are considered. For example, 'a' != 'b', 'a' == '', 'a'=='A'. The **sensitivity** parameter is used to specify the levels of differences that will be used for string comparison. The value **base** indicates that only characters are compared, but not the accent and capitalization. For example, 'a' != 'b', 'a' == '', 'a'=='A'. The value **accent** indicates that the accent is considered, but not the capitalization. For example, 'a' != 'b', 'a' == '', 'a'=='A'. The value **case** indicates that the capitalization is considered, but the accent. For example, 'a' != 'b', 'a' == '', 'a'=='A'. The value **variant** indicates that the accent and capitalization are considered. For example, 'a' != 'b', 'a' == '', 'a'=='A'.
```js ```js
...@@ -301,7 +301,7 @@ According to grammars in certain languages, the singular or plural form of a nou ...@@ -301,7 +301,7 @@ According to grammars in certain languages, the singular or plural form of a nou
let pluralRules = new Intl.PluralRules(); let pluralRules = new Intl.PluralRules();
``` ```
Alternatively, use your own locale and formatting parameters to create a **PluralRules** object. For a full list of parameters, see [PluralRulesOptions](../reference/apis/js-apis-intl.md#pluralrulesoptions9). Alternatively, use your own locale and formatting parameters to create a **PluralRules** object. For a full list of parameters, see [PluralRulesOptions](../reference/apis/js-apis-intl.md#pluralrulesoptions8).
```js ```js
let pluralRules = new Intl.PluralRules("zh-CN", {localeMatcher: "best fit", type: "cardinal"}); let pluralRules = new Intl.PluralRules("zh-CN", {localeMatcher: "best fit", type: "cardinal"});
...@@ -349,7 +349,7 @@ According to grammars in certain languages, the singular or plural form of a nou ...@@ -349,7 +349,7 @@ According to grammars in certain languages, the singular or plural form of a nou
let relativeTimeFormat = new Intl.RelativeTimeFormat(); 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#relativetimeformatinputoptions8).
```js ```js
let relativeTimeFormat = new Intl.RelativeTimeFormat("zh-CN", {numeric: "always", style: "long"}); let relativeTimeFormat = new Intl.RelativeTimeFormat("zh-CN", {numeric: "always", style: "long"});
...@@ -384,4 +384,4 @@ According to grammars in certain languages, the singular or plural form of a nou ...@@ -384,4 +384,4 @@ According to grammars in certain languages, the singular or plural form of a nou
```js ```js
let relativeTimeFormat = new Intl.RelativeTimeFormat("zh-CN", {numeric: "always", style: "long"}); 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"} let options = relativeTimeFormat.resolvedOptions(); // options = {"locale": "zh-CN", "style": "long", "numeric": "always", "numberingSystem": "latn"}
``` ```
\ No newline at end of file
# Using Native APIs (NDK) of the OHOS SDK in a CMake Project
## What Is Native API
For details, see [Native APIs](https://gitee.com/openharmony/docs/blob/master/en/application-dev/napi/Readme-EN.md).
## Downloading the NDK
You download the Native API Development Kit (NDK) by downloading the OHOS SDK, where the NDK is included. To download the OHOS SDK, use any of the following modes:
- (Recommended) Acquire source code from mirrors for an officially released version. For details, see [release notes](https://gitee.com/openharmony/docs/tree/master/en/release-notes#/openharmony/docs/blob/master/en/release-notes/OpenHarmony-v3.2-release.md).
- Download the SDK from the SDK Manager in DevEco Studio.
- Download the SDK from the [daily build](http://ci.openharmony.cn/dailys/dailybuilds), by clicking the download link to the ohos-sdk component.
![Download from Daily Build](figures/ci_download.png)
## Decompressing the NDK
Place the downloaded NDK in a folder you prefer and decompress it. Below shows the directory structure after decompression.
![SDK Directory Structure](figures/sdk-structure.png)
Configure the Linux environment as follows: (Skip this step if the NDK is downloaded from DevEco Studio.)
1. Add the CMake tool that comes with the NDK to the environment variables.
```
# Open the .bashrc file.
vim ~/.bashrc
# Append the custom CMake path to the file. Save the file and exit.
export PATH=~/ohos-sdk/ohos-sdk/linux/native/build-tools/cmake/bin:$PATH
# Run the source ~/.bashrc command to make the environment variables take effect.
source ~/.bashrc
```
2. Check the default CMake path.
```
# Run the which cmake command.
which cmake
# The result should be the same as the custom path previously appended to the file.
~/ohos-sdk/ohos-sdk/linux/native/build-tools/cmake/bin/cmake
```
## Using the NDK to Compile a Native Program
You can use the NDK to quickly develop a native program, including native dynamic libraries, static libraries, and executable files. The ArkUI application framework can call the native dynamic libraries through the NAPI framework. The following exemplifies how to use the NDK to compile a C/C++ dynamic library in a C/C++ demo project.
### Folders in the NDK
#### build Folder: ohos.toolchain.cmake file
The **ohos.toolchain.cmake** file contains the attributes of the CMake compilation target. Its path must be specified in the **CMAKE_TOOLCHAIN_FILE** parameter so that it can be located during CMake compilation. For details about the mandatory parameters in the **ohos.toolchain.cmake** file, see [Key Parameters in ohos.toolchain.cmake](#key-parameters-in-ohostoolchaincmake).
#### build-tools folder: Build Tool Provided by the NDK
```
# Run the following command to view the CMake version:
cmake -version
# Result
cmake version 3.16.5
CMake suite maintained and supported by Kitware (kitware.com/cmake).
```
#### llvm Folder: Compiler Provided by the NDK
![Compiler](figures/compiler.png)
### Demo Project for the NDK
#### Demo Project Directory
demo
├── CMakeLists.txt
├── include
└── sum.h
└── src
├── CMakeLists.txt
├── sum.cpp
└── hello.cpp
#### CMakeLists.txt in the demo Directory
```
# Specify the minimum CMake version.
CMAKE_MINIMUM_REQUIRED(VERSION 3.16)
# Set the project name, which is HELLO in this example.
PROJECT(HELLO)
# Add a subdirectory and build the subdirectory.
ADD_SUBDIRECTORY(src bin)
```
#### CMakeLists.txt in the src Directory
```
SET(LIBHELLO_SRC hello.cpp)
# Set compilation flags.
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0")
# Set the link parameter. The value below is only for exemplary purposes.
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--emit-relocs --verbose")
# Add a libsum dynamic library target. If the compilation is successful, a libsum.so file is generated.
ADD_LIBRARY(sum SHARED sum.cpp)
# Add the executable target called Hello. If the compilation is successful, a Hello executable is generated.
ADD_EXECUTABLE(Hello ${LIBHELLO_SRC})
# Specify the path to the include directory of the Hello target.
TARGET_INCLUDE_DIRECTORIES(Hello PUBLIC ../include)
# Specify the name of the library to be linked to the Hello target.
TARGET_LINK_LIBRARIES(Hello PUBLIC sum)
```
For details about CMake, see [CMake Tutorial](https://cmake.org/cmake/help/v3.16/guide/tutorial/).
#### Source Code
**hello.cpp** source code:
```
#include <iostream>
#include "sum.h"
int main(int argc,const char **argv)
{
std::cout<< "hello world!" <<std::endl;
int total = sum(1, 100);
std::cout<< "Sum 1 + 100=" << total << std::endl;
return 0;
}
```
**sum.h** source code:
```
int sum(int a, int b);
```
sum.cpp source code:
```
#include <iostream>
int sum(int a, int b)
{
return a + b;
}
```
### Key Parameters in ohos.toolchain.cmake
| Parameter | Type|Description|
|--------|------|------|
|OHOS_STL|c++\_shared/c++\_static|STL to use. The value must be consistent across the native libraries in the same application.<br>**c++\_shared** (default): The shared library of libc++, libc++\_shared.so, is used.<br>**c++\static**: The static library of libc++, libc++\_static.a, is used.|
|OHOS_ARCH|armeabi-v7a/arm64-v8a/x86_64|ABI to support. Currently, three types of ABI are supported.|
|OHOS_PLATFORM|OHOS|Target platform. Currently, only OHOS is supported.|
|CMAKE_TOOLCHAIN_FILE|Toolchain file|CMake toolchain file, that is, the aforementioned **ohos.toolchain.cmake** file.|
### Building from Command Line
In the project directory, create the **build** directory to store the intermediate files generated during CMake building.
> **NOTE**
>
> In the following commands, **ohos-sdk** is the root directory of the downloaded SDK. Replace it with the actual directory.
1. Use **OHOS_STL=c++_shared** for dynamic compilation.
```
>mkdir build && cd build
>cmake -DOHOS_STL=c++_shared -DOHOS_ARCH=armeabi-v7a -DOHOS_PLATFORM=OHOS -DCMAKE_TOOLCHAIN_FILE={ohos-sdk}/linux/native/build/cmake/ohos.toolchain.cmake ..
>cmake --build .
```
2. Use **OHOS_STL=c++_static** for static compilation.
```
>mkdir build && cd build
>cmake -DOHOS_STL=c++_static -DOHOS_ARCH=armeabi-v7a -DOHOS_PLATFORM=OHOS -DCMAKE_TOOLCHAIN_FILE={ohos-sdk}/linux/native/build/cmake/ohos.toolchain.cmake ..
>cmake --build .
```
<!--no_check-->
\ No newline at end of file
...@@ -325,7 +325,7 @@ ...@@ -325,7 +325,7 @@
- [@ohos.systemTimer (System Timer)](js-apis-system-timer.md) - [@ohos.systemTimer (System Timer)](js-apis-system-timer.md)
- [@ohos.wallpaper (Wallpaper)](js-apis-wallpaper.md) - [@ohos.wallpaper (Wallpaper)](js-apis-wallpaper.md)
- [@ohos.web.webview (Webview)](js-apis-webview.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) - [Timer](js-apis-timer.md)
- application - application
- [AccessibilityExtensionContext (Accessibility Extension Context)](js-apis-inner-application-accessibilityExtensionContext.md) - [AccessibilityExtensionContext (Accessibility Extension Context)](js-apis-inner-application-accessibilityExtensionContext.md)
...@@ -350,6 +350,7 @@ ...@@ -350,6 +350,7 @@
- [@ohos.multimodalInput.mouseEvent (Mouse Event)](js-apis-mouseevent.md) - [@ohos.multimodalInput.mouseEvent (Mouse Event)](js-apis-mouseevent.md)
- [@ohos.multimodalInput.pointer (Mouse Pointer)](js-apis-pointer.md) - [@ohos.multimodalInput.pointer (Mouse Pointer)](js-apis-pointer.md)
- [@ohos.multimodalInput.touchEvent (Touch Event)](js-apis-touchevent.md) - [@ohos.multimodalInput.touchEvent (Touch Event)](js-apis-touchevent.md)
- [@ohos.multimodalInput.shortKey (Shortcut Key)](js-apis-shortKey.md)
- [@ohos.power (System Power Management)](js-apis-power.md) - [@ohos.power (System Power Management)](js-apis-power.md)
- [@ohos.runningLock (Runninglock)](js-apis-runninglock.md) - [@ohos.runningLock (Runninglock)](js-apis-runninglock.md)
- [@ohos.sensor (Sensor)](js-apis-sensor.md) - [@ohos.sensor (Sensor)](js-apis-sensor.md)
......
# @ohos.arkui.componentSnapshot (Component Snapshot) # @ohos.arkui.componentSnapshot (Component Snapshot)
The **componentSnapshot** module provides APIs for obtaining component snapshots, including snapshots of components that have been loaded and snapshots of components that have not been loaded yet. The **componentSnapshot** module provides APIs for obtaining component snapshots, including snapshots of components that have been loaded and snapshots of components that have not been loaded yet. Note that a component snapshot does not contain content drawn outside of the area of the owning component or the parent component.
> **NOTE** > **NOTE**
> >
...@@ -8,6 +8,7 @@ The **componentSnapshot** module provides APIs for obtaining component snapshots ...@@ -8,6 +8,7 @@ The **componentSnapshot** module provides APIs for obtaining component snapshots
> >
> You can preview how this component looks on a real device. The preview is not yet available in the DevEco Studio Previewer. > You can preview how this component looks on a real device. The preview is not yet available in the DevEco Studio Previewer.
## Modules to Import ## Modules to Import
```js ```js
...@@ -20,14 +21,18 @@ get(id: string, callback: AsyncCallback<image.PixelMap>): void ...@@ -20,14 +21,18 @@ get(id: string, callback: AsyncCallback<image.PixelMap>): void
Obtains the snapshot of a component that has been loaded. This API uses an asynchronous callback to return the result. Obtains the snapshot of a component that has been loaded. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> The snapshot captures content rendered in the last frame. If this API is called when the component triggers an update, the re-rendered content will not be included in the obtained snapshot.
**System capability**: SystemCapability.ArkUI.ArkUI.Full **System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| -------- | ----------------------------------- | ---- | ------------------------------------------------------------------------------ | | -------- | ----------------------------------- | ---- | ---------------------------------------- |
| id | string | Yes | [ID](../arkui-ts/ts-universal-attributes-component-id.md) of the target component.| | id | string | Yes | [ID](../arkui-ts/ts-universal-attributes-component-id.md) of the target component.|
| callback | AsyncCallback&lt;image.PixelMap&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;image.PixelMap&gt; | Yes | Callback used to return the result. |
**Example** **Example**
...@@ -45,8 +50,8 @@ struct SnapshotExample { ...@@ -45,8 +50,8 @@ struct SnapshotExample {
Image(this.pixmap) Image(this.pixmap)
.width(300).height(300) .width(300).height(300)
// ...Component // ...Component
// ...Components // ...Component
// ...Components // ...Component
Button("click to generate UI snapshot") Button("click to generate UI snapshot")
.onClick(() => { .onClick(() => {
componentSnapshot.get("root", (error: Error, pixmap: image.PixelMap) => { componentSnapshot.get("root", (error: Error, pixmap: image.PixelMap) => {
...@@ -71,25 +76,29 @@ get(id: string): Promise<image.PixelMap> ...@@ -71,25 +76,29 @@ get(id: string): Promise<image.PixelMap>
Obtains the snapshot of a component that has been loaded. This API uses a promise to return the result. Obtains the snapshot of a component that has been loaded. This API uses a promise to return the result.
> **NOTE**
>
> The snapshot captures content rendered in the last frame. If this API is called when the component triggers an update, the re-rendered content will not be included in the obtained snapshot.
**System capability**: SystemCapability.ArkUI.ArkUI.Full **System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ------- | ------------------------------------------------------- | ---- | -------------------- | | ---- | ------ | ---- | ---------------------------------------- |
| id | string | Yes | [ID](../arkui-ts/ts-universal-attributes-component-id.md) of the target component.| | id | string | Yes | [ID](../arkui-ts/ts-universal-attributes-component-id.md) of the target component.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ----------------------------- | -------------- | | ----------------------------- | -------- |
| Promise&lt;image.PixelMap&gt; | Promise used to return the result.| | Promise&lt;image.PixelMap&gt; | Promise used to return the result.|
**Error codes** **Error codes**
| ID| Error Message | | ID | Error Message |
| -------- | ------------------- | | ------ | ------------------- |
| 100001 | if id is not valid. | | 100001 | if id is not valid. |
**Example** **Example**
...@@ -134,14 +143,21 @@ createFromBuilder(builder: CustomBuilder, callback: AsyncCallback<image.PixelMap ...@@ -134,14 +143,21 @@ createFromBuilder(builder: CustomBuilder, callback: AsyncCallback<image.PixelMap
Renders a custom component in the application background and outputs its snapshot. This API uses an asynchronous callback to return the result. Renders a custom component in the application background and outputs its snapshot. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> To account for the time spent in awaiting component building and rendering, the callback of offscreen snapshots has a delay of less than 500 ms.
>
> If a component is on a time-consuming task, for example, an **\<Image>** or **\<Web>** component that is loading online images, its loading may be still in progress when this API is called. In this case, the output snapshot does not represent the component in the way it looks when the loading is successfully completed.
**System capability**: SystemCapability.ArkUI.ArkUI.Full **System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| -------- | ------------------------------------------------------- | ---- | -------------------- | | -------- | ---------------------------------------- | ---- | ---------- |
| builder | [CustomBuilder](../arkui-ts/ts-types.md#custombuilder8) | Yes | Builder of the custom component.| | builder | [CustomBuilder](../arkui-ts/ts-types.md#custombuilder8) | Yes | Builder of the custom component.|
| callback | AsyncCallback&lt;image.PixelMap&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;image.PixelMap&gt; | Yes | Callback used to return the result.|
**Example** **Example**
...@@ -194,25 +210,31 @@ createFromBuilder(builder: CustomBuilder): Promise<image.PixelMap> ...@@ -194,25 +210,31 @@ createFromBuilder(builder: CustomBuilder): Promise<image.PixelMap>
Renders a custom component in the application background and outputs its snapshot. This API uses a promise to return the result. Renders a custom component in the application background and outputs its snapshot. This API uses a promise to return the result.
> **NOTE**
>
> To account for the time spent in awaiting component building and rendering, the callback of offscreen snapshots has a delay of less than 500 ms.
>
> If a component is on a time-consuming task, for example, an **\<Image>** or **\<Web>** component that is loading online images, its loading may be still in progress when this API is called. In this case, the output snapshot does not represent the component in the way it looks when the loading is successfully completed.
**System capability**: SystemCapability.ArkUI.ArkUI.Full **System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| ------- | ------------------------------------------------------- | ---- | -------------------- | | ------- | ---------------------------------------- | ---- | ---------- |
| builder | [CustomBuilder](../arkui-ts/ts-types.md#custombuilder8) | Yes | Builder of the custom component.| | builder | [CustomBuilder](../arkui-ts/ts-types.md#custombuilder8) | Yes | Builder of the custom component.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ----------------------------- | -------------- | | ----------------------------- | -------- |
| Promise&lt;image.PixelMap&gt; | Promise used to return the result.| | Promise&lt;image.PixelMap&gt; | Promise used to return the result.|
**Error codes** **Error codes**
| ID| Error Message | | ID | Error Message |
| -------- | ----------------------------------------- | | ------ | ---------------------------------------- |
| 100001 | if builder is not a valid build function. | | 100001 | if builder is not a valid build function. |
**Example** **Example**
......
...@@ -46,7 +46,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod ...@@ -46,7 +46,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
| ID | Error Message | | ID | Error Message |
| ------ | ---------------------- | | ------ | ---------------------- |
| 890001 | Unspported para value. | | 890001 | param value not valid |
**Example** **Example**
```js ```js
...@@ -85,7 +85,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod ...@@ -85,7 +85,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
| ID | Error Message | | ID | Error Message |
| ------ | ---------------------- | | ------ | ---------------------- |
| 890001 | Unspported para value. | | 890001 | param value not valid |
**Example** **Example**
```js ```js
...@@ -116,7 +116,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod ...@@ -116,7 +116,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
| ID | Error Message | | ID | Error Message |
| ------ | ---------------------- | | ------ | ---------------------- |
| 890001 | Unspported para value. | | 890001 | param value not valid |
**Example** **Example**
```js ```js
...@@ -153,7 +153,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod ...@@ -153,7 +153,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
| ID | Error Message | | ID | Error Message |
| ------ | ---------------------- | | ------ | ---------------------- |
| 890001 | Unspported para value. | | 890001 | param value not valid |
**Example** **Example**
```js ```js
...@@ -191,7 +191,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod ...@@ -191,7 +191,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
| ID | Error Message | | ID | Error Message |
| ------ | ---------------------- | | ------ | ---------------------- |
| 890001 | Unspported para value. | | 890001 | param value not valid |
**Example** **Example**
```js ```js
...@@ -222,7 +222,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod ...@@ -222,7 +222,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
| ID | Error Message | | ID | Error Message |
| ------ | ---------------------- | | ------ | ---------------------- |
| 890001 | Unspported para value. | | 890001 | param value not valid |
**Example** **Example**
```js ```js
...@@ -257,7 +257,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod ...@@ -257,7 +257,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
| ID | Error Message | | ID | Error Message |
| ------ | ---------------------- | | ------ | ---------------------- |
| 890001 | Unspported para value. | | 890001 | param value not valid |
**Example** **Example**
```js ```js
...@@ -288,7 +288,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod ...@@ -288,7 +288,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
| ID | Error Message | | ID | Error Message |
| ------ | ---------------------- | | ------ | ---------------------- |
| 890001 | Unspported para value. | | 890001 | param value not valid |
**Example** **Example**
```js ```js
...@@ -323,7 +323,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod ...@@ -323,7 +323,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
| ID | Error Message | | ID | Error Message |
| ------ | ---------------------- | | ------ | ---------------------- |
| 890001 | Unspported para value. | | 890001 | param value not valid |
**Example** **Example**
```js ```js
...@@ -354,7 +354,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod ...@@ -354,7 +354,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
| ID | Error Message | | ID | Error Message |
| ------ | ---------------------- | | ------ | ---------------------- |
| 890001 | Unspported para value. | | 890001 | param value not valid |
**Example** **Example**
```js ```js
...@@ -389,7 +389,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod ...@@ -389,7 +389,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
| ID | Error Message | | ID | Error Message |
| ------ | ---------------------- | | ------ | ---------------------- |
| 890001 | Unspported para value. | | 890001 | param value not valid |
**Example** **Example**
```js ```js
...@@ -420,7 +420,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod ...@@ -420,7 +420,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
| ID | Error Message | | ID | Error Message |
| ------ | ---------------------- | | ------ | ---------------------- |
| 890001 | Unspported para value. | | 890001 | param value not valid |
**Example** **Example**
```js ```js
...@@ -455,7 +455,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod ...@@ -455,7 +455,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
| ID | Error Message | | ID | Error Message |
| ------ | ---------------------- | | ------ | ---------------------- |
| 890001 | Unspported para value. | | 890001 | param value not valid |
**Example** **Example**
```js ```js
...@@ -492,7 +492,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod ...@@ -492,7 +492,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
| ID | Error Message | | ID | Error Message |
| ------ | ---------------------- | | ------ | ---------------------- |
| 890001 | Unspported para value. | | 890001 | param value not valid |
**Example** **Example**
```js ```js
...@@ -530,7 +530,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod ...@@ -530,7 +530,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
| ID | Error Message | | ID | Error Message |
| ------ | ---------------------- | | ------ | ---------------------- |
| 890001 | Unspported para value. | | 890001 | param value not valid |
**Example** **Example**
```js ```js
...@@ -563,7 +563,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod ...@@ -563,7 +563,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
| ID | Error Message | | ID | Error Message |
| ------ | ---------------------- | | ------ | ---------------------- |
| 890001 | Unspported para value. | | 890001 | param value not valid |
**Example** **Example**
```js ```js
...@@ -594,7 +594,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod ...@@ -594,7 +594,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
| ID | Error Message | | ID | Error Message |
| ------ | ---------------------- | | ------ | ---------------------- |
| 890001 | Unspported para value. | | 890001 | param value not valid |
**Example** **Example**
```js ```js
...@@ -625,7 +625,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod ...@@ -625,7 +625,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
| ID | Error Message | | ID | Error Message |
| ------ | ---------------------- | | ------ | ---------------------- |
| 890001 | Unspported para value. | | 890001 | param value not valid |
**Example** **Example**
```js ```js
...@@ -660,7 +660,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod ...@@ -660,7 +660,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
| ID | Error Message | | ID | Error Message |
| ------ | ---------------------- | | ------ | ---------------------- |
| 890001 | Unspported para value. | | 890001 | param value not valid |
**Example** **Example**
```ts ```ts
...@@ -691,7 +691,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod ...@@ -691,7 +691,7 @@ For details about the error codes, see [I18N Error Codes](../errorcodes/errorcod
| ID | Error Message | | ID | Error Message |
| ------ | ---------------------- | | ------ | ---------------------- |
| 890001 | Unspported para value. | | 890001 | param value not valid |
**Example** **Example**
```ts ```ts
...@@ -1737,6 +1737,35 @@ Obtains the **TimeZone** object corresponding to the specified time zone city ID ...@@ -1737,6 +1737,35 @@ Obtains the **TimeZone** object corresponding to the specified time zone city ID
let timezone = I18n.TimeZone.getTimezoneFromCity("Shanghai"); let timezone = I18n.TimeZone.getTimezoneFromCity("Shanghai");
``` ```
### getTimezonesByLocation<sup>10+</sup>
static getTimezonesByLocation(longitude: number, latitude: number): Array&lt;TimeZone&gt;
Creates an array of **TimeZone** objects corresponding to the specified longitude and latitude.
**System capability**: SystemCapability.Global.I18n
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ------ | ---- | ------ |
| longitude | number | Yes | Longitude. The value ranges from **-180** to **179.9**. A positive value is used for east longitude and a negative value is used for west longitude.|
| latitude | number | Yes | Latitude. The value ranges from **-90** to **89.9**. A positive value is used for north latitude and a negative value is used for south latitude.|
**Return value**
| Type | Description |
| -------- | ----------- |
| Array&lt;[TimeZone](#timezone)&gt; | Array of **TimeZone** objects.|
**Example**
```js
let timezoneArray = I18n.TimeZone.getTimezonesByLocation(-118.1, 34.0);
for (var i = 0; i < timezoneArray.length; i++) {
let tzId = timezoneArray[i].getID();
}
```
## Transliterator<sup>9+</sup> ## Transliterator<sup>9+</sup>
......
# @ohos.intl (Internationalization) # @ohos.intl (Internationalization)
The **intl** module provides basic i18n capabilities, such as time and date formatting, number formatting, and string sorting, through the standard i18n APIs defined in ECMA 402. The **intl** module provides basic i18n capabilities, such as time and date formatting, number formatting, and string sorting, through the standard i18n APIs defined in ECMA 402.
The [i18n](js-apis-i18n.md) module provides enhanced i18n capabilities through supplementary interfaces that are not defined in ECMA 402. It works with the intl module to provide a complete suite of i18n capabilities. The [i18n](js-apis-i18n.md) module provides enhanced i18n capabilities through supplementary interfaces that are not defined in ECMA 402. It works with the intl module to provide a complete suite of i18n capabilities.
> **NOTE** > **NOTE**
...@@ -68,7 +67,7 @@ Creates a **Locale** object. ...@@ -68,7 +67,7 @@ Creates a **Locale** object.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------------------- | -------------------------------- | ---- | ---------------------------- | | -------------------- | -------------------------------- | ---- | ---------------------------- |
| locale | string | Yes | A string containing locale information, including the language, optional script, and region. For details about the international standards and combination modes for the language, script, and country or region, see [intl Development](../../internationalization/intl-guidelines.md#setting-locale-information).| | locale | string | Yes | A string containing locale information, including the language, optional script, and region. For details about the international standards and combination modes for the language, script, and country or region, see [intl Development](../../internationalization/intl-guidelines.md#setting-locale-information).|
| options<sup>9+</sup> | [LocaleOptions](#localeoptions9) | No | Options for creating the **Locale** object. | | options | [LocaleOptions](#localeoptions6) | No | Options for creating the **Locale** object. |
**Example** **Example**
```js ```js
...@@ -160,9 +159,10 @@ Minimizes information of the **Locale** object. If the script and locale informa ...@@ -160,9 +159,10 @@ Minimizes information of the **Locale** object. If the script and locale informa
``` ```
## LocaleOptions<sup>9+</sup> ## LocaleOptions<sup>6+</sup>
Represents the locale options. Represents the locale options.
In API version 9, the attributes in **LocaleOptions** are optional.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
...@@ -207,7 +207,7 @@ Creates a **DateTimeOptions** object for the specified locale. ...@@ -207,7 +207,7 @@ Creates a **DateTimeOptions** object for the specified locale.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------------------- | ------------------------------------ | ---- | ---------------------------- | | -------------------- | ------------------------------------ | ---- | ---------------------------- |
| locale | string \| Array&lt;string&gt; | Yes | A string containing locale information, including the language, optional script, and region.| | locale | string \| Array&lt;string&gt; | Yes | A string containing locale information, including the language, optional script, and region.|
| options<sup>9+</sup> | [DateTimeOptions](#datetimeoptions9) | No | Options for creating a **DateTimeFormat** object. | | options | [DateTimeOptions](#datetimeoptions6) | No | Options for creating a **DateTimeFormat** object. |
**Example** **Example**
```js ```js
...@@ -299,7 +299,7 @@ Obtains the formatting options for **DateTimeFormat** object. ...@@ -299,7 +299,7 @@ Obtains the formatting options for **DateTimeFormat** object.
| Type | Description | | Type | Description |
| ------------------------------------ | ----------------------------- | | ------------------------------------ | ----------------------------- |
| [DateTimeOptions](#datetimeoptions9) | Formatting options for **DateTimeFormat** objects.| | [DateTimeOptions](#datetimeoptions6) | Formatting options for **DateTimeFormat** objects.|
**Example** **Example**
```js ```js
...@@ -311,9 +311,10 @@ Obtains the formatting options for **DateTimeFormat** object. ...@@ -311,9 +311,10 @@ Obtains the formatting options for **DateTimeFormat** object.
``` ```
## DateTimeOptions<sup>9+</sup> ## DateTimeOptions<sup>6+</sup>
Provides the options for the **DateTimeFormat** object. Provides the options for the **DateTimeFormat** object.
In API version 9, the attributes in **DateTimeOptions** are optional.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
...@@ -371,7 +372,7 @@ Creates a **NumberFormat** object for the specified locale. ...@@ -371,7 +372,7 @@ Creates a **NumberFormat** object for the specified locale.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------------------- | -------------------------------- | ---- | ---------------------------- | | -------------------- | -------------------------------- | ---- | ---------------------------- |
| locale | string \| Array&lt;string&gt; | Yes | A string containing locale information, including the language, optional script, and region.| | locale | string \| Array&lt;string&gt; | Yes | A string containing locale information, including the language, optional script, and region.|
| options<sup>9+</sup> | [NumberOptions](#numberoptions9) | No | Options for creating a **NumberFormat** object. | | options | [NumberOptions](#numberoptions6) | No | Options for creating a **NumberFormat** object. |
**Example** **Example**
```js ```js
...@@ -421,7 +422,7 @@ Obtains the options of the **NumberFormat** object. ...@@ -421,7 +422,7 @@ Obtains the options of the **NumberFormat** object.
| Type | Description | | Type | Description |
| -------------------------------- | --------------------------- | | -------------------------------- | --------------------------- |
| [NumberOptions](#numberoptions9) | Formatting options for **NumberFormat** objects.| | [NumberOptions](#numberoptions6) | Formatting options for **NumberFormat** objects.|
**Example** **Example**
...@@ -434,9 +435,10 @@ Obtains the options of the **NumberFormat** object. ...@@ -434,9 +435,10 @@ Obtains the options of the **NumberFormat** object.
``` ```
## NumberOptions<sup>9+</sup> ## NumberOptions<sup>6+</sup>
Defines the device capability. Defines the device capability.
In API version 9, the attributes in **NumberOptions** are optional.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
...@@ -448,7 +450,7 @@ Defines the device capability. ...@@ -448,7 +450,7 @@ Defines the device capability.
| currencyDisplay | string | Yes | Yes | Currency display mode. The value can be **symbol**, **narrowSymbol**, **code**, or **name**.| | currencyDisplay | string | Yes | Yes | Currency display mode. The value can be **symbol**, **narrowSymbol**, **code**, or **name**.|
| unit | string | Yes | Yes | Unit name, for example, **meter**, **inch**, or **hectare**. | | unit | string | Yes | Yes | Unit name, for example, **meter**, **inch**, or **hectare**. |
| unitDisplay | string | Yes | Yes | Unit display format. The value can be **long**, **short**, or **narrow**.| | unitDisplay | string | Yes | Yes | Unit display format. The value can be **long**, **short**, or **narrow**.|
| unitUsage | string | Yes | Yes | Unit usage scenario. The value can be any of the following: **default**, **area-land-agricult**, **area-land-commercl**, **area-land-residntl**, **length-person**, **length-person-small**, **length-rainfall**, **length-road**, **length-road-small**, **length-snowfall**, **length-vehicle**, **length-visiblty**, **length-visiblty-small**, **length-person-informal**, **length-person-small-informal**, **length-road-informal**, **speed-road-travel**, **speed-wind**, **temperature-person**, **temperature-weather**, **volume-vehicle-fuel**.| | unitUsage<sup>8+</sup> | string | Yes | Yes | Unit usage scenario. The value can be any of the following: **default**, **area-land-agricult**, **area-land-commercl**, **area-land-residntl**, **length-person**, **length-person-small**, **length-rainfall**, **length-road**, **length-road-small**, **length-snowfall**, **length-vehicle**, **length-visiblty**, **length-visiblty-small**, **length-person-informal**, **length-person-small-informal**, **length-road-informal**, **speed-road-travel**, **speed-wind**, **temperature-person**, **temperature-weather**, **volume-vehicle-fuel**.|
| signDisplay | string | Yes | Yes | Number sign display format. The value can be **auto**, **never**, **always**, or **expectZero**.| | signDisplay | string | Yes | Yes | Number sign display format. The value can be **auto**, **never**, **always**, or **expectZero**.|
| compactDisplay | string | Yes | Yes | Compact display format. The value can be **long** or **short**. | | compactDisplay | string | Yes | Yes | Compact display format. The value can be **long** or **short**. |
| notation | string | Yes | Yes | Number formatting specification. The value can be **standard**, **scientific**, **engineering**, or **compact**.| | notation | string | Yes | Yes | Number formatting specification. The value can be **standard**, **scientific**, **engineering**, or **compact**.|
...@@ -494,7 +496,7 @@ Creates a **Collator** object. ...@@ -494,7 +496,7 @@ Creates a **Collator** object.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------------------- | ------------------------------------ | ---- | ---------------------------- | | -------------------- | ------------------------------------ | ---- | ---------------------------- |
| locale | string \| Array&lt;string&gt; | Yes | A string containing locale information, including the language, optional script, and region.| | locale | string \| Array&lt;string&gt; | Yes | A string containing locale information, including the language, optional script, and region.|
| options<sup>9+</sup> | [CollatorOptions](#collatoroptions9) | No | Options for creating a **Collator** object. | | options | [CollatorOptions](#collatoroptions8) | No | Options for creating a **Collator** object. |
**Example** **Example**
```js ```js
...@@ -545,7 +547,7 @@ Returns properties reflecting the locale and collation options of a **Collator** ...@@ -545,7 +547,7 @@ Returns properties reflecting the locale and collation options of a **Collator**
| Type | Description | | Type | Description |
| ------------------------------------ | ----------------- | | ------------------------------------ | ----------------- |
| [CollatorOptions](#collatoroptions9) | Properties of the **Collator** object.| | [CollatorOptions](#collatoroptions8) | Properties of the **Collator** object.|
**Example** **Example**
```js ```js
...@@ -557,9 +559,10 @@ Returns properties reflecting the locale and collation options of a **Collator** ...@@ -557,9 +559,10 @@ Returns properties reflecting the locale and collation options of a **Collator**
``` ```
## CollatorOptions<sup>9+</sup> ## CollatorOptions<sup>8+</sup>
Represents the properties of a **Collator** object. Represents the properties of a **Collator** object.
In API version 9, the attributes in **CollatorOptions** are optional.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
...@@ -605,7 +608,7 @@ Creates a **PluralRules** object to obtain the singular-plural type of numbers. ...@@ -605,7 +608,7 @@ Creates a **PluralRules** object to obtain the singular-plural type of numbers.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------------------- | ---------------------------------------- | ---- | ---------------------------- | | -------------------- | ---------------------------------------- | ---- | ---------------------------- |
| locale | string \| Array&lt;string&gt; | Yes | A string containing locale information, including the language, optional script, and region.| | locale | string \| Array&lt;string&gt; | Yes | A string containing locale information, including the language, optional script, and region.|
| options<sup>9+</sup> | [PluralRulesOptions](#pluralrulesoptions9) | No | Options for creating a **PluralRules** object. | | options | [PluralRulesOptions](#pluralrulesoptions8) | No | Options for creating a **PluralRules** object. |
**Example** **Example**
```js ```js
...@@ -648,9 +651,10 @@ Obtains a string that represents the singular-plural type of the specified numbe ...@@ -648,9 +651,10 @@ Obtains a string that represents the singular-plural type of the specified numbe
``` ```
## PluralRulesOptions<sup>9+</sup> ## PluralRulesOptions<sup>8+</sup>
Represents the properties of a **PluralRules** object. Represents the properties of a **PluralRules** object.
In API version 9, the attributes in **PluralRulesOptions** are optional.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
...@@ -696,7 +700,7 @@ Creates a **RelativeTimeFormat** object. ...@@ -696,7 +700,7 @@ Creates a **RelativeTimeFormat** object.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------------------- | ---------------------------------------- | ---- | ---------------------------- | | -------------------- | ---------------------------------------- | ---- | ---------------------------- |
| locale | string \| Array&lt;string&gt; | Yes | A string containing locale information, including the language, optional script, and region.| | locale | string \| Array&lt;string&gt; | Yes | A string containing locale information, including the language, optional script, and region.|
| options<sup>9+</sup> | [RelativeTimeFormatInputOptions](#relativetimeformatinputoptions9) | No | Options for creating a **RelativeTimeFormat** object. | | options | [RelativeTimeFormatInputOptions](#relativetimeformatinputoptions8) | No | Options for creating a **RelativeTimeFormat** object. |
**Example** **Example**
```js ```js
...@@ -788,9 +792,10 @@ Obtains the formatting options for **RelativeTimeFormat** objects. ...@@ -788,9 +792,10 @@ Obtains the formatting options for **RelativeTimeFormat** objects.
``` ```
## RelativeTimeFormatInputOptions<sup>9+</sup> ## RelativeTimeFormatInputOptions<sup>8+</sup>
Represents the properties of a **RelativeTimeFormat** object. Represents the properties of a **RelativeTimeFormat** object.
In API version 9, the attributes in **RelativeTimeFormatInputOptions** are optional.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
......
# @ohos.logLibrary (Log Library)
The **logLibrary** module provides APIs for obtaining various system maintenance and test logs.
> **NOTE**
>
> - The initial APIs of this module are supported since API version 10. 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
```js
import logLibrary from '@ohos.logLibrary';
```
## LogEntry
Defines a **LogEntry** object.
**System capability**: SystemCapability.HiviewDFX.Hiview.LogLibrary
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| name | string | Yes| No| Log file name. |
| mtime | number | Yes| No | Time of the last modification to the file. The value is the number of seconds elapsed since 00:00:00 on January 1, 1970.|
| size | number | Yes| No | File size, in bytes.|
## logLibrary.list
list(logType: string): LogEntry[]
Obtains the list of log files of the specified type in synchronous mode. This API accepts objects of the string type as input parameters and returns a list log files of the specified type.
**Required permission**: ohos.permission.READ_HIVIEW_SYSTEM
**System capability**: SystemCapability.HiviewDFX.Hiview.LogLibrary
**Parameters**
| Name | Type | Mandatory| Description |
| --------- | ------------------------- | ---- | ------------------------------------------------------------ |
| logType | string | Yes| Log type, for example, **HILOG**, **FAULTLOG**, **BETACLUB**, or **REMOTELOG**.|
**Return value**
| Type | Description |
| ------------------- | ------------------------------------------------------------ |
| LogEntry[] | Array of log file objects.|
**Error codes**
For details about error codes, see [Log Library Error Codes](../errorcodes/errorcode-loglibrary.md).
| ID| Error Message|
| ------- | ----------------------------------------------------------------- |
| 201 | Permission denied. |
| 202 | Permission denied, non-system app called system api. |
| 401 | Invalid argument.|
**Example**
```js
import logLibrary from '@ohos.logLibrary';
try {
let logObj = logLibrary.list('HILOG');
// do something here.
} catch (error) {
console.error(`error code: ${error.code}, error msg: ${error.message}`);
}
```
## logLibrary.copy
copy(logType: string, logName: string, dest: string): Promise&lt;void&gt;
Copies log files of the specified type to the target application directory. This API uses a promise to return the result.
**Required permission**: ohos.permission.READ_HIVIEW_SYSTEM
**System capability**: SystemCapability.HiviewDFX.Hiview.LogLibrary
**Parameters**
| Name | Type | Mandatory| Description|
| --------- | ----------------------- | ---- | --------------- |
| logType | string | Yes| Log type, for example, **HILOG**, **FAULTLOG**, **BETACLUB**, or **REMOTELOG**.|
| logName | string | Yes | Log file name.|
| dest | string | Yes | Target directory. Enter the relative path of the directory. If this parameter is specified, log files will be saved to the **hiview/dest** folder in the application cache path, that is, **../cache/hiview/dest**. You can enter a multi-level directory.<br>If you leave this parameter empty, log files will be saved to the root directory, that is, the **hiview** folder in the application cache path.|
**Return value**
| Type | Description |
| ------------------- | ------------------------------------------------------------ |
| Promise&lt;void&gt; | Promise used to return the result. Depending on whether the operation is successful, you can use the **then()** or **catch()** method to process the callback.|
**Error codes**
For details about error codes, see [Log Library Error Codes](../errorcodes/errorcode-loglibrary.md).
| ID| Error Message|
| -------- | ---------------------------------------------------------------- |
| 201 | Permission denied. |
| 202 | Permission denied, non-system app called system api. |
| 401 | Invalid argument.|
| 21300001 | Source file does not exists. |
**Example**
```js
import logLibrary from '@ohos.logLibrary';
try {
logLibrary.copy('HILOG', 'hiapplogcat-1.zip', ''
).then(
(val) => {
// do something here.
}
).catch(
(err) => {
// do something here.
}
)
} catch (error) {
console.error(`error code: ${error.code}, error msg: ${error.message}`);
}
```
## logLibrary.copy
copy(logType: string, logName: string, dest: string, callback: AsyncCallback&lt;void&gt;): void
Copies log files of the specified type to the target application directory. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.READ_HIVIEW_SYSTEM
**System capability**: SystemCapability.HiviewDFX.Hiview.LogLibrary
**Parameters**
| Name | Type | Mandatory| Description |
| --------- | ------------------------- | ---- | ------------------------------------------------------------ |
| logType | string | Yes| Log type, for example, **HILOG**, **FAULTLOG**, **BETACLUB**, or **REMOTELOG**.|
| logName | string | Yes | Log file name.|
| dest | string | Yes | Target directory. Enter the relative path of the directory. If this parameter is specified, log files will be saved to the **hiview/dest** folder in the application cache path, that is, **../cache/hiview/dest**. You can enter a multi-level directory.<br>If you leave this parameter empty, log files will be saved to the root directory, that is, the **hiview** folder in the application cache path.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to process the received return value. The value **0** indicates that the operation is successful, and any other value indicates that the operation has failed.|
**Error codes**
For details about error codes, see [Log Library Error Codes](../errorcodes/errorcode-loglibrary.md).
| ID| Error Message|
| ------- | ----------------------------------------------------------------- |
| 201 | Permission denied. |
| 202 | Permission denied, non-system app called system api. |
| 401 | Invalid argument.|
| 21300001 | Source file does not exists. |
**Example**
```js
import logLibrary from '@ohos.logLibrary';
try {
logLibrary.copy('HILOG', 'hiapplogcat-1.zip', 'dir1', (error, val) => {
if (val === undefined) {
// copy failed.
} else {
// copy success.
}
});
} catch (error) {
console.error(`error code: ${error.code}, error msg: ${error.message}`);
}
```
## logLibrary.move
move(logType: string, logName: string, dest: string): Promise&lt;void&gt;
Moves log files of the specified type to the target application directory. This API uses a promise to return the result.
**Required permission**: ohos.permission.WRITE_HIVIEW_SYSTEM
**System capability**: SystemCapability.HiviewDFX.Hiview.LogLibrary
**Parameters**
| Name | Type | Mandatory| Description|
| --------- | ----------------------- | ---- | --------------- |
| logType | string | Yes| Log type, for example, **FAULTLOG**, **BETACLUB**, or **REMOTELOG**.|
| logName | string | Yes | Log file name.|
| dest | string | Yes | Target directory. Enter the relative path of the directory. If this parameter is specified, log files will be saved to the **hiview/dest** folder in the application cache path, that is, **../cache/hiview/dest**. You can enter a multi-level directory.<br>If you leave this parameter empty, log files will be saved to the root directory, that is, the **hiview** folder in the application cache path.|
**Return value**
| Type | Description |
| ------------------- | ------------------------------------------------------------ |
| Promise&lt;void&gt; | Promise used to return the result. Depending on whether the operation is successful, you can use the **then()** or **catch()** method to process the callback.|
**Error codes**
For details about error codes, see [Log Library Error Codes](../errorcodes/errorcode-loglibrary.md).
| ID| Error Message|
| -------- | ---------------------------------------------------------------- |
| 201 | Permission denied. |
| 202 | Permission denied, non-system app called system api. |
| 401 | Invalid argument.|
| 21300001 | Source file does not exists. |
**Example**
```js
import logLibrary from '@ohos.logLibrary';
try {
logLibrary.move('FAULTLOG', 'fault_log_test.zip', ''
).then(
(val) => {
// do something here.
}
).catch(
(err) => {
// do something here.
}
)
} catch (error) {
console.error(`error code: ${error.code}, error msg: ${error.message}`);
}
```
## logLibrary.move
move(logType: string, logName: string, dest: string, callback: AsyncCallback&lt;void&gt;): void
Moves log files of the specified type to the target application directory. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.WRITE_HIVIEW_SYSTEM
**System capability**: SystemCapability.HiviewDFX.Hiview.LogLibrary
**Parameters**
| Name | Type | Mandatory| Description |
| --------- | ------------------------- | ---- | ------------------------------------------------------------ |
| logType | string | Yes| Log type, for example, **HILOG**, **FAULTLOG**, **BETACLUB**, or **REMOTELOG**.|
| logName | string | Yes | Log file name.|
| dest | string | Yes | Target directory. Enter the relative path of the directory. If this parameter is specified, log files will be saved to the **hiview/dest** folder in the application cache path, that is, **../cache/hiview/dest**. You can enter a multi-level directory.<br>If you leave this parameter empty, log files will be saved to the root directory, that is, the **hiview** folder in the application cache path.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to process the received return value. The value **0** indicates that the operation is successful, and any other value indicates that the operation has failed.|
**Error codes**
For details about error codes, see [Log Library Error Codes](../errorcodes/errorcode-loglibrary.md).
| ID| Error Message|
| ------- | ----------------------------------------------------------------- |
| 201 | Permission denied. |
| 202 | Permission denied, non-system app called system api. |
| 401 | Invalid argument.|
| 21300001 | Source file does not exists. |
**Example**
```js
import logLibrary from '@ohos.logLibrary';
try {
logLibrary.move('FAULTLOG', 'fault_log_test.zip', 'dir1/dir2', (error, val) => {
if (val === undefined) {
// move failed.
} else {
// move success.
}
});
} catch (error) {
console.error(`error code: ${error.code}, error msg: ${error.message}`);
}
```
## logLibrary.remove
remove(logType: string, logName: string): void
Deletes log files of the specified type in synchronous mode.
**Required permission**: ohos.permission.WRITE_HIVIEW_SYSTEM
**System capability**: SystemCapability.HiviewDFX.Hiview.LogLibrary
**Parameters**
| Name | Type | Mandatory| Description |
| --------- | ------------------------- | ---- | ------------------------------------------------------------ |
| logType | string | Yes| Log type, for example, **FAULTLOG**, **BETACLUB**, or **REMOTELOG**.|
| logName | string | Yes | Log file name.|
**Error codes**
For details about error codes, see [Log Library Error Codes](../errorcodes/errorcode-loglibrary.md).
| ID| Error Message|
| ------- | ----------------------------------------------------------------- |
| 201 | Permission denied. |
| 202 | Permission denied, non-system app called system api. |
| 401 | Invalid argument.|
| 21300001 | Source file does not exists. |
**Example**
```js
import logLibrary from '@ohos.logLibrary';
try {
logLibrary.remove('FAULTLOG', 'fault_log_test.zip');
} catch (error) {
console.error(`error code: ${error.code}, error msg: ${error.message}`);
}
```
# console (Log Printing) # Console
The **console** module provides basic log printing capabilities and supports log printing by log level. The **console** module provides a simple debugging console, which is similar to the JavaScript console provided by the browser.
If you want to use more advanced log printing services, for example, filtering logs by the specified ID, you are advised to use [`@ohos.hilog`](js-apis-hilog.md).
> **NOTE** > **NOTE**
> >
...@@ -10,9 +8,9 @@ If you want to use more advanced log printing services, for example, filtering l ...@@ -10,9 +8,9 @@ If you want to use more advanced log printing services, for example, filtering l
## console.debug ## console.debug
debug(message: string): void debug(message: string, ...arguments: any[]): void
Prints debug-level logs. Prints debugging information in formatted output mode.
**System capability**: SystemCapability.ArkUI.ArkUI.Full **System capability**: SystemCapability.ArkUI.ArkUI.Full
...@@ -20,14 +18,25 @@ Prints debug-level logs. ...@@ -20,14 +18,25 @@ Prints debug-level logs.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ----------- | | ------- | ------ | ---- | ----------- |
| message | string | Yes | Text to print.| | message | string | Yes | Text to be printed.|
| arguments | any | No | Arguments in the message or other information to be printed.|
**Example**
```js
const number = 5;
console.debug('count: %d', number); // Print the debugging information with arguments in the message replaced.
// count: 5
console.debug('count:', number); // Print the message and other information.
// count: 5
console.debug('count:'); // Print the message only.
// count:
```
## console.log ## console.log
log(message: string): void log(message: string, ...arguments: any[]): void
Prints debug-level logs. Prints log information in formatted output mode.
**System capability**: SystemCapability.ArkUI.ArkUI.Full **System capability**: SystemCapability.ArkUI.ArkUI.Full
...@@ -35,14 +44,25 @@ Prints debug-level logs. ...@@ -35,14 +44,25 @@ Prints debug-level logs.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ----------- | | ------- | ------ | ---- | ----------- |
| message | string | Yes | Text to print.| | message | string | Yes | Text to be printed.|
| arguments | any | No |Arguments in the message or other information to be printed.|
**Example**
```js
const number = 5;
console.log('count: %d', number); // Print the log information with arguments in the message replaced.
// count: 5
console.log('count:', number); // Print the message and other information.
// count: 5
console.log('count:'); // Print the message only.
// count:
```
## console.info ## console.info
info(message: string): void info(message: string, ...arguments: any[]): void
Prints info-level logs. Prints log information in formatted output mode. This API is the alias of **console.log ()**.
**System capability**: SystemCapability.ArkUI.ArkUI.Full **System capability**: SystemCapability.ArkUI.ArkUI.Full
...@@ -50,14 +70,25 @@ Prints info-level logs. ...@@ -50,14 +70,25 @@ Prints info-level logs.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ----------- | | ------- | ------ | ---- | ----------- |
| message | string | Yes | Text to print.| | message | string | Yes | Text to be printed.|
| arguments | any | No | Arguments in the message or other information to be printed.|
**Example**
```js
const number = 5;
console.info('count: %d', number); // Print the log information with arguments in the message replaced.
// count: 5
console.info('count:', number); // Print the message and other information.
// count: 5
console.info('count:'); // Print the message only.
// count:
```
## console.warn ## console.warn
warn(message: string): void warn(message: string, ...arguments: any[]): void
Prints warn-level logs. Prints warning information in formatted output mode.
**System capability**: SystemCapability.ArkUI.ArkUI.Full **System capability**: SystemCapability.ArkUI.ArkUI.Full
...@@ -65,14 +96,25 @@ Prints warn-level logs. ...@@ -65,14 +96,25 @@ Prints warn-level logs.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ----------- | | ------- | ------ | ---- | ----------- |
| message | string | Yes | Text to print.| | message | string | Yes | Warning information to be printed.|
| arguments | any | No | Arguments in the message or other information to be printed.|
**Example**
```js
const str = "name should be string";
console.warn('warn: %d', str); // Print the warning information with arguments in the message replaced.
// warn: name should be string
console.warn('warn:', str); // Print the message and other information.
// warn: name should be string
console.warn('warn:'); // Print the message only.
// warn:
```
## console.error ## console.error
error(message: string): void error(message: string, ...arguments: any[]): void
Prints error-level logs. Prints error information in formatted output mode.
**System capability**: SystemCapability.ArkUI.ArkUI.Full **System capability**: SystemCapability.ArkUI.ArkUI.Full
...@@ -80,31 +122,26 @@ Prints error-level logs. ...@@ -80,31 +122,26 @@ Prints error-level logs.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ----------- | | ------- | ------ | ---- | ----------- |
| message | string | Yes | Text to print.| | message | string | Yes | Error information to be printed.|
| arguments | any | No | Arguments in the message or other information to be printed.|
**Example** **Example**
```js
const str = "value is not defined";
console.error('error: %d', str); // Print the error information with arguments in the message replaced.
// error: value is not defined
console.error('error:', str); // Print the message and other information.
// error: value is not defined
console.error('error:'); // Print the message only.
// error:
``` ```
export default {
clickConsole(){
var versionCode = 1;
console.info('Hello World. The current version code is ' + versionCode);
console.log(`versionCode: ${versionCode}`);
/ / The following is supported since API version 6: console.log('versionCode:%d.', versionCode);
}
}
```
Switch to the HiLog window at the bottom of HUAWEI DevEco Studio. Specifically, select the current device and process, set the log level to Info, and enter Hello World in the search box. Logs that meet the search criteria are displayed, as shown in the following figure.
![Printing logs](figures/printing-logs.png)
## console.assert<sup>10+</sup> ## console.assert<sup>10+</sup>
assert(value?: Object, ...arguments: Object[]): void assert(value?: Object, ...arguments: Object[]): void
If **value** is false, the subsequent content will be printed. Prints assertion information.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
...@@ -112,24 +149,26 @@ If **value** is false, the subsequent content will be printed. ...@@ -112,24 +149,26 @@ If **value** is false, the subsequent content will be printed.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ----------- | | ------- | ------ | ---- | ----------- |
| value | Object | No | Value| | value | Object | No | Result value. If **value** is **false** or left blank, the output starting with "Assertion failed" is printed. If **value** is **true**, no information is printed.|
| arguments | Object | No | Prints error messages.| | arguments | Object | No | Other information to be printed when **value** is **false**. If this parameter is left blank, other information is not printed.|
**Example** **Example**
``` ```js
console.assert(true, 'does nothing'); console.assert(true, 'does nothing'); // Do not print error information as value is true.
console.assert(2% 1 == 0,'does nothing'); // Do not print error information as value is true.
console.assert(false, 'console %s work', 'didn\'t'); console.assert(false, 'console %s work', 'didn\'t');
// Assertion console:ohos didn't work // Assertion failed: console didn't work
console.assert(); console.assert();
// Assertion failed // Assertion failed
``` ```
## console.count<sup>10+</sup> ## console.count<sup>10+</sup>
count(label?: string): void count(label?: string): void
Adds a counter by the specified label name to count the number of times **console.count()** is called. The default value is **default**. Maintains an internal counter. When this counter is invoked, its label name and the corresponding call count are printed.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
...@@ -137,10 +176,11 @@ Adds a counter by the specified label name to count the number of times **consol ...@@ -137,10 +176,11 @@ Adds a counter by the specified label name to count the number of times **consol
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ----------- | | ------- | ------ | ---- | ----------- |
| label | string | No | Counter label name.| | label | string | No | Counter label name. The default value is **default**.|
**Example** **Example**
``` ```js
console.count() console.count()
// default: 1 // default: 1
console.count('default') console.count('default')
...@@ -150,7 +190,7 @@ console.count('abc') ...@@ -150,7 +190,7 @@ console.count('abc')
console.count('xyz') console.count('xyz')
// xyz: 1 // xyz: 1
console.count('abc') console.count('abc')
abc: 2 // abc: 2
console.count() console.count()
// default: 3 // default: 3
``` ```
...@@ -159,7 +199,7 @@ console.count() ...@@ -159,7 +199,7 @@ console.count()
countReset(label?: string): void countReset(label?: string): void
Resets a counter by the specified label name. The default value is **default**. Resets a counter based on the specified label name.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
...@@ -167,10 +207,10 @@ Resets a counter by the specified label name. The default value is **default**. ...@@ -167,10 +207,10 @@ Resets a counter by the specified label name. The default value is **default**.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ----------- | | ------- | ------ | ---- | ----------- |
| label | string | No | Counter label name.| | label | string | No | Counter label name. The default value is **default**.|
**Example** **Example**
``` ```js
console.count('abc'); console.count('abc');
// abc: 1 // abc: 1
console.countReset('abc'); console.countReset('abc');
...@@ -190,13 +230,24 @@ Prints content of the specified object. ...@@ -190,13 +230,24 @@ Prints content of the specified object.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ----------- | | ------- | ------ | ---- | ----------- |
| dir | Object | No | Object whose content needs to be printed.| | dir | Object | No | Object whose content needs to be printed. If this parameter is left blank, no information is printed.|
**Example**
```js
let a = { foo: { bar: { baz: true } }};
console.dir(a);
// Object: {"foo":{"bar":{"baz":true}}}
console.dir(); // No information is printed.
```
## console.dirxml<sup>10+</sup> ## console.dirxml<sup>10+</sup>
dirxml(...arguments: Object[]): void dirxml(...arguments: Object[]): void
Calls **console.log()** and passes the received parameters to it. This API does not produce any content of the XML format. Displays an interactive tree of the descendant elements of the specified XML element. This API is implemented by calling **console.log()** internally. It does not produce any XML elements. The usage method is the same as that of **console.log()**.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
...@@ -204,13 +255,24 @@ Calls **console.log()** and passes the received parameters to it. This API does ...@@ -204,13 +255,24 @@ Calls **console.log()** and passes the received parameters to it. This API does
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ----------- | | ------- | ------ | ---- | ----------- |
| arguments | Object | No | Information to be printed.| | arguments | Object | Yes | Information to be printed.|
**Example**
```js
const number = 5;
console.dirxml('count: %d', number);
// count: 5
console.dirxml('count:', number);
// count: 5
console.dirxml('count:');
// count:
```
## console.group<sup>10+</sup> ## console.group<sup>10+</sup>
group(...arguments: Object[]): void group(...arguments: Object[]): void
Creates an inline group so that subsequent lines are indented by the value specified by **groupIndentation**. Increases the indentation of subsequent lines by two spaces.
If the information to be printed is provided, the information is printed without extra indentation. If the information to be printed is provided, the information is printed without extra indentation.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
...@@ -220,11 +282,26 @@ If the information to be printed is provided, the information is printed without ...@@ -220,11 +282,26 @@ If the information to be printed is provided, the information is printed without
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ----------- | | ------- | ------ | ---- | ----------- |
| arguments | Object | No | Information to be printed.| | arguments | Object | No | Information to be printed.|
**Example**
```js
console.log("outter");
// outter
console.group();
console.log("level 1");
// level 1
console.group("in level1");
// in level1
console.log("level 2");
// level 2
```
## console.groupCollapsed<sup>10+</sup> ## console.groupCollapsed<sup>10+</sup>
groupCollapsed(...arguments: Object[]): void groupCollapsed(...arguments: Object[]): void
Creates a collapsed inline group. Creates a new inline group in collapsed mode. The usage and function of this API are the same as those of **console.group()**.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
...@@ -234,14 +311,42 @@ Creates a collapsed inline group. ...@@ -234,14 +311,42 @@ Creates a collapsed inline group.
| ------- | ------ | ---- | ----------- | | ------- | ------ | ---- | ----------- |
| arguments | Object | No | Information to be printed.| | arguments | Object | No | Information to be printed.|
**Example**
```js
console.groupCollapsed("outter");
// outter
console.groupCollapsed();
console.log("level 1");
// level 1
console.groupCollapsed("in level1");
// in level1
console.log("level 2");
// level 2
```
## console.groupEnd<sup>10+</sup> ## console.groupEnd<sup>10+</sup>
groupEnd(): void groupEnd(): void
Exits an inline group so that subsequent lines are not indented by the value specified by **groupIndentation** . Reduces the indentation of subsequent lines by two spaces.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Example**
```js
console.log("outter");
// outter
console.group();
console.log("level 1");
// level 1
console.groupEnd();
console.log("outter");
// outter
```
## console.table<sup>10+</sup> ## console.table<sup>10+</sup>
table(tableData?: Object): void table(tableData?: Object): void
...@@ -254,10 +359,10 @@ Prints data in a table. ...@@ -254,10 +359,10 @@ Prints data in a table.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ----------- | | ------- | ------ | ---- | ----------- |
| tableData | Object | No | Data to be printed in a table.| | tableData | Object | No | Data to be printed in a table. If this parameter is left blank, no information is printed.|
**Example** **Example**
``` ```js
console.table([1, 2, 3]); console.table([1, 2, 3]);
// ┌─────────┬────────┐ // ┌─────────┬────────┐
// │ (index) │ Values │ // │ (index) │ Values │
...@@ -281,7 +386,7 @@ console.table({ a: [1, 2, 3, 4, 5], b: 5, c: { e: 5 } }); ...@@ -281,7 +386,7 @@ console.table({ a: [1, 2, 3, 4, 5], b: 5, c: { e: 5 } });
time(label?: string): void time(label?: string): void
Starts a timer to track the duration of an operation. The default value is **default**. You can use **console.timeEnd()** to disable the timer and print the result. Starts a timer to track the duration of an operation. You can use **console.timeEnd()** to close the timer and print the elapsed time (in ms).
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
...@@ -289,13 +394,18 @@ Starts a timer to track the duration of an operation. The default value is **def ...@@ -289,13 +394,18 @@ Starts a timer to track the duration of an operation. The default value is **def
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ----------- | | ------- | ------ | ---- | ----------- |
| label | string | No | Timer label.| | label | string | No | Timer label. The default value is **default**.|
**Example**
```js
console.time('abc');
```
## console.timeEnd<sup>10+</sup> ## console.timeEnd<sup>10+</sup>
timeEnd(label?: string): void timeEnd(label?: string): void
Stops the timer started by **console.time()** and prints the result. The default value is **default**. Stops the timer started by calling **console.time()** and prints the elapsed time (in ms).
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
...@@ -303,10 +413,10 @@ Stops the timer started by **console.time()** and prints the result. The default ...@@ -303,10 +413,10 @@ Stops the timer started by **console.time()** and prints the result. The default
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ----------- | | ------- | ------ | ---- | ----------- |
| label | string | No | Timer label.| | label | string | No | Timer label. The default value is **default**.|
**Example** **Example**
``` ```js
console.time('abc'); console.time('abc');
console.timeEnd('abc'); console.timeEnd('abc');
// abc: 225.438ms // abc: 225.438ms
...@@ -316,7 +426,7 @@ console.timeEnd('abc'); ...@@ -316,7 +426,7 @@ console.timeEnd('abc');
timeLog(label?: string, ...arguments: Object[]): void timeLog(label?: string, ...arguments: Object[]): void
Prints the elapsed time and other logs for the timer started by **console.time()**. Prints the elapsed time and other data parameters for the timer started by **console.time()**.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
...@@ -324,14 +434,13 @@ Prints the elapsed time and other logs for the timer started by **console.time() ...@@ -324,14 +434,13 @@ Prints the elapsed time and other logs for the timer started by **console.time()
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ----------- | | ------- | ------ | ---- | ----------- |
| label | string | No | Timer label.| | label | string | No | Timer label. The default value is **default**.|
| arguments | Object | No | Logs to be printed.| | arguments | Object | No | Logs to be printed.|
**Example** **Example**
``` ```js
console.time('timer1'); console.time('timer1');
const value = aaa (); // Return 17. console.timeLog('timer1', 17);
console.timeLog('timer1', value);
// timer1: 365.227ms 17 // timer1: 365.227ms 17
console.timeEnd('timer1'); console.timeEnd('timer1');
// timer1: 513.22ms // timer1: 513.22ms
...@@ -349,10 +458,14 @@ Creates a stack trace. ...@@ -349,10 +458,14 @@ Creates a stack trace.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ----------- | | ------- | ------ | ---- | ----------- |
| arguments | Object | No | Logs to be printed.| | arguments | Object | No | Logs to be printed. If this parameter is left blank, only stack information is printed.|
**Example** **Example**
``` ```js
console.trace(); console.trace();
// Trace:
// xxxxxxxxxx (current stack information)
console.trace("Show the trace"); console.trace("Show the trace");
// Trace: Show the trace
// xxxxxxxxxx (current stack information)
``` ```
...@@ -55,8 +55,7 @@ ethernet.setIfaceConfig("eth0", { ...@@ -55,8 +55,7 @@ ethernet.setIfaceConfig("eth0", {
route: "192.168.xx.xxx", route: "192.168.xx.xxx",
gateway: "192.168.xx.xxx", gateway: "192.168.xx.xxx",
netMask: "255.255.255.0", netMask: "255.255.255.0",
dnsServers: "1.1.1.1", dnsServers: "1.1.1.1"
domain: "2.2.2.2"
}, (error) => { }, (error) => {
if (error) { if (error) {
console.log("setIfaceConfig callback error = " + JSON.stringify(error)); console.log("setIfaceConfig callback error = " + JSON.stringify(error));
...@@ -115,8 +114,7 @@ ethernet.setIfaceConfig("eth0", { ...@@ -115,8 +114,7 @@ ethernet.setIfaceConfig("eth0", {
route: "192.168.xx.xxx", route: "192.168.xx.xxx",
gateway: "192.168.xx.xxx", gateway: "192.168.xx.xxx",
netMask: "255.255.255.0", netMask: "255.255.255.0",
dnsServers: "1.1.1.1", dnsServers: "1.1.1.1"
domain: "2.2.2.2"
}).then(() => { }).then(() => {
console.log("setIfaceConfig promise ok "); console.log("setIfaceConfig promise ok ");
}).catch(error => { }).catch(error => {
...@@ -168,7 +166,6 @@ ethernet.getIfaceConfig("eth0", (error, value) => { ...@@ -168,7 +166,6 @@ ethernet.getIfaceConfig("eth0", (error, value) => {
console.log("getIfaceConfig callback gateway = " + JSON.stringify(value.gateway)); console.log("getIfaceConfig callback gateway = " + JSON.stringify(value.gateway));
console.log("getIfaceConfig callback netMask = " + JSON.stringify(value.netMask)); console.log("getIfaceConfig callback netMask = " + JSON.stringify(value.netMask));
console.log("getIfaceConfig callback dnsServers = " + JSON.stringify(value.dnsServers)); console.log("getIfaceConfig callback dnsServers = " + JSON.stringify(value.dnsServers));
console.log("getIfaceConfig callback domain = " + JSON.stringify(value.domain));
} }
}); });
``` ```
...@@ -219,7 +216,6 @@ ethernet.getIfaceConfig("eth0").then((data) => { ...@@ -219,7 +216,6 @@ ethernet.getIfaceConfig("eth0").then((data) => {
console.log("getIfaceConfig promise gateway = " + JSON.stringify(data.gateway)); console.log("getIfaceConfig promise gateway = " + JSON.stringify(data.gateway));
console.log("getIfaceConfig promise netMask = " + JSON.stringify(data.netMask)); console.log("getIfaceConfig promise netMask = " + JSON.stringify(data.netMask));
console.log("getIfaceConfig promise dnsServers = " + JSON.stringify(data.dnsServers)); console.log("getIfaceConfig promise dnsServers = " + JSON.stringify(data.dnsServers));
console.log("getIfaceConfig promise domain = " + JSON.stringify(data.domain));
}).catch(error => { }).catch(error => {
console.log("getIfaceConfig promise error = " + JSON.stringify(error)); console.log("getIfaceConfig promise error = " + JSON.stringify(error));
}); });
......
...@@ -45,9 +45,9 @@ During RPC or IPC, the sender can use the **write()** method provided by **Messa ...@@ -45,9 +45,9 @@ During RPC or IPC, the sender can use the **write()** method provided by **Messa
### create ### create
static create(): MessageSequence static create(): MessageSequence
Creates a **MessageSequence** object. This API is a static method. Creates a **MessageSequence** object. This API is a static method.
**System capability**: SystemCapability.Communication.IPC.Core **System capability**: SystemCapability.Communication.IPC.Core
...@@ -6821,8 +6821,8 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -6821,8 +6821,8 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
} }
let deathRecipient = new MyDeathRecipient(); let deathRecipient = new MyDeathRecipient();
try { try {
proxy.registerDeathRecippient(deathRecipient, 0); proxy.registerDeathRecipient(deathRecipient, 0);
proxy.unregisterDeathRecippient(deathRecipient, 0); proxy.unregisterDeathRecipient(deathRecipient, 0);
} catch(error) { } catch(error) {
console.info("proxy register deathRecipient fail, errorCode " + error.code); console.info("proxy register deathRecipient fail, errorCode " + error.code);
console.info("proxy register deathRecipient fail, errorMessage " + error.message); console.info("proxy register deathRecipient fail, errorMessage " + error.message);
...@@ -6893,7 +6893,7 @@ Removes the callback used to receive death notifications of the remote object. ...@@ -6893,7 +6893,7 @@ Removes the callback used to receive death notifications of the remote object.
} }
} }
let deathRecipient = new MyDeathRecipient(); let deathRecipient = new MyDeathRecipient();
proxy.addDeathRecippient(deathRecipient, 0); proxy.addDeathRecipient(deathRecipient, 0);
proxy.removeDeathRecipient(deathRecipient, 0); proxy.removeDeathRecipient(deathRecipient, 0);
``` ```
......
# @ohos.multimodalInput.shortKey (Shortcut Key)
The **shortKey** module provides APIs to set the delay for starting an ability using a shortcut key. For example, you can set the delay to 3 seconds so that a screenshot is taken when you press and hold the shortcut key for 3 seconds.
> **NOTE**
>
> - The initial APIs of this module are supported since API version 10. 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
```
import shortKey from '@ohos.multimodalInput.shortKey';
```
## shortKey.setKeyDownDuration
setKeyDownDuration(businessId: string, delay: number, callback: AsyncCallback&lt;void&gt;): void
Sets the delay for starting an ability using the shortcut key. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MultimodalInput.Input.ShortKey
**Parameters**
| Name | Type | Mandatory| Description |
| ---------- | ------------------- | ---- | ------------------------------------------------------------ |
| businessId | string | Yes | Unique service ID registered on the multimodal side. It corresponds to **businessId** in the **ability_launch_config.json** file.|
| delay | number | Yes | Delay for starting an ability using the shortcut key, in ms.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example**
```
try {
shortKey.setKeyDownDuration("screenshot", 500, (error) => {
if (error) {
console.log(`Set key down duration failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
return;
}
console.log(`Set key down duration success`);
});
} catch (error) {
console.log(`Set key down duration failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## shortKey.setKeyDownDuration
setKeyDownDuration(businessId: string, delay: number): Promise&lt;void&gt;
Sets the delay for starting an ability using the shortcut key. This API uses a promise to return the result.
**System capability**: SystemCapability.MultimodalInput.Input.ShortKey
**Parameters**
| Name | Type | Mandatory| Description |
| ---------- | ------ | ---- | ------------------------------------------------------------ |
| businessId | string | Yes | Unique service ID registered on the multimodal side. It corresponds to **businessId** in the **ability_launch_config.json** file.|
| delay | number | Yes | Delay for starting an ability using the shortcut key, in ms.|
**Return value**
| Parameters | Description |
| ------------- | ------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
```
try {
shortKey.setKeyDownDuration("screenshot", 500).then(() => {
console.log(`Set key down duration success`);
});
} catch (error) {
console.log(`Set key down duration failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
...@@ -27,7 +27,7 @@ Obtains the current charging state and battery level. ...@@ -27,7 +27,7 @@ Obtains the current charging state and battery level.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| options | [GetStatusOptions](#getstatusoptions) | No| Object that contains the API calling result.| | options | [GetStatusOptions](#getstatusoptions) | No| Object that contains the API calling result. This parameter is optional and is left blank by default.|
**Example** **Example**
...@@ -50,9 +50,9 @@ Object that contains the API calling result. ...@@ -50,9 +50,9 @@ Object that contains the API calling result.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | --------------------------------------------------- | ---- | ------------------------------------------------------------ |
| success | (data: [BatteryResponse](#batteryresponse)) => void | No | Called when API call is successful. **data** is a return value of the [BatteryResponse](#batteryresponse) type.| | success | (data: [BatteryResponse](#batteryresponse)) => void | No | Called when an API call is successful. **data** is a return value of the [BatteryResponse](#batteryresponse) type.|
| fail | (data: string, code: number) => void | No | Called when API call has failed. **data** indicates the error information, and **code** indicates the error code. | | fail | (data: string, code: number) => void | No | Called when an API call has failed. **data** indicates the error information, and **code** indicates the error code. |
| complete | () => void | No | Called when API call is complete. | | complete | () => void | No | Called when an API call is complete. |
## BatteryResponse ## BatteryResponse
......
...@@ -28,7 +28,7 @@ Obtains the current screen brightness. ...@@ -28,7 +28,7 @@ Obtains the current screen brightness.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| options | [GetBrightnessOptions](#getbrightnessoptions) | No | Options for obtaining the screen brightness.| | options | [GetBrightnessOptions](#getbrightnessoptions) | No | Options for obtaining the screen brightness. This parameter is optional and is left blank by default.|
**Example** **Example**
...@@ -56,7 +56,7 @@ Sets the screen brightness. ...@@ -56,7 +56,7 @@ Sets the screen brightness.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| options | [SetBrightnessOptions](#setbrightnessoptions) | No | Options for setting the screen brightness.| | options | [SetBrightnessOptions](#setbrightnessoptions) | No | Options for setting the screen brightness. This parameter is optional and is left blank by default.|
**Example** **Example**
...@@ -85,7 +85,7 @@ Obtains the screen brightness adjustment mode. ...@@ -85,7 +85,7 @@ Obtains the screen brightness adjustment mode.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| options | [GetBrightnessModeOptions](#getbrightnessmodeoptions) | No| Options for obtaining the screen brightness mode.| | options | [GetBrightnessModeOptions](#getbrightnessmodeoptions) | No| Options for obtaining the screen brightness mode. This parameter is optional and is left blank by default.|
**Example** **Example**
...@@ -112,7 +112,7 @@ Sets the screen brightness adjustment mode. ...@@ -112,7 +112,7 @@ Sets the screen brightness adjustment mode.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| options | [SetBrightnessModeOptions](#setbrightnessmodeoptions) | No | Options for setting the screen brightness mode.| | options | [SetBrightnessModeOptions](#setbrightnessmodeoptions) | No | Options for setting the screen brightness mode. This parameter is optional and is left blank by default.|
**Example** **Example**
...@@ -143,7 +143,7 @@ Sets whether to always keep the screen on. Call this API in **onShow()**. ...@@ -143,7 +143,7 @@ Sets whether to always keep the screen on. Call this API in **onShow()**.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| options | [SetKeepScreenOnOptions](#setkeepscreenonoptions) | No| Options for setting the screen to be steady on.| | options | [SetKeepScreenOnOptions](#setkeepscreenonoptions) | No| Options for setting the screen to be steady on. This parameter is optional and is left blank by default.|
**Example** **Example**
...@@ -166,9 +166,9 @@ Defines the options for obtaining the screen brightness. ...@@ -166,9 +166,9 @@ Defines the options for obtaining the screen brightness.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ |
| success | (data: [BrightnessResponse](#brightnessresponse)) => void | No | Called when API call is successful. **data** is a return value of the [BrightnessResponse](#brightnessresponse) type.| | success | (data: [BrightnessResponse](#brightnessresponse)) => void | No | Called when an API call is successful. **data** is a return value of the [BrightnessResponse](#brightnessresponse) type.|
| fail | (data: string, code: number) => void | No | Called when API call has failed. **data** indicates the error information, and **code** indicates the error code. | | fail | (data: string, code: number) => void | No | Called when an API call has failed. **data** indicates the error information, and **code** indicates the error code. |
| complete | () => void | No | Called when the API call is complete. | | complete | () => void | No | Called when an API call is complete. |
## SetBrightnessOptions ## SetBrightnessOptions
...@@ -178,10 +178,10 @@ Defines the options for setting the screen brightness. ...@@ -178,10 +178,10 @@ Defines the options for setting the screen brightness.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------ | ---- | ------------------------------------------------------------ | | -------- | ------------------------------------ | ---- | ------------------------------------------------------------ |
| value | number | Yes | Screen brightness. The value is an integer ranging from **1** to **255**.<br>-&nbsp;If the value is less than or equal to **0**, value **1** will be used.<br>-&nbsp;If the value is greater than **255**, value **255** will be used.<br>-&nbsp;If the value contains decimals, the integral part of the value will be used. For example, if value **8.1** is set, value **8** will be used.| | value | number | Yes | Screen brightness. The value is an integer ranging from **1** to **255**.<br>- If the value is less than or equal to **0**, value **1** will be used.<br>- If the value is greater than **255**, value **255** will be used.<br>- If the value contains decimals, the integral part of the value will be used. For example, if value **8.1** is set, value **8** will be used.|
| success | () => void | No | Callback upon a successful API call. | | success | () => void | No | Called when an API call is successful. |
| fail | (data: string, code: number) => void | No | Called when API call has failed. **data** indicates the error information, and **code** indicates the error code. | | fail | (data: string, code: number) => void | No | Called when an API call has failed. **data** indicates the error information, and **code** indicates the error code. |
| complete | () => void | No | Called when the API call is complete. | | complete | () => void | No | Called when an API call is complete. |
## BrightnessResponse ## BrightnessResponse
...@@ -201,9 +201,9 @@ Defines the options for obtaining the screen brightness mode. ...@@ -201,9 +201,9 @@ Defines the options for obtaining the screen brightness mode.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| success | (data: [BrightnessModeResponse](#brightnessmoderesponse)) => void | No | Called when API call is successful. **data** is a return value of the [BrightnessModeResponse](#brightnessmoderesponse) type.| | success | (data: [BrightnessModeResponse](#brightnessmoderesponse)) => void | No | Called when an API call is successful. **data** is a return value of the [BrightnessModeResponse](#brightnessmoderesponse) type.|
| fail | (data: string, code: number) => void | No | Called when API call has failed. **data** indicates the error information, and **code** indicates the error code. | | fail | (data: string, code: number) => void | No | Called when an API call has failed. **data** indicates the error information, and **code** indicates the error code. |
| complete | () => void | No | Called when the API call is complete. | | complete | () => void | No | Called when an API call is complete. |
## SetBrightnessModeOptions ## SetBrightnessModeOptions
...@@ -214,9 +214,9 @@ Defines the options for setting the screen brightness mode. ...@@ -214,9 +214,9 @@ Defines the options for setting the screen brightness mode.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------ | ---- | ------------------------------------------------------ | | -------- | ------------------------------------ | ---- | ------------------------------------------------------ |
| mode | number | Yes | The value **0** indicates the manual adjustment mode, and the value **1** indicates the automatic adjustment mode.| | mode | number | Yes | The value **0** indicates the manual adjustment mode, and the value **1** indicates the automatic adjustment mode.|
| success | () => void | No | Callback upon a successful API call. | | success | () => void | No | Called when an API call is successful. |
| fail | (data: string, code: number) => void | No | Called when API call has failed. **data** indicates the error information, and **code** indicates the error code.| | fail | (data: string, code: number) => void | No | Called when an API call has failed. **data** indicates the error information, and **code** indicates the error code.|
| complete | () => void | No | Called when the API call is complete. | | complete | () => void | No | Called when an API call is complete. |
## BrightnessModeResponse ## BrightnessModeResponse
...@@ -237,6 +237,6 @@ Defines the options for setting the screen to be steady on. ...@@ -237,6 +237,6 @@ Defines the options for setting the screen to be steady on.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------------ | ------------------------------------ | ---- | ------------------------------------------------------ | | ------------ | ------------------------------------ | ---- | ------------------------------------------------------ |
| keepScreenOn | boolean | Yes | The value **true** means to keep the screen steady on, and the value **false** indicates the opposite. | | keepScreenOn | boolean | Yes | The value **true** means to keep the screen steady on, and the value **false** indicates the opposite. |
| success | () => void | No | Callback upon a successful API call. | | success | () => void | No | Called when an API call is successful. |
| fail | (data: string, code: number) => void | No | Called when API call has failed. **data** indicates the error information, and **code** indicates the error code.| | fail | (data: string, code: number) => void | No | Called when an API call has failed. **data** indicates the error information, and **code** indicates the error code.|
| complete | () => void | No | Called when the API call is complete. | | complete | () => void | No | Called when an API call is complete. |
...@@ -16,47 +16,15 @@ import fetch from '@system.fetch'; ...@@ -16,47 +16,15 @@ import fetch from '@system.fetch';
## fetch.fetch<sup>3+</sup> ## fetch.fetch<sup>3+</sup>
fetch(options:{ fetch(options:{ <br>
/** &nbsp;&nbsp;url: string;<br>
* Resource URL. &nbsp;&nbsp;data?: string | object;<br>
* @since 3 &nbsp;&nbsp;header?: Object;<br>
*/ &nbsp;&nbsp;method?: string;<br>
url: string; &nbsp;&nbsp;responseType?: string;<br>
/** &nbsp;&nbsp;success?: (data: FetchResponse) => void;<br>
* Request parameter, which can be of the string type or a JSON object. &nbsp;&nbsp;fail?: (data: any, code: number) => void;<br>
* @since 3 &nbsp;&nbsp;complete?: () => void;<br>
*/
data?: string | object;
/**
* Request header, which accommodates all attributes of the request.
* @since 3
*/
header?: Object;
/**
* Request methods available: OPTIONS, GET, HEAD, POST, PUT, DELETE and TRACE. The default value is GET.
* @since 3
*/
method?: string;
/**
* The return type can be text, or JSON. By default, the return type is determined based on Content-Type in the header returned by the server.
* @since 3
*/
responseType?: string;
/**
* Called when the network data is obtained successfully.
* @since 3
*/
success?: (data: FetchResponse) => void;
/**
* Called when the network data fails to be obtained.
* @since 3
*/
fail?: (data: any, code: number) => void;
/**
* Called when the execution is completed.
* @since 3
*/
complete?: () => void;
} ): void } ): void
Obtains data through a network. Obtains data through a network.
......
# @system.network (Network State) # @system.network (Network State)
> **NOTE** > **NOTE**
> - The APIs of this module are no longer maintained since API version 7. You are advised to use [`@ohos.telephony.observer`](js-apis-observer.md).
>
> - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version. > - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version.
...@@ -23,23 +21,11 @@ ohos.permission.GET_NETWORK_INFO ...@@ -23,23 +21,11 @@ ohos.permission.GET_NETWORK_INFO
## network.getType<sup>3+</sup> ## network.getType<sup>3+</sup>
getType(options?: { getType(options?: {<br>
/** &nbsp;&nbsp;success?: (data: NetworkResponse) => void;<br>
* Called when the network type is obtained. &nbsp;&nbsp;fail?: (data: any, code: number) => void;<br>
* @since 3 &nbsp;&nbsp;complete?: () => void;<br>
*/ }): void
success?: (data: NetworkResponse) => void;
/**
* Called when the network type fails to be obtained.
* @since 3
*/
fail?: (data: any, code: number) => void;
/**
* Called when the execution is completed.
* @since 3
*/
complete?: () => void;
}): void
Obtains the network type. Obtains the network type.
...@@ -79,17 +65,9 @@ export default { ...@@ -79,17 +65,9 @@ export default {
## network.subscribe<sup>3+</sup> ## network.subscribe<sup>3+</sup>
subscribe(options?:{ subscribe(options?:{<br>
/** &nbsp;&nbsp;success?: (data: NetworkResponse) => void;<br>
* Called when the network connection state changes. &nbsp;&nbsp;fail?: (data: any, code: number) => void;<br>
* @since 3
*/
success?: (data: NetworkResponse) => void;
/**
* Called when the listening fails.
* @since 3
*/
fail?: (data: any, code: number) => void;
}): void }): void
Listens to the network connection state. If this method is called multiple times, the last call takes effect. Listens to the network connection state. If this method is called multiple times, the last call takes effect.
......
# @ohos.thermal (Thermal Management) # @ohos.thermal (Thermal Management)
The **thermal** module provides thermal level-related callback and query APIs to obtain the information required for thermal control. This module provides thermal level-related callback and query APIs to obtain the information required for thermal control.
> **NOTE** > **NOTE**
> >
...@@ -90,7 +90,7 @@ Obtains the current thermal level. ...@@ -90,7 +90,7 @@ Obtains the current thermal level.
**System capability:** SystemCapability.PowerManager.ThermalManager **System capability:** SystemCapability.PowerManager.ThermalManager
**Return value** **Return value**:
| Type | Description | | Type | Description |
| ------------ | ------------ | | ------------ | ------------ |
...@@ -173,7 +173,7 @@ Obtains the current thermal level. ...@@ -173,7 +173,7 @@ Obtains the current thermal level.
**System capability:** SystemCapability.PowerManager.ThermalManager **System capability:** SystemCapability.PowerManager.ThermalManager
**Return value** **Return value**:
| Type | Description | | Type | Description |
| ------------ | ------ | | ------------ | ------ |
......
...@@ -4,44 +4,44 @@ ...@@ -4,44 +4,44 @@
Components support dynamic rotation, translation, and scaling effects. These effects can be set in the **style** attribute or **.css** files. Components support dynamic rotation, translation, and scaling effects. These effects can be set in the **style** attribute or **.css** files.
| Name| Type| Default Value| Description| | Name | Type | Default Value | Description |
| -------- | -------- | -------- | -------- | | ------------------------- | ---------------------------------- | ----------- | ---------------------------------------- |
| transform | string | - | Translation, rotation, and scaling attributes. For details, see Table 1. | | transform | string | - | Translation, rotation, and scaling attributes. For details, see Table 1. |
| animation-name | string | - | @keyframes rule. For details, see Table 2. | | animation-name | string | - | \@keyframes rule. For details, see Table 2. |
| animation-delay | &lt;time&gt; | 0 | Delay for playing the animation, in ms or s, for example, **1000 ms** or **1s**. The default unit is ms. | | animation-delay | &lt;time&gt; | 0 | Delay for playing the animation, in ms or s, for example, **1000 ms** or **1s**. \|The default unit is ms.|
| animation-duration | &lt;time&gt; | 0 | Animation duration, in ms or s, for example, **1000 ms** or **1s**. The default unit is ms.<br>**NOTE**<br>**animation-duration** must be specified. Otherwise, the duration is **0**, which means the animation will not be played. | | animation-duration | &lt;time&gt; | 0 | Animation duration, in ms or s, for example, **1000 ms** or **1s**. \|The default unit is ms.<br>**NOTE**<br>**animation-duration** must be specified. Otherwise, the duration is **0**, which means the animation will not be played.|
| animation-iteration-count | number \| infinite | 1 | Number of times that an animation is played. The animation is played once by default. You can set the value to **infinite** to play the animation infinitely.| | animation-iteration-count | number \| infinite | 1 | Number of times that an animation is played. The animation is played once by default. You can set the value to **infinite** to play the animation infinitely. |
| animation-timing-function | string | <br>linear | Speed curve of an animation, which makes the animation more fluent.<br>- **linear**: The animation speed keeps unchanged.<br>- **ease-in**: The animation starts at a low speed. The cubic-bezier curve (0.42, 0.0, 1.0, 1.0) is used<br>- **ease-out**: The animation ends at a low speed. The cubic-bezier curve (0.0, 0.0, 0.58, 1.0) is used.<br>- **ease-in-out**: The animation starts and ends at a low speed. The cubic-bezier curve (0.42, 0.0, 0.58, 1.0) is used. | | animation-timing-function | string | <br>linear | Speed curve of an animation, which makes the animation more fluent.<br>Available values are as follows:<br>- **linear**: The animation speed keeps unchanged.<br>- **ease-in**: The animation starts at a low speed. The cubic-bezier curve (0.42, 0.0, 1.0, 1.0) is used<br>- **ease-out**: The animation ends at a low speed. The cubic-bezier curve (0.0, 0.0, 0.58, 1.0) is used.<br>- **ease-in-out**: The animation starts and ends at a low speed. The cubic-bezier curve (0.42, 0.0, 0.58, 1.0) is used.|
| animation-fill-mode | string | none | Start and end styles of the animation.<br>- **none**: No style is applied to the target before or after the animation is executed.<br>- **forwards**: The target keeps the state at the end of the animation (defined in the last key frame) after the animation is executed.| | animation-fill-mode | string | none | Start and end styles of the animation.<br>- **none**: No style is applied to the target before or after the animation is executed.<br>- **forwards**: The target keeps the state at the end of the animation (defined in the last key frame) after the animation is executed.|
**Table 1** transform **Table 1** transform
| Name| Type| Description| | Name | Type | Description |
| -------- | -------- | -------- | | ---------- | ------------------------------------ | ---------- |
| translateX | &lt;length&gt; | Moves an element along the x-axis.| | translateX | &lt;length&gt; | Moves an element along the x-axis.|
| translateY | &lt;length&gt; | Moves an element along the y-axis.| | translateY | &lt;length&gt; | Moves an element along the y-axis.|
| rotate | &lt;deg&gt; \| &lt;rad&gt; | Rotates an element.| | rotate | &lt;deg&gt; \| &lt;rad&gt; | Rotates an element. |
> **NOTE** > **NOTE**
> >
> Only images of the original size can be rotated on lite wearables. > Only images of the original size can be rotated on lite wearables.
**Table 2** @keyframes **Table 2** \@keyframes
| Name| Type| Default Value| Description| | Name | Type | Default Value | Description |
| -------- | -------- | -------- | -------- | | ---------------- | -------------- | ---- | ------------------ |
| background-color | &lt;color&gt; | - | Background color applied to the component after the animation is played.| | background-color | &lt;color&gt; | - | Background color applied to the component after the animation is played. |
| width | &lt;length&gt; | - | Width value applied to the component after the animation is played.| | width | &lt;length&gt; | - | Width value applied to the component after the animation is played. |
| height | &lt;length&gt; | - | Height value applied to the component after the animation is played.| | height | &lt;length&gt; | - | Height value applied to the component after the animation is played. |
| transform | string | - | Transformation type applied to a component. For details, see Table 1.| | transform | string | - | Transformation type applied to a component. For details, see Table 1.|
If there is no default value for when an animation will start or end, use **from** and **to** to specify the start and end of the display. The following is an example: If there is no default value for when an animation will start or end, use **from** and **to** to specify the start and end of the display. The following is an example:
``` ```css
@keyframes Go @keyframes Go
{ {
from { from {
......
...@@ -50,7 +50,7 @@ Application resources can be accessed via an absolute or relative path. In this ...@@ -50,7 +50,7 @@ Application resources can be accessed via an absolute or relative path. In this
> >
> - If code files A and B are in the same directory, you can use either a relative or absolute path in code file B to reference resource files. > - If code files A and B are in the same directory, you can use either a relative or absolute path in code file B to reference resource files.
> >
> - If code files A and B are in different directories, you must use an absolute path in code file B to reference resource files. The reason is that the directory of code file B changes during Webpack packaging. > - If code files A and B are in different directories, you must use an absolute path in code file B to reference resource files, because the directory of code file B changes during Webpack packaging.
> >
......
...@@ -55,7 +55,6 @@ ...@@ -55,7 +55,6 @@
- [Network Connection Management Error Codes](errorcode-net-connection.md) - [Network Connection Management Error Codes](errorcode-net-connection.md)
- [Ethernet Connection Error Codes](errorcode-net-ethernet.md) - [Ethernet Connection Error Codes](errorcode-net-ethernet.md)
- [Network Sharing Error Codes](errorcode-net-sharing.md) - [Network Sharing Error Codes](errorcode-net-sharing.md)
- [Policy Management Error Codes](errorcode-net-policy.md)
- [mDNS Error Codes](errorcode-net-mdns.md) - [mDNS Error Codes](errorcode-net-mdns.md)
- Connectivity - Connectivity
- [Bluetooth Error Codes](errorcode-bluetoothManager.md) - [Bluetooth Error Codes](errorcode-bluetoothManager.md)
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册