From dd9b1411e85328afaa588ee0c5f300a82c2976eb Mon Sep 17 00:00:00 2001 From: huxiaominlenho Date: Fri, 26 May 2023 03:04:36 +0000 Subject: [PATCH] update wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/scan_service.cpp. Signed-off-by: huxiaominlenho --- wifi/bundle.json | 3 +- wifi/frameworks/native/interfaces/define.h | 2 +- .../wifi_manage/ienhance_service.h | 52 ++++++++++++++ .../wifi_manage/wifi_manager.cpp | 34 +++++++++ .../wifi_framework/wifi_manage/wifi_manager.h | 1 + .../wifi_manage/wifi_scan/BUILD.gn | 7 -- .../wifi_manage/wifi_scan/iscan_service.h | 8 +++ .../wifi_manage/wifi_scan/scan_interface.cpp | 8 +++ .../wifi_manage/wifi_scan/scan_interface.h | 8 ++- .../wifi_manage/wifi_scan/scan_service.cpp | 61 +++++----------- .../wifi_manage/wifi_scan/scan_service.h | 17 ++--- .../wifi_manage/wifi_service_manager.cpp | 69 +++++++++++++++++++ .../wifi_manage/wifi_service_manager.h | 31 ++++++++- .../config/wifi_config_file_spec.cpp | 2 + .../wifi_toolkit/config/wifi_settings.cpp | 2 + .../wifi_toolkit/include/wifi_internal_msg.h | 1 + wifi/wifi.gni | 1 - wifi/wifi_lite.gni | 1 - 18 files changed, 239 insertions(+), 69 deletions(-) create mode 100644 wifi/services/wifi_standard/wifi_framework/wifi_manage/ienhance_service.h diff --git a/wifi/bundle.json b/wifi/bundle.json index f0d34d6fe..c5411b742 100644 --- a/wifi/bundle.json +++ b/wifi/bundle.json @@ -56,8 +56,7 @@ "wifi_feature_with_app_frozen", "wifi_feature_non_seperate_p2p", "wifi_feature_non_hdf_driver", - "wifi_feature_is_random_mac_supported", - "wifi_feature_with_sched_scan_control_enable" + "wifi_feature_is_random_mac_supported" ], "adapted_system_type": [ "standard" diff --git a/wifi/frameworks/native/interfaces/define.h b/wifi/frameworks/native/interfaces/define.h index 0701055d3..5c5526c80 100644 --- a/wifi/frameworks/native/interfaces/define.h +++ b/wifi/frameworks/native/interfaces/define.h @@ -205,7 +205,7 @@ #define WIFI_SERVICE_P2P "P2pService" /* P2P */ #define WIFI_SERVICE_SCAN "ScanService" /* SCAN */ #define WIFI_SERVICE_AWARE "AwareService" /* AWARE */ - +#define WIFI_SERVICE_ENHANCE "EnhanceService" /* ENHANCE */ /* ---------Feature service ability id */ #ifdef OHOS_ARCH_LITE #define WIFI_DEVICE_ABILITY_ID 1120 diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/ienhance_service.h b/wifi/services/wifi_standard/wifi_framework/wifi_manage/ienhance_service.h new file mode 100644 index 000000000..c043d9b39 --- /dev/null +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/ienhance_service.h @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2023 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_IENHANCE_SERVICE_H +#define OHOS_IENHANCE_SERVICE_H + +#include "wifi_errcode.h" + +namespace OHOS { +namespace Wifi { +class IEnhanceService { +public: + virtual ~IEnhanceService() = default; + /** + * @Description Enhance service initialization function. + * + * @return success: WIFI_OPT_SUCCESS, failed: WIFI_OPT_FAILED + */ + virtual ErrCode Init() = 0; + /** + * @Description Stopping the Enhance Service. + * + * @return success: WIFI_OPT_SUCCESS, failed: WIFI_OPT_FAILED + */ + virtual ErrCode UnInit() = 0; + /** + * @Description check Scan is allowed. + * + * @return true: allowed, false: not allowed + */ + virtual bool AllowScanBySchedStrategy() = 0; + /** + * @Description Set EnhanceService Param. + * + * @return success: WIFI_OPT_SUCCESS, failed: WIFI_OPT_FAILED + */ + virtual ErrCode SetEnhanceParam(int64_t availableTime) = 0; +}; +} // namespace Wifi +} // namespace OHOS +#endif \ No newline at end of file diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_manager.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_manager.cpp index 3e51ef36a..7cab97fc4 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_manager.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_manager.cpp @@ -288,6 +288,7 @@ int WifiManager::Init() * The sta service automatically starts upon startup. After the sta * service is started, the scanning is directly started. */ + AutoStartEnhanceService(); AutoStartScanService(); } @@ -629,6 +630,16 @@ void WifiManager::CheckAndStartScanService(void) WIFI_LOGE("init scan service failed, ret %{public}d!", static_cast(errCode)); break; } + IEnhanceService *pEnhanceService = WifiServiceManager::GetInstance().GetEnhanceServiceInst(); + if (pEnhanceService == nullptr) { + WIFI_LOGE("Create %{public}s service failed!", WIFI_SERVICE_ENHANCE); + break; + } + errCode = pService->SetEnhanceService(pEnhanceService); + if (errCode != WIFI_OPT_SUCCESS) { + WIFI_LOGE("SetEnhanceService failed, ret %{public}d!", static_cast(errCode)); + break; + } } while (0); if (errCode != WIFI_OPT_SUCCESS) { WifiConfigCenter::GetInstance().SetScanMidState(WifiOprMidState::OPENING, WifiOprMidState::CLOSED); @@ -637,6 +648,29 @@ void WifiManager::CheckAndStartScanService(void) return; } +void WifiManager::AutoStartEnhanceService(void) +{ + WIFI_LOGI("AutoStartEnhanceService start"); + ErrCode errCode = WIFI_OPT_FAILED; + do { + if (WifiServiceManager::GetInstance().CheckAndEnforceService(WIFI_SERVICE_ENHANCE) < 0) { + WIFI_LOGE("Load %{public}s service failed!", WIFI_SERVICE_ENHANCE); + break; + } + IEnhanceService *pEnhanceService = WifiServiceManager::GetInstance().GetEnhanceServiceInst(); + if (pEnhanceService == nullptr) { + WIFI_LOGE("Create %{public}s service failed!", WIFI_SERVICE_ENHANCE); + break; + } + errCode = pEnhanceService->Init(); + if (errCode != WIFI_OPT_SUCCESS) { + WIFI_LOGE("init Enhance service failed, ret %{public}d!", static_cast(errCode)); + break; + } + } while (0); + return; +} + void WifiManager::CheckAndStopScanService(void) { /** diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_manager.h b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_manager.h index dae7034a7..70b1f11b7 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_manager.h +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_manager.h @@ -207,6 +207,7 @@ private: static void AutoStartP2pService(void); #endif static void AutoStartScanService(void); + static void AutoStartEnhanceService(void); static void CheckAndStartSta(void); static void AutoStartServiceThread(void); diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/BUILD.gn b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/BUILD.gn index 11aa6f060..3d8eaefdf 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/BUILD.gn +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/BUILD.gn @@ -111,13 +111,6 @@ if (defined(ohos_lite)) { "hiviewdfx_hilog_native:libhilog", ] - defines = [] - if (wifi_feature_with_sched_scan_control_enable) { - include_dirs += [ "//foundation/resourceschedule/efficiency_manager/interfaces/innerkits/component_scheduler/client/include" ] - external_deps += [ "efficiency_manager:component_sched_client" ] - defines += [ "WIFI_SCHED_SCAN_CONTROL_ENALE" ] - } - cflags_cc = [ "-std=c++17", "-fno-rtti", diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/iscan_service.h b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/iscan_service.h index e4471b265..1b0d62d2d 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/iscan_service.h +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/iscan_service.h @@ -18,6 +18,7 @@ #include "wifi_errcode.h" #include "wifi_msg.h" #include "iscan_service_callbacks.h" +#include "ienhance_service.h" namespace OHOS { namespace Wifi { @@ -112,6 +113,13 @@ public: * @return success: WIFI_OPT_SUCCESS, failed: WIFI_OPT_FAILED */ virtual ErrCode RegisterScanCallbacks(const IScanSerivceCallbacks &scanSerivceCallbacks) = 0; + /** + * @Description Set EnhanceService to Scan Service. + * + * @param enhanceService IEnhanceService object + * @return success: WIFI_OPT_SUCCESS, failed: WIFI_OPT_FAILED + */ + virtual ErrCode SetEnhanceService(IEnhanceService *enhanceService) = 0; }; } // namespace Wifi } // namespace OHOS diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/scan_interface.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/scan_interface.cpp index addf90c44..4910fee50 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/scan_interface.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/scan_interface.cpp @@ -162,5 +162,13 @@ ErrCode ScanInterface::RegisterScanCallbacks(const IScanSerivceCallbacks &scanSe mScanSerivceCallbacks = scanSerivceCallbacks; return WIFI_OPT_SUCCESS; } + +ErrCode ScanInterface::SetEnhanceService(IEnhanceService *enhanceService) +{ + WIFI_LOGI("Enter ScanInterface::SetEnhanceService\n"); + CHECK_NULL_AND_RETURN(pScanService, WIFI_OPT_FAILED); + pScanService->SetEnhanceService(enhanceService); + return WIFI_OPT_SUCCESS; +} } // namespace Wifi } // namespace OHOS \ No newline at end of file diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/scan_interface.h b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/scan_interface.h index 5063ded14..a9952f79b 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/scan_interface.h +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/scan_interface.h @@ -117,7 +117,13 @@ public: * @return success: WIFI_OPT_SUCCESS, failed: WIFI_OPT_FAILED */ ErrCode RegisterScanCallbacks(const IScanSerivceCallbacks &scanSerivceCallbacks); - + /** + * @Description Set EnhanceService to Scan Service. + * + * @param enhanceService IEnhanceService object + * @return success: WIFI_OPT_SUCCESS, failed: WIFI_OPT_FAILED + */ + ErrCode SetEnhanceService(IEnhanceService* enhanceService); private: ScanService *pScanService; IScanSerivceCallbacks mScanSerivceCallbacks; 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 27393f75e..409ecd7c3 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 @@ -49,8 +49,7 @@ ScanService::ScanService() scanTrustMode(false), isAbsFreezeState(false), isAbsFreezeScaned(false), - scanResultBackup(-1), - lastScanResultsAvailableTime(0) + scanResultBackup(-1) {} ScanService::~ScanService() @@ -163,6 +162,11 @@ void ScanService::RegisterScanCallbacks(const IScanSerivceCallbacks &iScanSerivc mScanSerivceCallbacks = iScanSerivceCallbacks; } +void ScanService::SetEnhanceService(IEnhanceService* enhanceService) +{ + mEnhanceService = enhanceService; +} + void ScanService::HandleScanStatusReport(ScanStatusReport &scanStatusReport) { WIFI_LOGI("Enter ScanService::HandleScanStatusReport.\n"); @@ -601,8 +605,11 @@ void ScanService::HandleCommonScanInfo( } struct timespec times = {0, 0}; clock_gettime(CLOCK_MONOTONIC, ×); - lastScanResultsAvailableTime = static_cast(times.tv_sec) * SECOND_TO_MICRO_SECOND + + int64_t availableTime = static_cast(times.tv_sec) * SECOND_TO_MICRO_SECOND + times.tv_nsec / SECOND_TO_MILLI_SECOND; + if (mEnhanceService != nullptr) { + mEnhanceService->SetEnhanceParam(availableTime); + } /* Send the scanning result to the module registered for listening. */ ScanInfoHandlerMap::iterator handleIter = scanInfoHandlerMap.begin(); for (; handleIter != scanInfoHandlerMap.end(); ++handleIter) { @@ -1183,10 +1190,13 @@ ErrCode ScanService::AllowExternScan() WIFI_LOGW("extern scan not allow by disable scan control."); return WIFI_OPT_FAILED; } - if (!AllowScanBySchedStrategy()) { - WIFI_LOGW("extern scan not allow by sched strategy."); - return WIFI_OPT_FAILED; + if (mEnhanceService != nullptr) { + if (!mEnhanceService->AllowScanBySchedStrategy()) { + WIFI_LOGW("extern scan not allow by sched strategy."); + return WIFI_OPT_FAILED; + } } + WIFI_LOGI("extern scan has allowed"); return WIFI_OPT_SUCCESS; } @@ -2247,45 +2257,6 @@ bool ScanService::AllowScanByDisableScanCtrl() return !disableScanFlag; } -bool ScanService::AllowScanBySchedStrategy() -{ - WIFI_LOGI("Enter ScanService::AllowScanBySchedStrategy."); -#ifdef WIFI_SCHED_SCAN_CONTROL_ENALE - sptr strategy = nullptr; - int ret = OHOS::ComponentScheduler::ComponentSchedClient::GetInstance().GetScanStrategy(GetBundleName(), - GetCallingUid(), ComponentScheduler::ScanStrategy::ScanType::SCAN_TYPE_WIFI, strategy); - if (ret != 0 || strategy == nullptr) { - WIFI_LOGW("GetScanStrategy fail: %{public}d.", ret); - return true; - } - - WIFI_LOGI("GetScanStrategy return mode: %{public}d.", strategy->GetMode()); - if (strategy->GetMode() == 0) { - return true; - } - - if (strategy->GetMode() < 0) { - WIFI_LOGE("ComponentSchedClient don't allow scan."); - return false; - } - - if (strategy->GetTimeStamp() < lastScanResultsAvailableTime) { - struct timespec times = {0, 0}; - clock_gettime(CLOCK_MONOTONIC, ×); - int64_t currTime = - static_cast(times.tv_sec) * SECOND_TO_MICRO_SECOND + times.tv_nsec / SECOND_TO_MILLI_SECOND; - int64_t sinceLastScanTime = currTime - lastScanResultsAvailableTime; - if (sinceLastScanTime > strategy->GetMode()) { - return true; - } - WIFI_LOGE("sinceLastScanTime:%{public}llu is less than GetMode:%{public}d, don't allow scan.", - sinceLastScanTime, strategy->GetMode()); - return false; - } -#endif - return true; -} - bool ScanService::AllowScanByMovingFreeze() { LOGI("Enter ScanService::AllowScanByMovingFreeze.\n"); diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/scan_service.h b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/scan_service.h index 126330a8f..6871c5c90 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/scan_service.h +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/scan_service.h @@ -30,6 +30,7 @@ #include "scan_monitor.h" #include "scan_state_machine.h" #include "scan_standby_listerner.h" +#include "ienhance_service.h" namespace OHOS { namespace Wifi { @@ -229,7 +230,13 @@ public: * */ virtual void SetStaCurrentTime(); - + /** + * @Description Set EnhanceService to Scan Service. + * + * @param enhanceService IEnhanceService object + * @return void + */ + virtual void SetEnhanceService(IEnhanceService* enhanceService); private: using ScanConfigMap = std::map; using ScanInfoHandlerMap = std::map; @@ -281,7 +288,7 @@ private: bool isAbsFreezeState; /* absolute freeze state. */ bool isAbsFreezeScaned; /* scanned in freeze state. */ int scanResultBackup; /* scan result backup. */ - int64_t lastScanResultsAvailableTime; /* scan results available time */ + IEnhanceService *mEnhanceService; /* EnhanceService handle */ #ifndef OHOS_ARCH_LITE StandByListerner standByListerner; /* standby Listerner*/ #endif @@ -755,12 +762,6 @@ private: * @return true: allow, false: not allowed. */ bool AllowScanByDisableScanCtrl(); - /** - * @Description Determines whether scanning is allowed by sched strategy scan control. - * - * @return true: allow, false: not allowed. - */ - bool AllowScanBySchedStrategy(); /** * @Description Determines whether scanning is allowed in movingfreeze mode. * diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_service_manager.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_service_manager.cpp index 9274c30e8..b79629d04 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_service_manager.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_service_manager.cpp @@ -45,9 +45,11 @@ int WifiServiceManager::Init() #endif mStaServiceHandle.Clear(); mScanServiceHandle.Clear(); + mEnhanceServiceHandle.Clear(); #ifdef OHOS_ARCH_LITE mServiceDllMap.insert(std::make_pair(WIFI_SERVICE_STA, "libwifi_sta_service.so")); mServiceDllMap.insert(std::make_pair(WIFI_SERVICE_SCAN, "libwifi_scan_service.so")); + mServiceDllMap.insert(std::make_pair(WIFI_SERVICE_ENHANCE, "libwifi_enhance_service.z.so")); #ifdef FEATURE_AP_SUPPORT mServiceDllMap.insert(std::make_pair(WIFI_SERVICE_AP, "libwifi_ap_service.so")); #endif @@ -58,6 +60,7 @@ int WifiServiceManager::Init() #else mServiceDllMap.insert(std::make_pair(WIFI_SERVICE_STA, "libwifi_sta_service.z.so")); mServiceDllMap.insert(std::make_pair(WIFI_SERVICE_SCAN, "libwifi_scan_service.z.so")); + mServiceDllMap.insert(std::make_pair(WIFI_SERVICE_ENHANCE, "libwifi_enhance_service.z.so")); #ifdef FEATURE_AP_SUPPORT mServiceDllMap.insert(std::make_pair(WIFI_SERVICE_AP, "libwifi_ap_service.z.so")); #endif @@ -209,6 +212,33 @@ int WifiServiceManager::LoadP2pService(const std::string &dlname, bool bCreate) } #endif +int WifiServiceManager::LoadEnhanceService(const std::string &dlname, bool bCreate) +{ + WIFI_LOGI("WifiServiceManager::LoadEnhanceService"); + std::unique_lock lock(mEnhanceMutex); + if (mEnhanceServiceHandle.handle != nullptr) { + WIFI_LOGE("WifiServiceManager::handle is not null: %{public}s", dlname.c_str()); + return 0; + } + mEnhanceServiceHandle.handle = dlopen(dlname.c_str(), RTLD_LAZY); + if (mEnhanceServiceHandle.handle == nullptr) { + WIFI_LOGE("dlopen %{public}s failed: %{public}s!", dlname.c_str(), dlerror()); + return -1; + } + mEnhanceServiceHandle.create = (IEnhanceService *(*)()) dlsym(mEnhanceServiceHandle.handle, "Create"); + mEnhanceServiceHandle.destroy = (void *(*)(IEnhanceService *))dlsym(mEnhanceServiceHandle.handle, "Destroy"); + if (mEnhanceServiceHandle.create == nullptr || mEnhanceServiceHandle.destroy == nullptr) { + WIFI_LOGE("%{public}s dlsym Create or Destroy failed!", dlname.c_str()); + dlclose(mEnhanceServiceHandle.handle); + mEnhanceServiceHandle.Clear(); + return -1; + } + if (bCreate) { + mEnhanceServiceHandle.pService = mEnhanceServiceHandle.create(); + } + return 0; +} + int WifiServiceManager::CheckAndEnforceService(const std::string &name, bool bCreate) { WIFI_LOGD("WifiServiceManager::CheckAndEnforceService name: %{public}s", name.c_str()); @@ -234,6 +264,9 @@ int WifiServiceManager::CheckAndEnforceService(const std::string &name, bool bCr return LoadP2pService(dlname, bCreate); } #endif + if (name == WIFI_SERVICE_ENHANCE) { + return LoadEnhanceService(dlname, bCreate); + } return -1; } @@ -308,6 +341,20 @@ IP2pService *WifiServiceManager::GetP2pServiceInst() } #endif +IEnhanceService *WifiServiceManager::GetEnhanceServiceInst() +{ + WIFI_LOGI("WifiServiceManager::GetEnhanceServiceInst"); + std::unique_lock lock(mEnhanceMutex); + if (mEnhanceServiceHandle.handle == nullptr) { + WIFI_LOGE("WifiServiceManager, Enhance handle is null"); + return nullptr; + } + if (mEnhanceServiceHandle.pService == nullptr) { + mEnhanceServiceHandle.pService = mEnhanceServiceHandle.create(); + } + return mEnhanceServiceHandle.pService; +} + NO_SANITIZE("cfi") int WifiServiceManager::UnloadStaService(bool bPreLoad) { WIFI_LOGI("WifiServiceManager::UnloadStaService"); @@ -403,6 +450,25 @@ NO_SANITIZE("cfi") int WifiServiceManager::UnloadP2pService(bool bPreLoad) } #endif +NO_SANITIZE("cfi") int WifiServiceManager::UnloadEnhanceService(bool bPreLoad) +{ + WIFI_LOGI("WifiServiceManager::UnloadEnhanceService"); + std::unique_lock lock(mEnhanceMutex); + if (mEnhanceServiceHandle.handle == nullptr) { + WIFI_LOGE("WifiServiceManager::UnloadEnhanceService handle is null"); + return 0; + } + if (mEnhanceServiceHandle.pService != nullptr) { + mEnhanceServiceHandle.destroy(mEnhanceServiceHandle.pService); + mEnhanceServiceHandle.pService = nullptr; + } + if (!bPreLoad) { + dlclose(mEnhanceServiceHandle.handle); + mEnhanceServiceHandle.Clear(); + } + return 0; +} + int WifiServiceManager::UnloadService(const std::string &name, int id) { bool bPreLoad = WifiSettings::GetInstance().IsModulePreLoad(name); @@ -423,6 +489,9 @@ int WifiServiceManager::UnloadService(const std::string &name, int id) return UnloadP2pService(bPreLoad); } #endif + if (name == WIFI_SERVICE_ENHANCE) { + return UnloadEnhanceService(bPreLoad); + } return -1; } diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_service_manager.h b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_service_manager.h index 6f59df00b..0b3f3d915 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_service_manager.h +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_service_manager.h @@ -28,6 +28,7 @@ #ifdef FEATURE_P2P_SUPPORT #include "ip2p_service.h" #endif +#include "ienhance_service.h" namespace OHOS { namespace Wifi { @@ -107,7 +108,23 @@ struct P2pServiceHandle { } }; #endif - +struct EnhanceServiceHandle { + void *handle; + IEnhanceService *(*create)(); + void *(*destroy)(IEnhanceService *); + IEnhanceService *pService; + EnhanceServiceHandle() : handle(nullptr), create(nullptr), destroy(nullptr), pService(nullptr) + {} + ~EnhanceServiceHandle() + {} + void Clear() + { + handle = nullptr; + create = nullptr; + destroy = nullptr; + pService = nullptr; + } +}; class WifiServiceManager { public: WifiServiceManager(); @@ -167,7 +184,12 @@ public: */ IP2pService *GetP2pServiceInst(void); #endif - + /** + * @Description Get the Enhance Service Inst object + * + * @return IEnhanceService* - Enhance service pointer, if Enhance not supported, nullptr is returned + */ + IEnhanceService *GetEnhanceServiceInst(void); /** * @Description unload a feature service * @@ -197,12 +219,14 @@ private: int LoadP2pService(const std::string &dlname, bool bCreate); int UnloadP2pService(bool bPreLoad); #endif - + int LoadEnhanceService(const std::string &dlname, bool bCreate); + int UnloadEnhanceService(bool bPreLoad); private: std::mutex mStaMutex; std::mutex mScanMutex; std::mutex mP2pMutex; std::mutex mApMutex; + std::mutex mEnhanceMutex; std::unordered_map mServiceDllMap; StaServiceHandle mStaServiceHandle; ScanServiceHandle mScanServiceHandle; @@ -212,6 +236,7 @@ private: #ifdef FEATURE_P2P_SUPPORT P2pServiceHandle mP2pServiceHandle; #endif + EnhanceServiceHandle mEnhanceServiceHandle; }; } // namespace Wifi } // namespace OHOS diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_toolkit/config/wifi_config_file_spec.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_toolkit/config/wifi_config_file_spec.cpp index a710d5527..a755d02c3 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_toolkit/config/wifi_config_file_spec.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_toolkit/config/wifi_config_file_spec.cpp @@ -867,6 +867,8 @@ static int SetWifiConfigValueSecond(WifiConfig &item, const std::string &key, co item.preLoadP2p = (std::stoi(value) != 0); /* 0 -> false 1 -> true */ } else if (key == "preLoadAware") { item.preLoadAware = (std::stoi(value) != 0); /* 0 -> false 1 -> true */ + } else if (key == "preLoadEnhance") { + item.preLoadEnhance = (std::stoi(value) != 0); /* 0 -> false 1 -> true */ } else if (key == "supportHwPnoFlag") { item.supportHwPnoFlag = std::stoi(value); } else if (key == "minRssi2Dot4Ghz") { 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 0bb8b87c5..87eda9e64 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 @@ -1485,6 +1485,8 @@ bool WifiSettings::IsModulePreLoad(const std::string &name) return mWifiConfig.preLoadP2p; } else if (name == WIFI_SERVICE_AWARE) { return mWifiConfig.preLoadAware; + } else if (name == WIFI_SERVICE_ENHANCE) { + return mWifiConfig.preLoadEnhance; } else { return false; } diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_toolkit/include/wifi_internal_msg.h b/wifi/services/wifi_standard/wifi_framework/wifi_toolkit/include/wifi_internal_msg.h index 396981f1e..9900923b9 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_toolkit/include/wifi_internal_msg.h +++ b/wifi/services/wifi_standard/wifi_framework/wifi_toolkit/include/wifi_internal_msg.h @@ -311,6 +311,7 @@ struct WifiConfig { bool preLoadAp; bool preLoadP2p; bool preLoadAware; + bool preLoadEnhance; bool supportHwPnoFlag; int minRssi2Dot4Ghz; int minRssi5Ghz; diff --git a/wifi/wifi.gni b/wifi/wifi.gni index 54d9d7ee4..e5a2c3e06 100644 --- a/wifi/wifi.gni +++ b/wifi/wifi.gni @@ -29,7 +29,6 @@ declare_args() { wifi_feature_non_seperate_p2p = false wifi_feature_non_hdf_driver = false wifi_feature_is_random_mac_supported = false - wifi_feature_with_sched_scan_control_enable = false if (defined(global_parts_info) && defined(global_parts_info.resourceschedule_efficiency_manager)) { wifi_feature_with_app_frozen = true diff --git a/wifi/wifi_lite.gni b/wifi/wifi_lite.gni index 55ffecec4..0a09f7857 100644 --- a/wifi/wifi_lite.gni +++ b/wifi/wifi_lite.gni @@ -26,5 +26,4 @@ declare_args() { wifi_feature_with_auth_disable = false wifi_feature_with_dhcp_disable = false wifi_feature_is_hdi_supported = false - wifi_feature_with_sched_scan_control_enable = false }