| longitude | number | Yes | Longitude. The value ranges from **-180** to **179.9**. A positive value is used for east longitude and a negative value is used for west longitude.|
| latitude | number | Yes | Latitude. The value ranges from **-90** to **89.9**. A positive value is used for north latitude and a negative value is used for south latitude.|
**Return value**
| Type | Description |
| -------- | ----------- |
| Array<[TimeZone](#timezone)> | Array of **TimeZone** objects.|
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.
| 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](#localeoptions9) | No | Options for creating the **Locale** object. |
| options | [LocaleOptions](#localeoptions6) | No | Options for creating the **Locale** object. |
**Example**
```js
...
...
@@ -160,9 +159,10 @@ Minimizes information of the **Locale** object. If the script and locale informa
```
## LocaleOptions<sup>9+</sup>
## LocaleOptions<sup>6+</sup>
Represents the locale options.
In API version 9, the attributes in **LocaleOptions** are optional.
| locale | string \| Array<string> | Yes | A string containing locale information, including the language, optional script, and region.|
| options<sup>9+</sup> | [RelativeTimeFormatInputOptions](#relativetimeformatinputoptions9) | No | Options for creating a **RelativeTimeFormat** object. |
| options | [RelativeTimeFormatInputOptions](#relativetimeformatinputoptions8) | No | Options for creating a **RelativeTimeFormat** object. |
**Example**
```js
...
...
@@ -788,9 +792,10 @@ Obtains the formatting options for **RelativeTimeFormat** objects.
```
## RelativeTimeFormatInputOptions<sup>9+</sup>
## RelativeTimeFormatInputOptions<sup>8+</sup>
Represents the properties of a **RelativeTimeFormat** object.
In API version 9, the attributes in **RelativeTimeFormatInputOptions** are optional.
The **logLibrary** module provides APIs for obtaining various system maintenance and test logs.
> **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.
> - The APIs provided by this module are system APIs.
| mtime | number | Yes| No | Time of the last modification to the file. The value is the number of seconds elapsed since 00:00:00 on January 1, 1970.|
| size | number | Yes| No | File size, in bytes.|
## logLibrary.list
list(logType: string): LogEntry[]
Obtains the list of log files of the specified type in synchronous mode. This API accepts objects of the string type as input parameters and returns a list log files of the specified type.
| logType | string | Yes| Log type, for example, **HILOG**, **FAULTLOG**, **BETACLUB**, or **REMOTELOG**.|
| logName | string | Yes | Log file name.|
| dest | string | Yes | Target directory. Enter the relative path of the directory. If this parameter is specified, log files will be saved to the **hiview/dest** folder in the application cache path, that is, **../cache/hiview/dest**. You can enter a multi-level directory.<br>If you leave this parameter empty, log files will be saved to the root directory, that is, the **hiview** folder in the application cache path.|
| Promise<void> | Promise used to return the result. Depending on whether the operation is successful, you can use the **then()** or **catch()** method to process the callback.|
**Error codes**
For details about error codes, see [Log Library Error Codes](../errorcodes/errorcode-loglibrary.md).
| logType | string | Yes| Log type, for example, **HILOG**, **FAULTLOG**, **BETACLUB**, or **REMOTELOG**.|
| logName | string | Yes | Log file name.|
| dest | string | Yes | Target directory. Enter the relative path of the directory. If this parameter is specified, log files will be saved to the **hiview/dest** folder in the application cache path, that is, **../cache/hiview/dest**. You can enter a multi-level directory.<br>If you leave this parameter empty, log files will be saved to the root directory, that is, the **hiview** folder in the application cache path.|
| callback | AsyncCallback<void> | Yes| Callback used to process the received return value. The value **0** indicates that the operation is successful, and any other value indicates that the operation has failed.|
**Error codes**
For details about error codes, see [Log Library Error Codes](../errorcodes/errorcode-loglibrary.md).
| logType | string | Yes| Log type, for example, **FAULTLOG**, **BETACLUB**, or **REMOTELOG**.|
| logName | string | Yes | Log file name.|
| dest | string | Yes | Target directory. Enter the relative path of the directory. If this parameter is specified, log files will be saved to the **hiview/dest** folder in the application cache path, that is, **../cache/hiview/dest**. You can enter a multi-level directory.<br>If you leave this parameter empty, log files will be saved to the root directory, that is, the **hiview** folder in the application cache path.|
| Promise<void> | Promise used to return the result. Depending on whether the operation is successful, you can use the **then()** or **catch()** method to process the callback.|
**Error codes**
For details about error codes, see [Log Library Error Codes](../errorcodes/errorcode-loglibrary.md).
| logType | string | Yes| Log type, for example, **HILOG**, **FAULTLOG**, **BETACLUB**, or **REMOTELOG**.|
| logName | string | Yes | Log file name.|
| dest | string | Yes | Target directory. Enter the relative path of the directory. If this parameter is specified, log files will be saved to the **hiview/dest** folder in the application cache path, that is, **../cache/hiview/dest**. You can enter a multi-level directory.<br>If you leave this parameter empty, log files will be saved to the root directory, that is, the **hiview** folder in the application cache path.|
| callback | AsyncCallback<void> | Yes| Callback used to process the received return value. The value **0** indicates that the operation is successful, and any other value indicates that the operation has failed.|
**Error codes**
For details about error codes, see [Log Library Error Codes](../errorcodes/errorcode-loglibrary.md).
The **console** module provides basic log printing capabilities and supports log printing by log level.
If you want to use more advanced log printing services, for example, filtering logs by the specified ID, you are advised to use [`@ohos.hilog`](js-apis-hilog.md).
The **console** module provides a simple debugging console, which is similar to the JavaScript console provided by the browser.
> **NOTE**
>
...
...
@@ -10,9 +8,9 @@ If you want to use more advanced log printing services, for example, filtering l
## console.debug
debug(message: string): void
debug(message: string, ...arguments: any[]): void
Prints debug-level logs.
Prints debugging information in formatted output mode.
| message | string | Yes | Error information to be printed.|
| arguments | any | No | Arguments in the message or other information to be printed.|
**Example**
```js
conststr="value is not defined";
console.error('error: %d',str);// Print the error information with arguments in the message replaced.
// error: value is not defined
console.error('error:',str);// Print the message and other information.
// error: value is not defined
console.error('error:');// Print the message only.
// error:
```
export default {
clickConsole(){
var versionCode = 1;
console.info('Hello World. The current version code is ' + versionCode);
console.log(`versionCode: ${versionCode}`);
/ / The following is supported since API version 6: console.log('versionCode:%d.', versionCode);
}
}
```
Switch to the HiLog window at the bottom of HUAWEI DevEco Studio. Specifically, select the current device and process, set the log level to Info, and enter Hello World in the search box. Logs that meet the search criteria are displayed, as shown in the following figure.
@@ -112,24 +149,26 @@ If **value** is false, the subsequent content will be printed.
| Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ----------- |
| value | Object | No | Value|
| arguments | Object | No | Prints error messages.|
| value | Object | No | Result value. If **value** is **false** or left blank, the output starting with "Assertion failed" is printed. If **value** is **true**, no information is printed.|
| arguments | Object | No | Other information to be printed when **value** is **false**. If this parameter is left blank, other information is not printed.|
**Example**
```
console.assert(true, 'does nothing');
```js
console.assert(true,'does nothing');// Do not print error information as value is true.
console.assert(2%1==0,'does nothing');// Do not print error information as value is true.
@@ -167,10 +207,10 @@ Resets a counter by the specified label name. The default value is **default**.
| Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ----------- |
| label | string | No | Counter label name.|
| label | string | No | Counter label name. The default value is **default**.|
**Example**
```
```js
console.count('abc');
// abc: 1
console.countReset('abc');
...
...
@@ -190,13 +230,24 @@ Prints content of the specified object.
| Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ----------- |
| dir | Object | No | Object whose content needs to be printed.|
| dir | Object | No | Object whose content needs to be printed. If this parameter is left blank, no information is printed.|
**Example**
```js
leta={foo:{bar:{baz:true}}};
console.dir(a);
// Object: {"foo":{"bar":{"baz":true}}}
console.dir();// No information is printed.
```
## console.dirxml<sup>10+</sup>
dirxml(...arguments: Object[]): void
Calls **console.log()** and passes the received parameters to it. This API does not produce any content of the XML format.
Displays an interactive tree of the descendant elements of the specified XML element. This API is implemented by calling **console.log()** internally. It does not produce any XML elements. The usage method is the same as that of **console.log()**.
Starts a timer to track the duration of an operation. The default value is **default**. You can use **console.timeEnd()** to disable the timer and print the result.
Starts a timer to track the duration of an operation. You can use **console.timeEnd()** to close the timer and print the elapsed time (in ms).
The **shortKey** module provides APIs to set the delay for starting an ability using a shortcut key. For example, you can set the delay to 3 seconds so that a screenshot is taken when you press and hold the shortcut key for 3 seconds.
> **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.
> - The APIs provided by this module are system APIs.
## Modules to Import
```
import shortKey from '@ohos.multimodalInput.shortKey';
| businessId | string | Yes | Unique service ID registered on the multimodal side. It corresponds to **businessId** in the **ability_launch_config.json** file.|
| delay | number | Yes | Delay for starting an ability using the shortcut key, in ms.|
| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
| businessId | string | Yes | Unique service ID registered on the multimodal side. It corresponds to **businessId** in the **ability_launch_config.json** file.|
| delay | number | Yes | Delay for starting an ability using the shortcut key, in ms.|
**Return value**
| Parameters | Description |
| ------------- | ------------- |
| Promise<void> | Promise used to return the result.|
@@ -27,7 +27,7 @@ Obtains the current charging state and battery level.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| options | [GetStatusOptions](#getstatusoptions) | No| Object that contains the API calling result.|
| options | [GetStatusOptions](#getstatusoptions) | No| Object that contains the API calling result. This parameter is optional and is left blank by default.|
**Example**
...
...
@@ -50,9 +50,9 @@ Object that contains the API calling result.
| success | (data: [BatteryResponse](#batteryresponse)) => void | No | Called when API call is successful. **data** is a return value of the [BatteryResponse](#batteryresponse) type.|
| fail | (data: string, code: number) => void | No | Called when API call has failed. **data** indicates the error information, and **code** indicates the error code. |
| complete | () => void | No | Called when API call is complete. |
| success | (data: [BatteryResponse](#batteryresponse)) => void | No | Called when an API call is successful. **data** is a return value of the [BatteryResponse](#batteryresponse) type.|
| fail | (data: string, code: number) => void | No | Called when an API call has failed. **data** indicates the error information, and **code** indicates the error code. |
| complete | () => void | No | Called when an API call is complete. |
@@ -28,7 +28,7 @@ Obtains the current screen brightness.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| options | [GetBrightnessOptions](#getbrightnessoptions) | No | Options for obtaining the screen brightness.|
| options | [GetBrightnessOptions](#getbrightnessoptions) | No | Options for obtaining the screen brightness. This parameter is optional and is left blank by default.|
**Example**
...
...
@@ -56,7 +56,7 @@ Sets the screen brightness.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| options | [SetBrightnessOptions](#setbrightnessoptions) | No | Options for setting the screen brightness.|
| options | [SetBrightnessOptions](#setbrightnessoptions) | No | Options for setting the screen brightness. This parameter is optional and is left blank by default.|
**Example**
...
...
@@ -85,7 +85,7 @@ Obtains the screen brightness adjustment mode.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| options | [GetBrightnessModeOptions](#getbrightnessmodeoptions) | No| Options for obtaining the screen brightness mode.|
| options | [GetBrightnessModeOptions](#getbrightnessmodeoptions) | No| Options for obtaining the screen brightness mode. This parameter is optional and is left blank by default.|
**Example**
...
...
@@ -112,7 +112,7 @@ Sets the screen brightness adjustment mode.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| options | [SetBrightnessModeOptions](#setbrightnessmodeoptions) | No | Options for setting the screen brightness mode.|
| options | [SetBrightnessModeOptions](#setbrightnessmodeoptions) | No | Options for setting the screen brightness mode. This parameter is optional and is left blank by default.|
**Example**
...
...
@@ -143,7 +143,7 @@ Sets whether to always keep the screen on. Call this API in **onShow()**.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| options | [SetKeepScreenOnOptions](#setkeepscreenonoptions) | No| Options for setting the screen to be steady on.|
| options | [SetKeepScreenOnOptions](#setkeepscreenonoptions) | No| Options for setting the screen to be steady on. This parameter is optional and is left blank by default.|
**Example**
...
...
@@ -166,9 +166,9 @@ Defines the options for obtaining the screen brightness.
| success | (data: [BrightnessResponse](#brightnessresponse)) => void | No | Called when API call is successful. **data** is a return value of the [BrightnessResponse](#brightnessresponse) type.|
| fail | (data: string, code: number) => void | No | Called when API call has failed. **data** indicates the error information, and **code** indicates the error code. |
| complete | () => void | No | Called when the API call is complete. |
| success | (data: [BrightnessResponse](#brightnessresponse)) => void | No | Called when an API call is successful. **data** is a return value of the [BrightnessResponse](#brightnessresponse) type.|
| fail | (data: string, code: number) => void | No | Called when an API call has failed. **data** indicates the error information, and **code** indicates the error code. |
| complete | () => void | No | Called when an API call is complete. |
## SetBrightnessOptions
...
...
@@ -178,10 +178,10 @@ Defines the options for setting the screen brightness.
| value | number | Yes | Screen brightness. The value is an integer ranging from **1** to **255**.<br>- If the value is less than or equal to **0**, value **1** will be used.<br>- If the value is greater than **255**, value **255** will be used.<br>- If the value contains decimals, the integral part of the value will be used. For example, if value **8.1** is set, value **8** will be used.|
| success | () => void | No | Callback upon a successful API call. |
| fail | (data: string, code: number) => void | No | Called when API call has failed. **data** indicates the error information, and **code** indicates the error code. |
| complete | () => void | No | Called when the API call is complete. |
| value | number | Yes | Screen brightness. The value is an integer ranging from **1** to **255**.<br>- If the value is less than or equal to **0**, value **1** will be used.<br>- If the value is greater than **255**, value **255** will be used.<br>- If the value contains decimals, the integral part of the value will be used. For example, if value **8.1** is set, value **8** will be used.|
| success | () => void | No | Called when an API call is successful. |
| fail | (data: string, code: number) => void | No | Called when an API call has failed. **data** indicates the error information, and **code** indicates the error code. |
| complete | () => void | No | Called when an API call is complete. |
## BrightnessResponse
...
...
@@ -201,9 +201,9 @@ Defines the options for obtaining the screen brightness mode.
| success | (data: [BrightnessModeResponse](#brightnessmoderesponse)) => void | No | Called when API call is successful. **data** is a return value of the [BrightnessModeResponse](#brightnessmoderesponse) type.|
| fail | (data: string, code: number) => void | No | Called when API call has failed. **data** indicates the error information, and **code** indicates the error code. |
| complete | () => void | No | Called when the API call is complete. |
| success | (data: [BrightnessModeResponse](#brightnessmoderesponse)) => void | No | Called when an API call is successful. **data** is a return value of the [BrightnessModeResponse](#brightnessmoderesponse) type.|
| fail | (data: string, code: number) => void | No | Called when an API call has failed. **data** indicates the error information, and **code** indicates the error code. |
| complete | () => void | No | Called when an API call is complete. |
## SetBrightnessModeOptions
...
...
@@ -214,9 +214,9 @@ Defines the options for setting the screen brightness mode.
| mode | number | Yes | The value **0** indicates the manual adjustment mode, and the value **1** indicates the automatic adjustment mode.|
| success | () => void | No | Callback upon a successful API call. |
| fail | (data: string, code: number) => void | No | Called when API call has failed. **data** indicates the error information, and **code** indicates the error code.|
| complete | () => void | No | Called when the API call is complete. |
| success | () => void | No | Called when an API call is successful. |
| fail | (data: string, code: number) => void | No | Called when an API call has failed. **data** indicates the error information, and **code** indicates the error code.|
| complete | () => void | No | Called when an API call is complete. |
## BrightnessModeResponse
...
...
@@ -237,6 +237,6 @@ Defines the options for setting the screen to be steady on.
| keepScreenOn | boolean | Yes | The value **true** means to keep the screen steady on, and the value **false** indicates the opposite. |
| success | () => void | No | Callback upon a successful API call. |
| fail | (data: string, code: number) => void | No | Called when API call has failed. **data** indicates the error information, and **code** indicates the error code.|
| complete | () => void | No | Called when the API call is complete. |
| success | () => void | No | Called when an API call is successful. |
| fail | (data: string, code: number) => void | No | Called when an API call has failed. **data** indicates the error information, and **code** indicates the error code.|
| complete | () => void | No | Called when an API call is complete. |
> This topic describes only module-specific error codes. For details about universal error codes, see [Universal Error Codes](errorcode-universal.md).
## 21300001 Specified File Not Exist
**Error Message**
The specified file does not exist.
**Description**
When the **copy**, **move**, or **delete** API is called to perform file operations, the file with the specified name does not exist in the specified type of logs.
**Possible Cause**
1. The input file name is incorrect.
2. The file with the input file name does not exist.
By default, OpenHarmony provides the power mode feature, which offers the following options: normal mode, performance mode, power-saving mode, and ultra power-saving mode. However, the power mode configuration varies according to hardware specifications of different products. To address this issue, OpenHarmony provides the power mode customization function, allowing you to customize power modes depending on your hardware specifications.
By default, OpenHarmony provides the power mode feature, which offers the following options: normal mode, performance mode, power-saving mode, and super power-saving mode. However, the power mode configuration varies according to hardware specifications of different products. To address this issue, OpenHarmony provides the power mode customization function, allowing you to customize power modes depending on your hardware specifications.
### Basic Concepts
...
...
@@ -16,7 +16,7 @@ OpenHarmony supports the following four power modes, each of which corresponds t
- Power-saving mode: power mode that emphasizes on power saving, such as decreasing the system brightness, reducing the screen-off time, and shortening the time for entering sleep mode.
-Ultra power-saving mode: power mode that emphasizes on ultimate power saving, such as greatly decreasing the system brightness, greatly reducing the screen-off time, and greatly shortening the time for entering sleep mode.
-Super power-saving mode: power mode that emphasizes on ultimate power saving, such as greatly decreasing the system brightness, greatly reducing the screen-off time, and greatly shortening the time for entering sleep mode.
### Constraints
...
...
@@ -59,7 +59,7 @@ The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/ma
| Normal mode| 600 |
| Power-saving mode| 601 |
| Performance mode| 602 |
| Ultra power-saving mode| 603 |
| Super power-saving mode| 603 |
The **switch** node is used to configure items of the power mode.
...
...
@@ -243,9 +243,9 @@ The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/ma
4. Turn on the screen. If the screen turns off after 30 seconds, the setting of the auto sleep time is successful.
5. Set the power mode to the ultra power-saving mode, and verify the setting.
5. Set the power mode to the super power-saving mode, and verify the setting.
1. Set the power mode to the ultra power-saving mode.
1. Set the power mode to the super power-saving mode.
```shell
power-shell setmode 603
...
...
@@ -278,8 +278,6 @@ The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/ma
## Reference
During development, you can refer to the [default power mode configuration](https://gitee.com/openharmony/powermgr_power_manager/tree/master/services/native/profile):
During development, you can refer to the [default power mode configuration](https://gitee.com/openharmony/powermgr_power_manager/blob/master/services/native/profile/power_mode_config.xml):
@@ -52,7 +52,7 @@ The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/ma
| name="current" | Charging current control | event | - **1**: event sending enabled<br>-**0**: event sending disabled| int | 0 or 1|
| name="voltage" | Charging voltage control (charging voltage during fast charging and slow charging)| protocol | Supported charging protocols: fast charging (supercharge) and slow charging (buck)| string | sc or buck|
| name="voltage" | Charging voltage control | event | - **1**: event sending enabled<br>-**0**: event sending disabled| int | 0 or 1|
| name="process_ctrl" | Process control (survival status of foreground and background processes)| event | - **1**: event sending enabled<br>-**0**: event sending disabled| int | 0 or 1|
| name="process_ctrl" | Process control (survival status of foreground and background processes)| event | - **1**: event sending enabled<br>-**0**: event sending disabled<br>If this parameter is not set, the value is defaulted to **0**.| int | 0 or 1|
| name="shut_down" | Shutdown control (device shutdown)| event | - **1**: event sending enabled<br>-**0**: event sending disabled| int | 0 or 1|
| name="thermallevel" | Thermal level control (thermal level reporting)| event | - **1**: event sending enabled<br>-**0**: event sending disabled| int | 0 or 1|
During development, you can refer to the [default thermal control configuration](https://gitee.com/openharmony/powermgr_thermal_manager/blob/master/services/native/profile/thermal_service_config.xml).