From 2b4e8a3ffb5a1841163d3e9514d51e5ba6e47ae0 Mon Sep 17 00:00:00 2001 From: wenjinchao Date: Sun, 7 Sep 2025 16:21:07 +0800 Subject: [PATCH 1/2] first Signed-off-by: wenjinchao Change-Id: I921a1a0faafeb3b158911dd4a6f1c86b7d288ac4 --- .../service/udmf/store/runtime_store.cpp | 17 +++++++++++++++++ .../service/udmf/store/runtime_store.h | 1 + .../service/udmf/store/store.h | 1 + .../service/udmf/udmf_service_impl.cpp | 16 +++++++++++++++- .../service/udmf/udmf_service_impl.h | 1 + 5 files changed, 35 insertions(+), 1 deletion(-) diff --git a/services/distributeddataservice/service/udmf/store/runtime_store.cpp b/services/distributeddataservice/service/udmf/store/runtime_store.cpp index 8badccd4a..61bf41f8d 100644 --- a/services/distributeddataservice/service/udmf/store/runtime_store.cpp +++ b/services/distributeddataservice/service/udmf/store/runtime_store.cpp @@ -605,5 +605,22 @@ Status RuntimeStore::MarkWhenCorrupted(DistributedDB::DBStatus status) } return E_DB_ERROR; } + +Status RuntimeStore::SetRemotePullStartNotify(std::function callback) +{ + if (callback == nullptr) { + ZLOGE("SetRemotePullStartNotify failed, callback is null."); + return E_INVALID_PARAMETERS; + } + DBStatus status = kvStore_->SetRemotePushFinishedNotify([callback](DistributedDB::RemotePushNotifyInfo info) { // todo 修改成pull + ZLOGI("Remote pull start notify received."); + callback(); + }); + if (status != DBStatus::OK) { + ZLOGE("SetRemotePushFinishedNotify failed, status: %{public}d.", status); + return E_DB_ERROR; + } + return E_OK; +} } // namespace UDMF } // namespace OHOS \ No newline at end of file diff --git a/services/distributeddataservice/service/udmf/store/runtime_store.h b/services/distributeddataservice/service/udmf/store/runtime_store.h index cfa06e62d..2dd5553b3 100644 --- a/services/distributeddataservice/service/udmf/store/runtime_store.h +++ b/services/distributeddataservice/service/udmf/store/runtime_store.h @@ -44,6 +44,7 @@ public: Status PutRuntime(const std::string &key, const Runtime &runtime) override; Status GetRuntime(const std::string &key, Runtime &runtime) override; Status PutSummary(UnifiedKey &key, const Summary &summary) override; + Status SetRemotePullStartNotify(std::function callback) override; bool Init() override; private: diff --git a/services/distributeddataservice/service/udmf/store/store.h b/services/distributeddataservice/service/udmf/store/store.h index a21f24b56..395d1cddd 100644 --- a/services/distributeddataservice/service/udmf/store/store.h +++ b/services/distributeddataservice/service/udmf/store/store.h @@ -44,6 +44,7 @@ public: virtual Status PutRuntime(const std::string &key, const Runtime &runtime) = 0; virtual Status GetRuntime(const std::string &key, Runtime &runtime) = 0; virtual Status PutSummary(UnifiedKey &key, const Summary &summary) = 0; + virtual Status SetRemotePullStartNotify(std::function callback) = 0; virtual bool Init() = 0; bool operator<(const Time &time) const diff --git a/services/distributeddataservice/service/udmf/udmf_service_impl.cpp b/services/distributeddataservice/service/udmf/udmf_service_impl.cpp index 4db92da93..a8ce604bd 100644 --- a/services/distributeddataservice/service/udmf/udmf_service_impl.cpp +++ b/services/distributeddataservice/service/udmf/udmf_service_impl.cpp @@ -13,6 +13,8 @@ * limitations under the License. */ +#include "store.h" +#include #define LOG_TAG "UdmfServiceImpl" #include "udmf_service_impl.h" @@ -1216,7 +1218,6 @@ int32_t UdmfServiceImpl::SetDelayInfo(const DataLoadInfo &dataLoadInfo, sptrPutSummary(udkey, summary); @@ -1225,6 +1226,8 @@ int32_t UdmfServiceImpl::SetDelayInfo(const DataLoadInfo &dataLoadInfo, sptr UdmfServiceImpl::ProcessResult(const std::map &store) +{ + // register notifier when delay drag + store->SetRemotePullStartNotify([this]() { + ZLOGI("Remote pull start."); + dataLoadCallback_.ForEach([&](const auto &key, auto &callback) { + + }); + }); +} } // namespace UDMF } // namespace OHOS \ No newline at end of file diff --git a/services/distributeddataservice/service/udmf/udmf_service_impl.h b/services/distributeddataservice/service/udmf/udmf_service_impl.h index beef4dda4..59d4dd7d9 100644 --- a/services/distributeddataservice/service/udmf/udmf_service_impl.h +++ b/services/distributeddataservice/service/udmf/udmf_service_impl.h @@ -94,6 +94,7 @@ private: DistributedData::StoreMetaData BuildMeta(const std::string &storeId, int userId); int32_t VerifyUpdatePermission(const QueryOption &query, UnifiedData &unifiedData, std::string &bundleName); bool HandleDelayLoad(const QueryOption &query, UnifiedData &unifiedData, int32_t &res); + void RegisterObserver(const std::string &key, const std::shared_ptr &store); class Factory { public: -- Gitee From 02fd53b4207cfc410173de552b6ba7e9040685c6 Mon Sep 17 00:00:00 2001 From: Power-the-WORLD Date: Fri, 12 Sep 2025 15:22:11 +0800 Subject: [PATCH 2/2] 11 Signed-off-by: Power-the-WORLD --- .../udmf/store/store_data_changed_observer.h | 15 +++++++++++++++ .../service/udmf/udmf_service_impl.cpp | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 services/distributeddataservice/service/udmf/store/store_data_changed_observer.h diff --git a/services/distributeddataservice/service/udmf/store/store_data_changed_observer.h b/services/distributeddataservice/service/udmf/store/store_data_changed_observer.h new file mode 100644 index 000000000..4c9138d70 --- /dev/null +++ b/services/distributeddataservice/service/udmf/store/store_data_changed_observer.h @@ -0,0 +1,15 @@ +/* + * Copyright (c) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + diff --git a/services/distributeddataservice/service/udmf/udmf_service_impl.cpp b/services/distributeddataservice/service/udmf/udmf_service_impl.cpp index a8ce604bd..6ab2ec6b7 100644 --- a/services/distributeddataservice/service/udmf/udmf_service_impl.cpp +++ b/services/distributeddataservice/service/udmf/udmf_service_impl.cpp @@ -1386,7 +1386,7 @@ void UdmfServiceImpl::RegisterObserver(const std::string &key, const std::shared store->SetRemotePullStartNotify([this]() { ZLOGI("Remote pull start."); dataLoadCallback_.ForEach([&](const auto &key, auto &callback) { - + }); }); } -- Gitee