diff --git a/common/include/dscreen_constants.h b/common/include/dscreen_constants.h index cce75aab13b162d6744c895848824d1c48ed8351..f8c15f6eec955abb90943532b050ef346b9addd9 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 a6101bbebb3150de870007eba4d5d3aa68fb1acc..987e9195c9054b11cb22a90e67e78cd9c68e9c32 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 bcbb3e9b0c1f0757fcabceb1fd95bbc8cf1d1317..adc10a540538a713700035ebf28382004c631f2f 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 += [ - "include", - "${common_path}/include", - ] - - sources = [ - "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" -} \ 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" +} 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 0000000000000000000000000000000000000000..5bb267e345c61c46cbf0849447114d680d47765f --- /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 152884ded32f1622fff676707a4840e759c8c4a1..2ba840d8571a06f675eacc8dfdc99e9c17a5474c 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 0000000000000000000000000000000000000000..ba1d2b376d28a1f75685edeccf075cf006e973d2 --- /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 8f4472cc86dbe81d3017d4c9235957fd3d9e33f3..eb509b24d7388644526dccaf771d69ea0d0179eb 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,136 +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" - -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::lock_guard 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 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."); - return ERR_DH_SCREEN_SA_GET_SINKPROXY_FAIL; - } - } - int32_t ret = dScreenSinkProxy_->InitSink(params); - return ret; -} - -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(); - 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/BUILD.gn b/interfaces/innerkits/native_cpp/screen_source/BUILD.gn index fec91820c36aa63208f420b31e63f6815ff8b66d..e98472585e7237361a199143dd1b3887ce53e17e 100644 --- a/interfaces/innerkits/native_cpp/screen_source/BUILD.gn +++ b/interfaces/innerkits/native_cpp/screen_source/BUILD.gn @@ -9,50 +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_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/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 0000000000000000000000000000000000000000..d47499aaacffed382196f2567281d0a41ae5af74 --- /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 0ee40a01795f4aca6ec503cbeb4690d0d68b2c66..bc7e488cd7bff061133263667b3c820f5bba5c46 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 0000000000000000000000000000000000000000..8e26343e5995ea70654cd3f591b7111b84632f02 --- /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 ed5e3c0f89c79b46a453b839d4241335ae20c355..a5b1ad2cb81f314bb92690067f5fd6a299bdfab7 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,166 +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_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::lock_guard 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 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."); - return ERR_DH_SCREEN_SA_GET_SOURCEPROXY_FAIL; - } - } - - int32_t ret = dScreenSourceProxy_->InitSource(params, dScreenSourceCallback_); - return ret; -} - -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(); - 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 diff --git a/sa_profile/4807.xml b/sa_profile/4807.xml index f3f552e2f137992fe8b494662d5a02ea6e3b40cd..776d981637d04ea70d09a2d726b70e3f4b49060b 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 6ec95fd48110875d465d97392409fb23b3d3a4d9..857162eb48837d0f75939dbb14a1cfb306729cb5 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/BUILD.gn b/services/screenservice/sinkservice/BUILD.gn index 0564cbdaec59d980d6869dd9703c545604bb68d2..aae25a6012c1e6f45c42012a5b02fd39e7d3f381 100644 --- a/services/screenservice/sinkservice/BUILD.gn +++ b/services/screenservice/sinkservice/BUILD.gn @@ -9,74 +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", - ] + 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 643b4155930d7ae1a8cdb572b4da137129c0e06f..020ce9546d3a440e14ff2841542a8cf841dafe43 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 0000000000000000000000000000000000000000..69d1aaeab085ff5a8940eb65067d553b03d6bf00 --- /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 922c984444db5ca4c7ca6fc1086a42bbaa765211..32e7a09140f8c62ed020938768051560333e5bdd 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", @@ -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 e1cb0ef3530824bcaaac58a418cfc7ad6d814d72..3a7c561db3c72bc7756bec8f0fd2238bddad4018 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 0000000000000000000000000000000000000000..8156f308bef8362e9f813d59fc09bec36412676d --- /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