From c962a7cd50f3af61f68893cf414d9f142b5a54c6 Mon Sep 17 00:00:00 2001 From: 15958027009 Date: Fri, 22 Nov 2024 09:44:53 +0800 Subject: [PATCH] no need clear conflictResource when wifidirect connected Signed-off-by: 15958027009 --- .../include/lnn_lane_link_conflict.h | 1 - .../lane_manager/src/lnn_lane_link_conflict.c | 61 ----------------- .../lane_manager/src/lnn_lane_link_p2p.c | 1 - .../lnn/lane_link/lnn_lane_link_deps_mock.cpp | 5 -- .../lnn/lane_link/lnn_lane_link_deps_mock.h | 2 - .../lnn_lane_link_conflict_test.cpp | 66 ------------------- 6 files changed, 136 deletions(-) diff --git a/core/bus_center/lnn/lane_hub/lane_manager/include/lnn_lane_link_conflict.h b/core/bus_center/lnn/lane_hub/lane_manager/include/lnn_lane_link_conflict.h index 686f95c9b..b0664b8ec 100644 --- a/core/bus_center/lnn/lane_hub/lane_manager/include/lnn_lane_link_conflict.h +++ b/core/bus_center/lnn/lane_hub/lane_manager/include/lnn_lane_link_conflict.h @@ -69,7 +69,6 @@ int32_t FindLinkConflictInfoByDevId(const DevIdentifyInfo *inputInfo, LinkConfli LinkConflictInfo *outputInfo); void RemoveConflictInfoTimelinessMsg(const DevIdentifyInfo *inputInfo, LinkConflictType conflictType); int32_t CheckLinkConflictByReleaseLink(LaneLinkType releaseLink); -void ClearConflictInfoByLinkType(const char *networkId, LaneLinkType releaseLink); #ifdef __cplusplus } diff --git a/core/bus_center/lnn/lane_hub/lane_manager/src/lnn_lane_link_conflict.c b/core/bus_center/lnn/lane_hub/lane_manager/src/lnn_lane_link_conflict.c index acad33378..b6e2df9e4 100644 --- a/core/bus_center/lnn/lane_hub/lane_manager/src/lnn_lane_link_conflict.c +++ b/core/bus_center/lnn/lane_hub/lane_manager/src/lnn_lane_link_conflict.c @@ -442,67 +442,6 @@ int32_t CheckLinkConflictByReleaseLink(LaneLinkType releaseLink) return SOFTBUS_LANE_NOT_FOUND; } -static bool GetConflictInfoWithLinkType(LaneLinkType type, const DevIdentifyInfo *identifyInfo, - const DevIdentifyInfo *hashInfo, LinkConflictInfo *outputInfo) -{ - if (LinkConflictLock() != SOFTBUS_OK) { - LNN_LOGE(LNN_LANE, "linkConflict lock fail"); - return false; - } - LinkConflictInfo *item = NULL; - LinkConflictInfo *next = NULL; - LIST_FOR_EACH_ENTRY_SAFE(item, next, &g_linkConflictList.list, LinkConflictInfo, node) { - bool isMatched = false; - if ((type == LANE_HML && item->conflictType == CONFLICT_LINK_NUM_LIMITED && item->releaseLink == LANE_HML) || - (type == LANE_P2P && item->conflictType == CONFLICT_THREE_VAP && item->releaseLink == LANE_HML)) { - isMatched = true; - } - if (!isMatched) { - continue; - } - if (memcmp(&item->identifyInfo, identifyInfo, sizeof(DevIdentifyInfo)) == 0 || - memcmp(&item->identifyInfo, hashInfo, sizeof(DevIdentifyInfo)) == 0) { - outputInfo->conflictType = item->conflictType; - if (memcpy_s(&outputInfo->identifyInfo, sizeof(DevIdentifyInfo), &item->identifyInfo, - sizeof(DevIdentifyInfo)) != EOK) { - LNN_LOGE(LNN_LANE, "memcpy identifyInfo fail"); - LinkConflictUnlock(); - return false; - } - LinkConflictUnlock(); - return true; - } - } - LinkConflictUnlock(); - return false; -} - -void ClearConflictInfoByLinkType(const char *networkId, LaneLinkType type) -{ - if (networkId == NULL || (type != LANE_HML && type != LANE_P2P)) { - LNN_LOGE(LNN_LANE, "invalid param"); - return; - } - DevIdentifyInfo identifyInfo; - (void)memset_s(&identifyInfo, sizeof(DevIdentifyInfo), 0, sizeof(DevIdentifyInfo)); - identifyInfo.type = IDENTIFY_TYPE_DEV_ID; - if (strcpy_s(identifyInfo.devInfo.peerDevId, sizeof(identifyInfo.devInfo.peerDevId), networkId) != EOK) { - LNN_LOGE(LNN_LANE, "strcpy peerDevId fail"); - return; - } - DevIdentifyInfo hashInfo; - (void)memset_s(&hashInfo, sizeof(DevIdentifyInfo), 0, sizeof(DevIdentifyInfo)); - hashInfo.type = IDENTIFY_TYPE_UDID_HASH; - GenerateConflictInfoWithDevIdHash(&identifyInfo, &hashInfo); - LinkConflictInfo conflictItem; - (void)memset_s(&conflictItem, sizeof(LinkConflictInfo), 0, sizeof(LinkConflictInfo)); - if (!GetConflictInfoWithLinkType(type, &identifyInfo, &hashInfo, &conflictItem)) { - return; - } - RemoveConflictInfoTimelinessMsg(&(conflictItem.identifyInfo), conflictItem.conflictType); - (void)DelLinkConflictInfo(&(conflictItem.identifyInfo), conflictItem.conflictType); -} - static void HandleConflictInfoTimeliness(SoftBusMessage *msg) { if (msg->obj == NULL) { diff --git a/core/bus_center/lnn/lane_hub/lane_manager/src/lnn_lane_link_p2p.c b/core/bus_center/lnn/lane_hub/lane_manager/src/lnn_lane_link_p2p.c index 42efb6ed5..343cd6349 100644 --- a/core/bus_center/lnn/lane_hub/lane_manager/src/lnn_lane_link_p2p.c +++ b/core/bus_center/lnn/lane_hub/lane_manager/src/lnn_lane_link_p2p.c @@ -923,7 +923,6 @@ static void NotifyLinkSucc(AsyncResultType type, uint32_t requestId, LaneLinkInf "requestId=%{public}u, linkId=%{public}d", reqInfo.laneRequestInfo.laneReqId, linkInfo->type, requestId, linkId); reqInfo.laneRequestInfo.cb.onLaneLinkSuccess(reqInfo.laneRequestInfo.laneReqId, throryLinkType, linkInfo); - ClearConflictInfoByLinkType(reqInfo.laneRequestInfo.networkId, linkInfo->type); } } if (reqInfo.auth.authHandle.authId != INVAILD_AUTH_ID) { diff --git a/tests/core/bus_center/lnn/lane_link/lnn_lane_link_deps_mock.cpp b/tests/core/bus_center/lnn/lane_link/lnn_lane_link_deps_mock.cpp index 675f1639d..7d9884278 100644 --- a/tests/core/bus_center/lnn/lane_link/lnn_lane_link_deps_mock.cpp +++ b/tests/core/bus_center/lnn/lane_link/lnn_lane_link_deps_mock.cpp @@ -179,10 +179,5 @@ int32_t CheckLinkConflictByReleaseLink(LaneLinkType releaseLink) { return GetLaneLinkDepsInterface()->CheckLinkConflictByReleaseLink(releaseLink); } - -void ClearConflictInfoByLinkType(const char *networkId, LaneLinkType releaseLink) -{ - GetLaneLinkDepsInterface()->ClearConflictInfoByLinkType(networkId, releaseLink); -} } } // namespace OHOS diff --git a/tests/core/bus_center/lnn/lane_link/lnn_lane_link_deps_mock.h b/tests/core/bus_center/lnn/lane_link/lnn_lane_link_deps_mock.h index c398fdac3..3b2cb5d3a 100644 --- a/tests/core/bus_center/lnn/lane_link/lnn_lane_link_deps_mock.h +++ b/tests/core/bus_center/lnn/lane_link/lnn_lane_link_deps_mock.h @@ -52,7 +52,6 @@ public: virtual void DelLogicAndLaneRelationship(uint64_t laneId) = 0; virtual int32_t LnnSyncPtk(const char *networkId) = 0; virtual int32_t CheckLinkConflictByReleaseLink(LaneLinkType releaseLink) = 0; - virtual void ClearConflictInfoByLinkType(const char *networkId, LaneLinkType releaseLink) = 0; }; class LaneLinkDepsInterfaceMock : public LaneLinkDepsInterface { @@ -86,7 +85,6 @@ public: MOCK_METHOD1(DelLogicAndLaneRelationship, void (uint64_t laneId)); MOCK_METHOD1(LnnSyncPtk, int32_t (const char *networkId)); MOCK_METHOD1(CheckLinkConflictByReleaseLink, int32_t (LaneLinkType releaseLink)); - MOCK_METHOD2(ClearConflictInfoByLinkType, void (const char *networkId, LaneLinkType releaseLink)); static int32_t ActionOfChannelOpenFailed(int32_t requestId, const char *networkId, const TransProxyPipelineChannelOption *option, const ITransProxyPipelineCallback *callback); diff --git a/tests/core/bus_center/lnn/lane_link_conflict/lnn_lane_link_conflict_test.cpp b/tests/core/bus_center/lnn/lane_link_conflict/lnn_lane_link_conflict_test.cpp index 8b92afeb3..807615d85 100644 --- a/tests/core/bus_center/lnn/lane_link_conflict/lnn_lane_link_conflict_test.cpp +++ b/tests/core/bus_center/lnn/lane_link_conflict/lnn_lane_link_conflict_test.cpp @@ -599,72 +599,6 @@ HWTEST_F(LNNLaneLinkConflictTest, LNN_UPDATE_EXISTS_LINK_CONFLICT_INFO_001, Test FreeConflictDevInfo(&inputInfo); } -/* -* @tc.name: LNN_CLEAR_CONFLICT_INFO_BY_RELEASE_LINK_001 -* @tc.desc: clear conflictInfo by linkType HML -* @tc.type: FUNC -* @tc.require: -*/ -HWTEST_F(LNNLaneLinkConflictTest, LNN_CLEAR_CONFLICT_INFO_BY_RELEASE_LINK_001, TestSize.Level1) -{ - NiceMock mock; - EXPECT_CALL(mock, LnnGetRemoteStrInfo).WillRepeatedly(Return(SOFTBUS_OK)); - EXPECT_CALL(mock, SoftBusGenerateStrHash).WillRepeatedly(Return(SOFTBUS_OK)); - EXPECT_CALL(mock, ConvertBytesToHexString) - .WillRepeatedly(LaneLinkConflictDepsInterfaceMock::ActionOfConvertBytesToHexString); - LinkConflictInfo inputInfo; - (void)memset_s(&inputInfo, sizeof(LinkConflictInfo), 0, sizeof(LinkConflictInfo)); - inputInfo.conflictType = CONFLICT_THREE_VAP; - inputInfo.identifyInfo.type = IDENTIFY_TYPE_DEV_ID; - EXPECT_EQ(strcpy_s(inputInfo.identifyInfo.devInfo.peerDevId, NETWORK_ID_BUF_LEN, PEER_NETWORK_ID), EOK); - inputInfo.releaseLink = LANE_HML; - int32_t ret = GenerateConflictDevInfo(&inputInfo); - ASSERT_EQ(ret, SOFTBUS_OK); - ret = AddLinkConflictInfo(&inputInfo); - EXPECT_EQ(ret, SOFTBUS_OK); - - ClearConflictInfoByLinkType(nullptr, LANE_HML); - ClearConflictInfoByLinkType(PEER_NETWORK_ID, LANE_LINK_TYPE_BUTT); - ClearConflictInfoByLinkType(PEER_NETWORK_ID, LANE_HML); - ClearConflictInfoByLinkType(PEER_NETWORK_ID, LANE_P2P); - ret = DelLinkConflictInfo(&inputInfo.identifyInfo, inputInfo.conflictType); - EXPECT_EQ(ret, SOFTBUS_LANE_NOT_FOUND); - FreeConflictDevInfo(&inputInfo); -} - -/* -* @tc.name: LNN_CLEAR_CONFLICT_INFO_BY_RELEASE_LINK_002 -* @tc.desc: clear conflictInfo by linkType P2P -* @tc.type: FUNC -* @tc.require: -*/ -HWTEST_F(LNNLaneLinkConflictTest, LNN_CLEAR_CONFLICT_INFO_BY_RELEASE_LINK_002, TestSize.Level1) -{ - NiceMock mock; - EXPECT_CALL(mock, LnnGetRemoteStrInfo).WillRepeatedly(Return(SOFTBUS_OK)); - EXPECT_CALL(mock, SoftBusGenerateStrHash).WillRepeatedly(Return(SOFTBUS_OK)); - EXPECT_CALL(mock, ConvertBytesToHexString) - .WillRepeatedly(LaneLinkConflictDepsInterfaceMock::ActionOfConvertBytesToHexString); - LinkConflictInfo inputInfo; - (void)memset_s(&inputInfo, sizeof(LinkConflictInfo), 0, sizeof(LinkConflictInfo)); - inputInfo.conflictType = CONFLICT_LINK_NUM_LIMITED; - inputInfo.identifyInfo.type = IDENTIFY_TYPE_DEV_ID; - EXPECT_EQ(strcpy_s(inputInfo.identifyInfo.devInfo.peerDevId, NETWORK_ID_BUF_LEN, PEER_NETWORK_ID), EOK); - inputInfo.releaseLink = LANE_HML; - int32_t ret = GenerateConflictDevInfo(&inputInfo); - ASSERT_EQ(ret, SOFTBUS_OK); - ret = AddLinkConflictInfo(&inputInfo); - EXPECT_EQ(ret, SOFTBUS_OK); - - ClearConflictInfoByLinkType(nullptr, LANE_HML); - ClearConflictInfoByLinkType(PEER_NETWORK_ID, LANE_LINK_TYPE_BUTT); - ClearConflictInfoByLinkType(PEER_NETWORK_ID, LANE_P2P); - ClearConflictInfoByLinkType(PEER_NETWORK_ID, LANE_HML); - ret = DelLinkConflictInfo(&inputInfo.identifyInfo, inputInfo.conflictType); - EXPECT_EQ(ret, SOFTBUS_LANE_NOT_FOUND); - FreeConflictDevInfo(&inputInfo); -} - /* * @tc.name: LNN_CHECK_LINK_CONFLICT_BY_RELEASE_LINK_001 * @tc.desc: check conflictInfo by releaseLink