diff --git a/drivers/external_device_manager/usb/libusb.ndk.json b/drivers/external_device_manager/usb/libusb.ndk.json index eb677bfeee99b3d144db38b9b9c6af425d602ca6..55f578e408bfb68ec45a13be05dca735cc700654 100644 --- a/drivers/external_device_manager/usb/libusb.ndk.json +++ b/drivers/external_device_manager/usb/libusb.ndk.json @@ -46,5 +46,8 @@ }, { "name": "OH_Usb_DestroyDeviceMemMap" + }, + { + "name": "OH_Usb_GetDevices" } ] \ No newline at end of file diff --git a/drivers/external_device_manager/usb/usb_ddk_api.h b/drivers/external_device_manager/usb/usb_ddk_api.h index 1ee732e19db29b923f2d6ee8b3bff45a7c593aae..cd6213272ef4e910bebe2ea9a7693ef277bf8915 100644 --- a/drivers/external_device_manager/usb/usb_ddk_api.h +++ b/drivers/external_device_manager/usb/usb_ddk_api.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -284,6 +284,19 @@ int32_t OH_Usb_CreateDeviceMemMap(uint64_t deviceId, size_t size, UsbDeviceMemMa * @version 1.0 */ void OH_Usb_DestroyDeviceMemMap(UsbDeviceMemMap *devMmap); + +/** + * @brief Obtain USB devices. + * + * @permission ohos.permission.ACCESS_DDK_USB + * @param devices USB device array. + * @return {@link USB_DDK_SUCCESS} the operation is successful. + * {@link USB_DDK_NO_PERM} permission check failed. + * {@link USB_DDK_INVALID_OPERATION} connect usb ddk service failed. + * {@link USB_DDK_INVALID_PARAMETER} devices is null. + * @since 16 + */ +int32_t OH_Usb_GetDevices(struct Usb_DeviceArray *devices); /** @} */ #ifdef __cplusplus } diff --git a/drivers/external_device_manager/usb/usb_ddk_types.h b/drivers/external_device_manager/usb/usb_ddk_types.h index 8c51cd7263f1f62c16ac69a271f1206cd926f323..7378ca4542b0ff541069b1ccaf41d7e7bbb4eb2d 100644 --- a/drivers/external_device_manager/usb/usb_ddk_types.h +++ b/drivers/external_device_manager/usb/usb_ddk_types.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -325,6 +325,18 @@ typedef enum { /** @error Transmission timeout. */ USB_DDK_TIMEOUT = 27400004, } UsbDdkErrCode; + +/** + * @brief all usb devices. + * + * @since 16 + */ +typedef struct Usb_DeviceArray { + /** device id array */ + uint64_t* deviceIds; + /** Number of devices. If the value is 0, no device exists */ + uint32_t num; +} Usb_DeviceArray; #ifdef __cplusplus } /** @} */