!3375 随机MAC内存泄漏

Merge pull request !3375 from fengye/master
This commit is contained in:
openharmony_ci 2024-11-21 10:03:29 +00:00 committed by Gitee
commit 4dcefa4642
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
6 changed files with 17 additions and 31 deletions

View File

@ -76,7 +76,7 @@ private:
class WifiCountryCodeIntlUtils {
public:
WifiCountryCodeIntlUtils() : wifiLibraryUtils_("libwifi_ext_lib.z.so", libHandle_, true) {}
WifiCountryCodeIntlUtils() : wifiLibraryUtils_("libwifi_ext_lib.z.so", libHandle_, false) {}
~WifiCountryCodeIntlUtils() = default;
std::string GetSystemRegion();
private:

View File

@ -343,17 +343,13 @@ void WifiP2pGroupManager::RemoveMacAddrPairInfo(WifiMacAddrInfoType type, const
WIFI_LOGD("%{public}s del mac address, type:%{public}d, GOName:%{private}s, addr:%{private}s, addrType:%{public}d",
__func__, type, owner.GetDeviceName().c_str(),
owner.GetDeviceAddress().c_str(), owner.GetDeviceAddressType());
WifiMacAddrInfo macAddrInfo;
macAddrInfo.bssid = owner.GetDeviceAddress();
macAddrInfo.bssidType = owner.GetDeviceAddressType();
WifiConfigCenter::GetInstance().RemoveMacAddrPairs(type, macAddrInfo);
WifiConfigCenter::GetInstance().RemoveMacAddrPairInfo(type,
owner.GetDeviceAddress(), owner.GetDeviceAddressType());
std::vector<WifiP2pDevice> clientVec = group.GetClientDevices();
for (auto iter = clientVec.begin(); iter != clientVec.end(); ++iter) {
WifiMacAddrInfo clientMacAddrInfo;
clientMacAddrInfo.bssid = iter->GetDeviceAddress();
clientMacAddrInfo.bssidType = iter->GetDeviceAddressType();
WifiConfigCenter::GetInstance().RemoveMacAddrPairs(type, clientMacAddrInfo);
WifiConfigCenter::GetInstance().RemoveMacAddrPairInfo(type,
iter->GetDeviceAddress(), iter->GetDeviceAddressType());
}
}
#endif

View File

@ -755,15 +755,7 @@ int WifiConfigCenter::ManageStation(const StationInfo &info, int mode, int id)
mConnectStationInfo.erase(iter);
}
#ifdef SUPPORT_RANDOM_MAC_ADDR
WifiMacAddrInfo randomMacAddrInfo;
randomMacAddrInfo.bssid = info.bssid;
randomMacAddrInfo.bssidType = RANDOM_DEVICE_ADDRESS;
RemoveMacAddrPairs(WifiMacAddrInfoType::HOTSPOT_MACADDR_INFO, randomMacAddrInfo);
WifiMacAddrInfo realMacAddrInfo;
realMacAddrInfo.bssid = info.bssid;
realMacAddrInfo.bssidType = REAL_DEVICE_ADDRESS;
RemoveMacAddrPairs(WifiMacAddrInfoType::HOTSPOT_MACADDR_INFO, realMacAddrInfo);
RemoveMacAddrPairInfo(WifiMacAddrInfoType::HOTSPOT_MACADDR_INFO, info.bssid, info.bssidType);
#endif
} else {
return -1;
@ -1340,19 +1332,19 @@ void WifiConfigCenter::DelMacAddrPairs(std::map<WifiMacAddrInfo, std::string>& m
}
}
void WifiConfigCenter::RemoveMacAddrPairInfo(WifiMacAddrInfoType type, std::string bssid)
void WifiConfigCenter::RemoveMacAddrPairInfo(WifiMacAddrInfoType type, std::string bssid, int bssidType)
{
LOGD("%{public}s: remove a mac address pair, type:%{public}d, bssid:%{private}s",
__func__, type, bssid.c_str());
WifiMacAddrInfo randomMacAddrInfo;
randomMacAddrInfo.bssid = GetRandomMacAddr(type, bssid);
randomMacAddrInfo.bssidType = REAL_DEVICE_ADDRESS == bssidType ? RANDOM_DEVICE_ADDRESS : REAL_DEVICE_ADDRESS;
RemoveMacAddrPairs(type, randomMacAddrInfo);
WifiMacAddrInfo realMacAddrInfo;
realMacAddrInfo.bssid = bssid;
realMacAddrInfo.bssidType = REAL_DEVICE_ADDRESS;
realMacAddrInfo.bssidType = REAL_DEVICE_ADDRESS == bssidType ? REAL_DEVICE_ADDRESS : RANDOM_DEVICE_ADDRESS;
RemoveMacAddrPairs(type, realMacAddrInfo);
WifiMacAddrInfo randomMacAddrInfo;
randomMacAddrInfo.bssid = bssid;
randomMacAddrInfo.bssidType = RANDOM_DEVICE_ADDRESS;
RemoveMacAddrPairs(type, randomMacAddrInfo);
}
WifiMacAddrErrCode WifiConfigCenter::AddMacAddrPairs(WifiMacAddrInfoType type,

View File

@ -304,8 +304,6 @@ public:
std::string GetRandomMacAddr(WifiMacAddrInfoType type, std::string bssid);
int RemoveMacAddrPairs(WifiMacAddrInfoType type, const WifiMacAddrInfo &macAddrInfo);
std::string GetMacAddrPairs(WifiMacAddrInfoType type, const WifiMacAddrInfo &macAddrInfo);
void ClearMacAddrPairs(WifiMacAddrInfoType type);
@ -318,7 +316,7 @@ public:
bool HasWifiActive();
void RemoveMacAddrPairInfo(WifiMacAddrInfoType type, std::string bssid);
void RemoveMacAddrPairInfo(WifiMacAddrInfoType type, std::string bssid, int bssidType);
void UpdateLinkedInfo(int instId = 0);
@ -334,6 +332,7 @@ private:
void DelMacAddrPairs(std::map<WifiMacAddrInfo, std::string>& macAddrInfoMap, const WifiMacAddrInfo &macAddrInfo);
WifiMacAddrErrCode AddMacAddrPairs(WifiMacAddrInfoType type, const WifiMacAddrInfo &macAddrInfo,
std::string randomMacAddr);
int RemoveMacAddrPairs(WifiMacAddrInfoType type, const WifiMacAddrInfo &macAddrInfo);
private:
// STA

View File

@ -323,7 +323,7 @@ int WifiScanConfig::GetScanInfoList(std::vector<WifiScanInfo> &results)
if (iter->disappearCount >= WIFI_DISAPPEAR_TIMES) {
#ifdef SUPPORT_RANDOM_MAC_ADDR
WifiConfigCenter::GetInstance().RemoveMacAddrPairInfo(
WifiMacAddrInfoType::WIFI_SCANINFO_MACADDR_INFO, iter->bssid);
WifiMacAddrInfoType::WIFI_SCANINFO_MACADDR_INFO, iter->bssid, iter->bssidType);
#endif
LOGI("ScanInfo remove ssid=%{public}s bssid=%{public}s.\n",
SsidAnonymize(iter->ssid).c_str(), MacAnonymize(iter->bssid).c_str());

View File

@ -206,14 +206,13 @@
"OHOS::Wifi::WifiConfigCenter::GetThreadStatusFlag() const";
"OHOS::Wifi::WifiConfigCenter::GetThreadStartTime() const";
"OHOS::Wifi::WifiConfigCenter::GetRandomMacAddr(OHOS::Wifi::WifiMacAddrInfoType, std::string)";
"OHOS::Wifi::WifiConfigCenter::RemoveMacAddrPairs(OHOS::Wifi::WifiMacAddrInfoType, OHOS::Wifi::WifiMacAddrInfo const&)";
"OHOS::Wifi::WifiConfigCenter::GetMacAddrPairs(OHOS::Wifi::WifiMacAddrInfoType, OHOS::Wifi::WifiMacAddrInfo const&)";
"OHOS::Wifi::WifiConfigCenter::ClearMacAddrPairs(OHOS::Wifi::WifiMacAddrInfoType)";
"OHOS::Wifi::WifiConfigCenter::GetAllWifiLinkedNetworkId()";
"OHOS::Wifi::WifiConfigCenter::SetPersistWifiState(int, int)";
"OHOS::Wifi::WifiConfigCenter::GetPersistWifiState(int)";
"OHOS::Wifi::WifiConfigCenter::HasWifiActive()";
"OHOS::Wifi::WifiConfigCenter::RemoveMacAddrPairInfo(OHOS::Wifi::WifiMacAddrInfoType, std::string)";
"OHOS::Wifi::WifiConfigCenter::RemoveMacAddrPairInfo(OHOS::Wifi::WifiMacAddrInfoType, std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>>, int)";
"OHOS::Wifi::WifiConfigCenter::UpdateLinkedInfo(int)";
"OHOS::Wifi::WifiConfigCenter::InsertWifiCategoryBlackListCache(int, std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>>, OHOS::Wifi::WifiCategoryBlackListInfo)";
"OHOS::Wifi::WifiConfigCenter::GetWifiCategoryBlackListCache(int, std::__h::map<std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>>, OHOS::Wifi::WifiCategoryBlackListInfo, std::__h::less<std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>>>, std::__h::allocator<std::__h::pair<std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>> const, OHOS::Wifi::WifiCategoryBlackListInfo>>>&)";