From 0f9058bf3b9c54b4ddd2162aeb0f11a8e62837b4 Mon Sep 17 00:00:00 2001 From: hanlu Date: Wed, 12 Jul 2023 01:31:08 +0800 Subject: [PATCH 1/9] f Signed-off-by: hanlu --- .../distributeddataservice/service/BUILD.gn | 1 - .../service/data_share/BUILD.gn | 4 +- .../service/data_share/common/callback_impl.h | 1 - .../common/extension_connect_adaptor.cpp | 7 +- .../data_share/common/extension_mgr_proxy.cpp | 102 ++++++++++++++++++ .../data_share/common/extension_mgr_proxy.h | 57 ++++++++++ .../data_share/common/scheduler_manager.cpp | 35 +++--- .../data/resultset_json_formatter.cpp | 1 + .../data_share/data_share_service_impl.cpp | 6 -- .../strategies/rdb_notify_strategy.cpp | 2 +- .../rdb_subscriber_manager.cpp | 11 +- .../rdb_subscriber_manager.h | 1 - 12 files changed, 189 insertions(+), 39 deletions(-) create mode 100644 services/distributeddataservice/service/data_share/common/extension_mgr_proxy.cpp create mode 100644 services/distributeddataservice/service/data_share/common/extension_mgr_proxy.h diff --git a/services/distributeddataservice/service/BUILD.gn b/services/distributeddataservice/service/BUILD.gn index 42b0e4b68..e467c8c75 100644 --- a/services/distributeddataservice/service/BUILD.gn +++ b/services/distributeddataservice/service/BUILD.gn @@ -121,7 +121,6 @@ ohos_shared_library("distributeddatasvc") { external_deps = [ "ability_base:want", "ability_base:zuri", - "ability_runtime:ability_manager", "ability_runtime:dataobs_manager", "access_token:libaccesstoken_sdk", "access_token:libtokenid_sdk", diff --git a/services/distributeddataservice/service/data_share/BUILD.gn b/services/distributeddataservice/service/data_share/BUILD.gn index 8cb08cb8e..d2245f76f 100644 --- a/services/distributeddataservice/service/data_share/BUILD.gn +++ b/services/distributeddataservice/service/data_share/BUILD.gn @@ -35,11 +35,11 @@ group("build_module") { } ohos_shared_library("data_share_service") { sources = [ - "common/app_connect_manager.cpp", "common/bundle_mgr_proxy.cpp", "common/db_delegate.cpp", "common/div_strategy.cpp", "common/extension_connect_adaptor.cpp", + "common/extension_mgr_proxy.cpp", "common/kv_delegate.cpp", "common/rdb_delegate.cpp", "common/scheduler_manager.cpp", @@ -91,7 +91,7 @@ ohos_shared_library("data_share_service") { external_deps = [ "ability_base:want", "ability_base:zuri", - "ability_runtime:ability_manager", + "ability_runtime:extension_manager", "ability_runtime:dataobs_manager", "access_token:libaccesstoken_sdk", "access_token:libtokenid_sdk", diff --git a/services/distributeddataservice/service/data_share/common/callback_impl.h b/services/distributeddataservice/service/data_share/common/callback_impl.h index 2eb22014d..451f375fa 100644 --- a/services/distributeddataservice/service/data_share/common/callback_impl.h +++ b/services/distributeddataservice/service/data_share/common/callback_impl.h @@ -16,7 +16,6 @@ #define DATASHARESERVICE_CALLBACK_IMPL_H #include "ability_connect_callback_stub.h" -#include "ability_manager_client.h" #include "block_data.h" namespace OHOS::DataShare { diff --git a/services/distributeddataservice/service/data_share/common/extension_connect_adaptor.cpp b/services/distributeddataservice/service/data_share/common/extension_connect_adaptor.cpp index 44725a692..a0deba23e 100644 --- a/services/distributeddataservice/service/data_share/common/extension_connect_adaptor.cpp +++ b/services/distributeddataservice/service/data_share/common/extension_connect_adaptor.cpp @@ -20,6 +20,7 @@ #include "app_connect_manager.h" #include "callback_impl.h" +#include "extension_mgr_proxy.h" #include "log_print.h" namespace OHOS::DataShare { @@ -37,8 +38,6 @@ ExtensionConnectAdaptor::ExtensionConnectAdaptor() : data_(1) {} bool ExtensionConnectAdaptor::DoConnect(std::shared_ptr context) { - AAFwk::Want want; - want.SetUri(context->uri); data_.Clear(); callback_ = new (std::nothrow) CallbackImpl(data_); if (callback_ == nullptr) { @@ -46,7 +45,7 @@ bool ExtensionConnectAdaptor::DoConnect(std::shared_ptr context) return false; } ZLOGI("Start connect %{public}s", context->uri.c_str()); - ErrCode ret = AAFwk::AbilityManagerClient::GetInstance()->ConnectAbility(want, callback_, nullptr); + ErrCode ret = ExtensionMgrProxy::GetInstance()->Connect(context->uri, callback_->AsObject(), nullptr); if (ret != ERR_OK) { ZLOGE("connect ability failed, ret = %{public}d", ret); return false; @@ -80,7 +79,7 @@ void ExtensionConnectAdaptor::Disconnect() } data_.Clear(); ZLOGI("Start disconnect"); - AAFwk::AbilityManagerClient::GetInstance()->DisconnectAbility(callback_); + ExtensionMgrProxy::GetInstance()->DisConnect(callback_->AsObject()); if (!data_.GetValue()) { ZLOGI("disconnect ability ended successfully"); } diff --git a/services/distributeddataservice/service/data_share/common/extension_mgr_proxy.cpp b/services/distributeddataservice/service/data_share/common/extension_mgr_proxy.cpp new file mode 100644 index 000000000..8b3454b46 --- /dev/null +++ b/services/distributeddataservice/service/data_share/common/extension_mgr_proxy.cpp @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2023 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. + */ + +#define LOG_TAG "AppConnectManager" +#include "extension_mgr_proxy.h" + +#include "app_connect_manager.h" +#include "extension_ability_info.h" +#include "if_system_ability_manager.h" +#include "iservice_registry.h" +#include "log_print.h" +#include "system_ability_definition.h" +#include "want.h" +namespace OHOS::DataShare { +void ExtensionMgrProxy::OnProxyDied() +{ + std::lock_guard lock(mutex_); + if (sa_ != nullptr) { + sa_->RemoveDeathRecipient(deathRecipient_); + } + deathRecipient_ = nullptr; + proxy_ = nullptr; +} + +ExtensionMgrProxy::~ExtensionMgrProxy() +{ + std::lock_guard lock(mutex_); + if (sa_ != nullptr) { + sa_->RemoveDeathRecipient(deathRecipient_); + } +} + +std::shared_ptr ExtensionMgrProxy::GetInstance() +{ + static std::shared_ptr proxy(new ExtensionMgrProxy()); + return proxy; +} + +bool ExtensionMgrProxy::Connect( + const std::string &uri, const sptr &connect, const sptr &callerToken) +{ + AAFwk::Want want; + want.SetUri(uri); + std::lock_guard lock(mutex_); + if (ConnectSA()) { + return proxy_->ConnectAbilityCommon(want, connect, callerToken, AppExecFwk::ExtensionAbilityType::DATASHARE); + } + return false; +} + +bool ExtensionMgrProxy::ConnectSA() +{ + if (proxy_ != nullptr) { + return true; + } + sptr systemAbilityManager = + SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + if (systemAbilityManager == nullptr) { + ZLOGE("Failed to get system ability mgr."); + return false; + } + + sa_ = systemAbilityManager->GetSystemAbility(ABILITY_MGR_SERVICE_ID); + if (sa_ == nullptr) { + ZLOGE("Failed to GetSystemAbility."); + return false; + } + deathRecipient_ = new (std::nothrow) ExtensionMgrProxy::ServiceDeathRecipient(weak_from_this()); + if (deathRecipient_ == nullptr) { + ZLOGE("deathRecipient alloc failed."); + return false; + } + sa_->AddDeathRecipient(deathRecipient_); + proxy_ = new (std::nothrow)Proxy(sa_); + if (proxy_ == nullptr) { + ZLOGE("proxy_ null, new failed"); + return false; + } + return true; +} + +bool ExtensionMgrProxy::DisConnect(sptr connect) +{ + std::lock_guard lock(mutex_); + if (ConnectSA()) { + return proxy_->DisconnectAbility(connect); + } + return false; +} +} // namespace OHOS::DataShare \ No newline at end of file diff --git a/services/distributeddataservice/service/data_share/common/extension_mgr_proxy.h b/services/distributeddataservice/service/data_share/common/extension_mgr_proxy.h new file mode 100644 index 000000000..96d3a41be --- /dev/null +++ b/services/distributeddataservice/service/data_share/common/extension_mgr_proxy.h @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2023 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. + */ + +#ifndef DATASHARESERVICE_EXTENSION_PROXY_H +#define DATASHARESERVICE_EXTENSION_PROXY_H + +#include +#include + +#include "extension_manager_proxy.h" +namespace OHOS::DataShare { +class ExtensionMgrProxy final : public std::enable_shared_from_this { +public: + ~ExtensionMgrProxy(); + static std::shared_ptr GetInstance(); + bool Connect(const std::string &uri, const sptr &connect, const sptr &callerToken); + bool DisConnect(sptr connect); +private: + using Proxy = AAFwk::ExtensionManagerProxy; + ExtensionMgrProxy() = default; + class ServiceDeathRecipient : public IRemoteObject::DeathRecipient { + public: + explicit ServiceDeathRecipient(std::weak_ptr owner) : owner_(owner) + { + } + void OnRemoteDied(const wptr &object) override + { + auto owner = owner_.lock(); + if (owner != nullptr) { + owner->OnProxyDied(); + } + } + + private: + std::weak_ptr owner_; + }; + void OnProxyDied(); + bool ConnectSA(); + std::mutex mutex_; + sptr sa_; + sptr proxy_; + sptr deathRecipient_; +}; +} // namespace OHOS::DataShare +#endif // DATASHARESERVICE_BUNDLEMGR_PROXY_H diff --git a/services/distributeddataservice/service/data_share/common/scheduler_manager.cpp b/services/distributeddataservice/service/data_share/common/scheduler_manager.cpp index c0c96fc1d..67628ee49 100644 --- a/services/distributeddataservice/service/data_share/common/scheduler_manager.cpp +++ b/services/distributeddataservice/service/data_share/common/scheduler_manager.cpp @@ -39,9 +39,6 @@ void SchedulerManager::Execute(const std::string &uri, const int32_t userId, con } std::vector keys = RdbSubscriberManager::GetInstance().GetKeysByUri(uri); for (auto const &key : keys) { - if (RdbSubscriberManager::GetInstance().GetCount(key) == 0) { - continue; - } ExecuteSchedulerSQL(rdbDir, userId, version, key, delegate); } } @@ -64,23 +61,33 @@ void SchedulerManager::SetTimer( ZLOGE("executor_ is nullptr"); return; } + // reminder time must is in future + auto now = time(nullptr); + if (reminderTime <= now) { + ZLOGE("reminderTime is not in future, %{public}" PRId64 "%{public}" PRId64 , reminderTime, now); + return; + } + auto duration = std::chrono::seconds(reminderTime - now); + ZLOGI("reminderTime will notify in %{public}" PRId64 " seconds", reminderTime - now); auto it = timerCache_.find(key); if (it != timerCache_.end()) { // has current timer, reset time - ZLOGD("has current taskId, uri is %{public}s, subscriberId is %{public}" PRId64 ", bundleName is %{public}s", - DistributedData::Anonymous::Change(key.uri).c_str(), key.subscriberId, key.bundleName.c_str()); - executor_->Reset(it->second, std::chrono::seconds(reminderTime - time(nullptr))); + ZLOGD("has current taskId, uri is %{private}s, subscriberId is %{public}" PRId64 ", bundleName is %{public}s", + key.uri.c_str(), key.subscriberId, key.bundleName.c_str()); + executor_->Reset(it->second, duration); return; } // not find task in map, create new timer - auto taskId = executor_->Schedule(std::chrono::seconds(reminderTime - time(nullptr)), - [key, dbPath, version, userId, this]() { - timerCache_.erase(key); - // 1. execute schedulerSQL in next time - Execute(key, userId, dbPath, version); - // 2. notify - RdbSubscriberManager::GetInstance().EmitByKey(key, userId, dbPath, version); - }); + auto taskId = executor_->Schedule(duration, [key, dbPath, version, userId, this]() { + ZLOGI("schedule notify start, uri is %{private}s, subscriberId is %{public}" PRId64 ", bundleName is " + "%{public}s", + key.uri.c_str(), key.subscriberId, key.bundleName.c_str()); + timerCache_.erase(key); + // 1. execute schedulerSQL in next time + Execute(key, userId, dbPath, version); + // 2. notify + RdbSubscriberManager::GetInstance().EmitByKey(key, userId, dbPath, version); + }); if (taskId == ExecutorPool::INVALID_TASK_ID) { ZLOGE("create timer failed, over the max capacity"); return; diff --git a/services/distributeddataservice/service/data_share/data/resultset_json_formatter.cpp b/services/distributeddataservice/service/data_share/data/resultset_json_formatter.cpp index 04e2d908f..5bdfa4a72 100644 --- a/services/distributeddataservice/service/data_share/data/resultset_json_formatter.cpp +++ b/services/distributeddataservice/service/data_share/data/resultset_json_formatter.cpp @@ -21,6 +21,7 @@ namespace OHOS::DataShare { bool ResultSetJsonFormatter::Marshal(json &node) const { + node = json::array(); int columnCount = 0; auto result = resultSet->GetColumnCount(columnCount); if (result != NativeRdb::E_OK) { diff --git a/services/distributeddataservice/service/data_share/data_share_service_impl.cpp b/services/distributeddataservice/service/data_share/data_share_service_impl.cpp index f084a0fe4..cb7b14f75 100644 --- a/services/distributeddataservice/service/data_share/data_share_service_impl.cpp +++ b/services/distributeddataservice/service/data_share/data_share_service_impl.cpp @@ -52,8 +52,6 @@ int32_t DataShareServiceImpl::Insert(const std::string &uri, const DataShareValu if (ret) { NotifyChange(uri); RdbSubscriberManager::GetInstance().Emit(uri, context); - SchedulerManager::GetInstance().Execute( - uri, context->currentUserId, context->calledSourceDir, context->version); } return ret; } @@ -83,8 +81,6 @@ int32_t DataShareServiceImpl::Update(const std::string &uri, const DataSharePred if (ret) { NotifyChange(uri); RdbSubscriberManager::GetInstance().Emit(uri, context); - SchedulerManager::GetInstance().Execute( - uri, context->currentUserId, context->calledSourceDir, context->version); } return ret; } @@ -97,8 +93,6 @@ int32_t DataShareServiceImpl::Delete(const std::string &uri, const DataSharePred if (ret) { NotifyChange(uri); RdbSubscriberManager::GetInstance().Emit(uri, context); - SchedulerManager::GetInstance().Execute( - uri, context->currentUserId, context->calledSourceDir, context->version); } return ret; } diff --git a/services/distributeddataservice/service/data_share/strategies/rdb_notify_strategy.cpp b/services/distributeddataservice/service/data_share/strategies/rdb_notify_strategy.cpp index 2c13eb862..ab3c95d87 100644 --- a/services/distributeddataservice/service/data_share/strategies/rdb_notify_strategy.cpp +++ b/services/distributeddataservice/service/data_share/strategies/rdb_notify_strategy.cpp @@ -35,7 +35,7 @@ bool RdbNotifyStrategy::Execute(std::shared_ptr context) return false; } if (context->callerBundleName != context->calledBundleName) { - ZLOGE("not your data, cannot notify, callerBundleName: %{public}s, calledBundleName: %{public}s", + ZLOGD("not your data, cannot notify, callerBundleName: %{public}s, calledBundleName: %{public}s", context->callerBundleName.c_str(), context->calledBundleName.c_str()); return false; } diff --git a/services/distributeddataservice/service/data_share/subscriber_managers/rdb_subscriber_manager.cpp b/services/distributeddataservice/service/data_share/subscriber_managers/rdb_subscriber_manager.cpp index cb8a9059a..59c274ead 100644 --- a/services/distributeddataservice/service/data_share/subscriber_managers/rdb_subscriber_manager.cpp +++ b/services/distributeddataservice/service/data_share/subscriber_managers/rdb_subscriber_manager.cpp @@ -229,6 +229,8 @@ void RdbSubscriberManager::Emit(const std::string &uri, std::shared_ptr Notify(key, context->currentUserId, val, context->calledSourceDir, context->version); return false; }); + SchedulerManager::GetInstance().Execute( + uri, context->currentUserId, context->calledSourceDir, context->version); } std::vector RdbSubscriberManager::GetKeysByUri(const std::string &uri) @@ -255,15 +257,6 @@ void RdbSubscriberManager::EmitByKey(const Key &key, int32_t userId, const std:: }); } -int RdbSubscriberManager::GetCount(const Key &key) -{ - auto pair = rdbCache_.Find(key); - if (!pair.first) { - return 0; - } - return pair.second.size(); -} - int RdbSubscriberManager::GetEnableObserverCount(const Key &key) { auto pair = rdbCache_.Find(key); diff --git a/services/distributeddataservice/service/data_share/subscriber_managers/rdb_subscriber_manager.h b/services/distributeddataservice/service/data_share/subscriber_managers/rdb_subscriber_manager.h index d388c5afa..32f8471e0 100644 --- a/services/distributeddataservice/service/data_share/subscriber_managers/rdb_subscriber_manager.h +++ b/services/distributeddataservice/service/data_share/subscriber_managers/rdb_subscriber_manager.h @@ -60,7 +60,6 @@ public: int Enable(const Key &key, std::shared_ptr context); void Emit(const std::string &uri, std::shared_ptr context); void EmitByKey(const Key &key, int32_t userId, const std::string &rdbPath, int version); - int GetCount(const Key &key); std::vector GetKeysByUri(const std::string &uri); void Clear(); -- Gitee From 6521ac9499a707cbf8fe2532c0a20f209059b41a Mon Sep 17 00:00:00 2001 From: hanlu Date: Wed, 12 Jul 2023 01:35:52 +0800 Subject: [PATCH 2/9] f Signed-off-by: hanlu --- services/distributeddataservice/service/data_share/BUILD.gn | 1 + 1 file changed, 1 insertion(+) diff --git a/services/distributeddataservice/service/data_share/BUILD.gn b/services/distributeddataservice/service/data_share/BUILD.gn index d2245f76f..cbc645f48 100644 --- a/services/distributeddataservice/service/data_share/BUILD.gn +++ b/services/distributeddataservice/service/data_share/BUILD.gn @@ -35,6 +35,7 @@ group("build_module") { } ohos_shared_library("data_share_service") { sources = [ + "common/app_connect_manager.cpp", "common/bundle_mgr_proxy.cpp", "common/db_delegate.cpp", "common/div_strategy.cpp", -- Gitee From 6e2981002c72d91bdd7cd5d8e38d2c0d0b5e567a Mon Sep 17 00:00:00 2001 From: hanlu Date: Wed, 12 Jul 2023 02:00:09 +0800 Subject: [PATCH 3/9] f Signed-off-by: hanlu --- .../service/data_share/common/scheduler_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/distributeddataservice/service/data_share/common/scheduler_manager.cpp b/services/distributeddataservice/service/data_share/common/scheduler_manager.cpp index 67628ee49..e63f070aa 100644 --- a/services/distributeddataservice/service/data_share/common/scheduler_manager.cpp +++ b/services/distributeddataservice/service/data_share/common/scheduler_manager.cpp @@ -64,7 +64,7 @@ void SchedulerManager::SetTimer( // reminder time must is in future auto now = time(nullptr); if (reminderTime <= now) { - ZLOGE("reminderTime is not in future, %{public}" PRId64 "%{public}" PRId64 , reminderTime, now); + ZLOGE("reminderTime is not in future, %{public}" PRId64 "%{public}" PRId64, reminderTime, now); return; } auto duration = std::chrono::seconds(reminderTime - now); -- Gitee From aca8471d1ed0ec4668778f07c546feca2e1cddad Mon Sep 17 00:00:00 2001 From: hanlu Date: Wed, 12 Jul 2023 02:17:12 +0800 Subject: [PATCH 4/9] f Signed-off-by: hanlu --- .../service/data_share/common/extension_mgr_proxy.cpp | 2 +- .../service/data_share/common/extension_mgr_proxy.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/services/distributeddataservice/service/data_share/common/extension_mgr_proxy.cpp b/services/distributeddataservice/service/data_share/common/extension_mgr_proxy.cpp index 8b3454b46..9ee1a361d 100644 --- a/services/distributeddataservice/service/data_share/common/extension_mgr_proxy.cpp +++ b/services/distributeddataservice/service/data_share/common/extension_mgr_proxy.cpp @@ -44,7 +44,7 @@ ExtensionMgrProxy::~ExtensionMgrProxy() std::shared_ptr ExtensionMgrProxy::GetInstance() { - static std::shared_ptr proxy(new ExtensionMgrProxy()); + std::shared_ptr proxy = std::make_shared(); return proxy; } diff --git a/services/distributeddataservice/service/data_share/common/extension_mgr_proxy.h b/services/distributeddataservice/service/data_share/common/extension_mgr_proxy.h index 96d3a41be..d107cde68 100644 --- a/services/distributeddataservice/service/data_share/common/extension_mgr_proxy.h +++ b/services/distributeddataservice/service/data_share/common/extension_mgr_proxy.h @@ -23,13 +23,14 @@ namespace OHOS::DataShare { class ExtensionMgrProxy final : public std::enable_shared_from_this { public: + // do not use + ExtensionMgrProxy() = default; ~ExtensionMgrProxy(); static std::shared_ptr GetInstance(); bool Connect(const std::string &uri, const sptr &connect, const sptr &callerToken); bool DisConnect(sptr connect); private: using Proxy = AAFwk::ExtensionManagerProxy; - ExtensionMgrProxy() = default; class ServiceDeathRecipient : public IRemoteObject::DeathRecipient { public: explicit ServiceDeathRecipient(std::weak_ptr owner) : owner_(owner) -- Gitee From a2943fa0648b303ae2ff874c33c4570f3ab2e4ab Mon Sep 17 00:00:00 2001 From: hanlu Date: Wed, 12 Jul 2023 02:19:01 +0800 Subject: [PATCH 5/9] f Signed-off-by: hanlu --- services/distributeddataservice/service/data_share/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/distributeddataservice/service/data_share/BUILD.gn b/services/distributeddataservice/service/data_share/BUILD.gn index cbc645f48..35f0aa352 100644 --- a/services/distributeddataservice/service/data_share/BUILD.gn +++ b/services/distributeddataservice/service/data_share/BUILD.gn @@ -92,8 +92,8 @@ ohos_shared_library("data_share_service") { external_deps = [ "ability_base:want", "ability_base:zuri", - "ability_runtime:extension_manager", "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", "access_token:libaccesstoken_sdk", "access_token:libtokenid_sdk", "bundle_framework:appexecfwk_base", -- Gitee From 082dbf3b47225f58a0a69fb89ef9b476d1a9261a Mon Sep 17 00:00:00 2001 From: hanlu Date: Wed, 12 Jul 2023 19:54:15 +0800 Subject: [PATCH 6/9] f Signed-off-by: hanlu --- services/distributeddataservice/service/BUILD.gn | 3 --- .../data_share/subscriber_managers/rdb_subscriber_manager.cpp | 3 +++ .../service/test/fuzztest/datashareservicestub_fuzzer/BUILD.gn | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/services/distributeddataservice/service/BUILD.gn b/services/distributeddataservice/service/BUILD.gn index e467c8c75..ff073e3ea 100644 --- a/services/distributeddataservice/service/BUILD.gn +++ b/services/distributeddataservice/service/BUILD.gn @@ -119,9 +119,6 @@ ohos_shared_library("distributeddatasvc") { ] external_deps = [ - "ability_base:want", - "ability_base:zuri", - "ability_runtime:dataobs_manager", "access_token:libaccesstoken_sdk", "access_token:libtokenid_sdk", "c_utils:utils", diff --git a/services/distributeddataservice/service/data_share/subscriber_managers/rdb_subscriber_manager.cpp b/services/distributeddataservice/service/data_share/subscriber_managers/rdb_subscriber_manager.cpp index 59c274ead..9acd29a0c 100644 --- a/services/distributeddataservice/service/data_share/subscriber_managers/rdb_subscriber_manager.cpp +++ b/services/distributeddataservice/service/data_share/subscriber_managers/rdb_subscriber_manager.cpp @@ -293,6 +293,9 @@ int RdbSubscriberManager::Notify(const Key &key, int32_t userId, const std::vect changeNode.templateId_.bundleName_ = key.bundleName; for (const auto &predicate : tpl.predicates_) { std::string result = delegate->Query(predicate.selectSql_); + if (result.empty()) { + continue; + } changeNode.data_.emplace_back("{\"" + predicate.key_ + "\":" + result + "}"); } diff --git a/services/distributeddataservice/service/test/fuzztest/datashareservicestub_fuzzer/BUILD.gn b/services/distributeddataservice/service/test/fuzztest/datashareservicestub_fuzzer/BUILD.gn index e2cbf7fe2..0c3106cfc 100644 --- a/services/distributeddataservice/service/test/fuzztest/datashareservicestub_fuzzer/BUILD.gn +++ b/services/distributeddataservice/service/test/fuzztest/datashareservicestub_fuzzer/BUILD.gn @@ -97,7 +97,7 @@ ohos_fuzztest("DataShareServiceStubFuzzTest") { external_deps = [ "ability_base:want", "ability_base:zuri", - "ability_runtime:ability_manager", + "ability_runtime:extension_manager", "ability_runtime:dataobs_manager", "access_token:libaccesstoken_sdk", "access_token:libtokenid_sdk", -- Gitee From a1927bb2b056907340219e8336598f1241464824 Mon Sep 17 00:00:00 2001 From: hanlu Date: Wed, 12 Jul 2023 20:00:07 +0800 Subject: [PATCH 7/9] f Signed-off-by: hanlu --- .../service/test/fuzztest/datashareservicestub_fuzzer/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/distributeddataservice/service/test/fuzztest/datashareservicestub_fuzzer/BUILD.gn b/services/distributeddataservice/service/test/fuzztest/datashareservicestub_fuzzer/BUILD.gn index 0c3106cfc..e65270f69 100644 --- a/services/distributeddataservice/service/test/fuzztest/datashareservicestub_fuzzer/BUILD.gn +++ b/services/distributeddataservice/service/test/fuzztest/datashareservicestub_fuzzer/BUILD.gn @@ -97,8 +97,8 @@ ohos_fuzztest("DataShareServiceStubFuzzTest") { external_deps = [ "ability_base:want", "ability_base:zuri", - "ability_runtime:extension_manager", "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", "access_token:libaccesstoken_sdk", "access_token:libtokenid_sdk", "bundle_framework:appexecfwk_base", -- Gitee From dca192c9eb9a9a529aa59589972e55800b00934e Mon Sep 17 00:00:00 2001 From: hanlu Date: Wed, 12 Jul 2023 22:20:48 +0800 Subject: [PATCH 8/9] f Signed-off-by: hanlu --- .../service/test/fuzztest/datashareservicestub_fuzzer/BUILD.gn | 1 + 1 file changed, 1 insertion(+) diff --git a/services/distributeddataservice/service/test/fuzztest/datashareservicestub_fuzzer/BUILD.gn b/services/distributeddataservice/service/test/fuzztest/datashareservicestub_fuzzer/BUILD.gn index e65270f69..fc781eb68 100644 --- a/services/distributeddataservice/service/test/fuzztest/datashareservicestub_fuzzer/BUILD.gn +++ b/services/distributeddataservice/service/test/fuzztest/datashareservicestub_fuzzer/BUILD.gn @@ -50,6 +50,7 @@ ohos_fuzztest("DataShareServiceStubFuzzTest") { "${data_service_path}/service/data_share/common/db_delegate.cpp", "${data_service_path}/service/data_share/common/div_strategy.cpp", "${data_service_path}/service/data_share/common/extension_connect_adaptor.cpp", + "${data_service_path}/service/data_share/common/extension_mgr_proxy.cpp", "${data_service_path}/service/data_share/common/kv_delegate.cpp", "${data_service_path}/service/data_share/common/rdb_delegate.cpp", "${data_service_path}/service/data_share/common/scheduler_manager.cpp", -- Gitee From 3abd74a1d44fba6c9d6e9e5c57f5a843826f072a Mon Sep 17 00:00:00 2001 From: hanlu Date: Thu, 13 Jul 2023 04:08:46 +0800 Subject: [PATCH 9/9] f Signed-off-by: hanlu --- .../service/data_share/common/extension_mgr_proxy.cpp | 2 +- .../service/data_share/common/scheduler_manager.cpp | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/services/distributeddataservice/service/data_share/common/extension_mgr_proxy.cpp b/services/distributeddataservice/service/data_share/common/extension_mgr_proxy.cpp index 9ee1a361d..e6081f85b 100644 --- a/services/distributeddataservice/service/data_share/common/extension_mgr_proxy.cpp +++ b/services/distributeddataservice/service/data_share/common/extension_mgr_proxy.cpp @@ -44,7 +44,7 @@ ExtensionMgrProxy::~ExtensionMgrProxy() std::shared_ptr ExtensionMgrProxy::GetInstance() { - std::shared_ptr proxy = std::make_shared(); + static std::shared_ptr proxy = std::make_shared(); return proxy; } diff --git a/services/distributeddataservice/service/data_share/common/scheduler_manager.cpp b/services/distributeddataservice/service/data_share/common/scheduler_manager.cpp index e63f070aa..694771d7d 100644 --- a/services/distributeddataservice/service/data_share/common/scheduler_manager.cpp +++ b/services/distributeddataservice/service/data_share/common/scheduler_manager.cpp @@ -80,8 +80,7 @@ void SchedulerManager::SetTimer( // not find task in map, create new timer auto taskId = executor_->Schedule(duration, [key, dbPath, version, userId, this]() { ZLOGI("schedule notify start, uri is %{private}s, subscriberId is %{public}" PRId64 ", bundleName is " - "%{public}s", - key.uri.c_str(), key.subscriberId, key.bundleName.c_str()); + "%{public}s", key.uri.c_str(), key.subscriberId, key.bundleName.c_str()); timerCache_.erase(key); // 1. execute schedulerSQL in next time Execute(key, userId, dbPath, version); -- Gitee