fix build p2p issue

Signed-off-by: zhangjie1999 <zhangshaojie3@huawei.com>
This commit is contained in:
zhangjie1999 2024-05-22 11:27:55 +00:00
parent ef75022607
commit 781be01f80

View File

@ -577,6 +577,47 @@ static void DelHasAllocedLink(uint64_t allocedLaneId, LaneLinkType *linkList, ui
}
}
static bool IsSupportWifiDirect(const char *networkId)
{
uint64_t localFeature = 0;
uint64_t remoteFeature = 0;
bool isFound = GetFeatureCap(networkId, &localFeature, &remoteFeature);
if (!isFound) {
LNN_LOGE(LNN_LANE, "getFeature fail");
return false;
}
if (((localFeature & (1 << BIT_BLE_TRIGGER_CONNECTION)) == 0) ||
((remoteFeature & (1 << BIT_BLE_TRIGGER_CONNECTION)) == 0)) {
LNN_LOGE(LNN_LANE, "local=%{public}" PRIu64 ", remote=%{public}" PRIu64, localFeature, remoteFeature);
return false;
}
return true;
}
static int32_t FinalDecideLinkType(const char *networkId, LaneLinkType *linkList,
uint32_t listNum, LanePreferredLinkList *recommendList)
{
if (listNum >= LANE_LINK_TYPE_BUTT) {
LNN_LOGE(LNN_LANE, "linkList size exceed limit, size=%{public}d", listNum);
return SOFTBUS_INVALID_NUM;
}
bool isFilterP2p = IsSupportWifiDirect(networkId);
uint32_t availableLinkNums = 0;
for (uint32_t i = 0; i < listNum; i++) {
if (isFilterP2p && linkList[i] == LANE_P2P) {
LNN_LOGE(LNN_LANE, "p2pLink is filtered");
continue;
}
recommendList->linkType[availableLinkNums++] = linkList[i];
}
recommendList->linkTypeNum = availableLinkNums;
if (availableLinkNums == 0) {
LNN_LOGE(LNN_LANE, "not available link");
return SOFTBUS_LANE_SELECT_FAIL;
}
return SOFTBUS_OK;
}
int32_t DecideAvailableLane(const char *networkId, const LaneSelectParam *request, LanePreferredLinkList *recommendList)
{
if (request == NULL || recommendList == NULL) {
@ -591,21 +632,5 @@ int32_t DecideAvailableLane(const char *networkId, const LaneSelectParam *reques
if (request->allocedLaneId != INVALID_LANE_ID) {
DelHasAllocedLink(request->allocedLaneId, linkList, &linksNum);
}
for (uint32_t i = 0; i < linksNum; i++) {
recommendList->linkType[i] = linkList[i];
}
recommendList->linkTypeNum = linksNum;
if (linksNum == 0) {
TransAlarmExtra extra = {
.conflictName = NULL,
.conflictedName = NULL,
.occupyedName = NULL,
.permissionName = NULL,
.sessionName = NULL,
.minBw = request->qosRequire.minBW,
.linkType = request->transType,
};
TRANS_ALARM(BANDWIDTH_INSUFFICIANT_ALARM, MANAGE_ALARM_TYPE, extra);
}
return SOFTBUS_OK;
return FinalDecideLinkType(networkId, linkList, linksNum, recommendList);
}