mirror of
https://gitee.com/openharmony/communication_dsoftbus
synced 2024-11-23 08:49:59 +00:00
!8437 no need clear conflictResource when wifiDirect connected
Merge pull request !8437 from 席国冬/master
This commit is contained in:
commit
538c37fcb8
@ -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
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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<LaneLinkConflictDepsInterfaceMock> 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<LaneLinkConflictDepsInterfaceMock> 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
|
||||
|
Loading…
Reference in New Issue
Block a user