提交 b711f801 编写于 作者: S shawn_he

update doc

Signed-off-by: Nshawn_he <shawn.he@huawei.com>
上级 c468f725
# HiLog Development (Native) # HiLog Development (Native)
## Introduction ## Introduction
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. 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.
> **NOTE** > **NOTE**
>
> This development guide is applicable only when you use Native APIs for application development. For details about the APIs, see [HiLog Native API Reference](../reference/native-apis/_hi_log.md). > This development guide is applicable only when you use Native APIs for application development. For details about the APIs, see [HiLog Native API Reference](../reference/native-apis/_hi_log.md).
## Available APIs ## Available APIs
| API/Macro| Description| | API/Macro| Description|
| -------- | -------- | | -------- | -------- |
| int OH_LOG_Print(LogType type, LogLevel level, unsigned int domain, const char *tag, const char *fmt, ...) | Outputs logs based on the specified log type, log level, service domain, log tag, and variable parameters determined by the format specifier and privacy identifier in the printf format.<br>Input arguments: See [Parameter Description](#parameter-description).<br>Output arguments: None<br>Return value: total number of bytes if log printing is successful; **-1** otherwise.| | int OH_LOG_Print(LogType type, LogLevel level, unsigned int domain, const char *tag, const char *fmt, ...) | Outputs logs based on the specified log type, log level, service domain, log tag, and variable parameters determined by the format specifier and privacy identifier in the printf format.<br>Input arguments: See [Parameter Description](#parameter-description).<br>Output arguments: None<br>Return value: total number of bytes if log printing is successful; **-1** otherwise.|
| #define OH_LOG_DEBUG(type, ...) ((void)OH_LOG_Print((type), LOG_DEBUG, LOG_DOMAIN, LOG_TAG, \_*VA*ARGS__))| Outputs DEBUG logs. This is a function-like macro.| | #define OH_LOG_DEBUG(type, ...) ((void)OH_LOG_Print((type), LOG_DEBUG, LOG_DOMAIN, LOG_TAG, \__VA_ARGS__))| Outputs DEBUG logs. This is a function-like macro.|
| #define OH_LOG_INFO(type, ...) ((void)OH_LOG_Print((type), LOG_INFO, LOG_DOMAIN, LOG_TAG, \_*VA*ARGS__)) | Outputs INFO logs. This is a function-like macro.| | #define OH_LOG_INFO(type, ...) ((void)OH_LOG_Print((type), LOG_INFO, LOG_DOMAIN, LOG_TAG, \__VA_ARGS__)) | Outputs INFO logs. This is a function-like macro.|
| #define OH_LOG_WARN(type, ...) ((void)OH_LOG_Print((type), LOG_WARN, LOG_DOMAIN, LOG_TAG, \_*VA*ARGS__)) | Outputs WARN logs. This is a function-like macro.| | #define OH_LOG_WARN(type, ...) ((void)OH_LOG_Print((type), LOG_WARN, LOG_DOMAIN, LOG_TAG, \__VA_ARGS__)) | Outputs WARN logs. This is a function-like macro.|
| #define OH_LOG_ERROR(type, ...) ((void)OH_LOG_Print((type), LOG_ERROR, LOG_DOMAIN, LOG_TAG, \_*VA*ARGS__)) | Outputs ERROR logs. This is a function-like macro.| | #define OH_LOG_ERROR(type, ...) ((void)OH_LOG_Print((type), LOG_ERROR, LOG_DOMAIN, LOG_TAG, \__VA_ARGS__)) | Outputs ERROR logs. This is a function-like macro.|
| #define OH_LOG_FATAL(type, ...) ((void)OH_LOG_Print((type), LOG_FATAL, LOG_DOMAIN, LOG_TAG, \_*VA*ARGS__)) | Outputs FATAL logs. This is a function-like macro.| | #define OH_LOG_FATAL(type, ...) ((void)OH_LOG_Print((type), LOG_FATAL, LOG_DOMAIN, LOG_TAG, \__VA_ARGS__)) | Outputs FATAL logs. This is a function-like macro.|
| bool OH_LOG_IsLoggable(unsigned int domain, const char *tag, LogLevel level) | Checks whether logs of the specified service domain, tag, and level can be printed.<br>Input arguments: See [Parameter Description](#parameter-description).<br>Output arguments: none<br>Return value: **true** if the specified logs can be printed; **false** otherwise.| | bool OH_LOG_IsLoggable(unsigned int domain, const char *tag, LogLevel level) | Checks whether logs of the specified service domain, tag, and level can be printed.<br>Input arguments: See [Parameter Description](#parameter-description).<br>Output arguments: none<br>Return value: **true** if the specified logs can be printed; **false** otherwise.|
## Parameter Parsing
## Parameter Description
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------------------------------ | | ------ | ------ | ---- | ------------------------------------------------------------ |
...@@ -30,9 +24,7 @@ HiLog is the log system of OpenHarmony that provides logging for the system fram ...@@ -30,9 +24,7 @@ HiLog is the log system of OpenHarmony that provides logging for the system fram
| tag | string | Yes | Log tag in the string format. You are advised to use this parameter to identify a particular service behavior or the class holding the ongoing method.| | tag | string | Yes | Log tag in the string format. You are advised to use this parameter to identify a particular service behavior or the class holding the ongoing method.|
| fmt | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory.<br>Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by **\<private>**.| | fmt | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory.<br>Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by **\<private>**.|
| args | any[] | Yes | Variable-length parameter list corresponding to the format string. The number and type of parameters must map to the identifier in the format string.| | args | any[] | Yes | Variable-length parameter list corresponding to the format string. The number and type of parameters must map to the identifier in the format string.|
## LogLevel ## LogLevel
Log level. Log level.
| Name | Value | Description | | Name | Value | Description |
...@@ -42,9 +34,7 @@ Log level. ...@@ -42,9 +34,7 @@ Log level.
| WARN | 5 | Log level used to record severe, unexpected faults that have little impact on users and can be rectified by the programs themselves or through simple operations.| | WARN | 5 | Log level used to record severe, unexpected faults that have little impact on users and can be rectified by the programs themselves or through simple operations.|
| ERROR | 6 | Log level used to record program or functional errors that affect the normal running or use of the functionality and can be fixed at a high cost, for example, by resetting data.| | ERROR | 6 | Log level used to record program or functional errors that affect the normal running or use of the functionality and can be fixed at a high cost, for example, by resetting data.|
| FATAL | 7 | Log level used to record program or functionality crashes that cannot be rectified. | FATAL | 7 | Log level used to record program or functionality crashes that cannot be rectified.
## Development Example ## Development Example
1. Add the link of **libhilog_ndk.z.so** to **CMakeLists.txt**: 1. Add the link of **libhilog_ndk.z.so** to **CMakeLists.txt**:
``` ```
target_link_libraries(entry PUBLIC libhilog_ndk.z.so) target_link_libraries(entry PUBLIC libhilog_ndk.z.so)
......
...@@ -179,18 +179,18 @@ import featureAbility from '@ohos.ability.featureAbility' ...@@ -179,18 +179,18 @@ import featureAbility from '@ohos.ability.featureAbility'
let context = featureAbility.getContext(); let context = featureAbility.getContext();
context.getFilesDir().then((data) => { context.getFilesDir().then((data) => {
var path = data + "/serviceInfo.txt" var path = data + "/serviceInfo.txt";
console.info("output path: " + path) console.info("output path: " + path);
let fd = fs.openSync(path, 0o102, 0o666) let file = fs.openSync(path, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
var serviceId = 10 var serviceId = 10;
var args = new Array("allInfo") var args = new Array("allInfo");
try { try {
hidebug.getServiceDump(serviceId, fd, args) hidebug.getServiceDump(serviceId, file.fd, args);
} catch (error) { } catch (error) {
console.info(error.code) console.info(error.code);
console.info(error.message) console.info(error.message);
} }
fs.closeSync(fd); fs.closeSync(file);
}) })
``` ```
......
...@@ -16,7 +16,7 @@ import http from '@ohos.net.http'; ...@@ -16,7 +16,7 @@ import http from '@ohos.net.http';
## Examples ## Examples
```js ```js
// Import the HTTP namespace. // Import the http namespace.
import http from '@ohos.net.http'; import http from '@ohos.net.http';
// Each httpRequest corresponds to an HTTP request task and cannot be reused. // Each httpRequest corresponds to an HTTP request task and cannot be reused.
...@@ -35,17 +35,17 @@ httpRequest.request( ...@@ -35,17 +35,17 @@ httpRequest.request(
header: { header: {
'Content-Type': 'application/json' 'Content-Type': 'application/json'
}, },
// This field is used to transfer data when the POST request is used. // This parameter is used to transfer data when the POST request is used.
extraData: { extraData: {
"data": "data to send", "data": "data to send",
}, },
expectDataType: http.HttpDataType.STRING, // Optional. This field specifies the type of the return data. expectDataType: http.HttpDataType.STRING, // Optional. This parameter specifies the type of the return data.
usingCache: true, // Optional. The default value is true. usingCache: true, // Optional. The default value is true.
priority: 1, // Optional. The default value is 1. priority: 1, // Optional. The default value is 1.
connectTimeout: 60000 // Optional. The default value is 60000, in ms. connectTimeout: 60000 // Optional. The default value is 60000, in ms.
readTimeout: 60000, // Optional. The default value is 60000, in ms. readTimeout: 60000, // Optional. The default value is 60000, in ms.
usingProtocol: http.HttpProtocol.HTTP1_1, // Optional. The default protocol type is automatically specified by the system. usingProtocol: http.HttpProtocol.HTTP1_1, // Optional. The default protocol type is automatically specified by the system.
usingProxy: false, // Optional. By default, network proxy is not used. This field is supported since API 10. usingProxy: false, // Optional. By default, network proxy is not used. This field is supported since API version 10.
caPath: "", // Optional. The preset CA certificate is used by default. This field is supported since API version 10. caPath: "", // Optional. The preset CA certificate is used by default. This field is supported since API version 10.
}, (err, data) => { }, (err, data) => {
if (!err) { if (!err) {
...@@ -55,13 +55,13 @@ httpRequest.request( ...@@ -55,13 +55,13 @@ httpRequest.request(
// data.header carries the HTTP response header. Parse the content based on service requirements. // data.header carries the HTTP response header. Parse the content based on service requirements.
console.info('header:' + JSON.stringify(data.header)); console.info('header:' + JSON.stringify(data.header));
console.info('cookies:' + JSON.stringify(data.cookies)); // 8+ console.info('cookies:' + JSON.stringify(data.cookies)); // 8+
// Call the destroy() method to release resources after HttpRequest is complete. // Call the destroy() method to release resources after the HttpRequest is complete.
httpRequest.destroy(); httpRequest.destroy();
} else { } else {
console.info('error:' + JSON.stringify(err)); console.info('error:' + JSON.stringify(err));
// Unsubscribe from HTTP Response Header events. // Unsubscribe from HTTP Response Header events.
httpRequest.off('headersReceive'); httpRequest.off('headersReceive');
// Call the destroy() method to release resources after HttpRequest is complete. // Call the destroy() method to release resources after the HttpRequest is complete.
httpRequest.destroy(); httpRequest.destroy();
} }
} }
...@@ -75,7 +75,7 @@ httpRequest.request( ...@@ -75,7 +75,7 @@ httpRequest.request(
createHttp(): HttpRequest createHttp(): HttpRequest
Creates an HTTP request. You can use this API to initiate or destroy an HTTP request, or enable or disable listening for HTTP Response Header events. An HttpRequest object corresponds to an HTTP request. To initiate multiple HTTP requests, you must create an **HttpRequest** object for each HTTP request. Creates an HTTP request. You can use this API to initiate or destroy an HTTP request, or enable or disable listening for HTTP Response Header events. An **HttpRequest** object corresponds to an HTTP request. To initiate multiple HTTP requests, you must create an **HttpRequest** object for each HTTP request.
> **NOTE** > **NOTE**
> Call the **destroy()** method to release resources after the HttpRequest is complete. > Call the **destroy()** method to release resources after the HttpRequest is complete.
...@@ -437,7 +437,7 @@ httpRequest.request2("EXAMPLE_URL", (err, data) => { ...@@ -437,7 +437,7 @@ httpRequest.request2("EXAMPLE_URL", (err, data) => {
request2(url: string, options: HttpRequestOptions, callback: AsyncCallback\<number\>): void request2(url: string, options: HttpRequestOptions, callback: AsyncCallback\<number\>): void
Initiates an HTTP request to a given URL. This API uses an asynchronous callback to return the result, which is a streaming response. 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.
**Required permissions**: ohos.permission.INTERNET **Required permissions**: ohos.permission.INTERNET
...@@ -572,7 +572,7 @@ Initiates an HTTP request containing specified options to a given URL. This API ...@@ -572,7 +572,7 @@ Initiates an HTTP request containing specified options to a given URL. This API
> **NOTE** > **NOTE**
> For details about the error codes, see [HTTP Error Codes](../errorcodes/errorcode-net-http.md). > For details about the error codes, see [HTTP Error Codes](../errorcodes/errorcode-net-http.md).
> The HTTP error code mapping is in the format of 2300000 + Curl error code. For more common error codes, see: > The HTTP error code mapping is in the format of 2300000 + Curl error code. For more common error codes, see [Curl Error Codes](https://curl.se/libcurl/c/libcurl-errors.html).
**Example** **Example**
...@@ -599,7 +599,7 @@ on(type: 'headerReceive', callback: AsyncCallback\<Object\>): void ...@@ -599,7 +599,7 @@ on(type: 'headerReceive', callback: AsyncCallback\<Object\>): void
Registers an observer for HTTP Response Header events. Registers an observer for HTTP Response Header events.
> **NOTE** > **NOTE**
> This API has been deprecated. You are advised to use [on('headersReceive')<sup>8+</sup>](#onheadersreceive8) instead. > This API has been deprecated. You are advised to use [on('headersReceive')<sup>8+</sup>](#onheadersreceive8).
**System capability**: SystemCapability.Communication.NetStack **System capability**: SystemCapability.Communication.NetStack
...@@ -626,7 +626,7 @@ Unregisters the observer for HTTP Response Header events. ...@@ -626,7 +626,7 @@ Unregisters the observer for HTTP Response Header events.
> **NOTE** > **NOTE**
> >
>1. This API has been deprecated. You are advised to use [off('headersReceive')<sup>8+</sup>](#offheadersreceive8) instead. >1. This API has been deprecated. You are advised to use [off('headersReceive')<sup>8+</sup>](#offheadersreceive8).
> >
>2. You can pass the callback of the **on** function if you want to cancel listening for a certain type of event. If you do not pass the callback, you will cancel listening for all events. >2. You can pass the callback of the **on** function if you want to cancel listening for a certain type of event. If you do not pass the callback, you will cancel listening for all events.
...@@ -831,7 +831,7 @@ Registers an observer for events indicating progress of receiving HTTP streaming ...@@ -831,7 +831,7 @@ Registers an observer for events indicating progress of receiving HTTP streaming
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | --------------------------------- | | -------- | ----------------------- | ---- | --------------------------------- |
| type | string | Yes | Event type. The value is **dataProgress**.| | type | string | Yes | Event type. The value is **dataProgress**.|
| 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.| | 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** **Example**
...@@ -910,7 +910,7 @@ Enumerates the response codes for an HTTP request. ...@@ -910,7 +910,7 @@ Enumerates the response codes for an HTTP request.
| Name | Value | Description | | Name | Value | Description |
| ----------------- | ---- | ------------------------------------------------------------ | | ----------------- | ---- | ------------------------------------------------------------ |
| OK | 200 | "OK." The request has been processed successfully. This return code is generally used for GET and POST requests. | | OK | 200 | The request is successful. The request has been processed successfully. This return code is generally used for GET and POST requests. |
| CREATED | 201 | "Created." The request has been successfully sent and a new resource is created. | | CREATED | 201 | "Created." The request has been successfully sent and a new resource is created. |
| ACCEPTED | 202 | "Accepted." The request has been accepted, but the processing has not been completed. | | ACCEPTED | 202 | "Accepted." The request has been accepted, but the processing has not been completed. |
| NOT_AUTHORITATIVE | 203 | "Non-Authoritative Information." The request is successful. | | NOT_AUTHORITATIVE | 203 | "Non-Authoritative Information." The request is successful. |
......
...@@ -14,7 +14,7 @@ Invalid parameter value. ...@@ -14,7 +14,7 @@ Invalid parameter value.
This error code is reported if the parameter value is invalid. This error code is reported if the parameter value is invalid.
**Cause** **Possible Cause**
The input parameter value is not within the valid value range. The input parameter value is not within the valid value range.
...@@ -32,7 +32,7 @@ Operation failed. Cannot connect to service. ...@@ -32,7 +32,7 @@ Operation failed. Cannot connect to service.
This error code is reported if a service connection failure occurs. This error code is reported if a service connection failure occurs.
**Cause** **Possible Cause**
The service is abnormal. The service is abnormal.
...@@ -48,9 +48,9 @@ System internal error. ...@@ -48,9 +48,9 @@ System internal error.
**Description** **Description**
This error code is reported if a system internal error occurs. An internal system error occurs.
**Cause** **Possible Cause**
1. The memory is abnormal. 1. The memory is abnormal.
...@@ -72,7 +72,7 @@ The device information does not exist. ...@@ -72,7 +72,7 @@ The device information does not exist.
This error code is reported if the device information does not exist. This error code is reported if the device information does not exist.
**Cause** **Possible Cause**
The device to set or obtain does not exist. The device to set or obtain does not exist.
...@@ -93,7 +93,7 @@ Device disconnected. ...@@ -93,7 +93,7 @@ Device disconnected.
This error code is reported if the device is not connected. This error code is reported if the device is not connected.
**Cause** **Possible Cause**
The network interface card (NIC) is faulty. The network interface card (NIC) is faulty.
...@@ -111,7 +111,7 @@ Failed to write the user configuration. ...@@ -111,7 +111,7 @@ Failed to write the user configuration.
This error code is reported if an error occurs while writing data to the user configuration file. This error code is reported if an error occurs while writing data to the user configuration file.
**Cause** **Possible Cause**
The system reports an error. The system reports an error.
......
...@@ -182,12 +182,12 @@ The table below provides only the sites for downloading the latest OpenHarmony L ...@@ -182,12 +182,12 @@ The table below provides only the sites for downloading the latest OpenHarmony L
| Hi3516 solution-Linux (binary)| 3.0 | [Download](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_taurus_linux.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_taurus_linux.tar.gz.sha256) | 418.1 MB | | Hi3516 solution-Linux (binary)| 3.0 | [Download](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_taurus_linux.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_taurus_linux.tar.gz.sha256) | 418.1 MB |
| RELEASE-NOTES | 3.0 | [Download](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.0-LTS/en/release-notes/OpenHarmony-v3.0-LTS.md)| - | - | | RELEASE-NOTES | 3.0 | [Download](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.0-LTS/en/release-notes/OpenHarmony-v3.0-LTS.md)| - | - |
| **Source Code of the Latest Release**| **Version**| **Site**| **SHA-256 Checksum**| **Software Package Size**| | **Source Code of the Latest Release**| **Version**| **Site**| **SHA-256 Checksum**| **Software Package Size**|
| Full code base (for mini, small, and standard systems)| 3.2 Release | [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Release/code-v3.2-Release.tar.gz)| [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Release/code-v3.2-Release.tar.gz.sha256)| 21.8 GB | | Full code base (for mini, small, and standard systems) | 4.0 Beta1 | [Download](https://repo.huaweicloud.com/openharmony/os/4.0-Beta1/code-v4.0-Beta1.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/4.0-Beta1/code-v4.0-Beta1.tar.gz.sha256)| 26.2 GB |
| Hi3861 solution (binary) | 3.2 Release| [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Release/hispark_pegasus.tar.gz)| [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Release/hispark_pegasus.tar.gz.sha256)| 22.9 MB | | Hi3861 solution (binary) | 4.0 Beta1 | [Download](https://repo.huaweicloud.com/openharmony/os/4.0-Beta1/hispark_pegasus.tar.gz) | [Download](https://repo.huaweicloud.com/openharmony/os/4.0-Beta1/hispark_pegasus.tar.gz.sha256)| 25.1 MB |
| Hi3516 solution-LiteOS (binary)| 3.2 Release| [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Release/hispark_taurus_LiteOS.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Release/hispark_taurus_LiteOS.tar.gz.sha256)| 294.3 MB | | Hi3516 solution-LiteOS (binary)| 4.0 Beta1 | [Download](https://repo.huaweicloud.com/openharmony/os/4.0-Beta1/hispark_taurus_LiteOS.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/4.0-Beta1/hispark_taurus_LiteOS.tar.gz.sha256)| 287.6 MB |
| Hi3516 solution-Linux (binary) | 3.2 Release| [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Release/hispark_taurus_Linux.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Release/hispark_taurus_Linux.tar.gz.sha256)| 174.3 MB | | Hi3516 solution-Linux (binary) | 4.0 Beta1 | [Download](https://repo.huaweicloud.com/openharmony/os/4.0-Beta1/hispark_taurus_Linux.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/4.0-Beta1/hispark_taurus_Linux.tar.gz.sha256)| 186.4 MB |
| RK3568 standard system solution (binary) | 3.2 Release| [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Release//dayu200_standard_arm32.tar.gz)| [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Release//dayu200_standard_arm32.tar.gz.sha256)| 3.9 GB | | RK3568 standard system solution (binary) | 4.0 Beta1 | [Download](https://repo.huaweicloud.com/openharmony/os/4.0-Beta1/dayu200_standard_arm32.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/4.0-Beta1/dayu200_standard_arm32.tar.gz.sha256)| 4.5 GB |
| RELEASE-NOTES | 3.2 Release| [Download](../../release-notes/OpenHarmony-v3.2-release.md)| - | - | | RELEASE-NOTES | 4.0 Beta1 | [Download](../../release-notes/OpenHarmony-v4.0-beta1.md)| - | - |
| **Compiler Toolchain**| **Version**| **Site**| **SHA-256 Checksum**| **Software Package Size**| | **Compiler Toolchain**| **Version**| **Site**| **SHA-256 Checksum**| **Software Package Size**|
| Compiler toolchain| - | [Download](https://repo.huaweicloud.com/openharmony/os/2.0/tool_chain/)| - | - | | Compiler toolchain| - | [Download](https://repo.huaweicloud.com/openharmony/os/2.0/tool_chain/)| - | - |
......
# Location Subsystem Changelog
## cl.location.1 Deletion of the geoLocationManager.requestEnableLocation API in API Version 9
When the location function is disabled, your application can call the **geoLocationManager.requestEnableLocation** API to request the user to enable the location function. However, this API is seldom used, and user experience for this API is not very good because the user is not notified of the scenario in which your application uses the location information.
Therefore, your app shows a popup, asking the user to go to the settings page and enable the location function. In addition, the popup clearly states the scenarios in which the location information will be used, improving user experience.
**Change Impact**
Your application cannot use the **geoLocationManager.requestEnableLocation** API in API version 9 to request the user to enable the location function. Instead, you need to implement a popup asking the user to enable the location function for your application.
**Key API/Component Changes**
| Class| API Type| Declaration| Change Type|
| -- | -- | -- | -- |
|geoLocationManager| method | function requestEnableLocation(callback: AsyncCallback&lt;boolean&gt;): void; | Deleted from API version 9. |
|geoLocationManager| method | function requestEnableLocation(): Promise&lt;boolean&gt;; | Deleted from API version 9. |
# Globalization Subsystem Changelog # Globalization Subsystem Changelog
## cl.global.1 Runtime Authentication Added for System APIs
The internationalization component of the globalization subsystem adds runtime authentication for system APIs in certain scenarios. The following changes are made in API version 9 and later:
- Setting the system language, country or region, and area
- Setting the 24-hour format of the system
- Adding and removing the preferred language
- Setting localized numbers
You need to adapt your application based on the following information.
**Change Impact**
APIs involved in the preceding scenarios can be properly called only by system applications that have the **UPDATE_CONFIGURATION** permission.
**Key API/Component Changes**
- Involved APIs:
- setSystemLanguage(language: string): void;
- setSystemRegion(region: string): void;
- setSystemLocale(locale: string): void;
- set24HourClock(option: boolean): void;
- addPreferredLanguage(language: string, index?: number): void;
- removePreferredLanguage(index: number): void;
- setUsingLocalDigit(flag: boolean): void;
**Adaptation Guide**
Make sure the application trying to call any of the above APIs is a system application. Non-system applications are not allowed to call the APIs.
An exception will be thrown upon lack of a necessary permission or a call request from a non-system application. The exception can be captured via **try-catch**.
```js
import I18n from '@ohos.i18n'
try {
I18n.System.setSystemLanguage('zh');
} catch(error) {
console.error(`call System.setSystemLanguage failed, error code: ${error.code}, message: ${error.message}.`)
}
```
## cl.resourceManager.1 Change in the Meaning of the Return Value for the API Used to Obtain the rawfile Descriptor ## cl.resourceManager.1 Change in the Meaning of the Return Value for the API Used to Obtain the rawfile Descriptor
...@@ -67,11 +27,13 @@ In versions earlier than 4.0.2.2, the rawfile can be accessed only through **fd* ...@@ -67,11 +27,13 @@ In versions earlier than 4.0.2.2, the rawfile can be accessed only through **fd*
**Key API/Component Changes** **Key API/Component Changes**
- Involved APIs: | **Original API** |
- getRawFd(path: string, callback: AsyncCallback\<RawFileDescriptor>): void | ---------------- |
- getRawFd(path: string): Promise\<RawFileDescriptor> | getRawFd(path: string, callback: AsyncCallback\<RawFileDescriptor>): void |
- getRawFileDescriptor(path: string, callback: AsyncCallback\<RawFileDescriptor>): void | getRawFd(path: string): Promise\<RawFileDescriptor> |
- getRawFileDescriptor(path: string): Promise\<RawFileDescriptor> | getRawFileDescriptor(path: string, callback: AsyncCallback\<RawFileDescriptor>): void|
| getRawFileDescriptor(path: string): Promise\<RawFileDescriptor>|
||
**Sample Code** **Sample Code**
......
# Power Subsystem Changelog
## cl.powermgr.1 CommonEventBatteryChangedCode API Change
Changed the **CommonEventBatteryChangedCode** enum class in [@ohos.batteryInfo](../../../application-dev/reference/apis/js-apis-battery-info.md) as follows:
- Changed the class name to **CommonEventBatteryChangedKey**.
- Deleted **EXTRA_MAX_CURRENT**, **EXTRA_MAX_VOLTAGE**, and **EXTRA_CHARGE_COUNTER**.
- Changed the enum value type from numeric to string.
#### **Change Impact**
The JS API needs to be adapted for applications developed based on earlier versions. Otherwise, relevant functions will be affected.
#### Key API/Component Changes
Before change:
| Name | Value | Description |
| -------------------- | ---- | -------------------------------------------------- |
| EXTRA_SOC | 0 | Remaining battery level in percentage. |
| EXTRA_VOLTAGE | 1 | Battery voltage of the device. |
| EXTRA_TEMPERATURE | 2 | Battery temperature of the device. |
| EXTRA_HEALTH_STATE | 3 | Battery health status of the device. |
| EXTRA_PLUGGED_TYPE | 4 | Type of the charger connected to the device. |
| EXTRA_MAX_CURRENT | 5 | Maximum battery current of the device. |
| EXTRA_MAX_VOLTAGE | 6 | Maximum battery voltage of the device. |
| EXTRA_CHARGE_STATE | 7 | Battery charging status of the device. |
| EXTRA_CHARGE_COUNTER | 8 | Number of battery charging times of the device. |
| EXTRA_PRESENT | 9 | Whether the battery is supported by the device or installed.|
| EXTRA_TECHNOLOGY | 10 | Battery technology of the device. |
| EXTRA_CAPACITY_LEVEL | 11 | Battery level of the device. |
After change:
| Name | Value | Description |
| -------------------- | --------------- | -------------------------------------------------- |
| EXTRA_SOC | "soc" | Remaining battery level in percentage. |
| EXTRA_CHARGE_STATE | "chargeState" | Battery charging status of the device. |
| EXTRA_HEALTH_STATE | "healthState" | Battery health status of the device. |
| EXTRA_PLUGGED_TYPE | "pluggedType" | Type of the charger connected to the device. |
| EXTRA_VOLTAGE | "voltage" | Battery voltage of the device. |
| EXTRA_TECHNOLOGY | "technology" | Battery technology of the device. |
| EXTRA_TEMPERATURE | "temperature" | Battery temperature of the device. |
| EXTRA_PRESENT | "present" | Whether the battery is supported by the device or installed.|
| EXTRA_CAPACITY_LEVEL | "capacityLevel" | Battery level of the device. |
#### Adaptation Guide
For details, see the API reference of the [@ohos.batteryInfo](../../../application-dev/reference/apis/js-apis-battery-info.md) API.
## cl.powermgr.2 estimatedRemainingChargeTime API Change
Changed the **estimatedRemainingChargeTime** API in [@ohos.batteryInfo](../../../application-dev/reference/apis/js-apis-battery-info.md) to a system API.
#### **Change Impact**
The JS API needs to be adapted for applications developed based on earlier versions. Otherwise, relevant functions will be affected.
#### Adaptation Guide
For details, see the API reference of the [@ohos.batteryInfo](../../../application-dev/reference/apis/js-apis-battery-info.md) API.
## cl.powermgr.3 System Common Event Behavior Change
The following common events are provided in the battery information through [@ohos.commonEventManager (common event module)](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-commonEventManager.md):
- COMMON_EVENT_BATTERY_LOW: common event for low battery level. It includes the remaining battery in percentage.
- COMMON_EVENT_BATTERY_OKAY: common event for normal battery level. It includes the remaining battery in percentage.
- COMMON_EVENT_POWER_CONNECTED: common event for connection to an external power supply. It includes the type of the power supply to which the device is connected.
- COMMON_EVENT_POWER_DISCONNECTED: common event for disconnection from an external power supply. It includes the type of the power supply from which the device is disconnected.
- COMMON_EVENT_CHARGING: common event for starting of battery charging. It includes the battery charging status.
- COMMON_EVENT_DISCHARGING: common event for ending of battery charging. It includes the battery charging status.
Changed the method of obtaining data from common events from **CommonEventData.data** to **CommonEventData.code**.
#### **Change Impact**
The application developed based on earlier versions needs to adapt the method for obtaining common events in the battery information. Otherwise, the original service logic will be affected.
#### Adaptation Guide
For details, see the API reference of the [@ohos.commonEventManager (Common Event Manager)](../../../application-dev/reference/apis/js-apis-commonEventManager.md) API.
# Startup Subsystem JS API Changelog
## cl.startup.1 Bundle Name Change
**Change Impact**
The original bundle name **@ohos.systemParameterV9** will be deleted and cannot be used anymore. Use the new bundle name **@ohos.systemParameterEnhance** instead.
**Adaptation Guide**
Change the bundle name from **@ohos.systemParameterV9** to **@ohos.systemParameterEnhance**. The APIs remain unchanged. The following is the sample code:
```js
import @ohos.systemParameterEnhance
```
# Telephony Subsystem Changelog
## cl.telephony.radio.1 isNrSupported API Change
NR is a proper noun and must be capitalized.
You need to adapt your application based on the following information.
**Change Impact**
The JS API needs to be adapted for applications developed based on earlier versions. Otherwise, relevant functions will be affected.
**Key API/Component Changes**
- Involved APIs:
isNrSupported(): boolean;
isNrSupported(slotId: number): boolean;
- Before change:
```js
function isNrSupported(): boolean;
function isNrSupported(slotId: number): boolean;
```
- After change:
```js
function isNRSupported(): boolean;
function isNRSupported(slotId: number): boolean;
```
**Adaptation Guide**
Use the new API. The sample code is as follows:
```js
let result = radio.isNrSupported();
console.log("Result: "+ result);
```
```js
let slotId = 0;
let result = radio.isNRSupported(slotId);
console.log("Result: "+ result);
```
## cl.telephony.call.2 dial API Change
Changed the `dial` API to the `dialCall` API in the call module of the telephony subsystem since API version 9.
You need to adapt your application based on the following information.
**Change Impact**
The `dial` API is deprecated and cannot be used anymore. Use the `dialCall` API instead. Otherwise, relevant functions will be affected.
**Key API/Component Changes**
- Involved APIs:
dial(phoneNumber: string, callback: AsyncCallback<boolean>): void;
dial(phoneNumber: string, options: DialOptions, callback: AsyncCallback<boolean>): void;
dial(phoneNumber: string, options?: DialOptions): Promise<boolean>;
- Before change:
```js
function dial(phoneNumber: string, callback: AsyncCallback<boolean>): void;
function dial(phoneNumber: string, options: DialOptions, callback: AsyncCallback<boolean>): void;
function dial(phoneNumber: string, options?: DialOptions): Promise<boolean>;
```
- After change:
```js
function dialCall(phoneNumber: string, callback: AsyncCallback<void>): void;
function dialCall(phoneNumber: string, options: DialCallOptions, callback: AsyncCallback<void>): void;
function dialCall(phoneNumber: string, options?: DialCallOptions): Promise<void>;
```
**Adaptation Guide**
The `dial` API is deprecated and cannot be used anymore. Use the `dialCall` API instead.
Use the new API. The sample code is as follows:
```js
call.dialCall("138xxxxxxxx", (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
```js
call.dialCall("138xxxxxxxx", {
accountId: 0,
videoState: 0,
dialScene: 0,
dialType: 0,
}, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
```js
try {
call.dialCall('138xxxxxxxx');
console.log(`dialCall success, promise: data->${JSON.stringify(data)}`);
} catch (error) {
console.log(`dialCall fail, promise: err->${JSON.stringify(error)}`);
}
```
# USB Subsystem API Changelog
## cl.usb_manager.1 System API Change
Runtime authentication is performed for system APIs of the USB manager. An asynchronous API throws an error code via **Promise.reject**.
If your application is developed based on earlier versions, modify the return values of functions. Otherwise, the original service logic will be affected.
**Key API/Component Changes**
| Bundle Name | Original API | New API |
| --------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| ohos.usbV9.d.ts | function setCurrentFunctions(funcs: FunctionType): Promise<boolean>; | function setCurrentFunctions(funcs: FunctionType): Promise<void>; |
| ohos.usbV9.d.ts | function setPortRoles(portId: number, powerRole: PowerRoleType, dataRole: DataRoleType): Promise<boolean>; | function setPortRoles(portId: number, powerRole: PowerRoleType, dataRole: DataRoleType): Promise<void>; |
## cl.usb_manager.2 SDK API Deletion
The **@ohos.usbV9.d.ts** file was deleted in OpenHarmony 4.0.5.5.
You need to import **@ohos.usbManager** to use USB service APIs.
```ts
import usbManager from '@ohos.usbManager';
```
**Adaptation Guide**
For details, see the [API Reference](../../../application-dev/reference/apis/js-apis-usbManager.md).
## cl.usb_manager.2 Bundle Name Change
For applications developed based on earlier versions, you need to change the name of the imported bundle. Otherwise, the original service logic will be affected.
**Key API/Component Changes**
| Original Bundle | New Bundle |
|------------------ | ------------------- |
| ohos.usbV9.d.ts | ohos.usbManager.d.ts |
**Adaptation Guide**
Change **@ohos.usbV9** to **@ohos.usbManager** when importing the bundle.
## cl.usb_manager.3 API Parameter Type Change
For applications developed based on earlier versions, you need to modify the parameter type. Otherwise, the original service logic will be affected.
**Key API/Component Changes**
| Original Class Name | New Class Name |
|---------------| ------------- |
| interface USBConfig | interface USBConfiguration |
| Original Namespace | New Namespace |
|---------------| ------------- |
| @namespace usbV9 | @namespace usbManager |
| Bundle Name | Original API | New API |
| --------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| ohos.usbManager.d.ts | function setConfiguration(pipe: USBDevicePipe, config: USBConfig): number; | function setConfiguration(pipe: USBDevicePipe, config: USBConfiguration): number; |
**Adaptation Guide**
When calling **setConfiguration**, change the parameter type from **USBConfig** to **USBConfiguration**.
## cl.usb_manager.4 SDK API Deletion
For applications developed based on earlier versions, you need to change the name of the imported bundle. Otherwise, the original service logic will be affected.
**Key API/Component Changes**
The **@ohos.usbV9.d.ts** file is replaced by the **@ohos.usbManager.d.ts** file.
| New Bundle | Original Bundle | Deleted Bundle |
| -------------------- | ------------- | --------------- |
| ohos.usbManager.d.ts | ohos.usb.d.ts | ohos.usbV9.d.ts |
You need to import **@ohos.usbManager** to use USB service APIs.
```ts
import usbManager from '@ohos.usbManager';
```
**Adaptation Guide**
For details, see the [API Reference](../../../application-dev/reference/apis/js-apis-usbManager.md).
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册