未验证 提交 0d883ed1 编写于 作者: O openharmony_ci 提交者: Gitee

!18984 翻译已完成18588+18597+18642+18656+18665+18668+18662+18716+18731+18738+18667+18661

Merge pull request !18984 from shawn_he/18588-d
......@@ -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 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 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.|
......@@ -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 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 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 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.|
......
......@@ -5,7 +5,6 @@ Network management functions include:
- [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.
- [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.
- [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.
......
# USB Service Development
## 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.
## 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 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. |
| 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. |
| connectDevice(device: USBDevice): Readonly\<USBDevicePipe> | Connects to the USB device based on the device list returned by `getDevices()`. |
| 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. |
| setConfiguration(pipe: USBDevicePipe, config: USBConfiguration): number | Sets the USB device configuration. |
| setInterface(pipe: USBDevicePipe, iface: USBInterface): number | Sets a USB interface. |
| claimInterface(pipe: USBDevicePipe, iface: USBInterface, force ?: boolean): number | Claims a USB interface. |
| bulkTransfer(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, timeout ?: number): Promise\<number> | Performs bulk transfer. |
| closePipe(pipe: USBDevicePipe): number | Closes a USB device pipe. |
| releaseInterface(pipe: USBDevicePipe, iface: USBInterface): number | Releases a USB interface. |
| getFileDescriptor(pipe: USBDevicePipe): number | Obtains the file descriptor. |
| getRawDescriptor(pipe: USBDevicePipe): Uint8Array | Obtains the raw USB descriptor. |
| controlTransfer(pipe: USBDevicePipe, controlparam: USBControlParams, timeout ?: number): Promise&lt;number&gt; | Performs control transfer. |
| hasRight(deviceName: string): boolean | Checks whether the user has the device access permissions.|
| requestRight(deviceName: string): Promise&lt;boolean&gt; | Requests the device access permissions for the application. This API uses a promise to return the result. |
| removeRight(deviceName: string): boolean | Revokes the device access permissions of the application.|
| connectDevice(device: USBDevice): Readonly&lt;USBDevicePipe&gt; | Connects to the USB device based on the device information returned by `getDevices()`. |
| 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. |
| setConfiguration(pipe: USBDevicePipe, config: USBConfiguration): number | Sets the USB device configuration. |
| setInterface(pipe: USBDevicePipe, iface: USBInterface): number | Sets a USB interface. |
| claimInterface(pipe: USBDevicePipe, iface: USBInterface, force ?: boolean): number | Claims a USB interface. |
| bulkTransfer(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, timeout ?: number): Promise&lt;number&gt; | Performs bulk transfer. |
| closePipe(pipe: USBDevicePipe): number | Closes a USB device pipe. |
| releaseInterface(pipe: USBDevicePipe, iface: USBInterface): number | Releases a USB interface. |
| getFileDescriptor(pipe: USBDevicePipe): number | Obtains the file descriptor. |
| 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
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:
1. Obtain the USB device list.
```js
// Import the USB API package.
import usb from '@ohos.usbManager';
// Obtain the USB device list.
let deviceList = usb.getDevices();
/*
Example deviceList structure
[
{
name: "1-1",
serial: "",
manufacturerName: "",
productName: "",
version: "",
vendorId: 7531,
productId: 2,
clazz: 9,
subClass: 0,
protocol: 1,
devAddress: 1,
busNum: 1,
configs: [
{
id: 1,
attributes: 224,
isRemoteWakeup: true,
isSelfPowered: true,
maxPower: 0,
name: "1-1",
interfaces: [
{
id: 0,
protocol: 0,
clazz: 9,
subClass: 0,
alternateSetting: 0,
name: "1-1",
endpoints: [
{
address: 129,
attributes: 3,
interval: 12,
maxPacketSize: 4,
direction: 128,
number: 1,
type: 3,
interfaceId: 0,
}
]
}
]
}
]
}
]
*/
```
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.
```js
// Import the USB API package.
import usb from '@ohos.usbManager';
// Obtain the USB device list.
let deviceList = usb.getDevices();
/*
Example deviceList structure:
[
{
name: "1-1",
serial: "",
manufacturerName: "",
productName: "",
version: "",
vendorId: 7531,
productId: 2,
clazz: 9,
subClass: 0,
protocol: 1,
devAddress: 1,
busNum: 1,
configs: [
{
id: 1,
attributes: 224,
isRemoteWakeup: true,
isSelfPowered: true,
maxPower: 0,
name: "1-1",
interfaces: [
{
id: 0,
protocol: 0,
clazz: 9,
subClass: 0,
alternateSetting: 0,
name: "1-1",
endpoints: [
{
address: 129,
attributes: 3,
interval: 12,
maxPacketSize: 4,
direction: 128,
number: 1,
type: 3,
interfaceId: 0,
}
]
}
]
}
]
}
]
*/
```
2. Obtain the device operation permissions.
```js
let deviceName = deviceList[0].name;
// Request the permissions to operate a specified device.
usb.requestRight(deviceName).then(hasRight => {
console.info("usb device request right result: " + hasRight);
}).catch(error => {
console.info("usb device request right failed : " + error);
});
```
```js
let deviceName = deviceList[0].name;
// Request the permissions to operate a specified device.
usb.requestRight(deviceName).then(hasRight => {
console.info("usb device request right result: " + hasRight);
}).catch(error => {
console.info("usb device request right failed : " + error);
});
```
3. Open the device.
```js
// Open the device, and obtain the USB device pipe for data transfer.
let interface1 = deviceList[0].configs[0].interfaces[0];
/*
Claim the corresponding interface from deviceList.
interface1 must be one present in the device configuration.
*/
usb.claimInterface(pipe, interface1, true);
```
```js
// Open the device, and obtain the USB device pipe for data transfer.
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.
*/
usb.claimInterface(pipe, interface1, true);
```
4. Perform data transfer.
```js
/*
```js
/*
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.
*/
let inEndpoint = interface1.endpoints[2];
let outEndpoint = interface1.endpoints[1];
let dataUint8Array = new Uint8Array(1024);
usb.bulkTransfer(pipe, inEndpoint, dataUint8Array, 15000).then(dataLength => {
if (dataLength >= 0) {
console.info("usb readData result Length : " + dataLength);
} else {
console.info("usb readData failed : " + dataLength);
}
}).catch(error => {
console.info("usb readData error : " + JSON.stringify(error));
});
// Send data. Select the corresponding TX endpoint from deviceList for data transfer. (endpoint.direction == 0)
usb.bulkTransfer(pipe, outEndpoint, dataUint8Array, 15000).then(dataLength => {
if (dataLength >= 0) {
console.info("usb writeData result write length : " + dataLength);
} else {
console.info("writeData failed");
}
}).catch(error => {
console.info("usb writeData error : " + JSON.stringify(error));
});
```
5. Release the USB interface, and close the USB device.
```js
usb.releaseInterface(pipe, interface);
usb.closePipe(pipe);
```
\ No newline at end of file
(endpoint.direction == 0x80); dataUint8Array indicates the data to read. The data type is Uint8Array.
*/
let inEndpoint = interface1.endpoints[2];
let outEndpoint = interface1.endpoints[1];
let dataUint8Array = new Uint8Array(1024);
usb.bulkTransfer(pipe, inEndpoint, dataUint8Array, 15000).then(dataLength => {
if (dataLength >= 0) {
console.info("usb readData result Length : " + dataLength);
} else {
console.info("usb readData failed : " + dataLength);
}
}).catch(error => {
console.info("usb readData error : " + JSON.stringify(error));
});
// Send data. Select the corresponding TX endpoint from deviceList for data transfer. (endpoint.direction == 0)
usb.bulkTransfer(pipe, outEndpoint, dataUint8Array, 15000).then(dataLength => {
if (dataLength >= 0) {
console.info("usb writeData result write length : " + dataLength);
} else {
console.info("writeData failed");
}
}).catch(error => {
console.info("usb writeData error : " + JSON.stringify(error));
});
```
5. Release the USB interface, and close the USB device.
```js
usb.releaseInterface(pipe, interface1);
usb.closePipe(pipe);
```
\ No newline at end of file
......@@ -111,7 +111,7 @@ The [i18n](../reference/apis/js-apis-i18n.md) module provides enhanced I18N capa
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
let options = {dateStyle: "full", timeStyle: "full"};
......@@ -181,7 +181,7 @@ The [i18n](../reference/apis/js-apis-i18n.md) module provides enhanced I18N capa
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
let options = {compactDisplay: "short", notation: "compact"};
......@@ -240,7 +240,7 @@ Users in different regions have different requirements for string sorting. [Coll
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'.
```js
......@@ -301,7 +301,7 @@ According to grammars in certain languages, the singular or plural form of a nou
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
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
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
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
```js
let relativeTimeFormat = new Intl.RelativeTimeFormat("zh-CN", {numeric: "always", style: "long"});
let options = relativeTimeFormat.resolvedOptions(); // options = {"locale": "zh-CN", "style": "long", "numeric": "always", "numberingSystem": "latn"}
```
```
\ No newline at end of file
......@@ -325,7 +325,7 @@
- [@ohos.systemTimer (System Timer)](js-apis-system-timer.md)
- [@ohos.wallpaper (Wallpaper)](js-apis-wallpaper.md)
- [@ohos.web.webview (Webview)](js-apis-webview.md)
- [console (Log)](js-apis-logs.md)
- [Console](js-apis-logs.md)
- [Timer](js-apis-timer.md)
- application
- [AccessibilityExtensionContext (Accessibility Extension Context)](js-apis-inner-application-accessibilityExtensionContext.md)
......
# @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.
> **NOTE**
......@@ -68,7 +67,7 @@ Creates a **Locale** object.
| 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).|
| options<sup>9+</sup> | [LocaleOptions](#localeoptions9) | No | Options for creating the **Locale** object. |
| options | [LocaleOptions](#localeoptions6) | No | Options for creating the **Locale** object. |
**Example**
```js
......@@ -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.
In API version 9, the attributes in **LocaleOptions** are optional.
**System capability**: SystemCapability.Global.I18n
......@@ -207,7 +207,7 @@ Creates a **DateTimeOptions** object for the specified locale.
| Name | Type | Mandatory | Description |
| -------------------- | ------------------------------------ | ---- | ---------------------------- |
| 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**
```js
......@@ -299,7 +299,7 @@ Obtains the formatting options for **DateTimeFormat** object.
| Type | Description |
| ------------------------------------ | ----------------------------- |
| [DateTimeOptions](#datetimeoptions9) | Formatting options for **DateTimeFormat** objects.|
| [DateTimeOptions](#datetimeoptions6) | Formatting options for **DateTimeFormat** objects.|
**Example**
```js
......@@ -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.
In API version 9, the attributes in **DateTimeOptions** are optional.
**System capability**: SystemCapability.Global.I18n
......@@ -371,7 +372,7 @@ Creates a **NumberFormat** object for the specified locale.
| Name | Type | Mandatory | Description |
| -------------------- | -------------------------------- | ---- | ---------------------------- |
| 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**
```js
......@@ -421,7 +422,7 @@ Obtains the options of the **NumberFormat** object.
| Type | Description |
| -------------------------------- | --------------------------- |
| [NumberOptions](#numberoptions9) | Formatting options for **NumberFormat** objects.|
| [NumberOptions](#numberoptions6) | Formatting options for **NumberFormat** objects.|
**Example**
......@@ -434,9 +435,10 @@ Obtains the options of the **NumberFormat** object.
```
## NumberOptions<sup>9+</sup>
## NumberOptions<sup>6+</sup>
Defines the device capability.
In API version 9, the attributes in **NumberOptions** are optional.
**System capability**: SystemCapability.Global.I18n
......@@ -448,7 +450,7 @@ Defines the device capability.
| 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**. |
| 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**.|
| 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**.|
......@@ -494,7 +496,7 @@ Creates a **Collator** object.
| Name | Type | Mandatory | Description |
| -------------------- | ------------------------------------ | ---- | ---------------------------- |
| 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**
```js
......@@ -545,7 +547,7 @@ Returns properties reflecting the locale and collation options of a **Collator**
| Type | Description |
| ------------------------------------ | ----------------- |
| [CollatorOptions](#collatoroptions9) | Properties of the **Collator** object.|
| [CollatorOptions](#collatoroptions8) | Properties of the **Collator** object.|
**Example**
```js
......@@ -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.
In API version 9, the attributes in **CollatorOptions** are optional.
**System capability**: SystemCapability.Global.I18n
......@@ -605,7 +608,7 @@ Creates a **PluralRules** object to obtain the singular-plural type of numbers.
| Name | Type | Mandatory | Description |
| -------------------- | ---------------------------------------- | ---- | ---------------------------- |
| 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**
```js
......@@ -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.
In API version 9, the attributes in **PluralRulesOptions** are optional.
**System capability**: SystemCapability.Global.I18n
......@@ -696,7 +700,7 @@ Creates a **RelativeTimeFormat** object.
| Name | Type | Mandatory | Description |
| -------------------- | ---------------------------------------- | ---- | ---------------------------- |
| 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**
```js
......@@ -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.
In API version 9, the attributes in **RelativeTimeFormatInputOptions** are optional.
**System capability**: SystemCapability.Global.I18n
......
# console (Log Printing)
# Console
The **console** module provides basic log printing capabilities and supports log printing by log level.
......
......@@ -55,8 +55,7 @@ ethernet.setIfaceConfig("eth0", {
route: "192.168.xx.xxx",
gateway: "192.168.xx.xxx",
netMask: "255.255.255.0",
dnsServers: "1.1.1.1",
domain: "2.2.2.2"
dnsServers: "1.1.1.1"
}, (error) => {
if (error) {
console.log("setIfaceConfig callback error = " + JSON.stringify(error));
......@@ -115,8 +114,7 @@ ethernet.setIfaceConfig("eth0", {
route: "192.168.xx.xxx",
gateway: "192.168.xx.xxx",
netMask: "255.255.255.0",
dnsServers: "1.1.1.1",
domain: "2.2.2.2"
dnsServers: "1.1.1.1"
}).then(() => {
console.log("setIfaceConfig promise ok ");
}).catch(error => {
......@@ -168,7 +166,6 @@ ethernet.getIfaceConfig("eth0", (error, value) => {
console.log("getIfaceConfig callback gateway = " + JSON.stringify(value.gateway));
console.log("getIfaceConfig callback netMask = " + JSON.stringify(value.netMask));
console.log("getIfaceConfig callback dnsServers = " + JSON.stringify(value.dnsServers));
console.log("getIfaceConfig callback domain = " + JSON.stringify(value.domain));
}
});
```
......@@ -219,7 +216,6 @@ ethernet.getIfaceConfig("eth0").then((data) => {
console.log("getIfaceConfig promise gateway = " + JSON.stringify(data.gateway));
console.log("getIfaceConfig promise netMask = " + JSON.stringify(data.netMask));
console.log("getIfaceConfig promise dnsServers = " + JSON.stringify(data.dnsServers));
console.log("getIfaceConfig promise domain = " + JSON.stringify(data.domain));
}).catch(error => {
console.log("getIfaceConfig promise error = " + JSON.stringify(error));
});
......
......@@ -16,47 +16,15 @@ import fetch from '@system.fetch';
## fetch.fetch<sup>3+</sup>
fetch(options:{
/**
* Resource URL.
* @since 3
*/
url: string;
/**
* Request parameter, which can be of the string type or a JSON object.
* @since 3
*/
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;
fetch(options:{ <br>
&nbsp;&nbsp;url: string;<br>
&nbsp;&nbsp;data?: string | object;<br>
&nbsp;&nbsp;header?: Object;<br>
&nbsp;&nbsp;method?: string;<br>
&nbsp;&nbsp;responseType?: string;<br>
&nbsp;&nbsp;success?: (data: FetchResponse) => void;<br>
&nbsp;&nbsp;fail?: (data: any, code: number) => void;<br>
&nbsp;&nbsp;complete?: () => void;<br>
} ): void
Obtains data through a network.
......
# @system.network (Network State)
> **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.
......@@ -23,23 +21,11 @@ ohos.permission.GET_NETWORK_INFO
## network.getType<sup>3+</sup>
getType(options?: {
/**
* Called when the network type is obtained.
* @since 3
*/
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
getType(options?: {<br>
&nbsp;&nbsp;success?: (data: NetworkResponse) => void;<br>
&nbsp;&nbsp;fail?: (data: any, code: number) => void;<br>
&nbsp;&nbsp;complete?: () => void;<br>
}): void
Obtains the network type.
......@@ -79,17 +65,9 @@ export default {
## network.subscribe<sup>3+</sup>
subscribe(options?:{
/**
* Called when the network connection state changes.
* @since 3
*/
success?: (data: NetworkResponse) => void;
/**
* Called when the listening fails.
* @since 3
*/
fail?: (data: any, code: number) => void;
subscribe(options?:{<br>
&nbsp;&nbsp;success?: (data: NetworkResponse) => void;<br>
&nbsp;&nbsp;fail?: (data: any, code: number) => void;<br>
}): void
Listens to the network connection state. If this method is called multiple times, the last call takes effect.
......
# Screen Hopping Error Codes
# Screen Hopping Error Codes (To Be Deprecated)
> **NOTE**
>
......
......@@ -6,7 +6,7 @@ By default, an application can run for a period of 6 to 12 seconds after it swit
You are advised not to call the [requestSuspendDelay()](../reference/apis/js-apis-resourceschedule-backgroundTaskManager.md#backgroundtaskmanagerrequestsuspenddelay) method to apply for delayed suspension after the application is running in the background. Instead, you need to call this interface to declare the execution time of the extended application to the system before performing any time-consuming operation. It is recommended that an application calls [requestSuspendDelay()](../reference/apis/js-apis-resourceschedule-backgroundTaskManager.md#backgroundtaskmanagerrequestsuspenddelay) when it is running in the foreground, so as not to affect the transient task quota of the application.
An application can obtain the remaining duration before being suspended by calling [getRemainingDelayTime()](../reference/apis/js-apis-resourceschedule-backgroundTaskManager.md#backgroundtaskmanagergetremainingdelaytimecallback). Each application has a daily time quota for transient tasks. Therefore, after the time-consuming task finishes execution, the application should call [cancelSuspendDelay()](../reference/apis/js-apis-resourceschedule-backgroundTaskManager.md#backgroundtaskmanagercancelsuspenddelay) to cancel the transient task in a timely manner.
An application can obtain the remaining duration before being suspended by calling [getRemainingDelayTime()](../reference/apis/js-apis-resourceschedule-backgroundTaskManager.md#backgroundtaskmanagergetremainingdelaytime). Each application has a daily time quota for transient tasks. Therefore, after the time-consuming task finishes execution, the application should call [cancelSuspendDelay()](../reference/apis/js-apis-resourceschedule-backgroundTaskManager.md#backgroundtaskmanagercancelsuspenddelay) to cancel the transient task in a timely manner.
Typical time-consuming tasks include saving status data to the local database, opening and processing a large file, and synchronizing data to the cloud server.
......
......@@ -31,11 +31,11 @@ The Short Messaging Service (SMS) module provides basic SMS management functions
| Name | Description |
| ------------------------------------------------------------ | ------------------------------------------------------- |
| createMessage(pdu: Array<number>, specification: string, callback: AsyncCallback<ShortMessage>): void | Creates an SMS message instance based on the PDU and the specified SMS protocol.|
| createMessage(pdu: Array<number>, specification: string, callback: AsyncCallback\<ShortMessage>): void | Creates an SMS message instance based on the PDU and the specified SMS protocol.|
| sendMessage(options: SendMessageOptions): void | Sends text or data SMS messages. |
| getDefaultSmsSlotId(callback: AsyncCallback<number>): void | Obtains the ID of the default SIM card used to send SMS messages. |
| setSmscAddr(slotId: number, smscAddr: string, callback: AsyncCallback<void>): void | Sets the SMSC address based on the specified slot ID. |
| getSmscAddr(slotId: number, callback: AsyncCallback<string>): void | Obtains the SMSC address based on the specified slot ID. |
| getDefaultSmsSlotId(callback: AsyncCallback\<number>): void | Obtains the ID of the default SIM card used to send SMS messages. |
| setSmscAddr(slotId: number, smscAddr: string, callback: AsyncCallback\<void>): void | Sets the SMSC address based on the specified slot ID. |
| getSmscAddr(slotId: number, callback: AsyncCallback\<string>): void | Obtains the SMSC address based on the specified slot ID. |
## How to Develop
......
......@@ -1289,7 +1289,7 @@
- [@ohos.systemTimer (System Timer)](reference/apis/js-apis-system-timer.md)
- [@ohos.wallpaper (Wallpaper)](reference/apis/js-apis-wallpaper.md)
- [@ohos.web.webview (Webview)](reference/apis/js-apis-webview.md)
- [console (Log)](reference/apis/js-apis-logs.md)
- [Console](reference/apis/js-apis-logs.md)
- [Timer](reference/apis/js-apis-timer.md)
- application
- [AccessibilityExtensionContext](reference/apis/js-apis-inner-application-accessibilityExtensionContext.md)
......
......@@ -23,7 +23,7 @@ Figure 1 Overview of system parameter operation primitives
| get | Obtains the value of a system parameter. |
| set | Sets the value of a system parameter. |
| wait | Waits for value change of a system parameter synchronously.|
| watch | Observes value change of a system parameter asynchronously.|
| watch | Watches for the value change of a system parameter asynchronously.|
#### Parameter Definition
......@@ -227,7 +227,7 @@ The parameter management subsystem allows you to manage system parameters by run
| param get [**key**] | Obtains the system parameter value of the specified key. If no key name is specified, all system parameter values will be returned.|
| param set **key value** | Sets the specified value for the specified key.|
| param wait **key** **value** | Waits for the system parameter value of the specified key to match the specified value. Fuzzy match is supported. For example, * indicates any value, and <strong>val</strong>* indicates matching of only the first three val characters.|
| param watch | Observes value change of a system parameter asynchronously.|
| param watch | Watches for the value change of a system parameter asynchronously.|
- syspara API mode
......@@ -244,7 +244,7 @@ The parameter management subsystem allows you to manage system parameters by run
| const&nbsp;char\*&nbsp;GetBrand(void) | Obtains the device's brand name.|
| const&nbsp;char\*&nbsp;GetMarketName(void) | Obtains the device's marketing name.|
| const&nbsp;char\*&nbsp;GetProductSeries(void) | Obtains the device's product series name.|
| const&nbsp;char\*&nbsp;GetProductModel(void) | Obtains the device's authentication model.|
| const&nbsp;char\*&nbsp;GetProductModel(void) | Obtains the device's product model.|
| const&nbsp;char\*&nbsp;GetSoftwareModel(void) | Obtains the device's software model.|
| const&nbsp;char\*&nbsp;GetHardwareModel(void) | Obtains the device's hardware model.|
| const&nbsp;char\*&nbsp;GetHardwareProfile(void) | Obtains the device's hardware profile.|
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册