From fb55a4b59527b2a0c51c32d405e45478fb0f8b55 Mon Sep 17 00:00:00 2001 From: dufresne_andy Date: Fri, 15 Mar 2024 13:00:47 +0800 Subject: [PATCH 1/9] Description:enhance host management to device Feature or Bugfix:Bugfix Binary Source: No Signed-off-by: dufresne_andy --- .../innerkits/native/include/iusb_srv.h | 3 + .../innerkits/native/include/usb_srv_client.h | 2 + .../innerkits/native/src/usb_srv_client.cpp | 25 +- services/BUILD.gn | 2 +- services/native/include/usb_service.h | 8 +- services/native/src/usb_service.cpp | 43 +- services/zidl/include/usb_server_proxy.h | 2 + services/zidl/include/usb_server_stub.h | 2 + .../include/usb_service_ipc_interface_code.h | 2 + services/zidl/src/usb_srv_proxy.cpp | 47 +- services/zidl/src/usb_srv_stub.cpp | 45 +- test/native/BUILD.gn | 4 +- test/native/service_unittest/BUILD.gn | 36 ++ .../include/usb_device_status_test.h | 31 ++ .../src/usb_device_status_test.cpp | 507 ++++++++++++++++++ 15 files changed, 745 insertions(+), 14 deletions(-) create mode 100644 test/native/service_unittest/include/usb_device_status_test.h create mode 100644 test/native/service_unittest/src/usb_device_status_test.cpp diff --git a/interfaces/innerkits/native/include/iusb_srv.h b/interfaces/innerkits/native/include/iusb_srv.h index b7310970..82e28d52 100644 --- a/interfaces/innerkits/native/include/iusb_srv.h +++ b/interfaces/innerkits/native/include/iusb_srv.h @@ -71,6 +71,9 @@ public: virtual int32_t ManageGlobalInterface(bool disable) = 0; virtual int32_t ManageDevice(int32_t vendorId, int32_t productId, bool disable) = 0; virtual int32_t ManageInterfaceType(InterfaceType interfaceType, bool disable) = 0; + virtual int32_t GetDeviceSpeed(uint8_t busNum, uint8_t devAddr, uint8_t &speed) = 0; + virtual int32_t GetInterfaceActiveStatus(uint8_t busNum, uint8_t devAddr, uint8_t interfaceid, + bool &unactivated) = 0; public: DECLARE_INTERFACE_DESCRIPTOR(u"ohos.usb.IUsbSrv"); }; diff --git a/interfaces/innerkits/native/include/usb_srv_client.h b/interfaces/innerkits/native/include/usb_srv_client.h index b72c0711..45fe47c8 100644 --- a/interfaces/innerkits/native/include/usb_srv_client.h +++ b/interfaces/innerkits/native/include/usb_srv_client.h @@ -73,6 +73,8 @@ public: int32_t RequestFree(UsbRequest &request); int32_t RequestAbort(UsbRequest &request); int32_t RequestQueue(UsbRequest &request); + int32_t GetDeviceSpeed(USBDevicePipe &pipe, uint8_t &speed); + int32_t GetInterfaceActiveStatus(USBDevicePipe &pipe, const UsbInterface &interface, bool &unactivated); std::string GetVersion() { diff --git a/interfaces/innerkits/native/src/usb_srv_client.cpp b/interfaces/innerkits/native/src/usb_srv_client.cpp index 5e36978c..2397d4e1 100644 --- a/interfaces/innerkits/native/src/usb_srv_client.cpp +++ b/interfaces/innerkits/native/src/usb_srv_client.cpp @@ -23,8 +23,9 @@ #include "usb_common.h" #include "usb_device.h" #include "usb_errors.h" +#include "v1_1/iusb_interface.h" -using namespace OHOS::HDI::Usb::V1_0; +using namespace OHOS::HDI::Usb::V1_1; namespace OHOS { namespace USB { UsbSrvClient::UsbSrvClient() @@ -452,5 +453,27 @@ int32_t UsbSrvClient::ManageInterfaceType(InterfaceType interfaceType, bool disa } return ret; } + +int32_t UsbSrvClient::GetDeviceSpeed(USBDevicePipe &pipe, uint8_t &speed) +{ + RETURN_IF_WITH_RET(Connect() != UEC_OK, UEC_INTERFACE_NO_INIT); + int32_t ret = proxy_->GetDeviceSpeed(pipe.GetBusNum(), pipe.GetDevAddr(), speed); + if (ret != UEC_OK) { + USB_HILOGE(MODULE_USB_INNERKIT, "failed ret = %{public}d!", ret); + } + USB_HILOGE(MODULE_USB_INNERKIT, "GetDeviceSpeed speed = %{public}u!", speed); + return ret; +} + +int32_t UsbSrvClient::GetInterfaceActiveStatus(USBDevicePipe &pipe, const UsbInterface &interface, bool &unactivated) +{ + RETURN_IF_WITH_RET(Connect() != UEC_OK, UEC_INTERFACE_NO_INIT); + int32_t ret = proxy_->GetInterfaceActiveStatus(pipe.GetBusNum(), pipe.GetDevAddr(), interface.GetId(), unactivated); + if (ret != UEC_OK) { + USB_HILOGE(MODULE_USB_INNERKIT, "failed ret = %{public}d!", ret); + } + return ret; +} + } // namespace USB } // namespace OHOS diff --git a/services/BUILD.gn b/services/BUILD.gn index 591eecda..34bf6f0e 100644 --- a/services/BUILD.gn +++ b/services/BUILD.gn @@ -83,7 +83,7 @@ ohos_shared_library("usbservice") { "bundle_framework:appexecfwk_core", "c_utils:utils", "common_event_service:cesfwk_innerkits", - "drivers_interface_usb:libusb_proxy_1.0", + "drivers_interface_usb:libusb_proxy_1.1", "eventhandler:libeventhandler", "hilog:libhilog", "hisysevent:libhisysevent", diff --git a/services/native/include/usb_service.h b/services/native/include/usb_service.h index a4b69d8f..68d0882b 100644 --- a/services/native/include/usb_service.h +++ b/services/native/include/usb_service.h @@ -38,7 +38,7 @@ #include "usb_server_stub.h" #include "usb_service_subscriber.h" #include "usbd_type.h" -#include "v1_0/iusb_interface.h" +#include "v1_1/iusb_interface.h" #include "v1_0/iusbd_bulk_callback.h" #include "v1_0/iusbd_subscriber.h" #include "v1_0/usb_types.h" @@ -69,7 +69,7 @@ public: return handler_; } - int32_t SetUsbd(const sptr &usbd); + int32_t SetUsbd(const sptr &usbd); int32_t OpenDevice(uint8_t busNum, uint8_t devAddr) override; bool CheckDevicePermission(uint8_t busNum, uint8_t devAddr); bool HasRight(std::string deviceName) override; @@ -125,6 +125,8 @@ public: int32_t ManageGlobalInterface(bool disable) override; int32_t ManageDevice(int32_t vendorId, int32_t productId, bool disable) override; int32_t ManageInterfaceType(InterfaceType interfaceType, bool disable) override; + int32_t GetInterfaceActiveStatus(uint8_t busNum, uint8_t devAddr, uint8_t interfaceid, bool &unactivated) override; + int32_t GetDeviceSpeed(uint8_t busNum, uint8_t devAddr, uint8_t &speed) override; private: class SystemAbilityStatusChangeListener : public SystemAbilityStatusChangeStub { public: @@ -179,7 +181,7 @@ private: std::shared_ptr handler_; sptr usbdSubscriber_; sptr hdiCb_ = nullptr; - sptr usbd_ = nullptr; + sptr usbd_ = nullptr; std::map deviceVidPidMap_; Utils::Timer unloadSelfTimer_ {"unLoadTimer"}; uint32_t unloadSelfTimerId_ {UINT32_MAX}; diff --git a/services/native/src/usb_service.cpp b/services/native/src/usb_service.cpp index a685efa3..381e4f32 100644 --- a/services/native/src/usb_service.cpp +++ b/services/native/src/usb_service.cpp @@ -42,7 +42,7 @@ #include "usbd_bulkcallback_impl.h" using OHOS::sptr; -using namespace OHOS::HDI::Usb::V1_0; +using namespace OHOS::HDI::Usb::V1_1; namespace OHOS { namespace USB { @@ -97,14 +97,15 @@ UsbService::UsbService() : SystemAbility(USB_SYSTEM_ABILITY_ID, true) usbRightManager_ = std::make_shared(); usbPortManager_ = std::make_shared(); usbDeviceManager_ = std::make_shared(); - usbd_ = IUsbInterface::Get(); + usbd_ = OHOS::HDI::Usb::V1_1::IUsbInterface::Get(); if (usbd_ == nullptr) { USB_HILOGE(MODULE_USB_SERVICE, "IUsbInterface::Get inteface failed"); } } + UsbService::~UsbService() {} -int32_t UsbService::SetUsbd(const sptr &usbd) +int32_t UsbService::SetUsbd(const sptr &usbd) { if (usbd == nullptr) { USB_HILOGE(MODULE_USB_SERVICE, "UsbService usbd is nullptr"); @@ -143,7 +144,7 @@ void UsbService::SystemAbilityStatusChangeListener::OnRemoveSystemAbility( { USB_HILOGI(MODULE_USB_SERVICE, "OnRemoveSystemAbility ID = %{public}d", systemAbilityId); if (systemAbilityId == USB_SYSTEM_ABILITY_ID) { - sptr usbd_ = IUsbInterface::Get(); + sptr usbd_ = OHOS::HDI::Usb::V1_1::IUsbInterface::Get(); if (usbd_ != nullptr) { usbd_->UnbindUsbdSubscriber(usbdSubscriber_); } @@ -234,7 +235,7 @@ bool UsbService::Init() bool UsbService::InitUsbd() { - usbd_ = IUsbInterface::Get(); + usbd_ = OHOS::HDI::Usb::V1_1::IUsbInterface::Get(); if (usbd_ == nullptr) { USB_HILOGE(MODULE_USB_SERVICE, " get usbd_ is nullptr"); return false; @@ -1555,7 +1556,7 @@ void UsbService::UsbdDeathRecipient::OnRemoteDied(const wptr &obj int32_t UsbService::PreManageInterface() { - usbd_ = IUsbInterface::Get(); + usbd_ = OHOS::HDI::Usb::V1_1::IUsbInterface::Get(); if (usbRightManager_ == nullptr) { USB_HILOGE(MODULE_USB_SERVICE, "invalid usbRightManager_"); return UEC_SERVICE_INVALID_VALUE; @@ -1708,5 +1709,35 @@ int32_t UsbService::ManageInterface(const HDI::Usb::V1_0::UsbDev &dev, uint8_t i } return usbd_->ManageInterface(dev, interfaceId, disable); } + +int32_t UsbService::GetInterfaceActiveStatus(uint8_t busNum, uint8_t devAddr, uint8_t interfaceid, bool &unactivated) +{ + const UsbDev dev = {busNum, devAddr}; + if (usbd_ == nullptr) { + USB_HILOGE(MODULE_USB_SERVICE, "UsbService::usbd_ is nullptr"); + return UEC_SERVICE_INVALID_VALUE; + } + int32_t ret = usbd_->GetInterfaceActiveStatus(dev, interfaceid, unactivated); + if (ret != UEC_OK) { + USB_HILOGE(MODULE_USB_SERVICE, "error ret:%{public}d", ret); + } + return ret; +} + +int32_t UsbService::GetDeviceSpeed(uint8_t busNum, uint8_t devAddr, uint8_t &speed) +{ + const UsbDev dev = {busNum, devAddr}; + if (usbd_ == nullptr) { + USB_HILOGE(MODULE_USB_SERVICE, "UsbService::usbd_ is nullptr"); + return UEC_SERVICE_INVALID_VALUE; + } + int32_t ret = usbd_->GetDeviceSpeed(dev, speed); + if (ret != UEC_OK) { + USB_HILOGE(MODULE_USB_SERVICE, "error ret:%{public}d", ret); + } + USB_HILOGE(MODULE_USB_SERVICE, "GetDeviceSpeedImpl:%{public}u", speed); + return ret; +} + } // namespace USB } // namespace OHOS diff --git a/services/zidl/include/usb_server_proxy.h b/services/zidl/include/usb_server_proxy.h index 29233649..3a9a50d9 100644 --- a/services/zidl/include/usb_server_proxy.h +++ b/services/zidl/include/usb_server_proxy.h @@ -79,6 +79,8 @@ public: int32_t ManageGlobalInterface(bool disable) override; int32_t ManageDevice(int32_t vendorId, int32_t productId, bool disable) override; int32_t ManageInterfaceType(InterfaceType interfaceType, bool disable) override; + int32_t GetDeviceSpeed(uint8_t busNum, uint8_t devAddr, uint8_t &speed) override; + int32_t GetInterfaceActiveStatus(uint8_t busNum, uint8_t devAddr, uint8_t interfaceid, bool &unactivated) override; private: static inline BrokerDelegator delegator_; int32_t ParseUsbPort(MessageParcel &reply, std::vector &result); diff --git a/services/zidl/include/usb_server_stub.h b/services/zidl/include/usb_server_stub.h index 9a59aed5..ad210422 100644 --- a/services/zidl/include/usb_server_stub.h +++ b/services/zidl/include/usb_server_stub.h @@ -88,6 +88,8 @@ private: int32_t DoManageGlobalInterface(MessageParcel &data, MessageParcel &reply, MessageOption &option); int32_t DoManageDevice(MessageParcel &data, MessageParcel &reply, MessageOption &option); int32_t DoManageInterfaceType(MessageParcel &data, MessageParcel &reply, MessageOption &option); + int32_t DoGetDeviceSpeed(MessageParcel &data, MessageParcel &reply, MessageOption &option); + int32_t DoGetInterfaceActiveStatus(MessageParcel &data, MessageParcel &reply, MessageOption &option); }; } // namespace USB } // namespace OHOS diff --git a/services/zidl/include/usb_service_ipc_interface_code.h b/services/zidl/include/usb_service_ipc_interface_code.h index 1b77242f..85b2f119 100644 --- a/services/zidl/include/usb_service_ipc_interface_code.h +++ b/services/zidl/include/usb_service_ipc_interface_code.h @@ -56,6 +56,8 @@ namespace USB { USB_FUN_DISABLE_GLOBAL_INTERFACE, USB_FUN_DISABLE_DEVICE, USB_FUN_DISABLE_INTERFACE_TYPE, + USB_FUN_GET_DEVICE_SPEED, + USB_FUN_GET_DRIVER_ACTIVE_STATUS, }; } // namespace USB } // namespace OHOS diff --git a/services/zidl/src/usb_srv_proxy.cpp b/services/zidl/src/usb_srv_proxy.cpp index 440ba5bb..ee468b9d 100644 --- a/services/zidl/src/usb_srv_proxy.cpp +++ b/services/zidl/src/usb_srv_proxy.cpp @@ -21,8 +21,9 @@ #include "usb_errors.h" #include "usb_request.h" #include "usb_server_proxy.h" +#include "v1_1/iusb_interface.h" -using namespace OHOS::HDI::Usb::V1_0; +using namespace OHOS::HDI::Usb::V1_1; namespace OHOS { namespace USB { @@ -1168,5 +1169,49 @@ int32_t UsbServerProxy::ManageInterfaceType(InterfaceType interfaceType, bool di } return ret; } + +int32_t UsbServerProxy::GetDeviceSpeed(uint8_t busNum, uint8_t devAddr, uint8_t &speed) +{ + sptr remote = Remote(); + RETURN_IF_WITH_RET(remote == nullptr, UEC_SERVICE_INNER_ERR); + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(UsbServerProxy::GetDescriptor())) { + USB_HILOGE(MODULE_INNERKIT, "write descriptor failed!"); + return ERR_ENOUGH_DATA; + } + SetDeviceMessage(data, busNum, devAddr); + int32_t ret = remote->SendRequest(static_cast(UsbInterfaceCode::USB_FUN_GET_DEVICE_SPEED), + data, reply, option); + if (ret == UEC_OK) { + READ_PARCEL_WITH_RET(reply, Uint8, speed, UEC_INTERFACE_READ_PARCEL_ERROR); + } + USB_HILOGE(MODULE_INNERKIT, "GetDeviceSpeed speed:%{public}u", speed); + return ret; +} + +int32_t UsbServerProxy::GetInterfaceActiveStatus(uint8_t busNum, uint8_t devAddr, + uint8_t interfaceid, bool &unactivated) +{ + sptr remote = Remote(); + RETURN_IF_WITH_RET(remote == nullptr, UEC_SERVICE_INNER_ERR); + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(UsbServerProxy::GetDescriptor())) { + USB_HILOGE(MODULE_INNERKIT, "write descriptor failed!"); + return ERR_ENOUGH_DATA; + } + SetDeviceMessage(data, busNum, devAddr); + WRITE_PARCEL_WITH_RET(data, Uint8, interfaceid, UEC_SERVICE_WRITE_PARCEL_ERROR); + int32_t ret = remote->SendRequest(static_cast(UsbInterfaceCode::USB_FUN_GET_DRIVER_ACTIVE_STATUS), + data, reply, option); + if (ret == UEC_OK) { + READ_PARCEL_WITH_RET(reply, Bool, unactivated, UEC_INTERFACE_READ_PARCEL_ERROR); + } + return ret; +} + } // namespace USB } // namespace OHOS diff --git a/services/zidl/src/usb_srv_stub.cpp b/services/zidl/src/usb_srv_stub.cpp index 01859db3..26413cca 100644 --- a/services/zidl/src/usb_srv_stub.cpp +++ b/services/zidl/src/usb_srv_stub.cpp @@ -20,8 +20,9 @@ #include "usb_errors.h" #include "usb_server_stub.h" #include "usb_interface_type.h" +#include "v1_1/iusb_interface.h" -using namespace OHOS::HDI::Usb::V1_0; +using namespace OHOS::HDI::Usb::V1_1; namespace OHOS { namespace USB { int32_t UsbServerStub::GetDeviceMessage(MessageParcel &data, uint8_t &busNum, uint8_t &devAddr) @@ -192,6 +193,12 @@ bool UsbServerStub::StubHost( case static_cast(UsbInterfaceCode::USB_FUN_DISABLE_INTERFACE_TYPE): result = DoManageInterfaceType(data, reply, option); return true; + case static_cast(UsbInterfaceCode::USB_FUN_GET_DEVICE_SPEED): + result = DoGetDeviceSpeed(data, reply, option); + return true; + case static_cast(UsbInterfaceCode::USB_FUN_GET_DRIVER_ACTIVE_STATUS): + result = DoGetInterfaceActiveStatus(data, reply, option); + return true; default:; } return false; @@ -913,5 +920,41 @@ int32_t UsbServerStub::DoManageInterfaceType(MessageParcel &data, MessageParcel } return ret; } + +int32_t UsbServerStub::DoGetInterfaceActiveStatus(MessageParcel &data, MessageParcel &reply, MessageOption &option) +{ + uint8_t busNum = 0; + uint8_t devAddr = 0; + uint8_t interfaceId = 0; + READ_PARCEL_WITH_RET(data, Uint8, busNum, UEC_SERVICE_WRITE_PARCEL_ERROR); + READ_PARCEL_WITH_RET(data, Uint8, devAddr, UEC_SERVICE_WRITE_PARCEL_ERROR); + READ_PARCEL_WITH_RET(data, Uint8, interfaceId, UEC_SERVICE_WRITE_PARCEL_ERROR); + bool unactivated; + int32_t ret = GetInterfaceActiveStatus(busNum, devAddr, interfaceId, unactivated); + if (ret == UEC_OK) { + WRITE_PARCEL_WITH_RET(reply, Bool, unactivated, UEC_SERVICE_WRITE_PARCEL_ERROR); + } else { + USB_HILOGE(MODULE_USBD, "ret:%{public}d", ret); + } + return ret; +} + +int32_t UsbServerStub::DoGetDeviceSpeed(MessageParcel &data, MessageParcel &reply, MessageOption &option) +{ + uint8_t busNum = 0; + uint8_t devAddr = 0; + READ_PARCEL_WITH_RET(data, Uint8, busNum, UEC_SERVICE_WRITE_PARCEL_ERROR); + READ_PARCEL_WITH_RET(data, Uint8, devAddr, UEC_SERVICE_WRITE_PARCEL_ERROR); + uint8_t speed; + int32_t ret = GetDeviceSpeed(busNum, devAddr, speed); + if (ret == UEC_OK) { + WRITE_PARCEL_WITH_RET(reply, Uint8, speed, UEC_SERVICE_WRITE_PARCEL_ERROR); + } else { + USB_HILOGE(MODULE_USBD, "ret:%{public}d", ret); + } + USB_HILOGE(MODULE_USBD, "DoGetDeviceSpeed speed:%{public}u", speed); + return ret; +} + } // namespace USB } // namespace OHOS diff --git a/test/native/BUILD.gn b/test/native/BUILD.gn index 5ad6f5bd..7bb5c008 100644 --- a/test/native/BUILD.gn +++ b/test/native/BUILD.gn @@ -16,5 +16,7 @@ import("./../../usbmgr.gni") group("usb_unittest_test") { testonly = true - deps = [ "../fuzztest:fuzztest" ] + deps = [ + "../fuzztest:fuzztest", + ] } diff --git a/test/native/service_unittest/BUILD.gn b/test/native/service_unittest/BUILD.gn index 8135283a..5ab5ea6c 100644 --- a/test/native/service_unittest/BUILD.gn +++ b/test/native/service_unittest/BUILD.gn @@ -243,6 +243,41 @@ ohos_unittest("test_usbmanageinterface") { ] } +ohos_unittest("test_usbdevicestatus") { + module_out_path = module_output_path + sources = [ + "src/usb_common_test.cpp", + "src/usb_device_status_test.cpp", + ] + + configs = [ + "${utils_path}:utils_config", + ":module_private_config", + ] + + deps = [ + "${usb_manager_path}/interfaces/innerkits:usbsrv_client", + "${usb_manager_path}/services:usbservice", + "//third_party/googletest:gtest_main", + ] + + external_deps = [ + "ability_base:want", + "access_token:libaccesstoken_sdk", + "access_token:libnativetoken", + "access_token:libtoken_setproc", + "bundle_framework:appexecfwk_base", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "drivers_interface_usb:libusb_proxy_1.1", + "eventhandler:libeventhandler", + "hilog:libhilog", + "ipc:ipc_core", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + ] +} + group("unittest") { testonly = true deps = [ @@ -252,5 +287,6 @@ group("unittest") { ":test_usbevent", ":test_usbmanageinterface", ":test_usbrequest", + ":test_usbdevicestatus", ] } diff --git a/test/native/service_unittest/include/usb_device_status_test.h b/test/native/service_unittest/include/usb_device_status_test.h new file mode 100644 index 00000000..43cd4c63 --- /dev/null +++ b/test/native/service_unittest/include/usb_device_status_test.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2021-2023 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef USB_DEVICE_STATUS_TEST_H +#define USB_DEVICE_STATUS_TEST_H + +#include + +namespace OHOS { +namespace USB { +class UsbDeviceStatusTest: public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp(); + void TearDown(); +}; +} // USB +} // OHOS +#endif // USBD_MANAGE_INTERFACE_TEST_H \ No newline at end of file diff --git a/test/native/service_unittest/src/usb_device_status_test.cpp b/test/native/service_unittest/src/usb_device_status_test.cpp new file mode 100644 index 00000000..aedce718 --- /dev/null +++ b/test/native/service_unittest/src/usb_device_status_test.cpp @@ -0,0 +1,507 @@ +/* + * Copyright (c) 2021-2023 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "usb_device_status_test.h" + +#include + +#include +#include + +#include "delayed_sp_singleton.h" +#include "hilog_wrapper.h" +#include "if_system_ability_manager.h" +#include "system_ability_definition.h" +#include "usb_common_test.h" +#include "usb_srv_client.h" +#include "usb_errors.h" +#include "v1_1/iusb_interface.h" +#include "v1_0/usb_types.h" + +constexpr int SLEEP_TIME = 3; +constexpr int32_t BUFFER_SIZE = 255; + +using namespace std; +using namespace testing::ext; +using namespace OHOS; +using namespace OHOS::USB; +using namespace OHOS::USB::Common; +using namespace OHOS::HDI::Usb::V1_1; + + +namespace OHOS { +namespace USB { + +void UsbDeviceStatusTest::SetUpTestCase(void) +{ + UsbCommonTest::GrantPermissionSysNative(); + auto &srvClient = UsbSrvClient::GetInstance(); + auto ret = srvClient.SetPortRole(1, 1, 1); + sleep(SLEEP_TIME); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest:: [Device] SetPortRole=%{public}d", ret); + ret = UsbCommonTest::SwitchErrCode(ret); + ASSERT_TRUE(ret == 0); + if (ret != 0) { + exit(0); + } + + std::cout << "please connect device, press enter to continue" << std::endl; + int32_t c; + while ((c = getchar()) != '\n' && c != EOF) { + ; + } + USB_HILOGI(MODULE_USB_SERVICE, "Start UsbDeviceStatusTest"); +} + +void UsbDeviceStatusTest::TearDownTestCase(void) +{ + USB_HILOGI(MODULE_USB_SERVICE, "End UsbDeviceStatusTest"); +} + +void UsbDeviceStatusTest::SetUp(void) {} + +void UsbDeviceStatusTest::TearDown(void) {} + + +/** + * @tc.name: GetDeviceSpeed001 + * @tc.desc: Test functions to GetDeviceSpeed + * @tc.type: FUNC + */ +HWTEST_F(UsbDeviceStatusTest, GetDeviceSpeed001, TestSize.Level1) +{ + USB_HILOGI(MODULE_USB_SERVICE, "Case Start : GetDeviceSpeed001"); + vector devi; + auto &UsbSrvClient = UsbSrvClient::GetInstance(); + auto ret = UsbSrvClient.GetDevices(devi); + EXPECT_TRUE(ret == 0); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetDeviceSpeed001 %{public}d ret=%{public}d", __LINE__, ret); + EXPECT_TRUE(!(devi.empty())) << "delist NULL"; + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetDeviceSpeed001 %{public}d size=%{public}zu", __LINE__, + devi.size()); + USBDevicePipe pipe; + UsbDevice device = devi.front(); + UsbSrvClient.RequestRight(device.GetName()); + ret = UsbSrvClient.OpenDevice(device, pipe); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetDeviceSpeed001 %{public}d OpenDevice=%{public}d", + __LINE__, ret); + EXPECT_TRUE(ret == 0); + uint8_t speed = 0; + ret = UsbSrvClient.GetDeviceSpeed(pipe, speed); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetDeviceSpeed001 %{public}d GetFileDescriptor=%{public}d", + __LINE__, ret); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetDeviceSpeed001 %{public}d speed=%{public}u", + __LINE__, speed); + EXPECT_TRUE(ret == 0); + ret = UsbSrvClient.Close(pipe); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::Close=%{public}d", ret); + EXPECT_TRUE(ret); + USB_HILOGI(MODULE_USB_SERVICE, "Case End : GetDeviceSpeed001"); +} + +/** + * @tc.name: GetDeviceSpeed002 + * @tc.desc: Test functions to GetDeviceSpeed + * @tc.type: FUNC + */ +HWTEST_F(UsbDeviceStatusTest, GetDeviceSpeed002, TestSize.Level1) +{ + USB_HILOGI(MODULE_USB_SERVICE, "Case Start : GetDeviceSpeed002"); + vector devi; + auto &UsbSrvClient = UsbSrvClient::GetInstance(); + auto ret = UsbSrvClient.GetDevices(devi); + EXPECT_TRUE(ret == 0); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetDeviceSpeed002 %{public}d ret=%{public}d", __LINE__, ret); + EXPECT_TRUE(!(devi.empty())) << "delist NULL"; + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetDeviceSpeed002 %{public}d size=%{public}zu", __LINE__, + devi.size()); + USBDevicePipe pipe; + UsbDevice device = devi.front(); + UsbSrvClient.RequestRight(device.GetName()); + ret = UsbSrvClient.OpenDevice(device, pipe); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetDeviceSpeed002 %{public}d OpenDevice=%{public}d", + __LINE__, ret); + EXPECT_TRUE(ret == 0); + USBDevicePipe pipeTmp = pipe; + pipeTmp.SetBusNum(BUFFER_SIZE); + uint8_t speed = 0; + ret = UsbSrvClient.GetDeviceSpeed(pipeTmp, speed); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetDeviceSpeed002 %{public}d GetFileDescriptor=%{public}d", + __LINE__, ret); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetDeviceSpeed002 %{public}d speed=%{public}u", + __LINE__, speed); + EXPECT_TRUE(ret != 0); + ret = UsbSrvClient.Close(pipe); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::Close=%{public}d", ret); + EXPECT_TRUE(ret); + USB_HILOGI(MODULE_USB_SERVICE, "Case End : GetDeviceSpeed002"); +} + +/** + * @tc.name: GetDeviceSpeed003 + * @tc.desc: Test functions to GetDeviceSpeed + * @tc.type: FUNC + */ +HWTEST_F(UsbDeviceStatusTest, GetDeviceSpeed003, TestSize.Level1) +{ + USB_HILOGI(MODULE_USB_SERVICE, "Case Start : GetDeviceSpeed003"); + vector devi; + auto &UsbSrvClient = UsbSrvClient::GetInstance(); + auto ret = UsbSrvClient.GetDevices(devi); + EXPECT_TRUE(ret == 0); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetDeviceSpeed003 %{public}d ret=%{public}d", __LINE__, ret); + EXPECT_TRUE(!(devi.empty())) << "delist NULL"; + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetDeviceSpeed003 %{public}d size=%{public}zu", __LINE__, + devi.size()); + USBDevicePipe pipe; + UsbDevice device = devi.front(); + UsbSrvClient.RequestRight(device.GetName()); + ret = UsbSrvClient.OpenDevice(device, pipe); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetDeviceSpeed003 %{public}d OpenDevice=%{public}d", + __LINE__, ret); + EXPECT_TRUE(ret == 0); + USBDevicePipe pipeTmp = pipe; + pipeTmp.SetDevAddr(BUFFER_SIZE); + uint8_t speed = 0; + ret = UsbSrvClient.GetDeviceSpeed(pipeTmp, speed); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetDeviceSpeed003 %{public}d GetFileDescriptor=%{public}d", + __LINE__, ret); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetDeviceSpeed003 %{public}d speed=%{public}u", + __LINE__, speed); + EXPECT_TRUE(ret != 0); + ret = UsbSrvClient.Close(pipe); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::Close=%{public}d", ret); + EXPECT_TRUE(ret); + USB_HILOGI(MODULE_USB_SERVICE, "Case End : GetDeviceSpeed003"); +} + + +/** + * @tc.name: GetInterfaceStatus001 + * @tc.desc: Test functions to GetInterfaceStatus + * @tc.type: FUNC + */ +HWTEST_F(UsbDeviceStatusTest, GetInterfaceStatus001, TestSize.Level1) +{ + USB_HILOGI(MODULE_USB_SERVICE, "Case Start : GetInterfaceStatus001"); + vector devi; + auto &UsbSrvClient = UsbSrvClient::GetInstance(); + auto ret = UsbSrvClient.GetDevices(devi); + EXPECT_TRUE(ret == 0); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus001 %{public}d ret=%{public}d", __LINE__, ret); + EXPECT_TRUE(!(devi.empty())) << "delist NULL"; + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus001 %{public}d size=%{public}zu", __LINE__, + devi.size()); + USBDevicePipe pipe; + UsbDevice device = devi.front(); + UsbSrvClient.RequestRight(device.GetName()); + ret = UsbSrvClient.OpenDevice(device, pipe); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus001 %{public}d OpenDevice=%{public}d", __LINE__, + ret); + EXPECT_TRUE(ret == 0); + UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(0); + pipe.SetBusNum(BUFFER_SIZE); + bool unactived = 1; + ret = UsbSrvClient.GetInterfaceActiveStatus(pipe, interface,unactived); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus001 %{public}d GetInterfaceStatus=%{public}d", + __LINE__, ret); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus001 %{public}d unactived=%{public}d", + __LINE__, unactived); + EXPECT_TRUE(ret != 0); + pipe.SetBusNum(device.GetBusNum()); + bool close = UsbSrvClient.Close(pipe); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus001 %{public}d close=%{public}d", __LINE__, close); + EXPECT_TRUE(close); + USB_HILOGI(MODULE_USB_SERVICE, "Case End : GetInterfaceStatus001"); +} + +/** + * @tc.name: GetInterfaceStatus002 + * @tc.desc: Test functions to GetInterfaceStatus + * @tc.type: FUNC + */ +HWTEST_F(UsbDeviceStatusTest, GetInterfaceStatus002, TestSize.Level1) +{ + USB_HILOGI(MODULE_USB_SERVICE, "Case Start : GetInterfaceStatus002"); + vector devi; + auto &UsbSrvClient = UsbSrvClient::GetInstance(); + auto ret = UsbSrvClient.GetDevices(devi); + EXPECT_TRUE(ret == 0); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus002 %{public}d ret=%{public}d", __LINE__, ret); + EXPECT_TRUE(!(devi.empty())) << "delist NULL"; + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus002 %{public}d size=%{public}zu", __LINE__, + devi.size()); + USBDevicePipe pipe; + UsbDevice device = devi.front(); + UsbSrvClient.RequestRight(device.GetName()); + ret = UsbSrvClient.OpenDevice(device, pipe); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus002 %{public}d OpenDevice=%{public}d", __LINE__, + ret); + EXPECT_TRUE(ret == 0); + UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(0); + pipe.SetDevAddr(BUFFER_SIZE); + bool unactived = 1; + ret = UsbSrvClient.GetInterfaceActiveStatus(pipe, interface,unactived); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus002 %{public}d GetInterfaceStatus=%{public}d", + __LINE__, ret); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus002 %{public}d unactived=%{public}d", + __LINE__, unactived); + EXPECT_TRUE(ret != 0); + pipe.SetDevAddr(device.GetDevAddr()); + bool close = UsbSrvClient.Close(pipe); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus002 %{public}d close=%{public}d", __LINE__, close); + EXPECT_TRUE(close); + USB_HILOGI(MODULE_USB_SERVICE, "Case End : GetInterfaceStatus002"); +} + +/** + * @tc.name: GetInterfaceStatus003 + * @tc.desc: Test functions to GetInterfaceStatus + * @tc.type: FUNC + */ +HWTEST_F(UsbDeviceStatusTest, GetInterfaceStatus003, TestSize.Level1) +{ + USB_HILOGI(MODULE_USB_SERVICE, "Case Start : GetInterfaceStatus003"); + vector devi; + auto &UsbSrvClient = UsbSrvClient::GetInstance(); + auto ret = UsbSrvClient.GetDevices(devi); + EXPECT_TRUE(ret == 0); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus003 %{public}d ret=%{public}d", __LINE__, ret); + EXPECT_TRUE(!(devi.empty())) << "delist NULL"; + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus003 %{public}d size=%{public}zu", __LINE__, + devi.size()); + USBDevicePipe pipe; + UsbDevice device = devi.front(); + UsbSrvClient.RequestRight(device.GetName()); + ret = UsbSrvClient.OpenDevice(device, pipe); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus003 %{public}d OpenDevice=%{public}d", __LINE__, + ret); + EXPECT_TRUE(ret == 0); + UsbInterface interface = device.GetConfigs().at(0).GetInterfaces().at(1); + bool unactived = 1; + ret = UsbSrvClient.GetInterfaceActiveStatus(pipe, interface,unactived); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus003 %{public}d GetInterfaceStatus=%{public}d", + __LINE__, ret); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus003 %{public}d unactived=%{public}d", + __LINE__, unactived); + EXPECT_TRUE(ret == 0); + bool close = UsbSrvClient.Close(pipe); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus003 %{public}d close=%{public}d", __LINE__, close); + EXPECT_TRUE(close); + USB_HILOGI(MODULE_USB_SERVICE, "Case End : GetInterfaceStatus003"); +} + +/** + * @tc.name: GetInterfaceStatus004 + * @tc.desc: Test functions to GetInterfaceStatus + * @tc.type: FUNC + */ +HWTEST_F(UsbDeviceStatusTest, GetInterfaceStatus004, TestSize.Level1) +{ + USB_HILOGI(MODULE_USB_SERVICE, "Case Start : GetInterfaceStatus004"); + vector devi; + auto &UsbSrvClient = UsbSrvClient::GetInstance(); + auto ret = UsbSrvClient.GetDevices(devi); + EXPECT_TRUE(ret == 0); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus004 %{public}d ret=%{public}d", __LINE__, ret); + EXPECT_TRUE(!(devi.empty())) << "delist NULL"; + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus004 %{public}d size=%{public}zu", __LINE__, + devi.size()); + USBDevicePipe pipe; + UsbDevice device = devi.front(); + UsbSrvClient.RequestRight(device.GetName()); + ret = UsbSrvClient.OpenDevice(device, pipe); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus004 %{public}d OpenDevice=%{public}d", __LINE__, + ret); + EXPECT_TRUE(ret == 0); + UsbInterface interface = device.GetConfigs().at(0).GetInterfaces().at(1); + pipe.SetBusNum(BUFFER_SIZE); + bool unactived = 1; + ret = UsbSrvClient.GetInterfaceActiveStatus(pipe, interface,unactived); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus004 %{public}d GetInterfaceStatus=%{public}d", + __LINE__, ret); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus004 %{public}d unactived=%{public}d", + __LINE__, unactived); + EXPECT_TRUE(ret != 0); + pipe.SetBusNum(device.GetBusNum()); + bool close = UsbSrvClient.Close(pipe); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus004 %{public}d close=%{public}d", __LINE__, close); + EXPECT_TRUE(close); + USB_HILOGI(MODULE_USB_SERVICE, "Case End : GetInterfaceStatus004"); +} + +/** + * @tc.name: GetInterfaceStatus005 + * @tc.desc: Test functions to GetInterfaceStatus + * @tc.type: FUNC + */ +HWTEST_F(UsbDeviceStatusTest, GetInterfaceStatus005, TestSize.Level1) +{ + USB_HILOGI(MODULE_USB_SERVICE, "Case Start : GetInterfaceStatus006"); + vector devi; + auto &UsbSrvClient = UsbSrvClient::GetInstance(); + auto ret = UsbSrvClient.GetDevices(devi); + EXPECT_TRUE(ret == 0); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus005 %{public}d ret=%{public}d", __LINE__, ret); + EXPECT_TRUE(!(devi.empty())) << "delist NULL"; + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus005 %{public}d size=%{public}zu", __LINE__, + devi.size()); + USBDevicePipe pipe; + UsbDevice device = devi.front(); + UsbSrvClient.RequestRight(device.GetName()); + ret = UsbSrvClient.OpenDevice(device, pipe); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus005 %{public}d OpenDevice=%{public}d", __LINE__, + ret); + EXPECT_TRUE(ret == 0); + UsbInterface interface = device.GetConfigs().at(0).GetInterfaces().at(1); + pipe.SetDevAddr(BUFFER_SIZE); + bool unactived = 1; + ret = UsbSrvClient.GetInterfaceActiveStatus(pipe, interface,unactived); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus005 %{public}d GetInterfaceStatus=%{public}d", + __LINE__, ret); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus005 %{public}d unactived=%{public}d", + __LINE__, unactived); + EXPECT_TRUE(ret != 0); + pipe.SetDevAddr(device.GetDevAddr()); + bool close = UsbSrvClient.Close(pipe); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus005 %{public}d close=%{public}d", __LINE__, close); + EXPECT_TRUE(close); + USB_HILOGI(MODULE_USB_SERVICE, "Case End : GetInterfaceStatus005"); +} + +/** + * @tc.name: GetInterfaceStatus006 + * @tc.desc: Test functions to GetInterfaceStatus + * @tc.type: FUNC + */ +HWTEST_F(UsbDeviceStatusTest, GetInterfaceStatus006, TestSize.Level1) +{ + USB_HILOGI(MODULE_USB_SERVICE, "Case Start : GetInterfaceStatus006"); + vector devi; + auto &UsbSrvClient = UsbSrvClient::GetInstance(); + auto ret = UsbSrvClient.GetDevices(devi); + EXPECT_TRUE(ret == 0); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus006 %{public}d ret=%{public}d", __LINE__, ret); + EXPECT_TRUE(!(devi.empty())) << "delist NULL"; + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus006 %{public}d size=%{public}zu", __LINE__, + devi.size()); + USBDevicePipe pipe; + UsbDevice device = devi.front(); + UsbSrvClient.RequestRight(device.GetName()); + ret = UsbSrvClient.OpenDevice(device, pipe); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus006 %{public}d OpenDevice=%{public}d", __LINE__, + ret); + EXPECT_TRUE(ret == 0); + UsbInterface interface = device.GetConfigs().at(0).GetInterfaces().at(0); + pipe.SetDevAddr(BUFFER_SIZE); + pipe.SetBusNum(BUFFER_SIZE); + bool unactived = 1; + ret = UsbSrvClient.GetInterfaceActiveStatus(pipe, interface,unactived); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus006 %{public}d GetInterfaceStatus=%{public}d", + __LINE__, ret); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus006 %{public}d unactived=%{public}d", + __LINE__, unactived); + EXPECT_TRUE(ret != 0); + pipe.SetDevAddr(device.GetDevAddr()); + pipe.SetBusNum(device.GetBusNum()); + bool close = UsbSrvClient.Close(pipe); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus006 %{public}d close=%{public}d", __LINE__, close); + EXPECT_TRUE(close); + USB_HILOGI(MODULE_USB_SERVICE, "Case End : GetInterfaceStatus006"); +} + +/** + * @tc.name: GetInterfaceStatus007 + * @tc.desc: Test functions to GetInterfaceStatus + * @tc.type: FUNC + */ +HWTEST_F(UsbDeviceStatusTest, GetInterfaceStatus007, TestSize.Level1) +{ + USB_HILOGI(MODULE_USB_SERVICE, "Case Start : GetInterfaceStatus007"); + vector devi; + auto &UsbSrvClient = UsbSrvClient::GetInstance(); + auto ret = UsbSrvClient.GetDevices(devi); + EXPECT_TRUE(ret == 0); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus007 %{public}d ret=%{public}d", __LINE__, ret); + EXPECT_TRUE(!(devi.empty())) << "delist NULL"; + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus007 %{public}d size=%{public}zu", __LINE__, + devi.size()); + USBDevicePipe pipe; + UsbDevice device = devi.front(); + UsbSrvClient.RequestRight(device.GetName()); + ret = UsbSrvClient.OpenDevice(device, pipe); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus007 %{public}d OpenDevice=%{public}d", __LINE__, + ret); + EXPECT_TRUE(ret == 0); + UsbInterface interface = device.GetConfigs().at(0).GetInterfaces().at(1); + pipe.SetDevAddr(BUFFER_SIZE); + pipe.SetBusNum(BUFFER_SIZE); + bool unactived = 1; + ret = UsbSrvClient.GetInterfaceActiveStatus(pipe, interface,unactived); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus007 %{public}d GetInterfaceStatus=%{public}d", + __LINE__, ret); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus007 %{public}d unactived=%{public}d", + __LINE__, unactived); + EXPECT_TRUE(ret != 0); + pipe.SetDevAddr(device.GetDevAddr()); + pipe.SetBusNum(device.GetBusNum()); + bool close = UsbSrvClient.Close(pipe); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus007 %{public}d close=%{public}d", __LINE__, close); + EXPECT_TRUE(close); + USB_HILOGI(MODULE_USB_SERVICE, "Case End : GetInterfaceStatus007"); +} + +/** + * @tc.name: GetInterfaceStatus008 + * @tc.desc: Test functions to GetInterfaceStatus + * @tc.type: FUNC + */ +HWTEST_F(UsbDeviceStatusTest, GetInterfaceStatus008, TestSize.Level1) +{ + USB_HILOGI(MODULE_USB_SERVICE, "Case Start : GetInterfaceStatus008"); + vector devi; + auto &UsbSrvClient = UsbSrvClient::GetInstance(); + auto ret = UsbSrvClient.GetDevices(devi); + EXPECT_TRUE(ret == 0); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus008 %{public}d ret=%{public}d", __LINE__, ret); + EXPECT_TRUE(!(devi.empty())) << "delist NULL"; + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus008 %{public}d size=%{public}zu", __LINE__, + devi.size()); + USBDevicePipe pipe; + UsbDevice device = devi.front(); + UsbSrvClient.RequestRight(device.GetName()); + ret = UsbSrvClient.OpenDevice(device, pipe); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus008 %{public}d OpenDevice=%{public}d", __LINE__, + ret); + EXPECT_TRUE(ret == 0); + UsbInterface interface = devi.front().GetConfigs().front().GetInterfaces().front(); + ret = UsbSrvClient.ClaimInterface(pipe, interface, true); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus008 %{public}d ClaimInterface=%{public}d", __LINE__, + ret); + EXPECT_TRUE(ret == 0); + bool unactived = 1; + ret = UsbSrvClient.GetInterfaceActiveStatus(pipe, interface, unactived); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus008 %{public}d GetInterfaceStatus=%{public}d", + __LINE__, ret); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus008 %{public}d unactived=%{public}d", + __LINE__, unactived); + bool close = UsbSrvClient.Close(pipe); + USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus008 %{public}d close=%{public}d", __LINE__, close); + EXPECT_TRUE(close); + USB_HILOGI(MODULE_USB_SERVICE, "Case End : GetInterfaceStatus008"); +} + +} // USB +} // OHOS \ No newline at end of file -- Gitee From e760ba159a57f63464d47d82a700fa4e66ddc040 Mon Sep 17 00:00:00 2001 From: dufresne_andy Date: Fri, 15 Mar 2024 17:05:24 +0800 Subject: [PATCH 2/9] Description:enhance host management to device Feature or Bugfix:Bugfix Binary Source: No Signed-off-by: dufresne_andy --- .../include/usb_device_status_test.h | 4 +- .../src/usb_device_status_test.cpp | 130 +++++++++--------- 2 files changed, 67 insertions(+), 67 deletions(-) diff --git a/test/native/service_unittest/include/usb_device_status_test.h b/test/native/service_unittest/include/usb_device_status_test.h index 43cd4c63..f05f92a3 100644 --- a/test/native/service_unittest/include/usb_device_status_test.h +++ b/test/native/service_unittest/include/usb_device_status_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. + * Copyright (c) 2021-2024 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 @@ -19,7 +19,7 @@ namespace OHOS { namespace USB { -class UsbDeviceStatusTest: public testing::Test { +class UsbDeviceStatusTest : public testing::Test { public: static void SetUpTestCase(); static void TearDownTestCase(); diff --git a/test/native/service_unittest/src/usb_device_status_test.cpp b/test/native/service_unittest/src/usb_device_status_test.cpp index aedce718..25c70119 100644 --- a/test/native/service_unittest/src/usb_device_status_test.cpp +++ b/test/native/service_unittest/src/usb_device_status_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. + * Copyright (c) 2021-2024 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 @@ -87,22 +87,22 @@ HWTEST_F(UsbDeviceStatusTest, GetDeviceSpeed001, TestSize.Level1) auto &UsbSrvClient = UsbSrvClient::GetInstance(); auto ret = UsbSrvClient.GetDevices(devi); EXPECT_TRUE(ret == 0); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetDeviceSpeed001 %{public}d ret=%{public}d", __LINE__, ret); + USB_HILOGI(MODULE_USB_SERVICE, "GetDeviceSpeed001 %{public}d ret=%{public}d", __LINE__, ret); EXPECT_TRUE(!(devi.empty())) << "delist NULL"; - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetDeviceSpeed001 %{public}d size=%{public}zu", __LINE__, + USB_HILOGI(MODULE_USB_SERVICE, "GetDeviceSpeed001 %{public}d size=%{public}zu", __LINE__, devi.size()); USBDevicePipe pipe; UsbDevice device = devi.front(); UsbSrvClient.RequestRight(device.GetName()); ret = UsbSrvClient.OpenDevice(device, pipe); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetDeviceSpeed001 %{public}d OpenDevice=%{public}d", + USB_HILOGI(MODULE_USB_SERVICE, "GetDeviceSpeed001 %{public}d OpenDevice=%{public}d", __LINE__, ret); EXPECT_TRUE(ret == 0); uint8_t speed = 0; ret = UsbSrvClient.GetDeviceSpeed(pipe, speed); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetDeviceSpeed001 %{public}d GetFileDescriptor=%{public}d", + USB_HILOGI(MODULE_USB_SERVICE, "GetDeviceSpeed001 %{public}d GetFileDescriptor=%{public}d", __LINE__, ret); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetDeviceSpeed001 %{public}d speed=%{public}u", + USB_HILOGI(MODULE_USB_SERVICE, "GetDeviceSpeed001 %{public}d speed=%{public}u", __LINE__, speed); EXPECT_TRUE(ret == 0); ret = UsbSrvClient.Close(pipe); @@ -123,24 +123,24 @@ HWTEST_F(UsbDeviceStatusTest, GetDeviceSpeed002, TestSize.Level1) auto &UsbSrvClient = UsbSrvClient::GetInstance(); auto ret = UsbSrvClient.GetDevices(devi); EXPECT_TRUE(ret == 0); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetDeviceSpeed002 %{public}d ret=%{public}d", __LINE__, ret); + USB_HILOGI(MODULE_USB_SERVICE, "GetDeviceSpeed002 %{public}d ret=%{public}d", __LINE__, ret); EXPECT_TRUE(!(devi.empty())) << "delist NULL"; - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetDeviceSpeed002 %{public}d size=%{public}zu", __LINE__, + USB_HILOGI(MODULE_USB_SERVICE, "GetDeviceSpeed002 %{public}d size=%{public}zu", __LINE__, devi.size()); USBDevicePipe pipe; UsbDevice device = devi.front(); UsbSrvClient.RequestRight(device.GetName()); ret = UsbSrvClient.OpenDevice(device, pipe); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetDeviceSpeed002 %{public}d OpenDevice=%{public}d", + USB_HILOGI(MODULE_USB_SERVICE, "GetDeviceSpeed002 %{public}d OpenDevice=%{public}d", __LINE__, ret); EXPECT_TRUE(ret == 0); USBDevicePipe pipeTmp = pipe; pipeTmp.SetBusNum(BUFFER_SIZE); uint8_t speed = 0; ret = UsbSrvClient.GetDeviceSpeed(pipeTmp, speed); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetDeviceSpeed002 %{public}d GetFileDescriptor=%{public}d", + USB_HILOGI(MODULE_USB_SERVICE, "GetDeviceSpeed002 %{public}d GetFileDescriptor=%{public}d", __LINE__, ret); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetDeviceSpeed002 %{public}d speed=%{public}u", + USB_HILOGI(MODULE_USB_SERVICE, "GetDeviceSpeed002 %{public}d speed=%{public}u", __LINE__, speed); EXPECT_TRUE(ret != 0); ret = UsbSrvClient.Close(pipe); @@ -161,24 +161,24 @@ HWTEST_F(UsbDeviceStatusTest, GetDeviceSpeed003, TestSize.Level1) auto &UsbSrvClient = UsbSrvClient::GetInstance(); auto ret = UsbSrvClient.GetDevices(devi); EXPECT_TRUE(ret == 0); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetDeviceSpeed003 %{public}d ret=%{public}d", __LINE__, ret); + USB_HILOGI(MODULE_USB_SERVICE, "GetDeviceSpeed003 %{public}d ret=%{public}d", __LINE__, ret); EXPECT_TRUE(!(devi.empty())) << "delist NULL"; - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetDeviceSpeed003 %{public}d size=%{public}zu", __LINE__, + USB_HILOGI(MODULE_USB_SERVICE, "GetDeviceSpeed003 %{public}d size=%{public}zu", __LINE__, devi.size()); USBDevicePipe pipe; UsbDevice device = devi.front(); UsbSrvClient.RequestRight(device.GetName()); ret = UsbSrvClient.OpenDevice(device, pipe); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetDeviceSpeed003 %{public}d OpenDevice=%{public}d", + USB_HILOGI(MODULE_USB_SERVICE, "GetDeviceSpeed003 %{public}d OpenDevice=%{public}d", __LINE__, ret); EXPECT_TRUE(ret == 0); USBDevicePipe pipeTmp = pipe; pipeTmp.SetDevAddr(BUFFER_SIZE); uint8_t speed = 0; ret = UsbSrvClient.GetDeviceSpeed(pipeTmp, speed); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetDeviceSpeed003 %{public}d GetFileDescriptor=%{public}d", + USB_HILOGI(MODULE_USB_SERVICE, "GetDeviceSpeed003 %{public}d GetFileDescriptor=%{public}d", __LINE__, ret); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetDeviceSpeed003 %{public}d speed=%{public}u", + USB_HILOGI(MODULE_USB_SERVICE, "GetDeviceSpeed003 %{public}d speed=%{public}u", __LINE__, speed); EXPECT_TRUE(ret != 0); ret = UsbSrvClient.Close(pipe); @@ -200,29 +200,29 @@ HWTEST_F(UsbDeviceStatusTest, GetInterfaceStatus001, TestSize.Level1) auto &UsbSrvClient = UsbSrvClient::GetInstance(); auto ret = UsbSrvClient.GetDevices(devi); EXPECT_TRUE(ret == 0); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus001 %{public}d ret=%{public}d", __LINE__, ret); + USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus001 %{public}d ret=%{public}d", __LINE__, ret); EXPECT_TRUE(!(devi.empty())) << "delist NULL"; - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus001 %{public}d size=%{public}zu", __LINE__, + USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus001 %{public}d size=%{public}zu", __LINE__, devi.size()); USBDevicePipe pipe; UsbDevice device = devi.front(); UsbSrvClient.RequestRight(device.GetName()); ret = UsbSrvClient.OpenDevice(device, pipe); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus001 %{public}d OpenDevice=%{public}d", __LINE__, + USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus001 %{public}d OpenDevice=%{public}d", __LINE__, ret); EXPECT_TRUE(ret == 0); UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(0); pipe.SetBusNum(BUFFER_SIZE); bool unactived = 1; ret = UsbSrvClient.GetInterfaceActiveStatus(pipe, interface,unactived); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus001 %{public}d GetInterfaceStatus=%{public}d", + USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus001 %{public}d GetInterfaceStatus=%{public}d", __LINE__, ret); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus001 %{public}d unactived=%{public}d", + USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus001 %{public}d unactived=%{public}d", __LINE__, unactived); EXPECT_TRUE(ret != 0); pipe.SetBusNum(device.GetBusNum()); bool close = UsbSrvClient.Close(pipe); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus001 %{public}d close=%{public}d", __LINE__, close); + USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus001 %{public}d close=%{public}d", __LINE__, close); EXPECT_TRUE(close); USB_HILOGI(MODULE_USB_SERVICE, "Case End : GetInterfaceStatus001"); } @@ -239,29 +239,29 @@ HWTEST_F(UsbDeviceStatusTest, GetInterfaceStatus002, TestSize.Level1) auto &UsbSrvClient = UsbSrvClient::GetInstance(); auto ret = UsbSrvClient.GetDevices(devi); EXPECT_TRUE(ret == 0); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus002 %{public}d ret=%{public}d", __LINE__, ret); + USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus002 %{public}d ret=%{public}d", __LINE__, ret); EXPECT_TRUE(!(devi.empty())) << "delist NULL"; - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus002 %{public}d size=%{public}zu", __LINE__, + USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus002 %{public}d size=%{public}zu", __LINE__, devi.size()); USBDevicePipe pipe; UsbDevice device = devi.front(); UsbSrvClient.RequestRight(device.GetName()); ret = UsbSrvClient.OpenDevice(device, pipe); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus002 %{public}d OpenDevice=%{public}d", __LINE__, + USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus002 %{public}d OpenDevice=%{public}d", __LINE__, ret); EXPECT_TRUE(ret == 0); UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(0); pipe.SetDevAddr(BUFFER_SIZE); bool unactived = 1; ret = UsbSrvClient.GetInterfaceActiveStatus(pipe, interface,unactived); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus002 %{public}d GetInterfaceStatus=%{public}d", + USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus002 %{public}d GetInterfaceStatus=%{public}d", __LINE__, ret); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus002 %{public}d unactived=%{public}d", + USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus002 %{public}d unactived=%{public}d", __LINE__, unactived); EXPECT_TRUE(ret != 0); pipe.SetDevAddr(device.GetDevAddr()); bool close = UsbSrvClient.Close(pipe); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus002 %{public}d close=%{public}d", __LINE__, close); + USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus002 %{public}d close=%{public}d", __LINE__, close); EXPECT_TRUE(close); USB_HILOGI(MODULE_USB_SERVICE, "Case End : GetInterfaceStatus002"); } @@ -278,27 +278,27 @@ HWTEST_F(UsbDeviceStatusTest, GetInterfaceStatus003, TestSize.Level1) auto &UsbSrvClient = UsbSrvClient::GetInstance(); auto ret = UsbSrvClient.GetDevices(devi); EXPECT_TRUE(ret == 0); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus003 %{public}d ret=%{public}d", __LINE__, ret); + USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus003 %{public}d ret=%{public}d", __LINE__, ret); EXPECT_TRUE(!(devi.empty())) << "delist NULL"; - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus003 %{public}d size=%{public}zu", __LINE__, + USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus003 %{public}d size=%{public}zu", __LINE__, devi.size()); USBDevicePipe pipe; UsbDevice device = devi.front(); UsbSrvClient.RequestRight(device.GetName()); ret = UsbSrvClient.OpenDevice(device, pipe); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus003 %{public}d OpenDevice=%{public}d", __LINE__, + USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus003 %{public}d OpenDevice=%{public}d", __LINE__, ret); EXPECT_TRUE(ret == 0); UsbInterface interface = device.GetConfigs().at(0).GetInterfaces().at(1); bool unactived = 1; ret = UsbSrvClient.GetInterfaceActiveStatus(pipe, interface,unactived); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus003 %{public}d GetInterfaceStatus=%{public}d", + USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus003 %{public}d GetInterfaceStatus=%{public}d", __LINE__, ret); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus003 %{public}d unactived=%{public}d", + USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus003 %{public}d unactived=%{public}d", __LINE__, unactived); EXPECT_TRUE(ret == 0); bool close = UsbSrvClient.Close(pipe); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus003 %{public}d close=%{public}d", __LINE__, close); + USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus003 %{public}d close=%{public}d", __LINE__, close); EXPECT_TRUE(close); USB_HILOGI(MODULE_USB_SERVICE, "Case End : GetInterfaceStatus003"); } @@ -315,29 +315,29 @@ HWTEST_F(UsbDeviceStatusTest, GetInterfaceStatus004, TestSize.Level1) auto &UsbSrvClient = UsbSrvClient::GetInstance(); auto ret = UsbSrvClient.GetDevices(devi); EXPECT_TRUE(ret == 0); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus004 %{public}d ret=%{public}d", __LINE__, ret); + USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus004 %{public}d ret=%{public}d", __LINE__, ret); EXPECT_TRUE(!(devi.empty())) << "delist NULL"; - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus004 %{public}d size=%{public}zu", __LINE__, + USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus004 %{public}d size=%{public}zu", __LINE__, devi.size()); USBDevicePipe pipe; UsbDevice device = devi.front(); UsbSrvClient.RequestRight(device.GetName()); ret = UsbSrvClient.OpenDevice(device, pipe); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus004 %{public}d OpenDevice=%{public}d", __LINE__, + USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus004 %{public}d OpenDevice=%{public}d", __LINE__, ret); EXPECT_TRUE(ret == 0); UsbInterface interface = device.GetConfigs().at(0).GetInterfaces().at(1); pipe.SetBusNum(BUFFER_SIZE); bool unactived = 1; ret = UsbSrvClient.GetInterfaceActiveStatus(pipe, interface,unactived); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus004 %{public}d GetInterfaceStatus=%{public}d", + USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus004 %{public}d GetInterfaceStatus=%{public}d", __LINE__, ret); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus004 %{public}d unactived=%{public}d", + USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus004 %{public}d unactived=%{public}d", __LINE__, unactived); EXPECT_TRUE(ret != 0); pipe.SetBusNum(device.GetBusNum()); bool close = UsbSrvClient.Close(pipe); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus004 %{public}d close=%{public}d", __LINE__, close); + USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus004 %{public}d close=%{public}d", __LINE__, close); EXPECT_TRUE(close); USB_HILOGI(MODULE_USB_SERVICE, "Case End : GetInterfaceStatus004"); } @@ -354,29 +354,29 @@ HWTEST_F(UsbDeviceStatusTest, GetInterfaceStatus005, TestSize.Level1) auto &UsbSrvClient = UsbSrvClient::GetInstance(); auto ret = UsbSrvClient.GetDevices(devi); EXPECT_TRUE(ret == 0); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus005 %{public}d ret=%{public}d", __LINE__, ret); + USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus005 %{public}d ret=%{public}d", __LINE__, ret); EXPECT_TRUE(!(devi.empty())) << "delist NULL"; - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus005 %{public}d size=%{public}zu", __LINE__, + USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus005 %{public}d size=%{public}zu", __LINE__, devi.size()); USBDevicePipe pipe; UsbDevice device = devi.front(); UsbSrvClient.RequestRight(device.GetName()); ret = UsbSrvClient.OpenDevice(device, pipe); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus005 %{public}d OpenDevice=%{public}d", __LINE__, + USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus005 %{public}d OpenDevice=%{public}d", __LINE__, ret); EXPECT_TRUE(ret == 0); UsbInterface interface = device.GetConfigs().at(0).GetInterfaces().at(1); pipe.SetDevAddr(BUFFER_SIZE); bool unactived = 1; ret = UsbSrvClient.GetInterfaceActiveStatus(pipe, interface,unactived); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus005 %{public}d GetInterfaceStatus=%{public}d", + USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus005 %{public}d GetInterfaceStatus=%{public}d", __LINE__, ret); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus005 %{public}d unactived=%{public}d", + USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus005 %{public}d unactived=%{public}d", __LINE__, unactived); EXPECT_TRUE(ret != 0); pipe.SetDevAddr(device.GetDevAddr()); bool close = UsbSrvClient.Close(pipe); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus005 %{public}d close=%{public}d", __LINE__, close); + USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus005 %{public}d close=%{public}d", __LINE__, close); EXPECT_TRUE(close); USB_HILOGI(MODULE_USB_SERVICE, "Case End : GetInterfaceStatus005"); } @@ -393,15 +393,15 @@ HWTEST_F(UsbDeviceStatusTest, GetInterfaceStatus006, TestSize.Level1) auto &UsbSrvClient = UsbSrvClient::GetInstance(); auto ret = UsbSrvClient.GetDevices(devi); EXPECT_TRUE(ret == 0); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus006 %{public}d ret=%{public}d", __LINE__, ret); + USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus006 %{public}d ret=%{public}d", __LINE__, ret); EXPECT_TRUE(!(devi.empty())) << "delist NULL"; - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus006 %{public}d size=%{public}zu", __LINE__, + USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus006 %{public}d size=%{public}zu", __LINE__, devi.size()); USBDevicePipe pipe; UsbDevice device = devi.front(); UsbSrvClient.RequestRight(device.GetName()); ret = UsbSrvClient.OpenDevice(device, pipe); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus006 %{public}d OpenDevice=%{public}d", __LINE__, + USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus006 %{public}d OpenDevice=%{public}d", __LINE__, ret); EXPECT_TRUE(ret == 0); UsbInterface interface = device.GetConfigs().at(0).GetInterfaces().at(0); @@ -409,15 +409,15 @@ HWTEST_F(UsbDeviceStatusTest, GetInterfaceStatus006, TestSize.Level1) pipe.SetBusNum(BUFFER_SIZE); bool unactived = 1; ret = UsbSrvClient.GetInterfaceActiveStatus(pipe, interface,unactived); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus006 %{public}d GetInterfaceStatus=%{public}d", + USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus006 %{public}d GetInterfaceStatus=%{public}d", __LINE__, ret); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus006 %{public}d unactived=%{public}d", + USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus006 %{public}d unactived=%{public}d", __LINE__, unactived); EXPECT_TRUE(ret != 0); pipe.SetDevAddr(device.GetDevAddr()); pipe.SetBusNum(device.GetBusNum()); bool close = UsbSrvClient.Close(pipe); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus006 %{public}d close=%{public}d", __LINE__, close); + USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus006 %{public}d close=%{public}d", __LINE__, close); EXPECT_TRUE(close); USB_HILOGI(MODULE_USB_SERVICE, "Case End : GetInterfaceStatus006"); } @@ -434,15 +434,15 @@ HWTEST_F(UsbDeviceStatusTest, GetInterfaceStatus007, TestSize.Level1) auto &UsbSrvClient = UsbSrvClient::GetInstance(); auto ret = UsbSrvClient.GetDevices(devi); EXPECT_TRUE(ret == 0); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus007 %{public}d ret=%{public}d", __LINE__, ret); + USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus007 %{public}d ret=%{public}d", __LINE__, ret); EXPECT_TRUE(!(devi.empty())) << "delist NULL"; - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus007 %{public}d size=%{public}zu", __LINE__, + USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus007 %{public}d size=%{public}zu", __LINE__, devi.size()); USBDevicePipe pipe; UsbDevice device = devi.front(); UsbSrvClient.RequestRight(device.GetName()); ret = UsbSrvClient.OpenDevice(device, pipe); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus007 %{public}d OpenDevice=%{public}d", __LINE__, + USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus007 %{public}d OpenDevice=%{public}d", __LINE__, ret); EXPECT_TRUE(ret == 0); UsbInterface interface = device.GetConfigs().at(0).GetInterfaces().at(1); @@ -450,15 +450,15 @@ HWTEST_F(UsbDeviceStatusTest, GetInterfaceStatus007, TestSize.Level1) pipe.SetBusNum(BUFFER_SIZE); bool unactived = 1; ret = UsbSrvClient.GetInterfaceActiveStatus(pipe, interface,unactived); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus007 %{public}d GetInterfaceStatus=%{public}d", + USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus007 %{public}d GetInterfaceStatus=%{public}d", __LINE__, ret); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus007 %{public}d unactived=%{public}d", + USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus007 %{public}d unactived=%{public}d", __LINE__, unactived); EXPECT_TRUE(ret != 0); pipe.SetDevAddr(device.GetDevAddr()); pipe.SetBusNum(device.GetBusNum()); bool close = UsbSrvClient.Close(pipe); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus007 %{public}d close=%{public}d", __LINE__, close); + USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus007 %{public}d close=%{public}d", __LINE__, close); EXPECT_TRUE(close); USB_HILOGI(MODULE_USB_SERVICE, "Case End : GetInterfaceStatus007"); } @@ -475,30 +475,30 @@ HWTEST_F(UsbDeviceStatusTest, GetInterfaceStatus008, TestSize.Level1) auto &UsbSrvClient = UsbSrvClient::GetInstance(); auto ret = UsbSrvClient.GetDevices(devi); EXPECT_TRUE(ret == 0); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus008 %{public}d ret=%{public}d", __LINE__, ret); + USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus008 %{public}d ret=%{public}d", __LINE__, ret); EXPECT_TRUE(!(devi.empty())) << "delist NULL"; - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus008 %{public}d size=%{public}zu", __LINE__, + USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus008 %{public}d size=%{public}zu", __LINE__, devi.size()); USBDevicePipe pipe; UsbDevice device = devi.front(); UsbSrvClient.RequestRight(device.GetName()); ret = UsbSrvClient.OpenDevice(device, pipe); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus008 %{public}d OpenDevice=%{public}d", __LINE__, + USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus008 %{public}d OpenDevice=%{public}d", __LINE__, ret); EXPECT_TRUE(ret == 0); UsbInterface interface = devi.front().GetConfigs().front().GetInterfaces().front(); ret = UsbSrvClient.ClaimInterface(pipe, interface, true); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus008 %{public}d ClaimInterface=%{public}d", __LINE__, + USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus008 %{public}d ClaimInterface=%{public}d", __LINE__, ret); EXPECT_TRUE(ret == 0); bool unactived = 1; ret = UsbSrvClient.GetInterfaceActiveStatus(pipe, interface, unactived); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus008 %{public}d GetInterfaceStatus=%{public}d", + USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus008 %{public}d GetInterfaceStatus=%{public}d", __LINE__, ret); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus008 %{public}d unactived=%{public}d", + USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus008 %{public}d unactived=%{public}d", __LINE__, unactived); bool close = UsbSrvClient.Close(pipe); - USB_HILOGI(MODULE_USB_SERVICE, "UsbDeviceStatusTest::GetInterfaceStatus008 %{public}d close=%{public}d", __LINE__, close); + USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus008 %{public}d close=%{public}d", __LINE__, close); EXPECT_TRUE(close); USB_HILOGI(MODULE_USB_SERVICE, "Case End : GetInterfaceStatus008"); } -- Gitee From 82c9d047efa9cfc8347235344c8e575d82f8cdc3 Mon Sep 17 00:00:00 2001 From: Zhao Zhen Date: Fri, 15 Mar 2024 09:21:10 +0000 Subject: [PATCH 3/9] update test/native/BUILD.gn. Signed-off-by: Zhao Zhen --- test/native/BUILD.gn | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/native/BUILD.gn b/test/native/BUILD.gn index 7bb5c008..5ad6f5bd 100644 --- a/test/native/BUILD.gn +++ b/test/native/BUILD.gn @@ -16,7 +16,5 @@ import("./../../usbmgr.gni") group("usb_unittest_test") { testonly = true - deps = [ - "../fuzztest:fuzztest", - ] + deps = [ "../fuzztest:fuzztest" ] } -- Gitee From 4b8c6f5b9c6d0bd276758c15f08a33799a3c3f5c Mon Sep 17 00:00:00 2001 From: Zhao Zhen Date: Fri, 15 Mar 2024 11:14:58 +0000 Subject: [PATCH 4/9] update test/native/service_unittest/src/usb_device_status_test.cpp. Signed-off-by: Zhao Zhen --- test/native/service_unittest/src/usb_device_status_test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/native/service_unittest/src/usb_device_status_test.cpp b/test/native/service_unittest/src/usb_device_status_test.cpp index 25c70119..599030cb 100644 --- a/test/native/service_unittest/src/usb_device_status_test.cpp +++ b/test/native/service_unittest/src/usb_device_status_test.cpp @@ -329,9 +329,9 @@ HWTEST_F(UsbDeviceStatusTest, GetInterfaceStatus004, TestSize.Level1) UsbInterface interface = device.GetConfigs().at(0).GetInterfaces().at(1); pipe.SetBusNum(BUFFER_SIZE); bool unactived = 1; - ret = UsbSrvClient.GetInterfaceActiveStatus(pipe, interface,unactived); + ret = UsbSrvClient.GetInterfaceActiveStatus(pipe, interface, unactived); USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus004 %{public}d GetInterfaceStatus=%{public}d", - __LINE__, ret); + __LINE__, ret); USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus004 %{public}d unactived=%{public}d", __LINE__, unactived); EXPECT_TRUE(ret != 0); -- Gitee From 1f8bd9c1a0a4af1129d0e0d23211865f0815b7eb Mon Sep 17 00:00:00 2001 From: Zhao Zhen Date: Fri, 15 Mar 2024 12:15:51 +0000 Subject: [PATCH 5/9] update test/native/service_unittest/BUILD.gn. Signed-off-by: Zhao Zhen --- test/native/service_unittest/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/native/service_unittest/BUILD.gn b/test/native/service_unittest/BUILD.gn index 5ab5ea6c..801f0d6c 100644 --- a/test/native/service_unittest/BUILD.gn +++ b/test/native/service_unittest/BUILD.gn @@ -284,9 +284,9 @@ group("unittest") { ":test_bulkcallback", ":test_usbcore", ":test_usbdevicepipe", + ":test_usbdevicestatus", ":test_usbevent", ":test_usbmanageinterface", ":test_usbrequest", - ":test_usbdevicestatus", ] } -- Gitee From 78bfafc183567738e0a85ec32e3e8a622b784bc1 Mon Sep 17 00:00:00 2001 From: Zhao Zhen Date: Fri, 15 Mar 2024 12:30:28 +0000 Subject: [PATCH 6/9] update test/native/service_unittest/src/usb_device_status_test.cpp. Signed-off-by: Zhao Zhen --- test/native/service_unittest/src/usb_device_status_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/native/service_unittest/src/usb_device_status_test.cpp b/test/native/service_unittest/src/usb_device_status_test.cpp index 599030cb..63d48bd9 100644 --- a/test/native/service_unittest/src/usb_device_status_test.cpp +++ b/test/native/service_unittest/src/usb_device_status_test.cpp @@ -408,7 +408,7 @@ HWTEST_F(UsbDeviceStatusTest, GetInterfaceStatus006, TestSize.Level1) pipe.SetDevAddr(BUFFER_SIZE); pipe.SetBusNum(BUFFER_SIZE); bool unactived = 1; - ret = UsbSrvClient.GetInterfaceActiveStatus(pipe, interface,unactived); + ret = UsbSrvClient.GetInterfaceActiveStatus(pipe, interface, unactived); USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus006 %{public}d GetInterfaceStatus=%{public}d", __LINE__, ret); USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus006 %{public}d unactived=%{public}d", -- Gitee From fc6fdcd27512bd3c09bc368181a6900fa2ea1943 Mon Sep 17 00:00:00 2001 From: Zhao Zhen Date: Fri, 15 Mar 2024 15:31:48 +0000 Subject: [PATCH 7/9] update test/native/service_unittest/src/usb_device_status_test.cpp. Signed-off-by: Zhao Zhen --- test/native/service_unittest/src/usb_device_status_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/native/service_unittest/src/usb_device_status_test.cpp b/test/native/service_unittest/src/usb_device_status_test.cpp index 63d48bd9..4e55e97b 100644 --- a/test/native/service_unittest/src/usb_device_status_test.cpp +++ b/test/native/service_unittest/src/usb_device_status_test.cpp @@ -214,7 +214,7 @@ HWTEST_F(UsbDeviceStatusTest, GetInterfaceStatus001, TestSize.Level1) UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(0); pipe.SetBusNum(BUFFER_SIZE); bool unactived = 1; - ret = UsbSrvClient.GetInterfaceActiveStatus(pipe, interface,unactived); + ret = UsbSrvClient.GetInterfaceActiveStatus(pipe, interface, unactived); USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus001 %{public}d GetInterfaceStatus=%{public}d", __LINE__, ret); USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus001 %{public}d unactived=%{public}d", -- Gitee From 5dfe9921d890e55f57e1eb173d8ed38f56781ed9 Mon Sep 17 00:00:00 2001 From: Zhao Zhen Date: Sat, 16 Mar 2024 03:43:02 +0000 Subject: [PATCH 8/9] update test/native/service_unittest/src/usb_device_status_test.cpp. Signed-off-by: Zhao Zhen --- test/native/service_unittest/src/usb_device_status_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/native/service_unittest/src/usb_device_status_test.cpp b/test/native/service_unittest/src/usb_device_status_test.cpp index 4e55e97b..081decc4 100644 --- a/test/native/service_unittest/src/usb_device_status_test.cpp +++ b/test/native/service_unittest/src/usb_device_status_test.cpp @@ -291,7 +291,7 @@ HWTEST_F(UsbDeviceStatusTest, GetInterfaceStatus003, TestSize.Level1) EXPECT_TRUE(ret == 0); UsbInterface interface = device.GetConfigs().at(0).GetInterfaces().at(1); bool unactived = 1; - ret = UsbSrvClient.GetInterfaceActiveStatus(pipe, interface,unactived); + ret = UsbSrvClient.GetInterfaceActiveStatus(pipe, interface, unactived); USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus003 %{public}d GetInterfaceStatus=%{public}d", __LINE__, ret); USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus003 %{public}d unactived=%{public}d", -- Gitee From df05670464a19cec82413602c24b37028726db72 Mon Sep 17 00:00:00 2001 From: Zhao Zhen Date: Sat, 16 Mar 2024 03:55:08 +0000 Subject: [PATCH 9/9] update test/native/service_unittest/src/usb_device_status_test.cpp. Signed-off-by: Zhao Zhen --- test/native/service_unittest/src/usb_device_status_test.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/native/service_unittest/src/usb_device_status_test.cpp b/test/native/service_unittest/src/usb_device_status_test.cpp index 081decc4..0bf36a37 100644 --- a/test/native/service_unittest/src/usb_device_status_test.cpp +++ b/test/native/service_unittest/src/usb_device_status_test.cpp @@ -253,7 +253,7 @@ HWTEST_F(UsbDeviceStatusTest, GetInterfaceStatus002, TestSize.Level1) UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(0); pipe.SetDevAddr(BUFFER_SIZE); bool unactived = 1; - ret = UsbSrvClient.GetInterfaceActiveStatus(pipe, interface,unactived); + ret = UsbSrvClient.GetInterfaceActiveStatus(pipe, interface, unactived); USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus002 %{public}d GetInterfaceStatus=%{public}d", __LINE__, ret); USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus002 %{public}d unactived=%{public}d", @@ -368,7 +368,7 @@ HWTEST_F(UsbDeviceStatusTest, GetInterfaceStatus005, TestSize.Level1) UsbInterface interface = device.GetConfigs().at(0).GetInterfaces().at(1); pipe.SetDevAddr(BUFFER_SIZE); bool unactived = 1; - ret = UsbSrvClient.GetInterfaceActiveStatus(pipe, interface,unactived); + ret = UsbSrvClient.GetInterfaceActiveStatus(pipe, interface, unactived); USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus005 %{public}d GetInterfaceStatus=%{public}d", __LINE__, ret); USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus005 %{public}d unactived=%{public}d", @@ -449,7 +449,7 @@ HWTEST_F(UsbDeviceStatusTest, GetInterfaceStatus007, TestSize.Level1) pipe.SetDevAddr(BUFFER_SIZE); pipe.SetBusNum(BUFFER_SIZE); bool unactived = 1; - ret = UsbSrvClient.GetInterfaceActiveStatus(pipe, interface,unactived); + ret = UsbSrvClient.GetInterfaceActiveStatus(pipe, interface, unactived); USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus007 %{public}d GetInterfaceStatus=%{public}d", __LINE__, ret); USB_HILOGI(MODULE_USB_SERVICE, "GetInterfaceStatus007 %{public}d unactived=%{public}d", -- Gitee