link event

Signed-off-by: 18392170496 <magentang4@huawei.com>
This commit is contained in:
18392170496 2024-11-26 22:39:22 +08:00
parent f024b355a3
commit 6696dbf090
24 changed files with 392 additions and 10 deletions

View File

@ -111,6 +111,7 @@ enum SoftBusFuncId {
CLIENT_ON_DATA_LEVEL_CHANGED,
CLIENT_ON_TRANS_LIMIT_CHANGE,
CLIENT_ON_CHANNEL_BIND,
CLIENT_CHANNEL_ON_QOS,
};
#ifdef __cplusplus

View File

@ -17,6 +17,7 @@
#define TRANS_CLIENT_PROXY_H
#include "session.h"
#include "socket.h"
#include "softbus_def.h"
#include "softbus_trans_def.h"
@ -47,6 +48,7 @@ int32_t ClientIpcSetChannelInfo(
int32_t ClientIpcOnTransLimitChange(const char *pkgName, int32_t pid, int32_t channelId, uint8_t tos);
int32_t CheckServiceIsRegistered(const char *pkgName, int32_t pid);
void RegisterPermissionChangeCallback(void);
int32_t ClientIpcChannelOnQos(ChannelMsg *data, QoSEvent event, const QosTV *qos, uint32_t count);
#ifdef __cplusplus
}

View File

@ -85,4 +85,13 @@ int32_t CheckServiceIsRegistered(const char *pkgName, int32_t pid)
(void)pkgName;
(void)pid;
return SOFTBUS_FUNC_NOT_SUPPORT;
}
int32_t ClientIpcChannelOnQos(ChannelMsg *data, QoSEvent event, const QosTV *qos, uint32_t count)
{
(void)data;
(void)event;
(void)qos;
(void)count;
return SOFTBUS_FUNC_NOT_SUPPORT;
}

View File

@ -315,4 +315,13 @@ int32_t CheckServiceIsRegistered(const char *pkgName, int32_t pid)
(void)pkgName;
(void)pid;
return SOFTBUS_FUNC_NOT_SUPPORT;
}
int32_t ClientIpcChannelOnQos(ChannelMsg *data, QoSEvent event, const QosTV *qos, uint32_t count)
{
(void)data;
(void)event;
(void)qos;
(void)count;
return SOFTBUS_FUNC_NOT_SUPPORT;
}

View File

@ -50,6 +50,8 @@ public:
int32_t OnClientPermissonChange(const char *pkgName, int32_t state);
void OnDataLevelChanged(const char *networkId, const DataLevelInfo *dataLevelInfo) override;
int32_t OnClientTransLimitChange(int32_t channelId, uint8_t tos) override;
int32_t OnClientChannelOnQos(
int32_t channelId, int32_t channelType, QoSEvent event, const QosTV *qos, uint32_t count) override;
private:
static inline BrokerDelegator<TransClientProxy> delegator_;

View File

@ -246,4 +246,19 @@ int32_t CheckServiceIsRegistered(const char *pkgName, int32_t pid)
return SOFTBUS_TRANS_GET_CLIENT_PROXY_NULL;
}
return SOFTBUS_OK;
}
int32_t ClientIpcChannelOnQos(ChannelMsg *data, QoSEvent event, const QosTV *qos, uint32_t count)
{
if (data == nullptr || data->msgPkgName == nullptr || qos == nullptr || count == 0 || count >= QOS_TYPE_BUTT) {
TRANS_LOGE(TRANS_SDK, "invalid param.");
return SOFTBUS_INVALID_PARAM;
}
sptr<TransClientProxy> clientProxy = GetClientProxy(data->msgPkgName, data->msgPid);
if (clientProxy == nullptr) {
TRANS_LOGE(TRANS_SDK, "softbus client proxy is nullptr!");
return SOFTBUS_TRANS_GET_CLIENT_PROXY_NULL;
}
return clientProxy->OnClientChannelOnQos(data->msgChannelId, data->msgChannelType, event, qos, count);
}

View File

@ -376,6 +376,40 @@ int32_t TransClientProxy::SetChannelInfo(
return serverRet;
}
int32_t TransClientProxy::OnClientChannelOnQos(
int32_t channelId, int32_t channelType, QoSEvent event, const QosTV *qos, uint32_t count)
{
if (qos == nullptr) {
TRANS_LOGE(TRANS_CTRL, "qos is nullptr");
return SOFTBUS_INVALID_PARAM;
}
sptr<IRemoteObject> remote = Remote();
TRANS_CHECK_AND_RETURN_RET_LOGE(
remote != nullptr, SOFTBUS_TRANS_PROXY_REMOTE_NULL, TRANS_CTRL, "remote is nullptr");
MessageParcel data;
TRANS_CHECK_AND_RETURN_RET_LOGE(data.WriteInterfaceToken(GetDescriptor()), SOFTBUS_TRANS_PROXY_WRITETOKEN_FAILED,
TRANS_CTRL, "write interface token failed!");
TRANS_CHECK_AND_RETURN_RET_LOGE(
data.WriteInt32(channelId), SOFTBUS_TRANS_PROXY_WRITEINT_FAILED, TRANS_CTRL, "write channel id failed");
TRANS_CHECK_AND_RETURN_RET_LOGE(
data.WriteInt32(channelType), SOFTBUS_TRANS_PROXY_WRITEINT_FAILED, TRANS_CTRL, "write channel type failed");
TRANS_CHECK_AND_RETURN_RET_LOGE(
data.WriteInt32(event), SOFTBUS_TRANS_PROXY_WRITEINT_FAILED, TRANS_CTRL, "write qos event failed");
TRANS_CHECK_AND_RETURN_RET_LOGE(
data.WriteUint32(count), SOFTBUS_TRANS_PROXY_WRITEINT_FAILED, TRANS_CTRL, "write qos tv count failed");
TRANS_CHECK_AND_RETURN_RET_LOGE(
data.WriteBuffer(qos, sizeof(QosTV) * count), SOFTBUS_IPC_ERR, TRANS_CTRL, "write qos failed");
MessageParcel reply;
MessageOption option = { MessageOption::TF_ASYNC };
int32_t ret = remote->SendRequest(CLIENT_CHANNEL_ON_QOS, data, reply, option);
if (ret != SOFTBUS_OK) {
TRANS_LOGE(TRANS_CTRL, "OnClientChannelOnQos send request failed, ret=%{public}d", ret);
return SOFTBUS_TRANS_PROXY_SEND_REQUEST_FAILED;
}
return SOFTBUS_OK;
}
int32_t TransClientProxy::OnJoinLNNResult(void *addr, uint32_t addrTypeLen, const char *networkId, int retCode)
{
(void)addr;

View File

@ -789,6 +789,65 @@ static void TransOnLaneFreeFail(uint32_t laneHandle, int32_t reason)
}
}
static int32_t TransNotifyLaneQosEvent(uint32_t laneHandle, LaneOwner laneOwner, LaneQosEvent qosEvent)
{
if (laneOwner > LANE_OWNER_BUTT || laneOwner < LANE_OWNER_SELF || qosEvent > LANE_QOS_BW_BUTT ||
qosEvent < LANE_QOS_BW_HIGH) {
TRANS_LOGE(
TRANS_SVC, "invalid lane owner or qos event, owner=%{public}d, qosEvent=%{public}d", laneOwner, qosEvent);
return SOFTBUS_INVALID_PARAM;
}
if (laneOwner != LANE_OWNER_OTHER || qosEvent != LANE_QOS_BW_HIGH) {
TRANS_LOGI(TRANS_SVC, "ignore lane qos event, owner=%{public}d, qosEvent=%{public}d", laneOwner, qosEvent);
return SOFTBUS_OK;
}
TransLaneInfo laneInfo;
(void)memset_s(&laneInfo, sizeof(TransLaneInfo), 0, sizeof(TransLaneInfo));
int32_t ret = TransGetTransLaneInfoByLaneHandle(laneHandle, &laneInfo);
if (ret != SOFTBUS_OK) {
TRANS_LOGE(TRANS_SVC, "get trans lane info failed, laneHandle=%{public}u, ret=%{public}d", laneHandle, ret);
return ret;
}
ChannelMsg data = {
.msgChannelId = laneInfo.channelId,
.msgChannelType = laneInfo.channelType,
.msgPid = laneInfo.pid,
.msgPkgName = laneInfo.pkgName,
.msgUuid = NULL,
.msgUdid = NULL
};
switch (qosEvent) {
case LANE_QOS_BW_HIGH: {
uint32_t count = 1;
QosTV qos[] = {
{QOS_TYPE_MIN_BW, 0},
};
QoSEvent event = QOS_SATISFIED;
ret = ClientIpcChannelOnQos(&data, event, (const QosTV *)qos, count);
if (ret != SOFTBUS_OK) {
TRANS_LOGE(
TRANS_SVC, "qos event failed, channelId=%{public}d, ret=%{public}d", laneInfo.channelId, ret);
}
break;
}
default:
ret = SOFTBUS_NOT_IMPLEMENT;
TRANS_LOGE(TRANS_SVC, "invalid lane qos event type, type=%{public}d", qosEvent);
break;
}
return ret;
}
static void TransOnLaneQosEvent(uint32_t laneHandle, LaneOwner laneOwner, LaneQosEvent qosEvent)
{
TRANS_LOGI(TRANS_SVC, "lane qos event, laneHandle=%{public}u, owner=%{public}d, qosEvent=%{public}d", laneHandle,
laneOwner, qosEvent);
int32_t ret = TransNotifyLaneQosEvent(laneHandle, laneOwner, qosEvent);
if (ret != SOFTBUS_OK) {
TRANS_LOGE(TRANS_SVC, "notify qos event failed, laneHandle=%{public}u, ret=%{public}d", laneHandle, ret);
}
}
static const LaneLinkType g_laneMap[LINK_TYPE_MAX + 1] = {
LANE_LINK_TYPE_BUTT,
LANE_WLAN_5G,
@ -1152,6 +1211,7 @@ static int32_t TransAddLaneAllocToPendingAndWaiting(uint32_t laneHandle, const L
allocListener.onLaneAllocFail = TransOnLaneRequestFail;
allocListener.onLaneFreeSuccess = TransOnLaneFreeSuccess;
allocListener.onLaneFreeFail = TransOnLaneFreeFail;
allocListener.onLaneQosEvent = TransOnLaneQosEvent;
TRANS_CHECK_AND_RETURN_RET_LOGE(
GetLaneManager() != NULL, SOFTBUS_TRANS_GET_LANE_INFO_ERR, TRANS_SVC, "GetLaneManager is null");
TRANS_CHECK_AND_RETURN_RET_LOGE(GetLaneManager()->lnnAllocLane != NULL, SOFTBUS_TRANS_GET_LANE_INFO_ERR,
@ -1357,6 +1417,7 @@ int32_t TransAsyncGetLaneInfoByQos(const SessionParam *param, const LaneAllocInf
allocListener.onLaneAllocFail = TransOnAsyncLaneFail;
allocListener.onLaneFreeSuccess = TransOnLaneFreeSuccess;
allocListener.onLaneFreeFail = TransOnLaneFreeFail;
allocListener.onLaneQosEvent = TransOnLaneQosEvent;
TRANS_CHECK_AND_RETURN_RET_LOGE(GetLaneManager()->lnnAllocLane != NULL, SOFTBUS_TRANS_GET_LANE_INFO_ERR,
TRANS_SVC, "lnnAllocLane is null");
ret = GetLaneManager()->lnnAllocLane(*laneHandle, allocInfo, &allocListener);

View File

@ -35,6 +35,17 @@ typedef enum {
CORE_SESSION_STATE_BUTT,
} CoreSessionState;
typedef struct {
ListNode node;
bool isQosLane;
char pkgName[PKG_NAME_SIZE_MAX];
int32_t channelId;
int32_t channelType;
int32_t pid;
uint32_t laneHandle;
LaneConnInfo laneConnInfo;
} TransLaneInfo;
int32_t TransLaneMgrInit(void);
int32_t TransSocketLaneMgrInit(void);
@ -86,6 +97,8 @@ int32_t TransGetPidFromSocketChannelInfoBySession(const char *sessionName, int32
int32_t TransGetConnectTypeByChannelId(int32_t channelId, ConnectType *connectType);
int32_t TransGetTransLaneInfoByLaneHandle(uint32_t laneHandle, TransLaneInfo *laneInfo);
#ifdef __cplusplus
}
#endif /* __cplusplus */

View File

@ -30,16 +30,6 @@
#include "trans_session_manager.h"
#define CMD_CONCURRENT_SESSION_LIST "concurrent_sessionlist"
typedef struct {
ListNode node;
bool isQosLane;
char pkgName[PKG_NAME_SIZE_MAX];
int32_t channelId;
int32_t channelType;
int32_t pid;
uint32_t laneHandle;
LaneConnInfo laneConnInfo;
} TransLaneInfo;
typedef struct {
ListNode node;
@ -859,4 +849,35 @@ int32_t TransGetConnectTypeByChannelId(int32_t channelId, ConnectType *connectTy
(void)SoftBusMutexUnlock(&(g_channelLaneList->lock));
TRANS_LOGE(TRANS_SVC, "can not find connectType by channelId=%{public}d", channelId);
return SOFTBUS_TRANS_INVALID_CHANNEL_ID;
}
int32_t TransGetTransLaneInfoByLaneHandle(uint32_t laneHandle, TransLaneInfo *laneInfo)
{
if (laneInfo == NULL) {
TRANS_LOGE(TRANS_INIT, "laneInfo is null");
return SOFTBUS_INVALID_PARAM;
}
if (g_channelLaneList == NULL) {
TRANS_LOGE(TRANS_INIT, "trans lane manager hasn't init.");
return SOFTBUS_INVALID_PARAM;
}
if (SoftBusMutexLock(&(g_channelLaneList->lock)) != SOFTBUS_OK) {
TRANS_LOGE(TRANS_SVC, "lock failed");
return SOFTBUS_LOCK_ERR;
}
TransLaneInfo *item = NULL;
LIST_FOR_EACH_ENTRY(item, &(g_channelLaneList->list), TransLaneInfo, node) {
if (item->laneHandle == laneHandle) {
if (memcpy_s(laneInfo, sizeof(TransLaneInfo), item, sizeof(TransLaneInfo)) != EOK) {
(void)SoftBusMutexUnlock(&(g_channelLaneList->lock));
return SOFTBUS_MEM_ERR;
}
(void)SoftBusMutexUnlock(&(g_channelLaneList->lock));
return SOFTBUS_OK;
}
}
(void)SoftBusMutexUnlock(&(g_channelLaneList->lock));
TRANS_LOGE(TRANS_SVC, "can not find laneInfo by laneHandle=%{public}u", laneHandle);
return SOFTBUS_NOT_FIND;
}

View File

@ -21,6 +21,7 @@
#include "iremote_object.h"
#include "iremote_proxy.h"
#include "session.h"
#include "socket.h"
#include "softbus_common.h"
#include "softbus_def.h"
@ -79,6 +80,10 @@ public:
virtual int32_t OnClientTransLimitChange(int32_t channelId, uint8_t tos);
virtual int32_t OnChannelBind(int32_t channelId, int32_t channelType);
virtual int32_t OnClientChannelOnQos(
int32_t channelId, int32_t channelType, QoSEvent event, const QosTV *qos, uint32_t count);
public:
DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.ISoftBusClient");
};

View File

@ -60,6 +60,8 @@ public:
void OnDataLevelChanged(const char *networkId, const DataLevelInfo *dataLevelInfo) override;
int32_t OnClientTransLimitChange(int32_t channelId, uint8_t tos) override;
int32_t OnChannelBind(int32_t channelId, int32_t channelType) override;
int32_t OnClientChannelOnQos(
int32_t channelId, int32_t channelType, QoSEvent event, const QosTV *qos, uint32_t count) override;
private:
int32_t OnChannelOpenedInner(MessageParcel &data, MessageParcel &reply);
@ -85,6 +87,7 @@ private:
int32_t OnDataLevelChangedInner(MessageParcel &data, MessageParcel &reply);
int32_t OnClientTransLimitChangeInner(MessageParcel &data, MessageParcel &reply);
int32_t OnChannelBindInner(MessageParcel &data, MessageParcel &reply);
int32_t OnChannelOnQosInner(MessageParcel &data, MessageParcel &reply);
using SoftBusClientStubFunc =
int32_t (SoftBusClientStub::*)(MessageParcel &data, MessageParcel &reply);
std::map<uint32_t, SoftBusClientStubFunc> memberFuncMap_;

View File

@ -175,4 +175,16 @@ int32_t ISoftBusClient::OnChannelBind(int32_t channelId, int32_t channelType)
COMM_LOGI(COMM_EVENT, "ipc default impl");
return SOFTBUS_OK;
}
int32_t ISoftBusClient::OnClientChannelOnQos(
int32_t channelId, int32_t channelType, QoSEvent event, const QosTV *qos, uint32_t count)
{
(void)channelId;
(void)channelType;
(void)event;
(void)qos;
(void)count;
COMM_LOGI(COMM_EVENT, "ipc default impl");
return SOFTBUS_OK;
}
} // namespace OHOS

View File

@ -61,6 +61,7 @@ SoftBusClientStub::SoftBusClientStub()
memberFuncMap_[CLIENT_ON_DATA_LEVEL_CHANGED] = &SoftBusClientStub::OnDataLevelChangedInner;
memberFuncMap_[CLIENT_ON_TRANS_LIMIT_CHANGE] = &SoftBusClientStub::OnClientTransLimitChangeInner;
memberFuncMap_[CLIENT_ON_CHANNEL_BIND] = &SoftBusClientStub::OnChannelBindInner;
memberFuncMap_[CLIENT_CHANNEL_ON_QOS] = &SoftBusClientStub::OnChannelOnQosInner;
}
int32_t SoftBusClientStub::OnRemoteRequest(uint32_t code,
@ -337,6 +338,37 @@ int32_t SoftBusClientStub::OnChannelQosEventInner(MessageParcel &data, MessagePa
return SOFTBUS_OK;
}
int32_t SoftBusClientStub::OnChannelOnQosInner(MessageParcel &data, MessageParcel &reply)
{
COMM_LOGI(COMM_EVENT, "OnChannelOnQosInner");
int32_t channelId;
COMM_CHECK_AND_RETURN_RET_LOGE(
data.ReadInt32(channelId), SOFTBUS_TRANS_PROXY_READINT_FAILED, COMM_SDK, "read channelId failed");
int32_t channelType;
COMM_CHECK_AND_RETURN_RET_LOGE(
data.ReadInt32(channelType), SOFTBUS_TRANS_PROXY_READINT_FAILED, COMM_SDK, "read channelType failed");
int32_t event;
COMM_CHECK_AND_RETURN_RET_LOGE(
data.ReadInt32(event), SOFTBUS_TRANS_PROXY_READINT_FAILED, COMM_SDK, "read event failed");
uint32_t count;
COMM_CHECK_AND_RETURN_RET_LOGE(
data.ReadUint32(count), SOFTBUS_TRANS_PROXY_READINT_FAILED, COMM_SDK, "read count failed");
COMM_CHECK_AND_RETURN_RET_LOGE(count < QOS_TYPE_BUTT, SOFTBUS_INVALID_PARAM, COMM_SDK, "invalid count");
QosTV *qos = (QosTV *)data.ReadBuffer(sizeof(QosTV) * count);
COMM_CHECK_AND_RETURN_RET_LOGE(
qos != nullptr, SOFTBUS_TRANS_PROXY_READRAWDATA_FAILED, COMM_SDK, "read qos failed!");
int32_t ret = OnClientChannelOnQos(channelId, channelType, (QoSEvent)event, qos, count);
if (ret != SOFTBUS_OK) {
COMM_LOGE(COMM_SDK, "OnClientChannelOnQos failed, ret=%{public}d", ret);
}
return SOFTBUS_OK;
}
int32_t SoftBusClientStub::SetChannelInfoInner(MessageParcel &data, MessageParcel &reply)
{
const char *sessionName = data.ReadCString();
@ -772,4 +804,18 @@ void SoftBusClientStub::OnDataLevelChanged(const char *networkId, const DataLeve
{
LnnOnDataLevelChanged(networkId, dataLevelInfo);
}
int32_t SoftBusClientStub::OnClientChannelOnQos(
int32_t channelId, int32_t channelType, QoSEvent event, const QosTV *qos, uint32_t count)
{
if (event < QOS_SATISFIED || event > QOS_NOT_SATISFIED) {
COMM_LOGE(COMM_SDK, "OnChannelOnQos invalid event=%{public}d", event);
return SOFTBUS_INVALID_PARAM;
}
if (qos == nullptr || count == 0) {
COMM_LOGE(COMM_SDK, "OnChannelOnQos invalid qos or count");
return SOFTBUS_INVALID_PARAM;
}
return TransOnChannelOnQos(channelId, channelType, event, qos, count);
}
} // namespace OHOS

View File

@ -17,6 +17,7 @@
#define CLIENT_TRANS_SESSION_CALLBACK_H
#include "session.h"
#include "socket.h"
#include "softbus_def.h"
#ifdef __cplusplus
@ -39,6 +40,7 @@ typedef struct {
int32_t (*OnRawStreamEncryptOptGet)(int32_t channelId, int32_t channelType, bool *isEncrypt);
int32_t (*OnChannelBind)(int32_t channelId, int32_t channelType);
int32_t (*IfChannelForSocket)(const char *sessionName, bool *isSocket);
int32_t (*OnQos)(int32_t channelId, int32_t channelType, QoSEvent event, const QosTV *qos, uint32_t count);
} IClientSessionCallBack;
IClientSessionCallBack *GetClientSessionCb(void);

View File

@ -617,6 +617,46 @@ int32_t ClientTransIfChannelForSocket(const char *sessionName, bool *isSocket)
return SOFTBUS_OK;
}
int32_t ClientTransOnQos(int32_t channelId, int32_t channelType, QoSEvent event, const QosTV *qos, uint32_t count)
{
if (qos == NULL) {
TRANS_LOGE(TRANS_SDK, "qos is NULL");
return SOFTBUS_INVALID_PARAM;
}
char sessionName[SESSION_NAME_SIZE_MAX + 1] = { 0 };
if (ClientGetSessionNameByChannelId(channelId, channelType, sessionName, SESSION_NAME_SIZE_MAX)) {
TRANS_LOGE(TRANS_SDK, "failed to get sessionName, channelId=%{public}d", channelId);
return SOFTBUS_TRANS_SESSION_NAME_NO_EXIST;
}
if (!IsDistributedDataSession(sessionName)) {
TRANS_LOGI(TRANS_SDK, "not report qos event on non-distributed data session");
return SOFTBUS_OK;
}
int32_t socket = INVALID_SESSION_ID;
SessionListenerAdapter sessionCallback;
bool isServer = false;
(void)memset_s(&sessionCallback, sizeof(SessionListenerAdapter), 0, sizeof(SessionListenerAdapter));
int32_t ret = GetSocketCallbackAdapterByChannelId(channelId, channelType, &socket, &sessionCallback, &isServer);
if (ret != SOFTBUS_OK) {
TRANS_LOGE(TRANS_SDK, "get session callback failed channelId=%{public}d", channelId);
return ret;
}
if (isServer) {
TRANS_LOGI(TRANS_SDK, "not report qos event on server side");
return SOFTBUS_OK;
}
if (!sessionCallback.isSocketListener) {
TRANS_LOGI(TRANS_SDK, "not report qos event on non-socket session");
return SOFTBUS_OK;
}
if (sessionCallback.socketClient.OnQos != NULL) {
sessionCallback.socketClient.OnQos(socket, event, qos, count);
TRANS_LOGI(
TRANS_SDK, "successful report qos event to client socket=%{public}d, event=%{public}d", socket, event);
}
return SOFTBUS_OK;
}
IClientSessionCallBack *GetClientSessionCb(void)
{
g_sessionCb.OnSessionOpened = TransOnSessionOpened;
@ -631,5 +671,6 @@ IClientSessionCallBack *GetClientSessionCb(void)
g_sessionCb.OnRawStreamEncryptOptGet = ClientRawStreamEncryptOptGet;
g_sessionCb.OnChannelBind = ClientTransOnChannelBind;
g_sessionCb.IfChannelForSocket = ClientTransIfChannelForSocket;
g_sessionCb.OnQos = ClientTransOnQos;
return &g_sessionCb;
}

View File

@ -17,6 +17,7 @@
#define CLIENT_TRANS_CHANNEL_CALLBACK_H
#include "session.h"
#include "socket.h"
#include "softbus_def.h"
#ifdef __cplusplus
@ -39,6 +40,7 @@ int32_t TransOnChannelQosEvent(int32_t channelId, int32_t channelType, int32_t e
int32_t TransSetChannelInfo(const char* sessionName, int32_t sessionId, int32_t channleId, int32_t channelType);
int32_t TransOnChannelBind(int32_t channelId, int32_t channelType);
int32_t TransOnChannelOnQos(int32_t channelId, int32_t channelType, QoSEvent event, const QosTV *qos, uint32_t count);
#ifdef __cplusplus
}

View File

@ -208,4 +208,9 @@ int32_t TransOnChannelBind(int32_t channelId, int32_t channelType)
return SOFTBUS_TRANS_INVALID_CHANNEL_TYPE;
}
return SOFTBUS_OK;
}
int32_t TransOnChannelOnQos(int32_t channelId, int32_t channelType, QoSEvent event, const QosTV *qos, uint32_t count)
{
return GetClientSessionCb()->OnQos(channelId, channelType, event, qos, count);
}

View File

@ -95,5 +95,9 @@ void DetectDisableWifiDirectApply(void)
{
GetLaneListenerDepsInterface()->DetectDisableWifiDirectApply();
}
int32_t HandleLaneQosChange(const LaneLinkInfo *laneLinkInfo)
{
return GetLaneListenerDepsInterface()->HandleLaneQosChange(reqInfoList, laneLinkInfo);
}
} // namespace OHOS

View File

@ -42,6 +42,7 @@ public:
virtual int32_t AddLaneResourceToPool(const LaneLinkInfo *linkInfo, uint64_t laneId, bool isServerSide) = 0;
virtual int32_t DelLaneResourceByLaneId(uint64_t laneId, bool isServerSide) = 0;
virtual void DetectDisableWifiDirectApply(void) = 0;
virtual int32_t HandleLaneQosChange(const LaneLinkInfo *laneLinkInfo) = 0;
};
class LaneListenerDepsInterfaceMock : public LaneListenerDepsInterface {
@ -63,6 +64,7 @@ public:
MOCK_METHOD3(AddLaneResourceToPool, int32_t (const LaneLinkInfo *linkInfo, uint64_t laneId, bool isServerSide));
MOCK_METHOD2(DelLaneResourceByLaneId, int32_t (uint64_t laneId, bool isServerSide));
MOCK_METHOD0(DetectDisableWifiDirectApply, void (void));
MOCK_METHOD1(HandleLaneQosChange, int32_t (const LaneLinkInfo *laneLinkInfo));
};
} // namespace OHOS
#endif // LNN_LANE_LISTENER_DEPS_MOCK_H

View File

@ -503,4 +503,38 @@ HWTEST_F(TransClientProxyTest, CheckServiceIsRegisteredTest001, TestSize.Level0)
ret = CheckServiceIsRegistered(g_pkgName, TEST_PID);
EXPECT_EQ(SOFTBUS_OK, ret);
}
/**
* @tc.name: ClientIpcChannelOnQosTest001
* @tc.desc: ClientIpcChannelOnQos test.
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(TransClientProxyTest, ClientIpcChannelOnQosTest001, TestSize.Level0)
{
int32_t ret = ClientIpcChannelOnQos(nullptr, QOS_SATISFIED, nullptr, QOS_TYPE_BUTT);
EXPECT_EQ(SOFTBUS_INVALID_PARAM, ret);
ChannelMsg data;
data.msgPkgName = nullptr;
ret = ClientIpcChannelOnQos(&data, QOS_SATISFIED, nullptr, QOS_TYPE_BUTT);
EXPECT_EQ(SOFTBUS_INVALID_PARAM, ret);
data.msgPkgName = g_pkgName;
ret = ClientIpcChannelOnQos(&data, QOS_SATISFIED, nullptr, QOS_TYPE_BUTT);
QosTV qos[] = {
{QOS_TYPE_MIN_BW, 0},
};
ret = ClientIpcChannelOnQos(&data, QOS_SATISFIED, qos, QOS_TYPE_BUTT);
EXPECT_EQ(SOFTBUS_INVALID_PARAM, ret);
ret = ClientIpcChannelOnQos(&data, QOS_SATISFIED, qos, 1);
EXPECT_NE(SOFTBUS_OK, ret);
data.msgChannelId = TEST_CHANNELID;
data.msgChannelType = TEST_CHANNELTYPE;
data.msgPid = TEST_PID;
ret = ClientIpcChannelOnQos(&data, QOS_SATISFIED, qos, 1);
EXPECT_EQ(SOFTBUS_OK, ret);
}
} // namespace OHOS

View File

@ -1422,4 +1422,36 @@ HWTEST_F(TransLanePendingTest, TransCancelLaneItemCondByLaneHandle001, TestSize.
TransReqLanePendingDeinit();
}
/**
* @tc.name: TransNotifyLaneQosEventTest001
* @tc.desc: TransNotifyLaneQosEvent test
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(TransLanePendingTest, TransNotifyLaneQosEventTest001, TestSize.Level1)
{
int32_t ret = TransNotifyLaneQosEvent(0, (LaneOwner)(LANE_OWNER_BUTT + 1), (LaneQosEvent)(LANE_QOS_BW_BUTT + 1));
EXPECT_EQ(SOFTBUS_INVALID_PARAM, ret);
ret = TransNotifyLaneQosEvent(0, (LaneOwner)(LANE_OWNER_SELF - 1), (LaneQosEvent)(LANE_QOS_BW_BUTT + 1));
EXPECT_EQ(SOFTBUS_INVALID_PARAM, ret);
ret = TransNotifyLaneQosEvent(TEST_LANE_ID, LANE_OWNER_SELF, (LaneQosEvent)(LANE_QOS_BW_BUTT + 1));
EXPECT_EQ(SOFTBUS_INVALID_PARAM, ret);
ret = TransNotifyLaneQosEvent(TEST_LANE_ID, LANE_OWNER_SELF, (LaneQosEvent)(LANE_QOS_BW_HIGH - 1));
EXPECT_EQ(SOFTBUS_INVALID_PARAM, ret);
ret = TransNotifyLaneQosEvent(TEST_LANE_ID, LANE_OWNER_SELF, LANE_QOS_BW_MID);
EXPECT_EQ(SOFTBUS_OK, ret);
ret = TransNotifyLaneQosEvent(TEST_LANE_ID, LANE_OWNER_OTHER, LANE_QOS_BW_MID);
EXPECT_EQ(SOFTBUS_OK, ret);
ret = TransNotifyLaneQosEvent(TEST_LANE_ID, LANE_OWNER_SELF, LANE_QOS_BW_HIGH);
EXPECT_EQ(SOFTBUS_OK, ret);
}
} // namespace OHOS

View File

@ -538,4 +538,24 @@ HWTEST_F(TransLaneManagerTest, TransGetConnectTypeByChannelId001, TestSize.Level
ret = TransGetConnectTypeByChannelId(1, &type);
EXPECT_EQ(SOFTBUS_TRANS_INVALID_CHANNEL_ID, ret);
}
/**
* @tc.name: TransGetTransLaneInfoByLaneHandle Test
* @tc.desc: TransGetTransLaneInfoByLaneHandle001
* @tc.type: FUNC
* @tc.require:
*/
HWTEST_F(TransLaneManagerTest, TransGetTransLaneInfoByLaneHandle001, TestSize.Level1)
{
TransLaneMgrDeinit();
int32_t ret = TransGetTransLaneInfoByLaneHandle(1, nullptr);
EXPECT_EQ(SOFTBUS_INVALID_PARAM, ret);
TransLaneInfo info;
ret = TransGetTransLaneInfoByLaneHandle(1, &info);
EXPECT_EQ(SOFTBUS_INVALID_PARAM, ret);
TransLaneMgrInit();
ret = TransGetTransLaneInfoByLaneHandle(1, &info);
EXPECT_EQ(SOFTBUS_NOT_FIND, ret);
TransLaneMgrDeinit();
}
} // OHOS

View File

@ -109,6 +109,11 @@ public:
{
return SOFTBUS_OK;
}
int32_t OnClientChannelOnQos([[maybe_unused]] int32_t channelId, [[maybe_unused]] int32_t channelType,
[[maybe_unused]] QoSEvent event, [[maybe_unused]] const QosTV *qos, [[maybe_unused]] uint32_t count) override
{
return SOFTBUS_OK;
}
};
namespace {
@ -502,6 +507,8 @@ HWTEST_F(SoftBusServerProxyFrameTest, ISoftBusClientTest001, TestSize.Level1)
EXPECT_EQ(ret, SOFTBUS_OK);
ret = g_stub->OnChannelBind(testInt, testInt);
EXPECT_EQ(ret, SOFTBUS_OK);
ret = g_stub->OnClientChannelOnQos(testInt, testInt, QOS_SATISFIED, nullptr, testUint);
EXPECT_EQ(ret, SOFTBUS_OK);
}
/**