diff --git a/services/distributedhardwarefwkservice/BUILD.gn b/services/distributedhardwarefwkservice/BUILD.gn index a3d7134e402eb35f1dd84c30b722f9dd3566c6e8..f91d94a5fef27d4ff8e17a2a8d6d98d7cf279183 100644 --- a/services/distributedhardwarefwkservice/BUILD.gn +++ b/services/distributedhardwarefwkservice/BUILD.gn @@ -126,6 +126,10 @@ ohos_shared_library("distributedhardwarefwksvr") { defines += [ "DHARDWARE_OPEN_SOURCE" ] } + if (distributed_hardware_fwk_low_latency) { + defines += [ "DHARDWARE_CHECK_RESOURCE" ] + } + external_deps = [ "ability_base:want", "ability_runtime:ability_manager", diff --git a/services/distributedhardwarefwkservice/include/componentmanager/component_manager.h b/services/distributedhardwarefwkservice/include/componentmanager/component_manager.h index cdb9e2b901e03d130febd5391fd6a16a1271a2f5..45757d4deb58a834b7c051267687cfdc4d89c130 100644 --- a/services/distributedhardwarefwkservice/include/componentmanager/component_manager.h +++ b/services/distributedhardwarefwkservice/include/componentmanager/component_manager.h @@ -136,6 +136,7 @@ private: int32_t GetCapParam(const std::string &uuid, const std::string &dhId, std::shared_ptr &capability); int32_t GetMetaParam(const std::string &uuid, const std::string &dhId, std::shared_ptr &metaCapPtr); + int32_t CheckSubtypeResource(const std::string &subtype, const std::string &networkId); private: std::map compSource_; diff --git a/services/distributedhardwarefwkservice/src/componentmanager/component_manager.cpp b/services/distributedhardwarefwkservice/src/componentmanager/component_manager.cpp index 17e0d07b4e49fdebf096e32105d41f3ac67637b7..6fe8f1427b4ec2c024cc44fbce77af139aa4b08d 100644 --- a/services/distributedhardwarefwkservice/src/componentmanager/component_manager.cpp +++ b/services/distributedhardwarefwkservice/src/componentmanager/component_manager.cpp @@ -554,17 +554,10 @@ int32_t ComponentManager::Enable(const std::string &networkId, const std::string return ret; } } - std::string subtype = param.subtype; - std::map resourceDesc = ComponentLoader::GetInstance().GetCompResourceDesc(); - if (resourceDesc.find(subtype) == resourceDesc.end()) { - DHLOGE("GetCompResourceDesc failed, subtype: %{public}s", subtype.c_str()); - return ERR_DH_FWK_RESOURCE_KEY_IS_EMPTY; - } - bool sensitiveVal = resourceDesc[subtype]; - bool isSameAuthForm = IsIdenticalAccount(networkId); - if (sensitiveVal && !isSameAuthForm) { - DHLOGE("Privacy resources must be logged in with the same account."); - return ERR_DH_FWK_COMPONENT_ENABLE_FAILED; + ret = CheckSubtypeResource(param.subtype, networkId); + if (ret != DH_FWK_SUCCESS) { + DHLOGE("CheckSubtypeResource failed, ret = %{public}d.", ret); + return ret; } auto compEnable = std::make_shared(); @@ -591,6 +584,22 @@ int32_t ComponentManager::Enable(const std::string &networkId, const std::string return result; } +int32_t ComponentManager::CheckSubtypeResource(const std::string &subtype, const std::string &networkId) +{ +#ifdef DHARDWARE_CHECK_RESOURCE + std::map resourceDesc = ComponentLoader::GetInstance().GetCompResourceDesc(); + if (resourceDesc.find(subtype) == resourceDesc.end()) { + DHLOGE("GetCompResourceDesc failed, subtype: %{public}s", subtype.c_str()); + return ERR_DH_FWK_RESOURCE_KEY_IS_EMPTY; + } + if (resourceDesc[subtype] && !IsIdenticalAccount(networkId)) { + DHLOGE("Privacy resources must be logged in with the same account."); + return ERR_DH_FWK_COMPONENT_ENABLE_FAILED; + } +#endif + return DH_FWK_SUCCESS; +} + int32_t ComponentManager::RetryGetEnableParam(const std::string &networkId, const std::string &uuid, const std::string &dhId, const DHType dhType, EnableParam ¶m) {