From a4ba0d906f16fbf564c292ef3972d29630c8f0b4 Mon Sep 17 00:00:00 2001 From: gaoqiang_strong Date: Wed, 13 Apr 2022 20:33:09 +0800 Subject: [PATCH 01/15] modify framework load screen SA Signed-off-by: gaoqiang_strong --- common/include/dscreen_constants.h | 1 + common/include/dscreen_errcode.h | 1 + .../innerkits/native_cpp/screen_sink/BUILD.gn | 63 ++++----- .../callback/dscreen_sink_load_callback.h | 34 +++++ .../include/dscreen_sink_handler.h | 3 + .../callback/dscreen_sink_load_callback.cpp | 43 ++++++ .../screen_sink/src/dscreen_sink_handler.cpp | 45 +++++-- .../native_cpp/screen_source/BUILD.gn | 68 +++++----- .../callback/dscreen_source_load_callback.h | 34 +++++ .../include/dscreen_source_handler.h | 3 + .../callback/dscreen_source_load_callback.cpp | 43 ++++++ .../src/dscreen_source_handler.cpp | 44 ++++-- sa_profile/4807.xml | 4 +- sa_profile/4808.xml | 4 +- services/screenservice/sinkservice/BUILD.gn | 125 ++++++++++-------- .../src/dscreen_sink_service.cpp | 5 +- .../screenservice/sinkservice/dscreensink.cfg | 10 ++ services/screenservice/sourceservice/BUILD.gn | 8 ++ .../src/dscreen_source_service.cpp | 2 + .../sourceservice/dscreensrc.cfg | 10 ++ 20 files changed, 398 insertions(+), 152 deletions(-) create mode 100644 interfaces/innerkits/native_cpp/screen_sink/include/callback/dscreen_sink_load_callback.h create mode 100644 interfaces/innerkits/native_cpp/screen_sink/src/callback/dscreen_sink_load_callback.cpp create mode 100644 interfaces/innerkits/native_cpp/screen_source/include/callback/dscreen_source_load_callback.h create mode 100644 interfaces/innerkits/native_cpp/screen_source/src/callback/dscreen_source_load_callback.cpp create mode 100644 services/screenservice/sinkservice/dscreensink.cfg create mode 100644 services/screenservice/sourceservice/dscreensrc.cfg diff --git a/common/include/dscreen_constants.h b/common/include/dscreen_constants.h index cce75aa..f8c15f6 100644 --- a/common/include/dscreen_constants.h +++ b/common/include/dscreen_constants.h @@ -125,6 +125,7 @@ constexpr int32_t DISTRIBUTED_HARDWARE_SCREEN_SOURCE_SA_ID = 4807; constexpr int32_t DISTRIBUTED_HARDWARE_SCREEN_SINK_SA_ID = 4808; constexpr uint64_t SCREEN_ID_INVALID = -1ULL; constexpr uint64_t SCREEN_ID_DEFAULT = 0; +constexpr int32_t SCREEN_LOADSA_TIMEOUT_MS = 10000; } // namespace DistributedHardware } // namespace OHOS #endif \ No newline at end of file diff --git a/common/include/dscreen_errcode.h b/common/include/dscreen_errcode.h index a6101bb..987e919 100644 --- a/common/include/dscreen_errcode.h +++ b/common/include/dscreen_errcode.h @@ -53,6 +53,7 @@ enum DScreenErrorCode { ERR_DH_SCREEN_SA_REGISTER_SCREENLISTENER_FAIL = -500029, ERR_DH_SCREEN_SA_UNREGISTER_SCREENLISTENER_FAIL = -500030, ERR_DH_SCREEN_SA_DSCREEN_NEGOTIATE_CODEC_FAIL = -500031, + ERR_DH_SCREEN_SA_LOAD_TIMEOUT = -500032, // Transport component error code ERR_DH_SCREEN_TRANS_ERROR = -51000, ERR_DH_SCREEN_TRANS_TIMEOUT = -51001, diff --git a/interfaces/innerkits/native_cpp/screen_sink/BUILD.gn b/interfaces/innerkits/native_cpp/screen_sink/BUILD.gn index bcbb3e9..9cd53e1 100644 --- a/interfaces/innerkits/native_cpp/screen_sink/BUILD.gn +++ b/interfaces/innerkits/native_cpp/screen_sink/BUILD.gn @@ -13,43 +13,46 @@ import("//build/ohos.gni") import("//build/ohos_var.gni") -import("//foundation/distributedhardware/distributedscreen/distributedscreen.gni") +import( + "//foundation/distributedhardware/distributedscreen/distributedscreen.gni") ohos_shared_library("distributed_screen_sink_sdk") { - include_dirs = [ - "//utils/system/safwk/native/include", - "${fwk_common_path}/utils/include", - ] + include_dirs = [ + "//utils/system/safwk/native/include", + "${fwk_common_path}/utils/include", + ] - include_dirs += [ - "include", - "${common_path}/include", - ] + include_dirs += [ + "include", + "include/callback", + "${common_path}/include", + ] - sources = [ - "src/dscreen_sink_handler.cpp", - "src/dscreen_sink_proxy.cpp", - ] + sources = [ + "src/callback/dscreen_sink_load_callback.cpp", + "src/dscreen_sink_handler.cpp", + "src/dscreen_sink_proxy.cpp", + ] - deps = [ - "//utils/native/base:utils", - "${common_path}:distributed_screen_utils", - ] + deps = [ + "${common_path}:distributed_screen_utils", + "//utils/native/base:utils", + ] - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"dscreensinksdk\"", - "LOG_DOMAIN=0xD004100", - ] + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"dscreensinksdk\"", + "LOG_DOMAIN=0xD004100", + ] - external_deps = [ - "hiviewdfx_hilog_native:libhilog", - "ipc:ipc_core", - "safwk:system_ability_fwk", - "samgr_standard:samgr_proxy", - ] + external_deps = [ + "hiviewdfx_hilog_native:libhilog", + "ipc:ipc_core", + "safwk:system_ability_fwk", + "samgr_standard:samgr_proxy", + ] - subsystem_name = "distributedhardware" + subsystem_name = "distributedhardware" - part_name = "distributed_screen" + part_name = "distributed_screen" } \ No newline at end of file diff --git a/interfaces/innerkits/native_cpp/screen_sink/include/callback/dscreen_sink_load_callback.h b/interfaces/innerkits/native_cpp/screen_sink/include/callback/dscreen_sink_load_callback.h new file mode 100644 index 0000000..5bb267e --- /dev/null +++ b/interfaces/innerkits/native_cpp/screen_sink/include/callback/dscreen_sink_load_callback.h @@ -0,0 +1,34 @@ +/* + * 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 + * + * 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_DSCREEN_SINK_LOAD_CALLBACK_H +#define OHOS_DSCREEN_SINK_LOAD_CALLBACK_H + +#include "system_ability_load_callback_stub.h" + +namespace OHOS { +namespace DistributedHardware { +class DScreenSinkLoadCallback : public SystemAbilityLoadCallbackStub { +public: + explicit DScreenSinkLoadCallback(const std::string params); + void OnLoadSystemAbilitySuccess(int32_t systemAbilityId, + const sptr &remoteObject); + void OnLoadSystemAbilityFail(int32_t systemAbilityId); +private: + std::string params_; +}; +} +} +#endif \ No newline at end of file diff --git a/interfaces/innerkits/native_cpp/screen_sink/include/dscreen_sink_handler.h b/interfaces/innerkits/native_cpp/screen_sink/include/dscreen_sink_handler.h index 152884d..2ba840d 100644 --- a/interfaces/innerkits/native_cpp/screen_sink/include/dscreen_sink_handler.h +++ b/interfaces/innerkits/native_cpp/screen_sink/include/dscreen_sink_handler.h @@ -16,6 +16,7 @@ #ifndef OHOS_DSCREEN_SINK_HANDLER_H #define OHOS_DSCREEN_SINK_HANDLER_H +#include #include #include "idistributed_hardware_sink.h" @@ -33,6 +34,7 @@ public: int32_t SubscribeLocalHardware(const std::string &dhId, const std::string ¶m) override; int32_t UnsubscribeLocalHardware(const std::string &dhId) override; void OnRemoteSinkSvrDied(const wptr &remote); + void FinishStartSA(const std::string params, const sptr &remoteObject); private: class DScreenSinkSvrRecipient : public IRemoteObject::DeathRecipient { public: @@ -43,6 +45,7 @@ private: ~DScreenSinkHandler(); std::mutex mutex_; + std::condition_variable conVar_; sptr dScreenSinkProxy_ = nullptr; sptr sinkSvrRecipient_ = nullptr; }; diff --git a/interfaces/innerkits/native_cpp/screen_sink/src/callback/dscreen_sink_load_callback.cpp b/interfaces/innerkits/native_cpp/screen_sink/src/callback/dscreen_sink_load_callback.cpp new file mode 100644 index 0000000..ba1d2b3 --- /dev/null +++ b/interfaces/innerkits/native_cpp/screen_sink/src/callback/dscreen_sink_load_callback.cpp @@ -0,0 +1,43 @@ +/* + * 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 + * + * 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. + */ +#include "dscreen_sink_load_callback.h" + +#include "dscreen_log.h" +#include "dscreen_sink_handler.h" + +namespace OHOS { +namespace DistributedHardware { +DScreenSinkLoadCallback::DScreenSinkLoadCallback( + const std::string params) : params_(params) {} + +void DScreenSinkLoadCallback::OnLoadSystemAbilitySuccess( + int32_t systemAbilityId, const sptr &remoteObject) +{ + DHLOGI("load screen SA success, systemAbilityId:%d, remoteObject result:%s", + systemAbilityId, (remoteObject != nullptr) ? "true":"false"); + if (remoteObject == nullptr) { + DHLOGE("remoteObject is nullptr"); + return; + } + + DScreenSinkHandler::GetInstance().FinishStartSA(params_, remoteObject); +} + +void DScreenSinkLoadCallback::OnLoadSystemAbilityFail(int32_t systemAbilityId) +{ + DHLOGE("load screen SA failed, systemAbilityId:%d", systemAbilityId); +} +} +} \ No newline at end of file diff --git a/interfaces/innerkits/native_cpp/screen_sink/src/dscreen_sink_handler.cpp b/interfaces/innerkits/native_cpp/screen_sink/src/dscreen_sink_handler.cpp index 8f4472c..17319e1 100644 --- a/interfaces/innerkits/native_cpp/screen_sink/src/dscreen_sink_handler.cpp +++ b/interfaces/innerkits/native_cpp/screen_sink/src/dscreen_sink_handler.cpp @@ -21,6 +21,7 @@ #include "dscreen_constants.h" #include "dscreen_errcode.h" #include "dscreen_log.h" +#include "dscreen_sink_load_callback.h" namespace OHOS { namespace DistributedHardware { @@ -43,7 +44,7 @@ DScreenSinkHandler::~DScreenSinkHandler() int32_t DScreenSinkHandler::InitSink(const std::string ¶ms) { DHLOGD("InitSink"); - std::lock_guard lock(mutex_); + std::unique_lock lock(mutex_); if (!dScreenSinkProxy_) { sptr samgr = @@ -52,21 +53,38 @@ int32_t DScreenSinkHandler::InitSink(const std::string ¶ms) DHLOGE("Failed to get system ability mgr."); return ERR_DH_SCREEN_SA_GET_SAMGR_FAIL; } - sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_SCREEN_SINK_SA_ID); - if (!remoteObject) { - DHLOGE("Failed to get dscreen sink service."); - return ERR_DH_SCREEN_SA_GET_SINKSERVICE_FAIL; - } - - remoteObject->AddDeathRecipient(sinkSvrRecipient_); - dScreenSinkProxy_ = iface_cast(remoteObject); - if ((!dScreenSinkProxy_) || (!dScreenSinkProxy_->AsObject())) { - DHLOGE("Failed to get dscreen sink proxy."); + sptr loadCallback = + new DScreenSinkLoadCallback(params); + int32_t ret = samgr->LoadSystemAbility( + DISTRIBUTED_HARDWARE_SCREEN_SINK_SA_ID, loadCallback); + if (ret != ERR_OK) { + DHLOGE("Failed to Load systemAbility, systemAbilityId:%d, ret code:%d", + DISTRIBUTED_HARDWARE_SCREEN_SINK_SA_ID, ret); return ERR_DH_SCREEN_SA_GET_SINKPROXY_FAIL; } } - int32_t ret = dScreenSinkProxy_->InitSink(params); - return ret; + + auto waitStatus = conVar_.wait_for(lock, std::chrono::milliseconds(SCREEN_LOADSA_TIMEOUT_MS), + [this]() { return dScreenSinkProxy_; }); + if (!waitStatus) { + DHLOGE("screen load sa timeout"); + return ERR_DH_SCREEN_SA_LOAD_TIMEOUT; + } + + return DH_SUCCESS; +} + +void DScreenSinkHandler::FinishStartSA(const std::string params, + const sptr &remoteObject) +{ + DHLOGD("FinishStartSA"); + remoteObject->AddDeathRecipient(sinkSvrRecipient_); + dScreenSinkProxy_ = iface_cast(remoteObject); + if ((!dScreenSinkProxy_) || (!dScreenSinkProxy_->AsObject())) { + DHLOGE("Failed to get dscreen sink proxy."); + return; + } + dScreenSinkProxy_->InitSink(params); } int32_t DScreenSinkHandler::ReleaseSink() @@ -79,6 +97,7 @@ int32_t DScreenSinkHandler::ReleaseSink() } int32_t ret = dScreenSinkProxy_->ReleaseSink(); + dScreenSinkProxy_ = nullptr; return ret; } diff --git a/interfaces/innerkits/native_cpp/screen_source/BUILD.gn b/interfaces/innerkits/native_cpp/screen_source/BUILD.gn index fec9182..0397b45 100644 --- a/interfaces/innerkits/native_cpp/screen_source/BUILD.gn +++ b/interfaces/innerkits/native_cpp/screen_source/BUILD.gn @@ -13,46 +13,48 @@ import("//build/ohos.gni") import("//build/ohos_var.gni") -import("//foundation/distributedhardware/distributedscreen/distributedscreen.gni") +import( + "//foundation/distributedhardware/distributedscreen/distributedscreen.gni") ohos_shared_library("distributed_screen_source_sdk") { - include_dirs = [ - "//utils/system/safwk/native/include", - "${fwk_common_path}/utils/include", - ] + include_dirs = [ + "//utils/system/safwk/native/include", + "${fwk_common_path}/utils/include", + ] - include_dirs += [ - "include", - "include/callback", - "${common_path}/include", - ] + include_dirs += [ + "include", + "include/callback", + "${common_path}/include", + ] - sources = [ - "src/dscreen_source_handler.cpp", - "src/dscreen_source_proxy.cpp", - "src/callback/dscreen_source_callback_stub.cpp", - "src/callback/dscreen_source_callback.cpp", - ] + sources = [ + "src/callback/dscreen_source_callback.cpp", + "src/callback/dscreen_source_callback_stub.cpp", + "src/callback/dscreen_source_load_callback.cpp", + "src/dscreen_source_handler.cpp", + "src/dscreen_source_proxy.cpp", + ] - deps = [ - "//utils/native/base:utils", - "${common_path}:distributed_screen_utils", - ] + deps = [ + "${common_path}:distributed_screen_utils", + "//utils/native/base:utils", + ] - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"dscreensourcesdk\"", - "LOG_DOMAIN=0xD004100", - ] + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"dscreensourcesdk\"", + "LOG_DOMAIN=0xD004100", + ] - external_deps = [ - "hiviewdfx_hilog_native:libhilog", - "ipc:ipc_core", - "safwk:system_ability_fwk", - "samgr_standard:samgr_proxy", - ] + external_deps = [ + "hiviewdfx_hilog_native:libhilog", + "ipc:ipc_core", + "safwk:system_ability_fwk", + "samgr_standard:samgr_proxy", + ] - subsystem_name = "distributedhardware" + subsystem_name = "distributedhardware" - part_name = "distributed_screen" + part_name = "distributed_screen" } \ No newline at end of file diff --git a/interfaces/innerkits/native_cpp/screen_source/include/callback/dscreen_source_load_callback.h b/interfaces/innerkits/native_cpp/screen_source/include/callback/dscreen_source_load_callback.h new file mode 100644 index 0000000..d47499a --- /dev/null +++ b/interfaces/innerkits/native_cpp/screen_source/include/callback/dscreen_source_load_callback.h @@ -0,0 +1,34 @@ +/* + * 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 + * + * 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_DSCREEN_SOURCE_LOAD_CALLBACK_H +#define OHOS_DSCREEN_SOURCE_LOAD_CALLBACK_H + +#include "system_ability_load_callback_stub.h" + +namespace OHOS { +namespace DistributedHardware { +class DScreenSourceLoadCallback : public SystemAbilityLoadCallbackStub { +public: + explicit DScreenSourceLoadCallback(const std::string params); + void OnLoadSystemAbilitySuccess(int32_t systemAbilityId, + const sptr &remoteObject); + void OnLoadSystemAbilityFail(int32_t systemAbilityId); +private: + std::string params_; +}; +} +} +#endif \ No newline at end of file diff --git a/interfaces/innerkits/native_cpp/screen_source/include/dscreen_source_handler.h b/interfaces/innerkits/native_cpp/screen_source/include/dscreen_source_handler.h index 0ee40a0..bc7e488 100644 --- a/interfaces/innerkits/native_cpp/screen_source/include/dscreen_source_handler.h +++ b/interfaces/innerkits/native_cpp/screen_source/include/dscreen_source_handler.h @@ -16,6 +16,7 @@ #ifndef OHOS_DSCREEN_SOURCE_HANDLER_H #define OHOS_DSCREEN_SOURCE_HANDLER_H +#include #include #include "dscreen_source_callback.h" @@ -37,6 +38,7 @@ public: int32_t ConfigDistributedHardware(const std::string &devId, const std::string &dhId, const std::string &key, const std::string &value) override; void OnRemoteSourceSvrDied(const wptr &remote); + void FinishStartSA(const std::string params, const sptr &remoteObject); private: class DScreenSourceSvrRecipient : public IRemoteObject::DeathRecipient { public: @@ -47,6 +49,7 @@ private: ~DScreenSourceHandler(); std::mutex mutex_; + std::condition_variable conVar_; sptr dScreenSourceProxy_ = nullptr; sptr dScreenSourceCallback_ = nullptr; sptr sourceSvrRecipient_ = nullptr; diff --git a/interfaces/innerkits/native_cpp/screen_source/src/callback/dscreen_source_load_callback.cpp b/interfaces/innerkits/native_cpp/screen_source/src/callback/dscreen_source_load_callback.cpp new file mode 100644 index 0000000..8e26343 --- /dev/null +++ b/interfaces/innerkits/native_cpp/screen_source/src/callback/dscreen_source_load_callback.cpp @@ -0,0 +1,43 @@ +/* + * 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 + * + * 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. + */ +#include "dscreen_source_load_callback.h" + +#include "dscreen_log.h" +#include "dscreen_source_handler.h" + +namespace OHOS { +namespace DistributedHardware { +DScreenSourceLoadCallback::DScreenSourceLoadCallback( + const std::string params) : params_(params) {} + +void DScreenSourceLoadCallback::OnLoadSystemAbilitySuccess( + int32_t systemAbilityId, const sptr &remoteObject) +{ + DHLOGI("load screen SA success, systemAbilityId:%d, remoteObject result:%s", + systemAbilityId, (remoteObject != nullptr) ? "true":"false"); + if (remoteObject == nullptr) { + DHLOGE("remoteObject is nullptr"); + return; + } + + DScreenSourceHandler::GetInstance().FinishStartSA(params_, remoteObject); +} + +void DScreenSourceLoadCallback::OnLoadSystemAbilityFail(int32_t systemAbilityId) +{ + DHLOGE("load screen SA failed, systemAbilityId:%d", systemAbilityId); +} +} +} diff --git a/interfaces/innerkits/native_cpp/screen_source/src/dscreen_source_handler.cpp b/interfaces/innerkits/native_cpp/screen_source/src/dscreen_source_handler.cpp index ed5e3c0..83299ae 100644 --- a/interfaces/innerkits/native_cpp/screen_source/src/dscreen_source_handler.cpp +++ b/interfaces/innerkits/native_cpp/screen_source/src/dscreen_source_handler.cpp @@ -21,6 +21,7 @@ #include "dscreen_constants.h" #include "dscreen_errcode.h" #include "dscreen_log.h" +#include "dscreen_source_load_callback.h" #include "dscreen_util.h" namespace OHOS { @@ -48,7 +49,7 @@ DScreenSourceHandler::~DScreenSourceHandler() int32_t DScreenSourceHandler::InitSource(const std::string ¶ms) { DHLOGD("InitSource"); - std::lock_guard lock(mutex_); + std::unique_lock lock(mutex_); if (!dScreenSourceProxy_) { sptr samgr = @@ -57,22 +58,38 @@ int32_t DScreenSourceHandler::InitSource(const std::string ¶ms) DHLOGE("Failed to get system ability mgr."); return ERR_DH_SCREEN_SA_GET_SAMGR_FAIL; } - sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_SCREEN_SOURCE_SA_ID); - if (!remoteObject) { - DHLOGE("Failed to get dscreen source service."); - return ERR_DH_SCREEN_SA_GET_SOURCESERVICE_FAIL; - } - - remoteObject->AddDeathRecipient(sourceSvrRecipient_); - dScreenSourceProxy_ = iface_cast(remoteObject); - if ((!dScreenSourceProxy_) || (!dScreenSourceProxy_->AsObject())) { - DHLOGE("Failed to get dscreen source proxy."); + sptr loadCallback = + new DScreenSourceLoadCallback(params); + int32_t ret = samgr->LoadSystemAbility( + DISTRIBUTED_HARDWARE_SCREEN_SOURCE_SA_ID, loadCallback); + if (ret != ERR_OK) { + DHLOGE("Failed to Load systemAbility, systemAbilityId:%d, ret code:%d", + DISTRIBUTED_HARDWARE_SCREEN_SOURCE_SA_ID, ret); return ERR_DH_SCREEN_SA_GET_SOURCEPROXY_FAIL; } } - int32_t ret = dScreenSourceProxy_->InitSource(params, dScreenSourceCallback_); - return ret; + auto waitStatus = conVar_.wait_for(lock, std::chrono::milliseconds(SCREEN_LOADSA_TIMEOUT_MS), + [this]() { return dScreenSourceProxy_; }); + if (!waitStatus) { + DHLOGE("screen load sa timeout."); + return ERR_DH_SCREEN_SA_LOAD_TIMEOUT; + } + + return DH_SUCCESS; +} + +void DScreenSourceHandler::FinishStartSA(const std::string params, + const sptr &remoteObject) +{ + DHLOGD("FinishStartSA"); + remoteObject->AddDeathRecipient(sourceSvrRecipient_); + dScreenSourceProxy_ = iface_cast(remoteObject); + if ((!dScreenSourceProxy_) || (!dScreenSourceProxy_->AsObject())) { + DHLOGE("Failed to get dscreen source proxy."); + return; + } + dScreenSourceProxy_->InitSource(params, dScreenSourceCallback_); } int32_t DScreenSourceHandler::ReleaseSource() @@ -84,6 +101,7 @@ int32_t DScreenSourceHandler::ReleaseSource() return ERR_DH_SCREEN_SA_SOURCEPROXY_NOT_INIT; } int32_t ret = dScreenSourceProxy_->ReleaseSource(); + dScreenSourceProxy_ = nullptr; return ret; } diff --git a/sa_profile/4807.xml b/sa_profile/4807.xml index f3f552e..18d8253 100644 --- a/sa_profile/4807.xml +++ b/sa_profile/4807.xml @@ -14,13 +14,13 @@ * limitations under the License. --> - dhardware + dscreensrc 4807 libdistributed_screen_source.z.so - true + false true 1 diff --git a/sa_profile/4808.xml b/sa_profile/4808.xml index 6ec95fd..7f724ef 100644 --- a/sa_profile/4808.xml +++ b/sa_profile/4808.xml @@ -14,13 +14,13 @@ * limitations under the License. --> - dhardware + dscreensink 4808 libdistributed_screen_sink.z.so - true + false true 1 diff --git a/services/screenservice/sinkservice/BUILD.gn b/services/screenservice/sinkservice/BUILD.gn index 0564cbd..a356c53 100644 --- a/services/screenservice/sinkservice/BUILD.gn +++ b/services/screenservice/sinkservice/BUILD.gn @@ -13,70 +13,79 @@ import("//build/ohos.gni") import("//build/ohos_var.gni") -import("//foundation/distributedhardware/distributedscreen/distributedscreen.gni") +import( + "//foundation/distributedhardware/distributedscreen/distributedscreen.gni") ohos_shared_library("distributed_screen_sink") { - include_dirs = [ - "//third_party/json/include", - "//utils/native/base/include", - "//utils/system/safwk/native/include", - "//foundation/graphic/standard/interfaces/innerkits/surface", - "${windowmanager_path}/interfaces/innerkits/dm", - "${fwk_common_path}/utils/include", - ] + include_dirs = [ + "//third_party/json/include", + "//utils/native/base/include", + "//utils/system/safwk/native/include", + "//foundation/graphic/standard/interfaces/innerkits/surface", + "${windowmanager_path}/interfaces/innerkits/dm", + "${fwk_common_path}/utils/include", + ] - include_dirs += [ - "./dscreenservice/include", - "./screenregionmgr/include", - "${interfaces_path}/innerkits/native_cpp/screen_sink/include", - "${interfaces_path}/innerkits/native_cpp/screen_sink/include/callback", - "${interfaces_path}/innerkits/native_cpp/screen_source/include", - "${interfaces_path}/innerkits/native_cpp/screen_source/include/callback", - "${common_path}/include", - "${services_path}/common/utils/include", - "${services_path}/common/databuffer/include", - "${services_path}/common/screen_channel/include", - "${services_path}/screentransport/screensinktrans/include", - "${services_path}/screentransport/screensinkprocessor/include", - "${services_path}/screentransport/screensinkprocessor/decoder/include", - "${services_path}/screenclient/include/", - ] + include_dirs += [ + "./dscreenservice/include", + "./screenregionmgr/include", + "${interfaces_path}/innerkits/native_cpp/screen_sink/include", + "${interfaces_path}/innerkits/native_cpp/screen_sink/include/callback", + "${interfaces_path}/innerkits/native_cpp/screen_source/include", + "${interfaces_path}/innerkits/native_cpp/screen_source/include/callback", + "${common_path}/include", + "${services_path}/common/utils/include", + "${services_path}/common/databuffer/include", + "${services_path}/common/screen_channel/include", + "${services_path}/screentransport/screensinktrans/include", + "${services_path}/screentransport/screensinkprocessor/include", + "${services_path}/screentransport/screensinkprocessor/decoder/include", + "${services_path}/screenclient/include/", + ] - sources = [ - "${services_path}/common/utils/src/dscreen_maprelation.cpp", - "${services_path}/common/utils/src/video_param.cpp", - "${interfaces_path}/innerkits/native_cpp/screen_sink/src/dscreen_sink_proxy.cpp", - "${interfaces_path}/innerkits/native_cpp/screen_source/src/dscreen_source_proxy.cpp", - "./dscreenservice/src/dscreen_sink_service.cpp", - "./dscreenservice/src/dscreen_sink_stub.cpp", - "./screenregionmgr/src/screenregion.cpp", - "./screenregionmgr/src/screenregionmgr.cpp", - ] + sources = [ + "${interfaces_path}/innerkits/native_cpp/screen_sink/src/dscreen_sink_proxy.cpp", + "${interfaces_path}/innerkits/native_cpp/screen_source/src/dscreen_source_proxy.cpp", + "${services_path}/common/utils/src/dscreen_maprelation.cpp", + "${services_path}/common/utils/src/video_param.cpp", + "./dscreenservice/src/dscreen_sink_service.cpp", + "./dscreenservice/src/dscreen_sink_stub.cpp", + "./screenregionmgr/src/screenregion.cpp", + "./screenregionmgr/src/screenregionmgr.cpp", + ] - deps = [ - "//utils/native/base:utils", - "${common_path}:distributed_screen_utils", - "${services_path}/screentransport/screensinktrans:distributed_screen_sinktrans", - "${services_path}/screenclient:distributed_screen_client", - "//foundation/graphic/standard/frameworks/surface:surface", - "${windowmanager_path}/dm:libdm", - ] + deps = [ + ":dscreensink.cfg", + "${common_path}:distributed_screen_utils", + "${services_path}/screenclient:distributed_screen_client", + "${services_path}/screentransport/screensinktrans:distributed_screen_sinktrans", + "${windowmanager_path}/dm:libdm", + "//foundation/graphic/standard/frameworks/surface:surface", + "//utils/native/base:utils", + ] - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"dscreensink\"", - "LOG_DOMAIN=0xD004100", - ] + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"dscreensink\"", + "LOG_DOMAIN=0xD004100", + ] - external_deps = [ - "hiviewdfx_hilog_native:libhilog", - "ipc:ipc_core", - "safwk:system_ability_fwk", - "samgr_standard:samgr_proxy", - "multimedia_media_standard:media_client", - ] + external_deps = [ + "hiviewdfx_hilog_native:libhilog", + "ipc:ipc_core", + "multimedia_media_standard:media_client", + "safwk:system_ability_fwk", + "samgr_standard:samgr_proxy", + ] - subsystem_name = "distributedhardware" + subsystem_name = "distributedhardware" - part_name = "distributed_screen" -} \ No newline at end of file + part_name = "distributed_screen" +} + +ohos_prebuilt_etc("dscreensink.cfg") { + relative_install_dir = "init" + source = "dscreensink.cfg" + part_name = "distributed_screen" + subsystem_name = "distributedhardware" +} diff --git a/services/screenservice/sinkservice/dscreenservice/src/dscreen_sink_service.cpp b/services/screenservice/sinkservice/dscreenservice/src/dscreen_sink_service.cpp index 643b415..020ce95 100644 --- a/services/screenservice/sinkservice/dscreenservice/src/dscreen_sink_service.cpp +++ b/services/screenservice/sinkservice/dscreenservice/src/dscreen_sink_service.cpp @@ -76,7 +76,10 @@ int32_t DScreenSinkService::InitSink(const std::string ¶ms) int32_t DScreenSinkService::ReleaseSink() { DHLOGI("ReleaseSink"); - return ScreenRegionManager::GetInstance().ReleaseAllRegions(); + ScreenRegionManager::GetInstance().ReleaseAllRegions(); + DHLOGI("exit sink sa process"); + exit(0); + return DH_SUCCESS; } int32_t DScreenSinkService::SubscribeLocalHardware(const std::string &dhId, const std::string ¶m) diff --git a/services/screenservice/sinkservice/dscreensink.cfg b/services/screenservice/sinkservice/dscreensink.cfg new file mode 100644 index 0000000..6bd5133 --- /dev/null +++ b/services/screenservice/sinkservice/dscreensink.cfg @@ -0,0 +1,10 @@ +{ + "services" : [{ + "name" : "dscreensink", + "dynamic" : true, + "path" : ["/system/bin/sa_main", "/system/profile/dscreensink.xml"], + "uid" : "system", + "gid" : ["system"], + "ondemand" : true + }] +} \ No newline at end of file diff --git a/services/screenservice/sourceservice/BUILD.gn b/services/screenservice/sourceservice/BUILD.gn index 922c984..13dc292 100644 --- a/services/screenservice/sourceservice/BUILD.gn +++ b/services/screenservice/sourceservice/BUILD.gn @@ -58,6 +58,7 @@ ohos_shared_library("distributed_screen_source") { ] deps = [ + ":dscreensrc.cfg", "${common_path}:distributed_screen_utils", "${mediastandard_path}/interfaces/inner_api/native:media_client", "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans", @@ -84,3 +85,10 @@ ohos_shared_library("distributed_screen_source") { part_name = "distributed_screen" } + +ohos_prebuilt_etc("dscreensrc.cfg") { + relative_install_dir = "init" + source = "dscreensrc.cfg" + part_name = "distributed_screen" + subsystem_name = "distributedhardware" +} diff --git a/services/screenservice/sourceservice/dscreenservice/src/dscreen_source_service.cpp b/services/screenservice/sourceservice/dscreenservice/src/dscreen_source_service.cpp index e1cb0ef..3a7c561 100644 --- a/services/screenservice/sourceservice/dscreenservice/src/dscreen_source_service.cpp +++ b/services/screenservice/sourceservice/dscreenservice/src/dscreen_source_service.cpp @@ -93,6 +93,8 @@ int32_t DScreenSourceService::ReleaseSource() DHLOGE("UnInit DScreenManager failed. err: %d", ret); return ret; } + DHLOGI("exit source sa process"); + exit(0); return DH_SUCCESS; } diff --git a/services/screenservice/sourceservice/dscreensrc.cfg b/services/screenservice/sourceservice/dscreensrc.cfg new file mode 100644 index 0000000..cb5ad38 --- /dev/null +++ b/services/screenservice/sourceservice/dscreensrc.cfg @@ -0,0 +1,10 @@ +{ + "services" : [{ + "name" : "dscreensrc", + "dynamic" : true, + "path" : ["/system/bin/sa_main", "/system/profile/dscreensrc.xml"], + "uid" : "system", + "gid" : ["system"], + "ondemand" : true + }] +} \ No newline at end of file From dcbbf889e3bda2ce350b35bfe0ac0f80160d9067 Mon Sep 17 00:00:00 2001 From: gaoqiang_strong Date: Thu, 14 Apr 2022 10:10:02 +0800 Subject: [PATCH 02/15] modify gn format Signed-off-by: gaoqiang_strong --- interfaces/innerkits/native_cpp/screen_sink/BUILD.gn | 2 +- interfaces/innerkits/native_cpp/screen_source/BUILD.gn | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/interfaces/innerkits/native_cpp/screen_sink/BUILD.gn b/interfaces/innerkits/native_cpp/screen_sink/BUILD.gn index 9cd53e1..adc10a5 100644 --- a/interfaces/innerkits/native_cpp/screen_sink/BUILD.gn +++ b/interfaces/innerkits/native_cpp/screen_sink/BUILD.gn @@ -55,4 +55,4 @@ ohos_shared_library("distributed_screen_sink_sdk") { subsystem_name = "distributedhardware" part_name = "distributed_screen" -} \ No newline at end of file +} diff --git a/interfaces/innerkits/native_cpp/screen_source/BUILD.gn b/interfaces/innerkits/native_cpp/screen_source/BUILD.gn index 0397b45..565bc5e 100644 --- a/interfaces/innerkits/native_cpp/screen_source/BUILD.gn +++ b/interfaces/innerkits/native_cpp/screen_source/BUILD.gn @@ -57,4 +57,4 @@ ohos_shared_library("distributed_screen_source_sdk") { subsystem_name = "distributedhardware" part_name = "distributed_screen" -} \ No newline at end of file +} From 463e26414ef2717f43b2b8e0ae58e98d642fdaa4 Mon Sep 17 00:00:00 2001 From: gaoqiang_strong Date: Thu, 14 Apr 2022 17:06:54 +0800 Subject: [PATCH 03/15] modify cfg Signed-off-by: gaoqiang_strong --- services/screenservice/sinkservice/dscreensink.cfg | 1 - services/screenservice/sourceservice/dscreensrc.cfg | 1 - 2 files changed, 2 deletions(-) diff --git a/services/screenservice/sinkservice/dscreensink.cfg b/services/screenservice/sinkservice/dscreensink.cfg index 6bd5133..540a69d 100644 --- a/services/screenservice/sinkservice/dscreensink.cfg +++ b/services/screenservice/sinkservice/dscreensink.cfg @@ -1,7 +1,6 @@ { "services" : [{ "name" : "dscreensink", - "dynamic" : true, "path" : ["/system/bin/sa_main", "/system/profile/dscreensink.xml"], "uid" : "system", "gid" : ["system"], diff --git a/services/screenservice/sourceservice/dscreensrc.cfg b/services/screenservice/sourceservice/dscreensrc.cfg index cb5ad38..0bd1cca 100644 --- a/services/screenservice/sourceservice/dscreensrc.cfg +++ b/services/screenservice/sourceservice/dscreensrc.cfg @@ -1,7 +1,6 @@ { "services" : [{ "name" : "dscreensrc", - "dynamic" : true, "path" : ["/system/bin/sa_main", "/system/profile/dscreensrc.xml"], "uid" : "system", "gid" : ["system"], From 5e4034c4f7db142703e3df511ee156aa4f5ac63f Mon Sep 17 00:00:00 2001 From: gaoqiang_strong Date: Fri, 15 Apr 2022 09:59:53 +0800 Subject: [PATCH 04/15] add sourcecallback read token Signed-off-by: gaoqiang_strong --- .../src/callback/dscreen_source_callback_stub.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/interfaces/innerkits/native_cpp/screen_source/src/callback/dscreen_source_callback_stub.cpp b/interfaces/innerkits/native_cpp/screen_source/src/callback/dscreen_source_callback_stub.cpp index 08f9ce8..c9ac9a5 100644 --- a/interfaces/innerkits/native_cpp/screen_source/src/callback/dscreen_source_callback_stub.cpp +++ b/interfaces/innerkits/native_cpp/screen_source/src/callback/dscreen_source_callback_stub.cpp @@ -33,6 +33,14 @@ DScreenSourceCallbackStub::~DScreenSourceCallbackStub() int32_t DScreenSourceCallbackStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) { + DHLOGI("OnRemoteRequest, code: %d", code); + std::u16string desc = DScreenSourceCallbackStub::GetDescriptor(); + std::u16string remoteDesc = data.ReadInterfaceToken(); + if (desc != remoteDesc) { + DHLOGE("DScreenSourceCallbackStub::OnRemoteRequest remoteDesc is invalid!"); + return ERR_INVALID_DATA; + } + std::map::iterator iter = memberFuncMap_.find(code); if (iter == memberFuncMap_.end()) { DHLOGE("invalid request code."); From f35d7a9398e69df3db109d75c800949951cd99ed Mon Sep 17 00:00:00 2001 From: gaoqiang_strong Date: Mon, 18 Apr 2022 21:25:50 +0800 Subject: [PATCH 05/15] modify SCREEN PKGNAME Signed-off-by: gaoqiang_strong --- common/include/dscreen_constants.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/include/dscreen_constants.h b/common/include/dscreen_constants.h index f8c15f6..c4b08a4 100644 --- a/common/include/dscreen_constants.h +++ b/common/include/dscreen_constants.h @@ -58,7 +58,7 @@ enum VideoFormat : uint8_t { }; /* Screen package name */ -const std::string PKG_NAME = "ohos.dhardware"; +const std::string PKG_NAME = "ohos.dhardware.dscreen"; /* Screen data session name */ const std::string DATA_SESSION_NAME = "ohos.dhardware.dscreen.data"; From 46deca551b048d42e46d3aed933a20c365a6c43c Mon Sep 17 00:00:00 2001 From: gaoqiang_strong Date: Wed, 20 Apr 2022 11:22:25 +0800 Subject: [PATCH 06/15] update. get Dscreen SA in one process Signed-off-by: gaoqiang_strong --- bundle.json | 3 ++- sa_profile/4807.xml | 2 +- sa_profile/4808.xml | 2 +- sa_profile/BUILD.gn | 7 +++++++ .../dscreensrc.cfg => sa_profile/dscreen.cfg | 4 ++-- services/screenservice/sinkservice/BUILD.gn | 1 - services/screenservice/sinkservice/dscreensink.cfg | 9 --------- services/screenservice/sourceservice/BUILD.gn | 8 -------- 8 files changed, 13 insertions(+), 23 deletions(-) rename services/screenservice/sourceservice/dscreensrc.cfg => sa_profile/dscreen.cfg (80%) delete mode 100644 services/screenservice/sinkservice/dscreensink.cfg diff --git a/bundle.json b/bundle.json index 1c71c17..df6046c 100644 --- a/bundle.json +++ b/bundle.json @@ -52,7 +52,8 @@ "//foundation/distributedhardware/distributedscreen/services/screentransport/screensourcetrans:distributed_screen_sourcetrans", "//foundation/distributedhardware/distributedscreen/services/screenservice/sinkservice:distributed_screen_sink", "//foundation/distributedhardware/distributedscreen/services/screenservice/sourceservice:distributed_screen_source", - "//foundation/distributedhardware/distributedscreen/sa_profile:dscreen_sa_profile" + "//foundation/distributedhardware/distributedscreen/sa_profile:dscreen_sa_profile", + "//foundation/distributedhardware/distributedscreen/sa_profile:dscreen.cfg" ], "inner_kits":[ { diff --git a/sa_profile/4807.xml b/sa_profile/4807.xml index 18d8253..6cc4818 100644 --- a/sa_profile/4807.xml +++ b/sa_profile/4807.xml @@ -14,7 +14,7 @@ * limitations under the License. --> - dscreensrc + dscreen 4807 libdistributed_screen_source.z.so diff --git a/sa_profile/4808.xml b/sa_profile/4808.xml index 7f724ef..6b16479 100644 --- a/sa_profile/4808.xml +++ b/sa_profile/4808.xml @@ -14,7 +14,7 @@ * limitations under the License. --> - dscreensink + dscreen 4808 libdistributed_screen_sink.z.so diff --git a/sa_profile/BUILD.gn b/sa_profile/BUILD.gn index 6b167fb..1789de8 100644 --- a/sa_profile/BUILD.gn +++ b/sa_profile/BUILD.gn @@ -20,4 +20,11 @@ ohos_sa_profile("dscreen_sa_profile") { ] part_name = "distributed_screen" +} + +ohos_prebuilt_etc("dscreen.cfg") { + relative_install_dir = "init" + source = "dscreen.cfg" + part_name = "distributed_screen" + subsystem_name = "distributedhardware" } \ No newline at end of file diff --git a/services/screenservice/sourceservice/dscreensrc.cfg b/sa_profile/dscreen.cfg similarity index 80% rename from services/screenservice/sourceservice/dscreensrc.cfg rename to sa_profile/dscreen.cfg index 0bd1cca..f623798 100644 --- a/services/screenservice/sourceservice/dscreensrc.cfg +++ b/sa_profile/dscreen.cfg @@ -1,7 +1,7 @@ { "services" : [{ - "name" : "dscreensrc", - "path" : ["/system/bin/sa_main", "/system/profile/dscreensrc.xml"], + "name" : "dscreen", + "path" : ["/system/bin/sa_main", "/system/profile/dscreen.xml"], "uid" : "system", "gid" : ["system"], "ondemand" : true diff --git a/services/screenservice/sinkservice/BUILD.gn b/services/screenservice/sinkservice/BUILD.gn index a356c53..40ef0fd 100644 --- a/services/screenservice/sinkservice/BUILD.gn +++ b/services/screenservice/sinkservice/BUILD.gn @@ -55,7 +55,6 @@ ohos_shared_library("distributed_screen_sink") { ] deps = [ - ":dscreensink.cfg", "${common_path}:distributed_screen_utils", "${services_path}/screenclient:distributed_screen_client", "${services_path}/screentransport/screensinktrans:distributed_screen_sinktrans", diff --git a/services/screenservice/sinkservice/dscreensink.cfg b/services/screenservice/sinkservice/dscreensink.cfg deleted file mode 100644 index 540a69d..0000000 --- a/services/screenservice/sinkservice/dscreensink.cfg +++ /dev/null @@ -1,9 +0,0 @@ -{ - "services" : [{ - "name" : "dscreensink", - "path" : ["/system/bin/sa_main", "/system/profile/dscreensink.xml"], - "uid" : "system", - "gid" : ["system"], - "ondemand" : true - }] -} \ No newline at end of file diff --git a/services/screenservice/sourceservice/BUILD.gn b/services/screenservice/sourceservice/BUILD.gn index 13dc292..922c984 100644 --- a/services/screenservice/sourceservice/BUILD.gn +++ b/services/screenservice/sourceservice/BUILD.gn @@ -58,7 +58,6 @@ ohos_shared_library("distributed_screen_source") { ] deps = [ - ":dscreensrc.cfg", "${common_path}:distributed_screen_utils", "${mediastandard_path}/interfaces/inner_api/native:media_client", "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans", @@ -85,10 +84,3 @@ ohos_shared_library("distributed_screen_source") { part_name = "distributed_screen" } - -ohos_prebuilt_etc("dscreensrc.cfg") { - relative_install_dir = "init" - source = "dscreensrc.cfg" - part_name = "distributed_screen" - subsystem_name = "distributedhardware" -} From a3f3995dfdeb858f84b14d6ebdc6f92588b36a83 Mon Sep 17 00:00:00 2001 From: gaoqiang_strong Date: Wed, 20 Apr 2022 14:33:52 +0800 Subject: [PATCH 07/15] update. get SA in one process Signed-off-by: gaoqiang_strong --- sa_profile/BUILD.gn | 2 +- services/screenservice/sinkservice/BUILD.gn | 7 ------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/sa_profile/BUILD.gn b/sa_profile/BUILD.gn index 1789de8..e53ec81 100644 --- a/sa_profile/BUILD.gn +++ b/sa_profile/BUILD.gn @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//build/ohos/sa_profile/sa_profile.gni") +import("//build/ohos.gni") ohos_sa_profile("dscreen_sa_profile") { sources = [ diff --git a/services/screenservice/sinkservice/BUILD.gn b/services/screenservice/sinkservice/BUILD.gn index 40ef0fd..1b85c0e 100644 --- a/services/screenservice/sinkservice/BUILD.gn +++ b/services/screenservice/sinkservice/BUILD.gn @@ -81,10 +81,3 @@ ohos_shared_library("distributed_screen_sink") { part_name = "distributed_screen" } - -ohos_prebuilt_etc("dscreensink.cfg") { - relative_install_dir = "init" - source = "dscreensink.cfg" - part_name = "distributed_screen" - subsystem_name = "distributedhardware" -} From 625bbaedb1cd3b056e53c2a75d20e228722af4f7 Mon Sep 17 00:00:00 2001 From: gaoqiang_strong Date: Wed, 20 Apr 2022 18:22:41 +0800 Subject: [PATCH 08/15] remove session server when stop Signed-off-by: gaoqiang_strong --- sa_profile/BUILD.gn | 2 +- services/softbusadapter/src/softbus_adapter.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/sa_profile/BUILD.gn b/sa_profile/BUILD.gn index e53ec81..8d64abb 100644 --- a/sa_profile/BUILD.gn +++ b/sa_profile/BUILD.gn @@ -27,4 +27,4 @@ ohos_prebuilt_etc("dscreen.cfg") { source = "dscreen.cfg" part_name = "distributed_screen" subsystem_name = "distributedhardware" -} \ No newline at end of file +} diff --git a/services/softbusadapter/src/softbus_adapter.cpp b/services/softbusadapter/src/softbus_adapter.cpp index 540590b..29a1378 100644 --- a/services/softbusadapter/src/softbus_adapter.cpp +++ b/services/softbusadapter/src/softbus_adapter.cpp @@ -133,6 +133,12 @@ int32_t SoftbusAdapter::RemoveSoftbusSessionServer(const std::string &pkgname, c return ERR_DH_SCREEN_TRANS_ILLEGAL_OPERATION; } + int32_t ret = RemoveSessionServer(pkgname.c_str(), sessionName.c_str()); + if (ret != DH_SUCCESS) { + DHLOGE("%s: RemoveSessionServer failed.", LOG_TAG); + return ret; + } + mapSessionSet_[sessionName].erase(peerDevId); if (mapSessionSet_[sessionName].empty()) { mapSessionSet_.erase(sessionName); From bec5a47d07c1498ba2783779208add5a1c63763e Mon Sep 17 00:00:00 2001 From: gaoqiang_strong Date: Thu, 21 Apr 2022 15:20:51 +0800 Subject: [PATCH 09/15] modify format Signed-off-by: gaoqiang_strong --- .../screen_sink/include/callback/dscreen_sink_load_callback.h | 4 ++-- .../screen_sink/src/callback/dscreen_sink_load_callback.cpp | 2 +- .../include/callback/dscreen_source_load_callback.h | 4 ++-- .../src/callback/dscreen_source_load_callback.cpp | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/interfaces/innerkits/native_cpp/screen_sink/include/callback/dscreen_sink_load_callback.h b/interfaces/innerkits/native_cpp/screen_sink/include/callback/dscreen_sink_load_callback.h index 5bb267e..ef702d7 100644 --- a/interfaces/innerkits/native_cpp/screen_sink/include/callback/dscreen_sink_load_callback.h +++ b/interfaces/innerkits/native_cpp/screen_sink/include/callback/dscreen_sink_load_callback.h @@ -24,8 +24,8 @@ class DScreenSinkLoadCallback : public SystemAbilityLoadCallbackStub { public: explicit DScreenSinkLoadCallback(const std::string params); void OnLoadSystemAbilitySuccess(int32_t systemAbilityId, - const sptr &remoteObject); - void OnLoadSystemAbilityFail(int32_t systemAbilityId); + const sptr &remoteObject) override; + void OnLoadSystemAbilityFail(int32_t systemAbilityId) override; private: std::string params_; }; diff --git a/interfaces/innerkits/native_cpp/screen_sink/src/callback/dscreen_sink_load_callback.cpp b/interfaces/innerkits/native_cpp/screen_sink/src/callback/dscreen_sink_load_callback.cpp index ba1d2b3..b68c5eb 100644 --- a/interfaces/innerkits/native_cpp/screen_sink/src/callback/dscreen_sink_load_callback.cpp +++ b/interfaces/innerkits/native_cpp/screen_sink/src/callback/dscreen_sink_load_callback.cpp @@ -26,7 +26,7 @@ void DScreenSinkLoadCallback::OnLoadSystemAbilitySuccess( int32_t systemAbilityId, const sptr &remoteObject) { DHLOGI("load screen SA success, systemAbilityId:%d, remoteObject result:%s", - systemAbilityId, (remoteObject != nullptr) ? "true":"false"); + systemAbilityId, (remoteObject != nullptr) ? "true" : "false"); if (remoteObject == nullptr) { DHLOGE("remoteObject is nullptr"); return; diff --git a/interfaces/innerkits/native_cpp/screen_source/include/callback/dscreen_source_load_callback.h b/interfaces/innerkits/native_cpp/screen_source/include/callback/dscreen_source_load_callback.h index d47499a..ba89e48 100644 --- a/interfaces/innerkits/native_cpp/screen_source/include/callback/dscreen_source_load_callback.h +++ b/interfaces/innerkits/native_cpp/screen_source/include/callback/dscreen_source_load_callback.h @@ -24,8 +24,8 @@ class DScreenSourceLoadCallback : public SystemAbilityLoadCallbackStub { public: explicit DScreenSourceLoadCallback(const std::string params); void OnLoadSystemAbilitySuccess(int32_t systemAbilityId, - const sptr &remoteObject); - void OnLoadSystemAbilityFail(int32_t systemAbilityId); + const sptr &remoteObject) override; + void OnLoadSystemAbilityFail(int32_t systemAbilityId) override; private: std::string params_; }; diff --git a/interfaces/innerkits/native_cpp/screen_source/src/callback/dscreen_source_load_callback.cpp b/interfaces/innerkits/native_cpp/screen_source/src/callback/dscreen_source_load_callback.cpp index 8e26343..c2929c5 100644 --- a/interfaces/innerkits/native_cpp/screen_source/src/callback/dscreen_source_load_callback.cpp +++ b/interfaces/innerkits/native_cpp/screen_source/src/callback/dscreen_source_load_callback.cpp @@ -26,7 +26,7 @@ void DScreenSourceLoadCallback::OnLoadSystemAbilitySuccess( int32_t systemAbilityId, const sptr &remoteObject) { DHLOGI("load screen SA success, systemAbilityId:%d, remoteObject result:%s", - systemAbilityId, (remoteObject != nullptr) ? "true":"false"); + systemAbilityId, (remoteObject != nullptr) ? "true" : "false"); if (remoteObject == nullptr) { DHLOGE("remoteObject is nullptr"); return; From 239f0e7b0272aefb9e2b47a018e4e633e223beec Mon Sep 17 00:00:00 2001 From: gaoqiang_strong Date: Thu, 21 Apr 2022 19:51:37 +0800 Subject: [PATCH 10/15] modify format Signed-off-by: gaoqiang_strong --- .../screen_sink/include/callback/dscreen_sink_load_callback.h | 2 +- .../screen_sink/src/callback/dscreen_sink_load_callback.cpp | 2 +- .../include/callback/dscreen_source_load_callback.h | 2 +- .../screen_source/src/callback/dscreen_source_load_callback.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/interfaces/innerkits/native_cpp/screen_sink/include/callback/dscreen_sink_load_callback.h b/interfaces/innerkits/native_cpp/screen_sink/include/callback/dscreen_sink_load_callback.h index ef702d7..9249672 100644 --- a/interfaces/innerkits/native_cpp/screen_sink/include/callback/dscreen_sink_load_callback.h +++ b/interfaces/innerkits/native_cpp/screen_sink/include/callback/dscreen_sink_load_callback.h @@ -22,7 +22,7 @@ namespace OHOS { namespace DistributedHardware { class DScreenSinkLoadCallback : public SystemAbilityLoadCallbackStub { public: - explicit DScreenSinkLoadCallback(const std::string params); + explicit DScreenSinkLoadCallback(const std::string ¶ms); void OnLoadSystemAbilitySuccess(int32_t systemAbilityId, const sptr &remoteObject) override; void OnLoadSystemAbilityFail(int32_t systemAbilityId) override; diff --git a/interfaces/innerkits/native_cpp/screen_sink/src/callback/dscreen_sink_load_callback.cpp b/interfaces/innerkits/native_cpp/screen_sink/src/callback/dscreen_sink_load_callback.cpp index b68c5eb..2911bce 100644 --- a/interfaces/innerkits/native_cpp/screen_sink/src/callback/dscreen_sink_load_callback.cpp +++ b/interfaces/innerkits/native_cpp/screen_sink/src/callback/dscreen_sink_load_callback.cpp @@ -20,7 +20,7 @@ namespace OHOS { namespace DistributedHardware { DScreenSinkLoadCallback::DScreenSinkLoadCallback( - const std::string params) : params_(params) {} + const std::string ¶ms) : params_(params) {} void DScreenSinkLoadCallback::OnLoadSystemAbilitySuccess( int32_t systemAbilityId, const sptr &remoteObject) diff --git a/interfaces/innerkits/native_cpp/screen_source/include/callback/dscreen_source_load_callback.h b/interfaces/innerkits/native_cpp/screen_source/include/callback/dscreen_source_load_callback.h index ba89e48..17688f1 100644 --- a/interfaces/innerkits/native_cpp/screen_source/include/callback/dscreen_source_load_callback.h +++ b/interfaces/innerkits/native_cpp/screen_source/include/callback/dscreen_source_load_callback.h @@ -22,7 +22,7 @@ namespace OHOS { namespace DistributedHardware { class DScreenSourceLoadCallback : public SystemAbilityLoadCallbackStub { public: - explicit DScreenSourceLoadCallback(const std::string params); + explicit DScreenSourceLoadCallback(const std::string ¶ms); void OnLoadSystemAbilitySuccess(int32_t systemAbilityId, const sptr &remoteObject) override; void OnLoadSystemAbilityFail(int32_t systemAbilityId) override; diff --git a/interfaces/innerkits/native_cpp/screen_source/src/callback/dscreen_source_load_callback.cpp b/interfaces/innerkits/native_cpp/screen_source/src/callback/dscreen_source_load_callback.cpp index c2929c5..9c7cdcb 100644 --- a/interfaces/innerkits/native_cpp/screen_source/src/callback/dscreen_source_load_callback.cpp +++ b/interfaces/innerkits/native_cpp/screen_source/src/callback/dscreen_source_load_callback.cpp @@ -20,7 +20,7 @@ namespace OHOS { namespace DistributedHardware { DScreenSourceLoadCallback::DScreenSourceLoadCallback( - const std::string params) : params_(params) {} + const std::string ¶ms) : params_(params) {} void DScreenSourceLoadCallback::OnLoadSystemAbilitySuccess( int32_t systemAbilityId, const sptr &remoteObject) From bdfa91d4023e6f410de8e85cea0c55e3a328af09 Mon Sep 17 00:00:00 2001 From: gaoqiang_strong Date: Fri, 22 Apr 2022 10:04:27 +0800 Subject: [PATCH 11/15] modify format Signed-off-by: gaoqiang_strong --- .../include/dscreen_sink_handler.h | 4 +-- .../screen_sink/src/dscreen_sink_handler.cpp | 26 +++++++++--------- .../include/dscreen_source_handler.h | 4 +-- .../src/dscreen_source_handler.cpp | 27 +++++++++---------- 4 files changed, 30 insertions(+), 31 deletions(-) diff --git a/interfaces/innerkits/native_cpp/screen_sink/include/dscreen_sink_handler.h b/interfaces/innerkits/native_cpp/screen_sink/include/dscreen_sink_handler.h index 2ba840d..a5238af 100644 --- a/interfaces/innerkits/native_cpp/screen_sink/include/dscreen_sink_handler.h +++ b/interfaces/innerkits/native_cpp/screen_sink/include/dscreen_sink_handler.h @@ -44,8 +44,8 @@ private: DScreenSinkHandler(); ~DScreenSinkHandler(); - std::mutex mutex_; - std::condition_variable conVar_; + std::mutex proxyMutex_; + std::condition_variable proxyConVar_; sptr dScreenSinkProxy_ = nullptr; sptr sinkSvrRecipient_ = nullptr; }; diff --git a/interfaces/innerkits/native_cpp/screen_sink/src/dscreen_sink_handler.cpp b/interfaces/innerkits/native_cpp/screen_sink/src/dscreen_sink_handler.cpp index 17319e1..75f06a0 100644 --- a/interfaces/innerkits/native_cpp/screen_sink/src/dscreen_sink_handler.cpp +++ b/interfaces/innerkits/native_cpp/screen_sink/src/dscreen_sink_handler.cpp @@ -30,7 +30,7 @@ IMPLEMENT_SINGLE_INSTANCE(DScreenSinkHandler); DScreenSinkHandler::DScreenSinkHandler() { DHLOGI("DScreenSinkHandler construct."); - std::lock_guard lock(mutex_); + std::lock_guard lock(proxyMutex_); if (!sinkSvrRecipient_) { sinkSvrRecipient_ = new DScreenSinkSvrRecipient(); } @@ -44,19 +44,16 @@ DScreenSinkHandler::~DScreenSinkHandler() int32_t DScreenSinkHandler::InitSink(const std::string ¶ms) { DHLOGD("InitSink"); - std::unique_lock lock(mutex_); + if (!dScreenSinkProxy_) { - sptr samgr = - SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); if (!samgr) { DHLOGE("Failed to get system ability mgr."); return ERR_DH_SCREEN_SA_GET_SAMGR_FAIL; } - sptr loadCallback = - new DScreenSinkLoadCallback(params); - int32_t ret = samgr->LoadSystemAbility( - DISTRIBUTED_HARDWARE_SCREEN_SINK_SA_ID, loadCallback); + sptr loadCallback = new DScreenSinkLoadCallback(params); + int32_t ret = samgr->LoadSystemAbility(DISTRIBUTED_HARDWARE_SCREEN_SINK_SA_ID, loadCallback); if (ret != ERR_OK) { DHLOGE("Failed to Load systemAbility, systemAbilityId:%d, ret code:%d", DISTRIBUTED_HARDWARE_SCREEN_SINK_SA_ID, ret); @@ -64,7 +61,8 @@ int32_t DScreenSinkHandler::InitSink(const std::string ¶ms) } } - auto waitStatus = conVar_.wait_for(lock, std::chrono::milliseconds(SCREEN_LOADSA_TIMEOUT_MS), + std::unique_lock lock(proxyMutex_); + auto waitStatus = proxyConVar_.wait_for(lock, std::chrono::milliseconds(SCREEN_LOADSA_TIMEOUT_MS), [this]() { return dScreenSinkProxy_; }); if (!waitStatus) { DHLOGE("screen load sa timeout"); @@ -78,6 +76,7 @@ void DScreenSinkHandler::FinishStartSA(const std::string params, const sptr &remoteObject) { DHLOGD("FinishStartSA"); + std::lock_guard lock(proxyMutex_); remoteObject->AddDeathRecipient(sinkSvrRecipient_); dScreenSinkProxy_ = iface_cast(remoteObject); if ((!dScreenSinkProxy_) || (!dScreenSinkProxy_->AsObject())) { @@ -85,12 +84,13 @@ void DScreenSinkHandler::FinishStartSA(const std::string params, return; } dScreenSinkProxy_->InitSink(params); + proxyConVar_.notify_one(); } int32_t DScreenSinkHandler::ReleaseSink() { DHLOGD("ReleaseSink"); - std::lock_guard lock(mutex_); + std::lock_guard lock(proxyMutex_); if (!dScreenSinkProxy_) { DHLOGE("screen sink proxy not init."); return ERR_DH_SCREEN_SA_SINKPROXY_NOT_INIT; @@ -104,7 +104,7 @@ int32_t DScreenSinkHandler::ReleaseSink() int32_t DScreenSinkHandler::SubscribeLocalHardware(const std::string &dhId, const std::string ¶m) { DHLOGD("SubscribeLocalHardware"); - std::lock_guard lock(mutex_); + std::lock_guard lock(proxyMutex_); if (!dScreenSinkProxy_) { DHLOGE("screen sink proxy not init."); return ERR_DH_SCREEN_SA_SINKPROXY_NOT_INIT; @@ -116,7 +116,7 @@ int32_t DScreenSinkHandler::SubscribeLocalHardware(const std::string &dhId, cons int32_t DScreenSinkHandler::UnsubscribeLocalHardware(const std::string &dhId) { DHLOGD("UnsubscribeLocalHardware"); - std::lock_guard lock(mutex_); + std::lock_guard lock(proxyMutex_); if (!dScreenSinkProxy_) { DHLOGE("screen sink proxy not init."); return ERR_DH_SCREEN_SA_SINKPROXY_NOT_INIT; @@ -139,7 +139,7 @@ void DScreenSinkHandler::OnRemoteSinkSvrDied(const wptr &remote) DHLOGE("OnRemoteDied remote promoted failed"); return; } - std::lock_guard lock(mutex_); + std::lock_guard lock(proxyMutex_); if (!dScreenSinkProxy_) { dScreenSinkProxy_->AsObject()->RemoveDeathRecipient(sinkSvrRecipient_); dScreenSinkProxy_ = nullptr; diff --git a/interfaces/innerkits/native_cpp/screen_source/include/dscreen_source_handler.h b/interfaces/innerkits/native_cpp/screen_source/include/dscreen_source_handler.h index bc7e488..b26f9e6 100644 --- a/interfaces/innerkits/native_cpp/screen_source/include/dscreen_source_handler.h +++ b/interfaces/innerkits/native_cpp/screen_source/include/dscreen_source_handler.h @@ -48,8 +48,8 @@ private: DScreenSourceHandler(); ~DScreenSourceHandler(); - std::mutex mutex_; - std::condition_variable conVar_; + std::mutex proxyMutex_; + std::condition_variable proxyConVar_; sptr dScreenSourceProxy_ = nullptr; sptr dScreenSourceCallback_ = nullptr; sptr sourceSvrRecipient_ = nullptr; diff --git a/interfaces/innerkits/native_cpp/screen_source/src/dscreen_source_handler.cpp b/interfaces/innerkits/native_cpp/screen_source/src/dscreen_source_handler.cpp index 83299ae..f40d07e 100644 --- a/interfaces/innerkits/native_cpp/screen_source/src/dscreen_source_handler.cpp +++ b/interfaces/innerkits/native_cpp/screen_source/src/dscreen_source_handler.cpp @@ -31,7 +31,7 @@ IMPLEMENT_SINGLE_INSTANCE(DScreenSourceHandler); DScreenSourceHandler::DScreenSourceHandler() { DHLOGI("DScreenSourceHandler construct."); - std::lock_guard lock(mutex_); + std::lock_guard lock(proxyMutex_); if (!sourceSvrRecipient_) { sourceSvrRecipient_ = new DScreenSourceSvrRecipient(); } @@ -49,19 +49,15 @@ DScreenSourceHandler::~DScreenSourceHandler() int32_t DScreenSourceHandler::InitSource(const std::string ¶ms) { DHLOGD("InitSource"); - std::unique_lock lock(mutex_); if (!dScreenSourceProxy_) { - sptr samgr = - SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); if (!samgr) { DHLOGE("Failed to get system ability mgr."); return ERR_DH_SCREEN_SA_GET_SAMGR_FAIL; } - sptr loadCallback = - new DScreenSourceLoadCallback(params); - int32_t ret = samgr->LoadSystemAbility( - DISTRIBUTED_HARDWARE_SCREEN_SOURCE_SA_ID, loadCallback); + sptr loadCallback = new DScreenSourceLoadCallback(params); + int32_t ret = samgr->LoadSystemAbility(DISTRIBUTED_HARDWARE_SCREEN_SOURCE_SA_ID, loadCallback); if (ret != ERR_OK) { DHLOGE("Failed to Load systemAbility, systemAbilityId:%d, ret code:%d", DISTRIBUTED_HARDWARE_SCREEN_SOURCE_SA_ID, ret); @@ -69,8 +65,9 @@ int32_t DScreenSourceHandler::InitSource(const std::string ¶ms) } } - auto waitStatus = conVar_.wait_for(lock, std::chrono::milliseconds(SCREEN_LOADSA_TIMEOUT_MS), - [this]() { return dScreenSourceProxy_; }); + std::unique_lock lock(proxyMutex_); + auto waitStatus = proxyConVar_.wait_for(lock, std::chrono::milliseconds(SCREEN_LOADSA_TIMEOUT_MS), + [this]() { return (dScreenSourceProxy_ != nullptr); }); if (!waitStatus) { DHLOGE("screen load sa timeout."); return ERR_DH_SCREEN_SA_LOAD_TIMEOUT; @@ -83,6 +80,7 @@ void DScreenSourceHandler::FinishStartSA(const std::string params, const sptr &remoteObject) { DHLOGD("FinishStartSA"); + std::lock_guard lock(proxyMutex_); remoteObject->AddDeathRecipient(sourceSvrRecipient_); dScreenSourceProxy_ = iface_cast(remoteObject); if ((!dScreenSourceProxy_) || (!dScreenSourceProxy_->AsObject())) { @@ -90,12 +88,13 @@ void DScreenSourceHandler::FinishStartSA(const std::string params, return; } dScreenSourceProxy_->InitSource(params, dScreenSourceCallback_); + proxyConVar_.notify_one(); } int32_t DScreenSourceHandler::ReleaseSource() { DHLOGD("ReleaseSource"); - std::lock_guard lock(mutex_); + std::lock_guard lock(proxyMutex_); if (!dScreenSourceProxy_) { DHLOGE("screen source proxy not init."); return ERR_DH_SCREEN_SA_SOURCEPROXY_NOT_INIT; @@ -110,7 +109,7 @@ int32_t DScreenSourceHandler::RegisterDistributedHardware(const std::string &dev { DHLOGD("RegisterDistributedHardware, devId: %s, dhId: %s", GetAnonyString(devId).c_str(), GetAnonyString(dhId).c_str()); - std::lock_guard lock(mutex_); + std::lock_guard lock(proxyMutex_); if (!dScreenSourceProxy_) { DHLOGE("screen source proxy not init."); return ERR_DH_SCREEN_SA_SOURCEPROXY_NOT_INIT; @@ -131,7 +130,7 @@ int32_t DScreenSourceHandler::UnregisterDistributedHardware(const std::string &d { DHLOGD("UnregisterDistributedHardware, devId: %s, dhId: %s", GetAnonyString(devId).c_str(), GetAnonyString(dhId).c_str()); - std::lock_guard lock(mutex_); + std::lock_guard lock(proxyMutex_); if (!dScreenSourceProxy_) { DHLOGE("screen source proxy not init."); return ERR_DH_SCREEN_SA_SOURCEPROXY_NOT_INIT; @@ -168,7 +167,7 @@ void DScreenSourceHandler::OnRemoteSourceSvrDied(const wptr &remo DHLOGE("OnRemoteDied remote promoted failed"); return; } - std::lock_guard lock(mutex_); + std::lock_guard lock(proxyMutex_); if (!dScreenSourceProxy_) { dScreenSourceProxy_->AsObject()->RemoveDeathRecipient(sourceSvrRecipient_); dScreenSourceProxy_ = nullptr; From b9ff7a839486c5aa64d601120c252f3bd6794c36 Mon Sep 17 00:00:00 2001 From: gaoqiang_strong Date: Fri, 22 Apr 2022 10:11:30 +0800 Subject: [PATCH 12/15] modify format Signed-off-by: gaoqiang_strong --- .../native_cpp/screen_sink/src/dscreen_sink_handler.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/interfaces/innerkits/native_cpp/screen_sink/src/dscreen_sink_handler.cpp b/interfaces/innerkits/native_cpp/screen_sink/src/dscreen_sink_handler.cpp index 75f06a0..3aecab5 100644 --- a/interfaces/innerkits/native_cpp/screen_sink/src/dscreen_sink_handler.cpp +++ b/interfaces/innerkits/native_cpp/screen_sink/src/dscreen_sink_handler.cpp @@ -44,8 +44,6 @@ DScreenSinkHandler::~DScreenSinkHandler() int32_t DScreenSinkHandler::InitSink(const std::string ¶ms) { DHLOGD("InitSink"); - - if (!dScreenSinkProxy_) { sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); if (!samgr) { From 41b7ed6d98333536a9122185c4db410be8cbde5c Mon Sep 17 00:00:00 2001 From: gaoqiang_strong Date: Fri, 22 Apr 2022 10:20:51 +0800 Subject: [PATCH 13/15] modify format Signed-off-by: gaoqiang_strong --- .../native_cpp/screen_sink/src/dscreen_sink_handler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/innerkits/native_cpp/screen_sink/src/dscreen_sink_handler.cpp b/interfaces/innerkits/native_cpp/screen_sink/src/dscreen_sink_handler.cpp index 3aecab5..93b7172 100644 --- a/interfaces/innerkits/native_cpp/screen_sink/src/dscreen_sink_handler.cpp +++ b/interfaces/innerkits/native_cpp/screen_sink/src/dscreen_sink_handler.cpp @@ -61,7 +61,7 @@ int32_t DScreenSinkHandler::InitSink(const std::string ¶ms) std::unique_lock lock(proxyMutex_); auto waitStatus = proxyConVar_.wait_for(lock, std::chrono::milliseconds(SCREEN_LOADSA_TIMEOUT_MS), - [this]() { return dScreenSinkProxy_; }); + [this]() { return dScreenSinkProxy_ != nullptr; }); if (!waitStatus) { DHLOGE("screen load sa timeout"); return ERR_DH_SCREEN_SA_LOAD_TIMEOUT; From ef8416e3dc0718eafd9b2494ed36ba3e3050e89f Mon Sep 17 00:00:00 2001 From: gaoqiang_strong Date: Fri, 22 Apr 2022 17:21:34 +0800 Subject: [PATCH 14/15] get Sa dynamic Signed-off-by: gaoqiang_strong --- .../native_cpp/screen_sink/include/dscreen_sink_handler.h | 2 +- .../native_cpp/screen_sink/src/dscreen_sink_handler.cpp | 4 ++-- .../native_cpp/screen_source/include/dscreen_source_handler.h | 2 +- .../native_cpp/screen_source/src/dscreen_source_handler.cpp | 4 ++-- .../sinkservice/screenregionmgr/src/screenregion.cpp | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/interfaces/innerkits/native_cpp/screen_sink/include/dscreen_sink_handler.h b/interfaces/innerkits/native_cpp/screen_sink/include/dscreen_sink_handler.h index a5238af..400e510 100644 --- a/interfaces/innerkits/native_cpp/screen_sink/include/dscreen_sink_handler.h +++ b/interfaces/innerkits/native_cpp/screen_sink/include/dscreen_sink_handler.h @@ -34,7 +34,7 @@ public: int32_t SubscribeLocalHardware(const std::string &dhId, const std::string ¶m) override; int32_t UnsubscribeLocalHardware(const std::string &dhId) override; void OnRemoteSinkSvrDied(const wptr &remote); - void FinishStartSA(const std::string params, const sptr &remoteObject); + void FinishStartSA(const std::string ¶ms, const sptr &remoteObject); private: class DScreenSinkSvrRecipient : public IRemoteObject::DeathRecipient { public: diff --git a/interfaces/innerkits/native_cpp/screen_sink/src/dscreen_sink_handler.cpp b/interfaces/innerkits/native_cpp/screen_sink/src/dscreen_sink_handler.cpp index 93b7172..4039067 100644 --- a/interfaces/innerkits/native_cpp/screen_sink/src/dscreen_sink_handler.cpp +++ b/interfaces/innerkits/native_cpp/screen_sink/src/dscreen_sink_handler.cpp @@ -70,7 +70,7 @@ int32_t DScreenSinkHandler::InitSink(const std::string ¶ms) return DH_SUCCESS; } -void DScreenSinkHandler::FinishStartSA(const std::string params, +void DScreenSinkHandler::FinishStartSA(const std::string ¶ms, const sptr &remoteObject) { DHLOGD("FinishStartSA"); @@ -138,7 +138,7 @@ void DScreenSinkHandler::OnRemoteSinkSvrDied(const wptr &remote) return; } std::lock_guard lock(proxyMutex_); - if (!dScreenSinkProxy_) { + if (dScreenSinkProxy_ != nullptr) { dScreenSinkProxy_->AsObject()->RemoveDeathRecipient(sinkSvrRecipient_); dScreenSinkProxy_ = nullptr; } diff --git a/interfaces/innerkits/native_cpp/screen_source/include/dscreen_source_handler.h b/interfaces/innerkits/native_cpp/screen_source/include/dscreen_source_handler.h index b26f9e6..a602ab6 100644 --- a/interfaces/innerkits/native_cpp/screen_source/include/dscreen_source_handler.h +++ b/interfaces/innerkits/native_cpp/screen_source/include/dscreen_source_handler.h @@ -38,7 +38,7 @@ public: int32_t ConfigDistributedHardware(const std::string &devId, const std::string &dhId, const std::string &key, const std::string &value) override; void OnRemoteSourceSvrDied(const wptr &remote); - void FinishStartSA(const std::string params, const sptr &remoteObject); + void FinishStartSA(const std::string ¶ms, const sptr &remoteObject); private: class DScreenSourceSvrRecipient : public IRemoteObject::DeathRecipient { public: diff --git a/interfaces/innerkits/native_cpp/screen_source/src/dscreen_source_handler.cpp b/interfaces/innerkits/native_cpp/screen_source/src/dscreen_source_handler.cpp index f40d07e..50538e8 100644 --- a/interfaces/innerkits/native_cpp/screen_source/src/dscreen_source_handler.cpp +++ b/interfaces/innerkits/native_cpp/screen_source/src/dscreen_source_handler.cpp @@ -76,7 +76,7 @@ int32_t DScreenSourceHandler::InitSource(const std::string ¶ms) return DH_SUCCESS; } -void DScreenSourceHandler::FinishStartSA(const std::string params, +void DScreenSourceHandler::FinishStartSA(const std::string ¶ms, const sptr &remoteObject) { DHLOGD("FinishStartSA"); @@ -168,7 +168,7 @@ void DScreenSourceHandler::OnRemoteSourceSvrDied(const wptr &remo return; } std::lock_guard lock(proxyMutex_); - if (!dScreenSourceProxy_) { + if (dScreenSinkProxy_ != nullptr) { dScreenSourceProxy_->AsObject()->RemoveDeathRecipient(sourceSvrRecipient_); dScreenSourceProxy_ = nullptr; } diff --git a/services/screenservice/sinkservice/screenregionmgr/src/screenregion.cpp b/services/screenservice/sinkservice/screenregionmgr/src/screenregion.cpp index 9fdf73b..9352084 100644 --- a/services/screenservice/sinkservice/screenregionmgr/src/screenregion.cpp +++ b/services/screenservice/sinkservice/screenregionmgr/src/screenregion.cpp @@ -37,7 +37,7 @@ ScreenRegion::ScreenRegion(const std::string &remoteDevId, uint64_t screenId, ui ScreenRegion::~ScreenRegion() { DHLOGD("ScreenRegion deConstruct"); - if (!sinkTrans_) { + if (sinkTrans_ != nullptr) { sinkTrans_->Release(); } } From 0c1131650b8b815b078e840b91f184457b953adc Mon Sep 17 00:00:00 2001 From: gaoqiang_strong Date: Fri, 22 Apr 2022 17:43:05 +0800 Subject: [PATCH 15/15] get sa dynamic Signed-off-by: gaoqiang_strong --- .../native_cpp/screen_source/src/dscreen_source_handler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/innerkits/native_cpp/screen_source/src/dscreen_source_handler.cpp b/interfaces/innerkits/native_cpp/screen_source/src/dscreen_source_handler.cpp index 50538e8..a45b050 100644 --- a/interfaces/innerkits/native_cpp/screen_source/src/dscreen_source_handler.cpp +++ b/interfaces/innerkits/native_cpp/screen_source/src/dscreen_source_handler.cpp @@ -168,7 +168,7 @@ void DScreenSourceHandler::OnRemoteSourceSvrDied(const wptr &remo return; } std::lock_guard lock(proxyMutex_); - if (dScreenSinkProxy_ != nullptr) { + if (dScreenSourceProxy_ != nullptr) { dScreenSourceProxy_->AsObject()->RemoveDeathRecipient(sourceSvrRecipient_); dScreenSourceProxy_ = nullptr; }