From 573b7ef66d9e622487dceb2ec284e85e68839b42 Mon Sep 17 00:00:00 2001 From: weishaoxiong Date: Sat, 9 Aug 2025 09:20:11 +0800 Subject: [PATCH 1/4] fix: Signed-off-by: weishaoxiong --- .../distributeddataservice/framework/utils/anonymous.cpp | 2 +- .../service/cloud/cloud_service_impl.cpp | 2 +- .../service/cloud/cloud_service_impl.h | 4 ++-- .../distributeddataservice/service/cloud/sync_manager.cpp | 5 +---- .../service/object/src/object_data_listener.cpp | 8 ++++---- .../service/test/cloud_data_test.cpp | 5 +++++ .../test/fuzztest/cloudservicestub_fuzzer/BUILD.gn | 1 + .../service/test/object_manager_mock_test.cpp | 3 +-- .../service/test/rdb_cloud_test.cpp | 2 -- 9 files changed, 16 insertions(+), 16 deletions(-) diff --git a/services/distributeddataservice/framework/utils/anonymous.cpp b/services/distributeddataservice/framework/utils/anonymous.cpp index d3b0ed483..2cf8434a1 100644 --- a/services/distributeddataservice/framework/utils/anonymous.cpp +++ b/services/distributeddataservice/framework/utils/anonymous.cpp @@ -66,7 +66,7 @@ std::string Anonymous::Change(const std::string &name) noAlnum.push_back(""); } if (!noAlnumStr.empty()) { - noAlnum.push_back(alnumStr); + noAlnum.push_back(noAlnumStr); alnum.push_back(""); } std::string res = ""; diff --git a/services/distributeddataservice/service/cloud/cloud_service_impl.cpp b/services/distributeddataservice/service/cloud/cloud_service_impl.cpp index 64ce9ff50..8bb23ca6c 100644 --- a/services/distributeddataservice/service/cloud/cloud_service_impl.cpp +++ b/services/distributeddataservice/service/cloud/cloud_service_impl.cpp @@ -315,7 +315,7 @@ bool CloudServiceImpl::GetStoreMetaData(StoreMetaData &meta) } StoreMetaDataLocal localMetaData; if (!MetaDataManager::GetInstance().LoadMeta(meta.GetKeyLocal(), localMetaData, true) || !localMetaData.isPublic) { - ZLOGE("failed, no store LocalMeta. bundleName:%{public}s, storeId:%{public}s", meta.bundleName.c_str(), + ZLOGE("meta empty, no public store. bundleName:%{public}s, storeId:%{public}s", meta.bundleName.c_str(), meta.GetStoreAlias().c_str()); return false; } diff --git a/services/distributeddataservice/service/cloud/cloud_service_impl.h b/services/distributeddataservice/service/cloud/cloud_service_impl.h index 4410519c1..fbd5a9773 100644 --- a/services/distributeddataservice/service/cloud/cloud_service_impl.h +++ b/services/distributeddataservice/service/cloud/cloud_service_impl.h @@ -201,6 +201,8 @@ private: static int32_t SaveNetworkStrategy(const std::vector &values, const HapInfo &hapInfo); static void Report(const std::string &faultType, DistributedDataDfx::Fault errCode, const std::string &bundleName, const std::string &appendix); + QueryLastResults AssembleLastResults(const std::vector &databases, + const std::map &lastSyncInfos); static std::pair GetSchemaFromHap(const HapInfo &hapInfo); static int32_t UpdateSchemaFromHap(const HapInfo &hapInfo); @@ -209,8 +211,6 @@ private: static void UpdateE2eeEnable(const std::string &schemaKey, bool newE2eeEnable, const std::string &bundleName); static void UpdateClearWaterMark( const HapInfo &hapInfo, const SchemaMeta &newSchemaMeta, const SchemaMeta &schemaMeta); - QueryLastResults AssembleLastResults(const std::vector &databases, - const std::map &lastSyncInfos); std::shared_ptr executor_; SyncManager syncManager_; diff --git a/services/distributeddataservice/service/cloud/sync_manager.cpp b/services/distributeddataservice/service/cloud/sync_manager.cpp index 773fca44b..39a046674 100644 --- a/services/distributeddataservice/service/cloud/sync_manager.cpp +++ b/services/distributeddataservice/service/cloud/sync_manager.cpp @@ -763,10 +763,7 @@ bool SyncManager::NeedSaveSyncInfo(const QueryKey &queryKey) if (queryKey.accountId.empty()) { return false; } - if (std::find(kvApps_.begin(), kvApps_.end(), queryKey.bundleName) != kvApps_.end()) { - return false; - } - return true; + return kvApps_.find(queryKey.bundleName) == kvApps_.end(); } std::pair> SyncManager::QueryLastSyncInfo( diff --git a/services/distributeddataservice/service/object/src/object_data_listener.cpp b/services/distributeddataservice/service/object/src/object_data_listener.cpp index ad10e0391..812c6806c 100644 --- a/services/distributeddataservice/service/object/src/object_data_listener.cpp +++ b/services/distributeddataservice/service/object/src/object_data_listener.cpp @@ -80,19 +80,19 @@ int32_t ObjectAssetsRecvListener::OnFinished(const std::string &srcNetworkId, co return OBJECT_SUCCESS; } + int32_t ObjectAssetsRecvListener::OnRecvProgress( const std::string &srcNetworkId, const sptr &assetObj, uint64_t totalBytes, uint64_t processBytes) { if (assetObj == nullptr || totalBytes == 0) { - ZLOGE("OnRecvProgress error! srcNetworkId:%{public}s, totalBytes: %{public}llu", + ZLOGE("OnRecvProgress error! srcNetworkId:%{public}s, totalBytes: %{public}lu", DistributedData::Anonymous::Change(srcNetworkId).c_str(), totalBytes); return OBJECT_INNER_ERROR; } auto objectKey = assetObj->dstBundleName_ + assetObj->sessionId_; - ZLOGI("srcNetworkId: %{public}s, objectKey:%{public}s, totalBytes: %{public}llu," - "processBytes: %{public}llu.", - DistributedData::Anonymous::Change(srcNetworkId).c_str(), + ZLOGI("OnRecvProgress, srcNetworkId: %{public}s, objectKey:%{public}s, totalBytes: %{public}lu," + "processBytes: %{public}lu.", DistributedData::Anonymous::Change(srcNetworkId).c_str(), DistributedData::Anonymous::Change(objectKey).c_str(), totalBytes, processBytes); int32_t progress = static_cast((processBytes * 100.0 / totalBytes) * 0.9); diff --git a/services/distributeddataservice/service/test/cloud_data_test.cpp b/services/distributeddataservice/service/test/cloud_data_test.cpp index 2b34daa84..81f3ec5a6 100644 --- a/services/distributeddataservice/service/test/cloud_data_test.cpp +++ b/services/distributeddataservice/service/test/cloud_data_test.cpp @@ -1155,6 +1155,10 @@ HWTEST_F(CloudDataTest, CloudSync007, TestSize.Level0) uint32_t seqNum = 10; auto ret = cloudServiceImpl_->CloudSync("bundleName", "storeId", { syncMode, seqNum }, nullptr); EXPECT_EQ(ret, CloudData::CloudService::INVALID_ARGUMENT); + + CloudData::Details details; + uint32_t tokenId = 0; + cloudServiceImpl_->OnAsyncComplete(tokenId, seqNum, std::move(details)); } /** @@ -2801,6 +2805,7 @@ HWTEST_F(CloudDataTest, UpdateSchemaFromHap003, TestSize.Level1) */ HWTEST_F(CloudDataTest, UpdateSchemaFromHap004, TestSize.Level1) { + ZLOGI("CloudServiceImplTest UpdateSchemaFromHap004 start"); ASSERT_NE(cloudServiceImpl_, nullptr); CloudInfo::AppInfo exampleAppInfo; exampleAppInfo.bundleName = COM_EXAMPLE_TEST_CLOUD; diff --git a/services/distributeddataservice/service/test/fuzztest/cloudservicestub_fuzzer/BUILD.gn b/services/distributeddataservice/service/test/fuzztest/cloudservicestub_fuzzer/BUILD.gn index 3f059f61a..2618103ac 100644 --- a/services/distributeddataservice/service/test/fuzztest/cloudservicestub_fuzzer/BUILD.gn +++ b/services/distributeddataservice/service/test/fuzztest/cloudservicestub_fuzzer/BUILD.gn @@ -73,6 +73,7 @@ ohos_fuzztest("CloudServiceStubFuzzTest") { "device_manager:devicemanagersdk", "hicollie:libhicollie", "hilog:libhilog", + "hisysevent:libhisysevent", "huks:libhukssdk", "ipc:ipc_core", "kv_store:datamgr_common", diff --git a/services/distributeddataservice/service/test/object_manager_mock_test.cpp b/services/distributeddataservice/service/test/object_manager_mock_test.cpp index faf7ca79c..48ce40c3e 100644 --- a/services/distributeddataservice/service/test/object_manager_mock_test.cpp +++ b/services/distributeddataservice/service/test/object_manager_mock_test.cpp @@ -169,13 +169,12 @@ HWTEST_F(ObjectManagerMockTest, IsNeedMetaSync003, TestSize.Level0) /** * @tc.name: SyncOnStore001 - * @tc.desc: Test SyncOnStore. + * @tc.desc: Test SyncOnStore * @tc.type: FUNC * @tc.require: */ HWTEST_F(ObjectManagerMockTest, SyncOnStore001, TestSize.Level0) { - // 2 means that the GetUserByToken interface will be called twice EXPECT_CALL(*accountDelegateMock, GetUserByToken(_)).Times(2).WillRepeatedly(Return(0)); auto &manager = ObjectStoreManager::GetInstance(); std::function &results)> func; diff --git a/services/distributeddataservice/service/test/rdb_cloud_test.cpp b/services/distributeddataservice/service/test/rdb_cloud_test.cpp index 12dbf62fe..73d4ccc9c 100644 --- a/services/distributeddataservice/service/test/rdb_cloud_test.cpp +++ b/services/distributeddataservice/service/test/rdb_cloud_test.cpp @@ -238,8 +238,6 @@ HWTEST_F(RdbCloudTest, ConvertStatus, TestSize.Level1) EXPECT_EQ(result, DBStatus::TIME_OUT); result = rdbCloud.ConvertStatus(GeneralError::E_CLOUD_DISABLED); EXPECT_EQ(result, DBStatus::CLOUD_DISABLED); - result = rdbCloud.ConvertStatus(GeneralError::E_SKIP_ASSET); - EXPECT_EQ(result, DBStatus::SKIP_ASSET); } /** -- Gitee From 93aaa331a7ad9d13fdf0d7c6efd96751f55e8994 Mon Sep 17 00:00:00 2001 From: weishaoxiong Date: Sat, 9 Aug 2025 09:30:19 +0800 Subject: [PATCH 2/4] fix: Signed-off-by: weishaoxiong --- .../service/cloud/cloud_service_impl.cpp | 2 +- .../service/object/src/object_data_listener.cpp | 3 +-- .../distributeddataservice/service/test/cloud_data_test.cpp | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/services/distributeddataservice/service/cloud/cloud_service_impl.cpp b/services/distributeddataservice/service/cloud/cloud_service_impl.cpp index 8bb23ca6c..9f4834e12 100644 --- a/services/distributeddataservice/service/cloud/cloud_service_impl.cpp +++ b/services/distributeddataservice/service/cloud/cloud_service_impl.cpp @@ -315,7 +315,7 @@ bool CloudServiceImpl::GetStoreMetaData(StoreMetaData &meta) } StoreMetaDataLocal localMetaData; if (!MetaDataManager::GetInstance().LoadMeta(meta.GetKeyLocal(), localMetaData, true) || !localMetaData.isPublic) { - ZLOGE("meta empty, no public store. bundleName:%{public}s, storeId:%{public}s", meta.bundleName.c_str(), + ZLOGE("meta empty, not public store. bundleName:%{public}s, storeId:%{public}s", meta.bundleName.c_str(), meta.GetStoreAlias().c_str()); return false; } diff --git a/services/distributeddataservice/service/object/src/object_data_listener.cpp b/services/distributeddataservice/service/object/src/object_data_listener.cpp index 812c6806c..071d19fcd 100644 --- a/services/distributeddataservice/service/object/src/object_data_listener.cpp +++ b/services/distributeddataservice/service/object/src/object_data_listener.cpp @@ -92,9 +92,8 @@ int32_t ObjectAssetsRecvListener::OnRecvProgress( auto objectKey = assetObj->dstBundleName_ + assetObj->sessionId_; ZLOGI("OnRecvProgress, srcNetworkId: %{public}s, objectKey:%{public}s, totalBytes: %{public}lu," - "processBytes: %{public}lu.", DistributedData::Anonymous::Change(srcNetworkId).c_str(), + "processBytes: %{public}lu.", DistributedData::Anonymous::Change(srcNetworkId).c_str(), DistributedData::Anonymous::Change(objectKey).c_str(), totalBytes, processBytes); - int32_t progress = static_cast((processBytes * 100.0 / totalBytes) * 0.9); ObjectStoreManager::GetInstance().NotifyAssetsRecvProgress(objectKey, progress); return OBJECT_SUCCESS; diff --git a/services/distributeddataservice/service/test/cloud_data_test.cpp b/services/distributeddataservice/service/test/cloud_data_test.cpp index 81f3ec5a6..7e2995508 100644 --- a/services/distributeddataservice/service/test/cloud_data_test.cpp +++ b/services/distributeddataservice/service/test/cloud_data_test.cpp @@ -1156,7 +1156,7 @@ HWTEST_F(CloudDataTest, CloudSync007, TestSize.Level0) auto ret = cloudServiceImpl_->CloudSync("bundleName", "storeId", { syncMode, seqNum }, nullptr); EXPECT_EQ(ret, CloudData::CloudService::INVALID_ARGUMENT); - CloudData::Details details; + CloudData::Details details{}; uint32_t tokenId = 0; cloudServiceImpl_->OnAsyncComplete(tokenId, seqNum, std::move(details)); } -- Gitee From 9f8190911479453761743367055c79d24c3b160b Mon Sep 17 00:00:00 2001 From: weishaoxiong Date: Sat, 9 Aug 2025 09:43:51 +0800 Subject: [PATCH 3/4] fix: Signed-off-by: weishaoxiong --- .../service/object/src/object_data_listener.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/services/distributeddataservice/service/object/src/object_data_listener.cpp b/services/distributeddataservice/service/object/src/object_data_listener.cpp index 071d19fcd..0cd6bd40b 100644 --- a/services/distributeddataservice/service/object/src/object_data_listener.cpp +++ b/services/distributeddataservice/service/object/src/object_data_listener.cpp @@ -85,14 +85,14 @@ int32_t ObjectAssetsRecvListener::OnRecvProgress( const std::string &srcNetworkId, const sptr &assetObj, uint64_t totalBytes, uint64_t processBytes) { if (assetObj == nullptr || totalBytes == 0) { - ZLOGE("OnRecvProgress error! srcNetworkId:%{public}s, totalBytes: %{public}lu", + ZLOGE("OnRecvProgress error! srcNetworkId:%{public}s, totalBytes: %{public}llu", DistributedData::Anonymous::Change(srcNetworkId).c_str(), totalBytes); return OBJECT_INNER_ERROR; } auto objectKey = assetObj->dstBundleName_ + assetObj->sessionId_; - ZLOGI("OnRecvProgress, srcNetworkId: %{public}s, objectKey:%{public}s, totalBytes: %{public}lu," - "processBytes: %{public}lu.", DistributedData::Anonymous::Change(srcNetworkId).c_str(), + ZLOGI("OnRecvProgress, srcNetworkId: %{public}s, objectKey:%{public}s, totalBytes: %{public}llu," + "processBytes: %{public}llu.", DistributedData::Anonymous::Change(srcNetworkId).c_str(), DistributedData::Anonymous::Change(objectKey).c_str(), totalBytes, processBytes); int32_t progress = static_cast((processBytes * 100.0 / totalBytes) * 0.9); ObjectStoreManager::GetInstance().NotifyAssetsRecvProgress(objectKey, progress); -- Gitee From 214655e3cc341d1b78d462e7940cbe3299f0f315 Mon Sep 17 00:00:00 2001 From: weishaoxiong Date: Tue, 12 Aug 2025 12:22:45 +0000 Subject: [PATCH 4/4] update services/distributeddataservice/service/test/object_manager_mock_test.cpp. Signed-off-by: weishaoxiong --- .../service/test/object_manager_mock_test.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/services/distributeddataservice/service/test/object_manager_mock_test.cpp b/services/distributeddataservice/service/test/object_manager_mock_test.cpp index 48ce40c3e..206288f90 100644 --- a/services/distributeddataservice/service/test/object_manager_mock_test.cpp +++ b/services/distributeddataservice/service/test/object_manager_mock_test.cpp @@ -175,6 +175,7 @@ HWTEST_F(ObjectManagerMockTest, IsNeedMetaSync003, TestSize.Level0) */ HWTEST_F(ObjectManagerMockTest, SyncOnStore001, TestSize.Level0) { + // 2 means that the GetUserByToken interface will be called twice EXPECT_CALL(*accountDelegateMock, GetUserByToken(_)).Times(2).WillRepeatedly(Return(0)); auto &manager = ObjectStoreManager::GetInstance(); std::function &results)> func; -- Gitee