mirror of
https://gitee.com/openharmony/communication_wifi.git
synced 2025-01-28 03:23:40 +00:00
randomMac
Signed-off-by: gaosong <gaosong29@huawei.com>
This commit is contained in:
parent
3ab8dcd5a5
commit
7b2e0b460f
@ -479,7 +479,9 @@ static napi_value JsObjToDeviceConfig(const napi_env& env, const napi_value& obj
|
||||
/* "creatorUid" is not supported currently */
|
||||
/* "disableReason" is not supported currently */
|
||||
JsObjectToInt(env, object, "netId", cppConfig.networkId);
|
||||
/* "randomMacType" is not supported currently */
|
||||
int randomMacType = static_cast<int>(WifiPrivacyConfig::RANDOMMAC);
|
||||
JsObjectToInt(env, object, "randomMacType", randomMacType);
|
||||
cppConfig.wifiPrivacySetting = WifiPrivacyConfig(randomMacType);
|
||||
/* "randomMacAddr" is not supported currently */
|
||||
int ipType = static_cast<int>(AssignIpMethod::UNASSIGNED);
|
||||
JsObjectToInt(env, object, "ipType", ipType);
|
||||
@ -1188,8 +1190,7 @@ static void DeviceConfigToJsArray(const napi_env& env, std::vector<WifiDeviceCon
|
||||
/* not supported currently */
|
||||
SetValueInt32(env, "disableReason", DEFAULT_INVALID_VALUE, result);
|
||||
SetValueInt32(env, "netId", vecDeviceConfigs[idx].networkId, result);
|
||||
/* not supported currently */
|
||||
SetValueInt32(env, "randomMacType", DEFAULT_INVALID_VALUE, result);
|
||||
SetValueInt32(env, "randomMacType", static_cast<int>(vecDeviceConfigs[idx].wifiPrivacySetting), result);
|
||||
/* not supported currently */
|
||||
SetValueUtf8String(env, "randomMacAddr", std::string("").c_str(), result);
|
||||
if (vecDeviceConfigs[idx].wifiIpConfig.assignMethod == AssignIpMethod::STATIC) {
|
||||
|
@ -166,6 +166,7 @@ static OHOS::Wifi::ErrCode ConvertDeviceConfigFromC(
|
||||
deviceConfig.keyMgmt = GetKeyMgmtBySecType(config->securityType);
|
||||
deviceConfig.networkId = config->netId;
|
||||
deviceConfig.frequency = config->freq;
|
||||
deviceConfig.wifiPrivacySetting = OHOS::Wifi::WifiPrivacyConfig(config->randomMacType);
|
||||
/* wapiPskType is not support, don't verify now */
|
||||
if (config->ipType == DHCP) {
|
||||
deviceConfig.wifiIpConfig.assignMethod = OHOS::Wifi::AssignIpMethod::DHCP;
|
||||
@ -197,6 +198,7 @@ static OHOS::Wifi::ErrCode ConvertDeviceConfigFromCpp(const OHOS::Wifi::WifiDevi
|
||||
result->securityType = GetSecTypeByKeyMgmt(deviceConfig.keyMgmt);
|
||||
result->netId = deviceConfig.networkId;
|
||||
result->freq = deviceConfig.frequency;
|
||||
result->randomMacType = static_cast<int>(deviceConfig.wifiPrivacySetting);
|
||||
/* wapiPskType is not support now */
|
||||
if (deviceConfig.wifiIpConfig.assignMethod == OHOS::Wifi::AssignIpMethod::DHCP) {
|
||||
result->ipType = DHCP;
|
||||
|
@ -201,6 +201,8 @@ typedef struct WifiDeviceConfig {
|
||||
IpConfig staticIp;
|
||||
/* 1 for hidden config */
|
||||
int isHiddenSsid;
|
||||
/* randomMacType */
|
||||
int randomMacType;
|
||||
} WifiDeviceConfig;
|
||||
|
||||
/**
|
||||
|
@ -647,6 +647,12 @@ void P2pStateMachine::ChangeConnectedStatus(P2pConnectedState connectedState)
|
||||
WIFI_LOGI("ChangeConnectedStatus, connectedState: %{public}d", connectedState);
|
||||
WifiP2pLinkedInfo p2pInfo;
|
||||
WifiSettings::GetInstance().GetP2pInfo(p2pInfo);
|
||||
P2pConnectedState curP2pConnectedState = p2pInfo.GetConnectState();
|
||||
if (curP2pConnectedState == connectedState) {
|
||||
WIFI_LOGD("The connection status is the same, ignore this status!");
|
||||
return;
|
||||
}
|
||||
|
||||
p2pInfo.SetConnectState(connectedState);
|
||||
WifiSettings::GetInstance().SaveP2pInfo(p2pInfo);
|
||||
groupManager.SaveP2pInfo(p2pInfo);
|
||||
|
@ -1410,6 +1410,7 @@ bool StaStateMachine::SetRandomMac(int networkId)
|
||||
std::string lastMac;
|
||||
std::string currentMac;
|
||||
if (deviceConfig.wifiPrivacySetting == WifiPrivacyConfig::DEVICEMAC) {
|
||||
WifiSettings::GetInstance().GetRealMacAddress(currentMac);
|
||||
} else {
|
||||
WifiStoreRandomMac randomMacInfo;
|
||||
std::vector<WifiScanInfo> scanInfoList;
|
||||
@ -2116,13 +2117,18 @@ void StaStateMachine::ConnectToNetworkProcess(InternalMessage *msg)
|
||||
}
|
||||
|
||||
std::string macAddr;
|
||||
std::string realMacAddr;
|
||||
WifiSettings::GetInstance().GetMacAddress(macAddr);
|
||||
WifiSettings::GetInstance().GetRealMacAddress(realMacAddr);
|
||||
linkedInfo.networkId = lastNetworkId;
|
||||
linkedInfo.bssid = bssid;
|
||||
linkedInfo.ssid = deviceConfig.ssid;
|
||||
linkedInfo.macType = (macAddr == realMacAddr ?
|
||||
static_cast<int>(WifiPrivacyConfig::DEVICEMAC) : static_cast<int>(WifiPrivacyConfig::RANDOMMAC));
|
||||
linkedInfo.macAddress = macAddr;
|
||||
linkedInfo.ifHiddenSSID = deviceConfig.hiddenSSID;
|
||||
lastLinkedInfo.bssid = bssid;
|
||||
lastLinkedInfo.macType = static_cast<int>(deviceConfig.wifiPrivacySetting);
|
||||
lastLinkedInfo.macAddress = deviceConfig.macAddress;
|
||||
lastLinkedInfo.ifHiddenSSID = deviceConfig.hiddenSSID;
|
||||
SetWifiLinkedInfo(lastNetworkId);
|
||||
|
Loading…
x
Reference in New Issue
Block a user