mirror of
https://gitee.com/openharmony/ability_dmsfwk
synced 2025-02-19 22:11:04 +00:00
查询远端数据副本时,过滤冗余数据
Signed-off-by: m30043719 <maxiaodong25@huawei.com>
This commit is contained in:
parent
d0e4bbe85d
commit
ceefbd741b
@ -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<Entry> 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<Entry> allEntries;
|
||||
std::promise<OHOS::DistributedKv::Status> 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<Entry> 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;
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user