!6032 [Bug]: fix signal-to-dual interworking

Merge pull request !6032 from 范妮娜/cherry-pick-1715225589
This commit is contained in:
openharmony_ci 2024-05-09 09:26:37 +00:00 committed by Gitee
commit b3bb68e3ab
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
9 changed files with 50 additions and 33 deletions

View File

@ -102,7 +102,7 @@ typedef struct {
} LaneResource;
typedef struct {
void (*OnLaneLinkSuccess)(uint32_t reqId, const LaneLinkInfo *linkInfo);
void (*OnLaneLinkSuccess)(uint32_t reqId, LaneLinkType linkType, const LaneLinkInfo *linkInfo);
void (*OnLaneLinkFail)(uint32_t reqId, int32_t reason, LaneLinkType linkType);
} LaneLinkCb;

View File

@ -424,7 +424,7 @@ static int32_t LaneLinkOfBr(uint32_t reqId, const LinkRequest *reqInfo, const La
return SOFTBUS_LANE_GET_LEDGER_INFO_ERR;
}
linkInfo.type = LANE_BR;
callback->OnLaneLinkSuccess(reqId, &linkInfo);
callback->OnLaneLinkSuccess(reqId, linkInfo.type, &linkInfo);
return SOFTBUS_OK;
}
@ -640,7 +640,7 @@ static int32_t LaneLinkOfBleReuseCommon(uint32_t reqId, const LinkRequest *reqIn
linkInfo.type = LANE_BLE;
}
ConnBleReturnConnection(&connection);
callback->OnLaneLinkSuccess(reqId, &linkInfo);
callback->OnLaneLinkSuccess(reqId, linkInfo.type, &linkInfo);
return SOFTBUS_OK;
}
@ -698,7 +698,7 @@ static int32_t LaneLinkOfBle(uint32_t reqId, const LinkRequest *reqInfo, const L
linkInfo.linkInfo.ble.protoType = BLE_GATT;
linkInfo.linkInfo.ble.psm = 0;
linkInfo.type = LANE_BLE;
callback->OnLaneLinkSuccess(reqId, &linkInfo);
callback->OnLaneLinkSuccess(reqId, linkInfo.type, &linkInfo);
return SOFTBUS_OK;
}
@ -717,7 +717,7 @@ static int32_t LaneLinkOfGattDirect(uint32_t reqId, const LinkRequest *reqInfo,
}
linkInfo.type = LANE_BLE_DIRECT;
linkInfo.linkInfo.bleDirect.protoType = BLE_GATT;
callback->OnLaneLinkSuccess(reqId, &linkInfo);
callback->OnLaneLinkSuccess(reqId, linkInfo.type, &linkInfo);
return SOFTBUS_OK;
}
@ -763,7 +763,7 @@ static int32_t LaneLinkOfP2pReuse(uint32_t reqId, const LinkRequest *reqInfo, co
if (memcpy_s(linkInfo.linkInfo.wlan.connInfo.addr, MAX_SOCKET_ADDR_LEN, ipAddr, MAX_SOCKET_ADDR_LEN) != EOK) {
return SOFTBUS_MEM_ERR;
}
callback->OnLaneLinkSuccess(reqId, &linkInfo);
callback->OnLaneLinkSuccess(reqId, linkInfo.type, &linkInfo);
return SOFTBUS_OK;
}
@ -967,7 +967,7 @@ static int32_t LaneLinkOfCoc(uint32_t reqId, const LinkRequest *reqInfo, const L
}
linkInfo.linkInfo.ble.protoType = BLE_COC;
linkInfo.type = LANE_COC;
callback->OnLaneLinkSuccess(reqId, &linkInfo);
callback->OnLaneLinkSuccess(reqId, linkInfo.type, &linkInfo);
return SOFTBUS_OK;
}
@ -987,7 +987,7 @@ static int32_t LaneLinkOfCocDirect(uint32_t reqId, const LinkRequest *reqInfo, c
linkInfo.type = LANE_COC_DIRECT;
linkInfo.linkInfo.bleDirect.protoType = BLE_COC;
callback->OnLaneLinkSuccess(reqId, &linkInfo);
callback->OnLaneLinkSuccess(reqId, linkInfo.type, &linkInfo);
return SOFTBUS_OK;
}

View File

@ -606,19 +606,22 @@ static void NotifyLinkSucc(AsyncResultType type, uint32_t requestId, LaneLinkInf
return;
}
(void)DelP2pLinkReqByReqId(type, requestId);
DelGuideInfoItem(reqInfo.laneRequestInfo.laneReqId, reqInfo.laneRequestInfo.linkType);
LaneLinkType throryLinkType = reqInfo.laneRequestInfo.linkType;
if (reqInfo.laneRequestInfo.linkType != linkInfo->type) {
LNN_LOGI(LNN_LANE, "not return specified link, requestId=%{public}u", requestId);
}
DelGuideInfoItem(reqInfo.laneRequestInfo.laneReqId, throryLinkType);
int32_t ret = AddNewP2pLinkedInfo(&reqInfo, linkId);
if (ret != SOFTBUS_OK) {
LNN_LOGE(LNN_LANE, "add new p2p linked info fail, laneReqId=%{public}u ", reqInfo.laneRequestInfo.laneReqId);
LNN_LOGE(LNN_LANE, "add new p2p linked info fail, laneReqId=%{public}u", reqInfo.laneRequestInfo.laneReqId);
if (reqInfo.laneRequestInfo.cb.OnLaneLinkFail != NULL) {
reqInfo.laneRequestInfo.cb.OnLaneLinkFail(reqInfo.laneRequestInfo.laneReqId, ret,
reqInfo.laneRequestInfo.linkType);
reqInfo.laneRequestInfo.cb.OnLaneLinkFail(reqInfo.laneRequestInfo.laneReqId, ret, throryLinkType);
}
} else {
if (reqInfo.laneRequestInfo.cb.OnLaneLinkSuccess != NULL) {
LNN_LOGI(LNN_LANE, "wifidirect conn succ, laneReqId=%{public}u, linktype=%{public}d, requestId=%{public}u, "
"linkId=%{public}d", reqInfo.laneRequestInfo.laneReqId, linkInfo->type, requestId, linkId);
reqInfo.laneRequestInfo.cb.OnLaneLinkSuccess(reqInfo.laneRequestInfo.laneReqId, linkInfo);
reqInfo.laneRequestInfo.cb.OnLaneLinkSuccess(reqInfo.laneRequestInfo.laneReqId, throryLinkType, linkInfo);
}
}
if (reqInfo.auth.authHandle.authId != INVAILD_AUTH_ID) {

View File

@ -264,7 +264,7 @@ static int32_t NotifyWlanDetectResult(LaneDetectInfo *requestItem, bool isSendSu
}
LNN_LOGI(LNN_LANE, "Detect success, wlan=%{public}d, laneReqId=%{public}u, detectId=%{public}u",
item->link.type, item->laneReqId, requestItem->laneDetectId);
item->cb.OnLaneLinkSuccess(item->laneReqId, &laneInfo);
item->cb.OnLaneLinkSuccess(item->laneReqId, laneInfo.type, &laneInfo);
}
ListDelete(&item->node);
SoftBusFree(item);

View File

@ -174,13 +174,13 @@ static void RemoveLaneTimeoutMessage(uint32_t laneReqId, LaneLinkType linkType)
RemoveLaneTimeout, &info);
}
static void LinkSuccess(uint32_t laneReqId, const LaneLinkInfo *linkInfo)
static void LinkSuccess(uint32_t laneReqId, LaneLinkType linkType, const LaneLinkInfo *linkInfo)
{
if (linkInfo == NULL) {
LNN_LOGE(LNN_LANE, "linkSuccess param invalid");
return;
}
RemoveLaneTimeoutMessage(laneReqId, linkInfo->type);
RemoveLaneTimeoutMessage(laneReqId, linkType);
LaneLinkInfo *linkParam = (LaneLinkInfo *)SoftBusCalloc(sizeof(LaneLinkInfo));
if (linkParam == NULL) {
LNN_LOGE(LNN_LANE, "linkSuccess info malloc fail");
@ -192,7 +192,7 @@ static void LinkSuccess(uint32_t laneReqId, const LaneLinkInfo *linkInfo)
(void)LnnLanePostMsgToHandler(MSG_TYPE_LANE_LINK_FAIL, laneReqId, SOFTBUS_MEM_ERR, NULL, 0);
return;
}
if (LnnLanePostMsgToHandler(MSG_TYPE_LANE_LINK_SUCCESS, laneReqId, 0, linkParam, 0) != SOFTBUS_OK) {
if (LnnLanePostMsgToHandler(MSG_TYPE_LANE_LINK_SUCCESS, laneReqId, linkType, linkParam, 0) != SOFTBUS_OK) {
LNN_LOGE(LNN_LANE, "post LaneLinkSuccess msg err, laneReqId=%{public}u", laneReqId);
SoftBusFree(linkParam);
}
@ -860,7 +860,8 @@ static void FreeUnusedLink(uint32_t laneReqId, const LaneLinkInfo *linkInfo)
}
}
static int32_t UpdateLinkStatus(uint32_t laneReqId, BuildLinkStatus status, LaneLinkType linkType, const LaneLinkInfo *linkInfo)
static int32_t UpdateLinkStatus(uint32_t laneReqId, BuildLinkStatus status, LaneLinkType linkType,
const LaneLinkInfo *linkInfo)
{
if (Lock() != SOFTBUS_OK) {
LNN_LOGE(LNN_LANE, "get lock fail");
@ -869,8 +870,7 @@ static int32_t UpdateLinkStatus(uint32_t laneReqId, BuildLinkStatus status, Lane
LaneLinkNodeInfo *nodeInfo = GetLaneLinkNodeWithoutLock(laneReqId);
if (nodeInfo == NULL) {
Unlock();
LNN_LOGE(LNN_LANE, "get lane link node info fail, laneReqId=%{public}u, linkType=%{public}d",
laneReqId, linkType);
LNN_LOGE(LNN_LANE, "get lane link node info fail, laneReqId=%{public}u", laneReqId);
if (status == BUILD_LINK_STATUS_SUCC) {
FreeUnusedLink(laneReqId, linkInfo);
}
@ -930,7 +930,7 @@ static bool IsNeedNotifySucc(uint32_t laneReqId)
return false;
}
static int32_t GetLaneLinkInfo(uint32_t laneReqId, LaneLinkInfo *info)
static int32_t GetLaneLinkInfo(uint32_t laneReqId, LaneLinkType *type, LaneLinkInfo *info)
{
if (Lock() != SOFTBUS_OK) {
LNN_LOGE(LNN_LANE, "get lock fail");
@ -945,12 +945,13 @@ static int32_t GetLaneLinkInfo(uint32_t laneReqId, LaneLinkInfo *info)
for (uint32_t i = 0; i < nodeInfo->listNum; i++) {
LaneLinkType linkType = nodeInfo->linkList->linkType[i];
if (nodeInfo->statusList[linkType].status == BUILD_LINK_STATUS_SUCC) {
if(memcpy_s(info, sizeof(LaneLinkInfo), &(nodeInfo->statusList[linkType].linkInfo),
if (memcpy_s(info, sizeof(LaneLinkInfo), &(nodeInfo->statusList[linkType].linkInfo),
sizeof(LaneLinkInfo)) != EOK) {
Unlock();
LNN_LOGE(LNN_LANE, "info memcpy fail, laneReqId=%{public}u", laneReqId);
return SOFTBUS_ERR;
}
*type = linkType;
Unlock();
return SOFTBUS_OK;
}
@ -992,9 +993,10 @@ static void FreeLowPriorityLink(uint32_t laneReqId, LaneLinkType linkType)
static void NotifyLinkSucc(uint32_t laneReqId)
{
LaneLinkType linkType;
LaneLinkInfo info;
(void)memset_s(&info, sizeof(LaneLinkInfo), 0, sizeof(LaneLinkInfo));
if (GetLaneLinkInfo(laneReqId, &info) != SOFTBUS_OK) {
if (GetLaneLinkInfo(laneReqId, &linkType, &info) != SOFTBUS_OK) {
LNN_LOGE(LNN_LANE, "get LaneLinkInfo fail, laneReqId=%{public}u", laneReqId);
NotifyLaneAllocFail(laneReqId, SOFTBUS_LANE_TRIGGER_LINK_FAIL);
return;
@ -1018,7 +1020,7 @@ static void NotifyLinkSucc(uint32_t laneReqId)
return;
}
NotifyLaneAllocSuccess(laneReqId, laneId, &info);
FreeLowPriorityLink(laneReqId, info.type);
FreeLowPriorityLink(laneReqId, linkType);
LaneType laneType;
if (ParseLaneTypeByLaneReqId(laneReqId, &laneType) != SOFTBUS_OK ||
AddLaneBusinessInfoItem(laneType, laneId) != SOFTBUS_OK) {
@ -1034,7 +1036,8 @@ static void LaneLinkSuccess(SoftBusMessage *msg)
}
LaneLinkInfo *info = (LaneLinkInfo *)msg->obj;
uint32_t laneReqId = (uint32_t)msg->arg1;
if (UpdateLinkStatus(laneReqId, BUILD_LINK_STATUS_SUCC, info->type, info) != SOFTBUS_OK) {
LaneLinkType linkType = (LaneLinkType)msg->arg2;
if (UpdateLinkStatus(laneReqId, BUILD_LINK_STATUS_SUCC, linkType, info) != SOFTBUS_OK) {
LNN_LOGE(LNN_LANE, "update link status fail, laneReqId=%{public}u", laneReqId);
SoftBusFree(info);
return;
@ -1089,7 +1092,7 @@ static void NotifyRetryOrFail(uint32_t laneReqId, LaneLinkType linkType, int32_t
NotifyLaneAllocFail(laneReqId, failReason);
DeleteLaneLinkNode(laneReqId);
}
if(needRetry) {
if (needRetry) {
(void)LnnLanePostMsgToHandler(MSG_TYPE_LANE_TRIGGER_LINK, laneReqId, 0, NULL, 0);
}
}
@ -1217,6 +1220,16 @@ static void HandleTypeProcessTimeout(uint32_t laneReqId)
return;
}
}
if (nodeInfo->linkList->linkType[nodeInfo->linkRetryIdx] == LANE_P2P) {
for (uint32_t i = 0; i < nodeInfo->linkRetryIdx; i++) {
LaneLinkType type = nodeInfo->linkList->linkType[i];
if (type == LANE_HML && nodeInfo->statusList[type].status == BUILD_LINK_STATUS_BUILDING) {
LNN_LOGI(LNN_LANE, "refuse same type link repeat build, laneReqId=%{public}u", laneReqId);
Unlock();
return;
}
}
}
Unlock();
(void)LnnLanePostMsgToHandler(MSG_TYPE_LANE_TRIGGER_LINK, laneReqId, 0, NULL, 0);
}

View File

@ -170,9 +170,10 @@ static void OnLaneLinkFail(uint32_t reqId, int32_t reason, LaneLinkType linkType
return;
}
static void OnLaneLinkSuccess(uint32_t reqId, const LaneLinkInfo *linkInfo)
static void OnLaneLinkSuccess(uint32_t reqId, LaneLinkType linkType, const LaneLinkInfo *linkInfo)
{
(void)reqId;
(void)linkType;
(void)linkInfo;
return;
}

View File

@ -74,7 +74,7 @@ int32_t LnnWifiAdpterInterfaceMock::ActionOfLnnConnectP2p(const LinkRequest *req
GTEST_LOG_(INFO) << "delay notify laneLinkSuccess after 50ms";
std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_FOR_LOOP_COMPLETION_MS));
}
callback->OnLaneLinkSuccess(laneLinkReqId, &linkInfo);
callback->OnLaneLinkSuccess(laneLinkReqId, request->linkType, &linkInfo);
return SOFTBUS_OK;
}

View File

@ -67,9 +67,10 @@ void LNNLaneLinkTest::TearDown()
{
}
static void OnLaneLinkSuccess(uint32_t reqId, const LaneLinkInfo *linkInfo)
static void OnLaneLinkSuccess(uint32_t reqId, LaneLinkType linkType, const LaneLinkInfo *linkInfo)
{
(void)reqId;
(void)linkType;
(void)linkInfo;
g_laneLinkResult = SOFTBUS_OK;
return;
@ -1143,11 +1144,10 @@ HWTEST_F(LNNLaneLinkTest, GuideChannelRetryOfAsync_008, TestSize.Level1)
EXPECT_CALL(linkMock, AuthGetPreferConnInfo).WillRepeatedly(Return(SOFTBUS_OK));
EXPECT_CALL(laneLinkMock, GetTransReqInfoByLaneReqId).WillRepeatedly(Return(SOFTBUS_OK));
EXPECT_CALL(linkMock, AuthGenRequestId).WillRepeatedly(Return(requestId));
EXPECT_CALL(linkMock, AuthOpenConn(_, requestId, NotNull(), _)).WillRepeatedly(linkMock.ActionOfConnOpenFailed)
EXPECT_CALL(linkMock, AuthOpenConn(_, requestId, NotNull(), _)).WillOnce(linkMock.ActionOfConnOpenFailed)
.WillRepeatedly(Return(SOFTBUS_OK));
EXPECT_CALL(linkMock, GetWifiDirectManager).WillRepeatedly(Return(&g_manager));
EXPECT_CALL(linkMock, AuthGetP2pConnInfo).WillRepeatedly(Return(SOFTBUS_OK));
EXPECT_CALL(linkMock, AuthOpenConn).WillRepeatedly(Return(SOFTBUS_OK));
ret = LnnConnectP2p(&request, laneReqId, &cb);
std::this_thread::sleep_for(std::chrono::milliseconds(200)); // delay 200ms for looper completion.

View File

@ -132,7 +132,7 @@ static void ConstructLocalInfo(void)
EXPECT_TRUE(ret == SOFTBUS_OK);
}
static void NotifyWlanLinkSuccess(uint32_t reqId, const LaneLinkInfo *linkInfo)
static void NotifyWlanLinkSuccess(uint32_t reqId, LaneLinkType linkType, const LaneLinkInfo *linkInfo)
{
EXPECT_TRUE((linkInfo->type == LANE_WLAN_2P4G) || (linkInfo->type == LANE_WLAN_5G));
EXPECT_EQ(linkInfo->linkInfo.wlan.connInfo.port, REMOTE_SESSION_PORT);
@ -145,7 +145,7 @@ static void NotifyWlanLinkFail(uint32_t reqId, int32_t reason, LaneLinkType link
printf("WLAN: reqId:0x%x, fail reason:%d, linkType:%d\n", reqId, reason, linkType);
}
static void NotifyBrLinkSuccess(uint32_t reqId, const LaneLinkInfo *linkInfo)
static void NotifyBrLinkSuccess(uint32_t reqId, LaneLinkType linkType, const LaneLinkInfo *linkInfo)
{
EXPECT_TRUE(linkInfo->type == LANE_BR);
EXPECT_STREQ(linkInfo->linkInfo.br.brMac, NODE_BT_MAC);