From 20083e2925266662da14025f933a204e25281dd6 Mon Sep 17 00:00:00 2001 From: shawn_he Date: Wed, 22 Feb 2023 14:05:51 +0800 Subject: [PATCH] update doc Signed-off-by: shawn_he --- en/application-dev/device/usb-guidelines.md | 6 +- .../internationalization/i18n-guidelines.md | 58 +- .../internationalization/intl-guidelines.md | 20 +- .../reference/apis/Readme-EN.md | 3 +- .../reference/apis/js-apis-battery-info.md | 51 +- .../reference/apis/js-apis-hichecker.md | 16 +- .../reference/apis/js-apis-hidebug.md | 4 +- .../reference/apis/js-apis-http.md | 2 + .../reference/apis/js-apis-i18n.md | 58 +- .../reference/apis/js-apis-intl.md | 16 +- .../reference/apis/js-apis-radio.md | 300 +++--- .../apis/js-apis-resource-manager.md | 8 +- .../reference/apis/js-apis-usb-deprecated.md | 1 + .../reference/apis/js-apis-usb.md | 1 + .../reference/apis/js-apis-usbManager.md | 950 ++++++++++++++++++ .../subsys-dfx-hisysevent-logging-config.md | 196 ++-- .../changelogs-telephony.md | 59 ++ .../changelog-telephony.md | 223 ++++ .../changelogs-telephony.md | 76 ++ .../OpenHarmony_4.0.2.3/changelogs-usb.md | 37 + .../OpenHarmony_4.0.3.2/changelogs-power.md | 82 ++ .../OpenHarmony_4.0.3.2/changelogs-startup.md | 15 + 22 files changed, 1853 insertions(+), 329 deletions(-) create mode 100644 en/application-dev/reference/apis/js-apis-usbManager.md create mode 100644 en/release-notes/changelogs/OpenHarmony_3.2.10.6/changelogs-telephony.md create mode 100644 en/release-notes/changelogs/OpenHarmony_3.2.10.7/changelog-telephony.md create mode 100644 en/release-notes/changelogs/OpenHarmony_3.2.10.7/changelogs-telephony.md create mode 100644 en/release-notes/changelogs/OpenHarmony_4.0.2.3/changelogs-usb.md create mode 100644 en/release-notes/changelogs/OpenHarmony_4.0.3.2/changelogs-power.md create mode 100644 en/release-notes/changelogs/OpenHarmony_4.0.3.2/changelogs-startup.md diff --git a/en/application-dev/device/usb-guidelines.md b/en/application-dev/device/usb-guidelines.md index 696fd8e06d..cdb6c32527 100644 --- a/en/application-dev/device/usb-guidelines.md +++ b/en/application-dev/device/usb-guidelines.md @@ -8,7 +8,7 @@ In Host mode, you can obtain the list of connected USB devices, enable or disabl The USB service provides the following functions: query of USB device list, bulk data transfer, control transfer, and access permission management. -The following table lists the USB APIs currently available. For details, see the [API Reference](../reference/apis/js-apis-usb.md). +The following table lists the USB APIs currently available. For details, see the [API Reference](../reference/apis/js-apis-usbManager.md). **Table 1** Open USB APIs @@ -18,7 +18,7 @@ The following table lists the USB APIs currently available. For details, see the | requestRight(deviceName: string): Promise\ | Requests the temporary permission for a given application to access the USB device. This API uses a promise to return the result. | | connectDevice(device: USBDevice): Readonly\ | Connects to the USB device based on the device list returned by `getDevices()`. | | getDevices(): Array> | Obtains the list of USB devices connected to the USB host. If no USB device is connected, an empty list is returned. | -| setConfiguration(pipe: USBDevicePipe, config: USBConfig): number | Sets the USB device configuration. | +| setConfiguration(pipe: USBDevicePipe, config: USBConfiguration): number | Sets the USB device configuration. | | setInterface(pipe: USBDevicePipe, iface: USBInterface): number | Sets a USB interface. | | claimInterface(pipe: USBDevicePipe, iface: USBInterface, force ?: boolean): number | Claims a USB interface. | | bulkTransfer(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, timeout ?: number): Promise\ | Performs bulk transfer. | @@ -36,7 +36,7 @@ You can set a USB device as the USB host to connect to other USB devices for dat ```js // Import the USB API package. - import usb from '@ohos.usbV9'; + import usb from '@ohos.usbManager'; // Obtain the USB device list. let deviceList = usb.getDevices(); /* diff --git a/en/application-dev/internationalization/i18n-guidelines.md b/en/application-dev/internationalization/i18n-guidelines.md index 8218f25613..e78bdb6437 100644 --- a/en/application-dev/internationalization/i18n-guidelines.md +++ b/en/application-dev/internationalization/i18n-guidelines.md @@ -6,7 +6,7 @@ The [intl](intl-guidelines.md) module provides basic i18n capabilities through t ## Obtaining and Setting i18n Information -The system provides APIs to configure information such as the system language, preferred language, country or region, 24-hour clock, and local digit switch. +The following table lists the APIs used to configure information such as the system language, preferred language, country or region, 24-hour clock, and use of local digits. ### Available APIs @@ -30,15 +30,15 @@ The system provides APIs to configure information such as the system language, p | System | getPreferredLanguageList()9+ | Obtains the preferred language list. | | System | getFirstPreferredLanguage()9+ | Obtains the first language in the preferred language list. | | System | getAppPreferredLanguage()9+ | Obtains the preferred language of an application. | -| System | setUsingLocalDigit(flag: boolean)9+ | Sets whether to enable the local digit switch. | -| System | getUsingLocalDigit()9+ | Checks whether the local digit switch is turned on. | +| System | setUsingLocalDigit(flag: boolean)9+ | Specifies whether to enable use of local digits. | +| System | getUsingLocalDigit()9+ | Checks whether use of local digits is enabled. | | | isRTL(locale:string):boolean9+ | Checks whether the locale uses a right-to-left (RTL) language.| ### How to Develop 1. Import the **i18n** module. ```js - import I18n from '@ohos.i18n' + import I18n from '@ohos.i18n'; ``` 2. Obtain and set the system language. @@ -51,7 +51,7 @@ The system provides APIs to configure information such as the system language, p I18n.System.setSystemLanguage("en"); // Set the system language to en. let language = I18n.System.getSystemLanguage(); // language = "en" } catch(error) { - console.error(`call i18n.System interface failed, error code: ${error.code}, message: ${error.message}`) + console.error(`call i18n.System interface failed, error code: ${error.code}, message: ${error.message}`); } ``` @@ -65,7 +65,7 @@ The system provides APIs to configure information such as the system language, p I18n.System.setSystemRegion("CN"); // Set the system country to CN. let region = I18n.System.getSystemRegion(); // region = "CN" } catch(error) { - console.error(`call i18n.System interface failed, error code: ${error.code}, message: ${error.message}`) + console.error(`call i18n.System interface failed, error code: ${error.code}, message: ${error.message}`); } ``` @@ -79,7 +79,7 @@ The system provides APIs to configure information such as the system language, p I18n.System.setSystemLocale("zh-Hans-CN"); // Set the system locale to zh-Hans-CN. let locale = I18n.System.getSystemLocale(); // locale = "zh-Hans-CN" } catch(error) { - console.error(`call i18n.System interface failed, error code: ${error.code}, message: ${error.message}`) + console.error(`call i18n.System interface failed, error code: ${error.code}, message: ${error.message}`); } ``` @@ -92,7 +92,7 @@ The system provides APIs to configure information such as the system language, p let rtl = I18n.isRTL("zh-CN"); // rtl = false rtl = I18n.isRTL("ar"); // rtl = true } catch(error) { - console.error(`call i18n.System interface failed, error code: ${error.code}, message: ${error.message}`) + console.error(`call i18n.System interface failed, error code: ${error.code}, message: ${error.message}`); } ``` @@ -106,7 +106,7 @@ The system provides APIs to configure information such as the system language, p I18n.System.set24HourClock(true); let hourClock = I18n.System.is24HourClock(); // hourClock = true } catch(error) { - console.error(`call i18n.System interface failed, error code: ${error.code}, message: ${error.message}`) + console.error(`call i18n.System interface failed, error code: ${error.code}, message: ${error.message}`); } ``` @@ -121,7 +121,7 @@ The system provides APIs to configure information such as the system language, p let sentenceCase = false; let localizedLanguage = I18n.System.getDisplayLanguage(language, locale, sentenceCase); // localizedLanguage = "English" } catch(error) { - console.error(`call i18n.System interface failed, error code: ${error.code}, message: ${error.message}`) + console.error(`call i18n.System interface failed, error code: ${error.code}, message: ${error.message}`); } ``` @@ -136,7 +136,7 @@ The system provides APIs to configure information such as the system language, p let sentenceCase = false; let localizedCountry = I18n.System.getDisplayCountry(country, locale, sentenceCase); // localizedCountry = "U.S." } catch(error) { - console.error(`call i18n.System interface failed, error code: ${error.code}, message: ${error.message}`) + console.error(`call i18n.System interface failed, error code: ${error.code}, message: ${error.message}`); } ``` @@ -150,7 +150,7 @@ The system provides APIs to configure information such as the system language, p let languageList = I18n.System.getSystemLanguages(); // languageList = ["en-Latn-US", "zh-Hans"] let countryList = I18n.System.getSystemCountries("zh"); // countryList = ["ZW", "YT", ..., "CN", "DE"], 240 countries and regions in total } catch(error) { - console.error(`call i18n.System interface failed, error code: ${error.code}, message: ${error.message}`) + console.error(`call i18n.System interface failed, error code: ${error.code}, message: ${error.message}`); } ``` @@ -162,7 +162,7 @@ The system provides APIs to configure information such as the system language, p try { let isSuggest = I18n.System.isSuggested("zh", "CN"); // isSuggest = true } catch(error) { - console.error(`call i18n.System interface failed, error code: ${error.code}, message: ${error.message}`) + console.error(`call i18n.System interface failed, error code: ${error.code}, message: ${error.message}`); } ``` @@ -182,7 +182,7 @@ The system provides APIs to configure information such as the system language, p let firstPreferredLanguage = I18n.System.getFirstPreferredLanguage(); // firstPreferredLanguage = "en-GB" let appPreferredLanguage = I18n.System.getAppPreferredLanguage(); // Set the preferred language of the application to en-GB if the application contains en-GB resources. } catch(error) { - console.error(`call i18n.System interface failed, error code: ${error.code}, message: ${error.message}`) + console.error(`call i18n.System interface failed, error code: ${error.code}, message: ${error.message}`); } ``` @@ -190,14 +190,14 @@ The system provides APIs to configure information such as the system language, p Call **setUsingLocalDigit** to enable the local digit switch. (This is a system API and can be called only by system applications with the UPDATE_CONFIGURATION permission.) Call **getUsingLocalDigit** to check whether the local digit switch is enabled. - Currently, the local digit switch applies only to the following languages: "ar", "as", "bn", "fa", "mr", "my", "ne", and "ur". + Currently, use of local digits is supported only for the following languages: **ar**, **as**, **bn**, **fa**, **mr**, **my**, **ne**, **ur**. ```js try { I18n.System.setUsingLocalDigit(true); // Enable the local digit switch. let status = I18n.System.getUsingLocalDigit(); // status = true } catch(error) { - console.error(`call i18n.System interface failed, error code: ${error.code}, message: ${error.message}`) + console.error(`call i18n.System interface failed, error code: ${error.code}, message: ${error.message}`); } ``` @@ -220,14 +220,14 @@ try { | Calendar | getMinimalDaysInFirstWeek():number8+ | Obtains the minimum number of days in the first week of a year. | | Calendar | setMinimalDaysInFirstWeek(value:number): void8+ | Sets the minimum number of days in the first week of a year. | | Calendar | getDisplayName(locale:string):string8+ | Obtains the localized display of the **Calendar** object. | -| Calendar | isWeekend(date?:Date):boolean8+ | Checks whether the specified date in this **Calendar** object is a weekend. | +| Calendar | isWeekend(date?:Date):boolean8+ | Checks whether a given date is a weekend in the calendar. | ### How to Develop 1. Import the **i18n** module. ```js - import I18n from '@ohos.i18n' + import I18n from '@ohos.i18n'; ``` 2. Instantiate a **Calendar** object. @@ -254,7 +254,7 @@ try { Call **set** to set the year, month, day, hour, minute, and second for the **Calendar** object. ```js - calendar.set(2021, 12, 21, 6, 0, 0) + calendar.set(2021, 12, 21, 6, 0, 0); ``` 5. Set and obtain the time zone for the **Calendar** object. @@ -317,7 +317,7 @@ try { 1. Import the **i18n** module. ```js - import I18n from '@ohos.i18n' + import I18n from '@ohos.i18n'; ``` 2. Instantiate a **PhoneNumberFormat** object. @@ -359,7 +359,7 @@ The **I18NUtil** class provides an API to implement measurement conversion. 1. Import the **i18n** module. ```js - import I18n from '@ohos.i18n' + import I18n from '@ohos.i18n'; ``` 2. Convert a measurement unit. @@ -393,7 +393,7 @@ The **I18NUtil** class provides an API to implement measurement conversion. 1. Import the **i18n** module. ```js - import I18n from '@ohos.i18n' + import I18n from '@ohos.i18n'; ``` 2. Instantiates an **IndexUtil** object. @@ -418,7 +418,7 @@ The **I18NUtil** class provides an API to implement measurement conversion. Call **addLocale** to add the alphabet index of a new locale to the current index list. ```js - indexUtil.addLocale("ar") + indexUtil.addLocale("ar"); ``` 5. Obtain the index of a string. @@ -454,7 +454,7 @@ When a text is displayed in more than one line, use [BreakIterator8](../referenc 1. Import the **i18n** module. ```js - import I18n from '@ohos.i18n' + import I18n from '@ohos.i18n'; ``` 2. Instantiate a **BreakIterator** object. @@ -462,7 +462,7 @@ When a text is displayed in more than one line, use [BreakIterator8](../referenc Call **getLineInstance** to instantiate a **BreakIterator** object. ```js - let locale = "en-US" + let locale = "en-US"; let breakIterator = I18n.getLineInstance(locale); ``` @@ -531,7 +531,7 @@ When a text is displayed in more than one line, use [BreakIterator8](../referenc 1. Import the **i18n** module. ```js - import I18n from '@ohos.i18n' + import I18n from '@ohos.i18n'; ``` 2. Instantiate the **TimeZone** object, and obtain the time zone information. @@ -592,7 +592,7 @@ Call [Transliterator](../reference/apis/js-apis-i18n.md#transliterator9) APIs to 1. Import the **i18n** module. ```js - import I18n from '@ohos.i18n' + import I18n from '@ohos.i18n'; ``` 2. Obtains the transliterator ID list. @@ -637,7 +637,7 @@ Call [Transliterator](../reference/apis/js-apis-i18n.md#transliterator9) APIs to 1. Import the **i18n** module. ```js - import I18n from '@ohos.i18n' + import I18n from '@ohos.i18n'; ``` 2. Check the input character has a certain attribute. @@ -719,7 +719,7 @@ Call [Transliterator](../reference/apis/js-apis-i18n.md#transliterator9) APIs to 1. Import the **i18n** module. ```js - import I18n from '@ohos.i18n' + import I18n from '@ohos.i18n'; ``` 2. Check the sequence of year, month, and day in a date. diff --git a/en/application-dev/internationalization/intl-guidelines.md b/en/application-dev/internationalization/intl-guidelines.md index 609af84500..7f21dbb96c 100644 --- a/en/application-dev/internationalization/intl-guidelines.md +++ b/en/application-dev/internationalization/intl-guidelines.md @@ -25,7 +25,7 @@ The [I18N](i18n-guidelines.md) module provides enhanced I18N capabilities throug Importing an incorrect bundle can lead to unexpected API behavior. ```js - import Intl from '@ohos.intl' + import Intl from '@ohos.intl'; ``` 2. Instantiates a **Locale** object. @@ -100,7 +100,7 @@ The [I18N](i18n-guidelines.md) module provides enhanced I18N capabilities throug Importing an incorrect bundle can lead to unexpected API behavior. ```js - import Intl from '@ohos.intl' + import Intl from '@ohos.intl'; ``` 2. Instantiate a **DateTimeFormat** object. @@ -170,7 +170,7 @@ The [I18N](i18n-guidelines.md) module provides enhanced I18N capabilities throug Importing an incorrect bundle can lead to unexpected API behavior. ```js - import Intl from '@ohos.intl' + import Intl from '@ohos.intl'; ``` 2. Instantiate a **NumberFormat** object. @@ -195,7 +195,7 @@ The [I18N](i18n-guidelines.md) module provides enhanced I18N capabilities throug ```js let options = {compactDisplay: "short", notation: "compact"}; let numberFormat = new Intl.NumberFormat("zh-CN", options); - let number = 1234.5678 + let number = 1234.5678; let formatResult = numberFormat.format(number); // formatResult = "1235" ``` @@ -229,7 +229,7 @@ Users in different regions have different requirements for string sorting. [Coll Importing an incorrect bundle can lead to unexpected API behavior. ```js - import Intl from '@ohos.intl' + import Intl from '@ohos.intl'; ``` 2. Instantiate a **Collator** object. @@ -290,7 +290,7 @@ According to grammars in certain languages, the singular or plural form of a nou Importing an incorrect bundle can lead to unexpected API behavior. ```js - import Intl from '@ohos.intl' + import Intl from '@ohos.intl'; ``` 2. Instantiate a **PluralRules** object. @@ -313,7 +313,7 @@ According to grammars in certain languages, the singular or plural form of a nou ```js let pluralRules = new Intl.PluralRules("zh-CN", {localeMatcher: "best fit", type: "cardinal"}); - let number = 1234.5678 + let number = 1234.5678; let categoryResult = pluralRules.select(number); // categoryResult = "other" ``` @@ -338,7 +338,7 @@ According to grammars in certain languages, the singular or plural form of a nou Importing an incorrect bundle can lead to unexpected API behavior. ```js - import Intl from '@ohos.intl' + import Intl from '@ohos.intl'; ``` 2. Instantiate a **RelativeTimeFormat** object. @@ -362,7 +362,7 @@ According to grammars in certain languages, the singular or plural form of a nou ```js let relativeTimeFormat = new Intl.RelativeTimeFormat("zh-CN", {numeric: "always", style: "long"}); let number = 2; - let unit = "year" + let unit = "year"; let formatResult = relativeTimeFormat.format(number, unit); // 2 years later ``` @@ -373,7 +373,7 @@ According to grammars in certain languages, the singular or plural form of a nou ```js let relativeTimeFormat = new Intl.RelativeTimeFormat("zh-CN", {numeric: "always", style: "long"}); let number = 2; - let unit = "year" + let unit = "year"; let formatPartsResult = relativeTimeFormat.formatToParts(number, unit); // formatPartsResult = [{"type": "integer", "value": "2", "unit": "year"}, {"type":"literal", "value": "years later"}] ``` diff --git a/en/application-dev/reference/apis/Readme-EN.md b/en/application-dev/reference/apis/Readme-EN.md index bb3eca1011..20a4ab5635 100644 --- a/en/application-dev/reference/apis/Readme-EN.md +++ b/en/application-dev/reference/apis/Readme-EN.md @@ -313,7 +313,7 @@ - [@ohos.systemParameterV9 (System Parameter)](js-apis-system-parameterV9.md) - [@ohos.thermal (Thermal Management)](js-apis-thermal.md) - [@ohos.update (Update)](js-apis-update.md) - - [@ohos.usbV9 (USB Management)](js-apis-usb.md) + - [@ohos.usbManager (USB Manager)](js-apis-usbManager.md) - [@ohos.vibrator (Vibrator)](js-apis-vibrator.md) - Account Management - [@ohos.account.appAccount (App Account Management)](js-apis-appAccount.md) @@ -371,6 +371,7 @@ - [@ohos.statfs (statfs)](js-apis-statfs.md) - [@ohos.systemParameter (System Parameter)](js-apis-system-parameter.md) - [@ohos.usb (USB Management)](js-apis-usb-deprecated.md) + - [@ohos.usbV9 (USB Management)](js-apis-usb.md) - [@system.app (Application Context)](js-apis-system-app.md) - [@system.battery (Battery Information)](js-apis-system-battery.md) - [@system.bluetooth (Bluetooth)](js-apis-system-bluetooth.md) diff --git a/en/application-dev/reference/apis/js-apis-battery-info.md b/en/application-dev/reference/apis/js-apis-battery-info.md index 41d13ba574..7c5b35ce70 100644 --- a/en/application-dev/reference/apis/js-apis-battery-info.md +++ b/en/application-dev/reference/apis/js-apis-battery-info.md @@ -2,9 +2,11 @@ The **batteryInfo** module provides APIs for querying the charger type, battery health status, and battery charging status. -> **NOTE**
+> **NOTE** +> > The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. + ## Modules to Import ```js @@ -20,18 +22,18 @@ Describes battery information. | Name | Type | Readable| Writable| Description | | --------------- | ------------------- | ---- | ---- | ---------------------| | batterySOC | number | Yes | No | Battery state of charge (SoC) of the device, in unit of percentage. | -| chargingStatus | [BatteryChargeState](#batterychargestate) | Yes | No | Battery charging state of the device. | -| healthStatus | [BatteryHealthState](#batteryhealthstate) | Yes | No | Battery health state of the device. | +| chargingStatus | [BatteryChargeState](#batterychargestate) | Yes | No | Battery charging status of the device. | +| healthStatus | [BatteryHealthState](#batteryhealthstate) | Yes | No | Battery health status of the device. | | pluggedType | [BatteryPluggedType](#batterypluggedtype) | Yes | No | Charger type of the device. | | voltage | number | Yes | No | Battery voltage of the device, in unit of microvolt. | | technology | string | Yes | No | Battery technology of the device. | | batteryTemperature | number | Yes | No | Battery temperature of the device, in unit of 0.1°C. | | isBatteryPresent7+ | boolean | Yes | No | Whether the battery is supported or present. | | batteryCapacityLevel9+ | [BatteryCapacityLevel](#batterycapacitylevel9) | Yes | No | Battery level of the device. | -| estimatedRemainingChargeTime9+ | number | Yes | No | Estimated time for fully charging the current device, in unit of milliseconds. | -| totalEnergy9+ | number | Yes | No | Total battery capacity of the device, in unit of mAh. This is a system API. | -| nowCurrent9+ | number | Yes | No | Battery current of the device, in unit of mA. This is a system API. | -| remainingEnergy9+ | number | Yes | No | Remaining battery capacity of the device, in unit of mAh. This is a system API.| +| estimatedRemainingChargeTime9+ | number | Yes | No | Estimated time for fully charging the current device, in unit of milliseconds. This is a system API. | +| totalEnergy9+ | number | Yes | No | Total battery capacity of the device, in unit of mAh. **System API**: This is a system API. | +| nowCurrent9+ | number | Yes | No | Battery current of the device, in unit of mA. **System API**: This is a system API. | +| remainingEnergy9+ | number | Yes | No | Remaining battery capacity of the device, in unit of mAh. **System API**: This is a system API.| ## BatteryPluggedType @@ -41,10 +43,10 @@ Enumerates charger types. | Name | Value | Description | | -------- | ---- | ----------------- | -| NONE | 0 | Unknown type | -| AC | 1 | AC charger| -| USB | 2 | USB charger | -| WIRELESS | 3 | Wireless charger| +| NONE | 0 | Unknown charger type. | +| AC | 1 | AC charger.| +| USB | 2 | USB charger. | +| WIRELESS | 3 | Wireless charger.| ## BatteryChargeState @@ -82,14 +84,15 @@ Enumerates battery levels. | Name | Value| Description | | -------------- | ------ | ---------------------------- | -| LEVEL_NONE | 0 | Unknown battery level. | | LEVEL_FULL | 1 | Full battery level. | | LEVEL_HIGH | 2 | High battery level. | | LEVEL_NORMAL | 3 | Normal battery level.| | LEVEL_LOW | 4 | Low battery level. | -| LEVEL_CRITICAL | 5 | Ultra-low battery level.| +| LEVEL_WARNING | 5 | Alarm battery level.| +| LEVEL_CRITICAL | 6 | Ultra-low battery level.| +| LEVEL_SHUTDOWN | 7 | Power-down battery level.| -## CommonEventBatteryChangedCode9+ +## CommonEventBatteryChangedKey9+ Enumerates keys for querying the additional information about the **COMMON_EVENT_BATTERY_CHANGED** event. @@ -97,14 +100,12 @@ Enumerates keys for querying the additional information about the **COMMON_EVENT | 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_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. | diff --git a/en/application-dev/reference/apis/js-apis-hichecker.md b/en/application-dev/reference/apis/js-apis-hichecker.md index 3a5687e9ee..7dc240114c 100644 --- a/en/application-dev/reference/apis/js-apis-hichecker.md +++ b/en/application-dev/reference/apis/js-apis-hichecker.md @@ -47,11 +47,11 @@ Adds one or more rules. HiChecker detects unexpected operations or gives feedbac ```js try { // Add a rule. - hichecker.addCheckRule(hichecker.RULE_CAUTION_PRINT_LOG);} + hichecker.addCheckRule(hichecker.RULE_CAUTION_PRINT_LOG); // Add multiple rules. - hichecker.addCheckRule( - hichecker.RULE_CAUTION_PRINT_LOG | hichecker.RULE_CAUTION_TRIGGER_CRASH); -catch (err) { + // hichecker.addCheckRule( + // hichecker.RULE_CAUTION_PRINT_LOG | hichecker.RULE_CAUTION_TRIGGER_CRASH); +} catch (err) { console.error(`code: ${err.code}, message: ${err.message}`); } ``` @@ -77,9 +77,9 @@ try { // Remove a rule. hichecker.removeCheckRule(hichecker.RULE_CAUTION_PRINT_LOG); // Remove multiple rules. - hichecker.removeCheckRule( - hichecker.RULE_CAUTION_PRINT_LOG | hichecker.RULE_CAUTION_TRIGGER_CRASH); -catch (err) { + // hichecker.removeCheckRule( + // hichecker.RULE_CAUTION_PRINT_LOG | hichecker.RULE_CAUTION_TRIGGER_CRASH); +} catch (err) { console.error(`code: ${err.code}, message: ${err.message}`); } ``` @@ -114,7 +114,7 @@ try { // Check whether the added rule exists in the collection of added rules. hichecker.containsCheckRule(hichecker.RULE_THREAD_CHECK_SLOW_PROCESS); // return true; hichecker.containsCheckRule(hichecker.RULE_CAUTION_PRINT_LOG); // return false; -catch (err) { +} catch (err) { console.error(`code: ${err.code}, message: ${err.message}`); } ``` diff --git a/en/application-dev/reference/apis/js-apis-hidebug.md b/en/application-dev/reference/apis/js-apis-hidebug.md index 189d855e89..364938ddfa 100644 --- a/en/application-dev/reference/apis/js-apis-hidebug.md +++ b/en/application-dev/reference/apis/js-apis-hidebug.md @@ -297,7 +297,7 @@ import hidebug from '@ohos.hidebug' try { hidebug.startJsCpuProfiling("cpu_profiling"); - ... + // ... hidebug.stopJsCpuProfiling(); } catch (error) { console.info(error.code) @@ -326,7 +326,7 @@ import hidebug from '@ohos.hidebug' try { hidebug.startJsCpuProfiling("cpu_profiling"); - ... + // ... hidebug.stopJsCpuProfiling(); } catch (error) { console.info(error.code) diff --git a/en/application-dev/reference/apis/js-apis-http.md b/en/application-dev/reference/apis/js-apis-http.md index 3735792dd3..9740df6628 100644 --- a/en/application-dev/reference/apis/js-apis-http.md +++ b/en/application-dev/reference/apis/js-apis-http.md @@ -581,6 +581,8 @@ httpResponseCache.delete().then(() => { | 6 | Unable to resolve the host because of a failure to resolve the specified remote host. You are advised perform the following: 1. Check whether the URL is correct. 2. Check whether the network connection is normal and whether the network can communicate with external networks. 3. Check whether the network access permission is available. | | 7 | Unable to connect to the proxy or host. You are advised perform the following: 1. Check whether the port number is correct. 2. Check whether the HTTP proxy is enabled on the local host. | +For details about the error codes, see [libcurl Error Codes](https://curl.se/libcurl/c/libcurl-errors.html). + ## HttpDataType9+ Enumerates HTTP data types. diff --git a/en/application-dev/reference/apis/js-apis-i18n.md b/en/application-dev/reference/apis/js-apis-i18n.md index cda33f5434..02cebd741c 100644 --- a/en/application-dev/reference/apis/js-apis-i18n.md +++ b/en/application-dev/reference/apis/js-apis-i18n.md @@ -1,6 +1,6 @@ # @ohos.i18n (Internationalization) -The **i18n** module provides system-related or enhanced i18n capabilities, such as locale management, phone number formatting, and calendar, through supplementary i18n APIs that are not defined in ECMA 402. + The **i18n** module provides system-related or enhanced i18n capabilities, such as locale management, phone number formatting, and calendar, through supplementary i18n APIs that are not defined in ECMA 402. The [intl](js-apis-intl.md) module provides basic i18n capabilities through the standard i18n APIs defined in ECMA 402. It works with the i18n module to provide a complete suite of i18n capabilities. > **NOTE** @@ -53,7 +53,7 @@ For details about the error codes, see [i18n Error Codes](../errorcodes/errorcod try { let displayCountry = I18n.System.getDisplayCountry("zh-CN", "en-GB"); // displayCountry = "China" } catch(error) { - console.error(`call System.getDisplayCountry failed, error code: ${error.code}, message: ${error.message}.`) + console.error(`call System.getDisplayCountry failed, error code: ${error.code}, message: ${error.message}.`); } ``` @@ -92,7 +92,7 @@ For details about the error codes, see [i18n Error Codes](../errorcodes/errorcod try { let displayLanguage = I18n.System.getDisplayLanguage("zh", "en-GB"); // displayLanguage = Chinese } catch(error) { - console.error(`call System.getDisplayLanguage failed, error code: ${error.code}, message: ${error.message}.`) + console.error(`call System.getDisplayLanguage failed, error code: ${error.code}, message: ${error.message}.`); } ``` @@ -100,7 +100,7 @@ For details about the error codes, see [i18n Error Codes](../errorcodes/errorcod static getSystemLanguages(): Array<string> -Obtains the list of system languages. +Obtains the list of system languages. For details about languages, see [Instantiating the Locale Object](../../internationalization/intl-guidelines.md#how-to-develop). **System capability**: SystemCapability.Global.I18n @@ -123,7 +123,7 @@ For details about the error codes, see [i18n Error Codes](../errorcodes/errorcod try { let systemLanguages = I18n.System.getSystemLanguages(); // [ "en-Latn-US", "zh-Hans" ] } catch(error) { - console.error(`call System.getSystemLanguages failed, error code: ${error.code}, message: ${error.message}.`) + console.error(`call System.getSystemLanguages failed, error code: ${error.code}, message: ${error.message}.`); } ``` @@ -131,7 +131,7 @@ For details about the error codes, see [i18n Error Codes](../errorcodes/errorcod static getSystemCountries(language: string): Array<string> -Obtains the list of countries and regions supported for the specified language. +Obtains the list of countries and regions supported for the specified language. For details about countries or regions, see [Instantiating the Locale Object](../../internationalization/intl-guidelines.md#how-to-develop). **System capability**: SystemCapability.Global.I18n @@ -160,7 +160,7 @@ For details about the error codes, see [i18n Error Codes](../errorcodes/errorcod try { let systemCountries = I18n.System.getSystemCountries('zh'); // systemCountries = [ "ZW", "YT", "YE", ..., "ER", "CN", "DE" ], 240 countries or regions in total } catch(error) { - console.error(`call System.getSystemCountries failed, error code: ${error.code}, message: ${error.message}.`) + console.error(`call System.getSystemCountries failed, error code: ${error.code}, message: ${error.message}.`); } ``` @@ -198,7 +198,7 @@ For details about the error codes, see [i18n Error Codes](../errorcodes/errorcod try { let res = I18n.System.isSuggested('zh', 'CN'); // res = true } catch(error) { - console.error(`call System.isSuggested failed, error code: ${error.code}, message: ${error.message}.`) + console.error(`call System.isSuggested failed, error code: ${error.code}, message: ${error.message}.`); } ``` @@ -206,7 +206,7 @@ For details about the error codes, see [i18n Error Codes](../errorcodes/errorcod static getSystemLanguage(): string -Obtains the system language. +Obtains the system language. For details about languages, see [Instantiating the Locale Object](../../internationalization/intl-guidelines.md#how-to-develop). **System capability**: SystemCapability.Global.I18n @@ -229,7 +229,7 @@ For details about the error codes, see [i18n Error Codes](../errorcodes/errorcod try { let systemLanguage = I18n.System.getSystemLanguage(); // systemLanguage indicates the current system language. } catch(error) { - console.error(`call System.getSystemLanguage failed, error code: ${error.code}, message: ${error.message}.`) + console.error(`call System.getSystemLanguage failed, error code: ${error.code}, message: ${error.message}.`); } ``` @@ -264,7 +264,7 @@ For details about the error codes, see [i18n Error Codes](../errorcodes/errorcod try { I18n.System.setSystemLanguage('zh'); // Set the current system language to zh. } catch(error) { - console.error(`call System.setSystemLanguage failed, error code: ${error.code}, message: ${error.message}.`) + console.error(`call System.setSystemLanguage failed, error code: ${error.code}, message: ${error.message}.`); } ``` @@ -272,7 +272,7 @@ For details about the error codes, see [i18n Error Codes](../errorcodes/errorcod static getSystemRegion(): string -Obtains the system region. +Obtains the system region. For details about system regions, see [Instantiating the Locale Object](../../internationalization/intl-guidelines.md#how-to-develop). **System capability**: SystemCapability.Global.I18n @@ -295,7 +295,7 @@ For details about the error codes, see [i18n Error Codes](../errorcodes/errorcod try { let systemRegion = I18n.System.getSystemRegion(); // Obtain the current system region. } catch(error) { - console.error(`call System.getSystemRegion failed, error code: ${error.code}, message: ${error.message}.`) + console.error(`call System.getSystemRegion failed, error code: ${error.code}, message: ${error.message}.`); } ``` @@ -330,7 +330,7 @@ For details about the error codes, see [i18n Error Codes](../errorcodes/errorcod try { I18n.System.setSystemRegion('CN'); // Set the current system region to CN. } catch(error) { - console.error(`call System.setSystemRegion failed, error code: ${error.code}, message: ${error.message}.`) + console.error(`call System.setSystemRegion failed, error code: ${error.code}, message: ${error.message}.`); } ``` @@ -338,7 +338,7 @@ For details about the error codes, see [i18n Error Codes](../errorcodes/errorcod static getSystemLocale(): string -Obtains the system locale. +Obtains the system locale. For details about system locales, see [Instantiating the Locale Object](../../internationalization/intl-guidelines.md#how-to-develop). **System capability**: SystemCapability.Global.I18n @@ -361,7 +361,7 @@ For details about the error codes, see [i18n Error Codes](../errorcodes/errorcod try { let systemLocale = I18n.System.getSystemLocale(); // Obtain the current system locale. } catch(error) { - console.error(`call System.getSystemLocale failed, error code: ${error.code}, message: ${error.message}.`) + console.error(`call System.getSystemLocale failed, error code: ${error.code}, message: ${error.message}.`); } ``` @@ -396,7 +396,7 @@ For details about the error codes, see [i18n Error Codes](../errorcodes/errorcod try { I18n.System.setSystemLocale('zh-CN'); // Set the current system locale to zh-CN. } catch(error) { - console.error(`call System.setSystemLocale failed, error code: ${error.code}, message: ${error.message}.`) + console.error(`call System.setSystemLocale failed, error code: ${error.code}, message: ${error.message}.`); } ``` @@ -427,7 +427,7 @@ For details about the error codes, see [i18n Error Codes](../errorcodes/errorcod try { let is24HourClock = I18n.System.is24HourClock(); // Check whether the 24-hour clock is enabled. } catch(error) { - console.error(`call System.is24HourClock failed, error code: ${error.code}, message: ${error.message}.`) + console.error(`call System.is24HourClock failed, error code: ${error.code}, message: ${error.message}.`); } ``` @@ -463,7 +463,7 @@ For details about the error codes, see [i18n Error Codes](../errorcodes/errorcod try { I18n.System.set24HourClock(true); } catch(error) { - console.error(`call System.set24HourClock failed, error code: ${error.code}, message: ${error.message}.`) + console.error(`call System.set24HourClock failed, error code: ${error.code}, message: ${error.message}.`); } ``` @@ -502,7 +502,7 @@ For details about the error codes, see [i18n Error Codes](../errorcodes/errorcod try { I18n.System.addPreferredLanguage(language, index); // Add zh-CN to the first place in the preferred language list. } catch(error) { - console.error(`call System.addPreferredLanguage failed, error code: ${error.code}, message: ${error.message}.`) + console.error(`call System.addPreferredLanguage failed, error code: ${error.code}, message: ${error.message}.`); } ``` @@ -539,7 +539,7 @@ For details about the error codes, see [i18n Error Codes](../errorcodes/errorcod try { I18n.System.removePreferredLanguage(index); } catch(error) { - console.error(`call System.removePreferredLanguage failed, error code: ${error.code}, message: ${error.message}.`) + console.error(`call System.removePreferredLanguage failed, error code: ${error.code}, message: ${error.message}.`); } ``` @@ -570,7 +570,7 @@ For details about the error codes, see [i18n Error Codes](../errorcodes/errorcod try { let preferredLanguageList = I18n.System.getPreferredLanguageList(); // Obtain the current preferred language list. } catch(error) { - console.error(`call System.getPreferredLanguageList failed, error code: ${error.code}, message: ${error.message}.`) + console.error(`call System.getPreferredLanguageList failed, error code: ${error.code}, message: ${error.message}.`); } ``` @@ -601,7 +601,7 @@ For details about the error codes, see [i18n Error Codes](../errorcodes/errorcod try { let firstPreferredLanguage = I18n.System.getFirstPreferredLanguage(); // Obtain the first language in the preferred language list. } catch(error) { - console.error(`call System.getFirstPreferredLanguage failed, error code: ${error.code}, message: ${error.message}.`) + console.error(`call System.getFirstPreferredLanguage failed, error code: ${error.code}, message: ${error.message}.`); } ``` @@ -632,7 +632,7 @@ For details about the error codes, see [i18n Error Codes](../errorcodes/errorcod try { let appPreferredLanguage = I18n.System.getAppPreferredLanguage(); // Obtain the preferred language of an application. } catch(error) { - console.error(`call System.getAppPreferredLanguage failed, error code: ${error.code}, message: ${error.message}.`) + console.error(`call System.getAppPreferredLanguage failed, error code: ${error.code}, message: ${error.message}.`); } ``` @@ -640,7 +640,7 @@ For details about the error codes, see [i18n Error Codes](../errorcodes/errorcod static setUsingLocalDigit(flag: boolean): void -Sets whether to enable the local digit switch. +Specifies whether to enable use of local digits. **System API**: This is a system API. @@ -667,7 +667,7 @@ For details about the error codes, see [i18n Error Codes](../errorcodes/errorcod try { I18n.System.setUsingLocalDigit(true); // Enable the local digit switch. } catch(error) { - console.error(`call System.setUsingLocalDigit failed, error code: ${error.code}, message: ${error.message}.`) + console.error(`call System.setUsingLocalDigit failed, error code: ${error.code}, message: ${error.message}.`); } ``` @@ -675,7 +675,7 @@ For details about the error codes, see [i18n Error Codes](../errorcodes/errorcod static getUsingLocalDigit(): boolean -Checks whether the local digit switch is turned on. +Checks whether use of local digits is enabled. **System capability**: SystemCapability.Global.I18n @@ -698,7 +698,7 @@ For details about the error codes, see [i18n Error Codes](../errorcodes/errorcod try { let status = I18n.System.getUsingLocalDigit(); // Check whether the local digit switch is enabled. } catch(error) { - console.error(`call System.getUsingLocalDigit failed, error code: ${error.code}, message: ${error.message}.`) + console.error(`call System.getUsingLocalDigit failed, error code: ${error.code}, message: ${error.message}.`); } ``` @@ -1025,7 +1025,7 @@ Checks whether the specified date in this **Calendar** object is a weekend. | Name | Type | Mandatory | Description | | ---- | ---- | ---- | ---------------------------------------- | -| date | Date | No | Specified date in this **Calendar** object. If this parameter is left unspecified, the system checks whether the current date in the **Calendar** object is a weekend.| +| date | Date | No | Specified date in this **Calendar** object. If the **date** parameter is not specified, the system checks whether the current date is a weekend.| **Return value** diff --git a/en/application-dev/reference/apis/js-apis-intl.md b/en/application-dev/reference/apis/js-apis-intl.md index d4f3449ada..623695f1cc 100644 --- a/en/application-dev/reference/apis/js-apis-intl.md +++ b/en/application-dev/reference/apis/js-apis-intl.md @@ -1,6 +1,6 @@ # @ohos.intl (Internationalization) -The **intl** module provides basic i18n capabilities, such as time and date formatting, number formatting, and string sorting, through the standard i18n APIs defined in ECMA 402. + The **intl** module provides basic i18n capabilities, such as time and date formatting, number formatting, and string sorting, through the standard i18n APIs defined in ECMA 402. The [i18n](js-apis-i18n.md) module provides enhanced i18n capabilities through supplementary interfaces that are not defined in ECMA 402. It works with the intl module to provide a complete suite of i18n capabilities. > **NOTE** @@ -48,9 +48,9 @@ Creates a **Locale** object. **Example** ```js // The default constructor uses the current system locale to create a Locale object. - let locale = new Intl.Locale() + let locale = new Intl.Locale(); // Return the current system locale. - let localeID = locale.toString() + let localeID = locale.toString(); ``` @@ -72,8 +72,8 @@ Creates a **Locale** object. **Example** ```js // Create a Locale object named zh-CN. - let locale = new Intl.Locale("zh-CN") - let localeID = locale.toString() // localeID = "zh-CN" + let locale = new Intl.Locale("zh-CN"); + let localeID = locale.toString(); // localeID = "zh-CN" ``` @@ -429,7 +429,7 @@ Obtains the options of the **NumberFormat** object. // Obtain the options of the NumberFormat object. let options = numfmt.resolvedOptions(); let style = options.style; // style = decimal - let notation = options.notation // notation = scientific + let notation = options.notation; // notation = scientific ``` @@ -552,7 +552,7 @@ Returns properties reflecting the locale and collation options of a **Collator** // Obtain the options of the Collator object. let options = collator.resolvedOptions(); let usage = options.usage; // usage = "sort" - let ignorePunctuation = options.ignorePunctuation // ignorePunctuation = true + let ignorePunctuation = options.ignorePunctuation; // ignorePunctuation = true ``` @@ -631,7 +631,7 @@ Obtains a string that represents the singular-plural type of the specified numbe | Type | Description | | ------ | ---------------------------------------- | -| string | Singular-plural type. The value can be any of the following: **one**, **two**, **few**, **many**, **others**.| +| string | Singular-plural type. The value can be any of the following: **zero**, **one**, **two**, **few**, **many**, **others**.| **Example** ```js diff --git a/en/application-dev/reference/apis/js-apis-radio.md b/en/application-dev/reference/apis/js-apis-radio.md index dfb1dd7506..ea662f7df4 100644 --- a/en/application-dev/reference/apis/js-apis-radio.md +++ b/en/application-dev/reference/apis/js-apis-radio.md @@ -104,7 +104,7 @@ radio.getNetworkState((err, data) =>{ getNetworkState\(slotId: number, callback: AsyncCallback\): void -Obtains the network status of the SIM card in the specified slot. This API uses an asynchronous callback to return the result. +Obtains the network status. This API uses an asynchronous callback to return the result. **Required permission**: ohos.permission.GET_NETWORK_INFO @@ -131,7 +131,7 @@ radio.getNetworkState(slotId, (err, data) => { getNetworkState\(slotId?: number\): Promise -Obtains the network status of the SIM card in the specified slot. This API uses a promise to return the result. +Obtains the network status. This API uses a promise to return the result. **Required permission**: ohos.permission.GET_NETWORK_INFO @@ -290,7 +290,7 @@ Obtains the ID of the slot in which the primary card is located. This API uses a | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| callback | AsyncCallback\ | Yes | Callback used to return the result.| +| callback | AsyncCallback\ | Yes | Callback invoked to return the result.| **Example** @@ -331,7 +331,7 @@ promise.then(data => { getSignalInformation\(slotId: number, callback: AsyncCallback\>\): void -Obtains a list of signal strengths of the network with which the SIM card in the specified slot is registered. This API uses an asynchronous callback to return the result. +Obtains a list of signal strengths of the network with which the SIM card in the specified slot is registered. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Telephony.CoreService @@ -356,7 +356,7 @@ radio.getSignalInformation(slotId, (err, data) => { getSignalInformation\(slotId: number\): Promise\> -Obtains a list of signal strengths of the network with which the SIM card in the specified slot is registered. This API uses a promise to return the result. +Obtains a list of signal strengths of the network with which the SIM card in the specified slot is registered. This API uses a promise to return the result. **System capability**: SystemCapability.Telephony.CoreService @@ -384,12 +384,16 @@ promise.then(data => { }); ``` -## radio.isNrSupported7+ +## radio.isNrSupported(deprecated) isNrSupported\(\): boolean Checks whether the current device supports 5G \(NR\). +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [isNRSupported](#radioisnrsupported9) instead. + **System capability**: SystemCapability.Telephony.CoreService **Return value** @@ -405,12 +409,15 @@ let result = radio.isNrSupported(); console.log("Result: "+ result); ``` - -## radio.isNrSupported8+ +## radio.isNrSupported(deprecated) isNrSupported\(slotId: number\): boolean -Checks whether the current device supports 5G \(NR\) for the SIM card in the specified slot. +Checks whether the current device supports 5G \(NR\). + +> **NOTE** +> +> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [isNRSupported](#radioisnrsupported9-1) instead. **System capability**: SystemCapability.Telephony.CoreService @@ -435,6 +442,57 @@ console.log("Result: "+ result); ``` +## radio.isNRSupported9+ + +isNRSupported\(\): boolean + +Checks whether the current device supports 5G \(NR\). + +**System capability**: SystemCapability.Telephony.CoreService + +**Return value** + +| Type | Description | +| ------- | -------------------------------- | +| boolean | - **true**: The current device supports 5G \(NR\).
- **false**: The current device does not support 5G \(NR\).| + +**Example** + +```js +let result = radio.isNRSupported(); +console.log("Result: "+ result); +``` + + +## radio.isNRSupported9+ + +isNRSupported\(slotId: number\): boolean + +Checks whether the current device supports 5G \(NR\). + +**System capability**: SystemCapability.Telephony.CoreService + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | -------------------------------------- | +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| + +**Return value** + +| Type | Description | +| ------------------ | ------------------------------------------------------------ | +| boolean | - **true**: The current device supports 5G \(NR\).
- **false**: The current device does not support 5G \(NR\).| + +**Example** + +```js +let slotId = 0; +let result = radio.isNRSupported(slotId); +console.log("Result: "+ result); +``` + + ## radio.isRadioOn7+ isRadioOn\(callback: AsyncCallback\): void @@ -596,7 +654,7 @@ Sets the ID of the slot in which the primary card is located. This API uses an a | Name | Type | Mandatory| Description | | -------- | --------------------- | ---- | -------------------------------------- | | slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| -| callback | AsyncCallback\ | Yes | Callback used to return the result. | +| callback | AsyncCallback\ | Yes | Callback used to return the result. | **Example** @@ -675,7 +733,7 @@ radio.getIMEI((err, data) => { getIMEI(slotId: number, callback: AsyncCallback): void -Obtains the IMEI of the SIM card in the specified slot. This API uses an asynchronous callback to return the result. +Obtains the IMEI of the SIM card in the specified card slot. This API uses an asynchronous callback to return the result. **System API**: This is a system API. @@ -704,7 +762,7 @@ radio.getIMEI(slotId, (err, data) => { getIMEI(slotId?: number): Promise -Obtains the IMEI of the SIM card in a card slot. This API uses a promise to return the result. +Obtains the IMEI of the SIM card in the specified card slot. This API uses a promise to return the result. **System API**: This is a system API. @@ -767,7 +825,7 @@ radio.getMEID((err, data) => { getMEID(slotId: number, callback: AsyncCallback): void -Obtains the MEID of the SIM card in the specified slot. This API uses an asynchronous callback to return the result. +Obtains the MEID of the SIM card in the specified card slot. This API uses an asynchronous callback to return the result. **System API**: This is a system API. @@ -796,7 +854,7 @@ radio.getMEID(slotId, (err, data) => { getMEID(slotId?: number): Promise -Obtains the MEID of the SIM card in the specified slot. This API uses a promise to return the result. +Obtains the MEID of the SIM card in the specified card slot. This API uses a promise to return the result. **System API**: This is a system API. @@ -859,7 +917,7 @@ radio.getUniqueDeviceId((err, data) => { getUniqueDeviceId(slotId: number, callback: AsyncCallback): void -Obtains the unique device ID of the SIM card in the specified slot. This API uses an asynchronous callback to return the result. +Obtains the unique device ID of the SIM card in the specified card slot. This API uses an asynchronous callback to return the result. **System API**: This is a system API. @@ -888,7 +946,7 @@ radio.getUniqueDeviceId(slotId, (err, data) => { getUniqueDeviceId(slotId?: number): Promise -Obtains the unique device ID of the SIM card in the specified slot. This API uses a promise to return the result. +Obtains the unique device ID of the SIM card in the specified card slot. This API uses a promise to return the result. **System API**: This is a system API. @@ -928,7 +986,7 @@ Sends a cell location update request. This API uses an asynchronous callback to **System API**: This is a system API. -**Required permissions**: ohos.permission.LOCATION +**Required permissions**: ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION **System capability**: SystemCapability.Telephony.CoreService @@ -954,7 +1012,7 @@ Sends a cell location update request for the SIM card in the specified slot. Thi **System API**: This is a system API. -**Required permissions**: ohos.permission.LOCATION +**Required permissions**: ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION **System capability**: SystemCapability.Telephony.CoreService @@ -978,11 +1036,11 @@ radio.sendUpdateCellLocationRequest(slotId, (err, data) => { sendUpdateCellLocationRequest\(slotId?: number): Promise -Sends a cell location update request for the SIM card in the specified slot.This API uses a promise to return the result. +Sends a cell location update request for the SIM card in the specified slot. This API uses a promise to return the result. **System API**: This is a system API. -**Required permissions**: ohos.permission.LOCATION +**Required permissions**: ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION **System capability**: SystemCapability.Telephony.CoreService @@ -1192,7 +1250,7 @@ promise.then(data => { getNetworkSearchInformation\(slotId: number, callback: AsyncCallback\): void -Obtains network search information for the SIM card in the specified slot. This API uses an asynchronous callback to return the result. +Obtains network search information for the SIM card in the specified slot. This API uses an asynchronous callback to return the result. **System API**: This is a system API. @@ -1205,7 +1263,7 @@ Obtains network search information for the SIM card in the specified slot. This | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------------------ | ---- | -------------------------------------- | | slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| -| callback | AsyncCallback\<[NetworkSearchResult](#networksearchresult)\> | Yes | Callback used to return the result. | +| callback | AsyncCallback\<[NetworkSearchResult](#networksearchresult)\> | Yes | Callback used to return the result. | **Example** @@ -1714,7 +1772,7 @@ promise.then(data => { on(type: 'imsRegStateChange', slotId: number, imsType: ImsServiceType, callback: Callback): void -Enables listening for **imsRegStateChange** events for the SIM card in the specified slot. This API uses an asynchronous callback to return the result. +Enables listening for **imsRegStateChange** events. This API uses an asynchronous callback to return the result. **System API**: This is a system API. @@ -1743,7 +1801,7 @@ radio.on('imsRegStateChange', 0, radio.ImsServiceType.TYPE_VIDEO, data => { off(type: 'imsRegStateChange', slotId: number, imsType: ImsServiceType, callback?: Callback): void -Disables listening for **imsRegStateChange** events for the SIM card in the specified slot. This API uses an asynchronous callback to return the result. +Disables listening for **imsRegStateChange** events. This API uses an asynchronous callback to return the result. **System API**: This is a system API. @@ -1770,7 +1828,7 @@ radio.off('imsRegStateChange', 0, radio.ImsServiceType.TYPE_VIDEO, data => { ## RadioTechnology -Enumerates radio access technologies. + Enumerates radio access technologies. **System capability**: SystemCapability.Telephony.CoreService @@ -1797,10 +1855,10 @@ Defines the signal strength. **System capability**: SystemCapability.Telephony.CoreService -| Name | Type | Mandatory | Description | -| -------- | ------- | --------- | ----------- | -| signalType | [NetworkType](#networktype) | Yes| Signal strength type.| -| signalLevel | number | Yes| Signal strength level.| +| Name | Type | Mandatory| Description | +| ----------- | --------------------------- | ---- | ----------------- | +| signalType | [NetworkType](#networktype) | Yes | Signal strength type.| +| signalLevel | number | Yes | Signal strength level.| ## NetworkType @@ -1825,17 +1883,17 @@ Defines the network status. **System capability**: SystemCapability.Telephony.CoreService -| Name | Type | Mandatory | Description | -| -------- | ------- | --------- | ----------- | -| longOperatorName | string | Yes | Long carrier name of the registered network.| -| shortOperatorName | string | Yes | Short carrier name of the registered network.| -| plmnNumeric | string | Yes | PLMN code of the registered network.| -| isRoaming | boolean | Yes | Whether the user is roaming.| -| regState | [RegState](#regstate) | Yes | Network registration status of the device.| -| cfgTech8+ | [RadioTechnology](#radiotechnology) | Yes | RAT of the device.| -| nsaState | [NsaState](#nsastate) | Yes | NSA network registration status of the device.| -| isCaActive | boolean | Yes | CA status.| -| isEmergency | boolean | Yes | Whether only emergency calls are allowed.| +| Name | Type | Mandatory| Description | +| -------------------- | ----------------------------------- | ---- | ------------------------------------------------------------ | +| longOperatorName | string | Yes | Long carrier name of the registered network. | +| shortOperatorName | string | Yes | Short carrier name of the registered network. | +| plmnNumeric | string | Yes | PLMN code of the registered network. | +| isRoaming | boolean | Yes | Whether the user is roaming. | +| regState | [RegState](#regstate) | Yes | Network registration status of the device. | +| cfgTech8+ | [RadioTechnology](#radiotechnology) | Yes | RAT of the device. | +| nsaState | [NsaState](#nsastate) | Yes | NSA network registration status of the device. | +| isCaActive | boolean | Yes | CA status. | +| isEmergency | boolean | Yes | Whether only emergency calls are allowed. | ## RegState @@ -1848,7 +1906,7 @@ Defines the network status. | ----------------------------- | ---- | -------------------------- | | REG_STATE_NO_SERVICE | 0 | The device cannot use any services, including data, SMS, and call services. | | REG_STATE_IN_SERVICE | 1 | The device can use services properly, including data, SMS, and call services. | -| REG_STATE_EMERGENCY_CALL_ONLY | 2 | The device can use only the emergency call service. | +| REG_STATE_EMERGENCY_CALL_ONLY | 2 | The device can use only the emergency call service.| | REG_STATE_POWER_OFF | 3 | The device cannot communicate with the network because the cellular radio service is disabled or the modem is powered off. | @@ -1922,7 +1980,7 @@ Enumerates preferred network modes. | PREFERRED_NETWORK_MODE_NR_LTE_TDSCDMA_GSM | 38 | NR+LTE+TD-SCDMA+GSM network mode. | | PREFERRED_NETWORK_MODE_NR_LTE_TDSCDMA_WCDMA | 39 | NR+LTE+TD-SCDMA+WCDMA network mode. | | PREFERRED_NETWORK_MODE_NR_LTE_TDSCDMA_WCDMA_GSM | 40 | NR+LTE+TD-SCDMA+WCDMA+GSM network mode. | -| PREFERRED_NETWORK_MODE_NR_LTE_TDSCDMA_WCDMA_GSM_EVDO_CDMA | 41 | NR+LTE+TD-SCDMA+WCDMA+GSM+EVDO+CDMA network mode. | +| PREFERRED_NETWORK_MODE_NR_LTE_TDSCDMA_WCDMA_GSM_EVDO_CDMA | 41 | NR+LTE+TD-SCDMA+WCDMA+GSM network mode. | | PREFERRED_NETWORK_MODE_MAX_VALUE | 99 | Maximum value of the preferred network mode. | ## CellInformation8+ @@ -1933,13 +1991,13 @@ Defines the cell information. **System capability**: SystemCapability.Telephony.CoreService -| Name | Type | Mandatory | Description | -| -------- | ------- | --------- | ----------- | -| networkType | [NetworkType](#networktype) | Yes | Network type of the cell. | -| isCamped | boolean | Yes | Status of the cell. | -| timeStamp | number | Yes | Timestamp when cell information is obtained. | -| signalInformation | [SignalInformation](#signalinformation) | Yes | Signal information. | -| data | [CdmaCellInformation](#cdmacellinformation8) \| [GsmCellInformation](#gsmcellinformation8) \| [LteCellInformation](#ltecellinformation8) \| [NrCellInformation](#nrcellinformation8) \| [TdscdmaCellInformation](#tdscdmacellinformation8) | Yes | CDMA cell information \|GSM cell information \|LTE cell information \|NR cell information \|TD-SCDMA cell information| +| Name | Type | Mandatory| Description | +| ----------------- | --------------------------------------- | ---- | ------------------------------------------------------------ | +| networkType | [NetworkType](#networktype) | Yes | Network type of the cell. | +| isCamped | boolean | Yes | Cell status. | +| timeStamp | number | Yes | Timestamp when cell information is obtained. | +| signalInformation | [SignalInformation](#signalinformation) | Yes | Signal information. | +| data | [CdmaCellInformation](#cdmacellinformation8) \| [GsmCellInformation](#gsmcellinformation8) \| [LteCellInformation](#ltecellinformation8) \| [NrCellInformation](#nrcellinformation8) \| [TdscdmaCellInformation](#tdscdmacellinformation8) | Yes | CDMA cell information\|GSM cell information\|LTE cell information\|NR cell information\|TD-SCDMA cell information| ## CdmaCellInformation8+ @@ -1949,13 +2007,13 @@ Defines the CDMA cell information. **System capability**: SystemCapability.Telephony.CoreService -| Name | Type | Mandatory | Description | -| -------- | ------- | --------- | ----------- | -| baseId | number | Yes | Base station ID. | -| latitude | number | Yes | Longitude. | -| longitude | number | Yes | Latitude. | -| nid | number | Yes | Network ID.| -| sid | number | Yes | System ID.| +| Name | Type | Mandatory| Description | +| --------- | ------ | ---- | ------------ | +| baseId | number | Yes | Base station ID. | +| latitude | number | Yes | Longitude. | +| longitude | number | Yes | Latitude. | +| nid | number | Yes | Network ID.| +| sid | number | Yes | System ID.| ## GsmCellInformation8+ @@ -1965,50 +2023,50 @@ Defines the GSM cell information. **System capability**: SystemCapability.Telephony.CoreService -| Name | Type | Mandatory | Description | -| -------- | ------- | --------- | ----------- | -| lac | number | Yes | Location area code. | -| cellId | number | Yes | Cell ID. | -| arfcn | number | Yes | Absolute radio frequency channel number.| -| bsic | number | Yes | Base station ID. | -| mcc | string | Yes | Mobile country code. | -| mnc | string | Yes | Mobile network code. | +| Name | Type | Mandatory| Description | +| ------ | ------ | ---- | -------------------- | +| lac | number | Yes | Location area code. | +| cellId | number | Yes | Cell ID. | +| arfcn | number | Yes | Absolute radio frequency channel number.| +| bsic | number | Yes | Base station ID. | +| mcc | string | Yes | Mobile country code. | +| mnc | string | Yes | Mobile network code. | ## LteCellInformation8+ -Defines the LTE cell information. +LTE cell information. **System API**: This is a system API. **System capability**: SystemCapability.Telephony.CoreService -| Name | Type | Mandatory | Description | -| -------- | ------- | --------- | ----------- | -| cgi | number | Yes | Cell global identification. | -| pci | number | Yes | Physical cell ID. | -| tac | number | Yes | Tracking area code. | -| earfcn | number | Yes | Absolute radio frequency channel number. | -| bandwidth | number | Yes | Bandwidth. | -| mcc | string | Yes | Mobile country code. | -| mnc | string | Yes | Mobile network code. | -| isSupportEndc | boolean | Yes | Support for New Radio_Dual Connectivity. | +| Name | Type | Mandatory| Description | +| ------------- | ------- | ---- | ----------------------- | +| cgi | number | Yes | Cell global identification. | +| pci | number | Yes | Physical cell ID. | +| tac | number | Yes | Tracking area code. | +| earfcn | number | Yes | Absolute radio frequency channel number. | +| bandwidth | number | Yes | Bandwidth. | +| mcc | string | Yes | Mobile country code. | +| mnc | string | Yes | Mobile network code. | +| isSupportEndc | boolean | Yes | Support for New Radio_Dual Connectivity.| ## NrCellInformation8+ -Defines the NR cell information. +Defines the 5G NR cell information. **System API**: This is a system API. **System capability**: SystemCapability.Telephony.CoreService -| Name | Type | Mandatory | Description | -| -------- | ------- | --------- | ----------- | -| nrArfcn | number | Yes | 5G frequency number. | -| pci | number | Yes | Physical cell ID. | -| tac | number | Yes | Tracking area code. | -| nci | number | Yes | 5G network cell ID.| -| mcc | string | Yes | Mobile country code. | -| mnc | string | Yes | Mobile network code. | +| Name | Type | Mandatory| Description | +| ------- | ------ | ---- | ---------------- | +| nrArfcn | number | Yes | 5G frequency number. | +| pci | number | Yes | Physical cell ID. | +| tac | number | Yes | Tracking area code. | +| nci | number | Yes | 5G network cell ID.| +| mcc | string | Yes | Mobile country code. | +| mnc | string | Yes | Mobile network code. | ## TdscdmaCellInformation8+ @@ -2018,14 +2076,14 @@ Defines the TD-SCDMA cell information. **System capability**: SystemCapability.Telephony.CoreService -| Name | Type | Mandatory | Description | -| -------- | ------- | --------- | ----------- | -| lac | number | Yes | Location area code.| -| cellId | number | Yes | Cell ID. | -| cpid | number | Yes | Cell parameter ID.| -| uarfcn | number | Yes | Absolute radio frequency number.| -| mcc | string | Yes | Mobile country code.| -| mnc | string | Yes | Mobile network code. | +| Name | Type | Mandatory| Description | +| ------ | ------ | ---- | ------------ | +| lac | number | Yes | Location area code.| +| cellId | number | Yes | Cell ID. | +| cpid | number | Yes | Cell parameter ID.| +| uarfcn | number | Yes | Absolute radio frequency number.| +| mcc | string | Yes | Mobile country code.| +| mnc | string | Yes | Mobile network code. | ## WcdmaCellInformation8+ @@ -2035,14 +2093,14 @@ Defines the WCDMA cell information. **System capability**: SystemCapability.Telephony.CoreService -| Name | Type | Mandatory | Description | -| -------- | ------- | --------- | ----------- | -| lac | number | Yes | Location area code.| -| cellId | number | Yes | Cell ID. | -| psc | number | Yes | Primary scrambling code. | -| uarfcn | number | Yes | Absolute radio frequency number.| -| mcc | string | Yes | Mobile country code.| -| mnc | string | Yes | Mobile network code. | +| Name | Type | Mandatory| Description | +| ------ | ------ | ---- | ------------ | +| lac | number | Yes | Location area code.| +| cellId | number | Yes | Cell ID. | +| psc | number | Yes | Primary scrambling code. | +| uarfcn | number | Yes | Absolute radio frequency number.| +| mcc | string | Yes | Mobile country code.| +| mnc | string | Yes | Mobile network code. | ## NrOptionMode8+ @@ -2056,7 +2114,7 @@ Enumerates NR selection modes. | -------------------- | ---- | ---------------------------------- | | NR_OPTION_UNKNOWN | 0 | Unknown NR selection mode. | | NR_OPTION_NSA_ONLY | 1 | NR selection mode in 5G non-standalone networking. | -| NR_OPTION_SA_ONLY | 2 | NR selection mode in 5G standalone networking. | +| NR_OPTION_SA_ONLY | 2 | NR selection mode in 5G non-standalone networking. | | NR_OPTION_NSA_AND_SA | 3 | NR selection mode in non-standalone and standalone networking.| ## NetworkSearchResult @@ -2067,10 +2125,10 @@ Defines the network search result. **System capability**: SystemCapability.Telephony.CoreService -| Name | Type | Mandatory | Description | -| -------- | ------- | --------- | ----------- | -| isNetworkSearchSuccess | boolean | Yes | Successful network search.| -| networkSearchResult | Array<[NetworkInformation](#networkinformation)\> | Yes | Network search result.| +| Name | Type | Mandatory| Description | +| ---------------------- | ------------------------------------------------- | ---- | -------------- | +| isNetworkSearchSuccess | boolean | Yes | Successful network search.| +| networkSearchResult | Array<[NetworkInformation](#networkinformation)\> | Yes | Network search result.| ## NetworkInformation @@ -2080,12 +2138,12 @@ Defines the network information. **System capability**: SystemCapability.Telephony.CoreService -| Name | Type | Mandatory | Description | -| -------- | ------- | --------- | ----------- | -| operatorName | string | Yes | Carrier name.| -| operatorNumeric | string | Yes | Carrier number. | -| state | [NetworkInformation](#networkinformationstate) | Yes | Network information status.| -| radioTech | string | Yes | Radio technology. | +| Name | Type | Mandatory| Description | +| --------------- | --------------------------------------------------- | ---- | -------------- | +| operatorName | string | Yes | Carrier name.| +| operatorNumeric | string | Yes | Carrier number. | +| state | [NetworkInformationState](#networkinformationstate) | Yes | Network information status.| +| radioTech | string | Yes | Radio access technology. | ## NetworkInformationState @@ -2110,12 +2168,12 @@ Defines the network selection mode. **System capability**: SystemCapability.Telephony.CoreService -| Name | Type | Mandatory | Description | -| -------- | ------- | --------- | ----------- | -| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| -| selectMode | [NetworkSelectionMode](#networkselectionmode) | Yes | Network selection mode. | -| networkInformation | [NetworkInformation](#networkinformation) | Yes | Network information. | -| resumeSelection | boolean | Yes | Whether to resume selection. | +| Name | Type | Mandatory| Description | +| ------------------ | --------------------------------------------- | ---- | -------------------------------------- | +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| +| selectMode | [NetworkSelectionMode](#networkselectionmode) | Yes | Network selection mode. | +| networkInformation | [NetworkInformation](#networkinformation) | Yes | Network information. | +| resumeSelection | boolean | Yes | Whether to resume selection. | ## ImsRegState9+ @@ -2153,10 +2211,10 @@ Defines the IMS registration information. **System capability**: SystemCapability.Telephony.CoreService -| Name | Type | Mandatory | Description | -| -------- | ------- | --------- | ----------- | -| imsRegState | [ImsRegState](#imsregstate9) | Yes | IMS registration state.| -| imsRegTech | [ImsRegTech](#imsregtech9) | Yes | IMS registration technology.| +| Name | Type | Mandatory| Description | +| ----------- | ---------------------------- | ---- | ------------- | +| imsRegState | [ImsRegState](#imsregstate9) | Yes | IMS registration state.| +| imsRegTech | [ImsRegTech](#imsregtech9) | Yes | IMS registration technology.| ## ImsServiceType9+ diff --git a/en/application-dev/reference/apis/js-apis-resource-manager.md b/en/application-dev/reference/apis/js-apis-resource-manager.md index 7dc343709c..54cf7cc816 100644 --- a/en/application-dev/reference/apis/js-apis-resource-manager.md +++ b/en/application-dev/reference/apis/js-apis-resource-manager.md @@ -15,8 +15,8 @@ import resourceManager from '@ohos.resourceManager'; ## Instruction -Since API version 9, the stage model allows an application to obtain a **ResourceManager** object based on **context** and call its resource management APIs without first importing the required bundle. This approach, however, is not applicable to the FA model. -For details about how to reference **context** in the stage model, see [Context in the Stage Model](../../application-models/application-context-stage.md). +Since API version 9, the stage model allows an application to obtain a **ResourceManager** object based on **context** and call its resource management APIs without first importing the required bundle. This approach, however, is not applicable to the FA model. For the FA model, you need to import the required bundle and then call the [getResourceManager](#resourcemanagergetresourcemanager) API to obtain a **ResourceManager** object. +For details about how to reference context in the stage model, see [Context in the Stage Model](../..//application-models/application-context-stage.md). ```ts import Ability from '@ohos.application.Ability'; @@ -60,6 +60,7 @@ Obtains the **ResourceManager** object of this application. This API uses an asy }); }); ``` +> **NOTE**
In the sample code, **0x1000000** indicates the resource ID, which can be found in the compiled **ResourceTable.txt** file. ## resourceManager.getResourceManager @@ -116,6 +117,7 @@ Obtains the **ResourceManager** object of this application. This API uses a prom console.log("error is " + error); }); ``` +> **NOTE**
In the sample code, **0x1000000** indicates the resource ID, which can be found in the compiled **ResourceTable.txt** file. ## resourceManager.getResourceManager @@ -1767,7 +1769,7 @@ For details about the error codes, see [Resource Manager Error Codes](../errorco getMediaByName(resName: string, callback: AsyncCallback<Uint8Array>): void -Obtains the content of the media file corresponding to the specified resource name. This API uses an asynchronous callback to return the result. +Obtains the content of the media file corresponding to the specified resource ID. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Global.ResourceManager diff --git a/en/application-dev/reference/apis/js-apis-usb-deprecated.md b/en/application-dev/reference/apis/js-apis-usb-deprecated.md index 95eb105b0a..fd71b32b8b 100644 --- a/en/application-dev/reference/apis/js-apis-usb-deprecated.md +++ b/en/application-dev/reference/apis/js-apis-usb-deprecated.md @@ -5,6 +5,7 @@ The **usb** module provides USB device management functions, including USB devic > **NOTE** > > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> The APIs provided by this module are no longer maintained since API version 9. You are advised to use [`@ohos.usbManager`](js-apis-usbManager.md) instead. ## Modules to Import diff --git a/en/application-dev/reference/apis/js-apis-usb.md b/en/application-dev/reference/apis/js-apis-usb.md index 358b80bf5b..52eb0d9543 100644 --- a/en/application-dev/reference/apis/js-apis-usb.md +++ b/en/application-dev/reference/apis/js-apis-usb.md @@ -4,6 +4,7 @@ The **usb** module provides USB device management functions, including USB devic > **NOTE**
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> The APIs provided by this module are no longer maintained since API version 9. You are advised to use [`@ohos.usbManager`](js-apis-usbManager.md) instead. ## Modules to Import diff --git a/en/application-dev/reference/apis/js-apis-usbManager.md b/en/application-dev/reference/apis/js-apis-usbManager.md new file mode 100644 index 0000000000..96da37cd6d --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-usbManager.md @@ -0,0 +1,950 @@ +# @ohos.usbManager (USB Manager) + +The **usbManager** module provides USB device management functions, including USB device list query, bulk data transfer, control transfer, and permission control on the host side as well as port management, and function switch and query on the device side. + +> **NOTE** +> +> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. + +## Modules to Import + +```js +import usb from "@ohos.usbManager"; +``` + +## usb.getDevices + +getDevices(): Array<Readonly<USBDevice>> + +Obtains the list of USB devices connected to the host. If no device is connected, an empty list is returned. + +**System capability**: SystemCapability.USB.USBManager + +**Return value** + +| Type | Description | +| ---------------------------------------------------- | ------- | +| Array<Readonly<[USBDevice](#usbdevice)>> | USB device list.| + +**Example** + +```js +let devicesList = usb.getDevices(); +console.log(`devicesList = ${JSON.stringify(devicesList)}`); +// devicesList is a list of USB devices. +// A simple example of devicesList is provided as follows: +[ + { + name: "1-1", + serial: "", + manufacturerName: "", + productName: "", + version: "", + vendorId: 7531, + productId: 2, + clazz: 9, + subClass: 0, + protocol: 1, + devAddress: 1, + busNum: 1, + configs: [ + { + id: 1, + attributes: 224, + isRemoteWakeup: true, + isSelfPowered: true, + maxPower: 0, + name: "1-1", + interfaces: [ + { + id: 0, + protocol: 0, + clazz: 9, + subClass: 0, + alternateSetting: 0, + name: "1-1", + endpoints: [ + { + address: 129, + attributes: 3, + interval: 12, + maxPacketSize: 4, + direction: 128, + number: 1, + type: 3, + interfaceId: 0, + }, + ], + }, + ], + }, + ], + }, +] +``` + +## usb.connectDevice + +connectDevice(device: USBDevice): Readonly<USBDevicePipe> + +Connects to the USB device based on the device information returned by **getDevices()**. + +Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB device list and device information, and then call [usb.requestRight](#usbrequestright) to request the device access permission. + +**System capability**: SystemCapability.USB.USBManager + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| device | [USBDevice](#usbdevice) | Yes| USB device information.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| Readonly<[USBDevicePipe](#usbdevicepipe)> | USB device pipe for data transfer.| + +**Error codes** + +For details about the error codes, see [USB Error Codes](../errorcodes/errorcode-usb.md). + +| ID| Error Message| +| -------- | -------- | +| 14400001 |Permission denied. Need call requestRight to get permission. | + +**Example** + +```js +let devicesList = usb.getDevices(); +if (devicesList.length == 0) { + console.log(`device list is empty`); + return; +} + +let device = devicesList[0]; +usb.requestRight(device.name); +let devicepipe = usb.connectDevice(device); +console.log(`devicepipe = ${JSON.stringify(devicepipe)}`); +``` + +## usb.hasRight + +hasRight(deviceName: string): boolean + +Checks whether the application has the permission to access the device. + +Checks whether the user, for example, the application or system, has the device access permissions. The value **true** is returned if the user has the device access permissions; the value **false** is returned otherwise. + +**System capability**: SystemCapability.USB.USBManager + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| deviceName | string | Yes| Device name.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the application has the permission to access the device; returns **false** otherwise.| + +**Example** + +```js +let devicesName="1-1"; +let bool = usb.hasRight(devicesName); +console.log(bool); +``` + +## usb.requestRight + +requestRight(deviceName: string): Promise<boolean> + +Requests the temporary permission for the application to access a USB device. This API uses a promise to return the result. + +**System capability**: SystemCapability.USB.USBManager + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| deviceName | string | Yes| Device name.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| Promise<boolean> | Promise used to return the result. The value **true** indicates that the temporary device access permissions are granted; and the value **false** indicates the opposite.| + +**Example** + +```js +let devicesName="1-1"; +usb.requestRight(devicesName).then((ret) => { + console.log(`requestRight = ${JSON.stringify(ret)}`); +}); +``` + +## usb.removeRight + +removeRight(deviceName: string): boolean + +Removes the permission for the application to access a USB device. + +**System capability**: SystemCapability.USB.USBManager + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| deviceName | string | Yes| Device name.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Permission removal result. The value **true** indicates that the access permission is removed successfully; and the value **false** indicates the opposite.| + +**Example** + +```js +let devicesName="1-1"; +if (usb.removeRight(devicesName) { + console.log(`Succeed in removing right`); +} +``` + +## usb.addRight + +addRight(bundleName: string, deviceName: string): boolean + +Adds the permission for the application to access a USB device. + +[requestRight](#usbrequestright) triggers a dialog box to request for user authorization, whereas **addRight** adds the access permission directly without displaying a dialog box. + +**System API**: This is a system API. + +**System capability**: SystemCapability.USB.USBManager + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| deviceName | string | Yes| Device name.| +| bundleName | string | Yes| Bundle name of the application.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Permission addition result. The value **true** indicates that the access permission is added successfully; and the value **false** indicates the opposite.| + +**Example** + +```js +let devicesName = "1-1"; +let bundleName = "com.example.hello"; +if (usb.addRight(bundleName, devicesName) { + console.log(`Succeed in adding right`); +} +``` + +## usb.claimInterface + +claimInterface(pipe: USBDevicePipe, iface: USBInterface, force ?: boolean): number + +Claims a USB interface. + +Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB device list and USB interfaces, call [usb.requestRight](#usbrequestright) to request the device access permission, and call [usb.connectDevice](#usbconnectdevice) to obtain **devicepipe** as an input parameter. + +**System capability**: SystemCapability.USB.USBManager + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.| +| iface | [USBInterface](#usbinterface) | Yes| USB interface, which is used to determine the index of the interface to claim.| +| force | boolean | No| Whether to forcibly claim the USB interface. The default value is **false**, indicating not to forcibly claim the USB interface.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| number | Returns **0** if the USB interface is successfully claimed; returns an error code otherwise.| + +**Example** + +```js +let ret = usb.claimInterface(devicepipe, interfaces); +console.log(`claimInterface = ${ret}`); +``` + +## usb.releaseInterface + +releaseInterface(pipe: USBDevicePipe, iface: USBInterface): number + +Releases a USB interface. + +Before you do this, ensure that you have claimed the interface by calling [usb.claimInterface](#usbclaiminterface). + +**System capability**: SystemCapability.USB.USBManager + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.| +| iface | [USBInterface](#usbinterface) | Yes| USB interface, which is used to determine the index of the interface to release.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| number | Returns **0** if the USB interface is successfully released; returns an error code otherwise.| + +**Example** + +```js +let ret = usb.releaseInterface(devicepipe, interfaces); +console.log(`releaseInterface = ${ret}`); +``` + +## usb.setConfiguration + +setConfiguration(pipe: USBDevicePipe, config: USBConfiguration): number + +Sets the device configuration. + +Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB device list and device configuration, call [usb.requestRight](#usbrequestright) to request the device access permission, and call [usb.connectDevice](#usbconnectdevice) to obtain **devicepipe** as an input parameter. + +**System capability**: SystemCapability.USB.USBManager + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.| +| config | [USBConfiguration](#usbconfiguration) | Yes| USB configuration to set.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| number | Returns **0** if the USB configuration is successfully set; returns an error code otherwise.| + +**Example** + +```js +let ret = usb.setConfiguration(devicepipe, config); +console.log(`setConfiguration = ${ret}`); +``` + +## usb.setInterface + +setInterface(pipe: USBDevicePipe, iface: USBInterface): number + +Sets a USB interface. + +Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB device list and interfaces, call [usb.requestRight](#usbrequestright) to request the device access permission, call [usb.connectDevice](#usbconnectdevice) to obtain **devicepipe** as an input parameter, and call [usb.claimInterface](#usbclaiminterface) to claim the USB interface. + +**System capability**: SystemCapability.USB.USBManager + +**Parameters** + +| Name | Type | Mandatory | Description | +| ----- | ------------------------------- | --- | ------------- | +| pipe | [USBDevicePipe](#usbdevicepipe) | Yes | Device pipe, which is used to determine the bus number and device address.| +| iface | [USBInterface](#usbinterface) | Yes | USB interface to set. | + +**Return value** + +| Type| Description| +| -------- | -------- | +| number | Returns **0** if the USB interface is successfully set; returns an error code otherwise.| + +**Example** + +```js +let ret = usb.setInterface(devicepipe, interfaces); +console.log(`setInterface = ${ret}`); +``` + +## usb.getRawDescriptor + +getRawDescriptor(pipe: USBDevicePipe): Uint8Array + +Obtains the raw USB descriptor. + +Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB device list, call [usb.requestRight](#usbrequestright) to request the device access permission, and call [usb.connectDevice](#usbconnectdevice) to obtain **devicepipe** as an input parameter. + +**System capability**: SystemCapability.USB.USBManager + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| Uint8Array | Returns the raw USB descriptor if the operation is successful; returns **undefined** otherwise.| + +**Example** + +```js +let ret = usb.getRawDescriptor(devicepipe); +``` + +## usb.getFileDescriptor + +getFileDescriptor(pipe: USBDevicePipe): number + +Obtains the file descriptor. + +Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB device list, call [usb.requestRight](#usbrequestright) to request the device access permission, and call [usb.connectDevice](#usbconnectdevice) to obtain **devicepipe** as an input parameter. + +**System capability**: SystemCapability.USB.USBManager + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.| + +**Return value** + +| Type | Description | +| ------ | -------------------- | +| number | Returns the file descriptor of the USB device if the operation is successful; returns **-1** otherwise.| + +**Example** + +```js +let ret = usb.getFileDescriptor(devicepipe); +``` + +## usb.controlTransfer + +controlTransfer(pipe: USBDevicePipe, controlparam: USBControlParams, timeout ?: number): Promise<number> + +Performs control transfer. + +Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB device list, call [usb.requestRight](#usbrequestright) to request the device access permission, and call [usb.connectDevice](#usbconnectdevice) to obtain **devicepipe** as an input parameter. + +**System capability**: SystemCapability.USB.USBManager + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| USB device pipe, which is used to determine the USB device.| +| controlparam | [USBControlParams](#usbcontrolparams) | Yes| Control transfer parameters.| +| timeout | number | No| Timeout duration in ms. This parameter is optional. The default value is **0**, indicating no timeout.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| Promise<number> | Promise used to return the result, which is the size of the transmitted or received data block if the transfer is successful, or **-1** if an exception has occurred.| + +**Example** + +```js +usb.controlTransfer(devicepipe, USBControlParams).then((ret) => { + console.log(`controlTransfer = ${JSON.stringify(ret)}`); +}) +``` + +## usb.bulkTransfer + +bulkTransfer(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, timeout ?: number): Promise<number> + +Performs bulk transfer. + +Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB device list and endpoints, call [usb.requestRight](#usbrequestright) to request the device access permission, call [usb.connectDevice](#usbconnectdevice) to obtain **devicepipe** as an input parameter, and call [usb.claimInterface](#usbclaiminterface) to claim the USB interface. + +**System capability**: SystemCapability.USB.USBManager + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| USB device pipe, which is used to determine the USB device.| +| endpoint | [USBEndpoint](#usbendpoint) | Yes| USB endpoint, which is used to determine the USB port for data transfer.| +| buffer | Uint8Array | Yes| Buffer for writing or reading data.| +| timeout | number | No| Timeout duration in ms. This parameter is optional. The default value is **0**, indicating no timeout.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| Promise<number> | Promise used to return the result, which is the size of the transmitted or received data block if the transfer is successful, or **-1** if an exception has occurred.| + +**Example** + +```js +// Call usb.getDevices to obtain a data set. Then, obtain a USB device and its access permission. +// Pass the obtained USB device as a parameter to usb.connectDevice. Then, call usb.connectDevice to connect the USB device. +// Call usb.claimInterface to claim the USB interface. After that, call usb.bulkTransfer to start bulk transfer. +usb.bulkTransfer(devicepipe, endpoint, buffer).then((ret) => { + console.log(`bulkTransfer = ${JSON.stringify(ret)}`); +}); +``` + +## usb.closePipe + +closePipe(pipe: USBDevicePipe): number + +Closes a USB device pipe. + +Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB device list, call [usb.requestRight](#usbrequestright) to request the device access permission, and call [usb.connectDevice](#usbconnectdevice) to obtain **devicepipe** as an input parameter. + +**System capability**: SystemCapability.USB.USBManager + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| USB device pipe.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| number | Returns **0** if the USB device pipe is closed successfully; returns an error code otherwise.| + +**Example** + +```js +let ret = usb.closePipe(devicepipe); +console.log(`closePipe = ${ret}`); +``` + +## usb.usbFunctionsFromString + +usbFunctionsFromString(funcs: string): number + +Converts the USB function list in the string format to a numeric mask in Device mode. + +**System API**: This is a system API. + +**System capability**: SystemCapability.USB.USBManager + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ---------------------- | +| funcs | string | Yes | Function list in string format.| + +**Return value** + +| Type | Description | +| ------ | ------------------ | +| number | Function list in numeric mask format.| + +**Example** + +```js +let funcs = "acm"; +let ret = usb.usbFunctionsFromString(funcs); +``` + +## usb.usbFunctionsToString + +usbFunctionsToString(funcs: FunctionType): string + +Converts the USB function list in the numeric mask format to a string in Device mode. + +**System API**: This is a system API. + +**System capability**: SystemCapability.USB.USBManager + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------------------------------ | ---- | ----------------- | +| funcs | [FunctionType](#functiontype) | Yes | USB function list in numeric mask format.| + +**Return value** + +| Type | Description | +| ------ | ------------------------------ | +| string | Function list in string format.| + +**Example** + +```js +let funcs = ACM | ECM; +let ret = usb.usbFunctionsToString(funcs); +``` + +## usb.setCurrentFunctions + +setCurrentFunctions(funcs: FunctionType): Promise\ + +Sets the current USB function list in Device mode. + +**System API**: This is a system API. + +**System capability**: SystemCapability.USB.USBManager + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------------------------------ | ---- | ----------------- | +| funcs | [FunctionType](#functiontype) | Yes | USB function list in numeric mask format.| + +**Return value** + +| Type | Description | +| --------------- | ------------- | +| Promise\ | Promise used to return the result.| + +**Example** + +```js +let funcs = HDC; +usb.setCurrentFunctions(funcs).then(() => { + console.info('usb setCurrentFunctions successfully.'); +}).catch(err => { + console.error('usb setCurrentFunctions failed: ' + err.code + ' message: ' + err.message); +}); +``` + +## usb.getCurrentFunctions + +getCurrentFunctions(): FunctionType + +Obtains the numeric mask combination for the USB function list in Device mode. + +**System API**: This is a system API. + +**System capability**: SystemCapability.USB.USBManager + +**Return value** + +| Type | Description | +| ------------------------------ | --------------------------------- | +| [FunctionType](#functiontype) | Numeric mask combination for the USB function list.| + +**Example** + +```js +let ret = usb.getCurrentFunctions(); +``` + +## usb.getPorts + +getPorts(): Array\ + +Obtains the list of all physical USB ports. + +**System API**: This is a system API. + +**System capability**: SystemCapability.USB.USBManager + +**Return value** + +| Type | Description | +| ----------------------------- | --------------------- | +| [Array\](#usbport) | List of physical USB ports.| + +**Example** + +```js +let ret = usb.getPorts(); +``` + +## usb.getSupportedModes + +getSupportedModes(portId: number): PortModeType + +Obtains the mask combination for the supported mode list of a given USB port. + +**System API**: This is a system API. + +**System capability**: SystemCapability.USB.USBManager + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | -------- | +| portId | number | Yes | Port number.| + +**Return value** + +| Type | Description | +| ------------------------------ | -------------------------- | +| [PortModeType](#portmodetype) | Mask combination for the supported mode list.| + +**Example** + +```js +let ret = usb.getSupportedModes(0); +``` + +## usb.setPortRoles + +setPortRoles(portId: number, powerRole: PowerRoleType, dataRole: DataRoleType): Promise\ + +Sets the role types supported by a specified port, which can be **powerRole** (for charging) and **dataRole** (for data transfer). + +**System API**: This is a system API. + +**System capability**: SystemCapability.USB.USBManager + +**Parameters** + +| Name | Type | Mandatory| Description | +| --------- | -------------------------------- | ---- | ---------------- | +| portId | number | Yes | Port number. | +| powerRole | [PowerRoleType](#powerroletype) | Yes | Role for charging. | +| dataRole | [DataRoleType](#dataroletype) | Yes | Role for data transfer.| + +**Return value** + +| Type | Description | +| --------------- | ------------- | +| Promise\ | Promise used to return the result.| + +**Example** + +```js +let portId = 1; +usb.usb.setPortRoles(portId, usb.PowerRoleType.SOURCE, usb.DataRoleType.HOST).then(() => { + console.info('usb setPortRoles successfully.'); +}).catch(err => { + console.error('usb setPortRoles failed: ' + err.code + ' message: ' + err.message); +}); +``` + +## USBEndpoint + +Represents the USB endpoint from which data is sent or received. You can obtain the USB endpoint through [USBInterface](#usbinterface). + +**System capability**: SystemCapability.USB.USBManager + +| Name | Type | Mandatory |Description | +| ------------- | ------------------------------------------- | ------------- |------------- | +| address | number | Yes|Endpoint address. | +| attributes | number | Yes|Endpoint attributes. | +| interval | number | Yes|Endpoint interval. | +| maxPacketSize | number | Yes|Maximum size of data packets on the endpoint. | +| direction | [USBRequestDirection](#usbrequestdirection) | Yes|Endpoint direction. | +| number | number | Yes|Endpoint number. | +| type | number | Yes|Endpoint type. | +| interfaceId | number | Yes|Unique ID of the interface to which the endpoint belongs.| + +## USBInterface + +Represents a USB interface. One [USBConfiguration](#usbconfiguration) object can contain multiple **USBInterface** instances, each providing a specific function. + +**System capability**: SystemCapability.USB.USBManager + +| Name | Type | Mandatory |Description | +| ---------------- | ---------------------------------------- | ------------- |--------------------- | +| id | number | Yes|Unique ID of the USB interface. | +| protocol | number | Yes|Interface protocol. | +| clazz | number | Yes|Device type. | +| subClass | number | Yes|Device subclass. | +| alternateSetting | number | Yes|Settings for alternating between descriptors of the same USB interface.| +| name | string | Yes|Interface name. | +| endpoints | Array<[USBEndpoint](#usbendpoint)> | Yes|Endpoints that belong to the USB interface. | + +## USBConfiguration + +Represents the USB configuration. One [USBDevice](#usbdevice) can contain multiple **USBConfig** instances. + +**System capability**: SystemCapability.USB.USBManager + +| Name | Type | Mandatory |Description | +| -------------- | ------------------------------------------------ | --------------- |--------------- | +| id | number | Yes|Unique ID of the USB configuration. | +| attributes | number | Yes|Configuration attributes. | +| maxPower | number | Yes|Maximum power consumption, in mA. | +| name | string | Yes|Configuration name, which can be left empty. | +| isRemoteWakeup | boolean | Yes|Support for remote wakeup.| +| isSelfPowered | boolean | Yes| Support for independent power supplies.| +| interfaces | Array <[USBInterface](#usbinterface)> | Yes|Supported interface attributes. | + +## USBDevice + +Represents the USB device information. + +**System capability**: SystemCapability.USB.USBManager + +| Name | Type | Mandatory |Description | +| ---------------- | ------------------------------------ | ---------- |---------- | +| busNum | number | Yes|Bus address. | +| devAddress | number | Yes|Device address. | +| serial | string | Yes|Sequence number. | +| name | string | Yes|Device name. | +| manufacturerName | string | Yes| Device manufacturer. | +| productName | string | Yes|Product name. | +| version | string | Yes|Version number. | +| vendorId | number | Yes|Vendor ID. | +| productId | number | Yes|Product ID. | +| clazz | number | Yes|Device class. | +| subClass | number | Yes|Device subclass. | +| protocol | number | Yes|Device protocol code. | +| configs | Array<[USBConfiguration](#usbconfiguration)> | Yes|Device configuration descriptor information.| + +## USBDevicePipe + +Represents a USB device pipe, which is used to determine a USB device. + +**System capability**: SystemCapability.USB.USBManager + +| Name | Type | Mandatory |Description | +| ---------- | ------ | ----- |----- | +| busNum | number |Yes| Bus address.| +| devAddress | number |Yes| Device address.| + +## USBControlParams + +Represents control transfer parameters. + +**System capability**: SystemCapability.USB.USBManager + +| Name | Type | Mandatory |Description | +| ------- | ----------------------------------------------- | ---------------- |---------------- | +| request | number | Yes |Request type. | +| target | [USBRequestTargetType](#usbrequesttargettype) | Yes |Request target type. | +| reqType | [USBControlRequestType](#usbcontrolrequesttype) | Yes |Control request type. | +| value | number | Yes |Request parameter value. | +| index | number | Yes |Index of the request parameter value.| +| data | Uint8Array | Yes |Buffer for writing or reading data. | + +## USBPort + +Represents a USB port. + +**System API**: This is a system API. + +**System capability**: SystemCapability.USB.USBManager + +| Name | Type | Mandatory |Description | +| -------------- | ------------------------------- | ------------------- |------------------------ | +| id | number | Yes |Unique identifier of a USB port. | +| supportedModes | [PortModeType](#portmodetype) | Yes |Numeric mask combination for the supported mode list.| +| status | [USBPortStatus](#usbportstatus) | Yes |USB port role. | + +## USBPortStatus + +Enumerates USB port roles. + +**System API**: This is a system API. + +**System capability**: SystemCapability.USB.USBManager + +| Name | Type| Mandatory |Description | +| ---------------- | -------- | ---------------- |---------------------- | +| currentMode | number | Yes|Current USB mode. | +| currentPowerRole | number | Yes |Current power role. | +| currentDataRole | number | Yes |Current data role.| + +## USBRequestTargetType + +Enumerates request target types. + +**System capability**: SystemCapability.USB.USBManager + +| Name | Value | Description | +| ---------------------------- | ---- | ------ | +| USB_REQUEST_TARGET_DEVICE | 0 | Device.| +| USB_REQUEST_TARGET_INTERFACE | 1 | Interface.| +| USB_REQUEST_TARGET_ENDPOINT | 2 | Endpoint.| +| USB_REQUEST_TARGET_OTHER | 3 | Other.| + +## USBControlRequestType + +Enumerates control request types. + +**System capability**: SystemCapability.USB.USBManager + +| Name | Value | Description | +| ------------------------- | ---- | ------ | +| USB_REQUEST_TYPE_STANDARD | 0 | Standard.| +| USB_REQUEST_TYPE_CLASS | 1 | Class. | +| USB_REQUEST_TYPE_VENDOR | 2 | Vendor.| + +## USBRequestDirection + +Enumerates request directions. + +**System capability**: SystemCapability.USB.USBManager + +| Name | Value | Description | +| --------------------------- | ---- | ------------------------ | +| USB_REQUEST_DIR_TO_DEVICE | 0 | Request for writing data from the host to the device.| +| USB_REQUEST_DIR_FROM_DEVICE | 0x80 | Request for reading data from the device to the host.| + +## FunctionType + +Enumerates USB device function types. + +**System API**: This is a system API. + +**System capability**: SystemCapability.USB.USBManager + +| Name | Value | Description | +| ------------ | ---- | ---------- | +| NONE | 0 | No function.| +| ACM | 1 | ACM function. | +| ECM | 2 | ECM function. | +| HDC | 4 | HDC function. | +| MTP | 8 | Not supported currently.| +| PTP | 16 | Not supported currently.| +| RNDIS | 32 | Not supported currently.| +| MIDI | 64 | Not supported currently.| +| AUDIO_SOURCE | 128 | Not supported currently.| +| NCM | 256 | Not supported currently.| + +## PortModeType + +Enumerates USB port mode types. + +**System API**: This is a system API. + +**System capability**: SystemCapability.USB.USBManager + +| Name | Value | Description | +| --------- | ---- | ---------------------------------------------------- | +| NONE | 0 | None | +| UFP | 1 | Upstream facing port, which functions as the sink of power supply. | +| DFP | 2 | Downstream facing port, which functions as the source of power supply. | +| DRP | 3 | Dynamic reconfiguration port (DRP), which can function as the DFP (host) or UFP (device). It is not supported currently.| +| NUM_MODES | 4 | Not supported currently. | + +## PowerRoleType + +Enumerates power role types. + +**System API**: This is a system API. + +**System capability**: SystemCapability.USB.USBManager + +| Name | Value | Description | +| ------ | ---- | ---------- | +| NONE | 0 | None | +| SOURCE | 1 | External power supply.| +| SINK | 2 | Internal power supply.| + +## DataRoleType + +Enumerates data role types. + +**System API**: This is a system API. + +**System capability**: SystemCapability.USB.USBManager + +| Name | Value | Description | +| ------ | ---- | ------------ | +| NONE | 0 | None | +| HOST | 1 | USB host.| +| DEVICE | 2 | USB device.| diff --git a/en/device-dev/subsystems/subsys-dfx-hisysevent-logging-config.md b/en/device-dev/subsystems/subsys-dfx-hisysevent-logging-config.md index 9b8204bc76..c74833145c 100644 --- a/en/device-dev/subsystems/subsys-dfx-hisysevent-logging-config.md +++ b/en/device-dev/subsystems/subsys-dfx-hisysevent-logging-config.md @@ -1,94 +1,108 @@ -# HiSysEvent Logging Configuration +# HiSysEvent Logging Configuration -## Overview -If HiSysEvent logging is required for a component, you need to define a YAML file and [configure the YAML file path](#section123181432175135) in the **bundle.json** file. During compilation, the OpenHarmony compilation framework will use the Python compilation script to parse and verify all the YAML files configured in the **bundle.json** file. On completion, the compilation framework will summarize the configuration information in the YAML files and convert the information into a JSON file named **hisysevent.def**. After that, the compilation framework will put the JSON file to a specified path as the basis for the system to determine whether to log system events. +## Overview -### Basic Concepts + +### Function Introduction + +If HiSysEvent logging is required for a component, you need to define a YAML file and [configure the YAML file path](#configuring-the-yaml-file-path) in the **bundle.json** file. During compilation, the OpenHarmony compilation framework will use the Python compilation script to parse and verify all the YAML files configured in the **bundle.json** file. On completion, the compilation framework will summarize the configuration information in the YAML files and convert the information into a JSON file named **hisysevent.def**. After that, the compilation framework will put the JSON file to a specified path as the basis for the system to determine whether to log system events. + + +### Basic Concepts Understanding the following concepts would be helpful for you in configuring HiSysEvent logging. -- Event domain - Represents the domain to which an event belongs. It is specified by the **domain** field in the YAML file. For details, see [domain](#section123181432175123) in the example YAML file. +- Event domain
Represents the domain to which an event belongs. It is specified by the **domain** field in the YAML file. For details, see [domain](#example) in the example YAML file. -- Event name - Indicates the events in an event domain. For details, see [EVENT\_NAMEA/EVENT\_NAMEB](#section123181432175123) in the example YAML file. +- Event name
Indicates the events in an event domain. For details, see [EVENT\_NAMEA/EVENT\_NAMEB](#example) in the example YAML file. -- Parameter - Defines the key values in an event name. For details, see [__BASE/NAME1/NAME2](#section123181432175123) in the example YAML file. +- Parameter
Defines the key values in an event name. For details, see [__BASE/NAME1/NAME2](#example) in the example YAML file. -### Constraints +### Constraints + +Constraints on the event domain, event name, and parameter - Each YAML file can contain only one event domain, and the domain name cannot be the same as that defined in other YAML files. - Zero or more event names can be defined for one event domain. The event names in the same event domain must be unique. -- Multiple parameters can be defined for one event name. The parameters in the same event name must be unique. There must be one and only one parameter named **\__BASE** in each event name. See Table 1 for the fields of this parameter and Table 2 for the fields of other custom parameters. - - **Table 1** Fields in the \__BASE parameter +- Multiple parameters can be defined for one event name. The parameters in the same event name must be unique. There must be only one parameter named **__BASE** in each event name. See Table 1 for the fields of this parameter and Table 2 for the fields of other custom parameters. + **Table 1** Fields in the \__BASE parameter + + | Field| Description| + | -------- | -------- | + | type | Event type. This field is mandatory.
Value:
- FAULT: fault
- STATISTIC: statistics
- SECURITY: security
- BEHAVIOR: user behavior| + | level | Event level. This field is mandatory.
Value:
- CRITICAL: critical
- MINOR: minor| + | tag | Event tag. This field is mandatory.
Rule:
- You can define a maximum of five tags, separated with a space.
- 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.
Rule:
The description contains 3 to 128 characters, including a to z, A to Z, 0 to 9, and underscores (_).| + + **Table 2** Description of custom parameters + | Field| Description| - | ----- | ----- | - | type | Indicates the type of the event. This field is mandatory.

Value:
  • **FAULT**: fault
  • **STATISTIC**: statistics
  • **SECURITY**: security
  • **BEHAVIOR**: user behavior
| - | level | Indicates the level of the event. This field is mandatory.

Value:
  • **CRITICAL**: critical
  • **MINOR**: minor
| - | tag | Indicates the tag of the event. This field is mandatory.

Rule:
  • You can define a maximum of five tags separated with a space.
  • A single tag can contain a maximum of 16 characters, including a to z, A to Z, and 0 to 9.
| - | desc | Describes the event name. This field is mandatory.

Rule:
  • The description contains 3 to 128 characters, including a to z, A to Z, 0 to 9, and underscores (_).
| + | -------- | -------- | + | type | Parameter type. This field is mandatory.
Value:
- BOOL
- INT8
- UINT8
- INT16
- UINT16
- INT32
- UINT32
- INT64
- UINT64
- FLOAT
- DOUBLE
- STRING | + | arrsize | Length of the parameter of the array type. This field is optional.
Value:
1-100| + | desc | Parameter description. This field is mandatory.
Rule:
The description contains 3 to 128 characters, including a to z, A to Z, 0 to 9, and underscores (_).| - **Table 2** Description of custom parameters - | Field| Description| - | ----- | ----- | - | type | Indicates the type of a parameter. This field is mandatory.

Value:
  • BOOL
  • UINT8
  • UINT16
  • INT32
  • UINT32
  • UINT64
  • FLOAT
  • DOUBLE
  • STRING
| - | arrsize | Specifies the length of the parameter of the array type. This field is optional.

Value range:
  • 1-100
| - | desc | Describes the parameter. This field is mandatory.

Rule:
  • The description contains 3 to 128 characters, including a to z, A to Z, 0 to 9, and underscores (_).
| +## Writing a YAML File + + +### Writing Rules + +- Event domain naming rules: + - The name must start with a letter and can contain only uppercase letters, digits, and underscores (_). + - The name contains 1 to 16 characters. -## Writing a YAML File +- Event naming rules: + - The name must start with a letter and can contain only uppercase letters, digits, and underscores (_). + - The name contains 1 to 32 characters. + - The number of internal event names in an event domain cannot exceed 4096. -### Writing Rules +- Parameter naming rules: + - The name must start with a letter and can contain only uppercase letters, digits, and underscores (_). + - The name contains 1 to 32 characters. + - The number of parameters in an event domain cannot exceed 128. -- Event domain naming rules: - - The name must start with a letter and can contain only uppercase letters, digits, and underscores (_). - - The name contains 1 to 16 characters. -- Event naming rules: - - The name must start with a letter and can contain only uppercase letters, digits, and underscores (_). - - The name contains 1 to 32 characters. - - The number of internal event names in an event domain cannot exceed 4096. -- Parameter naming rules: - - The name must start with a letter and can contain only uppercase letters, digits, and underscores (_). - - The name contains 1 to 32 characters. - - The number of parameters in an event domain cannot exceed 128. -### Example +### Example -- In the example YAML file, the event domain name is **MODULEA**. The event domain contains two events named **EVENT\_NAMEA** and **EVENT\_NAMEB**. -- **EVENT\_NAMEA** is defined as a critical event of the fault type. The event contains the **NAME1** parameter of the string type, the **NAME2** parameter of the string type, and the **NAME3** parameter of the unsigned short integer type. Therefore, you can perform [real-time subscription](subsys-dfx-hisysevent-listening.md) to the event based on the event domain **MODULEA** and event name **EVENT\_NAMEA**. -- **EVENT\_NAMEB** is defined as a general event of the statistics type. The event contains the **NAME1** parameter of the unsigned short integer type and the **NAME2** parameter of the integer type. Because two event tags named **tag1** and **tag2** are defined for **EVENT\_NAMEB** in the **\__BASE** parameter, you can perform [real-time subscription](subsys-dfx-hisysevent-listening.md) to the event based on the event domain **MODULEA** and event name **EVENT\_NAMEB**, or based on the event tag. +- In the example YAML file, the event domain name is **MODULEA**. The event domain contains two events named **EVENT_NAMEA** and **EVENT_NAMEB**. - ``` - ########################################## - # HiSysEvent definition for MODULEA - ########################################## +- **EVENT\_NAMEA** is defined as a critical event of the fault type. The event contains the **NAME1** parameter of the string type, the **NAME2** parameter of the string type, and the **NAME3** parameter of the unsigned short integer type. Therefore, you can perform [real-time subscription](../subsystems/subsys-dfx-hisysevent-listening.md) to the event based on the event domain **MODULEA** and event name **EVENT\_NAMEA**. - domain: MODULEA +- **EVENT\_NAMEB** is defined as a general event of the statistics type. The event contains the **NAME1** parameter of the unsigned short integer type and the **NAME2** parameter of the integer type. Because two event tags named **tag1** and **tag2** are defined for **EVENT\_NAMEB** in the **\__BASE** parameter, you can perform [real-time subscription](../subsystems/subsys-dfx-hisysevent-listening.md) to the event based on the event domain **MODULEA** and event name **EVENT\_NAMEB**, or based on the event tag. + + ``` + ########################################## + # the hisysevent definition for module a # + ########################################## + + domain: MODULEA + + EVENT_NAMEA: + __BASE: {type: FAULT, level: CRITICAL, desc: event name a} + NAME1: {type: STRING, desc: name1} + NAME2: {type: STRING, desc: name2} + NAME3: {type: UINT16, desc: name3} + + EVENT_NAMEB: + __BASE: {type: STATISTIC, level: MINOR, tag: tag1 tag2, desc: event name b} + NAME1: {type: UINT16, desc: name1} + NAME2: {type: INT32, desc: name2} + ``` - EVENT_NAMEA: - __BASE: {type: FAULT, level: CRITICAL, desc: event name a} - NAME1: {type: STRING, desc: name1} - NAME2: {type: STRING, desc: name2} - NAME3: {type: UINT16, desc: name3} - EVENT_NAMEB: - __BASE: {type: STATISTIC, level: MINOR, tag: tag1 tag2, desc: event name b} - NAME1: {type: UINT16, desc: name1} - NAME2: {type: INT32, desc: name2} - ``` +## Verifying the YAML File -## Verifying the YAML File -### Configuring the YAML File Path +### Configuring the YAML File Path + +In the **bundle.json** file, use the **hisysevent_config** attribute to specify the YAML file path. -In the **bundle.json** file, use the ```hisysevent_config``` attribute to specify the YAML file path. ``` { @@ -131,45 +145,47 @@ In the **bundle.json** file, use the ```hisysevent_config``` attribute to specif } ``` ->![](../public_sys-resources/icon-note.gif) **Note:** ->The YAML file can be placed in any directory of the component project as needed. You only need to specify the path in the **bundle.json** file. - -### Compiling the YAML File - -- Perform full compilation. - - During full compilation of the system, the configuration in the YAML files of all components are summarized. After the compilation is complete, the **hisysevent.def** file will be generated in the specified directory. +> **NOTE**
+> The YAML file can be placed in any directory of the component project as needed. You only need to specify the path in the **bundle.json** file. - ``` - cd absolute path of the project's root directory - ./build --product-name - ``` - - To obtain the **hisysevent.def** file generated after full compilation, run the following command: +### Compiling YAML Files - ``` - cd absolute path of the project's root directory - find out -name hisysevent.def -type f - ``` +- Perform full compilation. + - During full compilation of the system, the configurations in the YAML files of all components are summarized. After the compilation is complete, the **hisysevent.def** file will be generated in the specified directory. + + ``` + cd *absolute path of the project's root directory* + ./build --product-name + ``` -- Single-file compilation: + - To obtain the **hisysevent.def** file generated after full compilation, run the following commands: + + ``` + cd absolute path of the project's root directory + find out -name hisysevent.def -type f + ``` - You can also compile the YAML file of a single component by running the following commands: +- Single-file compilation: + You can also compile the YAML file of a single component by running the following commands: - ``` - cd absolute path of the project's root directory - ./build/ohos/hisysevent/gen_def_from_all_yaml.py --yaml-list --def-path - ``` + + ``` + cd absolute path of the project's root directory + ./build/ohos/hisysevent/gen_def_from_all_yaml.py --yaml-list --def-path + ``` - **Table 3** Parameters for single-file compilation + **Table 3** Parameters for single-file compilation + + | Option| Description| + | -------- | -------- | + | --yaml-list | Paths of the YAML files to be compiled. If there are multiple YAML file paths, separate each of them with a space.| + | --def-path | Path of the **hisysevent.def** file generated after compilation.| - | Parameter| Description| - | ------ | ------ | - | --yaml-list | Specifies the paths of the YAML files to be compiled. If there are multiple YAML file paths, separate each of them with a space.| - | --def-path | Specifies the path of the **hisysevent.def** file generated after compilation.| -### Logging and Querying Events +### Logging and Querying Events -1. Push the **hisysevent.def** file to the **/system/etc/hiview/** directory of the device by using the [hdc_std tool](subsys-toolchain-hdc-guide.md). +1. Push the **hisysevent.def** file to the **/system/etc/hiview/** directory of the device by using the [hdc_std tool](../subsystems/subsys-toolchain-hdc-guide.md). -2. Trigger logging of the custom system events in the YAML file. Then, run [hisysevent -l](subsys-dfx-hisysevent-tool.md) to query historical system events to find out if the logging of the custom system events is successful. +2. Trigger logging of the custom system events in the YAML file. Then, run [hisysevent -l](../subsystems/subsys-dfx-hisysevent-tool.md) to query historical system events to find out if the logging of the custom system events is successful. diff --git a/en/release-notes/changelogs/OpenHarmony_3.2.10.6/changelogs-telephony.md b/en/release-notes/changelogs/OpenHarmony_3.2.10.6/changelogs-telephony.md new file mode 100644 index 0000000000..f01e76ad64 --- /dev/null +++ b/en/release-notes/changelogs/OpenHarmony_3.2.10.6/changelogs-telephony.md @@ -0,0 +1,59 @@ +# Telephony Subsystem Changelog + + + +## cl.telephony.1 Radio Module API Change + + +### `isNrSupported` API Change for the Radio Module of Telephony Subsystem + +NR is a proper noun and must be capitalized. + +You need to adapt your application. + + + +**Change Impacts** + +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); +``` diff --git a/en/release-notes/changelogs/OpenHarmony_3.2.10.7/changelog-telephony.md b/en/release-notes/changelogs/OpenHarmony_3.2.10.7/changelog-telephony.md new file mode 100644 index 0000000000..cbf132c8c2 --- /dev/null +++ b/en/release-notes/changelogs/OpenHarmony_3.2.10.7/changelog-telephony.md @@ -0,0 +1,223 @@ +# Telephony Subsystem Changelog + + + +## cl.telephony.1 Call Module reject API Change +Changed the `reject` API to the `rejectCall` API in the call module of the telephony subsystem since API version 9. + +You need to adapt your application. + +**Change Impact** + +The `reject` API is deprecated and cannot be used anymore. Use the `rejectCall` API instead. Otherwise, relevant functions will be affected. + +- Involved APIs: + +```js + function reject(callId: number, callback: AsyncCallback): void; + function reject(callId: number, options: RejectMessageOptions, callback: AsyncCallback): void; + function reject(callId?: number, options?: RejectMessageOptions): Promise; + function reject(callback: AsyncCallback): void; + function reject(options: RejectMessageOptions, callback: AsyncCallback): void; +``` + +- Before change: + +```js + function reject(callId: number, callback: AsyncCallback): void; + function reject(callId: number, options: RejectMessageOptions, callback: AsyncCallback): void; + function reject(callId?: number, options?: RejectMessageOptions): Promise; + function reject(callback: AsyncCallback): void; + function reject(options: RejectMessageOptions, callback: AsyncCallback): void; +``` + +- After change: + +```js + function rejectCall(callId: number, callback: AsyncCallback): void; + function rejectCall(callId: number, options: RejectMessageOptions, callback: AsyncCallback): void; + function rejectCall(callId?: number, options?: RejectMessageOptions): Promise; + function rejectCall(callback: AsyncCallback): void; + function rejectCall(options: RejectMessageOptions, callback: AsyncCallback): void; +``` + + +**Adaptation Guide** + +The `reject` API is deprecated and cannot be used anymore. Use the `rejectCall` API instead. +The sample code is as follows: + +```js +call.rejectCall("138xxxxxxxx", (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +```js +let rejectMessageOptions={ + messageContent: "Unknown number blocked" +} +let promise = call.rejectCall(1, rejectMessageOptions); +promise.then(data => { + console.log(`rejectCall success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`rejectCall fail, promise: err->${JSON.stringify(err)}`); +}); +``` + + +```js +let rejectMessageOptions={ + messageContent: "Unknown number blocked" +} +let promise = call.rejectCall(1, rejectMessageOptions); +promise.then(data => { + console.log(`rejectCall success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`rejectCall fail, promise: err->${JSON.stringify(err)}`); +}); +``` + + +```js +call.rejectCall((err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +```js +let rejectMessageOptions={ + messageContent: "Unknown number blocked" +} +call.rejectCall(rejectMessageOptions, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## cl.telephony.2 Call Module answer API Change +Changed the `answer` API to the `answerCall` API in the call module of the telephony subsystem since API version 9. + +You need to adapt your application. + +**Change Impact** + +The `answer` API is deprecated and cannot be used anymore. Use the `answerCall` API instead. Otherwise, relevant functions will be affected. + +- Involved APIs: + +```js + function answer(callId: number, callback: AsyncCallback): void; + function answer(callId?: number): Promise; + function answer(callback: AsyncCallback): void; +``` + +- Before change: + +```js + function answer(callId: number, callback: AsyncCallback): void; + function answer(callId?: number): Promise; + function answer(callback: AsyncCallback): void; +``` + +- After change: + +```js + function answerCall(callId: number, callback: AsyncCallback): void; + function answerCall(callId?: number): Promise; + function answerCall(callback: AsyncCallback): void; +``` + + +**Adaptation Guide** + +The `answer` API is deprecated and cannot be used anymore. Use the `answerCall` API instead. +The sample code is as follows: + +```js +call.answerCall(1, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +```js +let promise = call.answerCall(1); +promise.then(data => { + console.log(`answerCall success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`answerCall fail, promise: err->${JSON.stringify(err)}`); +}); +``` + + +```js +call.answerCall((err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## cl.telephony.1 Call Module hangup API Change +Changed the `hangup` API to the `hangUpCall` API in the call module of the telephony subsystem since API version 9. + +You need to adapt your application. + +**Change Impact** + +The `hangup` API is deprecated and cannot be used anymore. Use the `hangUpCall` API instead. Otherwise, relevant functions will be affected. + +- Involved APIs: + +```js + function hangup(callId: number, callback: AsyncCallback): void; + function hangup(callId?: number): Promise; + function hangup(callback: AsyncCallback): void; +``` + +- Before change: + +```js + function hangup(callId: number, callback: AsyncCallback): void; + function hangup(callId?: number): Promise; + function hangup(callback: AsyncCallback): void; +``` + +- After change: + +```js + function hangUpCall(callId: number, callback: AsyncCallback): void; + function hangUpCall(callId?: number): Promise; + function hangUpCall(callback: AsyncCallback): void; +``` + + +**Adaptation Guide** + +The `hangup` API is deprecated and cannot be used anymore. Use the `hangUpCall` API instead. +The sample code is as follows: + +```js +call.hangUpCall(1, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +```js +let promise = call.hangUpCall(1); +promise.then(data => { + console.log(`hangUpCall success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`hangUpCall fail, promise: err->${JSON.stringify(err)}`); +}); +``` + + +```js +call.hangUpCall((err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` diff --git a/en/release-notes/changelogs/OpenHarmony_3.2.10.7/changelogs-telephony.md b/en/release-notes/changelogs/OpenHarmony_3.2.10.7/changelogs-telephony.md new file mode 100644 index 0000000000..7a5866bc47 --- /dev/null +++ b/en/release-notes/changelogs/OpenHarmony_3.2.10.7/changelogs-telephony.md @@ -0,0 +1,76 @@ +# Telephony Subsystem Changelog + + + +## cl.telephony.1 Call Module 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. + + +**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: + +```js + dial(phoneNumber: string, callback: AsyncCallback): void; + dial(phoneNumber: string, options: DialOptions, callback: AsyncCallback): void; + dial(phoneNumber: string, options?: DialOptions): Promise; +``` + +- Before change: + +```js +function dial(phoneNumber: string, callback: AsyncCallback): void; +function dial(phoneNumber: string, options: DialOptions, callback: AsyncCallback): void; +function dial(phoneNumber: string, options?: DialOptions): Promise; +``` + +- After change: + +```js +function dialCall(phoneNumber: string, callback: AsyncCallback): void; +function dialCall(phoneNumber: string, options: DialCallOptions, callback: AsyncCallback): void; +function dialCall(phoneNumber: string, options?: DialCallOptions): Promise; +``` + + + +**Adaptation Guide** + +The `dial` API is deprecated and cannot be used anymore. Use the `dialCall` API instead. Otherwise, relevant functions will be affected. +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)}`); +} +``` diff --git a/en/release-notes/changelogs/OpenHarmony_4.0.2.3/changelogs-usb.md b/en/release-notes/changelogs/OpenHarmony_4.0.2.3/changelogs-usb.md new file mode 100644 index 0000000000..909d8f69d6 --- /dev/null +++ b/en/release-notes/changelogs/OpenHarmony_4.0.2.3/changelogs-usb.md @@ -0,0 +1,37 @@ +# USB Subsystem API Changelog + +## cl.usb_manager.1 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 Name | New Bundle Name | +|------------------ | ------------------- | +| ohos.usbV9.d.ts | ohos.usbManager.d.ts | + +**Adaptation Guide** + +Change **@ohos.usbV9** to **@ohos.usbManager** when importing the bundle. + +## cl.usb_manager.2 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**. diff --git a/en/release-notes/changelogs/OpenHarmony_4.0.3.2/changelogs-power.md b/en/release-notes/changelogs/OpenHarmony_4.0.3.2/changelogs-power.md new file mode 100644 index 0000000000..c4506242ea --- /dev/null +++ b/en/release-notes/changelogs/OpenHarmony_4.0.3.2/changelogs-power.md @@ -0,0 +1,82 @@ +# 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. diff --git a/en/release-notes/changelogs/OpenHarmony_4.0.3.2/changelogs-startup.md b/en/release-notes/changelogs/OpenHarmony_4.0.3.2/changelogs-startup.md new file mode 100644 index 0000000000..506d8dcccc --- /dev/null +++ b/en/release-notes/changelogs/OpenHarmony_4.0.3.2/changelogs-startup.md @@ -0,0 +1,15 @@ +# 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 +``` -- GitLab