• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023-2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/**
17 * @file
18 * @kit BasicServicesKit
19 */
20
21import { AsyncCallback } from './@ohos.base';
22
23/**
24 * This module provides the capability of manage USB device.
25 *
26 * @namespace usbManager
27 * @syscap SystemCapability.USB.USBManager
28 * @since 9
29 */
30declare namespace usbManager {
31  /**
32   * Obtains the USB device list.
33   *
34   * @returns { Array<Readonly<USBDevice>> } USB device list.
35   * @syscap SystemCapability.USB.USBManager
36   * @since 9
37   */
38  /**
39   * Obtains the USB device list.
40   *
41   * @returns { Array<Readonly<USBDevice>> } USB device list.
42   * @throws { BusinessError } 801 - Capability not supported.
43   * @syscap SystemCapability.USB.USBManager
44   * @since 18
45   */
46  function getDevices(): Array<Readonly<USBDevice>>;
47
48  /**
49   * Connects to the USB device based on the device information returned by getDevices().
50   *
51   * @param { USBDevice } device - USB device on the device list returned by getDevices(). It cannot be empty.
52   * @returns { Readonly<USBDevicePipe> } object for data transfer.
53   * @throws { BusinessError } 401 - Parameter error. Possible causes:
54   * <br>1.Mandatory parameters are left unspecified.
55   * <br>2.Incorrect parameter types.
56   * @throws { BusinessError } 14400001 - Access right denied. Call requestRight to get the USBDevicePipe access right first.
57   * @syscap SystemCapability.USB.USBManager
58   * @since 9
59   */
60  /**
61   * Connects to the USB device based on the device information returned by getDevices().
62   *
63   * @param { USBDevice } device - USB device on the device list returned by getDevices(). It cannot be empty.
64   * @returns { Readonly<USBDevicePipe> } object for data transfer.
65   * @throws { BusinessError } 401 - Parameter error. Possible causes:
66   * <br>1.Mandatory parameters are left unspecified.
67   * <br>2.Incorrect parameter types.
68   * @throws { BusinessError } 801 - Capability not supported.
69   * @throws { BusinessError } 14400001 - Access right denied. Call requestRight to get the USBDevicePipe access right first.
70   * @syscap SystemCapability.USB.USBManager
71   * @since 18
72   */
73  function connectDevice(device: USBDevice): Readonly<USBDevicePipe>;
74
75  /**
76   * Checks whether the application has the permission to access the device.
77   *
78   * @param { string } deviceName - device name defined by USBDevice.name. It cannot be empty.
79   * @returns { boolean } indicates if the user has the permission to access the device.
80   * @throws { BusinessError } 401 - Parameter error. Possible causes:
81   * <br>1.Mandatory parameters are left unspecified.
82   * <br>2.Incorrect parameter types.
83   * @syscap SystemCapability.USB.USBManager
84   * @since 9
85   */
86  /**
87   * Checks whether the application has the permission to access the device.
88   *
89   * @param { string } deviceName - device name defined by USBDevice.name. It cannot be empty.
90   * @returns { boolean } indicates if the user has the permission to access the device.
91   * @throws { BusinessError } 401 - Parameter error. Possible causes:
92   * <br>1.Mandatory parameters are left unspecified.
93   * <br>2.Incorrect parameter types.
94   * @throws { BusinessError } 801 - Capability not supported.
95   * @syscap SystemCapability.USB.USBManager
96   * @since 18
97   */
98  function hasRight(deviceName: string): boolean;
99
100  /**
101   * Requests the permission for a given application to access the USB device.
102   * The system application has access to the device by default, and there is no need to call this interface to apply.
103   *
104   * @param { string } deviceName - device name defined by USBDevice.name. It cannot be empty.
105   * @returns { Promise<boolean> } indicates if the device access permissions are granted.
106   * @throws { BusinessError } 401 - Parameter error. Possible causes:
107   * <br>1.Mandatory parameters are left unspecified.
108   * <br>2.Incorrect parameter types.
109   * @syscap SystemCapability.USB.USBManager
110   * @since 9
111   */
112  /**
113   * Requests the permission for a given application to access the USB device.
114   * The system application has access to the device by default, and there is no need to call this interface to apply.
115   *
116   * @param { string } deviceName - device name defined by USBDevice.name. It cannot be empty.
117   * @returns { Promise<boolean> } indicates if the device access permissions are granted.
118   * @throws { BusinessError } 401 - Parameter error. Possible causes:
119   * <br>1.Mandatory parameters are left unspecified.
120   * <br>2.Incorrect parameter types.
121   * @throws { BusinessError } 801 - Capability not supported.
122   * @syscap SystemCapability.USB.USBManager
123   * @since 18
124   */
125  function requestRight(deviceName: string): Promise<boolean>;
126
127  /**
128   * Remove the permission for a given application to access the USB device.
129   * The system application has access to the device by default, and calling this interface will not have any impact.
130   *
131   * @param { string } deviceName - device name defined by USBDevice.name. It cannot be empty.
132   * @returns { boolean } indicates if the device access permissions are removed.
133   * @throws { BusinessError } 401 - Parameter error. Possible causes:
134   * <br>1.Mandatory parameters are left unspecified.
135   * <br>2.Incorrect parameter types.
136   * @syscap SystemCapability.USB.USBManager
137   * @since 9
138   */
139  /**
140   * Remove the permission for a given application to access the USB device.
141   * The system application has access to the device by default, and calling this interface will not have any impact.
142   *
143   * @param { string } deviceName - device name defined by USBDevice.name. It cannot be empty.
144   * @returns { boolean } indicates if the device access permissions are removed.
145   * @throws { BusinessError } 401 - Parameter error. Possible causes:
146   * <br>1.Mandatory parameters are left unspecified.
147   * <br>2.Incorrect parameter types.
148   * @throws { BusinessError } 801 - Capability not supported.
149   * @syscap SystemCapability.USB.USBManager
150   * @since 18
151   */
152  function removeRight(deviceName: string): boolean;
153
154  /**
155   * Add device access permission.
156   * The system application has access to the device by default, and calling this interface will not have any impact.
157   *
158   * @param { string } bundleName - refers to application that require access permissions. It cannot be empty.
159   * @param { string } deviceName - device name defined by USBDevice.name. It cannot be empty.
160   * @returns { boolean } value to indicate whether the permission is granted.
161   * @throws { BusinessError } 401 - Parameter error. Possible causes:
162   * <br>1.Mandatory parameters are left unspecified.
163   * <br>2.Incorrect parameter types.
164   * @syscap SystemCapability.USB.USBManager
165   * @systemapi
166   * @since 9
167   * @deprecated since 12
168   * @useinstead ohos.usbManager/usbManager#addDeviceAccessRight
169   */
170  function addRight(bundleName: string, deviceName: string): boolean;
171
172  /**
173   * Converts the string descriptor of a given USB function list to a numeric mask combination.
174   *
175   * @param { string } funcs - descriptor of the supported function list. It cannot be empty.
176   * @returns { number } the numeric mask combination of the function list.
177   * @throws { BusinessError } 401 - Parameter error. Possible causes:
178   * <br>1.Mandatory parameters are left unspecified.
179   * <br>2.Incorrect parameter types.
180   * @syscap SystemCapability.USB.USBManager
181   * @systemapi
182   * @since 9
183   * @deprecated since 12
184   * @useinstead ohos.usbManager/usbManager#getFunctionsFromString
185   */
186  function usbFunctionsFromString(funcs: string): number;
187
188  /**
189   * Converts the numeric mask combination of a given USB function list to a string descriptor.
190   *
191   * @param { FunctionType } funcs - numeric mask combination of the function list. The type of funcs must be number. It cannot be empty.
192   * @returns { string } - descriptor of the supported function list.
193   * @throws { BusinessError } 401 - Parameter error. Possible causes:
194   * <br>1.Mandatory parameters are left unspecified.
195   * <br>2.Incorrect parameter types.
196   * @syscap SystemCapability.USB.USBManager
197   * @systemapi
198   * @since 9
199   * @deprecated since 12
200   * @useinstead ohos.usbManager/usbManager#getStringFromFunctions
201   */
202  function usbFunctionsToString(funcs: FunctionType): string;
203
204  /**
205   * Sets the current USB function list in Device mode.
206   *
207   * @param { FunctionType } funcs - numeric mask combination of the supported function list. It cannot be empty.
208   * @returns { Promise<void> } the promise returned by the function.
209   * @throws { BusinessError } 401 - Parameter error. Possible causes:
210   * <br>1.Mandatory parameters are left unspecified.
211   * <br>2.Incorrect parameter types.
212   * @throws { BusinessError } 14400002 - Permission denied. The HDC is disabled by the system.
213   * @syscap SystemCapability.USB.USBManager
214   * @systemapi
215   * @since 9
216   * @deprecated since 12
217   * @useinstead ohos.usbManager/usbManager#setDeviceFunctions
218   */
219  function setCurrentFunctions(funcs: FunctionType): Promise<void>;
220
221  /**
222   * Obtains the numeric mask combination for the current USB function list in Device mode.
223   *
224   * @returns { FunctionType } the numeric mask combination for the current USB function list in FunctionType.
225   * @syscap SystemCapability.USB.USBManager
226   * @systemapi
227   * @since 9
228   * @deprecated since 12
229   * @useinstead ohos.usbManager/usbManager#getDeviceFunctions
230   */
231  function getCurrentFunctions(): FunctionType;
232
233  /* usb port functions begin */
234  /**
235   * Obtains the USBPort list.
236   *
237   * @returns { Array<USBPort> } the USBPort list.
238   * @syscap SystemCapability.USB.USBManager
239   * @systemapi
240   * @since 9
241   * @deprecated since 12
242   * @useinstead ohos.usbManager/usbManager#getPortList
243   */
244  function getPorts(): Array<USBPort>;
245
246  /**
247   * Gets the mask combination for the supported mode list of the specified USBPort.
248   *
249   * @param { number } portId - unique ID of the port. It cannot be empty.
250   * @returns { PortModeType } the mask combination for the supported mode list in PortModeType.
251   * @throws { BusinessError } 401 - Parameter error. Possible causes:
252   * <br>1.Mandatory parameters are left unspecified.
253   * <br>2.Incorrect parameter types.
254   * @syscap SystemCapability.USB.USBManager
255   * @systemapi
256   * @since 9
257   * @deprecated since 12
258   * @useinstead ohos.usbManager/usbManager#getPortSupportModes
259   */
260  function getSupportedModes(portId: number): PortModeType;
261
262  /**
263   * Sets the role types supported by the specified USBPort, which can be powerRole (for charging) and dataRole (for data transfer).
264   *
265   * @param { number } portId - unique ID of the port. It cannot be empty.
266   * @param { PowerRoleType } powerRole - charging role. It cannot be empty.
267   * @param { DataRoleType } dataRole - data role. It cannot be empty.
268   * @returns { Promise<void> } the promise returned by the function.
269   * @throws { BusinessError } 401 - Parameter error. Possible causes:
270   * <br>1.Mandatory parameters are left unspecified.
271   * <br>2.Incorrect parameter types.
272   * @syscap SystemCapability.USB.USBManager
273   * @systemapi
274   * @since 9
275   * @deprecated since 12
276   * @useinstead ohos.usbManager/usbManager#setPortRoleTypes
277   */
278  function setPortRoles(portId: number, powerRole: PowerRoleType, dataRole: DataRoleType): Promise<void>;
279
280  /**
281   * Add USB device access right.
282   * The system application has access to the device by default, and calling this interface will not have any impact.
283   *
284   * @permission ohos.permission.MANAGE_USB_CONFIG
285   * @param { string } tokenId - refers to application that require access permissions. It cannot be empty.
286   * @param { string } deviceName - device name defined by USBDevice.name. It cannot be empty.
287   * @returns { boolean } value to indicate whether the permission is granted.
288   * @throws { BusinessError } 401 - Parameter error. Possible causes:
289   * <br>1.Mandatory parameters are left unspecified.
290   * <br>2.Incorrect parameter types.
291   * @throws { BusinessError } 202 - Permission denied. Normal application do not have permission to use system api.
292   * @syscap SystemCapability.USB.USBManager
293   * @systemapi
294   * @since 12
295   */
296  /**
297   * Add USB device access right.
298   * The system application has access to the device by default, and calling this interface will not have any impact.
299   *
300   * @permission ohos.permission.MANAGE_USB_CONFIG
301   * @param { string } tokenId - refers to application that require access permissions. It cannot be empty.
302   * @param { string } deviceName - device name defined by USBDevice.name. It cannot be empty.
303   * @returns { boolean } value to indicate whether the permission is granted.
304   * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
305   * @throws { BusinessError } 202 - Permission denied. Normal application do not have permission to use system api.
306   * @throws { BusinessError } 401 - Parameter error. Possible causes:
307   * <br>1.Mandatory parameters are left unspecified.
308   * <br>2.Incorrect parameter types.
309   * @throws { BusinessError } 801 - Capability not supported.
310   * @syscap SystemCapability.USB.USBManager
311   * @systemapi
312   * @since 18
313   */
314  function addDeviceAccessRight(tokenId: string, deviceName: string): boolean;
315
316  /**
317   * Converts the string descriptor of a given USB function list to a numeric mask combination.
318   *
319   * @permission ohos.permission.MANAGE_USB_CONFIG
320   * @param { string } funcs - descriptor of the supported function list. It cannot be empty.
321   * @returns { number } the numeric mask combination of the function list.
322   * @throws { BusinessError } 401 - Parameter error. Possible causes:
323   * <br>1.Mandatory parameters are left unspecified.
324   * <br>2.Incorrect parameter types.
325   * @throws { BusinessError } 202 - Permission denied. Normal application do not have permission to use system api.
326   * @syscap SystemCapability.USB.USBManager
327   * @systemapi
328   * @since 12
329   */
330  /**
331   * Converts the string descriptor of a given USB function list to a numeric mask combination.
332   *
333   * @permission ohos.permission.MANAGE_USB_CONFIG
334   * @param { string } funcs - descriptor of the supported function list. It cannot be empty.
335   * @returns { number } the numeric mask combination of the function list.
336   * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
337   * @throws { BusinessError } 202 - Permission denied. Normal application do not have permission to use system api.
338   * @throws { BusinessError } 401 - Parameter error. Possible causes:
339   * <br>1.Mandatory parameters are left unspecified.
340   * <br>2.Incorrect parameter types.
341   * @throws { BusinessError } 801 - Capability not supported.
342   * @syscap SystemCapability.USB.USBManager
343   * @systemapi
344   * @since 18
345   */
346  function getFunctionsFromString(funcs: string): number;
347
348  /**
349   * Converts the numeric mask combination of a given USB function list to a string descriptor.
350   *
351   * @permission ohos.permission.MANAGE_USB_CONFIG
352   * @param { FunctionType } funcs - numeric mask combination of the function list. It cannot be empty.
353   * @returns { string } - descriptor of the supported function list.
354   * @throws { BusinessError } 401 - Parameter error. Possible causes:
355   * <br>1.Mandatory parameters are left unspecified.
356   * <br>2.Incorrect parameter types.
357   * @throws { BusinessError } 202 - Permission denied. Normal application do not have permission to use system api.
358   * @syscap SystemCapability.USB.USBManager
359   * @systemapi
360   * @since 12
361   */
362  /**
363   * Converts the numeric mask combination of a given USB function list to a string descriptor.
364   *
365   * @permission ohos.permission.MANAGE_USB_CONFIG
366   * @param { FunctionType } funcs - numeric mask combination of the function list. It cannot be empty.
367   * @returns { string } - descriptor of the supported function list.
368   * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
369   * @throws { BusinessError } 202 - Permission denied. Normal application do not have permission to use system api.
370   * @throws { BusinessError } 401 - Parameter error. Possible causes:
371   * <br>1.Mandatory parameters are left unspecified.
372   * <br>2.Incorrect parameter types.
373   * @throws { BusinessError } 801 - Capability not supported.
374   * @syscap SystemCapability.USB.USBManager
375   * @systemapi
376   * @since 18
377   */
378  function getStringFromFunctions(funcs: FunctionType): string;
379
380  /**
381   * Sets the current USB function list in Device mode.
382   *
383   * @permission ohos.permission.MANAGE_USB_CONFIG
384   * @param { FunctionType } funcs - numeric mask combination of the supported function list. It cannot be empty.
385   * @returns { Promise<void> } the promise returned by the function.
386   * @throws { BusinessError } 401 - Parameter error. Possible causes:
387   * <br>1.Mandatory parameters are left unspecified.
388   * <br>2.Incorrect parameter types.
389   * @throws { BusinessError } 202 - Permission denied. Normal application do not have permission to use system api.
390   * @throws { BusinessError } 14400002 - Permission denied. The HDC is disabled by the system.
391   * @throws { BusinessError } 14400006 - Unsupported operation. The function is not supported.
392   * @syscap SystemCapability.USB.USBManager
393   * @systemapi
394   * @since 12
395   */
396  /**
397   * Sets the current USB function list in Device mode.
398   *
399   * @permission ohos.permission.MANAGE_USB_CONFIG
400   * @param { FunctionType } funcs - numeric mask combination of the supported function list. It cannot be empty.
401   * @returns { Promise<void> } the promise returned by the function.
402   * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
403   * @throws { BusinessError } 202 - Permission denied. Normal application do not have permission to use system api.
404   * @throws { BusinessError } 401 - Parameter error. Possible causes:
405   * <br>1.Mandatory parameters are left unspecified.
406   * <br>2.Incorrect parameter types.
407   * @throws { BusinessError } 801 - Capability not supported.
408   * @throws { BusinessError } 14400002 - Permission denied. The HDC is disabled by the system.
409   * @throws { BusinessError } 14400006 - Unsupported operation. The function is not supported.
410   * @syscap SystemCapability.USB.USBManager
411   * @systemapi
412   * @since 18
413   */
414  function setDeviceFunctions(funcs: FunctionType): Promise<void>;
415
416  /**
417   * Obtains the numeric mask combination for the current USB function list in Device mode.
418   *
419   * @permission ohos.permission.MANAGE_USB_CONFIG
420   * @returns { FunctionType } the numeric mask combination for the current USB function list in FunctionType.
421   * @throws { BusinessError } 202 - Permission denied. Normal application do not have permission to use system api.
422   * @syscap SystemCapability.USB.USBManager
423   * @systemapi
424   * @since 12
425   */
426  /**
427   * Obtains the numeric mask combination for the current USB function list in Device mode.
428   *
429   * @permission ohos.permission.MANAGE_USB_CONFIG
430   * @returns { FunctionType } the numeric mask combination for the current USB function list in FunctionType.
431   * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
432   * @throws { BusinessError } 202 - Permission denied. Normal application do not have permission to use system api.
433   * @throws { BusinessError } 801 - Capability not supported.
434   * @syscap SystemCapability.USB.USBManager
435   * @systemapi
436   * @since 18
437   */
438  function getDeviceFunctions(): FunctionType;
439
440  /* usb port functions begin */
441  /**
442   * Obtains the USBPort list.
443   *
444   * @permission ohos.permission.MANAGE_USB_CONFIG
445   * @returns { Array<USBPort> } the USBPort list.
446   * @throws { BusinessError } 202 - Permission denied. Normal application do not have permission to use system api.
447   * @syscap SystemCapability.USB.USBManager
448   * @systemapi
449   * @since 12
450   */
451  /* usb port functions begin */
452  /**
453   * Obtains the USBPort list.
454   *
455   * @permission ohos.permission.MANAGE_USB_CONFIG
456   * @returns { Array<USBPort> } the USBPort list.
457   * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
458   * @throws { BusinessError } 202 - Permission denied. Normal application do not have permission to use system api.
459   * @throws { BusinessError } 801 - Capability not supported.
460   * @syscap SystemCapability.USB.USBManager
461   * @systemapi
462   * @since 18
463   */
464  function getPortList(): Array<USBPort>;
465
466  /**
467   * Gets the mask combination for the supported mode list of the specified USBPort.
468   *
469   * @permission ohos.permission.MANAGE_USB_CONFIG
470   * @param { number } portId - unique ID of the port. It cannot be empty.
471   * @returns { PortModeType } the mask combination for the supported mode list in PortModeType.
472   * @throws { BusinessError } 401 - Parameter error. Possible causes:
473   * <br>1.Mandatory parameters are left unspecified.
474   * <br>2.Incorrect parameter types.
475   * @throws { BusinessError } 202 - Permission denied. Normal application do not have permission to use system api.
476   * @syscap SystemCapability.USB.USBManager
477   * @systemapi
478   * @since 12
479   */
480  /**
481   * Gets the mask combination for the supported mode list of the specified USBPort.
482   *
483   * @permission ohos.permission.MANAGE_USB_CONFIG
484   * @param { number } portId - unique ID of the port. It cannot be empty.
485   * @returns { PortModeType } the mask combination for the supported mode list in PortModeType.
486   * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
487   * @throws { BusinessError } 202 - Permission denied. Normal application do not have permission to use system api.
488   * @throws { BusinessError } 401 - Parameter error. Possible causes:
489   * <br>1.Mandatory parameters are left unspecified.
490   * <br>2.Incorrect parameter types.
491   * @throws { BusinessError } 801 - Capability not supported.
492   * @syscap SystemCapability.USB.USBManager
493   * @systemapi
494   * @since 18
495   */
496  function getPortSupportModes(portId: number): PortModeType;
497
498  /**
499   * Sets the role types supported by the specified USBPort, which can be powerRole (for charging) and dataRole (for data transfer).
500   *
501   * @permission ohos.permission.MANAGE_USB_CONFIG
502   * @param { number } portId - unique ID of the port. It cannot be empty.
503   * @param { PowerRoleType } powerRole - charging role. It cannot be empty.
504   * @param { DataRoleType } dataRole - data role. It cannot be empty.
505   * @returns { Promise<void> } the promise returned by the function.
506   * @throws { BusinessError } 401 - Parameter error. Possible causes:
507   * <br>1.Mandatory parameters are left unspecified.
508   * <br>2.Incorrect parameter types.
509   * @throws { BusinessError } 202 - Permission denied. Normal application do not have permission to use system api.
510   * @throws { BusinessError } 14400003 - Unsupported operation. The current device does not support port role switching.
511   * @syscap SystemCapability.USB.USBManager
512   * @systemapi
513   * @since 12
514   */
515  /**
516   * Sets the role types supported by the specified USBPort, which can be powerRole (for charging) and dataRole (for data transfer).
517   *
518   * @permission ohos.permission.MANAGE_USB_CONFIG
519   * @param { number } portId - unique ID of the port. It cannot be empty.
520   * @param { PowerRoleType } powerRole - charging role. It cannot be empty.
521   * @param { DataRoleType } dataRole - data role. It cannot be empty.
522   * @returns { Promise<void> } the promise returned by the function.
523   * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
524   * @throws { BusinessError } 202 - Permission denied. Normal application do not have permission to use system api.
525   * @throws { BusinessError } 401 - Parameter error. Possible causes:
526   * <br>1.Mandatory parameters are left unspecified.
527   * <br>2.Incorrect parameter types.
528   * @throws { BusinessError } 801 - Capability not supported.
529   * @throws { BusinessError } 14400003 - Unsupported operation. The current device does not support port role switching.
530   * @syscap SystemCapability.USB.USBManager
531   * @systemapi
532   * @since 18
533   */
534  function setPortRoleTypes(portId: number, powerRole: PowerRoleType, dataRole: DataRoleType): Promise<void>;
535
536  /**
537   * Adds USB accessory access right.
538   *
539   * @permission ohos.permission.MANAGE_USB_CONFIG
540   * @param { number } tokenId - refers to application that require access permissions. It cannot be empty.
541   * @param { USBAccessory } accessory - USB accessory. It cannot be empty.
542   * @throws { BusinessError } 201 - The permission check failed.
543   * @throws { BusinessError } 202 - Permission denied. Normal application do not have permission to use system api.
544   * @throws { BusinessError } 401 - Parameter error. Possible causes:
545   * <br>1. Mandatory parameters are left unspecified.
546   * <br>2. Incorrect parameter types.
547   * @throws { BusinessError } 14400004 - Service exception. Possible causes:
548   * <br>1. No accessory is plugged in.
549   * @throws { BusinessError } 14400005 - Database operation exception.
550   * @syscap SystemCapability.USB.USBManager
551   * @systemapi
552   * @since 14
553   */
554  /**
555   * Adds USB accessory access right.
556   *
557   * @permission ohos.permission.MANAGE_USB_CONFIG
558   * @param { number } tokenId - refers to application that require access permissions. It cannot be empty.
559   * @param { USBAccessory } accessory - USB accessory. It cannot be empty.
560   * @throws { BusinessError } 201 - The permission check failed.
561   * @throws { BusinessError } 202 - Permission denied. Normal application do not have permission to use system api.
562   * @throws { BusinessError } 401 - Parameter error. Possible causes:
563   * <br>1. Mandatory parameters are left unspecified.
564   * <br>2. Incorrect parameter types.
565   * @throws { BusinessError } 801 - Capability not supported.
566   * @throws { BusinessError } 14400004 - Service exception. Possible causes:
567   * <br>1. No accessory is plugged in.
568   * @throws { BusinessError } 14400005 - Database operation exception.
569   * @syscap SystemCapability.USB.USBManager
570   * @systemapi
571   * @since 18
572   */
573  function addAccessoryRight(tokenId: number, accessory: USBAccessory): void;
574
575  /* usb pipe functions begin */
576  /**
577   * Claims a USB interface.
578   *
579   * @param { USBDevicePipe } pipe - device pipe, which is used to determine the bus number and device address. It cannot be empty.
580   * @param { USBInterface } iface - USB interface, which is used to determine the interface to claim. It cannot be empty.
581   * @param { boolean } [force] - optional parameter that determines whether to forcibly claim the USB interface.
582   * @returns { number } returns **0** if the USB interface is successfully claimed; returns an error code otherwise.
583   * @throws { BusinessError } 401 - Parameter error. Possible causes:
584   * <br>1.Mandatory parameters are left unspecified.
585   * <br>2.Incorrect parameter types.
586   * @syscap SystemCapability.USB.USBManager
587   * @since 9
588   */
589  /**
590   * Claims a USB interface.
591   *
592   * @param { USBDevicePipe } pipe - device pipe, which is used to determine the bus number and device address. It cannot be empty.
593   * @param { USBInterface } iface - USB interface, which is used to determine the interface to claim. It cannot be empty.
594   * @param { boolean } [force] - optional parameter that determines whether to forcibly claim the USB interface.
595   * @returns { number } returns **0** if the USB interface is successfully claimed; returns an error code otherwise.
596   * @throws { BusinessError } 401 - Parameter error. Possible causes:
597   * <br>1.Mandatory parameters are left unspecified.
598   * <br>2.Incorrect parameter types.
599   * @throws { BusinessError } 801 - Capability not supported.
600   * @syscap SystemCapability.USB.USBManager
601   * @since 18
602   */
603  function claimInterface(pipe: USBDevicePipe, iface: USBInterface, force?: boolean): number;
604
605  /**
606   * Releases a USB interface.
607   *
608   * @param { USBDevicePipe } pipe - device pipe, which is used to determine the bus number and device address. It cannot be empty.
609   * @param { USBInterface } iface - USB interface, which is used to determine the interface to release. It cannot be empty.
610   * @returns { number } returns **0** if the USB interface is successfully released; returns an error code otherwise.
611   * @throws { BusinessError } 401 - Parameter error. Possible causes:
612   * <br>1.Mandatory parameters are left unspecified.
613   * <br>2.Incorrect parameter types.
614   * @syscap SystemCapability.USB.USBManager
615   * @since 9
616   */
617  /**
618   * Releases a USB interface.
619   *
620   * @param { USBDevicePipe } pipe - device pipe, which is used to determine the bus number and device address. It cannot be empty.
621   * @param { USBInterface } iface - USB interface, which is used to determine the interface to release. It cannot be empty.
622   * @returns { number } returns **0** if the USB interface is successfully released; returns an error code otherwise.
623   * @throws { BusinessError } 401 - Parameter error. Possible causes:
624   * <br>1.Mandatory parameters are left unspecified.
625   * <br>2.Incorrect parameter types.
626   * @throws { BusinessError } 801 - Capability not supported.
627   * @syscap SystemCapability.USB.USBManager
628   * @since 18
629   */
630  function releaseInterface(pipe: USBDevicePipe, iface: USBInterface): number;
631
632  /**
633   * Sets the device configuration.
634   *
635   * @param { USBDevicePipe } pipe - device pipe, which is used to determine the bus number and device address. It cannot be empty.
636   * @param { USBConfiguration } config - device configuration. It cannot be empty.
637   * @returns { number } returns **0** if the device configuration is successfully set; returns an error code otherwise.
638   * @throws { BusinessError } 401 - Parameter error. Possible causes:
639   * <br>1.Mandatory parameters are left unspecified.
640   * <br>2.Incorrect parameter types.
641   * @syscap SystemCapability.USB.USBManager
642   * @since 9
643   */
644  /**
645   * Sets the device configuration.
646   *
647   * @param { USBDevicePipe } pipe - device pipe, which is used to determine the bus number and device address. It cannot be empty.
648   * @param { USBConfiguration } config - device configuration. It cannot be empty.
649   * @returns { number } returns **0** if the device configuration is successfully set; returns an error code otherwise.
650   * @throws { BusinessError } 401 - Parameter error. Possible causes:
651   * <br>1.Mandatory parameters are left unspecified.
652   * <br>2.Incorrect parameter types.
653   * @throws { BusinessError } 801 - Capability not supported.
654   * @syscap SystemCapability.USB.USBManager
655   * @since 18
656   */
657  function setConfiguration(pipe: USBDevicePipe, config: USBConfiguration): number;
658
659  /**
660   * Sets a USB interface.
661   *
662   * @param { USBDevicePipe } pipe - device pipe, which is used to determine the bus number and device address. It cannot be empty.
663   * @param { USBInterface } iface - USB interface, which is used to determine the interface to set. It cannot be empty.
664   * @returns { number } returns **0** if the USB interface is successfully set; return an error code otherwise.
665   * @throws { BusinessError } 401 - Parameter error. Possible causes:
666   * <br>1.Mandatory parameters are left unspecified.
667   * <br>2.Incorrect parameter types.
668   * @syscap SystemCapability.USB.USBManager
669   * @since 9
670   */
671  /**
672   * Sets a USB interface.
673   *
674   * @param { USBDevicePipe } pipe - device pipe, which is used to determine the bus number and device address. It cannot be empty.
675   * @param { USBInterface } iface - USB interface, which is used to determine the interface to set. It cannot be empty.
676   * @returns { number } returns **0** if the USB interface is successfully set; return an error code otherwise.
677   * @throws { BusinessError } 401 - Parameter error. Possible causes:
678   * <br>1.Mandatory parameters are left unspecified.
679   * <br>2.Incorrect parameter types.
680   * @throws { BusinessError } 801 - Capability not supported.
681   * @syscap SystemCapability.USB.USBManager
682   * @since 18
683   */
684  function setInterface(pipe: USBDevicePipe, iface: USBInterface): number;
685
686  /**
687   * Obtains the raw USB descriptor.
688   *
689   * @param { USBDevicePipe } pipe - device pipe, which is used to determine the bus number and device address. It cannot be empty.
690   * @returns { Uint8Array } returns the raw descriptor data.
691   * @throws { BusinessError } 401 - Parameter error. Possible causes:
692   * <br>1.Mandatory parameters are left unspecified.
693   * <br>2.Incorrect parameter types.
694   * @syscap SystemCapability.USB.USBManager
695   * @since 9
696   */
697  /**
698   * Obtains the raw USB descriptor.
699   *
700   * @param { USBDevicePipe } pipe - device pipe, which is used to determine the bus number and device address. It cannot be empty.
701   * @returns { Uint8Array } returns the raw descriptor data.
702   * @throws { BusinessError } 401 - Parameter error. Possible causes:
703   * <br>1.Mandatory parameters are left unspecified.
704   * <br>2.Incorrect parameter types.
705   * @throws { BusinessError } 801 - Capability not supported.
706   * @syscap SystemCapability.USB.USBManager
707   * @since 18
708   */
709  function getRawDescriptor(pipe: USBDevicePipe): Uint8Array;
710
711  /**
712   * Obtains the file descriptor.
713   *
714   * @param { USBDevicePipe } pipe - device pipe, which is used to determine the USB device. It cannot be empty.
715   * @returns { number } returns the file descriptor of the USB device.
716   * @throws { BusinessError } 401 - Parameter error. Possible causes:
717   * <br>1.Mandatory parameters are left unspecified.
718   * <br>2.Incorrect parameter types.
719   * @syscap SystemCapability.USB.USBManager
720   * @since 9
721   */
722  /**
723   * Obtains the file descriptor.
724   *
725   * @param { USBDevicePipe } pipe - device pipe, which is used to determine the USB device. It cannot be empty.
726   * @returns { number } returns the file descriptor of the USB device.
727   * @throws { BusinessError } 401 - Parameter error. Possible causes:
728   * <br>1.Mandatory parameters are left unspecified.
729   * <br>2.Incorrect parameter types.
730   * @throws { BusinessError } 801 - Capability not supported.
731   * @syscap SystemCapability.USB.USBManager
732   * @since 18
733   */
734  function getFileDescriptor(pipe: USBDevicePipe): number;
735
736  /**
737   * Performs control transfer.
738   *
739   * @param { USBDevicePipe } pipe - device pipe, which is used to determine the USB device. It cannot be empty.
740   * @param { USBControlParams } controlparam - control transfer parameters. It cannot be empty.
741   * @param { number } [timeout] - timeout duration. This parameter is optional. The default value is **0**, indicating no timeout.
742   * @returns { Promise<number> } returns the size of the transmitted or received data block if the control transfer is successful;
743   * return -1 if an exception occurs.
744   * @throws { BusinessError } 401 - Parameter error. Possible causes:
745   * <br>1.Mandatory parameters are left unspecified.
746   * <br>2.Incorrect parameter types.
747   * @syscap SystemCapability.USB.USBManager
748   * @since 9
749   * @deprecated since 12
750   * @useinstead ohos.usbManager/usbManager#usbControlTransfer
751   */
752  function controlTransfer(pipe: USBDevicePipe, controlparam: USBControlParams, timeout?: number): Promise<number>;
753
754  /**
755   * Performs usb control transfer.
756   *
757   * @param { USBDevicePipe } pipe - device pipe, which is used to determine the USB device. It cannot be empty.
758   * @param { USBDeviceRequestParams } requestparam - control transfer parameters. It cannot be empty.
759   * @param { number } [timeout] - timeout duration. This parameter is optional. The default value is **0**, indicating no timeout.
760   * @returns { Promise<number> } returns the size of the transmitted or received data block if the control transfer is successful;
761   * return -1 if an exception occurs.
762   * @throws { BusinessError } 401 - Parameter error. Possible causes:
763   * <br>1.Mandatory parameters are left unspecified.
764   * <br>2.Incorrect parameter types.
765   * @syscap SystemCapability.USB.USBManager
766   * @since 12
767   */
768  /**
769   * Performs usb control transfer.
770   *
771   * @param { USBDevicePipe } pipe - device pipe, which is used to determine the USB device. It cannot be empty.
772   * @param { USBDeviceRequestParams } requestparam - control transfer parameters. It cannot be empty.
773   * @param { number } [timeout] - timeout duration. This parameter is optional. The default value is **0**, indicating no timeout.
774   * @returns { Promise<number> } returns the size of the transmitted or received data block if the control transfer is successful;
775   * return -1 if an exception occurs.
776   * @throws { BusinessError } 401 - Parameter error. Possible causes:
777   * <br>1.Mandatory parameters are left unspecified.
778   * <br>2.Incorrect parameter types.
779   * @throws { BusinessError } 801 - Capability not supported.
780   * @syscap SystemCapability.USB.USBManager
781   * @since 18
782   */
783  function usbControlTransfer(pipe: USBDevicePipe, requestparam: USBDeviceRequestParams, timeout?: number): Promise<number>;
784
785  /**
786   * Performs bulk transfer.
787   *
788   * @param { USBDevicePipe } pipe - device pipe, which is used to determine the USB device. It cannot be empty.
789   * @param { USBEndpoint } endpoint - USB endpoint, which is used to determine the USB port for data transfer. It cannot be empty.
790   * @param { Uint8Array } buffer - buffer for writing or reading data. It cannot be empty.
791   * @param { number } [timeout] - timeout duration. This parameter is optional. The default value is **0**, indicating no timeout.
792   * @returns { Promise<number> } the size of the transmitted or received data block if the control transfer is successful;
793   * return -1 if an exception occurs.
794   * @throws { BusinessError } 401 - Parameter error. Possible causes:
795   * <br>1.Mandatory parameters are left unspecified.
796   * <br>2.Incorrect parameter types.
797   * @syscap SystemCapability.USB.USBManager
798   * @since 9
799   */
800  /**
801   * Performs bulk transfer.
802   *
803   * @param { USBDevicePipe } pipe - device pipe, which is used to determine the USB device. It cannot be empty.
804   * @param { USBEndpoint } endpoint - USB endpoint, which is used to determine the USB port for data transfer. It cannot be empty.
805   * @param { Uint8Array } buffer - buffer for writing or reading data. It cannot be empty.
806   * @param { number } [timeout] - timeout duration. This parameter is optional. The default value is **0**, indicating no timeout.
807   * @returns { Promise<number> } the size of the transmitted or received data block if the control transfer is successful;
808   * return -1 if an exception occurs.
809   * @throws { BusinessError } 401 - Parameter error. Possible causes:
810   * <br>1.Mandatory parameters are left unspecified.
811   * <br>2.Incorrect parameter types.
812   * @throws { BusinessError } 801 - Capability not supported.
813   * @syscap SystemCapability.USB.USBManager
814   * @since 18
815   */
816  function bulkTransfer(
817    pipe: USBDevicePipe,
818    endpoint: USBEndpoint,
819    buffer: Uint8Array,
820    timeout?: number
821  ): Promise<number>;
822
823  /**
824   * Closes a USB device pipe.
825   *
826   * @param { USBDevicePipe } pipe - device pipe, which is used to determine the USB device. It cannot be empty.
827   * @returns { number } returns **0** if the USB device pipe is closed successfully; return an error code otherwise.
828   * @throws { BusinessError } 401 - Parameter error. Possible causes:
829   * <br>1.Mandatory parameters are left unspecified.
830   * <br>2.Incorrect parameter types.
831   * @syscap SystemCapability.USB.USBManager
832   * @since 9
833   */
834  /**
835   * Closes a USB device pipe.
836   *
837   * @param { USBDevicePipe } pipe - device pipe, which is used to determine the USB device. It cannot be empty.
838   * @returns { number } returns **0** if the USB device pipe is closed successfully; return an error code otherwise.
839   * @throws { BusinessError } 401 - Parameter error. Possible causes:
840   * <br>1.Mandatory parameters are left unspecified.
841   * <br>2.Incorrect parameter types.
842   * @throws { BusinessError } 801 - Capability not supported.
843   * @syscap SystemCapability.USB.USBManager
844   * @since 18
845   */
846  function closePipe(pipe: USBDevicePipe): number;
847
848  /**
849   * Checks whether the application has the right to access the USB accessory.
850   *
851   * @param { USBAccessory } accessory - USB accessory. It cannot be empty.
852   * @returns { boolean } indicates if the user has the right to access the USB accessory.
853   * @throws { BusinessError } 401 - Parameter error. Possible causes:
854   * <br>1. Mandatory parameters are left unspecified.
855   * <br>2. Incorrect parameter types.
856   * @throws { BusinessError } 14400004 - Service exception. Possible causes:
857   * <br>1. No accessory is plugged in.
858   * @throws { BusinessError } 14400005 - Database operation exception.
859   * @throws { BusinessError } 14401001 - The target USBAccessory not matched.
860   * @syscap SystemCapability.USB.USBManager
861   * @since 14
862   */
863  /**
864   * Checks whether the application has the right to access the USB accessory.
865   *
866   * @param { USBAccessory } accessory - USB accessory. It cannot be empty.
867   * @returns { boolean } indicates if the user has the right to access the USB accessory.
868   * @throws { BusinessError } 401 - Parameter error. Possible causes:
869   * <br>1. Mandatory parameters are left unspecified.
870   * <br>2. Incorrect parameter types.
871   * @throws { BusinessError } 801 - Capability not supported.
872   * @throws { BusinessError } 14400004 - Service exception. Possible causes:
873   * <br>1. No accessory is plugged in.
874   * @throws { BusinessError } 14400005 - Database operation exception.
875   * @throws { BusinessError } 14401001 - The target USBAccessory not matched.
876   * @syscap SystemCapability.USB.USBManager
877   * @since 18
878   */
879  function hasAccessoryRight(accessory: USBAccessory): boolean;
880
881  /**
882   * Requests the right for a given application to access the USB accessory.
883   *
884   * @param { USBAccessory } accessory - USB accessory. It cannot be empty.
885   * @returns { Promise<boolean> } indicates if the USB accessory access right are granted.
886   * @throws { BusinessError } 401 - Parameter error. Possible causes:
887   * <br>1. Mandatory parameters are left unspecified.
888   * <br>2. Incorrect parameter types.
889   * @throws { BusinessError } 14400004 - Service exception. Possible causes:
890   * <br>1. No accessory is plugged in.
891   * @throws { BusinessError } 14400005 - Database operation exception.
892   * @throws { BusinessError } 14401001 - The target USBAccessory not matched.
893   * @syscap SystemCapability.USB.USBManager
894   * @since 14
895   */
896  /**
897   * Requests the right for a given application to access the USB accessory.
898   *
899   * @param { USBAccessory } accessory - USB accessory. It cannot be empty.
900   * @returns { Promise<boolean> } indicates if the USB accessory access right are granted.
901   * @throws { BusinessError } 401 - Parameter error. Possible causes:
902   * <br>1. Mandatory parameters are left unspecified.
903   * <br>2. Incorrect parameter types.
904   * @throws { BusinessError } 801 - Capability not supported.
905   * @throws { BusinessError } 14400004 - Service exception. Possible causes:
906   * <br>1. No accessory is plugged in.
907   * @throws { BusinessError } 14400005 - Database operation exception.
908   * @throws { BusinessError } 14401001 - The target USBAccessory not matched.
909   * @syscap SystemCapability.USB.USBManager
910   * @since 18
911   */
912  function requestAccessoryRight(accessory: USBAccessory): Promise<boolean>;
913
914  /**
915   * Cancels the right for a given application to access the USB accessory.
916   *
917   * @param { USBAccessory } accessory - USB accessory. It cannot be empty.
918   * @throws { BusinessError } 401 - Parameter error. Possible causes:
919   * <br>1. Mandatory parameters are left unspecified.
920   * <br>2. Incorrect parameter types.
921   * @throws { BusinessError } 14400004 - Service exception. Possible causes:
922   * <br>1. No accessory is plugged in.
923   * @throws { BusinessError } 14400005 - Database operation exception.
924   * @throws { BusinessError } 14401001 - The target USBAccessory not matched.
925   * @syscap SystemCapability.USB.USBManager
926   * @since 14
927   */
928  /**
929   * Cancels the right for a given application to access the USB accessory.
930   *
931   * @param { USBAccessory } accessory - USB accessory. It cannot be empty.
932   * @throws { BusinessError } 401 - Parameter error. Possible causes:
933   * <br>1. Mandatory parameters are left unspecified.
934   * <br>2. Incorrect parameter types.
935   * @throws { BusinessError } 801 - Capability not supported.
936   * @throws { BusinessError } 14400004 - Service exception. Possible causes:
937   * <br>1. No accessory is plugged in.
938   * @throws { BusinessError } 14400005 - Database operation exception.
939   * @throws { BusinessError } 14401001 - The target USBAccessory not matched.
940   * @syscap SystemCapability.USB.USBManager
941   * @since 18
942   */
943  function cancelAccessoryRight(accessory: USBAccessory): void;
944
945  /**
946   * Obtains the USB Accessory list.
947   *
948   * @returns { Array<Readonly<USBAccessory>> } USB accessory list.
949   * @throws { BusinessError } 14400004 - Service exception. Possible causes:
950   * <br>1. No accessory is plugged in.
951   * @syscap SystemCapability.USB.USBManager
952   * @since 14
953   */
954  /**
955   * Obtains the USB Accessory list.
956   *
957   * @returns { Array<Readonly<USBAccessory>> } USB accessory list.
958   * @throws { BusinessError } 801 - Capability not supported.
959   * @throws { BusinessError } 14400004 - Service exception. Possible causes:
960   * <br>1. No accessory is plugged in.
961   * @syscap SystemCapability.USB.USBManager
962   * @since 18
963   */
964  function getAccessoryList(): Array<Readonly<USBAccessory>>;
965
966  /**
967   * Obtains the accessory handle and opens accessory file descriptor.
968   *
969   * @param { USBAccessory } accessory - accessory, which is used to determine the accessory. It cannot be empty.
970   * @returns { USBAccessoryHandle } returns the handle of the accessory.
971   * @throws { BusinessError } 401 - Parameter error. Possible causes:
972   * <br>1. Mandatory parameters are left unspecified.
973   * <br>2. Incorrect parameter types.
974   * @throws { BusinessError } 14400001 - Permission denied. Call requestAccessoryRight to get the right first.
975   * @throws { BusinessError } 14400004 - Service exception. Possible causes:
976   * <br>1. No accessory is plugged in.
977   * @throws { BusinessError } 14401001 - The target USBAccessory not matched.
978   * @throws { BusinessError } 14401002 - Failed to open the native accessory node.
979   * @throws { BusinessError } 14401003 - Cannot reopen the accessory.
980   * @syscap SystemCapability.USB.USBManager
981   * @since 14
982   */
983  /**
984   * Obtains the accessory handle and opens accessory file descriptor.
985   *
986   * @param { USBAccessory } accessory - accessory, which is used to determine the accessory. It cannot be empty.
987   * @returns { USBAccessoryHandle } returns the handle of the accessory.
988   * @throws { BusinessError } 401 - Parameter error. Possible causes:
989   * <br>1. Mandatory parameters are left unspecified.
990   * <br>2. Incorrect parameter types.
991   * @throws { BusinessError } 801 - Capability not supported.
992   * @throws { BusinessError } 14400001 - Permission denied. Call requestAccessoryRight to get the right first.
993   * @throws { BusinessError } 14400004 - Service exception. Possible causes:
994   * <br>1. No accessory is plugged in.
995   * @throws { BusinessError } 14401001 - The target USBAccessory not matched.
996   * @throws { BusinessError } 14401002 - Failed to open the native accessory node.
997   * @throws { BusinessError } 14401003 - Cannot reopen the accessory.
998   * @syscap SystemCapability.USB.USBManager
999   * @since 18
1000   */
1001  function openAccessory(accessory: USBAccessory): USBAccessoryHandle;
1002
1003  /**
1004   * Closes the accessory file descriptor.
1005   *
1006   * @param { USBAccessoryHandle } accessoryHandle - Accessory handle to be closed.
1007   * @throws { BusinessError } 401 - Parameter error. Possible causes:
1008   * <br>1. Mandatory parameters are left unspecified.
1009   * <br>2. Incorrect parameter types.
1010   * @throws { BusinessError } 14400004 - Service exception. Possible causes:
1011   * <br>1. No accessory is plugged in.
1012   * @syscap SystemCapability.USB.USBManager
1013   * @since 14
1014   */
1015  /**
1016   * Closes the accessory file descriptor.
1017   *
1018   * @param { USBAccessoryHandle } accessoryHandle - Accessory handle to be closed.
1019   * @throws { BusinessError } 401 - Parameter error. Possible causes:
1020   * <br>1. Mandatory parameters are left unspecified.
1021   * <br>2. Incorrect parameter types.
1022   * @throws { BusinessError } 801 - Capability not supported.
1023   * @throws { BusinessError } 14400004 - Service exception. Possible causes:
1024   * <br>1. No accessory is plugged in.
1025   * @syscap SystemCapability.USB.USBManager
1026   * @since 18
1027   */
1028  function closeAccessory(accessoryHandle: USBAccessoryHandle): void;
1029
1030  /**
1031   * Represents the USB endpoint from which data is sent or received. You can obtain the USB endpoint through USBInterface.
1032   *
1033   * @typedef USBEndpoint
1034   * @syscap SystemCapability.USB.USBManager
1035   * @since 9
1036   */
1037  interface USBEndpoint {
1038    /**
1039     * Endpoint address
1040     *
1041     * @type { number }
1042     * @syscap SystemCapability.USB.USBManager
1043     * @since 9
1044     */
1045    address: number;
1046
1047    /**
1048     * Endpoint attributes
1049     *
1050     * @type { number }
1051     * @syscap SystemCapability.USB.USBManager
1052     * @since 9
1053     */
1054    attributes: number;
1055
1056    /**
1057     * Endpoint interval
1058     *
1059     * @type { number }
1060     * @syscap SystemCapability.USB.USBManager
1061     * @since 9
1062     */
1063    interval: number;
1064
1065    /**
1066     * Maximum size of data packets on the endpoint
1067     *
1068     * @type { number }
1069     * @syscap SystemCapability.USB.USBManager
1070     * @since 9
1071     */
1072    maxPacketSize: number;
1073
1074    /**
1075     * Endpoint direction
1076     *
1077     * @type { USBRequestDirection }
1078     * @syscap SystemCapability.USB.USBManager
1079     * @since 9
1080     */
1081    direction: USBRequestDirection;
1082
1083    /**
1084     * Endpoint number
1085     *
1086     * @type { number }
1087     * @syscap SystemCapability.USB.USBManager
1088     * @since 9
1089     */
1090    number: number;
1091
1092    /**
1093     * Endpoint type
1094     *
1095     * @type { number }
1096     * @syscap SystemCapability.USB.USBManager
1097     * @since 9
1098     */
1099    type: number;
1100
1101    /**
1102     * Unique ID defined by USBInterface.id, which indicates the interface to which the endpoint belongs
1103     *
1104     * @type { number }
1105     * @syscap SystemCapability.USB.USBManager
1106     * @since 9
1107     */
1108    interfaceId: number;
1109  }
1110
1111  /**
1112   * Represents a USB interface. One config can contain multiple **USBInterface** instances, each providing a specific function.
1113   *
1114   * @typedef USBInterface
1115   * @syscap SystemCapability.USB.USBManager
1116   * @since 9
1117   */
1118  interface USBInterface {
1119    /**
1120     * Unique ID of the USB interface
1121     *
1122     * @type { number }
1123     * @syscap SystemCapability.USB.USBManager
1124     * @since 9
1125     */
1126    id: number;
1127
1128    /**
1129     * Interface protocol
1130     *
1131     * @type { number }
1132     * @syscap SystemCapability.USB.USBManager
1133     * @since 9
1134     */
1135    protocol: number;
1136
1137    /**
1138     * Device type
1139     *
1140     * @type { number }
1141     * @syscap SystemCapability.USB.USBManager
1142     * @since 9
1143     */
1144    clazz: number;
1145
1146    /**
1147     * Device subclass
1148     *
1149     * @type { number }
1150     * @syscap SystemCapability.USB.USBManager
1151     * @since 9
1152     */
1153    subClass: number;
1154
1155    /**
1156     * Alternation between descriptors of the same USB interface
1157     *
1158     * @type { number }
1159     * @syscap SystemCapability.USB.USBManager
1160     * @since 9
1161     */
1162    alternateSetting: number;
1163
1164    /**
1165     * Interface name
1166     *
1167     * @type { string }
1168     * @syscap SystemCapability.USB.USBManager
1169     * @since 9
1170     */
1171    name: string;
1172
1173    /**
1174     * USBEndpoint that belongs to the USB interface
1175     *
1176     * @type { Array<USBEndpoint> }
1177     * @syscap SystemCapability.USB.USBManager
1178     * @since 9
1179     */
1180    endpoints: Array<USBEndpoint>;
1181  }
1182
1183  /**
1184   * USB configuration. One USBDevice can contain multiple USBConfiguration instances.
1185   *
1186   * @typedef USBConfiguration
1187   * @syscap SystemCapability.USB.USBManager
1188   * @since 9
1189   */
1190  interface USBConfiguration {
1191    /**
1192     * Unique ID of the USB configuration
1193     *
1194     * @type { number }
1195     * @syscap SystemCapability.USB.USBManager
1196     * @since 9
1197     */
1198    id: number;
1199
1200    /**
1201     * Configuration attributes
1202     *
1203     * @type { number }
1204     * @syscap SystemCapability.USB.USBManager
1205     * @since 9
1206     */
1207    attributes: number;
1208
1209    /**
1210     * Maximum power consumption, in mA
1211     *
1212     * @type { number }
1213     * @syscap SystemCapability.USB.USBManager
1214     * @since 9
1215     */
1216    maxPower: number;
1217
1218    /**
1219     * Configuration name, which can be left empty
1220     *
1221     * @type { string }
1222     * @syscap SystemCapability.USB.USBManager
1223     * @since 9
1224     */
1225    name: string;
1226
1227    /**
1228     * Support for remote wakeup
1229     *
1230     * @type { boolean }
1231     * @syscap SystemCapability.USB.USBManager
1232     * @since 9
1233     */
1234    isRemoteWakeup: boolean;
1235
1236    /**
1237     * Support for independent power supplies
1238     *
1239     * @type { boolean }
1240     * @syscap SystemCapability.USB.USBManager
1241     * @since 9
1242     */
1243    isSelfPowered: boolean;
1244
1245    /**
1246     * Supported interface attributes
1247     *
1248     * @type { Array<USBInterface> }
1249     * @syscap SystemCapability.USB.USBManager
1250     * @since 9
1251     */
1252    interfaces: Array<USBInterface>;
1253  }
1254
1255  /**
1256   * Represents a USB device.
1257   *
1258   * @typedef USBDevice
1259   * @syscap SystemCapability.USB.USBManager
1260   * @since 9
1261   */
1262  interface USBDevice {
1263    /**
1264     * Bus address
1265     *
1266     * @type { number }
1267     * @syscap SystemCapability.USB.USBManager
1268     * @since 9
1269     */
1270    busNum: number;
1271
1272    /**
1273     * Device address
1274     *
1275     * @type { number }
1276     * @syscap SystemCapability.USB.USBManager
1277     * @since 9
1278     */
1279    devAddress: number;
1280
1281    /**
1282     * Device SN
1283     *
1284     * @type { string }
1285     * @syscap SystemCapability.USB.USBManager
1286     * @since 9
1287     */
1288    serial: string;
1289
1290    /**
1291     * Device name
1292     *
1293     * @type { string }
1294     * @syscap SystemCapability.USB.USBManager
1295     * @since 9
1296     */
1297    name: string;
1298
1299    /**
1300     * Device manufacturer
1301     *
1302     * @type { string }
1303     * @syscap SystemCapability.USB.USBManager
1304     * @since 9
1305     */
1306    manufacturerName: string;
1307
1308    /**
1309     * Product information
1310     *
1311     * @type { string }
1312     * @syscap SystemCapability.USB.USBManager
1313     * @since 9
1314     */
1315    productName: string;
1316
1317    /**
1318     * Product version
1319     *
1320     * @type { string }
1321     * @syscap SystemCapability.USB.USBManager
1322     * @since 9
1323     */
1324    version: string;
1325
1326    /**
1327     * Vendor ID
1328     *
1329     * @type { number }
1330     * @syscap SystemCapability.USB.USBManager
1331     * @since 9
1332     */
1333    vendorId: number;
1334
1335    /**
1336     * Product ID
1337     *
1338     * @type { number }
1339     * @syscap SystemCapability.USB.USBManager
1340     * @since 9
1341     */
1342    productId: number;
1343
1344    /**
1345     * Device class
1346     *
1347     * @type { number }
1348     * @syscap SystemCapability.USB.USBManager
1349     * @since 9
1350     */
1351    clazz: number;
1352
1353    /**
1354     * Device subclass
1355     *
1356     * @type { number }
1357     * @syscap SystemCapability.USB.USBManager
1358     * @since 9
1359     */
1360    subClass: number;
1361
1362    /**
1363     * Device protocol code
1364     *
1365     * @type { number }
1366     * @syscap SystemCapability.USB.USBManager
1367     * @since 9
1368     */
1369    protocol: number;
1370
1371    /**
1372     * Device configuration descriptor information
1373     *
1374     * @type { Array<USBConfiguration> }
1375     * @syscap SystemCapability.USB.USBManager
1376     * @since 9
1377     */
1378    configs: Array<USBConfiguration>;
1379  }
1380
1381  /**
1382   * Represents a USB device pipe, which is used to determine the USB device.
1383   *
1384   * @typedef USBDevicePipe
1385   * @syscap SystemCapability.USB.USBManager
1386   * @since 9
1387   */
1388  interface USBDevicePipe {
1389    /**
1390     * Bus address.
1391     *
1392     * @type { number }
1393     * @syscap SystemCapability.USB.USBManager
1394     * @since 9
1395     */
1396    busNum: number;
1397
1398    /**
1399     * Device address
1400     *
1401     * @type { number }
1402     * @syscap SystemCapability.USB.USBManager
1403     * @since 9
1404     */
1405    devAddress: number;
1406  }
1407
1408  /**
1409   * Enumerates power role types.
1410   *
1411   * @enum { number }
1412   * @syscap SystemCapability.USB.USBManager
1413   * @systemapi
1414   * @since 9
1415   */
1416  export enum PowerRoleType {
1417    /**
1418     * None
1419     *
1420     * @syscap SystemCapability.USB.USBManager
1421     * @systemapi
1422     * @since 9
1423     */
1424    NONE = 0,
1425
1426    /**
1427     * External power supply
1428     *
1429     * @syscap SystemCapability.USB.USBManager
1430     * @systemapi
1431     * @since 9
1432     */
1433    SOURCE = 1,
1434
1435    /**
1436     * Internal power supply
1437     *
1438     * @syscap SystemCapability.USB.USBManager
1439     * @systemapi
1440     * @since 9
1441     */
1442    SINK = 2
1443  }
1444
1445  /**
1446   * Enumerates data role types.
1447   *
1448   * @enum { number }
1449   * @syscap SystemCapability.USB.USBManager
1450   * @systemapi
1451   * @since 9
1452   */
1453  export enum DataRoleType {
1454    /**
1455     * None
1456     *
1457     * @syscap SystemCapability.USB.USBManager
1458     * @systemapi
1459     * @since 9
1460     */
1461    NONE = 0,
1462
1463    /**
1464     * Host mode
1465     *
1466     * @syscap SystemCapability.USB.USBManager
1467     * @systemapi
1468     * @since 9
1469     */
1470    HOST = 1,
1471
1472    /**
1473     * Device mode
1474     *
1475     * @syscap SystemCapability.USB.USBManager
1476     * @systemapi
1477     * @since 9
1478     */
1479    DEVICE = 2
1480  }
1481
1482  /**
1483   * Enumerates port mode types
1484   *
1485   * @enum { number }
1486   * @syscap SystemCapability.USB.USBManager
1487   * @systemapi
1488   * @since 9
1489   */
1490  export enum PortModeType {
1491    /**
1492     * None
1493     *
1494     * @syscap SystemCapability.USB.USBManager
1495     * @systemapi
1496     * @since 9
1497     */
1498    NONE = 0,
1499
1500    /**
1501     * Upstream facing port, which functions as the sink of power supply
1502     *
1503     * @syscap SystemCapability.USB.USBManager
1504     * @systemapi
1505     * @since 9
1506     */
1507    UFP = 1,
1508
1509    /**
1510     * Downstream facing port, which functions as the source of power supply
1511     *
1512     * @syscap SystemCapability.USB.USBManager
1513     * @systemapi
1514     * @since 9
1515     */
1516    DFP = 2,
1517
1518    /**
1519     * Dynamic reconfiguration port (DRP), which can function as the DFP (host) or UFP (device). It is not supported currently.
1520     *
1521     * @syscap SystemCapability.USB.USBManager
1522     * @systemapi
1523     * @since 9
1524     */
1525    DRP = 3,
1526
1527    /**
1528     * Not supported currently
1529     *
1530     * @syscap SystemCapability.USB.USBManager
1531     * @systemapi
1532     * @since 9
1533     */
1534    NUM_MODES = 4
1535  }
1536
1537  /**
1538   * Enumerates USB device port roles.
1539   *
1540   * @typedef USBPortStatus
1541   * @syscap SystemCapability.USB.USBManager
1542   * @systemapi
1543   * @since 9
1544   */
1545  interface USBPortStatus {
1546    /**
1547     * USB mode
1548     *
1549     * @type { number }
1550     * @syscap SystemCapability.USB.USBManager
1551     * @systemapi
1552     * @since 9
1553     */
1554    currentMode: number;
1555
1556    /**
1557     * Power role
1558     *
1559     * @type { number }
1560     * @syscap SystemCapability.USB.USBManager
1561     * @systemapi
1562     * @since 9
1563     */
1564    currentPowerRole: number;
1565
1566    /**
1567     * Data role
1568     *
1569     * @type { number }
1570     * @syscap SystemCapability.USB.USBManager
1571     * @systemapi
1572     * @since 9
1573     */
1574    currentDataRole: number;
1575  }
1576
1577  /**
1578   * Represents a USB device port.
1579   *
1580   * @typedef USBPort
1581   * @syscap SystemCapability.USB.USBManager
1582   * @systemapi
1583   * @since 9
1584   */
1585  interface USBPort {
1586    /**
1587     * Unique ID of the USB port
1588     *
1589     * @type { number }
1590     * @syscap SystemCapability.USB.USBManager
1591     * @systemapi
1592     * @since 9
1593     */
1594    id: number;
1595
1596    /**
1597     * Mask combination for the supported mode list of the USB port
1598     *
1599     * @type { PortModeType }
1600     * @syscap SystemCapability.USB.USBManager
1601     * @systemapi
1602     * @since 9
1603     */
1604    supportedModes: PortModeType;
1605
1606    /**
1607     * USB port role
1608     *
1609     * @type { USBPortStatus }
1610     * @syscap SystemCapability.USB.USBManager
1611     * @systemapi
1612     * @since 9
1613     */
1614    status: USBPortStatus;
1615  }
1616
1617  /**
1618   * Represents control transfer parameters.
1619   *
1620   * @typedef USBControlParams
1621   * @syscap SystemCapability.USB.USBManager
1622   * @since 9
1623   * @deprecated since 18
1624   * @useinstead ohos.usbManager/usbManager#USBDeviceRequestParams
1625   */
1626  interface USBControlParams {
1627    /**
1628     * Request type
1629     *
1630     * @type { number }
1631     * @syscap SystemCapability.USB.USBManager
1632     * @since 9
1633     * @deprecated since 18
1634     */
1635    request: number;
1636
1637    /**
1638     * Request target type
1639     *
1640     * @type { USBRequestTargetType }
1641     * @syscap SystemCapability.USB.USBManager
1642     * @since 9
1643     * @deprecated since 18
1644     */
1645    target: USBRequestTargetType;
1646
1647    /**
1648     * Control request type
1649     *
1650     * @type { USBControlRequestType }
1651     * @syscap SystemCapability.USB.USBManager
1652     * @since 9
1653     * @deprecated since 18
1654     */
1655    reqType: USBControlRequestType;
1656
1657    /**
1658     * Request parameter value
1659     *
1660     * @type { number }
1661     * @syscap SystemCapability.USB.USBManager
1662     * @since 9
1663     * @deprecated since 18
1664     */
1665    value: number;
1666
1667    /**
1668     * Index of the parameter value
1669     *
1670     * @type { number }
1671     * @syscap SystemCapability.USB.USBManager
1672     * @since 9
1673     * @deprecated since 18
1674     */
1675    index: number;
1676
1677    /**
1678     * Data written to or read from the buffer
1679     *
1680     * @type { Uint8Array }
1681     * @syscap SystemCapability.USB.USBManager
1682     * @since 9
1683     * @deprecated since 18
1684     */
1685    data: Uint8Array;
1686  }
1687
1688  /**
1689   * Represents control transfer parameters.
1690   *
1691   * @typedef USBDeviceRequestParams
1692   * @syscap SystemCapability.USB.USBManager
1693   * @since 12
1694   */
1695  interface USBDeviceRequestParams {
1696    /**
1697     * Bit map request type
1698     *
1699     * @type { number }
1700     * @syscap SystemCapability.USB.USBManager
1701     * @since 12
1702     */
1703    bmRequestType: number;
1704
1705    /**
1706     * Byte request
1707     *
1708     * @type { number }
1709     * @syscap SystemCapability.USB.USBManager
1710     * @since 12
1711     */
1712    bRequest: number;
1713
1714    /**
1715     * Request parameter word value
1716     *
1717     * @type { number }
1718     * @syscap SystemCapability.USB.USBManager
1719     * @since 12
1720     */
1721    wValue: number;
1722
1723    /**
1724     * Word index of the parameter value
1725     *
1726     * @type { number }
1727     * @syscap SystemCapability.USB.USBManager
1728     * @since 12
1729     */
1730    wIndex: number;
1731
1732    /**
1733     * Word length of the parameter value
1734     *
1735     * @type { number }
1736     * @syscap SystemCapability.USB.USBManager
1737     * @since 12
1738     */
1739    wLength: number;
1740
1741    /**
1742     * Data written to or read from the buffer
1743     *
1744     * @type { Uint8Array }
1745     * @syscap SystemCapability.USB.USBManager
1746     * @since 12
1747     */
1748    data: Uint8Array;
1749  }
1750
1751  /**
1752   * Enumerates USB request target types.
1753   *
1754   * @enum { number }
1755   * @syscap SystemCapability.USB.USBManager
1756   * @since 9
1757   */
1758  export enum USBRequestTargetType {
1759    /**
1760     * USB device
1761     *
1762     * @syscap SystemCapability.USB.USBManager
1763     * @since 9
1764     */
1765    USB_REQUEST_TARGET_DEVICE = 0,
1766
1767    /**
1768     * USB interface
1769     *
1770     * @syscap SystemCapability.USB.USBManager
1771     * @since 9
1772     */
1773    USB_REQUEST_TARGET_INTERFACE = 1,
1774
1775    /**
1776     * Endpoint
1777     *
1778     * @syscap SystemCapability.USB.USBManager
1779     * @since 9
1780     */
1781    USB_REQUEST_TARGET_ENDPOINT = 2,
1782
1783    /**
1784     * Others
1785     *
1786     * @syscap SystemCapability.USB.USBManager
1787     * @since 9
1788     */
1789    USB_REQUEST_TARGET_OTHER = 3
1790  }
1791
1792  /**
1793   * Enumerates control request types.
1794   *
1795   * @enum { number }
1796   * @syscap SystemCapability.USB.USBManager
1797   * @since 9
1798   */
1799  export enum USBControlRequestType {
1800    /**
1801     * Standard
1802     *
1803     * @syscap SystemCapability.USB.USBManager
1804     * @since 9
1805     */
1806    USB_REQUEST_TYPE_STANDARD = 0,
1807
1808    /**
1809     * Class
1810     *
1811     * @syscap SystemCapability.USB.USBManager
1812     * @since 9
1813     */
1814    USB_REQUEST_TYPE_CLASS = 1,
1815
1816    /**
1817     * Vendor
1818     *
1819     * @syscap SystemCapability.USB.USBManager
1820     * @since 9
1821     */
1822    USB_REQUEST_TYPE_VENDOR = 2
1823  }
1824
1825  /**
1826   * Enumerates request directions.
1827   *
1828   * @enum { number }
1829   * @syscap SystemCapability.USB.USBManager
1830   * @since 9
1831   */
1832  export enum USBRequestDirection {
1833    /**
1834     * Request for writing data from the host to the device
1835     *
1836     * @syscap SystemCapability.USB.USBManager
1837     * @since 9
1838     */
1839    USB_REQUEST_DIR_TO_DEVICE = 0,
1840
1841    /**
1842     * Request for reading data from the device to the host
1843     *
1844     * @syscap SystemCapability.USB.USBManager
1845     * @since 9
1846     */
1847    USB_REQUEST_DIR_FROM_DEVICE = 0x80
1848  }
1849
1850  /**
1851   * Enumerates function modes.
1852   *
1853   * @enum { number }
1854   * @syscap SystemCapability.USB.USBManager
1855   * @systemapi
1856   * @since 9
1857   */
1858  export enum FunctionType {
1859    /**
1860     * None
1861     *
1862     * @syscap SystemCapability.USB.USBManager
1863     * @systemapi
1864     * @since 9
1865     */
1866    NONE = 0,
1867
1868    /**
1869     * Serial port device
1870     *
1871     * @syscap SystemCapability.USB.USBManager
1872     * @systemapi
1873     * @since 9
1874     */
1875    ACM = 1,
1876
1877    /**
1878     * Ethernet port device
1879     *
1880     * @syscap SystemCapability.USB.USBManager
1881     * @systemapi
1882     * @since 9
1883     */
1884    ECM = 2,
1885
1886    /**
1887     * HDC device
1888     *
1889     * @syscap SystemCapability.USB.USBManager
1890     * @systemapi
1891     * @since 9
1892     */
1893    HDC = 4,
1894
1895    /**
1896     * MTP device
1897     *
1898     * @syscap SystemCapability.USB.USBManager
1899     * @systemapi
1900     * @since 9
1901     */
1902    MTP = 8,
1903
1904    /**
1905     * PTP device
1906     *
1907     * @syscap SystemCapability.USB.USBManager
1908     * @systemapi
1909     * @since 9
1910     */
1911    PTP = 16,
1912
1913    /**
1914     * RNDIS device
1915     *
1916     * @syscap SystemCapability.USB.USBManager
1917     * @systemapi
1918     * @since 9
1919     */
1920    RNDIS = 32,
1921
1922    /**
1923     * MIDI device
1924     *
1925     * @syscap SystemCapability.USB.USBManager
1926     * @systemapi
1927     * @since 9
1928     */
1929    MIDI = 64,
1930
1931    /**
1932     * Audio source device
1933     *
1934     * @syscap SystemCapability.USB.USBManager
1935     * @systemapi
1936     * @since 9
1937     */
1938    AUDIO_SOURCE = 128,
1939
1940    /**
1941     * NCM device
1942     *
1943     * @syscap SystemCapability.USB.USBManager
1944     * @systemapi
1945     * @since 9
1946     */
1947    NCM = 256
1948  }
1949
1950  /**
1951   * Represents a USB Accessory.
1952   *
1953   * @typedef USBAccessory
1954   * @syscap SystemCapability.USB.USBManager
1955   * @since 14
1956   */
1957  interface USBAccessory {
1958    /**
1959     * The manufacturer name of the accessory.
1960     *
1961     * @type { string }
1962     * @syscap SystemCapability.USB.USBManager
1963     * @since 14
1964     */
1965    manufacturer: string;
1966
1967    /**
1968     * The product of the accessory.
1969     *
1970     * @type { string }
1971     * @syscap SystemCapability.USB.USBManager
1972     * @since 14
1973     */
1974    product: string;
1975
1976    /**
1977     * The user visible description of the accessory.
1978     *
1979     * @type { string }
1980     * @syscap SystemCapability.USB.USBManager
1981     * @since 14
1982     */
1983    description: string;
1984
1985    /**
1986     * The version of the accessory.
1987     *
1988     * @type { string }
1989     * @syscap SystemCapability.USB.USBManager
1990     * @since 14
1991     */
1992    version: string;
1993
1994    /**
1995     * The serial number of the accessory.
1996     *
1997     * @type { string }
1998     * @syscap SystemCapability.USB.USBManager
1999     * @since 14
2000     */
2001    serialNumber: string;
2002  }
2003
2004  /**
2005   * Handle of accessory.
2006   *
2007   * @typedef USBAccessoryHandle
2008   * @syscap SystemCapability.USB.USBManager
2009   * @since 14
2010   */
2011  interface USBAccessoryHandle {
2012    /**
2013     * The file descriptor of the accessory.The valid USBAccessoryHandle.accessoryFd is a positive value.
2014     *
2015     * @type { number }
2016     * @syscap SystemCapability.USB.USBManager
2017     * @since 14
2018     */
2019    accessoryFd: number;
2020  }
2021
2022  /**
2023     * Usb transfer flag.
2024     *
2025     * @enum { number }
2026     * @syscap SystemCapability.USB.USBManager
2027     * @since 18
2028     */
2029  export enum UsbTransferFlags {
2030    /**
2031     * Report short frames as errors
2032     *
2033     * @syscap SystemCapability.USB.USBManager
2034     * @since 18
2035     */
2036    USB_TRANSFER_SHORT_NOT_OK = 0,
2037
2038    /**
2039     * Automatically free transfer buffer
2040     *
2041     * @syscap SystemCapability.USB.USBManager
2042     * @since 18
2043     */
2044    USB_TRANSFER_FREE_BUFFER = 1,
2045
2046    /**
2047     * Automatically free transfer after callback returns
2048     *
2049     * @syscap SystemCapability.USB.USBManager
2050     * @since 18
2051     */
2052    USB_TRANSFER_FREE_TRANSFER = 2,
2053
2054    /**
2055     * Transmissions that are multiples of wMaxPacketSize will add an additional zero packet.
2056     *
2057     * @syscap SystemCapability.USB.USBManager
2058     * @since 18
2059     */
2060    USB_TRANSFER_ADD_ZERO_PACKET = 3
2061  }
2062
2063  /**
2064   * Usb transfer status.
2065   *
2066   * @enum { number }
2067   * @syscap SystemCapability.USB.USBManager
2068   * @since 18
2069   */
2070  export enum UsbTransferStatus {
2071    /**
2072     * Transfer completed
2073     *
2074     * @syscap SystemCapability.USB.USBManager
2075     * @since 18
2076     */
2077    TRANSFER_COMPLETED = 0,
2078
2079    /**
2080     * Transfer failed
2081     *
2082     * @syscap SystemCapability.USB.USBManager
2083     * @since 18
2084     */
2085    TRANSFER_ERROR = 1,
2086
2087    /**
2088     * Transfer timed out
2089     *
2090     * @syscap SystemCapability.USB.USBManager
2091     * @since 18
2092     */
2093    TRANSFER_TIMED_OUT = 2,
2094
2095    /**
2096     * Transfer was canceled
2097     *
2098     * @syscap SystemCapability.USB.USBManager
2099     * @since 18
2100     */
2101    TRANSFER_CANCELED = 3,
2102
2103    /**
2104     * For bulk/interrupt endpoints: halt condition detected (endpoint
2105     * stalled). For control endpoints: control request not supported.
2106     *
2107     * @syscap SystemCapability.USB.USBManager
2108     * @since 18
2109     */
2110    TRANSFER_STALL = 4,
2111
2112    /**
2113     * Device was disconnected
2114     *
2115     * @syscap SystemCapability.USB.USBManager
2116     * @since 18
2117     */
2118    TRANSFER_NO_DEVICE = 5,
2119
2120    /**
2121     * Device sent more data than requested
2122     *
2123     * @syscap SystemCapability.USB.USBManager
2124     * @since 18
2125     */
2126    TRANSFER_OVERFLOW = 6
2127  }
2128
2129  /**
2130   * USB DATA transfer type.
2131   *
2132   * @enum { number }
2133   * @syscap SystemCapability.USB.USBManager
2134   * @since 18
2135   */
2136  export enum UsbEndpointTransferType {
2137    /**
2138     * Isochronous endpoint
2139     *
2140     * @syscap SystemCapability.USB.USBManager
2141     * @since 18
2142     */
2143    TRANSFER_TYPE_ISOCHRONOUS = 0x1,
2144
2145    /**
2146     * Bulk endpoint
2147     *
2148     * @syscap SystemCapability.USB.USBManager
2149     * @since 18
2150     */
2151    TRANSFER_TYPE_BULK = 0x2,
2152
2153    /**
2154     * Interrupt endpoint
2155     *
2156     * @syscap SystemCapability.USB.USBManager
2157     * @since 18
2158     */
2159    TRANSFER_TYPE_INTERRUPT = 0x3
2160  }
2161
2162  /**
2163   * Isochronous packet descriptors, only for isochronous transfers.
2164   *
2165   * @typedef UsbIsoPacketDescriptor
2166   * @syscap SystemCapability.USB.USBManager
2167   * @since 18
2168   */
2169  interface UsbIsoPacketDescriptor {
2170    /**
2171     * Length of data to request in this packet
2172     *
2173     * @type { number }
2174     * @syscap SystemCapability.USB.USBManager
2175     * @since 18
2176     */
2177    length: number;
2178
2179    /**
2180     * Amount of data that was actually transferred
2181     *
2182     * @type { number }
2183     * @syscap SystemCapability.USB.USBManager
2184     * @since 18
2185     */
2186    actualLength: number;
2187
2188    /**
2189     * Status code for this packet
2190     *
2191     * @type { UsbTransferStatus }
2192     * @syscap SystemCapability.USB.USBManager
2193     * @since 18
2194     */
2195    status: UsbTransferStatus;
2196  }
2197
2198  /**
2199  * submit transfer callback.
2200  *
2201  * @typedef SubmitTransferCallback
2202  * @syscap SystemCapability.USB.USBManager
2203  * @since 18
2204  */
2205  interface SubmitTransferCallback {
2206    /**
2207     * Actual length of data that was transferred. Read-only, and only for
2208     * use within transfer callback function. Not valid for isochronous endpoint transfers.
2209     *
2210     * @type { number }
2211     * @syscap SystemCapability.USB.USBManager
2212     * @since 18
2213     */
2214    actualLength: number;
2215
2216    /**
2217     * The status of the transfer. Read-only, and only for use within transfer callback function.
2218     *
2219     * @type { UsbTransferStatus }
2220     * @syscap SystemCapability.USB.USBManager
2221     * @since 18
2222     */
2223    status: UsbTransferStatus;
2224
2225    /**
2226     * Isochronous packet descriptors, for isochronous transfers only.
2227     *
2228     * @type { Array<Readonly<UsbIsoPacketDescriptor>> }
2229     * @syscap SystemCapability.USB.USBManager
2230     * @since 18
2231     */
2232    isoPacketDescs: Array<Readonly<UsbIsoPacketDescriptor>>;
2233  }
2234
2235  /**
2236   * As a generic USB data transfer interface. The Client populates this interface and
2237   * submits it in order to request a transfer.
2238   *
2239   * @typedef UsbDataTransferParams
2240   * @syscap SystemCapability.USB.USBManager
2241   * @since 18
2242   */
2243  interface UsbDataTransferParams {
2244    /**
2245     * Pipe of the device that this data transfer will be submitted to.
2246     *
2247     * @type { USBDevicePipe }
2248     * @syscap SystemCapability.USB.USBManager
2249     * @since 18
2250     */
2251    devPipe: USBDevicePipe;
2252
2253    /**
2254     * A bitwise OR combination of UsbTransferFlags.
2255     *
2256     * @type { UsbTransferFlags }
2257     * @syscap SystemCapability.USB.USBManager
2258     * @since 18
2259     */
2260    flags: UsbTransferFlags;
2261
2262    /**
2263     * Address of the endpoint where this transfer will be sent.
2264     *
2265     * @type { number }
2266     * @syscap SystemCapability.USB.USBManager
2267     * @since 18
2268     */
2269    endpoint: number;
2270
2271    /**
2272     * Type of the transfer
2273     *
2274     * @type { UsbEndpointTransferType }
2275     * @syscap SystemCapability.USB.USBManager
2276     * @since 18
2277     */
2278    type: UsbEndpointTransferType;
2279
2280    /**
2281     * Timeout for this transfer in milliseconds. A value of 0 indicates no timeout.
2282     *
2283     * @type { number }
2284     * @syscap SystemCapability.USB.USBManager
2285     * @since 18
2286     */
2287    timeout: number;
2288
2289    /**
2290     * Length of the data buffer. Must be non-negative.
2291     *
2292     * @type { number }
2293     * @syscap SystemCapability.USB.USBManager
2294     * @since 18
2295     */
2296    length: number;
2297
2298    /**
2299     * Callback function. This will be invoked when the transfer completes, fails, or is canceled.
2300     *
2301     * @type { AsyncCallback<SubmitTransferCallback> }
2302     * @syscap SystemCapability.USB.USBManager
2303     * @since 18
2304     */
2305    callback: AsyncCallback<SubmitTransferCallback>;
2306
2307    /**
2308     * User context data. Useful for associating specific data to a transfer
2309     * that can be accessed from within the callback function.
2310     *
2311     * @type { Uint8Array }
2312     * @syscap SystemCapability.USB.USBManager
2313     * @since 18
2314     */
2315    userData: Uint8Array;
2316
2317    /**
2318     * Data buffer
2319     *
2320     * @type { Uint8Array }
2321     * @syscap SystemCapability.USB.USBManager
2322     * @since 18
2323     */
2324    buffer: Uint8Array;
2325
2326    /**
2327     * Count of isochronous packets. Only used for I/O with isochronous endpoints. Must be non-negative.
2328     *
2329     * @type { number }
2330     * @syscap SystemCapability.USB.USBManager
2331     * @since 18
2332     */
2333    isoPacketCount: number;
2334  }
2335
2336  /**
2337   * Submit USB data transfer.
2338   *
2339   * @param { transfer } As a generic USB data transfer interface. The Client populates this interface and
2340   * submits it in order to request a transfer
2341   * @throws { BusinessError } 801 - Capability not supported.
2342   * @throws { BusinessError } 14400001 - Access right denied. Call requestRight to get the USBDevicePipe access right first.
2343   * @throws { BusinessError } 14400007 - Resource busy. Possible causes:
2344   * <br>1. The transfer has already been submitted.
2345   * <br>2. The interface is claimed by another program or driver.
2346   * @throws { BusinessError } 14400008 - No such device (it may have been disconnected).
2347   * @throws { BusinessError } 14400009 - Insufficient memory. Possible causes:
2348   * <br>1. Malloc memory failed.
2349   * @throws { BusinessError } 14400012 - Transmission I/O error.
2350   * @syscap SystemCapability.USB.USBManager
2351   * @since 18
2352   */
2353  function usbSubmitTransfer(transfer: UsbDataTransferParams): void;
2354
2355  /**
2356   * Cancel USB data transfer.
2357   *
2358   * @param { transfer } Cancel the target transfer
2359   * @throws { BusinessError } 801 - Capability not supported.
2360   * @throws { BusinessError } 14400001 - Access right denied. Call requestRight to get the USBDevicePipe access right first.
2361   * @throws { BusinessError } 14400008 - No such device (it may have been disconnected).
2362   * @throws { BusinessError } 14400010 - Other USB error. Possible causes:
2363   * <br>1.Unrecognized discard error code.
2364   * @throws { BusinessError } 14400011 - The transfer is not in progress, or is already complete or cancelled.
2365   * @syscap SystemCapability.USB.USBManager
2366   * @since 18
2367   */
2368  function usbCancelTransfer(transfer: UsbDataTransferParams): void;
2369}
2370
2371export default usbManager;
2372