From 4a062b66b6268516a62523f72c2285f5d870a7f7 Mon Sep 17 00:00:00 2001 From: LuoBin Date: Tue, 31 Dec 2024 11:26:49 +0800 Subject: [PATCH] =?UTF-8?q?USB=20DDK=E5=A2=9E=E5=BC=BAndk=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: LuoBin Change-Id: I54c7acd5ea74fa12a32ad4a217bcffe7dc80a7e3 --- .../external_device_manager/usb/libusb.ndk.json | 3 +++ drivers/external_device_manager/usb/usb_ddk_api.h | 15 ++++++++++++++- .../external_device_manager/usb/usb_ddk_types.h | 14 +++++++++++++- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/drivers/external_device_manager/usb/libusb.ndk.json b/drivers/external_device_manager/usb/libusb.ndk.json index eb677bfee..55f578e40 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 1ee732e19..cd6213272 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 8c51cd726..7378ca454 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 } /** @} */ -- Gitee