From fc4b36cd5148ba72af6dbff7af6dc8b950122374 Mon Sep 17 00:00:00 2001 From: pwx1285814 Date: Fri, 13 Sep 2024 12:44:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=AE=E5=BC=82=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: pwx1285814 Change-Id: I596c73a2efda8e641de7c1c64c70b4e0eaca1c03 --- bundle.json | 3 +-- common/BUILD.gn | 2 -- screenhandler/include/dscreen_handler.h | 3 +-- screenhandler/src/dscreen_handler.cpp | 13 +++-------- .../screen_channel/include/iscreen_channel.h | 2 +- services/screenservice/sinkservice/BUILD.gn | 2 -- .../2.0/src/screenregionmgr.cpp | 23 +++++++++++++------ services/screenservice/sourceservice/BUILD.gn | 2 -- .../dscreenmgr/2.0/src/dscreen_manager.cpp | 23 +++++++++++++------ .../include/screen_data_channel_impl.h | 2 +- .../src/screen_data_channel_impl.cpp | 2 +- .../screentransport/screensinktrans/BUILD.gn | 2 -- .../encoder/src/image_source_encoder.cpp | 16 ++++++++----- .../screensourcetrans/BUILD.gn | 2 -- .../include/screentrans_test_utils.h | 2 +- 15 files changed, 51 insertions(+), 48 deletions(-) diff --git a/bundle.json b/bundle.json index d60cc459..bf7c1623 100644 --- a/bundle.json +++ b/bundle.json @@ -47,8 +47,7 @@ "c_utils", "window_manager", "distributed_hardware_fwk", - "libjpeg-turbo", - "json" + "libjpeg-turbo" ], "third_party": [] }, diff --git a/common/BUILD.gn b/common/BUILD.gn index 96cc038b..74c7be17 100644 --- a/common/BUILD.gn +++ b/common/BUILD.gn @@ -50,8 +50,6 @@ ohos_shared_library("distributed_screen_utils") { "json:nlohmann_json_static", ] - public_external_deps = [ "json:nlohmann_json_static" ] - defines = [ "HI_LOG_ENABLE", "DH_LOG_TAG=\"dscreenutil\"", diff --git a/screenhandler/include/dscreen_handler.h b/screenhandler/include/dscreen_handler.h index c53faf55..fb7b7e06 100644 --- a/screenhandler/include/dscreen_handler.h +++ b/screenhandler/include/dscreen_handler.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Copyright (c) 2022 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 @@ -37,7 +37,6 @@ public: int32_t Initialize() override; std::vector QueryMeta() override; std::vector Query() override; - std::vector RealQuery(); std::map QueryExtraInfo() override; bool IsSupportPlugin() override; void RegisterPluginListener(std::shared_ptr listener) override; diff --git a/screenhandler/src/dscreen_handler.cpp b/screenhandler/src/dscreen_handler.cpp index f400116f..36a29ecd 100644 --- a/screenhandler/src/dscreen_handler.cpp +++ b/screenhandler/src/dscreen_handler.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Copyright (c) 2022-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 @@ -126,19 +126,12 @@ void DScreenHandler::UnPluginHardware(const std::string &dhId) std::vector DScreenHandler::QueryMeta() { - DHLOGI("DScreenHandler query meta hardware info"); - return RealQuery(); + return {}; } std::vector DScreenHandler::Query() { - DHLOGI("DScreenHandler query full hardware info"); - return RealQuery(); -} - -std::vector DScreenHandler::RealQuery() -{ - DHLOGI("DScreenHandler RealQuery"); + DHLOGI("DScreenHandler query hardware info"); std::vector dhItemVec; std::vector> screens; Rosen::ScreenManager::GetInstance().GetAllScreens(screens); diff --git a/services/common/screen_channel/include/iscreen_channel.h b/services/common/screen_channel/include/iscreen_channel.h index 24d5c493..b2e74395 100644 --- a/services/common/screen_channel/include/iscreen_channel.h +++ b/services/common/screen_channel/include/iscreen_channel.h @@ -28,7 +28,7 @@ public: virtual ~IScreenChannel() = default; virtual int32_t CreateSession(const std::shared_ptr &listener) = 0; virtual int32_t ReleaseSession() = 0; - virtual int32_t OpenSession(const std::shared_ptr &listener) = 0; + virtual int32_t OpenSession(const std::shared_ptr listener) = 0; virtual int32_t CloseSession() = 0; virtual int32_t SendData(const std::shared_ptr &data) = 0; virtual void SetJpegSessionFlag(bool flag) = 0; diff --git a/services/screenservice/sinkservice/BUILD.gn b/services/screenservice/sinkservice/BUILD.gn index 6db4bea6..350eeae3 100644 --- a/services/screenservice/sinkservice/BUILD.gn +++ b/services/screenservice/sinkservice/BUILD.gn @@ -98,8 +98,6 @@ ohos_shared_library("distributed_screen_sink") { "window_manager:libdm", ] - public_external_deps = [ "json:nlohmann_json_static" ] - subsystem_name = "distributedhardware" part_name = "distributed_screen" diff --git a/services/screenservice/sinkservice/screenregionmgr/2.0/src/screenregionmgr.cpp b/services/screenservice/sinkservice/screenregionmgr/2.0/src/screenregionmgr.cpp index 93da68f3..babed377 100644 --- a/services/screenservice/sinkservice/screenregionmgr/2.0/src/screenregionmgr.cpp +++ b/services/screenservice/sinkservice/screenregionmgr/2.0/src/screenregionmgr.cpp @@ -47,6 +47,11 @@ 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() { @@ -156,13 +161,15 @@ void ScreenRegionManager::GetScreenDumpInfo(std::string &result) int32_t ScreenRegionManager::LoadAVReceiverEngineProvider() { DHLOGI("LoadAVReceiverEngineProvider enter"); - 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()); + 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"); return ERR_DH_AV_TRANS_LOAD_ERROR; } - void *pHandler = dlopen(RECEIVER_SO_NAME.c_str(), RTLD_LAZY | RTLD_NODELETE); + void *pHandler = dlopen(path, RTLD_LAZY | RTLD_NODELETE); if (pHandler == nullptr) { - DHLOGE("so: %{public}s load failed, failed reason : %{public}s", RECEIVER_SO_NAME.c_str(), dlerror()); + DHLOGE("%{public}s handler load failed, failed reason : %{public}s", path, dlerror()); return ERR_DH_AV_TRANS_NULL_VALUE; } AVTransProviderClass getEngineFactoryFunc = (AVTransProviderClass)dlsym(pHandler, GET_PROVIDER_FUNC.c_str()); @@ -179,11 +186,13 @@ int32_t ScreenRegionManager::LoadAVReceiverEngineProvider() int32_t ScreenRegionManager::UnloadAVReceiverEngineProvider() { DHLOGI("UnloadAVReceiverEngineProvider enter"); - 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()); + 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"); return ERR_DH_AV_TRANS_LOAD_ERROR; } - void *pHandler = dlopen(RECEIVER_SO_NAME.c_str(), RTLD_LAZY | RTLD_NODELETE); + void *pHandler = dlopen(path, RTLD_LAZY | RTLD_NODELETE); if (pHandler != nullptr) { dlclose(pHandler); pHandler = nullptr; diff --git a/services/screenservice/sourceservice/BUILD.gn b/services/screenservice/sourceservice/BUILD.gn index 97da3dd8..4061c4fb 100644 --- a/services/screenservice/sourceservice/BUILD.gn +++ b/services/screenservice/sourceservice/BUILD.gn @@ -106,8 +106,6 @@ ohos_shared_library("distributed_screen_source") { "window_manager:libdm", ] - public_external_deps = [ "json:nlohmann_json_static" ] - subsystem_name = "distributedhardware" part_name = "distributed_screen" 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 2ccb802a..b064c110 100644 --- a/services/screenservice/sourceservice/dscreenmgr/2.0/src/dscreen_manager.cpp +++ b/services/screenservice/sourceservice/dscreenmgr/2.0/src/dscreen_manager.cpp @@ -44,6 +44,11 @@ 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" }, @@ -397,13 +402,15 @@ void DScreenManager::PublishMessage(const DHTopic topic, const std::shared_ptr PATH_MAX)) { - DHLOGE("File canonicalization failed, so name: %{public}s.", SENDER_SO_NAME.c_str()); + 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"); return ERR_DH_AV_TRANS_LOAD_ERROR; } - void *pHandler = dlopen(SENDER_SO_NAME.c_str(), RTLD_LAZY | RTLD_NODELETE); + void *pHandler = dlopen(path, RTLD_LAZY | RTLD_NODELETE); if (pHandler == nullptr) { - DHLOGE("so: %{public}s load failed, failed reason : %{public}s", SENDER_SO_NAME.c_str(), dlerror()); + DHLOGE("%{public}s handler load failed, failed reason : %{public}s", path, dlerror()); return ERR_DH_AV_TRANS_NULL_VALUE; } AVTransProviderClass getEngineFactoryFunc = (AVTransProviderClass)dlsym(pHandler, GET_PROVIDER_FUNC.c_str()); @@ -420,11 +427,13 @@ int32_t DScreenManager::LoadAVSenderEngineProvider() int32_t DScreenManager::UnloadAVSenderEngineProvider() { DHLOGI("UnloadAVSenderEngineProvider enter"); - 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()); + 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"); return ERR_DH_AV_TRANS_LOAD_ERROR; } - void *pHandler = dlopen(SENDER_SO_NAME.c_str(), RTLD_LAZY | RTLD_NODELETE); + void *pHandler = dlopen(path, RTLD_LAZY | RTLD_NODELETE); if (pHandler != nullptr) { dlclose(pHandler); pHandler = nullptr; diff --git a/services/screentransport/screendatachannel/include/screen_data_channel_impl.h b/services/screentransport/screendatachannel/include/screen_data_channel_impl.h index 23a3bc10..46a1d95c 100644 --- a/services/screentransport/screendatachannel/include/screen_data_channel_impl.h +++ b/services/screentransport/screendatachannel/include/screen_data_channel_impl.h @@ -34,7 +34,7 @@ public: ~ScreenDataChannelImpl() override = default; int32_t CreateSession(const std::shared_ptr &listener) override; int32_t ReleaseSession() override; - int32_t OpenSession(const std::shared_ptr &listener) override; + int32_t OpenSession(const std::shared_ptr listener) override; int32_t CloseSession() override; int32_t SendData(const std::shared_ptr &screenData) override; void SetJpegSessionFlag(bool flag) override; diff --git a/services/screentransport/screendatachannel/src/screen_data_channel_impl.cpp b/services/screentransport/screendatachannel/src/screen_data_channel_impl.cpp index 535eb8df..e452b829 100644 --- a/services/screentransport/screendatachannel/src/screen_data_channel_impl.cpp +++ b/services/screentransport/screendatachannel/src/screen_data_channel_impl.cpp @@ -100,7 +100,7 @@ int32_t ScreenDataChannelImpl::ReleaseSession() return DH_SUCCESS; } -int32_t ScreenDataChannelImpl::OpenSession(const std::shared_ptr &listener) +int32_t ScreenDataChannelImpl::OpenSession(const std::shared_ptr listener) { DHLOGI("%{public}s: OpenSession, peerDevId(%{public}s)", DSCREEN_LOG_TAG, GetAnonyString(peerDevId_).c_str()); if (listener == nullptr) { diff --git a/services/screentransport/screensinktrans/BUILD.gn b/services/screentransport/screensinktrans/BUILD.gn index 4bb63ebc..f073e1aa 100644 --- a/services/screentransport/screensinktrans/BUILD.gn +++ b/services/screentransport/screensinktrans/BUILD.gn @@ -80,8 +80,6 @@ ohos_shared_library("distributed_screen_sinktrans") { "media_foundation:media_foundation", ] - public_external_deps = [ "json:nlohmann_json_static" ] - subsystem_name = "distributedhardware" part_name = "distributed_screen" diff --git a/services/screentransport/screensourceprocessor/encoder/src/image_source_encoder.cpp b/services/screentransport/screensourceprocessor/encoder/src/image_source_encoder.cpp index c2b3b08f..fa17fc66 100644 --- a/services/screentransport/screensourceprocessor/encoder/src/image_source_encoder.cpp +++ b/services/screentransport/screensourceprocessor/encoder/src/image_source_encoder.cpp @@ -29,12 +29,15 @@ #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); @@ -43,13 +46,14 @@ void ConsumerBufferListener::OnBufferAvailable() void ImageSourceEncoder::InitDscreenDBG() { - 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()); + 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."); return; } - pHandler_ = dlopen(DBG_SO_NAME.c_str(), RTLD_LAZY | RTLD_NODELETE | RTLD_GLOBAL); + pHandler_ = dlopen(path, RTLD_LAZY | RTLD_NODELETE | RTLD_GLOBAL); if (pHandler_ == nullptr) { - DHLOGE("so: %{public}s load failed, fail reason: %{public}s.", DBG_SO_NAME.c_str(), dlerror()); + DHLOGE("%{public}s: handler load failed, fail reason: %{public}s.", path, dlerror()); return; } GetDscreenDBGItfFunc getDscreenDBGItfFunc = (GetDscreenDBGItfFunc)dlsym(pHandler_, GET_DBG_ITF_FUNC.c_str()); diff --git a/services/screentransport/screensourcetrans/BUILD.gn b/services/screentransport/screensourcetrans/BUILD.gn index 0960cebc..d75d798e 100644 --- a/services/screentransport/screensourcetrans/BUILD.gn +++ b/services/screentransport/screensourcetrans/BUILD.gn @@ -81,8 +81,6 @@ ohos_shared_library("distributed_screen_sourcetrans") { "media_foundation:media_foundation", ] - public_external_deps = [ "json:nlohmann_json_static" ] - subsystem_name = "distributedhardware" part_name = "distributed_screen" diff --git a/services/screentransport/test/unittest/screentranstestutils/include/screentrans_test_utils.h b/services/screentransport/test/unittest/screentranstestutils/include/screentrans_test_utils.h index a0a36c99..eb793756 100644 --- a/services/screentransport/test/unittest/screentranstestutils/include/screentrans_test_utils.h +++ b/services/screentransport/test/unittest/screentranstestutils/include/screentrans_test_utils.h @@ -90,7 +90,7 @@ public: { return DH_SUCCESS; } - int32_t OpenSession(const std::shared_ptr &listener) override + int32_t OpenSession(const std::shared_ptr listener) override { return DH_SUCCESS; } -- Gitee