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 21/** 22 * This module provides the capability of manage USB device. 23 * 24 * @namespace usbManager 25 * @syscap SystemCapability.USB.USBManager 26 * @since 9 27 */ 28declare namespace usbManager { 29 /** 30 * Obtains the USB device list. 31 * 32 * @returns { Array<Readonly<USBDevice>> } USB device list. 33 * @syscap SystemCapability.USB.USBManager 34 * @since 9 35 */ 36 function getDevices(): Array<Readonly<USBDevice>>; 37 38 /** 39 * Connects to the USB device based on the device information returned by getDevices(). 40 * 41 * @param { USBDevice } device - USB device on the device list returned by getDevices(). It cannot be empty. 42 * @returns { Readonly<USBDevicePipe> } object for data transfer. 43 * @throws { BusinessError } 401 - Parameter error. Possible causes: 44 * <br>1.Mandatory parameters are left unspecified. 45 * <br>2.Incorrect parameter types. 46 * @throws { BusinessError } 14400001 - Permission denied. Call requestRight to get the permission first. 47 * @syscap SystemCapability.USB.USBManager 48 * @since 9 49 */ 50 function connectDevice(device: USBDevice): Readonly<USBDevicePipe>; 51 52 /** 53 * Checks whether the application has the permission to access the device. 54 * 55 * @param { string } deviceName - device name defined by USBDevice.name. It cannot be empty. 56 * @returns { boolean } indicates if the user has the permission to access the device. 57 * @throws { BusinessError } 401 - Parameter error. Possible causes: 58 * <br>1.Mandatory parameters are left unspecified. 59 * <br>2.Incorrect parameter types. 60 * @syscap SystemCapability.USB.USBManager 61 * @since 9 62 */ 63 function hasRight(deviceName: string): boolean; 64 65 /** 66 * Requests the permission for a given application to access the USB device. 67 * The system application has access to the device by default, and there is no need to call this interface to apply. 68 * 69 * @param { string } deviceName - device name defined by USBDevice.name. It cannot be empty. 70 * @returns { Promise<boolean> } indicates if the device access permissions are granted. 71 * @throws { BusinessError } 401 - Parameter error. Possible causes: 72 * <br>1.Mandatory parameters are left unspecified. 73 * <br>2.Incorrect parameter types. 74 * @syscap SystemCapability.USB.USBManager 75 * @since 9 76 */ 77 function requestRight(deviceName: string): Promise<boolean>; 78 79 /** 80 * Remove the permission for a given application to access the USB device. 81 * The system application has access to the device by default, and calling this interface will not have any impact. 82 * 83 * @param { string } deviceName - device name defined by USBDevice.name. It cannot be empty. 84 * @returns { boolean } indicates if the device access permissions are removed. 85 * @throws { BusinessError } 401 - Parameter error. Possible causes: 86 * <br>1.Mandatory parameters are left unspecified. 87 * <br>2.Incorrect parameter types. 88 * @syscap SystemCapability.USB.USBManager 89 * @since 9 90 */ 91 function removeRight(deviceName: string): boolean; 92 93 /** 94 * Add device access permission. 95 * The system application has access to the device by default, and calling this interface will not have any impact. 96 * 97 * @param { string } bundleName - refers to application that require access permissions. It cannot be empty. 98 * @param { string } deviceName - device name defined by USBDevice.name. It cannot be empty. 99 * @returns { boolean } value to indicate whether the permission is granted. 100 * @throws { BusinessError } 401 - Parameter error. Possible causes: 101 * <br>1.Mandatory parameters are left unspecified. 102 * <br>2.Incorrect parameter types. 103 * @syscap SystemCapability.USB.USBManager 104 * @systemapi 105 * @since 9 106 * @deprecated since 12 107 * @useinstead ohos.usbManager/usbManager#addDeviceAccessRight 108 */ 109 function addRight(bundleName: string, deviceName: string): boolean; 110 111 /** 112 * Converts the string descriptor of a given USB function list to a numeric mask combination. 113 * 114 * @param { string } funcs - descriptor of the supported function list. It cannot be empty. 115 * @returns { number } the numeric mask combination of the function list. 116 * @throws { BusinessError } 401 - Parameter error. Possible causes: 117 * <br>1.Mandatory parameters are left unspecified. 118 * <br>2.Incorrect parameter types. 119 * @syscap SystemCapability.USB.USBManager 120 * @systemapi 121 * @since 9 122 * @deprecated since 12 123 * @useinstead ohos.usbManager/usbManager#getFunctionsFromString 124 */ 125 function usbFunctionsFromString(funcs: string): number; 126 127 /** 128 * Converts the numeric mask combination of a given USB function list to a string descriptor. 129 * 130 * @param { FunctionType } funcs - numeric mask combination of the function list. The type of funcs must be number. It cannot be empty. 131 * @returns { string } - descriptor of the supported function list. 132 * @throws { BusinessError } 401 - Parameter error. Possible causes: 133 * <br>1.Mandatory parameters are left unspecified. 134 * <br>2.Incorrect parameter types. 135 * @syscap SystemCapability.USB.USBManager 136 * @systemapi 137 * @since 9 138 * @deprecated since 12 139 * @useinstead ohos.usbManager/usbManager#getStringFromFunctions 140 */ 141 function usbFunctionsToString(funcs: FunctionType): string; 142 143 /** 144 * Sets the current USB function list in Device mode. 145 * 146 * @param { FunctionType } funcs - numeric mask combination of the supported function list. It cannot be empty. 147 * @returns { Promise<void> } the promise returned by the function. 148 * @throws { BusinessError } 401 - Parameter error. Possible causes: 149 * <br>1.Mandatory parameters are left unspecified. 150 * <br>2.Incorrect parameter types. 151 * @throws { BusinessError } 14400002 - Permission denied. The HDC is disabled by the system. 152 * @syscap SystemCapability.USB.USBManager 153 * @systemapi 154 * @since 9 155 * @deprecated since 12 156 * @useinstead ohos.usbManager/usbManager#setDeviceFunctions 157 */ 158 function setCurrentFunctions(funcs: FunctionType): Promise<void>; 159 160 /** 161 * Obtains the numeric mask combination for the current USB function list in Device mode. 162 * 163 * @returns { FunctionType } the numeric mask combination for the current USB function list in FunctionType. 164 * @syscap SystemCapability.USB.USBManager 165 * @systemapi 166 * @since 9 167 * @deprecated since 12 168 * @useinstead ohos.usbManager/usbManager#getDeviceFunctions 169 */ 170 function getCurrentFunctions(): FunctionType; 171 172 /* usb port functions begin */ 173 /** 174 * Obtains the USBPort list. 175 * 176 * @returns { Array<USBPort> } the USBPort list. 177 * @syscap SystemCapability.USB.USBManager 178 * @systemapi 179 * @since 9 180 * @deprecated since 12 181 * @useinstead ohos.usbManager/usbManager#getPortList 182 */ 183 function getPorts(): Array<USBPort>; 184 185 /** 186 * Gets the mask combination for the supported mode list of the specified USBPort. 187 * 188 * @param { number } portId - unique ID of the port. It cannot be empty. 189 * @returns { PortModeType } the mask combination for the supported mode list in PortModeType. 190 * @throws { BusinessError } 401 - Parameter error. Possible causes: 191 * <br>1.Mandatory parameters are left unspecified. 192 * <br>2.Incorrect parameter types. 193 * @syscap SystemCapability.USB.USBManager 194 * @systemapi 195 * @since 9 196 * @deprecated since 12 197 * @useinstead ohos.usbManager/usbManager#getPortSupportModes 198 */ 199 function getSupportedModes(portId: number): PortModeType; 200 201 /** 202 * Sets the role types supported by the specified USBPort, which can be powerRole (for charging) and dataRole (for data transfer). 203 * 204 * @param { number } portId - unique ID of the port. It cannot be empty. 205 * @param { PowerRoleType } powerRole - charging role. It cannot be empty. 206 * @param { DataRoleType } dataRole - data role. It cannot be empty. 207 * @returns { Promise<void> } the promise returned by the function. 208 * @throws { BusinessError } 401 - Parameter error. Possible causes: 209 * <br>1.Mandatory parameters are left unspecified. 210 * <br>2.Incorrect parameter types. 211 * @syscap SystemCapability.USB.USBManager 212 * @systemapi 213 * @since 9 214 * @deprecated since 12 215 * @useinstead ohos.usbManager/usbManager#setPortRoleTypes 216 */ 217 function setPortRoles(portId: number, powerRole: PowerRoleType, dataRole: DataRoleType): Promise<void>; 218 219 /** 220 * Add USB device access right. 221 * The system application has access to the device by default, and calling this interface will not have any impact. 222 * 223 * @permission ohos.permission.MANAGE_USB_CONFIG 224 * @param { string } tokenId - refers to application that require access permissions. It cannot be empty. 225 * @param { string } deviceName - device name defined by USBDevice.name. It cannot be empty. 226 * @returns { boolean } value to indicate whether the permission is granted. 227 * @throws { BusinessError } 401 - Parameter error. Possible causes: 228 * <br>1.Mandatory parameters are left unspecified. 229 * <br>2.Incorrect parameter types. 230 * @throws { BusinessError } 202 - Permission denied. Normal application do not have permission to use system api. 231 * @syscap SystemCapability.USB.USBManager 232 * @systemapi 233 * @since 12 234 */ 235 function addDeviceAccessRight(tokenId: string, deviceName: string): boolean; 236 237 /** 238 * Converts the string descriptor of a given USB function list to a numeric mask combination. 239 * 240 * @permission ohos.permission.MANAGE_USB_CONFIG 241 * @param { string } funcs - descriptor of the supported function list. It cannot be empty. 242 * @returns { number } the numeric mask combination of the function list. 243 * @throws { BusinessError } 401 - Parameter error. Possible causes: 244 * <br>1.Mandatory parameters are left unspecified. 245 * <br>2.Incorrect parameter types. 246 * @throws { BusinessError } 202 - Permission denied. Normal application do not have permission to use system api. 247 * @syscap SystemCapability.USB.USBManager 248 * @systemapi 249 * @since 12 250 */ 251 function getFunctionsFromString(funcs: string): number; 252 253 /** 254 * Converts the numeric mask combination of a given USB function list to a string descriptor. 255 * 256 * @permission ohos.permission.MANAGE_USB_CONFIG 257 * @param { FunctionType } funcs - numeric mask combination of the function list. It cannot be empty. 258 * @returns { string } - descriptor of the supported function list. 259 * @throws { BusinessError } 401 - Parameter error. Possible causes: 260 * <br>1.Mandatory parameters are left unspecified. 261 * <br>2.Incorrect parameter types. 262 * @throws { BusinessError } 202 - Permission denied. Normal application do not have permission to use system api. 263 * @syscap SystemCapability.USB.USBManager 264 * @systemapi 265 * @since 12 266 */ 267 function getStringFromFunctions(funcs: FunctionType): string; 268 269 /** 270 * Sets the current USB function list in Device mode. 271 * 272 * @permission ohos.permission.MANAGE_USB_CONFIG 273 * @param { FunctionType } funcs - numeric mask combination of the supported function list. It cannot be empty. 274 * @returns { Promise<void> } the promise returned by the function. 275 * @throws { BusinessError } 401 - Parameter error. Possible causes: 276 * <br>1.Mandatory parameters are left unspecified. 277 * <br>2.Incorrect parameter types. 278 * @throws { BusinessError } 202 - Permission denied. Normal application do not have permission to use system api. 279 * @throws { BusinessError } 14400002 - Permission denied. The HDC is disabled by the system. 280 * @throws { BusinessError } 14400006 - Unsupported operation. The function is not supported. 281 * @syscap SystemCapability.USB.USBManager 282 * @systemapi 283 * @since 12 284 */ 285 function setDeviceFunctions(funcs: FunctionType): Promise<void>; 286 287 /** 288 * Obtains the numeric mask combination for the current USB function list in Device mode. 289 * 290 * @permission ohos.permission.MANAGE_USB_CONFIG 291 * @returns { FunctionType } the numeric mask combination for the current USB function list in FunctionType. 292 * @throws { BusinessError } 202 - Permission denied. Normal application do not have permission to use system api. 293 * @syscap SystemCapability.USB.USBManager 294 * @systemapi 295 * @since 12 296 */ 297 function getDeviceFunctions(): FunctionType; 298 299 /* usb port functions begin */ 300 /** 301 * Obtains the USBPort list. 302 * 303 * @permission ohos.permission.MANAGE_USB_CONFIG 304 * @returns { Array<USBPort> } the USBPort list. 305 * @throws { BusinessError } 202 - Permission denied. Normal application do not have permission to use system api. 306 * @syscap SystemCapability.USB.USBManager 307 * @systemapi 308 * @since 12 309 */ 310 function getPortList(): Array<USBPort>; 311 312 /** 313 * Gets the mask combination for the supported mode list of the specified USBPort. 314 * 315 * @permission ohos.permission.MANAGE_USB_CONFIG 316 * @param { number } portId - unique ID of the port. It cannot be empty. 317 * @returns { PortModeType } the mask combination for the supported mode list in PortModeType. 318 * @throws { BusinessError } 401 - Parameter error. Possible causes: 319 * <br>1.Mandatory parameters are left unspecified. 320 * <br>2.Incorrect parameter types. 321 * @throws { BusinessError } 202 - Permission denied. Normal application do not have permission to use system api. 322 * @syscap SystemCapability.USB.USBManager 323 * @systemapi 324 * @since 12 325 */ 326 function getPortSupportModes(portId: number): PortModeType; 327 328 /** 329 * Sets the role types supported by the specified USBPort, which can be powerRole (for charging) and dataRole (for data transfer). 330 * 331 * @permission ohos.permission.MANAGE_USB_CONFIG 332 * @param { number } portId - unique ID of the port. It cannot be empty. 333 * @param { PowerRoleType } powerRole - charging role. It cannot be empty. 334 * @param { DataRoleType } dataRole - data role. It cannot be empty. 335 * @returns { Promise<void> } the promise returned by the function. 336 * @throws { BusinessError } 401 - Parameter error. Possible causes: 337 * <br>1.Mandatory parameters are left unspecified. 338 * <br>2.Incorrect parameter types. 339 * @throws { BusinessError } 202 - Permission denied. Normal application do not have permission to use system api. 340 * @throws { BusinessError } 14400003 - Unsupported operation. The current device does not support port role switching. 341 * @syscap SystemCapability.USB.USBManager 342 * @systemapi 343 * @since 12 344 */ 345 function setPortRoleTypes(portId: number, powerRole: PowerRoleType, dataRole: DataRoleType): Promise<void>; 346 347 /** 348 * Adds USB accessory access right. 349 * 350 * @permission ohos.permission.MANAGE_USB_CONFIG 351 * @param { number } tokenId - refers to application that require access permissions. It cannot be empty. 352 * @param { USBAccessory } accessory - USB accessory. It cannot be empty. 353 * @throws { BusinessError } 201 - The permission check failed. 354 * @throws { BusinessError } 202 - Permission denied. Normal application do not have permission to use system api. 355 * @throws { BusinessError } 401 - Parameter error. Possible causes: 356 * <br>1. Mandatory parameters are left unspecified. 357 * <br>2. Incorrect parameter types. 358 * @throws { BusinessError } 14400004 - Service exception. Possible causes: 359 * <br>1. No accessory is plugged in. 360 * @throws { BusinessError } 14400005 - Database operation exception. 361 * @syscap SystemCapability.USB.USBManager 362 * @systemapi 363 * @since 14 364 */ 365 function addAccessoryRight(tokenId: number, accessory: USBAccessory): void; 366 367 /* usb pipe functions begin */ 368 /** 369 * Claims a USB interface. 370 * 371 * @param { USBDevicePipe } pipe - device pipe, which is used to determine the bus number and device address. It cannot be empty. 372 * @param { USBInterface } iface - USB interface, which is used to determine the interface to claim. It cannot be empty. 373 * @param { boolean } [force] - optional parameter that determines whether to forcibly claim the USB interface. 374 * @returns { number } returns **0** if the USB interface is successfully claimed; returns an error code otherwise. 375 * @throws { BusinessError } 401 - Parameter error. Possible causes: 376 * <br>1.Mandatory parameters are left unspecified. 377 * <br>2.Incorrect parameter types. 378 * @syscap SystemCapability.USB.USBManager 379 * @since 9 380 */ 381 function claimInterface(pipe: USBDevicePipe, iface: USBInterface, force?: boolean): number; 382 383 /** 384 * Releases a USB interface. 385 * 386 * @param { USBDevicePipe } pipe - device pipe, which is used to determine the bus number and device address. It cannot be empty. 387 * @param { USBInterface } iface - USB interface, which is used to determine the interface to release. It cannot be empty. 388 * @returns { number } returns **0** if the USB interface is successfully released; returns an error code otherwise. 389 * @throws { BusinessError } 401 - Parameter error. Possible causes: 390 * <br>1.Mandatory parameters are left unspecified. 391 * <br>2.Incorrect parameter types. 392 * @syscap SystemCapability.USB.USBManager 393 * @since 9 394 */ 395 function releaseInterface(pipe: USBDevicePipe, iface: USBInterface): number; 396 397 /** 398 * Sets the device configuration. 399 * 400 * @param { USBDevicePipe } pipe - device pipe, which is used to determine the bus number and device address. It cannot be empty. 401 * @param { USBConfiguration } config - device configuration. It cannot be empty. 402 * @returns { number } returns **0** if the device configuration is successfully set; returns an error code otherwise. 403 * @throws { BusinessError } 401 - Parameter error. Possible causes: 404 * <br>1.Mandatory parameters are left unspecified. 405 * <br>2.Incorrect parameter types. 406 * @syscap SystemCapability.USB.USBManager 407 * @since 9 408 */ 409 function setConfiguration(pipe: USBDevicePipe, config: USBConfiguration): number; 410 411 /** 412 * Sets a USB interface. 413 * 414 * @param { USBDevicePipe } pipe - device pipe, which is used to determine the bus number and device address. It cannot be empty. 415 * @param { USBInterface } iface - USB interface, which is used to determine the interface to set. It cannot be empty. 416 * @returns { number } returns **0** if the USB interface is successfully set; return an error code otherwise. 417 * @throws { BusinessError } 401 - Parameter error. Possible causes: 418 * <br>1.Mandatory parameters are left unspecified. 419 * <br>2.Incorrect parameter types. 420 * @syscap SystemCapability.USB.USBManager 421 * @since 9 422 */ 423 function setInterface(pipe: USBDevicePipe, iface: USBInterface): number; 424 425 /** 426 * Obtains the raw USB descriptor. 427 * 428 * @param { USBDevicePipe } pipe - device pipe, which is used to determine the bus number and device address. It cannot be empty. 429 * @returns { Uint8Array } returns the raw descriptor data. 430 * @throws { BusinessError } 401 - Parameter error. Possible causes: 431 * <br>1.Mandatory parameters are left unspecified. 432 * <br>2.Incorrect parameter types. 433 * @syscap SystemCapability.USB.USBManager 434 * @since 9 435 */ 436 function getRawDescriptor(pipe: USBDevicePipe): Uint8Array; 437 438 /** 439 * Obtains the file descriptor. 440 * 441 * @param { USBDevicePipe } pipe - device pipe, which is used to determine the USB device. It cannot be empty. 442 * @returns { number } returns the file descriptor of the USB device. 443 * @throws { BusinessError } 401 - Parameter error. Possible causes: 444 * <br>1.Mandatory parameters are left unspecified. 445 * <br>2.Incorrect parameter types. 446 * @syscap SystemCapability.USB.USBManager 447 * @since 9 448 */ 449 function getFileDescriptor(pipe: USBDevicePipe): number; 450 451 /** 452 * Performs control transfer. 453 * 454 * @param { USBDevicePipe } pipe - device pipe, which is used to determine the USB device. It cannot be empty. 455 * @param { USBControlParams } controlparam - control transfer parameters. It cannot be empty. 456 * @param { number } [timeout] - timeout duration. This parameter is optional. The default value is **0**, indicating no timeout. 457 * @returns { Promise<number> } returns the size of the transmitted or received data block if the control transfer is successful; 458 * return -1 if an exception occurs. 459 * @throws { BusinessError } 401 - Parameter error. Possible causes: 460 * <br>1.Mandatory parameters are left unspecified. 461 * <br>2.Incorrect parameter types. 462 * @syscap SystemCapability.USB.USBManager 463 * @since 9 464 * @deprecated since 12 465 * @useinstead ohos.usbManager/usbManager#usbControlTransfer 466 */ 467 function controlTransfer(pipe: USBDevicePipe, controlparam: USBControlParams, timeout?: number): Promise<number>; 468 469 /** 470 * Performs usb control transfer. 471 * 472 * @param { USBDevicePipe } pipe - device pipe, which is used to determine the USB device. It cannot be empty. 473 * @param { USBDeviceRequestParams } requestparam - control transfer parameters. It cannot be empty. 474 * @param { number } [timeout] - timeout duration. This parameter is optional. The default value is **0**, indicating no timeout. 475 * @returns { Promise<number> } returns the size of the transmitted or received data block if the control transfer is successful; 476 * return -1 if an exception occurs. 477 * @throws { BusinessError } 401 - Parameter error. Possible causes: 478 * <br>1.Mandatory parameters are left unspecified. 479 * <br>2.Incorrect parameter types. 480 * @syscap SystemCapability.USB.USBManager 481 * @since 12 482 */ 483 function usbControlTransfer(pipe: USBDevicePipe, requestparam: USBDeviceRequestParams, timeout?: number): Promise<number>; 484 485 /** 486 * Performs bulk transfer. 487 * 488 * @param { USBDevicePipe } pipe - device pipe, which is used to determine the USB device. It cannot be empty. 489 * @param { USBEndpoint } endpoint - USB endpoint, which is used to determine the USB port for data transfer. It cannot be empty. 490 * @param { Uint8Array } buffer - buffer for writing or reading data. It cannot be empty. 491 * @param { number } [timeout] - timeout duration. This parameter is optional. The default value is **0**, indicating no timeout. 492 * @returns { Promise<number> } the size of the transmitted or received data block if the control transfer is successful; 493 * return -1 if an exception occurs. 494 * @throws { BusinessError } 401 - Parameter error. Possible causes: 495 * <br>1.Mandatory parameters are left unspecified. 496 * <br>2.Incorrect parameter types. 497 * @syscap SystemCapability.USB.USBManager 498 * @since 9 499 */ 500 function bulkTransfer( 501 pipe: USBDevicePipe, 502 endpoint: USBEndpoint, 503 buffer: Uint8Array, 504 timeout?: number 505 ): Promise<number>; 506 507 /** 508 * Closes a USB device pipe. 509 * 510 * @param { USBDevicePipe } pipe - device pipe, which is used to determine the USB device. It cannot be empty. 511 * @returns { number } returns **0** if the USB device pipe is closed successfully; return an error code otherwise. 512 * @throws { BusinessError } 401 - Parameter error. Possible causes: 513 * <br>1.Mandatory parameters are left unspecified. 514 * <br>2.Incorrect parameter types. 515 * @syscap SystemCapability.USB.USBManager 516 * @since 9 517 */ 518 function closePipe(pipe: USBDevicePipe): number; 519 520 /** 521 * Checks whether the application has the right to access the USB accessory. 522 * 523 * @param { USBAccessory } accessory - USB accessory. It cannot be empty. 524 * @returns { boolean } indicates if the user has the right to access the USB accessory. 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 } 14400004 - Service exception. Possible causes: 529 * <br>1. No accessory is plugged in. 530 * @throws { BusinessError } 14400005 - Database operation exception. 531 * @throws { BusinessError } 14401001 - The target USBAccessory not matched. 532 * @syscap SystemCapability.USB.USBManager 533 * @since 14 534 */ 535 function hasAccessoryRight(accessory: USBAccessory): boolean; 536 537 /** 538 * Requests the right for a given application to access the USB accessory. 539 * 540 * @param { USBAccessory } accessory - USB accessory. It cannot be empty. 541 * @returns { Promise<boolean> } indicates if the USB accessory access right are granted. 542 * @throws { BusinessError } 401 - Parameter error. Possible causes: 543 * <br>1. Mandatory parameters are left unspecified. 544 * <br>2. Incorrect parameter types. 545 * @throws { BusinessError } 14400004 - Service exception. Possible causes: 546 * <br>1. No accessory is plugged in. 547 * @throws { BusinessError } 14400005 - Database operation exception. 548 * @throws { BusinessError } 14401001 - The target USBAccessory not matched. 549 * @syscap SystemCapability.USB.USBManager 550 * @since 14 551 */ 552 function requestAccessoryRight(accessory: USBAccessory): Promise<boolean>; 553 554 /** 555 * Cancels the right for a given application to access the USB accessory. 556 * 557 * @param { USBAccessory } accessory - USB accessory. It cannot be empty. 558 * @throws { BusinessError } 401 - Parameter error. Possible causes: 559 * <br>1. Mandatory parameters are left unspecified. 560 * <br>2. Incorrect parameter types. 561 * @throws { BusinessError } 14400004 - Service exception. Possible causes: 562 * <br>1. No accessory is plugged in. 563 * @throws { BusinessError } 14400005 - Database operation exception. 564 * @throws { BusinessError } 14401001 - The target USBAccessory not matched. 565 * @syscap SystemCapability.USB.USBManager 566 * @since 14 567 */ 568 function cancelAccessoryRight(accessory: USBAccessory): void; 569 570 /** 571 * Obtains the USB Accessory list. 572 * 573 * @returns { Array<Readonly<USBAccessory>> } USB accessory list. 574 * @throws { BusinessError } 14400004 - Service exception. Possible causes: 575 * <br>1. No accessory is plugged in. 576 * @syscap SystemCapability.USB.USBManager 577 * @since 14 578 */ 579 function getAccessoryList(): Array<Readonly<USBAccessory>>; 580 581 /** 582 * Obtains the accessory handle and opens accessory file descriptor. 583 * 584 * @param { USBAccessory } accessory - accessory, which is used to determine the accessory. It cannot be empty. 585 * @returns { USBAccessoryHandle } returns the handle of the accessory. 586 * @throws { BusinessError } 401 - Parameter error. Possible causes: 587 * <br>1. Mandatory parameters are left unspecified. 588 * <br>2. Incorrect parameter types. 589 * @throws { BusinessError } 14400001 - Permission denied. Call requestAccessoryRight to get the right first. 590 * @throws { BusinessError } 14400004 - Service exception. Possible causes: 591 * <br>1. No accessory is plugged in. 592 * @throws { BusinessError } 14401001 - The target USBAccessory not matched. 593 * @throws { BusinessError } 14401002 - Failed to open the native accessory node. 594 * @throws { BusinessError } 14401003 - Cannot reopen the accessory. 595 * @syscap SystemCapability.USB.USBManager 596 * @since 14 597 */ 598 function openAccessory(accessory: USBAccessory): USBAccessoryHandle; 599 600 /** 601 * Closes the accessory file descriptor. 602 * 603 * @param { USBAccessoryHandle } accessoryHandle - Accessory handle to be closed. 604 * @throws { BusinessError } 401 - Parameter error. Possible causes: 605 * <br>1. Mandatory parameters are left unspecified. 606 * <br>2. Incorrect parameter types. 607 * @throws { BusinessError } 14400004 - Service exception. Possible causes: 608 * <br>1. No accessory is plugged in. 609 * @syscap SystemCapability.USB.USBManager 610 * @since 14 611 */ 612 function closeAccessory(accessoryHandle: USBAccessoryHandle): void; 613 614 /** 615 * Represents the USB endpoint from which data is sent or received. You can obtain the USB endpoint through USBInterface. 616 * 617 * @typedef USBEndpoint 618 * @syscap SystemCapability.USB.USBManager 619 * @since 9 620 */ 621 interface USBEndpoint { 622 /** 623 * Endpoint address 624 * 625 * @type { number } 626 * @syscap SystemCapability.USB.USBManager 627 * @since 9 628 */ 629 address: number; 630 631 /** 632 * Endpoint attributes 633 * 634 * @type { number } 635 * @syscap SystemCapability.USB.USBManager 636 * @since 9 637 */ 638 attributes: number; 639 640 /** 641 * Endpoint interval 642 * 643 * @type { number } 644 * @syscap SystemCapability.USB.USBManager 645 * @since 9 646 */ 647 interval: number; 648 649 /** 650 * Maximum size of data packets on the endpoint 651 * 652 * @type { number } 653 * @syscap SystemCapability.USB.USBManager 654 * @since 9 655 */ 656 maxPacketSize: number; 657 658 /** 659 * Endpoint direction 660 * 661 * @type { USBRequestDirection } 662 * @syscap SystemCapability.USB.USBManager 663 * @since 9 664 */ 665 direction: USBRequestDirection; 666 667 /** 668 * Endpoint number 669 * 670 * @type { number } 671 * @syscap SystemCapability.USB.USBManager 672 * @since 9 673 */ 674 number: number; 675 676 /** 677 * Endpoint type 678 * 679 * @type { number } 680 * @syscap SystemCapability.USB.USBManager 681 * @since 9 682 */ 683 type: number; 684 685 /** 686 * Unique ID defined by USBInterface.id, which indicates the interface to which the endpoint belongs 687 * 688 * @type { number } 689 * @syscap SystemCapability.USB.USBManager 690 * @since 9 691 */ 692 interfaceId: number; 693 } 694 695 /** 696 * Represents a USB interface. One config can contain multiple **USBInterface** instances, each providing a specific function. 697 * 698 * @typedef USBInterface 699 * @syscap SystemCapability.USB.USBManager 700 * @since 9 701 */ 702 interface USBInterface { 703 /** 704 * Unique ID of the USB interface 705 * 706 * @type { number } 707 * @syscap SystemCapability.USB.USBManager 708 * @since 9 709 */ 710 id: number; 711 712 /** 713 * Interface protocol 714 * 715 * @type { number } 716 * @syscap SystemCapability.USB.USBManager 717 * @since 9 718 */ 719 protocol: number; 720 721 /** 722 * Device type 723 * 724 * @type { number } 725 * @syscap SystemCapability.USB.USBManager 726 * @since 9 727 */ 728 clazz: number; 729 730 /** 731 * Device subclass 732 * 733 * @type { number } 734 * @syscap SystemCapability.USB.USBManager 735 * @since 9 736 */ 737 subClass: number; 738 739 /** 740 * Alternation between descriptors of the same USB interface 741 * 742 * @type { number } 743 * @syscap SystemCapability.USB.USBManager 744 * @since 9 745 */ 746 alternateSetting: number; 747 748 /** 749 * Interface name 750 * 751 * @type { string } 752 * @syscap SystemCapability.USB.USBManager 753 * @since 9 754 */ 755 name: string; 756 757 /** 758 * USBEndpoint that belongs to the USB interface 759 * 760 * @type { Array<USBEndpoint> } 761 * @syscap SystemCapability.USB.USBManager 762 * @since 9 763 */ 764 endpoints: Array<USBEndpoint>; 765 } 766 767 /** 768 * USB configuration. One USBDevice can contain multiple USBConfiguration instances. 769 * 770 * @typedef USBConfiguration 771 * @syscap SystemCapability.USB.USBManager 772 * @since 9 773 */ 774 interface USBConfiguration { 775 /** 776 * Unique ID of the USB configuration 777 * 778 * @type { number } 779 * @syscap SystemCapability.USB.USBManager 780 * @since 9 781 */ 782 id: number; 783 784 /** 785 * Configuration attributes 786 * 787 * @type { number } 788 * @syscap SystemCapability.USB.USBManager 789 * @since 9 790 */ 791 attributes: number; 792 793 /** 794 * Maximum power consumption, in mA 795 * 796 * @type { number } 797 * @syscap SystemCapability.USB.USBManager 798 * @since 9 799 */ 800 maxPower: number; 801 802 /** 803 * Configuration name, which can be left empty 804 * 805 * @type { string } 806 * @syscap SystemCapability.USB.USBManager 807 * @since 9 808 */ 809 name: string; 810 811 /** 812 * Support for remote wakeup 813 * 814 * @type { boolean } 815 * @syscap SystemCapability.USB.USBManager 816 * @since 9 817 */ 818 isRemoteWakeup: boolean; 819 820 /** 821 * Support for independent power supplies 822 * 823 * @type { boolean } 824 * @syscap SystemCapability.USB.USBManager 825 * @since 9 826 */ 827 isSelfPowered: boolean; 828 829 /** 830 * Supported interface attributes 831 * 832 * @type { Array<USBInterface> } 833 * @syscap SystemCapability.USB.USBManager 834 * @since 9 835 */ 836 interfaces: Array<USBInterface>; 837 } 838 839 /** 840 * Represents a USB device. 841 * 842 * @typedef USBDevice 843 * @syscap SystemCapability.USB.USBManager 844 * @since 9 845 */ 846 interface USBDevice { 847 /** 848 * Bus address 849 * 850 * @type { number } 851 * @syscap SystemCapability.USB.USBManager 852 * @since 9 853 */ 854 busNum: number; 855 856 /** 857 * Device address 858 * 859 * @type { number } 860 * @syscap SystemCapability.USB.USBManager 861 * @since 9 862 */ 863 devAddress: number; 864 865 /** 866 * Device SN 867 * 868 * @type { string } 869 * @syscap SystemCapability.USB.USBManager 870 * @since 9 871 */ 872 serial: string; 873 874 /** 875 * Device name 876 * 877 * @type { string } 878 * @syscap SystemCapability.USB.USBManager 879 * @since 9 880 */ 881 name: string; 882 883 /** 884 * Device manufacturer 885 * 886 * @type { string } 887 * @syscap SystemCapability.USB.USBManager 888 * @since 9 889 */ 890 manufacturerName: string; 891 892 /** 893 * Product information 894 * 895 * @type { string } 896 * @syscap SystemCapability.USB.USBManager 897 * @since 9 898 */ 899 productName: string; 900 901 /** 902 * Product version 903 * 904 * @type { string } 905 * @syscap SystemCapability.USB.USBManager 906 * @since 9 907 */ 908 version: string; 909 910 /** 911 * Vendor ID 912 * 913 * @type { number } 914 * @syscap SystemCapability.USB.USBManager 915 * @since 9 916 */ 917 vendorId: number; 918 919 /** 920 * Product ID 921 * 922 * @type { number } 923 * @syscap SystemCapability.USB.USBManager 924 * @since 9 925 */ 926 productId: number; 927 928 /** 929 * Device class 930 * 931 * @type { number } 932 * @syscap SystemCapability.USB.USBManager 933 * @since 9 934 */ 935 clazz: number; 936 937 /** 938 * Device subclass 939 * 940 * @type { number } 941 * @syscap SystemCapability.USB.USBManager 942 * @since 9 943 */ 944 subClass: number; 945 946 /** 947 * Device protocol code 948 * 949 * @type { number } 950 * @syscap SystemCapability.USB.USBManager 951 * @since 9 952 */ 953 protocol: number; 954 955 /** 956 * Device configuration descriptor information 957 * 958 * @type { Array<USBConfiguration> } 959 * @syscap SystemCapability.USB.USBManager 960 * @since 9 961 */ 962 configs: Array<USBConfiguration>; 963 } 964 965 /** 966 * Represents a USB device pipe, which is used to determine the USB device. 967 * 968 * @typedef USBDevicePipe 969 * @syscap SystemCapability.USB.USBManager 970 * @since 9 971 */ 972 interface USBDevicePipe { 973 /** 974 * Bus address. 975 * 976 * @type { number } 977 * @syscap SystemCapability.USB.USBManager 978 * @since 9 979 */ 980 busNum: number; 981 982 /** 983 * Device address 984 * 985 * @type { number } 986 * @syscap SystemCapability.USB.USBManager 987 * @since 9 988 */ 989 devAddress: number; 990 } 991 992 /** 993 * Enumerates power role types. 994 * 995 * @enum { number } 996 * @syscap SystemCapability.USB.USBManager 997 * @systemapi 998 * @since 9 999 */ 1000 export enum PowerRoleType { 1001 /** 1002 * None 1003 * 1004 * @syscap SystemCapability.USB.USBManager 1005 * @systemapi 1006 * @since 9 1007 */ 1008 NONE = 0, 1009 1010 /** 1011 * External power supply 1012 * 1013 * @syscap SystemCapability.USB.USBManager 1014 * @systemapi 1015 * @since 9 1016 */ 1017 SOURCE = 1, 1018 1019 /** 1020 * Internal power supply 1021 * 1022 * @syscap SystemCapability.USB.USBManager 1023 * @systemapi 1024 * @since 9 1025 */ 1026 SINK = 2 1027 } 1028 1029 /** 1030 * Enumerates data role types. 1031 * 1032 * @enum { number } 1033 * @syscap SystemCapability.USB.USBManager 1034 * @systemapi 1035 * @since 9 1036 */ 1037 export enum DataRoleType { 1038 /** 1039 * None 1040 * 1041 * @syscap SystemCapability.USB.USBManager 1042 * @systemapi 1043 * @since 9 1044 */ 1045 NONE = 0, 1046 1047 /** 1048 * Host mode 1049 * 1050 * @syscap SystemCapability.USB.USBManager 1051 * @systemapi 1052 * @since 9 1053 */ 1054 HOST = 1, 1055 1056 /** 1057 * Device mode 1058 * 1059 * @syscap SystemCapability.USB.USBManager 1060 * @systemapi 1061 * @since 9 1062 */ 1063 DEVICE = 2 1064 } 1065 1066 /** 1067 * Enumerates port mode types 1068 * 1069 * @enum { number } 1070 * @syscap SystemCapability.USB.USBManager 1071 * @systemapi 1072 * @since 9 1073 */ 1074 export enum PortModeType { 1075 /** 1076 * None 1077 * 1078 * @syscap SystemCapability.USB.USBManager 1079 * @systemapi 1080 * @since 9 1081 */ 1082 NONE = 0, 1083 1084 /** 1085 * Upstream facing port, which functions as the sink of power supply 1086 * 1087 * @syscap SystemCapability.USB.USBManager 1088 * @systemapi 1089 * @since 9 1090 */ 1091 UFP = 1, 1092 1093 /** 1094 * Downstream facing port, which functions as the source of power supply 1095 * 1096 * @syscap SystemCapability.USB.USBManager 1097 * @systemapi 1098 * @since 9 1099 */ 1100 DFP = 2, 1101 1102 /** 1103 * Dynamic reconfiguration port (DRP), which can function as the DFP (host) or UFP (device). It is not supported currently. 1104 * 1105 * @syscap SystemCapability.USB.USBManager 1106 * @systemapi 1107 * @since 9 1108 */ 1109 DRP = 3, 1110 1111 /** 1112 * Not supported currently 1113 * 1114 * @syscap SystemCapability.USB.USBManager 1115 * @systemapi 1116 * @since 9 1117 */ 1118 NUM_MODES = 4 1119 } 1120 1121 /** 1122 * Enumerates USB device port roles. 1123 * 1124 * @typedef USBPortStatus 1125 * @syscap SystemCapability.USB.USBManager 1126 * @systemapi 1127 * @since 9 1128 */ 1129 interface USBPortStatus { 1130 /** 1131 * USB mode 1132 * 1133 * @type { number } 1134 * @syscap SystemCapability.USB.USBManager 1135 * @systemapi 1136 * @since 9 1137 */ 1138 currentMode: number; 1139 1140 /** 1141 * Power role 1142 * 1143 * @type { number } 1144 * @syscap SystemCapability.USB.USBManager 1145 * @systemapi 1146 * @since 9 1147 */ 1148 currentPowerRole: number; 1149 1150 /** 1151 * Data role 1152 * 1153 * @type { number } 1154 * @syscap SystemCapability.USB.USBManager 1155 * @systemapi 1156 * @since 9 1157 */ 1158 currentDataRole: number; 1159 } 1160 1161 /** 1162 * Represents a USB device port. 1163 * 1164 * @typedef USBPort 1165 * @syscap SystemCapability.USB.USBManager 1166 * @systemapi 1167 * @since 9 1168 */ 1169 interface USBPort { 1170 /** 1171 * Unique ID of the USB port 1172 * 1173 * @type { number } 1174 * @syscap SystemCapability.USB.USBManager 1175 * @systemapi 1176 * @since 9 1177 */ 1178 id: number; 1179 1180 /** 1181 * Mask combination for the supported mode list of the USB port 1182 * 1183 * @type { PortModeType } 1184 * @syscap SystemCapability.USB.USBManager 1185 * @systemapi 1186 * @since 9 1187 */ 1188 supportedModes: PortModeType; 1189 1190 /** 1191 * USB port role 1192 * 1193 * @type { USBPortStatus } 1194 * @syscap SystemCapability.USB.USBManager 1195 * @systemapi 1196 * @since 9 1197 */ 1198 status: USBPortStatus; 1199 } 1200 1201 /** 1202 * Represents control transfer parameters. 1203 * 1204 * @typedef USBControlParams 1205 * @syscap SystemCapability.USB.USBManager 1206 * @since 9 1207 */ 1208 interface USBControlParams { 1209 /** 1210 * Request type 1211 * 1212 * @type { number } 1213 * @syscap SystemCapability.USB.USBManager 1214 * @since 9 1215 */ 1216 request: number; 1217 1218 /** 1219 * Request target type 1220 * 1221 * @type { USBRequestTargetType } 1222 * @syscap SystemCapability.USB.USBManager 1223 * @since 9 1224 */ 1225 target: USBRequestTargetType; 1226 1227 /** 1228 * Control request type 1229 * 1230 * @type { USBControlRequestType } 1231 * @syscap SystemCapability.USB.USBManager 1232 * @since 9 1233 */ 1234 reqType: USBControlRequestType; 1235 1236 /** 1237 * Request parameter value 1238 * 1239 * @type { number } 1240 * @syscap SystemCapability.USB.USBManager 1241 * @since 9 1242 */ 1243 value: number; 1244 1245 /** 1246 * Index of the parameter value 1247 * 1248 * @type { number } 1249 * @syscap SystemCapability.USB.USBManager 1250 * @since 9 1251 */ 1252 index: number; 1253 1254 /** 1255 * Data written to or read from the buffer 1256 * 1257 * @type { Uint8Array } 1258 * @syscap SystemCapability.USB.USBManager 1259 * @since 9 1260 */ 1261 data: Uint8Array; 1262 } 1263 1264 /** 1265 * Represents control transfer parameters. 1266 * 1267 * @typedef USBDeviceRequestParams 1268 * @syscap SystemCapability.USB.USBManager 1269 * @since 12 1270 */ 1271 interface USBDeviceRequestParams { 1272 /** 1273 * Bit map request type 1274 * 1275 * @type { number } 1276 * @syscap SystemCapability.USB.USBManager 1277 * @since 12 1278 */ 1279 bmRequestType: number; 1280 1281 /** 1282 * Byte request 1283 * 1284 * @type { number } 1285 * @syscap SystemCapability.USB.USBManager 1286 * @since 12 1287 */ 1288 bRequest: number; 1289 1290 /** 1291 * Request parameter word value 1292 * 1293 * @type { number } 1294 * @syscap SystemCapability.USB.USBManager 1295 * @since 12 1296 */ 1297 wValue: number; 1298 1299 /** 1300 * Word index of the parameter value 1301 * 1302 * @type { number } 1303 * @syscap SystemCapability.USB.USBManager 1304 * @since 12 1305 */ 1306 wIndex: number; 1307 1308 /** 1309 * Word length of the parameter value 1310 * 1311 * @type { number } 1312 * @syscap SystemCapability.USB.USBManager 1313 * @since 12 1314 */ 1315 wLength: number; 1316 1317 /** 1318 * Data written to or read from the buffer 1319 * 1320 * @type { Uint8Array } 1321 * @syscap SystemCapability.USB.USBManager 1322 * @since 12 1323 */ 1324 data: Uint8Array; 1325 } 1326 1327 /** 1328 * Enumerates USB request target types. 1329 * 1330 * @enum { number } 1331 * @syscap SystemCapability.USB.USBManager 1332 * @since 9 1333 */ 1334 export enum USBRequestTargetType { 1335 /** 1336 * USB device 1337 * 1338 * @syscap SystemCapability.USB.USBManager 1339 * @since 9 1340 */ 1341 USB_REQUEST_TARGET_DEVICE = 0, 1342 1343 /** 1344 * USB interface 1345 * 1346 * @syscap SystemCapability.USB.USBManager 1347 * @since 9 1348 */ 1349 USB_REQUEST_TARGET_INTERFACE = 1, 1350 1351 /** 1352 * Endpoint 1353 * 1354 * @syscap SystemCapability.USB.USBManager 1355 * @since 9 1356 */ 1357 USB_REQUEST_TARGET_ENDPOINT = 2, 1358 1359 /** 1360 * Others 1361 * 1362 * @syscap SystemCapability.USB.USBManager 1363 * @since 9 1364 */ 1365 USB_REQUEST_TARGET_OTHER = 3 1366 } 1367 1368 /** 1369 * Enumerates control request types. 1370 * 1371 * @enum { number } 1372 * @syscap SystemCapability.USB.USBManager 1373 * @since 9 1374 */ 1375 export enum USBControlRequestType { 1376 /** 1377 * Standard 1378 * 1379 * @syscap SystemCapability.USB.USBManager 1380 * @since 9 1381 */ 1382 USB_REQUEST_TYPE_STANDARD = 0, 1383 1384 /** 1385 * Class 1386 * 1387 * @syscap SystemCapability.USB.USBManager 1388 * @since 9 1389 */ 1390 USB_REQUEST_TYPE_CLASS = 1, 1391 1392 /** 1393 * Vendor 1394 * 1395 * @syscap SystemCapability.USB.USBManager 1396 * @since 9 1397 */ 1398 USB_REQUEST_TYPE_VENDOR = 2 1399 } 1400 1401 /** 1402 * Enumerates request directions. 1403 * 1404 * @enum { number } 1405 * @syscap SystemCapability.USB.USBManager 1406 * @since 9 1407 */ 1408 export enum USBRequestDirection { 1409 /** 1410 * Request for writing data from the host to the device 1411 * 1412 * @syscap SystemCapability.USB.USBManager 1413 * @since 9 1414 */ 1415 USB_REQUEST_DIR_TO_DEVICE = 0, 1416 1417 /** 1418 * Request for reading data from the device to the host 1419 * 1420 * @syscap SystemCapability.USB.USBManager 1421 * @since 9 1422 */ 1423 USB_REQUEST_DIR_FROM_DEVICE = 0x80 1424 } 1425 1426 /** 1427 * Enumerates function modes. 1428 * 1429 * @enum { number } 1430 * @syscap SystemCapability.USB.USBManager 1431 * @systemapi 1432 * @since 9 1433 */ 1434 export enum FunctionType { 1435 /** 1436 * None 1437 * 1438 * @syscap SystemCapability.USB.USBManager 1439 * @systemapi 1440 * @since 9 1441 */ 1442 NONE = 0, 1443 1444 /** 1445 * Serial port device 1446 * 1447 * @syscap SystemCapability.USB.USBManager 1448 * @systemapi 1449 * @since 9 1450 */ 1451 ACM = 1, 1452 1453 /** 1454 * Ethernet port device 1455 * 1456 * @syscap SystemCapability.USB.USBManager 1457 * @systemapi 1458 * @since 9 1459 */ 1460 ECM = 2, 1461 1462 /** 1463 * HDC device 1464 * 1465 * @syscap SystemCapability.USB.USBManager 1466 * @systemapi 1467 * @since 9 1468 */ 1469 HDC = 4, 1470 1471 /** 1472 * MTP device 1473 * 1474 * @syscap SystemCapability.USB.USBManager 1475 * @systemapi 1476 * @since 9 1477 */ 1478 MTP = 8, 1479 1480 /** 1481 * PTP device 1482 * 1483 * @syscap SystemCapability.USB.USBManager 1484 * @systemapi 1485 * @since 9 1486 */ 1487 PTP = 16, 1488 1489 /** 1490 * RNDIS device 1491 * 1492 * @syscap SystemCapability.USB.USBManager 1493 * @systemapi 1494 * @since 9 1495 */ 1496 RNDIS = 32, 1497 1498 /** 1499 * MIDI device 1500 * 1501 * @syscap SystemCapability.USB.USBManager 1502 * @systemapi 1503 * @since 9 1504 */ 1505 MIDI = 64, 1506 1507 /** 1508 * Audio source device 1509 * 1510 * @syscap SystemCapability.USB.USBManager 1511 * @systemapi 1512 * @since 9 1513 */ 1514 AUDIO_SOURCE = 128, 1515 1516 /** 1517 * NCM device 1518 * 1519 * @syscap SystemCapability.USB.USBManager 1520 * @systemapi 1521 * @since 9 1522 */ 1523 NCM = 256 1524 } 1525 1526 /** 1527 * Represents a USB Accessory. 1528 * 1529 * @typedef USBAccessory 1530 * @syscap SystemCapability.USB.USBManager 1531 * @since 14 1532 */ 1533 interface USBAccessory { 1534 /** 1535 * The manufacturer name of the accessory. 1536 * 1537 * @type { string } 1538 * @syscap SystemCapability.USB.USBManager 1539 * @since 14 1540 */ 1541 manufacturer: string; 1542 1543 /** 1544 * The product of the accessory. 1545 * 1546 * @type { string } 1547 * @syscap SystemCapability.USB.USBManager 1548 * @since 14 1549 */ 1550 product: string; 1551 1552 /** 1553 * The user visible description of the accessory. 1554 * 1555 * @type { string } 1556 * @syscap SystemCapability.USB.USBManager 1557 * @since 14 1558 */ 1559 description: string; 1560 1561 /** 1562 * The version of the accessory. 1563 * 1564 * @type { string } 1565 * @syscap SystemCapability.USB.USBManager 1566 * @since 14 1567 */ 1568 version: string; 1569 1570 /** 1571 * The serial number of the accessory. 1572 * 1573 * @type { string } 1574 * @syscap SystemCapability.USB.USBManager 1575 * @since 14 1576 */ 1577 serialNumber: string; 1578 } 1579 1580 /** 1581 * Handle of accessory. 1582 * 1583 * @typedef USBAccessoryHandle 1584 * @syscap SystemCapability.USB.USBManager 1585 * @since 14 1586 */ 1587 interface USBAccessoryHandle { 1588 /** 1589 * The file descriptor of the accessory.The valid USBAccessoryHandle.accessoryFd is a positive value. 1590 * 1591 * @type { number } 1592 * @syscap SystemCapability.USB.USBManager 1593 * @since 14 1594 */ 1595 accessoryFd: number; 1596 } 1597} 1598 1599export default usbManager; 1600