提交 46192880 编写于 作者: S shawn_he

update doc

Signed-off-by: Nshawn_he <shawn.he@huawei.com>
上级 d4cfd309
......@@ -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()<sup>9+</sup> | Obtains the preferred language list. |
| System | getFirstPreferredLanguage()<sup>9+</sup> | Obtains the first language in the preferred language list. |
| System | getAppPreferredLanguage()<sup>9+</sup> | Obtains the preferred language of an application. |
| System | setUsingLocalDigit(flag: boolean)<sup>9+</sup> | Sets whether to enable the local digit switch. |
| System | getUsingLocalDigit()<sup>9+</sup> | Checks whether the local digit switch is turned on. |
| System | setUsingLocalDigit(flag: boolean)<sup>9+</sup> | Specifies whether to enable use of local digits. |
| System | getUsingLocalDigit()<sup>9+</sup> | Checks whether use of local digits is enabled. |
| | isRTL(locale:string):boolean<sup>9+</sup> | 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():number<sup>8+</sup> | Obtains the minimum number of days in the first week of a year. |
| Calendar | setMinimalDaysInFirstWeek(value:number): void<sup>8+</sup> | Sets the minimum number of days in the first week of a year. |
| Calendar | getDisplayName(locale:string):string<sup>8+</sup> | Obtains the localized display of the **Calendar** object. |
| Calendar | isWeekend(date?:Date):boolean<sup>8+</sup> | Checks whether the specified date in this **Calendar** object is a weekend. |
| Calendar | isWeekend(date?:Date):boolean<sup>8+</sup> | 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.
......
......@@ -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"}]
```
......@@ -390,6 +390,4 @@ According to grammars in certain languages, the singular or plural form of a nou
The following sample is provided to help you better understand how to develop internationalization capabilities:
-[`International`: Internationalization (JS) (API8)](https://gitee.com/openharmony/applications_app_samples/tree/master/UI/International)
-[`International`: Internationalization (ArkTS) (API8) (Full SDK)](https://gitee.com/openharmony/applications_app_samples/tree/master/common/International)
-[`International`: Internationalization (ArkTS) (API9) (Full SDK)] (https://gitee.com/openharmony/applications_app_samples/tree/master/code/SystemFeature/Internationalnation/International)
......@@ -30,10 +30,10 @@ Describes battery information.
| batteryTemperature | number | Yes | No | Battery temperature of the device, in unit of 0.1°C. |
| isBatteryPresent<sup>7+</sup> | boolean | Yes | No | Whether the battery is supported or present. |
| batteryCapacityLevel<sup>9+</sup> | [BatteryCapacityLevel](#batterycapacitylevel9) | Yes | No | Battery level of the device. |
| estimatedRemainingChargeTime<sup>9+</sup> | number | Yes | No | Estimated time for fully charging the current device, in unit of milliseconds. **System API**: This is a system API. |
| totalEnergy<sup>9+</sup> | number | Yes | No | Total battery capacity of the device, in unit of mAh. **System API**: This is a system API. |
| nowCurrent<sup>9+</sup> | number | Yes | No | Battery current of the device, in unit of mA. **System API**: This is a system API. |
| remainingEnergy<sup>9+</sup> | number | Yes | No | Remaining battery capacity of the device, in unit of mAh. **System API**: This is a system API.|
| estimatedRemainingChargeTime<sup>9+</sup> | number | Yes | No | Estimated time for fully charging the current device, in unit of milliseconds. This is a system API. |
| totalEnergy<sup>9+</sup> | number | Yes | No | Total battery capacity of the device, in unit of mAh. This is a system API. |
| nowCurrent<sup>9+</sup> | number | Yes | No | Battery current of the device, in unit of mA. This is a system API. |
| remainingEnergy<sup>9+</sup> | number | Yes | No | Remaining battery capacity of the device, in unit of mAh. This is a system API.|
## BatteryPluggedType
......
# @ohos.charger (Charging Type)
The **charger** module enumerates charging types.
> **NOTE**
>
> The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```js
import charger from '@ohos.charger';
```
## ChargeType
Enumerates charging types.
**System capability**: SystemCapability.PowerManager.BatteryManager.Core
| Name | Value | Description |
| -------- | ---- | ----------------- |
| NONE | 0 | Unknown charging type. |
| WIRED_NORMAL | 1 | Wired normal charging.|
| WIRED_QUICK | 2 | Wired fast charging. |
| WIRED_SUPER_QUICK | 3 | Wired super fast charging.|
| WIRELESS_NORMAL | 4 | Wireless normal charging.|
| WIRELESS_QUICK | 5 | Wireless fast charging.|
| WIRELESS_SUPER_QUICK | 6 | Wireless super fast charging.|
......@@ -46,11 +46,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}`);
}
```
......@@ -76,9 +76,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}`);
}
```
......@@ -113,7 +113,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}`);
}
```
......
......@@ -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)
......
# @ohos.hiviewdfx.hiAppEvent (Application Event Logging)
The **hiAppEvent** module provides application event-related functions, including flushing application events to a disk, querying and clearing application events, and customizing application event logging configuration.
This module provides application event-related functions, including flushing application events to a disk, querying and clearing application events, and customizing application event logging configuration.
> **NOTE**<br>
> **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.
......@@ -447,27 +448,27 @@ Enumerates event types.
| BEHAVIOR | 4 | Behavior event.|
## Event
## event
Provides constants that define the names of all predefined events.
**System capability**: SystemCapability.HiviewDFX.HiAppEvent
| Name | Type | Readable| Writable| Description |
| ------------------------- | ------ | ---- | ---- | -------------------- |
| USER_LOGIN | string | Yes | No | User login event. |
| USER_LOGOUT | string | Yes | No | User logout event. |
| DISTRIBUTED_SERVICE_START | string | Yes | No | Distributed service startup event.|
| Name | Type | Description |
| ------------------------- | ------ | -------------------- |
| USER_LOGIN | string | User login event. |
| USER_LOGOUT | string | User logout event. |
| DISTRIBUTED_SERVICE_START | string | Distributed service startup event.|
## Param
## param
Provides constants that define the names of all predefined event parameters.
**System capability**: SystemCapability.HiviewDFX.HiAppEvent
| Name | Type | Readable| Writable| Description |
| ------------------------------- | ------ | ---- | ---- | ------------------ |
| USER_ID | string | Yes | No | Custom user ID. |
| DISTRIBUTED_SERVICE_NAME | string | Yes | No | Distributed service name. |
| DISTRIBUTED_SERVICE_INSTANCE_ID | string | Yes | No | Distributed service instance ID.|
| Name | Type | Description |
| ------------------------------- | ------ | ------------------ |
| USER_ID | string | Custom user ID. |
| DISTRIBUTED_SERVICE_NAME | string | Distributed service name. |
| DISTRIBUTED_SERVICE_INSTANCE_ID | string | Distributed service instance ID.|
# @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 [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.
This 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**
> - The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> - This 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. For details about the basic i18n capabilities, see [intl](js-apis-intl.md).
> - This 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. For details about the basic I18N capabilities, see [Intl](js-apis-intl.md).
## Modules to Import
......@@ -42,7 +42,7 @@ Obtains the localized script for the specified country.
**Error codes**
For details about the error codes, see [i18n Error Codes](../errorcodes/errorcode-i18n.md).
For details about the error codes, see [I18N Error Codes](../errorcodes/errorcode-i18n.md).
| ID | Error Message |
| ------ | ---------------------- |
......@@ -81,7 +81,7 @@ Obtains the localized script for the specified language.
**Error codes**
For details about the error codes, see [i18n Error Codes](../errorcodes/errorcode-i18n.md).
For details about the error codes, see [I18N Error Codes](../errorcodes/errorcode-i18n.md).
| ID | Error Message |
| ------ | ---------------------- |
......@@ -112,7 +112,7 @@ Obtains the list of system languages. For details about languages, see [Instanti
**Error codes**
For details about the error codes, see [i18n Error Codes](../errorcodes/errorcode-i18n.md).
For details about the error codes, see [I18N Error Codes](../errorcodes/errorcode-i18n.md).
| ID | Error Message |
| ------ | ---------------------- |
......@@ -149,7 +149,7 @@ Obtains the list of countries and regions supported for the specified language.
**Error codes**
For details about the error codes, see [i18n Error Codes](../errorcodes/errorcode-i18n.md).
For details about the error codes, see [I18N Error Codes](../errorcodes/errorcode-i18n.md).
| ID | Error Message |
| ------ | ---------------------- |
......@@ -187,7 +187,7 @@ Checks whether the system language matches the specified region.
**Error codes**
For details about the error codes, see [i18n Error Codes](../errorcodes/errorcode-i18n.md).
For details about the error codes, see [I18N Error Codes](../errorcodes/errorcode-i18n.md).
| ID | Error Message |
| ------ | ---------------------- |
......@@ -218,7 +218,7 @@ Obtains the system language. For details about languages, see [Instantiating the
**Error codes**
For details about the error codes, see [i18n Error Codes](../errorcodes/errorcode-i18n.md).
For details about the error codes, see [I18N Error Codes](../errorcodes/errorcode-i18n.md).
| ID | Error Message |
| ------ | ---------------------- |
......@@ -239,7 +239,7 @@ static setSystemLanguage(language: string): void
Sets the system language. Currently, this API does not support real-time updating of the system language.
**System API**: This is a system API.
This is a system API.
**Permission required**: ohos.permission.UPDATE_CONFIGURATION
......@@ -253,7 +253,7 @@ Sets the system language. Currently, this API does not support real-time updatin
**Error codes**
For details about the error codes, see [i18n Error Codes](../errorcodes/errorcode-i18n.md).
For details about the error codes, see [I18N Error Codes](../errorcodes/errorcode-i18n.md).
| ID | Error Message |
| ------ | ---------------------- |
......@@ -284,7 +284,7 @@ Obtains the system region. For details about system regions, see [Instantiating
**Error codes**
For details about the error codes, see [i18n Error Codes](../errorcodes/errorcode-i18n.md).
For details about the error codes, see [I18N Error Codes](../errorcodes/errorcode-i18n.md).
| ID | Error Message |
| ------ | ---------------------- |
......@@ -305,7 +305,7 @@ static setSystemRegion(region: string): void
Sets the system region.
**System API**: This is a system API.
This is a system API.
**Permission required**: ohos.permission.UPDATE_CONFIGURATION
......@@ -319,7 +319,7 @@ Sets the system region.
**Error codes**
For details about the error codes, see [i18n Error Codes](../errorcodes/errorcode-i18n.md).
For details about the error codes, see [I18N Error Codes](../errorcodes/errorcode-i18n.md).
| ID | Error Message |
| ------ | ---------------------- |
......@@ -350,7 +350,7 @@ Obtains the system locale. For details about system locales, see [Instantiating
**Error codes**
For details about the error codes, see [i18n Error Codes](../errorcodes/errorcode-i18n.md).
For details about the error codes, see [I18N Error Codes](../errorcodes/errorcode-i18n.md).
| ID | Error Message |
| ------ | ---------------------- |
......@@ -371,7 +371,7 @@ static setSystemLocale(locale: string): void
Sets the system locale.
**System API**: This is a system API.
This is a system API.
**Permission required**: ohos.permission.UPDATE_CONFIGURATION
......@@ -385,7 +385,7 @@ Sets the system locale.
**Error codes**
For details about the error codes, see [i18n Error Codes](../errorcodes/errorcode-i18n.md).
For details about the error codes, see [I18N Error Codes](../errorcodes/errorcode-i18n.md).
| ID | Error Message |
| ------ | ---------------------- |
......@@ -416,7 +416,7 @@ Checks whether the 24-hour clock is used.
**Error codes**
For details about the error codes, see [i18n Error Codes](../errorcodes/errorcode-i18n.md).
For details about the error codes, see [I18N Error Codes](../errorcodes/errorcode-i18n.md).
| ID | Error Message |
| ------ | ---------------------- |
......@@ -437,7 +437,7 @@ static set24HourClock(option: boolean): void
Sets the 24-hour clock.
**System API**: This is a system API.
This is a system API.
**Permission required**: ohos.permission.UPDATE_CONFIGURATION
......@@ -451,7 +451,7 @@ Sets the 24-hour clock.
**Error codes**
For details about the error codes, see [i18n Error Codes](../errorcodes/errorcode-i18n.md).
For details about the error codes, see [I18N Error Codes](../errorcodes/errorcode-i18n.md).
| ID | Error Message |
| ------ | ---------------------- |
......@@ -473,7 +473,7 @@ static addPreferredLanguage(language: string, index?: number): void
Adds a preferred language to the specified position on the preferred language list.
**System API**: This is a system API.
This is a system API.
**Permission required**: ohos.permission.UPDATE_CONFIGURATION
......@@ -488,7 +488,7 @@ Adds a preferred language to the specified position on the preferred language li
**Error codes**
For details about the error codes, see [i18n Error Codes](../errorcodes/errorcode-i18n.md).
For details about the error codes, see [I18N Error Codes](../errorcodes/errorcode-i18n.md).
| ID | Error Message |
| ------ | ---------------------- |
......@@ -512,7 +512,7 @@ static removePreferredLanguage(index: number): void
Deletes a preferred language from the specified position on the preferred language list.
**System API**: This is a system API.
This is a system API.
**Permission required**: ohos.permission.UPDATE_CONFIGURATION
......@@ -526,7 +526,7 @@ Deletes a preferred language from the specified position on the preferred langua
**Error codes**
For details about the error codes, see [i18n Error Codes](../errorcodes/errorcode-i18n.md).
For details about the error codes, see [I18N Error Codes](../errorcodes/errorcode-i18n.md).
| ID | Error Message |
| ------ | ---------------------- |
......@@ -547,7 +547,7 @@ For details about the error codes, see [i18n Error Codes](../errorcodes/errorcod
static getPreferredLanguageList(): Array&lt;string&gt;
Obtains the preferred language list.
Obtains the list of preferred languages.
**System capability**: SystemCapability.Global.I18n
......@@ -555,11 +555,11 @@ Obtains the preferred language list.
| Type | Description |
| ------------------- | --------- |
| Array&lt;string&gt; | Preferred language list.|
| Array&lt;string&gt; | List of preferred languages.|
**Error codes**
For details about the error codes, see [i18n Error Codes](../errorcodes/errorcode-i18n.md).
For details about the error codes, see [I18N Error Codes](../errorcodes/errorcode-i18n.md).
| ID | Error Message |
| ------ | ---------------------- |
......@@ -590,7 +590,7 @@ Obtains the first language in the preferred language list.
**Error codes**
For details about the error codes, see [i18n Error Codes](../errorcodes/errorcode-i18n.md).
For details about the error codes, see [I18N Error Codes](../errorcodes/errorcode-i18n.md).
| ID | Error Message |
| ------ | ---------------------- |
......@@ -621,7 +621,7 @@ Obtains the preferred language of an application.
**Error codes**
For details about the error codes, see [i18n Error Codes](../errorcodes/errorcode-i18n.md).
For details about the error codes, see [I18N Error Codes](../errorcodes/errorcode-i18n.md).
| ID | Error Message |
| ------ | ---------------------- |
......@@ -642,7 +642,7 @@ static setUsingLocalDigit(flag: boolean): void
Specifies whether to enable use of local digits.
**System API**: This is a system API.
This is a system API.
**Permission required**: ohos.permission.UPDATE_CONFIGURATION
......@@ -652,11 +652,11 @@ Specifies whether to enable use of local digits.
| Name | Type | Mandatory | Description |
| ---- | ------- | ---- | ------------------------------- |
| flag | boolean | Yes | Whether to enable the local digit switch. The value **true** means to enable the local digit switch, and the value **false** indicates the opposite.|
| flag | boolean | Yes | Whether to turn on the local digit switch. The value **true** means to turn on the local digit switch, and the value **false** indicates the opposite.|
**Error codes**
For details about the error codes, see [i18n Error Codes](../errorcodes/errorcode-i18n.md).
For details about the error codes, see [I18N Error Codes](../errorcodes/errorcode-i18n.md).
| ID | Error Message |
| ------ | ---------------------- |
......@@ -687,7 +687,7 @@ Checks whether use of local digits is enabled.
**Error codes**
For details about the error codes, see [i18n Error Codes](../errorcodes/errorcode-i18n.md).
For details about the error codes, see [I18N Error Codes](../errorcodes/errorcode-i18n.md).
| ID | Error Message |
| ------ | ---------------------- |
......@@ -1059,7 +1059,7 @@ Creates a **PhoneNumberFormat** object.
| Name | Type | Mandatory | Description |
| ------- | ---------------------------------------- | ---- | ---------------- |
| country | string | Yes | Country or region to which the phone number to be formatted belongs.|
| options | [PhoneNumberFormatOptions](#phonenumberformatoptions8) | No | Options of the **PhoneNumberFormat** object. |
| options | [PhoneNumberFormatOptions](#phonenumberformatoptions9) | No | Options of the **PhoneNumberFormat** object. |
**Example**
```js
......@@ -1149,7 +1149,7 @@ Obtains the home location of a phone number.
```
## PhoneNumberFormatOptions<sup>8+</sup>
## PhoneNumberFormatOptions<sup>9+</sup>
Defines the options for this PhoneNumberFormat object.
......@@ -1194,7 +1194,7 @@ Creates an **IndexUtil** object.
**Example**
```js
let indexUtil= I18n.getInstance("zh-CN");
let indexUtil = I18n.getInstance("zh-CN");
```
......@@ -1267,7 +1267,7 @@ Obtains the index of a text object.
**Example**
```js
let indexUtil= I18n.getInstance("zh-CN");
let indexUtil = I18n.getInstance("zh-CN");
let index = indexUtil.getIndex("hi"); // index = "H"
```
......@@ -1382,7 +1382,7 @@ Puts the [BreakIterator](#breakiterator8) object to the first text boundary, whi
**Example**
```js
let iterator = i18n.getLineInstance("en");
let iterator = I18n.getLineInstance("en");
iterator.setLineBreakText("Apple is my favorite fruit.");
let firstPos = iterator.first(); // firstPos = 0
```
......@@ -1689,7 +1689,7 @@ Obtains the list of time zone city IDs supported by the system.
static getCityDisplayName(cityID: string, locale: string): string
Obtains the localized representation of a time zone city in the specified locale.
Obtains the localized display of a time zone city in the specified locale.
**System capability**: SystemCapability.Global.I18n
......@@ -2363,7 +2363,7 @@ This API is supported since API version 8 and is deprecated since API version 9.
getPreferredLanguageList(): Array&lt;string&gt;
Obtains the preferred language list.
Obtains the list of preferred languages.
This API is supported since API version 8 and is deprecated since API version 9. You are advised to use [System.getPreferredLanguageList](#getpreferredlanguagelist9) instead.
......@@ -2373,7 +2373,7 @@ This API is supported since API version 8 and is deprecated since API version 9.
| Type | Description |
| ------------------- | --------- |
| Array&lt;string&gt; | Preferred language list.|
| Array&lt;string&gt; | List of preferred languages.|
**Example**
```js
......
# @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();
```
......@@ -67,13 +67,13 @@ Creates a **Locale** object.
| Name | Type | Mandatory | Description |
| -------------------- | -------------------------------- | ---- | ---------------------------- |
| locale | string | Yes | A string containing locale information, including the language, optional script, and region. For details about the international standards and combination modes for the language, script, and country or region, see [intl Development](../../internationalization/intl-guidelines.md#setting-locale-information).|
| options<sup>9+</sup> | [LocaleOptions](#localeoptions6) | No | Options for creating the **Locale** object. |
| options<sup>9+</sup> | [LocaleOptions](#localeoptions9) | No | Options for creating the **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"
```
......@@ -159,7 +159,7 @@ Minimizes information of the **Locale** object. If the script and locale informa
```
## LocaleOptions<sup>6+</sup>
## LocaleOptions<sup>9+</sup>
Represents the locale options.
......@@ -206,7 +206,7 @@ Creates a **DateTimeOptions** object for the specified locale.
| Name | Type | Mandatory | Description |
| -------------------- | ------------------------------------ | ---- | ---------------------------- |
| locale | string \| Array&lt;string&gt; | Yes | A string containing locale information, including the language, optional script, and region.|
| options<sup>9+</sup> | [DateTimeOptions](#datetimeoptions6) | No | Options for creating a **DateTimeFormat** object. |
| options<sup>9+</sup> | [DateTimeOptions](#datetimeoptions9) | No | Options for creating a **DateTimeFormat** object. |
**Example**
```js
......@@ -298,7 +298,7 @@ Obtains the formatting options for **DateTimeFormat** object.
| Type | Description |
| ------------------------------------ | ----------------------------- |
| [DateTimeOptions](#datetimeoptions6) | Formatting options for **DateTimeFormat** objects.|
| [DateTimeOptions](#datetimeoptions9) | Formatting options for **DateTimeFormat** objects.|
**Example**
```js
......@@ -310,7 +310,7 @@ Obtains the formatting options for **DateTimeFormat** object.
```
## DateTimeOptions<sup>6+</sup>
## DateTimeOptions<sup>9+</sup>
Provides the options for the **DateTimeFormat** object.
......@@ -370,7 +370,7 @@ Creates a **NumberFormat** object for the specified locale.
| Name | Type | Mandatory | Description |
| -------------------- | -------------------------------- | ---- | ---------------------------- |
| locale | string \| Array&lt;string&gt; | Yes | A string containing locale information, including the language, optional script, and region.|
| options<sup>9+</sup> | [NumberOptions](#numberoptions6) | No | Options for creating a **NumberFormat** object. |
| options<sup>9+</sup> | [NumberOptions](#numberoptions9) | No | Options for creating a **NumberFormat** object. |
**Example**
```js
......@@ -420,7 +420,7 @@ Obtains the options of the **NumberFormat** object.
| Type | Description |
| -------------------------------- | --------------------------- |
| [NumberOptions](#numberoptions6) | Formatting options for **NumberFormat** objects.|
| [NumberOptions](#numberoptions9) | Formatting options for **NumberFormat** objects.|
**Example**
......@@ -429,11 +429,11 @@ 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
```
## NumberOptions<sup>6+</sup>
## NumberOptions<sup>9+</sup>
Defines the device capability.
......@@ -493,7 +493,7 @@ Creates a **Collator** object.
| Name | Type | Mandatory | Description |
| -------------------- | ------------------------------------ | ---- | ---------------------------- |
| locale | string \| Array&lt;string&gt; | Yes | A string containing locale information, including the language, optional script, and region.|
| options<sup>9+</sup> | [CollatorOptions](#collatoroptions8) | No | Options for creating a **Collator** object. |
| options<sup>9+</sup> | [CollatorOptions](#collatoroptions9) | No | Options for creating a **Collator** object. |
**Example**
```js
......@@ -544,7 +544,7 @@ Returns properties reflecting the locale and collation options of a **Collator**
| Type | Description |
| ------------------------------------ | ----------------- |
| [CollatorOptions](#collatoroptions8) | Properties of the **Collator** object.|
| [CollatorOptions](#collatoroptions9) | Properties of the **Collator** object.|
**Example**
```js
......@@ -552,11 +552,11 @@ 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
```
## CollatorOptions<sup>8+</sup>
## CollatorOptions<sup>9+</sup>
Represents the properties of a **Collator** object.
......@@ -604,7 +604,7 @@ Creates a **PluralRules** object to obtain the singular-plural type of numbers.
| Name | Type | Mandatory | Description |
| -------------------- | ---------------------------------------- | ---- | ---------------------------- |
| locale | string \| Array&lt;string&gt; | Yes | A string containing locale information, including the language, optional script, and region.|
| options<sup>9+</sup> | [PluralRulesOptions](#pluralrulesoptions8) | No | Options for creating a **PluralRules** object. |
| options<sup>9+</sup> | [PluralRulesOptions](#pluralrulesoptions9) | No | Options for creating a **PluralRules** object. |
**Example**
```js
......@@ -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
......@@ -647,7 +647,7 @@ Obtains a string that represents the singular-plural type of the specified numbe
```
## PluralRulesOptions<sup>8+</sup>
## PluralRulesOptions<sup>9+</sup>
Represents the properties of a **PluralRules** object.
......@@ -695,7 +695,7 @@ Creates a **RelativeTimeFormat** object.
| Name | Type | Mandatory | Description |
| -------------------- | ---------------------------------------- | ---- | ---------------------------- |
| locale | string \| Array&lt;string&gt; | Yes | A string containing locale information, including the language, optional script, and region.|
| options<sup>9+</sup> | [RelativeTimeFormatInputOptions](#relativetimeformatinputoptions8) | No | Options for creating a **RelativeTimeFormat** object. |
| options<sup>9+</sup> | [RelativeTimeFormatInputOptions](#relativetimeformatinputoptions9) | No | Options for creating a **RelativeTimeFormat** object. |
**Example**
```js
......@@ -787,7 +787,7 @@ Obtains the formatting options for **RelativeTimeFormat** objects.
```
## RelativeTimeFormatInputOptions<sup>8+</sup>
## RelativeTimeFormatInputOptions<sup>9+</sup>
Represents the properties of a **RelativeTimeFormat** object.
......
......@@ -10,7 +10,7 @@ The **radio** module provides basic network search management functions. You can
## Modules to Import
```
import radio from '@ohos.telephony.radio'
import radio from '@ohos.telephony.radio';
```
## radio.getRadioTech
......@@ -45,7 +45,7 @@ Obtains the RAT used in the CS and PS domains for the SIM card in the specified
```js
let slotId = 0;
radio.getRadioTech(slotId, (err, data) =>{
radio.getRadioTech(slotId, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
......@@ -127,7 +127,7 @@ Obtains the network status. This API uses an asynchronous callback to return the
**Example**
```js
radio.getNetworkState((err, data) =>{
radio.getNetworkState((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
......@@ -2464,7 +2464,7 @@ Defines the signal strength.
| --------------- | --------------------------- | ---- | ------------------ |
| signalType | [NetworkType](#networktype) | Yes | Signal strength type.|
| signalLevel | number | Yes | Signal strength level.|
| dBm<sup>9+</sup>| number | Yes | Network signal strength. |
| dBm<sup>9+</sup>| number | Yes | Signal strength, in dBm. |
## NetworkType
......
......@@ -483,6 +483,6 @@ Enumerates the types of **RunningLock** objects.
**System capability:** SystemCapability.PowerManager.PowerManager.Core
| Name | Value | Description |
| ------------------------ | ---- | -------------------------------------- |
| BACKGROUND | 1 | A lock that prevents the system from hibernating when the screen is off. |
| PROXIMITY_SCREEN_CONTROL | 2 | A lock that determines whether to turn on or off the screen based on the distance away from the screen.|
| --------------------------------- | ---- | ------------------------------------------------------------ |
| BACKGROUND<sup>(deprecated)</sup> | 1 | A lock that prevents the system from hibernating when the screen is off.<br>**NOTE**<br>This parameter is supported since API version 7 and deprecated since API version 10.|
| PROXIMITY_SCREEN_CONTROL | 2 | A lock that determines whether to turn on or off the screen based on the distance away from the screen. |
# @ohos.telephony.data (Cellular Data)
The **data** module provides basic mobile data management functions. You can obtain and set the default slot of the SIM card used for mobile data, and obtain the uplink and downlink connection status of cellular data services and connection status of the packet switched (PS) domain. Besides, you can check whether cellular data services and data roaming are enabled.
The cellular data module provides basic mobile data management functions. You can obtain and set the default slot of the SIM card used for mobile data, and obtain the uplink and downlink connection status of cellular data services and connection status of the packet switched (PS) domain. Besides, you can check whether cellular data services and data roaming are enabled.
>**NOTE**
>
......@@ -85,7 +85,7 @@ setDefaultCellularDataSlotId(slotId: number, callback: AsyncCallback\<void\>): v
Sets the default slot of the SIM card used for mobile data. This API uses an asynchronous callback to return the result.
This is a system API.
**System API**: This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
......@@ -98,6 +98,19 @@ This is a system API.
| slotId | number | Yes | SIM card slot ID. <br>**0**: card slot 1<br>**1**: card slot 2<br>**-1**: Clears the default configuration.|
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result. |
**Error codes**
| ID| Error Message |
| -------- | -------------------------------------------- |
| 201 | Permission denied. |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300004 | Do not have sim card. |
| 8300999 | Unknown error code. |
| 8301001 | SIM card is not activated. |
**Example**
```js
......@@ -112,7 +125,7 @@ setDefaultCellularDataSlotId(slotId: number): Promise\<void\>
Sets the default slot of the SIM card used for mobile data. This API uses a promise to return the result.
This is a system API.
**System API**: This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
......@@ -130,6 +143,19 @@ This is a system API.
| --------------- | ------------------------------- |
| Promise\<void\> | Promise used to return the result.|
**Error codes**
| ID| Error Message |
| -------- | -------------------------------------------- |
| 201 | Permission denied. |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300004 | Do not have sim card. |
| 8300999 | Unknown error code. |
| 8301001 | SIM card is not activated. |
**Example**
```js
......@@ -251,6 +277,17 @@ Checks whether the cellular data service is enabled. This API uses an asynchrono
| -------- | ------------------------ | ---- | ------------------------------------------------------------ |
| callback | AsyncCallback\<boolean\> | Yes | Callback used to return the result.<br>**true**: The cellular data service is enabled.<br>**false**: The cellular data service is disabled.|
**Error codes**
| ID| Error Message |
| -------- | -------------------------------------------- |
| 201 | Permission denied. |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300999 | Unknown error code. |
**Example**
```js
......@@ -275,6 +312,17 @@ Checks whether the cellular data service is enabled. This API uses a promise to
| ------------------ | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the result.<br>**true**: The cellular data service is enabled.<br>**false**: The cellular data service is disabled.|
**Error codes**
| ID| Error Message |
| -------- | -------------------------------------------- |
| 201 | Permission denied. |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300999 | Unknown error code. |
**Example**
```js
......@@ -303,6 +351,17 @@ Checks whether roaming is enabled for the cellular data service. This API uses a
| slotId | number | Yes | Card slot ID.<br>**0**: card slot 1<br>**1**: card slot 2 |
| callback | AsyncCallback\<boolean\> | Yes | Callback used to return the result.<br>**true**: Roaming is enabled for the cellular data service.<br>**false**: Roaming is disabled for the cellular data service.|
**Error codes**
| ID| Error Message |
| -------- | -------------------------------------------- |
| 201 | Permission denied. |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300999 | Unknown error code. |
**Example**
```js
......@@ -333,6 +392,17 @@ Checks whether roaming is enabled for the cellular data service. This API uses a
| ------------------ | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the result.<br>**true**: Roaming is enabled for the cellular data service.<br>**false**: Roaming is disabled for the cellular data service.|
**Error codes**
| ID| Error Message |
| -------- | -------------------------------------------- |
| 201 | Permission denied. |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300999 | Unknown error code. |
**Example**
```js
......@@ -350,7 +420,7 @@ enableCellularData(callback: AsyncCallback<void\>): void
Enables the cellular data service. This API uses an asynchronous callback to return the result.
This is a system API.
**System API**: This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
......@@ -362,6 +432,17 @@ This is a system API.
| -------- | --------------------- | ---- | ---------- |
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.|
**Error codes**
| ID| Error Message |
| -------- | -------------------------------------------- |
| 201 | Permission denied. |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300999 | Unknown error code. |
**Example**
```js
......@@ -376,7 +457,7 @@ enableCellularData(): Promise<void\>
Enables the cellular data service. This API uses a promise to return the result.
This is a system API.
**System API**: This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
......@@ -388,6 +469,17 @@ This is a system API.
| --------------- | ----------------------- |
| Promise\<void\> | Promise used to return the result.|
**Error codes**
| ID| Error Message |
| -------- | -------------------------------------------- |
| 201 | Permission denied. |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300999 | Unknown error code. |
**Example**
```js
......@@ -405,7 +497,7 @@ disableCellularData(callback: AsyncCallback<void\>): void
Disables the cellular data service. This API uses an asynchronous callback to return the result.
This is a system API.
**System API**: This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
......@@ -417,6 +509,17 @@ This is a system API.
| -------- | --------------------- | ---- | ---------- |
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.|
**Error codes**
| ID| Error Message |
| -------- | -------------------------------------------- |
| 201 | Permission denied. |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300999 | Unknown error code. |
**Example**
```js
......@@ -431,7 +534,7 @@ disableCellularData(): Promise<void\>
Disables the cellular data service. This API uses a promise to return the result.
This is a system API.
**System API**: This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
......@@ -443,6 +546,17 @@ This is a system API.
| --------------- | --------------------------- |
| Promise\<void\> | Promise used to return the result.|
**Error codes**
| ID| Error Message |
| -------- | -------------------------------------------- |
| 201 | Permission denied. |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300999 | Unknown error code. |
**Example**
```js
......@@ -460,7 +574,7 @@ enableCellularDataRoaming(slotId: number, callback: AsyncCallback<void\>): void
Enables the cellular data roaming service. This API uses an asynchronous callback to return the result.
This is a system API.
**System API**: This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
......@@ -473,6 +587,17 @@ This is a system API.
| slotId | number | Yes | Card slot ID.<br>**0**: card slot 1<br>**1**: card slot 2|
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result. |
**Error codes**
| ID| Error Message |
| -------- | -------------------------------------------- |
| 201 | Permission denied. |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300999 | Unknown error code. |
**Example**
```js
......@@ -487,7 +612,7 @@ enableCellularDataRoaming(slotId: number): Promise<void\>
Enables the cellular data roaming service. This API uses a promise to return the result.
This is a system API.
**System API**: This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
......@@ -505,6 +630,17 @@ This is a system API.
| --------------- | ------------------------- |
| Promise\<void\> | Promise used to return the result.|
**Error codes**
| ID| Error Message |
| -------- | -------------------------------------------- |
| 201 | Permission denied. |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300999 | Unknown error code. |
**Example**
```js
......@@ -522,7 +658,7 @@ disableCellularDataRoaming(slotId: number, callback: AsyncCallback<void\>): void
Disables the cellular data roaming service. This API uses an asynchronous callback to return the result.
This is a system API.
**System API**: This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
......@@ -535,6 +671,17 @@ This is a system API.
| slotId | number | Yes | Card slot ID.<br>**0**: card slot 1<br>**1**: card slot 2|
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result. |
**Error codes**
| ID| Error Message |
| -------- | -------------------------------------------- |
| 201 | Permission denied. |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300999 | Unknown error code. |
**Example**
```js
......@@ -549,7 +696,7 @@ disableCellularDataRoaming(slotId: number): Promise<void\>
Disables the cellular data roaming service. This API uses a promise to return the result.
This is a system API.
**System API**: This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
......@@ -567,6 +714,17 @@ This is a system API.
| --------------- | ------------------------- |
| Promise\<void\> | Promise used to return the result.|
**Error codes**
| ID| Error Message |
| -------- | -------------------------------------------- |
| 201 | Permission denied. |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300999 | Unknown error code. |
**Example**
```js
......
# 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.
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册