diff --git a/common/utils/include/constants.h b/common/utils/include/constants.h index 21c2b951c2a2bde25d212ae1c8e751d2ccff787a..72da5f4703b3fc6fff9094354388f149e3aca953 100644 --- a/common/utils/include/constants.h +++ b/common/utils/include/constants.h @@ -37,8 +37,6 @@ namespace DistributedHardware { constexpr uint32_t MAX_SWITCH_SIZE = 256; const std::string LOW_LATENCY_KEY = "identity"; const std::u16string DHMS_STUB_INTERFACE_TOKEN = u"ohos.distributedhardware.accessToken"; - const std::string COMPONENTSLOAD_PROFILE_PATH = - R"(/vendor/etc/distributedhardware/distributed_hardware_components_cfg.json)"; const std::string APP_ID = "dtbhardware_manager_service"; const std::string GLOBAL_CAPABILITY_ID = "global_capability_info"; const std::string GLOBAL_VERSION_ID = "global_version_info"; @@ -72,6 +70,8 @@ namespace DistributedHardware { constexpr const char *TRIGGER_TASK = "TriggerTask"; constexpr const char *EVENT_RUN = "EventRun"; constexpr const char *START_EVENT = "StartEvent"; + constexpr const char *COMPONENTSLOAD_PROFILE_PATH = + "etc/distributedhardware/distributed_hardware_components_cfg.json"; } // namespace DistributedHardware } // namespace OHOS #endif diff --git a/services/distributedhardwarefwkservice/BUILD.gn b/services/distributedhardwarefwkservice/BUILD.gn index 8c402de66d06556719dbbadd78a906829b79a414..1167c17c9145477bbf66e6a24dee908f693142b8 100644 --- a/services/distributedhardwarefwkservice/BUILD.gn +++ b/services/distributedhardwarefwkservice/BUILD.gn @@ -107,6 +107,7 @@ ohos_shared_library("distributedhardwarefwksvr") { external_deps = [ "c_utils:utils", + "config_policy:configpolicy_util", "eventhandler:libeventhandler", "init:libbegetutil", "ipc:ipc_core", diff --git a/services/distributedhardwarefwkservice/src/componentloader/component_loader.cpp b/services/distributedhardwarefwkservice/src/componentloader/component_loader.cpp index af90a6134bcd704b250597b092c8bea9afbf10c6..60853bfcca15114387e4304f9927188297f4829a 100644 --- a/services/distributedhardwarefwkservice/src/componentloader/component_loader.cpp +++ b/services/distributedhardwarefwkservice/src/componentloader/component_loader.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2023 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 @@ -20,6 +20,7 @@ #include #include +#include "config_policy_utils.h" #include "nlohmann/json.hpp" #include "constants.h" @@ -349,7 +350,10 @@ int32_t ComponentLoader::ParseConfig() std::map dhtypeMap; int32_t ret; DHLOGI("ParseConfig start"); - std::string jsonStr = Readfile(COMPONENTSLOAD_PROFILE_PATH); + char buf[MAX_PATH_LEN] = {0}; + char *profilePath = GetOneCfgFile(COMPONENTSLOAD_PROFILE_PATH, buf, MAX_PATH_LEN); + std::string componentProfilePath(profilePath); + std::string jsonStr = Readfile(componentProfilePath); if (jsonStr.length() == 0 || jsonStr.size() > MAX_MESSAGE_LEN) { DHLOGE("ConfigJson size is invalid!"); return ERR_DH_FWK_LOADER_CONFIG_JSON_INVALID; diff --git a/services/distributedhardwarefwkservice/test/unittest/common/componentloader/BUILD.gn b/services/distributedhardwarefwkservice/test/unittest/common/componentloader/BUILD.gn index f40cfb79b02fb7091825bf56a6d4c27e88481acc..cc59fbb0de66c54bbc23ee34196d6ed1a874836b 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/componentloader/BUILD.gn +++ b/services/distributedhardwarefwkservice/test/unittest/common/componentloader/BUILD.gn @@ -51,7 +51,10 @@ ohos_unittest("ComponentLoaderTest") { "//third_party/googletest:gtest_main", ] - external_deps = [ "hitrace_native:hitrace_meter" ] + external_deps = [ + "config_policy:configpolicy_util", + "hitrace_native:hitrace_meter", + ] defines = [ "HI_LOG_ENABLE",