mirror of
https://gitee.com/openharmony/communication_wifi.git
synced 2024-11-23 07:00:07 +00:00
commit
025f8acfff
@ -116,4 +116,12 @@
|
||||
#define INTERFACEDESCRIPTORL1 u"ohos.wifi.IWifiDeviceService"
|
||||
#define DECLARE_INTERFACE_DESCRIPTOR_L1_LENGTH (sizeof(INTERFACEDESCRIPTORL1)/sizeof(uint16_t))
|
||||
#define DECLARE_INTERFACE_DESCRIPTOR_L1 ((uint16_t*)&INTERFACEDESCRIPTORL1[0])
|
||||
|
||||
/* Multilink */
|
||||
#define INSTID_WLAN0 (0)
|
||||
#define INSTID_WLAN1 (1)
|
||||
#ifndef STA_INSTANCE_MAX_NUM
|
||||
#define STA_INSTANCE_MAX_NUM (2)
|
||||
#endif
|
||||
|
||||
#endif
|
@ -32,6 +32,7 @@ NO_SANITIZE("cfi") std::shared_ptr<WifiDevice> WifiDevice::GetInstance(int syste
|
||||
|
||||
std::shared_ptr<WifiDeviceImpl> device = std::make_shared<WifiDeviceImpl>();
|
||||
if (device && device->Init(systemAbilityId, instId)) {
|
||||
WIFI_LOGI("Init instId%{public}d. %{public}d", instId, systemAbilityId);
|
||||
return device;
|
||||
}
|
||||
|
||||
|
@ -468,6 +468,8 @@ if (defined(ohos_lite)) {
|
||||
sources = [
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_controller/concrete_clientmode_manager.cpp",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_controller/concrete_manager_state_machine.cpp",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_controller/multi_sta_manager.cpp",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_controller/multi_sta_state_machine.cpp",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_controller/softap_manager.cpp",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_controller/softap_manager_state_machine.cpp",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_controller/wifi_controller_state_machine.cpp",
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "wifi_common_util.h"
|
||||
#include "wifi_auth_center.h"
|
||||
#include "wifi_permission_utils.h"
|
||||
#include "define.h"
|
||||
#ifdef SUPPORT_RANDOM_MAC_ADDR
|
||||
#include "wifi_p2p_msg.h"
|
||||
#include "wifi_common_msg.h"
|
||||
@ -555,13 +556,13 @@ void WifiInternalEventDispatcher::DealStaCallbackMsg(
|
||||
|
||||
switch (msg.msgCode) {
|
||||
case WIFI_CBK_MSG_STATE_CHANGE:
|
||||
WifiInternalEventDispatcher::PublishWifiStateChangedEvent(msg.msgData);
|
||||
WifiInternalEventDispatcher::PublishWifiStateChangedEvent(msg.msgData, msg.id);
|
||||
break;
|
||||
case WIFI_CBK_MSG_CONNECTION_CHANGE:
|
||||
WifiInternalEventDispatcher::PublishConnStateChangedEvent(msg.msgData, msg.linkInfo);
|
||||
WifiInternalEventDispatcher::PublishConnStateChangedEvent(msg.msgData, msg.id, msg.linkInfo);
|
||||
break;
|
||||
case WIFI_CBK_MSG_RSSI_CHANGE:
|
||||
WifiInternalEventDispatcher::PublishRssiValueChangedEvent(msg.msgData);
|
||||
WifiInternalEventDispatcher::PublishRssiValueChangedEvent(msg.msgData, msg.id);
|
||||
break;
|
||||
case WIFI_CBK_MSG_STREAM_DIRECTION:
|
||||
break;
|
||||
@ -936,7 +937,7 @@ void WifiInternalEventDispatcher::DealP2pCallbackMsg(
|
||||
return;
|
||||
}
|
||||
|
||||
void WifiInternalEventDispatcher::PublishConnStateChangedEvent(int state, const WifiLinkedInfo &info)
|
||||
void WifiInternalEventDispatcher::PublishConnStateChangedEvent(int state, int instId, const WifiLinkedInfo &info)
|
||||
{
|
||||
std::string eventData = "Other";
|
||||
switch (state) {
|
||||
@ -957,15 +958,20 @@ void WifiInternalEventDispatcher::PublishConnStateChangedEvent(int state, const
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!WifiCommonEventHelper::PublishConnStateChangedEvent(state, eventData)) {
|
||||
WIFI_LOGE("failed to publish connection state changed event,%{public}s!", eventData.c_str());
|
||||
if ((instId == INSTID_WLAN0 && WifiCommonEventHelper::PublishConnStateChangedEvent(state, eventData)) ||
|
||||
(instId == INSTID_WLAN1 && WifiCommonEventHelper::PublishWifi2ConnStateChangedEvent(state, eventData))) {
|
||||
WIFI_LOGI("publish connection state changed event,%{public}s, instId %{public}d.", eventData.c_str(), instId);
|
||||
return;
|
||||
}
|
||||
WIFI_LOGI("publish connection state changed event,%{public}s.", eventData.c_str());
|
||||
WIFI_LOGE("publish connection state changed event,%{public}s, instId %{public}d fail.", eventData.c_str(), instId);
|
||||
}
|
||||
|
||||
void WifiInternalEventDispatcher::PublishRssiValueChangedEvent(int state)
|
||||
void WifiInternalEventDispatcher::PublishRssiValueChangedEvent(int state, int instId)
|
||||
{
|
||||
if (instId == INSTID_WLAN1) {
|
||||
WIFI_LOGW("PublishRssiValueChangedEvent instId wlan1!");
|
||||
return ;
|
||||
}
|
||||
WifiLinkedInfo likedInfo;
|
||||
WifiConfigCenter::GetInstance().GetLinkedInfo(likedInfo);
|
||||
int signalLevel = WifiSettings::GetInstance().GetSignalLevel(state, likedInfo.band);
|
||||
@ -977,13 +983,24 @@ void WifiInternalEventDispatcher::PublishRssiValueChangedEvent(int state)
|
||||
WIFI_LOGD("publish rssi value changed event.");
|
||||
}
|
||||
|
||||
void WifiInternalEventDispatcher::PublishWifiStateChangedEvent(int state)
|
||||
void WifiInternalEventDispatcher::PublishWifiStateChangedEvent(int state, int instId)
|
||||
{
|
||||
if (!WifiCommonEventHelper::PublishPowerStateChangeEvent(state, "OnWifiPowerStateChanged")) {
|
||||
WIFI_LOGE("failed to publish wifi state changed event!");
|
||||
return;
|
||||
if (instId == INSTID_WLAN0) {
|
||||
if (!WifiCommonEventHelper::PublishPowerStateChangeEvent(state, "OnWifiPowerStateChanged")) {
|
||||
WIFI_LOGE("failed to publish wifi state changed event!");
|
||||
return;
|
||||
}
|
||||
} else if (instId == INSTID_WLAN1) {
|
||||
if (!WifiCommonEventHelper::PublishWifi2PowerStateChangeEvent(state, "OnWifiPowerStateChanged")) {
|
||||
WIFI_LOGE("failed to publish wifi state changed event!");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
WIFI_LOGE("invalid InstId!");
|
||||
return;
|
||||
}
|
||||
WIFI_LOGD("publish wifi state changed event.");
|
||||
|
||||
WIFI_LOGI("publish wifi state changed event, state %{public}d, instId %{public}d", state, instId);
|
||||
}
|
||||
|
||||
bool WifiInternalEventDispatcher::VerifyRegisterCallbackPermission(int callbackEventId)
|
||||
|
@ -132,9 +132,9 @@ private:
|
||||
#ifdef SUPPORT_RANDOM_MAC_ADDR
|
||||
static void updateP2pDeviceMacAddress(std::vector<WifiP2pDevice> &device);
|
||||
#endif
|
||||
static void PublishConnStateChangedEvent(int state, const WifiLinkedInfo &info);
|
||||
static void PublishWifiStateChangedEvent(int state);
|
||||
static void PublishRssiValueChangedEvent(int state);
|
||||
static void PublishConnStateChangedEvent(int state, int instId, const WifiLinkedInfo &info);
|
||||
static void PublishWifiStateChangedEvent(int state, int instId);
|
||||
static void PublishRssiValueChangedEvent(int state, int instId);
|
||||
static void SendConfigChangeEvent(sptr<IWifiP2pCallback> &callback, CfgInfo* cfgInfo);
|
||||
private:
|
||||
std::unique_ptr<WifiEventHandler> mBroadcastThread = nullptr;
|
||||
|
@ -232,7 +232,7 @@ void WifiNetAgent::OnStaMachineNetManagerRestart(const sptr<NetManagerStandard::
|
||||
void WifiNetAgent::CreateNetLinkInfo(sptr<NetManagerStandard::NetLinkInfo> &netLinkInfo, IpInfo &wifiIpInfo,
|
||||
IpV6Info &wifiIpV6Info, WifiProxyConfig &wifiProxyConfig, int instId)
|
||||
{
|
||||
netLinkInfo->ifaceName_ = WifiConfigCenter::GetInstance().GetStaIfaceName();
|
||||
netLinkInfo->ifaceName_ = WifiConfigCenter::GetInstance().GetStaIfaceName(instId);
|
||||
|
||||
SetNetLinkIPInfo(netLinkInfo, wifiIpInfo, wifiIpV6Info);
|
||||
SetNetLinkRouteInfo(netLinkInfo, wifiIpInfo, wifiIpV6Info);
|
||||
|
@ -59,10 +59,12 @@ ConcreteMangerMachine::~ConcreteMangerMachine()
|
||||
WifiConfigCenter::GetInstance().SetWifiStopState(false);
|
||||
#ifdef HDI_CHIP_INTERFACE_SUPPORT
|
||||
if (!ifaceName.empty()) {
|
||||
WIFI_LOGW("destroy ConcreteMangerMachine RemoveStaIface ifaceName:%{public}s, instId:%{public}d",
|
||||
ifaceName.c_str(), mid);
|
||||
DelayedSingleton<HalDeviceManager>::GetInstance()->RemoveStaIface(ifaceName);
|
||||
ifaceName.clear();
|
||||
WifiServiceScheduler::GetInstance().ClearStaIfaceNameMap(mid);
|
||||
WifiConfigCenter::GetInstance().SetStaIfaceName("");
|
||||
WifiConfigCenter::GetInstance().SetStaIfaceName("", mid);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (C) 2021-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software``
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "multi_sta_manager.h"
|
||||
#include "wifi_logger.h"
|
||||
|
||||
DEFINE_WIFILOG_LABEL("MultiStaManager");
|
||||
|
||||
namespace OHOS {
|
||||
namespace Wifi {
|
||||
MultiStaManager::MultiStaManager(MultiStaManager::Role role, int id) : mid(id), curRole(role),
|
||||
pMultiStaStateMachine(nullptr)
|
||||
{}
|
||||
|
||||
MultiStaManager::~MultiStaManager()
|
||||
{
|
||||
WIFI_LOGE("Exit.");
|
||||
if (pMultiStaStateMachine != nullptr) {
|
||||
delete pMultiStaStateMachine;
|
||||
}
|
||||
}
|
||||
|
||||
ErrCode MultiStaManager::InitMultiStaManager()
|
||||
{
|
||||
pMultiStaStateMachine = new (std::nothrow) MultiStaStateMachine();
|
||||
if (pMultiStaStateMachine == nullptr) {
|
||||
WIFI_LOGE("Alloc pMultiStaStateMachine failed.\n");
|
||||
return WIFI_OPT_FAILED;
|
||||
}
|
||||
if (pMultiStaStateMachine->InitMultiStaStateMachine() != WIFI_OPT_SUCCESS) {
|
||||
WIFI_LOGE("InitMultiStaStateMachine failed.\n");
|
||||
return WIFI_OPT_FAILED;
|
||||
}
|
||||
pMultiStaStateMachine->RegisterCallback(mcb);
|
||||
pMultiStaStateMachine->SendMessage(MULTI_STA_CMD_START, static_cast<int>(curRole), mid);
|
||||
return WIFI_OPT_SUCCESS;
|
||||
}
|
||||
|
||||
ErrCode MultiStaManager::RegisterCallback(const MultiStaModeCallback &callbacks)
|
||||
{
|
||||
mcb = callbacks;
|
||||
return WIFI_OPT_SUCCESS;
|
||||
}
|
||||
|
||||
MultiStaStateMachine *MultiStaManager::GetMultiStaMachine()
|
||||
{
|
||||
return pMultiStaStateMachine;
|
||||
}
|
||||
|
||||
void MultiStaManager::SetRole(Role role)
|
||||
{
|
||||
curRole = role;
|
||||
}
|
||||
|
||||
MultiStaManager::Role MultiStaManager::GetRole()
|
||||
{
|
||||
return curRole;
|
||||
}
|
||||
|
||||
} // namespace Wifi
|
||||
} // namespace OHOS
|
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (C) 2021-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_MULTI_STA_MANAGER_H
|
||||
#define OHOS_MULTI_STA_MANAGER_H
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include "wifi_errcode.h"
|
||||
#include "multi_sta_state_machine.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Wifi {
|
||||
class MultiStaManager {
|
||||
public:
|
||||
enum class Role {
|
||||
ROLE_UNKNOW = -1,
|
||||
ROLE_STA_WIFI_2 = 0,
|
||||
ROLE_STA_2_REMOVED = 1,
|
||||
};
|
||||
|
||||
explicit MultiStaManager(MultiStaManager::Role role, int id);
|
||||
ErrCode RegisterCallback(const MultiStaModeCallback &callbacks);
|
||||
~MultiStaManager();
|
||||
ErrCode InitMultiStaManager();
|
||||
void SetRole(Role role);
|
||||
Role GetRole();
|
||||
MultiStaStateMachine *GetMultiStaMachine();
|
||||
int mid;
|
||||
|
||||
private:
|
||||
MultiStaManager::Role curRole;
|
||||
MultiStaModeCallback mcb;
|
||||
MultiStaStateMachine *pMultiStaStateMachine;
|
||||
};
|
||||
} // namespace Wifi
|
||||
} // namespace OHOS
|
||||
#endif
|
@ -0,0 +1,221 @@
|
||||
/*
|
||||
* Copyright (C) 2021-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "multi_sta_state_machine.h"
|
||||
#include "wifi_manager.h"
|
||||
#include "wifi_service_manager.h"
|
||||
#include "wifi_config_center.h"
|
||||
#include "wifi_chip_hal_interface.h"
|
||||
#include "wifi_internal_event_dispatcher.h"
|
||||
#include "wifi_settings.h"
|
||||
#include "wifi_common_event_helper.h"
|
||||
#include "wifi_service_scheduler.h"
|
||||
#include "i_ap_service.h"
|
||||
#ifdef HDI_CHIP_INTERFACE_SUPPORT
|
||||
#include "hal_device_manage.h"
|
||||
#endif
|
||||
|
||||
namespace OHOS {
|
||||
namespace Wifi {
|
||||
DEFINE_WIFILOG_LABEL("MultiStaStateMachine");
|
||||
int MultiStaStateMachine::mid{0};
|
||||
|
||||
MultiStaStateMachine::MultiStaStateMachine()
|
||||
: StateMachine("MultiStaStateMachine"), pDefaultState(nullptr), pIdleState(nullptr), pStartedState(nullptr)
|
||||
{}
|
||||
|
||||
MultiStaStateMachine::~MultiStaStateMachine()
|
||||
{
|
||||
WIFI_LOGE("MultiStaStateMachine::~MultiStaStateMachine");
|
||||
StopHandlerThread();
|
||||
ParsePointer(pDefaultState);
|
||||
ParsePointer(pIdleState);
|
||||
ParsePointer(pStartedState);
|
||||
#ifdef HDI_CHIP_INTERFACE_SUPPORT
|
||||
if (!ifaceName.empty()) {
|
||||
WIFI_LOGW("~MultiStaStateMachine ifaceName: %{public}s,instId:%{public}d",
|
||||
ifaceName.c_str(), mid);
|
||||
DelayedSingleton<HalDeviceManager>::GetInstance()->RemoveStaIface(ifaceName);
|
||||
ifaceName.clear();
|
||||
WifiServiceScheduler::GetInstance().ClearStaIfaceNameMap(mid);
|
||||
WifiConfigCenter::GetInstance().SetStaIfaceName("", mid);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* --------------------------Initialization functions--------------------------*/
|
||||
ErrCode MultiStaStateMachine::InitMultiStaStateMachine()
|
||||
{
|
||||
WIFI_LOGI("Enter MultiStaStateMachine::InitMultiStaStateMachine.\n");
|
||||
if (!InitialStateMachine("MultiStaStateMachine")) {
|
||||
WIFI_LOGE("Initial StateMachine failed.\n");
|
||||
return WIFI_OPT_FAILED;
|
||||
}
|
||||
|
||||
if (InitMultiStaStates() == WIFI_OPT_FAILED) {
|
||||
return WIFI_OPT_FAILED;
|
||||
}
|
||||
BuildStateTree();
|
||||
SetFirstState(pIdleState);
|
||||
StartStateMachine();
|
||||
return WIFI_OPT_SUCCESS;
|
||||
}
|
||||
|
||||
void MultiStaStateMachine::BuildStateTree()
|
||||
{
|
||||
StatePlus(pDefaultState, nullptr);
|
||||
StatePlus(pIdleState, pDefaultState);
|
||||
StatePlus(pStartedState, pDefaultState);
|
||||
}
|
||||
|
||||
ErrCode MultiStaStateMachine::InitMultiStaStates()
|
||||
{
|
||||
int tmpErrNumber;
|
||||
|
||||
WIFI_LOGE("Enter MultiStaStateMachine\n");
|
||||
pDefaultState = new (std::nothrow) DefaultState(this);
|
||||
tmpErrNumber = JudgmentEmpty(pDefaultState);
|
||||
pIdleState = new (std::nothrow) IdleState(this);
|
||||
tmpErrNumber += JudgmentEmpty(pIdleState);
|
||||
pStartedState = new (std::nothrow) StartedState(this);
|
||||
tmpErrNumber += JudgmentEmpty(pStartedState);
|
||||
if (tmpErrNumber != 0) {
|
||||
WIFI_LOGE("InitMultiStaStates some one state is null\n");
|
||||
return WIFI_OPT_FAILED;
|
||||
}
|
||||
return WIFI_OPT_SUCCESS;
|
||||
}
|
||||
|
||||
ErrCode MultiStaStateMachine::RegisterCallback(const MultiStaModeCallback &callbacks)
|
||||
{
|
||||
mcb = callbacks;
|
||||
return WIFI_OPT_SUCCESS;
|
||||
}
|
||||
|
||||
MultiStaStateMachine::DefaultState::DefaultState(MultiStaStateMachine *multiStaStateMachine)
|
||||
: State("DefaultState"), pMultiStaStateMachine(multiStaStateMachine)
|
||||
{}
|
||||
|
||||
MultiStaStateMachine::DefaultState::~DefaultState()
|
||||
{}
|
||||
|
||||
void MultiStaStateMachine::DefaultState::GoInState()
|
||||
{
|
||||
WIFI_LOGE("DefaultState GoInState function.\n");
|
||||
}
|
||||
|
||||
void MultiStaStateMachine::DefaultState::GoOutState()
|
||||
{
|
||||
WIFI_LOGE("DefaultState GoOutState function.\n");
|
||||
}
|
||||
|
||||
bool MultiStaStateMachine::DefaultState::ExecuteStateMsg(InternalMessagePtr msg)
|
||||
{
|
||||
if (msg == nullptr || pMultiStaStateMachine == nullptr) {
|
||||
return false;
|
||||
}
|
||||
WIFI_LOGE("DefaultState-msgCode=%{public}d is received.\n", msg->GetMessageName());
|
||||
return true;
|
||||
}
|
||||
|
||||
MultiStaStateMachine::IdleState::IdleState(MultiStaStateMachine *multiStaStateMachine)
|
||||
: State("IdleState"), pMultiStaStateMachine(multiStaStateMachine)
|
||||
{}
|
||||
|
||||
MultiStaStateMachine::IdleState::~IdleState()
|
||||
{}
|
||||
|
||||
void MultiStaStateMachine::IdleState::GoInState()
|
||||
{
|
||||
WIFI_LOGE("IdleState GoInState function.\n");
|
||||
}
|
||||
|
||||
void MultiStaStateMachine::IdleState::GoOutState()
|
||||
{
|
||||
WIFI_LOGE("IdleState GoOutState function.\n");
|
||||
}
|
||||
|
||||
bool MultiStaStateMachine::IdleState::ExecuteStateMsg(InternalMessagePtr msg)
|
||||
{
|
||||
if (msg == nullptr) {
|
||||
return false;
|
||||
}
|
||||
WIFI_LOGI("IdleState-msgCode=%{public}d is received.\n", msg->GetMessageName());
|
||||
switch (msg->GetMessageName()) {
|
||||
case MULTI_STA_CMD_START:
|
||||
HandleStartInIdleState(msg);
|
||||
break;
|
||||
case MULTI_STA_CMD_STOP:
|
||||
break;
|
||||
case MULTI_STA_CMD_STARTED:
|
||||
pMultiStaStateMachine->SwitchState(pMultiStaStateMachine->pStartedState);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void MultiStaStateMachine::IdleState::HandleStartInIdleState(InternalMessagePtr msg)
|
||||
{
|
||||
mid = msg->GetParam2();
|
||||
ErrCode ret = WifiServiceScheduler::GetInstance().AutoStartWifi2Service(mid, pMultiStaStateMachine->ifaceName);
|
||||
if (ret != WIFI_OPT_SUCCESS) {
|
||||
WIFI_LOGE("IdelState start wifi2 fail.\n");
|
||||
pMultiStaStateMachine->mcb.onStartFailure(mid);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
MultiStaStateMachine::StartedState::StartedState(MultiStaStateMachine *multiStaStateMachine)
|
||||
: State("StartedState"), pMultiStaStateMachine(multiStaStateMachine)
|
||||
{}
|
||||
|
||||
MultiStaStateMachine::StartedState::~StartedState()
|
||||
{}
|
||||
|
||||
void MultiStaStateMachine::StartedState::GoInState()
|
||||
{
|
||||
WIFI_LOGE("StartedState GoInState function.\n");
|
||||
}
|
||||
|
||||
void MultiStaStateMachine::StartedState::GoOutState()
|
||||
{
|
||||
WIFI_LOGE("StartedState GoOutState function.\n");
|
||||
}
|
||||
|
||||
bool MultiStaStateMachine::StartedState::ExecuteStateMsg(InternalMessagePtr msg)
|
||||
{
|
||||
if (msg == nullptr) {
|
||||
return false;
|
||||
}
|
||||
WIFI_LOGE("StartedState-msgCode=%{public}d is received.\n", msg->GetMessageName());
|
||||
ErrCode ret = WIFI_OPT_FAILED;
|
||||
switch (msg->GetMessageName()) {
|
||||
case MULTI_STA_CMD_STOP:
|
||||
ret = WifiServiceScheduler::GetInstance().AutoStopWifi2Service(mid);
|
||||
if (ret != WIFI_OPT_SUCCESS) {
|
||||
WIFI_LOGE("AutoStopWifi2Service fail.\n");
|
||||
}
|
||||
pMultiStaStateMachine->mcb.onStopped(mid);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace Wifi
|
||||
} // namespace OHOS
|
@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright (C) 2021-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef MULTI_STA_STATE_MACHINE_H
|
||||
#define MULTI_STA_STATE_MACHINE_H
|
||||
|
||||
#include "state.h"
|
||||
#include "state_machine.h"
|
||||
#include "wifi_logger.h"
|
||||
#include "wifi_errcode.h"
|
||||
#include <string>
|
||||
#include "wifi_ap_msg.h"
|
||||
#include "wifi_internal_msg.h"
|
||||
#include "wifi_controller_define.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Wifi {
|
||||
class MultiStaStateMachine : public StateMachine {
|
||||
public:
|
||||
MultiStaStateMachine();
|
||||
~MultiStaStateMachine();
|
||||
|
||||
class IdleState : public State {
|
||||
public:
|
||||
explicit IdleState(MultiStaStateMachine *multiStaStateMachine);
|
||||
~IdleState() override;
|
||||
void GoInState() override;
|
||||
void GoOutState() override;
|
||||
bool ExecuteStateMsg(InternalMessagePtr msg) override;
|
||||
|
||||
private:
|
||||
MultiStaStateMachine *pMultiStaStateMachine;
|
||||
void HandleStartInIdleState(InternalMessagePtr msg);
|
||||
};
|
||||
|
||||
class DefaultState : public State {
|
||||
public:
|
||||
explicit DefaultState(MultiStaStateMachine *multiStaStateMachine);
|
||||
~DefaultState() override;
|
||||
void GoInState() override;
|
||||
void GoOutState() override;
|
||||
bool ExecuteStateMsg(InternalMessagePtr msg) override;
|
||||
|
||||
private:
|
||||
MultiStaStateMachine *pMultiStaStateMachine;
|
||||
};
|
||||
|
||||
class StartedState : public State {
|
||||
public:
|
||||
explicit StartedState(MultiStaStateMachine *multiStaStateMachine);
|
||||
~StartedState() override;
|
||||
void GoInState() override;
|
||||
void GoOutState() override;
|
||||
bool ExecuteStateMsg(InternalMessagePtr msg) override;
|
||||
|
||||
private:
|
||||
MultiStaStateMachine *pMultiStaStateMachine;
|
||||
};
|
||||
|
||||
public:
|
||||
ErrCode InitMultiStaStateMachine();
|
||||
ErrCode RegisterCallback(const MultiStaModeCallback &callbacks);
|
||||
|
||||
private:
|
||||
template <typename T>
|
||||
inline void ParsePointer(T *&pointer)
|
||||
{
|
||||
if (pointer != nullptr) {
|
||||
delete pointer;
|
||||
pointer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline ErrCode JudgmentEmpty(T *&pointer)
|
||||
{
|
||||
if (pointer == nullptr) {
|
||||
return WIFI_OPT_FAILED;
|
||||
}
|
||||
return WIFI_OPT_SUCCESS;
|
||||
}
|
||||
|
||||
void BuildStateTree();
|
||||
ErrCode InitMultiStaStates();
|
||||
DefaultState *pDefaultState;
|
||||
IdleState *pIdleState;
|
||||
StartedState *pStartedState;
|
||||
MultiStaModeCallback mcb;
|
||||
static int mid;
|
||||
std::string ifaceName{""};
|
||||
};
|
||||
} // namespace Wifi
|
||||
} // namespace OHOS
|
||||
#endif
|
@ -53,6 +53,12 @@ namespace Wifi {
|
||||
#define SOFTAP_CMD_START 0x201
|
||||
#define SOFTAP_CMD_STOP 0x202
|
||||
|
||||
#define MULTI_STA_CMD_START 0x301
|
||||
#define MULTI_STA_CMD_STOP 0x302
|
||||
#define MULTI_STA_CMD_STARTED 0x303
|
||||
#define MULTI_STA_CMD_STOPPED 0x304
|
||||
#define CMD_MULTI_STA_STOPPED 0x305
|
||||
|
||||
#define STOP_WIFI_WAIT_TIME 100
|
||||
|
||||
struct ConcreteModeCallback {
|
||||
@ -66,6 +72,11 @@ struct SoftApModeCallback {
|
||||
std::function<void(int)> onStartFailure;
|
||||
};
|
||||
|
||||
struct MultiStaModeCallback {
|
||||
std::function<void(int)> onStopped;
|
||||
std::function<void(int)> onStartFailure;
|
||||
};
|
||||
|
||||
enum class ConcreteManagerRole {
|
||||
ROLE_UNKNOW = -1,
|
||||
ROLE_CLIENT_SCAN_ONLY = 0,
|
||||
|
@ -131,14 +131,23 @@ bool WifiControllerMachine::DisableState::ExecuteStateMsg(InternalMessagePtr msg
|
||||
#endif
|
||||
case CMD_WIFI_TOGGLED:
|
||||
case CMD_SCAN_ALWAYS_MODE_CHANGED:
|
||||
if (pWifiControllerMachine->ShouldEnableWifi()) {
|
||||
ConcreteManagerRole role = pWifiControllerMachine->GetWifiRole();
|
||||
if (role == ConcreteManagerRole::ROLE_UNKNOW) {
|
||||
if (!pWifiControllerMachine->ShouldEnableWifi(msg->GetParam2())) {
|
||||
WIFI_LOGW("keep disable, shouldn't enabled wifi.");
|
||||
break;
|
||||
}
|
||||
if (msg->GetParam2() == INSTID_WLAN1) {
|
||||
pWifiControllerMachine->MakeMultiStaManager(MultiStaManager::Role::ROLE_STA_WIFI_2, msg->GetParam2());
|
||||
pWifiControllerMachine->SwitchState(pWifiControllerMachine->pEnableState);
|
||||
} else if (msg->GetParam2() == INSTID_WLAN0) {
|
||||
ConcreteManagerRole roleStaWifi1 = pWifiControllerMachine->GetWifiRole();
|
||||
if (roleStaWifi1 == ConcreteManagerRole::ROLE_UNKNOW) {
|
||||
WIFI_LOGE("Get unknow wifi role, break");
|
||||
break;
|
||||
}
|
||||
pWifiControllerMachine->MakeConcreteManager(role, msg->GetParam2());
|
||||
pWifiControllerMachine->MakeConcreteManager(roleStaWifi1, msg->GetParam2());
|
||||
pWifiControllerMachine->SwitchState(pWifiControllerMachine->pEnableState);
|
||||
} else {
|
||||
WIFI_LOGE("DisableState, invalid instance id");
|
||||
}
|
||||
break;
|
||||
case CMD_AIRPLANE_TOGGLED:
|
||||
@ -206,10 +215,14 @@ bool WifiControllerMachine::EnableState::ExecuteStateMsg(InternalMessagePtr msg)
|
||||
break;
|
||||
#endif
|
||||
case CMD_STA_START_FAILURE:
|
||||
HandleStaStartFailure(msg->GetParam1());
|
||||
msg->GetParam1() == INSTID_WLAN0 ?
|
||||
HandleStaStartFailure(INSTID_WLAN0) : pWifiControllerMachine->RemoveMultiStaManager(INSTID_WLAN1);
|
||||
break;
|
||||
case CMD_CONCRETE_STOPPED:
|
||||
pWifiControllerMachine->HandleConcreteStop(msg->GetParam1());
|
||||
pWifiControllerMachine->HandleConcreteStop(INSTID_WLAN0);
|
||||
break;
|
||||
case CMD_MULTI_STA_STOPPED:
|
||||
pWifiControllerMachine->RemoveMultiStaManager(INSTID_WLAN1);
|
||||
break;
|
||||
case CMD_AIRPLANE_TOGGLED:
|
||||
if (msg->GetParam1()) {
|
||||
@ -222,7 +235,7 @@ bool WifiControllerMachine::EnableState::ExecuteStateMsg(InternalMessagePtr msg)
|
||||
pWifiControllerMachine->SendMessage(CMD_WIFI_TOGGLED, 1, 0);
|
||||
break;
|
||||
case CMD_STA_REMOVED:
|
||||
HandleStaRemoved(msg);
|
||||
INSTID_WLAN0 == msg->GetParam2() ? HandleStaRemoved(msg) : HandleWifi2Removed(msg);
|
||||
break;
|
||||
case CMD_CONCRETECLIENT_REMOVED:
|
||||
HandleConcreteClientRemoved(msg);
|
||||
@ -283,7 +296,7 @@ void WifiControllerMachine::HandleAirplaneClose()
|
||||
#ifndef OHOS_ARCH_LITE
|
||||
WifiManager::GetInstance().GetWifiEventSubscriberManager()->GetWifiAllowSemiActiveByDatashare();
|
||||
#endif
|
||||
if (!ShouldEnableWifi() || WifiConfigCenter::GetInstance().GetWifiStopState()) {
|
||||
if (!ShouldEnableWifi(INSTID_WLAN0) || WifiConfigCenter::GetInstance().GetWifiStopState()) {
|
||||
return;
|
||||
}
|
||||
#ifdef FEATURE_AP_SUPPORT
|
||||
@ -348,6 +361,22 @@ bool WifiControllerMachine::ConcreteIdExist(int id)
|
||||
std::unique_lock<std::mutex> lock(concreteManagerMutex);
|
||||
for (auto iter = concreteManagers.begin(); iter != concreteManagers.end(); ++iter) {
|
||||
if ((*iter)->mid == id) {
|
||||
WIFI_LOGI("concreteManagers is match");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool WifiControllerMachine::IsWifi2IdExist(int id)
|
||||
{
|
||||
if (!HasAnyMultiStaManager()) {
|
||||
return false;
|
||||
}
|
||||
std::unique_lock<std::mutex> lock(multiStaManagerMutex);
|
||||
for (auto iter = multiStaManagers.begin(); iter != multiStaManagers.end(); ++iter) {
|
||||
if ((*iter)->mid == id) {
|
||||
WIFI_LOGI("multiStaManagers is match");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -358,6 +387,17 @@ bool WifiControllerMachine::HasAnyConcreteManager()
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(concreteManagerMutex);
|
||||
if (concreteManagers.empty()) {
|
||||
WIFI_LOGE("Enter HasAnyConcreteManager is empty");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WifiControllerMachine::HasAnyMultiStaManager()
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(multiStaManagerMutex);
|
||||
if (multiStaManagers.empty()) {
|
||||
WIFI_LOGE("Enter HasAnyMultiStaManager is empty");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -398,6 +438,20 @@ void WifiControllerMachine::MakeConcreteManager(ConcreteManagerRole role, int id
|
||||
concreteManagers.push_back(clientmode);
|
||||
}
|
||||
|
||||
void WifiControllerMachine::MakeMultiStaManager(MultiStaManager::Role role, int instId)
|
||||
{
|
||||
WIFI_LOGI("Enter MakeMultiStaManager");
|
||||
MultiStaManager *multiStaMode = new (std::nothrow) MultiStaManager(role, instId);
|
||||
if (multiStaMode == nullptr) {
|
||||
WIFI_LOGE("new multiStaMode failed");
|
||||
return;
|
||||
}
|
||||
multiStaMode->RegisterCallback(WifiManager::GetInstance().GetWifiTogglerManager()->GetMultiStaCallback());
|
||||
multiStaMode->InitMultiStaManager();
|
||||
std::unique_lock<std::mutex> lock(multiStaManagerMutex);
|
||||
multiStaManagers.push_back(multiStaMode);
|
||||
}
|
||||
|
||||
#ifdef FEATURE_AP_SUPPORT
|
||||
void WifiControllerMachine::MakeSoftapManager(SoftApManager::Role role, int id)
|
||||
{
|
||||
@ -426,18 +480,21 @@ bool WifiControllerMachine::ShouldDisableWifi(InternalMessagePtr msg)
|
||||
WIFI_LOGI("Should disable wifi");
|
||||
return true;
|
||||
}
|
||||
return !ShouldEnableWifi();
|
||||
return !ShouldEnableWifi(msg->GetParam2());
|
||||
}
|
||||
|
||||
bool WifiControllerMachine::ShouldEnableWifi()
|
||||
bool WifiControllerMachine::ShouldEnableWifi(int id)
|
||||
{
|
||||
WIFI_LOGI("Enter ShouldEnableWifi");
|
||||
if (id == INSTID_WLAN1) {
|
||||
return WifiConfigCenter::GetInstance().GetWifiToggledEnable(INSTID_WLAN0) == WIFI_STATE_ENABLED;
|
||||
}
|
||||
#ifndef OHOS_ARCH_LITE
|
||||
if (WifiManager::GetInstance().GetWifiEventSubscriberManager()->IsMdmForbidden()) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
if (WifiConfigCenter::GetInstance().GetWifiToggledEnable() != WIFI_STATE_DISABLED || IsScanOnlyEnable()) {
|
||||
if (WifiConfigCenter::GetInstance().GetWifiToggledEnable(id) != WIFI_STATE_DISABLED || IsScanOnlyEnable()) {
|
||||
WIFI_LOGI("Should start wifi or scanonly.");
|
||||
return true;
|
||||
}
|
||||
@ -461,9 +518,9 @@ ConcreteManagerRole WifiControllerMachine::GetWifiRole()
|
||||
}
|
||||
}
|
||||
|
||||
bool WifiControllerMachine::IsWifiEnable()
|
||||
bool WifiControllerMachine::IsWifiEnable(int id)
|
||||
{
|
||||
return WifiConfigCenter::GetInstance().GetWifiToggledEnable() == WIFI_STATE_ENABLED;
|
||||
return WifiConfigCenter::GetInstance().GetWifiToggledEnable(id) == WIFI_STATE_ENABLED;
|
||||
}
|
||||
|
||||
bool WifiControllerMachine::IsSemiWifiEnable()
|
||||
@ -498,6 +555,7 @@ void WifiControllerMachine::StopAllConcreteManagers()
|
||||
}
|
||||
std::unique_lock<std::mutex> lock(concreteManagerMutex);
|
||||
for (auto iter = concreteManagers.begin(); iter != concreteManagers.end(); ++iter) {
|
||||
WIFI_LOGD("Enter StopAllConcreteManagers. mid = %{public}d", (*iter)->mid);
|
||||
(*iter)->GetConcreteMachine()->SendMessage(CONCRETE_CMD_STOP);
|
||||
}
|
||||
}
|
||||
@ -533,6 +591,21 @@ void WifiControllerMachine::StopSoftapManager(int id)
|
||||
}
|
||||
}
|
||||
|
||||
void WifiControllerMachine::StopMultiStaManager(int id)
|
||||
{
|
||||
WIFI_LOGI("Enter StopMultiStaManager, id = %{public}d", id);
|
||||
if (!HasAnyMultiStaManager()) {
|
||||
return;
|
||||
}
|
||||
std::unique_lock<std::mutex> lock(multiStaManagerMutex);
|
||||
for (auto iter = multiStaManagers.begin(); iter != multiStaManagers.end(); ++iter) {
|
||||
if ((*iter)->mid == id) {
|
||||
(*iter)->GetMultiStaMachine()->SendMessage(MULTI_STA_CMD_STOP);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WifiControllerMachine::StopAllSoftapManagers()
|
||||
{
|
||||
if (!HasAnySoftApManager()) {
|
||||
@ -568,6 +641,29 @@ void WifiControllerMachine::RemoveConcreteManager(int id)
|
||||
}
|
||||
}
|
||||
|
||||
void WifiControllerMachine::RemoveMultiStaManager(int id)
|
||||
{
|
||||
MultiStaManager *multiStaMgr = nullptr;
|
||||
|
||||
if (!HasAnyMultiStaManager()) {
|
||||
return;
|
||||
}
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(multiStaManagerMutex);
|
||||
for (auto iter = multiStaManagers.begin(); iter != multiStaManagers.end(); ++iter) {
|
||||
if ((*iter)->mid == id) {
|
||||
multiStaMgr = *iter;
|
||||
multiStaManagers.erase(iter);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (multiStaMgr != nullptr) {
|
||||
delete multiStaMgr;
|
||||
multiStaMgr = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef FEATURE_AP_SUPPORT
|
||||
void WifiControllerMachine::RmoveSoftapManager(int id)
|
||||
{
|
||||
@ -604,6 +700,20 @@ void WifiControllerMachine::HandleStaClose(int id)
|
||||
}
|
||||
}
|
||||
|
||||
void WifiControllerMachine::HandleWifi2Close(int id)
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(multiStaManagerMutex);
|
||||
if (multiStaManagers.empty()) {
|
||||
return;
|
||||
}
|
||||
for (auto iter = multiStaManagers.begin(); iter != multiStaManagers.end(); ++iter) {
|
||||
if ((*iter)->mid == id) {
|
||||
(*iter)->GetMultiStaMachine()->SendMessage(MULTI_STA_CMD_STOPPED);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WifiControllerMachine::SwitchRole(ConcreteManagerRole role)
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(concreteManagerMutex);
|
||||
@ -614,8 +724,20 @@ void WifiControllerMachine::SwitchRole(ConcreteManagerRole role)
|
||||
|
||||
void WifiControllerMachine::EnableState::HandleWifiToggleChangeInEnabledState(InternalMessagePtr msg)
|
||||
{
|
||||
if (msg->GetParam2() == INSTID_WLAN1 && msg->GetParam1() == 0) {
|
||||
WIFI_LOGI("Toggle disable wlan1.");
|
||||
pWifiControllerMachine->StopMultiStaManager(INSTID_WLAN1);
|
||||
return;
|
||||
}
|
||||
if (msg->GetParam2() == INSTID_WLAN1 && WifiConfigCenter::GetInstance().GetPersistWifiState(INSTID_WLAN0)
|
||||
== WIFI_STATE_ENABLED && msg->GetParam1() == 1) {
|
||||
pWifiControllerMachine->MakeMultiStaManager(MultiStaManager::Role::ROLE_STA_WIFI_2, msg->GetParam2());
|
||||
return;
|
||||
}
|
||||
|
||||
ConcreteManagerRole presentRole;
|
||||
if (pWifiControllerMachine->ShouldDisableWifi(msg)) {
|
||||
pWifiControllerMachine->StopMultiStaManager(INSTID_WLAN1);
|
||||
pWifiControllerMachine->StopAllConcreteManagers();
|
||||
return;
|
||||
}
|
||||
@ -628,6 +750,9 @@ void WifiControllerMachine::EnableState::HandleWifiToggleChangeInEnabledState(In
|
||||
WIFI_LOGE("Get unknow wifi role in enablestate.");
|
||||
return;
|
||||
}
|
||||
if (presentRole != ConcreteManagerRole::ROLE_CLIENT_STA) {
|
||||
pWifiControllerMachine->StopMultiStaManager(INSTID_WLAN1);
|
||||
}
|
||||
pWifiControllerMachine->SwitchRole(presentRole);
|
||||
return;
|
||||
}
|
||||
@ -671,7 +796,8 @@ void WifiControllerMachine::EnableState::HandleSoftapToggleChangeInEnabledState(
|
||||
}
|
||||
#ifndef HDI_CHIP_INTERFACE_SUPPORT
|
||||
if (!WifiConfigCenter::GetInstance().GetCoexSupport() &&
|
||||
pWifiControllerMachine->ShouldEnableWifi() && !WifiConfigCenter::GetInstance().GetWifiStopState() &&
|
||||
pWifiControllerMachine->ShouldEnableWifi(INSTID_WLAN0) &&
|
||||
!WifiConfigCenter::GetInstance().GetWifiStopState() &&
|
||||
pWifiControllerMachine->HasAnyConcreteManager()) {
|
||||
ConcreteManagerRole role = pWifiControllerMachine->GetWifiRole();
|
||||
if (role != ConcreteManagerRole::ROLE_UNKNOW) {
|
||||
@ -697,7 +823,7 @@ void WifiControllerMachine::EnableState::HandleStaStartFailure(int id)
|
||||
WIFI_LOGE("HandleStaStartFailure");
|
||||
pWifiControllerMachine->RemoveConcreteManager(id);
|
||||
mWifiStartFailCount++;
|
||||
if (pWifiControllerMachine->ShouldEnableWifi() && mWifiStartFailCount < WIFI_OPEN_RETRY_MAX_COUNT) {
|
||||
if (pWifiControllerMachine->ShouldEnableWifi(id) && mWifiStartFailCount < WIFI_OPEN_RETRY_MAX_COUNT) {
|
||||
pWifiControllerMachine->StartTimer(CMD_OPEN_WIFI_RETRY, WIFI_OPEN_RETRY_TIMEOUT);
|
||||
}
|
||||
}
|
||||
@ -716,6 +842,11 @@ void WifiControllerMachine::EnableState::HandleStaRemoved(InternalMessagePtr msg
|
||||
pWifiControllerMachine->StopConcreteManager(msg->GetParam2());
|
||||
}
|
||||
|
||||
void WifiControllerMachine::EnableState::HandleWifi2Removed(InternalMessagePtr msg)
|
||||
{
|
||||
pWifiControllerMachine->StopMultiStaManager(msg->GetParam2());
|
||||
}
|
||||
|
||||
void WifiControllerMachine::EnableState::HandleConcreteClientRemoved(InternalMessagePtr msg)
|
||||
{
|
||||
int id = msg->GetParam1();
|
||||
@ -747,6 +878,14 @@ void WifiControllerMachine::HandleStaStart(int id)
|
||||
}
|
||||
}
|
||||
|
||||
void WifiControllerMachine::HandleWifi2Start(int id)
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(multiStaManagerMutex);
|
||||
for (auto iter = multiStaManagers.begin(); iter != multiStaManagers.end(); ++iter) {
|
||||
(*iter)->GetMultiStaMachine()->SendMessage(MULTI_STA_CMD_STARTED);
|
||||
}
|
||||
}
|
||||
|
||||
void WifiControllerMachine::HandleStaSemiActive(int id)
|
||||
{
|
||||
mWifiStartFailCount = 0;
|
||||
@ -786,6 +925,7 @@ void WifiControllerMachine::EnableState::HandleApStop(InternalMessagePtr msg)
|
||||
|
||||
void WifiControllerMachine::HandleConcreteStop(int id)
|
||||
{
|
||||
WIFI_LOGD("WifiControllerMachine HandleConcreteStop id = %{public}d", id);
|
||||
RemoveConcreteManager(id);
|
||||
#ifndef HDI_CHIP_INTERFACE_SUPPORT
|
||||
if (!WifiConfigCenter::GetInstance().GetCoexSupport()) {
|
||||
@ -798,7 +938,7 @@ void WifiControllerMachine::HandleConcreteStop(int id)
|
||||
}
|
||||
#endif
|
||||
if (!WifiManager::GetInstance().GetWifiTogglerManager()->HasAnyApRuning()) {
|
||||
if (ShouldEnableWifi()) {
|
||||
if (ShouldEnableWifi(id)) {
|
||||
ConcreteManagerRole presentRole = GetWifiRole();
|
||||
MakeConcreteManager(presentRole, 0);
|
||||
return;
|
||||
@ -806,7 +946,7 @@ void WifiControllerMachine::HandleConcreteStop(int id)
|
||||
}
|
||||
} else {
|
||||
#endif
|
||||
if (ShouldEnableWifi()) {
|
||||
if (ShouldEnableWifi(id)) {
|
||||
ConcreteManagerRole presentRole = GetWifiRole();
|
||||
MakeConcreteManager(presentRole, 0);
|
||||
return;
|
||||
@ -840,7 +980,7 @@ void WifiControllerMachine::HandleSoftapStop(int id)
|
||||
if (HasAnyManager()) {
|
||||
return;
|
||||
}
|
||||
if (ShouldEnableWifi() && !WifiConfigCenter::GetInstance().GetWifiStopState()) {
|
||||
if (ShouldEnableWifi(INSTID_WLAN0) && !WifiConfigCenter::GetInstance().GetWifiStopState()) {
|
||||
role = GetWifiRole();
|
||||
if (role == ConcreteManagerRole::ROLE_UNKNOW) {
|
||||
WIFI_LOGE("Get unknow wifi role in HandleSoftapStop.");
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "wifi_logger.h"
|
||||
#include "wifi_errcode.h"
|
||||
#include "concrete_clientmode_manager.h"
|
||||
#include "multi_sta_manager.h"
|
||||
#ifdef FEATURE_AP_SUPPORT
|
||||
#include "softap_manager.h"
|
||||
#endif
|
||||
@ -55,6 +56,7 @@ public:
|
||||
bool ExecuteStateMsg(InternalMessagePtr msg) override;
|
||||
void HandleStaStartFailure(int id);
|
||||
void HandleStaRemoved(InternalMessagePtr msg);
|
||||
void HandleWifi2Removed(InternalMessagePtr msg);
|
||||
void HandleAPServiceStartFail(int id);
|
||||
void HandleConcreteClientRemoved(InternalMessagePtr msg);
|
||||
|
||||
@ -85,8 +87,11 @@ public:
|
||||
ErrCode InitWifiControllerMachine();
|
||||
|
||||
void RemoveConcreteManager(int id);
|
||||
void RemoveMultiStaManager(int id);
|
||||
void HandleStaClose(int id);
|
||||
void HandleWifi2Close(int id);
|
||||
void HandleStaStart(int id);
|
||||
void HandleWifi2Start(int id);
|
||||
void HandleStaSemiActive(int id);
|
||||
void HandleConcreteStop(int id);
|
||||
void ClearWifiStartFailCount();
|
||||
@ -120,9 +125,12 @@ private:
|
||||
void BuildStateTree();
|
||||
ErrCode InitWifiStates();
|
||||
bool HasAnyConcreteManager();
|
||||
bool HasAnyMultiStaManager();
|
||||
bool HasAnyManager();
|
||||
bool ConcreteIdExist(int id);
|
||||
bool IsWifi2IdExist(int id);
|
||||
void MakeConcreteManager(ConcreteManagerRole role, int id);
|
||||
void MakeMultiStaManager(MultiStaManager::Role role, int instId);
|
||||
#ifdef FEATURE_AP_SUPPORT
|
||||
bool HasAnySoftApManager();
|
||||
bool SoftApIdExist(int id);
|
||||
@ -133,14 +141,15 @@ private:
|
||||
SoftApManager *GetSoftApManager(int id);
|
||||
#endif
|
||||
bool ShouldDisableWifi(InternalMessagePtr msg);
|
||||
bool ShouldEnableWifi();
|
||||
bool ShouldEnableWifi(int id = 0);
|
||||
ConcreteManagerRole GetWifiRole();
|
||||
void StopAllConcreteManagers();
|
||||
void StopConcreteManager(int id);
|
||||
void StopMultiStaManager(int id);
|
||||
void SwitchRole(ConcreteManagerRole role);
|
||||
void HandleAirplaneOpen();
|
||||
void HandleAirplaneClose();
|
||||
static bool IsWifiEnable();
|
||||
static bool IsWifiEnable(int id = 0);
|
||||
static bool IsSemiWifiEnable();
|
||||
static bool IsScanOnlyEnable();
|
||||
|
||||
@ -158,6 +167,8 @@ private:
|
||||
mutable std::mutex softapManagerMutex;
|
||||
uint64_t stopSoftapTimerId_ {0};
|
||||
#endif
|
||||
mutable std::mutex multiStaManagerMutex;
|
||||
std::vector<MultiStaManager *> multiStaManagers;
|
||||
};
|
||||
} // namespace Wifi
|
||||
} // namespace OHOS
|
||||
|
@ -97,15 +97,21 @@ ErrCode WifiServiceScheduler::AutoStartStaService(int instId, std::string &staIf
|
||||
return WIFI_OPT_FAILED;
|
||||
}
|
||||
DispatchWifiOpenRes(OperateResState::OPEN_WIFI_OPENING, instId);
|
||||
int ret = WifiStaHalInterface::GetInstance().StartWifi(WifiConfigCenter::GetInstance().GetStaIfaceName());
|
||||
WIFI_LOGI("AutoStartStaService startwifi iface:%{public}s instId:%{public}d",
|
||||
WifiConfigCenter::GetInstance().GetStaIfaceName(instId).c_str(), instId);
|
||||
int ret = WifiStaHalInterface::GetInstance().StartWifi(WifiConfigCenter::GetInstance().GetStaIfaceName(instId),
|
||||
instId);
|
||||
if (ret != WIFI_OPT_SUCCESS) {
|
||||
WIFI_LOGE("AutoStartStaService start wifi fail.");
|
||||
WifiOprMidState staState = WifiConfigCenter::GetInstance().GetWifiMidState(instId);
|
||||
WriteWifiOpenAndCloseFailedHiSysEvent(static_cast<int>(OperateResState::OPEN_WIFI_FAILED), "TIME_OUT",
|
||||
static_cast<int>(staState));
|
||||
return WIFI_OPT_FAILED;
|
||||
} else {
|
||||
WIFI_LOGE("AutoStartStaService start wifi instId:%{public}d success.", instId);
|
||||
}
|
||||
if (PostStartWifi(instId) != WIFI_OPT_SUCCESS) {
|
||||
WIFI_LOGE("AutoStartStaService PostStartWifi instId:%{public}d", instId);
|
||||
return WIFI_OPT_FAILED;
|
||||
}
|
||||
WifiManager::GetInstance().PushServiceCloseMsg(WifiCloseServiceCode::STA_MSG_OPENED, instId);
|
||||
@ -115,6 +121,34 @@ ErrCode WifiServiceScheduler::AutoStartStaService(int instId, std::string &staIf
|
||||
return WIFI_OPT_SUCCESS;
|
||||
}
|
||||
|
||||
ErrCode WifiServiceScheduler::AutoStartWifi2Service(int instId, std::string &staIfName)
|
||||
{
|
||||
WifiOprMidState staState = WifiConfigCenter::GetInstance().GetWifiMidState(instId);
|
||||
WIFI_LOGI("AutoStartWifi2Service, current sta state:%{public}d", staState);
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
if (staState == WifiOprMidState::RUNNING) {
|
||||
return WIFI_OPT_SUCCESS;
|
||||
}
|
||||
if (PreStartWifi(instId, staIfName) != WIFI_OPT_SUCCESS) {
|
||||
return WIFI_OPT_FAILED;
|
||||
}
|
||||
DispatchWifi2OpenRes(OperateResState::OPEN_WIFI_OPENING, instId);
|
||||
int ret = WifiStaHalInterface::GetInstance().StartWifi(WifiConfigCenter::GetInstance().GetStaIfaceName(instId),
|
||||
instId);
|
||||
if (ret != WIFI_OPT_SUCCESS) {
|
||||
WIFI_LOGE("AutoStartWifi2Service start wifi fail.");
|
||||
return WIFI_OPT_FAILED;
|
||||
}
|
||||
if (PostStartWifi2(instId) != WIFI_OPT_SUCCESS) {
|
||||
WIFI_LOGE("AutoStartWifi2Service PostStartWifi instId %{public}d", instId);
|
||||
return WIFI_OPT_FAILED;
|
||||
}
|
||||
DispatchWifi2OpenRes(OperateResState::OPEN_WIFI_SUCCEED, instId);
|
||||
auto &ins = WifiManager::GetInstance().GetWifiTogglerManager()->GetControllerMachine();
|
||||
ins->HandleWifi2Start(instId);
|
||||
return WIFI_OPT_SUCCESS;
|
||||
}
|
||||
|
||||
ErrCode WifiServiceScheduler::AutoStopStaService(int instId)
|
||||
{
|
||||
WifiOprMidState staStateBefore = WifiConfigCenter::GetInstance().GetWifiMidState(instId);
|
||||
@ -151,7 +185,7 @@ ErrCode WifiServiceScheduler::AutoStopStaService(int instId)
|
||||
if (ret != WIFI_OPT_SUCCESS) {
|
||||
WIFI_LOGE("service disable sta failed, ret %{public}d!", static_cast<int>(ret));
|
||||
}
|
||||
if (WifiStaHalInterface::GetInstance().StopWifi() != WIFI_HAL_OPT_OK) {
|
||||
if (WifiStaHalInterface::GetInstance().StopWifi(instId) != WIFI_HAL_OPT_OK) {
|
||||
WIFI_LOGE("stop wifi failed.");
|
||||
WifiOprMidState staState = WifiConfigCenter::GetInstance().GetWifiMidState(instId);
|
||||
if (!WifiConfigCenter::GetInstance().SetWifiMidState(staState, staStateBefore, instId)) {
|
||||
@ -169,12 +203,57 @@ ErrCode WifiServiceScheduler::AutoStopStaService(int instId)
|
||||
return WIFI_OPT_SUCCESS;
|
||||
}
|
||||
|
||||
ErrCode WifiServiceScheduler::AutoStopWifi2Service(int instId)
|
||||
{
|
||||
WifiOprMidState staStateBefore = WifiConfigCenter::GetInstance().GetWifiMidState(instId);
|
||||
WIFI_LOGI("AutoStopWifi2Service, current sta state:%{public}d, instId:%{public}d",
|
||||
staStateBefore, instId);
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
if (staStateBefore == WifiOprMidState::CLOSED) {
|
||||
return WIFI_OPT_SUCCESS;
|
||||
}
|
||||
ErrCode ret = WIFI_OPT_FAILED;
|
||||
|
||||
if (!WifiConfigCenter::GetInstance().SetWifiMidState(staStateBefore, WifiOprMidState::CLOSING, instId)) {
|
||||
WIFI_LOGE("AutoStopWifi2Service,set wifi mid state closing failed!");
|
||||
return WIFI_OPT_FAILED;
|
||||
}
|
||||
|
||||
IStaService *pService = WifiServiceManager::GetInstance().GetStaServiceInst(instId);
|
||||
if (pService == nullptr) {
|
||||
WIFI_LOGE("AutoStopWifi2Service, Instance get sta service is null!");
|
||||
WifiConfigCenter::GetInstance().SetWifiMidState(WifiOprMidState::CLOSED, instId);
|
||||
WifiServiceManager::GetInstance().UnloadService(WIFI_SERVICE_STA, instId);
|
||||
return WIFI_OPT_SUCCESS;
|
||||
}
|
||||
DispatchWifi2CloseRes(OperateResState::CLOSE_WIFI_CLOSING, instId);
|
||||
ret = pService->DisableStaService();
|
||||
if (ret != WIFI_OPT_SUCCESS) {
|
||||
WIFI_LOGE("AutoStopWifi2Service service disable sta failed, ret %{public}d!", static_cast<int>(ret));
|
||||
}
|
||||
if (WifiStaHalInterface::GetInstance().StopWifi(instId) != WIFI_HAL_OPT_OK) {
|
||||
WIFI_LOGE("AutoStopWifi2Service stop wifi failed.");
|
||||
WifiOprMidState staState = WifiConfigCenter::GetInstance().GetWifiMidState(instId);
|
||||
if (!WifiConfigCenter::GetInstance().SetWifiMidState(staState, staStateBefore, instId)) {
|
||||
WIFI_LOGE("AutoStopWifi2Service, set wifi mid state:%{public}d failed!", staStateBefore);
|
||||
return WIFI_OPT_FAILED;
|
||||
}
|
||||
}
|
||||
WifiManager::GetInstance().PushServiceCloseMsg(WifiCloseServiceCode::STA_MSG_STOPED, instId);
|
||||
DispatchWifi2CloseRes(OperateResState::CLOSE_WIFI_SUCCEED, instId);
|
||||
auto &ins = WifiManager::GetInstance().GetWifiTogglerManager()->GetControllerMachine();
|
||||
ins->HandleWifi2Close(instId);
|
||||
WIFI_LOGE("AutoStopWifi2Service %{public}d success!", instId);
|
||||
return WIFI_OPT_SUCCESS;
|
||||
}
|
||||
|
||||
ErrCode WifiServiceScheduler::AutoStartScanOnly(int instId, std::string &staIfName)
|
||||
{
|
||||
WifiOprMidState curState = WifiConfigCenter::GetInstance().GetWifiScanOnlyMidState(instId);
|
||||
WIFI_LOGI("AutoStartScanOnly, Wifi scan only state is %{public}d", static_cast<int>(curState));
|
||||
WIFI_LOGI("AutoStartScanOnly, Wifi scan only state is %{public}d, instId = %{public}d",
|
||||
static_cast<int>(curState), instId);
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
if (curState != WifiOprMidState::CLOSED) {
|
||||
if (curState != WifiOprMidState::CLOSED && instId == 0) {
|
||||
WIFI_LOGE("ScanOnly State is not closed, return\n");
|
||||
return WIFI_OPT_SUCCESS;
|
||||
}
|
||||
@ -192,16 +271,19 @@ ErrCode WifiServiceScheduler::AutoStartScanOnly(int instId, std::string &staIfNa
|
||||
if (ifaceName.empty() && !DelayedSingleton<HalDeviceManager>::GetInstance()->CreateStaIface(
|
||||
std::bind(&WifiServiceScheduler::StaIfaceDestoryCallback, this, std::placeholders::_1, std::placeholders::_2),
|
||||
std::bind(&WifiServiceScheduler::OnRssiReportCallback, this, std::placeholders::_1, std::placeholders::_2),
|
||||
ifaceName)) {
|
||||
ifaceName, instId)) {
|
||||
WIFI_LOGE("AutoStartScanOnly, create iface failed!");
|
||||
return WIFI_OPT_FAILED;
|
||||
}
|
||||
WIFI_LOGI("AutoStartScanOnly SetStaIfaceName:%{public}s, instId:%{public}d", ifaceName.c_str(), instId);
|
||||
WifiConfigCenter::GetInstance().SetStaIfaceName(ifaceName);
|
||||
staIfName = ifaceName;
|
||||
g_staIfaceNameMap.insert(std::make_pair(instId, ifaceName));
|
||||
#endif
|
||||
WifiConfigCenter::GetInstance().SetWifiScanOnlyMidState(WifiOprMidState::OPENING, instId);
|
||||
WifiManager::GetInstance().AutoStartEnhanceService();
|
||||
if (instId == INSTID_WLAN0) {
|
||||
WifiManager::GetInstance().AutoStartEnhanceService();
|
||||
}
|
||||
WifiManager::GetInstance().GetWifiScanManager()->CheckAndStartScanService(instId);
|
||||
WifiConfigCenter::GetInstance().SetWifiScanOnlyMidState(WifiOprMidState::RUNNING, instId);
|
||||
return WIFI_OPT_SUCCESS;
|
||||
@ -230,7 +312,7 @@ ErrCode WifiServiceScheduler::AutoStopScanOnly(int instId, bool setIfaceDown)
|
||||
if (setIfaceDown) {
|
||||
#ifdef HDI_CHIP_INTERFACE_SUPPORT
|
||||
DelayedSingleton<HalDeviceManager>::GetInstance()->SetNetworkUpDown(
|
||||
WifiConfigCenter::GetInstance().GetStaIfaceName(), false);
|
||||
WifiConfigCenter::GetInstance().GetStaIfaceName(instId), false);
|
||||
#endif
|
||||
}
|
||||
WifiManager::GetInstance().GetWifiScanManager()->CheckAndStopScanService(instId);
|
||||
@ -250,7 +332,8 @@ ErrCode WifiServiceScheduler::AutoStartSemiStaService(int instId, std::string &s
|
||||
return WIFI_OPT_FAILED;
|
||||
}
|
||||
DispatchWifiSemiActiveRes(OperateResState::ENABLE_SEMI_WIFI_OPENING, instId);
|
||||
int ret = WifiStaHalInterface::GetInstance().StartWifi(WifiConfigCenter::GetInstance().GetStaIfaceName());
|
||||
int ret = WifiStaHalInterface::GetInstance().StartWifi(WifiConfigCenter::GetInstance().GetStaIfaceName(instId),
|
||||
instId);
|
||||
if (ret != WIFI_OPT_SUCCESS) {
|
||||
WIFI_LOGE("AutoStartSemiStaService start wifi fail.");
|
||||
WifiOprMidState staState = WifiConfigCenter::GetInstance().GetWifiMidState(instId);
|
||||
@ -279,12 +362,14 @@ ErrCode WifiServiceScheduler::PreStartWifi(int instId, std::string &staIfName)
|
||||
if (ifaceName.empty() && !DelayedSingleton<HalDeviceManager>::GetInstance()->CreateStaIface(
|
||||
std::bind(&WifiServiceScheduler::StaIfaceDestoryCallback, this, std::placeholders::_1, std::placeholders::_2),
|
||||
std::bind(&WifiServiceScheduler::OnRssiReportCallback, this, std::placeholders::_1, std::placeholders::_2),
|
||||
ifaceName)) {
|
||||
ifaceName, instId)) {
|
||||
WIFI_LOGE("PreStartWifi, create iface failed!");
|
||||
return WIFI_OPT_FAILED;
|
||||
}
|
||||
WifiConfigCenter::GetInstance().SetStaIfaceName(ifaceName);
|
||||
WIFI_LOGI("PreStartWifi SetStaIfaceName:%{public}s, instId:%{public}d", ifaceName.c_str(), instId);
|
||||
WifiConfigCenter::GetInstance().SetStaIfaceName(ifaceName, instId);
|
||||
g_staIfaceNameMap.insert(std::make_pair(instId, ifaceName));
|
||||
staIfName = WifiConfigCenter::GetInstance().GetStaIfaceName(instId);
|
||||
#endif
|
||||
WifiOprMidState staState = WifiConfigCenter::GetInstance().GetWifiMidState(instId);
|
||||
if (!WifiConfigCenter::GetInstance().SetWifiMidState(staState, WifiOprMidState::OPENING, instId)) {
|
||||
@ -296,48 +381,17 @@ ErrCode WifiServiceScheduler::PreStartWifi(int instId, std::string &staIfName)
|
||||
|
||||
ErrCode WifiServiceScheduler::PostStartWifi(int instId)
|
||||
{
|
||||
ErrCode errCode = WIFI_OPT_FAILED;
|
||||
do {
|
||||
if (WifiServiceManager::GetInstance().CheckAndEnforceService(WIFI_SERVICE_STA) < 0) {
|
||||
WIFI_LOGE("Load %{public}s service failed!", WIFI_SERVICE_STA);
|
||||
break;
|
||||
}
|
||||
IStaService *pService = WifiServiceManager::GetInstance().GetStaServiceInst(instId);
|
||||
if (pService == nullptr) {
|
||||
WIFI_LOGE("Create %{public}s service failed!", WIFI_SERVICE_STA);
|
||||
break;
|
||||
}
|
||||
if (InitStaService(pService) != WIFI_OPT_SUCCESS) {
|
||||
WIFI_LOGE("InitStaService failed!");
|
||||
break;
|
||||
}
|
||||
if (StartWifiStaService(instId) == WIFI_OPT_FAILED) {
|
||||
WIFI_LOGE("StartWifiStaService failed!");
|
||||
}
|
||||
#ifdef FEATURE_SELF_CURE_SUPPORT
|
||||
if (StartSelfCureService(instId) != WIFI_OPT_SUCCESS) {
|
||||
WIFI_LOGE("StartSelfCureService failed!");
|
||||
break;
|
||||
}
|
||||
if (StartSelfCureService(instId) != WIFI_OPT_SUCCESS) {
|
||||
WIFI_LOGE("StartSelfCureService failed!");
|
||||
}
|
||||
#endif
|
||||
errCode = pService->EnableStaService();
|
||||
if (errCode != WIFI_OPT_SUCCESS) {
|
||||
WIFI_LOGE("Service enable sta failed ,ret %{public}d!", static_cast<int>(errCode));
|
||||
break;
|
||||
}
|
||||
#ifndef OHOS_ARCH_LITE
|
||||
IEnhanceService *pEnhanceService = WifiServiceManager::GetInstance().GetEnhanceServiceInst();
|
||||
if (pEnhanceService == nullptr) {
|
||||
WIFI_LOGE("get pEnhance service failed!");
|
||||
break;
|
||||
}
|
||||
errCode = pService->SetEnhanceService(pEnhanceService);
|
||||
if (errCode != WIFI_OPT_SUCCESS) {
|
||||
WIFI_LOGE("SetEnhanceService failed, ret %{public}d!", static_cast<int>(errCode));
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
} while (0);
|
||||
WifiManager::GetInstance().GetWifiStaManager()->StopUnloadStaSaTimer();
|
||||
#ifdef FEATURE_P2P_SUPPORT
|
||||
errCode = WifiManager::GetInstance().GetWifiP2pManager()->AutoStartP2pService();
|
||||
ErrCode errCode = WifiManager::GetInstance().GetWifiP2pManager()->AutoStartP2pService();
|
||||
if (errCode != WIFI_OPT_SUCCESS && errCode != WIFI_OPT_OPEN_SUCC_WHEN_OPENED) {
|
||||
WIFI_LOGE("AutoStartStaService, AutoStartP2pService failed!");
|
||||
}
|
||||
@ -345,7 +399,40 @@ ErrCode WifiServiceScheduler::PostStartWifi(int instId)
|
||||
return WIFI_OPT_SUCCESS;
|
||||
}
|
||||
|
||||
ErrCode WifiServiceScheduler::InitStaService(IStaService *pService)
|
||||
ErrCode WifiServiceScheduler::PostStartWifi2(int instId)
|
||||
{
|
||||
StartWifiStaService(instId);
|
||||
return WIFI_OPT_SUCCESS;
|
||||
}
|
||||
|
||||
ErrCode WifiServiceScheduler::StartWifiStaService(int instId)
|
||||
{
|
||||
if (WifiServiceManager::GetInstance().CheckAndEnforceService(WIFI_SERVICE_STA, instId) < 0) {
|
||||
WIFI_LOGE("StartWifiStaService Load %{public}s service failed!", WIFI_SERVICE_STA);
|
||||
return WIFI_OPT_FAILED;
|
||||
}
|
||||
WIFI_LOGD("StartWifiStaService GetStaServiceInst instId:%{public}d", instId);
|
||||
IStaService *pService = WifiServiceManager::GetInstance().GetStaServiceInst(instId);
|
||||
if (pService == nullptr) {
|
||||
WIFI_LOGE("StartWifiStaService Create %{public}s service failed!", WIFI_SERVICE_STA);
|
||||
return WIFI_OPT_FAILED;
|
||||
}
|
||||
WIFI_LOGD("StartWifiStaService InitStaService instId:%{public}d", instId);
|
||||
if (InitStaService(pService, instId) != WIFI_OPT_SUCCESS) {
|
||||
WIFI_LOGE("StartWifiStaService InitStaService failed!");
|
||||
return WIFI_OPT_FAILED;
|
||||
}
|
||||
WIFI_LOGD("StartWifiStaService EnableStaService instId:%{public}d", instId);
|
||||
ErrCode errCode = pService->EnableStaService();
|
||||
if (errCode != WIFI_OPT_SUCCESS) {
|
||||
WIFI_LOGE("StartWifiStaService Service enable sta failed ,ret %{public}d!", static_cast<int>(errCode));
|
||||
return WIFI_OPT_FAILED;
|
||||
}
|
||||
WIFI_LOGI("StartWifiStaService instId%{public}d successful", instId);
|
||||
return WIFI_OPT_SUCCESS;
|
||||
}
|
||||
|
||||
ErrCode WifiServiceScheduler::InitStaService(IStaService *pService, int instId)
|
||||
{
|
||||
if (pService == nullptr) {
|
||||
WIFI_LOGE("pService is nullptr");
|
||||
@ -357,11 +444,13 @@ ErrCode WifiServiceScheduler::InitStaService(IStaService *pService)
|
||||
WIFI_LOGE("Register sta service callback failed!");
|
||||
return WIFI_OPT_FAILED;
|
||||
}
|
||||
errCode = pService->RegisterStaServiceCallback(WifiManager::GetInstance().GetWifiScanManager()->GetStaCallback());
|
||||
if (errCode != WIFI_OPT_SUCCESS) {
|
||||
WIFI_LOGE("WifiScanManager register sta service callback failed!");
|
||||
return WIFI_OPT_FAILED;
|
||||
}
|
||||
if (instId == INSTID_WLAN0) {
|
||||
errCode = pService->RegisterStaServiceCallback(
|
||||
WifiManager::GetInstance().GetWifiScanManager()->GetStaCallback());
|
||||
if (errCode != WIFI_OPT_SUCCESS) {
|
||||
WIFI_LOGE("WifiScanManager register sta service callback failed!");
|
||||
return WIFI_OPT_FAILED;
|
||||
}
|
||||
#ifndef OHOS_ARCH_LITE
|
||||
errCode = pService->RegisterStaServiceCallback(WifiCountryCodeManager::GetInstance().GetStaCallback());
|
||||
if (errCode != WIFI_OPT_SUCCESS) {
|
||||
@ -377,6 +466,7 @@ ErrCode WifiServiceScheduler::InitStaService(IStaService *pService)
|
||||
return WIFI_OPT_FAILED;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return WIFI_OPT_SUCCESS;
|
||||
}
|
||||
|
||||
@ -429,7 +519,7 @@ void WifiServiceScheduler::StaIfaceDestoryCallback(std::string &destoryIfaceName
|
||||
auto &ins = WifiManager::GetInstance().GetWifiTogglerManager()->GetControllerMachine();
|
||||
ins->SendMessage(CMD_STA_REMOVED, createIfaceType, iter->first);
|
||||
if (createIfaceType >= 0) {
|
||||
WifiConfigCenter::GetInstance().SetStaIfaceName("");
|
||||
WifiConfigCenter::GetInstance().SetStaIfaceName("", iter->first);
|
||||
g_staIfaceNameMap.erase(iter);
|
||||
}
|
||||
return;
|
||||
@ -480,6 +570,29 @@ void WifiServiceScheduler::DispatchWifiOpenRes(OperateResState state, int instId
|
||||
}
|
||||
}
|
||||
|
||||
void WifiServiceScheduler::DispatchWifi2OpenRes(OperateResState state, int instId)
|
||||
{
|
||||
WIFI_LOGI("DispatchWifi2OpenRes, state:%{public}d", static_cast<int>(state));
|
||||
WifiEventCallbackMsg cbMsg;
|
||||
cbMsg.msgCode = WIFI_CBK_MSG_STATE_CHANGE;
|
||||
cbMsg.id = instId;
|
||||
if (state == OperateResState::OPEN_WIFI_OPENING) {
|
||||
WifiConfigCenter::GetInstance().SetWifiState(static_cast<int>(WifiState::ENABLING), instId);
|
||||
WifiConfigCenter::GetInstance().SetWifiDetailState(WifiDetailState::STATE_ACTIVATING, instId);
|
||||
cbMsg.msgData = static_cast<int>(WifiState::ENABLING);
|
||||
WifiInternalEventDispatcher::GetInstance().AddBroadCastMsg(cbMsg);
|
||||
}
|
||||
if (state == OperateResState::OPEN_WIFI_SUCCEED) {
|
||||
WifiConfigCenter::GetInstance().SetWifiState(static_cast<int>(WifiState::ENABLED), instId);
|
||||
WifiConfigCenter::GetInstance().SetWifiDetailState(WifiDetailState::STATE_ACTIVATED, instId);
|
||||
WifiSettings::GetInstance().SetStaLastRunState(WIFI_STATE_ENABLED, instId);
|
||||
WifiConfigCenter::GetInstance().SetWifiMidState(WifiOprMidState::OPENING, WifiOprMidState::RUNNING, instId);
|
||||
cbMsg.msgData = static_cast<int>(WifiState::ENABLED);
|
||||
WifiInternalEventDispatcher::GetInstance().AddBroadCastMsg(cbMsg);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void WifiServiceScheduler::DispatchWifiSemiActiveRes(OperateResState state, int instId)
|
||||
{
|
||||
WIFI_LOGI("DispatchWifiSemiActiveRes, state:%{public}d", static_cast<int>(state));
|
||||
@ -538,7 +651,7 @@ void WifiServiceScheduler::DispatchWifiCloseRes(OperateResState state, int instI
|
||||
WIFI_LOGI("reset selfcure wifi off->open!");
|
||||
int state = WifiSettings::GetInstance().GetStaLastRunState();
|
||||
state = (state == WIFI_STATE_SEMI_ENABLED) ? WIFI_STATE_SEMI_ENABLED : WIFI_STATE_ENABLED;
|
||||
WifiConfigCenter::GetInstance().SetWifiToggledState(state);
|
||||
WifiConfigCenter::GetInstance().SetWifiToggledState(state, instId);
|
||||
WifiSettings::GetInstance().SetStaLastRunState(WIFI_STATE_DISABLED, instId);
|
||||
WifiManager::GetInstance().GetWifiTogglerManager()->WifiToggled(1, 0);
|
||||
}
|
||||
@ -549,6 +662,30 @@ void WifiServiceScheduler::DispatchWifiCloseRes(OperateResState state, int instI
|
||||
}
|
||||
}
|
||||
|
||||
void WifiServiceScheduler::DispatchWifi2CloseRes(OperateResState state, int instId)
|
||||
{
|
||||
WIFI_LOGI("DispatchWifi2CloseRes, state:%{public}d", static_cast<int>(state));
|
||||
WifiEventCallbackMsg cbMsg;
|
||||
cbMsg.msgCode = WIFI_CBK_MSG_STATE_CHANGE;
|
||||
cbMsg.id = instId;
|
||||
if (state == OperateResState::CLOSE_WIFI_CLOSING) {
|
||||
WifiConfigCenter::GetInstance().SetWifiState(static_cast<int>(WifiState::DISABLING), instId);
|
||||
WifiConfigCenter::GetInstance().SetWifiDetailState(WifiDetailState::STATE_DEACTIVATING, instId);
|
||||
cbMsg.msgData = static_cast<int>(WifiState::DISABLING);
|
||||
WifiInternalEventDispatcher::GetInstance().AddBroadCastMsg(cbMsg);
|
||||
return;
|
||||
}
|
||||
if (state == OperateResState::CLOSE_WIFI_SUCCEED) {
|
||||
WifiConfigCenter::GetInstance().SetWifiState(static_cast<int>(WifiState::DISABLED), instId);
|
||||
WifiConfigCenter::GetInstance().SetWifiDetailState(WifiDetailState::STATE_INACTIVE, instId);
|
||||
WifiConfigCenter::GetInstance().SetWifiMidState(WifiOprMidState::CLOSED, instId);
|
||||
cbMsg.msgData = static_cast<int>(WifiState::DISABLED);
|
||||
WifiSettings::GetInstance().SetStaLastRunState(WIFI_STATE_DISABLED, instId);
|
||||
WifiInternalEventDispatcher::GetInstance().AddBroadCastMsg(cbMsg);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------softAp------------------------------------------------------------*/
|
||||
|
||||
#ifdef FEATURE_AP_SUPPORT
|
||||
|
@ -40,22 +40,28 @@ public:
|
||||
explicit WifiServiceScheduler();
|
||||
~WifiServiceScheduler();
|
||||
ErrCode AutoStartStaService(int instId, std::string &staIfName);
|
||||
ErrCode AutoStartWifi2Service(int instId, std::string &staIfName);
|
||||
ErrCode AutoStopStaService(int instId);
|
||||
ErrCode AutoStopWifi2Service(int instId);
|
||||
ErrCode AutoStartScanOnly(int instId, std::string &staIfName);
|
||||
ErrCode AutoStopScanOnly(int instId, bool setIfaceDown);
|
||||
ErrCode AutoStartSemiStaService(int instId, std::string &staIfName);
|
||||
ErrCode AutoStartApService(int instId, std::string &softApIfName);
|
||||
ErrCode AutoStopApService(int instId);
|
||||
void DispatchWifiOpenRes(OperateResState state, int instId);
|
||||
void DispatchWifi2OpenRes(OperateResState state, int instId);
|
||||
void DispatchWifiSemiActiveRes(OperateResState state, int instId);
|
||||
void DispatchWifiCloseRes(OperateResState state, int instId);
|
||||
void DispatchWifi2CloseRes(OperateResState state, int instId);
|
||||
void ClearStaIfaceNameMap(int instId);
|
||||
void ClearP2pIfaceNameMap(int instId);
|
||||
void ClearSoftApIfaceNameMap(int instId);
|
||||
private:
|
||||
ErrCode PreStartWifi(int instId, std::string &staIfName);
|
||||
ErrCode PostStartWifi(int instId);
|
||||
ErrCode InitStaService(IStaService *pService);
|
||||
ErrCode PostStartWifi2(int instId);
|
||||
ErrCode InitStaService(IStaService *pService, int instId);
|
||||
ErrCode StartWifiStaService(int instId);
|
||||
#ifdef FEATURE_SELF_CURE_SUPPORT
|
||||
ErrCode StartSelfCureService(int instId);
|
||||
#endif
|
||||
|
@ -112,7 +112,7 @@ int WifiManager::Init()
|
||||
int lastState = WifiSettings::GetInstance().GetStaLastRunState();
|
||||
if (lastState != WIFI_STATE_DISABLED && !IsFactoryMode()) { /* Automatic startup upon startup */
|
||||
WIFI_LOGI("AutoStartServiceThread lastState:%{public}d", lastState);
|
||||
WifiConfigCenter::GetInstance().SetWifiToggledState(lastState);
|
||||
WifiConfigCenter::GetInstance().SetWifiToggledState(lastState, INSTID_WLAN0);
|
||||
mStartServiceThread = std::make_unique<WifiEventHandler>("StartServiceThread");
|
||||
mStartServiceThread->PostAsyncTask([this]() {
|
||||
AutoStartServiceThread();
|
||||
|
@ -68,7 +68,7 @@ static pthread_mutex_t g_wpaObjMutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static struct IWpaInterface *g_wpaObj = NULL;
|
||||
static struct HDIDeviceManager *g_devMgr = NULL;
|
||||
static pthread_mutex_t g_ifaceNameMutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static char g_staIfaceName[IFACENAME_LEN] = {0};
|
||||
static char g_staIfaceName[STA_INSTANCE_MAX_NUM][IFACENAME_LEN] = {{0}, {0}};
|
||||
static char g_p2pIfaceName[IFACENAME_LEN] = {0};
|
||||
|
||||
const char *HDI_AP_SERVICE_NAME = "hostapd_interface_service";
|
||||
@ -425,38 +425,56 @@ pthread_mutex_t* GetWpaObjMutex(void)
|
||||
return &g_wpaObjMutex;
|
||||
}
|
||||
|
||||
WifiErrorNo SetHdiStaIfaceName(const char *ifaceName)
|
||||
WifiErrorNo SetHdiStaIfaceName(const char *ifaceName, int instId)
|
||||
{
|
||||
pthread_mutex_lock(&g_ifaceNameMutex);
|
||||
if (ifaceName == NULL) {
|
||||
LOGI("SetHdiStaIfaceName enter instId = %{public}d", instId);
|
||||
if (ifaceName == NULL || instId >= STA_INSTANCE_MAX_NUM) {
|
||||
pthread_mutex_unlock(&g_ifaceNameMutex);
|
||||
return WIFI_HAL_OPT_INVALID_PARAM;
|
||||
}
|
||||
|
||||
if (memset_s(g_staIfaceName, IFACENAME_LEN, 0, IFACENAME_LEN) != EOK) {
|
||||
if (memset_s(g_staIfaceName[instId], IFACENAME_LEN, 0, IFACENAME_LEN) != EOK) {
|
||||
pthread_mutex_unlock(&g_ifaceNameMutex);
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
|
||||
if (strcpy_s(g_staIfaceName, IFACENAME_LEN, ifaceName) != EOK) {
|
||||
if (strcpy_s(g_staIfaceName[instId], IFACENAME_LEN, ifaceName) != EOK) {
|
||||
pthread_mutex_unlock(&g_ifaceNameMutex);
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
|
||||
LOGI("SetHdiStaIfaceName, g_staIfaceName:%{public}s", g_staIfaceName);
|
||||
LOGI("SetHdiStaIfaceName, g_staIfaceName:%{public}s, instId = %{public}d", g_staIfaceName[instId], instId);
|
||||
pthread_mutex_unlock(&g_ifaceNameMutex);
|
||||
return WIFI_HAL_OPT_OK;
|
||||
}
|
||||
|
||||
const char *GetHdiStaIfaceName()
|
||||
const char *GetHdiStaIfaceName(int instId)
|
||||
{
|
||||
LOGI("GetHdiStaIfaceName enter instId = %{public}d", instId);
|
||||
const char *ifaceName = NULL;
|
||||
if (instId >= STA_INSTANCE_MAX_NUM) {
|
||||
LOGE("invalid param instId = %{public}d", instId);
|
||||
return ifaceName;
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&g_ifaceNameMutex);
|
||||
ifaceName = g_staIfaceName;
|
||||
ifaceName = g_staIfaceName[instId];
|
||||
pthread_mutex_unlock(&g_ifaceNameMutex);
|
||||
LOGI("GetHdiStaIfaceName enter ifaceName = %{public}s", ifaceName);
|
||||
return ifaceName;
|
||||
}
|
||||
|
||||
void ClearHdiStaIfaceName(int instId)
|
||||
{
|
||||
pthread_mutex_lock(&g_ifaceNameMutex);
|
||||
if (memset_s(g_staIfaceName[instId], IFACENAME_LEN, 0, IFACENAME_LEN) != EOK) {
|
||||
pthread_mutex_unlock(&g_ifaceNameMutex);
|
||||
return;
|
||||
}
|
||||
pthread_mutex_unlock(&g_ifaceNameMutex);
|
||||
}
|
||||
|
||||
WifiErrorNo SetHdiP2pIfaceName(const char *ifaceName)
|
||||
{
|
||||
pthread_mutex_lock(&g_ifaceNameMutex);
|
||||
|
@ -101,8 +101,9 @@ WifiErrorNo HdiAddWpaIface(const char *ifName, const char *confName);
|
||||
*/
|
||||
WifiErrorNo HdiRemoveWpaIface(const char *ifName);
|
||||
|
||||
WifiErrorNo SetHdiStaIfaceName(const char *ifaceName);
|
||||
const char *GetHdiStaIfaceName();
|
||||
WifiErrorNo SetHdiStaIfaceName(const char *ifaceName, int instId);
|
||||
const char *GetHdiStaIfaceName(int instId);
|
||||
void ClearHdiStaIfaceName(int instId);
|
||||
WifiErrorNo SetHdiP2pIfaceName(const char *ifaceName);
|
||||
const char *GetHdiP2pIfaceName();
|
||||
|
||||
|
@ -32,10 +32,17 @@
|
||||
#define REPLY_BUF_LENGTH (4096 * 10)
|
||||
#define ETH_ADDR_LEN 6
|
||||
|
||||
#ifndef INSTID_WLAN0
|
||||
#define INSTID_WLAN0 (0)
|
||||
#endif
|
||||
#ifndef INSTID_WLAN1
|
||||
#define INSTID_WLAN1 (1)
|
||||
#endif
|
||||
|
||||
const int QUOTATION_MARKS_FLAG_YES = 0;
|
||||
const int QUOTATION_MARKS_FLAG_NO = 1;
|
||||
|
||||
static struct IWpaCallback *g_hdiWpaStaCallbackObj = NULL;
|
||||
static struct IWpaCallback *g_hdiWpaStaCallbackObj[STA_INSTANCE_MAX_NUM];
|
||||
static WpaSsidField g_wpaSsidFields[] = {
|
||||
{DEVICE_CONFIG_SSID, "ssid", QUOTATION_MARKS_FLAG_YES},
|
||||
{DEVICE_CONFIG_PSK, "psk", QUOTATION_MARKS_FLAG_YES},
|
||||
@ -69,11 +76,33 @@ static WpaSsidField g_wpaSsidFields[] = {
|
||||
{DEVICE_CONFIG_WAPI_CA_CERT, "wapi_ca_cert", QUOTATION_MARKS_FLAG_YES},
|
||||
};
|
||||
|
||||
static WifiErrorNo RegisterEventCallback()
|
||||
static int GetInstId(const char *ifaceName)
|
||||
{
|
||||
LOGI("RegisterEventCallback enter");
|
||||
int inst = INSTID_WLAN0;
|
||||
if (ifaceName == NULL) {
|
||||
LOGE("GetInstId ifaceName is null");
|
||||
return inst;
|
||||
}
|
||||
for (int instId = 0; instId < STA_INSTANCE_MAX_NUM; instId++) {
|
||||
const char *hdiStaIfname = GetHdiStaIfaceName(instId);
|
||||
if (hdiStaIfname == NULL) {
|
||||
continue;
|
||||
}
|
||||
if (strcmp(ifaceName, hdiStaIfname) == 0) {
|
||||
inst = instId;
|
||||
break;
|
||||
}
|
||||
}
|
||||
LOGI("GetInstId ifaceName = %{public}sm instId = %{public}d", ifaceName, inst);
|
||||
return inst;
|
||||
}
|
||||
|
||||
static WifiErrorNo RegisterEventCallback(const char *ifaceName)
|
||||
{
|
||||
LOGI("RegisterEventCallback enter! ifaceName = %{puiblic}s", ifaceName);
|
||||
pthread_mutex_lock(GetWpaObjMutex());
|
||||
if (g_hdiWpaStaCallbackObj == NULL) {
|
||||
int instId = GetInstId(ifaceName);
|
||||
if (g_hdiWpaStaCallbackObj[instId] == NULL) {
|
||||
pthread_mutex_unlock(GetWpaObjMutex());
|
||||
LOGE("RegisterEventCallback: g_hdiWpaStaCallbackObj is NULL");
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
@ -86,7 +115,7 @@ static WifiErrorNo RegisterEventCallback()
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
|
||||
int32_t result = wpaObj->RegisterWpaEventCallback(wpaObj, g_hdiWpaStaCallbackObj, GetHdiStaIfaceName());
|
||||
int32_t result = wpaObj->RegisterWpaEventCallback(wpaObj, g_hdiWpaStaCallbackObj[instId], ifaceName);
|
||||
if (result != HDF_SUCCESS) {
|
||||
pthread_mutex_unlock(GetWpaObjMutex());
|
||||
LOGE("RegisterEventCallback: RegisterEventCallback failed result:%{public}d", result);
|
||||
@ -98,11 +127,17 @@ static WifiErrorNo RegisterEventCallback()
|
||||
return WIFI_HAL_OPT_OK;
|
||||
}
|
||||
|
||||
static WifiErrorNo UnRegisterEventCallback()
|
||||
static WifiErrorNo UnRegisterEventCallback(const char *ifaceName)
|
||||
{
|
||||
LOGI("UnRegisterEventCallback enter");
|
||||
LOGI("UnRegisterEventCallback enter! ifaceName = %{public}s", ifaceName);
|
||||
if (ifaceName == NULL) {
|
||||
LOGE("UnRegisterEventCallback ifaceName is null");
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
pthread_mutex_lock(GetWpaObjMutex());
|
||||
if (g_hdiWpaStaCallbackObj != NULL) {
|
||||
int instId = GetInstId(ifaceName);
|
||||
LOGI("UnRegisterEventCallback enter! instId = %{puiblic}d", instId);
|
||||
if (g_hdiWpaStaCallbackObj[instId] != NULL) {
|
||||
struct IWpaInterface *wpaObj = GetWpaInterface();
|
||||
if (wpaObj == NULL) {
|
||||
pthread_mutex_unlock(GetWpaObjMutex());
|
||||
@ -110,15 +145,15 @@ static WifiErrorNo UnRegisterEventCallback()
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
|
||||
int32_t result = wpaObj->UnregisterWpaEventCallback(wpaObj, g_hdiWpaStaCallbackObj, GetHdiStaIfaceName());
|
||||
int32_t result = wpaObj->UnregisterWpaEventCallback(wpaObj, g_hdiWpaStaCallbackObj[instId], ifaceName);
|
||||
if (result != HDF_SUCCESS) {
|
||||
pthread_mutex_unlock(GetWpaObjMutex());
|
||||
LOGE("UnRegisterEventCallback: UnregisterEventCallback failed result:%{public}d", result);
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
StubCollectorRemoveObject(IWPACALLBACK_INTERFACE_DESC, g_hdiWpaStaCallbackObj);
|
||||
free(g_hdiWpaStaCallbackObj);
|
||||
g_hdiWpaStaCallbackObj = NULL;
|
||||
StubCollectorRemoveObject(IWPACALLBACK_INTERFACE_DESC, g_hdiWpaStaCallbackObj[instId]);
|
||||
free(g_hdiWpaStaCallbackObj[instId]);
|
||||
g_hdiWpaStaCallbackObj[instId] = NULL;
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(GetWpaObjMutex());
|
||||
@ -150,8 +185,12 @@ static int CalcQuotationMarksFlag(int pos, const char value[WIFI_NETWORK_CONFIG_
|
||||
return flag;
|
||||
}
|
||||
|
||||
static WifiErrorNo SetNetwork(int networkId, SetNetworkConfig conf)
|
||||
static WifiErrorNo SetNetwork(int networkId, SetNetworkConfig conf, const char *ifaceName)
|
||||
{
|
||||
if (ifaceName == NULL) {
|
||||
LOGE("GetInstId ifaceName is null");
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
int pos = -1;
|
||||
for (unsigned i = 0; i < sizeof(g_wpaSsidFields) / sizeof(g_wpaSsidFields[0]); ++i) {
|
||||
if (g_wpaSsidFields[i].field == conf.cfgParam) {
|
||||
@ -183,22 +222,25 @@ static WifiErrorNo SetNetwork(int networkId, SetNetworkConfig conf)
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
|
||||
int32_t result = wpaObj->SetNetwork(wpaObj, GetHdiStaIfaceName(), networkId, g_wpaSsidFields[pos].fieldName,
|
||||
conf.cfgValue);
|
||||
int32_t result = wpaObj->SetNetwork(wpaObj, ifaceName, networkId, g_wpaSsidFields[pos].fieldName, conf.cfgValue);
|
||||
if (result != HDF_SUCCESS) {
|
||||
LOGE("SetNetwork: SetNetwork failed result:%{public}d", result);
|
||||
pthread_mutex_unlock(GetWpaObjMutex());
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
pthread_mutex_unlock(GetWpaObjMutex());
|
||||
LOGI("SetNetwork success.");
|
||||
LOGI("SetNetwork success. ifaceName = %{public}s", ifaceName);
|
||||
return WIFI_HAL_OPT_OK;
|
||||
}
|
||||
|
||||
WifiErrorNo HdiWpaStaStart(const char *ifaceName)
|
||||
WifiErrorNo HdiWpaStaStart(const char *ifaceName, int instId)
|
||||
{
|
||||
LOGI("HdiWpaStaStart enter");
|
||||
if (SetHdiStaIfaceName(ifaceName) != WIFI_HAL_OPT_OK) {
|
||||
if (ifaceName == NULL) {
|
||||
LOGE("HdiWpaStaStart ifaceName is null");
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
LOGI("HdiWpaStaStart enter! ifaceName = %{public}s, instId = %{public}d", ifaceName, instId);
|
||||
if (SetHdiStaIfaceName(ifaceName, instId) != WIFI_HAL_OPT_OK) {
|
||||
LOGE("HdiWpaStaStart: set sta iface name failed!");
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
@ -213,12 +255,12 @@ WifiErrorNo HdiWpaStaStart(const char *ifaceName)
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
|
||||
if (RegisterEventCallback() != WIFI_HAL_OPT_OK) {
|
||||
if (RegisterEventCallback(ifaceName) != WIFI_HAL_OPT_OK) {
|
||||
LOGE("HdiWpaStaStart: RegisterEventCallback failed!");
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
|
||||
if (HdiAddWpaIface(GetHdiStaIfaceName(), CONFIG_ROOR_DIR"/wpa_supplicant/wpa_supplicant.conf") != WIFI_HAL_OPT_OK) {
|
||||
if (HdiAddWpaIface(ifaceName, CONFIG_ROOR_DIR "/wpa_supplicant/wpa_supplicant.conf") != WIFI_HAL_OPT_OK) {
|
||||
LOGE("HdiWpaStaStart: HdiAddWpaIface failed!");
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
@ -227,30 +269,60 @@ WifiErrorNo HdiWpaStaStart(const char *ifaceName)
|
||||
return WIFI_HAL_OPT_OK;
|
||||
}
|
||||
|
||||
WifiErrorNo HdiWpaStaStop()
|
||||
static WifiErrorNo HdiWpaStaStopWifi(int instId)
|
||||
{
|
||||
LOGI("HdiWpaStaStop enter");
|
||||
for (int inst = instId; inst < STA_INSTANCE_MAX_NUM; inst++) {
|
||||
const char *ifaceName = GetHdiStaIfaceName(instId);
|
||||
if (ifaceName == NULL) {
|
||||
LOGE("HdiWpaStopWifi ifaceName is null");
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
if (HdiRemoveWpaIface(ifaceName) != WIFI_HAL_OPT_OK) {
|
||||
LOGE("HdiWpaStop: HdiRemoveWpaIface failed");
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
if (UnRegisterEventCallback(ifaceName) != WIFI_HAL_OPT_OK) {
|
||||
LOGE("HdiWpaStop: UnRegisterEventCallback failed");
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
ClearHdiStaIfaceName(instId);
|
||||
LOGI("HdiWpaStaStopWifi success, instId = %{public}d, ifaceName = %{public}s", instId, ifaceName);
|
||||
}
|
||||
return WIFI_HAL_OPT_OK;
|
||||
}
|
||||
|
||||
WifiErrorNo HdiWpaStaStop(int instId)
|
||||
{
|
||||
LOGI("HdiWpaStaStop enter, instId = %{public}d", instId);
|
||||
if (IsHdiWpaStopped() == WIFI_HAL_OPT_OK) {
|
||||
LOGI("HdiWpa already stopped, HdiWpaStaStop success!");
|
||||
return WIFI_HAL_OPT_OK;
|
||||
}
|
||||
|
||||
do {
|
||||
if (HdiRemoveWpaIface(GetHdiP2pIfaceName()) != WIFI_HAL_OPT_OK) {
|
||||
LOGE("HdiWpaStaStop: HdiRemoveWpaP2pIface failed!");
|
||||
break;
|
||||
if (instId == INSTID_WLAN1) {
|
||||
const char *ifaceName = GetHdiStaIfaceName(instId);
|
||||
if (ifaceName == NULL) {
|
||||
LOGE("HdiWpaStaStopWifi ifaceName is null");
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
|
||||
if (HdiRemoveWpaIface(GetHdiStaIfaceName()) != WIFI_HAL_OPT_OK) {
|
||||
if (HdiRemoveWpaIface(ifaceName) != WIFI_HAL_OPT_OK) {
|
||||
LOGE("HdiWpaStaStop: HdiRemoveWpaStaIface failed!");
|
||||
break;
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
|
||||
if (UnRegisterEventCallback() != WIFI_HAL_OPT_OK) {
|
||||
if (UnRegisterEventCallback(ifaceName) != WIFI_HAL_OPT_OK) {
|
||||
LOGE("HdiWpaStaStop: UnRegisterEventCallback failed!");
|
||||
break;
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
} while (0);
|
||||
ClearHdiStaIfaceName(instId);
|
||||
LOGI("HdiWpaStaStopWifi success, instId = %{public}d, ifaceName = %{public}s", instId, ifaceName);
|
||||
return WIFI_HAL_OPT_OK;
|
||||
}
|
||||
|
||||
if (HdiRemoveWpaIface(GetHdiP2pIfaceName()) != WIFI_HAL_OPT_OK) {
|
||||
LOGE("HdiWpaStaStop: HdiRemoveWpaP2pIface failed!");
|
||||
}
|
||||
|
||||
HdiWpaStaStopWifi(INSTID_WLAN0);
|
||||
|
||||
if (HdiWpaStop() != WIFI_HAL_OPT_OK) {
|
||||
LOGE("HdiWpaStaStop: HdiWpaStaStop failed!");
|
||||
@ -261,9 +333,13 @@ WifiErrorNo HdiWpaStaStop()
|
||||
return WIFI_HAL_OPT_OK;
|
||||
}
|
||||
|
||||
WifiErrorNo HdiWpaStaConnect(int networkId)
|
||||
WifiErrorNo HdiWpaStaConnect(int networkId, const char *ifaceName)
|
||||
{
|
||||
LOGI("HdiWpaStaConnect enter, networkId:%{public}d", networkId);
|
||||
if (ifaceName == NULL) {
|
||||
LOGE("HdiWpaStaConnect ifaceName is null");
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
LOGI("HdiWpaStaConnect enter, networkId:%{public}d, ifaceName = %{public}s", networkId, ifaceName);
|
||||
pthread_mutex_lock(GetWpaObjMutex());
|
||||
struct IWpaInterface *wpaObj = GetWpaInterface();
|
||||
if (wpaObj == NULL) {
|
||||
@ -272,7 +348,7 @@ WifiErrorNo HdiWpaStaConnect(int networkId)
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
|
||||
int32_t result = wpaObj->SelectNetwork(wpaObj, GetHdiStaIfaceName(), networkId);
|
||||
int32_t result = wpaObj->SelectNetwork(wpaObj, ifaceName, networkId);
|
||||
if (result != HDF_SUCCESS) {
|
||||
LOGE("HdiWpaStaConnect: SelectNetwork failed result:%{public}d", result);
|
||||
pthread_mutex_unlock(GetWpaObjMutex());
|
||||
@ -283,9 +359,13 @@ WifiErrorNo HdiWpaStaConnect(int networkId)
|
||||
return WIFI_HAL_OPT_OK;
|
||||
}
|
||||
|
||||
WifiErrorNo HdiWpaStaReconnect()
|
||||
WifiErrorNo HdiWpaStaReconnect(const char *ifaceName)
|
||||
{
|
||||
LOGI("HdiWpaStaReconnect enter");
|
||||
if (ifaceName == NULL) {
|
||||
LOGE("HdiWpaStaReconnect ifaceName is null");
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
LOGI("HdiWpaStaReconnect enter! ifaceName = %{public}s", ifaceName);
|
||||
pthread_mutex_lock(GetWpaObjMutex());
|
||||
struct IWpaInterface *wpaObj = GetWpaInterface();
|
||||
if (wpaObj == NULL) {
|
||||
@ -294,7 +374,7 @@ WifiErrorNo HdiWpaStaReconnect()
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
|
||||
int32_t result = wpaObj->Reconnect(wpaObj, GetHdiStaIfaceName());
|
||||
int32_t result = wpaObj->Reconnect(wpaObj, ifaceName);
|
||||
if (result != HDF_SUCCESS) {
|
||||
LOGE("HdiWpaStaReconnect: Reconnect failed result:%{public}d", result);
|
||||
pthread_mutex_unlock(GetWpaObjMutex());
|
||||
@ -305,8 +385,12 @@ WifiErrorNo HdiWpaStaReconnect()
|
||||
return WIFI_HAL_OPT_OK;
|
||||
}
|
||||
|
||||
WifiErrorNo HdiWpaStaReassociate()
|
||||
WifiErrorNo HdiWpaStaReassociate(const char *ifaceName)
|
||||
{
|
||||
if (ifaceName == NULL) {
|
||||
LOGE("HdiWpaStaReassociate ifaceName is null");
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
pthread_mutex_lock(GetWpaObjMutex());
|
||||
struct IWpaInterface *wpaObj = GetWpaInterface();
|
||||
if (wpaObj == NULL) {
|
||||
@ -315,7 +399,7 @@ WifiErrorNo HdiWpaStaReassociate()
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
|
||||
int32_t result = wpaObj->Reassociate(wpaObj, GetHdiStaIfaceName());
|
||||
int32_t result = wpaObj->Reassociate(wpaObj, ifaceName);
|
||||
if (result != HDF_SUCCESS) {
|
||||
LOGE("HdiWpaStaReassociate: Reassociate failed result:%{public}d", result);
|
||||
pthread_mutex_unlock(GetWpaObjMutex());
|
||||
@ -325,9 +409,13 @@ WifiErrorNo HdiWpaStaReassociate()
|
||||
return WIFI_HAL_OPT_OK;
|
||||
}
|
||||
|
||||
WifiErrorNo HdiWpaStaDisconnect()
|
||||
WifiErrorNo HdiWpaStaDisconnect(const char *ifaceName)
|
||||
{
|
||||
LOGI("HdiWpaStaDisconnect enter");
|
||||
if (ifaceName == NULL) {
|
||||
LOGE("HdiWpaStaDisconnect ifaceName is null");
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
LOGI("HdiWpaStaDisconnect enter! ifaceName = %{public}s", ifaceName);
|
||||
pthread_mutex_lock(GetWpaObjMutex());
|
||||
struct IWpaInterface *wpaObj = GetWpaInterface();
|
||||
if (wpaObj == NULL) {
|
||||
@ -336,7 +424,7 @@ WifiErrorNo HdiWpaStaDisconnect()
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
|
||||
int32_t result = wpaObj->Disconnect(wpaObj, GetHdiStaIfaceName());
|
||||
int32_t result = wpaObj->Disconnect(wpaObj, ifaceName);
|
||||
if (result != HDF_SUCCESS) {
|
||||
LOGE("HdiWpaStaDisconnect: Disconnect failed result:%{public}d", result);
|
||||
pthread_mutex_unlock(GetWpaObjMutex());
|
||||
@ -385,9 +473,9 @@ static void HdiWpaFree(struct HdiWpaCmdStatus *status)
|
||||
}
|
||||
}
|
||||
|
||||
WifiErrorNo HdiWpaStaGetDeviceMacAddress(char *macAddr, int macAddrLen)
|
||||
WifiErrorNo HdiWpaStaGetDeviceMacAddress(char *macAddr, int macAddrLen, const char *ifaceName)
|
||||
{
|
||||
LOGI("HdiWpaStaGetDeviceMacAddress enter");
|
||||
LOGI("HdiWpaStaGetDeviceMacAddress enter! ifaceName = %{public}s", ifaceName);
|
||||
if (macAddr == NULL) {
|
||||
LOGE("HdiWpaStaGetDeviceMacAddress: invalid parameter!");
|
||||
return WIFI_HAL_OPT_INVALID_PARAM;
|
||||
@ -403,7 +491,7 @@ WifiErrorNo HdiWpaStaGetDeviceMacAddress(char *macAddr, int macAddrLen)
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
|
||||
int32_t result = wpaObj->WifiStatus(wpaObj, GetHdiStaIfaceName(), &status);
|
||||
int32_t result = wpaObj->WifiStatus(wpaObj, ifaceName, &status);
|
||||
if (result != HDF_SUCCESS) {
|
||||
LOGE("HdiWpaStaGetDeviceMacAddress: WifiStatus failed result:%{public}d", result);
|
||||
HdiWpaFree(&status);
|
||||
@ -441,7 +529,7 @@ WifiErrorNo HdiWpaStaScan()
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
|
||||
int32_t result = wpaObj->Scan(wpaObj, GetHdiStaIfaceName());
|
||||
int32_t result = wpaObj->Scan(wpaObj, GetHdiStaIfaceName(INSTID_WLAN0));
|
||||
if (result != HDF_SUCCESS) {
|
||||
LOGE("HdiWpaStaScan: Scan failed result:%{public}d", result);
|
||||
pthread_mutex_unlock(GetWpaObjMutex());
|
||||
@ -452,11 +540,11 @@ WifiErrorNo HdiWpaStaScan()
|
||||
return WIFI_HAL_OPT_OK;
|
||||
}
|
||||
|
||||
ScanInfo *HdiWpaStaGetScanInfos(int *size)
|
||||
ScanInfo *HdiWpaStaGetScanInfos(int *size, const char *ifaceName)
|
||||
{
|
||||
LOGI("HdiWpaStaGetScanInfos enter");
|
||||
if (size == NULL) {
|
||||
LOGE("HdiWpaStaGetScanInfos: invalid parameter!");
|
||||
if (ifaceName == NULL || size == NULL) {
|
||||
LOGE("HdiWpaStaGetScanInfos ifaceName is null");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -486,7 +574,7 @@ ScanInfo *HdiWpaStaGetScanInfos(int *size)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int32_t result = wpaObj->ScanResult(wpaObj, GetHdiStaIfaceName(), resultBuff, &resultBuffLen);
|
||||
int32_t result = wpaObj->ScanResult(wpaObj, ifaceName, resultBuff, &resultBuffLen);
|
||||
if (result != HDF_SUCCESS) {
|
||||
free(results);
|
||||
free(resultBuff);
|
||||
@ -533,9 +621,13 @@ ScanInfo *HdiWpaStaGetScanInfos(int *size)
|
||||
return results;
|
||||
}
|
||||
|
||||
WifiErrorNo HdiWpaStaRemoveNetwork(int networkId)
|
||||
WifiErrorNo HdiWpaStaRemoveNetwork(int networkId, const char *ifaceName)
|
||||
{
|
||||
LOGI("HdiWpaStaRemoveNetwork enter, networkId:%{public}d", networkId);
|
||||
if (ifaceName == NULL) {
|
||||
LOGE("HdiWpaStaRemoveNetwork ifaceName is null");
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
LOGI("HdiWpaStaRemoveNetwork enter, networkId:%{public}d, ifaceName = %{public}s", networkId, ifaceName);
|
||||
pthread_mutex_lock(GetWpaObjMutex());
|
||||
struct IWpaInterface *wpaObj = GetWpaInterface();
|
||||
if (wpaObj == NULL) {
|
||||
@ -544,7 +636,7 @@ WifiErrorNo HdiWpaStaRemoveNetwork(int networkId)
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
|
||||
int32_t result = wpaObj->RemoveNetwork(wpaObj, GetHdiStaIfaceName(), networkId);
|
||||
int32_t result = wpaObj->RemoveNetwork(wpaObj, ifaceName, networkId);
|
||||
if (result != HDF_SUCCESS) {
|
||||
LOGE("HdiWpaStaRemoveNetwork: RemoveNetwork failed result:%{public}d", result);
|
||||
pthread_mutex_unlock(GetWpaObjMutex());
|
||||
@ -555,9 +647,13 @@ WifiErrorNo HdiWpaStaRemoveNetwork(int networkId)
|
||||
return WIFI_HAL_OPT_OK;
|
||||
}
|
||||
|
||||
WifiErrorNo HdiWpaStaAddNetwork(int *networkId)
|
||||
WifiErrorNo HdiWpaStaAddNetwork(int *networkId, const char *ifaceName)
|
||||
{
|
||||
LOGI("HdiWpaStaAddNetwork enter");
|
||||
if (ifaceName == NULL) {
|
||||
LOGE("HdiWpaStaAddNetwork ifaceName is null");
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
LOGI("HdiWpaStaAddNetwork enter! ifaceName = %{public}s", ifaceName);
|
||||
if (networkId == NULL) {
|
||||
LOGE("HdiWpaStaAddNetwork: invalid parameter!");
|
||||
return WIFI_HAL_OPT_INVALID_PARAM;
|
||||
@ -570,7 +666,7 @@ WifiErrorNo HdiWpaStaAddNetwork(int *networkId)
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
|
||||
int32_t result = wpaObj->AddNetwork(wpaObj, GetHdiStaIfaceName(), networkId);
|
||||
int32_t result = wpaObj->AddNetwork(wpaObj, ifaceName, networkId);
|
||||
if (result != HDF_SUCCESS) {
|
||||
LOGE("HdiWpaStaAddNetwork: AddNetwork failed result:%{public}d", result);
|
||||
pthread_mutex_unlock(GetWpaObjMutex());
|
||||
@ -581,9 +677,13 @@ WifiErrorNo HdiWpaStaAddNetwork(int *networkId)
|
||||
return WIFI_HAL_OPT_OK;
|
||||
}
|
||||
|
||||
WifiErrorNo HdiWpaStaEnableNetwork(int networkId)
|
||||
WifiErrorNo HdiWpaStaEnableNetwork(int networkId, const char *ifaceName)
|
||||
{
|
||||
LOGI("HdiWpaStaEnableNetwork enter, networkId:%{public}d", networkId);
|
||||
if (ifaceName == NULL) {
|
||||
LOGE("HdiWpaStaEnableNetwork ifaceName is null");
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
LOGI("HdiWpaStaEnableNetwork enter, networkId:%{public}d, ifaceName = %{public}s", networkId, ifaceName);
|
||||
pthread_mutex_lock(GetWpaObjMutex());
|
||||
struct IWpaInterface *wpaObj = GetWpaInterface();
|
||||
if (wpaObj == NULL) {
|
||||
@ -592,7 +692,7 @@ WifiErrorNo HdiWpaStaEnableNetwork(int networkId)
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
|
||||
int32_t result = wpaObj->EnableNetwork(wpaObj, GetHdiStaIfaceName(), networkId);
|
||||
int32_t result = wpaObj->EnableNetwork(wpaObj, ifaceName, networkId);
|
||||
if (result != HDF_SUCCESS) {
|
||||
LOGE("HdiWpaStaEnableNetwork: EnableNetwork failed result:%{public}d", result);
|
||||
pthread_mutex_unlock(GetWpaObjMutex());
|
||||
@ -603,9 +703,13 @@ WifiErrorNo HdiWpaStaEnableNetwork(int networkId)
|
||||
return WIFI_HAL_OPT_OK;
|
||||
}
|
||||
|
||||
WifiErrorNo HdiWpaStaDisableNetwork(int networkId)
|
||||
WifiErrorNo HdiWpaStaDisableNetwork(int networkId, const char *ifaceName)
|
||||
{
|
||||
LOGI("HdiWpaStaDisableNetwork enter, networkId:%{public}d", networkId);
|
||||
if (ifaceName == NULL) {
|
||||
LOGE("HdiWpaStaDisableNetwork ifaceName is null");
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
LOGI("HdiWpaStaDisableNetwork enter, networkId:%{public}d, ifaceName = %{public}s", networkId, ifaceName);
|
||||
pthread_mutex_lock(GetWpaObjMutex());
|
||||
struct IWpaInterface *wpaObj = GetWpaInterface();
|
||||
if (wpaObj == NULL) {
|
||||
@ -614,7 +718,7 @@ WifiErrorNo HdiWpaStaDisableNetwork(int networkId)
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
|
||||
int32_t result = wpaObj->DisableNetwork(wpaObj, GetHdiStaIfaceName(), networkId);
|
||||
int32_t result = wpaObj->DisableNetwork(wpaObj, ifaceName, networkId);
|
||||
if (result != HDF_SUCCESS) {
|
||||
LOGE("HdiWpaStaDisableNetwork: DisableNetwork failed result:%{public}d", result);
|
||||
pthread_mutex_unlock(GetWpaObjMutex());
|
||||
@ -625,24 +729,32 @@ WifiErrorNo HdiWpaStaDisableNetwork(int networkId)
|
||||
return WIFI_HAL_OPT_OK;
|
||||
}
|
||||
|
||||
WifiErrorNo HdiWpaStaSetNetwork(int networkId, SetNetworkConfig *confs, int size)
|
||||
WifiErrorNo HdiWpaStaSetNetwork(int networkId, SetNetworkConfig *confs, int size, const char *ifaceName)
|
||||
{
|
||||
LOGI("HdiWpaStaSetNetwork enter");
|
||||
if (ifaceName == NULL) {
|
||||
LOGE("HdiWpaStaSetNetwork ifaceName is null");
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
LOGI("HdiWpaStaSetNetwork enter! ifaceName = %{public}s", ifaceName);
|
||||
if (confs == NULL) {
|
||||
LOGE("HdiWpaStaSetNetwork: invalid parameter!");
|
||||
return WIFI_HAL_OPT_INVALID_PARAM;
|
||||
}
|
||||
|
||||
for (int i = 0; i < size; ++i) {
|
||||
SetNetwork(networkId, confs[i]);
|
||||
SetNetwork(networkId, confs[i], ifaceName);
|
||||
}
|
||||
|
||||
return WIFI_HAL_OPT_OK;
|
||||
}
|
||||
|
||||
WifiErrorNo HdiWpaStaSaveConfig()
|
||||
WifiErrorNo HdiWpaStaSaveConfig(const char *ifaceName)
|
||||
{
|
||||
LOGI("HdiWpaStaSaveConfig enter");
|
||||
if (ifaceName == NULL) {
|
||||
LOGE("HdiWpaStaSaveConfig ifaceName is null");
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
LOGI("HdiWpaStaSaveConfig enter! ifaceName = %{public}s", ifaceName);
|
||||
pthread_mutex_lock(GetWpaObjMutex());
|
||||
struct IWpaInterface *wpaObj = GetWpaInterface();
|
||||
if (wpaObj == NULL) {
|
||||
@ -651,7 +763,7 @@ WifiErrorNo HdiWpaStaSaveConfig()
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
|
||||
int32_t result = wpaObj->SaveConfig(wpaObj, GetHdiStaIfaceName());
|
||||
int32_t result = wpaObj->SaveConfig(wpaObj, ifaceName);
|
||||
if (result != HDF_SUCCESS) {
|
||||
LOGE("HdiWpaStaSaveConfig: SaveConfig failed result:%{public}d", result);
|
||||
pthread_mutex_unlock(GetWpaObjMutex());
|
||||
@ -662,9 +774,13 @@ WifiErrorNo HdiWpaStaSaveConfig()
|
||||
return WIFI_HAL_OPT_OK;
|
||||
}
|
||||
|
||||
WifiErrorNo RegisterHdiWpaStaEventCallback(struct IWpaCallback *callback)
|
||||
WifiErrorNo RegisterHdiWpaStaEventCallback(struct IWpaCallback *callback, const char *ifaceName, int instId)
|
||||
{
|
||||
LOGI("RegisterHdiWpaStaEventCallback enter");
|
||||
if (ifaceName == NULL) {
|
||||
LOGE("RegisterHdiWpaStaEventCallback ifaceName is null");
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
LOGI("RegisterHdiWpaStaEventCallback enter, ifaceName = %{public}s, instId = %{public}d", ifaceName, instId);
|
||||
pthread_mutex_lock(GetWpaObjMutex());
|
||||
if (callback == NULL || callback->OnEventConnected == NULL) {
|
||||
pthread_mutex_unlock(GetWpaObjMutex());
|
||||
@ -672,44 +788,47 @@ WifiErrorNo RegisterHdiWpaStaEventCallback(struct IWpaCallback *callback)
|
||||
return WIFI_HAL_OPT_INVALID_PARAM;
|
||||
}
|
||||
|
||||
if (g_hdiWpaStaCallbackObj != NULL) {
|
||||
if (g_hdiWpaStaCallbackObj[instId] != NULL) {
|
||||
pthread_mutex_unlock(GetWpaObjMutex());
|
||||
LOGI("RegisterHdiWpaStaEventCallback: already register!");
|
||||
return WIFI_HAL_OPT_OK;
|
||||
}
|
||||
|
||||
g_hdiWpaStaCallbackObj = (struct IWpaCallback *)malloc(sizeof(struct IWpaCallback));
|
||||
if (g_hdiWpaStaCallbackObj == NULL) {
|
||||
g_hdiWpaStaCallbackObj[instId] = (struct IWpaCallback *)malloc(sizeof(struct IWpaCallback));
|
||||
if (g_hdiWpaStaCallbackObj[instId] == NULL) {
|
||||
pthread_mutex_unlock(GetWpaObjMutex());
|
||||
LOGE("RegisterHdiWpaStaEventCallback: IWpaCallback malloc failed!");
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
if (memset_s(g_hdiWpaStaCallbackObj, sizeof(struct IWpaCallback),
|
||||
0, sizeof(struct IWpaCallback)) != EOK) {
|
||||
if (memset_s(g_hdiWpaStaCallbackObj[instId], sizeof(struct IWpaCallback), 0, sizeof(struct IWpaCallback)) != EOK) {
|
||||
pthread_mutex_unlock(GetWpaObjMutex());
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
g_hdiWpaStaCallbackObj->OnEventDisconnected = callback->OnEventDisconnected;
|
||||
g_hdiWpaStaCallbackObj->OnEventConnected = callback->OnEventConnected;
|
||||
g_hdiWpaStaCallbackObj->OnEventBssidChanged = callback->OnEventBssidChanged;
|
||||
g_hdiWpaStaCallbackObj->OnEventStateChanged = callback->OnEventStateChanged;
|
||||
g_hdiWpaStaCallbackObj->OnEventTempDisabled = callback->OnEventTempDisabled;
|
||||
g_hdiWpaStaCallbackObj->OnEventAssociateReject = callback->OnEventAssociateReject;
|
||||
g_hdiWpaStaCallbackObj->OnEventWpsOverlap = callback->OnEventWpsOverlap;
|
||||
g_hdiWpaStaCallbackObj->OnEventWpsTimeout = callback->OnEventWpsTimeout;
|
||||
g_hdiWpaStaCallbackObj->OnEventAuthTimeout = callback->OnEventAuthTimeout;
|
||||
g_hdiWpaStaCallbackObj[instId]->OnEventDisconnected = callback->OnEventDisconnected;
|
||||
g_hdiWpaStaCallbackObj[instId]->OnEventConnected = callback->OnEventConnected;
|
||||
g_hdiWpaStaCallbackObj[instId]->OnEventBssidChanged = callback->OnEventBssidChanged;
|
||||
g_hdiWpaStaCallbackObj[instId]->OnEventStateChanged = callback->OnEventStateChanged;
|
||||
g_hdiWpaStaCallbackObj[instId]->OnEventTempDisabled = callback->OnEventTempDisabled;
|
||||
g_hdiWpaStaCallbackObj[instId]->OnEventAssociateReject = callback->OnEventAssociateReject;
|
||||
g_hdiWpaStaCallbackObj[instId]->OnEventWpsOverlap = callback->OnEventWpsOverlap;
|
||||
g_hdiWpaStaCallbackObj[instId]->OnEventWpsTimeout = callback->OnEventWpsTimeout;
|
||||
g_hdiWpaStaCallbackObj[instId]->OnEventAuthTimeout = callback->OnEventAuthTimeout;
|
||||
#ifndef HDI_CHIP_INTERFACE_SUPPORT
|
||||
g_hdiWpaStaCallbackObj->OnEventScanResult = callback->OnEventScanResult;
|
||||
g_hdiWpaStaCallbackObj[instId]->OnEventScanResult = callback->OnEventScanResult;
|
||||
#endif
|
||||
g_hdiWpaStaCallbackObj->OnEventStaNotify = callback->OnEventStaNotify;
|
||||
g_hdiWpaStaCallbackObj[instId]->OnEventStaNotify = callback->OnEventStaNotify;
|
||||
pthread_mutex_unlock(GetWpaObjMutex());
|
||||
LOGI("RegisterHdiWpaStaEventCallback3 success.");
|
||||
return WIFI_HAL_OPT_OK;
|
||||
}
|
||||
|
||||
WifiErrorNo HdiWpaStaStartWpsPbcMode(WifiWpsParam *config)
|
||||
WifiErrorNo HdiWpaStaStartWpsPbcMode(WifiWpsParam *config, const char *ifaceName)
|
||||
{
|
||||
LOGI("HdiWpaStaStartWpsPbcMode enter");
|
||||
if (ifaceName == NULL) {
|
||||
LOGE("HdiWpaStaStartWpsPbcMode ifaceName is null");
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
LOGI("HdiWpaStaStartWpsPbcMode enter! ifaceName = %{public}s", ifaceName);
|
||||
if (config == NULL) {
|
||||
LOGE("HdiWpaStaStartWpsPbcMode: invalid parameter!");
|
||||
return WIFI_HAL_OPT_INVALID_PARAM;
|
||||
@ -728,7 +847,7 @@ WifiErrorNo HdiWpaStaStartWpsPbcMode(WifiWpsParam *config)
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
|
||||
int32_t result = wpaObj->WpsPbcMode(wpaObj, GetHdiStaIfaceName(), &wpsParam);
|
||||
int32_t result = wpaObj->WpsPbcMode(wpaObj, ifaceName, &wpsParam);
|
||||
if (result != HDF_SUCCESS) {
|
||||
LOGE("HdiWpaStaStartWpsPbcMode: WpsPbcMode failed result:%{public}d", result);
|
||||
pthread_mutex_unlock(GetWpaObjMutex());
|
||||
@ -739,9 +858,13 @@ WifiErrorNo HdiWpaStaStartWpsPbcMode(WifiWpsParam *config)
|
||||
return WIFI_HAL_OPT_OK;
|
||||
}
|
||||
|
||||
WifiErrorNo HdiWpaStaStartWpsPinMode(WifiWpsParam *config, int *pinCode)
|
||||
WifiErrorNo HdiWpaStaStartWpsPinMode(WifiWpsParam *config, int *pinCode, const char *ifaceName)
|
||||
{
|
||||
LOGI("HdiWpaStaStartWpsPinMode enter");
|
||||
if (ifaceName == NULL) {
|
||||
LOGE("HdiWpaStaStartWpsPinMode ifaceName is null");
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
LOGI("HdiWpaStaStartWpsPinMode enter! ifaceName = %{public}s", ifaceName);
|
||||
if (config == NULL || pinCode == NULL) {
|
||||
LOGE("HdiWpaStaStartWpsPinMode: invalid parameter!");
|
||||
return WIFI_HAL_OPT_INVALID_PARAM;
|
||||
@ -762,7 +885,7 @@ WifiErrorNo HdiWpaStaStartWpsPinMode(WifiWpsParam *config, int *pinCode)
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
|
||||
int32_t result = wpaObj->WpsPinMode(wpaObj, GetHdiStaIfaceName(), &wpsParam, pinCode);
|
||||
int32_t result = wpaObj->WpsPinMode(wpaObj, ifaceName, &wpsParam, pinCode);
|
||||
if (result != HDF_SUCCESS) {
|
||||
LOGE("HdiWpaStaStartWpsPinMode: WpsPbcMode failed result:%{public}d", result);
|
||||
pthread_mutex_unlock(GetWpaObjMutex());
|
||||
@ -773,9 +896,13 @@ WifiErrorNo HdiWpaStaStartWpsPinMode(WifiWpsParam *config, int *pinCode)
|
||||
return WIFI_HAL_OPT_OK;
|
||||
}
|
||||
|
||||
WifiErrorNo HdiStopWpsSta()
|
||||
WifiErrorNo HdiStopWpsSta(const char *ifaceName)
|
||||
{
|
||||
LOGI("HdiStopWpsSta enter");
|
||||
if (ifaceName == NULL) {
|
||||
LOGE("HdiStopWpsSta ifaceName is null");
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
LOGI("HdiStopWpsSta enter! ifaceName = %{public}s", ifaceName);
|
||||
pthread_mutex_lock(GetWpaObjMutex());
|
||||
struct IWpaInterface *wpaObj = GetWpaInterface();
|
||||
if (wpaObj == NULL) {
|
||||
@ -784,7 +911,7 @@ WifiErrorNo HdiStopWpsSta()
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
|
||||
int32_t result = wpaObj->WpsCancel(wpaObj, GetHdiStaIfaceName());
|
||||
int32_t result = wpaObj->WpsCancel(wpaObj, ifaceName);
|
||||
if (result != HDF_SUCCESS) {
|
||||
LOGE("HdiStopWpsSta: WpsCancel failed result:%{public}d", result);
|
||||
pthread_mutex_unlock(GetWpaObjMutex());
|
||||
@ -795,9 +922,13 @@ WifiErrorNo HdiStopWpsSta()
|
||||
return WIFI_HAL_OPT_OK;
|
||||
}
|
||||
|
||||
WifiErrorNo HdiWpaStaAutoConnect(int enable)
|
||||
WifiErrorNo HdiWpaStaAutoConnect(int enable, const char *ifaceName)
|
||||
{
|
||||
LOGI("HdiWpaStaAutoConnect enter, enable:%{public}d", enable);
|
||||
if (ifaceName == NULL) {
|
||||
LOGE("HdiWpaStaAutoConnect ifaceName is null");
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
LOGI("HdiWpaStaAutoConnect enter, enable:%{public}d, ifaceName = %{public}s", enable, ifaceName);
|
||||
pthread_mutex_lock(GetWpaObjMutex());
|
||||
struct IWpaInterface *wpaObj = GetWpaInterface();
|
||||
if (wpaObj == NULL) {
|
||||
@ -806,7 +937,7 @@ WifiErrorNo HdiWpaStaAutoConnect(int enable)
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
|
||||
int32_t result = wpaObj->AutoConnect(wpaObj, GetHdiStaIfaceName(), enable);
|
||||
int32_t result = wpaObj->AutoConnect(wpaObj, ifaceName, enable);
|
||||
if (result != HDF_SUCCESS) {
|
||||
LOGE("HdiWpaStaAutoConnect: AutoConnect failed result:%{public}d", result);
|
||||
pthread_mutex_unlock(GetWpaObjMutex());
|
||||
@ -817,9 +948,13 @@ WifiErrorNo HdiWpaStaAutoConnect(int enable)
|
||||
return WIFI_HAL_OPT_OK;
|
||||
}
|
||||
|
||||
WifiErrorNo HdiWpaStaBlocklistClear()
|
||||
WifiErrorNo HdiWpaStaBlocklistClear(const char *ifaceName)
|
||||
{
|
||||
LOGI("HdiWpaStaBlocklistClear enter");
|
||||
if (ifaceName == NULL) {
|
||||
LOGE("HdiWpaStaBlocklistClear ifaceName is null");
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
LOGI("HdiWpaStaBlocklistClear enter! ifaceName = %{public}s", ifaceName);
|
||||
pthread_mutex_lock(GetWpaObjMutex());
|
||||
struct IWpaInterface *wpaObj = GetWpaInterface();
|
||||
if (wpaObj == NULL) {
|
||||
@ -828,7 +963,7 @@ WifiErrorNo HdiWpaStaBlocklistClear()
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
|
||||
int32_t result = wpaObj->BlocklistClear(wpaObj, GetHdiStaIfaceName());
|
||||
int32_t result = wpaObj->BlocklistClear(wpaObj, ifaceName);
|
||||
if (result != HDF_SUCCESS) {
|
||||
LOGE("HdiWpaStaBlocklistClear: BlocklistClear failed result:%{public}d", result);
|
||||
pthread_mutex_unlock(GetWpaObjMutex());
|
||||
@ -839,9 +974,13 @@ WifiErrorNo HdiWpaStaBlocklistClear()
|
||||
return WIFI_HAL_OPT_OK;
|
||||
}
|
||||
|
||||
WifiErrorNo HdiWpaStaSetPowerSave(int enable)
|
||||
WifiErrorNo HdiWpaStaSetPowerSave(int enable, const char *ifaceName)
|
||||
{
|
||||
LOGI("HdiWpaStaSetPowerSave enter, enable:%{public}d", enable);
|
||||
if (ifaceName == NULL) {
|
||||
LOGE("HdiWpaStaSetPowerSave ifaceName is null");
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
LOGI("HdiWpaStaSetPowerSave enter, enable:%{public}d, ifaceName = %{public}s", enable, ifaceName);
|
||||
pthread_mutex_lock(GetWpaObjMutex());
|
||||
struct IWpaInterface *wpaObj = GetWpaInterface();
|
||||
if (wpaObj == NULL) {
|
||||
@ -850,7 +989,7 @@ WifiErrorNo HdiWpaStaSetPowerSave(int enable)
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
|
||||
int32_t result = wpaObj->SetPowerSave(wpaObj, GetHdiStaIfaceName(), enable);
|
||||
int32_t result = wpaObj->SetPowerSave(wpaObj, ifaceName, enable);
|
||||
if (result != HDF_SUCCESS) {
|
||||
LOGE("HdiWpaStaSetPowerSave: SetPowerSave failed result:%{public}d", result);
|
||||
pthread_mutex_unlock(GetWpaObjMutex());
|
||||
@ -861,9 +1000,13 @@ WifiErrorNo HdiWpaStaSetPowerSave(int enable)
|
||||
return WIFI_HAL_OPT_OK;
|
||||
}
|
||||
|
||||
WifiErrorNo HdiWpaStaSetCountryCode(const char *countryCode)
|
||||
WifiErrorNo HdiWpaStaSetCountryCode(const char *countryCode, const char *ifaceName)
|
||||
{
|
||||
LOGI("HdiWpaStaSetCountryCode enter, enable:%{public}s", countryCode);
|
||||
if (ifaceName == NULL) {
|
||||
LOGE("HdiWpaStaSetCountryCode ifaceName is null");
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
LOGI("HdiWpaStaSetCountryCode enter, enable:%{public}s, ifaceName = %{public}s", countryCode, ifaceName);
|
||||
pthread_mutex_lock(GetWpaObjMutex());
|
||||
struct IWpaInterface *wpaObj = GetWpaInterface();
|
||||
if (wpaObj == NULL) {
|
||||
@ -872,7 +1015,7 @@ WifiErrorNo HdiWpaStaSetCountryCode(const char *countryCode)
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
|
||||
int32_t result = wpaObj->SetCountryCode(wpaObj, GetHdiStaIfaceName(), countryCode);
|
||||
int32_t result = wpaObj->SetCountryCode(wpaObj, ifaceName, countryCode);
|
||||
if (result != HDF_SUCCESS) {
|
||||
LOGE("HdiWpaStaSetCountryCode: SetCountryCode failed result:%{public}d", result);
|
||||
pthread_mutex_unlock(GetWpaObjMutex());
|
||||
@ -883,9 +1026,13 @@ WifiErrorNo HdiWpaStaSetCountryCode(const char *countryCode)
|
||||
return WIFI_HAL_OPT_OK;
|
||||
}
|
||||
|
||||
WifiErrorNo HdiWpaStaGetCountryCode(char *countryCode, uint32_t size)
|
||||
WifiErrorNo HdiWpaStaGetCountryCode(char *countryCode, uint32_t size, const char *ifaceName)
|
||||
{
|
||||
LOGI("HdiWpaStaGetCountryCode enter, enable:%{public}s", countryCode);
|
||||
if (ifaceName == NULL) {
|
||||
LOGE("HdiWpaStaGetCountryCode ifaceName is null");
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
LOGI("HdiWpaStaGetCountryCode enter, enable:%{public}s, ifaceName = %{public}s", countryCode, ifaceName);
|
||||
pthread_mutex_lock(GetWpaObjMutex());
|
||||
struct IWpaInterface *wpaObj = GetWpaInterface();
|
||||
if (wpaObj == NULL) {
|
||||
@ -894,7 +1041,7 @@ WifiErrorNo HdiWpaStaGetCountryCode(char *countryCode, uint32_t size)
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
|
||||
int32_t result = wpaObj->GetCountryCode(wpaObj, GetHdiStaIfaceName(), countryCode, size);
|
||||
int32_t result = wpaObj->GetCountryCode(wpaObj, ifaceName, countryCode, size);
|
||||
if (result != HDF_SUCCESS) {
|
||||
LOGE("HdiWpaStaGetCountryCode: SetCountryCode failed result:%{public}d", result);
|
||||
pthread_mutex_unlock(GetWpaObjMutex());
|
||||
@ -905,9 +1052,13 @@ WifiErrorNo HdiWpaStaGetCountryCode(char *countryCode, uint32_t size)
|
||||
return WIFI_HAL_OPT_OK;
|
||||
}
|
||||
|
||||
WifiErrorNo HdiWpaStaSetSuspendMode(int mode)
|
||||
WifiErrorNo HdiWpaStaSetSuspendMode(int mode, const char *ifaceName)
|
||||
{
|
||||
LOGI("HdiWpaStaSetSuspendMode enter, mode:%{public}d", mode);
|
||||
if (ifaceName == NULL) {
|
||||
LOGE("HdiWpaStaSetSuspendMode ifaceName is null");
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
LOGI("HdiWpaStaSetSuspendMode enter, mode:%{public}d, ifaceName = %{public}s", mode, ifaceName);
|
||||
pthread_mutex_lock(GetWpaObjMutex());
|
||||
struct IWpaInterface *wpaObj = GetWpaInterface();
|
||||
if (wpaObj == NULL) {
|
||||
@ -916,7 +1067,7 @@ WifiErrorNo HdiWpaStaSetSuspendMode(int mode)
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
|
||||
int32_t result = wpaObj->SetSuspendMode(wpaObj, GetHdiStaIfaceName(), mode);
|
||||
int32_t result = wpaObj->SetSuspendMode(wpaObj, ifaceName, mode);
|
||||
if (result != HDF_SUCCESS) {
|
||||
LOGE("HdiWpaStaSetSuspendMode: SetSuspendMode failed result:%{public}d", result);
|
||||
pthread_mutex_unlock(GetWpaObjMutex());
|
||||
@ -927,9 +1078,13 @@ WifiErrorNo HdiWpaStaSetSuspendMode(int mode)
|
||||
return WIFI_HAL_OPT_OK;
|
||||
}
|
||||
|
||||
WifiErrorNo HdiWpaListNetworks(struct HdiWifiWpaNetworkInfo *networkList, uint32_t *size)
|
||||
WifiErrorNo HdiWpaListNetworks(struct HdiWifiWpaNetworkInfo *networkList, uint32_t *size, const char *ifaceName)
|
||||
{
|
||||
LOGI("HdiWpaListNetworks enter");
|
||||
if (ifaceName == NULL) {
|
||||
LOGE("HdiWpaListNetworks ifaceName is null");
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
LOGI("HdiWpaListNetworks enter! ifaceName = %{public}s", ifaceName);
|
||||
pthread_mutex_lock(GetWpaObjMutex());
|
||||
struct IWpaInterface *wpaObj = GetWpaInterface();
|
||||
if (wpaObj == NULL) {
|
||||
@ -938,7 +1093,7 @@ WifiErrorNo HdiWpaListNetworks(struct HdiWifiWpaNetworkInfo *networkList, uint32
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
|
||||
int32_t result = wpaObj->ListNetworks(wpaObj, GetHdiStaIfaceName(), networkList, size);
|
||||
int32_t result = wpaObj->ListNetworks(wpaObj, ifaceName, networkList, size);
|
||||
if (result != HDF_SUCCESS) {
|
||||
LOGE("HdiWpaListNetworks: ListNetworks failed result:%{public}d", result);
|
||||
pthread_mutex_unlock(GetWpaObjMutex());
|
||||
@ -949,9 +1104,14 @@ WifiErrorNo HdiWpaListNetworks(struct HdiWifiWpaNetworkInfo *networkList, uint32
|
||||
return WIFI_HAL_OPT_OK;
|
||||
}
|
||||
|
||||
WifiErrorNo HdiWpaGetNetwork(int32_t networkId, const char* param, char* value, uint32_t valueLen)
|
||||
WifiErrorNo HdiWpaGetNetwork(
|
||||
int32_t networkId, const char* param, char* value, uint32_t valueLen, const char *ifaceName)
|
||||
{
|
||||
LOGI("HdiWpaGetNetwork enter,networkId:%{public}d", networkId);
|
||||
if (ifaceName == NULL) {
|
||||
LOGE("HdiWpaGetNetwork ifaceName is null");
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
LOGI("HdiWpaGetNetwork enter,networkId:%{public}d, ifaceName = %{public}s", networkId, ifaceName);
|
||||
pthread_mutex_lock(GetWpaObjMutex());
|
||||
struct IWpaInterface *wpaObj = GetWpaInterface();
|
||||
if (wpaObj == NULL) {
|
||||
@ -960,7 +1120,7 @@ WifiErrorNo HdiWpaGetNetwork(int32_t networkId, const char* param, char* value,
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
|
||||
int32_t result = wpaObj->GetNetwork(wpaObj, GetHdiStaIfaceName(), networkId, param, value, valueLen);
|
||||
int32_t result = wpaObj->GetNetwork(wpaObj, ifaceName, networkId, param, value, valueLen);
|
||||
if (result != HDF_SUCCESS) {
|
||||
LOGE("HdiWpaGetNetwork: GetNetwork failed result:%{public}d", result);
|
||||
pthread_mutex_unlock(GetWpaObjMutex());
|
||||
|
@ -24,59 +24,60 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
WifiErrorNo HdiWpaStaStart(const char *ifaceName);
|
||||
WifiErrorNo HdiWpaStaStart(const char *ifaceName, int instId);
|
||||
|
||||
WifiErrorNo HdiWpaStaStop();
|
||||
WifiErrorNo HdiWpaStaStop(int instId);
|
||||
|
||||
WifiErrorNo HdiWpaStaConnect(int networkId);
|
||||
WifiErrorNo HdiWpaStaConnect(int networkId, const char *ifaceName);
|
||||
|
||||
WifiErrorNo HdiWpaStaReconnect();
|
||||
WifiErrorNo HdiWpaStaReconnect(const char *ifaceName);
|
||||
|
||||
WifiErrorNo HdiWpaStaReassociate();
|
||||
WifiErrorNo HdiWpaStaReassociate(const char *ifaceName);
|
||||
|
||||
WifiErrorNo HdiWpaStaDisconnect();
|
||||
WifiErrorNo HdiWpaStaDisconnect(const char *ifaceName);
|
||||
|
||||
WifiErrorNo HdiWpaStaGetDeviceMacAddress(char *macAddr, int macAddrLen);
|
||||
WifiErrorNo HdiWpaStaGetDeviceMacAddress(char *macAddr, int macAddrLen, const char *ifaceName);
|
||||
|
||||
WifiErrorNo HdiWpaStaScan();
|
||||
|
||||
ScanInfo *HdiWpaStaGetScanInfos(int *size);
|
||||
ScanInfo *HdiWpaStaGetScanInfos(int *size, const char *ifaceName);
|
||||
|
||||
WifiErrorNo HdiWpaStaRemoveNetwork(int networkId);
|
||||
WifiErrorNo HdiWpaStaRemoveNetwork(int networkId, const char *ifaceName);
|
||||
|
||||
WifiErrorNo HdiWpaStaAddNetwork(int *networkId);
|
||||
WifiErrorNo HdiWpaStaAddNetwork(int *networkId, const char *ifaceName);
|
||||
|
||||
WifiErrorNo HdiWpaStaEnableNetwork(int networkId);
|
||||
WifiErrorNo HdiWpaStaEnableNetwork(int networkId, const char *ifaceName);
|
||||
|
||||
WifiErrorNo HdiWpaStaDisableNetwork(int networkId);
|
||||
WifiErrorNo HdiWpaStaDisableNetwork(int networkId, const char *ifaceName);
|
||||
|
||||
WifiErrorNo HdiWpaStaSetNetwork(int networkId, SetNetworkConfig *confs, int size);
|
||||
WifiErrorNo HdiWpaStaSetNetwork(int networkId, SetNetworkConfig *confs, int size, const char *ifaceName);
|
||||
|
||||
WifiErrorNo HdiWpaStaSaveConfig();
|
||||
WifiErrorNo HdiWpaStaSaveConfig(const char *ifaceName);
|
||||
|
||||
WifiErrorNo RegisterHdiWpaStaEventCallback(struct IWpaCallback *callback);
|
||||
WifiErrorNo RegisterHdiWpaStaEventCallback(struct IWpaCallback *callback, const char *ifaceName, int instId);
|
||||
|
||||
WifiErrorNo HdiWpaStaStartWpsPbcMode(WifiWpsParam *config);
|
||||
WifiErrorNo HdiWpaStaStartWpsPbcMode(WifiWpsParam *config, const char *ifaceName);
|
||||
|
||||
WifiErrorNo HdiWpaStaStartWpsPinMode(WifiWpsParam *config, int *pinCode);
|
||||
WifiErrorNo HdiWpaStaStartWpsPinMode(WifiWpsParam *config, int *pinCode, const char *ifaceName);
|
||||
|
||||
WifiErrorNo HdiStopWpsSta();
|
||||
WifiErrorNo HdiStopWpsSta(const char *ifaceName);
|
||||
|
||||
WifiErrorNo HdiWpaStaAutoConnect(int enable);
|
||||
WifiErrorNo HdiWpaStaAutoConnect(int enable, const char *ifaceName);
|
||||
|
||||
WifiErrorNo HdiWpaStaBlocklistClear();
|
||||
WifiErrorNo HdiWpaStaBlocklistClear(const char *ifaceName);
|
||||
|
||||
WifiErrorNo HdiWpaStaSetPowerSave(int enable);
|
||||
WifiErrorNo HdiWpaStaSetPowerSave(int enable, const char *ifaceName);
|
||||
|
||||
WifiErrorNo HdiWpaStaSetCountryCode(const char *countryCode);
|
||||
WifiErrorNo HdiWpaStaSetCountryCode(const char *countryCode, const char *ifaceName);
|
||||
|
||||
WifiErrorNo HdiWpaStaSetSuspendMode(int mode);
|
||||
WifiErrorNo HdiWpaStaSetSuspendMode(int mode, const char *ifaceName);
|
||||
|
||||
WifiErrorNo HdiWpaStaGetCountryCode(char *countryCode, uint32_t size);
|
||||
WifiErrorNo HdiWpaStaGetCountryCode(char *countryCode, uint32_t size, const char *ifaceName);
|
||||
|
||||
WifiErrorNo HdiWpaListNetworks(struct HdiWifiWpaNetworkInfo *networkList, uint32_t *size);
|
||||
WifiErrorNo HdiWpaListNetworks(struct HdiWifiWpaNetworkInfo *networkList, uint32_t *size, const char *ifaceName);
|
||||
|
||||
WifiErrorNo HdiWpaGetNetwork(int32_t networkId, const char* param, char* value, uint32_t valueLen);
|
||||
WifiErrorNo HdiWpaGetNetwork(
|
||||
int32_t networkId, const char* param, char* value, uint32_t valueLen, const char *ifaceName);
|
||||
|
||||
WifiErrorNo HdiWpaStaSetShellCmd(const char *ifName, const char *cmd);
|
||||
|
||||
|
@ -45,7 +45,11 @@ int g_currentWpaStatus = static_cast<int>(OHOS::Wifi::SupplicantState::UNKNOWN);
|
||||
int32_t OnEventDisconnected(struct IWpaCallback *self,
|
||||
const struct HdiWpaDisconnectParam *disconectParam, const char* ifName)
|
||||
{
|
||||
LOGI("OnEventDisconnected: callback enter!");
|
||||
if (ifName == nullptr) {
|
||||
LOGE("OnEventDisconnected: invalid ifName!");
|
||||
return 1;
|
||||
}
|
||||
LOGI("OnEventDisconnected: callback enter! ifName = %{public}s", ifName);
|
||||
if (disconectParam == NULL || disconectParam->bssidLen <= 0) {
|
||||
LOGE("OnEventDisconnected: invalid parameter!");
|
||||
return 1;
|
||||
@ -57,7 +61,7 @@ int32_t OnEventDisconnected(struct IWpaCallback *self,
|
||||
return 1;
|
||||
}
|
||||
int reasonCode = disconectParam->reasonCode;
|
||||
const OHOS::Wifi::WifiEventCallback &cbk = OHOS::Wifi::WifiStaHalInterface::GetInstance().GetCallbackInst();
|
||||
const OHOS::Wifi::WifiEventCallback &cbk = OHOS::Wifi::WifiStaHalInterface::GetInstance().GetCallbackInst(ifName);
|
||||
if (cbk.onReportDisConnectReason) {
|
||||
cbk.onReportDisConnectReason(reasonCode, std::string(szBssid));
|
||||
}
|
||||
@ -82,14 +86,21 @@ int32_t OnEventDisconnected(struct IWpaCallback *self,
|
||||
if (cbk.onConnectChanged) {
|
||||
cbk.onConnectChanged(HAL_WPA_CB_DISCONNECTED, reasonCode, std::string(szBssid));
|
||||
}
|
||||
LOGI("%{public}s callback out, bssid:%{public}s", __func__, OHOS::Wifi::MacAnonymize(szBssid).c_str());
|
||||
LOGI("%{public}s callback out, bssid:%{public}s ifName = %{public}s",
|
||||
__func__,
|
||||
OHOS::Wifi::MacAnonymize(szBssid).c_str(),
|
||||
ifName);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t OnEventConnected(struct IWpaCallback *self,
|
||||
const struct HdiWpaConnectParam *connectParam, const char* ifName)
|
||||
{
|
||||
LOGI("OnEventConnected: callback enter!");
|
||||
if (ifName == nullptr) {
|
||||
LOGE("OnEventConnected: invalid ifName!");
|
||||
return 1;
|
||||
}
|
||||
LOGI("OnEventConnected: callback enter! ifName = %{public}s", ifName);
|
||||
if (connectParam == NULL || connectParam->bssidLen <= 0) {
|
||||
LOGE("OnEventConnected: invalid parameter!");
|
||||
return 1;
|
||||
@ -100,7 +111,7 @@ int32_t OnEventConnected(struct IWpaCallback *self,
|
||||
LOGE("%{public}s: failed to convert mac!", __func__);
|
||||
return 1;
|
||||
}
|
||||
const OHOS::Wifi::WifiEventCallback &cbk = OHOS::Wifi::WifiStaHalInterface::GetInstance().GetCallbackInst();
|
||||
const OHOS::Wifi::WifiEventCallback &cbk = OHOS::Wifi::WifiStaHalInterface::GetInstance().GetCallbackInst(ifName);
|
||||
if (cbk.onConnectChanged) {
|
||||
cbk.onConnectChanged(HAL_WPA_CB_CONNECTED, connectParam->networkId, szBssid);
|
||||
}
|
||||
@ -111,7 +122,11 @@ int32_t OnEventConnected(struct IWpaCallback *self,
|
||||
int32_t OnEventBssidChanged(struct IWpaCallback *self,
|
||||
const struct HdiWpaBssidChangedParam *bssidChangedParam, const char* ifName)
|
||||
{
|
||||
LOGI("OnEventBssidChanged: callback enter!");
|
||||
if (ifName == nullptr) {
|
||||
LOGE("OnEventBssidChanged: invalid ifName!");
|
||||
return 1;
|
||||
}
|
||||
LOGI("OnEventBssidChanged: callback enter! ifName = %{public}s", ifName);
|
||||
if (bssidChangedParam == nullptr || bssidChangedParam->reason == nullptr) {
|
||||
LOGE("OnEventBssidChanged: invalid parameter!");
|
||||
return 1;
|
||||
@ -129,7 +144,7 @@ int32_t OnEventBssidChanged(struct IWpaCallback *self,
|
||||
return 1;
|
||||
}
|
||||
|
||||
const OHOS::Wifi::WifiEventCallback &cbk = OHOS::Wifi::WifiStaHalInterface::GetInstance().GetCallbackInst();
|
||||
const OHOS::Wifi::WifiEventCallback &cbk = OHOS::Wifi::WifiStaHalInterface::GetInstance().GetCallbackInst(ifName);
|
||||
if (cbk.onBssidChanged) {
|
||||
cbk.onBssidChanged(reason, szBssid);
|
||||
}
|
||||
@ -141,25 +156,33 @@ int32_t OnEventBssidChanged(struct IWpaCallback *self,
|
||||
int32_t OnEventStateChanged(struct IWpaCallback *self,
|
||||
const struct HdiWpaStateChangedParam *statechangedParam, const char* ifName)
|
||||
{
|
||||
LOGI("OnEventStateChanged: callback enter!");
|
||||
if (ifName == nullptr) {
|
||||
LOGE("OnEventStateChanged: invalid ifName!");
|
||||
return 1;
|
||||
}
|
||||
LOGI("OnEventStateChanged: callback enter! ifName = %{public}s", ifName);
|
||||
if (statechangedParam == NULL) {
|
||||
LOGE("OnEventStateChanged: invalid parameter!");
|
||||
return 1;
|
||||
}
|
||||
|
||||
const OHOS::Wifi::WifiEventCallback &cbk = OHOS::Wifi::WifiStaHalInterface::GetInstance().GetCallbackInst();
|
||||
const OHOS::Wifi::WifiEventCallback &cbk = OHOS::Wifi::WifiStaHalInterface::GetInstance().GetCallbackInst(ifName);
|
||||
g_currentWpaStatus = statechangedParam->status;
|
||||
if (cbk.onWpaStateChanged) {
|
||||
cbk.onWpaStateChanged(g_currentWpaStatus);
|
||||
}
|
||||
LOGI("OnEventStateChanged:callback out status = %{public}d", g_currentWpaStatus);
|
||||
LOGI("OnEventStateChanged:callback out status = %{public}d, ifName = %{public}s", g_currentWpaStatus, ifName);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t OnEventTempDisabled(struct IWpaCallback *self,
|
||||
const struct HdiWpaTempDisabledParam *tempDisabledParam, const char *ifName)
|
||||
{
|
||||
LOGI("OnEventTempDisabled: callback enter!");
|
||||
if (ifName == nullptr) {
|
||||
LOGE("OnEventTempDisabled: invalid ifName!");
|
||||
return 1;
|
||||
}
|
||||
LOGI("OnEventTempDisabled: callback enter! ifName = %{public}s", ifName);
|
||||
|
||||
if (tempDisabledParam == NULL) {
|
||||
LOGE("OnEventTempDisabled tempDisabledParam is NULL");
|
||||
@ -173,9 +196,11 @@ int32_t OnEventTempDisabled(struct IWpaCallback *self,
|
||||
if (tempDisabledParam->reason != NULL && tempDisabledParam->reasonLen > 0) {
|
||||
reason = std::string(tempDisabledParam->reason, tempDisabledParam->reason + tempDisabledParam->reasonLen);
|
||||
}
|
||||
LOGI("OnEventTempDisabled ssid:%{public}s reason:%{public}s",
|
||||
OHOS::Wifi::SsidAnonymize(ssid).c_str(), reason.c_str());
|
||||
const OHOS::Wifi::WifiEventCallback &cbk = OHOS::Wifi::WifiStaHalInterface::GetInstance().GetCallbackInst();
|
||||
LOGI("OnEventTempDisabled ssid:%{public}s reason:%{public}s, ifName = %{public}s",
|
||||
OHOS::Wifi::SsidAnonymize(ssid).c_str(),
|
||||
reason.c_str(),
|
||||
ifName);
|
||||
const OHOS::Wifi::WifiEventCallback &cbk = OHOS::Wifi::WifiStaHalInterface::GetInstance().GetCallbackInst(ifName);
|
||||
if (cbk.onWpaSsidWrongKey && reason == "AUTH_FAILED") {
|
||||
cbk.onWpaSsidWrongKey();
|
||||
}
|
||||
@ -185,7 +210,11 @@ int32_t OnEventTempDisabled(struct IWpaCallback *self,
|
||||
int32_t OnEventAssociateReject(struct IWpaCallback *self,
|
||||
const struct HdiWpaAssociateRejectParam *associateRejectParam, const char *ifName)
|
||||
{
|
||||
LOGI("OnEventAssociateReject: callback enter!");
|
||||
if (ifName == nullptr) {
|
||||
LOGE("OnEventAssociateReject: invalid ifName!");
|
||||
return 1;
|
||||
}
|
||||
LOGI("OnEventAssociateReject: callback enter! ifName = %{public}s", ifName);
|
||||
if (associateRejectParam == NULL) {
|
||||
LOGE("OnEventAssociateReject: invalid parameter!");
|
||||
return 1;
|
||||
@ -215,7 +244,7 @@ int32_t OnEventAssociateReject(struct IWpaCallback *self,
|
||||
}
|
||||
}
|
||||
}
|
||||
const OHOS::Wifi::WifiEventCallback &cbk = OHOS::Wifi::WifiStaHalInterface::GetInstance().GetCallbackInst();
|
||||
const OHOS::Wifi::WifiEventCallback &cbk = OHOS::Wifi::WifiStaHalInterface::GetInstance().GetCallbackInst(ifName);
|
||||
if (isWrongPwd && cbk.onWpaSsidWrongKey) {
|
||||
LOGI("onWpaConnectionRejectCallBack, wrong password");
|
||||
cbk.onWpaSsidWrongKey();
|
||||
@ -238,14 +267,19 @@ int32_t OnEventAssociateReject(struct IWpaCallback *self,
|
||||
|
||||
int32_t OnEventStaNotify(struct IWpaCallback *self, const char* notifyParam, const char *ifName)
|
||||
{
|
||||
LOGI("OnEventStaNotify: callback enter!");
|
||||
if (ifName == nullptr) {
|
||||
LOGE("OnEventStaNotify: invalid ifName!");
|
||||
return 1;
|
||||
}
|
||||
LOGI("OnEventStaNotify: callback enter! ifName = %{public}s", ifName);
|
||||
if (notifyParam == NULL) {
|
||||
LOGE("OnEventStaNotify: invalid parameter!");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (strcmp(ifName, "wlan0") == 0) {
|
||||
const OHOS::Wifi::WifiEventCallback &cbk = OHOS::Wifi::WifiStaHalInterface::GetInstance().GetCallbackInst();
|
||||
if (strcmp(ifName, "wlan0") == 0 || strcmp(ifName, "wlan1") == 0) {
|
||||
const OHOS::Wifi::WifiEventCallback &cbk =
|
||||
OHOS::Wifi::WifiStaHalInterface::GetInstance().GetCallbackInst(ifName);
|
||||
if (cbk.onEventStaNotify) {
|
||||
cbk.onEventStaNotify(notifyParam);
|
||||
}
|
||||
@ -260,8 +294,12 @@ int32_t OnEventStaNotify(struct IWpaCallback *self, const char* notifyParam, con
|
||||
|
||||
int32_t OnEventWpsOverlap(struct IWpaCallback *self, const char *ifName)
|
||||
{
|
||||
LOGI("OnEventWpsOverlap: callback enter!");
|
||||
const OHOS::Wifi::WifiEventCallback &cbk = OHOS::Wifi::WifiStaHalInterface::GetInstance().GetCallbackInst();
|
||||
if (ifName == nullptr) {
|
||||
LOGE("OnEventWpsOverlap: invalid ifName!");
|
||||
return 1;
|
||||
}
|
||||
LOGI("OnEventWpsOverlap: callback enter! ifName = %{public}s", ifName);
|
||||
const OHOS::Wifi::WifiEventCallback &cbk = OHOS::Wifi::WifiStaHalInterface::GetInstance().GetCallbackInst(ifName);
|
||||
if (cbk.onWpsOverlap) {
|
||||
cbk.onWpsOverlap(1);
|
||||
}
|
||||
@ -270,8 +308,12 @@ int32_t OnEventWpsOverlap(struct IWpaCallback *self, const char *ifName)
|
||||
|
||||
int32_t OnEventWpsTimeout(struct IWpaCallback *self, const char *ifName)
|
||||
{
|
||||
LOGI("OnEventWpsTimeout: callback enter!");
|
||||
const OHOS::Wifi::WifiEventCallback &cbk = OHOS::Wifi::WifiStaHalInterface::GetInstance().GetCallbackInst();
|
||||
if (ifName == nullptr) {
|
||||
LOGE("OnEventWpsOverlap: invalid ifName!");
|
||||
return 1;
|
||||
}
|
||||
LOGI("OnEventWpsTimeout: callback enter! ifName = %{public}s", ifName);
|
||||
const OHOS::Wifi::WifiEventCallback &cbk = OHOS::Wifi::WifiStaHalInterface::GetInstance().GetCallbackInst(ifName);
|
||||
if (cbk.onWpsTimeOut) {
|
||||
cbk.onWpsTimeOut(1);
|
||||
}
|
||||
@ -280,8 +322,12 @@ int32_t OnEventWpsTimeout(struct IWpaCallback *self, const char *ifName)
|
||||
|
||||
int32_t OnEventAuthTimeout(struct IWpaCallback *self, const char *ifName)
|
||||
{
|
||||
LOGI("OnEventAuthTimeout: callback enter!");
|
||||
const OHOS::Wifi::WifiEventCallback &cbk = OHOS::Wifi::WifiStaHalInterface::GetInstance().GetCallbackInst();
|
||||
if (ifName == nullptr) {
|
||||
LOGE("OnEventWpsOverlap: invalid ifName!");
|
||||
return 1;
|
||||
}
|
||||
LOGI("OnEventAuthTimeout: callback enter! ifName = %{public}s", ifName);
|
||||
const OHOS::Wifi::WifiEventCallback &cbk = OHOS::Wifi::WifiStaHalInterface::GetInstance().GetCallbackInst(ifName);
|
||||
if (g_currentWpaStatus == static_cast<int>(OHOS::Wifi::SupplicantState::FOUR_WAY_HANDSHAKE) &&
|
||||
cbk.onWpaSsidWrongKey) {
|
||||
LOGI("OnEventAuthTimeout, wrong password");
|
||||
|
@ -31,6 +31,8 @@
|
||||
#include "wifi_common_util.h"
|
||||
#include "wifi_common_def.h"
|
||||
#include "hdi_struct_toolkit.h"
|
||||
#include "wifi_hdi_wpa_proxy.h"
|
||||
#include "define.h"
|
||||
|
||||
#ifndef UT_TEST
|
||||
#include "wifi_log.h"
|
||||
@ -62,37 +64,38 @@ constexpr int P2P_SUPPLICANT_CONNECTED = 1;
|
||||
constexpr int SSID_ASSIC_WIDTH = 2;
|
||||
constexpr int BAND_WIDTH_OFFSET = 16;
|
||||
|
||||
WifiErrorNo WifiHdiWpaClient::StartWifi(const std::string &ifaceName)
|
||||
WifiErrorNo WifiHdiWpaClient::StartWifi(const std::string &ifaceName, int instId)
|
||||
{
|
||||
WifiEventCallback callback;
|
||||
callback.onConnectChanged = [](int param1, int param2, const std::string ¶m3) {};
|
||||
ReqRegisterStaEventCallback(callback);
|
||||
return HdiWpaStaStart(ifaceName.c_str());
|
||||
ReqRegisterStaEventCallback(callback, ifaceName.c_str(), instId);
|
||||
LOGI("WifiHdiWpaClient StartWifi ifaceName:%{public}s instId:%{public}d", ifaceName.c_str(), instId);
|
||||
return HdiWpaStaStart(ifaceName.c_str(), instId);
|
||||
}
|
||||
|
||||
WifiErrorNo WifiHdiWpaClient::StopWifi(void)
|
||||
WifiErrorNo WifiHdiWpaClient::StopWifi(int instId)
|
||||
{
|
||||
return HdiWpaStaStop();
|
||||
return HdiWpaStaStop(instId);
|
||||
}
|
||||
|
||||
WifiErrorNo WifiHdiWpaClient::ReqConnect(int networkId)
|
||||
WifiErrorNo WifiHdiWpaClient::ReqConnect(int networkId, const char *ifaceName)
|
||||
{
|
||||
return HdiWpaStaConnect(networkId);
|
||||
return HdiWpaStaConnect(networkId, ifaceName);
|
||||
}
|
||||
|
||||
WifiErrorNo WifiHdiWpaClient::ReqReconnect(void)
|
||||
WifiErrorNo WifiHdiWpaClient::ReqReconnect(const char *ifaceName)
|
||||
{
|
||||
return HdiWpaStaReconnect();
|
||||
return HdiWpaStaReconnect(ifaceName);
|
||||
}
|
||||
|
||||
WifiErrorNo WifiHdiWpaClient::ReqReassociate(void)
|
||||
WifiErrorNo WifiHdiWpaClient::ReqReassociate(const char *ifaceName)
|
||||
{
|
||||
return HdiWpaStaReassociate();
|
||||
return HdiWpaStaReassociate(ifaceName);
|
||||
}
|
||||
|
||||
WifiErrorNo WifiHdiWpaClient::ReqDisconnect(void)
|
||||
WifiErrorNo WifiHdiWpaClient::ReqDisconnect(const char *ifaceName)
|
||||
{
|
||||
return HdiWpaStaDisconnect();
|
||||
return HdiWpaStaDisconnect(ifaceName);
|
||||
}
|
||||
|
||||
WifiErrorNo WifiHdiWpaClient::GetStaCapabilities(unsigned int &capabilities)
|
||||
@ -101,11 +104,11 @@ WifiErrorNo WifiHdiWpaClient::GetStaCapabilities(unsigned int &capabilities)
|
||||
return WIFI_HAL_OPT_OK;
|
||||
}
|
||||
|
||||
WifiErrorNo WifiHdiWpaClient::GetStaDeviceMacAddress(std::string &mac)
|
||||
WifiErrorNo WifiHdiWpaClient::GetStaDeviceMacAddress(std::string &mac, const char *ifaceName)
|
||||
{
|
||||
char macAddr[HAL_BSSID_LENGTH + 1] = {0};
|
||||
int macAddrLen = HAL_BSSID_LENGTH + 1;
|
||||
WifiErrorNo err = HdiWpaStaGetDeviceMacAddress(macAddr, macAddrLen);
|
||||
WifiErrorNo err = HdiWpaStaGetDeviceMacAddress(macAddr, macAddrLen, ifaceName);
|
||||
if (err == WIFI_HAL_OPT_OK) {
|
||||
mac = std::string(macAddr);
|
||||
}
|
||||
@ -131,7 +134,7 @@ WifiErrorNo WifiHdiWpaClient::QueryScanInfos(std::vector<InterScanInfo> &scanInf
|
||||
{
|
||||
LOGI("WifiHdiWpaClient::%{public}s enter", __func__);
|
||||
int size = HAL_GET_MAX_SCAN_INFO;
|
||||
ScanInfo* results = HdiWpaStaGetScanInfos(&size);
|
||||
ScanInfo *results = HdiWpaStaGetScanInfos(&size, GetHdiStaIfaceName(INSTID_WLAN0));
|
||||
if (results == NULL) {
|
||||
return size == 0 ? WIFI_HAL_OPT_OK : WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
@ -186,33 +189,33 @@ WifiErrorNo WifiHdiWpaClient::ReqStopPnoScan(void)
|
||||
return WIFI_HAL_OPT_NOT_SUPPORT;
|
||||
}
|
||||
|
||||
WifiErrorNo WifiHdiWpaClient::RemoveDevice(int networkId)
|
||||
WifiErrorNo WifiHdiWpaClient::RemoveDevice(int networkId, const char *ifaceName)
|
||||
{
|
||||
if (networkId < 0) {
|
||||
return WIFI_HAL_OPT_INVALID_PARAM;
|
||||
}
|
||||
|
||||
return HdiWpaStaRemoveNetwork(networkId);
|
||||
return HdiWpaStaRemoveNetwork(networkId, ifaceName);
|
||||
}
|
||||
|
||||
WifiErrorNo WifiHdiWpaClient::ClearDeviceConfig(void) const
|
||||
WifiErrorNo WifiHdiWpaClient::ClearDeviceConfig(const char *ifaceName) const
|
||||
{
|
||||
return HdiWpaStaRemoveNetwork(-1);
|
||||
return HdiWpaStaRemoveNetwork(-1, ifaceName);
|
||||
}
|
||||
|
||||
WifiErrorNo WifiHdiWpaClient::GetNextNetworkId(int &networkId)
|
||||
WifiErrorNo WifiHdiWpaClient::GetNextNetworkId(int &networkId, const char *ifaceName)
|
||||
{
|
||||
return HdiWpaStaAddNetwork(&networkId);
|
||||
return HdiWpaStaAddNetwork(&networkId, ifaceName);
|
||||
}
|
||||
|
||||
WifiErrorNo WifiHdiWpaClient::ReqEnableNetwork(int networkId)
|
||||
WifiErrorNo WifiHdiWpaClient::ReqEnableNetwork(int networkId, const char *ifaceName)
|
||||
{
|
||||
return HdiWpaStaEnableNetwork(networkId);
|
||||
return HdiWpaStaEnableNetwork(networkId, ifaceName);
|
||||
}
|
||||
|
||||
WifiErrorNo WifiHdiWpaClient::ReqDisableNetwork(int networkId)
|
||||
WifiErrorNo WifiHdiWpaClient::ReqDisableNetwork(int networkId, const char *ifaceName)
|
||||
{
|
||||
return HdiWpaStaDisableNetwork(networkId);
|
||||
return HdiWpaStaDisableNetwork(networkId, ifaceName);
|
||||
}
|
||||
|
||||
void WifiHdiWpaClient::SetWapiConfig(const WifiHalDeviceConfig &config, SetNetworkConfig *conf, int &num)
|
||||
@ -229,7 +232,7 @@ void WifiHdiWpaClient::SetWapiConfig(const WifiHalDeviceConfig &config, SetNetwo
|
||||
}
|
||||
}
|
||||
|
||||
WifiErrorNo WifiHdiWpaClient::SetDeviceConfig(int networkId, const WifiHalDeviceConfig &config)
|
||||
WifiErrorNo WifiHdiWpaClient::SetDeviceConfig(int networkId, const WifiHalDeviceConfig &config, const char *ifaceName)
|
||||
{
|
||||
if (CheckValidDeviceConfig(config) != WIFI_HAL_OPT_OK) {
|
||||
LOGE("SetDeviceConfig, CheckValidDeviceConfig return error!");
|
||||
@ -353,10 +356,10 @@ WifiErrorNo WifiHdiWpaClient::SetDeviceConfig(int networkId, const WifiHalDevice
|
||||
if (num == 0) {
|
||||
return WIFI_HAL_OPT_OK;
|
||||
}
|
||||
return HdiWpaStaSetNetwork(networkId, conf, num);
|
||||
return HdiWpaStaSetNetwork(networkId, conf, num, ifaceName);
|
||||
}
|
||||
|
||||
WifiErrorNo WifiHdiWpaClient::SetBssid(int networkId, const std::string &bssid)
|
||||
WifiErrorNo WifiHdiWpaClient::SetBssid(int networkId, const std::string &bssid, const char *ifaceName)
|
||||
{
|
||||
SetNetworkConfig conf;
|
||||
int num = PushDeviceConfigString(&conf, DEVICE_CONFIG_BSSID, bssid, false);
|
||||
@ -365,15 +368,16 @@ WifiErrorNo WifiHdiWpaClient::SetBssid(int networkId, const std::string &bssid)
|
||||
return WIFI_HAL_OPT_OK;
|
||||
}
|
||||
|
||||
return HdiWpaStaSetNetwork(networkId, &conf, num);
|
||||
return HdiWpaStaSetNetwork(networkId, &conf, num, ifaceName);
|
||||
}
|
||||
|
||||
WifiErrorNo WifiHdiWpaClient::SaveDeviceConfig(void)
|
||||
WifiErrorNo WifiHdiWpaClient::SaveDeviceConfig(const char *ifaceName)
|
||||
{
|
||||
return HdiWpaStaSaveConfig();
|
||||
return HdiWpaStaSaveConfig(ifaceName);
|
||||
}
|
||||
|
||||
WifiErrorNo WifiHdiWpaClient::ReqRegisterStaEventCallback(const WifiEventCallback &callback)
|
||||
WifiErrorNo WifiHdiWpaClient::ReqRegisterStaEventCallback(
|
||||
const WifiEventCallback &callback, const char *ifaceName, int instId)
|
||||
{
|
||||
struct IWpaCallback cWifiHdiWpaCallback;
|
||||
if (memset_s(&cWifiHdiWpaCallback, sizeof(cWifiHdiWpaCallback), 0, sizeof(cWifiHdiWpaCallback)) != EOK) {
|
||||
@ -394,10 +398,10 @@ WifiErrorNo WifiHdiWpaClient::ReqRegisterStaEventCallback(const WifiEventCallbac
|
||||
cWifiHdiWpaCallback.OnEventStaNotify = OnEventStaNotify;
|
||||
}
|
||||
|
||||
return RegisterHdiWpaStaEventCallback(&cWifiHdiWpaCallback);
|
||||
return RegisterHdiWpaStaEventCallback(&cWifiHdiWpaCallback, ifaceName, instId);
|
||||
}
|
||||
|
||||
WifiErrorNo WifiHdiWpaClient::ReqStartWpsPbcMode(const WifiHalWpsConfig &config)
|
||||
WifiErrorNo WifiHdiWpaClient::ReqStartWpsPbcMode(const WifiHalWpsConfig &config, const char *ifaceName)
|
||||
{
|
||||
WifiWpsParam param;
|
||||
if (memset_s(¶m, sizeof(param), 0, sizeof(param)) != EOK) {
|
||||
@ -408,10 +412,10 @@ WifiErrorNo WifiHdiWpaClient::ReqStartWpsPbcMode(const WifiHalWpsConfig &config)
|
||||
if (strncpy_s(param.bssid, sizeof(param.bssid), config.bssid.c_str(), config.bssid.length()) != EOK) {
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
return HdiWpaStaStartWpsPbcMode(¶m);
|
||||
return HdiWpaStaStartWpsPbcMode(¶m, ifaceName);
|
||||
}
|
||||
|
||||
WifiErrorNo WifiHdiWpaClient::ReqStartWpsPinMode(const WifiHalWpsConfig &config, int &pinCode)
|
||||
WifiErrorNo WifiHdiWpaClient::ReqStartWpsPinMode(const WifiHalWpsConfig &config, int &pinCode, const char *ifaceName)
|
||||
{
|
||||
WifiWpsParam param;
|
||||
if (memset_s(¶m, sizeof(param), 0, sizeof(param)) != EOK) {
|
||||
@ -427,12 +431,12 @@ WifiErrorNo WifiHdiWpaClient::ReqStartWpsPinMode(const WifiHalWpsConfig &config,
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
}
|
||||
return HdiWpaStaStartWpsPinMode(¶m, &pinCode);
|
||||
return HdiWpaStaStartWpsPinMode(¶m, &pinCode, ifaceName);
|
||||
}
|
||||
|
||||
WifiErrorNo WifiHdiWpaClient::ReqStopWps(void)
|
||||
WifiErrorNo WifiHdiWpaClient::ReqStopWps(const char *ifaceName)
|
||||
{
|
||||
return HdiStopWpsSta();
|
||||
return HdiStopWpsSta(ifaceName);
|
||||
}
|
||||
|
||||
WifiErrorNo WifiHdiWpaClient::ReqGetRoamingCapabilities(WifiHalRoamCapability &capability)
|
||||
@ -450,39 +454,39 @@ WifiErrorNo WifiHdiWpaClient::ReqGetConnectSignalInfo(const std::string &endBssi
|
||||
return WIFI_HAL_OPT_NOT_SUPPORT;
|
||||
}
|
||||
|
||||
WifiErrorNo WifiHdiWpaClient::ReqWpaAutoConnect(int enable)
|
||||
WifiErrorNo WifiHdiWpaClient::ReqWpaAutoConnect(int enable, const char *ifaceName)
|
||||
{
|
||||
return HdiWpaStaAutoConnect(enable);
|
||||
return HdiWpaStaAutoConnect(enable, ifaceName);
|
||||
}
|
||||
|
||||
WifiErrorNo WifiHdiWpaClient::ReqWpaBlocklistClear(void)
|
||||
WifiErrorNo WifiHdiWpaClient::ReqWpaBlocklistClear(const char *ifaceName)
|
||||
{
|
||||
return HdiWpaStaBlocklistClear();
|
||||
return HdiWpaStaBlocklistClear(ifaceName);
|
||||
}
|
||||
|
||||
WifiErrorNo WifiHdiWpaClient::ReqSetPowerSave(bool enable)
|
||||
WifiErrorNo WifiHdiWpaClient::ReqSetPowerSave(bool enable, const char *ifaceName)
|
||||
{
|
||||
return HdiWpaStaSetPowerSave(enable);
|
||||
return HdiWpaStaSetPowerSave(enable, ifaceName);
|
||||
}
|
||||
|
||||
WifiErrorNo WifiHdiWpaClient::ReqWpaSetCountryCode(const std::string &countryCode)
|
||||
WifiErrorNo WifiHdiWpaClient::ReqWpaSetCountryCode(const std::string &countryCode, const char *ifaceName)
|
||||
{
|
||||
return HdiWpaStaSetCountryCode(countryCode.c_str());
|
||||
return HdiWpaStaSetCountryCode(countryCode.c_str(), ifaceName);
|
||||
}
|
||||
|
||||
WifiErrorNo WifiHdiWpaClient::ReqWpaGetCountryCode(std::string &countryCode)
|
||||
WifiErrorNo WifiHdiWpaClient::ReqWpaGetCountryCode(std::string &countryCode, const char *ifaceName)
|
||||
{
|
||||
char szCountryCode[HAL_COUNTRY_CODE_LENGTH + 1] = "";
|
||||
if (WIFI_HAL_OPT_OK != HdiWpaStaGetCountryCode(szCountryCode, HAL_COUNTRY_CODE_LENGTH)) {
|
||||
if (WIFI_HAL_OPT_OK != HdiWpaStaGetCountryCode(szCountryCode, HAL_COUNTRY_CODE_LENGTH, ifaceName)) {
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
countryCode = szCountryCode;
|
||||
return WIFI_HAL_OPT_OK;
|
||||
}
|
||||
|
||||
WifiErrorNo WifiHdiWpaClient::ReqWpaSetSuspendMode(bool mode) const
|
||||
WifiErrorNo WifiHdiWpaClient::ReqWpaSetSuspendMode(bool mode, const char *ifaceName) const
|
||||
{
|
||||
return HdiWpaStaSetSuspendMode(mode);
|
||||
return HdiWpaStaSetSuspendMode(mode, ifaceName);
|
||||
}
|
||||
|
||||
WifiErrorNo WifiHdiWpaClient::ReqWpaShellCmd(const std::string &ifName, const std::string &cmd)
|
||||
@ -592,7 +596,7 @@ WifiErrorNo WifiHdiWpaClient::CheckValidDeviceConfig(const WifiHalDeviceConfig &
|
||||
return WIFI_HAL_OPT_OK;
|
||||
}
|
||||
|
||||
WifiErrorNo WifiHdiWpaClient::GetNetworkList(std::vector<WifiHalWpaNetworkInfo> &networkList)
|
||||
WifiErrorNo WifiHdiWpaClient::GetNetworkList(std::vector<WifiHalWpaNetworkInfo> &networkList, const char *ifaceName)
|
||||
{
|
||||
HdiWifiWpaNetworkInfo *listNetwork = new HdiWifiWpaNetworkInfo[WIFI_MAX_SCAN_COUNT];
|
||||
if (listNetwork == nullptr) {
|
||||
@ -600,7 +604,7 @@ WifiErrorNo WifiHdiWpaClient::GetNetworkList(std::vector<WifiHalWpaNetworkInfo>
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
uint32_t size = WIFI_MAX_SCAN_COUNT;
|
||||
if (WIFI_HAL_OPT_OK != HdiWpaListNetworks(listNetwork, &size)) {
|
||||
if (WIFI_HAL_OPT_OK != HdiWpaListNetworks(listNetwork, &size, ifaceName)) {
|
||||
if (listNetwork != nullptr) {
|
||||
delete[] listNetwork;
|
||||
listNetwork = nullptr;
|
||||
@ -634,7 +638,7 @@ WifiErrorNo WifiHdiWpaClient::GetNetworkList(std::vector<WifiHalWpaNetworkInfo>
|
||||
return WIFI_HAL_OPT_OK;
|
||||
}
|
||||
|
||||
WifiErrorNo WifiHdiWpaClient::GetDeviceConfig(WifiHalGetDeviceConfig &config)
|
||||
WifiErrorNo WifiHdiWpaClient::GetDeviceConfig(WifiHalGetDeviceConfig &config, const char *ifaceName)
|
||||
{
|
||||
int32_t networkId = config.networkId;
|
||||
char param[WIFI_HDI_MAX_STR_LENGTH +1] = {0};
|
||||
@ -644,7 +648,7 @@ WifiErrorNo WifiHdiWpaClient::GetDeviceConfig(WifiHalGetDeviceConfig &config)
|
||||
}
|
||||
char value[WIFI_HDI_MAX_STR_LENGTH +1] = {0};
|
||||
uint32_t valueLen = WIFI_HDI_MAX_STR_LENGTH;
|
||||
if (WIFI_HAL_OPT_OK != HdiWpaGetNetwork(networkId, param, value, valueLen)) {
|
||||
if (WIFI_HAL_OPT_OK != HdiWpaGetNetwork(networkId, param, value, valueLen, ifaceName)) {
|
||||
LOGE("WifiHdiWpaClient::%{public}s failed", __func__);
|
||||
return WIFI_HAL_OPT_FAILED;
|
||||
}
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "wifi_event_callback.h"
|
||||
#include "wifi_ap_event_callback.h"
|
||||
#include "wifi_p2p_event_callback.h"
|
||||
#include "define.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Wifi {
|
||||
@ -41,14 +42,14 @@ public:
|
||||
*
|
||||
* @return WifiErrorNo
|
||||
*/
|
||||
WifiErrorNo StartWifi(const std::string &ifaceName);
|
||||
WifiErrorNo StartWifi(const std::string &ifaceName, int instId = 0);
|
||||
|
||||
/**
|
||||
* @Description Close Wifi.
|
||||
*
|
||||
* @return WifiErrorNo
|
||||
*/
|
||||
WifiErrorNo StopWifi(void);
|
||||
WifiErrorNo StopWifi(int instId = 0);
|
||||
|
||||
/**
|
||||
* @Description Connect Wifi.
|
||||
@ -56,28 +57,28 @@ public:
|
||||
* @param networkId
|
||||
* @return WifiErrorNo
|
||||
*/
|
||||
WifiErrorNo ReqConnect(int networkId);
|
||||
WifiErrorNo ReqConnect(int networkId, const char *ifaceName);
|
||||
|
||||
/**
|
||||
* @Description Reconnect Wifi.
|
||||
*
|
||||
* @return WifiErrorNo
|
||||
*/
|
||||
WifiErrorNo ReqReconnect(void);
|
||||
WifiErrorNo ReqReconnect(const char *ifaceName);
|
||||
|
||||
/**
|
||||
* @Description Reassociate Wifi.
|
||||
*
|
||||
* @return WifiErrorNo
|
||||
*/
|
||||
WifiErrorNo ReqReassociate(void);
|
||||
WifiErrorNo ReqReassociate(const char *ifaceName);
|
||||
|
||||
/**
|
||||
* @Description Disconnect Wifi.
|
||||
*
|
||||
* @return WifiErrorNo
|
||||
*/
|
||||
WifiErrorNo ReqDisconnect(void);
|
||||
WifiErrorNo ReqDisconnect(const char *ifaceName);
|
||||
|
||||
/**
|
||||
* @Description Obtaining the STA Support Capability.
|
||||
@ -93,7 +94,7 @@ public:
|
||||
* @param mac
|
||||
* @return WifiErrorNo
|
||||
*/
|
||||
WifiErrorNo GetStaDeviceMacAddress(std::string &mac);
|
||||
WifiErrorNo GetStaDeviceMacAddress(std::string &mac, const char *ifaceName);
|
||||
|
||||
/**
|
||||
* @Description Obtains the frequencies supported by a specified
|
||||
@ -150,14 +151,14 @@ public:
|
||||
* @param networkId
|
||||
* @return WifiErrorNo
|
||||
*/
|
||||
WifiErrorNo RemoveDevice(int networkId);
|
||||
WifiErrorNo RemoveDevice(int networkId, const char *ifaceName);
|
||||
|
||||
/**
|
||||
* @Description Clears the network configuration information saved by wpa_supplicant.
|
||||
*
|
||||
* @return WifiErrorNo
|
||||
*/
|
||||
WifiErrorNo ClearDeviceConfig(void) const;
|
||||
WifiErrorNo ClearDeviceConfig(const char *ifaceName) const;
|
||||
|
||||
/**
|
||||
* @Description Request to obtain the next network ID.
|
||||
@ -165,7 +166,7 @@ public:
|
||||
* @param networkId
|
||||
* @return WifiErrorNo
|
||||
*/
|
||||
WifiErrorNo GetNextNetworkId(int &networkId);
|
||||
WifiErrorNo GetNextNetworkId(int &networkId, const char *ifaceName);
|
||||
|
||||
/**
|
||||
* @Description Enable a network.
|
||||
@ -173,7 +174,7 @@ public:
|
||||
* @param networkId
|
||||
* @return WifiErrorNo
|
||||
*/
|
||||
WifiErrorNo ReqEnableNetwork(int networkId);
|
||||
WifiErrorNo ReqEnableNetwork(int networkId, const char *ifaceName);
|
||||
|
||||
/**
|
||||
* @Description Disable a network.
|
||||
@ -181,7 +182,7 @@ public:
|
||||
* @param networkId
|
||||
* @return WifiErrorNo
|
||||
*/
|
||||
WifiErrorNo ReqDisableNetwork(int networkId);
|
||||
WifiErrorNo ReqDisableNetwork(int networkId, const char *ifaceName);
|
||||
|
||||
/**
|
||||
* @Description Setting the network.
|
||||
@ -190,7 +191,7 @@ public:
|
||||
* @param config - Setting Network Parameters.
|
||||
* @return WifiErrorNo
|
||||
*/
|
||||
WifiErrorNo SetDeviceConfig(int networkId, const WifiHalDeviceConfig &config);
|
||||
WifiErrorNo SetDeviceConfig(int networkId, const WifiHalDeviceConfig &config, const char *ifaceName);
|
||||
|
||||
/**
|
||||
* @Description Set bssid to supplicant.
|
||||
@ -199,14 +200,14 @@ public:
|
||||
* @param bssid
|
||||
* @return WifiErrorNo
|
||||
*/
|
||||
WifiErrorNo SetBssid(int networkId, const std::string &bssid);
|
||||
WifiErrorNo SetBssid(int networkId, const std::string &bssid, const char *ifaceName);
|
||||
|
||||
/**
|
||||
* @Description Save the network.
|
||||
*
|
||||
* @return WifiErrorNo
|
||||
*/
|
||||
WifiErrorNo SaveDeviceConfig(void);
|
||||
WifiErrorNo SaveDeviceConfig(const char *ifaceName);
|
||||
|
||||
/**
|
||||
* @Description Registering the Sta Event Callback.
|
||||
@ -214,7 +215,7 @@ public:
|
||||
* @param callback - Registering an Event Callback Function.
|
||||
* @return WifiErrorNo
|
||||
*/
|
||||
WifiErrorNo ReqRegisterStaEventCallback(const WifiEventCallback &callback);
|
||||
WifiErrorNo ReqRegisterStaEventCallback(const WifiEventCallback &callback, const char *ifaceName, int instId);
|
||||
|
||||
/**
|
||||
* @Description Enabling WPS in PBC Mode.
|
||||
@ -222,7 +223,7 @@ public:
|
||||
* @param config
|
||||
* @return WifiErrorNo
|
||||
*/
|
||||
WifiErrorNo ReqStartWpsPbcMode(const WifiHalWpsConfig &config);
|
||||
WifiErrorNo ReqStartWpsPbcMode(const WifiHalWpsConfig &config, const char *ifaceName);
|
||||
|
||||
/**
|
||||
* @Description Enable PIN mode WPS.
|
||||
@ -231,14 +232,14 @@ public:
|
||||
* @param pinCode
|
||||
* @return WifiErrorNo
|
||||
*/
|
||||
WifiErrorNo ReqStartWpsPinMode(const WifiHalWpsConfig &config, int &pinCode);
|
||||
WifiErrorNo ReqStartWpsPinMode(const WifiHalWpsConfig &config, int &pinCode, const char *ifaceName);
|
||||
|
||||
/**
|
||||
* @Description Close wps.
|
||||
*
|
||||
* @return WifiErrorNo
|
||||
*/
|
||||
WifiErrorNo ReqStopWps(void);
|
||||
WifiErrorNo ReqStopWps(const char *ifaceName);
|
||||
|
||||
/**
|
||||
* @Description Obtains the roaming support capability.
|
||||
@ -271,14 +272,14 @@ public:
|
||||
* @param enable
|
||||
* @return WifiErrorNo
|
||||
*/
|
||||
WifiErrorNo ReqWpaAutoConnect(int enable);
|
||||
WifiErrorNo ReqWpaAutoConnect(int enable, const char *ifaceName);
|
||||
|
||||
/**
|
||||
* @Description Clearing the wpa Blocklist.
|
||||
*
|
||||
* @return WifiErrorNo
|
||||
*/
|
||||
WifiErrorNo ReqWpaBlocklistClear(void);
|
||||
WifiErrorNo ReqWpaBlocklistClear(const char *ifaceName);
|
||||
|
||||
/**
|
||||
* @Description Turn on/off power save mode for the interface.
|
||||
@ -286,7 +287,7 @@ public:
|
||||
* @param enable
|
||||
* @return WifiErrorNo
|
||||
*/
|
||||
WifiErrorNo ReqSetPowerSave(bool enable);
|
||||
WifiErrorNo ReqSetPowerSave(bool enable, const char *ifaceName);
|
||||
|
||||
/**
|
||||
* @Description Setting the country code.
|
||||
@ -294,17 +295,17 @@ public:
|
||||
* @param countCode
|
||||
* @return WifiErrorNo
|
||||
*/
|
||||
WifiErrorNo ReqWpaSetCountryCode(const std::string &countryCode);
|
||||
WifiErrorNo ReqWpaGetCountryCode(std::string &countryCode);
|
||||
WifiErrorNo ReqWpaSetCountryCode(const std::string &countryCode, const char *ifaceName);
|
||||
WifiErrorNo ReqWpaGetCountryCode(std::string &countryCode, const char *ifaceName);
|
||||
/**
|
||||
* @Description Send suspend mode to wpa
|
||||
*
|
||||
* @param mode: true for suspend, false for resume
|
||||
* @return WifiErrorNo
|
||||
*/
|
||||
WifiErrorNo ReqWpaSetSuspendMode(bool mode) const;
|
||||
WifiErrorNo GetNetworkList(std::vector<WifiHalWpaNetworkInfo> &networkList);
|
||||
WifiErrorNo GetDeviceConfig(WifiHalGetDeviceConfig &config);
|
||||
WifiErrorNo ReqWpaSetSuspendMode(bool mode, const char *ifaceName) const;
|
||||
WifiErrorNo GetNetworkList(std::vector<WifiHalWpaNetworkInfo> &networkList, const char *ifaceName);
|
||||
WifiErrorNo GetDeviceConfig(WifiHalGetDeviceConfig &config, const char *ifaceName);
|
||||
|
||||
/**
|
||||
* @Description Send SIM/AKA/AKA' authentication to wpa
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "wifi_supplicant_hal_interface.h"
|
||||
#include "wifi_p2p_hal_interface.h"
|
||||
#include "wifi_global_func.h"
|
||||
#include "wifi_config_center.h"
|
||||
|
||||
RpcClient *GetChipRpcClient(void)
|
||||
{
|
||||
@ -64,7 +65,8 @@ void OnConnectChanged(int status, int networkId, const char *mac)
|
||||
if (mac == nullptr) {
|
||||
return;
|
||||
}
|
||||
const OHOS::Wifi::WifiEventCallback &cbk = OHOS::Wifi::WifiStaHalInterface::GetInstance().GetCallbackInst();
|
||||
const OHOS::Wifi::WifiEventCallback &cbk = OHOS::Wifi::WifiStaHalInterface::GetInstance().GetCallbackInst(
|
||||
OHOS::Wifi::WifiConfigCenter::GetInstance().GetStaIfaceName(INSTID_WLAN0));
|
||||
if (cbk.onConnectChanged) {
|
||||
cbk.onConnectChanged(status, networkId, mac);
|
||||
}
|
||||
@ -75,7 +77,8 @@ void OnDisConnectReasonCallback(int reason, const char *bssid)
|
||||
if (bssid == nullptr) {
|
||||
return;
|
||||
}
|
||||
const OHOS::Wifi::WifiEventCallback &cbk = OHOS::Wifi::WifiStaHalInterface::GetInstance().GetCallbackInst();
|
||||
const OHOS::Wifi::WifiEventCallback &cbk = OHOS::Wifi::WifiStaHalInterface::GetInstance().GetCallbackInst(
|
||||
OHOS::Wifi::WifiConfigCenter::GetInstance().GetStaIfaceName(INSTID_WLAN0));
|
||||
if (cbk.onReportDisConnectReason) {
|
||||
cbk.onReportDisConnectReason(reason, bssid);
|
||||
}
|
||||
@ -86,7 +89,8 @@ void OnBssidChanged(const char *reason, const char *bssid)
|
||||
if (reason == nullptr || bssid == nullptr) {
|
||||
return;
|
||||
}
|
||||
const OHOS::Wifi::WifiEventCallback &cbk = OHOS::Wifi::WifiStaHalInterface::GetInstance().GetCallbackInst();
|
||||
const OHOS::Wifi::WifiEventCallback &cbk = OHOS::Wifi::WifiStaHalInterface::GetInstance().GetCallbackInst(
|
||||
OHOS::Wifi::WifiConfigCenter::GetInstance().GetStaIfaceName(INSTID_WLAN0));
|
||||
if (cbk.onBssidChanged) {
|
||||
cbk.onBssidChanged(reason, bssid);
|
||||
}
|
||||
@ -94,7 +98,8 @@ void OnBssidChanged(const char *reason, const char *bssid)
|
||||
|
||||
void OnWpaStateChanged(int status)
|
||||
{
|
||||
const OHOS::Wifi::WifiEventCallback &cbk = OHOS::Wifi::WifiStaHalInterface::GetInstance().GetCallbackInst();
|
||||
const OHOS::Wifi::WifiEventCallback &cbk = OHOS::Wifi::WifiStaHalInterface::GetInstance().GetCallbackInst(
|
||||
OHOS::Wifi::WifiConfigCenter::GetInstance().GetStaIfaceName(INSTID_WLAN0));
|
||||
if (cbk.onWpaStateChanged) {
|
||||
cbk.onWpaStateChanged(status);
|
||||
}
|
||||
@ -102,7 +107,8 @@ void OnWpaStateChanged(int status)
|
||||
|
||||
void OnWpaSsidWrongKey()
|
||||
{
|
||||
const OHOS::Wifi::WifiEventCallback &cbk = OHOS::Wifi::WifiStaHalInterface::GetInstance().GetCallbackInst();
|
||||
const OHOS::Wifi::WifiEventCallback &cbk = OHOS::Wifi::WifiStaHalInterface::GetInstance().GetCallbackInst(
|
||||
OHOS::Wifi::WifiConfigCenter::GetInstance().GetStaIfaceName(INSTID_WLAN0));
|
||||
if (cbk.onWpaSsidWrongKey) {
|
||||
cbk.onWpaSsidWrongKey();
|
||||
}
|
||||
@ -110,7 +116,8 @@ void OnWpaSsidWrongKey()
|
||||
|
||||
void OnWpaConnectionFull(int status)
|
||||
{
|
||||
const OHOS::Wifi::WifiEventCallback &cbk = OHOS::Wifi::WifiStaHalInterface::GetInstance().GetCallbackInst();
|
||||
const OHOS::Wifi::WifiEventCallback &cbk = OHOS::Wifi::WifiStaHalInterface::GetInstance().GetCallbackInst(
|
||||
OHOS::Wifi::WifiConfigCenter::GetInstance().GetStaIfaceName(INSTID_WLAN0));
|
||||
if (cbk.onWpaConnectionFull) {
|
||||
cbk.onWpaConnectionFull(status);
|
||||
}
|
||||
@ -118,7 +125,8 @@ void OnWpaConnectionFull(int status)
|
||||
|
||||
void OnWpaConnectionReject(int status)
|
||||
{
|
||||
const OHOS::Wifi::WifiEventCallback &cbk = OHOS::Wifi::WifiStaHalInterface::GetInstance().GetCallbackInst();
|
||||
const OHOS::Wifi::WifiEventCallback &cbk = OHOS::Wifi::WifiStaHalInterface::GetInstance().GetCallbackInst(
|
||||
OHOS::Wifi::WifiConfigCenter::GetInstance().GetStaIfaceName(INSTID_WLAN0));
|
||||
if (cbk.onWpaConnectionReject) {
|
||||
cbk.onWpaConnectionReject(status);
|
||||
}
|
||||
@ -129,7 +137,8 @@ void OnWpaStaNotifyCallBack(const char *notifyParam)
|
||||
if (notifyParam == nullptr) {
|
||||
return;
|
||||
}
|
||||
const OHOS::Wifi::WifiEventCallback &cbk = OHOS::Wifi::WifiStaHalInterface::GetInstance().GetCallbackInst();
|
||||
const OHOS::Wifi::WifiEventCallback &cbk = OHOS::Wifi::WifiStaHalInterface::GetInstance().GetCallbackInst(
|
||||
OHOS::Wifi::WifiConfigCenter::GetInstance().GetStaIfaceName(INSTID_WLAN0));
|
||||
if (cbk.onEventStaNotify) {
|
||||
cbk.onEventStaNotify(notifyParam);
|
||||
}
|
||||
@ -137,7 +146,8 @@ void OnWpaStaNotifyCallBack(const char *notifyParam)
|
||||
|
||||
void OnWpsOverlap(int status)
|
||||
{
|
||||
const OHOS::Wifi::WifiEventCallback &cbk = OHOS::Wifi::WifiStaHalInterface::GetInstance().GetCallbackInst();
|
||||
const OHOS::Wifi::WifiEventCallback &cbk = OHOS::Wifi::WifiStaHalInterface::GetInstance().GetCallbackInst(
|
||||
OHOS::Wifi::WifiConfigCenter::GetInstance().GetStaIfaceName(INSTID_WLAN0));
|
||||
if (cbk.onWpsOverlap) {
|
||||
cbk.onWpsOverlap(status);
|
||||
}
|
||||
@ -145,7 +155,8 @@ void OnWpsOverlap(int status)
|
||||
|
||||
void OnWpsTimeOut(int status)
|
||||
{
|
||||
const OHOS::Wifi::WifiEventCallback &cbk = OHOS::Wifi::WifiStaHalInterface::GetInstance().GetCallbackInst();
|
||||
const OHOS::Wifi::WifiEventCallback &cbk = OHOS::Wifi::WifiStaHalInterface::GetInstance().GetCallbackInst(
|
||||
OHOS::Wifi::WifiConfigCenter::GetInstance().GetStaIfaceName(INSTID_WLAN0));
|
||||
if (cbk.onWpsTimeOut) {
|
||||
cbk.onWpsTimeOut(status);
|
||||
}
|
||||
|
@ -110,9 +110,11 @@ void HalDeviceManager::StopChipHdi()
|
||||
}
|
||||
|
||||
bool HalDeviceManager::CreateStaIface(const IfaceDestoryCallback &ifaceDestoryCallback,
|
||||
const RssiReportCallback &rssiReportCallback, std::string &ifaceName)
|
||||
const RssiReportCallback &rssiReportCallback, std::string &ifaceName, int instId)
|
||||
{
|
||||
LOGI("CreateStaIface, ifaceName: %{public}s, instId = %{public}d", ifaceName.c_str(), instId);
|
||||
if (!CheckReloadChipHdiService()) {
|
||||
LOGE("CreateStaIface CheckReloadChipHdiService failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -125,14 +127,17 @@ bool HalDeviceManager::CreateStaIface(const IfaceDestoryCallback &ifaceDestoryCa
|
||||
|
||||
CHECK_NULL_AND_RETURN(iface, false);
|
||||
CHECK_NULL_AND_RETURN(g_chipIfaceCallback, false);
|
||||
int32_t ret = iface->RegisterChipIfaceCallBack(g_chipIfaceCallback);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
LOGE("CreateStaIface, call RegisterChipIfaceCallBack failed! ret:%{public}d", ret);
|
||||
return false;
|
||||
if (instId == INSTID_WLAN0) {
|
||||
int32_t ret = iface->RegisterChipIfaceCallBack(g_chipIfaceCallback);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
LOGE("CreateStaIface, call RegisterChipIfaceCallBack failed! ret:%{public}d", ret);
|
||||
return false;
|
||||
}
|
||||
g_rssiReportCallback = rssiReportCallback;
|
||||
} else {
|
||||
LOGE("CreateStaIface wlan1 skip scan callback instId = %{public}d", instId);
|
||||
}
|
||||
|
||||
g_rssiReportCallback = rssiReportCallback;
|
||||
|
||||
mIWifiStaIfaces[ifaceName] = iface;
|
||||
LOGI("CreateStaIface success! ifaceName:%{public}s", ifaceName.c_str());
|
||||
return true;
|
||||
@ -1443,11 +1448,14 @@ bool HalDeviceManager::RemoveIface(sptr<IChipIface> &iface, bool isCallback, Ifa
|
||||
CHECK_NULL_AND_RETURN(chip, false);
|
||||
int32_t ret = HDF_FAILURE;
|
||||
switch (ifaceType) {
|
||||
case IfaceType::STA :
|
||||
if (iface && g_chipIfaceCallback) {
|
||||
iface->UnRegisterChipIfaceCallBack(g_chipIfaceCallback);
|
||||
case IfaceType::STA:
|
||||
if (ifaceName == "wlan0") {
|
||||
LOGE("RemoveIface, IfaceType::STA wlan0");
|
||||
if (iface && g_chipIfaceCallback) {
|
||||
iface->UnRegisterChipIfaceCallBack(g_chipIfaceCallback);
|
||||
}
|
||||
g_rssiReportCallback = nullptr;
|
||||
}
|
||||
g_rssiReportCallback = nullptr;
|
||||
ret = chip->RemoveStaService(ifaceName);
|
||||
break;
|
||||
case IfaceType::AP :
|
||||
|
@ -192,8 +192,8 @@ public:
|
||||
* @param ifaceName: [out] iface name
|
||||
* @return bool
|
||||
*/
|
||||
bool CreateStaIface(const IfaceDestoryCallback &ifaceDestoryCallback,
|
||||
const RssiReportCallback &rssiReportCallback, std::string &ifaceName);
|
||||
bool CreateStaIface(const IfaceDestoryCallback &ifaceDestoryCallback, const RssiReportCallback &rssiReportCallback,
|
||||
std::string &ifaceName, int instId);
|
||||
|
||||
/**
|
||||
* @Description create ap iface
|
||||
|
@ -19,12 +19,26 @@
|
||||
#include "wifi_log.h"
|
||||
#include "wifi_hdi_util.h"
|
||||
#include "wifi_code_convert.h"
|
||||
#include "wifi_config_center.h"
|
||||
#include "define.h"
|
||||
|
||||
#undef LOG_TAG
|
||||
#define LOG_TAG "WifiStaHalInterface"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Wifi {
|
||||
static int GetInstId(const std::string &ifaceName)
|
||||
{
|
||||
int inst = INSTID_WLAN0;
|
||||
for (int instId = INSTID_WLAN0; instId < STA_INSTANCE_MAX_NUM; instId++) {
|
||||
if (ifaceName.compare(WifiConfigCenter::GetInstance().GetStaIfaceName(instId)) == 0) {
|
||||
inst = instId;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return inst;
|
||||
}
|
||||
|
||||
WifiStaHalInterface &WifiStaHalInterface::GetInstance(void)
|
||||
{
|
||||
static WifiStaHalInterface inst;
|
||||
@ -47,11 +61,12 @@ WifiStaHalInterface &WifiStaHalInterface::GetInstance(void)
|
||||
return inst;
|
||||
}
|
||||
|
||||
WifiErrorNo WifiStaHalInterface::StartWifi(const std::string &ifaceName)
|
||||
WifiErrorNo WifiStaHalInterface::StartWifi(const std::string &ifaceName, int instId)
|
||||
{
|
||||
LOGD("WifiStaHalInterface ifaceName:%{public}s, instId:%{public}d", ifaceName.c_str(), instId);
|
||||
#ifdef HDI_WPA_INTERFACE_SUPPORT
|
||||
CHECK_NULL_AND_RETURN(mHdiWpaClient, WIFI_HAL_OPT_FAILED);
|
||||
return mHdiWpaClient->StartWifi(ifaceName);
|
||||
return mHdiWpaClient->StartWifi(ifaceName, instId);
|
||||
#else
|
||||
CHECK_NULL_AND_RETURN(mIdlClient, WIFI_HAL_OPT_FAILED);
|
||||
return mIdlClient->StartWifi();
|
||||
@ -59,22 +74,22 @@ WifiErrorNo WifiStaHalInterface::StartWifi(const std::string &ifaceName)
|
||||
}
|
||||
|
||||
|
||||
WifiErrorNo WifiStaHalInterface::StopWifi(void)
|
||||
WifiErrorNo WifiStaHalInterface::StopWifi(int instId)
|
||||
{
|
||||
#ifdef HDI_WPA_INTERFACE_SUPPORT
|
||||
CHECK_NULL_AND_RETURN(mHdiWpaClient, WIFI_HAL_OPT_FAILED);
|
||||
return mHdiWpaClient->StopWifi();
|
||||
return mHdiWpaClient->StopWifi(instId);
|
||||
#else
|
||||
CHECK_NULL_AND_RETURN(mIdlClient, WIFI_HAL_OPT_FAILED);
|
||||
return mIdlClient->StopWifi();
|
||||
#endif
|
||||
}
|
||||
|
||||
WifiErrorNo WifiStaHalInterface::Connect(int networkId)
|
||||
WifiErrorNo WifiStaHalInterface::Connect(int networkId, const std::string &ifaceName)
|
||||
{
|
||||
#ifdef HDI_WPA_INTERFACE_SUPPORT
|
||||
CHECK_NULL_AND_RETURN(mHdiWpaClient, WIFI_HAL_OPT_FAILED);
|
||||
return mHdiWpaClient->ReqConnect(networkId);
|
||||
return mHdiWpaClient->ReqConnect(networkId, ifaceName.c_str());
|
||||
#else
|
||||
CHECK_NULL_AND_RETURN(mIdlClient, WIFI_HAL_OPT_FAILED);
|
||||
return mIdlClient->ReqConnect(networkId);
|
||||
@ -85,7 +100,7 @@ WifiErrorNo WifiStaHalInterface::Reconnect(void)
|
||||
{
|
||||
#ifdef HDI_WPA_INTERFACE_SUPPORT
|
||||
CHECK_NULL_AND_RETURN(mHdiWpaClient, WIFI_HAL_OPT_FAILED);
|
||||
return mHdiWpaClient->ReqReconnect();
|
||||
return mHdiWpaClient->ReqReconnect(WifiConfigCenter::GetInstance().GetStaIfaceName(INSTID_WLAN0).c_str());
|
||||
#else
|
||||
CHECK_NULL_AND_RETURN(mIdlClient, WIFI_HAL_OPT_FAILED);
|
||||
return mIdlClient->ReqReconnect();
|
||||
@ -96,18 +111,19 @@ WifiErrorNo WifiStaHalInterface::Reassociate(void)
|
||||
{
|
||||
#ifdef HDI_WPA_INTERFACE_SUPPORT
|
||||
CHECK_NULL_AND_RETURN(mHdiWpaClient, WIFI_HAL_OPT_FAILED);
|
||||
return mHdiWpaClient->ReqReassociate();
|
||||
return mHdiWpaClient->ReqReassociate(WifiConfigCenter::GetInstance().GetStaIfaceName(INSTID_WLAN0).c_str());
|
||||
#else
|
||||
CHECK_NULL_AND_RETURN(mIdlClient, WIFI_HAL_OPT_FAILED);
|
||||
return mIdlClient->ReqReassociate();
|
||||
#endif
|
||||
}
|
||||
|
||||
WifiErrorNo WifiStaHalInterface::Disconnect(void)
|
||||
WifiErrorNo WifiStaHalInterface::Disconnect(const std::string &ifaceName)
|
||||
{
|
||||
LOGD("WifiStaHalInterface Disconnect ifaceName:%{public}s", ifaceName.c_str());
|
||||
#ifdef HDI_WPA_INTERFACE_SUPPORT
|
||||
CHECK_NULL_AND_RETURN(mHdiWpaClient, WIFI_HAL_OPT_FAILED);
|
||||
return mHdiWpaClient->ReqDisconnect();
|
||||
return mHdiWpaClient->ReqDisconnect(ifaceName.c_str());
|
||||
#else
|
||||
CHECK_NULL_AND_RETURN(mIdlClient, WIFI_HAL_OPT_FAILED);
|
||||
return mIdlClient->ReqDisconnect();
|
||||
@ -125,11 +141,11 @@ WifiErrorNo WifiStaHalInterface::GetStaCapabilities(unsigned int &capabilities)
|
||||
#endif
|
||||
}
|
||||
|
||||
WifiErrorNo WifiStaHalInterface::GetStaDeviceMacAddress(std::string &mac)
|
||||
WifiErrorNo WifiStaHalInterface::GetStaDeviceMacAddress(std::string &mac, const std::string &ifaceName)
|
||||
{
|
||||
#ifdef HDI_WPA_INTERFACE_SUPPORT
|
||||
CHECK_NULL_AND_RETURN(mHdiWpaClient, WIFI_HAL_OPT_FAILED);
|
||||
return mHdiWpaClient->GetStaDeviceMacAddress(mac);
|
||||
return mHdiWpaClient->GetStaDeviceMacAddress(mac, ifaceName.c_str());
|
||||
#else
|
||||
CHECK_NULL_AND_RETURN(mIdlClient, WIFI_HAL_OPT_FAILED);
|
||||
return mIdlClient->GetStaDeviceMacAddress(mac);
|
||||
@ -351,7 +367,8 @@ WifiErrorNo WifiStaHalInterface::GetNetworkList(std::vector<WifiHalWpaNetworkInf
|
||||
#ifdef HDI_WPA_INTERFACE_SUPPORT
|
||||
LOGI("call WifiStaHalInterface::%{public}s!", __func__);
|
||||
CHECK_NULL_AND_RETURN(mHdiWpaClient, WIFI_HAL_OPT_FAILED);
|
||||
return mHdiWpaClient->GetNetworkList(networkList);
|
||||
return mHdiWpaClient->GetNetworkList(
|
||||
networkList, WifiConfigCenter::GetInstance().GetStaIfaceName(INSTID_WLAN0).c_str());
|
||||
#else
|
||||
CHECK_NULL_AND_RETURN(mIdlClient, WIFI_HAL_OPT_FAILED);
|
||||
return mIdlClient->ReqGetNetworkList(networkList);
|
||||
@ -395,74 +412,76 @@ WifiErrorNo WifiStaHalInterface::RemoveDevice(int networkId)
|
||||
{
|
||||
#ifdef HDI_WPA_INTERFACE_SUPPORT
|
||||
CHECK_NULL_AND_RETURN(mHdiWpaClient, WIFI_HAL_OPT_FAILED);
|
||||
return mHdiWpaClient->RemoveDevice(networkId);
|
||||
return mHdiWpaClient->RemoveDevice(
|
||||
networkId, WifiConfigCenter::GetInstance().GetStaIfaceName(INSTID_WLAN0).c_str());
|
||||
#else
|
||||
CHECK_NULL_AND_RETURN(mIdlClient, WIFI_HAL_OPT_FAILED);
|
||||
return mIdlClient->RemoveDevice(networkId);
|
||||
#endif
|
||||
}
|
||||
|
||||
WifiErrorNo WifiStaHalInterface::ClearDeviceConfig(void) const
|
||||
WifiErrorNo WifiStaHalInterface::ClearDeviceConfig(const std::string &ifaceName) const
|
||||
{
|
||||
#ifdef HDI_WPA_INTERFACE_SUPPORT
|
||||
CHECK_NULL_AND_RETURN(mHdiWpaClient, WIFI_HAL_OPT_FAILED);
|
||||
return mHdiWpaClient->ClearDeviceConfig();
|
||||
return mHdiWpaClient->ClearDeviceConfig(ifaceName.c_str());
|
||||
#else
|
||||
CHECK_NULL_AND_RETURN(mIdlClient, WIFI_HAL_OPT_FAILED);
|
||||
return mIdlClient->ClearDeviceConfig();
|
||||
#endif
|
||||
}
|
||||
|
||||
WifiErrorNo WifiStaHalInterface::GetNextNetworkId(int &networkId)
|
||||
WifiErrorNo WifiStaHalInterface::GetNextNetworkId(int &networkId, const std::string &ifaceName)
|
||||
{
|
||||
#ifdef HDI_WPA_INTERFACE_SUPPORT
|
||||
CHECK_NULL_AND_RETURN(mHdiWpaClient, WIFI_HAL_OPT_FAILED);
|
||||
return mHdiWpaClient->GetNextNetworkId(networkId);
|
||||
return mHdiWpaClient->GetNextNetworkId(networkId, ifaceName.c_str());
|
||||
#else
|
||||
CHECK_NULL_AND_RETURN(mIdlClient, WIFI_HAL_OPT_FAILED);
|
||||
return mIdlClient->GetNextNetworkId(networkId);
|
||||
#endif
|
||||
}
|
||||
|
||||
WifiErrorNo WifiStaHalInterface::EnableNetwork(int networkId)
|
||||
WifiErrorNo WifiStaHalInterface::EnableNetwork(int networkId, const std::string &ifaceName)
|
||||
{
|
||||
#ifdef HDI_WPA_INTERFACE_SUPPORT
|
||||
CHECK_NULL_AND_RETURN(mHdiWpaClient, WIFI_HAL_OPT_FAILED);
|
||||
return mHdiWpaClient->ReqEnableNetwork(networkId);
|
||||
return mHdiWpaClient->ReqEnableNetwork(networkId, ifaceName.c_str());
|
||||
#else
|
||||
CHECK_NULL_AND_RETURN(mIdlClient, WIFI_HAL_OPT_FAILED);
|
||||
return mIdlClient->ReqEnableNetwork(networkId);
|
||||
#endif
|
||||
}
|
||||
|
||||
WifiErrorNo WifiStaHalInterface::DisableNetwork(int networkId)
|
||||
WifiErrorNo WifiStaHalInterface::DisableNetwork(int networkId, const std::string &ifaceName)
|
||||
{
|
||||
#ifdef HDI_WPA_INTERFACE_SUPPORT
|
||||
CHECK_NULL_AND_RETURN(mHdiWpaClient, WIFI_HAL_OPT_FAILED);
|
||||
return mHdiWpaClient->ReqDisableNetwork(networkId);
|
||||
return mHdiWpaClient->ReqDisableNetwork(networkId, ifaceName.c_str());
|
||||
#else
|
||||
CHECK_NULL_AND_RETURN(mIdlClient, WIFI_HAL_OPT_FAILED);
|
||||
return mIdlClient->ReqDisableNetwork(networkId);
|
||||
#endif
|
||||
}
|
||||
|
||||
WifiErrorNo WifiStaHalInterface::SetDeviceConfig(int networkId, const WifiHalDeviceConfig &config)
|
||||
WifiErrorNo WifiStaHalInterface::SetDeviceConfig(
|
||||
int networkId, const WifiHalDeviceConfig &config, const std::string &ifaceName)
|
||||
{
|
||||
#ifdef HDI_WPA_INTERFACE_SUPPORT
|
||||
CHECK_NULL_AND_RETURN(mHdiWpaClient, WIFI_HAL_OPT_FAILED);
|
||||
return mHdiWpaClient->SetDeviceConfig(networkId, config);
|
||||
return mHdiWpaClient->SetDeviceConfig(networkId, config, ifaceName.c_str());
|
||||
#else
|
||||
CHECK_NULL_AND_RETURN(mIdlClient, WIFI_HAL_OPT_FAILED);
|
||||
return mIdlClient->SetDeviceConfig(networkId, config);
|
||||
#endif
|
||||
}
|
||||
|
||||
WifiErrorNo WifiStaHalInterface::GetDeviceConfig(WifiHalGetDeviceConfig &config)
|
||||
WifiErrorNo WifiStaHalInterface::GetDeviceConfig(WifiHalGetDeviceConfig &config, const std::string &ifaceName)
|
||||
{
|
||||
#ifdef HDI_WPA_INTERFACE_SUPPORT
|
||||
LOGI("call WifiStaHalInterface::%{public}s!", __func__);
|
||||
CHECK_NULL_AND_RETURN(mHdiWpaClient, WIFI_HAL_OPT_FAILED);
|
||||
return mHdiWpaClient->GetDeviceConfig(config);
|
||||
return mHdiWpaClient->GetDeviceConfig(config, ifaceName.c_str());
|
||||
#else
|
||||
CHECK_NULL_AND_RETURN(mIdlClient, WIFI_HAL_OPT_FAILED);
|
||||
return mIdlClient->GetDeviceConfig(config);
|
||||
@ -473,24 +492,26 @@ WifiErrorNo WifiStaHalInterface::SaveDeviceConfig(void)
|
||||
{
|
||||
#ifdef HDI_WPA_INTERFACE_SUPPORT
|
||||
CHECK_NULL_AND_RETURN(mHdiWpaClient, WIFI_HAL_OPT_FAILED);
|
||||
return mHdiWpaClient->SaveDeviceConfig();
|
||||
return mHdiWpaClient->SaveDeviceConfig(WifiConfigCenter::GetInstance().GetStaIfaceName(INSTID_WLAN0).c_str());
|
||||
#else
|
||||
CHECK_NULL_AND_RETURN(mIdlClient, WIFI_HAL_OPT_FAILED);
|
||||
return mIdlClient->SaveDeviceConfig();
|
||||
#endif
|
||||
}
|
||||
|
||||
WifiErrorNo WifiStaHalInterface::RegisterStaEventCallback(const WifiEventCallback &callback)
|
||||
WifiErrorNo WifiStaHalInterface::RegisterStaEventCallback(
|
||||
const WifiEventCallback &callback, const std::string &ifaceName)
|
||||
{
|
||||
int instId = GetInstId(ifaceName);
|
||||
#ifdef HDI_WPA_INTERFACE_SUPPORT
|
||||
CHECK_NULL_AND_RETURN(mHdiWpaClient, WIFI_HAL_OPT_FAILED);
|
||||
WifiErrorNo err = mHdiWpaClient->ReqRegisterStaEventCallback(callback);
|
||||
WifiErrorNo err = mHdiWpaClient->ReqRegisterStaEventCallback(callback, ifaceName.c_str(), instId);
|
||||
#else
|
||||
CHECK_NULL_AND_RETURN(mIdlClient, WIFI_HAL_OPT_FAILED);
|
||||
WifiErrorNo err = mIdlClient->ReqRegisterStaEventCallback(callback);
|
||||
#endif
|
||||
if (err == WIFI_HAL_OPT_OK || callback.onConnectChanged == nullptr) {
|
||||
mStaCallback = callback;
|
||||
mStaCallback[instId] = callback;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
@ -499,7 +520,8 @@ WifiErrorNo WifiStaHalInterface::StartWpsPbcMode(const WifiHalWpsConfig &config)
|
||||
{
|
||||
#ifdef HDI_WPA_INTERFACE_SUPPORT
|
||||
CHECK_NULL_AND_RETURN(mHdiWpaClient, WIFI_HAL_OPT_FAILED);
|
||||
return mHdiWpaClient->ReqStartWpsPbcMode(config);
|
||||
return mHdiWpaClient->ReqStartWpsPbcMode(
|
||||
config, WifiConfigCenter::GetInstance().GetStaIfaceName(INSTID_WLAN0).c_str());
|
||||
#else
|
||||
CHECK_NULL_AND_RETURN(mIdlClient, WIFI_HAL_OPT_FAILED);
|
||||
return mIdlClient->ReqStartWpsPbcMode(config);
|
||||
@ -513,7 +535,8 @@ WifiErrorNo WifiStaHalInterface::StartWpsPinMode(const WifiHalWpsConfig &config,
|
||||
}
|
||||
#ifdef HDI_WPA_INTERFACE_SUPPORT
|
||||
CHECK_NULL_AND_RETURN(mHdiWpaClient, WIFI_HAL_OPT_FAILED);
|
||||
return mHdiWpaClient->ReqStartWpsPinMode(config, pinCode);
|
||||
return mHdiWpaClient->ReqStartWpsPinMode(
|
||||
config, pinCode, WifiConfigCenter::GetInstance().GetStaIfaceName(INSTID_WLAN0).c_str());
|
||||
#else
|
||||
CHECK_NULL_AND_RETURN(mIdlClient, WIFI_HAL_OPT_FAILED);
|
||||
return mIdlClient->ReqStartWpsPinMode(config, pinCode);
|
||||
@ -524,7 +547,7 @@ WifiErrorNo WifiStaHalInterface::StopWps(void)
|
||||
{
|
||||
#ifdef HDI_WPA_INTERFACE_SUPPORT
|
||||
CHECK_NULL_AND_RETURN(mHdiWpaClient, WIFI_HAL_OPT_FAILED);
|
||||
return mHdiWpaClient->ReqStopWps();
|
||||
return mHdiWpaClient->ReqStopWps(WifiConfigCenter::GetInstance().GetStaIfaceName(INSTID_WLAN0).c_str());
|
||||
#else
|
||||
CHECK_NULL_AND_RETURN(mIdlClient, WIFI_HAL_OPT_FAILED);
|
||||
return mIdlClient->ReqStopWps();
|
||||
@ -542,11 +565,11 @@ WifiErrorNo WifiStaHalInterface::GetRoamingCapabilities(WifiHalRoamCapability &c
|
||||
#endif
|
||||
}
|
||||
|
||||
WifiErrorNo WifiStaHalInterface::SetBssid(int networkId, const std::string &bssid)
|
||||
WifiErrorNo WifiStaHalInterface::SetBssid(int networkId, const std::string &bssid, const std::string &ifaceName)
|
||||
{
|
||||
#ifdef HDI_WPA_INTERFACE_SUPPORT
|
||||
CHECK_NULL_AND_RETURN(mHdiWpaClient, WIFI_HAL_OPT_FAILED);
|
||||
return mHdiWpaClient->SetBssid(networkId, bssid);
|
||||
return mHdiWpaClient->SetBssid(networkId, bssid, ifaceName.c_str());
|
||||
#else
|
||||
CHECK_NULL_AND_RETURN(mIdlClient, WIFI_HAL_OPT_FAILED);
|
||||
return mIdlClient->SetBssid(networkId, bssid);
|
||||
@ -568,7 +591,8 @@ WifiErrorNo WifiStaHalInterface::WpaAutoConnect(int enable)
|
||||
{
|
||||
#ifdef HDI_WPA_INTERFACE_SUPPORT
|
||||
CHECK_NULL_AND_RETURN(mHdiWpaClient, WIFI_HAL_OPT_FAILED);
|
||||
return mHdiWpaClient->ReqWpaAutoConnect(enable);
|
||||
return mHdiWpaClient->ReqWpaAutoConnect(
|
||||
enable, WifiConfigCenter::GetInstance().GetStaIfaceName(INSTID_WLAN0).c_str());
|
||||
#else
|
||||
CHECK_NULL_AND_RETURN(mIdlClient, WIFI_HAL_OPT_FAILED);
|
||||
return mIdlClient->ReqWpaAutoConnect(enable);
|
||||
@ -579,7 +603,7 @@ WifiErrorNo WifiStaHalInterface::WpaBlocklistClear()
|
||||
{
|
||||
#ifdef HDI_WPA_INTERFACE_SUPPORT
|
||||
CHECK_NULL_AND_RETURN(mHdiWpaClient, WIFI_HAL_OPT_FAILED);
|
||||
return mHdiWpaClient->ReqWpaBlocklistClear();
|
||||
return mHdiWpaClient->ReqWpaBlocklistClear(WifiConfigCenter::GetInstance().GetStaIfaceName(INSTID_WLAN0).c_str());
|
||||
#else
|
||||
CHECK_NULL_AND_RETURN(mIdlClient, WIFI_HAL_OPT_FAILED);
|
||||
return mIdlClient->ReqWpaBlocklistClear();
|
||||
@ -710,9 +734,10 @@ WifiErrorNo WifiStaHalInterface::SetNetworkInterfaceUpDown(const std::string &if
|
||||
#endif
|
||||
}
|
||||
|
||||
const WifiEventCallback &WifiStaHalInterface::GetCallbackInst(void) const
|
||||
const WifiEventCallback &WifiStaHalInterface::GetCallbackInst(const std::string &ifaceName) const
|
||||
{
|
||||
return mStaCallback;
|
||||
int instId = GetInstId(ifaceName);
|
||||
return mStaCallback[instId];
|
||||
}
|
||||
|
||||
const std::function<void(int)> &WifiStaHalInterface::GetDeathCallbackInst(void) const
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "define.h"
|
||||
#include "wifi_base_hal_interface.h"
|
||||
#include "wifi_event_callback.h"
|
||||
#include "wifi_native_struct.h"
|
||||
@ -38,14 +39,14 @@ public:
|
||||
*
|
||||
* @return WifiErrorNo
|
||||
*/
|
||||
WifiErrorNo StartWifi(const std::string &ifaceName = "wlan0");
|
||||
WifiErrorNo StartWifi(const std::string &ifaceName = "wlan0", int instId = 0);
|
||||
|
||||
/**
|
||||
* @Description Close Wifi.
|
||||
*
|
||||
* @return WifiErrorNo
|
||||
*/
|
||||
WifiErrorNo StopWifi(void);
|
||||
WifiErrorNo StopWifi(int instId = 0);
|
||||
|
||||
/**
|
||||
* @Description Connect Wifi.
|
||||
@ -53,7 +54,7 @@ public:
|
||||
* @param networkId
|
||||
* @return WifiErrorNo
|
||||
*/
|
||||
WifiErrorNo Connect(int networkId);
|
||||
WifiErrorNo Connect(int networkId, const std::string &ifaceName);
|
||||
|
||||
/**
|
||||
* @Description Reconnect Wifi.
|
||||
@ -74,7 +75,7 @@ public:
|
||||
*
|
||||
* @return WifiErrorNo
|
||||
*/
|
||||
WifiErrorNo Disconnect(void);
|
||||
WifiErrorNo Disconnect(const std::string &ifaceName);
|
||||
|
||||
/**
|
||||
* @Description Obtaining the STA Support Capability.
|
||||
@ -90,7 +91,7 @@ public:
|
||||
* @param mac
|
||||
* @return WifiErrorNo
|
||||
*/
|
||||
WifiErrorNo GetStaDeviceMacAddress(std::string &mac);
|
||||
WifiErrorNo GetStaDeviceMacAddress(std::string &mac, const std::string &ifaceName);
|
||||
|
||||
/**
|
||||
* @Description Sets the Wi-Fi country code.
|
||||
@ -194,7 +195,7 @@ public:
|
||||
*
|
||||
* @return WifiErrorNo
|
||||
*/
|
||||
WifiErrorNo ClearDeviceConfig(void) const;
|
||||
WifiErrorNo ClearDeviceConfig(const std::string &ifaceName) const;
|
||||
|
||||
/**
|
||||
* @Description Request to obtain the next network ID.
|
||||
@ -202,7 +203,7 @@ public:
|
||||
* @param networkId
|
||||
* @return WifiErrorNo
|
||||
*/
|
||||
WifiErrorNo GetNextNetworkId(int &networkId);
|
||||
WifiErrorNo GetNextNetworkId(int &networkId, const std::string &ifaceName);
|
||||
|
||||
/**
|
||||
* @Description Enable a network.
|
||||
@ -210,7 +211,7 @@ public:
|
||||
* @param networkId
|
||||
* @return WifiErrorNo
|
||||
*/
|
||||
WifiErrorNo EnableNetwork(int networkId);
|
||||
WifiErrorNo EnableNetwork(int networkId, const std::string &ifaceName);
|
||||
|
||||
/**
|
||||
* @Description Disable a network.
|
||||
@ -218,7 +219,7 @@ public:
|
||||
* @param networkId
|
||||
* @return WifiErrorNo
|
||||
*/
|
||||
WifiErrorNo DisableNetwork(int networkId);
|
||||
WifiErrorNo DisableNetwork(int networkId, const std::string &ifaceName);
|
||||
|
||||
/**
|
||||
* @Description Setting the network.
|
||||
@ -227,7 +228,7 @@ public:
|
||||
* @param config
|
||||
* @return WifiErrorNo
|
||||
*/
|
||||
WifiErrorNo SetDeviceConfig(int networkId, const WifiHalDeviceConfig &config);
|
||||
WifiErrorNo SetDeviceConfig(int networkId, const WifiHalDeviceConfig &config, const std::string &ifaceName);
|
||||
|
||||
/**
|
||||
* @Description Obtaining Network Configurations.
|
||||
@ -235,7 +236,7 @@ public:
|
||||
* @param config
|
||||
* @return WifiErrorNo
|
||||
*/
|
||||
WifiErrorNo GetDeviceConfig(WifiHalGetDeviceConfig &config);
|
||||
WifiErrorNo GetDeviceConfig(WifiHalGetDeviceConfig &config, const std::string &ifaceName);
|
||||
|
||||
/**
|
||||
* @Description Save network config.
|
||||
@ -250,7 +251,7 @@ public:
|
||||
* @param callback
|
||||
* @return WifiErrorNo
|
||||
*/
|
||||
WifiErrorNo RegisterStaEventCallback(const WifiEventCallback &callback);
|
||||
WifiErrorNo RegisterStaEventCallback(const WifiEventCallback &callback, const std::string &ifaceName);
|
||||
|
||||
/**
|
||||
* @Description Enabling WPS in PBC Mode.
|
||||
@ -291,7 +292,7 @@ public:
|
||||
* @param bssid
|
||||
* @return WifiErrorNo
|
||||
*/
|
||||
WifiErrorNo SetBssid(int networkId, const std::string &bssid);
|
||||
WifiErrorNo SetBssid(int networkId, const std::string &bssid, const std::string &ifaceName);
|
||||
|
||||
/**
|
||||
* @Description Setting Roaming Configurations.
|
||||
@ -395,7 +396,7 @@ public:
|
||||
*
|
||||
* @return const WifiEventCallback& - register sta callback objects
|
||||
*/
|
||||
const WifiEventCallback &GetCallbackInst(void) const;
|
||||
const WifiEventCallback &GetCallbackInst(const std::string &ifaceName) const;
|
||||
|
||||
/**
|
||||
* @Description Get register callback objects for death receiver
|
||||
@ -413,7 +414,7 @@ public:
|
||||
WifiErrorNo RegisterNativeProcessCallback(const std::function<void(int)> &callback);
|
||||
|
||||
private:
|
||||
WifiEventCallback mStaCallback;
|
||||
WifiEventCallback mStaCallback[2];
|
||||
std::function<void(int)> mDeathCallback;
|
||||
};
|
||||
} // namespace Wifi
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "wifi_supplicant_hal_interface.h"
|
||||
#include <mutex>
|
||||
#include "wifi_log.h"
|
||||
#include "wifi_config_center.h"
|
||||
|
||||
#undef LOG_TAG
|
||||
#define LOG_TAG "WifiSupplicantHalInterface"
|
||||
@ -133,7 +134,8 @@ WifiErrorNo WifiSupplicantHalInterface::SetPowerSave(bool enable) const
|
||||
{
|
||||
#ifdef HDI_WPA_INTERFACE_SUPPORT
|
||||
CHECK_NULL_AND_RETURN(mHdiWpaClient, WIFI_HAL_OPT_FAILED);
|
||||
return mHdiWpaClient->ReqSetPowerSave(enable);
|
||||
return mHdiWpaClient->ReqSetPowerSave(
|
||||
enable, WifiConfigCenter::GetInstance().GetStaIfaceName(INSTID_WLAN0).c_str());
|
||||
#else
|
||||
CHECK_NULL_AND_RETURN(mIdlClient, WIFI_HAL_OPT_FAILED);
|
||||
return mIdlClient->ReqSetPowerSave(enable);
|
||||
@ -144,7 +146,8 @@ WifiErrorNo WifiSupplicantHalInterface::WpaSetCountryCode(const std::string &cou
|
||||
{
|
||||
#ifdef HDI_WPA_INTERFACE_SUPPORT
|
||||
CHECK_NULL_AND_RETURN(mHdiWpaClient, WIFI_HAL_OPT_FAILED);
|
||||
return mHdiWpaClient->ReqWpaSetCountryCode(countryCode);
|
||||
return mHdiWpaClient->ReqWpaSetCountryCode(
|
||||
countryCode, WifiConfigCenter::GetInstance().GetStaIfaceName(INSTID_WLAN0).c_str());
|
||||
#else
|
||||
CHECK_NULL_AND_RETURN(mIdlClient, WIFI_HAL_OPT_FAILED);
|
||||
return mIdlClient->ReqWpaSetCountryCode(countryCode);
|
||||
@ -155,7 +158,8 @@ WifiErrorNo WifiSupplicantHalInterface::WpaGetCountryCode(std::string &countryCo
|
||||
{
|
||||
#ifdef HDI_WPA_INTERFACE_SUPPORT
|
||||
CHECK_NULL_AND_RETURN(mHdiWpaClient, WIFI_HAL_OPT_FAILED);
|
||||
return mHdiWpaClient->ReqWpaGetCountryCode(countryCode);
|
||||
return mHdiWpaClient->ReqWpaGetCountryCode(
|
||||
countryCode, WifiConfigCenter::GetInstance().GetStaIfaceName(INSTID_WLAN0).c_str());
|
||||
#else
|
||||
CHECK_NULL_AND_RETURN(mIdlClient, WIFI_HAL_OPT_FAILED);
|
||||
return mIdlClient->ReqWpaGetCountryCode(countryCode);
|
||||
@ -171,7 +175,8 @@ WifiErrorNo WifiSupplicantHalInterface::WpaSetSuspendMode(bool mode) const
|
||||
{
|
||||
#ifdef HDI_WPA_INTERFACE_SUPPORT
|
||||
CHECK_NULL_AND_RETURN(mHdiWpaClient, WIFI_HAL_OPT_FAILED);
|
||||
return mHdiWpaClient->ReqWpaSetSuspendMode(mode);
|
||||
return mHdiWpaClient->ReqWpaSetSuspendMode(
|
||||
mode, WifiConfigCenter::GetInstance().GetStaIfaceName(INSTID_WLAN0).c_str());
|
||||
#else
|
||||
CHECK_NULL_AND_RETURN(mIdlClient, WIFI_HAL_OPT_FAILED);
|
||||
return mIdlClient->ReqWpaSetSuspendMode(mode);
|
||||
@ -182,7 +187,7 @@ WifiErrorNo WifiSupplicantHalInterface::WpaSetPowerMode(bool mode) const
|
||||
{
|
||||
#ifdef HDI_WPA_INTERFACE_SUPPORT
|
||||
CHECK_NULL_AND_RETURN(mHdiWpaClient, WIFI_HAL_OPT_FAILED);
|
||||
return mHdiWpaClient->ReqSetPowerSave(mode);
|
||||
return mHdiWpaClient->ReqSetPowerSave(mode, WifiConfigCenter::GetInstance().GetStaIfaceName(INSTID_WLAN0).c_str());
|
||||
#else
|
||||
CHECK_NULL_AND_RETURN(mIdlClient, WIFI_HAL_OPT_FAILED);
|
||||
return mIdlClient->ReqWpaSetPowerMode(!mode); // idl impl need revese power mode
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "wifi_base_hal_interface.h"
|
||||
#include "wifi_error_no.h"
|
||||
#include "i_wifi_struct.h"
|
||||
#include "define.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Wifi {
|
||||
|
@ -104,7 +104,7 @@ int WifiServiceManager::CheckPreLoadService(void)
|
||||
for (auto iter = mServiceDllMap.begin(); iter != mServiceDllMap.end(); ++iter) {
|
||||
bool bLoad = WifiSettings::GetInstance().IsModulePreLoad(iter->first);
|
||||
if (bLoad) {
|
||||
int ret = CheckAndEnforceService(iter->first, false);
|
||||
int ret = CheckAndEnforceService(iter->first, 0, false);
|
||||
if (ret < 0) {
|
||||
return -1;
|
||||
}
|
||||
@ -113,15 +113,17 @@ int WifiServiceManager::CheckPreLoadService(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int WifiServiceManager::LoadStaService(const std::string &dlname, bool bCreate)
|
||||
int WifiServiceManager::LoadStaService(const std::string &dlname, int instId, bool bCreate)
|
||||
{
|
||||
WIFI_LOGI("LoadStaService");
|
||||
WIFI_LOGI("LoadStaService, insId %{public}d", instId);
|
||||
std::unique_lock<std::mutex> lock(mStaMutex);
|
||||
if (mStaServiceHandle.pService[0]) {
|
||||
if (mStaServiceHandle.pService[instId]) {
|
||||
WIFI_LOGE("WifiServiceManager::LoadStaService pService is not NULL");
|
||||
return 0;
|
||||
}
|
||||
IStaService *service = new StaInterface();
|
||||
mStaServiceHandle.pService[0] = service;
|
||||
IStaService *service = new StaInterface(instId);
|
||||
mStaServiceHandle.pService[instId] = service;
|
||||
WIFI_LOGI("WifiServiceManager::LoadStaService new pService %{public}d", instId);
|
||||
WifiManager::GetInstance().GetWifiStaManager()->StopUnloadStaSaTimer();
|
||||
return 0;
|
||||
}
|
||||
@ -209,7 +211,7 @@ int WifiServiceManager::LoadEnhanceService(const std::string &dlname, bool bCrea
|
||||
return 0;
|
||||
}
|
||||
|
||||
int WifiServiceManager::CheckAndEnforceService(const std::string &name, bool bCreate)
|
||||
int WifiServiceManager::CheckAndEnforceService(const std::string &name, int instId, bool bCreate)
|
||||
{
|
||||
WIFI_LOGD("WifiServiceManager::CheckAndEnforceService name: %{public}s", name.c_str());
|
||||
std::string dlname;
|
||||
@ -219,7 +221,7 @@ int WifiServiceManager::CheckAndEnforceService(const std::string &name, bool bCr
|
||||
}
|
||||
WIFI_LOGD("WifiServiceManager::CheckAndEnforceService get dllname: %{public}s", dlname.c_str());
|
||||
if (name == WIFI_SERVICE_STA) {
|
||||
return LoadStaService(dlname, bCreate);
|
||||
return LoadStaService(dlname, instId, bCreate);
|
||||
}
|
||||
#ifdef FEATURE_SELF_CURE_SUPPORT
|
||||
if (name == WIFI_SERVICE_SELFCURE) {
|
||||
|
@ -143,7 +143,7 @@ public:
|
||||
* @param bCreate - whether create the service instance
|
||||
* @return int - 0 success; -1 feature service name not correct or load service failed
|
||||
*/
|
||||
int CheckAndEnforceService(const std::string &name, bool bCreate = true);
|
||||
int CheckAndEnforceService(const std::string &name, int instId = 0, bool bCreate = true);
|
||||
|
||||
/**
|
||||
* @Description Get the Sta Service Inst object
|
||||
@ -214,7 +214,7 @@ public:
|
||||
|
||||
private:
|
||||
int GetServiceDll(const std::string &name, std::string &dlname);
|
||||
int LoadStaService(const std::string &dlname, bool bCreate);
|
||||
int LoadStaService(const std::string &dlname, int insId, bool bCreate);
|
||||
int UnloadStaService(bool bPreLoad, int instId = 0);
|
||||
#ifdef FEATURE_SELF_CURE_SUPPORT
|
||||
int LoadSelfCureService(const std::string &dlname, bool bCreate);
|
||||
|
@ -22,7 +22,9 @@ DEFINE_WIFILOG_LABEL("StaInterface");
|
||||
namespace OHOS {
|
||||
namespace Wifi {
|
||||
StaInterface::StaInterface(int instId) : pStaService(nullptr), m_instId(instId)
|
||||
{}
|
||||
{
|
||||
WIFI_LOGI("StaInterface constuctor instId %{public}d", instId);
|
||||
}
|
||||
|
||||
StaInterface::~StaInterface()
|
||||
{
|
||||
@ -47,7 +49,7 @@ extern "C" void Destroy(IStaService *pservice)
|
||||
|
||||
ErrCode StaInterface::EnableStaService()
|
||||
{
|
||||
WIFI_LOGI("Enter EnableStaService.\n");
|
||||
WIFI_LOGI("Enter EnableStaService m_instId:%{public}d\n", m_instId);
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
if (!InitStaServiceLocked()) {
|
||||
return WIFI_OPT_FAILED;
|
||||
@ -55,7 +57,7 @@ ErrCode StaInterface::EnableStaService()
|
||||
|
||||
CHECK_NULL_AND_RETURN(pStaService, WIFI_OPT_FAILED);
|
||||
if (pStaService->EnableStaService() != WIFI_OPT_SUCCESS) {
|
||||
LOGE("EnableStaService failed.\n");
|
||||
LOGE("EnableStaService failed m_instId:%{public}d\n", m_instId);
|
||||
pStaService->DisableStaService();
|
||||
return WIFI_OPT_FAILED;
|
||||
}
|
||||
@ -64,7 +66,7 @@ ErrCode StaInterface::EnableStaService()
|
||||
|
||||
ErrCode StaInterface::DisableStaService()
|
||||
{
|
||||
LOGI("Enter DisableStaService.\n");
|
||||
WIFI_LOGI("Enter DisableStaService m_instId:%{public}d\n", m_instId);
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
CHECK_NULL_AND_RETURN(pStaService, WIFI_OPT_FAILED);
|
||||
if (pStaService->DisableStaService() != WIFI_OPT_SUCCESS) {
|
||||
@ -496,14 +498,15 @@ ErrCode StaInterface::DeliverStaIfaceData(const std::string ¤tMac)
|
||||
|
||||
bool StaInterface::InitStaServiceLocked()
|
||||
{
|
||||
WIFI_LOGI("InitStaServiceLocked m_instId:%{public}d\n", m_instId);
|
||||
if (pStaService == nullptr) {
|
||||
pStaService = new (std::nothrow) StaService(m_instId);
|
||||
if (pStaService == nullptr) {
|
||||
WIFI_LOGE("New StaService failed.\n");
|
||||
WIFI_LOGE("New StaService m_instId:%{public}d\n", m_instId);
|
||||
return false;
|
||||
}
|
||||
if (pStaService->InitStaService(m_staCallback) != WIFI_OPT_SUCCESS) {
|
||||
WIFI_LOGE("InitStaService failed.\n");
|
||||
WIFI_LOGE("InitStaService m_instId:%{public}d\n", m_instId);
|
||||
delete pStaService;
|
||||
pStaService = nullptr;
|
||||
return false;
|
||||
|
@ -29,7 +29,9 @@ DEFINE_WIFILOG_LABEL("StaMonitor");
|
||||
namespace OHOS {
|
||||
namespace Wifi {
|
||||
StaMonitor::StaMonitor(int instId) : pStaStateMachine(nullptr), m_instId(instId)
|
||||
{}
|
||||
{
|
||||
WIFI_LOGI("StaMonitor constuctor insId %{public}d", instId);
|
||||
}
|
||||
|
||||
StaMonitor::~StaMonitor()
|
||||
{
|
||||
@ -56,7 +58,8 @@ ErrCode StaMonitor::InitStaMonitor()
|
||||
[this](int reason, const std::string &bssid) { this->OnReportDisConnectReasonCallBack(reason, bssid); },
|
||||
};
|
||||
|
||||
if (WifiStaHalInterface::GetInstance().RegisterStaEventCallback(callBack) != WIFI_HAL_OPT_OK) {
|
||||
std::string ifaceName = WifiConfigCenter::GetInstance().GetStaIfaceName(m_instId);
|
||||
if (WifiStaHalInterface::GetInstance().RegisterStaEventCallback(callBack, ifaceName) != WIFI_HAL_OPT_OK) {
|
||||
WIFI_LOGE("InitStaMonitor RegisterStaEventCallback failed!");
|
||||
return WIFI_OPT_FAILED;
|
||||
}
|
||||
@ -67,7 +70,8 @@ NO_SANITIZE("cfi") ErrCode StaMonitor::UnInitStaMonitor() const
|
||||
{
|
||||
WIFI_LOGI("Enter UnInitStaMonitor.\n");
|
||||
WifiEventCallback callBack;
|
||||
if (WifiStaHalInterface::GetInstance().RegisterStaEventCallback(callBack) != WIFI_HAL_OPT_OK) {
|
||||
std::string ifaceName = WifiConfigCenter::GetInstance().GetStaIfaceName(m_instId);
|
||||
if (WifiStaHalInterface::GetInstance().RegisterStaEventCallback(callBack, ifaceName) != WIFI_HAL_OPT_OK) {
|
||||
WIFI_LOGE("~StaMonitor RegisterStaEventCallback failed!");
|
||||
return WIFI_OPT_FAILED;
|
||||
}
|
||||
@ -106,10 +110,8 @@ void StaMonitor::OnReportDisConnectReasonCallBack(int reason, const std::string
|
||||
|
||||
void StaMonitor::OnConnectChangedCallBack(int status, int networkId, const std::string &bssid)
|
||||
{
|
||||
WIFI_LOGI("OnConnectChangedCallBack() status:%{public}d,networkId=%{public}d,bssid=%{public}s",
|
||||
status,
|
||||
networkId,
|
||||
MacAnonymize(bssid).c_str());
|
||||
WIFI_LOGI("OnConnectChangedCallBack status:%{public}d, networkId=%{public}d, bssid=%{public}s, instId=%{public}d",
|
||||
status, networkId, MacAnonymize(bssid).c_str(), m_instId);
|
||||
if (pStaStateMachine == nullptr) {
|
||||
WIFI_LOGE("The statemachine pointer is null.");
|
||||
return;
|
||||
|
@ -97,7 +97,7 @@ StaService::~StaService()
|
||||
|
||||
ErrCode StaService::InitStaService(const std::vector<StaServiceCallback> &callbacks)
|
||||
{
|
||||
WIFI_LOGI("Enter InitStaService.\n");
|
||||
WIFI_LOGI("Enter InitStaService m_instId:%{public}d\n", m_instId);
|
||||
pStaStateMachine = new (std::nothrow) StaStateMachine(m_instId);
|
||||
if (pStaStateMachine == nullptr) {
|
||||
WIFI_LOGE("Alloc pStaStateMachine failed.\n");
|
||||
@ -124,30 +124,32 @@ ErrCode StaService::InitStaService(const std::vector<StaServiceCallback> &callba
|
||||
|
||||
pStaMonitor->SetStateMachine(pStaStateMachine);
|
||||
|
||||
pStaAutoConnectService = new (std::nothrow) StaAutoConnectService(pStaStateMachine, m_instId);
|
||||
if (pStaAutoConnectService == nullptr) {
|
||||
WIFI_LOGE("Alloc pStaAutoConnectService failed.\n");
|
||||
return WIFI_OPT_FAILED;
|
||||
}
|
||||
if (pStaAutoConnectService->InitAutoConnectService() != WIFI_OPT_SUCCESS) {
|
||||
WIFI_LOGE("InitAutoConnectService failed.\n");
|
||||
return WIFI_OPT_FAILED;
|
||||
}
|
||||
pStaAutoConnectService->SetAutoConnectStateCallback(callbacks);
|
||||
if (m_instId == INSTID_WLAN0) {
|
||||
pStaAutoConnectService = new (std::nothrow) StaAutoConnectService(pStaStateMachine, m_instId);
|
||||
if (pStaAutoConnectService == nullptr) {
|
||||
WIFI_LOGE("Alloc pStaAutoConnectService failed.\n");
|
||||
return WIFI_OPT_FAILED;
|
||||
}
|
||||
if (pStaAutoConnectService->InitAutoConnectService() != WIFI_OPT_SUCCESS) {
|
||||
WIFI_LOGE("InitAutoConnectService failed.\n");
|
||||
return WIFI_OPT_FAILED;
|
||||
}
|
||||
pStaAutoConnectService->SetAutoConnectStateCallback(callbacks);
|
||||
#ifndef OHOS_ARCH_LITE
|
||||
pStaAppAcceleration = new (std::nothrow) StaAppAcceleration(m_instId);
|
||||
if (pStaAppAcceleration == nullptr) {
|
||||
WIFI_LOGE("Alloc pStaAppAcceleration failed.\n");
|
||||
}
|
||||
pStaAppAcceleration = new (std::nothrow) StaAppAcceleration(m_instId);
|
||||
if (pStaAppAcceleration == nullptr) {
|
||||
WIFI_LOGE("Alloc pStaAppAcceleration failed.\n");
|
||||
}
|
||||
|
||||
if (pStaAppAcceleration->InitAppAcceleration() != WIFI_OPT_SUCCESS) {
|
||||
WIFI_LOGE("InitAppAcceleration failed.\n");
|
||||
}
|
||||
std::vector<StaServiceCallback> appAccelerationStaCallBacks;
|
||||
appAccelerationStaCallBacks.push_back(pStaAppAcceleration->GetStaCallback());
|
||||
RegisterStaServiceCallback(appAccelerationStaCallBacks);
|
||||
GetStaControlInfo();
|
||||
if (pStaAppAcceleration->InitAppAcceleration() != WIFI_OPT_SUCCESS) {
|
||||
WIFI_LOGE("InitAppAcceleration failed.\n");
|
||||
}
|
||||
std::vector<StaServiceCallback> appAccelerationStaCallBacks;
|
||||
appAccelerationStaCallBacks.push_back(pStaAppAcceleration->GetStaCallback());
|
||||
RegisterStaServiceCallback(appAccelerationStaCallBacks);
|
||||
GetStaControlInfo();
|
||||
#endif
|
||||
}
|
||||
WIFI_LOGI("Init staservice successfully.\n");
|
||||
return WIFI_OPT_SUCCESS;
|
||||
}
|
||||
@ -179,7 +181,7 @@ bool StaService::IsAppInCandidateFilterList(int uid) const
|
||||
|
||||
ErrCode StaService::EnableStaService()
|
||||
{
|
||||
WIFI_LOGI("Enter EnableStaService.\n");
|
||||
WIFI_LOGI("Enter EnableStaService m_instId:%{public}d\n", m_instId);
|
||||
CHECK_NULL_AND_RETURN(pStaStateMachine, WIFI_OPT_FAILED);
|
||||
#ifndef OHOS_ARCH_LITE
|
||||
// notification of registration country code change
|
||||
@ -189,7 +191,9 @@ ErrCode StaService::EnableStaService()
|
||||
WIFI_LOGI("m_staObserver is null\n");
|
||||
return WIFI_OPT_FAILED;
|
||||
}
|
||||
WifiCountryCodeManager::GetInstance().RegisterWifiCountryCodeChangeListener(m_staObserver);
|
||||
if (m_instId == INSTID_WLAN0) {
|
||||
WifiCountryCodeManager::GetInstance().RegisterWifiCountryCodeChangeListener(m_staObserver);
|
||||
}
|
||||
#endif
|
||||
WifiSettings::GetInstance().ReloadDeviceConfig();
|
||||
pStaStateMachine->SendMessage(WIFI_SVR_CMD_STA_ENABLE_STA, STA_CONNECT_MODE);
|
||||
@ -298,7 +302,7 @@ ErrCode StaService::ConnectToCandidateConfig(const int uid, const int networkId)
|
||||
|
||||
std::string StaService::ConvertString(const std::u16string &wideText) const
|
||||
{
|
||||
return std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> {}.to_bytes(wideText);
|
||||
return std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>{}.to_bytes(wideText);
|
||||
}
|
||||
|
||||
#ifndef OHOS_ARCH_LITE
|
||||
@ -407,6 +411,7 @@ int StaService::AddDeviceConfig(const WifiDeviceConfig &config) const
|
||||
std::string userSelectbssid = config.bssid;
|
||||
int status = config.status;
|
||||
WifiDeviceConfig tempDeviceConfig;
|
||||
tempDeviceConfig.instanceId = config.instanceId;
|
||||
if (FindDeviceConfig(config, tempDeviceConfig) == 0) {
|
||||
netWorkId = tempDeviceConfig.networkId;
|
||||
status = tempDeviceConfig.status;
|
||||
@ -471,15 +476,16 @@ int StaService::UpdateDeviceConfig(const WifiDeviceConfig &config) const
|
||||
|
||||
ErrCode StaService::RemoveDevice(int networkId) const
|
||||
{
|
||||
LOGI("Enter RemoveDevice, networkId = %{public}d.\n", networkId);
|
||||
LOGI("Enter RemoveDevice, networkId = %{public}d m_instId:%{public}d\n", networkId, m_instId);
|
||||
WifiLinkedInfo linkedInfo;
|
||||
WifiConfigCenter::GetInstance().GetLinkedInfo(linkedInfo, m_instId);
|
||||
if (linkedInfo.networkId == networkId) {
|
||||
WifiStaHalInterface::GetInstance().ClearDeviceConfig();
|
||||
std::string ifaceName = WifiConfigCenter::GetInstance().GetStaIfaceName(m_instId);
|
||||
WifiStaHalInterface::GetInstance().ClearDeviceConfig(ifaceName);
|
||||
}
|
||||
|
||||
WifiDeviceConfig config;
|
||||
if (WifiSettings::GetInstance().GetDeviceConfig(networkId, config) == 0) {
|
||||
if (WifiSettings::GetInstance().GetDeviceConfig(networkId, config, m_instId) == 0) {
|
||||
CHECK_NULL_AND_RETURN(pStaAutoConnectService, WIFI_OPT_FAILED);
|
||||
pStaAutoConnectService->EnableOrDisableBssid(config.bssid, true, 0);
|
||||
} else {
|
||||
@ -507,7 +513,8 @@ ErrCode StaService::RemoveDevice(int networkId) const
|
||||
ErrCode StaService::RemoveAllDevice() const
|
||||
{
|
||||
LOGI("Enter RemoveAllDevice.\n");
|
||||
if (WifiStaHalInterface::GetInstance().ClearDeviceConfig() == WIFI_HAL_OPT_OK) {
|
||||
std::string ifaceName = WifiConfigCenter::GetInstance().GetStaIfaceName(m_instId);
|
||||
if (WifiStaHalInterface::GetInstance().ClearDeviceConfig(ifaceName) == WIFI_HAL_OPT_OK) {
|
||||
LOGD("Remove all device config successfully!");
|
||||
} else {
|
||||
LOGE("WifiStaHalInterface:RemoveAllDevice failed!");
|
||||
@ -538,10 +545,11 @@ ErrCode StaService::RemoveAllDevice() const
|
||||
|
||||
ErrCode StaService::ConnectToDevice(const WifiDeviceConfig &config) const
|
||||
{
|
||||
LOGI("Enter ConnectToDevice, ssid = %{public}s.\n", SsidAnonymize(config.ssid).c_str());
|
||||
LOGI(
|
||||
"Enter ConnectToDevice, ssid = %{public}s instId:%{public}d. \n", SsidAnonymize(config.ssid).c_str(), m_instId);
|
||||
CHECK_NULL_AND_RETURN(pStaStateMachine, WIFI_OPT_FAILED);
|
||||
int netWorkId = AddDeviceConfig(config);
|
||||
if(netWorkId == INVALID_NETWORK_ID) {
|
||||
if (netWorkId == INVALID_NETWORK_ID) {
|
||||
LOGD("ConnectToDevice, AddDeviceConfig failed!");
|
||||
return WIFI_OPT_FAILED;
|
||||
}
|
||||
@ -554,7 +562,7 @@ ErrCode StaService::ConnectToNetwork(int networkId) const
|
||||
{
|
||||
LOGI("Enter ConnectToNetwork, networkId is %{public}d.", networkId);
|
||||
WifiDeviceConfig config;
|
||||
if (WifiSettings::GetInstance().GetDeviceConfig(networkId, config) != 0) {
|
||||
if (WifiSettings::GetInstance().GetDeviceConfig(networkId, config, m_instId) != 0) {
|
||||
LOGE("WifiDeviceConfig is null!");
|
||||
return WIFI_OPT_FAILED;
|
||||
}
|
||||
@ -571,7 +579,7 @@ ErrCode StaService::StartRoamToNetwork(const int networkId, const std::string bs
|
||||
{
|
||||
LOGI("Enter StartRoamToNetwork, networkId: %{public}d, bssid: %{public}s", networkId, MacAnonymize(bssid).c_str());
|
||||
WifiDeviceConfig config;
|
||||
if (WifiSettings::GetInstance().GetDeviceConfig(networkId, config) != 0) {
|
||||
if (WifiSettings::GetInstance().GetDeviceConfig(networkId, config, m_instId) != 0) {
|
||||
LOGE("%{public}s WifiDeviceConfig is null!", __FUNCTION__);
|
||||
return WIFI_OPT_FAILED;
|
||||
}
|
||||
@ -603,7 +611,7 @@ ErrCode StaService::StartConnectToUserSelectNetwork(int networkId, std::string b
|
||||
LOGI("Enter StartConnectToUserSelectNetwork, networkId: %{public}d, bssid: %{public}s",
|
||||
networkId, MacAnonymize(bssid).c_str());
|
||||
WifiDeviceConfig config;
|
||||
if (WifiSettings::GetInstance().GetDeviceConfig(networkId, config) != 0) {
|
||||
if (WifiSettings::GetInstance().GetDeviceConfig(networkId, config, m_instId) != 0) {
|
||||
LOGE("%{public}s WifiDeviceConfig is null!", __FUNCTION__);
|
||||
return WIFI_OPT_FAILED;
|
||||
}
|
||||
@ -777,7 +785,7 @@ int StaService::FindDeviceConfig(const WifiDeviceConfig &config, WifiDeviceConfi
|
||||
if (config.uid > WIFI_INVALID_UID) {
|
||||
ret = WifiSettings::GetInstance().GetCandidateConfig(config.uid, config.ssid, config.keyMgmt, outConfig);
|
||||
} else {
|
||||
ret = WifiSettings::GetInstance().GetDeviceConfig(config.ssid, config.keyMgmt, outConfig);
|
||||
ret = WifiSettings::GetInstance().GetDeviceConfig(config.ssid, config.keyMgmt, outConfig, m_instId);
|
||||
}
|
||||
LOGI("FindDeviceConfig uid:%{public}d, ssid:%{public}s, ret:%{public}d.", config.uid,
|
||||
SsidAnonymize(outConfig.ssid).c_str(), ret);
|
||||
@ -860,7 +868,7 @@ ErrCode StaService::EnableAutoJoin(const std::string &conditionName)
|
||||
}
|
||||
|
||||
ErrCode StaService::RegisterAutoJoinCondition(const std::string &conditionName,
|
||||
const std::function<bool()> &autoJoinCondition)
|
||||
const std::function<bool()> &autoJoinCondition)
|
||||
{
|
||||
CHECK_NULL_AND_RETURN(pStaAutoConnectService, WIFI_OPT_FAILED);
|
||||
pStaAutoConnectService->RegisterAutoJoinCondition(conditionName, autoJoinCondition);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -553,6 +553,8 @@ public:
|
||||
#ifndef OHOS_ARCH_LITE
|
||||
void SetEnhanceService(IEnhanceService* enhanceService);
|
||||
#endif
|
||||
|
||||
bool SetMacToHal(const std::string ¤tMac, const std::string &realMac, int instId);
|
||||
private:
|
||||
/**
|
||||
* @Description Destruct state.
|
||||
@ -1269,6 +1271,7 @@ private:
|
||||
bool IsGoodSignalQuality();
|
||||
void AppendFastTransitionKeyMgmt(const WifiScanInfo &scanInfo, WifiHalDeviceConfig &halDeviceConfig) const;
|
||||
void ConvertSsidToOriginalSsid(const WifiDeviceConfig &config, WifiHalDeviceConfig &halDeviceConfig) const;
|
||||
void CreateWifi2Config(int &networkId);
|
||||
};
|
||||
} // namespace Wifi
|
||||
} // namespace OHOS
|
||||
|
@ -147,8 +147,8 @@ ErrCode WifiDeviceServiceImpl::DisableWifi()
|
||||
return WIFI_OPT_PERMISSION_DENIED;
|
||||
}
|
||||
|
||||
if (m_instId == 0) {
|
||||
WifiConfigCenter::GetInstance().SetWifiToggledState(WIFI_STATE_DISABLED);
|
||||
if (m_instId == INSTID_WLAN0 || m_instId == INSTID_WLAN1) {
|
||||
WifiConfigCenter::GetInstance().SetWifiToggledState(WIFI_STATE_DISABLED, m_instId);
|
||||
WifiConfigCenter::GetInstance().SetWifiAllowSemiActive(false);
|
||||
}
|
||||
|
||||
@ -184,7 +184,7 @@ ErrCode WifiDeviceServiceImpl::EnableSemiWifi()
|
||||
return WIFI_OPT_FORBID_AIRPLANE;
|
||||
}
|
||||
#endif
|
||||
if (m_instId == 0) {
|
||||
if (m_instId == INSTID_WLAN0 || m_instId == INSTID_WLAN1) {
|
||||
WifiConfigCenter::GetInstance().SetWifiToggledState(WIFI_STATE_SEMI_ENABLED);
|
||||
}
|
||||
|
||||
@ -1760,8 +1760,8 @@ ErrCode WifiDeviceServiceImpl::FactoryReset()
|
||||
}
|
||||
|
||||
WIFI_LOGI("WifiDeviceServiceImpl FactoryReset sta,p2p,hotspot! m_instId:%{public}d", m_instId);
|
||||
if (m_instId == 0) {
|
||||
WifiConfigCenter::GetInstance().SetWifiToggledState(WIFI_STATE_SEMI_ENABLED);
|
||||
if (m_instId >= 0 || m_instId < STA_INSTANCE_MAX_NUM) {
|
||||
WifiConfigCenter::GetInstance().SetWifiToggledState(WIFI_STATE_SEMI_ENABLED, m_instId);
|
||||
}
|
||||
WifiManager::GetInstance().GetWifiTogglerManager()->WifiToggled(0, m_instId);
|
||||
WifiOprMidState curState = WifiConfigCenter::GetInstance().GetApMidState(m_instId);
|
||||
|
@ -445,14 +445,14 @@ void WifiEventSubscriberManager::CheckAndStartStaByDatashare()
|
||||
|
||||
int lastStaState = GetLastStaStateByDatashare();
|
||||
if (lastStaState == openWifi) {
|
||||
WifiConfigCenter::GetInstance().SetWifiToggledState(WIFI_STATE_ENABLED);
|
||||
WifiConfigCenter::GetInstance().SetWifiToggledState(WIFI_STATE_ENABLED, INSTID_WLAN0);
|
||||
WifiManager::GetInstance().GetWifiTogglerManager()->WifiToggled(1, 0);
|
||||
} else if (lastStaState == openWifiInAirplanemode) {
|
||||
WifiSettings::GetInstance().SetWifiFlagOnAirplaneMode(true);
|
||||
WifiConfigCenter::GetInstance().SetWifiToggledState(WIFI_STATE_ENABLED);
|
||||
WifiConfigCenter::GetInstance().SetWifiToggledState(WIFI_STATE_ENABLED, INSTID_WLAN0);
|
||||
WifiManager::GetInstance().GetWifiTogglerManager()->WifiToggled(1, 0);
|
||||
} else if (lastStaState == closeWifiByAirplanemodeOpen) {
|
||||
WifiConfigCenter::GetInstance().SetWifiToggledState(WIFI_STATE_ENABLED);
|
||||
WifiConfigCenter::GetInstance().SetWifiToggledState(WIFI_STATE_ENABLED, INSTID_WLAN0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,6 +49,7 @@ WifiTogglerManager::WifiTogglerManager()
|
||||
#endif
|
||||
InitConcreteCallback();
|
||||
InitSoftapCallback();
|
||||
InitMultiStacallback();
|
||||
pWifiControllerMachine = std::make_unique<WifiControllerMachine>();
|
||||
if (pWifiControllerMachine) {
|
||||
pWifiControllerMachine->InitWifiControllerMachine();
|
||||
@ -65,9 +66,15 @@ SoftApModeCallback& WifiTogglerManager::GetSoftApCallback()
|
||||
return mSoftApModeCb;
|
||||
}
|
||||
|
||||
MultiStaModeCallback& WifiTogglerManager::GetMultiStaCallback()
|
||||
{
|
||||
return mMultiStaModeCb;
|
||||
}
|
||||
|
||||
ErrCode WifiTogglerManager::WifiToggled(int isOpen, int id)
|
||||
{
|
||||
pWifiControllerMachine->ClearWifiStartFailCount();
|
||||
WIFI_LOGI("WifiTogglerManager::WifiToggled, isOpen %{public}d instId: %{public}d", isOpen, id);
|
||||
pWifiControllerMachine->SendMessage(CMD_WIFI_TOGGLED, isOpen, id);
|
||||
return WIFI_OPT_SUCCESS;
|
||||
}
|
||||
@ -133,6 +140,13 @@ void WifiTogglerManager::InitSoftapCallback()
|
||||
mSoftApModeCb.onStopped = std::bind(&WifiTogglerManager::DealSoftapStop, this, _1);
|
||||
}
|
||||
|
||||
void WifiTogglerManager::InitMultiStacallback()
|
||||
{
|
||||
using namespace std::placeholders;
|
||||
mMultiStaModeCb.onStartFailure = std::bind(&WifiTogglerManager::DealMultiStaStartFailure, this, _1);
|
||||
mMultiStaModeCb.onStopped = std::bind(&WifiTogglerManager::DealMultiStaStop, this, _1);
|
||||
}
|
||||
|
||||
void WifiTogglerManager::DealConcreateStop(int id)
|
||||
{
|
||||
if (pWifiControllerMachine) {
|
||||
@ -168,6 +182,20 @@ void WifiTogglerManager::DealClientRemoved(int id)
|
||||
}
|
||||
}
|
||||
|
||||
void WifiTogglerManager::DealMultiStaStartFailure(int id)
|
||||
{
|
||||
if (pWifiControllerMachine) {
|
||||
pWifiControllerMachine->SendMessage(CMD_STA_START_FAILURE, id);
|
||||
}
|
||||
}
|
||||
|
||||
void WifiTogglerManager::DealMultiStaStop(int id)
|
||||
{
|
||||
if (pWifiControllerMachine) {
|
||||
pWifiControllerMachine->SendMessage(CMD_MULTI_STA_STOPPED, id);
|
||||
}
|
||||
}
|
||||
|
||||
void WifiTogglerManager::ForceStopWifi()
|
||||
{
|
||||
if (pWifiControllerMachine) {
|
||||
|
@ -31,6 +31,7 @@ public:
|
||||
~WifiTogglerManager() = default;
|
||||
|
||||
ConcreteModeCallback& GetConcreteCallback(void);
|
||||
MultiStaModeCallback &GetMultiStaCallback();
|
||||
SoftApModeCallback& GetSoftApCallback(void);
|
||||
ErrCode WifiToggled(int isOpen, int id = 0);
|
||||
ErrCode SoftapToggled(int isOpen, int id = 0);
|
||||
@ -48,17 +49,21 @@ public:
|
||||
private:
|
||||
void InitConcreteCallback(void);
|
||||
void InitSoftapCallback(void);
|
||||
void InitMultiStacallback();
|
||||
void DealConcreateStop(int id = 0);
|
||||
void DealConcreateStartFailure(int id = 0);
|
||||
void DealSoftapStop(int id = 0);
|
||||
void DealSoftapStartFailure(int id = 0);
|
||||
void DealClientRemoved(int id = 0);
|
||||
void DealMultiStaStartFailure(int id);
|
||||
void DealMultiStaStop(int id);
|
||||
void CheckSatelliteState();
|
||||
bool IsInterfaceUp(std::string &iface);
|
||||
|
||||
private:
|
||||
ConcreteModeCallback mConcreteModeCb;
|
||||
SoftApModeCallback mSoftApModeCb;
|
||||
MultiStaModeCallback mMultiStaModeCb;
|
||||
std::unique_ptr<WifiControllerMachine> pWifiControllerMachine = nullptr;
|
||||
};
|
||||
|
||||
|
@ -74,7 +74,7 @@ int WifiConfigCenter::Init()
|
||||
InitScanControlForbidList();
|
||||
InitScanControlIntervalList();
|
||||
ClearLocalHid2dInfo();
|
||||
mPersistWifiState = WifiSettings::GetInstance().GetOperatorWifiType();
|
||||
mPersistWifiState[INSTID_WLAN0] = WifiSettings::GetInstance().GetOperatorWifiType(INSTID_WLAN0);
|
||||
mAirplaneModeState = WifiSettings::GetInstance().GetLastAirplaneMode();
|
||||
return 0;
|
||||
}
|
||||
@ -143,16 +143,18 @@ bool WifiConfigCenter::GetWifiStopState() const
|
||||
return mWifiStoping.load();
|
||||
}
|
||||
|
||||
void WifiConfigCenter::SetStaIfaceName(const std::string &ifaceName)
|
||||
void WifiConfigCenter::SetStaIfaceName(const std::string &ifaceName, int instId)
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(mStaMutex);
|
||||
mStaIfaceName = ifaceName;
|
||||
mStaIfaceName[instId] = ifaceName;
|
||||
}
|
||||
|
||||
std::string WifiConfigCenter::GetStaIfaceName()
|
||||
std::string WifiConfigCenter::GetStaIfaceName(int instId)
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(mStaMutex);
|
||||
return mStaIfaceName;
|
||||
WIFI_LOGD("GetStaIfaceName instId:%{public}d mStaIfaceName[instId]:%{public}s ",
|
||||
instId, mStaIfaceName[instId].c_str());
|
||||
return mStaIfaceName[instId];
|
||||
}
|
||||
|
||||
int WifiConfigCenter::GetWifiState(int instId)
|
||||
@ -337,6 +339,8 @@ int WifiConfigCenter::SaveLinkedInfo(const WifiLinkedInfo &info, int instId)
|
||||
if (bssid == info.bssid) {
|
||||
iter->second.channelWidth = channelWidth;
|
||||
}
|
||||
} else {
|
||||
mWifiLinkedInfo.emplace(instId, info);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -357,6 +361,7 @@ int WifiConfigCenter::SetMacAddress(const std::string &macAddress, int instId)
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(mStaMutex);
|
||||
mMacAddress[instId] = macAddress;
|
||||
WIFI_LOGI("SetMacAddress instId:%{public}d, macAddress:%{public}s", instId, macAddress.c_str());
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1054,23 +1059,23 @@ bool WifiConfigCenter::SetWifiStateOnAirplaneChanged(const int &state)
|
||||
mAirplaneModeState = state;
|
||||
WifiSettings::GetInstance().SetLastAirplaneMode(state);
|
||||
if (WifiSettings::GetInstance().GetWifiFlagOnAirplaneMode()) {
|
||||
if (GetPersistWifiState() == WIFI_STATE_DISABLED) {
|
||||
if (GetPersistWifiState(INSTID_WLAN0) == WIFI_STATE_DISABLED) {
|
||||
return true;
|
||||
}
|
||||
if (GetPersistWifiState() == WIFI_STATE_SEMI_ENABLED && state == MODE_STATE_OPEN) {
|
||||
SetPersistWifiState(WIFI_STATE_DISABLED);
|
||||
if (GetPersistWifiState(INSTID_WLAN0) == WIFI_STATE_SEMI_ENABLED && state == MODE_STATE_OPEN) {
|
||||
SetPersistWifiState(WIFI_STATE_DISABLED, INSTID_WLAN0);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (state == MODE_STATE_OPEN) {
|
||||
if (GetPersistWifiState() == WIFI_STATE_ENABLED) {
|
||||
if (GetPersistWifiState(INSTID_WLAN0) == WIFI_STATE_ENABLED) {
|
||||
WifiSettings::GetInstance().SetWifiDisabledByAirplane(true);
|
||||
}
|
||||
SetPersistWifiState(WIFI_STATE_DISABLED);
|
||||
SetPersistWifiState(WIFI_STATE_DISABLED, INSTID_WLAN0);
|
||||
} else {
|
||||
if (WifiSettings::GetInstance().GetWifiDisabledByAirplane()) {
|
||||
SetPersistWifiState(WIFI_STATE_ENABLED);
|
||||
SetPersistWifiState(WIFI_STATE_ENABLED, INSTID_WLAN0);
|
||||
WifiSettings::GetInstance().SetWifiDisabledByAirplane(false);
|
||||
}
|
||||
}
|
||||
@ -1082,21 +1087,21 @@ int WifiConfigCenter::GetAirplaneModeState() const
|
||||
return mAirplaneModeState.load();
|
||||
}
|
||||
|
||||
int WifiConfigCenter::GetWifiToggledEnable()
|
||||
int WifiConfigCenter::GetWifiToggledEnable(int id)
|
||||
{
|
||||
if (GetAirplaneModeState() == MODE_STATE_OPEN) {
|
||||
if (GetPersistWifiState() == WIFI_STATE_ENABLED) {
|
||||
if (GetPersistWifiState(id) == WIFI_STATE_ENABLED) {
|
||||
return WIFI_STATE_ENABLED;
|
||||
}
|
||||
return WIFI_STATE_DISABLED;
|
||||
}
|
||||
if (GetPersistWifiState() != WIFI_STATE_ENABLED && GetWifiAllowSemiActive()) {
|
||||
if (GetPersistWifiState(id) != WIFI_STATE_ENABLED && GetWifiAllowSemiActive()) {
|
||||
return WIFI_STATE_SEMI_ENABLED;
|
||||
}
|
||||
return GetPersistWifiState();
|
||||
return GetPersistWifiState(id);
|
||||
}
|
||||
|
||||
void WifiConfigCenter::SetWifiToggledState(int state)
|
||||
void WifiConfigCenter::SetWifiToggledState(int state, int id)
|
||||
{
|
||||
if (GetAirplaneModeState() == MODE_STATE_OPEN) {
|
||||
WifiSettings::GetInstance().SetWifiDisabledByAirplane(false);
|
||||
@ -1107,7 +1112,7 @@ void WifiConfigCenter::SetWifiToggledState(int state)
|
||||
state = WIFI_STATE_DISABLED;
|
||||
}
|
||||
}
|
||||
SetPersistWifiState(state);
|
||||
SetPersistWifiState(state, id);
|
||||
}
|
||||
|
||||
void WifiConfigCenter::SetPowerSavingModeState(const int &state)
|
||||
@ -1459,16 +1464,24 @@ void WifiConfigCenter::InitScanControlIntervalList()
|
||||
return;
|
||||
}
|
||||
|
||||
void WifiConfigCenter::SetPersistWifiState(int state)
|
||||
void WifiConfigCenter::SetPersistWifiState(int state, int instId)
|
||||
{
|
||||
mPersistWifiState = state;
|
||||
WifiSettings::GetInstance().SetOperatorWifiType(state);
|
||||
if (instId < 0 || instId >= STA_INSTANCE_MAX_NUM) {
|
||||
LOGE("SetPersistWifiState invalid instId %{public}d", instId);
|
||||
return;
|
||||
}
|
||||
mPersistWifiState.at(instId) = state;
|
||||
WifiSettings::GetInstance().SetOperatorWifiType(state, instId);
|
||||
LOGI("persist wifi state is %{public}d", state);
|
||||
}
|
||||
|
||||
int WifiConfigCenter::GetPersistWifiState()
|
||||
int WifiConfigCenter::GetPersistWifiState(int instId)
|
||||
{
|
||||
return mPersistWifiState.load();
|
||||
if (instId < 0 || instId >= STA_INSTANCE_MAX_NUM) {
|
||||
LOGE("GetPersistWifiState invalid instId %{public}d", instId);
|
||||
return -1;
|
||||
}
|
||||
return mPersistWifiState.at(instId);
|
||||
}
|
||||
|
||||
std::string WifiConfigCenter::GetPairMacAddress(std::map<WifiMacAddrInfo, std::string>& macAddrInfoMap,
|
||||
|
@ -24,7 +24,9 @@
|
||||
#include <vector>
|
||||
#include "wifi_internal_msg.h"
|
||||
#include "wifi_settings.h"
|
||||
|
||||
#ifndef STA_INSTANCE_MAX_NUM
|
||||
#define STA_INSTANCE_MAX_NUM 2
|
||||
#endif
|
||||
#define SOFT_BUS_SERVICE_UID 1024
|
||||
#define CAST_ENGINE_SERVICE_UID 5526
|
||||
#define MIRACAST_SERVICE_UID 5529
|
||||
@ -66,9 +68,9 @@ public:
|
||||
|
||||
bool GetWifiStopState() const;
|
||||
|
||||
void SetStaIfaceName(const std::string &ifaceName);
|
||||
void SetStaIfaceName(const std::string &ifaceName, int instId = 0);
|
||||
|
||||
std::string GetStaIfaceName();
|
||||
std::string GetStaIfaceName(int instId = 0);
|
||||
|
||||
int GetWifiState(int instId = 0);
|
||||
|
||||
@ -282,9 +284,9 @@ public:
|
||||
|
||||
int GetAirplaneModeState() const;
|
||||
|
||||
int GetWifiToggledEnable();
|
||||
int GetWifiToggledEnable(int id = 0);
|
||||
|
||||
void SetWifiToggledState(int state);
|
||||
void SetWifiToggledState(int state, int id = 0);
|
||||
|
||||
void SetPowerSavingModeState(const int &state);
|
||||
|
||||
@ -315,14 +317,16 @@ public:
|
||||
|
||||
void ClearMacAddrPairs(WifiMacAddrInfoType type);
|
||||
|
||||
void SetPersistWifiState(int state, int instId);
|
||||
|
||||
int GetPersistWifiState(int instId);
|
||||
|
||||
private:
|
||||
WifiConfigCenter();
|
||||
bool HasWifiActive();
|
||||
void UpdateLinkedInfo(int instId = 0);
|
||||
void InitScanControlForbidList();
|
||||
void InitScanControlIntervalList();
|
||||
void SetPersistWifiState(int state);
|
||||
int GetPersistWifiState();
|
||||
std::string GetPairMacAddress(std::map<WifiMacAddrInfo, std::string>& macAddrInfoMap,
|
||||
const WifiMacAddrInfo &macAddrInfo);
|
||||
WifiMacAddrErrCode InsertMacAddrPairs(std::map<WifiMacAddrInfo, std::string>& macAddrInfoMap,
|
||||
@ -341,7 +345,7 @@ private:
|
||||
std::atomic<int> mSelectedCandidateNetworkId {INVALID_NETWORK_ID};
|
||||
std::atomic<bool> mWifiAllowSemiActive {false};
|
||||
std::atomic<bool> mWifiStoping {false};
|
||||
std::string mStaIfaceName {"wlan0"};
|
||||
std::vector<std::string> mStaIfaceName = {"wlan0", "wlan1"};
|
||||
std::map<int, std::atomic<int>> mWifiState;
|
||||
std::map<int, WifiDetailState> mWifiDetailState;
|
||||
std::map<int, std::atomic<WifiOprMidState>> mStaMidState;
|
||||
@ -403,7 +407,7 @@ private:
|
||||
std::atomic<int> mGnssFixState {MODE_STATE_CLOSE};
|
||||
std::atomic<int> mScanGenieState {MODE_STATE_OPEN};
|
||||
std::atomic<int> mAirplaneModeState {MODE_STATE_CLOSE};
|
||||
std::atomic<int> mPersistWifiState {WIFI_STATE_DISABLED};
|
||||
std::vector<int> mPersistWifiState {std::vector<int>(2, WIFI_STATE_DISABLED)};
|
||||
std::atomic<int> mPowerSavingModeState {MODE_STATE_CLOSE};
|
||||
std::atomic<int> mFreezeModeState {MODE_STATE_CLOSE};
|
||||
std::atomic<int> mNoChargerPlugModeState {MODE_STATE_CLOSE};
|
||||
|
@ -187,7 +187,7 @@ void WifiSettings::ClearDeviceConfig(void)
|
||||
return;
|
||||
}
|
||||
|
||||
int WifiSettings::GetDeviceConfig(std::vector<WifiDeviceConfig> &results)
|
||||
int WifiSettings::GetDeviceConfig(std::vector<WifiDeviceConfig> &results, int instId)
|
||||
{
|
||||
if (!deviceConfigLoadFlag.test_and_set()) {
|
||||
LOGD("Reload wifi config");
|
||||
@ -196,14 +196,14 @@ int WifiSettings::GetDeviceConfig(std::vector<WifiDeviceConfig> &results)
|
||||
std::unique_lock<std::mutex> lock(mStaMutex);
|
||||
for (auto iter = mWifiDeviceConfig.begin(); iter != mWifiDeviceConfig.end(); iter++) {
|
||||
// -1: Connect by system, use default uid.
|
||||
if (iter->second.uid == -1 || iter->second.isShared) {
|
||||
if ((iter->second.uid == -1 || iter->second.isShared) && iter->second.instanceId == instId) {
|
||||
results.push_back(iter->second);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int WifiSettings::GetDeviceConfig(const int &networkId, WifiDeviceConfig &config)
|
||||
int WifiSettings::GetDeviceConfig(const int &networkId, WifiDeviceConfig &config, int instId)
|
||||
{
|
||||
if (!deviceConfigLoadFlag.test_and_set()) {
|
||||
LOGD("Reload wifi config");
|
||||
@ -211,7 +211,7 @@ int WifiSettings::GetDeviceConfig(const int &networkId, WifiDeviceConfig &config
|
||||
}
|
||||
std::unique_lock<std::mutex> lock(mStaMutex);
|
||||
for (auto iter = mWifiDeviceConfig.begin(); iter != mWifiDeviceConfig.end(); iter++) {
|
||||
if (iter->second.networkId == networkId) {
|
||||
if (iter->second.networkId == networkId && iter->second.instanceId == instId) {
|
||||
config = iter->second;
|
||||
SyncAfterDecryped(config);
|
||||
return 0;
|
||||
@ -220,7 +220,8 @@ int WifiSettings::GetDeviceConfig(const int &networkId, WifiDeviceConfig &config
|
||||
return -1;
|
||||
}
|
||||
|
||||
int WifiSettings::GetDeviceConfig(const std::string &index, const int &indexType, WifiDeviceConfig &config)
|
||||
int WifiSettings::GetDeviceConfig(const std::string &index, const int &indexType,
|
||||
WifiDeviceConfig &config, int instId)
|
||||
{
|
||||
if (!deviceConfigLoadFlag.test_and_set()) {
|
||||
LOGD("Reload wifi config");
|
||||
@ -229,7 +230,7 @@ int WifiSettings::GetDeviceConfig(const std::string &index, const int &indexType
|
||||
std::unique_lock<std::mutex> lock(mStaMutex);
|
||||
if (indexType == DEVICE_CONFIG_INDEX_SSID) {
|
||||
for (auto iter = mWifiDeviceConfig.begin(); iter != mWifiDeviceConfig.end(); iter++) {
|
||||
if (iter->second.ssid == index) {
|
||||
if (iter->second.ssid == index && iter->second.instanceId == instId) {
|
||||
config = iter->second;
|
||||
SyncAfterDecryped(config);
|
||||
return 0;
|
||||
@ -237,7 +238,7 @@ int WifiSettings::GetDeviceConfig(const std::string &index, const int &indexType
|
||||
}
|
||||
} else {
|
||||
for (auto iter = mWifiDeviceConfig.begin(); iter != mWifiDeviceConfig.end(); iter++) {
|
||||
if (iter->second.bssid == index) {
|
||||
if (iter->second.bssid == index && iter->second.instanceId == instId) {
|
||||
config = iter->second;
|
||||
SyncAfterDecryped(config);
|
||||
return 0;
|
||||
@ -247,7 +248,8 @@ int WifiSettings::GetDeviceConfig(const std::string &index, const int &indexType
|
||||
return -1;
|
||||
}
|
||||
|
||||
int WifiSettings::GetDeviceConfig(const std::string &ssid, const std::string &keymgmt, WifiDeviceConfig &config)
|
||||
int WifiSettings::GetDeviceConfig(const std::string &ssid, const std::string &keymgmt,
|
||||
WifiDeviceConfig &config, int instId)
|
||||
{
|
||||
if (!deviceConfigLoadFlag.test_and_set()) {
|
||||
LOGD("Reload wifi config");
|
||||
@ -258,7 +260,7 @@ int WifiSettings::GetDeviceConfig(const std::string &ssid, const std::string &ke
|
||||
if (keymgmt.compare("WPA-PSK+SAE") == 0) {
|
||||
for (auto iter = mWifiDeviceConfig.begin(); iter != mWifiDeviceConfig.end(); iter++) {
|
||||
if ((iter->second.ssid == ssid) && (keymgmt.find(iter->second.keyMgmt) != std::string::npos)
|
||||
&& (iter->second.uid == -1 || iter->second.isShared)) {
|
||||
&& (iter->second.uid == -1 || iter->second.isShared) && iter->second.instanceId == instId) {
|
||||
config = iter->second;
|
||||
SyncAfterDecryped(config);
|
||||
return 0;
|
||||
@ -267,7 +269,7 @@ int WifiSettings::GetDeviceConfig(const std::string &ssid, const std::string &ke
|
||||
} else {
|
||||
for (auto iter = mWifiDeviceConfig.begin(); iter != mWifiDeviceConfig.end(); iter++) {
|
||||
if ((iter->second.ssid == ssid) && (iter->second.keyMgmt == keymgmt)
|
||||
&& (iter->second.uid == -1 || iter->second.isShared)) {
|
||||
&& (iter->second.uid == -1 || iter->second.isShared) && iter->second.instanceId == instId) {
|
||||
config = iter->second;
|
||||
SyncAfterDecryped(config);
|
||||
return 0;
|
||||
@ -441,7 +443,7 @@ int WifiSettings::SyncDeviceConfig()
|
||||
std::unique_lock<std::mutex> lock(mStaMutex);
|
||||
std::vector<WifiDeviceConfig> tmp;
|
||||
for (auto iter = mWifiDeviceConfig.begin(); iter != mWifiDeviceConfig.end(); ++iter) {
|
||||
if (!iter->second.isEphemeral) {
|
||||
if (!iter->second.isEphemeral && iter->second.instanceId == 0) {
|
||||
tmp.push_back(iter->second);
|
||||
}
|
||||
}
|
||||
|
@ -115,13 +115,13 @@ public:
|
||||
|
||||
void ClearDeviceConfig(void);
|
||||
|
||||
int GetDeviceConfig(std::vector<WifiDeviceConfig> &results);
|
||||
int GetDeviceConfig(std::vector<WifiDeviceConfig> &results, int instId = 0);
|
||||
|
||||
int GetDeviceConfig(const int &networkId, WifiDeviceConfig &config);
|
||||
int GetDeviceConfig(const int &networkId, WifiDeviceConfig &config, int instId = 0);
|
||||
|
||||
int GetDeviceConfig(const std::string &index, const int &indexType, WifiDeviceConfig &config);
|
||||
int GetDeviceConfig(const std::string &index, const int &indexType, WifiDeviceConfig &config, int instId = 0);
|
||||
|
||||
int GetDeviceConfig(const std::string &ssid, const std::string &keymgmt, WifiDeviceConfig &config);
|
||||
int GetDeviceConfig(const std::string &ssid, const std::string &keymgmt, WifiDeviceConfig &config, int instId = 0);
|
||||
|
||||
int SetDeviceState(int networkId, int state, bool bSetOther = false);
|
||||
|
||||
|
@ -96,6 +96,11 @@ bool WifiCommonEventHelper::PublishEvent(const std::string &eventAction, const s
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WifiCommonEventHelper::PublishWifi2PowerStateChangeEvent(const int &code, const std::string &data)
|
||||
{
|
||||
return WifiCommonEventHelper::PublishEvent(COMMON_EVENT_WIFI2_POWER_STATE, code, data);
|
||||
}
|
||||
|
||||
bool WifiCommonEventHelper::PublishPowerStateChangeEvent(const int &code, const std::string &data)
|
||||
{
|
||||
return WifiCommonEventHelper::PublishEvent(COMMON_EVENT_WIFI_POWER_STATE, code, data);
|
||||
@ -122,6 +127,11 @@ bool WifiCommonEventHelper::PublishWiTasRssiValueChangedEvent(const int &code, c
|
||||
return WifiCommonEventHelper::PublishEvent(COMMON_EVENT_WITAS_RSSI_VALUE, code, data);
|
||||
}
|
||||
|
||||
bool WifiCommonEventHelper::PublishWifi2ConnStateChangedEvent(const int &code, const std::string &data)
|
||||
{
|
||||
return WifiCommonEventHelper::PublishEvent(COMMON_EVENT_WIFI2_CONN_STATE, code, data);
|
||||
}
|
||||
|
||||
bool WifiCommonEventHelper::PublishConnStateChangedEvent(const int &code, const std::string &data)
|
||||
{
|
||||
return WifiCommonEventHelper::PublishEvent(COMMON_EVENT_WIFI_CONN_STATE, code, data);
|
||||
|
@ -21,18 +21,21 @@
|
||||
namespace OHOS {
|
||||
namespace Wifi {
|
||||
inline const std::string COMMON_EVENT_WIFI_POWER_STATE = "usual.event.wifi.POWER_STATE";
|
||||
inline const std::string COMMON_EVENT_WIFI2_POWER_STATE = "usual.event.wifi.WIFI2_POWER_STATE";
|
||||
inline const std::string COMMON_EVENT_WIFI_SCAN_FINISHED = "usual.event.wifi.SCAN_FINISHED";
|
||||
inline const std::string COMMON_EVENT_WIFI_SCAN_STATE = "usual.event.wifi.SCAN_STATE";
|
||||
inline const std::string COMMON_EVENT_WIFI_RSSI_VALUE = "usual.event.wifi.RSSI_VALUE";
|
||||
inline const std::string COMMON_EVENT_WITAS_RSSI_VALUE = "usual.event.wifi.WITAS_RSSI_VALUE";
|
||||
inline const std::string COMMON_EVENT_WIFI_CONN_STATE = "usual.event.wifi.CONN_STATE";
|
||||
inline const std::string COMMON_EVENT_WIFI2_CONN_STATE = "usual.event.wifi.WIFI2_CONN_STATE";
|
||||
inline const std::string COMMON_EVENT_WIFI_HOTSPOT_STATE = "usual.event.wifi.HOTSPOT_STATE";
|
||||
inline const std::string COMMON_EVENT_WIFI_AP_STA_JOIN = "usual.event.wifi.WIFI_HS_STA_JOIN";
|
||||
inline const std::string COMMON_EVENT_WIFI_AP_STA_LEAVE = "usual.event.wifi.WIFI_HS_STA_LEAVE";
|
||||
inline const std::string COMMON_EVENT_WIFI_MPLINK_STATE = "usual.event.wifi.mplink.STATE_CHANGE";
|
||||
inline const std::string COMMON_EVENT_WIFI_P2P_CONN_STATE = "usual.event.wifi.p2p.CONN_STATE_CHANGE";
|
||||
inline const std::string COMMON_EVENT_WIFI_P2P_STATE_CHANGED = "usual.event.wifi.p2p.STATE_CHANGE";
|
||||
inline const std::string COMMON_EVENT_WIFI_P2P_PEERS_STATE_CHANGED = "usual.event.wifi.p2p.DEVICES_CHANGE";
|
||||
inline const std::string COMMON_EVENT_WIFI_P2P_PEERS_STATE_CHANGED =
|
||||
"usual.event.wifi.p2p.DEVICES_CHANGE";
|
||||
inline const std::string COMMON_EVENT_WIFI_P2P_PEERS_DISCOVERY_STATE_CHANGED =
|
||||
"usual.event.wifi.p2p.PEER_DISCOVERY_STATE_CHANGE";
|
||||
inline const std::string COMMON_EVENT_WIFI_P2P_CURRENT_DEVICE_STATE_CHANGED =
|
||||
@ -52,12 +55,14 @@ public:
|
||||
static bool PublishEvent(const std::string &eventAction, const std::string ¶mKey, T paramValue,
|
||||
const int &code, const std::string &data);
|
||||
static bool PublishPowerStateChangeEvent(const int &code, const std::string &data);
|
||||
static bool PublishWifi2PowerStateChangeEvent(const int &code, const std::string &data);
|
||||
static bool PublishScanFinishedEvent(const int &code, const std::string &data);
|
||||
static bool PublishScanStateChangedEvent(const int &code, const std::string &data);
|
||||
static bool PublishRssiValueChangedEvent(const std::string &pramKey, int paramValue,
|
||||
const int &code, const std::string &data);
|
||||
static bool PublishWiTasRssiValueChangedEvent(const int &code, const std::string &data);
|
||||
static bool PublishConnStateChangedEvent(const int &code, const std::string &data);
|
||||
static bool PublishWifi2ConnStateChangedEvent(const int &code, const std::string &data);
|
||||
static bool PublishHotspotStateChangedEvent(const int &code, const std::string &data);
|
||||
static bool PublishApStaJoinEvent(const int &code, const std::string &data);
|
||||
static bool PublishApStaLeaveEvent(const int &code, const std::string &data);
|
||||
|
@ -33,6 +33,9 @@ const unsigned long long MAC_ADDRESS_MULTICAST_MASK = 1ULL << 40;
|
||||
constexpr int MAX_MAC_SIZE = 18;
|
||||
constexpr int LONG_TO_BYTE_SIZE = 8;
|
||||
constexpr int MAC_ADDRESS_ETHER_ADDR_LEN = 6;
|
||||
constexpr unsigned int WIFI2_RANDOM_MAC_CHANGE_POS = 9;
|
||||
constexpr unsigned int WIFI2_RANDOM_MAC_CHANGE_LEN = 2;
|
||||
constexpr unsigned int WIFI2_RANDOM_MAC_MASK = 0x80;
|
||||
|
||||
constexpr int OFFSET_VALUE_56 = 56;
|
||||
constexpr int OFFSET_VALUE_48 = 48;
|
||||
@ -268,5 +271,24 @@ int WifiRandomMacHelper::GenerateRandomMacAddressByLong(unsigned long long rando
|
||||
lngAddr, MacAnonymize(randomMacAddr).c_str());
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool WifiRandomMacHelper::GetWifi2RandomMac(std::string &wifi2RandomMac)
|
||||
{
|
||||
std::string inputStrMac = wifi2RandomMac.substr(WIFI2_RANDOM_MAC_CHANGE_POS, WIFI2_RANDOM_MAC_CHANGE_LEN);
|
||||
std::stringstream inputSsMac;
|
||||
inputSsMac << std::hex <<inputStrMac;
|
||||
unsigned int inputHexMac;
|
||||
if (inputSsMac >> inputHexMac) {
|
||||
WIFI_LOGD("%{public}s conver pos 3 mac to hex success", __func__);
|
||||
} else {
|
||||
WIFI_LOGE("%{public}s conver pos 3 mac to hex fail", __func__);
|
||||
}
|
||||
unsigned int outputHexMac = inputHexMac ^ WIFI2_RANDOM_MAC_MASK;
|
||||
std::stringstream outSsMac;
|
||||
outSsMac << std::hex <<outputHexMac;
|
||||
wifi2RandomMac.replace(WIFI2_RANDOM_MAC_CHANGE_POS, WIFI2_RANDOM_MAC_CHANGE_LEN, outSsMac.str());
|
||||
return true;
|
||||
}
|
||||
|
||||
} // Wifi
|
||||
} // OHOS
|
||||
|
@ -108,6 +108,14 @@ public:
|
||||
* @return std::string - formated string
|
||||
*/
|
||||
static std::string BytesArrayToString(const std::vector<uint8_t> &bytes);
|
||||
|
||||
/**
|
||||
* @Description change random mac for wifi2
|
||||
*for example, input mac is 00:1a:2b:3c:4d:5e, this func will change pos 3 byte mac from "3c" to "bc" by
|
||||
*performing an XOR operation with 0x80
|
||||
* @param wifi2RandomMac - wifi2RandomMac
|
||||
*/
|
||||
static bool GetWifi2RandomMac(std::string &wifi2RandomMac);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -112,7 +112,11 @@ ohos_unittest("precompiled_macro_unittest") {
|
||||
|
||||
deps = [
|
||||
"$WIFI_ROOT_DIR/base:wifi_base",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage:wifi_device_ability",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage:wifi_hotspot_ability",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage:wifi_manager_service",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage:wifi_scan_ability",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_native:wifi_native",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_toolkit:wifi_toolkit",
|
||||
"$WIFI_ROOT_DIR/utils:wifi_utils",
|
||||
"//third_party/googletest:gmock_main",
|
||||
|
@ -32,11 +32,13 @@ void WifiHalDeviceManagerTest::OnRssiReportCallback(int index, int antRssi)
|
||||
HWTEST_F(WifiHalDeviceManagerTest, ScanTest, TestSize.Level1)
|
||||
{
|
||||
std::string ifaceName;
|
||||
int instId = 0;
|
||||
HalDeviceManager::g_chipHdiServiceDied = true;
|
||||
DelayedSingleton<HalDeviceManager>::GetInstance()->CreateStaIface(
|
||||
std::bind(WifiHalDeviceManagerTest::DestoryCallback, std::placeholders::_1, std::placeholders::_2),
|
||||
std::bind(WifiHalDeviceManagerTest::OnRssiReportCallback, std::placeholders::_1, std::placeholders::_2),
|
||||
ifaceName);
|
||||
ifaceName,
|
||||
instId);
|
||||
ScanParams scanParams;
|
||||
DelayedSingleton<HalDeviceManager>::GetInstance()->Scan(ifaceName, scanParams);
|
||||
}
|
||||
@ -44,11 +46,13 @@ HWTEST_F(WifiHalDeviceManagerTest, ScanTest, TestSize.Level1)
|
||||
HWTEST_F(WifiHalDeviceManagerTest, StartPnoScanTest, TestSize.Level1)
|
||||
{
|
||||
std::string ifaceName;
|
||||
int instId = 0;
|
||||
HalDeviceManager::g_chipHdiServiceDied = true;
|
||||
DelayedSingleton<HalDeviceManager>::GetInstance()->CreateStaIface(
|
||||
std::bind(WifiHalDeviceManagerTest::DestoryCallback, std::placeholders::_1, std::placeholders::_2),
|
||||
std::bind(WifiHalDeviceManagerTest::OnRssiReportCallback, std::placeholders::_1, std::placeholders::_2),
|
||||
ifaceName);
|
||||
ifaceName,
|
||||
instId);
|
||||
PnoScanParams pnoScanParams;
|
||||
DelayedSingleton<HalDeviceManager>::GetInstance()->StartPnoScan(ifaceName, pnoScanParams);
|
||||
}
|
||||
@ -56,22 +60,26 @@ HWTEST_F(WifiHalDeviceManagerTest, StartPnoScanTest, TestSize.Level1)
|
||||
HWTEST_F(WifiHalDeviceManagerTest, StopPnoScanTest, TestSize.Level1)
|
||||
{
|
||||
std::string ifaceName;
|
||||
int instId = 0;
|
||||
HalDeviceManager::g_chipHdiServiceDied = true;
|
||||
DelayedSingleton<HalDeviceManager>::GetInstance()->CreateStaIface(
|
||||
std::bind(WifiHalDeviceManagerTest::DestoryCallback, std::placeholders::_1, std::placeholders::_2),
|
||||
std::bind(WifiHalDeviceManagerTest::OnRssiReportCallback, std::placeholders::_1, std::placeholders::_2),
|
||||
ifaceName);
|
||||
ifaceName,
|
||||
instId);
|
||||
DelayedSingleton<HalDeviceManager>::GetInstance()->StopPnoScan(ifaceName);
|
||||
}
|
||||
|
||||
HWTEST_F(WifiHalDeviceManagerTest, GetScanInfosTest, TestSize.Level1)
|
||||
{
|
||||
std::string ifaceName;
|
||||
int instId = 0;
|
||||
HalDeviceManager::g_chipHdiServiceDied = true;
|
||||
DelayedSingleton<HalDeviceManager>::GetInstance()->CreateStaIface(
|
||||
std::bind(WifiHalDeviceManagerTest::DestoryCallback, std::placeholders::_1, std::placeholders::_2),
|
||||
std::bind(WifiHalDeviceManagerTest::OnRssiReportCallback, std::placeholders::_1, std::placeholders::_2),
|
||||
ifaceName);
|
||||
ifaceName,
|
||||
instId);
|
||||
std::vector<ScanResultsInfo> scanResultsInfo;
|
||||
DelayedSingleton<HalDeviceManager>::GetInstance()->GetScanInfos(ifaceName, scanResultsInfo);
|
||||
}
|
||||
@ -79,11 +87,13 @@ HWTEST_F(WifiHalDeviceManagerTest, GetScanInfosTest, TestSize.Level1)
|
||||
HWTEST_F(WifiHalDeviceManagerTest, GetConnectSignalInfoTest, TestSize.Level1)
|
||||
{
|
||||
std::string ifaceName;
|
||||
int instId = 0;
|
||||
HalDeviceManager::g_chipHdiServiceDied = true;
|
||||
DelayedSingleton<HalDeviceManager>::GetInstance()->CreateStaIface(
|
||||
std::bind(WifiHalDeviceManagerTest::DestoryCallback, std::placeholders::_1, std::placeholders::_2),
|
||||
std::bind(WifiHalDeviceManagerTest::OnRssiReportCallback, std::placeholders::_1, std::placeholders::_2),
|
||||
ifaceName);
|
||||
ifaceName,
|
||||
instId);
|
||||
SignalPollResult signalPollResult;
|
||||
DelayedSingleton<HalDeviceManager>::GetInstance()->GetConnectSignalInfo(ifaceName, signalPollResult);
|
||||
}
|
||||
@ -91,11 +101,13 @@ HWTEST_F(WifiHalDeviceManagerTest, GetConnectSignalInfoTest, TestSize.Level1)
|
||||
HWTEST_F(WifiHalDeviceManagerTest, SetPmModeTest, TestSize.Level1)
|
||||
{
|
||||
std::string ifaceName;
|
||||
int instId = 0;
|
||||
HalDeviceManager::g_chipHdiServiceDied = true;
|
||||
DelayedSingleton<HalDeviceManager>::GetInstance()->CreateStaIface(
|
||||
std::bind(WifiHalDeviceManagerTest::DestoryCallback, std::placeholders::_1, std::placeholders::_2),
|
||||
std::bind(WifiHalDeviceManagerTest::OnRssiReportCallback, std::placeholders::_1, std::placeholders::_2),
|
||||
ifaceName);
|
||||
ifaceName,
|
||||
instId);
|
||||
int mode = 0;
|
||||
DelayedSingleton<HalDeviceManager>::GetInstance()->SetPmMode(ifaceName, mode);
|
||||
}
|
||||
@ -103,11 +115,13 @@ HWTEST_F(WifiHalDeviceManagerTest, SetPmModeTest, TestSize.Level1)
|
||||
HWTEST_F(WifiHalDeviceManagerTest, SetDpiMarkRuleTest, TestSize.Level1)
|
||||
{
|
||||
std::string ifaceName;
|
||||
int instId = 0;
|
||||
HalDeviceManager::g_chipHdiServiceDied = true;
|
||||
DelayedSingleton<HalDeviceManager>::GetInstance()->CreateStaIface(
|
||||
std::bind(WifiHalDeviceManagerTest::DestoryCallback, std::placeholders::_1, std::placeholders::_2),
|
||||
std::bind(WifiHalDeviceManagerTest::OnRssiReportCallback, std::placeholders::_1, std::placeholders::_2),
|
||||
ifaceName);
|
||||
ifaceName,
|
||||
instId);
|
||||
int uid = 0;
|
||||
int protocol = 0;
|
||||
int enable = 0;
|
||||
@ -117,11 +131,13 @@ HWTEST_F(WifiHalDeviceManagerTest, SetDpiMarkRuleTest, TestSize.Level1)
|
||||
HWTEST_F(WifiHalDeviceManagerTest, SetStaMacAddressTest, TestSize.Level1)
|
||||
{
|
||||
std::string ifaceName;
|
||||
int instId = 0;
|
||||
HalDeviceManager::g_chipHdiServiceDied = true;
|
||||
DelayedSingleton<HalDeviceManager>::GetInstance()->CreateStaIface(
|
||||
std::bind(WifiHalDeviceManagerTest::DestoryCallback, std::placeholders::_1, std::placeholders::_2),
|
||||
std::bind(WifiHalDeviceManagerTest::OnRssiReportCallback, std::placeholders::_1, std::placeholders::_2),
|
||||
ifaceName);
|
||||
ifaceName,
|
||||
instId);
|
||||
std::string mac{"12:34:56:78:90:AB"};
|
||||
DelayedSingleton<HalDeviceManager>::GetInstance()->SetStaMacAddress(ifaceName, mac);
|
||||
}
|
||||
@ -145,11 +161,13 @@ HWTEST_F(WifiHalDeviceManagerTest, GetChipsetCategoryTest, TestSize.Level1)
|
||||
HWTEST_F(WifiHalDeviceManagerTest, GetChipsetWifiFeatrureCapabilityTest, TestSize.Level1)
|
||||
{
|
||||
std::string ifaceName;
|
||||
int instId = 0;
|
||||
HalDeviceManager::g_chipHdiServiceDied = true;
|
||||
DelayedSingleton<HalDeviceManager>::GetInstance()->CreateStaIface(
|
||||
std::bind(WifiHalDeviceManagerTest::DestoryCallback, std::placeholders::_1, std::placeholders::_2),
|
||||
std::bind(WifiHalDeviceManagerTest::OnRssiReportCallback, std::placeholders::_1, std::placeholders::_2),
|
||||
ifaceName);
|
||||
ifaceName,
|
||||
instId);
|
||||
int chipsetFeatrureCapability = 0;
|
||||
DelayedSingleton<HalDeviceManager>::GetInstance()->GetChipsetWifiFeatrureCapability(
|
||||
ifaceName, chipsetFeatrureCapability);
|
||||
@ -158,9 +176,12 @@ HWTEST_F(WifiHalDeviceManagerTest, GetChipsetWifiFeatrureCapabilityTest, TestSiz
|
||||
HWTEST_F(WifiHalDeviceManagerTest, GetFrequenciesByBandTest, TestSize.Level1)
|
||||
{
|
||||
std::string ifaceName;
|
||||
int instId = 0;
|
||||
HalDeviceManager::g_chipHdiServiceDied = true;
|
||||
DelayedSingleton<HalDeviceManager>::GetInstance()->CreateApIface(
|
||||
std::bind(WifiHalDeviceManagerTest::DestoryCallback, std::placeholders::_1, std::placeholders::_2), ifaceName);
|
||||
std::bind(WifiHalDeviceManagerTest::DestoryCallback, std::placeholders::_1, std::placeholders::_2),
|
||||
ifaceName,
|
||||
instId);
|
||||
int32_t band = 0;
|
||||
std::vector<int> frequencies;
|
||||
DelayedSingleton<HalDeviceManager>::GetInstance()->GetFrequenciesByBand(ifaceName, band, frequencies);
|
||||
@ -168,7 +189,8 @@ HWTEST_F(WifiHalDeviceManagerTest, GetFrequenciesByBandTest, TestSize.Level1)
|
||||
DelayedSingleton<HalDeviceManager>::GetInstance()->CreateStaIface(
|
||||
std::bind(WifiHalDeviceManagerTest::DestoryCallback, std::placeholders::_1, std::placeholders::_2),
|
||||
std::bind(WifiHalDeviceManagerTest::OnRssiReportCallback, std::placeholders::_1, std::placeholders::_2),
|
||||
ifaceName);
|
||||
ifaceName,
|
||||
instId);
|
||||
DelayedSingleton<HalDeviceManager>::GetInstance()->GetFrequenciesByBand(ifaceName, band, frequencies);
|
||||
}
|
||||
|
||||
@ -195,6 +217,7 @@ HWTEST_F(WifiHalDeviceManagerTest, GetPowerModelTest, TestSize.Level1)
|
||||
HWTEST_F(WifiHalDeviceManagerTest, SetWifiCountryCodeTest, TestSize.Level1)
|
||||
{
|
||||
std::string ifaceName;
|
||||
int instId = 0;
|
||||
HalDeviceManager::g_chipHdiServiceDied = true;
|
||||
DelayedSingleton<HalDeviceManager>::GetInstance()->CreateApIface(
|
||||
std::bind(WifiHalDeviceManagerTest::DestoryCallback, std::placeholders::_1, std::placeholders::_2), ifaceName);
|
||||
@ -204,7 +227,8 @@ HWTEST_F(WifiHalDeviceManagerTest, SetWifiCountryCodeTest, TestSize.Level1)
|
||||
DelayedSingleton<HalDeviceManager>::GetInstance()->CreateStaIface(
|
||||
std::bind(WifiHalDeviceManagerTest::DestoryCallback, std::placeholders::_1, std::placeholders::_2),
|
||||
std::bind(WifiHalDeviceManagerTest::OnRssiReportCallback, std::placeholders::_1, std::placeholders::_2),
|
||||
ifaceName);
|
||||
ifaceName,
|
||||
instId);
|
||||
code = "CN";
|
||||
DelayedSingleton<HalDeviceManager>::GetInstance()->SetWifiCountryCode(ifaceName, code);
|
||||
}
|
||||
@ -222,11 +246,13 @@ HWTEST_F(WifiHalDeviceManagerTest, SetApMacAddressTest, TestSize.Level1)
|
||||
HWTEST_F(WifiHalDeviceManagerTest, SelectInterfacesToDeleteTest, TestSize.Level1)
|
||||
{
|
||||
std::string ifaceName;
|
||||
int instId = 0;
|
||||
HalDeviceManager::g_chipHdiServiceDied = true;
|
||||
DelayedSingleton<HalDeviceManager>::GetInstance()->CreateStaIface(
|
||||
std::bind(WifiHalDeviceManagerTest::DestoryCallback, std::placeholders::_1, std::placeholders::_2),
|
||||
std::bind(WifiHalDeviceManagerTest::OnRssiReportCallback, std::placeholders::_1, std::placeholders::_2),
|
||||
ifaceName);
|
||||
ifaceName,
|
||||
instId);
|
||||
WifiChipInfo wifiChipInfo;
|
||||
DelayedSingleton<HalDeviceManager>::GetInstance()->GetChipInfo(0, wifiChipInfo);
|
||||
IfaceType ifaceType = IfaceType::STA;
|
||||
@ -238,11 +264,13 @@ HWTEST_F(WifiHalDeviceManagerTest, SelectInterfacesToDeleteTest, TestSize.Level1
|
||||
HWTEST_F(WifiHalDeviceManagerTest, CreateTheNeedChangeChipModeIfaceDataTest, TestSize.Level1)
|
||||
{
|
||||
std::string ifaceName;
|
||||
int instId = 0;
|
||||
HalDeviceManager::g_chipHdiServiceDied = true;
|
||||
DelayedSingleton<HalDeviceManager>::GetInstance()->CreateStaIface(
|
||||
std::bind(WifiHalDeviceManagerTest::DestoryCallback, std::placeholders::_1, std::placeholders::_2),
|
||||
std::bind(WifiHalDeviceManagerTest::OnRssiReportCallback, std::placeholders::_1, std::placeholders::_2),
|
||||
ifaceName);
|
||||
ifaceName,
|
||||
instId);
|
||||
UsableMode chipMode;
|
||||
IfaceCreationData ifaceCreationData;
|
||||
WifiChipInfo wifiChipInfo;
|
||||
@ -260,11 +288,13 @@ HWTEST_F(WifiHalDeviceManagerTest, CreateTheNeedChangeChipModeIfaceDataTest, Tes
|
||||
HWTEST_F(WifiHalDeviceManagerTest, CompareIfaceCreationDataTest, TestSize.Level1)
|
||||
{
|
||||
std::string ifaceName;
|
||||
int instId = 0;
|
||||
HalDeviceManager::g_chipHdiServiceDied = true;
|
||||
DelayedSingleton<HalDeviceManager>::GetInstance()->CreateStaIface(
|
||||
std::bind(WifiHalDeviceManagerTest::DestoryCallback, std::placeholders::_1, std::placeholders::_2),
|
||||
std::bind(WifiHalDeviceManagerTest::OnRssiReportCallback, std::placeholders::_1, std::placeholders::_2),
|
||||
ifaceName);
|
||||
ifaceName,
|
||||
instId);
|
||||
WifiIfaceInfo ifaceInfo;
|
||||
IfaceCreationData data1;
|
||||
DelayedSingleton<HalDeviceManager>::GetInstance()->GetChipInfo(0, data1.chipInfo);
|
||||
@ -290,11 +320,13 @@ HWTEST_F(WifiHalDeviceManagerTest, DispatchIfaceDestoryCallbackTest, TestSize.Le
|
||||
{
|
||||
IfaceType ifaceType = IfaceType::STA;
|
||||
std::string ifaceName;
|
||||
int instId = 0;
|
||||
HalDeviceManager::g_chipHdiServiceDied = true;
|
||||
DelayedSingleton<HalDeviceManager>::GetInstance()->CreateStaIface(
|
||||
std::bind(WifiHalDeviceManagerTest::DestoryCallback, std::placeholders::_1, std::placeholders::_2),
|
||||
std::bind(WifiHalDeviceManagerTest::OnRssiReportCallback, std::placeholders::_1, std::placeholders::_2),
|
||||
ifaceName);
|
||||
ifaceName,
|
||||
instId);
|
||||
DelayedSingleton<HalDeviceManager>::GetInstance()->DispatchIfaceDestoryCallback(
|
||||
ifaceName, ifaceType, true, ifaceType);
|
||||
HalDeviceManager::g_chipHdiServiceDied = true;
|
||||
@ -314,11 +346,13 @@ HWTEST_F(WifiHalDeviceManagerTest, DispatchIfaceDestoryCallbackTest, TestSize.Le
|
||||
HWTEST_F(WifiHalDeviceManagerTest, RemoveStaIfaceTest, TestSize.Level1)
|
||||
{
|
||||
std::string ifaceName;
|
||||
int instId = 0;
|
||||
HalDeviceManager::g_chipHdiServiceDied = true;
|
||||
DelayedSingleton<HalDeviceManager>::GetInstance()->CreateStaIface(
|
||||
std::bind(WifiHalDeviceManagerTest::DestoryCallback, std::placeholders::_1, std::placeholders::_2),
|
||||
std::bind(WifiHalDeviceManagerTest::OnRssiReportCallback, std::placeholders::_1, std::placeholders::_2),
|
||||
ifaceName);
|
||||
ifaceName,
|
||||
instId);
|
||||
DelayedSingleton<HalDeviceManager>::GetInstance()->RemoveStaIface(ifaceName);
|
||||
}
|
||||
|
||||
@ -343,11 +377,13 @@ HWTEST_F(WifiHalDeviceManagerTest, RemoveP2pIfaceTest, TestSize.Level1)
|
||||
HWTEST_F(WifiHalDeviceManagerTest, CreateStaIfaceTest, TestSize.Level1)
|
||||
{
|
||||
std::string ifaceName = "Wlan0";
|
||||
int instId = 0;
|
||||
HalDeviceManager::g_chipHdiServiceDied = false;
|
||||
DelayedSingleton<HalDeviceManager>::GetInstance()->CreateStaIface(
|
||||
std::bind(WifiHalDeviceManagerTest::DestoryCallback, std::placeholders::_1, std::placeholders::_2),
|
||||
std::bind(WifiHalDeviceManagerTest::OnRssiReportCallback, std::placeholders::_1, std::placeholders::_2),
|
||||
ifaceName);
|
||||
ifaceName,
|
||||
instId);
|
||||
bool result = DelayedSingleton<HalDeviceManager>::GetInstance()->RemoveStaIface(ifaceName);
|
||||
EXPECT_EQ(result, false);
|
||||
}
|
||||
@ -375,11 +411,13 @@ HWTEST_F(WifiHalDeviceManagerTest, CreateApIfaceTest, TestSize.Level1)
|
||||
HWTEST_F(WifiHalDeviceManagerTest, ScanTest_01, TestSize.Level1)
|
||||
{
|
||||
std::string ifaceName;
|
||||
int instId = 0;
|
||||
HalDeviceManager::g_chipHdiServiceDied = true;
|
||||
DelayedSingleton<HalDeviceManager>::GetInstance()->CreateStaIface(
|
||||
std::bind(WifiHalDeviceManagerTest::DestoryCallback, std::placeholders::_1, std::placeholders::_2),
|
||||
std::bind(WifiHalDeviceManagerTest::OnRssiReportCallback, std::placeholders::_1, std::placeholders::_2),
|
||||
ifaceName);
|
||||
ifaceName,
|
||||
instId);
|
||||
ScanParams scanParams;
|
||||
HalDeviceManager::g_chipHdiServiceDied = false;
|
||||
DelayedSingleton<HalDeviceManager>::GetInstance()->Scan(ifaceName, scanParams);
|
||||
@ -427,12 +465,14 @@ HWTEST_F(WifiHalDeviceManagerTest, GetChipsetWifiFeatrureCapabilityTest_01, Test
|
||||
HWTEST_F(WifiHalDeviceManagerTest, GetScanInfosTest_01, TestSize.Level1)
|
||||
{
|
||||
std::string ifaceName;
|
||||
int instId = 0;
|
||||
HalDeviceManager::g_chipHdiServiceDied = false;
|
||||
DelayedSingleton<HalDeviceManager>::GetInstance()->ResetHalDeviceManagerInfo(false);
|
||||
DelayedSingleton<HalDeviceManager>::GetInstance()->CreateStaIface(
|
||||
std::bind(WifiHalDeviceManagerTest::DestoryCallback, std::placeholders::_1, std::placeholders::_2),
|
||||
std::bind(WifiHalDeviceManagerTest::OnRssiReportCallback, std::placeholders::_1, std::placeholders::_2),
|
||||
ifaceName);
|
||||
ifaceName,
|
||||
instId);
|
||||
std::vector<ScanResultsInfo> scanResultsInfo;
|
||||
DelayedSingleton<HalDeviceManager>::GetInstance()->GetScanInfos(ifaceName, scanResultsInfo);
|
||||
}
|
||||
|
@ -344,12 +344,13 @@ HWTEST_F(WifiIdlInnerInterfaceTest, OnConnectChangedTest, TestSize.Level1)
|
||||
char *mac = nullptr;
|
||||
OnConnectChanged(status, networkId, mac);
|
||||
char mac1[] = "00:00:AA:BB:CC:DD";
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiEventCallback callback;
|
||||
RegisterStaCallbackMock(&callback);
|
||||
WifiStaHalInterface::GetInstance().RegisterStaEventCallback(callback);
|
||||
WifiStaHalInterface::GetInstance().RegisterStaEventCallback(callback, ifaceName);
|
||||
OnConnectChanged(status, networkId, mac1);
|
||||
UnRegisterStaCallbackMock(&callback);
|
||||
WifiStaHalInterface::GetInstance().RegisterStaEventCallback(callback);
|
||||
WifiStaHalInterface::GetInstance().RegisterStaEventCallback(callback, ifaceName);
|
||||
OnConnectChanged(status, networkId, mac1);
|
||||
}
|
||||
|
||||
@ -366,12 +367,13 @@ HWTEST_F(WifiIdlInnerInterfaceTest, OnDisConnectReasonCallbackTest, TestSize.Lev
|
||||
char *mac = nullptr;
|
||||
OnDisConnectReasonCallback(reason, mac);
|
||||
char mac1[] = "00:00:AA:BB:CC:DD";
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiEventCallback callback;
|
||||
RegisterStaCallbackMock(&callback);
|
||||
WifiStaHalInterface::GetInstance().RegisterStaEventCallback(callback);
|
||||
WifiStaHalInterface::GetInstance().RegisterStaEventCallback(callback, ifaceName);
|
||||
OnDisConnectReasonCallback(reason, mac1);
|
||||
UnRegisterStaCallbackMock(&callback);
|
||||
WifiStaHalInterface::GetInstance().RegisterStaEventCallback(callback);
|
||||
WifiStaHalInterface::GetInstance().RegisterStaEventCallback(callback, ifaceName);
|
||||
OnDisConnectReasonCallback(reason, mac1);
|
||||
}
|
||||
|
||||
@ -391,11 +393,12 @@ HWTEST_F(WifiIdlInnerInterfaceTest, OnBssidChangedTest, TestSize.Level1)
|
||||
OnBssidChanged(reason, bss);
|
||||
char bssid[] = "00:00:AA:BB:CC:DD";
|
||||
WifiEventCallback callback;
|
||||
std::string ifaceName = "wlan0";
|
||||
RegisterStaCallbackMock(&callback);
|
||||
WifiStaHalInterface::GetInstance().RegisterStaEventCallback(callback);
|
||||
WifiStaHalInterface::GetInstance().RegisterStaEventCallback(callback, ifaceName);
|
||||
OnBssidChanged(reason, bssid);
|
||||
UnRegisterStaCallbackMock(&callback);
|
||||
WifiStaHalInterface::GetInstance().RegisterStaEventCallback(callback);
|
||||
WifiStaHalInterface::GetInstance().RegisterStaEventCallback(callback, ifaceName);
|
||||
OnBssidChanged(reason, bssid);
|
||||
}
|
||||
/**
|
||||
@ -410,7 +413,8 @@ HWTEST_F(WifiIdlInnerInterfaceTest, OnWpaStateChangedTest, TestSize.Level1)
|
||||
int status = 1;
|
||||
WifiEventCallback callback;
|
||||
RegisterStaCallbackMock(&callback);
|
||||
WifiStaHalInterface::GetInstance().RegisterStaEventCallback(callback);
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiStaHalInterface::GetInstance().RegisterStaEventCallback(callback, ifaceName);
|
||||
OnWpaStateChanged(status);
|
||||
OnWpaSsidWrongKey();
|
||||
OnWpaConnectionFull(status);
|
||||
@ -418,7 +422,7 @@ HWTEST_F(WifiIdlInnerInterfaceTest, OnWpaStateChangedTest, TestSize.Level1)
|
||||
OnWpsOverlap(status);
|
||||
OnWpsTimeOut(status);
|
||||
UnRegisterStaCallbackMock(&callback);
|
||||
WifiStaHalInterface::GetInstance().RegisterStaEventCallback(callback);
|
||||
WifiStaHalInterface::GetInstance().RegisterStaEventCallback(callback, ifaceName);
|
||||
OnWpaStateChanged(status);
|
||||
OnWpaSsidWrongKey();
|
||||
OnWpaConnectionFull(status);
|
||||
|
@ -61,7 +61,7 @@ void WifiStaHalInterfaceTest::SetUpTestCase()
|
||||
callback.onWpaSsidWrongKey = OnWpaSsidWrongKey;
|
||||
callback.onWpsOverlap = OnWpsOverlap;
|
||||
callback.onWpsTimeOut = OnWpsTimeOut;
|
||||
WifiStaHalInterface::GetInstance().RegisterStaEventCallback(callback);
|
||||
WifiStaHalInterface::GetInstance().RegisterStaEventCallback(callback, ifaceName);
|
||||
|
||||
SupplicantEventCallback cbk;
|
||||
cbk.onScanNotify = OnScanNotify;
|
||||
@ -71,7 +71,8 @@ void WifiStaHalInterfaceTest::SetUpTestCase()
|
||||
void WifiStaHalInterfaceTest::TearDownTestCase()
|
||||
{
|
||||
WifiEventCallback callback;
|
||||
WifiStaHalInterface::GetInstance().RegisterStaEventCallback(callback);
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiStaHalInterface::GetInstance().RegisterStaEventCallback(callback, ifaceName);
|
||||
WifiSupplicantHalInterface::GetInstance().UnRegisterSupplicantEventCallback();
|
||||
}
|
||||
|
||||
@ -83,7 +84,8 @@ HWTEST_F(WifiStaHalInterfaceTest, StartWifiTest, TestSize.Level1)
|
||||
|
||||
HWTEST_F(WifiStaHalInterfaceTest, ConnectTest, TestSize.Level1)
|
||||
{
|
||||
WifiErrorNo ret = WifiStaHalInterface::GetInstance().Connect(1);
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiErrorNo ret = WifiStaHalInterface::GetInstance().Connect(1, ifaceName);
|
||||
EXPECT_FALSE(ret == WIFI_HAL_OPT_OK);
|
||||
}
|
||||
|
||||
@ -101,7 +103,8 @@ HWTEST_F(WifiStaHalInterfaceTest, ReassociateTest, TestSize.Level1)
|
||||
|
||||
HWTEST_F(WifiStaHalInterfaceTest, DisconnectTest, TestSize.Level1)
|
||||
{
|
||||
WifiErrorNo ret = WifiStaHalInterface::GetInstance().Disconnect();
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiErrorNo ret = WifiStaHalInterface::GetInstance().Disconnect(ifaceName);
|
||||
EXPECT_TRUE(ret == WIFI_HAL_OPT_OK);
|
||||
}
|
||||
|
||||
@ -115,7 +118,8 @@ HWTEST_F(WifiStaHalInterfaceTest, GetStaCapabilitiesTest, TestSize.Level1)
|
||||
HWTEST_F(WifiStaHalInterfaceTest, GetStaDeviceMacAddressTest, TestSize.Level1)
|
||||
{
|
||||
std::string mac;
|
||||
WifiErrorNo ret = WifiStaHalInterface::GetInstance().GetStaDeviceMacAddress(mac);
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiErrorNo ret = WifiStaHalInterface::GetInstance().GetStaDeviceMacAddress(mac, ifaceName);
|
||||
EXPECT_TRUE(ret == WIFI_HAL_OPT_OK);
|
||||
}
|
||||
|
||||
@ -224,26 +228,30 @@ HWTEST_F(WifiStaHalInterfaceTest, RemoveDeviceConfigTest, TestSize.Level1)
|
||||
|
||||
HWTEST_F(WifiStaHalInterfaceTest, ClearDeviceConfigTest, TestSize.Level1)
|
||||
{
|
||||
WifiErrorNo ret = WifiStaHalInterface::GetInstance().ClearDeviceConfig();
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiErrorNo ret = WifiStaHalInterface::GetInstance().ClearDeviceConfig(ifaceName);
|
||||
EXPECT_TRUE(ret == WIFI_HAL_OPT_OK);
|
||||
}
|
||||
|
||||
HWTEST_F(WifiStaHalInterfaceTest, GetNextNetworkIdTest, TestSize.Level1)
|
||||
{
|
||||
int id = 0;
|
||||
WifiErrorNo ret = WifiStaHalInterface::GetInstance().GetNextNetworkId(id);
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiErrorNo ret = WifiStaHalInterface::GetInstance().GetNextNetworkId(id, ifaceName);
|
||||
EXPECT_TRUE(ret == WIFI_HAL_OPT_OK);
|
||||
}
|
||||
|
||||
HWTEST_F(WifiStaHalInterfaceTest, EnableNetworkTest, TestSize.Level1)
|
||||
{
|
||||
WifiErrorNo ret = WifiStaHalInterface::GetInstance().EnableNetwork(1);
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiErrorNo ret = WifiStaHalInterface::GetInstance().EnableNetwork(1, ifaceName);
|
||||
EXPECT_FALSE(ret == WIFI_HAL_OPT_OK);
|
||||
}
|
||||
|
||||
HWTEST_F(WifiStaHalInterfaceTest, DisableNetworkTest, TestSize.Level1)
|
||||
{
|
||||
WifiErrorNo ret = WifiStaHalInterface::GetInstance().DisableNetwork(1);
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiErrorNo ret = WifiStaHalInterface::GetInstance().DisableNetwork(1, ifaceName);
|
||||
EXPECT_FALSE(ret == WIFI_HAL_OPT_OK);
|
||||
}
|
||||
|
||||
@ -251,35 +259,37 @@ HWTEST_F(WifiStaHalInterfaceTest, SetDeviceConfigTest, TestSize.Level1)
|
||||
{
|
||||
WifiHalDeviceConfig cfg;
|
||||
cfg.psk = "1234567";
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiErrorNo ret = WifiStaHalInterface::GetInstance().SetDeviceConfig(1, cfg);
|
||||
EXPECT_TRUE(ret == WIFI_HAL_OPT_FAILED);
|
||||
cfg.psk = "01234567890123456789012345678901234567890123456789012345678901234";
|
||||
ret = WifiStaHalInterface::GetInstance().SetDeviceConfig(1, cfg);
|
||||
ret = WifiStaHalInterface::GetInstance().SetDeviceConfig(1, cfg, ifaceName);
|
||||
EXPECT_TRUE(ret == WIFI_HAL_OPT_FAILED);
|
||||
cfg.psk = "12345678";
|
||||
ret = WifiStaHalInterface::GetInstance().SetDeviceConfig(1, cfg);
|
||||
ret = WifiStaHalInterface::GetInstance().SetDeviceConfig(1, cfg, ifaceName);
|
||||
EXPECT_FALSE(ret == WIFI_HAL_OPT_OK);
|
||||
cfg.authAlgorithms = 8;
|
||||
ret = WifiStaHalInterface::GetInstance().SetDeviceConfig(1, cfg);
|
||||
ret = WifiStaHalInterface::GetInstance().SetDeviceConfig(1, cfg, ifaceName);
|
||||
EXPECT_TRUE(ret == WIFI_HAL_OPT_FAILED);
|
||||
cfg.authAlgorithms = 7;
|
||||
ret = WifiStaHalInterface::GetInstance().SetDeviceConfig(1, cfg);
|
||||
ret = WifiStaHalInterface::GetInstance().SetDeviceConfig(1, cfg, ifaceName);
|
||||
EXPECT_FALSE(ret == WIFI_HAL_OPT_OK);
|
||||
cfg.ssid = "Honor";
|
||||
cfg.priority = 5;
|
||||
cfg.scanSsid = 1;
|
||||
cfg.wepKeyIdx = 2;
|
||||
ret = WifiStaHalInterface::GetInstance().SetDeviceConfig(1, cfg);
|
||||
ret = WifiStaHalInterface::GetInstance().SetDeviceConfig(1, cfg, ifaceName);
|
||||
EXPECT_FALSE(ret == WIFI_HAL_OPT_OK);
|
||||
cfg.allowedGroupMgmtCiphers = 4;
|
||||
ret = WifiStaHalInterface::GetInstance().SetDeviceConfig(1, cfg);
|
||||
ret = WifiStaHalInterface::GetInstance().SetDeviceConfig(1, cfg, ifaceName);
|
||||
EXPECT_FALSE(ret == WIFI_HAL_OPT_OK);
|
||||
}
|
||||
|
||||
HWTEST_F(WifiStaHalInterfaceTest, GetDeviceConfigTest, TestSize.Level1)
|
||||
{
|
||||
WifiHalGetDeviceConfig cfg;
|
||||
WifiErrorNo ret = WifiStaHalInterface::GetInstance().GetDeviceConfig(cfg);
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiErrorNo ret = WifiStaHalInterface::GetInstance().GetDeviceConfig(cfg, ifaceName);
|
||||
EXPECT_FALSE(ret == WIFI_HAL_OPT_OK);
|
||||
}
|
||||
|
||||
|
@ -57,6 +57,8 @@ ohos_unittest("manager_unittest") {
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/wifi_system_timer.cpp",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_controller/concrete_clientmode_manager.cpp",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_controller/concrete_manager_state_machine.cpp",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_controller/multi_sta_manager.cpp",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_controller/multi_sta_state_machine.cpp",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_controller/softap_manager.cpp",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_controller/softap_manager_state_machine.cpp",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_controller/wifi_controller_state_machine.cpp",
|
||||
|
@ -28,6 +28,8 @@ ohos_unittest("wifi_controller_unittest") {
|
||||
"$WIFI_ROOT_DIR/frameworks/native/src/network_selection.cpp",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_controller/concrete_clientmode_manager.cpp",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_controller/concrete_manager_state_machine.cpp",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_controller/multi_sta_manager.cpp",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_controller/multi_sta_state_machine.cpp",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_controller/softap_manager.cpp",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_controller/softap_manager_state_machine.cpp",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_controller/wifi_controller_state_machine.cpp",
|
||||
|
@ -84,8 +84,9 @@ public:
|
||||
|
||||
void WifiToggledTest1()
|
||||
{
|
||||
int instId = 0;
|
||||
InternalMessagePtr msg = std::make_shared<InternalMessage>();
|
||||
WifiConfigCenter::GetInstance().SetWifiToggledState(false);
|
||||
WifiConfigCenter::GetInstance().SetWifiToggledState(false, instId);
|
||||
WifiSettings::GetInstance().SetScanOnlySwitchState(0, 0);
|
||||
WifiConfigCenter::GetInstance().SetWifiStopState(true);
|
||||
msg->SetMessageName(CMD_WIFI_TOGGLED);
|
||||
@ -101,8 +102,9 @@ public:
|
||||
|
||||
void WifiToggledTest2()
|
||||
{
|
||||
int instId = 0;
|
||||
InternalMessagePtr msg = std::make_shared<InternalMessage>();
|
||||
WifiConfigCenter::GetInstance().SetWifiToggledState(false);
|
||||
WifiConfigCenter::GetInstance().SetWifiToggledState(false, instId);
|
||||
WifiSettings::GetInstance().SetScanOnlySwitchState(0, 0);
|
||||
WifiConfigCenter::GetInstance().SetWifiStopState(true);
|
||||
msg->SetMessageName(CMD_WIFI_TOGGLED);
|
||||
@ -120,8 +122,9 @@ public:
|
||||
|
||||
void HandleStaStartFail()
|
||||
{
|
||||
int instId = 0;
|
||||
InternalMessagePtr msg = std::make_shared<InternalMessage>();
|
||||
WifiConfigCenter::GetInstance().SetWifiToggledState(false);
|
||||
WifiConfigCenter::GetInstance().SetWifiToggledState(false, instId);
|
||||
WifiSettings::GetInstance().SetScanOnlySwitchState(0, 0);
|
||||
WifiConfigCenter::GetInstance().SetWifiStopState(true);
|
||||
msg->SetMessageName(CMD_STA_START_FAILURE);
|
||||
@ -295,6 +298,7 @@ public:
|
||||
|
||||
void ConcreteIdExistTest()
|
||||
{
|
||||
int instId = 0;
|
||||
ConcreteClientModeManager *clientmode =
|
||||
new (std::nothrow) ConcreteClientModeManager(ConcreteManagerRole::ROLE_CLIENT_STA, 0);
|
||||
clientmode->pConcreteMangerMachine = new MockConcreteMangerMachine();
|
||||
@ -310,13 +314,13 @@ public:
|
||||
pWifiControllerMachine->HandleStaSemiActive(0);
|
||||
pWifiControllerMachine->HandleStaClose(0);
|
||||
pWifiControllerMachine->SwitchRole(ConcreteManagerRole::ROLE_CLIENT_SCAN_ONLY);
|
||||
WifiConfigCenter::GetInstance().SetWifiToggledState(1);
|
||||
EXPECT_TRUE(pWifiControllerMachine->ShouldEnableWifi());
|
||||
WifiConfigCenter::GetInstance().SetWifiToggledState(1, instId);
|
||||
EXPECT_TRUE(pWifiControllerMachine->ShouldEnableWifi(instId));
|
||||
InternalMessagePtr msg = std::make_shared<InternalMessage>();
|
||||
msg->SetMessageName(CMD_WIFI_TOGGLED);
|
||||
msg->SetParam2(0);
|
||||
EXPECT_FALSE(pWifiControllerMachine->ShouldDisableWifi(msg));
|
||||
WifiConfigCenter::GetInstance().SetWifiToggledState(WIFI_STATE_SEMI_ENABLED);
|
||||
WifiConfigCenter::GetInstance().SetWifiToggledState(WIFI_STATE_SEMI_ENABLED, instId);
|
||||
WifiConfigCenter::GetInstance().SetWifiDetailState(WifiDetailState::STATE_ACTIVATED, 0);
|
||||
EXPECT_TRUE(pWifiControllerMachine->ShouldDisableWifi(msg));
|
||||
pWifiControllerMachine->RemoveConcreteManager(1);
|
||||
@ -326,6 +330,7 @@ public:
|
||||
|
||||
void GetWifiRoleTest()
|
||||
{
|
||||
int instId = 0;
|
||||
pWifiControllerMachine->GetWifiRole();
|
||||
}
|
||||
};
|
||||
@ -467,11 +472,12 @@ HWTEST_F(WifiControllerMachineTest, GetWifiRoleTest, TestSize.Level1)
|
||||
|
||||
HWTEST_F(WifiControllerMachineTest, HandleApStopTest, TestSize.Level1)
|
||||
{
|
||||
int instId = 0;
|
||||
InternalMessagePtr msg = std::make_shared<InternalMessage>();
|
||||
msg->SetMessageName(CMD_AP_STOPPED);
|
||||
msg->SetParam1(0);
|
||||
WifiConfigCenter::GetInstance().SetSoftapToggledState(false);
|
||||
WifiConfigCenter::GetInstance().SetWifiToggledState(WIFI_STATE_DISABLED);
|
||||
WifiConfigCenter::GetInstance().SetWifiToggledState(WIFI_STATE_DISABLED, instId);
|
||||
pWifiControllerMachine->pEnableState->HandleApStop(msg);
|
||||
}
|
||||
}
|
||||
|
@ -33,46 +33,53 @@ public:
|
||||
|
||||
HWTEST_F(WifiHdiWpaStaImplTest, HdiWpaStaStartTest_01, TestSize.Level1)
|
||||
{
|
||||
WifiErrorNo result = HdiWpaStaStart(nullptr);
|
||||
WifiErrorNo result = HdiWpaStaStart(nullptr, 0);
|
||||
int instId = 0;
|
||||
std::string ifaceName = "wlan0";
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_FAILED);
|
||||
result = HdiWpaStaStart("wlan0");
|
||||
result = HdiWpaStaStart(ifaceName.c_str(), instId);
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_FAILED);
|
||||
}
|
||||
|
||||
HWTEST_F(WifiHdiWpaStaImplTest, HdiWpaStaStopTest_01, TestSize.Level1)
|
||||
{
|
||||
WifiErrorNo result = HdiWpaStaStop();
|
||||
int instId = 0;
|
||||
WifiErrorNo result = HdiWpaStaStop(instId);
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_OK);
|
||||
}
|
||||
|
||||
HWTEST_F(WifiHdiWpaStaImplTest, HdiWpaStaConnectTest, TestSize.Level1)
|
||||
{
|
||||
int networkId = 1;
|
||||
WifiErrorNo result = HdiWpaStaConnect(networkId);
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiErrorNo result = HdiWpaStaConnect(networkId, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_FAILED);
|
||||
}
|
||||
|
||||
HWTEST_F(WifiHdiWpaStaImplTest, HdiWpaStaAddNetworkTest, TestSize.Level1)
|
||||
{
|
||||
int *networkId = nullptr;
|
||||
WifiErrorNo result = HdiWpaStaAddNetwork(networkId);
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiErrorNo result = HdiWpaStaAddNetwork(networkId, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_INVALID_PARAM);
|
||||
|
||||
int workld = 1;
|
||||
result = HdiWpaStaAddNetwork(&workld);
|
||||
result = HdiWpaStaAddNetwork(&workld, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_FAILED);
|
||||
}
|
||||
|
||||
HWTEST_F(WifiHdiWpaStaImplTest, HdiWpaStaDisableNetworkTest, TestSize.Level1)
|
||||
{
|
||||
int networkId = 1;
|
||||
WifiErrorNo result = HdiWpaStaDisableNetwork(networkId);
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiErrorNo result = HdiWpaStaDisableNetwork(networkId, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_FAILED);
|
||||
}
|
||||
|
||||
HWTEST_F(WifiHdiWpaStaImplTest, HdiWpaStaSaveConfigTest, TestSize.Level1)
|
||||
{
|
||||
WifiErrorNo result = HdiWpaStaSaveConfig();
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiErrorNo result = HdiWpaStaSaveConfig(ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_FAILED);
|
||||
}
|
||||
|
||||
@ -80,29 +87,32 @@ HWTEST_F(WifiHdiWpaStaImplTest, HdiWpaStaStartWpsPinModeTest, TestSize.Level1)
|
||||
{
|
||||
WifiWpsParam config;
|
||||
int pinCode;
|
||||
WifiErrorNo result = HdiWpaStaStartWpsPinMode(nullptr, &pinCode);
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiErrorNo result = HdiWpaStaStartWpsPinMode(nullptr, &pinCode, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_INVALID_PARAM);
|
||||
result = HdiWpaStaStartWpsPinMode(&config, nullptr);
|
||||
result = HdiWpaStaStartWpsPinMode(&config, nullptr, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_INVALID_PARAM);
|
||||
result = HdiWpaStaStartWpsPinMode(nullptr, nullptr);
|
||||
result = HdiWpaStaStartWpsPinMode(nullptr, nullptr, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_INVALID_PARAM);
|
||||
result = HdiWpaStaStartWpsPinMode(&config, &pinCode);
|
||||
result = HdiWpaStaStartWpsPinMode(&config, &pinCode, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_FAILED);
|
||||
}
|
||||
|
||||
HWTEST_F(WifiHdiWpaStaImplTest, HdiWpaStaStartWpsPbcModeTest, TestSize.Level1)
|
||||
{
|
||||
WifiWpsParam config;
|
||||
WifiErrorNo result = HdiWpaStaStartWpsPbcMode(nullptr);
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiErrorNo result = HdiWpaStaStartWpsPbcMode(nullptr, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_INVALID_PARAM);
|
||||
result = HdiWpaStaStartWpsPbcMode(&config);
|
||||
result = HdiWpaStaStartWpsPbcMode(&config, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_FAILED);
|
||||
}
|
||||
|
||||
HWTEST_F(WifiHdiWpaStaImplTest, HdiWpaStaSetCountryCodeTest, TestSize.Level1)
|
||||
{
|
||||
char countryCode[10] = "CN";
|
||||
WifiErrorNo result = HdiWpaStaSetCountryCode(countryCode);
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiErrorNo result = HdiWpaStaSetCountryCode(countryCode, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_FAILED);
|
||||
}
|
||||
|
||||
@ -110,14 +120,16 @@ HWTEST_F(WifiHdiWpaStaImplTest, HdiWpaStaGetCountryCodeTest, TestSize.Level1)
|
||||
{
|
||||
char countryCode[2];
|
||||
uint32_t size = 2;
|
||||
WifiErrorNo result = HdiWpaStaGetCountryCode(countryCode, size);
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiErrorNo result = HdiWpaStaGetCountryCode(countryCode, size, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_FAILED);
|
||||
}
|
||||
|
||||
HWTEST_F(WifiHdiWpaStaImplTest, HdiWpaStaSetSuspendModeTest, TestSize.Level1)
|
||||
{
|
||||
int mode = 1;
|
||||
WifiErrorNo result = HdiWpaStaSetSuspendMode(mode);
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiErrorNo result = HdiWpaStaSetSuspendMode(mode, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_FAILED);
|
||||
}
|
||||
|
||||
@ -125,7 +137,8 @@ HWTEST_F(WifiHdiWpaStaImplTest, HdiWpaListNetworksTest, TestSize.Level1)
|
||||
{
|
||||
struct HdiWifiWpaNetworkInfo networkList[10];
|
||||
uint32_t size = 10;
|
||||
WifiErrorNo result = HdiWpaListNetworks(networkList, &size);
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiErrorNo result = HdiWpaListNetworks(networkList, &size, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_FAILED);
|
||||
}
|
||||
|
||||
@ -135,7 +148,8 @@ HWTEST_F(WifiHdiWpaStaImplTest, HdiWpaGetNetworkTest, TestSize.Level1)
|
||||
const char *param = "param";
|
||||
char value[10];
|
||||
uint32_t valueLen = 10;
|
||||
WifiErrorNo result = HdiWpaGetNetwork(networkId, param, value, valueLen);
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiErrorNo result = HdiWpaGetNetwork(networkId, param, value, valueLen, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_FAILED);
|
||||
}
|
||||
|
||||
@ -159,26 +173,30 @@ HWTEST_F(WifiHdiWpaStaImplTest, HdiWpaStaGetPskPassphraseTest, TestSize.Level1)
|
||||
HWTEST_F(WifiHdiWpaStaImplTest, HdiWpaStaSetPowerSaveTest, TestSize.Level1)
|
||||
{
|
||||
int enable = true;
|
||||
WifiErrorNo result = HdiWpaStaSetPowerSave(enable);
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiErrorNo result = HdiWpaStaSetPowerSave(enable, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_FAILED);
|
||||
}
|
||||
|
||||
HWTEST_F(WifiHdiWpaStaImplTest, HdiWpaStaBlocklistClearTest, TestSize.Level1)
|
||||
{
|
||||
WifiErrorNo result = HdiWpaStaBlocklistClear();
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiErrorNo result = HdiWpaStaBlocklistClear(ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_FAILED);
|
||||
}
|
||||
|
||||
HWTEST_F(WifiHdiWpaStaImplTest, HdiWpaStaAutoConnectTest, TestSize.Level1)
|
||||
{
|
||||
int enable = true;
|
||||
WifiErrorNo result = HdiWpaStaAutoConnect(enable);
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiErrorNo result = HdiWpaStaAutoConnect(enable, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_FAILED);
|
||||
}
|
||||
|
||||
HWTEST_F(WifiHdiWpaStaImplTest, HdiStopWpsStaTest, TestSize.Level1)
|
||||
{
|
||||
WifiErrorNo result = HdiStopWpsSta();
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiErrorNo result = HdiStopWpsSta(ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_FAILED);
|
||||
}
|
||||
|
||||
@ -186,21 +204,24 @@ HWTEST_F(WifiHdiWpaStaImplTest, HdiWpaStaSetNetworkTest, TestSize.Level1)
|
||||
{
|
||||
int networkId = 1;
|
||||
int size = 1;
|
||||
WifiErrorNo result = HdiWpaStaSetNetwork(networkId, nullptr, size);
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiErrorNo result = HdiWpaStaSetNetwork(networkId, nullptr, size, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_INVALID_PARAM);
|
||||
}
|
||||
|
||||
HWTEST_F(WifiHdiWpaStaImplTest, HdiWpaStaEnableNetworkTest, TestSize.Level1)
|
||||
{
|
||||
int networkId = 2;
|
||||
WifiErrorNo result = HdiWpaStaEnableNetwork(networkId);
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiErrorNo result = HdiWpaStaEnableNetwork(networkId, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_FAILED);
|
||||
}
|
||||
|
||||
HWTEST_F(WifiHdiWpaStaImplTest, HdiWpaStaRemoveNetworkTest, TestSize.Level1)
|
||||
{
|
||||
int networkId = 3;
|
||||
WifiErrorNo result = HdiWpaStaRemoveNetwork(networkId);
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiErrorNo result = HdiWpaStaRemoveNetwork(networkId, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_FAILED);
|
||||
}
|
||||
|
||||
@ -214,10 +235,11 @@ HWTEST_F(WifiHdiWpaStaImplTest, HdiWpaStaGetDeviceMacAddressTest, TestSize.Level
|
||||
{
|
||||
char macAddr[18] = {0};
|
||||
int macAddrLen = 0;
|
||||
WifiErrorNo result = HdiWpaStaGetDeviceMacAddress(nullptr, macAddrLen);
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiErrorNo result = HdiWpaStaGetDeviceMacAddress(nullptr, macAddrLen, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_INVALID_PARAM);
|
||||
|
||||
result = HdiWpaStaGetDeviceMacAddress(macAddr, macAddrLen);
|
||||
result = HdiWpaStaGetDeviceMacAddress(macAddr, macAddrLen, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_FAILED);
|
||||
}
|
||||
|
||||
@ -313,33 +335,38 @@ HWTEST_F(WifiHdiWpaStaImplTest, ConvertMacToStrSuccess, TestSize.Level1)
|
||||
|
||||
HWTEST_F(WifiHdiWpaStaImplTest, HdiWpaStaDisconnectTest, TestSize.Level1)
|
||||
{
|
||||
WifiErrorNo result = HdiWpaStaDisconnect();
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiErrorNo result = HdiWpaStaDisconnect(ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_FAILED);
|
||||
}
|
||||
|
||||
HWTEST_F(WifiHdiWpaStaImplTest, HdiWpaStaReassociateTest, TestSize.Level1)
|
||||
{
|
||||
WifiErrorNo result = HdiWpaStaReassociate();
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiErrorNo result = HdiWpaStaReassociate(ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_FAILED);
|
||||
}
|
||||
|
||||
HWTEST_F(WifiHdiWpaStaImplTest, HdiWpaStaReconnectTest, TestSize.Level1)
|
||||
{
|
||||
WifiErrorNo result = HdiWpaStaReconnect();
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiErrorNo result = HdiWpaStaReconnect(ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_FAILED);
|
||||
}
|
||||
|
||||
HWTEST_F(WifiHdiWpaStaImplTest, HdiWpaStaGetScanInfosTest, TestSize.Level1)
|
||||
{
|
||||
int *size = nullptr;
|
||||
ScanInfo *result = HdiWpaStaGetScanInfos(size);
|
||||
std::string ifaceName = "wlan0";
|
||||
ScanInfo *result = HdiWpaStaGetScanInfos(size, ifaceName.c_str());
|
||||
EXPECT_EQ(result, NULL);
|
||||
}
|
||||
|
||||
HWTEST_F(WifiHdiWpaStaImplTest, HdiWpaStaGetScanInfosTest1, TestSize.Level1)
|
||||
{
|
||||
int size = 1;
|
||||
ScanInfo *result = HdiWpaStaGetScanInfos(&size);
|
||||
std::string ifaceName = "wlan0";
|
||||
ScanInfo *result = HdiWpaStaGetScanInfos(&size, ifaceName.c_str());
|
||||
EXPECT_EQ(result, NULL);
|
||||
}
|
||||
}
|
||||
|
@ -40,38 +40,45 @@ public:
|
||||
|
||||
HWTEST_F(WifiHdiWpaClientTest, StartWifi, TestSize.Level1)
|
||||
{
|
||||
WifiErrorNo result = wifiHdiWpaClient->StartWifi("wlan");
|
||||
std::string ifaceName = "wlan0";
|
||||
int instId = 0;
|
||||
WifiErrorNo result = wifiHdiWpaClient->StartWifi(ifaceName.c_str(), instId);
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_FAILED);
|
||||
}
|
||||
|
||||
HWTEST_F(WifiHdiWpaClientTest, ReqConnect, TestSize.Level1)
|
||||
{
|
||||
int networkId = 111;
|
||||
WifiErrorNo result = wifiHdiWpaClient->ReqConnect(networkId);
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiErrorNo result = wifiHdiWpaClient->ReqConnect(networkId, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_OK);
|
||||
}
|
||||
|
||||
HWTEST_F(WifiHdiWpaClientTest, StopWifi, TestSize.Level1)
|
||||
{
|
||||
WifiErrorNo result = wifiHdiWpaClient->StopWifi();
|
||||
int instId = 0;
|
||||
WifiErrorNo result = wifiHdiWpaClient->StopWifi(instId);
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_FAILED);
|
||||
}
|
||||
|
||||
HWTEST_F(WifiHdiWpaClientTest, ReqReconnect, TestSize.Level1)
|
||||
{
|
||||
WifiErrorNo result = wifiHdiWpaClient->ReqReconnect();
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiErrorNo result = wifiHdiWpaClient->ReqReconnect(ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_OK);
|
||||
}
|
||||
|
||||
HWTEST_F(WifiHdiWpaClientTest, ReqReassociate, TestSize.Level1)
|
||||
{
|
||||
WifiErrorNo result = wifiHdiWpaClient->ReqReassociate();
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiErrorNo result = wifiHdiWpaClient->ReqReassociate(ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_OK);
|
||||
}
|
||||
|
||||
HWTEST_F(WifiHdiWpaClientTest, ReqDisconnect, TestSize.Level1)
|
||||
{
|
||||
WifiErrorNo result = wifiHdiWpaClient->ReqDisconnect();
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiErrorNo result = wifiHdiWpaClient->ReqDisconnect(ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_OK);
|
||||
}
|
||||
|
||||
@ -87,10 +94,11 @@ HWTEST_F(WifiHdiWpaClientTest, GetStaDeviceMacAddress, TestSize.Level1)
|
||||
{
|
||||
std::string macAddress = "00:11:22:33:44:55";
|
||||
std::string result;
|
||||
WifiErrorNo error = wifiHdiWpaClient->GetStaDeviceMacAddress(result);
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiErrorNo error = wifiHdiWpaClient->GetStaDeviceMacAddress(result, ifaceName.c_str());
|
||||
EXPECT_EQ(error, WIFI_HAL_OPT_FAILED);
|
||||
|
||||
error = wifiHdiWpaClient->GetStaDeviceMacAddress(macAddress);
|
||||
error = wifiHdiWpaClient->GetStaDeviceMacAddress(macAddress, ifaceName.c_str());
|
||||
EXPECT_EQ(error, WIFI_HAL_OPT_FAILED);
|
||||
}
|
||||
|
||||
@ -137,37 +145,42 @@ HWTEST_F(WifiHdiWpaClientTest, ReqStopPnoScan, TestSize.Level1)
|
||||
HWTEST_F(WifiHdiWpaClientTest, RemoveDevice, TestSize.Level1)
|
||||
{
|
||||
int networkId = 222;
|
||||
WifiErrorNo result = wifiHdiWpaClient->RemoveDevice(networkId);
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiErrorNo result = wifiHdiWpaClient->RemoveDevice(networkId, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_OK);
|
||||
result = wifiHdiWpaClient->RemoveDevice(-1);
|
||||
result = wifiHdiWpaClient->RemoveDevice(-1, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_INVALID_PARAM);
|
||||
}
|
||||
|
||||
HWTEST_F(WifiHdiWpaClientTest, GetNextNetworkId, TestSize.Level1)
|
||||
{
|
||||
int networkId;
|
||||
WifiErrorNo result = wifiHdiWpaClient->GetNextNetworkId(networkId);
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiErrorNo result = wifiHdiWpaClient->GetNextNetworkId(networkId, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_OK);
|
||||
EXPECT_EQ(networkId, 0);
|
||||
}
|
||||
|
||||
HWTEST_F(WifiHdiWpaClientTest, ClearDeviceConfig, TestSize.Level1)
|
||||
{
|
||||
WifiErrorNo result = wifiHdiWpaClient->ClearDeviceConfig();
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiErrorNo result = wifiHdiWpaClient->ClearDeviceConfig(ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_OK);
|
||||
}
|
||||
|
||||
HWTEST_F(WifiHdiWpaClientTest, ReqEnableNetwork, TestSize.Level1)
|
||||
{
|
||||
int networkId = 333;
|
||||
WifiErrorNo result = wifiHdiWpaClient->ReqEnableNetwork(networkId);
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiErrorNo result = wifiHdiWpaClient->ReqEnableNetwork(networkId, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_OK);
|
||||
}
|
||||
|
||||
HWTEST_F(WifiHdiWpaClientTest, ReqDisableNetwork, TestSize.Level1)
|
||||
{
|
||||
int networkId = 444;
|
||||
WifiErrorNo result = wifiHdiWpaClient->ReqDisableNetwork(networkId);
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiErrorNo result = wifiHdiWpaClient->ReqDisableNetwork(networkId, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_OK);
|
||||
}
|
||||
|
||||
@ -176,17 +189,18 @@ HWTEST_F(WifiHdiWpaClientTest, SetDeviceConfigTest, TestSize.Level1)
|
||||
int networkId = 555;
|
||||
WifiHalDeviceConfig config;
|
||||
config.psk = "";
|
||||
WifiErrorNo result = wifiHdiWpaClient->SetDeviceConfig(networkId, config);
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiErrorNo result = wifiHdiWpaClient->SetDeviceConfig(networkId, config, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_OK);
|
||||
config.psk = "12345";
|
||||
result = wifiHdiWpaClient->SetDeviceConfig(networkId, config);
|
||||
result = wifiHdiWpaClient->SetDeviceConfig(networkId, config, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_FAILED);
|
||||
config.psk = "1234567891011121314151617181920abcdefdhigklmnopqrst123456789101112131415";
|
||||
result = wifiHdiWpaClient->SetDeviceConfig(networkId, config);
|
||||
result = wifiHdiWpaClient->SetDeviceConfig(networkId, config, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_FAILED);
|
||||
config.psk = "12345678910";
|
||||
config.authAlgorithms = 10;
|
||||
result = wifiHdiWpaClient->SetDeviceConfig(networkId, config);
|
||||
result = wifiHdiWpaClient->SetDeviceConfig(networkId, config, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_FAILED);
|
||||
|
||||
config.ssid = "TestSSID";
|
||||
@ -195,26 +209,26 @@ HWTEST_F(WifiHdiWpaClientTest, SetDeviceConfigTest, TestSize.Level1)
|
||||
config.priority = 1;
|
||||
SetNetworkConfig expectedConfig[DEVICE_CONFIG_END_POS];
|
||||
memcpy_s(expectedConfig, sizeof(expectedConfig), 0, sizeof(expectedConfig));
|
||||
result = wifiHdiWpaClient->SetDeviceConfig(networkId, config);
|
||||
result = wifiHdiWpaClient->SetDeviceConfig(networkId, config, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_FAILED);
|
||||
|
||||
config.keyMgmt = "SAE";
|
||||
config.eapConfig.eap = "NONE";
|
||||
result = wifiHdiWpaClient->SetDeviceConfig(networkId, config);
|
||||
result = wifiHdiWpaClient->SetDeviceConfig(networkId, config, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_FAILED);
|
||||
|
||||
config.keyMgmt = "NONE";
|
||||
config.eapConfig.eap = "TLS";
|
||||
result = wifiHdiWpaClient->SetDeviceConfig(networkId, config);
|
||||
result = wifiHdiWpaClient->SetDeviceConfig(networkId, config, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_FAILED);
|
||||
|
||||
config.keyMgmt = "WEP";
|
||||
config.eapConfig.eap = "TTLS";
|
||||
result = wifiHdiWpaClient->SetDeviceConfig(networkId, config);
|
||||
result = wifiHdiWpaClient->SetDeviceConfig(networkId, config, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_FAILED);
|
||||
|
||||
config.keyMgmt = "WAPI";
|
||||
result = wifiHdiWpaClient->SetDeviceConfig(networkId, config);
|
||||
result = wifiHdiWpaClient->SetDeviceConfig(networkId, config, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_FAILED);
|
||||
}
|
||||
|
||||
@ -223,46 +237,47 @@ HWTEST_F(WifiHdiWpaClientTest, SetDeviceConfigTest1, TestSize.Level1)
|
||||
int networkId = 555;
|
||||
WifiHalDeviceConfig config;
|
||||
config.priority = -1;
|
||||
WifiErrorNo result = wifiHdiWpaClient->SetDeviceConfig(networkId, config);
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiErrorNo result = wifiHdiWpaClient->SetDeviceConfig(networkId, config, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_OK);
|
||||
|
||||
config.priority = 1;
|
||||
config.scanSsid = 1;
|
||||
result = wifiHdiWpaClient->SetDeviceConfig(networkId, config);
|
||||
result = wifiHdiWpaClient->SetDeviceConfig(networkId, config, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_OK);
|
||||
|
||||
config.scanSsid = 2;
|
||||
config.wepKeyIdx = 1;
|
||||
result = wifiHdiWpaClient->SetDeviceConfig(networkId, config);
|
||||
result = wifiHdiWpaClient->SetDeviceConfig(networkId, config, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_OK);
|
||||
|
||||
config.wepKeyIdx = -1;
|
||||
config.authAlgorithms = 1;
|
||||
result = wifiHdiWpaClient->SetDeviceConfig(networkId, config);
|
||||
result = wifiHdiWpaClient->SetDeviceConfig(networkId, config, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_OK);
|
||||
|
||||
config.authAlgorithms = 0;
|
||||
config.isRequirePmf = true;
|
||||
result = wifiHdiWpaClient->SetDeviceConfig(networkId, config);
|
||||
result = wifiHdiWpaClient->SetDeviceConfig(networkId, config, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_OK);
|
||||
|
||||
config.allowedProtocols = 1;
|
||||
result = wifiHdiWpaClient->SetDeviceConfig(networkId, config);
|
||||
result = wifiHdiWpaClient->SetDeviceConfig(networkId, config, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_OK);
|
||||
|
||||
config.allowedProtocols = -1;
|
||||
config.allowedPairwiseCiphers = 1;
|
||||
result = wifiHdiWpaClient->SetDeviceConfig(networkId, config);
|
||||
result = wifiHdiWpaClient->SetDeviceConfig(networkId, config, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_OK);
|
||||
|
||||
config.allowedPairwiseCiphers = 0;
|
||||
config.allowedGroupCiphers = 1;
|
||||
result = wifiHdiWpaClient->SetDeviceConfig(networkId, config);
|
||||
result = wifiHdiWpaClient->SetDeviceConfig(networkId, config, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_OK);
|
||||
|
||||
config.allowedGroupCiphers = 0;
|
||||
config.allowedGroupMgmtCiphers = 1;
|
||||
result = wifiHdiWpaClient->SetDeviceConfig(networkId, config);
|
||||
result = wifiHdiWpaClient->SetDeviceConfig(networkId, config, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_OK);
|
||||
}
|
||||
|
||||
@ -270,28 +285,32 @@ HWTEST_F(WifiHdiWpaClientTest, SetBssid, TestSize.Level1)
|
||||
{
|
||||
int networkId = 666;
|
||||
std::string bssid = "00:11:22:33:44:55";
|
||||
|
||||
std::string ifaceName = "wlan0";
|
||||
SetNetworkConfig expectedConfig;
|
||||
memset_s(&expectedConfig, sizeof(expectedConfig), 0, sizeof(expectedConfig));
|
||||
|
||||
WifiErrorNo result = wifiHdiWpaClient->SetBssid(networkId, bssid);
|
||||
WifiErrorNo result = wifiHdiWpaClient->SetBssid(networkId, bssid, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_OK);
|
||||
|
||||
bssid = "";
|
||||
result = wifiHdiWpaClient->SetBssid(networkId, bssid);
|
||||
result = wifiHdiWpaClient->SetBssid(networkId, bssid, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_OK);
|
||||
}
|
||||
|
||||
HWTEST_F(WifiHdiWpaClientTest, SaveDeviceConfig, TestSize.Level1)
|
||||
{
|
||||
WifiErrorNo result = wifiHdiWpaClient->SaveDeviceConfig();
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiErrorNo result = wifiHdiWpaClient->SaveDeviceConfig(ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_OK);
|
||||
}
|
||||
|
||||
HWTEST_F(WifiHdiWpaClientTest, ReqRegisterStaEventCallbackTEST, TestSize.Level1)
|
||||
{
|
||||
int instId = 0;
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiEventCallback *wifiEventCallbackMock = new WifiEventCallback();
|
||||
WifiErrorNo result = wifiHdiWpaClient->ReqRegisterStaEventCallback(*wifiEventCallbackMock);
|
||||
WifiErrorNo result =
|
||||
wifiHdiWpaClient->ReqRegisterStaEventCallback(*wifiEventCallbackMock, ifaceName.c_str(), instId);
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_INVALID_PARAM);
|
||||
delete wifiEventCallbackMock;
|
||||
}
|
||||
@ -302,12 +321,13 @@ HWTEST_F(WifiHdiWpaClientTest, ReqStartWpsPbcModeTEST, TestSize.Level1)
|
||||
config.anyFlag = true;
|
||||
config.multiAp = false;
|
||||
config.bssid = "00:11:22:33:44:55";
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiWpsParam expectedParam;
|
||||
memset_s(&expectedParam, sizeof(expectedParam), 0, sizeof(expectedParam));
|
||||
expectedParam.anyFlag = true;
|
||||
expectedParam.multiAp = false;
|
||||
strncpy_s(expectedParam.bssid, sizeof(expectedParam.bssid), config.bssid.c_str(), sizeof(expectedParam.bssid) - 1);
|
||||
WifiErrorNo result = wifiHdiWpaClient->ReqStartWpsPbcMode(config);
|
||||
WifiErrorNo result = wifiHdiWpaClient->ReqStartWpsPbcMode(config, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_OK);
|
||||
}
|
||||
|
||||
@ -317,7 +337,8 @@ HWTEST_F(WifiHdiWpaClientTest, ReqStartWpsPbcModeTest, TestSize.Level1)
|
||||
config.anyFlag = true;
|
||||
config.multiAp = false;
|
||||
config.bssid = "";
|
||||
WifiErrorNo result = wifiHdiWpaClient->ReqStartWpsPbcMode(config);
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiErrorNo result = wifiHdiWpaClient->ReqStartWpsPbcMode(config, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_FAILED);
|
||||
}
|
||||
|
||||
@ -328,6 +349,7 @@ HWTEST_F(WifiHdiWpaClientTest, ReqStartWpsPinModeTEST, TestSize.Level1)
|
||||
config.multiAp = false;
|
||||
config.bssid = "00:11:22:33:44:55";
|
||||
config.pinCode = "12345678";
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiWpsParam expectedParam;
|
||||
memset_s(&expectedParam, sizeof(expectedParam), 0, sizeof(expectedParam));
|
||||
expectedParam.anyFlag = config.anyFlag;
|
||||
@ -336,7 +358,7 @@ HWTEST_F(WifiHdiWpaClientTest, ReqStartWpsPinModeTEST, TestSize.Level1)
|
||||
strncpy_s(expectedParam.pinCode, sizeof(expectedParam.pinCode), config.pinCode.c_str(),
|
||||
sizeof(expectedParam.pinCode) - 1);
|
||||
int pinCode;
|
||||
WifiErrorNo result = wifiHdiWpaClient->ReqStartWpsPinMode(config, pinCode);
|
||||
WifiErrorNo result = wifiHdiWpaClient->ReqStartWpsPinMode(config, pinCode, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_OK);
|
||||
}
|
||||
|
||||
@ -346,14 +368,16 @@ HWTEST_F(WifiHdiWpaClientTest, ReqStartWpsPinModeTest, TestSize.Level1)
|
||||
config.anyFlag = true;
|
||||
config.multiAp = false;
|
||||
config.bssid = "";
|
||||
std::string ifaceName = "wlan0";
|
||||
int pinCode;
|
||||
WifiErrorNo result = wifiHdiWpaClient->ReqStartWpsPinMode(config, pinCode);
|
||||
WifiErrorNo result = wifiHdiWpaClient->ReqStartWpsPinMode(config, pinCode, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_FAILED);
|
||||
}
|
||||
|
||||
HWTEST_F(WifiHdiWpaClientTest, ReqStopWpsTEST, TestSize.Level1)
|
||||
{
|
||||
WifiErrorNo result = wifiHdiWpaClient->ReqStopWps();
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiErrorNo result = wifiHdiWpaClient->ReqStopWps(ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_OK);
|
||||
}
|
||||
|
||||
@ -382,42 +406,48 @@ HWTEST_F(WifiHdiWpaClientTest, ReqGetConnectSignalInfoTEST, TestSize.Level1)
|
||||
HWTEST_F(WifiHdiWpaClientTest, ReqWpaAutoConnectTEST, TestSize.Level1)
|
||||
{
|
||||
int enable = 1;
|
||||
WifiErrorNo result = wifiHdiWpaClient->ReqWpaAutoConnect(enable);
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiErrorNo result = wifiHdiWpaClient->ReqWpaAutoConnect(enable, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_OK);
|
||||
}
|
||||
|
||||
HWTEST_F(WifiHdiWpaClientTest, ReqWpaBlocklistClearTEST, TestSize.Level1)
|
||||
{
|
||||
WifiErrorNo result = wifiHdiWpaClient->ReqWpaBlocklistClear();
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiErrorNo result = wifiHdiWpaClient->ReqWpaBlocklistClear(ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_OK);
|
||||
}
|
||||
|
||||
HWTEST_F(WifiHdiWpaClientTest, ReqSetPowerSave, TestSize.Level1)
|
||||
{
|
||||
bool enable = true;
|
||||
WifiErrorNo result = wifiHdiWpaClient->ReqSetPowerSave(enable);
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiErrorNo result = wifiHdiWpaClient->ReqSetPowerSave(enable, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_OK);
|
||||
}
|
||||
|
||||
HWTEST_F(WifiHdiWpaClientTest, ReqWpaSetCountryCodeTEST, TestSize.Level1)
|
||||
{
|
||||
std::string countryCode = "US";
|
||||
WifiErrorNo result = wifiHdiWpaClient->ReqWpaSetCountryCode(countryCode);
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiErrorNo result = wifiHdiWpaClient->ReqWpaSetCountryCode(countryCode, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_OK);
|
||||
}
|
||||
|
||||
HWTEST_F(WifiHdiWpaClientTest, ReqWpaGetCountryCodeTEST, TestSize.Level1)
|
||||
{
|
||||
std::string expectedCountryCode = "US";
|
||||
std::string ifaceName = "wlan0";
|
||||
std::string countryCode;
|
||||
WifiErrorNo result = wifiHdiWpaClient->ReqWpaGetCountryCode(countryCode);
|
||||
WifiErrorNo result = wifiHdiWpaClient->ReqWpaGetCountryCode(countryCode, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_FAILED);
|
||||
}
|
||||
|
||||
HWTEST_F(WifiHdiWpaClientTest, ReqWpaSetSuspendModeTEST, TestSize.Level1)
|
||||
{
|
||||
bool mode = true;
|
||||
WifiErrorNo result = wifiHdiWpaClient->ReqWpaSetSuspendMode(mode);
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiErrorNo result = wifiHdiWpaClient->ReqWpaSetSuspendMode(mode, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_OK);
|
||||
}
|
||||
|
||||
@ -447,8 +477,9 @@ HWTEST_F(WifiHdiWpaClientTest, ReqWpaShellCmdTest2, TestSize.Level1)
|
||||
|
||||
HWTEST_F(WifiHdiWpaClientTest, GetNetworkListTEST, TestSize.Level1)
|
||||
{
|
||||
std::string ifaceName = "wlan0";
|
||||
std::vector<WifiHalWpaNetworkInfo> networkList;
|
||||
WifiErrorNo result = wifiHdiWpaClient->GetNetworkList(networkList);
|
||||
WifiErrorNo result = wifiHdiWpaClient->GetNetworkList(networkList, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_FAILED);
|
||||
}
|
||||
|
||||
@ -457,7 +488,8 @@ HWTEST_F(WifiHdiWpaClientTest, GetDeviceConfigTEST, TestSize.Level1)
|
||||
WifiHalGetDeviceConfig config;
|
||||
config.networkId = 777;
|
||||
config.param = "param";
|
||||
WifiErrorNo result = wifiHdiWpaClient->GetDeviceConfig(config);
|
||||
std::string ifaceName = "wlan0";
|
||||
WifiErrorNo result = wifiHdiWpaClient->GetDeviceConfig(config, ifaceName.c_str());
|
||||
EXPECT_EQ(result, WIFI_HAL_OPT_OK);
|
||||
}
|
||||
|
||||
|
@ -225,6 +225,8 @@ ohos_unittest("wifi_selfcure_unittest") {
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/wifi_system_ability_listerner.cpp",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_controller/concrete_clientmode_manager.cpp",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_controller/concrete_manager_state_machine.cpp",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_controller/multi_sta_manager.cpp",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_controller/multi_sta_state_machine.cpp",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_controller/softap_manager.cpp",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_controller/softap_manager_state_machine.cpp",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_controller/wifi_controller_state_machine.cpp",
|
||||
|
@ -112,6 +112,14 @@ ohos_unittest("wifi_sta_new_unittest") {
|
||||
"//third_party/googletest:gtest_main",
|
||||
]
|
||||
|
||||
deps += [
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage:wifi_device_ability",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage:wifi_hotspot_ability",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage:wifi_scan_ability",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_native:wifi_native",
|
||||
"$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta:wifi_sta_service",
|
||||
]
|
||||
|
||||
ldflags = [
|
||||
"-fPIC",
|
||||
"--coverage",
|
||||
|
@ -61,7 +61,7 @@ int WifiServiceManager::CheckPreLoadService(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int WifiServiceManager::LoadStaService(const std::string &dlname, bool bCreate)
|
||||
int WifiServiceManager::LoadStaService(const std::string &dlname, int instId, bool bCreate)
|
||||
{
|
||||
WIFI_LOGI("LoadStaService");
|
||||
return 0;
|
||||
@ -103,7 +103,7 @@ int WifiServiceManager::LoadEnhanceService(const std::string &dlname, bool bCrea
|
||||
return 0;
|
||||
}
|
||||
|
||||
int WifiServiceManager::CheckAndEnforceService(const std::string &name, bool bCreate)
|
||||
int WifiServiceManager::CheckAndEnforceService(const std::string &name, int instId, bool bCreate)
|
||||
{
|
||||
WIFI_LOGD("WifiServiceManager::CheckAndEnforceService name: %{public}s", name.c_str());
|
||||
return 0;
|
||||
|
@ -22,7 +22,7 @@ declare_args() {
|
||||
wifi_feature_with_p2p = true
|
||||
wifi_feature_with_ap_intf = "wlan"
|
||||
wifi_feature_with_ap_num = 1
|
||||
wifi_feature_with_sta_num = 1
|
||||
wifi_feature_with_sta_num = 2
|
||||
wifi_feature_with_auth_disable = false
|
||||
wifi_feature_with_dhcp_disable = false
|
||||
wifi_feature_with_encryption = true
|
||||
|
Loading…
Reference in New Issue
Block a user