diff --git a/common/utils/include/device_type.h b/common/utils/include/device_type.h index 475efc4c0a77c10669e2825058ff82c7be9faced..805b8012834a9288d4c16da2b6236ed131b6687a 100644 --- a/common/utils/include/device_type.h +++ b/common/utils/include/device_type.h @@ -25,7 +25,7 @@ enum class DHType : uint32_t { UNKNOWN = 0x0, // unknown device CAMERA = 0x01, // Camera AUDIO = 0x02, // Mic - DISPLAY = 0x08, // Display + SCREEN = 0x08, // Display GPS = 0x10, // GPS INPUT = 0x20, // Key board HFP = 0x40, // HFP External device @@ -38,7 +38,7 @@ enum class DHType : uint32_t { const std::unordered_map DHTypeStrMap = { { DHType::CAMERA, "CAMERA" }, { DHType::AUDIO, "AUDIO" }, - { DHType::DISPLAY, "DISPLAY" }, + { DHType::SCREEN, "SCREEN" }, { DHType::GPS, "GPS" }, { DHType::INPUT, "INPUT" }, { DHType::HFP, "HFP" }, @@ -60,7 +60,7 @@ struct DeviceInfo { /* The key is DHType, the value is the prefix of DHId */ const std::unordered_map DHTypePrefixMap = { {DHType::CAMERA, "Camera"}, - {DHType::DISPLAY, "Screen"}, + {DHType::SCREEN, "Screen"}, {DHType::INPUT, "Input"}, }; } // namespace DistributedHardware diff --git a/interfaces/inner_kits/src/distributed_hardware_fwk_kit.cpp b/interfaces/inner_kits/src/distributed_hardware_fwk_kit.cpp index 18038a0ee250f903d1ff9688d167f280b7dbf04c..5491364433b4a95e07621d9d7b15657948887095 100644 --- a/interfaces/inner_kits/src/distributed_hardware_fwk_kit.cpp +++ b/interfaces/inner_kits/src/distributed_hardware_fwk_kit.cpp @@ -42,7 +42,7 @@ int32_t DistributedHardwareFwkKit::RegisterPublisherListener(const DHTopic topic DHLOGI("Register publisher listener, topic: %" PRIu32 ", is DHFWK online: %s", (uint32_t)topic, isDHFWKOnLine_ ? "true" : "false"); if (!IsDHTopicValid(topic)) { - DHLOGE("Topic invalid, topic: " PRIu32 , (uint32_t)topic); + DHLOGE("Topic invalid, topic: " PRIu32, (uint32_t)topic); return ERR_DH_FWK_PARA_INVALID; } @@ -64,7 +64,7 @@ int32_t DistributedHardwareFwkKit::UnregisterPublisherListener(const DHTopic top DHLOGI("Unregister publisher listener, topic: %" PRIu32 ", is DHFWK online: %s", (uint32_t)topic, isDHFWKOnLine_ ? "true" : "false"); if (!IsDHTopicValid(topic)) { - DHLOGE("Topic invalid, topic: " PRIu32 , (uint32_t)topic); + DHLOGE("Topic invalid, topic: " PRIu32, (uint32_t)topic); return ERR_DH_FWK_PARA_INVALID; } @@ -83,7 +83,7 @@ int32_t DistributedHardwareFwkKit::PublishMessage(const DHTopic topic, const std { DHLOGI("Publish message, topic: %" PRIu32 ", msg: %s", (uint32_t)topic, message.c_str()); if (!IsDHTopicValid(topic)) { - DHLOGE("Topic invalid, topic: " PRIu32 , (uint32_t)topic); + DHLOGE("Topic invalid, topic: " PRIu32, (uint32_t)topic); return ERR_DH_FWK_PARA_INVALID; } diff --git a/interfaces/inner_kits/src/ipc/distributed_hardware_proxy.cpp b/interfaces/inner_kits/src/ipc/distributed_hardware_proxy.cpp index 46eda26b5d1a98394a12832e0e060094657ae191..c47f2a5a81423877d0d092f30819e4fe26a33b8c 100644 --- a/interfaces/inner_kits/src/ipc/distributed_hardware_proxy.cpp +++ b/interfaces/inner_kits/src/ipc/distributed_hardware_proxy.cpp @@ -29,7 +29,7 @@ namespace DistributedHardware { #undef DH_LOG_TAG #define DH_LOG_TAG "DistributedHardwareProxy" const std::unordered_set DH_TYPE_SET { - DHType::UNKNOWN, DHType::CAMERA, DHType::AUDIO, DHType::DISPLAY, DHType::GPS, DHType::INPUT, + DHType::UNKNOWN, DHType::CAMERA, DHType::AUDIO, DHType::SCREEN, DHType::GPS, DHType::INPUT, DHType::HFP, DHType::A2D, DHType::VIRMODEM_MIC, DHType::VIRMODEM_SPEAKER, DHType::MAX_DH, }; diff --git a/services/distributedhardwarefwkservice/BUILD.gn b/services/distributedhardwarefwkservice/BUILD.gn index d3bc93dc47b45ccf01da5d641299c0ebb4cc099b..cafb1d866ce559cd8fbc08363cc5913b67c5d868 100644 --- a/services/distributedhardwarefwkservice/BUILD.gn +++ b/services/distributedhardwarefwkservice/BUILD.gn @@ -51,6 +51,7 @@ ohos_shared_library("distributedhardwarefwksvr") { "src/componentmanager/component_disable.cpp", "src/componentmanager/component_enable.cpp", "src/componentmanager/component_manager.cpp", + "src/componentmanager/component_monitor.cpp", "src/distributed_hardware_manager.cpp", "src/distributed_hardware_manager_factory.cpp", "src/distributed_hardware_service.cpp", diff --git a/services/distributedhardwarefwkservice/include/componentloader/component_loader.h b/services/distributedhardwarefwkservice/include/componentloader/component_loader.h index 1ef1ea69b96b37a5b5210bd34358e33f5fb0e773..3ff04a4341a80a48465c26fc4cece6369feed032 100644 --- a/services/distributedhardwarefwkservice/include/componentloader/component_loader.h +++ b/services/distributedhardwarefwkservice/include/componentloader/component_loader.h @@ -30,6 +30,19 @@ namespace OHOS { namespace DistributedHardware { +namespace { +struct CompHandler { + DHType type; + void *sourceHandler; + int32_t sourceSaId; + void *sinkHandler; + int32_t sinkSaId; + void *hardwareHandler; +}; + +const std::string COMPONENTSLOAD_DISTRIBUTED_COMPONENTS = "distributed_components"; +} + struct CompConfig { std::string name; DHType type; @@ -37,18 +50,12 @@ struct CompConfig { std::string compHandlerVersion; std::string compSourceLoc; std::string compSourceVersion; + int32_t compSourceSaId; std::string compSinkLoc; std::string compSinkVersion; + int32_t compSinkSaId; }; -struct CompHandler { - void *sourceHandler; - void *sinkHandler; - void *hardwareHandler; -}; - -const std::string COMPONENTSLOAD_DISTRIBUTED_COMPONENTS = "distributed_components"; - class ComponentLoader { DECLARE_SINGLE_INSTANCE_BASE(ComponentLoader); @@ -67,6 +74,8 @@ public: int32_t ReleaseSink(const DHType dhType); std::vector GetAllCompTypes(); int32_t GetLocalDHVersion(DHVersion &dhVersion); + int32_t GetSourceSaId(const DHType dhType); + DHType GetDHTypeBySrcSaId(const int32_t saId); private: void *GetHandler(const std::string &soName); diff --git a/services/distributedhardwarefwkservice/include/componentmanager/component_manager.h b/services/distributedhardwarefwkservice/include/componentmanager/component_manager.h index dc1165409c4400ef848a9044fb0d8694f6dd9fe8..6ec6d7e9bd5994f852a6c207335ce973fdcd2ab2 100644 --- a/services/distributedhardwarefwkservice/include/componentmanager/component_manager.h +++ b/services/distributedhardwarefwkservice/include/componentmanager/component_manager.h @@ -23,6 +23,7 @@ #include #include "single_instance.h" +#include "component_monitor.h" #include "device_type.h" #include "idistributed_hardware.h" #include "idistributed_hardware_sink.h" @@ -31,11 +32,12 @@ namespace OHOS { namespace DistributedHardware { +using ActionResult = std::unordered_map>; class ComponentManager { DECLARE_SINGLE_INSTANCE_BASE(ComponentManager); public: - ComponentManager() {} + ComponentManager(); ~ComponentManager(); public: @@ -47,6 +49,7 @@ public: const DHType dhType); void DumpLoadedComps(std::set &compSourceType, std::set &compSinkType); + void Recover(DHType dhType); private: enum class Action : int32_t { @@ -56,14 +59,14 @@ private: STOP_SINK }; - using ActionResult = std::unordered_map>; - DHType GetDHType(const std::string &uuid, const std::string &dhId) const; bool InitCompSource(); bool InitCompSink(); ActionResult StartSource(); + ActionResult StartSource(DHType dhType); ActionResult StopSource(); ActionResult StartSink(); + ActionResult StartSink(DHType dhType); ActionResult StopSink(); bool WaitForResult(const Action &action, ActionResult result); int32_t GetEnableParam(const std::string &networkId, const std::string &uuid, const std::string &dhId, @@ -75,11 +78,16 @@ private: int32_t GetSinkVersion(const std::string &networkId, const std::string &uuid, DHType dhType, std::string &sinkVersion); void UpdateVersionCache(const std::string &uuid, const VersionInfo &versionInfo); - sptr GetRemoteDHMS(const std::string &networkId) const; + + void DoRecover(DHType dhType); + void ReStartSA(DHType dhType); + void RecoverDistributedHardware(DHType dhType); private: std::map compSource_; std::map compSink_; + std::map compSrcSaId_; + std::shared_ptr compMonitorPtr_; }; } // namespace DistributedHardware } // namespace OHOS diff --git a/services/distributedhardwarefwkservice/include/componentmanager/component_monitor.h b/services/distributedhardwarefwkservice/include/componentmanager/component_monitor.h new file mode 100644 index 0000000000000000000000000000000000000000..78fc5f815023d1aae1b1fbcf591c06793a21514f --- /dev/null +++ b/services/distributedhardwarefwkservice/include/componentmanager/component_monitor.h @@ -0,0 +1,52 @@ +/* + * 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_DISTRIBUTED_HARDWARE_COMPONENT_MONITOR_H +#define OHOS_DISTRIBUTED_HARDWARE_COMPONENT_MONITOR_H + +#include +#include +#include +#include +#include + +#include "system_ability_status_change_stub.h" + +#include "single_instance.h" + +namespace OHOS { +namespace DistributedHardware { +class ComponentMonitor { +REMOVE_NO_USE_CONSTRUCTOR(ComponentMonitor); +public: + explicit ComponentMonitor(); + ~ComponentMonitor(); + void AddSAMonitor(int32_t saId); + void RemoveSAMonitor(int32_t saId); + +public: + class CompSystemAbilityListener : public SystemAbilityStatusChangeStub { + public: + void OnAddSystemAbility(int32_t saId, const std::string &deviceId) override; + void OnRemoveSystemAbility(int32_t saId, const std::string &deviceId) override; + }; + +private: + std::mutex saListenersMtx_; + std::map> saListeners_; +}; +} // namespace DistributedHardware +} // namespace OHOS +#endif \ No newline at end of file diff --git a/services/distributedhardwarefwkservice/include/resourcemanager/capability_info_manager.h b/services/distributedhardwarefwkservice/include/resourcemanager/capability_info_manager.h index 7bbe92e624178d725ab50770ba932f3a5e28fe65..8958acc3ba72bbd7656a42d3b536315ad157ea10 100644 --- a/services/distributedhardwarefwkservice/include/resourcemanager/capability_info_manager.h +++ b/services/distributedhardwarefwkservice/include/resourcemanager/capability_info_manager.h @@ -78,6 +78,8 @@ public: int32_t GetCapability(const std::string &deviceId, const std::string &dhId, std::shared_ptr &capPtr); int32_t GetDataByKey(const std::string &key, std::shared_ptr& capInfoPtr); + /* Query batch records by dhtype */ + int32_t GetDataByDHType(const DHType dhType, CapabilityInfoMap &capabilityMap); /* Queries batch records in the database based on the prefix of the key. */ int32_t GetDataByKeyPrefix(const std::string &keyPrefix, CapabilityInfoMap &capabilityMap); /* Init the count of manual sync times */ diff --git a/services/distributedhardwarefwkservice/src/componentloader/component_loader.cpp b/services/distributedhardwarefwkservice/src/componentloader/component_loader.cpp index 0188d46169fe7c300c2981a26c559f8b72c7d182..1e323c7a19130d7c2a4165c11e7539c5df194c7c 100644 --- a/services/distributedhardwarefwkservice/src/componentloader/component_loader.cpp +++ b/services/distributedhardwarefwkservice/src/componentloader/component_loader.cpp @@ -15,6 +15,7 @@ #include "componentloader/component_loader.h" +#include #include #include #include @@ -43,23 +44,34 @@ using GetHardwareClass = IHardwareHandler *(*)(); using GetSourceHardwareClass = IDistributedHardwareSource *(*)(); using GetSinkHardwareClass = IDistributedHardwareSink *(*)(); namespace { +const std::string COMP_NAME = "name"; +const std::string COMP_TYPE = "type"; +const std::string COMP_HANDLER_LOC = "comp_handler_loc"; +const std::string COMP_HANDLER_VERSION = "comp_handler_version"; +const std::string COMP_SOURCE_LOC = "comp_source_loc"; +const std::string COMP_SOURCE_VERSION = "comp_source_version"; +const std::string COMP_SOURCE_SA_ID = "comp_source_sa_id"; +const std::string COMP_SINK_LOC = "comp_sink_loc"; +const std::string COMP_SINK_VERSION = "comp_sink_version"; +const std::string COMP_SINK_SA_ID = "comp_sink_sa_id"; + const std::string DEFAULT_NAME = ""; -const std::string DEFAULT_HANDLER_LOC = ""; -const std::string DEFAULT_SOURCE_LOC = ""; -const std::string DEFAULT_SINK_LOC = ""; const std::string DEFAULT_TYPE = "UNKNOWN"; +const std::string DEFAULT_LOC = ""; +const int32_t DEFAULT_SA_ID = -1; const std::string DEFAULT_VERSION = "1.0"; + #ifdef __LP64__ const std::string LIB_LOAD_PATH = "/system/lib64/"; #else const std::string LIB_LOAD_PATH = "/system/lib/"; #endif -} + std::map g_mapDhTypeName = { { "UNKNOWN", DHType::UNKNOWN }, { "CAMERA", DHType::CAMERA }, { "AUDIO", DHType::AUDIO }, - { "DISPLAY", DHType::DISPLAY }, + { "SCREEN", DHType::SCREEN }, { "GPS", DHType::GPS }, { "INPUT", DHType::INPUT }, { "HFP", DHType::HFP }, @@ -67,6 +79,7 @@ std::map g_mapDhTypeName = { { "VIRMODEM_MIC", DHType::VIRMODEM_MIC }, { "VIRMODEM_SPEAKER", DHType::VIRMODEM_SPEAKER }, }; +} int32_t ComponentLoader::Init() { @@ -88,16 +101,18 @@ std::vector ComponentLoader::GetAllCompTypes() return DHTypeALL; } -void from_json(const nlohmann::json &j, CompConfig &cCfg) +void from_json(const nlohmann::json &json, CompConfig &cfg) { - cCfg.name = j.value("name", DEFAULT_NAME); - cCfg.type = g_mapDhTypeName[j.value("type", DEFAULT_TYPE)]; - cCfg.compHandlerLoc = j.value("comp_handler_loc", DEFAULT_HANDLER_LOC); - cCfg.compHandlerVersion = j.value("comp_handler_version", DEFAULT_VERSION); - cCfg.compSourceLoc = j.value("comp_source_loc", DEFAULT_SOURCE_LOC); - cCfg.compSourceVersion = j.value("comp_source_version", DEFAULT_VERSION); - cCfg.compSinkLoc = j.value("comp_sink_loc", DEFAULT_SINK_LOC); - cCfg.compSinkVersion = j.value("comp_sink_version", DEFAULT_VERSION); + cfg.name = json.value(COMP_NAME, DEFAULT_NAME); + cfg.type = g_mapDhTypeName[json.value(COMP_TYPE, DEFAULT_TYPE)]; + cfg.compHandlerLoc = json.value(COMP_HANDLER_LOC, DEFAULT_LOC); + cfg.compHandlerVersion = json.value(COMP_HANDLER_VERSION, DEFAULT_VERSION); + cfg.compSourceLoc = json.value(COMP_SOURCE_LOC, DEFAULT_LOC); + cfg.compSourceVersion = json.value(COMP_SOURCE_VERSION, DEFAULT_VERSION); + cfg.compSourceSaId = json.value(COMP_SOURCE_SA_ID, DEFAULT_SA_ID); + cfg.compSinkLoc = json.value(COMP_SINK_LOC, DEFAULT_LOC); + cfg.compSinkVersion = json.value(COMP_SINK_VERSION, DEFAULT_VERSION); + cfg.compSinkSaId = json.value(COMP_SINK_SA_ID, DEFAULT_SA_ID); } CompVersion ComponentLoader::GetCompVersionFromComConfig(const CompConfig& cCfg) @@ -181,15 +196,23 @@ void ComponentLoader::GetAllHandler(std::map &dhtypeMap) std::map::iterator itor; for (itor = dhtypeMap.begin(); itor != dhtypeMap.end(); itor++) { CompHandler comHandler; + comHandler.type = itor->second.type; comHandler.hardwareHandler = GetHandler(itor->second.compHandlerLoc); - comHandler.sinkHandler = GetHandler(itor->second.compSinkLoc); comHandler.sourceHandler = GetHandler(itor->second.compSourceLoc); + comHandler.sourceSaId = itor->second.compSourceSaId; + comHandler.sinkHandler = GetHandler(itor->second.compSinkLoc); + comHandler.sinkSaId = itor->second.compSinkSaId; compHandlerMap_.insert(std::pair(itor->second.type, comHandler)); } } int32_t ComponentLoader::GetHardwareHandler(const DHType dhType, IHardwareHandler *&hardwareHandlerPtr) { + if (compHandlerMap_.find(dhType) == compHandlerMap_.end()) { + DHLOGE("DHType not exist, dhType: " PRIu32, (uint32_t)dhType); + return ERR_DH_FWK_LOADER_HANDLER_IS_NULL; + } + if (compHandlerMap_[dhType].hardwareHandler == nullptr) { DHLOGE("hardwareHandler is null."); return ERR_DH_FWK_LOADER_HANDLER_IS_NULL; @@ -209,6 +232,11 @@ int32_t ComponentLoader::GetHardwareHandler(const DHType dhType, IHardwareHandle int32_t ComponentLoader::GetSource(const DHType dhType, IDistributedHardwareSource *&sourcePtr) { + if (compHandlerMap_.find(dhType) == compHandlerMap_.end()) { + DHLOGE("DHType not exist, dhType: " PRIu32, (uint32_t)dhType); + return ERR_DH_FWK_LOADER_HANDLER_IS_NULL; + } + if (compHandlerMap_[dhType].sourceHandler == nullptr) { DHLOGE("sourceHandler is null."); return ERR_DH_FWK_LOADER_HANDLER_IS_NULL; @@ -228,6 +256,11 @@ int32_t ComponentLoader::GetSource(const DHType dhType, IDistributedHardwareSour int32_t ComponentLoader::GetSink(const DHType dhType, IDistributedHardwareSink *&sinkPtr) { + if (compHandlerMap_.find(dhType) == compHandlerMap_.end()) { + DHLOGE("DHType not exist, dhType: " PRIu32, (uint32_t)dhType); + return ERR_DH_FWK_LOADER_HANDLER_IS_NULL; + } + if (compHandlerMap_[dhType].sinkHandler == nullptr) { DHLOGE("sinkHandler is null."); return ERR_DH_FWK_LOADER_HANDLER_IS_NULL; @@ -362,5 +395,28 @@ bool ComponentLoader::IsDHTypeExist(DHType dhType) } return true; } + +int32_t ComponentLoader::GetSourceSaId(const DHType dhType) +{ + if (compHandlerMap_.find(dhType) == compHandlerMap_.end()) { + DHLOGE("DHType not exist, dhType: " PRIu32, (uint32_t)dhType); + return DEFAULT_SA_ID; + } + + return compHandlerMap_[dhType].sourceSaId; +} + +DHType ComponentLoader::GetDHTypeBySrcSaId(const int32_t saId) +{ + DHType type = DHType::UNKNOWN; + for (const auto &handler : compHandlerMap_) { + if (handler.second.sourceSaId == saId) { + type = handler.second.type; + break; + } + } + + return type; +} } // namespace DistributedHardware } // namespace OHOS diff --git a/services/distributedhardwarefwkservice/src/componentmanager/component_manager.cpp b/services/distributedhardwarefwkservice/src/componentmanager/component_manager.cpp index 70453a31158b55ea6b8fa526ef5c668a929469e9..d9ae9c92ea6afc1e973b7b497067ee49a1f31d32 100644 --- a/services/distributedhardwarefwkservice/src/componentmanager/component_manager.cpp +++ b/services/distributedhardwarefwkservice/src/componentmanager/component_manager.cpp @@ -15,8 +15,14 @@ #include "component_manager.h" +#include #include #include +#include + +#include "ipc_object_stub.h" +#include "iservice_registry.h" +#include "system_ability_definition.h" #include "anonymous_string.h" #include "capability_info_manager.h" @@ -31,10 +37,9 @@ #include "distributed_hardware_errno.h" #include "distributed_hardware_log.h" #include "enabled_comps_dump.h" -#include "ipc_object_stub.h" -#include "iservice_registry.h" #include "monitor_task_timer.h" -#include "system_ability_definition.h" +#include "task_executor.h" +#include "task_factory.h" #include "version_info_manager.h" #include "version_manager.h" @@ -49,11 +54,18 @@ namespace { constexpr int32_t ENABLE_RETRY_MAX_TIMES = 30; constexpr int32_t DISABLE_RETRY_MAX_TIMES = 30; constexpr int32_t ENABLE_PARAM_RETRY_TIME = 500 * 1000; + const int32_t INVALID_SA_ID = -1; +} + +ComponentManager::ComponentManager() : compSource_({}), compSink_({}), compSrcSaId_({}), + compMonitorPtr_(std::make_shared()) +{ + DHLOGI("Ctor ComponentManager"); } ComponentManager::~ComponentManager() { - DHLOGD("start."); + DHLOGD("Dtor ComponentManager"); } int32_t ComponentManager::Init() @@ -72,6 +84,13 @@ int32_t ComponentManager::Init() return ERR_DH_FWK_COMPONENT_INIT_SINK_FAILED; } + for (const auto &comp : compSource_) { + if (compSrcSaId_.find(comp.first) == compSrcSaId_.end()) { + continue; + } + compMonitorPtr_->AddSAMonitor(compSrcSaId_.at(comp.first)); + } + auto sourceResult = StartSource(); auto sinkResult = StartSink(); @@ -94,6 +113,12 @@ int32_t ComponentManager::Init() int32_t ComponentManager::UnInit() { DHLOGI("start."); + for (const auto &comp : compSource_) { + if (compSrcSaId_.find(comp.first) == compSrcSaId_.end()) { + continue; + } + compMonitorPtr_->RemoveSAMonitor(compSrcSaId_.at(comp.first)); + } auto sourceResult = StopSource(); auto sinkResult = StopSink(); @@ -112,7 +137,7 @@ int32_t ComponentManager::UnInit() return DH_FWK_SUCCESS; } -ComponentManager::ActionResult ComponentManager::StartSource() +ActionResult ComponentManager::StartSource() { DHLOGI("start."); std::unordered_map> futures; @@ -127,7 +152,28 @@ ComponentManager::ActionResult ComponentManager::StartSource() return futures; } -ComponentManager::ActionResult ComponentManager::StartSink() +ActionResult ComponentManager::StartSource(DHType dhType) +{ + DHLOGI("Start Source, dhType: %" PRIu32, (uint32_t)dhType); + std::unordered_map> futures; + if (compSource_.find(dhType) == compSource_.end()) { + DHLOGE("Component for DHType: %" PRIu32 " not init source handler", (uint32_t)dhType); + return futures; + } + + std::string uuid = DHContext::GetInstance().GetDeviceInfo().uuid; + CompVersion compVersion; + VersionManager::GetInstance().GetCompVersion(uuid, dhType, compVersion); + auto params = compVersion.sourceVersion; + auto future = std::async(std::launch::async, [this, dhType, params]() { + return compSource_[dhType]->InitSource(params); + }); + futures.emplace(dhType, future.share()); + + return futures; +} + +ActionResult ComponentManager::StartSink() { DHLOGI("start."); std::unordered_map> futures; @@ -142,7 +188,28 @@ ComponentManager::ActionResult ComponentManager::StartSink() return futures; } -ComponentManager::ActionResult ComponentManager::StopSource() +ActionResult ComponentManager::StartSink(DHType dhType) +{ + DHLOGI("Start Sink, dhType: %" PRIu32, (uint32_t)dhType); + std::unordered_map> futures; + if (compSink_.find(dhType) == compSink_.end()) { + DHLOGE("Component for DHType: %" PRIu32 " not init sink handler", (uint32_t)dhType); + return futures; + } + + std::string uuid = DHContext::GetInstance().GetDeviceInfo().uuid; + CompVersion compVersion; + VersionManager::GetInstance().GetCompVersion(uuid, dhType, compVersion); + auto params = compVersion.sinkVersion; + auto future = std::async(std::launch::async, [this, dhType, params]() { + return compSink_[dhType]->InitSink(params); + }); + futures.emplace(dhType, future.share()); + + return futures; +} + +ActionResult ComponentManager::StopSource() { DHLOGI("start."); std::unordered_map> futures; @@ -153,7 +220,7 @@ ComponentManager::ActionResult ComponentManager::StopSource() return futures; } -ComponentManager::ActionResult ComponentManager::StopSink() +ActionResult ComponentManager::StopSink() { DHLOGI("start."); std::unordered_map> futures; @@ -206,6 +273,11 @@ bool ComponentManager::InitCompSource() continue; } compSource_.insert(std::make_pair(type, sourcePtr)); + + int32_t saId = ComponentLoader::GetInstance().GetSourceSaId(type); + if (saId != INVALID_SA_ID) { + compSrcSaId_.insert(std::make_pair(type, saId)); + } } return !compSource_.empty(); } @@ -416,26 +488,6 @@ void ComponentManager::UpdateVersionCache(const std::string &uuid, const Version VersionManager::GetInstance().AddDHVersion(uuid, dhVersion); } -sptr ComponentManager::GetRemoteDHMS(const std::string &networkId) const -{ - DHLOGI("start, networkId = %s", GetAnonyString(networkId).c_str()); - if (networkId.empty()) { - DHLOGE("networkId is empty"); - return nullptr; - } - auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); - if (samgr == nullptr) { - DHLOGE("GetSystemAbilityManager failed"); - return nullptr; - } - auto object = samgr->CheckSystemAbility(DISTRIBUTED_HARDWARE_SA_ID, networkId); - if (object == nullptr) { - DHLOGE("CheckSystemAbility failed"); - return nullptr; - } - return iface_cast(object); -} - void ComponentManager::DumpLoadedComps(std::set &compSourceType, std::set &compSinkType) { for (auto compSource : compSource_) { @@ -445,5 +497,63 @@ void ComponentManager::DumpLoadedComps(std::set &compSourceType, std::se compSinkType.emplace(compSink.first); } } + +void ComponentManager::Recover(DHType dhType) +{ + std::thread(&ComponentManager::DoRecover, this, dhType).detach(); +} + +void ComponentManager::DoRecover(DHType dhType) +{ + // step1: restart sa process + ReStartSA(dhType); + // step2: recover distributed hardware virtual driver + RecoverDistributedHardware(dhType); +} + +void ComponentManager::ReStartSA(DHType dhType) +{ + DHLOGI("Restart SA for DHType %" PRIu32, (uint32_t)dhType); + auto sourceResult = StartSource(dhType); + auto sinkResult = StartSink(dhType); + + if (!WaitForResult(Action::START_SOURCE, sourceResult)) { + DHLOGE("ReStartSource failed, DHType: %" PRIu32, (uint32_t)dhType); + } + + if (!WaitForResult(Action::START_SINK, sinkResult)) { + DHLOGE("ReStartSink failed, DHType: %" PRIu32, (uint32_t)dhType); + } + DHLOGI("Finish Restart"); +} + +void ComponentManager::RecoverDistributedHardware(DHType dhType) +{ + CapabilityInfoMap capabilityMap; + CapabilityInfoManager::GetInstance()->GetDataByDHType(dhType, capabilityMap); + for (const auto &capInfo : capabilityMap) { + std::string uuid = DHContext::GetInstance().GetUUIDByDeviceId(capInfo.second->GetDeviceId()); + if (uuid.empty()) { + DHLOGE("Can not find uuid by capability deviceId: %s", + GetAnonyString(capInfo.second->GetDeviceId()).c_str()); + continue; + } + + std::string networkId = DHContext::GetInstance().GetNetworkIdByUUID(uuid); + if (networkId.empty()) { + DHLOGI("Can not find network id by uuid: %s", GetAnonyString(uuid).c_str()); + continue; + } + + TaskParam taskParam = { + .networkId = networkId, + .uuid = uuid, + .dhId = capInfo.second->GetDHId(), + .dhType = capInfo.second->GetDHType() + }; + auto task = TaskFactory::GetInstance().CreateTask(TaskType::ENABLE, taskParam, nullptr); + TaskExecutor::GetInstance().PushTask(task); + } +} } // namespace DistributedHardware } // namespace OHOS diff --git a/services/distributedhardwarefwkservice/src/componentmanager/component_monitor.cpp b/services/distributedhardwarefwkservice/src/componentmanager/component_monitor.cpp new file mode 100644 index 0000000000000000000000000000000000000000..abdaf84aa3840524222dbbdb493c48168a9e4ba1 --- /dev/null +++ b/services/distributedhardwarefwkservice/src/componentmanager/component_monitor.cpp @@ -0,0 +1,117 @@ +/* + * 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 "component_monitor.h" + +#include + +#include "iservice_registry.h" +#include "system_ability_definition.h" + +#include "anonymous_string.h" +#include "component_loader.h" +#include "component_manager.h" +#include "device_type.h" +#include "distributed_hardware_errno.h" +#include "distributed_hardware_log.h" + +namespace OHOS { +namespace DistributedHardware { +ComponentMonitor::ComponentMonitor() : saListeners_({}) +{ + DHLOGI("Ctor ComponentMonitor"); +} + +ComponentMonitor::~ComponentMonitor() +{ + DHLOGI("Dtor ComponentMonitor"); + std::lock_guard lock(saListenersMtx_); + saListeners_.clear(); +} + +void ComponentMonitor::CompSystemAbilityListener::OnAddSystemAbility(int32_t saId, const std::string &deviceId) +{ + DHLOGI("OnAddSystemAbility, saId: %d, deviceId: %s", saId, GetAnonyString(deviceId).c_str()); +} + +void ComponentMonitor::CompSystemAbilityListener::OnRemoveSystemAbility(int32_t saId, const std::string &deviceId) +{ + DHLOGI("OnRemoveSystemAbility, saId: %d, deviceId: %s", saId, GetAnonyString(deviceId).c_str()); + DHType dhType = ComponentLoader::GetInstance().GetDHTypeBySrcSaId(saId); + if (dhType == DHType::UNKNOWN) { + DHLOGE("Can not find DHType by sa Id: %d", saId); + return; + } + + DHLOGI("Try Recover Component, dhType: %" PRIu32, (uint32_t)dhType); + ComponentManager::GetInstance().Recover(dhType); +} + +void ComponentMonitor::AddSAMonitor(int32_t saId) +{ + DHLOGI("Try add sa monitor, saId: %" PRIu32, saId); + std::lock_guard lock(saListenersMtx_); + if (saListeners_.find(saId) != saListeners_.end()) { + DHLOGW("SaId is in monitor, id: %" PRIu32, saId); + return; + } + + sptr listener = new CompSystemAbilityListener(); + sptr systemAbilityManager = + SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + if (!systemAbilityManager) { + DHLOGE("get system ability manager failed."); + return; + } + + int32_t ret = systemAbilityManager->SubscribeSystemAbility(saId, listener); + if (ret != DH_FWK_SUCCESS) { + DHLOGE("subscribe sa change listener failed: %d", ret); + return; + } + + saListeners_[saId] = listener; + DHLOGI("subscribe sa change listener success."); + return; +} + +void ComponentMonitor::RemoveSAMonitor(int32_t saId) +{ + DHLOGI("Try remove sa monitor, saId: %" PRIu32, saId); + std::lock_guard lock(saListenersMtx_); + if (saListeners_.find(saId) == saListeners_.end()) { + DHLOGW("can not find sa listener info, id: %" PRIu32, saId); + return; + } + + sptr systemAbilityManager = + SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + if (!systemAbilityManager) { + DHLOGE("get system ability manager failed."); + return; + } + + int32_t ret = systemAbilityManager->UnSubscribeSystemAbility(saId, saListeners_[saId]); + if (ret != DH_FWK_SUCCESS) { + DHLOGE("unsubscribe sa change listener failed: %d", ret); + return; + } + + saListeners_.erase(saId); + DHLOGI("unsubscribe sa change listener success"); + return; +} +} // namespace DistributedHardware +} // namespace OHOS \ No newline at end of file diff --git a/services/distributedhardwarefwkservice/src/distributed_hardware_stub.cpp b/services/distributedhardwarefwkservice/src/distributed_hardware_stub.cpp index e1fcee7ed68c787e303ed5aed2ea4c33cf7ea78d..0ede44fe58eba8c4bbf071a533b60c3d4d7824d5 100644 --- a/services/distributedhardwarefwkservice/src/distributed_hardware_stub.cpp +++ b/services/distributedhardwarefwkservice/src/distributed_hardware_stub.cpp @@ -66,7 +66,7 @@ int32_t DistributedHardwareStub::RegisterPublisherListenerInner(MessageParcel &d reply.WriteInt32(ERR_DH_FWK_PARA_INVALID); return ERR_DH_FWK_PARA_INVALID; } - DHLOGI("Register listener, topic: %" PRIu32 , (uint32_t)topic); + DHLOGI("Register listener, topic: %" PRIu32, (uint32_t)topic); RegisterPublisherListener(topic, listener); reply.WriteInt32(DH_FWK_SUCCESS); return DH_FWK_SUCCESS; @@ -88,7 +88,7 @@ int32_t DistributedHardwareStub::UnregisterPublisherListenerInner(MessageParcel reply.WriteInt32(ERR_DH_FWK_PARA_INVALID); return ERR_DH_FWK_PARA_INVALID; } - DHLOGI("Unregister listener, topic: %" PRIu32 , (uint32_t)topic); + DHLOGI("Unregister listener, topic: %" PRIu32, (uint32_t)topic); UnregisterPublisherListener(topic, listener); reply.WriteInt32(DH_FWK_SUCCESS); return DH_FWK_SUCCESS; diff --git a/services/distributedhardwarefwkservice/src/resourcemanager/capability_info_manager.cpp b/services/distributedhardwarefwkservice/src/resourcemanager/capability_info_manager.cpp index 1516268afcd63fb50fb88ea2def89f7e2b87776a..cb39f613fcbe48337a8a9b86795ce4026abfc0a9 100644 --- a/services/distributedhardwarefwkservice/src/resourcemanager/capability_info_manager.cpp +++ b/services/distributedhardwarefwkservice/src/resourcemanager/capability_info_manager.cpp @@ -518,6 +518,18 @@ int32_t CapabilityInfoManager::GetDataByKey(const std::string &key, std::shared_ return CapabilityUtils::GetCapabilityByValue(data, capInfoPtr); } +int32_t CapabilityInfoManager::GetDataByDHType(const DHType dhType, CapabilityInfoMap &capabilityMap) +{ + std::lock_guard lock(capInfoMgrMutex_); + for (const auto &capInfo : globalCapInfoMap_) { + if (capInfo.second->GetDHType() != dhType) { + continue; + } + capabilityMap[capInfo.first] = capInfo.second; + } + return DH_FWK_SUCCESS; +} + int32_t CapabilityInfoManager::GetDataByKeyPrefix(const std::string &keyPrefix, CapabilityInfoMap &capabilityMap) { std::lock_guard lock(capInfoMgrMutex_); diff --git a/services/distributedhardwarefwkservice/src/task/task_executor.cpp b/services/distributedhardwarefwkservice/src/task/task_executor.cpp index 45316ea519326b415b54a774e9d0d7aa7345a9fc..0d8a649e29974859bec1c64e9fc44a23e45f07ad 100644 --- a/services/distributedhardwarefwkservice/src/task/task_executor.cpp +++ b/services/distributedhardwarefwkservice/src/task/task_executor.cpp @@ -23,6 +23,9 @@ namespace OHOS { namespace DistributedHardware { +namespace { + const uint32_t MAX_TASK_QUEUE_LENGTH = 256; +} IMPLEMENT_SINGLE_INSTANCE(TaskExecutor); TaskExecutor::TaskExecutor() : taskThreadFlag_(true) { @@ -46,6 +49,10 @@ void TaskExecutor::PushTask(const std::shared_ptr& task) { DHLOGI("Push task: %s", task->GetId().c_str()); std::unique_lock lock(taskQueueMtx_); + if (taskQueue_.size() > MAX_TASK_QUEUE_LENGTH) { + DHLOGE("Task queue is full"); + return; + } taskQueue_.push(task); } diff --git a/services/distributedhardwarefwkservice/test/fuzztest/componentloader_fuzzer/componentloader_fuzzer.cpp b/services/distributedhardwarefwkservice/test/fuzztest/componentloader_fuzzer/componentloader_fuzzer.cpp index fde0fba405c7d3de3e0671548f7da47ae27a8f37..8615305233c2537f5da01272dfaec9a8905732b3 100644 --- a/services/distributedhardwarefwkservice/test/fuzztest/componentloader_fuzzer/componentloader_fuzzer.cpp +++ b/services/distributedhardwarefwkservice/test/fuzztest/componentloader_fuzzer/componentloader_fuzzer.cpp @@ -28,7 +28,7 @@ namespace DistributedHardware { namespace { const uint32_t DH_TYPE_SIZE = 10; const DHType dhTypeFuzz[DH_TYPE_SIZE] = { - DHType::CAMERA, DHType::AUDIO, DHType::DISPLAY, DHType::VIRMODEM_MIC, + DHType::CAMERA, DHType::AUDIO, DHType::SCREEN, DHType::VIRMODEM_MIC, DHType::INPUT, DHType::A2D, DHType::GPS, DHType::HFP, DHType::VIRMODEM_SPEAKER }; } diff --git a/services/distributedhardwarefwkservice/test/fuzztest/componentmanager_fuzzer/componentmanager_fuzzer.cpp b/services/distributedhardwarefwkservice/test/fuzztest/componentmanager_fuzzer/componentmanager_fuzzer.cpp index c05bf82249b775610e6f40a0185c771ee64ef651..1ead2ed89d1af330c90f1c522abf66857dc07cdb 100644 --- a/services/distributedhardwarefwkservice/test/fuzztest/componentmanager_fuzzer/componentmanager_fuzzer.cpp +++ b/services/distributedhardwarefwkservice/test/fuzztest/componentmanager_fuzzer/componentmanager_fuzzer.cpp @@ -30,7 +30,7 @@ namespace DistributedHardware { namespace { const uint32_t DH_TYPE_SIZE = 10; const DHType dhTypeFuzz[DH_TYPE_SIZE] = { - DHType::CAMERA, DHType::AUDIO, DHType::DISPLAY, DHType::VIRMODEM_MIC, + DHType::CAMERA, DHType::AUDIO, DHType::SCREEN, DHType::VIRMODEM_MIC, DHType::INPUT, DHType::A2D, DHType::GPS, DHType::HFP, DHType::VIRMODEM_SPEAKER }; } diff --git a/services/distributedhardwarefwkservice/test/fuzztest/resourcemanager_fuzzer/resourcemanager_fuzzer.cpp b/services/distributedhardwarefwkservice/test/fuzztest/resourcemanager_fuzzer/resourcemanager_fuzzer.cpp index 64bb8c0949a936c59ebba3ef35c20fd00403f4eb..852fc8bb9662a5f7aa9413ed0dea6678f55f1ec8 100644 --- a/services/distributedhardwarefwkservice/test/fuzztest/resourcemanager_fuzzer/resourcemanager_fuzzer.cpp +++ b/services/distributedhardwarefwkservice/test/fuzztest/resourcemanager_fuzzer/resourcemanager_fuzzer.cpp @@ -31,7 +31,7 @@ namespace DistributedHardware { namespace { const uint32_t DH_TYPE_SIZE = 10; const DHType dhTypeFuzz[DH_TYPE_SIZE] = { - DHType::CAMERA, DHType::AUDIO, DHType::DISPLAY, DHType::VIRMODEM_MIC, + DHType::CAMERA, DHType::AUDIO, DHType::SCREEN, DHType::VIRMODEM_MIC, DHType::INPUT, DHType::A2D, DHType::GPS, DHType::HFP, DHType::VIRMODEM_SPEAKER }; } diff --git a/services/distributedhardwarefwkservice/test/fuzztest/task_fuzzer/task_fuzzer.cpp b/services/distributedhardwarefwkservice/test/fuzztest/task_fuzzer/task_fuzzer.cpp index ea875f80bf48473c4a106f1f20368e56ef87fe35..22f17590b8ed3b756dfc34f4fa8eefee2989eb8c 100644 --- a/services/distributedhardwarefwkservice/test/fuzztest/task_fuzzer/task_fuzzer.cpp +++ b/services/distributedhardwarefwkservice/test/fuzztest/task_fuzzer/task_fuzzer.cpp @@ -30,7 +30,7 @@ namespace DistributedHardware { namespace { const uint32_t DH_TYPE_SIZE = 10; const DHType dhTypeFuzz[DH_TYPE_SIZE] = { - DHType::CAMERA, DHType::AUDIO, DHType::DISPLAY, DHType::VIRMODEM_MIC, + DHType::CAMERA, DHType::AUDIO, DHType::SCREEN, DHType::VIRMODEM_MIC, DHType::INPUT, DHType::A2D, DHType::GPS, DHType::HFP, DHType::VIRMODEM_SPEAKER }; diff --git a/services/distributedhardwarefwkservice/test/fuzztest/versioninfomanager_fuzzer/versioninfomanager_fuzzer.cpp b/services/distributedhardwarefwkservice/test/fuzztest/versioninfomanager_fuzzer/versioninfomanager_fuzzer.cpp index 340d9e0b4ef16cc80e133b3d1012d0b5289ee1fc..264e442167b48992eacee4fbdea2ffa94659e39f 100644 --- a/services/distributedhardwarefwkservice/test/fuzztest/versioninfomanager_fuzzer/versioninfomanager_fuzzer.cpp +++ b/services/distributedhardwarefwkservice/test/fuzztest/versioninfomanager_fuzzer/versioninfomanager_fuzzer.cpp @@ -32,7 +32,7 @@ namespace { constexpr uint32_t SLEEP_TIME_US = 10 * 1000; const uint32_t DH_TYPE_SIZE = 10; const DHType dhTypeFuzz[DH_TYPE_SIZE] = { - DHType::CAMERA, DHType::AUDIO, DHType::DISPLAY, DHType::VIRMODEM_MIC, + DHType::CAMERA, DHType::AUDIO, DHType::SCREEN, DHType::VIRMODEM_MIC, DHType::INPUT, DHType::A2D, DHType::GPS, DHType::HFP, DHType::VIRMODEM_SPEAKER }; } diff --git a/services/distributedhardwarefwkservice/test/unittest/common/componentmanager/src/component_manager_test.cpp b/services/distributedhardwarefwkservice/test/unittest/common/componentmanager/src/component_manager_test.cpp index 591b9a7fe14d810c359253b663ffc22cb466ba56..a09736fa7048bfe2009a2d9814c98ff9b5d12ae5 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/componentmanager/src/component_manager_test.cpp +++ b/services/distributedhardwarefwkservice/test/unittest/common/componentmanager/src/component_manager_test.cpp @@ -189,7 +189,7 @@ HWTEST_F(ComponentManagerTest, init_test_003, TestSize.Level0) EXPECT_CALL(cameraSource, InitSource(testing::_)).Times(1).WillOnce(testing::Invoke(handler)); MockIDistributedHardwareSource displaySource; - ComponentManager::GetInstance().compSource_.insert(std::make_pair(DHType::DISPLAY, &displaySource)); + ComponentManager::GetInstance().compSource_.insert(std::make_pair(DHType::SCREEN, &displaySource)); EXPECT_CALL(displaySource, InitSource(testing::_)).Times(1).WillOnce(testing::Invoke(handler)); MockIDistributedHardwareSink micSink; @@ -224,7 +224,7 @@ HWTEST_F(ComponentManagerTest, unInit_test_001, TestSize.Level0) EXPECT_CALL(cameraSource, ReleaseSource()).Times(1).WillOnce(testing::Invoke(handler)); MockIDistributedHardwareSink displaycSink; - ComponentManager::GetInstance().compSink_.insert(std::make_pair(DHType::DISPLAY, &displaycSink)); + ComponentManager::GetInstance().compSink_.insert(std::make_pair(DHType::SCREEN, &displaycSink)); EXPECT_CALL(displaycSink, ReleaseSink()).Times(1).WillOnce(testing::Invoke(handler)); MockIDistributedHardwareSink micSink; diff --git a/services/distributedhardwarefwkservice/test/unittest/common/resourcemanager/src/resource_manager_test.cpp b/services/distributedhardwarefwkservice/test/unittest/common/resourcemanager/src/resource_manager_test.cpp index 3fb148b9f637eb07284efcbe98650b243295b38f..c37786b31762904316ecd17e61b008ec538c6a71 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/resourcemanager/src/resource_manager_test.cpp +++ b/services/distributedhardwarefwkservice/test/unittest/common/resourcemanager/src/resource_manager_test.cpp @@ -67,7 +67,7 @@ const shared_ptr CAP_INFO_1 = const shared_ptr CAP_INFO_2 = make_shared(DH_ID_2, DEV_ID_0, DEV_NAME, TEST_DEV_TYPE_PAD, DHType::GPS, DH_ATTR_0); const shared_ptr CAP_INFO_3 = - make_shared(DH_ID_3, DEV_ID_0, DEV_NAME, TEST_DEV_TYPE_PAD, DHType::DISPLAY, DH_ATTR_0); + make_shared(DH_ID_3, DEV_ID_0, DEV_NAME, TEST_DEV_TYPE_PAD, DHType::SCREEN, DH_ATTR_0); const shared_ptr CAP_INFO_4 = make_shared(DH_ID_4, DEV_ID_0, DEV_NAME, TEST_DEV_TYPE_PAD, DHType::INPUT, DH_ATTR_0); @@ -78,7 +78,7 @@ const shared_ptr CAP_INFO_6 = const shared_ptr CAP_INFO_7 = make_shared(DH_ID_2, DEV_ID_1, DEV_NAME, TEST_DEV_TYPE_PAD, DHType::GPS, DH_ATTR_1); const shared_ptr CAP_INFO_8 = - make_shared(DH_ID_3, DEV_ID_1, DEV_NAME, TEST_DEV_TYPE_PAD, DHType::DISPLAY, DH_ATTR_1); + make_shared(DH_ID_3, DEV_ID_1, DEV_NAME, TEST_DEV_TYPE_PAD, DHType::SCREEN, DH_ATTR_1); const shared_ptr CAP_INFO_9 = make_shared(DH_ID_4, DEV_ID_1, DEV_NAME, TEST_DEV_TYPE_PAD, DHType::INPUT, DH_ATTR_1); } diff --git a/services/distributedhardwarefwkservice/test/unittest/common/task/src/task_test.cpp b/services/distributedhardwarefwkservice/test/unittest/common/task/src/task_test.cpp index 8a9fdf71180a117eaa9f93ea55aa3c843558d94c..4e648fd86ee821e72f1edc8f34cc41780e24a611 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/task/src/task_test.cpp +++ b/services/distributedhardwarefwkservice/test/unittest/common/task/src/task_test.cpp @@ -40,7 +40,7 @@ const std::string DEV_NETWORK_ID_1 = "nt36a637105409e904d4da83790a4a8"; const MockDevInfo DEV_INFO_11 = { DEV_NETWORK_ID_1, DEV_ID_1, "Camera_1", DHType::CAMERA }; const MockDevInfo DEV_INFO_12 = { DEV_NETWORK_ID_1, DEV_ID_1, "Gps_1", DHType::GPS }; const MockDevInfo DEV_INFO_13 = { DEV_NETWORK_ID_1, DEV_ID_1, "Audio_1", DHType::AUDIO }; -const MockDevInfo DEV_INFO_14 = { DEV_NETWORK_ID_1, DEV_ID_1, "Display_1", DHType::DISPLAY }; +const MockDevInfo DEV_INFO_14 = { DEV_NETWORK_ID_1, DEV_ID_1, "Display_1", DHType::SCREEN }; const MockDevInfo DEV_INFO_15 = { DEV_NETWORK_ID_1, DEV_ID_1, "Input_1", DHType::INPUT }; const std::string DEV_ID_2 = "06d177ffa09543389f3b445b4722f9be"; @@ -48,7 +48,7 @@ const std::string DEV_NETWORK_ID_2 = "ntd177ffa09543389f3b445b4722f9be"; const MockDevInfo DEV_INFO_21 = { DEV_NETWORK_ID_2, DEV_ID_2, "Camera_1", DHType::CAMERA }; const MockDevInfo DEV_INFO_22 = { DEV_NETWORK_ID_2, DEV_ID_2, "Gps_1", DHType::GPS }; const MockDevInfo DEV_INFO_23 = { DEV_NETWORK_ID_2, DEV_ID_2, "Audio_1", DHType::AUDIO }; -const MockDevInfo DEV_INFO_24 = { DEV_NETWORK_ID_2, DEV_ID_2, "Display_1", DHType::DISPLAY }; +const MockDevInfo DEV_INFO_24 = { DEV_NETWORK_ID_2, DEV_ID_2, "Display_1", DHType::SCREEN }; const MockDevInfo DEV_INFO_25 = { DEV_NETWORK_ID_2, DEV_ID_2, "Input_1", DHType::INPUT }; const TaskParam TASK_PARAM_1 = { diff --git a/services/distributedhardwarefwkservice/test/unittest/common/versioninfomanager/src/version_info_manager_test.cpp b/services/distributedhardwarefwkservice/test/unittest/common/versioninfomanager/src/version_info_manager_test.cpp index 5475fb074493a822171db50ab109cc22b00cbdd3..c9716e056c5e32c041e1bd3a39de265c1915f1b0 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/versioninfomanager/src/version_info_manager_test.cpp +++ b/services/distributedhardwarefwkservice/test/unittest/common/versioninfomanager/src/version_info_manager_test.cpp @@ -61,7 +61,7 @@ std::vector CreateVersionInfos() CompVersion compVersions2 = { .name = NAME_SCREEN, - .dhType = DHType::DISPLAY, + .dhType = DHType::SCREEN, .handlerVersion = VERSION_2, .sourceVersion = VERSION_2, .sinkVersion = VERSION_2 diff --git a/services/distributedhardwarefwkservice/test/unittest/common/versioninfomanager/src/version_info_test.cpp b/services/distributedhardwarefwkservice/test/unittest/common/versioninfomanager/src/version_info_test.cpp index 0de57f655dd31ace598ac24294870725f6127caf..2c73db990d46c3da56a06d62c0d105e77e99d233 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/versioninfomanager/src/version_info_test.cpp +++ b/services/distributedhardwarefwkservice/test/unittest/common/versioninfomanager/src/version_info_test.cpp @@ -67,7 +67,7 @@ HWTEST_F(VersionInfoTest, version_info_test_001, TestSize.Level0) { CompVersion compVersions1 = { .name = NAME_SCREEN, - .dhType = DHType::DISPLAY, + .dhType = DHType::SCREEN, .handlerVersion = VERSION_1, .sourceVersion = VERSION_1, .sinkVersion = VERSION_1 diff --git a/services/distributedhardwarefwkservice/test/unittest/common/versionmanager/src/version_manager_test.cpp b/services/distributedhardwarefwkservice/test/unittest/common/versionmanager/src/version_manager_test.cpp index 865d4367beb269bceb939cb3f1b9e2477d815056..4193cc1bd7bf96163bee2b6848965430fbcff0a1 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/versionmanager/src/version_manager_test.cpp +++ b/services/distributedhardwarefwkservice/test/unittest/common/versionmanager/src/version_manager_test.cpp @@ -94,7 +94,7 @@ HWTEST_F(VersionManagerTest, version_manager_test_002, TestSize.Level0) CompVersionGetValue(cVs2, TEST_COMPONENT_NAME_2, DHType::AUDIO, TEST_HANDLER_VERSION_2, TEST_SOURCE_VERSION_2, TEST_SINK_VERSION_2); CompVersion cVs3; - CompVersionGetValue(cVs3, TEST_COMPONENT_NAME_3, DHType::DISPLAY, TEST_HANDLER_VERSION_3, TEST_SOURCE_VERSION_3, + CompVersionGetValue(cVs3, TEST_COMPONENT_NAME_3, DHType::SCREEN, TEST_HANDLER_VERSION_3, TEST_SOURCE_VERSION_3, TEST_SINK_VERSION_3); dhVersion.uuid = TEST_DEVICE_ID_1; dhVersion.dhVersion = TEST_DH_VERSION;