@@ -123,10 +137,11 @@ Prints error information in formatted output mode.
| Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ----------- |
| message | string | Yes | Error information to be printed.|
| arguments | any | No | Arguments in the message or other information to be printed.|
| arguments | any[] | No | Arguments in the message or other information to be printed.|
**Example**
```js
conststr="value is not defined";
console.error('error: %d',str);// Print the error information with arguments in the message replaced.
...
...
@@ -153,6 +168,7 @@ Prints assertion information.
| arguments | Object | No | Other information to be printed when **value** is **false**. If this parameter is left blank, other information is not printed.|
**Example**
```js
console.assert(true,'does nothing');// Do not print error information as value is true.
console.assert(2%1==0,'does nothing');// Do not print error information as value is true.
...
...
@@ -180,6 +196,7 @@ Maintains an internal counter. When this counter is invoked, its label name and
**Example**
```js
console.count()
// default: 1
...
...
@@ -210,6 +227,7 @@ Resets a counter based on the specified label name.
| label | string | No | Counter label name. The default value is **default**.|
**Example**
```js
console.count('abc');
// abc: 1
...
...
@@ -234,6 +252,7 @@ Prints content of the specified object.
**Example**
```js
leta={foo:{bar:{baz:true}}};
console.dir(a);
...
...
@@ -258,6 +277,7 @@ Displays an interactive tree of the descendant elements of the specified XML ele
| arguments | Object | Yes | Information to be printed.|
**Example**
```js
constnumber=5;
console.dirxml('count: %d',number);
...
...
@@ -284,6 +304,7 @@ If the information to be printed is provided, the information is printed without
| arguments | Object | No | Information to be printed.|
**Example**
```js
console.log("outter");
// outter
...
...
@@ -313,6 +334,7 @@ Creates a new inline group in collapsed mode. The usage and function of this API
**Example**
```js
console.groupCollapsed("outter");
// outter
...
...
@@ -335,6 +357,7 @@ Reduces the indentation of subsequent lines by two spaces.
**Example**
```js
console.log("outter");
// outter
...
...
@@ -362,6 +385,7 @@ Prints data in a table.
| tableData | Object | No | Data to be printed in a table. If this parameter is left blank, no information is printed.|
## 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<boolean>): void; | Deleted from API version 9. |
|geoLocationManager| method | function requestEnableLocation(): Promise<boolean>; | Deleted from API version 9. |
## 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.
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**.
## cl.resourceManager.1 Change in the Meaning of the Return Value for the API Used to Obtain the rawfile Descriptor
Changed the meaning of the return value for the API used to obtain the rawfile descriptor after the non-decompression feature is added in this version. The change in the meaning of the return value, namely, **descriptor: RawFileDescriptor {fd, offset, length}**, is described as follows:
**Before change:**
**fd**: file descriptor for accessing the rawfile.
**offset**: offset for accessing the rawfile. In this case, the value is **0**.
**length**: size of the rawfile to access.
**After change:**
**fd**: file descriptor for accessing the HAP where the rawfile is located.
**offset**: offset of the accessed rawfile relative to the HAP.
**length**: size of the rawfile to access.
**Change Impact**
In versions earlier than 4.0.2.2, the rawfile can be accessed only through **fd**. In version 4.0.2.2 or later, the rawfile can be accessed only through **{fd, offset, and length}**.
In versions earlier than 4.0.6.2, only the values of string resources can be directly obtained. In 4.0.6.2 or later, the values of string resources can be formatted based on the input arguments for enhanced query.
The following error codes are added:
9001007 If the resource obtained by resId formatting error.
9001008 If the resource obtained by resName formatting error.
**Sample Code**
The following uses **getStringSync** as an example. Before the change, only example 1 is supported. After the change, both example 1 and example 2 are supported.
## 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.
| 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.
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:
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.
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
importusbManagerfrom'@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.
| 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.