1e41f4b71Sopenharmony_ci# @ohos.driver.deviceManager (Peripheral Management) (System API)
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ciThe **deviceManager** module provides the functions of managing peripheral devices, including querying information about peripherals and their drivers.
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci>  **NOTE**
6e41f4b71Sopenharmony_ci>
7e41f4b71Sopenharmony_ci> The initial APIs of this module are supported since API version 12. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8e41f4b71Sopenharmony_ci> This topic describes only system APIs provided by the module. For details about its public APIs, see [@ohos.driver.deviceManager (Peripheral Management)](js-apis-driver-deviceManager.md).
9e41f4b71Sopenharmony_ci
10e41f4b71Sopenharmony_ci## Modules to Import
11e41f4b71Sopenharmony_ci
12e41f4b71Sopenharmony_ci```ts
13e41f4b71Sopenharmony_ciimport { deviceManager } from '@kit.DriverDevelopmentKit';
14e41f4b71Sopenharmony_ci```
15e41f4b71Sopenharmony_ci
16e41f4b71Sopenharmony_ci## deviceManager.queryDeviceInfo
17e41f4b71Sopenharmony_ci
18e41f4b71Sopenharmony_ciqueryDeviceInfo(deviceId?: number): Array<Readonly<DeviceInfo>>
19e41f4b71Sopenharmony_ci
20e41f4b71Sopenharmony_ciObtains the list of detailed information about peripherals.
21e41f4b71Sopenharmony_ci
22e41f4b71Sopenharmony_ci**System API**: This is a system API.
23e41f4b71Sopenharmony_ci
24e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ACCESS_EXTENSIONAL_DEVICE_DRIVER
25e41f4b71Sopenharmony_ci
26e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Driver.ExternalDevice
27e41f4b71Sopenharmony_ci
28e41f4b71Sopenharmony_ci**Parameters**
29e41f4b71Sopenharmony_ci
30e41f4b71Sopenharmony_ci| Name     | Type    | Mandatory | Description                    |
31e41f4b71Sopenharmony_ci|----------|--------|-----|------------------------|
32e41f4b71Sopenharmony_ci| deviceId | number | No  | Device ID, which can be obtained by **queryDevices**.|
33e41f4b71Sopenharmony_ci
34e41f4b71Sopenharmony_ci**Return value**
35e41f4b71Sopenharmony_ci
36e41f4b71Sopenharmony_ci| Type                                                    | Description         |
37e41f4b71Sopenharmony_ci|--------------------------------------------------------|-------------|
38e41f4b71Sopenharmony_ci| Array<Readonly<[DeviceInfo](#deviceinfo)>> | List of detailed information about peripherals.|
39e41f4b71Sopenharmony_ci
40e41f4b71Sopenharmony_ci**Error codes**
41e41f4b71Sopenharmony_ci
42e41f4b71Sopenharmony_ci| ID   | Error Message                                                                 |
43e41f4b71Sopenharmony_ci|----------|-----------------------------------------------------------------------|
44e41f4b71Sopenharmony_ci| 201      | The permission check failed.                                          |
45e41f4b71Sopenharmony_ci| 202      | Permission denied. A non-system application cannot call a system API. |
46e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1.Incorrect parameter types.        |
47e41f4b71Sopenharmony_ci| 26300001 | ExternalDeviceManager service exception.                              |
48e41f4b71Sopenharmony_ci
49e41f4b71Sopenharmony_ci**Example**
50e41f4b71Sopenharmony_ci
51e41f4b71Sopenharmony_ci```ts
52e41f4b71Sopenharmony_ciimport { deviceManager } from '@kit.DriverDevelopmentKit';
53e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
54e41f4b71Sopenharmony_ci
55e41f4b71Sopenharmony_citry {
56e41f4b71Sopenharmony_ci  // For example, deviceId is 12345678. You can use queryDevices() to obtain the deviceId.
57e41f4b71Sopenharmony_ci  let deviceInfos : Array<deviceManager.DeviceInfo> = deviceManager.queryDeviceInfo(12345678);
58e41f4b71Sopenharmony_ci  for (let item of deviceInfos) {
59e41f4b71Sopenharmony_ci    console.info(`Device id is ${item.deviceId}`)
60e41f4b71Sopenharmony_ci  }
61e41f4b71Sopenharmony_ci} catch (error) {
62e41f4b71Sopenharmony_ci  let err: BusinessError = error as BusinessError;
63e41f4b71Sopenharmony_ci  console.error(`Failed to query device info. Code is ${err.code}, message is ${err.message}`);
64e41f4b71Sopenharmony_ci}
65e41f4b71Sopenharmony_ci```
66e41f4b71Sopenharmony_ci## deviceManager.queryDriverInfo
67e41f4b71Sopenharmony_ci
68e41f4b71Sopenharmony_ciqueryDriverInfo(driverUid?: string): Array&lt;Readonly&lt;DriverInfo&gt;&gt;
69e41f4b71Sopenharmony_ci
70e41f4b71Sopenharmony_ciObtains the list of detailed information about peripheral drivers.
71e41f4b71Sopenharmony_ci
72e41f4b71Sopenharmony_ci**System API**: This is a system API.
73e41f4b71Sopenharmony_ci
74e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ACCESS_EXTENSIONAL_DEVICE_DRIVER
75e41f4b71Sopenharmony_ci
76e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Driver.ExternalDevice
77e41f4b71Sopenharmony_ci
78e41f4b71Sopenharmony_ci**Parameters**
79e41f4b71Sopenharmony_ci
80e41f4b71Sopenharmony_ci| Name      | Type    | Mandatory | Description                        |
81e41f4b71Sopenharmony_ci|-----------|--------|-----|----------------------------|
82e41f4b71Sopenharmony_ci| driverUid | string | No  | Driver UID, which can be obtained by using **queryDeviceInfo**.|
83e41f4b71Sopenharmony_ci
84e41f4b71Sopenharmony_ci**Return value**
85e41f4b71Sopenharmony_ci
86e41f4b71Sopenharmony_ci| Type                                                    | Description           |
87e41f4b71Sopenharmony_ci|--------------------------------------------------------|---------------|
88e41f4b71Sopenharmony_ci| Array&lt;Readonly&lt;[DriverInfo](#driverinfo)&gt;&gt; | List of detailed information about peripheral drivers.|
89e41f4b71Sopenharmony_ci
90e41f4b71Sopenharmony_ci**Error codes**
91e41f4b71Sopenharmony_ci
92e41f4b71Sopenharmony_ci| ID   | Error Message                                                                 |
93e41f4b71Sopenharmony_ci|----------|-----------------------------------------------------------------------|
94e41f4b71Sopenharmony_ci| 201      | The permission check failed.                                          |
95e41f4b71Sopenharmony_ci| 202      | Permission denied. A non-system application cannot call a system API. |
96e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1.Incorrect parameter types.        |
97e41f4b71Sopenharmony_ci| 26300001 | ExternalDeviceManager service exception.                              |
98e41f4b71Sopenharmony_ci
99e41f4b71Sopenharmony_ci**Example**
100e41f4b71Sopenharmony_ci
101e41f4b71Sopenharmony_ci```ts
102e41f4b71Sopenharmony_ciimport { deviceManager } from '@kit.DriverDevelopmentKit';
103e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
104e41f4b71Sopenharmony_ci
105e41f4b71Sopenharmony_citry {
106e41f4b71Sopenharmony_ci  // In this example, driver-12345 is the driver UID. During application development, you can use queryDeviceInfo to query the driver UID and use it as the input parameter.
107e41f4b71Sopenharmony_ci  let driverInfos : Array<deviceManager.DriverInfo> = deviceManager.queryDriverInfo("driver-12345");
108e41f4b71Sopenharmony_ci  for (let item of driverInfos) {
109e41f4b71Sopenharmony_ci    console.info(`driver name is ${item.driverName}`)
110e41f4b71Sopenharmony_ci  }
111e41f4b71Sopenharmony_ci} catch (error) {
112e41f4b71Sopenharmony_ci  let err: BusinessError = error as BusinessError;
113e41f4b71Sopenharmony_ci  console.error(`Failed to query driver info. Code is ${err.code}, message is ${err.message}`);
114e41f4b71Sopenharmony_ci}
115e41f4b71Sopenharmony_ci```
116e41f4b71Sopenharmony_ci
117e41f4b71Sopenharmony_ci## DeviceInfo
118e41f4b71Sopenharmony_ci
119e41f4b71Sopenharmony_ciDefines the detailed information about a device.
120e41f4b71Sopenharmony_ci
121e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Driver.ExternalDevice
122e41f4b71Sopenharmony_ci
123e41f4b71Sopenharmony_ci| Name             | Type     | Mandatory | Description         |
124e41f4b71Sopenharmony_ci|-----------------|---------|-----|-------------|
125e41f4b71Sopenharmony_ci| deviceId        | number  | Yes  | Device ID.      |
126e41f4b71Sopenharmony_ci| isDriverMatched | boolean | Yes  | Whether the device matches the driver. |
127e41f4b71Sopenharmony_ci| driverUid       | string  | No  | UID of the driver matching the device.|
128e41f4b71Sopenharmony_ci
129e41f4b71Sopenharmony_ci## USBDeviceInfo
130e41f4b71Sopenharmony_ci
131e41f4b71Sopenharmony_ciDefines detailed information about the USB device. It is inherited from [DeviceInfo](#deviceinfo).
132e41f4b71Sopenharmony_ci
133e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Driver.ExternalDevice
134e41f4b71Sopenharmony_ci
135e41f4b71Sopenharmony_ci| Name               | Type                                                                | Mandatory | Description              |
136e41f4b71Sopenharmony_ci|-------------------|--------------------------------------------------------------------|-----|------------------|
137e41f4b71Sopenharmony_ci| vendorId          | number                                                             | Yes  | Vendor ID of the USB device. |
138e41f4b71Sopenharmony_ci| productId         | number                                                             | Yes  | Product ID of the USB device.|
139e41f4b71Sopenharmony_ci| interfaceDescList | Array&lt;Readonly&lt;[USBInterfaceDesc](#usbinterfacedesc)&gt;&gt; | Yes  | List of interface descriptors of the USB device.   |
140e41f4b71Sopenharmony_ci
141e41f4b71Sopenharmony_ci## USBInterfaceDesc
142e41f4b71Sopenharmony_ci
143e41f4b71Sopenharmony_ciDefines the interface descriptor of a USB device.
144e41f4b71Sopenharmony_ci
145e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Driver.ExternalDevice
146e41f4b71Sopenharmony_ci
147e41f4b71Sopenharmony_ci| Name              | Type    | Mandatory | Description    |
148e41f4b71Sopenharmony_ci|------------------|--------|-----|--------|
149e41f4b71Sopenharmony_ci| bInterfaceNumber | number | Yes  | Interface ID. |
150e41f4b71Sopenharmony_ci| bClass           | number | Yes  | Interface class. |
151e41f4b71Sopenharmony_ci| bSubClass        | number | Yes  | Interface subclass.|
152e41f4b71Sopenharmony_ci| bProtocol        | number | Yes  | Interface protocol. |
153e41f4b71Sopenharmony_ci
154e41f4b71Sopenharmony_ci## DriverInfo
155e41f4b71Sopenharmony_ci
156e41f4b71Sopenharmony_ciDefines detailed information about a driver.
157e41f4b71Sopenharmony_ci
158e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Driver.ExternalDevice
159e41f4b71Sopenharmony_ci
160e41f4b71Sopenharmony_ci| Name           | Type                                                | Mandatory | Description            |
161e41f4b71Sopenharmony_ci|---------------|----------------------------------------------------|-----|----------------|
162e41f4b71Sopenharmony_ci| busType       | [BusType](js-apis-driver-deviceManager.md#bustype) | Yes  | Bus type.         |
163e41f4b71Sopenharmony_ci| driverUid     | string                                             | Yes  | Driver UID.        |
164e41f4b71Sopenharmony_ci| driverName    | string                                             | Yes  | Driver name.         |
165e41f4b71Sopenharmony_ci| driverVersion | string                                             | Yes  | Driver version.         |
166e41f4b71Sopenharmony_ci| driverSize    | string                                             | Yes  | Driver size, in bytes.|
167e41f4b71Sopenharmony_ci| description   | string                                             | Yes  | Driver description.         |
168e41f4b71Sopenharmony_ci
169e41f4b71Sopenharmony_ci## USBDriverInfo
170e41f4b71Sopenharmony_ci
171e41f4b71Sopenharmony_ciDefines detailed information about the USB device driver. It is inherited from [DriverInfo](#driverinfo).
172e41f4b71Sopenharmony_ci
173e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Driver.ExternalDevice
174e41f4b71Sopenharmony_ci
175e41f4b71Sopenharmony_ci| Name           | Type                 | Mandatory | Description                     |
176e41f4b71Sopenharmony_ci|---------------|---------------------|-----|-------------------------|
177e41f4b71Sopenharmony_ci| productIdList | Array&lt;number&gt; | Yes  | Product ID list of the USB devices supported by the driver.|
178e41f4b71Sopenharmony_ci| vendorIdList  | Array&lt;number&gt; | Yes  | Vendor ID list of the USB devices supported by the driver. |
179