diff --git a/interfaces/inner_kits/src/ipc/distributed_hardware_proxy.cpp b/interfaces/inner_kits/src/ipc/distributed_hardware_proxy.cpp index cb54443031adbda5abe02cad501308adc93d094f..62dc1ae9e116824e9389e801ae390ef6fc0c698c 100644 --- a/interfaces/inner_kits/src/ipc/distributed_hardware_proxy.cpp +++ b/interfaces/inner_kits/src/ipc/distributed_hardware_proxy.cpp @@ -46,7 +46,7 @@ int32_t DistributedHardwareProxy::RegisterPublisherListener(const DHTopic topic, DHLOGE("remote service is null"); return ERR_DH_FWK_SERVICE_REMOTE_IS_NULL; } - if (DHTopic::TOPIC_MIN > topic || topic > DHTopic::TOPIC_MAX) { + if (topic < DHTopic::TOPIC_MIN || topic > DHTopic::TOPIC_MAX) { DHLOGE("Topic is invalid!"); return ERR_DH_FWK_PARA_INVALID; } @@ -95,7 +95,7 @@ int32_t DistributedHardwareProxy::UnregisterPublisherListener(const DHTopic topi DHLOGE("remote service is null"); return ERR_DH_FWK_SERVICE_REMOTE_IS_NULL; } - if (DHTopic::TOPIC_MIN > topic || topic > DHTopic::TOPIC_MAX) { + if (topic < DHTopic::TOPIC_MIN || topic > DHTopic::TOPIC_MAX) { DHLOGE("Topic is invalid!"); return ERR_DH_FWK_PARA_INVALID; } @@ -138,7 +138,7 @@ int32_t DistributedHardwareProxy::PublishMessage(const DHTopic topic, const std: DHLOGE("remote service is null"); return ERR_DH_FWK_SERVICE_REMOTE_IS_NULL; } - if (DHTopic::TOPIC_MIN > topic || topic > DHTopic::TOPIC_MAX) { + if (topic < DHTopic::TOPIC_MIN || topic > DHTopic::TOPIC_MAX) { DHLOGE("Topic is invalid!"); return ERR_DH_FWK_PARA_INVALID; } diff --git a/interfaces/inner_kits/src/ipc/publisher_listener_stub.cpp b/interfaces/inner_kits/src/ipc/publisher_listener_stub.cpp index 9296ad6a8a2434bf1ee2ee47ecb6af63e7f61456..db73fa8a6c3876d5174ca8f9d6f848910ab53e3d 100644 --- a/interfaces/inner_kits/src/ipc/publisher_listener_stub.cpp +++ b/interfaces/inner_kits/src/ipc/publisher_listener_stub.cpp @@ -39,8 +39,8 @@ int32_t PublisherListenerStub::OnRemoteRequest( IPublisherListener::Message msgCode = static_cast(code); switch (msgCode) { case IPublisherListener::Message::ON_MESSAGE: { - DHTopic topic = (DHTopic)data.ReadUint32(); - if (DHTopic::TOPIC_MIN > topic || topic > DHTopic::TOPIC_MAX) { + DHTopic topic = static_cast(data.ReadUint32()); + if (topic < DHTopic::TOPIC_MIN || topic > DHTopic::TOPIC_MAX) { DHLOGE("Topic is invalid!"); return ERR_INVALID_DATA; } diff --git a/services/distributedhardwarefwkservice/include/componentloader/component_loader.h b/services/distributedhardwarefwkservice/include/componentloader/component_loader.h index 3ff04a4341a80a48465c26fc4cece6369feed032..1a45ec7f118bb29ff7e4f7fb1e7d9725f49820a0 100644 --- a/services/distributedhardwarefwkservice/include/componentloader/component_loader.h +++ b/services/distributedhardwarefwkservice/include/componentloader/component_loader.h @@ -39,8 +39,6 @@ struct CompHandler { int32_t sinkSaId; void *hardwareHandler; }; - -const std::string COMPONENTSLOAD_DISTRIBUTED_COMPONENTS = "distributed_components"; } struct CompConfig { diff --git a/services/distributedhardwarefwkservice/include/localhardwaremanager/local_hardware_manager.h b/services/distributedhardwarefwkservice/include/localhardwaremanager/local_hardware_manager.h index 26008e273bd4974da2e0e32c683c90b54702f2fb..e1a118d94a200f29439cb8b00150c34fb7924915 100644 --- a/services/distributedhardwarefwkservice/include/localhardwaremanager/local_hardware_manager.h +++ b/services/distributedhardwarefwkservice/include/localhardwaremanager/local_hardware_manager.h @@ -27,11 +27,6 @@ namespace OHOS { namespace DistributedHardware { -namespace { - constexpr int32_t QUERY_INTERVAL_TIME = 1000 * 1000; // 1s - constexpr int32_t QUERY_RETRY_MAX_TIMES = 30; -} - class LocalHardwareManager { DECLARE_SINGLE_INSTANCE_BASE(LocalHardwareManager); diff --git a/services/distributedhardwarefwkservice/include/resourcemanager/capability_info_manager.h b/services/distributedhardwarefwkservice/include/resourcemanager/capability_info_manager.h index 8958acc3ba72bbd7656a42d3b536315ad157ea10..47d1a8818ca47358e158439d86e13e84598b4b6f 100644 --- a/services/distributedhardwarefwkservice/include/resourcemanager/capability_info_manager.h +++ b/services/distributedhardwarefwkservice/include/resourcemanager/capability_info_manager.h @@ -35,9 +35,6 @@ class DBAdapter; namespace OHOS { namespace DistributedHardware { -namespace { - constexpr int32_t MANUAL_SYNC_TIMEOUT = 1; -} class CapabilityInfoManager : public std::enable_shared_from_this, public EventSender, public DistributedKv::KvStoreObserver, diff --git a/services/distributedhardwarefwkservice/include/resourcemanager/db_adapter.h b/services/distributedhardwarefwkservice/include/resourcemanager/db_adapter.h index f2d052d1f267c6ff8d8f7f09814e7fb57bc40b81..6d09605b4bd8d781e944be528f8db05f5acd466f 100644 --- a/services/distributedhardwarefwkservice/include/resourcemanager/db_adapter.h +++ b/services/distributedhardwarefwkservice/include/resourcemanager/db_adapter.h @@ -31,14 +31,6 @@ namespace OHOS { namespace DistributedHardware { -namespace { -constexpr int32_t MAX_INIT_RETRY_TIMES = 20; -constexpr int32_t INIT_RETRY_SLEEP_INTERVAL = 200 * 1000; // 200ms -constexpr int32_t MANUAL_SYNC_TIMES = 6; -constexpr int32_t MANUAL_SYNC_INTERVAL = 100 * 1000; // 100ms -constexpr int32_t DIED_CHECK_MAX_TIMES = 300; -constexpr int32_t DIED_CHECK_INTERVAL = 100 * 1000; // 100ms -} class DBAdapter : public std::enable_shared_from_this, public EventSender, public DistributedKv::KvStoreSyncCallback, diff --git a/services/distributedhardwarefwkservice/src/componentloader/component_loader.cpp b/services/distributedhardwarefwkservice/src/componentloader/component_loader.cpp index d4cc5c3709abae0e1044b914b4a4ff3255513242..7f54475a34ca43108c9d3702031715b3cd132525 100644 --- a/services/distributedhardwarefwkservice/src/componentloader/component_loader.cpp +++ b/services/distributedhardwarefwkservice/src/componentloader/component_loader.cpp @@ -55,6 +55,8 @@ 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 COMPONENTSLOAD_DISTRIBUTED_COMPONENTS = "distributed_components"; + const std::string DEFAULT_NAME = ""; const std::string DEFAULT_TYPE = "UNKNOWN"; const std::string DEFAULT_LOC = ""; diff --git a/services/distributedhardwarefwkservice/src/ipc/publisher_listener_proxy.cpp b/services/distributedhardwarefwkservice/src/ipc/publisher_listener_proxy.cpp index d76ecf842bc798042143b3364b8c34c9e70e5c05..bc8af04a64a4a2d24982e3d82e19cfea3e0905b8 100644 --- a/services/distributedhardwarefwkservice/src/ipc/publisher_listener_proxy.cpp +++ b/services/distributedhardwarefwkservice/src/ipc/publisher_listener_proxy.cpp @@ -35,7 +35,7 @@ void PublisherListenerProxy::OnMessage(const DHTopic topic, const std::string& m DHLOGE("Get Remote IRemoteObject failed"); return; } - if (DHTopic::TOPIC_MIN > topic || topic > DHTopic::TOPIC_MAX) { + if (topic < DHTopic::TOPIC_MIN || topic > DHTopic::TOPIC_MAX) { DHLOGE("Topic is invalid!"); return; } diff --git a/services/distributedhardwarefwkservice/src/localhardwaremanager/local_hardware_manager.cpp b/services/distributedhardwarefwkservice/src/localhardwaremanager/local_hardware_manager.cpp index 52faf9f42be820af601561f7319b8e8613b7dc43..f73676ed783e28b5b4fa6a9a30aa9483ae5c3500 100644 --- a/services/distributedhardwarefwkservice/src/localhardwaremanager/local_hardware_manager.cpp +++ b/services/distributedhardwarefwkservice/src/localhardwaremanager/local_hardware_manager.cpp @@ -28,6 +28,10 @@ namespace OHOS { namespace DistributedHardware { +namespace { + constexpr int32_t QUERY_INTERVAL_TIME = 1000 * 1000; // 1s + constexpr int32_t QUERY_RETRY_MAX_TIMES = 30; +} #undef DH_LOG_TAG #define DH_LOG_TAG "LocalHardwareManager" diff --git a/services/distributedhardwarefwkservice/src/resourcemanager/db_adapter.cpp b/services/distributedhardwarefwkservice/src/resourcemanager/db_adapter.cpp index bc69c925ba69e769657ab43302e75e90d2032583..942c48da2fa621e1ff7f963509c12d7bdd3e888b 100644 --- a/services/distributedhardwarefwkservice/src/resourcemanager/db_adapter.cpp +++ b/services/distributedhardwarefwkservice/src/resourcemanager/db_adapter.cpp @@ -32,7 +32,13 @@ namespace DistributedHardware { #define DH_LOG_TAG "DBAdapter" namespace { -const std::string DATABASE_DIR = "/data/service/el1/public/database/"; + constexpr int32_t MAX_INIT_RETRY_TIMES = 20; + constexpr int32_t INIT_RETRY_SLEEP_INTERVAL = 200 * 1000; // 200ms + constexpr int32_t MANUAL_SYNC_TIMES = 6; + constexpr int32_t MANUAL_SYNC_INTERVAL = 100 * 1000; // 100ms + constexpr int32_t DIED_CHECK_MAX_TIMES = 300; + constexpr int32_t DIED_CHECK_INTERVAL = 100 * 1000; // 100ms + const std::string DATABASE_DIR = "/data/service/el1/public/database/"; } DBAdapter::DBAdapter(const std::string &appId, const std::string &storeId, @@ -360,7 +366,7 @@ void DBAdapter::UnRegisterManualSyncListener() void DBAdapter::OnRemoteDied() { DHLOGI("OnRemoteDied, recover db begin"); - auto ReInitTask = [this] { + auto reInitTask = [this] { int32_t times = 0; while (times < DIED_CHECK_MAX_TIMES) { // init kvStore. @@ -375,7 +381,7 @@ void DBAdapter::OnRemoteDied() usleep(DIED_CHECK_INTERVAL); } }; - DHContext::GetInstance().GetEventBus()->PostTask(ReInitTask, "ReInitTask", 0); + DHContext::GetInstance().GetEventBus()->PostTask(reInitTask, "reInitTask", 0); DHLOGI("OnRemoteDied, recover db end"); }