diff --git a/services/distributeddataservice/service/udmf/store/runtime_store.cpp b/services/distributeddataservice/service/udmf/store/runtime_store.cpp index 8badccd4a2b591925b4c7045d6a1e1eb183aa189..61bf41f8dec17f5fabca37917afa1d95bc3d5f6f 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 cfa06e62dc12bebee9b13fcad7c9a6c4932f3082..2dd5553b387b3872060ad27076c7773df917f286 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 a21f24b5682a862f564995a20478307f9bc01f13..395d1cddd4e98c6a8670ea3a81c4dddb983c2976 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/store/store_data_changed_observer.h b/services/distributeddataservice/service/udmf/store/store_data_changed_observer.h new file mode 100644 index 0000000000000000000000000000000000000000..4c9138d7040fc11559498d5c7c5d31ccb262fcf2 --- /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 4db92da9345e0d2be2dbf31620094a2a2e74ed73..6ab2ec6b7acfff99ce925ca85417a6c24498a419 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 beef4dda4af40b975f557f4139e4a7d750f219ba..59d4dd7d9655ef282cd2278aa655ddfdd3adacad 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: