提交 f0bb0e65 编写于 作者: S shawn_he

update doc

Signed-off-by: Nshawn_he <shawn.he@huawei.com>
上级 28f62ee7
...@@ -12,6 +12,8 @@ debug(message: string, ...arguments: any[]): void ...@@ -12,6 +12,8 @@ debug(message: string, ...arguments: any[]): void
Prints debugging information in formatted output mode. Prints debugging information in formatted output mode.
Since API version 9, this API is supported in ArkTS widgets.
**System capability**: SystemCapability.ArkUI.ArkUI.Full **System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters** **Parameters**
...@@ -19,9 +21,10 @@ Prints debugging information in formatted output mode. ...@@ -19,9 +21,10 @@ Prints debugging information in formatted output mode.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ----------- | | ------- | ------ | ---- | ----------- |
| message | string | Yes | Text to be printed.| | message | string | Yes | Text 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** **Example**
```js ```js
const number = 5; const number = 5;
console.debug('count: %d', number); // Print the debugging information with arguments in the message replaced. console.debug('count: %d', number); // Print the debugging information with arguments in the message replaced.
...@@ -38,6 +41,8 @@ log(message: string, ...arguments: any[]): void ...@@ -38,6 +41,8 @@ log(message: string, ...arguments: any[]): void
Prints log information in formatted output mode. Prints log information in formatted output mode.
Since API version 9, this API is supported in ArkTS widgets.
**System capability**: SystemCapability.ArkUI.ArkUI.Full **System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters** **Parameters**
...@@ -45,9 +50,10 @@ Prints log information in formatted output mode. ...@@ -45,9 +50,10 @@ Prints log information in formatted output mode.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ----------- | | ------- | ------ | ---- | ----------- |
| message | string | Yes | Text to be printed.| | message | string | Yes | Text 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** **Example**
```js ```js
const number = 5; const number = 5;
console.log('count: %d', number); // Print the log information with arguments in the message replaced. console.log('count: %d', number); // Print the log information with arguments in the message replaced.
...@@ -64,6 +70,8 @@ info(message: string, ...arguments: any[]): void ...@@ -64,6 +70,8 @@ info(message: string, ...arguments: any[]): void
Prints log information in formatted output mode. This API is the alias of **console.log ()**. Prints log information in formatted output mode. This API is the alias of **console.log ()**.
Since API version 9, this API is supported in ArkTS widgets.
**System capability**: SystemCapability.ArkUI.ArkUI.Full **System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters** **Parameters**
...@@ -71,9 +79,10 @@ Prints log information in formatted output mode. This API is the alias of **cons ...@@ -71,9 +79,10 @@ Prints log information in formatted output mode. This API is the alias of **cons
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ----------- | | ------- | ------ | ---- | ----------- |
| message | string | Yes | Text to be printed.| | message | string | Yes | Text 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** **Example**
```js ```js
const number = 5; const number = 5;
console.info('count: %d', number); // Print the log information with arguments in the message replaced. console.info('count: %d', number); // Print the log information with arguments in the message replaced.
...@@ -90,6 +99,8 @@ warn(message: string, ...arguments: any[]): void ...@@ -90,6 +99,8 @@ warn(message: string, ...arguments: any[]): void
Prints warning information in formatted output mode. Prints warning information in formatted output mode.
Since API version 9, this API is supported in ArkTS widgets.
**System capability**: SystemCapability.ArkUI.ArkUI.Full **System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters** **Parameters**
...@@ -97,9 +108,10 @@ Prints warning information in formatted output mode. ...@@ -97,9 +108,10 @@ Prints warning information in formatted output mode.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ----------- | | ------- | ------ | ---- | ----------- |
| message | string | Yes | Warning information to be printed.| | message | string | Yes | Warning 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** **Example**
```js ```js
const str = "name should be string"; const str = "name should be string";
console.warn('warn: %d', str); // Print the warning information with arguments in the message replaced. console.warn('warn: %d', str); // Print the warning information with arguments in the message replaced.
...@@ -116,6 +128,8 @@ error(message: string, ...arguments: any[]): void ...@@ -116,6 +128,8 @@ error(message: string, ...arguments: any[]): void
Prints error information in formatted output mode. Prints error information in formatted output mode.
Since API version 9, this API is supported in ArkTS widgets.
**System capability**: SystemCapability.ArkUI.ArkUI.Full **System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters** **Parameters**
...@@ -123,10 +137,11 @@ Prints error information in formatted output mode. ...@@ -123,10 +137,11 @@ Prints error information in formatted output mode.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ----------- | | ------- | ------ | ---- | ----------- |
| message | string | Yes | Error information to be printed.| | 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** **Example**
```js ```js
const str = "value is not defined"; const str = "value is not defined";
console.error('error: %d', str); // Print the error information with arguments in the message replaced. console.error('error: %d', str); // Print the error information with arguments in the message replaced.
...@@ -153,6 +168,7 @@ Prints assertion information. ...@@ -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.| | arguments | Object | No | Other information to be printed when **value** is **false**. If this parameter is left blank, other information is not printed.|
**Example** **Example**
```js ```js
console.assert(true, 'does nothing'); // Do not print error information as value is true. console.assert(true, 'does nothing'); // Do not print error information as value is true.
console.assert(2% 1 == 0,'does nothing'); // Do not print error information as value is true. console.assert(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 ...@@ -180,6 +196,7 @@ Maintains an internal counter. When this counter is invoked, its label name and
**Example** **Example**
```js ```js
console.count() console.count()
// default: 1 // default: 1
...@@ -210,6 +227,7 @@ Resets a counter based on the specified label name. ...@@ -210,6 +227,7 @@ Resets a counter based on the specified label name.
| label | string | No | Counter label name. The default value is **default**.| | label | string | No | Counter label name. The default value is **default**.|
**Example** **Example**
```js ```js
console.count('abc'); console.count('abc');
// abc: 1 // abc: 1
...@@ -234,6 +252,7 @@ Prints content of the specified object. ...@@ -234,6 +252,7 @@ Prints content of the specified object.
**Example** **Example**
```js ```js
let a = { foo: { bar: { baz: true } }}; let a = { foo: { bar: { baz: true } }};
console.dir(a); console.dir(a);
...@@ -258,6 +277,7 @@ Displays an interactive tree of the descendant elements of the specified XML ele ...@@ -258,6 +277,7 @@ Displays an interactive tree of the descendant elements of the specified XML ele
| arguments | Object | Yes | Information to be printed.| | arguments | Object | Yes | Information to be printed.|
**Example** **Example**
```js ```js
const number = 5; const number = 5;
console.dirxml('count: %d', number); console.dirxml('count: %d', number);
...@@ -284,6 +304,7 @@ If the information to be printed is provided, the information is printed without ...@@ -284,6 +304,7 @@ If the information to be printed is provided, the information is printed without
| arguments | Object | No | Information to be printed.| | arguments | Object | No | Information to be printed.|
**Example** **Example**
```js ```js
console.log("outter"); console.log("outter");
// outter // outter
...@@ -313,6 +334,7 @@ Creates a new inline group in collapsed mode. The usage and function of this API ...@@ -313,6 +334,7 @@ Creates a new inline group in collapsed mode. The usage and function of this API
**Example** **Example**
```js ```js
console.groupCollapsed("outter"); console.groupCollapsed("outter");
// outter // outter
...@@ -335,6 +357,7 @@ Reduces the indentation of subsequent lines by two spaces. ...@@ -335,6 +357,7 @@ Reduces the indentation of subsequent lines by two spaces.
**Example** **Example**
```js ```js
console.log("outter"); console.log("outter");
// outter // outter
...@@ -362,6 +385,7 @@ Prints data in a table. ...@@ -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.| | tableData | Object | No | Data to be printed in a table. If this parameter is left blank, no information is printed.|
**Example** **Example**
```js ```js
console.table([1, 2, 3]); console.table([1, 2, 3]);
// ┌─────────┬────────┐ // ┌─────────┬────────┐
...@@ -382,6 +406,7 @@ console.table({ a: [1, 2, 3, 4, 5], b: 5, c: { e: 5 } }); ...@@ -382,6 +406,7 @@ console.table({ a: [1, 2, 3, 4, 5], b: 5, c: { e: 5 } });
// │ c │ │ │ │ │ │ 5 │ │ // │ c │ │ │ │ │ │ 5 │ │
// └─────────┴───┴───┴───┴───┴───┴───┴────────┘ // └─────────┴───┴───┴───┴───┴───┴───┴────────┘
``` ```
## console.time<sup>10+</sup> ## console.time<sup>10+</sup>
time(label?: string): void time(label?: string): void
...@@ -397,6 +422,7 @@ Starts a timer to track the duration of an operation. You can use **console.time ...@@ -397,6 +422,7 @@ Starts a timer to track the duration of an operation. You can use **console.time
| label | string | No | Timer label. The default value is **default**.| | label | string | No | Timer label. The default value is **default**.|
**Example** **Example**
```js ```js
console.time('abc'); console.time('abc');
``` ```
...@@ -416,6 +442,7 @@ Stops the timer started by calling **console.time()** and prints the elapsed tim ...@@ -416,6 +442,7 @@ Stops the timer started by calling **console.time()** and prints the elapsed tim
| label | string | No | Timer label. The default value is **default**.| | label | string | No | Timer label. The default value is **default**.|
**Example** **Example**
```js ```js
console.time('abc'); console.time('abc');
console.timeEnd('abc'); console.timeEnd('abc');
...@@ -438,6 +465,7 @@ Prints the elapsed time and other data parameters for the timer started by **con ...@@ -438,6 +465,7 @@ Prints the elapsed time and other data parameters for the timer started by **con
| arguments | Object | No | Logs to be printed.| | arguments | Object | No | Logs to be printed.|
**Example** **Example**
```js ```js
console.time('timer1'); console.time('timer1');
console.timeLog('timer1', 17); console.timeLog('timer1', 17);
...@@ -461,6 +489,7 @@ Creates a stack trace. ...@@ -461,6 +489,7 @@ Creates a stack trace.
| arguments | Object | No | Logs to be printed. If this parameter is left blank, only stack information is printed.| | arguments | Object | No | Logs to be printed. If this parameter is left blank, only stack information is printed.|
**Example** **Example**
```js ```js
console.trace(); console.trace();
// Trace: // Trace:
......
# 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
## 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
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}**.
**Key API/Component Changes**
- Involved APIs:
- getRawFd(path: string, callback: AsyncCallback\<RawFileDescriptor>): void
- getRawFd(path: string): Promise\<RawFileDescriptor>
- getRawFileDescriptor(path: string, callback: AsyncCallback\<RawFileDescriptor>): void
- getRawFileDescriptor(path: string): Promise\<RawFileDescriptor>
**Sample Code**
The following is an example of calling the **getRawFd** API:
```
try {
this.context.resourceManager.getRawFd("test.ogg", (error, value) => {
if (error != null) {
console.log(`callback getRawFd failed error code: ${error.code}, message: ${error.message}.`);
} else {
let fileDescriptor = {
fd = value.fd,
offset = value.offset,
length = value.length
}
this.avPlayer.fdSrc(fileDescriptor); // Take the audio player as an example. When calling fdSrc, pass fileDescriptor in addition to fd.
}
});
} catch (error) {
console.error(`callback getRawFd failed, error code: ${error.code}, message: ${error.message}.`)
};
```
## cl.resourceManager.2 Addition of getStringSync and getStringByNameSync APIs
Added the **getStringSync** and **getStringByNameSync** APIs and error codes to obtain and format strings.
| Bundle Name | API |
| --------------- | ---------------------------------------------------- |
| ohos.resourceManager.d.ts | getStringSync(resId: number, ...args: Array<string \| number>): string; |
| ohos.resourceManager.d.ts | getStringSync(resource: Resource, ...args: Array<string \| number>): string; |
| ohos.resourceManager.d.ts | getStringByNameSync(resName: string, ...args: Array<string \| number>): string; |
**Change Impact**
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.
```
Example 1:
try {
this.context.resourceManager.getStringSync($r('app.string.test').id);
} catch (error) {
console.error(`getStringSync failed, error code: ${error.code}, message: ${error.message}.`)
}
Example 2:
try {
this.context.resourceManager.getStringSync($r('app.string.test').id, "format string", 787, 98.78);
} catch (error) {
console.error(`getStringSync failed, error code: ${error.code}, message: ${error.message}.`)
}
```
**Adaptation Guide**
For details, see the API reference.
[API Reference](../../../application-dev/reference/apis/js-apis-resource-manager.md)
[Error Codes](../../../application-dev/reference/errorcodes/errorcode-resource-manager.md)
# 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.
先完成此消息的编辑!
想要评论请 注册