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
FixNamespaceComments: true
ConstructorInitializerAllOnOneLineOrOnePerLine: true
BreakConstructorInitializers: AfterColon
BreakConstructorInitializers: BeforeColon
AlignArrayOfStructures: Left
AllowShortFunctionsOnASingleLine: Empty
AllowShortLambdasOnASingleLine: Empty

View File

@ -111,11 +111,6 @@ int32_t UsbRightManager::Init()
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;
GetCurrentUserId(uid);
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)
{
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;
GetCurrentUserId(uid);
if (uid == USB_RIGHT_USERID_CONSOLE) {

View File

@ -96,7 +96,8 @@ int32_t UsbService::SetUsbd(const sptr<IUsbInterface> &usbd)
}
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)
{
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;
if (!GetBundleName(bundleName)) {
USB_HILOGE(MODULE_USB_SERVICE, "HasRight GetBundleName 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());
return usbRightManager_->HasRight(GetDeviceVidPidSerialNumber(deviceName), bundleName);
}
@ -307,16 +313,20 @@ bool UsbService::HasRight(std::string deviceName)
int32_t UsbService::RequestRight(std::string deviceName)
{
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;
if (!GetBundleName(bundleName)) {
USB_HILOGI(MODULE_USB_SERVICE, "RequestRight GetBundleName false");
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());
return usbRightManager_->RequestRight(deviceName, GetDeviceVidPidSerialNumber(deviceName), bundleName);
}
@ -328,6 +338,11 @@ int32_t UsbService::RemoveRight(std::string deviceName)
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;
if (!GetBundleName(bundleName)) {
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.SetmSerial(GetDevStringValFromIdx(busNum, devAddr, dev.GetiSerialNumber()));
USB_HILOGI(MODULE_USB_SERVICE,
"iSerial:%{public}d Manufactur:%{public}s product:%{public}s " "version:%{public}s",
dev.GetiSerialNumber(), dev.GetManufacturerName().c_str(),
dev.GetProductName().c_str(), dev.GetVersion().c_str());
"iSerial:%{public}d Manufactur:%{public}s product:%{public}s "
"version:%{public}s",
dev.GetiSerialNumber(), dev.GetManufacturerName().c_str(), dev.GetProductName().c_str(),
dev.GetVersion().c_str());
std::vector<USBConfig> configs;
configs = dev.GetConfigs();

View File

@ -26,7 +26,6 @@ namespace USB {
namespace Common {
class UsbCommonTest {
public:
static void SetTestCaseHapApply();
static void SetTestCaseNative (TokenInfoParams *infoInstance);
static void GrantPermissionSysNative();
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)
{
UsbCommonTest::SetTestCaseHapApply();
UsbCommonTest::GrantPermissionSysNative();
auto &srvClient = UsbSrvClient::GetInstance();
auto ret = srvClient.SetPortRole(1, 1, 1);
sleep(SLEEP_TIME);
@ -120,33 +120,33 @@ HWTEST_F(UsbBulkcallbackTest, RegBulkCallback001, TestSize.Level1)
EXPECT_TRUE(ret == 0);
EXPECT_TRUE(!(devi.empty())) << "delist NULL";
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback001 %{public}d size=%{public}zu", __LINE__,
devi.size());
devi.size());
USBDevicePipe pipe;
UsbDevice device = devi.front();
UsbSrvClient.RequestRight(device.GetName());
ret = UsbSrvClient.OpenDevice(device, pipe);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback001 %{public}d OpenDevice=%{public}d",
__LINE__, ret);
USB_HILOGI(
MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback001 %{public}d OpenDevice=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0);
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
USBEndpoint point = interface.GetEndpoints().front();
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback001 %{public}d point=%{public}d", __LINE__,
point.GetInterfaceId());
point.GetInterfaceId());
ret = UsbSrvClient.ClaimInterface(pipe, interface, true);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback001 %{public}d ClaimInterface=%{public}d",
__LINE__, ret);
__LINE__, ret);
EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.RegBulkCallback(pipe, point, cb);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback001 %{public}d RegBulkCallback=%{public}d",
__LINE__, ret);
__LINE__, ret);
EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.UnRegBulkCallback(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback001 %{public}d UnRegBulkCallback=%{public}d",
__LINE__, ret);
__LINE__, ret);
EXPECT_TRUE(ret == 0);
bool close = UsbSrvClient.Close(pipe);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback001 %{public}d close=%{public}d", __LINE__,
close);
USB_HILOGI(
MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback001 %{public}d close=%{public}d", __LINE__, close);
EXPECT_TRUE(close);
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(!(devi.empty())) << "delist NULL";
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback002 %{public}d size=%{public}zu", __LINE__,
devi.size());
devi.size());
USBDevicePipe pipe;
UsbDevice device = devi.front();
UsbSrvClient.RequestRight(device.GetName());
ret = UsbSrvClient.OpenDevice(device, pipe);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback002 %{public}d OpenDevice=%{public}d",
__LINE__, ret);
USB_HILOGI(
MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback002 %{public}d OpenDevice=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0);
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
USBEndpoint point = interface.GetEndpoints().at(1);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback002 %{public}d point=%{public}d", __LINE__,
point.GetInterfaceId());
point.GetInterfaceId());
ret = UsbSrvClient.ClaimInterface(pipe, interface, true);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback002 %{public}d ClaimInterface=%{public}d",
__LINE__, ret);
__LINE__, ret);
EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.RegBulkCallback(pipe, point, cb);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback002 %{public}d RegBulkCallback=%{public}d",
__LINE__, ret);
__LINE__, ret);
EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.UnRegBulkCallback(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback002 %{public}d UnRegBulkCallback=%{public}d",
__LINE__, ret);
__LINE__, ret);
EXPECT_TRUE(ret == 0);
bool close = UsbSrvClient.Close(pipe);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback002 %{public}d close=%{public}d", __LINE__,
close);
USB_HILOGI(
MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback002 %{public}d close=%{public}d", __LINE__, close);
EXPECT_TRUE(close);
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(!(devi.empty())) << "delist NULL";
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback003 %{public}d size=%{public}zu", __LINE__,
devi.size());
devi.size());
USBDevicePipe pipe;
UsbDevice device = devi.front();
UsbSrvClient.RequestRight(device.GetName());
ret = UsbSrvClient.OpenDevice(device, pipe);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback003 %{public}d OpenDevice=%{public}d",
__LINE__, ret);
USB_HILOGI(
MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback003 %{public}d OpenDevice=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0);
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
USBEndpoint point = interface.GetEndpoints().at(1);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback003 %{public}d point=%{public}d", __LINE__,
point.GetInterfaceId());
point.GetInterfaceId());
ret = UsbSrvClient.ClaimInterface(pipe, interface, true);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback003 %{public}d ClaimInterface=%{public}d",
__LINE__, ret);
__LINE__, ret);
EXPECT_TRUE(ret == 0);
pipe.SetBusNum(BUFFER_SIZE);
ret = UsbSrvClient.RegBulkCallback(pipe, point, cb);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback003 %{public}d RegBulkCallback=%{public}d",
__LINE__, ret);
__LINE__, ret);
EXPECT_TRUE(ret != 0);
ret = UsbSrvClient.UnRegBulkCallback(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback003 %{public}d UnRegBulkCallback=%{public}d",
__LINE__, ret);
__LINE__, ret);
EXPECT_TRUE(ret != 0);
pipe.SetBusNum(device.GetBusNum());
bool close = UsbSrvClient.Close(pipe);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback003 %{public}d close=%{public}d", __LINE__,
close);
USB_HILOGI(
MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback003 %{public}d close=%{public}d", __LINE__, close);
EXPECT_TRUE(close);
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(!(devi.empty())) << "delist NULL";
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback004 %{public}d size=%{public}zu", __LINE__,
devi.size());
devi.size());
USBDevicePipe pipe;
UsbDevice device = devi.front();
UsbSrvClient.RequestRight(device.GetName());
ret = UsbSrvClient.OpenDevice(device, pipe);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback004 %{public}d OpenDevice=%{public}d",
__LINE__, ret);
USB_HILOGI(
MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback004 %{public}d OpenDevice=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0);
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
USBEndpoint point = interface.GetEndpoints().at(1);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback004 %{public}d point=%{public}d", __LINE__,
point.GetInterfaceId());
point.GetInterfaceId());
ret = UsbSrvClient.ClaimInterface(pipe, interface, true);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback004 %{public}d ClaimInterface=%{public}d",
__LINE__, ret);
__LINE__, ret);
EXPECT_TRUE(ret == 0);
pipe.SetDevAddr(BUFFER_SIZE);
ret = UsbSrvClient.RegBulkCallback(pipe, point, cb);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback004 %{public}d RegBulkCallback=%{public}d",
__LINE__, ret);
__LINE__, ret);
EXPECT_TRUE(ret != 0);
ret = UsbSrvClient.UnRegBulkCallback(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback004 %{public}d UnRegBulkCallback=%{public}d",
__LINE__, ret);
__LINE__, ret);
EXPECT_TRUE(ret != 0);
pipe.SetDevAddr(device.GetDevAddr());
bool close = UsbSrvClient.Close(pipe);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback004 %{public}d close=%{public}d", __LINE__,
close);
USB_HILOGI(
MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback004 %{public}d close=%{public}d", __LINE__, close);
EXPECT_TRUE(close);
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(!(devi.empty())) << "delist NULL";
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback005 %{public}d size=%{public}zu", __LINE__,
devi.size());
devi.size());
USBDevicePipe pipe;
UsbDevice device = devi.front();
UsbSrvClient.RequestRight(device.GetName());
ret = UsbSrvClient.OpenDevice(device, pipe);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback005 %{public}d OpenDevice=%{public}d",
__LINE__, ret);
USB_HILOGI(
MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback005 %{public}d OpenDevice=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0);
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
USBEndpoint point = interface.GetEndpoints().at(0);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback005 %{public}d point=%{public}d", __LINE__,
point.GetInterfaceId());
point.GetInterfaceId());
ret = UsbSrvClient.ClaimInterface(pipe, interface, true);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback005 %{public}d ClaimInterface=%{public}d",
__LINE__, ret);
__LINE__, ret);
EXPECT_TRUE(ret == 0);
pipe.SetDevAddr(BUFFER_SIZE);
ret = UsbSrvClient.RegBulkCallback(pipe, point, cb);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback005 %{public}d RegBulkCallback=%{public}d",
__LINE__, ret);
__LINE__, ret);
EXPECT_TRUE(ret != 0);
ret = UsbSrvClient.UnRegBulkCallback(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback005 %{public}d UnRegBulkCallback=%{public}d",
__LINE__, ret);
__LINE__, ret);
EXPECT_TRUE(ret != 0);
pipe.SetDevAddr(device.GetDevAddr());
bool close = UsbSrvClient.Close(pipe);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback005 %{public}d close=%{public}d", __LINE__,
close);
USB_HILOGI(
MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback005 %{public}d close=%{public}d", __LINE__, close);
EXPECT_TRUE(close);
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(!(devi.empty())) << "delist NULL";
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback006 %{public}d size=%{public}zu", __LINE__,
devi.size());
devi.size());
USBDevicePipe pipe;
UsbDevice device = devi.front();
UsbSrvClient.RequestRight(device.GetName());
ret = UsbSrvClient.OpenDevice(device, pipe);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback006 %{public}d OpenDevice=%{public}d",
__LINE__, ret);
USB_HILOGI(
MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback006 %{public}d OpenDevice=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0);
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
USBEndpoint point = interface.GetEndpoints().at(0);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback006 %{public}d point=%{public}d", __LINE__,
point.GetInterfaceId());
point.GetInterfaceId());
ret = UsbSrvClient.ClaimInterface(pipe, interface, true);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback006 %{public}d ClaimInterface=%{public}d",
__LINE__, ret);
__LINE__, ret);
EXPECT_TRUE(ret == 0);
pipe.SetBusNum(BUFFER_SIZE);
ret = UsbSrvClient.RegBulkCallback(pipe, point, cb);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback006 %{public}d RegBulkCallback=%{public}d",
__LINE__, ret);
__LINE__, ret);
EXPECT_TRUE(ret != 0);
ret = UsbSrvClient.UnRegBulkCallback(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback006 %{public}d UnRegBulkCallback=%{public}d",
__LINE__, ret);
__LINE__, ret);
EXPECT_TRUE(ret != 0);
pipe.SetBusNum(device.GetBusNum());
bool close = UsbSrvClient.Close(pipe);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback006 %{public}d close=%{public}d", __LINE__,
close);
USB_HILOGI(
MODULE_USB_SERVICE, "UsbBulkcallbackTest::RegBulkCallback006 %{public}d close=%{public}d", __LINE__, close);
EXPECT_TRUE(close);
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);
USBEndpoint point = interface.GetEndpoints().front();
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead001 %{public}d point=%{public}d", __LINE__,
point.GetInterfaceId());
point.GetInterfaceId());
ret = UsbSrvClient.ClaimInterface(pipe, interface, true);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead001 %{public}d ClaimInterface=%{public}d", __LINE__,
ret);
USB_HILOGI(
MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead001 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.RegBulkCallback(pipe, point, cb);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead001 %{public}d RegBulkCallback=%{public}d", __LINE__,
ret);
USB_HILOGI(
MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead001 %{public}d RegBulkCallback=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.BulkRead(pipe, point, ashmem);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead001 %{public}d BulkRead=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.UnRegBulkCallback(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead001 %{public}d UnRegBulkCallback=%{public}d",
__LINE__, ret);
USB_HILOGI(
MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead001 %{public}d UnRegBulkCallback=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.BulkCancel(pipe, point);
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);
USBEndpoint point = interface.GetEndpoints().at(1);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead002 %{public}d point=%{public}d", __LINE__,
point.GetInterfaceId());
point.GetInterfaceId());
ret = UsbSrvClient.ClaimInterface(pipe, interface, true);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead002 %{public}d ClaimInterface=%{public}d", __LINE__,
ret);
USB_HILOGI(
MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead002 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.RegBulkCallback(pipe, point, cb);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead002 %{public}d RegBulkCallback=%{public}d", __LINE__,
ret);
USB_HILOGI(
MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead002 %{public}d RegBulkCallback=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.BulkRead(pipe, point, ashmem);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead002 %{public}d BulkRead=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret != 0);
ret = UsbSrvClient.UnRegBulkCallback(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead002 %{public}d UnRegBulkCallback=%{public}d",
__LINE__, ret);
USB_HILOGI(
MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead002 %{public}d UnRegBulkCallback=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.BulkCancel(pipe, point);
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);
USBEndpoint point = interface.GetEndpoints().front();
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead003 %{public}d point=%{public}d", __LINE__,
point.GetInterfaceId());
point.GetInterfaceId());
ret = UsbSrvClient.ClaimInterface(pipe, interface, true);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead003 %{public}d ClaimInterface=%{public}d", __LINE__,
ret);
USB_HILOGI(
MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead003 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.RegBulkCallback(pipe, point, cb);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead003 %{public}d RegBulkCallback=%{public}d", __LINE__,
ret);
USB_HILOGI(
MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead003 %{public}d RegBulkCallback=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0);
pipe.SetBusNum(BUFFER_SIZE);
ret = UsbSrvClient.BulkRead(pipe, point, ashmem);
@ -548,8 +548,8 @@ HWTEST_F(UsbBulkcallbackTest, BulkRead003, TestSize.Level1)
EXPECT_TRUE(ret != 0);
pipe.SetBusNum(device.GetBusNum());
ret = UsbSrvClient.UnRegBulkCallback(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead003 %{public}d UnRegBulkCallback=%{public}d",
__LINE__, ret);
USB_HILOGI(
MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead003 %{public}d UnRegBulkCallback=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.BulkCancel(pipe, point);
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);
USBEndpoint point = interface.GetEndpoints().front();
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead004 %{public}d point=%{public}d", __LINE__,
point.GetInterfaceId());
point.GetInterfaceId());
ret = UsbSrvClient.ClaimInterface(pipe, interface, true);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead004 %{public}d ClaimInterface=%{public}d", __LINE__,
ret);
USB_HILOGI(
MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead004 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.RegBulkCallback(pipe, point, cb);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead004 %{public}d RegBulkCallback=%{public}d", __LINE__,
ret);
USB_HILOGI(
MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead004 %{public}d RegBulkCallback=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0);
pipe.SetDevAddr(BUFFER_SIZE);
ret = UsbSrvClient.BulkRead(pipe, point, ashmem);
@ -603,8 +603,8 @@ HWTEST_F(UsbBulkcallbackTest, BulkRead004, TestSize.Level1)
EXPECT_TRUE(ret != 0);
pipe.SetDevAddr(device.GetDevAddr());
ret = UsbSrvClient.UnRegBulkCallback(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead004 %{public}d UnRegBulkCallback=%{public}d",
__LINE__, ret);
USB_HILOGI(
MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkRead004 %{public}d UnRegBulkCallback=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.BulkCancel(pipe, point);
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();
UsbSrvClient.RequestRight(device.GetName());
ret = UsbSrvClient.OpenDevice(device, pipe);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite001 %{public}d OpenDevice=%{public}d", __LINE__,
ret);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite001 %{public}d OpenDevice=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0);
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
USBEndpoint point = interface.GetEndpoints().at(1);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite001 %{public}d point=%{public}d", __LINE__,
point.GetInterfaceId());
point.GetInterfaceId());
ret = UsbSrvClient.ClaimInterface(pipe, interface, true);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite001 %{public}d ClaimInterface=%{public}d", __LINE__,
ret);
USB_HILOGI(
MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite001 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.RegBulkCallback(pipe, point, cb);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite001 %{public}d RegBulkCallback=%{public}d", __LINE__,
ret);
USB_HILOGI(
MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite001 %{public}d RegBulkCallback=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.BulkWrite(pipe, point, ashmem);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite001 %{public}d BulkWrite=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.UnRegBulkCallback(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite001 %{public}d UnRegBulkCallback=%{public}d",
__LINE__, ret);
USB_HILOGI(
MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite001 %{public}d UnRegBulkCallback=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.BulkCancel(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite001 %{public}d BulkCancel=%{public}d", __LINE__,
ret);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite001 %{public}d BulkCancel=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0);
bool close = UsbSrvClient.Close(pipe);
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();
UsbSrvClient.RequestRight(device.GetName());
ret = UsbSrvClient.OpenDevice(device, pipe);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite002 %{public}d OpenDevice=%{public}d", __LINE__,
ret);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite002 %{public}d OpenDevice=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0);
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
USBEndpoint point = interface.GetEndpoints().at(1);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite002 %{public}d point=%{public}d", __LINE__,
point.GetInterfaceId());
point.GetInterfaceId());
ret = UsbSrvClient.ClaimInterface(pipe, interface, true);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite002 %{public}d ClaimInterface=%{public}d", __LINE__,
ret);
USB_HILOGI(
MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite002 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.RegBulkCallback(pipe, point, cb);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite002 %{public}d RegBulkCallback=%{public}d", __LINE__,
ret);
USB_HILOGI(
MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite002 %{public}d RegBulkCallback=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0);
pipe.SetBusNum(BUFFER_SIZE);
ret = UsbSrvClient.BulkWrite(pipe, point, ashmem);
@ -714,12 +711,11 @@ HWTEST_F(UsbBulkcallbackTest, BulkWrite002, TestSize.Level1)
EXPECT_TRUE(ret != 0);
pipe.SetBusNum(device.GetBusNum());
ret = UsbSrvClient.UnRegBulkCallback(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite002 %{public}d UnRegBulkCallback=%{public}d",
__LINE__, ret);
USB_HILOGI(
MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite002 %{public}d UnRegBulkCallback=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.BulkCancel(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite002 %{public}d BulkCancel=%{public}d", __LINE__,
ret);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite002 %{public}d BulkCancel=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0);
bool close = UsbSrvClient.Close(pipe);
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();
UsbSrvClient.RequestRight(device.GetName());
ret = UsbSrvClient.OpenDevice(device, pipe);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite003 %{public}d OpenDevice=%{public}d", __LINE__,
ret);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite003 %{public}d OpenDevice=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0);
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
USBEndpoint point = interface.GetEndpoints().at(1);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite003 %{public}d point=%{public}d", __LINE__,
point.GetInterfaceId());
point.GetInterfaceId());
ret = UsbSrvClient.ClaimInterface(pipe, interface, true);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite003 %{public}d ClaimInterface=%{public}d", __LINE__,
ret);
USB_HILOGI(
MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite003 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.RegBulkCallback(pipe, point, cb);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite003 %{public}d RegBulkCallback=%{public}d", __LINE__,
ret);
USB_HILOGI(
MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite003 %{public}d RegBulkCallback=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0);
pipe.SetDevAddr(BUFFER_SIZE);
ret = UsbSrvClient.BulkWrite(pipe, point, ashmem);
@ -771,12 +766,11 @@ HWTEST_F(UsbBulkcallbackTest, BulkWrite003, TestSize.Level1)
EXPECT_TRUE(ret != 0);
pipe.SetDevAddr(device.GetDevAddr());
ret = UsbSrvClient.UnRegBulkCallback(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite003 %{public}d UnRegBulkCallback=%{public}d",
__LINE__, ret);
USB_HILOGI(
MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite003 %{public}d UnRegBulkCallback=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.BulkCancel(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite003 %{public}d BulkCancel=%{public}d", __LINE__,
ret);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkWrite003 %{public}d BulkCancel=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0);
bool close = UsbSrvClient.Close(pipe);
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);
EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.RegBulkCallback(pipe, point, cb);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkCancel001 %{public}d RegBulkCallback=%{public}d",
__LINE__, ret);
USB_HILOGI(
MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkCancel001 %{public}d RegBulkCallback=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.BulkRead(pipe, point, ashmem);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkCancel001 %{public}d BulkRead=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.UnRegBulkCallback(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkCancel001 %{public}d UnRegBulkCallback=%{public}d",
__LINE__, ret);
__LINE__, ret);
EXPECT_TRUE(ret == 0);
pipe.SetBusNum(BUFFER_SIZE);
ret = UsbSrvClient.BulkCancel(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkCancel001 %{public}d BulkCancel=%{public}d", __LINE__,
ret);
USB_HILOGI(
MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkCancel001 %{public}d BulkCancel=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret != 0);
pipe.SetBusNum(device.GetBusNum());
ret = UsbSrvClient.BulkCancel(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkCancel002 %{public}d BulkCancel=%{public}d", __LINE__,
ret);
USB_HILOGI(
MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkCancel002 %{public}d BulkCancel=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0);
bool close = UsbSrvClient.Close(pipe);
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();
UsbSrvClient.RequestRight(device.GetName());
ret = UsbSrvClient.OpenDevice(device, pipe);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkCancel002 %{public}d OpenDevice=%{public}d", __LINE__,
ret);
USB_HILOGI(
MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkCancel002 %{public}d OpenDevice=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0);
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
USBEndpoint point = interface.GetEndpoints().front();
ret = UsbSrvClient.ClaimInterface(pipe, interface, true);
EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.RegBulkCallback(pipe, point, cb);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkCancel002 %{public}d RegBulkCallback=%{public}d",
__LINE__, ret);
USB_HILOGI(
MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkCancel002 %{public}d RegBulkCallback=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.BulkRead(pipe, point, ashmem);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkCancel002 %{public}d BulkRead=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.UnRegBulkCallback(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkCancel002 %{public}d UnRegBulkCallback=%{public}d",
__LINE__, ret);
__LINE__, ret);
EXPECT_TRUE(ret == 0);
pipe.SetDevAddr(BUFFER_SIZE);
ret = UsbSrvClient.BulkCancel(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkCancel002 %{public}d BulkCancel=%{public}d", __LINE__,
ret);
USB_HILOGI(
MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkCancel002 %{public}d BulkCancel=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret != 0);
pipe.SetDevAddr(device.GetDevAddr());
ret = UsbSrvClient.BulkCancel(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkCancel002 %{public}d BulkCancel=%{public}d", __LINE__,
ret);
USB_HILOGI(
MODULE_USB_SERVICE, "UsbBulkcallbackTest::BulkCancel002 %{public}d BulkCancel=%{public}d", __LINE__, ret);
EXPECT_TRUE(ret == 0);
bool close = UsbSrvClient.Close(pipe);
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(!(devi.empty())) << "delist NULL";
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback001 %{public}d size=%{public}zu", __LINE__,
devi.size());
devi.size());
USBDevicePipe pipe;
UsbDevice device = devi.front();
UsbSrvClient.RequestRight(device.GetName());
ret = UsbSrvClient.OpenDevice(device, pipe);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback001 %{public}d OpenDevice=%{public}d",
__LINE__, ret);
__LINE__, ret);
EXPECT_TRUE(ret == 0);
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
USBEndpoint point = interface.GetEndpoints().front();
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback001 %{public}d point=%{public}d", __LINE__,
point.GetInterfaceId());
point.GetInterfaceId());
ret = UsbSrvClient.ClaimInterface(pipe, interface, true);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback001 %{public}d ClaimInterface=%{public}d",
__LINE__, ret);
__LINE__, ret);
EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.RegBulkCallback(pipe, point, cb);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback001 %{public}d RegBulkCallback=%{public}d",
__LINE__, ret);
__LINE__, ret);
EXPECT_TRUE(ret == 0);
ret = UsbSrvClient.UnRegBulkCallback(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback001 %{public}d UnRegBulkCallback=%{public}d",
__LINE__, ret);
__LINE__, ret);
EXPECT_TRUE(ret == 0);
bool close = UsbSrvClient.Close(pipe);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback001 %{public}d close=%{public}d", __LINE__,
close);
USB_HILOGI(
MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback001 %{public}d close=%{public}d", __LINE__, close);
EXPECT_TRUE(close);
USB_HILOGI(MODULE_USB_SERVICE, "Case End : UnRegBulkCallback001 : BulkTransfer");
}
@ -960,29 +954,29 @@ HWTEST_F(UsbBulkcallbackTest, UnRegBulkCallback002, TestSize.Level1)
UsbSrvClient.RequestRight(device.GetName());
ret = UsbSrvClient.OpenDevice(device, pipe);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback002 %{public}d OpenDevice=%{public}d",
__LINE__, ret);
__LINE__, ret);
EXPECT_TRUE(ret == 0);
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
USBEndpoint point = interface.GetEndpoints().front();
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback002 %{public}d point=%{public}d", __LINE__,
point.GetInterfaceId());
point.GetInterfaceId());
ret = UsbSrvClient.ClaimInterface(pipe, interface, true);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback002 %{public}d ClaimInterface=%{public}d",
__LINE__, ret);
__LINE__, ret);
EXPECT_TRUE(ret == 0);
pipe.SetBusNum(BUFFER_SIZE);
ret = UsbSrvClient.RegBulkCallback(pipe, point, cb);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback002 %{public}d RegBulkCallback=%{public}d",
__LINE__, ret);
__LINE__, ret);
EXPECT_TRUE(ret != 0);
ret = UsbSrvClient.UnRegBulkCallback(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback002 %{public}d UnRegBulkCallback=%{public}d",
__LINE__, ret);
__LINE__, ret);
EXPECT_TRUE(ret != 0);
pipe.SetBusNum(device.GetBusNum());
bool close = UsbSrvClient.Close(pipe);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback002 %{public}d close=%{public}d", __LINE__,
close);
USB_HILOGI(
MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback002 %{public}d close=%{public}d", __LINE__, close);
EXPECT_TRUE(close);
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(!(devi.empty())) << "delist NULL";
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback003 %{public}d size=%{public}zu", __LINE__,
devi.size());
devi.size());
USBDevicePipe pipe;
UsbDevice device = devi.front();
UsbSrvClient.RequestRight(device.GetName());
ret = UsbSrvClient.OpenDevice(device, pipe);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback003 %{public}d OpenDevice=%{public}d",
__LINE__, ret);
__LINE__, ret);
EXPECT_TRUE(ret == 0);
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
USBEndpoint point = interface.GetEndpoints().front();
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback003 %{public}d point=%{public}d", __LINE__,
point.GetInterfaceId());
point.GetInterfaceId());
ret = UsbSrvClient.ClaimInterface(pipe, interface, true);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback003 %{public}d ClaimInterface=%{public}d",
__LINE__, ret);
__LINE__, ret);
EXPECT_TRUE(ret == 0);
pipe.SetDevAddr(BUFFER_SIZE);
ret = UsbSrvClient.RegBulkCallback(pipe, point, cb);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback003 %{public}d RegBulkCallback=%{public}d",
__LINE__, ret);
__LINE__, ret);
EXPECT_TRUE(ret != 0);
ret = UsbSrvClient.UnRegBulkCallback(pipe, point);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback003 %{public}d UnRegBulkCallback=%{public}d",
__LINE__, ret);
__LINE__, ret);
EXPECT_TRUE(ret != 0);
pipe.SetDevAddr(device.GetDevAddr());
bool close = UsbSrvClient.Close(pipe);
USB_HILOGI(MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback003 %{public}d close=%{public}d", __LINE__,
close);
USB_HILOGI(
MODULE_USB_SERVICE, "UsbBulkcallbackTest::UnRegBulkCallback003 %{public}d close=%{public}d", __LINE__, close);
EXPECT_TRUE(close);
USB_HILOGI(MODULE_USB_SERVICE, "Case End : UnRegBulkCallback003 : BulkTransfer");
}
} // BulkCallback
} // USB
} // OHOS
} // namespace BulkCallback
} // namespace USB
} // namespace OHOS

View File

@ -15,26 +15,11 @@
#include "usb_common_test.h"
static constexpr int32_t DEFAULT_API_VERSION = 8;
using namespace OHOS::Security::AccessToken;
namespace OHOS {
namespace USB {
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 = {
.dcapsNum = 0,
.permsNum = 0,
@ -57,15 +42,7 @@ TokenInfoParams g_sysInfoInstance = {
.aplStr = "system_basic",
};
void UsbCommonTest::SetTestCaseHapApply (void)
{
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)
void UsbCommonTest::SetTestCaseNative(TokenInfoParams *infoInstance)
{
uint64_t tokenId = GetAccessTokenId(infoInstance);
int ret = SetSelfTokenID(tokenId);
@ -86,6 +63,6 @@ void UsbCommonTest::GrantPermissionNormalNative()
{
SetTestCaseNative(&g_normalInfoInstance);
}
} // Common
} // USB
} // OHOS
} // namespace Common
} // namespace USB
} // namespace OHOS

View File

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

View File

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

View File

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