!7487 Fixing Logic Problems

Merge pull request !7487 from shiyifan/master
This commit is contained in:
openharmony_ci 2024-09-19 02:57:56 +00:00 committed by Gitee
commit 20cbc11f72
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 18 additions and 17 deletions

View File

@ -38,7 +38,7 @@ static constexpr char DEFAULT_NET_MASK[] = "255.255.255.0";
static constexpr int CHANNEL_ARRAY_NUM_MAX = 256;
static constexpr int DECIMAL_BASE = 10;
int32_t P2pAdapter::GetFrequency5GListIntArray(std::vector<int> &frequencyList)
int32_t P2pAdapter::GetChannel5GListIntArray(std::vector<int> &channels)
{
int array[CHANNEL_ARRAY_NUM_MAX] {};
auto ret = Hid2dGetChannelListFor5G(array, CHANNEL_ARRAY_NUM_MAX);
@ -47,7 +47,7 @@ int32_t P2pAdapter::GetFrequency5GListIntArray(std::vector<int> &frequencyList)
int count = 0;
while (array[count]) {
frequencyList.push_back(array[count]);
channels.push_back(array[count]);
count++;
}
@ -199,12 +199,13 @@ int32_t P2pAdapter::GetStationFrequencyWithFilter()
int32_t frequency = P2pAdapter::GetStationFrequency();
CONN_CHECK_AND_RETURN_RET_LOGW(frequency > 0, FREQUENCY_INVALID, CONN_WIFI_DIRECT, "invalid frequency");
if (WifiDirectUtils::Is5GBand(frequency)) {
std::vector<int> frequencyArray;
auto ret = P2pAdapter::GetFrequency5GListIntArray(frequencyArray);
std::vector<int> channelArray;
auto ret = P2pAdapter::GetChannel5GListIntArray(channelArray);
if (ret != SOFTBUS_OK) {
return ret;
}
if (WifiDirectUtils::IsInChannelList(frequency, frequencyArray)) {
int32_t channel = WifiDirectUtils::FrequencyToChannel(frequency);
if (WifiDirectUtils::IsInChannelList(channel, channelArray)) {
return frequency;
}
return FREQUENCY_INVALID;

View File

@ -61,7 +61,7 @@ public:
std::vector<WifiDirectP2pDeviceInfo> clientDevices;
};
static int32_t GetFrequency5GListIntArray(std::vector<int> &frequencyList);
static int32_t GetChannel5GListIntArray(std::vector<int> &frequencyList);
static bool IsWifiP2pEnabled();
static std::string GetInterfaceCoexistCap();
static int32_t GetStationFrequency();

View File

@ -949,11 +949,11 @@ int P2pV1Processor::ProcessConnectRequestAsGc(std::shared_ptr<NegotiateCommand>
int P2pV1Processor::SendConnectResponseAsNone(const NegotiateChannel &channel, const std::string &remoteMac)
{
std::vector<int> frequencyList;
auto ret = P2pAdapter::GetFrequency5GListIntArray(frequencyList);
std::vector<int> channels;
auto ret = P2pAdapter::GetChannel5GListIntArray(channels);
CONN_CHECK_AND_RETURN_RET_LOGW(
ret == SOFTBUS_OK, ret, CONN_WIFI_DIRECT, "get 5g channels failed, error=%{public}d", ret);
auto channelString = WifiDirectUtils::ChannelListToString(frequencyList);
auto channelString = WifiDirectUtils::ChannelListToString(channels);
std::string selfWifiConfig;
ret = P2pAdapter::GetSelfWifiConfigInfo(selfWifiConfig);
@ -1293,11 +1293,11 @@ int P2pV1Processor::ProcessAuthHandShakeRequest(std::shared_ptr<NegotiateCommand
int P2pV1Processor::SendConnectRequestAsNone(const NegotiateChannel &channel, WifiDirectRole expectedRole)
{
std::vector<int> frequencyList;
int32_t ret = P2pAdapter::GetFrequency5GListIntArray(frequencyList);
std::vector<int> channels;
int32_t ret = P2pAdapter::GetChannel5GListIntArray(channels);
CONN_CHECK_AND_RETURN_RET_LOGW(
ret == SOFTBUS_OK, ret, CONN_WIFI_DIRECT, "get 5g frequencyList failed, error=%{public}d", ret);
auto channelString = WifiDirectUtils::ChannelListToString(frequencyList);
ret == SOFTBUS_OK, ret, CONN_WIFI_DIRECT, "get 5g channels failed, error=%{public}d", ret);
auto channelString = WifiDirectUtils::ChannelListToString(channels);
std::string selfWifiConfig;
ret = P2pAdapter::GetSelfWifiConfigInfo(selfWifiConfig);
@ -1717,12 +1717,12 @@ int P2pV1Processor::ChooseFrequency(int gcFreq, const std::vector<int> &gcChanne
}
}
std::vector<int> goFrequencyList;
int32_t ret = P2pAdapter::GetFrequency5GListIntArray(goFrequencyList);
std::vector<int> goChannels;
int32_t ret = P2pAdapter::GetChannel5GListIntArray(goChannels);
CONN_CHECK_AND_RETURN_RET_LOGW(
ret == SOFTBUS_OK, ret, CONN_WIFI_DIRECT, "get local goFrequencyList list failed, error=%{public}d", ret);
ret == SOFTBUS_OK, ret, CONN_WIFI_DIRECT, "get local Channels list failed, error=%{public}d", ret);
for (auto goChannel : goFrequencyList) {
for (auto goChannel : goChannels) {
if (std::find(gcChannels.begin(), gcChannels.end(), goChannel) != gcChannels.end()) {
return WifiDirectUtils::ChannelToFrequency(goChannel);
}