From 7aec463fbf88ecee02d511ee9b99b0c4d41d84fc Mon Sep 17 00:00:00 2001 From: gaoqiang_strong Date: Wed, 13 Apr 2022 11:45:48 +0800 Subject: [PATCH 01/13] 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 | 2 + .../callback/dscreen_sink_load_callback.h | 33 +++++++++++++++ .../include/dscreen_sink_handler.h | 3 ++ .../callback/dscreen_sink_load_callback.cpp | 41 +++++++++++++++++++ .../screen_sink/src/dscreen_sink_handler.cpp | 40 ++++++++++++------ .../native_cpp/screen_source/BUILD.gn | 1 + .../callback/dscreen_source_load_callback.h | 33 +++++++++++++++ .../include/dscreen_source_handler.h | 3 ++ .../callback/dscreen_source_load_callback.cpp | 41 +++++++++++++++++++ .../src/dscreen_source_handler.cpp | 40 ++++++++++++------ services/screenservice/sinkservice/BUILD.gn | 8 ++++ .../src/dscreen_sink_service.cpp | 5 ++- .../screenservice/sinkservice/dscreensink.cfg | 10 +++++ services/screenservice/sourceservice/BUILD.gn | 8 ++++ .../src/dscreen_source_service.cpp | 1 + .../sourceservice/dscreensrc.cfg | 10 +++++ 18 files changed, 254 insertions(+), 27 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 cce75aab..f8c15f6e 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 a6101bbe..987e9195 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 bcbb3e9b..489a9d55 100644 --- a/interfaces/innerkits/native_cpp/screen_sink/BUILD.gn +++ b/interfaces/innerkits/native_cpp/screen_sink/BUILD.gn @@ -23,12 +23,14 @@ ohos_shared_library("distributed_screen_sink_sdk") { include_dirs += [ "include", + "include/callback", "${common_path}/include", ] sources = [ "src/dscreen_sink_handler.cpp", "src/dscreen_sink_proxy.cpp", + "src/callback/dscreen_sink_load_callback.cpp", ] deps = [ 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 00000000..868c5edd --- /dev/null +++ b/interfaces/innerkits/native_cpp/screen_sink/include/callback/dscreen_sink_load_callback.h @@ -0,0 +1,33 @@ +/* + * 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 152884de..2ba840d8 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 00000000..9b417650 --- /dev/null +++ b/interfaces/innerkits/native_cpp/screen_sink/src/callback/dscreen_sink_load_callback.cpp @@ -0,0 +1,41 @@ +/* + * 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) +{ + DHLOGE("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 8f4472cc..c695dd3d 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,33 @@ 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) +{ + 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 +92,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 fec91820..f08753a1 100644 --- a/interfaces/innerkits/native_cpp/screen_source/BUILD.gn +++ b/interfaces/innerkits/native_cpp/screen_source/BUILD.gn @@ -30,6 +30,7 @@ ohos_shared_library("distributed_screen_source_sdk") { sources = [ "src/dscreen_source_handler.cpp", "src/dscreen_source_proxy.cpp", + "src/callback/dscreen_source_load_callback.cpp", "src/callback/dscreen_source_callback_stub.cpp", "src/callback/dscreen_source_callback.cpp", ] 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 00000000..7fe3f898 --- /dev/null +++ b/interfaces/innerkits/native_cpp/screen_source/include/callback/dscreen_source_load_callback.h @@ -0,0 +1,33 @@ +/* + * 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 0ee40a01..bc7e488c 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 00000000..da6d728c --- /dev/null +++ b/interfaces/innerkits/native_cpp/screen_source/src/callback/dscreen_source_load_callback.cpp @@ -0,0 +1,41 @@ +/* + * 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) +{ + DHLOGE("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 ed5e3c0f..152a98cc 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,34 @@ 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 +97,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/services/screenservice/sinkservice/BUILD.gn b/services/screenservice/sinkservice/BUILD.gn index 0564cbda..463c78a4 100644 --- a/services/screenservice/sinkservice/BUILD.gn +++ b/services/screenservice/sinkservice/BUILD.gn @@ -60,6 +60,7 @@ ohos_shared_library("distributed_screen_sink") { "${services_path}/screenclient:distributed_screen_client", "//foundation/graphic/standard/frameworks/surface:surface", "${windowmanager_path}/dm:libdm", + ":dscreensink.cfg", ] defines = [ @@ -79,4 +80,11 @@ ohos_shared_library("distributed_screen_sink") { subsystem_name = "distributedhardware" part_name = "distributed_screen" +} + +ohos_prebuilt_etc("dscreensink.cfg"){ + relative_install_dir = "init" + source = "dscreensink.cfg" + part_name = "distributed_screen" + subsystem_name = "distributedhardware" } \ No newline at end of file diff --git a/services/screenservice/sinkservice/dscreenservice/src/dscreen_sink_service.cpp b/services/screenservice/sinkservice/dscreenservice/src/dscreen_sink_service.cpp index 643b4155..861a3c61 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(); + 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 00000000..d2b2a588 --- /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 922c9844..9ebee127 100644 --- a/services/screenservice/sourceservice/BUILD.gn +++ b/services/screenservice/sourceservice/BUILD.gn @@ -65,6 +65,7 @@ ohos_shared_library("distributed_screen_source") { "//foundation/graphic/standard/frameworks/surface:surface", "//foundation/graphic/standard/rosen/modules/render_service_client:librender_service_client", "//utils/native/base:utils", + ":dscreensrc.cfg", ] defines = [ @@ -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" +} \ No newline at end of file diff --git a/services/screenservice/sourceservice/dscreenservice/src/dscreen_source_service.cpp b/services/screenservice/sourceservice/dscreenservice/src/dscreen_source_service.cpp index e1cb0ef3..920f758c 100644 --- a/services/screenservice/sourceservice/dscreenservice/src/dscreen_source_service.cpp +++ b/services/screenservice/sourceservice/dscreenservice/src/dscreen_source_service.cpp @@ -93,6 +93,7 @@ int32_t DScreenSourceService::ReleaseSource() DHLOGE("UnInit DScreenManager failed. err: %d", ret); return ret; } + exit(0); return DH_SUCCESS; } diff --git a/services/screenservice/sourceservice/dscreensrc.cfg b/services/screenservice/sourceservice/dscreensrc.cfg new file mode 100644 index 00000000..90106d0a --- /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 -- Gitee From 703857441fa50c892310d2bed6311c223478b8fd Mon Sep 17 00:00:00 2001 From: gaoqiang_strong Date: Wed, 13 Apr 2022 11:55:51 +0800 Subject: [PATCH 02/13] modify framework load screen SA Signed-off-by: gaoqiang_strong --- .../include/callback/dscreen_sink_load_callback.h | 3 ++- .../src/callback/dscreen_sink_load_callback.cpp | 9 ++++++--- .../screen_sink/src/dscreen_sink_handler.cpp | 12 ++++++++---- .../include/callback/dscreen_source_load_callback.h | 3 ++- .../src/callback/dscreen_source_load_callback.cpp | 9 ++++++--- .../screen_source/src/dscreen_source_handler.cpp | 12 ++++++++---- 6 files changed, 32 insertions(+), 16 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 868c5edd..39fa230f 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 @@ -23,7 +23,8 @@ namespace DistributedHardware { class DScreenSinkLoadCallback : public SystemAbilityLoadCallbackStub { public: explicit DScreenSinkLoadCallback(const std::string params); - void OnLoadSystemAbilitySuccess(int32_t systemAbilityId, const sptr &remoteObject); + void OnLoadSystemAbilitySuccess(int32_t systemAbilityId, + const sptr &remoteObject); void OnLoadSystemAbilityFail(int32_t systemAbilityId); 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 9b417650..64ba2d86 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,11 +20,14 @@ namespace OHOS { namespace DistributedHardware { -DScreenSinkLoadCallback::DScreenSinkLoadCallback(const std::string params):params(params){} +DScreenSinkLoadCallback::DScreenSinkLoadCallback( + const std::string params) : params(params){} -void DScreenSinkLoadCallback::OnLoadSystemAbilitySuccess(int32_t systemAbilityId, const sptr &remoteObject) +void DScreenSinkLoadCallback::OnLoadSystemAbilitySuccess( + int32_t systemAbilityId, const sptr &remoteObject) { - DHLOGE("load screen SA success, systemAbilityId:%d, remoteObject result:%s", systemAbilityId, (remoteObject != nullptr) ? "true":"false"); + DHLOGE("load screen SA success, systemAbilityId:%d, remoteObject result:%s", + systemAbilityId, (remoteObject != nullptr) ? "true":"false"); if (remoteObject == nullptr) { DHLOGE("remoteObject is nullptr"); return; 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 c695dd3d..9eef2f62 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 @@ -53,10 +53,13 @@ int32_t DScreenSinkHandler::InitSink(const std::string ¶ms) 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); + 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; } } @@ -71,7 +74,8 @@ int32_t DScreenSinkHandler::InitSink(const std::string ¶ms) return DH_SUCCESS; } -void DScreenSinkHandler::FinishStartSA(const std::string params, const sptr &remoteObject) +void DScreenSinkHandler::FinishStartSA(const std::string params, + const sptr &remoteObject) { remoteObject->AddDeathRecipient(sinkSvrRecipient_); dScreenSinkProxy_ = iface_cast(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 7fe3f898..1ccd721e 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 @@ -23,7 +23,8 @@ namespace DistributedHardware { class DScreenSourceLoadCallback : public SystemAbilityLoadCallbackStub { public: explicit DScreenSourceLoadCallback(const std::string params); - void OnLoadSystemAbilitySuccess(int32_t systemAbilityId, const sptr &remoteObject); + void OnLoadSystemAbilitySuccess(int32_t systemAbilityId, + const sptr &remoteObject); void OnLoadSystemAbilityFail(int32_t systemAbilityId); 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 da6d728c..26c4f45a 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,11 +20,14 @@ namespace OHOS { namespace DistributedHardware { -DScreenSourceLoadCallback::DScreenSourceLoadCallback(const std::string params):params(params){} +DScreenSourceLoadCallback::DScreenSourceLoadCallback( + const std::string params) : params(params){} -void DScreenSourceLoadCallback::OnLoadSystemAbilitySuccess(int32_t systemAbilityId, const sptr &remoteObject) +void DScreenSourceLoadCallback::OnLoadSystemAbilitySuccess( + int32_t systemAbilityId, const sptr &remoteObject) { - DHLOGE("load screen SA success, systemAbilityId:%d, remoteObject result:%s", systemAbilityId, (remoteObject != nullptr) ? "true":"false"); + DHLOGE("load screen SA success, systemAbilityId:%d, remoteObject result:%s", + systemAbilityId, (remoteObject != nullptr) ? "true":"false"); if (remoteObject == nullptr) { DHLOGE("remoteObject is nullptr"); return; 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 152a98cc..9677438e 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 @@ -58,10 +58,13 @@ int32_t DScreenSourceHandler::InitSource(const std::string ¶ms) 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); + 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; } } @@ -76,7 +79,8 @@ int32_t DScreenSourceHandler::InitSource(const std::string ¶ms) return DH_SUCCESS; } -void DScreenSourceHandler::FinishStartSA(const std::string params, const sptr &remoteObject) +void DScreenSourceHandler::FinishStartSA(const std::string params, + const sptr &remoteObject) { DHLOGD("FinishStartSA"); remoteObject->AddDeathRecipient(sourceSvrRecipient_); -- Gitee From 3924cda5fc903d07ef5ed997af274e8ad1bb9bca Mon Sep 17 00:00:00 2001 From: gaoqiang_strong Date: Wed, 13 Apr 2022 12:56:22 +0800 Subject: [PATCH 03/13] check format Signed-off-by: gaoqiang_strong --- interfaces/innerkits/native_cpp/screen_sink/BUILD.gn | 2 +- .../screen_sink/src/callback/dscreen_sink_load_callback.cpp | 4 +--- .../native_cpp/screen_sink/src/dscreen_sink_handler.cpp | 1 + .../src/callback/dscreen_source_load_callback.cpp | 4 +--- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/interfaces/innerkits/native_cpp/screen_sink/BUILD.gn b/interfaces/innerkits/native_cpp/screen_sink/BUILD.gn index 489a9d55..2e0717d5 100644 --- a/interfaces/innerkits/native_cpp/screen_sink/BUILD.gn +++ b/interfaces/innerkits/native_cpp/screen_sink/BUILD.gn @@ -28,9 +28,9 @@ ohos_shared_library("distributed_screen_sink_sdk") { ] sources = [ + "src/callback/dscreen_sink_load_callback.cpp", "src/dscreen_sink_handler.cpp", "src/dscreen_sink_proxy.cpp", - "src/callback/dscreen_sink_load_callback.cpp", ] deps = [ 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 64ba2d86..b90c0042 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 @@ -19,14 +19,13 @@ namespace OHOS { namespace DistributedHardware { - DScreenSinkLoadCallback::DScreenSinkLoadCallback( const std::string params) : params(params){} void DScreenSinkLoadCallback::OnLoadSystemAbilitySuccess( int32_t systemAbilityId, const sptr &remoteObject) { - DHLOGE("load screen SA success, systemAbilityId:%d, remoteObject result:%s", + DHLOGI("load screen SA success, systemAbilityId:%d, remoteObject result:%s", systemAbilityId, (remoteObject != nullptr) ? "true":"false"); if (remoteObject == nullptr) { DHLOGE("remoteObject is nullptr"); @@ -39,6 +38,5 @@ 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 9eef2f62..7e45604f 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 @@ -77,6 +77,7 @@ int32_t DScreenSinkHandler::InitSink(const std::string ¶ms) void DScreenSinkHandler::FinishStartSA(const std::string params, const sptr &remoteObject) { + DHLOGD("FinishStartSA"); remoteObject->AddDeathRecipient(sinkSvrRecipient_); dScreenSinkProxy_ = iface_cast(remoteObject); if ((!dScreenSinkProxy_) || (!dScreenSinkProxy_->AsObject())) { 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 26c4f45a..6e65d4b0 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 @@ -19,14 +19,13 @@ namespace OHOS { namespace DistributedHardware { - DScreenSourceLoadCallback::DScreenSourceLoadCallback( const std::string params) : params(params){} void DScreenSourceLoadCallback::OnLoadSystemAbilitySuccess( int32_t systemAbilityId, const sptr &remoteObject) { - DHLOGE("load screen SA success, systemAbilityId:%d, remoteObject result:%s", + DHLOGI("load screen SA success, systemAbilityId:%d, remoteObject result:%s", systemAbilityId, (remoteObject != nullptr) ? "true":"false"); if (remoteObject == nullptr) { DHLOGE("remoteObject is nullptr"); @@ -39,6 +38,5 @@ void DScreenSourceLoadCallback::OnLoadSystemAbilityFail(int32_t systemAbilityId) { DHLOGE("load screen SA failed, systemAbilityId:%d", systemAbilityId); } - } } -- Gitee From 88a0d2901243d533ae0991b4645db5d2df3ab8b2 Mon Sep 17 00:00:00 2001 From: gaoqiang_strong Date: Wed, 13 Apr 2022 12:58:02 +0800 Subject: [PATCH 04/13] check format Signed-off-by: gaoqiang_strong --- .../screen_sink/src/callback/dscreen_sink_load_callback.cpp | 1 + .../screen_source/src/callback/dscreen_source_load_callback.cpp | 1 + 2 files changed, 2 insertions(+) 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 b90c0042..f5808f8b 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 @@ -34,6 +34,7 @@ void DScreenSinkLoadCallback::OnLoadSystemAbilitySuccess( DScreenSinkHandler::GetInstance().FinishStartSA(params, remoteObject); } + void DScreenSinkLoadCallback::OnLoadSystemAbilityFail(int32_t systemAbilityId) { DHLOGE("load screen SA failed, systemAbilityId:%d", systemAbilityId); 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 6e65d4b0..4add4b37 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 @@ -34,6 +34,7 @@ void DScreenSourceLoadCallback::OnLoadSystemAbilitySuccess( DScreenSourceHandler::GetInstance().FinishStartSA(params, remoteObject); } + void DScreenSourceLoadCallback::OnLoadSystemAbilityFail(int32_t systemAbilityId) { DHLOGE("load screen SA failed, systemAbilityId:%d", systemAbilityId); -- Gitee From be77680a4a96197e228764f2099565b7b76acea6 Mon Sep 17 00:00:00 2001 From: gaoqiang_strong Date: Wed, 13 Apr 2022 13:08:41 +0800 Subject: [PATCH 05/13] check format Signed-off-by: gaoqiang_strong --- .../screen_sink/src/callback/dscreen_sink_load_callback.cpp | 2 +- .../screen_source/src/callback/dscreen_source_load_callback.cpp | 2 +- .../sinkservice/dscreenservice/src/dscreen_sink_service.cpp | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) 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 f5808f8b..3fac4eba 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 params) : params(params) {} void DScreenSinkLoadCallback::OnLoadSystemAbilitySuccess( int32_t systemAbilityId, const sptr &remoteObject) 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 4add4b37..db95c540 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 params) : params(params) {} void DScreenSourceLoadCallback::OnLoadSystemAbilitySuccess( int32_t systemAbilityId, const sptr &remoteObject) diff --git a/services/screenservice/sinkservice/dscreenservice/src/dscreen_sink_service.cpp b/services/screenservice/sinkservice/dscreenservice/src/dscreen_sink_service.cpp index 861a3c61..24b6d09b 100644 --- a/services/screenservice/sinkservice/dscreenservice/src/dscreen_sink_service.cpp +++ b/services/screenservice/sinkservice/dscreenservice/src/dscreen_sink_service.cpp @@ -79,7 +79,6 @@ int32_t DScreenSinkService::ReleaseSink() ScreenRegionManager::GetInstance().ReleaseAllRegions(); exit(0); return DH_SUCCESS; - } int32_t DScreenSinkService::SubscribeLocalHardware(const std::string &dhId, const std::string ¶m) -- Gitee From ebe087542f59e50617eb30aabae78c93b07a29bd Mon Sep 17 00:00:00 2001 From: gaoqiang_strong Date: Wed, 13 Apr 2022 13:23:44 +0800 Subject: [PATCH 06/13] check format Signed-off-by: gaoqiang_strong --- .../innerkits/native_cpp/screen_sink/BUILD.gn | 79 ++++++++++--------- 1 file changed, 40 insertions(+), 39 deletions(-) diff --git a/interfaces/innerkits/native_cpp/screen_sink/BUILD.gn b/interfaces/innerkits/native_cpp/screen_sink/BUILD.gn index 2e0717d5..9cd53e18 100644 --- a/interfaces/innerkits/native_cpp/screen_sink/BUILD.gn +++ b/interfaces/innerkits/native_cpp/screen_sink/BUILD.gn @@ -13,45 +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 += [ - "include", - "include/callback", - "${common_path}/include", - ] - - 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", - ] - - 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", - ] - - subsystem_name = "distributedhardware" - - part_name = "distributed_screen" + include_dirs = [ + "//utils/system/safwk/native/include", + "${fwk_common_path}/utils/include", + ] + + include_dirs += [ + "include", + "include/callback", + "${common_path}/include", + ] + + sources = [ + "src/callback/dscreen_sink_load_callback.cpp", + "src/dscreen_sink_handler.cpp", + "src/dscreen_sink_proxy.cpp", + ] + + deps = [ + "${common_path}:distributed_screen_utils", + "//utils/native/base:utils", + ] + + 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", + ] + + subsystem_name = "distributedhardware" + + part_name = "distributed_screen" } \ No newline at end of file -- Gitee From 5ca047ce49133ed33b5a7e2f445578357ade2e43 Mon Sep 17 00:00:00 2001 From: gaoqiang_strong Date: Wed, 13 Apr 2022 13:56:15 +0800 Subject: [PATCH 07/13] check format Signed-off-by: gaoqiang_strong --- .../innerkits/native_cpp/screen_sink/BUILD.gn | 79 +++++++++---------- 1 file changed, 39 insertions(+), 40 deletions(-) diff --git a/interfaces/innerkits/native_cpp/screen_sink/BUILD.gn b/interfaces/innerkits/native_cpp/screen_sink/BUILD.gn index 9cd53e18..489a9d55 100644 --- a/interfaces/innerkits/native_cpp/screen_sink/BUILD.gn +++ b/interfaces/innerkits/native_cpp/screen_sink/BUILD.gn @@ -13,46 +13,45 @@ 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 += [ - "include", - "include/callback", - "${common_path}/include", - ] - - sources = [ - "src/callback/dscreen_sink_load_callback.cpp", - "src/dscreen_sink_handler.cpp", - "src/dscreen_sink_proxy.cpp", - ] - - deps = [ - "${common_path}:distributed_screen_utils", - "//utils/native/base:utils", - ] - - 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", - ] - - subsystem_name = "distributedhardware" - - part_name = "distributed_screen" + include_dirs = [ + "//utils/system/safwk/native/include", + "${fwk_common_path}/utils/include", + ] + + include_dirs += [ + "include", + "include/callback", + "${common_path}/include", + ] + + sources = [ + "src/dscreen_sink_handler.cpp", + "src/dscreen_sink_proxy.cpp", + "src/callback/dscreen_sink_load_callback.cpp", + ] + + deps = [ + "//utils/native/base:utils", + "${common_path}:distributed_screen_utils", + ] + + 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", + ] + + subsystem_name = "distributedhardware" + + part_name = "distributed_screen" } \ No newline at end of file -- Gitee From e306a7f84f44dee720810276cc49148f9dd5208d Mon Sep 17 00:00:00 2001 From: gaoqiang_strong Date: Wed, 13 Apr 2022 14:11:30 +0800 Subject: [PATCH 08/13] modify framework load screen SA Signed-off-by: gaoqiang_strong --- sa_profile/4807.xml | 54 +++++++++---------- sa_profile/4808.xml | 54 +++++++++---------- .../screenservice/sinkservice/dscreensink.cfg | 18 +++---- .../sourceservice/dscreensrc.cfg | 18 +++---- 4 files changed, 72 insertions(+), 72 deletions(-) diff --git a/sa_profile/4807.xml b/sa_profile/4807.xml index f3f552e2..776d9816 100644 --- a/sa_profile/4807.xml +++ b/sa_profile/4807.xml @@ -1,27 +1,27 @@ - - - - dhardware - - 4807 - libdistributed_screen_source.z.so - - - true - true - 1 - - + + + + dscreensrc + + 4807 + libdistributed_screen_source.z.so + + + false + true + 1 + + diff --git a/sa_profile/4808.xml b/sa_profile/4808.xml index 6ec95fd4..857162eb 100644 --- a/sa_profile/4808.xml +++ b/sa_profile/4808.xml @@ -1,27 +1,27 @@ - - - - dhardware - - 4808 - libdistributed_screen_sink.z.so - - - true - true - 1 - - + + + + dscreensink + + 4808 + libdistributed_screen_sink.z.so + + + false + true + 1 + + diff --git a/services/screenservice/sinkservice/dscreensink.cfg b/services/screenservice/sinkservice/dscreensink.cfg index d2b2a588..45401cb2 100644 --- a/services/screenservice/sinkservice/dscreensink.cfg +++ b/services/screenservice/sinkservice/dscreensink.cfg @@ -1,10 +1,10 @@ -{ - "services":[{ - "name":"dscreensink", - "dynamic":true, - "path":["/system/bin/sa_main","system/profile/dscreensink.xml"], - "uid":"system", - "gid":["system"], - "ondemand":true - }] +{ + "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/dscreensrc.cfg b/services/screenservice/sourceservice/dscreensrc.cfg index 90106d0a..e6af45ba 100644 --- a/services/screenservice/sourceservice/dscreensrc.cfg +++ b/services/screenservice/sourceservice/dscreensrc.cfg @@ -1,10 +1,10 @@ -{ - "services":[{ - "name":"dscreensrc", - "dynamic":true, - "path":["/system/bin/sa_main","system/profile/dscreensrc.xml"], - "uid":"system", - "gid":["system"], - "ondemand":true - }] +{ + "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 -- Gitee From ed471d21471da7562bdd0db9c0609c22b9cbea6d Mon Sep 17 00:00:00 2001 From: gaoqiang_strong Date: Wed, 13 Apr 2022 14:38:28 +0800 Subject: [PATCH 09/13] modify gn format Signed-off-by: gaoqiang_strong --- .../innerkits/native_cpp/screen_sink/BUILD.gn | 81 ++++++++++--------- 1 file changed, 41 insertions(+), 40 deletions(-) diff --git a/interfaces/innerkits/native_cpp/screen_sink/BUILD.gn b/interfaces/innerkits/native_cpp/screen_sink/BUILD.gn index 489a9d55..adc10a54 100644 --- a/interfaces/innerkits/native_cpp/screen_sink/BUILD.gn +++ b/interfaces/innerkits/native_cpp/screen_sink/BUILD.gn @@ -13,45 +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 += [ - "include", - "include/callback", - "${common_path}/include", - ] - - sources = [ - "src/dscreen_sink_handler.cpp", - "src/dscreen_sink_proxy.cpp", - "src/callback/dscreen_sink_load_callback.cpp", - ] - - deps = [ - "//utils/native/base:utils", - "${common_path}:distributed_screen_utils", - ] - - 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", - ] - - subsystem_name = "distributedhardware" - - part_name = "distributed_screen" -} \ No newline at end of file + include_dirs = [ + "//utils/system/safwk/native/include", + "${fwk_common_path}/utils/include", + ] + + include_dirs += [ + "include", + "include/callback", + "${common_path}/include", + ] + + sources = [ + "src/callback/dscreen_sink_load_callback.cpp", + "src/dscreen_sink_handler.cpp", + "src/dscreen_sink_proxy.cpp", + ] + + deps = [ + "${common_path}:distributed_screen_utils", + "//utils/native/base:utils", + ] + + 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", + ] + + subsystem_name = "distributedhardware" + + part_name = "distributed_screen" +} -- Gitee From 6e0a7ea874af3c95659820ff9b9173f30165d506 Mon Sep 17 00:00:00 2001 From: gaoqiang_strong Date: Wed, 13 Apr 2022 14:57:20 +0800 Subject: [PATCH 10/13] modify gn format Signed-off-by: gaoqiang_strong --- .../native_cpp/screen_source/BUILD.gn | 87 ++++++------ services/screenservice/sinkservice/BUILD.gn | 131 +++++++++--------- services/screenservice/sourceservice/BUILD.gn | 16 +-- 3 files changed, 118 insertions(+), 116 deletions(-) diff --git a/interfaces/innerkits/native_cpp/screen_source/BUILD.gn b/interfaces/innerkits/native_cpp/screen_source/BUILD.gn index f08753a1..e9847258 100644 --- a/interfaces/innerkits/native_cpp/screen_source/BUILD.gn +++ b/interfaces/innerkits/native_cpp/screen_source/BUILD.gn @@ -9,51 +9,52 @@ # 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. +# limitations under the License. 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 += [ - "include", - "include/callback", - "${common_path}/include", - ] - - sources = [ - "src/dscreen_source_handler.cpp", - "src/dscreen_source_proxy.cpp", - "src/callback/dscreen_source_load_callback.cpp", - "src/callback/dscreen_source_callback_stub.cpp", - "src/callback/dscreen_source_callback.cpp", - ] - - deps = [ - "//utils/native/base:utils", - "${common_path}:distributed_screen_utils", - ] - - 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", - ] - - subsystem_name = "distributedhardware" - - part_name = "distributed_screen" -} \ No newline at end of file + include_dirs = [ + "//utils/system/safwk/native/include", + "${fwk_common_path}/utils/include", + ] + + include_dirs += [ + "include", + "include/callback", + "${common_path}/include", + ] + + 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 = [ + "${common_path}:distributed_screen_utils", + "//utils/native/base:utils", + ] + + 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", + ] + + subsystem_name = "distributedhardware" + + part_name = "distributed_screen" +} diff --git a/services/screenservice/sinkservice/BUILD.gn b/services/screenservice/sinkservice/BUILD.gn index 463c78a4..aae25a60 100644 --- a/services/screenservice/sinkservice/BUILD.gn +++ b/services/screenservice/sinkservice/BUILD.gn @@ -9,82 +9,83 @@ # 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. +# limitations under the License. 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", - ":dscreensink.cfg", - ] + 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" + part_name = "distributed_screen" } -ohos_prebuilt_etc("dscreensink.cfg"){ - relative_install_dir = "init" - source = "dscreensink.cfg" - part_name = "distributed_screen" - subsystem_name = "distributedhardware" -} \ No newline at end of file +ohos_prebuilt_etc("dscreensink.cfg") { + relative_install_dir = "init" + source = "dscreensink.cfg" + part_name = "distributed_screen" + subsystem_name = "distributedhardware" +} diff --git a/services/screenservice/sourceservice/BUILD.gn b/services/screenservice/sourceservice/BUILD.gn index 9ebee127..32e7a091 100644 --- a/services/screenservice/sourceservice/BUILD.gn +++ b/services/screenservice/sourceservice/BUILD.gn @@ -9,7 +9,7 @@ # 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. +# limitations under the License. import("//build/ohos.gni") import("//build/ohos_var.gni") @@ -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", @@ -65,7 +66,6 @@ ohos_shared_library("distributed_screen_source") { "//foundation/graphic/standard/frameworks/surface:surface", "//foundation/graphic/standard/rosen/modules/render_service_client:librender_service_client", "//utils/native/base:utils", - ":dscreensrc.cfg", ] defines = [ @@ -86,9 +86,9 @@ 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" -} \ No newline at end of file +ohos_prebuilt_etc("dscreensrc.cfg") { + relative_install_dir = "init" + source = "dscreensrc.cfg" + part_name = "distributed_screen" + subsystem_name = "distributedhardware" +} -- Gitee From 51e6f4cc6e12acada05f805d397e67459d507b77 Mon Sep 17 00:00:00 2001 From: gaoqiang_strong Date: Wed, 13 Apr 2022 16:31:58 +0800 Subject: [PATCH 11/13] modfiy Signed-off-by: gaoqiang_strong --- .../screen_sink/src/dscreen_sink_handler.cpp | 308 +++++++-------- .../src/dscreen_source_handler.cpp | 366 +++++++++--------- 2 files changed, 337 insertions(+), 337 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 7e45604f..eb509b24 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 @@ -1,155 +1,155 @@ -/* - * 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_handler.h" - -#include "if_system_ability_manager.h" -#include "iservice_registry.h" - -#include "dscreen_constants.h" -#include "dscreen_errcode.h" -#include "dscreen_log.h" -#include "dscreen_sink_load_callback.h" - -namespace OHOS { -namespace DistributedHardware { -IMPLEMENT_SINGLE_INSTANCE(DScreenSinkHandler); - -DScreenSinkHandler::DScreenSinkHandler() -{ - DHLOGI("DScreenSinkHandler construct."); - std::lock_guard lock(mutex_); - if (!sinkSvrRecipient_) { - sinkSvrRecipient_ = new DScreenSinkSvrRecipient(); - } -} - -DScreenSinkHandler::~DScreenSinkHandler() -{ - DHLOGI("~DScreenSinkHandler."); -} - -int32_t DScreenSinkHandler::InitSink(const std::string ¶ms) -{ - DHLOGD("InitSink"); - std::unique_lock lock(mutex_); - - if (!dScreenSinkProxy_) { - 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); - 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; - } - } - - 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() -{ - DHLOGD("ReleaseSink"); - std::lock_guard lock(mutex_); - if (!dScreenSinkProxy_) { - DHLOGE("screen sink proxy not init."); - return ERR_DH_SCREEN_SA_SINKPROXY_NOT_INIT; - } - - int32_t ret = dScreenSinkProxy_->ReleaseSink(); - dScreenSinkProxy_ = nullptr; - return ret; -} - -int32_t DScreenSinkHandler::SubscribeLocalHardware(const std::string &dhId, const std::string ¶m) -{ - DHLOGD("SubscribeLocalHardware"); - std::lock_guard lock(mutex_); - if (!dScreenSinkProxy_) { - DHLOGE("screen sink proxy not init."); - return ERR_DH_SCREEN_SA_SINKPROXY_NOT_INIT; - } - int32_t ret = dScreenSinkProxy_->SubscribeLocalHardware(dhId, param); - return ret; -} - -int32_t DScreenSinkHandler::UnsubscribeLocalHardware(const std::string &dhId) -{ - DHLOGD("UnsubscribeLocalHardware"); - std::lock_guard lock(mutex_); - if (!dScreenSinkProxy_) { - DHLOGE("screen sink proxy not init."); - return ERR_DH_SCREEN_SA_SINKPROXY_NOT_INIT; - } - int32_t ret = dScreenSinkProxy_->UnsubscribeLocalHardware(dhId); - return ret; -} - -void DScreenSinkHandler::DScreenSinkSvrRecipient::OnRemoteDied(const wptr &remote) -{ - DHLOGI("DScreenSinkSvrRecipient OnRemoteDied."); - DScreenSinkHandler::GetInstance().OnRemoteSinkSvrDied(remote); -} - -void DScreenSinkHandler::OnRemoteSinkSvrDied(const wptr &remote) -{ - DHLOGI("OnRemoteSinkSvrDied"); - sptr remoteObject = remote.promote(); - if (!remoteObject) { - DHLOGE("OnRemoteDied remote promoted failed"); - return; - } - std::lock_guard lock(mutex_); - if (!dScreenSinkProxy_) { - dScreenSinkProxy_->AsObject()->RemoveDeathRecipient(sinkSvrRecipient_); - dScreenSinkProxy_ = nullptr; - } -} - -IDistributedHardwareSink *GetSinkHardwareHandler() -{ - DHLOGD("GetSinkHardwareHandler"); - return &DScreenSinkHandler::GetInstance(); -} -} // namespace DistributedHardware +/* + * 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_handler.h" + +#include "if_system_ability_manager.h" +#include "iservice_registry.h" + +#include "dscreen_constants.h" +#include "dscreen_errcode.h" +#include "dscreen_log.h" +#include "dscreen_sink_load_callback.h" + +namespace OHOS { +namespace DistributedHardware { +IMPLEMENT_SINGLE_INSTANCE(DScreenSinkHandler); + +DScreenSinkHandler::DScreenSinkHandler() +{ + DHLOGI("DScreenSinkHandler construct."); + std::lock_guard lock(mutex_); + if (!sinkSvrRecipient_) { + sinkSvrRecipient_ = new DScreenSinkSvrRecipient(); + } +} + +DScreenSinkHandler::~DScreenSinkHandler() +{ + DHLOGI("~DScreenSinkHandler."); +} + +int32_t DScreenSinkHandler::InitSink(const std::string ¶ms) +{ + DHLOGD("InitSink"); + std::unique_lock lock(mutex_); + + if (!dScreenSinkProxy_) { + 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); + 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; + } + } + + 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() +{ + DHLOGD("ReleaseSink"); + std::lock_guard lock(mutex_); + if (!dScreenSinkProxy_) { + DHLOGE("screen sink proxy not init."); + return ERR_DH_SCREEN_SA_SINKPROXY_NOT_INIT; + } + + int32_t ret = dScreenSinkProxy_->ReleaseSink(); + dScreenSinkProxy_ = nullptr; + return ret; +} + +int32_t DScreenSinkHandler::SubscribeLocalHardware(const std::string &dhId, const std::string ¶m) +{ + DHLOGD("SubscribeLocalHardware"); + std::lock_guard lock(mutex_); + if (!dScreenSinkProxy_) { + DHLOGE("screen sink proxy not init."); + return ERR_DH_SCREEN_SA_SINKPROXY_NOT_INIT; + } + int32_t ret = dScreenSinkProxy_->SubscribeLocalHardware(dhId, param); + return ret; +} + +int32_t DScreenSinkHandler::UnsubscribeLocalHardware(const std::string &dhId) +{ + DHLOGD("UnsubscribeLocalHardware"); + std::lock_guard lock(mutex_); + if (!dScreenSinkProxy_) { + DHLOGE("screen sink proxy not init."); + return ERR_DH_SCREEN_SA_SINKPROXY_NOT_INIT; + } + int32_t ret = dScreenSinkProxy_->UnsubscribeLocalHardware(dhId); + return ret; +} + +void DScreenSinkHandler::DScreenSinkSvrRecipient::OnRemoteDied(const wptr &remote) +{ + DHLOGI("DScreenSinkSvrRecipient OnRemoteDied."); + DScreenSinkHandler::GetInstance().OnRemoteSinkSvrDied(remote); +} + +void DScreenSinkHandler::OnRemoteSinkSvrDied(const wptr &remote) +{ + DHLOGI("OnRemoteSinkSvrDied"); + sptr remoteObject = remote.promote(); + if (!remoteObject) { + DHLOGE("OnRemoteDied remote promoted failed"); + return; + } + std::lock_guard lock(mutex_); + if (!dScreenSinkProxy_) { + dScreenSinkProxy_->AsObject()->RemoveDeathRecipient(sinkSvrRecipient_); + dScreenSinkProxy_ = nullptr; + } +} + +IDistributedHardwareSink *GetSinkHardwareHandler() +{ + DHLOGD("GetSinkHardwareHandler"); + return &DScreenSinkHandler::GetInstance(); +} +} // namespace DistributedHardware } // namespace OHOS \ No newline at end of file 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 9677438e..a5b1ad2c 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 @@ -1,184 +1,184 @@ -/* - * 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_handler.h" - -#include "if_system_ability_manager.h" -#include "iservice_registry.h" - -#include "dscreen_constants.h" -#include "dscreen_errcode.h" -#include "dscreen_log.h" -#include "dscreen_source_load_callback.h" -#include "dscreen_util.h" - -namespace OHOS { -namespace DistributedHardware { -IMPLEMENT_SINGLE_INSTANCE(DScreenSourceHandler); - -DScreenSourceHandler::DScreenSourceHandler() -{ - DHLOGI("DScreenSourceHandler construct."); - std::lock_guard lock(mutex_); - if (!sourceSvrRecipient_) { - sourceSvrRecipient_ = new DScreenSourceSvrRecipient(); - } - - if (!dScreenSourceCallback_) { - dScreenSourceCallback_ = new DScreenSourceCallback(); - } -} - -DScreenSourceHandler::~DScreenSourceHandler() -{ - DHLOGI("~DScreenSourceHandler."); -} - -int32_t DScreenSourceHandler::InitSource(const std::string ¶ms) -{ - DHLOGD("InitSource"); - std::unique_lock lock(mutex_); - - if (!dScreenSourceProxy_) { - 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); - 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; - } - } - - 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() -{ - DHLOGD("ReleaseSource"); - std::lock_guard lock(mutex_); - if (!dScreenSourceProxy_) { - DHLOGE("screen source proxy not init."); - return ERR_DH_SCREEN_SA_SOURCEPROXY_NOT_INIT; - } - int32_t ret = dScreenSourceProxy_->ReleaseSource(); - dScreenSourceProxy_ = nullptr; - return ret; -} - -int32_t DScreenSourceHandler::RegisterDistributedHardware(const std::string &devId, - const std::string &dhId, const EnableParam ¶m, std::shared_ptr callback) -{ - DHLOGD("RegisterDistributedHardware, devId: %s, dhId: %s", GetAnonyString(devId).c_str(), - GetAnonyString(dhId).c_str()); - std::lock_guard lock(mutex_); - if (!dScreenSourceProxy_) { - DHLOGE("screen source proxy not init."); - return ERR_DH_SCREEN_SA_SOURCEPROXY_NOT_INIT; - } - if (!dScreenSourceCallback_) { - DHLOGE("screen source callback is null."); - return ERR_DH_SCREEN_SA_SOURCEPCALLBACK_NOT_INIT; - } - - std::string reqId = GetRandomID(); - dScreenSourceCallback_->PushRegRegisterCallback(reqId, callback); - int ret = dScreenSourceProxy_->RegisterDistributedHardware(devId, dhId, param, reqId); - return ret; -} - -int32_t DScreenSourceHandler::UnregisterDistributedHardware(const std::string &devId, - const std::string &dhId, std::shared_ptr callback) -{ - DHLOGD("UnregisterDistributedHardware, devId: %s, dhId: %s", GetAnonyString(devId).c_str(), - GetAnonyString(dhId).c_str()); - std::lock_guard lock(mutex_); - if (!dScreenSourceProxy_) { - DHLOGE("screen source proxy not init."); - return ERR_DH_SCREEN_SA_SOURCEPROXY_NOT_INIT; - } - if (!dScreenSourceCallback_) { - DHLOGE("screen source callback is null."); - return ERR_DH_SCREEN_SA_SOURCEPCALLBACK_NOT_INIT; - } - - std::string reqId = GetRandomID(); - dScreenSourceCallback_->PushUnregisterCallback(reqId, callback); - int ret = dScreenSourceProxy_->UnregisterDistributedHardware(devId, dhId, reqId); - return ret; -} - -int32_t DScreenSourceHandler::ConfigDistributedHardware(const std::string &devId, - const std::string &dhId, const std::string &key, const std::string &value) -{ - DHLOGD("ConfigDistributedHardware"); - return DH_SUCCESS; -} - -void DScreenSourceHandler::DScreenSourceSvrRecipient::OnRemoteDied(const wptr &remote) -{ - DHLOGI("DScreenSourceSvrRecipient OnRemoteDied"); - DScreenSourceHandler::GetInstance().OnRemoteSourceSvrDied(remote); -} - -void DScreenSourceHandler::OnRemoteSourceSvrDied(const wptr &remote) -{ - DHLOGI("OnRemoteSourceSvrDied"); - sptr remoteObject = remote.promote(); - if (!remoteObject) { - DHLOGE("OnRemoteDied remote promoted failed"); - return; - } - std::lock_guard lock(mutex_); - if (!dScreenSourceProxy_) { - dScreenSourceProxy_->AsObject()->RemoveDeathRecipient(sourceSvrRecipient_); - dScreenSourceProxy_ = nullptr; - } -} - -IDistributedHardwareSource *GetSourceHardwareHandler() -{ - DHLOGD("GetSourceHardwareHandler"); - return &DScreenSourceHandler::GetInstance(); -} -} +/* + * 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_handler.h" + +#include "if_system_ability_manager.h" +#include "iservice_registry.h" + +#include "dscreen_constants.h" +#include "dscreen_errcode.h" +#include "dscreen_log.h" +#include "dscreen_source_load_callback.h" +#include "dscreen_util.h" + +namespace OHOS { +namespace DistributedHardware { +IMPLEMENT_SINGLE_INSTANCE(DScreenSourceHandler); + +DScreenSourceHandler::DScreenSourceHandler() +{ + DHLOGI("DScreenSourceHandler construct."); + std::lock_guard lock(mutex_); + if (!sourceSvrRecipient_) { + sourceSvrRecipient_ = new DScreenSourceSvrRecipient(); + } + + if (!dScreenSourceCallback_) { + dScreenSourceCallback_ = new DScreenSourceCallback(); + } +} + +DScreenSourceHandler::~DScreenSourceHandler() +{ + DHLOGI("~DScreenSourceHandler."); +} + +int32_t DScreenSourceHandler::InitSource(const std::string ¶ms) +{ + DHLOGD("InitSource"); + std::unique_lock lock(mutex_); + + if (!dScreenSourceProxy_) { + 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); + 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; + } + } + + 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() +{ + DHLOGD("ReleaseSource"); + std::lock_guard lock(mutex_); + if (!dScreenSourceProxy_) { + DHLOGE("screen source proxy not init."); + return ERR_DH_SCREEN_SA_SOURCEPROXY_NOT_INIT; + } + int32_t ret = dScreenSourceProxy_->ReleaseSource(); + dScreenSourceProxy_ = nullptr; + return ret; +} + +int32_t DScreenSourceHandler::RegisterDistributedHardware(const std::string &devId, + const std::string &dhId, const EnableParam ¶m, std::shared_ptr callback) +{ + DHLOGD("RegisterDistributedHardware, devId: %s, dhId: %s", GetAnonyString(devId).c_str(), + GetAnonyString(dhId).c_str()); + std::lock_guard lock(mutex_); + if (!dScreenSourceProxy_) { + DHLOGE("screen source proxy not init."); + return ERR_DH_SCREEN_SA_SOURCEPROXY_NOT_INIT; + } + if (!dScreenSourceCallback_) { + DHLOGE("screen source callback is null."); + return ERR_DH_SCREEN_SA_SOURCEPCALLBACK_NOT_INIT; + } + + std::string reqId = GetRandomID(); + dScreenSourceCallback_->PushRegRegisterCallback(reqId, callback); + int ret = dScreenSourceProxy_->RegisterDistributedHardware(devId, dhId, param, reqId); + return ret; +} + +int32_t DScreenSourceHandler::UnregisterDistributedHardware(const std::string &devId, + const std::string &dhId, std::shared_ptr callback) +{ + DHLOGD("UnregisterDistributedHardware, devId: %s, dhId: %s", GetAnonyString(devId).c_str(), + GetAnonyString(dhId).c_str()); + std::lock_guard lock(mutex_); + if (!dScreenSourceProxy_) { + DHLOGE("screen source proxy not init."); + return ERR_DH_SCREEN_SA_SOURCEPROXY_NOT_INIT; + } + if (!dScreenSourceCallback_) { + DHLOGE("screen source callback is null."); + return ERR_DH_SCREEN_SA_SOURCEPCALLBACK_NOT_INIT; + } + + std::string reqId = GetRandomID(); + dScreenSourceCallback_->PushUnregisterCallback(reqId, callback); + int ret = dScreenSourceProxy_->UnregisterDistributedHardware(devId, dhId, reqId); + return ret; +} + +int32_t DScreenSourceHandler::ConfigDistributedHardware(const std::string &devId, + const std::string &dhId, const std::string &key, const std::string &value) +{ + DHLOGD("ConfigDistributedHardware"); + return DH_SUCCESS; +} + +void DScreenSourceHandler::DScreenSourceSvrRecipient::OnRemoteDied(const wptr &remote) +{ + DHLOGI("DScreenSourceSvrRecipient OnRemoteDied"); + DScreenSourceHandler::GetInstance().OnRemoteSourceSvrDied(remote); +} + +void DScreenSourceHandler::OnRemoteSourceSvrDied(const wptr &remote) +{ + DHLOGI("OnRemoteSourceSvrDied"); + sptr remoteObject = remote.promote(); + if (!remoteObject) { + DHLOGE("OnRemoteDied remote promoted failed"); + return; + } + std::lock_guard lock(mutex_); + if (!dScreenSourceProxy_) { + dScreenSourceProxy_->AsObject()->RemoveDeathRecipient(sourceSvrRecipient_); + dScreenSourceProxy_ = nullptr; + } +} + +IDistributedHardwareSource *GetSourceHardwareHandler() +{ + DHLOGD("GetSourceHardwareHandler"); + return &DScreenSourceHandler::GetInstance(); +} +} } \ No newline at end of file -- Gitee From d9acf35e47bf396921b18a24c7a2fd698382ed62 Mon Sep 17 00:00:00 2001 From: gaoqiang_strong Date: Wed, 13 Apr 2022 18:55:56 +0800 Subject: [PATCH 12/13] modif 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 +- .../src/callback/dscreen_source_load_callback.cpp | 2 +- .../sinkservice/dscreenservice/src/dscreen_sink_service.cpp | 1 + services/screenservice/sinkservice/dscreensink.cfg | 4 ++-- .../dscreenservice/src/dscreen_source_service.cpp | 1 + services/screenservice/sourceservice/dscreensrc.cfg | 4 ++-- 8 files changed, 10 insertions(+), 8 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 39fa230f..5bb267e3 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 @@ -27,7 +27,7 @@ public: const sptr &remoteObject); void OnLoadSystemAbilityFail(int32_t systemAbilityId); private: - std::string params; + 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 3fac4eba..a815a551 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 params) : 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 1ccd721e..d47499aa 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 @@ -27,7 +27,7 @@ public: const sptr &remoteObject); void OnLoadSystemAbilityFail(int32_t systemAbilityId); private: - std::string params; + 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 db95c540..2b99a5ed 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 params) : params_(params) {} void DScreenSourceLoadCallback::OnLoadSystemAbilitySuccess( int32_t systemAbilityId, const sptr &remoteObject) diff --git a/services/screenservice/sinkservice/dscreenservice/src/dscreen_sink_service.cpp b/services/screenservice/sinkservice/dscreenservice/src/dscreen_sink_service.cpp index 24b6d09b..020ce954 100644 --- a/services/screenservice/sinkservice/dscreenservice/src/dscreen_sink_service.cpp +++ b/services/screenservice/sinkservice/dscreenservice/src/dscreen_sink_service.cpp @@ -77,6 +77,7 @@ int32_t DScreenSinkService::ReleaseSink() { DHLOGI("ReleaseSink"); ScreenRegionManager::GetInstance().ReleaseAllRegions(); + DHLOGI("exit sink sa process"); exit(0); return DH_SUCCESS; } diff --git a/services/screenservice/sinkservice/dscreensink.cfg b/services/screenservice/sinkservice/dscreensink.cfg index 45401cb2..69d1aaea 100644 --- a/services/screenservice/sinkservice/dscreensink.cfg +++ b/services/screenservice/sinkservice/dscreensink.cfg @@ -2,9 +2,9 @@ "services" : [{ "name" : "dscreensink", "dynamic" : true, - "path" : ["/system/bin/sa_main","system/profile/dscreensink.xml"], + "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/dscreenservice/src/dscreen_source_service.cpp b/services/screenservice/sourceservice/dscreenservice/src/dscreen_source_service.cpp index 920f758c..3a7c561d 100644 --- a/services/screenservice/sourceservice/dscreenservice/src/dscreen_source_service.cpp +++ b/services/screenservice/sourceservice/dscreenservice/src/dscreen_source_service.cpp @@ -93,6 +93,7 @@ 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 index e6af45ba..8156f308 100644 --- a/services/screenservice/sourceservice/dscreensrc.cfg +++ b/services/screenservice/sourceservice/dscreensrc.cfg @@ -2,9 +2,9 @@ "services" : [{ "name" : "dscreensrc", "dynamic" : true, - "path" : ["/system/bin/sa_main","system/profile/dscreensrc.xml"], + "path" : ["/system/bin/sa_main", "/system/profile/dscreensrc.xml"], "uid" : "system", "gid" : ["system"], "ondemand" : true - }] + }] } \ No newline at end of file -- Gitee From 62183863bf1d5f34570b0cd9a2bf092e3e5d4e3c Mon Sep 17 00:00:00 2001 From: gaoqiang_strong Date: Wed, 13 Apr 2022 19:12:26 +0800 Subject: [PATCH 13/13] mm Signed-off-by: gaoqiang_strong --- .../screen_sink/src/callback/dscreen_sink_load_callback.cpp | 2 +- .../screen_source/src/callback/dscreen_source_load_callback.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 a815a551..ba1d2b37 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 @@ -32,7 +32,7 @@ void DScreenSinkLoadCallback::OnLoadSystemAbilitySuccess( return; } - DScreenSinkHandler::GetInstance().FinishStartSA(params, remoteObject); + DScreenSinkHandler::GetInstance().FinishStartSA(params_, remoteObject); } void DScreenSinkLoadCallback::OnLoadSystemAbilityFail(int32_t systemAbilityId) 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 2b99a5ed..8e26343e 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 @@ -32,7 +32,7 @@ void DScreenSourceLoadCallback::OnLoadSystemAbilitySuccess( return; } - DScreenSourceHandler::GetInstance().FinishStartSA(params, remoteObject); + DScreenSourceHandler::GetInstance().FinishStartSA(params_, remoteObject); } void DScreenSourceLoadCallback::OnLoadSystemAbilityFail(int32_t systemAbilityId) -- Gitee