feature(usb):for system app, check apl then check issystem

Signed-off-by: wuchengwen <wuchengwen4@huawei.com>
This commit is contained in:
wuchengwen 2023-05-22 14:17:21 +00:00
parent b630bcb15e
commit e6f0b077f3
9 changed files with 189 additions and 214 deletions

View File

@ -12,7 +12,7 @@ AlignEscapedNewlines: Left
NamespaceIndentation: None NamespaceIndentation: None
FixNamespaceComments: true FixNamespaceComments: true
ConstructorInitializerAllOnOneLineOrOnePerLine: true ConstructorInitializerAllOnOneLineOrOnePerLine: true
BreakConstructorInitializers: AfterColon BreakConstructorInitializers: BeforeColon
AlignArrayOfStructures: Left AlignArrayOfStructures: Left
AllowShortFunctionsOnASingleLine: Empty AllowShortFunctionsOnASingleLine: Empty
AllowShortLambdasOnASingleLine: Empty AllowShortLambdasOnASingleLine: Empty

View File

@ -111,11 +111,6 @@ int32_t UsbRightManager::Init()
bool UsbRightManager::HasRight(const std::string &deviceName, const std::string &bundleName) bool UsbRightManager::HasRight(const std::string &deviceName, const std::string &bundleName)
{ {
if (IsSystemHap()) {
USB_HILOGW(MODULE_USB_SERVICE, "system app, bypass: dev=%{private}s app=%{public}s", deviceName.c_str(),
bundleName.c_str());
return true;
}
int32_t uid = USB_RIGHT_USERID_INVALID; int32_t uid = USB_RIGHT_USERID_INVALID;
GetCurrentUserId(uid); GetCurrentUserId(uid);
if (uid == USB_RIGHT_USERID_CONSOLE) { if (uid == USB_RIGHT_USERID_CONSOLE) {
@ -184,11 +179,6 @@ bool UsbRightManager::AddDeviceRight(const std::string &deviceName, const std::s
bool UsbRightManager::RemoveDeviceRight(const std::string &deviceName, const std::string &bundleName) bool UsbRightManager::RemoveDeviceRight(const std::string &deviceName, const std::string &bundleName)
{ {
if (IsSystemHap()) {
USB_HILOGD(MODULE_USB_SERVICE, "system app, bypass: dev=%{private}s app=%{public}s", deviceName.c_str(),
bundleName.c_str());
return true;
}
int32_t uid = USB_RIGHT_USERID_INVALID; int32_t uid = USB_RIGHT_USERID_INVALID;
GetCurrentUserId(uid); GetCurrentUserId(uid);
if (uid == USB_RIGHT_USERID_CONSOLE) { if (uid == USB_RIGHT_USERID_CONSOLE) {

View File

@ -96,7 +96,8 @@ int32_t UsbService::SetUsbd(const sptr<IUsbInterface> &usbd)
} }
UsbService::SystemAbilityStatusChangeListener::SystemAbilityStatusChangeListener( UsbService::SystemAbilityStatusChangeListener::SystemAbilityStatusChangeListener(
sptr<UsbServiceSubscriber> usbdSubscriber) : usbdSubscriber_(usbdSubscriber) sptr<UsbServiceSubscriber> usbdSubscriber)
: usbdSubscriber_(usbdSubscriber)
{ {
} }
@ -290,16 +291,21 @@ std::string UsbService::GetDeviceVidPidSerialNumber(std::string deviceName)
bool UsbService::HasRight(std::string deviceName) bool UsbService::HasRight(std::string deviceName)
{ {
USB_HILOGI(MODULE_USB_SERVICE, "calling usbRightManager HasRight"); USB_HILOGI(MODULE_USB_SERVICE, "calling usbRightManager HasRight");
if (usbRightManager_ == nullptr) {
USB_HILOGE(MODULE_USB_SERVICE, "invalid usbRightManager_");
return false;
}
if (usbRightManager_->IsSystemHap()) {
USB_HILOGW(MODULE_USB_SERVICE, "system app, bypass: dev=%{public}s", deviceName.c_str());
return true;
}
std::string bundleName; std::string bundleName;
if (!GetBundleName(bundleName)) { if (!GetBundleName(bundleName)) {
USB_HILOGE(MODULE_USB_SERVICE, "HasRight GetBundleName false"); USB_HILOGE(MODULE_USB_SERVICE, "HasRight GetBundleName false");
return false; return false;
} }
if (usbRightManager_ == nullptr) {
USB_HILOGE(MODULE_USB_SERVICE, "invalid usbRightManager_");
return false;
}
USB_HILOGI(MODULE_USB_SERVICE, "bundle=%{public}s, device=%{public}s", bundleName.c_str(), deviceName.c_str()); USB_HILOGI(MODULE_USB_SERVICE, "bundle=%{public}s, device=%{public}s", bundleName.c_str(), deviceName.c_str());
return usbRightManager_->HasRight(GetDeviceVidPidSerialNumber(deviceName), bundleName); return usbRightManager_->HasRight(GetDeviceVidPidSerialNumber(deviceName), bundleName);
} }
@ -307,16 +313,20 @@ bool UsbService::HasRight(std::string deviceName)
int32_t UsbService::RequestRight(std::string deviceName) int32_t UsbService::RequestRight(std::string deviceName)
{ {
USB_HILOGI(MODULE_USB_SERVICE, "calling usbRightManager RequestRight"); USB_HILOGI(MODULE_USB_SERVICE, "calling usbRightManager RequestRight");
if (usbRightManager_ == nullptr) {
USB_HILOGE(MODULE_USB_SERVICE, "invalid usbRightManager_");
return UEC_SERVICE_INNER_ERR;
}
if (usbRightManager_->IsSystemHap()) {
USB_HILOGW(MODULE_USB_SERVICE, "system app, bypass: dev=%{public}s", deviceName.c_str());
return UEC_OK;
}
std::string bundleName; std::string bundleName;
if (!GetBundleName(bundleName)) { if (!GetBundleName(bundleName)) {
USB_HILOGI(MODULE_USB_SERVICE, "RequestRight GetBundleName false"); USB_HILOGI(MODULE_USB_SERVICE, "RequestRight GetBundleName false");
return UEC_SERVICE_INNER_ERR; return UEC_SERVICE_INNER_ERR;
} }
if (usbRightManager_ == nullptr) {
USB_HILOGE(MODULE_USB_SERVICE, "invalid usbRightManager_");
return UEC_SERVICE_INVALID_VALUE;
}
USB_HILOGI(MODULE_USB_SERVICE, "bundle=%{public}s, device=%{public}s", bundleName.c_str(), deviceName.c_str()); USB_HILOGI(MODULE_USB_SERVICE, "bundle=%{public}s, device=%{public}s", bundleName.c_str(), deviceName.c_str());
return usbRightManager_->RequestRight(deviceName, GetDeviceVidPidSerialNumber(deviceName), bundleName); return usbRightManager_->RequestRight(deviceName, GetDeviceVidPidSerialNumber(deviceName), bundleName);
} }
@ -328,6 +338,11 @@ int32_t UsbService::RemoveRight(std::string deviceName)
return UEC_SERVICE_INVALID_VALUE; return UEC_SERVICE_INVALID_VALUE;
} }
if (usbRightManager_->IsSystemHap()) {
USB_HILOGW(MODULE_USB_SERVICE, "system app, bypass: dev=%{public}s", deviceName.c_str());
return UEC_OK;
}
std::string bundleName; std::string bundleName;
if (!GetBundleName(bundleName)) { if (!GetBundleName(bundleName)) {
USB_HILOGE(MODULE_USB_SERVICE, "RequestRight GetBundleName false"); USB_HILOGE(MODULE_USB_SERVICE, "RequestRight GetBundleName false");
@ -730,9 +745,10 @@ int32_t UsbService::FillDevStrings(UsbDevice &dev)
dev.SetProductName(GetDevStringValFromIdx(busNum, devAddr, dev.GetiProduct())); dev.SetProductName(GetDevStringValFromIdx(busNum, devAddr, dev.GetiProduct()));
dev.SetmSerial(GetDevStringValFromIdx(busNum, devAddr, dev.GetiSerialNumber())); dev.SetmSerial(GetDevStringValFromIdx(busNum, devAddr, dev.GetiSerialNumber()));
USB_HILOGI(MODULE_USB_SERVICE, USB_HILOGI(MODULE_USB_SERVICE,
"iSerial:%{public}d Manufactur:%{public}s product:%{public}s " "version:%{public}s", "iSerial:%{public}d Manufactur:%{public}s product:%{public}s "
dev.GetiSerialNumber(), dev.GetManufacturerName().c_str(), "version:%{public}s",
dev.GetProductName().c_str(), dev.GetVersion().c_str()); dev.GetiSerialNumber(), dev.GetManufacturerName().c_str(), dev.GetProductName().c_str(),
dev.GetVersion().c_str());
std::vector<USBConfig> configs; std::vector<USBConfig> configs;
configs = dev.GetConfigs(); configs = dev.GetConfigs();

View File

@ -26,7 +26,6 @@ namespace USB {
namespace Common { namespace Common {
class UsbCommonTest { class UsbCommonTest {
public: public:
static void SetTestCaseHapApply();
static void SetTestCaseNative (TokenInfoParams *infoInstance); static void SetTestCaseNative (TokenInfoParams *infoInstance);
static void GrantPermissionSysNative(); static void GrantPermissionSysNative();
static void GrantPermissionNormalNative(); static void GrantPermissionNormalNative();

View File

@ -77,7 +77,7 @@ static int32_t InitAshmemOne(sptr<Ashmem> &asmptr, int32_t asmSize, uint8_t rflg
void UsbBulkcallbackTest::SetUpTestCase(void) void UsbBulkcallbackTest::SetUpTestCase(void)
{ {
UsbCommonTest::SetTestCaseHapApply(); UsbCommonTest::GrantPermissionSysNative();
auto &srvClient = UsbSrvClient::GetInstance(); auto &srvClient = UsbSrvClient::GetInstance();
auto ret = srvClient.SetPortRole(1, 1, 1); auto ret = srvClient.SetPortRole(1, 1, 1);
sleep(SLEEP_TIME); sleep(SLEEP_TIME);
@ -120,33 +120,33 @@ HWTEST_F(UsbBulkcallbackTest, RegBulkCallback001, TestSize.Level1)
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
EXPECT_TRUE(!(devi.empty())) << "delist NULL"; EXPECT_TRUE(!(devi.empty())) << "delist NULL";
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback001 %{public}d size=%{public}zu", __LINE__, USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback001 %{public}d size=%{public}zu", __LINE__,
devi.size()); devi.size());
USBDevicePipe pipe; USBDevicePipe pipe;
UsbDevice device = devi.front(); UsbDevice device = devi.front();
UsbSrvClient.RequestRight(device.GetName()); UsbSrvClient.RequestRight(device.GetName());
ret = UsbSrvClient.OpenDevice(device, pipe); ret = UsbSrvClient.OpenDevice(device, pipe);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback001 %{public}d OpenDevice=%{public}d", USB_HILOGI(
__LINE__, ret); MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback001 %{public}d OpenDevice=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1); UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
USBEndpoint point = interface.GetEndpoints().front(); USBEndpoint point = interface.GetEndpoints().front();
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback001 %{public}d point=%{public}d", __LINE__, USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback001 %{public}d point=%{public}d", __LINE__,
point.GetInterfaceId()); point.GetInterfaceId());
ret = UsbSrvClient.ClaimInterface(pipe, interface, true); ret = UsbSrvClient.ClaimInterface(pipe, interface, true);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback001 %{public}d ClaimInterface=%{public}d", USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback001 %{public}d ClaimInterface=%{public}d",
__LINE__, ret); __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.RegBulkCallback(pipe, point, cb); ret = UsbSrvClient.RegBulkCallback(pipe, point, cb);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback001 %{public}d RegBulkCallback=%{public}d", USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback001 %{public}d RegBulkCallback=%{public}d",
__LINE__, ret); __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.UnRegBulkCallback(pipe, point); ret = UsbSrvClient.UnRegBulkCallback(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback001 %{public}d UnRegBulkCallback=%{public}d", USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback001 %{public}d UnRegBulkCallback=%{public}d",
__LINE__, ret); __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
bool close = UsbSrvClient.Close(pipe); bool close = UsbSrvClient.Close(pipe);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback001 %{public}d close=%{public}d", __LINE__, USB_HILOGI(
close); MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback001 %{public}d close=%{public}d", __LINE__, close);
EXPECT_TRUE(close); EXPECT_TRUE(close);
USB_HILOGI(MODULE_USB_SERVICE, "Case End : RegBulkCallback001 : BulkTransfer"); USB_HILOGI(MODULE_USB_SERVICE, "Case End : RegBulkCallback001 : BulkTransfer");
} }
@ -168,33 +168,33 @@ HWTEST_F(UsbBulkcallbackTest, RegBulkCallback002, TestSize.Level1)
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
EXPECT_TRUE(!(devi.empty())) << "delist NULL"; EXPECT_TRUE(!(devi.empty())) << "delist NULL";
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback002 %{public}d size=%{public}zu", __LINE__, USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback002 %{public}d size=%{public}zu", __LINE__,
devi.size()); devi.size());
USBDevicePipe pipe; USBDevicePipe pipe;
UsbDevice device = devi.front(); UsbDevice device = devi.front();
UsbSrvClient.RequestRight(device.GetName()); UsbSrvClient.RequestRight(device.GetName());
ret = UsbSrvClient.OpenDevice(device, pipe); ret = UsbSrvClient.OpenDevice(device, pipe);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback002 %{public}d OpenDevice=%{public}d", USB_HILOGI(
__LINE__, ret); MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback002 %{public}d OpenDevice=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1); UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
USBEndpoint point = interface.GetEndpoints().at(1); USBEndpoint point = interface.GetEndpoints().at(1);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback002 %{public}d point=%{public}d", __LINE__, USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback002 %{public}d point=%{public}d", __LINE__,
point.GetInterfaceId()); point.GetInterfaceId());
ret = UsbSrvClient.ClaimInterface(pipe, interface, true); ret = UsbSrvClient.ClaimInterface(pipe, interface, true);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback002 %{public}d ClaimInterface=%{public}d", USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback002 %{public}d ClaimInterface=%{public}d",
__LINE__, ret); __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.RegBulkCallback(pipe, point, cb); ret = UsbSrvClient.RegBulkCallback(pipe, point, cb);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback002 %{public}d RegBulkCallback=%{public}d", USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback002 %{public}d RegBulkCallback=%{public}d",
__LINE__, ret); __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.UnRegBulkCallback(pipe, point); ret = UsbSrvClient.UnRegBulkCallback(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback002 %{public}d UnRegBulkCallback=%{public}d", USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback002 %{public}d UnRegBulkCallback=%{public}d",
__LINE__, ret); __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
bool close = UsbSrvClient.Close(pipe); bool close = UsbSrvClient.Close(pipe);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback002 %{public}d close=%{public}d", __LINE__, USB_HILOGI(
close); MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback002 %{public}d close=%{public}d", __LINE__, close);
EXPECT_TRUE(close); EXPECT_TRUE(close);
USB_HILOGI(MODULE_USB_SERVICE, "Case End : RegBulkCallback002 : BulkTransfer"); USB_HILOGI(MODULE_USB_SERVICE, "Case End : RegBulkCallback002 : BulkTransfer");
} }
@ -216,35 +216,35 @@ HWTEST_F(UsbBulkcallbackTest, RegBulkCallback003, TestSize.Level1)
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
EXPECT_TRUE(!(devi.empty())) << "delist NULL"; EXPECT_TRUE(!(devi.empty())) << "delist NULL";
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback003 %{public}d size=%{public}zu", __LINE__, USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback003 %{public}d size=%{public}zu", __LINE__,
devi.size()); devi.size());
USBDevicePipe pipe; USBDevicePipe pipe;
UsbDevice device = devi.front(); UsbDevice device = devi.front();
UsbSrvClient.RequestRight(device.GetName()); UsbSrvClient.RequestRight(device.GetName());
ret = UsbSrvClient.OpenDevice(device, pipe); ret = UsbSrvClient.OpenDevice(device, pipe);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback003 %{public}d OpenDevice=%{public}d", USB_HILOGI(
__LINE__, ret); MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback003 %{public}d OpenDevice=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1); UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
USBEndpoint point = interface.GetEndpoints().at(1); USBEndpoint point = interface.GetEndpoints().at(1);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback003 %{public}d point=%{public}d", __LINE__, USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback003 %{public}d point=%{public}d", __LINE__,
point.GetInterfaceId()); point.GetInterfaceId());
ret = UsbSrvClient.ClaimInterface(pipe, interface, true); ret = UsbSrvClient.ClaimInterface(pipe, interface, true);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback003 %{public}d ClaimInterface=%{public}d", USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback003 %{public}d ClaimInterface=%{public}d",
__LINE__, ret); __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
pipe.SetBusNum(BUFFER_SIZE); pipe.SetBusNum(BUFFER_SIZE);
ret = UsbSrvClient.RegBulkCallback(pipe, point, cb); ret = UsbSrvClient.RegBulkCallback(pipe, point, cb);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback003 %{public}d RegBulkCallback=%{public}d", USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback003 %{public}d RegBulkCallback=%{public}d",
__LINE__, ret); __LINE__, ret);
EXPECT_TRUE(ret != 0); EXPECT_TRUE(ret != 0);
ret = UsbSrvClient.UnRegBulkCallback(pipe, point); ret = UsbSrvClient.UnRegBulkCallback(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback003 %{public}d UnRegBulkCallback=%{public}d", USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback003 %{public}d UnRegBulkCallback=%{public}d",
__LINE__, ret); __LINE__, ret);
EXPECT_TRUE(ret != 0); EXPECT_TRUE(ret != 0);
pipe.SetBusNum(device.GetBusNum()); pipe.SetBusNum(device.GetBusNum());
bool close = UsbSrvClient.Close(pipe); bool close = UsbSrvClient.Close(pipe);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback003 %{public}d close=%{public}d", __LINE__, USB_HILOGI(
close); MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback003 %{public}d close=%{public}d", __LINE__, close);
EXPECT_TRUE(close); EXPECT_TRUE(close);
USB_HILOGI(MODULE_USB_SERVICE, "Case End : RegBulkCallback003 : BulkTransfer"); USB_HILOGI(MODULE_USB_SERVICE, "Case End : RegBulkCallback003 : BulkTransfer");
} }
@ -266,35 +266,35 @@ HWTEST_F(UsbBulkcallbackTest, RegBulkCallback004, TestSize.Level1)
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
EXPECT_TRUE(!(devi.empty())) << "delist NULL"; EXPECT_TRUE(!(devi.empty())) << "delist NULL";
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback004 %{public}d size=%{public}zu", __LINE__, USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback004 %{public}d size=%{public}zu", __LINE__,
devi.size()); devi.size());
USBDevicePipe pipe; USBDevicePipe pipe;
UsbDevice device = devi.front(); UsbDevice device = devi.front();
UsbSrvClient.RequestRight(device.GetName()); UsbSrvClient.RequestRight(device.GetName());
ret = UsbSrvClient.OpenDevice(device, pipe); ret = UsbSrvClient.OpenDevice(device, pipe);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback004 %{public}d OpenDevice=%{public}d", USB_HILOGI(
__LINE__, ret); MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback004 %{public}d OpenDevice=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1); UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
USBEndpoint point = interface.GetEndpoints().at(1); USBEndpoint point = interface.GetEndpoints().at(1);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback004 %{public}d point=%{public}d", __LINE__, USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback004 %{public}d point=%{public}d", __LINE__,
point.GetInterfaceId()); point.GetInterfaceId());
ret = UsbSrvClient.ClaimInterface(pipe, interface, true); ret = UsbSrvClient.ClaimInterface(pipe, interface, true);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback004 %{public}d ClaimInterface=%{public}d", USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback004 %{public}d ClaimInterface=%{public}d",
__LINE__, ret); __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
pipe.SetDevAddr(BUFFER_SIZE); pipe.SetDevAddr(BUFFER_SIZE);
ret = UsbSrvClient.RegBulkCallback(pipe, point, cb); ret = UsbSrvClient.RegBulkCallback(pipe, point, cb);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback004 %{public}d RegBulkCallback=%{public}d", USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback004 %{public}d RegBulkCallback=%{public}d",
__LINE__, ret); __LINE__, ret);
EXPECT_TRUE(ret != 0); EXPECT_TRUE(ret != 0);
ret = UsbSrvClient.UnRegBulkCallback(pipe, point); ret = UsbSrvClient.UnRegBulkCallback(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback004 %{public}d UnRegBulkCallback=%{public}d", USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback004 %{public}d UnRegBulkCallback=%{public}d",
__LINE__, ret); __LINE__, ret);
EXPECT_TRUE(ret != 0); EXPECT_TRUE(ret != 0);
pipe.SetDevAddr(device.GetDevAddr()); pipe.SetDevAddr(device.GetDevAddr());
bool close = UsbSrvClient.Close(pipe); bool close = UsbSrvClient.Close(pipe);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback004 %{public}d close=%{public}d", __LINE__, USB_HILOGI(
close); MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback004 %{public}d close=%{public}d", __LINE__, close);
EXPECT_TRUE(close); EXPECT_TRUE(close);
USB_HILOGI(MODULE_USB_SERVICE, "Case End : RegBulkCallback004 : BulkTransfer"); USB_HILOGI(MODULE_USB_SERVICE, "Case End : RegBulkCallback004 : BulkTransfer");
} }
@ -316,35 +316,35 @@ HWTEST_F(UsbBulkcallbackTest, RegBulkCallback005, TestSize.Level1)
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
EXPECT_TRUE(!(devi.empty())) << "delist NULL"; EXPECT_TRUE(!(devi.empty())) << "delist NULL";
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback005 %{public}d size=%{public}zu", __LINE__, USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback005 %{public}d size=%{public}zu", __LINE__,
devi.size()); devi.size());
USBDevicePipe pipe; USBDevicePipe pipe;
UsbDevice device = devi.front(); UsbDevice device = devi.front();
UsbSrvClient.RequestRight(device.GetName()); UsbSrvClient.RequestRight(device.GetName());
ret = UsbSrvClient.OpenDevice(device, pipe); ret = UsbSrvClient.OpenDevice(device, pipe);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback005 %{public}d OpenDevice=%{public}d", USB_HILOGI(
__LINE__, ret); MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback005 %{public}d OpenDevice=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1); UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
USBEndpoint point = interface.GetEndpoints().at(0); USBEndpoint point = interface.GetEndpoints().at(0);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback005 %{public}d point=%{public}d", __LINE__, USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback005 %{public}d point=%{public}d", __LINE__,
point.GetInterfaceId()); point.GetInterfaceId());
ret = UsbSrvClient.ClaimInterface(pipe, interface, true); ret = UsbSrvClient.ClaimInterface(pipe, interface, true);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback005 %{public}d ClaimInterface=%{public}d", USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback005 %{public}d ClaimInterface=%{public}d",
__LINE__, ret); __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
pipe.SetDevAddr(BUFFER_SIZE); pipe.SetDevAddr(BUFFER_SIZE);
ret = UsbSrvClient.RegBulkCallback(pipe, point, cb); ret = UsbSrvClient.RegBulkCallback(pipe, point, cb);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback005 %{public}d RegBulkCallback=%{public}d", USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback005 %{public}d RegBulkCallback=%{public}d",
__LINE__, ret); __LINE__, ret);
EXPECT_TRUE(ret != 0); EXPECT_TRUE(ret != 0);
ret = UsbSrvClient.UnRegBulkCallback(pipe, point); ret = UsbSrvClient.UnRegBulkCallback(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback005 %{public}d UnRegBulkCallback=%{public}d", USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback005 %{public}d UnRegBulkCallback=%{public}d",
__LINE__, ret); __LINE__, ret);
EXPECT_TRUE(ret != 0); EXPECT_TRUE(ret != 0);
pipe.SetDevAddr(device.GetDevAddr()); pipe.SetDevAddr(device.GetDevAddr());
bool close = UsbSrvClient.Close(pipe); bool close = UsbSrvClient.Close(pipe);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback005 %{public}d close=%{public}d", __LINE__, USB_HILOGI(
close); MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback005 %{public}d close=%{public}d", __LINE__, close);
EXPECT_TRUE(close); EXPECT_TRUE(close);
USB_HILOGI(MODULE_USB_SERVICE, "Case End : RegBulkCallback005 : BulkTransfer"); USB_HILOGI(MODULE_USB_SERVICE, "Case End : RegBulkCallback005 : BulkTransfer");
} }
@ -366,35 +366,35 @@ HWTEST_F(UsbBulkcallbackTest, RegBulkCallback006, TestSize.Level1)
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
EXPECT_TRUE(!(devi.empty())) << "delist NULL"; EXPECT_TRUE(!(devi.empty())) << "delist NULL";
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback006 %{public}d size=%{public}zu", __LINE__, USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback006 %{public}d size=%{public}zu", __LINE__,
devi.size()); devi.size());
USBDevicePipe pipe; USBDevicePipe pipe;
UsbDevice device = devi.front(); UsbDevice device = devi.front();
UsbSrvClient.RequestRight(device.GetName()); UsbSrvClient.RequestRight(device.GetName());
ret = UsbSrvClient.OpenDevice(device, pipe); ret = UsbSrvClient.OpenDevice(device, pipe);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback006 %{public}d OpenDevice=%{public}d", USB_HILOGI(
__LINE__, ret); MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback006 %{public}d OpenDevice=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1); UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
USBEndpoint point = interface.GetEndpoints().at(0); USBEndpoint point = interface.GetEndpoints().at(0);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback006 %{public}d point=%{public}d", __LINE__, USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback006 %{public}d point=%{public}d", __LINE__,
point.GetInterfaceId()); point.GetInterfaceId());
ret = UsbSrvClient.ClaimInterface(pipe, interface, true); ret = UsbSrvClient.ClaimInterface(pipe, interface, true);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback006 %{public}d ClaimInterface=%{public}d", USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback006 %{public}d ClaimInterface=%{public}d",
__LINE__, ret); __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
pipe.SetBusNum(BUFFER_SIZE); pipe.SetBusNum(BUFFER_SIZE);
ret = UsbSrvClient.RegBulkCallback(pipe, point, cb); ret = UsbSrvClient.RegBulkCallback(pipe, point, cb);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback006 %{public}d RegBulkCallback=%{public}d", USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback006 %{public}d RegBulkCallback=%{public}d",
__LINE__, ret); __LINE__, ret);
EXPECT_TRUE(ret != 0); EXPECT_TRUE(ret != 0);
ret = UsbSrvClient.UnRegBulkCallback(pipe, point); ret = UsbSrvClient.UnRegBulkCallback(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback006 %{public}d UnRegBulkCallback=%{public}d", USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback006 %{public}d UnRegBulkCallback=%{public}d",
__LINE__, ret); __LINE__, ret);
EXPECT_TRUE(ret != 0); EXPECT_TRUE(ret != 0);
pipe.SetBusNum(device.GetBusNum()); pipe.SetBusNum(device.GetBusNum());
bool close = UsbSrvClient.Close(pipe); bool close = UsbSrvClient.Close(pipe);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback006 %{public}d close=%{public}d", __LINE__, USB_HILOGI(
close); MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback006 %{public}d close=%{public}d", __LINE__, close);
EXPECT_TRUE(close); EXPECT_TRUE(close);
USB_HILOGI(MODULE_USB_SERVICE, "Case End : RegBulkCallback006 : BulkTransfer"); USB_HILOGI(MODULE_USB_SERVICE, "Case End : RegBulkCallback006 : BulkTransfer");
} }
@ -427,21 +427,21 @@ HWTEST_F(UsbBulkcallbackTest, BulkRead001, TestSize.Level1)
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1); UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
USBEndpoint point = interface.GetEndpoints().front(); USBEndpoint point = interface.GetEndpoints().front();
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead001 %{public}d point=%{public}d", __LINE__, USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead001 %{public}d point=%{public}d", __LINE__,
point.GetInterfaceId()); point.GetInterfaceId());
ret = UsbSrvClient.ClaimInterface(pipe, interface, true); ret = UsbSrvClient.ClaimInterface(pipe, interface, true);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead001 %{public}d ClaimInterface=%{public}d", __LINE__, USB_HILOGI(
ret); MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead001 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.RegBulkCallback(pipe, point, cb); ret = UsbSrvClient.RegBulkCallback(pipe, point, cb);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead001 %{public}d RegBulkCallback=%{public}d", __LINE__, USB_HILOGI(
ret); MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead001 %{public}d RegBulkCallback=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.BulkRead(pipe, point, ashmem); ret = UsbSrvClient.BulkRead(pipe, point, ashmem);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead001 %{public}d BulkRead=%{public}d", __LINE__, ret); USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead001 %{public}d BulkRead=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.UnRegBulkCallback(pipe, point); ret = UsbSrvClient.UnRegBulkCallback(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead001 %{public}d UnRegBulkCallback=%{public}d", USB_HILOGI(
__LINE__, ret); MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead001 %{public}d UnRegBulkCallback=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.BulkCancel(pipe, point); ret = UsbSrvClient.BulkCancel(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead001 %{public}d BulkCancel=%{public}d", __LINE__, ret); USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead001 %{public}d BulkCancel=%{public}d", __LINE__, ret);
@ -480,21 +480,21 @@ HWTEST_F(UsbBulkcallbackTest, BulkRead002, TestSize.Level1)
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1); UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
USBEndpoint point = interface.GetEndpoints().at(1); USBEndpoint point = interface.GetEndpoints().at(1);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead002 %{public}d point=%{public}d", __LINE__, USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead002 %{public}d point=%{public}d", __LINE__,
point.GetInterfaceId()); point.GetInterfaceId());
ret = UsbSrvClient.ClaimInterface(pipe, interface, true); ret = UsbSrvClient.ClaimInterface(pipe, interface, true);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead002 %{public}d ClaimInterface=%{public}d", __LINE__, USB_HILOGI(
ret); MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead002 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.RegBulkCallback(pipe, point, cb); ret = UsbSrvClient.RegBulkCallback(pipe, point, cb);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead002 %{public}d RegBulkCallback=%{public}d", __LINE__, USB_HILOGI(
ret); MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead002 %{public}d RegBulkCallback=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.BulkRead(pipe, point, ashmem); ret = UsbSrvClient.BulkRead(pipe, point, ashmem);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead002 %{public}d BulkRead=%{public}d", __LINE__, ret); USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead002 %{public}d BulkRead=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret != 0); EXPECT_TRUE(ret != 0);
ret = UsbSrvClient.UnRegBulkCallback(pipe, point); ret = UsbSrvClient.UnRegBulkCallback(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead002 %{public}d UnRegBulkCallback=%{public}d", USB_HILOGI(
__LINE__, ret); MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead002 %{public}d UnRegBulkCallback=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.BulkCancel(pipe, point); ret = UsbSrvClient.BulkCancel(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead002 %{public}d BulkCancel=%{public}d", __LINE__, ret); USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead002 %{public}d BulkCancel=%{public}d", __LINE__, ret);
@ -533,14 +533,14 @@ HWTEST_F(UsbBulkcallbackTest, BulkRead003, TestSize.Level1)
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1); UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
USBEndpoint point = interface.GetEndpoints().front(); USBEndpoint point = interface.GetEndpoints().front();
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead003 %{public}d point=%{public}d", __LINE__, USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead003 %{public}d point=%{public}d", __LINE__,
point.GetInterfaceId()); point.GetInterfaceId());
ret = UsbSrvClient.ClaimInterface(pipe, interface, true); ret = UsbSrvClient.ClaimInterface(pipe, interface, true);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead003 %{public}d ClaimInterface=%{public}d", __LINE__, USB_HILOGI(
ret); MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead003 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.RegBulkCallback(pipe, point, cb); ret = UsbSrvClient.RegBulkCallback(pipe, point, cb);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead003 %{public}d RegBulkCallback=%{public}d", __LINE__, USB_HILOGI(
ret); MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead003 %{public}d RegBulkCallback=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
pipe.SetBusNum(BUFFER_SIZE); pipe.SetBusNum(BUFFER_SIZE);
ret = UsbSrvClient.BulkRead(pipe, point, ashmem); ret = UsbSrvClient.BulkRead(pipe, point, ashmem);
@ -548,8 +548,8 @@ HWTEST_F(UsbBulkcallbackTest, BulkRead003, TestSize.Level1)
EXPECT_TRUE(ret != 0); EXPECT_TRUE(ret != 0);
pipe.SetBusNum(device.GetBusNum()); pipe.SetBusNum(device.GetBusNum());
ret = UsbSrvClient.UnRegBulkCallback(pipe, point); ret = UsbSrvClient.UnRegBulkCallback(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead003 %{public}d UnRegBulkCallback=%{public}d", USB_HILOGI(
__LINE__, ret); MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead003 %{public}d UnRegBulkCallback=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.BulkCancel(pipe, point); ret = UsbSrvClient.BulkCancel(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead003 %{public}d BulkCancel=%{public}d", __LINE__, ret); USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead003 %{public}d BulkCancel=%{public}d", __LINE__, ret);
@ -588,14 +588,14 @@ HWTEST_F(UsbBulkcallbackTest, BulkRead004, TestSize.Level1)
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1); UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
USBEndpoint point = interface.GetEndpoints().front(); USBEndpoint point = interface.GetEndpoints().front();
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead004 %{public}d point=%{public}d", __LINE__, USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead004 %{public}d point=%{public}d", __LINE__,
point.GetInterfaceId()); point.GetInterfaceId());
ret = UsbSrvClient.ClaimInterface(pipe, interface, true); ret = UsbSrvClient.ClaimInterface(pipe, interface, true);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead004 %{public}d ClaimInterface=%{public}d", __LINE__, USB_HILOGI(
ret); MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead004 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.RegBulkCallback(pipe, point, cb); ret = UsbSrvClient.RegBulkCallback(pipe, point, cb);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead004 %{public}d RegBulkCallback=%{public}d", __LINE__, USB_HILOGI(
ret); MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead004 %{public}d RegBulkCallback=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
pipe.SetDevAddr(BUFFER_SIZE); pipe.SetDevAddr(BUFFER_SIZE);
ret = UsbSrvClient.BulkRead(pipe, point, ashmem); ret = UsbSrvClient.BulkRead(pipe, point, ashmem);
@ -603,8 +603,8 @@ HWTEST_F(UsbBulkcallbackTest, BulkRead004, TestSize.Level1)
EXPECT_TRUE(ret != 0); EXPECT_TRUE(ret != 0);
pipe.SetDevAddr(device.GetDevAddr()); pipe.SetDevAddr(device.GetDevAddr());
ret = UsbSrvClient.UnRegBulkCallback(pipe, point); ret = UsbSrvClient.UnRegBulkCallback(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead004 %{public}d UnRegBulkCallback=%{public}d", USB_HILOGI(
__LINE__, ret); MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead004 %{public}d UnRegBulkCallback=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.BulkCancel(pipe, point); ret = UsbSrvClient.BulkCancel(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead004 %{public}d BulkCancel=%{public}d", __LINE__, ret); USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead004 %{public}d BulkCancel=%{public}d", __LINE__, ret);
@ -638,31 +638,29 @@ HWTEST_F(UsbBulkcallbackTest, BulkWrite001, TestSize.Level1)
UsbDevice device = devi.front(); UsbDevice device = devi.front();
UsbSrvClient.RequestRight(device.GetName()); UsbSrvClient.RequestRight(device.GetName());
ret = UsbSrvClient.OpenDevice(device, pipe); ret = UsbSrvClient.OpenDevice(device, pipe);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite001 %{public}d OpenDevice=%{public}d", __LINE__, USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite001 %{public}d OpenDevice=%{public}d", __LINE__, ret);
ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1); UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
USBEndpoint point = interface.GetEndpoints().at(1); USBEndpoint point = interface.GetEndpoints().at(1);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite001 %{public}d point=%{public}d", __LINE__, USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite001 %{public}d point=%{public}d", __LINE__,
point.GetInterfaceId()); point.GetInterfaceId());
ret = UsbSrvClient.ClaimInterface(pipe, interface, true); ret = UsbSrvClient.ClaimInterface(pipe, interface, true);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite001 %{public}d ClaimInterface=%{public}d", __LINE__, USB_HILOGI(
ret); MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite001 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.RegBulkCallback(pipe, point, cb); ret = UsbSrvClient.RegBulkCallback(pipe, point, cb);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite001 %{public}d RegBulkCallback=%{public}d", __LINE__, USB_HILOGI(
ret); MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite001 %{public}d RegBulkCallback=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.BulkWrite(pipe, point, ashmem); ret = UsbSrvClient.BulkWrite(pipe, point, ashmem);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite001 %{public}d BulkWrite=%{public}d", __LINE__, ret); USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite001 %{public}d BulkWrite=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.UnRegBulkCallback(pipe, point); ret = UsbSrvClient.UnRegBulkCallback(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite001 %{public}d UnRegBulkCallback=%{public}d", USB_HILOGI(
__LINE__, ret); MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite001 %{public}d UnRegBulkCallback=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.BulkCancel(pipe, point); ret = UsbSrvClient.BulkCancel(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite001 %{public}d BulkCancel=%{public}d", __LINE__, USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite001 %{public}d BulkCancel=%{public}d", __LINE__, ret);
ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
bool close = UsbSrvClient.Close(pipe); bool close = UsbSrvClient.Close(pipe);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite001 %{public}d close=%{public}d", __LINE__, close); USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite001 %{public}d close=%{public}d", __LINE__, close);
@ -693,20 +691,19 @@ HWTEST_F(UsbBulkcallbackTest, BulkWrite002, TestSize.Level1)
UsbDevice device = devi.front(); UsbDevice device = devi.front();
UsbSrvClient.RequestRight(device.GetName()); UsbSrvClient.RequestRight(device.GetName());
ret = UsbSrvClient.OpenDevice(device, pipe); ret = UsbSrvClient.OpenDevice(device, pipe);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite002 %{public}d OpenDevice=%{public}d", __LINE__, USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite002 %{public}d OpenDevice=%{public}d", __LINE__, ret);
ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1); UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
USBEndpoint point = interface.GetEndpoints().at(1); USBEndpoint point = interface.GetEndpoints().at(1);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite002 %{public}d point=%{public}d", __LINE__, USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite002 %{public}d point=%{public}d", __LINE__,
point.GetInterfaceId()); point.GetInterfaceId());
ret = UsbSrvClient.ClaimInterface(pipe, interface, true); ret = UsbSrvClient.ClaimInterface(pipe, interface, true);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite002 %{public}d ClaimInterface=%{public}d", __LINE__, USB_HILOGI(
ret); MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite002 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.RegBulkCallback(pipe, point, cb); ret = UsbSrvClient.RegBulkCallback(pipe, point, cb);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite002 %{public}d RegBulkCallback=%{public}d", __LINE__, USB_HILOGI(
ret); MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite002 %{public}d RegBulkCallback=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
pipe.SetBusNum(BUFFER_SIZE); pipe.SetBusNum(BUFFER_SIZE);
ret = UsbSrvClient.BulkWrite(pipe, point, ashmem); ret = UsbSrvClient.BulkWrite(pipe, point, ashmem);
@ -714,12 +711,11 @@ HWTEST_F(UsbBulkcallbackTest, BulkWrite002, TestSize.Level1)
EXPECT_TRUE(ret != 0); EXPECT_TRUE(ret != 0);
pipe.SetBusNum(device.GetBusNum()); pipe.SetBusNum(device.GetBusNum());
ret = UsbSrvClient.UnRegBulkCallback(pipe, point); ret = UsbSrvClient.UnRegBulkCallback(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite002 %{public}d UnRegBulkCallback=%{public}d", USB_HILOGI(
__LINE__, ret); MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite002 %{public}d UnRegBulkCallback=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.BulkCancel(pipe, point); ret = UsbSrvClient.BulkCancel(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite002 %{public}d BulkCancel=%{public}d", __LINE__, USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite002 %{public}d BulkCancel=%{public}d", __LINE__, ret);
ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
bool close = UsbSrvClient.Close(pipe); bool close = UsbSrvClient.Close(pipe);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite002 %{public}d close=%{public}d", __LINE__, close); USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite002 %{public}d close=%{public}d", __LINE__, close);
@ -750,20 +746,19 @@ HWTEST_F(UsbBulkcallbackTest, BulkWrite003, TestSize.Level1)
UsbDevice device = devi.front(); UsbDevice device = devi.front();
UsbSrvClient.RequestRight(device.GetName()); UsbSrvClient.RequestRight(device.GetName());
ret = UsbSrvClient.OpenDevice(device, pipe); ret = UsbSrvClient.OpenDevice(device, pipe);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite003 %{public}d OpenDevice=%{public}d", __LINE__, USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite003 %{public}d OpenDevice=%{public}d", __LINE__, ret);
ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1); UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
USBEndpoint point = interface.GetEndpoints().at(1); USBEndpoint point = interface.GetEndpoints().at(1);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite003 %{public}d point=%{public}d", __LINE__, USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite003 %{public}d point=%{public}d", __LINE__,
point.GetInterfaceId()); point.GetInterfaceId());
ret = UsbSrvClient.ClaimInterface(pipe, interface, true); ret = UsbSrvClient.ClaimInterface(pipe, interface, true);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite003 %{public}d ClaimInterface=%{public}d", __LINE__, USB_HILOGI(
ret); MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite003 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.RegBulkCallback(pipe, point, cb); ret = UsbSrvClient.RegBulkCallback(pipe, point, cb);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite003 %{public}d RegBulkCallback=%{public}d", __LINE__, USB_HILOGI(
ret); MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite003 %{public}d RegBulkCallback=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
pipe.SetDevAddr(BUFFER_SIZE); pipe.SetDevAddr(BUFFER_SIZE);
ret = UsbSrvClient.BulkWrite(pipe, point, ashmem); ret = UsbSrvClient.BulkWrite(pipe, point, ashmem);
@ -771,12 +766,11 @@ HWTEST_F(UsbBulkcallbackTest, BulkWrite003, TestSize.Level1)
EXPECT_TRUE(ret != 0); EXPECT_TRUE(ret != 0);
pipe.SetDevAddr(device.GetDevAddr()); pipe.SetDevAddr(device.GetDevAddr());
ret = UsbSrvClient.UnRegBulkCallback(pipe, point); ret = UsbSrvClient.UnRegBulkCallback(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite003 %{public}d UnRegBulkCallback=%{public}d", USB_HILOGI(
__LINE__, ret); MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite003 %{public}d UnRegBulkCallback=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.BulkCancel(pipe, point); ret = UsbSrvClient.BulkCancel(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite003 %{public}d BulkCancel=%{public}d", __LINE__, USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite003 %{public}d BulkCancel=%{public}d", __LINE__, ret);
ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
bool close = UsbSrvClient.Close(pipe); bool close = UsbSrvClient.Close(pipe);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite003 %{public}d close=%{public}d", __LINE__, close); USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite003 %{public}d close=%{public}d", __LINE__, close);
@ -812,25 +806,25 @@ HWTEST_F(UsbBulkcallbackTest, BulkCancel001, TestSize.Level1)
ret = UsbSrvClient.ClaimInterface(pipe, interface, true); ret = UsbSrvClient.ClaimInterface(pipe, interface, true);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.RegBulkCallback(pipe, point, cb); ret = UsbSrvClient.RegBulkCallback(pipe, point, cb);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkCancel001 %{public}d RegBulkCallback=%{public}d", USB_HILOGI(
__LINE__, ret); MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkCancel001 %{public}d RegBulkCallback=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.BulkRead(pipe, point, ashmem); ret = UsbSrvClient.BulkRead(pipe, point, ashmem);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkCancel001 %{public}d BulkRead=%{public}d", __LINE__, ret); USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkCancel001 %{public}d BulkRead=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.UnRegBulkCallback(pipe, point); ret = UsbSrvClient.UnRegBulkCallback(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkCancel001 %{public}d UnRegBulkCallback=%{public}d", USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkCancel001 %{public}d UnRegBulkCallback=%{public}d",
__LINE__, ret); __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
pipe.SetBusNum(BUFFER_SIZE); pipe.SetBusNum(BUFFER_SIZE);
ret = UsbSrvClient.BulkCancel(pipe, point); ret = UsbSrvClient.BulkCancel(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkCancel001 %{public}d BulkCancel=%{public}d", __LINE__, USB_HILOGI(
ret); MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkCancel001 %{public}d BulkCancel=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret != 0); EXPECT_TRUE(ret != 0);
pipe.SetBusNum(device.GetBusNum()); pipe.SetBusNum(device.GetBusNum());
ret = UsbSrvClient.BulkCancel(pipe, point); ret = UsbSrvClient.BulkCancel(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkCancel002 %{public}d BulkCancel=%{public}d", __LINE__, USB_HILOGI(
ret); MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkCancel002 %{public}d BulkCancel=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
bool close = UsbSrvClient.Close(pipe); bool close = UsbSrvClient.Close(pipe);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkCancel001 %{public}d close=%{public}d", __LINE__, close); USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkCancel001 %{public}d close=%{public}d", __LINE__, close);
@ -861,33 +855,33 @@ HWTEST_F(UsbBulkcallbackTest, BulkCancel002, TestSize.Level1)
UsbDevice device = devi.front(); UsbDevice device = devi.front();
UsbSrvClient.RequestRight(device.GetName()); UsbSrvClient.RequestRight(device.GetName());
ret = UsbSrvClient.OpenDevice(device, pipe); ret = UsbSrvClient.OpenDevice(device, pipe);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkCancel002 %{public}d OpenDevice=%{public}d", __LINE__, USB_HILOGI(
ret); MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkCancel002 %{public}d OpenDevice=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1); UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
USBEndpoint point = interface.GetEndpoints().front(); USBEndpoint point = interface.GetEndpoints().front();
ret = UsbSrvClient.ClaimInterface(pipe, interface, true); ret = UsbSrvClient.ClaimInterface(pipe, interface, true);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.RegBulkCallback(pipe, point, cb); ret = UsbSrvClient.RegBulkCallback(pipe, point, cb);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkCancel002 %{public}d RegBulkCallback=%{public}d", USB_HILOGI(
__LINE__, ret); MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkCancel002 %{public}d RegBulkCallback=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.BulkRead(pipe, point, ashmem); ret = UsbSrvClient.BulkRead(pipe, point, ashmem);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkCancel002 %{public}d BulkRead=%{public}d", __LINE__, ret); USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkCancel002 %{public}d BulkRead=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.UnRegBulkCallback(pipe, point); ret = UsbSrvClient.UnRegBulkCallback(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkCancel002 %{public}d UnRegBulkCallback=%{public}d", USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkCancel002 %{public}d UnRegBulkCallback=%{public}d",
__LINE__, ret); __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
pipe.SetDevAddr(BUFFER_SIZE); pipe.SetDevAddr(BUFFER_SIZE);
ret = UsbSrvClient.BulkCancel(pipe, point); ret = UsbSrvClient.BulkCancel(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkCancel002 %{public}d BulkCancel=%{public}d", __LINE__, USB_HILOGI(
ret); MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkCancel002 %{public}d BulkCancel=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret != 0); EXPECT_TRUE(ret != 0);
pipe.SetDevAddr(device.GetDevAddr()); pipe.SetDevAddr(device.GetDevAddr());
ret = UsbSrvClient.BulkCancel(pipe, point); ret = UsbSrvClient.BulkCancel(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkCancel002 %{public}d BulkCancel=%{public}d", __LINE__, USB_HILOGI(
ret); MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkCancel002 %{public}d BulkCancel=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
bool close = UsbSrvClient.Close(pipe); bool close = UsbSrvClient.Close(pipe);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkCancel002 %{public}d close=%{public}d", __LINE__, close); USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkCancel002 %{public}d close=%{public}d", __LINE__, close);
@ -910,33 +904,33 @@ HWTEST_F(UsbBulkcallbackTest, UnRegBulkCallback001, TestSize.Level1)
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
EXPECT_TRUE(!(devi.empty())) << "delist NULL"; EXPECT_TRUE(!(devi.empty())) << "delist NULL";
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback001 %{public}d size=%{public}zu", __LINE__, USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback001 %{public}d size=%{public}zu", __LINE__,
devi.size()); devi.size());
USBDevicePipe pipe; USBDevicePipe pipe;
UsbDevice device = devi.front(); UsbDevice device = devi.front();
UsbSrvClient.RequestRight(device.GetName()); UsbSrvClient.RequestRight(device.GetName());
ret = UsbSrvClient.OpenDevice(device, pipe); ret = UsbSrvClient.OpenDevice(device, pipe);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback001 %{public}d OpenDevice=%{public}d", USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback001 %{public}d OpenDevice=%{public}d",
__LINE__, ret); __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1); UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
USBEndpoint point = interface.GetEndpoints().front(); USBEndpoint point = interface.GetEndpoints().front();
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback001 %{public}d point=%{public}d", __LINE__, USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback001 %{public}d point=%{public}d", __LINE__,
point.GetInterfaceId()); point.GetInterfaceId());
ret = UsbSrvClient.ClaimInterface(pipe, interface, true); ret = UsbSrvClient.ClaimInterface(pipe, interface, true);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback001 %{public}d ClaimInterface=%{public}d", USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback001 %{public}d ClaimInterface=%{public}d",
__LINE__, ret); __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.RegBulkCallback(pipe, point, cb); ret = UsbSrvClient.RegBulkCallback(pipe, point, cb);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback001 %{public}d RegBulkCallback=%{public}d", USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback001 %{public}d RegBulkCallback=%{public}d",
__LINE__, ret); __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.UnRegBulkCallback(pipe, point); ret = UsbSrvClient.UnRegBulkCallback(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback001 %{public}d UnRegBulkCallback=%{public}d", USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback001 %{public}d UnRegBulkCallback=%{public}d",
__LINE__, ret); __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
bool close = UsbSrvClient.Close(pipe); bool close = UsbSrvClient.Close(pipe);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback001 %{public}d close=%{public}d", __LINE__, USB_HILOGI(
close); MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback001 %{public}d close=%{public}d", __LINE__, close);
EXPECT_TRUE(close); EXPECT_TRUE(close);
USB_HILOGI(MODULE_USB_SERVICE, "Case End : UnRegBulkCallback001 : BulkTransfer"); USB_HILOGI(MODULE_USB_SERVICE, "Case End : UnRegBulkCallback001 : BulkTransfer");
} }
@ -960,29 +954,29 @@ HWTEST_F(UsbBulkcallbackTest, UnRegBulkCallback002, TestSize.Level1)
UsbSrvClient.RequestRight(device.GetName()); UsbSrvClient.RequestRight(device.GetName());
ret = UsbSrvClient.OpenDevice(device, pipe); ret = UsbSrvClient.OpenDevice(device, pipe);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback002 %{public}d OpenDevice=%{public}d", USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback002 %{public}d OpenDevice=%{public}d",
__LINE__, ret); __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1); UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
USBEndpoint point = interface.GetEndpoints().front(); USBEndpoint point = interface.GetEndpoints().front();
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback002 %{public}d point=%{public}d", __LINE__, USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback002 %{public}d point=%{public}d", __LINE__,
point.GetInterfaceId()); point.GetInterfaceId());
ret = UsbSrvClient.ClaimInterface(pipe, interface, true); ret = UsbSrvClient.ClaimInterface(pipe, interface, true);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback002 %{public}d ClaimInterface=%{public}d", USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback002 %{public}d ClaimInterface=%{public}d",
__LINE__, ret); __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
pipe.SetBusNum(BUFFER_SIZE); pipe.SetBusNum(BUFFER_SIZE);
ret = UsbSrvClient.RegBulkCallback(pipe, point, cb); ret = UsbSrvClient.RegBulkCallback(pipe, point, cb);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback002 %{public}d RegBulkCallback=%{public}d", USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback002 %{public}d RegBulkCallback=%{public}d",
__LINE__, ret); __LINE__, ret);
EXPECT_TRUE(ret != 0); EXPECT_TRUE(ret != 0);
ret = UsbSrvClient.UnRegBulkCallback(pipe, point); ret = UsbSrvClient.UnRegBulkCallback(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback002 %{public}d UnRegBulkCallback=%{public}d", USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback002 %{public}d UnRegBulkCallback=%{public}d",
__LINE__, ret); __LINE__, ret);
EXPECT_TRUE(ret != 0); EXPECT_TRUE(ret != 0);
pipe.SetBusNum(device.GetBusNum()); pipe.SetBusNum(device.GetBusNum());
bool close = UsbSrvClient.Close(pipe); bool close = UsbSrvClient.Close(pipe);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback002 %{public}d close=%{public}d", __LINE__, USB_HILOGI(
close); MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback002 %{public}d close=%{public}d", __LINE__, close);
EXPECT_TRUE(close); EXPECT_TRUE(close);
USB_HILOGI(MODULE_USB_SERVICE, "Case End : UnRegBulkCallback002 : BulkTransfer"); USB_HILOGI(MODULE_USB_SERVICE, "Case End : UnRegBulkCallback002 : BulkTransfer");
} }
@ -1002,38 +996,38 @@ HWTEST_F(UsbBulkcallbackTest, UnRegBulkCallback003, TestSize.Level1)
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
EXPECT_TRUE(!(devi.empty())) << "delist NULL"; EXPECT_TRUE(!(devi.empty())) << "delist NULL";
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback003 %{public}d size=%{public}zu", __LINE__, USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback003 %{public}d size=%{public}zu", __LINE__,
devi.size()); devi.size());
USBDevicePipe pipe; USBDevicePipe pipe;
UsbDevice device = devi.front(); UsbDevice device = devi.front();
UsbSrvClient.RequestRight(device.GetName()); UsbSrvClient.RequestRight(device.GetName());
ret = UsbSrvClient.OpenDevice(device, pipe); ret = UsbSrvClient.OpenDevice(device, pipe);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback003 %{public}d OpenDevice=%{public}d", USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback003 %{public}d OpenDevice=%{public}d",
__LINE__, ret); __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1); UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
USBEndpoint point = interface.GetEndpoints().front(); USBEndpoint point = interface.GetEndpoints().front();
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback003 %{public}d point=%{public}d", __LINE__, USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback003 %{public}d point=%{public}d", __LINE__,
point.GetInterfaceId()); point.GetInterfaceId());
ret = UsbSrvClient.ClaimInterface(pipe, interface, true); ret = UsbSrvClient.ClaimInterface(pipe, interface, true);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback003 %{public}d ClaimInterface=%{public}d", USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback003 %{public}d ClaimInterface=%{public}d",
__LINE__, ret); __LINE__, ret);
EXPECT_TRUE(ret == 0); EXPECT_TRUE(ret == 0);
pipe.SetDevAddr(BUFFER_SIZE); pipe.SetDevAddr(BUFFER_SIZE);
ret = UsbSrvClient.RegBulkCallback(pipe, point, cb); ret = UsbSrvClient.RegBulkCallback(pipe, point, cb);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback003 %{public}d RegBulkCallback=%{public}d", USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback003 %{public}d RegBulkCallback=%{public}d",
__LINE__, ret); __LINE__, ret);
EXPECT_TRUE(ret != 0); EXPECT_TRUE(ret != 0);
ret = UsbSrvClient.UnRegBulkCallback(pipe, point); ret = UsbSrvClient.UnRegBulkCallback(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback003 %{public}d UnRegBulkCallback=%{public}d", USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback003 %{public}d UnRegBulkCallback=%{public}d",
__LINE__, ret); __LINE__, ret);
EXPECT_TRUE(ret != 0); EXPECT_TRUE(ret != 0);
pipe.SetDevAddr(device.GetDevAddr()); pipe.SetDevAddr(device.GetDevAddr());
bool close = UsbSrvClient.Close(pipe); bool close = UsbSrvClient.Close(pipe);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback003 %{public}d close=%{public}d", __LINE__, USB_HILOGI(
close); MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback003 %{public}d close=%{public}d", __LINE__, close);
EXPECT_TRUE(close); EXPECT_TRUE(close);
USB_HILOGI(MODULE_USB_SERVICE, "Case End : UnRegBulkCallback003 : BulkTransfer"); USB_HILOGI(MODULE_USB_SERVICE, "Case End : UnRegBulkCallback003 : BulkTransfer");
} }
} // BulkCallback } // namespace BulkCallback
} // USB } // namespace USB
} // OHOS } // namespace OHOS

View File

@ -15,26 +15,11 @@
#include "usb_common_test.h" #include "usb_common_test.h"
static constexpr int32_t DEFAULT_API_VERSION = 8;
using namespace OHOS::Security::AccessToken; using namespace OHOS::Security::AccessToken;
namespace OHOS { namespace OHOS {
namespace USB { namespace USB {
namespace Common { namespace Common {
static HapInfoParams g_InfoParams = {
.userID = 1,
.bundleName = "usb",
.instIndex = 0,
.appIDDesc = "usb_test",
.apiVersion = DEFAULT_API_VERSION,
.isSystemApp = true
};
HapPolicyParams policy = {
.apl = APL_SYSTEM_BASIC,
.domain = "domain"
};
TokenInfoParams g_normalInfoInstance = { TokenInfoParams g_normalInfoInstance = {
.dcapsNum = 0, .dcapsNum = 0,
.permsNum = 0, .permsNum = 0,
@ -57,15 +42,7 @@ TokenInfoParams g_sysInfoInstance = {
.aplStr = "system_basic", .aplStr = "system_basic",
}; };
void UsbCommonTest::SetTestCaseHapApply (void) void UsbCommonTest::SetTestCaseNative(TokenInfoParams *infoInstance)
{
AccessTokenKit::AllocHapToken(g_InfoParams, policy);
AccessTokenIDEx tokenID = AccessTokenKit::GetHapTokenIDEx(g_InfoParams.userID, g_InfoParams.bundleName,
g_InfoParams.instIndex);
SetSelfTokenID(tokenID.tokenIDEx);
}
void UsbCommonTest::SetTestCaseNative (TokenInfoParams *infoInstance)
{ {
uint64_t tokenId = GetAccessTokenId(infoInstance); uint64_t tokenId = GetAccessTokenId(infoInstance);
int ret = SetSelfTokenID(tokenId); int ret = SetSelfTokenID(tokenId);
@ -86,6 +63,6 @@ void UsbCommonTest::GrantPermissionNormalNative()
{ {
SetTestCaseNative(&g_normalInfoInstance); SetTestCaseNative(&g_normalInfoInstance);
} }
} // Common } // namespace Common
} // USB } // namespace USB
} // OHOS } // namespace OHOS

View File

@ -41,7 +41,7 @@ constexpr int32_t SLEEP_TIME = 3;
constexpr int32_t BUFFER_SIZE = 255; constexpr int32_t BUFFER_SIZE = 255;
void UsbDevicePipeTest::SetUpTestCase(void) void UsbDevicePipeTest::SetUpTestCase(void)
{ {
UsbCommonTest::SetTestCaseHapApply(); UsbCommonTest::GrantPermissionSysNative();
auto &srvClient = UsbSrvClient::GetInstance(); auto &srvClient = UsbSrvClient::GetInstance();
auto ret = srvClient.SetPortRole(1, 1, 1); auto ret = srvClient.SetPortRole(1, 1, 1);
sleep(SLEEP_TIME); sleep(SLEEP_TIME);

View File

@ -45,7 +45,7 @@ constexpr int32_t TAG_SIZE = 50;
constexpr int32_t BUFFER_SIZE = 255; constexpr int32_t BUFFER_SIZE = 255;
void UsbRequestTest::SetUpTestCase(void) void UsbRequestTest::SetUpTestCase(void)
{ {
UsbCommonTest::SetTestCaseHapApply(); UsbCommonTest::GrantPermissionSysNative();
auto &srvClient = UsbSrvClient::GetInstance(); auto &srvClient = UsbSrvClient::GetInstance();
auto ret = srvClient.SetPortRole(1, 1, 1); auto ret = srvClient.SetPortRole(1, 1, 1);
sleep(SLEEP_TIME); sleep(SLEEP_TIME);

View File

@ -13,8 +13,8 @@
* limitations under the License. * limitations under the License.
*/ */
#include "usb_srv_client.h"
#include "usb_common_test.h" #include "usb_common_test.h"
#include "usb_srv_client.h"
using namespace std; using namespace std;
using namespace OHOS; using namespace OHOS;
@ -126,7 +126,7 @@ static inline bool isNumber(string_view strv)
int32_t main(int32_t argc, char *argv[]) int32_t main(int32_t argc, char *argv[])
{ {
UsbCommonTest::SetTestCaseHapApply(); UsbCommonTest::GrantPermissionSysNative();
if (argc < MIN_ARG_NUM) { if (argc < MIN_ARG_NUM) {
PrintHelp(); PrintHelp();
@ -150,4 +150,3 @@ int32_t main(int32_t argc, char *argv[])
} }
return 0; return 0;
} }