mirror of
https://github.com/openharmony/usb_manager.git
synced 2026-07-19 08:35:06 -04:00
feat: 1. add bulk_async and callback return
2. class UsbdClient remove static 3. API UsbClaimInterfaceUnforce adapter 4. js unit test case modify and c++ unit test case modify Signed-off-by: wu-chengwen <wuchengwen4@huawei.com>
This commit is contained in:
@@ -18,6 +18,10 @@ config("usbsrv_private_config") {
|
||||
"${usb_manager_path}/services/zidl/include",
|
||||
"//drivers/peripheral/usb/hal/client/include",
|
||||
"//utils/system/safwk/native/include",
|
||||
"//drivers/framework/include/utils",
|
||||
"//drivers/adapter/uhdf2/osal/include",
|
||||
"//drivers/adapter/uhdf2/ipc/include",
|
||||
"//utils/native/base/include",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -31,6 +35,7 @@ ohos_shared_library("usbsrv_client") {
|
||||
"native/src/usb_device_pipe.cpp",
|
||||
"native/src/usb_request.cpp",
|
||||
"native/src/usb_srv_client.cpp",
|
||||
"native/src/usbd_bulk_callback.cpp",
|
||||
]
|
||||
|
||||
configs = [
|
||||
|
||||
@@ -51,7 +51,13 @@ public:
|
||||
USB_FUN_REQUEST_WAIT,
|
||||
USB_FUN_REQUEST_CANCEL,
|
||||
USB_FUN_GET_DESCRIPTOR,
|
||||
USB_FUN_GET_FILEDESCRIPTOR,
|
||||
USB_FUN_CLOSE_DEVICE,
|
||||
USB_FUN_BULK_AYSNC_READ,
|
||||
USB_FUN_BULK_AYSNC_WRITE,
|
||||
USB_FUN_BULK_AYSNC_CANCEL,
|
||||
USB_FUN_REG_BULK_CALLBACK,
|
||||
USB_FUN_UNREG_BULK_CALLBACK,
|
||||
};
|
||||
|
||||
virtual int32_t OpenDevice(uint8_t busNum, uint8_t devAddr) = 0;
|
||||
@@ -66,28 +72,32 @@ public:
|
||||
virtual int32_t GetPorts(std::vector<UsbPort> &ports) = 0;
|
||||
virtual int32_t GetSupportedModes(int32_t portId, int32_t &supportedModes) = 0;
|
||||
virtual int32_t SetPortRole(int32_t portId, int32_t powerRole, int32_t dataRole) = 0;
|
||||
virtual int32_t ClaimInterface(uint8_t busNum, uint8_t devAddr, uint8_t interfaceid) = 0;
|
||||
virtual int32_t ReleaseInterface(uint8_t busNum, uint8_t devAddr, uint8_t interfaceid) = 0;
|
||||
virtual int32_t
|
||||
BulkTransferRead(const UsbDev &dev, const UsbPipe &pipe, std::vector<uint8_t> &vdata, int32_t timeout) = 0;
|
||||
virtual int32_t BulkTransferWrite(const UsbDev &dev,
|
||||
const UsbPipe &pipe,
|
||||
const std::vector<uint8_t> &vdata,
|
||||
int32_t timeout) = 0;
|
||||
virtual int32_t ControlTransfer(const UsbDev &dev, const UsbCtrlTransfer &ctrl, std::vector<uint8_t> &vdata) = 0;
|
||||
virtual int32_t ClaimInterface(uint8_t busNum, uint8_t devAddr, uint8_t interfaceid, uint8_t force) = 0;
|
||||
virtual int32_t BulkTransferRead(const UsbDev &dev, const UsbPipe &pipe, std::vector<uint8_t> &bufferData,
|
||||
int32_t timeOut) = 0;
|
||||
virtual int32_t BulkTransferWrite(const UsbDev &dev, const UsbPipe &pipe, const std::vector<uint8_t> &bufferData,
|
||||
int32_t timeOut) = 0;
|
||||
virtual int32_t ControlTransfer(const UsbDev &dev, const UsbCtrlTransfer &ctrl,
|
||||
std::vector<uint8_t> &bufferData) = 0;
|
||||
virtual int32_t SetActiveConfig(uint8_t busNum, uint8_t devAddr, uint8_t configId) = 0;
|
||||
virtual int32_t GetActiveConfig(uint8_t busNum, uint8_t devAddr, uint8_t &configId) = 0;
|
||||
virtual int32_t SetInterface(uint8_t busNum, uint8_t devAddr, uint8_t interfaceid, uint8_t altIndex) = 0;
|
||||
virtual int32_t GetRawDescriptor(uint8_t busNum, uint8_t devAddr, std::vector<uint8_t> &vdata) = 0;
|
||||
virtual int32_t RequestQueue(const UsbDev &dev,
|
||||
const UsbPipe &pipe,
|
||||
const std::vector<uint8_t> &cData,
|
||||
const std::vector<uint8_t> &vData) = 0;
|
||||
virtual int32_t
|
||||
RequestWait(const UsbDev &dev, int32_t timeout, std::vector<uint8_t> &cData, std::vector<uint8_t> &vData) = 0;
|
||||
virtual int32_t GetRawDescriptor(uint8_t busNum, uint8_t devAddr, std::vector<uint8_t> &bufferData) = 0;
|
||||
virtual int32_t GetFileDescriptor(uint8_t busNum, uint8_t devAddr, int32_t &fd) = 0;
|
||||
virtual int32_t RequestQueue(const UsbDev &dev, const UsbPipe &pipe, const std::vector<uint8_t> &clientData,
|
||||
const std::vector<uint8_t> &bufferData) = 0;
|
||||
virtual int32_t RequestWait(const UsbDev &dev, int32_t timeOut, std::vector<uint8_t> &clientData,
|
||||
std::vector<uint8_t> &bufferData) = 0;
|
||||
virtual int32_t RequestCancel(uint8_t busNum, uint8_t devAddr, uint8_t interfaceid, uint8_t endpointId) = 0;
|
||||
virtual int32_t Close(uint8_t busNum, uint8_t devAddr) = 0;
|
||||
|
||||
virtual int32_t RegBulkCallback(const UsbDev &devInfo, const UsbPipe &pipe, const sptr<IRemoteObject> &cb) = 0;
|
||||
virtual int32_t UnRegBulkCallback(const UsbDev &devInfo, const UsbPipe &pipe) = 0;
|
||||
virtual int32_t BulkRead(const UsbDev &devInfo, const UsbPipe &pipe, sptr<Ashmem> &ashmem) = 0;
|
||||
virtual int32_t BulkWrite(const UsbDev &devInfo, const UsbPipe &pipe, sptr<Ashmem> &ashmem) = 0;
|
||||
virtual int32_t BulkCancel(const UsbDev &devInfo, const UsbPipe &pipe) = 0;
|
||||
|
||||
public:
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.usb.IUsbSrv");
|
||||
};
|
||||
|
||||
@@ -28,11 +28,8 @@ namespace OHOS {
|
||||
namespace USB {
|
||||
class USBConfig {
|
||||
public:
|
||||
USBConfig(uint32_t id,
|
||||
uint32_t attributes,
|
||||
std::string name,
|
||||
uint32_t maxPower,
|
||||
std::vector<UsbInterface> interfaces)
|
||||
USBConfig(uint32_t id, uint32_t attributes, std::string name, uint32_t maxPower,
|
||||
std::vector<UsbInterface> interfaces)
|
||||
{
|
||||
this->id = id;
|
||||
this->attributes = attributes;
|
||||
|
||||
@@ -27,8 +27,8 @@ public:
|
||||
USBDevicePipe(uint8_t busNum, uint8_t devAddr);
|
||||
int32_t ClaimInterface(const UsbInterface &interface, bool force);
|
||||
int32_t ReleaseInterface(const UsbInterface &interface);
|
||||
int32_t BulkTransfer(const USBEndpoint &endpoint, std::vector<uint8_t> &vdata, int32_t timeout);
|
||||
int32_t ControlTransfer(const UsbCtrlTransfer &ctrl, std::vector<uint8_t> &vdata);
|
||||
int32_t BulkTransfer(const USBEndpoint &endpoint, std::vector<uint8_t> &bufferData, int32_t timeOut);
|
||||
int32_t ControlTransfer(const UsbCtrlTransfer &ctrl, std::vector<uint8_t> &bufferData);
|
||||
int32_t SetConfiguration(const USBConfig &config);
|
||||
int32_t SetInterface(const UsbInterface &interface);
|
||||
int32_t Close();
|
||||
|
||||
@@ -38,13 +38,13 @@ public:
|
||||
{
|
||||
this->endpoint = endpoint;
|
||||
}
|
||||
void SetClientData(std::vector<uint8_t> vdata)
|
||||
void SetClientData(std::vector<uint8_t> bufferData)
|
||||
{
|
||||
clientData = vdata;
|
||||
clientData = bufferData;
|
||||
}
|
||||
void SetReqData(std::vector<uint8_t> vdata)
|
||||
void SetReqData(std::vector<uint8_t> bufferData)
|
||||
{
|
||||
reqData = vdata;
|
||||
reqData = bufferData;
|
||||
}
|
||||
std::vector<uint8_t> &GetClientData()
|
||||
{
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace OHOS {
|
||||
namespace USB {
|
||||
const std::string MAXVERSION = "001";
|
||||
const std::string SUBVERSION = "001";
|
||||
const std::string DLPVERSION = "018";
|
||||
const std::string DLPVERSION = "025";
|
||||
const std::string SEVVERSION = MAXVERSION + "." + SUBVERSION + "." + DLPVERSION;
|
||||
|
||||
class UsbSrvClient final : public DelayedRefSingleton<UsbSrvClient> {
|
||||
@@ -54,14 +54,15 @@ public:
|
||||
std::string UsbFunctionsToString(int32_t funcs);
|
||||
int32_t ClaimInterface(USBDevicePipe &pip, const UsbInterface &interface, bool force);
|
||||
int32_t ReleaseInterface(USBDevicePipe &pip, const UsbInterface &interface);
|
||||
int32_t BulkTransfer(USBDevicePipe &pip, const USBEndpoint &endpoint, std::vector<uint8_t> &vdata, int32_t timeout);
|
||||
int32_t ControlTransfer(USBDevicePipe &pip, const UsbCtrlTransfer &ctrl, std::vector<uint8_t> &vdata);
|
||||
int32_t BulkTransfer(USBDevicePipe &pip, const USBEndpoint &endpoint, std::vector<uint8_t> &bufferData,
|
||||
int32_t timeOut);
|
||||
int32_t ControlTransfer(USBDevicePipe &pip, const UsbCtrlTransfer &ctrl, std::vector<uint8_t> &bufferData);
|
||||
int32_t SetConfiguration(USBDevicePipe &pip, const USBConfig &config);
|
||||
int32_t SetInterface(USBDevicePipe &pipe, const UsbInterface &interface);
|
||||
int32_t GetRawDescriptors(std::vector<uint8_t> &vdata);
|
||||
int32_t GetFileDescriptor();
|
||||
int32_t GetRawDescriptors(USBDevicePipe &pipe, std::vector<uint8_t> &bufferData);
|
||||
int32_t GetFileDescriptor(USBDevicePipe &pipe, int32_t &fd);
|
||||
bool Close(const USBDevicePipe &pip);
|
||||
int32_t PipeRequestWait(USBDevicePipe &pip, int64_t timeout, UsbRequest &req);
|
||||
int32_t PipeRequestWait(USBDevicePipe &pip, int64_t timeOut, UsbRequest &req);
|
||||
|
||||
int32_t RequestInitialize(UsbRequest &request);
|
||||
int32_t RequestFree(UsbRequest &request);
|
||||
@@ -72,6 +73,11 @@ public:
|
||||
{
|
||||
return SEVVERSION;
|
||||
}
|
||||
int32_t RegBulkCallback(USBDevicePipe &pip, const USBEndpoint &endpoint, const sptr<IRemoteObject> &cb);
|
||||
int32_t UnRegBulkCallback(USBDevicePipe &pip, const USBEndpoint &endpoint);
|
||||
int32_t BulkRead(USBDevicePipe &pip, const USBEndpoint &endpoint, sptr<Ashmem> &ashmem);
|
||||
int32_t BulkWrite(USBDevicePipe &pip, const USBEndpoint &endpoint, sptr<Ashmem> &ashmem);
|
||||
int32_t BulkCancel(USBDevicePipe &pip, const USBEndpoint &endpoint);
|
||||
|
||||
private:
|
||||
class UsbSrvDeathRecipient : public IRemoteObject::DeathRecipient {
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef USBD_BULK_CALLBACK_H
|
||||
#define USBD_BULK_CALLBACK_H
|
||||
|
||||
#include "ipc_object_stub.h"
|
||||
|
||||
namespace OHOS::USB {
|
||||
enum {
|
||||
CMD_USBD_BULK_CALLBACK_READ,
|
||||
CMD_USBD_BULK_CALLBACK_WRITE,
|
||||
};
|
||||
|
||||
class UsbdBulkCallBack : public OHOS::IPCObjectStub {
|
||||
public:
|
||||
explicit UsbdBulkCallBack() : OHOS::IPCObjectStub(u"UsbdBulkCallback.V1_0") {};
|
||||
virtual ~UsbdBulkCallBack() = default;
|
||||
int32_t OnRemoteRequest(uint32_t code, OHOS::MessageParcel &data, OHOS::MessageParcel &reply,
|
||||
OHOS::MessageOption &option) override;
|
||||
virtual int32_t OnBulkWriteCallback(int32_t status, int32_t actLength) = 0;
|
||||
virtual int32_t OnBulkReadCallback(int32_t status, int32_t actLength) = 0;
|
||||
};
|
||||
} // namespace OHOS::USB
|
||||
#endif
|
||||
@@ -50,16 +50,16 @@ int32_t USBDevicePipe::ReleaseInterface(const UsbInterface &interface)
|
||||
return ((UsbSrvClient *)usbClient)->ReleaseInterface(*this, interface);
|
||||
}
|
||||
|
||||
int32_t USBDevicePipe::BulkTransfer(const USBEndpoint &endpoint, std::vector<uint8_t> &vdata, int32_t timeout)
|
||||
int32_t USBDevicePipe::BulkTransfer(const USBEndpoint &endpoint, std::vector<uint8_t> &bufferData, int32_t timeOut)
|
||||
{
|
||||
RETURN_IF_WITH_RET(usbClient == nullptr, ERR_NO_INIT);
|
||||
return ((UsbSrvClient *)usbClient)->BulkTransfer(*this, endpoint, vdata, timeout);
|
||||
return ((UsbSrvClient *)usbClient)->BulkTransfer(*this, endpoint, bufferData, timeOut);
|
||||
}
|
||||
|
||||
int32_t USBDevicePipe::ControlTransfer(const UsbCtrlTransfer &ctrl, std::vector<uint8_t> &vdata)
|
||||
int32_t USBDevicePipe::ControlTransfer(const UsbCtrlTransfer &ctrl, std::vector<uint8_t> &bufferData)
|
||||
{
|
||||
RETURN_IF_WITH_RET(usbClient == nullptr, ERR_NO_INIT);
|
||||
return ((UsbSrvClient *)usbClient)->ControlTransfer(*this, ctrl, vdata);
|
||||
return ((UsbSrvClient *)usbClient)->ControlTransfer(*this, ctrl, bufferData);
|
||||
}
|
||||
int32_t USBDevicePipe::SetConfiguration(const USBConfig &config)
|
||||
{
|
||||
|
||||
@@ -26,7 +26,7 @@ int32_t UsbRequest::Initialize(const USBDevicePipe &pipe, const USBEndpoint &end
|
||||
this->endpoint = endpoint;
|
||||
int32_t ret = ((UsbSrvClient *)usbClient)->RequestInitialize(*this);
|
||||
if (ERR_OK != ret) {
|
||||
USB_HILOGI(MODULE_USB_INNERKIT, "UsbRequest::%{public}s:%{public}d failed width ret = %{public}d.", __func__,
|
||||
USB_HILOGE(MODULE_USB_INNERKIT, "UsbRequest::%{public}s:%{public}d failed width ret = %{public}d.", __func__,
|
||||
__LINE__, ret);
|
||||
}
|
||||
return ret;
|
||||
@@ -36,7 +36,7 @@ int32_t UsbRequest::Queue()
|
||||
{
|
||||
int32_t ret = ((UsbSrvClient *)usbClient)->RequestQueue(*this);
|
||||
if (ERR_OK != ret) {
|
||||
USB_HILOGI(MODULE_USB_INNERKIT, "UsbRequest::%{public}s:%{public}d failed width ret = %{public}d.", __func__,
|
||||
USB_HILOGE(MODULE_USB_INNERKIT, "UsbRequest::%{public}s:%{public}d failed width ret = %{public}d.", __func__,
|
||||
__LINE__, ret);
|
||||
}
|
||||
return ret;
|
||||
@@ -46,7 +46,7 @@ int32_t UsbRequest::Free()
|
||||
{
|
||||
int32_t ret = ((UsbSrvClient *)usbClient)->RequestFree(*this);
|
||||
if (ERR_OK != ret) {
|
||||
USB_HILOGI(MODULE_USB_INNERKIT, "UsbRequest::%{public}s:%{public}d failed width ret = %{public}d.", __func__,
|
||||
USB_HILOGE(MODULE_USB_INNERKIT, "UsbRequest::%{public}s:%{public}d failed width ret = %{public}d.", __func__,
|
||||
__LINE__, ret);
|
||||
}
|
||||
return ret;
|
||||
@@ -56,7 +56,7 @@ int32_t UsbRequest::Abort()
|
||||
{
|
||||
int32_t ret = ((UsbSrvClient *)usbClient)->RequestAbort(*this);
|
||||
if (ERR_OK != ret) {
|
||||
USB_HILOGI(MODULE_USB_INNERKIT, "UsbRequest::%{public}s:%{public}d failed width ret = %{public}d.", __func__,
|
||||
USB_HILOGE(MODULE_USB_INNERKIT, "UsbRequest::%{public}s:%{public}d failed width ret = %{public}d.", __func__,
|
||||
__LINE__, ret);
|
||||
}
|
||||
return ret;
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
namespace OHOS {
|
||||
namespace USB {
|
||||
#define USB_MAX_REQUEST_DATA_SIZE 1024
|
||||
|
||||
const uint8_t CLAIM_FORCE_1 = 1;
|
||||
UsbSrvClient::UsbSrvClient()
|
||||
{
|
||||
Connect();
|
||||
@@ -83,7 +83,7 @@ int32_t UsbSrvClient::OpenDevice(const UsbDevice &device, USBDevicePipe &pipe)
|
||||
RETURN_IF_WITH_RET(Connect() != UEC_OK, UEC_INTERFACE_NO_INIT);
|
||||
int32_t ret = proxy_->OpenDevice(device.GetBusNum(), device.GetDevAddr());
|
||||
if (ret != UEC_OK) {
|
||||
USB_HILOGI(MODULE_USB_INNERKIT, "%{public}s : failed width ret = %{public}d !", __func__, ret);
|
||||
USB_HILOGE(MODULE_USB_INNERKIT, "%{public}s : failed width ret = %{public}d !", __func__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ int32_t UsbSrvClient::HasRight(std::string deviceName)
|
||||
RETURN_IF_WITH_RET(Connect() != UEC_OK, UEC_INTERFACE_NO_INIT);
|
||||
int32_t ret = proxy_->HasRight(deviceName);
|
||||
if (ret != UEC_OK) {
|
||||
USB_HILOGI(MODULE_USB_INNERKIT, " Calling HasRight False!");
|
||||
USB_HILOGE(MODULE_USB_INNERKIT, " Calling HasRight False!");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -108,7 +108,7 @@ int32_t UsbSrvClient::RequestRight(std::string deviceName)
|
||||
RETURN_IF_WITH_RET(Connect() != UEC_OK, UEC_INTERFACE_NO_INIT);
|
||||
int32_t ret = proxy_->RequestRight(deviceName);
|
||||
if (ret != UEC_OK) {
|
||||
USB_HILOGI(MODULE_USB_INNERKIT, " Calling RequestRight False!");
|
||||
USB_HILOGE(MODULE_USB_INNERKIT, " Calling RequestRight False!");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -118,7 +118,7 @@ int32_t UsbSrvClient::RemoveRight(std::string deviceName)
|
||||
RETURN_IF_WITH_RET(Connect() != UEC_OK, UEC_INTERFACE_NO_INIT);
|
||||
int32_t ret = proxy_->RemoveRight(deviceName);
|
||||
if (ret != UEC_OK) {
|
||||
USB_HILOGI(MODULE_USB_INNERKIT, " Calling RequestRight False!");
|
||||
USB_HILOGE(MODULE_USB_INNERKIT, " Calling RequestRight False!");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -128,7 +128,7 @@ int32_t UsbSrvClient::GetDevices(std::vector<UsbDevice> &deviceList)
|
||||
RETURN_IF_WITH_RET(Connect() != UEC_OK, UEC_INTERFACE_NO_INIT);
|
||||
int32_t ret = proxy_->GetDevices(deviceList);
|
||||
if (ret != UEC_OK) {
|
||||
USB_HILOGI(MODULE_USB_INNERKIT, "%{public}s failed ret = %{public}d!", __func__, ret);
|
||||
USB_HILOGE(MODULE_USB_INNERKIT, "%{public}s failed ret = %{public}d!", __func__, ret);
|
||||
}
|
||||
USB_HILOGI(MODULE_USB_INNERKIT, "%{public}s list size = %{public}d!", __func__, deviceList.size());
|
||||
return ret;
|
||||
@@ -139,7 +139,7 @@ int32_t UsbSrvClient::GetCurrentFunctions(int32_t &funcs)
|
||||
RETURN_IF_WITH_RET(Connect() != UEC_OK, UEC_INTERFACE_NO_INIT);
|
||||
int32_t ret = proxy_->GetCurrentFunctions(funcs);
|
||||
if (ret != UEC_OK) {
|
||||
USB_HILOGI(MODULE_USB_INNERKIT, "%{public}s failed ret = %{public}d!", __func__, ret);
|
||||
USB_HILOGE(MODULE_USB_INNERKIT, "%{public}s failed ret = %{public}d!", __func__, ret);
|
||||
}
|
||||
USB_HILOGI(MODULE_USB_INNERKIT, " Calling GetCurrentFunctions Success!");
|
||||
return ret;
|
||||
@@ -149,7 +149,7 @@ int32_t UsbSrvClient::SetCurrentFunctions(int32_t funcs)
|
||||
RETURN_IF_WITH_RET(Connect() != UEC_OK, false);
|
||||
int32_t ret = proxy_->SetCurrentFunctions(funcs);
|
||||
if (ret != UEC_OK) {
|
||||
USB_HILOGI(MODULE_USB_INNERKIT, "%{public}s failed ret = %{public}d!", __func__, ret);
|
||||
USB_HILOGE(MODULE_USB_INNERKIT, "%{public}s failed ret = %{public}d!", __func__, ret);
|
||||
return ret;
|
||||
}
|
||||
USB_HILOGI(MODULE_USB_INNERKIT, " Calling SetCurrentFunctions Success!");
|
||||
@@ -179,7 +179,7 @@ int32_t UsbSrvClient::GetPorts(std::vector<UsbPort> &usbports)
|
||||
USB_HILOGI(MODULE_USB_INNERKIT, " Calling GetPorts");
|
||||
int32_t ret = proxy_->GetPorts(usbports);
|
||||
if (ret != UEC_OK) {
|
||||
USB_HILOGI(MODULE_USB_INNERKIT, "%{public}s failed ret = %{public}d!", __func__, ret);
|
||||
USB_HILOGE(MODULE_USB_INNERKIT, "%{public}s failed ret = %{public}d!", __func__, ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -190,7 +190,7 @@ int32_t UsbSrvClient::GetSupportedModes(int32_t portId, int32_t &result)
|
||||
USB_HILOGI(MODULE_USB_INNERKIT, " Calling GetSupportedModes");
|
||||
int32_t ret = proxy_->GetSupportedModes(portId, result);
|
||||
if (ret != UEC_OK) {
|
||||
USB_HILOGI(MODULE_USB_INNERKIT, "%{public}s failed ret = %{public}d!", __func__, ret);
|
||||
USB_HILOGE(MODULE_USB_INNERKIT, "%{public}s failed ret = %{public}d!", __func__, ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -201,7 +201,7 @@ int32_t UsbSrvClient::SetPortRole(int32_t portId, int32_t powerRole, int32_t dat
|
||||
USB_HILOGI(MODULE_USB_INNERKIT, " Calling SetPortRole");
|
||||
int32_t ret = proxy_->SetPortRole(portId, powerRole, dataRole);
|
||||
if (ret != UEC_OK) {
|
||||
USB_HILOGI(MODULE_USB_INNERKIT, "%{public}s failed ret = %{public}d!", __func__, ret);
|
||||
USB_HILOGE(MODULE_USB_INNERKIT, "%{public}s failed ret = %{public}d!", __func__, ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -209,9 +209,9 @@ int32_t UsbSrvClient::SetPortRole(int32_t portId, int32_t powerRole, int32_t dat
|
||||
int32_t UsbSrvClient::ClaimInterface(USBDevicePipe &pipe, const UsbInterface &interface, bool force)
|
||||
{
|
||||
RETURN_IF_WITH_RET(proxy_ == nullptr, UEC_INTERFACE_NO_INIT);
|
||||
int32_t ret = proxy_->ClaimInterface(pipe.GetBusNum(), pipe.GetDevAddr(), interface.GetId());
|
||||
int32_t ret = proxy_->ClaimInterface(pipe.GetBusNum(), pipe.GetDevAddr(), interface.GetId(), force);
|
||||
if (ret != UEC_OK) {
|
||||
USB_HILOGI(MODULE_USB_INNERKIT, "%{public}s : failed width ret = %{public}d !", __func__, ret);
|
||||
USB_HILOGE(MODULE_USB_INNERKIT, "%{public}s : failed width ret = %{public}d !", __func__, ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -220,36 +220,35 @@ int32_t UsbSrvClient::ReleaseInterface(USBDevicePipe &pipe, const UsbInterface &
|
||||
RETURN_IF_WITH_RET(proxy_ == nullptr, UEC_INTERFACE_NO_INIT);
|
||||
int32_t ret = proxy_->ReleaseInterface(pipe.GetBusNum(), pipe.GetDevAddr(), interface.GetId());
|
||||
if (ret != UEC_OK) {
|
||||
USB_HILOGI(MODULE_USB_INNERKIT, "%{public}s : failed width ret = %{public}d !", __func__, ret);
|
||||
USB_HILOGE(MODULE_USB_INNERKIT, "%{public}s : failed width ret = %{public}d !", __func__, ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
int32_t UsbSrvClient::BulkTransfer(USBDevicePipe &pipe,
|
||||
const USBEndpoint &endpoint,
|
||||
std::vector<uint8_t> &vdata,
|
||||
int32_t timeout)
|
||||
int32_t UsbSrvClient::BulkTransfer(USBDevicePipe &pipe, const USBEndpoint &endpoint, std::vector<uint8_t> &bufferData,
|
||||
int32_t timeOut)
|
||||
{
|
||||
RETURN_IF_WITH_RET(proxy_ == nullptr, UEC_INTERFACE_NO_INIT);
|
||||
int32_t ret = ERR_INVALID_VALUE;
|
||||
int32_t ret = UEC_INTERFACE_INVALID_VALUE;
|
||||
const UsbDev tdev = {pipe.GetBusNum(), pipe.GetDevAddr()};
|
||||
const UsbPipe tpipe = {endpoint.GetInterfaceId(), endpoint.GetAddress()};
|
||||
if (USB_ENDPOINT_DIR_IN == endpoint.GetDirection()) {
|
||||
ret = proxy_->BulkTransferRead(tdev, tpipe, vdata, timeout);
|
||||
ret = proxy_->BulkTransferRead(tdev, tpipe, bufferData, timeOut);
|
||||
} else if (USB_ENDPOINT_DIR_OUT == endpoint.GetDirection()) {
|
||||
ret = proxy_->BulkTransferWrite(tdev, tpipe, vdata, timeout);
|
||||
ret = proxy_->BulkTransferWrite(tdev, tpipe, bufferData, timeOut);
|
||||
}
|
||||
if (ret != UEC_OK) {
|
||||
USB_HILOGI(MODULE_USB_INNERKIT, "%{public}s : failed width ret = %{public}d !", __func__, ret);
|
||||
USB_HILOGE(MODULE_USB_INNERKIT, "%{public}s : failed width ret = %{public}d !", __func__, ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
int32_t UsbSrvClient::ControlTransfer(USBDevicePipe &pipe, const UsbCtrlTransfer &ctrl, std::vector<uint8_t> &vdata)
|
||||
int32_t UsbSrvClient::ControlTransfer(USBDevicePipe &pipe, const UsbCtrlTransfer &ctrl,
|
||||
std::vector<uint8_t> &bufferData)
|
||||
{
|
||||
RETURN_IF_WITH_RET(proxy_ == nullptr, UEC_INTERFACE_NO_INIT);
|
||||
const UsbDev dev = {pipe.GetBusNum(), pipe.GetDevAddr()};
|
||||
int32_t ret = proxy_->ControlTransfer(dev, ctrl, vdata);
|
||||
int32_t ret = proxy_->ControlTransfer(dev, ctrl, bufferData);
|
||||
if (ret != UEC_OK) {
|
||||
USB_HILOGI(MODULE_USB_INNERKIT, "%{public}s : failed width ret = %{public}d !", __func__, ret);
|
||||
USB_HILOGE(MODULE_USB_INNERKIT, "%{public}s : failed width ret = %{public}d !", __func__, ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -266,13 +265,23 @@ int32_t UsbSrvClient::SetInterface(USBDevicePipe &pipe, const UsbInterface &inte
|
||||
return proxy_->SetInterface(pipe.GetBusNum(), pipe.GetDevAddr(), interface.GetId(),
|
||||
interface.GetAlternateSetting());
|
||||
}
|
||||
int32_t UsbSrvClient::GetRawDescriptors(std::vector<uint8_t> &vdata)
|
||||
int32_t UsbSrvClient::GetRawDescriptors(USBDevicePipe &pipe, std::vector<uint8_t> &bufferData)
|
||||
{
|
||||
return UEC_OK;
|
||||
RETURN_IF_WITH_RET(Connect() != UEC_OK, UEC_INTERFACE_NO_INIT);
|
||||
int32_t ret = proxy_->GetRawDescriptor(pipe.GetBusNum(), pipe.GetDevAddr(), bufferData);
|
||||
if (ret != UEC_OK) {
|
||||
USB_HILOGE(MODULE_USB_INNERKIT, "%{public}s failed ret = %{public}d!", __func__, ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
int32_t UsbSrvClient::GetFileDescriptor()
|
||||
int32_t UsbSrvClient::GetFileDescriptor(USBDevicePipe &pipe, int32_t &fd)
|
||||
{
|
||||
return UEC_OK;
|
||||
RETURN_IF_WITH_RET(Connect() != UEC_OK, UEC_INTERFACE_NO_INIT);
|
||||
int32_t ret = proxy_->GetFileDescriptor(pipe.GetBusNum(), pipe.GetDevAddr(), fd);
|
||||
if (ret != UEC_OK) {
|
||||
USB_HILOGE(MODULE_USB_INNERKIT, "%{public}s failed ret = %{public}d!", __func__, ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool UsbSrvClient::Close(const USBDevicePipe &pipe)
|
||||
@@ -282,22 +291,22 @@ bool UsbSrvClient::Close(const USBDevicePipe &pipe)
|
||||
return (ret == UEC_OK);
|
||||
}
|
||||
|
||||
int32_t UsbSrvClient::PipeRequestWait(USBDevicePipe &pipe, int64_t timeout, UsbRequest &req)
|
||||
int32_t UsbSrvClient::PipeRequestWait(USBDevicePipe &pipe, int64_t timeOut, UsbRequest &req)
|
||||
{
|
||||
RETURN_IF_WITH_RET(proxy_ == nullptr, UEC_INTERFACE_NO_INIT);
|
||||
std::vector<uint8_t> cData;
|
||||
std::vector<uint8_t> vData;
|
||||
std::vector<uint8_t> clientData;
|
||||
std::vector<uint8_t> bufferData;
|
||||
const UsbDev tdev = {pipe.GetBusNum(), pipe.GetDevAddr()};
|
||||
int32_t ret = proxy_->RequestWait(tdev, timeout, cData, vData);
|
||||
int32_t ret = proxy_->RequestWait(tdev, timeOut, clientData, bufferData);
|
||||
if (ret != UEC_OK) {
|
||||
USB_HILOGI(MODULE_USB_INNERKIT, "UsbSrvClient::%{public}s:%{public}d :failed width ret = %{public}d.", __func__,
|
||||
USB_HILOGE(MODULE_USB_INNERKIT, "UsbSrvClient::%{public}s:%{public}d :failed width ret = %{public}d.", __func__,
|
||||
__LINE__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
req.SetPipe(pipe);
|
||||
req.SetClientData(cData);
|
||||
req.SetReqData(vData);
|
||||
req.SetClientData(clientData);
|
||||
req.SetReqData(bufferData);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -306,7 +315,7 @@ int32_t UsbSrvClient::RequestInitialize(UsbRequest &request)
|
||||
RETURN_IF_WITH_RET(proxy_ == nullptr, UEC_INTERFACE_NO_INIT);
|
||||
const USBDevicePipe &pipe = request.GetPipe();
|
||||
const USBEndpoint &endpoint = request.GetEndpoint();
|
||||
return proxy_->ClaimInterface(pipe.GetBusNum(), pipe.GetDevAddr(), endpoint.GetInterfaceId());
|
||||
return proxy_->ClaimInterface(pipe.GetBusNum(), pipe.GetDevAddr(), endpoint.GetInterfaceId(), CLAIM_FORCE_1);
|
||||
}
|
||||
|
||||
int32_t UsbSrvClient::RequestFree(UsbRequest &request)
|
||||
@@ -314,7 +323,7 @@ int32_t UsbSrvClient::RequestFree(UsbRequest &request)
|
||||
RETURN_IF_WITH_RET(proxy_ == nullptr, UEC_INTERFACE_NO_INIT);
|
||||
const USBDevicePipe &pipe = request.GetPipe();
|
||||
const USBEndpoint &ep = request.GetEndpoint();
|
||||
return proxy_->ReleaseInterface(pipe.GetBusNum(), pipe.GetDevAddr(), ep.GetInterfaceId());
|
||||
return proxy_->RequestCancel(pipe.GetBusNum(), pipe.GetDevAddr(), ep.GetInterfaceId(), ep.GetAddress());
|
||||
}
|
||||
|
||||
int32_t UsbSrvClient::RequestAbort(UsbRequest &request)
|
||||
@@ -334,5 +343,60 @@ int32_t UsbSrvClient::RequestQueue(UsbRequest &request)
|
||||
const UsbPipe tpipe = {ep.GetInterfaceId(), ep.GetAddress()};
|
||||
return proxy_->RequestQueue(tdev, tpipe, request.GetClientData(), request.GetReqData());
|
||||
}
|
||||
int32_t UsbSrvClient::RegBulkCallback(USBDevicePipe &pip, const USBEndpoint &endpoint, const sptr<IRemoteObject> &cb)
|
||||
{
|
||||
RETURN_IF_WITH_RET(proxy_ == nullptr, UEC_INTERFACE_NO_INIT);
|
||||
const UsbDev tdev = {pip.GetBusNum(), pip.GetDevAddr()};
|
||||
const UsbPipe tpipe = {endpoint.GetInterfaceId(), endpoint.GetAddress()};
|
||||
int32_t ret = proxy_->RegBulkCallback(tdev, tpipe, cb);
|
||||
if (ret != UEC_OK) {
|
||||
USB_HILOGE(MODULE_USB_INNERKIT, "%{public}s : failed width ret = %{public}d !", __func__, ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
int32_t UsbSrvClient::UnRegBulkCallback(USBDevicePipe &pip, const USBEndpoint &endpoint)
|
||||
{
|
||||
RETURN_IF_WITH_RET(proxy_ == nullptr, UEC_INTERFACE_NO_INIT);
|
||||
const UsbDev tdev = {pip.GetBusNum(), pip.GetDevAddr()};
|
||||
const UsbPipe tpipe = {endpoint.GetInterfaceId(), endpoint.GetAddress()};
|
||||
int32_t ret = proxy_->UnRegBulkCallback(tdev, tpipe);
|
||||
if (ret != UEC_OK) {
|
||||
USB_HILOGE(MODULE_USB_INNERKIT, "%{public}s : failed width ret = %{public}d !", __func__, ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
int32_t UsbSrvClient::BulkRead(USBDevicePipe &pip, const USBEndpoint &endpoint, sptr<Ashmem> &ashmem)
|
||||
{
|
||||
RETURN_IF_WITH_RET(proxy_ == nullptr, UEC_INTERFACE_NO_INIT);
|
||||
const UsbDev tdev = {pip.GetBusNum(), pip.GetDevAddr()};
|
||||
const UsbPipe tpipe = {endpoint.GetInterfaceId(), endpoint.GetAddress()};
|
||||
int32_t ret = proxy_->BulkRead(tdev, tpipe, ashmem);
|
||||
if (ret != UEC_OK) {
|
||||
USB_HILOGE(MODULE_USB_INNERKIT, "%{public}s : failed width ret = %{public}d !", __func__, ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
int32_t UsbSrvClient::BulkWrite(USBDevicePipe &pip, const USBEndpoint &endpoint, sptr<Ashmem> &ashmem)
|
||||
{
|
||||
RETURN_IF_WITH_RET(proxy_ == nullptr, UEC_INTERFACE_NO_INIT);
|
||||
const UsbDev tdev = {pip.GetBusNum(), pip.GetDevAddr()};
|
||||
const UsbPipe tpipe = {endpoint.GetInterfaceId(), endpoint.GetAddress()};
|
||||
int32_t ret = proxy_->BulkWrite(tdev, tpipe, ashmem);
|
||||
if (ret != UEC_OK) {
|
||||
USB_HILOGE(MODULE_USB_INNERKIT, "%{public}s : failed width ret = %{public}d !", __func__, ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
int32_t UsbSrvClient::BulkCancel(USBDevicePipe &pip, const USBEndpoint &endpoint)
|
||||
{
|
||||
RETURN_IF_WITH_RET(proxy_ == nullptr, UEC_INTERFACE_NO_INIT);
|
||||
const UsbDev tdev = {pip.GetBusNum(), pip.GetDevAddr()};
|
||||
const UsbPipe tpipe = {endpoint.GetInterfaceId(), endpoint.GetAddress()};
|
||||
int32_t ret = proxy_->BulkCancel(tdev, tpipe);
|
||||
if (ret != UEC_OK) {
|
||||
USB_HILOGE(MODULE_USB_INNERKIT, "%{public}s : failed width ret = %{public}d !", __func__, ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
} // namespace USB
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#include "usbd_bulk_callback.h"
|
||||
#include <hdf_base.h>
|
||||
#include <hdf_log.h>
|
||||
#include <hdf_sbuf_ipc.h>
|
||||
#include "usb_errors.h"
|
||||
|
||||
#define HDF_LOG_TAG USBD_BULK_CALLBACK
|
||||
|
||||
namespace OHOS::USB {
|
||||
int32_t UsbdBulkCallBack::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
|
||||
MessageOption &option)
|
||||
{
|
||||
HDF_LOGI("%{public}s:%{public}d OnRemoteRequest entry! code:%{public}d", __func__, __LINE__, code);
|
||||
switch (code) {
|
||||
case CMD_USBD_BULK_CALLBACK_WRITE: {
|
||||
int32_t status;
|
||||
int32_t actLength;
|
||||
if (!data.ReadInt32(status)) {
|
||||
HDF_LOGE("%{public}s:%{public}d get status error", __func__, __LINE__);
|
||||
return UEC_SERVICE_WRITE_PARCEL_ERROR;
|
||||
}
|
||||
if (!data.ReadInt32(actLength)) {
|
||||
HDF_LOGE("%{public}s:%{public}d get actLength error", __func__, __LINE__);
|
||||
return UEC_SERVICE_WRITE_PARCEL_ERROR;
|
||||
}
|
||||
HDF_LOGI("%{public}s:%{public}d status:%{public}d actLength:%{public}d", __func__, __LINE__, status,
|
||||
actLength);
|
||||
OnBulkWriteCallback(status, actLength);
|
||||
break;
|
||||
}
|
||||
case CMD_USBD_BULK_CALLBACK_READ: {
|
||||
int32_t status;
|
||||
int32_t actLength;
|
||||
if (!data.ReadInt32(status)) {
|
||||
HDF_LOGE("%{public}s:%{public}d get status error", __func__, __LINE__);
|
||||
return UEC_SERVICE_WRITE_PARCEL_ERROR;
|
||||
}
|
||||
if (!data.ReadInt32(actLength)) {
|
||||
HDF_LOGE("%{public}s:%{public}d get actLength error", __func__, __LINE__);
|
||||
return UEC_SERVICE_WRITE_PARCEL_ERROR;
|
||||
}
|
||||
HDF_LOGI("%{public}s:%{public}d status:%{public}d actLength:%{public}d", __func__, __LINE__, status,
|
||||
actLength);
|
||||
OnBulkReadCallback(status, actLength);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
|
||||
}
|
||||
}
|
||||
return UEC_OK;
|
||||
}
|
||||
} // namespace OHOS::USB
|
||||
Vendored
+20
-20
@@ -503,7 +503,7 @@ declare namespace usb {
|
||||
*
|
||||
* @since 8
|
||||
*/
|
||||
enum PowerRoleType {
|
||||
export enum PowerRoleType {
|
||||
/**
|
||||
* 无
|
||||
*
|
||||
@@ -515,13 +515,13 @@ declare namespace usb {
|
||||
*
|
||||
* @since 8
|
||||
*/
|
||||
SOURCE,
|
||||
SOURCE = 1,
|
||||
/**
|
||||
* 内部供电
|
||||
*
|
||||
* @since 8
|
||||
*/
|
||||
SINK
|
||||
SINK = 2
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -529,7 +529,7 @@ declare namespace usb {
|
||||
*
|
||||
* @since 8
|
||||
*/
|
||||
enum DataRoleType {
|
||||
export enum DataRoleType {
|
||||
/**
|
||||
* 无
|
||||
*
|
||||
@@ -541,13 +541,13 @@ declare namespace usb {
|
||||
*
|
||||
* @since 8
|
||||
*/
|
||||
HOST,
|
||||
HOST = 1,
|
||||
/**
|
||||
* device模式,从设备模式
|
||||
*
|
||||
* @since 8
|
||||
*/
|
||||
DEVICE
|
||||
DEVICE = 2
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -555,7 +555,7 @@ declare namespace usb {
|
||||
*
|
||||
* @since 8
|
||||
*/
|
||||
enum PortModeType {
|
||||
export enum PortModeType {
|
||||
/**
|
||||
* 无
|
||||
*
|
||||
@@ -567,25 +567,25 @@ declare namespace usb {
|
||||
*
|
||||
* @since 8
|
||||
*/
|
||||
UFP,
|
||||
UFP = 1,
|
||||
/**
|
||||
* host 数据下行,对外提供电源
|
||||
*
|
||||
* @since 8
|
||||
*/
|
||||
DFP,
|
||||
DFP = 2,
|
||||
/**
|
||||
* DRP既可以做DFP(Host),也可以做UFP(Device),当前不支持
|
||||
*
|
||||
* @since 8
|
||||
*/
|
||||
DRP,
|
||||
DRP = 3,
|
||||
/**
|
||||
* 当前不支持
|
||||
*
|
||||
* @since 8
|
||||
*/
|
||||
NUM_MODES
|
||||
NUM_MODES = 4
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -692,7 +692,7 @@ declare namespace usb {
|
||||
*
|
||||
* @since 8
|
||||
*/
|
||||
enum USBRequestTargetType {
|
||||
export enum USBRequestTargetType {
|
||||
/**
|
||||
* 设备
|
||||
*
|
||||
@@ -704,26 +704,26 @@ declare namespace usb {
|
||||
*
|
||||
* @since 8
|
||||
*/
|
||||
USB_REQUEST_TARGET_INTERFACE,
|
||||
USB_REQUEST_TARGET_INTERFACE = 1,
|
||||
/**
|
||||
* 端点
|
||||
*
|
||||
* @since 8
|
||||
*/
|
||||
USB_REQUEST_TARGET_ENDPOINT,
|
||||
USB_REQUEST_TARGET_ENDPOINT = 2,
|
||||
/**
|
||||
* 其他
|
||||
*
|
||||
* @since 8
|
||||
*/
|
||||
USB_REQUEST_TARGET_OTHER
|
||||
USB_REQUEST_TARGET_OTHER = 3
|
||||
}
|
||||
|
||||
/**
|
||||
* 控制请求类型
|
||||
* @since 8
|
||||
*/
|
||||
enum USBControlRequestType {
|
||||
export enum USBControlRequestType {
|
||||
/**
|
||||
* 标准
|
||||
*
|
||||
@@ -735,20 +735,20 @@ declare namespace usb {
|
||||
*
|
||||
* @since 8
|
||||
*/
|
||||
USB_REQUEST_TYPE_CLASS,
|
||||
USB_REQUEST_TYPE_CLASS = 1,
|
||||
/**
|
||||
* 厂商
|
||||
*
|
||||
* @since 8
|
||||
*/
|
||||
USB_REQUEST_TYPE_VENDOR
|
||||
USB_REQUEST_TYPE_VENDOR = 2
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求方向
|
||||
* @since 8
|
||||
*/
|
||||
enum USBRequestDirection {
|
||||
export enum USBRequestDirection {
|
||||
/**
|
||||
* 写数据,主设备往从设备
|
||||
*
|
||||
@@ -768,7 +768,7 @@ declare namespace usb {
|
||||
*
|
||||
* @since 8
|
||||
*/
|
||||
enum FunctionType {
|
||||
export enum FunctionType {
|
||||
/**
|
||||
* 无
|
||||
*
|
||||
|
||||
@@ -22,26 +22,19 @@ namespace OHOS {
|
||||
namespace USB {
|
||||
class NapiUtil {
|
||||
public:
|
||||
static void JsValueToString(const napi_env &env, const napi_value &value, const int bufLen, std::string &target);
|
||||
static void JsObjectToString(const napi_env &env,
|
||||
const napi_value &object,
|
||||
std::string fieldStr,
|
||||
const int bufLen,
|
||||
std::string &fieldRef);
|
||||
static bool
|
||||
JsObjectGetProperty(const napi_env &env, const napi_value &object, std::string fieldStr, napi_value &value);
|
||||
static void JsObjectToInt(const napi_env &env, const napi_value &object, std::string fieldStr, int &fieldRef);
|
||||
static bool JsUint8ArrayParse(const napi_env &env,
|
||||
const napi_value &object,
|
||||
uint8_t **uint8Buffer,
|
||||
size_t &bufferSize,
|
||||
size_t &offset);
|
||||
static void Uint8ArrayToJsValue(const napi_env &env,
|
||||
std::vector<uint8_t> &uint8Buffer,
|
||||
size_t bufferSize,
|
||||
napi_value &result);
|
||||
static void JsValueToString(const napi_env &env, const napi_value &value, const int32_t bufLen,
|
||||
std::string &target);
|
||||
static void JsObjectToString(const napi_env &env, const napi_value &object, std::string fieldStr,
|
||||
const int32_t bufLen, std::string &fieldRef);
|
||||
static bool JsObjectGetProperty(const napi_env &env, const napi_value &object, std::string fieldStr,
|
||||
napi_value &value);
|
||||
static void JsObjectToInt(const napi_env &env, const napi_value &object, std::string fieldStr, int32_t &fieldRef);
|
||||
static bool JsUint8ArrayParse(const napi_env &env, const napi_value &object, uint8_t **uint8Buffer,
|
||||
size_t &bufferSize, size_t &offset);
|
||||
static void Uint8ArrayToJsValue(const napi_env &env, std::vector<uint8_t> &uint8Buffer, size_t bufferSize,
|
||||
napi_value &result);
|
||||
static void SetValueUtf8String(const napi_env &env, std::string fieldStr, std::string str, napi_value &result);
|
||||
static void SetValueInt32(const napi_env &env, std::string fieldStr, const int intValue, napi_value &result);
|
||||
static void SetValueInt32(const napi_env &env, std::string fieldStr, const int32_t intValue, napi_value &result);
|
||||
static void SetValueBool(const napi_env &env, std::string fieldStr, const bool boolValue, napi_value &result);
|
||||
};
|
||||
} // namespace USB
|
||||
|
||||
@@ -23,6 +23,40 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace USB {
|
||||
const int32_t NONE = 0;
|
||||
const int32_t SOURCE = 1;
|
||||
const int32_t SINK = 2;
|
||||
|
||||
const int32_t HOST = 1;
|
||||
const int32_t DEVICE = 2;
|
||||
|
||||
const int32_t UFP = 1;
|
||||
const int32_t DFP = 2;
|
||||
const int32_t DRP = 3;
|
||||
const int32_t NUM_MODES = 4;
|
||||
|
||||
const int32_t USB_REQUEST_TARGET_DEVICE = 0;
|
||||
const int32_t USB_REQUEST_TARGET_INTERFACE = 1;
|
||||
const int32_t USB_REQUEST_TARGET_ENDPOINT = 2;
|
||||
const int32_t USB_REQUEST_TARGET_OTHER = 3;
|
||||
|
||||
const int32_t USB_REQUEST_TYPE_STANDARD = 0;
|
||||
const int32_t USB_REQUEST_TYPE_CLASS = 1;
|
||||
const int32_t USB_REQUEST_TYPE_VENDOR = 2;
|
||||
|
||||
const int32_t USB_REQUEST_DIR_TO_DEVICE = 0;
|
||||
const int32_t USB_REQUEST_DIR_FROM_DEVICE = 0x80;
|
||||
|
||||
const int32_t ACM = 1;
|
||||
const int32_t ECM = 2;
|
||||
const int32_t HDC = 4;
|
||||
const int32_t MTP = 8;
|
||||
const int32_t PTP = 16;
|
||||
const int32_t RNDIS = 32;
|
||||
const int32_t MIDI = 64;
|
||||
const int32_t AUDIO_SOURCE = 128;
|
||||
const int32_t NCM = 256;
|
||||
|
||||
struct USBAsyncContext {
|
||||
napi_env env;
|
||||
napi_async_work work;
|
||||
@@ -56,13 +90,13 @@ struct USBControlTransferAsyncContext : USBAsyncContext {
|
||||
int32_t index;
|
||||
uint8_t *buffer;
|
||||
uint32_t bufferLength;
|
||||
int32_t timeout = 0;
|
||||
int32_t timeOut = 0;
|
||||
};
|
||||
|
||||
struct USBBulkTransferAsyncContext : USBAsyncContext {
|
||||
uint8_t *buffer;
|
||||
uint32_t bufferLength;
|
||||
int32_t timeout = 0;
|
||||
int32_t timeOut = 0;
|
||||
USBDevicePipe pipe;
|
||||
USBEndpoint endpoint;
|
||||
};
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
namespace OHOS {
|
||||
namespace USB {
|
||||
const int32_t MAX_STR_LENGTH = 1024;
|
||||
void NapiUtil::JsValueToString(const napi_env &env, const napi_value &value, const int bufLen, std::string &target)
|
||||
void NapiUtil::JsValueToString(const napi_env &env, const napi_value &value, const int32_t bufLen, std::string &target)
|
||||
{
|
||||
if (bufLen <= 0 || bufLen > MAX_STR_LENGTH) {
|
||||
USB_HILOGE(MODULE_JS_NAPI, "%{public}s string too long malloc failed", __func__);
|
||||
@@ -42,11 +42,8 @@ void NapiUtil::JsValueToString(const napi_env &env, const napi_value &value, con
|
||||
target = buf.get();
|
||||
}
|
||||
|
||||
void NapiUtil::JsObjectToString(const napi_env &env,
|
||||
const napi_value &object,
|
||||
std::string fieldStr,
|
||||
const int bufLen,
|
||||
std::string &fieldRef)
|
||||
void NapiUtil::JsObjectToString(const napi_env &env, const napi_value &object, std::string fieldStr,
|
||||
const int32_t bufLen, std::string &fieldRef)
|
||||
{
|
||||
if (bufLen <= 0)
|
||||
return;
|
||||
@@ -73,10 +70,8 @@ void NapiUtil::JsObjectToString(const napi_env &env,
|
||||
}
|
||||
}
|
||||
|
||||
bool NapiUtil::JsObjectGetProperty(const napi_env &env,
|
||||
const napi_value &object,
|
||||
std::string fieldStr,
|
||||
napi_value &value)
|
||||
bool NapiUtil::JsObjectGetProperty(const napi_env &env, const napi_value &object, std::string fieldStr,
|
||||
napi_value &value)
|
||||
{
|
||||
bool hasProperty = false;
|
||||
napi_has_named_property(env, object, fieldStr.c_str(), &hasProperty);
|
||||
@@ -88,7 +83,7 @@ bool NapiUtil::JsObjectGetProperty(const napi_env &env,
|
||||
return hasProperty;
|
||||
}
|
||||
|
||||
void NapiUtil::JsObjectToInt(const napi_env &env, const napi_value &object, std::string fieldStr, int &fieldRef)
|
||||
void NapiUtil::JsObjectToInt(const napi_env &env, const napi_value &object, std::string fieldStr, int32_t &fieldRef)
|
||||
{
|
||||
bool hasProperty = false;
|
||||
napi_has_named_property(env, object, fieldStr.c_str(), &hasProperty);
|
||||
@@ -101,15 +96,12 @@ void NapiUtil::JsObjectToInt(const napi_env &env, const napi_value &object, std:
|
||||
NAPI_ASSERT_RETURN_VOID(env, valueType == napi_number, "Wrong argument type. Number expected.");
|
||||
napi_get_value_int32(env, field, &fieldRef);
|
||||
} else {
|
||||
USB_HILOGW(MODULE_JS_NAPI, "%{public}s js to int no property: %{public}s", __func__, fieldStr.c_str());
|
||||
USB_HILOGW(MODULE_JS_NAPI, "%{public}s js to int32_t no property: %{public}s", __func__, fieldStr.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
bool NapiUtil::JsUint8ArrayParse(const napi_env &env,
|
||||
const napi_value &object,
|
||||
uint8_t **uint8Buffer,
|
||||
size_t &bufferSize,
|
||||
size_t &offset)
|
||||
bool NapiUtil::JsUint8ArrayParse(const napi_env &env, const napi_value &object, uint8_t **uint8Buffer,
|
||||
size_t &bufferSize, size_t &offset)
|
||||
{
|
||||
bool isTypedArray = false;
|
||||
if (napi_is_typedarray(env, object, &isTypedArray) != napi_ok || !isTypedArray) {
|
||||
@@ -135,10 +127,8 @@ bool NapiUtil::JsUint8ArrayParse(const napi_env &env,
|
||||
return true;
|
||||
}
|
||||
|
||||
void NapiUtil::Uint8ArrayToJsValue(const napi_env &env,
|
||||
std::vector<uint8_t> &uint8Buffer,
|
||||
size_t bufferSize,
|
||||
napi_value &result)
|
||||
void NapiUtil::Uint8ArrayToJsValue(const napi_env &env, std::vector<uint8_t> &uint8Buffer, size_t bufferSize,
|
||||
napi_value &result)
|
||||
{
|
||||
if (bufferSize < 0) {
|
||||
napi_get_undefined(env, &result);
|
||||
@@ -159,7 +149,7 @@ void NapiUtil::SetValueUtf8String(const napi_env &env, std::string fieldStr, std
|
||||
napi_set_named_property(env, result, fieldStr.c_str(), value);
|
||||
}
|
||||
|
||||
void NapiUtil::SetValueInt32(const napi_env &env, std::string fieldStr, const int intValue, napi_value &result)
|
||||
void NapiUtil::SetValueInt32(const napi_env &env, std::string fieldStr, const int32_t intValue, napi_value &result)
|
||||
{
|
||||
napi_value value;
|
||||
napi_create_int32(env, intValue, &value);
|
||||
|
||||
@@ -46,7 +46,7 @@ const int32_t PARAM_COUNT_4 = 4;
|
||||
const int32_t STR_DEFAULT_SIZE = 256;
|
||||
const int32_t DEFAULT_DESCRIPTION_SIZE = 32;
|
||||
|
||||
static void ParseUsbDevicePipe(const napi_env env, const napi_value &obj, USBDevicePipe &pip)
|
||||
static void ParseUsbDevicePipe(const napi_env env, const napi_value &obj, USBDevicePipe &pipe)
|
||||
{
|
||||
napi_valuetype valueType;
|
||||
napi_typeof(env, obj, &valueType);
|
||||
@@ -54,10 +54,10 @@ static void ParseUsbDevicePipe(const napi_env env, const napi_value &obj, USBDev
|
||||
|
||||
int32_t busNum = 0;
|
||||
NapiUtil::JsObjectToInt(env, obj, "busNum", busNum);
|
||||
pip.SetBusNum((uint8_t)busNum);
|
||||
pipe.SetBusNum((uint8_t)busNum);
|
||||
int32_t devAddr = 0;
|
||||
NapiUtil::JsObjectToInt(env, obj, "devAddress", devAddr);
|
||||
pip.SetDevAddr((uint8_t)devAddr);
|
||||
pipe.SetDevAddr((uint8_t)devAddr);
|
||||
}
|
||||
|
||||
static void ProcessPromise(const napi_env env, const USBAsyncContext &asyncContext, napi_value &result)
|
||||
@@ -71,11 +71,11 @@ static void ProcessPromise(const napi_env env, const USBAsyncContext &asyncConte
|
||||
}
|
||||
}
|
||||
|
||||
static void CreateUsbDevicePipe(const napi_env env, napi_value &obj, const USBDevicePipe &pip)
|
||||
static void CreateUsbDevicePipe(const napi_env env, napi_value &obj, const USBDevicePipe &pipe)
|
||||
{
|
||||
napi_create_object(env, &obj);
|
||||
NapiUtil::SetValueInt32(env, "busNum", pip.GetBusNum(), obj);
|
||||
NapiUtil::SetValueInt32(env, "devAddress", pip.GetDevAddr(), obj);
|
||||
NapiUtil::SetValueInt32(env, "busNum", pipe.GetBusNum(), obj);
|
||||
NapiUtil::SetValueInt32(env, "devAddress", pipe.GetDevAddr(), obj);
|
||||
}
|
||||
|
||||
static void CtoJSUsbEndpoint(const napi_env &env, napi_value &obj, const USBEndpoint &usbEndpoint)
|
||||
@@ -383,7 +383,7 @@ static napi_value CoreGetDevices(napi_env env, napi_callback_info info)
|
||||
napi_value result;
|
||||
if (ret != UEC_OK) {
|
||||
napi_get_undefined(env, &result);
|
||||
USB_HILOGD(MODULE_JS_NAPI, "end call %{public}s, get device faild ret : %{public}d", __func__, ret);
|
||||
USB_HILOGE(MODULE_JS_NAPI, "end call %{public}s, get device faild ret : %{public}d", __func__, ret);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -420,11 +420,11 @@ static napi_value CoreConnectDevice(napi_env env, napi_callback_info info)
|
||||
UsbDevice dev;
|
||||
ParseDeviceObj(env, deviceObj, dev);
|
||||
|
||||
USBDevicePipe pip;
|
||||
int32_t ret = g_usbClient.OpenDevice(dev, pip);
|
||||
USBDevicePipe pipe;
|
||||
int32_t ret = g_usbClient.OpenDevice(dev, pipe);
|
||||
napi_value pipObj = nullptr;
|
||||
if (ret == UEC_OK) {
|
||||
CreateUsbDevicePipe(env, pipObj, pip);
|
||||
CreateUsbDevicePipe(env, pipObj, pipe);
|
||||
} else if (ret == UEC_SERVICE_PERMISSION_DENIED || ret == UEC_INTERFACE_PERMISSION_DENIED) {
|
||||
napi_throw_error(env, nullptr, "permission denied, need call requestRight to get permission");
|
||||
} else {
|
||||
@@ -660,7 +660,7 @@ static napi_value CoreGetCurrentFunctions(napi_env env, napi_callback_info info)
|
||||
napi_value result;
|
||||
if (ret != UEC_OK) {
|
||||
napi_get_undefined(env, &result);
|
||||
USB_HILOGD(MODULE_JS_NAPI, "end call %{public}s, get ports faild ret : %{public}d", __func__, ret);
|
||||
USB_HILOGE(MODULE_JS_NAPI, "end call %{public}s, get ports faild ret : %{public}d", __func__, ret);
|
||||
return result;
|
||||
}
|
||||
napi_create_int32(env, cfuncs, &result);
|
||||
@@ -687,7 +687,7 @@ static napi_value CoreGetPorts(napi_env env, napi_callback_info info)
|
||||
napi_value result;
|
||||
if (ret != UEC_OK) {
|
||||
napi_get_undefined(env, &result);
|
||||
USB_HILOGD(MODULE_JS_NAPI, "end call %{public}s, get ports faild ret : %{public}d", __func__, ret);
|
||||
USB_HILOGE(MODULE_JS_NAPI, "end call %{public}s, get ports faild ret : %{public}d", __func__, ret);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -834,8 +834,8 @@ static napi_value PipeClaimInterface(napi_env env, napi_callback_info info)
|
||||
napi_typeof(env, obj, &type);
|
||||
NAPI_ASSERT(env, type == napi_object, "Wrong argument type. Object expected.");
|
||||
|
||||
USBDevicePipe pip;
|
||||
ParseUsbDevicePipe(env, obj, pip);
|
||||
USBDevicePipe pipe;
|
||||
ParseUsbDevicePipe(env, obj, pipe);
|
||||
|
||||
UsbInterface interface;
|
||||
napi_value obj2 = argv[INDEX_1];
|
||||
@@ -850,8 +850,8 @@ static napi_value PipeClaimInterface(napi_env env, napi_callback_info info)
|
||||
napi_get_value_bool(env, argv[INDEX_2], &isForce);
|
||||
}
|
||||
|
||||
int32_t ret = pip.ClaimInterface(interface, isForce);
|
||||
USB_HILOGD(MODULE_JS_NAPI, "pip call ClaimInterface ret: %{public}d", ret);
|
||||
int32_t ret = pipe.ClaimInterface(interface, isForce);
|
||||
USB_HILOGD(MODULE_JS_NAPI, "pipe call ClaimInterface ret: %{public}d", ret);
|
||||
napi_value result;
|
||||
napi_create_int32(env, ret, &result);
|
||||
struct timeval end = {0};
|
||||
@@ -877,14 +877,14 @@ static napi_value PipeReleaseInterface(napi_env env, napi_callback_info info)
|
||||
napi_typeof(env, obj, &type);
|
||||
NAPI_ASSERT(env, type == napi_object, "Wrong argument type. Object expected.");
|
||||
|
||||
USBDevicePipe pip;
|
||||
ParseUsbDevicePipe(env, obj, pip);
|
||||
USBDevicePipe pipe;
|
||||
ParseUsbDevicePipe(env, obj, pipe);
|
||||
|
||||
UsbInterface interface;
|
||||
napi_value obj2 = argv[INDEX_1];
|
||||
ParseInterfaceObj(env, obj2, interface);
|
||||
int32_t ret = pip.ReleaseInterface(interface);
|
||||
USB_HILOGD(MODULE_JS_NAPI, "pip call PipeReleaseInterface ret: %{public}d", ret);
|
||||
int32_t ret = pipe.ReleaseInterface(interface);
|
||||
USB_HILOGD(MODULE_JS_NAPI, "pipe call PipeReleaseInterface ret: %{public}d", ret);
|
||||
napi_value result;
|
||||
napi_create_int32(env, ret, &result);
|
||||
struct timeval end = {0};
|
||||
@@ -909,8 +909,8 @@ static napi_value PipeSetInterface(napi_env env, napi_callback_info info)
|
||||
napi_typeof(env, pipeObj, &type);
|
||||
NAPI_ASSERT(env, type == napi_object, "Wrong argument type. Object expected.");
|
||||
|
||||
USBDevicePipe pip;
|
||||
ParseUsbDevicePipe(env, pipeObj, pip);
|
||||
USBDevicePipe pipe;
|
||||
ParseUsbDevicePipe(env, pipeObj, pipe);
|
||||
|
||||
napi_value interfaceObj = argv[INDEX_1];
|
||||
napi_typeof(env, interfaceObj, &type);
|
||||
@@ -918,7 +918,7 @@ static napi_value PipeSetInterface(napi_env env, napi_callback_info info)
|
||||
|
||||
UsbInterface interface;
|
||||
ParseInterfaceObj(env, interfaceObj, interface);
|
||||
int32_t ret = g_usbClient.SetInterface(pip, interface);
|
||||
int32_t ret = g_usbClient.SetInterface(pipe, interface);
|
||||
napi_value result;
|
||||
napi_create_int32(env, ret, &result);
|
||||
struct timeval end = {0};
|
||||
@@ -943,8 +943,8 @@ static napi_value PipeSetConfiguration(napi_env env, napi_callback_info info)
|
||||
|
||||
napi_typeof(env, pipeObj, &type);
|
||||
NAPI_ASSERT(env, type == napi_object, "Wrong argument type. Object expected.");
|
||||
USBDevicePipe pip;
|
||||
ParseUsbDevicePipe(env, pipeObj, pip);
|
||||
USBDevicePipe pipe;
|
||||
ParseUsbDevicePipe(env, pipeObj, pipe);
|
||||
|
||||
napi_value configObj = argv[INDEX_1];
|
||||
napi_typeof(env, configObj, &type);
|
||||
@@ -952,7 +952,7 @@ static napi_value PipeSetConfiguration(napi_env env, napi_callback_info info)
|
||||
USBConfig config;
|
||||
ParseConfigObj(env, configObj, config);
|
||||
|
||||
int32_t ret = g_usbClient.SetConfiguration(pip, config);
|
||||
int32_t ret = g_usbClient.SetConfiguration(pipe, config);
|
||||
napi_value result;
|
||||
napi_create_int32(env, ret, &result);
|
||||
struct timeval end = {0};
|
||||
@@ -977,14 +977,14 @@ static napi_value PipeGetRawDescriptors(napi_env env, napi_callback_info info)
|
||||
napi_typeof(env, obj, &type);
|
||||
NAPI_ASSERT(env, type == napi_object, "Wrong argument type. Object expected.");
|
||||
|
||||
USBDevicePipe pip;
|
||||
ParseUsbDevicePipe(env, obj, pip);
|
||||
USBDevicePipe pipe;
|
||||
ParseUsbDevicePipe(env, obj, pipe);
|
||||
|
||||
napi_value result;
|
||||
std::vector<uint8_t> vdata;
|
||||
int32_t ret = g_usbClient.GetRawDescriptors(vdata);
|
||||
std::vector<uint8_t> bufferData;
|
||||
int32_t ret = g_usbClient.GetRawDescriptors(pipe, bufferData);
|
||||
if (ret == UEC_OK) {
|
||||
NapiUtil::Uint8ArrayToJsValue(env, vdata, vdata.size(), result);
|
||||
NapiUtil::Uint8ArrayToJsValue(env, bufferData, bufferData.size(), result);
|
||||
} else {
|
||||
napi_get_undefined(env, &result);
|
||||
}
|
||||
@@ -1000,18 +1000,27 @@ static napi_value PipeGetFileDescriptor(napi_env env, napi_callback_info info)
|
||||
USB_HILOGD(MODULE_JS_NAPI, "begin call %{public}s", __func__);
|
||||
struct timeval start = {0};
|
||||
gettimeofday(&start, nullptr);
|
||||
|
||||
size_t argc = PARAM_COUNT_1;
|
||||
napi_value argv[PARAM_COUNT_1] = {0};
|
||||
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
|
||||
NAPI_ASSERT(env, (argc == PARAM_COUNT_0), "PipeGetFileDescriptor failed to get cb info");
|
||||
|
||||
int32_t fd = g_usbClient.GetFileDescriptor();
|
||||
napi_status status = napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
|
||||
NAPI_ASSERT(env, (status == napi_ok) && (argc >= PARAM_COUNT_1), "PipeGetFileDescriptor failed to get cb info");
|
||||
napi_value obj = argv[INDEX_0];
|
||||
napi_valuetype type;
|
||||
napi_typeof(env, obj, &type);
|
||||
NAPI_ASSERT(env, type == napi_object, "Wrong argument type. Object expected.");
|
||||
|
||||
USBDevicePipe pipe;
|
||||
ParseUsbDevicePipe(env, obj, pipe);
|
||||
|
||||
int32_t fd = -1;
|
||||
napi_value result;
|
||||
int32_t ret = g_usbClient.GetFileDescriptor(pipe, fd);
|
||||
napi_create_int32(env, fd, &result);
|
||||
struct timeval end = {0};
|
||||
gettimeofday(&end, nullptr);
|
||||
USB_HILOGD(MODULE_JS_NAPI, "end call %{public}s, takes : %{public}ld ms", __func__, getTimeDiff(start, end));
|
||||
USB_HILOGD(MODULE_JS_NAPI, "end call %{public}s, ret : %{public}d, takes : %{public}ld ms",
|
||||
__func__, ret, getTimeDiff(start, end));
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1019,17 +1028,17 @@ static auto g_controlTransferExecute = [](napi_env env, void *data) {
|
||||
struct timeval beginAsync = {0};
|
||||
gettimeofday(&beginAsync, nullptr);
|
||||
USBControlTransferAsyncContext *asyncContext = (USBControlTransferAsyncContext *)data;
|
||||
std::vector<uint8_t> vdata(asyncContext->buffer, asyncContext->buffer + asyncContext->bufferLength);
|
||||
std::vector<uint8_t> bufferData(asyncContext->buffer, asyncContext->buffer + asyncContext->bufferLength);
|
||||
const UsbCtrlTransfer tctrl = {asyncContext->reqType, asyncContext->request, asyncContext->value,
|
||||
asyncContext->index, asyncContext->timeout};
|
||||
int32_t ret = asyncContext->pipe.ControlTransfer(tctrl, vdata);
|
||||
asyncContext->index, asyncContext->timeOut};
|
||||
int32_t ret = asyncContext->pipe.ControlTransfer(tctrl, bufferData);
|
||||
if ((asyncContext->reqType & USB_ENDPOINT_DIR_MASK) == USB_ENDPOINT_DIR_OUT) {
|
||||
delete asyncContext->buffer;
|
||||
asyncContext->buffer = nullptr;
|
||||
} else {
|
||||
(vdata.size() > asyncContext->bufferLength) ? asyncContext->bufferLength = asyncContext->bufferLength
|
||||
: asyncContext->bufferLength = vdata.size();
|
||||
memcpy_s(asyncContext->buffer, asyncContext->bufferLength, vdata.data(), asyncContext->bufferLength);
|
||||
(bufferData.size() > asyncContext->bufferLength) ? asyncContext->bufferLength = asyncContext->bufferLength
|
||||
: asyncContext->bufferLength = bufferData.size();
|
||||
memcpy_s(asyncContext->buffer, asyncContext->bufferLength, bufferData.data(), asyncContext->bufferLength);
|
||||
}
|
||||
if (ret == UEC_OK) {
|
||||
asyncContext->status = napi_ok;
|
||||
@@ -1080,10 +1089,10 @@ static napi_value PipeControlTransfer(napi_env env, napi_callback_info info)
|
||||
PipeControlParam controlParam = {0};
|
||||
ParsePipeControlParam(env, argv[INDEX_1], controlParam);
|
||||
|
||||
// timeout param
|
||||
int32_t timeout = 0;
|
||||
// timeOut param
|
||||
int32_t timeOut = 0;
|
||||
if (argc >= PARAM_COUNT_3) {
|
||||
napi_get_value_int32(env, argv[INDEX_2], &timeout);
|
||||
napi_get_value_int32(env, argv[INDEX_2], &timeOut);
|
||||
}
|
||||
|
||||
auto asyncContext = new USBControlTransferAsyncContext();
|
||||
@@ -1104,7 +1113,7 @@ static napi_value PipeControlTransfer(napi_env env, napi_callback_info info)
|
||||
}
|
||||
|
||||
asyncContext->bufferLength = controlParam.dataLength;
|
||||
asyncContext->timeout = timeout;
|
||||
asyncContext->timeOut = timeOut;
|
||||
napi_value result = nullptr;
|
||||
napi_create_promise(env, &asyncContext->deferred, &result);
|
||||
|
||||
@@ -1125,16 +1134,16 @@ static auto g_bulkTransferExecute = [](napi_env env, void *data) {
|
||||
gettimeofday(&beginAsync, nullptr);
|
||||
|
||||
USBBulkTransferAsyncContext *asyncContext = (USBBulkTransferAsyncContext *)data;
|
||||
std::vector<uint8_t> vdata(asyncContext->buffer, asyncContext->buffer + asyncContext->bufferLength);
|
||||
int32_t ret = asyncContext->pipe.BulkTransfer(asyncContext->endpoint, vdata, asyncContext->timeout);
|
||||
std::vector<uint8_t> bufferData(asyncContext->buffer, asyncContext->buffer + asyncContext->bufferLength);
|
||||
int32_t ret = asyncContext->pipe.BulkTransfer(asyncContext->endpoint, bufferData, asyncContext->timeOut);
|
||||
|
||||
if (asyncContext->endpoint.GetDirection() == USB_ENDPOINT_DIR_OUT) {
|
||||
delete asyncContext->buffer;
|
||||
asyncContext->buffer = nullptr;
|
||||
} else {
|
||||
(vdata.size() > asyncContext->bufferLength) ? asyncContext->bufferLength = asyncContext->bufferLength
|
||||
: asyncContext->bufferLength = vdata.size();
|
||||
memcpy_s(asyncContext->buffer, asyncContext->bufferLength, vdata.data(), asyncContext->bufferLength);
|
||||
(bufferData.size() > asyncContext->bufferLength) ? asyncContext->bufferLength = asyncContext->bufferLength
|
||||
: asyncContext->bufferLength = bufferData.size();
|
||||
memcpy_s(asyncContext->buffer, asyncContext->bufferLength, bufferData.data(), asyncContext->bufferLength);
|
||||
}
|
||||
|
||||
USB_HILOGD(MODULE_JS_NAPI, "call pipe result %{public}d", ret);
|
||||
@@ -1172,19 +1181,19 @@ static bool GetBulkTransferParams(napi_env env, napi_callback_info info, USBBulk
|
||||
NAPI_ASSERT(env, (status == napi_ok) && (argc >= PARAM_COUNT_3), "BulkTransfer failed to get cb info");
|
||||
|
||||
napi_valuetype type;
|
||||
USBDevicePipe pip;
|
||||
USBDevicePipe pipe;
|
||||
napi_typeof(env, argv[INDEX_0], &type);
|
||||
NAPI_ASSERT(env, type == napi_object, "BulkTransfer wrong argument type index 0, object expected");
|
||||
ParseUsbDevicePipe(env, argv[INDEX_0], pip);
|
||||
ParseUsbDevicePipe(env, argv[INDEX_0], pipe);
|
||||
|
||||
USBEndpoint ep;
|
||||
napi_typeof(env, argv[INDEX_1], &type);
|
||||
NAPI_ASSERT(env, type == napi_object, "BulkTransfer wrong argument type index 1. Object expected.");
|
||||
ParseEndpointObj(env, argv[INDEX_1], ep);
|
||||
|
||||
int32_t timeout = 0;
|
||||
int32_t timeOut = 0;
|
||||
if (argc > PARAM_COUNT_3) {
|
||||
napi_get_value_int32(env, argv[INDEX_3], &timeout);
|
||||
napi_get_value_int32(env, argv[INDEX_3], &timeOut);
|
||||
}
|
||||
|
||||
uint8_t *buffer = nullptr;
|
||||
@@ -1192,11 +1201,11 @@ static bool GetBulkTransferParams(napi_env env, napi_callback_info info, USBBulk
|
||||
size_t bufferSize;
|
||||
bool hasBuffer = NapiUtil::JsUint8ArrayParse(env, argv[INDEX_2], &buffer, bufferSize, offset);
|
||||
if (!hasBuffer) {
|
||||
USB_HILOGD(MODULE_JS_NAPI, "BulkTransfer wrong argument, buffer is null");
|
||||
USB_HILOGE(MODULE_JS_NAPI, "BulkTransfer wrong argument, buffer is null");
|
||||
return false;
|
||||
}
|
||||
asyncContext.env = env;
|
||||
asyncContext.pipe = pip;
|
||||
asyncContext.pipe = pipe;
|
||||
asyncContext.endpoint = ep;
|
||||
|
||||
if (ep.GetDirection() == USB_ENDPOINT_DIR_OUT) {
|
||||
@@ -1207,7 +1216,7 @@ static bool GetBulkTransferParams(napi_env env, napi_callback_info info, USBBulk
|
||||
asyncContext.buffer = buffer;
|
||||
}
|
||||
asyncContext.bufferLength = bufferSize;
|
||||
asyncContext.timeout = timeout;
|
||||
asyncContext.timeOut = timeOut;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1221,7 +1230,7 @@ static napi_value PipeBulkTransfer(napi_env env, napi_callback_info info)
|
||||
napi_value result = nullptr;
|
||||
napi_create_promise(env, &asyncContext->deferred, &result);
|
||||
if (!GetBulkTransferParams(env, info, *asyncContext)) {
|
||||
USB_HILOGD(MODULE_JS_NAPI, "end call %{public}s %{public}d : invalid arg", __func__, __LINE__);
|
||||
USB_HILOGE(MODULE_JS_NAPI, "end call %{public}s %{public}d : invalid arg", __func__, __LINE__);
|
||||
asyncContext->status = napi_invalid_arg;
|
||||
napi_value queryResult = nullptr;
|
||||
napi_create_int32(env, -1, &queryResult);
|
||||
@@ -1238,7 +1247,7 @@ static napi_value PipeBulkTransfer(napi_env env, napi_callback_info info)
|
||||
struct timeval end = {0};
|
||||
gettimeofday(&end, nullptr);
|
||||
if (status != napi_ok) {
|
||||
USB_HILOGD(MODULE_JS_NAPI, "end call %{public}s, create async work failed, takes : %{public}ld ms", __func__,
|
||||
USB_HILOGE(MODULE_JS_NAPI, "end call %{public}s, create async work failed, takes : %{public}ld ms", __func__,
|
||||
getTimeDiff(start, end));
|
||||
return result;
|
||||
}
|
||||
@@ -1265,9 +1274,9 @@ static napi_value PipeClose(napi_env env, napi_callback_info info)
|
||||
napi_typeof(env, obj, &type);
|
||||
NAPI_ASSERT(env, type == napi_object, "Wrong argument type. Object expected.");
|
||||
|
||||
USBDevicePipe pip;
|
||||
ParseUsbDevicePipe(env, obj, pip);
|
||||
int32_t ret = pip.Close();
|
||||
USBDevicePipe pipe;
|
||||
ParseUsbDevicePipe(env, obj, pipe);
|
||||
int32_t ret = pipe.Close();
|
||||
napi_value result;
|
||||
napi_create_int32(env, ret, &result);
|
||||
struct timeval end = {0};
|
||||
@@ -1286,6 +1295,61 @@ static napi_value GetVersion(napi_env env, napi_callback_info info)
|
||||
return result;
|
||||
}
|
||||
|
||||
static napi_value ToInt32Value(napi_env env, int32_t value)
|
||||
{
|
||||
napi_value staticValue = nullptr;
|
||||
napi_create_int32(env, value, &staticValue);
|
||||
return staticValue;
|
||||
}
|
||||
|
||||
static napi_value DeclareEnum(napi_env env, napi_value exports)
|
||||
{
|
||||
napi_property_descriptor desc[] = {
|
||||
/* Declare Enum PowerRoleType */
|
||||
DECLARE_NAPI_STATIC_PROPERTY("NONE", ToInt32Value(env, NONE)),
|
||||
DECLARE_NAPI_STATIC_PROPERTY("SOURCE", ToInt32Value(env, SOURCE)),
|
||||
DECLARE_NAPI_STATIC_PROPERTY("SINK", ToInt32Value(env, SINK)),
|
||||
|
||||
/* Declare Enum DataRoleType */
|
||||
DECLARE_NAPI_STATIC_PROPERTY("HOST", ToInt32Value(env, HOST)),
|
||||
DECLARE_NAPI_STATIC_PROPERTY("DEVICE", ToInt32Value(env, DEVICE)),
|
||||
|
||||
/* Declare Enum PortModeType */
|
||||
DECLARE_NAPI_STATIC_PROPERTY("UFP", ToInt32Value(env, UFP)),
|
||||
DECLARE_NAPI_STATIC_PROPERTY("DFP", ToInt32Value(env, DFP)),
|
||||
DECLARE_NAPI_STATIC_PROPERTY("DRP", ToInt32Value(env, DRP)),
|
||||
DECLARE_NAPI_STATIC_PROPERTY("NUM_MODES", ToInt32Value(env, NUM_MODES)),
|
||||
|
||||
/* Declare Enum USBRequestTargetType */
|
||||
DECLARE_NAPI_STATIC_PROPERTY("USB_REQUEST_TARGET_DEVICE", ToInt32Value(env, USB_REQUEST_TARGET_DEVICE)),
|
||||
DECLARE_NAPI_STATIC_PROPERTY("USB_REQUEST_TARGET_INTERFACE", ToInt32Value(env, USB_REQUEST_TARGET_INTERFACE)),
|
||||
DECLARE_NAPI_STATIC_PROPERTY("USB_REQUEST_TARGET_ENDPOINT", ToInt32Value(env, USB_REQUEST_TARGET_ENDPOINT)),
|
||||
DECLARE_NAPI_STATIC_PROPERTY("USB_REQUEST_TARGET_OTHER", ToInt32Value(env, USB_REQUEST_TARGET_OTHER)),
|
||||
|
||||
/* Declare Enum USBControlRequestType */
|
||||
DECLARE_NAPI_STATIC_PROPERTY("USB_REQUEST_TYPE_STANDARD", ToInt32Value(env, USB_REQUEST_TYPE_STANDARD)),
|
||||
DECLARE_NAPI_STATIC_PROPERTY("USB_REQUEST_TYPE_CLASS", ToInt32Value(env, USB_REQUEST_TYPE_CLASS)),
|
||||
DECLARE_NAPI_STATIC_PROPERTY("USB_REQUEST_TYPE_VENDOR", ToInt32Value(env, USB_REQUEST_TYPE_VENDOR)),
|
||||
|
||||
/* Declare Enum USBRequestDirection */
|
||||
DECLARE_NAPI_STATIC_PROPERTY("USB_REQUEST_DIR_TO_DEVICE", ToInt32Value(env, USB_REQUEST_DIR_TO_DEVICE)),
|
||||
DECLARE_NAPI_STATIC_PROPERTY("USB_REQUEST_DIR_FROM_DEVICE", ToInt32Value(env, USB_REQUEST_DIR_FROM_DEVICE)),
|
||||
|
||||
/* Declare Enum FunctionType */
|
||||
DECLARE_NAPI_STATIC_PROPERTY("ACM", ToInt32Value(env, ACM)),
|
||||
DECLARE_NAPI_STATIC_PROPERTY("ECM", ToInt32Value(env, ECM)),
|
||||
DECLARE_NAPI_STATIC_PROPERTY("HDC", ToInt32Value(env, HDC)),
|
||||
DECLARE_NAPI_STATIC_PROPERTY("MTP", ToInt32Value(env, MTP)),
|
||||
DECLARE_NAPI_STATIC_PROPERTY("PTP", ToInt32Value(env, PTP)),
|
||||
DECLARE_NAPI_STATIC_PROPERTY("RNDIS", ToInt32Value(env, RNDIS)),
|
||||
DECLARE_NAPI_STATIC_PROPERTY("MIDI", ToInt32Value(env, MIDI)),
|
||||
DECLARE_NAPI_STATIC_PROPERTY("AUDIO_SOURCE", ToInt32Value(env, AUDIO_SOURCE)),
|
||||
DECLARE_NAPI_STATIC_PROPERTY("NCM", ToInt32Value(env, NCM)),
|
||||
};
|
||||
NAPI_CALL(env, napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc));
|
||||
return exports;
|
||||
}
|
||||
|
||||
EXTERN_C_START
|
||||
/*
|
||||
* function for module exports
|
||||
@@ -1320,9 +1384,12 @@ static napi_value UsbInit(napi_env env, napi_value exports)
|
||||
DECLARE_NAPI_FUNCTION("closePipe", PipeClose),
|
||||
|
||||
/* fort test get usb service version */
|
||||
DECLARE_NAPI_FUNCTION("getVersion", GetVersion)};
|
||||
DECLARE_NAPI_FUNCTION("getVersion", GetVersion),
|
||||
};
|
||||
NAPI_CALL(env, napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc));
|
||||
|
||||
DeclareEnum(env, exports);
|
||||
|
||||
USB_HILOGD(MODULE_JS_NAPI, "return");
|
||||
|
||||
return exports;
|
||||
|
||||
@@ -26,8 +26,8 @@ public:
|
||||
|
||||
static int32_t ParseDeviceDescriptor(const uint8_t *buffer, uint32_t length, UsbDevice &dev);
|
||||
static int32_t ParseConfigDescriptor(const uint8_t *buffer, uint32_t length, uint32_t &cursor, USBConfig &config);
|
||||
static int32_t
|
||||
ParseInterfaceDescriptor(const uint8_t *buffer, uint32_t length, uint32_t &cursor, UsbInterface &interface);
|
||||
static int32_t ParseInterfaceDescriptor(const uint8_t *buffer, uint32_t length, uint32_t &cursor,
|
||||
UsbInterface &interface);
|
||||
static int32_t ParseEndpointDescriptor(const uint8_t *buffer, uint32_t length, uint32_t &cursor, USBEndpoint &ep);
|
||||
};
|
||||
} // namespace USB
|
||||
|
||||
@@ -45,7 +45,7 @@ public:
|
||||
private:
|
||||
static const int32_t FUNCTION_SETTABLE;
|
||||
static const std::map<std::string, int32_t> FUNCTION_MAPPING_N2C;
|
||||
static int currentFunctions;
|
||||
static int32_t currentFunctions;
|
||||
};
|
||||
} // namespace USB
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -65,41 +65,36 @@ public:
|
||||
int32_t GetSupportedModes(int32_t portId, int32_t &result) override;
|
||||
int32_t SetPortRole(int32_t portId, int32_t powerRole, int32_t dataRole) override;
|
||||
|
||||
int32_t ClaimInterface(uint8_t busNum, uint8_t devAddr, uint8_t interfaceid) override;
|
||||
int32_t ClaimInterface(uint8_t busNum, uint8_t devAddr, uint8_t interfaceid, uint8_t force) override;
|
||||
int32_t ReleaseInterface(uint8_t busNum, uint8_t devAddr, uint8_t interfaceid) override;
|
||||
int32_t
|
||||
BulkTransferRead(const UsbDev &dev, const UsbPipe &pipe, std::vector<uint8_t> &vdata, int32_t timeout) override;
|
||||
int32_t BulkTransferWrite(const UsbDev &dev,
|
||||
const UsbPipe &pipe,
|
||||
const std::vector<uint8_t> &vdata,
|
||||
int32_t timeout) override;
|
||||
int32_t ControlTransfer(const UsbDev &dev, const UsbCtrlTransfer &ctrl, std::vector<uint8_t> &vdata) override;
|
||||
int32_t BulkTransferRead(const UsbDev &dev, const UsbPipe &pipe, std::vector<uint8_t> &bufferData,
|
||||
int32_t timeOut) override;
|
||||
int32_t BulkTransferWrite(const UsbDev &dev, const UsbPipe &pipe, const std::vector<uint8_t> &bufferData,
|
||||
int32_t timeOut) override;
|
||||
int32_t ControlTransfer(const UsbDev &dev, const UsbCtrlTransfer &ctrl, std::vector<uint8_t> &bufferData) override;
|
||||
int32_t SetActiveConfig(uint8_t busNum, uint8_t devAddr, uint8_t configIndex) override;
|
||||
int32_t GetActiveConfig(uint8_t busNum, uint8_t devAddr, uint8_t &configIndex) override;
|
||||
int32_t SetInterface(uint8_t busNum, uint8_t devAddr, uint8_t interfaceid, uint8_t altIndex) override;
|
||||
int32_t GetRawDescriptor(uint8_t busNum, uint8_t devAddr, std::vector<uint8_t> &vdata) override;
|
||||
int32_t RequestQueue(const UsbDev &dev,
|
||||
const UsbPipe &pipe,
|
||||
const std::vector<uint8_t> &cData,
|
||||
const std::vector<uint8_t> &vData) override;
|
||||
int32_t RequestWait(const UsbDev &dev,
|
||||
int32_t timeout,
|
||||
std::vector<uint8_t> &cData,
|
||||
std::vector<uint8_t> &vData) override;
|
||||
int32_t GetRawDescriptor(uint8_t busNum, uint8_t devAddr, std::vector<uint8_t> &bufferData) override;
|
||||
int32_t GetFileDescriptor(uint8_t busNum, uint8_t devAddr, int32_t &fd) override;
|
||||
int32_t RequestQueue(const UsbDev &dev, const UsbPipe &pipe, const std::vector<uint8_t> &clientData,
|
||||
const std::vector<uint8_t> &bufferData) override;
|
||||
int32_t RequestWait(const UsbDev &dev, int32_t timeOut, std::vector<uint8_t> &clientData,
|
||||
std::vector<uint8_t> &bufferData) override;
|
||||
int32_t RequestCancel(uint8_t busNum, uint8_t devAddr, uint8_t interfaceid, uint8_t endpointId) override;
|
||||
int32_t Close(uint8_t busNum, uint8_t devAddr) override;
|
||||
bool AddDevice(uint8_t busNum, uint8_t devAddr);
|
||||
bool DelDevice(uint8_t busNum, uint8_t devAddr);
|
||||
void UpdateUsbPort(int32_t portId, int32_t powerRole, int32_t dataRole, int32_t mode);
|
||||
int32_t GetDeviceInfo(uint8_t busNum, uint8_t devAddr, UsbDevice &dev);
|
||||
int32_t GetDeviceInfoDescriptor(const UsbDev &uDev,
|
||||
std::vector<uint8_t> &decriptor,
|
||||
uint32_t &length,
|
||||
UsbDevice &dev);
|
||||
int32_t GetConfigDescriptor(const UsbDev &uDev,
|
||||
std::vector<uint8_t> &decriptor,
|
||||
std::vector<USBConfig> &configs,
|
||||
UsbDevice &dev);
|
||||
int32_t GetDeviceInfoDescriptor(const UsbDev &uDev, std::vector<uint8_t> &decriptor, UsbDevice &dev);
|
||||
int32_t GetConfigDescriptor(UsbDevice &dev, std::vector<uint8_t> &decriptor);
|
||||
|
||||
int32_t RegBulkCallback(const UsbDev &devInfo, const UsbPipe &pipe, const sptr<IRemoteObject> &cb) override;
|
||||
int32_t UnRegBulkCallback(const UsbDev &devInfo, const UsbPipe &pipe) override;
|
||||
int32_t BulkRead(const UsbDev &devInfo, const UsbPipe &pipe, sptr<Ashmem> &ashmem) override;
|
||||
int32_t BulkWrite(const UsbDev &devInfo, const UsbPipe &pipe, sptr<Ashmem> &ashmem) override;
|
||||
int32_t BulkCancel(const UsbDev &devInfo, const UsbPipe &pipe) override;
|
||||
|
||||
private:
|
||||
bool Init();
|
||||
|
||||
@@ -40,7 +40,7 @@ int32_t UsbDescriptorParser::ParseDeviceDescriptor(const uint8_t *buffer, uint32
|
||||
{
|
||||
uint32_t cursor = 0;
|
||||
if (buffer == nullptr || length == 0) {
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "%{public}s: buffer is null", __func__);
|
||||
USB_HILOGE(MODULE_USB_SERVICE, "%{public}s: buffer is null", __func__);
|
||||
return UEC_SERVICE_INVALID_VALUE;
|
||||
}
|
||||
|
||||
@@ -48,14 +48,14 @@ int32_t UsbDescriptorParser::ParseDeviceDescriptor(const uint8_t *buffer, uint32
|
||||
__func__, buffer, length, cursor);
|
||||
uint32_t deviceDescriptorSize = sizeof(UsbdDeviceDescriptor);
|
||||
if (length < deviceDescriptorSize) {
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "%{public}s: buffer size error", __func__);
|
||||
USB_HILOGE(MODULE_USB_SERVICE, "%{public}s: buffer size error", __func__);
|
||||
return UEC_SERVICE_INVALID_VALUE;
|
||||
}
|
||||
|
||||
UsbdDeviceDescriptor deviceDescriptor = *(UsbdDeviceDescriptor *)buffer;
|
||||
cursor += deviceDescriptorSize;
|
||||
if (deviceDescriptor.bLength != deviceDescriptorSize) {
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "%{public}s: UsbdDeviceDescriptor size error", __func__);
|
||||
USB_HILOGE(MODULE_USB_SERVICE, "%{public}s: UsbdDeviceDescriptor size error", __func__);
|
||||
return UEC_SERVICE_INVALID_VALUE;
|
||||
}
|
||||
|
||||
@@ -74,10 +74,8 @@ int32_t UsbDescriptorParser::ParseDeviceDescriptor(const uint8_t *buffer, uint32
|
||||
return UEC_OK;
|
||||
}
|
||||
|
||||
int32_t UsbDescriptorParser::ParseConfigDescriptor(const uint8_t *buffer,
|
||||
uint32_t length,
|
||||
uint32_t &cursor,
|
||||
USBConfig &config)
|
||||
int32_t UsbDescriptorParser::ParseConfigDescriptor(const uint8_t *buffer, uint32_t length, uint32_t &cursor,
|
||||
USBConfig &config)
|
||||
{
|
||||
if (buffer == nullptr || length == 0) {
|
||||
return UEC_SERVICE_INVALID_VALUE;
|
||||
@@ -87,14 +85,14 @@ int32_t UsbDescriptorParser::ParseConfigDescriptor(const uint8_t *buffer,
|
||||
__func__, buffer, length, cursor);
|
||||
uint32_t configDescriptorSize = sizeof(UsbdConfigDescriptor);
|
||||
if (length < configDescriptorSize) {
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "%{public}s: buffer size error", __func__);
|
||||
USB_HILOGE(MODULE_USB_SERVICE, "%{public}s: buffer size error", __func__);
|
||||
return UEC_SERVICE_INVALID_VALUE;
|
||||
}
|
||||
|
||||
UsbdConfigDescriptor configDescriptor = *(UsbdConfigDescriptor *)buffer;
|
||||
cursor += configDescriptorSize;
|
||||
if (configDescriptor.bLength != configDescriptorSize) {
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "%{public}s: UsbdDeviceDescriptor size error", __func__);
|
||||
USB_HILOGE(MODULE_USB_SERVICE, "%{public}s: UsbdDeviceDescriptor size error", __func__);
|
||||
return UEC_SERVICE_INVALID_VALUE;
|
||||
}
|
||||
|
||||
@@ -104,7 +102,7 @@ int32_t UsbDescriptorParser::ParseConfigDescriptor(const uint8_t *buffer,
|
||||
config.SetiConfiguration(configDescriptor.iConfiguration);
|
||||
|
||||
std::vector<UsbInterface> interfaces;
|
||||
for (int i = 0; (i < configDescriptor.bNumInterfaces) && (cursor < length); ++i) {
|
||||
for (int32_t i = 0; (i < configDescriptor.bNumInterfaces) && (cursor < length); ++i) {
|
||||
uint32_t interfaceCursor = 0;
|
||||
UsbInterface interface;
|
||||
ParseInterfaceDescriptor(buffer + cursor + interfaceCursor, length - cursor - interfaceCursor, interfaceCursor,
|
||||
@@ -120,10 +118,8 @@ int32_t UsbDescriptorParser::ParseConfigDescriptor(const uint8_t *buffer,
|
||||
return UEC_OK;
|
||||
}
|
||||
|
||||
int32_t UsbDescriptorParser::ParseInterfaceDescriptor(const uint8_t *buffer,
|
||||
uint32_t length,
|
||||
uint32_t &cursor,
|
||||
UsbInterface &interface)
|
||||
int32_t UsbDescriptorParser::ParseInterfaceDescriptor(const uint8_t *buffer, uint32_t length, uint32_t &cursor,
|
||||
UsbInterface &interface)
|
||||
{
|
||||
if (buffer == nullptr || length == 0) {
|
||||
return UEC_SERVICE_INVALID_VALUE;
|
||||
@@ -163,7 +159,7 @@ int32_t UsbDescriptorParser::ParseInterfaceDescriptor(const uint8_t *buffer,
|
||||
interface.SetiInterface(interfaceDescriptor.iInterface);
|
||||
|
||||
std::vector<USBEndpoint> eps;
|
||||
for (int j = 0; j < interfaceDescriptor.bNumEndpoints; ++j) {
|
||||
for (int32_t j = 0; j < interfaceDescriptor.bNumEndpoints; ++j) {
|
||||
uint32_t epCursor = 0;
|
||||
USBEndpoint ep;
|
||||
ParseEndpointDescriptor(buffer + cursor + epCursor, length - cursor - epCursor, epCursor, ep);
|
||||
@@ -174,10 +170,8 @@ int32_t UsbDescriptorParser::ParseInterfaceDescriptor(const uint8_t *buffer,
|
||||
interface.SetEndpoints(eps);
|
||||
return UEC_OK;
|
||||
}
|
||||
int32_t UsbDescriptorParser::ParseEndpointDescriptor(const uint8_t *buffer,
|
||||
uint32_t length,
|
||||
uint32_t &cursor,
|
||||
USBEndpoint &ep)
|
||||
int32_t UsbDescriptorParser::ParseEndpointDescriptor(const uint8_t *buffer, uint32_t length, uint32_t &cursor,
|
||||
USBEndpoint &ep)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "%{public}s: parse begin buffer=%{public}p, length=%{public}d, cursor=%{public}d",
|
||||
__func__, buffer, length, cursor);
|
||||
@@ -188,12 +182,12 @@ int32_t UsbDescriptorParser::ParseEndpointDescriptor(const uint8_t *buffer,
|
||||
uint32_t descriptorHeaderSize = sizeof(UsbdDescriptorHeader);
|
||||
while ((uint32_t)cursor < length) {
|
||||
if (descriptorHeaderSize >= length) {
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "%{public}s: descriptor size error", __func__);
|
||||
USB_HILOGE(MODULE_USB_SERVICE, "%{public}s: descriptor size error", __func__);
|
||||
return UEC_SERVICE_INVALID_VALUE;
|
||||
}
|
||||
UsbdDescriptorHeader descriptorHeader = *(UsbdDescriptorHeader *)(buffer + cursor);
|
||||
if (descriptorHeader.bLength > length) {
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "%{public}s: descriptor size error", __func__);
|
||||
USB_HILOGE(MODULE_USB_SERVICE, "%{public}s: descriptor size error", __func__);
|
||||
return UEC_SERVICE_INVALID_VALUE;
|
||||
}
|
||||
if (descriptorHeader.bDescriptorType == static_cast<uint8_t>(DescriptorType::DESCRIPTOR_TYPE_ENDPOINT)) {
|
||||
@@ -206,7 +200,7 @@ int32_t UsbDescriptorParser::ParseEndpointDescriptor(const uint8_t *buffer,
|
||||
|
||||
UsbdEndpointDescriptor endpointDescriptor = *(UsbdEndpointDescriptor *)(buffer + cursor);
|
||||
if (endpointDescriptor.bLength != sizeof(UsbdEndpointDescriptor)) {
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "%{public}s: Endpoint descriptor size error, length=%{public}d", __func__,
|
||||
USB_HILOGE(MODULE_USB_SERVICE, "%{public}s: Endpoint descriptor size error, length=%{public}d", __func__,
|
||||
endpointDescriptor.bLength);
|
||||
return UEC_SERVICE_INVALID_VALUE;
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ int32_t UsbFunctionManager::FromStringFunctions(std::string strFun)
|
||||
std::vector<std::string> vModeStr;
|
||||
size_t pos = 0;
|
||||
while (pos < len) {
|
||||
int find_pos = strFun.find(",", pos);
|
||||
int32_t find_pos = strFun.find(",", pos);
|
||||
if (find_pos < 0) {
|
||||
vModeStr.push_back(strFun.substr(pos, len - pos));
|
||||
break;
|
||||
@@ -73,7 +73,7 @@ int32_t UsbFunctionManager::FromStringFunctions(std::string strFun)
|
||||
if (it != FUNCTION_MAPPING_N2C.end()) {
|
||||
ret |= it->second;
|
||||
} else {
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbFunctionManager::FromStringFunctions Invalid argument of usb function");
|
||||
USB_HILOGE(MODULE_USB_SERVICE, "UsbFunctionManager::FromStringFunctions Invalid argument of usb function");
|
||||
return UEC_SERVICE_INVALID_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ UsbPortManager::~UsbPortManager()
|
||||
void UsbPortManager::Init()
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbPortManager::QueryPort start");
|
||||
int ret = QueryPort();
|
||||
int32_t ret = QueryPort();
|
||||
if (ret) {
|
||||
USB_HILOGE(MODULE_USB_SERVICE, "UsbPortManager::QueryPort false");
|
||||
}
|
||||
@@ -49,7 +49,7 @@ int32_t UsbPortManager::GetPorts(std::vector<UsbPort> &ports)
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbPortManager::GetPorts success");
|
||||
return UEC_OK;
|
||||
} else {
|
||||
int ret = QueryPort();
|
||||
int32_t ret = QueryPort();
|
||||
if (ret == UEC_OK) {
|
||||
for (auto it = portMap.begin(); it != portMap.end(); ++it) {
|
||||
ports.push_back(it->second);
|
||||
@@ -81,11 +81,11 @@ int32_t UsbPortManager::QueryPort()
|
||||
int32_t powerRole = 0;
|
||||
int32_t dataRole = 0;
|
||||
int32_t mode = 0;
|
||||
int ret = UsbdClient::QueryPort(portId, powerRole, dataRole, mode);
|
||||
int32_t ret = UsbdClient::GetInstance().QueryPort(portId, powerRole, dataRole, mode);
|
||||
USB_HILOGE(MODULE_USB_SERVICE, "portId:%{public}d powerRole:%{public}d dataRole:%{public}d mode:%{public}d ",
|
||||
portId, powerRole, dataRole, mode);
|
||||
if (ret) {
|
||||
USB_HILOGE(MODULE_USB_SERVICE, "UsbdClient::queryPorts false");
|
||||
USB_HILOGE(MODULE_USB_SERVICE, "UsbdClient::GetInstance().queryPorts false");
|
||||
return ret;
|
||||
}
|
||||
UsbPortStatus usbPortStatus;
|
||||
|
||||
@@ -19,10 +19,10 @@
|
||||
namespace OHOS {
|
||||
namespace USB {
|
||||
UsbServerEventHandler::UsbServerEventHandler(const std::shared_ptr<AppExecFwk::EventRunner> &runner,
|
||||
const wptr<UsbService> &service)
|
||||
const wptr<UsbService> &service)
|
||||
: AppExecFwk::EventHandler(runner), service_(service)
|
||||
{
|
||||
USB_HILOGE(MODULE_USB_SERVICE, "UsbServerEventHandler::UsbServerEventHandler instance created.");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbServerEventHandler::UsbServerEventHandler instance created.");
|
||||
}
|
||||
|
||||
void UsbServerEventHandler::ProcessEvent([[maybe_unused]] const AppExecFwk::InnerEvent::Pointer &event) {}
|
||||
|
||||
+132
-111
@@ -40,7 +40,7 @@ namespace {
|
||||
const std::string USB_SERVICE_NAME = "UsbService";
|
||||
constexpr int32_t COMMEVENT_REGISTER_RETRY_TIMES = 10;
|
||||
constexpr int32_t COMMEVENT_REGISTER_WAIT_DELAY_US = 20000;
|
||||
const int32_t USB_MAX_DESCRIPTOR_SIZE = 256;
|
||||
const uint32_t CURSOR_INIT = 18;
|
||||
const int32_t DESCRIPTOR_TYPE_STRING = 3;
|
||||
const int32_t DESCRIPTOR_VALUE_START_OFFSET = 2;
|
||||
const int32_t HALF = 2;
|
||||
@@ -59,9 +59,7 @@ UsbService::UsbService() : SystemAbility(USB_SYSTEM_ABILITY_ID, true)
|
||||
usbRightManager_ = std::make_shared<UsbRightManager>();
|
||||
usbPortManager_ = std::make_shared<UsbPortManager>();
|
||||
}
|
||||
UsbService::~UsbService()
|
||||
{
|
||||
}
|
||||
UsbService::~UsbService() {}
|
||||
|
||||
void UsbService::OnStart()
|
||||
{
|
||||
@@ -120,7 +118,7 @@ bool UsbService::Init()
|
||||
bool UsbService::InitUsbd()
|
||||
{
|
||||
usbdSubscriber_ = new UsbServiceSubscriber();
|
||||
ErrCode ret = UsbdClient::BindUsbdSubscriber(usbdSubscriber_);
|
||||
ErrCode ret = UsbdClient::GetInstance().BindUsbdSubscriber(usbdSubscriber_);
|
||||
USB_HILOGE(MODULE_USB_SERVICE, " entry InitUsbd ret: %{public}d", ret);
|
||||
return SUCCEEDED(ret);
|
||||
}
|
||||
@@ -134,7 +132,7 @@ void UsbService::OnStop()
|
||||
eventRunner_.reset();
|
||||
handler_.reset();
|
||||
ready_ = false;
|
||||
UsbdClient::UnbindUsbdSubscriber();
|
||||
UsbdClient::GetInstance().UnbindUsbdSubscriber(usbdSubscriber_);
|
||||
}
|
||||
|
||||
bool UsbService::IsCommonEventServiceAbilityExist()
|
||||
@@ -159,7 +157,7 @@ int32_t UsbService::OpenDevice(uint8_t busNum, uint8_t devAddr)
|
||||
int32_t ret = UsbService::HasRight(name);
|
||||
if (UEC_OK == ret) {
|
||||
const UsbDev dev = {busNum, devAddr};
|
||||
ret = UsbdClient::OpenDevice(dev);
|
||||
ret = UsbdClient::GetInstance().OpenDevice(dev);
|
||||
if (UEC_OK != ret) {
|
||||
USB_HILOGE(MODULE_USB_SERVICE, "%{public}s:%{public}d OpenDevice failed ret:%{public}d", __func__, __LINE__,
|
||||
ret);
|
||||
@@ -215,13 +213,13 @@ int32_t UsbService::GetDevices(std::vector<UsbDevice> &deviceList)
|
||||
|
||||
int32_t UsbService::GetCurrentFunctions(int32_t &funcs)
|
||||
{
|
||||
return UsbdClient::GetCurrentFunctions(funcs);
|
||||
return UsbdClient::GetInstance().GetCurrentFunctions(funcs);
|
||||
}
|
||||
|
||||
int32_t UsbService::SetCurrentFunctions(int32_t funcs)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "func = %{public}d", funcs);
|
||||
return UsbdClient::SetCurrentFunctions(funcs);
|
||||
return UsbdClient::GetInstance().SetCurrentFunctions(funcs);
|
||||
}
|
||||
|
||||
int32_t UsbService::UsbFunctionsFromString(std::string funcs)
|
||||
@@ -251,46 +249,42 @@ int32_t UsbService::GetSupportedModes(int32_t portId, int32_t &supportedModes)
|
||||
int32_t UsbService::SetPortRole(int32_t portId, int32_t powerRole, int32_t dataRole)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "calling usbd getPorts");
|
||||
return UsbdClient::SetPortRole(portId, powerRole, dataRole);
|
||||
return UsbdClient::GetInstance().SetPortRole(portId, powerRole, dataRole);
|
||||
}
|
||||
|
||||
int32_t UsbService::ClaimInterface(uint8_t busNum, uint8_t devAddr, uint8_t interface)
|
||||
int32_t UsbService::ClaimInterface(uint8_t busNum, uint8_t devAddr, uint8_t interface, uint8_t force)
|
||||
{
|
||||
const UsbDev dev = {busNum, devAddr};
|
||||
return UsbdClient::ClaimInterface(dev, interface);
|
||||
return UsbdClient::GetInstance().ClaimInterface(dev, interface, force);
|
||||
}
|
||||
int32_t UsbService::ReleaseInterface(uint8_t busNum, uint8_t devAddr, uint8_t interface)
|
||||
{
|
||||
const UsbDev dev = {busNum, devAddr};
|
||||
return UsbdClient::ReleaseInterface(dev, interface);
|
||||
return UsbdClient::GetInstance().ReleaseInterface(dev, interface);
|
||||
}
|
||||
int32_t UsbService::BulkTransferRead(const UsbDev &devInfo,
|
||||
const UsbPipe &pipe,
|
||||
std::vector<uint8_t> &vdata,
|
||||
int32_t timeout)
|
||||
int32_t UsbService::BulkTransferRead(const UsbDev &devInfo, const UsbPipe &pipe, std::vector<uint8_t> &bufferData,
|
||||
int32_t timeOut)
|
||||
{
|
||||
int32_t ret = UsbdClient::BulkTransferRead(devInfo, pipe, timeout, vdata);
|
||||
int32_t ret = UsbdClient::GetInstance().BulkTransferRead(devInfo, pipe, timeOut, bufferData);
|
||||
if (UEC_OK != ret) {
|
||||
USB_HILOGE(MODULE_USB_SERVICE, "%{public}s:%{public}d BulkTransferRead error ret:%{public}d", __func__,
|
||||
__LINE__, ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
int32_t UsbService::BulkTransferWrite(const UsbDev &dev,
|
||||
const UsbPipe &pipe,
|
||||
const std::vector<uint8_t> &vdata,
|
||||
int32_t timeout)
|
||||
int32_t UsbService::BulkTransferWrite(const UsbDev &dev, const UsbPipe &pipe, const std::vector<uint8_t> &bufferData,
|
||||
int32_t timeOut)
|
||||
{
|
||||
int32_t ret = UsbdClient::BulkTransferWrite(dev, pipe, timeout, vdata);
|
||||
int32_t ret = UsbdClient::GetInstance().BulkTransferWrite(dev, pipe, timeOut, bufferData);
|
||||
if (UEC_OK != ret) {
|
||||
USB_HILOGE(MODULE_USB_SERVICE, "%{public}s:%{public}d BulkTransferWrite error ret:%{public}d", __func__,
|
||||
__LINE__, ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
int32_t UsbService::ControlTransfer(const UsbDev &dev, const UsbCtrlTransfer &ctrl, std::vector<uint8_t> &vdata)
|
||||
int32_t UsbService::ControlTransfer(const UsbDev &dev, const UsbCtrlTransfer &ctrl, std::vector<uint8_t> &bufferData)
|
||||
{
|
||||
int32_t ret = UsbdClient::ControlTransfer(dev, ctrl, vdata);
|
||||
int32_t ret = UsbdClient::GetInstance().ControlTransfer(dev, ctrl, bufferData);
|
||||
if (UEC_OK != ret) {
|
||||
USB_HILOGE(MODULE_USB_SERVICE, "%{public}s:%{public}d error ret:%{public}d", __func__, __LINE__, ret);
|
||||
}
|
||||
@@ -299,44 +293,50 @@ int32_t UsbService::ControlTransfer(const UsbDev &dev, const UsbCtrlTransfer &ct
|
||||
int32_t UsbService::SetActiveConfig(uint8_t busNum, uint8_t devAddr, uint8_t configIndex)
|
||||
{
|
||||
const UsbDev dev = {busNum, devAddr};
|
||||
return UsbdClient::SetConfig(dev, configIndex);
|
||||
return UsbdClient::GetInstance().SetConfig(dev, configIndex);
|
||||
}
|
||||
int32_t UsbService::GetActiveConfig(uint8_t busNum, uint8_t devAddr, uint8_t &configIndex)
|
||||
{
|
||||
const UsbDev dev = {busNum, devAddr};
|
||||
return UsbdClient::GetConfig(dev, configIndex);
|
||||
return UsbdClient::GetInstance().GetConfig(dev, configIndex);
|
||||
}
|
||||
int32_t UsbService::SetInterface(uint8_t busNum, uint8_t devAddr, uint8_t interfaceid, uint8_t altIndex)
|
||||
{
|
||||
const UsbDev dev = {busNum, devAddr};
|
||||
return UsbdClient::SetInterface(dev, interfaceid, altIndex);
|
||||
return UsbdClient::GetInstance().SetInterface(dev, interfaceid, altIndex);
|
||||
}
|
||||
int32_t UsbService::GetRawDescriptor(uint8_t busNum, uint8_t devAddr, std::vector<uint8_t> &vdata)
|
||||
int32_t UsbService::GetRawDescriptor(uint8_t busNum, uint8_t devAddr, std::vector<uint8_t> &bufferData)
|
||||
{
|
||||
const UsbDev dev = {busNum, devAddr};
|
||||
int32_t ret = UsbdClient::GetRawDescriptor(dev, vdata);
|
||||
int32_t ret = UsbdClient::GetInstance().GetRawDescriptor(dev, bufferData);
|
||||
if (UEC_OK != ret) {
|
||||
USB_HILOGE(MODULE_USB_SERVICE, "%{public}s:%{public}d error ret:%{public}d", __func__, __LINE__, ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
int32_t UsbService::RequestQueue(const UsbDev &dev,
|
||||
const UsbPipe &pipe,
|
||||
const std::vector<uint8_t> &cData,
|
||||
const std::vector<uint8_t> &vData)
|
||||
int32_t UsbService::GetFileDescriptor(uint8_t busNum, uint8_t devAddr, int32_t &fd)
|
||||
{
|
||||
int32_t ret = UsbdClient::RequestQueue(dev, pipe, cData, vData);
|
||||
const UsbDev dev = {busNum, devAddr};
|
||||
int32_t ret = UsbdClient::GetInstance().GetFileDescriptor(dev, fd);
|
||||
if (UEC_OK != ret) {
|
||||
USB_HILOGE(MODULE_USB_SERVICE, "%{public}s:%{public}d error ret:%{public}d", __func__, __LINE__, ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
int32_t UsbService::RequestWait(const UsbDev &dev,
|
||||
int32_t timeout,
|
||||
std::vector<uint8_t> &cData,
|
||||
std::vector<uint8_t> &vData)
|
||||
|
||||
int32_t UsbService::RequestQueue(const UsbDev &dev, const UsbPipe &pipe, const std::vector<uint8_t> &clientData,
|
||||
const std::vector<uint8_t> &bufferData)
|
||||
{
|
||||
int32_t ret = UsbdClient::RequestWait(dev, cData, vData, timeout);
|
||||
int32_t ret = UsbdClient::GetInstance().RequestQueue(dev, pipe, clientData, bufferData);
|
||||
if (UEC_OK != ret) {
|
||||
USB_HILOGE(MODULE_USB_SERVICE, "%{public}s:%{public}d error ret:%{public}d", __func__, __LINE__, ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
int32_t UsbService::RequestWait(const UsbDev &dev, int32_t timeOut, std::vector<uint8_t> &clientData,
|
||||
std::vector<uint8_t> &bufferData)
|
||||
{
|
||||
int32_t ret = UsbdClient::GetInstance().RequestWait(dev, clientData, bufferData, timeOut);
|
||||
if (UEC_OK != ret) {
|
||||
USB_HILOGE(MODULE_USB_SERVICE, "%{public}s:%{public}d error ret:%{public}d", __func__, __LINE__, ret);
|
||||
}
|
||||
@@ -347,13 +347,13 @@ int32_t UsbService::RequestCancel(uint8_t busNum, uint8_t devAddr, uint8_t inter
|
||||
{
|
||||
const UsbDev dev = {busNum, devAddr};
|
||||
const UsbPipe pipe = {interfaceId, endpointId};
|
||||
return UsbdClient::RequestCancel(dev, pipe);
|
||||
return UsbdClient::GetInstance().RequestCancel(dev, pipe);
|
||||
}
|
||||
|
||||
int32_t UsbService::Close(uint8_t busNum, uint8_t devAddr)
|
||||
{
|
||||
const UsbDev dev = {busNum, devAddr};
|
||||
return UsbdClient::CloseDevice(dev);
|
||||
return UsbdClient::GetInstance().CloseDevice(dev);
|
||||
}
|
||||
|
||||
static std::string GetDevStringValFromIdx(uint8_t busNum, uint8_t devAddr, uint8_t idx)
|
||||
@@ -362,20 +362,19 @@ static std::string GetDevStringValFromIdx(uint8_t busNum, uint8_t devAddr, uint8
|
||||
std::vector<uint8_t> strV;
|
||||
std::string string = " ";
|
||||
|
||||
USB_HILOGW(MODULE_USB_SERVICE, "%{public}s:%{public}d getString idx:%{public}d", __func__, __LINE__, idx);
|
||||
if (idx == 0) {
|
||||
return string;
|
||||
}
|
||||
|
||||
int32_t ret = UsbdClient::GetStringDescriptor(dev, idx, strV);
|
||||
int32_t ret = UsbdClient::GetInstance().GetStringDescriptor(dev, idx, strV);
|
||||
if (ret != UEC_OK) {
|
||||
USB_HILOGW(MODULE_USB_SERVICE, "%{public}s:%{public}d get string[%{public}d] failed ret:%{public}d", __func__,
|
||||
USB_HILOGE(MODULE_USB_SERVICE, "%{public}s:%{public}d get string[%{public}d] failed ret:%{public}d", __func__,
|
||||
__LINE__, idx, ret);
|
||||
return string;
|
||||
}
|
||||
uint32_t length = strV.size();
|
||||
if ((length < DESCRIPTOR_VALUE_START_OFFSET) || (strV[1] != DESCRIPTOR_TYPE_STRING)) {
|
||||
USB_HILOGW(MODULE_USB_SERVICE, "%{public}s:%{public}d type or length error, len:%{public}d", __func__, __LINE__,
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "%{public}s:%{public}d type or length error, len:%{public}d", __func__, __LINE__,
|
||||
length);
|
||||
return string;
|
||||
}
|
||||
@@ -385,7 +384,7 @@ static std::string GetDevStringValFromIdx(uint8_t busNum, uint8_t devAddr, uint8
|
||||
}
|
||||
std::wstring wstr((wchar_t *)(tbuf), (length - DESCRIPTOR_VALUE_START_OFFSET) / HALF);
|
||||
string = std::string(wstr.begin(), wstr.end());
|
||||
USB_HILOGW(MODULE_USB_SERVICE, "%{public}s:%{public}d getString idx:%{public}d String:%{public}s length:%{public}d",
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "%{public}s:%{public}d getString idx:%{public}d String:%{public}s length:%{public}d",
|
||||
__func__, __LINE__, idx, string.c_str(), length);
|
||||
delete[] tbuf;
|
||||
return string;
|
||||
@@ -415,7 +414,7 @@ static int32_t FillDevStrings(UsbDevice &dev)
|
||||
dev.SetManufacturerName(GetDevStringValFromIdx(busNum, devAddr, dev.GetiManufacturer()));
|
||||
dev.SetProductName(GetDevStringValFromIdx(busNum, devAddr, dev.GetiProduct()));
|
||||
dev.SetmSerial(GetDevStringValFromIdx(busNum, devAddr, dev.GetiSerialNumber()));
|
||||
USB_HILOGW(MODULE_USB_SERVICE,
|
||||
USB_HILOGI(MODULE_USB_SERVICE,
|
||||
"%{public}s:%{public}d iSerial:%{public}d mSerial:%{public}s Manufactur:%{public}s product:%{public}s "
|
||||
"version:%{public}s",
|
||||
__func__, __LINE__, dev.GetiSerialNumber(), dev.GetmSerial().c_str(), dev.GetManufacturerName().c_str(),
|
||||
@@ -425,12 +424,12 @@ static int32_t FillDevStrings(UsbDevice &dev)
|
||||
configs = dev.GetConfigs();
|
||||
for (auto it = configs.begin(); it != configs.end(); ++it) {
|
||||
it->SetName(GetDevStringValFromIdx(busNum, devAddr, it->GetiConfiguration()));
|
||||
USB_HILOGW(MODULE_USB_SERVICE, "%{public}s:%{public}d Config:%{public}d %{public}s", __func__, __LINE__,
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "%{public}s:%{public}d Config:%{public}d %{public}s", __func__, __LINE__,
|
||||
it->GetiConfiguration(), it->GetName().c_str());
|
||||
std::vector<UsbInterface> interfaces = it->GetInterfaces();
|
||||
for (auto itIF = interfaces.begin(); itIF != interfaces.end(); ++itIF) {
|
||||
itIF->SetName(GetDevStringValFromIdx(busNum, devAddr, itIF->GetiInterface()));
|
||||
USB_HILOGW(MODULE_USB_SERVICE, "%{public}s:%{public}d interface:%{public}d %{public}s", __func__, __LINE__,
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "%{public}s:%{public}d interface:%{public}d %{public}s", __func__, __LINE__,
|
||||
itIF->GetiInterface(), itIF->GetName().c_str());
|
||||
}
|
||||
it->SetInterfaces(interfaces);
|
||||
@@ -440,78 +439,63 @@ static int32_t FillDevStrings(UsbDevice &dev)
|
||||
return UEC_OK;
|
||||
}
|
||||
|
||||
int32_t UsbService::GetDeviceInfoDescriptor(const UsbDev &uDev,
|
||||
std::vector<uint8_t> &decriptor,
|
||||
uint32_t &length,
|
||||
UsbDevice &dev)
|
||||
int32_t UsbService::GetDeviceInfoDescriptor(const UsbDev &uDev, std::vector<uint8_t> &decriptor, UsbDevice &dev)
|
||||
{
|
||||
uint8_t *buffer = NULL;
|
||||
int32_t ret = UsbdClient::GetDeviceDescriptor(uDev, decriptor);
|
||||
int32_t ret = UsbdClient::GetInstance().GetRawDescriptor(uDev, decriptor);
|
||||
if (ret != UEC_OK) {
|
||||
UsbdClient::CloseDevice(uDev);
|
||||
UsbdClient::GetInstance().CloseDevice(uDev);
|
||||
USB_HILOGE(MODULE_USB_SERVICE,
|
||||
"%{public}s:%{public}d UsbdClient::GetDeviceDescriptor failed ret=%{public}d busNum:%{public}d "
|
||||
"%{public}s:%{public}d GetRawDescriptor failed ret=%{public}d busNum:%{public}d "
|
||||
"devAddr:%{public}d",
|
||||
__func__, __LINE__, ret, uDev.busNum, uDev.devAddr);
|
||||
return ret;
|
||||
}
|
||||
buffer = decriptor.data();
|
||||
length = decriptor.size();
|
||||
uint8_t *buffer = decriptor.data();
|
||||
uint32_t length = decriptor.size();
|
||||
if ((!buffer) || (length == 0)) {
|
||||
USB_HILOGE(MODULE_USB_SERVICE,
|
||||
"%{public}s:%{public}d UsbdClient::GetDeviceDescriptor failed len=%{public}d busNum:%{public}d "
|
||||
"%{public}s:%{public}d GetRawDescriptor failed len=%{public}d busNum:%{public}d "
|
||||
"devAddr:%{public}d",
|
||||
__func__, __LINE__, length, uDev.busNum, uDev.devAddr);
|
||||
return UEC_SERVICE_INVALID_VALUE;
|
||||
}
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "%{public}s:%{public}d GetDeviceDescriptor ret=%{public}d len:%{public}d", __func__,
|
||||
__LINE__, ret, length);
|
||||
dev.SetBusNum(uDev.busNum);
|
||||
dev.SetDevAddr(uDev.devAddr);
|
||||
dev.SetName(std::to_string(uDev.busNum) + "-" + std::to_string(uDev.devAddr));
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "%{public}s GetDeviceDescriptor length=%{public}d", __func__, length);
|
||||
|
||||
ret = UsbDescriptorParser::ParseDeviceDescriptor(buffer, length, dev);
|
||||
if (ret != UEC_OK) {
|
||||
UsbdClient::CloseDevice(uDev);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "%{public}s ParseDeviceDescriptor failed ret=%{public}d", __func__, ret);
|
||||
UsbdClient::GetInstance().CloseDevice(uDev);
|
||||
USB_HILOGE(MODULE_USB_SERVICE, "%{public}s ParseDeviceDescriptor failed ret=%{public}d", __func__, ret);
|
||||
return ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t UsbService::GetConfigDescriptor(const UsbDev &uDev,
|
||||
std::vector<uint8_t> &decriptor,
|
||||
std::vector<USBConfig> &configs,
|
||||
UsbDevice &dev)
|
||||
int32_t UsbService::GetConfigDescriptor(UsbDevice &dev, std::vector<uint8_t> &decriptor)
|
||||
{
|
||||
uint8_t *buffer = NULL;
|
||||
std::vector<USBConfig> configs;
|
||||
uint8_t *buffer = decriptor.data();
|
||||
uint32_t length = decriptor.size();
|
||||
uint32_t cursor = CURSOR_INIT;
|
||||
int32_t ret = UEC_OK;
|
||||
for (uint8_t i = 0; i < dev.GetDescConfigCount(); ++i) {
|
||||
uint32_t cursor = 0;
|
||||
decriptor.clear();
|
||||
ret = UsbdClient::GetConfigDescriptor(uDev, i, decriptor);
|
||||
if (ret != UEC_OK) {
|
||||
UsbdClient::CloseDevice(uDev);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "%{public}s UsbdClient::GetConfigDescriptor failed ret=%{public}d", __func__,
|
||||
ret);
|
||||
return ret;
|
||||
}
|
||||
uint32_t length = decriptor.size();
|
||||
buffer = decriptor.data();
|
||||
if (length == 0) {
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "%{public}s:%{public}d GetConfigDescriptor[%{public}d] length=%{public}d",
|
||||
if (length <= cursor) {
|
||||
USB_HILOGE(MODULE_USB_SERVICE, "%{public}s:%{public}d GetConfigDescriptor[%{public}d] length=%{public}d",
|
||||
__func__, __LINE__, i, length);
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "%{public}s GetConfigDescriptor length=%{public}d", __func__, length);
|
||||
uint32_t configCursor = 0;
|
||||
USBConfig config;
|
||||
ret = UsbDescriptorParser::ParseConfigDescriptor(buffer + cursor, length - cursor, configCursor, config);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "%{public}s ParseConfigDescriptor[%{public}d] ret:%{public}d", __func__, i, ret);
|
||||
cursor += configCursor;
|
||||
configs.push_back(config);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "%{public}s Descriptor=%{public}s", __func__, config.ToString().c_str());
|
||||
}
|
||||
dev.SetConfigs(configs);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "%{public}s:%{public}d SetConfigs ret=%{public}d", __func__, __LINE__, ret);
|
||||
ret = FillDevStrings(dev);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "%{public}s:%{public}d FillDevStrings ret=%{public}d", __func__, __LINE__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -521,44 +505,33 @@ int32_t UsbService::GetDeviceInfo(uint8_t busNum, uint8_t devAddr, UsbDevice &de
|
||||
busNum, devAddr);
|
||||
const UsbDev uDev = {busNum, devAddr};
|
||||
std::vector<uint8_t> decriptor;
|
||||
uint32_t length = USB_MAX_DESCRIPTOR_SIZE;
|
||||
|
||||
int32_t ret = UsbdClient::OpenDevice(uDev);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "%{public}s:%{public}d UsbdClient::OpenDevice ret=%{public}d", __func__, __LINE__,
|
||||
ret);
|
||||
int32_t ret = UsbdClient::GetInstance().OpenDevice(uDev);
|
||||
if (ret != UEC_OK) {
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "%{public}s UsbdClient::OpenDevice failed ret=%{public}d", __func__, ret);
|
||||
USB_HILOGE(MODULE_USB_SERVICE, "%{public}s OpenDevice failed ret=%{public}d", __func__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = GetDeviceInfoDescriptor(uDev, decriptor, length, dev);
|
||||
ret = GetDeviceInfoDescriptor(uDev, decriptor, dev);
|
||||
if (ret != UEC_OK) {
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "%{public}s UsbdClient::GetDeviceInfoDescriptor failed ret=%{public}d", __func__,
|
||||
USB_HILOGE(MODULE_USB_SERVICE, "%{public}s:%{public}d GetDeviceInfoDescriptor ret=%{public}d", __func__,
|
||||
__LINE__, ret);
|
||||
}
|
||||
ret = GetConfigDescriptor(dev, decriptor);
|
||||
if (ret != UEC_OK) {
|
||||
USB_HILOGE(MODULE_USB_SERVICE, "%{public}s:%{public}d GetConfigDescriptor ret=%{public}d", __func__, __LINE__,
|
||||
ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::vector<USBConfig> configs;
|
||||
ret = GetConfigDescriptor(uDev, decriptor, configs, dev);
|
||||
if (ret != UEC_OK) {
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "%{public}s UsbdClient::GetConfigDescriptor failed ret=%{public}d", __func__,
|
||||
ret);
|
||||
return ret;
|
||||
}
|
||||
dev.SetConfigs(configs);
|
||||
ret = FillDevStrings(dev);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "%{public}s:%{public}d FillDevStrings ret=%{public}d", __func__, __LINE__, ret);
|
||||
|
||||
UsbdClient::CloseDevice(uDev);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "%{public}s Descriptor=%{public}s", __func__, dev.ToString().c_str());
|
||||
UsbdClient::GetInstance().CloseDevice(uDev);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "%{public}s CloseDevice=%{public}s", __func__, dev.ToString().c_str());
|
||||
|
||||
return UEC_OK;
|
||||
}
|
||||
|
||||
bool UsbService::AddDevice(uint8_t busNum, uint8_t devAddr)
|
||||
{
|
||||
USB_HILOGW(MODULE_USBD, "%{public}s:%{public}d busNum:%{public}d devAddr:%{public}d", __func__, __LINE__, busNum,
|
||||
devAddr);
|
||||
UsbDevice *devInfo = new UsbDevice();
|
||||
memset_s(devInfo, sizeof(UsbDevice), 0, sizeof(UsbDevice));
|
||||
int32_t ret = GetDeviceInfo(busNum, devAddr, *devInfo);
|
||||
@@ -572,10 +545,10 @@ bool UsbService::AddDevice(uint8_t busNum, uint8_t devAddr)
|
||||
}
|
||||
bool UsbService::DelDevice(uint8_t busNum, uint8_t devAddr)
|
||||
{
|
||||
USB_HILOGW(MODULE_USBD, "%{public}s:%{public}d entry", __func__, __LINE__);
|
||||
USB_HILOGI(MODULE_USBD, "%{public}s:%{public}d entry", __func__, __LINE__);
|
||||
int32_t ret = Close(busNum, devAddr);
|
||||
if (ret != UEC_OK) {
|
||||
USB_HILOGW(MODULE_USBD, "%{public}s:%{public}d Close device failed width ret = %{public}d", __func__, __LINE__,
|
||||
USB_HILOGE(MODULE_USBD, "%{public}s:%{public}d Close device failed width ret = %{public}d", __func__, __LINE__,
|
||||
ret);
|
||||
}
|
||||
return usbHostManger_->DelDevice(busNum, devAddr);
|
||||
@@ -610,5 +583,53 @@ bool UsbService::GetBundleName(std::string &bundleName)
|
||||
bundleMgr->GetBundleNameForUid(uid, bundleName);
|
||||
return true;
|
||||
}
|
||||
|
||||
int32_t UsbService::RegBulkCallback(const UsbDev &devInfo, const UsbPipe &pipe, const sptr<IRemoteObject> &cb)
|
||||
{
|
||||
int32_t ret = UsbdClient::GetInstance().RegBulkCallback(devInfo, pipe, cb);
|
||||
if (UEC_OK != ret) {
|
||||
USB_HILOGE(MODULE_USB_SERVICE, "%{public}s:%{public}d RegBulkCallback error ret:%{public}d", __func__, __LINE__,
|
||||
ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t UsbService::UnRegBulkCallback(const UsbDev &devInfo, const UsbPipe &pipe)
|
||||
{
|
||||
int32_t ret = UsbdClient::GetInstance().UnRegBulkCallback(devInfo, pipe);
|
||||
if (UEC_OK != ret) {
|
||||
USB_HILOGE(MODULE_USB_SERVICE, "%{public}s:%{public}d UnRegBulkCallback error ret:%{public}d", __func__,
|
||||
__LINE__, ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t UsbService::BulkRead(const UsbDev &devInfo, const UsbPipe &pipe, sptr<Ashmem> &ashmem)
|
||||
{
|
||||
int32_t ret = UsbdClient::GetInstance().BulkRead(devInfo, pipe, ashmem);
|
||||
if (UEC_OK != ret) {
|
||||
USB_HILOGE(MODULE_USB_SERVICE, "%{public}s:%{public}d BulkRead error ret:%{public}d", __func__, __LINE__, ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t UsbService::BulkWrite(const UsbDev &devInfo, const UsbPipe &pipe, sptr<Ashmem> &ashmem)
|
||||
{
|
||||
int32_t ret = UsbdClient::GetInstance().BulkWrite(devInfo, pipe, ashmem);
|
||||
if (UEC_OK != ret) {
|
||||
USB_HILOGE(MODULE_USB_SERVICE, "%{public}s:%{public}d BulkWrite error ret:%{public}d", __func__, __LINE__, ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t UsbService::BulkCancel(const UsbDev &devInfo, const UsbPipe &pipe)
|
||||
{
|
||||
int32_t ret = UsbdClient::GetInstance().BulkCancel(devInfo, pipe);
|
||||
if (UEC_OK != ret) {
|
||||
USB_HILOGE(MODULE_USB_SERVICE, "%{public}s:%{public}d BulkCancel error ret:%{public}d", __func__, __LINE__,
|
||||
ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
} // namespace USB
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -54,7 +54,7 @@ int32_t UsbServiceSubscriber::PortChangedEvent(int32_t portId, int32_t powerRole
|
||||
|
||||
int32_t Invoking(const UsbInfo &info, Want &want)
|
||||
{
|
||||
int ret = 0;
|
||||
int32_t ret = 0;
|
||||
switch (info.getDevInfoStatus()) {
|
||||
case ACT_DEVUP:
|
||||
want.SetAction(CommonEventSupport::COMMON_EVENT_USB_DEVICE_ATTACHED);
|
||||
@@ -79,7 +79,7 @@ int32_t UsbServiceSubscriber::DeviceEvent(const UsbInfo &info)
|
||||
{
|
||||
struct timeval start;
|
||||
gettimeofday(&start, NULL);
|
||||
int status = info.getDevInfoStatus();
|
||||
int32_t status = info.getDevInfoStatus();
|
||||
int32_t ret = UEC_OK;
|
||||
Want want;
|
||||
USB_HILOGW(MODULE_USBD, "%{public}s:%{public}d status:%{public}d bus:%{public}d dev:%{public}d", __func__, __LINE__,
|
||||
@@ -106,8 +106,8 @@ int32_t UsbServiceSubscriber::DeviceEvent(const UsbInfo &info)
|
||||
if ((ACT_UPDEVICE == status) || (ACT_DOWNDEVICE == status)) {
|
||||
return ret;
|
||||
}
|
||||
int busNum = info.getDevInfoBusNum();
|
||||
int devAddr = info.getDevInfoDevNum();
|
||||
int32_t busNum = info.getDevInfoBusNum();
|
||||
int32_t devAddr = info.getDevInfoDevNum();
|
||||
USB_HILOGW(MODULE_USBD, "%{public}s:%{public}d status:%{public}d bus:%{public}d dev:%{public}d", __func__, __LINE__,
|
||||
status, busNum, devAddr);
|
||||
auto pms = DelayedSpSingleton<UsbService>::GetInstance();
|
||||
|
||||
@@ -44,37 +44,39 @@ public:
|
||||
virtual int32_t GetSupportedModes(int32_t portId, int32_t &supportedModes) override;
|
||||
virtual int32_t SetPortRole(int32_t portId, int32_t powerRole, int32_t dataRole) override;
|
||||
|
||||
virtual int32_t ClaimInterface(uint8_t busNum, uint8_t devAddr, uint8_t interfaceid) override;
|
||||
virtual int32_t ClaimInterface(uint8_t busNum, uint8_t devAddr, uint8_t interfaceid, uint8_t force) override;
|
||||
virtual int32_t ReleaseInterface(uint8_t busNum, uint8_t devAddr, uint8_t interfaceid) override;
|
||||
virtual int32_t
|
||||
BulkTransferRead(const UsbDev &dev, const UsbPipe &pipe, std::vector<uint8_t> &vdata, int32_t timeout) override;
|
||||
virtual int32_t BulkTransferWrite(const UsbDev &dev,
|
||||
const UsbPipe &pipe,
|
||||
const std::vector<uint8_t> &vdata,
|
||||
int32_t timeout) override;
|
||||
virtual int32_t
|
||||
ControlTransfer(const UsbDev &dev, const UsbCtrlTransfer &ctrl, std::vector<uint8_t> &vdata) override;
|
||||
virtual int32_t BulkTransferRead(const UsbDev &dev, const UsbPipe &pipe, std::vector<uint8_t> &bufferData,
|
||||
int32_t timeOut) override;
|
||||
virtual int32_t BulkTransferWrite(const UsbDev &dev, const UsbPipe &pipe, const std::vector<uint8_t> &bufferData,
|
||||
int32_t timeOut) override;
|
||||
|
||||
virtual int32_t ControlTransfer(const UsbDev &dev, const UsbCtrlTransfer &ctrl,
|
||||
std::vector<uint8_t> &bufferData) override;
|
||||
virtual int32_t SetActiveConfig(uint8_t busNum, uint8_t devAddr, uint8_t configIndex) override;
|
||||
virtual int32_t GetActiveConfig(uint8_t busNum, uint8_t devAddr, uint8_t &configIndex) override;
|
||||
virtual int32_t SetInterface(uint8_t busNum, uint8_t devAddr, uint8_t interfaceid, uint8_t altIndex) override;
|
||||
virtual int32_t GetRawDescriptor(uint8_t busNum, uint8_t devAddr, std::vector<uint8_t> &vdata) override;
|
||||
virtual int32_t RequestQueue(const UsbDev &dev,
|
||||
const UsbPipe &pipe,
|
||||
const std::vector<uint8_t> &cData,
|
||||
const std::vector<uint8_t> &vData) override;
|
||||
virtual int32_t RequestWait(const UsbDev &dev,
|
||||
int32_t timeout,
|
||||
std::vector<uint8_t> &cData,
|
||||
std::vector<uint8_t> &vData) override;
|
||||
virtual int32_t GetRawDescriptor(uint8_t busNum, uint8_t devAddr, std::vector<uint8_t> &bufferData) override;
|
||||
virtual int32_t GetFileDescriptor(uint8_t busNum, uint8_t devAddr, int32_t &fd) override;
|
||||
virtual int32_t RequestQueue(const UsbDev &dev, const UsbPipe &pipe, const std::vector<uint8_t> &clientData,
|
||||
const std::vector<uint8_t> &bufferData) override;
|
||||
virtual int32_t RequestWait(const UsbDev &dev, int32_t timeOut, std::vector<uint8_t> &clientData,
|
||||
std::vector<uint8_t> &bufferData) override;
|
||||
virtual int32_t RequestCancel(uint8_t busNum, uint8_t devAddr, uint8_t interfaceid, uint8_t endpointId) override;
|
||||
virtual int32_t Close(uint8_t busNum, uint8_t devAddr) override;
|
||||
|
||||
virtual int32_t RegBulkCallback(const UsbDev &dev, const UsbPipe &pipe, const sptr<IRemoteObject> &cb) override;
|
||||
virtual int32_t UnRegBulkCallback(const UsbDev &dev, const UsbPipe &pipe) override;
|
||||
virtual int32_t BulkRead(const UsbDev &dev, const UsbPipe &pipe, sptr<Ashmem> &ashmem) override;
|
||||
virtual int32_t BulkWrite(const UsbDev &dev, const UsbPipe &pipe, sptr<Ashmem> &ashmem) override;
|
||||
virtual int32_t BulkCancel(const UsbDev &dev, const UsbPipe &pipe) override;
|
||||
|
||||
private:
|
||||
static inline BrokerDelegator<UsbServerProxy> delegator_;
|
||||
int32_t ParseUsbPort(MessageParcel &reply, std::vector<UsbPort> &result);
|
||||
int32_t SetDeviceMessage(MessageParcel &data, uint8_t busNum, uint8_t devAddr);
|
||||
int32_t SetBufferMessage(MessageParcel &data, const std::vector<uint8_t> &vData);
|
||||
int32_t GetBufferMessage(MessageParcel &data, std::vector<uint8_t> &vData);
|
||||
int32_t SetBufferMessage(MessageParcel &data, const std::vector<uint8_t> &bufferData);
|
||||
int32_t GetBufferMessage(MessageParcel &data, std::vector<uint8_t> &bufferData);
|
||||
int32_t GetDeviceListMessageParcel(MessageParcel &data, std::vector<UsbDevice> &deviceList);
|
||||
int32_t GetDeviceMessageParcel(MessageParcel &data, UsbDevice &devInfo);
|
||||
int32_t GetDeviceConfigsMessageParcel(MessageParcel &data, std::vector<USBConfig> &configs);
|
||||
|
||||
@@ -31,7 +31,7 @@ public:
|
||||
UsbServerStub() = default;
|
||||
virtual ~UsbServerStub() = default;
|
||||
|
||||
int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
|
||||
int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
|
||||
|
||||
private:
|
||||
bool StubHost(uint32_t code, int32_t &result, MessageParcel &data, MessageParcel &reply, MessageOption &option);
|
||||
@@ -58,6 +58,7 @@ private:
|
||||
int32_t DoGetActiveConfig(MessageParcel &data, MessageParcel &reply, MessageOption &option);
|
||||
int32_t DoSetInterface(MessageParcel &data, MessageParcel &reply, MessageOption &option);
|
||||
int32_t DoGetRawDescriptor(MessageParcel &data, MessageParcel &reply, MessageOption &option);
|
||||
int32_t DoGetFileDescriptor(MessageParcel &data, MessageParcel &reply, MessageOption &option);
|
||||
int32_t DoRequestQueue(MessageParcel &data, MessageParcel &reply, MessageOption &option);
|
||||
int32_t DoRequestWait(MessageParcel &data, MessageParcel &reply, MessageOption &option);
|
||||
int32_t DoRequestCancel(MessageParcel &data, MessageParcel &reply, MessageOption &option);
|
||||
@@ -68,13 +69,19 @@ private:
|
||||
int32_t WriteUsbPort(MessageParcel &reply, const UsbPort &port);
|
||||
|
||||
int32_t GetDeviceMessage(MessageParcel &data, uint8_t &busNum, uint8_t &devAddr);
|
||||
int32_t SetBufferMessage(MessageParcel &data, const std::vector<uint8_t> &vData);
|
||||
int32_t GetBufferMessage(MessageParcel &data, std::vector<uint8_t> &vData);
|
||||
int32_t SetBufferMessage(MessageParcel &data, const std::vector<uint8_t> &bufferData);
|
||||
int32_t GetBufferMessage(MessageParcel &data, std::vector<uint8_t> &bufferData);
|
||||
int32_t SetDeviceListMessageParcel(std::vector<UsbDevice> &deviceList, MessageParcel &data);
|
||||
int32_t SetDeviceMessageParcel(UsbDevice &devInfo, MessageParcel &data);
|
||||
int32_t SetDeviceConfigsMessageParcel(std::vector<USBConfig> &configs, MessageParcel &data);
|
||||
int32_t SetDeviceInterfacesMessageParcel(std::vector<UsbInterface> &interfaces, MessageParcel &data);
|
||||
int32_t SetDeviceEndpointsMessageParcel(std::vector<USBEndpoint> &eps, MessageParcel &data);
|
||||
|
||||
int32_t DoRegBulkCallback(MessageParcel &data, MessageParcel &reply, MessageOption &option);
|
||||
int32_t DoUnRegBulkCallback(MessageParcel &data, MessageParcel &reply, MessageOption &option);
|
||||
int32_t DoBulkRead(MessageParcel &data, MessageParcel &reply, MessageOption &option);
|
||||
int32_t DoBulkWrite(MessageParcel &data, MessageParcel &reply, MessageOption &option);
|
||||
int32_t DoBulkCancel(MessageParcel &data, MessageParcel &reply, MessageOption &option);
|
||||
};
|
||||
} // namespace USB
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -32,10 +32,10 @@ int32_t UsbServerProxy::SetDeviceMessage(MessageParcel &data, uint8_t busNum, ui
|
||||
return UEC_OK;
|
||||
}
|
||||
|
||||
int32_t UsbServerProxy::SetBufferMessage(MessageParcel &data, const std::vector<uint8_t> &vdata)
|
||||
int32_t UsbServerProxy::SetBufferMessage(MessageParcel &data, const std::vector<uint8_t> &bufferData)
|
||||
{
|
||||
uint32_t length = vdata.size();
|
||||
const uint8_t *ptr = vdata.data();
|
||||
uint32_t length = bufferData.size();
|
||||
const uint8_t *ptr = bufferData.data();
|
||||
if (!ptr) {
|
||||
length = 0;
|
||||
}
|
||||
@@ -54,26 +54,26 @@ int32_t UsbServerProxy::SetBufferMessage(MessageParcel &data, const std::vector<
|
||||
return UEC_OK;
|
||||
}
|
||||
|
||||
int32_t UsbServerProxy::GetBufferMessage(MessageParcel &data, std::vector<uint8_t> &vdata)
|
||||
int32_t UsbServerProxy::GetBufferMessage(MessageParcel &data, std::vector<uint8_t> &bufferData)
|
||||
{
|
||||
uint32_t dataSize = 0;
|
||||
vdata.clear();
|
||||
bufferData.clear();
|
||||
if (!data.ReadUint32(dataSize)) {
|
||||
USB_HILOGE(MODULE_USBD, "%{public}s:%{public}d failed", __func__, __LINE__);
|
||||
return UEC_SERVICE_READ_PARCEL_ERROR;
|
||||
}
|
||||
if (dataSize == 0) {
|
||||
USB_HILOGW(MODULE_USBD, "%{public}s:%{public}d size:%{public}d", __func__, __LINE__, dataSize);
|
||||
USB_HILOGI(MODULE_USBD, "%{public}s:%{public}d size:%{public}d", __func__, __LINE__, dataSize);
|
||||
return UEC_OK;
|
||||
}
|
||||
|
||||
const uint8_t *readData = data.ReadUnpadBuffer(dataSize);
|
||||
if (readData == nullptr) {
|
||||
USB_HILOGW(MODULE_USBD, "%{public}s:%{public}d failed size:%{public}d", __func__, __LINE__, dataSize);
|
||||
USB_HILOGE(MODULE_USBD, "%{public}s:%{public}d failed size:%{public}d", __func__, __LINE__, dataSize);
|
||||
return UEC_SERVICE_READ_PARCEL_ERROR;
|
||||
}
|
||||
std::vector<uint8_t> tdata(readData, readData + dataSize);
|
||||
vdata.swap(tdata);
|
||||
bufferData.swap(tdata);
|
||||
return UEC_OK;
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ int32_t UsbServerProxy::GetDeviceConfigsMessageParcel(MessageParcel &data, std::
|
||||
std::string tstr;
|
||||
data.ReadInt32(tmp);
|
||||
configCount = tmp;
|
||||
for (int i = 0; i < configCount; ++i) {
|
||||
for (int32_t i = 0; i < configCount; ++i) {
|
||||
USBConfig config;
|
||||
data.ReadInt32(tmp);
|
||||
config.SetId(tmp);
|
||||
@@ -208,7 +208,7 @@ int32_t UsbServerProxy::GetDeviceInterfacesMessageParcel(MessageParcel &data, st
|
||||
std::string tstr;
|
||||
data.ReadInt32(tmp);
|
||||
interfaceCount = tmp;
|
||||
for (int i = 0; i < interfaceCount; ++i) {
|
||||
for (int32_t i = 0; i < interfaceCount; ++i) {
|
||||
UsbInterface interface;
|
||||
data.ReadInt32(tmp);
|
||||
interface.SetId(tmp);
|
||||
@@ -243,7 +243,7 @@ int32_t UsbServerProxy::GetDeviceEndpointsMessageParcel(MessageParcel &data, std
|
||||
int32_t tmp, epCount;
|
||||
data.ReadInt32(tmp);
|
||||
epCount = tmp;
|
||||
for (int i = 0; i < epCount; ++i) {
|
||||
for (int32_t i = 0; i < epCount; ++i) {
|
||||
USBEndpoint ep;
|
||||
data.ReadInt32(tmp);
|
||||
ep.SetAddr(tmp);
|
||||
@@ -534,7 +534,7 @@ int32_t UsbServerProxy::SetPortRole(int32_t portId, int32_t powerRole, int32_t d
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t UsbServerProxy::ClaimInterface(uint8_t busNum, uint8_t devAddr, uint8_t interface)
|
||||
int32_t UsbServerProxy::ClaimInterface(uint8_t busNum, uint8_t devAddr, uint8_t interface, uint8_t force)
|
||||
{
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
RETURN_IF_WITH_RET(remote == nullptr, UEC_SERVICE_INNER_ERR);
|
||||
@@ -547,6 +547,7 @@ int32_t UsbServerProxy::ClaimInterface(uint8_t busNum, uint8_t devAddr, uint8_t
|
||||
}
|
||||
SetDeviceMessage(data, busNum, devAddr);
|
||||
WRITE_PARCEL_WITH_RET(data, Uint8, interface, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
WRITE_PARCEL_WITH_RET(data, Uint8, force, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
int32_t ret = remote->SendRequest(static_cast<int32_t>(IUsbSrv::USB_FUN_CLAIM_INTERFACE), data, reply, option);
|
||||
if (ret != UEC_OK) {
|
||||
USB_HILOGE(MODULE_USB_INNERKIT, "UsbServerProxy::%{public}s SendRequest is failed, error code: %{public}d",
|
||||
@@ -555,6 +556,7 @@ int32_t UsbServerProxy::ClaimInterface(uint8_t busNum, uint8_t devAddr, uint8_t
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t UsbServerProxy::ReleaseInterface(uint8_t busNum, uint8_t devAddr, uint8_t interface)
|
||||
{
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
@@ -575,10 +577,8 @@ int32_t UsbServerProxy::ReleaseInterface(uint8_t busNum, uint8_t devAddr, uint8_
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
int32_t UsbServerProxy::BulkTransferRead(const UsbDev &dev,
|
||||
const UsbPipe &pipe,
|
||||
std::vector<uint8_t> &vdata,
|
||||
int32_t timeout)
|
||||
int32_t UsbServerProxy::BulkTransferRead(const UsbDev &dev, const UsbPipe &pipe, std::vector<uint8_t> &bufferData,
|
||||
int32_t timeOut)
|
||||
{
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
RETURN_IF_WITH_RET(remote == nullptr, UEC_SERVICE_INNER_ERR);
|
||||
@@ -592,26 +592,24 @@ int32_t UsbServerProxy::BulkTransferRead(const UsbDev &dev,
|
||||
SetDeviceMessage(data, dev.busNum, dev.devAddr);
|
||||
WRITE_PARCEL_WITH_RET(data, Uint8, pipe.interfaceId, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
WRITE_PARCEL_WITH_RET(data, Uint8, pipe.endpointId, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
WRITE_PARCEL_WITH_RET(data, Int32, timeout, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
WRITE_PARCEL_WITH_RET(data, Int32, timeOut, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
int32_t ret = remote->SendRequest(static_cast<int32_t>(IUsbSrv::USB_FUN_BULK_TRANSFER_READ), data, reply, option);
|
||||
if (ret != UEC_OK) {
|
||||
USB_HILOGE(MODULE_USB_INNERKIT, "UsbServerProxy::%{public}s SendRequest is failed, error code: %d", __func__,
|
||||
ret);
|
||||
return ret;
|
||||
}
|
||||
ret = GetBufferMessage(reply, vdata);
|
||||
ret = GetBufferMessage(reply, bufferData);
|
||||
if (ret != UEC_OK) {
|
||||
USB_HILOGE(MODULE_USB_INNERKIT, "UsbServerProxy::%{public}s get buffer is failed, error code: %d", __func__,
|
||||
ret);
|
||||
return ret;
|
||||
}
|
||||
USB_HILOGW(MODULE_USBD, "%{public}s Set buffer message. length = %{public}d", __func__, vdata.size());
|
||||
USB_HILOGI(MODULE_USBD, "%{public}s Set buffer message. length = %{public}d", __func__, bufferData.size());
|
||||
return ret;
|
||||
}
|
||||
int32_t UsbServerProxy::BulkTransferWrite(const UsbDev &dev,
|
||||
const UsbPipe &pipe,
|
||||
const std::vector<uint8_t> &vdata,
|
||||
int32_t timeout)
|
||||
int32_t UsbServerProxy::BulkTransferWrite(const UsbDev &dev, const UsbPipe &pipe,
|
||||
const std::vector<uint8_t> &bufferData, int32_t timeOut)
|
||||
{
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
RETURN_IF_WITH_RET(remote == nullptr, UEC_SERVICE_INNER_ERR);
|
||||
@@ -625,8 +623,8 @@ int32_t UsbServerProxy::BulkTransferWrite(const UsbDev &dev,
|
||||
SetDeviceMessage(data, dev.busNum, dev.devAddr);
|
||||
WRITE_PARCEL_WITH_RET(data, Uint8, pipe.interfaceId, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
WRITE_PARCEL_WITH_RET(data, Uint8, pipe.endpointId, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
WRITE_PARCEL_WITH_RET(data, Int32, timeout, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
int32_t ret = SetBufferMessage(data, vdata);
|
||||
WRITE_PARCEL_WITH_RET(data, Int32, timeOut, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
int32_t ret = SetBufferMessage(data, bufferData);
|
||||
if (UEC_OK != ret) {
|
||||
USB_HILOGE(MODULE_INNERKIT, "UsbServerProxy::%{public}s:%{public}d SetBufferMessage ret:%{public}d", __func__,
|
||||
__LINE__, ret);
|
||||
@@ -640,7 +638,8 @@ int32_t UsbServerProxy::BulkTransferWrite(const UsbDev &dev,
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t UsbServerProxy::ControlTransfer(const UsbDev &dev, const UsbCtrlTransfer &ctrl, std::vector<uint8_t> &vdata)
|
||||
int32_t UsbServerProxy::ControlTransfer(const UsbDev &dev, const UsbCtrlTransfer &ctrl,
|
||||
std::vector<uint8_t> &bufferData)
|
||||
{
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
RETURN_IF_WITH_RET(remote == nullptr, UEC_SERVICE_INNER_ERR);
|
||||
@@ -657,27 +656,27 @@ int32_t UsbServerProxy::ControlTransfer(const UsbDev &dev, const UsbCtrlTransfer
|
||||
WRITE_PARCEL_WITH_RET(data, Int32, ctrl.value, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
WRITE_PARCEL_WITH_RET(data, Int32, ctrl.index, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
WRITE_PARCEL_WITH_RET(data, Int32, ctrl.timeout, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
int32_t ret = SetBufferMessage(data, vdata);
|
||||
int32_t ret = SetBufferMessage(data, bufferData);
|
||||
if (UEC_OK != ret) {
|
||||
USB_HILOGE(MODULE_INNERKIT, "UsbServerProxy::%{public}s:%{public}d write failed! len:%{public}d", __func__,
|
||||
__LINE__, ret);
|
||||
return ret;
|
||||
}
|
||||
bool bWrite = ((ctrl.requestType & USB_ENDPOINT_DIR_MASK) == USB_ENDPOINT_DIR_OUT);
|
||||
bool isWrite = ((ctrl.requestType & USB_ENDPOINT_DIR_MASK) == USB_ENDPOINT_DIR_OUT);
|
||||
ret = remote->SendRequest(static_cast<int32_t>(IUsbSrv::USB_FUN_CONTROL_TRANSFER), data, reply, option);
|
||||
if (ret != UEC_OK) {
|
||||
USB_HILOGE(MODULE_INNERKIT, "UsbServerProxy::%{public}s:%{public}d USB_FUN_CONTROL_TRANSFER ret:%{public}d",
|
||||
__func__, __LINE__, ret);
|
||||
return ret;
|
||||
}
|
||||
if (!bWrite) {
|
||||
ret = GetBufferMessage(reply, vdata);
|
||||
if (!isWrite) {
|
||||
ret = GetBufferMessage(reply, bufferData);
|
||||
if (UEC_OK != ret) {
|
||||
USB_HILOGW(MODULE_USBD, "%{public}s:%{public}d Get buffer message error. ret = %{public}d", __func__,
|
||||
USB_HILOGE(MODULE_USBD, "%{public}s:%{public}d Get buffer message error. ret = %{public}d", __func__,
|
||||
__LINE__, ret);
|
||||
return ret;
|
||||
}
|
||||
USB_HILOGW(MODULE_USBD, "%{public}s Get buffer message. length = %{public}d", __func__, vdata.size());
|
||||
USB_HILOGI(MODULE_USBD, "%{public}s Get buffer message. length = %{public}d", __func__, bufferData.size());
|
||||
}
|
||||
return UEC_OK;
|
||||
}
|
||||
@@ -743,7 +742,7 @@ int32_t UsbServerProxy::SetInterface(uint8_t busNum, uint8_t devAddr, uint8_t in
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
int32_t UsbServerProxy::GetRawDescriptor(uint8_t busNum, uint8_t devAddr, std::vector<uint8_t> &vdata)
|
||||
int32_t UsbServerProxy::GetRawDescriptor(uint8_t busNum, uint8_t devAddr, std::vector<uint8_t> &bufferData)
|
||||
{
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
RETURN_IF_WITH_RET(remote == nullptr, UEC_SERVICE_INNER_ERR);
|
||||
@@ -757,7 +756,7 @@ int32_t UsbServerProxy::GetRawDescriptor(uint8_t busNum, uint8_t devAddr, std::v
|
||||
SetDeviceMessage(data, busNum, devAddr);
|
||||
int32_t ret = remote->SendRequest(static_cast<int32_t>(IUsbSrv::USB_FUN_GET_DESCRIPTOR), data, reply, option);
|
||||
if (ret == UEC_OK) {
|
||||
ret = GetBufferMessage(reply, vdata);
|
||||
ret = GetBufferMessage(reply, bufferData);
|
||||
if (UEC_OK != ret) {
|
||||
USB_HILOGE(MODULE_INNERKIT, "UsbServerProxy::%{public}s:%{public}d get failed ret:%{public}d", __func__,
|
||||
__LINE__, ret);
|
||||
@@ -766,10 +765,27 @@ int32_t UsbServerProxy::GetRawDescriptor(uint8_t busNum, uint8_t devAddr, std::v
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t UsbServerProxy::RequestQueue(const UsbDev &dev,
|
||||
const UsbPipe &pipe,
|
||||
const std::vector<uint8_t> &cData,
|
||||
const std::vector<uint8_t> &vData)
|
||||
int32_t UsbServerProxy::GetFileDescriptor(uint8_t busNum, uint8_t devAddr, int32_t &fd)
|
||||
{
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
RETURN_IF_WITH_RET(remote == nullptr, UEC_SERVICE_INNER_ERR);
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
if (!data.WriteInterfaceToken(UsbServerProxy::GetDescriptor())) {
|
||||
USB_HILOGE(MODULE_INNERKIT, "UsbServerProxy::%{public}s write descriptor failed!", __func__);
|
||||
return ERR_ENOUGH_DATA;
|
||||
}
|
||||
SetDeviceMessage(data, busNum, devAddr);
|
||||
int32_t ret = remote->SendRequest(static_cast<int32_t>(IUsbSrv::USB_FUN_GET_FILEDESCRIPTOR), data, reply, option);
|
||||
if (ret == UEC_OK) {
|
||||
READ_PARCEL_WITH_RET(reply, Int32, fd, UEC_INTERFACE_READ_PARCEL_ERROR);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t UsbServerProxy::RequestQueue(const UsbDev &dev, const UsbPipe &pipe, const std::vector<uint8_t> &clientData,
|
||||
const std::vector<uint8_t> &bufferData)
|
||||
{
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
RETURN_IF_WITH_RET(remote == nullptr, UEC_SERVICE_INNER_ERR);
|
||||
@@ -784,14 +800,14 @@ int32_t UsbServerProxy::RequestQueue(const UsbDev &dev,
|
||||
WRITE_PARCEL_WITH_RET(data, Uint8, pipe.interfaceId, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
WRITE_PARCEL_WITH_RET(data, Uint8, pipe.endpointId, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
|
||||
int32_t ret = UsbServerProxy::SetBufferMessage(data, cData);
|
||||
int32_t ret = UsbServerProxy::SetBufferMessage(data, clientData);
|
||||
if (UEC_OK != ret) {
|
||||
USB_HILOGE(MODULE_INNERKIT, "UsbServerProxy::%{public}s:%{public}d setBuffer failed ret:%{public}d", __func__,
|
||||
__LINE__, ret);
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
ret = UsbServerProxy::SetBufferMessage(data, vData);
|
||||
ret = UsbServerProxy::SetBufferMessage(data, bufferData);
|
||||
if (UEC_OK != ret) {
|
||||
USB_HILOGE(MODULE_INNERKIT, "UsbServerProxy::%{public}s:%{public}d setBuffer failed ret:%{public}d", __func__,
|
||||
__LINE__, ret);
|
||||
@@ -806,10 +822,8 @@ int32_t UsbServerProxy::RequestQueue(const UsbDev &dev,
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t UsbServerProxy::RequestWait(const UsbDev &dev,
|
||||
int32_t timeout,
|
||||
std::vector<uint8_t> &cData,
|
||||
std::vector<uint8_t> &vData)
|
||||
int32_t UsbServerProxy::RequestWait(const UsbDev &dev, int32_t timeOut, std::vector<uint8_t> &clientData,
|
||||
std::vector<uint8_t> &bufferData)
|
||||
{
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
RETURN_IF_WITH_RET(remote == nullptr, UEC_SERVICE_INNER_ERR);
|
||||
@@ -823,7 +837,7 @@ int32_t UsbServerProxy::RequestWait(const UsbDev &dev,
|
||||
}
|
||||
|
||||
SetDeviceMessage(data, dev.busNum, dev.devAddr);
|
||||
WRITE_PARCEL_WITH_RET(data, Int32, timeout, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
WRITE_PARCEL_WITH_RET(data, Int32, timeOut, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
int32_t ret = remote->SendRequest(static_cast<int32_t>(IUsbSrv::USB_FUN_REQUEST_WAIT), data, reply, option);
|
||||
if (ret != UEC_OK) {
|
||||
USB_HILOGE(MODULE_INNERKIT, "UsbServerProxy::%{public}s:%{public}d queue failed! ret:%{public}d", __func__,
|
||||
@@ -831,14 +845,14 @@ int32_t UsbServerProxy::RequestWait(const UsbDev &dev,
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = UsbServerProxy::GetBufferMessage(reply, cData);
|
||||
ret = UsbServerProxy::GetBufferMessage(reply, clientData);
|
||||
if (ret != UEC_OK) {
|
||||
USB_HILOGE(MODULE_INNERKIT, "UsbServerProxy::%{public}s:%{public}d get clientData failed! ret:%{public}d",
|
||||
__func__, __LINE__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = UsbServerProxy::GetBufferMessage(reply, vData);
|
||||
ret = UsbServerProxy::GetBufferMessage(reply, bufferData);
|
||||
if (ret != UEC_OK) {
|
||||
USB_HILOGE(MODULE_INNERKIT, "UsbServerProxy::%{public}s:%{public}d get buffer failed! ret:%{public}d", __func__,
|
||||
__LINE__, ret);
|
||||
@@ -893,5 +907,118 @@ int32_t UsbServerProxy::Close(uint8_t busNum, uint8_t devAddr)
|
||||
|
||||
return UEC_OK;
|
||||
}
|
||||
|
||||
int32_t UsbServerProxy::RegBulkCallback(const UsbDev &dev, const UsbPipe &pipe, const sptr<IRemoteObject> &cb)
|
||||
{
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
RETURN_IF_WITH_RET(remote == nullptr, UEC_SERVICE_INNER_ERR);
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(UsbServerProxy::GetDescriptor())) {
|
||||
USB_HILOGE(MODULE_INNERKIT, "UsbServerProxy::%{public}s write descriptor failed!", __func__);
|
||||
return ERR_ENOUGH_DATA;
|
||||
}
|
||||
SetDeviceMessage(data, dev.busNum, dev.devAddr);
|
||||
WRITE_PARCEL_WITH_RET(data, Uint8, pipe.interfaceId, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
WRITE_PARCEL_WITH_RET(data, Uint8, pipe.endpointId, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
WRITE_PARCEL_WITH_RET(data, RemoteObject, cb, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
MessageOption option;
|
||||
MessageParcel reply;
|
||||
int32_t ret = remote->SendRequest(static_cast<int32_t>(IUsbSrv::USB_FUN_REG_BULK_CALLBACK), data, reply, option);
|
||||
if (ret != UEC_OK) {
|
||||
USB_HILOGE(MODULE_INNERKIT, "UsbServerProxy::%{public}s SendRequest failed!", __func__);
|
||||
return ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t UsbServerProxy::UnRegBulkCallback(const UsbDev &dev, const UsbPipe &pipe)
|
||||
{
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
RETURN_IF_WITH_RET(remote == nullptr, UEC_SERVICE_INNER_ERR);
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(UsbServerProxy::GetDescriptor())) {
|
||||
USB_HILOGE(MODULE_INNERKIT, "UsbServerProxy::%{public}s write descriptor failed!", __func__);
|
||||
return ERR_ENOUGH_DATA;
|
||||
}
|
||||
SetDeviceMessage(data, dev.busNum, dev.devAddr);
|
||||
WRITE_PARCEL_WITH_RET(data, Uint8, pipe.interfaceId, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
WRITE_PARCEL_WITH_RET(data, Uint8, pipe.endpointId, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
MessageOption option;
|
||||
MessageParcel reply;
|
||||
int32_t ret = remote->SendRequest(static_cast<int32_t>(IUsbSrv::USB_FUN_UNREG_BULK_CALLBACK), data, reply, option);
|
||||
if (ret != UEC_OK) {
|
||||
USB_HILOGE(MODULE_INNERKIT, "UsbServerProxy::%{public}s SendRequest failed!", __func__);
|
||||
return ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t UsbServerProxy::BulkRead(const UsbDev &dev, const UsbPipe &pipe, sptr<Ashmem> &ashmem)
|
||||
{
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
RETURN_IF_WITH_RET(remote == nullptr, UEC_SERVICE_INNER_ERR);
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(UsbServerProxy::GetDescriptor())) {
|
||||
USB_HILOGE(MODULE_INNERKIT, "UsbServerProxy::%{public}s write descriptor failed!", __func__);
|
||||
return ERR_ENOUGH_DATA;
|
||||
}
|
||||
SetDeviceMessage(data, dev.busNum, dev.devAddr);
|
||||
WRITE_PARCEL_WITH_RET(data, Uint8, pipe.interfaceId, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
WRITE_PARCEL_WITH_RET(data, Uint8, pipe.endpointId, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
WRITE_PARCEL_WITH_RET(data, Ashmem, ashmem, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
MessageOption option;
|
||||
MessageParcel reply;
|
||||
int32_t ret = remote->SendRequest(static_cast<int32_t>(IUsbSrv::USB_FUN_BULK_AYSNC_READ), data, reply, option);
|
||||
if (ret != UEC_OK) {
|
||||
USB_HILOGE(MODULE_INNERKIT, "UsbServerProxy::%{public}s SendRequest failed!", __func__);
|
||||
return ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t UsbServerProxy::BulkWrite(const UsbDev &dev, const UsbPipe &pipe, sptr<Ashmem> &ashmem)
|
||||
{
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
RETURN_IF_WITH_RET(remote == nullptr, UEC_SERVICE_INNER_ERR);
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(UsbServerProxy::GetDescriptor())) {
|
||||
USB_HILOGE(MODULE_INNERKIT, "UsbServerProxy::%{public}s write descriptor failed!", __func__);
|
||||
return ERR_ENOUGH_DATA;
|
||||
}
|
||||
SetDeviceMessage(data, dev.busNum, dev.devAddr);
|
||||
WRITE_PARCEL_WITH_RET(data, Uint8, pipe.interfaceId, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
WRITE_PARCEL_WITH_RET(data, Uint8, pipe.endpointId, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
WRITE_PARCEL_WITH_RET(data, Ashmem, ashmem, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
MessageOption option;
|
||||
MessageParcel reply;
|
||||
int32_t ret = remote->SendRequest(static_cast<int32_t>(IUsbSrv::USB_FUN_BULK_AYSNC_WRITE), data, reply, option);
|
||||
if (ret != UEC_OK) {
|
||||
USB_HILOGE(MODULE_INNERKIT, "UsbServerProxy::%{public}s SendRequest failed!", __func__);
|
||||
return ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t UsbServerProxy::BulkCancel(const UsbDev &dev, const UsbPipe &pipe)
|
||||
{
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
RETURN_IF_WITH_RET(remote == nullptr, UEC_SERVICE_INNER_ERR);
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(UsbServerProxy::GetDescriptor())) {
|
||||
USB_HILOGE(MODULE_INNERKIT, "UsbServerProxy::%{public}s write descriptor failed!", __func__);
|
||||
return ERR_ENOUGH_DATA;
|
||||
}
|
||||
SetDeviceMessage(data, dev.busNum, dev.devAddr);
|
||||
WRITE_PARCEL_WITH_RET(data, Uint8, pipe.interfaceId, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
WRITE_PARCEL_WITH_RET(data, Uint8, pipe.endpointId, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
MessageOption option;
|
||||
MessageParcel reply;
|
||||
int32_t ret = remote->SendRequest(static_cast<int32_t>(IUsbSrv::USB_FUN_BULK_AYSNC_CANCEL), data, reply, option);
|
||||
if (ret != UEC_OK) {
|
||||
USB_HILOGE(MODULE_INNERKIT, "UsbServerProxy::%{public}s SendRequest failed!", __func__);
|
||||
return ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
} // namespace USB
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -36,10 +36,10 @@ int32_t UsbServerStub::GetDeviceMessage(MessageParcel &data, uint8_t &busNum, ui
|
||||
return UEC_OK;
|
||||
}
|
||||
|
||||
int32_t UsbServerStub::SetBufferMessage(MessageParcel &data, const std::vector<uint8_t> &vdata)
|
||||
int32_t UsbServerStub::SetBufferMessage(MessageParcel &data, const std::vector<uint8_t> &bufferData)
|
||||
{
|
||||
uint32_t length = vdata.size();
|
||||
const uint8_t *ptr = vdata.data();
|
||||
uint32_t length = bufferData.size();
|
||||
const uint8_t *ptr = bufferData.data();
|
||||
if (!ptr) {
|
||||
length = 0;
|
||||
}
|
||||
@@ -55,10 +55,10 @@ int32_t UsbServerStub::SetBufferMessage(MessageParcel &data, const std::vector<u
|
||||
return UEC_OK;
|
||||
}
|
||||
|
||||
int32_t UsbServerStub::GetBufferMessage(MessageParcel &data, std::vector<uint8_t> &vdata)
|
||||
int32_t UsbServerStub::GetBufferMessage(MessageParcel &data, std::vector<uint8_t> &bufferData)
|
||||
{
|
||||
uint32_t dataSize = 0;
|
||||
vdata.clear();
|
||||
bufferData.clear();
|
||||
if (!data.ReadUint32(dataSize)) {
|
||||
USB_HILOGE(MODULE_USBD, "%{public}s:%{public}d failed", __func__, __LINE__);
|
||||
return UEC_SERVICE_READ_PARCEL_ERROR;
|
||||
@@ -70,19 +70,16 @@ int32_t UsbServerStub::GetBufferMessage(MessageParcel &data, std::vector<uint8_t
|
||||
|
||||
const uint8_t *readData = data.ReadUnpadBuffer(dataSize);
|
||||
if (readData == nullptr) {
|
||||
USB_HILOGW(MODULE_USBD, "%{public}s:%{public}d failed size:%{public}d", __func__, __LINE__, dataSize);
|
||||
USB_HILOGE(MODULE_USBD, "%{public}s:%{public}d failed size:%{public}d", __func__, __LINE__, dataSize);
|
||||
return UEC_SERVICE_READ_PARCEL_ERROR;
|
||||
}
|
||||
std::vector<uint8_t> tdata(readData, readData + dataSize);
|
||||
vdata.swap(tdata);
|
||||
bufferData.swap(tdata);
|
||||
return UEC_OK;
|
||||
}
|
||||
|
||||
bool UsbServerStub::StubDevice(uint32_t code,
|
||||
int32_t &result,
|
||||
MessageParcel &data,
|
||||
MessageParcel &reply,
|
||||
MessageOption &option)
|
||||
bool UsbServerStub::StubDevice(uint32_t code, int32_t &result, MessageParcel &data, MessageParcel &reply,
|
||||
MessageOption &option)
|
||||
{
|
||||
switch (code) {
|
||||
case static_cast<int>(IUsbSrv::USB_FUN_OPEN_DEVICE):
|
||||
@@ -121,16 +118,22 @@ bool UsbServerStub::StubDevice(uint32_t code,
|
||||
case static_cast<int>(IUsbSrv::USB_FUN_CONTROL_TRANSFER):
|
||||
result = DoControlTransfer(data, reply, option);
|
||||
return true;
|
||||
case static_cast<int>(IUsbSrv::USB_FUN_REG_BULK_CALLBACK):
|
||||
result = DoRegBulkCallback(data, reply, option);
|
||||
return true;
|
||||
case static_cast<int>(IUsbSrv::USB_FUN_UNREG_BULK_CALLBACK):
|
||||
result = DoUnRegBulkCallback(data, reply, option);
|
||||
return true;
|
||||
case static_cast<int>(IUsbSrv::USB_FUN_GET_FILEDESCRIPTOR):
|
||||
result = DoGetFileDescriptor(data, reply, option);
|
||||
return true;
|
||||
default:;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool UsbServerStub::StubHost(uint32_t code,
|
||||
int32_t &result,
|
||||
MessageParcel &data,
|
||||
MessageParcel &reply,
|
||||
MessageOption &option)
|
||||
bool UsbServerStub::StubHost(uint32_t code, int32_t &result, MessageParcel &data, MessageParcel &reply,
|
||||
MessageOption &option)
|
||||
{
|
||||
switch (code) {
|
||||
case static_cast<int>(IUsbSrv::USB_FUN_GET_DEVICES):
|
||||
@@ -166,12 +169,24 @@ bool UsbServerStub::StubHost(uint32_t code,
|
||||
case static_cast<int>(IUsbSrv::USB_FUN_REQUEST_CANCEL):
|
||||
result = DoRequestCancel(data, reply, option);
|
||||
return true;
|
||||
case static_cast<int>(IUsbSrv::USB_FUN_BULK_AYSNC_READ):
|
||||
result = DoBulkRead(data, reply, option);
|
||||
return true;
|
||||
case static_cast<int>(IUsbSrv::USB_FUN_BULK_AYSNC_WRITE):
|
||||
result = DoBulkWrite(data, reply, option);
|
||||
return true;
|
||||
case static_cast<int>(IUsbSrv::USB_FUN_BULK_AYSNC_CANCEL):
|
||||
result = DoBulkCancel(data, reply, option);
|
||||
return true;
|
||||
case static_cast<int>(IUsbSrv::USB_FUN_GET_DESCRIPTOR):
|
||||
result = DoGetRawDescriptor(data, reply, option);
|
||||
return true;
|
||||
default:;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int UsbServerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
|
||||
int32_t UsbServerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
|
||||
{
|
||||
USB_HILOGD(MODULE_USB_SERVICE, "UsbServerStub::OnRemoteRequest, cmd = %{public}d, flags = %{public}d", code,
|
||||
option.GetFlags());
|
||||
@@ -268,15 +283,15 @@ int32_t UsbServerStub::DoRemoveRight(MessageParcel &data, MessageParcel &reply,
|
||||
int32_t UsbServerStub::DoGetPorts(MessageParcel &data, MessageParcel &reply, MessageOption &option)
|
||||
{
|
||||
std::vector<UsbPort> ports;
|
||||
int ret = GetPorts(ports);
|
||||
int32_t ret = GetPorts(ports);
|
||||
USB_HILOGI(MODULE_SERVICE, "UsbServerStub::GetPorts ret %{public}d ", ret);
|
||||
if (ret != UEC_OK) {
|
||||
return ret;
|
||||
}
|
||||
unsigned int size = ports.size();
|
||||
uint32_t size = ports.size();
|
||||
USB_HILOGI(MODULE_SERVICE, "UsbServerStub::GetPorts size %{public}d ", size);
|
||||
WRITE_PARCEL_WITH_RET(reply, Int32, size, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
for (unsigned int i = 0; i < size; ++i) {
|
||||
for (uint32_t i = 0; i < size; ++i) {
|
||||
ret = WriteUsbPort(reply, ports[i]);
|
||||
if (ret) {
|
||||
return ret;
|
||||
@@ -325,11 +340,14 @@ int32_t UsbServerStub::DoClaimInterface(MessageParcel &data, MessageParcel &repl
|
||||
uint8_t busNum = 0;
|
||||
uint8_t devAddr = 0;
|
||||
uint8_t interface = 0;
|
||||
uint8_t force = 0;
|
||||
READ_PARCEL_WITH_RET(data, Uint8, busNum, UEC_SERVICE_READ_PARCEL_ERROR);
|
||||
READ_PARCEL_WITH_RET(data, Uint8, devAddr, UEC_SERVICE_READ_PARCEL_ERROR);
|
||||
READ_PARCEL_WITH_RET(data, Uint8, interface, UEC_SERVICE_READ_PARCEL_ERROR);
|
||||
return ClaimInterface(busNum, devAddr, interface);
|
||||
READ_PARCEL_WITH_RET(data, Uint8, force, UEC_SERVICE_READ_PARCEL_ERROR);
|
||||
return ClaimInterface(busNum, devAddr, interface, force);
|
||||
}
|
||||
|
||||
int32_t UsbServerStub::DoReleaseInterface(MessageParcel &data, MessageParcel &reply, MessageOption &option)
|
||||
{
|
||||
uint8_t busNum = 0;
|
||||
@@ -347,23 +365,23 @@ int32_t UsbServerStub::DoBulkTransferRead(MessageParcel &data, MessageParcel &re
|
||||
uint8_t devAddr = 0;
|
||||
uint8_t interface = 0;
|
||||
uint8_t endpoint = 0;
|
||||
int32_t timeout = 0;
|
||||
int32_t timeOut = 0;
|
||||
READ_PARCEL_WITH_RET(data, Uint8, busNum, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
READ_PARCEL_WITH_RET(data, Uint8, devAddr, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
READ_PARCEL_WITH_RET(data, Uint8, interface, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
READ_PARCEL_WITH_RET(data, Uint8, endpoint, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
READ_PARCEL_WITH_RET(data, Int32, timeout, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
std::vector<uint8_t> vdata;
|
||||
const UsbDev tdev = {busNum, devAddr};
|
||||
const UsbPipe tpipe = {interface, endpoint};
|
||||
int32_t ret = BulkTransferRead(tdev, tpipe, vdata, timeout);
|
||||
READ_PARCEL_WITH_RET(data, Int32, timeOut, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
std::vector<uint8_t> bufferData;
|
||||
const UsbDev tmpDev = {busNum, devAddr};
|
||||
const UsbPipe tmpPipe = {interface, endpoint};
|
||||
int32_t ret = BulkTransferRead(tmpDev, tmpPipe, bufferData, timeOut);
|
||||
if (ret != UEC_OK) {
|
||||
USB_HILOGW(MODULE_USBD, "%{public}s:%{public}d ret:%{public}d", __func__, __LINE__, ret);
|
||||
USB_HILOGE(MODULE_USBD, "%{public}s:%{public}d ret:%{public}d", __func__, __LINE__, ret);
|
||||
return ret;
|
||||
}
|
||||
ret = SetBufferMessage(reply, vdata);
|
||||
ret = SetBufferMessage(reply, bufferData);
|
||||
if (ret != UEC_OK) {
|
||||
USB_HILOGW(MODULE_USBD, "%{public}s:%{public}d ret:%{public}d", __func__, __LINE__, ret);
|
||||
USB_HILOGE(MODULE_USBD, "%{public}s:%{public}d ret:%{public}d", __func__, __LINE__, ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -374,23 +392,23 @@ int32_t UsbServerStub::DoBulkTransferWrite(MessageParcel &data, MessageParcel &r
|
||||
uint8_t devAddr = 0;
|
||||
uint8_t interface = 0;
|
||||
uint8_t endpoint = 0;
|
||||
int32_t timeout = 0;
|
||||
int32_t timeOut = 0;
|
||||
READ_PARCEL_WITH_RET(data, Uint8, busNum, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
READ_PARCEL_WITH_RET(data, Uint8, devAddr, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
READ_PARCEL_WITH_RET(data, Uint8, interface, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
READ_PARCEL_WITH_RET(data, Uint8, endpoint, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
READ_PARCEL_WITH_RET(data, Int32, timeout, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
std::vector<uint8_t> vdata;
|
||||
const UsbDev tdev = {busNum, devAddr};
|
||||
const UsbPipe tpipe = {interface, endpoint};
|
||||
int32_t ret = GetBufferMessage(data, vdata);
|
||||
READ_PARCEL_WITH_RET(data, Int32, timeOut, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
std::vector<uint8_t> bufferData;
|
||||
const UsbDev tmpDev = {busNum, devAddr};
|
||||
const UsbPipe tmpPipe = {interface, endpoint};
|
||||
int32_t ret = GetBufferMessage(data, bufferData);
|
||||
if (UEC_OK != ret) {
|
||||
USB_HILOGW(MODULE_USBD, "%{public}s:%{public}d ret:%{public}d", __func__, __LINE__, ret);
|
||||
USB_HILOGE(MODULE_USBD, "%{public}s:%{public}d ret:%{public}d", __func__, __LINE__, ret);
|
||||
return ret;
|
||||
}
|
||||
ret = BulkTransferWrite(tdev, tpipe, vdata, timeout);
|
||||
ret = BulkTransferWrite(tmpDev, tmpPipe, bufferData, timeOut);
|
||||
if (UEC_OK != ret) {
|
||||
USB_HILOGW(MODULE_USBD, "%{public}s:%{public}d BulkTransferWrite error ret:%{public}d", __func__, __LINE__,
|
||||
USB_HILOGE(MODULE_USBD, "%{public}s:%{public}d BulkTransferWrite error ret:%{public}d", __func__, __LINE__,
|
||||
ret);
|
||||
}
|
||||
return ret;
|
||||
@@ -404,7 +422,7 @@ int32_t UsbServerStub::DoControlTransfer(MessageParcel &data, MessageParcel &rep
|
||||
int32_t request;
|
||||
int32_t value;
|
||||
int32_t index;
|
||||
int32_t timeout;
|
||||
int32_t timeOut;
|
||||
|
||||
READ_PARCEL_WITH_RET(data, Uint8, busNum, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
READ_PARCEL_WITH_RET(data, Uint8, devAddr, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
@@ -412,27 +430,27 @@ int32_t UsbServerStub::DoControlTransfer(MessageParcel &data, MessageParcel &rep
|
||||
READ_PARCEL_WITH_RET(data, Int32, request, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
READ_PARCEL_WITH_RET(data, Int32, value, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
READ_PARCEL_WITH_RET(data, Int32, index, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
READ_PARCEL_WITH_RET(data, Int32, timeout, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
std::vector<uint8_t> vdata;
|
||||
int32_t ret = GetBufferMessage(data, vdata);
|
||||
READ_PARCEL_WITH_RET(data, Int32, timeOut, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
std::vector<uint8_t> bufferData;
|
||||
int32_t ret = GetBufferMessage(data, bufferData);
|
||||
if (UEC_OK != ret) {
|
||||
USB_HILOGW(MODULE_USBD, "%{public}s:%{public}d get error ret:%{public}d", __func__, __LINE__, ret);
|
||||
USB_HILOGE(MODULE_USBD, "%{public}s:%{public}d get error ret:%{public}d", __func__, __LINE__, ret);
|
||||
return ret;
|
||||
}
|
||||
// 写数据
|
||||
bool bWrite = ((requestType & USB_ENDPOINT_DIR_MASK) == USB_ENDPOINT_DIR_OUT);
|
||||
const UsbDev tdev = {busNum, devAddr};
|
||||
const UsbCtrlTransfer tctrl = {requestType, request, value, index, timeout};
|
||||
ret = ControlTransfer(tdev, tctrl, vdata);
|
||||
const UsbDev tmpDev = {busNum, devAddr};
|
||||
const UsbCtrlTransfer tctrl = {requestType, request, value, index, timeOut};
|
||||
ret = ControlTransfer(tmpDev, tctrl, bufferData);
|
||||
if (ret != UEC_OK) {
|
||||
USB_HILOGW(MODULE_USBD, "%{public}s:%{public}d ControlTransfer error ret:%{public}d", __func__, __LINE__, ret);
|
||||
USB_HILOGE(MODULE_USBD, "%{public}s:%{public}d ControlTransfer error ret:%{public}d", __func__, __LINE__, ret);
|
||||
return ret;
|
||||
}
|
||||
// 读数据
|
||||
if (!bWrite) {
|
||||
ret = SetBufferMessage(reply, vdata);
|
||||
ret = SetBufferMessage(reply, bufferData);
|
||||
if (UEC_OK != ret) {
|
||||
USB_HILOGW(MODULE_USBD, "%{public}s:%{public}d Set buffer message error length = %{public}d", __func__,
|
||||
USB_HILOGE(MODULE_USBD, "%{public}s:%{public}d Set buffer message error length = %{public}d", __func__,
|
||||
__LINE__, ret);
|
||||
}
|
||||
}
|
||||
@@ -484,17 +502,12 @@ int32_t UsbServerStub::DoGetRawDescriptor(MessageParcel &data, MessageParcel &re
|
||||
uint8_t devAddr = 0;
|
||||
READ_PARCEL_WITH_RET(data, Uint8, busNum, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
READ_PARCEL_WITH_RET(data, Uint8, devAddr, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
std::vector<uint8_t> vdata;
|
||||
int32_t ret = GetBufferMessage(data, vdata);
|
||||
if (UEC_OK != ret) {
|
||||
USB_HILOGW(MODULE_USBD, "%{public}s:%{public}d ret:%{public}d", __func__, __LINE__, ret);
|
||||
return ret;
|
||||
}
|
||||
ret = GetRawDescriptor(busNum, devAddr, vdata);
|
||||
std::vector<uint8_t> bufferData;
|
||||
int32_t ret = GetRawDescriptor(busNum, devAddr, bufferData);
|
||||
if (UEC_OK == ret) {
|
||||
ret = SetBufferMessage(reply, vdata);
|
||||
ret = SetBufferMessage(reply, bufferData);
|
||||
if (UEC_OK != ret) {
|
||||
USB_HILOGW(MODULE_USBD, "%{public}s:%{public}d ret:%{public}d", __func__, __LINE__, ret);
|
||||
USB_HILOGE(MODULE_USBD, "%{public}s:%{public}d ret:%{public}d", __func__, __LINE__, ret);
|
||||
}
|
||||
} else {
|
||||
USB_HILOGW(MODULE_USBD, "%{public}s:%{public}d ret:%{public}d", __func__, __LINE__, ret);
|
||||
@@ -502,6 +515,22 @@ int32_t UsbServerStub::DoGetRawDescriptor(MessageParcel &data, MessageParcel &re
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t UsbServerStub::DoGetFileDescriptor(MessageParcel &data, MessageParcel &reply, MessageOption &option)
|
||||
{
|
||||
uint8_t busNum = 0;
|
||||
uint8_t devAddr = 0;
|
||||
READ_PARCEL_WITH_RET(data, Uint8, busNum, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
READ_PARCEL_WITH_RET(data, Uint8, devAddr, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
int32_t fd = -1;
|
||||
int32_t ret = GetFileDescriptor(busNum, devAddr, fd);
|
||||
if (UEC_OK == ret) {
|
||||
WRITE_PARCEL_WITH_RET(reply, Int32, fd, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
} else {
|
||||
USB_HILOGE(MODULE_USBD, "%{public}s:%{public}d ret:%{public}d", __func__, __LINE__, ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t UsbServerStub::DoRequestQueue(MessageParcel &data, MessageParcel &reply, MessageOption &option)
|
||||
{
|
||||
uint8_t busNum = 0;
|
||||
@@ -512,24 +541,24 @@ int32_t UsbServerStub::DoRequestQueue(MessageParcel &data, MessageParcel &reply,
|
||||
READ_PARCEL_WITH_RET(data, Uint8, devAddr, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
READ_PARCEL_WITH_RET(data, Uint8, ifId, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
READ_PARCEL_WITH_RET(data, Uint8, endpoint, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
std::vector<uint8_t> cData;
|
||||
std::vector<uint8_t> vData;
|
||||
std::vector<uint8_t> clientData;
|
||||
std::vector<uint8_t> bufferData;
|
||||
|
||||
int32_t ret = UsbServerStub::GetBufferMessage(data, cData);
|
||||
int32_t ret = UsbServerStub::GetBufferMessage(data, clientData);
|
||||
if (UEC_OK != ret) {
|
||||
USB_HILOGI(MODULE_USB_INNERKIT, "%{public}s:%{public}d failed ret:%{public}d", __func__, __LINE__, ret);
|
||||
USB_HILOGE(MODULE_USB_INNERKIT, "%{public}s:%{public}d failed ret:%{public}d", __func__, __LINE__, ret);
|
||||
return ret;
|
||||
}
|
||||
ret = UsbServerStub::GetBufferMessage(data, vData);
|
||||
ret = UsbServerStub::GetBufferMessage(data, bufferData);
|
||||
if (UEC_OK != ret) {
|
||||
USB_HILOGI(MODULE_USB_INNERKIT, "%{public}s:%{public}d failed ret:%{public}d", __func__, __LINE__, ret);
|
||||
USB_HILOGE(MODULE_USB_INNERKIT, "%{public}s:%{public}d failed ret:%{public}d", __func__, __LINE__, ret);
|
||||
return ret;
|
||||
}
|
||||
const UsbDev tdev = {busNum, devAddr};
|
||||
const UsbPipe tpipe = {ifId, endpoint};
|
||||
ret = RequestQueue(tdev, tpipe, cData, vData);
|
||||
const UsbDev tmpDev = {busNum, devAddr};
|
||||
const UsbPipe tmpPipe = {ifId, endpoint};
|
||||
ret = RequestQueue(tmpDev, tmpPipe, clientData, bufferData);
|
||||
if (UEC_OK != ret) {
|
||||
USB_HILOGI(MODULE_USB_INNERKIT, "%{public}s:%{public}d failed ret:%{public}d", __func__, __LINE__, ret);
|
||||
USB_HILOGE(MODULE_USB_INNERKIT, "%{public}s:%{public}d failed ret:%{public}d", __func__, __LINE__, ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -538,29 +567,29 @@ int32_t UsbServerStub::DoRequestWait(MessageParcel &data, MessageParcel &reply,
|
||||
{
|
||||
uint8_t busNum = 0;
|
||||
uint8_t devAddr = 0;
|
||||
int32_t timeout = 0;
|
||||
std::vector<uint8_t> cData;
|
||||
std::vector<uint8_t> vData;
|
||||
int32_t timeOut = 0;
|
||||
std::vector<uint8_t> clientData;
|
||||
std::vector<uint8_t> bufferData;
|
||||
READ_PARCEL_WITH_RET(data, Uint8, busNum, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
READ_PARCEL_WITH_RET(data, Uint8, devAddr, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
READ_PARCEL_WITH_RET(data, Int32, timeout, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
READ_PARCEL_WITH_RET(data, Int32, timeOut, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
|
||||
const UsbDev tdev = {busNum, devAddr};
|
||||
int32_t ret = RequestWait(tdev, timeout, cData, vData);
|
||||
const UsbDev tmpDev = {busNum, devAddr};
|
||||
int32_t ret = RequestWait(tmpDev, timeOut, clientData, bufferData);
|
||||
if (ret != UEC_OK) {
|
||||
USB_HILOGI(MODULE_USB_INNERKIT, "%{public}s:%{public}d failed ret:%{public}d", __func__, __LINE__, ret);
|
||||
USB_HILOGE(MODULE_USB_INNERKIT, "%{public}s:%{public}d failed ret:%{public}d", __func__, __LINE__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = SetBufferMessage(reply, cData);
|
||||
ret = SetBufferMessage(reply, clientData);
|
||||
if (ret != UEC_OK) {
|
||||
USB_HILOGI(MODULE_USB_INNERKIT, "%{public}s:%{public}d failed ret:%{public}d", __func__, __LINE__, ret);
|
||||
USB_HILOGE(MODULE_USB_INNERKIT, "%{public}s:%{public}d failed ret:%{public}d", __func__, __LINE__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = SetBufferMessage(reply, vData);
|
||||
ret = SetBufferMessage(reply, bufferData);
|
||||
if (ret != UEC_OK) {
|
||||
USB_HILOGI(MODULE_USB_INNERKIT, "%{public}s:%{public}d failed ret:%{public}d", __func__, __LINE__, ret);
|
||||
USB_HILOGE(MODULE_USB_INNERKIT, "%{public}s:%{public}d failed ret:%{public}d", __func__, __LINE__, ret);
|
||||
return ret;
|
||||
}
|
||||
return ret;
|
||||
@@ -578,7 +607,7 @@ int32_t UsbServerStub::DoRequestCancel(MessageParcel &data, MessageParcel &reply
|
||||
READ_PARCEL_WITH_RET(data, Uint8, endpointId, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
int32_t ret = RequestCancel(busNum, devAddr, interfaceId, endpointId);
|
||||
if (UEC_OK != ret) {
|
||||
USB_HILOGI(MODULE_USB_INNERKIT, "%{public}s:%{public}d failed ret:%{public}d", __func__, __LINE__, ret);
|
||||
USB_HILOGE(MODULE_USB_INNERKIT, "%{public}s:%{public}d failed ret:%{public}d", __func__, __LINE__, ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -591,7 +620,7 @@ int32_t UsbServerStub::DoClose(MessageParcel &data, MessageParcel &reply, Messag
|
||||
READ_PARCEL_WITH_RET(data, Uint8, devAddr, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
int32_t ret = Close(busNum, devAddr);
|
||||
if (UEC_OK != ret) {
|
||||
USB_HILOGI(MODULE_USB_INNERKIT, "%{public}s:%{public}d failed ret:%{public}d", __func__, __LINE__, ret);
|
||||
USB_HILOGE(MODULE_USB_INNERKIT, "%{public}s:%{public}d failed ret:%{public}d", __func__, __LINE__, ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -607,7 +636,7 @@ int32_t UsbServerStub::DoGetDevices(MessageParcel &data, MessageParcel &reply, M
|
||||
USB_HILOGE(MODULE_SERVICE, "%{public}s: list size = %{public}d", __func__, deviceList.size());
|
||||
ret = SetDeviceListMessageParcel(deviceList, reply);
|
||||
if (UEC_OK != ret) {
|
||||
USB_HILOGI(MODULE_USB_INNERKIT, "%{public}s:%{public}d failed ret:%{public}d", __func__, __LINE__, ret);
|
||||
USB_HILOGE(MODULE_USB_INNERKIT, "%{public}s:%{public}d failed ret:%{public}d", __func__, __LINE__, ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -711,5 +740,108 @@ int32_t UsbServerStub::SetDeviceEndpointsMessageParcel(std::vector<USBEndpoint>
|
||||
}
|
||||
return UEC_OK;
|
||||
}
|
||||
|
||||
int32_t UsbServerStub::DoRegBulkCallback(MessageParcel &data, MessageParcel &reply, MessageOption &option)
|
||||
{
|
||||
uint8_t busNum = 0;
|
||||
uint8_t devAddr = 0;
|
||||
uint8_t interface = 0;
|
||||
uint8_t endpoint = 0;
|
||||
READ_PARCEL_WITH_RET(data, Uint8, busNum, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
READ_PARCEL_WITH_RET(data, Uint8, devAddr, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
READ_PARCEL_WITH_RET(data, Uint8, interface, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
READ_PARCEL_WITH_RET(data, Uint8, endpoint, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
const sptr<IRemoteObject> cb = data.ReadRemoteObject();
|
||||
const UsbDev tmpDev = {busNum, devAddr};
|
||||
const UsbPipe tmpPipe = {interface, endpoint};
|
||||
int32_t ret = RegBulkCallback(tmpDev, tmpPipe, cb);
|
||||
if (ret != UEC_OK) {
|
||||
USB_HILOGE(MODULE_USBD, "%{public}s:%{public}d ret:%{public}d", __func__, __LINE__, ret);
|
||||
return ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t UsbServerStub::DoUnRegBulkCallback(MessageParcel &data, MessageParcel &reply, MessageOption &option)
|
||||
{
|
||||
uint8_t busNum = 0;
|
||||
uint8_t devAddr = 0;
|
||||
uint8_t interface = 0;
|
||||
uint8_t endpoint = 0;
|
||||
READ_PARCEL_WITH_RET(data, Uint8, busNum, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
READ_PARCEL_WITH_RET(data, Uint8, devAddr, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
READ_PARCEL_WITH_RET(data, Uint8, interface, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
READ_PARCEL_WITH_RET(data, Uint8, endpoint, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
const UsbDev tmpDev = {busNum, devAddr};
|
||||
const UsbPipe tmpPipe = {interface, endpoint};
|
||||
int32_t ret = UnRegBulkCallback(tmpDev, tmpPipe);
|
||||
if (ret != UEC_OK) {
|
||||
USB_HILOGE(MODULE_USBD, "%{public}s:%{public}d ret:%{public}d", __func__, __LINE__, ret);
|
||||
return ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t UsbServerStub::DoBulkRead(MessageParcel &data, MessageParcel &reply, MessageOption &option)
|
||||
{
|
||||
uint8_t busNum = 0;
|
||||
uint8_t devAddr = 0;
|
||||
uint8_t interface = 0;
|
||||
uint8_t endpoint = 0;
|
||||
READ_PARCEL_WITH_RET(data, Uint8, busNum, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
READ_PARCEL_WITH_RET(data, Uint8, devAddr, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
READ_PARCEL_WITH_RET(data, Uint8, interface, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
READ_PARCEL_WITH_RET(data, Uint8, endpoint, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
sptr<Ashmem> ashmem = data.ReadAshmem();
|
||||
const UsbDev tmpDev = {busNum, devAddr};
|
||||
const UsbPipe tmpPipe = {interface, endpoint};
|
||||
int32_t ret = BulkRead(tmpDev, tmpPipe, ashmem);
|
||||
if (ret != UEC_OK) {
|
||||
USB_HILOGE(MODULE_USBD, "%{public}s:%{public}d ret:%{public}d", __func__, __LINE__, ret);
|
||||
return ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t UsbServerStub::DoBulkWrite(MessageParcel &data, MessageParcel &reply, MessageOption &option)
|
||||
{
|
||||
uint8_t busNum = 0;
|
||||
uint8_t devAddr = 0;
|
||||
uint8_t interface = 0;
|
||||
uint8_t endpoint = 0;
|
||||
READ_PARCEL_WITH_RET(data, Uint8, busNum, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
READ_PARCEL_WITH_RET(data, Uint8, devAddr, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
READ_PARCEL_WITH_RET(data, Uint8, interface, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
READ_PARCEL_WITH_RET(data, Uint8, endpoint, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
sptr<Ashmem> ashmem = data.ReadAshmem();
|
||||
const UsbDev tmpDev = {busNum, devAddr};
|
||||
const UsbPipe tmpPipe = {interface, endpoint};
|
||||
int32_t ret = BulkWrite(tmpDev, tmpPipe, ashmem);
|
||||
if (ret != UEC_OK) {
|
||||
USB_HILOGE(MODULE_USBD, "%{public}s:%{public}d ret:%{public}d", __func__, __LINE__, ret);
|
||||
return ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t UsbServerStub::DoBulkCancel(MessageParcel &data, MessageParcel &reply, MessageOption &option)
|
||||
{
|
||||
uint8_t busNum = 0;
|
||||
uint8_t devAddr = 0;
|
||||
uint8_t interface = 0;
|
||||
uint8_t endpoint = 0;
|
||||
READ_PARCEL_WITH_RET(data, Uint8, busNum, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
READ_PARCEL_WITH_RET(data, Uint8, devAddr, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
READ_PARCEL_WITH_RET(data, Uint8, interface, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
READ_PARCEL_WITH_RET(data, Uint8, endpoint, UEC_SERVICE_WRITE_PARCEL_ERROR);
|
||||
const UsbDev tmpDev = {busNum, devAddr};
|
||||
const UsbPipe tmpPipe = {interface, endpoint};
|
||||
int32_t ret = BulkCancel(tmpDev, tmpPipe);
|
||||
if (ret != UEC_OK) {
|
||||
USB_HILOGE(MODULE_USBD, "%{public}s:%{public}d ret:%{public}d", __func__, __LINE__, ret);
|
||||
return ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
} // namespace USB
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -20,7 +20,7 @@ const twelve = 12;
|
||||
*/
|
||||
export default class DateAndTimeUtil {
|
||||
constructor() {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -31,7 +31,7 @@ export default class DateAndTimeUtil {
|
||||
const hours = datetime.getHours();
|
||||
const minutes = datetime.getMinutes();
|
||||
return this.concatTime(hours, minutes);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -46,7 +46,7 @@ export default class DateAndTimeUtil {
|
||||
var now = this.concatTimeWithSeconds(hours, minutes, seconds);
|
||||
console.info('now concat: ' + now);
|
||||
return now;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* format
|
||||
@@ -55,7 +55,7 @@ export default class DateAndTimeUtil {
|
||||
*/
|
||||
fill(value) {
|
||||
return (value > 9 ? '' : '0') + value;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* concat date
|
||||
@@ -64,15 +64,15 @@ export default class DateAndTimeUtil {
|
||||
*/
|
||||
concatDate(year, month, date) {
|
||||
return year + this.year + month + this.month + date + this.day;
|
||||
};
|
||||
}
|
||||
|
||||
concatTime(hours, minutes) {
|
||||
return `${this.fill(hours)}:${this.fill(minutes)}`;
|
||||
};
|
||||
}
|
||||
|
||||
concatTimeWithSeconds(hours, minutes, milliseconds) {
|
||||
return `${this.fill(hours)}:${this.fill(minutes)}:${this.fill(milliseconds)}`;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn to 24-hour clock
|
||||
@@ -97,7 +97,7 @@ export default class DateAndTimeUtil {
|
||||
return time;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn to 12-hour clock
|
||||
@@ -116,5 +116,5 @@ export default class DateAndTimeUtil {
|
||||
const reduceHours = parseInt(hours) - twelve;
|
||||
return this.afternoon.concat(`${reduceHours}:${minutes}`);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,15 +25,16 @@ describe('UsbCoreJsFunctionsTest', function () {
|
||||
console.log('*************Usb Unit UsbCoreJsFunctionsTest Begin*************');
|
||||
var Version = usb.getVersion()
|
||||
console.info('begin test getversion :' + Version)
|
||||
// 切换为host
|
||||
// version > 17 host currentMode = 2 device currentMode = 1
|
||||
var usbPortList = usb.getPorts()
|
||||
if (usbPortList.length > 0) {
|
||||
if (usbPortList[0].status.currentMode == 1) {
|
||||
usb.setPortRoles(usbPortList[0].id, 1, 1).then(data => {
|
||||
usb.setPortRoles(usbPortList[0].id, usb.SOURCE, usb.HOST).then(data => {
|
||||
console.info('usb case setPortRoles return: ' + data);
|
||||
}).catch(error => {
|
||||
console.info('usb case setPortRoles error : ' + error);
|
||||
});
|
||||
CheckEmptyUtils.sleep(8000)
|
||||
console.log('*************Usb Unit Begin switch to host*************');
|
||||
}
|
||||
}
|
||||
@@ -52,7 +53,7 @@ describe('UsbCoreJsFunctionsTest', function () {
|
||||
var gPipe;
|
||||
|
||||
/**
|
||||
* @tc.number : get_devices_test_01
|
||||
* @tc.number : SUB_USB_get_devices_test_01
|
||||
* @tc.name : getDevices
|
||||
* @tc.desc : 获取设备列表
|
||||
*/
|
||||
@@ -71,7 +72,7 @@ describe('UsbCoreJsFunctionsTest', function () {
|
||||
|
||||
|
||||
/**
|
||||
* @tc.number : has_right_1
|
||||
* @tc.number : SUB_USB_has_right_01
|
||||
* @tc.name : hasRigt
|
||||
* @tc.desc : 权限查询 连接设备 关闭设备
|
||||
*/
|
||||
@@ -94,7 +95,7 @@ describe('UsbCoreJsFunctionsTest', function () {
|
||||
|
||||
|
||||
/**
|
||||
* @tc.number : request_right_01
|
||||
* @tc.number : SUB_USB_request_right_01
|
||||
* @tc.name : requestRight
|
||||
* @tc.desc : 请求权限
|
||||
*/
|
||||
@@ -119,7 +120,7 @@ describe('UsbCoreJsFunctionsTest', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : connect_device_01
|
||||
* @tc.number : SUB_USB_connect_device_01
|
||||
* @tc.name : connectDevice
|
||||
* @tc.desc : 打开设备
|
||||
*/
|
||||
@@ -148,7 +149,7 @@ describe('UsbCoreJsFunctionsTest', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : close_pipe_02
|
||||
* @tc.number : SUB_USB_close_pipe_02
|
||||
* @tc.name : closePipe
|
||||
* @tc.desc : 反向测试 关闭设备 错误 busNum
|
||||
*/
|
||||
@@ -170,7 +171,7 @@ describe('UsbCoreJsFunctionsTest', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : close_pipe_03
|
||||
* @tc.number : SUB_USB_close_pipe_03
|
||||
* @tc.name : closePipe
|
||||
* @tc.desc : 反向测试 关闭设备 错误 devAddress
|
||||
*/
|
||||
@@ -191,7 +192,7 @@ describe('UsbCoreJsFunctionsTest', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : close_pipe_04
|
||||
* @tc.number : SUB_USB_close_pipe_04
|
||||
* @tc.name : closePipe
|
||||
* @tc.desc : 反向测试 关闭设备 错误 devAddress busNum
|
||||
*/
|
||||
@@ -213,7 +214,7 @@ describe('UsbCoreJsFunctionsTest', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : close_pipe_01
|
||||
* @tc.number : SUB_USB_close_pipe_01
|
||||
* @tc.name : closePipe
|
||||
* @tc.desc : 关闭设备
|
||||
*/
|
||||
@@ -233,4 +234,115 @@ describe('UsbCoreJsFunctionsTest', function () {
|
||||
console.info('usb close_pipe_01 : PASS');
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_USB_get_raw_descriptor_01
|
||||
* @tc.name : getRawDescriptor
|
||||
* @tc.desc : 获取原始的USB描述符
|
||||
*/
|
||||
it('SUB_USB_get_raw_descriptor_01', 0, function () {
|
||||
if (gDeviceList.length == 0) {
|
||||
console.info('usb case get_device_list is null')
|
||||
expect(false).assertTrue();
|
||||
return
|
||||
}
|
||||
|
||||
gPipe = usb.connectDevice(gDeviceList[0])
|
||||
console.info('usb case getRawDescriptor param: ' + JSON.stringify(gPipe));
|
||||
var descriptor = usb.getRawDescriptor(gPipe);
|
||||
console.info('usb case getRawDescriptor ret: ' + descriptor);
|
||||
expect(true).assertTrue();
|
||||
var isPipClose = usb.closePipe(gPipe);
|
||||
expect(isPipClose).assertEqual(0);
|
||||
|
||||
console.info('usb SUB_USB_get_raw_descriptor_01 : PASS');
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_USB_get_file_descriptor_01
|
||||
* @tc.name : getFileDescriptor
|
||||
* @tc.desc : 获取文件描述符
|
||||
*/
|
||||
it('SUB_USB_get_file_descriptor_01', 0, function () {
|
||||
if (gDeviceList.length == 0) {
|
||||
console.info('usb case get_device_list is null')
|
||||
expect(false).assertTrue();
|
||||
return
|
||||
}
|
||||
gPipe = usb.connectDevice(gDeviceList[0])
|
||||
console.info('usb case getFileDescriptor param: ' + JSON.stringify(gPipe));
|
||||
var fileDescriptor = usb.getFileDescriptor(gPipe);
|
||||
console.info('usb case getFileDescriptor ret: ' + fileDescriptor);
|
||||
expect(true).assertTrue();
|
||||
var isPipClose = usb.closePipe(gPipe);
|
||||
expect(isPipClose).assertEqual(0);
|
||||
|
||||
console.info('usb SUB_USB_get_file_descriptor_01 : PASS');
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_USB_get_file_descriptor_02
|
||||
* @tc.name : getFileDescriptor
|
||||
* @tc.desc : 获取文件描述符,反向测试,错误参数busNum=512
|
||||
*/
|
||||
it('SUB_USB_get_file_descriptor_02', 0, function () {
|
||||
if (gDeviceList.length == 0) {
|
||||
console.info('usb case get_device_list is null')
|
||||
expect(false).assertTrue();
|
||||
return
|
||||
}
|
||||
gPipe = usb.connectDevice(gDeviceList[0])
|
||||
var tempPipe = {busNum : 255, devAddress : 255}
|
||||
console.info('usb case getFileDescriptor param: ' + JSON.stringify(gPipe));
|
||||
var fileDescriptor = usb.getFileDescriptor(tempPipe);
|
||||
expect(fileDescriptor < 0).assertTrue();
|
||||
console.info('usb case getFileDescriptor ret: ' + fileDescriptor);
|
||||
var isPipClose = usb.closePipe(gPipe);
|
||||
expect(isPipClose).assertEqual(0);
|
||||
console.info('usb SUB_USB_get_file_descriptor_02 : PASS');
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_USB_get_file_descriptor_03
|
||||
* @tc.name : getFileDescriptor
|
||||
* @tc.desc : 获取文件描述符,反向测试,错误参数devAddress=512
|
||||
*/
|
||||
it('SUB_USB_get_file_descriptor_03', 0, function () {
|
||||
if (gDeviceList.length == 0) {
|
||||
console.info('usb case get_device_list is null')
|
||||
expect(false).assertTrue();
|
||||
return
|
||||
}
|
||||
gPipe = usb.connectDevice(gDeviceList[0])
|
||||
var tempPipe = {busNum : 255, devAddress : gPipe.devAddress}
|
||||
console.info('usb case getFileDescriptor param: ' + JSON.stringify(gPipe));
|
||||
var fileDescriptor = usb.getFileDescriptor(tempPipe);
|
||||
expect(fileDescriptor < 0).assertTrue();
|
||||
console.info('usb case getFileDescriptor ret: ' + fileDescriptor);
|
||||
var isPipClose = usb.closePipe(gPipe);
|
||||
expect(isPipClose).assertEqual(0);
|
||||
console.info('usb SUB_USB_get_file_descriptor_03 : PASS');
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_USB_get_file_descriptor_04
|
||||
* @tc.name : getFileDescriptor
|
||||
* @tc.desc : 获取文件描述符,反向测试,错误参数busNum=512,devAddress=512
|
||||
*/
|
||||
it('SUB_USB_get_file_descriptor_04', 0, function () {
|
||||
if (gDeviceList.length == 0) {
|
||||
console.info('usb case get_device_list is null')
|
||||
expect(false).assertTrue();
|
||||
return
|
||||
}
|
||||
gPipe = usb.connectDevice(gDeviceList[0])
|
||||
var tempPipe = {busNum : gPipe.busNum, devAddress : 255}
|
||||
console.info('usb case getFileDescriptor param: ' + JSON.stringify(gPipe));
|
||||
var fileDescriptor = usb.getFileDescriptor(tempPipe);
|
||||
expect(fileDescriptor < 0).assertTrue();
|
||||
console.info('usb case getFileDescriptor ret: ' + fileDescriptor);
|
||||
var isPipClose = usb.closePipe(gPipe);
|
||||
expect(isPipClose).assertEqual(0);
|
||||
console.info('usb SUB_USB_get_file_descriptor_04 : PASS');
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
@@ -25,11 +25,11 @@ describe('UsbCoreJsFunctionsTestEx', function () {
|
||||
console.log('*************Usb Unit UsbCoreJsFunctionsTestEx Begin*************');
|
||||
var Version = usb.getVersion()
|
||||
console.info('begin test getversion :' + Version)
|
||||
// 切换为host
|
||||
// version > 17 host currentMode = 2 device currentMode = 1
|
||||
var usbPortList = usb.getPorts()
|
||||
if (usbPortList.length > 0) {
|
||||
if (usbPortList[0].status.currentMode == 1) {
|
||||
usb.setPortRoles(usbPortList[0].id, 1, 1).then(data => {
|
||||
usb.setPortRoles(usbPortList[0].id, usb.SOURCE, usb.HOST).then(data => {
|
||||
console.info('usb case setPortRolesEx return: ' + data);
|
||||
}).catch(error => {
|
||||
console.info('usb case setPortRolesEx error : ' + error);
|
||||
@@ -51,7 +51,7 @@ describe('UsbCoreJsFunctionsTestEx', function () {
|
||||
|
||||
|
||||
/**
|
||||
* @tc.number : connect_device_02
|
||||
* @tc.number : SUB_USB_connect_device_02
|
||||
* @tc.name : connectDevice
|
||||
* @tc.desc : 反向测试 错误参数 devAddress 打开设备
|
||||
*/
|
||||
@@ -88,7 +88,7 @@ describe('UsbCoreJsFunctionsTestEx', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : connect_device_03
|
||||
* @tc.number : SUB_USB_connect_device_03
|
||||
* @tc.name : connectDevice
|
||||
* @tc.desc : 反向测试 busNum错误参数 打开设备
|
||||
*/
|
||||
@@ -124,7 +124,7 @@ describe('UsbCoreJsFunctionsTestEx', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : connect_device_04
|
||||
* @tc.number : SUB_USB_connect_device_04
|
||||
* @tc.name : connectDevice
|
||||
* @tc.desc : 反向测试 serial错误参数 打开设备
|
||||
*/
|
||||
@@ -163,7 +163,7 @@ describe('UsbCoreJsFunctionsTestEx', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : connect_device_05
|
||||
* @tc.number : SUB_USB_connect_device_05
|
||||
* @tc.name : connectDevice
|
||||
* @tc.desc : 反向测试 name错误参数 打开设备
|
||||
*/
|
||||
@@ -201,7 +201,7 @@ describe('UsbCoreJsFunctionsTestEx', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : connect_device_06
|
||||
* @tc.number : SUB_USB_connect_device_06
|
||||
* @tc.name : connectDevice
|
||||
* @tc.desc : 反向测试 manufacturerName错误参数 打开设备
|
||||
*/
|
||||
@@ -240,7 +240,7 @@ describe('UsbCoreJsFunctionsTestEx', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : connect_device_07
|
||||
* @tc.number : SUB_USB_connect_device_07
|
||||
* @tc.name : connectDevice
|
||||
* @tc.desc : 反向测试 productName错误参数 打开设备
|
||||
*/
|
||||
@@ -279,7 +279,7 @@ describe('UsbCoreJsFunctionsTestEx', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : connect_device_08
|
||||
* @tc.number : SUB_USB_connect_device_08
|
||||
* @tc.name : connectDevice
|
||||
* @tc.desc : 反向测试 version错误参数 打开设备
|
||||
*/
|
||||
@@ -318,7 +318,7 @@ describe('UsbCoreJsFunctionsTestEx', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : connect_device_09
|
||||
* @tc.number : SUB_USB_connect_device_09
|
||||
* @tc.name : connectDevice
|
||||
* @tc.desc : 反向测试 vendorId错误参数 打开设备
|
||||
*/
|
||||
@@ -357,7 +357,7 @@ describe('UsbCoreJsFunctionsTestEx', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : connect_device_10
|
||||
* @tc.number : SUB_USB_connect_device_10
|
||||
* @tc.name : connectDevice
|
||||
* @tc.desc : 反向测试 productId错误参数 打开设备
|
||||
*/
|
||||
@@ -396,7 +396,7 @@ describe('UsbCoreJsFunctionsTestEx', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : connect_device_11
|
||||
* @tc.number : SUB_USB_connect_device_11
|
||||
* @tc.name : connectDevice
|
||||
* @tc.desc : 反向测试 clazz错误参数 打开设备
|
||||
*/
|
||||
@@ -434,7 +434,7 @@ describe('UsbCoreJsFunctionsTestEx', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : connect_device_12
|
||||
* @tc.number : SUB_USB_connect_device_12
|
||||
* @tc.name : connectDevice
|
||||
* @tc.desc : 反向测试 subclass错误参数 打开设备
|
||||
*/
|
||||
@@ -472,7 +472,7 @@ describe('UsbCoreJsFunctionsTestEx', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : connect_device_13
|
||||
* @tc.number : SUB_USB_connect_device_13
|
||||
* @tc.name : connectDevice
|
||||
* @tc.desc : 反向测试 protocol错误参数 打开设备
|
||||
*/
|
||||
@@ -510,7 +510,7 @@ describe('UsbCoreJsFunctionsTestEx', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : has_right_02
|
||||
* @tc.number : SUB_USB_has_right_02
|
||||
* @tc.name : hasRight
|
||||
* @tc.desc : 反向测试 给错误设备名字
|
||||
*/
|
||||
@@ -535,7 +535,7 @@ describe('UsbCoreJsFunctionsTestEx', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : has_right_03
|
||||
* @tc.number : SUB_USB_has_right_03
|
||||
* @tc.name : hasRight
|
||||
* @tc.desc : 反向测试 给设备名字为字母
|
||||
*/
|
||||
@@ -560,7 +560,7 @@ describe('UsbCoreJsFunctionsTestEx', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : request_right_02
|
||||
* @tc.number : SUB_USB_request_right_02
|
||||
* @tc.name : requestRight
|
||||
* @tc.desc : 反向测试 错误设备名字 请求权限
|
||||
*/
|
||||
@@ -587,7 +587,7 @@ describe('UsbCoreJsFunctionsTestEx', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : request_right_03
|
||||
* @tc.number : SUB_USB_request_right_03
|
||||
* @tc.name : requestRight
|
||||
* @tc.desc : 反向测试 设备名字为数字 请求权限
|
||||
*/
|
||||
|
||||
@@ -28,12 +28,11 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
|
||||
console.log('*************Usb Unit UsbDevicePipeJsFunctionsTest Begin*************');
|
||||
var Version = usb.getVersion()
|
||||
console.info('usb unit begin test getversion :' + Version)
|
||||
|
||||
// 切换为host
|
||||
// version > 17 host currentMode = 2 device currentMode = 1
|
||||
var usbPortList = usb.getPorts()
|
||||
if (usbPortList.length > 0) {
|
||||
if (usbPortList[0].status.currentMode == 1) {
|
||||
usb.setPortRoles(usbPortList[0].id, 1, 1).then(data => {
|
||||
usb.setPortRoles(usbPortList[0].id, usb.SOURCE, usb.HOST).then(data => {
|
||||
console.info('usb case setPortRoles return: ' + data);
|
||||
}).catch(error => {
|
||||
console.info('usb case setPortRoles error : ' + error);
|
||||
@@ -66,10 +65,10 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
|
||||
var endpoint = testParam.config.interfaces[j].endpoints[k];
|
||||
if (endpoint.type == EventConstants.USB_ENDPOINT_XFER_BULK) {
|
||||
bfind = true
|
||||
if (endpoint.direction == EventConstants.USB_ENDPOINT_DIR_OUT) {
|
||||
if (endpoint.direction == usb.USB_REQUEST_DIR_TO_DEVICE) {
|
||||
testParam.maxOutSize = endpoint.maxPacketSize;
|
||||
testParam.outEndpoint = endpoint;
|
||||
} else if (endpoint.direction == EventConstants.USB_ENDPOINT_DIR_IN) {
|
||||
} else if (endpoint.direction == usb.USB_REQUEST_DIR_FROM_DEVICE) {
|
||||
testParam.maxInSize = endpoint.maxPacketSize;
|
||||
testParam.inEndpoint = endpoint
|
||||
}
|
||||
@@ -132,7 +131,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number : bulk_transfer_test_01
|
||||
* @tc.number : SUB_USB_bulk_transfer_test_01
|
||||
* @tc.name : bulkTransfer
|
||||
* @tc.desc : 批量传输 收数据
|
||||
*/
|
||||
@@ -144,8 +143,6 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
|
||||
return
|
||||
}
|
||||
|
||||
testParam.isClaimed = usb.releaseInterface(testParam.pip, testParam.interface)
|
||||
expect(testParam.isClaimed).assertEqual(0);
|
||||
testParam.isClaimed = usb.claimInterface(testParam.pip, testParam.interface, true);
|
||||
expect(testParam.isClaimed).assertEqual(0);
|
||||
|
||||
@@ -163,7 +160,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : bulk_transfer_test_02
|
||||
* @tc.number : SUB_USB_bulk_transfer_test_02
|
||||
* @tc.name : bulkTransfer
|
||||
* @tc.desc : 批量传输 发数据
|
||||
*/
|
||||
@@ -175,8 +172,6 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
|
||||
return
|
||||
}
|
||||
|
||||
testParam.isClaimed = usb.releaseInterface(testParam.pip, testParam.interface)
|
||||
expect(testParam.isClaimed).assertEqual(0);
|
||||
testParam.isClaimed = usb.claimInterface(testParam.pip, testParam.interface, true);
|
||||
expect(testParam.isClaimed).assertEqual(0);
|
||||
|
||||
@@ -202,7 +197,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : claim_interface_test_01
|
||||
* @tc.number : SUB_USB_claim_interface_test_01
|
||||
* @tc.name : claimInterface
|
||||
* @tc.desc : 获取接口 并释放
|
||||
*/
|
||||
@@ -232,6 +227,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
|
||||
isClaim = usb.releaseInterface(gPipe, gDeviceList[0].configs[j].interfaces[k])
|
||||
console.info('usb case releaseInterface function return: ' + isClaim);
|
||||
expect(isClaim).assertEqual(0);
|
||||
gPipe = usb.connectDevice(gDeviceList[0])
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -257,7 +253,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number : set_configuration_test_01
|
||||
* @tc.number : SUB_USB_set_configuration_test_01
|
||||
* @tc.name : setConfiguration
|
||||
* @tc.desc : 设置设备接口
|
||||
*/
|
||||
@@ -269,6 +265,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
|
||||
return
|
||||
}
|
||||
|
||||
gPipe = usb.connectDevice(gDeviceList[0])
|
||||
for (var j = 0; j < gDeviceList[0].configs.length; j++) {
|
||||
var ret = usb.setConfiguration(gPipe, gDeviceList[0].configs[j])
|
||||
console.info('usb case setConfiguration return : ' + ret);
|
||||
@@ -280,7 +277,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : set_configuration_test_02
|
||||
* @tc.number : SUB_USB_set_configuration_test_02
|
||||
* @tc.name : setConfiguration
|
||||
* @tc.desc : 反向测试 设置设备接口
|
||||
*/
|
||||
@@ -304,7 +301,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : set_interface_test_01
|
||||
* @tc.number : SUB_USB_set_interface_test_01
|
||||
* @tc.name : setInterface
|
||||
* @tc.desc : 设置设备接口
|
||||
*/
|
||||
@@ -331,7 +328,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : set_interface_test_02
|
||||
* @tc.number : SUB_USB_set_interface_test_02
|
||||
* @tc.name : setInterface
|
||||
* @tc.desc : 反向测试 设置设备接口
|
||||
*/
|
||||
@@ -373,7 +370,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number : control_transfer_test_01
|
||||
* @tc.number : SUB_USB_control_transfer_test_01
|
||||
* @tc.name : controlTransfer
|
||||
* @tc.desc : 控制传输 GetDescriptor: cmd 6 reqType 128 value 512 index 0
|
||||
*/
|
||||
@@ -386,12 +383,13 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
|
||||
}
|
||||
|
||||
var timeout = 5000;
|
||||
var controlParam = getTransferParam(6, ((1 << 7) | (0 << 5) | (0 & 0x1f)), (2 << 8), 0)
|
||||
var controlParam = getTransferParam(6, (usb.USB_REQUEST_DIR_FROM_DEVICE << 7)
|
||||
| (usb.USB_REQUEST_TYPE_STANDARD << 5) | (usb.USB_REQUEST_TARGET_DEVICE & 0x1f), (2 << 8), 0)
|
||||
callControlTransfer(testParam.pip, controlParam, timeout, 'control_transfer_test_01 GetDescriptor')
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : control_transfer_test_02
|
||||
* @tc.number : SUB_USB_control_transfer_test_02
|
||||
* @tc.name : controlTransfer
|
||||
* @tc.desc : 控制传输 GetStatus: cmd 0 reqType 128 value 0 index 0
|
||||
*/
|
||||
@@ -404,12 +402,13 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
|
||||
}
|
||||
|
||||
var timeout = 5000;
|
||||
var controlParam = getTransferParam(0, 128, 0, 0)
|
||||
var controlParam = getTransferParam(0, (usb.USB_REQUEST_DIR_FROM_DEVICE << 7)
|
||||
| (usb.USB_REQUEST_TYPE_STANDARD << 5) | (usb.USB_REQUEST_TARGET_DEVICE & 0x1f), 0, 0)
|
||||
callControlTransfer(testParam.pip, controlParam, timeout, 'control_transfer_test_02 GetStatus')
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : control_transfer_test_03
|
||||
* @tc.number : SUB_USB_control_transfer_test_03
|
||||
* @tc.name : controlTransfer
|
||||
* @tc.desc : 控制传输 GetConfiguration: cmd 8 reqType 128 value 0 index 0
|
||||
*/
|
||||
@@ -422,12 +421,13 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
|
||||
}
|
||||
|
||||
var timeout = 5000;
|
||||
var controlParam = getTransferParam(8, 128, 0, 0)
|
||||
var controlParam = getTransferParam(8, (usb.USB_REQUEST_DIR_FROM_DEVICE << 7)
|
||||
| (usb.USB_REQUEST_TYPE_STANDARD << 5) | (usb.USB_REQUEST_TARGET_DEVICE & 0x1f), 0, 0)
|
||||
callControlTransfer(testParam.pip, controlParam, timeout, 'control_transfer_test_03 GetConfiguration')
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : control_transfer_test_04
|
||||
* @tc.number : SUB_USB_control_transfer_test_04
|
||||
* @tc.name : controlTransfer
|
||||
* @tc.desc : 控制传输 GetInterface: cmd 10 reqType 129 value 0 index 1
|
||||
*/
|
||||
@@ -440,12 +440,13 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
|
||||
}
|
||||
|
||||
var timeout = 5000;
|
||||
var controlParam = getTransferParam(10, 129, 0, 1)
|
||||
var controlParam = getTransferParam(10, (usb.USB_REQUEST_DIR_FROM_DEVICE << 7)
|
||||
| (usb.USB_REQUEST_TYPE_STANDARD << 5) | (usb.USB_REQUEST_TARGET_INTERFACE & 0x1f), 0, 1)
|
||||
callControlTransfer(testParam.pip, controlParam, timeout, 'control_transfer_test_04 GetInterface')
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : control_transfer_test_05
|
||||
* @tc.number : SUB_USB_control_transfer_test_05
|
||||
* @tc.name : controlTransfer
|
||||
* @tc.desc : 控制传输 ClearFeature: cmd 1 reqType 0 value 0 index 0
|
||||
*/
|
||||
@@ -458,8 +459,85 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
|
||||
}
|
||||
|
||||
var timeout = 5000;
|
||||
var controlParam = getTransferParam(1, 0, 0, 0)
|
||||
var controlParam = getTransferParam(1, (usb.USB_REQUEST_DIR_TO_DEVICE << 7)
|
||||
| (usb.USB_REQUEST_TYPE_STANDARD << 5) | (usb.USB_REQUEST_TARGET_DEVICE & 0x1f), 0, 0)
|
||||
callControlTransfer(testParam.pip, controlParam, timeout, 'control_transfer_test_05 ClearFeature')
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_USB_control_transfer_test_06
|
||||
* @tc.name : controlTransfer
|
||||
* @tc.desc : 控制传输 ClearFeature: cmd 1 reqType 0 value 0 index 0
|
||||
*/
|
||||
it('SUB_USB_control_transfer_test_06', 0, function () {
|
||||
console.info('usb control_transfer_test_06 begin');
|
||||
var testParam = getTransferTestParam()
|
||||
if (testParam.inEndpoint == null || testParam.interface == null || testParam.outEndpoint == null) {
|
||||
expect(false).assertTrue();
|
||||
return
|
||||
}
|
||||
|
||||
var timeout = 5000;
|
||||
var controlParam = getTransferParam(255, (usb.USB_REQUEST_DIR_FROM_DEVICE << 7)
|
||||
| (usb.USB_REQUEST_TYPE_STANDARD << 5) | (usb.USB_REQUEST_TARGET_INTERFACE & 0x1f), (2 << 8), 0)
|
||||
callControlTransfer(testParam.pip, controlParam, timeout, 'control_transfer_test_06 ClearFeature')
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_USB_control_transfer_test_07
|
||||
* @tc.name : controlTransfer
|
||||
* @tc.desc : 控制传输 ClearFeature: cmd 1 reqType 0 value 0 index 0
|
||||
*/
|
||||
it('SUB_USB_control_transfer_test_07', 0, function () {
|
||||
console.info('usb control_transfer_test_07 begin');
|
||||
var testParam = getTransferTestParam()
|
||||
if (testParam.inEndpoint == null || testParam.interface == null || testParam.outEndpoint == null) {
|
||||
expect(false).assertTrue();
|
||||
return
|
||||
}
|
||||
|
||||
var timeout = 5000;
|
||||
var controlParam = getTransferParam(255, (usb.USB_REQUEST_DIR_TO_DEVICE << 7)
|
||||
| (usb.USB_REQUEST_TYPE_CLASS << 5) | (usb.USB_REQUEST_TARGET_ENDPOINT & 0x1f), (2 << 8), 0)
|
||||
callControlTransfer(testParam.pip, controlParam, timeout, 'control_transfer_test_07 ClearFeature')
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_USB_control_transfer_test_08
|
||||
* @tc.name : controlTransfer
|
||||
* @tc.desc : 控制传输 ClearFeature: cmd 1 reqType 0 value 0 index 0
|
||||
*/
|
||||
it('SUB_USB_control_transfer_test_08', 0, function () {
|
||||
console.info('usb control_transfer_test_08 begin');
|
||||
var testParam = getTransferTestParam()
|
||||
if (testParam.inEndpoint == null || testParam.interface == null || testParam.outEndpoint == null) {
|
||||
expect(false).assertTrue();
|
||||
return
|
||||
}
|
||||
|
||||
var timeout = 5000;
|
||||
var controlParam = getTransferParam(255, (usb.USB_REQUEST_DIR_TO_DEVICE << 7)
|
||||
| (usb.USB_REQUEST_TYPE_VENDOR << 5) | (usb.USB_REQUEST_TARGET_OTHER & 0x1f), (2 << 8), 0)
|
||||
callControlTransfer(testParam.pip, controlParam, timeout, 'control_transfer_test_08 ClearFeature')
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_USB_control_transfer_test_09
|
||||
* @tc.name : controlTransfer
|
||||
* @tc.desc : 控制传输 ClearFeature: cmd 1 reqType 0 value 0 index 0
|
||||
*/
|
||||
it('SUB_USB_control_transfer_test_09', 0, function () {
|
||||
console.info('usb control_transfer_test_09 begin');
|
||||
var testParam = getTransferTestParam()
|
||||
if (testParam.inEndpoint == null || testParam.interface == null || testParam.outEndpoint == null) {
|
||||
expect(false).assertTrue();
|
||||
return
|
||||
}
|
||||
|
||||
var timeout = 5000;
|
||||
var controlParam = getTransferParam(255, (usb.USB_REQUEST_DIR_TO_DEVICE << 7)
|
||||
| (usb.USB_REQUEST_TYPE_CLASS << 5) | (usb.USB_REQUEST_TARGET_OTHER & 0x1f), 0, 0)
|
||||
callControlTransfer(testParam.pip, controlParam, timeout, 'control_transfer_test_09 ClearFeature')
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
@@ -28,11 +28,11 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
|
||||
var Version = usb.getVersion()
|
||||
console.info('usb unit begin test getversion :' + Version)
|
||||
|
||||
// 切换为host
|
||||
// version > 17 host currentMode = 2 device currentMode = 1
|
||||
var usbPortList = usb.getPorts()
|
||||
if (usbPortList.length > 0) {
|
||||
if (usbPortList[0].status.currentMode == 1) {
|
||||
usb.setPortRoles(usbPortList[0].id, 1, 1).then(data => {
|
||||
usb.setPortRoles(usbPortList[0].id, usb.SOURCE, usb.HOST).then(data => {
|
||||
console.info('usb case setPortRoles return: ' + data);
|
||||
}).catch(error => {
|
||||
console.info('usb case setPortRoles error : ' + error);
|
||||
@@ -66,10 +66,10 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
|
||||
if (endpoint.type == EventConstants.USB_ENDPOINT_XFER_BULK) {
|
||||
|
||||
bfind = true
|
||||
if (endpoint.direction == EventConstants.USB_ENDPOINT_DIR_OUT) {
|
||||
if (endpoint.direction == usb.USB_REQUEST_DIR_TO_DEVICE) {
|
||||
testParam.outEndpoint = endpoint;
|
||||
testParam.maxOutSize = endpoint.maxPacketSize;
|
||||
} else if (endpoint.direction == EventConstants.USB_ENDPOINT_DIR_IN) {
|
||||
} else if (endpoint.direction == usb.USB_REQUEST_DIR_FROM_DEVICE) {
|
||||
testParam.inEndpoint = endpoint
|
||||
testParam.maxInSize = endpoint.maxPacketSize;
|
||||
}
|
||||
@@ -133,7 +133,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number : bulk_transfer_test_03
|
||||
* @tc.number : SUB_USB_bulk_transfer_test_03
|
||||
* @tc.name : bulkTransfer
|
||||
* @tc.desc : 反向测试 批量传输 发数据 修改 outEndpoint.address = 123
|
||||
*/
|
||||
@@ -145,8 +145,6 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
|
||||
return
|
||||
}
|
||||
|
||||
testParam.isClaimed = usb.releaseInterface(testParam.pip, testParam.interface)
|
||||
expect(testParam.isClaimed).assertEqual(0);
|
||||
testParam.isClaimed = usb.claimInterface(testParam.pip, testParam.interface, true);
|
||||
expect(testParam.isClaimed).assertEqual(0);
|
||||
|
||||
@@ -160,13 +158,13 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
|
||||
expect(data).assertEqual(-1);
|
||||
}).catch(error => {
|
||||
console.info('usb 03 write error : ' + JSON.stringify(error));
|
||||
console.info('usb case bulk_transfer_test_03 : PASS');
|
||||
expect(false).assertFalse();
|
||||
console.info('usb case bulk_transfer_test_03 : PASS');
|
||||
});
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : bulk_transfer_test_04
|
||||
* @tc.number : SUB_USB_bulk_transfer_test_04
|
||||
* @tc.name : bulkTransfer
|
||||
* @tc.desc : 反向测试 批量传输 发数据 修改 outEndpoint.number = 123
|
||||
*/
|
||||
@@ -178,8 +176,6 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
|
||||
return
|
||||
}
|
||||
|
||||
testParam.isClaimed = usb.releaseInterface(testParam.pip, testParam.interface)
|
||||
expect(testParam.isClaimed).assertEqual(0);
|
||||
testParam.isClaimed = usb.claimInterface(testParam.pip, testParam.interface, true);
|
||||
expect(testParam.isClaimed).assertEqual(0);
|
||||
|
||||
@@ -193,13 +189,13 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
|
||||
expect(data).assertEqual(-1);
|
||||
}).catch(error => {
|
||||
console.info('usb 04 write error : ' + JSON.stringify(error));
|
||||
console.info('usb case bulk_transfer_test_04 : PASS');
|
||||
expect(false).assertFalse();
|
||||
console.info('usb case bulk_transfer_test_04 : PASS');
|
||||
});
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : bulk_transfer_test_05
|
||||
* @tc.number : SUB_USB_bulk_transfer_test_05
|
||||
* @tc.name : bulkTransfer
|
||||
* @tc.desc : 反向测试 批量传输 发数据 修改 outEndpoint.type = 123
|
||||
*/
|
||||
@@ -211,8 +207,6 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
|
||||
return
|
||||
}
|
||||
|
||||
testParam.isClaimed = usb.releaseInterface(testParam.pip, testParam.interface)
|
||||
expect(testParam.isClaimed).assertEqual(0);
|
||||
testParam.isClaimed = usb.claimInterface(testParam.pip, testParam.interface, true);
|
||||
expect(testParam.isClaimed).assertEqual(0);
|
||||
|
||||
@@ -226,13 +220,13 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
|
||||
expect(data).assertEqual(-1);
|
||||
}).catch(error => {
|
||||
console.info('usb 05 write error : ' + JSON.stringify(error));
|
||||
console.info('usb case bulk_transfer_test_05 : PASS');
|
||||
expect(false).assertFalse();
|
||||
console.info('usb case bulk_transfer_test_05 : PASS');
|
||||
});
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : claim_interface_test_02
|
||||
* @tc.number : SUB_USB_claim_interface_test_02
|
||||
* @tc.name : claimInterface
|
||||
* @tc.desc : 反向测试 USBInterface传入异常id 获取接口 失败
|
||||
*/
|
||||
@@ -268,7 +262,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : claim_interface_test_03
|
||||
* @tc.number : SUB_USB_claim_interface_test_03
|
||||
* @tc.name : claimInterface
|
||||
* @tc.desc : 反向测试 USBInterface传入异常protocol 获取接口 失败
|
||||
*/
|
||||
@@ -304,7 +298,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : claim_interface_test_04
|
||||
* @tc.number : SUB_USB_claim_interface_test_04
|
||||
* @tc.name : claimInterface
|
||||
* @tc.desc : 反向测试 USBInterface传入异常clazz 获取接口 失败
|
||||
*/
|
||||
@@ -340,7 +334,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : claim_interface_test_05
|
||||
* @tc.number : SUB_USB_claim_interface_test_05
|
||||
* @tc.name : claimInterface
|
||||
* @tc.desc : 反向测试 USBInterface传入异常name 获取接口 失败
|
||||
*/
|
||||
@@ -376,7 +370,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : claim_interface_test_06
|
||||
* @tc.number : SUB_USB_claim_interface_test_06
|
||||
* @tc.name : claimInterface
|
||||
* @tc.desc : 反向测试 USBInterface传入异常subClass 获取接口 失败
|
||||
*/
|
||||
@@ -412,7 +406,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : release_interface_test_01
|
||||
* @tc.number : SUB_USB_release_interface_test_01
|
||||
* @tc.name : releaseInterface
|
||||
* @tc.desc : 反向测试 获取接口 release传入Interface的错误ID 并释放
|
||||
*/
|
||||
@@ -429,7 +423,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
|
||||
expect(false).assertTrue();
|
||||
return
|
||||
}
|
||||
|
||||
gPipe = usb.connectDevice(gDeviceList[0])
|
||||
for (var j = 0; j < gDeviceList[0].configs.length; j++) {
|
||||
if (gDeviceList[0].configs[j].interfaces.length == 0) {
|
||||
console.info('usb 01 case current device.configs.interfaces.length = 0');
|
||||
@@ -448,7 +442,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : release_interface_test_02
|
||||
* @tc.number : SUB_USB_release_interface_test_02
|
||||
* @tc.name : releaseInterface
|
||||
* @tc.desc : 反向测试 获取接口 release传入Interface的错误name 并释放
|
||||
*/
|
||||
@@ -465,7 +459,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
|
||||
expect(false).assertTrue();
|
||||
return
|
||||
}
|
||||
|
||||
gPipe = usb.connectDevice(gDeviceList[0])
|
||||
for (var j = 0; j < gDeviceList[0].configs.length; j++) {
|
||||
if (gDeviceList[0].configs[j].interfaces.length == 0) {
|
||||
console.info('usb 02 case current device.configs.interfaces.length = 0');
|
||||
@@ -484,7 +478,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : release_interface_test_03
|
||||
* @tc.number : SUB_USB_release_interface_test_03
|
||||
* @tc.name : releaseInterface
|
||||
* @tc.desc : 反向测试 获取接口 release传入Interface的错误clazz 并释放
|
||||
*/
|
||||
@@ -501,7 +495,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
|
||||
expect(false).assertTrue();
|
||||
return
|
||||
}
|
||||
|
||||
gPipe = usb.connectDevice(gDeviceList[0])
|
||||
for (var j = 0; j < gDeviceList[0].configs.length; j++) {
|
||||
if (gDeviceList[0].configs[j].interfaces.length == 0) {
|
||||
console.info('usb 03 case current device.configs.interfaces.length = 0');
|
||||
@@ -520,7 +514,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : release_interface_test_04
|
||||
* @tc.number : SUB_USB_release_interface_test_04
|
||||
* @tc.name : releaseInterface
|
||||
* @tc.desc : 反向测试 获取接口 release传入Interface的错误protocol 并释放
|
||||
*/
|
||||
@@ -537,7 +531,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
|
||||
expect(false).assertTrue();
|
||||
return
|
||||
}
|
||||
|
||||
gPipe = usb.connectDevice(gDeviceList[0])
|
||||
for (var j = 0; j < gDeviceList[0].configs.length; j++) {
|
||||
if (gDeviceList[0].configs[j].interfaces.length == 0) {
|
||||
console.info('usb 04 case current device.configs.interfaces.length = 0');
|
||||
@@ -556,7 +550,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : release_interface_test_05
|
||||
* @tc.number : SUB_USB_release_interface_test_05
|
||||
* @tc.name : releaseInterface
|
||||
* @tc.desc : 反向测试 获取接口 release传入Interface的错误subClass 并释放
|
||||
*/
|
||||
@@ -573,7 +567,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
|
||||
expect(false).assertTrue();
|
||||
return
|
||||
}
|
||||
|
||||
gPipe = usb.connectDevice(gDeviceList[0])
|
||||
for (var j = 0; j < gDeviceList[0].configs.length; j++) {
|
||||
if (gDeviceList[0].configs[j].interfaces.length == 0) {
|
||||
console.info('usb 05 case current device.configs.interfaces.length = 0');
|
||||
@@ -592,7 +586,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : set_interface_test_03
|
||||
* @tc.number : SUB_USB_set_interface_test_03
|
||||
* @tc.name : setInterface
|
||||
* @tc.desc : 反向测试 Interface的protocol 设置设备接口
|
||||
*/
|
||||
@@ -603,7 +597,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
|
||||
expect(false).assertTrue()
|
||||
return
|
||||
}
|
||||
|
||||
gPipe = usb.connectDevice(gDeviceList[0])
|
||||
for (var j = 0; j < gDeviceList[0].configs.length; j++) {
|
||||
var isClaimed = usb.claimInterface(gPipe, gDeviceList[0].configs[j].interfaces[0], true);
|
||||
|
||||
@@ -619,7 +613,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : set_interface_test_04
|
||||
* @tc.number : SUB_USB_set_interface_test_04
|
||||
* @tc.name : setInterface
|
||||
* @tc.desc : 反向测试 Interface的clazz 设置设备接口
|
||||
*/
|
||||
@@ -630,7 +624,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
|
||||
expect(false).assertTrue()
|
||||
return
|
||||
}
|
||||
|
||||
gPipe = usb.connectDevice(gDeviceList[0])
|
||||
for (var j = 0; j < gDeviceList[0].configs.length; j++) {
|
||||
var isClaim = usb.claimInterface(gPipe, gDeviceList[0].configs[j].interfaces[0], true)
|
||||
|
||||
@@ -647,7 +641,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : set_interface_test_05
|
||||
* @tc.number : SUB_USB_set_interface_test_05
|
||||
* @tc.name : setInterface
|
||||
* @tc.desc : 反向测试 Interface的subClass 设置设备接口
|
||||
*/
|
||||
@@ -658,7 +652,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
|
||||
expect(false).assertTrue()
|
||||
return
|
||||
}
|
||||
|
||||
gPipe = usb.connectDevice(gDeviceList[0])
|
||||
for (var j = 0; j < gDeviceList[0].configs.length; j++) {
|
||||
var isClaim = usb.claimInterface(gPipe, gDeviceList[0].configs[j].interfaces[0], true)
|
||||
|
||||
@@ -675,7 +669,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : set_interface_test_06
|
||||
* @tc.number : SUB_USB_set_interface_test_06
|
||||
* @tc.name : setInterface
|
||||
* @tc.desc : 反向测试 Interface的name 设置设备接口
|
||||
*/
|
||||
@@ -686,7 +680,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
|
||||
expect(false).assertTrue()
|
||||
return
|
||||
}
|
||||
|
||||
gPipe = usb.connectDevice(gDeviceList[0])
|
||||
for (var j = 0; j < gDeviceList[0].configs.length; j++) {
|
||||
var isClaim = usb.claimInterface(gPipe, gDeviceList[0].configs[j].interfaces[0], true)
|
||||
|
||||
@@ -702,7 +696,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : set_configuration_test_03
|
||||
* @tc.number : SUB_USB_set_configuration_test_03
|
||||
* @tc.name : setConfiguration
|
||||
* @tc.desc : 反向测试 USBConfig的name 赋值错误 设置设备接口
|
||||
*/
|
||||
@@ -713,7 +707,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
|
||||
expect(false).assertTrue();
|
||||
return
|
||||
}
|
||||
|
||||
gPipe = usb.connectDevice(gDeviceList[0])
|
||||
for (var j = 0; j < gDeviceList[0].configs.length; j++) {
|
||||
var config = gDeviceList[0].configs[j]
|
||||
config.name = 'asdfsd'
|
||||
@@ -726,7 +720,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : set_configuration_test_04
|
||||
* @tc.number : SUB_USB_set_configuration_test_04
|
||||
* @tc.name : setConfiguration
|
||||
* @tc.desc : 反向测试 USBConfig的name 赋值错误 设置设备接口
|
||||
*/
|
||||
@@ -751,7 +745,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : set_configuration_test_05
|
||||
* @tc.number : SUB_USB_set_configuration_test_05
|
||||
* @tc.name : setConfiguration
|
||||
* @tc.desc : 反向测试 USBConfig的attributes 赋值错误 设置设备接口
|
||||
*/
|
||||
|
||||
@@ -24,12 +24,11 @@ describe('UsbFunctionsJsFunctionsTest', function () {
|
||||
console.log('*************Usb Unit UsbFunctionsJsFunctionsTest Begin*************');
|
||||
var Version = usb.getVersion()
|
||||
console.info('begin test getversion :' + Version)
|
||||
// 切换到 device
|
||||
// version > 17 host currentMode = 2 device currentMode = 1
|
||||
var usbPortList = usb.getPorts()
|
||||
if (usbPortList.length > 0) {
|
||||
if (usbPortList[0].status.currentMode == 2) {
|
||||
console.info('usb case set data role 1, data role 1');
|
||||
usb.setPortRoles(usbPortList[0].id, 2, 2).then(data => {
|
||||
usb.setPortRoles(usbPortList[0].id, usb.SINK, usb.DEVICE).then(data => {
|
||||
console.info('usb case setPortRoles return: ' + data);
|
||||
}).catch(error => {
|
||||
console.info('usb case setPortRoles error : ' + error);
|
||||
@@ -49,7 +48,7 @@ describe('UsbFunctionsJsFunctionsTest', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : get_current_functions_test_01
|
||||
* @tc.number : SUB_USB_get_current_functions_test_01
|
||||
* @tc.name : getCurrentFunctions
|
||||
* @tc.desc : 获取当前设备模式 掩码与描述字符转换
|
||||
*/
|
||||
@@ -68,7 +67,7 @@ describe('UsbFunctionsJsFunctionsTest', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : get_current_functions_test_02
|
||||
* @tc.number : SUB_USB_get_current_functions_test_02
|
||||
* @tc.name : usbFunctionString
|
||||
* @tc.desc : 反向测试 获取当前设备模式 掩码与描述字符转换
|
||||
*/
|
||||
@@ -89,7 +88,7 @@ describe('UsbFunctionsJsFunctionsTest', function () {
|
||||
|
||||
var errStrMaskCode = 'none'
|
||||
var nMaskCode = usb.usbFunctionsFromString(errStrMaskCode)
|
||||
expect(nMaskCode).assertEqual(0);
|
||||
expect(nMaskCode).assertEqual(usb.NONE);
|
||||
console.info('usb case errStrMaskCode ' + errStrMaskCode +
|
||||
' usbFunctionsFromString return int: ' + nMaskCode);
|
||||
|
||||
@@ -111,7 +110,7 @@ describe('UsbFunctionsJsFunctionsTest', function () {
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number : set_current_functions_test_02
|
||||
* @tc.number : SUB_USB_set_current_functions_test_02
|
||||
* @tc.name : functions_test
|
||||
* @tc.desc : 在设备模式下设置当前的USB功能列表 Set 1 设置为ACM功能
|
||||
*/
|
||||
@@ -122,11 +121,11 @@ describe('UsbFunctionsJsFunctionsTest', function () {
|
||||
console.info('usb case getCurrentFunctions return: ' + maskCode);
|
||||
var funcString = usb.usbFunctionsToString(maskCode);
|
||||
console.info('usb case funcString:' + funcString);
|
||||
callSetCurFunction('set_current_functions_test_02 ACM 1', 1)
|
||||
callSetCurFunction('set_current_functions_test_02 ACM 1', usb.ACM)
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : set_current_functions_test_03
|
||||
* @tc.number : SUB_USB_set_current_functions_test_03
|
||||
* @tc.name : functions_test
|
||||
* @tc.desc : 在设备模式下设置当前的USB功能列表 Set 2 设置为ECM功能
|
||||
*/
|
||||
@@ -137,11 +136,11 @@ describe('UsbFunctionsJsFunctionsTest', function () {
|
||||
console.info('usb case getCurrentFunctions return: ' + maskCode);
|
||||
var funcString = usb.usbFunctionsToString(maskCode);
|
||||
console.info('usb case funcString:' + funcString);
|
||||
callSetCurFunction('set_current_functions_test_03 ECM 2', 2)
|
||||
callSetCurFunction('set_current_functions_test_03 ECM 2', usb.ECM)
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : set_current_functions_test_04
|
||||
* @tc.number : SUB_USB_set_current_functions_test_04
|
||||
* @tc.name : functions_test
|
||||
* @tc.desc : 在设备模式下设置当前的USB功能列表 Set 3 设置为ACM、ECM功能
|
||||
*/
|
||||
@@ -152,11 +151,11 @@ describe('UsbFunctionsJsFunctionsTest', function () {
|
||||
console.info('usb case getCurrentFunctions return: ' + maskCode);
|
||||
var funcString = usb.usbFunctionsToString(maskCode);
|
||||
console.info('usb case funcString:' + funcString);
|
||||
callSetCurFunction('set_current_functions_test_04 ACM ECM 3', 3)
|
||||
callSetCurFunction('set_current_functions_test_04 ACM ECM 3', (usb.ACM | usb.ECM))
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : set_current_functions_test_05
|
||||
* @tc.number : SUB_USB_set_current_functions_test_05
|
||||
* @tc.name : functions_test
|
||||
* @tc.desc : 在设备模式下设置当前的USB功能列表 Set 4 设置为HDC功能
|
||||
*/
|
||||
@@ -167,11 +166,11 @@ describe('UsbFunctionsJsFunctionsTest', function () {
|
||||
console.info('usb case getCurrentFunctions return: ' + maskCode);
|
||||
var funcString = usb.usbFunctionsToString(maskCode);
|
||||
console.info('usb case funcString:' + funcString);
|
||||
callSetCurFunction('set_current_functions_test_05 HDC 4', 4)
|
||||
callSetCurFunction('set_current_functions_test_05 HDC 4', usb.HDC)
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : set_current_functions_test_06
|
||||
* @tc.number : SUB_USB_set_current_functions_test_06
|
||||
* @tc.name : functions_test
|
||||
* @tc.desc : 在设备模式下设置当前的USB功能列表 Set 5 设置为ACM、HDC功能
|
||||
*/
|
||||
@@ -182,11 +181,11 @@ describe('UsbFunctionsJsFunctionsTest', function () {
|
||||
console.info('usb case getCurrentFunctions return: ' + maskCode);
|
||||
var funcString = usb.usbFunctionsToString(maskCode);
|
||||
console.info('usb case funcString:' + funcString);
|
||||
callSetCurFunction('set_current_functions_test_06 ACM HDC 5', 5)
|
||||
callSetCurFunction('set_current_functions_test_06 ACM HDC 5', (usb.HDC | usb.ACM))
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : set_current_functions_test_07
|
||||
* @tc.number : SUB_USB_set_current_functions_test_07
|
||||
* @tc.name : functions_test
|
||||
* @tc.desc : 在设备模式下设置当前的USB功能列表 Set 6 设置为ECM、HDC功能
|
||||
*/
|
||||
@@ -197,7 +196,7 @@ describe('UsbFunctionsJsFunctionsTest', function () {
|
||||
console.info('usb case getCurrentFunctions return: ' + maskCode);
|
||||
var funcString = usb.usbFunctionsToString(maskCode);
|
||||
console.info('usb case funcString:' + funcString);
|
||||
callSetCurFunction('set_current_functions_test_07 ECM HDC 6', 6)
|
||||
callSetCurFunction('set_current_functions_test_07 ECM HDC 6', (usb.HDC | usb.ECM))
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
@@ -23,13 +23,11 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
|
||||
console.log('*************Usb Unit UsbFunctionsJsFunctionsTestEx Begin*************');
|
||||
var Version = usb.getVersion()
|
||||
console.info('begin test getversion :' + Version)
|
||||
|
||||
// 切换到 device
|
||||
// 17 version host currentMode = 2 device currentMode = 1
|
||||
var usbPortList = usb.getPorts()
|
||||
if (usbPortList.length > 0) {
|
||||
if (usbPortList[0].status.currentMode == 2) {
|
||||
console.info('usb case set data role 1, data role 1');
|
||||
usb.setPortRoles(usbPortList[0].id, 2, 2).then(data => {
|
||||
usb.setPortRoles(usbPortList[0].id, usb.SINK, usb.DEVICE).then(data => {
|
||||
console.info('usb case setPortRoles return: ' + data);
|
||||
}).catch(error => {
|
||||
console.info('usb case setPortRoles error : ' + error);
|
||||
@@ -52,13 +50,14 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : usb_function_to_string_test_01
|
||||
* @tc.number : SUB_USB_usb_function_to_string_test_01
|
||||
* @tc.name : usbFunctionsToString
|
||||
* @tc.desc : 正向测试 0 返回 'none'
|
||||
*/
|
||||
it('SUB_USB_usb_function_to_string_test_01', 0, function () {
|
||||
console.info('usb usb_function_to_string_test_01 begin');
|
||||
var maskCode = 0
|
||||
var maskCode = usb.NONE
|
||||
console.info('usb case maskCode : ' + usb.NONE);
|
||||
var strMaskCode = usb.usbFunctionsToString(maskCode)
|
||||
expect(strMaskCode).assertEqual('none');
|
||||
console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode);
|
||||
@@ -66,13 +65,14 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : usb_function_to_string_test_02
|
||||
* @tc.number : SUB_USB_usb_function_to_string_test_02
|
||||
* @tc.name : usbFunctionsToString
|
||||
* @tc.desc : 正向测试 1 返回 'acm'
|
||||
*/
|
||||
it('SUB_USB_usb_function_to_string_test_02', 0, function () {
|
||||
console.info('usb usb_function_to_string_test_02 begin');
|
||||
var maskCode = 1
|
||||
var maskCode = usb.ACM
|
||||
console.info('usb case maskCode : ' + usb.ACM);
|
||||
var strMaskCode = usb.usbFunctionsToString(maskCode)
|
||||
expect(strMaskCode).assertEqual('acm');
|
||||
console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode);
|
||||
@@ -80,13 +80,14 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : usb_function_to_string_test_03
|
||||
* @tc.number : SUB_USB_usb_function_to_string_test_03
|
||||
* @tc.name : usbFunctionsToString
|
||||
* @tc.desc : 正向测试 2 返回 'ecm'
|
||||
*/
|
||||
it('SUB_USB_usb_function_to_string_test_03', 0, function () {
|
||||
console.info('usb usb_function_to_string_test_02 begin');
|
||||
var maskCode = 2
|
||||
var maskCode = usb.ECM
|
||||
console.info('usb case maskCode : ' + maskCode);
|
||||
var strMaskCode = usb.usbFunctionsToString(maskCode)
|
||||
expect(strMaskCode).assertEqual('ecm');
|
||||
console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode);
|
||||
@@ -94,13 +95,14 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : usb_function_to_string_test_04
|
||||
* @tc.number : SUB_USB_usb_function_to_string_test_04
|
||||
* @tc.name : usbFunctionsToString
|
||||
* @tc.desc : 正向测试 3 返回 'acm,ecm'
|
||||
*/
|
||||
it('SUB_USB_usb_function_to_string_test_04', 0, function () {
|
||||
console.info('usb usb_function_to_string_test_02 begin');
|
||||
var maskCode = 3
|
||||
var maskCode = usb.ACM | usb.ECM
|
||||
console.info('usb case maskCode : ' + maskCode);
|
||||
var strMaskCode = usb.usbFunctionsToString(maskCode)
|
||||
expect(strMaskCode).assertEqual('acm,ecm');
|
||||
console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode);
|
||||
@@ -108,13 +110,14 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : usb_function_to_string_test_05
|
||||
* @tc.number : SUB_USB_usb_function_to_string_test_05
|
||||
* @tc.name : usbFunctionsToString
|
||||
* @tc.desc : 正向测试 4 返回 'hdc'
|
||||
*/
|
||||
it('SUB_USB_usb_function_to_string_test_05', 0, function () {
|
||||
console.info('usb usb_function_to_string_test_05 begin');
|
||||
var maskCode = 4
|
||||
var maskCode = usb.HDC
|
||||
console.info('usb case maskCode : ' + maskCode);
|
||||
var strMaskCode = usb.usbFunctionsToString(maskCode)
|
||||
expect(strMaskCode).assertEqual('hdc');
|
||||
console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode);
|
||||
@@ -122,13 +125,14 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : usb_function_to_string_test_06
|
||||
* @tc.number : SUB_USB_usb_function_to_string_test_06
|
||||
* @tc.name : usbFunctionsToString
|
||||
* @tc.desc : 正向测试 5 返回 'acm,hdc'
|
||||
*/
|
||||
it('SUB_USB_usb_function_to_string_test_06', 0, function () {
|
||||
console.info('usb usb_function_to_string_test_06 begin');
|
||||
var maskCode = 5
|
||||
var maskCode = usb.ACM | usb.HDC
|
||||
console.info('usb case maskCode : ' + maskCode);
|
||||
var strMaskCode = usb.usbFunctionsToString(maskCode)
|
||||
expect(strMaskCode).assertEqual('hdc,acm');
|
||||
console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode);
|
||||
@@ -136,13 +140,14 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : usb_function_to_string_test_07
|
||||
* @tc.number : SUB_USB_usb_function_to_string_test_07
|
||||
* @tc.name : usbFunctionsToString
|
||||
* @tc.desc : 正向测试 6 返回 'ecm,hdc'
|
||||
*/
|
||||
it('SUB_USB_usb_function_to_string_test_07', 0, function () {
|
||||
console.info('usb usb_function_to_string_test_07 begin');
|
||||
var maskCode = 6
|
||||
var maskCode = usb.ECM | usb.HDC
|
||||
console.info('usb case maskCode : ' + maskCode);
|
||||
var strMaskCode = usb.usbFunctionsToString(maskCode)
|
||||
expect(strMaskCode).assertEqual('hdc,ecm');
|
||||
console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode);
|
||||
@@ -150,7 +155,7 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : usb_function_from_string_test_01
|
||||
* @tc.number : SUB_USB_usb_function_from_string_test_01
|
||||
* @tc.name : usbFunctionsFromString
|
||||
* @tc.desc : 正向测试 'none' 返回 0
|
||||
*/
|
||||
@@ -158,13 +163,13 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
|
||||
console.info('usb usb_function_from_string_test_01 begin');
|
||||
var strMaskCode = 'none'
|
||||
var nMaskCode = usb.usbFunctionsFromString(strMaskCode)
|
||||
expect(nMaskCode).assertEqual(0);
|
||||
expect(nMaskCode).assertEqual(usb.NONE);
|
||||
console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode);
|
||||
console.info('usb usb_function_to_string_test_01 : PASS');
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : usb_function_from_string_test_02
|
||||
* @tc.number : SUB_USB_usb_function_from_string_test_02
|
||||
* @tc.name : usbFunctionsFromString
|
||||
* @tc.desc : 正向测试 'acm' 返回 1
|
||||
*/
|
||||
@@ -172,13 +177,13 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
|
||||
console.info('usb usb_function_from_string_test_02 begin');
|
||||
var strMaskCode = 'acm'
|
||||
var nMaskCode = usb.usbFunctionsFromString(strMaskCode)
|
||||
expect(nMaskCode).assertEqual(1);
|
||||
expect(nMaskCode).assertEqual(usb.ACM);
|
||||
console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode);
|
||||
console.info('usb usb_function_from_string_test_02 : PASS');
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : usb_function_from_string_test_03
|
||||
* @tc.number : SUB_USB_usb_function_from_string_test_03
|
||||
* @tc.name : usbFunctionsFromString
|
||||
* @tc.desc : 正向测试 'ecm' 返回 2
|
||||
*/
|
||||
@@ -186,13 +191,13 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
|
||||
console.info('usb usb_function_from_string_test_03 begin');
|
||||
var strMaskCode = 'ecm'
|
||||
var nMaskCode = usb.usbFunctionsFromString(strMaskCode)
|
||||
expect(nMaskCode).assertEqual(2);
|
||||
expect(nMaskCode).assertEqual(usb.ECM);
|
||||
console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode);
|
||||
console.info('usb usb_function_from_string_test_03 : PASS');
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : usb_function_from_string_test_04
|
||||
* @tc.number : SUB_USB_usb_function_from_string_test_04
|
||||
* @tc.name : usbFunctionsFromString
|
||||
* @tc.desc : 正向测试 'acm,ecm' 返回 3
|
||||
*/
|
||||
@@ -200,13 +205,13 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
|
||||
console.info('usb usb_function_from_string_test_04 begin');
|
||||
var strMaskCode = 'acm,ecm'
|
||||
var nMaskCode = usb.usbFunctionsFromString(strMaskCode)
|
||||
expect(nMaskCode).assertEqual(3);
|
||||
expect(nMaskCode).assertEqual(usb.ACM | usb.ECM);
|
||||
console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode);
|
||||
console.info('usb usb_function_from_string_test_04 : PASS');
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : usb_function_from_string_test_05
|
||||
* @tc.number : SUB_USB_usb_function_from_string_test_05
|
||||
* @tc.name : usbFunctionsFromString
|
||||
* @tc.desc : 正向测试 'hdc' 返回 4
|
||||
*/
|
||||
@@ -214,13 +219,13 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
|
||||
console.info('usb usb_function_from_string_test_05 begin');
|
||||
var strMaskCode = 'hdc'
|
||||
var nMaskCode = usb.usbFunctionsFromString(strMaskCode)
|
||||
expect(nMaskCode).assertEqual(4);
|
||||
expect(nMaskCode).assertEqual(usb.HDC);
|
||||
console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode);
|
||||
console.info('usb usb_function_from_string_test_04 : PASS');
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : usb_function_from_string_test_06
|
||||
* @tc.number : SUB_USB_usb_function_from_string_test_06
|
||||
* @tc.name : usbFunctionsFromString
|
||||
* @tc.desc : 正向测试 'acm,hdc' 返回 5
|
||||
*/
|
||||
@@ -228,13 +233,13 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
|
||||
console.info('usb usb_function_from_string_test_06 begin');
|
||||
var strMaskCode = 'acm,hdc'
|
||||
var nMaskCode = usb.usbFunctionsFromString(strMaskCode)
|
||||
expect(nMaskCode).assertEqual(5);
|
||||
expect(nMaskCode).assertEqual(usb.HDC | usb.ACM);
|
||||
console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode);
|
||||
console.info('usb usb_function_from_string_test_06 : PASS');
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : usb_function_from_string_test_07
|
||||
* @tc.number : SUB_USB_usb_function_from_string_test_07
|
||||
* @tc.name : usbFunctionsFromString
|
||||
* @tc.desc : 正向测试 'ecm,hdc' 返回 6
|
||||
*/
|
||||
@@ -242,7 +247,7 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
|
||||
console.info('usb usb_function_from_string_test_07 begin');
|
||||
var strMaskCode = 'ecm,hdc'
|
||||
var nMaskCode = usb.usbFunctionsFromString(strMaskCode)
|
||||
expect(nMaskCode).assertEqual(6);
|
||||
expect(nMaskCode).assertEqual(usb.HDC | usb.ECM);
|
||||
console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode);
|
||||
console.info('usb usb_function_from_string_test_07 : PASS');
|
||||
})
|
||||
|
||||
@@ -36,7 +36,7 @@ describe('UsbPortJsFunctionsTest', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : get_ports_test_01
|
||||
* @tc.number : SUB_USB_get_ports_test_01
|
||||
* @tc.name : getPorts
|
||||
* @tc.desc : 获取USB端口描述信息列表
|
||||
*/
|
||||
@@ -54,7 +54,7 @@ describe('UsbPortJsFunctionsTest', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : get_supported_modes_test_01
|
||||
* @tc.number : SUB_USB_get_supported_modes_test_01
|
||||
* @tc.name : getSupportedModes
|
||||
* @tc.desc : 获取指定的端口支持的模式列表的组合掩码
|
||||
*/
|
||||
@@ -78,7 +78,7 @@ describe('UsbPortJsFunctionsTest', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : set_port_roles_test_01
|
||||
* @tc.number : SUB_USB_set_port_roles_test_01
|
||||
* @tc.name : setPortRoles
|
||||
* @tc.desc : 切换为Device set powerRole 2 DataRole 2
|
||||
*/
|
||||
@@ -93,7 +93,7 @@ describe('UsbPortJsFunctionsTest', function () {
|
||||
|
||||
for (var i = 0; i < usbPortList.length; i++) {
|
||||
console.info('usb case set data role 2, data role 2');
|
||||
usb.setPortRoles(usbPortList[i].id, 2, 2).then(data => {
|
||||
usb.setPortRoles(usbPortList[i].id, usb.SINK, usb.DEVICE).then(data => {
|
||||
console.info('usb case setPortRoles return: ' + data);
|
||||
expect(data).assertTrue();
|
||||
}).catch(error => {
|
||||
@@ -107,7 +107,7 @@ describe('UsbPortJsFunctionsTest', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : set_port_roles_test_02
|
||||
* @tc.number : SUB_USB_set_port_roles_test_02
|
||||
* @tc.name : setPortRoles
|
||||
* @tc.desc : 切换为host set powerRole 1 DataRole 1
|
||||
*/
|
||||
@@ -123,7 +123,7 @@ describe('UsbPortJsFunctionsTest', function () {
|
||||
for (var i = 0; i < usbPortList.length; i++) {
|
||||
console.info('usb case set data role 1, data role 1');
|
||||
CheckEmptyUtils.sleep(5000)
|
||||
usb.setPortRoles(usbPortList[i].id, 1, 1).then(data => {
|
||||
usb.setPortRoles(usbPortList[i].id, usb.SOURCE, usb.HOST).then(data => {
|
||||
expect(data).assertTrue();
|
||||
console.info('usb case setPortRoles return: ' + data);
|
||||
}).catch(error => {
|
||||
|
||||
@@ -20,6 +20,7 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from
|
||||
/* usb core functions test */
|
||||
describe('UsbPortJsFunctionsTestEx', function () {
|
||||
|
||||
var gPort;
|
||||
beforeAll(function () {
|
||||
console.log('*************Usb Unit UsbPortJsFunctionsTestEx Begin*************');
|
||||
var Version = usb.getVersion()
|
||||
@@ -38,7 +39,7 @@ describe('UsbPortJsFunctionsTestEx', function () {
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : get_supported_modes_test_02
|
||||
* @tc.number : SUB_USB_get_supported_modes_test_02
|
||||
* @tc.name : getSupportedModes
|
||||
* @tc.desc : 反向测试 改变id 获取指定的端口支持的模式列表的组合掩码
|
||||
*/
|
||||
@@ -52,336 +53,152 @@ describe('UsbPortJsFunctionsTestEx', function () {
|
||||
}
|
||||
|
||||
expect(usbPortList.length > 0).assertTrue();
|
||||
|
||||
gPort = usbPortList[0]
|
||||
var portID = usbPortList[0].id + 10
|
||||
var maskCode = usb.getSupportedModes(portID)
|
||||
expect(maskCode).assertEqual(0);
|
||||
expect(maskCode).assertEqual(usb.NONE);
|
||||
|
||||
console.info('usb get_supported_modes_test_02 : PASS');
|
||||
expect(true).assertTrue();
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : set_port_roles_test_03
|
||||
* @tc.number : SUB_USB_set_port_roles_test_03
|
||||
* @tc.name : setPortRoles
|
||||
* @tc.desc : Device模式下,dataRole参数错误
|
||||
* @tc.desc : dataRole参数错误
|
||||
*/
|
||||
it('SUB_USB_set_port_roles_test_03', 0, function () {
|
||||
var portId = 2;
|
||||
var powerRole = 2;
|
||||
var dataRole = -1;
|
||||
var portId = gPort.id;
|
||||
var powerRole = usb.SINK;
|
||||
var dataRole = usb.NONE - 1;
|
||||
CheckEmptyUtils.sleep(2000)
|
||||
usb.setPortRoles(2, 2, -1).then(data => {
|
||||
usb.setPortRoles(portId, powerRole, dataRole).then(data => {
|
||||
console.info('usb case setPortRoles return: ' + data);
|
||||
expect(data).assertTrue();
|
||||
}).catch(error => {
|
||||
console.info('usb case setPortRoles error : ' + error);
|
||||
expect(error).assertFalse();
|
||||
console.info('set_port_roles_test_03: PASS');
|
||||
console.info('usb set_port_roles_test_03: PASS');
|
||||
})
|
||||
|
||||
console.info('set_port_roles_test_03: PASS');
|
||||
console.info('usb set_port_roles_test_03: PASS');
|
||||
expect(true).assertTrue();
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : set_port_roles_test_04
|
||||
* @tc.number : SUB_USB_set_port_roles_test_04
|
||||
* @tc.name : setPortRoles
|
||||
* @tc.desc : Device模式下,portId,powerRole参数错误
|
||||
* @tc.desc : portId,powerRole参数错误
|
||||
*/
|
||||
it('SUB_USB_set_port_roles_test_04', 0, function () {
|
||||
var portId = -1;
|
||||
var powerRole = -1;
|
||||
var dataRole = 2;
|
||||
var portId = gPort.id;
|
||||
var powerRole = usb.NONE - 1;
|
||||
var dataRole = usb.DEVICE;
|
||||
CheckEmptyUtils.sleep(2000)
|
||||
usb.setPortRoles(-1, -1, 2).then(data => {
|
||||
usb.setPortRoles(portId, powerRole, dataRole).then(data => {
|
||||
console.info('usb case setPortRoles return: ' + data);
|
||||
expect(data).assertTrue();
|
||||
}).catch(error => {
|
||||
console.info('usb case setPortRoles error : ' + error);
|
||||
expect(error).assertFalse();
|
||||
console.info('set_port_roles_test_04: PASS');
|
||||
console.info('usb set_port_roles_test_04: PASS');
|
||||
})
|
||||
|
||||
console.info('set_port_roles_test_04: PASS');
|
||||
console.info('usb set_port_roles_test_04: PASS');
|
||||
expect(true).assertTrue();
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : set_port_roles_test_05
|
||||
* @tc.number : SUB_USB_set_port_roles_test_05
|
||||
* @tc.name : setPortRoles
|
||||
* @tc.desc : Device模式下,portId,dataRole参数错误
|
||||
* @tc.desc : portId,dataRole参数错误
|
||||
*/
|
||||
it('SUB_USB_set_port_roles_test_05', 0, function () {
|
||||
var portId = -1;
|
||||
var powerRole = 2;
|
||||
var dataRole = -1;
|
||||
var portId = gPort.id - 3;
|
||||
var powerRole = usb.SINK;
|
||||
var dataRole = usb.NONE - 1;
|
||||
CheckEmptyUtils.sleep(2000)
|
||||
usb.setPortRoles(-1, 2, -1).then(data => {
|
||||
usb.setPortRoles(portId, powerRole, dataRole).then(data => {
|
||||
console.info('usb case setPortRoles return: ' + data);
|
||||
expect(data).assertTrue();
|
||||
}).catch(error => {
|
||||
console.info('usb case setPortRoles error : ' + error);
|
||||
expect(error).assertFalse();
|
||||
console.info('set_port_roles_test_05: PASS');
|
||||
console.info('usb set_port_roles_test_05: PASS');
|
||||
})
|
||||
|
||||
console.info('set_port_roles_test_05: PASS');
|
||||
console.info('usb set_port_roles_test_05: PASS');
|
||||
expect(true).assertTrue();
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : set_port_roles_test_06
|
||||
* @tc.number : SUB_USB_set_port_roles_test_06
|
||||
* @tc.name : setPortRoles
|
||||
* @tc.desc : Device模式下,powerRole,dataRole参数错误
|
||||
* @tc.desc : powerRole,dataRole参数错误
|
||||
*/
|
||||
it('SUB_USB_set_port_roles_test_06', 0, function () {
|
||||
var portId = 2;
|
||||
var powerRole = -1;
|
||||
var dataRole = -1;
|
||||
var portId = gPort.id;
|
||||
var powerRole = usb.NONE - 1;
|
||||
var dataRole = usb.NONE - 1;
|
||||
CheckEmptyUtils.sleep(2000)
|
||||
usb.setPortRoles(2, -1, -1).then(data => {
|
||||
usb.setPortRoles(portId, powerRole, dataRole).then(data => {
|
||||
console.info('usb case setPortRoles return: ' + data);
|
||||
expect(data).assertTrue();
|
||||
}).catch(error => {
|
||||
console.info('usb case setPortRoles error : ' + error);
|
||||
expect(error).assertFalse();
|
||||
console.info('set_port_roles_test_06: PASS');
|
||||
console.info('usb set_port_roles_test_06: PASS');
|
||||
})
|
||||
|
||||
console.info('set_port_roles_test_06: PASS');
|
||||
console.info('usb set_port_roles_test_06: PASS');
|
||||
expect(true).assertTrue();
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : set_port_roles_test_07
|
||||
* @tc.number : SUB_USB_set_port_roles_test_07
|
||||
* @tc.name : setPortRoles
|
||||
* @tc.desc : Device模式下,portId,portId,dataRole参数错误
|
||||
* @tc.desc : portId,portId,dataRole参数错误
|
||||
*/
|
||||
it('SUB_USB_set_port_roles_test_07', 0, function () {
|
||||
var portId = -1;
|
||||
var dataRole = -1;
|
||||
var powerRole = -1;
|
||||
var portId = gPort.id - 1;
|
||||
var dataRole = usb.NONE - 1;
|
||||
var powerRole = usb.NONE - 1;
|
||||
|
||||
CheckEmptyUtils.sleep(2000)
|
||||
usb.setPortRoles(-1, -1, -1).then(data => {
|
||||
usb.setPortRoles(portId, powerRole, dataRole).then(data => {
|
||||
console.info('usb case setPortRoles 07 return: ' + data);
|
||||
expect(data).assertTrue();
|
||||
}).catch(error => {
|
||||
console.info('usb case setPortRoles 07 error : ' + error);
|
||||
expect(error).assertFalse();
|
||||
console.info('set_port_roles_test_07: PASS');
|
||||
console.info('usb set_port_roles_test_07: PASS');
|
||||
})
|
||||
|
||||
console.info('set_port_roles_test_07: PASS');
|
||||
console.info('usb set_port_roles_test_07: PASS');
|
||||
expect(true).assertTrue();
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : set_port_roles_test_08
|
||||
* @tc.number : SUB_USB_set_port_roles_test_08
|
||||
* @tc.name : setPortRoles
|
||||
* @tc.desc : host模式下,portId参数错误
|
||||
* @tc.desc : portId参数错误
|
||||
*/
|
||||
it('SUB_USB_set_port_roles_test_08', 0, function () {
|
||||
var portId = -1;
|
||||
var portId = gPort.id - 1;
|
||||
var powerRole = 1;
|
||||
var dataRole = 1;
|
||||
CheckEmptyUtils.sleep(2000)
|
||||
usb.setPortRoles(-1, 1, 1).then(data => {
|
||||
usb.setPortRoles(portId, powerRole, dataRole).then(data => {
|
||||
console.info('usb case setPortRoles return: ' + data);
|
||||
expect(data).assertTrue();
|
||||
}).catch(error => {
|
||||
console.info('usb case setPortRoles error : ' + error);
|
||||
expect(error).assertFalse();
|
||||
console.info('set_port_roles_test_08: PASS');
|
||||
console.info('usb set_port_roles_test_08: PASS');
|
||||
})
|
||||
|
||||
console.info('set_port_roles_test_08: PASS');
|
||||
console.info('usb set_port_roles_test_08: PASS');
|
||||
expect(true).assertTrue();
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : set_port_roles_test_09
|
||||
* @tc.name : setPortRoles
|
||||
* @tc.desc : host模式下,powerRole参数错误
|
||||
*/
|
||||
it('SUB_USB_set_port_roles_test_09', 0, function () {
|
||||
var portId = 1;
|
||||
var powerRole = -1;
|
||||
var dataRole = 1;
|
||||
CheckEmptyUtils.sleep(2000)
|
||||
usb.setPortRoles(1, -1, 1).then(data => {
|
||||
console.info('usb case setPortRoles return: ' + data);
|
||||
expect(data).assertTrue();
|
||||
}).catch(error => {
|
||||
console.info('usb case setPortRoles error : ' + error);
|
||||
expect(error).assertFalse();
|
||||
console.info('set_port_roles_test_09: PASS');
|
||||
})
|
||||
|
||||
console.info('set_port_roles_test_09: PASS');
|
||||
expect(true).assertTrue();
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : set_port_roles_test_10
|
||||
* @tc.name : setPortRoles
|
||||
* @tc.desc : host模式下,dataRole参数错误
|
||||
*/
|
||||
it('SUB_USB_set_port_roles_test_10', 0, function () {
|
||||
var portId = 1;
|
||||
var powerRole = 1;
|
||||
var dataRole = -1;
|
||||
CheckEmptyUtils.sleep(2000)
|
||||
usb.setPortRoles(1, -1, 1).then(data => {
|
||||
console.info('usb case setPortRoles return: ' + data);
|
||||
expect(data).assertTrue();
|
||||
}).catch(error => {
|
||||
console.info('usb case setPortRoles error : ' + error);
|
||||
expect(error).assertFalse();
|
||||
console.info('set_port_roles_test_10: PASS');
|
||||
})
|
||||
|
||||
console.info('set_port_roles_test_10: PASS');
|
||||
expect(true).assertTrue();
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : set_port_roles_test_11
|
||||
* @tc.name : setPortRoles
|
||||
* @tc.desc : host模式下,portId,powerRole参数错误
|
||||
*/
|
||||
it('SUB_USB_set_port_roles_test_11', 0, function () {
|
||||
var portId = -1;
|
||||
var powerRole = -1;
|
||||
var dataRole = 1;
|
||||
CheckEmptyUtils.sleep(2000)
|
||||
usb.setPortRoles(-1, -1, 1).then(data => {
|
||||
console.info('usb case setPortRoles return: ' + data);
|
||||
expect(data).assertTrue();
|
||||
}).catch(error => {
|
||||
console.info('usb case setPortRoles error : ' + error);
|
||||
expect(error).assertFalse();
|
||||
console.info('set_port_roles_test_11: PASS');
|
||||
})
|
||||
|
||||
console.info('set_port_roles_test_11: PASS');
|
||||
expect(true).assertTrue();
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : set_port_roles_test_12
|
||||
* @tc.name : setPortRoles
|
||||
* @tc.desc : host模式下,portId,dataRole参数错误
|
||||
*/
|
||||
it('SUB_USB_set_port_roles_test_12', 0, function () {
|
||||
var portId = -1;
|
||||
var powerRole = 1;
|
||||
var dataRole = -1;
|
||||
CheckEmptyUtils.sleep(2000)
|
||||
usb.setPortRoles(-1, 1, -1).then(data => {
|
||||
console.info('usb case setPortRoles return: ' + data);
|
||||
expect(data).assertTrue();
|
||||
}).catch(error => {
|
||||
console.info('usb case setPortRoles error : ' + error);
|
||||
expect(error).assertFalse();
|
||||
console.info('set_port_roles_test_12: PASS');
|
||||
})
|
||||
|
||||
console.info('set_port_roles_test_12: PASS');
|
||||
expect(true).assertTrue();
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : set_port_roles_test_13
|
||||
* @tc.name : setPortRoles
|
||||
* @tc.desc : host模式下,powerRole,dataRole参数错误
|
||||
*/
|
||||
it('SUB_USB_set_port_roles_test_13', 0, function () {
|
||||
var portId = 1;
|
||||
var powerRole = -1;
|
||||
var dataRole = -1;
|
||||
CheckEmptyUtils.sleep(2000)
|
||||
usb.setPortRoles(1, -1, -1).then(data => {
|
||||
console.info('usb case setPortRoles return: ' + data);
|
||||
expect(data).assertTrue();
|
||||
}).catch(error => {
|
||||
console.info('usb case setPortRoles error : ' + error);
|
||||
expect(error).assertFalse();
|
||||
console.info('set_port_roles_test_13: PASS');
|
||||
})
|
||||
|
||||
console.info('set_port_roles_test_13: PASS');
|
||||
expect(true).assertTrue();
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : set_port_roles_test_14
|
||||
* @tc.name : setPortRoles
|
||||
* @tc.desc : host模式下,portId,powerRole,dataRole参数错误
|
||||
*/
|
||||
it('SUB_USB_set_port_roles_test_14', 0, function () {
|
||||
var portId = -1;
|
||||
var powerRole = -1;
|
||||
var dataRole = -1;
|
||||
CheckEmptyUtils.sleep(2000)
|
||||
|
||||
usb.setPortRoles(-1, -1, -1).then(data => {
|
||||
console.info('usb case setPortRoles 14 return: ' + data);
|
||||
expect(data).assertTrue();
|
||||
}).catch(error => {
|
||||
console.info('usb case setPortRoles 14 error : ' + error);
|
||||
expect(error).assertFalse();
|
||||
console.info('set_port_roles_test_14: PASS');
|
||||
})
|
||||
|
||||
console.info('set_port_roles_test_14: PASS');
|
||||
expect(true).assertTrue();
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : set_port_roles_test_15
|
||||
* @tc.name : setPortRoles
|
||||
* @tc.desc : Device模式下,portId参数错误
|
||||
*/
|
||||
it('SUB_USB_set_port_roles_test_15', 0, function () {
|
||||
var portId = -1;
|
||||
var powerRole = 2;
|
||||
var dataRole = 2;
|
||||
CheckEmptyUtils.sleep(2000)
|
||||
usb.setPortRoles(-1, 2, 2).then(data => {
|
||||
console.info('usb case setPortRoles return: ' + data);
|
||||
expect(data).assertTrue();
|
||||
}).catch(error => {
|
||||
console.info('usb case setPortRoles error : ' + error);
|
||||
expect(error).assertFalse();
|
||||
console.info('set_port_roles_test_15: PASS');
|
||||
})
|
||||
|
||||
console.info('set_port_roles_test_15: PASS');
|
||||
expect(true).assertTrue();
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number : set_port_roles_test_16
|
||||
* @tc.name : setPortRoles
|
||||
* @tc.desc : Device模式下,powerRole参数错误
|
||||
*/
|
||||
it('SUB_USB_set_port_roles_test_16', 0, function () {
|
||||
var portId = 2;
|
||||
var powerRole = -1;
|
||||
var dataRole = 2;
|
||||
CheckEmptyUtils.sleep(2000)
|
||||
usb.setPortRoles(2, -1, 2).then(data => {
|
||||
console.info('usb case setPortRoles return: ' + data);
|
||||
expect(data).assertTrue();
|
||||
}).catch(error => {
|
||||
console.info('usb case setPortRoles error : ' + error);
|
||||
expect(error).assertFalse();
|
||||
console.info('set_port_roles_test_16: PASS');
|
||||
})
|
||||
|
||||
console.info('set_port_roles_test_16: PASS');
|
||||
expect(true).assertTrue();
|
||||
})
|
||||
})
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "iservice_registry.h"
|
||||
#include "string_ex.h"
|
||||
#include "system_ability_definition.h"
|
||||
#include "usb_errors.h"
|
||||
#include "usb_service.h"
|
||||
#include "usb_srv_client.h"
|
||||
|
||||
@@ -32,11 +33,11 @@ using namespace OHOS::USB;
|
||||
using namespace OHOS;
|
||||
using namespace std;
|
||||
|
||||
const int SLEEP_TIME = 3;
|
||||
const int32_t SLEEP_TIME = 3;
|
||||
|
||||
const int TEST_PORT_ID = 1;
|
||||
const int TEST_POWER_ROLE = 2;
|
||||
const int TEST_DATAR_ROLE = 2;
|
||||
const int32_t TEST_PORT_ID = 1;
|
||||
const int32_t TEST_POWER_ROLE = 2;
|
||||
const int32_t TEST_DATAR_ROLE = 2;
|
||||
|
||||
void UsbCoreTest::SetUpTestCase(void)
|
||||
{
|
||||
@@ -48,12 +49,12 @@ void UsbCoreTest::SetUpTestCase(void)
|
||||
if (ret != 0) {
|
||||
exit(0);
|
||||
}
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Start UsbCoreTest-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Start UsbCoreTest");
|
||||
}
|
||||
|
||||
void UsbCoreTest::TearDownTestCase(void)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------End UsbCoreTest-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "End UsbCoreTest");
|
||||
}
|
||||
|
||||
void UsbCoreTest::SetUp(void) {}
|
||||
@@ -67,13 +68,13 @@ void UsbCoreTest::TearDown(void) {}
|
||||
*/
|
||||
HWTEST_F(UsbCoreTest, GetCurrentFunctions001, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : GetCurrentFunctions001 : SetConfig-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : GetCurrentFunctions001 : SetConfig");
|
||||
auto &instance = UsbSrvClient::GetInstance();
|
||||
int32_t funcs = 0;
|
||||
funcs = instance.GetCurrentFunctions(funcs);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbCoreTest::funcs=%{public}d", funcs);
|
||||
ASSERT_TRUE(funcs == 0);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : GetCurrentFunctions001 : SetConfig-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : GetCurrentFunctions001 : SetConfig");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,12 +84,12 @@ HWTEST_F(UsbCoreTest, GetCurrentFunctions001, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbCoreTest, SetCurrentFunctions001, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : SetCurrentFunctions001 : SetConfig-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : SetCurrentFunctions001 : SetConfig");
|
||||
auto &instance = UsbSrvClient::GetInstance();
|
||||
int32_t isok = instance.SetCurrentFunctions(1);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbCoreTest::SetCurrentFunctions=%{public}d", isok);
|
||||
ASSERT_TRUE(isok == 0);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : SetCurrentFunctions001 : SetConfig-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : SetCurrentFunctions001 : SetConfig");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -98,12 +99,12 @@ HWTEST_F(UsbCoreTest, SetCurrentFunctions001, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbCoreTest, SetCurrentFunctions002, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : SetCurrentFunctions002 : SetConfig-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : SetCurrentFunctions002 : SetConfig");
|
||||
auto &instance = UsbSrvClient::GetInstance();
|
||||
int32_t isok = instance.SetCurrentFunctions(2);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbCoreTest::SetCurrentFunctions=%{public}d", isok);
|
||||
ASSERT_TRUE(isok == 0);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : SetCurrentFunctions002 : SetConfig-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : SetCurrentFunctions002 : SetConfig");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -113,12 +114,12 @@ HWTEST_F(UsbCoreTest, SetCurrentFunctions002, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbCoreTest, SetCurrentFunctions003, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : SetCurrentFunctions003 : SetConfig-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : SetCurrentFunctions003 : SetConfig");
|
||||
auto &instance = UsbSrvClient::GetInstance();
|
||||
int32_t isok = instance.SetCurrentFunctions(3);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbCoreTest::SetCurrentFunctions=%{public}d", isok);
|
||||
ASSERT_TRUE(isok == 0);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : SetCurrentFunctions003 : SetConfig-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : SetCurrentFunctions003 : SetConfig");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -128,12 +129,12 @@ HWTEST_F(UsbCoreTest, SetCurrentFunctions003, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbCoreTest, SetCurrentFunctions004, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : SetCurrentFunctions004 : SetConfig-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : SetCurrentFunctions004 : SetConfig");
|
||||
auto &instance = UsbSrvClient::GetInstance();
|
||||
int32_t isok = instance.SetCurrentFunctions(4);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbCoreTest::SetCurrentFunctions=%{public}d", isok);
|
||||
ASSERT_TRUE(isok == 0);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : SetCurrentFunctions004 : SetConfig-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : SetCurrentFunctions004 : SetConfig");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,12 +144,12 @@ HWTEST_F(UsbCoreTest, SetCurrentFunctions004, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbCoreTest, SetCurrentFunctions005, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : SetCurrentFunctions005 : SetConfig-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : SetCurrentFunctions005 : SetConfig");
|
||||
auto &instance = UsbSrvClient::GetInstance();
|
||||
int32_t isok = instance.SetCurrentFunctions(5);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbCoreTest::SetCurrentFunctions=%{public}d", isok);
|
||||
ASSERT_TRUE(isok == 0);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : SetCurrentFunctions005 : SetConfig-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : SetCurrentFunctions005 : SetConfig");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -158,12 +159,12 @@ HWTEST_F(UsbCoreTest, SetCurrentFunctions005, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbCoreTest, SetCurrentFunctions006, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : SetCurrentFunctions006 : SetConfig-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : SetCurrentFunctions006 : SetConfig");
|
||||
auto &instance = UsbSrvClient::GetInstance();
|
||||
int32_t isok = instance.SetCurrentFunctions(6);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbCoreTest::SetCurrentFunctions=%{public}d", isok);
|
||||
ASSERT_TRUE(isok == 0);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : SetCurrentFunctions006 : SetConfig-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : SetCurrentFunctions006 : SetConfig");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -173,12 +174,12 @@ HWTEST_F(UsbCoreTest, SetCurrentFunctions006, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbCoreTest, SetCurrentFunctions007, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : SetCurrentFunctions007 : SetConfig-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : SetCurrentFunctions007 : SetConfig");
|
||||
auto &instance = UsbSrvClient::GetInstance();
|
||||
int32_t isok = instance.SetCurrentFunctions(8);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbCoreTest::SetCurrentFunctions=%{public}d", isok);
|
||||
ASSERT_TRUE(isok != 0);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : SetCurrentFunctions007 : SetConfig-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : SetCurrentFunctions007 : SetConfig");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -188,12 +189,12 @@ HWTEST_F(UsbCoreTest, SetCurrentFunctions007, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbCoreTest, UsbFunctionsFromString001, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : UsbFunctionsFromString001 : SetConfig-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : UsbFunctionsFromString001 : SetConfig");
|
||||
auto &instance = UsbSrvClient::GetInstance();
|
||||
int32_t funcCode = instance.UsbFunctionsFromString(UsbFunctionManager::FUNCTION_NAME_NONE);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbCoreTest::functionsFromString=%{public}d", funcCode);
|
||||
ASSERT_TRUE(funcCode != ERR_INVALID_VALUE);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : UsbFunctionsFromString001 : SetConfig-----------");
|
||||
ASSERT_TRUE(funcCode != UEC_SERVICE_INVALID_VALUE);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : UsbFunctionsFromString001 : SetConfig");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -203,12 +204,12 @@ HWTEST_F(UsbCoreTest, UsbFunctionsFromString001, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbCoreTest, UsbFunctionsFromString002, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : UsbFunctionsFromString002 : SetConfig-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : UsbFunctionsFromString002 : SetConfig");
|
||||
auto &instance = UsbSrvClient::GetInstance();
|
||||
int32_t funcCode = instance.UsbFunctionsFromString(UsbFunctionManager::FUNCTION_NAME_HDC);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbCoreTest::functionsFromString=%{public}d", funcCode);
|
||||
ASSERT_TRUE(funcCode != ERR_INVALID_VALUE);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : UsbFunctionsFromString002 : SetConfig-----------");
|
||||
ASSERT_TRUE(funcCode != UEC_SERVICE_INVALID_VALUE);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : UsbFunctionsFromString002 : SetConfig");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -218,12 +219,12 @@ HWTEST_F(UsbCoreTest, UsbFunctionsFromString002, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbCoreTest, UsbFunctionsFromString003, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : UsbFunctionsFromString003 : SetConfig-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : UsbFunctionsFromString003 : SetConfig");
|
||||
auto &instance = UsbSrvClient::GetInstance();
|
||||
int32_t funcCode = instance.UsbFunctionsFromString(UsbFunctionManager::FUNCTION_NAME_ACM);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbCoreTest::functionsFromString=%{public}d", funcCode);
|
||||
ASSERT_TRUE(funcCode != ERR_INVALID_VALUE);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : UsbFunctionsFromString003 : SetConfig-----------");
|
||||
ASSERT_TRUE(funcCode != UEC_SERVICE_INVALID_VALUE);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : UsbFunctionsFromString003 : SetConfig");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -233,12 +234,12 @@ HWTEST_F(UsbCoreTest, UsbFunctionsFromString003, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbCoreTest, UsbFunctionsFromString004, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : UsbFunctionsFromString004 : SetConfig-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : UsbFunctionsFromString004 : SetConfig");
|
||||
auto &instance = UsbSrvClient::GetInstance();
|
||||
int32_t funcCode = instance.UsbFunctionsFromString(UsbFunctionManager::FUNCTION_NAME_ECM);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbCoreTest::functionsFromString=%{public}d", funcCode);
|
||||
ASSERT_TRUE(funcCode != ERR_INVALID_VALUE);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : UsbFunctionsFromString004 : SetConfig-----------");
|
||||
ASSERT_TRUE(funcCode != UEC_SERVICE_INVALID_VALUE);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : UsbFunctionsFromString004 : SetConfig");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -248,13 +249,13 @@ HWTEST_F(UsbCoreTest, UsbFunctionsFromString004, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbCoreTest, UsbFunctionsFromString005, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : UsbFunctionsFromString005 : SetConfig-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : UsbFunctionsFromString005 : SetConfig");
|
||||
auto &instance = UsbSrvClient::GetInstance();
|
||||
std::string funcs = "qwerts";
|
||||
int32_t funcCode = instance.UsbFunctionsFromString(funcs);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbCoreTest::functionsFromString=%{public}d", funcCode);
|
||||
ASSERT_TRUE(funcCode == ERR_INVALID_VALUE);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : UsbFunctionsFromString005 : SetConfig-----------");
|
||||
ASSERT_TRUE(funcCode == UEC_SERVICE_INVALID_VALUE);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : UsbFunctionsFromString005 : SetConfig");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -264,13 +265,13 @@ HWTEST_F(UsbCoreTest, UsbFunctionsFromString005, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbCoreTest, UsbFunctionsFromString006, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : UsbFunctionsFromString006 : SetConfig-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : UsbFunctionsFromString006 : SetConfig");
|
||||
auto &instance = UsbSrvClient::GetInstance();
|
||||
std::string funcs = "zxcbvx";
|
||||
int32_t funcCode = instance.UsbFunctionsFromString(funcs);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbCoreTest::functionsFromString=%{public}d", funcCode);
|
||||
ASSERT_TRUE(funcCode == ERR_INVALID_VALUE);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : UsbFunctionsFromString006 : SetConfig-----------");
|
||||
ASSERT_TRUE(funcCode == UEC_SERVICE_INVALID_VALUE);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : UsbFunctionsFromString006 : SetConfig");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -280,13 +281,13 @@ HWTEST_F(UsbCoreTest, UsbFunctionsFromString006, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbCoreTest, UsbFunctionsToString001, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : UsbFunctionsToString001 : SetConfig-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : UsbFunctionsToString001 : SetConfig");
|
||||
auto &instance = UsbSrvClient::GetInstance();
|
||||
std::string funcName = instance.UsbFunctionsToString(UsbFunctionManager::FUNCTION_NONE);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbCoreTest::UsbFunctionsToString=%{public}s", funcName.c_str());
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbCoreTest::UsbFunctionsToString=%{public}d", funcName.size());
|
||||
ASSERT_TRUE(!(funcName.empty()));
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : UsbFunctionsToString001 : SetConfig-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : UsbFunctionsToString001 : SetConfig");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -296,12 +297,12 @@ HWTEST_F(UsbCoreTest, UsbFunctionsToString001, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbCoreTest, UsbFunctionsToString002, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : UsbFunctionsToString002 : SetConfig-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : UsbFunctionsToString002 : SetConfig");
|
||||
auto &instance = UsbSrvClient::GetInstance();
|
||||
std::string funcName = instance.UsbFunctionsToString(UsbFunctionManager::FUNCTION_HDC);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbCoreTest::UsbFunctionsToString=%{public}s", funcName.c_str());
|
||||
ASSERT_TRUE(!(funcName.empty()));
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : UsbFunctionsToString002 : SetConfig-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : UsbFunctionsToString002 : SetConfig");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -311,12 +312,12 @@ HWTEST_F(UsbCoreTest, UsbFunctionsToString002, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbCoreTest, UsbFunctionsToString003, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : UsbFunctionsToString003 : SetConfig-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : UsbFunctionsToString003 : SetConfig");
|
||||
auto &instance = UsbSrvClient::GetInstance();
|
||||
std::string funcName = instance.UsbFunctionsToString(UsbFunctionManager::FUNCTION_ACM);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbFunctionServiceTest::UsbFunctionsToString=%{public}s", funcName.c_str());
|
||||
ASSERT_TRUE(!(funcName.empty()));
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : UsbFunctionsToString003 : SetConfig-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : UsbFunctionsToString003 : SetConfig");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -326,12 +327,12 @@ HWTEST_F(UsbCoreTest, UsbFunctionsToString003, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbCoreTest, UsbFunctionsToString004, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : UsbFunctionsToString004 : SetConfig-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : UsbFunctionsToString004 : SetConfig");
|
||||
auto &instance = UsbSrvClient::GetInstance();
|
||||
std::string funcName = instance.UsbFunctionsToString(UsbFunctionManager::FUNCTION_ECM);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbFunctionServiceTest::UsbFunctionsToString=%{public}s", funcName.c_str());
|
||||
ASSERT_TRUE(!(funcName.empty()));
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : UsbFunctionsToString004 : SetConfig-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : UsbFunctionsToString004 : SetConfig");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -341,12 +342,12 @@ HWTEST_F(UsbCoreTest, UsbFunctionsToString004, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbCoreTest, UsbFunctionsToString005, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : UsbFunctionsToString005 : SetConfig-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : UsbFunctionsToString005 : SetConfig");
|
||||
auto &instance = UsbSrvClient::GetInstance();
|
||||
std::string funcName = instance.UsbFunctionsToString(-1);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbFunctionServiceTest::UsbFunctionsToString=%{public}s", funcName.c_str());
|
||||
ASSERT_TRUE(!(funcName.empty()));
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : UsbFunctionsToString005 : SetConfig-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : UsbFunctionsToString005 : SetConfig");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -358,13 +359,13 @@ HWTEST_F(UsbCoreTest, UsbFunctionsToString005, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbCoreTest, UsbHasRight001, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : UsbHasRight001: SetConfig-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : UsbHasRight001: SetConfig");
|
||||
auto &UsbSrvClient = UsbSrvClient::GetInstance();
|
||||
std::string deviceName = "device_80";
|
||||
int32_t result = UsbSrvClient.HasRight(deviceName);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbCoreTest::UsbHasRight001 HasRight=%{public}d", result);
|
||||
ASSERT_TRUE(result != 0);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : UsbHasRight001: SetConfig-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : UsbHasRight001: SetConfig");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -376,7 +377,7 @@ HWTEST_F(UsbCoreTest, UsbHasRight001, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbCoreTest, UsbHasRight002, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : UsbHasRight002: SetConfig-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : UsbHasRight002: SetConfig");
|
||||
auto &UsbSrvClient = UsbSrvClient::GetInstance();
|
||||
std::string deviceName = "device_80";
|
||||
int32_t result = UsbSrvClient.HasRight(deviceName);
|
||||
@@ -388,7 +389,7 @@ HWTEST_F(UsbCoreTest, UsbHasRight002, TestSize.Level1)
|
||||
result = UsbSrvClient.HasRight(deviceName);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbCoreTest::UsbHasRight002 HasRight=%{public}d", result);
|
||||
ASSERT_TRUE(result == 0);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : UsbHasRight002: SetConfig-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : UsbHasRight002: SetConfig");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -400,7 +401,7 @@ HWTEST_F(UsbCoreTest, UsbHasRight002, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbCoreTest, UsbHasRight003, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : UsbHasRight003: SetConfig-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : UsbHasRight003: SetConfig");
|
||||
auto &UsbSrvClient = UsbSrvClient::GetInstance();
|
||||
std::string deviceName = "device_80";
|
||||
int32_t result = UsbSrvClient.HasRight(deviceName);
|
||||
@@ -413,7 +414,7 @@ HWTEST_F(UsbCoreTest, UsbHasRight003, TestSize.Level1)
|
||||
result = UsbSrvClient.HasRight(deviceName);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbCoreTest::UsbHasRight003 HasRight=%{public}d", result);
|
||||
ASSERT_TRUE(result != 0);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : UsbHasRight003: SetConfig-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : UsbHasRight003: SetConfig");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -425,7 +426,7 @@ HWTEST_F(UsbCoreTest, UsbHasRight003, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbCoreTest, UsbHasRight004, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : UsbHasRight004: SetConfig-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : UsbHasRight004: SetConfig");
|
||||
auto &UsbSrvClient = UsbSrvClient::GetInstance();
|
||||
std::string deviceName = "device_82";
|
||||
int32_t result = UsbSrvClient.HasRight(deviceName);
|
||||
@@ -440,7 +441,7 @@ HWTEST_F(UsbCoreTest, UsbHasRight004, TestSize.Level1)
|
||||
result = UsbSrvClient.RemoveRight(deviceName);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbCoreTest::Usbrequestright003 RemoveRight=%{public}d", result);
|
||||
ASSERT_TRUE(result == 0);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : UsbHasRight004: SetConfig-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : UsbHasRight004: SetConfig");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -452,7 +453,7 @@ HWTEST_F(UsbCoreTest, UsbHasRight004, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbCoreTest, Usbrequestright001, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : Usbrequestright001: SetConfig-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : Usbrequestright001: SetConfig");
|
||||
auto &UsbSrvClient = UsbSrvClient::GetInstance();
|
||||
std::string deviceName = "device_83";
|
||||
int32_t result = UsbSrvClient.RequestRight(deviceName);
|
||||
@@ -464,7 +465,7 @@ HWTEST_F(UsbCoreTest, Usbrequestright001, TestSize.Level1)
|
||||
result = UsbSrvClient.RemoveRight(deviceName);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbCoreTest::Usbrequestright003 RemoveRight=%{public}d", result);
|
||||
ASSERT_TRUE(result == 0);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : Usbrequestright001: SetConfig-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : Usbrequestright001: SetConfig");
|
||||
}
|
||||
/**
|
||||
* @tc.name: Usbrequestright002
|
||||
@@ -475,7 +476,7 @@ HWTEST_F(UsbCoreTest, Usbrequestright001, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbCoreTest, Usbrequestright002, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : Usbrequestright002: SetConfig-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : Usbrequestright002: SetConfig");
|
||||
auto &UsbSrvClient = UsbSrvClient::GetInstance();
|
||||
std::string deviceName = "device_84";
|
||||
int32_t result = UsbSrvClient.RequestRight(deviceName);
|
||||
@@ -487,7 +488,7 @@ HWTEST_F(UsbCoreTest, Usbrequestright002, TestSize.Level1)
|
||||
result = UsbSrvClient.RemoveRight(deviceName);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbCoreTest::Usbrequestright003 RemoveRight=%{public}d", result);
|
||||
ASSERT_TRUE(result == 0);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : Usbrequestright002: SetConfig-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : Usbrequestright002: SetConfig");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -498,7 +499,7 @@ HWTEST_F(UsbCoreTest, Usbrequestright002, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbCoreTest, Usbrequestright003, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : Usbrequestright003: SetConfig-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : Usbrequestright003: SetConfig");
|
||||
auto &UsbSrvClient = UsbSrvClient::GetInstance();
|
||||
std::string deviceName = "device_81";
|
||||
int32_t result = UsbSrvClient.HasRight(deviceName);
|
||||
@@ -513,7 +514,7 @@ HWTEST_F(UsbCoreTest, Usbrequestright003, TestSize.Level1)
|
||||
result = UsbSrvClient.RemoveRight(deviceName);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbCoreTest::Usbrequestright003 RemoveRight=%{public}d", result);
|
||||
ASSERT_TRUE(result == 0);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : Usbrequestright003: SetConfig-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : Usbrequestright003: SetConfig");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -526,13 +527,13 @@ HWTEST_F(UsbCoreTest, Usbrequestright003, TestSize.Level1)
|
||||
|
||||
HWTEST_F(UsbCoreTest, GetPorts001, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : GetPorts001 : GetPorts-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : GetPorts001 : GetPorts");
|
||||
auto &usbSrvClient = UsbSrvClient::GetInstance();
|
||||
std::vector<UsbPort> portlist;
|
||||
auto ports = usbSrvClient.GetPorts(portlist);
|
||||
USB_HILOGD(MODULE_USB_SERVICE, "Get UsbPort size=%{public}d", portlist.size());
|
||||
ASSERT_TRUE(ports == 0);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : GetPorts001 : GetPorts-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : GetPorts001 : GetPorts");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -545,13 +546,13 @@ HWTEST_F(UsbCoreTest, GetPorts001, TestSize.Level1)
|
||||
|
||||
HWTEST_F(UsbCoreTest, GetSupportedModes001, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : GetSupportedModes001 : GetSupportedModes-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : GetSupportedModes001 : GetSupportedModes");
|
||||
auto &UsbSrvClient = UsbSrvClient::GetInstance();
|
||||
int32_t result = 0;
|
||||
auto modes = UsbSrvClient.GetSupportedModes(0, result);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbCoreTest::status=%{public}d", modes);
|
||||
ASSERT_TRUE(modes != 0);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : GetSupportedModes001 : GetSupportedModes-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : GetSupportedModes001 : GetSupportedModes");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -564,13 +565,13 @@ HWTEST_F(UsbCoreTest, GetSupportedModes001, TestSize.Level1)
|
||||
|
||||
HWTEST_F(UsbCoreTest, GetSupportedModes002, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : GetSupportedModes002 : GetSupportedModes-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : GetSupportedModes002 : GetSupportedModes");
|
||||
auto &UsbSrvClient = UsbSrvClient::GetInstance();
|
||||
int32_t result = 0;
|
||||
auto modes = UsbSrvClient.GetSupportedModes(-1, result);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbCoreTest::status=%{public}d", modes);
|
||||
ASSERT_TRUE(modes != 0);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : GetSupportedModes002 : GetSupportedModes-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : GetSupportedModes002 : GetSupportedModes");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -583,13 +584,13 @@ HWTEST_F(UsbCoreTest, GetSupportedModes002, TestSize.Level1)
|
||||
|
||||
HWTEST_F(UsbCoreTest, GetSupportedModes003, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : GetSupportedModes003 : GetSupportedModes-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : GetSupportedModes003 : GetSupportedModes");
|
||||
auto &UsbSrvClient = UsbSrvClient::GetInstance();
|
||||
int32_t result = 0;
|
||||
auto modes = UsbSrvClient.GetSupportedModes(0xFFFFFFFF, result);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbCoreTest::status=%{public}d", modes);
|
||||
ASSERT_TRUE(modes != 0);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : GetSupportedModes003 : GetSupportedModes-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : GetSupportedModes003 : GetSupportedModes");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -602,13 +603,13 @@ HWTEST_F(UsbCoreTest, GetSupportedModes003, TestSize.Level1)
|
||||
|
||||
HWTEST_F(UsbCoreTest, GetSupportedModes004, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : GetSupportedModes004 : GetSupportedModes-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : GetSupportedModes004 : GetSupportedModes");
|
||||
auto &UsbSrvClient = UsbSrvClient::GetInstance();
|
||||
int32_t result = 0;
|
||||
auto modes = UsbSrvClient.GetSupportedModes(1, result);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbCoreTest::status=%{public}d", modes);
|
||||
ASSERT_TRUE(modes == 0);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : GetSupportedModes004 : GetSupportedModes-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : GetSupportedModes004 : GetSupportedModes");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -621,12 +622,12 @@ HWTEST_F(UsbCoreTest, GetSupportedModes004, TestSize.Level1)
|
||||
|
||||
HWTEST_F(UsbCoreTest, SetPortRole001, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : SetPortRole001 : SetPortRole-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : SetPortRole001 : SetPortRole");
|
||||
auto &UsbSrvClient = UsbSrvClient::GetInstance();
|
||||
auto ret = UsbSrvClient.SetPortRole(1, 1, 1);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbCoreTest::status=%{public}d", ret);
|
||||
ASSERT_TRUE(ret == 0);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : SetPortRole001 : SetPortRole-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : SetPortRole001 : SetPortRole");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -639,12 +640,12 @@ HWTEST_F(UsbCoreTest, SetPortRole001, TestSize.Level1)
|
||||
|
||||
HWTEST_F(UsbCoreTest, SetPortRole002, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : SetPortRole002 : SetPortRole-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : SetPortRole002 : SetPortRole");
|
||||
auto &UsbSrvClient = UsbSrvClient::GetInstance();
|
||||
auto ret = UsbSrvClient.SetPortRole(2, 1, 1);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbCoreTest::status=%{public}d", ret);
|
||||
ASSERT_TRUE(ret != 0);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : SetPortRole002 : SetPortRole-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : SetPortRole002 : SetPortRole");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -657,12 +658,12 @@ HWTEST_F(UsbCoreTest, SetPortRole002, TestSize.Level1)
|
||||
|
||||
HWTEST_F(UsbCoreTest, SetPortRole003, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : SetPortRole003 : SetPortRole-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : SetPortRole003 : SetPortRole");
|
||||
auto &UsbSrvClient = UsbSrvClient::GetInstance();
|
||||
auto ret = UsbSrvClient.SetPortRole(1, 4, 2);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbCoreTest::status=%{public}d", ret);
|
||||
ASSERT_TRUE(ret != 0);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : SetPortRole003 : SetPortRole-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : SetPortRole003 : SetPortRole");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -674,12 +675,12 @@ HWTEST_F(UsbCoreTest, SetPortRole003, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbCoreTest, SetPortRole004, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : SetPortRole004 : SetPortRole-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : SetPortRole004 : SetPortRole");
|
||||
auto &UsbSrvClient = UsbSrvClient::GetInstance();
|
||||
auto ret = UsbSrvClient.SetPortRole(1, 1, 5);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbCoreTest::status=%{public}d", ret);
|
||||
ASSERT_TRUE(ret != 0);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : SetPortRole004 : SetPortRole-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : SetPortRole004 : SetPortRole");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -691,12 +692,12 @@ HWTEST_F(UsbCoreTest, SetPortRole004, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbCoreTest, SetPortRole005, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : SetPortRole005 : SetPortRole-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : SetPortRole005 : SetPortRole");
|
||||
auto &UsbSrvClient = UsbSrvClient::GetInstance();
|
||||
auto ret = UsbSrvClient.SetPortRole(1, 5, 5);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbCoreTest::status=%{public}d", ret);
|
||||
ASSERT_TRUE(ret != 0);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : SetPortRole005 : SetPortRole-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : SetPortRole005 : SetPortRole");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -708,12 +709,12 @@ HWTEST_F(UsbCoreTest, SetPortRole005, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbCoreTest, SetPortRole006, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : SetPortRole006 : SetPortRole-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : SetPortRole006 : SetPortRole");
|
||||
auto &UsbSrvClient = UsbSrvClient::GetInstance();
|
||||
auto ret = UsbSrvClient.SetPortRole(5, 1, 5);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbCoreTest::status=%{public}d", ret);
|
||||
ASSERT_TRUE(ret != 0);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : SetPortRole006 : SetPortRole-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : SetPortRole006 : SetPortRole");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -725,12 +726,12 @@ HWTEST_F(UsbCoreTest, SetPortRole006, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbCoreTest, SetPortRole007, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : SetPortRole007 : SetPortRole-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : SetPortRole007 : SetPortRole");
|
||||
auto &UsbSrvClient = UsbSrvClient::GetInstance();
|
||||
auto ret = UsbSrvClient.SetPortRole(2, 5, 5);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbCoreTest::status=%{public}d", ret);
|
||||
ASSERT_TRUE(ret != 0);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : SetPortRole007 : SetPortRole-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : SetPortRole007 : SetPortRole");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -742,10 +743,10 @@ HWTEST_F(UsbCoreTest, SetPortRole007, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbCoreTest, SetPortRole008, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : SetPortRole008 : SetPortRole-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : SetPortRole008 : SetPortRole");
|
||||
auto &UsbSrvClient = UsbSrvClient::GetInstance();
|
||||
auto ret = UsbSrvClient.SetPortRole(1, 2, 2);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbCoreTest::status=%{public}d", ret);
|
||||
ASSERT_TRUE(ret == 0);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : SetPortRole008 : SetPortRole-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : SetPortRole008 : SetPortRole");
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -29,7 +29,7 @@
|
||||
#include "usb_service.h"
|
||||
#include "usb_srv_client.h"
|
||||
|
||||
const int SLEEP_TIME = 3;
|
||||
const int32_t SLEEP_TIME = 3;
|
||||
|
||||
using namespace testing::ext;
|
||||
using namespace OHOS::USB;
|
||||
@@ -47,16 +47,16 @@ void UsbRequestTest::SetUpTestCase(void)
|
||||
exit(0);
|
||||
}
|
||||
std::cout << "请连接设备,连接完后按回车键继续" << std::endl;
|
||||
int c;
|
||||
int32_t c;
|
||||
while ((c = getchar()) != '\n' && c != EOF) {
|
||||
;
|
||||
}
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Start UsbdRequestTest-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Start UsbdRequestTest");
|
||||
}
|
||||
|
||||
void UsbRequestTest::TearDownTestCase(void)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------End UsbdRequestTest-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "End UsbdRequestTest");
|
||||
}
|
||||
|
||||
void UsbRequestTest::SetUp(void) {}
|
||||
@@ -69,7 +69,7 @@ void UsbRequestTest::TearDown(void) {}
|
||||
*/
|
||||
HWTEST_F(UsbRequestTest, UsbRequestInitialize001, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : UsbRequestInitialize001 : Initialize-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : UsbRequestInitialize001 : Initialize");
|
||||
vector<UsbDevice> delist;
|
||||
auto &UsbSrvClient = UsbSrvClient::GetInstance();
|
||||
auto ret = UsbSrvClient.GetDevices(delist);
|
||||
@@ -86,10 +86,6 @@ HWTEST_F(UsbRequestTest, UsbRequestInitialize001, TestSize.Level1)
|
||||
EXPECT_TRUE(ret == 0);
|
||||
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
|
||||
USBEndpoint point = interface.GetEndpoints().front();
|
||||
ret = UsbSrvClient.ReleaseInterface(pip, interface);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbRequestInitialize001 %{public}d ReleaseInterface=%{public}d",
|
||||
__LINE__, ret);
|
||||
EXPECT_TRUE(ret == 0);
|
||||
ret = UsbSrvClient.ClaimInterface(pip, interface, true);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbRequestInitialize001 %{public}d ClaimInterface=%{public}d",
|
||||
__LINE__, ret);
|
||||
@@ -106,7 +102,7 @@ HWTEST_F(UsbRequestTest, UsbRequestInitialize001, TestSize.Level1)
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbRequestInitialize001 %{public}d close=%{public}d", __LINE__,
|
||||
close);
|
||||
EXPECT_TRUE(close);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : UsbRequestInitialize001 : Initialize-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : UsbRequestInitialize001 : Initialize");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,7 +112,7 @@ HWTEST_F(UsbRequestTest, UsbRequestInitialize001, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbRequestTest, UsbRequestInitialize002, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : UsbRequestInitialize002 : Initialize-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : UsbRequestInitialize002 : Initialize");
|
||||
vector<UsbDevice> delist;
|
||||
auto &UsbSrvClient = UsbSrvClient::GetInstance();
|
||||
auto ret = UsbSrvClient.GetDevices(delist);
|
||||
@@ -134,10 +130,6 @@ HWTEST_F(UsbRequestTest, UsbRequestInitialize002, TestSize.Level1)
|
||||
UsbRequest request;
|
||||
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
|
||||
USBEndpoint point = interface.GetEndpoints().at(1);
|
||||
ret = UsbSrvClient.ReleaseInterface(pip, interface);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbRequestInitialize002 %{public}d ReleaseInterface=%{public}d",
|
||||
__LINE__, ret);
|
||||
EXPECT_TRUE(ret == 0);
|
||||
ret = UsbSrvClient.ClaimInterface(pip, interface, true);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbRequestInitialize002 %{public}d ClaimInterface=%{public}d",
|
||||
__LINE__, ret);
|
||||
@@ -156,7 +148,7 @@ HWTEST_F(UsbRequestTest, UsbRequestInitialize002, TestSize.Level1)
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbRequestInitialize002 %{public}d close=%{public}d", __LINE__,
|
||||
close);
|
||||
EXPECT_TRUE(close);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : UsbRequestInitialize002 : Initialize-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : UsbRequestInitialize002 : Initialize");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -166,7 +158,7 @@ HWTEST_F(UsbRequestTest, UsbRequestInitialize002, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbRequestTest, UsbRequestInitialize003, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : UsbRequestInitialize003 : Initialize-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : UsbRequestInitialize003 : Initialize");
|
||||
vector<UsbDevice> delist;
|
||||
auto &UsbSrvClient = UsbSrvClient::GetInstance();
|
||||
auto ret = UsbSrvClient.GetDevices(delist);
|
||||
@@ -183,10 +175,6 @@ HWTEST_F(UsbRequestTest, UsbRequestInitialize003, TestSize.Level1)
|
||||
UsbRequest request;
|
||||
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
|
||||
USBEndpoint point = interface.GetEndpoints().at(0);
|
||||
ret = UsbSrvClient.ReleaseInterface(pip, interface);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbRequestInitialize003 %{public}d ReleaseInterface=%{public}d",
|
||||
__LINE__, ret);
|
||||
EXPECT_TRUE(ret == 0);
|
||||
ret = UsbSrvClient.ClaimInterface(pip, interface, true);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbRequestInitialize003 %{public}d ClaimInterface=%{public}d",
|
||||
__LINE__, ret);
|
||||
@@ -203,7 +191,7 @@ HWTEST_F(UsbRequestTest, UsbRequestInitialize003, TestSize.Level1)
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbRequestInitialize003 %{public}d close=%{public}d", __LINE__,
|
||||
close);
|
||||
EXPECT_TRUE(close);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : UsbRequestInitialize003 : Initialize-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : UsbRequestInitialize003 : Initialize");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -213,7 +201,7 @@ HWTEST_F(UsbRequestTest, UsbRequestInitialize003, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbRequestTest, UsbRequestInitialize004, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : UsbRequestInitialize004 : Initialize-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : UsbRequestInitialize004 : Initialize");
|
||||
vector<UsbDevice> delist;
|
||||
auto &UsbSrvClient = UsbSrvClient::GetInstance();
|
||||
auto ret = UsbSrvClient.GetDevices(delist);
|
||||
@@ -230,10 +218,6 @@ HWTEST_F(UsbRequestTest, UsbRequestInitialize004, TestSize.Level1)
|
||||
UsbRequest request;
|
||||
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
|
||||
USBEndpoint point = interface.GetEndpoints().at(0);
|
||||
ret = UsbSrvClient.ReleaseInterface(pip, interface);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbRequestInitialize004 %{public}d ReleaseInterface=%{public}d",
|
||||
__LINE__, ret);
|
||||
EXPECT_TRUE(ret == 0);
|
||||
ret = UsbSrvClient.ClaimInterface(pip, interface, true);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbRequestInitialize004 %{public}d ClaimInterface=%{public}d",
|
||||
__LINE__, ret);
|
||||
@@ -250,7 +234,7 @@ HWTEST_F(UsbRequestTest, UsbRequestInitialize004, TestSize.Level1)
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbRequestInitialize004 %{public}d close=%{public}d", __LINE__,
|
||||
close);
|
||||
EXPECT_TRUE(close);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : UsbRequestInitialize004 : Initialize-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : UsbRequestInitialize004 : Initialize");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -260,7 +244,7 @@ HWTEST_F(UsbRequestTest, UsbRequestInitialize004, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbRequestTest, UsbRequestInitialize005, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : UsbRequestInitialize005 : Initialize-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : UsbRequestInitialize005 : Initialize");
|
||||
vector<UsbDevice> delist;
|
||||
auto &UsbSrvClient = UsbSrvClient::GetInstance();
|
||||
auto ret = UsbSrvClient.GetDevices(delist);
|
||||
@@ -277,10 +261,6 @@ HWTEST_F(UsbRequestTest, UsbRequestInitialize005, TestSize.Level1)
|
||||
UsbRequest request;
|
||||
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
|
||||
USBEndpoint point = interface.GetEndpoints().at(1);
|
||||
ret = UsbSrvClient.ReleaseInterface(pip, interface);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbRequestInitialize005 %{public}d ReleaseInterface=%{public}d",
|
||||
__LINE__, ret);
|
||||
EXPECT_TRUE(ret == 0);
|
||||
ret = UsbSrvClient.ClaimInterface(pip, interface, true);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbRequestInitialize005 %{public}d ClaimInterface=%{public}d",
|
||||
__LINE__, ret);
|
||||
@@ -300,7 +280,7 @@ HWTEST_F(UsbRequestTest, UsbRequestInitialize005, TestSize.Level1)
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbRequestInitialize005 %{public}d close=%{public}d", __LINE__,
|
||||
close);
|
||||
EXPECT_TRUE(close);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : UsbRequestInitialize005 : Initialize-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : UsbRequestInitialize005 : Initialize");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -310,7 +290,7 @@ HWTEST_F(UsbRequestTest, UsbRequestInitialize005, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbRequestTest, UsbRequestInitialize006, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : UsbRequestInitialize006 : Initialize-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : UsbRequestInitialize006 : Initialize");
|
||||
vector<UsbDevice> delist;
|
||||
auto &UsbSrvClient = UsbSrvClient::GetInstance();
|
||||
auto ret = UsbSrvClient.GetDevices(delist);
|
||||
@@ -327,10 +307,6 @@ HWTEST_F(UsbRequestTest, UsbRequestInitialize006, TestSize.Level1)
|
||||
UsbRequest request;
|
||||
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
|
||||
USBEndpoint point = interface.GetEndpoints().at(1);
|
||||
ret = UsbSrvClient.ReleaseInterface(pip, interface);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbRequestInitialize006 %{public}d ReleaseInterface=%{public}d",
|
||||
__LINE__, ret);
|
||||
EXPECT_TRUE(ret == 0);
|
||||
ret = UsbSrvClient.ClaimInterface(pip, interface, true);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbRequestInitialize006 %{public}d ClaimInterface=%{public}d",
|
||||
__LINE__, ret);
|
||||
@@ -350,7 +326,7 @@ HWTEST_F(UsbRequestTest, UsbRequestInitialize006, TestSize.Level1)
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbRequestInitialize006 %{public}d close=%{public}d", __LINE__,
|
||||
close);
|
||||
EXPECT_TRUE(close);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : UsbRequestInitialize006 : Initialize-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : UsbRequestInitialize006 : Initialize");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -360,7 +336,7 @@ HWTEST_F(UsbRequestTest, UsbRequestInitialize006, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbRequestTest, UsbrequestQueue001, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : UsbrequestQueue001 : RequestQueue-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : UsbrequestQueue001 : RequestQueue");
|
||||
vector<UsbDevice> delist;
|
||||
auto &UsbSrvClient = UsbSrvClient::GetInstance();
|
||||
auto ret = UsbSrvClient.GetDevices(delist);
|
||||
@@ -378,10 +354,6 @@ HWTEST_F(UsbRequestTest, UsbrequestQueue001, TestSize.Level1)
|
||||
UsbRequest request;
|
||||
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
|
||||
USBEndpoint point = interface.GetEndpoints().at(0);
|
||||
ret = UsbSrvClient.ReleaseInterface(pip, interface);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbrequestQueue001 %{public}d ReleaseInterface=%{public}d",
|
||||
__LINE__, ret);
|
||||
EXPECT_TRUE(ret == 0);
|
||||
ret = UsbSrvClient.ClaimInterface(pip, interface, true);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbrequestQueue001 %{public}d ClaimInterface=%{public}d", __LINE__,
|
||||
ret);
|
||||
@@ -399,7 +371,7 @@ HWTEST_F(UsbRequestTest, UsbrequestQueue001, TestSize.Level1)
|
||||
bool close = UsbSrvClient.Close(pip);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbrequestQueue001 %{public}d close=%{public}d", __LINE__, close);
|
||||
EXPECT_TRUE(close);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : UsbrequestQueue001 : RequestQueue-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : UsbrequestQueue001 : RequestQueue");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -409,7 +381,7 @@ HWTEST_F(UsbRequestTest, UsbrequestQueue001, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbRequestTest, UsbrequestQueue002, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : UsbrequestQueue002 : RequestQueue-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : UsbrequestQueue002 : RequestQueue");
|
||||
vector<UsbDevice> delist;
|
||||
auto &UsbSrvClient = UsbSrvClient::GetInstance();
|
||||
auto ret = UsbSrvClient.GetDevices(delist);
|
||||
@@ -427,10 +399,6 @@ HWTEST_F(UsbRequestTest, UsbrequestQueue002, TestSize.Level1)
|
||||
UsbRequest request;
|
||||
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
|
||||
USBEndpoint point = interface.GetEndpoints().at(1);
|
||||
ret = UsbSrvClient.ReleaseInterface(pip, interface);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbrequestQueue002 %{public}d ReleaseInterface=%{public}d",
|
||||
__LINE__, ret);
|
||||
EXPECT_TRUE(ret == 0);
|
||||
ret = UsbSrvClient.ClaimInterface(pip, interface, true);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbrequestQueue002 %{public}d ClaimInterface=%{public}d", __LINE__,
|
||||
ret);
|
||||
@@ -451,7 +419,7 @@ HWTEST_F(UsbRequestTest, UsbrequestQueue002, TestSize.Level1)
|
||||
bool close = UsbSrvClient.Close(pip);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbrequestQueue002 %{public}d close=%{public}d", __LINE__, close);
|
||||
EXPECT_TRUE(close);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : UsbrequestQueue002 : RequestQueue-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : UsbrequestQueue002 : RequestQueue");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -461,7 +429,7 @@ HWTEST_F(UsbRequestTest, UsbrequestQueue002, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbRequestTest, UsbrequestQueue003, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : UsbrequestQueue003 : RequestQueue-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : UsbrequestQueue003 : RequestQueue");
|
||||
vector<UsbDevice> delist;
|
||||
auto &UsbSrvClient = UsbSrvClient::GetInstance();
|
||||
auto ret = UsbSrvClient.GetDevices(delist);
|
||||
@@ -479,10 +447,6 @@ HWTEST_F(UsbRequestTest, UsbrequestQueue003, TestSize.Level1)
|
||||
UsbRequest request;
|
||||
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
|
||||
USBEndpoint point = interface.GetEndpoints().at(0);
|
||||
ret = UsbSrvClient.ReleaseInterface(pip, interface);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbrequestQueue003 %{public}d ReleaseInterface=%{public}d",
|
||||
__LINE__, ret);
|
||||
EXPECT_TRUE(ret == 0);
|
||||
ret = UsbSrvClient.ClaimInterface(pip, interface, true);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbrequestQueue003 %{public}d ClaimInterface=%{public}d", __LINE__,
|
||||
ret);
|
||||
@@ -503,7 +467,7 @@ HWTEST_F(UsbRequestTest, UsbrequestQueue003, TestSize.Level1)
|
||||
bool close = UsbSrvClient.Close(pip);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbrequestQueue003 %{public}d close=%{public}d", __LINE__, close);
|
||||
EXPECT_TRUE(close);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : UsbrequestQueue003 : RequestQueue-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : UsbrequestQueue003 : RequestQueue");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -513,7 +477,7 @@ HWTEST_F(UsbRequestTest, UsbrequestQueue003, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbRequestTest, UsbrequestQueue004, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : UsbrequestQueue004 : RequestQueue-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : UsbrequestQueue004 : RequestQueue");
|
||||
vector<UsbDevice> delist;
|
||||
auto &UsbSrvClient = UsbSrvClient::GetInstance();
|
||||
auto ret = UsbSrvClient.GetDevices(delist);
|
||||
@@ -531,10 +495,6 @@ HWTEST_F(UsbRequestTest, UsbrequestQueue004, TestSize.Level1)
|
||||
UsbRequest request;
|
||||
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
|
||||
USBEndpoint point = interface.GetEndpoints().at(0);
|
||||
ret = UsbSrvClient.ReleaseInterface(pip, interface);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbrequestQueue004 %{public}d ReleaseInterface=%{public}d",
|
||||
__LINE__, ret);
|
||||
EXPECT_TRUE(ret == 0);
|
||||
ret = UsbSrvClient.ClaimInterface(pip, interface, true);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbrequestQueue004 %{public}d ClaimInterface=%{public}d", __LINE__,
|
||||
ret);
|
||||
@@ -555,7 +515,7 @@ HWTEST_F(UsbRequestTest, UsbrequestQueue004, TestSize.Level1)
|
||||
bool close = UsbSrvClient.Close(pip);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbrequestQueue004 %{public}d close=%{public}d", __LINE__, close);
|
||||
EXPECT_TRUE(close);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : UsbrequestQueue004 : RequestQueue-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : UsbrequestQueue004 : RequestQueue");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -565,7 +525,7 @@ HWTEST_F(UsbRequestTest, UsbrequestQueue004, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbRequestTest, UsbrequestQueue005, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : UsbrequestQueue005 : RequestQueue-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : UsbrequestQueue005 : RequestQueue");
|
||||
vector<UsbDevice> delist;
|
||||
auto &UsbSrvClient = UsbSrvClient::GetInstance();
|
||||
auto ret = UsbSrvClient.GetDevices(delist);
|
||||
@@ -583,10 +543,6 @@ HWTEST_F(UsbRequestTest, UsbrequestQueue005, TestSize.Level1)
|
||||
UsbRequest request;
|
||||
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
|
||||
USBEndpoint point = interface.GetEndpoints().at(1);
|
||||
ret = UsbSrvClient.ReleaseInterface(pip, interface);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbrequestQueue005 %{public}d ReleaseInterface=%{public}d",
|
||||
__LINE__, ret);
|
||||
EXPECT_TRUE(ret == 0);
|
||||
ret = UsbSrvClient.ClaimInterface(pip, interface, true);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbrequestQueue005 %{public}d ClaimInterface=%{public}d", __LINE__,
|
||||
ret);
|
||||
@@ -610,7 +566,7 @@ HWTEST_F(UsbRequestTest, UsbrequestQueue005, TestSize.Level1)
|
||||
bool close = UsbSrvClient.Close(pip);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbrequestQueue005 %{public}d close=%{public}d", __LINE__, close);
|
||||
EXPECT_TRUE(close);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : UsbrequestQueue005 : RequestQueue-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : UsbrequestQueue005 : RequestQueue");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -620,7 +576,7 @@ HWTEST_F(UsbRequestTest, UsbrequestQueue005, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbRequestTest, UsbrequestQueue006, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : UsbrequestQueue006 : RequestQueue-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : UsbrequestQueue006 : RequestQueue");
|
||||
vector<UsbDevice> delist;
|
||||
auto &UsbSrvClient = UsbSrvClient::GetInstance();
|
||||
auto ret = UsbSrvClient.GetDevices(delist);
|
||||
@@ -638,10 +594,6 @@ HWTEST_F(UsbRequestTest, UsbrequestQueue006, TestSize.Level1)
|
||||
UsbRequest request;
|
||||
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
|
||||
USBEndpoint point = interface.GetEndpoints().at(1);
|
||||
ret = UsbSrvClient.ReleaseInterface(pip, interface);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbrequestQueue006 %{public}d ReleaseInterface=%{public}d",
|
||||
__LINE__, ret);
|
||||
EXPECT_TRUE(ret == 0);
|
||||
ret = UsbSrvClient.ClaimInterface(pip, interface, true);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbrequestQueue006 %{public}d ClaimInterface=%{public}d", __LINE__,
|
||||
ret);
|
||||
@@ -665,7 +617,7 @@ HWTEST_F(UsbRequestTest, UsbrequestQueue006, TestSize.Level1)
|
||||
bool close = UsbSrvClient.Close(pip);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbrequestQueue006 %{public}d close=%{public}d", __LINE__, close);
|
||||
EXPECT_TRUE(close);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : UsbrequestQueue006 : RequestQueue-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : UsbrequestQueue006 : RequestQueue");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -675,7 +627,7 @@ HWTEST_F(UsbRequestTest, UsbrequestQueue006, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbRequestTest, Usbrequestfree001, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : Usbrequestfree001 : RequestQueue-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : Usbrequestfree001 : RequestQueue");
|
||||
vector<UsbDevice> delist;
|
||||
auto &UsbSrvClient = UsbSrvClient::GetInstance();
|
||||
auto ret = UsbSrvClient.GetDevices(delist);
|
||||
@@ -692,10 +644,6 @@ HWTEST_F(UsbRequestTest, Usbrequestfree001, TestSize.Level1)
|
||||
UsbRequest request;
|
||||
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
|
||||
USBEndpoint point = interface.GetEndpoints().at(0);
|
||||
ret = UsbSrvClient.ReleaseInterface(pip, interface);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestfree001 %{public}d ReleaseInterface=%{public}d", __LINE__,
|
||||
ret);
|
||||
EXPECT_TRUE(ret == 0);
|
||||
ret = UsbSrvClient.ClaimInterface(pip, interface, true);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestfree001 %{public}d ClaimInterface=%{public}d", __LINE__,
|
||||
ret);
|
||||
@@ -712,7 +660,7 @@ HWTEST_F(UsbRequestTest, Usbrequestfree001, TestSize.Level1)
|
||||
bool close = UsbSrvClient.Close(pip);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestfree001 %{public}d close=%{public}d", __LINE__, close);
|
||||
EXPECT_TRUE(close);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : Usbrequestfree001 : RequestFree-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : Usbrequestfree001 : RequestFree");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -722,7 +670,7 @@ HWTEST_F(UsbRequestTest, Usbrequestfree001, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbRequestTest, Usbrequestfree002, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : Usbrequestfree002 : RequestQueue-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : Usbrequestfree002 : RequestQueue");
|
||||
vector<UsbDevice> delist;
|
||||
auto &UsbSrvClient = UsbSrvClient::GetInstance();
|
||||
auto ret = UsbSrvClient.GetDevices(delist);
|
||||
@@ -739,10 +687,6 @@ HWTEST_F(UsbRequestTest, Usbrequestfree002, TestSize.Level1)
|
||||
UsbRequest request;
|
||||
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
|
||||
USBEndpoint point = interface.GetEndpoints().at(0);
|
||||
ret = UsbSrvClient.ReleaseInterface(pip, interface);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestfree002 %{public}d ReleaseInterface=%{public}d", __LINE__,
|
||||
ret);
|
||||
EXPECT_TRUE(ret == 0);
|
||||
ret = UsbSrvClient.ClaimInterface(pip, interface, true);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestfree002 %{public}d ClaimInterface=%{public}d", __LINE__,
|
||||
ret);
|
||||
@@ -762,7 +706,7 @@ HWTEST_F(UsbRequestTest, Usbrequestfree002, TestSize.Level1)
|
||||
bool close = UsbSrvClient.Close(pip);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestfree002 %{public}d close=%{public}d", __LINE__, close);
|
||||
EXPECT_TRUE(close);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : Usbrequestfree002 : RequestFree-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : Usbrequestfree002 : RequestFree");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -772,7 +716,7 @@ HWTEST_F(UsbRequestTest, Usbrequestfree002, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbRequestTest, Usbrequestfree003, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : Usbrequestfree003 : RequestQueue-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : Usbrequestfree003 : RequestQueue");
|
||||
vector<UsbDevice> delist;
|
||||
auto &UsbSrvClient = UsbSrvClient::GetInstance();
|
||||
auto ret = UsbSrvClient.GetDevices(delist);
|
||||
@@ -789,10 +733,6 @@ HWTEST_F(UsbRequestTest, Usbrequestfree003, TestSize.Level1)
|
||||
UsbRequest request;
|
||||
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
|
||||
USBEndpoint point = interface.GetEndpoints().at(0);
|
||||
ret = UsbSrvClient.ReleaseInterface(pip, interface);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestfree003 %{public}d ReleaseInterface=%{public}d", __LINE__,
|
||||
ret);
|
||||
EXPECT_TRUE(ret == 0);
|
||||
ret = UsbSrvClient.ClaimInterface(pip, interface, true);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestfree003 %{public}d ClaimInterface=%{public}d", __LINE__,
|
||||
ret);
|
||||
@@ -812,7 +752,7 @@ HWTEST_F(UsbRequestTest, Usbrequestfree003, TestSize.Level1)
|
||||
bool close = UsbSrvClient.Close(pip);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestfree003 %{public}d close=%{public}d", __LINE__, close);
|
||||
EXPECT_TRUE(close);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : Usbrequestfree003 : RequestFree-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : Usbrequestfree003 : RequestFree");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -822,7 +762,7 @@ HWTEST_F(UsbRequestTest, Usbrequestfree003, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbRequestTest, Usbrequestfree004, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : Usbrequestfree004 : Requestfree-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : Usbrequestfree004 : Requestfree");
|
||||
vector<UsbDevice> delist;
|
||||
auto &UsbSrvClient = UsbSrvClient::GetInstance();
|
||||
auto ret = UsbSrvClient.GetDevices(delist);
|
||||
@@ -839,10 +779,6 @@ HWTEST_F(UsbRequestTest, Usbrequestfree004, TestSize.Level1)
|
||||
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
|
||||
UsbRequest request;
|
||||
USBEndpoint point = interface.GetEndpoints().at(1);
|
||||
ret = UsbSrvClient.ReleaseInterface(pip, interface);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestfree004 %{public}d ReleaseInterface=%{public}d", __LINE__,
|
||||
ret);
|
||||
EXPECT_TRUE(ret == 0);
|
||||
ret = UsbSrvClient.ClaimInterface(pip, interface, true);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestfree004 %{public}d ClaimInterface=%{public}d", __LINE__,
|
||||
ret);
|
||||
@@ -862,7 +798,7 @@ HWTEST_F(UsbRequestTest, Usbrequestfree004, TestSize.Level1)
|
||||
bool close = UsbSrvClient.Close(pip);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestfree004 %{public}d close=%{public}d", __LINE__, close);
|
||||
EXPECT_TRUE(close);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : Usbrequestfree004 : Requestfree-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : Usbrequestfree004 : Requestfree");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -872,7 +808,7 @@ HWTEST_F(UsbRequestTest, Usbrequestfree004, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbRequestTest, Usbrequestfree005, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : Usbrequestfree005 : RequestQueue-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : Usbrequestfree005 : RequestQueue");
|
||||
vector<UsbDevice> delist;
|
||||
auto &UsbSrvClient = UsbSrvClient::GetInstance();
|
||||
auto ret = UsbSrvClient.GetDevices(delist);
|
||||
@@ -889,10 +825,6 @@ HWTEST_F(UsbRequestTest, Usbrequestfree005, TestSize.Level1)
|
||||
UsbRequest request;
|
||||
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
|
||||
USBEndpoint point = interface.GetEndpoints().at(1);
|
||||
ret = UsbSrvClient.ReleaseInterface(pip, interface);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestfree005 %{public}d ReleaseInterface=%{public}d", __LINE__,
|
||||
ret);
|
||||
EXPECT_TRUE(ret == 0);
|
||||
ret = UsbSrvClient.ClaimInterface(pip, interface, true);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestfree005 %{public}d ClaimInterface=%{public}d", __LINE__,
|
||||
ret);
|
||||
@@ -915,7 +847,7 @@ HWTEST_F(UsbRequestTest, Usbrequestfree005, TestSize.Level1)
|
||||
bool close = UsbSrvClient.Close(pip);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestfree005 %{public}d close=%{public}d", __LINE__, close);
|
||||
EXPECT_TRUE(close);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : Usbrequestfree005 : RequestFree-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : Usbrequestfree005 : RequestFree");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -925,7 +857,7 @@ HWTEST_F(UsbRequestTest, Usbrequestfree005, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbRequestTest, Usbrequestfree006, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : Usbrequestfree006 : RequestQueue-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : Usbrequestfree006 : RequestQueue");
|
||||
vector<UsbDevice> delist;
|
||||
auto &UsbSrvClient = UsbSrvClient::GetInstance();
|
||||
auto ret = UsbSrvClient.GetDevices(delist);
|
||||
@@ -942,10 +874,6 @@ HWTEST_F(UsbRequestTest, Usbrequestfree006, TestSize.Level1)
|
||||
UsbRequest request;
|
||||
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
|
||||
USBEndpoint point = interface.GetEndpoints().at(1);
|
||||
ret = UsbSrvClient.ReleaseInterface(pip, interface);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestfree006 %{public}d ReleaseInterface=%{public}d", __LINE__,
|
||||
ret);
|
||||
EXPECT_TRUE(ret == 0);
|
||||
ret = UsbSrvClient.ClaimInterface(pip, interface, true);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestfree006 %{public}d ClaimInterface=%{public}d", __LINE__,
|
||||
ret);
|
||||
@@ -968,7 +896,7 @@ HWTEST_F(UsbRequestTest, Usbrequestfree006, TestSize.Level1)
|
||||
bool close = UsbSrvClient.Close(pip);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestfree006 %{public}d close=%{public}d", __LINE__, close);
|
||||
EXPECT_TRUE(close);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : Usbrequestfree006 : RequestFree-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : Usbrequestfree006 : RequestFree");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -978,7 +906,7 @@ HWTEST_F(UsbRequestTest, Usbrequestfree006, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbRequestTest, Usbrequestabort001, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : Usbrequestabort001 : Requestabort-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : Usbrequestabort001 : Requestabort");
|
||||
vector<UsbDevice> delist;
|
||||
auto &UsbSrvClient = UsbSrvClient::GetInstance();
|
||||
auto ret = UsbSrvClient.GetDevices(delist);
|
||||
@@ -996,10 +924,6 @@ HWTEST_F(UsbRequestTest, Usbrequestabort001, TestSize.Level1)
|
||||
UsbRequest request;
|
||||
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
|
||||
USBEndpoint point = interface.GetEndpoints().at(0);
|
||||
ret = UsbSrvClient.ReleaseInterface(pip, interface);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestabort001 %{public}d ReleaseInterface=%{public}d",
|
||||
__LINE__, ret);
|
||||
EXPECT_TRUE(ret == 0);
|
||||
ret = UsbSrvClient.ClaimInterface(pip, interface, true);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestabort001 %{public}d ClaimInterface=%{public}d", __LINE__,
|
||||
ret);
|
||||
@@ -1023,7 +947,7 @@ HWTEST_F(UsbRequestTest, Usbrequestabort001, TestSize.Level1)
|
||||
bool close = UsbSrvClient.Close(pip);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestabort001 %{public}d close=%{public}d", __LINE__, close);
|
||||
EXPECT_TRUE(close);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : Usbrequestabort001 : Requestabort-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : Usbrequestabort001 : Requestabort");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1033,7 +957,7 @@ HWTEST_F(UsbRequestTest, Usbrequestabort001, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbRequestTest, Usbrequestabort002, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : Usbrequestabort002 : Requestabort-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : Usbrequestabort002 : Requestabort");
|
||||
vector<UsbDevice> delist;
|
||||
auto &UsbSrvClient = UsbSrvClient::GetInstance();
|
||||
auto ret = UsbSrvClient.GetDevices(delist);
|
||||
@@ -1051,10 +975,6 @@ HWTEST_F(UsbRequestTest, Usbrequestabort002, TestSize.Level1)
|
||||
UsbRequest request;
|
||||
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
|
||||
USBEndpoint point = interface.GetEndpoints().at(0);
|
||||
ret = UsbSrvClient.ReleaseInterface(pip, interface);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestabort002 %{public}d ReleaseInterface=%{public}d",
|
||||
__LINE__, ret);
|
||||
EXPECT_TRUE(ret == 0);
|
||||
ret = UsbSrvClient.ClaimInterface(pip, interface, true);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestabort002 %{public}d ClaimInterface=%{public}d", __LINE__,
|
||||
ret);
|
||||
@@ -1078,7 +998,7 @@ HWTEST_F(UsbRequestTest, Usbrequestabort002, TestSize.Level1)
|
||||
bool close = UsbSrvClient.Close(pip);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestabort002 %{public}d close=%{public}d", __LINE__, close);
|
||||
EXPECT_TRUE(close);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : Usbrequestabort002 : Requestabort-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : Usbrequestabort002 : Requestabort");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1088,7 +1008,7 @@ HWTEST_F(UsbRequestTest, Usbrequestabort002, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbRequestTest, Usbrequestabort003, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : Usbrequestabort003 : Requestabort-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : Usbrequestabort003 : Requestabort");
|
||||
vector<UsbDevice> delist;
|
||||
auto &UsbSrvClient = UsbSrvClient::GetInstance();
|
||||
auto ret = UsbSrvClient.GetDevices(delist);
|
||||
@@ -1106,10 +1026,6 @@ HWTEST_F(UsbRequestTest, Usbrequestabort003, TestSize.Level1)
|
||||
UsbRequest request;
|
||||
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
|
||||
USBEndpoint point = interface.GetEndpoints().at(0);
|
||||
ret = UsbSrvClient.ReleaseInterface(pip, interface);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestabort003 %{public}d ReleaseInterface=%{public}d",
|
||||
__LINE__, ret);
|
||||
EXPECT_TRUE(ret == 0);
|
||||
ret = UsbSrvClient.ClaimInterface(pip, interface, true);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestabort003 %{public}d ClaimInterface=%{public}d", __LINE__,
|
||||
ret);
|
||||
@@ -1133,7 +1049,7 @@ HWTEST_F(UsbRequestTest, Usbrequestabort003, TestSize.Level1)
|
||||
bool close = UsbSrvClient.Close(pip);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestabort003 %{public}d close=%{public}d", __LINE__, close);
|
||||
EXPECT_TRUE(close);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : Usbrequestabort003 : Requestabort-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : Usbrequestabort003 : Requestabort");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1143,7 +1059,7 @@ HWTEST_F(UsbRequestTest, Usbrequestabort003, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbRequestTest, Usbrequestabort004, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : Usbrequestabort004 : Requestabort-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : Usbrequestabort004 : Requestabort");
|
||||
vector<UsbDevice> delist;
|
||||
auto &UsbSrvClient = UsbSrvClient::GetInstance();
|
||||
auto ret = UsbSrvClient.GetDevices(delist);
|
||||
@@ -1165,8 +1081,6 @@ HWTEST_F(UsbRequestTest, Usbrequestabort004, TestSize.Level1)
|
||||
point.GetDirection());
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestabort004 %{public}d GetInterfaceId=%{public}d ", __LINE__,
|
||||
point.GetInterfaceId());
|
||||
ret = UsbSrvClient.ReleaseInterface(pip, interface);
|
||||
EXPECT_TRUE(ret == 0);
|
||||
ret = UsbSrvClient.ClaimInterface(pip, interface, true);
|
||||
EXPECT_TRUE(ret == 0);
|
||||
uint8_t tag[50] = "hello world request013";
|
||||
@@ -1186,7 +1100,7 @@ HWTEST_F(UsbRequestTest, Usbrequestabort004, TestSize.Level1)
|
||||
bool close = UsbSrvClient.Close(pip);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestabort004 %{public}d close=%{public}d", __LINE__, close);
|
||||
EXPECT_TRUE(close);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : Usbrequestabort004 : Requestabort-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : Usbrequestabort004 : Requestabort");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1196,7 +1110,7 @@ HWTEST_F(UsbRequestTest, Usbrequestabort004, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbRequestTest, Usbrequestabort005, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : Usbrequestabort005 : Requestabort-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : Usbrequestabort005 : Requestabort");
|
||||
vector<UsbDevice> delist;
|
||||
auto &UsbSrvClient = UsbSrvClient::GetInstance();
|
||||
auto ret = UsbSrvClient.GetDevices(delist);
|
||||
@@ -1214,8 +1128,6 @@ HWTEST_F(UsbRequestTest, Usbrequestabort005, TestSize.Level1)
|
||||
UsbRequest request;
|
||||
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
|
||||
USBEndpoint point = interface.GetEndpoints().at(1);
|
||||
ret = UsbSrvClient.ReleaseInterface(pip, interface);
|
||||
EXPECT_TRUE(ret == 0);
|
||||
ret = UsbSrvClient.ClaimInterface(pip, interface, true);
|
||||
EXPECT_TRUE(ret == 0);
|
||||
uint8_t tag[50] = "request abort 005";
|
||||
@@ -1238,7 +1150,7 @@ HWTEST_F(UsbRequestTest, Usbrequestabort005, TestSize.Level1)
|
||||
bool close = UsbSrvClient.Close(pip);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestabort005 %{public}d close=%{public}d", __LINE__, close);
|
||||
EXPECT_TRUE(close);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : Usbrequestabort005 : Requestabort-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : Usbrequestabort005 : Requestabort");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1248,7 +1160,7 @@ HWTEST_F(UsbRequestTest, Usbrequestabort005, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbRequestTest, Usbrequestabort006, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : Usbrequestabort006 : Requestabort-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : Usbrequestabort006 : Requestabort");
|
||||
vector<UsbDevice> delist;
|
||||
auto &UsbSrvClient = UsbSrvClient::GetInstance();
|
||||
auto ret = UsbSrvClient.GetDevices(delist);
|
||||
@@ -1266,10 +1178,6 @@ HWTEST_F(UsbRequestTest, Usbrequestabort006, TestSize.Level1)
|
||||
UsbRequest request;
|
||||
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
|
||||
USBEndpoint point = interface.GetEndpoints().at(1);
|
||||
ret = UsbSrvClient.ReleaseInterface(pip, interface);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestabort006 %{public}d ReleaseInterface=%{public}d",
|
||||
__LINE__, ret);
|
||||
EXPECT_TRUE(ret == 0);
|
||||
ret = UsbSrvClient.ClaimInterface(pip, interface, true);
|
||||
EXPECT_TRUE(ret == 0);
|
||||
uint8_t tag[50] = "request abort 006";
|
||||
@@ -1292,7 +1200,7 @@ HWTEST_F(UsbRequestTest, Usbrequestabort006, TestSize.Level1)
|
||||
bool close = UsbSrvClient.Close(pip);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestabort006 %{public}d close=%{public}d", __LINE__, close);
|
||||
EXPECT_TRUE(close);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : Usbrequestabort006 : Requestabort-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : Usbrequestabort006 : Requestabort");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1302,7 +1210,7 @@ HWTEST_F(UsbRequestTest, Usbrequestabort006, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbRequestTest, PipeRequestWait001, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : PipeRequestWait001 : Initialize-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : PipeRequestWait001 : Initialize");
|
||||
vector<UsbDevice> delist;
|
||||
auto &UsbSrvClient = UsbSrvClient::GetInstance();
|
||||
auto ret = UsbSrvClient.GetDevices(delist);
|
||||
@@ -1319,10 +1227,6 @@ HWTEST_F(UsbRequestTest, PipeRequestWait001, TestSize.Level1)
|
||||
EXPECT_TRUE(ret == 0);
|
||||
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
|
||||
USBEndpoint point = interface.GetEndpoints().front();
|
||||
ret = UsbSrvClient.ReleaseInterface(pip, interface);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::PipeRequestWait001 %{public}d ReleaseInterface=%{public}d",
|
||||
__LINE__, ret);
|
||||
EXPECT_TRUE(ret == 0);
|
||||
ret = UsbSrvClient.ClaimInterface(pip, interface, true);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::PipeRequestWait001 %{public}d ClaimInterface=%{public}d", __LINE__,
|
||||
ret);
|
||||
@@ -1346,7 +1250,7 @@ HWTEST_F(UsbRequestTest, PipeRequestWait001, TestSize.Level1)
|
||||
bool close = UsbSrvClient.Close(pip);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::PipeRequestWait001 %{public}d close=%{public}d", __LINE__, close);
|
||||
EXPECT_TRUE(close);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : PipeRequestWait001 : Initialize-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : PipeRequestWait001 : Initialize");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1356,7 +1260,7 @@ HWTEST_F(UsbRequestTest, PipeRequestWait001, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbRequestTest, PipeRequestWait002, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : PipeRequestWait002 : Initialize-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : PipeRequestWait002 : Initialize");
|
||||
vector<UsbDevice> delist;
|
||||
auto &UsbSrvClient = UsbSrvClient::GetInstance();
|
||||
auto ret = UsbSrvClient.GetDevices(delist);
|
||||
@@ -1373,10 +1277,6 @@ HWTEST_F(UsbRequestTest, PipeRequestWait002, TestSize.Level1)
|
||||
EXPECT_TRUE(ret == 0);
|
||||
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
|
||||
USBEndpoint point = interface.GetEndpoints().front();
|
||||
ret = UsbSrvClient.ReleaseInterface(pip, interface);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::PipeRequestWait002 %{public}d ReleaseInterface=%{public}d",
|
||||
__LINE__, ret);
|
||||
EXPECT_TRUE(ret == 0);
|
||||
ret = UsbSrvClient.ClaimInterface(pip, interface, true);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::PipeRequestWait002 %{public}d ClaimInterface=%{public}d", __LINE__,
|
||||
ret);
|
||||
@@ -1402,7 +1302,7 @@ HWTEST_F(UsbRequestTest, PipeRequestWait002, TestSize.Level1)
|
||||
bool close = UsbSrvClient.Close(pip);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::PipeRequestWait002 %{public}d close=%{public}d", __LINE__, close);
|
||||
EXPECT_TRUE(close);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : PipeRequestWait002 : Initialize-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : PipeRequestWait002 : Initialize");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1412,7 +1312,7 @@ HWTEST_F(UsbRequestTest, PipeRequestWait002, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbRequestTest, PipeRequestWait003, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : PipeRequestWait003 : Initialize-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : PipeRequestWait003 : Initialize");
|
||||
vector<UsbDevice> delist;
|
||||
auto &UsbSrvClient = UsbSrvClient::GetInstance();
|
||||
auto ret = UsbSrvClient.GetDevices(delist);
|
||||
@@ -1429,10 +1329,6 @@ HWTEST_F(UsbRequestTest, PipeRequestWait003, TestSize.Level1)
|
||||
EXPECT_TRUE(ret == 0);
|
||||
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
|
||||
USBEndpoint point = interface.GetEndpoints().front();
|
||||
ret = UsbSrvClient.ReleaseInterface(pip, interface);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::PipeRequestWait003 %{public}d ReleaseInterface=%{public}d",
|
||||
__LINE__, ret);
|
||||
EXPECT_TRUE(ret == 0);
|
||||
ret = UsbSrvClient.ClaimInterface(pip, interface, true);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::PipeRequestWait003 %{public}d ClaimInterface=%{public}d", __LINE__,
|
||||
ret);
|
||||
@@ -1458,7 +1354,7 @@ HWTEST_F(UsbRequestTest, PipeRequestWait003, TestSize.Level1)
|
||||
bool close = UsbSrvClient.Close(pip);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::PipeRequestWait003 %{public}d close=%{public}d", __LINE__, close);
|
||||
EXPECT_TRUE(close);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : PipeRequestWait003 : Initialize-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : PipeRequestWait003 : Initialize");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1468,7 +1364,7 @@ HWTEST_F(UsbRequestTest, PipeRequestWait003, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbRequestTest, PipeRequestWait004, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : PipeRequestWait004 : Initialize-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : PipeRequestWait004 : Initialize");
|
||||
vector<UsbDevice> delist;
|
||||
auto &UsbSrvClient = UsbSrvClient::GetInstance();
|
||||
auto ret = UsbSrvClient.GetDevices(delist);
|
||||
@@ -1485,8 +1381,6 @@ HWTEST_F(UsbRequestTest, PipeRequestWait004, TestSize.Level1)
|
||||
EXPECT_TRUE(ret == 0);
|
||||
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
|
||||
USBEndpoint point = interface.GetEndpoints().at(1);
|
||||
ret = UsbSrvClient.ReleaseInterface(pip, interface);
|
||||
EXPECT_TRUE(ret == 0);
|
||||
ret = UsbSrvClient.ClaimInterface(pip, interface, true);
|
||||
EXPECT_TRUE(ret == 0);
|
||||
UsbRequest request;
|
||||
@@ -1511,7 +1405,7 @@ HWTEST_F(UsbRequestTest, PipeRequestWait004, TestSize.Level1)
|
||||
bool close = UsbSrvClient.Close(pip);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::PipeRequestWait004 %{public}d close=%{public}d", __LINE__, close);
|
||||
EXPECT_TRUE(close);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : PipeRequestWait004 : Initialize-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : PipeRequestWait004 : Initialize");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1521,7 +1415,7 @@ HWTEST_F(UsbRequestTest, PipeRequestWait004, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbRequestTest, PipeRequestWait005, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : PipeRequestWait005 : Initialize-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : PipeRequestWait005 : Initialize");
|
||||
vector<UsbDevice> delist;
|
||||
auto &UsbSrvClient = UsbSrvClient::GetInstance();
|
||||
auto ret = UsbSrvClient.GetDevices(delist);
|
||||
@@ -1538,8 +1432,6 @@ HWTEST_F(UsbRequestTest, PipeRequestWait005, TestSize.Level1)
|
||||
EXPECT_TRUE(ret == 0);
|
||||
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
|
||||
USBEndpoint point = interface.GetEndpoints().at(1);
|
||||
ret = UsbSrvClient.ReleaseInterface(pip, interface);
|
||||
EXPECT_TRUE(ret == 0);
|
||||
ret = UsbSrvClient.ClaimInterface(pip, interface, true);
|
||||
EXPECT_TRUE(ret == 0);
|
||||
UsbRequest request;
|
||||
@@ -1564,7 +1456,7 @@ HWTEST_F(UsbRequestTest, PipeRequestWait005, TestSize.Level1)
|
||||
bool close = UsbSrvClient.Close(pip);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::PipeRequestWait005 %{public}d close=%{public}d", __LINE__, close);
|
||||
EXPECT_TRUE(close);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : PipeRequestWait005 : Initialize-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : PipeRequestWait005 : Initialize");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1574,7 +1466,7 @@ HWTEST_F(UsbRequestTest, PipeRequestWait005, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(UsbRequestTest, PipeRequestWait006, TestSize.Level1)
|
||||
{
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case Start : PipeRequestWait006 : Initialize-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case Start : PipeRequestWait006 : Initialize");
|
||||
vector<UsbDevice> delist;
|
||||
auto &UsbSrvClient = UsbSrvClient::GetInstance();
|
||||
auto ret = UsbSrvClient.GetDevices(delist);
|
||||
@@ -1591,10 +1483,6 @@ HWTEST_F(UsbRequestTest, PipeRequestWait006, TestSize.Level1)
|
||||
EXPECT_TRUE(ret == 0);
|
||||
UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
|
||||
USBEndpoint point = interface.GetEndpoints().at(1);
|
||||
ret = UsbSrvClient.ReleaseInterface(pip, interface);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::PipeRequestWait006 %{public}d ReleaseInterface=%{public}d",
|
||||
__LINE__, ret);
|
||||
EXPECT_TRUE(ret == 0);
|
||||
ret = UsbSrvClient.ClaimInterface(pip, interface, true);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::PipeRequestWait006 %{public}d ClaimInterface=%{public}d", __LINE__,
|
||||
ret);
|
||||
@@ -1621,5 +1509,5 @@ HWTEST_F(UsbRequestTest, PipeRequestWait006, TestSize.Level1)
|
||||
bool close = UsbSrvClient.Close(pip);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::PipeRequestWait006 %{public}d close=%{public}d", __LINE__, close);
|
||||
EXPECT_TRUE(close);
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "-----------Case End : PipeRequestWait006 : Initialize-----------");
|
||||
USB_HILOGI(MODULE_USB_SERVICE, "Case End : PipeRequestWait006 : Initialize");
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
# Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//base/usb/usb_manager/usbmgr.gni")
|
||||
import("//build/test.gni")
|
||||
|
||||
config("usbsrv_private_config") {
|
||||
include_dirs = [
|
||||
"//utils/system/safwk/native/include",
|
||||
"//drivers/peripheral/usb/hal/client/include",
|
||||
]
|
||||
}
|
||||
|
||||
ohos_executable("usb_function_port_test") {
|
||||
sources = [ "usb_function_port_test.cpp" ]
|
||||
configs = [
|
||||
"${utils_path}:utils_config",
|
||||
":usbsrv_private_config",
|
||||
]
|
||||
deps = [
|
||||
"//base/usb/usb_manager/interfaces/innerkits:usbsrv_client",
|
||||
"//utils/native/base:utils",
|
||||
]
|
||||
external_deps = [
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
]
|
||||
install_enable = true
|
||||
subsystem_name = "usb"
|
||||
part_name = "usb_manager_native"
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "usb_srv_client.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace OHOS;
|
||||
using namespace OHOS::USB;
|
||||
|
||||
static const int32_t DEFAULT_PORT_ID = 1;
|
||||
static const int32_t DEFAULT_ROLE_HOST = 1;
|
||||
static const int32_t DEFAULT_ROLE_DEVICE = 2;
|
||||
|
||||
static const int32_t HOST_MODE = 2;
|
||||
|
||||
static UsbSrvClient &g_usbClient = UsbSrvClient::GetInstance();
|
||||
|
||||
static void PrintHelp()
|
||||
{
|
||||
printf("2 args\n");
|
||||
printf("-p 0: Query Port\n");
|
||||
printf("-p 1: Switch to host\n");
|
||||
printf("-p 2: Switch to device:\n");
|
||||
printf("-f 0: Query fucntion\n");
|
||||
printf("-f 1: Switch to function:acm\n");
|
||||
printf("-f 2: Switch to function:ecm\n");
|
||||
printf("-f 3: Switch to function:acm&ecm\n");
|
||||
printf("-f 4: Switch to function:hdc\n");
|
||||
printf("-f 5: Switch to function:acm&hdc\n");
|
||||
printf("-f 6: Switch to function:ecm&hdc\n");
|
||||
}
|
||||
|
||||
static void GetCurrentFunctionInfo()
|
||||
{
|
||||
int32_t funcs = -1;
|
||||
string strFun = "";
|
||||
int32_t ret = g_usbClient.GetCurrentFunctions(funcs);
|
||||
if (ret) {
|
||||
printf("%s:%d error exit\n", __func__, __LINE__);
|
||||
return;
|
||||
}
|
||||
strFun = g_usbClient.UsbFunctionsToString(funcs);
|
||||
printf("%s:%d get current function: %s\n", __func__, __LINE__, strFun.c_str());
|
||||
}
|
||||
|
||||
static void FunctionSwitch(UsbSrvClient &g_usbClient, int32_t mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case 0:
|
||||
GetCurrentFunctionInfo();
|
||||
break;
|
||||
default:
|
||||
int32_t ret = g_usbClient.SetCurrentFunctions(mode);
|
||||
if (ret) {
|
||||
printf("%s:%d error exit\n", __func__, __LINE__);
|
||||
break;
|
||||
}
|
||||
GetCurrentFunctionInfo();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void GetPortsInfo()
|
||||
{
|
||||
std::vector<UsbPort> usbports;
|
||||
int32_t ret = g_usbClient.GetPorts(usbports);
|
||||
if (ret) {
|
||||
printf("%s:%d error exit\n", __func__, __LINE__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (usbports[0].usbPortStatus.currentMode == HOST_MODE) {
|
||||
printf("get current port %d: host\n", usbports[0].usbPortStatus.currentMode);
|
||||
} else {
|
||||
printf("get current port %d: device\n", usbports[0].usbPortStatus.currentMode);
|
||||
}
|
||||
}
|
||||
|
||||
static void PortSwitch(UsbSrvClient &g_usbClient, int32_t mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case 0:
|
||||
GetPortsInfo();
|
||||
break;
|
||||
case DEFAULT_ROLE_HOST:
|
||||
g_usbClient.SetPortRole(DEFAULT_PORT_ID, DEFAULT_ROLE_HOST, DEFAULT_ROLE_HOST);
|
||||
GetPortsInfo();
|
||||
break;
|
||||
case DEFAULT_ROLE_DEVICE:
|
||||
g_usbClient.SetPortRole(DEFAULT_PORT_ID, DEFAULT_ROLE_DEVICE, DEFAULT_ROLE_DEVICE);
|
||||
GetPortsInfo();
|
||||
break;
|
||||
default:
|
||||
printf("%s:%d port param error\n", __func__, __LINE__);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t main(int32_t argc, char *argv[])
|
||||
{
|
||||
if ((argc < 1) || (strcmp(argv[1], "-h") == 0)) {
|
||||
PrintHelp();
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((!strcmp(argv[1], "-f"))) {
|
||||
int32_t mode = atoi(argv[2]);
|
||||
FunctionSwitch(g_usbClient, mode);
|
||||
} else if (!strcmp(argv[1], "-p")) {
|
||||
int32_t mode = atoi(argv[2]);
|
||||
PortSwitch(g_usbClient, mode);
|
||||
} else {
|
||||
printf("param incorrect: please input -h for help\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user