> - The APIs of this module are no longer maintained since API version 7. It is recommended that you use [`@ohos.batteryInfo`](js-apis-battery-info.md) instead.
>
> - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```
import battery from '@system.battery';
```
## battery.getStatus
getStatus(Object): void
Obtains the current charging state and battery level.
> - The APIs of this module are no longer maintained since API version 7. It is recommended that you use [`@ohos.brightness`](js-apis-brightness.md) instead.
>
> - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version.
| 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 | Function | No | Called when the execution is successful. |
| fail | Function | No | Called when the operation fails. |
| complete | Function | No | Called when the execution is complete. |
**Example**
```
export default {
setValue() {
brightness.setValue({
value: 100,
success: function(){
console.log('handling set brightness success.');
},
fail: function(data, code){
console.log('handling set brightness value fail, code:' + code + ', data: ' + data);
> - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.
| transformation | string | No | Encryption mode and padding of the AES algorithm. The default value is **AES/CBC/PKCS5Padding**. |
| iv | string | No | Initial vector for AES-based encryption and decryption. The value is a character string encoded using Base64. The default value is the key value. |
| ivOffset | string | No | Offset of the initial vector for AES-based encryption and decryption. The default value is **0**. |
| ivLen | string | No | Length of the initial vector for AES-based encryption and decryption. The default value is **16**. |
| success | Function | No | Called when data is encrypted or decrypted successfully. |
| fail | Function | No | Called when data fails to be encrypted or decrypted. |
| complete | Function | No | Called when the execution is complete. |
> - The APIs of this module are no longer maintained since API version 7. It is recommended that you use [`@ohos.i18n`](js-apis-i18n.md) and [`@ohos.intl`](js-apis-intl.md) instead.
>
>
> - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```
import configuration from '@system.configuration';
```
## configuration.getLocale
getLocale(): <LocaleResponse>
Obtains the current locale of the application, which is the same as the system locale.
> - The APIs of this module are no longer maintained since API version 6. It is recommended that you use [`@ohos.deviceInfo`](js-apis-device-info.md) instead.
>
> - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - The APIs of this module are no longer maintained since API version 6. It is recommended that you use [`@ohos.net.http`](js-apis-http.md) instead.
>
> - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version.
| data | string \| Object | No | Request parameter, which can be a string or a JSON object. For details, see Relationship between data and Content-Type. |
| header | Object | No | Request header. |
| method | string | No | Request method. The default value is **GET**. The value can be **OPTIONS**, **GET**, **HEAD**, **POST**, **PUT**, **DELETE **or **TRACE**. |
| responseType | string | No | Response type. The return type can be text or JSON. By default, the return type is determined based on **Content-Type** in the header returned by the server. For details, see return values of the success callback. |
| success | Function | No | Called when the network data is obtained successfully. |
| fail | Function | No | Called when the network data fails to be obtained. |
| complete | Function | No | Called when the execution is complete. |
**Table1** Relationship between data and Content-Type
The following values will be returned when data is successfully obtained.
| Parameter | Type | Description |
| -------- | -------- | -------- |
| code | number | Server status code. |
| data | string \| Object | The type of the returned data is determined by **responseType**. For details, see Relationship between responseType and data returned by the success function. |
> HTTPS is supported by default. To support HTTP, you need to add **"network"** to the **config.json** file, and set the attribute **"cleartextTraffic"** to **true**.
> - The APIs of this module are no longer maintained since API version 6. It is recommended that you use [`@ohos.fileio`](js-apis-fileio.md) instead.
>
> - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version.
| success | Function | No | Called when the source file is moved to the specified location successfully. This function returns the URI of the destination location. |
| fail | Function | No | Called when the operation fails. |
| complete | Function | No | Called when the execution is complete. |
One of the following error codes will be returned if the operation fails.
| success | Function | No | Called when the source file is copied and saved to the specified location successfully. This function returns the URI of the destination location. |
| fail | Function | No | Called when the operation fails. |
| complete | Function | No | Called when the execution is complete. |
One of the following error codes will be returned if the operation fails.
| position | number | No | Offset to the position where the writing starts. The default value is **0**. |
| append | boolean | No | Whether to enable the append mode. The default value is **false**. If the value is **true**, the **position** parameter will become invalid. |
| success | Function | No | Called when the operation is successful. |
| fail | Function | No | Called when the operation fails. |
| complete | Function | No | Called when the execution is complete. |
One of the following error codes will be returned if the operation fails.
| Error Code | Description |
| -------- | -------- |
| 202 | Invalid parameter. |
| 300 | I/O error. |
**Example**
```
export default {
writeArrayBuffer() {
file.writeArrayBuffer({
uri: 'internal://app/test',
buffer: new Uint8Array(8), // The buffer is of the Uint8Array type.
| uri | string | Yes | URI of a local file. |
| encoding | string | No | Encoding format. The default format is UTF-8. |
| position | number | No | Position where the reading starts. The default value is the start position of the file. |
| length | number | No | Length of the text to be read (in bytes). The default value is **4096**. |
| success | Function | No | Called when the operation is successful. |
| fail | Function | No | Called when the operation fails. |
| complete | Function | No | Called when the execution is complete. |
Return values of the **success** callback
| Name | Type | Description |
| -------- | -------- | -------- |
| text | string | Text read from the specified file. |
One of the following error codes will be returned if the operation fails.
| uri | string | Yes | URI of a local file. |
| position | number | No | Position where the reading starts. The default value is the start position of the file. |
| length | number | No | Length of data to read. If this parameter is not set, the reading proceeds until the end of the file. |
| success | Function | No | Called when the operation is successful. |
| fail | Function | No | Called when the operation fails. |
| complete | Function | No | Called when the execution is complete. |
> - The APIs of this module are no longer maintained since API version 7. It is recommended that you use [`@ohos.geolocation`](js-apis-geolocation.md) instead.
>
> - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version.
| timeout | number | No | Timeout duration, in milliseconds. The default value is **30000**.<br/>The timeout duration is necessary in case the request to obtain the geographic location is rejected for the lack of the required permission, weak positioning signal, or incorrect location settings. After the timeout duration expires, the fail function will be called.<br/>The value is a 32-digit positive integer. If the value set is less than or equal to **0**, the default value will be used. |
| coordType | string | No | Coordinate system type. Available types can be obtained by **getSupportedCoordTypes**. The default type is **wgs84**. |
| success | Function | No | Called when the operation is successful. |
| fail | Function | No | Called when the operation fails. |
| complete | Function | No | Called when the execution is complete |
The following values will be returned when the operation is successful.
| Parameter | Type | Description |
| -------- | -------- | -------- |
| longitude | number | Longitude |
| latitude | number | Latitude |
| altitude | number | Altitude |
| accuracy | number | Location accuracy |
| time | number | Time when the location is obtained |
One of the following error codes will be returned if the operation fails.
> - The APIs of this module are no longer maintained since API version 7. It is recommended that you use [`@ohos.telephony.observer`](js-apis-observer.md) instead.
>
> - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - The APIs of this module are no longer maintained since API version 7. It is recommended that you use [`@ohos.bundle`](js-apis-Bundle.md) instead.
>
> - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```
import pkg from '@system.package';
```
## package.hasInstalled
hasInstalled(Object): void
Checks whether an application exists, or whether a native application has been installed.
> - The APIs of this module are no longer maintained since API version 6. It is recommended that you use [`@ohos.request`](js-apis-request.md) instead.
>
> - The initial APIs of this module are supported since API version 4. Newly added APIs will be marked with a superscript to indicate their earliest API version.
| data | Array<RequestData> | No | Form data in the request body. |
| success | Function | No | Called when the download task is complete. |
| fail | Function | No | Called when downloading fails or the task does not exist. |
| complete | Function | No | Called when the execution is complete. |
**Table 1** File
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| filename | string | No | File name in the header when **multipart** is used. |
| name | string | No | Name of a form item when **multipart** is used. The default value is **file**. |
| uri | string | Yes | Local storage path of a file. |
| type | string | No | Type of the file content. By default, the type is obtained based on the suffix of the file name or URI. |
**Table 2** RequestData
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| name | string | Yes | Name of the form element |
| value | string | Yes | Value of the form element |
The following values will be returned when the files are successfully uploaded.
| Name | Type | Description |
| -------- | -------- | -------- |
| code | number | HTTP status code returned by the server. |
| data | string | Content returned by the server. The value type is determined by the type in the returned headers. |
> - The APIs of this module are no longer maintained since API version 6. It is recommended that you use [`@ohos.data.storage`](js-apis-data-storage.md) instead.
>
> - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version.