mirror of
https://gitee.com/openharmony/communication_wifi.git
synced 2024-12-03 13:01:31 +00:00
commit
2d44406c35
@ -22,8 +22,10 @@ extern "C" {
|
||||
|
||||
#ifdef OHOS_EUPDATER
|
||||
#define CONFIG_ROOR_DIR "/tmp/service/el1/public/wifi"
|
||||
#define P2P_CONFIG_FILE "/tmp/service/el1/public/wifi/p2p_supplicant.conf"
|
||||
#else
|
||||
#define CONFIG_ROOR_DIR "/data/service/el1/public/wifi"
|
||||
#define P2P_CONFIG_FILE "/data/service/el1/public/wifi/p2p_supplicant.conf"
|
||||
#endif // OHOS_EUPDATER
|
||||
|
||||
#define WIFI_MANAGGER_PID_NAME "wifi_mgr_pid"
|
||||
|
@ -107,6 +107,10 @@ ohos_shared_library("wifi_ap_service") {
|
||||
defines += [ "SUPPORT_RANDOM_MAC_ADDR" ]
|
||||
}
|
||||
|
||||
if (wifi_feature_with_local_random_mac) {
|
||||
defines += [ "SUPPORT_LOCAL_RANDOM_MAC" ]
|
||||
}
|
||||
|
||||
part_name = "wifi"
|
||||
subsystem_name = "communication"
|
||||
}
|
||||
|
@ -178,6 +178,28 @@ bool ApStartedState::SetConfig(HotspotConfig &apConfig)
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_LOCAL_RANDOM_MAC
|
||||
HotspotConfig curApConfig;
|
||||
WifiSettings::GetInstance().GetHotspotConfig(curApConfig, m_id);
|
||||
|
||||
LOGD("%{public}s: [ssid:%{private}s, securityType:%{public}d] ==> [ssid:%{private}s, securityType:%{public}d]",
|
||||
__func__, curApConfig.GetSsid().c_str(), curApConfig.GetSecurityType(),
|
||||
apConfig.GetSsid().c_str(), apConfig.GetSecurityType());
|
||||
if ((curApConfig.GetSsid() != apConfig.GetSsid()) ||
|
||||
(curApConfig.GetSecurityType() != apConfig.GetSecurityType())) {
|
||||
std::string macAddress;
|
||||
WifiSettings::GetInstance().GenerateRandomMacAddress(macAddress);
|
||||
if (MacAddress::IsValidMac(macAddress.c_str())) {
|
||||
if (WifiApHalInterface::GetInstance().SetConnectMacAddr(macAddress) != WIFI_IDL_OPT_OK) {
|
||||
LOGE("%{public}s: failed to set ap MAC address:%{private}s", __func__, macAddress.c_str());
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
LOGW("%{public}s: macAddress is invalid", __func__);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
WifiSettings::GetInstance().SetHotspotConfig(apConfig, m_id);
|
||||
WifiSettings::GetInstance().SyncHotspotConfig();
|
||||
m_ApConfigUse.LogConfig(apConfig);
|
||||
|
@ -79,7 +79,11 @@ void P2pDisabledState::SetVendorFeatures() const
|
||||
if (ret < 0) {
|
||||
WIFI_LOGW("Failed to obtain P2pVendorConfig information.");
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_LOCAL_RANDOM_MAC
|
||||
p2pVendorCfg.SetRandomMacSupport(true);
|
||||
WifiSettings::GetInstance().SetP2pVendorConfig(p2pVendorCfg);
|
||||
WifiSettings::GetInstance().SyncP2pVendorConfig();
|
||||
#endif
|
||||
WIFI_LOGI("P2pVendorConfig random mac is %{public}s", p2pVendorCfg.GetRandomMacSupport() ? "true" : "false");
|
||||
WifiP2PHalInterface::GetInstance().SetRandomMacAddr(p2pVendorCfg.GetRandomMacSupport());
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ void P2pStateMachine::InitializeThisDevice()
|
||||
if (ret < 0) {
|
||||
WIFI_LOGW("Failed to obtain P2pVendorConfig information.");
|
||||
}
|
||||
|
||||
WIFI_LOGI("%{public}s: random mac is %{public}s", __func__, p2pVendorCfg.GetRandomMacSupport() ? "true" : "false");
|
||||
if (p2pVendorCfg.GetDeviceName().empty()) {
|
||||
deviceName = std::string("OHOS_") + GetRandomStr(randomLen);
|
||||
p2pVendorCfg.SetDeviceName(deviceName);
|
||||
|
@ -156,6 +156,19 @@ int ExcuteCmd(const char *szCmd)
|
||||
return HAL_FAILURE;
|
||||
}
|
||||
|
||||
int FileIsExisted(const char* file)
|
||||
{
|
||||
if (file == NULL) {
|
||||
LOGE("%{pubic}s: invalid parameter", __func__);
|
||||
return HAL_FAILURE;
|
||||
}
|
||||
if (access(file, F_OK) != -1) {
|
||||
LOGE("%{pubic}s: file isn't existed", __func__);
|
||||
return HAL_FAILURE;
|
||||
}
|
||||
return HAL_SUCCESS;
|
||||
}
|
||||
|
||||
int CopyConfigFile(const char* configName)
|
||||
{
|
||||
char buf[BUFF_SIZE] = {0};
|
||||
@ -169,6 +182,10 @@ int CopyConfigFile(const char* configName)
|
||||
LOGE("strcat_s failed.");
|
||||
return HAL_FAILURE;
|
||||
}
|
||||
if ((strcmp(path[i], P2P_CONFIG_FILE) == 0) && FileIsExisted(path[i])) {
|
||||
LOGW("%{public}s: path[%{public}d]: %{public}s is existed", __func__, i, path[i]);
|
||||
break;
|
||||
}
|
||||
if (access(path[i], F_OK) != -1) {
|
||||
char cmd[BUFF_SIZE] = {0};
|
||||
if (snprintf_s(cmd, sizeof(cmd), sizeof(cmd) - 1,
|
||||
|
@ -40,7 +40,7 @@ WifiHalVendorInterface *GetWifiHalVendorInterface(void);
|
||||
void ReleaseWifiHalVendorInterface(void);
|
||||
|
||||
int ExcuteCmd(const char *szCmd);
|
||||
|
||||
int FileIsExisted(const char* file);
|
||||
int CopyConfigFile(const char* configName);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ declare_args() {
|
||||
wifi_feature_with_app_frozen = false
|
||||
wifi_feature_non_seperate_p2p = false
|
||||
wifi_feature_non_hdf_driver = false
|
||||
wifi_feature_with_local_random_mac = false
|
||||
wifi_feature_with_local_random_mac = true
|
||||
if (defined(global_parts_info) &&
|
||||
defined(global_parts_info.resourceschedule_efficiency_manager)) {
|
||||
wifi_feature_with_app_frozen = true
|
||||
|
Loading…
Reference in New Issue
Block a user