From 92e3876becf2dc00ad8ad844e5ba507be90cc6b1 Mon Sep 17 00:00:00 2001 From: li-tiangang4 Date: Thu, 15 Aug 2024 19:09:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=86=85=E5=AD=98=E8=B6=85?= =?UTF-8?q?=E5=9F=BA=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-tiangang4 --- .../src/resourcemanager/capability_info_manager.cpp | 13 +++++++++++++ .../src/resourcemanager/meta_info_manager.cpp | 10 ++++++++++ 2 files changed, 23 insertions(+) diff --git a/services/distributedhardwarefwkservice/src/resourcemanager/capability_info_manager.cpp b/services/distributedhardwarefwkservice/src/resourcemanager/capability_info_manager.cpp index 49b1805e..2ec14455 100644 --- a/services/distributedhardwarefwkservice/src/resourcemanager/capability_info_manager.cpp +++ b/services/distributedhardwarefwkservice/src/resourcemanager/capability_info_manager.cpp @@ -167,16 +167,19 @@ int32_t CapabilityInfoManager::SyncRemoteCapabilityInfos() std::shared_ptr capabilityInfo; if (GetCapabilityByValue(data, capabilityInfo) != DH_FWK_SUCCESS) { DHLOGE("Get capability ptr by value failed"); + capabilityInfo = nullptr; continue; } const std::string &deviceId = capabilityInfo->GetDeviceId(); const std::string &localDeviceId = DHContext::GetInstance().GetDeviceInfo().deviceId; if (deviceId.compare(localDeviceId) == 0) { DHLOGE("local device info not need sync from db"); + capabilityInfo = nullptr; continue; } if (!DHContext::GetInstance().IsDeviceOnline(DHContext::GetInstance().GetUUIDByDeviceId(deviceId))) { DHLOGE("offline device, no need sync to memory, deviceId : %{public}s ", GetAnonyString(deviceId).c_str()); + capabilityInfo = nullptr; continue; } globalCapInfoMap_[capabilityInfo->GetKey()] = capabilityInfo; @@ -385,17 +388,20 @@ void CapabilityInfoManager::HandleCapabilityAddChange(const std::vector capPtr; if (GetCapabilityByValue(value, capPtr) != DH_FWK_SUCCESS) { DHLOGE("Get capability by value failed"); + capPtr = nullptr; continue; } std::string uuid = DHContext::GetInstance().GetUUIDByDeviceId(capPtr->GetDeviceId()); if (uuid.empty()) { DHLOGE("Find uuid failed and never enable, deviceId: %{public}s", GetAnonyString(capPtr->GetDeviceId()).c_str()); + capPtr = nullptr; continue; } std::string networkId = DHContext::GetInstance().GetNetworkIdByUUID(uuid); if (networkId.empty()) { DHLOGE("Find network failed and never enable, uuid: %{public}s", GetAnonyString(uuid).c_str()); + capPtr = nullptr; continue; } @@ -425,22 +431,26 @@ void CapabilityInfoManager::HandleCapabilityUpdateChange(const std::vector capPtr; if (GetCapabilityByValue(value, capPtr) != DH_FWK_SUCCESS) { DHLOGE("Get capability by value failed"); + capPtr = nullptr; continue; } std::string uuid = DHContext::GetInstance().GetUUIDByDeviceId(capPtr->GetDeviceId()); if (uuid.empty()) { DHLOGE("Find uuid failed and never enable, deviceId: %{public}s", GetAnonyString(capPtr->GetDeviceId()).c_str()); + capPtr = nullptr; continue; } std::string networkId = DHContext::GetInstance().GetNetworkIdByUUID(uuid); if (networkId.empty()) { DHLOGE("Find network failed and never enable, uuid: %{public}s", GetAnonyString(uuid).c_str()); + capPtr = nullptr; continue; } std::string enabledDeviceKey = GetCapabilityKey(capPtr->GetDeviceId(), capPtr->GetDHId()); if (TaskBoard::GetInstance().IsEnabledDevice(enabledDeviceKey)) { DHLOGI("The deviceKey: %{public}s is enabled.", GetAnonyString(enabledDeviceKey).c_str()); + capPtr = nullptr; continue; } const auto keyString = capPtr->GetKey(); @@ -469,17 +479,20 @@ void CapabilityInfoManager::HandleCapabilityDeleteChange(const std::vector capPtr; if (GetCapabilityByValue(value, capPtr) != DH_FWK_SUCCESS) { DHLOGE("Get capability by value failed"); + capPtr = nullptr; continue; } const auto keyString = capPtr->GetKey(); std::string uuid = DHContext::GetInstance().GetUUIDByDeviceId(capPtr->GetDeviceId()); if (uuid.empty()) { DHLOGI("Find uuid failed and never disable"); + capPtr = nullptr; continue; } std::string networkId = DHContext::GetInstance().GetNetworkIdByUUID(uuid); if (networkId.empty()) { DHLOGI("Find network failed and never disable, uuid: %{public}s", GetAnonyString(uuid).c_str()); + capPtr = nullptr; continue; } TaskParam taskParam = { diff --git a/services/distributedhardwarefwkservice/src/resourcemanager/meta_info_manager.cpp b/services/distributedhardwarefwkservice/src/resourcemanager/meta_info_manager.cpp index 2e26b1f7..e5316174 100644 --- a/services/distributedhardwarefwkservice/src/resourcemanager/meta_info_manager.cpp +++ b/services/distributedhardwarefwkservice/src/resourcemanager/meta_info_manager.cpp @@ -203,18 +203,21 @@ int32_t MetaInfoManager::SyncRemoteMetaInfos() std::shared_ptr metaCapInfo; if (GetMetaCapByValue(data, metaCapInfo) != DH_FWK_SUCCESS) { DHLOGE("Get Metainfo ptr by value failed"); + metaCapInfo = nullptr; continue; } const std::string &udidHash = metaCapInfo->GetUdidHash(); const std::string &localUdidHash = DHContext::GetInstance().GetDeviceInfo().udidHash; if (udidHash.compare(localUdidHash) == 0) { DHLOGE("device MetaInfo not need sync from db"); + metaCapInfo = nullptr; continue; } if (!DHContext::GetInstance().IsDeviceOnline( DHContext::GetInstance().GetUUIDByDeviceId(metaCapInfo->GetDeviceId()))) { DHLOGE("offline device, no need sync to memory, udidHash : %{public}s", GetAnonyString(metaCapInfo->GetUdidHash()).c_str()); + metaCapInfo = nullptr; continue; } globalMetaInfoMap_[metaCapInfo->GetKey()] = metaCapInfo; @@ -380,17 +383,20 @@ void MetaInfoManager::HandleMetaCapabilityAddChange(const std::vector capPtr; if (GetCapabilityByValue(value, capPtr) != DH_FWK_SUCCESS) { DHLOGE("Get Meta capability by value failed"); + capPtr = nullptr; continue; } std::string uuid = DHContext::GetInstance().GetUUIDByDeviceId(capPtr->GetDeviceId()); if (uuid.empty()) { DHLOGE("Find uuid failed and never enable, deviceId: %{public}s", GetAnonyString(capPtr->GetDeviceId()).c_str()); + capPtr = nullptr; continue; } std::string networkId = DHContext::GetInstance().GetNetworkIdByUUID(uuid); if (networkId.empty()) { DHLOGE("Find network failed and never enable, uuid: %{public}s", GetAnonyString(uuid).c_str()); + capPtr = nullptr; continue; } @@ -416,22 +422,26 @@ void MetaInfoManager::HandleMetaCapabilityUpdateChange(const std::vector capPtr; if (GetCapabilityByValue(value, capPtr) != DH_FWK_SUCCESS) { DHLOGE("Get Meta capability by value failed"); + capPtr = nullptr; continue; } std::string uuid = DHContext::GetInstance().GetUUIDByDeviceId(capPtr->GetDeviceId()); if (uuid.empty()) { DHLOGE("Find uuid failed and never enable, deviceId: %{public}s", GetAnonyString(capPtr->GetDeviceId()).c_str()); + capPtr = nullptr; continue; } std::string networkId = DHContext::GetInstance().GetNetworkIdByUUID(uuid); if (networkId.empty()) { DHLOGE("Find network failed and never enable, uuid: %{public}s", GetAnonyString(uuid).c_str()); + capPtr = nullptr; continue; } std::string enabledDeviceKey = GetCapabilityKey(capPtr->GetDeviceId(), capPtr->GetDHId()); if (TaskBoard::GetInstance().IsEnabledDevice(enabledDeviceKey)) { DHLOGI("The deviceKey: %{public}s is enabled.", GetAnonyString(enabledDeviceKey).c_str()); + capPtr = nullptr; continue; } const auto keyString = capPtr->GetKey(); -- Gitee