mirror of
https://gitee.com/openharmony/communication_wifi.git
synced 2024-12-19 21:07:25 +00:00
add scan controller for hml
Signed-off-by: guoyuan <guoyuan28@huawei.com>
This commit is contained in:
parent
b891ed4021
commit
adde6e09ee
@ -1251,7 +1251,7 @@ ErrCode WifiP2pServiceImpl::Hid2dSetUpperScene(const std::string& ifName, const
|
||||
WIFI_LOGE("Get P2P service failed!");
|
||||
return WIFI_OPT_P2P_NOT_OPENED;
|
||||
}
|
||||
WifiSettings::GetInstance().SetHid2dUpperScene(scene);
|
||||
WifiSettings::GetInstance().SetHid2dUpperScene(ifName, scene);
|
||||
return pService->Hid2dSetUpperScene(ifName, scene);
|
||||
}
|
||||
|
||||
|
@ -2511,10 +2511,11 @@ bool ScanService::AllowScanByMovingFreeze()
|
||||
bool ScanService::AllowScanByHid2dState()
|
||||
{
|
||||
LOGD("Enter ScanService::AllowScanByHid2dState.\n");
|
||||
std::string ifName;
|
||||
Hid2dUpperScene scene;
|
||||
P2pBusinessType type;
|
||||
WifiP2pLinkedInfo linkedInfo;
|
||||
WifiSettings::GetInstance().GetHid2dUpperScene(scene);
|
||||
WifiSettings::GetInstance().GetHid2dUpperScene(ifName, scene);
|
||||
WifiSettings::GetInstance().GetP2pBusinessType(type);
|
||||
WifiSettings::GetInstance().GetP2pInfo(linkedInfo);
|
||||
|
||||
@ -2522,14 +2523,25 @@ bool ScanService::AllowScanByHid2dState()
|
||||
WIFI_LOGI("ScanService::AllowScanByHid2dState, no need to control this scan");
|
||||
return true;
|
||||
}
|
||||
if (linkedInfo.GetConnectState() == P2pConnectedState::P2P_DISCONNECTED) {
|
||||
if (strstr(ifName.c_str(), "chba")) {
|
||||
if ((scene.scene & 0x07) > 0) {
|
||||
WIFI_LOGW("Scan is not allowed in hml.");
|
||||
return false;
|
||||
} else {
|
||||
WIFI_LOGW("allow scan, and clear ifname.");
|
||||
WifiSettings::GetInstance().SetHid2dUpperScene("", scene);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
// scene bit 0-2 is valid, 0x01: video, 0x02: audio, 0x04: file,
|
||||
// scene & 0x07 > 0 means one of them takes effect.
|
||||
if (((scene.scene & 0x07) > 0) && type == P2pBusinessType::P2P_TYPE_HID2D) {
|
||||
WIFI_LOGW("Scan is not allowed in hid2d business.");
|
||||
return false;
|
||||
} else {
|
||||
if (linkedInfo.GetConnectState() == P2pConnectedState::P2P_DISCONNECTED) {
|
||||
return true;
|
||||
}
|
||||
// scene bit 0-2 is valid, 0x01: video, 0x02: audio, 0x04: file,
|
||||
// scene & 0x07 > 0 means one of them takes effect.
|
||||
if (((scene.scene & 0x07) > 0) && type == P2pBusinessType::P2P_TYPE_HID2D) {
|
||||
WIFI_LOGW("Scan is not allowed in hid2d business.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1369,17 +1369,20 @@ int WifiSettings::GetP2pConnectedState()
|
||||
return mP2pConnectState.load();
|
||||
}
|
||||
|
||||
int WifiSettings::SetHid2dUpperScene(const Hid2dUpperScene &scene)
|
||||
int WifiSettings::SetHid2dUpperScene(const std::string& ifName, const Hid2dUpperScene &scene)
|
||||
{
|
||||
LOGD("SetHid2dUpperScene ifName: %{public}s", ifName.c_str());
|
||||
std::unique_lock<std::mutex> lock(mP2pMutex);
|
||||
mUpperIfName = ifName;
|
||||
mUpperScene = scene;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int WifiSettings::GetHid2dUpperScene(Hid2dUpperScene &scene)
|
||||
int WifiSettings::GetHid2dUpperScene(std::string& ifName, Hid2dUpperScene &scene)
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(mP2pMutex);
|
||||
scene = mUpperScene;
|
||||
ifName = mUpperIfName;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1400,10 +1403,14 @@ int WifiSettings::GetP2pBusinessType(P2pBusinessType &type)
|
||||
void WifiSettings::ClearLocalHid2dInfo()
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(mP2pMutex);
|
||||
mUpperScene.mac = "";
|
||||
mUpperScene.scene = 0;
|
||||
mUpperScene.fps = 0;
|
||||
mUpperScene.bw = 0;
|
||||
if (strstr(mUpperIfName.c_str(), "chba") == NULL) {
|
||||
mUpperScene.mac = "";
|
||||
mUpperScene.scene = 0;
|
||||
mUpperScene.fps = 0;
|
||||
mUpperScene.bw = 0;
|
||||
mUpperIfName = "";
|
||||
}
|
||||
|
||||
mP2pBusinessType = P2pBusinessType::INVALID;
|
||||
}
|
||||
|
||||
|
@ -790,7 +790,7 @@ public:
|
||||
* @param state - the hid2d upper scene
|
||||
* @return int - 0 success
|
||||
*/
|
||||
int SetHid2dUpperScene(const Hid2dUpperScene &scene);
|
||||
int SetHid2dUpperScene(const std::string& ifName, const Hid2dUpperScene &scene);
|
||||
|
||||
/**
|
||||
* @Description Get the hid2d upper scene
|
||||
@ -798,7 +798,7 @@ public:
|
||||
* @param state - the hid2d upper scene
|
||||
* @return int - 0 success
|
||||
*/
|
||||
int GetHid2dUpperScene(Hid2dUpperScene &scene);
|
||||
int GetHid2dUpperScene(std::string& ifName, Hid2dUpperScene &scene);
|
||||
|
||||
/**
|
||||
* @Description Set p2p type
|
||||
@ -1655,6 +1655,7 @@ private:
|
||||
std::map<int, PowerModel> powerModel;
|
||||
int mHotspotIdleTimeout;
|
||||
std::map <int, DisconnectedReason> mLastDiscReason;
|
||||
std::string mUpperIfName;
|
||||
Hid2dUpperScene mUpperScene;
|
||||
P2pBusinessType mP2pBusinessType;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user