| callback | AsyncCallback<Array<[BatteryStatsInfo](#batterystatsinfo)>> | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is the array of power consumption information obtained. If the operation failed, **err** is an error object.|
| callback | AsyncCallback<Array<[BatteryStatsInfo](#batterystatsinfo)>> | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is the array of power consumption information obtained (that is, **Array<[BatteryStatsInfo](#batterystatsinfo)>>**). If the operation failed, **err** is an error object.|
**Error codes**
For details about the error codes, see [Thermal Manager Error Codes](../errorcodes/errorcode-batteryStatistics.md).
| Code| Error Message |
| -------- | -------------- |
| 4600101 | Operation failed. Cannot connect to service.|
| Code | Error Message |
|---------|---------|
| 4600101 | Operation failed. Cannot connect to service.|
**Example**
...
...
@@ -112,9 +112,9 @@ Obtains the power consumption of an application.
For details about the error codes, see [Thermal Manager Error Codes](../errorcodes/errorcode-batteryStatistics.md).
| Code| Error Message |
| -------- | -------------- |
| 4600101 | Operation failed. Cannot connect to service.|
| Code | Error Message |
|---------|---------|
| 4600101 | Operation failed. Cannot connect to service.|
**Example**
...
...
@@ -153,9 +153,9 @@ Obtains the proportion of the power consumption of an application.
For details about the error codes, see [Thermal Manager Error Codes](../errorcodes/errorcode-batteryStatistics.md).
| Code| Error Message |
| -------- | -------------- |
| 4600101 | Operation failed. Cannot connect to service.|
| Code | Error Message |
|---------|---------|
| 4600101 | Operation failed. Cannot connect to service.|
**Example**
...
...
@@ -194,16 +194,16 @@ Obtains the power consumption of a hardware unit according to the consumption ty
For details about the error codes, see [Thermal Manager Error Codes](../errorcodes/errorcode-batteryStatistics.md).
| Code| Error Message |
| -------- | -------------- |
| 4600101 | Operation failed. Cannot connect to service.|
| Code | Error Message |
|---------|---------|
| 4600101 | Operation failed. Cannot connect to service.|
@@ -10,7 +10,7 @@ The **observer** module provides event subscription management functions. You ca
## Modules to Import
```
import observer from '@ohos.telephony.observer'
import observer from '@ohos.telephony.observer';
```
## observer.on('networkStateChange')
...
...
@@ -31,7 +31,6 @@ Registers an observer for network status change events. This API uses an asynchr
| callback | Callback\<[NetworkState](js-apis-radio.md#networkstate)\> | Yes | Callback used to return the result. For details, see [NetworkState](js-apis-radio.md#networkstate).|
**Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
@@ -70,7 +69,6 @@ Registers an observer for network status change events of the SIM card in the sp
| callback | Callback\<[NetworkState](js-apis-radio.md#networkstate)\> | Yes | Callback used to return the result. For details, see [NetworkState](js-apis-radio.md#networkstate).|
**Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
@@ -145,7 +143,6 @@ Registers an observer for signal status change events. This API uses an asynchro
| callback | Callback<Array<[SignalInformation](js-apis-radio.md#signalinformation)\>\> | Yes | Callback used to return the result. For details, see [SignalInformation](js-apis-radio.md#signalinformation).|
**Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
@@ -182,7 +179,6 @@ Registers an observer for signal status change events of the SIM card in the spe
| callback | Callback<Array<[SignalInformation](js-apis-radio.md#signalinformation)\>\> | Yes | Callback used to return the result. For details, see [SignalInformation](js-apis-radio.md#signalinformation).|
**Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
@@ -222,7 +218,6 @@ Unregisters the observer for signal status change events. This API uses an async
| callback | Callback<Array<[SignalInformation](js-apis-radio.md#signalinformation)\>\> | No | Callback used to return the result. For details, see [SignalInformation](js-apis-radio.md#signalinformation).|
**Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
on\(type: \'cellInfoChange\', options: { slotId: number }, callback: Callback<CellInformation\>\): void;
Registers an observer for signal status change events of the SIM card in the specified slot. This API uses an asynchronous callback to return the execution result.
**System API**: This is a system API.
**Required permissions**: ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION
Unregisters the observer for cell information change events. This API uses an asynchronous callback to return the result.
>**NOTE**
>
>You can pass the callback of the **on** function if you want to cancel listening for a certain type of event. If you do not pass the callback, you will cancel listening for all events.
// You can pass the callback of the on method to cancel listening for a certain type of callback. If you do not pass the callback, you will cancel listening for all callbacks.
observer.off('cellInfoChange',callback);
observer.off('cellInfoChange');
```
## observer.on('callStateChange')
...
...
@@ -261,7 +375,6 @@ Registers an observer for call status change events. This API uses an asynchrono
| callback | Callback\<{ state: [CallState](js-apis-call.md#callstate), number: string }\> | Yes | Callback function. For details, see [CallState](js-apis-call.md#callstate) in call.<br>**number**: phone number.|
**Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
@@ -375,7 +486,6 @@ Registers an observer for connection status change events of the cellular data l
| callback | Callback\<{ state: [DataConnectState](js-apis-telephony-data.md#dataconnectstate), network: [RatType](js-apis-radio.md#radiotechnology) }\> | Yes | Callback used to return the result. For details, see [DataConnectState](js-apis-telephony-data.md#dataconnectstate) and [RadioTechnology](js-apis-radio.md#radiotechnology).|
**Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
@@ -411,7 +521,6 @@ Registers an observer for connection status change events of the cellular data l
| callback | Callback\<{ state: [DataConnectState](js-apis-telephony-data.md#dataconnectstate), network: [RatType](js-apis-radio.md#radiotechnology) }\> | Yes | Callback used to return the result. For details, see [DataConnectState](js-apis-telephony-data.md#dataconnectstate) and [RadioTechnology](js-apis-radio.md#radiotechnology).|
**Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
@@ -450,7 +559,6 @@ Unregisters the observer for connection status change events of the cellular dat
| callback | Callback\<{ state: [DataConnectState](js-apis-telephony-data.md#dataconnectstate), network: [RatType](js-apis-radio.md#radiotechnology) }\> | No | Callback used to return the result. For details, see [DataConnectState](js-apis-telephony-data.md#dataconnectstate) and [RadioTechnology](js-apis-radio.md#radiotechnology).|
**Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
@@ -489,7 +597,6 @@ Registers an observer for the uplink and downlink data flow status change events
| callback | Callback\<[DataFlowType](js-apis-telephony-data.md#dataflowtype)\> | Yes | Callback used to return the result. For details, see [DataFlowType](js-apis-telephony-data.md#dataflowtype).|
**Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
@@ -525,7 +632,6 @@ Registers an observer for the uplink and downlink data flow status change events
| callback | Callback\<[DataFlowType](js-apis-telephony-data.md#dataflowtype)\> | Yes | Callback used to return the result. For details, see [DataFlowType](js-apis-telephony-data.md#dataflowtype).|
**Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
@@ -564,7 +670,6 @@ Unregisters the observer for the uplink and downlink data flow status change eve
| callback | Callback\<[DataFlowType](js-apis-telephony-data.md#dataflowtype)\> | No | Callback used to return the result. For details, see [DataFlowType](js-apis-telephony-data.md#dataflowtype).|
**Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| success | (data: [BatteryResponse](#batteryresponse)) => void | No | Called when API call is successful. **data** is a return value of the [BatteryResponse](#batteryresponse) type.|
...
...
@@ -56,7 +58,9 @@ Object that contains the API calling result.
Defines a response that returns the charging status and remaining power of the device.
| Name| Type| Description|
| -------- | -------- | -------- |
| charging | boolean | Whether the battery is being charged.|
| level | number | Current battery level, which ranges from **0.00** to **1.00**.|
| 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 API call is complete. |
| complete | () => void | No | Called when the API call is complete. |
## SetBrightnessOptions
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 | Called when API call is successful. |
| 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 API call is complete. |
| complete | () => void | No | Called when the API call is complete. |
## BrightnessResponse
Defines a response that returns the screen brightness.
| Parameter| Type | Description|
| -------- | -------- | -------- |
| value | number | Screen brightness. The value ranges from 1 to 255.|
| 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 API call is complete. |
| complete | () => void | No | Called when the API call is complete. |
## SetBrightnessModeOptions
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 | Called when API call is successful. |
| 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 API call is complete. |
| complete | () => void | No | Called when the API call is complete. |
## BrightnessModeResponse
Defines a response that returns the screen brightness mode.
| Name| Type | Description|
| -------- | -------- | -------- |
| mode | number | The value **0** indicates the manual adjustment mode, and the value **1** indicates the automatic adjustment mode.|
| keepScreenOn | boolean | Yes | The value **true** means to keep the screen steady on, and the value **false** indicates the opposite. |
| success | () => void | No | Called when API call is successful. |
| 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 API call is complete. |
| complete | () => void | No | Called when the API call is complete. |
@@ -8,8 +8,10 @@ There are two types of updates: SD card update and over the air (OTA) update.
- The OTA update depends on the server deployed by the device manufacturer for managing update packages. The OTA server IP address is passed by the caller. The request interface is fixed and developed by the device manufacturer.
> **NOTE**
> - The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - The APIs provided by this module are system APIs.
>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> The APIs provided by this module are system APIs.
## Modules to Import
...
...
@@ -2034,7 +2036,7 @@ Enumerates update states.
| WAITING_INSTALL | 30 | Waiting for installation. |
| UPDATING | 31 | Updating. |
| WAITING_APPLY | 40 | Waiting for applying the update. |
The **usb** module provides USB device management functions, including USB device list query, bulk data transfer, control transfer, and permission control.
> **NOTE**
> **NOTE**
>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> This module is deprecated since API version 9. You are advised to use [`@ohos.usbManager`](js-apis-usbManager.md) instead.
>
> The APIs provided by this module are no longer maintained since API version 9. You are advised to use [`@ohos.usbManager`](js-apis-usbManager.md).
@@ -131,7 +132,7 @@ Checks whether the application has the permission to access the device.
| Type| Description|
| -------- | -------- |
| boolean | The value **true** indicates that the application has the permission to access the device, and the value **false** indicates the opposite.|
| boolean | Returns **true** if the application has the permission to access the device; returns **false** otherwise.|
@@ -159,14 +160,14 @@ Requests the temporary permission for the application to access the USB device.
| Type| Description|
| -------- | -------- |
| Promise<boolean> | Promise used to return the result. The value **true** indicates that the temporary device access permissions are granted, and the value **false** indicates the opposite.|
| Promise<boolean> | Promise used to return the result. The value **true** indicates that the temporary device access permissions are granted; and the value **false** indicates the opposite.|
The **usb** module provides USB device management functions, including USB device list query, bulk data transfer, control transfer, and permission control on the host side as well as port management, and function switch and query on the device side.
> **NOTE**<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.
>
> The APIs provided by this module are no longer maintained since API version 9. You are advised to use [`@ohos.usbManager`](js-apis-usbManager.md).
## Modules to Import
...
...
@@ -29,7 +32,7 @@ Obtains the list of USB devices connected to the host. If no device is connected
Connects to a USB device based on the device list obtained by using**getDevices()**.
Connects to the USB device based on the device information returned by**getDevices()**.
Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB device list and device information, and then call [usb.requestRight](#usbrequestright) to request the device access permission.
...
...
@@ -118,13 +121,12 @@ For details about the error codes, see [USB Error Codes](../errorcodes/errorcode
Checks whether the application has the permission to access the device.
The value **true** is returned if the device access permission is available; the value **false** is returned otherwise.
Checks whether the user, for example, the application or system, has the device access permissions. The value **true** is returned if the user has the device access permissions; the value **false** is returned otherwise.
The **usbManager** module provides USB device management functions, including USB device list query, bulk data transfer, control transfer, and permission control on the host side as well as port management, and function switch and query on the device side.
...
...
@@ -30,7 +30,7 @@ Obtains the list of USB devices connected to the host. If no device is connected
> The following describes only the error codes specific to the **socket** module. For details about common error codes, see [Common Error Codes](errorcode-universal.md) file.
By default, the system brightness of OpenHarmony ranges from **0** to **255** (**0** indicates the minimum luminance and **255** the maximum). It is applicable to the entire system and all application windows. Due to hardware restrictions, some display devices are unable to support the system brightness range. To address this issue, OpenHarmony provides the function of customizing the system brightness range. This way, you can adjust the system brightness range based on the hardware specifications of the display devices.
### Basic Concepts
**System brightness**
Global brightness of OpenHarmony. The customized brightness range is effective for all application windows.
**Window brightness**
Brightness of an application window. The customized brightness range is effective only for this application window. After a brightness is specified for an application window, its brightness is not affected by the system brightness.
### Constraints
The [sysparam](./subsys-boot-init-sysparam.md) module of OpenHarmony provides an easy-to-use key-value pair access interface for system services to configure service functions based on their own system parameters. The customization of the system brightness range is dependent on this feature.
## How to Develop
### Setting Up the Environment
**Hardware requirements:**
Development board running the standard system, for example, the DAYU200 or Hi3516D V300 open source suite.
**Environment requirements:**
For details about the requirements on the Linux environment, see [Quick Start](../quick-start/Readme-EN.md).
### How to Develop
1. In the target directory, create a target folder by referring to the [default brightness value configuration folder](https://gitee.com/openharmony/powermgr_display_manager/tree/master/service/etc). The file format is as follows:
```text
etc
├── BUILD.gn
├── display.para
├── display.para.dac
```
2. Write the customized **display.para** file by referring to the [**display.para** file](https://gitee.com/openharmony/powermgr_display_manager/blob/master/service/etc/display.para) in the default brightness range configuration folder. Include the customized brightness thresholds, for example, **max=150**, **default=75**, and **min=50**, into the file:
```shell
# Brightness limits is 0-255.
const.display.brightness.min=50
const.display.brightness.default=75
const.display.brightness.max=150
```
3. Write the customized **display.para.dac** file by referring to the [**display.para.dac** file](https://gitee.com/openharmony/powermgr_display_manager/blob/master/service/etc/display.para.dac) in the default brightness range configuration folder, so as to grant the permission required to access the customized configuration.
4. Write the customized **BUILD.gn** file by referring to the [**BUILD.gn** file](https://gitee.com/openharmony/powermgr_display_manager/blob/master/service/etc/BUILD.gn) in the default brightness range configuration folder. Then, put the **display.para** and **display.para.dac** files to the **/vendor/etc/param** directory. For example:
## Install display.para to /vendor/etc/param/display.para
ohos_prebuilt_etc("display.para") {
source = "display.para"
relative_install_dir = "param"
install_images = [ chipset_base_dir ]
part_name = "${displaymgr_part_name}"
subsystem_name = "powermgr"
}
ohos_prebuilt_etc("display.para.dac") {
source = "display.para.dac"
relative_install_dir = "param"
install_images = [ chipset_base_dir ]
part_name = "${displaymgr_part_name}"
subsystem_name = "powermgr"
}
group("param_files") {
deps = [
":display.para",
":display.para.dac",
]
}
```
5. Write the customized **bundle.json** file by referring to the [**bundle.json** file](https://gitee.com/openharmony/powermgr_display_manager/blob/master/bundle.json) in the default brightness range configuration folder, so as to compile the **BUILD.gn** file.
In the preceding code, **//base/powermgr/display_manager/service** indicates the directory of the created folder, and **etc** indicates the folder name.
6. Build the customized version by referring to [Quick Start](../quick-start/Readme-EN.md). The following command uses DAYU200 as an example:
```shell
./build.sh --product-name rk3568 --ccache
```
7. Burn the customized version to the DAYU200 development board.
### Debugging and Verification
1. After startup, run the following command to launch the shell command line:
```shell
hdc shell
```
2. Run the following command to check the console output:
```shell
hidumper -s 3308 -a -a
```
3. Check the console output for the customized system brightness thresholds.
The default system brightness thresholds are as follows:
4. Set the system brightness thresholds to the customized values.
## Reference
For details about how to write the configuration file during system brightness customization, refer to the [default brightness range configuration file](https://gitee.com/openharmony/powermgr_display_manager/tree/master/service/etc).
@@ -36,7 +36,7 @@ The AI subsystem is the part of OpenHarmony that provides native distributed AI
***Programming language**: C/C++
***Operating system**: OpenHarmony
***Operating system**: OpenHarmony mini- and small-system
***Others**: The System Ability Manager \(Samgr\) has been started and is running properly.
...
...
@@ -314,9 +314,7 @@ The AI subsystem is the part of OpenHarmony that provides native distributed AI
}
```
4. Develop a sample application. For details, see the [keyword spotting demo](https://gitee.com/openharmony/applications_sample_camera/tree/master/ai).
1. Import the HTTP namespace from **@ohos.net.http.d.ts**.
1. Import the **http** namespace from **@ohos.net.http.d.ts**.
2. Call **createHttp()** to create an **HttpRequest** object.
3. Call **httpRequest.on()** to subscribe to an HTTP response header. This method returns a response earlier than the request. You can subscribe to HTTP response header events based on service requirements.
3. Call **httpRequest.on()** to subscribe to HTTP response header events. This API returns a response earlier than the request. You can subscribe to HTTP response header events based on service requirements.
4. Call **httpRequest.request()** to initiate a network request. You need to pass in the URL and optional parameters of the HTTP request.
5. Parse the returned result based on service requirements.
6. Call **httpRequest.destroy()** to release resources after the request is processed.
6. Call **off()** to unsubscribe from HTTP response header events.
7. Call **httpRequest.destroy()** to release resources after the request is processed.
```
// Import the HTTP namespace.
// Import the http namespace.
import http from '@ohos.net.http';
// Each httpRequest corresponds to an HttpRequestTask object and cannot be reused.
// Each httpRequest corresponds to an HTTP request task and cannot be reused.
let httpRequest = http.createHttp();
// Subscribe to the HTTP response header, which is returned earlier than the response to httpRequest.
httpRequest.on('headersReceive', (data) => {
console.info('header: ' + data.header);
// This API is used to listen for the HTTP Response Header event, which is returned earlier than the result of the HTTP request. It is up to you whether to listen for HTTP Response Header events.
// on('headerReceive', AsyncCallback) is replaced by on('headersReceive', Callback) since API version 8.
// Set the URL for the httpRequest. You must specify the URL address, and set httpRequestOptions as required. You can specify the parameters for GET in extraData.
// Customize EXAMPLE_URL in extraData on your own. It is up to you whether to add parameters to the URL.
"EXAMPLE_URL",
{
method: 'POST', // Optional. The default value is GET.
method: http.RequestMethod.POST, // Optional. The default value is http.RequestMethod.GET.
// You can add header fields based on service requirements.
header: {
'Content-Type': 'application/json'
...
...
@@ -127,21 +122,28 @@ httpRequest.request(
extraData: {
"data": "data to send",
},
connectTimeout: 60000, // This parameter is optional. The default value is 60000, that is, 60s.
readTimeout: 60000, // This parameter is optional. The default value is 60000, that is, 60s.
},(err, data) => {
expectDataType: http.HttpDataType.STRING, // Optional. This field specifies the type of the return data.
usingCache: true, // Optional. The default value is true.
priority: 1, // Optional. The default value is 1.
connectTimeout: 60000 // Optional. The default value is 60000, in ms.
readTimeout: 60000, // Optional. The default value is 60000, in ms.
usingProtocol: http.HttpProtocol.HTTP1_1, // Optional. The default protocol type is automatically specified by the system.
usingProxy: false, // Optional. By default, network proxy is not used. This field is supported since API 10.
}, (err, data) => {
if (!err) {
// data.result carries the HTTP response. Parse the response based on service requirements.
## cl.resourceManager.1 Change in the Meaning of the Return Value for the API Used to Obtain the rawfile Descriptor
Changed the meaning of the return value for the API used to obtain the rawfile descriptor after the non-decompression feature is added in this version. The change in the meaning of the return value, namely, **descriptor: RawFileDescriptor {fd, offset, length}**, is described as follows:
**Before change:**
**fd**: file descriptor for accessing the rawfile.
**offset**: offset for accessing the rawfile. In this case, the value is **0**.
**length**: size of the rawfile to access.
**After change:**
**fd**: file descriptor for accessing the HAP where the rawfile is located.
**offset**: offset of the accessed rawfile relative to the HAP.
**length**: size of the rawfile to access.
**Change Impact**
In versions earlier than 4.0.2.2, the rawfile can be accessed only through **fd**. In version 4.0.2.2 or later, the rawfile can be accessed only through **{fd, offset, and length}**.