From 499355e13855f86b194ab66b53841e169c766d0c Mon Sep 17 00:00:00 2001 From: 17333770736 Date: Mon, 26 Aug 2024 17:08:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=8F=E6=84=9F=E4=BF=A1=E6=81=AF=E6=89=93?= =?UTF-8?q?=E5=8D=B0+=E5=8F=98=E9=87=8F=E4=B8=8A=E9=94=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 17333770736 --- common/src/distributed_sched_utils.cpp | 29 ++++++++++--------- .../include/softbus_adapter/softbus_adapter.h | 1 + .../dsched_all_connect_manager.cpp | 6 ++-- .../src/softbus_adapter/softbus_adapter.cpp | 10 +++++-- 4 files changed, 28 insertions(+), 18 deletions(-) diff --git a/common/src/distributed_sched_utils.cpp b/common/src/distributed_sched_utils.cpp index ca4e309e..14bcfe88 100644 --- a/common/src/distributed_sched_utils.cpp +++ b/common/src/distributed_sched_utils.cpp @@ -71,7 +71,7 @@ bool IsValidPath(const std::string &inFilePath, std::string &realFilePath) char path[PATH_MAX + 1] = { 0 }; if (inFilePath.empty() || inFilePath.length() > PATH_MAX || inFilePath.length() + 1 > MAX_CONFIG_PATH_LEN || realpath(inFilePath.c_str(), path) == nullptr) { - HILOGE("Get continue config file real path fail, inFilePath %{public}s.", inFilePath.c_str()); + HILOGE("Get continue config file real path fail, inFilePath %{public}s.", GetAnonymStr(inFilePath).c_str()); return false; } @@ -81,11 +81,11 @@ bool IsValidPath(const std::string &inFilePath, std::string &realFilePath) return false; } if (!std::filesystem::exists(realFilePath)) { - HILOGE("The real file path %{public}s does not exist in the file system.", realFilePath.c_str()); + HILOGE("The real file path %{public}s does not exist in the file system.", GetAnonymStr(realFilePath).c_str()); realFilePath = ""; return false; } - HILOGI("The real file path %{public}s exist in the file system.", realFilePath.c_str()); + HILOGI("The real file path %{public}s exist in the file system.", GetAnonymStr(realFilePath).c_str()); return true; } @@ -132,37 +132,38 @@ bool UpdateAllowAppList(const std::string &cfgJsonStr) int32_t LoadContinueConfig() { HILOGI("Load continue config, isMissContinueCfg %{public}d, ContinueCfgFullPath %{public}s.", - g_isMissContinueCfg.load(), g_continueCfgFullPath.c_str()); + g_isMissContinueCfg.load(), GetAnonymStr(g_continueCfgFullPath).c_str()); std::string tempPath = g_continueCfgFullPath; if (!g_isMissContinueCfg.load() && (g_continueCfgFullPath.empty() || !IsValidPath(tempPath, g_continueCfgFullPath))) { char cfgPathBuf[MAX_CONFIG_PATH_LEN] = { 0 }; char *filePath = GetOneCfgFile(CONTINUE_CONFIG_RELATIVE_PATH.c_str(), cfgPathBuf, MAX_CONFIG_PATH_LEN); if (filePath == nullptr || filePath != cfgPathBuf) { - HILOGI("Not find continue config file, relative path %{public}s.", CONTINUE_CONFIG_RELATIVE_PATH.c_str()); + HILOGI("Not find continue config file, relative path %{public}s.", + GetAnonymStr(CONTINUE_CONFIG_RELATIVE_PATH).c_str()); g_isMissContinueCfg.store(true); g_continueCfgFullPath = ""; return ERR_OK; } g_isMissContinueCfg.store(false); g_continueCfgFullPath = std::string(filePath); - HILOGI("Get Continue config file full path success, cfgFullPath %{public}s.", g_continueCfgFullPath.c_str()); + HILOGI("Get Continue config file full path success, cfgFullPath %{public}s.", + GetAnonymStr(g_continueCfgFullPath).c_str()); } - if (g_isMissContinueCfg.load()) { HILOGI("Current device does not carry continue config file."); return ERR_OK; } - tempPath = g_continueCfgFullPath; + std::string anonymPath = GetAnonymStr(g_continueCfgFullPath); if (!IsValidPath(tempPath, g_continueCfgFullPath)) { - HILOGE("Continue config full path is invalid, cfgFullPath %{public}s.", g_continueCfgFullPath.c_str()); + HILOGE("Continue config full path is invalid, cfgFullPath %{public}s.", anonymPath.c_str()); return DMS_PERMISSION_DENIED; } std::ifstream in; in.open(g_continueCfgFullPath.c_str(), std::ios::binary | std::ios::in); if (!in.is_open()) { - HILOGE("Open continue config json file fail, cfgFullPath %{public}s.", g_continueCfgFullPath.c_str()); + HILOGE("Open continue config json file fail, cfgFullPath %{public}s.", anonymPath.c_str()); return DMS_PERMISSION_DENIED; } @@ -174,11 +175,11 @@ int32_t LoadContinueConfig() in.close(); if (!UpdateAllowAppList(cfgFileContent)) { - HILOGE("Update allow app list fail, cfgFullPath %{public}s.", g_continueCfgFullPath.c_str()); + HILOGE("Update allow app list fail, cfgFullPath %{public}s.", anonymPath.c_str()); return DMS_PERMISSION_DENIED; } HILOGI("Load continue config success, isMissContinueCfg %{public}d, cfgFullPath %{public}s.", - g_isMissContinueCfg.load(), g_continueCfgFullPath.c_str()); + g_isMissContinueCfg.load(), anonymPath.c_str()); return ERR_OK; } @@ -193,12 +194,12 @@ bool CheckBundleContinueConfig(const std::string &bundleName) auto it = std::find(g_allowAppList.begin(), g_allowAppList.end(), bundleName); if (it == g_allowAppList.end()) { HILOGE("Current app is not allow to continue in config file, bundleName %{public}s, cfgPath %{public}s.", - bundleName.c_str(), g_continueCfgFullPath.c_str()); + bundleName.c_str(), GetAnonymStr(g_continueCfgFullPath).c_str()); return false; } HILOGI("Current app is allow to continue in config file, bundleName %{public}s, cfgPath %{public}s.", - bundleName.c_str(), g_continueCfgFullPath.c_str()); + bundleName.c_str(), GetAnonymStr(g_continueCfgFullPath).c_str()); return true; } diff --git a/services/dtbschedmgr/include/softbus_adapter/softbus_adapter.h b/services/dtbschedmgr/include/softbus_adapter/softbus_adapter.h index 591ded2a..6d6340c8 100644 --- a/services/dtbschedmgr/include/softbus_adapter/softbus_adapter.h +++ b/services/dtbschedmgr/include/softbus_adapter/softbus_adapter.h @@ -48,6 +48,7 @@ private: std::thread eventThread_; std::condition_variable eventCon_; std::mutex eventMutex_; + std::mutex softbusAdapterListenerMutex_; std::shared_ptr eventHandler_ = nullptr; }; } // namespace DistributedSchedule diff --git a/services/dtbschedmgr/src/softbus_adapter/allconnectmgr/dsched_all_connect_manager.cpp b/services/dtbschedmgr/src/softbus_adapter/allconnectmgr/dsched_all_connect_manager.cpp index a6569145..5f392ded 100644 --- a/services/dtbschedmgr/src/softbus_adapter/allconnectmgr/dsched_all_connect_manager.cpp +++ b/services/dtbschedmgr/src/softbus_adapter/allconnectmgr/dsched_all_connect_manager.cpp @@ -93,14 +93,16 @@ int32_t DSchedAllConnectManager::GetServiceCollaborationManagerProxy() #endif char path[PATH_MAX + 1] = {0}; if (resolvedPath.length() > PATH_MAX || realpath(resolvedPath.c_str(), path) == nullptr) { - HILOGE("Check all connect so real path failed, resolvedPath [%{public}s].", resolvedPath.c_str()); + HILOGE("Check all connect so real path failed, resolvedPath [%{public}s].", + GetAnonymStr(resolvedPath).c_str()); return INVALID_PARAMETERS_ERR; } int32_t (*ServiceCollaborationManagerExport)(ServiceCollaborationManager_API *exportapi) = nullptr; dllHandle_ = dlopen(resolvedPath.c_str(), RTLD_LAZY); if (dllHandle_ == nullptr) { - HILOGE("Open dms interactive adapter shared object fail, resolvedPath [%{public}s].", resolvedPath.c_str()); + HILOGE("Open dms interactive adapter shared object fail, resolvedPath [%{public}s].", + GetAnonymStr(resolvedPath).c_str()); return NOT_FIND_SERVICE_REGISTRY; } diff --git a/services/dtbschedmgr/src/softbus_adapter/softbus_adapter.cpp b/services/dtbschedmgr/src/softbus_adapter/softbus_adapter.cpp index 4d0968ce..2c2c49f5 100644 --- a/services/dtbschedmgr/src/softbus_adapter/softbus_adapter.cpp +++ b/services/dtbschedmgr/src/softbus_adapter/softbus_adapter.cpp @@ -173,7 +173,10 @@ int32_t SoftbusAdapter::RegisterSoftbusEventListener(const std::shared_ptr lock(softbusAdapterListenerMutex_); + softbusAdapterListener_ = listener; + } EventListener eventListener; eventListener.event = FOREGROUND_APP; eventListener.freq = EVENT_MID_FREQ; @@ -195,7 +198,10 @@ int32_t SoftbusAdapter::UnregisterSoftbusEventListener(const std::shared_ptr lock(softbusAdapterListenerMutex_); + softbusAdapterListener_ = listener; + } EventListener eventListener; eventListener.event = FOREGROUND_APP; eventListener.freq = EVENT_MID_FREQ;