未验证 提交 5768ff82 编写于 作者: O openharmony_ci 提交者: Gitee

!22885 翻译已完成21857+21753+21895+21984+22009+22026+22089+21777+21969+22266+22361+22381+22456+22540

Merge pull request !22885 from shawn_he/21878-d
# HTTP Data Request
## When to Use
## Overview
An application can initiate a data request over HTTP. Common HTTP methods include **GET**, **POST**, **OPTIONS**, **HEAD**, **PUT**, **DELETE**, **TRACE**, and **CONNECT**.
......@@ -18,7 +18,7 @@ The following table provides only a simple description of the related APIs. For
| ----------------------------------------- | ----------------------------------- |
| createHttp() | Creates an HTTP request. |
| request() | Initiates an HTTP request to a given URL. |
| request2()<sup>10+</sup> | Initiates an HTTP network request based on the URL and returns a streaming response.|
| requestInStream()<sup>10+</sup> | Initiates an HTTP network request to a given URL and returns a streaming response.|
| destroy() | Destroys an HTTP request. |
| on(type: 'headersReceive') | Registers an observer for HTTP Response Header events. |
| off(type: 'headersReceive') | Unregisters the observer for HTTP Response Header events.|
......@@ -27,8 +27,8 @@ The following table provides only a simple description of the related APIs. For
| off\('dataReceive'\)<sup>10+</sup> | Unregisters the observer for events indicating receiving of HTTP streaming responses. |
| on\('dataEnd'\)<sup>10+</sup> | Registers an observer for events indicating completion of receiving HTTP streaming responses. |
| off\('dataEnd'\)<sup>10+</sup> | Unregisters the observer for events indicating completion of receiving HTTP streaming responses.|
| on\('dataProgress'\)<sup>10+</sup> | Registers an observer for events indicating progress of receiving HTTP streaming responses. |
| off\('dataProgress'\)<sup>10+</sup> | Unregisters the observer for events indicating progress of receiving HTTP streaming responses.|
| on\('dataReceiveProgress'\)<sup>10+</sup> | Registers an observer for events indicating progress of receiving HTTP streaming responses. |
| off\('dataReceiveProgress'\)<sup>10+</sup> | Unregisters the observer for events indicating progress of receiving HTTP streaming responses.|
## How to Develop request APIs
......@@ -53,6 +53,7 @@ httpRequest.on('headersReceive', (header) => {
});
httpRequest.request(
// Customize EXAMPLE_URL in extraData on your own. It is up to you whether to add parameters to the URL.
"EXAMPLE_URL",
{
method: http.RequestMethod.POST, // Optional. The default value is http.RequestMethod.GET.
// You can add header fields based on service requirements.
......@@ -81,7 +82,7 @@ httpRequest.request(
// Call the destroy() method to release resources after HttpRequest is complete.
httpRequest.destroy();
} else {
console.info('error:' + JSON.stringify(err));
console.error('error:' + JSON.stringify(err));
// Unsubscribe from HTTP Response Header events.
httpRequest.off('headersReceive');
// Call the destroy() method to release resources after HttpRequest is complete.
......@@ -91,12 +92,12 @@ httpRequest.request(
);
```
## How to Develop request2 APIs
## How to Develop requestInStream APIs
1. Import the **http** namespace from **@ohos.net.http.d.ts**.
2. Call **createHttp()** to create an **HttpRequest** object.
3. Depending on your need, call **on()** of the **HttpRequest** object to subscribe to HTTP response header events as well as events indicating receiving of HTTP streaming responses, progress of receiving HTTP streaming responses, and completion of receiving HTTP streaming responses.
4. Call **request2()** to initiate a network request. You need to pass in the URL and optional parameters of the HTTP request.
4. Call **requestInStream()** to initiate a network request. You need to pass in the URL and optional parameters of the HTTP request.
5. Parse the returned response code as needed.
6. Call **off()** of the **HttpRequest** object to unsubscribe from the related events.
7. Call **httpRequest.destroy()** to release resources after the request is processed.
......@@ -122,11 +123,11 @@ httpRequest.on('dataEnd', () => {
console.info('No more data in response, data receive end');
});
// Subscribe to events indicating progress of receiving HTTP streaming responses.
httpRequest.on('dataProgress', (data) => {
console.log("dataProgress receiveSize:" + data.receiveSize + ", totalSize:" + data.totalSize);
httpRequest.on('dataReceiveProgress', (data) => {
console.log("dataReceiveProgress receiveSize:" + data.receiveSize + ", totalSize:" + data.totalSize);
});
httpRequest.request2(
httpRequest.requestInStream(
// Customize EXAMPLE_URL in extraData on your own. It is up to you whether to add parameters to the URL.
"EXAMPLE_URL",
{
......@@ -146,14 +147,14 @@ httpRequest.request2(
readTimeout: 60000, // Optional. The default value is 60000, in ms. If a large amount of data needs to be transmitted, you are advised to set this parameter to a larger value to ensure normal data transmission.
usingProtocol: http.HttpProtocol.HTTP1_1, // Optional. The default protocol type is automatically specified by the system.
}, (err, data) => {
console.info('error:' + JSON.stringify(err));
console.error('error:' + JSON.stringify(err));
console.info('ResponseCode :' + JSON.stringify(data));
// Unsubscribe from HTTP Response Header events.
httpRequest.off('headersReceive');
// Unregister the observer for events indicating receiving of HTTP streaming responses.
httpRequest.off('dataReceive');
// Unregister the observer for events indicating progress of receiving HTTP streaming responses.
httpRequest.off('dataProgress');
httpRequest.off('dataReceiveProgress');
// Unregister the observer for events indicating completion of receiving HTTP streaming responses.
httpRequest.off('dataEnd');
// Call the destroy() method to release resources after HttpRequest is complete.
......@@ -161,10 +162,3 @@ httpRequest.request2(
}
);
```
## Samples
The following sample is provided to help you better understand how to develop the HTTP data request feature:
- [`Http`: Data Request (ArkTS) (API9)](https://gitee.com/openharmony/applications_app_samples/tree/master/code/BasicFeature/Connectivity/Http)
- [HTTP Communication (ArkTS) (API9)](https://gitee.com/openharmony/codelabs/tree/master/NetworkManagement/SmartChatEtsOH)
# IPC & RPC Development Guidelines
## When to Use
## Overview
IPC/RPC enables a proxy and a stub that run on different processes to communicate with each other, regardless of whether they run on the same or different devices.
......
# Network Connection Management
## Introduction
## Overview
The Network Connection Management module 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.
> **NOTE**
>
> To maximize the application running efficiency, most API calls are called asynchronously in callback or promise mode. The following code examples use the callback mode. For details about the APIs, see [sms API Reference](../reference/apis/js-apis-net-connection.md).
## Basic Concepts
......
# Ethernet Connection
## Introduction
## Overview
The Ethernet Connection module allows a device to access the Internet through a network cable. After a device is connected to the Ethernet through a network cable, the device can obtain a series of network attributes, such as the dynamically allocated IP address, subnet mask, gateway, and DNS. You can manually configure and obtain the network attributes of the device in static mode.
> **NOTE**
>
> To maximize the application running efficiency, most API calls are called asynchronously in callback or promise mode. The following code examples use the callback mode. For details about the APIs, see [sms API Reference](../reference/apis/js-apis-net-ethernet.md).
## **Constraints**
......
# MDNS Management
## Introduction
## Overview
Multicast DNS (mDNS) provides functions such as adding, removing, discovering, and resolving local services on a LAN.
- Local service: a service provider on a LAN, for example, a printer or scanner.
......
# Network Sharing
## Introduction
## Overview
The Network Sharing module allows you to share your device's Internet connection with other connected devices by means of Wi-Fi hotspot, Bluetooth, and USB sharing. It also allows you to query the network sharing state and shared mobile data volume.
> **NOTE**
>
> To maximize the application running efficiency, most API calls are called asynchronously in callback or promise mode. The following code examples use the callback mode. For details about the APIs, see [sms API Reference](../reference/apis/js-apis-net-sharing.md).
## Basic Concepts
......
# Traffic Management
## Introduction
## Overview
The traffic management module allows you to query real-time or historical data traffic by the specified network interface card (NIC) or user ID (UID).
......@@ -11,6 +11,7 @@ Its functions include:
- Subscribing to traffic change events by NIC or UID
> **NOTE**
>
> To maximize the application running efficiency, most API calls are called asynchronously in callback or promise mode. The following code examples use the callback mode. For details about the APIs, see [Traffic Management](../reference/apis/js-apis-net-statistics.md).
The following describes the development procedure specific to each application scenario.
......
......@@ -5,6 +5,7 @@
A virtual private network (VPN) is a dedicated network established on a public network. On a VPN, the connection between any two nodes does not have an end-to-end physical link required by the traditional private network. Instead, user data is transmitted over a logical link because a VPN is a logical network deployed over the network platform (such as the Internet) provided by the public network service provider.
> **NOTE**
>
> To maximize the application running efficiency, most API calls are called asynchronously in callback or promise mode. The following code examples use the callback mode. For details about the APIs, see [Traffic Management](../reference/apis/js-apis-net-vpn.md).
The following describes the development procedure specific to each application scenario.
......
# Socket Connection
## Introduction
## Overview
The Socket Connection module allows an application to transmit data over a socket connection through the TCP, UDP, or TLS protocol.
......
# Subscribing to State Changes of a Remote Object
## Overview
IPC/RPC allows you to subscribe to the state changes of a remote stub object. When the remote stub object dies, a death notification will be sent to your local proxy object. Such subscription and unsubscription are controlled by APIs. To be specific, you need to implement the **DeathRecipient** interface and the **onRemoteDied** API to clear resources. This callback is invoked when the process accommodating the remote stub object dies, or the device accommodating the remote stub object leaves the network. It is worth noting that these APIs should be called in the following order: The proxy object must first subscribe to death notifications of the stub object. If the stub object is in the normal state, the proxy object can cancel the subscription as required. If the process of the stub object exits or the device hosting the stub object goes offline, subsequent operations customized by the proxy object will be automatically triggered.
## When to Use
......
# WebSocket Connection
## When to Use
## Overview
You can use WebSocket to establish a bidirectional connection between a server and a client. Before doing this, you need to use the **createWebSocket()** API to create a **WebSocket** object and then use the **connect()** API to connect to the server. If the connection is successful, the client will receive a callback of the **open** event. Then, the client can communicate with the server using the **send()** API. When the server sends a message to the client, the client will receive a callback of the **message** event. If the client no longer needs this connection, it can call the **close()** API to disconnect from the server. Then, the client will receive a callback of the **close** event.
......
# DFX
- [Development of Application Event Logging](hiappevent-guidelines.md)
- [Development of Performance Tracing](hitracemeter-guidelines.md)
- [Development of Distributed Call Chain Tracing](hitracechain-guidelines.md)
- [HiLog Development (Native)](hilog-guidelines.md)
- Performance Tracing
......
# Application Freeze (appfreeze) Log Analysis
## Introduction
## Overview
Application freeze (appfreeze) means that an application does not respond to user operations (for example, clicking) within a given period of time. OpenHarmony provides a mechanism for detecting appfreeze faults and generates appfreeze logs for fault analysis.
......
# Application Recovery Development
## When to Use
## Overview
During application running, some unexpected behaviors are inevitable. For example, unprocessed exceptions and errors are thrown, and the call or running constraints of the recovery framework are violated.
......
# Process Crash (cppcrash) Log Analysis
## Introduction
## Overview
A process crash refers to a C/C++ runtime crash. The FaultLogger module of OpenHarmony provides capabilities such as process crash detection, log collection, log storage, and log reporting, helping you to locate faults more effectively.
......
# Development of Error Manager
## When to Use
## Overview
If coding specification issues or errors exist in the code of an application, the application may encounter unexpected errors, for example, uncaught exceptions or application lifecycle timeouts, while it is running. In such a case, the application may exit unexpectedly. Error logs, however, are usually stored on users' local storage, making it inconvenient to locate faults. With the APIs provided by the **errorManager** module, your application will be able to report related errors and logs to your service platform for fault locating before it exits.
......
# Development of Application Event Logging
## Introduction
## Overview
A traditional log system aggregates log information generated by all applications running on the entire device, making it difficult to identify key information in the log. Therefore, an effective logging mechanism is needed to evaluate mission-critical information, for example, number of visits, number of daily active users, user operation habits, and key factors that affect application usage.
......
# HiLog Development (Native)
## Introduction
## Overview
HiLog is the log system of OpenHarmony that provides logging for the system framework, services, and applications to record information on user operations and system running status.
......
# Development of Distributed Call Chain Tracing
## Introduction
## Overview
The hiTraceChain module provides APIs to implement call chain tracing throughout a service process. This can help you quickly obtain the run log for the call chain of a specified service process and locate faults in inter-device, inter-process, or inter-thread communications.
......
# Development of Performance Tracing (ArkTS)
## Introduction
## Overview
hiTraceMeter provides APIs for system performance tracing. You can call the APIs provided by the hiTraceMeter module in your own service logic to effectively track service processes and check the system performance.
......@@ -21,7 +21,7 @@ hiTraceMeter provides APIs for system performance tracing. You can call the APIs
## Available APIs
The performance tracing APIs are provided by the **hiTraceMeter** module. For details, see [API Reference](../reference/apis/js-apis-hitracemeter.md).
The performance tracing APIs are provided by the **hiTraceMeter** module. For details, see [API Reference]( ../reference/apis/js-apis-hitracemeter.md).
**APIs for performance tracing**
......@@ -35,60 +35,16 @@ The performance tracing APIs are provided by the **hiTraceMeter** module. For de
In this example, distributed call chain tracing begins when the application startup execution page is loaded and stops when the service usage is completed.
1. Create a JS application project. In the displayed **Project** window, choose **entry** > **src** > **main** > **js** > **default** > **pages** > **index**, and double-click **index.js**. Add the code to implement performance tracing upon page loading. The sample code is as follows:
```js
import hiTraceMeter from '@ohos.hiTraceMeter'
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
// Start trace tasks with the same name concurrently.
hiTraceMeter.startTrace("business", 1);
// Keep the service process running.
console.log(`business running`);
hiTraceMeter.startTrace("business", 2); // Start the second trace task with the same name while the first task is still running. The tasks are running concurrently and therefore their taskId must be different.
// Keep the service process running.
console.log(`business running`);
hiTraceMeter.finishTrace("business", 1);
// Keep the service process running.
console.log(`business running`);
hiTraceMeter.finishTrace("business", 2);
// Start trace tasks with the same name in serial mode.
hiTraceMeter.startTrace("business", 1);
// Keep the service process running.
console.log(`business running`);
hiTraceMeter.finishTrace("business", 1); // End the first trace task.
// Keep the service process running.
console.log(`business running`);
hiTraceMeter.startTrace("business", 1); // Start the second trace task with the same name in serial mode.
// Keep the service process running.
console.log(`business running`);
let traceCount = 3;
hiTraceMeter.traceByValue("myTestCount", traceCount);
traceCount = 4;
hiTraceMeter.traceByValue("myTestCount", traceCount);
hiTraceMeter.finishTrace("business", 1);
}
}
```
2. Create an ArkTs application project. In the displayed **Project** window, choose **entry** > **src** > **main** > **ets** > **pages** > **index**, and double-click **index.js**. Add the code to implement performance tracing upon page loading. For example, if the name of the trace task is **HITRACE\_TAG\_APP**, the sample code is as follows:
1. Create an ArkTS application project. In the displayed **Project** window, choose **entry** > **src** > **main** > **ets** > **pages** > **index**, and double-click **index.js**. Add the code to implement performance tracing upon page loading. For example, if the name of the trace task is **HITRACE\_TAG\_APP**, the sample code is as follows:
```ts
import hitrace from '@ohos.hiTraceMeter';
@Entry
@Component
struct Index {
@State message: string = 'Hello World';
build() {
Row() {
Column() {
......@@ -97,7 +53,7 @@ In this example, distributed call chain tracing begins when the application star
.fontWeight(FontWeight.Bold)
.onClick(() => {
this.message = 'Hello ArkUI';
// Start trace tasks with the same name concurrently.
hitrace.startTrace("HITRACE_TAG_APP", 1001);
// Keep the service process running.
......@@ -107,7 +63,7 @@ In this example, distributed call chain tracing begins when the application star
hitrace.startTrace("HITRACE_TAG_APP", 1002);
// Keep the service process running.
console.log(`HITRACE_TAG_APP running`);
hitrace.finishTrace("HITRACE_TAG_APP", 1001);
hitrace.finishTrace("HITRACE_TAG_APP", 1002);
......@@ -143,7 +99,7 @@ In this example, distributed call chain tracing begins when the application star
```
3. Click the run button on the application page. Then, run the following commands in sequence in shell:
```shell
hdc shell
hitrace --trace_begin app
......
# Development of Performance Tracing (Native)
## Introduction
## Overview
hiTraceMeter provides APIs for system performance tracing. You can call the APIs provided by the hiTraceMeter module in your own service logic to effectively track service processes and check the system performance.
> **NOTE**
......
# Connecting the Neural Network Runtime to an AI Inference Framework
# Development Guide for Connecting the Neural Network Runtime to an AI Inference Framework
## When to Use
......@@ -19,8 +19,7 @@ The environment requirements for the Neural Network Runtime are as follows:
- Development environment: Ubuntu 18.04 or later.
- Access device: a standard device running OpenHarmony. The built-in hardware accelerator driver has been connected to the Neural Network Runtime through an HDI API.
The Neural Network Runtime is opened to external systems through OpenHarmony Native APIs. Therefore, you need to use the Native development suite of the OpenHarmony to compile Neural Network Runtime applications.
The Neural Network Runtime is opened to external systems through OpenHarmony Native APIs. Therefore, you need to use the Native development suite of the OpenHarmony to compile Neural Network Runtime applications.
### Environment Setup
......@@ -33,7 +32,6 @@ unzip native-linux-{version number}.zip
```
The directory structure after decompression is as follows. The content in the directory may vary depending on version iteration. Use the Native APIs of the latest version.
```text
native/
─ ─ build // Cross-compilation toolchain
......@@ -488,4 +486,4 @@ The development process of the Neural Network Runtime consists of three phases:
```shell
rm /data/local/tmp/*nncache
```
\ No newline at end of file
```
......@@ -4,9 +4,9 @@ The **cooperate** module implements screen hopping for two or more networked dev
> **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 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.
> - The APIs provided by this module are system APIs.
## Modules to Import
......@@ -26,7 +26,7 @@ Prepares for screen hopping. This API uses an asynchronous callback to return th
| Name | Type | Mandatory | Description |
| -------- | ------------------------- | ---- | --------------------------- |
| callback | AsyncCallback&lt;void&gt; | Yes|Callback used to return the result. |
| callback | AsyncCallback&lt;void&gt; | Yes|Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object. |
**Example**
......@@ -56,7 +56,7 @@ Prepares for screen hopping. This API uses a promise to return the result.
| Parameters | Description |
| ------------------- | ------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
| Promise&lt;void&gt; | Promise that returns no value.|
......@@ -75,7 +75,6 @@ try {
```
## cooperate.unprepare
unprepare(callback: AsyncCallback&lt;void&gt;): void;
......@@ -86,7 +85,7 @@ Cancels the preparation for screen hopping. This API uses an asynchronous callba
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ------------------------------------------ |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
**Example**
......@@ -104,8 +103,6 @@ try {
}
```
## cooperate.unprepare
unprepare(): Promise&lt;void&gt;;
......@@ -118,7 +115,7 @@ Cancels the preparation for screen hopping. This API uses a promise to return th
| Parameters | Description |
| ------------------- | --------------------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
| Promise&lt;void&gt; | Promise that returns no value.|
```js
try {
......@@ -133,7 +130,6 @@ try {
```
## cooperate.activate
activate(targetNetworkId: string, inputDeviceId: number, callback: AsyncCallback&lt;void&gt;): void;
......@@ -148,7 +144,7 @@ Starts screen hopping. This API uses an asynchronous callback to return the resu
| -------- | ---------------------------- | ---- | ---------------------------- |
| targetNetworkId | string | Yes | Descriptor of the target device for screen hopping. |
| inputDeviceId | number | Yes | Identifier of the input device for screen hopping.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
**Error codes**
......@@ -156,7 +152,7 @@ For details about the error codes, see [Screen Hopping Error Codes](../errorcode
| ID| Error Message|
| -------- | ---------------------------------------- |
| 20900001 | This error code is reported if the screen hopping status is abnormal when the screen hopping API is called. |
| 20900001 | Operation failed.|
**Example**
......@@ -197,7 +193,7 @@ Starts screen hopping. This API uses a promise to return the result.
| Name | Description |
| ---------------------- | ------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result. |
| Promise&lt;void&gt; | Promise that returns no value. |
**Error codes**
......@@ -205,7 +201,7 @@ For details about the error codes, see [Screen Hopping Error Codes](../errorcode
| ID| Error Message|
| -------- | ---------------------------------------- |
| 20900001 | This error code is reported if the screen hopping status is abnormal when the screen hopping API is called. |
| 20900001 | Operation failed. |
**Example**
......@@ -235,8 +231,8 @@ Stops screen hopping. This API uses an asynchronous callback to return the resul
| Name | Type | Mandatory | Description |
| -------- | ---------------------------- | ---- | ---------------------------- |
| isUnchained | boolean | Yes| Whether to disable the cross-device link.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
| isUnchained | boolean | Yes| Whether to disable the cross-device link.<br> The value **true** means to disable the cross-device link, and the value **false** means the opposite.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
......@@ -268,7 +264,7 @@ Stops screen hopping. This API uses a promise to return the result.
| Name | Type | Mandatory| Description |
| ----------- | ------- | ---- | ------------------ |
| isUnchained | boolean | Yes | Whether to disable the cross-device link.|
| isUnchained | boolean | Yes | Whether to disable the cross-device link.<br> The value **true** means to disable the cross-device link, and the value **false** means the opposite.|
......@@ -276,7 +272,7 @@ Stops screen hopping. This API uses a promise to return the result.
| Name | Description |
| -------- | ---------------------------- |
| Promise&lt;void&gt; | Promise used to return the result. |
| Promise&lt;void&gt; | Promise that returns no value. |
......@@ -307,7 +303,7 @@ Obtains the screen hopping status of the target device. This API uses an asynchr
| Name | Type | Mandatory | Description |
| -------- | --------- | ---- | ---------------------------- |
| networkId | string | Yes | Descriptor of the target device for screen hopping. |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result.|
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result. The value **true** indicates that screen hopping is enabled, and the value **false** indicates the opposite.|
**Example**
......@@ -336,9 +332,9 @@ Obtains the screen hopping status of the target device. This API uses a promise
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | --------- | ---- | ---------------------------- |
| networkId | string | Yes | Descriptor of the target device for screen hopping. |
| Name | Type | Mandatory | Description |
| -------- | --------- | ---- | ---------------------------- |
| networkId | string | Yes | Descriptor of the target device for screen hopping. |
......@@ -346,7 +342,7 @@ Obtains the screen hopping status of the target device. This API uses a promise
| Parameters | Description |
| ------------------- | ------------------------------- |
| Promise&lt;boolean&gt; | Promise used to return the result.|
| Promise&lt;boolean&gt; | Promise used to return the result. The value **true** indicates that screen hopping is enabled, and the value **false** indicates the opposite.|
......
......@@ -4,7 +4,7 @@ The **hiAppEvent** module provides the application event logging functions, such
> **NOTE**
>
> - The APIs provided by this module are deprecated since API version 9. You are advised to use [`@ohos.hiviewdfx.hiAppEvent`](js-apis-hiviewdfx-hiappevent.md) instead.
> - The APIs provided by this module are deprecated since API version 9. You are advised to use [`@ohos.hiviewdfx.hiAppEvent`](js-apis-hiviewdfx-hiappevent.md).
> - The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
......@@ -20,7 +20,7 @@ Before using application event logging, you need to understand the requirements
**Event Name**
An event name is a string that contains a maximum of 48 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a lowercase letter and cannot end with an underscore (\_).
An event name is a string that contains a maximum of 48 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a letter or dollar sign ($) and cannot end with an underscore (_).
**Event Type**
......@@ -30,8 +30,8 @@ An event type is an enumerated value of [EventType](#eventtype).
An event parameter is an object in key-value pair format, where the key is the parameter name and the value is the parameter value. The requirements are as follows:
- A parameter name is a string that contains a maximum of 16 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a lowercase letter and cannot end with an underscore (\_).
- The parameter value can be of the string, number, boolean, or array type.
- A parameter name is a string that contains a maximum of 16 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a letter or dollar sign ($) and cannot end with an underscore (_).
- A parameter value can be of the string, number, boolean, or array type.
- If the parameter value is a string, its maximum length is 8*1024 characters. If this limit is exceeded, excess characters will be discarded.
- If the parameter value is a number, the value must be within the range of **Number.MIN_SAFE_INTEGER** to **Number.MAX_SAFE_INTEGER**. Otherwise, uncertain values may be generated.
- If the parameter value is an array, the elements in the array must be of the same type, which can only be string, number, or boolean. In addition, the number of elements must be less than 100. If this limit is exceeded, excess elements will be discarded.
......@@ -156,12 +156,12 @@ Provides the configuration items for application event logging.
| Name | Type | Mandatory| Description |
| ---------- | ------- | ---- | ------------------------------------------------------------ |
| disable | boolean | No | Application event logging switch. The value **true** means to disable the application event logging function, and the value **false** means the opposite.|
| maxStorage | string | No | Maximum size of the event file storage directory. The default value is <strong>10M</strong>. If the specified size is exceeded, the oldest event logging files in the directory will be deleted to free up space.|
| maxStorage | string | No | Maximum size of the event file storage directory. The default value is **10M**. If the specified size is exceeded, the oldest event logging files in the directory will be deleted to free up space.|
## EventType
Enumerates event types.
Enumerates the event types.
**System capability**: SystemCapability.HiviewDFX.HiAppEvent
......
......@@ -122,10 +122,10 @@ Defines parameters for an **AppEventInfo** object.
| Name | Type | Mandatory| Description |
| --------- | ----------------------- | ---- | ------------------------------------------------------------ |
| domain | string | Yes | Event domain. Event domain name, which is a string of up to 32 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a lowercase letter and cannot end with an underscore (_).|
| name | string | Yes | Event name. Event name, which is a string of up to 48 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a lowercase letter and cannot end with an underscore (_).|
| domain | string | Yes | Event domain. The value is a string of up to 32 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a lowercase letter and cannot end with an underscore (_).|
| name | string | Yes | Event name. The value is a string of up to 48 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a lowercase letter or dollar sign ($) and cannot end with an underscore (_).|
| eventType | [EventType](#eventtype) | Yes | Event type. |
| params | object | Yes | Event parameter object, which consists of a parameter name and a parameter value. The specifications are as follows:<br>- The parameter name is a string of up to 16 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a lowercase letter and cannot end with an underscore (_).<br>- The parameter value can be a string, number, boolean, or array. If the parameter value is a string, its maximum length is 8*1024 characters. If this limit is exceeded, excess characters will be discarded. If the parameter value is a number, the value must be within the range of **Number.MIN_SAFE_INTEGER** to **Number.MAX_SAFE_INTEGER**. Otherwise, uncertain values may be generated. If the parameter value is an array, the elements in the array must be of the same type, which can only be string, number, or boolean. In addition, the number of elements must be less than 100. If this limit is exceeded, excess elements will be discarded.<br>- The maximum number of parameters is 32. If this limit is exceeded, excess parameters will be discarded.|
| params | object | Yes | Event parameter object, which consists of a parameter name and a parameter value. The specifications are as follows:<br>- The parameter name is a string of up to 16 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a lowercase letter or dollar sign ($) and cannot end with an underscore (_).<br>- The parameter value can be a string, number, boolean, or array. If the parameter value is a string, its maximum length is 8*1024 characters. If this limit is exceeded, excess characters will be discarded. If the parameter value is a number, the value must be within the range of **Number.MIN_SAFE_INTEGER** to **Number.MAX_SAFE_INTEGER**. Otherwise, uncertain values may be generated. If the parameter value is an array, the elements in the array must be of the same type, which can only be string, number, or boolean. In addition, the number of elements must be less than 100. If this limit is exceeded, excess elements will be discarded.<br>- The maximum number of parameters is 32. If this limit is exceeded, excess parameters will be discarded.|
## hiAppEvent.configure
......@@ -436,7 +436,7 @@ hiAppEvent.clearData();
## EventType
Enumerates event types.
Enumerates the event types.
**System capability**: SystemCapability.HiviewDFX.HiAppEvent
......
......@@ -86,7 +86,7 @@ Creates an HTTP request. You can use this API to initiate or destroy an HTTP req
| Type | Description |
| :---------- | :----------------------------------------------------------- |
| HttpRequest | An **HttpRequest** object, which contains the **request**, **request2**, **destroy**, **on**, or **off** method.|
| HttpRequest | An **HttpRequest** object, which contains the **request**, **requestInStream**, **destroy**, **on**, or **off** method.|
**Example**
......@@ -364,9 +364,9 @@ Destroys an HTTP request.
httpRequest.destroy();
```
### request2<sup>10+</sup>
### requestInStream<sup>10+</sup>
request2(url: string, callback: AsyncCallback\<number\>): void
requestInStream(url: string, callback: AsyncCallback\<number\>): void
Initiates an HTTP request containing specified options to a given URL. This API uses an asynchronous callback to return the result, which is a streaming response.
......@@ -424,18 +424,18 @@ Initiates an HTTP request containing specified options to a given URL. This API
**Example**
```js
httpRequest.request2("EXAMPLE_URL", (err, data) => {
httpRequest.requestInStream("EXAMPLE_URL", (err, data) => {
if (!err) {
console.info("request2 OK! ResponseCode is " + JSON.stringify(data));
console.info("requestInStream OK! ResponseCode is " + JSON.stringify(data));
} else {
console.info("request2 ERROR : err = " + JSON.stringify(err));
console.info("requestInStream ERROR : err = " + JSON.stringify(err));
}
})
```
### request2<sup>10+</sup>
### requestInStream<sup>10+</sup>
request2(url: string, options: HttpRequestOptions, callback: AsyncCallback\<number\>): void
requestInStream(url: string, options: HttpRequestOptions, callback: AsyncCallback\<number\>): void
Initiates an HTTP request containing specified options to a given URL. This API uses an asynchronous callback to return the result, which is a streaming response.
......@@ -494,7 +494,7 @@ Initiates an HTTP request containing specified options to a given URL. This API
**Example**
```js
httpRequest.request2("EXAMPLE_URL",
httpRequest.requestInStream("EXAMPLE_URL",
{
method: http.RequestMethod.GET,
header: {
......@@ -504,16 +504,16 @@ httpRequest.request2("EXAMPLE_URL",
connectTimeout: 60000
}, (err, data) => {
if (!err) {
console.info("request2 OK! ResponseCode is " + JSON.stringify(data));
console.info("requestInStream OK! ResponseCode is " + JSON.stringify(data));
} else {
console.info("request2 ERROR : err = " + JSON.stringify(err));
console.info("requestInStream ERROR : err = " + JSON.stringify(err));
}
})
```
### request2<sup>10+</sup>
### requestInStream<sup>10+</sup>
request2(url: string, options? : HttpRequestOptions): Promise\<number\>
requestInStream(url: string, options? : HttpRequestOptions): Promise\<number\>
Initiates an HTTP request containing specified options to a given URL. This API uses a promise to return the result, which is a streaming response.
......@@ -577,7 +577,7 @@ Initiates an HTTP request containing specified options to a given URL. This API
**Example**
```js
let promise = httpRequest.request2("EXAMPLE_URL", {
let promise = httpRequest.requestInStream("EXAMPLE_URL", {
method: http.RequestMethod.GET,
connectTimeout: 60000,
readTimeout: 60000,
......@@ -586,9 +586,9 @@ let promise = httpRequest.request2("EXAMPLE_URL", {
}
});
promise.then((data) => {
console.info("request2 OK!" + JSON.stringify(data));
console.info("requestInStream OK!" + JSON.stringify(data));
}).catch((err) => {
console.info("request2 ERROR : err = " + JSON.stringify(err));
console.info("requestInStream ERROR : err = " + JSON.stringify(err));
});
```
......@@ -815,9 +815,9 @@ Unregisters the observer for events indicating completion of receiving HTTP stre
httpRequest.off('dataEnd');
```
### on('dataProgress')<sup>10+</sup>
### on('dataReceiveProgress')<sup>10+</sup>
on(type: 'dataProgress', callback: Callback\<{ receiveSize: number, totalSize: number }\>): void
on(type: 'dataReceiveProgress', callback: Callback\<{ receiveSize: number, totalSize: number }\>): void
Registers an observer for events indicating progress of receiving HTTP streaming responses.
......@@ -830,20 +830,20 @@ Registers an observer for events indicating progress of receiving HTTP streaming
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | --------------------------------- |
| type | string | Yes | Event type. The value is **dataProgress**.|
| type | string | Yes | Event type. The value is **dataReceiveProgress**.|
| callback | AsyncCallback\<{ receiveSize: number, totalSize: number }\> | Yes | Callback used to return the result.<br>- **receiveSize**: number of received bytes.<br>- **totalSize**: total number of bytes to be received.|
**Example**
```js
httpRequest.on('dataProgress', (data) => {
console.info('dataProgress:' + JSON.stringify(data));
httpRequest.on('dataReceiveProgress', (data) => {
console.info('dataReceiveProgress:' + JSON.stringify(data));
});
```
### off('dataProgress')<sup>10+</sup>
### off('dataReceiveProgress')<sup>10+</sup>
off(type: 'dataProgress', callback?: Callback\<{ receiveSize: number, totalSize: number }\>): void
off(type: 'dataReceiveProgress', callback?: Callback\<{ receiveSize: number, totalSize: number }\>): void
Unregisters the observer for events indicating progress of receiving HTTP streaming responses.
......@@ -856,13 +856,13 @@ Unregisters the observer for events indicating progress of receiving HTTP stream
| Name | Type | Mandatory| Description |
| -------- | ------------------ | ---- | -------------------------------------- |
| type | string | Yes | Event type. The value is **dataProgress**.|
| type | string | Yes | Event type. The value is **dataReceiveProgress**.|
| callback | Callback\<{ receiveSize: number, totalSize: number }\> | No | Callback used to return the result. |
**Example**
```js
httpRequest.off('dataProgress');
httpRequest.off('dataReceiveProgress');
```
## HttpRequestOptions<sup>6+</sup>
......
......@@ -158,7 +158,7 @@ Obtains the global HTTP proxy configuration of the network. This API uses an asy
| Name | Type | Mandatory| Description |
| -------- | --------------------------------------- | ---- | ------------------------------------------------------------ |
| callback | AsyncCallback\<[HttpProxy](#httpproxy)> | Yes | Callback used to return the result. If the global HTTP proxy configuration of the network is obtained successfully, **error** is **undefined** and **data** is the global HTTP proxy configuration. Otherwise, **error** is an error object.|
| callback | AsyncCallback\<[HttpProxy](#httpproxy10)> | Yes | Callback used to return the result. If the global HTTP proxy configuration of the network is obtained successfully, **error** is **undefined** and **data** is the global HTTP proxy configuration. Otherwise, **error** is an error object.|
**Error codes**
......@@ -192,7 +192,7 @@ Obtains the global HTTP proxy configuration of the network. This API uses a prom
| Type | Description |
| --------------------------------- | ------------------------------------- |
| Promise\<[HttpProxy](#httpproxy)> | Promise used to return the result.|
| Promise\<[HttpProxy](#httpproxy10)> | Promise used to return the result.|
**Error codes**
......@@ -229,7 +229,7 @@ Sets the global HTTP proxy configuration of the network. This API uses an asynch
| Name | Type | Mandatory| Description |
| --------- | ----------------------- | ---- | ------------------------------------------------------------ |
| httpProxy | [HttpProxy](#httpproxy) | Yes | Global HTTP proxy configuration of the network. |
| httpProxy | [HttpProxy](#httpproxy10) | Yes | Global HTTP proxy configuration of the network. |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the global HTTP proxy configuration of the network is set successfully, **error** is **undefined**. Otherwise, **error** is an error object.|
**Error codes**
......@@ -274,7 +274,7 @@ Sets the global HTTP proxy configuration of the network. This API uses a promise
| Name | Type | Mandatory| Description |
| --------- | ------------------------------------------------------------ | ---- | ---------------- |
| httpProxy | [HttpProxy](#httpproxy) | Yes | Global HTTP proxy configuration of the network.|
| httpProxy | [HttpProxy](#httpproxy10) | Yes | Global HTTP proxy configuration of the network.|
**Return value**
......@@ -324,7 +324,7 @@ This API uses an asynchronous callback to return the result.
| Name | Type | Mandatory| Description |
| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ |
| callback | AsyncCallback<[HttpProxy](#httpproxy)> | Yes | Callback used to return the result. If the global HTTP proxy configuration of the network is obtained successfully, **error** is **undefined** and **data** is the global HTTP proxy configuration. Otherwise, **error** is an error object.|
| callback | AsyncCallback<[HttpProxy](#httpproxy10)> | Yes | Callback used to return the result. If the global HTTP proxy configuration of the network is obtained successfully, **error** is **undefined** and **data** is the global HTTP proxy configuration. Otherwise, **error** is an error object.|
**Error codes**
......@@ -347,7 +347,7 @@ connection.getDefaultHttpProxy((error, data) => {
getDefaultHttpProxy(): Promise\<HttpProxy>;
Obtains the default proxy configuration of the network.
If the global proxy is set, the global proxy configuration is returned. If [setAppNet](#connectionsetappnet) is used to bind the application to the network specified by [NetHandle](#nethandle), the proxy configuration of this network is returned. In other cases, the HTTP proxy configuration of the default network is returned.
If the global proxy is set, the global HTTP proxy configuration is returned. If [setAppNet](#connectionsetappnet) is used to bind the application to the network specified by [NetHandle](#nethandle), the HTTP proxy configuration of this network is returned. In other cases, the HTTP proxy configuration of the default network is returned.
This API uses a promise to return the result.
**System capability**: SystemCapability.Communication.NetManager.Core
......@@ -356,7 +356,7 @@ This API uses a promise to return the result.
| Type | Description |
| -------------------------------- | ----------------------------------------- |
| Promise<[HttpProxy](#httpproxy)> | Promise used to return the result.|
| Promise<[HttpProxy](#httpproxy10)> | Promise used to return the result.|
**Error codes**
......
......@@ -486,7 +486,7 @@ Defines the network configuration for the Ethernet connection.
| gateway | string | Yes| Gateway of the Ethernet connection. The value must be an IPv4 address, which is a 32-bit number displayed in dotted decimal notation and each 8-bit field ranges from 0 to 255. This parameter does not need to be configured in DHCP mode.|
| netMask | string | Yes| Subnet mask of the Ethernet connection. The value must be an IPv4 address, which is a 32-bit number displayed in dotted decimal notation and each 8-bit field ranges from 0 to 255. This parameter does not need to be configured in DHCP mode.|
| dnsServers | string | Yes| DNS server addresses of the Ethernet connection. The value must be an IPv4 address. This parameter does not need to be configured in DHCP mode. Multiple addresses are separated by commas (,).|
| httpProxy<sup>10+</sup> | [HttpProxy](js-apis-net-connection.md#httpproxy) | No| HTTP proxy of the Ethernet connection. By default, no proxy is configured.|
| httpProxy<sup>10+</sup> | [HttpProxy](js-apis-net-connection.md#httpproxy10) | No| HTTP proxy of the Ethernet connection. By default, no proxy is configured.|
## IPSetMode<sup>9+</sup>
......
......@@ -850,7 +850,7 @@ Enumerates mouse pointer styles.
| MIDDLE_BTN_SOUTH_EAST | 36 | Scrolling south-east |![MID_Btn_South_East.png](./figures/MID_Btn_South_East.png)|
| MIDDLE_BTN_SOUTH_WEST | 37 | Scrolling south-west |![MID_Btn_South_West.png](./figures/MID_Btn_South_West.png)|
| MIDDLE_BTN_NORTH_SOUTH_WEST_EAST | 38 | Moving as a cone in four directions|![MID_Btn_North_South_West_East.png](./figures/MID_Btn_North_South_West_East.png)|
| HORIZONTAL_TEXT_CURSOR<sup>10+</sup> | 39 | Horizontal text selection|![Horizontal_Text_Cursor.png](./figures/Horizontal_Text_Cursor.png)|
| HORIZONTAL_TEXT_CURSOR<sup>10+</sup> | 39 | Horizontal text cursor|![Horizontal_Text_Cursor.png](./figures/Horizontal_Text_Cursor.png)|
| CURSOR_CROSS<sup>10+</sup> | 40 | Cross cursor|![Cursor_Cross.png](./figures/Cursor_Cross.png)|
| CURSOR_CIRCLE<sup>10+</sup> | 41 | Circular cursor|![Cursor_Circle.png](./figures/Cursor_Circle.png)|
......@@ -1726,3 +1726,357 @@ try {
console.log(`getTouchpadRightClickType failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## pointer.setPointerSize<sup>10+</sup>
setPointerSize(size: number, callback: AsyncCallback&lt;void&gt;): void
Sets the pointer size. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MultimodalInput.Input.Pointer
**System API**: This is a system API.
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ------------------------- | ---- | ------------------------------------- |
| size | number | Yes | Pointer size. The value ranges from **1** to **7**. The default value is **1**. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
**Example**
```js
try {
pointer.setPointerSize(1, (error) => {
if (error) {
console.log(`setPointerSize failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
return;
}
console.log(`setPointerSize success`);
});
} catch (error) {
console.log(`setPointerSize failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## pointer.setPointerSize<sup>10+</sup>
setPointerSize(size: number): Promise&lt;void&gt;
Sets the pointer size. This API uses a promise to return the result.
**System capability**: SystemCapability.MultimodalInput.Input.Pointer
**System API**: This is a system API.
**Parameters**
| Name | Type | Mandatory | Description |
| ----- | ------ | ---- | ----------------------------------- |
| size | number | Yes | Pointer size. The value ranges from **1** to **7**. The default value is **1**.|
**Return value**
| Name | Description |
| ------------------- | ---------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
**Example**
```js
try {
pointer.setPointerSize(3).then(() => {
console.log(`setPointerSize success`);
});
} catch (error) {
console.log(`setPointerSize failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## pointer.setPointerSizeSync<sup>10+</sup>
setPointerSizeSync(size: number): void;
Sets the pointer size. This API returns the result synchronously.
**System capability**: SystemCapability.MultimodalInput.Input.Pointer
**System API**: This is a system API.
**Parameters**
| Name | Type | Mandatory | Description |
| ----- | ------ | ---- | ----------------------------------- |
| size | number | Yes | Pointer size. The value ranges from **1** to **7**. The default value is **1**.|
**Example**
```js
try {
pointer.setPointerSizeSync(5);
console.log(`setPointerSizeSync success`);
} catch (error) {
console.log(`setPointerSizeSync failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## pointer.getPointerSize<sup>10+</sup>
getPointerSize(callback: AsyncCallback&lt;number&gt;): void
Obtains the pointer size. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MultimodalInput.Input.Pointer
**System API**: This is a system API.
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | --------------------------- | ---- | -------------- |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the result.|
**Example**
```js
try {
pointer.getPointerSize((error, size) => {
console.log(`getPointerSize success, size: ${JSON.stringify(size)}`);
});
} catch (error) {
console.log(`getPointerSize failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## pointer.getPointerSize<sup>10+</sup>
getPointerSize(): Promise&lt;number&gt;
Obtains the pointer size. This API uses a promise to return the result.
**System capability**: SystemCapability.MultimodalInput.Input.Pointer
**System API**: This is a system API.
**Return value**
| Name | Description |
| --------------------- | ------------------- |
| Promise&lt;number&gt; | Promise used to return the result.|
**Example**
```js
try {
pointer.getPointerSize().then((size) => {
console.log(`getPointerSize success, size: ${JSON.stringify(size)}`);
});
} catch (error) {
console.log(`getPointerSize failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## pointer.getPointerSizeSync<sup>10+</sup>
getPointerSizeSync(): number
Obtains the pointer size. This API returns the result synchronously.
**System capability**: SystemCapability.MultimodalInput.Input.Pointer
**System API**: This is a system API.
**Return value**
| Name | Description |
| --------------------- | ------------------- |
| number | Pointer size. |
**Example**
```js
try {
let pointerSize = pointer.getPointerSizeSync();
console.log(`getPointerSizeSync success, pointerSize: ${JSON.stringify(pointerSize)}`);
} catch (error) {
console.log(`getPointerSizeSync failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## pointer.setPointerColor<sup>10+</sup>
setPointerColor(color: number, callback: AsyncCallback&lt;void&gt;): void
Sets the pointer color. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MultimodalInput.Input.Pointer
**System API**: This is a system API.
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ------------------------- | ---- | ------------------------------------- |
| color | number | Yes | Pointer color. The default value is **black** (0x000000). |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
**Example**
```js
try {
pointer.setPointerColor(0xF6C800, (error) => {
if (error) {
console.log(`setPointerColor failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
return;
}
console.log(`setPointerColor success`);
});
} catch (error) {
console.log(`setPointerColor failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## pointer.setPointerColor<sup>10+</sup>
setPointerColor(color: number): Promise&lt;void&gt;
Sets the pointer color. This API uses a promise to return the result.
**System capability**: SystemCapability.MultimodalInput.Input.Pointer
**System API**: This is a system API.
**Parameters**
| Name | Type | Mandatory | Description |
| ----- | ------ | ---- | ----------------------------------- |
| color | number | Yes | Pointer color. The default value is **black** (0x000000).|
**Return value**
| Name | Description |
| ------------------- | ---------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
**Example**
```js
try {
pointer.setPointerColor(0xF6C800).then(() => {
console.log(`setPointerColor success`);
});
} catch (error) {
console.log(`setPointerColor failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## pointer.setPointerColorSync<sup>10+</sup>
setPointerColorSync(color: number): void;
Sets the pointer color. This API returns the result synchronously.
**System capability**: SystemCapability.MultimodalInput.Input.Pointer
**System API**: This is a system API.
**Parameters**
| Name | Type | Mandatory | Description |
| ----- | ------ | ---- | ----------------------------------- |
| color | number | Yes | Pointer color. The default value is **black** (0x000000).|
**Example**
```js
try {
pointer.setPointerColorSync(0xF6C800);
console.log(`setPointerColorSync success`);
} catch (error) {
console.log(`setPointerColorSync failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## pointer.getPointerColor<sup>10+</sup>
getPointerColor(callback: AsyncCallback&lt;number&gt;): void
Obtains the pointer color. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MultimodalInput.Input.Pointer
**System API**: This is a system API.
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | --------------------------- | ---- | -------------- |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the result.|
**Example**
```js
try {
pointer.getPointerColor((error, color) => {
console.log(`getPointerColor success, color: ${JSON.stringify(color)}`);
});
} catch (error) {
console.log(`getPointerColor failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## pointer.getPointerColor<sup>10+</sup>
getPointerColor(): Promise&lt;number&gt;
Obtains the pointer color. This API uses a promise to return the result.
**System capability**: SystemCapability.MultimodalInput.Input.Pointer
**System API**: This is a system API.
**Return value**
| Name | Description |
| --------------------- | ------------------- |
| Promise&lt;number&gt; | Promise used to return the result.|
**Example**
```js
try {
pointer.getPointerColor().then((color) => {
console.log(`getPointerColor success, color: ${JSON.stringify(color)}`);
});
} catch (error) {
console.log(`getPointerColor failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## pointer.getPointerColorSync<sup>10+</sup>
getPointerColorSync(): number
Obtains the pointer color. This API returns the result synchronously.
**System capability**: SystemCapability.MultimodalInput.Input.Pointer
**System API**: This is a system API.
**Return value**
| Name | Description |
| --------------------- | ------------------- |
| number | Pointer color.|
**Example**
```js
try {
let pointerColor = pointer.getPointerColorSync();
console.log(`getPointerColorSync success, pointerColor: ${JSON.stringify(pointerColor)}`);
} catch (error) {
console.log(`getPointerColorSync failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
......@@ -2732,7 +2732,7 @@ Obtains the MSISDN of the SIM card in the specified slot. This API uses an async
**System API**: This is a system API.
**Required permission**: ohos.permission.GET_TELEPHONY_STATE
**Required permission**: ohos.permission.GET_PHONE_NUMBERS
**System capability**: SystemCapability.Telephony.CoreService
......@@ -2775,7 +2775,7 @@ Obtains the MSISDN of the SIM card in the specified slot. This API uses a promis
**System API**: This is a system API.
**Required permission**: ohos.permission.GET_TELEPHONY_STATE
**Required permission**: ohos.permission.GET_PHONE_NUMBERS
**System capability**: SystemCapability.Telephony.CoreService
......
......@@ -1691,7 +1691,7 @@ listen(address: NetAddress, callback: AsyncCallback\<void\>): void
Binds the IP address and port number. The port number can be specified or randomly allocated by the system. The server listens to and accepts TCP socket connections established over the socket. Multiple threads are used to process client data concurrently. This API uses an asynchronous callback to return the result.
> **NOTE**
> **NOTE**<br>
> The server uses this API to perform the **bind**, **listen**, and **accept** operations. If the **bind** operation fails, the system randomly allocates a port number.
**Required permissions**: ohos.permission.INTERNET
......@@ -1736,7 +1736,7 @@ listen(address: NetAddress): Promise\<void\>
Binds the IP address and port number. The port number can be specified or randomly allocated by the system. The server listens to and accepts TCP socket connections established over the socket. Multiple threads are used to process client data concurrently. This API uses a promise to return the result.
> **NOTE**
> **NOTE**<br>
> The server uses this API to perform the **bind**, **listen**, and **accept** operations. If the **bind** operation fails, the system randomly allocates a port number.
**Required permissions**: ohos.permission.INTERNET
......
# Application Event Logging Error Codes
# Application Event Logging Error Codes
> **NOTE**
>
......@@ -63,8 +63,8 @@ This error code is reported if the **write** API is called to perform applicatio
The specified event name does not comply with the following rules:
- The event name contains only digits, lowercase letters, and underscores (\_).
- The event name starts with a lowercase letter and does not end with an underscore (\_).
- An event name contains only digits, letters, and underscores (_).
- An event name starts with a letter or dollar sign ($) and does not end with an underscore (_).
- The event name is not empty and contains a maximum of 48 characters.
**Solution**
......@@ -119,11 +119,11 @@ This error code is reported if the **write** API is called to perform applicatio
**Possible Causes**
The specified event parameter name does not comply with the following rules:
The specified event name does not comply with the following rules:
- The event parameter name contains only digits, lowercase letters, and underscores (\_).
- The event parameter name starts with a lowercase letter and does not end with an underscore (\_).
- The event parameter name is not empty and contains a maximum of 16 characters.
- An event name contains only digits, letters, and underscores (_).
- An event name starts with a letter or dollar sign ($) and does not end with an underscore (_).
- An event parameter name is not empty and contains a maximum of 16 characters.
**Solution**
......@@ -163,7 +163,7 @@ The specified watcher name does not comply with the following rules:
- The watcher name can contain only digits, lowercase letters, and underscores (\_).
- The watcher name starts with a lowercase letter and does not end with an underscore (\_).
- The watcher name is not empty and contains a maximum of 32 characters.
- A watcher name is not empty and contains a maximum of 32 characters.
**Solution**
......
......@@ -33,10 +33,11 @@ Constraints on the event domain, event name, and parameter
| Field| Description|
| -------- | -------- |
| type | Event type. This field is mandatory.<br>Value:<br>- FAULT: fault<br>- STATISTIC: statistics<br>- SECURITY: security<br>- BEHAVIOR: user behavior|
| type | Event type. This field is mandatory.<br>Value:<br>- **FAULT**: fault<br>- STATISTIC: statistics<br>- **SECURITY**: security<br>- **BEHAVIOR**: behavior|
| level | Event level. This field is mandatory.<br>Value:<br>- CRITICAL: critical<br>- MINOR: minor|
| tag | Event tag. This field is mandatory.<br>Rule:<br>- You can define a maximum of five tags, separated with a space.<br>- A single tag can contain a maximum of 16 characters, including a to z, A to Z, and 0 to 9.|
| desc | Event name. This field is mandatory.<br>Rule:<br>The description contains 3 to 128 characters, including a to z, A to Z, 0 to 9, and underscores (_).|
| desc | Event name. This field is mandatory.<br>Rule:<br>- A string of 3 to 128 characters.|
| preserve | Whether events need to be logged in the event file. This field is optional. The default value is **true**.<br>Value:<br>- **true**: Events need to be logged in the event file.<br>- **false**: Events do not need to be logged in the event file.|
**Table 2** Description of custom parameters
......@@ -44,7 +45,7 @@ Constraints on the event domain, event name, and parameter
| -------- | -------- |
| type | Parameter type. This field is mandatory.<br>Value:<br>- BOOL<br>- INT8<br>- UINT8<br>- INT16<br>- UINT16<br>- INT32<br>- UINT32<br>- INT64<br>- UINT64<br>- FLOAT<br>- DOUBLE<br>- STRING |
| arrsize | Length of the parameter of the array type. This field is optional.<br>Value:<br>1-100|
| desc | Parameter description. This field is mandatory.<br>Rule:<br>The description contains 3 to 128 characters, including a to z, A to Z, 0 to 9, and underscores (_).|
| desc | Parameter description. This field is mandatory.<br>Rule:<br>- A string of 3 to 128 characters.|
## How to Develop
......
# Network Management Subsystem Changelog
## request2 API Name Change
Changed the name of the HTTP streaming request from **request2** to **requestInStream**. The original name **request2** does not clearly express the intent of the API and may cause ambiguity, which does not comply with the OpenHarmony API specifications.
-
## dataProgress Event Name Change
Changed the name of the streaming data receiving event from **dataProgress** to **dataReceiveProgress**. The original name **dataProgress** does not clearly express the meaning of the event, which does not comply with the OpenHarmony API specifications.
-
**Change Impact**
For applications developed based on earlier versions, the corresponding API and event names must be updated. Otherwise, API calls may fail, affecting the service logic.
**Key API/Component Changes**
Involved APIs:
- request2;
- on(type: "dataProgress", callback: Callback<{ receiveSize: number, totalSize: number }>): void;
- off(type: "dataProgress", callback: Callback<{ receiveSize: number, totalSize: number }>): void;
Before change:
- request2(url: string, callback: AsyncCallback<number>): void;
- request2(url: string, options: HttpRequestOptions, callback: AsyncCallback<number>): void;
- request2(url: string, options?: HttpRequestOptions): Promise<number>;
- on(type: "dataProgress", callback: Callback<{ receiveSize: number, totalSize: number }>): void;
- off(type: 'dataProgress', callback?: Callback<{ receiveSize: number, totalSize: number }>): void;
After change:
- requestInStream(url: string, callback: AsyncCallback<number>): void;
- requestInStream(url: string, options: HttpRequestOptions, callback: AsyncCallback<number>): void;
- requestInStream(url: string, options?: HttpRequestOptions): Promise<number>;
- on(type: "dataReceiveProgress", callback: Callback<{ receiveSize: number, totalSize: number }>): void;
- off(type: 'dataReceiveProgress', callback?: Callback<{ receiveSize: number, totalSize: number }>): void;
**Adaptation Guide**
Replace the API name **request2** and event name **dataProgress** in the original service code with **requestInStream** and **dataReceiveProgress**, respectively.
# DFX Subsystem Changelog
## cl.hiviewdfx.1 Event Verification Specification Change for the write Method of the HiAppEvent Module
Extended the event verification specifications for the **write** method of the HiAppEvent module to support predefined events of HUAWEI Analytics. Specific changes are as follows:
- The event name can start with a dollar sign ($) and can contain uppercase letters, lowercase letters, digits, and underscores (_). Before the change, the event name can contain lowercase letters, digits, and underscores (_).
- The event parameter name can start with a dollar sign ($) and can contain uppercase letters, lowercase letters, digits, and underscores (_). Before the change, the event parameter name can contain lowercase letters, digits, and underscores (_).
**Change Impact**
More event definition formats are supported for event logging.
**Key API/Component Changes**
Involved APIs:
- hiAppEvent.write;
**Adaptation Guide**
The event verification specifications are downward compatible. No additional adaptation is required.
# Telephony Subsystem Changelog
## cl.telephony.1 VoNRState Enum Value Change of setVoNState
Changed the **VoNRState** enum values of the **setVoNState** API. The values value of **VONR_STATE_ON** is changed from **0** to **1** and that of **VONR_STATE_OFF** is defined as **0** to keep consistency with boolean values.
**Change Impact**
The new **VoNRState** enum values need to be used when **setVoNState** is called. The API function remains unchanged.
**Key API/Component Changes**
Before change:
```js
function setVoNRState(slotId: number, state: VoNRState, callback: AsyncCallback<void>): void;
/**
* @systemapi Hide this for inner system use.
* @since 10
*/
export enum VoNRState {
/** Indicates the VoNR switch is on */
VONR_STATE_ON = 0,
}
```
After change:
```js
function setVoNRState(slotId: number, state: VoNRState, callback: AsyncCallback<void>): void;
/**
* Indicates the VoNR state.
*
* @enum { number }
* @syscap SystemCapability.Telephony.CallManager
* @systemapi Hide this for inner system use.
* @since 10
*/
export enum VoNRState {
/**
* Indicates the VoNR switch is off.
*
* @syscap SystemCapability.Telephony.CallManager
* @systemapi Hide this for inner system use.
* @since 10
*/
VONR_STATE_OFF = 0,
/**
* Indicates the VoNR switch is on.
*
* @syscap SystemCapability.Telephony.CallManager
* @systemapi Hide this for inner system use.
* @since 10
*/
VONR_STATE_ON = 1,
}
```
**Adaptation Guide**
When calling **setVoNState**, use the new **VoNRState** enum values. The sample code is as follows:
```js
call.setVoNRState( 0, VONR_STATE_ON, (err) => {
if (err) {
console.log(`callback: err->${JSON.stringify(err)}`);
}
});
call.setVoNRState( 0, VONR_STATE_OFF, (err) => {
console.log(`callback: err->${JSON.stringify(err)}`);
});
```
## cl.telephony.2 Callback Value Change of setVoNState
Changed the callback value of **setVoNState** from a boolean value to **void**.
**Change Impact**
The callback value needs to be set to **void** when **setVoNState** is called.
**Key API/Component Changes**
Before change:
```js
function setVoNRState(slotId: number, state: VoNRState, callback: AsyncCallback<boolean>): void;
function setVoNRState(slotId: number, state: VoNRState): Promise<boolean>;
```
After change:
```js
function setVoNRState(slotId: number, state: VoNRState, callback: AsyncCallback<void>): void;
function setVoNRState(slotId: number, state: VoNRState): Promise<void>;
```
**Adaptation Guide**
Set the callback value to **void** when calling **setVoNState**. The sample code is as follows:
```js
call.setVoNRState( 0, VONR_STATE_ON, (err) => {
if (err) {
console.log(`callback: err->${JSON.stringify(err)}`);
}
});
call.setVoNRState( 0, VONR_STATE_OFF, (err) => {
console.log(`callback: err->${JSON.stringify(err)}`);
});
```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册