From ceefbd741bafdbadb93985d298a4c6b7c6a98afb Mon Sep 17 00:00:00 2001 From: m30043719 Date: Tue, 20 Aug 2024 10:37:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E8=BF=9C=E7=AB=AF=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=89=AF=E6=9C=AC=E6=97=B6=EF=BC=8C=E8=BF=87=E6=BB=A4?= =?UTF-8?q?=E5=86=97=E4=BD=99=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: m30043719 --- .../src/mission/distributed_bm_storage.cpp | 27 +++++++++---------- .../mission/distributed_bm_storage_test.cpp | 21 +++++++++++++++ 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/services/dtbschedmgr/src/mission/distributed_bm_storage.cpp b/services/dtbschedmgr/src/mission/distributed_bm_storage.cpp index e88ae165..3420db6b 100644 --- a/services/dtbschedmgr/src/mission/distributed_bm_storage.cpp +++ b/services/dtbschedmgr/src/mission/distributed_bm_storage.cpp @@ -269,28 +269,25 @@ bool DmsBmStorage::DealGetBundleName(const std::string &networkId, const uint16_ return false; } std::string udid = DtbschedmgrDeviceInfoStorage::GetInstance().GetUdidByNetworkId(networkId); - if (udid == "") { - HILOGE("can not get udid by networkId"); + std::string uuid = DtbschedmgrDeviceInfoStorage::GetInstance().GetUuidByNetworkId(networkId); + if (udid == "" || uuid == "") { + HILOGE("can not get udid or uuid"); + return false; + } + HILOGI("uuid: %{public}s", GetAnonymStr(uuid).c_str()); + std::vector remoteEntries; + Status status = kvStorePtr_->GetDeviceEntries(uuid, remoteEntries); + if (remoteEntries.empty() || status != Status::SUCCESS) { + HILOGE("GetDeviceEntries error: %{public}d or remoteEntries is empty", status); return false; } - Key allEntryKeyPrefix(""); - std::vector allEntries; - std::promise resultStatusSignal; - int64_t begin = GetTickCount(); - GetEntries(networkId, allEntryKeyPrefix, resultStatusSignal, allEntries); - Status status = GetResultSatus(resultStatusSignal); - HILOGI("GetEntries spend %{public}" PRId64 " ms", GetTickCount() - begin); - if (status != Status::SUCCESS) { - HILOGE("GetEntries error: %{public}d", status); - return false; - } std::vector reduRiskEntries; std::string keyOfPublic = udid + AppExecFwk::Constants::FILE_UNDERLINE + PUBLIC_RECORDS; - for (auto entry : allEntries) { + for (auto entry : remoteEntries) { std::string key = entry.key.ToString(); std::string value = entry.value.ToString(); - if (key.find(udid) == std::string::npos || key.find(keyOfPublic) != std::string::npos) { + if (key.find(keyOfPublic) != std::string::npos) { continue; } DmsBundleInfo distributedBundleInfo; diff --git a/services/dtbschedmgr/test/unittest/mission/distributed_bm_storage_test.cpp b/services/dtbschedmgr/test/unittest/mission/distributed_bm_storage_test.cpp index ae0b81c4..1bb85e73 100644 --- a/services/dtbschedmgr/test/unittest/mission/distributed_bm_storage_test.cpp +++ b/services/dtbschedmgr/test/unittest/mission/distributed_bm_storage_test.cpp @@ -189,6 +189,27 @@ HWTEST_F(DistributedBmStorageTest, GetDistributedBundleNameTest_003, TestSize.Le DTEST_LOG << "DistributedBmStorageTest GetDistributedBundleNameTest_003 end" << std::endl; } +/** + * @tc.name: GetDistributedBundleNameTest_004 + * @tc.desc: test insert DistributedBmStorage + * @tc.type: FUNC + */ +HWTEST_F(DistributedBmStorageTest, GetDistributedBundleNameTest_004, TestSize.Level1) +{ + DTEST_LOG << "DistributedBmStorageTest GetDistributedBundleNameTest_004 start" << std::endl; + ASSERT_NE(dmsBmStorage_, nullptr); + auto distributedDataStorage = GetDmsBmStorage(); + EXPECT_NE(distributedDataStorage, nullptr); + if (distributedDataStorage != nullptr) { + std::string networkId = ""; + std::string bundleName = "browser"; + uint16_t bundleNameId = 4; + bool ret = dmsBmStorage_->GetInstance()->GetDistributedBundleName(networkId, bundleNameId, bundleName); + EXPECT_EQ(ret, false); + } + DTEST_LOG << "DistributedBmStorageTest GetDistributedBundleNameTest_004 end" << std::endl; +} + /** * @tc.name: GetBundleIdTest_001 * @tc.desc: test delete DistributedBmStorage