diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p_service_impl.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p_service_impl.cpp index 4c036e2cd..55c4ea93c 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p_service_impl.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p_service_impl.cpp @@ -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); } diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/scan_service.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/scan_service.cpp index ffe082434..23ce4580e 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/scan_service.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/scan_service.cpp @@ -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; } diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_toolkit/config/wifi_settings.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_toolkit/config/wifi_settings.cpp index 4602eead8..8ca6bddfd 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_toolkit/config/wifi_settings.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_toolkit/config/wifi_settings.cpp @@ -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 lock(mP2pMutex); + mUpperIfName = ifName; mUpperScene = scene; return 0; } -int WifiSettings::GetHid2dUpperScene(Hid2dUpperScene &scene) +int WifiSettings::GetHid2dUpperScene(std::string& ifName, Hid2dUpperScene &scene) { std::unique_lock lock(mP2pMutex); scene = mUpperScene; + ifName = mUpperIfName; return 0; } @@ -1400,10 +1403,14 @@ int WifiSettings::GetP2pBusinessType(P2pBusinessType &type) void WifiSettings::ClearLocalHid2dInfo() { std::unique_lock 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; } diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_toolkit/config/wifi_settings.h b/wifi/services/wifi_standard/wifi_framework/wifi_toolkit/config/wifi_settings.h index 4e3df6844..dcbdb495e 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_toolkit/config/wifi_settings.h +++ b/wifi/services/wifi_standard/wifi_framework/wifi_toolkit/config/wifi_settings.h @@ -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 powerModel; int mHotspotIdleTimeout; std::map mLastDiscReason; + std::string mUpperIfName; Hid2dUpperScene mUpperScene; P2pBusinessType mP2pBusinessType;