diff --git a/framework/innerkitsimpl/service/udmf_service_client_virtual.cpp b/framework/innerkitsimpl/service/udmf_service_client_virtual.cpp new file mode 100644 index 0000000000000000000000000000000000000000..738cf41e1ba53689b6357d1bc276f1c9b366d6b0 --- /dev/null +++ b/framework/innerkitsimpl/service/udmf_service_client_virtual.cpp @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2024 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. + */ + +#include "udmf_service_client.h" + +#include "iservice_registry.h" +#include "datamgr_service_proxy.h" +#include "system_ability_definition.h" +#include "unified_data_helper.h" + +#include "logger.h" + +namespace OHOS { +namespace UDMF { +std::shared_ptr UdmfServiceClient::instance_; +std::mutex UdmfServiceClient::mutex_; +sptr UdmfServiceClient::kvDataServiceProxy_; + +UdmfServiceClient::UdmfServiceClient(const sptr &proxy) : udmfProxy_(proxy) +{ + LOG_INFO(UDMF_SERVICE, "construct"); +} + +std::shared_ptr UdmfServiceClient::GetInstance() +{ + return instance_; +} + +UdmfServiceClient::ServiceDeathRecipient::ServiceDeathRecipient() +{ + LOG_INFO(UDMF_SERVICE, "Construct!"); +} + +UdmfServiceClient::ServiceDeathRecipient::~ServiceDeathRecipient() +{ + LOG_INFO(UDMF_SERVICE, "Destruct!"); +} + +void UdmfServiceClient::ServiceDeathRecipient::OnRemoteDied(const wptr &remote) +{ + LOG_WARN(UDMF_SERVICE, "DistributedDataService die!"); + std::lock_guard lockGuard(mutex_); + instance_ = nullptr; +} + +int32_t UdmfServiceClient::SetData(CustomOption &option, UnifiedData &unifiedData, std::string &key) +{ + LOG_DEBUG(UDMF_SERVICE, "start, tag: %{public}d", option.intention); + return udmfProxy_->SetData(option, unifiedData, key); +} + +int32_t UdmfServiceClient::GetData(const QueryOption &query, UnifiedData &unifiedData) +{ + LOG_DEBUG(UDMF_SERVICE, "start, tag: %{public}s", query.key.c_str()); + return E_OK; +} + +int32_t UdmfServiceClient::GetBatchData(const QueryOption &query, std::vector &unifiedDataSet) +{ + LOG_DEBUG(UDMF_SERVICE, "start, tag: intention = %{public}d, key = %{public}s", query.intention, query.key.c_str()); + return E_OK; +} + +int32_t UdmfServiceClient::UpdateData(const QueryOption &query, UnifiedData &unifiedData) +{ + LOG_DEBUG(UDMF_SERVICE, "start, tag: %{public}s", query.key.c_str()); + return udmfProxy_->UpdateData(query, unifiedData); +} + +int32_t UdmfServiceClient::DeleteData(const QueryOption &query, std::vector &unifiedDataSet) +{ + LOG_DEBUG(UDMF_SERVICE, "start, tag: intention = %{public}d, key = %{public}s", query.intention, query.key.c_str()); + return udmfProxy_->DeleteData(query, unifiedDataSet); +} + +int32_t UdmfServiceClient::GetSummary(const QueryOption &query, Summary &summary) +{ + return udmfProxy_->GetSummary(query, summary); +} + +int32_t UdmfServiceClient::AddPrivilege(const QueryOption &query, Privilege &privilege) +{ + return udmfProxy_->AddPrivilege(query, privilege); +} + +int32_t UdmfServiceClient::Sync(const QueryOption &query, const std::vector &devices) +{ + return udmfProxy_->Sync(query, devices); +} +} // namespace UDMF +} // namespace OHOS \ No newline at end of file diff --git a/interfaces/innerkits/BUILD.gn b/interfaces/innerkits/BUILD.gn index 75463f90002d67a75918b4457969014b26d95b0e..b385c8fc1c3fdc935e8fcc512457902e219e575d 100755 --- a/interfaces/innerkits/BUILD.gn +++ b/interfaces/innerkits/BUILD.gn @@ -66,10 +66,17 @@ ohos_shared_library("udmf_client") { "${udmf_framework_path}/innerkitsimpl/data/unified_data_helper.cpp", "${udmf_framework_path}/innerkitsimpl/data/unified_record.cpp", "${udmf_framework_path}/innerkitsimpl/data/video.cpp", - "${udmf_framework_path}/innerkitsimpl/service/udmf_service_client.cpp", "${udmf_framework_path}/innerkitsimpl/service/udmf_service_proxy.cpp", ] + if (udmf_datamgr_service) { + sources += [ + "${udmf_framework_path}/innerkitsimpl/service/udmf_service_client.cpp", + ] + } else { + sources += [ "${udmf_framework_path}/innerkitsimpl/service/udmf_service_client_virtual.cpp" ] + } + public_configs = [ ":udmf_client_config" ] external_deps = [ diff --git a/udmf.gni b/udmf.gni index a38869fa42703459d47dd083bbd32641ebe97a21..17074923d683141ddbaafbd01792594faf635359 100644 --- a/udmf.gni +++ b/udmf.gni @@ -27,8 +27,6 @@ access_kit_path = "//base/security/access_token" arkui_path = "//foundation/arkui" -ddms_path = "//foundation/distributeddatamgr/datamgr_service" - file_service_path = "//foundation/filemanagement/app_file_service" udmf_root_path = "//foundation/distributeddatamgr/udmf" @@ -42,3 +40,16 @@ udmf_service_path = "${udmf_root_path}/service" kv_store_path = "//foundation/distributeddatamgr/kv_store" developer_test_path = "//test/testfwk/developer_test" + +declare_args() { + udmf_datamgr_service = true + + if (defined(global_parts_info) && + !defined(global_parts_info.distributeddatamgr_udmf)) { + udmf_datamgr_service = false + } +} + +if (udmf_datamgr_service) { + ddms_path = "//foundation/distributeddatamgr/datamgr_service" +}