Signed-off-by: chensong <chensong60@huawei.com>
This commit is contained in:
chensong 2024-11-09 16:28:23 +08:00
parent 06c4db901b
commit d3897dd176
11 changed files with 83 additions and 15 deletions

View File

@ -190,6 +190,15 @@ public:
*/
virtual ErrCode Hid2dSetPeerWifiCfgInfo(PeerCfgType cfgType, char cfgData[CFG_DATA_MAX_BYTES],
int setDataValidLen) = 0;
/**
* @Description obtain supported frequency
*
* @param cfgType - current use freq
* @param cfgData - where use 160M Frequency
* @return int - supported frequency
*/
virtual int FreqEnhance(int freq, bool is160M) = 0;
};
} // namespace Wifi
} // namespace OHOS

View File

@ -21,6 +21,7 @@
#include "ip2p_service_callbacks.h"
#include "wifi_hid2d_msg.h"
#include "wifi_ap_msg.h"
#include "ienhance_service.h"
namespace OHOS {
namespace Wifi {
@ -340,6 +341,14 @@ public:
* @return ErrCode - operate result
*/
virtual ErrCode GetRptStationsList(std::vector<StationInfo> &result) = 0;
/**
* @Description Set EnhanceService to p2p service
*
* @param enhanceService IEnhanceService object
* @return success: WIFI_OPT_SUCCESS, failed: WIFI_OPT_FAILED
*/
virtual ErrCode SetEnhanceService(IEnhanceService* enhanceService);
};
} // namespace Wifi
} // namespace OHOS

View File

@ -385,31 +385,19 @@ bool P2pGroupOperatingState::ProcessCmdHid2dCreateGroup(const InternalMessagePtr
freq = info.first;
isFreqEnhance = (info.second == FreqType::FREQUENCY_160M);
WIFI_LOGI("Create a hid2d group, frequency: %{public}d, isFreqEnhance: %{public}d.", freq, isFreqEnhance);
void *handle;
do {
const char *so = "libwifi_enhance_interface.z.so";
int (*FreqEnhance)(int, bool);
handle = dlopen(so, RTLD_LAZY);
if ((handle == nullptr) || (!isFreqEnhance)) {
WIFI_LOGE("wifi_enhance_service:P2P enhance is empty or is FreqEnhance is false");
if (enhanceService_ == nullptr) {
WIFI_LOGE("p2p enhanceSerive_ is nullptr");
break;
}
FreqEnhance = (int(*)(int, bool))dlsym(handle, "FreqEnhance");
if (FreqEnhance == nullptr) {
WIFI_LOGE("wifi_enhance_service:Invalid method '%s' - no FreqEnhance()", so);
break;
}
freqEnhance = FreqEnhance(freq, isFreqEnhance);
freqEnhance = enhanceService_->FreqEnhance(freq, isFreqEnhance);
if (!(static_cast<unsigned int>(freqEnhance) & (static_cast<unsigned int>(P2P_ENHANCE_MASK))) &&
(static_cast<unsigned int>(freqEnhance) % static_cast<unsigned int>(BAND_MASK != 0))) {
WIFI_LOGE("FreqEnhance Error :freq = %d, freqEnhance = %d.", freq, freqEnhance);
} else {
freq = freqEnhance;
}
FreqEnhance = nullptr;
} while (0);
dlclose(handle);
handle = nullptr;
ret = WifiP2PHalInterface::GetInstance().GroupAdd(true, PERSISTENT_NET_ID, freq);
if (WifiErrorNo::WIFI_HAL_OPT_FAILED == ret) {
WIFI_LOGE("p2p configure to CreateGroup failed.");
@ -443,5 +431,11 @@ bool P2pGroupOperatingState::ExecuteStateMsg(InternalMessagePtr msg)
return NOT_EXECUTED;
}
}
void P2pGroupOperatingState::SetEnhanceService(IEnhanceService* enhanceService)
{
enhanceService_ = enhanceService;
}
} // namespace Wifi
} // namespace OHOS

View File

@ -20,6 +20,7 @@
#include "p2p_define.h"
#include "wifi_p2p_group_manager.h"
#include "wifi_p2p_device_manager.h"
#include "ienhance_service.h"
namespace OHOS {
namespace Wifi {
@ -64,6 +65,14 @@ public:
*/
virtual bool ExecuteStateMsg(InternalMessagePtr msg) override;
/**
* @Description Set EnhanceService to p2p service
*
* @param enhanceService IEnhanceService object
* @return success: WIFI_OPT_SUCCESS, failed: WIFI_OPT_FAILED
*/
virtual void SetEnhanceService(IEnhanceService* enhanceService);
private:
/**
* @Description Initialization
@ -141,6 +150,7 @@ private:
P2pStateMachine &p2pStateMachine;
WifiP2pGroupManager &groupManager;
WifiP2pDeviceManager &deviceManager;
IEnhanceService *enhanceSerive_ = nullptr;
};
} // namespace Wifi
} // namespace OHOS

View File

@ -277,5 +277,11 @@ ErrCode P2pInterface::SetGcIpAddress(const IpAddrInfo& ipInfo)
{
return p2pService.SetGcIpAddress(ipInfo);
}
ErrCode P2pInterface::SetEnhanceService(IEnhanceService* enhanceService)
{
return p2pService.SetEnhanceService(enhanceService);
}
} // namespace Wifi
} // namespace OHOS

View File

@ -353,6 +353,14 @@ public:
* @return ErrCode - operate result
*/
virtual ErrCode GetRptStationsList(std::vector<StationInfo> &result) override;
/**
* @Description Set EnhanceService to p2p service
*
* @param enhanceService IEnhanceService object
* @return success: WIFI_OPT_SUCCESS, failed: WIFI_OPT_FAILED
*/
virtual ErrCode SetEnhanceService(IEnhanceService* enhanceService) override;
private:
WifiP2pGroupManager groupManager; /* group manager */
WifiP2pDeviceManager deviceMgr; /* device manager */

View File

@ -140,6 +140,7 @@ void P2pStateMachine::Initialize()
if (pDhcpResultNotify == nullptr) {
WIFI_LOGW("pDhcpResultNotify Initialize failed.");
}
p2pGroupOperatingState.SetEnhanceService(enhanceService_);
return;
}
@ -1325,5 +1326,10 @@ bool P2pStateMachine::GetConnectedStationInfo(std::map<std::string, StationInfo>
return m_DhcpdInterface.GetConnectedStationInfo(ifaceName, result);
}
void P2pStateMachine:SetEnhanceService(IEnhanceService* enhanceService)
{
enhanceService_ = enhanceService;
}
} // namespace Wifi
} // namespace OHOS

View File

@ -465,6 +465,7 @@ private:
static DHCPTYPE m_isNeedDhcp;
std::string p2pDevIface;
static std::mutex m_gcJoinmutex;
IEnhanceService *enhanceService_ = nullptr;
public:
std::vector<std::string> curClientList;

View File

@ -60,6 +60,12 @@ ErrCode WifiP2pService::DisableP2p()
return ErrCode::WIFI_OPT_SUCCESS;
}
ErrCode WifiP2pService::SetEnhanceService(IEnhanceService* enhanceService)
{
p2pStateMachine.SetEnhanceService(enhanceService);
return ErrCode::WIFI_OPT_SUCCESS;
}
ErrCode WifiP2pService::DiscoverDevices()
{
WIFI_LOGI("DiscoverDevices");

View File

@ -23,6 +23,7 @@
#include "p2p_state_machine.h"
#include "i_wifi_p2p_iface.h"
#include "wifi_error_no.h"
#include "ienhance_service.h"
namespace OHOS {
namespace Wifi {
@ -330,6 +331,14 @@ private:
*/
virtual void ClearAllP2pServiceCallbacks();
/**
* @Description Set EnhanceService to p2p service
*
* @param enhanceService IEnhanceService object
* @return success: WIFI_OPT_SUCCESS, failed: WIFI_OPT_FAILED
*/
virtual ErrCode SetEnhanceService(IEnhanceService* enhanceService) override;
private:
P2pStateMachine &p2pStateMachine;
WifiP2pDeviceManager &deviceManager; /* device manager */

View File

@ -99,6 +99,16 @@ ErrCode WifiP2pManager::AutoStartP2pService()
WIFI_LOGE("service EnableP2p failed, ret %{public}d!", static_cast<int>(ret));
break;
}
IEnhanceService *pEnhanceService = WifiServiceManager::GetInstance().GetEnhanceServiceInst();
if (pEnhanceService == nullptr) {
WIFI_LOGE("Create %{public}s service failed!", WIFI_SERVICE_ENHANCE);
break;
}
ret = pService->SetEnhanceService(pEnhanceService);
if (errCode != WIFI_OPT_SUCCESS) {
WIFI_LOGE("SetEnhanceService failed, ret %{public}d!", static_cast<int>(ret));
break;
}
} while (false);
if (ret != WIFI_OPT_SUCCESS) {
WifiConfigCenter::GetInstance().SetP2pMidState(WifiOprMidState::OPENING, WifiOprMidState::CLOSED);