From ec0ba08782565bca2a244df88a55fbd7b3264d19 Mon Sep 17 00:00:00 2001 From: li-tiangang4 Date: Thu, 9 Jan 2025 19:51:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=A4=9A=E4=BD=99=E7=9A=84?= =?UTF-8?q?=E5=85=A5=E5=8F=82=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-tiangang4 --- .../dh_data_sync_trigger_listener.cpp | 6 +----- .../local_capability_info_manager.cpp | 5 ++--- .../src/resourcemanager/meta_info_manager.cpp | 6 +----- .../local_capability_info_manager_test.cpp | 13 ++----------- 4 files changed, 6 insertions(+), 24 deletions(-) diff --git a/services/distributedhardwarefwkservice/src/componentmanager/dh_data_sync_trigger_listener.cpp b/services/distributedhardwarefwkservice/src/componentmanager/dh_data_sync_trigger_listener.cpp index 9267f7cf..74b532db 100644 --- a/services/distributedhardwarefwkservice/src/componentmanager/dh_data_sync_trigger_listener.cpp +++ b/services/distributedhardwarefwkservice/src/componentmanager/dh_data_sync_trigger_listener.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 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 @@ -44,10 +44,6 @@ void DHDataSyncTriggerListener::OnDataSyncTrigger(const std::string &networkId) return; } DHLOGI("Receive data sync trigger, networkId: %{public}s", GetAnonyString(networkId).c_str()); - if (networkId.empty()) { - DHLOGE("OnDataSyncTrigger networkId is empty"); - return; - } std::shared_ptr networkIdPtr = std::make_shared(networkId); AppExecFwk::InnerEvent::Pointer msgEvent = AppExecFwk::InnerEvent::Get(EVENT_DATA_SYNC_MANUAL, networkIdPtr); if (ComponentManager::GetInstance().GetEventHandler() == nullptr) { diff --git a/services/distributedhardwarefwkservice/src/resourcemanager/local_capability_info_manager.cpp b/services/distributedhardwarefwkservice/src/resourcemanager/local_capability_info_manager.cpp index a13809c5..b97c3f9d 100644 --- a/services/distributedhardwarefwkservice/src/resourcemanager/local_capability_info_manager.cpp +++ b/services/distributedhardwarefwkservice/src/resourcemanager/local_capability_info_manager.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 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 @@ -168,8 +168,7 @@ int32_t LocalCapabilityInfoManager::RemoveCapabilityInfoByKey(const std::string void LocalCapabilityInfoManager::GetCapabilitiesByDeviceId(const std::string &deviceId, std::vector> &resInfos) { - if (!IsIdLengthValid(deviceId) || resInfos.empty() || resInfos.size() > MAX_DB_RECORD_SIZE) { - DHLOGE("On parameter error, maybe empty or too large!"); + if (!IsIdLengthValid(deviceId)) { return; } std::lock_guard lock(capInfoMgrMutex_); diff --git a/services/distributedhardwarefwkservice/src/resourcemanager/meta_info_manager.cpp b/services/distributedhardwarefwkservice/src/resourcemanager/meta_info_manager.cpp index 95c9048e..ac233b06 100644 --- a/services/distributedhardwarefwkservice/src/resourcemanager/meta_info_manager.cpp +++ b/services/distributedhardwarefwkservice/src/resourcemanager/meta_info_manager.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 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 @@ -513,10 +513,6 @@ std::vector MetaInfoManager::GetEntriesByKeys(const std::v return {}; } DHLOGI("call"); - if (keys.empty()) { - DHLOGE("keys empty."); - return {}; - } std::lock_guard lock(metaInfoMgrMutex_); if (dbAdapterPtr_ == nullptr) { DHLOGE("dbAdapterPtr_ is null"); diff --git a/services/distributedhardwarefwkservice/test/unittest/common/resourcemanager/local_capability_info_manager_test.cpp b/services/distributedhardwarefwkservice/test/unittest/common/resourcemanager/local_capability_info_manager_test.cpp index 16cfd8a4..38d6c2ae 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/resourcemanager/local_capability_info_manager_test.cpp +++ b/services/distributedhardwarefwkservice/test/unittest/common/resourcemanager/local_capability_info_manager_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 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 @@ -124,16 +124,7 @@ HWTEST_F(LocalCapInfoMgrTest, GetCapabilitiesByDeviceId_001, TestSize.Level0) { std::string deviceId = ""; std::vector> resInfos; - LocalCapabilityInfoManager::GetInstance()->GetCapabilitiesByDeviceId(deviceId, resInfos); - - deviceId = "123456789"; - std::string dhid = "111111"; - std::shared_ptr capInfo = std::make_shared( - "dhid", deviceId, "devName_test", DEV_TYPE_TEST, DHType::AUDIO, "attrs", "subtype"); - std::string key = deviceId + "###" + dhid; - LocalCapabilityInfoManager::GetInstance()->globalCapInfoMap_[key] = capInfo; - LocalCapabilityInfoManager::GetInstance()->GetCapabilitiesByDeviceId(deviceId, resInfos); - EXPECT_TRUE(resInfos.empty()); + ASSERT_NO_FATAL_FAILURE(LocalCapabilityInfoManager::GetInstance()->GetCapabilitiesByDeviceId(deviceId, resInfos)); } HWTEST_F(LocalCapInfoMgrTest, GetCapability_001, TestSize.Level0) -- Gitee