From 0c981ea14857e4b8409c76307bbeda2ab3713220 Mon Sep 17 00:00:00 2001 From: pwx1285814 Date: Mon, 29 Jul 2024 15:55:36 +0800 Subject: [PATCH] =?UTF-8?q?so=E6=B2=99=E7=9B=92=E6=9D=83=E9=99=90=E9=9A=94?= =?UTF-8?q?=E7=A6=BB=E6=8E=92=E6=9F=A5=E6=95=B4=E6=94=B9=EF=BC=8C=E5=B0=86?= =?UTF-8?q?dlopen=E4=B8=AD=E7=9A=84=E7=BB=9D=E5=AF=B9=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=BA=E7=9B=B8=E5=AF=B9=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: pwx1285814 Change-Id: I2fd96c8fbf6b6447a38bac2705b73d10fe4f28a7 Signed-off-by: pwx1285814 --- .../2.0/src/screenregionmgr.cpp | 23 ++++++------------- .../dscreenmgr/2.0/src/dscreen_manager.cpp | 23 ++++++------------- .../encoder/src/image_source_encoder.cpp | 16 +++++-------- 3 files changed, 20 insertions(+), 42 deletions(-) diff --git a/services/screenservice/sinkservice/screenregionmgr/2.0/src/screenregionmgr.cpp b/services/screenservice/sinkservice/screenregionmgr/2.0/src/screenregionmgr.cpp index babed377..93da68f3 100644 --- a/services/screenservice/sinkservice/screenregionmgr/2.0/src/screenregionmgr.cpp +++ b/services/screenservice/sinkservice/screenregionmgr/2.0/src/screenregionmgr.cpp @@ -47,11 +47,6 @@ using AVTransProviderClass = IAVEngineProvider *(*)(const std::string); const std::string RECEIVER_SO_NAME = "libdistributed_av_receiver.z.so"; const std::string GET_PROVIDER_FUNC = "GetAVReceiverEngineProvider"; -#ifdef __LP64__ -const std::string LIB_LOAD_PATH = "/system/lib64/"; -#else -const std::string LIB_LOAD_PATH = "/system/lib/"; -#endif ScreenRegionManager::ScreenRegionManager() { @@ -161,15 +156,13 @@ void ScreenRegionManager::GetScreenDumpInfo(std::string &result) int32_t ScreenRegionManager::LoadAVReceiverEngineProvider() { DHLOGI("LoadAVReceiverEngineProvider enter"); - char path[PATH_MAX + 1] = {0x00}; - if ((LIB_LOAD_PATH.length() + RECEIVER_SO_NAME.length()) > PATH_MAX || - realpath((LIB_LOAD_PATH + RECEIVER_SO_NAME).c_str(), path) == nullptr) { - DHLOGE("File canonicalization failed"); + if ((RECEIVER_SO_NAME.length() == 0) || (RECEIVER_SO_NAME.length() > PATH_MAX)) { + DHLOGE("File canonicalization failed, so name: %{public}s.", RECEIVER_SO_NAME.c_str()); return ERR_DH_AV_TRANS_LOAD_ERROR; } - void *pHandler = dlopen(path, RTLD_LAZY | RTLD_NODELETE); + void *pHandler = dlopen(RECEIVER_SO_NAME.c_str(), RTLD_LAZY | RTLD_NODELETE); if (pHandler == nullptr) { - DHLOGE("%{public}s handler load failed, failed reason : %{public}s", path, dlerror()); + DHLOGE("so: %{public}s load failed, failed reason : %{public}s", RECEIVER_SO_NAME.c_str(), dlerror()); return ERR_DH_AV_TRANS_NULL_VALUE; } AVTransProviderClass getEngineFactoryFunc = (AVTransProviderClass)dlsym(pHandler, GET_PROVIDER_FUNC.c_str()); @@ -186,13 +179,11 @@ int32_t ScreenRegionManager::LoadAVReceiverEngineProvider() int32_t ScreenRegionManager::UnloadAVReceiverEngineProvider() { DHLOGI("UnloadAVReceiverEngineProvider enter"); - char path[PATH_MAX + 1] = {0x00}; - if ((LIB_LOAD_PATH.length() + RECEIVER_SO_NAME.length()) > PATH_MAX || - realpath((LIB_LOAD_PATH + RECEIVER_SO_NAME).c_str(), path) == nullptr) { - DHLOGE("File canonicalization failed"); + if ((RECEIVER_SO_NAME.length() == 0) || (RECEIVER_SO_NAME.length() > PATH_MAX)) { + DHLOGE("File canonicalization failed, so name: %{public}s.", RECEIVER_SO_NAME.c_str()); return ERR_DH_AV_TRANS_LOAD_ERROR; } - void *pHandler = dlopen(path, RTLD_LAZY | RTLD_NODELETE); + void *pHandler = dlopen(RECEIVER_SO_NAME.c_str(), RTLD_LAZY | RTLD_NODELETE); if (pHandler != nullptr) { dlclose(pHandler); pHandler = nullptr; diff --git a/services/screenservice/sourceservice/dscreenmgr/2.0/src/dscreen_manager.cpp b/services/screenservice/sourceservice/dscreenmgr/2.0/src/dscreen_manager.cpp index b064c110..2ccb802a 100644 --- a/services/screenservice/sourceservice/dscreenmgr/2.0/src/dscreen_manager.cpp +++ b/services/screenservice/sourceservice/dscreenmgr/2.0/src/dscreen_manager.cpp @@ -44,11 +44,6 @@ using AVTransProviderClass = IAVEngineProvider *(*)(const std::string); const std::string SENDER_SO_NAME = "libdistributed_av_sender.z.so"; const std::string GET_PROVIDER_FUNC = "GetAVSenderEngineProvider"; -#ifdef __LP64__ -const std::string LIB_LOAD_PATH = "/system/lib64/"; -#else -const std::string LIB_LOAD_PATH = "/system/lib/"; -#endif const std::map stateMap = { { DISABLED, "disabled" }, @@ -402,15 +397,13 @@ void DScreenManager::PublishMessage(const DHTopic topic, const std::shared_ptr PATH_MAX || - realpath((LIB_LOAD_PATH + SENDER_SO_NAME).c_str(), path) == nullptr) { - DHLOGE("File canonicalization failed"); + if ((SENDER_SO_NAME.length() == 0) || (SENDER_SO_NAME.length() > PATH_MAX)) { + DHLOGE("File canonicalization failed, so name: %{public}s.", SENDER_SO_NAME.c_str()); return ERR_DH_AV_TRANS_LOAD_ERROR; } - void *pHandler = dlopen(path, RTLD_LAZY | RTLD_NODELETE); + void *pHandler = dlopen(SENDER_SO_NAME.c_str(), RTLD_LAZY | RTLD_NODELETE); if (pHandler == nullptr) { - DHLOGE("%{public}s handler load failed, failed reason : %{public}s", path, dlerror()); + DHLOGE("so: %{public}s load failed, failed reason : %{public}s", SENDER_SO_NAME.c_str(), dlerror()); return ERR_DH_AV_TRANS_NULL_VALUE; } AVTransProviderClass getEngineFactoryFunc = (AVTransProviderClass)dlsym(pHandler, GET_PROVIDER_FUNC.c_str()); @@ -427,13 +420,11 @@ int32_t DScreenManager::LoadAVSenderEngineProvider() int32_t DScreenManager::UnloadAVSenderEngineProvider() { DHLOGI("UnloadAVSenderEngineProvider enter"); - char path[PATH_MAX + 1] = {0x00}; - if ((LIB_LOAD_PATH.length() + SENDER_SO_NAME.length()) > PATH_MAX || - realpath((LIB_LOAD_PATH + SENDER_SO_NAME).c_str(), path) == nullptr) { - DHLOGE("File canonicalization failed"); + if ((SENDER_SO_NAME.length() == 0) || (SENDER_SO_NAME.length() > PATH_MAX)) { + DHLOGE("File canonicalization failed, so name: %{public}s.", SENDER_SO_NAME.c_str()); return ERR_DH_AV_TRANS_LOAD_ERROR; } - void *pHandler = dlopen(path, RTLD_LAZY | RTLD_NODELETE); + void *pHandler = dlopen(SENDER_SO_NAME.c_str(), RTLD_LAZY | RTLD_NODELETE); if (pHandler != nullptr) { dlclose(pHandler); pHandler = nullptr; diff --git a/services/screentransport/screensourceprocessor/encoder/src/image_source_encoder.cpp b/services/screentransport/screensourceprocessor/encoder/src/image_source_encoder.cpp index fa17fc66..c2b3b08f 100644 --- a/services/screentransport/screensourceprocessor/encoder/src/image_source_encoder.cpp +++ b/services/screentransport/screensourceprocessor/encoder/src/image_source_encoder.cpp @@ -29,15 +29,12 @@ #include "dscreen_hisysevent.h" #include "dscreen_log.h" #include "jpeglib.h" -#ifdef __LP64__ -static const std::string LIB_LOAD_PATH = "/system/lib64/libdistributed_screen_dbg_itf.z.so"; -#else -static const std::string LIB_LOAD_PATH = "/system/lib/libdistributed_screen_dbg_itf.z.so"; -#endif + using GetDscreenDBGItfFunc = OHOS::DistributedHardware::IDScreenDBGItf* (*)(); using GetImageDirtyFunc = OHOS::DistributedHardware::IImageSetDirty* (*)(); namespace OHOS { namespace DistributedHardware { +const std::string DBG_SO_NAME = "libdistributed_screen_dbg_itf.z.so"; void ConsumerBufferListener::OnBufferAvailable() { DHLOGI("%{public}s: OnBufferAvailable, receiv data from RS.", DSCREEN_LOG_TAG); @@ -46,14 +43,13 @@ void ConsumerBufferListener::OnBufferAvailable() void ImageSourceEncoder::InitDscreenDBG() { - char path[PATH_MAX + 1] = {0x00}; - if (LIB_LOAD_PATH.length() > PATH_MAX || realpath(LIB_LOAD_PATH.c_str(), path) == nullptr) { - DHLOGE("File connicailization failed."); + if ((DBG_SO_NAME.length() == 0) || (DBG_SO_NAME.length() > PATH_MAX)) { + DHLOGE("File canonicalization failed, so name: %{public}s.", DBG_SO_NAME.c_str()); return; } - pHandler_ = dlopen(path, RTLD_LAZY | RTLD_NODELETE | RTLD_GLOBAL); + pHandler_ = dlopen(DBG_SO_NAME.c_str(), RTLD_LAZY | RTLD_NODELETE | RTLD_GLOBAL); if (pHandler_ == nullptr) { - DHLOGE("%{public}s: handler load failed, fail reason: %{public}s.", path, dlerror()); + DHLOGE("so: %{public}s load failed, fail reason: %{public}s.", DBG_SO_NAME.c_str(), dlerror()); return; } GetDscreenDBGItfFunc getDscreenDBGItfFunc = (GetDscreenDBGItfFunc)dlsym(pHandler_, GET_DBG_ITF_FUNC.c_str()); -- Gitee