提交 d58bf52c 编写于 作者: S shawn_he

update docs

Signed-off-by: Nshawn_he <shawn.he@huawei.com>
上级 b5cb8eea
# USB Service Development # USB Service Development
The USB service provides the following functions: query of USB device list, bulk data transfer, control transfer, and access permission management.
## When to Use ## When to Use
In Host mode, you can obtain the list of connected devices, enable or disable the devices, manage device access permissions, and perform data transfer or control transfer. In Host mode, you can obtain the list of connected devices, enable or disable the devices, manage device access permissions, and perform data transfer or control transfer.
## APIs ## APIs
The USB service provides the following functions: query of USB device list, bulk data transfer, control transfer, and access permission management.
The following table lists the USB APIs currently available. For details, see the [API Reference](../reference/apis/js-apis-usb.md). The following table lists the USB APIs currently available. For details, see the [API Reference](../reference/apis/js-apis-usb.md).
**Table 1** Open USB APIs **Table 1** Open USB APIs
...@@ -16,12 +16,12 @@ The following table lists the USB APIs currently available. For details, see the ...@@ -16,12 +16,12 @@ The following table lists the USB APIs currently available. For details, see the
| ------------------------------------------------------------ | ------------------------------------------------------------ | | ------------------------------------------------------------ | ------------------------------------------------------------ |
| hasRight(deviceName: string): boolean | 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. | | hasRight(deviceName: string): boolean | 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. |
| requestRight(deviceName: string): Promise\<boolean> | Requests the temporary permission for a given application to access the USB device. | | requestRight(deviceName: string): Promise\<boolean> | Requests the temporary permission for a given application to access the USB device. |
| connectDevice(device: USBDevice): Readonly\<USBDevicePipe> | Connects to the USB device based on the device information returned by **getDevices()**. | | connectDevice(device: USBDevice): Readonly\<USBDevicePipe> | Connects to the USB device based on the device information returned by `getDevices()`. |
| getDevices(): Array<Readonly\<USBDevice>> | Obtains the USB device list. | | getDevices(): Array<Readonly\<USBDevice>> | Obtains the USB device list. |
| setConfiguration(pipe: USBDevicePipe, config: USBConfig): number | Sets the USB device configuration. | | setConfiguration(pipe: USBDevicePipe, config: USBConfig): number | Sets the USB device configuration. |
| setInterface(pipe: USBDevicePipe, iface: USBInterface): number | Sets a USB interface. | | setInterface(pipe: USBDevicePipe, iface: USBInterface): number | Sets a USB interface. |
| claimInterface(pipe: USBDevicePipe, iface: USBInterface, force?: boolean): number | Claims a USB interface | | claimInterface(pipe: USBDevicePipe, iface: USBInterface, force?: boolean): number | Claims a USB interface. |
| bulkTransfer(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, timeout?: number): Promise\<number> | Performs bulk transfer. | | bulkTransfer(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, timeout?: number): Promise\<number> | Performs bulk transfer. |
| closePipe(pipe: USBDevicePipe): number | Closes a USB device pipe. | | closePipe(pipe: USBDevicePipe): number | Closes a USB device pipe. |
| releaseInterface(pipe: USBDevicePipe, iface: USBInterface): number | Releases a USB interface. | | releaseInterface(pipe: USBDevicePipe, iface: USBInterface): number | Releases a USB interface. |
| getFileDescriptor(pipe: USBDevicePipe): number | Obtains the file descriptor. | | getFileDescriptor(pipe: USBDevicePipe): number | Obtains the file descriptor. |
...@@ -30,7 +30,7 @@ The following table lists the USB APIs currently available. For details, see the ...@@ -30,7 +30,7 @@ The following table lists the USB APIs currently available. For details, see the
## How to Develop ## How to Develop
You can set a USB device as a host to connect to a device for data transfer. The development procedure is as follows: You can set a USB device as the USB host to connect to other USB devices for data transfer. The development procedure is as follows:
1. Obtain the USB device list. 1. Obtain the USB device list.
...@@ -113,7 +113,7 @@ You can set a USB device as a host to connect to a device for data transfer. The ...@@ -113,7 +113,7 @@ You can set a USB device as a host to connect to a device for data transfer. The
Claim the corresponding interface from deviceList. Claim the corresponding interface from deviceList.
interface1 must be one present in the device configuration. interface1 must be one present in the device configuration.
*/ */
usb.claimInterface(pipe , interface1, true); usb.claimInterface(pipe, interface1, true);
``` ```
4. Perform data transfer. 4. Perform data transfer.
......
...@@ -7,7 +7,7 @@ There are two types of updates: SD card update and over the air (OTA) update. ...@@ -7,7 +7,7 @@ There are two types of updates: SD card update and over the air (OTA) update.
- The SD card update depends on the update packages and SD cards. - The SD card update depends on the update packages and SD cards.
- 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. - 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:** > **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 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.
> >
...@@ -239,7 +239,7 @@ var versionDigestInfo = { ...@@ -239,7 +239,7 @@ var versionDigestInfo = {
// Options of the description file // Options of the description file
var descriptionOptions = { var descriptionOptions = {
format: DescriptionFormat.STANDARD, // Standard format format: update.DescriptionFormat.STANDARD, // Standard format
language: "zh-cn" // Chinese language: "zh-cn" // Chinese
} }
...@@ -282,7 +282,7 @@ var versionDigestInfo = { ...@@ -282,7 +282,7 @@ var versionDigestInfo = {
// Options of the description file // Options of the description file
var descriptionOptions = { var descriptionOptions = {
format: DescriptionFormat.STANDARD, // Standard format format: update.DescriptionFormat.STANDARD, // Standard format
language: "zh-cn" // Chinese language: "zh-cn" // Chinese
} }
...@@ -369,7 +369,7 @@ Obtains the description file of the current version. This API uses an asynchrono ...@@ -369,7 +369,7 @@ Obtains the description file of the current version. This API uses an asynchrono
```ts ```ts
// Options of the description file // Options of the description file
var descriptionOptions = { var descriptionOptions = {
format: DescriptionFormat.STANDARD, // Standard format format: update.DescriptionFormat.STANDARD, // Standard format
language: "zh-cn" // Chinese language: "zh-cn" // Chinese
} }
...@@ -406,7 +406,7 @@ Obtains the description file of the current version. This API uses a promise to ...@@ -406,7 +406,7 @@ Obtains the description file of the current version. This API uses a promise to
```ts ```ts
// Options of the description file // Options of the description file
var descriptionOptions = { var descriptionOptions = {
format: DescriptionFormat.STANDARD, // Standard format format: update.DescriptionFormat.STANDARD, // Standard format
language: "zh-cn" // Chinese language: "zh-cn" // Chinese
} }
...@@ -1580,7 +1580,7 @@ Represents an update file. ...@@ -1580,7 +1580,7 @@ Represents an update file.
## UpgradeTaskCallback ## UpgradeTaskCallback
### (eventInfo: [EventInfo](#eventinfo)): void (eventInfo: EventInfo): void
Represents an event callback. Represents an event callback.
......
...@@ -94,14 +94,16 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ...@@ -94,14 +94,16 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
**Parameters** **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | Name| Type| Mandatory| Description|
| device | [USBDevice](#usbdevice) | Yes| USB device information.| | -------- | -------- | -------- | -------- |
| device | [USBDevice](#usbdevice) | Yes| USB device information.|
**Return value** **Return value**
| Type| Description|
| -------- | -------- | | Type| Description|
| Readonly&lt;[USBDevicePipe](#usbdevicepipe)&gt; | USB device pipe for data transfer.| | -------- | -------- |
| Readonly&lt;[USBDevicePipe](#usbdevicepipe)&gt; | USB device pipe for data transfer.|
**Example** **Example**
...@@ -119,14 +121,16 @@ Checks whether the application has the permission to access the device. ...@@ -119,14 +121,16 @@ Checks whether the application has the permission to access the device.
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
**Parameters** **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | Name| Type| Mandatory| Description|
| deviceName | string | Yes| Device name to set.| | -------- | -------- | -------- | -------- |
| deviceName | string | Yes| Device name.|
**Return value** **Return value**
| Type| Description|
| -------- | -------- | | Type| Description|
| boolean | Returns **true** if the application has the permission to access the device; returns **false** otherwise.| | -------- | -------- |
| boolean | The value **true** indicates that the application has the permission to access the device, and the value **false** indicates the opposite.|
**Example** **Example**
...@@ -140,19 +144,21 @@ console.log(bool); ...@@ -140,19 +144,21 @@ console.log(bool);
requestRight(deviceName: string): Promise&lt;boolean&gt; requestRight(deviceName: string): Promise&lt;boolean&gt;
Requests the temporary permission for the application to access the USB device. Requests the temporary permission for the application to access the USB device. This API uses a promise to return the result.
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
**Parameters** **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | Name| Type| Mandatory| Description|
| deviceName | string | Yes| Device name to set.| | -------- | -------- | -------- | -------- |
| deviceName | string | Yes| Device name.|
**Return value** **Return value**
| Type| Description|
| -------- | -------- | | Type| Description|
| Promise&lt;boolean&gt; | Returns **true** if the temporary device access permissions are granted; returns **false** otherwise.| | -------- | -------- |
| Promise&lt;boolean&gt; | Promise used to return the result. The value **true** indicates that the temporary device access permissions are granted, and the value **false** indicates the opposite.|
**Example** **Example**
...@@ -174,16 +180,18 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ...@@ -174,16 +180,18 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
**Parameters** **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | Name| Type| Mandatory| Description|
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.| | -------- | -------- | -------- | -------- |
| iface | [USBInterface](#usbinterface) | Yes| USB interface, which is used to determine the index of the interface to claim.| | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.|
| force | boolean | No| Whether to forcibly claim the USB interface. The default value is **false**, indicating not to forcibly claim the USB interface.| | iface | [USBInterface](#usbinterface) | Yes| USB interface, which is used to determine the index of the interface to claim.|
| force | boolean | No| Whether to forcibly claim the USB interface. The default value is **false**, indicating not to forcibly claim the USB interface.|
**Return value** **Return value**
| Type| Description|
| -------- | -------- | | Type| Description|
| number | Returns **0** if the USB interface is successfully claimed; returns an error code otherwise.| | -------- | -------- |
| number | The value **0** indicates that the USB interface is successfully claimed, and an error code indicates the opposite.|
**Example** **Example**
...@@ -203,15 +211,17 @@ Before you do this, ensure that you have claimed the interface by calling [usb.c ...@@ -203,15 +211,17 @@ Before you do this, ensure that you have claimed the interface by calling [usb.c
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
**Parameters** **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | Name| Type| Mandatory| Description|
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.| | -------- | -------- | -------- | -------- |
| iface | [USBInterface](#usbinterface) | Yes| USB interface, which is used to determine the index of the interface to release.| | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.|
| iface | [USBInterface](#usbinterface) | Yes| USB interface, which is used to determine the index of the interface to release.|
**Return value** **Return value**
| Type| Description|
| -------- | -------- | | Type| Description|
| number | Returns **0** if the USB interface is successfully released; returns an error code otherwise.| | -------- | -------- |
| number | The value **0** indicates that the USB interface is successfully released, and an error code indicates the opposite.|
**Example** **Example**
...@@ -231,15 +241,17 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ...@@ -231,15 +241,17 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
**Parameters** **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | Name| Type| Mandatory| Description|
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.| | -------- | -------- | -------- | -------- |
| config | [USBConfig](#usbconfig) | Yes| USB configuration to set.| | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.|
| config | [USBConfig](#usbconfig) | Yes| USB configuration to set.|
**Return value** **Return value**
| Type| Description|
| -------- | -------- | | Type| Description|
| number | Returns **0** if the USB configuration is successfully set; returns an error code otherwise.| | -------- | -------- |
| number | The value **0** indicates that the USB configuration is successfully set, and an error code indicates the opposite.|
**Example** **Example**
...@@ -266,9 +278,10 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ...@@ -266,9 +278,10 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
| iface | [USBInterface](#usbinterface) | Yes | USB interface to set. | | iface | [USBInterface](#usbinterface) | Yes | USB interface to set. |
**Return value** **Return value**
| Type| Description|
| -------- | -------- | | Type| Description|
| number | Returns **0** if the USB interface is successfully set; returns an error code otherwise.| | -------- | -------- |
| number | The value **0** indicates that the USB interface is successfully set, and an error code indicates the opposite.|
**Example** **Example**
...@@ -289,14 +302,15 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ...@@ -289,14 +302,15 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.| | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Uint8Array | Returns the raw USB descriptor if the operation is successful; returns **undefined** otherwise.| | Uint8Array | The return value is the raw USB descriptor if the operation is successful, or **undefined** if the operation has failed.|
**Example** **Example**
...@@ -315,15 +329,16 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ...@@ -315,15 +329,16 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
**Parameters** **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | Name| Type| Mandatory| Description|
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.| | -------- | -------- | -------- | -------- |
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | -------------------- | | ------ | -------------------- |
| number | Returns the file descriptor of the USB device if the operation is successful; returns **-1** otherwise.| | number | The return value is the file descriptor of the USB device if the operation is successful, or **-1** if the operation has failed.|
**Example** **Example**
...@@ -342,16 +357,18 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ...@@ -342,16 +357,18 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
**Parameters** **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | Name| Type| Mandatory| Description|
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| USB device pipe, which is used to determine the USB device.| | -------- | -------- | -------- | -------- |
| contrlparam | [USBControlParams](#usbcontrolparams) | Yes| Control transfer parameters.| | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| USB device pipe, which is used to determine the USB device.|
| timeout | number | No| Timeout duration. The default value is **0**, indicating no timeout.| | contrlparam | [USBControlParams](#usbcontrolparams) | Yes| Control transfer parameters.|
| timeout | number | No| Timeout duration in ms. This parameter is optional. The default value is **0**, indicating no timeout.|
**Return value** **Return value**
| Type| Description|
| -------- | -------- | | Type| Description|
| Promise&lt;number&gt; | Returns the size of the transmitted or received data block if the control transfer is successful; returns **-1** if an exception occurs.| | -------- | -------- |
| Promise&lt;number&gt; | Promise used to return the result, which is the size of the transmitted or received data block if the transfer is successful, or **-1** if an exception has occurred.|
**Example** **Example**
...@@ -372,17 +389,19 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ...@@ -372,17 +389,19 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
**Parameters** **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | Name| Type| Mandatory| Description|
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| USB device pipe, which is used to determine the USB device.| | -------- | -------- | -------- | -------- |
| endpoint | [USBEndpoint](#usbendpoint) | Yes| USB endpoint, which is used to determine the USB port for data transfer.| | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| USB device pipe, which is used to determine the USB device.|
| buffer | Uint8Array | Yes| Buffer for writing or reading data.| | endpoint | [USBEndpoint](#usbendpoint) | Yes| USB endpoint, which is used to determine the USB port for data transfer.|
| timeout | number | No| Timeout duration. The default value is **0**, indicating no timeout.| | buffer | Uint8Array | Yes| Buffer for writing or reading data.|
| timeout | number | No| Timeout duration in ms. This parameter is optional. The default value is **0**, indicating no timeout.|
**Return value** **Return value**
| Type| Description|
| -------- | -------- | | Type| Description|
| Promise&lt;number&gt; | Returns the size of the transmitted or received data block if the control transfer is successful; returns **-1** if an exception occurs.| | -------- | -------- |
| Promise&lt;number&gt; | Promise used to return the result, which is the size of the transmitted or received data block if the transfer is successful, or **-1** if an exception has occurred.|
**Example** **Example**
...@@ -406,14 +425,16 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ...@@ -406,14 +425,16 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
**Parameters** **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | Name| Type| Mandatory| Description|
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| USB device pipe.| | -------- | -------- | -------- | -------- |
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| USB device pipe.|
**Return value** **Return value**
| Type| Description|
| -------- | -------- | | Type| Description|
| number | Returns **0** if the USB device pipe is closed successfully; returns an error code otherwise.| | -------- | -------- |
| number | The value **0** indicates that the USB device pipe is closed successfully, and an error code indicates the opposite.|
**Example** **Example**
...@@ -498,8 +519,8 @@ Sets the current USB function list in Device mode. ...@@ -498,8 +519,8 @@ Sets the current USB function list in Device mode.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------ | ------------------------------------------------------ | | ------------------ | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the result. The value **true** indicates that the operation is successful, and the value **false** indicates the opposite.| | Promise\<boolean\> | Promise used to return the result. The value **true** indicates that the operation is successful, and the value **false** indicates the opposite.|
**Example** **Example**
...@@ -601,8 +622,8 @@ Sets the role types supported by a specified port, which can be **powerRole** (f ...@@ -601,8 +622,8 @@ Sets the role types supported by a specified port, which can be **powerRole** (f
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------ | -------------- | | ------------------ | ------------------------------------------------------------ |
| Promise\<boolean\> | Promise used to return the result. The value **true** indicates that the operation is successful, and the value **false** indicates the opposite.| | Promise\<boolean\> | Promise used to return the result. The value **true** indicates that the operation is successful, and the value **false** indicates the opposite.|
**Example** **Example**
......
...@@ -15,27 +15,27 @@ HiSysEvent allows you to query system events by specifying search criteria. For ...@@ -15,27 +15,27 @@ HiSysEvent allows you to query system events by specifying search criteria. For
> >
> For details about the **HiSysEventRecord** argument in the **OnQuery()** method of **HiSysEventQueryCallback**, see Table 5 in [HiSysEvent Listening](subsys-dfx-hisysevent-listening.md). > For details about the **HiSysEventRecord** argument in the **OnQuery()** method of **HiSysEventQueryCallback**, see Table 5 in [HiSysEvent Listening](subsys-dfx-hisysevent-listening.md).
**Table 1** Description of the HiSysEvent query API **Table 1** Description of the HiSysEvent query API
| API| Description| | API | Description |
| -------- | -------- | | --- | ----------- |
| int32_t HiSysEventManager::Query(struct QueryArg&amp; arg, std::vector&lt;QueryRule&gt;&amp; rules, std::shared_ptr&lt;HiSysEventQueryCallback&gt; callback) | Queries system events by specifying search criteria such as the time segment, event domain, and event name.<br>Input arguments:<br>- **arg**: event query parameter.<br>- **rules**: rules for event filtering.<br>- **callback**: callback object for event query.<br>Return value:<br>- **0**: Query is successful.<br>- A negative value: Query has failed.| | int32_t HiSysEventManager::Query(struct QueryArg&amp; arg, std::vector&lt;QueryRule&gt;&amp; rules, std::shared_ptr&lt;HiSysEventQueryCallback&gt; callback) | Queries system events by specifying search criteria such as the time segment, event domain, and event name.<br>Input arguments:<br>- **arg**: event query parameter.<br>- **rules**: rules for event filtering.<br>- **callback**: callback object for event query.<br>Return value:<br>- **0**: Query is successful.<br>- A negative value: Query has failed.|
**Table 2** Description of QueryArg **Table 2** Description of QueryArg
| Attribute| Description| | Attribute | Description |
| -------- | -------- | | --------- | ----------- |
| beginTime | Start time, in the **long long int** format.| | beginTime | Start time, in the **long long int** format.|
| endTime | End time, in the **long long int** format.| | endTime | End time, in the **long long int** format.|
| maxEvents | Maximum number of returned events, in the **int** format.| | maxEvents | Maximum number of returned events, in the **int** format.|
**Table 3** Description of QueryRule **Table 3** Description of QueryRule
| API| Description| | API| Description|
| -------- | -------- | | -------- | -------- |
| QueryRule(const std::string&amp; domain, const std::vector&lt;std::string&gt;&amp; eventList) | Constructor used to create a **QueryRule** object.<br>Input arguments:<br>- **domain**: domain to which the event of the **QueryRule** object belongs, in the string format. By default, an empty string indicates that the domain is successfully matched.<br>- **eventList**: event name list, in the **std::vector&lt;std::string&gt;** format. By default, an empty string indicates that the event names on the list are successfully matched.| | QueryRule(const std::string&amp; domain, const std::vector&lt;std::string&gt;&amp; eventList) | Constructor used to create a **QueryRule** object.<br>Input arguments:<br>- **domain**: domain to which the event of the **QueryRule** object belongs, in the string format. By default, an empty string indicates that the domain is successfully matched.<br>- **eventList**: event name list, in the **std::vector&lt;std::string&gt;** format. By default, an empty string indicates that the event names on the list are successfully matched.|
**Table 4** Description of HiSysEventQueryCallback **Table 4** Description of HiSysEventQueryCallback
| API| Description| | API| Description|
| -------- | -------- | | -------- | -------- |
...@@ -60,7 +60,7 @@ HiSysEvent allows you to query system events by specifying search criteria. For ...@@ -60,7 +60,7 @@ HiSysEvent allows you to query system events by specifying search criteria. For
void HiSysEventQueryCallback::OnComplete(int32_t reason, int32_t total) void HiSysEventQueryCallback::OnComplete(int32_t reason, int32_t total)
``` ```
Invoke the query API in the corresponding service logic. Call the query API in the corresponding service logic.
``` ```
HiSysEventManager::Query(struct QueryArg& queryArg, HiSysEventManager::Query(struct QueryArg& queryArg,
...@@ -93,7 +93,7 @@ HiSysEvent allows you to query system events by specifying search criteria. For ...@@ -93,7 +93,7 @@ HiSysEvent allows you to query system events by specifying search criteria. For
} // namespace HiviewDFX } // namespace HiviewDFX
} // namespace OHOS } // namespace OHOS
// Invoke the query callback API to obtain system events. // Call the query callback API to obtain system events.
auto queryCallBack = std::make_shared<HiSysEventToolQuery>(); auto queryCallBack = std::make_shared<HiSysEventToolQuery>();
struct QueryArg args(clientCmdArg.beginTime, clientCmdArg.endTime, clientCmdArg.maxEvents); struct QueryArg args(clientCmdArg.beginTime, clientCmdArg.endTime, clientCmdArg.maxEvents);
std::vector<QueryRule> rules; std::vector<QueryRule> rules;
......
...@@ -286,4 +286,4 @@ The following table describes APIs available for obtaining device location infor ...@@ -286,4 +286,4 @@ The following table describes APIs available for obtaining device location infor
Location subsystem Location subsystem
[base_location](https://gitee.com/openharmony/base_location) [base_location](https://gitee.com/openharmony/base_location/blob/master/README.en.md)
...@@ -6,5 +6,5 @@ The table below lists the APIs changes of the multimodal input subsystem in Open ...@@ -6,5 +6,5 @@ The table below lists the APIs changes of the multimodal input subsystem in Open
| Module| Class| Method/Attribute/Enumeration/Constant| Change Type| | Module| Class| Method/Attribute/Enumeration/Constant| Change Type|
|---|---|---|---| |---|---|---|---|
| ohos.multimodalInput.inputMonitor | inputMonitor | off(type:"mouse", receiver?:Callback\<MouseEvent>):void; | Added| | ohos.multimodalInput.inputMonitor | inputMonitor | off(type: "mouse", receiver?: Callback\<MouseEvent>):void; | Added|
| ohos.multimodalInput.inputMonitor | inputMonitor | on(type:"mouse", receiver:Callback\<MouseEvent>):void; | Added| | ohos.multimodalInput.inputMonitor | inputMonitor | on(type: "mouse", receiver: Callback\<MouseEvent>):void; | Added|
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册