From c8af399bbf8bbb107ca2c1e285b182494f6d7546 Mon Sep 17 00:00:00 2001 From: shilong Date: Tue, 24 Dec 2024 19:55:51 +0800 Subject: [PATCH] =?UTF-8?q?Fix:=E5=9B=9E=E9=80=80=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: shilong --- .../external_device_manager/hid/hid_ddk_api.h | 4 ++- .../hid/hid_ddk_types.h | 18 +++++----- .../usb/libusb.ndk.json | 3 -- .../external_device_manager/usb/usb_ddk_api.h | 33 +++++++------------ .../usb/usb_ddk_types.h | 26 +++++---------- 5 files changed, 31 insertions(+), 53 deletions(-) diff --git a/drivers/external_device_manager/hid/hid_ddk_api.h b/drivers/external_device_manager/hid/hid_ddk_api.h index 44f16c804..ac9336efd 100644 --- a/drivers/external_device_manager/hid/hid_ddk_api.h +++ b/drivers/external_device_manager/hid/hid_ddk_api.h @@ -83,7 +83,8 @@ int32_t OH_Hid_CreateDevice(Hid_Device *hidDevice, Hid_EventProperties *hidEvent * {@link HID_DDK_INVALID_OPERATION} connect hid ddk service failed or the caller is not the creator of device. * {@link HID_DDK_INVALID_PARAMETER} parameter check failed. Possible causes: 1.deviceId is less than 0;\n * 2.length exceeds 7; 3.items is null. - * {@link HID_DDK_NULL_PTR} the device does not exist. + * {@link HID_DDK_NULL_PTR} the inject of device is null. + * {@link HID_DDK_FAILURE} the device does not exit. * @since 11 * @version 1.0 */ @@ -97,6 +98,7 @@ int32_t OH_Hid_EmitEvent(int32_t deviceId, const Hid_EmitItem items[], uint16_t * @return {@link HID_DDK_SUCCESS} operation successful. * {@link HID_DDK_NO_PERM} permission check failed. * {@link HID_DDK_INVALID_OPERATION} connect hid ddk service failed or the caller is not the creator of device. + * {@link HID_DDK_FAILURE} the device does not exit. * @since 11 * @version 1.0 */ diff --git a/drivers/external_device_manager/hid/hid_ddk_types.h b/drivers/external_device_manager/hid/hid_ddk_types.h index 01dfc5d9b..1029fbb12 100644 --- a/drivers/external_device_manager/hid/hid_ddk_types.h +++ b/drivers/external_device_manager/hid/hid_ddk_types.h @@ -591,18 +591,18 @@ typedef struct Hid_EventProperties { typedef enum { /** @error Operation successful */ HID_DDK_SUCCESS = 0, - /** @error Permission denied */ - HID_DDK_NO_PERM = 201, - /** @error Invalid parameter */ - HID_DDK_INVALID_PARAMETER = 401, /** @error Operation failed */ - HID_DDK_FAILURE = 27300001, - /** @error Null pointer exception */ - HID_DDK_NULL_PTR = 27300002, + HID_DDK_FAILURE = -1, + /** @error Invalid parameter */ + HID_DDK_INVALID_PARAMETER = -2, /** @error Invalid operation */ - HID_DDK_INVALID_OPERATION = 27300003, + HID_DDK_INVALID_OPERATION = -3, + /** @error Null pointer exception */ + HID_DDK_NULL_PTR = -4, /** @error Timeout */ - HID_DDK_TIMEOUT = 27300004, + HID_DDK_TIMEOUT = -5, + /** @error Permission denied */ + HID_DDK_NO_PERM = -6 } Hid_DdkErrCode; #ifdef __cplusplus } diff --git a/drivers/external_device_manager/usb/libusb.ndk.json b/drivers/external_device_manager/usb/libusb.ndk.json index eb677bfee..d3ad5dbd3 100644 --- a/drivers/external_device_manager/usb/libusb.ndk.json +++ b/drivers/external_device_manager/usb/libusb.ndk.json @@ -5,9 +5,6 @@ { "name": "OH_Usb_Release" }, - { - "name": "OH_Usb_ReleaseResource" - }, { "name": "OH_Usb_GetDeviceDescriptor" }, diff --git a/drivers/external_device_manager/usb/usb_ddk_api.h b/drivers/external_device_manager/usb/usb_ddk_api.h index 1ee732e19..90ff08e69 100644 --- a/drivers/external_device_manager/usb/usb_ddk_api.h +++ b/drivers/external_device_manager/usb/usb_ddk_api.h @@ -70,17 +70,6 @@ int32_t OH_Usb_Init(void); */ void OH_Usb_Release(void); -/** - * @brief Releases the DDK. - * - * @permission ohos.permission.ACCESS_DDK_USB - * @return {@link USB_DDK_SUCCESS} the operation is successful. - * {@link USB_DDK_NO_PERM} permission check failed. - * @since 14 - * @version 1.0 - */ -int32_t OH_Usb_ReleaseResource(void); - /** * @brief Obtains the USB device descriptor. * @@ -88,7 +77,7 @@ int32_t OH_Usb_ReleaseResource(void); * @param deviceId ID of the device whose descriptor is to be obtained. * @param desc Standard device descriptor defined in the USB protocol. * @return {@link USB_DDK_SUCCESS} the operation is successful. - * {@link USB_DDK_NO_PERM} permission check failed. + * {@link USB_DDK_FAILED} permission check failed or internal error failed. * {@link USB_DDK_INVALID_OPERATION} connect usb ddk service failed. * {@link USB_DDK_INVALID_PARAMETER} desc is null. * @since 10 @@ -106,7 +95,7 @@ int32_t OH_Usb_GetDeviceDescriptor(uint64_t deviceId, struct UsbDeviceDescriptor * @param config Configuration descriptor, which includes the standard configuration descriptor defined in the\n * USB protocol and the associated interface descriptor and endpoint descriptor. * @return {@link USB_DDK_SUCCESS} the operation is successful. - * {@link USB_DDK_NO_PERM} permission check failed. + * {@link USB_DDK_FAILED} permission check failed or internal error failed. * {@link USB_DDK_INVALID_OPERATION} connect usb ddk service failed. * {@link USB_DDK_INVALID_PARAMETER} config is null. * @since 10 @@ -135,7 +124,7 @@ void OH_Usb_FreeConfigDescriptor(struct UsbDdkConfigDescriptor * const config); * @param interfaceHandle Interface operation handle. After the interface is claimed successfully, a value will be\n * assigned to this parameter. * @return {@link USB_DDK_SUCCESS} the operation is successful. - * {@link USB_DDK_NO_PERM} permission check failed. + * {@link USB_DDK_FAILED} permission check failed or internal error failed. * {@link USB_DDK_INVALID_OPERATION} connect usb ddk service failed. * {@link USB_DDK_INVALID_PARAMETER} interfaceHandle is null. * @since 10 @@ -149,7 +138,7 @@ int32_t OH_Usb_ClaimInterface(uint64_t deviceId, uint8_t interfaceIndex, uint64_ * @permission ohos.permission.ACCESS_DDK_USB * @param interfaceHandle Interface operation handle. * @return {@link USB_DDK_SUCCESS} the operation is successful. - * {@link USB_DDK_NO_PERM} permission check failed. + * {@link USB_DDK_FAILED} permission check failed or internal error failed. * {@link USB_DDK_INVALID_OPERATION} connect usb ddk service failed. * @since 10 * @version 1.0 @@ -164,7 +153,7 @@ int32_t OH_Usb_ReleaseInterface(uint64_t interfaceHandle); * @param settingIndex Index of the alternate setting, which corresponds to bAlternateSetting\n * in the USB protocol. * @return {@link USB_DDK_SUCCESS} the operation is successful. - * {@link USB_DDK_NO_PERM} permission check failed. + * {@link USB_DDK_FAILED} permission check failed or internal error failed. * {@link USB_DDK_INVALID_OPERATION} connect usb ddk service failed. * @since 10 * @version 1.0 @@ -179,7 +168,7 @@ int32_t OH_Usb_SelectInterfaceSetting(uint64_t interfaceHandle, uint8_t settingI * @param settingIndex Index of the alternate setting, which corresponds to bAlternateSetting\n * in the USB protocol. * @return {@link USB_DDK_SUCCESS} the operation is successful. - * {@link USB_DDK_NO_PERM} permission check failed. + * {@link USB_DDK_FAILED} permission check failed or internal error failed. * {@link USB_DDK_INVALID_OPERATION} connect usb ddk service failed. * {@link USB_DDK_INVALID_PARAMETER} settingIndex is null. * @since 10 @@ -197,7 +186,7 @@ int32_t OH_Usb_GetCurrentInterfaceSetting(uint64_t interfaceHandle, uint8_t *set * @param data Data to be transferred. * @param dataLen Data length. The return value indicates the length of the actually read data. * @return {@link USB_DDK_SUCCESS} the operation is successful. - * {@link USB_DDK_NO_PERM} permission check failed. + * {@link USB_DDK_FAILED} permission check failed or internal error failed. * {@link USB_DDK_INVALID_OPERATION} connect usb ddk service failed. * {@link USB_DDK_INVALID_PARAMETER} setup is null or data is null or dataLen is null or dataLen is less than\n * size of the read data. @@ -218,7 +207,7 @@ int32_t OH_Usb_SendControlReadRequest(uint64_t interfaceHandle, const struct Usb * @param data Data to be transferred. * @param dataLen Data length. * @return {@link USB_DDK_SUCCESS} the operation is successful. - * {@link USB_DDK_NO_PERM} permission check failed. + * {@link USB_DDK_FAILED} permission check failed or internal error failed. * {@link USB_DDK_INVALID_OPERATION} connect usb ddk service failed. * {@link USB_DDK_INVALID_PARAMETER} setup is null or data is null. * @since 10 @@ -235,7 +224,7 @@ int32_t OH_Usb_SendControlWriteRequest(uint64_t interfaceHandle, const struct Us * @param pipe Pipe used to transfer data. * @param devMmap Device memory map, which can be obtained by calling OH_Usb_CreateDeviceMemMap. * @return {@link USB_DDK_SUCCESS} the operation is successful. - * {@link USB_DDK_NO_PERM} permission check failed. + * {@link USB_DDK_FAILED} permission check failed or internal error failed. * {@link USB_DDK_INVALID_OPERATION} connect usb ddk service failed. * {@link USB_DDK_INVALID_PARAMETER} pipe is null or devMmap is null or address of devMmap is null. * @since 10 @@ -251,7 +240,7 @@ int32_t OH_Usb_SendPipeRequest(const struct UsbRequestPipe *pipe, UsbDeviceMemMa * @param pipe Pipe used to transfer data. * @param ashmem Shared memory, which can be obtained by calling OH_DDK_CreateAshmem. * @return {@link USB_DDK_SUCCESS} the operation is successful. - * {@link USB_DDK_NO_PERM} permission check failed. + * {@link USB_DDK_FAILED} permission check failed or internal error failed. * {@link USB_DDK_INVALID_OPERATION} connect usb ddk service failed. * {@link USB_DDK_INVALID_PARAMETER} pipe is null or ashmem is null or address of ashmem is null. * @since 12 @@ -267,7 +256,7 @@ int32_t OH_Usb_SendPipeRequestWithAshmem(const struct UsbRequestPipe *pipe, DDK_ * @param size Buffer size. * @param devMmap Data memory map, through which the created buffer is returned to the caller. * @return {@link USB_DDK_SUCCESS} the operation is successful. - * {@link USB_DDK_NO_PERM} permission check failed. + * {@link USB_DDK_FAILED} permission check failed or internal error failed. * {@link USB_DDK_INVALID_PARAMETER} devMmap is null. * {@link USB_DDK_MEMORY_ERROR} mmap failed or alloc memory of devMmap failed. * @since 10 diff --git a/drivers/external_device_manager/usb/usb_ddk_types.h b/drivers/external_device_manager/usb/usb_ddk_types.h index 8c51cd726..602baba11 100644 --- a/drivers/external_device_manager/usb/usb_ddk_types.h +++ b/drivers/external_device_manager/usb/usb_ddk_types.h @@ -298,32 +298,22 @@ typedef struct UsbDeviceMemMap { typedef enum { /** @error The operation is successful. */ USB_DDK_SUCCESS = 0, - /** @error The operation failed. - * @deprecate since 14 - */ + /** @error The operation failed. */ USB_DDK_FAILED = -1, - /** @error Permission denied. */ - USB_DDK_NO_PERM = 201, /** @error Invalid parameter. */ - USB_DDK_INVALID_PARAMETER = 401, + USB_DDK_INVALID_PARAMETER = -2, /** @error Memory-related error, for example, insufficient memory, memory data copy failure,\n * or memory application failure. */ - USB_DDK_MEMORY_ERROR = 27400001, - /** @error Null pointer exception - * @deprecate since 14 - */ + USB_DDK_MEMORY_ERROR = -3, + /** @error Invalid operation. */ + USB_DDK_INVALID_OPERATION = -4, + /** @error Null pointer exception */ USB_DDK_NULL_PTR = -5, - /** @error Device busy. - * @deprecate since 14 - */ + /** @error Device busy. */ USB_DDK_DEVICE_BUSY = -6, - /** @error Invalid operation. */ - USB_DDK_INVALID_OPERATION = 27400002, - /** @error Device I/O operation failed. */ - USB_DDK_IO_FAILED = 27400003, /** @error Transmission timeout. */ - USB_DDK_TIMEOUT = 27400004, + USB_DDK_TIMEOUT = -7 } UsbDdkErrCode; #ifdef __cplusplus } -- Gitee